hiw to set selector in the IDT

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
matan
Posts: 13
Joined: Sat May 02, 2015 4:15 am
Libera.chat IRC: matan

hiw to set selector in the IDT

Post by matan »

I want to write c code that loads my idt table. (Using inline asm) i know how to fill all of the info for each entry except the selector, as far as i understanding it is the code segment for my handler , but how do i get the code segment for the handler in C ?
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: hiw to set selector in the IDT

Post by iansjack »

That's easy. The code selector is whatever you choose to set it to. C doesn't set it, you do.
matan
Posts: 13
Joined: Sat May 02, 2015 4:15 am
Libera.chat IRC: matan

Re: hiw to set selector in the IDT

Post by matan »

so what should i set it ? is it important ? will my handler be called no matter what value of selector i use ?
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: hiw to set selector in the IDT

Post by iansjack »

Well, at what address are you running the code? (Where have you loaded it?) And what segment selectors have you defined in your GDT? You surely must know what selector you want to use for kernel code.

Really, this is very basic stuff and (at the risk of offending those who think I am being rude for not writing you a tutorial on memory addressing in the x86 processor) I'm not going to engage any longer with this question.
matan
Posts: 13
Joined: Sat May 02, 2015 4:15 am
Libera.chat IRC: matan

Re: hiw to set selector in the IDT

Post by matan »

sorry for being stupid , i got confused with memory segmentation , both GDT entries and memory 64k chunks are called "segments".
Post Reply