Subversion Repositories f9daq

Rev

Rev 41 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #ifndef __PCIVME_DRV_H__
  2. #define __PCIVME_DRV_H__
  3. //-------------------------------------------------------------------------
  4. // WINNT driver for PCIVME interface from ARW Elektronik, Germany ---------
  5. // the main header file of the driver
  6. //
  7. // (c) 1999-2004 ARW Elektronik
  8. //
  9. // this source code is published under GPL (Open Source). You can use, redistrubute and
  10. // modify it unless this header   is not modified or deleted. No warranty is given that
  11. // this software will work like expected.
  12. // This product is not authorized for use as critical component in life support systems
  13. // wihout the express written approval of ARW Elektronik Germany.
  14. //
  15. // Please announce changes and hints to ARW Elektronik
  16. //
  17. // $Log: pcivme_drv.h,v $
  18. // Revision 1.3  2004/07/24 07:07:26  klaus
  19. // Update copyright to 2004
  20. //
  21. // Revision 1.2  2003/11/15 19:12:50  klaus
  22. // Update copyright to 2003
  23. //
  24. // Revision 1.1.1.1  2003/11/14 23:16:33  klaus
  25. // First put into repository
  26. //
  27. // Revision 1.5  2002/10/27 18:41:21  klaus
  28. // changed driver version to 2.0 (not 'inf' version)
  29. //
  30. // Revision 1.4  2002/10/27 17:02:30  klaus
  31. // File addressing bug > 2 Gbtye circumvent
  32. //
  33. // Revision 1.3  2002/10/27 16:17:48  klaus
  34. // Typing bug fixed caused at log addition
  35. //
  36. // Revision 1.2  2002/10/27 16:11:02  klaus
  37. // Added CVS log into header
  38. //
  39. // what                                            who          when
  40. // started                                         AR           15.06.1999
  41. // version 1.0 released                                                    AR                   20.10.1ß99
  42. // version 1.2 released                            AR           25.11.2001
  43. // changed to VisualStudio 6.0                     AR           30.09.2001
  44. // compiled with DDK 1/2001                        AR           20.11.2001
  45. // removed alloc_text cause of WIN2000 problems    AR           25.11.2001
  46. // version 1.3 released                            AR           25.11.2001
  47. // changed resource allocation caused by WIN2000   AR           08.06.2002
  48. //
  49.  
  50. //-------------------------------------------------------------------------
  51. #define DRIVER_VERSION ((2 << 16) | 0)  // the only place for version info
  52. #define DRIVER_VARIANT 0                // mark customisation here
  53. //-------------------------------------------------------------------------
  54.  
  55. //-------------------------------------------------------------------------
  56. // precautions for debug compile
  57. #define PCIVME_DEBUG
  58.  
  59. #ifndef PCIVME_DEBUG
  60. #ifdef  KdPrint()
  61. #undef  KdPrint()
  62. #define KdPrint(x)
  63. #endif
  64. #endif
  65. //-------------------------------------------------------------------------
  66.  
  67. //-------------------------------------------------------------------------
  68. // INCLUDES
  69. //
  70. #define PCI_MAX_BUSES     4   // buses to search for pciada
  71.  
  72. #define PCIVME_MAX_PCIADA 4   // maximum of PCIADA to search for  
  73. #define PCIVME_MAX_VMEMM  16  // maximum number of VMEMMs
  74.  
  75. //-------------------------------------------------------------------------
  76. // DEFINES
  77. //
  78. #define PCIVME_VENDOR_ID  0x10B5  
  79. #define PCIVME_DEVICE_ID  0x9050
  80. #define PCIVME_SUBSYS_ID  0x1167
  81. #define PCIVME_SUBVEN_ID  0x9050
  82.  
  83. #define LCR_SPACE         256  // space in bytes of LCR
  84. #define IFR_SPACE         8192 // space in bytes of IFR
  85.  
  86. //-------------------------------------------------------------------------
  87. // TYPEDEFS
  88. //
  89. typedef struct _FILE_OBJ
  90. {
  91.         USHORT uwAssociatedVMEMM;                  // which VMEMM it belongs
  92.         UCHAR  bAddressModifier;                   // this is the current modifier
  93.         UCHAR  bAccessType;                            // this is the current access type (1,2,4)
  94.         UCHAR  bIncrement;                                   // set 0 if no increment of address
  95.         ULONG  dwAddressMask;          // mask for aligned transfers
  96.         ULONG  dwAccessBase;
  97.         void   (*fRead)(void *to, ULONG length, void *from);  // resulting read
  98.         void   (*fWrite)(void *to, ULONG length, void *from); // resulting write
  99.  
  100.         BOOLEAN bQueueIrq;                                 // queue interrupt vectors belonging to this
  101.         PVOID   pIrqListHandle;                    // pointer to the irq FIFO
  102.  
  103.         BOOLEAN bBusError;                 // marks current access as responsible
  104. } FILE_OBJ, *PFILE_OBJ;
  105.  
  106. typedef struct
  107. {
  108.         int               Bus;             // bus number of pciada
  109.         PCI_SLOT_NUMBER   Slot;            // slot + function number encoded
  110.         PCI_COMMON_CONFIG PCIDevice;       // content of pcr
  111.  
  112.     PHYSICAL_ADDRESS  pvPhysLcr;       // local config register
  113.         PHYSICAL_ADDRESS  pvPhysIfr;       // interface registers
  114.         PVOID             pvVirtLcr;       // virtual LCR space
  115.         PVOID             pvVirtIfr;       // virtual IFR space
  116.  
  117.         KIRQL                     Irql;                    // virtual Irq level
  118.         ULONG                     Vector;              // mapped system vector
  119.         KAFFINITY                 Affinity;        // which processor uses this irq
  120.  
  121.         PKINTERRUPT               InterruptObject; // points to the associated irq obj
  122.  
  123.         PUSHORT           pwCntrl;         // LCR Cntrl Offset @ LCR + 0x50
  124.         PUSHORT           pwIntCSR;        // LCR IntCSR Offset @ LCR + 0x4C
  125.  
  126.         ULONG                     dwLinkCount;     // how often this interface is requested
  127.     BOOLEAN                       bConnected;      // VMEMM is connected and powered
  128.         BOOLEAN                   bWordMode;       // WordMode Jumper set
  129.         BOOLEAN                   bSysControl;     // SystemController enabled
  130.         USHORT                    wModuleNumber;   // Number (Jumper) of VMEMM
  131.         USHORT                    wFPGAVersion;    // Revision of (VMEMM) FPGA
  132.         USHORT                    wModuleType;     // Type of (VMEMM) module
  133.  
  134.         PUSHORT                   pwCSR;           // pointer to csr register
  135.         PUSHORT                   pwIRQStat;       // pointer to irq status
  136.         PUCHAR                    pbVector;        // pointer to vector read register
  137.         PULONG                    pdwVMEAdr;       // pointer to VME adress register
  138.         PUCHAR                    pbModifier;      // pointer to address modifier register
  139.         PVOID                     pvVME;           // pointer into VME window
  140.  
  141.         ULONG                     dwVMEPage;       // current page to VME
  142.         UCHAR                     bModifier;       // current Modifier
  143.  
  144.         KSPIN_LOCK                AccessLock;      // a lock for Access to VMEMM registers
  145.         KSPIN_LOCK                IrqListLock;     // a lock to guard access to List
  146.         LIST_ENTRY                IrqListList;     // start of list of IRQ FIFOs
  147.  
  148.         KDPC                      kDPCobj;                 // custom DPC object for irq tunneling
  149.  
  150.         PBOOLEAN                  pbBusError;      // points to the responsible party
  151.  
  152.         int               nInterruptHandlers; // counts the controlling interrupt handlers
  153. } PCIADA;
  154.  
  155. typedef struct _DEVICE_EXT
  156. {
  157.         PDEVICE_OBJECT DeviceObject;       // points to myself
  158.     PDRIVER_OBJECT driverObj;          // points to my driver                               */
  159.         PIRP actualIrp;                                    // points to ..
  160.  
  161.         KSPIN_LOCK      IRPLock;                           // a lock to guard access to List
  162.         LIST_ENTRY  IRPList;                       // List of queued IRPs
  163.  
  164.         int    nPCIADAs;                   // how many PCIADAs are found
  165.  
  166.         PCIADA pciada[PCIVME_MAX_PCIADA];  // for each PCIADA a descriptor
  167.  
  168.         PCIADA *vmemm[PCIVME_MAX_VMEMM];   // points to PCIADA to which it belongs
  169.  
  170.         int    nInitState;                 // tracks the state of initialisation
  171. } DEVICE_EXT;
  172.  
  173. typedef struct
  174. {
  175.         LIST_ENTRY entry;                                  // doubly linked list
  176.         PFILE_OBJ  pFile_obj;                      // the owner
  177.         PVOID      pIrqListHandle;                 // the irq FIFO of this owner
  178. } FIFO_LIST;
  179.  
  180. // Prototypes to support following pragmas
  181. NTSTATUS DriverEntry(PDRIVER_OBJECT driverObj, PUNICODE_STRING regPath);
  182. NTSTATUS PCIVMEOpen(PDEVICE_OBJECT deviceObj, PIRP irp);
  183. NTSTATUS PCIVMEClose(PDEVICE_OBJECT deviceObj, PIRP irp);
  184. VOID     PCIVMEUnload(PDRIVER_OBJECT driverObj);
  185. NTSTATUS SearchDevices(PDEVICE_OBJECT device_Obj);
  186. NTSTATUS PLX9050BugFix(PDEVICE_OBJECT device_Obj);
  187. NTSTATUS PCIVMEExtractResources(PCIADA *pciada, PCM_RESOURCE_LIST pList);
  188. NTSTATUS PCIVMEReserveResources(PDEVICE_OBJECT device_Obj);
  189. NTSTATUS PCIVMEFreeResources(PDEVICE_OBJECT device_Obj);
  190. NTSTATUS PCIVMETranslateBusAddresses(PDEVICE_OBJECT device_Obj);
  191. NTSTATUS PCIVMETranslateInterrupt(PDEVICE_OBJECT device_Obj);
  192. NTSTATUS PCIVMEMapIOspace(PDEVICE_OBJECT device_object);
  193. VOID     PCIVMESoftInit(PDEVICE_OBJECT device_Obj);
  194. PBOOLEAN ExchangePointer(PBOOLEAN *current, PBOOLEAN next);
  195.  
  196. /* release all this procedures after init of the driver */
  197. #if 0 // WIN2000 change versus WINNT?
  198. #ifdef ALLOC_PRAGMA
  199. #pragma alloc_text (init, DriverEntry)
  200. #pragma alloc_text (init, SearchDevices)
  201. #pragma alloc_text (init, PLX9050BugFix)
  202. #pragma alloc_text (init, PCIVMEExtractResources)
  203. #pragma alloc_text (init, PCIVMEReserveResources)
  204. #pragma alloc_text (init, PCIVMETranslateBusAddresses)
  205. #pragma alloc_text (init, PCIVMETranslateInterrupt)
  206. #pragma alloc_text (init, PCIVMEMapIOspace)
  207. #pragma alloc_text (init, PCIVMESoftInit)
  208. #endif
  209.  
  210. /* put all this procedures in the paged memory-pool, all called at passiv Level */
  211. #ifdef ALLOC_PRAGMA
  212. #pragma alloc_text (page, PCIVMEOpen)
  213. #pragma alloc_text (page, PCIVMEClose)
  214. #pragma alloc_text (page, PCIVMEUnload)
  215. #pragma alloc_text (page, PCIVMEFreeResources)
  216. #endif
  217. #endif // WIN2000 change versus WINNT?
  218.  
  219. #endif // __PCIVME_DRV_H__
  220.  
  221.