[PSDK/DDK]: Last couple of fixes to headers. Classpnp can compile (and link) now.
[reactos.git] / reactos / include / ddk / classpnp.h
index 6373cee..368f390 100644 (file)
 
 #include <scsi.h>
 
-#define DEBUG_BUFFER_LENGTH               256
-
 #define SRB_CLASS_FLAGS_LOW_PRIORITY      0x10000000
 #define SRB_CLASS_FLAGS_PERSISTANT        0x20000000
 #define SRB_CLASS_FLAGS_PAGING            0x40000000
 #define SRB_CLASS_FLAGS_FREE_MDL          0x80000000
 
+#define ASSERT_FDO(x) \
+    ASSERT(((PCOMMON_DEVICE_EXTENSION) (x)->DeviceExtension)->IsFdo)
+
+#define ASSERT_PDO(x) \
+    ASSERT(!(((PCOMMON_DEVICE_EXTENSION) (x)->DeviceExtension)->IsFdo))
+
 #define IS_CLEANUP_REQUEST(majorFunction)   \
   ((majorFunction == IRP_MJ_CLOSE) ||       \
    (majorFunction == IRP_MJ_CLEANUP) ||     \
 
 #define IS_SCSIOP_READWRITE(opCode) (IS_SCSIOP_READ(opCode) || IS_SCSIOP_WRITE(opCode))
 
+#define ADJUST_FUA_FLAG(fdoExt) {                                                       \
+    if (TEST_FLAG(fdoExt->DeviceFlags, DEV_WRITE_CACHE) &&                              \
+        !TEST_FLAG(fdoExt->DeviceFlags, DEV_POWER_PROTECTED) &&                         \
+        !TEST_FLAG(fdoExt->ScanForSpecialFlags, CLASS_SPECIAL_FUA_NOT_SUPPORTED) ) {    \
+        fdoExt->CdbForceUnitAccess = TRUE;                                              \
+    } else {                                                                            \
+        fdoExt->CdbForceUnitAccess = FALSE;                                             \
+    }                                                                                   \
+}
+
+#define FREE_POOL(_PoolPtr)     \
+    if (_PoolPtr != NULL) {     \
+        ExFreePool(_PoolPtr);   \
+        _PoolPtr = NULL;        \
+    }
+
+#ifdef POOL_TAGGING
+#undef ExAllocatePool
+#undef ExAllocatePoolWithQuota
+#define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'nUcS')
+//#define ExAllocatePool(a,b) #assert(0)
+#define ExAllocatePoolWithQuota(a,b) ExAllocatePoolWithQuotaTag(a,b,'nUcS')
+#endif
+
+#define CLASS_TAG_AUTORUN_DISABLE           'ALcS'
+#define CLASS_TAG_FILE_OBJECT_EXTENSION     'FLcS'
+#define CLASS_TAG_MEDIA_CHANGE_DETECTION    'MLcS'
+#define CLASS_TAG_MOUNT                     'mLcS'
+#define CLASS_TAG_RELEASE_QUEUE             'qLcS'
+#define CLASS_TAG_POWER                     'WLcS'
+#define CLASS_TAG_WMI                       'wLcS'
+#define CLASS_TAG_FAILURE_PREDICT           'fLcS'
+#define CLASS_TAG_DEVICE_CONTROL            'OIcS'
+#define CLASS_TAG_MODE_DATA                 'oLcS'
+#define CLASS_TAG_MULTIPATH                 'mPcS'
+
 #define MAXIMUM_RETRIES 4
 
 #define CLASS_DRIVER_EXTENSION_KEY ((PVOID) ClassInitialize)
 #define ClassAcquireRemoveLock(devobj, tag) \
   ClassAcquireRemoveLockEx(devobj, tag, __FILE__, __LINE__)
 
+#ifdef TRY
+#undef TRY
+#endif
+#ifdef LEAVE
+#undef LEAVE
+#endif
+
+#ifdef FINALLY
+#undef FINALLY
+#endif
+
+#define TRY
+#define LEAVE             goto __tryLabel;
+#define FINALLY           __tryLabel:
+
+#if defined DebugPrint
+#undef DebugPrint
+#endif
+
+#if DBG
+#define DebugPrint(x) ClassDebugPrint x
+#else
+#define DebugPrint(x)
+#endif
+
+#define DEBUG_BUFFER_LENGTH               256
+
 #define START_UNIT_TIMEOUT                  (60 * 4)
 
 #define MEDIA_CHANGE_DEFAULT_TIME          1
 
 #define DEFAULT_FAILURE_PREDICTION_PERIOD 60 * 60 * 1
 
