2 * QEMU S390 bootmap interpreter -- declarations
4 * Copyright 2014 IBM Corp.
5 * Author(s): Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com>
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
11 #ifndef _PC_BIOS_S390_CCW_BOOTMAP_H
12 #define _PC_BIOS_S390_CCW_BOOTMAP_H
16 #define FREE_SPACE_FILLER '\xAA'
18 typedef struct ScsiBlockPtr
{
23 } __attribute__ ((packed
)) ScsiBlockPtr
;
25 typedef struct FbaBlockPtr
{
29 } __attribute__ ((packed
)) FbaBlockPtr
;
31 typedef struct EckdBlockPtr
{
32 uint16_t cylinder
; /* cylinder/head/sector is an address of the block */
36 uint8_t count
; /* (size_in_blocks-1);
37 * it's 0 for TablePtr, ScriptPtr, and SectionPtr */
38 } __attribute__ ((packed
)) EckdBlockPtr
;
40 typedef struct ExtEckdBlockPtr
{
43 } __attribute__ ((packed
)) ExtEckdBlockPtr
;
45 typedef union BootMapPointer
{
49 ExtEckdBlockPtr xeckd
;
50 } __attribute__ ((packed
)) BootMapPointer
;
52 typedef struct ComponentEntry
{
55 uint8_t component_type
;
56 uint64_t load_address
;
57 } __attribute((packed
)) ComponentEntry
;
59 typedef struct ComponentHeader
{
60 uint8_t magic
[4]; /* == "zIPL" */
61 uint8_t type
; /* == ZIPL_COMP_HEADER_* */
63 } __attribute((packed
)) ComponentHeader
;
65 typedef struct ScsiMbr
{
69 ScsiBlockPtr blockptr
;
70 } __attribute__ ((packed
)) ScsiMbr
;
72 #define ZIPL_MAGIC "zIPL"
73 #define IPL1_MAGIC "\xc9\xd7\xd3\xf1" /* == "IPL1" in EBCDIC */
74 #define IPL2_MAGIC "\xc9\xd7\xd3\xf2" /* == "IPL2" in EBCDIC */
75 #define VOL1_MAGIC "\xe5\xd6\xd3\xf1" /* == "VOL1" in EBCDIC */
76 #define LNX1_MAGIC "\xd3\xd5\xe7\xf1" /* == "LNX1" in EBCDIC */
77 #define CMS1_MAGIC "\xc3\xd4\xe2\xf1" /* == "CMS1" in EBCDIC */
79 #define LDL1_VERSION '\x40' /* == ' ' in EBCDIC */
80 #define LDL2_VERSION '\xf2' /* == '2' in EBCDIC */
82 #define ZIPL_COMP_HEADER_IPL 0x00
83 #define ZIPL_COMP_HEADER_DUMP 0x01
85 #define ZIPL_COMP_ENTRY_LOAD 0x02
86 #define ZIPL_COMP_ENTRY_EXEC 0x01
88 typedef struct XEckdMbr
{
89 uint8_t magic
[4]; /* == "xIPL" */
92 uint8_t dev_type
; /* == DEV_TYPE_* */
93 #define DEV_TYPE_ECKD 0x00
94 #define DEV_TYPE_FBA 0x01
96 BootMapPointer blockptr
;
98 } __attribute__ ((packed
)) XEckdMbr
; /* see also BootInfo */
100 typedef struct BootMapScriptEntry
{
101 BootMapPointer blkptr
;
103 uint8_t type
; /* == BOOT_SCRIPT_* */
104 #define BOOT_SCRIPT_EXEC 0x01
105 #define BOOT_SCRIPT_LOAD 0x02
107 uint64_t load_address
;
110 } __attribute__ ((packed
)) BootMapScriptEntry
;
112 typedef struct BootMapScriptHeader
{
115 #define BOOT_SCRIPT_HDR_IPL 0x00
116 uint8_t reserved
[27];
117 } __attribute__ ((packed
)) BootMapScriptHeader
;
119 typedef struct BootMapScript
{
120 BootMapScriptHeader header
;
121 BootMapScriptEntry entry
[0];
122 } __attribute__ ((packed
)) BootMapScript
;
125 * These aren't real VTOCs, but referred to this way in some docs.
126 * They are "volume labels" actually.
128 * Some structures looks similar to described above, but left
129 * separate as there is no indication that they are the same.
130 * So, the value definitions are left separate too.
132 typedef struct LDL_VTOC
{ /* @ rec.3 cyl.0 trk.0 for ECKD */
133 char magic
[4]; /* "LNX1", EBCDIC */
134 char volser
[6]; /* volser, EBCDIC */
135 uint8_t reserved
[69]; /* reserved, 0x40 */
136 uint8_t LDL_version
; /* 0x40 or 0xF2 */
137 uint64_t formatted_blocks
; /* if LDL_version >= 0xF2 */
138 } __attribute__ ((packed
)) LDL_VTOC
;
140 typedef struct format_date
{
147 } __attribute__ ((packed
)) format_date_t
;
149 typedef struct CMS_VTOC
{ /* @ rec.3 cyl.0 trk.0 for ECKD */
150 /* @ blk.1 (zero based) for FBA */
151 char magic
[4]; /* 'CMS1', EBCDIC */
152 char volser
[6]; /* volser, EBCDIC */
153 uint16_t version
; /* = 0 */
154 uint32_t block_size
; /* = 512, 1024, 2048, or 4096 */
155 uint32_t disk_origin
; /* = 4 or 5 */
156 uint32_t blocks
; /* Number of usable cyls/blocks */
157 uint32_t formatted
; /* Max number of fmtd cyls/blks */
158 uint32_t CMS_blocks
; /* disk size in CMS blocks */
159 uint32_t CMS_used
; /* Number of CMS blocks in use */
160 uint32_t FST_size
; /* = 64, bytes */
161 uint32_t FST_per_CMS_blk
; /* */
162 format_date_t format_date
; /* YYMMDDhhmmss as 6 bytes */
163 uint8_t reserved1
[2]; /* = 0 */
164 uint32_t offset
; /* disk offset when reserved */
165 uint32_t next_hole
; /* block nr */
166 uint32_t HBLK_hole_offset
; /* >> HBLK data of next hole */
167 uint32_t alloc_map_usr_off
; /* >> user part of Alloc map */
168 uint8_t reserved2
[4]; /* = 0 */
169 char shared_seg_name
[8]; /* */
170 } __attribute__ ((packed
)) CMS_VTOC
;
172 /* from zipl/include/boot.h */
173 typedef struct BootInfoBpIpl
{
175 ExtEckdBlockPtr eckd
;
179 } __attribute__ ((packed
)) BootInfoBpIpl
;
181 typedef struct EckdDumpParam
{
188 } __attribute((packed
, may_alias
)) EckdDumpParam
;
190 typedef struct FbaDumpParam
{
193 } __attribute((packed
)) FbaDumpParam
;
195 typedef struct BootInfoBpDump
{
201 } __attribute__ ((packed
)) BootInfoBpDump
;
203 typedef struct BootInfo
{ /* @ 0x70, record #0 */
204 unsigned char magic
[4]; /* = 'zIPL', ASCII */
205 uint8_t version
; /* = 1 */
206 #define BOOT_INFO_VERSION 1
207 uint8_t bp_type
; /* = 0 */
208 #define BOOT_INFO_BP_TYPE_IPL 0x00
209 #define BOOT_INFO_BP_TYPE_DUMP 0x01
210 uint8_t dev_type
; /* = 0 */
211 #define BOOT_INFO_DEV_TYPE_ECKD 0x00
212 #define BOOT_INFO_DEV_TYPE_FBA 0x01
213 uint8_t flags
; /* = 1 */
215 #define BOOT_INFO_FLAGS_ARCH 0x01
217 #define BOOT_INFO_FLAGS_ARCH 0x00
223 } __attribute__ ((packed
)) BootInfo
; /* see also XEckdMbr */
225 typedef struct Ipl1
{
226 unsigned char key
[4]; /* == "IPL1" */
227 unsigned char data
[24];
228 } __attribute__((packed
)) Ipl1
;
230 typedef struct Ipl2
{
231 unsigned char key
[4]; /* == "IPL2" */
233 unsigned char data
[144];
235 unsigned char reserved1
[92-4];
237 unsigned char reserved2
[144-(92-4)-sizeof(XEckdMbr
)];
240 } __attribute__((packed
)) Ipl2
;
242 typedef struct IplVolumeLabel
{
243 unsigned char key
[4]; /* == "VOL1" */
245 unsigned char data
[80];
247 unsigned char key
[4]; /* == "VOL1" */
248 unsigned char volser
[6];
249 unsigned char reserved
[6];
252 } __attribute__((packed
)) IplVolumeLabel
;
254 #endif /* _PC_BIOS_S390_CCW_BOOTMAP_H */