multi.c 1.1 KB

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