svn commit: r355825 - in head/stand/i386: common libi386

Warner Losh imp at FreeBSD.org
Mon Dec 16 21:52:13 UTC 2019


Author: imp
Date: Mon Dec 16 21:52:12 2019
New Revision: 355825
URL: https://svnweb.freebsd.org/changeset/base/355825

Log:
  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.

Modified:
  head/stand/i386/common/edd.h
  head/stand/i386/libi386/biosdisk.c

Modified: head/stand/i386/common/edd.h
==============================================================================
--- head/stand/i386/common/edd.h	Mon Dec 16 21:35:02 2019	(r355824)
+++ head/stand/i386/common/edd.h	Mon Dec 16 21:52:12 2019	(r355825)
@@ -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_ */

Modified: head/stand/i386/libi386/biosdisk.c
==============================================================================
--- head/stand/i386/libi386/biosdisk.c	Mon Dec 16 21:35:02 2019	(r355824)
+++ head/stand/i386/libi386/biosdisk.c	Mon Dec 16 21:52:12 2019	(r355825)
@@ -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
@@ -265,8 +281,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();
 
@@ -367,8 +383,8 @@ bc_add(int biosdev)
                 return (-1);
 
         v86.ctl = V86_FLAGS;
-        v86.addr = 0x13;
-        v86.eax = 0x4b01;
+        v86.addr = DISK_BIOS;
+        v86.eax = CMD_CD_GET_STATUS;
         v86.edx = biosdev;
         v86.ds = VTOPSEG(&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. */
 	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 */
@@ -444,8 +460,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();
 }
@@ -458,8 +474,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();
 
@@ -493,8 +509,8 @@ bd_get_diskinfo_ext(struct bdinfo *bd)
 	bzero(&params, sizeof(params));
 	params.len = sizeof(params);
 	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(&params);
 	v86.esi = VTOPOFF(&params);
@@ -560,8 +576,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)
@@ -1076,12 +1092,11 @@ bd_edd_io(bdinfo_t *bd, daddr_t dblk, int blks, caddr_
 	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);
@@ -1113,11 +1128,11 @@ bd_chs_io(bdinfo_t *bd, daddr_t dblk, int blks, caddr_
 	}
 
 	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);
@@ -1222,8 +1237,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))


More information about the svn-src-head mailing list