multi.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2002
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #include <common.h>
  7. #include <irq_func.h>
  8. /*
  9. * CPU test
  10. * Load/store multiple word instructions: lmw, stmw
  11. *
  12. * 27 consecutive words are loaded from a source memory buffer
  13. * into GPRs r5 through r31. After that, 27 consecutive words are stored
  14. * from the GPRs r5 through r31 into a target memory buffer. The contents
  15. * of the source and target buffers are then compared.
  16. */
  17. #include <post.h>
  18. #include "cpu_asm.h"
  19. #if CONFIG_POST & CONFIG_SYS_POST_CPU
  20. extern void cpu_post_exec_02(ulong *code, ulong op1, ulong op2);
  21. int cpu_post_test_multi(void)
  22. {
  23. int ret = 0;
  24. unsigned int i;
  25. ulong src[27], dst[27];
  26. int flag = disable_interrupts();
  27. ulong code[] = {
  28. ASM_LMW(5, 3, 0), /* lmw r5, 0(r3) */
  29. ASM_STMW(5, 4, 0), /* stmr r5, 0(r4) */
  30. ASM_BLR, /* blr */
  31. };
  32. for (i = 0; i < ARRAY_SIZE(src); ++i) {
  33. src[i] = i;
  34. dst[i] = 0;
  35. }
  36. cpu_post_exec_02(code, (ulong) src, (ulong) dst);
  37. ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1;
  38. if (ret != 0)
  39. post_log("Error at multi test !\n");
  40. if (flag)
  41. enable_interrupts();
  42. return ret;
  43. }
  44. #endif