📄 os_core.lst
字号:
27 */
28
\ In segment DATA_C, align 4, align-sorted
29 INT8U const OSMapTbl[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
\ OSMapTbl:
\ 00000000 010204081020 DC8 1, 2, 4, 8, 16, 32, 64, 128
\ 4080
30
31 /*
32 *********************************************************************************************************
33 * PRIORITY RESOLUTION TABLE
34 *
35 * Note: Index into table is bit pattern to resolve highest priority
36 * Indexed value corresponds to highest priority bit position (i.e. 0..7)
37 *********************************************************************************************************
38 */
39
\ In segment DATA_C, align 4, align-sorted
40 INT8U const OSUnMapTbl[256] = {
\ OSUnMapTbl:
\ 00000000 000001000200 DC8 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1
\ 010003000100
\ 020001000400
\ 0100020001
\ 00000017 000300010002 DC8 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0
\ 000100050001
\ 000200010003
\ 0001000200
\ 0000002E 010004000100 DC8 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2
\ 020001000300
\ 010002000100
\ 0600010002
\ 00000045 000100030001 DC8 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0
\ 000200010004
\ 000100020001
\ 0003000100
\ 0000005C 020001000500 DC8 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1
\ 010002000100
\ 030001000200
\ 0100040001
\ 00000073 000200010003 DC8 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0
\ 000100020001
\ 000700010002
\ 0001000300
\ 0000008A 010002000100 DC8 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5
\ 040001000200
\ 010003000100
\ 0200010005
\ 000000A1 000100020001 DC8 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0
\ 000300010002
\ 000100040001
\ 0002000100
\ 000000B8 030001000200 DC8 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1
\ 010006000100
\ 020001000300
\ 0100020001
\ 000000CF 000400010002 DC8 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0
\ 000100030001
\ 000200010005
\ 0001000200
\ 000000E6 010003000100 DC8 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2
\ 020001000400
\ 010002000100
\ 0300010002
\ 000000FD 000100 DC8 0, 1, 0
41 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x00 to 0x0F */
42 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x10 to 0x1F */
43 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x20 to 0x2F */
44 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x30 to 0x3F */
45 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x40 to 0x4F */
46 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x50 to 0x5F */
47 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x60 to 0x6F */
48 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x70 to 0x7F */
49 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x80 to 0x8F */
50 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x90 to 0x9F */
51 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xA0 to 0xAF */
52 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xB0 to 0xBF */
53 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xC0 to 0xCF */
54 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xD0 to 0xDF */
55 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xE0 to 0xEF */
56 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 /* 0xF0 to 0xFF */
57 };
58
59 /*$PAGE*/
60 /*
61 *********************************************************************************************************
62 * FUNCTION PROTOTYPES
63 *********************************************************************************************************
64 */
65 static void OS_InitEventList(void);
66 static void OS_InitMisc(void);
67 static void OS_InitRdyList(void);
68 static void OS_InitTaskIdle(void);
69 #if OS_TASK_STAT_EN > 0
70 static void OS_InitTaskStat(void);
71 #endif
72 static void OS_InitTCBList(void);
73
74 /*$PAGE*/
75 /*
76 *********************************************************************************************************
77 * GET THE NAME OF A SEMAPHORE, MUTEX, MAILBOX or QUEUE
78 *
79 * Description: This function is used to obtain the name assigned to a semaphore, mutex, mailbox or queue.
80 *
81 * Arguments : pevent is a pointer to the event group. 'pevent' can point either to a semaphore,
82 * a mutex, a mailbox or a queue. Where this function is concerned, the actual
83 * type is irrelevant.
84 *
85 * pname is a pointer to an ASCII string that will receive the name of the semaphore,
86 * mutex, mailbox or queue. The string must be able to hold at least
87 * OS_EVENT_NAME_SIZE characters.
88 *
89 * err is a pointer to an error code that can contain one of the following values:
90 *
91 * OS_NO_ERR if the name was copied to 'pname'
92 * OS_ERR_EVENT_TYPE if 'pevent' is not pointing to the proper event
93 * control block type.
94 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
95 * OS_ERR_PEVENT_NULL if you passed a NULL pointer for 'pevent'
96 *
97 * Returns : The length of the string or 0 if the 'pevent' is a NULL pointer.
98 *********************************************************************************************************
99 */
100
101 #if OS_EVENT_NAME_SIZE > 1
\ In segment CODE, align 4, keep-with-next
102 INT8U OSEventNameGet (OS_EVENT *pevent, char *pname, INT8U *err)
103 {
\ OSEventNameGet:
\ 00000000 F0B5 PUSH {R4-R7,LR}
\ 00000002 0600 MOVS R6,R0
\ 00000004 0F00 MOVS R7,R1
\ 00000006 1400 MOVS R4,R2
104 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
105 OS_CPU_SR cpu_sr;
106 #endif
107 INT8U len;
108
109
110 OS_ENTER_CRITICAL();
\ 00000008 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 0000000C 0500 MOVS R5,R0
111 #if OS_ARG_CHK_EN > 0
112 if (pevent == (OS_EVENT *)0) { /* Is 'pevent' a NULL pointer? */
\ 0000000E 002E CMP R6,#+0
\ 00000010 03D1 BNE ??OSEventNameGet_0
113 OS_EXIT_CRITICAL(); /* Yes */
\ 00000012 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
114 *err = OS_ERR_PEVENT_NULL;
\ 00000016 0420 MOVS R0,#+4
\ 00000018 1AE0 B.N ??OSEventNameGet_1
115 return (0);
116 }
117 if (pname == (char *)0) { /* Is 'pname' a NULL pointer? */
\ ??OSEventNameGet_0:
\ 0000001A 002F CMP R7,#+0
\ 0000001C 03D1 BNE ??OSEventNameGet_2
118 OS_EXIT_CRITICAL(); /* Yes */
\ 0000001E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
119 *err = OS_ERR_PNAME_NULL;
\ 00000022 0F20 MOVS R0,#+15
\ 00000024 14E0 B.N ??OSEventNameGet_1
120 return (0);
121 }
122 #endif
123 switch (pevent->OSEventType) {
\ ??OSEventNameGet_2:
\ 00000026 3078 LDRB R0,[R6, #+0]
\ 00000028 401E SUBS R0,R0,#+1
\ 0000002A 0328 CMP R0,#+3
\ 0000002C 0CD8 BHI ??OSEventNameGet_3
124 case OS_EVENT_TYPE_SEM:
125 case OS_EVENT_TYPE_MUTEX:
126 case OS_EVENT_TYPE_MBOX:
127 case OS_EVENT_TYPE_Q:
128 break;
129
130 default:
131 OS_EXIT_CRITICAL();
132 *err = OS_ERR_EVENT_TYPE;
133 return (0);
134 }
135 len = OS_StrCopy(pname, pevent->OSEventName); /* Copy name from OS_EVENT */
\ 0000002E 1036 ADDS R6,R6,#+16
\ 00000030 3100 MOVS R1,R6
\ 00000032 3800 MOVS R0,R7
\ 00000034 ........ BL OS_StrCopy
\ 00000038 0600 MOVS R6,R0
136 OS_EXIT_CRITICAL();
\ 0000003A 2800 MOVS R0,R5
\ 0000003C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
137 *err = OS_NO_ERR;
\ 00000040 0020 MOVS R0,#+0
\ 00000042 2070 STRB R0,[R4, #+0]
138 return (len);
\ 00000044 3000 MOVS R0,R6
\ 00000046 05E0 B ??OSEventNameGet_4
\ ??OSEventNameGet_3:
\ 00000048 2800 MOVS R0,R5
\ 0000004A ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
\ 0000004E 0120 MOVS R0,#+1
\ ??OSEventNameGet_1:
\ 00000050 2070 STRB R0,[R4, #+0]
\ 00000052 0020 MOVS R0,#+0
\ ??OSEventNameGet_4:
\ 00000054 F0BC POP {R4-R7}
\ 00000056 02BC POP {R1}
\ 00000058 0847 BX R1 ;; return
139 }
140 #endif
141
142 /*$PAGE*/
143 /*
144 *********************************************************************************************************
145 * ASSIGN A NAME TO A SEMAPHORE, MUTEX, MAILBOX or QUEUE
146 *
147 * Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
148 *
149 * Arguments : pevent is a pointer to the event group. 'pevent' can point either to a semaphore,
150 * a mutex, a mailbox or a queue. Where this function is concerned, it doesn't
151 * matter the actual type.
152 *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -