mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
pc-bios/s390-ccw: qemuize types
Turn [the most of] existing declarations from struct type_name { ... }; into struct TypeName { ... }; typedef struct TypeName TypeName; and make use of them. Also switch u{8,16,32,64} to uint{8,16,32,64}_t. Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
This commit is contained in:
parent
dc25e843f6
commit
b88d7fa590
4 changed files with 115 additions and 94 deletions
|
@ -23,48 +23,54 @@
|
|||
/* We've given up on this device. */
|
||||
#define VIRTIO_CONFIG_S_FAILED 0x80
|
||||
|
||||
enum virtio_dev_type {
|
||||
enum VirtioDevType {
|
||||
VIRTIO_ID_NET = 1,
|
||||
VIRTIO_ID_BLOCK = 2,
|
||||
VIRTIO_ID_CONSOLE = 3,
|
||||
VIRTIO_ID_BALLOON = 5,
|
||||
};
|
||||
typedef enum VirtioDevType VirtioDevType;
|
||||
|
||||
struct virtio_dev_header {
|
||||
enum virtio_dev_type type : 8;
|
||||
u8 num_vq;
|
||||
u8 feature_len;
|
||||
u8 config_len;
|
||||
u8 status;
|
||||
u8 vqconfig[];
|
||||
struct VirtioDevHeader {
|
||||
VirtioDevType type:8;
|
||||
uint8_t num_vq;
|
||||
uint8_t feature_len;
|
||||
uint8_t config_len;
|
||||
uint8_t status;
|
||||
uint8_t vqconfig[];
|
||||
} __attribute__((packed));
|
||||
typedef struct VirtioDevHeader VirtioDevHeader;
|
||||
|
||||
struct virtio_vqconfig {
|
||||
u64 token;
|
||||
u64 address;
|
||||
u16 num;
|
||||
u8 pad[6];
|
||||
struct VirtioVqConfig {
|
||||
uint64_t token;
|
||||
uint64_t address;
|
||||
uint16_t num;
|
||||
uint8_t pad[6];
|
||||
} __attribute__((packed));
|
||||
typedef struct VirtioVqConfig VirtioVqConfig;
|
||||
|
||||
struct vq_info_block {
|
||||
u64 queue;
|
||||
u32 align;
|
||||
u16 index;
|
||||
u16 num;
|
||||
struct VqInfo {
|
||||
uint64_t queue;
|
||||
uint32_t align;
|
||||
uint16_t index;
|
||||
uint16_t num;
|
||||
} __attribute__((packed));
|
||||
typedef struct VqInfo VqInfo;
|
||||
|
||||
struct vq_config_block {
|
||||
u16 index;
|
||||
u16 num;
|
||||
struct VqConfig {
|
||||
uint16_t index;
|
||||
uint16_t num;
|
||||
} __attribute__((packed));
|
||||
typedef struct VqConfig VqConfig;
|
||||
|
||||
struct virtio_dev {
|
||||
struct virtio_dev_header *header;
|
||||
struct virtio_vqconfig *vqconfig;
|
||||
struct VirtioDev {
|
||||
VirtioDevHeader *header;
|
||||
VirtioVqConfig *vqconfig;
|
||||
char *host_features;
|
||||
char *guest_features;
|
||||
char *config;
|
||||
};
|
||||
typedef struct VirtioDev VirtioDev;
|
||||
|
||||
#define KVM_S390_VIRTIO_RING_ALIGN 4096
|
||||
|
||||
|
@ -81,46 +87,51 @@ struct virtio_dev {
|
|||
#define VRING_HIDDEN_IS_CHAIN 256
|
||||
|
||||
/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
|
||||
struct vring_desc {
|
||||
struct VRingDesc {
|
||||
/* Address (guest-physical). */
|
||||
u64 addr;
|
||||
uint64_t addr;
|
||||
/* Length. */
|
||||
u32 len;
|
||||
uint32_t len;
|
||||
/* The flags as indicated above. */
|
||||
u16 flags;
|
||||
uint16_t flags;
|
||||
/* We chain unused descriptors via this, too */
|
||||
u16 next;
|
||||
uint16_t next;
|
||||
} __attribute__((packed));
|
||||
typedef struct VRingDesc VRingDesc;
|
||||
|
||||
struct vring_avail {
|
||||
u16 flags;
|
||||
u16 idx;
|
||||
u16 ring[];
|
||||
struct VRingAvail {
|
||||
uint16_t flags;
|
||||
uint16_t idx;
|
||||
uint16_t ring[];
|
||||
} __attribute__((packed));
|
||||
typedef struct VRingAvail VRingAvail;
|
||||
|
||||
/* u32 is used here for ids for padding reasons. */
|
||||
struct vring_used_elem {
|
||||
/* uint32_t is used here for ids for padding reasons. */
|
||||
struct VRingUsedElem {
|
||||
/* Index of start of used descriptor chain. */
|
||||
u32 id;
|
||||
uint32_t id;
|
||||
/* Total length of the descriptor chain which was used (written to) */
|
||||
u32 len;
|
||||
uint32_t len;
|
||||
} __attribute__((packed));
|
||||
typedef struct VRingUsedElem VRingUsedElem;
|
||||
|
||||
struct vring_used {
|
||||
u16 flags;
|
||||
u16 idx;
|
||||
struct vring_used_elem ring[];
|
||||
struct VRingUsed {
|
||||
uint16_t flags;
|
||||
uint16_t idx;
|
||||
VRingUsedElem ring[];
|
||||
} __attribute__((packed));
|
||||
typedef struct VRingUsed VRingUsed;
|
||||
|
||||
struct vring {
|
||||
struct VRing {
|
||||
unsigned int num;
|
||||
int next_idx;
|
||||
int used_idx;
|
||||
struct vring_desc *desc;
|
||||
struct vring_avail *avail;
|
||||
struct vring_used *used;
|
||||
struct subchannel_id schid;
|
||||
VRingDesc *desc;
|
||||
VRingAvail *avail;
|
||||
VRingUsed *used;
|
||||
SubChannelId schid;
|
||||
};
|
||||
typedef struct VRing VRing;
|
||||
|
||||
|
||||
/***********************************************
|
||||
|
@ -152,37 +163,39 @@ struct vring {
|
|||
#define VIRTIO_BLK_T_BARRIER 0x80000000
|
||||
|
||||
/* This is the first element of the read scatter-gather list. */
|
||||
struct virtio_blk_outhdr {
|
||||
struct VirtioBlkOuthdr {
|
||||
/* VIRTIO_BLK_T* */
|
||||
u32 type;
|
||||
uint32_t type;
|
||||
/* io priority. */
|
||||
u32 ioprio;
|
||||
uint32_t ioprio;
|
||||
/* Sector (ie. 512 byte offset) */
|
||||
u64 sector;
|
||||
uint64_t sector;
|
||||
};
|
||||
typedef struct VirtioBlkOuthdr VirtioBlkOuthdr;
|
||||
|
||||
typedef struct VirtioBlkConfig {
|
||||
u64 capacity; /* in 512-byte sectors */
|
||||
u32 size_max; /* max segment size (if VIRTIO_BLK_F_SIZE_MAX) */
|
||||
u32 seg_max; /* max number of segments (if VIRTIO_BLK_F_SEG_MAX) */
|
||||
struct VirtioBlkConfig {
|
||||
uint64_t capacity; /* in 512-byte sectors */
|
||||
uint32_t size_max; /* max segment size (if VIRTIO_BLK_F_SIZE_MAX) */
|
||||
uint32_t seg_max; /* max number of segments (if VIRTIO_BLK_F_SEG_MAX) */
|
||||
|
||||
struct virtio_blk_geometry {
|
||||
u16 cylinders;
|
||||
u8 heads;
|
||||
u8 sectors;
|
||||
struct VirtioBlkGeometry {
|
||||
uint16_t cylinders;
|
||||
uint8_t heads;
|
||||
uint8_t sectors;
|
||||
} geometry; /* (if VIRTIO_BLK_F_GEOMETRY) */
|
||||
|
||||
u32 blk_size; /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
|
||||
uint32_t blk_size; /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
|
||||
|
||||
/* the next 4 entries are guarded by VIRTIO_BLK_F_TOPOLOGY */
|
||||
u8 physical_block_exp; /* exponent for physical block per logical block */
|
||||
u8 alignment_offset; /* alignment offset in logical blocks */
|
||||
u16 min_io_size; /* min I/O size without performance penalty
|
||||
uint8_t physical_block_exp; /* exponent for physical blk per logical blk */
|
||||
uint8_t alignment_offset; /* alignment offset in logical blocks */
|
||||
uint16_t min_io_size; /* min I/O size without performance penalty
|
||||
in logical blocks */
|
||||
u32 opt_io_size; /* optimal sustained I/O size in logical blocks */
|
||||
uint32_t opt_io_size; /* optimal sustained I/O size in logical blks */
|
||||
|
||||
u8 wce; /* writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */
|
||||
} __attribute__((packed)) VirtioBlkConfig;
|
||||
uint8_t wce; /* writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */
|
||||
} __attribute__((packed));
|
||||
typedef struct VirtioBlkConfig VirtioBlkConfig;
|
||||
|
||||
bool virtio_guessed_disk_nature(void);
|
||||
void virtio_assume_scsi(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue