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 QIPL_ADDRESS 0xcc 76 77 /* Boot Menu flags */ 78 #define QIPL_FLAG_BM_OPTS_CMD 0x80 79 #define QIPL_FLAG_BM_OPTS_ZIPL 0x40 80 81 /* 82 * This definition must be kept in sync with the defininition 83 * in hw/s390x/ipl.h 84 */ 85 struct QemuIplParameters { 86 uint8_t qipl_flags; 87 uint8_t reserved1[3]; 88 uint64_t netboot_start_addr; 89 uint32_t boot_menu_timeout; 90 uint8_t reserved2[12]; 91 } __attribute__ ((packed)); 92 typedef struct QemuIplParameters QemuIplParameters; 93 94 extern QemuIplParameters qipl; 95 96 #define S390_IPL_TYPE_FCP 0x00 97 #define S390_IPL_TYPE_CCW 0x02 98 #define S390_IPL_TYPE_QEMU_SCSI 0xff 99 100 static inline bool store_iplb(IplParameterBlock *iplb) 101 { 102 register unsigned long addr asm("0") = (unsigned long) iplb; 103 register unsigned long rc asm("1") = 0; 104 105 asm volatile ("diag %0,%2,0x308\n" 106 : "+d" (addr), "+d" (rc) 107 : "d" (6) 108 : "memory", "cc"); 109 return rc == 0x01; 110 } 111 112 #endif /* IPLB_H */ 113