home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / IncPOS.lzx / pExec / Device.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  4.6 KB  |  167 lines

  1. #ifndef __INC_POS_PEXEC_DEVICE_H
  2. #define __INC_POS_PEXEC_DEVICE_H
  3. /*******************************************************************
  4.  Includes Release 24
  5.  (C) Copyright 1995-1997 proDAD
  6.      All Rights Reserved
  7.  
  8.  $AUT Holger Burkarth
  9.  $DAT >>Device.h<<   09 Nov 1996    19:07:27 - (C) ProDAD
  10. *******************************************************************/
  11. #ifndef __INC_POS_PEXEC_LIBRARY_H
  12. #include <pExec/Library.h>
  13. #endif
  14. #ifndef __INC_POS_PEXEC_MSGPORT_H
  15. #include <pExec/MsgPort.h>
  16. #endif
  17.  
  18.  
  19. /*----------------------------------
  20. -----------------------------------*/
  21. struct pOS_Device
  22. {
  23.   struct pOS_Library dd_Library;
  24. };
  25.  
  26.  
  27. /*----------------------------------
  28. -----------------------------------*/
  29. struct pOS_Unit
  30. {
  31.   struct pOS_MsgPort unit_MsgPort; /* queue for unprocessed messages */
  32.                             /* instance of msgport is recommended */
  33.   UBYTE   unit_Flags;
  34.   UBYTE   unit_Num;         /* kann vom Device für eigene Zwecke verwendet werden */
  35.   UWORD   unit_OpenCnt;     /* number of active opens */
  36. };
  37.  
  38.  
  39. enum pOS_UnitFlags
  40. {
  41.   UNITF_Active  =0x01, /* BeginIO-Task is working */
  42.   UNITF_InTask  =0x02, /* Unit-Task is working */
  43.   UNITF_Quit    =0x04, /* quit Unit-Task */
  44.   UNITF_Stopped =0x08, /* Unit-Task is CMD_STOP */
  45.   UNITF_NeedSig =0x10, /* Unit-Task need WackUp-Signal */
  46. };
  47.  
  48.  
  49.  
  50.  
  51. /*----------------------------------
  52. -----------------------------------*/
  53. struct pOS_IORequest
  54. {
  55.   struct pOS_Message  io_Message;
  56.   struct pOS_Device  *io_Device;   /* device node pointer  */
  57.   struct pOS_Unit    *io_Unit;     /* unit (driver private) */
  58.   UWORD               io_Command;   /* (enum pOS_IOReqCommands) */
  59.   UBYTE               io_Flags;     /* (enum pOS_IOReqFlags) */
  60.   SBYTE               io_Error;     /* (enum pOS_IOReqErrors) */
  61. };
  62.  
  63.  
  64. /*----------------------------------
  65. -----------------------------------*/
  66. struct pOS_IOStdReq
  67. {
  68.   struct pOS_Message  io_Message;
  69.   struct pOS_Device  *io_Device;   /* device node pointer  */
  70.   struct pOS_Unit    *io_Unit;     /* unit (driver private)*/
  71.   UWORD               io_Command;   /* (enum pOS_IOReqCommands) */
  72.   UBYTE               io_Flags;     /* (enum pOS_IOReqFlags) */
  73.   SBYTE               io_Error;     /* (enum pOS_IOReqErrors) */
  74.   ULONG               io_Actual;    /* actual number of bytes transferred */
  75.   ULONG               io_Length;    /* requested number bytes transferred */
  76.   APTR                io_Data;      /* points to data area */
  77.   ULONG               io_Offset;    /* offset for block structured devices */
  78.   ULONG               io_OPad;
  79.   UBYTE               io_Pad[8];
  80. };
  81.  
  82.  
  83.  
  84.  
  85.  
  86. enum pOS_IOReqFlags
  87. {
  88.   IOREQB_Quick   = 0,
  89.  
  90.   IOREQF_Quick   = 0x01,
  91.   IOREQF_IntSig  = 0x02, /* für Device-eigene interne Zwecke */
  92.  
  93.   IOREQF_Pending = 0x80,
  94. };
  95.  
  96.  
  97. enum pOS_IOReqErrors
  98. {
  99.   IOERR_None       = 0,
  100.   IOERR_OpenFail   =-1, /* device/unit failed to open */
  101.   IOERR_Aborted    =-2, /* request terminated early [after AbortIO()] */
  102.   IOERR_NoCMD      =-3, /* command not supported by device */
  103.   IOERR_BadLength  =-4, /* not a valid length (usually IO_LENGTH) */
  104.   IOERR_BadAddress =-5, /* invalid address (misaligned or bad range) */
  105.   IOERR_UnitBusy   =-6, /* device opens ok, but requested unit is busy */
  106.   IOERR_Selftest   =-7, /* hardware failed self-test */
  107.   IOERR_NoMem      =-8, /* not enough memory */
  108.   IOERR_NoSubCMD   =-9  /* sub-command not supported by device */
  109. };
  110.  
  111.  
  112. enum pOS_IOReqCommands
  113. {
  114.   CMD_INVALID   = 0,
  115.   CMD_RESET     = 1,
  116.   CMD_READ      = 2,
  117.   CMD_WRITE     = 3,
  118.   CMD_UPDATE    = 4,
  119.   CMD_CLEAR     = 5,
  120.   CMD_STOP      = 6,
  121.   CMD_START     = 7,
  122.   CMD_FLUSH     = 8,
  123.  
  124.   CMD_NONSTD    = 9,
  125. };
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. /*----------------------------------
  135.  Rückwärtsgerichtete Struktur, DevBase
  136.  steht auf das Ende der Struct.
  137. -----------------------------------*/
  138. struct pOS_StdDeviceFunction
  139. {
  140.   struct pOS_LibraryFunction Reserved2[8];
  141.  
  142.   VOID  (*AbortIO_func)(_R_LB struct pOS_Device*,_R_A0 struct pOS_IORequest*);
  143.   UBYTE _d5[8];
  144.   VOID  (*BeginIO_func)(_R_LB struct pOS_Device*,_R_A0 struct pOS_IORequest*);
  145.   UBYTE _d4[8];
  146.  
  147.   struct pOS_LibraryFunction Reserved1[8];
  148.  
  149.   struct pOS_SegmentLst* (*Expunge_func)(_R_LB struct pOS_Device*);
  150.   UBYTE _d3[8];
  151.   VOID  (*Close_func)(_R_LB struct pOS_Device*,_R_A0 struct pOS_IORequest*);
  152.   UBYTE _d2[8];
  153.   BOOL  (*Open_func)(_R_LB struct pOS_Device*,_R_A0 struct pOS_IORequest*,_R_D0 ULONG unitNr,_R_D1 ULONG flags);
  154.   UBYTE _d1[8];
  155. }; /* => DeviceBase */
  156.  
  157.  
  158. #define _pOS_GetStdDeviceFunction(dev) \
  159.  ( (struct pOS_StdDeviceFunction*)((ULONG)(dev) - sizeof(struct pOS_StdDeviceFunction)) )
  160.  
  161. #define _pOS_GetDeviceFunction(dev,index) \
  162.  ( (struct pOS_LibraryFunction*)((ULONG)(dev) - (index)*sizeof(struct pOS_LibraryFunction)) )
  163.  
  164.  
  165.  
  166. #endif
  167.