virtio-net: introduce a new macaddr control
[qemu/ar7.git] / hw / virtio-bus.h
blob7584a0e6ae3c7fed9bcb22616fb9a3717b6ea282
1 /*
2 * VirtioBus
4 * Copyright (C) 2012 : GreenSocs Ltd
5 * http://www.greensocs.com/ , email: info@greensocs.com
7 * Developed by :
8 * Frederic Konrad <fred.konrad@greensocs.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, see <http://www.gnu.org/licenses/>.
25 #ifndef VIRTIO_BUS_H
26 #define VIRTIO_BUS_H
28 #include "qdev.h"
29 #include "sysemu/sysemu.h"
30 #include "virtio.h"
32 #define TYPE_VIRTIO_BUS "virtio-bus"
33 #define VIRTIO_BUS_GET_CLASS(obj) \
34 OBJECT_GET_CLASS(VirtioBusClass, obj, TYPE_VIRTIO_BUS)
35 #define VIRTIO_BUS_CLASS(klass) \
36 OBJECT_CLASS_CHECK(VirtioBusClass, klass, TYPE_VIRTIO_BUS)
37 #define VIRTIO_BUS(obj) OBJECT_CHECK(VirtioBusState, (obj), TYPE_VIRTIO_BUS)
39 typedef struct VirtioBusState VirtioBusState;
41 typedef struct VirtioBusClass {
42 /* This is what a VirtioBus must implement */
43 BusClass parent;
44 void (*notify)(DeviceState *d, uint16_t vector);
45 void (*save_config)(DeviceState *d, QEMUFile *f);
46 void (*save_queue)(DeviceState *d, int n, QEMUFile *f);
47 int (*load_config)(DeviceState *d, QEMUFile *f);
48 int (*load_queue)(DeviceState *d, int n, QEMUFile *f);
49 int (*load_done)(DeviceState *d, QEMUFile *f);
50 unsigned (*get_features)(DeviceState *d);
51 bool (*query_guest_notifiers)(DeviceState *d);
52 int (*set_guest_notifiers)(DeviceState *d, int nvqs, bool assign);
53 int (*set_host_notifier)(DeviceState *d, int n, bool assigned);
54 void (*vmstate_change)(DeviceState *d, bool running);
56 * transport independent init function.
57 * This is called by virtio-bus just after the device is plugged.
59 void (*device_plugged)(DeviceState *d);
61 * transport independent exit function.
62 * This is called by virtio-bus just before the device is unplugged.
64 void (*device_unplug)(DeviceState *d);
65 } VirtioBusClass;
67 struct VirtioBusState {
68 BusState parent_obj;
70 * Only one VirtIODevice can be plugged on the bus.
72 VirtIODevice *vdev;
74 * This will be removed at the end of the series.
76 VirtIOBindings bindings;
79 int virtio_bus_plug_device(VirtIODevice *vdev);
80 void virtio_bus_reset(VirtioBusState *bus);
81 void virtio_bus_destroy_device(VirtioBusState *bus);
82 /* Get the device id of the plugged device. */
83 uint16_t virtio_bus_get_vdev_id(VirtioBusState *bus);
84 /* Get the config_len field of the plugged device. */
85 size_t virtio_bus_get_vdev_config_len(VirtioBusState *bus);
86 /* Get the features of the plugged device. */
87 uint32_t virtio_bus_get_vdev_features(VirtioBusState *bus,
88 uint32_t requested_features);
89 /* Get bad features of the plugged device. */
90 uint32_t virtio_bus_get_vdev_bad_features(VirtioBusState *bus);
91 /* Get config of the plugged device. */
92 void virtio_bus_get_vdev_config(VirtioBusState *bus, uint8_t *config);
94 #endif /* VIRTIO_BUS_H */