next up previous contents index
Next: 10.6.4 base_cpu_init: initialize the Up: (X86) Base Environment Previous: 10.6.2 base_vm.h: definitions for

10.6.3 base_cpu_setup: initialize and activate the base CPU environment

   

SYNOPSIS

#include <oskit/machine/base_cpu.h>

void base_cpu_setup(void);

DESCRIPTION

This function provides a single entrypoint to initialize and activate all of the processor structures necessary for ordinary execution. This includes identifying the CPU, and initializing and activating the base GDT, IDT, and TSS, and reloading all segment registers as recommended by Intel. The call returns with the CS segment set to KERNEL_CS (the default kernel code segment; see 10.7.1 for details), DS, ES, and SS set to KERNEL_DS (the default kernel data segment), and FS and GS set to 0. After the base_cpu_setup call completes, a full working kernel environment is in place: segment registers can be loaded, interrupts and traps can be fielded by the OS, privilege level changes can occur, etc.

This function does not initialize or activate the processor's paging mechanism, since unlike the other mechanisms, paging is optional on the x86 and not needed in some environments (e.g., boot loaders or embedded kernels).

The base_cpu_setup function is actually just a simple wrapper that calls base_cpu_init followed by base_cpu_load.

Note that it is permissible to call this function (and/or the more primitive functions it is built on) more than once. This is particularly useful when reconfiguring the kernel memory map. For example, a typical MultiBoot (or other 32-bit) kernel generally starts out with paging disabled, so it must run in the low range of linear/physical memory. However, after enabling page translation, the OS may later want to relocate itself to run at a higher address in linear memory so that application programs can use the low part (e.g., v86-mode programs). An easy way to do this with the OSKit is to call base_cpu_setup once at the very beginning, to initialize the basic unpaged kernel environment, and then later, after paging is enabled and appropriate mappings have been established in high linear address space, modify the linear_base_va variable (Section 10.6.2) to reflect the kernel's new linear address base, and finally call base_cpu_setup again to reinitialize and reload the processor tables according to the new memory map.

DEPENDENCIES

base_cpu_init
10.6.4
base_cpu_load
10.6.5


next up previous contents index
Next: 10.6.4 base_cpu_init: initialize the Up: (X86) Base Environment Previous: 10.6.2 base_vm.h: definitions for

University of Utah Flux Research Group