summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-10-28 21:23:49 +0000
committerjhb <jhb@FreeBSD.org>2007-10-28 21:23:49 +0000
commitae8e7ec2a3a62350e0e8adf6cc88be3a8330aab9 (patch)
tree7b9079349353dab6e5c41cb3230d6c339d05d93e
parent80e186726f434f12eda8b927b4d96a968a6753f5 (diff)
downloadFreeBSD-src-ae8e7ec2a3a62350e0e8adf6cc88be3a8330aab9.zip
FreeBSD-src-ae8e7ec2a3a62350e0e8adf6cc88be3a8330aab9.tar.gz
- Add constants for the different memory types in the SMAP table.
- Use the SMAP types and constants from <machine/pc/bios.h> in the boot code rather than duplicating it.
-rw-r--r--sys/amd64/amd64/machdep.c2
-rw-r--r--sys/amd64/amd64/nexus.c2
-rw-r--r--sys/amd64/include/pc/bios.h10
-rw-r--r--sys/boot/i386/libi386/biosmem.c22
-rw-r--r--sys/boot/i386/libi386/biossmap.c27
-rw-r--r--sys/i386/i386/machdep.c2
-rw-r--r--sys/i386/include/pc/bios.h10
7 files changed, 37 insertions, 38 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 7252386..d79e87f 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -881,7 +881,7 @@ getmemsize(caddr_t kmdp, u_int64_t first)
printf("SMAP type=%02x base=%016lx len=%016lx\n",
smap->type, smap->base, smap->length);
- if (smap->type != 0x01)
+ if (smap->type != SMAP_TYPE_MEMORY)
continue;
if (smap->length == 0)
diff --git a/sys/amd64/amd64/nexus.c b/sys/amd64/amd64/nexus.c
index b5498b7..54d9e5f 100644
--- a/sys/amd64/amd64/nexus.c
+++ b/sys/amd64/amd64/nexus.c
@@ -587,7 +587,7 @@ ram_attach(device_t dev)
rid = 0;
for (smap = smapbase; smap < smapend; smap++) {
- if (smap->type != 0x01 || smap->length == 0)
+ if (smap->type != SMAP_TYPE_MEMORY || smap->length == 0)
continue;
error = bus_set_resource(dev, SYS_RES_MEMORY, rid, smap->base,
smap->length);
diff --git a/sys/amd64/include/pc/bios.h b/sys/amd64/include/pc/bios.h
index ffad369..782d4bf 100644
--- a/sys/amd64/include/pc/bios.h
+++ b/sys/amd64/include/pc/bios.h
@@ -38,10 +38,16 @@ extern u_int32_t bios_sigsearch(u_int32_t start, u_char *sig, int siglen,
/*
* Int 15:E820 'SMAP' structure
- *
- * XXX add constants for type
*/
+
#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;
u_int64_t length;
diff --git a/sys/boot/i386/libi386/biosmem.c b/sys/boot/i386/libi386/biosmem.c
index 6d4f966..3c2205e 100644
--- a/sys/boot/i386/libi386/biosmem.c
+++ b/sys/boot/i386/libi386/biosmem.c
@@ -31,21 +31,14 @@ __FBSDID("$FreeBSD$");
* Obtain memory configuration information from the BIOS
*/
#include <stand.h>
+#include <machine/pc/bios.h>
#include "libi386.h"
#include "btxv86.h"
vm_offset_t memtop, memtop_copyin;
u_int32_t bios_basemem, bios_extmem;
-#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)
@@ -57,18 +50,19 @@ 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();
- if ((v86.efl & 1) || (v86.eax != SMAPSIG))
+ if ((v86.efl & 1) || (v86.eax != SMAP_SIG))
break;
/* look for a low-memory segment that's large enough */
- if ((smap.type == 1) && (smap.base == 0) && (smap.length >= (512 * 1024)))
+ if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0) &&
+ (smap.length >= (512 * 1024)))
bios_basemem = smap.length;
/* look for the first segment in 'extended' memory */
- if ((smap.type == 1) && (smap.base == 0x100000)) {
+ if ((smap.type == SMAP_TYPE_MEMORY) && (smap.base == 0x100000)) {
bios_extmem = smap.length;
}
} while (v86.ebx != 0);
diff --git a/sys/boot/i386/libi386/biossmap.c b/sys/boot/i386/libi386/biossmap.c
index 6f75b27..5a617f7 100644
--- a/sys/boot/i386/libi386/biossmap.c
+++ b/sys/boot/i386/libi386/biossmap.c
@@ -34,21 +34,14 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/linker.h>
#include <machine/metadata.h>
+#include <machine/pc/bios.h>
#include "bootstrap.h"
#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
@@ -64,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 & 1) || (v86.eax != SMAPSIG))
+ if ((v86.efl & 1) || (v86.eax != SMAP_SIG))
break;
n++;
} while (v86.ebx != 0);
@@ -84,14 +77,14 @@ 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();
- bcopy(&smap, &smapbase[smaplen], sizeof(struct smap));
+ bcopy(&smap, &smapbase[smaplen], sizeof(struct bios_smap));
smaplen++;
- if ((v86.efl & 1) || (v86.eax != SMAPSIG))
+ if ((v86.efl & 1) || (v86.eax != SMAP_SIG))
break;
} while (v86.ebx != 0 && smaplen < n);
}
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 7931975..55ec4be 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -1751,7 +1751,7 @@ int15e820:
smap->type, smap->base, smap->length);
has_smap = 1;
- if (smap->type != 0x01)
+ if (smap->type != SMAP_TYPE_MEMORY)
continue;
if (smap->length == 0)
diff --git a/sys/i386/include/pc/bios.h b/sys/i386/include/pc/bios.h
index 4533de7..ca06024 100644
--- a/sys/i386/include/pc/bios.h
+++ b/sys/i386/include/pc/bios.h
@@ -271,10 +271,16 @@ struct PIR_table
/*
* Int 15:E820 'SMAP' structure
- *
- * XXX add constants for type
*/
+
#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;
u_int64_t length;
OpenPOWER on IntegriCloud