[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] rombios: add support for special CHS layout (spt=32)
>>> On 07.12.12 at 04:25, DuanZhenzhong <zhenzhong.duan@xxxxxxxxxx> 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@xxxxxxxxxx> > --- 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@xxxxxxxxxxxxx > http://lists.xen.org/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |