gonzui


Format: Advanced Search

tkernel_2/include/device/sdrvif.hbare sourcepermlink (0.02 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by T-Engine Forum at 2013/03/11.
   11:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   12:  *
   13:  *----------------------------------------------------------------------
   14:  */
   15: 
   16: /*
   17:  *      sdrvif.h (device)
   18:  *
   19:  *      Simple device driver I/F layer
   20:  *
   21:  *      Used for simple devices which operation can be processed without
   22:  *      switching to wait mode. Used with very simple devices.
   23:  *
   24:  *      Except where otherwise stated, the functions defined here cannot be
   25:  *      called from the task-independent part or when dispatch or interrupt
   26:  *      disabled.
   27:  */
   28: 
   29: #ifndef __DEVICE_SDRVIF_H__
   30: #define __DEVICE_SDRVIF_H__
   31: 
   32: #include <basic.h>
   33: #include <tk/devmgr.h>
   34: 
   35: #ifdef __cplusplus
   36: extern "C" {
   37: #endif
   38: 
   39: /*
   40:  * Driver I/F access handle
   41:  */
   42: typedef struct SimpleDriverInterface *  SDI;
   43: 
   44: /*
   45:  * Device registration information
   46:  */
   47: typedef struct {
   48:         void*  exinf;           /* Extended information (may be optional) */
   49:         UB     devnm[L_DEVNM+1]; /* Physical device name */
   50:         ATR    drvatr;            /* Driver attributes */
   51:         ATR    devatr;            /* Device attributes */
   52:         INT    nsub;              /* Number of subunits */
   53:         INT    blksz;             /* Unique data block size (-1 = unknown) */
   54: 
   55: /*
   56:  * Processing function (set to NULL if processing function not required)
   57:  *      In all cases, processing must be completed promptly without
   58:  *      switching to wait mode on an irregular basis.
   59:  *      The processing function calls only one task at a time, because
   60:  *      the driver I/F exercises exclusive control.
   61:  *      Processing functions are executed as quasi-task portions in the
   62:  *      request task (application task) context. Since processing
   63:  *      functions operate in the request task context, in the event of a
   64:  *      change in task priority or other change, it is necessary to
   65:  *      return them to their original state before returning from the
   66:  *      processing function.
   67:  *      The read/write return value is either the size of the input/output
   68:  *      result or an error.
   69:  *      A buf area check (ChkSpace) has been implemented in the driver I/F.
   70:  */
   71:         ER  (*open )( ID devid, UINT omode, SDI );
   72:         ER  (*close)( ID devid, UINT option, SDI );
   73:         INT (*read )( ID devid, INT start, INT size, void *buf, SDI );
   74:         INT (*write)( ID devid, INT start, INT size, void *buf, SDI );
   75:         INT (*event)( INT evttyp, void *evtinf, SDI );
   76: } SDefDev;
   77: 
   78: /* Driver attributes */
   79: #ifndef TDA_OPENREQ
   80: #define TDA_OPENREQ     0x0001      /* Each time open/close */
   81: #endif
   82: 
   83: /*
   84:  * Device registration
   85:  *      Registers the device in accordance with the ddev registration
   86:  *      information.
   87:  *      Initial device information is returned in idev. If idev = NULL,
   88:  *      information is not returned.
   89:  *      The driver I/F access handle is returned in SDI.
   90:  * Update
   91:  *      Updates the SDI device registration in accordance with the ddev
   92:  *      registration information. The device name (devnm) cannot
   93:  *      (and must not) be changed.
   94:  *      The update process does not alter the device ID.
   95:  * Delete
   96:  *      Deletes the SDI device registration.
   97:  */
   98: IMPORT ER SDefDevice( const SDefDev *ddev, T_IDEV *idev, SDI* );        /* Register */
   99: IMPORT ER SRedefDevice( const SDefDev *ddev, SDI );                     /* Update */
  100: IMPORT ER SDelDevice( SDI );                                            /* Delete */
  101: 
  102: /*
  103:  * Get information from SDI
  104:  *      These functions can be called from the task-independent part
  105:  *      and when dispatch or interrupt is disabled.
  106:  */
  107: IMPORT ID SDI_devid( SDI );             /* Physical device ID */
  108: IMPORT void* SDI_exinf( SDI );          /* Extended information (exinf) */
  109: IMPORT const SDefDev* SDI_ddev( SDI );  /* Registration information */
  110: 
  111: #ifdef __cplusplus
  112: }
  113: #endif
  114: #endif /* __DEVICE_SDRVIF_H__ */