1 /* 2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de. 4 * Distributed under the terms of the MIT License. 5 * 6 * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 7 * Distributed under the terms of the NewOS License. 8 */ 9 #ifndef _KERNEL_ARCH_X86_PAGING_32_BIT_PAGING_H 10 #define _KERNEL_ARCH_X86_PAGING_32_BIT_PAGING_H 11 12 13 #include <SupportDefs.h> 14 15 #include <int.h> 16 #include <kernel.h> 17 18 19 #define VADDR_TO_PDENT(va) (((va) / B_PAGE_SIZE) / 1024) 20 #define VADDR_TO_PTENT(va) (((va) / B_PAGE_SIZE) % 1024) 21 22 23 // page directory entry bits 24 #define X86_PDE_PRESENT 0x00000001 25 #define X86_PDE_WRITABLE 0x00000002 26 #define X86_PDE_USER 0x00000004 27 #define X86_PDE_WRITE_THROUGH 0x00000008 28 #define X86_PDE_CACHING_DISABLED 0x00000010 29 #define X86_PDE_ACCESSED 0x00000020 30 #define X86_PDE_IGNORED1 0x00000040 31 #define X86_PDE_RESERVED1 0x00000080 32 #define X86_PDE_IGNORED2 0x00000100 33 #define X86_PDE_IGNORED3 0x00000200 34 #define X86_PDE_IGNORED4 0x00000400 35 #define X86_PDE_IGNORED5 0x00000800 36 #define X86_PDE_ADDRESS_MASK 0xfffff000 37 38 // page table entry bits 39 #define X86_PTE_PRESENT 0x00000001 40 #define X86_PTE_WRITABLE 0x00000002 41 #define X86_PTE_USER 0x00000004 42 #define X86_PTE_WRITE_THROUGH 0x00000008 43 #define X86_PTE_CACHING_DISABLED 0x00000010 44 #define X86_PTE_ACCESSED 0x00000020 45 #define X86_PTE_DIRTY 0x00000040 46 #define X86_PTE_PAT 0x00000080 47 #define X86_PTE_GLOBAL 0x00000100 48 #define X86_PTE_IGNORED1 0x00000200 49 #define X86_PTE_IGNORED2 0x00000400 50 #define X86_PTE_IGNORED3 0x00000800 51 #define X86_PTE_ADDRESS_MASK 0xfffff000 52 #define X86_PTE_PROTECTION_MASK (X86_PTE_WRITABLE | X86_PTE_USER) 53 #define X86_PTE_MEMORY_TYPE_MASK (X86_PTE_WRITE_THROUGH \ 54 | X86_PTE_CACHING_DISABLED) 55 56 #define FIRST_USER_PGDIR_ENT (VADDR_TO_PDENT(USER_BASE)) 57 #define NUM_USER_PGDIR_ENTS (VADDR_TO_PDENT(ROUNDUP(USER_SIZE, \ 58 B_PAGE_SIZE * 1024))) 59 #define FIRST_KERNEL_PGDIR_ENT (VADDR_TO_PDENT(KERNEL_BASE)) 60 #define NUM_KERNEL_PGDIR_ENTS (VADDR_TO_PDENT(KERNEL_SIZE)) 61 62 63 static const size_t kPageTableAlignment = 1024 * B_PAGE_SIZE; 64 65 66 typedef uint32 page_table_entry; 67 typedef uint32 page_directory_entry; 68 69 70 #endif // _KERNEL_ARCH_X86_PAGING_32_BIT_PAGING_H 71