Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1006 lines
23 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1991 - 1999
  3. Module Name:
  4. disk.c
  5. Abstract:
  6. SCSI disk class driver
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. Revision History:
  11. --*/
  12. #include "ntddk.h"
  13. #include "scsi.h"
  14. #include <wmidata.h>
  15. #include "classpnp.h"
  16. #if defined(JAPAN) && defined(_X86_)
  17. #include "machine.h"
  18. #endif
  19. #include <wmistr.h>
  20. #if defined(_X86_)
  21. #include "mountdev.h"
  22. #endif
  23. #ifdef ExAllocatePool
  24. #undef ExAllocatePool
  25. #define ExAllocatePool #assert(FALSE)
  26. #endif
  27. #define DISK_TAG_GENERAL ' DcS' // "ScD " - generic tag
  28. #define DISK_TAG_SMART 'aDcS' // "ScDa" - SMART allocations
  29. #define DISK_TAG_INFO_EXCEPTION 'ADcS' // "ScDA" - Info Exceptions
  30. #define DISK_TAG_DISABLE_CACHE 'CDcS' // "ScDC" - disable cache paths
  31. #define DISK_TAG_CCONTEXT 'cDcS' // "ScDc" - disk allocated completion context
  32. #define DISK_TAG_DISK_GEOM 'GDcS' // "ScDG" - disk geometry buffer
  33. #define DISK_TAG_UPDATE_GEOM 'gDcS' // "ScDg" - update disk geometry paths
  34. #define DISK_TAG_SENSE_INFO 'IDcS' // "ScDI" - sense info buffers
  35. #define DISK_TAG_PNP_ID 'iDcS' // "ScDp" - pnp ids
  36. #define DISK_TAG_MODE_DATA 'MDcS' // "ScDM" - mode data buffer
  37. #define DISK_CACHE_MBR_CHECK 'mDcS' // "ScDM" - mbr checksum code
  38. #define DISK_TAG_NAME 'NDcS' // "ScDN" - disk name code
  39. #define DISK_TAG_READ_CAP 'PDcS' // "ScDP" - read capacity buffer
  40. #define DISK_TAG_PART_LIST 'pDcS' // "ScDp" - disk partition lists
  41. #define DISK_TAG_SRB 'SDcS' // "ScDS" - srb allocation
  42. #define DISK_TAG_START 'sDcS' // "ScDs" - start device paths
  43. #define DISK_TAG_UPDATE_CAP 'UDcS' // "ScDU" - update capacity path
  44. #define DISK_TAG_WI_CONTEXT 'WDcS' // "ScDW" - work-item context
  45. typedef
  46. VOID
  47. (*PDISK_UPDATE_PARTITIONS) (
  48. IN PDEVICE_OBJECT Fdo,
  49. IN OUT PDRIVE_LAYOUT_INFORMATION_EX PartitionList
  50. );
  51. #if defined(_X86_)
  52. //
  53. // Disk device data
  54. //
  55. typedef enum _DISK_GEOMETRY_SOURCE {
  56. DiskGeometryUnknown,
  57. DiskGeometryFromBios,
  58. DiskGeometryFromPort,
  59. DiskGeometryFromNec98,
  60. DiskGeometryGuessedFromBios,
  61. DiskGeometryFromDefault,
  62. DiskGeometryFromNT4
  63. } DISK_GEOMETRY_SOURCE, *PDISK_GEOMETRY_SOURCE;
  64. #endif
  65. //
  66. // Context for requests that can be combined and sent down
  67. //
  68. typedef struct _DISK_GROUP_CONTEXT
  69. {
  70. //
  71. // Queue of requests whose representative is currently outstanding at the port driver
  72. //
  73. LIST_ENTRY CurrList;
  74. //
  75. // The representative for the above queue
  76. //
  77. PIRP CurrIrp;
  78. //
  79. // Queue of requests whose representative is waiting to go down
  80. //
  81. LIST_ENTRY NextList;
  82. //
  83. // The representative for the above queue
  84. //
  85. PIRP NextIrp;
  86. //
  87. // The srb associated with this group
  88. //
  89. SCSI_REQUEST_BLOCK Srb;
  90. //
  91. // The mutex that will synchronize access to this context
  92. //
  93. KMUTEX Mutex;
  94. //
  95. // This event will allow for the requests to be sent down synchronously
  96. //
  97. KEVENT Event;
  98. #if DBG
  99. //
  100. // This counter maintains the number of requests currently tagged
  101. // to the request that is waiting to go down
  102. //
  103. ULONG DbgTagCount;
  104. //
  105. // This counter maintains the number of requests that were avoided
  106. //
  107. ULONG DbgSavCount;
  108. //
  109. // This counter maintains the total number of times that we combined
  110. // requests and the respective number of requests that were tagged
  111. //
  112. ULONG DbgRefCount[64];
  113. #endif
  114. } DISK_GROUP_CONTEXT, *PDISK_GROUP_CONTEXT;
  115. //
  116. // Write cache setting as defined by the user
  117. //
  118. typedef enum _DISK_USER_WRITE_CACHE_SETTING
  119. {
  120. DiskWriteCacheDisable = 0,
  121. DiskWriteCacheEnable = 1,
  122. DiskWriteCacheDefault = -1
  123. } DISK_USER_WRITE_CACHE_SETTING, *PDISK_USER_WRITE_CACHE_SETTING;
  124. typedef struct _DISK_DATA {
  125. //
  126. // This field is the ordinal of a partition as it appears on a disk.
  127. //
  128. ULONG PartitionOrdinal;
  129. //
  130. // How has this disk been partitioned? Either EFI or MBR.
  131. //
  132. PARTITION_STYLE PartitionStyle;
  133. union {
  134. struct {
  135. //
  136. // Disk signature (from MBR)
  137. //
  138. ULONG Signature;
  139. //
  140. // MBR checksum
  141. //
  142. ULONG MbrCheckSum;
  143. //
  144. // Number of hidden sectors for BPB.
  145. //
  146. ULONG HiddenSectors;
  147. //
  148. // Partition type of this device object
  149. //
  150. // This field is set by:
  151. //
  152. // 1. Initially set according to the partition list entry
  153. // partition type returned by IoReadPartitionTable.
  154. //
  155. // 2. Subsequently set by the
  156. // IOCTL_DISK_SET_PARTITION_INFORMATION I/O control
  157. // function when IoSetPartitionInformation function
  158. // successfully updates the partition type on the disk.
  159. //
  160. UCHAR PartitionType;
  161. //
  162. // Boot indicator - indicates whether this partition is a
  163. // bootable (active) partition for this device
  164. //
  165. // This field is set according to the partition list entry boot
  166. // indicator returned by IoReadPartitionTable.
  167. //
  168. BOOLEAN BootIndicator;
  169. } Mbr;
  170. struct {
  171. //
  172. // The DiskGUID field from the EFI partition header.
  173. //
  174. GUID DiskId;
  175. //
  176. // Partition type of this device object.
  177. //
  178. GUID PartitionType;
  179. //
  180. // Unique partition identifier for this partition.
  181. //
  182. GUID PartitionId;
  183. //
  184. // EFI partition attributes for this partition.
  185. //
  186. ULONG64 Attributes;
  187. //
  188. // EFI partition name of this partition.
  189. //
  190. WCHAR PartitionName[36];
  191. } Efi;
  192. }; // unnamed union
  193. struct {
  194. //
  195. // This flag is set when the well known name is created (through
  196. // DiskCreateSymbolicLinks) and cleared when destroying it
  197. // (by calling DiskDeleteSymbolicLinks).
  198. //
  199. BOOLEAN WellKnownNameCreated : 1;
  200. //
  201. // This flag is set when the PhysicalDriveN link is created (through
  202. // DiskCreateSymbolicLinks) and is cleared when destroying it (through
  203. // DiskDeleteSymbolicLinks)
  204. //
  205. BOOLEAN PhysicalDriveLinkCreated : 1;
  206. } LinkStatus;
  207. //
  208. // ReadyStatus - STATUS_SUCCESS indicates that the drive is ready for
  209. // use. Any error status is to be returned as an explaination for why
  210. // a request is failed.
  211. //
  212. // This was done solely for the zero-length partition case of having no
  213. // media in a removable disk drive. When that occurs, and a read is sent
  214. // to the zero-length non-partition-zero PDO that was created, we had to
  215. // be able to fail the request with a reasonable value. This may not have
  216. // been the best way to do this, but it works.
  217. //
  218. NTSTATUS ReadyStatus;
  219. //
  220. // Routine to be called when updating the disk partitions. This routine
  221. // is different for removable and non-removable media and is called by
  222. // (among other things) DiskEnumerateDevice
  223. //
  224. PDISK_UPDATE_PARTITIONS UpdatePartitionRoutine;
  225. //
  226. // SCSI address used for SMART operations.
  227. //
  228. SCSI_ADDRESS ScsiAddress;
  229. //
  230. // Event used to synchronize partitioning operations and enumerations.
  231. //
  232. KEVENT PartitioningEvent;
  233. //
  234. // These unicode strings hold the disk and volume interface strings. If
  235. // the interfaces were not registered or could not be set then the string
  236. // buffer will be NULL.
  237. //
  238. UNICODE_STRING DiskInterfaceString;
  239. UNICODE_STRING PartitionInterfaceString;
  240. //
  241. // What type of failure prediction mechanism is available
  242. //
  243. FAILURE_PREDICTION_METHOD FailurePredictionCapability;
  244. BOOLEAN AllowFPPerfHit;
  245. #if defined(_X86_)
  246. //
  247. // This flag indiciates that a non-default geometry for this drive has
  248. // already been determined by the disk driver. This field is ignored
  249. // for removable media drives.
  250. //
  251. DISK_GEOMETRY_SOURCE GeometrySource;
  252. //
  253. // If GeometryDetermined is TRUE this will contain the geometry which was
  254. // reported by the firmware or by the BIOS. For removable media drives
  255. // this will contain the last geometry used when media was present.
  256. //
  257. DISK_GEOMETRY RealGeometry;
  258. #endif
  259. //
  260. // Indicates that the cached partition table is valid when set.
  261. //
  262. ULONG CachedPartitionTableValid;
  263. //
  264. // The cached partition table - this is only valid if the previous
  265. // flag is set. When invalidated the cached partition table will be
  266. // freed and replaced the next time one of the partitioning functions is
  267. // called. This allows the error handling routines to invalidate it by
  268. // setting the flag and doesn't require that they obtain a lock.
  269. //
  270. PDRIVE_LAYOUT_INFORMATION_EX CachedPartitionTable;
  271. //
  272. // This mutex prevents more than one IOCTL_DISK_VERIFY from being
  273. // sent down to the disk. This greatly reduces the possibility of
  274. // a Denial-of-Service attack
  275. //
  276. KMUTEX VerifyMutex;
  277. //
  278. // This allows for parallel flush requests to be combined into one so as to
  279. // reduce the number of outstanding requests that are sent down to the disk
  280. //
  281. DISK_GROUP_CONTEXT FlushContext;
  282. //
  283. // The user-specified disk write cache setting
  284. //
  285. DISK_USER_WRITE_CACHE_SETTING WriteCacheOverride;
  286. } DISK_DATA, *PDISK_DATA;
  287. //
  288. // Define a general structure of identfing disk controllers with bad
  289. // hardware.
  290. //
  291. #define HackDisableTaggedQueuing (0x01)
  292. #define HackDisableSynchronousTransfers (0x02)
  293. #define HackDisableSpinDown (0x04)
  294. #define HackDisableWriteCache (0x08)
  295. #define HackCauseNotReportableHack (0x10)
  296. #define HackRequiresStartUnitCommand (0x20)
  297. #define DiskDeviceParameterSubkey L"Disk"
  298. #define DiskDeviceUserWriteCacheSetting L"UserWriteCacheSetting"
  299. #define DiskDeviceCacheIsPowerProtected L"CacheIsPowerProtected"
  300. #define FUNCTIONAL_EXTENSION_SIZE sizeof(FUNCTIONAL_DEVICE_EXTENSION) + sizeof(DISK_DATA)
  301. #define PHYSICAL_EXTENSION_SIZE sizeof(PHYSICAL_DEVICE_EXTENSION) + sizeof(DISK_DATA)
  302. #define MODE_DATA_SIZE 192
  303. #define VALUE_BUFFER_SIZE 2048
  304. #define SCSI_DISK_TIMEOUT 10
  305. #define PARTITION0_LIST_SIZE 4
  306. #define MAX_MEDIA_TYPES 4
  307. typedef struct _DISK_MEDIA_TYPES_LIST {
  308. PCHAR VendorId;
  309. PCHAR ProductId;
  310. PCHAR Revision;
  311. const ULONG NumberOfTypes;
  312. const ULONG NumberOfSides;
  313. const STORAGE_MEDIA_TYPE MediaTypes[MAX_MEDIA_TYPES];
  314. } DISK_MEDIA_TYPES_LIST, *PDISK_MEDIA_TYPES_LIST;
  315. //
  316. // WMI reregistration structures used for reregister work item
  317. //
  318. typedef struct
  319. {
  320. SINGLE_LIST_ENTRY Next;
  321. PDEVICE_OBJECT DeviceObject;
  322. PIRP Irp;
  323. } DISKREREGREQUEST, *PDISKREREGREQUEST;
  324. #define MAX_SECTORS_PER_VERIFY 0x200
  325. //
  326. // This is based off 100ns units
  327. //
  328. #define ONE_MILLI_SECOND ((ULONGLONG)10 * 1000)
  329. //
  330. // Context for the work-item
  331. //
  332. typedef struct _DISK_VERIFY_WORKITEM_CONTEXT
  333. {
  334. PIRP Irp;
  335. PSCSI_REQUEST_BLOCK Srb;
  336. PIO_WORKITEM WorkItem;
  337. } DISK_VERIFY_WORKITEM_CONTEXT, *PDISK_VERIFY_WORKITEM_CONTEXT;
  338. //
  339. // Poll for Failure Prediction every hour
  340. //
  341. #define DISK_DEFAULT_FAILURE_POLLING_PERIOD 1 * 60 * 60
  342. //
  343. // Static global lookup tables.
  344. //
  345. extern CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[];
  346. extern const DISK_MEDIA_TYPES_LIST DiskMediaTypes[];
  347. //
  348. // Macros
  349. //
  350. //
  351. // Routine prototypes.
  352. //
  353. NTSTATUS
  354. DriverEntry(
  355. IN PDRIVER_OBJECT DriverObject,
  356. IN PUNICODE_STRING RegistryPath
  357. );
  358. VOID
  359. DiskUnload(
  360. IN PDRIVER_OBJECT DriverObject
  361. );
  362. NTSTATUS
  363. DiskAddDevice(
  364. IN PDRIVER_OBJECT DriverObject,
  365. IN PDEVICE_OBJECT Pdo
  366. );
  367. NTSTATUS
  368. DiskInitFdo(
  369. IN PDEVICE_OBJECT Fdo
  370. );
  371. NTSTATUS
  372. DiskInitPdo(
  373. IN PDEVICE_OBJECT Pdo
  374. );
  375. NTSTATUS
  376. DiskStartFdo(
  377. IN PDEVICE_OBJECT Fdo
  378. );
  379. NTSTATUS
  380. DiskStartPdo(
  381. IN PDEVICE_OBJECT Pdo
  382. );
  383. NTSTATUS
  384. DiskStopDevice(
  385. IN PDEVICE_OBJECT DeviceObject,
  386. IN UCHAR Type
  387. );
  388. NTSTATUS
  389. DiskRemoveDevice(
  390. IN PDEVICE_OBJECT DeviceObject,
  391. IN UCHAR Type
  392. );
  393. NTSTATUS
  394. DiskReadWriteVerification(
  395. IN PDEVICE_OBJECT DeviceObject,
  396. IN PIRP Irp
  397. );
  398. NTSTATUS
  399. DiskDeviceControl(
  400. IN PDEVICE_OBJECT DeviceObject,
  401. IN PIRP Irp
  402. );
  403. VOID
  404. DiskFdoProcessError(
  405. PDEVICE_OBJECT DeviceObject,
  406. PSCSI_REQUEST_BLOCK Srb,
  407. NTSTATUS *Status,
  408. BOOLEAN *Retry
  409. );
  410. NTSTATUS
  411. DiskShutdownFlush(
  412. IN PDEVICE_OBJECT DeviceObject,
  413. IN PIRP Irp
  414. );
  415. NTSTATUS
  416. DiskGetCacheInformation(
  417. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  418. IN PDISK_CACHE_INFORMATION CacheInfo
  419. );
  420. NTSTATUS
  421. DiskSetCacheInformation(
  422. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  423. IN PDISK_CACHE_INFORMATION CacheInfo
  424. );
  425. VOID
  426. DiskLogCacheInformation(
  427. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  428. IN PDISK_CACHE_INFORMATION CacheInfo,
  429. IN NTSTATUS Status
  430. );
  431. NTSTATUS
  432. DiskIoctlGetCacheSetting(
  433. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  434. IN PIRP Irp
  435. );
  436. NTSTATUS
  437. DiskIoctlSetCacheSetting(
  438. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  439. IN PIRP Irp
  440. );
  441. VOID
  442. DisableWriteCache(
  443. IN PDEVICE_OBJECT DeviceObject,
  444. IN PIO_WORKITEM WorkItem
  445. );
  446. VOID
  447. DiskIoctlVerify(
  448. IN PDEVICE_OBJECT DeviceObject,
  449. IN PDISK_VERIFY_WORKITEM_CONTEXT Context
  450. );
  451. VOID
  452. DiskFlushDispatch(
  453. IN PDEVICE_OBJECT Fdo,
  454. IN PDISK_GROUP_CONTEXT FlushContext
  455. );
  456. NTSTATUS
  457. DiskFlushComplete(
  458. IN PDEVICE_OBJECT Fdo,
  459. IN PIRP Irp,
  460. IN PVOID Context
  461. );
  462. NTSTATUS
  463. DiskModeSelect(
  464. IN PDEVICE_OBJECT DeviceObject,
  465. IN PCHAR ModeSelectBuffer,
  466. IN ULONG Length,
  467. IN BOOLEAN SavePage
  468. );
  469. //
  470. // We need to validate that the self test subcommand is valid and
  471. // appropriate. Right now we allow subcommands 0, 1 and 2 which are non
  472. // captive mode tests. Once we figure out a way to know if it is safe to
  473. // run a captive test then we can allow captive mode tests. Also if the
  474. // atapi 5 spec is ever updated to denote that bit 7 is the captive
  475. // mode bit, we can allow any request that does not have bit 7 set. Until
  476. // that is done we want to be sure
  477. //
  478. #define DiskIsValidSmartSelfTest(Subcommand) \
  479. ( ((Subcommand) == SMART_OFFLINE_ROUTINE_OFFLINE) || \
  480. ((Subcommand) == SMART_SHORT_SELFTEST_OFFLINE) || \
  481. ((Subcommand) == SMART_EXTENDED_SELFTEST_OFFLINE) )
  482. NTSTATUS
  483. DiskPerformSmartCommand(
  484. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  485. IN ULONG SrbControlCode,
  486. IN UCHAR Command,
  487. IN UCHAR Feature,
  488. IN UCHAR SectorCount,
  489. IN UCHAR SectorNumber,
  490. IN OUT PSRB_IO_CONTROL SrbControl,
  491. OUT PULONG BufferSize
  492. );
  493. NTSTATUS
  494. DiskGetInfoExceptionInformation(
  495. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  496. OUT PMODE_INFO_EXCEPTIONS ReturnPageData
  497. );
  498. NTSTATUS
  499. DiskSetInfoExceptionInformation(
  500. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  501. IN PMODE_INFO_EXCEPTIONS PageData
  502. );
  503. NTSTATUS
  504. DiskDetectFailurePrediction(
  505. PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  506. PFAILURE_PREDICTION_METHOD FailurePredictCapability
  507. );
  508. BOOLEAN
  509. EnumerateBusKey(
  510. IN PFUNCTIONAL_DEVICE_EXTENSION DeviceExtension,
  511. HANDLE BusKey,
  512. PULONG DiskNumber
  513. );
  514. NTSTATUS
  515. DiskCreateFdo(
  516. IN PDRIVER_OBJECT DriverObject,
  517. IN PDEVICE_OBJECT LowerDeviceObject,
  518. IN PULONG DeviceCount,
  519. IN BOOLEAN DasdAccessOnly
  520. );
  521. VOID
  522. UpdateDeviceObjects(
  523. IN PDEVICE_OBJECT DeviceObject,
  524. IN PIRP Irp
  525. );
  526. VOID
  527. DiskSetSpecialHacks(
  528. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  529. IN ULONG_PTR Data
  530. );
  531. VOID
  532. ResetBus(
  533. IN PDEVICE_OBJECT DeviceObject
  534. );
  535. NTSTATUS
  536. DiskEnumerateDevice(
  537. IN PDEVICE_OBJECT Fdo
  538. );
  539. NTSTATUS
  540. DiskQueryId(
  541. IN PDEVICE_OBJECT Pdo,
  542. IN BUS_QUERY_ID_TYPE IdType,
  543. IN PUNICODE_STRING UnicodeIdString
  544. );
  545. NTSTATUS
  546. DiskQueryPnpCapabilities(
  547. IN PDEVICE_OBJECT DeviceObject,
  548. IN PDEVICE_CAPABILITIES Capabilities
  549. );
  550. NTSTATUS
  551. DiskGenerateDeviceName(
  552. IN BOOLEAN IsFdo,
  553. IN ULONG DeviceNumber,
  554. IN OPTIONAL ULONG PartitionNumber,
  555. IN OPTIONAL PLARGE_INTEGER StartingOffset,
  556. IN OPTIONAL PLARGE_INTEGER PartitionLength,
  557. OUT PUCHAR *RawName
  558. );
  559. VOID
  560. DiskCreateSymbolicLinks(
  561. IN PDEVICE_OBJECT DeviceObject
  562. );
  563. VOID
  564. DiskUpdatePartitions(
  565. IN PDEVICE_OBJECT Fdo,
  566. IN OUT PDRIVE_LAYOUT_INFORMATION_EX PartitionList
  567. );
  568. VOID
  569. DiskUpdateRemovablePartitions(
  570. IN PDEVICE_OBJECT Fdo,
  571. IN OUT PDRIVE_LAYOUT_INFORMATION_EX PartitionList
  572. );
  573. NTSTATUS
  574. DiskCreatePdo(
  575. IN PDEVICE_OBJECT Fdo,
  576. IN ULONG PartitionOrdinal,
  577. IN PPARTITION_INFORMATION_EX PartitionEntry,
  578. IN PARTITION_STYLE PartitionStyle,
  579. OUT PDEVICE_OBJECT *Pdo
  580. );
  581. VOID
  582. DiskDeleteSymbolicLinks(
  583. IN PDEVICE_OBJECT DeviceObject
  584. );
  585. NTSTATUS
  586. DiskPdoQueryWmiRegInfo(
  587. IN PDEVICE_OBJECT DeviceObject,
  588. OUT ULONG *RegFlags,
  589. OUT PUNICODE_STRING InstanceName
  590. );
  591. NTSTATUS
  592. DiskPdoQueryWmiDataBlock(
  593. IN PDEVICE_OBJECT DeviceObject,
  594. IN PIRP Irp,
  595. IN ULONG GuidIndex,
  596. IN ULONG BufferAvail,
  597. OUT PUCHAR Buffer
  598. );
  599. NTSTATUS
  600. DiskPdoSetWmiDataBlock(
  601. IN PDEVICE_OBJECT DeviceObject,
  602. IN PIRP Irp,
  603. IN ULONG GuidIndex,
  604. IN ULONG BufferSize,
  605. IN PUCHAR Buffer
  606. );
  607. NTSTATUS
  608. DiskPdoSetWmiDataItem(
  609. IN PDEVICE_OBJECT DeviceObject,
  610. IN PIRP Irp,
  611. IN ULONG GuidIndex,
  612. IN ULONG DataItemId,
  613. IN ULONG BufferSize,
  614. IN PUCHAR Buffer
  615. );
  616. NTSTATUS
  617. DiskPdoExecuteWmiMethod(
  618. IN PDEVICE_OBJECT DeviceObject,
  619. IN PIRP Irp,
  620. IN ULONG GuidIndex,
  621. IN ULONG MethodId,
  622. IN ULONG InBufferSize,
  623. IN ULONG OutBufferSize,
  624. IN PUCHAR Buffer
  625. );
  626. NTSTATUS
  627. DiskFdoQueryWmiRegInfo(
  628. IN PDEVICE_OBJECT DeviceObject,
  629. OUT ULONG *RegFlags,
  630. OUT PUNICODE_STRING InstanceName
  631. );
  632. NTSTATUS
  633. DiskFdoQueryWmiRegInfoEx(
  634. IN PDEVICE_OBJECT DeviceObject,
  635. OUT ULONG *RegFlags,
  636. OUT PUNICODE_STRING InstanceName,
  637. OUT PUNICODE_STRING MofName
  638. );
  639. NTSTATUS
  640. DiskFdoQueryWmiDataBlock(
  641. IN PDEVICE_OBJECT DeviceObject,
  642. IN PIRP Irp,
  643. IN ULONG GuidIndex,
  644. IN ULONG BufferAvail,
  645. OUT PUCHAR Buffer
  646. );
  647. NTSTATUS
  648. DiskFdoSetWmiDataBlock(
  649. IN PDEVICE_OBJECT DeviceObject,
  650. IN PIRP Irp,
  651. IN ULONG GuidIndex,
  652. IN ULONG BufferSize,
  653. IN PUCHAR Buffer
  654. );
  655. NTSTATUS
  656. DiskFdoSetWmiDataItem(
  657. IN PDEVICE_OBJECT DeviceObject,
  658. IN PIRP Irp,
  659. IN ULONG GuidIndex,
  660. IN ULONG DataItemId,
  661. IN ULONG BufferSize,
  662. IN PUCHAR Buffer
  663. );
  664. NTSTATUS
  665. DiskFdoExecuteWmiMethod(
  666. IN PDEVICE_OBJECT DeviceObject,
  667. IN PIRP Irp,
  668. IN ULONG GuidIndex,
  669. IN ULONG MethodId,
  670. IN ULONG InBufferSize,
  671. IN ULONG OutBufferSize,
  672. IN PUCHAR Buffer
  673. );
  674. NTSTATUS
  675. DiskWmiFunctionControl(
  676. IN PDEVICE_OBJECT DeviceObject,
  677. IN PIRP Irp,
  678. IN ULONG GuidIndex,
  679. IN CLASSENABLEDISABLEFUNCTION Function,
  680. IN BOOLEAN Enable
  681. );
  682. NTSTATUS
  683. DiskReadFailurePredictStatus(
  684. PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  685. PSTORAGE_FAILURE_PREDICT_STATUS DiskSmartStatus
  686. );
  687. NTSTATUS
  688. DiskReadFailurePredictData(
  689. PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  690. PSTORAGE_FAILURE_PREDICT_DATA DiskSmartData
  691. );
  692. NTSTATUS
  693. DiskEnableDisableFailurePrediction(
  694. PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  695. BOOLEAN Enable
  696. );
  697. NTSTATUS
  698. DiskEnableDisableFailurePredictPolling(
  699. PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  700. BOOLEAN Enable,
  701. ULONG PollTimeInSeconds
  702. );
  703. VOID
  704. DiskAcquirePartitioningLock(
  705. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
  706. );
  707. VOID
  708. DiskReleasePartitioningLock(
  709. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
  710. );
  711. NTSTATUS DiskInitializeReregistration(
  712. VOID
  713. );
  714. extern GUIDREGINFO DiskWmiFdoGuidList[];
  715. extern GUIDREGINFO DiskWmiPdoGuidList[];
  716. #if defined(_X86_)
  717. NTSTATUS
  718. DiskReadDriveCapacity(
  719. IN PDEVICE_OBJECT Fdo
  720. );
  721. #else
  722. #define DiskReadDriveCapacity(Fdo) ClassReadDriveCapacity(Fdo)
  723. #endif
  724. #if defined(_X86_)
  725. NTSTATUS
  726. DiskSaveDetectInfo(
  727. PDRIVER_OBJECT DriverObject
  728. );
  729. VOID
  730. DiskCleanupDetectInfo(
  731. IN PDRIVER_OBJECT DriverObject
  732. );
  733. VOID
  734. DiskDriverReinitialization (
  735. IN PDRIVER_OBJECT DriverObject,
  736. IN PVOID Nothing,
  737. IN ULONG Count
  738. );
  739. #endif
  740. VOID
  741. DiskConvertPartitionToExtended(
  742. IN PPARTITION_INFORMATION Partition,
  743. OUT PPARTITION_INFORMATION_EX PartitionEx
  744. );
  745. PDRIVE_LAYOUT_INFORMATION_EX
  746. DiskConvertLayoutToExtended(
  747. IN CONST PDRIVE_LAYOUT_INFORMATION Layout
  748. );
  749. PDRIVE_LAYOUT_INFORMATION
  750. DiskConvertExtendedToLayout(
  751. IN CONST PDRIVE_LAYOUT_INFORMATION_EX LayoutEx
  752. );
  753. NTSTATUS
  754. DiskReadPartitionTableEx(
  755. IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
  756. IN BOOLEAN BypassCache,
  757. OUT PDRIVE_LAYOUT_INFORMATION_EX* DriveLayout
  758. );
  759. NTSTATUS
  760. DiskWritePartitionTableEx(
  761. IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
  762. IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout
  763. );
  764. NTSTATUS
  765. DiskSetPartitionInformationEx(
  766. IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
  767. IN ULONG PartitionNumber,
  768. IN struct _SET_PARTITION_INFORMATION_EX* PartitionInfo
  769. );
  770. NTSTATUS
  771. DiskSetPartitionInformation(
  772. IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
  773. IN ULONG SectorSize,
  774. IN ULONG PartitionNumber,
  775. IN ULONG PartitionType
  776. );
  777. NTSTATUS
  778. DiskVerifyPartitionTable(
  779. IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
  780. IN BOOLEAN FixErrors
  781. );
  782. BOOLEAN
  783. DiskInvalidatePartitionTable(
  784. IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
  785. IN BOOLEAN PartitionLockHeld
  786. );
  787. #if defined (_X86_)
  788. NTSTATUS
  789. DiskGetDetectInfo(
  790. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
  791. OUT PDISK_DETECTION_INFO DetectInfo
  792. );
  793. NTSTATUS
  794. DiskReadSignature(
  795. IN PDEVICE_OBJECT Fdo
  796. );
  797. BOOLEAN
  798. DiskIsNT4Geometry(
  799. IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
  800. );
  801. #else
  802. #define DiskGetDetectInfo(FdoExtension, DetectInfo) (STATUS_UNSUCCESSFUL)
  803. #endif
  804. #define DiskHashGuid(Guid) (((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0])