os_core.ls1

来自「在51单片机上移植成功的UCOS-II操作系统源代码,包括源代码及相关注释」· LS1 代码 · 共 1,120 行 · 第 1/5 页

LS1
1,120
字号
0103 00              427             DB      000H
0104 02              428             DB      002H
0105 00              429             DB      000H
0106 01              430             DB      001H
0107 00              431             DB      000H
                     432     
                     433     ; /*
                     434     ; *****************************************************************************************
                             ****************
                     435     ; *                                                uC/OS-II
                     436     ; *                                          The Real-Time Kernel
                     437     ; *                                             CORE FUNCTIONS
                     438     ; *
                     439     ; *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
                     440     ; *                                           All Rights Reserved
                     441     ; *
                     442     ; *                                                  V2.00
                     443     ; *
                     444     ; * File : OS_CORE.C
                     445     ; * By   : Jean J. Labrosse
                     446     ; *****************************************************************************************
                             ****************
                     447     ; */
                     448     ; 
                     449     ; #ifndef  OS_MASTER_FILE
                     450     ; #define  OS_GLOBALS
                     451     ; #include "includes.h"
A51 MACRO ASSEMBLER  OS_CORE                                                              09/09/2007 21:12:24 PAGE     8

                     452     ; #endif
                     453     ; 
                     454     ; /*
                     455     ; *****************************************************************************************
                             ****************
                     456     ; *                                         LOCAL GLOBAL VARIABLES
                     457     ; *****************************************************************************************
                             ****************
                     458     ; */
                     459     ;                                        
                     460     ; static  INT8U        OSIntExitY;               /* Variable used by 'OSIntExit' to prevent
                              using locals */
                     461     ; 
                     462     ; static  OS_STK       OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE];       /* Idle       task stack
                                           */
                     463     ; 
                     464     ; #if     OS_TASK_STAT_EN
                     465     ; static  OS_STK       OSTaskStatStk[OS_TASK_STAT_STK_SIZE];      /* Statistics task stack 
                                           */
                     466     ; #endif
                     467     ; 
                     468     ; static  OS_TCB       OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS];   /* Table of TCBs         
                                           */
                     469     ; 
                     470     ; /*$PAGE*/
                     471     ; /*
                     472     ; *****************************************************************************************
                             ****************
                     473     ; *                              MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
                     474     ; *
                     475     ; * Note: Index into table is desired bit position, 0..7
                     476     ; *       Indexed value corresponds to bit mask
                     477     ; *****************************************************************************************
                             ****************
                     478     ; */
                     479     ; 
                     480     ; INT8U const code OSMapTbl[]   = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
                     481     ; 
                     482     ; /*
                     483     ; *****************************************************************************************
                             ****************
                     484     ; *                                       PRIORITY RESOLUTION TABLE
                     485     ; *
                     486     ; * Note: Index into table is bit pattern to resolve highest priority
                     487     ; *       Indexed value corresponds to highest priority bit position (i.e. 0..7)
                     488     ; *****************************************************************************************
                             ****************
                     489     ; */
                     490     ; 
                     491     ; INT8U const code OSUnMapTbl[] = {
                     492     ;     0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     493     ;     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     494     ;     5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     495     ;     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     496     ;     6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     497     ;     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     498     ;     5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     499     ;     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     500     ;     7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     501     ;     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     502     ;     5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     503     ;     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     504     ;     6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     505     ;     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     506     ;     5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
                     507     ;     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
A51 MACRO ASSEMBLER  OS_CORE                                                              09/09/2007 21:12:24 PAGE     9

                     508     ; };
                     509     ; 
                     510     ; /*$PAGE*/
                     511     ; /*
                     512     ; *****************************************************************************************
                             ****************
                     513     ; *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
                     514     ; *
                     515     ; * Description: This function is called by other uC/OS-II services and is used to ready a 
                             task that was
                     516     ; *              waiting for an event to occur.
                     517     ; *
                     518     ; * Arguments  : pevent    is a pointer to the event control block corresponding to the eve
                             nt.
                     519     ; *
                     520     ; *              msg       is a pointer to a message.  This pointer is used by message orie
                             nted services
                     521     ; *                        such as MAILBOXEs and QUEUEs.  The pointer is not used when call
                             ed by other
                     522     ; *                        service functions.
                     523     ; *
                     524     ; *              msk       is a mask that is used to clear the status byte of the TCB.  For
                              example,
                     525     ; *                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STA
                             T_MBOX etc.
                     526     ; *
                     527     ; * Returns    : none
                     528     ; *
                     529     ; * Note       : This function is INTERNAL to uC/OS-II and your application should not call
                              it.
                     530     ; *****************************************************************************************
                             ****************
                     531     ; */
                     532     ; #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
                     533     ; void  OSEventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk) reentrant
                     534     ; {
                     535     ;     OS_TCB *ptcb;
                     536     ;     INT8U   x;
                     537     ;     INT8U   y;
                     538     ;     INT8U   bitx;
                     539     ;     INT8U   bity;
                     540     ;     INT8U   prio;
                     541     ; 
                     542     ; 
                     543     ;     y    = OSUnMapTbl[pevent->OSEventGrp];            /* Find highest prio. task waiting 
                             for message   */
                     544     ;     bity = OSMapTbl[y];
                     545     ;     x    = OSUnMapTbl[pevent->OSEventTbl[y]];
                     546     ;     bitx = OSMapTbl[x];
                     547     ;     prio = (INT8U)((y << 3) + x);                     /* Find priority of task getting th
                             e msg         */
                     548     ;     if ((pevent->OSEventTbl[y] &= ~bitx) == 0) {      /* Remove this task from the waitin
                             g list        */
                     549     ;         pevent->OSEventGrp &= ~bity;
                     550     ;     }
                     551     ;     ptcb                 =  OSTCBPrioTbl[prio];       /* Point to this task's OS_TCB     
                                           */
                     552     ;     ptcb->OSTCBDly       =  0;                        /* Prevent OSTimeTick() from readyi
                             ng task       */
                     553     ;     ptcb->OSTCBEventPtr  = (OS_EVENT *)0;             /* Unlink ECB from this task       
                                           */
                     554     ; #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN
                     555     ;     ptcb->OSTCBMsg       = msg;                       /* Send message directly to waiting
                              task         */
                     556     ; #else
                     557     ;     msg                  = msg;                       /* Prevent compiler warning if not 
A51 MACRO ASSEMBLER  OS_CORE                                                              09/09/2007 21:12:24 PAGE    10

                             used          */    
                     558     ; #endif    
                     559     ;     ptcb->OSTCBStat     &= ~msk;                      /* Clear bit associated with event 
                             type          */
                     560     ;     if (ptcb->OSTCBStat == OS_STAT_RDY) {             /* See if task is ready (could be s
                             usp'd)        */
                     561     ;         OSRdyGrp        |=  bity;                     /* Put task in the ready to run lis
                             t             */
                     562     ;         OSRdyTbl[y]     |=  bitx;
                     563     ;     }
                     564     ; }
                     565     ; #endif
                     566     ; /*$PAGE*/
                     567     ; /*
                     568     ; *****************************************************************************************
                             ****************
                     569     ; *                                   MAKE TASK WAIT FOR EVENT TO OCCUR
                     570     ; *
                     571     ; * Description: This function is called by other uC/OS-II services to suspend a task becau
                             se an event has
                     572     ; *              not occurred.
                     573     ; *
                     574     ; * Arguments  : pevent   is a pointer to the event control block for which the task will b
                             e waiting for.
                     575     ; *
                     576     ; * Returns    : none
                     577     ; *
                     578     ; * Note       : This function is INTERNAL to uC/OS-II and your application should not call
                              it.
                     579     ; *****************************************************************************************
                             ****************
                     580     ; */
                     581     ; #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
                     582     ; void  OSEventTaskWait (OS_EVENT *pevent) reentrant
                     583     ; {
                     584     ;     OSTCBCur->OSTCBEventPtr = pevent;            /* Store pointer to event control block 
                             in TCB        */
                     585     ;     if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {      /* Task no long
                             er ready      */
                     586     ;         OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
                     587     ;     }
                     588     ;     pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX;          /* Put task in 
                             waiting list  */
                     589     ;     pevent->OSEventGrp                   |= OSTCBCur->OSTCBBitY;
                     590     ; }
                     591     ; #endif
                     592     ; /*$PAGE*/
                     593     ; /*
                     594     ; *****************************************************************************************
                             ****************
                     595     ; *                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
                     596     ; *
                     597     ; * Description: This function is called by other uC/OS-II services to make a task ready to
                              run because a
                     598     ; *              timeout occurred.
                     599     ; *
                     600     ; * Arguments  : pevent   is a pointer to the event control block which is readying a task.
                     601     ; *
                     602     ; * Returns    : none

⌨️ 快捷键说明

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