rthw.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. /*
  47. * CPU interfaces
  48. */
  49. void rt_hw_cpu_icache_enable(void);
  50. void rt_hw_cpu_icache_disable(void);
  51. rt_base_t rt_hw_cpu_icache_status(void);
  52. void rt_hw_cpu_dcache_enable(void);
  53. void rt_hw_cpu_dcache_disable(void);
  54. rt_base_t rt_hw_cpu_dcache_status(void);
  55. void rt_hw_cpu_reset(void);
  56. void rt_hw_cpu_shutdown(void);
  57. rt_uint8_t *rt_hw_stack_init(void *entry,
  58. void *parameter,
  59. rt_uint8_t *stack_addr,
  60. void *exit);
  61. /*
  62. * Interrupt handler definition
  63. */
  64. typedef void (*rt_isr_handler_t)(int vector, void *param);
  65. struct rt_irq_desc
  66. {
  67. rt_isr_handler_t handler;
  68. void *param;
  69. #ifdef RT_USING_INTERRUPT_INFO
  70. char name[RT_NAME_MAX];
  71. rt_uint32_t counter;
  72. #endif
  73. };
  74. /*
  75. * Interrupt interfaces
  76. */
  77. void rt_hw_interrupt_init(void);
  78. void rt_hw_interrupt_mask(int vector);
  79. void rt_hw_interrupt_umask(int vector);
  80. rt_isr_handler_t rt_hw_interrupt_install(int vector,
  81. rt_isr_handler_t handler,
  82. void *param,
  83. char *name);
  84. rt_base_t rt_hw_interrupt_disable(void);
  85. void rt_hw_interrupt_enable(rt_base_t level);
  86. /*
  87. * Context interfaces
  88. */
  89. void rt_hw_context_switch(rt_uint32_t from, rt_uint32_t to);
  90. void rt_hw_context_switch_to(rt_uint32_t to);
  91. void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to);
  92. void rt_hw_console_output(const char *str);
  93. void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry);
  94. void rt_hw_show_memory(rt_uint32_t addr, rt_uint32_t size);
  95. /*
  96. * Exception interfaces
  97. */
  98. void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context));
  99. /*
  100. * delay interfaces
  101. */
  102. void rt_hw_us_delay(rt_uint32_t us);
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif