📄 os_mutex.lst
字号:
\ 000000DC 0000A0E3 MOV R0,#+0
\ 000000E0 000081E5 STR R0,[R1, #+0]
303 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 000000E4 0000A0E3 MOV R0,#+0
\ 000000E8 0000C4E5 STRB R0,[R4, #+0]
304 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 000000EC ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 000000F0 000090E5 LDR R0,[R0, #+0]
\ 000000F4 040084E5 STR R0,[R4, #+4]
305 pevent->OSEventCnt = 0;
\ 000000F8 0000A0E3 MOV R0,#+0
\ 000000FC B800C4E1 STRH R0,[R4, #+8]
306 OSEventFreeList = pevent;
\ 00000100 ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 00000104 004080E5 STR R4,[R0, #+0]
307 OS_EXIT_CRITICAL();
\ 00000108 0700B0E1 MOVS R0,R7
\ 0000010C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
308 *err = OS_ERR_NONE;
\ 00000110 0000A0E3 MOV R0,#+0
\ 00000114 0000C5E5 STRB R0,[R5, #+0]
309 pevent_return = (OS_EVENT *)0; /* Mutex has been deleted */
\ 00000118 0040A0E3 MOV R4,#+0
\ 0000011C 3B0000EA B ??OSMutexDel_11
310 } else {
311 OS_EXIT_CRITICAL();
\ ??OSMutexDel_10:
\ 00000120 0700B0E1 MOVS R0,R7
\ 00000124 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
312 *err = OS_ERR_TASK_WAITING;
\ 00000128 4900A0E3 MOV R0,#+73
\ 0000012C 0000C5E5 STRB R0,[R5, #+0]
313 pevent_return = pevent;
\ 00000130 360000EA 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:
\ 00000134 B800D4E1 LDRH R0,[R4, #+8]
\ 00000138 2024B0E1 LSRS R2,R0,#+8
319 prio = (INT8U)(pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8); /* Get owner's original prio */
\ 0000013C B810D4E1 LDRH R1,[R4, #+8]
320 ptcb = (OS_TCB *)pevent->OSEventPtr;
\ 00000140 040094E5 LDR R0,[R4, #+4]
321 if (ptcb != (OS_TCB *)0) { /* See if any task owns the mutex */
\ 00000144 000050E3 CMP R0,#+0
\ 00000148 0B00000A BEQ ??OSMutexDel_12
322 if (ptcb->OSTCBPrio == pip) { /* See if original prio was changed */
\ 0000014C 2E30D0E5 LDRB R3,[R0, #+46]
\ 00000150 FF2012E2 ANDS R2,R2,#0xFF ;; Zero extend
\ 00000154 020053E1 CMP R3,R2
\ 00000158 0700001A BNE ??OSMutexDel_12
323 OSMutex_RdyAtPrio(ptcb, prio); /* Yes, Restore the task's original prio */
\ 0000015C FF1011E2 ANDS R1,R1,#0xFF ;; Zero extend
\ 00000160 ........ BL OSMutex_RdyAtPrio
\ 00000164 040000EA B ??OSMutexDel_12
324 }
325 }
326 while (pevent->OSEventGrp != 0) { /* Ready ALL tasks waiting for mutex */
327 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MUTEX, OS_STAT_PEND_OK);
\ ??OSMutexDel_13:
\ 00000168 0030A0E3 MOV R3,#+0
\ 0000016C 1020A0E3 MOV R2,#+16
\ 00000170 0010A0E3 MOV R1,#+0
\ 00000174 0400B0E1 MOVS R0,R4
\ 00000178 ........ _BLF OS_EventTaskRdy,??OS_EventTaskRdy??rA
328 }
\ ??OSMutexDel_12:
\ 0000017C 0A00D4E5 LDRB R0,[R4, #+10]
\ 00000180 000050E3 CMP R0,#+0
\ 00000184 F7FFFF1A BNE ??OSMutexDel_13
329 #if OS_EVENT_NAME_SIZE > 1
330 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 00000188 3F00A0E3 MOV R0,#+63
\ 0000018C 0F00C4E5 STRB R0,[R4, #+15]
331 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 00000190 0000A0E3 MOV R0,#+0
\ 00000194 1000C4E5 STRB R0,[R4, #+16]
332 #endif
333 pip = (INT8U)(pevent->OSEventCnt >> 8);
\ 00000198 B800D4E1 LDRH R0,[R4, #+8]
\ 0000019C 2024B0E1 LSRS R2,R0,#+8
334 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
\ 000001A0 FF2012E2 ANDS R2,R2,#0xFF ;; Zero extend
\ 000001A4 0400A0E3 MOV R0,#+4
\ 000001A8 ........ LDR R1,??DataTable57 ;; OSTCBPrioTbl
\ 000001AC 901221E0 MLA R1,R0,R2,R1
\ 000001B0 0000A0E3 MOV R0,#+0
\ 000001B4 000081E5 STR R0,[R1, #+0]
335 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 000001B8 0000A0E3 MOV R0,#+0
\ 000001BC 0000C4E5 STRB R0,[R4, #+0]
336 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 000001C0 ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 000001C4 000090E5 LDR R0,[R0, #+0]
\ 000001C8 040084E5 STR R0,[R4, #+4]
337 pevent->OSEventCnt = 0;
\ 000001CC 0000A0E3 MOV R0,#+0
\ 000001D0 B800C4E1 STRH R0,[R4, #+8]
338 OSEventFreeList = pevent; /* Get next free event control block */
\ 000001D4 ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 000001D8 004080E5 STR R4,[R0, #+0]
339 OS_EXIT_CRITICAL();
\ 000001DC 0700B0E1 MOVS R0,R7
\ 000001E0 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
340 if (tasks_waiting == OS_TRUE) { /* Reschedule only if task(s) were waiting */
\ 000001E4 010058E3 CMP R8,#+1
\ 000001E8 0000001A BNE ??OSMutexDel_14
341 OS_Sched(); /* Find highest priority task ready to run */
\ 000001EC ........ _BLF OS_Sched,??OS_Sched??rA
342 }
343 *err = OS_ERR_NONE;
\ ??OSMutexDel_14:
\ 000001F0 0000A0E3 MOV R0,#+0
\ 000001F4 0000C5E5 STRB R0,[R5, #+0]
344 pevent_return = (OS_EVENT *)0; /* Mutex has been deleted */
\ 000001F8 0040A0E3 MOV R4,#+0
\ 000001FC 030000EA B ??OSMutexDel_11
345 break;
346
347 default:
348 OS_EXIT_CRITICAL();
\ ??OSMutexDel_9:
\ 00000200 0700B0E1 MOVS R0,R7
\ 00000204 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
349 *err = OS_ERR_INVALID_OPT;
\ 00000208 0700A0E3 MOV R0,#+7
\ 0000020C 0000C5E5 STRB R0,[R5, #+0]
350 pevent_return = pevent;
351 break;
352 }
353 return (pevent_return);
\ ??OSMutexDel_11:
\ 00000210 0400B0E1 MOVS R0,R4
\ ??OSMutexDel_1:
\ 00000214 F081BDE8 POP {R4-R8,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 F0412DE9 PUSH {R4-R8,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0150B0E1 MOVS R5,R1
\ 0000000C 0260B0E1 MOVS R6,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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -