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".
20 #include <palacios/vm_dev.h>
21 #include <palacios/vmm_dev_mgr.h>
22 #include <palacios/vm_guest.h>
23 #include <palacios/vmm.h>
24 #include <palacios/vmm_decoder.h>
29 #define PrintDebug(fmt, args...)
33 //DEFINE_HASHTABLE_INSERT(insert_dev, const char *, struct vm_device *);
34 //DEFINE_HASHTABLE_SEARCH(find_dev, const char *, struct vm_device *);
35 //DEFINE_HASHTABLE_REMOVE(remove_dev, const char *, struct vm_device *, 0);
37 int v3_init_dev_mgr(struct guest_info * info) {
38 struct vmm_dev_mgr * mgr = &(info->dev_mgr);
40 INIT_LIST_HEAD(&(mgr->dev_list));
43 // mgr->dev_table = v3_create_htable(0, , );
49 int v3_dev_mgr_deinit(struct guest_info * info) {
50 struct vm_device * dev;
51 struct vmm_dev_mgr * mgr = &(info->dev_mgr);
52 struct vm_device * tmp;
54 list_for_each_entry_safe(dev, tmp, &(mgr->dev_list), dev_link) {
55 v3_detach_device(dev);
64 int v3_attach_device(struct guest_info * vm, struct vm_device * dev) {
65 struct vmm_dev_mgr *mgr= &(vm->dev_mgr);
69 list_add(&(dev->dev_link), &(mgr->dev_list));
77 int v3_detach_device(struct vm_device * dev) {
78 struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr);
80 dev->ops->deinit(dev);
82 list_del(&(dev->dev_link));
95 int v3_dev_hook_io(struct vm_device * dev, uint16_t port,
96 int (*read)(uint16_t port, void * dst, uint_t length, struct vm_device * dev),
97 int (*write)(uint16_t port, void * src, uint_t length, struct vm_device * dev)) {
98 return v3_hook_io_port(dev->vm, port,
99 (int (*)(ushort_t, void *, uint_t, void *))read,
100 (int (*)(ushort_t, void *, uint_t, void *))write,
105 int v3_dev_unhook_io(struct vm_device * dev, uint16_t port) {
106 return v3_unhook_io_port(dev->vm, port);
115 void PrintDebugDevMgr(struct guest_info * info) {
116 struct vmm_dev_mgr * mgr = &(info->dev_mgr);
117 struct vm_device * dev;
119 PrintDebug("%d devices registered with manager\n", mgr->num_devs);
121 list_for_each_entry(dev, &(mgr->dev_list), dev_link) {
123 PrintDebug("next..\n");
130 void PrintDebugDev(struct vm_device * dev) {
131 PrintDebug("Device: %s\n", dev->name);
138 void PrintDebugDevMgr(struct guest_info * info) {}
139 void PrintDebugDev(struct vm_device * dev) {}