📄 os_q.s43
字号:
MOV.B 6(SP),R13
; 548. #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; 549. OS_CPU_SR cpu_sr;
; 550. #endif
; 551. OS_Q *pq;
; 552.
; 553.
; 554. #if OS_ARG_CHK_EN > 0
; 555. if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
CMP #0,R11
JNE (?0144)
; 556. return (OS_ERR_PEVENT_NULL);
MOV.B #4,R12
; 557. }
JMP (?0166)
?0144:
; 558. if (msg == (void *)0) { /* Make sure we are not posting a NULL pointer */
CMP #0,R10
JNE (?0146)
; 559. return (OS_ERR_POST_NULL_PTR);
MOV.B #3,R12
; 560. }
JMP (?0166)
?0146:
; 561. if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
MOV.B #2,R12
CMP.B @R11,R12
JEQ (?0148)
; 562. return (OS_ERR_EVENT_TYPE);
MOV.B #1,R12
; 563. }
JMP (?0166)
?0148:
; 564. #endif
; 565. OS_ENTER_CRITICAL();
DINT
; 566. if (pevent->OSEventGrp != 0x00) { /* See if any task pending on queue */
CMP.B #0,1(R11)
JEQ (?0150)
; 567. if ((opt & OS_POST_OPT_BROADCAST) != 0x00) { /* Do we need to post msg to ALL waiting tasks ? */
BIT.B #1,R13
JEQ (?0152)
?0151:
; 568. while (pevent->OSEventGrp != 0x00) { /* Yes, Post to ALL tasks waiting on queue */
CMP.B #0,1(R11)
JEQ (?0156)
; 569. OS_EventTaskRdy(pevent, msg, OS_STAT_Q);
PUSH.B #4
MOV R10,R14
MOV R11,R12
CALL #OS_EventTaskRdy
ADD #2,SP
; 570. }
; 571. } else {
JMP (?0151)
?0152:
; 572. OS_EventTaskRdy(pevent, msg, OS_STAT_Q); /* No, Post to HPT waiting on queue */
PUSH.B #4
MOV R10,R14
MOV R11,R12
CALL #OS_EventTaskRdy
ADD #2,SP
?0156:
; 573. }
; 574. OS_EXIT_CRITICAL();
EINT
; 575. OS_Sched(); /* Find highest priority task ready to run */
CALL #OS_Sched
; 576. return (OS_NO_ERR);
MOV.B #0,R12
; 577. }
JMP (?0166)
?0150:
; 578. pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue control block */
MOV 4(R11),R12
; 579. if (pq->OSQEntries >= pq->OSQSize) { /* Make sure queue is not full */
CMP 10(R12),12(R12)
JNC (?0158)
; 580. OS_EXIT_CRITICAL();
EINT
; 581. return (OS_Q_FULL);
MOV.B #30,R12
; 582. }
JMP (?0166)
?0158:
; 583. if ((opt & OS_POST_OPT_FRONT) != 0x00) { /* Do we post to the FRONT of the queue? */
BIT.B #2,R13
JEQ (?0160)
; 584. if (pq->OSQOut == pq->OSQStart) { /* Yes, Post as LIFO, Wrap OUT pointer if we ... */
CMP 8(R12),2(R12)
JNE (?0162)
; 585. pq->OSQOut = pq->OSQEnd; /* ... are at the 1st queue entry */
MOV 4(R12),8(R12)
?0162:
; 586. }
; 587. pq->OSQOut--;
ADD #-2,8(R12)
; 588. *pq->OSQOut = msg; /* Insert message into queue */
MOV 8(R12),R13
MOV R10,0(R13)
; 589. } else { /* No, Post as FIFO */
JMP (?0165)
?0160:
; 590. *pq->OSQIn++ = msg; /* Insert message into queue */
MOV 6(R12),R13
ADD #2,6(R12)
MOV R10,0(R13)
; 591. if (pq->OSQIn == pq->OSQEnd) { /* Wrap IN ptr if we are at end of queue */
CMP 6(R12),4(R12)
JNE (?0165)
; 592. pq->OSQIn = pq->OSQStart;
MOV 2(R12),6(R12)
?0165:
; 593. }
; 594. }
; 595. pq->OSQEntries++; /* Update the nbr of entries in the queue */
ADD #1,12(R12)
; 596. OS_EXIT_CRITICAL();
EINT
; 597. return (OS_NO_ERR);
MOV.B #0,R12
; 598. }
?0166:
POP R11
POP R10
RET
OSQQuery:
; 599. #endif
; 600. /*$PAGE*/
; 601. /*
; 602. *********************************************************************************************************
; 603. * QUERY A MESSAGE QUEUE
; 604. *
; 605. * Description: This function obtains information about a message queue.
; 606. *
; 607. * Arguments : pevent is a pointer to the event control block associated with the desired queue
; 608. *
; 609. * pdata is a pointer to a structure that will contain information about the message
; 610. * queue.
; 611. *
; 612. * Returns : OS_NO_ERR The call was successful and the message was sent
; 613. * OS_ERR_EVENT_TYPE If you are attempting to obtain data from a non queue.
; 614. * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
; 615. *********************************************************************************************************
; 616. */
; 617.
; 618. #if OS_Q_QUERY_EN > 0
; 619. INT8U OSQQuery (OS_EVENT *pevent, OS_Q_DATA *pdata)
; 620. {
; 621. #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
; 622. OS_CPU_SR cpu_sr;
; 623. #endif
; 624. OS_Q *pq;
; 625. INT8U *psrc;
; 626. INT8U *pdest;
; 627.
; 628.
; 629. #if OS_ARG_CHK_EN > 0
; 630. if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
CMP #0,R12
JNE (?0168)
; 631. return (OS_ERR_PEVENT_NULL);
MOV.B #4,R12
; 632. }
RET
?0168:
; 633. if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
MOV.B #2,R13
CMP.B @R12,R13
JEQ (?0170)
; 634. return (OS_ERR_EVENT_TYPE);
MOV.B #1,R12
; 635. }
RET
?0170:
; 636. #endif
; 637. OS_ENTER_CRITICAL();
DINT
; 638. pdata->OSEventGrp = pevent->OSEventGrp; /* Copy message queue wait list */
MOV.B 1(R12),8(R14)
; 639. psrc = &pevent->OSEventTbl[0];
MOV R12,R15
ADD #6,R15
; 640. pdest = &pdata->OSEventTbl[0];
MOV R14,R13
ADD #6,R13
; 641. #if OS_EVENT_TBL_SIZE > 0
; 642. *pdest++ = *psrc++;
MOV.B @R15+,0(R13)
ADD #1,R13
; 643. #endif
; 644.
; 645. #if OS_EVENT_TBL_SIZE > 1
; 646. *pdest++ = *psrc++;
MOV.B @R15+,0(R13)
; 647. #endif
; 648.
; 649. #if OS_EVENT_TBL_SIZE > 2
; 650. *pdest++ = *psrc++;
; 651. #endif
; 652.
; 653. #if OS_EVENT_TBL_SIZE > 3
; 654. *pdest++ = *psrc++;
; 655. #endif
; 656.
; 657. #if OS_EVENT_TBL_SIZE > 4
; 658. *pdest++ = *psrc++;
; 659. #endif
; 660.
; 661. #if OS_EVENT_TBL_SIZE > 5
; 662. *pdest++ = *psrc++;
; 663. #endif
; 664.
; 665. #if OS_EVENT_TBL_SIZE > 6
; 666. *pdest++ = *psrc++;
; 667. #endif
; 668.
; 669. #if OS_EVENT_TBL_SIZE > 7
; 670. *pdest = *psrc;
; 671. #endif
; 672. pq = (OS_Q *)pevent->OSEventPtr;
MOV 4(R12),R13
; 673. if (pq->OSQEntries > 0) {
CMP #0,12(R13)
JEQ (?0172)
; 674. pdata->OSMsg = *pq->OSQOut; /* Get next message to return if available */
MOV 8(R13),R12
MOV @R12,0(R14)
; 675. } else {
JMP (?0173)
?0172:
; 676. pdata->OSMsg = (void *)0;
MOV #0,0(R14)
?0173:
; 677. }
; 678. pdata->OSNMsgs = pq->OSQEntries;
MOV 12(R13),2(R14)
; 679. pdata->OSQSize = pq->OSQSize;
MOV 10(R13),4(R14)
; 680. OS_EXIT_CRITICAL();
EINT
; 681. return (OS_NO_ERR);
MOV.B #0,R12
; 682. }
RET
OS_QInit:
; 683. #endif /* OS_Q_QUERY_EN */
; 684.
; 685. /*$PAGE*/
; 686. /*
; 687. *********************************************************************************************************
; 688. * QUEUE MODULE INITIALIZATION
; 689. *
; 690. * Description : This function is called by uC/OS-II to initialize the message queue module. Your
; 691. * application MUST NOT call this function.
; 692. *
; 693. * Arguments : none
; 694. *
; 695. * Returns : none
; 696. *
; 697. * Note(s) : This function is INTERNAL to uC/OS-II and your application should not call it.
; 698. *********************************************************************************************************
; 699. */
; 700.
; 701. void OS_QInit (void)
; 702. {
; 703. #if OS_MAX_QS == 1
; 704. OSQFreeList = &OSQTbl[0]; /* Only ONE queue! */
; 705. OSQFreeList->OSQPtr = (OS_Q *)0;
; 706. #endif
; 707.
; 708. #if OS_MAX_QS >= 2
; 709. INT16U i;
; 710. OS_Q *pq1;
; 711. OS_Q *pq2;
; 712.
; 713.
; 714. pq1 = &OSQTbl[0];
MOV #OSQTbl,R14
; 715. pq2 = &OSQTbl[1];
MOV #(OSQTbl+14),R13
; 716. for (i = 0; i < (OS_MAX_QS - 1); i++) { /* Init. list of free QUEUE control blocks */
MOV #0,R12
?0176:
CMP #1,R12
JC (?0175)
; 717. pq1->OSQPtr = pq2;
MOV R13,0(R14)
; 718. pq1++;
ADD #14,R14
; 719. pq2++;
ADD #14,R13
ADD #1,R12
JMP (?0176)
?0175:
; 720. }
; 721. pq1->OSQPtr = (OS_Q *)0;
MOV #0,0(R14)
; 722. OSQFreeList = &OSQTbl[0];
MOV #OSQTbl,&OSQFreeList
; 723. #endif
; 724. }
RET
; 725. #endif /* OS_Q_EN */
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -