You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Chapter-8/README.md
+23-3Lines changed: 23 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,9 @@ In a paged system, each process may execute in its own 4gb area of memory, witho
21
21
The translation of a linear address to a physical address is done in multiple steps:
22
22
23
23
1. The processor use the registry `CR3` to know the physical address of the pages directory.
24
-
2. The first 10 bytes of the linear address represent an offset (between 0 and 1023), pointing to an entry in the pages directory. This entry contains the physical address of a pages table.
25
-
3. the next 10 bytes of the linear address represent an offset, pointing to an entry in the pages table. This entry is pointing to a 4ko page.
26
-
4. The last 12 bytes of the linear address represent an offset (between 0 and 4095), which indicates the position in the 4ko page.
24
+
2. The first 10 bits of the linear address represent an offset (between 0 and 1023), pointing to an entry in the pages directory. This entry contains the physical address of a pages table.
25
+
3. the next 10 bits of the linear address represent an offset, pointing to an entry in the pages table. This entry is pointing to a 4ko page.
26
+
4. The last 12 bits of the linear address represent an offset (between 0 and 4095), which indicates the position in the 4ko page.
27
27
28
28

29
29
@@ -44,4 +44,24 @@ The two types of entries (table and directory) look like the same. Only the fiel
44
44
* 0 = 4ko
45
45
* 1 = 4mo
46
46
47
+
**Note:** Physical addresses in the pages diretcory or pages table are written using 20 bits because these addresses are aligned on 4ko, so the last 12bits should be equal to 0.
48
+
49
+
* A pages directory or pages table used 1024*4 = 4096 bytes = 4k
50
+
* A pages table can address 1024 * 4k = 4 Mo
51
+
* A pages directory can address 1024 * (1024 * 4k) = 4 Go
52
+
53
+
#### How to enable pagination?
54
+
55
+
To enable pagination, we just need to set bit 31 of the `CR0`registry to 1:
56
+
57
+
```asm
58
+
asm(" mov %%cr0, %%eax; \
59
+
or %1, %%eax; \
60
+
mov %%eax, %%cr0" \
61
+
:: "i"(0x80000000));
62
+
```
63
+
64
+
But before, we need to initialize our pages directory with at least one pages table.
0 commit comments