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.


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