biosmem.c revision 53207
1/* 2 * mjs copyright 3 * 4 * $FreeBSD: head/sys/boot/pc98/libpc98/biosmem.c 53207 1999-11-16 00:42:18Z nyan $ 5 */ 6 7/* 8 * Obtain memory configuration information from the BIOS 9 * 10 * Note that we don't try too hard here; knowing the size of 11 * base memory and extended memory out to 16 or 64M is enough for 12 * the requirements of the bootstrap. 13 * 14 * We also maintain a pointer to the top of physical memory 15 * once called to allow rangechecking of load/copy requests. 16 */ 17#include <stand.h> 18#include "btxv86.h" 19 20vm_offset_t memtop; 21 22/* 23 * Return base memory size in kB. 24 */ 25int 26getbasemem(void) 27{ 28#ifdef PC98 29 return ((*(u_char *)PTOV(0xA1501)&0x07)+1)*128; 30#else 31 v86.ctl = 0; 32 v86.addr = 0x12; /* int 0x12 */ 33 v86int(); 34 35 return(v86.eax & 0xffff); 36#endif 37} 38 39/* 40 * Return extended memory size in kB 41 */ 42int 43getextmem(void) 44{ 45 int extkb; 46 47#ifdef PC98 48 extkb = *(u_char *)PTOV(0xA1401)*128 + *(unsigned short *)PTOV(0xA1594)*1024; 49#else 50 v86.ctl = 0; 51 v86.addr = 0x15; /* int 0x15 function 0x88*/ 52 v86.eax = 0x8800; 53 v86int(); 54 extkb = v86.eax & 0xffff; 55#endif 56 57 /* Set memtop to actual top or 16M, whicheve is less */ 58 memtop = min((0x100000 + (extkb * 1024)), (16 * 1024 * 1024)); 59 60 return(extkb); 61} 62 63