









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










‘anchor00’ ‘anchor01’
‘anchor02’ ‘anchor03’
‘anchor04’ ‘anchor05’
‘anchor06’ ‘anchor07’
Thanks to overnight efforts by Alex Fedosov and our CS support-team!
init
exit
The isr function
The LKM layout
registers the ‘isr’ and then enables the UART device to generate interrupt-signals
disables the UART’s interrupt-signals and then unregisters this module’s ‘isr’
module’s ‘payload’ is just a single callback-function that will ‘handle’ a UART interrupt
the usual pair of module-administration functions
#include <linux/interrupt.h> #include <asm/io.h> #define UART_BASE 0x03F
irqreturn_t my_uart_isr ( int irq, void *dev_id ) { int intr_identify = inb( UART_BASE + 2 ) & 0x0F; if ( intr_identify == 0x01 ) return IRQ_NONE;
if ( intr_identify == 0x04 ) // a new character has arrived outb( inb( UART_BASE ), UART_BASE ); return IRQ_HANDLED; }
#define UART_IRQ 4 // signal-line’s number to the IO-APIC char modname[] = “uartintr”; // kernel displays this in ‘/proc/interrupts’
static int __init my_init ( void ) { … if ( request_irq ( UART_IRQ, &my_uart_isr, IRQF_SHARED, modname, &modname ) < 0 ) return –EBUSY; … // your code to enable the UART’s interrupts goes here … return 0; // SUCCESS }
trigger-level
reserved reserved
DMA Mode select
XMIT FIFO reset
RCVR FIFO reset
enable
Writing 0 will disable the UART’s FIFO-mode, writing 1 will enable FIFO-mode
Writing 1 empties the FIFO, writing 0 has no effect
00 = 1 byte 01 = 4 bytes 10 = 8 bytes 11 = 14 bytes
NOTE: DMA is unsupported for the UART on our systems
Legend: DTR = Data Terminal Ready (1=yes, 0=no) RTS = Request To Send (1=yes, 0=no) OUT1 = not used (except in loopback mode) OUT2 = enables the UART to issue interrupts LOOPBACK-mode (1=enabled, 0=disabled)
static __exit my_exit ( void ) { … // disable any further UART interrupt-requests outb( 0x00, UART_BASE + 1 ); // INTERRUPT_ENABLE outb( 0x00, UART_BASE + 4 ); // MODEM_CONTROL
// remove your UART interrupt-service routine free_irq ( UART_IRQ, modname ); … }