📄 os_q.s79
字号:
// 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
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock9 Using cfiCommon1
CFI Function OSQPend
THUMB
// 362 void *OSQPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
// 363 {
OSQPend:
PUSH {R4-R7,LR}
CFI ?RET Frame(CFA, -4)
CFI R7 Frame(CFA, -8)
CFI R6 Frame(CFA, -12)
CFI R5 Frame(CFA, -16)
CFI R4 Frame(CFA, -20)
CFI CFA R13+20
MOVS R4,R0
MOVS R5,R1
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 ... */
LDR R0,??DataTable14 ;; OSIntNesting
LDRB R0,[R0, #+0]
CMP R0,#+0
BEQ ??OSQPend_0
// 372 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
MOVS R0,#+2
??OSQPend_1:
STRB R0,[R6, #+0]
// 373 return ((void *)0);
MOVS R0,#+0
B ??OSQPend_2
// 374 }
// 375 #if OS_ARG_CHK_EN > 0
// 376 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
??OSQPend_0:
CMP R4,#+0
BNE ??OSQPend_3
// 377 *err = OS_ERR_PEVENT_NULL;
MOVS R0,#+4
B.N ??OSQPend_1
// 378 return ((void *)0);
// 379 }
// 380 if (pevent->OSEventType != OS_EVENT_TYPE_Q) {/* Validate event block type */
??OSQPend_3:
LDRB R0,[R4, #+0]
CMP R0,#+2
BEQ ??OSQPend_4
// 381 *err = OS_ERR_EVENT_TYPE;
MOVS R0,#+1
STRB R0,[R6, #+0]
// 382 return ((void *)0);
MOVS R0,#+0
B ??OSQPend_2
// 383 }
// 384 #endif
// 385 OS_ENTER_CRITICAL();
??OSQPend_4:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R7,R0
// 386 pq = (OS_Q *)pevent->OSEventPtr; /* Point at queue control block */
LDR R0,[R4, #+4]
// 387 if (pq->OSQEntries > 0) { /* See if any messages in the queue */
LDRH R1,[R0, #+22]
CMP R1,#+0
BEQ ??OSQPend_5
// 388 msg = *pq->OSQOut++; /* Yes, extract oldest message from the queue */
LDR R1,[R0, #+16]
ADDS R2,R1,#+4
STR R2,[R0, #+16]
LDR R4,[R1, #+0]
// 389 pq->OSQEntries--; /* Update the number of entries in the queue */
LDRH R1,[R0, #+22]
SUBS R1,R1,#+1
STRH R1,[R0, #+22]
// 390 if (pq->OSQOut == pq->OSQEnd) { /* Wrap OUT pointer if we are at the end of the queue */
MOVS R1,R2
LDR R2,[R0, #+8]
CMP R1,R2
BNE ??OSQPend_6
// 391 pq->OSQOut = pq->OSQStart;
LDR R1,[R0, #+4]
STR R1,[R0, #+16]
// 392 }
// 393 OS_EXIT_CRITICAL();
??OSQPend_7:
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:
LDR R0,??OSQPend_8 ;; OSTCBCur
LDR R0,[R0, #+0]
ADDS R0,R0,#+44
LDR R1,??OSQPend_8 ;; OSTCBCur
LDR R1,[R1, #+0]
ADDS R1,R1,#+44
LDRB R1,[R1, #+0]
MOVS R2,#+4
ORRS R2,R2,R1
STRB R2,[R0, #+0]
// 398 OSTCBCur->OSTCBDly = timeout; /* Load timeout into TCB */
LDR R0,??OSQPend_8 ;; OSTCBCur
LDR R0,[R0, #+0]
STRH R5,[R0, #+42]
// 399 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
MOVS R0,R4
_BLF OS_EventTaskWait,??OS_EventTaskWait??rT
// 400 OS_EXIT_CRITICAL();
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 401 OS_Sched(); /* Find next highest priority task ready to run */
_BLF OS_Sched,??OS_Sched??rT
// 402 OS_ENTER_CRITICAL();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R7,R0
// 403 if (OSTCBCur->OSTCBStat & OS_STAT_Q) { /* Was task readied because of a timeout? */
LDR R0,??OSQPend_8 ;; OSTCBCur
LDR R0,[R0, #+0]
ADDS R0,R0,#+44
LDRB R0,[R0, #+0]
LSLS R0,R0,#+29
BPL ??OSQPend_9
// 404 OS_EventTO(pevent); /* Yes */
MOVS R0,R4
_BLF OS_EventTO,??OS_EventTO??rT
// 405 OS_EXIT_CRITICAL();
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 406 *err = OS_TIMEOUT; /* Indicate a timeout occured */
MOVS R0,#+10
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:
LDR R0,??OSQPend_8 ;; OSTCBCur
LDR R0,[R0, #+0]
LDR R4,[R0, #+32]
// 410 OSTCBCur->OSTCBMsg = (void *)0;
LDR R0,??OSQPend_8 ;; OSTCBCur
LDR R0,[R0, #+0]
MOVS R1,#+0
STR R1,[R0, #+32]
// 411 OSTCBCur->OSTCBStat = OS_STAT_RDY;
LDR R0,??OSQPend_8 ;; OSTCBCur
LDR R0,[R0, #+0]
ADDS R0,R0,#+44
STRB R1,[R0, #+0]
// 412 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0; /* No longer waiting for event */
LDR R0,??OSQPend_8 ;; OSTCBCur
LDR R0,[R0, #+0]
STR R1,[R0, #+28]
// 413 OS_EXIT_CRITICAL();
??OSQPend_6:
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 414 *err = OS_NO_ERR;
MOVS R0,#+0
STRB R0,[R6, #+0]
// 415 return (msg); /* Return message received */
MOVS R0,R4
??OSQPend_2:
POP {R4-R7}
POP {R1}
BX R1 ;; return
Nop
DATA
??OSQPend_8:
DC32 OSTCBCur
CFI EndBlock cfiBlock9
// 416 }
RSEG CODE:CODE:NOROOT(2)
DATA
??DataTable14:
DC32 OSIntNesting
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock10 Using cfiCommon0
CFI NoFunction
ARM
??OSQPost??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock10
REQUIRE OSQPost
// 417 /*$PAGE*/
// 418 /*
// 419 *********************************************************************************************************
// 420 * POST MESSAGE TO A QUEUE
// 421 *
// 422 * Description: This function sends a message to a queue
// 423 *
// 424 * Arguments : pevent is a pointer to the event control block associated with the desired queue
// 425 *
// 426 * msg is a pointer to the message to send. You MUST NOT send a NULL pointer.
// 427 *
// 428 * Returns : OS_NO_ERR The call was successful and the message was sent
// 429 * OS_Q_FULL If the queue cannot accept any more messages because it is full.
// 430 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue.
// 431 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
// 432 *
// 433 * Note(s) : As of V2.60, this function allows you to send NULL pointer messages.
// 434 *********************************************************************************************************
// 435 */
// 436
// 437 #if OS_Q_POST_EN > 0
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock11 Using cfiCommon1
CFI Function OSQPost
THUMB
// 438 INT8U OSQPost (OS_EVENT *pevent, void *msg)
// 439 {
OSQPost:
PUSH {R4-R6,LR}
CFI ?RET Frame(CFA, -4)
CFI R6 Frame(CFA, -8)
CFI R5 Frame(CFA, -12)
CFI R4 Frame(CFA, -16)
CFI CFA R13+16
MOVS R6,R0
MOVS R4,R1
// 440 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 441 OS_CPU_SR cpu_sr;
// 442 #endif
// 443 OS_Q *pq;
// 444
// 445
// 446 #if OS_ARG_CHK_EN > 0
// 447 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
CMP R6,#+0
BNE ??OSQPost_0
// 448 return (OS_ERR_PEVENT_NULL);
MOVS R0,#+4
B ??OSQPost_1
// 449 }
// 450 #endif
// 451 if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
??OSQPost_0:
LDRB R0,[R6, #+0]
CMP R0,#+2
BEQ ??OSQPost_2
// 452 return (OS_ERR_EVENT_TYPE);
MOVS R0,#+1
B ??OSQPost_1
// 453 }
// 454 OS_ENTER_CRITICAL();
??OSQPost_2:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R5,R0
// 455 if (pevent->OSEventGrp != 0x00) { /* See if any task pending on queue */
LDRB R0,[R6, #+1]
CMP R0,#+0
BEQ ??OSQPost_3
// 456 OS_EventTaskRdy(pevent, msg, OS_STAT_Q); /* Ready highest priority task waiting on event */
MOVS R2,#+4
MOVS R1,R4
MOVS R0,R6
_BLF OS_EventTaskRdy,??OS_EventTaskRdy??rT
// 457 OS_EXIT_CRITICAL();
MOVS R0,R5
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 458 OS_Sched(); /* Find highest priority task ready to run */
_BLF OS_Sched,??OS_Sched??rT
// 459 return (OS_NO_ERR);
B.N ??OSQPost_4
// 460 }
// 461 pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue control block */
??OSQPost_3:
LDR R0,[R6, #+4]
// 462 if (pq->OSQEntries >= pq->OSQSize) { /* Make sure queue is not full */
LDRH R1,[R0, #+22]
LDRH R2,[R0, #+20]
CMP R1,R2
BCC ??OSQPost_5
// 463 OS_EXIT_CRITICAL();
MOVS R0,R5
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 464 return (OS_Q_FULL);
MOVS R0,#+30
B ??OSQPost_1
// 465 }
// 466 *pq->OSQIn++ = msg; /* Insert message into queue */
??OSQPost_5:
LDR R1,[R0, #+12]
ADDS R2,R1,#+4
STR R2,[R0, #+12]
STR R4,[R1, #+0]
// 467 pq->OSQEntries++; /* Update the nbr of entries in the queue */
LDRH R1,[R0, #+22]
ADDS R1,R1,#+1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -