kgdb.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * ARM KGDB support
  4. *
  5. * Author: Deepak Saxena <dsaxena@mvista.com>
  6. *
  7. * Copyright (C) 2002 MontaVista Software Inc.
  8. *
  9. */
  10. #ifndef __ARM_KGDB_H__
  11. #define __ARM_KGDB_H__
  12. #include <linux/ptrace.h>
  13. #include <asm/opcodes.h>
  14. /*
  15. * GDB assumes that we're a user process being debugged, so
  16. * it will send us an SWI command to write into memory as the
  17. * debug trap. When an SWI occurs, the next instruction addr is
  18. * placed into R14_svc before jumping to the vector trap.
  19. * This doesn't work for kernel debugging as we are already in SVC
  20. * we would loose the kernel's LR, which is a bad thing. This
  21. * is bad thing.
  22. *
  23. * By doing this as an undefined instruction trap, we force a mode
  24. * switch from SVC to UND mode, allowing us to save full kernel state.
  25. *
  26. * We also define a KGDB_COMPILED_BREAK which can be used to compile
  27. * in breakpoints. This is important for things like sysrq-G and for
  28. * the initial breakpoint from trap_init().
  29. *
  30. * Note to ARM HW designers: Add real trap support like SH && PPC to
  31. * make our lives much much simpler. :)
  32. */
  33. #define BREAK_INSTR_SIZE 4
  34. #define GDB_BREAKINST 0xef9f0001
  35. #define KGDB_BREAKINST 0xe7ffdefe
  36. #define KGDB_COMPILED_BREAK 0xe7ffdeff
  37. #define CACHE_FLUSH_IS_SAFE 1
  38. #ifndef __ASSEMBLY__
  39. static inline void arch_kgdb_breakpoint(void)
  40. {
  41. asm(__inst_arm(0xe7ffdeff));
  42. }
  43. extern void kgdb_handle_bus_error(void);
  44. extern int kgdb_fault_expected;
  45. #endif /* !__ASSEMBLY__ */
  46. /*
  47. * From Kevin Hilman:
  48. *
  49. * gdb is expecting the following registers layout.
  50. *
  51. * r0-r15: 1 long word each
  52. * f0-f7: unused, 3 long words each !!
  53. * fps: unused, 1 long word
  54. * cpsr: 1 long word
  55. *
  56. * Even though f0-f7 and fps are not used, they need to be
  57. * present in the registers sent for correct processing in
  58. * the host-side gdb.
  59. *
  60. * In particular, it is crucial that CPSR is in the right place,
  61. * otherwise gdb will not be able to correctly interpret stepping over
  62. * conditional branches.
  63. */
  64. #define _GP_REGS 16
  65. #define _FP_REGS 8
  66. #define _EXTRA_REGS 2
  67. #define GDB_MAX_REGS (_GP_REGS + (_FP_REGS * 3) + _EXTRA_REGS)
  68. #define DBG_MAX_REG_NUM (_GP_REGS + _FP_REGS + _EXTRA_REGS)
  69. #define KGDB_MAX_NO_CPUS 1
  70. #define BUFMAX 400
  71. #define NUMREGBYTES (GDB_MAX_REGS << 2)
  72. #define NUMCRITREGBYTES (32 << 2)
  73. #define _R0 0
  74. #define _R1 1
  75. #define _R2 2
  76. #define _R3 3
  77. #define _R4 4
  78. #define _R5 5
  79. #define _R6 6
  80. #define _R7 7
  81. #define _R8 8
  82. #define _R9 9
  83. #define _R10 10
  84. #define _FP 11
  85. #define _IP 12
  86. #define _SPT 13
  87. #define _LR 14
  88. #define _PC 15
  89. #define _CPSR (GDB_MAX_REGS - 1)
  90. /*
  91. * So that we can denote the end of a frame for tracing,
  92. * in the simple case:
  93. */
  94. #define CFI_END_FRAME(func) __CFI_END_FRAME(_PC, _SPT, func)
  95. #endif /* __ASM_KGDB_H__ */