os_dbg.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /*
  2. ************************************************************************************************************************
  3. * uC/OS-III
  4. * The Real-Time Kernel
  5. *
  6. * (c) Copyright 2009-2011; Micrium, Inc.; Weston, FL
  7. * All rights reserved. Protected by international copyright laws.
  8. *
  9. * DEBUGGER CONSTANTS
  10. *
  11. * File : OS_DBG.C
  12. * By : JJL
  13. * Version : V3.02.00
  14. *
  15. * LICENSING TERMS:
  16. * ---------------
  17. * uC/OS-III is provided in source form for FREE short-term evaluation, for educational use or
  18. * for peaceful research. If you plan or intend to use uC/OS-III in a commercial application/
  19. * product then, you need to contact Micrium to properly license uC/OS-III for its use in your
  20. * application/product. We provide ALL the source code for your convenience and to help you
  21. * experience uC/OS-III. The fact that the source is provided does NOT mean that you can use
  22. * it commercially without paying a licensing fee.
  23. *
  24. * Knowledge of the source code may NOT be used to develop a similar product.
  25. *
  26. * Please help us continue to provide the embedded community with the finest software available.
  27. * Your honesty is greatly appreciated.
  28. *
  29. * You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036.
  30. ************************************************************************************************************************
  31. */
  32. #include <os.h>
  33. #ifdef VSC_INCLUDE_SOURCE_FILE_NAMES
  34. const CPU_CHAR *os_dbg__c = "$Id: $";
  35. #endif
  36. CPU_INT16U const OSDbg_DbgEn = OS_CFG_DBG_EN; /* Debug constants are defined below */
  37. #if OS_CFG_DBG_EN > 0u
  38. /*
  39. ************************************************************************************************************************
  40. * DEBUG DATA
  41. ************************************************************************************************************************
  42. */
  43. CPU_INT08U const OSDbg_ArgChkEn = OS_CFG_ARG_CHK_EN;
  44. CPU_INT08U const OSDbg_AppHooksEn = OS_CFG_APP_HOOKS_EN;
  45. CPU_INT32U const OSDbg_EndiannessTest = 0x12345678LU; /* Variable to test CPU endianness */
  46. CPU_INT08U const OSDbg_CalledFromISRChkEn = OS_CFG_CALLED_FROM_ISR_CHK_EN;
  47. CPU_INT08U const OSDbg_FlagEn = OS_CFG_FLAG_EN;
  48. OS_FLAG_GRP const OSDbg_FlagGrp = { 0u };
  49. #if OS_CFG_FLAG_EN > 0u
  50. CPU_INT08U const OSDbg_FlagDelEn = OS_CFG_FLAG_DEL_EN;
  51. CPU_INT08U const OSDbg_FlagModeClrEn = OS_CFG_FLAG_MODE_CLR_EN;
  52. CPU_INT08U const OSDbg_FlagPendAbortEn = OS_CFG_FLAG_PEND_ABORT_EN;
  53. CPU_INT16U const OSDbg_FlagGrpSize = sizeof(OS_FLAG_GRP); /* Size in Bytes of OS_FLAG_GRP */
  54. CPU_INT16U const OSDbg_FlagWidth = sizeof(OS_FLAGS); /* Width (in bytes) of OS_FLAGS */
  55. #else
  56. CPU_INT08U const OSDbg_FlagDelEn = 0u;
  57. CPU_INT08U const OSDbg_FlagModeClrEn = 0u;
  58. CPU_INT08U const OSDbg_FlagPendAbortEn = 0u;
  59. CPU_INT16U const OSDbg_FlagGrpSize = 0u;
  60. CPU_INT16U const OSDbg_FlagWidth = 0u;
  61. #endif
  62. #if OS_CFG_ISR_POST_DEFERRED_EN > 0u
  63. CPU_INT16U const OSDbg_IntQ = sizeof(OS_INT_Q);
  64. #else
  65. CPU_INT16U const OSDbg_IntQ = 0u;
  66. #endif
  67. CPU_INT08U const OSDbg_ISRPostDeferredEn = OS_CFG_ISR_POST_DEFERRED_EN;
  68. OS_MEM const OSDbg_Mem = { 0u };
  69. CPU_INT08U const OSDbg_MemEn = OS_CFG_MEM_EN;
  70. #if OS_CFG_MEM_EN > 0u
  71. CPU_INT16U const OSDbg_MemSize = sizeof(OS_MEM); /* Mem. Partition header size (bytes) */
  72. #else
  73. CPU_INT16U const OSDbg_MemSize = 0u;
  74. #endif
  75. CPU_INT08U const OSDbg_MsgEn = OS_MSG_EN;
  76. #if (OS_MSG_EN) > 0u
  77. CPU_INT16U const OSDbg_MsgSize = sizeof(OS_MSG); /* OS_MSG size */
  78. CPU_INT16U const OSDbg_MsgPoolSize = sizeof(OS_MSG_POOL);
  79. CPU_INT16U const OSDbg_MsgQSize = sizeof(OS_MSG_Q);
  80. #else
  81. CPU_INT16U const OSDbg_MsgSize = 0u;
  82. CPU_INT16U const OSDbg_MsgPoolSize = 0u;
  83. CPU_INT16U const OSDbg_MsgQSize = 0u;
  84. #endif
  85. OS_MUTEX const OSDbg_Mutex = { 0u };
  86. CPU_INT08U const OSDbg_MutexEn = OS_CFG_MUTEX_EN;
  87. #if OS_CFG_MUTEX_EN > 0u
  88. CPU_INT08U const OSDbg_MutexDelEn = OS_CFG_MUTEX_DEL_EN;
  89. CPU_INT08U const OSDbg_MutexPendAbortEn = OS_CFG_MUTEX_PEND_ABORT_EN;
  90. CPU_INT16U const OSDbg_MutexSize = sizeof(OS_MUTEX); /* Size in bytes of OS_MUTEX */
  91. #else
  92. CPU_INT08U const OSDbg_MutexDelEn = 0u;
  93. CPU_INT08U const OSDbg_MutexPendAbortEn = 0u;
  94. CPU_INT16U const OSDbg_MutexSize = 0u;
  95. #endif
  96. CPU_INT08U const OSDbg_ObjTypeChkEn = OS_CFG_OBJ_TYPE_CHK_EN;
  97. CPU_INT08U const OSDbg_PendMultiEn = OS_CFG_PEND_MULTI_EN;
  98. CPU_INT16U const OSDbg_PendDataSize = sizeof(OS_PEND_DATA);
  99. CPU_INT16U const OSDbg_PendListSize = sizeof(OS_PEND_LIST);
  100. CPU_INT16U const OSDbg_PendObjSize = sizeof(OS_PEND_OBJ);
  101. CPU_INT16U const OSDbg_PrioMax = OS_CFG_PRIO_MAX; /* Maximum number of priorities */
  102. CPU_INT16U const OSDbg_PrioTblSize = sizeof(OSPrioTbl);
  103. CPU_INT16U const OSDbg_PtrSize = sizeof(void *); /* Size in Bytes of a pointer */
  104. OS_Q const OSDbg_Q = { 0u };
  105. CPU_INT08U const OSDbg_QEn = OS_CFG_Q_EN;
  106. #if OS_CFG_Q_EN > 0u
  107. CPU_INT08U const OSDbg_QDelEn = OS_CFG_Q_DEL_EN;
  108. CPU_INT08U const OSDbg_QFlushEn = OS_CFG_Q_FLUSH_EN;
  109. CPU_INT08U const OSDbg_QPendAbortEn = OS_CFG_Q_PEND_ABORT_EN;
  110. CPU_INT16U const OSDbg_QSize = sizeof(OS_Q); /* Size in bytes of OS_Q structure */
  111. #else
  112. CPU_INT08U const OSDbg_QDelEn = 0u;
  113. CPU_INT08U const OSDbg_QFlushEn = 0u;
  114. CPU_INT08U const OSDbg_QPendAbortEn = 0u;
  115. CPU_INT16U const OSDbg_QSize = 0u;
  116. #endif
  117. CPU_INT08U const OSDbg_SchedRoundRobinEn = OS_CFG_SCHED_ROUND_ROBIN_EN;
  118. OS_SEM const OSDbg_Sem = { 0u };
  119. CPU_INT08U const OSDbg_SemEn = OS_CFG_SEM_EN;
  120. #if OS_CFG_SEM_EN > 0u
  121. CPU_INT08U const OSDbg_SemDelEn = OS_CFG_SEM_DEL_EN;
  122. CPU_INT08U const OSDbg_SemPendAbortEn = OS_CFG_SEM_PEND_ABORT_EN;
  123. CPU_INT08U const OSDbg_SemSetEn = OS_CFG_SEM_SET_EN;
  124. CPU_INT16U const OSDbg_SemSize = sizeof(OS_SEM); /* Size in bytes of OS_SEM */
  125. #else
  126. CPU_INT08U const OSDbg_SemDelEn = 0u;
  127. CPU_INT08U const OSDbg_SemPendAbortEn = 0u;
  128. CPU_INT08U const OSDbg_SemSetEn = 0u;
  129. CPU_INT16U const OSDbg_SemSize = 0u;
  130. #endif
  131. CPU_INT16U const OSDbg_RdyList = sizeof(OS_RDY_LIST);
  132. CPU_INT32U const OSDbg_RdyListSize = sizeof(OSRdyList); /* Number of bytes in the ready table */
  133. CPU_INT08U const OSDbg_StkWidth = sizeof(CPU_STK);
  134. CPU_INT08U const OSDbg_StatTaskEn = OS_CFG_STAT_TASK_EN;
  135. CPU_INT08U const OSDbg_StatTaskStkChkEn = OS_CFG_STAT_TASK_STK_CHK_EN;
  136. CPU_INT08U const OSDbg_TaskChangePrioEn = OS_CFG_TASK_CHANGE_PRIO_EN;
  137. CPU_INT08U const OSDbg_TaskDelEn = OS_CFG_TASK_DEL_EN;
  138. CPU_INT08U const OSDbg_TaskQEn = OS_CFG_TASK_Q_EN;
  139. CPU_INT08U const OSDbg_TaskQPendAbortEn = OS_CFG_TASK_Q_PEND_ABORT_EN;
  140. CPU_INT08U const OSDbg_TaskProfileEn = OS_CFG_TASK_PROFILE_EN;
  141. CPU_INT16U const OSDbg_TaskRegTblSize = OS_CFG_TASK_REG_TBL_SIZE;
  142. CPU_INT08U const OSDbg_TaskSemPendAbortEn = OS_CFG_TASK_SEM_PEND_ABORT_EN;
  143. CPU_INT08U const OSDbg_TaskSuspendEn = OS_CFG_TASK_SUSPEND_EN;
  144. CPU_INT16U const OSDbg_TCBSize = sizeof(OS_TCB); /* Size in Bytes of OS_TCB */
  145. CPU_INT16U const OSDbg_TickSpokeSize = sizeof(OS_TICK_SPOKE);
  146. CPU_INT08U const OSDbg_TimeDlyHMSMEn = OS_CFG_TIME_DLY_HMSM_EN;
  147. CPU_INT08U const OSDbg_TimeDlyResumeEn = OS_CFG_TIME_DLY_RESUME_EN;
  148. OS_TMR const OSDbg_Tmr = { 0u };
  149. CPU_INT08U const OSDbg_TmrEn = OS_CFG_TMR_EN;
  150. #if OS_CFG_TMR_EN > 0u
  151. CPU_INT08U const OSDbg_TmrDelEn = OS_CFG_TMR_DEL_EN;
  152. CPU_INT16U const OSDbg_TmrSize = sizeof(OS_TMR);
  153. CPU_INT16U const OSDbg_TmrSpokeSize = sizeof(OS_TMR_SPOKE);
  154. #else
  155. CPU_INT08U const OSDbg_TmrDelEn = 0u;
  156. CPU_INT16U const OSDbg_TmrSize = 0u;
  157. CPU_INT16U const OSDbg_TmrSpokeSize = 0u;
  158. #endif
  159. CPU_INT16U const OSDbg_VersionNbr = OS_VERSION;
  160. /*$PAGE*/
  161. /*
  162. ************************************************************************************************************************
  163. * DEBUG DATA
  164. * TOTAL DATA SPACE (i.e. RAM) USED BY uC/OS-III
  165. ************************************************************************************************************************
  166. */
  167. CPU_INT32U const OSDbg_DataSize = sizeof(OSIntNestingCtr)
  168. #if OS_CFG_APP_HOOKS_EN > 0u
  169. + sizeof(OS_AppTaskCreateHookPtr)
  170. + sizeof(OS_AppTaskDelHookPtr)
  171. + sizeof(OS_AppTaskReturnHookPtr)
  172. + sizeof(OS_AppIdleTaskHookPtr)
  173. + sizeof(OS_AppStatTaskHookPtr)
  174. + sizeof(OS_AppTaskSwHookPtr)
  175. + sizeof(OS_AppTimeTickHookPtr)
  176. #endif
  177. + sizeof(OSIdleTaskCtr)
  178. + sizeof(OSIdleTaskTCB)
  179. #if OS_CFG_ISR_POST_DEFERRED_EN > 0u
  180. + sizeof(OSIntQInPtr)
  181. + sizeof(OSIntQOutPtr)
  182. + sizeof(OSIntQNbrEntries)
  183. + sizeof(OSIntQMaxNbrEntries)
  184. + sizeof(OSIntQOvfCtr)
  185. + sizeof(OSIntQTaskTCB)
  186. #endif
  187. + sizeof(OSRunning)
  188. #ifdef OS_SAFETY_CRITICAL_IEC61508
  189. + sizeof(OSSafetyCriticalStartFlag);
  190. #endif
  191. #if OS_CFG_FLAG_EN > 0u
  192. + sizeof(OSFlagQty)
  193. #endif
  194. #if OS_CFG_MEM_EN > 0u
  195. + sizeof(OSMemQty)
  196. #endif
  197. + sizeof(OSMsgPool)
  198. #if OS_CFG_MUTEX_EN > 0u
  199. + sizeof(OSMutexQty)
  200. #endif
  201. + sizeof(OSPrioCur)
  202. + sizeof(OSPrioHighRdy)
  203. + sizeof(OSPrioTbl)
  204. #if OS_CFG_Q_EN > 0u
  205. + sizeof(OSQQty)
  206. #endif
  207. + sizeof(OSRdyList)
  208. + sizeof(OSSchedLockNestingCtr)
  209. #if OS_CFG_SCHED_LOCK_TIME_MEAS_EN > 0u
  210. + sizeof(OSSchedLockTimeBegin)
  211. + sizeof(OSSchedLockTimeMax)
  212. + sizeof(OSSchedLockTimeMaxCur)
  213. #endif
  214. #if OS_CFG_SCHED_ROUND_ROBIN_EN
  215. + sizeof(OSSchedRoundRobinDfltTimeQuanta)
  216. + sizeof(OSSchedRoundRobinEn)
  217. #endif
  218. #if OS_CFG_SEM_EN > 0u
  219. + sizeof(OSSemQty)
  220. #endif
  221. + sizeof(OSTaskCtxSwCtr)
  222. + sizeof(OSTaskQty)
  223. #if OS_CFG_STAT_TASK_EN > 0u
  224. + sizeof(OSStatTaskCtr)
  225. + sizeof(OSStatTaskCtrMax)
  226. + sizeof(OSStatTaskCtrRun)
  227. + sizeof(OSStatTaskRdy)
  228. + sizeof(OSStatTaskTCB)
  229. + sizeof(OSStatTaskCPUUsage)
  230. #endif
  231. + sizeof(OSTickCtr)
  232. + sizeof(OSTickTaskTCB)
  233. #if OS_CFG_TMR_EN > 0u
  234. + sizeof(OSTmrTaskTCB)
  235. + sizeof(OSTmrTickCtr)
  236. + sizeof(OSTmrQty)
  237. + sizeof(OSTmrUpdateCnt)
  238. + sizeof(OSTmrUpdateCtr)
  239. #endif
  240. + sizeof(OSTCBCurPtr)
  241. + sizeof(OSTCBHighRdyPtr);
  242. /*$PAGE*/
  243. /*
  244. ************************************************************************************************************************
  245. * OS DEBUG INITIALIZATION
  246. *
  247. * Description: This function is used to make sure that debug variables that are unused in the application are not
  248. * optimized away. This function might not be necessary for all compilers. In this case, you should simply
  249. * DELETE the code in this function while still leaving the declaration of the function itself.
  250. *
  251. * Arguments : none
  252. *
  253. * Returns : none
  254. *
  255. * Note(s) : (1) This code doesn't do anything, it simply prevents the compiler from optimizing out the 'const'
  256. * variables which are declared in this file.
  257. * (2) You may decide to 'compile out' the code (by using #if 0/#endif) INSIDE the function if your compiler
  258. * DOES NOT optimize out the 'const' variables above.
  259. ************************************************************************************************************************
  260. */
  261. void OS_Dbg_Init (void)
  262. {
  263. void const *p_temp;
  264. p_temp = (void const *)&OSDbg_DbgEn;
  265. p_temp = (void const *)&OSDbg_DataSize;
  266. p_temp = (void const *)&OSDbg_ArgChkEn;
  267. p_temp = (void const *)&OSDbg_AppHooksEn;
  268. p_temp = (void const *)&OSDbg_EndiannessTest;
  269. p_temp = (void const *)&OSDbg_CalledFromISRChkEn;
  270. p_temp = (void const *)&OSDbg_FlagGrp;
  271. p_temp = (void const *)&OSDbg_FlagEn;
  272. #if OS_CFG_FLAG_EN > 0u
  273. p_temp = (void const *)&OSDbg_FlagDelEn;
  274. p_temp = (void const *)&OSDbg_FlagModeClrEn;
  275. p_temp = (void const *)&OSDbg_FlagPendAbortEn;
  276. p_temp = (void const *)&OSDbg_FlagGrpSize;
  277. p_temp = (void const *)&OSDbg_FlagWidth;
  278. #endif
  279. #if OS_CFG_ISR_POST_DEFERRED_EN > 0u
  280. p_temp = (void const *)&OSDbg_IntQ;
  281. #endif
  282. p_temp = (void const *)&OSDbg_ISRPostDeferredEn;
  283. p_temp = (void const *)&OSDbg_Mem;
  284. p_temp = (void const *)&OSDbg_MemEn;
  285. #if OS_CFG_MEM_EN > 0u
  286. p_temp = (void const *)&OSDbg_MemSize;
  287. #endif
  288. p_temp = (void const *)&OSDbg_MsgEn;
  289. #if (OS_MSG_EN) > 0u
  290. p_temp = (void const *)&OSDbg_MsgSize;
  291. p_temp = (void const *)&OSDbg_MsgPoolSize;
  292. p_temp = (void const *)&OSDbg_MsgQSize;
  293. #endif
  294. p_temp = (void const *)&OSDbg_Mutex;
  295. p_temp = (void const *)&OSDbg_MutexEn;
  296. #if (OS_CFG_MUTEX_EN) > 0u
  297. p_temp = (void const *)&OSDbg_MutexDelEn;
  298. p_temp = (void const *)&OSDbg_MutexPendAbortEn;
  299. p_temp = (void const *)&OSDbg_MutexSize;
  300. #endif
  301. p_temp = (void const *)&OSDbg_ObjTypeChkEn;
  302. p_temp = (void const *)&OSDbg_PendMultiEn;
  303. p_temp = (void const *)&OSDbg_PendDataSize;
  304. p_temp = (void const *)&OSDbg_PendListSize;
  305. p_temp = (void const *)&OSDbg_PendObjSize;
  306. p_temp = (void const *)&OSDbg_PrioMax;
  307. p_temp = (void const *)&OSDbg_PrioTblSize;
  308. p_temp = (void const *)&OSDbg_PtrSize;
  309. p_temp = (void const *)&OSDbg_Q;
  310. p_temp = (void const *)&OSDbg_QEn;
  311. #if (OS_CFG_Q_EN) > 0u
  312. p_temp = (void const *)&OSDbg_QDelEn;
  313. p_temp = (void const *)&OSDbg_QFlushEn;
  314. p_temp = (void const *)&OSDbg_QPendAbortEn;
  315. p_temp = (void const *)&OSDbg_QSize;
  316. #endif
  317. p_temp = (void const *)&OSDbg_SchedRoundRobinEn;
  318. p_temp = (void const *)&OSDbg_Sem;
  319. p_temp = (void const *)&OSDbg_SemEn;
  320. #if (OS_CFG_SEM_EN) > 0u
  321. p_temp = (void const *)&OSDbg_SemDelEn;
  322. p_temp = (void const *)&OSDbg_SemPendAbortEn;
  323. p_temp = (void const *)&OSDbg_SemSetEn;
  324. p_temp = (void const *)&OSDbg_SemSize;
  325. #endif
  326. p_temp = (void const *)&OSDbg_RdyList;
  327. p_temp = (void const *)&OSDbg_RdyListSize;
  328. p_temp = (void const *)&OSDbg_StkWidth;
  329. p_temp = (void const *)&OSDbg_StatTaskEn;
  330. p_temp = (void const *)&OSDbg_StatTaskStkChkEn;
  331. p_temp = (void const *)&OSDbg_TaskChangePrioEn;
  332. p_temp = (void const *)&OSDbg_TaskDelEn;
  333. p_temp = (void const *)&OSDbg_TaskQEn;
  334. p_temp = (void const *)&OSDbg_TaskQPendAbortEn;
  335. p_temp = (void const *)&OSDbg_TaskProfileEn;
  336. p_temp = (void const *)&OSDbg_TaskRegTblSize;
  337. p_temp = (void const *)&OSDbg_TaskSemPendAbortEn;
  338. p_temp = (void const *)&OSDbg_TaskSuspendEn;
  339. p_temp = (void const *)&OSDbg_TCBSize;
  340. p_temp = (void const *)&OSDbg_TickSpokeSize;
  341. p_temp = (void const *)&OSDbg_TimeDlyHMSMEn;
  342. p_temp = (void const *)&OSDbg_TimeDlyResumeEn;
  343. p_temp = (void const *)&OSDbg_Tmr;
  344. p_temp = (void const *)&OSDbg_TmrEn;
  345. #if (OS_CFG_TMR_EN) > 0u
  346. p_temp = (void const *)&OSDbg_TmrDelEn;
  347. p_temp = (void const *)&OSDbg_TmrSize;
  348. p_temp = (void const *)&OSDbg_TmrSpokeSize;
  349. #endif
  350. p_temp = (void const *)&OSDbg_VersionNbr;
  351. p_temp = p_temp; /* Prevent compiler warning for not using 'p_temp' */
  352. }
  353. #endif