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

📄 ss_drvr.c

📁 中国石油二期加油站IC系统后台通讯软件
💻 C
字号:

/********************************************************************20**
 
     Name:     System Services -- Driver
 
     Type:     C source file
 
     Desc:     Source code for those functions in System Services
               that exist for driver support.
 
     File:     ss_drvr.c
 
     Sid:      ss_drvr.c 1.2  -  08/11/98 10:46:54
 
     Prg:      kp
  
*********************************************************************21*/



/* header include files (.h) */

#include "envopt.h"        /* environment options */
#include "envdep.h"        /* environment dependent */
#include "envind.h"        /* environment independent */

#include "gen.h"           /* general layer */
#include "ssi.h"           /* system services */

#include "ss_err.h"        /* errors */
#include "ss_dep.h"        /* implementation-specific */
#include "ss_queue.h"      /* queues */
#include "ss_msg.h"        /* messaging */
#include "ss_mem.h"        /* memory management interface */
#include "ss_gen.h"        /* general */



/* header/extern include files (.x) */

#include "gen.x"           /* general layer */
#include "ssi.x"           /* system services */


#include "ss_dep.x"        /* implementation-specific */
#include "ss_queue.x"      /* queues */
#include "ss_task.x"       /* tasking */
#include "ss_timer.x"      /* timers */
#include "ss_strm.x"       /* STREAMS */
#include "ss_msg.x"        /* messaging */
#include "ss_mem.x"        /* memory management interface */
#include "ss_drvr.x"       /* driver tasks */
#include "ss_gen.x"        /* general */


#ifdef SS_DRVR_SUPPORT



/*
*
*       Fun:   SRegDrvrTsk
*
*       Desc:  This function is used to register a driver task.
*
*       Ret:   ROK      - ok
*              RFAILED  - failed, general (optional)
*              ROUTRES  - failed, out of resources (optional)
*
*       Notes:
*
*       File:  ss_drvr.c
*
*/
    #ifdef ANSI
PUBLIC S16 SRegDrvrTsk
(
Inst channel,                   /* channel instance */
ProcId low,                     /* processor ID -- low */
ProcId high,                    /* processor ID -- high */
ActvTsk actvTsk,                /* activation function */
ISTsk isTsk                     /* interrupt service function */
)
    #else
PUBLIC S16 SRegDrvrTsk(channel, low, high, actvTsk, isTsk)
Inst channel;                   /* channel instance */
ProcId low;                     /* processor ID -- low */
ProcId high;                    /* processor ID -- high */
ActvTsk actvTsk;                /* activation function */
ISTsk isTsk;                    /* interrupt service function */
    #endif
{
    S16 ret;
#if (ERRCLASS & ERRCLS_INT_PAR)
    ProcId thisProcId;
#endif


    TRC1(SRegDrvrTsk);


#if (ERRCLASS & ERRCLS_INT_PAR)
    thisProcId = SFndProcId();
    if (thisProcId >= low  &&  thisProcId <= high)
    {
        SSLOGERROR(ERRCLS_INT_PAR, ESS197, ERRZERO, "Invalid procId range");
        RETVALUE(RFAILED);
    }

    if (channel >= SS_MAX_DRVRTSKS)
    {
        SSLOGERROR(ERRCLS_INT_PAR, ESS198, channel, "Invalid channel");
        RETVALUE(RFAILED);
    }

    /* check activation functions */
    if (actvTsk == NULLP  ||  isTsk == NULLP)
    {
        SSLOGERROR(ERRCLS_INT_PAR, ESS199, ERRZERO, "Null pointer");
        RETVALUE(RFAILED);
    }

    /* check if already registered */
    if (osCp.drvrTskTbl[channel].used == TRUE)
    {
        SSLOGERROR(ERRCLS_INT_PAR, ESS200, ERRZERO,
                   "Driver task already registered");
        RETVALUE(RFAILED);
    }
#endif


#if (ERRCLASS & ERRCLS_DEBUG)
    /* check count of tasks */
    if (osCp.numDrvrTsks == SS_MAX_DRVRTSKS)
    {
        SSLOGERROR(ERRCLS_DEBUG, ESS201, ERRZERO, "Too many tasks");
        RETVALUE(ROUTRES);
    }
#endif


    if (SInitLock(&osCp.drvrTskTbl[channel].lock, SS_DRVRENTRY_LOCK) != ROK)
    {

#if (ERRCLASS & ERRCLS_DEBUG)
        SSLOGERROR(ERRCLS_DEBUG, ESS202, ERRZERO, "Could not initialize lock");
#endif

        RETVALUE(RFAILED);
    }

    osCp.drvrTskTbl[channel].channel = channel;
    osCp.drvrTskTbl[channel].actvTsk = actvTsk;
    osCp.drvrTskTbl[channel].isTsk = isTsk;
    osCp.drvrTskTbl[channel].low = low;
    osCp.drvrTskTbl[channel].high = high;

    ret = ssdRegDrvrTsk(&osCp.drvrTskTbl[channel]);
    if (ret != ROK)
    {
        osCp.drvrTskTbl[channel].channel = 0;
        osCp.drvrTskTbl[channel].actvTsk = NULLP;
        osCp.drvrTskTbl[channel].isTsk = NULLP;
        osCp.drvrTskTbl[channel].low = 0;
        osCp.drvrTskTbl[channel].high = 0;
        SDestroyLock(&osCp.drvrTskTbl[channel].lock);
    } else
    {
        osCp.drvrTskTbl[channel].used = TRUE;
        osCp.numDrvrTsks++;
    }


    RETVALUE(ret);
}


#endif /* SS_DRVR_SUPPORT */



/********************************************************************30**
  
         End of file: ss_drvr.c 1.2  -  08/11/98 10:46:54
  
*********************************************************************31*/

  
/********************************************************************40**
  
        Notes: 
  
*********************************************************************41*/

/********************************************************************50**

*********************************************************************51*/

   
/********************************************************************60**
  
        Revision history:
  
*********************************************************************61*/

/********************************************************************90**
 
     ver       pat    init                  description
------------ -------- ---- ----------------------------------------------
1.1          ---      kp   1. initial release

1.2          ---      kp   1. cosmetic changes, error codes regenerated

*********************************************************************91*/

⌨️ 快捷键说明

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