src/gdt.c
/* Should be called by main. This will setup the special GDT
*  pointer, set up the first 3 entries in our GDT, and then
*  finally call gdt_flush() in our assembler file in order
*  to tell the processor where the new GDT is and update the
*  new segment registers */
Should be called by main. This will setup the special GDT
pointer, set up the first 3 entries in our GDT, and then
finally call gdt_flush() in our assembler file in order
to tell the processor where the new GDT is and update the
new segment registers
Should be called by main . This will setup the special GDT pointer set up the first 3 entries in our GDT and then finally call gdt_flush () in our assembler file in order to tell the processor where the new GDT is and update the new segment registers
void gdt_install()
{
    gp.limit = (sizeof(struct packed_entry) * 3) - 1;
    gp.base = gdt;
    gdt_set_gate(0, new_gdt_entry(0, 0, 0, 0, 0, 0, 0));
    gdt_set_gate(1, new_gdt_entry(
                    0x0000000,     
                    0x0100,        
                    KERNELPRIV,
                    TIGHTCTRL,
                    CANRW,
                    CODEMODE,
                    PAGEGRAN
                    )
                );
    gdt_set_gate(2, new_gdt_entry(
                    0x00000000,     
                    0x0100,         
                    KERNELPRIV,
                    TIGHTCTRL,
                    CANRW,
                    DATAMODE,
                    PAGEGRAN
                    )
                );
    gdt_flush();
}
void gdt_install ( ) { gp . limit = ( sizeof ( struct packed_entry ) * 3 ) - 1 ; gp . base = gdt ; gdt_set_gate ( 0 , new_gdt_entry ( 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ) ; gdt_set_gate ( 1 , new_gdt_entry ( 0x0000000 , 0x0100 , KERNELPRIV , TIGHTCTRL , CANRW , CODEMODE , PAGEGRAN ) ) ; gdt_set_gate ( 2 , new_gdt_entry ( 0x00000000 , 0x0100 , KERNELPRIV , TIGHTCTRL , CANRW , DATAMODE , PAGEGRAN ) ) ; gdt_flush ( ) ; }
Should be called by main.
Should be called by main .
/* Setup the GDT pointer and limit */ /* Our NULL descriptor */ /* Code segment */ // at 16MiB normally // Until 8GiB /* Data segment */ // at 0MiB // Until 8GiB /* Flush out the old GDT and install the new changes! */