📄 os_mutex.lst
字号:
\ ??OSMutexAccept_4:
\ 00000030 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
111 pip = (INT8U)(pevent->OSEventCnt >> 8); /* Get PIP from mutex */
\ 00000034 2189 LDRH R1,[R4, #+8]
\ 00000036 090A LSRS R1,R1,#+8
112 if ((pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {
\ 00000038 0026 MOVS R6,#+0
\ 0000003A 2289 LDRH R2,[R4, #+8]
\ 0000003C D2B2 UXTB R2,R2
\ 0000003E FF2A CMP R2,#+255
\ 00000040 1BD1 BNE.N ??OSMutexAccept_5
113 pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8; /* Mask off LSByte (Acquire Mutex) */
\ 00000042 2289 LDRH R2,[R4, #+8]
\ 00000044 12F47F42 ANDS R2,R2,#0xFF00
\ 00000048 2281 STRH R2,[R4, #+8]
114 pevent->OSEventCnt |= OSTCBCur->OSTCBPrio; /* Save current task priority in LSByte */
\ 0000004A .... LDR.N R2,??DataTable1 ;; OSTCBCur
\ 0000004C 2389 LDRH R3,[R4, #+8]
\ 0000004E 1768 LDR R7,[R2, #+0]
\ 00000050 2E37 ADDS R7,R7,#+46
\ 00000052 3F78 LDRB R7,[R7, #+0]
\ 00000054 1F43 ORRS R7,R7,R3
\ 00000056 2781 STRH R7,[R4, #+8]
115 pevent->OSEventPtr = (void *)OSTCBCur; /* Link TCB of task owning Mutex */
\ 00000058 1368 LDR R3,[R2, #+0]
\ 0000005A 6360 STR R3,[R4, #+4]
116 if (OSTCBCur->OSTCBPrio <= pip) { /* PIP 'must' have a SMALLER prio ... */
\ 0000005C 1268 LDR R2,[R2, #+0]
\ 0000005E 2E32 ADDS R2,R2,#+46
\ 00000060 1278 LDRB R2,[R2, #+0]
\ 00000062 9142 CMP R1,R2
\ 00000064 04D3 BCC.N ??OSMutexAccept_6
117 OS_EXIT_CRITICAL(); /* ... than current task! */
\ 00000066 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
118 *perr = OS_ERR_PIP_LOWER;
\ 0000006A 7820 MOVS R0,#+120
\ 0000006C 2870 STRB R0,[R5, #+0]
\ 0000006E 02E0 B.N ??OSMutexAccept_7
119 } else {
120 OS_EXIT_CRITICAL();
\ ??OSMutexAccept_6:
\ 00000070 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
121 *perr = OS_ERR_NONE;
\ 00000074 2E70 STRB R6,[R5, #+0]
122 }
123 return (OS_TRUE);
\ ??OSMutexAccept_7:
\ 00000076 0120 MOVS R0,#+1
\ 00000078 F0BD POP {R4-R7,PC}
124 }
125 OS_EXIT_CRITICAL();
\ ??OSMutexAccept_5:
\ 0000007A ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
126 *perr = OS_ERR_NONE;
\ 0000007E 2E70 STRB R6,[R5, #+0]
\ 00000080 C2E7 B.N ??OSMutexAccept_1
127 return (OS_FALSE);
128 }
129 #endif
130
131 /*$PAGE*/
132 /*
133 *********************************************************************************************************
134 * CREATE A MUTUAL EXCLUSION SEMAPHORE
135 *
136 * Description: This function creates a mutual exclusion semaphore.
137 *
138 * Arguments : prio is the priority to use when accessing the mutual exclusion semaphore. In
139 * other words, when the semaphore is acquired and a higher priority task
140 * attempts to obtain the semaphore then the priority of the task owning the
141 * semaphore is raised to this priority. It is assumed that you will specify
142 * a priority that is LOWER in value than ANY of the tasks competing for the
143 * mutex.
144 *
145 * perr is a pointer to an error code which will be returned to your application:
146 * OS_ERR_NONE if the call was successful.
147 * OS_ERR_CREATE_ISR if you attempted to create a MUTEX from an ISR
148 * OS_ERR_PRIO_EXIST if a task at the priority inheritance priority
149 * already exist.
150 * OS_ERR_PEVENT_NULL No more event control blocks available.
151 * OS_ERR_PRIO_INVALID if the priority you specify is higher that the
152 * maximum allowed (i.e. > OS_LOWEST_PRIO)
153 *
154 * Returns : != (void *)0 is a pointer to the event control clock (OS_EVENT) associated with the
155 * created mutex.
156 * == (void *)0 if an error is detected.
157 *
158 * Note(s) : 1) The LEAST significant 8 bits of '.OSEventCnt' are used to hold the priority number
159 * of the task owning the mutex or 0xFF if no task owns the mutex.
160 *
161 * 2) The MOST significant 8 bits of '.OSEventCnt' are used to hold the priority number
162 * to use to reduce priority inversion.
163 *********************************************************************************************************
164 */
165
\ In segment CODE, align 4, keep-with-next
166 OS_EVENT *OSMutexCreate (INT8U prio, INT8U *perr)
167 {
\ OSMutexCreate:
\ 00000000 2DE9F041 PUSH {R4-R8,LR}
\ 00000004 0400 MOVS R4,R0
\ 00000006 0D00 MOVS R5,R1
168 OS_EVENT *pevent;
169 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
170 OS_CPU_SR cpu_sr = 0;
171 #endif
172
173
174
175 #if OS_ARG_CHK_EN > 0
176 if (perr == (INT8U *)0) { /* Validate 'perr' */
\ 00000008 01D1 BNE.N ??OSMutexCreate_0
177 return ((OS_EVENT *)0);
\ 0000000A 0020 MOVS R0,#+0
\ 0000000C 40E0 B.N ??OSMutexCreate_1
178 }
179 if (prio >= OS_LOWEST_PRIO) { /* Validate PIP */
\ ??OSMutexCreate_0:
\ 0000000E 1F2C CMP R4,#+31
\ 00000010 03D3 BCC.N ??OSMutexCreate_2
180 *perr = OS_ERR_PRIO_INVALID;
\ 00000012 2A20 MOVS R0,#+42
\ 00000014 2870 STRB R0,[R5, #+0]
181 return ((OS_EVENT *)0);
\ 00000016 0020 MOVS R0,#+0
\ 00000018 3AE0 B.N ??OSMutexCreate_1
182 }
183 #endif
184 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSMutexCreate_2:
\ 0000001A .... LDR.N R0,??DataTable5 ;; OSIntNesting
\ 0000001C 0078 LDRB R0,[R0, #+0]
\ 0000001E 0028 CMP R0,#+0
\ 00000020 03D0 BEQ.N ??OSMutexCreate_3
185 *perr = OS_ERR_CREATE_ISR; /* ... can't CREATE mutex from an ISR */
\ 00000022 1020 MOVS R0,#+16
\ 00000024 2870 STRB R0,[R5, #+0]
186 return ((OS_EVENT *)0);
\ 00000026 0020 MOVS R0,#+0
\ 00000028 32E0 B.N ??OSMutexCreate_1
187 }
188 OS_ENTER_CRITICAL();
\ ??OSMutexCreate_3:
\ 0000002A ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 0000002E .... LDR.N R1,??DataTable7 ;; OSTCBPrioTbl
\ 00000030 11EB8401 ADDS R1,R1,R4, LSL #+2
\ 00000034 0A68 LDR R2,[R1, #+0]
\ 00000036 002A CMP R2,#+0
\ 00000038 05D0 BEQ.N ??OSMutexCreate_4
189 if (OSTCBPrioTbl[prio] != (OS_TCB *)0) { /* Mutex priority must not already exist */
190 OS_EXIT_CRITICAL(); /* Task already exist at priority ... */
\ 0000003A ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
191 *perr = OS_ERR_PRIO_EXIST; /* ... inheritance priority */
\ 0000003E 2820 MOVS R0,#+40
\ 00000040 2870 STRB R0,[R5, #+0]
192 return ((OS_EVENT *)0);
\ 00000042 0020 MOVS R0,#+0
\ 00000044 24E0 B.N ??OSMutexCreate_1
193 }
194 OSTCBPrioTbl[prio] = OS_TCB_RESERVED; /* Reserve the table entry */
\ ??OSMutexCreate_4:
\ 00000046 0122 MOVS R2,#+1
\ 00000048 0A60 STR R2,[R1, #+0]
195 pevent = OSEventFreeList; /* Get next free event control block */
\ 0000004A .... LDR.N R2,??DataTable6 ;; OSEventFreeList
\ 0000004C 1368 LDR R3,[R2, #+0]
\ 0000004E 1E00 MOVS R6,R3
196 if (pevent == (OS_EVENT *)0) { /* See if an ECB was available */
\ 00000050 0427 MOVS R7,#+4
\ 00000052 B846 MOV R8,R7
\ 00000054 0027 MOVS R7,#+0
\ 00000056 002E CMP R6,#+0
\ 00000058 06D1 BNE.N ??OSMutexCreate_5
197 OSTCBPrioTbl[prio] = (OS_TCB *)0; /* No, Release the table entry */
\ 0000005A 0F60 STR R7,[R1, #+0]
198 OS_EXIT_CRITICAL();
\ 0000005C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
199 *perr = OS_ERR_PEVENT_NULL; /* No more event control blocks */
\ 00000060 4046 MOV R0,R8
\ 00000062 2870 STRB R0,[R5, #+0]
200 return (pevent);
\ 00000064 3846 MOV R0,R7
\ 00000066 13E0 B.N ??OSMutexCreate_1
201 }
202 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr; /* Adjust the free list */
\ ??OSMutexCreate_5:
\ 00000068 5968 LDR R1,[R3, #+4]
\ 0000006A 1160 STR R1,[R2, #+0]
203 OS_EXIT_CRITICAL();
\ 0000006C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
204 pevent->OSEventType = OS_EVENT_TYPE_MUTEX;
\ 00000070 4046 MOV R0,R8
\ 00000072 3070 STRB R0,[R6, #+0]
205 pevent->OSEventCnt = (INT16U)((INT16U)prio << 8) | OS_MUTEX_AVAILABLE; /* Resource is avail. */
\ 00000074 FF20 MOVS R0,#+255
\ 00000076 50EA0420 ORRS R0,R0,R4, LSL #+8
\ 0000007A 3081 STRH R0,[R6, #+8]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -