[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [rtl] interrupt handling




Dear Patrick,
	I have tested the following code on a 486 machine (I'm using IRQ
10). This is a small modification of examples/sound/sound.c file.


/*******************************************************************/

#include <linux/mc146818rtc.h>

#include <rtl_fifo.h>
#include <rtl_core.h>
#include <rtl_time.h>
#include <rtl.h>

#include "PCL_225.h"

unsigned long i,j=0;

/* Interrupt handler - called when ever IRQ 10 is pulled low, and if it is
enabled */

unsigned int intr_handler(unsigned int irq, struct pt_regs *regs) {

	int dat;

 	(void) CMOS_READ(RTC_REG_C);        /* clear IRQ */
	j++;
	for(i=0;i<4097;i++)
	{
	outb_p(0x01,CHIP5_PORT_A);
	outb_p(0x00,CHIP5_PORT_A);
	}
	rtl_hard_enable_irq(10);
	return 0;
}

/* this gets inserted when ever insmod is issued */

int init_module(void)
{

/* Initializations */
	outb_p(0x80,CONTROL_PORT_CHIP5);/* first 8255, all output ports */

	outb_p(0x00,CHIP5_PORT_A);

/* Tell the kernel to branch to function intr_handler(), when ever IRQ 10
occurs. In my PC IRQ 10 line has to be pulled low */

	rtl_request_irq(10, intr_handler);
	rtl_hard_enable_irq(10);
	(void) CMOS_READ(RTC_REG_C);
	rtl_printf("intr module loaded...\n");
	return 0;
}

/* Following gets executed whenever rmmod is issued */

void cleanup_module(void)
{
	rtl_free_irq(10);
	rtl_printf("intr module removed...%u\n",j);
}

/*************************************************************************/

> > I have an ISA board using interrupt 5.  I am trying to set up an interrupt
> > handler for this board that uses system interrupt 13.  The following code
> > was used to do this in dos.
> >
> > /* Port addresses for the 8259A interrupt controller  */
> >
> > #define INT_MASK_PORT           0x0021
> > #define INT_CONTROLLER          0x0020
> > #define SPECIFIC_EOI_IR5        0x0065
> >
> > /******************************************************/
> >
> > void interrupt HS_Int_Handler (...) {
> > .
> > .
> > handler code
> > .
> > .
> > }
> >
> > Orig_Int_13_Handler = dos_getvect (13);
> > _dos_setvect (13, HS_Int_Handler);
> > outportb (INT_MASK_PORT, inportb (INT_MASK_PORT) & ~IRQ_5);
> > outportb (INT_CONTROLLER, SPECIFIC_EOI_IR5);
> > _enable();
> > .
> > .
> > .
> > collect data
> > .
> > .
> > .
> > //Disable interrupt from HS
> > outportb (INT_MASK_PORT, inportb (INT_MASK_PORT) | IRQ_5);
> > _dos_setvect (13, Orig_Int_13_Handler);
> > outportb(INT_CONTROLLER, SPECIFIC_EOI_IR5);
> > _enable
> >
> > How do I do this in rtlinux??
> >
> > Thanks for any help,
> > Patrick
> > -- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail majordomo@rtlinux.org OR
> > echo "unsubscribe rtl <Your_email>" | mail majordomo@rtlinux.org
> > ---
> > For more information on Real-Time Linux see:
> > http://www.rtlinux.org/rtlinux/


***********************************************************************
								      *
RAMESH K, Receiver Engineer					      *
Millimeterwave Observatory	 Ph: +91-80-3340128 ext 447	      *
Raman Research Institute	Fax: +91-80-3340492 Attn Ramesh K     *
Sir C V Raman Avenue						      *
Sadashivanagar							      *
Bangalore - 560 080						      *
India								      *
http://www.rri.res.in						      *
								      *
***********************************************************************