Page 1 of 1
PIC remapping
Posted: Wed Apr 09, 2003 1:11 pm
by slacker
i seem to be using the same code as everyone else in remapping my IRQ's but of course when i do it an exception fires: gen protection fault int 0D. any ideas why this code that everyone uses is not workin for me?
Code: Select all
#include "port.h"
void map_pics()
{
portoutb(0x20, 0x11); /* ICW1 */
portoutb(0xA0, 0x11);
portoutb(0x21, 0x20); //int 0x20 usually
portoutb(0xA1, 0x28); //int 0x28 usually
portoutb(0x21, 0x04); /* ICW3 */
portoutb(0xA1, 0x02);
portoutb(0x21, 0x01); /* ICW4 */
portoutb(0xA1, 0x01);
};
heres my port out:
Code: Select all
inline void portout(unsigned short port, char data)
{
asm volatile("outb %%al,%%dx"::"d" (port), "a" (data));
};
and another portout function that results in the same error:
Code: Select all
void portoutb(unsigned short port,char data){
asm("movw %0,%%dx\n\
movb %1,%%al\n\
outb %%al,%%dx"::"r" (port), "r" (data):"dx","al");
}
Re:PIC remapping
Posted: Wed Apr 09, 2003 2:17 pm
by slacker
also is there anything i have to do before remapping pics?
Re:PIC remapping
Posted: Wed Apr 09, 2003 2:22 pm
by Whatever5k
Did you disable/unmask the IRQs. If not, it's likely that you get any exception if you don't have an interrupt handler installed for it.
Add this after your map_pics() function (or better: in it):
Code: Select all
portoutb(0x21, 0xFF);
portoutb(0xA1, 0xFF);
Re:PIC remapping
Posted: Wed Apr 09, 2003 2:44 pm
by slacker
why do i have to disable/unmask iRQ's? what does it mean to unmask IRQs? how would i do this?
Re:PIC remapping
Posted: Wed Apr 09, 2003 2:47 pm
by slacker
interrupt handler? whats that?
Re:PIC remapping
Posted: Wed Apr 09, 2003 2:49 pm
by Whatever5k
Disabling an IRQ means to not allow it to interrupt. As far as I remember, the PIC gets the signal but doesn't send it to the CPU. Unmasking an IRQ is another word for disabling it. See [1] for more informations on the PIC. So if you don't unmask/disable an IRQ, you will most likely receive several IRQs (timer, keyboard). Now consider what should happen. Interrupt handler for interrupt 0x20 would be called, that is the timer. I suppose you don't have an interrupt handler for this - therefore, on a IRQ you will receive a GPF since you don't have a handler installed for the appropriate IRQ.
1.
http://users.win.be/W0005997/GI/pic.html
Re:PIC remapping
Posted: Wed Apr 09, 2003 2:59 pm
by slacker
damn abless. your smart. thanks i get it. cause i only wrote ISRs for like the first 14
Re:PIC remapping
Posted: Mon Apr 14, 2003 2:17 pm
by slacker
abless wrote:
Did you disable/unmask the IRQs. If not, it's likely that you get any exception if you don't have an interrupt handler installed for it.
Add this after your map_pics() function (or better: in it):
Code: Select all
portoutb(0x21, 0xFF);
portoutb(0xA1, 0xFF);
that 0xFF stuff just disables IRQs...why would i do this if i wanted to enable them after remapping them?
Re:PIC remapping
Posted: Tue Apr 15, 2003 2:44 pm
by Whatever5k
that 0xFF stuff just disables IRQs...why would i do this if i wanted to enable them after remapping them?
Cannot really follow you here. You want to disable an IRQ if you don't have an interrupt handler for it installed, that's the one and only reason. If you have interrupt handlers installed for *every* IRQ, you needn't disable the IRQs - anyway, I don't think so and that's the reason why I suggest to disable all IRQs at startup and to enable them bit after bit when adding a driver for it.