xref: /openbmc/qemu/include/hw/s390x/ipl/qipl.h (revision 0927875e)
1 /*
2  * S/390 boot structures
3  *
4  * Copyright 2024 IBM Corp.
5  * Author(s): Jared Rossi <jrossi@linux.ibm.com>
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 S390X_QIPL_H
13 #define S390X_QIPL_H
14 
15 /* Boot Menu flags */
16 #define QIPL_FLAG_BM_OPTS_CMD   0x80
17 #define QIPL_FLAG_BM_OPTS_ZIPL  0x40
18 
19 #define QIPL_ADDRESS  0xcc
20 #define LOADPARM_LEN    8
21 #define NO_LOADPARM "\0\0\0\0\0\0\0\0"
22 
23 /*
24  * The QEMU IPL Parameters will be stored at absolute address
25  * 204 (0xcc) which means it is 32-bit word aligned but not
26  * double-word aligned. Placement of 64-bit data fields in this
27  * area must account for their alignment needs.
28  * The total size of the struct must never exceed 28 bytes.
29  */
30 struct QemuIplParameters {
31     uint8_t  qipl_flags;
32     uint8_t  reserved1[3];
33     uint64_t reserved2;
34     uint32_t boot_menu_timeout;
35     uint8_t  reserved3[2];
36     uint16_t chain_len;
37     uint64_t next_iplb;
38 } QEMU_PACKED;
39 typedef struct QemuIplParameters QemuIplParameters;
40 
41 struct IPLBlockPVComp {
42     uint64_t tweak_pref;
43     uint64_t addr;
44     uint64_t size;
45 } QEMU_PACKED;
46 typedef struct IPLBlockPVComp IPLBlockPVComp;
47 
48 struct IPLBlockPV {
49     uint8_t  reserved18[87];    /* 0x18 */
50     uint8_t  version;           /* 0x6f */
51     uint32_t reserved70;        /* 0x70 */
52     uint32_t num_comp;          /* 0x74 */
53     uint64_t pv_header_addr;    /* 0x78 */
54     uint64_t pv_header_len;     /* 0x80 */
55     struct IPLBlockPVComp components[0];
56 } QEMU_PACKED;
57 typedef struct IPLBlockPV IPLBlockPV;
58 
59 struct IplBlockCcw {
60     uint8_t  reserved0[85];
61     uint8_t  ssid;
62     uint16_t devno;
63     uint8_t  vm_flags;
64     uint8_t  reserved3[3];
65     uint32_t vm_parm_len;
66     uint8_t  nss_name[8];
67     uint8_t  vm_parm[64];
68     uint8_t  reserved4[8];
69 } QEMU_PACKED;
70 typedef struct IplBlockCcw IplBlockCcw;
71 
72 struct IplBlockFcp {
73     uint8_t  reserved1[305 - 1];
74     uint8_t  opt;
75     uint8_t  reserved2[3];
76     uint16_t reserved3;
77     uint16_t devno;
78     uint8_t  reserved4[4];
79     uint64_t wwpn;
80     uint64_t lun;
81     uint32_t bootprog;
82     uint8_t  reserved5[12];
83     uint64_t br_lba;
84     uint32_t scp_data_len;
85     uint8_t  reserved6[260];
86     uint8_t  scp_data[0];
87 } QEMU_PACKED;
88 typedef struct IplBlockFcp IplBlockFcp;
89 
90 struct IplBlockQemuScsi {
91     uint32_t lun;
92     uint16_t target;
93     uint16_t channel;
94     uint8_t  reserved0[77];
95     uint8_t  ssid;
96     uint16_t devno;
97 } QEMU_PACKED;
98 typedef struct IplBlockQemuScsi IplBlockQemuScsi;
99 
100 union IplParameterBlock {
101     struct {
102         uint32_t len;
103         uint8_t  reserved0[3];
104         uint8_t  version;
105         uint32_t blk0_len;
106         uint8_t  pbt;
107         uint8_t  flags;
108         uint16_t reserved01;
109         uint8_t  loadparm[LOADPARM_LEN];
110         union {
111             IplBlockCcw ccw;
112             IplBlockFcp fcp;
113             IPLBlockPV pv;
114             IplBlockQemuScsi scsi;
115         };
116     } QEMU_PACKED;
117     struct {
118         uint8_t  reserved1[110];
119         uint16_t devno;
120         uint8_t  reserved2[88];
121         uint8_t  reserved_ext[4096 - 200];
122     } QEMU_PACKED;
123 } QEMU_PACKED;
124 typedef union IplParameterBlock IplParameterBlock;
125 
126 #endif
127