]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ppc32/main.cpp
update
[l4.git] / kernel / fiasco / src / kern / ppc32 / main.cpp
1 INTERFACE [ppc32]:
2 #include <cstddef>
3
4 //---------------------------------------------------------------------------
5 IMPLEMENTATION [ppc32]:
6
7 #include <cstdlib>
8 #include <cstdio>
9 #include <cstring>
10
11 #include "config.h"
12 #include "globals.h"
13 //#include "kmem_alloc.h"
14 #include "kip_init.h"
15 //#include "pagetable.h"
16 #include "kdb_ke.h"
17 #include "kernel_thread.h"
18 #include "kernel_task.h"
19 #include "kernel_console.h"
20 //#include "reset.h" //TODO cbass: implement
21 #include "space.h"
22 //#include "terminate.h" //TODO cbass: implement
23
24 #include "processor.h"
25 #include "boot_info.h"
26 /*
27 static int exit_question_active = 0;
28
29 extern "C" void __attribute__ ((noreturn))
30 _exit(int)
31 {
32   if (exit_question_active)
33     platform_reset();
34
35   while (1)
36     {
37       Proc::halt();
38       Proc::pause();
39     }
40 }
41
42
43 static void exit_question()
44 {
45   exit_question_active = 1;
46
47   while (1)
48     {
49       puts("\nReturn reboots, \"k\" enters L4 kernel debugger...");
50
51       char c = Kconsole::console()->getchar();
52
53       if (c == 'k' || c == 'K')
54         {
55           kdb_ke("_exit");
56         }
57       else
58         {
59           // it may be better to not call all the destruction stuff
60           // because of unresolved static destructor dependency
61           // problems.
62           // SO just do the reset at this point.
63           puts("\033[1mRebooting...\033[0m");
64           platform_reset();
65           break;
66         }
67     }
68 }
69
70 */
71 #include "thread_state.h"
72 int main()
73 {
74   // caution: no stack variables in this function because we're going
75   // to change the stack pointer!
76
77   // make some basic initializations, then create and run the kernel
78   // thread
79   //set_exit_question(&exit_question);
80
81   // disallow all interrupts before we selectively enable them
82   //  pic_disable_all();
83
84   // create kernel thread
85   static Kernel_thread *kernel = new (Ram_quota::root) Kernel_thread;
86   nil_thread = kernel;
87   Task *const ktask = Kernel_task::kernel_task();
88   check(kernel->bind(ktask, User<Utcb>::Ptr(0)));
89   //kdb_ke("init");
90
91   // switch to stack of kernel thread and bootstrap the kernel
92   asm volatile ( " stw %%r1, 0(%[boot_stack]) \n" //save old stack pointer
93                  " mr  %%r1, %[stack]         \n" //new stack
94                  " mr  %%r3, %[kernel]        \n" //"this" pointer
95                  " bl call_bootstrap          \n"
96                  :
97                  : [boot_stack]"r" (&boot_stack),
98                    [stack]"r" (kernel->init_stack()),
99                    [kernel]"r" (kernel)
100                  );
101 }
102