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 on VNET-NIC device, and fix vnet & virtio net
[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 #include <palacios/vmm_config.h>
30
31
32 struct v3_vm_info;
33
34 struct v3_device_ops;
35
36
37 struct vm_device {
38     char name[32];
39   
40     void * private_data;
41
42     struct v3_device_ops * ops;
43
44     struct v3_vm_info * vm;
45
46     struct list_head dev_link;
47
48
49     uint_t num_io_hooks;
50     struct list_head io_hooks;
51 };
52
53
54 struct vmm_dev_mgr {
55     uint_t num_devs;
56     struct list_head dev_list;
57     struct hashtable * dev_table;
58
59     struct list_head blk_list;
60     struct hashtable * blk_table;
61
62     struct list_head net_list;
63     struct hashtable * net_table;
64
65     struct list_head console_list;
66     struct hashtable * console_table;
67
68 };
69
70 int v3_create_device(struct v3_vm_info * vm, const char * dev_name, v3_cfg_tree_t * cfg);
71
72
73 void v3_free_device(struct vm_device * dev);
74
75
76 struct vm_device * v3_find_dev(struct v3_vm_info * info, const char * dev_name);
77
78
79 // Registration of devices
80
81 //
82 // The following device manager functions should only be called
83 // when the guest is stopped
84 //
85
86
87
88 int v3_init_dev_mgr(struct v3_vm_info * vm);
89 int v3_dev_mgr_deinit(struct v3_vm_info * vm);
90
91
92
93
94
95
96 int v3_init_devices();
97
98
99 struct v3_device_ops {
100     int (*free)(struct vm_device *dev);
101
102
103     int (*reset)(struct vm_device *dev);
104
105     int (*start)(struct vm_device *dev);
106     int (*stop)(struct vm_device *dev);
107
108
109     //int (*save)(struct vm_device *dev, struct *iostream);
110     //int (*restore)(struct vm_device *dev, struct *iostream);
111 };
112
113
114
115
116
117
118 int v3_dev_hook_io(struct vm_device   *dev,
119                    ushort_t            port,
120                    int (*read)(struct guest_info * core, ushort_t port, void * dst, uint_t length, struct vm_device * dev),
121                    int (*write)(struct guest_info * core, ushort_t port, void * src, uint_t length, struct vm_device * dev));
122
123 int v3_dev_unhook_io(struct vm_device   *dev,
124                      ushort_t            port);
125
126
127 int v3_attach_device(struct v3_vm_info * vm, struct vm_device * dev);
128 int v3_detach_device(struct vm_device * dev);
129
130 struct vm_device * v3_allocate_device(char * name, struct v3_device_ops * ops, void * private_data);
131
132
133 struct v3_device_info {
134     char * name;
135     int (*init)(struct v3_vm_info * info, v3_cfg_tree_t * cfg);
136 };
137
138
139 #define device_register(name, init_dev_fn)                              \
140     static char _v3_device_name[] = name;                               \
141     static struct v3_device_info _v3_device                             \
142     __attribute__((__used__))                                           \
143         __attribute__((unused, __section__ ("_v3_devices"),             \
144                        aligned(sizeof(addr_t))))                        \
145         = {_v3_device_name , init_dev_fn};
146
147
148
149
150 void v3_print_dev_mgr(struct v3_vm_info * vm);
151
152
153 struct v3_dev_blk_ops {
154     uint64_t (*get_capacity)(void * private_data);
155     // Reads always operate on 2048 byte blocks
156     int (*read)(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data);
157     int (*write)(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void * private_data);
158 };
159
160 struct v3_dev_net_ops {
161     int (*send)(uint8_t * buf, uint32_t count, void * private_data, struct vm_device *dest_dev);
162     int (*register_input)(void *backend_data, 
163                                       int (*frontend_input)(struct v3_vm_info *info, 
164                                                                      uchar_t * buf,
165                                                                   uint32_t size,
166                                                                   void *private_data), 
167                                    void *front_data);
168 };
169
170 struct v3_dev_console_ops {
171
172 };
173
174 int v3_dev_add_blk_frontend(struct v3_vm_info * vm, 
175                             char * name, 
176                             int (*connect)(struct v3_vm_info * vm, 
177                                             void * frontend_data, 
178                                             struct v3_dev_blk_ops * ops, 
179                                             v3_cfg_tree_t * cfg, 
180                                             void * private_data), 
181                             void * priv_data);
182 int v3_dev_connect_blk(struct v3_vm_info * vm, 
183                        char * frontend_name, 
184                        struct v3_dev_blk_ops * ops, 
185                        v3_cfg_tree_t * cfg, 
186                        void * private_data);
187
188 int v3_dev_add_net_frontend(struct v3_vm_info * vm, 
189                             char * name, 
190                             int (*connect)(struct v3_vm_info * vm, 
191                                             void * frontend_data, 
192                                             struct v3_dev_net_ops * ops, 
193                                             v3_cfg_tree_t * cfg, 
194                                             void * private_data), 
195                             void * priv_data);
196
197 int v3_dev_connect_net(struct v3_vm_info * vm, 
198                        char * frontend_name, 
199                        struct v3_dev_net_ops * ops, 
200                        v3_cfg_tree_t * cfg, 
201                        void * private_data);
202
203
204 #endif // ! __V3VEE__
205
206 #endif