📄 os_sem.lst
字号:
225 #endif
226 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 00000090 2070 STRB R0,[R4, #+0]
227 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 00000092 3068 LDR R0,[R6, #+0]
\ 00000094 6060 STR R0,[R4, #+4]
228 pevent->OSEventCnt = 0;
\ 00000096 5046 MOV R0,R10
\ 00000098 2081 STRH R0,[R4, #+8]
229 OSEventFreeList = pevent; /* Get next free event control block */
\ 0000009A 3460 STR R4,[R6, #+0]
230 OS_EXIT_CRITICAL();
\ 0000009C 4846 MOV R0,R9
\ 0000009E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
231 if (tasks_waiting == OS_TRUE) { /* Reschedule only if task(s) were waiting */
\ 000000A2 012F CMP R7,#+1
\ 000000A4 01D1 BNE.N ??OSSemDel_8
232 OS_Sched(); /* Find highest priority task ready to run */
\ 000000A6 ........ _BLF OS_Sched,??OS_Sched??rT
233 }
234 *perr = OS_ERR_NONE;
\ ??OSSemDel_8:
\ 000000AA 5046 MOV R0,R10
\ 000000AC 2870 STRB R0,[R5, #+0]
235 pevent_return = (OS_EVENT *)0; /* Semaphore has been deleted */
\ 000000AE 05E0 B.N ??OSSemDel_1
236 break;
237
238 default:
239 OS_EXIT_CRITICAL();
\ ??OSSemDel_6:
\ 000000B0 4846 MOV R0,R9
\ 000000B2 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
240 *perr = OS_ERR_INVALID_OPT;
\ 000000B6 0720 MOVS R0,#+7
\ 000000B8 2870 STRB R0,[R5, #+0]
241 pevent_return = pevent;
\ 000000BA 2000 MOVS R0,R4
242 break;
243 }
244 return (pevent_return);
\ ??OSSemDel_1:
\ 000000BC BDE8F08F POP {R4-R11,PC} ;; return
245 }
246 #endif
247
248 /*$PAGE*/
249 /*
250 *********************************************************************************************************
251 * PEND ON SEMAPHORE
252 *
253 * Description: This function waits for a semaphore.
254 *
255 * Arguments : pevent is a pointer to the event control block associated with the desired
256 * semaphore.
257 *
258 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
259 * wait for the resource up to the amount of time specified by this argument.
260 * If you specify 0, however, your task will wait forever at the specified
261 * semaphore or, until the resource becomes available (or the event occurs).
262 *
263 * perr is a pointer to where an error message will be deposited. Possible error
264 * messages are:
265 *
266 * OS_ERR_NONE The call was successful and your task owns the resource
267 * or, the event you are waiting for occurred.
268 * OS_ERR_TIMEOUT The semaphore was not received within the specified
269 * 'timeout'.
270 * OS_ERR_PEND_ABORT The wait on the semaphore was aborted.
271 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore.
272 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
273 * would lead to a suspension.
274 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
275 * OS_ERR_PEND_LOCKED If you called this function when the scheduler is locked
276 *
277 * Returns : none
278 *********************************************************************************************************
279 */
280 /*$PAGE*/
\ In segment CODE, align 4, keep-with-next
281 void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *perr)
282 {
\ OSSemPend:
\ 00000000 2DE9F043 PUSH {R4-R9,LR}
\ 00000004 8046 MOV R8,R0
\ 00000006 8946 MOV R9,R1
\ 00000008 1400 MOVS R4,R2
283 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
284 OS_CPU_SR cpu_sr = 0;
285 #endif
286
287
288
289 #if OS_ARG_CHK_EN > 0
290 if (perr == (INT8U *)0) { /* Validate 'perr' */
291 return;
292 }
293 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
294 *perr = OS_ERR_PEVENT_NULL;
295 return;
296 }
297 #endif
298 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ 0000000A 98F80000 LDRB R0,[R8, #+0]
\ 0000000E 0328 CMP R0,#+3
\ 00000010 02D0 BEQ.N ??OSSemPend_0
299 *perr = OS_ERR_EVENT_TYPE;
\ 00000012 0120 MOVS R0,#+1
\ 00000014 2070 STRB R0,[R4, #+0]
300 return;
\ 00000016 59E0 B.N ??OSSemPend_1
301 }
302 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSSemPend_0:
\ 00000018 .... LDR.N R0,??DataTable4 ;; OSIntNesting
\ 0000001A 0078 LDRB R0,[R0, #+0]
\ 0000001C 0028 CMP R0,#+0
\ 0000001E 02D0 BEQ.N ??OSSemPend_2
303 *perr = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 00000020 0220 MOVS R0,#+2
\ 00000022 2070 STRB R0,[R4, #+0]
304 return;
\ 00000024 52E0 B.N ??OSSemPend_1
305 }
306 if (OSLockNesting > 0) { /* See if called with scheduler locked ... */
\ ??OSSemPend_2:
\ 00000026 2A48 LDR.N R0,??OSSemPend_3 ;; OSLockNesting
\ 00000028 0078 LDRB R0,[R0, #+0]
\ 0000002A 0028 CMP R0,#+0
\ 0000002C 02D0 BEQ.N ??OSSemPend_4
307 *perr = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked */
\ 0000002E 0D20 MOVS R0,#+13
\ 00000030 2070 STRB R0,[R4, #+0]
308 return;
\ 00000032 4BE0 B.N ??OSSemPend_1
309 }
310 OS_ENTER_CRITICAL();
\ ??OSSemPend_4:
\ 00000034 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000038 0500 MOVS R5,R0
311 if (pevent->OSEventCnt > 0) { /* If sem. is positive, resource available ... */
\ 0000003A 0026 MOVS R6,#+0
\ 0000003C B8F80800 LDRH R0,[R8, #+8]
\ 00000040 0028 CMP R0,#+0
\ 00000042 07D0 BEQ.N ??OSSemPend_5
312 pevent->OSEventCnt--; /* ... decrement semaphore only if positive. */
\ 00000044 401E SUBS R0,R0,#+1
\ 00000046 A8F80800 STRH R0,[R8, #+8]
313 OS_EXIT_CRITICAL();
\ 0000004A 2800 MOVS R0,R5
\ 0000004C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
314 *perr = OS_ERR_NONE;
\ 00000050 2670 STRB R6,[R4, #+0]
315 return;
\ 00000052 3BE0 B.N ??OSSemPend_1
316 }
317 /* Otherwise, must wait until event occurs */
318 OSTCBCur->OSTCBStat |= OS_STAT_SEM; /* Resource not available, pend on semaphore */
\ ??OSSemPend_5:
\ 00000054 1F4F LDR.N R7,??OSSemPend_3+0x4 ;; OSTCBCur
\ 00000056 3868 LDR R0,[R7, #+0]
\ 00000058 0100 MOVS R1,R0
\ 0000005A 3031 ADDS R1,R1,#+48
\ 0000005C 0978 LDRB R1,[R1, #+0]
\ 0000005E 51F00101 ORRS R1,R1,#0x1
\ 00000062 80F83010 STRB R1,[R0, #+48]
319 OSTCBCur->OSTCBStatPend = OS_STAT_PEND_OK;
\ 00000066 3868 LDR R0,[R7, #+0]
\ 00000068 3130 ADDS R0,R0,#+49
\ 0000006A 3100 MOVS R1,R6
\ 0000006C 0170 STRB R1,[R0, #+0]
320 OSTCBCur->OSTCBDly = timeout; /* Store pend timeout in TCB */
\ 0000006E 3868 LDR R0,[R7, #+0]
\ 00000070 A0F82E90 STRH R9,[R0, #+46]
321 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
\ 00000074 4046 MOV R0,R8
\ 00000076 ........ _BLF OS_EventTaskWait,??OS_EventTaskWait??rT
322 OS_EXIT_CRITICAL();
\ 0000007A 2800 MOVS R0,R5
\ 0000007C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
323 OS_Sched(); /* Find next highest priority task ready */
\ 00000080 ........ _BLF OS_Sched,??OS_Sched??rT
324 OS_ENTER_CRITICAL();
\ 00000084 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000088 0500 MOVS R5,R0
325 switch (OSTCBCur->OSTCBStatPend) { /* See if we timed-out or aborted */
\ 0000008A 3868 LDR R0,[R7, #+0]
\ 0000008C 90F83110 LDRB R1,[R0, #+49]
\ 00000090 0029 CMP R1,#+0
\ 00000092 02D0 BEQ.N ??OSSemPend_6
\ 00000094 0229 CMP R1,#+2
\ 00000096 03D0 BEQ.N ??OSSemPend_7
\ 00000098 05E0 B.N ??OSSemPend_8
326 case OS_STAT_PEND_OK:
327 *perr = OS_ERR_NONE;
\ ??OSSemPend_6:
\ 0000009A 3000 MOVS R0,R6
\ 0000009C 2070 STRB R0,[R4, #+0]
\ 0000009E 07E0 B.N ??OSSemPend_9
328 break;
329
330 case OS_STAT_PEND_ABORT:
331 *perr = OS_ERR_PEND_ABORT; /* Indicate that we aborted */
\ ??OSSemPend_7:
\ 000000A0 0E20 MOVS R0,#+14
\ 000000A2 2070 STRB R0,[R4, #+0]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -