Mark3 Realtime Kernel
mark3c.h
Go to the documentation of this file.
1 /*===========================================================================
2  _____ _____ _____ _____
3  ___| _|__ __|_ |__ __|__ |__ __| __ |__ ______
4 | \ / | || \ || | || |/ / ||___ |
5 | \/ | || \ || \ || \ ||___ |
6 |__/\__/|__|_||__|\__\ __||__|\__\ __||__|\__\ __||______|
7  |_____| |_____| |_____| |_____|
8 
9 --[Mark3 Realtime Platform]--------------------------------------------------
10 
11 Copyright (c) 2012 - 2019 m0slevin, all rights reserved.
12 See license.txt for more information
13 ===========================================================================*/
21 #pragma once
22 
23 #include "mark3cfg.h"
24 #include "fake_types.h"
25 
26 #include <stdint.h>
27 #include <stdbool.h>
28 
29 #if defined(__cplusplus)
30 extern "C" {
31 #endif
32 
33 //---------------------------------------------------------------------------
34 // Define a series of handle types to be used in place of the underlying classes
35 // of Mark3.
36 #if KERNEL_EVENT_FLAGS
37 typedef void* EventFlag_t;
38 #endif // #if KERNEL_EVENT_FLAGS
39 typedef void* Mailbox_t;
40 typedef void* Message_t;
41 typedef void* MessagePool_t;
42 typedef void* MessageQueue_t;
43 typedef void* Mutex_t;
44 typedef void* Notify_t;
45 typedef void* Semaphore_t;
46 typedef void* Thread_t;
47 typedef void* Timer_t;
48 typedef void* ConditionVariable_t;
49 typedef void* ReaderWriterLock_t;
50 typedef void* Coroutine_t;
51 
52 //---------------------------------------------------------------------------
53 // Function pointer types used by Kernel APIs
54 #if KERNEL_THREAD_CREATE_CALLOUT
55 typedef void (*thread_create_callout_t)(Thread_t hThread_);
56 #endif // #if KERNEL_THREAD_CREATE_CALLOUT
57 #if KERNEL_THREAD_EXIT_CALLOUT
58 typedef void (*thread_exit_callout_t)(Thread_t hThread_);
59 #endif // #if KERNEL_THREAD_EXIT_CALLOUT
60 #if KERNEL_CONTEXT_SWITCH_CALLOUT
61 typedef void (*thread_context_callout_t)(Thread_t hThread_);
62 #endif // #if KERNEL_CONTEXT_SWITCH_CALLOUT
63 typedef void (*kernel_debug_print_t)(const char* szString_);
64 typedef void (*coroutine_callback_t)(Coroutine_t caller, void* pvContext);
65 
66 //---------------------------------------------------------------------------
67 // Use the sizes of the structs in fake_types.h to generate opaque object-blobs
68 // that get instantiated as kernel objects (from the C++ code) later.
69 #define THREAD_SIZE (sizeof(Fake_Thread))
70 #define TIMER_SIZE (sizeof(Fake_Timer))
71 #define SEMAPHORE_SIZE (sizeof(Fake_Semaphore))
72 #define MUTEX_SIZE (sizeof(Fake_Mutex))
73 #define MESSAGE_SIZE (sizeof(Fake_Message))
74 #define MESSAGEQUEUE_SIZE (sizeof(Fake_MessageQueue))
75 #define MAILBOX_SIZE (sizeof(Fake_Mailbox))
76 #define NOTIFY_SIZE (sizeof(Fake_Notify))
77 #if KERNEL_EVENT_FLAGS
78 #define EVENTFLAG_SIZE (sizeof(Fake_EventFlag))
79 #endif // #if KERNEL_EVENT_FLAGS
80 #define MESSAGEPOOL_SIZE (sizeof(Fake_MessagePool))
81 #define CONDITIONVARIABLE_SIZE (sizeof(Fake_ConditionVariable))
82 #define READERWRITERLOCK_SIZE (sizeof(Fake_ReaderWriterLock))
83 #define COROUTINE_SIZE (sizeof(Fake_Coroutine))
84 #if KERNEL_EVENT_FLAGS
85 //---------------------------------------------------------------------------
90 typedef enum {
91  EVENT_FLAG_ALL_SET,
92  EVENT_FLAG_ANY_SET,
93  EVENT_FLAG_ALL_CLEAR,
94  EVENT_FlAG_ANY_CLEAR,
95  EVENT_FLAG_PENDING_UNBLOCK
96 } event_flag_operation_t;
97 #endif // #if KERNEL_EVENT_FLAGS
98 
99 //---------------------------------------------------------------------------
103 typedef enum {
110 
111 //---------------------------------------------------------------------------
112 // Macros for declaring opaque buffers of an appropriate size for the given
113 // kernel objects
114 #define TOKEN_1(x, y) x##y
115 #define TOKEN_2(x, y) TOKEN_1(x, y)
116 
117 // Ensure that opaque buffers are sized to the nearest word - which is
118 // a platform-dependent value.
119 #define WORD_ROUND(x) (((x) + (sizeof(K_WORD) - 1)) / sizeof(K_WORD))
120 
121 #define DECLARE_THREAD(name) \
122  K_WORD TOKEN_2(__thread_, name)[WORD_ROUND(THREAD_SIZE)]; \
123  Thread_t name = (Thread_t)TOKEN_2(__thread_, name);
124 
125 #define DECLARE_TIMER(name) \
126  K_WORD TOKEN_2(__timer_, name)[WORD_ROUND(TIMER_SIZE)]; \
127  Timer_t name = (Timer_t)TOKEN_2(__timer_, name);
128 
129 #define DECLARE_SEMAPHORE(name) \
130  K_WORD TOKEN_2(__semaphore_, name)[WORD_ROUND(SEMAPHORE_SIZE)]; \
131  Semaphore_t name = (Semaphore_t)TOKEN_2(__semaphore_, name);
132 
133 #define DECLARE_MUTEX(name) \
134  K_WORD TOKEN_2(__mutex_, name)[WORD_ROUND(MUTEX_SIZE)]; \
135  Mutex_t name = (Mutex_t)TOKEN_2(__mutex_, name);
136 
137 #define DECLARE_MESSAGE(name) \
138  K_WORD TOKEN_2(__message_, name)[WORD_ROUND(MESSAGE_SIZE)]; \
139  Message_t name = (Message_t)TOKEN_2(__message_, name);
140 
141 #define DECLARE_MESSAGEPOOL(name) \
142  K_WORD TOKEN_2(__messagepool_, name)[WORD_ROUND(MESSAGEPOOL_SIZE)]; \
143  MessagePool_t name = (MessagePool_t)TOKEN_2(__messagepool_, name);
144 
145 #define DECLARE_MESSAGEQUEUE(name) \
146  K_WORD TOKEN_2(__messagequeue_, name)[WORD_ROUND(MESSAGEQUEUE_SIZE)]; \
147  MessageQueue_t name = (MessageQueue_t)TOKEN_2(__messagequeue_, name);
148 
149 #define DECLARE_MAILBOX(name) \
150  K_WORD TOKEN_2(__mailbox_, name)[WORD_ROUND(MAILBOX_SIZE)]; \
151  Mailbox_t name = (Mailbox_t)TOKEN_2(__mailbox_, name);
152 
153 #define DECLARE_NOTIFY(name) \
154  K_WORD TOKEN_2(__notify_, name)[WORD_ROUND(NOTIFY_SIZE)]; \
155  Notify_t name = (Notify_t)TOKEN_2(__notify_, name);
156 
157 #if KERNEL_EVENT_FLAGS
158 #define DECLARE_EVENTFLAG(name) \
159  K_WORD TOKEN_2(__eventflag_, name)[WORD_ROUND(EVENTFLAG_SIZE)]; \
160  EventFlag_t name = (EventFlag_t)TOKEN_2(__eventflag_, name);
161 #endif // #if KERNEL_EVENT_FLAGS
162 
163 #define DECLARE_CONDITIONVARIABLE(name) \
164  K_WORD TOKEN_2(__condvar_, name)[WORD_ROUND(EVENTFLAG_SIZE)]; \
165  ConditionVariable_t name = (ConditionVariable_t)TOKEN_2(__condvar_, name);
166 
167 #define DECLARE_READERWRITERLOCK(name) \
168  K_WORD TOKEN_2(__readerwriterlock_, name)[WORD_ROUND(EVENTFLAG_SIZE)]; \
169  ReaderWriterLock_t name = (ReaderWriterLock_t)TOKEN_2(__readerwriterlock_, name);
170 
171 #define DECLARE_COROUTINE(name) \
172  K_WORD TOKEN_2(__coroutine_, name)[WORD_ROUND(COROUTINE_SIZE)]; \
173  Coroutine_t name = (Coroutine_t)TOKEN_2(__coroutine_, name);
174 
175 //---------------------------------------------------------------------------
176 // Allocate-once Memory managment APIs
183 void* Alloc_Memory(size_t eSize_);
184 
189 void Free_Memory(void* pvObject_);
190 
196 Semaphore_t Alloc_Semaphore(void);
197 void Free_Semaphore(Semaphore_t handle);
198 
204 Mutex_t Alloc_Mutex(void);
205 void Free_Mutex(Mutex_t handle);
206 
207 #if KERNEL_EVENT_FLAGS
208 
213 EventFlag_t Alloc_EventFlag(void);
214 void Free_EventFlag(EventFlag_t handle);
215 #endif // #if KERNEL_EVENT_FLAGS
216 
222 Message_t Alloc_Message(void);
223 void Free_Message(Message_t handle);
224 
230 MessageQueue_t Alloc_MessageQueue(void);
231 void Free_MessageQueue(MessageQueue_t handle);
232 
233 MessagePool_t Alloc_MessagePool(void);
234 void Free_MessagePool(MessagePool_t handle);
235 
241 Notify_t Alloc_Notify(void);
242 void Free_Notify(Notify_t handle);
243 
249 Mailbox_t Alloc_Mailbox(void);
250 void Free_Mailbox(Mailbox_t handle);
251 
257 Thread_t Alloc_Thread(void);
258 void Free_Thread(Thread_t handle);
259 
265 Timer_t Alloc_Timer(void);
266 void Free_Timer(Timer_t handle);
267 
268 //---------------------------------------------------------------------------
269 // Kernel APIs
274 void Kernel_Init(void);
279 void Kernel_Start(void);
286 bool Kernel_IsStarted(void);
287 
288 typedef void (*panic_func_t)(uint16_t u16PanicCode_);
294 void Kernel_SetPanic(panic_func_t pfPanic_);
300 bool Kernel_IsPanic(void);
306 void Kernel_Panic(uint16_t u16Cause_);
307 
308 #if KERNEL_THREAD_CREATE_CALLOUT
309 
314 void Kernel_SetThreadCreateCallout(thread_create_callout_t pfCreate_);
315 #endif // #if KERNEL_THREAD_CREATE_CALLOUT
316 
317 #if KERNEL_THREAD_EXIT_CALLOUT
318 
323 void Kernel_SetThreadExitCallout(thread_exit_callout_t pfExit_);
324 #endif // #if KERNEL_THREAD_EXIT_CALLOUT
325 
326 #if KERNEL_CONTEXT_SWITCH_CALLOUT
327 
332 void Kernel_SetThreadContextSwitchCallout(thread_context_callout_t pfContext_);
333 #endif // #if KERNEL_CONTEXT_SWITCH_CALLOUT
334 
335 #if KERNEL_THREAD_CREATE_CALLOUT
336 
341 thread_create_callout_t Kernel_GetThreadCreateCallout(void);
342 #endif // #if KERNEL_THREAD_CREATE_CALLOUT
343 
344 #if KERNEL_THREAD_EXIT_CALLOUT
345 
350 thread_exit_callout_t Kernel_GetThreadExitCallout(void);
351 #endif // #if KERNEL_THREAD_EXIT_CALLOUT
352 
353 #if KERNEL_CONTEXT_SWITCH_CALLOUT
354 
359 thread_context_callout_t Kernel_GetThreadContextSwitchCallout(void);
360 #endif // #if KERNEL_CONTEXT_SWITCH_CALLOUT
361 
362 #if KERNEL_STACK_CHECK
363 
369 void Kernel_SetStackGuardThreshold(uint16_t u16Threshold_);
370 
376 uint16_t Kernel_GetStackGuardThreshold(void);
377 #endif // #if KERNEL_STACK_CHECK
378 
384 uint32_t Kernel_GetTicks(void);
385 
386 //---------------------------------------------------------------------------
387 // Scheduler APIs
393 void Scheduler_Enable(bool bEnable_);
399 bool Scheduler_IsEnabled(void);
405 Thread_t Scheduler_GetCurrentThread(void);
406 
407 typedef void (*thread_entry_func_t)(void* pvArg_);
408 //---------------------------------------------------------------------------
409 // Thread APIs
423 void Thread_Init(Thread_t handle,
424  K_WORD* pwStack_,
425  uint16_t u16StackSize_,
426  PORT_PRIO_TYPE uXPriority_,
427  thread_entry_func_t pfEntryPoint_,
428  void* pvArg_);
434 void Thread_Start(Thread_t handle);
440 void Thread_Stop(Thread_t handle);
441 
442 #if KERNEL_NAMED_THREADS
443 
449 void Thread_SetName(Thread_t handle, const char* szName_);
456 const char* Thread_GetName(Thread_t handle);
457 #endif // #if KERNEL_NAMED_THREADS
458 
465 PORT_PRIO_TYPE Thread_GetPriority(Thread_t handle);
472 PORT_PRIO_TYPE Thread_GetCurPriority(Thread_t handle);
473 
474 #if KERNEL_ROUND_ROBIN
475 
481 void Thread_SetQuantum(Thread_t handle, uint16_t u16Quantum_);
488 uint16_t Thread_GetQuantum(Thread_t handle);
489 #endif // #if KERNEL_ROUND_ROBIN
490 
497 void Thread_SetPriority(Thread_t handle, PORT_PRIO_TYPE uXPriority_);
503 void Thread_Exit(Thread_t handle);
509 void Thread_Sleep(uint32_t u32TimeMs_);
510 
511 #if KERNEL_EXTENDED_CONTEXT
512 
518 void* Thread_GetExtendedContext(Thread_t handle);
519 
526 void Thread_SetExtendedContext(Thread_t handle, void* pvData_);
527 #endif // #if KERNEL_EXTENDED_CONTEXT
528 
533 void Thread_Yield(void);
534 
539 void Thread_CoopYield(void);
540 
547 void Thread_SetID(Thread_t handle, uint8_t u8ID_);
554 uint8_t Thread_GetID(Thread_t handle);
555 
556 #if KERNEL_STACK_CHECK
557 
563 uint16_t Thread_GetStackSlack(Thread_t handle);
564 #endif // #if KERNEL_STACK_CHECK
565 
572 thread_state_t Thread_GetState(Thread_t handle);
573 
574 //---------------------------------------------------------------------------
575 // Timer APIs
576 typedef void (*timer_callback_t)(Thread_t hOwner_, void* pvData_);
582 void Timer_Init(Timer_t handle);
593 void Timer_Start(Timer_t handle, bool bRepeat_, uint32_t u32IntervalMs_, timer_callback_t pfCallback_, void* pvData_);
594 
600 void Timer_Restart(Timer_t handle);
601 
607 void Timer_Stop(Timer_t handle);
608 
609 //---------------------------------------------------------------------------
610 // Semaphore APIs
618 void Semaphore_Init(Semaphore_t handle, uint16_t u16InitVal_, uint16_t u16MaxVal_);
624 void Semaphore_Post(Semaphore_t handle);
630 void Semaphore_Pend(Semaphore_t handle);
638 bool Semaphore_TimedPend(Semaphore_t handle, uint32_t u32WaitTimeMS_);
639 
640 //---------------------------------------------------------------------------
641 // Mutex APIs
647 void Mutex_Init(Mutex_t handle);
653 void Mutex_Claim(Mutex_t handle);
659 void Mutex_Release(Mutex_t handle);
667 bool Mutex_TimedClaim(Mutex_t handle, uint32_t u32WaitTimeMS_);
668 
669 #if KERNEL_EVENT_FLAGS
670 //---------------------------------------------------------------------------
671 // EventFlag APIs
677 void EventFlag_Init(EventFlag_t handle);
686 uint16_t EventFlag_Wait(EventFlag_t handle, uint16_t u16Mask_, event_flag_operation_t eMode_);
696 uint16_t EventFlag_TimedWait(EventFlag_t handle, uint16_t u16Mask_, event_flag_operation_t eMode_, uint32_t u32TimeMS_);
703 void EventFlag_Set(EventFlag_t handle, uint16_t u16Mask_);
710 void EventFlag_Clear(EventFlag_t handle, uint16_t u16Mask_);
717 uint16_t EventFlag_GetMask(EventFlag_t handle);
718 #endif // #if KERNEL_EVENT_FLAGS
719 
720 //---------------------------------------------------------------------------
721 // Notification APIs
727 void Notify_Init(Notify_t handle);
733 void Notify_Signal(Notify_t handle);
740 void Notify_Wait(Notify_t handle, bool* pbFlag_);
749 bool Notify_TimedWait(Notify_t handle, uint32_t u32WaitTimeMS_, bool* pbFlag_);
750 
751 //---------------------------------------------------------------------------
752 // Atomic Functions
760 uint8_t Atomic_Set8(uint8_t* pu8Source_, uint8_t u8Val_);
768 uint16_t Atomic_Set16(uint16_t* pu16Source_, uint16_t u16Val_);
776 uint32_t Atomic_Set32(uint32_t* pu32Source_, uint32_t u32Val_);
784 uint8_t Atomic_Add8(uint8_t* pu8Source_, uint8_t u8Val_);
792 uint16_t Atomic_Add16(uint16_t* pu16Source_, uint16_t u16Val_);
800 uint32_t Atomic_Add32(uint32_t* pu32Source_, uint32_t u32Val_);
808 uint8_t Atomic_Sub8(uint8_t* pu8Source_, uint8_t u8Val_);
816 uint16_t Atomic_Sub16(uint16_t* pu16Source_, uint16_t u16Val_);
824 uint32_t Atomic_Sub32(uint32_t* pu32Source_, uint32_t u32Val_);
833 bool Atomic_TestAndSet(bool* pbLock);
834 
835 //---------------------------------------------------------------------------
836 // Message/Message Queue APIs
842 void Message_Init(Message_t handle);
849 void Message_SetData(Message_t handle, void* pvData_);
856 void* Message_GetData(Message_t handle);
863 void Message_SetCode(Message_t handle, uint16_t u16Code_);
870 uint16_t Message_GetCode(Message_t handle);
876 void MessageQueue_Init(MessageQueue_t handle);
883 Message_t MessageQueue_Receive(MessageQueue_t handle);
894 Message_t MessageQueue_TimedReceive(MessageQueue_t handle, uint32_t u32TimeWaitMS_);
895 
902 void MessageQueue_Send(MessageQueue_t handle, Message_t hMessage_);
903 
909 uint16_t MessageQueue_GetCount(MessageQueue_t handle);
910 
916 void MessagePool_Init(MessagePool_t handle);
917 
924 void MessagePool_Push(MessagePool_t handle, Message_t msg);
925 
932 Message_t MessagePool_Pop(MessagePool_t handle);
933 
934 //---------------------------------------------------------------------------
935 // Mailbox APIs
936 
945 void Mailbox_Init(Mailbox_t handle, void* pvBuffer_, uint16_t u16BufferSize_, uint16_t u16ElementSize_);
946 
954 bool Mailbox_Send(Mailbox_t handle, void* pvData_);
955 
963 bool Mailbox_SendTail(Mailbox_t handle, void* pvData_);
964 
973 bool Mailbox_TimedSend(Mailbox_t handle, void* pvData_, uint32_t u32TimeoutMS_);
974 
983 bool Mailbox_TimedSendTail(Mailbox_t handle, void* pvData_, uint32_t u32TimeoutMS_);
984 
992 void Mailbox_Receive(Mailbox_t handle, void* pvData_);
993 
1001 void Mailbox_ReceiveTail(Mailbox_t handle, void* pvData_);
1002 
1012 bool Mailbox_TimedReceive(Mailbox_t handle, void* pvData_, uint32_t u32TimeoutMS_);
1013 
1023 bool Mailbox_TimedReceiveTail(Mailbox_t handle, void* pvData_, uint32_t u32TimeoutMS_);
1024 
1031 uint16_t Mailbox_GetFreeSlots(Mailbox_t handle);
1032 
1039 bool Mailbox_IsFull(Mailbox_t handle);
1040 
1047 bool Mailbox_IsEmpty(Mailbox_t handle);
1048 
1049 //---------------------------------------------------------------------------
1050 // Condition Variables
1056 void ConditionVariable_Init(ConditionVariable_t handle);
1057 
1064 void ConditionVariable_Wait(ConditionVariable_t handle, Mutex_t hMutex_);
1065 
1071 void ConditionVariable_Signal(ConditionVariable_t handle);
1072 
1078 void ConditionVariable_Broadcast(ConditionVariable_t handle);
1079 
1088 bool ConditionVariable_TimedWait(ConditionVariable_t handle, Mutex_t hMutex_, uint32_t u32WaitTimeMS_);
1089 
1090 //---------------------------------------------------------------------------
1091 // Reader-writer locks
1097 void ReaderWriterLock_Init(ReaderWriterLock_t handle);
1098 
1104 void ReaderWriterLock_AcquireReader(ReaderWriterLock_t handle);
1105 
1111 void ReaderWriterLock_ReleaseReader(ReaderWriterLock_t handle);
1112 
1118 void ReaderWriterLock_AcquireWriter(ReaderWriterLock_t handle);
1119 
1125 void ReaderWriterLock_ReleaseWriter(ReaderWriterLock_t handle);
1126 
1134 bool ReaderWriterLock_TimedAcquireWriter(ReaderWriterLock_t handle, uint32_t u32TimeoutMs_);
1135 
1143 bool ReaderWriterLock_TimedAcquireReader(ReaderWriterLock_t handle, uint32_t u32TimeoutMs_);
1144 
1150 void Kernel_SetDebugPrintFunction(kernel_debug_print_t pfPrintFunction_);
1151 
1157 void Kernel_DebugPrint(const char* szString_);
1158 
1159 #if defined(__cplusplus)
1160 }
1161 #endif
bool ReaderWriterLock_TimedAcquireWriter(ReaderWriterLock_t handle, uint32_t u32TimeoutMs_)
ReaderWriterLock_TimedAcquireWriter.
Definition: mark3c.cpp:936
void * Message_GetData(Message_t handle)
Message_GetData.
Definition: mark3c.cpp:701
void Kernel_Panic(uint16_t u16Cause_)
Kernel_Panic.
Definition: mark3c.cpp:221
void(* thread_entry_func_t)(void *pvArg_)
Definition: mark3c.h:407
MessagePool_t Alloc_MessagePool(void)
Definition: mark3c.cpp:100
void ReaderWriterLock_ReleaseWriter(ReaderWriterLock_t handle)
ReaderWriterLock_ReleaseWriter.
Definition: mark3c.cpp:929
void ReaderWriterLock_AcquireWriter(ReaderWriterLock_t handle)
ReaderWriterLock_AcquireWriter.
Definition: mark3c.cpp:922
#define K_WORD
Size of a data word.
Definition: portcfg.h:62
void Semaphore_Pend(Semaphore_t handle)
Semaphore_Pend.
Definition: mark3c.cpp:503
bool Mailbox_TimedSend(Mailbox_t handle, void *pvData_, uint32_t u32TimeoutMS_)
Mailbox_TimedSend.
Definition: mark3c.cpp:801
void Kernel_SetStackGuardThreshold(uint16_t u16Threshold_)
Definition: mark3c.cpp:275
void Scheduler_Enable(bool bEnable_)
Scheduler_Enable.
Definition: mark3c.cpp:300
void MessagePool_Init(MessagePool_t handle)
MessagePool_Init.
Definition: mark3c.cpp:736
thread_state_t Thread_GetState(Thread_t handle)
Thread_GetState.
Definition: mark3c.cpp:449
void Kernel_Start(void)
Kernel_Start.
Definition: mark3c.cpp:197
Timer_t Alloc_Timer(void)
Alloc_Timer.
Definition: mark3c.cpp:167
void ConditionVariable_Wait(ConditionVariable_t handle, Mutex_t hMutex_)
ConditionVariable_Wait.
Definition: mark3c.cpp:872
Mailbox_t Alloc_Mailbox(void)
Alloc_Mailbox.
Definition: mark3c.cpp:123
!< Thread is blocked on a blocking call
Definition: mark3c.h:107
void * Message_t
Message opaque handle data type.
Definition: mark3c.h:40
void Free_MessageQueue(MessageQueue_t handle)
Definition: mark3c.cpp:94
void Timer_Stop(Timer_t handle)
Timer_Stop.
Definition: mark3c.cpp:473
void Timer_Init(Timer_t handle)
Timer_Init.
Definition: mark3c.cpp:459
void * Mutex_t
Mutex opaque handle data type.
Definition: mark3c.h:43
void Thread_Start(Thread_t handle)
Thread_Start.
Definition: mark3c.cpp:333
void Kernel_SetPanic(panic_func_t pfPanic_)
Kernel_SetPanic.
Definition: mark3c.cpp:209
void Free_MessagePool(MessagePool_t handle)
Definition: mark3c.cpp:106
void * Semaphore_t
Semaphore opaque handle data type.
Definition: mark3c.h:45
EventFlag_t Alloc_EventFlag(void)
Definition: mark3c.cpp:64
void Kernel_SetDebugPrintFunction(kernel_debug_print_t pfPrintFunction_)
Kernel_SetDebugPrintFunction.
Definition: mark3c.cpp:287
void Free_Thread(Thread_t handle)
Definition: mark3c.cpp:161
uint16_t MessageQueue_GetCount(MessageQueue_t handle)
MessageQueue_GetCount.
Definition: mark3c.cpp:771
uint8_t Thread_GetID(Thread_t handle)
Thread_GetID.
Definition: mark3c.cpp:437
void Free_Semaphore(Semaphore_t handle)
Definition: mark3c.cpp:46
uint8_t Atomic_Set8(uint8_t *pu8Source_, uint8_t u8Val_)
Atomic_Set8.
Definition: mark3c.cpp:625
uint32_t Atomic_Sub32(uint32_t *pu32Source_, uint32_t u32Val_)
Atomic_Sub32.
Definition: mark3c.cpp:673
#define PORT_PRIO_TYPE
Type used for bitmap in the PriorityMap class.
Definition: portcfg.h:73
void ReaderWriterLock_AcquireReader(ReaderWriterLock_t handle)
ReaderWriterLock_AcquireReader.
Definition: mark3c.cpp:908
uint16_t Kernel_GetStackGuardThreshold(void)
Definition: mark3c.cpp:281
void Thread_Stop(Thread_t handle)
Thread_Stop.
Definition: mark3c.cpp:340
void Message_SetData(Message_t handle, void *pvData_)
Message_SetData.
Definition: mark3c.cpp:694
void Mutex_Release(Mutex_t handle)
Mutex_Release.
Definition: mark3c.cpp:533
void * Mailbox_t
Mailbox opaque handle data type.
Definition: mark3c.h:39
Thread_t Scheduler_GetCurrentThread(void)
Scheduler_GetCurrentThread.
Definition: mark3c.cpp:312
Message_t MessagePool_Pop(MessagePool_t handle)
MessagePool_Pop.
Definition: mark3c.cpp:750
uint16_t Thread_GetStackSlack(Thread_t handle)
Definition: mark3c.cpp:443
Semaphore_t Alloc_Semaphore(void)
Alloc_Semaphore.
Definition: mark3c.cpp:40
void Free_Timer(Timer_t handle)
Definition: mark3c.cpp:172
Mutex_t Alloc_Mutex(void)
Alloc_Mutex.
Definition: mark3c.cpp:52
void Free_Notify(Notify_t handle)
Definition: mark3c.cpp:118
void * Notify_t
Notification object opaque handle data type.
Definition: mark3c.h:44
void ConditionVariable_Signal(ConditionVariable_t handle)
ConditionVariable_Signal.
Definition: mark3c.cpp:879
Thread_t Alloc_Thread(void)
Alloc_Thread.
Definition: mark3c.cpp:156
void Mailbox_ReceiveTail(Mailbox_t handle, void *pvData_)
Mailbox_ReceiveTail.
Definition: mark3c.cpp:822
Mark3 Kernel Configuration This file is used to configure the kernel for your specific application in...
void Thread_Exit(Thread_t handle)
Thread_Exit.
Definition: mark3c.cpp:392
void * Thread_t
Thread opaque handle data type.
Definition: mark3c.h:46
void Free_Message(Message_t handle)
Definition: mark3c.cpp:82
bool ConditionVariable_TimedWait(ConditionVariable_t handle, Mutex_t hMutex_, uint32_t u32WaitTimeMS_)
ConditionVariable_TimedWait.
Definition: mark3c.cpp:891
!< Thread has been manually stopped
Definition: mark3c.h:108
uint8_t Atomic_Add8(uint8_t *pu8Source_, uint8_t u8Val_)
Atomic_Add8.
Definition: mark3c.cpp:643
void Notify_Signal(Notify_t handle)
Notify_Signal.
Definition: mark3c.cpp:602
void MessageQueue_Send(MessageQueue_t handle, Message_t hMessage_)
MessageQueue_Send.
Definition: mark3c.cpp:764
void(* coroutine_callback_t)(Coroutine_t caller, void *pvContext)
Definition: mark3c.h:64
void Mutex_Init(Mutex_t handle)
Mutex_Init.
Definition: mark3c.cpp:519
void Free_Mailbox(Mailbox_t handle)
Definition: mark3c.cpp:128
Message_t MessageQueue_TimedReceive(MessageQueue_t handle, uint32_t u32TimeWaitMS_)
MessageQueue_TimedReceive.
Definition: mark3c.cpp:757
void Notify_Wait(Notify_t handle, bool *pbFlag_)
Notify_Wait.
Definition: mark3c.cpp:609
uint32_t Kernel_GetTicks(void)
Kernel_GetTicks.
Definition: mark3c.cpp:227
uint16_t Message_GetCode(Message_t handle)
Message_GetCode.
Definition: mark3c.cpp:715
PORT_PRIO_TYPE Thread_GetPriority(Thread_t handle)
Thread_GetPriority.
Definition: mark3c.cpp:359
C-struct definitions that mirror.
void * ConditionVariable_t
Condition Variable opaque handle data type.
Definition: mark3c.h:48
void Message_SetCode(Message_t handle, uint16_t u16Code_)
Message_SetCode.
Definition: mark3c.cpp:708
bool Atomic_TestAndSet(bool *pbLock)
Atomic_TestAndSet.
Definition: mark3c.cpp:679
void Kernel_DebugPrint(const char *szString_)
KernelDebug_DebugPrint.
Definition: mark3c.cpp:293
void * Coroutine_t
Coroutine opaaque handle data type.
Definition: mark3c.h:50
void Notify_Init(Notify_t handle)
Notify_Init.
Definition: mark3c.cpp:595
uint32_t Atomic_Set32(uint32_t *pu32Source_, uint32_t u32Val_)
Atomic_Set32.
Definition: mark3c.cpp:637
void Thread_SetName(Thread_t handle, const char *szName_)
Definition: mark3c.cpp:346
void Semaphore_Post(Semaphore_t handle)
Semaphore_Post.
Definition: mark3c.cpp:496
bool Mailbox_TimedSendTail(Mailbox_t handle, void *pvData_, uint32_t u32TimeoutMS_)
Mailbox_TimedSendTail.
Definition: mark3c.cpp:808
uint16_t Atomic_Add16(uint16_t *pu16Source_, uint16_t u16Val_)
Atomic_Add16.
Definition: mark3c.cpp:649
bool Mailbox_IsEmpty(Mailbox_t handle)
Mailbox_IsEmpty.
Definition: mark3c.cpp:857
void Thread_SetQuantum(Thread_t handle, uint16_t u16Quantum_)
Definition: mark3c.cpp:372
void * Alloc_Memory(size_t eSize_)
Alloc_Memory.
void Free_Memory(void *pvObject_)
Free_Memory.
Definition: mark3c.cpp:34
Message_t MessageQueue_Receive(MessageQueue_t handle)
MessageQueue_Receive.
Definition: mark3c.cpp:729
void ReaderWriterLock_ReleaseReader(ReaderWriterLock_t handle)
ReaderWriterLock_ReleaseReader.
Definition: mark3c.cpp:915
bool Kernel_IsStarted(void)
Kernel_IsStarted.
Definition: mark3c.cpp:203
uint16_t Thread_GetQuantum(Thread_t handle)
Definition: mark3c.cpp:378
bool Mailbox_TimedReceive(Mailbox_t handle, void *pvData_, uint32_t u32TimeoutMS_)
Mailbox_TimedReceive.
Definition: mark3c.cpp:829
void ConditionVariable_Init(ConditionVariable_t handle)
ConditionVariable_Init.
Definition: mark3c.cpp:866
void ConditionVariable_Broadcast(ConditionVariable_t handle)
ConditionVariable_Broadcast.
Definition: mark3c.cpp:885
MessageQueue_t Alloc_MessageQueue(void)
Alloc_MessageQueue.
Definition: mark3c.cpp:88
Message_t Alloc_Message(void)
Alloc_Message.
Definition: mark3c.cpp:76
bool Mailbox_SendTail(Mailbox_t handle, void *pvData_)
Mailbox_SendTail.
Definition: mark3c.cpp:794
bool Kernel_IsPanic(void)
Kernel_IsPanic.
Definition: mark3c.cpp:215
void Message_Init(Message_t handle)
Message_Init.
Definition: mark3c.cpp:687
PORT_PRIO_TYPE Thread_GetCurPriority(Thread_t handle)
Thread_GetCurPriority.
Definition: mark3c.cpp:365
uint32_t Atomic_Add32(uint32_t *pu32Source_, uint32_t u32Val_)
Atomic_Add32.
Definition: mark3c.cpp:655
void Mailbox_Receive(Mailbox_t handle, void *pvData_)
Mailbox_Receive.
Definition: mark3c.cpp:815
void Thread_Sleep(uint32_t u32TimeMs_)
Thread_Sleep.
Definition: mark3c.cpp:399
void Kernel_Init(void)
Kernel_Init.
Definition: mark3c.cpp:191
void * ReaderWriterLock_t
Reader-writer-lock opaque handle data type.
Definition: mark3c.h:49
void Free_EventFlag(EventFlag_t handle)
Definition: mark3c.cpp:70
bool Mailbox_TimedReceiveTail(Mailbox_t handle, void *pvData_, uint32_t u32TimeoutMS_)
Mailbox_TimedReceiveTail.
Definition: mark3c.cpp:836
bool Mutex_TimedClaim(Mutex_t handle, uint32_t u32WaitTimeMS_)
Mutex_TimedClaim.
Definition: mark3c.cpp:540
void(* panic_func_t)(uint16_t u16PanicCode_)
Definition: mark3c.h:288
void MessageQueue_Init(MessageQueue_t handle)
MessageQueue_Init.
Definition: mark3c.cpp:722
!< Thread has terminated via exit path
Definition: mark3c.h:105
void * MessagePool_t
MessagePool opaque handle data type.
Definition: mark3c.h:41
void Mutex_Claim(Mutex_t handle)
Mutex_Claim.
Definition: mark3c.cpp:526
void ReaderWriterLock_Init(ReaderWriterLock_t handle)
ReaderWriterLock_Init.
Definition: mark3c.cpp:901
!< Thread is ready to run
Definition: mark3c.h:106
void(* timer_callback_t)(Thread_t hOwner_, void *pvData_)
Definition: mark3c.h:576
void Free_Mutex(Mutex_t handle)
Definition: mark3c.cpp:58
bool Notify_TimedWait(Notify_t handle, uint32_t u32WaitTimeMS_, bool *pbFlag_)
Notify_TimedWait.
Definition: mark3c.cpp:616
void Thread_Yield(void)
Thread_Yield.
Definition: mark3c.cpp:421
bool ReaderWriterLock_TimedAcquireReader(ReaderWriterLock_t handle, uint32_t u32TimeoutMs_)
ReaderWriterLock_TimedAcquireReader.
Definition: mark3c.cpp:943
void Semaphore_Init(Semaphore_t handle, uint16_t u16InitVal_, uint16_t u16MaxVal_)
Semaphore_Init.
Definition: mark3c.cpp:489
bool Scheduler_IsEnabled(void)
Scheduler_IsEnabled.
Definition: mark3c.cpp:306
void Thread_CoopYield(void)
Thread_CoopYield.
Definition: mark3c.cpp:426
void(* kernel_debug_print_t)(const char *szString_)
Definition: mark3c.h:63
void * MessageQueue_t
MessageQueue opaque handle data type.
Definition: mark3c.h:42
void Timer_Restart(Timer_t handle)
Timer_Restart.
Definition: mark3c.cpp:480
uint16_t Mailbox_GetFreeSlots(Mailbox_t handle)
Mailbox_GetFreeSlots.
Definition: mark3c.cpp:843
void Thread_SetPriority(Thread_t handle, PORT_PRIO_TYPE uXPriority_)
Thread_SetPriority.
Definition: mark3c.cpp:385
const char * Thread_GetName(Thread_t handle)
Definition: mark3c.cpp:352
thread_state_t
Definition: mark3c.h:103
void Timer_Start(Timer_t handle, bool bRepeat_, uint32_t u32IntervalMs_, timer_callback_t pfCallback_, void *pvData_)
Timer_Start.
Definition: mark3c.cpp:466
uint8_t Atomic_Sub8(uint8_t *pu8Source_, uint8_t u8Val_)
Atomic_Sub8.
Definition: mark3c.cpp:661
void * Timer_t
Timer opaque handle data type.
Definition: mark3c.h:47
uint16_t Atomic_Sub16(uint16_t *pu16Source_, uint16_t u16Val_)
Atomic_Sub16.
Definition: mark3c.cpp:667
void Mailbox_Init(Mailbox_t handle, void *pvBuffer_, uint16_t u16BufferSize_, uint16_t u16ElementSize_)
Mailbox_Init.
Definition: mark3c.cpp:780
bool Mailbox_Send(Mailbox_t handle, void *pvData_)
Mailbox_Send.
Definition: mark3c.cpp:787
void Thread_SetID(Thread_t handle, uint8_t u8ID_)
Thread_SetID.
Definition: mark3c.cpp:431
void MessagePool_Push(MessagePool_t handle, Message_t msg)
MessagePool_Push.
Definition: mark3c.cpp:743
void Thread_Init(Thread_t handle, K_WORD *pwStack_, uint16_t u16StackSize_, PORT_PRIO_TYPE uXPriority_, thread_entry_func_t pfEntryPoint_, void *pvArg_)
Thread_Init.
Definition: mark3c.cpp:321
bool Mailbox_IsFull(Mailbox_t handle)
Mailbox_IsFull.
Definition: mark3c.cpp:850
Notify_t Alloc_Notify(void)
Alloc_Notify.
Definition: mark3c.cpp:112
bool Semaphore_TimedPend(Semaphore_t handle, uint32_t u32WaitTimeMS_)
Semaphore_TimedPend.
Definition: mark3c.cpp:510
uint16_t Atomic_Set16(uint16_t *pu16Source_, uint16_t u16Val_)
Atomic_Set16.
Definition: mark3c.cpp:631