View Single Post

  #4 (permalink)  
Old 12-11-2007, 06:28 PM
kkumarp kkumarp is offline
Junior Member
User
 
Join Date: Dec 2007
My distro: SUSE
Posts: 1
Rep Power: 0
kkumarp is on a distinguished road
Question How to disable/enable interrupts permanently in linux

Hi,
I want to mask some hardware interrupts (selectively).
I'm using below code to mask interrupt 10.

#include <stdio.h>
#include <stdlib.h>
#include <sys/io.h>
int main()
{
int slave;
//Change the IO privilege level of current process.
if (iopl(3) < 0)
{
perror("cannot get i/o privileges");
return 1;
}
slave = 0;
slave = inb_p(0xA1); //get the contents of Interrupt Mask Regester (IMR)
printf("Before changing...\n");
printf("IMR :: %x\n",slave);
slave |= 0x4; //Mask interrupt 10
outb_p(slave,0xA1); //write new flag to IMR
slave = 0;
slave = inb_p(0xA1); //get the contents of Interrupt Mask Regester (IMR)
printf("After changing...\n");
printf("IMR :: %x\n",slave);
sleep(5); //Sleep for 5 seconds
printf("After sleep...\n");
printf("IMR :: %x\n",slave);
return 0;
}

This is user level application. It first changes the privilege level from 0 to 3. Then reads the contents of Interrupt Mask Register (IMR), which contains the status of interrupts 8 to 15. It then sets bit 3 (interrupt 10) and rewrites the value back to IMR.
When I run the application, it change the mask in IMR. But the mask gets reset to old value immediately, before exiting from the application. I want to keep the new mask till the completion of application.
Can anybody help me, how to do this?

Last edited by kkumarp; 12-11-2007 at 08:51 PM..
Reply With Quote