aboutsummaryrefslogtreecommitdiff
path: root/arch/i386/paging.h
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2024-03-08 17:24:49 +0200
committeraqua <aqua@iserlohn-fortress.net>2024-03-08 22:00:07 +0200
commit20b97ea7c0dbbdc13800e12ff5c86c00c4a342ec (patch)
tree473281e5fc8b256827ce1a678573444e1aa5f669 /arch/i386/paging.h
parentGenerate src/conf.h (diff)
downloadkernel-20b97ea7c0dbbdc13800e12ff5c86c00c4a342ec.tar.xz
Bazel build
Diffstat (limited to 'arch/i386/paging.h')
-rw-r--r--arch/i386/paging.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/arch/i386/paging.h b/arch/i386/paging.h
new file mode 100644
index 0000000..f5bfa78
--- /dev/null
+++ b/arch/i386/paging.h
@@ -0,0 +1,59 @@
+#pragma once
+
+/* DirectoryEntry
+ * |31| | | | | | | | | | | | | | | | | | | |11| | 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
+ * | page table 4-kb aligned address | avail | G| S| | A| C| W| U| R| P| */
+struct __attribute__((packed)) DirectoryEntry {
+ unsigned present : 1; /* 0: if set, the page is actually in physical memory */
+ unsigned writeable : 1; /* 1: if set, the page is read/write; otherwise the page is read-only */
+ unsigned user : 1; /* 2: if set, then page can be access by all; otherwise only the supervisor can access it */
+ unsigned writethrough : 1; /* 3: if set, write-through caching is enabled; otherwise write-back is enabled instead */
+ unsigned cachedisable : 1; /* 4: if set, the page will not be cached */
+ unsigned accessed : 1; /* 5: set by the CPU when the page is read from or written to */
+ unsigned dirty : 1; /* 6: used to determine whether a page has been written to */
+ unsigned pagesize : 1; /* 7: page size == 0 */
+ unsigned global : 1;
+ unsigned int __available__ : 3; /* available to the OS */
+ unsigned int address : 20;
+};
+/* TODO _Static_assert(sizeof(struct DirectoryEntry) == 4, "DirectoryEntry size"); */
+
+/* DirectoryEntry4MB
+ * |31| | | | | | | | |22|21|20| | | | | | |13|12|11| | 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
+ * | bits 31-22 of address |RS| bits 39-22 of |AT| avail | G|PS| D| A|CD|WT|US|RW| P|
+ * | |VD| address */
+struct __attribute__((packed)) DirectoryEntry4MB {
+ unsigned present : 1; /* 0: if set, the page is actually in physical memory */
+ unsigned writeable : 1; /* 1: if set, the page is read/write; otherwise the page is read-only */
+ unsigned useraccess : 1; /* 2: if set, then page can be access by all; otherwise only the supervisor can access it */
+ unsigned writethrough : 1; /* 3: if set, write-through caching is enabled; otherwise write-back is enabled instead */
+ unsigned cachedisable : 1; /* 4: if set, the page will not be cached */
+ unsigned accessed : 1; /* 5: set by the CPU when the page is read from or written to */
+ unsigned dirty : 1; /* 6: used to determine whether a page has been written to */
+ unsigned pagesize : 1; /* 7: page size == 1 */
+ unsigned global : 1; /* 8: */
+ unsigned __available__ : 3; /* 11..9 available to the OS */
+ unsigned pat : 1; /* 12: page attribute table */
+ unsigned int address_high : 8;
+ unsigned rsvd : 1; /* 21 */
+ unsigned int address_low : 10;
+};
+/* TODO _Static_assert(sizeof(struct DirectoryEntry4MB) == 4, "DirectoryEntry4M size"); */
+
+/* TableEntry
+ * |31| | | | | | | | | | | | | | | | | | | |11| | 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
+ * | page table 4-kb aligned address | avail | G| | D| A| C| W|US|RW| P| */
+struct __attribute__((packed)) TableEntry {
+ unsigned present : 1; /* if set, the page is actually in physical memory */
+ unsigned writeable : 1; /* if set, the page is read/write; otherwise the page is read-only */
+ unsigned user : 1; /* if set, then page can be access by all; otherwise only the supervisor can access it */
+ unsigned writethrough : 1; /* if set, write-through caching is enabled; otherwise write-back is enabled instead */
+ unsigned cachedisable : 1; /* if set, the page will not be cached */
+ unsigned accessed : 1; /* set by the CPU when the page is read from or written to */
+ unsigned dirty : 1; /* used to determine whether a page has been written to */
+ unsigned pat : 1; /* page attribute table? */
+ unsigned global : 1;
+ unsigned int __available__ : 3; /* available to the OS */
+ unsigned int address : 20;
+};
+/* TODO _Static_assert(sizeof(struct TableEntry) == 4, "TableEntry size"); */