Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 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 | */ |
Paolo Bonzini | cb9c377 | 2012-12-06 12:15:58 +0100 | [diff] [blame] | 19 | #ifndef HW_S390_VIRTIO_BUS_H |
| 20 | #define HW_S390_VIRTIO_BUS_H 1 |
Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 21 | |
Paolo Bonzini | 12c5674 | 2012-05-16 12:54:05 +0200 | [diff] [blame] | 22 | #include "virtio-blk.h" |
Alexander Graf | 6c33286 | 2010-11-17 13:01:04 +0100 | [diff] [blame] | 23 | #include "virtio-net.h" |
Amit Shah | 16c915b | 2012-06-20 12:29:32 +0530 | [diff] [blame] | 24 | #include "virtio-rng.h" |
Alexander Graf | 6be9b41 | 2011-03-29 15:29:31 +0200 | [diff] [blame] | 25 | #include "virtio-serial.h" |
Stefan Hajnoczi | 973abc7 | 2011-02-11 08:40:59 +0000 | [diff] [blame] | 26 | #include "virtio-scsi.h" |
Alexander Graf | 6c33286 | 2010-11-17 13:01:04 +0100 | [diff] [blame] | 27 | |
Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 28 | #define VIRTIO_DEV_OFFS_TYPE 0 /* 8 bits */ |
| 29 | #define VIRTIO_DEV_OFFS_NUM_VQ 1 /* 8 bits */ |
| 30 | #define VIRTIO_DEV_OFFS_FEATURE_LEN 2 /* 8 bits */ |
| 31 | #define VIRTIO_DEV_OFFS_CONFIG_LEN 3 /* 8 bits */ |
| 32 | #define VIRTIO_DEV_OFFS_STATUS 4 /* 8 bits */ |
| 33 | #define VIRTIO_DEV_OFFS_CONFIG 5 /* dynamic */ |
| 34 | |
| 35 | #define VIRTIO_VQCONFIG_OFFS_TOKEN 0 /* 64 bits */ |
| 36 | #define VIRTIO_VQCONFIG_OFFS_ADDRESS 8 /* 64 bits */ |
| 37 | #define VIRTIO_VQCONFIG_OFFS_NUM 16 /* 16 bits */ |
| 38 | #define VIRTIO_VQCONFIG_LEN 24 |
| 39 | |
| 40 | #define VIRTIO_RING_LEN (TARGET_PAGE_SIZE * 3) |
Jens Freimann | 4170aea | 2012-04-26 09:03:36 +0000 | [diff] [blame] | 41 | #define VIRTIO_VRING_AVAIL_IDX_OFFS 2 |
| 42 | #define VIRTIO_VRING_USED_IDX_OFFS 2 |
Alexander Graf | d1ff903 | 2011-04-13 10:55:11 +0200 | [diff] [blame] | 43 | #define S390_DEVICE_PAGES 512 |
Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 44 | |
Alexander Graf | 7fa41e5 | 2010-08-23 18:58:34 +0200 | [diff] [blame] | 45 | #define VIRTIO_PARAM_MASK 0xff |
| 46 | #define VIRTIO_PARAM_VRING_INTERRUPT 0x0 |
| 47 | #define VIRTIO_PARAM_CONFIG_CHANGED 0x1 |
| 48 | #define VIRTIO_PARAM_DEV_ADD 0x2 |
| 49 | |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 50 | #define TYPE_VIRTIO_S390_DEVICE "virtio-s390-device" |
| 51 | #define VIRTIO_S390_DEVICE(obj) \ |
| 52 | OBJECT_CHECK(VirtIOS390Device, (obj), TYPE_VIRTIO_S390_DEVICE) |
| 53 | #define VIRTIO_S390_DEVICE_CLASS(klass) \ |
| 54 | OBJECT_CLASS_CHECK(VirtIOS390DeviceClass, (klass), TYPE_VIRTIO_S390_DEVICE) |
| 55 | #define VIRTIO_S390_DEVICE_GET_CLASS(obj) \ |
| 56 | OBJECT_GET_CLASS(VirtIOS390DeviceClass, (obj), TYPE_VIRTIO_S390_DEVICE) |
| 57 | |
Anthony Liguori | 0d93692 | 2012-05-02 09:00:20 +0200 | [diff] [blame] | 58 | #define TYPE_S390_VIRTIO_BUS "s390-virtio-bus" |
| 59 | #define S390_VIRTIO_BUS(obj) \ |
| 60 | OBJECT_CHECK(VirtIOS390Bus, (obj), TYPE_S390_VIRTIO_BUS) |
| 61 | |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 62 | typedef struct VirtIOS390Device VirtIOS390Device; |
| 63 | |
| 64 | typedef struct VirtIOS390DeviceClass { |
| 65 | DeviceClass qdev; |
| 66 | int (*init)(VirtIOS390Device *dev); |
| 67 | } VirtIOS390DeviceClass; |
| 68 | |
| 69 | struct VirtIOS390Device { |
Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 70 | DeviceState qdev; |
| 71 | ram_addr_t dev_offs; |
| 72 | ram_addr_t feat_offs; |
| 73 | uint8_t feat_len; |
| 74 | VirtIODevice *vdev; |
Paolo Bonzini | 12c5674 | 2012-05-16 12:54:05 +0200 | [diff] [blame] | 75 | VirtIOBlkConf blk; |
Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 76 | NICConf nic; |
Michael S. Tsirkin | 8172539 | 2010-01-10 13:52:53 +0200 | [diff] [blame] | 77 | uint32_t host_features; |
Alexander Graf | 6be9b41 | 2011-03-29 15:29:31 +0200 | [diff] [blame] | 78 | virtio_serial_conf serial; |
Alex Williamson | f0c07c7 | 2010-09-02 09:00:50 -0600 | [diff] [blame] | 79 | virtio_net_conf net; |
Stefan Hajnoczi | 973abc7 | 2011-02-11 08:40:59 +0000 | [diff] [blame] | 80 | VirtIOSCSIConf scsi; |
Amit Shah | 16c915b | 2012-06-20 12:29:32 +0530 | [diff] [blame] | 81 | VirtIORNGConf rng; |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 82 | }; |
Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 83 | |
| 84 | typedef struct VirtIOS390Bus { |
| 85 | BusState bus; |
| 86 | |
| 87 | VirtIOS390Device *console; |
| 88 | ram_addr_t dev_page; |
| 89 | ram_addr_t dev_offs; |
| 90 | ram_addr_t next_ring; |
| 91 | } VirtIOS390Bus; |
| 92 | |
| 93 | |
Blue Swirl | 64b85a8 | 2011-01-23 16:21:20 +0000 | [diff] [blame] | 94 | void s390_virtio_device_update_status(VirtIOS390Device *dev); |
Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 95 | |
Blue Swirl | 64b85a8 | 2011-01-23 16:21:20 +0000 | [diff] [blame] | 96 | VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus); |
| 97 | VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size); |
Alexander Graf | f3304ee | 2009-12-05 12:44:27 +0100 | [diff] [blame] | 98 | |
Blue Swirl | 64b85a8 | 2011-01-23 16:21:20 +0000 | [diff] [blame] | 99 | VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus, |
| 100 | ram_addr_t mem, int *vq_num); |
| 101 | VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem); |
| 102 | void s390_virtio_device_sync(VirtIOS390Device *dev); |
Jens Freimann | 4170aea | 2012-04-26 09:03:36 +0000 | [diff] [blame] | 103 | void s390_virtio_reset_idx(VirtIOS390Device *dev); |
| 104 | |
Paolo Bonzini | cb9c377 | 2012-12-06 12:15:58 +0100 | [diff] [blame] | 105 | |
| 106 | #endif |