IDT descriptor

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
slacker

IDT descriptor

Post by slacker »

in a descriptor there are two offsets....how do i use bitshifts to form 2 offsets from one?
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:IDT descriptor

Post by distantvoices »

the two OFFSETS you indicate are the high 16 bits and the low 16 bits of the base adress of the handler pointed to by the descriptor.

say you want to save an adress a into such a descriptor,
you 'll have to do the following:

typedef int (* handler_t)(int);

handler_t b=hwint01;

you pass b to a function tha builds the descriptor:

unsigned long adress;
unsigned short low_base;
unsigned short high_base;
adress=(unsigned long)b;

low_base=adress&0x0000ffff; //only the low 16 bits!
high_base=adress>>16; //only the high 16 bits! - right shift

hope this helps

stay safe
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
slacker

Re:IDT descriptor

Post by slacker »

how would i get the address of a function in c?
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:IDT descriptor

Post by distantvoices »

The name of the function stands for the functions adress, gosh. So, you pass the function name to an other function via function-pointer or via &-operator.

It is like a label in nasm or any other assembler.

to extract the adress you can do either
unsigned long adress = (unsigned long)&your_function

or

(void *t)(int)=your_function; //to build a pointer to the function.
unsigned long adress =(unsigned long)t;

Still un-clear?

If someone finds mistakes pls tell & correct.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
Post Reply