📄 os_mutex.lst
字号:
225 *err = OS_ERR_PEVENT_NULL;
\ 00000016 0420 MOVS R0,#+4
\ 00000018 2870 STRB R0,[R5, #+0]
226 return ((OS_EVENT *)0);
\ 0000001A 0020 MOVS R0,#+0
\ 0000001C 5BE0 B ??OSMutexDel_3
227 }
228 #endif
229 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
\ ??OSMutexDel_2:
\ 0000001E 2078 LDRB R0,[R4, #+0]
\ 00000020 0428 CMP R0,#+4
\ 00000022 01D0 BEQ ??OSMutexDel_4
230 *err = OS_ERR_EVENT_TYPE;
\ 00000024 0120 MOVS R0,#+1
\ 00000026 54E0 B.N ??OSMutexDel_1
231 return (pevent);
232 }
233 OS_ENTER_CRITICAL();
\ ??OSMutexDel_4:
\ 00000028 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 0000002C 0600 MOVS R6,R0
234 if (pevent->OSEventGrp != 0x00) { /* See if any tasks waiting on mutex */
\ 0000002E 6078 LDRB R0,[R4, #+1]
\ 00000030 0028 CMP R0,#+0
\ 00000032 01D0 BEQ ??OSMutexDel_5
235 tasks_waiting = TRUE; /* Yes */
\ 00000034 0127 MOVS R7,#+1
\ 00000036 00E0 B ??OSMutexDel_6
236 } else {
237 tasks_waiting = FALSE; /* No */
\ ??OSMutexDel_5:
\ 00000038 0027 MOVS R7,#+0
238 }
239 switch (opt) {
\ ??OSMutexDel_6:
\ 0000003A 6846 MOV R0,SP
\ 0000003C 0078 LDRB R0,[R0, #+0]
\ 0000003E 0028 CMP R0,#+0
\ 00000040 02D0 BEQ ??OSMutexDel_7
\ 00000042 0128 CMP R0,#+1
\ 00000044 24D0 BEQ ??OSMutexDel_8
\ 00000046 40E0 B ??OSMutexDel_9
240 case OS_DEL_NO_PEND: /* Delete mutex only if no task waiting */
241 if (tasks_waiting == FALSE) {
\ ??OSMutexDel_7:
\ 00000048 002F CMP R7,#+0
\ 0000004A 17D1 BNE ??OSMutexDel_10
242 #if OS_EVENT_NAME_SIZE > 1
243 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 0000004C 3F20 MOVS R0,#+63
\ 0000004E 2074 STRB R0,[R4, #+16]
244 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 00000050 0020 MOVS R0,#+0
\ 00000052 6074 STRB R0,[R4, #+17]
245 #endif
246 pip = (INT8U)(pevent->OSEventCnt >> 8);
247 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
\ 00000054 6088 LDRH R0,[R4, #+2]
\ 00000056 0004 LSLS R0,R0,#+16
\ 00000058 000E LSRS R0,R0,#+24
\ 0000005A 8000 LSLS R0,R0,#+2
\ 0000005C .... LDR R1,??DataTable10 ;; OSTCBPrioTbl
\ 0000005E 0022 MOVS R2,#+0
\ 00000060 0A50 STR R2,[R1, R0]
248 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 00000062 2270 STRB R2,[R4, #+0]
249 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 00000064 .... LDR R0,??DataTable12 ;; OSEventFreeList
\ 00000066 0068 LDR R0,[R0, #+0]
\ 00000068 6060 STR R0,[R4, #+4]
250 pevent->OSEventCnt = 0;
\ 0000006A 6280 STRH R2,[R4, #+2]
251 OSEventFreeList = pevent;
\ 0000006C .... LDR R0,??DataTable12 ;; OSEventFreeList
\ 0000006E 0460 STR R4,[R0, #+0]
252 OS_EXIT_CRITICAL();
\ 00000070 3000 MOVS R0,R6
\ 00000072 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
253 *err = OS_NO_ERR;
\ ??OSMutexDel_11:
\ 00000076 0020 MOVS R0,#+0
\ 00000078 2870 STRB R0,[R5, #+0]
254 return ((OS_EVENT *)0); /* Mutex has been deleted */
\ 0000007A 2CE0 B ??OSMutexDel_3
255 } else {
256 OS_EXIT_CRITICAL();
\ ??OSMutexDel_10:
\ 0000007C 3000 MOVS R0,R6
\ 0000007E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
257 *err = OS_ERR_TASK_WAITING;
\ 00000082 0820 MOVS R0,#+8
\ 00000084 25E0 B.N ??OSMutexDel_1
258 return (pevent);
259 }
260
261 case OS_DEL_ALWAYS: /* Always delete the mutex */
262 while (pevent->OSEventGrp != 0x00) { /* Ready ALL tasks waiting for mutex */
263 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MUTEX);
\ ??OSMutexDel_12:
\ 00000086 1022 MOVS R2,#+16
\ 00000088 0021 MOVS R1,#+0
\ 0000008A 2000 MOVS R0,R4
\ 0000008C ........ _BLF OS_EventTaskRdy,??OS_EventTaskRdy??rT
264 }
\ ??OSMutexDel_8:
\ 00000090 6078 LDRB R0,[R4, #+1]
\ 00000092 0028 CMP R0,#+0
\ 00000094 F7D1 BNE ??OSMutexDel_12
265 #if OS_EVENT_NAME_SIZE > 1
266 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 00000096 3F20 MOVS R0,#+63
\ 00000098 2074 STRB R0,[R4, #+16]
267 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 0000009A 0020 MOVS R0,#+0
\ 0000009C 6074 STRB R0,[R4, #+17]
268 #endif
269 pip = (INT8U)(pevent->OSEventCnt >> 8);
270 OSTCBPrioTbl[pip] = (OS_TCB *)0; /* Free up the PIP */
\ 0000009E 6088 LDRH R0,[R4, #+2]
\ 000000A0 0004 LSLS R0,R0,#+16
\ 000000A2 000E LSRS R0,R0,#+24
\ 000000A4 8000 LSLS R0,R0,#+2
\ 000000A6 .... LDR R1,??DataTable10 ;; OSTCBPrioTbl
\ 000000A8 0022 MOVS R2,#+0
\ 000000AA 0A50 STR R2,[R1, R0]
271 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 000000AC 2270 STRB R2,[R4, #+0]
272 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 000000AE .... LDR R0,??DataTable12 ;; OSEventFreeList
\ 000000B0 0068 LDR R0,[R0, #+0]
\ 000000B2 6060 STR R0,[R4, #+4]
273 pevent->OSEventCnt = 0;
\ 000000B4 6280 STRH R2,[R4, #+2]
274 OSEventFreeList = pevent; /* Get next free event control block */
\ 000000B6 .... LDR R0,??DataTable12 ;; OSEventFreeList
\ 000000B8 0460 STR R4,[R0, #+0]
275 OS_EXIT_CRITICAL();
\ 000000BA 3000 MOVS R0,R6
\ 000000BC ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
276 if (tasks_waiting == TRUE) { /* Reschedule only if task(s) were waiting */
\ 000000C0 012F CMP R7,#+1
\ 000000C2 D8D1 BNE ??OSMutexDel_11
277 OS_Sched(); /* Find highest priority task ready to run */
\ 000000C4 ........ _BLF OS_Sched,??OS_Sched??rT
278 }
279 *err = OS_NO_ERR;
\ ??OSMutexDel_13:
\ 000000C8 D5E7 B.N ??OSMutexDel_11
280 return ((OS_EVENT *)0); /* Mutex has been deleted */
281
282 default:
283 OS_EXIT_CRITICAL();
\ ??OSMutexDel_9:
\ 000000CA 3000 MOVS R0,R6
\ 000000CC ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
284 *err = OS_ERR_INVALID_OPT;
\ 000000D0 0720 MOVS R0,#+7
\ ??OSMutexDel_1:
\ 000000D2 2870 STRB R0,[R5, #+0]
285 return (pevent);
\ 000000D4 2000 MOVS R0,R4
\ ??OSMutexDel_3:
\ 000000D6 01B0 ADD SP,SP,#+4
\ 000000D8 F0BC POP {R4-R7}
\ 000000DA 02BC POP {R1}
\ 000000DC 0847 BX R1 ;; return
286 }
287 }
288 #endif
289
290 /*$PAGE*/
291 /*
292 *********************************************************************************************************
293 * PEND ON MUTUAL EXCLUSION SEMAPHORE
294 *
295 * Description: This function waits for a mutual exclusion semaphore.
296 *
297 * Arguments : pevent is a pointer to the event control block associated with the desired
298 * mutex.
299 *
300 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
301 * wait for the resource up to the amount of time specified by this argument.
302 * If you specify 0, however, your task will wait forever at the specified
303 * mutex or, until the resource becomes available.
304 *
305 * err is a pointer to where an error message will be deposited. Possible error
306 * messages are:
307 * OS_NO_ERR The call was successful and your task owns the mutex
308 * OS_TIMEOUT The mutex was not available within the specified time.
309 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a mutex
310 * OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
311 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
312 * would lead to a suspension.
313 *
314 * Returns : none
315 *
316 * Note(s) : 1) The task that owns the Mutex MUST NOT pend on any other event while it owns the mutex.
317 * 2) You MUST NOT change the priority of the task that owns the mutex
318 *********************************************************************************************************
319 */
\ In segment CODE, align 4, keep-with-next
320 void OSMutexPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -