summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Kagan <rkagan@virtuozzo.com>2017-04-26 17:18:04 +0300
committerKevin O'Connor <kevin@koconnor.net>2017-05-02 19:57:03 -0400
commit3aadef4fd9ce7671c9cc1559c64cb439510856d9 (patch)
tree7448bfd07189bfb8c30801b3de0d7376b38efe23 /src
parent69ebdef9bdb7f0f4f7bd9b5f30ef0bf687d6c918 (diff)
downloadqemu-seabios-3aadef4fd9ce7671c9cc1559c64cb439510856d9.tar.gz
esp-scsi: enumerate luns with REPORT LUNS
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
Diffstat (limited to 'src')
-rw-r--r--src/hw/esp-scsi.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/hw/esp-scsi.c b/src/hw/esp-scsi.c
index d2ba023..57d3832 100644
--- a/src/hw/esp-scsi.c
+++ b/src/hw/esp-scsi.c
@@ -153,14 +153,10 @@ esp_scsi_process_op(struct disk_op_s *op)
return DISK_RET_EBADTRACK;
}
-static int
-esp_scsi_add_lun(struct pci_device *pci, u32 iobase, u8 target, u8 lun)
+static void
+esp_scsi_init_lun(struct esp_lun_s *llun, struct pci_device *pci, u32 iobase,
+ u8 target, u8 lun)
{
- struct esp_lun_s *llun = malloc_fseg(sizeof(*llun));
- if (!llun) {
- warn_noalloc();
- return -1;
- }
memset(llun, 0, sizeof(*llun));
llun->drive.type = DTYPE_ESP_SCSI;
llun->drive.cntl_id = pci->bdf;
@@ -168,9 +164,24 @@ esp_scsi_add_lun(struct pci_device *pci, u32 iobase, u8 target, u8 lun)
llun->target = target;
llun->lun = lun;
llun->iobase = iobase;
+}
+
+static int
+esp_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv)
+{
+ struct esp_lun_s *tmpl_llun =
+ container_of(tmpl_drv, struct esp_lun_s, drive);
+ struct esp_lun_s *llun = malloc_fseg(sizeof(*llun));
+ if (!llun) {
+ warn_noalloc();
+ return -1;
+ }
+ esp_scsi_init_lun(llun, tmpl_llun->pci, tmpl_llun->iobase,
+ tmpl_llun->target, lun);
- char *name = znprintf(MAXDESCSIZE, "esp %pP %d:%d", pci, target, lun);
- int prio = bootprio_find_scsi_device(pci, target, lun);
+ char *name = znprintf(MAXDESCSIZE, "esp %pP %d:%d",
+ 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);
free(name);
if (ret)
@@ -185,7 +196,11 @@ fail:
static void
esp_scsi_scan_target(struct pci_device *pci, u32 iobase, u8 target)
{
- esp_scsi_add_lun(pci, iobase, target, 0);
+ struct esp_lun_s llun0;
+
+ esp_scsi_init_lun(&llun0, pci, iobase, target, 0);
+
+ scsi_rep_luns_scan(&llun0.drive, esp_scsi_add_lun);
}
static void