Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

mcd_arch_interface.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2025, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2025-08-16 Rbb666 first version
  9. */
  10. #ifndef __MCD_ARCH_INTERFACE_H__
  11. #define __MCD_ARCH_INTERFACE_H__
  12. #include <stdint.h>
  13. /**
  14. * @brief Architecture-specific hard fault exception handler
  15. *
  16. * This function should be implemented by each supported architecture
  17. * to handle the architecture-specific stack frame processing.
  18. *
  19. * @param context Pointer to exception context (architecture-specific format)
  20. * @return int Always returns -1 to indicate fault condition
  21. */
  22. #ifdef PKG_USING_MCOREDUMP_ARCH_ARMV7M
  23. int armv7m_hard_fault_exception_hook(void *context);
  24. /**
  25. * @brief Architecture-specific register collection function
  26. *
  27. * This function extracts register values from the architecture-specific
  28. * stack frame format and stores them in the standard register sets.
  29. *
  30. * @param stack_top Pointer to the stack frame
  31. * @param core_regset Pointer to store ARM core registers
  32. * @param fp_regset Pointer to store FPU registers
  33. */
  34. void collect_registers_armv7m(uint32_t *stack_top, core_regset_type *core_regset, fp_regset_type *fp_regset);
  35. // 打印寄存器
  36. void print_registers_armv7m(core_regset_type *reg, fp_regset_type *fp_reg, char *thread);
  37. // 打印一段内存
  38. void print_mem_armv7m(uint32_t addr, uint32_t len);
  39. /* Generic interface macro for architecture-agnostic code */
  40. #define collect_registers collect_registers_armv7m
  41. #define print_registers print_registers_armv7m
  42. #define print_mem print_mem_armv7m
  43. #define arch_hard_fault_exception_hook armv7m_hard_fault_exception_hook
  44. #elif defined(PKG_USING_MCOREDUMP_ARCH_ARMV8M)
  45. int armv8m_hard_fault_exception_hook(void *context);
  46. /**
  47. * @brief Architecture-specific register collection function
  48. *
  49. * This function extracts register values from the architecture-specific
  50. * stack frame format and stores them in the standard register sets.
  51. *
  52. * @param stack_top Pointer to the stack frame
  53. * @param core_regset Pointer to store ARM core registers
  54. * @param fp_regset Pointer to store FPU registers
  55. */
  56. void collect_registers_armv8m(uint32_t *stack_top, core_regset_type *core_regset, fp_regset_type *fp_regset);
  57. /* Generic interface macro for architecture-agnostic code */
  58. #define collect_registers collect_registers_armv8m
  59. #define print_registers
  60. #define print_mem
  61. #define arch_hard_fault_exception_hook armv8m_hard_fault_exception_hook
  62. #else
  63. #error "MCoredump does not support this architecture"
  64. #endif
  65. #endif /* __MCD_ARCH_INTERFACE_H__ */