]> git.proxmox.com Git - qemu.git/blame - hw/s390-virtio-bus.h
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging
[qemu.git] / hw / s390-virtio-bus.h
CommitLineData
f3304eea
AG
1/*
2 * QEMU S390x VirtIO BUS definitions
3 *
4 * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
5 *
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.
10 *
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.
15 *
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/>.
18 */
19
6c33286a 20#include "virtio-net.h"
6be9b414 21#include "virtio-serial.h"
973abc7f 22#include "virtio-scsi.h"
6c33286a 23
f3304eea
AG
24#define VIRTIO_DEV_OFFS_TYPE 0 /* 8 bits */
25#define VIRTIO_DEV_OFFS_NUM_VQ 1 /* 8 bits */
26#define VIRTIO_DEV_OFFS_FEATURE_LEN 2 /* 8 bits */
27#define VIRTIO_DEV_OFFS_CONFIG_LEN 3 /* 8 bits */
28#define VIRTIO_DEV_OFFS_STATUS 4 /* 8 bits */
29#define VIRTIO_DEV_OFFS_CONFIG 5 /* dynamic */
30
31#define VIRTIO_VQCONFIG_OFFS_TOKEN 0 /* 64 bits */
32#define VIRTIO_VQCONFIG_OFFS_ADDRESS 8 /* 64 bits */
33#define VIRTIO_VQCONFIG_OFFS_NUM 16 /* 16 bits */
34#define VIRTIO_VQCONFIG_LEN 24
35
36#define VIRTIO_RING_LEN (TARGET_PAGE_SIZE * 3)
4170aea1
JF
37#define VIRTIO_VRING_AVAIL_IDX_OFFS 2
38#define VIRTIO_VRING_USED_IDX_OFFS 2
d1ff903c 39#define S390_DEVICE_PAGES 512
f3304eea 40
7fa41e53
AG
41#define VIRTIO_PARAM_MASK 0xff
42#define VIRTIO_PARAM_VRING_INTERRUPT 0x0
43#define VIRTIO_PARAM_CONFIG_CHANGED 0x1
44#define VIRTIO_PARAM_DEV_ADD 0x2
45
39bffca2
AL
46#define TYPE_VIRTIO_S390_DEVICE "virtio-s390-device"
47#define VIRTIO_S390_DEVICE(obj) \
48 OBJECT_CHECK(VirtIOS390Device, (obj), TYPE_VIRTIO_S390_DEVICE)
49#define VIRTIO_S390_DEVICE_CLASS(klass) \
50 OBJECT_CLASS_CHECK(VirtIOS390DeviceClass, (klass), TYPE_VIRTIO_S390_DEVICE)
51#define VIRTIO_S390_DEVICE_GET_CLASS(obj) \
52 OBJECT_GET_CLASS(VirtIOS390DeviceClass, (obj), TYPE_VIRTIO_S390_DEVICE)
53
54typedef struct VirtIOS390Device VirtIOS390Device;
55
56typedef struct VirtIOS390DeviceClass {
57 DeviceClass qdev;
58 int (*init)(VirtIOS390Device *dev);
59} VirtIOS390DeviceClass;
60
61struct VirtIOS390Device {
f3304eea
AG
62 DeviceState qdev;
63 ram_addr_t dev_offs;
64 ram_addr_t feat_offs;
65 uint8_t feat_len;
66 VirtIODevice *vdev;
428c149b 67 BlockConf block;
a8686a9b 68 char *block_serial;
f3304eea 69 NICConf nic;
8172539d 70 uint32_t host_features;
6be9b414 71 virtio_serial_conf serial;
f0c07c7c 72 virtio_net_conf net;
973abc7f 73 VirtIOSCSIConf scsi;
39bffca2 74};
f3304eea
AG
75
76typedef struct VirtIOS390Bus {
77 BusState bus;
78
79 VirtIOS390Device *console;
80 ram_addr_t dev_page;
81 ram_addr_t dev_offs;
82 ram_addr_t next_ring;
83} VirtIOS390Bus;
84
85
64b85a8f 86void s390_virtio_device_update_status(VirtIOS390Device *dev);
f3304eea 87
64b85a8f
BS
88VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus);
89VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size);
f3304eea 90
64b85a8f
BS
91VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus,
92 ram_addr_t mem, int *vq_num);
93VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem);
94void s390_virtio_device_sync(VirtIOS390Device *dev);
4170aea1
JF
95void s390_virtio_reset_idx(VirtIOS390Device *dev);
96