From nobody Fri Oct 08 01:16:28 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E74E812D0BFA; Fri, 8 Oct 2021 01:16:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HQVdT0FRKz3tND; Fri, 8 Oct 2021 01:16:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 22D571DBC8; Fri, 8 Oct 2021 01:16:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1981GSge010597; Fri, 8 Oct 2021 01:16:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1981GSjO010596; Fri, 8 Oct 2021 01:16:28 GMT (envelope-from git) Date: Fri, 8 Oct 2021 01:16:28 GMT Message-Id: <202110080116.1981GSjO010596@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 017912879876 - stable/12 - Use symbolic names for int13 calls List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 01791287987664b5db4a362dc817f7081553aca2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=01791287987664b5db4a362dc817f7081553aca2 commit 01791287987664b5db4a362dc817f7081553aca2 Author: Warner Losh AuthorDate: 2019-12-16 21:52:12 +0000 Commit: Kyle Evans 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))