fpu.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (C) 2007
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * Author: Sergei Poselenov <sposelenov@emcraft.com>
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. /*
  27. * FPU 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. #include <post.h>
  35. #if CONFIG_POST & CONFIG_SYS_POST_FPU
  36. #include <watchdog.h>
  37. extern int fpu_status (void);
  38. extern void fpu_enable (void);
  39. extern void fpu_disable (void);
  40. extern int fpu_post_test_math1 (void);
  41. extern int fpu_post_test_math2 (void);
  42. extern int fpu_post_test_math3 (void);
  43. extern int fpu_post_test_math4 (void);
  44. extern int fpu_post_test_math5 (void);
  45. extern int fpu_post_test_math6 (void);
  46. extern int fpu_post_test_math7 (void);
  47. int fpu_post_test (int flags)
  48. {
  49. int fpu = fpu_status ();
  50. int ret = 0;
  51. WATCHDOG_RESET ();
  52. if (!fpu)
  53. fpu_enable ();
  54. if (ret == 0)
  55. ret = fpu_post_test_math1 ();
  56. if (ret == 0)
  57. ret = fpu_post_test_math2 ();
  58. if (ret == 0)
  59. ret = fpu_post_test_math3 ();
  60. if (ret == 0)
  61. ret = fpu_post_test_math4 ();
  62. if (ret == 0)
  63. ret = fpu_post_test_math5 ();
  64. if (ret == 0)
  65. ret = fpu_post_test_math6 ();
  66. if (ret == 0)
  67. ret = fpu_post_test_math7 ();
  68. if (!fpu)
  69. fpu_disable ();
  70. WATCHDOG_RESET ();
  71. return ret;
  72. }
  73. #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */