Repository navigation
Expand file tree
/
Copy pathos.h
More file actions
2445 lines (1900 loc) · 113 KB
/
Copy pathos.h
File metadata and controls
2445 lines (1900 loc) · 113 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*********************************************************************************************************
* uC/OS-III
* The Real-Time Kernel
*
* Copyright 2009-2022 Silicon Laboratories Inc. www.silabs.com
*
* SPDX-License-Identifier: APACHE-2.0
*
* This software is subject to an open source license and is distributed by
* Silicon Laboratories Inc. pursuant to the terms of the Apache License,
* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
*
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* File : os.h
* Version : V3.08.02
*********************************************************************************************************
* Note(s) : (1) Assumes the following versions (or more recent) of software modules are included
* in the project build:
*
* (a) uC/CPU V1.31.00
*********************************************************************************************************
*/
#ifndef OS_H
#define OS_H
/*
************************************************************************************************************************
* uC/OS-III VERSION NUMBER
************************************************************************************************************************
*/
#define OS_VERSION 30802u /* Version of uC/OS-III (Vx.yy.zz mult. by 10000) */
/*
************************************************************************************************************************
* INCLUDE HEADER FILES
************************************************************************************************************************
*/
#include <os_cfg.h>
#include <os_cfg_app.h>
#include <cpu_core.h>
#include "os_type.h"
#include <os_cpu.h>
#include "os_trace.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
************************************************************************************************************************
* COMPATIBILITY CONFIGURATIONS
************************************************************************************************************************
*/
#ifndef OS_CFG_TASK_IDLE_EN
#define OS_CFG_TASK_IDLE_EN 1u
#endif
#ifndef OS_CFG_TASK_STK_REDZONE_EN
#define OS_CFG_TASK_STK_REDZONE_EN 0u
#endif
#ifndef OS_CFG_INVALID_OS_CALLS_CHK_EN
#define OS_CFG_INVALID_OS_CALLS_CHK_EN 0u
#endif
/*
************************************************************************************************************************
* CRITICAL SECTION HANDLING
************************************************************************************************************************
*/
#if (OS_CFG_SCHED_LOCK_TIME_MEAS_EN > 0u) && defined(CPU_CFG_INT_DIS_MEAS_EN)
#define OS_SCHED_LOCK_TIME_MEAS_START() OS_SchedLockTimeMeasStart()
#else
#define OS_SCHED_LOCK_TIME_MEAS_START()
#endif
#if (OS_CFG_SCHED_LOCK_TIME_MEAS_EN > 0u) && defined(CPU_CFG_INT_DIS_MEAS_EN)
#define OS_SCHED_LOCK_TIME_MEAS_STOP() OS_SchedLockTimeMeasStop()
#else
#define OS_SCHED_LOCK_TIME_MEAS_STOP()
#endif
/*
************************************************************************************************************************
* MISCELLANEOUS
************************************************************************************************************************
*/
#ifdef OS_GLOBALS
#define OS_EXT
#else
#define OS_EXT extern
#endif
#ifndef OS_FALSE
#define OS_FALSE 0u
#endif
#ifndef OS_TRUE
#define OS_TRUE 1u
#endif
#define OS_PRIO_TBL_SIZE (((OS_CFG_PRIO_MAX - 1u) / ((CPU_CFG_DATA_SIZE * 8u))) + 1u)
#define OS_MSG_EN (((OS_CFG_TASK_Q_EN > 0u) || (OS_CFG_Q_EN > 0u)) ? 1u : 0u)
#define OS_OBJ_TYPE_REQ (((OS_CFG_DBG_EN > 0u) || (OS_CFG_OBJ_TYPE_CHK_EN > 0u)) ? 1u : 0u)
/*
************************************************************************************************************************
************************************************************************************************************************
* # D E F I N E S
************************************************************************************************************************
************************************************************************************************************************
*/
/*
========================================================================================================================
* TASK STATUS
========================================================================================================================
*/
#define OS_STATE_OS_STOPPED (OS_STATE)(0u)
#define OS_STATE_OS_RUNNING (OS_STATE)(1u)
#define OS_STATE_NOT_RDY (CPU_BOOLEAN)(0u)
#define OS_STATE_RDY (CPU_BOOLEAN)(1u)
/* ------------------- TASK STATES ------------------ */
#define OS_TASK_STATE_BIT_DLY (OS_STATE)(0x01u) /* /-------- SUSPENDED bit */
/* | */
#define OS_TASK_STATE_BIT_PEND (OS_STATE)(0x02u) /* | /----- PEND bit */
/* | | */
#define OS_TASK_STATE_BIT_SUSPENDED (OS_STATE)(0x04u) /* | | /--- Delayed/Timeout bit */
/* | | | */
/* V V V */
#define OS_TASK_STATE_RDY (OS_STATE)( 0u) /* 0 0 0 Ready */
#define OS_TASK_STATE_DLY (OS_STATE)( 1u) /* 0 0 1 Delayed or Timeout */
#define OS_TASK_STATE_PEND (OS_STATE)( 2u) /* 0 1 0 Pend */
#define OS_TASK_STATE_PEND_TIMEOUT (OS_STATE)( 3u) /* 0 1 1 Pend + Timeout */
#define OS_TASK_STATE_SUSPENDED (OS_STATE)( 4u) /* 1 0 0 Suspended */
#define OS_TASK_STATE_DLY_SUSPENDED (OS_STATE)( 5u) /* 1 0 1 Suspended + Delayed or Timeout */
#define OS_TASK_STATE_PEND_SUSPENDED (OS_STATE)( 6u) /* 1 1 0 Suspended + Pend */
#define OS_TASK_STATE_PEND_TIMEOUT_SUSPENDED (OS_STATE)( 7u) /* 1 1 1 Suspended + Pend + Timeout */
#define OS_TASK_STATE_DEL (OS_STATE)(255u)
/* ----------------- PENDING ON ... ----------------- */
#define OS_TASK_PEND_ON_NOTHING (OS_STATE)( 0u) /* Pending on nothing */
#define OS_TASK_PEND_ON_FLAG (OS_STATE)( 1u) /* Pending on event flag group */
#define OS_TASK_PEND_ON_TASK_Q (OS_STATE)( 2u) /* Pending on message to be sent to task */
#define OS_TASK_PEND_ON_COND (OS_STATE)( 3u) /* Pending on condition variable */
#define OS_TASK_PEND_ON_MUTEX (OS_STATE)( 4u) /* Pending on mutual exclusion semaphore */
#define OS_TASK_PEND_ON_Q (OS_STATE)( 5u) /* Pending on queue */
#define OS_TASK_PEND_ON_SEM (OS_STATE)( 6u) /* Pending on semaphore */
#define OS_TASK_PEND_ON_TASK_SEM (OS_STATE)( 7u) /* Pending on signal to be sent to task */
/*
------------------------------------------------------------------------------------------------------------------------
* TASK PEND STATUS
* (Status codes for OS_TCBs field .PendStatus)
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_STATUS_PEND_OK (OS_STATUS)( 0u) /* Pending status OK, !pending, or pending complete */
#define OS_STATUS_PEND_ABORT (OS_STATUS)( 1u) /* Pending aborted */
#define OS_STATUS_PEND_DEL (OS_STATUS)( 2u) /* Pending object deleted */
#define OS_STATUS_PEND_TIMEOUT (OS_STATUS)( 3u) /* Pending timed out */
/*
========================================================================================================================
* OS OBJECT TYPES
*
* Note(s) : (1) OS_OBJ_TYPE_&&& #define values specifically chosen as ASCII representations of the kernel
* object types. Memory displays of kernel objects will display the kernel object TYPEs with
* their chosen ASCII names.
========================================================================================================================
*/
#define OS_OBJ_TYPE_NONE (OS_OBJ_TYPE)CPU_TYPE_CREATE('N', 'O', 'N', 'E')
#define OS_OBJ_TYPE_FLAG (OS_OBJ_TYPE)CPU_TYPE_CREATE('F', 'L', 'A', 'G')
#define OS_OBJ_TYPE_MEM (OS_OBJ_TYPE)CPU_TYPE_CREATE('M', 'E', 'M', ' ')
#define OS_OBJ_TYPE_MUTEX (OS_OBJ_TYPE)CPU_TYPE_CREATE('M', 'U', 'T', 'X')
#define OS_OBJ_TYPE_COND (OS_OBJ_TYPE)CPU_TYPE_CREATE('C', 'O', 'N', 'D')
#define OS_OBJ_TYPE_Q (OS_OBJ_TYPE)CPU_TYPE_CREATE('Q', 'U', 'E', 'U')
#define OS_OBJ_TYPE_SEM (OS_OBJ_TYPE)CPU_TYPE_CREATE('S', 'E', 'M', 'A')
#define OS_OBJ_TYPE_TMR (OS_OBJ_TYPE)CPU_TYPE_CREATE('T', 'M', 'R', ' ')
/*
========================================================================================================================
* Possible values for 'opt' argument
========================================================================================================================
*/
#define OS_OPT_NONE (OS_OPT)(0x0000u)
/*
------------------------------------------------------------------------------------------------------------------------
* DELETE OPTIONS
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_OPT_DEL_NO_PEND (OS_OPT)(0x0000u)
#define OS_OPT_DEL_ALWAYS (OS_OPT)(0x0001u)
/*
------------------------------------------------------------------------------------------------------------------------
* PEND OPTIONS
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_OPT_PEND_FLAG_MASK (OS_OPT)(0x000Fu)
#define OS_OPT_PEND_FLAG_CLR_ALL (OS_OPT)(0x0001u) /* Wait for ALL the bits specified to be CLR */
#define OS_OPT_PEND_FLAG_CLR_AND (OS_OPT)(0x0001u)
#define OS_OPT_PEND_FLAG_CLR_ANY (OS_OPT)(0x0002u) /* Wait for ANY of the bits specified to be CLR */
#define OS_OPT_PEND_FLAG_CLR_OR (OS_OPT)(0x0002u)
#define OS_OPT_PEND_FLAG_SET_ALL (OS_OPT)(0x0004u) /* Wait for ALL the bits specified to be SET */
#define OS_OPT_PEND_FLAG_SET_AND (OS_OPT)(0x0004u)
#define OS_OPT_PEND_FLAG_SET_ANY (OS_OPT)(0x0008u) /* Wait for ANY of the bits specified to be SET */
#define OS_OPT_PEND_FLAG_SET_OR (OS_OPT)(0x0008u)
#define OS_OPT_PEND_FLAG_CONSUME (OS_OPT)(0x0100u) /* Consume the flags if condition(s) satisfied */
#define OS_OPT_PEND_BLOCKING (OS_OPT)(0x0000u)
#define OS_OPT_PEND_NON_BLOCKING (OS_OPT)(0x8000u)
/*
------------------------------------------------------------------------------------------------------------------------
* PEND ABORT OPTIONS
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_OPT_PEND_ABORT_1 (OS_OPT)(0x0000u) /* Pend abort a single waiting task */
#define OS_OPT_PEND_ABORT_ALL (OS_OPT)(0x0100u) /* Pend abort ALL tasks waiting */
/*
------------------------------------------------------------------------------------------------------------------------
* POST OPTIONS
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_OPT_POST_NONE (OS_OPT)(0x0000u)
#define OS_OPT_POST_FLAG_SET (OS_OPT)(0x0000u)
#define OS_OPT_POST_FLAG_CLR (OS_OPT)(0x0001u)
#define OS_OPT_POST_FIFO (OS_OPT)(0x0000u) /* Default is to post FIFO */
#define OS_OPT_POST_LIFO (OS_OPT)(0x0010u) /* Post to highest priority task waiting */
#define OS_OPT_POST_1 (OS_OPT)(0x0000u) /* Post message to highest priority task waiting */
#define OS_OPT_POST_ALL (OS_OPT)(0x0200u) /* Broadcast message to ALL tasks waiting */
#define OS_OPT_POST_NO_SCHED (OS_OPT)(0x8000u) /* Do not call the scheduler if this is selected */
/*
------------------------------------------------------------------------------------------------------------------------
* TASK OPTIONS
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_OPT_TASK_NONE (OS_OPT)(0x0000u) /* No option selected */
#define OS_OPT_TASK_STK_CHK (OS_OPT)(0x0001u) /* Enable stack checking for the task */
#define OS_OPT_TASK_STK_CLR (OS_OPT)(0x0002u) /* Clear the stack when the task is create */
#define OS_OPT_TASK_SAVE_FP (OS_OPT)(0x0004u) /* Save the contents of any floating-point registers */
#define OS_OPT_TASK_NO_TLS (OS_OPT)(0x0008u) /* Specifies the task DOES NOT require TLS support */
/*
------------------------------------------------------------------------------------------------------------------------
* TIME OPTIONS
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_OPT_TIME_DLY 0x00u
#define OS_OPT_TIME_TIMEOUT ((OS_OPT)0x02u)
#define OS_OPT_TIME_MATCH ((OS_OPT)0x04u)
#define OS_OPT_TIME_PERIODIC ((OS_OPT)0x08u)
#define OS_OPT_TIME_HMSM_STRICT ((OS_OPT)0x00u)
#define OS_OPT_TIME_HMSM_NON_STRICT ((OS_OPT)0x10u)
#define OS_OPT_TIME_MASK ((OS_OPT)(OS_OPT_TIME_DLY | \
OS_OPT_TIME_TIMEOUT | \
OS_OPT_TIME_PERIODIC | \
OS_OPT_TIME_MATCH))
#define OS_OPT_TIME_OPTS_MASK ((OS_OPT)(OS_OPT_TIME_DLY | \
OS_OPT_TIME_TIMEOUT | \
OS_OPT_TIME_PERIODIC | \
OS_OPT_TIME_MATCH | \
OS_OPT_TIME_HMSM_NON_STRICT))
/*
------------------------------------------------------------------------------------------------------------------------
* TIMER OPTIONS
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_OPT_TMR_NONE (OS_OPT)(0u) /* No option selected */
#define OS_OPT_TMR_ONE_SHOT (OS_OPT)(1u) /* Timer will not auto restart when it expires */
#define OS_OPT_TMR_PERIODIC (OS_OPT)(2u) /* Timer will auto restart when it expires */
#define OS_OPT_TMR_CALLBACK (OS_OPT)(3u) /* OSTmrStop() option to call 'callback' w/ timer arg */
#define OS_OPT_TMR_CALLBACK_ARG (OS_OPT)(4u) /* OSTmrStop() option to call 'callback' w/ new arg */
/*
------------------------------------------------------------------------------------------------------------------------
* TIMER STATES
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_TMR_STATE_UNUSED (OS_STATE)(0u)
#define OS_TMR_STATE_STOPPED (OS_STATE)(1u)
#define OS_TMR_STATE_RUNNING (OS_STATE)(2u)
#define OS_TMR_STATE_COMPLETED (OS_STATE)(3u)
#define OS_TMR_STATE_TIMEOUT (OS_STATE)(4u)
/*
------------------------------------------------------------------------------------------------------------------------
* PRIORITY
------------------------------------------------------------------------------------------------------------------------
*/
/* Dflt prio to init task TCB */
#define OS_PRIO_INIT (OS_PRIO)(OS_CFG_PRIO_MAX)
/*
------------------------------------------------------------------------------------------------------------------------
* STACK REDZONE
------------------------------------------------------------------------------------------------------------------------
*/
#define OS_STACK_CHECK_VAL 0x5432DCBAABCD2345UL
#define OS_STACK_CHECK_DEPTH 8u
/*
************************************************************************************************************************
************************************************************************************************************************
* E N U M E R A T I O N S
************************************************************************************************************************
************************************************************************************************************************
*/
/*
------------------------------------------------------------------------------------------------------------------------
* ERROR CODES
------------------------------------------------------------------------------------------------------------------------
*/
typedef enum os_err {
OS_ERR_NONE = 0u,
OS_ERR_A = 10000u,
OS_ERR_ACCEPT_ISR = 10001u,
OS_ERR_B = 11000u,
OS_ERR_C = 12000u,
OS_ERR_CREATE_ISR = 12001u,
OS_ERR_D = 13000u,
OS_ERR_DEL_ISR = 13001u,
OS_ERR_E = 14000u,
OS_ERR_F = 15000u,
OS_ERR_FATAL_RETURN = 15001u,
OS_ERR_FLAG_GRP_DEPLETED = 15101u,
OS_ERR_FLAG_NOT_RDY = 15102u,
OS_ERR_FLAG_PEND_OPT = 15103u,
OS_ERR_FLUSH_ISR = 15104u,
OS_ERR_G = 16000u,
OS_ERR_H = 17000u,
OS_ERR_I = 18000u,
OS_ERR_ILLEGAL_CREATE_RUN_TIME = 18001u,
OS_ERR_ILLEGAL_DEL_RUN_TIME = 18007u,
OS_ERR_J = 19000u,
OS_ERR_K = 20000u,
OS_ERR_L = 21000u,
OS_ERR_LOCK_NESTING_OVF = 21001u,
OS_ERR_M = 22000u,
OS_ERR_MEM_CREATE_ISR = 22201u,
OS_ERR_MEM_FULL = 22202u,
OS_ERR_MEM_INVALID_P_ADDR = 22203u,
OS_ERR_MEM_INVALID_BLKS = 22204u,
OS_ERR_MEM_INVALID_PART = 22205u,
OS_ERR_MEM_INVALID_P_BLK = 22206u,
OS_ERR_MEM_INVALID_P_MEM = 22207u,
OS_ERR_MEM_INVALID_P_DATA = 22208u,
OS_ERR_MEM_INVALID_SIZE = 22209u,
OS_ERR_MEM_NO_FREE_BLKS = 22210u,
OS_ERR_MSG_POOL_EMPTY = 22301u,
OS_ERR_MSG_POOL_NULL_PTR = 22302u,
OS_ERR_MUTEX_NOT_OWNER = 22401u,
OS_ERR_MUTEX_OWNER = 22402u,
OS_ERR_MUTEX_NESTING = 22403u,
OS_ERR_MUTEX_OVF = 22404u,
OS_ERR_N = 23000u,
OS_ERR_NAME = 23001u,
OS_ERR_NO_MORE_ID_AVAIL = 23002u,
OS_ERR_O = 24000u,
OS_ERR_OBJ_CREATED = 24001u,
OS_ERR_OBJ_DEL = 24002u,
OS_ERR_OBJ_PTR_NULL = 24003u,
OS_ERR_OBJ_TYPE = 24004u,
OS_ERR_OPT_INVALID = 24101u,
OS_ERR_OS_NOT_RUNNING = 24201u,
OS_ERR_OS_RUNNING = 24202u,
OS_ERR_OS_NOT_INIT = 24203u,
OS_ERR_OS_NO_APP_TASK = 24204u,
OS_ERR_P = 25000u,
OS_ERR_PEND_ABORT = 25001u,
OS_ERR_PEND_ABORT_ISR = 25002u,
OS_ERR_PEND_ABORT_NONE = 25003u,
OS_ERR_PEND_ABORT_SELF = 25004u,
OS_ERR_PEND_DEL = 25005u,
OS_ERR_PEND_ISR = 25006u,
OS_ERR_PEND_LOCKED = 25007u,
OS_ERR_PEND_WOULD_BLOCK = 25008u,
OS_ERR_POST_NULL_PTR = 25101u,
OS_ERR_POST_ISR = 25102u,
OS_ERR_PRIO_EXIST = 25201u,
OS_ERR_PRIO = 25202u,
OS_ERR_PRIO_INVALID = 25203u,
OS_ERR_PTR_INVALID = 25301u,
OS_ERR_Q = 26000u,
OS_ERR_Q_FULL = 26001u,
OS_ERR_Q_EMPTY = 26002u,
OS_ERR_Q_MAX = 26003u,
OS_ERR_Q_SIZE = 26004u,
OS_ERR_R = 27000u,
OS_ERR_REG_ID_INVALID = 27001u,
OS_ERR_ROUND_ROBIN_1 = 27002u,
OS_ERR_ROUND_ROBIN_DISABLED = 27003u,
OS_ERR_S = 28000u,
OS_ERR_SCHED_INVALID_TIME_SLICE = 28001u,
OS_ERR_SCHED_LOCK_ISR = 28002u,
OS_ERR_SCHED_LOCKED = 28003u,
OS_ERR_SCHED_NOT_LOCKED = 28004u,
OS_ERR_SCHED_UNLOCK_ISR = 28005u,
OS_ERR_SEM_OVF = 28101u,
OS_ERR_SET_ISR = 28102u,
OS_ERR_STAT_RESET_ISR = 28201u,
OS_ERR_STAT_PRIO_INVALID = 28202u,
OS_ERR_STAT_STK_INVALID = 28203u,
OS_ERR_STAT_STK_SIZE_INVALID = 28204u,
OS_ERR_STATE_INVALID = 28205u,
OS_ERR_STATUS_INVALID = 28206u,
OS_ERR_STK_INVALID = 28207u,
OS_ERR_STK_SIZE_INVALID = 28208u,
OS_ERR_STK_LIMIT_INVALID = 28209u,
OS_ERR_STK_OVF = 28210u,
OS_ERR_T = 29000u,
OS_ERR_TASK_CHANGE_PRIO_ISR = 29001u,
OS_ERR_TASK_CREATE_ISR = 29002u,
OS_ERR_TASK_DEL = 29003u,
OS_ERR_TASK_DEL_IDLE = 29004u,
OS_ERR_TASK_DEL_INVALID = 29005u,
OS_ERR_TASK_DEL_ISR = 29006u,
OS_ERR_TASK_INVALID = 29007u,
OS_ERR_TASK_NO_MORE_TCB = 29008u,
OS_ERR_TASK_NOT_DLY = 29009u,
OS_ERR_TASK_NOT_EXIST = 29010u,
OS_ERR_TASK_NOT_SUSPENDED = 29011u,
OS_ERR_TASK_OPT = 29012u,
OS_ERR_TASK_RESUME_ISR = 29013u,
OS_ERR_TASK_RESUME_PRIO = 29014u,
OS_ERR_TASK_RESUME_SELF = 29015u,
OS_ERR_TASK_RUNNING = 29016u,
OS_ERR_TASK_STK_CHK_ISR = 29017u,
OS_ERR_TASK_SUSPENDED = 29018u,
OS_ERR_TASK_SUSPEND_IDLE = 29019u,
OS_ERR_TASK_SUSPEND_INT_HANDLER = 29020u,
OS_ERR_TASK_SUSPEND_ISR = 29021u,
OS_ERR_TASK_SUSPEND_PRIO = 29022u,
OS_ERR_TASK_WAITING = 29023u,
OS_ERR_TASK_SUSPEND_CTR_OVF = 29024u,
OS_ERR_TCB_INVALID = 29101u,
OS_ERR_TLS_ID_INVALID = 29120u,
OS_ERR_TLS_ISR = 29121u,
OS_ERR_TLS_NO_MORE_AVAIL = 29122u,
OS_ERR_TLS_NOT_EN = 29123u,
OS_ERR_TLS_DESTRUCT_ASSIGNED = 29124u,
OS_ERR_TICK_PRIO_INVALID = 29201u,
OS_ERR_TICK_STK_INVALID = 29202u,
OS_ERR_TICK_STK_SIZE_INVALID = 29203u,
OS_ERR_TICK_WHEEL_SIZE = 29204u,
OS_ERR_TICK_DISABLED = 29205u,
OS_ERR_TIME_DLY_ISR = 29301u,
OS_ERR_TIME_DLY_RESUME_ISR = 29302u,
OS_ERR_TIME_GET_ISR = 29303u,
OS_ERR_TIME_INVALID_HOURS = 29304u,
OS_ERR_TIME_INVALID_MINUTES = 29305u,
OS_ERR_TIME_INVALID_SECONDS = 29306u,
OS_ERR_TIME_INVALID_MILLISECONDS = 29307u,
OS_ERR_TIME_NOT_DLY = 29308u,
OS_ERR_TIME_SET_ISR = 29309u,
OS_ERR_TIME_ZERO_DLY = 29310u,
OS_ERR_TIMEOUT = 29401u,
OS_ERR_TMR_INACTIVE = 29501u,
OS_ERR_TMR_INVALID_DEST = 29502u,
OS_ERR_TMR_INVALID_DLY = 29503u,
OS_ERR_TMR_INVALID_PERIOD = 29504u,
OS_ERR_TMR_INVALID_STATE = 29505u,
OS_ERR_TMR_INVALID = 29506u,
OS_ERR_TMR_ISR = 29507u,
OS_ERR_TMR_NO_CALLBACK = 29508u,
OS_ERR_TMR_NON_AVAIL = 29509u,
OS_ERR_TMR_PRIO_INVALID = 29510u,
OS_ERR_TMR_STK_INVALID = 29511u,
OS_ERR_TMR_STK_SIZE_INVALID = 29512u,
OS_ERR_TMR_STOPPED = 29513u,
OS_ERR_TMR_INVALID_CALLBACK = 29514u,
OS_ERR_U = 30000u,
OS_ERR_V = 31000u,
OS_ERR_W = 32000u,
OS_ERR_X = 33000u,
OS_ERR_Y = 34000u,
OS_ERR_YIELD_ISR = 34001u,
OS_ERR_Z = 35000u
} OS_ERR;
/*
************************************************************************************************************************
************************************************************************************************************************
* D A T A T Y P E S
************************************************************************************************************************
************************************************************************************************************************
*/
typedef struct os_flag_grp OS_FLAG_GRP;
typedef struct os_mem OS_MEM;
typedef struct os_msg OS_MSG;
typedef struct os_msg_pool OS_MSG_POOL;
typedef struct os_msg_q OS_MSG_Q;
typedef struct os_mutex OS_MUTEX;
typedef struct os_cond OS_COND;
typedef struct os_q OS_Q;
typedef struct os_sem OS_SEM;
typedef void (*OS_TASK_PTR)(void *p_arg);
typedef struct os_tcb OS_TCB;
#if defined(OS_CFG_TLS_TBL_SIZE) && (OS_CFG_TLS_TBL_SIZE > 0u)
typedef void *OS_TLS;
typedef CPU_DATA OS_TLS_ID;
typedef void (*OS_TLS_DESTRUCT_PTR)(OS_TCB *p_tcb,
OS_TLS_ID id,
OS_TLS value);
#endif
typedef struct os_rdy_list OS_RDY_LIST;
typedef struct os_tick_list OS_TICK_LIST;
typedef void (*OS_TMR_CALLBACK_PTR)(void *p_tmr, void *p_arg);
typedef struct os_tmr OS_TMR;
typedef struct os_pend_list OS_PEND_LIST;
typedef struct os_pend_obj OS_PEND_OBJ;
#if (OS_CFG_APP_HOOKS_EN > 0u)
typedef void (*OS_APP_HOOK_VOID)(void);
typedef void (*OS_APP_HOOK_TCB)(OS_TCB *p_tcb);
#endif
/*
************************************************************************************************************************
************************************************************************************************************************
* D A T A S T R U C T U R E S
************************************************************************************************************************
************************************************************************************************************************
*/
/*
------------------------------------------------------------------------------------------------------------------------
* READY LIST
------------------------------------------------------------------------------------------------------------------------
*/
struct os_rdy_list {
OS_TCB *HeadPtr; /* Pointer to task that will run at selected priority */
OS_TCB *TailPtr; /* Pointer to last task at selected priority */
#if (OS_CFG_DBG_EN > 0u)
OS_OBJ_QTY NbrEntries; /* Number of entries at selected priority */
#endif
};
/*
------------------------------------------------------------------------------------------------------------------------
* PEND LIST
------------------------------------------------------------------------------------------------------------------------
*/
struct os_pend_list {
OS_TCB *HeadPtr;
OS_TCB *TailPtr;
#if (OS_CFG_DBG_EN > 0u)
OS_OBJ_QTY NbrEntries;
#endif
};
/*
------------------------------------------------------------------------------------------------------------------------
* PEND OBJ
*
* Note(s) : (1) The 'os_pend_obj' structure data type is a template/subset for specific kernel objects' data types:
* 'os_flag_grp', 'os_mutex', 'os_q', and 'os_sem'. Each specific kernel object data type MUST define
* ALL generic OS pend object parameters, synchronized in both the sequential order & data type of each
* parameter.
*
* Thus, ANY modification to the sequential order or data types of OS pend object parameters MUST be
* appropriately synchronized between the generic OS pend object data type & ALL specific kernel objects'
* data types.
------------------------------------------------------------------------------------------------------------------------
*/
struct os_pend_obj {
#if (OS_OBJ_TYPE_REQ > 0u)
OS_OBJ_TYPE Type;
#endif
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr;
#endif
OS_PEND_LIST PendList; /* List of tasks pending on object */
#if (OS_CFG_DBG_EN > 0u)
void *DbgPrevPtr;
void *DbgNextPtr;
CPU_CHAR *DbgNamePtr;
#endif
};
/*
------------------------------------------------------------------------------------------------------------------------
* EVENT FLAGS
*
* Note(s) : See PEND OBJ Note #1'.
------------------------------------------------------------------------------------------------------------------------
*/
struct os_flag_grp { /* Event Flag Group */
/* ------------------ GENERIC MEMBERS ------------------ */
#if (OS_OBJ_TYPE_REQ > 0u)
OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_FLAG */
#endif
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr; /* Pointer to Event Flag Name (NUL terminated ASCII) */
#endif
OS_PEND_LIST PendList; /* List of tasks waiting on event flag group */
#if (OS_CFG_DBG_EN > 0u)
OS_FLAG_GRP *DbgPrevPtr;
OS_FLAG_GRP *DbgNextPtr;
CPU_CHAR *DbgNamePtr;
#endif
/* ------------------ SPECIFIC MEMBERS ------------------ */
OS_FLAGS Flags; /* 8, 16 or 32 bit flags */
#if (OS_CFG_TS_EN > 0u)
CPU_TS TS; /* Timestamp of when last post occurred */
#endif
#if (defined(OS_CFG_TRACE_EN) && (OS_CFG_TRACE_EN > 0u))
CPU_ADDR FlagID; /* Unique ID for third-party debuggers and tracers. */
#endif
};
/*
------------------------------------------------------------------------------------------------------------------------
* MEMORY PARTITIONS
------------------------------------------------------------------------------------------------------------------------
*/
struct os_mem { /* MEMORY CONTROL BLOCK */
#if (OS_OBJ_TYPE_REQ > 0u)
OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_MEM */
#endif
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr;
#endif
void *AddrPtr; /* Pointer to beginning of memory partition */
void *FreeListPtr; /* Pointer to list of free memory blocks */
OS_MEM_SIZE BlkSize; /* Size (in bytes) of each block of memory */
OS_MEM_QTY NbrMax; /* Total number of blocks in this partition */
OS_MEM_QTY NbrFree; /* Number of memory blocks remaining in this partition */
#if (OS_CFG_DBG_EN > 0u)
OS_MEM *DbgPrevPtr;
OS_MEM *DbgNextPtr;
#endif
#if (defined(OS_CFG_TRACE_EN) && (OS_CFG_TRACE_EN > 0u))
CPU_ADDR MemID; /* Unique ID for third-party debuggers and tracers. */
#endif
};
/*
------------------------------------------------------------------------------------------------------------------------
* MESSAGES
------------------------------------------------------------------------------------------------------------------------
*/
struct os_msg { /* MESSAGE CONTROL BLOCK */
OS_MSG *NextPtr; /* Pointer to next message */
void *MsgPtr; /* Actual message */
OS_MSG_SIZE MsgSize; /* Size of the message (in # bytes) */
#if (OS_CFG_TS_EN > 0u)
CPU_TS MsgTS; /* Time stamp of when message was sent */
#endif
};
struct os_msg_pool { /* OS_MSG POOL */
OS_MSG *NextPtr; /* Pointer to next message */
OS_MSG_QTY NbrFree; /* Number of messages available from this pool */
OS_MSG_QTY NbrUsed; /* Current number of messages used */
#if (OS_CFG_DBG_EN > 0u)
OS_MSG_QTY NbrUsedMax; /* Peak number of messages used */
#endif
};
struct os_msg_q { /* OS_MSG_Q */
OS_MSG *InPtr; /* Pointer to next OS_MSG to be inserted in the queue */
OS_MSG *OutPtr; /* Pointer to next OS_MSG to be extracted from the queue */
OS_MSG_QTY NbrEntriesSize; /* Maximum allowable number of entries in the queue */
OS_MSG_QTY NbrEntries; /* Current number of entries in the queue */
#if (OS_CFG_DBG_EN > 0u)
OS_MSG_QTY NbrEntriesMax; /* Peak number of entries in the queue */
#endif
#if (defined(OS_CFG_TRACE_EN) && (OS_CFG_TRACE_EN > 0u))
CPU_ADDR MsgQID; /* Unique ID for third-party debuggers and tracers. */
#endif
};
/*
------------------------------------------------------------------------------------------------------------------------
* MUTUAL EXCLUSION SEMAPHORES
*
* Note(s) : See PEND OBJ Note #1'.
------------------------------------------------------------------------------------------------------------------------
*/
struct os_mutex { /* Mutual Exclusion Semaphore */
/* ------------------ GENERIC MEMBERS ------------------ */
#if (OS_OBJ_TYPE_REQ > 0u)
OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_MUTEX */
#endif
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr; /* Pointer to Mutex Name (NUL terminated ASCII) */
#endif
OS_PEND_LIST PendList; /* List of tasks waiting on mutex */
#if (OS_CFG_DBG_EN > 0u)
OS_MUTEX *DbgPrevPtr;
OS_MUTEX *DbgNextPtr;
CPU_CHAR *DbgNamePtr;
#endif
/* ------------------ SPECIFIC MEMBERS ------------------ */
OS_MUTEX *MutexGrpNextPtr;
OS_TCB *OwnerTCBPtr;
OS_NESTING_CTR OwnerNestingCtr; /* Mutex is available when the counter is 0 */
#if (OS_CFG_TS_EN > 0u)
CPU_TS TS;
#endif
#if (defined(OS_CFG_TRACE_EN) && (OS_CFG_TRACE_EN > 0u))
CPU_ADDR MutexID; /* Unique ID for third-party debuggers and tracers. */
#endif
};
/*
------------------------------------------------------------------------------------------------------------------------
* CONDITION VARIABLES
*
* Note(s) : See PEND OBJ Note #1'.
------------------------------------------------------------------------------------------------------------------------
*/
struct os_cond { /* Condition Variable */
/* ------------------ GENERIC MEMBERS ------------------ */
#if (OS_OBJ_TYPE_REQ > 0u)
OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_COND */
#endif
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr; /* Pointer to Mutex Name (NUL terminated ASCII) */
#endif
OS_PEND_LIST PendList; /* List of tasks waiting on condition variable */
#if (OS_CFG_DBG_EN > 0u)
void *DbgPrevPtr;
void *DbgNextPtr;
CPU_CHAR *DbgNamePtr;
#endif
/* ------------------ SPECIFIC MEMBERS ------------------ */
OS_MUTEX *Mutex; /* Mutex bound to the condition variable. */
};
/*
------------------------------------------------------------------------------------------------------------------------
* MESSAGE QUEUES
*
* Note(s) : See PEND OBJ Note #1'.
------------------------------------------------------------------------------------------------------------------------
*/
struct os_q { /* Message Queue */
/* ------------------ GENERIC MEMBERS ------------------ */
#if (OS_OBJ_TYPE_REQ > 0u)
OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_Q */
#endif
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr; /* Pointer to Message Queue Name (NUL terminated ASCII) */
#endif
OS_PEND_LIST PendList; /* List of tasks waiting on message queue */
#if (OS_CFG_DBG_EN > 0u)
OS_Q *DbgPrevPtr;
OS_Q *DbgNextPtr;
CPU_CHAR *DbgNamePtr;
#endif
/* ------------------ SPECIFIC MEMBERS ------------------ */
OS_MSG_Q MsgQ; /* List of messages */
};
/*
------------------------------------------------------------------------------------------------------------------------
* SEMAPHORES
*
* Note(s) : See PEND OBJ Note #1'.
------------------------------------------------------------------------------------------------------------------------
*/
struct os_sem { /* Semaphore */
/* ------------------ GENERIC MEMBERS ------------------ */
#if (OS_OBJ_TYPE_REQ > 0u)
OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_SEM */
#endif
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr; /* Pointer to Semaphore Name (NUL terminated ASCII) */
#endif
OS_PEND_LIST PendList; /* List of tasks waiting on semaphore */
#if (OS_CFG_DBG_EN > 0u)
OS_SEM *DbgPrevPtr;
OS_SEM *DbgNextPtr;
CPU_CHAR *DbgNamePtr;
#endif
/* ------------------ SPECIFIC MEMBERS ------------------ */
OS_SEM_CTR Ctr;
#if (OS_CFG_TS_EN > 0u)
CPU_TS TS;
#endif
#if (defined(OS_CFG_TRACE_EN) && (OS_CFG_TRACE_EN > 0u))
CPU_ADDR SemID; /* Unique ID for third-party debuggers and tracers. */
#endif
};
/*
------------------------------------------------------------------------------------------------------------------------
* TASK CONTROL BLOCK
------------------------------------------------------------------------------------------------------------------------
*/
struct os_tcb {
CPU_STK *StkPtr; /* Pointer to current top of stack */
void *ExtPtr; /* Pointer to user definable data for TCB extension */
CPU_STK *StkLimitPtr; /* Pointer used to set stack 'watermark' limit */
#if (OS_CFG_DBG_EN > 0u)
CPU_CHAR *NamePtr; /* Pointer to task name */
#endif
OS_TCB *NextPtr; /* Pointer to next TCB in the TCB list */
OS_TCB *PrevPtr; /* Pointer to previous TCB in the TCB list */
#if (OS_CFG_TICK_EN > 0u)
OS_TCB *TickNextPtr;
OS_TCB *TickPrevPtr;
#endif
#if ((OS_CFG_DBG_EN > 0u) || (OS_CFG_STAT_TASK_STK_CHK_EN > 0u) || (OS_CFG_TASK_STK_REDZONE_EN > 0u))
CPU_STK *StkBasePtr; /* Pointer to base address of stack */
#endif
#if defined(OS_CFG_TLS_TBL_SIZE) && (OS_CFG_TLS_TBL_SIZE > 0u)
OS_TLS TLS_Tbl[OS_CFG_TLS_TBL_SIZE];
#endif
#if (OS_CFG_DBG_EN > 0u)
OS_TASK_PTR TaskEntryAddr; /* Pointer to task entry point address */
void *TaskEntryArg; /* Argument passed to task when it was created */
#endif
OS_TCB *PendNextPtr; /* Pointer to next TCB in pend list. */
OS_TCB *PendPrevPtr; /* Pointer to previous TCB in pend list. */
OS_PEND_OBJ *PendObjPtr; /* Pointer to object pended on. */
OS_STATE PendOn; /* Indicates what task is pending on */
OS_STATUS PendStatus; /* Pend status */
OS_STATE TaskState; /* See OS_TASK_STATE_xxx */
OS_PRIO Prio; /* Task priority (0 == highest) */
#if (OS_CFG_MUTEX_EN > 0u)
OS_PRIO BasePrio; /* Base priority (Not inherited) */
OS_MUTEX *MutexGrpHeadPtr; /* Owned mutex group head pointer */
#endif
#if ((OS_CFG_DBG_EN > 0u) || (OS_CFG_STAT_TASK_STK_CHK_EN > 0u) || (OS_CFG_TASK_STK_REDZONE_EN > 0u))
CPU_STK_SIZE StkSize; /* Size of task stack (in number of stack elements) */
#endif
OS_OPT Opt; /* Task options as passed by OSTaskCreate() */
#if (OS_CFG_TS_EN > 0u)
CPU_TS TS; /* Timestamp */
#endif
#if (defined(OS_CFG_TRACE_EN) && (OS_CFG_TRACE_EN > 0u))
CPU_ADDR SemID; /* Unique ID for third-party debuggers and tracers. */
#endif
OS_SEM_CTR SemCtr; /* Task specific semaphore counter */
/* DELAY / TIMEOUT */
#if (OS_CFG_TICK_EN > 0u)
OS_TICK TickRemain; /* Number of ticks remaining */