All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Collin L. Walling" <walling@linux.vnet.ibm.com>
To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org
Cc: borntraeger@de.ibm.com, frankja@linux.vnet.ibm.com,
	cohuck@redhat.com, thuth@redhat.com, david@redhat.com,
	alifm@linux.vnet.ibm.com, eblake@redhat.com,
	mihajlov@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH v8 02/13] s390-ccw: refactor eckd_block_num to use CHS
Date: Wed, 21 Feb 2018 14:35:41 -0500	[thread overview]
Message-ID: <1519241752-28083-3-git-send-email-walling@linux.vnet.ibm.com> (raw)
In-Reply-To: <1519241752-28083-1-git-send-email-walling@linux.vnet.ibm.com>

Add new cylinder/head/sector struct. Use it to calculate
eckd block numbers instead of a BootMapPointer (which used
eckd chs anyway).

Signed-off-by: Collin L. Walling <walling@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/bootmap.c | 28 ++++++++++++++--------------
 pc-bios/s390-ccw/bootmap.h |  8 ++++++--
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
index a4eaf24..9534f56 100644
--- a/pc-bios/s390-ccw/bootmap.c
+++ b/pc-bios/s390-ccw/bootmap.c
@@ -95,32 +95,32 @@ static inline void verify_boot_info(BootInfo *bip)
                "Bad block size in zIPL section of the 1st record.");
 }
 
