Protected Mode: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
m (Syntax higlighting)
m (Categorised)
Line 36: Line 36:


[[Category:X86 CPU]]
[[Category:X86 CPU]]
[[Category:Operating Modes]]

Revision as of 16:00, 20 December 2009

Protected mode is the 'native' operating mode of Intel processors (and clones) since the 80286. On 80386s and later, 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 or MSW 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