gonzui


Format: Advanced Search

mtkernel_3/kernel/tkernel/device.hbare sourcepermlink (0.02 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:  *      device.h
   16:  *      Device Management Function
   17:  */
   18: 
   19: #ifndef _DEVICE_H_
   20: #define _DEVICE_H_
   21: 
   22: /* Set Object Name in .exinf for DEBUG */
   23: #define OBJNAME_DMMBF   "DEvt"            /* Event notification mbf */
   24: #define OBJNAME_DMSEM   "DMSy"            /* semaphore of synchronous control */
   25: #define OBJNAME_DMLOCK  "DMLk"           /* Multi-lock for Dev.Mgr. */
   26: 
   27: IMPORT  T_IDEV           knl_DefaultIDev;
   28: 
   29: /*
   30:  *      Device registration management
   31:  */
   32: 
   33: IMPORT DevCB knl_DevCBtbl[];    /* Device registration information table */
   34: IMPORT QUEUE knl_UsedDevCB;     /* In-use queue */
   35: IMPORT QUEUE knl_FreeDevCB;     /* Unused queue */
   36: 
   37: #define MAX_UNIT        255            /* Maximum number of subunits */
   38: 
   39: /*
   40:  * Verify validity of device ID
   41:  */
   42: Inline ER knl_check_devid( ID devid )
   43: {
   44:         devid >>= 8;
   45:         if ( devid < 1 || devid > MAX_REGDEV ) {
   46:                 return E_ID;
   47:         }
   48:         return E_OK;
   49: }
   50: 
   51: /*
   52:  * Device Management: Input/Output
   53:  */
   54: IMPORT OpnCB knl_OpnCBtbl[];    /* Open management information table */
   55: IMPORT QUEUE knl_FreeOpnCB;     /* Unused queue */
   56: 
   57: #define DD(opncb)               ( (opncb) - knl_OpnCBtbl + 1 )
   58: #define OPNCB(dd)               ( knl_OpnCBtbl + ((dd) - 1) )
   59: 
   60: IMPORT ReqCB knl_ReqCBtbl[];    /* Request management information table */
   61: IMPORT QUEUE knl_FreeReqCB;     /* Unused queue */
   62: 
   63: #define REQID(reqcb)            ( (reqcb) - knl_ReqCBtbl + 1 )
   64: #define REQCB(reqid)            ( knl_ReqCBtbl + ((reqid) - 1) )
   65: 
   66: #define DEVREQ_REQCB(devreq)    ((ReqCB*)((B*)(devreq) - offsetof(ReqCB, req)))
   67: 
   68: IMPORT ResCB knl_resource_control_block;
   69: 
   70: 
   71: #include "limits.h"
   72: 
   73: /* Suspend disable request count */
   74: IMPORT  INT      knl_DisSusCnt;
   75: 
   76: /* Maximum number of suspend disable request counts */
   77: #define MAX_DISSUS      INT_MAX
   78: 
   79: 
   80: /*
   81:  * Device driver abort function call
   82:  */
   83: Inline ER knl_call_abortfn( DevCB *devcb, ID tskid, T_DEVREQ *devreq, INT nreq )
   84: {
   85:         ER ercd;
   86:         ABTFN  abortfn;
   87: 
   88:         abortfn = (ABTFN)devcb->ddev.abortfn;
   89: 
   90:         DISABLE_INTERRUPT;
   91:         knl_ctxtsk->sysmode++;
   92:         ENABLE_INTERRUPT;
   93:         ercd = (*abortfn)(tskid, devreq, nreq, devcb->ddev.exinf);
   94:         DISABLE_INTERRUPT;
   95:         knl_ctxtsk->sysmode--;
   96:         ENABLE_INTERRUPT;
   97: 
   98:         return ercd;
   99: }
  100: 
  101: 
  102: IMPORT ID knl_request( ID dd, W start, void *buf, W size, TMO tmout, INT cmd );
  103: IMPORT BOOL knl_chkopen( DevCB *devcb, INT unitno );
  104: IMPORT void knl_delReqCB( ReqCB *reqcb );
  105: IMPORT ResCB* knl_GetResCB( void );
  106: IMPORT void knl_delOpnCB( OpnCB *opncb, BOOL free );
  107: IMPORT ER knl_close_device( OpnCB *opncb, UINT option );
  108: 
  109: #endif /* _DEVICE_H_ */