summaryrefslogtreecommitdiffstats
path: root/data/mnet/GP10/Host/Mch/post/860MemTest.cpp
blob: 26798bae5db50208247f98d28eb1135adc7dd24f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// *******************************************************************
//
// (c) Copyright Cisco 2000
// All Rights Reserved
//
// *******************************************************************

#include <stdio.h>
#include <sysLib.h>
#include "mch/post.h"



void MPC860MemTest(void)
{
   // First validate the MPC860 SDRAM by writing a walking one pattern and a
   // walking zero pattern.  Each memory location is saved prior to testing a
   // location and restored after testing.
   unsigned int save, read, write;
   unsigned int errs = 0;
   
   // Loop through all MPC860 SDRAM.
   for (unsigned int *addr = 0; addr < (unsigned int *)sysMemTop(); addr++)
   {
      // Do not test the memory used to execute this code.
      if (((char *)*addr < pText) && ((char *)*addr > (pText+POT_MEM_SIZE)) && ((char **)*addr != &pText) &&
         ((char **)*addr != &pData) && ((char **)*addr != &pBSS))
      {
         save = *addr;
         write = 0x80000000;
         for(; write; write>>=1)
         {
            *addr = write;
            read = *addr;
            if (read != write)
               errs++;
               
            *addr = ~write;
            read = *addr;
            if (read != ~write)
               errs++;
         }
         *addr = save;
      }
   }
   
   // Update the power on test status that will be checked later by root.
   if (errs) PowerOnTestStatus |= MPC860_SDRAM_TEST;
   
}