5 class Kernel_thread : public Thread
9 * Frees the memory of the initcall sections.
11 * Virtually initcall sections are freed by not marking them
12 * reserved in the KIP. This method just invalidates the contents of
13 * the memory, by filling it with some invalid data and may be
16 void free_initcall_section();
17 void bootstrap() asm ("call_bootstrap") FIASCO_FASTCALL;
18 void bootstrap_arch();
20 void do_idle() __attribute__((noreturn));
26 INTERFACE [kernel_can_exit]:
28 EXTENSION class Kernel_thread
31 void arch_exit() __attribute__((noreturn));
41 #include "delayloop.h"
43 #include "helping_lock.h"
44 #include "kernel_task.h"
45 #include "processor.h"
48 #include "thread_state.h"
50 #include "vmem_alloc.h"
55 Kernel_thread::Kernel_thread() : Thread(Thread::Kernel)
60 Kernel_thread::init_stack()
65 // the kernel bootstrap routine
68 Kernel_thread::bootstrap()
70 // Initializations done -- Helping_lock can now use helping lock
71 Helping_lock::threading_system_active = true;
73 state_change_dirty (0, Thread_ready); // Set myself ready
75 set_cpu_of(this, Cpu::boot_cpu()->id());
76 Timer::init_system_clock();
77 Sched_context::rq(cpu()).set_idle(this->sched());
79 // Setup initial timeslice
80 set_current_sched (sched());
86 Per_cpu_data::run_late_ctors(0);
89 printf("Calibrating timer loop... ");
90 // Init delay loop, needs working timer interrupt
100 * NEVER inline this function, because our caller is an initcall
102 IMPLEMENT FIASCO_NOINLINE FIASCO_NORETURN
106 free_initcall_section();
108 // No initcalls after this point!
110 kernel_context(cpu(), this);
112 // init_workload cannot be an initcall, because it fires up the userland
113 // applications which then have access to initcall frames as per kinfo page.
119 // ------------------------------------------------------------------------
120 IMPLEMENTATION [!arch_idle]:
122 PUBLIC inline NEEDS["processor.h"]
124 Kernel_thread::idle_op()
126 if (Config::hlt_works_ok)
127 Proc::halt(); // stop the CPU, waiting for an int
132 // ------------------------------------------------------------------------
133 IMPLEMENTATION [!kernel_can_exit]:
137 Kernel_thread::do_idle()
143 // ------------------------------------------------------------------------
144 IMPLEMENTATION [kernel_can_exit]:
148 Kernel_thread::do_idle()
156 puts ("\nExiting, wait...");
159 Task *sigma0 = static_cast<Task *>(sigma0_task);
163 boot_task->initiate_deletion(rl.list());
164 boot_task->destroy(rl.list());
166 delete boot_task; // Nuke everything else
168 Helping_lock::threading_system_active = false;