Sfoglia il codice sorgente

feat: page directory and page table struct

greatbridf 3 anni fa
parent
commit
36c0bb6a52
1 ha cambiato i file con 64 aggiunte e 0 eliminazioni
  1. 64 0
      include/kernel/mem.h

+ 64 - 0
include/kernel/mem.h

@@ -39,6 +39,70 @@ void* k_malloc(size_t size);
 
 void k_free(void* ptr);
 
+/*
+ * page directory entry
+ *
+ * p   : present (1)
+ * rw  : allow write (1)
+ * us  : allow user access (1)
+ * pwt : todo
+ * pcd : todo
+ * a   : accessed for linear address translation (1)
+ * d   : dirty (1) (ignored)
+ * ps  : use 4MiB pages (ignored)
+ * addr: page table address
+ */
+struct page_directory_entry_in {
+    uint32_t p : 1;
+    uint32_t rw : 1;
+    uint32_t us : 1;
+    uint32_t pwt : 1;
+    uint32_t pcd : 1;
+    uint32_t a : 1;
+    uint32_t d : 1;
+    uint32_t ps : 1;
+    uint32_t ignored : 4;
+    uint32_t addr : 20;
+};
+
+typedef union page_directory_entry {
+    uint32_t v;
+    struct page_directory_entry_in in;
+} page_directory_entry;
+
+/*
+ * page table entry
+ *
+ * p   : present (1)
+ * rw  : allow write (1)
+ * us  : allow user access (1)
+ * pwt : todo
+ * pcd : todo
+ * a   : accessed for linear address translation (1)
+ * d   : dirty (1)
+ * pat : todo (ignored)
+ * g   : used in cr4 mode (ignored)
+ * addr: physical memory address
+ */
+struct page_table_entry_in {
+    uint32_t p : 1;
+    uint32_t rw : 1;
+    uint32_t us : 1;
+    uint32_t pwt : 1;
+    uint32_t pcd : 1;
+    uint32_t a : 1;
+    uint32_t d : 1;
+    uint32_t pat : 1;
+    uint32_t g : 1;
+    uint32_t ignored : 3;
+    uint32_t addr : 20;
+};
+
+typedef union page_table_entry {
+    uint32_t v;
+    struct page_table_entry_in in;
+} page_table_entry;
+
 #ifdef __cplusplus
 }
 #endif