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