From patchwork Thu Jun 26 14:30:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 364561 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1BC1F1400F0 for ; Fri, 27 Jun 2014 00:31:32 +1000 (EST) Received: from localhost ([::1]:44972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Ai2-0007x0-9Y for incoming@patchwork.ozlabs.org; Thu, 26 Jun 2014 10:31:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0AhD-0006bf-Hq for qemu-devel@nongnu.org; Thu, 26 Jun 2014 10:30:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0Ah0-0001lK-VQ for qemu-devel@nongnu.org; Thu, 26 Jun 2014 10:30:39 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:46055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0Ah0-0001ky-8R for qemu-devel@nongnu.org; Thu, 26 Jun 2014 10:30:26 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Jun 2014 15:30:25 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 26 Jun 2014 15:30:23 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4BF6C1B08041 for ; Thu, 26 Jun 2014 15:30:55 +0100 (BST) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5QEUMpH28377146 for ; Thu, 26 Jun 2014 14:30:22 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5QEUMxp013521 for ; Thu, 26 Jun 2014 08:30:22 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s5QEUMuH013508; Thu, 26 Jun 2014 08:30:22 -0600 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 1122) id 0537C1224439; Thu, 26 Jun 2014 16:30:22 +0200 (CEST) From: Jens Freimann To: Christian Borntraeger , Alexander Graf , Cornelia Huck Date: Thu, 26 Jun 2014 16:30:06 +0200 Message-Id: <1403793009-54176-8-git-send-email-jfrei@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1403793009-54176-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1403793009-54176-1-git-send-email-jfrei@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14062614-0342-0000-0000-0000003EDE5F X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.111 Cc: "Eugene \(jno\) Dvurechenski" , Jens Freimann , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 07/10] pc-bios/s390-ccw: factor out ipl code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Eugene (jno) Dvurechenski" Move the scsi-disk specific ipl code from zipl_load() into a new function ipl_scsi(). This makes it easier to add ipl routines for other disk types. Signed-off-by: Eugene (jno) Dvurechenski Signed-off-by: Jens Freimann --- pc-bios/s390-ccw/bootmap.c | 82 +++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 9e342c9..992c9aa 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -12,7 +12,9 @@ #include "bootmap.h" #include "virtio.h" +#ifdef DEBUG /* #define DEBUG_FALLBACK */ +#endif #ifdef DEBUG_FALLBACK #define dputs(txt) \ @@ -23,7 +25,7 @@ #endif /* Scratch space */ -static uint8_t sec[SECTOR_SIZE] __attribute__((__aligned__(SECTOR_SIZE))); +static uint8_t sec[SECTOR_SIZE*4] __attribute__((__aligned__(PAGE_SIZE))); typedef struct ResetInfo { uint32_t ipl_mask; @@ -71,19 +73,9 @@ static void jump_to_IPL_code(uint64_t address) virtio_panic("\n! IPL returns !\n"); } -/* Check for ZIPL magic. Returns 0 if not matched. */ -static int zipl_magic(uint8_t *ptr) -{ - uint32_t *p = (void *)ptr; - uint32_t *z = (void *)ZIPL_MAGIC; - - if (*p != *z) { - debug_print_int("invalid magic", *p); - virtio_panic("invalid magic"); - } - - return 1; -} +/*********************************************************************** + * IPL a SCSI disk + */ static void zipl_load_segment(ComponentEntry *entry) { @@ -91,8 +83,10 @@ static void zipl_load_segment(ComponentEntry *entry) ScsiBlockPtr *bprs = (void *)sec; const int bprs_size = sizeof(sec); block_number_t blockno; - long address; + uint64_t address; int i; + char err_msg[] = "zIPL failed to read BPRS at 0xZZZZZZZZZZZZZZZZ"; + char *blk_no = &err_msg[30]; /* where to print blockno in (those ZZs) */ blockno = entry->data.blockno; address = entry->load_address; @@ -102,11 +96,11 @@ static void zipl_load_segment(ComponentEntry *entry) do { memset(bprs, FREE_SPACE_FILLER, bprs_size); - debug_print_int("reading bprs at", blockno); - read_block(blockno, bprs, "zipl_load_segment: cannot read block"); + fill_hex_val(blk_no, &blockno, sizeof(blockno)); + read_block(blockno, bprs, err_msg); for (i = 0;; i++) { - u64 *cur_desc = (void *)&bprs[i]; + uint64_t *cur_desc = (void *)&bprs[i]; blockno = bprs[i].blockno; if (!blockno) { @@ -131,7 +125,7 @@ static void zipl_load_segment(ComponentEntry *entry) } address = virtio_load_direct(cur_desc[0], cur_desc[1], 0, (void *)address); - IPL_assert(address != -1, "zipl_load_segment: wrong IPL address"); + IPL_assert(address != -1, "zIPL load segment failed"); } } while (blockno); } @@ -143,13 +137,11 @@ static void zipl_run(ScsiBlockPtr *pte) ComponentEntry *entry; uint8_t tmp_sec[SECTOR_SIZE]; - virtio_read(pte->blockno, tmp_sec); + read_block(pte->blockno, tmp_sec, "Cannot read header"); header = (ComponentHeader *)tmp_sec; - IPL_assert(zipl_magic(tmp_sec), "zipl_run: zipl_magic"); - - IPL_assert(header->type == ZIPL_COMP_HEADER_IPL, - "zipl_run: wrong header type"); + IPL_assert(magic_match(tmp_sec, ZIPL_MAGIC), "No zIPL magic"); + IPL_assert(header->type == ZIPL_COMP_HEADER_IPL, "Bad header type"); dputs("start loading images\n"); @@ -161,17 +153,16 @@ static void zipl_run(ScsiBlockPtr *pte) entry++; IPL_assert((uint8_t *)(&entry[1]) <= (tmp_sec + SECTOR_SIZE), - "zipl_run: wrong entry size"); + "Wrong entry value"); } - IPL_assert(entry->component_type == ZIPL_COMP_ENTRY_EXEC, - "zipl_run: no EXEC entry"); + IPL_assert(entry->component_type == ZIPL_COMP_ENTRY_EXEC, "No EXEC entry"); /* should not return */ jump_to_IPL_code(entry->load_address); } -void zipl_load(void) +static void ipl_scsi(void) { ScsiMbr *mbr = (void *)sec; uint8_t *ns, *ns_end; @@ -179,20 +170,16 @@ void zipl_load(void) const int pte_len = sizeof(ScsiBlockPtr); ScsiBlockPtr *prog_table_entry; - /* Grab the MBR */ - read_block(0, mbr, "zipl_load: cannot read block 0"); - - dputs("checking magic\n"); - - IPL_assert(zipl_magic(mbr->magic), "zipl_load: zipl_magic 1"); + /* The 0-th block (MBR) was already read into sec[] */ + sclp_print("Using SCSI scheme.\n"); debug_print_int("program table", mbr->blockptr.blockno); /* Parse the program table */ read_block(mbr->blockptr.blockno, sec, - "zipl_load: cannot read program table"); + "Error reading Program Table"); - IPL_assert(zipl_magic(sec), "zipl_load: zipl_magic 2"); + IPL_assert(magic_match(sec, ZIPL_MAGIC), "No zIPL magic"); ns_end = sec + virtio_get_block_size(); for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) { @@ -206,7 +193,7 @@ void zipl_load(void) debug_print_int("program table entries", program_table_entries); - IPL_assert(program_table_entries, "zipl_load: no program table"); + IPL_assert(program_table_entries != 0, "Empty Program Table"); /* Run the default entry */ @@ -214,3 +201,24 @@ void zipl_load(void) zipl_run(prog_table_entry); /* no return */ } + +/*********************************************************************** + * IPL starts here + */ + +void zipl_load(void) +{ + ScsiMbr *mbr = (void *)sec; + + /* Grab the MBR */ + memset(sec, FREE_SPACE_FILLER, sizeof(sec)); + read_block(0, mbr, "Cannot read block 0"); + + dputs("checking magic\n"); + + if (magic_match(mbr->magic, ZIPL_MAGIC)) { + ipl_scsi(); /* no return */ + } + + virtio_panic("\n* invalid MBR magic *\n"); +}