interrupt servicing problems

Jan Kiszka jan.kiszka at web.de
Thu Jul 27 14:12:24 CEST 2006


Geraads/Wiermans/Aerts wrote:
> On do, 2006-07-27 at 11:51 +0200, Jan Kiszka wrote: 
>> Geraads/Wiermans/Aerts wrote:
>>> We have problems getting a isr handler going, we did use some basic code
>>> from "rtai-3.3/addons/drivers/serial" a starting writing a new driver
>>> for our needs.
>> I recommend to check the RTDM interface for this (addons/rtdm): better
>> defined semantics (my believe :)), support for defining clean
>> driver/application interfaces, better portability (architecture-wise and
>> RT-extension-wise).
>>
>> For a usage example you may have a look this new benchmark (not yet
>> adopted by RTAI, AFAIK):
>>
>> http://www.rts.uni-hannover.de/xenomai/lxr/source/ksrc/drivers/testing/irqbench.c
>>
>> Pick out the parts that relate to serial port + RTDM-IRQ (not the I-pipe
>> domain stuff).
> A lot of code for the small thing we want to do, we just want a
> transmitter empty interrupt from the serialport (uart) and service it. 
> You think using this code and stripping it down will do the job?

Ok, I see the issue (it's just that the example is known to work). What
about this:

int irq_handler(rtdm_irq_t *irq_handle)
{
	/* handle IRQ, somehow */

	return RTDM_IRQ_HANDLED;
}

my_init()
{
	...
	err = rtdm_irq_request(&irq_handle, irq_no, irq_handler, 0,
			       "myirq", NULL);
	if (err)
		return err;
	outb(IER_TX, base_io + IER); /* IER_TX = 0x02, IER = 1)
	rtdm_irq_enable(&irq_handle);
	...
}

my_cleanup()
{
	...
	outb(0, base_io + IER);
	rtdm_irq_free(&irq_handle);
	...
}

Detailed information on the API is available as a Doxygen generated doc,
online e.g. at

http://snail.fsffrance.org/www.xenomai.org/documentation/trunk/html/api/group__rtdm.html

> 
>> [The user-space front-end looks like this, BTW:
>> http://www.rts.uni-hannover.de/xenomai/lxr/source/src/testsuite/irqbench/irqloop.c]
>>
>>> I thing we did configured the "isr" handler correct. But the the routine
>>> is never serviced.
>>>
>>> Here the particial code (complete src attached)
>>> Initmodule part:
>>>   #define COM_IRQ 4
>>>   #define BASE_ADR 0x3f8
>>>   static int base_adr = BASE_ADR;
>>>
>>>   // ISR initialise
>>>   rt_disable_irq(COM_IRQ);
>>>   rt_free_global_irq(COM_IRQ);
>> Why releasing an IRQ you haven't acquired yet?
> Indeed it looks superfluous, but we added this line during debugging
> just to try to get it going. 
>>>   // SOME OTHER CODE, UART INIT....!
>>>
>>>   // install irq handler and enable irq
>>>   if(rt_request_global_irq(COM_IRQ, (void*)dti_tx_isr))
>>>   {
>>>      rt_free_global_irq(COM_IRQ);
>> If it failed, you don't have it, so why release it?
> we used the code from 'addons/drivers/serial/' and modified it!

Weird. Sorry for blaming you for this.

> 
>>>      rt_printk("NO COM_IRQ POSSIBLE!\n");
>>>      return -ENODEV;
>>>   }
>>>   if(request_region(base_adr, 8, RTAI_DTIDRV_NAME)==NULL)
>>>   {
>>>     release_region(base_adr,8);
>>>     request_region(base_adr, 8, RTAI_DTIDRV_NAME);
>>>   }
>> Request, release, request? Why?
> we used the code from 'addons/drivers/serial/' and modified it! 

Ok. Note that request_region is a protocol to reserve io regions against
concurrent use. There is no function requirement, it's just a good style
for real drivers.

>>>   rt_startup_irq(COM_IRQ);
>>>   rt_enable_irq(COM_IRQ);
>>>
>>> The uart is initialised correctly, we can see by debugging info thru
>>> rt_kprint that the interrupt flag in the uart is active but the handler
>>> is never serviced!
>>> Can someone help us or give some advice!
>>>
>>> Henk Geraads
>>>
>> Jan
>>
>>
>> PS: Also take care to release the serial port on the Linux side
>> (setserial /dev/ttyS0 uart none).
> Yeah, we did that! 
> 

That's good (I personally tend to forget it).

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://mail.rtai.org/pipermail/rtai/attachments/20060727/8e00f3e7/attachment.pgp 


More information about the Rtai mailing list