bswap: Fix build on FreeBSD 10.0
[qemu.git] / hw / s390x / css.h
blobe9b440540d735977b9d3d3df8bd085ef7de02500
1 /*
2 * Channel subsystem structures and definitions.
4 * Copyright 2012 IBM Corp.
5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
7 * This work is licensed under the terms of the GNU GPL, version 2 or (at
8 * your option) any later version. See the COPYING file in the top-level
9 * directory.
12 #ifndef CSS_H
13 #define CSS_H
15 #include "ioinst.h"
17 /* Channel subsystem constants. */
18 #define MAX_SCHID 65535
19 #define MAX_SSID 3
20 #define MAX_CSSID 254 /* 255 is reserved */
21 #define MAX_CHPID 255
23 #define MAX_CIWS 62
25 typedef struct CIW {
26 uint8_t type;
27 uint8_t command;
28 uint16_t count;
29 } QEMU_PACKED CIW;
31 typedef struct SenseId {
32 /* common part */
33 uint8_t reserved; /* always 0x'FF' */
34 uint16_t cu_type; /* control unit type */
35 uint8_t cu_model; /* control unit model */
36 uint16_t dev_type; /* device type */
37 uint8_t dev_model; /* device model */
38 uint8_t unused; /* padding byte */
39 /* extended part */
40 CIW ciw[MAX_CIWS]; /* variable # of CIWs */
41 } QEMU_PACKED SenseId;
43 /* Channel measurements, from linux/drivers/s390/cio/cmf.c. */
44 typedef struct CMB {
45 uint16_t ssch_rsch_count;
46 uint16_t sample_count;
47 uint32_t device_connect_time;
48 uint32_t function_pending_time;
49 uint32_t device_disconnect_time;
50 uint32_t control_unit_queuing_time;
51 uint32_t device_active_only_time;
52 uint32_t reserved[2];
53 } QEMU_PACKED CMB;
55 typedef struct CMBE {
56 uint32_t ssch_rsch_count;
57 uint32_t sample_count;
58 uint32_t device_connect_time;
59 uint32_t function_pending_time;
60 uint32_t device_disconnect_time;
61 uint32_t control_unit_queuing_time;
62 uint32_t device_active_only_time;
63 uint32_t device_busy_time;
64 uint32_t initial_command_response_time;
65 uint32_t reserved[7];
66 } QEMU_PACKED CMBE;
68 struct SubchDev {
69 /* channel-subsystem related things: */
70 uint8_t cssid;
71 uint8_t ssid;
72 uint16_t schid;
73 uint16_t devno;
74 SCHIB curr_status;
75 uint8_t sense_data[32];
76 hwaddr channel_prog;
77 CCW1 last_cmd;
78 bool last_cmd_valid;
79 ORB *orb;
80 bool thinint_active;
81 /* transport-provided data: */
82 int (*ccw_cb) (SubchDev *, CCW1);
83 SenseId id;
84 void *driver_data;
87 typedef SubchDev *(*css_subch_cb_func)(uint8_t m, uint8_t cssid, uint8_t ssid,
88 uint16_t schid);
89 int css_create_css_image(uint8_t cssid, bool default_image);
90 bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno);
91 void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
92 uint16_t devno, SubchDev *sch);
93 void css_sch_build_virtual_schib(SubchDev *sch, uint8_t chpid, uint8_t type);
94 uint16_t css_build_subchannel_id(SubchDev *sch);
95 void css_reset(void);
96 void css_reset_sch(SubchDev *sch);
97 void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid);
98 void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
99 int hotplugged, int add);
100 void css_generate_chp_crws(uint8_t cssid, uint8_t chpid);
101 void css_adapter_interrupt(uint8_t isc);
102 #endif