]>
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 { |
f38b5b7f FA |
19 | uint64_t netboot_start_addr; |
20 | uint8_t reserved0[77]; | |
3041e3be | 21 | uint8_t ssid; |
04ca4b92 AY |
22 | uint16_t devno; |
23 | uint8_t vm_flags; | |
24 | uint8_t reserved3[3]; | |
25 | uint32_t vm_parm_len; | |
26 | uint8_t nss_name[8]; | |
27 | uint8_t vm_parm[64]; | |
28 | uint8_t reserved4[8]; | |
29 | } QEMU_PACKED; | |
30 | typedef struct IplBlockCcw IplBlockCcw; | |
31 | ||
32 | struct IplBlockFcp { | |
33 | uint8_t reserved1[305 - 1]; | |
34 | uint8_t opt; | |
35 | uint8_t reserved2[3]; | |
36 | uint16_t reserved3; | |
37 | uint16_t devno; | |
38 | uint8_t reserved4[4]; | |
39 | uint64_t wwpn; | |
40 | uint64_t lun; | |
41 | uint32_t bootprog; | |
42 | uint8_t reserved5[12]; | |
43 | uint64_t br_lba; | |
44 | uint32_t scp_data_len; | |
45 | uint8_t reserved6[260]; | |
46 | uint8_t scp_data[]; | |
47 | } QEMU_PACKED; | |
48 | typedef struct IplBlockFcp IplBlockFcp; | |
49 | ||
e468b673 AY |
50 | struct IplBlockQemuScsi { |
51 | uint32_t lun; | |
52 | uint16_t target; | |
53 | uint16_t channel; | |
54 | uint8_t reserved0[77]; | |
55 | uint8_t ssid; | |
56 | uint16_t devno; | |
57 | } QEMU_PACKED; | |
58 | typedef struct IplBlockQemuScsi IplBlockQemuScsi; | |
59 | ||
bd1badf4 FA |
60 | #define DIAG308_FLAGS_LP_VALID 0x80 |
61 | ||
04ca4b92 AY |
62 | union IplParameterBlock { |
63 | struct { | |
64 | uint32_t len; | |
65 | uint8_t reserved0[3]; | |
66 | uint8_t version; | |
67 | uint32_t blk0_len; | |
68 | uint8_t pbt; | |
69 | uint8_t flags; | |
70 | uint16_t reserved01; | |
71 | uint8_t loadparm[8]; | |
72 | union { | |
73 | IplBlockCcw ccw; | |
74 | IplBlockFcp fcp; | |
e468b673 | 75 | IplBlockQemuScsi scsi; |
04ca4b92 AY |
76 | }; |
77 | } QEMU_PACKED; | |
78 | struct { | |
79 | uint8_t reserved1[110]; | |
80 | uint16_t devno; | |
81 | uint8_t reserved2[88]; | |
82 | uint8_t reserved_ext[4096 - 200]; | |
83 | } QEMU_PACKED; | |
84 | } QEMU_PACKED; | |
85 | typedef union IplParameterBlock IplParameterBlock; | |
df75a4e2 | 86 | |
bd1badf4 | 87 | int s390_ipl_set_loadparm(uint8_t *loadparm); |
feacc6c2 | 88 | void s390_ipl_update_diag308(IplParameterBlock *iplb); |
db3b2566 | 89 | void s390_ipl_prepare_cpu(S390CPU *cpu); |
df75a4e2 | 90 | IplParameterBlock *s390_ipl_get_iplb(void); |
e91e972c | 91 | void s390_reipl_request(void); |
df75a4e2 | 92 | |
04fccf10 DH |
93 | #define TYPE_S390_IPL "s390-ipl" |
94 | #define S390_IPL(obj) OBJECT_CHECK(S390IPLState, (obj), TYPE_S390_IPL) | |
95 | ||
96 | struct S390IPLState { | |
97 | /*< private >*/ | |
98 | DeviceState parent_obj; | |
99 | uint64_t start_addr; | |
bb099546 | 100 | uint64_t compat_start_addr; |
04fccf10 | 101 | uint64_t bios_start_addr; |
bb099546 | 102 | uint64_t compat_bios_start_addr; |
04fccf10 DH |
103 | bool enforce_bios; |
104 | IplParameterBlock iplb; | |
105 | bool iplb_valid; | |
106 | bool reipl_requested; | |
f38b5b7f | 107 | bool netboot; |
04fccf10 DH |
108 | |
109 | /*< public >*/ | |
110 | char *kernel; | |
111 | char *initrd; | |
112 | char *cmdline; | |
113 | char *firmware; | |
5f31ade0 | 114 | char *netboot_fw; |
04fccf10 DH |
115 | uint8_t cssid; |
116 | uint8_t ssid; | |
117 | uint16_t devno; | |
04ca4b92 | 118 | bool iplbext_migration; |
04fccf10 DH |
119 | }; |
120 | typedef struct S390IPLState S390IPLState; | |
121 | ||
9946a911 AY |
122 | #define S390_IPL_TYPE_FCP 0x00 |
123 | #define S390_IPL_TYPE_CCW 0x02 | |
e468b673 | 124 | #define S390_IPL_TYPE_QEMU_SCSI 0xff |
9946a911 | 125 | |
6aed9589 | 126 | #define S390_IPLB_HEADER_LEN 8 |
04ca4b92 | 127 | #define S390_IPLB_MIN_CCW_LEN 200 |
9946a911 | 128 | #define S390_IPLB_MIN_FCP_LEN 384 |
e468b673 | 129 | #define S390_IPLB_MIN_QEMU_SCSI_LEN 200 |
9946a911 AY |
130 | |
131 | static inline bool iplb_valid_len(IplParameterBlock *iplb) | |
132 | { | |
133 | return be32_to_cpu(iplb->len) <= sizeof(IplParameterBlock); | |
134 | } | |
135 | ||
136 | static inline bool iplb_valid_ccw(IplParameterBlock *iplb) | |
137 | { | |
138 | return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_CCW_LEN && | |
139 | iplb->pbt == S390_IPL_TYPE_CCW; | |
140 | } | |
141 | ||
142 | static inline bool iplb_valid_fcp(IplParameterBlock *iplb) | |
143 | { | |
144 | return be32_to_cpu(iplb->len) >= S390_IPLB_MIN_FCP_LEN && | |
145 | iplb->pbt == S390_IPL_TYPE_FCP; | |
146 | } | |
04ca4b92 | 147 | |
df75a4e2 | 148 | #endif |