aboutsummaryrefslogtreecommitdiffstats
path: root/src/block.c
diff options
context:
space:
mode:
authorSam Eiderman <shmuel.eiderman@oracle.com>2019-06-12 12:37:04 +0300
committerGerd Hoffmann <kraxel@redhat.com>2019-11-06 10:56:00 +0100
commit9caa19be0e534c687081fbdfcd301406e728c98c (patch)
tree588e9234ba792d7aedda3a5442032f9a22d773f4 /src/block.c
parentcb56f61c109985ad71078b1fb2e65bd4d6ed1a59 (diff)
downloadseabios-9caa19be0e534c687081fbdfcd301406e728c98c.tar.gz
geometry: Apply LCHS values for boot devices
Boot devices which use overriden LCHS values are: * ata * ahci * scsi * esp * lsi * megasas * mpt * pvscsi * virtio * virtio-blk We use these values in get_translation() and setup_translation() by introducing a new translation type: "TRANSLATION_MACHINE". We treat this translation as TRANSLATION_NONE in fill_ata_edd(), although this does not really matter since now the translation between physical and logical geometry does not exist. Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> Message-Id: <20190612093704.47175-6-shmuel.eiderman@oracle.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'src/block.c')
-rw-r--r--src/block.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/block.c b/src/block.c
index f73ec18c..ca23a83a 100644
--- a/src/block.c
+++ b/src/block.c
@@ -69,9 +69,17 @@ int create_bounce_buf(void)
* Disk geometry translation
****************************************************************/
+static int
+overriden_lchs_supplied(struct drive_s *drive)
+{
+ return drive->lchs.cylinder || drive->lchs.head || drive->lchs.sector;
+}
+
static u8
get_translation(struct drive_s *drive)
{
+ if (overriden_lchs_supplied(drive))
+ return TRANSLATION_MACHINE;
u8 type = drive->type;
if (CONFIG_QEMU && type == DTYPE_ATA) {
// Emulators pass in the translation info via nvram.
@@ -159,6 +167,16 @@ setup_translation(struct drive_s *drive)
break;
}
break;
+ case TRANSLATION_MACHINE:
+ desc = "overriden";
+ cylinders = drive->lchs.cylinder;
+ heads = drive->lchs.head;
+ if (heads > 255)
+ heads = 255;
+ spt = drive->lchs.sector;
+ if (spt > 63)
+ spt = 63;
+ break;
}
// clip to 1024 cylinders in lchs
if (cylinders > 1024)
@@ -423,7 +441,8 @@ fill_ata_edd(struct segoff_s edd, struct drive_s *drive_gf)
u16 options = 0;
if (GET_GLOBALFLAT(drive_gf->type) == DTYPE_ATA) {
u8 translation = GET_GLOBALFLAT(drive_gf->translation);
- if (translation != TRANSLATION_NONE) {
+ if ((translation != TRANSLATION_NONE) &&
+ (translation != TRANSLATION_MACHINE)) {
options |= 1<<3; // CHS translation
if (translation == TRANSLATION_LBA)
options |= 1<<9;