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