next up previous contents index
Next: 10.14.4 Command-line arguments Up: (X86 PC) MultiBoot Startup Previous: 10.14.2 Startup sequence

10.14.3 Memory model

 

Once the OS kernel receives control in its main routine, the processor has been set up in the base environment defined earlier in Section 10.6. The base_gdt, base_idt, and base_tss have been set up and activated, so that segmentation operations work and traps can be handled. Paging is disabled, and all kernel code and data segment descriptors are set up with an offset of zero, so that virtual addresses, linear addresses, and physical addresses are all the same. The client OS is free to change this memory layout later, e.g., by enabling paging and reorganizing the linear address space as described in Section 10.6.3.

As part of the initialization performed by multiboot_main, the OSKit's MultiBoot startup code uses information passed to the OS by the boot loader, describing the location and amount of physical memory available, to set up the malloc_lmm memory pool (see Section 9.5.1). This allows the OS kernel to allocate and manage physical memory using the normal C-language memory allocation mechanisms, as well as directly using the underlying LMM memory manager library functions. The physical memory placed on the malloc_lmm pool during initialization is guaranteed not to contain any of the data structures passed by the boot loader which the OS may need to use, such as the command line or the boot modules; this way, the kernel can freely allocate and use memory right from the start without worrying about accidentally ``stepping on'' boot loader data that it will need to access later on. In addition, the physical memory placed on the malloc_lmm is divided into the three separate regions defined in phys_lmm.h (see Section 10.11.1): one for low memory below 1MB, one for ``DMA'' memory below 16MB, and one for all physical memory above this line. This division allows the kernel to allocate ``special'' memory when needed for device access or for calls to real-mode BIOS routines, simply by specifying the appropriate flags in the LMM allocation calls.


next up previous contents index
Next: 10.14.4 Command-line arguments Up: (X86 PC) MultiBoot Startup Previous: 10.14.2 Startup sequence

University of Utah Flux Research Group