Check out the new USENIX Web site. next up previous
Next: FreeBSD ACPI Sleeping States Up: FreeBSD ACPI Power States Previous: FreeBSD ACPI Power States

I386 Background

To understand ACPI power states, it is important to be familiar with i386 CPU architecture and CPU initialization. All i386 CPUs support ``real mode.'' Real mode is a CPU state that is compatible with the old i8086 processor. In this mode each memory access pointer, including the instruction pointer, is 16 bits long. This provides a 64KB address space. Segment registers are used to extend the memory address space that can be referenced and also to separate the code, data, and stack areas. To convert a segment-based address into a physical address, take the segment register value and shift it left four bits and add it to the address. The extra four bits from the segment register allow us to reference up to 1MB of physical memory. There are six segment registers: CS, DS, SS, ES, FS and GS. The code segment register (CS) is used when accessing instructions through the instruction pointer. When accessing data memory, the data segment register (DS) is used by default. Stack operations use the stack segment register (SS).

When booting, the BIOS firmware passes program control to software in real mode, as described above. Most modern operating systems do not operate in real mode. Instead, they change the working mode from real mode to ``protected mode.'' To switch to the protected mode, the kernel must set up the GDTR register and update control register CR0. The GDTR register points to the global descriptor table (GDT). The GDT is used for address translation in protected mode.

In protected mode, segment registers and some special registers, such as TR (Task register), point to an entry in the GDT. This entry is then used when translating addresses. The current mode of the CPU is determined by the mode-select flag in the CR0 register. Once the system is in protected mode, kernels that wish to use paging for virtual memory must enable it. To enable paging, the kernel has to set the CR3 register to point to the page table structures to use and then change the mode flag in the CR0 register.


next up previous
Next: FreeBSD ACPI Sleeping States Up: FreeBSD ACPI Power States Previous: FreeBSD ACPI Power States
Takanori Watanabe 2002-04-13