📄 os_sem.lst
字号:
\ 000000FC 260000EA B ??OSSemDel_11
211 } else {
212 OS_EXIT_CRITICAL();
\ ??OSSemDel_10:
\ 00000100 0700B0E1 MOVS R0,R7
\ 00000104 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
213 *err = OS_ERR_TASK_WAITING;
\ 00000108 4900A0E3 MOV R0,#+73
\ 0000010C 0000C5E5 STRB R0,[R5, #+0]
214 pevent_return = pevent;
\ 00000110 210000EA B ??OSSemDel_11
215 }
216 break;
217
218 case OS_DEL_ALWAYS: /* Always delete the semaphore */
219 while (pevent->OSEventGrp != 0) { /* Ready ALL tasks waiting for semaphore */
220 (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
\ ??OSSemDel_12:
\ 00000114 0030A0E3 MOV R3,#+0
\ 00000118 0120A0E3 MOV R2,#+1
\ 0000011C 0010A0E3 MOV R1,#+0
\ 00000120 0400B0E1 MOVS R0,R4
\ 00000124 ........ _BLF OS_EventTaskRdy,??OS_EventTaskRdy??rA
221 }
\ ??OSSemDel_8:
\ 00000128 0A00D4E5 LDRB R0,[R4, #+10]
\ 0000012C 000050E3 CMP R0,#+0
\ 00000130 F7FFFF1A BNE ??OSSemDel_12
222 #if OS_EVENT_NAME_SIZE > 1
223 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 00000134 3F00A0E3 MOV R0,#+63
\ 00000138 0F00C4E5 STRB R0,[R4, #+15]
224 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 0000013C 0000A0E3 MOV R0,#+0
\ 00000140 1000C4E5 STRB R0,[R4, #+16]
225 #endif
226 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 00000144 0000A0E3 MOV R0,#+0
\ 00000148 0000C4E5 STRB R0,[R4, #+0]
227 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 0000014C ........ LDR R0,??DataTable9 ;; OSEventFreeList
\ 00000150 000090E5 LDR R0,[R0, #+0]
\ 00000154 040084E5 STR R0,[R4, #+4]
228 pevent->OSEventCnt = 0;
\ 00000158 0000A0E3 MOV R0,#+0
\ 0000015C B800C4E1 STRH R0,[R4, #+8]
229 OSEventFreeList = pevent; /* Get next free event control block */
\ 00000160 ........ LDR R0,??DataTable9 ;; OSEventFreeList
\ 00000164 004080E5 STR R4,[R0, #+0]
230 OS_EXIT_CRITICAL();
\ 00000168 0700B0E1 MOVS R0,R7
\ 0000016C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
231 if (tasks_waiting == OS_TRUE) { /* Reschedule only if task(s) were waiting */
\ 00000170 010058E3 CMP R8,#+1
\ 00000174 0000001A BNE ??OSSemDel_13
232 OS_Sched(); /* Find highest priority task ready to run */
\ 00000178 ........ _BLF OS_Sched,??OS_Sched??rA
233 }
234 *err = OS_ERR_NONE;
\ ??OSSemDel_13:
\ 0000017C 0000A0E3 MOV R0,#+0
\ 00000180 0000C5E5 STRB R0,[R5, #+0]
235 pevent_return = (OS_EVENT *)0; /* Semaphore has been deleted */
\ 00000184 0040A0E3 MOV R4,#+0
\ 00000188 030000EA B ??OSSemDel_11
236 break;
237
238 default:
239 OS_EXIT_CRITICAL();
\ ??OSSemDel_9:
\ 0000018C 0700B0E1 MOVS R0,R7
\ 00000190 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
240 *err = OS_ERR_INVALID_OPT;
\ 00000194 0700A0E3 MOV R0,#+7
\ 00000198 0000C5E5 STRB R0,[R5, #+0]
241 pevent_return = pevent;
242 break;
243 }
244 return (pevent_return);
\ ??OSSemDel_11:
\ 0000019C 0400B0E1 MOVS R0,R4
\ ??OSSemDel_1:
\ 000001A0 F081BDE8 POP {R4-R8,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 * err 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 *err)
282 {
\ OSSemPend:
\ 00000000 F0402DE9 PUSH {R4-R7,LR}
\ 00000004 0050B0E1 MOVS R5,R0
\ 00000008 0160B0E1 MOVS R6,R1
\ 0000000C 0240B0E1 MOVS R4,R2
283 INT8U pend_stat;
284 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
285 OS_CPU_SR cpu_sr = 0;
\ 00000010 0070A0E3 MOV R7,#+0
286 #endif
287
288
289
290 #if OS_ARG_CHK_EN > 0
291 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000014 000054E3 CMP R4,#+0
\ 00000018 5800000A BEQ ??OSSemPend_0
292 return;
293 }
294 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 0000001C 000055E3 CMP R5,#+0
\ 00000020 0200001A BNE ??OSSemPend_1
295 *err = OS_ERR_PEVENT_NULL;
\ 00000024 0400A0E3 MOV R0,#+4
\ 00000028 0000C4E5 STRB R0,[R4, #+0]
296 return;
\ 0000002C 530000EA B ??OSSemPend_0
297 }
298 #endif
299 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ ??OSSemPend_1:
\ 00000030 0000D5E5 LDRB R0,[R5, #+0]
\ 00000034 030050E3 CMP R0,#+3
\ 00000038 0200000A BEQ ??OSSemPend_2
300 *err = OS_ERR_EVENT_TYPE;
\ 0000003C 0100A0E3 MOV R0,#+1
\ 00000040 0000C4E5 STRB R0,[R4, #+0]
301 return;
\ 00000044 4D0000EA B ??OSSemPend_0
302 }
303 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSSemPend_2:
\ 00000048 ........ LDR R0,??DataTable10 ;; OSIntNesting
\ 0000004C 0000D0E5 LDRB R0,[R0, #+0]
\ 00000050 010050E3 CMP R0,#+1
\ 00000054 0200003A BCC ??OSSemPend_3
304 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 00000058 0200A0E3 MOV R0,#+2
\ 0000005C 0000C4E5 STRB R0,[R4, #+0]
305 return;
\ 00000060 460000EA B ??OSSemPend_0
306 }
307 if (OSLockNesting > 0) { /* See if called with scheduler locked ... */
\ ??OSSemPend_3:
\ 00000064 18019FE5 LDR R0,??OSSemPend_4 ;; OSLockNesting
\ 00000068 0000D0E5 LDRB R0,[R0, #+0]
\ 0000006C 010050E3 CMP R0,#+1
\ 00000070 0200003A BCC ??OSSemPend_5
308 *err = OS_ERR_PEND_LOCKED; /* ... can't PEND when locked */
\ 00000074 0D00A0E3 MOV R0,#+13
\ 00000078 0000C4E5 STRB R0,[R4, #+0]
309 return;
\ 0000007C 3F0000EA B ??OSSemPend_0
310 }
311 OS_ENTER_CRITICAL();
\ ??OSSemPend_5:
\ 00000080 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000084 0070B0E1 MOVS R7,R0
312 if (pevent->OSEventCnt > 0) { /* If sem. is positive, resource available ... */
\ 00000088 B800D5E1 LDRH R0,[R5, #+8]
\ 0000008C 010050E3 CMP R0,#+1
\ 00000090 0900003A BCC ??OSSemPend_6
313 pevent->OSEventCnt--; /* ... decrement semaphore only if positive. */
\ 00000094 B800D5E1 LDRH R0,[R5, #+8]
\ 00000098 FF10A0E3 MOV R1,#+255
\ 0000009C FF1C81E3 ORR R1,R1,#0xFF00
\ 000000A0 000091E0 ADDS R0,R1,R0
\ 000000A4 B800C5E1 STRH R0,[R5, #+8]
314 OS_EXIT_CRITICAL();
\ 000000A8 0700B0E1 MOVS R0,R7
\ 000000AC ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
315 *err = OS_ERR_NONE;
\ 000000B0 0000A0E3 MOV R0,#+0
\ 000000B4 0000C4E5 STRB R0,[R4, #+0]
316 return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -