From a86a9db13280c19df2e6f8e8ff14799140b1084f Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 25 Mar 2019 18:21:58 +0100
Subject: [PATCH] Cleanup the usage of <machine/pc/bios.h> and the header
 itself.

---
 sys/boot/pc32/libi386/biosmem.c     | 16 ++++------------
 sys/boot/pc32/libi386/biossmap.c    | 24 ++++++++----------------
 sys/platform/pc64/include/pc/bios.h | 21 ---------------------
 3 files changed, 12 insertions(+), 49 deletions(-)

diff --git a/sys/boot/pc32/libi386/biosmem.c b/sys/boot/pc32/libi386/biosmem.c
index 49c5dda5bc..132a7ffbf9 100644
--- a/sys/boot/pc32/libi386/biosmem.c
+++ b/sys/boot/pc32/libi386/biosmem.c
@@ -40,15 +40,7 @@ vm_offset_t	memtop;
 vm_offset_t	heapbase;
 u_int32_t	bios_basemem, bios_extmem, bios_howmem;
 
-#define SMAPSIG	0x534D4150
-
-struct smap {
-    u_int64_t	base;
-    u_int64_t	length;
-    u_int32_t	type;
-} __packed;
-
-static struct smap smap;
+static struct bios_smap smap;
 
 void
 bios_getmem(void)
@@ -64,8 +56,8 @@ bios_getmem(void)
 	v86.ctl = V86_FLAGS;
 	v86.addr = 0x15;		/* int 0x15 function 0xe820*/
 	v86.eax = 0xe820;
-	v86.ecx = sizeof(struct smap);
-	v86.edx = SMAPSIG;
+	v86.ecx = sizeof(struct bios_smap);
+	v86.edx = SMAP_SIG;
 	v86.es = VTOPSEG(&smap);
 	v86.edi = VTOPOFF(&smap);
 	v86int();
@@ -75,7 +67,7 @@ bios_getmem(void)
 		(int)(smap.base >> 32), (int)smap.base,
 		(int)(smap.length >> 32), (int)smap.length);
 #endif
-	if ((v86.efl & PSL_C) || (v86.eax != SMAPSIG))
+	if ((v86.efl & PSL_C) || (v86.eax != SMAP_SIG))
 	    break;
 	/* look for a low-memory segment that's large enough */
 	if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) &&
diff --git a/sys/boot/pc32/libi386/biossmap.c b/sys/boot/pc32/libi386/biossmap.c
index 20ba7af79d..e2fad06c69 100644
--- a/sys/boot/pc32/libi386/biossmap.c
+++ b/sys/boot/pc32/libi386/biossmap.c
@@ -39,17 +39,9 @@
 #include "libi386.h"
 #include "btxv86.h"
 
-#define SMAPSIG	0x534D4150
+static struct bios_smap smap;
 
-struct smap {
-	u_int64_t	base;
-	u_int64_t	length;
-	u_int32_t	type;
-} __packed;
-
-static struct smap smap;
-
-static struct smap *smapbase;
+static struct bios_smap *smapbase;
 static int smaplen;
 
 void
@@ -65,12 +57,12 @@ bios_getsmap(void)
 		v86.ctl = V86_FLAGS;
 		v86.addr = 0x15;		/* int 0x15 function 0xe820*/
 		v86.eax = 0xe820;
-		v86.ecx = sizeof(struct smap);
-		v86.edx = SMAPSIG;
+		v86.ecx = sizeof(struct bios_smap);
+		v86.edx = SMAP_SIG;
 		v86.es = VTOPSEG(&smap);
 		v86.edi = VTOPOFF(&smap);
 		v86int();
-		if ((v86.efl & PSL_C) || (v86.eax != SMAPSIG))
+		if ((v86.efl & PSL_C) || (v86.eax != SMAP_SIG))
 			break;
 		n++;
 	} while (v86.ebx != 0);
@@ -85,8 +77,8 @@ bios_getsmap(void)
 		v86.ctl = V86_FLAGS;
 		v86.addr = 0x15;		/* int 0x15 function 0xe820*/
 		v86.eax = 0xe820;
-		v86.ecx = sizeof(struct smap);
-		v86.edx = SMAPSIG;
+		v86.ecx = sizeof(struct bios_smap);
+		v86.edx = SMAP_SIG;
 		v86.es = VTOPSEG(&smap);
 		v86.edi = VTOPOFF(&smap);
 		v86int();
@@ -123,7 +115,7 @@ bios_getsmap(void)
 			smapbase[smaplen] = smap;
 			++smaplen;
 		}
-		if ((v86.efl & PSL_C) || (v86.eax != SMAPSIG))
+		if ((v86.efl & PSL_C) || (v86.eax != SMAP_SIG))
 			break;
 	} while (v86.ebx != 0 && smaplen < n);
 }
diff --git a/sys/platform/pc64/include/pc/bios.h b/sys/platform/pc64/include/pc/bios.h
index 40919a362b..3f4f021847 100644
--- a/sys/platform/pc64/include/pc/bios.h
+++ b/sys/platform/pc64/include/pc/bios.h
@@ -44,10 +44,6 @@ extern u_int32_t	bios_sigsearch(u_int32_t start, u_char *sig, int siglen,
 #define SMAP_SIG	0x534D4150			/* 'SMAP' */
 
 #define	SMAP_TYPE_MEMORY	1
-#define	SMAP_TYPE_RESERVED	2
-#define	SMAP_TYPE_ACPI_RECLAIM	3
-#define	SMAP_TYPE_ACPI_NVS	4
-#define	SMAP_TYPE_ACPI_ERROR	5
 
 struct bios_smap {
     u_int64_t	base;
@@ -55,23 +51,6 @@ struct bios_smap {
     u_int32_t	type;
 } __packed;
 
-struct bios_oem_signature {
-	char * anchor;		/* search anchor string in BIOS memory */
-	size_t offset;		/* offset from anchor (may be negative) */
-	size_t totlen;		/* total length of BIOS string to copy */
-} __packed;
-struct bios_oem_range {
-	u_int from;		/* shouldn't be below 0xe0000 */
-	u_int to;		/* shouldn't be above 0xfffff */
-} __packed;
-struct bios_oem {
-	struct bios_oem_range range;
-	struct bios_oem_signature signature[];
-} __packed;
-
-extern int
-bios_oem_strings(struct bios_oem *oem, u_char *buffer, size_t maxlen);
-
 /*
  * System Management BIOS
  */
-- 
2.21.0

