From 2adc99b277ab05877ef847bddde45346378f561a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 10 Jul 2012 11:12:53 +0200 Subject: 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 Signed-off-by: Kevin Wolf --- hw/pc.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'hw/pc.c') diff --git a/hw/pc.c b/hw/pc.c index 77b12b4..598267a 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -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); -- cgit v1.1