All of lore.kernel.org
 help / color / mirror / Atom feed
From: DuanZhenzhong <zhenzhong.duan@oracle.com>
To: xen-devel <xen-devel@lists.xen.org>
Cc: Joe Jin <joe.jin@oracle.com>
Subject: rombios: add support for special CHS layout (spt=32)
Date: Fri, 07 Dec 2012 11:25:33 +0800	[thread overview]
Message-ID: <50C161AD.9020803@oracle.com> (raw)

When booting up windows VM which converted by dd scsi disk, it fails with
"Error Loading Operating System", root cause is rombios doesn't simulate disk's
logical CHS properly. Real bios uses spt=32 here.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
--- a/tools/firmware/rombios/rombios.c	2011-12-09 00:50:28.000000000 +0800
+++ b/tools/firmware/rombios/rombios.c	2012-11-20 09:42:50.000000000 +0800
@@ -2674,6 +2674,8 @@ void ata_detect( )
       Bit32u sectors_low, sectors_high;
       Bit16u cylinders, heads, spt, blksize;
       Bit8u  translation, removable, mode;
+      Bit8u i;
+      Bit8u *p;
 
       // default mode to PIO16
       mode = ATA_MODE_PIO16;
@@ -2738,14 +2740,32 @@ void ata_detect( )
         case ATA_TRANSLATION_NONE:
           break;
         case ATA_TRANSLATION_LBA:
-          spt = 63;
-          sectors_low /= 63;
-          heads = sectors_low / 1024;
-          if (heads>128) heads = 255;
-          else if (heads>64) heads = 128;
-          else if (heads>32) heads = 64;
-          else if (heads>16) heads = 32;
-          else heads=16;
+          spt = heads = 0;
+          if (ata_cmd_data_in(device,ATA_CMD_READ_SECTORS, 1, 0, 0, 1, 0L, 0L, get_SS(),buffer) !=0 )
+            BX_PANIC("ata-detect: Failed to read first sector\n");
+          for(i=0; i<4; i++) {
+            p = buffer + 0x1be + i * 16;
+            if (read_dword(get_SS(), p+12) && read_byte(get_SS(), p+5)) {
+              /* We make the assumption that the partition terminates on
+                 a cylinder boundary */
+              heads = read_byte(get_SS(), p+5) + 1;
+              spt = read_byte(get_SS(), p+6) & 63;
+              if (spt != 0)
+                break;
+            }
+          }
+          if (spt == 32) {
+            sectors_low /= spt;
+          } else {
+            spt = 63;
+            sectors_low /= 63;
+            heads = sectors_low / 1024;
+            if (heads>128) heads = 255;
+            else if (heads>64) heads = 128;
+            else if (heads>32) heads = 64;
+            else if (heads>16) heads = 32;
+            else heads=16;
+          }
           cylinders = sectors_low / heads;
           break;
         case ATA_TRANSLATION_RECHS:

             reply	other threads:[~2012-12-07  3:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  3:25 DuanZhenzhong [this message]
2012-12-07 11:27 ` rombios: add support for special CHS layout (spt=32) Jan Beulich
2012-12-10  2:15   ` Zhenzhong Duan

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=50C161AD.9020803@oracle.com \
    --to=zhenzhong.duan@oracle.com \
    --cc=joe.jin@oracle.com \
    --cc=xen-devel@lists.xen.org \
    /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.