1 /* 2 * Copyright 2004-2008, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 6 * Distributed under the terms of the NewOS License. 7 */ 8 #ifndef _KERNEL_ARCH_x86_KERNEL_H 9 #define _KERNEL_ARCH_x86_KERNEL_H 10 11 12 #ifndef _ASSEMBLER 13 #ifdef __cplusplus 14 # include <arch/cpu.h> 15 #endif 16 #endif 17 18 19 #ifdef _BOOT_MODE 20 21 22 // 32-bit and 64-bit kernel load addresses. 23 #define KERNEL_LOAD_BASE 0x80000000 24 #define KERNEL_LOAD_BASE_64_BIT 0xffffffff80000000ll 25 26 27 #elif defined(__x86_64__) 28 29 30 // Base of the kernel address space. 31 // KERNEL_BASE is the base of the kernel address space. This differs from the 32 // address where the kernel is loaded to: the kernel is loaded in the top 2GB 33 // of the virtual address space as required by GCC's kernel code model. The 34 // whole kernel address space is the top 512GB of the address space. 35 #define KERNEL_BASE 0xffffff0000000000 36 #define KERNEL_SIZE 0x10000000000 37 #define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1)) 38 #define KERNEL_LOAD_BASE 0xffffffff80000000 39 40 // Kernel physical memory map area. 41 #define KERNEL_PMAP_BASE 0xffffff0000000000 42 #define KERNEL_PMAP_SIZE 0x8000000000 43 44 // Userspace address space layout. 45 // There is a 2MB hole just before the end of the bottom half of the address 46 // space. This means that if userland passes in a buffer that crosses into the 47 // uncanonical address region, it will be caught through a page fault. 48 #define USER_BASE 0x100000 49 #define USER_BASE_ANY USER_BASE 50 #define USER_SIZE (0x800000000000 - (0x200000 + USER_BASE)) 51 #define USER_TOP (USER_BASE + (USER_SIZE - 1)) 52 53 #define KERNEL_USER_DATA_BASE 0x7f0000000000 54 #define USER_STACK_REGION 0x7f0000000000 55 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) 56 57 #ifdef _COMPAT_MODE 58 59 #define USER32_SIZE 0x100000000 60 #define USER32_TOP (USER_BASE + (USER32_SIZE - 1)) 61 62 #define KERNEL_USER32_DATA_BASE 0x60000000 63 64 #define USER32_STACK_REGION 0x70000000 65 #define USER32_STACK_REGION_SIZE ((USER32_TOP - USER32_STACK_REGION) + 1) 66 67 #endif // _COMPAT_MODE 68 69 70 #else // __x86_64__ 71 72 73 // memory layout 74 #define KERNEL_BASE 0x80000000 75 #define KERNEL_SIZE 0x80000000 76 #define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1)) 77 78 /* User space layout is a little special: 79 * The user space does not completely cover the space not covered by the 80 * kernel. There is a gap of 64kb between the user and kernel space. The 64kb 81 * region assures a user space thread cannot pass a buffer into the kernel as 82 * part of a syscall that would cross into kernel space. 83 * Further, there is a 1MB hole starting at 0x0 to prevent NULL from being mapped. 84 */ 85 #define USER_BASE 0x100000 86 #define USER_BASE_ANY USER_BASE 87 #define USER_SIZE (KERNEL_BASE - (0x10000 + USER_BASE)) 88 #define USER_TOP (USER_BASE + (USER_SIZE - 1)) 89 90 #define KERNEL_USER_DATA_BASE 0x60000000 91 #define USER_STACK_REGION 0x70000000 92 #define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1) 93 94 95 #endif // __x86_64__ 96 97 #endif // _KERNEL_ARCH_x86_KERNEL_H 98