wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | |
| 26 | /* |
| 27 | * CPU test |
| 28 | * |
| 29 | * This test checks the arithmetic logic unit (ALU) of CPU. |
| 30 | * It tests independently various groups of instructions using |
| 31 | * run-time modification of the code to reduce the memory footprint. |
| 32 | * For more details refer to post/cpu/ *.c files. |
| 33 | */ |
| 34 | |
| 35 | #ifdef CONFIG_POST |
| 36 | |
| 37 | #include <watchdog.h> |
| 38 | #include <post.h> |
| 39 | |
| 40 | #if CONFIG_POST & CFG_POST_CPU |
| 41 | |
| 42 | extern int cpu_post_test_cmp (void); |
| 43 | extern int cpu_post_test_cmpi (void); |
| 44 | extern int cpu_post_test_two (void); |
| 45 | extern int cpu_post_test_twox (void); |
| 46 | extern int cpu_post_test_three (void); |
| 47 | extern int cpu_post_test_threex (void); |
| 48 | extern int cpu_post_test_threei (void); |
| 49 | extern int cpu_post_test_andi (void); |
| 50 | extern int cpu_post_test_srawi (void); |
| 51 | extern int cpu_post_test_rlwnm (void); |
| 52 | extern int cpu_post_test_rlwinm (void); |
| 53 | extern int cpu_post_test_rlwimi (void); |
| 54 | extern int cpu_post_test_store (void); |
| 55 | extern int cpu_post_test_load (void); |
| 56 | extern int cpu_post_test_cr (void); |
| 57 | extern int cpu_post_test_b (void); |
| 58 | extern int cpu_post_test_multi (void); |
| 59 | extern int cpu_post_test_string (void); |
| 60 | extern int cpu_post_test_complex (void); |
| 61 | |
| 62 | ulong cpu_post_makecr (long v) |
| 63 | { |
| 64 | ulong cr = 0; |
| 65 | |
| 66 | if (v < 0) |
| 67 | cr |= 0x80000000; |
| 68 | if (v > 0) |
| 69 | cr |= 0x40000000; |
| 70 | if (v == 0) |
| 71 | cr |= 0x20000000; |
| 72 | |
| 73 | return cr; |
| 74 | } |
| 75 | |
| 76 | int cpu_post_test (int flags) |
| 77 | { |
| 78 | int ic = icache_status (); |
| 79 | int ret = 0; |
| 80 | |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 81 | WATCHDOG_RESET(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 82 | if (ic) |
| 83 | icache_disable (); |
| 84 | |
| 85 | if (ret == 0) |
| 86 | ret = cpu_post_test_cmp (); |
| 87 | if (ret == 0) |
| 88 | ret = cpu_post_test_cmpi (); |
| 89 | if (ret == 0) |
| 90 | ret = cpu_post_test_two (); |
| 91 | if (ret == 0) |
| 92 | ret = cpu_post_test_twox (); |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 93 | WATCHDOG_RESET(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 94 | if (ret == 0) |
| 95 | ret = cpu_post_test_three (); |
| 96 | if (ret == 0) |
| 97 | ret = cpu_post_test_threex (); |
| 98 | if (ret == 0) |
| 99 | ret = cpu_post_test_threei (); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 100 | if (ret == 0) |
| 101 | ret = cpu_post_test_andi (); |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 102 | WATCHDOG_RESET(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 103 | if (ret == 0) |
| 104 | ret = cpu_post_test_srawi (); |
| 105 | if (ret == 0) |
| 106 | ret = cpu_post_test_rlwnm (); |
| 107 | if (ret == 0) |
| 108 | ret = cpu_post_test_rlwinm (); |
| 109 | if (ret == 0) |
| 110 | ret = cpu_post_test_rlwimi (); |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 111 | WATCHDOG_RESET(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 112 | if (ret == 0) |
| 113 | ret = cpu_post_test_store (); |
| 114 | if (ret == 0) |
| 115 | ret = cpu_post_test_load (); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 116 | if (ret == 0) |
| 117 | ret = cpu_post_test_cr (); |
| 118 | if (ret == 0) |
| 119 | ret = cpu_post_test_b (); |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 120 | WATCHDOG_RESET(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 121 | if (ret == 0) |
| 122 | ret = cpu_post_test_multi (); |
wdenk | 5ceea26 | 2005-06-05 20:30:43 +0000 | [diff] [blame] | 123 | WATCHDOG_RESET(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 124 | if (ret == 0) |
| 125 | ret = cpu_post_test_string (); |
| 126 | if (ret == 0) |
| 127 | ret = cpu_post_test_complex (); |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 128 | WATCHDOG_RESET(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 129 | |
| 130 | if (ic) |
| 131 | icache_enable (); |
| 132 | |
wdenk | 2029f4d | 2002-11-21 23:11:29 +0000 | [diff] [blame] | 133 | WATCHDOG_RESET(); |
| 134 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 135 | return ret; |
| 136 | } |
| 137 | |
| 138 | #endif /* CONFIG_POST & CFG_POST_CPU */ |
| 139 | #endif /* CONFIG_POST */ |