⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_q.lst

📁 uCOS 嵌入式操作系统的改进版,增加了网络通讯.
💻 LST
📖 第 1 页 / 共 4 页
字号:
 579          {
 580   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 581   1          OS_CPU_SR  cpu_sr;
 582   1      #endif
 583   1          OS_Q      *pq;
 584   1      
 585   1      
 586   1      #if OS_ARG_CHK_EN > 0
 587   1          if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
 588   2              return (OS_ERR_PEVENT_NULL);
 589   2          }
 590   1          if (msg == (void *)0) {                           /* Make sure we are not posting a NULL pointer   */
 591   2              return (OS_ERR_POST_NULL_PTR);
 592   2          }
 593   1      #endif
 594   1          if (pevent->OSEventType != OS_EVENT_TYPE_Q) {     /* Validate event block type                     */
 595   2              return (OS_ERR_EVENT_TYPE);
 596   2          }
 597   1          OS_ENTER_CRITICAL();
 598   1          if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on queue              */
 599   2              if ((opt & OS_POST_OPT_BROADCAST) != 0x00) {  /* Do we need to post msg to ALL waiting tasks ? */
 600   3                  while (pevent->OSEventGrp != 0x00) {      /* Yes, Post to ALL tasks waiting on queue       */
 601   4                      OS_EventTaskRdy(pevent, msg, OS_STAT_Q);
 602   4                  }
 603   3              } else {
 604   3                  OS_EventTaskRdy(pevent, msg, OS_STAT_Q);  /* No,  Post to HPT waiting on queue             */
 605   3              }
 606   2              OS_EXIT_CRITICAL();
 607   2              OS_Sched();                                   /* Find highest priority task ready to run       */
 608   2              return (OS_NO_ERR);
 609   2          }
 610   1          pq = (OS_Q *)pevent->OSEventPtr;                  /* Point to queue control block                  */
 611   1          if (pq->OSQEntries >= pq->OSQSize) {              /* Make sure queue is not full                   */
 612   2              OS_EXIT_CRITICAL();
C51 COMPILER V7.06   OS_Q                                                                  07/18/2003 11:06:02 PAGE 11  

 613   2              return (OS_Q_FULL);
 614   2          }
 615   1          if ((opt & OS_POST_OPT_FRONT) != 0x00) {          /* Do we post to the FRONT of the queue?         */
 616   2              if (pq->OSQOut == pq->OSQStart) {             /* Yes, Post as LIFO, Wrap OUT pointer if we ... */
 617   3                  pq->OSQOut = pq->OSQEnd;                  /*      ... are at the 1st queue entry           */
 618   3              }
 619   2              pq->OSQOut--;
 620   2              *pq->OSQOut = msg;                            /*      Insert message into queue                */
 621   2          } else {                                          /* No,  Post as FIFO                             */
 622   2              *pq->OSQIn++ = msg;                           /*      Insert message into queue                */
 623   2              if (pq->OSQIn == pq->OSQEnd) {                /*      Wrap IN ptr if we are at end of queue    */
 624   3                  pq->OSQIn = pq->OSQStart;
 625   3              }
 626   2          }
 627   1          pq->OSQEntries++;                                 /* Update the nbr of entries in the queue        */
 628   1          OS_EXIT_CRITICAL();
 629   1          return (OS_NO_ERR);
 630   1      }
 631          #endif
 632          /*$PAGE*/
 633          /*
 634          *********************************************************************************************************
 635          *                                        QUERY A MESSAGE QUEUE
 636          *
 637          * Description: This function obtains information about a message queue.
 638          *
 639          * Arguments  : pevent        is a pointer to the event control block associated with the desired queue
 640          *
 641          *              pdata         is a pointer to a structure that will contain information about the message
 642          *                            queue.
 643          *
 644          * Returns    : OS_NO_ERR           The call was successful and the message was sent
 645          *              OS_ERR_EVENT_TYPE   If you are attempting to obtain data from a non queue.
 646          *              OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
 647          *********************************************************************************************************
 648          */
 649          
 650          #if OS_Q_QUERY_EN > 0
 651          INT8U  OSQQuery (OS_EVENT *pevent, OS_Q_DATA *pndata) reentrant //using 0
 652          {
 653   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 654   1          OS_CPU_SR  cpu_sr;
 655   1      #endif
 656   1          OS_Q      *pq;
 657   1          INT8U     *psrc;
 658   1          INT8U     *pdest;
 659   1      
 660   1      
 661   1      #if OS_ARG_CHK_EN > 0
 662   1          if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
 663   2              return (OS_ERR_PEVENT_NULL);
 664   2          }
 665   1      #endif
 666   1          if (pevent->OSEventType != OS_EVENT_TYPE_Q) {          /* Validate event block type                */
 667   2              return (OS_ERR_EVENT_TYPE);
 668   2          }
 669   1          OS_ENTER_CRITICAL();
 670   1          pndata->OSEventGrp = pevent->OSEventGrp;                /* Copy message queue wait list           */
 671   1          psrc              = &pevent->OSEventTbl[0];
 672   1          pdest             = &pndata->OSEventTbl[0];
 673   1      #if OS_EVENT_TBL_SIZE > 0
 674   1          *pdest++          = *psrc++;
