|
@@ -12,7 +12,7 @@ what happens when an interrupt is triggered and etc. The source code of this dri
|
|
Initialization of a kernel module
|
|
Initialization of a kernel module
|
|
--------------------------------------------------------------------------------
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
-We will start to consider this driver as we usually did it with all new concepts that we saw in this book. We will start to consider it from the intialization. As you already may know, the Linux kernel provides two macros for initialization and finalization of a driver or a kernel module:
|
|
|
|
|
|
+We will start to consider this driver as we usually did it with all new concepts that we saw in this book. We will start to consider it from the initialization. As you already may know, the Linux kernel provides two macros for initialization and finalization of a driver or a kernel module:
|
|
|
|
|
|
* `module_init`;
|
|
* `module_init`;
|
|
* `module_exit`.
|
|
* `module_exit`.
|
|
@@ -194,7 +194,7 @@ In our case we pass `0`, so it will be `IRQF_TRIGGER_NONE`. This flag means that
|
|
static const char serial21285_name[] = "Footbridge UART";
|
|
static const char serial21285_name[] = "Footbridge UART";
|
|
```
|
|
```
|
|
|
|
|
|
-and will be displayed in the output of the `/proc/interrupts`. And in the last parameter we pass the pointer to the our main `uart_port` structure. Now we know a little about `request_irq` function and its parameters, let's look at its implemenetation. As we can see above, the `request_irq` function just makes a call of the `request_threaded_irq` function inside. The `request_threaded_irq` function defined in the [kernel/irq/manage.c](https://github.com/torvalds/linux/blob/16f73eb02d7e1765ccab3d2018e0bd98eb93d973/kernel/irq/manage.c) source code file and allocates a given interrupt line. If we will look at this function, it starts from the definition of the `irqaction` and the `irq_desc`:
|
|
|
|
|
|
+and will be displayed in the output of the `/proc/interrupts`. And in the last parameter we pass the pointer to the our main `uart_port` structure. Now we know a little about `request_irq` function and its parameters, let's look at its implementation. As we can see above, the `request_irq` function just makes a call of the `request_threaded_irq` function inside. The `request_threaded_irq` function defined in the [kernel/irq/manage.c](https://github.com/torvalds/linux/blob/16f73eb02d7e1765ccab3d2018e0bd98eb93d973/kernel/irq/manage.c) source code file and allocates a given interrupt line. If we will look at this function, it starts from the definition of the `irqaction` and the `irq_desc`:
|
|
|
|
|
|
```C
|
|
```C
|
|
int request_threaded_irq(unsigned int irq, irq_handler_t handler,
|
|
int request_threaded_irq(unsigned int irq, irq_handler_t handler,
|
|
@@ -296,7 +296,7 @@ if (new->thread_fn && !nested) {
|
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
-And fill the rest of the given interrupt descriptor fields in the end. So, our `16` and `17` interrupt request lines are registered and the `serial21285_rx_chars` and `serial21285_tx_chars` functions will be invoked when an interrupt controller will get event releated to these interrupts. Now let's look at what happens when an interrupt occurs.
|
|
|
|
|
|
+And fill the rest of the given interrupt descriptor fields in the end. So, our `16` and `17` interrupt request lines are registered and the `serial21285_rx_chars` and `serial21285_tx_chars` functions will be invoked when an interrupt controller will get event related to these interrupts. Now let's look at what happens when an interrupt occurs.
|
|
|
|
|
|
Prepare to handle an interrupt
|
|
Prepare to handle an interrupt
|
|
--------------------------------------------------------------------------------
|
|
--------------------------------------------------------------------------------
|