11b3e83adSIngo Weinhold /* 21b3e83adSIngo Weinhold * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. 31b3e83adSIngo Weinhold * Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de. 41b3e83adSIngo Weinhold * Distributed under the terms of the MIT License. 51b3e83adSIngo Weinhold * 61b3e83adSIngo Weinhold * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 71b3e83adSIngo Weinhold * Distributed under the terms of the NewOS License. 81b3e83adSIngo Weinhold */ 91b3e83adSIngo Weinhold #ifndef _KERNEL_ARCH_X86_PAGING_32_BIT_PAGING_H 101b3e83adSIngo Weinhold #define _KERNEL_ARCH_X86_PAGING_32_BIT_PAGING_H 111b3e83adSIngo Weinhold 121b3e83adSIngo Weinhold 131b3e83adSIngo Weinhold #include <SupportDefs.h> 141b3e83adSIngo Weinhold 151b3e83adSIngo Weinhold #include <int.h> 16f0675bf7SIngo Weinhold #include <kernel.h> 171b3e83adSIngo Weinhold 181b3e83adSIngo Weinhold 191b3e83adSIngo Weinhold #define VADDR_TO_PDENT(va) (((va) / B_PAGE_SIZE) / 1024) 201b3e83adSIngo Weinhold #define VADDR_TO_PTENT(va) (((va) / B_PAGE_SIZE) % 1024) 211b3e83adSIngo Weinhold 221b3e83adSIngo Weinhold 231b3e83adSIngo Weinhold // page directory entry bits 241b3e83adSIngo Weinhold #define X86_PDE_PRESENT 0x00000001 251b3e83adSIngo Weinhold #define X86_PDE_WRITABLE 0x00000002 261b3e83adSIngo Weinhold #define X86_PDE_USER 0x00000004 271b3e83adSIngo Weinhold #define X86_PDE_WRITE_THROUGH 0x00000008 281b3e83adSIngo Weinhold #define X86_PDE_CACHING_DISABLED 0x00000010 291b3e83adSIngo Weinhold #define X86_PDE_ACCESSED 0x00000020 301b3e83adSIngo Weinhold #define X86_PDE_IGNORED1 0x00000040 311b3e83adSIngo Weinhold #define X86_PDE_RESERVED1 0x00000080 321b3e83adSIngo Weinhold #define X86_PDE_IGNORED2 0x00000100 331b3e83adSIngo Weinhold #define X86_PDE_IGNORED3 0x00000200 341b3e83adSIngo Weinhold #define X86_PDE_IGNORED4 0x00000400 351b3e83adSIngo Weinhold #define X86_PDE_IGNORED5 0x00000800 361b3e83adSIngo Weinhold #define X86_PDE_ADDRESS_MASK 0xfffff000 371b3e83adSIngo Weinhold 381b3e83adSIngo Weinhold // page table entry bits 391b3e83adSIngo Weinhold #define X86_PTE_PRESENT 0x00000001 401b3e83adSIngo Weinhold #define X86_PTE_WRITABLE 0x00000002 411b3e83adSIngo Weinhold #define X86_PTE_USER 0x00000004 421b3e83adSIngo Weinhold #define X86_PTE_WRITE_THROUGH 0x00000008 431b3e83adSIngo Weinhold #define X86_PTE_CACHING_DISABLED 0x00000010 441b3e83adSIngo Weinhold #define X86_PTE_ACCESSED 0x00000020 451b3e83adSIngo Weinhold #define X86_PTE_DIRTY 0x00000040 461b3e83adSIngo Weinhold #define X86_PTE_PAT 0x00000080 471b3e83adSIngo Weinhold #define X86_PTE_GLOBAL 0x00000100 481b3e83adSIngo Weinhold #define X86_PTE_IGNORED1 0x00000200 491b3e83adSIngo Weinhold #define X86_PTE_IGNORED2 0x00000400 501b3e83adSIngo Weinhold #define X86_PTE_IGNORED3 0x00000800 511b3e83adSIngo Weinhold #define X86_PTE_ADDRESS_MASK 0xfffff000 521b3e83adSIngo Weinhold #define X86_PTE_PROTECTION_MASK (X86_PTE_WRITABLE | X86_PTE_USER) 531b3e83adSIngo Weinhold #define X86_PTE_MEMORY_TYPE_MASK (X86_PTE_WRITE_THROUGH \ 541b3e83adSIngo Weinhold | X86_PTE_CACHING_DISABLED) 551b3e83adSIngo Weinhold 56f0675bf7SIngo Weinhold #define FIRST_USER_PGDIR_ENT (VADDR_TO_PDENT(USER_BASE)) 57f0675bf7SIngo Weinhold #define NUM_USER_PGDIR_ENTS (VADDR_TO_PDENT(ROUNDUP(USER_SIZE, \ 58f0675bf7SIngo Weinhold B_PAGE_SIZE * 1024))) 59f0675bf7SIngo Weinhold #define FIRST_KERNEL_PGDIR_ENT (VADDR_TO_PDENT(KERNEL_BASE)) 60f0675bf7SIngo Weinhold #define NUM_KERNEL_PGDIR_ENTS (VADDR_TO_PDENT(KERNEL_SIZE)) 61f0675bf7SIngo Weinhold 621b3e83adSIngo Weinhold 63*e5885c7dSIngo Weinhold static const size_t kPageTableAlignment = 1024 * B_PAGE_SIZE; 64*e5885c7dSIngo Weinhold 65*e5885c7dSIngo Weinhold 661b3e83adSIngo Weinhold typedef uint32 page_table_entry; 671b3e83adSIngo Weinhold typedef uint32 page_directory_entry; 681b3e83adSIngo Weinhold 691b3e83adSIngo Weinhold 701b3e83adSIngo Weinhold #endif // _KERNEL_ARCH_X86_PAGING_32_BIT_PAGING_H 71