+static inline ULONG CountOfSetBitsUChar(UCHAR _X)
+{ ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
+static inline ULONG CountOfSetBitsULong(ULONG _X)
+{ ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
+static inline ULONG CountOfSetBitsULong32(ULONG32 _X)
+{ ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
+static inline ULONG CountOfSetBitsULong64(ULONG64 _X)
+{ ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
+static inline ULONG CountOfSetBitsUlongPtr(ULONG_PTR _X)
+{ ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
+
 typedef enum _MEDIA_CHANGE_DETECTION_STATE {
   MediaUnknown,
   MediaPresent,
@@ -192,12 +270,9 @@ typedef struct _CLASS_PRIVATE_COMMON_DATA CLASS_PRIVATE_COMMON_DATA, *PCLASS_PRI
 struct _MEDIA_CHANGE_DETECTION_INFO;
 typedef struct _MEDIA_CHANGE_DETECTION_INFO MEDIA_CHANGE_DETECTION_INFO, *PMEDIA_CHANGE_DETECTION_INFO;
 
-struct _DICTIONARY_HEADER;
-typedef struct _DICTIONARY_HEADER DICTIONARY_HEADER, *PDICTIONARY_HEADER;
-
 typedef struct _DICTIONARY {
   ULONGLONG Signature;
-  PDICTIONARY_HEADER List;
+  struct _DICTIONARY_HEADER* List;
   KSPIN_LOCK SpinLock;
 } DICTIONARY, *PDICTIONARY;
 
@@ -533,9 +608,6 @@ typedef struct _PHYSICAL_DEVICE_EXTENSION {
   ULONG_PTR Reserved4;
 } PHYSICAL_DEVICE_EXTENSION, *PPHYSICAL_DEVICE_EXTENSION;
 
-struct _FAILURE_PREDICTION_INFO;
-typedef struct _FAILURE_PREDICTION_INFO *PFAILURE_PREDICTION_INFO;
-
 typedef struct _CLASS_POWER_OPTIONS {
   ULONG PowerDown:1;
   ULONG LockQueue:1;
@@ -606,7 +678,7 @@ typedef struct _FUNCTIONAL_DEVICE_EXTENSION {
   LONG ProtectedLockCount;
   LONG InternalLockCount;
   KEVENT EjectSynchronizationEvent;
-  USHORT  DeviceFlags;
+  USHORT DeviceFlags;
   UCHAR SectorShift;
 #if (NTDDI_VERSION >= NTDDI_VISTA)
   UCHAR CdbForceUnitAccess;
@@ -615,7 +687,7 @@ typedef struct _FUNCTIONAL_DEVICE_EXTENSION {
 #endif
   PMEDIA_CHANGE_DETECTION_INFO MediaChangeDetectionInfo;
   PKEVENT Unused1;
-  HANDLE  Unused2;
+  HANDLE Unused2;
   FILE_OBJECT_EXTENSION KernelModeMcnContext;
   ULONG MediaChangeCount;
   HANDLE DeviceDirectory;
@@ -627,7 +699,7 @@ typedef struct _FUNCTIONAL_DEVICE_EXTENSION {
   BOOLEAN ReleaseQueueIrpFromPool;
   BOOLEAN FailurePredicted;
   ULONG FailureReason;
-  PFAILURE_PREDICTION_INFO FailurePredictionInfo;
+  struct _FAILURE_PREDICTION_INFO* FailurePredictionInfo;
   BOOLEAN PowerDownInProgress;
   ULONG EnumerationInterlock;
   KEVENT ChildLock;
@@ -658,6 +730,7 @@ typedef struct _FUNCTIONAL_DEVICE_EXTENSION {
   ULONG_PTR Reserved2;
   ULONG_PTR Reserved3;
   ULONG_PTR Reserved4;
+
 #endif /* (NTDDI_VERSION <= NTDDI_WIN2K) */
 
 } FUNCTIONAL_DEVICE_EXTENSION, *PFUNCTIONAL_DEVICE_EXTENSION;
@@ -707,6 +780,22 @@ ClassDeviceControl(
   PDEVICE_OBJECT DeviceObject,
   PIRP Irp);
 
+SCSIPORTAPI
+NTSTATUS
+NTAPI
+ClassIoComplete(
+  PDEVICE_OBJECT DeviceObject,
+  PIRP Irp,
+  PVOID Context);
+
+SCSIPORTAPI
+NTSTATUS
+NTAPI
+ClassIoCompleteAssociated(
+  PDEVICE_OBJECT DeviceObject,
+  PIRP Irp,
+  PVOID Context);
+
 SCSIPORTAPI
 BOOLEAN
 NTAPI
@@ -796,6 +885,13 @@ NTAPI
 ClassClaimDevice(
   PDEVICE_OBJECT LowerDeviceObject,
   BOOLEAN Release);
+  
+SCSIPORTAPI
+NTSTATUS
+NTAPI
+ClassInternalIoControl (
+  PDEVICE_OBJECT DeviceObject,
+  PIRP Irp);
 
 SCSIPORTAPI
 VOID
@@ -822,7 +918,7 @@ NTAPI
 ClassGetDescriptor(
   PDEVICE_OBJECT DeviceObject,
   PSTORAGE_PROPERTY_ID PropertyId,
-  PVOID *Descriptor);
+  PSTORAGE_DESCRIPTOR_HEADER *Descriptor);
 
 SCSIPORTAPI
 VOID
@@ -981,6 +1077,13 @@ NTAPI
 ClassReleaseChildLock(
   PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
 
+NTSTATUS
+NTAPI
+ClassSignalCompletion(
+  PDEVICE_OBJECT DeviceObject,
+  PIRP Irp,
+  PKEVENT Event);
+
 VOID
 NTAPI
 ClassSendStartUnit(
@@ -993,12 +1096,28 @@ ClassRemoveDevice(
   PDEVICE_OBJECT DeviceObject,
   UCHAR RemoveType);
 
+SCSIPORTAPI
+NTSTATUS
+NTAPI
+ClassAsynchronousCompletion(
+  PDEVICE_OBJECT DeviceObject,
+  PIRP Irp,
+  PVOID Event);
+
 SCSIPORTAPI
 VOID
 NTAPI
 ClassCheckMediaState(
   PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
 
+SCSIPORTAPI
+NTSTATUS
+NTAPI
+ClassCheckVerifyComplete(
+  PDEVICE_OBJECT DeviceObject,
+  PIRP Irp,
+  PVOID Context);
+
 SCSIPORTAPI
 VOID
 NTAPI