cpu.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * (C) Copyright 2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. /*
  9. * CPU test
  10. *
  11. * This test checks the arithmetic logic unit (ALU) of CPU.
  12. * It tests independently various groups of instructions using
  13. * run-time modification of the code to reduce the memory footprint.
  14. * For more details refer to post/cpu/ *.c files.
  15. */
  16. #include <watchdog.h>
  17. #include <post.h>
  18. #include <asm/mmu.h>
  19. #if CONFIG_POST & CONFIG_SYS_POST_CPU
  20. extern int cpu_post_test_cmp (void);
  21. extern int cpu_post_test_cmpi (void);
  22. extern int cpu_post_test_two (void);
  23. extern int cpu_post_test_twox (void);
  24. extern int cpu_post_test_three (void);
  25. extern int cpu_post_test_threex (void);
  26. extern int cpu_post_test_threei (void);
  27. extern int cpu_post_test_andi (void);
  28. extern int cpu_post_test_srawi (void);
  29. extern int cpu_post_test_rlwnm (void);
  30. extern int cpu_post_test_rlwinm (void);
  31. extern int cpu_post_test_rlwimi (void);
  32. extern int cpu_post_test_store (void);
  33. extern int cpu_post_test_load (void);
  34. extern int cpu_post_test_cr (void);
  35. extern int cpu_post_test_b (void);
  36. extern int cpu_post_test_multi (void);
  37. extern int cpu_post_test_string (void);
  38. extern int cpu_post_test_complex (void);
  39. DECLARE_GLOBAL_DATA_PTR;
  40. ulong cpu_post_makecr (long v)
  41. {
  42. ulong cr = 0;
  43. if (v < 0)
  44. cr |= 0x80000000;
  45. if (v > 0)
  46. cr |= 0x40000000;
  47. if (v == 0)
  48. cr |= 0x20000000;
  49. return cr;
  50. }
  51. int cpu_post_test (int flags)
  52. {
  53. int ic = icache_status ();
  54. int ret = 0;
  55. WATCHDOG_RESET();
  56. if (ic)
  57. icache_disable ();
  58. #ifdef CONFIG_4xx_DCACHE
  59. /* disable cache */
  60. change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, TLB_WORD2_I_ENABLE);
  61. #endif
  62. if (ret == 0)
  63. ret = cpu_post_test_cmp ();
  64. if (ret == 0)
  65. ret = cpu_post_test_cmpi ();
  66. if (ret == 0)
  67. ret = cpu_post_test_two ();
  68. if (ret == 0)
  69. ret = cpu_post_test_twox ();
  70. WATCHDOG_RESET();
  71. if (ret == 0)
  72. ret = cpu_post_test_three ();
  73. if (ret == 0)
  74. ret = cpu_post_test_threex ();
  75. if (ret == 0)
  76. ret = cpu_post_test_threei ();
  77. if (ret == 0)
  78. ret = cpu_post_test_andi ();
  79. WATCHDOG_RESET();
  80. if (ret == 0)
  81. ret = cpu_post_test_srawi ();
  82. if (ret == 0)
  83. ret = cpu_post_test_rlwnm ();
  84. if (ret == 0)
  85. ret = cpu_post_test_rlwinm ();
  86. if (ret == 0)
  87. ret = cpu_post_test_rlwimi ();
  88. WATCHDOG_RESET();
  89. if (ret == 0)
  90. ret = cpu_post_test_store ();
  91. if (ret == 0)
  92. ret = cpu_post_test_load ();
  93. if (ret == 0)
  94. ret = cpu_post_test_cr ();
  95. if (ret == 0)
  96. ret = cpu_post_test_b ();
  97. WATCHDOG_RESET();
  98. if (ret == 0)
  99. ret = cpu_post_test_multi ();
  100. WATCHDOG_RESET();
  101. if (ret == 0)
  102. ret = cpu_post_test_string ();
  103. if (ret == 0)
  104. ret = cpu_post_test_complex ();
  105. WATCHDOG_RESET();
  106. if (ic)
  107. icache_enable ();
  108. #ifdef CONFIG_4xx_DCACHE
  109. /* enable cache */
  110. change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, 0);
  111. #endif
  112. WATCHDOG_RESET();
  113. return ret;
  114. }
  115. #endif /* CONFIG_POST & CONFIG_SYS_POST_CPU */