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.


removed a lot of pointless stuff from the device manager
[palacios.git] / palacios / src / palacios / vmm_dev_mgr.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 #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>
25
26
27 #ifndef DEBUG_DEV_MGR
28 #undef PrintDebug
29 #define PrintDebug(fmt, args...)
30 #endif
31
32
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);
36
37 int v3_init_dev_mgr(struct guest_info * info) {
38     struct vmm_dev_mgr * mgr = &(info->dev_mgr);
39
40     INIT_LIST_HEAD(&(mgr->dev_list));
41     mgr->num_devs = 0;
42
43     //   mgr->dev_table = v3_create_htable(0, , );
44
45     return 0;
46 }
47
48
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;
53
54     list_for_each_entry_safe(dev, tmp, &(mgr->dev_list), dev_link) {
55         v3_detach_device(dev);
56         v3_free_device(dev);
57     }
58
59     return 0;
60 }
61
62
63
64 int v3_attach_device(struct guest_info * vm, struct vm_device * dev) {
65     struct vmm_dev_mgr *mgr= &(vm->dev_mgr);
66   
67     dev->vm = vm;
68
69     list_add(&(dev->dev_link), &(mgr->dev_list));
70     mgr->num_devs++;
71
72     dev->ops->init(dev);
73
74     return 0;
75 }
76
77 int v3_detach_device(struct vm_device * dev) {
78     struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr);
79
80     dev->ops->deinit(dev);
81
82     list_del(&(dev->dev_link));
83     mgr->num_devs--;
84
85     dev->vm = NULL;
86
87     return 0;
88 }
89
90
91
92
93
94 /* IO HOOKS */
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, 
101                            (void *)dev);
102 }
103
104
105 int v3_dev_unhook_io(struct vm_device * dev, uint16_t port) {
106     return v3_unhook_io_port(dev->vm, port);
107 }
108
109
110
111
112
113 #ifdef DEBUG_DEV_MGR
114
115 void PrintDebugDevMgr(struct guest_info * info) {
116     struct vmm_dev_mgr * mgr = &(info->dev_mgr);
117     struct vm_device * dev;
118
119     PrintDebug("%d devices registered with manager\n", mgr->num_devs);
120
121     list_for_each_entry(dev, &(mgr->dev_list), dev_link) {
122         PrintDebugDev(dev);
123         PrintDebug("next..\n");
124     }
125
126     return;
127 }
128
129
130 void PrintDebugDev(struct vm_device * dev) {
131     PrintDebug("Device: %s\n", dev->name);
132 }
133
134
135
136
137 #else 
138 void PrintDebugDevMgr(struct guest_info * info) {}
139 void PrintDebugDev(struct vm_device * dev) {}
140 #endif