diff cos/kernel/kernel.h @ 30:0148f55bfe24

Added static asserts and fixed pages
author windel
date Thu, 29 Dec 2011 23:51:35 +0100
parents 7e3bdcb391dc
children 3a6a9b929db0
line wrap: on
line diff
--- a/cos/kernel/kernel.h	Thu Dec 29 19:34:01 2011 +0100
+++ b/cos/kernel/kernel.h	Thu Dec 29 23:51:35 2011 +0100
@@ -70,7 +70,7 @@
    uint64_t ps : 1; // must be 0.
    uint64_t ignored2 : 4;
    // 12 bits so far
-   uint64_t address : 48; // address of page directory pointer table.
+   uint64_t address : 40; // address of page directory pointer table.
    uint64_t ignored3 : 11;
    uint64_t xd : 1; // execute disable
 } PML4E_t; // 64 bits wide, PML4 table must be 4096 byte aligned.
@@ -94,7 +94,7 @@
    uint64_t ps : 1; // page size, must be 0, otherwise maps a 1 GB page.
    uint64_t ignored2 : 4;
    // 12 bits so far
-   uint64_t address : 48; // address of page directory table.
+   uint64_t address : 40; // address of page directory table.
    uint64_t ignored3 : 11;
    uint64_t xd : 1; // execute disable
 } PDPTE_t; // Page directory pointer table entry, 64 bits wide. 4-kB aligned.
@@ -118,7 +118,7 @@
    uint64_t ps : 1; // page size, must be 0, otherwise maps a 2-MB page.
    uint64_t ignored2 : 4;
    // 12 bits so far
-   uint64_t address : 48; // address of page table.
+   uint64_t address : 40; // address of page table.
    uint64_t ignored3 : 11;
    uint64_t xd : 1; // execute disable
 } PDE_t;
@@ -130,9 +130,10 @@
    uint64_t physicalAddress;
 } PD_t;
 
+
 typedef struct
 {
-   uint64_t present : 1;
+   unsigned present : 1;
    uint64_t rw : 1;
    uint64_t us : 1; // user or supervisor
    uint64_t pwt : 1;
@@ -143,11 +144,16 @@
    uint64_t g : 1; // Global?
    uint64_t ignored : 3;
 
-   uint64_t address : 48;
+   uint64_t address : 40;
    uint64_t ignored2 : 11;
    uint64_t xd : 1;
 } page_t;
 
+_Static_assert(sizeof(page_t) == 8, "sizeof(page_t) != 8");
+_Static_assert(sizeof(PDE_t) == 8, "sizeof(PDE_t) != 8");
+_Static_assert(sizeof(PDPTE_t) == 8, "sizeof(PDPTE_t) != 8");
+_Static_assert(sizeof(PML4E_t) == 8, "sizeof(PML4E_t) != 8");
+
 // Page table:
 typedef struct
 {