rthw.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /*
  7. * File : rthw.h
  8. *
  9. * Change Logs:
  10. * Date Author Notes
  11. * 2006-03-18 Bernard the first version
  12. * 2006-04-25 Bernard add rt_hw_context_switch_interrupt declaration
  13. * 2006-09-24 Bernard add rt_hw_context_switch_to declaration
  14. * 2012-12-29 Bernard add rt_hw_exception_install declaration
  15. * 2017-10-17 Hichard add some micros
  16. */
  17. #ifndef __RT_HW_H__
  18. #define __RT_HW_H__
  19. #include <rtthread.h>
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /*
  24. * Some macros define
  25. */
  26. #ifndef HWREG32
  27. #define HWREG32(x) (*((volatile rt_uint32_t *)(x)))
  28. #endif
  29. #ifndef HWREG16
  30. #define HWREG16(x) (*((volatile rt_uint16_t *)(x)))
  31. #endif
  32. #ifndef HWREG8
  33. #define HWREG8(x) (*((volatile rt_uint8_t *)(x)))
  34. #endif
  35. #ifndef RT_CPU_CACHE_LINE_SZ
  36. #define RT_CPU_CACHE_LINE_SZ 32
  37. #endif
  38. enum RT_HW_CACHE_OPS
  39. {
  40. RT_HW_CACHE_FLUSH = 0x01,
  41. RT_HW_CACHE_INVALIDATE = 0x02,
  42. };
  43. /*
  44. * CPU interfaces
  45. */
  46. void rt_hw_cpu_icache_enable(void);
  47. void rt_hw_cpu_icache_disable(void);
  48. rt_base_t rt_hw_cpu_icache_status(void);
  49. void rt_hw_cpu_icache_ops(int ops, void* addr, int size);
  50. void rt_hw_cpu_dcache_enable(void);
  51. void rt_hw_cpu_dcache_disable(void);
  52. rt_base_t rt_hw_cpu_dcache_status(void);
  53. void rt_hw_cpu_dcache_ops(int ops, void* addr, int size);
  54. void rt_hw_cpu_reset(void);
  55. void rt_hw_cpu_shutdown(void);
  56. rt_uint8_t *rt_hw_stack_init(void *entry,
  57. void *parameter,
  58. rt_uint8_t *stack_addr,
  59. void *exit);
  60. /*
  61. * Interrupt handler definition
  62. */
  63. typedef void (*rt_isr_handler_t)(int vector, void *param);
  64. struct rt_irq_desc
  65. {
  66. rt_isr_handler_t handler;
  67. void *param;
  68. #ifdef RT_USING_INTERRUPT_INFO
  69. char name[RT_NAME_MAX];
  70. rt_uint32_t counter;
  71. #endif
  72. };
  73. /*
  74. * Interrupt interfaces
  75. */
  76. void rt_hw_interrupt_init(void);
  77. void rt_hw_interrupt_mask(int vector);
  78. void rt_hw_interrupt_umask(int vector);
  79. rt_isr_handler_t rt_hw_interrupt_install(int vector,
  80. rt_isr_handler_t handler,
  81. void *param,
  82. char *name);
  83. rt_base_t rt_hw_interrupt_disable(void);
  84. void rt_hw_interrupt_enable(rt_base_t level);
  85. /*
  86. * Context interfaces
  87. */
  88. void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to);
  89. void rt_hw_context_switch_to(rt_uint32_t to);
  90. void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to);
  91. void rt_hw_console_output(const char *str);
  92. void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry);
  93. void rt_hw_show_memory(rt_uint32_t addr, rt_uint32_t size);
  94. /*
  95. * Exception interfaces
  96. */
  97. void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context));
  98. /*
  99. * delay interfaces
  100. */
  101. void rt_hw_us_delay(rt_uint32_t us);
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105. #endif