* rombios: add support for special CHS layout (spt=32)
@ 2012-12-07 3:25 DuanZhenzhong
2012-12-07 11:27 ` Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: DuanZhenzhong @ 2012-12-07 3:25 UTC (permalink / raw)
To: xen-devel; +Cc: Joe Jin
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:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: rombios: add support for special CHS layout (spt=32)
2012-12-07 3:25 rombios: add support for special CHS layout (spt=32) DuanZhenzhong
@ 2012-12-07 11:27 ` Jan Beulich
2012-12-10 2:15 ` Zhenzhong Duan
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2012-12-07 11:27 UTC (permalink / raw)
To: DuanZhenzhong; +Cc: Joe Jin, xen-devel
>>> On 07.12.12 at 04:25, DuanZhenzhong <zhenzhong.duan@oracle.com> wrote:
> 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 */
Which certainly isn't a generally correct assumption, so I strongly
recommend against basing any decisions on that.
Jan
> + 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:
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: rombios: add support for special CHS layout (spt=32)
2012-12-07 11:27 ` Jan Beulich
@ 2012-12-10 2:15 ` Zhenzhong Duan
0 siblings, 0 replies; 3+ messages in thread
From: Zhenzhong Duan @ 2012-12-10 2:15 UTC (permalink / raw)
To: Jan Beulich; +Cc: Joe Jin, xen-devel
On 2012-12-07 19:27, Jan Beulich wrote:
>>>> On 07.12.12 at 04:25, DuanZhenzhong <zhenzhong.duan@oracle.com> wrote:
>> 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 */
> Which certainly isn't a generally correct assumption, so I strongly
> recommend against basing any decisions on that.
>
> Jan
Thanks for comment. Are we the first facing this bug?
Is there any workaround for this issue?
zduan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-10 2:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-07 3:25 rombios: add support for special CHS layout (spt=32) DuanZhenzhong
2012-12-07 11:27 ` Jan Beulich
2012-12-10 2:15 ` Zhenzhong Duan
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.