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