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,
33 struct v3_vm_info *vm)
35 V3_ASSERT(host_dev_hooks != NULL);
36 V3_ASSERT(host_dev_hooks->open != NULL);
38 return host_dev_hooks->open(impl,bus,gdev,vm->host_priv_data);
41 int v3_host_dev_close(v3_host_dev_t hdev)
43 V3_ASSERT(host_dev_hooks);
44 V3_ASSERT(host_dev_hooks->close);
46 return host_dev_hooks->close(hdev);
49 uint64_t v3_host_dev_read_io(v3_host_dev_t hdev,
54 V3_ASSERT(host_dev_hooks != NULL);
55 V3_ASSERT(host_dev_hooks->read_io != NULL);
57 return host_dev_hooks->read_io(hdev,port,dst,len);
60 uint64_t v3_host_dev_write_io(v3_host_dev_t hdev,
65 V3_ASSERT(host_dev_hooks != NULL);
66 V3_ASSERT(host_dev_hooks->write_io != NULL);
68 return host_dev_hooks->write_io(hdev,port,src,len);
71 uint64_t v3_host_dev_read_mem(v3_host_dev_t hdev,
76 V3_ASSERT(host_dev_hooks != NULL);
77 V3_ASSERT(host_dev_hooks->read_mem != NULL);
79 return host_dev_hooks->read_mem(hdev,gpa,dst,len);
82 uint64_t v3_host_dev_write_mem(v3_host_dev_t hdev,
87 V3_ASSERT(host_dev_hooks != NULL);
88 V3_ASSERT(host_dev_hooks->write_mem != NULL);
90 return host_dev_hooks->write_mem(hdev,gpa,src,len);
93 uint64_t v3_host_dev_read_config(v3_host_dev_t hdev,
98 V3_ASSERT(host_dev_hooks != NULL);
99 V3_ASSERT(host_dev_hooks->read_config);
101 return host_dev_hooks->read_config(hdev,offset,dst,len);
104 uint64_t v3_host_dev_write_config(v3_host_dev_t hdev,
109 V3_ASSERT(host_dev_hooks != NULL);
110 V3_ASSERT(host_dev_hooks->write_config);
112 return host_dev_hooks->write_config(hdev,offset,src,len);
117 int v3_host_dev_ack_irq(v3_host_dev_t hdev, uint8_t irq)
119 V3_ASSERT(host_dev_hooks != NULL);
120 V3_ASSERT(host_dev_hooks->ack_irq);
122 return host_dev_hooks->ack_irq(hdev,irq);
126 int v3_host_dev_raise_irq(v3_host_dev_t hostdev,
127 v3_guest_dev_t guest_dev,
130 // Make this smarter later...
132 struct vm_device *dev = (struct vm_device *) guest_dev;
134 if (dev && dev->vm) {
135 return v3_raise_irq(dev->vm,irq);
142 uint64_t v3_host_dev_read_guest_mem(v3_host_dev_t hostdev,
143 v3_guest_dev_t guest_dev,
148 struct vm_device *dev = (struct vm_device *) guest_dev;
153 struct v3_vm_info *vm = dev->vm;
158 return v3_read_gpa_memory(&(vm->cores[0]), gpa, len, dst);
163 uint64_t v3_host_dev_write_guest_mem(v3_host_dev_t hostdev,
164 v3_guest_dev_t guest_dev,
169 struct vm_device *dev = (struct vm_device *) guest_dev;
174 struct v3_vm_info *vm = dev->vm;
179 return v3_write_gpa_memory(&(vm->cores[0]), gpa, len, src);
186 void V3_Init_Host_Device_Support(struct v3_host_dev_hooks * hooks) {
187 host_dev_hooks = hooks;
188 PrintDebug("V3 host device interface inited\n");