/*
 *	Initialise the memory management. For now simply print the amount of
 *	memory!
 */
 
#include <linuxmt/types.h>
#include <linuxmt/config.h>
#include <arch/system.h>
#include <arch/segment.h>

/*
 *	0x9000:2	- Extended memory size
 *	0x9000:4	- Display page
 *	0x9000:6	- Video mode
 *	0x9000:7	- Window Width
 *	0x9000:8,10,12	- Video parameters
 *	0x9000:15 	- No vga
 *	0x9000:16	- Video height (points)
 *
 *	0x9000:80	- 16 bytes of disk 0 info
 *	0x9000:90	- 16 bytes of disk 1 info
 *
 *	1ff		- AA if psmouse present
 */


void setup_mm()
{
	int basemem=640;		/* Hard coded */
	int xms=peekw(0x9000,2);	/* Fetched by boot code */
	long memstart;
	long memend;
	
	if(arch_cpu>1)
		printk("PC/AT class machine, 80286 or higher CPU\n");
	else
		printk("PC/XT class machine, 80186 or lower CPU\n");
		
	printk("%dK base", basemem);
	if(arch_cpu<2)
		xms=0;			/* XT bios hasn't got xms interrupt */
	if(xms)
		printk(", %dK extended",xms);
	printk(".\n");
	printk("ELKS kernel (%d text + %d data + %d bss)\n",
		(int)_endtext, (int)_enddata, (int)_endbss-(int)_enddata);
	printk("Kernel text at %x:0000, data at %x:0000 \n", get_cs(),
		get_ds());
	/*
	 *	This computes the 640K - _endbss 
	 */
	 
	memend = ((long)basemem)<<10;
	memstart = ((long)get_ds())<<4;
	memstart += (unsigned int)_endbss +15;
	
	printk("%d K of memory for user processes.\n",
		(int)((memend-memstart)>>10));
		
	if(peekb(0x9000,0x1ff)==0xAA && arch_cpu>1)
		printk("ps2: PS/2 pointing device detected\n");
}
