summaryrefslogtreecommitdiff
path: root/roms/seabios/src/disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'roms/seabios/src/disk.c')
-rw-r--r--roms/seabios/src/disk.c338
1 files changed, 157 insertions, 181 deletions
diff --git a/roms/seabios/src/disk.c b/roms/seabios/src/disk.c
index 0291fe3e0..4421d9d72 100644
--- a/roms/seabios/src/disk.c
+++ b/roms/seabios/src/disk.c
@@ -5,45 +5,23 @@
//
// This file may be distributed under the terms of the GNU LGPLv3 license.
-#include "disk.h" // floppy_13
#include "biosvar.h" // SET_BDA
-#include "config.h" // CONFIG_*
-#include "util.h" // debug_enter
-#include "pic.h" // eoi_pic2
#include "bregs.h" // struct bregs
-#include "pci.h" // pci_bdf_to_bus
-#include "ata.h" // ATA_CB_DC
+#include "config.h" // CONFIG_*
+#include "hw/ata.h" // ATA_CB_DC
+#include "hw/pci.h" // pci_bdf_to_bus
+#include "hw/pic.h" // pic_eoi2
+#include "output.h" // debug_enter
+#include "stacks.h" // call16_int
+#include "std/disk.h" // DISK_RET_SUCCESS
+#include "string.h" // memset
+#include "util.h" // CDRom_locks
/****************************************************************
* Helper functions
****************************************************************/
-void
-__disk_ret(struct bregs *regs, u32 linecode, const char *fname)
-{
- u8 code = linecode;
- if (regs->dl < EXTSTART_HD)
- SET_BDA(floppy_last_status, code);
- else
- SET_BDA(disk_last_status, code);
- if (code)
- __set_code_invalid(regs, linecode, fname);
- else
- set_code_success(regs);
-}
-
-void
-__disk_ret_unimplemented(struct bregs *regs, u32 linecode, const char *fname)
-{
- u8 code = linecode;
- if (regs->dl < EXTSTART_HD)
- SET_BDA(floppy_last_status, code);
- else
- SET_BDA(disk_last_status, code);
- __set_code_unimplemented(regs, linecode, fname);
-}
-
static void
__disk_stub(struct bregs *regs, int lineno, const char *fname)
{
@@ -56,32 +34,31 @@ __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_g)
+getLCHS(struct drive_s *drive_gf)
{
struct chs_s res = { };
- if (CONFIG_CDROM_EMU
- && drive_g == GLOBALFLAT2GLOBAL(GET_GLOBAL(cdemu_drive_gf))) {
+ if (CONFIG_CDROM_EMU && drive_gf == 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
// read-only).
- res.cylinders = GET_LOW(CDEmu.lchs.cylinders);
- res.heads = GET_LOW(CDEmu.lchs.heads);
- res.spt = GET_LOW(CDEmu.lchs.spt);
+ res.cylinder = GET_LOW(CDEmu.lchs.cylinder);
+ res.head = GET_LOW(CDEmu.lchs.head);
+ res.sector = GET_LOW(CDEmu.lchs.sector);
return res;
}
- res.cylinders = GET_GLOBAL(drive_g->lchs.cylinders);
- res.heads = GET_GLOBAL(drive_g->lchs.heads);
- res.spt = GET_GLOBAL(drive_g->lchs.spt);
+ res.cylinder = GET_GLOBALFLAT(drive_gf->lchs.cylinder);
+ res.head = GET_GLOBALFLAT(drive_gf->lchs.head);
+ res.sector = GET_GLOBALFLAT(drive_gf->lchs.sector);
return res;
}
// Perform read/write/verify using old-style chs accesses
static void noinline
-basic_access(struct bregs *regs, struct drive_s *drive_g, u16 command)
+basic_access(struct bregs *regs, struct drive_s *drive_gf, u16 command)
{
struct disk_op_s dop;
- dop.drive_g = drive_g;
+ dop.drive_gf = drive_gf;
dop.command = command;
u8 count = regs->al;
@@ -96,18 +73,18 @@ basic_access(struct bregs *regs, struct drive_s *drive_g, u16 command)
}
dop.count = count;
- struct chs_s chs = getLCHS(drive_g);
- u16 nlc=chs.cylinders, nlh=chs.heads, nlspt=chs.spt;
+ struct chs_s chs = getLCHS(drive_gf);
+ u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector;
// sanity check on cyl heads, sec
- if (cylinder >= nlc || head >= nlh || sector > nlspt) {
+ if (cylinder >= nlc || head >= nlh || sector > nls) {
warn_invalid(regs);
disk_ret(regs, DISK_RET_EPARAM);
return;
}
// translate lchs to lba
- dop.lba = (((((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nlspt)
+ dop.lba = (((((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nls)
+ (u32)sector - 1);
dop.buf_fl = MAKE_FLATPTR(regs->es, regs->bx);
@@ -121,15 +98,15 @@ basic_access(struct bregs *regs, struct drive_s *drive_g, u16 command)
// Perform read/write/verify using new-style "int13ext" accesses.
static void noinline
-extended_access(struct bregs *regs, struct drive_s *drive_g, u16 command)
+extended_access(struct bregs *regs, struct drive_s *drive_gf, 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_g = drive_g;
- if (dop.lba >= GET_GLOBAL(drive_g->sectors)) {
+ dop.drive_gf = drive_gf;
+ if (dop.lba >= GET_GLOBALFLAT(drive_gf->sectors)) {
warn_invalid(regs);
disk_ret(regs, DISK_RET_EPARAM);
return;
@@ -157,10 +134,10 @@ extended_access(struct bregs *regs, struct drive_s *drive_g, u16 command)
// disk controller reset
static void
-disk_1300(struct bregs *regs, struct drive_s *drive_g)
+disk_1300(struct bregs *regs, struct drive_s *drive_gf)
{
struct disk_op_s dop;
- dop.drive_g = drive_g;
+ dop.drive_gf = drive_gf;
dop.command = CMD_RESET;
int status = send_disk_op(&dop);
disk_ret(regs, status);
@@ -168,7 +145,7 @@ disk_1300(struct bregs *regs, struct drive_s *drive_g)
// read disk status
static void
-disk_1301(struct bregs *regs, struct drive_s *drive_g)
+disk_1301(struct bregs *regs, struct drive_s *drive_gf)
{
u8 v;
if (regs->dl < EXTSTART_HD)
@@ -183,47 +160,48 @@ disk_1301(struct bregs *regs, struct drive_s *drive_g)
// read disk sectors
static void
-disk_1302(struct bregs *regs, struct drive_s *drive_g)
+disk_1302(struct bregs *regs, struct drive_s *drive_gf)
{
- basic_access(regs, drive_g, CMD_READ);
+ basic_access(regs, drive_gf, CMD_READ);
}
// write disk sectors
static void
-disk_1303(struct bregs *regs, struct drive_s *drive_g)
+disk_1303(struct bregs *regs, struct drive_s *drive_gf)
{
- basic_access(regs, drive_g, CMD_WRITE);
+ basic_access(regs, drive_gf, CMD_WRITE);
}
// verify disk sectors
static void
-disk_1304(struct bregs *regs, struct drive_s *drive_g)
+disk_1304(struct bregs *regs, struct drive_s *drive_gf)
{
- basic_access(regs, drive_g, CMD_VERIFY);
+ basic_access(regs, drive_gf, CMD_VERIFY);
}
// format disk track
static void noinline
-disk_1305(struct bregs *regs, struct drive_s *drive_g)
+disk_1305(struct bregs *regs, struct drive_s *drive_gf)
{
debug_stub(regs);
- struct chs_s chs = getLCHS(drive_g);
- u16 nlh=chs.heads, nlspt=chs.spt;
+ struct chs_s chs = getLCHS(drive_gf);
+ u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector;
- u8 num_sectors = regs->al;
- u8 head = regs->dh;
+ u8 count = regs->al;
+ u8 cylinder = regs->ch;
+ u8 head = regs->dh;
- if (head >= nlh || num_sectors == 0 || num_sectors > nlspt) {
+ if (cylinder >= nlc || head >= nlh || count == 0 || count > nls) {
disk_ret(regs, DISK_RET_EPARAM);
return;
}
struct disk_op_s dop;
- dop.drive_g = drive_g;
+ dop.drive_gf = drive_gf;
dop.command = CMD_FORMAT;
- dop.lba = head;
- dop.count = num_sectors;
+ dop.lba = (((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nls;
+ dop.count = count;
dop.buf_fl = MAKE_FLATPTR(regs->es, regs->bx);
int status = send_disk_op(&dop);
disk_ret(regs, status);
@@ -231,11 +209,11 @@ disk_1305(struct bregs *regs, struct drive_s *drive_g)
// read disk drive parameters
static void noinline
-disk_1308(struct bregs *regs, struct drive_s *drive_g)
+disk_1308(struct bregs *regs, struct drive_s *drive_gf)
{
// Get logical geometry from table
- struct chs_s chs = getLCHS(drive_g);
- u16 nlc=chs.cylinders, nlh=chs.heads, nlspt=chs.spt;
+ struct chs_s chs = getLCHS(drive_gf);
+ u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector;
nlc--;
nlh--;
u8 count;
@@ -243,11 +221,10 @@ disk_1308(struct bregs *regs, struct drive_s *drive_g)
// Floppy
count = GET_GLOBAL(FloppyCount);
- if (CONFIG_CDROM_EMU
- && drive_g == GLOBALFLAT2GLOBAL(GET_GLOBAL(cdemu_drive_gf)))
+ if (CONFIG_CDROM_EMU && drive_gf == GET_GLOBAL(cdemu_drive_gf))
regs->bx = GET_LOW(CDEmu.media) * 2;
else
- regs->bx = GET_GLOBAL(drive_g->floppy_type);
+ regs->bx = GET_GLOBALFLAT(drive_gf->floppy_type);
// set es & di to point to 11 byte diskette param table in ROM
regs->es = SEG_BIOS;
@@ -274,7 +251,7 @@ disk_1308(struct bregs *regs, struct drive_s *drive_g)
regs->al = 0;
regs->ch = nlc & 0xff;
- regs->cl = ((nlc >> 2) & 0xc0) | (nlspt & 0x3f);
+ regs->cl = ((nlc >> 2) & 0xc0) | (nls & 0x3f);
regs->dh = nlh;
disk_ret(regs, DISK_RET_SUCCESS);
@@ -283,33 +260,33 @@ disk_1308(struct bregs *regs, struct drive_s *drive_g)
// initialize drive parameters
static void
-disk_1309(struct bregs *regs, struct drive_s *drive_g)
+disk_1309(struct bregs *regs, struct drive_s *drive_gf)
{
DISK_STUB(regs);
}
// seek to specified cylinder
static void
-disk_130c(struct bregs *regs, struct drive_s *drive_g)
+disk_130c(struct bregs *regs, struct drive_s *drive_gf)
{
DISK_STUB(regs);
}
// alternate disk reset
static void
-disk_130d(struct bregs *regs, struct drive_s *drive_g)
+disk_130d(struct bregs *regs, struct drive_s *drive_gf)
{
DISK_STUB(regs);
}
// check drive ready
static void
-disk_1310(struct bregs *regs, struct drive_s *drive_g)
+disk_1310(struct bregs *regs, struct drive_s *drive_gf)
{
// should look at 40:8E also???
struct disk_op_s dop;
- dop.drive_g = drive_g;
+ dop.drive_gf = drive_gf;
dop.command = CMD_ISREADY;
int status = send_disk_op(&dop);
disk_ret(regs, status);
@@ -317,21 +294,21 @@ disk_1310(struct bregs *regs, struct drive_s *drive_g)
// recalibrate
static void
-disk_1311(struct bregs *regs, struct drive_s *drive_g)
+disk_1311(struct bregs *regs, struct drive_s *drive_gf)
{
DISK_STUB(regs);
}
// controller internal diagnostic
static void
-disk_1314(struct bregs *regs, struct drive_s *drive_g)
+disk_1314(struct bregs *regs, struct drive_s *drive_gf)
{
DISK_STUB(regs);
}
// read disk drive size
static void noinline
-disk_1315(struct bregs *regs, struct drive_s *drive_g)
+disk_1315(struct bregs *regs, struct drive_s *drive_gf)
{
disk_ret(regs, DISK_RET_SUCCESS);
if (regs->dl < EXTSTART_HD || regs->dl >= EXTSTART_CD) {
@@ -342,18 +319,18 @@ disk_1315(struct bregs *regs, struct drive_s *drive_g)
// Hard drive
// Get logical geometry from table
- struct chs_s chs = getLCHS(drive_g);
- u16 nlc=chs.cylinders, nlh=chs.heads, nlspt=chs.spt;
+ struct chs_s chs = getLCHS(drive_gf);
+ u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector;
// Compute sector count seen by int13
- u32 lba = (u32)(nlc - 1) * (u32)nlh * (u32)nlspt;
+ u32 lba = (u32)(nlc - 1) * (u32)nlh * (u32)nls;
regs->cx = lba >> 16;
regs->dx = lba & 0xffff;
regs->ah = 3; // hard disk accessible
}
static void
-disk_1316(struct bregs *regs, struct drive_s *drive_g)
+disk_1316(struct bregs *regs, struct drive_s *drive_gf)
{
if (regs->dl >= EXTSTART_HD) {
// Hard drive
@@ -365,7 +342,7 @@ disk_1316(struct bregs *regs, struct drive_s *drive_g)
// IBM/MS installation check
static void
-disk_1341(struct bregs *regs, struct drive_s *drive_g)
+disk_1341(struct bregs *regs, struct drive_s *drive_gf)
{
regs->bx = 0xaa55; // install check
regs->cx = 0x0007; // ext disk access and edd, removable supported
@@ -375,28 +352,28 @@ disk_1341(struct bregs *regs, struct drive_s *drive_g)
// IBM/MS extended read
static void
-disk_1342(struct bregs *regs, struct drive_s *drive_g)
+disk_1342(struct bregs *regs, struct drive_s *drive_gf)
{
- extended_access(regs, drive_g, CMD_READ);
+ extended_access(regs, drive_gf, CMD_READ);
}
// IBM/MS extended write
static void
-disk_1343(struct bregs *regs, struct drive_s *drive_g)
+disk_1343(struct bregs *regs, struct drive_s *drive_gf)
{
- extended_access(regs, drive_g, CMD_WRITE);
+ extended_access(regs, drive_gf, CMD_WRITE);
}
// IBM/MS verify
static void
-disk_1344(struct bregs *regs, struct drive_s *drive_g)
+disk_1344(struct bregs *regs, struct drive_s *drive_gf)
{
- extended_access(regs, drive_g, CMD_VERIFY);
+ extended_access(regs, drive_gf, CMD_VERIFY);
}
// lock
static void
-disk_134500(struct bregs *regs, struct drive_s *drive_g)
+disk_134500(struct bregs *regs, struct drive_s *drive_gf)
{
int cdid = regs->dl - EXTSTART_CD;
u8 locks = GET_LOW(CDRom_locks[cdid]);
@@ -412,7 +389,7 @@ disk_134500(struct bregs *regs, struct drive_s *drive_g)
// unlock
static void
-disk_134501(struct bregs *regs, struct drive_s *drive_g)
+disk_134501(struct bregs *regs, struct drive_s *drive_gf)
{
int cdid = regs->dl - EXTSTART_CD;
u8 locks = GET_LOW(CDRom_locks[cdid]);
@@ -429,7 +406,7 @@ disk_134501(struct bregs *regs, struct drive_s *drive_g)
// status
static void
-disk_134502(struct bregs *regs, struct drive_s *drive_g)
+disk_134502(struct bregs *regs, struct drive_s *drive_gf)
{
int cdid = regs->dl - EXTSTART_CD;
u8 locks = GET_LOW(CDRom_locks[cdid]);
@@ -438,14 +415,14 @@ disk_134502(struct bregs *regs, struct drive_s *drive_g)
}
static void
-disk_1345XX(struct bregs *regs, struct drive_s *drive_g)
+disk_1345XX(struct bregs *regs, struct drive_s *drive_gf)
{
disk_ret_unimplemented(regs, DISK_RET_EPARAM);
}
// IBM/MS lock/unlock drive
static void
-disk_1345(struct bregs *regs, struct drive_s *drive_g)
+disk_1345(struct bregs *regs, struct drive_s *drive_gf)
{
if (regs->dl < EXTSTART_CD) {
// Always success for HD
@@ -454,16 +431,16 @@ disk_1345(struct bregs *regs, struct drive_s *drive_g)
}
switch (regs->al) {
- case 0x00: disk_134500(regs, drive_g); break;
- case 0x01: disk_134501(regs, drive_g); break;
- case 0x02: disk_134502(regs, drive_g); break;
- default: disk_1345XX(regs, drive_g); break;
+ 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;
}
}
// IBM/MS eject media
static void noinline
-disk_1346(struct bregs *regs, struct drive_s *drive_g)
+disk_1346(struct bregs *regs, struct drive_s *drive_gf)
{
if (regs->dl < EXTSTART_CD) {
// Volume Not Removable
@@ -497,14 +474,14 @@ disk_1346(struct bregs *regs, struct drive_s *drive_g)
// IBM/MS extended seek
static void
-disk_1347(struct bregs *regs, struct drive_s *drive_g)
+disk_1347(struct bregs *regs, struct drive_s *drive_gf)
{
- extended_access(regs, drive_g, CMD_SEEK);
+ extended_access(regs, drive_gf, CMD_SEEK);
}
// IBM/MS get drive parameters
static void noinline
-disk_1348(struct bregs *regs, struct drive_s *drive_g)
+disk_1348(struct bregs *regs, struct drive_s *drive_gf)
{
u16 seg = regs->ds;
struct int13dpt_s *param_far = (struct int13dpt_s*)(regs->si+0);
@@ -519,15 +496,15 @@ disk_1348(struct bregs *regs, struct drive_s *drive_g)
// EDD 1.x
- u8 type = GET_GLOBAL(drive_g->type);
- u16 npc = GET_GLOBAL(drive_g->pchs.cylinders);
- u16 nph = GET_GLOBAL(drive_g->pchs.heads);
- u16 npspt = GET_GLOBAL(drive_g->pchs.spt);
- u64 lba = GET_GLOBAL(drive_g->sectors);
- u16 blksize = GET_GLOBAL(drive_g->blksize);
+ 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);
dprintf(DEBUG_HDL_13, "disk_1348 size=%d t=%d chs=%d,%d,%d lba=%d bs=%d\n"
- , size, type, npc, nph, npspt, (u32)lba, blksize);
+ , size, type, npc, nph, nps, (u32)lba, blksize);
SET_FARVAR(seg, param_far->size, 26);
if (type == DTYPE_ATA_ATAPI) {
@@ -538,7 +515,7 @@ disk_1348(struct bregs *regs, struct drive_s *drive_g)
SET_FARVAR(seg, param_far->spt, 0xffffffff);
SET_FARVAR(seg, param_far->sector_count, (u64)-1);
} else {
- if (lba > (u64)npspt*nph*0x3fff) {
+ if (lba > (u64)nps*nph*0x3fff) {
SET_FARVAR(seg, param_far->infos, 0x00); // geometry is invalid
SET_FARVAR(seg, param_far->cylinders, 0x3fff);
} else {
@@ -546,7 +523,7 @@ disk_1348(struct bregs *regs, struct drive_s *drive_g)
SET_FARVAR(seg, param_far->cylinders, (u32)npc);
}
SET_FARVAR(seg, param_far->heads, (u32)nph);
- SET_FARVAR(seg, param_far->spt, (u32)npspt);
+ SET_FARVAR(seg, param_far->spt, (u32)nps);
SET_FARVAR(seg, param_far->sector_count, lba);
}
SET_FARVAR(seg, param_far->blksize, blksize);
@@ -569,10 +546,10 @@ disk_1348(struct bregs *regs, struct drive_s *drive_g)
SET_FARVAR(seg, param_far->dpte, SEGOFF(SEG_LOW, (u32)&DefaultDPTE));
// Fill in dpte
- struct atadrive_s *adrive_g = container_of(
- drive_g, struct atadrive_s, drive);
- struct ata_channel_s *chan_gf = GET_GLOBAL(adrive_g->chan_gf);
- u8 slave = GET_GLOBAL(adrive_g->slave);
+ struct atadrive_s *adrive_gf = container_of(
+ drive_gf, struct atadrive_s, drive);
+ struct ata_channel_s *chan_gf = GET_GLOBALFLAT(adrive_gf->chan_gf);
+ u8 slave = GET_GLOBALFLAT(adrive_gf->slave);
u16 iobase2 = GET_GLOBALFLAT(chan_gf->iobase2);
u8 irq = GET_GLOBALFLAT(chan_gf->irq);
iobase1 = GET_GLOBALFLAT(chan_gf->iobase1);
@@ -582,7 +559,7 @@ disk_1348(struct bregs *regs, struct drive_s *drive_g)
u16 options = 0;
if (type == DTYPE_ATA) {
- u8 translation = GET_GLOBAL(drive_g->translation);
+ u8 translation = GET_GLOBALFLAT(drive_gf->translation);
if (translation != TRANSLATION_NONE) {
options |= 1<<3; // CHS translation
if (translation == TRANSLATION_LBA)
@@ -616,7 +593,7 @@ disk_1348(struct bregs *regs, struct drive_s *drive_g)
SET_LOW(DefaultDPTE.checksum, -sum);
} else {
SET_FARVAR(seg, param_far->dpte.segoff, 0xffffffff);
- bdf = GET_GLOBAL(drive_g->cntl_id);
+ bdf = GET_GLOBALFLAT(drive_gf->cntl_id);
}
if (size < 66) {
@@ -686,7 +663,7 @@ disk_1348(struct bregs *regs, struct drive_s *drive_g)
// IBM/MS extended media change
static void
-disk_1349(struct bregs *regs, struct drive_s *drive_g)
+disk_1349(struct bregs *regs, struct drive_s *drive_gf)
{
if (regs->dl < EXTSTART_CD) {
// Always success for HD
@@ -699,56 +676,56 @@ disk_1349(struct bregs *regs, struct drive_s *drive_g)
}
static void
-disk_134e01(struct bregs *regs, struct drive_s *drive_g)
+disk_134e01(struct bregs *regs, struct drive_s *drive_gf)
{
disk_ret(regs, DISK_RET_SUCCESS);
}
static void
-disk_134e03(struct bregs *regs, struct drive_s *drive_g)
+disk_134e03(struct bregs *regs, struct drive_s *drive_gf)
{
disk_ret(regs, DISK_RET_SUCCESS);
}
static void
-disk_134e04(struct bregs *regs, struct drive_s *drive_g)
+disk_134e04(struct bregs *regs, struct drive_s *drive_gf)
{
disk_ret(regs, DISK_RET_SUCCESS);
}
static void
-disk_134e06(struct bregs *regs, struct drive_s *drive_g)
+disk_134e06(struct bregs *regs, struct drive_s *drive_gf)
{
disk_ret(regs, DISK_RET_SUCCESS);
}
static void
-disk_134eXX(struct bregs *regs, struct drive_s *drive_g)
+disk_134eXX(struct bregs *regs, struct drive_s *drive_gf)
{
disk_ret(regs, DISK_RET_EPARAM);
}
// IBM/MS set hardware configuration
static void
-disk_134e(struct bregs *regs, struct drive_s *drive_g)
+disk_134e(struct bregs *regs, struct drive_s *drive_gf)
{
switch (regs->al) {
- case 0x01: disk_134e01(regs, drive_g); break;
- case 0x03: disk_134e03(regs, drive_g); break;
- case 0x04: disk_134e04(regs, drive_g); break;
- case 0x06: disk_134e06(regs, drive_g); break;
- default: disk_134eXX(regs, drive_g); break;
+ 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;
}
}
static void
-disk_13XX(struct bregs *regs, struct drive_s *drive_g)
+disk_13XX(struct bregs *regs, struct drive_s *drive_gf)
{
disk_ret_unimplemented(regs, DISK_RET_EPARAM);
}
static void
-disk_13(struct bregs *regs, struct drive_s *drive_g)
+disk_13(struct bregs *regs, struct drive_s *drive_gf)
{
//debug_stub(regs);
@@ -756,37 +733,37 @@ disk_13(struct bregs *regs, struct drive_s *drive_g)
SET_BDA(disk_interrupt_flag, 0);
switch (regs->ah) {
- case 0x00: disk_1300(regs, drive_g); break;
- case 0x01: disk_1301(regs, drive_g); break;
- case 0x02: disk_1302(regs, drive_g); break;
- case 0x03: disk_1303(regs, drive_g); break;
- case 0x04: disk_1304(regs, drive_g); break;
- case 0x05: disk_1305(regs, drive_g); break;
- case 0x08: disk_1308(regs, drive_g); break;
- case 0x09: disk_1309(regs, drive_g); break;
- case 0x0c: disk_130c(regs, drive_g); break;
- case 0x0d: disk_130d(regs, drive_g); break;
- case 0x10: disk_1310(regs, drive_g); break;
- case 0x11: disk_1311(regs, drive_g); break;
- case 0x14: disk_1314(regs, drive_g); break;
- case 0x15: disk_1315(regs, drive_g); break;
- case 0x16: disk_1316(regs, drive_g); break;
- case 0x41: disk_1341(regs, drive_g); break;
- case 0x42: disk_1342(regs, drive_g); break;
- case 0x43: disk_1343(regs, drive_g); break;
- case 0x44: disk_1344(regs, drive_g); break;
- case 0x45: disk_1345(regs, drive_g); break;
- case 0x46: disk_1346(regs, drive_g); break;
- case 0x47: disk_1347(regs, drive_g); break;
- case 0x48: disk_1348(regs, drive_g); break;
- case 0x49: disk_1349(regs, drive_g); break;
- case 0x4e: disk_134e(regs, drive_g); break;
- default: disk_13XX(regs, drive_g); break;
- }
-}
-
-static void
-floppy_13(struct bregs *regs, struct drive_s *drive_g)
+ 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;
+ }
+}
+
+static void
+floppy_13(struct bregs *regs, struct drive_s *drive_gf)
{
// Only limited commands are supported on floppies.
switch (regs->ah) {
@@ -799,9 +776,9 @@ floppy_13(struct bregs *regs, struct drive_s *drive_g)
case 0x08:
case 0x15:
case 0x16:
- disk_13(regs, drive_g);
+ disk_13(regs, drive_gf);
break;
- default: disk_13XX(regs, drive_g); break;
+ default: disk_13XX(regs, drive_gf); break;
}
}
@@ -820,21 +797,21 @@ handle_legacy_disk(struct bregs *regs, u8 extdrive)
}
if (extdrive < EXTSTART_HD) {
- struct drive_s *drive_g = getDrive(EXTTYPE_FLOPPY, extdrive);
- if (!drive_g)
+ struct drive_s *drive_gf = getDrive(EXTTYPE_FLOPPY, extdrive);
+ if (!drive_gf)
goto fail;
- floppy_13(regs, drive_g);
+ floppy_13(regs, drive_gf);
return;
}
- struct drive_s *drive_g;
+ struct drive_s *drive_gf;
if (extdrive >= EXTSTART_CD)
- drive_g = getDrive(EXTTYPE_CD, extdrive - EXTSTART_CD);
+ drive_gf = getDrive(EXTTYPE_CD, extdrive - EXTSTART_CD);
else
- drive_g = getDrive(EXTTYPE_HD, extdrive - EXTSTART_HD);
- if (!drive_g)
+ drive_gf = getDrive(EXTTYPE_HD, extdrive - EXTSTART_HD);
+ if (!drive_gf)
goto fail;
- disk_13(regs, drive_g);
+ disk_13(regs, drive_gf);
return;
fail:
@@ -865,14 +842,13 @@ handle_13(struct bregs *regs)
u8 emudrive = GET_LOW(CDEmu.emulated_extdrive);
if (extdrive == emudrive) {
// Access to an emulated drive.
- struct drive_s *cdemu_g;
- cdemu_g = GLOBALFLAT2GLOBAL(GET_GLOBAL(cdemu_drive_gf));
+ struct drive_s *cdemu_gf = GET_GLOBAL(cdemu_drive_gf);
if (regs->ah > 0x16) {
// Only old-style commands supported.
- disk_13XX(regs, cdemu_g);
+ disk_13XX(regs, cdemu_gf);
return;
}
- disk_13(regs, cdemu_g);
+ disk_13(regs, cdemu_gf);
return;
}
if (extdrive < EXTSTART_CD && ((emudrive ^ extdrive) & 0x80) == 0)
@@ -889,7 +865,7 @@ handle_76(void)
{
debug_isr(DEBUG_ISR_76);
SET_BDA(disk_interrupt_flag, 0xff);
- eoi_pic2();
+ pic_eoi2();
}
// Old Fixed Disk Parameter Table (newer tables are in the ebda).