IDT(nobody is answering in the old thread)
Posted: Thu Dec 26, 2002 2:37 am
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
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