Code: Select all
i32 InterruptEnableMask(PPRIVATE priv, u32 mask){
u8 emask;
emask = inb(PIC1 + IER);
emask = emask & (~mask);
outb(emask, PIC1 + IER);
emask = inb(PIC2 + IER);
emask = emask & (~(mask>>8));
outb(emask, PIC2 + IER);
return IO_SUCCESS;
}
i32 InterruptDisableMask(PPRIVATE priv, u32 mask){
u8 emask;
emask = inb(PIC1 + IER);
emask = emask | mask;
outb(emask, PIC1 + IER);
emask = inb(PIC2 + IER);
emask = emask | (mask>>8);
outb(emask, PIC2 + IER);
return IO_SUCCESS;
}
But the simple command is:
You just masked the interrupts one through eight on the master 8253(PIC). The slave 8253(PIC) is connected to master here:
Code: Select all
mov al, 4
OUT 0x20 + 1, al
mov al, 2
OUT 0xA0 + 1, al
If you mask the interrupt 0x2 for the master 8253 it will completely disable the slave 8253.
In all you have sixteen hardware interrupts to mask or unmask. However only fourteen are actually usable since I think one line on each is used to connected them together, but someone who knows more should answer that.
In my functions above if you look at each function you will notice that I read the current mask from each of the two 8253(PIC)s. Then I apply the transformation on the bits to reflect the changes needed as in: unmask this, or mask that. Then rewrite it to the I/O port.
If you unmask interrupt zero on the master 8253(PIC), or the most least significant bit in the mask, turn on the timer, and fill in the IDT vector 0x20.
idt[0x20].handler..
idt[0x20]....blah
Code: Select all
struct __attribute__ ((__packed__)) titr{
u16 offset_low;
u16 selector;
u16 attr;
u16 offset_high;
};
void it_set(struct titr *ir, u32 index, u32 offset, u16 selector, u16 attr){
unsigned char ah, al;
ir[index].offset_high = offset >> 16;
ir[index].attr = attr | 0x0e00;
ir[index].selector = selector;
ir[index].offset_low = offset & 0xFFFF;
//0xe00
return;
}
I dunno if that will help since you might not know or understand C, but if you do I am sure it would be almost invaluable as I remember when I have tried to get the IDT running it would have been nice to really have something I could check my own work against.