You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mcd_arch_interface.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. /**
  13. * @brief Architecture-specific hard fault exception handler
  14. *
  15. * This function should be implemented by each supported architecture
  16. * to handle the architecture-specific stack frame processing.
  17. *
  18. * @param context Pointer to exception context (architecture-specific format)
  19. * @return int Always returns -1 to indicate fault condition
  20. */
  21. #ifdef PKG_USING_MCOREDUMP_ARCH_ARMV7M
  22. int armv7m_hard_fault_exception_hook(void *context);
  23. /**
  24. * @brief Architecture-specific register collection function
  25. *
  26. * This function extracts register values from the architecture-specific
  27. * stack frame format and stores them in the standard register sets.
  28. *
  29. * @param stack_top Pointer to the stack frame
  30. * @param core_regset Pointer to store ARM core registers
  31. * @param fp_regset Pointer to store FPU registers
  32. */
  33. void collect_registers_armv7m(uint32_t *stack_top, core_regset_type *core_regset, fp_regset_type *fp_regset);
  34. // 打印寄存器
  35. void print_registers_armv7m(core_regset_type *reg, fp_regset_type *fp_reg, char *thread);
  36. /* Generic interface macro for architecture-agnostic code */
  37. #define collect_registers collect_registers_armv7m
  38. #define print_registers print_registers_armv7m
  39. #define arch_hard_fault_exception_hook armv7m_hard_fault_exception_hook
  40. #elif defined(PKG_USING_MCOREDUMP_ARCH_ARMV8M)
  41. int armv8m_hard_fault_exception_hook(void *context);
  42. /**
  43. * @brief Architecture-specific register collection function
  44. *
  45. * This function extracts register values from the architecture-specific
  46. * stack frame format and stores them in the standard register sets.
  47. *
  48. * @param stack_top Pointer to the stack frame
  49. * @param core_regset Pointer to store ARM core registers
  50. * @param fp_regset Pointer to store FPU registers
  51. */
  52. void collect_registers_armv8m(uint32_t *stack_top, core_regset_type *core_regset, fp_regset_type *fp_regset);
  53. /* Generic interface macro for architecture-agnostic code */
  54. #define collect_registers collect_registers_armv8m
  55. #define print_registers
  56. #define arch_hard_fault_exception_hook armv8m_hard_fault_exception_hook
  57. #else
  58. #error "MCoredump does not support this architecture"
  59. #endif
  60. #endif /* __MCD_ARCH_INTERFACE_H__ */