C51 COMPILER V7.06   OS_Q                                                                  07/18/2003 11:06:02 PAGE 12  

 675   1      #endif
 676   1      
 677   1      #if OS_EVENT_TBL_SIZE > 1
 678   1          *pdest++          = *psrc++;
 679   1      #endif
 680   1      
 681   1      #if OS_EVENT_TBL_SIZE > 2
 682   1          *pdest++          = *psrc++;
 683   1      #endif
 684   1      
 685   1      #if OS_EVENT_TBL_SIZE > 3
 686   1          *pdest++          = *psrc++;
 687   1      #endif
 688   1      
 689   1      #if OS_EVENT_TBL_SIZE > 4
 690   1          *pdest++          = *psrc++;
 691   1      #endif
 692   1      
 693   1      #if OS_EVENT_TBL_SIZE > 5
 694   1          *pdest++          = *psrc++;
 695   1      #endif
 696   1      
 697   1      #if OS_EVENT_TBL_SIZE > 6
 698   1          *pdest++          = *psrc++;
 699   1      #endif
 700   1      
 701   1      #if OS_EVENT_TBL_SIZE > 7
 702   1          *pdest            = *psrc;
 703   1      #endif
 704   1          pq = (OS_Q *)pevent->OSEventPtr;
 705   1          if (pq->OSQEntries > 0) {
 706   2              pndata->OSMsg = *pq->OSQOut;                        /* Get next message to return if available  */
 707   2          } else {
 708   2              pndata->OSMsg = (void *)0;
 709   2          }
 710   1          pndata->OSNMsgs = pq->OSQEntries;
 711   1          pndata->OSQSize = pq->OSQSize;
 712   1          OS_EXIT_CRITICAL();
 713   1          return (OS_NO_ERR);
 714   1      }
 715          #endif                                                     /* OS_Q_QUERY_EN                            */
 716          
 717          /*$PAGE*/
 718          /*
 719          *********************************************************************************************************
 720          *                                      QUEUE MODULE INITIALIZATION
 721          *
 722          * Description : This function is called by uC/OS-II to initialize the message queue module.  Your
 723          *               application MUST NOT call this function.
 724          *
 725          * Arguments   :  none
 726          *
 727          * Returns     : none
 728          *
 729          * Note(s)    : This function is INTERNAL to uC/OS-II and your application should not call it.
 730          *********************************************************************************************************
 731          */
 732          
 733          void  OS_QInit (void) reentrant //using 0
 734          {
 735   1      #if OS_MAX_QS == 1
                  OSQFreeList         = &OSQTbl[0];            /* Only ONE queue!                                    */
C51 COMPILER V7.06   OS_Q                                                                  07/18/2003 11:06:02 PAGE 13  

                  OSQFreeList->OSQPtr = (OS_Q *)0;
              #endif
 739   1      
 740   1      #if OS_MAX_QS >= 2
 741   1          INT16U  i;
 742   1          OS_Q   *pq1;
 743   1          OS_Q   *pq2;
 744   1      
 745   1      
 746   1          (void)memset(&OSQTbl[0], 0, sizeof(OSQTbl)); /* Clear the queue table                              */
 747   1          pq1 = &OSQTbl[0];
 748   1          pq2 = &OSQTbl[1];
 749   1          for (i = 0; i < (OS_MAX_QS - 1); i++) {      /* Init. list of free QUEUE control blocks            */
 750   2              pq1->OSQPtr = pq2;
 751   2              pq1++;
 752   2              pq2++;
 753   2          }
 754   1          pq1->OSQPtr = (OS_Q *)0;
 755   1          OSQFreeList = &OSQTbl[0];
 756   1      #endif
 757   1      }
 758          #endif                                           /* OS_Q_EN                                            */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   5701    ----
   CONSTANT SIZE    =      2    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -