gonzui


Format: Advanced Search

tkernel_2/include/device/disk.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 TRON Forum(http://www.tron.org/) at 2015/06/01.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: 
   15: /*
   16:  *      disk.h
   17:  *
   18:  *      Disk driver
   19:  */
   20: 
   21: #ifndef __DEVICE_DISK_H__
   22: #define __DEVICE_DISK_H__
   23: 
   24: #include <basic.h>
   25: #include <tk/devmgr.h>
   26: 
   27: #ifdef __cplusplus
   28: extern "C" {
   29: #endif
   30: 
   31: /* Disk attribute data number */
   32: typedef enum {
   33:         DN_DISKEVENT   = TDN_EVENT,      /* Message buffer for event notification
   34:                                                 data: ID          RW */
   35:         DN_DISKINFO    = TDN_DISKINFO,    /* Disk information
   36:                                                 data: DiskInfo            R- */
   37:         DN_DISKINFO_D  = TDN_DISKINFO_D, /* Disk information
   38:                                                 data: DiskInfo_D  R- */
   39:         DN_DISKFORMAT  = -100,          /* Disk format
   40:                                                 data: DiskFormat  -W */
   41:         DN_DISKINIT    = -101,            /* Disk initialization
   42:                                                 data: DiskInit            -W */
   43:         DN_DISKCMD     = -102,             /* Disk command
   44:                                                 data: DiskCmd             -W */
   45:         DN_DISKMEMADR  = -103,          /* First address of memory disk area
   46:                                                 data: void*               R- */
   47:         DN_DISKPARTINFO        = -104,                /* Disk partition information
   48:                                                 data: DiskPartInfo        R- */
   49:         DN_DISKCHSINFO = -105,         /* Disk CHS information
   50:                                                 data: DiskCHSInfo R- */
   51:         DN_DISKIDINFO  = -106           /* Disk identifying information
   52:                                                 data: UB[]                R- */
   53: } DiskDataNo;
   54: 
   55: /* DN_DISKFORMAT: Disk format (W) */
   56: typedef enum {
   57:         DiskFmt_MEMINIT        = -2,          /* Memory disk initialization   */
   58:         DiskFmt_MEM    = -1,              /* Memory disk              */
   59:         DiskFmt_STD    = 0,               /* Only this type of standard HD     */
   60:         DiskFmt_2DD    = 1,               /* 2DD 720KB                 */
   61:         DiskFmt_2HD    = 2,               /* 2HD 1.44MB                        */
   62:         DiskFmt_VHD    = 3,               /* Floptical 20MB            */
   63:         DiskFmt_CDROM  = 4,             /* CD-ROM 640MB                    */
   64:         DiskFmt_2HD12  = 0x12           /* 2HD 1.2MB                     */
   65: } DiskFormat;
   66: 
   67: /* DN_DISKINFO: Disk information (R) */
   68: struct diskinfo {
   69:         DiskFormat format;             /* Format type             */
   70:         unsigned int   protect:1;                /* Protect state              */
   71:         unsigned int   removable:1;              /* Removable or not                 */
   72:         unsigned int   rsv:30;                   /* Reserved (0)                 */
   73:         W      blocksize;           /* Number of block bytes         */
   74:         W      blockcont;           /* Total number of blocks                        */
   75: };
   76: #ifndef __diskinfo__
   77: #define __diskinfo__
   78: typedef struct diskinfo         DiskInfo;
   79: #endif
   80: 
   81: /* DN_DISKINFO_D: Disk information (R) */
   82: struct diskinfo_d {
   83:         DiskFormat format;             /* Format type             */
   84:         unsigned int   protect:1;                /* Protect state              */
   85:         unsigned int   removable:1;              /* Removable or not                 */
   86:         unsigned int   rsv:30;                   /* Reserved (0)                 */
   87:         W      blocksize;           /* Number of block bytes         */
   88:         D      blockcont_d;         /* Total number of blocks                      */
   89: };
   90: #ifndef __diskinfo_d__
   91: #define __diskinfo_d__
   92: typedef struct diskinfo_d       DiskInfo_D;
   93: #endif
   94: 
   95: /* DN_DISKINIT: Disk initialization (W) */
   96: typedef enum {
   97:         DISKINIT = 1
   98: } DiskInit;
   99: 
  100: /* DN_DISKCMD:  Disk command (W) */
  101: typedef struct {
  102:         B      clen;                        /* Length of SCSI command            */
  103:         UB     cdb[12];            /* SCSI command           */
  104:         W      dlen;                        /* Data length                       */
  105:         UB     *data;                      /* Data address            */
  106: } DiskCmd;
  107: 
  108: /* DN_DISKPARTINFO: Disk partition information (R) */
  109: typedef enum {                          /* Disk system ID             */
  110:         DSID_NONE      = 0x00,
  111:         DSID_DOS1      = 0x01,
  112:         DSID_STDFS_X   = 0x03,           /* Regard XENIX as STDFS.        */
  113:         DSID_DOS2      = 0x04,
  114:         DSID_DOSE      = 0x05,
  115:         DSID_DOS3      = 0x06,
  116:         DSID_HPFS      = 0x07,
  117:         DSID_FS                = 0x08,
  118:         DSID_AIX       = 0x09,
  119:         DSID_OS2       = 0x0A,
  120:         DSID_WIN95     = 0x0B,
  121:         DSID_WIN95L    = 0x0C,
  122:         DSID_DOS3L     = 0x0E,
  123:         DSID_DOS3E     = 0x0F,
  124:         DSID_STDFS     = 0x13,
  125:         DSID_VENIX     = 0x40,
  126:         DSID_CPM1      = 0x52,
  127:         DSID_UNIX      = 0x63,
  128:         DSID_NOVELL1   = 0x64,
  129:         DSID_NOVELL2   = 0x65,
  130:         DSID_PCIX      = 0x75,
  131:         DSID_MINIX1    = 0x80,
  132:         DSID_MINIX2    = 0x81,
  133:         DSID_LINUX1    = 0x82,
  134:         DSID_LINUX2    = 0x83,
  135:         DSID_AMOEBA    = 0x93,
  136:         DSID_BSDI      = 0x9F,
  137:         DSID_386BSD    = 0xA5,
  138:         DSID_CPM2      = 0xDB,
  139:         DSID_DOSSEC    = 0xF2
  140: } DiskSystemId;
  141: 
  142: #define isSTDFS_SID(id)         (((id) == DSID_STDFS )||( (id) == DSID_STDFS_X))
  143: 
  144: typedef struct {
  145:         DiskSystemId   systemid; /* System ID                    */
  146:         W              startblock; /* Start block number           */
  147:         W              endblock;   /* End block number               */
  148: } DiskPartInfo;
  149: 
  150: /* DN_DISKCHSINFO: Disk CHS information (R) */
  151: typedef struct {
  152:         W      cylinder;            /* Total number of cylinders                      */
  153:         W      head;                        /* Number of heads per cylinder      */
  154:         W      sector;                      /* Number of sectors per head      */
  155: } DiskCHSInfo;
  156: 
  157: /* Event notification */
  158: typedef struct {
  159:         T_DEVEVT_ID    h;         /* Standard header (with device ID)    */
  160:         UW             info;              /* Additional information                   */
  161: } DiskEvt;
  162: 
  163: /* DOS/V-format partition information */
  164: typedef struct {
  165:         UB     BootInd;            /* Boot indicator         */
  166:         UB     StartHead;          /* Start head number            */
  167:         UB     StartSec;           /* Start sector number           */
  168:         UB     StartCyl;           /* Start cylinder number         */
  169:         UB     SysInd;                     /* System indicator       */
  170:         UB     EndHead;            /* End head number                */
  171:         UB     EndSec;                     /* End sector number              */
  172:         UB     EndCyl;                     /* End cylinder number            */
  173:         UH     StartBlock[2];              /* Relative start sector number             */
  174:         UH     BlockCnt[2];                /* Number of sectors                  */
  175: } PartInfo;
  176: 
  177: #define MAX_PARTITION   4         /* Number of partitions                */
  178: 
  179: /* Structure of block 0 */
  180: typedef struct {
  181:         VB             boot_prog[0x1be];  /* Boot program  */
  182:         PartInfo       part[MAX_PARTITION];  /* Partition information */
  183:         UH             signature;         /* Signature           */
  184: } DiskBlock0;
  185: 
  186: #ifdef __cplusplus
  187: }
  188: #endif
  189: #endif /* __DEVICE_DISK_H__ */