something wrong with pic in pmode, please help!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
udarkman

something wrong with pic in pmode, please help!

Post by udarkman »

I tried to reprogram pic but I think I couldnt manage to do it. What is wrong with this code??

I want to handle int8 (timer). Whenever I call int 8 softwarely, it works fine. But I want to do it with IRQ0.
Here is how I initialize pic. And full source is included.Please help:)
...
in al, (PIC8259MASTER + 1)
mov [Old82591Mask], al
in al, (PIC8259SLAVE + 1)
mov [Old82592Mask], al

mov dl, 28h
mov dh, 20h
call InitPic

mov al, 0feh ;just open int8
out (PIC8259MASTER + 1), al
mov al, 0ffh
out (PIC8259SLAVE + 1), al
...

proc InitPic
mov al, 11h
out PIC8259MASTER, al
out PIC8259SLAVE, al

mov al, dh
out PIC8259MASTER+1, al

mov al, dl
out PIC8259SLAVE+1, al

mov al, 4
out PIC8259MASTER+1, al

mov al, 2
out PIC8259SLAVE+1, al

mov al, 1
out PIC8259MASTER+1, al
out PIC8259SLAVE+1, al

ret
endp InitPic

[attachment deleted by admin]
shad

Re:something wrong with pic in pmode, please help!

Post by shad »

idk what all that above is.. its pretty simple..
0x20 = master, 0xA0 = slave.

outportb(0x20, 0x11);
outportb(0xA0, 0x11);

outportb(0x21, 0x20);
outportb(0xA1, 0x28);

outportb(0x21, 0x04);
outportb(0xA1, 0x02);

outportb(0x21, 0x01);
outportb(0xA1, 0x01);

That will remap to ints 32 - 48,
to mask an all ints but the clock:

outportb( 0x21, ~0x1 );
outportb( 0xA1, ~0x0 );

Make sure you send EOI at the end of ur handler (outportb(0x20,0x20); )
udarkman

Re:something wrong with pic in pmode, please help!

Post by udarkman »

if you be carefull, the code you wrote is same as mine but in C. And also Im sure that Im sending EOI at the end of int handler.. Also if there were a problem with EOI, the program would crash at the end of handler. but, 'int8 proc' dont executed even once.
udarkman

Re:something wrong with pic in pmode, please help!

Post by udarkman »

I think I found the problem but couldnt solve. I forgot to set interrupts. But when I set interrupts (sti) after jumping to pmode, the program crashes and restarts computer.:)
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:something wrong with pic in pmode, please help!

Post by distantvoices »

this is because you have mapped your hardware irq to int 0x20 - 0x27 resp. 0x28 - 0x2f.

Think about it: int 8 in asm has the cpu look in the idt at entry '0x08 and execute the code it points to. the hardware triggers int 0x20 upon receipt of a signal on the irq0-line. If you don't have setup proper entries in the idt for int #0x20 - int #0x2f, your computer will triple fault further.

stay safe
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:something wrong with pic in pmode, please help!

Post by Pype.Clicker »

Your problem seems indeed to be in your IDT set up: in pmode, you should have the exception handlers in INT 0 .. INT 1F and *then* the ISR (irq0 => int 0x20, irq1 => int 0x21 ...)

So far your IDT looks like a real-mode interrupt table ...
udarkman

Re:something wrong with pic in pmode, please help!

Post by udarkman »

oh! yes... thanks for helps....
slacker

Re:something wrong with pic in pmode, please help!

Post by slacker »

i find it easier to do my IDT is assembly...
Post Reply