Files
x86-bare-metal-examples/protected_mode.S

40 lines
1.1 KiB
ArmAsm
Raw Normal View History

2015-10-04 19:59:15 +02:00
/*
# Protected mode
2015-10-18 14:56:12 +02:00
Major changes from real moe:
2015-10-06 12:27:24 +02:00
- BIOS cannot be used anymore
2015-10-18 14:56:12 +02:00
- GDT and segmentation take effect immediately so we *have*
to deal with it now.
2015-10-06 12:27:24 +02:00
2015-10-18 14:56:12 +02:00
- we have to encode instructions differently, thus a `.code32` is needed.
Note that in 16-bit, 32-bit instructions were encodable, but with a prefix.
2015-10-06 12:27:24 +02:00
2015-10-27 09:04:46 +01:00
## Linux kernel
arch/x86/include/asm/segment.h contains a lot of action:
- the user privilege level
- the segment steup (kernel an user code and data segments)
## Bibliography
2015-10-04 19:59:15 +02:00
2015-10-18 14:56:12 +02:00
- http://stackoverflow.com/questions/28645439/how-do-i-enter-32-bit-protected-mode-in-nasm-assembly Initially adapted from this.
2015-10-04 19:59:15 +02:00
- http://wiki.osdev.org/Journey_To_The_Protected_Land
- http://wiki.osdev.org/Protected_Mode
- https://github.com/chrisdew/xv6/blob/master/bootasm.S
- https://thiscouldbebetter.wordpress.com/2011/03/17/entering-protected-mode-from-assembly/ FASM based. Did not word on first try, but looks real clean.
- http://skelix.net/skelixos/tutorial02_en.html
2015-10-04 19:59:15 +02:00
*/
#include "common.h"
2015-10-18 14:56:12 +02:00
BEGIN
CLEAR
2015-10-18 14:56:12 +02:00
PROTECTED_MODE
VGA_PRINT_STRING $message
jmp .
2015-10-18 14:56:12 +02:00
message:
.asciz "hello world"