cpu.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. #include <common.h>
  24. /*
  25. * CPU test
  26. *
  27. * This test checks the arithmetic logic unit (ALU) of CPU.
  28. * It tests independently various groups of instructions using
  29. * run-time modification of the code to reduce the memory footprint.
  30. * For more details refer to post/cpu/ *.c files.
  31. */
  32. #ifdef CONFIG_POST
  33. #include <watchdog.h>
  34. #include <post.h>
  35. #if CONFIG_POST & CFG_POST_CPU
  36. extern int cpu_post_test_cmp (void);
  37. extern int cpu_post_test_cmpi (void);
  38. extern int cpu_post_test_two (void);
  39. extern int cpu_post_test_twox (void);
  40. extern int cpu_post_test_three (void);
  41. extern int cpu_post_test_threex (void);
  42. extern int cpu_post_test_threei (void);
  43. extern int cpu_post_test_andi (void);
  44. extern int cpu_post_test_srawi (void);
  45. extern int cpu_post_test_rlwnm (void);
  46. extern int cpu_post_test_rlwinm (void);
  47. extern int cpu_post_test_rlwimi (void);
  48. extern int cpu_post_test_store (void);
  49. extern int cpu_post_test_load (void);
  50. extern int cpu_post_test_cr (void);
  51. extern int cpu_post_test_b (void);
  52. extern int cpu_post_test_multi (void);
  53. extern int cpu_post_test_string (void);
  54. extern int cpu_post_test_complex (void);
  55. ulong cpu_post_makecr (long v)
  56. {
  57. ulong cr = 0;
  58. if (v < 0)
  59. cr |= 0x80000000;
  60. if (v > 0)
  61. cr |= 0x40000000;
  62. if (v == 0)
  63. cr |= 0x20000000;
  64. return cr;
  65. }
  66. int cpu_post_test (int flags)
  67. {
  68. int ic = icache_status ();
  69. int ret = 0;
  70. WATCHDOG_RESET();
  71. if (ic)
  72. icache_disable ();
  73. if (ret == 0)
  74. ret = cpu_post_test_cmp ();
  75. if (ret == 0)
  76. ret = cpu_post_test_cmpi ();
  77. if (ret == 0)
  78. ret = cpu_post_test_two ();
  79. if (ret == 0)
  80. ret = cpu_post_test_twox ();
  81. WATCHDOG_RESET();
  82. if (ret == 0)
  83. ret = cpu_post_test_three ();
  84. if (ret == 0)
  85. ret = cpu_post_test_threex ();
  86. if (ret == 0)
  87. ret = cpu_post_test_threei ();
  88. if (ret == 0)
  89. ret = cpu_post_test_andi ();
  90. WATCHDOG_RESET();
  91. if (ret == 0)
  92. ret = cpu_post_test_srawi ();
  93. if (ret == 0)
  94. ret = cpu_post_test_rlwnm ();
  95. if (ret == 0)
  96. ret = cpu_post_test_rlwinm ();
  97. if (ret == 0)
  98. ret = cpu_post_test_rlwimi ();
  99. WATCHDOG_RESET();
  100. if (ret == 0)
  101. ret = cpu_post_test_store ();
  102. if (ret == 0)
  103. ret = cpu_post_test_load ();
  104. if (ret == 0)
  105. ret = cpu_post_test_cr ();
  106. if (ret == 0)
  107. ret = cpu_post_test_b ();
  108. WATCHDOG_RESET();
  109. if (ret == 0)
  110. ret = cpu_post_test_multi ();
  111. if (ret == 0)
  112. ret = cpu_post_test_string ();
  113. if (ret == 0)
  114. ret = cpu_post_test_complex ();
  115. WATCHDOG_RESET();
  116. if (ic)
  117. icache_enable ();
  118. WATCHDOG_RESET();
  119. return ret;
  120. }
  121. #endif /* CONFIG_POST & CFG_POST_CPU */
  122. #endif /* CONFIG_POST */