xref: /openbmc/qemu/include/hw/s390x/ipl/qipl.h (revision bb185de4)
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[12];
36 } QEMU_PACKED;
37 typedef struct QemuIplParameters QemuIplParameters;
38 
39 struct IPLBlockPVComp {
40     uint64_t tweak_pref;
41     uint64_t addr;
42     uint64_t size;
43 } QEMU_PACKED;
44 typedef struct IPLBlockPVComp IPLBlockPVComp;
45 
46 struct IPLBlockPV {
47     uint8_t  reserved18[87];    /* 0x18 */
48     uint8_t  version;           /* 0x6f */
49     uint32_t reserved70;        /* 0x70 */
50     uint32_t num_comp;          /* 0x74 */
51     uint64_t pv_header_addr;    /* 0x78 */
52     uint64_t pv_header_len;     /* 0x80 */
53     struct IPLBlockPVComp components[0];
54 } QEMU_PACKED;
55 typedef struct IPLBlockPV IPLBlockPV;
56 
57 struct IplBlockCcw {
58     uint8_t  reserved0[85];
59     uint8_t  ssid;
60     uint16_t devno;
61     uint8_t  vm_flags;
62     uint8_t  reserved3[3];
63     uint32_t vm_parm_len;
64     uint8_t  nss_name[8];
65     uint8_t  vm_parm[64];
66     uint8_t  reserved4[8];
67 } QEMU_PACKED;
68 typedef struct IplBlockCcw IplBlockCcw;
69 
70 struct IplBlockFcp {
71     uint8_t  reserved1[305 - 1];
72     uint8_t  opt;
73     uint8_t  reserved2[3];
74     uint16_t reserved3;
75     uint16_t devno;
76     uint8_t  reserved4[4];
77     uint64_t wwpn;
78     uint64_t lun;
79     uint32_t bootprog;
80     uint8_t  reserved5[12];
81     uint64_t br_lba;
82     uint32_t scp_data_len;
83     uint8_t  reserved6[260];
84     uint8_t  scp_data[0];
85 } QEMU_PACKED;
86 typedef struct IplBlockFcp IplBlockFcp;
87 
88 struct IplBlockQemuScsi {
89     uint32_t lun;
90     uint16_t target;
91     uint16_t channel;
92     uint8_t  reserved0[77];
93     uint8_t  ssid;
94     uint16_t devno;
95 } QEMU_PACKED;
96 typedef struct IplBlockQemuScsi IplBlockQemuScsi;
97 
98 union IplParameterBlock {
99     struct {
100         uint32_t len;
101         uint8_t  reserved0[3];
102         uint8_t  version;
103         uint32_t blk0_len;
104         uint8_t  pbt;
105         uint8_t  flags;
106         uint16_t reserved01;
107         uint8_t  loadparm[LOADPARM_LEN];
108         union {
109             IplBlockCcw ccw;
110             IplBlockFcp fcp;
111             IPLBlockPV pv;
112             IplBlockQemuScsi scsi;
113         };
114     } QEMU_PACKED;
115     struct {
116         uint8_t  reserved1[110];
117         uint16_t devno;
118         uint8_t  reserved2[88];
119         uint8_t  reserved_ext[4096 - 200];
120     } QEMU_PACKED;
121 } QEMU_PACKED;
122 typedef union IplParameterBlock IplParameterBlock;
123 
124 #endif
125