📄 os_sem.lst
字号:
231 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
\ 0000009E 0023 MOVS R3,#+0
\ 000000A0 0122 MOVS R2,#+1
\ 000000A2 0021 MOVS R1,#+0
\ 000000A4 4846 MOV R0,R9
\ 000000A6 ........ BL OS_EventTaskRdy
\ 000000AA F4E7 B.N ??OSSemDel_6
232 }
233 #if OS_EVENT_NAME_EN > 0u
234 pevent->OSEventName = (INT8U *)(void *)"?";
\ ??OSSemDel_11:
\ 000000AC .... ADR.N R0,??DataTable3 ;; "\?"
\ 000000AE C9F81400 STR R0,[R9, #+20]
235 #endif
236 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 000000B2 0020 MOVS R0,#+0
\ 000000B4 89F80000 STRB R0,[R9, #+0]
237 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 000000B8 .... LDR.N R0,??DataTable3_2
\ 000000BA 0068 LDR R0,[R0, #+0]
\ 000000BC C9F80400 STR R0,[R9, #+4]
238 pevent->OSEventCnt = 0u;
\ 000000C0 0020 MOVS R0,#+0
\ 000000C2 A9F80800 STRH R0,[R9, #+8]
239 OSEventFreeList = pevent; /* Get next free event control block */
\ 000000C6 .... LDR.N R0,??DataTable3_2
\ 000000C8 C0F80090 STR R9,[R0, #+0]
240 OS_EXIT_CRITICAL();
\ 000000CC 4046 MOV R0,R8
\ 000000CE ........ BL OS_CPU_SR_Restore
241 if (tasks_waiting == OS_TRUE) { /* Reschedule only if task(s) were waiting */
\ 000000D2 F6B2 UXTB R6,R6 ;; ZeroExt R6,R6,#+24,#+24
\ 000000D4 012E CMP R6,#+1
\ 000000D6 01D1 BNE.N ??OSSemDel_12
242 OS_Sched(); /* Find highest priority task ready to run */
\ 000000D8 ........ BL OS_Sched
243 }
244 *perr = OS_ERR_NONE;
\ ??OSSemDel_12:
\ 000000DC 0020 MOVS R0,#+0
\ 000000DE 2870 STRB R0,[R5, #+0]
245 pevent_return = (OS_EVENT *)0; /* Semaphore has been deleted */
\ 000000E0 0020 MOVS R0,#+0
\ 000000E2 0700 MOVS R7,R0
246 break;
\ 000000E4 05E0 B.N ??OSSemDel_10
247
248 default:
249 OS_EXIT_CRITICAL();
\ ??OSSemDel_7:
\ 000000E6 4046 MOV R0,R8
\ 000000E8 ........ BL OS_CPU_SR_Restore
250 *perr = OS_ERR_INVALID_OPT;
\ 000000EC 0720 MOVS R0,#+7
\ 000000EE 2870 STRB R0,[R5, #+0]
251 pevent_return = pevent;
\ 000000F0 4F46 MOV R7,R9
252 break;
253 }
254 return (pevent_return);
\ ??OSSemDel_10:
\ 000000F2 3800 MOVS R0,R7
\ ??OSSemDel_1:
\ 000000F4 BDE8F283 POP {R1,R4-R9,PC} ;; return
255 }
256 #endif
257
258 /*$PAGE*/
259 /*
260 *********************************************************************************************************
261 * PEND ON SEMAPHORE
262 *
263 * Description: This function waits for a semaphore.
264 *
265 * Arguments : pevent is a pointer to the event control block associated with the desired
266 * semaphore.
267 *
268 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
269 * wait for the resource up to the amount of time specified by this argument.
270 * If you specify 0, however, your task will wait forever at the specified
271 * semaphore or, until the resource becomes available (or the event occurs).
272 *
273 * perr is a pointer to where an error message will be deposited. Possible error
274 * messages are:
275 *
276 * OS_ERR_NONE The call was successful and your task owns the resource
277 * or, the event you are waiting for occurred.
278 * OS_ERR_TIMEOUT The semaphore was not received within the specified
279 * 'timeout'.
280 * OS_ERR_PEND_ABORT The wait on the semaphore was aborted.
281 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore.
282 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
283 * would lead to a suspension.
284 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
285 * OS_ERR_PEND_LOCKED If you called this function when the scheduler is locked
286 *
287 * Returns : none
288 *********************************************************************************************************
289 */
290 /*$PAGE*/
\ In section .text, align 2, keep-with-next
291 void OSSemPend (OS_EVENT *pevent,
292 INT32U timeout,
293 INT8U *perr)
294 {
\ OSSemPend:
\ 00000000 F8B5 PUSH {R3-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
\ 00000006 1600 MOVS R6,R2
295 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
296 OS_CPU_SR cpu_sr = 0u;
\ 00000008 0027 MOVS R7,#+0
297 #endif
298
299
300
301 #ifdef OS_SAFETY_CRITICAL
302 if (perr == (INT8U *)0) {
303 OS_SAFETY_CRITICAL_EXCEPTION();
304 return;
305 }
306 #endif
307
308 #if OS_ARG_CHK_EN > 0u
309 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
310 *perr = OS_ERR_PEVENT_NULL;
311 return;
312 }
313 #endif
314 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ 0000000A 2078 LDRB R0,[R4, #+0]
\ 0000000C 0328 CMP R0,#+3
\ 0000000E 02D0 BEQ.N ??OSSemPend_0
315 *perr = OS_ERR_EVENT_TYPE;
\ 00000010 0120 MOVS R0,#+1
\ 00000012 3070 STRB R0,[R6, #+0]
316 return;
\ 00000014 64E0 B.N ??OSSemPend_1
317 }
318 if (OSIntNesting > 0u) { /* See if called from ISR ... */
\ ??OSSemPend_0:
\ 00000016 .... LDR.N R0,??DataTable3_1
\ 00000018 0078 LDRB R0,[R0, #+0]
\ 0000001A 0028 CMP R0,#+0
\ 0000001C 02D0 BEQ.N ??OSSemPend_2
319 *perr = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 0000001E 0220 MOVS R0,#+2
\ 00000020 3070 STRB R0,[R6, #+0]
320 return;
\ 00000022 5DE0 B.N ??OSSemPend_1
321 }
322 if (OSLockNesting > 0u) { /* See if called with scheduler locked ... */
\ ??OSSemPend_2:
\ 00000024 .... LDR.N R0,??DataTable3_3
\ 00000026 0078 LDRB R0,[R0, #+0]
\ 00000028 0028 CMP R0,#+0
\ 0000002A 02D0 BEQ.N ??OSSemPend_3
323 *perr = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked */
\ 0000002C 0D20 MOVS R0,#+13
\ 0000002E 3070 STRB R0,[R6, #+0]
324 return;
\ 00000030 56E0 B.N ??OSSemPend_1
325 }
326 OS_ENTER_CRITICAL();
\ ??OSSemPend_3:
\ 00000032 ........ BL OS_CPU_SR_Save
\ 00000036 0700 MOVS R7,R0
327 if (pevent->OSEventCnt > 0u) { /* If sem. is positive, resource available ... */
\ 00000038 2089 LDRH R0,[R4, #+8]
\ 0000003A 0028 CMP R0,#+0
\ 0000003C 08D0 BEQ.N ??OSSemPend_4
328 pevent->OSEventCnt--; /* ... decrement semaphore only if positive. */
\ 0000003E 2089 LDRH R0,[R4, #+8]
\ 00000040 401E SUBS R0,R0,#+1
\ 00000042 2081 STRH R0,[R4, #+8]
329 OS_EXIT_CRITICAL();
\ 00000044 3800 MOVS R0,R7
\ 00000046 ........ BL OS_CPU_SR_Restore
330 *perr = OS_ERR_NONE;
\ 0000004A 0020 MOVS R0,#+0
\ 0000004C 3070 STRB R0,[R6, #+0]
331 return;
\ 0000004E 47E0 B.N ??OSSemPend_1
332 }
333 /* Otherwise, must wait until event occurs */
334 OSTCBCur->OSTCBStat |= OS_STAT_SEM; /* Resource not available, pend on semaphore */
\ ??OSSemPend_4:
\ 00000050 .... LDR.N R0,??DataTable3_4
\ 00000052 0068 LDR R0,[R0, #+0]
\ 00000054 90F83400 LDRB R0,[R0, #+52]
\ 00000058 50F00100 ORRS R0,R0,#0x1
\ 0000005C .... LDR.N R1,??DataTable3_4
\ 0000005E 0968 LDR R1,[R1, #+0]
\ 00000060 81F83400 STRB R0,[R1, #+52]
335 OSTCBCur->OSTCBStatPend = OS_STAT_PEND_OK;
\ 00000064 .... LDR.N R0,??DataTable3_4
\ 00000066 0068 LDR R0,[R0, #+0]
\ 00000068 0021 MOVS R1,#+0
\ 0000006A 80F83510 STRB R1,[R0, #+53]
336 OSTCBCur->OSTCBDly = timeout; /* Store pend timeout in TCB */
\ 0000006E .... LDR.N R0,??DataTable3_4
\ 00000070 0068 LDR R0,[R0, #+0]
\ 00000072 0563 STR R5,[R0, #+48]
337 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
\ 00000074 2000 MOVS R0,R4
\ 00000076 ........ BL OS_EventTaskWait
338 OS_EXIT_CRITICAL();
\ 0000007A 3800 MOVS R0,R7
\ 0000007C ........ BL OS_CPU_SR_Restore
339 OS_Sched(); /* Find next highest priority task ready */
\ 00000080 ........ BL OS_Sched
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -