This series updates the generic code so that either "low" memory or the f-segment can be used for storing drive mapping information. It also updates the virtio code to use "low" memory for its allocations. I think there is a good chance this series will, in practice, avoid running out of memory when a large number of virtio drives are available.
There are other ways to tackle this problem (eg, more of the virtio storage could be moved into "high" memory), but I think this approach has the benefit of avoiding a "big bang" patch series.
Comments welcome.
-Kevin
Kevin O'Connor (4): boot: Rename drive_g to drive disk: Don't require the 'struct drive_s' to be in the f-segment block: Rename disk_op_s->drive_gf to drive_fl virtio: Allocate drive_s storage in low memory
src/block.c | 36 ++++----- src/block.h | 2 +- src/boot.c | 16 ++-- src/cdrom.c | 6 +- src/disk.c | 218 +++++++++++++++++++++++++-------------------------- src/hw/ahci.c | 4 +- src/hw/ata.c | 26 +++--- src/hw/blockcmd.c | 10 +-- src/hw/esp-scsi.c | 2 +- src/hw/floppy.c | 20 ++--- src/hw/lsi-scsi.c | 2 +- src/hw/megasas.c | 2 +- src/hw/mpt-scsi.c | 2 +- src/hw/nvme.c | 2 +- src/hw/pvscsi.c | 2 +- src/hw/ramdisk.c | 2 +- src/hw/sdcard.c | 2 +- src/hw/usb-msc.c | 4 +- src/hw/usb-uas.c | 2 +- src/hw/virtio-blk.c | 14 ++-- src/hw/virtio-ring.c | 1 - src/hw/virtio-scsi.c | 5 +- 22 files changed, 189 insertions(+), 191 deletions(-)
The 'struct drive_s' pointer is a 32bit pointer (and boot.c code is only compiled in 32bit mode), so avoid using the "_g" suffix on the pointer.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/boot.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/boot.c b/src/boot.c index 59623fb..83d48f2 100644 --- a/src/boot.c +++ b/src/boot.c @@ -372,24 +372,24 @@ boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio) }
void -boot_add_floppy(struct drive_s *drive_g, const char *desc, int prio) +boot_add_floppy(struct drive_s *drive, const char *desc, int prio) { bootentry_add(IPL_TYPE_FLOPPY, defPrio(prio, DefaultFloppyPrio) - , (u32)drive_g, desc); + , (u32)drive, desc); }
void -boot_add_hd(struct drive_s *drive_g, const char *desc, int prio) +boot_add_hd(struct drive_s *drive, const char *desc, int prio) { bootentry_add(IPL_TYPE_HARDDISK, defPrio(prio, DefaultHDPrio) - , (u32)drive_g, desc); + , (u32)drive, desc); }
void -boot_add_cd(struct drive_s *drive_g, const char *desc, int prio) +boot_add_cd(struct drive_s *drive, const char *desc, int prio) { bootentry_add(IPL_TYPE_CDROM, defPrio(prio, DefaultCDPrio) - , (u32)drive_g, desc); + , (u32)drive, desc); }
// Add a CBFS payload entry @@ -648,13 +648,13 @@ boot_disk(u8 bootdrv, int checksig)
// Boot from a CD-ROM static void -boot_cdrom(struct drive_s *drive_g) +boot_cdrom(struct drive_s *drive) { if (! CONFIG_CDROM_BOOT) return; printf("Booting from DVD/CD...\n");
- int status = cdrom_boot(drive_g); + int status = cdrom_boot(drive); if (status) { printf("Boot failed: Could not read from CDROM (code %04x)\n", status); return;
Allow the 'struct drive_s' drive description structure to be in either the "low" memory segment or the f-segment.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.c | 22 +++++++++++----------- src/disk.c | 10 +++++----- src/hw/blockcmd.c | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/block.c b/src/block.c index d104f6d..8c5fb2d 100644 --- a/src/block.c +++ b/src/block.c @@ -312,12 +312,12 @@ fill_generic_edd(struct segoff_s edd, struct drive_s *drive_gf
// EDD 1.x
- u8 type = GET_GLOBALFLAT(drive_gf->type); - u16 npc = GET_GLOBALFLAT(drive_gf->pchs.cylinder); - u16 nph = GET_GLOBALFLAT(drive_gf->pchs.head); - u16 nps = GET_GLOBALFLAT(drive_gf->pchs.sector); - u64 lba = GET_GLOBALFLAT(drive_gf->sectors); - u16 blksize = GET_GLOBALFLAT(drive_gf->blksize); + u8 type = GET_FLATPTR(drive_gf->type); + u16 npc = GET_FLATPTR(drive_gf->pchs.cylinder); + u16 nph = GET_FLATPTR(drive_gf->pchs.head); + u16 nps = GET_FLATPTR(drive_gf->pchs.sector); + u64 lba = GET_FLATPTR(drive_gf->sectors); + u16 blksize = GET_FLATPTR(drive_gf->blksize);
dprintf(DEBUG_HDL_13, "disk_1348 size=%d t=%d chs=%d,%d,%d lba=%d bs=%d\n" , size, type, npc, nph, nps, (u32)lba, blksize); @@ -469,7 +469,7 @@ fill_ata_edd(struct segoff_s edd, struct drive_s *drive_gf) int noinline fill_edd(struct segoff_s edd, struct drive_s *drive_gf) { - switch (GET_GLOBALFLAT(drive_gf->type)) { + switch (GET_FLATPTR(drive_gf->type)) { case DTYPE_ATA: case DTYPE_ATA_ATAPI: return fill_ata_edd(edd, drive_gf); @@ -477,7 +477,7 @@ fill_edd(struct segoff_s edd, struct drive_s *drive_gf) case DTYPE_VIRTIO_SCSI: return fill_generic_edd( edd, drive_gf, 0xffffffff, EDD_PCI | EDD_SCSI - , edd_pci_path(GET_GLOBALFLAT(drive_gf->cntl_id), 0), 0); + , edd_pci_path(GET_FLATPTR(drive_gf->cntl_id), 0), 0); default: return fill_generic_edd(edd, drive_gf, 0, 0, 0, 0); } @@ -527,7 +527,7 @@ default_process_op(struct disk_op_s *op) static int process_op_both(struct disk_op_s *op) { - switch (GET_GLOBALFLAT(op->drive_gf->type)) { + switch (GET_FLATPTR(op->drive_gf->type)) { case DTYPE_ATA_ATAPI: return ata_atapi_process_op(op); case DTYPE_USB: @@ -585,7 +585,7 @@ static int process_op_16(struct disk_op_s *op) { ASSERT16(); - switch (GET_GLOBALFLAT(op->drive_gf->type)) { + switch (GET_FLATPTR(op->drive_gf->type)) { case DTYPE_FLOPPY: return floppy_process_op(op); case DTYPE_ATA: @@ -608,7 +608,7 @@ process_op(struct disk_op_s *op) , op->count, op->command);
int ret, origcount = op->count; - if (origcount * GET_GLOBALFLAT(op->drive_gf->blksize) > 64*1024) { + if (origcount * GET_FLATPTR(op->drive_gf->blksize) > 64*1024) { op->count = 0; return DISK_RET_EBOUNDARY; } diff --git a/src/disk.c b/src/disk.c index 6e58428..5a4fe9d 100644 --- a/src/disk.c +++ b/src/disk.c @@ -81,9 +81,9 @@ getLCHS(struct drive_s *drive_gf) res.sector = sptcyl & 0x3f; return res; } - res.cylinder = GET_GLOBALFLAT(drive_gf->lchs.cylinder); - res.head = GET_GLOBALFLAT(drive_gf->lchs.head); - res.sector = GET_GLOBALFLAT(drive_gf->lchs.sector); + res.cylinder = GET_FLATPTR(drive_gf->lchs.cylinder); + res.head = GET_FLATPTR(drive_gf->lchs.head); + res.sector = GET_FLATPTR(drive_gf->lchs.sector); return res; }
@@ -168,7 +168,7 @@ extended_access(struct bregs *regs, struct drive_s *drive_gf, u16 command) dop.lba = GET_FARVAR(regs->ds, param_far->lba); dop.command = command; dop.drive_gf = drive_gf; - if (dop.lba >= GET_GLOBALFLAT(drive_gf->sectors)) { + if (dop.lba >= GET_FLATPTR(drive_gf->sectors)) { warn_invalid(regs); disk_ret(regs, DISK_RET_EPARAM); return; @@ -287,7 +287,7 @@ disk_1308(struct bregs *regs, struct drive_s *drive_gf) if (CONFIG_CDROM_EMU && drive_gf == GET_GLOBAL(cdemu_drive_gf)) regs->bx = GET_LOW(CDEmu.media) * 2; else - regs->bx = GET_GLOBALFLAT(drive_gf->floppy_type); + regs->bx = GET_FLATPTR(drive_gf->floppy_type);
// set es & di to point to 11 byte diskette param table in ROM regs->es = SEG_BIOS; diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index 98c06ce..f260dd8 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -5,10 +5,10 @@ // // This file may be distributed under the terms of the GNU LGPLv3 license.
-#include "biosvar.h" // GET_GLOBALFLAT #include "block.h" // struct disk_op_s #include "blockcmd.h" // struct cdb_request_sense #include "byteorder.h" // be32_to_cpu +#include "farptr.h" // GET_FLATPTR #include "output.h" // dprintf #include "std/disk.h" // DISK_RET_EPARAM #include "string.h" // memset @@ -117,7 +117,7 @@ scsi_fill_cmd(struct disk_op_s *op, void *cdbcmd, int maxcdb) : CDB_CMD_WRITE_10); cmd->lba = cpu_to_be32(op->lba); cmd->count = cpu_to_be16(op->count); - return GET_GLOBALFLAT(op->drive_gf->blksize); + return GET_FLATPTR(op->drive_gf->blksize); case CMD_SCSI: if (MODESEGMENT) return -1;
Now that the drive_s struct does not need to be in the f-segment, rename references to drive_gf in the generic drive code to drive_fl.
This is just variable renames - no code changes.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.c | 36 ++++----- src/block.h | 2 +- src/cdrom.c | 6 +- src/disk.c | 218 +++++++++++++++++++++++++-------------------------- src/hw/ahci.c | 4 +- src/hw/ata.c | 26 +++--- src/hw/blockcmd.c | 8 +- src/hw/esp-scsi.c | 2 +- src/hw/floppy.c | 20 ++--- src/hw/lsi-scsi.c | 2 +- src/hw/megasas.c | 2 +- src/hw/mpt-scsi.c | 2 +- src/hw/nvme.c | 2 +- src/hw/pvscsi.c | 2 +- src/hw/ramdisk.c | 2 +- src/hw/sdcard.c | 2 +- src/hw/usb-msc.c | 4 +- src/hw/usb-uas.c | 2 +- src/hw/virtio-blk.c | 2 +- src/hw/virtio-scsi.c | 2 +- 20 files changed, 173 insertions(+), 173 deletions(-)
diff --git a/src/block.c b/src/block.c index 8c5fb2d..f73ec18 100644 --- a/src/block.c +++ b/src/block.c @@ -298,7 +298,7 @@ map_floppy_drive(struct drive_s *drive)
// Fill in EDD info static int -fill_generic_edd(struct segoff_s edd, struct drive_s *drive_gf +fill_generic_edd(struct segoff_s edd, struct drive_s *drive_fl , u32 dpte_so, u8 bus_iface, u32 iface_path, u32 device_path) { u16 seg = edd.seg; @@ -312,12 +312,12 @@ fill_generic_edd(struct segoff_s edd, struct drive_s *drive_gf
// EDD 1.x
- u8 type = GET_FLATPTR(drive_gf->type); - u16 npc = GET_FLATPTR(drive_gf->pchs.cylinder); - u16 nph = GET_FLATPTR(drive_gf->pchs.head); - u16 nps = GET_FLATPTR(drive_gf->pchs.sector); - u64 lba = GET_FLATPTR(drive_gf->sectors); - u16 blksize = GET_FLATPTR(drive_gf->blksize); + u8 type = GET_FLATPTR(drive_fl->type); + u16 npc = GET_FLATPTR(drive_fl->pchs.cylinder); + u16 nph = GET_FLATPTR(drive_fl->pchs.head); + u16 nps = GET_FLATPTR(drive_fl->pchs.sector); + u64 lba = GET_FLATPTR(drive_fl->sectors); + u16 blksize = GET_FLATPTR(drive_fl->blksize);
dprintf(DEBUG_HDL_13, "disk_1348 size=%d t=%d chs=%d,%d,%d lba=%d bs=%d\n" , size, type, npc, nph, nps, (u32)lba, blksize); @@ -467,19 +467,19 @@ fill_ata_edd(struct segoff_s edd, struct drive_s *drive_gf)
// Fill Extended Disk Drive (EDD) "Get drive parameters" info for a drive int noinline -fill_edd(struct segoff_s edd, struct drive_s *drive_gf) +fill_edd(struct segoff_s edd, struct drive_s *drive_fl) { - switch (GET_FLATPTR(drive_gf->type)) { + switch (GET_FLATPTR(drive_fl->type)) { case DTYPE_ATA: case DTYPE_ATA_ATAPI: - return fill_ata_edd(edd, drive_gf); + return fill_ata_edd(edd, drive_fl); case DTYPE_VIRTIO_BLK: case DTYPE_VIRTIO_SCSI: return fill_generic_edd( - edd, drive_gf, 0xffffffff, EDD_PCI | EDD_SCSI - , edd_pci_path(GET_FLATPTR(drive_gf->cntl_id), 0), 0); + edd, drive_fl, 0xffffffff, EDD_PCI | EDD_SCSI + , edd_pci_path(GET_FLATPTR(drive_fl->cntl_id), 0), 0); default: - return fill_generic_edd(edd, drive_gf, 0, 0, 0, 0); + return fill_generic_edd(edd, drive_fl, 0, 0, 0, 0); } }
@@ -527,7 +527,7 @@ default_process_op(struct disk_op_s *op) static int process_op_both(struct disk_op_s *op) { - switch (GET_FLATPTR(op->drive_gf->type)) { + switch (GET_FLATPTR(op->drive_fl->type)) { case DTYPE_ATA_ATAPI: return ata_atapi_process_op(op); case DTYPE_USB: @@ -556,7 +556,7 @@ int VISIBLE32FLAT process_op_32(struct disk_op_s *op) { ASSERT32FLAT(); - switch (op->drive_gf->type) { + switch (op->drive_fl->type) { case DTYPE_VIRTIO_BLK: return virtio_blk_process_op(op); case DTYPE_AHCI: @@ -585,7 +585,7 @@ static int process_op_16(struct disk_op_s *op) { ASSERT16(); - switch (GET_FLATPTR(op->drive_gf->type)) { + switch (GET_FLATPTR(op->drive_fl->type)) { case DTYPE_FLOPPY: return floppy_process_op(op); case DTYPE_ATA: @@ -604,11 +604,11 @@ int process_op(struct disk_op_s *op) { dprintf(DEBUG_HDL_13, "disk_op d=%p lba=%d buf=%p count=%d cmd=%d\n" - , op->drive_gf, (u32)op->lba, op->buf_fl + , op->drive_fl, (u32)op->lba, op->buf_fl , op->count, op->command);
int ret, origcount = op->count; - if (origcount * GET_FLATPTR(op->drive_gf->blksize) > 64*1024) { + if (origcount * GET_FLATPTR(op->drive_fl->blksize) > 64*1024) { op->count = 0; return DISK_RET_EBOUNDARY; } diff --git a/src/block.h b/src/block.h index f03ec38..a380f16 100644 --- a/src/block.h +++ b/src/block.h @@ -10,7 +10,7 @@
struct disk_op_s { void *buf_fl; - struct drive_s *drive_gf; + struct drive_s *drive_fl; u8 command; u16 count; union { diff --git a/src/cdrom.c b/src/cdrom.c index a4f31ad..828fb3b 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -31,7 +31,7 @@ cdemu_read(struct disk_op_s *op) { struct drive_s *drive_gf = GET_LOW(emulated_drive_gf); struct disk_op_s dop; - dop.drive_gf = drive_gf; + dop.drive_fl = drive_gf; dop.command = op->command; dop.lba = GET_LOW(CDEmu.ilba) + op->lba / 4;
@@ -136,8 +136,8 @@ cdrom_boot(struct drive_s *drive) struct disk_op_s dop; int cdid = getDriveId(EXTTYPE_CD, drive); memset(&dop, 0, sizeof(dop)); - dop.drive_gf = drive; - if (!dop.drive_gf || cdid < 0) + dop.drive_fl = drive; + if (!dop.drive_fl || cdid < 0) return 1;
int ret = scsi_is_ready(&dop); diff --git a/src/disk.c b/src/disk.c index 5a4fe9d..0328fbd 100644 --- a/src/disk.c +++ b/src/disk.c @@ -67,10 +67,10 @@ __disk_stub(struct bregs *regs, int lineno, const char *fname)
// Get the cylinders/heads/sectors for the given drive. static struct chs_s -getLCHS(struct drive_s *drive_gf) +getLCHS(struct drive_s *drive_fl) { struct chs_s res = { }; - if (CONFIG_CDROM_EMU && drive_gf == GET_GLOBAL(cdemu_drive_gf)) { + if (CONFIG_CDROM_EMU && drive_fl == GET_GLOBAL(cdemu_drive_gf)) { // Emulated drive - get info from CDEmu. (It's not possible to // populate the geometry directly in the driveid because the // geometry is only known after the bios segment is made @@ -81,9 +81,9 @@ getLCHS(struct drive_s *drive_gf) res.sector = sptcyl & 0x3f; return res; } - res.cylinder = GET_FLATPTR(drive_gf->lchs.cylinder); - res.head = GET_FLATPTR(drive_gf->lchs.head); - res.sector = GET_FLATPTR(drive_gf->lchs.sector); + res.cylinder = GET_FLATPTR(drive_fl->lchs.cylinder); + res.head = GET_FLATPTR(drive_fl->lchs.head); + res.sector = GET_FLATPTR(drive_fl->lchs.sector); return res; }
@@ -117,10 +117,10 @@ send_disk_op(struct disk_op_s *op)
// Perform read/write/verify using old-style chs accesses static void noinline -basic_access(struct bregs *regs, struct drive_s *drive_gf, u16 command) +basic_access(struct bregs *regs, struct drive_s *drive_fl, u16 command) { struct disk_op_s dop; - dop.drive_gf = drive_gf; + dop.drive_fl = drive_fl; dop.command = command;
u8 count = regs->al; @@ -135,7 +135,7 @@ basic_access(struct bregs *regs, struct drive_s *drive_gf, u16 command) } dop.count = count;
- struct chs_s chs = getLCHS(drive_gf); + struct chs_s chs = getLCHS(drive_fl); u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector;
// sanity check on cyl heads, sec @@ -160,15 +160,15 @@ basic_access(struct bregs *regs, struct drive_s *drive_gf, u16 command)
// Perform read/write/verify using new-style "int13ext" accesses. static void noinline -extended_access(struct bregs *regs, struct drive_s *drive_gf, u16 command) +extended_access(struct bregs *regs, struct drive_s *drive_fl, u16 command) { struct disk_op_s dop; struct int13ext_s *param_far = (struct int13ext_s*)(regs->si+0); // Get lba and check. dop.lba = GET_FARVAR(regs->ds, param_far->lba); dop.command = command; - dop.drive_gf = drive_gf; - if (dop.lba >= GET_FLATPTR(drive_gf->sectors)) { + dop.drive_fl = drive_fl; + if (dop.lba >= GET_FLATPTR(drive_fl->sectors)) { warn_invalid(regs); disk_ret(regs, DISK_RET_EPARAM); return; @@ -196,10 +196,10 @@ extended_access(struct bregs *regs, struct drive_s *drive_gf, u16 command)
// disk controller reset static void -disk_1300(struct bregs *regs, struct drive_s *drive_gf) +disk_1300(struct bregs *regs, struct drive_s *drive_fl) { struct disk_op_s dop; - dop.drive_gf = drive_gf; + dop.drive_fl = drive_fl; dop.command = CMD_RESET; dop.count = 0; int status = send_disk_op(&dop); @@ -208,7 +208,7 @@ disk_1300(struct bregs *regs, struct drive_s *drive_gf)
// read disk status static void -disk_1301(struct bregs *regs, struct drive_s *drive_gf) +disk_1301(struct bregs *regs, struct drive_s *drive_fl) { u8 v; if (regs->dl < EXTSTART_HD) @@ -223,32 +223,32 @@ disk_1301(struct bregs *regs, struct drive_s *drive_gf)
// read disk sectors static void -disk_1302(struct bregs *regs, struct drive_s *drive_gf) +disk_1302(struct bregs *regs, struct drive_s *drive_fl) { - basic_access(regs, drive_gf, CMD_READ); + basic_access(regs, drive_fl, CMD_READ); }
// write disk sectors static void -disk_1303(struct bregs *regs, struct drive_s *drive_gf) +disk_1303(struct bregs *regs, struct drive_s *drive_fl) { - basic_access(regs, drive_gf, CMD_WRITE); + basic_access(regs, drive_fl, CMD_WRITE); }
// verify disk sectors static void -disk_1304(struct bregs *regs, struct drive_s *drive_gf) +disk_1304(struct bregs *regs, struct drive_s *drive_fl) { - basic_access(regs, drive_gf, CMD_VERIFY); + basic_access(regs, drive_fl, CMD_VERIFY); }
// format disk track static void noinline -disk_1305(struct bregs *regs, struct drive_s *drive_gf) +disk_1305(struct bregs *regs, struct drive_s *drive_fl) { debug_stub(regs);
- struct chs_s chs = getLCHS(drive_gf); + struct chs_s chs = getLCHS(drive_fl); u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector;
u8 count = regs->al; @@ -261,7 +261,7 @@ disk_1305(struct bregs *regs, struct drive_s *drive_gf) }
struct disk_op_s dop; - dop.drive_gf = drive_gf; + dop.drive_fl = drive_fl; dop.command = CMD_FORMAT; dop.lba = (((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nls; dop.count = count; @@ -272,10 +272,10 @@ disk_1305(struct bregs *regs, struct drive_s *drive_gf)
// read disk drive parameters static void noinline -disk_1308(struct bregs *regs, struct drive_s *drive_gf) +disk_1308(struct bregs *regs, struct drive_s *drive_fl) { // Get logical geometry from table - struct chs_s chs = getLCHS(drive_gf); + struct chs_s chs = getLCHS(drive_fl); u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector; nlc--; nlh--; @@ -284,10 +284,10 @@ disk_1308(struct bregs *regs, struct drive_s *drive_gf) // Floppy count = GET_GLOBAL(FloppyCount);
- if (CONFIG_CDROM_EMU && drive_gf == GET_GLOBAL(cdemu_drive_gf)) + if (CONFIG_CDROM_EMU && drive_fl == GET_GLOBAL(cdemu_drive_gf)) regs->bx = GET_LOW(CDEmu.media) * 2; else - regs->bx = GET_FLATPTR(drive_gf->floppy_type); + regs->bx = GET_FLATPTR(drive_fl->floppy_type);
// set es & di to point to 11 byte diskette param table in ROM regs->es = SEG_BIOS; @@ -323,33 +323,33 @@ disk_1308(struct bregs *regs, struct drive_s *drive_gf)
// initialize drive parameters static void -disk_1309(struct bregs *regs, struct drive_s *drive_gf) +disk_1309(struct bregs *regs, struct drive_s *drive_fl) { DISK_STUB(regs); }
// seek to specified cylinder static void -disk_130c(struct bregs *regs, struct drive_s *drive_gf) +disk_130c(struct bregs *regs, struct drive_s *drive_fl) { DISK_STUB(regs); }
// alternate disk reset static void -disk_130d(struct bregs *regs, struct drive_s *drive_gf) +disk_130d(struct bregs *regs, struct drive_s *drive_fl) { DISK_STUB(regs); }
// check drive ready static void -disk_1310(struct bregs *regs, struct drive_s *drive_gf) +disk_1310(struct bregs *regs, struct drive_s *drive_fl) { // should look at 40:8E also???
struct disk_op_s dop; - dop.drive_gf = drive_gf; + dop.drive_fl = drive_fl; dop.command = CMD_ISREADY; dop.count = 0; int status = send_disk_op(&dop); @@ -358,21 +358,21 @@ disk_1310(struct bregs *regs, struct drive_s *drive_gf)
// recalibrate static void -disk_1311(struct bregs *regs, struct drive_s *drive_gf) +disk_1311(struct bregs *regs, struct drive_s *drive_fl) { DISK_STUB(regs); }
// controller internal diagnostic static void -disk_1314(struct bregs *regs, struct drive_s *drive_gf) +disk_1314(struct bregs *regs, struct drive_s *drive_fl) { DISK_STUB(regs); }
// read disk drive size static void noinline -disk_1315(struct bregs *regs, struct drive_s *drive_gf) +disk_1315(struct bregs *regs, struct drive_s *drive_fl) { disk_ret(regs, DISK_RET_SUCCESS); if (regs->dl < EXTSTART_HD || regs->dl >= EXTSTART_CD) { @@ -383,7 +383,7 @@ disk_1315(struct bregs *regs, struct drive_s *drive_gf) // Hard drive
// Get logical geometry from table - struct chs_s chs = getLCHS(drive_gf); + struct chs_s chs = getLCHS(drive_fl); u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector;
// Compute sector count seen by int13 @@ -394,7 +394,7 @@ disk_1315(struct bregs *regs, struct drive_s *drive_gf) }
static void -disk_1316(struct bregs *regs, struct drive_s *drive_gf) +disk_1316(struct bregs *regs, struct drive_s *drive_fl) { if (regs->dl >= EXTSTART_HD) { // Hard drive @@ -406,7 +406,7 @@ disk_1316(struct bregs *regs, struct drive_s *drive_gf)
// IBM/MS installation check static void -disk_1341(struct bregs *regs, struct drive_s *drive_gf) +disk_1341(struct bregs *regs, struct drive_s *drive_fl) { regs->bx = 0xaa55; // install check regs->cx = 0x0007; // ext disk access and edd, removable supported @@ -416,23 +416,23 @@ disk_1341(struct bregs *regs, struct drive_s *drive_gf)
// IBM/MS extended read static void -disk_1342(struct bregs *regs, struct drive_s *drive_gf) +disk_1342(struct bregs *regs, struct drive_s *drive_fl) { - extended_access(regs, drive_gf, CMD_READ); + extended_access(regs, drive_fl, CMD_READ); }
// IBM/MS extended write static void -disk_1343(struct bregs *regs, struct drive_s *drive_gf) +disk_1343(struct bregs *regs, struct drive_s *drive_fl) { - extended_access(regs, drive_gf, CMD_WRITE); + extended_access(regs, drive_fl, CMD_WRITE); }
// IBM/MS verify static void -disk_1344(struct bregs *regs, struct drive_s *drive_gf) +disk_1344(struct bregs *regs, struct drive_s *drive_fl) { - extended_access(regs, drive_gf, CMD_VERIFY); + extended_access(regs, drive_fl, CMD_VERIFY); }
// Locks for removable devices @@ -440,7 +440,7 @@ u8 CDRom_locks[BUILD_MAX_EXTDRIVE] VARLOW;
// lock static void -disk_134500(struct bregs *regs, struct drive_s *drive_gf) +disk_134500(struct bregs *regs, struct drive_s *drive_fl) { int cdid = regs->dl - EXTSTART_CD; u8 locks = GET_LOW(CDRom_locks[cdid]); @@ -456,7 +456,7 @@ disk_134500(struct bregs *regs, struct drive_s *drive_gf)
// unlock static void -disk_134501(struct bregs *regs, struct drive_s *drive_gf) +disk_134501(struct bregs *regs, struct drive_s *drive_fl) { int cdid = regs->dl - EXTSTART_CD; u8 locks = GET_LOW(CDRom_locks[cdid]); @@ -473,7 +473,7 @@ disk_134501(struct bregs *regs, struct drive_s *drive_gf)
// status static void -disk_134502(struct bregs *regs, struct drive_s *drive_gf) +disk_134502(struct bregs *regs, struct drive_s *drive_fl) { int cdid = regs->dl - EXTSTART_CD; u8 locks = GET_LOW(CDRom_locks[cdid]); @@ -482,14 +482,14 @@ disk_134502(struct bregs *regs, struct drive_s *drive_gf) }
static void -disk_1345XX(struct bregs *regs, struct drive_s *drive_gf) +disk_1345XX(struct bregs *regs, struct drive_s *drive_fl) { disk_ret_unimplemented(regs, DISK_RET_EPARAM); }
// IBM/MS lock/unlock drive static void -disk_1345(struct bregs *regs, struct drive_s *drive_gf) +disk_1345(struct bregs *regs, struct drive_s *drive_fl) { if (regs->dl < EXTSTART_CD) { // Always success for HD @@ -498,16 +498,16 @@ disk_1345(struct bregs *regs, struct drive_s *drive_gf) }
switch (regs->al) { - case 0x00: disk_134500(regs, drive_gf); break; - case 0x01: disk_134501(regs, drive_gf); break; - case 0x02: disk_134502(regs, drive_gf); break; - default: disk_1345XX(regs, drive_gf); break; + case 0x00: disk_134500(regs, drive_fl); break; + case 0x01: disk_134501(regs, drive_fl); break; + case 0x02: disk_134502(regs, drive_fl); break; + default: disk_1345XX(regs, drive_fl); break; } }
// IBM/MS eject media static void noinline -disk_1346(struct bregs *regs, struct drive_s *drive_gf) +disk_1346(struct bregs *regs, struct drive_s *drive_fl) { if (regs->dl < EXTSTART_CD) { // Volume Not Removable @@ -541,22 +541,22 @@ disk_1346(struct bregs *regs, struct drive_s *drive_gf)
// IBM/MS extended seek static void -disk_1347(struct bregs *regs, struct drive_s *drive_gf) +disk_1347(struct bregs *regs, struct drive_s *drive_fl) { - extended_access(regs, drive_gf, CMD_SEEK); + extended_access(regs, drive_fl, CMD_SEEK); }
// IBM/MS get drive parameters static void -disk_1348(struct bregs *regs, struct drive_s *drive_gf) +disk_1348(struct bregs *regs, struct drive_s *drive_fl) { - int ret = fill_edd(SEGOFF(regs->ds, regs->si), drive_gf); + int ret = fill_edd(SEGOFF(regs->ds, regs->si), drive_fl); disk_ret(regs, ret); }
// IBM/MS extended media change static void -disk_1349(struct bregs *regs, struct drive_s *drive_gf) +disk_1349(struct bregs *regs, struct drive_s *drive_fl) { if (regs->dl < EXTSTART_CD) { // Always success for HD @@ -569,56 +569,56 @@ disk_1349(struct bregs *regs, struct drive_s *drive_gf) }
static void -disk_134e01(struct bregs *regs, struct drive_s *drive_gf) +disk_134e01(struct bregs *regs, struct drive_s *drive_fl) { disk_ret(regs, DISK_RET_SUCCESS); }
static void -disk_134e03(struct bregs *regs, struct drive_s *drive_gf) +disk_134e03(struct bregs *regs, struct drive_s *drive_fl) { disk_ret(regs, DISK_RET_SUCCESS); }
static void -disk_134e04(struct bregs *regs, struct drive_s *drive_gf) +disk_134e04(struct bregs *regs, struct drive_s *drive_fl) { disk_ret(regs, DISK_RET_SUCCESS); }
static void -disk_134e06(struct bregs *regs, struct drive_s *drive_gf) +disk_134e06(struct bregs *regs, struct drive_s *drive_fl) { disk_ret(regs, DISK_RET_SUCCESS); }
static void -disk_134eXX(struct bregs *regs, struct drive_s *drive_gf) +disk_134eXX(struct bregs *regs, struct drive_s *drive_fl) { disk_ret(regs, DISK_RET_EPARAM); }
// IBM/MS set hardware configuration static void -disk_134e(struct bregs *regs, struct drive_s *drive_gf) +disk_134e(struct bregs *regs, struct drive_s *drive_fl) { switch (regs->al) { - case 0x01: disk_134e01(regs, drive_gf); break; - case 0x03: disk_134e03(regs, drive_gf); break; - case 0x04: disk_134e04(regs, drive_gf); break; - case 0x06: disk_134e06(regs, drive_gf); break; - default: disk_134eXX(regs, drive_gf); break; + case 0x01: disk_134e01(regs, drive_fl); break; + case 0x03: disk_134e03(regs, drive_fl); break; + case 0x04: disk_134e04(regs, drive_fl); break; + case 0x06: disk_134e06(regs, drive_fl); break; + default: disk_134eXX(regs, drive_fl); break; } }
static void -disk_13XX(struct bregs *regs, struct drive_s *drive_gf) +disk_13XX(struct bregs *regs, struct drive_s *drive_fl) { disk_ret_unimplemented(regs, DISK_RET_EPARAM); }
static void -disk_13(struct bregs *regs, struct drive_s *drive_gf) +disk_13(struct bregs *regs, struct drive_s *drive_fl) { //debug_stub(regs);
@@ -626,37 +626,37 @@ disk_13(struct bregs *regs, struct drive_s *drive_gf) SET_BDA(disk_interrupt_flag, 0);
switch (regs->ah) { - case 0x00: disk_1300(regs, drive_gf); break; - case 0x01: disk_1301(regs, drive_gf); break; - case 0x02: disk_1302(regs, drive_gf); break; - case 0x03: disk_1303(regs, drive_gf); break; - case 0x04: disk_1304(regs, drive_gf); break; - case 0x05: disk_1305(regs, drive_gf); break; - case 0x08: disk_1308(regs, drive_gf); break; - case 0x09: disk_1309(regs, drive_gf); break; - case 0x0c: disk_130c(regs, drive_gf); break; - case 0x0d: disk_130d(regs, drive_gf); break; - case 0x10: disk_1310(regs, drive_gf); break; - case 0x11: disk_1311(regs, drive_gf); break; - case 0x14: disk_1314(regs, drive_gf); break; - case 0x15: disk_1315(regs, drive_gf); break; - case 0x16: disk_1316(regs, drive_gf); break; - case 0x41: disk_1341(regs, drive_gf); break; - case 0x42: disk_1342(regs, drive_gf); break; - case 0x43: disk_1343(regs, drive_gf); break; - case 0x44: disk_1344(regs, drive_gf); break; - case 0x45: disk_1345(regs, drive_gf); break; - case 0x46: disk_1346(regs, drive_gf); break; - case 0x47: disk_1347(regs, drive_gf); break; - case 0x48: disk_1348(regs, drive_gf); break; - case 0x49: disk_1349(regs, drive_gf); break; - case 0x4e: disk_134e(regs, drive_gf); break; - default: disk_13XX(regs, drive_gf); break; + case 0x00: disk_1300(regs, drive_fl); break; + case 0x01: disk_1301(regs, drive_fl); break; + case 0x02: disk_1302(regs, drive_fl); break; + case 0x03: disk_1303(regs, drive_fl); break; + case 0x04: disk_1304(regs, drive_fl); break; + case 0x05: disk_1305(regs, drive_fl); break; + case 0x08: disk_1308(regs, drive_fl); break; + case 0x09: disk_1309(regs, drive_fl); break; + case 0x0c: disk_130c(regs, drive_fl); break; + case 0x0d: disk_130d(regs, drive_fl); break; + case 0x10: disk_1310(regs, drive_fl); break; + case 0x11: disk_1311(regs, drive_fl); break; + case 0x14: disk_1314(regs, drive_fl); break; + case 0x15: disk_1315(regs, drive_fl); break; + case 0x16: disk_1316(regs, drive_fl); break; + case 0x41: disk_1341(regs, drive_fl); break; + case 0x42: disk_1342(regs, drive_fl); break; + case 0x43: disk_1343(regs, drive_fl); break; + case 0x44: disk_1344(regs, drive_fl); break; + case 0x45: disk_1345(regs, drive_fl); break; + case 0x46: disk_1346(regs, drive_fl); break; + case 0x47: disk_1347(regs, drive_fl); break; + case 0x48: disk_1348(regs, drive_fl); break; + case 0x49: disk_1349(regs, drive_fl); break; + case 0x4e: disk_134e(regs, drive_fl); break; + default: disk_13XX(regs, drive_fl); break; } }
static void -floppy_13(struct bregs *regs, struct drive_s *drive_gf) +floppy_13(struct bregs *regs, struct drive_s *drive_fl) { // Only limited commands are supported on floppies. switch (regs->ah) { @@ -669,9 +669,9 @@ floppy_13(struct bregs *regs, struct drive_s *drive_gf) case 0x08: case 0x15: case 0x16: - disk_13(regs, drive_gf); + disk_13(regs, drive_fl); break; - default: disk_13XX(regs, drive_gf); break; + default: disk_13XX(regs, drive_fl); break; } }
@@ -707,21 +707,21 @@ handle_legacy_disk(struct bregs *regs, u8 extdrive) }
if (extdrive < EXTSTART_HD) { - struct drive_s *drive_gf = getDrive(EXTTYPE_FLOPPY, extdrive); - if (!drive_gf) + struct drive_s *drive_fl = getDrive(EXTTYPE_FLOPPY, extdrive); + if (!drive_fl) goto fail; - floppy_13(regs, drive_gf); + floppy_13(regs, drive_fl); return; }
- struct drive_s *drive_gf; + struct drive_s *drive_fl; if (extdrive >= EXTSTART_CD) - drive_gf = getDrive(EXTTYPE_CD, extdrive - EXTSTART_CD); + drive_fl = getDrive(EXTTYPE_CD, extdrive - EXTSTART_CD); else - drive_gf = getDrive(EXTTYPE_HD, extdrive - EXTSTART_HD); - if (!drive_gf) + drive_fl = getDrive(EXTTYPE_HD, extdrive - EXTSTART_HD); + if (!drive_fl) goto fail; - disk_13(regs, drive_gf); + disk_13(regs, drive_fl); return;
fail: diff --git a/src/hw/ahci.c b/src/hw/ahci.c index b9043b9..1746e7a 100644 --- a/src/hw/ahci.c +++ b/src/hw/ahci.c @@ -217,7 +217,7 @@ int ahci_atapi_process_op(struct disk_op_s *op) return 0;
struct ahci_port_s *port_gf = container_of( - op->drive_gf, struct ahci_port_s, drive); + op->drive_fl, struct ahci_port_s, drive); struct ahci_cmd_s *cmd = port_gf->cmd;
if (op->command == CMD_WRITE || op->command == CMD_FORMAT) @@ -237,7 +237,7 @@ static int ahci_disk_readwrite_aligned(struct disk_op_s *op, int iswrite) { struct ahci_port_s *port_gf = container_of( - op->drive_gf, struct ahci_port_s, drive); + op->drive_fl, struct ahci_port_s, drive); struct ahci_cmd_s *cmd = port_gf->cmd; int rc;
diff --git a/src/hw/ata.c b/src/hw/ata.c index 9a4b435..b6e073c 100644 --- a/src/hw/ata.c +++ b/src/hw/ata.c @@ -271,15 +271,15 @@ fail: ****************************************************************/
// Transfer 'op->count' blocks (of 'blocksize' bytes) to/from drive -// 'op->drive_gf'. +// 'op->drive_fl'. static int ata_pio_transfer(struct disk_op_s *op, int iswrite, int blocksize) { dprintf(16, "ata_pio_transfer id=%p write=%d count=%d bs=%d buf=%p\n" - , op->drive_gf, iswrite, op->count, blocksize, op->buf_fl); + , op->drive_fl, iswrite, op->count, blocksize, op->buf_fl);
struct atadrive_s *adrive_gf = container_of( - op->drive_gf, struct atadrive_s, drive); + op->drive_fl, struct atadrive_s, drive); struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); u16 iobase1 = GET_GLOBALFLAT(chan_gf->iobase1); u16 iobase2 = GET_GLOBALFLAT(chan_gf->iobase2); @@ -289,14 +289,14 @@ ata_pio_transfer(struct disk_op_s *op, int iswrite, int blocksize) for (;;) { if (iswrite) { // Write data to controller - dprintf(16, "Write sector id=%p dest=%p\n", op->drive_gf, buf_fl); + dprintf(16, "Write sector id=%p dest=%p\n", op->drive_fl, buf_fl); if (CONFIG_ATA_PIO32) outsl_fl(iobase1, buf_fl, blocksize / 4); else outsw_fl(iobase1, buf_fl, blocksize / 2); } else { // Read data from controller - dprintf(16, "Read sector id=%p dest=%p\n", op->drive_gf, buf_fl); + dprintf(16, "Read sector id=%p dest=%p\n", op->drive_fl, buf_fl); if (CONFIG_ATA_PIO32) insl_fl(iobase1, buf_fl, blocksize / 4); else @@ -366,7 +366,7 @@ ata_try_dma(struct disk_op_s *op, int iswrite, int blocksize) // Need minimum alignment of 1. return -1; struct atadrive_s *adrive_gf = container_of( - op->drive_gf, struct atadrive_s, drive); + op->drive_fl, struct atadrive_s, drive); struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); u16 iomaster = GET_GLOBALFLAT(chan_gf->iomaster); if (! iomaster) @@ -413,10 +413,10 @@ ata_dma_transfer(struct disk_op_s *op) { if (! CONFIG_ATA_DMA) return -1; - dprintf(16, "ata_dma_transfer id=%p buf=%p\n", op->drive_gf, op->buf_fl); + dprintf(16, "ata_dma_transfer id=%p buf=%p\n", op->drive_fl, op->buf_fl);
struct atadrive_s *adrive_gf = container_of( - op->drive_gf, struct atadrive_s, drive); + op->drive_fl, struct atadrive_s, drive); struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); u16 iomaster = GET_GLOBALFLAT(chan_gf->iomaster);
@@ -466,7 +466,7 @@ static int ata_pio_cmd_data(struct disk_op_s *op, int iswrite, struct ata_pio_command *cmd) { struct atadrive_s *adrive_gf = container_of( - op->drive_gf, struct atadrive_s, drive); + op->drive_fl, struct atadrive_s, drive); struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); u16 iobase1 = GET_GLOBALFLAT(chan_gf->iobase1); u16 iobase2 = GET_GLOBALFLAT(chan_gf->iobase2); @@ -495,7 +495,7 @@ ata_dma_cmd_data(struct disk_op_s *op, struct ata_pio_command *cmd) if (! CONFIG_ATA_DMA) return -1; struct atadrive_s *adrive_gf = container_of( - op->drive_gf, struct atadrive_s, drive); + op->drive_fl, struct atadrive_s, drive); int ret = send_cmd(adrive_gf, cmd); if (ret) return ret; @@ -559,7 +559,7 @@ ata_process_op(struct disk_op_s *op) return 0;
struct atadrive_s *adrive_gf = container_of( - op->drive_gf, struct atadrive_s, drive); + op->drive_fl, struct atadrive_s, drive); switch (op->command) { case CMD_READ: return ata_readwrite(op, 0); @@ -597,7 +597,7 @@ ata_atapi_process_op(struct disk_op_s *op) return default_process_op(op);
struct atadrive_s *adrive_gf = container_of( - op->drive_gf, struct atadrive_s, drive); + op->drive_fl, struct atadrive_s, drive); struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); u16 iobase1 = GET_GLOBALFLAT(chan_gf->iobase1); u16 iobase2 = GET_GLOBALFLAT(chan_gf->iobase2); @@ -667,7 +667,7 @@ send_ata_identity(struct atadrive_s *adrive, u16 *buffer, int command)
struct disk_op_s dop; memset(&dop, 0, sizeof(dop)); - dop.drive_gf = &adrive->drive; + dop.drive_fl = &adrive->drive; dop.count = 1; dop.lba = 1; dop.buf_fl = MAKE_FLATPTR(GET_SEG(SS), buffer); diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index f260dd8..1f15081 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -117,7 +117,7 @@ scsi_fill_cmd(struct disk_op_s *op, void *cdbcmd, int maxcdb) : CDB_CMD_WRITE_10); cmd->lba = cpu_to_be32(op->lba); cmd->count = cpu_to_be16(op->count); - return GET_FLATPTR(op->drive_gf->blksize); + return GET_FLATPTR(op->drive_fl->blksize); case CMD_SCSI: if (MODESEGMENT) return -1; @@ -141,7 +141,7 @@ int scsi_is_ready(struct disk_op_s *op) { ASSERT32FLAT(); - dprintf(6, "scsi_is_ready (drive=%p)\n", op->drive_gf); + dprintf(6, "scsi_is_ready (drive=%p)\n", op->drive_fl);
/* Retry TEST UNIT READY for 5 seconds unless MEDIUM NOT PRESENT is * reported by the device. If the device reports "IN PROGRESS", @@ -223,7 +223,7 @@ int scsi_rep_luns_scan(struct drive_s *tmp_drive, scsi_add_lun add_lun) .command = CDB_CMD_REPORT_LUNS, }; struct disk_op_s op = { - .drive_gf = tmp_drive, + .drive_fl = tmp_drive, .command = CMD_SCSI, .count = 1, .cdbcmd = &cdb, @@ -284,7 +284,7 @@ scsi_drive_setup(struct drive_s *drive, const char *s, int prio) ASSERT32FLAT(); struct disk_op_s dop; memset(&dop, 0, sizeof(dop)); - dop.drive_gf = drive; + dop.drive_fl = drive; struct cdbres_inquiry data; int ret = cdb_get_inquiry(&dop, &data); if (ret) diff --git a/src/hw/esp-scsi.c b/src/hw/esp-scsi.c index 57d3832..ffd86d0 100644 --- a/src/hw/esp-scsi.c +++ b/src/hw/esp-scsi.c @@ -83,7 +83,7 @@ esp_scsi_process_op(struct disk_op_s *op) if (!CONFIG_ESP_SCSI) return DISK_RET_EBADTRACK; struct esp_lun_s *llun_gf = - container_of(op->drive_gf, struct esp_lun_s, drive); + container_of(op->drive_fl, struct esp_lun_s, drive); u16 target = GET_GLOBALFLAT(llun_gf->target); u16 lun = GET_GLOBALFLAT(llun_gf->lun); u8 cdbcmd[16]; diff --git a/src/hw/floppy.c b/src/hw/floppy.c index 98ed9bb..f2577c5 100644 --- a/src/hw/floppy.c +++ b/src/hw/floppy.c @@ -473,7 +473,7 @@ floppy_dma_cmd(struct disk_op_s *op, int count, int command, u8 *param) return DISK_RET_EBOUNDARY;
// Invoke floppy controller - u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id); + u8 floppyid = GET_GLOBALFLAT(op->drive_fl->cntl_id); ret = floppy_drive_pio(floppyid, command, param); if (ret) return ret; @@ -506,11 +506,11 @@ lba2chs(struct disk_op_s *op) struct chs_s res = { };
u32 tmp = op->lba; - u16 nls = GET_GLOBALFLAT(op->drive_gf->lchs.sector); + u16 nls = GET_GLOBALFLAT(op->drive_fl->lchs.sector); res.sector = (tmp % nls) + 1;
tmp /= nls; - u16 nlh = GET_GLOBALFLAT(op->drive_gf->lchs.head); + u16 nlh = GET_GLOBALFLAT(op->drive_fl->lchs.head); res.head = tmp % nlh;
tmp /= nlh; @@ -538,12 +538,12 @@ static int floppy_read(struct disk_op_s *op) { struct chs_s chs = lba2chs(op); - int ret = floppy_prep(op->drive_gf, chs.cylinder); + int ret = floppy_prep(op->drive_fl, chs.cylinder); if (ret) return ret;
// send read-normal-data command to controller - u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id); + u8 floppyid = GET_GLOBALFLAT(op->drive_fl->cntl_id); u8 param[8]; param[0] = (chs.head << 2) | floppyid; // HD DR1 DR2 param[1] = chs.cylinder; @@ -561,12 +561,12 @@ static int floppy_write(struct disk_op_s *op) { struct chs_s chs = lba2chs(op); - int ret = floppy_prep(op->drive_gf, chs.cylinder); + int ret = floppy_prep(op->drive_fl, chs.cylinder); if (ret) return ret;
// send write-normal-data command to controller - u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id); + u8 floppyid = GET_GLOBALFLAT(op->drive_fl->cntl_id); u8 param[8]; param[0] = (chs.head << 2) | floppyid; // HD DR1 DR2 param[1] = chs.cylinder; @@ -584,7 +584,7 @@ static int floppy_verify(struct disk_op_s *op) { struct chs_s chs = lba2chs(op); - int ret = floppy_prep(op->drive_gf, chs.cylinder); + int ret = floppy_prep(op->drive_fl, chs.cylinder); if (ret) return ret;
@@ -597,12 +597,12 @@ static int floppy_format(struct disk_op_s *op) { struct chs_s chs = lba2chs(op); - int ret = floppy_prep(op->drive_gf, chs.cylinder); + int ret = floppy_prep(op->drive_fl, chs.cylinder); if (ret) return ret;
// send format-track command to controller - u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id); + u8 floppyid = GET_GLOBALFLAT(op->drive_fl->cntl_id); u8 param[7]; param[0] = (chs.head << 2) | floppyid; // HD DR1 DR2 param[1] = FLOPPY_SIZE_CODE; diff --git a/src/hw/lsi-scsi.c b/src/hw/lsi-scsi.c index 5233251..d5fc3e4 100644 --- a/src/hw/lsi-scsi.c +++ b/src/hw/lsi-scsi.c @@ -57,7 +57,7 @@ lsi_scsi_process_op(struct disk_op_s *op) if (!CONFIG_LSI_SCSI) return DISK_RET_EBADTRACK; struct lsi_lun_s *llun_gf = - container_of(op->drive_gf, struct lsi_lun_s, drive); + container_of(op->drive_fl, struct lsi_lun_s, drive); u16 target = GET_GLOBALFLAT(llun_gf->target); u16 lun = GET_GLOBALFLAT(llun_gf->lun); u8 cdbcmd[16]; diff --git a/src/hw/megasas.c b/src/hw/megasas.c index efd0f6e..d267580 100644 --- a/src/hw/megasas.c +++ b/src/hw/megasas.c @@ -167,7 +167,7 @@ megasas_process_op(struct disk_op_s *op) if (blocksize < 0) return default_process_op(op); struct megasas_lun_s *mlun_gf = - container_of(op->drive_gf, struct megasas_lun_s, drive); + container_of(op->drive_fl, struct megasas_lun_s, drive); struct megasas_cmd_frame *frame = GET_GLOBALFLAT(mlun_gf->frame); u16 pci_id = GET_GLOBALFLAT(mlun_gf->pci_id); int i; diff --git a/src/hw/mpt-scsi.c b/src/hw/mpt-scsi.c index 80c6d6b..1faede6 100644 --- a/src/hw/mpt-scsi.c +++ b/src/hw/mpt-scsi.c @@ -188,7 +188,7 @@ mpt_scsi_process_op(struct disk_op_s *op) return default_process_op(op);
struct mpt_lun_s *llun_gf = - container_of(op->drive_gf, struct mpt_lun_s, drive); + container_of(op->drive_fl, struct mpt_lun_s, drive); u16 target = GET_GLOBALFLAT(llun_gf->target); u16 lun = GET_GLOBALFLAT(llun_gf->lun); u32 iobase = GET_GLOBALFLAT(llun_gf->iobase); diff --git a/src/hw/nvme.c b/src/hw/nvme.c index 556a9a4..93c25f5 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -601,7 +601,7 @@ nvme_process_op(struct disk_op_s *op) if (!CONFIG_NVME) return DISK_RET_SUCCESS;
- struct nvme_namespace *ns = container_of(op->drive_gf, struct nvme_namespace, + struct nvme_namespace *ns = container_of(op->drive_fl, struct nvme_namespace, drive);
switch (op->command) { diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c index 7c850a9..d62d0a0 100644 --- a/src/hw/pvscsi.c +++ b/src/hw/pvscsi.c @@ -213,7 +213,7 @@ pvscsi_process_op(struct disk_op_s *op) if (!CONFIG_PVSCSI) return DISK_RET_EBADTRACK; struct pvscsi_lun_s *plun = - container_of(op->drive_gf, struct pvscsi_lun_s, drive); + container_of(op->drive_fl, struct pvscsi_lun_s, drive); struct pvscsi_ring_dsc_s *ring_dsc = plun->ring_dsc; struct PVSCSIRingsState *s = ring_dsc->ring_state; u32 req_entries = s->reqNumEntriesLog2; diff --git a/src/hw/ramdisk.c b/src/hw/ramdisk.c index adec1d1..b9e9baa 100644 --- a/src/hw/ramdisk.c +++ b/src/hw/ramdisk.c @@ -62,7 +62,7 @@ ramdisk_setup(void) static int ramdisk_copy(struct disk_op_s *op, int iswrite) { - u32 offset = GET_GLOBALFLAT(op->drive_gf->cntl_id); + u32 offset = GET_GLOBALFLAT(op->drive_fl->cntl_id); offset += (u32)op->lba * DISK_SECTOR_SIZE; u64 opd = GDT_DATA | GDT_LIMIT(0xfffff) | GDT_BASE((u32)op->buf_fl); u64 ramd = GDT_DATA | GDT_LIMIT(0xfffff) | GDT_BASE(offset); diff --git a/src/hw/sdcard.c b/src/hw/sdcard.c index 73fef29..6410340 100644 --- a/src/hw/sdcard.c +++ b/src/hw/sdcard.c @@ -266,7 +266,7 @@ static int sdcard_readwrite(struct disk_op_s *op, int iswrite) { struct sddrive_s *drive = container_of( - op->drive_gf, struct sddrive_s, drive); + op->drive_fl, struct sddrive_s, drive); int cmd = iswrite ? SC_WRITE_SINGLE : SC_READ_SINGLE; if (op->count > 1) cmd = iswrite ? SC_WRITE_MULTIPLE : SC_READ_MULTIPLE; diff --git a/src/hw/usb-msc.c b/src/hw/usb-msc.c index a234f13..2b18828 100644 --- a/src/hw/usb-msc.c +++ b/src/hw/usb-msc.c @@ -69,9 +69,9 @@ usb_process_op(struct disk_op_s *op) return 0;
dprintf(16, "usb_cmd_data id=%p write=%d count=%d buf=%p\n" - , op->drive_gf, 0, op->count, op->buf_fl); + , op->drive_fl, 0, op->count, op->buf_fl); struct usbdrive_s *udrive_gf = container_of( - op->drive_gf, struct usbdrive_s, drive); + op->drive_fl, struct usbdrive_s, drive);
// Setup command block wrapper. struct cbw_s cbw; diff --git a/src/hw/usb-uas.c b/src/hw/usb-uas.c index f00221a..6a8decc 100644 --- a/src/hw/usb-uas.c +++ b/src/hw/usb-uas.c @@ -98,7 +98,7 @@ uas_process_op(struct disk_op_s *op) return DISK_RET_EBADTRACK;
struct uasdrive_s *drive_gf = container_of( - op->drive_gf, struct uasdrive_s, drive); + op->drive_fl, struct uasdrive_s, drive);
uas_ui ui; memset(&ui, 0, sizeof(ui)); diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c index 901b8f5..ad16200 100644 --- a/src/hw/virtio-blk.c +++ b/src/hw/virtio-blk.c @@ -33,7 +33,7 @@ static int virtio_blk_op(struct disk_op_s *op, int write) { struct virtiodrive_s *vdrive_gf = - container_of(op->drive_gf, struct virtiodrive_s, drive); + container_of(op->drive_fl, struct virtiodrive_s, drive); struct vring_virtqueue *vq = vdrive_gf->vq; struct virtio_blk_outhdr hdr = { .type = write ? VIRTIO_BLK_T_OUT : VIRTIO_BLK_T_IN, diff --git a/src/hw/virtio-scsi.c b/src/hw/virtio-scsi.c index 4eea5c3..466b305 100644 --- a/src/hw/virtio-scsi.c +++ b/src/hw/virtio-scsi.c @@ -39,7 +39,7 @@ virtio_scsi_process_op(struct disk_op_s *op) if (! CONFIG_VIRTIO_SCSI) return 0; struct virtio_lun_s *vlun = - container_of(op->drive_gf, struct virtio_lun_s, drive); + container_of(op->drive_fl, struct virtio_lun_s, drive); struct vp_device *vp = vlun->vp; struct vring_virtqueue *vq = vlun->vq; struct virtio_scsi_req_cmd req;
On 11/07/2017 18:50, Kevin O'Connor wrote:
Now that the drive_s struct does not need to be in the f-segment, rename references to drive_gf in the generic drive code to drive_fl.
This is just variable renames - no code changes.
Signed-off-by: Kevin O'Connor kevin@koconnor.net
There are still quite a few:
src/block.c:fill_ata_edd(struct segoff_s edd, struct drive_s *drive_gf) src/block.c: drive_gf, struct atadrive_s, drive); src/block.c: if (GET_GLOBALFLAT(drive_gf->type) == DTYPE_ATA) { src/block.c: u8 translation = GET_GLOBALFLAT(drive_gf->translation); src/block.c: edd, drive_gf, SEGOFF(SEG_LOW, (u32)&DefaultDPTE).segoff src/block.h:int fill_edd(struct segoff_s edd, struct drive_s *drive_gf); src/cdrom.c: struct drive_s *drive_gf = GET_LOW(emulated_drive_gf); src/cdrom.c: dop.drive_fl = drive_gf; src/hw/floppy.c:floppy_media_sense(struct drive_s *drive_gf) src/hw/floppy.c: u8 ftype = GET_GLOBALFLAT(drive_gf->floppy_type), stype = ftype; src/hw/floppy.c: u8 floppyid = GET_GLOBALFLAT(drive_gf->cntl_id); src/hw/floppy.c:floppy_prep(struct drive_s *drive_gf, u8 cylinder) src/hw/floppy.c: u8 floppyid = GET_GLOBALFLAT(drive_gf->cntl_id); src/hw/floppy.c: ret = floppy_media_sense(drive_gf); src/hw/usb-uas.c: struct uasdrive_s *drive_gf = container_of( src/hw/usb-uas.c: ui.command.lun[1] = GET_GLOBALFLAT(drive_gf->lun); src/hw/usb-uas.c: int ret = usb_send_bulk(GET_GLOBALFLAT(drive_gf->command), src/hw/usb-uas.c: ret = usb_send_bulk(GET_GLOBALFLAT(drive_gf->status), src/hw/usb-uas.c: ret = usb_send_bulk(GET_GLOBALFLAT(drive_gf->data_in), src/hw/usb-uas.c: ret = usb_send_bulk(GET_GLOBALFLAT(drive_gf->data_out), src/hw/usb-uas.c: ret = usb_send_bulk(GET_GLOBALFLAT(drive_gf->status),
plus others that use drive_gf in the name and should probably be changed too:
src/block.c: struct atadrive_s *adrive_gf = container_of( src/block.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/block.c: u8 slave = GET_GLOBALFLAT(adrive_gf->slave); src/cdrom.c:struct drive_s *emulated_drive_gf VARLOW; src/cdrom.c: emulated_drive_gf = drive; src/hw/ata.c:ata_reset(struct atadrive_s *adrive_gf) src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c: u8 slave = GET_GLOBALFLAT(adrive_gf->slave); src/hw/ata.c: dprintf(6, "ata_reset drive=%p\n", &adrive_gf->drive); src/hw/ata.c: u8 type=GET_GLOBALFLAT(adrive_gf->drive.type); src/hw/ata.c:isready(struct atadrive_s *adrive_gf) src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c:send_cmd(struct atadrive_s *adrive_gf, struct ata_pio_command *cmd) src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c: u8 slave = GET_GLOBALFLAT(adrive_gf->slave); src/hw/ata.c:ata_cmd_nondata(struct atadrive_s *adrive_gf, struct ata_pio_command *cmd) src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c: int ret = send_cmd(adrive_gf, cmd); src/hw/ata.c: struct atadrive_s *adrive_gf = container_of( src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c: struct atadrive_s *adrive_gf = container_of( src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c: struct atadrive_s *adrive_gf = container_of( src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c: struct atadrive_s *adrive_gf = container_of( src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c: int ret = send_cmd(adrive_gf, cmd); src/hw/ata.c: struct atadrive_s *adrive_gf = container_of( src/hw/ata.c: int ret = send_cmd(adrive_gf, cmd); src/hw/ata.c: struct atadrive_s *adrive_gf = container_of( src/hw/ata.c: ata_reset(adrive_gf); src/hw/ata.c: return isready(adrive_gf); src/hw/ata.c: struct atadrive_s *adrive_gf = container_of( src/hw/ata.c: struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf); src/hw/ata.c: int ret = send_cmd(adrive_gf, &cmd); src/hw/usb-msc.c:usb_msc_send(struct usbdrive_s *udrive_gf, int dir, void *buf, u32 bytes) src/hw/usb-msc.c: pipe = GET_GLOBALFLAT(udrive_gf->bulkout); src/hw/usb-msc.c: pipe = GET_GLOBALFLAT(udrive_gf->bulkin); src/hw/usb-msc.c: struct usbdrive_s *udrive_gf = container_of( src/hw/usb-msc.c: cbw.bCBWLUN = GET_GLOBALFLAT(udrive_gf->lun); src/hw/usb-msc.c: int ret = usb_msc_send(udrive_gf, USB_DIR_OUT src/hw/usb-msc.c: ret = usb_msc_send(udrive_gf, cbw.bmCBWFlags, op->buf_fl, bytes); src/hw/usb-msc.c: ret = usb_msc_send(udrive_gf, USB_DIR_IN src/hw/virtio-blk.c: struct virtiodrive_s *vdrive_gf = src/hw/virtio-blk.c: struct vring_virtqueue *vq = vdrive_gf->vq; src/hw/virtio-blk.c: .length = vdrive_gf->drive.blksize * op->count, src/hw/virtio-blk.c: vring_kick(&vdrive_gf->vp, vq, 1); src/hw/virtio-blk.c: vp_get_isr(&vdrive_gf->vp);
Thanks,
Paolo
On 27/09/2017 16:56, Paolo Bonzini wrote:
On 11/07/2017 18:50, Kevin O'Connor wrote:
Now that the drive_s struct does not need to be in the f-segment, rename references to drive_gf in the generic drive code to drive_fl.
This is just variable renames - no code changes.
Signed-off-by: Kevin O'Connor kevin@koconnor.net
There are still quite a few:
Nevermind, these would be handled as in patch 4.
Paolo
On Wed, Sep 27, 2017 at 04:56:05PM +0200, Paolo Bonzini wrote:
On 11/07/2017 18:50, Kevin O'Connor wrote:
Now that the drive_s struct does not need to be in the f-segment, rename references to drive_gf in the generic drive code to drive_fl.
This is just variable renames - no code changes.
Signed-off-by: Kevin O'Connor kevin@koconnor.net
There are still quite a few:
src/block.c:fill_ata_edd(struct segoff_s edd, struct drive_s *drive_gf) src/block.c: drive_gf, struct atadrive_s, drive); src/block.c: if (GET_GLOBALFLAT(drive_gf->type) == DTYPE_ATA) { src/block.c: u8 translation = GET_GLOBALFLAT(drive_gf->translation); src/block.c: edd, drive_gf, SEGOFF(SEG_LOW, (u32)&DefaultDPTE).segoff
If the 'struct drive_s' was known to be allocated with malloc_fseg() (and thus GET_GLOBALFLAT() is valid), then I tried to leave the variable as drive_gf. In the above, the ATA drives are still allocated with malloc_fseg() so I didn't change them.
src/block.h:int fill_edd(struct segoff_s edd, struct drive_s *drive_gf);
This one was an oversight - thanks.
-Kevin
Use the "low" memory segment instead of the f-segment for the drive_s storage. This can help avoid running out of memory in the f-segment.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/hw/virtio-blk.c | 12 ++++++------ src/hw/virtio-ring.c | 1 - src/hw/virtio-scsi.c | 3 +-- 3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/hw/virtio-blk.c b/src/hw/virtio-blk.c index ad16200..88d7e54 100644 --- a/src/hw/virtio-blk.c +++ b/src/hw/virtio-blk.c @@ -32,9 +32,9 @@ struct virtiodrive_s { static int virtio_blk_op(struct disk_op_s *op, int write) { - struct virtiodrive_s *vdrive_gf = + struct virtiodrive_s *vdrive = container_of(op->drive_fl, struct virtiodrive_s, drive); - struct vring_virtqueue *vq = vdrive_gf->vq; + struct vring_virtqueue *vq = vdrive->vq; struct virtio_blk_outhdr hdr = { .type = write ? VIRTIO_BLK_T_OUT : VIRTIO_BLK_T_IN, .ioprio = 0, @@ -48,7 +48,7 @@ virtio_blk_op(struct disk_op_s *op, int write) }, { .addr = op->buf_fl, - .length = vdrive_gf->drive.blksize * op->count, + .length = vdrive->drive.blksize * op->count, }, { .addr = (void*)(&status), @@ -61,7 +61,7 @@ virtio_blk_op(struct disk_op_s *op, int write) vring_add_buf(vq, sg, 2, 1, 0, 0); else vring_add_buf(vq, sg, 1, 2, 0, 0); - vring_kick(&vdrive_gf->vp, vq, 1); + vring_kick(&vdrive->vp, vq, 1);
/* Wait for reply */ while (!vring_more_used(vq)) @@ -73,7 +73,7 @@ virtio_blk_op(struct disk_op_s *op, int write) /* Clear interrupt status register. Avoid leaving interrupts stuck if * VRING_AVAIL_F_NO_INTERRUPT was ignored and interrupts were raised. */ - vp_get_isr(&vdrive_gf->vp); + vp_get_isr(&vdrive->vp);
return status == VIRTIO_BLK_S_OK ? DISK_RET_SUCCESS : DISK_RET_EBADTRACK; } @@ -99,7 +99,7 @@ init_virtio_blk(void *data) struct pci_device *pci = data; u8 status = VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER; dprintf(1, "found virtio-blk at %pP\n", pci); - struct virtiodrive_s *vdrive = malloc_fseg(sizeof(*vdrive)); + struct virtiodrive_s *vdrive = malloc_low(sizeof(*vdrive)); if (!vdrive) { warn_noalloc(); return; diff --git a/src/hw/virtio-ring.c b/src/hw/virtio-ring.c index 7205a0a..0ed3189 100644 --- a/src/hw/virtio-ring.c +++ b/src/hw/virtio-ring.c @@ -16,7 +16,6 @@ * */
-#include "biosvar.h" // GET_GLOBAL #include "output.h" // panic #include "virtio-ring.h" #include "virtio-pci.h" diff --git a/src/hw/virtio-scsi.c b/src/hw/virtio-scsi.c index 466b305..a87cad8 100644 --- a/src/hw/virtio-scsi.c +++ b/src/hw/virtio-scsi.c @@ -7,7 +7,6 @@ // // This file may be distributed under the terms of the GNU LGPLv3 license.
-#include "biosvar.h" // GET_GLOBALFLAT #include "block.h" // struct drive_s #include "blockcmd.h" // scsi_drive_setup #include "config.h" // CONFIG_* @@ -114,7 +113,7 @@ virtio_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv) { struct virtio_lun_s *tmpl_vlun = container_of(tmpl_drv, struct virtio_lun_s, drive); - struct virtio_lun_s *vlun = malloc_fseg(sizeof(*vlun)); + struct virtio_lun_s *vlun = malloc_low(sizeof(*vlun)); if (!vlun) { warn_noalloc(); return -1;
On 11/07/2017 18:50, Kevin O'Connor wrote:
This series updates the generic code so that either "low" memory or the f-segment can be used for storing drive mapping information. It also updates the virtio code to use "low" memory for its allocations. I think there is a good chance this series will, in practice, avoid running out of memory when a large number of virtio drives are available.
There are other ways to tackle this problem (eg, more of the virtio storage could be moved into "high" memory), but I think this approach has the benefit of avoiding a "big bang" patch series.
Comments welcome.
Tested-by: Paolo Bonzini pbonzini@redhat.com
Thank you very much for the fix! It would be nice to have it in 1.11.
Paolo
-Kevin
Kevin O'Connor (4): boot: Rename drive_g to drive disk: Don't require the 'struct drive_s' to be in the f-segment block: Rename disk_op_s->drive_gf to drive_fl virtio: Allocate drive_s storage in low memory
src/block.c | 36 ++++----- src/block.h | 2 +- src/boot.c | 16 ++-- src/cdrom.c | 6 +- src/disk.c | 218 +++++++++++++++++++++++++-------------------------- src/hw/ahci.c | 4 +- src/hw/ata.c | 26 +++--- src/hw/blockcmd.c | 10 +-- src/hw/esp-scsi.c | 2 +- src/hw/floppy.c | 20 ++--- src/hw/lsi-scsi.c | 2 +- src/hw/megasas.c | 2 +- src/hw/mpt-scsi.c | 2 +- src/hw/nvme.c | 2 +- src/hw/pvscsi.c | 2 +- src/hw/ramdisk.c | 2 +- src/hw/sdcard.c | 2 +- src/hw/usb-msc.c | 4 +- src/hw/usb-uas.c | 2 +- src/hw/virtio-blk.c | 14 ++-- src/hw/virtio-ring.c | 1 - src/hw/virtio-scsi.c | 5 +- 22 files changed, 189 insertions(+), 191 deletions(-)
On Wed, Sep 27, 2017 at 04:49:50PM +0200, Paolo Bonzini wrote:
On 11/07/2017 18:50, Kevin O'Connor wrote:
This series updates the generic code so that either "low" memory or the f-segment can be used for storing drive mapping information. It also updates the virtio code to use "low" memory for its allocations. I think there is a good chance this series will, in practice, avoid running out of memory when a large number of virtio drives are available.
There are other ways to tackle this problem (eg, more of the virtio storage could be moved into "high" memory), but I think this approach has the benefit of avoiding a "big bang" patch series.
Comments welcome.
Tested-by: Paolo Bonzini pbonzini@redhat.com
Thank you very much for the fix! It would be nice to have it in 1.11.
Thanks. I committed this series.
-Kevin