home *** CD-ROM | disk | FTP | other *** search
-
-
-
- #include "screen.h"
- #include "showbox.hpp"
-
- void DetectRealRam( struct MCES_SYSTEM * PsysStruc, char *Msgs )
- {
- ushort RamSenseCnt;
- int A20Sense;
- int RamRet;
- Box LBox("Detecting","RAM Size Detection", BRIGHTWHITEFORGROUND + BLUEBACKGROUND);
- ErrorBox * WorkBox1;
- uchar intctr1 = inportb(0x21);
- uchar intctr2 = inportb(0xa1);
-
- LogTestName("Detecting real ram");
-
- if (cpu_type() == 4)
- I486CACHE_OFF();
-
- A20Sense = CheckMemwrap();
-
- if (A20Sense)
- // ensure A20 enabled before testing
- kbd_a20_on_off(1); // enable the keyboard controller A20 line
-
- // base ram is either 512K or 640K so there is no need
- // to test below 512k
-
- // perform existence test on highest base ram first
- // if it exists then the lower ram exists
-
- LBox.Redraw("Starting at block at 640K" );
-
- if ( !(RamRet = BEGIN_VIRTUAL( 0, 4, 512 )) )
- {
- PsysStruc -> BaseMemory = 1;
- MsgOut( Msgs, "Installed base memory - 640K\n" );
- }
- else
- {
- if (RamRet >= 100) // if a protected mode trap occurred
- {
- sprintf(line,"A protected mode error has occurred.\n"
- "The error code is %d", RamRet - 100 );
- WorkBox1 = new ErrorBox(line);
- delete WorkBox1;
- }
- PsysStruc -> BaseMemory = 0;
- MsgOut( Msgs, "Installed base memory - 512K" );
- }
-
- // check beginning of each 64k block up to 64MB
- // the first 64k block is used for temp storage
- // of the data in the block being tested during mem tests
- for (RamSenseCnt = 1088; RamSenseCnt < 65535; RamSenseCnt += 64)
- {
- sprintf(line, "Starting block at %u",RamSenseCnt);
- LBox.Redraw( line );
-
- RamRet = BEGIN_VIRTUAL( 0, 4, RamSenseCnt );
- if (RamRet >= 100) // if a protected mode trap occurred
- {
- sprintf(line,"A protected mode error has occurred.\n"
- "The error code is %d", RamRet - 100 );
- LogError( line );
- WorkBox1 = new ErrorBox(line);
- delete WorkBox1;
- }
-
- if (RamRet)
- break;
- }
-
- sleep(3);
-
- asm cli
-
- while (inportb(0x64) & 1)
- {
- inportb(0x60);
- sleep(1);
- }
-
- set_int_ctrlrs(8,0x70);
-
- outportb( 0x21, intctr1 );
- outportb( 0x20, 0x20 );
- outportb( 0xa1, intctr2 );
- outportb( 0xa0, 0x20 );
-
- asm sti
-
- RamSenseCnt -= 1024; // calc how much ext ram
-
- PsysStruc -> ExtMemory = RamSenseCnt / 64;
-
- sprintf(line, "Installed extended memory - %uK\n", RamSenseCnt );
-
- MsgOut( Msgs, line );
-
- if (A20Sense) // if wrapping was enabled to begin with
- kbd_a20_on_off(0); // disable the keyboard controller A20 line
-
- printf("\nFinished with detecting real ram");
- while (!kbhit());
- getch();
-
- }
-
-