biosmem.c revision 53207
143561Skato/* 243561Skato * mjs copyright 353207Snyan * 453207Snyan * $FreeBSD: head/sys/boot/pc98/libpc98/biosmem.c 53207 1999-11-16 00:42:18Z nyan $ 543561Skato */ 643561Skato 743561Skato/* 843561Skato * Obtain memory configuration information from the BIOS 943561Skato * 1043561Skato * Note that we don't try too hard here; knowing the size of 1143561Skato * base memory and extended memory out to 16 or 64M is enough for 1243561Skato * the requirements of the bootstrap. 1343561Skato * 1443561Skato * We also maintain a pointer to the top of physical memory 1543561Skato * once called to allow rangechecking of load/copy requests. 1643561Skato */ 1743561Skato#include <stand.h> 1843561Skato#include "btxv86.h" 1943561Skato 2043561Skatovm_offset_t memtop; 2143561Skato 2243561Skato/* 2343561Skato * Return base memory size in kB. 2443561Skato */ 2543561Skatoint 2643561Skatogetbasemem(void) 2743561Skato{ 2843561Skato#ifdef PC98 2943561Skato return ((*(u_char *)PTOV(0xA1501)&0x07)+1)*128; 3043561Skato#else 3143561Skato v86.ctl = 0; 3243561Skato v86.addr = 0x12; /* int 0x12 */ 3343561Skato v86int(); 3443561Skato 3543561Skato return(v86.eax & 0xffff); 3643561Skato#endif 3743561Skato} 3843561Skato 3943561Skato/* 4043561Skato * Return extended memory size in kB 4143561Skato */ 4243561Skatoint 4343561Skatogetextmem(void) 4443561Skato{ 4543561Skato int extkb; 4653207Snyan 4743561Skato#ifdef PC98 4843561Skato extkb = *(u_char *)PTOV(0xA1401)*128 + *(unsigned short *)PTOV(0xA1594)*1024; 4943561Skato#else 5043561Skato v86.ctl = 0; 5143561Skato v86.addr = 0x15; /* int 0x15 function 0x88*/ 5243561Skato v86.eax = 0x8800; 5343561Skato v86int(); 5443561Skato extkb = v86.eax & 0xffff; 5543561Skato#endif 5653207Snyan 5743561Skato /* Set memtop to actual top or 16M, whicheve is less */ 5843561Skato memtop = min((0x100000 + (extkb * 1024)), (16 * 1024 * 1024)); 5943561Skato 6043561Skato return(extkb); 6143561Skato} 6243561Skato 63