]>
Commit | Line | Data |
---|---|---|
df75a4e2 FZ |
1 | /* |
2 | * s390 IPL device | |
3 | * | |
4 | * Copyright 2015 IBM Corp. | |
5 | * Author(s): Zhang Fan <[email protected]> | |
6 | * | |
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. | |
10 | */ | |
11 | ||
12 | #ifndef HW_S390_IPL_H | |
13 | #define HW_S390_IPL_H | |
14 | ||
04fccf10 | 15 | #include "hw/qdev.h" |
db3b2566 DH |
16 | #include "cpu.h" |
17 | ||
04ca4b92 | 18 | struct IplBlockCcw { |
118ee80f | 19 | uint8_t reserved0[85]; |
3041e3be | 20 | uint8_t ssid; |
04ca4b92 AY |
21 | uint16_t devno; |
22 | uint8_t vm_flags; | |
23 | uint8_t reserved3[3]; | |
24 | uint32_t vm_parm_len; | |
25 | uint8_t nss_name[8]; | |
26 | uint8_t vm_parm[64]; | |
27 | uint8_t reserved4[8]; | |
28 | } QEMU_PACKED; | |
29 | typedef struct IplBlockCcw IplBlockCcw; | |
30 | ||
31 | struct IplBlockFcp { | |
32 | uint8_t reserved1[305 - 1]; | |
33 | uint8_t opt; | |
34 | uint8_t reserved2[3]; | |
35 | uint16_t reserved3; | |
36 | uint16_t devno; | |
37 | uint8_t reserved4[4]; | |
38 | uint64_t wwpn; | |
39 | uint64_t lun; | |
40 | uint32_t bootprog; | |
41 | uint8_t reserved5[12]; | |
42 | uint64_t br_lba; | |
43 | uint32_t scp_data_len; | |
44 | uint8_t reserved6[260]; | |
45 | uint8_t scp_data[]; | |
46 | } QEMU_PACKED; | |
47 | typedef struct IplBlockFcp IplBlockFcp; | |
48 | ||
e468b673 AY |
49 | struct IplBlockQemuScsi { |
50 | uint32_t lun; | |
51 | uint16_t target; | |
52 | uint16_t channel; | |
53 | uint8_t reserved0[77]; | |
54 | uint8_t ssid; | |
55 | uint16_t devno; | |
56 | } QEMU_PACKED; | |
57 | typedef struct IplBlockQemuScsi IplBlockQemuScsi; | |
58 | ||
bd1badf4 FA |
59 | #define DIAG308_FLAGS_LP_VALID 0x80 |
60 | ||
04ca4b92 AY |
61 | union IplParameterBlock { |
62 | struct { | |
63 | uint32_t len; | |
64 | uint8_t reserved0[3]; | |
65 | uint8_t version; | |
66 | uint32_t blk0_len; | |
67 | uint8_t pbt; | |
68 | uint8_t flags; | |
69 | uint16_t reserved01; | |
70 | uint8_t loadparm[8]; | |
71 | union { | |
72 | IplBlockCcw ccw; | |
73 | IplBlockFcp fcp; | |
e468b673 | 74 | IplBlockQemuScsi scsi; |
04ca4b92 AY |
75 | }; |
76 | } QEMU_PACKED; | |
77 | struct { | |
78 | uint8_t reserved1[110]; | |
79 | uint16_t devno; | |
80 | uint8_t reserved2[88]; | |
81 | uint8_t reserved_ext[4096 - 200]; | |
82 | } QEMU_PACKED; | |
83 | } QEMU_PACKED; | |
84 | typedef union IplParameterBlock IplParameterBlock; | |
df75a4e2 | 85 | |
bd1badf4 | 86 | int s390_ipl_set_loadparm(uint8_t *loadparm); |
feacc6c2 | 87 | void s390_ipl_update_diag308(IplParameterBlock *iplb); |
db3b2566 | 88 | void s390_ipl_prepare_cpu(S390CPU *cpu); |
df75a4e2 | 89 | IplParameterBlock *s390_ipl_get_iplb(void); |
a30fb811 DH |
90 | |
91 | enum s390_reset { | |
92 | /* default is a reset not triggered by a CPU e.g. issued by QMP */ | |
93 | S390_RESET_EXTERNAL = 0, | |
94 | S390_RESET_REIPL, | |
95 | S390_RESET_MODIFIED_CLEAR, | |
96 | S390_RESET_LOAD_NORMAL, | |
97 | }; | |
98 | void s390_ipl_reset_request(CPUState *cs, enum s390_reset reset_type); | |
99 | void s390_ipl_get_reset_request(CPUState **cs, enum s390_reset *reset_type); | |
100 | void s390_ipl_clear_reset_request(void); | |
df75a4e2 | 101 | |
118ee80f CW |
102 | #define QIPL_ADDRESS 0xcc |
103 | ||
26b2a2a4 CW |
104 | /* Boot Menu flags */ |
105 | #define QIPL_FLAG_BM_OPTS_CMD 0x80 | |
53b310ce | 106 | #define QIPL_FLAG_BM_OPTS_ZIPL 0x40 |
26b2a2a4 | 107 | |
118ee80f CW |
108 | /* |
109 | * The QEMU IPL Parameters will be stored at absolute address | |
110 | * 204 (0xcc) which means it is 32-bit word aligned but not | |
111 | * double-word aligned. | |
112 | * Placement of data fields in this area must account for | |
113 | * their alignment needs. E.g., netboot_start_address must | |
114 | * have an offset of 4 + n * 8 bytes within the struct in order | |
115 | * to keep it double-word aligned. | |
116 | * The total size of the struct must never exceed 28 bytes. | |
117 | * This definition must be kept in sync with the defininition | |
118 | * in pc-bios/s390-ccw/iplb.h. | |
119 | */ | |
120 | struct QemuIplParameters { | |
26b2a2a4 CW |
121 | uint8_t qipl_flags; |
122 | uint8_t reserved1[3]; | |
118ee80f | 123 | uint64_t netboot_start_addr; |
26b2a2a4 CW |
124 | uint32_t boot_menu_timeout; |
125 | uint8_t reserved2[12]; | |
118ee80f CW |
126 | } QEMU_PACKED; |
127 | typedef struct QemuIplParameters QemuIplParameters; | |
128 | ||
04fccf10 DH |
129 | #define TYPE_S390_IPL "s390-ipl" |
130 | #define S390_IPL(obj) OBJECT_CHECK(S390IPLState, (obj), TYPE_S390_IPL) | |
131 | ||
132 | struct S390IPLState { | |
133 | /*< private >*/ | |
134 | DeviceState parent_obj; | |
135 | uint64_t start_addr; | |
bb099546 | 136 | uint64_t compat_start_addr; |
04fccf10 | 137 | uint64_t bios_start_addr; |
bb099546 | 138 | uint64_t compat_bios_start_addr; |
04fccf10 DH |
139 | bool enforce_bios; |
140 | IplParameterBlock iplb; | |
141 | bool iplb_valid; | |
f38b5b7f | 142 | bool netboot; |
118ee80f | 143 | QemuIplParameters qipl; |
a30fb811 DH |
144 | /* reset related properties don't have to be migrated or reset */ |
145 | enum s390_reset reset_type; | |
146 | int reset_cpu_index; | |
04fccf10 DH |
147 | |
148 | /*< public >*/ | |
149 | char *kernel; | |
150 | char *initrd; | |
151 | char *cmdline; | |
152 | char *firmware; | |
5f31ade0 | 153 | char *netboot_fw; |
04fccf10 DH |
154 | uint8_t cssid; |
155 | uint8_t ssid; | |
156 | uint16_t devno; | |
04ca4b92 | 157 | bool iplbext_migration; |
04fccf10 DH |
158 | }; |
159 | typedef struct S390IPLState S390IPLState; | |
160 | ||
9946a911 AY |
161 | #define S390_IPL_TYPE_FCP 0x00 |
162 | #define S390_IPL_TYPE_CCW 0x02 | |
e468b673 | 163 | #define S390_IPL_TYPE_QEMU_SCSI 0xff |
9946a911 | 164 | |
6aed9589 | 165 | #define S390_IPLB_HEADER_LEN 8 |
04ca4b92 | 166 | #define S390_IPLB_MIN_CCW_LEN 200 |
9946a911 | 167 | #define S390_IPLB_MIN_FCP_LEN 384 |
e468b673 | 168 | #define S390_IPLB_MIN_QEMU_SCSI_LEN 200 |
9946a911 AY |
169 | |
170 | static inline bool iplb_valid_len(IplParameterBlock *iplb) | |
171 | { | |
172 | return be32_to_cpu(iplb->len) <= sizeof(IplParameterBlock); | |
173 | } | |
174 | ||
175 | static inline bool iplb_valid_ccw(IplParameterBlock *iplb) | |
176 | { | |
177 | return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_CCW_LEN && | |
178 | iplb->pbt == S390_IPL_TYPE_CCW; | |
179 | } | |
180 | ||
181 | static inline bool iplb_valid_fcp(IplParameterBlock *iplb) | |
182 | { | |
183 | return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_FCP_LEN && | |
184 | iplb->pbt == S390_IPL_TYPE_FCP; | |
185 | } | |
04ca4b92 | 186 | |
df75a4e2 | 187 | #endif |