I have a doubt in "The Global Descriptor Table", I am go throughing the tutorial written by "Jamesmolloy", which describes how to load GDT in kernel code. Please refer the below link for more information
http://www.jamesmolloy.co.uk/tutorial_h ... 20IDT.html
GDT loaded as below
Code: Select all
gdt_set_gate(0, 0, 0, 0, 0); // Null segment
gdt_set_gate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF); // Code segment
gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); // Data segment
gdt_set_gate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF); // User mode code segment
gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF); // User mode data segment
Code: Select all
[GLOBAL gdt_flush] ; Allows the C code to call gdt_flush().
gdt_flush:
mov eax, [esp+4] ; Get the pointer to the GDT, passed as a parameter.
lgdt [eax] ; Load the new GDT pointer
mov ax, 0x10 ; 0x10 is the offset in the GDT to our data segment
mov ds, ax ; Load all data segment selectors
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x08:.flush ; 0x08 is the offset to our code segment: Far jump!
.flush:
ret
Here are my doubts:
1. Once the below code is executed, what the processor will understand?
Code: Select all
lgdt [lgdt_offset] ; Load the new GDT pointer
3. Once we load the CS register with 0x08, whether it will look for the physical address 0x08 or the GDT offset at 0x08
4. In case, if CS register value always refers to one of the GDT entry (in SEGMENTED memory) then, in case of PAGE memory system how it will be?
Sorry if I have confused you.