📄 os_mutex.lst
字号:
\ 000000CC 0400A0E3 MOV R0,#+4
\ 000000D0 0000C4E5 STRB R0,[R4, #+0]
200 return (pevent);
\ 000000D4 0600B0E1 MOVS R0,R6
\ 000000D8 150000EA B ??OSMutexCreate_1
201 }
202 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr; /* Adjust the free list */
\ ??OSMutexCreate_5:
\ 000000DC ........ LDR R1,??DataTable17 ;; OSEventFreeList
\ 000000E0 ........ LDR R2,??DataTable17 ;; OSEventFreeList
\ 000000E4 002092E5 LDR R2,[R2, #+0]
\ 000000E8 042092E5 LDR R2,[R2, #+4]
\ 000000EC 002081E5 STR R2,[R1, #+0]
203 OS_EXIT_CRITICAL();
\ 000000F0 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
204 pevent->OSEventType = OS_EVENT_TYPE_MUTEX;
\ 000000F4 0400A0E3 MOV R0,#+4
\ 000000F8 0000C6E5 STRB R0,[R6, #+0]
205 pevent->OSEventCnt = (INT16U)((INT16U)prio << 8) | OS_MUTEX_AVAILABLE; /* Resource is avail. */
\ 000000FC FF00A0E3 MOV R0,#+255
\ 00000100 050490E1 ORRS R0,R0,R5, LSL #+8
\ 00000104 B800C6E1 STRH R0,[R6, #+8]
206 pevent->OSEventPtr = (void *)0; /* No task owning the mutex */
\ 00000108 0000A0E3 MOV R0,#+0
\ 0000010C 040086E5 STR R0,[R6, #+4]
207 #if OS_EVENT_NAME_SIZE > 1
208 pevent->OSEventName[0] = '?';
\ 00000110 3F00A0E3 MOV R0,#+63
\ 00000114 0F00C6E5 STRB R0,[R6, #+15]
209 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 00000118 0000A0E3 MOV R0,#+0
\ 0000011C 1000C6E5 STRB R0,[R6, #+16]
210 #endif
211 OS_EventWaitListInit(pevent);
\ 00000120 0600B0E1 MOVS R0,R6
\ 00000124 ........ _BLF OS_EventWaitListInit,??OS_EventWaitListInit??rA
212 *err = OS_ERR_NONE;
\ 00000128 0000A0E3 MOV R0,#+0
\ 0000012C 0000C4E5 STRB R0,[R4, #+0]
213 return (pevent);
\ 00000130 0600B0E1 MOVS R0,R6
\ ??OSMutexCreate_1:
\ 00000134 7080BDE8 POP {R4-R6,PC} ;; return
214 }
215
216 /*$PAGE*/
217 /*
218 *********************************************************************************************************
219 * DELETE A MUTEX
220 *
221 * Description: This function deletes a mutual exclusion semaphore and readies all tasks pending on the it.
222 *
223 * Arguments : pevent is a pointer to the event control block associated with the desired mutex.
224 *
225 * opt determines delete options as follows:
226 * opt == OS_DEL_NO_PEND Delete mutex ONLY if no task pending
227 * opt == OS_DEL_ALWAYS Deletes the mutex even if tasks are waiting.
228 * In this case, all the tasks pending will be readied.
229 *
230 * err is a pointer to an error code that can contain one of the following values:
231 * OS_ERR_NONE The call was successful and the mutex was deleted
232 * OS_ERR_DEL_ISR If you attempted to delete the MUTEX from an ISR
233 * OS_ERR_INVALID_OPT An invalid option was specified
234 * OS_ERR_TASK_WAITING One or more tasks were waiting on the mutex
235 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a mutex
236 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
237 *
238 * Returns : pevent upon error
239 * (OS_EVENT *)0 if the mutex was successfully deleted.
240 *
241 * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
242 * the mutex MUST check the return code of OSMutexPend().
243 *
244 * 2) This call can potentially disable interrupts for a long time. The interrupt disable
245 * time is directly proportional to the number of tasks waiting on the mutex.
246 *
247 * 3) Because ALL tasks pending on the mutex will be readied, you MUST be careful because the
248 * resource(s) will no longer be guarded by the mutex.
249 *
250 * 4) IMPORTANT: In the 'OS_DEL_ALWAYS' case, we assume that the owner of the Mutex (if there
251 * is one) is ready-to-run and is thus NOT pending on another kernel object or
252 * has delayed itself. In other words, if a task owns the mutex being deleted,
253 * that task will be made ready-to-run at its original priority.
254 *********************************************************************************************************
255 */
256
257 #if OS_MUTEX_DEL_EN
\ In segment CODE, align 4, keep-with-next
258 OS_EVENT *OSMutexDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
259 {
\ OSMutexDel:
\ 00000000 F0412DE9 PUSH {R4-R8,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0160B0E1 MOVS R6,R1
\ 0000000C 0250B0E1 MOVS R5,R2
260 BOOLEAN tasks_waiting;
261 OS_EVENT *pevent_return;
262 INT8U pip; /* Priority inheritance priority */
263 INT8U prio;
264 OS_TCB *ptcb;
265 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
266 OS_CPU_SR cpu_sr = 0;
\ 00000010 0070A0E3 MOV R7,#+0
267 #endif
268
269
270
271 #if OS_ARG_CHK_EN > 0
272 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000014 000055E3 CMP R5,#+0
\ 00000018 0100001A BNE ??OSMutexDel_0
273 return (pevent);
\ 0000001C 0400B0E1 MOVS R0,R4
\ 00000020 7B0000EA B ??OSMutexDel_1
274 }
275 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ ??OSMutexDel_0:
\ 00000024 000054E3 CMP R4,#+0
\ 00000028 0300001A BNE ??OSMutexDel_2
276 *err = OS_ERR_PEVENT_NULL;
\ 0000002C 0400A0E3 MOV R0,#+4
\ 00000030 0000C5E5 STRB R0,[R5, #+0]
277 return (pevent);
\ 00000034 0400B0E1 MOVS R0,R4
\ 00000038 750000EA B ??OSMutexDel_1
278 }
279 #endif
280 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
\ ??OSMutexDel_2:
\ 0000003C 0000D4E5 LDRB R0,[R4, #+0]
\ 00000040 040050E3 CMP R0,#+4
\ 00000044 0300000A BEQ ??OSMutexDel_3
281 *err = OS_ERR_EVENT_TYPE;
\ 00000048 0100A0E3 MOV R0,#+1
\ 0000004C 0000C5E5 STRB R0,[R5, #+0]
282 return (pevent);
\ 00000050 0400B0E1 MOVS R0,R4
\ 00000054 6E0000EA B ??OSMutexDel_1
283 }
284 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSMutexDel_3:
\ 00000058 ........ LDR R0,??DataTable47 ;; OSIntNesting
\ 0000005C 0000D0E5 LDRB R0,[R0, #+0]
\ 00000060 010050E3 CMP R0,#+1
\ 00000064 0300003A BCC ??OSMutexDel_4
285 *err = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
\ 00000068 0F00A0E3 MOV R0,#+15
\ 0000006C 0000C5E5 STRB R0,[R5, #+0]
286 return (pevent);
\ 00000070 0400B0E1 MOVS R0,R4
\ 00000074 660000EA B ??OSMutexDel_1
287 }
288 OS_ENTER_CRITICAL();
\ ??OSMutexDel_4:
\ 00000078 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 0000007C 0070B0E1 MOVS R7,R0
289 if (pevent->OSEventGrp != 0) { /* See if any tasks waiting on mutex */
\ 00000080 0A00D4E5 LDRB R0,[R4, #+10]
\ 00000084 000050E3 CMP R0,#+0
\ 00000088 0100000A BEQ ??OSMutexDel_5
290 tasks_waiting = OS_TRUE; /* Yes */
\ 0000008C 0180A0E3 MOV R8,#+1
\ 00000090 000000EA B ??OSMutexDel_6
291 } else {
292 tasks_waiting = OS_FALSE; /* No */
\ ??OSMutexDel_5:
\ 00000094 0080A0E3 MOV R8,#+0
293 }
294 switch (opt) {
\ ??OSMutexDel_6:
\ 00000098 000056E3 CMP R6,#+0
\ 0000009C 0200000A BEQ ??OSMutexDel_7
\ 000000A0 010056E3 CMP R6,#+1
\ 000000A4 2200000A BEQ ??OSMutexDel_8
\ 000000A8 540000EA B ??OSMutexDel_9
295 case OS_DEL_NO_PEND: /* DELETE MUTEX ONLY IF NO TASK WAITING --- */
296 if (tasks_waiting == OS_FALSE) {
\ ??OSMutexDel_7:
\ 000000AC 000058E3 CMP R8,#+0
\ 000000B0 1A00001A BNE ??OSMutexDel_10
297 #if OS_EVENT_NAME_SIZE > 1
298 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 000000B4 3F00A0E3 MOV R0,#+63
\ 000000B8 0F00C4E5 STRB R0,[R4, #+15]
299 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 000000BC 0000A0E3 MOV R0,#+0
\ 000000C0 1000C4E5 STRB R0,[R4, #+16]
300 #endif
301 pip = (INT8U)(pevent->OSEventCnt >> 8);
\ 000000C4 B800D4E1 LDRH R0,[R4, #+8]
\ 000000C8 2024B0E1 LSRS R2,R0,#+8
302 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
\ 000000CC FF2012E2 ANDS R2,R2,#0xFF ;; Zero extend
\ 000000D0 0400A0E3 MOV R0,#+4
\ 000000D4 ........ LDR R1,??DataTable57 ;; OSTCBPrioTbl
\ 000000D8 901221E0 MLA R1,R0,R2,R1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -