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.


438a30304b4b07fee479ec160fe8acf980b1f284
[palacios-OLD.git] / kitten / palacios-glue / vm.c
1 /*
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20
21
22 #include <palacios-glue/vmm_stubs.h>
23 #include <palacios-glue/vm.h>
24
25 #include <lwk/kernel.h>
26
27 #include <lwk/palacios.h>
28
29 #include <palacios/vmm.h>
30 #include <palacios/vmm_io.h>
31
32
33
34
35 int RunVMM() {
36   struct v3_os_hooks os_hooks;
37   struct v3_ctrl_ops v3_ops;
38   struct guest_info * vm_info = 0;
39   struct v3_vm_config vm_config;
40
41   void * ramdiskImage=&initrd_start;
42   ulong_t ramdiskSize=(&initrd_end)-(&initrd_start);
43
44   memset(&os_hooks, 0, sizeof(struct v3_os_hooks));
45   memset(&v3_ops, 0, sizeof(struct v3_ctrl_ops));
46   memset(&vm_config, 0, sizeof(struct v3_vm_config));
47
48   
49   os_hooks.print_debug = &printk;  // serial print ideally
50   os_hooks.print_info = &printk;   // serial print ideally
51   os_hooks.print_trace = &printk;  // serial print ideally
52   os_hooks.allocate_pages = &Allocate_VMM_Pages; // defined in vmm_stubs
53   os_hooks.free_page = &Free_VMM_Page; // defined in vmm_stubs
54   os_hooks.malloc = &kmem_alloc;
55   os_hooks.free = &kmem_free;
56   os_hooks.vaddr_to_paddr = &kitten_va_to_pa;
57   os_hooks.paddr_to_vaddr = &kitten_pa_to_va;
58   os_hooks.hook_interrupt = &kitten_hook_interrupt;
59   os_hooks.ack_irq = &ack_irq;
60   os_hooks.get_cpu_khz = &get_cpu_khz;
61
62
63   
64   Init_V3(&os_hooks, &v3_ops);
65
66   
67   vm_config.rombios = &rombios_start;
68   vm_config.rombios_size = (&rombios_end)-(&rombios_start);
69   vm_config.vgabios = &vgabios_start;
70   vm_config.vgabios_size = (&vgabios_end)-(&vgabios_start);
71   
72   
73   if (ramdiskImage != NULL) {
74     vm_config.use_ramdisk = 1;
75     vm_config.ramdisk = ramdiskImage;
76     vm_config.ramdisk_size = ramdiskSize;
77   }
78
79
80
81   vm_info = (v3_ops).allocate_guest();
82
83   Init_Stubs(vm_info);
84
85   //PrintBoth("Allocated Guest\n");
86
87   (v3_ops).config_guest(vm_info, &vm_config);
88
89   //PrintBoth("Configured guest\n");
90
91   (v3_ops).init_guest(vm_info);
92   PrintBoth("Starting Guest\n");
93   //Clear_Screen();
94
95   (v3_ops).start_guest(vm_info);
96   
97     return 0;
98 }