📄 os_mutex.lst
字号:
313 pevent_return = pevent;
\ 00000098 2000 MOVS R0,R4
\ 0000009A 35E0 B.N ??OSMutexDel_2
314 }
315 break;
316
317 case OS_DEL_ALWAYS: /* ALWAYS DELETE THE MUTEX ---------------- */
318 pip = (INT8U)(pevent->OSEventCnt >> 8); /* Get PIP of mutex */
319 prio = (INT8U)(pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8); /* Get owner's original prio */
\ ??OSMutexDel_9:
\ 0000009C 2189 LDRH R1,[R4, #+8]
\ 0000009E C9B2 UXTB R1,R1
320 ptcb = (OS_TCB *)pevent->OSEventPtr;
\ 000000A0 6068 LDR R0,[R4, #+4]
321 if (ptcb != (OS_TCB *)0) { /* See if any task owns the mutex */
\ 000000A2 0028 CMP R0,#+0
\ 000000A4 0ED0 BEQ.N ??OSMutexDel_13
322 if (ptcb->OSTCBPrio == pip) { /* See if original prio was changed */
\ 000000A6 90F82E20 LDRB R2,[R0, #+46]
\ 000000AA 2389 LDRH R3,[R4, #+8]
\ 000000AC 1B0A LSRS R3,R3,#+8
\ 000000AE 9A42 CMP R2,R3
\ 000000B0 08D1 BNE.N ??OSMutexDel_13
323 OSMutex_RdyAtPrio(ptcb, prio); /* Yes, Restore the task's original prio */
\ 000000B2 ........ BL OSMutex_RdyAtPrio
\ 000000B6 05E0 B.N ??OSMutexDel_13
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_14:
\ 000000B8 4B46 MOV R3,R9
\ 000000BA 1022 MOVS R2,#+16
\ 000000BC 1946 MOV R1,R3
\ 000000BE 2000 MOVS R0,R4
\ 000000C0 ........ _BLF OS_EventTaskRdy,??OS_EventTaskRdy??rT
328 }
\ ??OSMutexDel_13:
\ 000000C4 A07A LDRB R0,[R4, #+10]
\ 000000C6 0028 CMP R0,#+0
\ 000000C8 F6D1 BNE.N ??OSMutexDel_14
329 #if OS_EVENT_NAME_SIZE > 1
330 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 000000CA 84F80FB0 STRB R11,[R4, #+15]
331 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 000000CE 2074 STRB R0,[R4, #+16]
332 #endif
333 pip = (INT8U)(pevent->OSEventCnt >> 8);
334 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
\ 000000D0 2089 LDRH R0,[R4, #+8]
\ 000000D2 000A LSRS R0,R0,#+8
\ 000000D4 47F82090 STR R9,[R7, R0, LSL #+2]
335 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 000000D8 4846 MOV R0,R9
\ 000000DA 2070 STRB R0,[R4, #+0]
336 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 000000DC 3068 LDR R0,[R6, #+0]
\ 000000DE 6060 STR R0,[R4, #+4]
337 pevent->OSEventCnt = 0;
\ 000000E0 4846 MOV R0,R9
\ 000000E2 2081 STRH R0,[R4, #+8]
338 OSEventFreeList = pevent; /* Get next free event control block */
\ 000000E4 3460 STR R4,[R6, #+0]
339 OS_EXIT_CRITICAL();
\ 000000E6 4046 MOV R0,R8
\ 000000E8 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
340 if (tasks_waiting == OS_TRUE) { /* Reschedule only if task(s) were waiting */
\ 000000EC 5046 MOV R0,R10
\ 000000EE 0128 CMP R0,#+1
\ 000000F0 01D1 BNE.N ??OSMutexDel_12
341 OS_Sched(); /* Find highest priority task ready to run */
\ 000000F2 ........ _BLF OS_Sched,??OS_Sched??rT
342 }
343 *perr = OS_ERR_NONE;
\ ??OSMutexDel_12:
\ 000000F6 4846 MOV R0,R9
\ 000000F8 2870 STRB R0,[R5, #+0]
344 pevent_return = (OS_EVENT *)0; /* Mutex has been deleted */
\ 000000FA 05E0 B.N ??OSMutexDel_2
345 break;
346
347 default:
348 OS_EXIT_CRITICAL();
\ ??OSMutexDel_10:
\ 000000FC 4046 MOV R0,R8
\ 000000FE ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
349 *perr = OS_ERR_INVALID_OPT;
\ 00000102 0720 MOVS R0,#+7
\ 00000104 2870 STRB R0,[R5, #+0]
350 pevent_return = pevent;
\ 00000106 2000 MOVS R0,R4
351 break;
352 }
353 return (pevent_return);
\ ??OSMutexDel_2:
\ 00000108 BDE8F28F POP {R1,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 * perr 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 *perr)
398 {
\ OSMutexPend:
\ 00000000 2DE9F14F PUSH {R0,R4-R11,LR}
\ 00000004 ADF80010 STRH R1,[SP, #+0]
\ 00000008 0400 MOVS R4,R0
\ 0000000A 1500 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;
408 #endif
409
410
411
412 #if OS_ARG_CHK_EN > 0
413 if (perr == (INT8U *)0) { /* Validate 'perr' */
\ 0000000C 03D0 BEQ.N ??OSMutexPend_0
414 return;
415 }
416 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 0000000E 002C CMP R4,#+0
\ 00000010 03D1 BNE.N ??OSMutexPend_1
417 *perr = OS_ERR_PEVENT_NULL;
\ 00000012 0420 MOVS R0,#+4
\ 00000014 2870 STRB R0,[R5, #+0]
418 return;
\ ??OSMutexPend_0:
\ 00000016 BDE8F18F POP {R0,R4-R11,PC} ;; return
419 }
\ ??OSMutexPend_1:
\ 0000001A 2078 LDRB R0,[R4, #+0]
\ 0000001C 0428 CMP R0,#+4
\ 0000001E 02D0 BEQ.N ??OSMutexPend_2
420 #endif
421 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
422 *perr = OS_ERR_EVENT_TYPE;
\ 00000020 0120 MOVS R0,#+1
\ 00000022 2870 STRB R0,[R5, #+0]
423 return;
\ 00000024 F7E7 B.N ??OSMutexPend_0
424 }
425 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSMutexPend_2:
\ 00000026 .... LDR.N R0,??DataTable17 ;; OSIntNesting
\ 00000028 0078 LDRB R0,[R0, #+0]
\ 0000002A 0028 CMP R0,#+0
\ 0000002C 02D0 BEQ.N ??OSMutexPend_3
426 *perr = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 0000002E 0220 MOVS R0,#+2
\ 00000030 2870 STRB R0,[R5, #+0]
427 return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -