User:Nedbrek/mmap
Jump to navigation
Jump to search
In the constrained environment of assembly language programming, it is important to have a clear picture of where everything is in memory:
Range | Area |
---|---|
0_0000..0_03FF | Real mode IDT (reclaimable) |
0_0400..0_04FF | BIOS low data (reclaimable) |
0_0500..0_7BFF | boot stack (30,464 bytes) |
0_7C00..0_7DFF | boot sector (512 bytes) |
0_7E00..3_FFFF | available |
4_0000..4_FCFF | boot output block (BOB) |
4_FD00..4_FFFF | video config scratchpad (reclaimable) |
5_0000..5_FFFF | GDT+IDT |
6_0000..6_FFFF | stage 1 page tables |
7_0000..7_FFFF | output of BIOS memory map (INT 15/E820) |
8_0000..9_FBFF | possible BIOS EDA |
9_FC00..9_FFFF | definite BIOS EDA |
A_0000..F_FFFF | ROM |
struct Bob /// Boot Output Block
{
DWord bootDisk; // drive letter stored in DX by the BIOS
DWord vgaWidth; // (pixels)
DWord vgaHeight; // (pixels)
DWord vgaBpp; // bits per pixel
DWord vgaLfbp; // address of the linear frame buffer
DWord vgaCaps; // mode attributes (offset 0 of the get mode structure)
DWord vgaMode; // value passed to INT 10/4F01 (BIOS set video mode)
};
Memory is grouped into 64KB segments (to take advantage of an assembler trick for zeroing it).
Bootl delivers us directly to 64 bit mode, thus each PTE is 8 bytes. That allows for 512 PTEs per 4KB page, with 16 pages in the one segment allocated for the task.
They are:
Number | Description |
---|---|
0 | PML4 (root page table, VA[47:39]) |
1 | PDP (page directory pointers, VA[38:30]) |
2 | PDE (page directory entry, VA[29:21] - good for 2M pages positioned from 0 to 1GB) |
3-15 | available |