i have written a kernel module for my 2.6.23.1 patched with rtai
the file is as follows:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/stddef.h>
#include <linux/ioport.h>
#include <linux/types.h>
#include <asm/io.h>
#include <rtai.h>
#include <rtai_sched.h>
#include <rtai_fifos.h>
#define FIFO 0
#define SERPORT 0x3f8
static void handler()
{
int y,i=1;
rt_printk("\n interrupted now \n");
for(;i<=14; i++)
{
y=inb(SERPORT);
rtf_put(FIFO, &y, sizeof(y));
rt_printk("%d ",y);
}
rt_ack_irq(4);
}
int init_module(void)
{
rt_printk("...................................start..................................\n\n");
int ret;
rt_free_global_irq(4); // freeing this first may not need to do this
rt_printk("\nmodule inserted\n");
ret = rt_request_global_irq(4, (void *)handler);
if (ret) { printk ("\n\n##### error requesting irq 4: returned %d\n", ret); }
rt_enable_irq(4);
outb_p(0x83, SERPORT + 3); // set DLAB
outb_p(0x0c, SERPORT); // set baud rate to 9600
outb_p(0x00, SERPORT+1);
outb_p(((0x83)&(0x7f)), SERPORT + 3); //reset DLAB
outb_p(0x05,SERPORT + 1); //enable serial port interrupt
outb_p(0x07,SERPORT + 2); // fifo control register enable fifos, clear rx & tx fifo, set intr. trigger to 14 bytes
rt_set_oneshot_mode();
rtf_create(FIFO,1024);
rt_printk("\ntimer started\n");
rt_printk("\n interrupt indentification register %x \n", inb(SERPORT + 2));
start_rt_timer(1);
}
void cleanup_module(void)
{
stop_rt_timer();
rtf_destroy(FIFO);
rt_free_global_irq(4);
printk("\nReal Time Task Destroyed");
printk("\nModule cleanup");
}
MODULE_LICENSE("GPL");
the dmesg output shows:
module inserted
timer started
(IIR) interrupt indentification register c1
contents of IIR register indicates that fifos ARE ENABLED.....
however when i send data from my atmega 8535 board at a baud rate of 9600, no interrupts are generated the control never goes to the handler.
outputs of files in /proc directory:
interrupts:\
CPU0 CPU1
0: 254 0 IO-APIC-edge timer
1: 2258 0 IO-APIC-edge i8042
7: 1 0 IO-APIC-edge parport0
8: 1 0 IO-APIC-edge rtc
9: 1 0 IO-APIC-fasteoi acpi
12: 28074 0 IO-APIC-edge i8042
14: 16336 0 IO-APIC-edge libata
15: 8780 0 IO-APIC-edge libata
16: 1954 0 IO-APIC-fasteoi ehci_hcd:usb1, uhci_hcd:usb2
17: 0 0 IO-APIC-fasteoi uhci_hcd:usb3
18: 0 0 IO-APIC-fasteoi uhci_hcd:usb4
19: 301 0 IO-APIC-fasteoi uhci_hcd:usb5, HDA Intel, i915@pci:0000:00:02.0
20: 25787 0 IO-APIC-fasteoi eth0
NMI: 0 0
LOC: 546731 586187
ERR: 0
MIS: 0
~
ioports:
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
0060-006f : keyboard
0070-0077 : rtc
0080-008f : dma page reg
00a0-00a1 : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : 0000:00:1f.2
0170-0177 : libata
01f0-01f7 : 0000:00:1f.2
01f0-01f7 : libata
02f8-02ff : serial
0376-0376 : 0000:00:1f.2
0376-0376 : libata
0378-037a : parport0
03c0-03df : vga+
03f6-03f6 : 0000:00:1f.2
03f6-03f6 : libata
03f8-03ff : serial
0400-047f : 0000:00:1f.0
0400-0403 : ACPI PM1a_EVT_BLK
0404-0405 : ACPI PM1a_CNT_BLK
0408-040b : ACPI PM_TMR
0410-0415 : ACPI CPU throttle
0428-042f : ACPI GPE0_BLK
0460-047f : iTCO_wdt
0480-04bf : 0000:00:1f.0
0500-051f : 0000:00:1f.3
0500-051f : i801_smbus
0cf8-0cff : PCI conf1
a000-afff : PCI Bus #01
a000-a0ff : 0000:01:05.0
a000-a0ff : skge
b000-b01f : 0000:00:1d.0
b000-b01f : uhci_hcd
b400-b41f : 0000:00:1d.1
b400-b41f : uhci_hcd
b800-b81f : 0000:00:1d.2
b800-b81f : uhci_hcd
bc00-bc1f : 0000:00:1d.3
bc00-bc1f : uhci_hcd
i see that there is no line in the interrupts file for serial port.
however when i do setserial /dev/ttyS0 i get
[root@localhost proc]# setserial /dev/ttyS0
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
why is the interrupt not being generated kindly guide me....