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) 2011, Peter Dinda <pdinda@northwestern.edu>
11 * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Peter Dinda <pdinda@northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <interfaces/vmm_host_dev.h>
22 #include <palacios/vmm.h>
23 #include <palacios/vmm_debug.h>
24 #include <palacios/vmm_types.h>
25 #include <palacios/vm_guest.h>
26 #include <palacios/vm_guest_mem.h>
28 struct v3_host_dev_hooks * host_dev_hooks = 0;
30 v3_host_dev_t v3_host_dev_open(char *impl,
34 V3_ASSERT(host_dev_hooks != NULL);
35 V3_ASSERT(host_dev_hooks->open != NULL);
37 return host_dev_hooks->open(impl,bus,gdev);
40 int v3_host_dev_close(v3_host_dev_t hdev)
42 V3_ASSERT(host_dev_hooks);
43 V3_ASSERT(host_dev_hooks->close);
45 return host_dev_hooks->close(hdev);
48 uint64_t v3_host_dev_read_io(v3_host_dev_t hdev,
53 V3_ASSERT(host_dev_hooks != NULL);
54 V3_ASSERT(host_dev_hooks->read_io != NULL);
56 return host_dev_hooks->read_io(hdev,port,dst,len);
59 uint64_t v3_host_dev_write_io(v3_host_dev_t hdev,
64 V3_ASSERT(host_dev_hooks != NULL);
65 V3_ASSERT(host_dev_hooks->write_io != NULL);
67 return host_dev_hooks->write_io(hdev,port,src,len);
70 uint64_t v3_host_dev_read_mem(v3_host_dev_t hdev,
75 V3_ASSERT(host_dev_hooks != NULL);
76 V3_ASSERT(host_dev_hooks->read_mem != NULL);
78 return host_dev_hooks->read_mem(hdev,gpa,dst,len);
81 uint64_t v3_host_dev_write_mem(v3_host_dev_t hdev,
86 V3_ASSERT(host_dev_hooks != NULL);
87 V3_ASSERT(host_dev_hooks->write_mem != NULL);
89 return host_dev_hooks->write_mem(hdev,gpa,src,len);
92 uint64_t v3_host_dev_read_config(v3_host_dev_t hdev,
97 V3_ASSERT(host_dev_hooks != NULL);
98 V3_ASSERT(host_dev_hooks->read_config);
100 return host_dev_hooks->read_config(hdev,offset,dst,len);
103 uint64_t v3_host_dev_write_config(v3_host_dev_t hdev,
108 V3_ASSERT(host_dev_hooks != NULL);
109 V3_ASSERT(host_dev_hooks->write_config);
111 return host_dev_hooks->write_config(hdev,offset,src,len);
116 int v3_host_dev_ack_irq(v3_host_dev_t hdev, uint8_t irq)
118 V3_ASSERT(host_dev_hooks != NULL);
119 V3_ASSERT(host_dev_hooks->ack_irq);
121 return host_dev_hooks->ack_irq(hdev,irq);
125 int v3_host_dev_raise_irq(v3_host_dev_t hostdev,
126 v3_guest_dev_t guest_dev,
129 // Make this smarter later...
131 struct vm_device *dev = (struct vm_device *) guest_dev;
133 if (dev && dev->vm) {
134 return v3_raise_irq(dev->vm,irq);
141 uint64_t v3_host_dev_read_guest_mem(v3_host_dev_t hostdev,
142 v3_guest_dev_t guest_dev,
147 struct vm_device *dev = (struct vm_device *) guest_dev;
152 struct v3_vm_info *vm = dev->vm;
157 return v3_read_gpa_memory(&(vm->cores[0]), gpa, len, dst);
162 uint64_t v3_host_dev_write_guest_mem(v3_host_dev_t hostdev,
163 v3_guest_dev_t guest_dev,
168 struct vm_device *dev = (struct vm_device *) guest_dev;
173 struct v3_vm_info *vm = dev->vm;
178 return v3_write_gpa_memory(&(vm->cores[0]), gpa, len, src);
185 void V3_Init_Host_Device_Support(struct v3_host_dev_hooks * hooks) {
186 host_dev_hooks = hooks;
187 PrintDebug("V3 host device interface inited\n");