-static block_number_t eckd_block_num(BootMapPointer *p)
+static block_number_t eckd_block_num(EckdCHS *chs)
 {
     const uint64_t sectors = virtio_get_sectors();
     const uint64_t heads = virtio_get_heads();
-    const uint64_t cylinder = p->eckd.cylinder
-                            + ((p->eckd.head & 0xfff0) << 12);
-    const uint64_t head = p->eckd.head & 0x000f;
+    const uint64_t cylinder = chs->cylinder
+                            + ((chs->head & 0xfff0) << 12);
+    const uint64_t head = chs->head & 0x000f;
     const block_number_t block = sectors * heads * cylinder
                                + sectors * head
-                               + p->eckd.sector
+                               + chs->sector
                                - 1; /* block nr starts with zero */
     return block;
 }
 
 static bool eckd_valid_address(BootMapPointer *p)
 {
-    const uint64_t head = p->eckd.head & 0x000f;
+    const uint64_t head = p->eckd.chs.head & 0x000f;
 
     if (head >= virtio_get_heads()
-        ||  p->eckd.sector > virtio_get_sectors()
-        ||  p->eckd.sector <= 0) {
+        ||  p->eckd.chs.sector > virtio_get_sectors()
+        ||  p->eckd.chs.sector <= 0) {
         return false;
     }
 
     if (!virtio_guessed_disk_nature() &&
-        eckd_block_num(p) >= virtio_get_blocks()) {
+        eckd_block_num(&p->eckd.chs) >= virtio_get_blocks()) {
         return false;
     }
 
@@ -140,7 +140,7 @@ static block_number_t load_eckd_segments(block_number_t blk, uint64_t *address)
     do {
         more_data = false;
         for (j = 0;; j++) {
-            block_nr = eckd_block_num((void *)&(bprs[j].xeckd));
+            block_nr = eckd_block_num(&bprs[j].xeckd.bptr.chs);
             if (is_null_block_number(block_nr)) { /* end of chunk */
                 break;
             }
@@ -198,7 +198,7 @@ static void run_eckd_boot_script(block_number_t bmt_block_nr)
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
     read_block(bmt_block_nr, sec, "Cannot read Boot Map Table");
 
-    block_nr = eckd_block_num(&bmt->entry[loadparm]);
+    block_nr = eckd_block_num(&bmt->entry[loadparm].xeckd.bptr.chs);
     IPL_assert(block_nr != -1, "Cannot find Boot Map Table Entry");
 
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
@@ -206,7 +206,7 @@ static void run_eckd_boot_script(block_number_t bmt_block_nr)
 
     for (i = 0; bms->entry[i].type == BOOT_SCRIPT_LOAD; i++) {
         address = bms->entry[i].address.load_address;
-        block_nr = eckd_block_num(&(bms->entry[i].blkptr));
+        block_nr = eckd_block_num(&bms->entry[i].blkptr.xeckd.bptr.chs);
 
         do {
             block_nr = load_eckd_segments(block_nr, &address);
@@ -239,7 +239,7 @@ static void ipl_eckd_cdl(void)
                "Non-ECKD device type in zIPL section of IPL2 record.");
 
     /* save pointer to Boot Map Table */
-    bmt_block_nr = eckd_block_num(&mbr->blockptr);
+    bmt_block_nr = eckd_block_num(&mbr->blockptr.xeckd.bptr.chs);
 
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
     read_block(2, vlbl, "Cannot read Volume Label at block 2");
@@ -300,7 +300,7 @@ static void ipl_eckd_ldl(ECKD_IPL_mode_t mode)
     verify_boot_info(bip);
 
     /* save pointer to Boot Map Table */
-    bmt_block_nr = eckd_block_num((void *)&bip->bp.ipl.bm_ptr.eckd.bptr);
+    bmt_block_nr = eckd_block_num(&bip->bp.ipl.bm_ptr.eckd.bptr.chs);
 
     run_eckd_boot_script(bmt_block_nr);
     /* no return */
diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h
index 486c0f3..b361084 100644
--- a/pc-bios/s390-ccw/bootmap.h
+++ b/pc-bios/s390-ccw/bootmap.h
@@ -32,10 +32,14 @@ typedef struct FbaBlockPtr {
     uint16_t blockct;
 } __attribute__ ((packed)) FbaBlockPtr;
 
-typedef struct EckdBlockPtr {
-    uint16_t cylinder; /* cylinder/head/sector is an address of the block */
+typedef struct EckdCHS {
+    uint16_t cylinder;
     uint16_t head;
     uint8_t sector;
+} __attribute__ ((packed)) EckdCHS;
+
+typedef struct EckdBlockPtr {
+    EckdCHS chs; /* cylinder/head/sector is an address of the block */
     uint16_t size;
     uint8_t count; /* (size_in_blocks-1);
                     * it's 0 for TablePtr, ScriptPtr, and SectionPtr */
-- 
2.7.4

  parent reply	other threads:[~2018-02-21 19:43 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-21 19:35 [Qemu-devel] [PATCH v8 00/13] Interactive Boot Menu for DASD and SCSI Guests on s390x Collin L. Walling
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 01/13] s390-ccw: refactor boot map table code Collin L. Walling
2018-02-21 19:35 ` Collin L. Walling [this message]
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 03/13] s390-ccw: refactor IPL structs Collin L. Walling
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 04/13] s390-ccw: update libc Collin L. Walling
2018-02-22  4:30   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 05/13] s390-ccw: move auxiliary IPL data to separate location Collin L. Walling
2018-02-22  4:40   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-02-22  8:38     ` Viktor Mihajlovski
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 06/13] s390-ccw: parse and set boot menu options Collin L. Walling
2018-02-22  5:32   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 07/13] s390-ccw: set up interactive boot menu parameters Collin L. Walling
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 08/13] s390-ccw: read stage2 boot loader data to find menu Collin L. Walling
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 09/13] s390-ccw: print zipl boot menu Collin L. Walling
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 10/13] s390-ccw: read user input for boot index via the SCLP console Collin L. Walling
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 11/13] s390-ccw: set cp_receive mask only when needed and consume pending service irqs Collin L. Walling
2018-02-22  6:19   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 12/13] s390-ccw: use zipl values when no boot menu options are present Collin L. Walling
2018-02-22  6:27   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-02-21 19:35 ` [Qemu-devel] [PATCH v8 13/13] s390-ccw: interactive boot menu for scsi Collin L. Walling
2018-02-22  6:34   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-02-22 11:51 ` [Qemu-devel] [PATCH v8 00/13] Interactive Boot Menu for DASD and SCSI Guests on s390x Christian Borntraeger
2018-02-22 12:23   ` Viktor Mihajlovski
2018-02-22 15:40     ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2018-02-22 15:44       ` Christian Borntraeger
2018-02-22 16:45         ` Collin L. Walling
2018-02-22 19:40           ` Collin L. Walling
2018-02-23 10:07             ` Thomas Huth
2018-02-23 10:11               ` Christian Borntraeger
2018-02-23 14:57                 ` Collin L. Walling
2018-02-23 14:59                   ` Collin L. Walling
2018-02-23 15:01                   ` Christian Borntraeger
2018-02-22 12:42   ` Thomas Huth
2018-02-23  8:53 ` [Qemu-devel] " Christian Borntraeger
2018-02-23 10:17   ` Thomas Huth
2018-02-23 11:50     ` Viktor Mihajlovski
2018-02-23 13:33       ` Thomas Huth
2018-02-23 15:03         ` Collin L. Walling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1519241752-28083-3-git-send-email-walling@linux.vnet.ibm.com \
    --to=walling@linux.vnet.ibm.com \
    --cc=alifm@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=eblake@redhat.com \
    --cc=frankja@linux.vnet.ibm.com \
    --cc=mihajlov@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.