forked from cirosantilli/x86-bare-metal-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paging.S
53 lines (39 loc) · 1.09 KB
/
paging.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
# Paging
Expected output:
00001234
00005678
Verbose beginner's tutorial: http://www.cirosantilli.com/x86-paging/
Keep the following Intel shorthands in mind:
- PTE: Page table
- PDE: Page directory
- PDPTE: Page-directory-
*/
#include "common.h"
BEGIN
CLEAR
STAGE2
PROTECTED_MODE
SETUP_PAGING_4M
/* Setup a test canary value. */
movl $0x1234, 0x1000
/* Print the canary to make sure it is really there. */
VGA_PRINT_HEX_4 0x1000
/* Make page 0 point to 4KiB. */
orb $0x10, page_table + 1
PAGING_ON
/*
THIS is what we've been working for!!!
Even though we mov to 0, the paging circuit reads that as physical address 0x1000,
so the canary value 0x1234 should be modified to 0x5678.
*/
movl $0x5678, 0
/*
Turn paging back off to prevent it from messing with us.
Remember that VGA does memory accesses, so if paging is still on,
we must identity map up to it, which we have, so this is not mandatory.
*/
PAGING_OFF
/* Print the (hopefully) modified value 0x5678. */
VGA_PRINT_HEX_4 0x1000
jmp .