ptrace-vsx.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (C) 2015 Anshuman Khandual, IBM Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #define VEC_MAX 128
  10. #define VSX_MAX 32
  11. #define VMX_MAX 32
  12. /*
  13. * unsigned long vsx[32]
  14. * unsigned long load[128]
  15. */
  16. int validate_vsx(unsigned long *vsx, unsigned long *load)
  17. {
  18. int i;
  19. for (i = 0; i < VSX_MAX; i++) {
  20. if (vsx[i] != load[2 * i + 1]) {
  21. printf("vsx[%d]: %lx load[%d] %lx\n",
  22. i, vsx[i], 2 * i + 1, load[2 * i + 1]);
  23. return TEST_FAIL;
  24. }
  25. }
  26. return TEST_PASS;
  27. }
  28. /*
  29. * unsigned long vmx[32][2]
  30. * unsigned long load[128]
  31. */
  32. int validate_vmx(unsigned long vmx[][2], unsigned long *load)
  33. {
  34. int i;
  35. for (i = 0; i < VMX_MAX; i++) {
  36. #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  37. if ((vmx[i][0] != load[64 + 2 * i]) ||
  38. (vmx[i][1] != load[65 + 2 * i])) {
  39. printf("vmx[%d][0]: %lx load[%d] %lx\n",
  40. i, vmx[i][0], 64 + 2 * i,
  41. load[64 + 2 * i]);
  42. printf("vmx[%d][1]: %lx load[%d] %lx\n",
  43. i, vmx[i][1], 65 + 2 * i,
  44. load[65 + 2 * i]);
  45. return TEST_FAIL;
  46. }
  47. #else /*
  48. * In LE each value pair is stored in an
  49. * alternate manner.
  50. */
  51. if ((vmx[i][0] != load[65 + 2 * i]) ||
  52. (vmx[i][1] != load[64 + 2 * i])) {
  53. printf("vmx[%d][0]: %lx load[%d] %lx\n",
  54. i, vmx[i][0], 65 + 2 * i,
  55. load[65 + 2 * i]);
  56. printf("vmx[%d][1]: %lx load[%d] %lx\n",
  57. i, vmx[i][1], 64 + 2 * i,
  58. load[64 + 2 * i]);
  59. return TEST_FAIL;
  60. }
  61. #endif
  62. }
  63. return TEST_PASS;
  64. }
  65. /*
  66. * unsigned long store[128]
  67. * unsigned long load[128]
  68. */
  69. int compare_vsx_vmx(unsigned long *store, unsigned long *load)
  70. {
  71. int i;
  72. for (i = 0; i < VSX_MAX; i++) {
  73. if (store[1 + 2 * i] != load[1 + 2 * i]) {
  74. printf("store[%d]: %lx load[%d] %lx\n",
  75. 1 + 2 * i, store[i],
  76. 1 + 2 * i, load[i]);
  77. return TEST_FAIL;
  78. }
  79. }
  80. #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  81. for (i = 64; i < VEC_MAX; i++) {
  82. if (store[i] != load[i]) {
  83. printf("store[%d]: %lx load[%d] %lx\n",
  84. i, store[i], i, load[i]);
  85. return TEST_FAIL;
  86. }
  87. }
  88. #else /* In LE each value pair is stored in an alternate manner */
  89. for (i = 64; i < VEC_MAX; i++) {
  90. if (!(i % 2) && (store[i] != load[i+1])) {
  91. printf("store[%d]: %lx load[%d] %lx\n",
  92. i, store[i], i+1, load[i+1]);
  93. return TEST_FAIL;
  94. }
  95. if ((i % 2) && (store[i] != load[i-1])) {
  96. printf("here store[%d]: %lx load[%d] %lx\n",
  97. i, store[i], i-1, load[i-1]);
  98. return TEST_FAIL;
  99. }
  100. }
  101. #endif
  102. return TEST_PASS;
  103. }
  104. void load_vsx_vmx(unsigned long *load, unsigned long *vsx,
  105. unsigned long vmx[][2])
  106. {
  107. int i;
  108. for (i = 0; i < VSX_MAX; i++)
  109. vsx[i] = load[1 + 2 * i];
  110. for (i = 0; i < VMX_MAX; i++) {
  111. vmx[i][0] = load[64 + 2 * i];
  112. vmx[i][1] = load[65 + 2 * i];
  113. }
  114. }
  115. void loadvsx(void *p, int tmp);
  116. void storevsx(void *p, int tmp);