Skip to content
bruno-masci edited this page Jun 11, 2017 · 4 revisions

Welcome to the brunix wiki!

http://wiki.osdev.org/Memory_Map_%28x86%29

+------------------+ <- 0xFFFFFFFF (4GB) | 32-bit | | memory mapped | | devices | | | //////////\

//////////
| | | Unused | | | +------------------+ <- depends on amount of RAM | | | | | Extended Memory | | | | | +------------------+ <- 0x00100000 (1MB) | BIOS ROM | +------------------+ <- 0x000F0000 (960KB) | 16-bit devices, | | expansion ROMs | +------------------+ <- 0x000C0000 (768KB) | VGA Display | +------------------+ <- 0x000A0000 (640KB) | | | Low Memory | | | +------------------+ <- 0x00000000 Figure from https://pdos.csail.mit.edu/6.828/2014/labs/lab1

The PC starts executing in REAL MODE with CS:IP [0xf000:0xfff0] (physical address 0x000ffff0), an address corresponding to the ROM BIOS. The next thing that the PC does is jump backwards to an earlier location in the BIOS [0xf000:0xe05b].

The BIOS prepares de env and then sets up a temporary stack: mov ss, 0 mov sp, 0x7000 and enables A20 gate (for addressing more than 1Mb of memory)

lidt (Load Interrupt Descriptor Table). Data structure needed to process

hardware and software interrupts.

[f000:d248] 0xfd248: lidtw %cs:0x68f8

lgdt (Load Global Descriptor Table). Data structure used to hold information

about the different memory segments code can access.

[f000:d24e] 0xfd24e: lgdtw %cs:0x68b4

cr0 is a control register that holds various flags.

Specifically what the code here does is that it sets the first bit of cr0 to

1, which enables protected mode.

This instruction switches us to 32-bit mode by changing the code segment.

[f000:d25e] 0xfd25e: ljmpl $0x8,$0xfd266

Initialize the segment registers DS, ES, SS, FS and GS to 0x10.

REFERENCIA: https://github.com/petroav/6.828/blob/master/lab/solutions/lab1.md

Clone this wiki locally