Changeset 44
- Timestamp:
- Jun 23, 2017, 9:57:35 AM (7 years ago)
- Location:
- trunk/hal/x86_64
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/hal_boot.h
r42 r44 130 130 #define NPDPG (PAGE_SIZE / sizeof (pt_entry_t)) 131 131 132 #define CLUSTERS_BASE_VA 0xffff800000000000 132 /* -------------------------------------------------------------------------- */ 133 133 134 134 /* 135 * These parameters are configurable. 135 * There are two arrays: one for the heap, one for the kernel image. They are 136 * separated by 64TB of VA, which is more than enough to avoid collision. 136 137 */ 137 #define CLUSTER _VA_SIZE 0x100000000 /* 4GB */138 #define CLUSTER _PA_SIZE 0x200000000 /* 8GB */138 #define CLUSTERS_HEAP_BASE_VA 0xffff800000000000 139 #define CLUSTERS_KIMG_BASE_VA 0xffffc00000000000 139 140 140 #define CLUSTER_MIN_VA(n) (CLUSTERS_BASE_VA + n * CLUSTER_VA_SIZE) 141 #define CLUSTER_MAX_VA(n) (CLUSTER_MIN_VA(n) + CLUSTER_VA_SIZE) 141 /* These parameters are configurable. */ 142 #define CLUSTER_HEAP_VA_SIZE 0x100000000 /* 4GB */ 143 #define CLUSTER_HEAP_PA_SIZE 0x200000000 /* 8GB */ 142 144 145 /* These parameters are *not* configurable. */ 146 #define CLUSTER_KIMG_VA_SIZE 0x80000000 /* 2GB */ 147 148 /* Macros to get the heap/kimg ranges for a cluster */ 149 #define CLUSTER_HEAP_MIN_VA(n) \ 150 (CLUSTERS_HEAP_BASE_VA + n * CLUSTER_HEAP_VA_SIZE) 151 #define CLUSTER_HEAP_MAX_VA(n) \ 152 (CLUSTER_HEAP_MIN_VA(n) + CLUSTER_HEAP_VA_SIZE) 153 #define CLUSTER_KIMG_MIN_VA(n) \ 154 (CLUSTERS_KIMG_BASE_VA + n * CLUSTER_KIMG_VA_SIZE) 155 #define CLUSTER_KIMG_MAX_VA(n) \ 156 (CLUSTER_KIMG_MIN_VA(n) + CLUSTER_KIMG_VA_SIZE) 157 -
trunk/hal/x86_64/hal_gpt.c
r42 r44 44 44 #define pl4_i(VA) (((VA_SIGN_POS(VA)) & L4_FRAME) >> L4_SHIFT) 45 45 46 extern vaddr_t __kernel_end; 47 size_t kimg_size __in_kdata = 0; 48 46 49 paddr_t pa_avail __in_kdata = 0; 47 50 vaddr_t va_avail __in_kdata = 0; … … 176 179 void hal_gpt_init(paddr_t firstpa) 177 180 { 181 paddr_t kimg_min_pa = 0; 182 183 /* Initialize global values */ 178 184 pa_avail = firstpa; 179 va_avail = CLUSTER_MIN_VA(0); 180 hal_gpt_maptree_area(CLUSTER_MIN_VA(0), CLUSTER_MAX_VA(0)); 185 va_avail = CLUSTER_HEAP_MIN_VA(0); 186 kimg_size = ((uint64_t)&__kernel_end - KERNBASE); 187 XASSERT(kimg_size % PAGE_SIZE == 0); 188 kimg_size = kimg_size / PAGE_SIZE; 189 190 /* Create cluster0's heap entry. */ 191 hal_gpt_maptree_area(CLUSTER_HEAP_MIN_VA(0), CLUSTER_HEAP_MAX_VA(0)); 192 193 /* Create cluster0's kimg entry. */ 194 hal_gpt_maptree_area(CLUSTER_KIMG_MIN_VA(0), CLUSTER_KIMG_MAX_VA(0)); 195 196 /* Manually enter cluster0's kimg */ 197 hal_gpt_enter_range(CLUSTER_KIMG_MIN_VA(0), kimg_min_pa, kimg_size); 181 198 } 182 199 -
trunk/hal/x86_64/hal_init.c
r39 r44 39 39 void cpu_attach(); 40 40 41 size_t mytest __in_kdata = 0; 41 42 42 43 struct multiboot_info mb_info __in_kdata; … … 98 99 x86_printf("[+] hal_acpi_init called\n"); 99 100 101 x86_printf("-> mytest = %z\n", mytest); 102 size_t *myptr = XPTR_KIMG(0, &mytest) + CLUSTER_KIMG_MIN_VA(0); 103 *myptr = 1; 104 x86_printf("-> mytest = %z\n", mytest); 100 105 101 106 int m = 0; -
trunk/hal/x86_64/hal_types.h
r38 r44 163 163 * 164 164 * In Intel 64 bits, the kernel virtual space has 4 Gbytes per cluster 165 * - the cxy field occupies bits[ 63:32]165 * - the cxy field occupies bits[34:32] 166 166 * - the ptr field occupies bits[31:0] 167 167 *************************************************************************** … … 193 193 #define XPTR_NULL 0 194 194 195 /* virtual (heap) */ 195 196 #define PTR_MASK 0x00000000FFFFFFFFULL 196 197 #define CXY_MASK 0x0000000700000000ULL 197 198 #define PTR_SHIFT 32 198 199 #define GET_CXY(xp) ((cxy_t)((xp) >> PTR_SHIFT)) 200 199 #define GET_CXY(xp) ((cxy_t)(((xp) & CXY_MASK) >> PTR_SHIFT)) 201 200 #define GET_PTR(xp) ((void*)((xp) & PTR_MASK)) 202 203 201 #define XPTR(cxy,ptr) (((uint64_t)(cxy) << PTR_SHIFT) | (((uint64_t)(ptr)) & PTR_MASK)) 204 202 205 206 203 /* virtual (kimg). A KIMG entry has 2GB of VA. */ 204 #define PTR_KIMG_MASK 0x000000007FFFFFFFULL 205 #define CXY_KIMG_MASK 0x0000000380000000ULL 206 #define PTR_KIMG_SHIFT 31 207 #define GET_KIMG_CXY(xp) ((cxy_t)(((xp) & CXY_KIMG_MASK) >> PTR_KIMG_SHIFT)) 208 #define GET_KIMG_PTR(xp) ((void*)((xp) & PTR_KIMG_MASK)) 209 #define XPTR_KIMG(cxy,ptr) (((uint64_t)(cxy) << PTR_KIMG_SHIFT) | (((uint64_t)(ptr)) & PTR_KIMG_MASK)) 210 211 /* physical */ 207 212 #define LPA_MASK 0x00000001FFFFFFFFULL 208 209 213 #define LPA_SHIFT 33 210 211 214 #define CXY_FROM_PADDR(paddr) ((cxy_t)((paddr) >> LPA_SHIFT)) 212 213 215 #define LPA_FROM_PADDR(paddr) (lpa_t)((paddr & LPA_MASK) 214 215 216 #define PADDR(cxy,lad) (((uint64_t)(cxy) << LPA_SHIFT) | (((uint64_t)(ptr)) & LPA_MASK)) 216 217
Note: See TracChangeset
for help on using the changeset viewer.