2015-07-31 17:04:51 +03:00
|
|
|
/*
|
|
|
|
* QEMU S390 IPL Block
|
|
|
|
*
|
|
|
|
* Copyright 2015 IBM Corp.
|
|
|
|
* Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at
|
|
|
|
* your option) any later version. See the COPYING file in the top-level
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef IPLB_H
|
|
|
|
#define IPLB_H
|
|
|
|
|
2018-05-29 07:40:09 +03:00
|
|
|
#define LOADPARM_LEN 8
|
|
|
|
|
2015-07-31 17:04:51 +03:00
|
|
|
struct IplBlockCcw {
|
2018-02-23 18:43:11 +03:00
|
|
|
uint8_t reserved0[85];
|
2015-07-31 17:04:51 +03:00
|
|
|
uint8_t ssid;
|
|
|
|
uint16_t devno;
|
|
|
|
uint8_t vm_flags;
|
|
|
|
uint8_t reserved3[3];
|
|
|
|
uint32_t vm_parm_len;
|
|
|
|
uint8_t nss_name[8];
|
|
|
|
uint8_t vm_parm[64];
|
|
|
|
uint8_t reserved4[8];
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
typedef struct IplBlockCcw IplBlockCcw;
|
|
|
|
|
|
|
|
struct IplBlockFcp {
|
|
|
|
uint8_t reserved1[305 - 1];
|
|
|
|
uint8_t opt;
|
|
|
|
uint8_t reserved2[3];
|
|
|
|
uint16_t reserved3;
|
|
|
|
uint16_t devno;
|
|
|
|
uint8_t reserved4[4];
|
|
|
|
uint64_t wwpn;
|
|
|
|
uint64_t lun;
|
|
|
|
uint32_t bootprog;
|
|
|
|
uint8_t reserved5[12];
|
|
|
|
uint64_t br_lba;
|
|
|
|
uint32_t scp_data_len;
|
|
|
|
uint8_t reserved6[260];
|
|
|
|
uint8_t scp_data[];
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
typedef struct IplBlockFcp IplBlockFcp;
|
|
|
|
|
2016-06-01 16:25:51 +03:00
|
|
|
struct IplBlockQemuScsi {
|
|
|
|
uint32_t lun;
|
|
|
|
uint16_t target;
|
|
|
|
uint16_t channel;
|
|
|
|
uint8_t reserved0[77];
|
|
|
|
uint8_t ssid;
|
|
|
|
uint16_t devno;
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
typedef struct IplBlockQemuScsi IplBlockQemuScsi;
|
|
|
|
|
2015-07-31 17:04:51 +03:00
|
|
|
struct IplParameterBlock {
|
|
|
|
uint32_t len;
|
|
|
|
uint8_t reserved0[3];
|
|
|
|
uint8_t version;
|
|
|
|
uint32_t blk0_len;
|
|
|
|
uint8_t pbt;
|
|
|
|
uint8_t flags;
|
|
|
|
uint16_t reserved01;
|
2018-05-29 07:40:09 +03:00
|
|
|
uint8_t loadparm[LOADPARM_LEN];
|
2015-07-31 17:04:51 +03:00
|
|
|
union {
|
|
|
|
IplBlockCcw ccw;
|
|
|
|
IplBlockFcp fcp;
|
2016-06-01 16:25:51 +03:00
|
|
|
IplBlockQemuScsi scsi;
|
2015-07-31 17:04:51 +03:00
|
|
|
};
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
typedef struct IplParameterBlock IplParameterBlock;
|
|
|
|
|
|
|
|
extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));
|
|
|
|
|
2018-02-23 18:43:11 +03:00
|
|
|
#define QIPL_ADDRESS 0xcc
|
|
|
|
|
2018-02-23 18:43:12 +03:00
|
|
|
/* Boot Menu flags */
|
|
|
|
#define QIPL_FLAG_BM_OPTS_CMD 0x80
|
2018-02-23 18:43:18 +03:00
|
|
|
#define QIPL_FLAG_BM_OPTS_ZIPL 0x40
|
2018-02-23 18:43:12 +03:00
|
|
|
|
2018-02-23 18:43:11 +03:00
|
|
|
/*
|
2022-11-11 21:17:33 +03:00
|
|
|
* This definition must be kept in sync with the definition
|
2018-02-23 18:43:11 +03:00
|
|
|
* in hw/s390x/ipl.h
|
|
|
|
*/
|
|
|
|
struct QemuIplParameters {
|
2018-02-23 18:43:12 +03:00
|
|
|
uint8_t qipl_flags;
|
|
|
|
uint8_t reserved1[3];
|
2018-02-23 18:43:11 +03:00
|
|
|
uint64_t netboot_start_addr;
|
2018-02-23 18:43:12 +03:00
|
|
|
uint32_t boot_menu_timeout;
|
|
|
|
uint8_t reserved2[12];
|
2018-02-23 18:43:11 +03:00
|
|
|
} __attribute__ ((packed));
|
|
|
|
typedef struct QemuIplParameters QemuIplParameters;
|
|
|
|
|
|
|
|
extern QemuIplParameters qipl;
|
|
|
|
|
2015-07-31 17:04:51 +03:00
|
|
|
#define S390_IPL_TYPE_FCP 0x00
|
|
|
|
#define S390_IPL_TYPE_CCW 0x02
|
2016-06-01 16:25:51 +03:00
|
|
|
#define S390_IPL_TYPE_QEMU_SCSI 0xff
|
2015-07-31 17:04:51 +03:00
|
|
|
|
2018-04-05 18:07:24 +03:00
|
|
|
static inline bool manage_iplb(IplParameterBlock *iplb, bool store)
|
2015-07-31 17:04:51 +03:00
|
|
|
{
|
|
|
|
register unsigned long addr asm("0") = (unsigned long) iplb;
|
|
|
|
register unsigned long rc asm("1") = 0;
|
2018-05-02 15:52:21 +03:00
|
|
|
unsigned long subcode = store ? 6 : 5;
|
2015-07-31 17:04:51 +03:00
|
|
|
|
|
|
|
asm volatile ("diag %0,%2,0x308\n"
|
|
|
|
: "+d" (addr), "+d" (rc)
|
2018-05-02 15:52:21 +03:00
|
|
|
: "d" (subcode)
|
2015-07-31 17:04:51 +03:00
|
|
|
: "memory", "cc");
|
|
|
|
return rc == 0x01;
|
|
|
|
}
|
|
|
|
|
2018-04-05 18:07:24 +03:00
|
|
|
|
|
|
|
static inline bool store_iplb(IplParameterBlock *iplb)
|
|
|
|
{
|
|
|
|
return manage_iplb(iplb, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool set_iplb(IplParameterBlock *iplb)
|
|
|
|
{
|
|
|
|
return manage_iplb(iplb, false);
|
|
|
|
}
|
|
|
|
|
2015-07-31 17:04:51 +03:00
|
|
|
#endif /* IPLB_H */
|