📄 os_sem.lst
字号:
\ 00000094 0028 CMP R0,#+0
\ 00000096 F6D1 BNE.N ??OSSemDel_12
222 #if OS_EVENT_NAME_SIZE > 1
223 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 00000098 84F80FB0 STRB R11,[R4, #+15]
224 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 0000009C 2074 STRB R0,[R4, #+16]
225 #endif
226 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 0000009E 2070 STRB R0,[R4, #+0]
227 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 000000A0 3068 LDR R0,[R6, #+0]
\ 000000A2 6060 STR R0,[R4, #+4]
228 pevent->OSEventCnt = 0;
\ 000000A4 5046 MOV R0,R10
\ 000000A6 2081 STRH R0,[R4, #+8]
229 OSEventFreeList = pevent; /* Get next free event control block */
\ 000000A8 3460 STR R4,[R6, #+0]
230 OS_EXIT_CRITICAL();
\ 000000AA 4846 MOV R0,R9
\ 000000AC ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
231 if (tasks_waiting == OS_TRUE) { /* Reschedule only if task(s) were waiting */
\ 000000B0 012F CMP R7,#+1
\ 000000B2 01D1 BNE.N ??OSSemDel_11
232 OS_Sched(); /* Find highest priority task ready to run */
\ 000000B4 ........ _BLF OS_Sched,??OS_Sched??rT
233 }
234 *perr = OS_ERR_NONE;
\ ??OSSemDel_11:
\ 000000B8 5046 MOV R0,R10
\ 000000BA 2870 STRB R0,[R5, #+0]
235 pevent_return = (OS_EVENT *)0; /* Semaphore has been deleted */
\ 000000BC 05E0 B.N ??OSSemDel_2
236 break;
237
238 default:
239 OS_EXIT_CRITICAL();
\ ??OSSemDel_9:
\ 000000BE 4846 MOV R0,R9
\ 000000C0 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
240 *perr = OS_ERR_INVALID_OPT;
\ 000000C4 0720 MOVS R0,#+7
\ 000000C6 2870 STRB R0,[R5, #+0]
241 pevent_return = pevent;
\ 000000C8 2000 MOVS R0,R4
242 break;
243 }
244 return (pevent_return);
\ ??OSSemDel_2:
\ 000000CA 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
\ 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 8846 MOV R8,R1
\ 00000006 0400 MOVS R4,R0
\ 00000008 1500 MOVS R5,R2
283 INT8U pend_stat;
284 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
285 OS_CPU_SR cpu_sr = 0;
286 #endif
287
288
289
290 #if OS_ARG_CHK_EN > 0
291 if (perr == (INT8U *)0) { /* Validate 'perr' */
\ 0000000A 5FD0 BEQ.N ??OSSemPend_0
292 return;
293 }
294 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 0000000C 002C CMP R4,#+0
\ 0000000E 02D1 BNE.N ??OSSemPend_1
295 *perr = OS_ERR_PEVENT_NULL;
\ 00000010 0420 MOVS R0,#+4
\ 00000012 2870 STRB R0,[R5, #+0]
296 return;
\ 00000014 5AE0 B.N ??OSSemPend_0
297 }
298 #endif
299 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ ??OSSemPend_1:
\ 00000016 2078 LDRB R0,[R4, #+0]
\ 00000018 0328 CMP R0,#+3
\ 0000001A 02D0 BEQ.N ??OSSemPend_2
300 *perr = OS_ERR_EVENT_TYPE;
\ 0000001C 0120 MOVS R0,#+1
\ 0000001E 2870 STRB R0,[R5, #+0]
301 return;
\ 00000020 54E0 B.N ??OSSemPend_0
302 }
303 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSSemPend_2:
\ 00000022 .... LDR.N R0,??DataTable4 ;; OSIntNesting
\ 00000024 0078 LDRB R0,[R0, #+0]
\ 00000026 0028 CMP R0,#+0
\ 00000028 02D0 BEQ.N ??OSSemPend_3
304 *perr = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 0000002A 0220 MOVS R0,#+2
\ 0000002C 2870 STRB R0,[R5, #+0]
305 return;
\ 0000002E 4DE0 B.N ??OSSemPend_0
306 }
307 if (OSLockNesting > 0) { /* See if called with scheduler locked ... */
\ ??OSSemPend_3:
\ 00000030 2748 LDR.N R0,??OSSemPend_4 ;; OSLockNesting
\ 00000032 0078 LDRB R0,[R0, #+0]
\ 00000034 0028 CMP R0,#+0
\ 00000036 02D0 BEQ.N ??OSSemPend_5
308 *perr = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked */
\ 00000038 0D20 MOVS R0,#+13
\ 0000003A 2870 STRB R0,[R5, #+0]
309 return;
\ 0000003C 46E0 B.N ??OSSemPend_0
310 }
311 OS_ENTER_CRITICAL();
\ ??OSSemPend_5:
\ 0000003E ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000042 0600 MOVS R6,R0
312 if (pevent->OSEventCnt > 0) { /* If sem. is positive, resource available ... */
\ 00000044 0027 MOVS R7,#+0
\ 00000046 2089 LDRH R0,[R4, #+8]
\ 00000048 0028 CMP R0,#+0
\ 0000004A 06D0 BEQ.N ??OSSemPend_6
313 pevent->OSEventCnt--; /* ... decrement semaphore only if positive. */
\ 0000004C 401E SUBS R0,R0,#+1
\ 0000004E 2081 STRH R0,[R4, #+8]
314 OS_EXIT_CRITICAL();
\ 00000050 3000 MOVS R0,R6
\ 00000052 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
315 *perr = OS_ERR_NONE;
\ 00000056 2F70 STRB R7,[R5, #+0]
316 return;
\ 00000058 38E0 B.N ??OSSemPend_0
317 }
318 /* Otherwise, must wait until event occurs */
319 OSTCBCur->OSTCBStat |= OS_STAT_SEM; /* Resource not available, pend on semaphore */
\ ??OSSemPend_6:
\ 0000005A 1E48 LDR.N R0,??OSSemPend_4+0x4 ;; OSTCBCur
\ 0000005C 8146 MOV R9,R0
\ 0000005E D9F80000 LDR R0,[R9, #+0]
\ 00000062 0100 MOVS R1,R0
\ 00000064 2C31 ADDS R1,R1,#+44
\ 00000066 0978 LDRB R1,[R1, #+0]
\ 00000068 51F00101 ORRS R1,R1,#0x1
\ 0000006C 80F82C10 STRB R1,[R0, #+44]
320 OSTCBCur->OSTCBStatPend = OS_STAT_PEND_OK;
\ 00000070 D9F80000 LDR R0,[R9, #+0]
\ 00000074 2D30 ADDS R0,R0,#+45
\ 00000076 3900 MOVS R1,R7
\ 00000078 0170 STRB R1,[R0, #+0]
321 OSTCBCur->OSTCBDly = timeout; /* Store pend timeout in TCB */
\ 0000007A D9F80000 LDR R0,[R9, #+0]
\ 0000007E A0F82A80 STRH R8,[R0, #+42]
322 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
\ 00000082 2000 MOVS R0,R4
\ 00000084 ........ _BLF OS_EventTaskWait,??OS_EventTaskWait??rT
323 OS_EXIT_CRITICAL();
\ 00000088 3000 MOVS R0,R6
\ 0000008A ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
324 OS_Sched(); /* Find next highest priority task ready */
\ 0000008E ........ _BLF OS_Sched,??OS_Sched??rT
325 OS_ENTER_CRITICAL();
\ 00000092 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000096 0600 MOVS R6,R0
326 if (OSTCBCur->OSTCBStatPend != OS_STAT_PEND_OK) { /* See if we timed-out or aborted */
\ 00000098 D9F80000 LDR R0,[R9, #+0]
\ 0000009C 1C30 ADDS R0,R0,#+28
\ 0000009E 417C LDRB R1,[R0, #+17]
\ 000000A0 0029 CMP R1,#+0
\ 000000A2 0ED0 BEQ.N ??OSSemPend_7
327 pend_stat = OSTCBCur->OSTCBStatPend;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -