os_cpu.h
上传用户:yyyd609
上传日期:2022-07-18
资源大小:183k
文件大小:6k
源码类别:

微处理器开发

开发平台:

C/C++

  1. /*
  2. *********************************************************************************************************
  3. *                                               uC/OS-II
  4. *                                         The Real-Time Kernel
  5. *
  6. *
  7. *                             (c) Copyright 1992-2004, Micrium, Weston, FL
  8. *                                          All Rights Reserved
  9. *
  10. *                                           Generic ARM Port
  11. *
  12. * File      : OS_CPU.H
  13. * Version   : V1.60
  14. * By        : Jean J. Labrosse
  15. *
  16. * For       : ARM7 or ARM9
  17. * Mode      : ARM or Thumb
  18. * Toolchain : ARM Developer Suite Version 1.2 and higher
  19. *********************************************************************************************************
  20. */
  21. #ifndef  OS_CPU_H
  22. #define  OS_CPU_H
  23. #ifdef   OS_CPU_GLOBALS
  24. #define  OS_CPU_EXT
  25. #else
  26. #define  OS_CPU_EXT  extern
  27. #endif
  28. /*
  29. *********************************************************************************************************
  30. *                                   INTERRUPT DISABLE TIME MEASUREMENT
  31. *********************************************************************************************************
  32. */
  33. #define  OS_CPU_INT_DIS_MEAS_EN    0
  34. /*
  35. *********************************************************************************************************
  36. *                                              DATA TYPES
  37. *                                         (Compiler Specific)
  38. *********************************************************************************************************
  39. */
  40. typedef unsigned char  BOOLEAN;
  41. typedef unsigned char  INT8U;                    /* Unsigned  8 bit quantity                           */
  42. typedef signed   char  INT8S;                    /* Signed    8 bit quantity                           */
  43. typedef unsigned short INT16U;                   /* Unsigned 16 bit quantity                           */
  44. typedef signed   short INT16S;                   /* Signed   16 bit quantity                           */
  45. typedef unsigned long  INT32U;                   /* Unsigned 32 bit quantity                           */
  46. typedef signed   long  INT32S;                   /* Signed   32 bit quantity                           */
  47. typedef float          FP32;                     /* Single precision floating point                    */
  48. typedef double         FP64;                     /* Double precision floating point                    */
  49. typedef unsigned int   OS_STK;                   /* Each stack entry is 32-bit wide                    */
  50. typedef unsigned int   OS_CPU_SR;                /* Define size of CPU status register (PSR = 32 bits) */
  51. /*
  52. *********************************************************************************************************
  53. *                                                ARM
  54. *
  55. * Method #1:  Disable/Enable interrupts using simple instructions.  After critical section, interrupts
  56. *             will be enabled even if they were disabled before entering the critical section.
  57. *             NOT IMPLEMENTED
  58. *
  59. * Method #2:  Disable/Enable interrupts by preserving the state of interrupts.  In other words, if
  60. *             interrupts were disabled before entering the critical section, they will be disabled when
  61. *             leaving the critical section.
  62. *             NOT IMPLEMENTED
  63. *
  64. * Method #3:  Disable/Enable interrupts by preserving the state of interrupts.  Generally speaking you
  65. *             would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then
  66. *             disable interrupts.  'cpu_sr' is allocated in all of uC/OS-II's functions that need to
  67. *             disable interrupts.  You would restore the interrupt disable state by copying back 'cpu_sr'
  68. *             into the CPU's status register.
  69. *********************************************************************************************************
  70. */
  71. #define  OS_CRITICAL_METHOD    3
  72. #if      OS_CRITICAL_METHOD == 3
  73. #if      OS_CPU_INT_DIS_MEAS_EN > 0
  74. #define  OS_ENTER_CRITICAL()  {cpu_sr = OS_CPU_SR_Save();  
  75.                                OS_CPU_IntDisMeasStart();}
  76. #define  OS_EXIT_CRITICAL()   {OS_CPU_IntDisMeasStop();   
  77.                                OS_CPU_SR_Restore(cpu_sr);}
  78. #else
  79. #define  OS_ENTER_CRITICAL()  {cpu_sr = OS_CPU_SR_Save();}
  80. #define  OS_EXIT_CRITICAL()   {OS_CPU_SR_Restore(cpu_sr);}
  81. #endif
  82. #endif
  83. /*
  84. *********************************************************************************************************
  85. *                                         ARM Miscellaneous
  86. *********************************************************************************************************
  87. */
  88. #define  OS_STK_GROWTH        1                   /* Stack grows from HIGH to LOW memory on ARM        */
  89. #define  OS_TASK_SW()         OSCtxSw()
  90. /*
  91. *********************************************************************************************************
  92. *                                            GLOBAL VARIABLES
  93. *********************************************************************************************************
  94. */
  95.                                                   /* Variables used to measure interrupt disable time  */
  96. #if OS_CPU_INT_DIS_MEAS_EN > 0
  97. OS_CPU_EXT  INT16U  OS_CPU_IntDisMeasNestingCtr;
  98. OS_CPU_EXT  INT16U  OS_CPU_IntDisMeasCntsEnter;
  99. OS_CPU_EXT  INT16U  OS_CPU_IntDisMeasCntsExit;
  100. OS_CPU_EXT  INT16U  OS_CPU_IntDisMeasCntsMax;
  101. OS_CPU_EXT  INT16U  OS_CPU_IntDisMeasCntsDelta;
  102. OS_CPU_EXT  INT16U  OS_CPU_IntDisMeasCntsOvrhd;
  103. #endif
  104. /*
  105. *********************************************************************************************************
  106. *                                              PROTOTYPES
  107. *********************************************************************************************************
  108. */
  109. #if OS_CRITICAL_METHOD == 3
  110.        OS_CPU_SR  OS_CPU_SR_Save(void);           /* See OS_CPU_A.S                                    */
  111.        void       OS_CPU_SR_Restore(OS_CPU_SR cpu_sr);
  112. #endif
  113.        void       OSTimeTickISR(void);
  114.        void       OSCtxSw(void);
  115.        void       OSIntCtxSw(void);
  116.        void       OSStartHighRdy(void);
  117.        void       OSTimeTickISRHandler(void);     /* See BSP.C                                         */
  118. #if OS_CPU_INT_DIS_MEAS_EN > 0
  119.        void       OS_CPU_IntDisMeasInit(void);
  120.        void       OS_CPU_IntDisMeasStart(void);
  121.        void       OS_CPU_IntDisMeasStop(void);
  122.        INT16U     OS_CPU_IntDisMeasTmrRd(void);
  123. #endif
  124. #endif