Protected Mode: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
No edit summary
No edit summary
Line 3: Line 3:
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).
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 [[Non Mascherable Interrupts|NMI]] (as suggested by Intel Developers Manual), optionally enable [[A20 line]], and load the [[Global Descriptor Table]]
Before switch to Protected Mode, you have to disable interrupts and [[Non Mascherable Interrupts|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:
Whether the CPU is in [[Real Mode]] or in protected mode is defined by the lowest bit of the CR0 register. Example:

Revision as of 18:21, 10 December 2007

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