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.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
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.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
22 #include <geekos/vmm_stubs.h>
24 #include <geekos/debug.h>
25 #include <geekos/serial.h>
26 #include <geekos/vm.h>
27 #include <geekos/screen.h>
29 #include <palacios/vmm.h>
30 #include <palacios/vmm_io.h>
33 #define MAGIC_CODE 0xf1e2d3c4
36 struct layout_region {
41 struct guest_mem_layout {
44 struct layout_region regions[0];
49 extern void * g_ramdiskImage;
50 extern ulong_t s_ramdiskSize;
53 int RunVMM(struct Boot_Info * bootInfo) {
54 struct v3_os_hooks os_hooks;
55 struct v3_ctrl_ops v3_ops;
56 struct guest_info * vm_info = 0;
57 struct v3_vm_config vm_config;
60 memset(&os_hooks, 0, sizeof(struct v3_os_hooks));
61 memset(&v3_ops, 0, sizeof(struct v3_ctrl_ops));
62 memset(&vm_config, 0, sizeof(struct v3_vm_config));
65 os_hooks.print_debug = &SerialPrint;
66 os_hooks.print_info = &Print;
67 os_hooks.print_trace = &SerialPrint;
68 os_hooks.allocate_pages = &Allocate_VMM_Pages;
69 os_hooks.free_page = &Free_VMM_Page;
70 os_hooks.malloc = &VMM_Malloc;
71 os_hooks.free = &VMM_Free;
72 os_hooks.vaddr_to_paddr = &Identity;
73 os_hooks.paddr_to_vaddr = &Identity;
74 os_hooks.hook_interrupt = &geekos_hook_interrupt;
75 os_hooks.ack_irq = &ack_irq;
76 os_hooks.get_cpu_khz = &get_cpu_khz;
80 Init_V3(&os_hooks, &v3_ops);
83 extern char _binary___palacios_vm_kernel_start;
84 PrintBoth(" Guest Load Addr: 0x%x\n", &_binary___palacios_vm_kernel_start);
86 struct guest_mem_layout * layout = (struct guest_mem_layout *)&_binary___palacios_vm_kernel_start;
88 if (layout->magic != MAGIC_CODE) {
90 PrintBoth("Layout Magic Mismatch (0x%x)\n", layout->magic);
94 PrintBoth("%d layout regions\n", layout->num_regions);
96 region_start = (void *)&(layout->regions[layout->num_regions]);
98 PrintBoth("region start = 0x%x\n", region_start);
102 struct layout_region * rombios = &(layout->regions[0]);
103 struct layout_region * vgabios = &(layout->regions[1]);
105 vm_config.rombios = region_start;
106 vm_config.rombios_size = rombios->length;
108 vm_config.mem_size = 128 * 1024 * 1024;
110 region_start += rombios->length;
113 vm_config.enable_profiling = 1;
115 vm_config.enable_profiling = 0;
117 vm_config.enable_pci = 1;
119 vm_config.vgabios = region_start;
120 vm_config.vgabios_size = vgabios->length;
126 if (g_ramdiskImage != NULL) {
127 vm_config.use_ram_cd = 1;
128 vm_config.ramdisk = g_ramdiskImage;
129 vm_config.ramdisk_size = s_ramdiskSize;
134 vm_info = (v3_ops).allocate_guest();
138 PrintBoth("Allocated Guest\n");
143 PrintBoth("Initializing guest\n");
144 (v3_ops).init_guest(vm_info, &vm_config);
146 PrintBoth("Starting Guest\n");
149 (v3_ops).start_guest(vm_info);