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.


Update to the device framework.
[palacios.git] / palacios / include / palacios / vmm_dev_mgr.h
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 #ifndef _VMM_DEV_MGR
21 #define _VMM_DEV_MGR
22
23 #ifdef __V3VEE__
24
25 #include <palacios/vmm_types.h>
26 #include <palacios/vmm_list.h>
27 #include <palacios/vmm_string.h>
28 #include <palacios/vmm_hashtable.h>
29
30
31 struct guest_info;
32
33 struct v3_device_ops;
34
35
36 struct vm_device {
37     char name[32];
38   
39     void * private_data;
40
41     struct v3_device_ops * ops;
42
43     struct guest_info * vm;
44
45     struct list_head dev_link;
46
47
48     uint_t num_io_hooks;
49     struct list_head io_hooks;
50 };
51
52
53 struct vmm_dev_mgr {
54     uint_t num_devs;
55     struct list_head dev_list;
56
57     struct hashtable * dev_table;
58 };
59
60
61
62
63 int v3_create_device(struct guest_info * info, const char * dev_name, void * cfg_data);
64 void v3_free_device(struct vm_device * dev);
65
66
67 struct vm_device * v3_find_dev(struct guest_info * info, const char * dev_name);
68
69
70 // Registration of devices
71
72 //
73 // The following device manager functions should only be called
74 // when the guest is stopped
75 //
76
77
78
79 int v3_init_dev_mgr(struct guest_info * info);
80 int v3_dev_mgr_deinit(struct guest_info * info);
81
82
83
84
85 int v3_init_devices();
86
87
88 struct v3_device_ops {
89     int (*free)(struct vm_device *dev);
90
91
92     int (*reset)(struct vm_device *dev);
93
94     int (*start)(struct vm_device *dev);
95     int (*stop)(struct vm_device *dev);
96
97
98     //int (*save)(struct vm_device *dev, struct *iostream);
99     //int (*restore)(struct vm_device *dev, struct *iostream);
100 };
101
102
103
104
105
106
107 int v3_dev_hook_io(struct vm_device   *dev,
108                    ushort_t            port,
109                    int (*read)(ushort_t port, void * dst, uint_t length, struct vm_device * dev),
110                    int (*write)(ushort_t port, void * src, uint_t length, struct vm_device * dev));
111
112 int v3_dev_unhook_io(struct vm_device   *dev,
113                      ushort_t            port);
114
115
116 int v3_attach_device(struct guest_info * vm, struct vm_device * dev);
117 int v3_detach_device(struct vm_device * dev);
118
119 struct vm_device * v3_allocate_device(char * name, struct v3_device_ops * ops, void * private_data);
120
121
122 struct v3_device_info {
123     char * name;
124     int (*init)(struct guest_info * info, void * cfg_data);
125 };
126
127
128 #define device_register(name, init_dev_fn)                              \
129     static char _v3_device_name[] = name;                               \
130     static struct v3_device_info _v3_device                             \
131     __attribute__((__used__))                                           \
132         __attribute__((unused, __section__ ("_v3_devices"),             \
133                        aligned(sizeof(addr_t))))                        \
134         = {_v3_device_name , init_dev_fn};
135
136
137
138
139 void PrintDebugDevMgr(struct guest_info * info);
140 void PrintDebugDev(struct vm_device * dev);
141
142
143
144
145
146 #endif // ! __V3VEE__
147
148 #endif