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