Changeset 236 for trunk/hal/x86_64/core
- Timestamp:
- Jul 19, 2017, 2:30:15 PM (7 years ago)
- Location:
- trunk/hal/x86_64/core
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_apic.c
r235 r236 491 491 492 492 int 493 start_secondary_cpu(uint32_t gid, paddr_t pa)493 boot_cpuN(uint32_t gid, paddr_t pa) 494 494 { 495 495 /* -
trunk/hal/x86_64/core/hal_apic.h
r234 r236 34 34 uint32_t hal_lapic_gid(); 35 35 void hal_apic_init(); 36 37 int boot_cpuN(uint32_t gid, paddr_t pa); 38 36 39 #endif 37 40 -
trunk/hal/x86_64/core/hal_boot.h
r234 r236 37 37 #define ASM_ENTRY(x) \ 38 38 .text; ASM_ALIGN_TEXT; .globl x; .type x,@function; x: 39 40 #define LABEL(x) \ 41 .globl x; .type x,@function; x: 39 42 40 43 /* -------------------------------------------------------------------------- */ … … 131 134 /* -------------------------------------------------------------------------- */ 132 135 136 #define SMP_TRAMPOLINE_PA (2 * PAGE_SIZE) 137 138 /* -------------------------------------------------------------------------- */ 139 133 140 #define KERNEL_VA_SIZE (NKL2_KIMG_ENTRIES * NBPD_L2) 134 141 #define CLUSTERS_BASE_VA HAL_VA_BASE -
trunk/hal/x86_64/core/hal_cpu.S
r235 r236 108 108 ret 109 109 110 ASM_ENTRY(rcr0) 111 movq %cr0,%rax 112 ret 113 110 114 ASM_ENTRY(rcr2) 111 115 movq %cr2,%rax 116 ret 117 118 ASM_ENTRY(rcr3) 119 movq %cr3,%rax 112 120 ret 113 121 -
trunk/hal/x86_64/core/hal_init.c
r235 r236 58 58 uint8_t mb_mmap[PAGE_SIZE] __in_kdata; 59 59 60 /* x86-specific per-cluster structures */ 61 uint8_t gdtstore[PAGE_SIZE] __in_kdata; 62 uint8_t idtstore[PAGE_SIZE] __in_kdata; 63 64 /* x86-specific per-cpu structures */ 65 typedef struct { 66 bool_t valid; 67 struct tss tss; 68 struct tls tls; 69 uint8_t boot_stack[STKSIZE]; 70 uint8_t intr_stack[STKSIZE]; 71 uint8_t dbfl_stack[STKSIZE]; 72 uint8_t nmfl_stack[STKSIZE]; 73 } percpu_archdata_t; 74 percpu_archdata_t cpudata[CONFIG_MAX_LOCAL_CORES] __in_kdata; 75 60 76 /* -------------------------------------------------------------------------- */ 61 77 … … 245 261 /* -------------------------------------------------------------------------- */ 246 262 263 static uint32_t cpuN_booted __in_kdata; 264 265 void start_secondary_cpus() 266 { 267 pt_entry_t flags = PG_V | PG_KW; 268 extern vaddr_t cpuN_boot_trampoline; 269 extern vaddr_t cpuN_boot_trampoline_end; 270 extern paddr_t smp_L4pa; 271 extern vaddr_t smp_stkva; 272 extern paddr_t L4paddr; 273 size_t i, sz; 274 275 smp_L4pa = L4paddr; 276 277 /* map the SMP trampoline (identity) */ 278 vaddr_t trampva = (vaddr_t)SMP_TRAMPOLINE_PA; 279 hal_gpt_maptree_area(trampva, trampva + PAGE_SIZE); 280 hal_gpt_enter(trampva, SMP_TRAMPOLINE_PA, flags); 281 282 /* copy it */ 283 sz = (size_t)&cpuN_boot_trampoline_end - (size_t)&cpuN_boot_trampoline; 284 memcpy((void *)trampva, (void *)&cpuN_boot_trampoline, sz); 285 286 for (i = 0; i < CONFIG_MAX_LOCAL_CORES; i++) { 287 if (i == 0 || !cpudata[i].valid) { 288 continue; 289 } 290 291 smp_stkva = (vaddr_t)cpudata[i].boot_stack + STKSIZE; 292 293 cpuN_booted = 0; 294 boot_cpuN(i, SMP_TRAMPOLINE_PA); 295 while (!hal_atomic_cas(&cpuN_booted, 1, 0)) { 296 /* wait */ 297 } 298 } 299 300 // XXX: unmap the trampoline 301 } 302 303 void init_x86_64_cpuN() 304 { 305 cpuN_booted = 1; 306 x86_printf("-> cpu%z is alive!\n", hal_lapic_gid()); 307 while (1); 308 } 309 310 /* -------------------------------------------------------------------------- */ 311 247 312 static void apic_map() 248 313 { … … 310 375 init_bootinfo(&btinfo); 311 376 377 start_secondary_cpus(); 378 312 379 reg_t dummy; 313 380 hal_enable_irq(&dummy); … … 342 409 343 410 /* -------------------------------------------------------------------------- */ 344 345 /* x86-specific per-cluster structures */346 uint8_t gdtstore[PAGE_SIZE] __in_kdata;347 uint8_t idtstore[PAGE_SIZE] __in_kdata;348 349 /* x86-specific per-cpu structures */350 typedef struct {351 bool_t valid;352 struct tss tss;353 struct tls tls;354 uint8_t intr_stack[STKSIZE];355 uint8_t dbfl_stack[STKSIZE];356 uint8_t nmfl_stack[STKSIZE];357 } percpu_archdata_t;358 percpu_archdata_t cpudata[CONFIG_MAX_LOCAL_CORES] __in_kdata;359 411 360 412 void cpu_activate(uint32_t gid) -
trunk/hal/x86_64/core/hal_internal.h
r235 r236 48 48 void wrmsr(uint32_t, uint64_t); 49 49 void mfence(); 50 vaddr_t rcr2(void); 50 uint64_t rcr0(void); 51 vaddr_t rcr2(void); 52 uint64_t rcr3(void); 51 53 uint64_t rcr4(void); 52 54 void lcr4(uint64_t);
Note: See TracChangeset
for help on using the changeset viewer.