📄 os_mutex.lst
字号:
\ 00000118 004080E5 STR R4,[R0, #+0]
307 OS_EXIT_CRITICAL();
\ 0000011C 0B00B0E1 MOVS R0,R11
\ 00000120 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
308 *err = OS_ERR_NONE;
\ 00000124 0000A0E3 MOV R0,#+0
\ 00000128 0000C5E5 STRB R0,[R5, #+0]
309 pevent_return = (OS_EVENT *)0; /* Mutex has been deleted */
\ 0000012C 0000A0E3 MOV R0,#+0
\ 00000130 0070B0E1 MOVS R7,R0
\ 00000134 450000EA B ??OSMutexDel_11
310 } else {
311 OS_EXIT_CRITICAL();
\ ??OSMutexDel_10:
\ 00000138 0B00B0E1 MOVS R0,R11
\ 0000013C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
312 *err = OS_ERR_TASK_WAITING;
\ 00000140 4900A0E3 MOV R0,#+73
\ 00000144 0000C5E5 STRB R0,[R5, #+0]
313 pevent_return = pevent;
\ 00000148 0470B0E1 MOVS R7,R4
\ 0000014C 3F0000EA B ??OSMutexDel_11
314 }
315 break;
316
317 case OS_DEL_ALWAYS: /* ALWAYS DELETE THE MUTEX ---------------- */
318 pip = (INT8U)(pevent->OSEventCnt >> 8); /* Get PIP of mutex */
\ ??OSMutexDel_8:
\ 00000150 B800D4E1 LDRH R0,[R4, #+8]
\ 00000154 2004B0E1 LSRS R0,R0,#+8
\ 00000158 0080B0E1 MOVS R8,R0
319 prio = (INT8U)(pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8); /* Get owner's original prio */
\ 0000015C B800D4E1 LDRH R0,[R4, #+8]
\ 00000160 0090B0E1 MOVS R9,R0
320 ptcb = (OS_TCB *)pevent->OSEventPtr;
\ 00000164 040094E5 LDR R0,[R4, #+4]
\ 00000168 00A0B0E1 MOVS R10,R0
321 if (ptcb != (OS_TCB *)0) { /* See if any task owns the mutex */
\ 0000016C 00005AE3 CMP R10,#+0
\ 00000170 0700000A BEQ ??OSMutexDel_12
322 if (ptcb->OSTCBPrio == pip) { /* See if original prio was changed */
\ 00000174 2E00DAE5 LDRB R0,[R10, #+46]
\ 00000178 FF8018E2 ANDS R8,R8,#0xFF ;; Zero extend
\ 0000017C 080050E1 CMP R0,R8
\ 00000180 0300001A BNE ??OSMutexDel_12
323 OSMutex_RdyAtPrio(ptcb, prio); /* Yes, Restore the task's original prio */
\ 00000184 0910B0E1 MOVS R1,R9
\ 00000188 FF1011E2 ANDS R1,R1,#0xFF ;; Zero extend
\ 0000018C 0A00B0E1 MOVS R0,R10
\ 00000190 ........ BL OSMutex_RdyAtPrio
324 }
325 }
326 while (pevent->OSEventGrp != 0) { /* Ready ALL tasks waiting for mutex */
\ ??OSMutexDel_12:
\ 00000194 0A00D4E5 LDRB R0,[R4, #+10]
\ 00000198 000050E3 CMP R0,#+0
\ 0000019C 0500000A BEQ ??OSMutexDel_13
327 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MUTEX, OS_STAT_PEND_OK);
\ 000001A0 0030A0E3 MOV R3,#+0
\ 000001A4 1020A0E3 MOV R2,#+16
\ 000001A8 0010A0E3 MOV R1,#+0
\ 000001AC 0400B0E1 MOVS R0,R4
\ 000001B0 ........ _BLF OS_EventTaskRdy,??OS_EventTaskRdy??rA
\ 000001B4 F6FFFFEA B ??OSMutexDel_12
328 }
329 #if OS_EVENT_NAME_SIZE > 1
330 pevent->OSEventName[0] = '?'; /* Unknown name */
\ ??OSMutexDel_13:
\ 000001B8 3F00A0E3 MOV R0,#+63
\ 000001BC 0F00C4E5 STRB R0,[R4, #+15]
331 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 000001C0 0000A0E3 MOV R0,#+0
\ 000001C4 1000C4E5 STRB R0,[R4, #+16]
332 #endif
333 pip = (INT8U)(pevent->OSEventCnt >> 8);
\ 000001C8 B800D4E1 LDRH R0,[R4, #+8]
\ 000001CC 2004B0E1 LSRS R0,R0,#+8
\ 000001D0 0080B0E1 MOVS R8,R0
334 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
\ 000001D4 0800B0E1 MOVS R0,R8
\ 000001D8 FF0010E2 ANDS R0,R0,#0xFF ;; Zero extend
\ 000001DC 0410A0E3 MOV R1,#+4
\ 000001E0 ........ LDR R2,??DataTable57 ;; OSTCBPrioTbl
\ 000001E4 912020E0 MLA R0,R1,R0,R2
\ 000001E8 0010A0E3 MOV R1,#+0
\ 000001EC 001080E5 STR R1,[R0, #+0]
335 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 000001F0 0000A0E3 MOV R0,#+0
\ 000001F4 0000C4E5 STRB R0,[R4, #+0]
336 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 000001F8 ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 000001FC 000090E5 LDR R0,[R0, #+0]
\ 00000200 040084E5 STR R0,[R4, #+4]
337 pevent->OSEventCnt = 0;
\ 00000204 0000A0E3 MOV R0,#+0
\ 00000208 B800C4E1 STRH R0,[R4, #+8]
338 OSEventFreeList = pevent; /* Get next free event control block */
\ 0000020C ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 00000210 004080E5 STR R4,[R0, #+0]
339 OS_EXIT_CRITICAL();
\ 00000214 0B00B0E1 MOVS R0,R11
\ 00000218 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
340 if (tasks_waiting == OS_TRUE) { /* Reschedule only if task(s) were waiting */
\ 0000021C 010056E3 CMP R6,#+1
\ 00000220 0000001A BNE ??OSMutexDel_14
341 OS_Sched(); /* Find highest priority task ready to run */
\ 00000224 ........ _BLF OS_Sched,??OS_Sched??rA
342 }
343 *err = OS_ERR_NONE;
\ ??OSMutexDel_14:
\ 00000228 0000A0E3 MOV R0,#+0
\ 0000022C 0000C5E5 STRB R0,[R5, #+0]
344 pevent_return = (OS_EVENT *)0; /* Mutex has been deleted */
\ 00000230 0000A0E3 MOV R0,#+0
\ 00000234 0070B0E1 MOVS R7,R0
\ 00000238 040000EA B ??OSMutexDel_11
345 break;
346
347 default:
348 OS_EXIT_CRITICAL();
\ ??OSMutexDel_9:
\ 0000023C 0B00B0E1 MOVS R0,R11
\ 00000240 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
349 *err = OS_ERR_INVALID_OPT;
\ 00000244 0700A0E3 MOV R0,#+7
\ 00000248 0000C5E5 STRB R0,[R5, #+0]
350 pevent_return = pevent;
\ 0000024C 0470B0E1 MOVS R7,R4
351 break;
352 }
353 return (pevent_return);
\ ??OSMutexDel_11:
\ 00000250 0700B0E1 MOVS R0,R7
\ ??OSMutexDel_1:
\ 00000254 04D08DE2 ADD SP,SP,#+4 ;; stack cleaning
\ 00000258 F08FBDE8 POP {R4-R11,PC} ;; return
354 }
355 #endif
356
357 /*$PAGE*/
358 /*
359 *********************************************************************************************************
360 * PEND ON MUTUAL EXCLUSION SEMAPHORE
361 *
362 * Description: This function waits for a mutual exclusion semaphore.
363 *
364 * Arguments : pevent is a pointer to the event control block associated with the desired
365 * mutex.
366 *
367 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
368 * wait for the resource up to the amount of time specified by this argument.
369 * If you specify 0, however, your task will wait forever at the specified
370 * mutex or, until the resource becomes available.
371 *
372 * err is a pointer to where an error message will be deposited. Possible error
373 * messages are:
374 * OS_ERR_NONE The call was successful and your task owns the mutex
375 * OS_ERR_TIMEOUT The mutex was not available within the specified 'timeout'.
376 * OS_ERR_PEND_ABORT The wait on the mutex was aborted.
377 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a mutex
378 * OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
379 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
380 * would lead to a suspension.
381 * OS_ERR_PIP_LOWER If the priority of the task that owns the Mutex is
382 * HIGHER (i.e. a lower number) than the PIP. This error
383 * indicates that you did not set the PIP higher (lower
384 * number) than ALL the tasks that compete for the Mutex.
385 * Unfortunately, this is something that could not be
386 * detected when the Mutex is created because we don't know
387 * what tasks will be using the Mutex.
388 * OS_ERR_PEND_LOCKED If you called this function when the scheduler is locked
389 *
390 * Returns : none
391 *
392 * Note(s) : 1) The task that owns the Mutex MUST NOT pend on any other event while it owns the mutex.
393 *
394 * 2) You MUST NOT change the priority of the task that owns the mutex
395 *********************************************************************************************************
396 */
\ In segment CODE, align 4, keep-with-next
397 void OSMutexPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
398 {
\ OSMutexPend:
\ 00000000 F24F2DE9 PUSH {R1,R4-R11,LR}
\ 00000004 04D04DE2 SUB SP,SP,#+4
\ 00000008 0040B0E1 MOVS R4,R0
\ 0000000C 0250B0E1 MOVS R5,R2
399 INT8U pip; /* Priority Inheritance Priority (PIP) */
400 INT8U mprio; /* Mutex owner priority */
401 BOOLEAN rdy; /* Flag indicating task was ready */
402 OS_TCB *ptcb;
403 OS_EVENT *pevent2;
404 INT8U y;
405 INT8U pend_stat;
406 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
407 OS_CPU_SR cpu_sr = 0;
\ 00000010 0000A0E3 MOV R0,#+0
\ 00000014 00B0B0E1 MOVS R11,R0
408 #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -