ok, i have following problem:
i want to write my IDT in C
but i get:
-when paging is on 3rd(14) in bochs
-when it's off 3rd(13) in bochs
- __attribute__ ((packed)) doesn't change anything
-i used the part union because the shitfting and logical operations look ugly(imho)
so here is the code, look at it
typedef struct {
unsigned short int Offset1;
unsigned short int Segment;
unsigned short int t;
unsigned short int Offset2;
} intdes;
typedef struct
{
unsigned short limit;
intdes *lIDT;
} IDTR;
typedef union
{
void *p;
unsigned short a;
unsigned short b;
} part;
extern void unhandled();
void setVector(int nr, void *function);
void LIDT();
intdes IDT[256];
IDTR sysreg;
void main()
{
...
for(i=0; i <256; i++)
{
setVector(i, (void *)(unhandled));
}
LIDT();
asm("sti");
...
}
void setVector(int nr, void *function)
{
intdes n;
part p;
p.p = function;
n.Offset1 = p.a;
n.Offset2 = p.b;
n.Segment = 0x8;
n.t = 0x8e00;
IDT[nr] = n;
return;
}
void LIDT()
{
sysreg.limit = 1024;
sysreg.lIDT = IDT;
asm volatile ("lidt _sysreg");
return;
}
thanks
IDT(nobody is answering in the old thread)
Re:IDT(nobody is answering in the old thread)
Hi people, why are you all trying to write all your idts in c? Is older work not working in your implementations? Or is it more robust or something? ???
Re:IDT(nobody is answering in the old thread)
It's easier...but I will have to make my IRQ functions in Asm :-\
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:IDT(nobody is answering in the old thread)
nah. Just the saving/restoring stub need to be written in ASM. Then, you're free to call [C_exception_handlers+eax*4] -- provided that eax is the interrupt number