Do the first two valid entries in the GDT, for code and data, apply to the kernel?
As in, after I set up the GDT and get into protected mode could I use a plain 32-bit pointer to access any memory location?
Flat memory model in kernel
Re: Flat memory model in kernel
Like any other program, the kernel uses whatever values you put in CS, DS, SS, etc as segment selectors. Whether those represent to a flat memory model or not is up to you.
Re: Flat memory model in kernel
So if the data entry in the GDT ranges from 0 to FFFFF and the privileges are right (and granularity is on) then I should be able to use within the kernel a 32-bit pointer to address up to 4 GB, right?
Unreal mode looks a bit like what I'm asking, except I am unsure about leaving protected mode.
I am confused about how to use memory in protected mode. Surely I don't need to mess with the registers in my C code?
Unreal mode looks a bit like what I'm asking, except I am unsure about leaving protected mode.
I am confused about how to use memory in protected mode. Surely I don't need to mess with the registers in my C code?
Re: Flat memory model in kernel
C code produced by gcc assumes flat memory model in protected mode.
Which means, CS, DS, ES, SS all point to the same memory region, CS is executable, while DS, ES and SS are also writable.
Which means, CS, DS, ES, SS all point to the same memory region, CS is executable, while DS, ES and SS are also writable.
Learn to read.