1
2
3
4
5
6
7
8
9
10
11
12#ifndef CSS_H
13#define CSS_H
14
15#include "hw/s390x/adapter.h"
16#include "hw/s390x/s390_flic.h"
17#include "ioinst.h"
18
19
20#define MAX_SCHID 65535
21#define MAX_SSID 3
22#define MAX_CSSID 254
23#define MAX_CHPID 255
24
25#define MAX_CIWS 62
26
27typedef struct CIW {
28 uint8_t type;
29 uint8_t command;
30 uint16_t count;
31} QEMU_PACKED CIW;
32
33typedef struct SenseId {
34
35 uint8_t reserved;
36 uint16_t cu_type;
37 uint8_t cu_model;
38 uint16_t dev_type;
39 uint8_t dev_model;
40 uint8_t unused;
41
42 CIW ciw[MAX_CIWS];
43} QEMU_PACKED SenseId;
44
45
46typedef struct CMB {
47 uint16_t ssch_rsch_count;
48 uint16_t sample_count;
49 uint32_t device_connect_time;
50 uint32_t function_pending_time;
51 uint32_t device_disconnect_time;
52 uint32_t control_unit_queuing_time;
53 uint32_t device_active_only_time;
54 uint32_t reserved[2];
55} QEMU_PACKED CMB;
56
57typedef struct CMBE {
58 uint32_t ssch_rsch_count;
59 uint32_t sample_count;
60 uint32_t device_connect_time;
61 uint32_t function_pending_time;
62 uint32_t device_disconnect_time;
63 uint32_t control_unit_queuing_time;
64 uint32_t device_active_only_time;
65 uint32_t device_busy_time;
66 uint32_t initial_command_response_time;
67 uint32_t reserved[7];
68} QEMU_PACKED CMBE;
69
70struct SubchDev {
71
72 uint8_t cssid;
73 uint8_t ssid;
74 uint16_t schid;
75 uint16_t devno;
76 SCHIB curr_status;
77 uint8_t sense_data[32];
78 hwaddr channel_prog;
79 CCW1 last_cmd;
80 bool last_cmd_valid;
81 bool ccw_fmt_1;
82 bool thinint_active;
83 uint8_t ccw_no_data_cnt;
84
85 int (*ccw_cb) (SubchDev *, CCW1);
86 void (*disable_cb)(SubchDev *);
87 SenseId id;
88 void *driver_data;
89};
90
91typedef struct IndAddr {
92 hwaddr addr;
93 uint64_t map;
94 unsigned long refcnt;
95 int len;
96 QTAILQ_ENTRY(IndAddr) sibling;
97} IndAddr;
98
99IndAddr *get_indicator(hwaddr ind_addr, int len);
100void release_indicator(AdapterInfo *adapter, IndAddr *indicator);
101int map_indicator(AdapterInfo *adapter, IndAddr *indicator);
102
103typedef SubchDev *(*css_subch_cb_func)(uint8_t m, uint8_t cssid, uint8_t ssid,
104 uint16_t schid);
105void subch_device_save(SubchDev *s, QEMUFile *f);
106int subch_device_load(SubchDev *s, QEMUFile *f);
107int css_create_css_image(uint8_t cssid, bool default_image);
108bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno);
109void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
110 uint16_t devno, SubchDev *sch);
111void css_sch_build_virtual_schib(SubchDev *sch, uint8_t chpid, uint8_t type);
112uint16_t css_build_subchannel_id(SubchDev *sch);
113void css_reset(void);
114void css_reset_sch(SubchDev *sch);
115void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid);
116void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
117 int hotplugged, int add);
118void css_generate_chp_crws(uint8_t cssid, uint8_t chpid);
119void css_generate_css_crws(uint8_t cssid);
120void css_clear_sei_pending(void);
121void css_adapter_interrupt(uint8_t isc);
122
123#define CSS_IO_ADAPTER_VIRTIO 1
124int css_register_io_adapter(uint8_t type, uint8_t isc, bool swap,
125 bool maskable, uint32_t *id);
126#endif
127