2013-04-22 23:02:49 +04:00
|
|
|
/*
|
|
|
|
* QEMU S390 bootmap interpreter
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 Alexander Graf <agraf@suse.de>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2017-07-12 15:49:43 +03:00
|
|
|
#include "libc.h"
|
2013-04-22 23:02:49 +04:00
|
|
|
#include "s390-ccw.h"
|
2020-10-06 12:42:46 +03:00
|
|
|
#include "s390-arch.h"
|
2014-05-19 22:08:54 +04:00
|
|
|
#include "bootmap.h"
|
2014-05-19 22:10:27 +04:00
|
|
|
#include "virtio.h"
|
2017-07-12 15:49:47 +03:00
|
|
|
#include "bswap.h"
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2014-05-19 22:12:43 +04:00
|
|
|
#ifdef DEBUG
|
2014-05-19 22:05:40 +04:00
|
|
|
/* #define DEBUG_FALLBACK */
|
2014-05-19 22:12:43 +04:00
|
|
|
#endif
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_FALLBACK
|
|
|
|
#define dputs(txt) \
|
|
|
|
do { sclp_print("zipl: " txt); } while (0)
|
|
|
|
#else
|
|
|
|
#define dputs(fmt, ...) \
|
|
|
|
do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Scratch space */
|
2014-05-19 22:12:43 +04:00
|
|
|
static uint8_t sec[MAX_SECTOR_SIZE*4] __attribute__((__aligned__(PAGE_SIZE)));
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2018-03-06 09:18:01 +03:00
|
|
|
const uint8_t el_torito_magic[] = "EL TORITO SPECIFICATION"
|
|
|
|
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Match two CCWs located after PSW and eight filler bytes.
|
|
|
|
* From libmagic and arch/s390/kernel/head.S.
|
|
|
|
*/
|
|
|
|
const uint8_t linux_s390_magic[] = "\x02\x00\x00\x18\x60\x00\x00\x50\x02\x00"
|
|
|
|
"\x00\x68\x60\x00\x00\x50\x40\x40\x40\x40"
|
|
|
|
"\x40\x40\x40\x40";
|
|
|
|
|
|
|
|
static inline bool is_iso_vd_valid(IsoVolDesc *vd)
|
|
|
|
{
|
|
|
|
const uint8_t vol_desc_magic[] = "CD001";
|
|
|
|
|
|
|
|
return !memcmp(&vd->ident[0], vol_desc_magic, 5) &&
|
|
|
|
vd->version == 0x1 &&
|
|
|
|
vd->type <= VOL_DESC_TYPE_PARTITION;
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:13:41 +04:00
|
|
|
/***********************************************************************
|
|
|
|
* IPL an ECKD DASD (CDL or LDL/CMS format)
|
|
|
|
*/
|
|
|
|
|
|
|
|
static unsigned char _bprs[8*1024]; /* guessed "max" ECKD sector size */
|
2015-01-22 15:44:26 +03:00
|
|
|
static const int max_bprs_entries = sizeof(_bprs) / sizeof(ExtEckdBlockPtr);
|
2018-02-23 18:43:14 +03:00
|
|
|
static uint8_t _s2[MAX_SECTOR_SIZE * 3] __attribute__((__aligned__(PAGE_SIZE)));
|
|
|
|
static void *s2_prev_blk = _s2;
|
|
|
|
static void *s2_cur_blk = _s2 + MAX_SECTOR_SIZE;
|
|
|
|
static void *s2_next_blk = _s2 + MAX_SECTOR_SIZE * 2;
|
2014-05-19 22:13:41 +04:00
|
|
|
|
2014-05-19 22:14:41 +04:00
|
|
|
static inline void verify_boot_info(BootInfo *bip)
|
|
|
|
{
|
2015-11-23 17:11:55 +03:00
|
|
|
IPL_assert(magic_match(bip->magic, ZIPL_MAGIC), "No zIPL sig in BootInfo");
|
2014-05-19 22:14:41 +04:00
|
|
|
IPL_assert(bip->version == BOOT_INFO_VERSION, "Wrong zIPL version");
|
|
|
|
IPL_assert(bip->bp_type == BOOT_INFO_BP_TYPE_IPL, "DASD is not for IPL");
|
|
|
|
IPL_assert(bip->dev_type == BOOT_INFO_DEV_TYPE_ECKD, "DASD is not ECKD");
|
|
|
|
IPL_assert(bip->flags == BOOT_INFO_FLAGS_ARCH, "Not for this arch");
|
|
|
|
IPL_assert(block_size_ok(bip->bp.ipl.bm_ptr.eckd.bptr.size),
|
|
|
|
"Bad block size in zIPL section of the 1st record.");
|
|
|
|
}
|
|
|
|
|
2018-02-23 18:43:08 +03:00
|
|
|
static block_number_t eckd_block_num(EckdCHS *chs)
|
2014-05-19 22:13:41 +04:00
|
|
|
{
|
2014-08-29 13:01:39 +04:00
|
|
|
const uint64_t sectors = virtio_get_sectors();
|
|
|
|
const uint64_t heads = virtio_get_heads();
|
2018-02-23 18:43:08 +03:00
|
|
|
const uint64_t cylinder = chs->cylinder
|
|
|
|
+ ((chs->head & 0xfff0) << 12);
|
|
|
|
const uint64_t head = chs->head & 0x000f;
|
2014-08-29 13:01:39 +04:00
|
|
|
const block_number_t block = sectors * heads * cylinder
|
|
|
|
+ sectors * head
|
2018-02-23 18:43:08 +03:00
|
|
|
+ chs->sector
|
2014-08-29 13:01:39 +04:00
|
|
|
- 1; /* block nr starts with zero */
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool eckd_valid_address(BootMapPointer *p)
|
|
|
|
{
|
2018-02-23 18:43:08 +03:00
|
|
|
const uint64_t head = p->eckd.chs.head & 0x000f;
|
2014-05-19 22:13:41 +04:00
|
|
|
|
|
|
|
if (head >= virtio_get_heads()
|
2018-02-23 18:43:08 +03:00
|
|
|
|| p->eckd.chs.sector > virtio_get_sectors()
|
|
|
|
|| p->eckd.chs.sector <= 0) {
|
2014-05-19 22:13:41 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-29 13:01:39 +04:00
|
|
|
if (!virtio_guessed_disk_nature() &&
|
2018-02-23 18:43:08 +03:00
|
|
|
eckd_block_num(&p->eckd.chs) >= virtio_get_blocks()) {
|
2014-05-19 22:13:41 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static block_number_t load_eckd_segments(block_number_t blk, uint64_t *address)
|
|
|
|
{
|
|
|
|
block_number_t block_nr;
|
|
|
|
int j, rc;
|
|
|
|
BootMapPointer *bprs = (void *)_bprs;
|
|
|
|
bool more_data;
|
|
|
|
|
|
|
|
memset(_bprs, FREE_SPACE_FILLER, sizeof(_bprs));
|
|
|
|
read_block(blk, bprs, "BPRS read failed");
|
|
|
|
|
|
|
|
do {
|
|
|
|
more_data = false;
|
|
|
|
for (j = 0;; j++) {
|
2018-02-23 18:43:08 +03:00
|
|
|
block_nr = eckd_block_num(&bprs[j].xeckd.bptr.chs);
|
2014-05-19 22:13:41 +04:00
|
|
|
if (is_null_block_number(block_nr)) { /* end of chunk */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we need the updated blockno for the next indirect entry
|
|
|
|
* in the chain, but don't want to advance address
|
|
|
|
*/
|
|
|
|
if (j == (max_bprs_entries - 1)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
IPL_assert(block_size_ok(bprs[j].xeckd.bptr.size),
|
|
|
|
"bad chunk block size");
|
|
|
|
IPL_assert(eckd_valid_address(&bprs[j]), "bad chunk ECKD addr");
|
|
|
|
|
|
|
|
if ((bprs[j].xeckd.bptr.count == 0) && unused_space(&(bprs[j+1]),
|
|
|
|
sizeof(EckdBlockPtr))) {
|
|
|
|
/* This is a "continue" pointer.
|
|
|
|
* This ptr should be the last one in the current
|
|
|
|
* script section.
|
|
|
|
* I.e. the next ptr must point to the unused memory area
|
|
|
|
*/
|
|
|
|
memset(_bprs, FREE_SPACE_FILLER, sizeof(_bprs));
|
|
|
|
read_block(block_nr, bprs, "BPRS continuation read failed");
|
|
|
|
more_data = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load (count+1) blocks of code at (block_nr)
|
|
|
|
* to memory (address).
|
|
|
|
*/
|
|
|
|
rc = virtio_read_many(block_nr, (void *)(*address),
|
|
|
|
bprs[j].xeckd.bptr.count+1);
|
|
|
|
IPL_assert(rc == 0, "code chunk read failed");
|
|
|
|
|
|
|
|
*address += (bprs[j].xeckd.bptr.count+1) * virtio_get_block_size();
|
|
|
|
}
|
|
|
|
} while (more_data);
|
|
|
|
return block_nr;
|
|
|
|
}
|
|
|
|
|
2018-02-23 18:43:14 +03:00
|
|
|
static bool find_zipl_boot_menu_banner(int *offset)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Menu banner starts with "zIPL" */
|
2020-09-24 11:59:24 +03:00
|
|
|
for (i = 0; i <= virtio_get_block_size() - 4; i++) {
|
2018-02-23 18:43:14 +03:00
|
|
|
if (magic_match(s2_cur_blk + i, ZIPL_MAGIC_EBCDIC)) {
|
|
|
|
*offset = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int eckd_get_boot_menu_index(block_number_t s1b_block_nr)
|
|
|
|
{
|
|
|
|
block_number_t cur_block_nr;
|
|
|
|
block_number_t prev_block_nr = 0;
|
|
|
|
block_number_t next_block_nr = 0;
|
|
|
|
EckdStage1b *s1b = (void *)sec;
|
|
|
|
int banner_offset;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Get Stage1b data */
|
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
|
|
|
read_block(s1b_block_nr, s1b, "Cannot read stage1b boot loader");
|
|
|
|
|
|
|
|
memset(_s2, FREE_SPACE_FILLER, sizeof(_s2));
|
|
|
|
|
|
|
|
/* Get Stage2 data */
|
|
|
|
for (i = 0; i < STAGE2_BLK_CNT_MAX; i++) {
|
|
|
|
cur_block_nr = eckd_block_num(&s1b->seek[i].chs);
|
|
|
|
|
2020-09-24 11:59:25 +03:00
|
|
|
if (!cur_block_nr || is_null_block_number(cur_block_nr)) {
|
2018-02-23 18:43:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
read_block(cur_block_nr, s2_cur_blk, "Cannot read stage2 boot loader");
|
|
|
|
|
|
|
|
if (find_zipl_boot_menu_banner(&banner_offset)) {
|
|
|
|
/*
|
|
|
|
* Load the adjacent blocks to account for the
|
|
|
|
* possibility of menu data spanning multiple blocks.
|
|
|
|
*/
|
|
|
|
if (prev_block_nr) {
|
|
|
|
read_block(prev_block_nr, s2_prev_blk,
|
|
|
|
"Cannot read stage2 boot loader");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i + 1 < STAGE2_BLK_CNT_MAX) {
|
|
|
|
next_block_nr = eckd_block_num(&s1b->seek[i + 1].chs);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (next_block_nr) {
|
|
|
|
read_block(next_block_nr, s2_next_blk,
|
|
|
|
"Cannot read stage2 boot loader");
|
|
|
|
}
|
|
|
|
|
|
|
|
return menu_get_zipl_boot_index(s2_cur_blk + banner_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_block_nr = cur_block_nr;
|
|
|
|
}
|
|
|
|
|
|
|
|
sclp_print("No zipl boot menu data found. Booting default entry.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void run_eckd_boot_script(block_number_t bmt_block_nr,
|
|
|
|
block_number_t s1b_block_nr)
|
2014-05-19 22:13:41 +04:00
|
|
|
{
|
|
|
|
int i;
|
2016-04-18 14:45:32 +03:00
|
|
|
unsigned int loadparm = get_loadparm_index();
|
2014-05-19 22:13:41 +04:00
|
|
|
block_number_t block_nr;
|
|
|
|
uint64_t address;
|
2018-02-23 18:43:07 +03:00
|
|
|
BootMapTable *bmt = (void *)sec;
|
2014-05-19 22:13:41 +04:00
|
|
|
BootMapScript *bms = (void *)sec;
|
|
|
|
|
2018-02-23 18:43:14 +03:00
|
|
|
if (menu_is_enabled_zipl()) {
|
|
|
|
loadparm = eckd_get_boot_menu_index(s1b_block_nr);
|
|
|
|
}
|
|
|
|
|
2016-04-18 14:45:32 +03:00
|
|
|
debug_print_int("loadparm", loadparm);
|
2018-04-16 19:56:07 +03:00
|
|
|
IPL_assert(loadparm < MAX_BOOT_ENTRIES, "loadparm value greater than"
|
2016-04-18 14:45:32 +03:00
|
|
|
" maximum number of boot entries allowed");
|
|
|
|
|
2014-05-19 22:13:41 +04:00
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
2018-02-23 18:43:07 +03:00
|
|
|
read_block(bmt_block_nr, sec, "Cannot read Boot Map Table");
|
2014-05-19 22:13:41 +04:00
|
|
|
|
2018-02-23 18:43:08 +03:00
|
|
|
block_nr = eckd_block_num(&bmt->entry[loadparm].xeckd.bptr.chs);
|
2018-02-23 18:43:07 +03:00
|
|
|
IPL_assert(block_nr != -1, "Cannot find Boot Map Table Entry");
|
2014-05-19 22:13:41 +04:00
|
|
|
|
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
|
|
|
read_block(block_nr, sec, "Cannot read Boot Map Script");
|
|
|
|
|
2019-04-29 16:09:41 +03:00
|
|
|
for (i = 0; bms->entry[i].type == BOOT_SCRIPT_LOAD ||
|
|
|
|
bms->entry[i].type == BOOT_SCRIPT_SIGNATURE; i++) {
|
|
|
|
|
|
|
|
/* We don't support secure boot yet, so we skip signature entries */
|
|
|
|
if (bms->entry[i].type == BOOT_SCRIPT_SIGNATURE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:13:41 +04:00
|
|
|
address = bms->entry[i].address.load_address;
|
2018-02-23 18:43:08 +03:00
|
|
|
block_nr = eckd_block_num(&bms->entry[i].blkptr.xeckd.bptr.chs);
|
2014-05-19 22:13:41 +04:00
|
|
|
|
|
|
|
do {
|
|
|
|
block_nr = load_eckd_segments(block_nr, &address);
|
|
|
|
} while (block_nr != -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
IPL_assert(bms->entry[i].type == BOOT_SCRIPT_EXEC,
|
|
|
|
"Unknown script entry type");
|
2020-10-06 12:42:48 +03:00
|
|
|
write_reset_psw(bms->entry[i].address.load_address); /* no return */
|
|
|
|
jump_to_IPL_code(0); /* no return */
|
2014-05-19 22:13:41 +04:00
|
|
|
}
|
|
|
|
|
2014-05-19 22:14:41 +04:00
|
|
|
static void ipl_eckd_cdl(void)
|
2014-05-19 22:13:41 +04:00
|
|
|
{
|
|
|
|
XEckdMbr *mbr;
|
2018-02-23 18:43:09 +03:00
|
|
|
EckdCdlIpl2 *ipl2 = (void *)sec;
|
2014-05-19 22:13:41 +04:00
|
|
|
IplVolumeLabel *vlbl = (void *)sec;
|
2018-02-23 18:43:14 +03:00
|
|
|
block_number_t bmt_block_nr, s1b_block_nr;
|
2014-05-19 22:13:41 +04:00
|
|
|
|
|
|
|
/* we have just read the block #0 and recognized it as "IPL1" */
|
2014-05-19 22:14:41 +04:00
|
|
|
sclp_print("CDL\n");
|
2014-05-19 22:13:41 +04:00
|
|
|
|
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
|
|
|
read_block(1, ipl2, "Cannot read IPL2 record at block 1");
|
|
|
|
|
2018-02-23 18:43:09 +03:00
|
|
|
mbr = &ipl2->mbr;
|
2020-07-28 19:14:50 +03:00
|
|
|
if (!magic_match(mbr, ZIPL_MAGIC)) {
|
|
|
|
sclp_print("No zIPL section in IPL2 record.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!block_size_ok(mbr->blockptr.xeckd.bptr.size)) {
|
|
|
|
sclp_print("Bad block size in zIPL section of IPL2 record.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!mbr->dev_type == DEV_TYPE_ECKD) {
|
|
|
|
sclp_print("Non-ECKD device type in zIPL section of IPL2 record.\n");
|
|
|
|
return;
|
|
|
|
}
|
2014-05-19 22:13:41 +04:00
|
|
|
|
2018-02-23 18:43:07 +03:00
|
|
|
/* save pointer to Boot Map Table */
|
2018-02-23 18:43:08 +03:00
|
|
|
bmt_block_nr = eckd_block_num(&mbr->blockptr.xeckd.bptr.chs);
|
2014-05-19 22:13:41 +04:00
|
|
|
|
2018-02-23 18:43:14 +03:00
|
|
|
/* save pointer to Stage1b Data */
|
|
|
|
s1b_block_nr = eckd_block_num(&ipl2->stage1.seek[0].chs);
|
|
|
|
|
2014-05-19 22:13:41 +04:00
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
|
|
|
read_block(2, vlbl, "Cannot read Volume Label at block 2");
|
2020-07-28 19:14:50 +03:00
|
|
|
if (!magic_match(vlbl->key, VOL1_MAGIC)) {
|
|
|
|
sclp_print("Invalid magic of volume label block.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!magic_match(vlbl->f.key, VOL1_MAGIC)) {
|
|
|
|
sclp_print("Invalid magic of volser block.\n");
|
|
|
|
return;
|
|
|
|
}
|
2014-05-19 22:13:41 +04:00
|
|
|
print_volser(vlbl->f.volser);
|
|
|
|
|
2018-02-23 18:43:14 +03:00
|
|
|
run_eckd_boot_script(bmt_block_nr, s1b_block_nr);
|
2014-05-19 22:13:41 +04:00
|
|
|
/* no return */
|
|
|
|
}
|
|
|
|
|
2014-08-29 13:01:40 +04:00
|
|
|
static void print_eckd_ldl_msg(ECKD_IPL_mode_t mode)
|
2014-05-19 22:14:41 +04:00
|
|
|
{
|
|
|
|
LDL_VTOC *vlbl = (void *)sec; /* already read, 3rd block */
|
|
|
|
char msg[4] = { '?', '.', '\n', '\0' };
|
|
|
|
|
|
|
|
sclp_print((mode == ECKD_CMS) ? "CMS" : "LDL");
|
|
|
|
sclp_print(" version ");
|
|
|
|
switch (vlbl->LDL_version) {
|
|
|
|
case LDL1_VERSION:
|
|
|
|
msg[0] = '1';
|
|
|
|
break;
|
|
|
|
case LDL2_VERSION:
|
|
|
|
msg[0] = '2';
|
|
|
|
break;
|
|
|
|
default:
|
2020-06-24 10:52:23 +03:00
|
|
|
msg[0] = ebc2asc[vlbl->LDL_version];
|
2014-05-19 22:14:41 +04:00
|
|
|
msg[1] = '?';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sclp_print(msg);
|
|
|
|
print_volser(vlbl->volser);
|
2014-08-29 13:01:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ipl_eckd_ldl(ECKD_IPL_mode_t mode)
|
|
|
|
{
|
2018-02-23 18:43:14 +03:00
|
|
|
block_number_t bmt_block_nr, s1b_block_nr;
|
2018-02-23 18:43:09 +03:00
|
|
|
EckdLdlIpl1 *ipl1 = (void *)sec;
|
2014-08-29 13:01:40 +04:00
|
|
|
|
|
|
|
if (mode != ECKD_LDL_UNLABELED) {
|
|
|
|
print_eckd_ldl_msg(mode);
|
|
|
|
}
|
2014-05-19 22:14:41 +04:00
|
|
|
|
|
|
|
/* DO NOT read BootMap pointer (only one, xECKD) at block #2 */
|
|
|
|
|
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
2014-08-29 13:01:40 +04:00
|
|
|
read_block(0, sec, "Cannot read block 0 to grab boot info.");
|
|
|
|
if (mode == ECKD_LDL_UNLABELED) {
|
2018-02-23 18:43:09 +03:00
|
|
|
if (!magic_match(ipl1->bip.magic, ZIPL_MAGIC)) {
|
2014-08-29 13:01:40 +04:00
|
|
|
return; /* not applicable layout */
|
|
|
|
}
|
|
|
|
sclp_print("unlabeled LDL.\n");
|
|
|
|
}
|
2018-02-23 18:43:09 +03:00
|
|
|
verify_boot_info(&ipl1->bip);
|
2014-05-19 22:14:41 +04:00
|
|
|
|
2018-02-23 18:43:07 +03:00
|
|
|
/* save pointer to Boot Map Table */
|
2018-02-23 18:43:09 +03:00
|
|
|
bmt_block_nr = eckd_block_num(&ipl1->bip.bp.ipl.bm_ptr.eckd.bptr.chs);
|
2018-02-23 18:43:07 +03:00
|
|
|
|
2018-02-23 18:43:14 +03:00
|
|
|
/* save pointer to Stage1b Data */
|
|
|
|
s1b_block_nr = eckd_block_num(&ipl1->stage1.seek[0].chs);
|
|
|
|
|
|
|
|
run_eckd_boot_script(bmt_block_nr, s1b_block_nr);
|
2014-05-19 22:14:41 +04:00
|
|
|
/* no return */
|
|
|
|
}
|
|
|
|
|
2014-08-29 13:01:38 +04:00
|
|
|
static void print_eckd_msg(void)
|
|
|
|
{
|
|
|
|
char msg[] = "Using ECKD scheme (block size *****), ";
|
|
|
|
char *p = &msg[34], *q = &msg[30];
|
|
|
|
int n = virtio_get_block_size();
|
|
|
|
|
|
|
|
/* Fill in the block size and show up the message */
|
|
|
|
if (n > 0 && n <= 99999) {
|
|
|
|
while (n) {
|
|
|
|
*p-- = '0' + (n % 10);
|
|
|
|
n /= 10;
|
|
|
|
}
|
|
|
|
while (p >= q) {
|
|
|
|
*p-- = ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sclp_print(msg);
|
|
|
|
}
|
|
|
|
|
2015-10-30 19:28:48 +03:00
|
|
|
static void ipl_eckd(void)
|
|
|
|
{
|
2018-02-23 18:43:07 +03:00
|
|
|
XEckdMbr *mbr = (void *)sec;
|
2015-10-30 19:28:48 +03:00
|
|
|
LDL_VTOC *vlbl = (void *)sec;
|
|
|
|
|
|
|
|
print_eckd_msg();
|
|
|
|
|
|
|
|
/* Grab the MBR again */
|
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
|
|
|
read_block(0, mbr, "Cannot read block 0 on DASD");
|
|
|
|
|
|
|
|
if (magic_match(mbr->magic, IPL1_MAGIC)) {
|
2020-07-28 19:14:50 +03:00
|
|
|
ipl_eckd_cdl(); /* only returns in case of error */
|
|
|
|
return;
|
2015-10-30 19:28:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* LDL/CMS? */
|
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
|
|
|
read_block(2, vlbl, "Cannot read block 2");
|
|
|
|
|
|
|
|
if (magic_match(vlbl->magic, CMS1_MAGIC)) {
|
|
|
|
ipl_eckd_ldl(ECKD_CMS); /* no return */
|
|
|
|
}
|
|
|
|
if (magic_match(vlbl->magic, LNX1_MAGIC)) {
|
|
|
|
ipl_eckd_ldl(ECKD_LDL); /* no return */
|
|
|
|
}
|
|
|
|
|
|
|
|
ipl_eckd_ldl(ECKD_LDL_UNLABELED); /* it still may return */
|
|
|
|
/*
|
|
|
|
* Ok, it is not a LDL by any means.
|
|
|
|
* It still might be a CDL with zero record keys for IPL1 and IPL2
|
|
|
|
*/
|
|
|
|
ipl_eckd_cdl();
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:12:43 +04:00
|
|
|
/***********************************************************************
|
|
|
|
* IPL a SCSI disk
|
|
|
|
*/
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2014-05-19 22:11:07 +04:00
|
|
|
static void zipl_load_segment(ComponentEntry *entry)
|
2013-04-22 23:02:49 +04:00
|
|
|
{
|
2014-05-19 22:10:27 +04:00
|
|
|
const int max_entries = (MAX_SECTOR_SIZE / sizeof(ScsiBlockPtr));
|
2014-05-19 22:08:54 +04:00
|
|
|
ScsiBlockPtr *bprs = (void *)sec;
|
2014-06-18 16:16:46 +04:00
|
|
|
const int bprs_size = sizeof(sec);
|
2014-05-19 22:09:50 +04:00
|
|
|
block_number_t blockno;
|
2014-05-19 22:12:43 +04:00
|
|
|
uint64_t address;
|
2013-04-22 23:02:49 +04:00
|
|
|
int i;
|
2014-05-19 22:12:43 +04:00
|
|
|
char err_msg[] = "zIPL failed to read BPRS at 0xZZZZZZZZZZZZZZZZ";
|
|
|
|
char *blk_no = &err_msg[30]; /* where to print blockno in (those ZZs) */
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
blockno = entry->data.blockno;
|
2020-10-06 12:42:46 +03:00
|
|
|
address = entry->compdat.load_addr;
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
debug_print_int("loading segment at block", blockno);
|
|
|
|
debug_print_int("addr", address);
|
|
|
|
|
|
|
|
do {
|
2014-06-18 16:16:46 +04:00
|
|
|
memset(bprs, FREE_SPACE_FILLER, bprs_size);
|
2014-05-19 22:12:43 +04:00
|
|
|
fill_hex_val(blk_no, &blockno, sizeof(blockno));
|
|
|
|
read_block(blockno, bprs, err_msg);
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
for (i = 0;; i++) {
|
2014-05-19 22:12:43 +04:00
|
|
|
uint64_t *cur_desc = (void *)&bprs[i];
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
blockno = bprs[i].blockno;
|
2014-05-19 22:05:40 +04:00
|
|
|
if (!blockno) {
|
2013-04-22 23:02:49 +04:00
|
|
|
break;
|
2014-05-19 22:05:40 +04:00
|
|
|
}
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
/* we need the updated blockno for the next indirect entry in the
|
|
|
|
chain, but don't want to advance address */
|
2014-05-19 22:05:40 +04:00
|
|
|
if (i == (max_entries - 1)) {
|
2013-04-22 23:02:49 +04:00
|
|
|
break;
|
2014-05-19 22:05:40 +04:00
|
|
|
}
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2014-06-18 16:16:46 +04:00
|
|
|
if (bprs[i].blockct == 0 && unused_space(&bprs[i + 1],
|
2014-05-19 22:08:54 +04:00
|
|
|
sizeof(ScsiBlockPtr))) {
|
2014-06-18 16:16:46 +04:00
|
|
|
/* This is a "continue" pointer.
|
|
|
|
* This ptr is the last one in the current script section.
|
|
|
|
* I.e. the next ptr must point to the unused memory area.
|
|
|
|
* The blockno is not zero, so the upper loop must continue
|
|
|
|
* reading next section of BPRS.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
2013-04-22 23:02:49 +04:00
|
|
|
address = virtio_load_direct(cur_desc[0], cur_desc[1], 0,
|
2014-05-19 22:05:40 +04:00
|
|
|
(void *)address);
|
2014-05-19 22:12:43 +04:00
|
|
|
IPL_assert(address != -1, "zIPL load segment failed");
|
2013-04-22 23:02:49 +04:00
|
|
|
}
|
|
|
|
} while (blockno);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Run a zipl program */
|
2014-05-19 22:11:07 +04:00
|
|
|
static void zipl_run(ScsiBlockPtr *pte)
|
2013-04-22 23:02:49 +04:00
|
|
|
{
|
2014-05-19 22:08:54 +04:00
|
|
|
ComponentHeader *header;
|
|
|
|
ComponentEntry *entry;
|
2014-05-19 22:10:27 +04:00
|
|
|
uint8_t tmp_sec[MAX_SECTOR_SIZE];
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2014-05-19 22:12:43 +04:00
|
|
|
read_block(pte->blockno, tmp_sec, "Cannot read header");
|
2014-05-19 22:08:54 +04:00
|
|
|
header = (ComponentHeader *)tmp_sec;
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2015-11-23 17:11:55 +03:00
|
|
|
IPL_assert(magic_match(tmp_sec, ZIPL_MAGIC), "No zIPL magic in header");
|
2014-05-19 22:12:43 +04:00
|
|
|
IPL_assert(header->type == ZIPL_COMP_HEADER_IPL, "Bad header type");
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
dputs("start loading images\n");
|
|
|
|
|
|
|
|
/* Load image(s) into RAM */
|
2014-05-19 22:08:54 +04:00
|
|
|
entry = (ComponentEntry *)(&header[1]);
|
2019-04-29 16:09:41 +03:00
|
|
|
while (entry->component_type == ZIPL_COMP_ENTRY_LOAD ||
|
|
|
|
entry->component_type == ZIPL_COMP_ENTRY_SIGNATURE) {
|
|
|
|
|
|
|
|
/* We don't support secure boot yet, so we skip signature entries */
|
|
|
|
if (entry->component_type == ZIPL_COMP_ENTRY_SIGNATURE) {
|
|
|
|
entry++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:11:07 +04:00
|
|
|
zipl_load_segment(entry);
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
entry++;
|
|
|
|
|
2014-05-19 22:11:07 +04:00
|
|
|
IPL_assert((uint8_t *)(&entry[1]) <= (tmp_sec + MAX_SECTOR_SIZE),
|
2014-05-19 22:12:43 +04:00
|
|
|
"Wrong entry value");
|
2013-04-22 23:02:49 +04:00
|
|
|
}
|
|
|
|
|
2014-05-19 22:12:43 +04:00
|
|
|
IPL_assert(entry->component_type == ZIPL_COMP_ENTRY_EXEC, "No EXEC entry");
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
/* should not return */
|
2020-10-06 12:42:48 +03:00
|
|
|
write_reset_psw(entry->compdat.load_psw);
|
|
|
|
jump_to_IPL_code(0);
|
2013-04-22 23:02:49 +04:00
|
|
|
}
|
|
|
|
|
2014-05-19 22:12:43 +04:00
|
|
|
static void ipl_scsi(void)
|
2013-04-22 23:02:49 +04:00
|
|
|
{
|
2014-05-19 22:08:54 +04:00
|
|
|
ScsiMbr *mbr = (void *)sec;
|
2013-04-22 23:02:49 +04:00
|
|
|
int program_table_entries = 0;
|
2018-02-23 18:43:07 +03:00
|
|
|
BootMapTable *prog_table = (void *)sec;
|
2016-04-18 14:45:31 +03:00
|
|
|
unsigned int loadparm = get_loadparm_index();
|
2018-04-16 19:56:10 +03:00
|
|
|
bool valid_entries[MAX_BOOT_ENTRIES] = {false};
|
|
|
|
size_t i;
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2015-10-30 19:28:48 +03:00
|
|
|
/* Grab the MBR */
|
|
|
|
memset(sec, FREE_SPACE_FILLER, sizeof(sec));
|
|
|
|
read_block(0, mbr, "Cannot read block 0");
|
|
|
|
|
|
|
|
if (!magic_match(mbr->magic, ZIPL_MAGIC)) {
|
|
|
|
return;
|
|
|
|
}
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2014-05-19 22:12:43 +04:00
|
|
|
sclp_print("Using SCSI scheme.\n");
|
2015-09-17 13:41:36 +03:00
|
|
|
debug_print_int("MBR Version", mbr->version_id);
|
|
|
|
IPL_check(mbr->version_id == 1,
|
|
|
|
"Unknown MBR layout version, assuming version 1");
|
2018-02-23 18:43:07 +03:00
|
|
|
debug_print_int("program table", mbr->pt.blockno);
|
|
|
|
IPL_assert(mbr->pt.blockno, "No Program Table");
|
2013-04-22 23:02:49 +04:00
|
|
|
|
|
|
|
/* Parse the program table */
|
2018-02-23 18:43:07 +03:00
|
|
|
read_block(mbr->pt.blockno, sec, "Error reading Program Table");
|
2015-11-23 17:11:55 +03:00
|
|
|
IPL_assert(magic_match(sec, ZIPL_MAGIC), "No zIPL magic in PT");
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2018-04-16 19:56:10 +03:00
|
|
|
for (i = 0; i < MAX_BOOT_ENTRIES; i++) {
|
|
|
|
if (prog_table->entry[i].scsi.blockno) {
|
|
|
|
valid_entries[i] = true;
|
|
|
|
program_table_entries++;
|
2013-04-22 23:02:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
debug_print_int("program table entries", program_table_entries);
|
2014-05-19 22:12:43 +04:00
|
|
|
IPL_assert(program_table_entries != 0, "Empty Program Table");
|
2013-04-22 23:02:49 +04:00
|
|
|
|
2018-02-23 18:43:19 +03:00
|
|
|
if (menu_is_enabled_enum()) {
|
2018-04-16 19:56:10 +03:00
|
|
|
loadparm = menu_get_enum_boot_index(valid_entries);
|
2018-02-23 18:43:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-23 18:43:07 +03:00
|
|
|
debug_print_int("loadparm", loadparm);
|
2018-04-16 19:56:07 +03:00
|
|
|
IPL_assert(loadparm < MAX_BOOT_ENTRIES, "loadparm value greater than"
|
2018-02-23 18:43:07 +03:00
|
|
|
" maximum number of boot entries allowed");
|
|
|
|
|
|
|
|
zipl_run(&prog_table->entry[loadparm].scsi); /* no return */
|
2013-04-22 23:02:49 +04:00
|
|
|
}
|
2014-05-19 22:12:43 +04:00
|
|
|
|
2015-10-12 18:50:20 +03:00
|
|
|
/***********************************************************************
|
|
|
|
* IPL El Torito ISO9660 image or DVD
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool is_iso_bc_entry_compatible(IsoBcSection *s)
|
|
|
|
{
|
2015-10-12 18:50:20 +03:00
|
|
|
uint8_t *magic_sec = (uint8_t *)(sec + ISO_SECTOR_SIZE);
|
|
|
|
|
|
|
|
if (s->unused || !s->sector_count) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
read_iso_sector(bswap32(s->load_rba), magic_sec,
|
|
|
|
"Failed to read image sector 0");
|
|
|
|
|
|
|
|
/* Checking bytes 8 - 32 for S390 Linux magic */
|
2018-02-23 18:43:10 +03:00
|
|
|
return !memcmp(magic_sec + 8, linux_s390_magic, 24);
|
2015-10-12 18:50:20 +03:00
|
|
|
}
|
|
|
|
|
2015-10-12 18:50:20 +03:00
|
|
|
/* Location of the current sector of the directory */
|
|
|
|
static uint32_t sec_loc[ISO9660_MAX_DIR_DEPTH];
|
|
|
|
/* Offset in the current sector of the directory */
|
|
|
|
static uint32_t sec_offset[ISO9660_MAX_DIR_DEPTH];
|
|
|
|
/* Remained directory space in bytes */
|
|
|
|
static uint32_t dir_rem[ISO9660_MAX_DIR_DEPTH];
|
|
|
|
|
|
|
|
static inline uint32_t iso_get_file_size(uint32_t load_rba)
|
|
|
|
{
|
|
|
|
IsoVolDesc *vd = (IsoVolDesc *)sec;
|
|
|
|
IsoDirHdr *cur_record = &vd->vd.primary.rootdir;
|
|
|
|
uint8_t *temp = sec + ISO_SECTOR_SIZE;
|
|
|
|
int level = 0;
|
|
|
|
|
|
|
|
read_iso_sector(ISO_PRIMARY_VD_SECTOR, sec,
|
|
|
|
"Failed to read ISO primary descriptor");
|
|
|
|
sec_loc[0] = iso_733_to_u32(cur_record->ext_loc);
|
|
|
|
dir_rem[0] = 0;
|
|
|
|
sec_offset[0] = 0;
|
|
|
|
|
|
|
|
while (level >= 0) {
|
|
|
|
IPL_assert(sec_offset[level] <= ISO_SECTOR_SIZE,
|
|
|
|
"Directory tree structure violation");
|
|
|
|
|
|
|
|
cur_record = (IsoDirHdr *)(temp + sec_offset[level]);
|
|
|
|
|
|
|
|
if (sec_offset[level] == 0) {
|
|
|
|
read_iso_sector(sec_loc[level], temp,
|
|
|
|
"Failed to read ISO directory");
|
|
|
|
if (dir_rem[level] == 0) {
|
|
|
|
/* Skip self and parent records */
|
|
|
|
dir_rem[level] = iso_733_to_u32(cur_record->data_len) -
|
|
|
|
cur_record->dr_len;
|
|
|
|
sec_offset[level] += cur_record->dr_len;
|
|
|
|
|
|
|
|
cur_record = (IsoDirHdr *)(temp + sec_offset[level]);
|
|
|
|
dir_rem[level] -= cur_record->dr_len;
|
|
|
|
sec_offset[level] += cur_record->dr_len;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cur_record->dr_len || sec_offset[level] == ISO_SECTOR_SIZE) {
|
|
|
|
/* Zero-padding and/or the end of current sector */
|
|
|
|
dir_rem[level] -= ISO_SECTOR_SIZE - sec_offset[level];
|
|
|
|
sec_offset[level] = 0;
|
|
|
|
sec_loc[level]++;
|
|
|
|
} else {
|
|
|
|
/* The directory record is valid */
|
|
|
|
if (load_rba == iso_733_to_u32(cur_record->ext_loc)) {
|
|
|
|
return iso_733_to_u32(cur_record->data_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
dir_rem[level] -= cur_record->dr_len;
|
|
|
|
sec_offset[level] += cur_record->dr_len;
|
|
|
|
|
|
|
|
if (cur_record->file_flags & 0x2) {
|
|
|
|
/* Subdirectory */
|
|
|
|
if (level == ISO9660_MAX_DIR_DEPTH - 1) {
|
|
|
|
sclp_print("ISO-9660 directory depth limit exceeded\n");
|
|
|
|
} else {
|
|
|
|
level++;
|
|
|
|
sec_loc[level] = iso_733_to_u32(cur_record->ext_loc);
|
|
|
|
sec_offset[level] = 0;
|
|
|
|
dir_rem[level] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir_rem[level] == 0) {
|
|
|
|
/* Nothing remaining */
|
|
|
|
level--;
|
|
|
|
read_iso_sector(sec_loc[level], temp,
|
|
|
|
"Failed to read ISO directory");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-12 18:50:20 +03:00
|
|
|
static void load_iso_bc_entry(IsoBcSection *load)
|
|
|
|
{
|
|
|
|
IsoBcSection s = *load;
|
|
|
|
/*
|
|
|
|
* According to spec, extent for each file
|
|
|
|
* is padded and ISO_SECTOR_SIZE bytes aligned
|
|
|
|
*/
|
|
|
|
uint32_t blks_to_load = bswap16(s.sector_count) >> ET_SECTOR_SHIFT;
|
2015-10-12 18:50:20 +03:00
|
|
|
uint32_t real_size = iso_get_file_size(bswap32(s.load_rba));
|
|
|
|
|
|
|
|
if (real_size) {
|
|
|
|
/* Round up blocks to load */
|
|
|
|
blks_to_load = (real_size + ISO_SECTOR_SIZE - 1) / ISO_SECTOR_SIZE;
|
|
|
|
sclp_print("ISO boot image size verified\n");
|
|
|
|
} else {
|
|
|
|
sclp_print("ISO boot image size could not be verified\n");
|
|
|
|
}
|
2015-10-12 18:50:20 +03:00
|
|
|
|
|
|
|
read_iso_boot_image(bswap32(s.load_rba),
|
|
|
|
(void *)((uint64_t)bswap16(s.load_segment)),
|
|
|
|
blks_to_load);
|
|
|
|
|
2018-04-20 12:30:42 +03:00
|
|
|
jump_to_low_kernel();
|
2015-10-12 18:50:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t find_iso_bc(void)
|
|
|
|
{
|
|
|
|
IsoVolDesc *vd = (IsoVolDesc *)sec;
|
|
|
|
uint32_t block_num = ISO_PRIMARY_VD_SECTOR;
|
|
|
|
|
|
|
|
if (virtio_read_many(block_num++, sec, 1)) {
|
|
|
|
/* If primary vd cannot be read, there is no boot catalog */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (is_iso_vd_valid(vd) && vd->type != VOL_DESC_TERMINATOR) {
|
|
|
|
if (vd->type == VOL_DESC_TYPE_BOOT) {
|
|
|
|
IsoVdElTorito *et = &vd->vd.boot;
|
|
|
|
|
2018-02-23 18:43:10 +03:00
|
|
|
if (!memcmp(&et->el_torito[0], el_torito_magic, 32)) {
|
2015-10-12 18:50:20 +03:00
|
|
|
return bswap32(et->bc_offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
read_iso_sector(block_num++, sec,
|
|
|
|
"Failed to read ISO volume descriptor");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IsoBcSection *find_iso_bc_entry(void)
|
|
|
|
{
|
|
|
|
IsoBcEntry *e = (IsoBcEntry *)sec;
|
|
|
|
uint32_t offset = find_iso_bc();
|
|
|
|
int i;
|
2016-04-18 14:45:36 +03:00
|
|
|
unsigned int loadparm = get_loadparm_index();
|
2015-10-12 18:50:20 +03:00
|
|
|
|
|
|
|
if (!offset) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
read_iso_sector(offset, sec, "Failed to read El Torito boot catalog");
|
|
|
|
|
|
|
|
if (!is_iso_bc_valid(e)) {
|
|
|
|
/* The validation entry is mandatory */
|
2015-09-17 13:47:27 +03:00
|
|
|
panic("No valid boot catalog found!\n");
|
2015-10-12 18:50:20 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Each entry has 32 bytes size, so one sector cannot contain > 64 entries.
|
|
|
|
* We consider only boot catalogs with no more than 64 entries.
|
|
|
|
*/
|
|
|
|
for (i = 1; i < ISO_BC_ENTRY_PER_SECTOR; i++) {
|
|
|
|
if (e[i].id == ISO_BC_BOOTABLE_SECTION) {
|
|
|
|
if (is_iso_bc_entry_compatible(&e[i].body.sect)) {
|
2016-04-18 14:45:36 +03:00
|
|
|
if (loadparm <= 1) {
|
|
|
|
/* found, default, or unspecified */
|
|
|
|
return &e[i].body.sect;
|
|
|
|
}
|
|
|
|
loadparm--;
|
2015-10-12 18:50:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-17 13:47:27 +03:00
|
|
|
panic("No suitable boot entry found on ISO-9660 media!\n");
|
2015-10-12 18:50:20 +03:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ipl_iso_el_torito(void)
|
|
|
|
{
|
|
|
|
IsoBcSection *s = find_iso_bc_entry();
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
load_iso_bc_entry(s);
|
|
|
|
/* no return */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-19 22:12:43 +04:00
|
|
|
/***********************************************************************
|
2015-10-30 19:28:48 +03:00
|
|
|
* Bus specific IPL sequences
|
2014-05-19 22:12:43 +04:00
|
|
|
*/
|
|
|
|
|
2015-10-30 19:28:48 +03:00
|
|
|
static void zipl_load_vblk(void)
|
2014-05-19 22:12:43 +04:00
|
|
|
{
|
2015-10-12 18:50:20 +03:00
|
|
|
if (virtio_guessed_disk_nature()) {
|
|
|
|
virtio_assume_iso9660();
|
|
|
|
}
|
|
|
|
ipl_iso_el_torito();
|
|
|
|
|
2014-05-19 22:14:41 +04:00
|
|
|
if (virtio_guessed_disk_nature()) {
|
|
|
|
sclp_print("Using guessed DASD geometry.\n");
|
|
|
|
virtio_assume_eckd();
|
|
|
|
}
|
2015-10-30 19:28:48 +03:00
|
|
|
ipl_eckd();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zipl_load_vscsi(void)
|
|
|
|
{
|
|
|
|
if (virtio_get_block_size() == VIRTIO_ISO_BLOCK_SIZE) {
|
|
|
|
/* Is it an ISO image in non-CD drive? */
|
|
|
|
ipl_iso_el_torito();
|
2014-05-19 22:14:41 +04:00
|
|
|
}
|
|
|
|
|
2015-10-30 19:28:48 +03:00
|
|
|
sclp_print("Using guessed DASD geometry.\n");
|
|
|
|
virtio_assume_eckd();
|
|
|
|
ipl_eckd();
|
|
|
|
}
|
2014-05-19 22:14:41 +04:00
|
|
|
|
2015-10-30 19:28:48 +03:00
|
|
|
/***********************************************************************
|
|
|
|
* IPL starts here
|
|
|
|
*/
|
|
|
|
|
|
|
|
void zipl_load(void)
|
|
|
|
{
|
2016-11-02 00:34:00 +03:00
|
|
|
VDev *vdev = virtio_get_device();
|
|
|
|
|
|
|
|
if (vdev->is_cdrom) {
|
2015-10-30 19:28:48 +03:00
|
|
|
ipl_iso_el_torito();
|
|
|
|
panic("\n! Cannot IPL this ISO image !\n");
|
2014-05-19 22:13:41 +04:00
|
|
|
}
|
2014-05-19 22:12:43 +04:00
|
|
|
|
2016-11-02 00:34:00 +03:00
|
|
|
if (virtio_get_device_type() == VIRTIO_ID_NET) {
|
|
|
|
jump_to_IPL_code(vdev->netboot_start_addr);
|
|
|
|
}
|
|
|
|
|
2015-10-30 19:28:48 +03:00
|
|
|
ipl_scsi();
|
|
|
|
|
|
|
|
switch (virtio_get_device_type()) {
|
|
|
|
case VIRTIO_ID_BLOCK:
|
|
|
|
zipl_load_vblk();
|
|
|
|
break;
|
|
|
|
case VIRTIO_ID_SCSI:
|
|
|
|
zipl_load_vscsi();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic("\n! Unknown IPL device type !\n");
|
|
|
|
}
|
2014-08-29 13:01:40 +04:00
|
|
|
|
2020-07-28 19:14:50 +03:00
|
|
|
sclp_print("zIPL load failed.\n");
|
2014-05-19 22:12:43 +04:00
|
|
|
}
|