Protected Mode

From OSDev.wiki
Revision as of 00:51, 2 January 2009 by osdev>Lode
Jump to navigation Jump to search

Protected mode is the 32 bit 'native' operating mode of Intel processors (and clones) since the 80386. It allows the developer to work with several virtual address spaces, each of which has a maximum of 4GB of addressable memory and allows the system to enforce strict memory protection as well as restricting the available instruction set (so that your application cannot control the hard disk directly while the kernel can)

Protected mode unleashes the real power of your CPU, so you better get informed about it if you are considering writing an OS. However, it will prevent you from using virtually any of the BIOS interrupts (unless you have a V86 monitor).

Before switch to Protected Mode, you have to disable interrupts and NMI (as suggested by Intel Developers Manual), optionally enable A20 Line, and load the Global Descriptor Table

Whether the CPU is in Real Mode or in protected mode is defined by the lowest bit of the CR0 register. Example:

CLI
LGDT [GDTR]
MOV EAX, CR0
OR AL, 1
MOV CR0, EAX

Immediately after that you have to jump to the code segment in the GDT:

JMP 08h:PModeMain

This takes you to protected mode...

Good Luck

See Also

Articles

External Links