diff options
author | Markus Armbruster <armbru@redhat.com> | 2012-07-10 11:12:53 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-07-17 16:48:32 +0200 |
commit | 2adc99b277ab05877ef847bddde45346378f561a (patch) | |
tree | da0313df8aa57f7ec78584464783689f7a6dae71 /hw/pc.c | |
parent | 4e4e6e319b5508289da0f2966f63c841c832b847 (diff) |
hd-geometry: Compute BIOS CHS translation in one place
Currently, it is split between hd_geometry_guess() and
pc_cmos_init_late(). Confusing. info qtree shows the result of the
former. Also confusing.
Fold the part done in pc_cmos_init_late() into hd_geometry_guess().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/pc.c')
-rw-r--r-- | hw/pc.c | 19 |
1 files changed, 4 insertions, 15 deletions
@@ -290,7 +290,7 @@ static void pc_cmos_init_late(void *opaque) int16_t cylinders; int8_t heads, sectors; int val; - int i; + int i, trans; val = 0; if (ide_get_geometry(arg->idebus[0], 0, @@ -313,20 +313,9 @@ static void pc_cmos_init_late(void *opaque) geometry can be different if a translation is done. */ if (ide_get_geometry(arg->idebus[i / 2], i % 2, &cylinders, &heads, §ors) >= 0) { - int translation = ide_get_bios_chs_trans(arg->idebus[i / 2], - i % 2); - if (translation == BIOS_ATA_TRANSLATION_AUTO) { - if (cylinders <= 1024 && heads <= 16 && sectors <= 63) { - /* No translation. */ - translation = 0; - } else { - /* LBA translation. */ - translation = 1; - } - } else { - translation--; - } - val |= translation << (i * 2); + trans = ide_get_bios_chs_trans(arg->idebus[i / 2], i % 2) - 1; + assert((trans & ~3) == 0); + val |= trans << (i * 2); } } rtc_set_memory(s, 0x39, val); |