[SeaBIOS] [PATCH 2/4] disk: Don't require the 'struct drive_s' to be in the f-segment
Kevin O'Connor
kevin at koconnor.net
Tue Jul 11 18:50:30 CEST 2017
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 at 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;
--
2.9.4
More information about the SeaBIOS
mailing list