PIC, IRQs and IDT?
PIC, IRQs and IDT?
I have read a couple of PIC tuts, and it seems like some of them saves the state of the PICs before remapping them. then they restore the state.
Should i do this? What diffrens does it do?
It works fine for me, and i don?t do it at the moment..
/ Christoffer
Should i do this? What diffrens does it do?
It works fine for me, and i don?t do it at the moment..
/ Christoffer
Re:Save state of PICs?
AFAIK you only should do that if you're going to switch to realmode in your OS... (also the BIOS will expect, if you're going to use it though, that the IRQs are placed at the interrupts where it's placed at bootup...)
Anyway, I'm not doing it either, because I really don't think it's neccesary....
Anyway, I'm not doing it either, because I really don't think it's neccesary....
Re:Save state of PICs?
Ok. Then i wont do it until someone tells me to.
Re:PIC, IRQs and IDT?
Hmm. it seemed to work until i did a division with zero on purpose. then it crashed.
i used this tutorial:
http://www.osdever.net/tutorials/interr ... ?the_id=39
and as i am writing my os in asm, my source looks almost exact like it.
i think that the problem lies in my idt, that prob. don?t point to the right place..
how do i find out the correct offset to my interrupt rutines and put it into the code that might look like this:
code from the tut.
maybe someone have another tutorial link?
i used this tutorial:
http://www.osdever.net/tutorials/interr ... ?the_id=39
and as i am writing my os in asm, my source looks almost exact like it.
i think that the problem lies in my idt, that prob. don?t point to the right place..
how do i find out the correct offset to my interrupt rutines and put it into the code that might look like this:
code from the tut.
Code: Select all
start_of_idt:
;first entry
dw 0x0000 ; <-- if i am correct, this would be one of the
; offset parts?
dw 0x10 ; <-- and this would be the gdt segment?
dw 0x8E00 ; <-- hmm, misc info, and enabled bit?
dw 0x20 ; <-- second part off offset?
;second entry
dw 0x0000
dw 0x10
dw 0x8E00
dw 0x30
;third entry
dw 0x0000
dw 0x10
dw 0x8E00
dw 0x10
end_of_idt:
Re:PIC, IRQs and IDT?
Hi,
I can think of a few ways of getting the offsets into the IDT (or GDT). At assembly time you could:
Unfortunately NASM won't let you do "dw theOffset & 0xFFFF" because "theOffset" is a label not a normal number, so you have to add the extra stuff which would need to be defined beforehand. For e.g. at the start of your code put something like:
This should work because subtracting a label from a label leaves a normal number, and ORGADDRESS is also a normal number, so the shift (or and) isn't working on label anymore
Alternatively you could do it at run time:
Cheers,
Brendan
I can think of a few ways of getting the offsets into the IDT (or GDT). At assembly time you could:
Code: Select all
dw (theOffset - CODESTART + ORGADDRESS) & 0xFFFF
dw 0x10
dw 0x8E00
dw (theOffset - CODESTART + ORGADDRESS) >> 16
Code: Select all
%define ORGADDRESS 0x12345678
org ORGADDRESS
bits 32
CODESTART:
Alternatively you could do it at run time:
Code: Select all
; eax Offset for interrupt handler
; bl Interrupt type (0x8F = trap gate, 0x8E = interrupt gate)
; edx Address of IDT entry
makeIDTentry:
push eax
mov [edx],ax
mov word [edx+2],SELECTORkernelCode
shr eax,16
mov byte [edx+4],0x00
mov byte [edx+5],bl
mov [edx+6],ax
pop eax
ret
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re:PIC, IRQs and IDT?
So how do i get "theOffset"?
I take the label at my isr, like "isr01"?
do i need to do something with it or could it look like this:
and:
is that it?
/ Christoffer
I take the label at my isr, like "isr01"?
do i need to do something with it or could it look like this:
Code: Select all
%define ORGADDRESS 0x100000
org ORGADDRESS
bits 32
CODESTART:
Code: Select all
dw (isr01 - CODESTART + ORGADDRESS) & 0xFFFF
dw 0x10
dw 0x8E00
dw (isr01 - CODESTART + ORGADDRESS) >> 16
/ Christoffer
Re:PIC, IRQs and IDT?
Hi,
There's really only one way to know for sure - assemble it, then disassemble it
Cheers,
Brendan
I could say "yes - it'd work", but what if I'm wrong? Stranger things have happened....bubach wrote: I take the label at my isr, like "isr01"?
is that it?
There's really only one way to know for sure - assemble it, then disassemble it
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re:PIC, IRQs and IDT?
Ok, so it didn?t work. or i may have some other problem, becasue i keep getting these "bogus memory"- fault, and bochs dies.
bogus memory.. hm.. i guess that i jumped to some **** place that does not exists?
is this really idt related?
/ Christoffer
bogus memory.. hm.. i guess that i jumped to some **** place that does not exists?
is this really idt related?
/ Christoffer
Re:PIC, IRQs and IDT?
Can somebody take a quick look at this source and tell me what i did wrong and where to find info to fix it.
from the kernel:
I have added my own interrupt nr 32 and tried to call it, but i always get a "bogus memory" or "(3) exception, nr 11"-error. :'(
I have attached my idt.in, isr.inc and pic.inc files in three_in_one.asm.txt
I know that it is mutch to ask for u to read all that, but i would be VERY thankful. Probably i have done something really stupid.
/ Christoffer
from the kernel:
Code: Select all
; Remap PICs.
;--------------
mov cl, 0x20 ; PIC 1.
mov ch, 0x28 ; PIC 2.
call remap_pics ; Remap the PICs.
call disable_irqs ; Disable IRQs for now.
mov dl, 0x0A ; row, 00h -> 18h (0 -> 24)
mov dh, 0x01 ; col, 00h -> 4Fh (0 -> 79)
call setcursorxy ; move it
mov esi, pic_irq
mov al, 0x07 ; "White".
call print
mov dl, 0x0A ; row, 00h -> 18h (0 -> 24)
mov dh, 0x35 ; col, 00h -> 4Fh (0 -> 79)
call setcursorxy ; move it
mov esi, pic_irq_ok
mov al, 0x02 ; Green.
call print
; Setup IDT.
;--------------
lidt [cs:idt_pointer]
sti ; Interrupts back..
mov dl, 0x0B ; row, 00h -> 18h (0 -> 24)
mov dh, 0x01 ; col, 00h -> 4Fh (0 -> 79)
call setcursorxy ; move it
mov esi, idt
mov al, 0x07 ; "White".
call print
mov dl, 0x0B ; row, 00h -> 18h (0 -> 24)
mov dh, 0x35 ; col, 00h -> 4Fh (0 -> 79)
call setcursorxy ; move it
mov esi, idt_ok
mov al, 0x02 ; Green.
call print
I have attached my idt.in, isr.inc and pic.inc files in three_in_one.asm.txt
I know that it is mutch to ask for u to read all that, but i would be VERY thankful. Probably i have done something really stupid.
/ Christoffer
Re:PIC, IRQs and IDT?
Search in the old post ( to when people on this site new asm) under "ASHLEY4" IDT" and you will find my code with all the answers to your ?.
\\\\||////
(@@)
ASHLEY4.
\\\\||////
(@@)
ASHLEY4.
Re:PIC, IRQs and IDT?
I hate this forums search function.
The site admins should rip phpBB?s search function.
I have tried but i can?t find your thread.
The search function even tells me that u haven?t starded ANY post. Gives me "end of result" when i serach for any thread started by ASHLEY4.
*starts looking throw the pages manually*
/ Christoffer
The site admins should rip phpBB?s search function.
I have tried but i can?t find your thread.
The search function even tells me that u haven?t starded ANY post. Gives me "end of result" when i serach for any thread started by ASHLEY4.
*starts looking throw the pages manually*
/ Christoffer
Re:PIC, IRQs and IDT?
Can?t find anything usefull. :'(
Re:PIC, IRQs and IDT?
Try this:
http://www.mega-tokyo.com/forum/index.p ... 53;start=0
You after look under guest's, i left this forum.
\\\\||////
(@@)
ASHLEY4.
http://www.mega-tokyo.com/forum/index.p ... 53;start=0
You after look under guest's, i left this forum.
\\\\||////
(@@)
ASHLEY4.
Re:PIC, IRQs and IDT?
belive me, i didn?t look for only members. i looked for everybody named ashley4.
This forums search function sucks!
why did you leave this forum?
do u have a homepage or something? it would be nice if i could look at all the code, becasue some things seems to be missing in the thread you link to. for example what is 'sys_interrupt'? a label to the start of your isr?s?
thanks for the help!
/ Christoffer
This forums search function sucks!
why did you leave this forum?
do u have a homepage or something? it would be nice if i could look at all the code, becasue some things seems to be missing in the thread you link to. for example what is 'sys_interrupt'? a label to the start of your isr?s?
thanks for the help!
/ Christoffer
Re:PIC, IRQs and IDT?
Give me untill tonight and i will send you a small demo that set up A20,GDT,IDT,remap pic etc and goes to pmode,with code (fasm, may compile with nasm ?).
\\\\||////
(@@)
ASHLEY4.
\\\\||////
(@@)
ASHLEY4.