1/** 2 * \file 3 * \brief K1OM address space sizes and offsets 4 * 5 * The layout of the K1OM virtual address space can be summarized as 6 * follows: 7 * 8 *<pre> 9 * +----------------------------------------------------+-----------------+ 10 * | User-space | Physical memory | 11 * | PML4 entries: 0 1 2 3 4 ... 510 | 511 | 12 * +----------------------------------------------------+-----------------+</pre> 13 * 14 * User-space maps user-space programs. Physical memory maps all 15 * available physical memory (up to PADDR_SPACE_LIMIT). 16 * 17 * This partition is static and can only be changed at compile-time. 18 * 19 * Physical memory can grow downwards, towards user-space, although it 20 * is expected to stay within PML4 entry 511 for quite some time (one 21 * PML4 entry can map 512 GBytes). The rest of the address space can 22 * be freely mapped by (possibly multiple) user-space programs. 23 */ 24 25/* 26 * Copyright (c) 2007, 2008, 2009, 2010, 2011, ETH Zurich. 27 * All rights reserved. 28 * 29 * This file is distributed under the terms in the attached LICENSE file. 30 * If you do not find this file, copies can be found by writing to: 31 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 32 */ 33 34#ifndef KERNEL_TARGET_K1OM_OFFSETS_H 35#define KERNEL_TARGET_K1OM_OFFSETS_H 36 37 38 39/** 40 * Absolute size of virtual address space. This is 48-bit on x86-64 41 * currently, which equals 256 TBytes and allows for 512 PML4 slots, 42 * each of which can map 512 GBytes. 43 */ 44#define K1OM_VADDR_SPACE_BITS 48 45#define K1OM_VADDR_SPACE_SIZE ((genpaddr_t)1 << K1OM_VADDR_SPACE_BITS) 46 47/** 48 * Absolute size of physical address space. This is also 40-bit. 49 * 50 * Intel Xeon Phi Systems Software Developers Guide, 2.1.4: 51 * 52 * The Intel�� Xeon Phi��� coprocessor supports 40-bit physical address in 64-bit. 53 */ 54#define X1OM_PADDR_SPACE_BITS 40 55#define K1OM_PADDR_SPACE_SIZE ((genpaddr_t)1 << X1OM_PADDR_SPACE_BITS) 56 57/** 58 * Start address of kernel image in physical memory. This is passed to 59 * the linker also. The bootloader will load us there. 60 */ 61#define K1OM_START_KERNEL_PHYS 0x100000 62 63/** 64 * Kernel stack size -- 16KB 65 */ 66#define K1OM_KERNEL_STACK_SIZE 0x4000 67 68 69 70/** 71 * Maximum physical address space mappable by the kernel. Adjust this 72 * for a bigger physical address space. We set this to 40-bit, 73 * i.e. 1024 GBytes. 74 * 75 * Xeon Phi Systems Software Developers Guide, 2.1.4: 76 * 77 * The Intel�� Xeon Phi��� coprocessor supports 40-bit physical address in 64-bit. 78 * 79 */ 80#define K1OM_PADDR_SPACE_LIMIT ((genpaddr_t)1 << 40) 81 82/** 83 * Maximum physical address space mappable by the kernel. Adjust this 84 * for a bigger physical address space. We set this to 40-bit, 85 * i.e. 1024 GBytes. 86 * 87 * Xeon Phi Systems Software Developers Guide, 2.1.4: 88 * 89 * The Intel�� Xeon Phi��� coprocessor supports 40-bit physical address in 64-bit. 90 * 91 */ 92#ifdef __XEON_PHI_7120__ 93#define K1OM_PHYSICAL_MEMORY_SIZE ((genpaddr_t)(16ULL*1024*1024*1024)) 94#else 95#ifdef __XEON_PHI_5120__ 96#define K1OM_PHYSICAL_MEMORY_SIZE ((genpaddr_t)(8ULL*1024*1024*1024)) 97#else 98/* __XEON_PHI_3120__ */ 99#define K1OM_PHYSICAL_MEMORY_SIZE ((genpaddr_t)(6ULL*1024*1024*1024)) 100#endif 101#endif 102 103 104 105/** 106 * Static address space limit for the init user-space domain. The 107 * static space is used to map in code and static data of the init 108 * module, as well as all loaded multiboot modules. init can freely 109 * allocate dynamic memory as soon as it is running. This is 32 MBytes 110 * right now. 111 * 112 * You should make this constant a multiple of #BASE_PAGE_SIZE * 113 * #PTABLE_SIZE or you'll restrict init's static address space 114 * unneccessarily. init's lowest segment should also be based at these 115 * multiples or it restricts itself. 116 */ 117#define K1OM_INIT_SPACE_LIMIT (32 * 1024 * 1024) 118 119/** 120 * Base address of init address space in virtual memory. init should 121 * start at 4 MByte. The kernel maps in important structures at 2 122 * MByte. This address should be page-table size aligned (i.e. with 4 123 * KByte pages, a page table maps 2 MBytes. Thus, align it to 124 * multiples of 2 MBytes). 125 */ 126#define K1OM_INIT_VBASE 0x200000 127 128/** 129 * Initial amount of physical memory to map during bootup. The low 130 * 1MByte of memory is always expected to be there and has to be 131 * specified here at minimum. If you need more during bootup, increase 132 * this value. This value is also the amount of memory you _expect_ to 133 * be in the system during bootup, or the kernel will crash! 134 */ 135#define K1OM_KERNEL_INIT_MEMORY (1 * 1024 * 1024) 136 137/** 138 * Aligns an address to the nearest PML4 entry by masking out lower 39 139 * bits. 140 */ 141#define K1OM_PML4_ALIGN(addr) ((addr) & ((genpaddr_t)0x1ffffffUL << 39)) 142 143/** 144 * Absolute offset of mapped physical memory within virtual address 145 * space. This occupies one or more (usually one) PML4 slots directly 146 * before the kernel. This needs to be aligned to PADDR_SPACE_LIMIT. 147 * 148 * Change VSPACE_END in lib/barrelfish if you change this. 149 */ 150#define K1OM_MEMORY_OFFSET K1OM_PML4_ALIGN(-K1OM_PADDR_SPACE_LIMIT) 151 152/** 153 * The real-mode addresses 154 */ 155 156#define K1OM_REAL_MODE_SEGMENT 0x0600 /**< The real-mode segment */ 157#define K1OM_REAL_MODE_OFFSET 0x0000 /**< The real-mode offset _has to be_ 0000!! */ 158 159#define K1OM_REAL_MODE_LINEAR_OFFSET \ 160 (K1OM_REAL_MODE_SEGMENT << 4) /**< The linear offset 161 of the real-mode 162 segment */ 163 164#define K1OM_REAL_MODE_SEGMENT_TO_REAL_MODE_PAGE(seg) ((uint8_t)(seg >> 8)) 165#define K1OM_REAL_MODE_ADDR_TO_REAL_MODE_VECTOR(seg,off) ((uint32_t)(seg << 16) | off) 166 167#define X86_64_REAL_MODE_SEGMENT 0x0600 /**< The real-mode segment */ 168#define X86_64_REAL_MODE_OFFSET 0x0000 /**< The real-mode offset _has to be_ 0000!! */ 169 170#define X86_64_REAL_MODE_LINEAR_OFFSET \ 171 (X86_64_REAL_MODE_SEGMENT << 4) /**< The linear offset 172 of the real-mode 173 segment */ 174 175#define X86_64_REAL_MODE_SEGMENT_TO_REAL_MODE_PAGE(seg) ((uint8_t)(seg >> 8)) 176#define X86_64_REAL_MODE_ADDR_TO_REAL_MODE_VECTOR(seg,off) ((uint32_t)(seg << 16) | off) 177 178/* 179 * TODO: Add K1OM offsets 180 */ 181 182#ifndef __ASSEMBLER__ 183 184/** 185 * \brief The kernel stack. 186 */ 187extern uintptr_t k1om_kernel_stack[K1OM_KERNEL_STACK_SIZE/sizeof(uintptr_t)]; 188 189#endif 190 191#endif // KERNEL_TARGET_K1OM_OFFSETS_H 192