Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
struct IDT_entry{
unsigned short int offset_lowerbits;
unsigned short int selector;
unsigned char zero;
unsigned char type_attr;
unsigned short int offset_higherbits;
};
Can the "gdt_code" label in the GDT table be used instead?
gdt_start:
dq 0x00 ; 8 null bytes here
gdt_code: ; so here's the "kernel code segment selector" ?
dw 0xFFFF
dw 0x0000
db 0x00
db 10011010b
db 11001111b
db 0x00
.gdt_data: ; and the "kernel data segment selector" ?
dw 0xFFFF
dw 0x0000
db 0x00
db 10010010b
db 11001111b
db 0x00
gdt_end:
; GDT descriptor
gdt_descriptor:
dw gdt_end - gdt_start - 1
dd gdt_start
growlnx wrote:This offset is in relation to the beginning of the GDT table, right?
That's a selector. The offset is encoded using the upper 13 bits of the selector, and some other information goes in the lower 3 bits. The lower 3 bits are all zero for ring 0 GDT segments, so your selectors are equal to the offset, but that's not true for all selectors.
For example, if you add a ring 3 descriptor at offset 0x18 in your GDT, you'll probably use the selector 0x1B to access it.
growlnx wrote:This offset is in relation to the beginning of the GDT table, right?
That's a selector. The offset is encoded using the upper 13 bits of the selector, and some other information goes in the lower 3 bits. The lower 3 bits are all zero for ring 0 GDT segments, so your selectors are equal to the offset, but that's not true for all selectors.
For example, if you add a ring 3 descriptor at offset 0x18 in your GDT, you'll probably use the selector 0x1B to access it.