1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *    Copyright IBM Corp. 2007
4  *    Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
5  */
6 
7 #ifndef _ASM_S390_SCLP_H
8 #define _ASM_S390_SCLP_H
9 
10 #include <linux/types.h>
11 #include <asm/chpid.h>
12 #include <asm/cpu.h>
13 
14 #define SCLP_CHP_INFO_MASK_SIZE		32
15 #define EARLY_SCCB_SIZE		PAGE_SIZE
16 #define SCLP_MAX_CORES		512
17 /* 144 + 16 * SCLP_MAX_CORES + 2 * (SCLP_MAX_CORES - 1) */
18 #define EXT_SCCB_READ_SCP	(3 * PAGE_SIZE)
19 /* 24 + 16 * SCLP_MAX_CORES */
20 #define EXT_SCCB_READ_CPU	(3 * PAGE_SIZE)
21 
22 struct sclp_chp_info {
23 	u8 recognized[SCLP_CHP_INFO_MASK_SIZE];
24 	u8 standby[SCLP_CHP_INFO_MASK_SIZE];
25 	u8 configured[SCLP_CHP_INFO_MASK_SIZE];
26 };
27 
28 #define LOADPARM_LEN 8
29 
30 struct sclp_ipl_info {
31 	int is_valid;
32 	int has_dump;
33 	char loadparm[LOADPARM_LEN];
34 };
35 
36 struct sclp_core_entry {
37 	u8 core_id;
38 	u8 reserved0;
39 	u8 : 4;
40 	u8 sief2 : 1;
41 	u8 skey : 1;
42 	u8 : 2;
43 	u8 : 2;
44 	u8 gpere : 1;
45 	u8 siif : 1;
46 	u8 sigpif : 1;
47 	u8 : 3;
48 	u8 reserved2[3];
49 	u8 : 2;
50 	u8 ib : 1;
51 	u8 cei : 1;
52 	u8 : 4;
53 	u8 reserved3[6];
54 	u8 type;
55 	u8 reserved1;
56 } __attribute__((packed));
57 
58 struct sclp_core_info {
59 	unsigned int configured;
60 	unsigned int standby;
61 	unsigned int combined;
62 	struct sclp_core_entry core[SCLP_MAX_CORES];
63 };
64 
65 struct sclp_info {
66 	unsigned char has_linemode : 1;
67 	unsigned char has_vt220 : 1;
68 	unsigned char has_siif : 1;
69 	unsigned char has_sigpif : 1;
70 	unsigned char has_core_type : 1;
71 	unsigned char has_sprp : 1;
72 	unsigned char has_hvs : 1;
73 	unsigned char has_esca : 1;
74 	unsigned char has_sief2 : 1;
75 	unsigned char has_64bscao : 1;
76 	unsigned char has_gpere : 1;
77 	unsigned char has_cmma : 1;
78 	unsigned char has_gsls : 1;
79 	unsigned char has_ib : 1;
80 	unsigned char has_cei : 1;
81 	unsigned char has_pfmfi : 1;
82 	unsigned char has_ibs : 1;
83 	unsigned char has_skey : 1;
84 	unsigned char has_kss : 1;
85 	unsigned char has_gisaf : 1;
86 	unsigned char has_diag318 : 1;
87 	unsigned char has_sipl : 1;
88 	unsigned char has_dirq : 1;
89 	unsigned int ibc;
90 	unsigned int mtid;
91 	unsigned int mtid_cp;
92 	unsigned int mtid_prev;
93 	unsigned long rzm;
94 	unsigned long rnmax;
95 	unsigned long hamax;
96 	unsigned int max_cores;
97 	unsigned long hsa_size;
98 	unsigned long facilities;
99 	unsigned int hmfai;
100 };
101 extern struct sclp_info sclp;
102 
103 struct zpci_report_error_header {
104 	u8 version;	/* Interface version byte */
105 	u8 action;	/* Action qualifier byte
106 			 * 0: Adapter Reset Request
107 			 * 1: Deconfigure and repair action requested
108 			 *	(OpenCrypto Problem Call Home)
109 			 * 2: Informational Report
110 			 *	(OpenCrypto Successful Diagnostics Execution)
111 			 */
112 	u16 length;	/* Length of Subsequent Data (up to 4K – SCLP header */
113 	u8 data[0];	/* Subsequent Data passed verbatim to SCLP ET 24 */
114 } __packed;
115 
116 int sclp_early_read_info(void);
117 int sclp_early_read_storage_info(void);
118 int sclp_early_get_core_info(struct sclp_core_info *info);
119 void sclp_early_get_ipl_info(struct sclp_ipl_info *info);
120 void sclp_early_detect(void);
121 void sclp_early_printk(const char *s);
122 void __sclp_early_printk(const char *s, unsigned int len);
123 
124 int sclp_early_get_memsize(unsigned long *mem);
125 int sclp_early_get_hsa_size(unsigned long *hsa_size);
126 int _sclp_get_core_info(struct sclp_core_info *info);
127 int sclp_core_configure(u8 core);
128 int sclp_core_deconfigure(u8 core);
129 int sclp_sdias_blk_count(void);
130 int sclp_sdias_copy(void *dest, int blk_num, int nr_blks);
131 int sclp_chp_configure(struct chp_id chpid);
132 int sclp_chp_deconfigure(struct chp_id chpid);
133 int sclp_chp_read_info(struct sclp_chp_info *info);
134 int sclp_pci_configure(u32 fid);
135 int sclp_pci_deconfigure(u32 fid);
136 int sclp_ap_configure(u32 apid);
137 int sclp_ap_deconfigure(u32 apid);
138 int sclp_pci_report(struct zpci_report_error_header *report, u32 fh, u32 fid);
139 int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count);
140 int memcpy_hsa_user(void __user *dest, unsigned long src, size_t count);
141 void sclp_ocf_cpc_name_copy(char *dst);
142 
sclp_get_core_info(struct sclp_core_info * info,int early)143 static inline int sclp_get_core_info(struct sclp_core_info *info, int early)
144 {
145 	if (early)
146 		return sclp_early_get_core_info(info);
147 	return _sclp_get_core_info(info);
148 }
149 
150 #endif /* _ASM_S390_SCLP_H */
151