cpu.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. #include <watchdog.h>
  33. #include <post.h>
  34. #include <asm/mmu.h>
  35. #if CONFIG_POST & CONFIG_SYS_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. DECLARE_GLOBAL_DATA_PTR;
  56. ulong cpu_post_makecr (long v)
  57. {
  58. ulong cr = 0;
  59. if (v < 0)
  60. cr |= 0x80000000;
  61. if (v > 0)
  62. cr |= 0x40000000;
  63. if (v == 0)
  64. cr |= 0x20000000;
  65. return cr;
  66. }
  67. int cpu_post_test (int flags)
  68. {
  69. int ic = icache_status ();
  70. int ret = 0;
  71. WATCHDOG_RESET();
  72. if (ic)
  73. icache_disable ();
  74. #ifdef CONFIG_4xx_DCACHE
  75. /* disable cache */
  76. change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, TLB_WORD2_I_ENABLE);
  77. #endif
  78. if (ret == 0)
  79. ret = cpu_post_test_cmp ();
  80. if (ret == 0)
  81. ret = cpu_post_test_cmpi ();
  82. if (ret == 0)
  83. ret = cpu_post_test_two ();
  84. if (ret == 0)
  85. ret = cpu_post_test_twox ();
  86. WATCHDOG_RESET();
  87. if (ret == 0)
  88. ret = cpu_post_test_three ();
  89. if (ret == 0)
  90. ret = cpu_post_test_threex ();
  91. if (ret == 0)
  92. ret = cpu_post_test_threei ();
  93. if (ret == 0)
  94. ret = cpu_post_test_andi ();
  95. WATCHDOG_RESET();
  96. if (ret == 0)
  97. ret = cpu_post_test_srawi ();
  98. if (ret == 0)
  99. ret = cpu_post_test_rlwnm ();
  100. if (ret == 0)
  101. ret = cpu_post_test_rlwinm ();
  102. if (ret == 0)
  103. ret = cpu_post_test_rlwimi ();
  104. WATCHDOG_RESET();
  105. if (ret == 0)
  106. ret = cpu_post_test_store ();
  107. if (ret == 0)
  108. ret = cpu_post_test_load ();
  109. if (ret == 0)
  110. ret = cpu_post_test_cr ();
  111. if (ret == 0)
  112. ret = cpu_post_test_b ();
  113. WATCHDOG_RESET();
  114. if (ret == 0)
  115. ret = cpu_post_test_multi ();
  116. WATCHDOG_RESET();
  117. if (ret == 0)
  118. ret = cpu_post_test_string ();
  119. if (ret == 0)
  120. ret = cpu_post_test_complex ();
  121. WATCHDOG_RESET();
  122. if (ic)
  123. icache_enable ();
  124. #ifdef CONFIG_4xx_DCACHE
  125. /* enable cache */
  126. change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, 0);
  127. #endif
  128. WATCHDOG_RESET();
  129. return ret;
  130. }
  131. #endif /* CONFIG_POST & CONFIG_SYS_POST_CPU */