xref: /openbmc/linux/arch/s390/include/asm/ipl.h (revision feac8c8b)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * s390 (re)ipl support
4  *
5  * Copyright IBM Corp. 2007
6  */
7 
8 #ifndef _ASM_S390_IPL_H
9 #define _ASM_S390_IPL_H
10 
11 #include <asm/lowcore.h>
12 #include <asm/types.h>
13 #include <asm/cio.h>
14 #include <asm/setup.h>
15 
16 #define NSS_NAME_SIZE	8
17 
18 #define IPL_PARMBLOCK_ORIGIN	0x2000
19 
20 #define IPL_PARM_BLK_FCP_LEN (sizeof(struct ipl_list_hdr) + \
21 			      sizeof(struct ipl_block_fcp))
22 
23 #define IPL_PARM_BLK0_FCP_LEN (sizeof(struct ipl_block_fcp) + 16)
24 
25 #define IPL_PARM_BLK_CCW_LEN (sizeof(struct ipl_list_hdr) + \
26 			      sizeof(struct ipl_block_ccw))
27 
28 #define IPL_PARM_BLK0_CCW_LEN (sizeof(struct ipl_block_ccw) + 16)
29 
30 #define IPL_MAX_SUPPORTED_VERSION (0)
31 
32 #define IPL_PARMBLOCK_START	((struct ipl_parameter_block *) \
33 				 IPL_PARMBLOCK_ORIGIN)
34 #define IPL_PARMBLOCK_SIZE	(IPL_PARMBLOCK_START->hdr.len)
35 
36 struct ipl_list_hdr {
37 	u32 len;
38 	u8  reserved1[3];
39 	u8  version;
40 	u32 blk0_len;
41 	u8  pbt;
42 	u8  flags;
43 	u16 reserved2;
44 	u8  loadparm[8];
45 } __attribute__((packed));
46 
47 struct ipl_block_fcp {
48 	u8  reserved1[305-1];
49 	u8  opt;
50 	u8  reserved2[3];
51 	u16 reserved3;
52 	u16 devno;
53 	u8  reserved4[4];
54 	u64 wwpn;
55 	u64 lun;
56 	u32 bootprog;
57 	u8  reserved5[12];
58 	u64 br_lba;
59 	u32 scp_data_len;
60 	u8  reserved6[260];
61 	u8  scp_data[];
62 } __attribute__((packed));
63 
64 #define DIAG308_VMPARM_SIZE	64
65 #define DIAG308_SCPDATA_SIZE	(PAGE_SIZE - (sizeof(struct ipl_list_hdr) + \
66 				 offsetof(struct ipl_block_fcp, scp_data)))
67 
68 struct ipl_block_ccw {
69 	u8  reserved1[84];
70 	u16 reserved2 : 13;
71 	u8  ssid : 3;
72 	u16 devno;
73 	u8  vm_flags;
74 	u8  reserved3[3];
75 	u32 vm_parm_len;
76 	u8  nss_name[8];
77 	u8  vm_parm[DIAG308_VMPARM_SIZE];
78 	u8  reserved4[8];
79 } __attribute__((packed));
80 
81 struct ipl_parameter_block {
82 	struct ipl_list_hdr hdr;
83 	union {
84 		struct ipl_block_fcp fcp;
85 		struct ipl_block_ccw ccw;
86 	} ipl_info;
87 } __packed __aligned(PAGE_SIZE);
88 
89 /*
90  * IPL validity flags
91  */
92 extern u32 ipl_flags;
93 
94 struct save_area;
95 struct save_area * __init save_area_alloc(bool is_boot_cpu);
96 struct save_area * __init save_area_boot_cpu(void);
97 void __init save_area_add_regs(struct save_area *, void *regs);
98 void __init save_area_add_vxrs(struct save_area *, __vector128 *vxrs);
99 
100 extern void do_reipl(void);
101 extern void do_halt(void);
102 extern void do_poff(void);
103 extern void ipl_verify_parameters(void);
104 extern void ipl_update_parameters(void);
105 extern size_t append_ipl_vmparm(char *, size_t);
106 extern size_t append_ipl_scpdata(char *, size_t);
107 
108 enum {
109 	IPL_DEVNO_VALID		= 1,
110 	IPL_PARMBLOCK_VALID	= 2,
111 };
112 
113 enum ipl_type {
114 	IPL_TYPE_UNKNOWN	= 1,
115 	IPL_TYPE_CCW		= 2,
116 	IPL_TYPE_FCP		= 4,
117 	IPL_TYPE_FCP_DUMP	= 8,
118 	IPL_TYPE_NSS		= 16,
119 };
120 
121 struct ipl_info
122 {
123 	enum ipl_type type;
124 	union {
125 		struct {
126 			struct ccw_dev_id dev_id;
127 		} ccw;
128 		struct {
129 			struct ccw_dev_id dev_id;
130 			u64 wwpn;
131 			u64 lun;
132 		} fcp;
133 		struct {
134 			char name[NSS_NAME_SIZE + 1];
135 		} nss;
136 	} data;
137 };
138 
139 extern struct ipl_info ipl_info;
140 extern void setup_ipl(void);
141 
142 /*
143  * DIAG 308 support
144  */
145 enum diag308_subcode  {
146 	DIAG308_REL_HSA = 2,
147 	DIAG308_LOAD_CLEAR = 3,
148 	DIAG308_LOAD_NORMAL_DUMP = 4,
149 	DIAG308_SET = 5,
150 	DIAG308_STORE = 6,
151 };
152 
153 enum diag308_ipl_type {
154 	DIAG308_IPL_TYPE_FCP	= 0,
155 	DIAG308_IPL_TYPE_CCW	= 2,
156 };
157 
158 enum diag308_opt {
159 	DIAG308_IPL_OPT_IPL	= 0x10,
160 	DIAG308_IPL_OPT_DUMP	= 0x20,
161 };
162 
163 enum diag308_flags {
164 	DIAG308_FLAGS_LP_VALID	= 0x80,
165 };
166 
167 enum diag308_vm_flags {
168 	DIAG308_VM_FLAGS_NSS_VALID	= 0x80,
169 	DIAG308_VM_FLAGS_VP_VALID	= 0x40,
170 };
171 
172 enum diag308_rc {
173 	DIAG308_RC_OK		= 0x0001,
174 	DIAG308_RC_NOCONFIG	= 0x0102,
175 };
176 
177 extern int diag308(unsigned long subcode, void *addr);
178 extern void diag308_reset(void);
179 extern void store_status(void (*fn)(void *), void *data);
180 extern void lgr_info_log(void);
181 
182 #endif /* _ASM_S390_IPL_H */
183