xref: /kvm-unit-tests/lib/s390x/css.h (revision 9cab58249f98adc451933530fd7e618e1856eb94)
16c9f99dfSJanosch Frank /* SPDX-License-Identifier: GPL-2.0-only */
2a3b101f0SPierre Morel /*
3a3b101f0SPierre Morel  * CSS definitions
4a3b101f0SPierre Morel  *
5a2b44f22SJanosch Frank  * Copyright IBM Corp. 2020
6a3b101f0SPierre Morel  * Author: Pierre Morel <pmorel@linux.ibm.com>
7a3b101f0SPierre Morel  */
8a3b101f0SPierre Morel 
9eb5a1bbaSCornelia Huck #ifndef _S390X_CSS_H_
10eb5a1bbaSCornelia Huck #define _S390X_CSS_H_
11a3b101f0SPierre Morel 
12a3b101f0SPierre Morel /* subchannel ID bit 16 must always be one */
13a3b101f0SPierre Morel #define SCHID_ONE	0x00010000
14a3b101f0SPierre Morel 
15a3b101f0SPierre Morel #define CCW_F_CD	0x80
16a3b101f0SPierre Morel #define CCW_F_CC	0x40
17a3b101f0SPierre Morel #define CCW_F_SLI	0x20
18a3b101f0SPierre Morel #define CCW_F_SKP	0x10
19a3b101f0SPierre Morel #define CCW_F_PCI	0x08
20a3b101f0SPierre Morel #define CCW_F_IDA	0x04
21a3b101f0SPierre Morel #define CCW_F_S		0x02
22a3b101f0SPierre Morel #define CCW_F_MIDA	0x01
23a3b101f0SPierre Morel 
24a3b101f0SPierre Morel #define CCW_C_NOP	0x03
25a3b101f0SPierre Morel #define CCW_C_TIC	0x08
26a3b101f0SPierre Morel 
27a3b101f0SPierre Morel struct ccw1 {
28a3b101f0SPierre Morel 	uint8_t code;
29a3b101f0SPierre Morel 	uint8_t flags;
30a3b101f0SPierre Morel 	uint16_t count;
31a3b101f0SPierre Morel 	uint32_t data_address;
32a3b101f0SPierre Morel } __attribute__ ((aligned(8)));
33a3b101f0SPierre Morel 
34a3b101f0SPierre Morel #define ORB_CTRL_KEY	0xf0000000
35a3b101f0SPierre Morel #define ORB_CTRL_SPND	0x08000000
36a3b101f0SPierre Morel #define ORB_CTRL_STR	0x04000000
37a3b101f0SPierre Morel #define ORB_CTRL_MOD	0x02000000
38a3b101f0SPierre Morel #define ORB_CTRL_SYNC	0x01000000
39a3b101f0SPierre Morel #define ORB_CTRL_FMT	0x00800000
40a3b101f0SPierre Morel #define ORB_CTRL_PFCH	0x00400000
41a3b101f0SPierre Morel #define ORB_CTRL_ISIC	0x00200000
42a3b101f0SPierre Morel #define ORB_CTRL_ALCC	0x00100000
43a3b101f0SPierre Morel #define ORB_CTRL_SSIC	0x00080000
44a3b101f0SPierre Morel #define ORB_CTRL_CPTC	0x00040000
45a3b101f0SPierre Morel #define ORB_CTRL_C64	0x00020000
46a3b101f0SPierre Morel #define ORB_CTRL_I2K	0x00010000
47a3b101f0SPierre Morel #define ORB_CTRL_LPM	0x0000ff00
48a3b101f0SPierre Morel #define ORB_CTRL_ILS	0x00000080
49a3b101f0SPierre Morel #define ORB_CTRL_MIDAW	0x00000040
50a3b101f0SPierre Morel #define ORB_CTRL_ORBX	0x00000001
51a3b101f0SPierre Morel 
52a3b101f0SPierre Morel #define ORB_LPM_DFLT	0x00008000
53a3b101f0SPierre Morel 
54a3b101f0SPierre Morel struct orb {
55a3b101f0SPierre Morel 	uint32_t intparm;
56a3b101f0SPierre Morel 	uint32_t ctrl;
57a3b101f0SPierre Morel 	uint32_t cpa;
58a3b101f0SPierre Morel 	uint32_t prio;
59a3b101f0SPierre Morel 	uint32_t reserved[4];
60a3b101f0SPierre Morel } __attribute__ ((aligned(4)));
61a3b101f0SPierre Morel 
62a3b101f0SPierre Morel struct scsw {
638cb729e4SPierre Morel #define SCSW_SC_PENDING		0x00000001
648cb729e4SPierre Morel #define SCSW_SC_SECONDARY	0x00000002
658cb729e4SPierre Morel #define SCSW_SC_PRIMARY		0x00000004
668cb729e4SPierre Morel #define SCSW_SC_INTERMEDIATE	0x00000008
678cb729e4SPierre Morel #define SCSW_SC_ALERT		0x00000010
68a3b101f0SPierre Morel 	uint32_t ctrl;
69a3b101f0SPierre Morel 	uint32_t ccw_addr;
708cb729e4SPierre Morel #define SCSW_DEVS_DEV_END	0x04
718cb729e4SPierre Morel #define SCSW_DEVS_SCH_END	0x08
72a3b101f0SPierre Morel 	uint8_t  dev_stat;
738cb729e4SPierre Morel #define SCSW_SCHS_PCI	0x80
748cb729e4SPierre Morel #define SCSW_SCHS_IL	0x40
75a3b101f0SPierre Morel 	uint8_t  sch_stat;
76a3b101f0SPierre Morel 	uint16_t count;
77a3b101f0SPierre Morel };
78a3b101f0SPierre Morel 
79a3b101f0SPierre Morel struct pmcw {
80a3b101f0SPierre Morel 	uint32_t intparm;
81a3b101f0SPierre Morel #define PMCW_DNV	0x0001
82a3b101f0SPierre Morel #define PMCW_ENABLE	0x0080
833c4ae93fSPierre Morel #define PMCW_MBUE	0x0010
843c4ae93fSPierre Morel #define PMCW_DCTME	0x0008
85551e6622SPierre Morel #define PMCW_ISC_MASK	0x3800
86551e6622SPierre Morel #define PMCW_ISC_SHIFT	11
87a3b101f0SPierre Morel 	uint16_t flags;
88a3b101f0SPierre Morel 	uint16_t devnum;
89a3b101f0SPierre Morel 	uint8_t  lpm;
90a3b101f0SPierre Morel 	uint8_t  pnom;
91a3b101f0SPierre Morel 	uint8_t  lpum;
92a3b101f0SPierre Morel 	uint8_t  pim;
93a3b101f0SPierre Morel 	uint16_t mbi;
94a3b101f0SPierre Morel 	uint8_t  pom;
95a3b101f0SPierre Morel 	uint8_t  pam;
96a3b101f0SPierre Morel 	uint8_t  chpid[8];
973c4ae93fSPierre Morel #define PMCW_MBF1	0x0004
98a3b101f0SPierre Morel 	uint32_t flags2;
99a3b101f0SPierre Morel };
100a3b101f0SPierre Morel #define PMCW_CHANNEL_TYPE(pmcw) (pmcw->flags2 >> 21)
101a3b101f0SPierre Morel 
102a3b101f0SPierre Morel struct schib {
103a3b101f0SPierre Morel 	struct pmcw pmcw;
104a3b101f0SPierre Morel 	struct scsw scsw;
1053c4ae93fSPierre Morel 	uint64_t mbo;
1063c4ae93fSPierre Morel 	uint8_t  md[4];
107a3b101f0SPierre Morel } __attribute__ ((aligned(4)));
108fa68e2a8SPierre Morel extern struct schib schib;
109a3b101f0SPierre Morel 
110a3b101f0SPierre Morel struct irb {
111a3b101f0SPierre Morel 	struct scsw scsw;
112a3b101f0SPierre Morel 	uint32_t esw[5];
113a3b101f0SPierre Morel 	uint32_t ecw[8];
114a3b101f0SPierre Morel 	uint32_t emw[8];
115a3b101f0SPierre Morel } __attribute__ ((aligned(4)));
116a3b101f0SPierre Morel 
1178cb729e4SPierre Morel #define CCW_CMD_SENSE_ID	0xe4
1188cb729e4SPierre Morel #define CSS_SENSEID_COMMON_LEN	8
1198cb729e4SPierre Morel struct senseid {
1208cb729e4SPierre Morel 	/* common part */
1218cb729e4SPierre Morel 	uint8_t reserved;        /* always 0x'FF' */
1228cb729e4SPierre Morel 	uint16_t cu_type;        /* control unit type */
1238cb729e4SPierre Morel 	uint8_t cu_model;        /* control unit model */
1248cb729e4SPierre Morel 	uint16_t dev_type;       /* device type */
1258cb729e4SPierre Morel 	uint8_t dev_model;       /* device model */
1268cb729e4SPierre Morel 	uint8_t unused;          /* padding byte */
1278cb729e4SPierre Morel 	uint8_t padding[256 - 8]; /* Extended part */
1288cb729e4SPierre Morel } __attribute__ ((aligned(4))) __attribute__ ((packed));
1298cb729e4SPierre Morel 
130a3b101f0SPierre Morel /* CSS low level access functions */
131a3b101f0SPierre Morel 
ssch(unsigned long schid,struct orb * addr)132a3b101f0SPierre Morel static inline int ssch(unsigned long schid, struct orb *addr)
133a3b101f0SPierre Morel {
134a3b101f0SPierre Morel 	register long long reg1 asm("1") = schid;
135a3b101f0SPierre Morel 	int cc;
136a3b101f0SPierre Morel 
137a3b101f0SPierre Morel 	asm volatile(
138a3b101f0SPierre Morel 		"	ssch	0(%2)\n"
139a3b101f0SPierre Morel 		"	ipm	%0\n"
140a3b101f0SPierre Morel 		"	srl	%0,28\n"
141a3b101f0SPierre Morel 		: "=d" (cc)
142a3b101f0SPierre Morel 		: "d" (reg1), "a" (addr), "m" (*addr)
143a3b101f0SPierre Morel 		: "cc", "memory");
144a3b101f0SPierre Morel 	return cc;
145a3b101f0SPierre Morel }
146a3b101f0SPierre Morel 
stsch(unsigned long schid,struct schib * addr)147a3b101f0SPierre Morel static inline int stsch(unsigned long schid, struct schib *addr)
148a3b101f0SPierre Morel {
149a3b101f0SPierre Morel 	register unsigned long reg1 asm ("1") = schid;
150*9312c862SJanosch Frank 	uint64_t bogus_cc = 1;
151a3b101f0SPierre Morel 	int cc;
152a3b101f0SPierre Morel 
153a3b101f0SPierre Morel 	asm volatile(
154*9312c862SJanosch Frank 		"       tmll    %[bogus_cc],3\n"
155a3b101f0SPierre Morel 		"	stsch	0(%3)\n"
156a3b101f0SPierre Morel 		"	ipm	%0\n"
157a3b101f0SPierre Morel 		"	srl	%0,28"
158a3b101f0SPierre Morel 		: "=d" (cc), "=m" (*addr)
159*9312c862SJanosch Frank 		: "d" (reg1), "a" (addr), [bogus_cc] "d" (bogus_cc)
160a3b101f0SPierre Morel 		: "cc");
161a3b101f0SPierre Morel 	return cc;
162a3b101f0SPierre Morel }
163a3b101f0SPierre Morel 
msch(unsigned long schid,struct schib * addr)164a3b101f0SPierre Morel static inline int msch(unsigned long schid, struct schib *addr)
165a3b101f0SPierre Morel {
166a3b101f0SPierre Morel 	register unsigned long reg1 asm ("1") = schid;
167a3b101f0SPierre Morel 	int cc;
168a3b101f0SPierre Morel 
169a3b101f0SPierre Morel 	asm volatile(
170a3b101f0SPierre Morel 		"	msch	0(%3)\n"
171a3b101f0SPierre Morel 		"	ipm	%0\n"
172a3b101f0SPierre Morel 		"	srl	%0,28"
173a3b101f0SPierre Morel 		: "=d" (cc)
174a3b101f0SPierre Morel 		: "d" (reg1), "m" (*addr), "a" (addr)
175a3b101f0SPierre Morel 		: "cc");
176a3b101f0SPierre Morel 	return cc;
177a3b101f0SPierre Morel }
178a3b101f0SPierre Morel 
tsch(unsigned long schid,struct irb * addr)179a3b101f0SPierre Morel static inline int tsch(unsigned long schid, struct irb *addr)
180a3b101f0SPierre Morel {
181a3b101f0SPierre Morel 	register unsigned long reg1 asm ("1") = schid;
182*9312c862SJanosch Frank 	uint64_t bogus_cc = 2;
183a3b101f0SPierre Morel 	int cc;
184a3b101f0SPierre Morel 
185a3b101f0SPierre Morel 	asm volatile(
186*9312c862SJanosch Frank 		"       tmll    %[bogus_cc],3\n"
187a3b101f0SPierre Morel 		"	tsch	0(%3)\n"
188a3b101f0SPierre Morel 		"	ipm	%0\n"
189a3b101f0SPierre Morel 		"	srl	%0,28"
190a3b101f0SPierre Morel 		: "=d" (cc), "=m" (*addr)
191*9312c862SJanosch Frank 		: "d" (reg1), "a" (addr), [bogus_cc] "d" (bogus_cc)
192a3b101f0SPierre Morel 		: "cc");
193a3b101f0SPierre Morel 	return cc;
194a3b101f0SPierre Morel }
195a3b101f0SPierre Morel 
hsch(unsigned long schid)196a3b101f0SPierre Morel static inline int hsch(unsigned long schid)
197a3b101f0SPierre Morel {
198a3b101f0SPierre Morel 	register unsigned long reg1 asm("1") = schid;
199a3b101f0SPierre Morel 	int cc;
200a3b101f0SPierre Morel 
201a3b101f0SPierre Morel 	asm volatile(
202a3b101f0SPierre Morel 		"	hsch\n"
203a3b101f0SPierre Morel 		"	ipm	%0\n"
204a3b101f0SPierre Morel 		"	srl	%0,28"
205a3b101f0SPierre Morel 		: "=d" (cc)
206a3b101f0SPierre Morel 		: "d" (reg1)
207a3b101f0SPierre Morel 		: "cc");
208a3b101f0SPierre Morel 	return cc;
209a3b101f0SPierre Morel }
210a3b101f0SPierre Morel 
xsch(unsigned long schid)211a3b101f0SPierre Morel static inline int xsch(unsigned long schid)
212a3b101f0SPierre Morel {
213a3b101f0SPierre Morel 	register unsigned long reg1 asm("1") = schid;
214a3b101f0SPierre Morel 	int cc;
215a3b101f0SPierre Morel 
216a3b101f0SPierre Morel 	asm volatile(
217a3b101f0SPierre Morel 		"	xsch\n"
218a3b101f0SPierre Morel 		"	ipm	%0\n"
219a3b101f0SPierre Morel 		"	srl	%0,28"
220a3b101f0SPierre Morel 		: "=d" (cc)
221a3b101f0SPierre Morel 		: "d" (reg1)
222a3b101f0SPierre Morel 		: "cc");
223a3b101f0SPierre Morel 	return cc;
224a3b101f0SPierre Morel }
225a3b101f0SPierre Morel 
csch(unsigned long schid)226a3b101f0SPierre Morel static inline int csch(unsigned long schid)
227a3b101f0SPierre Morel {
228a3b101f0SPierre Morel 	register unsigned long reg1 asm("1") = schid;
229a3b101f0SPierre Morel 	int cc;
230a3b101f0SPierre Morel 
231a3b101f0SPierre Morel 	asm volatile(
232a3b101f0SPierre Morel 		"	csch\n"
233a3b101f0SPierre Morel 		"	ipm	%0\n"
234a3b101f0SPierre Morel 		"	srl	%0,28"
235a3b101f0SPierre Morel 		: "=d" (cc)
236a3b101f0SPierre Morel 		: "d" (reg1)
237a3b101f0SPierre Morel 		: "cc");
238a3b101f0SPierre Morel 	return cc;
239a3b101f0SPierre Morel }
240a3b101f0SPierre Morel 
rsch(unsigned long schid)241a3b101f0SPierre Morel static inline int rsch(unsigned long schid)
242a3b101f0SPierre Morel {
243a3b101f0SPierre Morel 	register unsigned long reg1 asm("1") = schid;
244a3b101f0SPierre Morel 	int cc;
245a3b101f0SPierre Morel 
246a3b101f0SPierre Morel 	asm volatile(
247a3b101f0SPierre Morel 		"	rsch\n"
248a3b101f0SPierre Morel 		"	ipm	%0\n"
249a3b101f0SPierre Morel 		"	srl	%0,28"
250a3b101f0SPierre Morel 		: "=d" (cc)
251a3b101f0SPierre Morel 		: "d" (reg1)
252a3b101f0SPierre Morel 		: "cc");
253a3b101f0SPierre Morel 	return cc;
254a3b101f0SPierre Morel }
255a3b101f0SPierre Morel 
rchp(unsigned long chpid)256a3b101f0SPierre Morel static inline int rchp(unsigned long chpid)
257a3b101f0SPierre Morel {
258a3b101f0SPierre Morel 	register unsigned long reg1 asm("1") = chpid;
259*9312c862SJanosch Frank 	uint64_t bogus_cc = 1;
260a3b101f0SPierre Morel 	int cc;
261a3b101f0SPierre Morel 
262a3b101f0SPierre Morel 	asm volatile(
263*9312c862SJanosch Frank 		"       tmll    %[bogus_cc],3\n"
264a3b101f0SPierre Morel 		"	rchp\n"
265a3b101f0SPierre Morel 		"	ipm	%0\n"
266a3b101f0SPierre Morel 		"	srl	%0,28"
267a3b101f0SPierre Morel 		: "=d" (cc)
268*9312c862SJanosch Frank 		: "d" (reg1), [bogus_cc] "d" (bogus_cc)
269a3b101f0SPierre Morel 		: "cc");
270a3b101f0SPierre Morel 	return cc;
271a3b101f0SPierre Morel }
272a3b101f0SPierre Morel 
stcrw(uint32_t * crw)2732b30c34dSNico Boehr static inline int stcrw(uint32_t *crw)
2742b30c34dSNico Boehr {
275*9312c862SJanosch Frank 	uint64_t bogus_cc = 1;
2762b30c34dSNico Boehr 	int cc;
2772b30c34dSNico Boehr 
2782b30c34dSNico Boehr 	asm volatile(
279*9312c862SJanosch Frank 		"       tmll    %[bogus_cc],3\n"
2802b30c34dSNico Boehr 		"	stcrw	%[crw]\n"
2812b30c34dSNico Boehr 		"	ipm	%[cc]\n"
2822b30c34dSNico Boehr 		"	srl	%[cc],28"
2832b30c34dSNico Boehr 		: [cc] "=d" (cc)
284*9312c862SJanosch Frank 		: [crw] "Q" (*crw), [bogus_cc] "d" (bogus_cc)
2852b30c34dSNico Boehr 		: "cc", "memory");
2862b30c34dSNico Boehr 	return cc;
2872b30c34dSNico Boehr }
2882b30c34dSNico Boehr 
289a3b101f0SPierre Morel /* Debug functions */
290a3b101f0SPierre Morel char *dump_pmcw_flags(uint16_t f);
291a3b101f0SPierre Morel char *dump_scsw_flags(uint32_t f);
292a3b101f0SPierre Morel 
293a3b101f0SPierre Morel void dump_scsw(struct scsw *scsw);
294a3b101f0SPierre Morel void dump_irb(struct irb *irbp);
295a3b101f0SPierre Morel void dump_schib(struct schib *sch);
296a3b101f0SPierre Morel struct ccw1 *dump_ccw(struct ccw1 *cp);
297a3b101f0SPierre Morel void dump_irb(struct irb *irbp);
298a3b101f0SPierre Morel void dump_pmcw(struct pmcw *p);
299a3b101f0SPierre Morel void dump_orb(struct orb *op);
300a3b101f0SPierre Morel 
301a3b101f0SPierre Morel int css_enumerate(void);
302a3b101f0SPierre Morel #define MAX_ENABLE_RETRIES      5
303a3b101f0SPierre Morel 
304551e6622SPierre Morel #define IO_SCH_ISC      3
305551e6622SPierre Morel int css_enable(int schid, int isc);
306d3d7fa5aSPierre Morel bool css_enabled(int schid);
3078cb729e4SPierre Morel 
3088cb729e4SPierre Morel /* Library functions */
3098cb729e4SPierre Morel int start_ccw1_chain(unsigned int sid, struct ccw1 *ccw);
310a6e5e596SPierre Morel struct ccw1 *ccw_alloc(int code, void *data, int count, unsigned char flags);
3118cb729e4SPierre Morel void css_irq_io(void);
3128cb729e4SPierre Morel int css_residual_count(unsigned int schid);
3138cb729e4SPierre Morel 
3148cb729e4SPierre Morel void enable_io_isc(uint8_t isc);
3158cb729e4SPierre Morel int wait_and_check_io_completion(int schid);
3168cb729e4SPierre Morel 
3172b30c34dSNico Boehr int css_find_installed_chpid(int sid, uint8_t *chpid_out);
3182b30c34dSNico Boehr int css_generate_crw(int sid);
3192b30c34dSNico Boehr 
3207fbcef02SPierre Morel /*
3217fbcef02SPierre Morel  * CHSC definitions
3227fbcef02SPierre Morel  */
3237fbcef02SPierre Morel struct chsc_header {
3247fbcef02SPierre Morel 	uint16_t len;
3257fbcef02SPierre Morel 	uint16_t code;
3267fbcef02SPierre Morel };
3277fbcef02SPierre Morel 
3287fbcef02SPierre Morel /* Store Channel Subsystem Characteristics */
3297fbcef02SPierre Morel struct chsc_scsc {
3307fbcef02SPierre Morel 	struct chsc_header req;
3317fbcef02SPierre Morel 	uint16_t req_fmt;
3327fbcef02SPierre Morel 	uint8_t cssid;
3337fbcef02SPierre Morel 	uint8_t reserved[9];
3347fbcef02SPierre Morel 	struct chsc_header res;
3357fbcef02SPierre Morel 	uint32_t res_fmt;
336d6c5a00eSPierre Morel #define CSSC_EXTENDED_MEASUREMENT_BLOCK 48
3377fbcef02SPierre Morel 	uint64_t general_char[255];
3387fbcef02SPierre Morel 	uint64_t chsc_char[254];
3397fbcef02SPierre Morel };
3407fbcef02SPierre Morel 
3417fbcef02SPierre Morel extern struct chsc_scsc *chsc_scsc;
3427fbcef02SPierre Morel #define CHSC_SCSC	0x0010
3437fbcef02SPierre Morel #define CHSC_SCSC_LEN	0x0010
3447fbcef02SPierre Morel 
3457fbcef02SPierre Morel bool get_chsc_scsc(void);
3467fbcef02SPierre Morel 
3477fbcef02SPierre Morel #define CSS_GENERAL_FEAT_BITLEN	(255 * 64)
3487fbcef02SPierre Morel #define CSS_CHSC_FEAT_BITLEN	(254 * 64)
3497fbcef02SPierre Morel 
3507fbcef02SPierre Morel #define CHSC_SCSC	0x0010
3517fbcef02SPierre Morel #define CHSC_SCSC_LEN	0x0010
3527fbcef02SPierre Morel 
3537fbcef02SPierre Morel #define CHSC_ERROR	0x0000
3547fbcef02SPierre Morel #define CHSC_RSP_OK	0x0001
3557fbcef02SPierre Morel #define CHSC_RSP_INVAL	0x0002
3567fbcef02SPierre Morel #define CHSC_RSP_REQERR	0x0003
3577fbcef02SPierre Morel #define CHSC_RSP_ENOCMD	0x0004
3587fbcef02SPierre Morel #define CHSC_RSP_NODATA	0x0005
3597fbcef02SPierre Morel #define CHSC_RSP_SUP31B	0x0006
3607fbcef02SPierre Morel #define CHSC_RSP_EFRMT	0x0007
3617fbcef02SPierre Morel #define CHSC_RSP_ECSSID	0x0008
3627fbcef02SPierre Morel #define CHSC_RSP_ERFRMT	0x0009
3637fbcef02SPierre Morel #define CHSC_RSP_ESSID	0x000A
3647fbcef02SPierre Morel #define CHSC_RSP_EBUSY	0x000B
3657fbcef02SPierre Morel #define CHSC_RSP_MAX	0x000B
3667fbcef02SPierre Morel 
_chsc(void * p)3677fbcef02SPierre Morel static inline int _chsc(void *p)
3687fbcef02SPierre Morel {
3697fbcef02SPierre Morel 	int cc;
3707fbcef02SPierre Morel 
3717fbcef02SPierre Morel 	asm volatile(" .insn   rre,0xb25f0000,%2,0\n"
3727fbcef02SPierre Morel 		     " ipm     %0\n"
3737fbcef02SPierre Morel 		     " srl     %0,28\n"
3747fbcef02SPierre Morel 		     : "=d" (cc), "=m" (p)
3757fbcef02SPierre Morel 		     : "d" (p), "m" (p)
3767fbcef02SPierre Morel 		     : "cc");
3777fbcef02SPierre Morel 
3787fbcef02SPierre Morel 	return cc;
3797fbcef02SPierre Morel }
3807fbcef02SPierre Morel 
3817fbcef02SPierre Morel bool chsc(void *p, uint16_t code, uint16_t len);
3827fbcef02SPierre Morel 
3837fbcef02SPierre Morel #include <bitops.h>
3847fbcef02SPierre Morel #define css_test_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char)
3857fbcef02SPierre Morel #define css_test_chsc_feature(bit) test_bit_inv(bit, chsc_scsc->chsc_char)
3867fbcef02SPierre Morel 
387d6c5a00eSPierre Morel #define SCHM_DCTM	1 /* activate Device Connection TiMe */
388d6c5a00eSPierre Morel #define SCHM_MBU	2 /* activate Measurement Block Update */
389d6c5a00eSPierre Morel 
schm(void * mbo,unsigned int flags)390d6c5a00eSPierre Morel static inline void schm(void *mbo, unsigned int flags)
391d6c5a00eSPierre Morel {
392d6c5a00eSPierre Morel 	register void *__gpr2 asm("2") = mbo;
393d6c5a00eSPierre Morel 	register long __gpr1 asm("1") = flags;
394d6c5a00eSPierre Morel 
395d6c5a00eSPierre Morel 	asm("schm" : : "d" (__gpr2), "d" (__gpr1));
396d6c5a00eSPierre Morel }
397d6c5a00eSPierre Morel 
3983c4ae93fSPierre Morel bool css_enable_mb(int sid, uint64_t mb, uint16_t mbi, uint16_t flg, bool fmt1);
3993c4ae93fSPierre Morel bool css_disable_mb(int schid);
4003c4ae93fSPierre Morel 
401a87cf540SPierre Morel struct measurement_block_format0 {
402a87cf540SPierre Morel 	uint16_t ssch_rsch_count;
403a87cf540SPierre Morel 	uint16_t sample_count;
404a87cf540SPierre Morel 	uint32_t device_connect_time;
405a87cf540SPierre Morel 	uint32_t function_pending_time;
406a87cf540SPierre Morel 	uint32_t device_disconnect_time;
407a87cf540SPierre Morel 	uint32_t cu_queuing_time;
408a87cf540SPierre Morel 	uint32_t device_active_only_time;
409a87cf540SPierre Morel 	uint32_t device_busy_time;
410a87cf540SPierre Morel 	uint32_t initial_cmd_resp_time;
411a87cf540SPierre Morel };
412a87cf540SPierre Morel 
413fa68e2a8SPierre Morel struct measurement_block_format1 {
414fa68e2a8SPierre Morel 	uint32_t ssch_rsch_count;
415fa68e2a8SPierre Morel 	uint32_t sample_count;
416fa68e2a8SPierre Morel 	uint32_t device_connect_time;
417fa68e2a8SPierre Morel 	uint32_t function_pending_time;
418fa68e2a8SPierre Morel 	uint32_t device_disconnect_time;
419fa68e2a8SPierre Morel 	uint32_t cu_queuing_time;
420fa68e2a8SPierre Morel 	uint32_t device_active_only_time;
421fa68e2a8SPierre Morel 	uint32_t device_busy_time;
422fa68e2a8SPierre Morel 	uint32_t initial_cmd_resp_time;
423fa68e2a8SPierre Morel 	uint32_t irq_delay_time;
424fa68e2a8SPierre Morel 	uint32_t irq_prio_delay_time;
425fa68e2a8SPierre Morel };
426fa68e2a8SPierre Morel 
427a3b101f0SPierre Morel #endif
428