string.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * Load/store string instructions: lswi, stswi, lswx, stswx
  27. *
  28. * Several consecutive bytes from a source memory buffer are loaded
  29. * left to right into GPRs. After that, the bytes are stored
  30. * from the GPRs into a target memory buffer. The contents
  31. * of the source and target buffers are then compared.
  32. */
  33. #ifdef CONFIG_POST
  34. #include <post.h>
  35. #include "cpu_asm.h"
  36. #if CONFIG_POST & CFG_POST_CPU
  37. extern void cpu_post_exec_02 (ulong *code, ulong op1, ulong op2);
  38. extern void cpu_post_exec_04 (ulong *code, ulong op1, ulong op2, ulong op3,
  39. ulong op4);
  40. #include <bedbug/regs.h>
  41. int cpu_post_test_string (void)
  42. {
  43. int ret = 0;
  44. unsigned int i;
  45. if (ret == 0)
  46. {
  47. char src [31], dst [31];
  48. ulong code[] =
  49. {
  50. ASM_LSWI(5, 3, 31),
  51. ASM_STSWI(5, 4, 31),
  52. ASM_BLR,
  53. };
  54. for (i = 0; i < sizeof(src); i ++)
  55. {
  56. src[i] = (char) i;
  57. dst[i] = 0;
  58. }
  59. cpu_post_exec_02(code, (ulong)src, (ulong)dst);
  60. ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1;
  61. }
  62. if (ret == 0)
  63. {
  64. char src [95], dst [95];
  65. ulong code[] =
  66. {
  67. ASM_LSWX(8, 3, 5),
  68. ASM_STSWX(8, 4, 5),
  69. ASM_BLR,
  70. };
  71. for (i = 0; i < sizeof(src); i ++)
  72. {
  73. src[i] = (char) i;
  74. dst[i] = 0;
  75. }
  76. cpu_post_exec_04(code, (ulong)src, (ulong)dst, 0, sizeof(src));
  77. ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1;
  78. }
  79. if (ret != 0)
  80. {
  81. post_log ("Error at string test !\n");
  82. }
  83. return ret;
  84. }
  85. #endif
  86. #endif