diff --git a/arch/paging.c b/arch/paging.c index 4468776..6ae5503 100644 --- a/arch/paging.c +++ b/arch/paging.c @@ -4,42 +4,45 @@ #define I386_VM_PT_ENTRIES 1024 -#define I386_PAGE_SIZE 4096 -#define I386_BIG_PAGE_SIZE (I386_PAGE_SIZE * I386_VM_PT_ENTRIES) +#define I386_PAGE_SIZE 4096 +#define I386_BIG_PAGE_SIZE (I386_PAGE_SIZE * I386_VM_PT_ENTRIES) // i386 paging constants -#define I386_VM_PRESENT 0x001 // Page is present -#define I386_VM_WRITE 0x002 // Read/write access allowed -#define I386_VM_READ 0x000 // Read access only -#define I386_VM_USER 0x004 // User access allowed -#define I386_VM_PWT 0x008 // Write through -#define I386_VM_PCD 0x010 // Cache disable -#define I386_VM_ACC 0x020 // Accessed -#define I386_VM_ADDR_MASK 0xFFFFF000 // physical address +#define I386_VM_PRESENT 0x001 // Page is present +#define I386_VM_WRITE 0x002 // Read/write access allowed +#define I386_VM_READ 0x000 // Read access only +#define I386_VM_USER 0x004 // User access allowed + +#define I386_VM_PWT 0x008 // Write through +#define I386_VM_PCD 0x010 // Cache disable +#define I386_VM_ACC 0x020 // Accessed + +#define I386_VM_ADDR_MASK 0xFFFFF000 // physical address #define I386_VM_ADDR_MASK_4MB 0xFFC00000 // physical address + #define I386_VM_OFFSET_MASK_4MB 0x003FFFFF // physical address // Page directory specific flags. #define I386_VM_BIGPAGE 0x080 // 4MB page // CR0 bits -#define I386_CR0_PE 0x00000001 // Protected mode -#define I386_CR0_MP 0x00000002 // Monitor Coprocessor -#define I386_CR0_EM 0x00000004 // Emulate -#define I386_CR0_TS 0x00000008 // Task Switched -#define I386_CR0_ET 0x00000010 // Extension Type -#define I386_CR0_WP 0x00010000 // Enable paging -#define I386_CR0_PG 0x80000000 // Enable paging +#define I386_CR0_PE 0x00000001 // Protected mode +#define I386_CR0_MP 0x00000002 // Monitor Coprocessor +#define I386_CR0_EM 0x00000004 // Emulate +#define I386_CR0_TS 0x00000008 // Task Switched +#define I386_CR0_ET 0x00000010 // Extension Type +#define I386_CR0_WP 0x00010000 // Enable paging +#define I386_CR0_PG 0x80000000 // Enable paging // some CR4 bits -#define I386_CR4_VME 0x00000001 // Virtual 8086 -#define I386_CR4_PVI 0x00000002 // Virtual ints -#define I386_CR4_TSD 0x00000004 // RDTSC privileged -#define I386_CR4_DE 0x00000008 // Debugging extensions -#define I386_CR4_PSE 0x00000010 // Page size extensions -#define I386_CR4_PAE 0x00000020 // Physical addr extens -#define I386_CR4_MCE 0x00000040 // Machine check enable -#define I386_CR4_PGE 0x00000080 // Global page flag enable +#define I386_CR4_VME 0x00000001 // Virtual 8086 +#define I386_CR4_PVI 0x00000002 // Virtual ints +#define I386_CR4_TSD 0x00000004 // RDTSC privileged +#define I386_CR4_DE 0x00000008 // Debugging extensions +#define I386_CR4_PSE 0x00000010 // Page size extensions +#define I386_CR4_PAE 0x00000020 // Physical addr extens +#define I386_CR4_MCE 0x00000040 // Machine check enable +#define I386_CR4_PGE 0x00000080 // Global page flag enable // TODO: implement this #define assert(n) if (n) {}