xref: /openbmc/qemu/pc-bios/s390-ccw/iplb.h (revision 48151859)
1 /*
2  * QEMU S390 IPL Block
3  *
4  * Copyright 2015 IBM Corp.
5  * Author(s): Alexander Yarygin <yarygin@linux.vnet.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 IPLB_H
13 #define IPLB_H
14 
15 struct IplBlockCcw {
16     uint8_t  reserved0[85];
17     uint8_t  ssid;
18     uint16_t devno;
19     uint8_t  vm_flags;
20     uint8_t  reserved3[3];
21     uint32_t vm_parm_len;
22     uint8_t  nss_name[8];
23     uint8_t  vm_parm[64];
24     uint8_t  reserved4[8];
25 } __attribute__ ((packed));
26 typedef struct IplBlockCcw IplBlockCcw;
27 
28 struct IplBlockFcp {
29     uint8_t  reserved1[305 - 1];
30     uint8_t  opt;
31     uint8_t  reserved2[3];
32     uint16_t reserved3;
33     uint16_t devno;
34     uint8_t  reserved4[4];
35     uint64_t wwpn;
36     uint64_t lun;
37     uint32_t bootprog;
38     uint8_t  reserved5[12];
39     uint64_t br_lba;
40     uint32_t scp_data_len;
41     uint8_t  reserved6[260];
42     uint8_t  scp_data[];
43 } __attribute__ ((packed));
44 typedef struct IplBlockFcp IplBlockFcp;
45 
46 struct IplBlockQemuScsi {
47     uint32_t lun;
48     uint16_t target;
49     uint16_t channel;
50     uint8_t  reserved0[77];
51     uint8_t  ssid;
52     uint16_t devno;
53 } __attribute__ ((packed));
54 typedef struct IplBlockQemuScsi IplBlockQemuScsi;
55 
56 struct IplParameterBlock {
57     uint32_t len;
58     uint8_t  reserved0[3];
59     uint8_t  version;
60     uint32_t blk0_len;
61     uint8_t  pbt;
62     uint8_t  flags;
63     uint16_t reserved01;
64     uint8_t  loadparm[8];
65     union {
66         IplBlockCcw ccw;
67         IplBlockFcp fcp;
68         IplBlockQemuScsi scsi;
69     };
70 } __attribute__ ((packed));
71 typedef struct IplParameterBlock IplParameterBlock;
72 
73 extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));
74 
75 #define S390_IPL_TYPE_FCP 0x00
76 #define S390_IPL_TYPE_CCW 0x02
77 #define S390_IPL_TYPE_QEMU_SCSI 0xff
78 
79 static inline bool store_iplb(IplParameterBlock *iplb)
80 {
81     register unsigned long addr asm("0") = (unsigned long) iplb;
82     register unsigned long rc asm("1") = 0;
83 
84     asm volatile ("diag %0,%2,0x308\n"
85                   : "+d" (addr), "+d" (rc)
86                   : "d" (6)
87                   : "memory", "cc");
88     return rc == 0x01;
89 }
90 
91 #endif /* IPLB_H */
92