MFC: Add constants for the different memory types in the SMAP table and
use the SMAP types and constants from <machine/pc/bios.h> in the boot code.
This commit is contained in:
parent
d3daa7de75
commit
303513927d
@ -929,7 +929,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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1770,7 +1770,7 @@ getmemsize(int first)
|
||||
smap->type, smap->base, smap->length);
|
||||
has_smap = 1;
|
||||
|
||||
if (smap->type != 0x01)
|
||||
if (smap->type != SMAP_TYPE_MEMORY)
|
||||
continue;
|
||||
|
||||
if (smap->length == 0)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user