]>
Commit | Line | Data |
---|---|---|
f3304eea AG |
1 | /* |
2 | * QEMU S390x VirtIO BUS definitions | |
3 | * | |
4 | * Copyright (c) 2009 Alexander Graf <[email protected]> | |
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 | */ | |
cb9c377f PB |
19 | #ifndef HW_S390_VIRTIO_BUS_H |
20 | #define HW_S390_VIRTIO_BUS_H 1 | |
f3304eea | 21 | |
b73d3531 AG |
22 | #include "hw/virtio-blk.h" |
23 | #include "hw/virtio-net.h" | |
24 | #include "hw/virtio-rng.h" | |
25 | #include "hw/virtio-serial.h" | |
26 | #include "hw/virtio-scsi.h" | |
27 | #include "hw/virtio-bus.h" | |
6c33286a | 28 | |
f3304eea AG |
29 | #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) | |
4170aea1 JF |
42 | #define VIRTIO_VRING_AVAIL_IDX_OFFS 2 |
43 | #define VIRTIO_VRING_USED_IDX_OFFS 2 | |
d1ff903c | 44 | #define S390_DEVICE_PAGES 512 |
f3304eea | 45 | |
7fa41e53 AG |
46 | #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 | ||
39bffca2 AL |
51 | #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 | ||
0d936928 AL |
59 | #define TYPE_S390_VIRTIO_BUS "s390-virtio-bus" |
60 | #define S390_VIRTIO_BUS(obj) \ | |
61 | OBJECT_CHECK(VirtIOS390Bus, (obj), TYPE_S390_VIRTIO_BUS) | |
62 | ||
ea35d4f1 FK |
63 | /* virtio-s390-bus */ |
64 | ||
65 | typedef struct VirtioBusState VirtioS390BusState; | |
66 | typedef 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 | ||
39bffca2 AL |
77 | typedef struct VirtIOS390Device VirtIOS390Device; |
78 | ||
ea35d4f1 FK |
79 | void virtio_s390_bus_new(VirtioBusState *bus, VirtIOS390Device *dev); |
80 | ||
39bffca2 AL |
81 | typedef struct VirtIOS390DeviceClass { |
82 | DeviceClass qdev; | |
83 | int (*init)(VirtIOS390Device *dev); | |
84 | } VirtIOS390DeviceClass; | |
85 | ||
86 | struct VirtIOS390Device { | |
f3304eea AG |
87 | DeviceState qdev; |
88 | ram_addr_t dev_offs; | |
89 | ram_addr_t feat_offs; | |
90 | uint8_t feat_len; | |
91 | VirtIODevice *vdev; | |
12c5674b | 92 | VirtIOBlkConf blk; |
f3304eea | 93 | NICConf nic; |
8172539d | 94 | uint32_t host_features; |
6be9b414 | 95 | virtio_serial_conf serial; |
f0c07c7c | 96 | virtio_net_conf net; |
973abc7f | 97 | VirtIOSCSIConf scsi; |
16c915ba | 98 | VirtIORNGConf rng; |
11e9235b | 99 | VirtioBusState bus; |
39bffca2 | 100 | }; |
f3304eea AG |
101 | |
102 | typedef struct VirtIOS390Bus { | |
103 | BusState bus; | |
104 | ||
105 | VirtIOS390Device *console; | |
106 | ram_addr_t dev_page; | |
107 | ram_addr_t dev_offs; | |
108 | ram_addr_t next_ring; | |
109 | } VirtIOS390Bus; | |
110 | ||
111 | ||
64b85a8f | 112 | void s390_virtio_device_update_status(VirtIOS390Device *dev); |
f3304eea | 113 | |
64b85a8f BS |
114 | VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus); |
115 | VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size); | |
f3304eea | 116 | |
64b85a8f BS |
117 | VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus, |
118 | ram_addr_t mem, int *vq_num); | |
119 | VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem); | |
120 | void s390_virtio_device_sync(VirtIOS390Device *dev); | |
4170aea1 JF |
121 | void s390_virtio_reset_idx(VirtIOS390Device *dev); |
122 | ||
cb9c377f PB |
123 | |
124 | #endif |