1 // taken from Qi boot loader
4 * (C) Copyright 2007 OpenMoko, Inc.
5 * Author: Andy Green <andy@openmoko.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #define APPLICATION_TITLE "32MB memory test";
28 #include "application.h"
31 #define RAM_START ((u8 *)0x10000000)
32 #define RAM_SIZE (32 * 1024 * 1024)
34 // redirect Qi routines to the correct EEPROM routines
36 #define print32 print_u32
37 #define printdec print_u32
40 void memory_test(void *start
, unsigned int length
);
42 // this must be the first executable code as the loader executes from the first program address
43 ReturnType
mem(int block
, int status
)
45 APPLICATION_INITIALISE();
47 memory_test(RAM_START
, RAM_SIZE
);
49 APPLICATION_FINALISE(0, 0);
53 int memory_test_const32(void * start
, unsigned int length
, u32 value
)
56 u32
* p
= (u32
*)start
;
57 u32
* pend
= (u32
*)(start
+ length
);
58 int count
= length
>> 2;
82 int memory_test_ads(void * start
, unsigned int length
, u32 mask
)
85 u32
* p
= (u32
*)start
;
86 u32
* pend
= (u32
*)(start
+ length
);
100 if (*p
++ != 0xffffffff) {
102 print32((long)p
- 4);
110 print32((long)p
- 4);
120 int memory_test_walking1(void * start
, unsigned int length
)
126 errors
+= memory_test_const32(start
, length
, value
);
133 /* negative runs == run forever */
135 #define INTERRUPT_HERE() \
137 if (serial_input_available()) { \
138 serial_input_char(); \
143 void memory_test(void *start
, unsigned int length
)
152 printdec(length
>> 20);
156 puts("Test series ");
157 printdec(series
+ 1);
160 /* these are looking at data issues, they flood the whole
161 * array with the same data
164 errors
+= memory_test_const32(start
, length
, 0x55555555);
166 errors
+= memory_test_const32(start
, length
, 0xaaaaaaaa);
168 errors
+= memory_test_const32(start
, length
, 0x55aa55aa);
170 errors
+= memory_test_const32(start
, length
, 0xaa55aa55);
172 errors
+= memory_test_const32(start
, length
, 0x00ff00ff);
174 errors
+= memory_test_const32(start
, length
, 0xff00ff00);
176 errors
+= memory_test_walking1(start
, length
);
180 /* this is looking at addressing issues, it floods only
181 * addresses meeting a walking mask with 0xffffffff (the rest
182 * is zeroed), and makes sure all the bits are only seen where
187 while (! (length
& mask
)) {
188 errors
+= memory_test_ads(start
, length
, mask
);