9 #include "RtosTask.hpp"
10 #include "RtosList.hpp"
11 #include "RtosPortable.hpp"
12 #include "RtosHeap.hpp"
27 #if RTOS_CFG_TRACE_BUFFER_SIZE
28 Rtos::TRACE_BUFFER Rtos::sTraceBuffer;
36 sTick = 0xFFFFFFFF - 1234;
41 #if RTOS_CFG_TRACE_BUFFER_SIZE
44 RtosPortable::start();
56 RtosPortable::enterCriticalSection();
60 RtosPortable::yield();
61 RtosPortable::exitCriticalSection();
69 RtosPortable::enterCriticalSection();
71 TICK ticksToSleep = 1;
73 ticksToSleep = tick -
sTick;
78 RtosPortable::yield();
79 RtosPortable::exitCriticalSection();
88 if ((
sTick == tick)) {
104 RtosPortable::enterCriticalSection();
107 RtosPortable::exitCriticalSection();
115 RtosPortable::enterCriticalSection();
116 if (task->mIterableCore.mListOwner) {
117 task->mIterableCore.mListOwner->
remove(task->mIterableCore);
119 if (task->mIterableSyncObj.mListOwner) {
120 task->mIterableSyncObj.mListOwner->
remove(task->mIterableCore);
127 RtosPortable::yield();
128 RtosPortable::exitCriticalSection();
137 RTOS_ASSERT(!RtosPortable::isStackOverflow(task->mStack, task->mStackSize));
139 task->mIsTimeout =
false;
143 iterable->mListOwner->
remove(*iterable);
149 iterable->mSortValue =
sTick + tick;
159 iterable->mListOwner->
remove(*iterable);
173 RtosTask* task = iterable->mTaskOwner;
175 if (task->mIterableSyncObj.mListOwner) {
176 task->mIsTimeout =
true;
177 task->mIterableSyncObj.mListOwner->
remove(task->mIterableSyncObj);
201 #if RTOS_CFG_TRACE_BUFFER_SIZE
205 for (
int i = RTOS_CFG_MAX_PRIORITIES - 1; i >= 0; i--) {
214 #if RTOS_CFG_TRACE_BUFFER_SIZE
216 if (sTraceBuffer.count < RTOS_CFG_TRACE_BUFFER_SIZE) {
217 sTraceBuffer.buffer[sTraceBuffer.indexIn].cycles = RtosPortable::getCyclesCounter();
218 sTraceBuffer.buffer[sTraceBuffer.indexIn].task =
sCurrentTask;
219 sTraceBuffer.indexIn++;
220 if (sTraceBuffer.indexIn >= RTOS_CFG_TRACE_BUFFER_SIZE) {
221 sTraceBuffer.indexIn = 0;
223 sTraceBuffer.count++;
226 sTraceBuffer.overloadError =
true;
240 #if RTOS_CFG_USE_LOW_POWER_IN_IDLE
241 RTOS_LOW_POWER_MODE();
250 #if RTOS_CFG_TRACE_BUFFER_SIZE
251 int Rtos::getTraceBuffer(TRACE_TAG** p) {
252 if (sTraceBuffer.overloadError) {
255 int count = sTraceBuffer.count;
259 *p = &sTraceBuffer.buffer[sTraceBuffer.indexOut];
260 if (sTraceBuffer.indexOut + count > RTOS_CFG_TRACE_BUFFER_SIZE) {
261 count = RTOS_CFG_TRACE_BUFFER_SIZE - sTraceBuffer.indexOut;
262 sTraceBuffer.indexOut = 0;
265 sTraceBuffer.indexOut += count;
270 void Rtos::releaseBuffer(
int count) {
271 RtosPortable::enterCriticalSection();
272 sTraceBuffer.count -= count;
273 RtosPortable::exitCriticalSection();
276 void Rtos::clearTraceBuffer() {
277 RtosPortable::enterCriticalSection();
278 memset(&sTraceBuffer, 0,
sizeof(sTraceBuffer));
279 RtosPortable::exitCriticalSection();