155342Snyan/*- 255342Snyan * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 355342Snyan * All rights reserved. 453207Snyan * 555342Snyan * Redistribution and use in source and binary forms, with or without 655342Snyan * modification, are permitted provided that the following conditions 755342Snyan * are met: 855342Snyan * 1. Redistributions of source code must retain the above copyright 955342Snyan * notice, this list of conditions and the following disclaimer. 1055342Snyan * 2. Redistributions in binary form must reproduce the above copyright 1155342Snyan * notice, this list of conditions and the following disclaimer in the 1255342Snyan * documentation and/or other materials provided with the distribution. 1355342Snyan * 1455342Snyan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1555342Snyan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1655342Snyan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1755342Snyan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1855342Snyan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1955342Snyan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2055342Snyan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2155342Snyan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2255342Snyan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2355342Snyan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2455342Snyan * SUCH DAMAGE. 2543561Skato */ 2643561Skato 27119880Sobrien#include <sys/cdefs.h> 28119880Sobrien__FBSDID("$FreeBSD$"); 29119880Sobrien 3043561Skato/* 3143561Skato * Obtain memory configuration information from the BIOS 3243561Skato */ 3343561Skato#include <stand.h> 3468358Snyan#include "libi386.h" 3543561Skato#include "btxv86.h" 3643561Skato 37200255Snyanvm_offset_t memtop, memtop_copyin, high_heap_base; 38200255Snyanuint32_t bios_basemem, bios_extmem, high_heap_size; 3943561Skato 40200255Snyan/* 41200255Snyan * The minimum amount of memory to reserve in bios_extmem for the heap. 42200255Snyan */ 43200255Snyan#define HEAP_MIN (3 * 1024 * 1024) 44200255Snyan 4555342Snyanvoid 4655342Snyanbios_getmem(void) 4743561Skato{ 4855342Snyan 4955342Snyan bios_basemem = ((*(u_char *)PTOV(0xA1501) & 0x07) + 1) * 128 * 1024; 5055342Snyan bios_extmem = *(u_char *)PTOV(0xA1401) * 128 * 1024 + 5155342Snyan *(u_int16_t *)PTOV(0xA1594) * 1024 * 1024; 5243561Skato 5355342Snyan /* Set memtop to actual top of memory */ 54153599Snyan memtop = memtop_copyin = 0x100000 + bios_extmem; 5543561Skato 56200255Snyan /* 57200255Snyan * If we have extended memory, use the last 3MB of 'extended' memory 58200255Snyan * as a high heap candidate. 59200255Snyan */ 60200255Snyan if (bios_extmem >= HEAP_MIN) { 61200255Snyan high_heap_size = HEAP_MIN; 62200255Snyan high_heap_base = memtop - HEAP_MIN; 63200255Snyan } 6455342Snyan} 65