biosmem.c revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Obtain memory configuration information from the BIOS
*/
#include <stand.h>
#include "bootstrap.h"
#include "smbios.h"
#include "libi386.h"
#include "btxv86.h"
#include "smbios.h"
static struct bios_smap_xattr smap;
/*
* Used to track which method was used to set BIOS memory
* regions.
*/
static uint8_t b_bios_probed;
#define B_BASEMEM_E820 0x1
#define B_BASEMEM_12 0x2
#define B_EXTMEM_E820 0x4
#define B_EXTMEM_E801 0x8
#define B_EXTMEM_8800 0x10
/*
* The minimum amount of memory to reserve in bios_extmem for the heap.
*/
/*
* Products in this list need quirks to detect
* memory correctly. You need both maker and product as
* reported by smbios.
*/
extended memory */
struct bios_getmem_quirks {
const char* bios_vendor;
const char* maker;
const char* product;
int quirk;
};
static struct bios_getmem_quirks quirks[] = {
};
static int
bios_getquirks(void)
{
int i;
return (0);
}
void
bios_getmem(void)
{
/* Parse system memory map */
do {
v86int();
break;
/* look for a low-memory segment that's large enough */
}
/* look for the first segment in 'extended' memory */
!(bios_getquirks() & BQ_DISTRUST_E820_EXTMEM)) {
}
/*
* Look for the largest segment in 'extended' memory beyond
* 1MB but below 4GB.
*/
/*
* If this segment crosses the 4GB boundary, truncate it.
*/
if (size > high_heap_size) {
}
}
/* Fall back to the old compatibility function for base memory */
if (bios_basemem == 0) {
v86int();
}
/* Fall back through several compatibility functions for extended memory */
if (bios_extmem == 0) {
v86int();
/*
* Clear high_heap; it may end up overlapping
* with the segment we're determining here.
* Let the default "steal stuff from top of
* bios_extmem" code below pick up on it.
*/
high_heap_size = 0;
high_heap_base = 0;
/*
* %cx is the number of 1KiB blocks between 1..16MiB.
* It can only be up to 0x3c00; if it's smaller then
* there's a PC AT memory hole so we can't treat
* it as contiguous.
*/
/* truncate bios_extmem */
if (bios_extmem > 0x3ff00000)
bios_extmem = 0x3ff00000;
}
}
if (bios_extmem == 0) {
v86int();
}
/* Set memtop to actual top of memory */
/*
* If we have extended memory and did not find a suitable heap
* region in the SMAP, use the last 3MB of 'extended' memory as a
* high heap candidate.
*/
}
}
#ifndef BOOT2
static int
{
int bq = bios_getquirks();
if (bq & BQ_DISTRUST_E820_EXTMEM)
printf(" BQ_DISTRUST_E820_EXTMEM");
printf("\n");
if (b_bios_probed & B_BASEMEM_E820)
printf(" B_BASEMEM_E820");
if (b_bios_probed & B_BASEMEM_12)
printf(" B_BASEMEM_12");
if (b_bios_probed & B_EXTMEM_E820)
printf(" B_EXTMEM_E820");
if (b_bios_probed & B_EXTMEM_E801)
printf(" B_EXTMEM_E801");
if (b_bios_probed & B_EXTMEM_8800)
printf(" B_EXTMEM_8800");
printf("\n");
return (CMD_OK);
}
#endif