Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


709a0ab9a36ce1bc2af592f2bf6c9c8844cfee3a
[palacios-OLD.git] / kitten / init / main.c
1 #include <lwk/init.h>
2 #include <lwk/kernel.h>
3 #include <lwk/params.h>
4 #include <lwk/console.h>
5 #include <lwk/cpuinfo.h>
6 #include <lwk/percpu.h>
7 #include <lwk/smp.h>
8 #include <lwk/cpuinfo.h>
9 #include <lwk/delay.h>
10 #include <lwk/bootmem.h>
11 #include <lwk/aspace.h>
12 #include <lwk/task.h>
13 #include <lwk/sched.h>
14 #include <lwk/timer.h>
15 #include <lwk/palacios.h>
16
17 /**
18  * Pristine copy of the LWK boot command line.
19  */
20 char lwk_command_line[COMMAND_LINE_SIZE];
21
22
23 /**
24  * This is the architecture-independent kernel entry point. Before it is
25  * called, architecture-specific code has done the bare minimum initialization
26  * necessary. This function initializes the kernel and its various subsystems.
27  * It calls back to architecture-specific code at several well defined points,
28  * which all architectures must implement (e.g., setup_arch()).
29  */
30 void
31 start_kernel()
32 {
33         unsigned int cpu;
34         unsigned int timeout;
35         int status;
36
37         /*
38          * Parse the kernel boot command line.
39          * This is where boot-time configurable variables get set,
40          * e.g., the ones with param() and driver_param() specifiers.
41          */
42         parse_params(lwk_command_line);
43
44         /*
45          * Initialize the console subsystem.
46          * printk()'s will be visible after this.
47          */
48         console_init();
49
50         /*
51          * Hello, Dave.
52          */
53         printk(lwk_banner);
54         printk(KERN_DEBUG "%s\n", lwk_command_line);
55
56         /*
57          * Do architecture specific initialization.
58          * This detects memory, CPUs, etc.
59          */
60         setup_arch();
61
62         /*
63          * Initialize the kernel memory subsystem. Up until now, the simple
64          * boot-time memory allocator (bootmem) has been used for all dynamic
65          * memory allocation. Here, the bootmem allocator is destroyed and all
66          * of the free pages it was managing are added to the kernel memory
67          * pool (kmem) or the user memory pool (umem).
68          *
69          * After this point, any use of the bootmem allocator will cause a
70          * kernel panic. The normal kernel memory subsystem API should be used
71          * instead (e.g., kmem_alloc() and kmem_free()).
72          */
73         mem_subsys_init();
74
75         /*
76          * Initialize the address space management subsystem.
77          */
78         aspace_subsys_init();
79
80         /*
81          * Initialize the task management subsystem.
82          */
83         task_subsys_init();
84
85         /*
86          * Initialize the task scheduling subsystem.
87          */
88         sched_subsys_init();
89
90         /*
91          * Initialize the task scheduling subsystem.
92          */
93         timer_subsys_init();
94
95         /*
96          * Boot all of the other CPUs in the system, one at a time.
97          */
98         printk(KERN_INFO "Number of CPUs detected: %d\n", num_cpus());
99         for_each_cpu_mask(cpu, cpu_present_map) {
100                 /* The bootstrap CPU (that's us) is already booted. */
101                 if (cpu == 0) {
102                         cpu_set(cpu, cpu_online_map);
103                         continue;
104                 }
105
106                 printk(KERN_DEBUG "Booting CPU %u.\n", cpu);
107                 arch_boot_cpu(cpu);
108
109                 /* Wait for ACK that CPU has booted (5 seconds max). */
110                 for (timeout = 0; timeout < 50000; timeout++) {
111                         if (cpu_isset(cpu, cpu_online_map))
112                                 break;
113                         udelay(100);
114                 }
115
116                 if (!cpu_isset(cpu, cpu_online_map))
117                         panic("Failed to boot CPU %d.\n", cpu);
118         }
119
120 #ifdef CONFIG_V3VEE
121         v3vee_run_vmm();
122 #else
123         /*
124          * Start up user-space...
125          */
126         printk(KERN_INFO "Loading initial user-level task (init_task)...\n");
127         if ((status = create_init_task()) != 0)
128                 panic("Failed to create init_task (status=%d).", status);
129
130         schedule();  /* This should not return */
131 #endif
132         BUG();
133 }