gdb_machdep.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*-
  2. * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  3. *
  4. * Copyright (c) 2006 Marcel Moolenaar
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. * $FreeBSD$
  29. */
  30. #ifndef _MACHINE_GDB_MACHDEP_H_
  31. #define _MACHINE_GDB_MACHDEP_H_
  32. #ifdef BOOKE
  33. #define PPC_GDB_NREGS0 1
  34. #define PPC_GDB_NREGS4 (70 + 1)
  35. #define PPC_GDB_NREGS8 (1 + 32)
  36. #define PPC_GDB_NREGS16 0
  37. #else
  38. /*
  39. * 0 - 32*GPR(4/8)
  40. * 32 - 32*FPR(8)
  41. * 64 - PC, PS (4/8)
  42. * 66 - CR (4)
  43. * 67 - LR, CTR (4/8)
  44. * 69 - XER, FPSCR (4)
  45. * 71 - 32*VR(16)
  46. * 103 - VSCR, VRSAVE (4)
  47. */
  48. #define PPC_REGNUM_R0 0
  49. #define PPC_REGNUM_R31 (PPC_REGNUM_R0 + 31)
  50. #define PPC_REGNUM_FR0 32
  51. #define PPC_REGNUM_FR31 (PPC_REGNUM_FR0 + 31)
  52. #define PPC_REGNUM_PC 64
  53. #define PPC_REGNUM_PS 65
  54. #define PPC_REGNUM_CR 66
  55. #define PPC_REGNUM_LR 67
  56. #define PPC_REGNUM_CTR 68
  57. #define PPC_REGNUM_XER 69
  58. #define PPC_REGNUM_FPSCR 70
  59. #define PPC_REGNUM_VR0 71
  60. #define PPC_REGNUM_VR31 (PPC_REGNUM_VR0 + 31)
  61. #define PPC_GDB_NREGS0 0
  62. #ifdef __powerpc64__
  63. #define PPC_GDB_NREGS4 5
  64. #define PPC_GDB_NREGS8 (64 + 4)
  65. #else
  66. #define PPC_GDB_NREGS4 (32 + 7 + 2)
  67. #define PPC_GDB_NREGS8 32
  68. #endif
  69. #define PPC_GDB_NREGS16 32
  70. #endif
  71. #define GDB_NREGS (PPC_GDB_NREGS0 + PPC_GDB_NREGS4 + \
  72. PPC_GDB_NREGS8 + PPC_GDB_NREGS16)
  73. #define GDB_REG_PC 64
  74. #define GDB_BUFSZ (PPC_GDB_NREGS4 * 8 + \
  75. PPC_GDB_NREGS8 * 16 + \
  76. PPC_GDB_NREGS16 * 32)
  77. static __inline size_t
  78. gdb_cpu_regsz(int regnum)
  79. {
  80. #ifdef BOOKE
  81. if (regnum == 70)
  82. return (0);
  83. if (regnum == 71 || regnum >= 73)
  84. return (8);
  85. #else
  86. #ifdef __powerpc64__
  87. if ((regnum >= PPC_REGNUM_R0 && regnum <= PPC_REGNUM_PS) ||
  88. regnum == PPC_REGNUM_LR || regnum == PPC_REGNUM_CTR)
  89. return (8);
  90. #else
  91. if (regnum >= PPC_REGNUM_FR0 && regnum <= PPC_REGNUM_FR31)
  92. return (8);
  93. #endif
  94. if (regnum >= PPC_REGNUM_VR0 && regnum <= PPC_REGNUM_VR31)
  95. return (16);
  96. #endif
  97. return (4);
  98. }
  99. static __inline int
  100. gdb_cpu_query(void)
  101. {
  102. return (0);
  103. }
  104. static __inline void *
  105. gdb_begin_write(void)
  106. {
  107. return (NULL);
  108. }
  109. static __inline void
  110. gdb_end_write(void *arg __unused)
  111. {
  112. }
  113. void *gdb_cpu_getreg(int, size_t *);
  114. void gdb_cpu_setreg(int, void *);
  115. int gdb_cpu_signal(int, int);
  116. void gdb_cpu_do_offsets(void);
  117. #endif /* !_MACHINE_GDB_MACHDEP_H_ */