Merge tag 'v1.2.0' into tizen-arm
[sdk/emulator/qemu.git] / hw / virtio-transport.h
1 /*
2  * Virtio transport header
3  *
4  * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd.
5  *
6  * Author:
7  *  Evgeny Voevodin <e.voevodin@samsung.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #ifndef VIRTIO_TRANSPORT_H_
23 #define VIRTIO_TRANSPORT_H_
24
25 #include "qdev.h"
26 #include "qemu-common.h"
27
28 #define VIRTIO_MMIO "virtio-mmio"
29 #define VIRTIO_PCI "virtio-pci"
30
31 #define TYPE_VIRTIO_BUS "virtio-bus"
32 #define VIRTIO_BUS(obj) OBJECT_CHECK(virtio_bus, (obj), TYPE_VIRTIO_BUS)
33
34 struct VirtIOTransportLink;
35
36 typedef int (*virtio_backend_init_cb)(DeviceState *dev, VirtIODevice *vdev,
37              struct VirtIOTransportLink *trl);
38
39 typedef struct VirtIOTransportLink {
40     DeviceState *tr;
41     virtio_backend_init_cb cb;
42     uint32_t host_features;
43     QTAILQ_ENTRY(VirtIOTransportLink) sibling;
44 } VirtIOTransportLink;
45
46 /*
47  * Find transport device by its ID.
48  */
49 VirtIOTransportLink* virtio_find_transport(const char *name);
50
51 /*
52  * Count transport devices by ID.
53  */
54 uint32_t virtio_count_transports(const char *name);
55
56 /*
57  * Initialize new transport device
58  */
59 char* virtio_init_transport(DeviceState *dev, VirtIOTransportLink **trl,
60         const char* name, virtio_backend_init_cb cb);
61
62 /*
63  * Unplug back-end from system bus and plug it into transport bus.
64  */
65 void virtio_plug_into_transport(DeviceState *dev, VirtIOTransportLink *trl);
66
67 /*
68  * Execute call-back on back-end initialization.
69  * Performs initialization of MMIO or PCI transport.
70  */
71 int virtio_call_backend_init_cb(DeviceState *dev, VirtIOTransportLink *trl,
72         VirtIODevice *vdev);
73
74 #endif /* VIRTIO_TRANSPORT_H_ */