hw/9pfs: Endian fixes for virtfs
[qemu.git] / hw / s390-virtio-bus.h
blobb5e59b7d4b982338ecdc8f27d007c599a3e3fdd6
1 /*
2 * QEMU S390x VirtIO BUS definitions
4 * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "virtio-net.h"
21 #include "virtio-serial.h"
23 #define VIRTIO_DEV_OFFS_TYPE 0 /* 8 bits */
24 #define VIRTIO_DEV_OFFS_NUM_VQ 1 /* 8 bits */
25 #define VIRTIO_DEV_OFFS_FEATURE_LEN 2 /* 8 bits */
26 #define VIRTIO_DEV_OFFS_CONFIG_LEN 3 /* 8 bits */
27 #define VIRTIO_DEV_OFFS_STATUS 4 /* 8 bits */
28 #define VIRTIO_DEV_OFFS_CONFIG 5 /* dynamic */
30 #define VIRTIO_VQCONFIG_OFFS_TOKEN 0 /* 64 bits */
31 #define VIRTIO_VQCONFIG_OFFS_ADDRESS 8 /* 64 bits */
32 #define VIRTIO_VQCONFIG_OFFS_NUM 16 /* 16 bits */
33 #define VIRTIO_VQCONFIG_LEN 24
35 #define VIRTIO_RING_LEN (TARGET_PAGE_SIZE * 3)
36 #define S390_DEVICE_PAGES 512
38 #define VIRTIO_PARAM_MASK 0xff
39 #define VIRTIO_PARAM_VRING_INTERRUPT 0x0
40 #define VIRTIO_PARAM_CONFIG_CHANGED 0x1
41 #define VIRTIO_PARAM_DEV_ADD 0x2
43 #define TYPE_VIRTIO_S390_DEVICE "virtio-s390-device"
44 #define VIRTIO_S390_DEVICE(obj) \
45 OBJECT_CHECK(VirtIOS390Device, (obj), TYPE_VIRTIO_S390_DEVICE)
46 #define VIRTIO_S390_DEVICE_CLASS(klass) \
47 OBJECT_CLASS_CHECK(VirtIOS390DeviceClass, (klass), TYPE_VIRTIO_S390_DEVICE)
48 #define VIRTIO_S390_DEVICE_GET_CLASS(obj) \
49 OBJECT_GET_CLASS(VirtIOS390DeviceClass, (obj), TYPE_VIRTIO_S390_DEVICE)
51 typedef struct VirtIOS390Device VirtIOS390Device;
53 typedef struct VirtIOS390DeviceClass {
54 DeviceClass qdev;
55 int (*init)(VirtIOS390Device *dev);
56 } VirtIOS390DeviceClass;
58 struct VirtIOS390Device {
59 DeviceState qdev;
60 ram_addr_t dev_offs;
61 ram_addr_t feat_offs;
62 uint8_t feat_len;
63 VirtIODevice *vdev;
64 BlockConf block;
65 char *block_serial;
66 NICConf nic;
67 uint32_t host_features;
68 virtio_serial_conf serial;
69 virtio_net_conf net;
72 typedef struct VirtIOS390Bus {
73 BusState bus;
75 VirtIOS390Device *console;
76 ram_addr_t dev_page;
77 ram_addr_t dev_offs;
78 ram_addr_t next_ring;
79 } VirtIOS390Bus;
82 void s390_virtio_device_update_status(VirtIOS390Device *dev);
84 VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus);
85 VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size);
87 VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus,
88 ram_addr_t mem, int *vq_num);
89 VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem);
90 void s390_virtio_device_sync(VirtIOS390Device *dev);