]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ux/kernel_thread-ux.cpp
Inital import
[l4.git] / kernel / fiasco / src / kern / ux / kernel_thread-ux.cpp
1 INTERFACE:
2
3 EXTENSION class Kernel_thread
4 {
5 public:
6   static int    init_done();
7
8 private:
9   static int    free_initcall_section_done;
10 };
11
12 IMPLEMENTATION[ux]:
13
14 #include <unistd.h>
15 #include <sys/mman.h>
16 #include "boot_info.h"
17 #include "fb.h"
18 #include "kdb_ke.h"
19 #include "net.h"
20 #include "mem_layout.h"
21 #include "pic.h"
22 #include "trap_state.h"
23 #include "usermode.h"
24
25 int Kernel_thread::free_initcall_section_done;
26
27 IMPLEMENT inline
28 int
29 Kernel_thread::init_done()
30 {
31   return free_initcall_section_done;
32 }
33
34 IMPLEMENT inline NEEDS [<unistd.h>, <sys/mman.h>, "mem_layout.h"]
35 void
36 Kernel_thread::free_initcall_section()
37 {
38   munmap ((void*)&Mem_layout::initcall_start, 
39           &Mem_layout::initcall_end - &Mem_layout::initcall_start);
40   free_initcall_section_done = 1;
41 }
42
43 IMPLEMENT FIASCO_INIT
44 void
45 Kernel_thread::bootstrap_arch()
46 {
47   // install slow trap handler
48   nested_trap_handler      = Trap_state::base_handler;
49   Trap_state::base_handler = thread_handle_trap;
50
51   if (Boot_info::jdb_cmd())
52     kdb_ke_sequence (Boot_info::jdb_cmd());
53
54   if (Boot_info::wait())
55     kdb_ke ("Wait");
56
57   boot_app_cpus();
58 }
59
60 IMPLEMENT
61 void
62 Kernel_thread::arch_exit()
63 {
64   fflush(0);  // Flush output stream
65   Pic::irq_prov_shutdown(); // atexit calls are not run with _exit
66   _exit(0);   // Don't call destructors
67 }
68
69 //--------------------------------------------------------------------------
70 IMPLEMENTATION [!mp]:
71
72 static void inline
73 Kernel_thread::boot_app_cpus()
74 {}
75
76
77 //--------------------------------------------------------------------------
78 IMPLEMENTATION [mp]:
79
80 static void
81 Kernel_thread::boot_app_cpus()
82 {
83   printf("MP: launching APs...\n");
84   if (0)
85     {
86        extern char _tramp_mp_entry[];
87         printf("new child: %d   [%d]\n",
88                Emulation::spawn_cpu_thread((Address)_tramp_mp_entry),
89                Emulation::gettid());
90     }
91 }