Page 1 of 1
IDT descriptor
Posted: Thu Mar 27, 2003 8:35 pm
by slacker
in a descriptor there are two offsets....how do i use bitshifts to form 2 offsets from one?
Re:IDT descriptor
Posted: Fri Mar 28, 2003 2:29 am
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
Re:IDT descriptor
Posted: Fri Mar 28, 2003 4:47 pm
by slacker
how would i get the address of a function in c?
Re:IDT descriptor
Posted: Sat Mar 29, 2003 11:49 am
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.