blob: 1daf753884138f940265f072687b264de610fc90 [file] [log] [blame]
Alexander Graff3304ee2009-12-05 12:44:27 +01001/*
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 */
Paolo Bonzinicb9c3772012-12-06 12:15:58 +010019#ifndef HW_S390_VIRTIO_BUS_H
20#define HW_S390_VIRTIO_BUS_H 1
Alexander Graff3304ee2009-12-05 12:44:27 +010021
Paolo Bonzini0d09e412013-02-05 17:06:20 +010022#include "hw/virtio/virtio-blk.h"
23#include "hw/virtio/virtio-net.h"
24#include "hw/virtio/virtio-rng.h"
25#include "hw/virtio/virtio-serial.h"
26#include "hw/virtio/virtio-scsi.h"
27#include "hw/virtio/virtio-bus.h"
Alexander Graf6c332862010-11-17 13:01:04 +010028
Alexander Graff3304ee2009-12-05 12:44:27 +010029#define VIRTIO_DEV_OFFS_TYPE 0 /* 8 bits */
30#define VIRTIO_DEV_OFFS_NUM_VQ 1 /* 8 bits */
31#define VIRTIO_DEV_OFFS_FEATURE_LEN 2 /* 8 bits */
32#define VIRTIO_DEV_OFFS_CONFIG_LEN 3 /* 8 bits */
33#define VIRTIO_DEV_OFFS_STATUS 4 /* 8 bits */
34#define VIRTIO_DEV_OFFS_CONFIG 5 /* dynamic */
35
36#define VIRTIO_VQCONFIG_OFFS_TOKEN 0 /* 64 bits */
37#define VIRTIO_VQCONFIG_OFFS_ADDRESS 8 /* 64 bits */
38#define VIRTIO_VQCONFIG_OFFS_NUM 16 /* 16 bits */
39#define VIRTIO_VQCONFIG_LEN 24
40
41#define VIRTIO_RING_LEN (TARGET_PAGE_SIZE * 3)
Jens Freimann4170aea2012-04-26 09:03:36 +000042#define VIRTIO_VRING_AVAIL_IDX_OFFS 2
43#define VIRTIO_VRING_USED_IDX_OFFS 2
Alexander Grafd1ff9032011-04-13 10:55:11 +020044#define S390_DEVICE_PAGES 512
Alexander Graff3304ee2009-12-05 12:44:27 +010045
Alexander Graf7fa41e52010-08-23 18:58:34 +020046#define VIRTIO_PARAM_MASK 0xff
47#define VIRTIO_PARAM_VRING_INTERRUPT 0x0
48#define VIRTIO_PARAM_CONFIG_CHANGED 0x1
49#define VIRTIO_PARAM_DEV_ADD 0x2
50
Anthony Liguori39bffca2011-12-07 21:34:16 -060051#define TYPE_VIRTIO_S390_DEVICE "virtio-s390-device"
52#define VIRTIO_S390_DEVICE(obj) \
53 OBJECT_CHECK(VirtIOS390Device, (obj), TYPE_VIRTIO_S390_DEVICE)
54#define VIRTIO_S390_DEVICE_CLASS(klass) \
55 OBJECT_CLASS_CHECK(VirtIOS390DeviceClass, (klass), TYPE_VIRTIO_S390_DEVICE)
56#define VIRTIO_S390_DEVICE_GET_CLASS(obj) \
57 OBJECT_GET_CLASS(VirtIOS390DeviceClass, (obj), TYPE_VIRTIO_S390_DEVICE)
58
Anthony Liguori0d936922012-05-02 09:00:20 +020059#define TYPE_S390_VIRTIO_BUS "s390-virtio-bus"
60#define S390_VIRTIO_BUS(obj) \
61 OBJECT_CHECK(VirtIOS390Bus, (obj), TYPE_S390_VIRTIO_BUS)
62
KONRAD Fredericea35d4f2013-01-15 00:08:05 +010063/* virtio-s390-bus */
64
65typedef struct VirtioBusState VirtioS390BusState;
66typedef struct VirtioBusClass VirtioS390BusClass;
67
68#define TYPE_VIRTIO_S390_BUS "virtio-s390-bus"
69#define VIRTIO_S390_BUS(obj) \
70 OBJECT_CHECK(VirtioS390BusState, (obj), TYPE_VIRTIO_S390_BUS)
71#define VIRTIO_S390_BUS_GET_CLASS(obj) \
72 OBJECT_GET_CLASS(VirtioS390BusClass, obj, TYPE_VIRTIO_S390_BUS)
73#define VIRTIO_S390_BUS_CLASS(klass) \
74 OBJECT_CLASS_CHECK(VirtioS390BusClass, klass, TYPE_VIRTIO_S390_BUS)
75
76
Anthony Liguori39bffca2011-12-07 21:34:16 -060077typedef struct VirtIOS390Device VirtIOS390Device;
78
KONRAD Fredericea35d4f2013-01-15 00:08:05 +010079void virtio_s390_bus_new(VirtioBusState *bus, VirtIOS390Device *dev);
80
Anthony Liguori39bffca2011-12-07 21:34:16 -060081typedef struct VirtIOS390DeviceClass {
82 DeviceClass qdev;
83 int (*init)(VirtIOS390Device *dev);
84} VirtIOS390DeviceClass;
85
86struct VirtIOS390Device {
Alexander Graff3304ee2009-12-05 12:44:27 +010087 DeviceState qdev;
88 ram_addr_t dev_offs;
89 ram_addr_t feat_offs;
90 uint8_t feat_len;
91 VirtIODevice *vdev;
Alexander Graff3304ee2009-12-05 12:44:27 +010092 NICConf nic;
Michael S. Tsirkin81725392010-01-10 13:52:53 +020093 uint32_t host_features;
Alex Williamsonf0c07c72010-09-02 09:00:50 -060094 virtio_net_conf net;
Amit Shah16c915b2012-06-20 12:29:32 +053095 VirtIORNGConf rng;
KONRAD Frederic11e92352013-01-15 00:08:06 +010096 VirtioBusState bus;
Anthony Liguori39bffca2011-12-07 21:34:16 -060097};
Alexander Graff3304ee2009-12-05 12:44:27 +010098
99typedef struct VirtIOS390Bus {
100 BusState bus;
101
102 VirtIOS390Device *console;
103 ram_addr_t dev_page;
104 ram_addr_t dev_offs;
105 ram_addr_t next_ring;
106} VirtIOS390Bus;
107
108
Blue Swirl64b85a82011-01-23 16:21:20 +0000109void s390_virtio_device_update_status(VirtIOS390Device *dev);
Alexander Graff3304ee2009-12-05 12:44:27 +0100110
Blue Swirl64b85a82011-01-23 16:21:20 +0000111VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus);
112VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size);
Alexander Graff3304ee2009-12-05 12:44:27 +0100113
Blue Swirl64b85a82011-01-23 16:21:20 +0000114VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus,
115 ram_addr_t mem, int *vq_num);
116VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem);
117void s390_virtio_device_sync(VirtIOS390Device *dev);
Jens Freimann4170aea2012-04-26 09:03:36 +0000118void s390_virtio_reset_idx(VirtIOS390Device *dev);
119
KONRAD Frederic55d11e02013-03-18 17:37:24 +0100120/* virtio-blk-s390 */
121
122#define TYPE_VIRTIO_BLK_S390 "virtio-blk-s390"
123#define VIRTIO_BLK_S390(obj) \
124 OBJECT_CHECK(VirtIOBlkS390, (obj), TYPE_VIRTIO_BLK_S390)
125
126typedef struct VirtIOBlkS390 {
127 VirtIOS390Device parent_obj;
128 VirtIOBlock vdev;
129 VirtIOBlkConf blk;
130} VirtIOBlkS390;
131
KONRAD Frederic9ef13d82013-03-21 15:15:16 +0100132/* virtio-scsi-s390 */
133
134#define TYPE_VIRTIO_SCSI_S390 "virtio-scsi-s390"
135#define VIRTIO_SCSI_S390(obj) \
136 OBJECT_CHECK(VirtIOSCSIS390, (obj), TYPE_VIRTIO_SCSI_S390)
137
138typedef struct VirtIOSCSIS390 {
139 VirtIOS390Device parent_obj;
140 VirtIOSCSI vdev;
141} VirtIOSCSIS390;
Paolo Bonzinicb9c3772012-12-06 12:15:58 +0100142
KONRAD Frederic55169142013-04-09 14:53:32 +0200143/* virtio-serial-s390 */
144
145#define TYPE_VIRTIO_SERIAL_S390 "virtio-serial-s390"
146#define VIRTIO_SERIAL_S390(obj) \
147 OBJECT_CHECK(VirtIOSerialS390, (obj), TYPE_VIRTIO_SERIAL_S390)
148
149typedef struct VirtIOSerialS390 {
150 VirtIOS390Device parent_obj;
151 VirtIOSerial vdev;
152} VirtIOSerialS390;
153
Paolo Bonzinicb9c3772012-12-06 12:15:58 +0100154#endif