Use symbolic names for int13 calls

For all the INT13 calls, use symbolic names instead of magic numbers. This makes
it easier to understand what the code is doing w/o a trip to google to find what
these numbers mean.
This commit is contained in:
Warner Losh 2019-12-16 21:52:12 +00:00
parent 2e1d04ae9b
commit 7f5499972e
2 changed files with 43 additions and 25 deletions

View File

@ -107,4 +107,7 @@ struct edd_params_v4 {
#define EDD_DEVICE_PATH_KEY 0xbedd #define EDD_DEVICE_PATH_KEY 0xbedd
#define EDD_QUERY_MAGIC 0x55aa
#define EDD_INSTALLED 0xaa55
#endif /* !_EDD_H_ */ #endif /* !_EDD_H_ */

View File

@ -64,6 +64,22 @@ __FBSDID("$FreeBSD$");
#define ACDMAJOR 117 #define ACDMAJOR 117
#define CDMAJOR 15 #define CDMAJOR 15
/*
* INT13 commands
*/
#define CMD_RESET 0x0000
#define CMD_READ_CHS 0x0200
#define CMD_WRITE_CHS 0x0300
#define CMD_READ_PARAM 0x0800
#define CMD_DRIVE_TYPE 0x1500
#define CMD_CHECK_EDD 0x4100
#define CMD_READ_LBA 0x4200
#define CMD_WRITE_LBA 0x4300
#define CMD_EXT_PARAM 0x4800
#define CMD_CD_GET_STATUS 0x4b01
#define DISK_BIOS 0x13
#ifdef DISK_DEBUG #ifdef DISK_DEBUG
#define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args) #define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args)
#else #else
@ -265,8 +281,8 @@ fd_count(void)
bd_reset_disk(drive); bd_reset_disk(drive);
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
v86.eax = 0x1500; v86.eax = CMD_DRIVE_TYPE;
v86.edx = drive; v86.edx = drive;
v86int(); v86int();
@ -367,8 +383,8 @@ bc_add(int biosdev)
return (-1); return (-1);
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
v86.eax = 0x4b01; v86.eax = CMD_CD_GET_STATUS;
v86.edx = biosdev; v86.edx = biosdev;
v86.ds = VTOPSEG(&bc_sp); v86.ds = VTOPSEG(&bc_sp);
v86.esi = VTOPOFF(&bc_sp); v86.esi = VTOPOFF(&bc_sp);
@ -422,14 +438,14 @@ bd_check_extensions(int unit)
/* Determine if we can use EDD with this device. */ /* Determine if we can use EDD with this device. */
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
v86.eax = 0x4100; v86.eax = CMD_CHECK_EDD;
v86.edx = unit; v86.edx = unit;
v86.ebx = 0x55aa; v86.ebx = EDD_QUERY_MAGIC;
v86int(); v86int();
if (V86_CY(v86.efl) || /* carry set */ if (V86_CY(v86.efl) || /* carry set */
(v86.ebx & 0xffff) != 0xaa55) /* signature */ (v86.ebx & 0xffff) != EDD_INSTALLED) /* signature */
return (0); return (0);
/* extended disk access functions (AH=42h-44h,47h,48h) supported */ /* extended disk access functions (AH=42h-44h,47h,48h) supported */
@ -444,8 +460,8 @@ bd_reset_disk(int unit)
{ {
/* reset disk */ /* reset disk */
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
v86.eax = 0; v86.eax = CMD_RESET;
v86.edx = unit; v86.edx = unit;
v86int(); v86int();
} }
@ -458,8 +474,8 @@ bd_get_diskinfo_std(struct bdinfo *bd)
{ {
bzero(&v86, sizeof(v86)); bzero(&v86, sizeof(v86));
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
v86.eax = 0x800; v86.eax = CMD_READ_PARAM;
v86.edx = bd->bd_unit; v86.edx = bd->bd_unit;
v86int(); v86int();
@ -493,8 +509,8 @@ bd_get_diskinfo_ext(struct bdinfo *bd)
bzero(&params, sizeof(params)); bzero(&params, sizeof(params));
params.len = sizeof(params); params.len = sizeof(params);
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
v86.eax = 0x4800; v86.eax = CMD_EXT_PARAM;
v86.edx = bd->bd_unit; v86.edx = bd->bd_unit;
v86.ds = VTOPSEG(&params); v86.ds = VTOPSEG(&params);
v86.esi = VTOPOFF(&params); v86.esi = VTOPOFF(&params);
@ -560,8 +576,8 @@ bd_int13probe(bdinfo_t *bd)
/* Get disk type */ /* Get disk type */
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
v86.eax = 0x1500; v86.eax = CMD_DRIVE_TYPE;
v86.edx = bd->bd_unit; v86.edx = bd->bd_unit;
v86int(); v86int();
if (V86_CY(v86.efl) || (v86.eax & 0x300) == 0) if (V86_CY(v86.efl) || (v86.eax & 0x300) == 0)
@ -1076,12 +1092,11 @@ bd_edd_io(bdinfo_t *bd, daddr_t dblk, int blks, caddr_t dest,
packet.seg = VTOPSEG(dest); packet.seg = VTOPSEG(dest);
packet.lba = dblk; packet.lba = dblk;
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
/* Should we Write with verify ?? 0x4302 ? */
if (dowrite == BD_WR) if (dowrite == BD_WR)
v86.eax = 0x4300; v86.eax = CMD_WRITE_LBA; /* maybe Write with verify 0x4302? */
else else
v86.eax = 0x4200; v86.eax = CMD_READ_LBA;
v86.edx = bd->bd_unit; v86.edx = bd->bd_unit;
v86.ds = VTOPSEG(&packet); v86.ds = VTOPSEG(&packet);
v86.esi = VTOPOFF(&packet); v86.esi = VTOPOFF(&packet);
@ -1113,11 +1128,11 @@ bd_chs_io(bdinfo_t *bd, daddr_t dblk, int blks, caddr_t dest,
} }
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
if (dowrite == BD_WR) if (dowrite == BD_WR)
v86.eax = 0x300 | blks; v86.eax = CMD_WRITE_CHS | blks;
else else
v86.eax = 0x200 | blks; v86.eax = CMD_READ_CHS | blks;
v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec; v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec;
v86.edx = (hd << 8) | bd->bd_unit; v86.edx = (hd << 8) | bd->bd_unit;
v86.es = VTOPSEG(dest); v86.es = VTOPSEG(dest);
@ -1222,8 +1237,8 @@ bd_getbigeom(int bunit)
{ {
v86.ctl = V86_FLAGS; v86.ctl = V86_FLAGS;
v86.addr = 0x13; v86.addr = DISK_BIOS;
v86.eax = 0x800; v86.eax = CMD_READ_PARAM;
v86.edx = 0x80 + bunit; v86.edx = 0x80 + bunit;
v86int(); v86int();
if (V86_CY(v86.efl)) if (V86_CY(v86.efl))