Mark3 Realtime Kernel
fake_types.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 ===========================================================================*/
26 #include <stdint.h>
27 #include <stddef.h>
28 #include <stdbool.h>
29 #include "mark3cfg.h"
30 
31 #pragma once
32 #if defined(__cplusplus)
34 extern "C" {
35 #endif
36 
37 //---------------------------------------------------------------------------
38 typedef struct {
39  void* prev;
40  void* next;
41 } Fake_LinkedListNode;
42 
43 //---------------------------------------------------------------------------
44 typedef struct {
45  void* head;
46  void* tail;
47 } Fake_LinkedList;
48 
49 //---------------------------------------------------------------------------
50 typedef struct {
51  Fake_LinkedListNode fake_node;
52  Fake_LinkedList fake_list;
53  PORT_PRIO_TYPE m_uXPriority;
54  void* m_pclMap;
55 } Fake_ThreadList;
56 
57 //---------------------------------------------------------------------------
58 typedef struct {
59  Fake_LinkedListNode m_ll_node;
60  uint8_t m_u8Initialized;
61  uint8_t m_u8Flags;
62  void* m_pfCallback;
63  uint32_t m_u32Interval;
64  uint32_t m_u32TimeLeft;
65  void* m_pclOwner;
66  void* m_pvData;
67 } Fake_Timer;
68 
69 //---------------------------------------------------------------------------
70 typedef struct {
71  Fake_LinkedListNode m_ll_node;
72  K_WORD* m_pwStackTop;
73  K_WORD* m_pwStack;
74  uint8_t m_u8ThreadID;
75  PORT_PRIO_TYPE m_uXPriority;
76  PORT_PRIO_TYPE m_uXCurPriority;
77  uint8_t m_eState;
78 #if KERNEL_EXTENDED_CONTEXT
79  void* m_pvExtendedContext;
80 #endif // #if KERNEL_EXTENDED_CONTEXT
81 #if KERNEL_NAMED_THREADS
82  const char* m_szName;
83 #endif // #if KERNEL_NAMED_THREADS
84  uint16_t m_u16StackSize;
85  void* m_pclCurrent;
86  void* m_pclOwner;
87  void* m_pfEntryPoint;
88  void* m_pvArg;
89 #if KERNEL_ROUND_ROBIN
90  uint16_t m_u16Quantum;
91 #endif // #if KERNEL_ROUND_ROBIN
92 #if KERNEL_EVENT_FLAGS
93  uint16_t m_u16FlagMask;
94  uint8_t m_eFlagMode;
95 #endif // #if KERNEL_EVENT_FLAGS
96  bool m_bExpired;
97  int m_iErrno;
98  Fake_Timer m_clTimer;
99 } Fake_Thread;
100 
101 //---------------------------------------------------------------------------
102 typedef struct {
103  Fake_ThreadList thread_list;
104  uint8_t m_u8Initialized;
105  uint16_t m_u16Value;
106  uint16_t m_u16MaxValue;
107 } Fake_Semaphore;
108 
109 //---------------------------------------------------------------------------
110 typedef struct {
111  Fake_ThreadList thread_list;
112  uint8_t m_u8Initialized;
113  uint8_t m_u8Recurse;
114  bool m_bReady;
115  bool m_bRecursive;
116  uint8_t m_u8MaxPri;
117  void* m_pclOwner;
118 } Fake_Mutex;
119 
120 //---------------------------------------------------------------------------
121 typedef struct {
122  Fake_LinkedListNode list_node;
123  void* m_pvData;
124  uint16_t m_u16Code;
125 } Fake_Message;
126 
127 //---------------------------------------------------------------------------
128 typedef struct {
129  Fake_Semaphore m_clSemaphore;
130  Fake_LinkedList m_clLinkList;
131 } Fake_MessageQueue;
132 
133 //---------------------------------------------------------------------------
134 typedef struct {
135  Fake_LinkedList m_clList;
136 } Fake_MessagePool;
137 
138 //---------------------------------------------------------------------------
139 typedef struct {
140  uint16_t m_u16Head;
141  uint16_t m_u16Tail;
142  uint16_t m_u16Count;
143  uint16_t m_u16Free;
144  uint16_t m_u16ElementSize;
145  void* m_pvBuffer;
146  Fake_Semaphore m_clRecvSem;
147  Fake_Semaphore m_clSendSem;
148 } Fake_Mailbox;
149 
150 //---------------------------------------------------------------------------
151 typedef struct {
152  Fake_ThreadList thread_list;
153  uint8_t m_u8Initialized;
154  bool m_bPending;
155 } Fake_Notify;
156 
157 //---------------------------------------------------------------------------
158 typedef struct {
159  Fake_ThreadList thread_list;
160  uint8_t m_u8Initialized;
161  uint16_t m_u16EventFlag;
162 } Fake_EventFlag;
163 
164 //---------------------------------------------------------------------------
165 typedef struct {
166  Fake_Mutex m_clGlobalMutex;
167  Fake_Mutex m_clReaderMutex;
168  uint8_t m_u8ReadCount;
169 } Fake_ReaderWriterLock;
170 
171 //---------------------------------------------------------------------------
172 typedef struct {
173  Fake_Mutex m_clMutex;
174  Fake_Semaphore m_clSemaphore;
175  uint8_t m_u8Waiters;
176 } Fake_ConditionVariable;
177 
178 //---------------------------------------------------------------------------
179 typedef struct {
180  Fake_LinkedListNode list_node;
181  void* m_pclOwner;
182  void* m_pvContext;
183  PORT_PRIO_TYPE m_uPriority;
184  bool m_bQueued;
185 } Fake_Coroutine;
186 
187 #if defined(__cplusplus)
188 }
189 #endif
190 
#define K_WORD
Size of a data word.
Definition: portcfg.h:62
#define PORT_PRIO_TYPE
Type used for bitmap in the PriorityMap class.
Definition: portcfg.h:73
Mark3 Kernel Configuration This file is used to configure the kernel for your specific application in...