rthw.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * File : rthw.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2006-03-18 Bernard the first version
  23. * 2006-04-25 Bernard add rt_hw_context_switch_interrupt declaration
  24. * 2006-09-24 Bernard add rt_hw_context_switch_to declaration
  25. * 2012-12-29 Bernard add rt_hw_exception_install declaration
  26. * 2017-10-17 Hichard add some micros
  27. */
  28. #ifndef __RT_HW_H__
  29. #define __RT_HW_H__
  30. #include <rtthread.h>
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /*
  35. * Some macros define
  36. */
  37. #ifndef HWREG32
  38. #define HWREG32(x) (*((volatile rt_uint32_t *)(x)))
  39. #endif
  40. #ifndef HWREG16
  41. #define HWREG16(x) (*((volatile rt_uint16_t *)(x)))
  42. #endif
  43. #ifndef HWREG8
  44. #define HWREG8(x) (*((volatile rt_uint8_t *)(x)))
  45. #endif
  46. #ifndef RT_CPU_CACHE_LINE_SZ
  47. #define RT_CPU_CACHE_LINE_SZ 32
  48. #endif
  49. enum RT_HW_CACHE_OPS
  50. {
  51. RT_HW_CACHE_FLUSH = 0x01,
  52. RT_HW_CACHE_INVALIDATE = 0x02,
  53. };
  54. /*
  55. * CPU interfaces
  56. */
  57. void rt_hw_cpu_icache_enable(void);
  58. void rt_hw_cpu_icache_disable(void);
  59. rt_base_t rt_hw_cpu_icache_status(void);
  60. void rt_hw_cpu_icache_ops(int ops, void* addr, int size);
  61. void rt_hw_cpu_dcache_enable(void);
  62. void rt_hw_cpu_dcache_disable(void);
  63. rt_base_t rt_hw_cpu_dcache_status(void);
  64. void rt_hw_cpu_dcache_ops(int ops, void* addr, int size);
  65. void rt_hw_cpu_reset(void);
  66. void rt_hw_cpu_shutdown(void);
  67. rt_uint8_t *rt_hw_stack_init(void *entry,
  68. void *parameter,
  69. rt_uint8_t *stack_addr,
  70. void *exit);
  71. /*
  72. * Interrupt handler definition
  73. */
  74. typedef void (*rt_isr_handler_t)(int vector, void *param);
  75. struct rt_irq_desc
  76. {
  77. rt_isr_handler_t handler;
  78. void *param;
  79. #ifdef RT_USING_INTERRUPT_INFO
  80. char name[RT_NAME_MAX];
  81. rt_uint32_t counter;
  82. #endif
  83. };
  84. /*
  85. * Interrupt interfaces
  86. */
  87. void rt_hw_interrupt_init(void);
  88. void rt_hw_interrupt_mask(int vector);
  89. void rt_hw_interrupt_umask(int vector);
  90. rt_isr_handler_t rt_hw_interrupt_install(int vector,
  91. rt_isr_handler_t handler,
  92. void *param,
  93. char *name);
  94. rt_base_t rt_hw_interrupt_disable(void);
  95. void rt_hw_interrupt_enable(rt_base_t level);
  96. /*
  97. * Context interfaces
  98. */
  99. void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to);
  100. void rt_hw_context_switch_to(rt_uint32_t to);
  101. void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to);
  102. void rt_hw_console_output(const char *str);
  103. void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry);
  104. void rt_hw_show_memory(rt_uint32_t addr, rt_uint32_t size);
  105. /*
  106. * Exception interfaces
  107. */
  108. void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context));
  109. /*
  110. * delay interfaces
  111. */
  112. void rt_hw_us_delay(rt_uint32_t us);
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif