git: 017912879876 - stable/12 - Use symbolic names for int13 calls
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 08 Oct 2021 01:16:28 UTC
The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=01791287987664b5db4a362dc817f7081553aca2 commit 01791287987664b5db4a362dc817f7081553aca2 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2019-12-16 21:52:12 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2021-10-08 01:15:58 +0000 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. (cherry picked from commit 7f5499972e115cafc861ec438cd7237422cd9b7c) --- stand/i386/common/edd.h | 3 ++ stand/i386/libi386/biosdisk.c | 65 ++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/stand/i386/common/edd.h b/stand/i386/common/edd.h index 7d1f45020f9d..9739c45b0f38 100644 --- a/stand/i386/common/edd.h +++ b/stand/i386/common/edd.h @@ -107,4 +107,7 @@ struct edd_params_v4 { #define EDD_DEVICE_PATH_KEY 0xbedd +#define EDD_QUERY_MAGIC 0x55aa +#define EDD_INSTALLED 0xaa55 + #endif /* !_EDD_H_ */ diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c index c2d95e81161f..00d2de5de418 100644 --- a/stand/i386/libi386/biosdisk.c +++ b/stand/i386/libi386/biosdisk.c @@ -64,6 +64,22 @@ __FBSDID("$FreeBSD$"); #define ACDMAJOR 117 #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 #define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args) #else @@ -266,8 +282,8 @@ fd_count(void) bd_reset_disk(drive); v86.ctl = V86_FLAGS; - v86.addr = 0x13; - v86.eax = 0x1500; + v86.addr = DISK_BIOS; + v86.eax = CMD_DRIVE_TYPE; v86.edx = drive; v86int(); @@ -371,8 +387,8 @@ bd_get_diskinfo_cd(struct bdinfo *bd) bc_sp.sp_size = sizeof (bc_sp) - sizeof (bc_sp.sp_dummy); v86.ctl = V86_FLAGS; - v86.addr = 0x13; - v86.eax = 0x4b01; + v86.addr = DISK_BIOS; + v86.eax = CMD_CD_GET_STATUS; v86.edx = bd->bd_unit; v86.ds = VTOPSEG(&bc_sp); v86.esi = VTOPOFF(&bc_sp); @@ -462,14 +478,14 @@ bd_check_extensions(int unit) /* Determine if we can use EDD with this device. */ v86.ctl = V86_FLAGS; - v86.addr = 0x13; - v86.eax = 0x4100; + v86.addr = DISK_BIOS; + v86.eax = CMD_CHECK_EDD; v86.edx = unit; - v86.ebx = 0x55aa; + v86.ebx = EDD_QUERY_MAGIC; v86int(); if (V86_CY(v86.efl) || /* carry set */ - (v86.ebx & 0xffff) != 0xaa55) /* signature */ + (v86.ebx & 0xffff) != EDD_INSTALLED) /* signature */ return (0); /* extended disk access functions (AH=42h-44h,47h,48h) supported */ @@ -484,8 +500,8 @@ bd_reset_disk(int unit) { /* reset disk */ v86.ctl = V86_FLAGS; - v86.addr = 0x13; - v86.eax = 0; + v86.addr = DISK_BIOS; + v86.eax = CMD_RESET; v86.edx = unit; v86int(); } @@ -498,8 +514,8 @@ bd_get_diskinfo_std(struct bdinfo *bd) { bzero(&v86, sizeof(v86)); v86.ctl = V86_FLAGS; - v86.addr = 0x13; - v86.eax = 0x800; + v86.addr = DISK_BIOS; + v86.eax = CMD_READ_PARAM; v86.edx = bd->bd_unit; v86int(); @@ -543,8 +559,8 @@ bd_get_diskinfo_ext(struct bdinfo *bd) bzero(&dparams, sizeof(dparams)); params->len = sizeof(struct edd_params_v3); v86.ctl = V86_FLAGS; - v86.addr = 0x13; - v86.eax = 0x4800; + v86.addr = DISK_BIOS; + v86.eax = CMD_EXT_PARAM; v86.edx = bd->bd_unit; v86.ds = VTOPSEG(&dparams); v86.esi = VTOPOFF(&dparams); @@ -615,8 +631,8 @@ bd_int13probe(bdinfo_t *bd) /* Get disk type */ v86.ctl = V86_FLAGS; - v86.addr = 0x13; - v86.eax = 0x1500; + v86.addr = DISK_BIOS; + v86.eax = CMD_DRIVE_TYPE; v86.edx = bd->bd_unit; v86int(); if (V86_CY(v86.efl) || (v86.eax & 0x300) == 0) @@ -1125,12 +1141,11 @@ bd_edd_io(bdinfo_t *bd, daddr_t dblk, int blks, caddr_t dest, packet.seg = VTOPSEG(dest); packet.lba = dblk; v86.ctl = V86_FLAGS; - v86.addr = 0x13; - /* Should we Write with verify ?? 0x4302 ? */ + v86.addr = DISK_BIOS; if (dowrite == BD_WR) - v86.eax = 0x4300; + v86.eax = CMD_WRITE_LBA; /* maybe Write with verify 0x4302? */ else - v86.eax = 0x4200; + v86.eax = CMD_READ_LBA; v86.edx = bd->bd_unit; v86.ds = VTOPSEG(&packet); v86.esi = VTOPOFF(&packet); @@ -1162,11 +1177,11 @@ bd_chs_io(bdinfo_t *bd, daddr_t dblk, int blks, caddr_t dest, } v86.ctl = V86_FLAGS; - v86.addr = 0x13; + v86.addr = DISK_BIOS; if (dowrite == BD_WR) - v86.eax = 0x300 | blks; + v86.eax = CMD_WRITE_CHS | blks; else - v86.eax = 0x200 | blks; + v86.eax = CMD_READ_CHS | blks; v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec; v86.edx = (hd << 8) | bd->bd_unit; v86.es = VTOPSEG(dest); @@ -1271,8 +1286,8 @@ bd_getbigeom(int bunit) { v86.ctl = V86_FLAGS; - v86.addr = 0x13; - v86.eax = 0x800; + v86.addr = DISK_BIOS; + v86.eax = CMD_READ_PARAM; v86.edx = 0x80 + bunit; v86int(); if (V86_CY(v86.efl))