📄 os_q.lst
字号:
322 OS_EXIT_CRITICAL();
\ 00000024 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
323 return (OS_NO_ERR);
\ 00000028 0020 MOVS R0,#+0
\ ??OSQFlush_1:
\ 0000002A 10BC POP {R4}
\ 0000002C 02BC POP {R1}
\ 0000002E 0847 BX R1 ;; return
324 }
325 #endif
326
327 /*$PAGE*/
328 /*
329 *********************************************************************************************************
330 * PEND ON A QUEUE FOR A MESSAGE
331 *
332 * Description: This function waits for a message to be sent to a queue
333 *
334 * Arguments : pevent is a pointer to the event control block associated with the desired queue
335 *
336 * timeout is an optional timeout period (in clock ticks). If non-zero, your task will
337 * wait for a message to arrive at the queue up to the amount of time
338 * specified by this argument. If you specify 0, however, your task will wait
339 * forever at the specified queue or, until a message arrives.
340 *
341 * err is a pointer to where an error message will be deposited. Possible error
342 * messages are:
343 *
344 * OS_NO_ERR The call was successful and your task received a
345 * message.
346 * OS_TIMEOUT A message was not received within the specified timeout
347 * OS_ERR_EVENT_TYPE You didn't pass a pointer to a queue
348 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
349 * OS_ERR_PEND_ISR If you called this function from an ISR and the result
350 * would lead to a suspension.
351 *
352 * Returns : != (void *)0 is a pointer to the message received
353 * == (void *)0 if you received a NULL pointer message or,
354 * if no message was received or,
355 * if 'pevent' is a NULL pointer or,
356 * if you didn't pass a pointer to a queue.
357 *
358 * Note(s) : As of V2.60, this function allows you to receive NULL pointer messages.
359 *********************************************************************************************************
360 */
361
\ In segment CODE, align 4, keep-with-next
362 void *OSQPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
363 {
\ OSQPend:
\ 00000000 F0B5 PUSH {R4-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
\ 00000006 1600 MOVS R6,R2
364 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
365 OS_CPU_SR cpu_sr;
366 #endif
367 void *msg;
368 OS_Q *pq;
369
370
371 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 00000008 .... LDR R0,??DataTable14 ;; OSIntNesting
\ 0000000A 0078 LDRB R0,[R0, #+0]
\ 0000000C 0028 CMP R0,#+0
\ 0000000E 03D0 BEQ ??OSQPend_0
372 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
\ 00000010 0220 MOVS R0,#+2
\ ??OSQPend_1:
\ 00000012 3070 STRB R0,[R6, #+0]
373 return ((void *)0);
\ 00000014 0020 MOVS R0,#+0
\ 00000016 59E0 B ??OSQPend_2
374 }
375 #if OS_ARG_CHK_EN > 0
376 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ ??OSQPend_0:
\ 00000018 002C CMP R4,#+0
\ 0000001A 01D1 BNE ??OSQPend_3
377 *err = OS_ERR_PEVENT_NULL;
\ 0000001C 0420 MOVS R0,#+4
\ 0000001E F8E7 B.N ??OSQPend_1
378 return ((void *)0);
379 }
380 if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type */
\ ??OSQPend_3:
\ 00000020 2078 LDRB R0,[R4, #+0]
\ 00000022 0228 CMP R0,#+2
\ 00000024 03D0 BEQ ??OSQPend_4
381 *err = OS_ERR_EVENT_TYPE;
\ 00000026 0120 MOVS R0,#+1
\ 00000028 3070 STRB R0,[R6, #+0]
382 return ((void *)0);
\ 0000002A 0020 MOVS R0,#+0
\ 0000002C 4EE0 B ??OSQPend_2
383 }
384 #endif
385 OS_ENTER_CRITICAL();
\ ??OSQPend_4:
\ 0000002E ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000032 0700 MOVS R7,R0
386 pq = (OS_Q *)pevent->OSEventPtr; /* Point at queue control block */
\ 00000034 6068 LDR R0,[R4, #+4]
387 if (pq->OSQEntries > 0) { /* See if any messages in the queue */
\ 00000036 C18A LDRH R1,[R0, #+22]
\ 00000038 0029 CMP R1,#+0
\ 0000003A 0DD0 BEQ ??OSQPend_5
388 msg = *pq->OSQOut++; /* Yes, extract oldest message from the queue */
\ 0000003C 0169 LDR R1,[R0, #+16]
\ 0000003E 0A1D ADDS R2,R1,#+4
\ 00000040 0261 STR R2,[R0, #+16]
\ 00000042 0C68 LDR R4,[R1, #+0]
389 pq->OSQEntries--; /* Update the number of entries in the queue */
\ 00000044 C18A LDRH R1,[R0, #+22]
\ 00000046 491E SUBS R1,R1,#+1
\ 00000048 C182 STRH R1,[R0, #+22]
390 if (pq->OSQOut == pq->OSQEnd) { /* Wrap OUT pointer if we are at the end of the queue */
\ 0000004A 1100 MOVS R1,R2
\ 0000004C 8268 LDR R2,[R0, #+8]
\ 0000004E 9142 CMP R1,R2
\ 00000050 36D1 BNE ??OSQPend_6
391 pq->OSQOut = pq->OSQStart;
\ 00000052 4168 LDR R1,[R0, #+4]
\ 00000054 0161 STR R1,[R0, #+16]
392 }
393 OS_EXIT_CRITICAL();
\ ??OSQPend_7:
\ 00000056 33E0 B.N ??OSQPend_6
394 *err = OS_NO_ERR;
395 return (msg); /* Return message received */
396 }
397 OSTCBCur->OSTCBStat |= OS_STAT_Q; /* Task will have to pend for a message to be posted */
\ ??OSQPend_5:
\ 00000058 1E48 LDR R0,??OSQPend_8 ;; OSTCBCur
\ 0000005A 0068 LDR R0,[R0, #+0]
\ 0000005C 2C30 ADDS R0,R0,#+44
\ 0000005E 1D49 LDR R1,??OSQPend_8 ;; OSTCBCur
\ 00000060 0968 LDR R1,[R1, #+0]
\ 00000062 2C31 ADDS R1,R1,#+44
\ 00000064 0978 LDRB R1,[R1, #+0]
\ 00000066 0422 MOVS R2,#+4
\ 00000068 0A43 ORRS R2,R2,R1
\ 0000006A 0270 STRB R2,[R0, #+0]
398 OSTCBCur->OSTCBDly = timeout; /* Load timeout into TCB */
\ 0000006C 1948 LDR R0,??OSQPend_8 ;; OSTCBCur
\ 0000006E 0068 LDR R0,[R0, #+0]
\ 00000070 4585 STRH R5,[R0, #+42]
399 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
\ 00000072 2000 MOVS R0,R4
\ 00000074 ........ _BLF OS_EventTaskWait,??OS_EventTaskWait??rT
400 OS_EXIT_CRITICAL();
\ 00000078 3800 MOVS R0,R7
\ 0000007A ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
401 OS_Sched(); /* Find next highest priority task ready to run */
\ 0000007E ........ _BLF OS_Sched,??OS_Sched??rT
402 OS_ENTER_CRITICAL();
\ 00000082 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000086 0700 MOVS R7,R0
403 if (OSTCBCur->OSTCBStat & OS_STAT_Q) { /* Was task readied because of a timeout? */
\ 00000088 1248 LDR R0,??OSQPend_8 ;; OSTCBCur
\ 0000008A 0068 LDR R0,[R0, #+0]
\ 0000008C 2C30 ADDS R0,R0,#+44
\ 0000008E 0078 LDRB R0,[R0, #+0]
\ 00000090 4007 LSLS R0,R0,#+29
\ 00000092 07D5 BPL ??OSQPend_9
404 OS_EventTO(pevent); /* Yes */
\ 00000094 2000 MOVS R0,R4
\ 00000096 ........ _BLF OS_EventTO,??OS_EventTO??rT
405 OS_EXIT_CRITICAL();
\ 0000009A 3800 MOVS R0,R7
\ 0000009C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
406 *err = OS_TIMEOUT; /* Indicate a timeout occured */
\ 000000A0 0A20 MOVS R0,#+10
\ 000000A2 B6E7 B.N ??OSQPend_1
407 return ((void *)0); /* No message received */
408 }
409 msg = OSTCBCur->OSTCBMsg;/* No, Extract message from TCB (Put there by QPost) */
\ ??OSQPend_9:
\ 000000A4 0B48 LDR R0,??OSQPend_8 ;; OSTCBCur
\ 000000A6 0068 LDR R0,[R0, #+0]
\ 000000A8 046A LDR R4,[R0, #+32]
410 OSTCBCur->OSTCBMsg = (void *)0;
\ 000000AA 0A48 LDR R0,??OSQPend_8 ;; OSTCBCur
\ 000000AC 0068 LDR R0,[R0, #+0]
\ 000000AE 0021 MOVS R1,#+0
\ 000000B0 0162 STR R1,[R0, #+32]
411 OSTCBCur->OSTCBStat = OS_STAT_RDY;
\ 000000B2 0848 LDR R0,??OSQPend_8 ;; OSTCBCur
\ 000000B4 0068 LDR R0,[R0, #+0]
\ 000000B6 2C30 ADDS R0,R0,#+44
\ 000000B8 0170 STRB R1,[R0, #+0]
412 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0; /* No longer waiting for event */
\ 000000BA 0648 LDR R0,??OSQPend_8 ;; OSTCBCur
\ 000000BC 0068 LDR R0,[R0, #+0]
\ 000000BE C161 STR R1,[R0, #+28]
413 OS_EXIT_CRITICAL();
\ ??OSQPend_6:
\ 000000C0 3800 MOVS R0,R7
\ 000000C2 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
414 *err = OS_NO_ERR;
\ 000000C6 0020 MOVS R0,#+0
\ 000000C8 3070 STRB R0,[R6, #+0]
415 return (msg); /* Return message received */
\ 000000CA 2000 MOVS R0,R4
\ ??OSQPend_2:
\ 000000CC F0BC POP {R4-R7}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -