Code: Select all
void init_gdt(void) {
struct gdtdesc kcode, kdata, kstack, tcode, tdata, text;
/* initialising segment descriptors*/
//0x8 Code
init_code_desc(0x0, 0xFFFFF, &kcode); //kernel Code segement 0 --> 1 Go
//0x10 Data
init_data_desc(0x0, 0xFFFFF, &kdata); //kernel data segment 0 --> 1 Go
//0x18 kernel Stack
init_gdt_desc(0, 0x10, PRESENT|S|T_STACK, GRANULARITY|D|AVAILABLE, &kstack);
//0x20 video seg
init_gdt_desc(0xB8000, 0xFFFF, 0x92|0x60, 0x0D, &text);
//0x28 task code
init_gdt_desc(0x0, 0xFFFFF, 0x9a, GRANULARITY|D, &tcode);
//0x30 task data
init_gdt_desc(0x0, 0xFFFFF, 0x92, GRANULARITY|D, &tdata);
//adding entries
add_gdt_desc(kcode);
add_gdt_desc(kdata);
add_gdt_desc(kstack);
add_gdt_desc(text);
add_gdt_desc(tcode);
add_gdt_desc(tdata);
kgdtr.limite = GDTSIZE*8;
kgdtr.base = GDTBASE;
...
then I load my GDT ...
Code: Select all
asm("lgdtl (kgdtr)");
asm(" movw $0x10,%ax \n \
movw %ax, %ds \n \
movw %ax, %es \n \
movw %ax, %fs \n \
movw %ax, %gs \n \
movw $0x18,%ax \n \
movw %ax, %ss \n \
movl $0x1FFFF,%esp \n \
nop \n \
nop \n \
ljmp $0x08,$next \n \
next: \n");
when I do this
Code: Select all
//0x18 kernel Stack
init_gdt_desc(0, 0xFFFFF, PRESENT|S|T_STACK, GRANULARITY|D|AVAILABLE, &kstack);
00017286841p[CPU ] >>PANIC<< LEAVE: BP > BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].limit
00017286841i[SYS ] Last time is 17
00017286841i[XGUI ] Exit.
00017286841i[CPU ] protected mode
00017286841i[CPU ] CS.d_b = 32 bit
00017286841i[CPU ] SS.d_b = 32 bit
00017286841i[CPU ] | EAX=00000018 EBX=001083bc ECX=00080800 EDX=00cf9200
00017286841i[CPU ] | ESP=0001ffff EBP=0009efdc ESI=000093bc EDI=00000000
00017286841i[CPU ] | IOPL=0 NV UP DI PL NZ AC PE NC
00017286841i[CPU ] | SEG selector base limit G D
00017286841i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00017286841i[CPU ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00017286841i[CPU ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00017286841i[CPU ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00017286841i[CPU ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00017286841i[CPU ] | SS:0018( 0003| 0| 0) 00000000 0000ffff 1 1
00017286841i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00017286841i[CPU ] | EIP=001006ec (001006eb)
00017286841i[CPU ] | CR0=0x60000011 CR1=0x00000000 CR2=0x00000000
00017286841i[CPU ] | CR3=0x00000000 CR4=0x00000000
00017286841i[ ] restoring default signal behavior