help on enabling pm interrupts, system is resetting
Posted: Thu Jul 05, 2007 1:00 am
hi all,
i'm quite new in os developement, and need some help about enabling inerrupts on a little pm os i'm trying to develope. I'm trying to prepare the PM ivt, as specified in the intel manual, with just the int 0x80, but after enabling interrupts (lidt) and trying to call int 80h the system reset.
This is the bochs output:
and thet is the involved part of my code
every help or suggestion is very appreciated
many thanks,
angelo
i'm quite new in os developement, and need some help about enabling inerrupts on a little pm os i'm trying to develope. I'm trying to prepare the PM ivt, as specified in the intel manual, with just the int 0x80, but after enabling interrupts (lidt) and trying to call int 80h the system reset.
This is the bochs output:
Code: Select all
00001062423d[CPU0 ] interrupt(): vector = 128, INT = 1, EXT = 0
00001062423e[CPU0 ] interrupt(): gate descriptor is not valid sys seg
00001062423d[CPU0 ] exception(0x0D)
00001062423d[CPU0 ] interrupt(): vector = 13, INT = 0, EXT = 1
00001062423e[CPU0 ] interrupt(): gate descriptor is not valid sys seg
00001062423d[CPU0 ] exception(0x0D)
00001062423d[CPU0 ] interrupt(): vector = 8, INT = 0, EXT = 1
00001062423e[CPU0 ] interrupt(): gate descriptor is not valid sys seg
00001062423d[CPU0 ] exception(0x0D)
00001062423i[CPU0 ] protected mode
00001062423i[CPU0 ] CS.d_b = 32 bit
00001062423i[CPU0 ] SS.d_b = 32 bit
00001062423i[CPU0 ] EFER = 0x00000000
00001062423i[CPU0 ] | RAX=00000000000003f8 RBX=000000000000000e
00001062423i[CPU0 ] | RCX=0000000000000000 RDX=0000000000000400
00001062423i[CPU0 ] | RSP=000000000001ffdc RBP=000000000001ffe8
00001062423i[CPU0 ] | RSI=00000000000001ab RDI=00000000000001ab
00001062423i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00001062423i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
00001062423i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00001062423i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00001062423i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF af PF cf
00001062423i[CPU0 ] | SEG selector base limit G D
00001062423i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00001062423i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00001062423i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001062423i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001062423i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001062423i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001062423i[CPU0 ] | GS:0018( 0003| 0| 0) 000b8000 00000f9f 0 0
00001062423i[CPU0 ] | MSR_FS_BASE:0000000000000000
00001062423i[CPU0 ] | MSR_GS_BASE:00000000000b8000
00001062423i[CPU0 ] | RIP=00000000000085a3 (00000000000085a3)
00001062423i[CPU0 ] | CR0=0x00000011 CR1=0x0 CR2=0x0000000000000000
00001062423i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00001062423i[CPU0 ] >> int 0x80 : CD80
Code: Select all
#pragma pack(1)
struct _idt_reg {
ushort size;
ulong base;
} __attribute__ ((aligned(16)));
struct _idt_gate_desc {
ushort offset_procedure_0_15;
ushort segment_selector;
ushort zero:8;
ushort mask:8;
ushort offset_procedure_16_32;
};
#pragma pack()
struct _idt_reg idtr;
static void _fill_idt (ulong int_n, ulong linear_offset)
{
struct _idt_gate_desc igd;
kmemset ((unsigned char *)&igd, 0, sizeof(struct _idt_gate_desc));
igd.offset_procedure_0_15 = (ushort) linear_offset & 0xffff;
igd.segment_selector = (ushort) 0x08;
igd.zero = 0;
igd.mask = 0x8E;
igd.offset_procedure_16_32 = (ushort) ((linear_offset>>16) & 0xffff);
kmemcpy ( _idt_start + ((int_n-1) * 8),
(unsigned char *)&igd,
sizeof(struct _idt_gate_desc)
);
}
void k_load_ivt ()
{
_fill_idt (0x80, (unsigned long)&_int_0x80);
idtr.size = 255*8-1;
idtr.base = 0;
asm ("lidt idtr");
//asm ("sti");
__asm__ __volatile__
(
" pushl $0x01 \n"
" int $0x80 \n"
" addl $4, %esp \n"
);
for (;;);
}
many thanks,
angelo