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_HOST". 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: <20190626123816.8907-6-shmuel.eiderman@oracle.com>
This commit is contained in:
parent
d49496f94e
commit
c9ba5276e3
18
src/block.c
18
src/block.c
|
@ -69,9 +69,18 @@ int create_bounce_buf(void)
|
||||||
* Disk geometry translation
|
* Disk geometry translation
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
static int
|
||||||
|
host_lchs_supplied(struct drive_s *drive)
|
||||||
|
{
|
||||||
|
return (drive->lchs.head <= 255 &&
|
||||||
|
drive->lchs.sector > 0 && drive->lchs.sector <= 63);
|
||||||
|
}
|
||||||
|
|
||||||
static u8
|
static u8
|
||||||
get_translation(struct drive_s *drive)
|
get_translation(struct drive_s *drive)
|
||||||
{
|
{
|
||||||
|
if (host_lchs_supplied(drive))
|
||||||
|
return TRANSLATION_HOST;
|
||||||
u8 type = drive->type;
|
u8 type = drive->type;
|
||||||
if (CONFIG_QEMU && type == DTYPE_ATA) {
|
if (CONFIG_QEMU && type == DTYPE_ATA) {
|
||||||
// Emulators pass in the translation info via nvram.
|
// Emulators pass in the translation info via nvram.
|
||||||
|
@ -159,6 +168,12 @@ setup_translation(struct drive_s *drive)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TRANSLATION_HOST:
|
||||||
|
desc = "host-supplied";
|
||||||
|
cylinders = drive->lchs.cylinder;
|
||||||
|
heads = drive->lchs.head;
|
||||||
|
spt = drive->lchs.sector;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// clip to 1024 cylinders in lchs
|
// clip to 1024 cylinders in lchs
|
||||||
if (cylinders > 1024)
|
if (cylinders > 1024)
|
||||||
|
@ -423,7 +438,8 @@ fill_ata_edd(struct segoff_s edd, struct drive_s *drive_gf)
|
||||||
u16 options = 0;
|
u16 options = 0;
|
||||||
if (GET_GLOBALFLAT(drive_gf->type) == DTYPE_ATA) {
|
if (GET_GLOBALFLAT(drive_gf->type) == DTYPE_ATA) {
|
||||||
u8 translation = GET_GLOBALFLAT(drive_gf->translation);
|
u8 translation = GET_GLOBALFLAT(drive_gf->translation);
|
||||||
if (translation != TRANSLATION_NONE) {
|
if ((translation != TRANSLATION_NONE) &&
|
||||||
|
(translation != TRANSLATION_HOST)) {
|
||||||
options |= 1<<3; // CHS translation
|
options |= 1<<3; // CHS translation
|
||||||
if (translation == TRANSLATION_LBA)
|
if (translation == TRANSLATION_LBA)
|
||||||
options |= 1<<9;
|
options |= 1<<9;
|
||||||
|
|
|
@ -90,6 +90,7 @@ struct drive_s {
|
||||||
#define TRANSLATION_LBA 1
|
#define TRANSLATION_LBA 1
|
||||||
#define TRANSLATION_LARGE 2
|
#define TRANSLATION_LARGE 2
|
||||||
#define TRANSLATION_RECHS 3
|
#define TRANSLATION_RECHS 3
|
||||||
|
#define TRANSLATION_HOST 4
|
||||||
|
|
||||||
#define EXTTYPE_FLOPPY 0
|
#define EXTTYPE_FLOPPY 0
|
||||||
#define EXTTYPE_HD 1
|
#define EXTTYPE_HD 1
|
||||||
|
|
|
@ -594,6 +594,7 @@ static int ahci_port_setup(struct ahci_port_s *port)
|
||||||
, ata_extract_version(buffer));
|
, ata_extract_version(buffer));
|
||||||
port->prio = bootprio_find_ata_device(ctrl->pci_tmp, pnr, 0);
|
port->prio = bootprio_find_ata_device(ctrl->pci_tmp, pnr, 0);
|
||||||
}
|
}
|
||||||
|
boot_lchs_find_ata_device(ctrl->pci_tmp, pnr, 0, &(port->drive.lchs));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -755,6 +755,10 @@ init_drive_atapi(struct atadrive_s *dummy, u16 *buffer)
|
||||||
int prio = bootprio_find_ata_device(adrive->chan_gf->pci_tmp,
|
int prio = bootprio_find_ata_device(adrive->chan_gf->pci_tmp,
|
||||||
adrive->chan_gf->chanid,
|
adrive->chan_gf->chanid,
|
||||||
adrive->slave);
|
adrive->slave);
|
||||||
|
boot_lchs_find_ata_device(adrive->chan_gf->pci_tmp,
|
||||||
|
adrive->chan_gf->chanid,
|
||||||
|
adrive->slave,
|
||||||
|
&(adrive->drive.lchs));
|
||||||
boot_add_cd(&adrive->drive, desc, prio);
|
boot_add_cd(&adrive->drive, desc, prio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,6 +809,10 @@ init_drive_ata(struct atadrive_s *dummy, u16 *buffer)
|
||||||
int prio = bootprio_find_ata_device(adrive->chan_gf->pci_tmp,
|
int prio = bootprio_find_ata_device(adrive->chan_gf->pci_tmp,
|
||||||
adrive->chan_gf->chanid,
|
adrive->chan_gf->chanid,
|
||||||
adrive->slave);
|
adrive->slave);
|
||||||
|
boot_lchs_find_ata_device(adrive->chan_gf->pci_tmp,
|
||||||
|
adrive->chan_gf->chanid,
|
||||||
|
adrive->slave,
|
||||||
|
&(adrive->drive.lchs));
|
||||||
// Register with bcv system.
|
// Register with bcv system.
|
||||||
boot_add_hd(&adrive->drive, desc, prio);
|
boot_add_hd(&adrive->drive, desc, prio);
|
||||||
|
|
||||||
|
|
|
@ -181,6 +181,8 @@ esp_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv)
|
||||||
|
|
||||||
char *name = znprintf(MAXDESCSIZE, "esp %pP %d:%d",
|
char *name = znprintf(MAXDESCSIZE, "esp %pP %d:%d",
|
||||||
llun->pci, llun->target, llun->lun);
|
llun->pci, llun->target, llun->lun);
|
||||||
|
boot_lchs_find_scsi_device(llun->pci, llun->target, llun->lun,
|
||||||
|
&(llun->drive.lchs));
|
||||||
int prio = bootprio_find_scsi_device(llun->pci, llun->target, llun->lun);
|
int prio = bootprio_find_scsi_device(llun->pci, llun->target, llun->lun);
|
||||||
int ret = scsi_drive_setup(&llun->drive, name, prio);
|
int ret = scsi_drive_setup(&llun->drive, name, prio);
|
||||||
free(name);
|
free(name);
|
||||||
|
|
|
@ -158,6 +158,8 @@ lsi_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv)
|
||||||
lsi_scsi_init_lun(llun, tmpl_llun->pci, tmpl_llun->iobase,
|
lsi_scsi_init_lun(llun, tmpl_llun->pci, tmpl_llun->iobase,
|
||||||
tmpl_llun->target, lun);
|
tmpl_llun->target, lun);
|
||||||
|
|
||||||
|
boot_lchs_find_scsi_device(llun->pci, llun->target, llun->lun,
|
||||||
|
&(llun->drive.lchs));
|
||||||
char *name = znprintf(MAXDESCSIZE, "lsi %pP %d:%d",
|
char *name = znprintf(MAXDESCSIZE, "lsi %pP %d:%d",
|
||||||
llun->pci, llun->target, llun->lun);
|
llun->pci, llun->target, llun->lun);
|
||||||
int prio = bootprio_find_scsi_device(llun->pci, llun->target, llun->lun);
|
int prio = bootprio_find_scsi_device(llun->pci, llun->target, llun->lun);
|
||||||
|
|
|
@ -225,6 +225,7 @@ megasas_add_lun(struct pci_device *pci, u32 iobase, u8 target, u8 lun)
|
||||||
free(mlun);
|
free(mlun);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
boot_lchs_find_scsi_device(pci, target, lun, &(mlun->drive.lchs));
|
||||||
name = znprintf(MAXDESCSIZE, "MegaRAID SAS (PCI %pP) LD %d:%d"
|
name = znprintf(MAXDESCSIZE, "MegaRAID SAS (PCI %pP) LD %d:%d"
|
||||||
, pci, target, lun);
|
, pci, target, lun);
|
||||||
prio = bootprio_find_scsi_device(pci, target, lun);
|
prio = bootprio_find_scsi_device(pci, target, lun);
|
||||||
|
|
|
@ -221,6 +221,8 @@ mpt_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv)
|
||||||
mpt_scsi_init_lun(llun, tmpl_llun->pci, tmpl_llun->iobase,
|
mpt_scsi_init_lun(llun, tmpl_llun->pci, tmpl_llun->iobase,
|
||||||
tmpl_llun->target, lun);
|
tmpl_llun->target, lun);
|
||||||
|
|
||||||
|
boot_lchs_find_scsi_device(llun->pci, llun->target, llun->lun,
|
||||||
|
&(llun->drive.lchs));
|
||||||
char *name = znprintf(MAXDESCSIZE, "mpt %pP %d:%d",
|
char *name = znprintf(MAXDESCSIZE, "mpt %pP %d:%d",
|
||||||
llun->pci, llun->target, llun->lun);
|
llun->pci, llun->target, llun->lun);
|
||||||
int prio = bootprio_find_scsi_device(llun->pci, llun->target, llun->lun);
|
int prio = bootprio_find_scsi_device(llun->pci, llun->target, llun->lun);
|
||||||
|
|
|
@ -273,6 +273,7 @@ pvscsi_add_lun(struct pci_device *pci, void *iobase,
|
||||||
plun->iobase = iobase;
|
plun->iobase = iobase;
|
||||||
plun->ring_dsc = ring_dsc;
|
plun->ring_dsc = ring_dsc;
|
||||||
|
|
||||||
|
boot_lchs_find_scsi_device(pci, target, lun, &(plun->drive.lchs));
|
||||||
char *name = znprintf(MAXDESCSIZE, "pvscsi %pP %d:%d", pci, target, lun);
|
char *name = znprintf(MAXDESCSIZE, "pvscsi %pP %d:%d", pci, target, lun);
|
||||||
int prio = bootprio_find_scsi_device(pci, target, lun);
|
int prio = bootprio_find_scsi_device(pci, target, lun);
|
||||||
int ret = scsi_drive_setup(&plun->drive, name, prio);
|
int ret = scsi_drive_setup(&plun->drive, name, prio);
|
||||||
|
|
|
@ -183,6 +183,8 @@ init_virtio_blk(void *data)
|
||||||
|
|
||||||
status |= VIRTIO_CONFIG_S_DRIVER_OK;
|
status |= VIRTIO_CONFIG_S_DRIVER_OK;
|
||||||
vp_set_status(&vdrive->vp, status);
|
vp_set_status(&vdrive->vp, status);
|
||||||
|
|
||||||
|
boot_lchs_find_pci_device(pci, &vdrive->drive.lchs);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
|
@ -121,6 +121,8 @@ virtio_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv)
|
||||||
virtio_scsi_init_lun(vlun, tmpl_vlun->pci, tmpl_vlun->vp, tmpl_vlun->vq,
|
virtio_scsi_init_lun(vlun, tmpl_vlun->pci, tmpl_vlun->vp, tmpl_vlun->vq,
|
||||||
tmpl_vlun->target, lun);
|
tmpl_vlun->target, lun);
|
||||||
|
|
||||||
|
boot_lchs_find_scsi_device(vlun->pci, vlun->target, vlun->lun,
|
||||||
|
&(vlun->drive.lchs));
|
||||||
int prio = bootprio_find_scsi_device(vlun->pci, vlun->target, vlun->lun);
|
int prio = bootprio_find_scsi_device(vlun->pci, vlun->target, vlun->lun);
|
||||||
int ret = scsi_drive_setup(&vlun->drive, "virtio-scsi", prio);
|
int ret = scsi_drive_setup(&vlun->drive, "virtio-scsi", prio);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
Loading…
Reference in New Issue