3 * Shared main startup/shutdown code
13 IMPLEMENTATION[amd64]:
20 #include "kernel_thread.h"
21 #include "kernel_task.h"
29 Cpu const &cpu = *Cpu::boot_cpu();
31 // caution: no stack variables in this function because we're going
32 // to change the stack pointer!
34 printf ("CPU[%u]: %s (%X:%X:%X:%X) Model: %s at %llu MHz\n\n",
36 cpu.vendor_str(), cpu.family(), cpu.model(),
37 cpu.stepping(), cpu.brand(), cpu.model_str(),
38 div32(cpu.frequency(), 1000000));
40 cpu.show_cache_tlb_info("");
42 printf ("\nFreeing init code/data: %lu bytes (%lu pages)\n\n",
43 (Address)(&Mem_layout::initcall_end - &Mem_layout::initcall_start),
44 (Address)(&Mem_layout::initcall_end - &Mem_layout::initcall_start
45 >> Config::PAGE_SHIFT));
47 // Perform architecture specific initialization
50 // create kernel thread
51 static Kernel_thread *kernel = new (Ram_quota::root) Kernel_thread;
53 Task *const ktask = Kernel_task::kernel_task();
54 check(kernel->bind(ktask, User<Utcb>::Ptr(0)));
56 // switch to stack of kernel thread and bootstrap the kernel
58 (" movq %%rax, %%cr3 \n\t" // restore proper cr3 after running on the mp boot dir
59 " movq %%rsp, %0 \n\t" // save stack pointer in safe variable
60 " movq %4, %%rsp \n\t" // switch stack
61 " call call_bootstrap \n\t" // bootstrap kernel thread
62 : "=m" (boot_stack), "=a" (dummy), "=c" (dummy), "=d" (dummy)
63 : "S" (kernel->init_stack()), "D" (kernel),
64 "a" (Mem_layout::pmem_to_phys(Kmem::dir())));
68 //------------------------------------------------------------------------
69 IMPLEMENTATION[(amd64) && mp]:
71 #include "kernel_thread.h"
74 main_switch_ap_cpu_stack(Kernel_thread *kernel)
78 // switch to stack of kernel thread and bootstrap the kernel
80 (" mov %%rsi, %%rsp \n\t" // switch stack
81 " call call_ap_bootstrap \n\t" // bootstrap kernel thread
82 : "=a" (dummy), "=c" (dummy), "=d" (dummy)
83 : "a"(kernel), "S" (kernel->init_stack()));