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/hd-geometry.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'hw/hd-geometry.c') diff --git a/hw/hd-geometry.c b/hw/hd-geometry.c index 74678a656..1cdb9fb75 100644 --- a/hw/hd-geometry.c +++ b/hw/hd-geometry.c @@ -125,7 +125,7 @@ void hd_geometry_guess(BlockDriverState *bs, if (guess_disk_lchs(bs, &cylinders, &heads, &secs) < 0) { /* no LCHS guess: use a standard physical disk geometry */ guess_chs_for_size(bs, pcyls, pheads, psecs); - translation = BIOS_ATA_TRANSLATION_AUTO; + translation = hd_bios_chs_auto_trans(*pcyls, *pheads, *psecs); } else if (heads > 16) { /* LCHS guess with heads > 16 means that a BIOS LBA translation was active, so a standard physical disk @@ -148,3 +148,10 @@ void hd_geometry_guess(BlockDriverState *bs, } trace_hd_geometry_guess(bs, *pcyls, *pheads, *psecs, translation); } + +int hd_bios_chs_auto_trans(uint32_t cyls, uint32_t heads, uint32_t secs) +{ + return cyls <= 1024 && heads <= 16 && secs <= 63 + ? BIOS_ATA_TRANSLATION_NONE + : BIOS_ATA_TRANSLATION_LBA; +} -- cgit v1.2.3