gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/sysmgr.hbare sourcepermlink (0.04 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      sysmgr.h
   16:  *      micro T-Kernel/SM(System Maneger) Definition
   17:  */
   18: 
   19: #ifndef _SYSMGR_
   20: #define _SYSMGR_
   21: 
   22: #include <tk/tkernel.h>
   23: #include <sys/queue.h>
   24: 
   25: #include "kernel.h"
   26: 
   27: 
   28: /* ------------------------------------------------------------------------ */
   29: /*
   30:  *      Device management function
   31:  */
   32: 
   33: /*
   34:  * Lock for device management exclusive control
   35:  */
   36: IMPORT FastMLock        knl_DevMgrLock;
   37: #define LockDM()        MLock(&knl_DevMgrLock, 0)
   38: #define UnlockDM()      MUnlock(&knl_DevMgrLock, 0)
   39: 
   40: /*
   41:  * Lock for device registration exclusive control
   42:  */
   43: #define LockREG()       MLock(&knl_DevMgrLock, 1)
   44: #define UnlockREG()     MUnlock(&knl_DevMgrLock, 1)
   45: 
   46: /*
   47:  * Device registration information
   48:  */
   49: typedef struct DeviceControlBlock {
   50:         QUEUE  q;
   51:         UB     devnm[L_DEVNM+1];   /* Device name */
   52:         T_DDEV ddev;                   /* Registration information */
   53:         QUEUE  openq;                   /* Open device management queue */
   54: } DevCB;
   55: 
   56: IMPORT  DevCB            knl_DevCBtbl[];   /* Device registration information
   57:                                            table */
   58: IMPORT  QUEUE            knl_UsedDevCB;    /* In-use queue */
   59: 
   60: #define DID(devcb)              ( ((devcb) - knl_DevCBtbl + 1) << 8 )
   61: #define DEVID(devcb, unitno)    ( DID(devcb) + (unitno) )
   62: #define DEVCB(devid)            ( knl_DevCBtbl + (((devid) >> 8) - 1) )
   63: #define UNITNO(devid)           ( (devid) & 0xff )
   64: 
   65: /*
   66:  * Open management information
   67:  */
   68: typedef struct OpenControlBlock {
   69:         QUEUE          q;
   70:         QUEUE          resq;           /* For connection from resource
   71:                                            management */
   72:         ID             resid;             /* Section resource ID */
   73:         DevCB          *devcb;         /* Target device */
   74:         INT            unitno;           /* Subunit number
   75:                                            (0: Physical device) */
   76:         UINT           omode;           /* Open mode */
   77:         QUEUE          requestq;       /* Request management queue */
   78:         UH             waitone;   /* Number of individual request
   79:                                            waits */
   80:         T_DEVREQ       *waireqlst;   /* List of multiple request waits */
   81:         INT            nwaireq;  /* Number of multiple request waits */
   82:         ID             abort_tskid;       /* Abort completion wait task */
   83:         INT            abort_cnt;        /* Number of abort completion wait
   84:                                            requests */
   85:         ID             abort_semid; /* Semaphore for abort completion wait */
   86: } OpnCB;
   87: 
   88: #define RESQ_OPNCB(rq)          ( (OpnCB*)((B*)(rq) - offsetof(OpnCB, resq)) )
   89: 
   90: /*
   91:  * Request management information
   92:  */
   93: typedef struct RequestControlBlock {
   94:         QUEUE          q;
   95:         OpnCB          *opncb;         /* Open device */
   96:         ID             tskid;             /* Processing task */
   97:         T_DEVREQ       req;          /* Request packet */
   98: } ReqCB;
   99: 
  100: /*
  101:  * Resource management information
  102:  */
  103: typedef struct ResourceControlBlock {
  104:         QUEUE          openq;          /* Open device management queue */
  105:         INT            dissus;           /* Suspend disable request count */
  106: } ResCB;
  107: 
  108: /*
  109:  * Request function types
  110:  */
  111: 
  112: typedef ER  (*OPNFN)( ID devid, UINT omode, void *exinf );
  113: typedef ER  (*ABTFN)( ID tskid, T_DEVREQ *devreq, INT nreq, void *exinf );
  114: typedef INT (*WAIFN)( T_DEVREQ *devreq, INT nreq, TMO tmout, void *exinf );
  115: typedef INT (*EVTFN)( INT evttyp, void *evtinf, void *exinf );
  116: typedef ER  (*CLSFN)( ID devid, UINT option, void *exinf );
  117: typedef ER  (*EXCFN)( T_DEVREQ *devreq, TMO tmout, void *exinf );
  118: 
  119: /* ------------------------------------------------------------------------ */
  120: 
  121: #define IMPORT_DEFINE   1
  122: #if IMPORT_DEFINE
  123: /* device.c */
  124: IMPORT  FastMLock        knl_DevMgrLock;
  125: IMPORT  DevCB            knl_DevCBtbl[];
  126: IMPORT  QUEUE            knl_UsedDevCB;
  127: IMPORT  DevCB*           knl_searchDevCB( CONST UB *devnm );
  128: IMPORT  INT                      knl_phydevnm( UB *pdevnm, CONST UB *ldevnm );
  129: IMPORT  ER                       knl_initialize_devmgr( void );
  130: IMPORT  ER                       knl_finish_devmgr( void );
  131: /* deviceio.c */
  132: IMPORT ER knl_check_devdesc( ID dd, UINT mode, OpnCB **p_opncb );
  133: IMPORT void knl_devmgr_startup( void );
  134: IMPORT void knl_devmgr_cleanup( void );
  135: IMPORT ER knl_initDevIO( void );
  136: IMPORT ER knl_finishDevIO( void );
  137: 
  138: #endif
  139: 
  140: #endif /* _SYSMGR_ */