my idt is epic failure

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
anonlalo
Posts: 8
Joined: Sat Mar 05, 2011 9:36 pm

my idt is epic failure

Post by anonlalo »

hi, new to this forum first post :) been reading the wiki and stuff for a while... worked through a bunch of tutorials... I am having trouble at the point of IDT...

I am lost on IDT... it loads correctly, but I am quite sure I'm doing something wrong. my assembler is nasm.

here is my idt.s

Code: Select all

bits 32

global installIDT
extern puts

installIDT:
pusha
lidt [idtr]
popa
ret

startidt:
     dd isr0, 00000000000010001000111000000000b, 0
     dd isr1, 00000000000010001000111000000000b, 0
     < etc, ...>

IDT_END:
idtr:
     dw startidt -IDT_END - 1
     dd startidt

isr0:
pusha
     ;handle interrupt here
popa
sti
iret

isr1:
pusha
     ;handle interrupt here
popa
sti
iret
first i tried this for idt entry:

Code: Select all

dw 0xffff
dw 0x08
db 0
db 10001110b
dw isr0
but it gave me turnication error, which i through process of elimination determined was coming from "dw isr0"

then I tried this line which I found on the forums:

Code: Select all

dw isr0, 8, 1000111000000000b, 0
it gave same error relocation turnicated to fit: r_386_16 against '.text.'

everything assembles and links fine, but when I call an int it crashes...
I have not set the stack in my os, but I booted with grub and the tutorial i looked at also did not set the stack after using grub, so i'm not sure if this is a problem.
I have read the wiki, I have re-read the entire chapter on interupts in the intel manuals, i have searched the forums for "lidt" since "idt assembly" is too common a search string and gives me that error. been trying at this for a good 8 hours can't figure it out.
a5498828
Member
Member
Posts: 99
Joined: Thu Aug 12, 2010 7:25 am

Re: my idt is epic failure

Post by a5498828 »

startidt -IDT_END - 1
wtf
sti
iret
iret will load flags from stack

dd isr1, 00000000000010001000111000000000b, 0
please... have you read osdev wiki?
use dw instead of binary because its unreadable.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: my idt is epic failure

Post by Chandra »

Hi,

there are lots of IDT related stuffs available in the wiki. You may want to have a look at them. There's also an example in the FAQ section which fits best in your case. Thank you.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
anonlalo
Posts: 8
Joined: Sat Mar 05, 2011 9:36 pm

Re: my idt is epic failure

Post by anonlalo »

hey thanks for your quick responses guys:)

I had read the idt stuff in the wiki and every other bit i could find on it elsewhere, but I did not check the FAQ. After first trying a variation of what the FAQ had, and then exactly what it had...

I went and checked my GDT, i had a typo in the access flags:)

I had considered that using mov with shifts would be good, but I knew i couldn't use them in the IDT itself, and I had a passing thought of editing them in memory with a function, but i had dismissed it as inefficient without even considering the insignificance of a few ms at boot-time.

and as to binary being less readable - i find it pretty easy when I know how the data is divided up and i have a binary calculator.. easier than a bunch of shl and shr which have always required alot of thinking and careful planning for me to work with, perhaps it's just my weakness.

anyways thanks again guys I will go back and try my version see if it works with the gdt fixed.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: my idt is epic failure

Post by Combuster »

The linker complains about the fact that you are loading a 16-bit field with a 32-bit address, which obviously does not fit. You will need to split the IDT addresses manually in code since the ELF file format can not do it for you.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply