os_cpu.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. *********************************************************************************************************
  3. * uC/OS-II
  4. * The Real-Time Kernel
  5. *
  6. *
  7. * (c) Copyright 2006, Micrium, Weston, FL
  8. * All Rights Reserved
  9. *
  10. * ARM Cortex-M3 Port
  11. *
  12. * File : OS_CPU.H
  13. * Version : V2.89
  14. * By : Jean J. Labrosse
  15. * Brian Nagel
  16. *
  17. * For : ARMv7M Cortex-M3
  18. * Mode : Thumb2
  19. * Toolchain : RealView Development Suite
  20. * RealView Microcontroller Development Kit (MDK)
  21. * ARM Developer Suite (ADS)
  22. * Keil uVision
  23. *********************************************************************************************************
  24. */
  25. #ifndef OS_CPU_H
  26. #define OS_CPU_H
  27. #ifdef OS_CPU_GLOBALS
  28. #define OS_CPU_EXT
  29. #else
  30. #define OS_CPU_EXT extern
  31. #endif
  32. #ifndef OS_CPU_EXCEPT_STK_SIZE
  33. #define OS_CPU_EXCEPT_STK_SIZE 128u /* Default exception stack size is 128 OS_STK entries */
  34. #endif
  35. /*
  36. *********************************************************************************************************
  37. * DATA TYPES
  38. * (Compiler Specific)
  39. *********************************************************************************************************
  40. */
  41. typedef unsigned char BOOLEAN;
  42. typedef unsigned char INT8U; /* Unsigned 8 bit quantity */
  43. typedef signed char INT8S; /* Signed 8 bit quantity */
  44. typedef unsigned short INT16U; /* Unsigned 16 bit quantity */
  45. typedef signed short INT16S; /* Signed 16 bit quantity */
  46. typedef unsigned int INT32U; /* Unsigned 32 bit quantity */
  47. typedef signed int INT32S; /* Signed 32 bit quantity */
  48. typedef float FP32; /* Single precision floating point */
  49. typedef double FP64; /* Double precision floating point */
  50. typedef unsigned int OS_STK; /* Each stack entry is 32-bit wide */
  51. typedef unsigned int OS_CPU_SR; /* Define size of CPU status register (PSR = 32 bits) */
  52. /*
  53. *********************************************************************************************************
  54. * Cortex-M3
  55. * Critical Section Management
  56. *
  57. * Method #1: Disable/Enable interrupts using simple instructions. After critical section, interrupts
  58. * will be enabled even if they were disabled before entering the critical section.
  59. * NOT IMPLEMENTED
  60. *
  61. * Method #2: Disable/Enable interrupts by preserving the state of interrupts. In other words, if
  62. * interrupts were disabled before entering the critical section, they will be disabled when
  63. * leaving the critical section.
  64. * NOT IMPLEMENTED
  65. *
  66. * Method #3: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you
  67. * would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
  68. * disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to
  69. * disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr'
  70. * into the CPU's status register.
  71. *********************************************************************************************************
  72. */
  73. #define OS_CRITICAL_METHOD 3u
  74. #if OS_CRITICAL_METHOD == 3u
  75. #define OS_ENTER_CRITICAL() {cpu_sr = OS_CPU_SR_Save();}
  76. #define OS_EXIT_CRITICAL() {OS_CPU_SR_Restore(cpu_sr);}
  77. #endif
  78. /*
  79. *********************************************************************************************************
  80. * Cortex-M3 Miscellaneous
  81. *********************************************************************************************************
  82. */
  83. #define OS_STK_GROWTH 1u /* Stack grows from HIGH to LOW memory on ARM */
  84. #define OS_TASK_SW() OSCtxSw()
  85. /*
  86. *********************************************************************************************************
  87. * GLOBAL VARIABLES
  88. *********************************************************************************************************
  89. */
  90. OS_CPU_EXT OS_STK OS_CPU_ExceptStk[OS_CPU_EXCEPT_STK_SIZE];
  91. OS_CPU_EXT OS_STK *OS_CPU_ExceptStkBase;
  92. /*
  93. *********************************************************************************************************
  94. * PROTOTYPES
  95. *********************************************************************************************************
  96. */
  97. #if OS_CRITICAL_METHOD == 3u /* See OS_CPU_A.ASM */
  98. OS_CPU_SR OS_CPU_SR_Save(void);
  99. void OS_CPU_SR_Restore(OS_CPU_SR cpu_sr);
  100. #endif
  101. void OSCtxSw(void);
  102. void OSIntCtxSw(void);
  103. void OSStartHighRdy(void);
  104. void OS_CPU_PendSVHandler(void);
  105. /* See OS_CPU_C.C */
  106. void OS_CPU_SysTickHandler(void);
  107. void OS_CPU_SysTickInit(INT32U cnts);
  108. #endif