Source code of Windows XP (NT5)
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.

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