aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2010-02-17 01:07:36 -0500
committerKevin O'Connor <kevin@koconnor.net>2010-02-17 01:07:36 -0500
commitd2d1de07cec679f51e8e013308916a5854e6ed86 (patch)
tree34d18cd1345b9e0606c86f020b55d8e5e3e62af9
parent76977b2d8d6b54e40a3d2668372d942b9332d86f (diff)
downloadseabios-d2d1de07cec679f51e8e013308916a5854e6ed86.tar.gz
Don't require a valid physical cylinders/heads/spt for logical mapping.
Modern drives don't provide a "physical" chs report - try to detect that and force an LBA mapping in that case. Also, don't require setup_translation be called only on ATA drives.
-rw-r--r--src/block.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/block.c b/src/block.c
index 63aa368d..365053eb 100644
--- a/src/block.c
+++ b/src/block.c
@@ -40,10 +40,15 @@ get_translation(struct drive_s *drive_g)
return translation;
}
- // On COREBOOT, use a heuristic to determine translation type.
+ // Otherwise use a heuristic to determine translation type.
u16 heads = GET_GLOBAL(drive_g->pchs.heads);
u16 cylinders = GET_GLOBAL(drive_g->pchs.cylinders);
u16 spt = GET_GLOBAL(drive_g->pchs.spt);
+ u64 sectors = GET_GLOBAL(drive_g->sectors);
+ u64 psectors = (u64)heads * cylinders * spt;
+ if (!heads || !cylinders || !spt || psectors > sectors)
+ // pchs doesn't look valid - use LBA.
+ return TRANSLATION_LBA;
if (cylinders <= 1024 && heads <= 16 && spt <= 63)
return TRANSLATION_NONE;
@@ -58,9 +63,6 @@ setup_translation(struct drive_s *drive_g)
u8 translation = get_translation(drive_g);
SET_GLOBAL(drive_g->translation, translation);
- u8 ataid = GET_GLOBAL(drive_g->cntl_id);
- u8 channel = ataid / 2;
- u8 slave = ataid % 2;
u16 heads = GET_GLOBAL(drive_g->pchs.heads);
u16 cylinders = GET_GLOBAL(drive_g->pchs.cylinders);
u16 spt = GET_GLOBAL(drive_g->pchs.spt);
@@ -120,11 +122,12 @@ setup_translation(struct drive_s *drive_g)
// clip to 1024 cylinders in lchs
if (cylinders > 1024)
cylinders = 1024;
- dprintf(1, "ata%d-%d: PCHS=%u/%d/%d translation=%s LCHS=%d/%d/%d\n"
- , channel, slave
+ dprintf(1, "drive %p: PCHS=%u/%d/%d translation=%s LCHS=%d/%d/%d s=%d\n"
+ , drive_g
, drive_g->pchs.cylinders, drive_g->pchs.heads, drive_g->pchs.spt
, desc
- , cylinders, heads, spt);
+ , cylinders, heads, spt
+ , (u32)sectors);
SET_GLOBAL(drive_g->lchs.heads, heads);
SET_GLOBAL(drive_g->lchs.cylinders, cylinders);