1 #ifndef LIBRARIES_DEVICEIO_H
    2 #define LIBRARIES_DEVICEIO_H
    3 
    4 #ifndef EXEC_TYPES_H
    5 	#include <exec/types.h>
    6 #endif /* EXEC_TYPES_H */
    7 
    8 #ifndef UTILITY_TAGITEM_H
    9    #include <utility/tagitem.h>
   10 #endif /* UTILITY_TAGITEM_H */
   11 
   12 /* ============================================ */
   13 
   14 #define DEVICEIO_NAME    "deviceio.library"
   15 #define DEVICEIO_VERSION (1)
   16 
   17 /* ============================================ */
   18 
   19 #ifndef DEVICEIO_PRIVATE_H
   20 
   21 /* 
   22  * There's really nothing in this structure you need to care about
   23  */
   24 
   25 struct DeviceIO
   26 {
   27    /* 
   28     * more below this point !
   29     *
   30     * please do not tuch anything here, use 
   31     * QueryDeviceIOA or SetDeviceIOA if you need
   32     * to query/set something inside
   33     *
   34     * look in to private.h for more info
   35     */
   36 };
   37 
   38 #endif /* DEVICEIO_PRIVATE_H */
   39 
   40 /* ============================================ */
   41 
   42 /*
   43  * DeviceIO BLCK
   44  */
   45 
   46 typedef unsigned long DBLCK;
   47 
   48 /*
   49  * DeviceIO - Tag base
   50  */
   51 
   52 #define DEVICEIO_TAGBASE   (TAG_USER)
   53 
   54 /*
   55  * DeviceIO - Error base
   56  */
   57 
   58 #define DEVICEIO_ERRBASE   (1024)
   59 
   60 /* ============================================ */
   61 
   62 /*
   63  * InitDeviceIOA - Tags
   64  */
   65 
   66 #define IDIO_LockDosListFlags  (DEVICEIO_TAGBASE + 1)    /* Flags used to LockDosList() */
   67 #define IDIO_MarkToState       (DEVICEIO_TAGBASE + 2)    /* See below */
   68 
   69 #define IDIO_IOC_Lines         (DEVICEIO_TAGBASE + 101)  /* IOC Lines */
   70 #define IDIO_IOC_ReadAheadSize (DEVICEIO_TAGBASE + 102)  /* IOC ReadAheadSize (Bytes) */
   71 #define IDIO_IOC_Copyback      (DEVICEIO_TAGBASE + 103)  /* IOC Copyback (BOOL) */
   72 
   73 #define IDIO_PoolSize          (DEVICEIO_TAGBASE + 201)  /* Internal Pool size */
   74 #define IDIO_PoolTreshold      (DEVICEIO_TAGBASE + 202)  /* Internal Pool trashold */
   75 
   76 #define IDIO_CTRL_C            (DEVICEIO_TAGBASE + 301)  /* enable/disable CTRL_C checking (BOOL) */
   77 
   78 #define IDIO_Force             (DEVICEIO_TAGBASE + 401)  /* */
   79 #define IDIO_ForceBlockSize    (DEVICEIO_TAGBASE + 402)  /* */
   80 
   81 #define IDIO_FSSM              (DEVICEIO_TAGBASE + 501)  /* */
   82 
   83 /*
   84  * QueryDeviceIOA - Tags
   85  */
   86 
   87 #define DEVICEIO_QUERY_TAGBASE   (TAG_USER)
   88 
   89 #define DIOQ_ADOS_FileSysStartupMsg (DEVICEIO_QUERY_TAGBASE + 1)
   90 #define DIOQ_ADOS_DosEnvec          (DEVICEIO_QUERY_TAGBASE + 2)
   91 #define DIOQ_ADOS_MsgPort           (DEVICEIO_QUERY_TAGBASE + 3)
   92 #define DIOQ_LL_MsgPort             (DEVICEIO_QUERY_TAGBASE + 11)
   93 #define DIOQ_LL_IORequest           (DEVICEIO_QUERY_TAGBASE + 12)  /* User reserved IOReq */
   94 #define DIOQ_Start_ByteH            (DEVICEIO_QUERY_TAGBASE + 101) /* the byte offset of our partition on the disk */
   95 #define DIOQ_Start_ByteL            (DEVICEIO_QUERY_TAGBASE + 102) /* high 32 bits */
   96 #define DIOQ_End_ByteH              (DEVICEIO_QUERY_TAGBASE + 103) /* the byte offset of the end of our partition (excluding) on the disk */
   97 #define DIOQ_End_ByteL              (DEVICEIO_QUERY_TAGBASE + 104) /* high 32 bits */
   98 #define DIOQ_Sector_Low             (DEVICEIO_QUERY_TAGBASE + 105)
   99 #define DIOQ_Sector_High            (DEVICEIO_QUERY_TAGBASE + 106)
  100 #define DIOQ_Device_API             (DEVICEIO_QUERY_TAGBASE + 201)
  101 #define DIOQ_Device_APIUsed         (DEVICEIO_QUERY_TAGBASE + 202)
  102 #define DIOQ_Blocks_Total           (DEVICEIO_QUERY_TAGBASE + 301) /* size of the partition in blocks */
  103 #define DIOQ_Blocks_Reserved_Start  (DEVICEIO_QUERY_TAGBASE + 302) /* number of blocks reserved at start (=reserved) */
  104 #define DIOQ_Blocks_Reserved_End    (DEVICEIO_QUERY_TAGBASE + 303) /* number of blocks reserved at end (=prealloc) */
  105 #define DIOQ_Blocks_MaxTransfer     (DEVICEIO_QUERY_TAGBASE + 304) /* max. blocks which may be transfered to the device at once (limits io_Length) */
  106 #define DIOQ_Sectors_Block          (DEVICEIO_QUERY_TAGBASE + 311) /* number of sectors in a block */
  107 #define DIOQ_Sectors_PerCylinder    (DEVICEIO_QUERY_TAGBASE + 312)
  108 #define DIOQ_Sectors_Total          (DEVICEIO_QUERY_TAGBASE + 313) /* size of the partition in sectors */
  109 #define DIOQ_Bytes_Block            (DEVICEIO_QUERY_TAGBASE + 321) /* size of a block in bytes */
  110 #define DIOQ_Bytes_Sector           (DEVICEIO_QUERY_TAGBASE + 322)
  111 #define DIOQ_Shifts_Block           (DEVICEIO_QUERY_TAGBASE + 331) /* shift count needed to convert a blockoffset<->byteoffset */
  112 #define DIOQ_Shifts_Block32         (DEVICEIO_QUERY_TAGBASE + 332) /* shift count needed to convert a blockoffset<->32byteoffset */
  113 #define DIOQ_Mask_Block             (DEVICEIO_QUERY_TAGBASE + 341)
  114 #define DIOQ_Mask_Block32           (DEVICEIO_QUERY_TAGBASE + 342) /* masks the least significant bits of a BLCKf pointer */
  115 #define DIOQ_Mask_Mask              (DEVICEIO_QUERY_TAGBASE + 343) /* mask as specified by mountlist */
  116 #define DIOQ_Cache_Lines            (DEVICEIO_QUERY_TAGBASE + 501)
  117 #define DIOQ_Cache_RAHS             (DEVICEIO_QUERY_TAGBASE + 502)
  118 #define DIOQ_Cache_Copyback         (DEVICEIO_QUERY_TAGBASE + 503)
  119 
  120 #define DIOQ_Flags                  (DEVICEIO_QUERY_TAGBASE + 1024)
  121 
  122 /*
  123  * SetDeviceIOA - Tags
  124  */
  125 
  126 #define DEVICEIO_SET_TAGBASE     (TAG_USER)
  127 
  128 #define DIOS_TransferFunc_Ptr    (DEVICEIO_SET_TAGBASE + 1) /* transfer() hook (Prototype = void func(struct DeviceIO *, arg1, arg2, arg3) */
  129 #define DIOS_TransferFunc_Arg1   (DEVICEIO_SET_TAGBASE + 2) /* transfer hook arg1 (Default 0) */
  130 #define DIOS_TransferFunc_Arg2   (DEVICEIO_SET_TAGBASE + 3) /* transfer hook arg2 (Default 0) */
  131 #define DIOS_TransferFunc_Arg3   (DEVICEIO_SET_TAGBASE + 4) /* transfer hook arg3 (Default 0) */
  132 
  133 #define DIOS_CTRL_C              (DEVICEIO_SET_TAGBASE + 11) /* enable/disable CTRL_C checking */
  134 
  135 #define DIOS_State               (DEVICEIO_SET_TAGBASE + 21) /* Set to specyfic 'state' */
  136 
  137 /* ============================================ */
  138 
  139 /*
  140  * Device Flags
  141  */
  142 
  143 #define DF_DeviceOpen      (1)
  144 #define DF_CachedIO        (1 << 1)
  145 #define DF_WriteProtected  (1 << 2)
  146 #define DF_Inhibited       (1 << 3)
  147 #define DF_Disable_CTRLC   (1 << 4)
  148 #define DF_Forced          (1 << 5)
  149 #define DF_BlockSizeFucked (1 << 6)
  150 
  151 /*
  152  * Interfaces
  153  */
  154 
  155 #define DIOI_Standard   (0)      /* All devices support this */
  156 #define DIOI_NSD        (1)      /* NewStyleDevcie intraface */
  157 #define DIOI_TD64       (1 << 1) /* TrackDisk64 interface    */
  158 #define DIOI_ScsiDirect (1 << 2) /* SCSIDirect interface     */
  159 
  160 /*
  161  * IDIO_MarkToState
  162  */
  163 
  164 #define MTS_None         (0)      /* */
  165 #define MTS_WriteProtect (1)      /* Set device to WriteProtected state */
  166 #define MTS_Inhibit      (1 << 1) /* Set device to Inhibit state */
  167 
  168 
  169 /*
  170  * InitDeviceIOA - Errors
  171  */
  172 
  173 #define DIO_ERROR_READ_GEOMETRY     (DEVICEIO_ERRBASE + 1)
  174 #define DIO_ERROR_NO_64BIT_SUPPORT  (DEVICEIO_ERRBASE + 2)
  175 
  176 /*
  177  * CachedIO - Errors
  178  */
  179 
  180 #define DIO_ERROR_OUTSIDE_PARTITION (DEVICEIO_ERRBASE + 3)
  181 
  182 /* ============================================ */
  183 
  184 /*
  185  * InitDeviceData
  186  */
  187 
  188 struct InitDeviceData
  189 {
  190    /* ADOS Device */
  191    STRPTR      device_name;
  192    ULONG       device_unit;
  193    ULONG       device_flags;
  194 };
  195 
  196 /*
  197  * Global Macros
  198  */
  199 
  200 /*===============*/
  201 /* Global Macros */
  202 /*===============*/
  203 
  204 #define STRIPDEVNAME(_name)              \
  205    {                                     \
  206       int _name_lenght = strlen(_name);  \
  207                                          \
  208       if(_name[_name_lenght - 1] == ':') \
  209          _name[_name_lenght - 1] = 0;    \
  210    }                                    
  211 
  212 #define ReadBlock(_dio, _blck, _buff) ReadBlocks(_dio, _blck, _buff, 1L)
  213 #define WriteBlock(_dio, _blck, _buff) WriteBlocks(_dio, _blck, _buff, 1L)
  214 
  215 #define AllocateBlock(_dio) AllocateBlocks(_dio, 1L)
  216 
  217 /* ============================================ */
  218 
  219 #ifndef FSTM_NO_ALIASES
  220 
  221 #define InitDeviceIOA		DIO_InitDeviceIOA
  222 #define CleanupDeviceIO		DIO_CleanupDeviceIO
  223 
  224 #define QueryDeviceIOA		DIO_QueryDeviceIOA
  225 #define SetDeviceIOA			DIO_SetDeviceIOA
  226 
  227 #define WriteProtection		DIO_WriteProtection
  228 #define Update					DIO_Update
  229 #define MotorOFF				DIO_MotorOFF
  230 #define IsDiskPresent		DIO_IsDiskPresent
  231 
  232 #define SetIOCache			DIO_SetIOCache
  233 #define FlushIOCache			DIO_FlushIOCache
  234 #define FlushBlocks			DIO_FlushBlocks
  235 
  236 #define ReadBlocks			DIO_ReadBlocks
  237 #define ReadBytes				DIO_ReadBytes
  238 
  239 #define WriteBlocks			DIO_WriteBlocks
  240 #define WriteBytes			DIO_WriteBytes
  241 
  242 #define AllocateBlocks		DIO_AllocateBlocks
  243 #define AllocateBlocksV		DIO_AllocateBlocksV
  244 
  245 #define FreeBlocks			DIO_FreeBlocks
  246 #define FreeBlocksV			DIO_FreeBlocksV
  247 
  248 #define Abort					DIO_Abort
  249 #define SetAbort				DIO_SetAbort
  250 #define Dump					DIO_Dump
  251 
  252 #ifdef USE_INLINE_STDARG
  253 
  254 	#define InitDeviceIO		DIO_InitDeviceIO
  255 
  256 	#define QueryDeviceIO	DIO_QueryDeviceIO
  257 	#define SetDeviceIO		DIO_SetDeviceIO
  258 
  259 #endif /* USE_INLINE_STDARG */
  260 
  261 #endif /* FSTM_NO_ALIASES */
  262 
  263 /* ============================================ */
  264 
  265 #endif /* LIBRARIES_DEVICEIO_H */