gonzui


Format: Advanced Search

tkernel_2/monitor/include/device.hbare sourcepermlink (0.05 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 TRON Forum(http://www.tron.org/) at 2015/06/01.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: 
   15: /*
   16:  *      device.h
   17:  *
   18:  *       T-Monitor device-related definitions
   19:  *
   20:  *       since machines support different devices, functions defined here
   21:  *       may not be usable all the time.
   22:  *       Available functions differ from one system to the other.
   23:  */
   24: 
   25: #ifndef __MONITOR_DEVICE_H__
   26: #define __MONITOR_DEVICE_H__
   27: 
   28: /* ------------------------------------------------------------------------ */
   29: /*
   30:  *       serial port
   31:  */
   32: 
   33: /*
   34:  * initialize serial port
   35:  *       port    console port number (0 - )
   36:  *              when it is -1, it means there is no console.
   37:  *       speed   communication speed (bps)
   38:  */
   39: IMPORT ER initSIO( W port, W speed );
   40: 
   41: /*
   42:  * serial port output (one character transmission)
   43:  */
   44: IMPORT void putSIO( UB c );
   45: 
   46: /*
   47:  * serial port input (one character reception)
   48:  *       tmo     timeout (milliseconds)
   49:  *              You can not wait forever.
   50:  *       return value       >= 0 : character code
   51:  *                 -1 : timeout
   52:  *       input data using buffer.
   53:  *       receive error is ignored.
   54:  */
   55: IMPORT W getSIO( W tmo );
   56: 
   57: #define SIO_RCVBUFSZ    64         /* receive buffer size */
   58: #define SIO_PTRMSK      (SIO_RCVBUFSZ - 1)
   59: 
   60: /*
   61:  * control block for a serial port
   62:  */
   63: typedef struct siocb    SIOCB;
   64: struct siocb {
   65:         UW     info;                       /* driver can use this for arbitrary purposes */
   66:         UB     rcvbuf[SIO_RCVBUFSZ];       /* receive buffer */
   67:         UW     iptr;                       /* input pointer */
   68:         UW     optr;                       /* output pointer */
   69: 
   70:         /*
   71:          * I/O functions
   72:          *       same specification as putSIO(), and getSIO()
   73:          */
   74:         void (*put)( SIOCB*, UB c );   /* send a character */
   75:         W    (*get)( SIOCB*, W tmo );  /* receive a character */
   76: };
   77: 
   78: /*
   79:  * serial port configuration information
   80:  */
   81: typedef struct cfgsio   CFGSIO;
   82: struct cfgsio {
   83:         /*
   84:          * initialization processing
   85:          *       serial port that is supported by the initialization of CFGSIO
   86:          *       speed   communication speed (bps)
   87:          *       initialize the serial port according to the specified parameters and set SIOCB
   88:          *       SIOCB is given in 0-cleared state initially.
   89:          *       Subsequent I/O operations uses the SIOCB.
   90:          */
   91:         ER (*initsio)( SIOCB*, const CFGSIO*, W speed );
   92: 
   93:         UW     info;                       /* additional information (driver-dependent) */
   94: };
   95: 
   96: IMPORT W        ConPort;       /* console port number */
   97: IMPORT UW       ConPortBps;   /* console port communication speed (bps) */
   98: 
   99: /* ------------------------------------------------------------------------ */
  100: /*
  101:  *      disk drive
  102:  */
  103: 
  104: #define L_DEVNM         8              /* device name length */
  105: #define N_PARTITION     4           /* number of partitions */
  106: 
  107: /*
  108:  * disk access
  109:  *       devnm   device name (possibly with the partition number)
  110:  *       blk     start block number
  111:  *               if device name has a partition number, then the block number in that partition
  112:  *               if there is no partition number in the disk anme, the block number in the entire disk
  113:  *       nblk    number of blocks
  114:  *       buf     buffer (* )
  115:  *       wrt     FALSE : read
  116:  *               TRUE  : write
  117:  *       return value error code
  118:  *       argument marked with (* ) may be an address specified from external sources.
  119:  */
  120: IMPORT ER rwDisk( const UB *devnm, W blk, W nblk, void *buf, BOOL wrt );
  121: 
  122: /*
  123:  * obtain disk information
  124:  *       devnm   device name (possibly with the partition number)
  125:  *       blksz   return block size (* )
  126:  *       tblks   return the number of all blocks (* )
  127:  *       return value error code
  128:  *       if there is a partition number to the device name, return the specific information to that partition.
  129:  *       argument marked with (* ) may be an address specified from external sources.
  130:  */
  131: IMPORT ER infoDisk( const UB *devnm, W *blksz, W *tblks );
  132: 
  133: /*
  134:  * control block for a disk drive
  135:  *       During the first initialization of the disk driver, please do the following:
  136:  *       assume the first initialization if blksz == 0.
  137:  *       blksz   block size
  138:  *       boot    0xff if there is a partition
  139:  *               0 if there is no partition
  140:  *       part[0] the starting block number of a whole disk and number of blocks
  141:  *       rwdisk  I/O processing function
  142:  *
  143:  *      after the disk driver initialization, boot and part[1 - (and up) ] are
  144:  *       set by upper level software.
  145:  */
  146: typedef struct diskcb   DISKCB;
  147: struct diskcb {
  148:         UW     info;                       /* driver can use this for arbitrary purposes */
  149:         UW     blksz;                      /* block size (in bytes) */
  150:         UB     boot;                       /* boot partition number (0: no partition) */
  151:         struct partition {             /* partition information */
  152:                 UW    sblk;              /* start block number */
  153:                 UW    nblk;              /* number of blocks */
  154:         } part[1 + N_PARTITION];       /* [0]:whole, [1- (and up)]: each partition */
  155: 
  156:         /*
  157:          * I/O functions
  158:          *       blk     start block number
  159:          *               this is not a block number within a partition, but
  160:          *               it is a disk-wide block number unique inside the whole disk.
  161:          *       nblk    number of blocks
  162:          *       buf     buffer (* )
  163:          *       wrt     FALSE : read
  164:          *               TRUE  : write
  165:          *       return value error code
  166:          *       argument marked with (* ) may be an address specified from external sources.
  167:          */
  168:         ER (*rwdisk)( DISKCB*, W blk, W nblk, void *buf, BOOL wrt );
  169: };
  170: 
  171: /*
  172:  * disk drive configuration information
  173:  */
  174: typedef struct cfgdisk  CFGDISK;
  175: struct cfgdisk {
  176:         UB     name[L_DEVNM];              /* device name */
  177:         UW     attr;                       /* disk drive attribute */
  178: 
  179:         /*
  180:          * initialization processing
  181:          *       disk drive that is supported by the initialization by CFGDISK
  182:          *       disk drive is initialized and DISKCB is set up.
  183:          *       DISKCB is given in 0-cleared state initially. Subsequently,
  184:          *       DISKCB returned in the previous call is passed.
  185:          *       I/O function receives this DISKCB.
  186:          *
  187:          *       In principle, this function is called every time an I/O processing is performed.
  188:          *       Hence, there is no need to perform hardware initialization on the second call and afterward.
  189:          *       but whether the hardware status remains as it was the last time the initialization took place is not guaranteed,
  190:          *     so,
  191:          *      it is desirable to initialize hardware from time to as necessary.
  192:          *     If we perform re-initialization, DISKCB is to be re-initialized.
  193:          */
  194:         ER (*initdisk)( DISKCB*, const CFGDISK* );
  195: 
  196:         UW     info;                       /* additional information (driver-dependent) */
  197: };
  198: 
  199: /* disk drive attribute */
  200: #define DA_RONLY        0x0001         /* read-only */
  201: 
  202: /*
  203:  * open disk (obtain disk drive control block)
  204:  *       open a device indicated by `devnm', and return the disk information in `dcb'.
  205:  *       devnm can specify a device name with partition number.
  206:  *       return the partition number specified by devnm.
  207:  *       return value     0   : entire disks
  208:  *               1 - : partition number
  209:  *               < 0 : error
  210:  *       usually openDisk() is internally called implicitly, and you don't have to call it explicitly.
  211:  *       it is provided here so that you can call it independently
  212:  */
  213: IMPORT W openDisk( const UB *devnm, DISKCB **dcb );
  214: 
  215: /* ------------------------------------------------------------------------ */
  216: /*
  217:  *      Flash ROM
  218:  */
  219: 
  220: IMPORT const UW FROM_SECSZ;     /* Flash ROM sector size (bytes) */
  221: 
  222: /*
  223:  * Flash ROM sector erase / write
  224:  *       addr    Flash ROM write start address (must be on a sector boundary)
  225:  *       data    write data start address (RAM)
  226:  *       nsec    number of sectors to write
  227:  *       msg      0 : no message display  no verify write
  228:  *                1 : message display    with verify write
  229:  *               -1 : message display no verify write
  230:  *       return value error code
  231:  */
  232: IMPORT ER writeFrom( UW addr, UW data, W nsec, W msg );
  233: 
  234: /*
  235:  * set up Flash ROM loading processing
  236:  *       mode     0 : set up for loading write data
  237:  *               -1 : set up for writing already loaded data
  238:  *
  239:  *       in the case of setting up loading (mode= 0)
  240:  *         addr returns the following value.
  241:  *           addr[0]  the start address in RAM area for loading data
  242:  *           addr[1]  the end address in RAM area for loading data
  243:  *               addr[1] - addr[0] + 1 = load area size
  244:  *               in principle, load area size matches the size of FLASH ROM.
  245:  *               But if RAM is small, there may be cases
  246:  *               in which load area size is smaller than that of Flash ROM size.
  247:  *           addr[2]  the distance between the data load RAM area and Flash ROM area
  248:  *               adjustment is made so that the addr[0] position is written to the beginning of Flash ROM.
  249:  *               addr[2] = addr[0] - Flash ROM start address
  250:  *
  251:  *       in the case of setting up for writing (mode = -1),
  252:  *         we set the writing area based on the addr value when we called this function using mode = 0.
  253:  *           addr[0]  starting address of loaded data in RAM area (to be written)
  254:  *            addr[1]  ending address of loaded data in RAM area (to be written)
  255:  *               addr[1] - addr[0] + 1 = size of written data
  256:  *           addr[2]  the value remains the same after it was set by mode = 0 (ignored)
  257:  *         the modified values are returned in addr.
  258:  *           addr[0]  Flash ROM write start address
  259:  *           addr[1]  start address of write data in RAM
  260:  *               address will be adjusted to the sector boundary of Flash ROM.
  261:  *           addr[2]  number of sectors to write
  262:  *               Since writing is done in the unit of sectors, the writing will be done from the sector boundary,
  263:  *               areas immediately before and after the designated area may be part of the write operation.
  264:  */
  265: IMPORT void setupFlashLoad( W mode, UW addr[3] );
  266: 
  267: /* ------------------------------------------------------------------------ */
  268: /*
  269:  *      PCMCIA
  270:  */
  271: 
  272: /*
  273:  * initialize slot
  274:  */
  275: IMPORT void initPcSlot( void );
  276: 
  277: /* ------------------------------------------------------------------------ */
  278: /*
  279:  *       PCI device
  280:  */
  281: 
  282: /*
  283:  * initialize PCI
  284:  */
  285: IMPORT void initPCI( void );
  286: 
  287: /*
  288:  * submodule extended SVC function
  289:  *       fno     function code
  290:  *       p1-p3 parameter(s)
  291:  *       er_p    returns error code
  292:  *       return value      if the function is handled, returns TRUE.
  293:  *               if not, returns FALSE
  294:  */
  295: IMPORT BOOL pciSVC( W fno, W p1, W p2, W p3, W *er_p );
  296: 
  297: /* ------------------------------------------------------------------------ */
  298: /*
  299:  *       memory disk
  300:  */
  301: 
  302: /*
  303:  * initialization processing
  304:  */
  305: IMPORT ER initMemDisk( DISKCB *dcb, const CFGDISK *cfg );
  306: 
  307: /*
  308:  * submodule extended SVC function
  309:  *       fno     function code
  310:  *       p1-p3 parameter(s)
  311:  *       er_p    returns error code
  312:  *       return value      if the function is handled, returns TRUE.
  313:  *               if not, returns FALSE
  314:  */
  315: IMPORT BOOL memDiskSVC( W fno, W p1, W p2, W p3, W *er_p );
  316: 
  317: /*
  318:  * exclude area used for RAM disk
  319:  *       top     the start of RAM area (the lower address)
  320:  *       end     the end of RAM area (upper area)
  321:  *       excluding the area used for RAM disk from the upper end of RAM area,
  322:  *       return the address (the end of RAM area) as return value.
  323:  */
  324: IMPORT UW omitRAMDiskArea( UW top, UW end );
  325: 
  326: /* ------------------------------------------------------------------------ */
  327: /*
  328:  *       display
  329:  */
  330: 
  331: /*
  332:  * display power off message
  333:  */
  334: IMPORT void DispPowerOff( void );
  335: 
  336: /*
  337:  * display the progression (two hexadecimal digits) on the screen
  338:  *       monitor uses n = 0x01 - 0x0f.
  339:  *       OS uses values 0x10 and above, and 0x00 means the booting has completed.
  340:  */
  341: IMPORT void DispProgress( W n );
  342: 
  343: /* ------------------------------------------------------------------------ */
  344: 
  345: #endif /* __MONITOR_DEVICE_H__ */