win-pvdrivers

annotate xenscsi/xenscsi.h @ 900:938de6b8623d

fix memory leak on suspend/resume
author James Harper <james.harper@bendigoit.com.au>
date Thu Mar 31 20:20:36 2011 +1100 (2011-03-31)
parents 150118f124a1
children
rev   line source
james@191 1 #if !defined(_XENSCSI_H_)
james@191 2 #define _XENSCSI_H_
james@191 3
james@191 4 #include <ntifs.h>
james@191 5 #include <ntddk.h>
james@191 6 #include <wdm.h>
james@191 7 #include <initguid.h>
james@191 8 #include <ntdddisk.h>
james@471 9 //#include <srb.h>
james@191 10
james@191 11 #define NTSTRSAFE_LIB
james@191 12 #include <ntstrsafe.h>
james@191 13
james@191 14 #define __DRIVER_NAME "XenSCSI"
james@191 15
james@191 16 #include <xen_windows.h>
james@191 17 #include <memory.h>
james@191 18 #include <grant_table.h>
james@191 19 #include <event_channel.h>
james@191 20 #include <hvm/params.h>
james@191 21 #include <hvm/hvm_op.h>
james@191 22 #include <xen_public.h>
james@191 23 #include <io/ring.h>
james@191 24 #include <io/vscsiif.h>
james@191 25
james@471 26 //#include <io/blkif.h>
james@482 27 //#include <storport.h>
james@482 28 #include <scsi.h>
james@471 29 //#include <ntddscsi.h>
james@471 30 //#include <ntdddisk.h>
james@471 31 #include <stdlib.h>
james@471 32 #include <io/xenbus.h>
james@471 33 #include <io/protocols.h>
james@471 34
james@471 35
james@191 36 typedef struct vscsiif_request vscsiif_request_t;
james@191 37 typedef struct vscsiif_response vscsiif_response_t;
james@191 38
james@191 39 #define XENSCSI_POOL_TAG (ULONG) 'XSCS'
james@191 40
james@191 41 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
james@191 42 #define VSCSIIF_RING_SIZE __RING_SIZE((vscsiif_sring_t *)0, PAGE_SIZE)
james@191 43
james@191 44 typedef struct {
james@191 45 vscsiif_request_t req;
james@191 46 PSCSI_REQUEST_BLOCK Srb;
james@191 47 } vscsiif_shadow_t;
james@191 48
james@274 49 #define SHADOW_ENTRIES 32
james@314 50 #define MAX_GRANT_ENTRIES 512
james@191 51
james@471 52 #define SCSI_DEV_NODEV ((ULONG)-1)
james@471 53
james@466 54 typedef struct {
james@473 55 LIST_ENTRY entry;
james@471 56 ULONG dev_no; // SCSI_DEV_NODEV == end
james@473 57 ULONG state;
james@473 58 BOOLEAN validated;
james@473 59 UCHAR host;
james@473 60 UCHAR channel;
james@473 61 UCHAR id;
james@473 62 UCHAR lun;
james@466 63 } scsi_dev_t;
james@466 64
james@791 65 #if 0
james@473 66 #define SCSI_STATE_ENUM_PENDING 0
james@473 67 #define SCSI_STATE_ENUM_IN_PROGRESS 1
james@473 68 #define SCSI_STATE_ENUM_COMPLETE 2
james@473 69
james@473 70 #define XENSCSI_MAX_ENUM_TIME 5
james@791 71 #endif
james@791 72
james@791 73 #define SHARED_PAUSED_SCSIPORT_UNPAUSED 0
james@791 74 #define SHARED_PAUSED_PASSIVE_PAUSED 1
james@791 75 #define SHARED_PAUSED_SCSIPORT_PAUSED 2
james@791 76 #define SHARED_PAUSED_PASSIVE_UNPAUSED 3
james@466 77
james@191 78 struct
james@191 79 {
james@274 80 vscsiif_shadow_t shadows[SHADOW_ENTRIES];
james@274 81 USHORT shadow_free_list[SHADOW_ENTRIES];
james@274 82 USHORT shadow_free;
james@274 83
james@314 84 grant_ref_t grant_free_list[MAX_GRANT_ENTRIES];
james@274 85 USHORT grant_free;
james@314 86 USHORT grant_entries;
james@274 87
james@274 88 evtchn_port_t event_channel;
james@274 89
james@274 90 vscsiif_front_ring_t ring;
james@473 91
james@473 92 XENPCI_VECTORS vectors;
james@473 93
james@473 94 LIST_ENTRY dev_list_head;
james@791 95
james@791 96 //BOOLEAN pause_req;
james@791 97 //BOOLEAN pause_ack;
james@791 98 volatile LONG shared_paused;
james@791 99 ULONG scsiport_paused; /* scsiport code has acknowledged pause */
james@791 100 ULONG bus_changes[8];
james@191 101 } typedef XENSCSI_DEVICE_DATA, *PXENSCSI_DEVICE_DATA;
james@191 102
james@495 103 struct {
james@495 104 UCHAR sense_len;
james@495 105 UCHAR sense_buffer[VSCSIIF_SENSE_BUFFERSIZE];
james@495 106 } typedef XENSCSI_LU_DATA, *PXENSCSI_LU_DATA;
james@495 107
james@191 108 enum dma_data_direction {
james@191 109 DMA_BIDIRECTIONAL = 0,
james@191 110 DMA_TO_DEVICE = 1,
james@191 111 DMA_FROM_DEVICE = 2,
james@191 112 DMA_NONE = 3,
james@191 113 };
james@191 114
james@274 115 VOID
james@274 116 XenScsi_FillInitCallbacks(PHW_INITIALIZATION_DATA HwInitializationData);
james@274 117
james@191 118 #endif