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.

2617 lines
61 KiB

  1. /*++ BUILD Version: 0011 // Increment this if a change has global effects
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. hal.h
  5. Abstract:
  6. This header file defines the Hardware Architecture Layer (HAL) interfaces
  7. that are exported by a system vendor to the NT system.
  8. Author:
  9. David N. Cutler (davec) 25-Apr-1991
  10. Revision History:
  11. --*/
  12. // begin_nthal
  13. #ifndef _HAL_
  14. #define _HAL_
  15. // begin_ntosp
  16. //
  17. // Define OEM bitmapped font check values.
  18. //
  19. #define OEM_FONT_VERSION 0x200
  20. #define OEM_FONT_TYPE 0
  21. #define OEM_FONT_ITALIC 0
  22. #define OEM_FONT_UNDERLINE 0
  23. #define OEM_FONT_STRIKEOUT 0
  24. #define OEM_FONT_CHARACTER_SET 255
  25. #define OEM_FONT_FAMILY (3 << 4)
  26. //
  27. // Define OEM bitmapped font file header structure.
  28. //
  29. // N.B. this is a packed structure.
  30. //
  31. #include "pshpack1.h"
  32. typedef struct _OEM_FONT_FILE_HEADER {
  33. USHORT Version;
  34. ULONG FileSize;
  35. UCHAR Copyright[60];
  36. USHORT Type;
  37. USHORT Points;
  38. USHORT VerticleResolution;
  39. USHORT HorizontalResolution;
  40. USHORT Ascent;
  41. USHORT InternalLeading;
  42. USHORT ExternalLeading;
  43. UCHAR Italic;
  44. UCHAR Underline;
  45. UCHAR StrikeOut;
  46. USHORT Weight;
  47. UCHAR CharacterSet;
  48. USHORT PixelWidth;
  49. USHORT PixelHeight;
  50. UCHAR Family;
  51. USHORT AverageWidth;
  52. USHORT MaximumWidth;
  53. UCHAR FirstCharacter;
  54. UCHAR LastCharacter;
  55. UCHAR DefaultCharacter;
  56. UCHAR BreakCharacter;
  57. USHORT WidthInBytes;
  58. ULONG Device;
  59. ULONG Face;
  60. ULONG BitsPointer;
  61. ULONG BitsOffset;
  62. UCHAR Filler;
  63. struct {
  64. USHORT Width;
  65. USHORT Offset;
  66. } Map[1];
  67. } OEM_FONT_FILE_HEADER, *POEM_FONT_FILE_HEADER;
  68. #include "poppack.h"
  69. // end_ntosp
  70. // begin_ntddk begin_wdm begin_ntosp
  71. //
  72. // Define the device description structure.
  73. //
  74. typedef struct _DEVICE_DESCRIPTION {
  75. ULONG Version;
  76. BOOLEAN Master;
  77. BOOLEAN ScatterGather;
  78. BOOLEAN DemandMode;
  79. BOOLEAN AutoInitialize;
  80. BOOLEAN Dma32BitAddresses;
  81. BOOLEAN IgnoreCount;
  82. BOOLEAN Reserved1; // must be false
  83. BOOLEAN Dma64BitAddresses;
  84. ULONG BusNumber; // unused for WDM
  85. ULONG DmaChannel;
  86. INTERFACE_TYPE InterfaceType;
  87. DMA_WIDTH DmaWidth;
  88. DMA_SPEED DmaSpeed;
  89. ULONG MaximumLength;
  90. ULONG DmaPort;
  91. } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION;
  92. //
  93. // Define the supported version numbers for the device description structure.
  94. //
  95. #define DEVICE_DESCRIPTION_VERSION 0
  96. #define DEVICE_DESCRIPTION_VERSION1 1
  97. #define DEVICE_DESCRIPTION_VERSION2 2
  98. // end_ntddk end_wdm
  99. //
  100. // Boot record disk partition table entry structure format.
  101. //
  102. typedef struct _PARTITION_DESCRIPTOR {
  103. UCHAR ActiveFlag; // Bootable or not
  104. UCHAR StartingTrack; // Not used
  105. UCHAR StartingCylinderLsb; // Not used
  106. UCHAR StartingCylinderMsb; // Not used
  107. UCHAR PartitionType; // 12 bit FAT, 16 bit FAT etc.
  108. UCHAR EndingTrack; // Not used
  109. UCHAR EndingCylinderLsb; // Not used
  110. UCHAR EndingCylinderMsb; // Not used
  111. UCHAR StartingSectorLsb0; // Hidden sectors
  112. UCHAR StartingSectorLsb1;
  113. UCHAR StartingSectorMsb0;
  114. UCHAR StartingSectorMsb1;
  115. UCHAR PartitionLengthLsb0; // Sectors in this partition
  116. UCHAR PartitionLengthLsb1;
  117. UCHAR PartitionLengthMsb0;
  118. UCHAR PartitionLengthMsb1;
  119. } PARTITION_DESCRIPTOR, *PPARTITION_DESCRIPTOR;
  120. //
  121. // Number of partition table entries
  122. //
  123. #define NUM_PARTITION_TABLE_ENTRIES 4
  124. //
  125. // Partition table record and boot signature offsets in 16-bit words.
  126. //
  127. #define PARTITION_TABLE_OFFSET (0x1be / 2)
  128. #define BOOT_SIGNATURE_OFFSET ((0x200 / 2) - 1)
  129. //
  130. // Boot record signature value.
  131. //
  132. #define BOOT_RECORD_SIGNATURE (0xaa55)
  133. //
  134. // Initial size of the Partition list structure.
  135. //
  136. #define PARTITION_BUFFER_SIZE 2048
  137. //
  138. // Partition active flag - i.e., boot indicator
  139. //
  140. #define PARTITION_ACTIVE_FLAG 0x80
  141. // end_ntosp
  142. // begin_ntddk
  143. //
  144. // The following function prototypes are for HAL routines with a prefix of Hal.
  145. //
  146. // General functions.
  147. //
  148. typedef
  149. BOOLEAN
  150. (*PHAL_RESET_DISPLAY_PARAMETERS) (
  151. IN ULONG Columns,
  152. IN ULONG Rows
  153. );
  154. NTHALAPI
  155. VOID
  156. HalAcquireDisplayOwnership (
  157. IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters
  158. );
  159. // end_ntddk
  160. NTHALAPI
  161. VOID
  162. HalDisplayString (
  163. PUCHAR String
  164. );
  165. NTHALAPI
  166. VOID
  167. HalQueryDisplayParameters (
  168. OUT PULONG WidthInCharacters,
  169. OUT PULONG HeightInLines,
  170. OUT PULONG CursorColumn,
  171. OUT PULONG CursorRow
  172. );
  173. NTHALAPI
  174. VOID
  175. HalSetDisplayParameters (
  176. IN ULONG CursorColumn,
  177. IN ULONG CursorRow
  178. );
  179. NTHALAPI
  180. BOOLEAN
  181. HalInitSystem (
  182. IN ULONG Phase,
  183. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  184. );
  185. NTHALAPI
  186. VOID
  187. HalProcessorIdle(
  188. VOID
  189. );
  190. NTHALAPI
  191. VOID
  192. HalReportResourceUsage (
  193. VOID
  194. );
  195. NTHALAPI
  196. ULONG
  197. HalSetTimeIncrement (
  198. IN ULONG DesiredIncrement
  199. );
  200. // begin_ntosp
  201. //
  202. // Get and set environment variable values.
  203. //
  204. NTHALAPI
  205. ARC_STATUS
  206. HalGetEnvironmentVariable (
  207. IN PCHAR Variable,
  208. IN USHORT Length,
  209. OUT PCHAR Buffer
  210. );
  211. NTHALAPI
  212. ARC_STATUS
  213. HalSetEnvironmentVariable (
  214. IN PCHAR Variable,
  215. IN PCHAR Value
  216. );
  217. NTHALAPI
  218. NTSTATUS
  219. HalGetEnvironmentVariableEx (
  220. IN PWSTR VariableName,
  221. IN LPGUID VendorGuid,
  222. OUT PVOID Value,
  223. IN OUT PULONG ValueLength,
  224. OUT PULONG Attributes OPTIONAL
  225. );
  226. NTSTATUS
  227. HalSetEnvironmentVariableEx (
  228. IN PWSTR VariableName,
  229. IN LPGUID VendorGuid,
  230. IN PVOID Value,
  231. IN ULONG ValueLength,
  232. IN ULONG Attributes
  233. );
  234. NTSTATUS
  235. HalEnumerateEnvironmentVariablesEx (
  236. IN ULONG InformationClass,
  237. OUT PVOID Buffer,
  238. IN OUT PULONG BufferLength
  239. );
  240. // end_ntosp
  241. //
  242. // Cache and write buffer flush functions.
  243. //
  244. //
  245. #if defined(_ALPHA_) || defined(_IA64_) // ntddk ntifs ntndis ntosp
  246. // ntddk ntifs ntndis ntosp
  247. NTHALAPI
  248. VOID
  249. HalChangeColorPage (
  250. IN PVOID NewColor,
  251. IN PVOID OldColor,
  252. IN ULONG PageFrame
  253. );
  254. NTHALAPI
  255. VOID
  256. HalFlushDcachePage (
  257. IN PVOID Color,
  258. IN ULONG PageFrame,
  259. IN ULONG Length
  260. );
  261. // begin_ntosp
  262. NTHALAPI
  263. VOID
  264. HalFlushIoBuffers (
  265. IN PMDL Mdl,
  266. IN BOOLEAN ReadOperation,
  267. IN BOOLEAN DmaOperation
  268. );
  269. // begin_ntddk begin_ntifs begin_ntndis
  270. DECLSPEC_DEPRECATED_DDK // Use GetDmaRequirement
  271. NTHALAPI
  272. ULONG
  273. HalGetDmaAlignmentRequirement (
  274. VOID
  275. );
  276. // end_ntosp end_ntddk end_ntifs end_ntndis
  277. NTHALAPI
  278. VOID
  279. HalPurgeDcachePage (
  280. IN PVOID Color,
  281. IN ULONG PageFrame,
  282. IN ULONG Length
  283. );
  284. NTHALAPI
  285. VOID
  286. HalPurgeIcachePage (
  287. IN PVOID Color,
  288. IN ULONG PageFrame,
  289. IN ULONG Length
  290. );
  291. NTHALAPI
  292. VOID
  293. HalSweepDcache (
  294. VOID
  295. );
  296. NTHALAPI
  297. VOID
  298. HalSweepDcacheRange (
  299. IN PVOID BaseAddress,
  300. IN SIZE_T Length
  301. );
  302. NTHALAPI
  303. VOID
  304. HalSweepIcache (
  305. VOID
  306. );
  307. NTHALAPI
  308. VOID
  309. HalSweepIcacheRange (
  310. IN PVOID BaseAddress,
  311. IN SIZE_T Length
  312. );
  313. NTHALAPI
  314. VOID
  315. HalZeroPage (
  316. IN PVOID NewColor,
  317. IN PVOID OldColor,
  318. IN PFN_NUMBER PageFrame
  319. );
  320. #endif // ntddk ntifs ntndis ntosp
  321. // ntddk ntifs ntndis ntosp
  322. #if defined(_M_IX86) || defined(_M_AMD64) // ntddk ntifs ntndis ntosp
  323. // ntddk ntifs ntndis ntosp
  324. #define HalGetDmaAlignmentRequirement() 1L // ntddk ntifs ntndis ntosp
  325. NTHALAPI
  326. VOID
  327. HalHandleNMI (
  328. IN OUT PVOID NmiInformation
  329. );
  330. #if defined(_AMD64_)
  331. NTHALAPI
  332. VOID
  333. HalHandleMcheck (
  334. IN PKTRAP_FRAME TrapFrame,
  335. IN PKEXCEPTION_FRAME ExceptionFrame
  336. );
  337. #endif
  338. //
  339. // The following are temporary.
  340. //
  341. #if defined(_M_AMD64)
  342. NTHALAPI
  343. KIRQL
  344. HalSwapIrql (
  345. IN KIRQL Irql
  346. );
  347. NTHALAPI
  348. KIRQL
  349. HalGetCurrentIrql (
  350. VOID
  351. );
  352. #endif
  353. #endif // ntddk ntifs ntndis ntosp
  354. // ntddk ntifs wdm ntndis
  355. #if defined(_M_IA64)
  356. NTHALAPI
  357. VOID
  358. HalSweepCacheRange (
  359. IN PVOID BaseAddress,
  360. IN SIZE_T Length
  361. );
  362. NTHALAPI
  363. LONGLONG
  364. HalCallPal (
  365. IN ULONGLONG FunctionIndex,
  366. IN ULONGLONG Arguement1,
  367. IN ULONGLONG Arguement2,
  368. IN ULONGLONG Arguement3,
  369. OUT PULONGLONG ReturnValue0,
  370. OUT PULONGLONG ReturnValue1,
  371. OUT PULONGLONG ReturnValue2,
  372. OUT PULONGLONG ReturnValue3
  373. );
  374. #endif
  375. // begin_ntosp
  376. NTHALAPI // ntddk ntifs wdm ntndis
  377. VOID // ntddk ntifs wdm ntndis
  378. KeFlushWriteBuffer ( // ntddk ntifs wdm ntndis
  379. VOID // ntddk ntifs wdm ntndis
  380. ); // ntddk ntifs wdm ntndis
  381. // ntddk ntifs wdm ntndis
  382. #if defined(_ALPHA_)
  383. NTHALAPI
  384. PVOID
  385. HalCreateQva(
  386. IN PHYSICAL_ADDRESS PhysicalAddress,
  387. IN PVOID VirtualAddress
  388. );
  389. NTHALAPI
  390. PVOID
  391. HalDereferenceQva(
  392. PVOID Qva,
  393. INTERFACE_TYPE InterfaceType,
  394. ULONG BusNumber
  395. );
  396. #endif
  397. #if !defined(_X86_)
  398. NTHALAPI
  399. BOOLEAN
  400. HalCallBios (
  401. IN ULONG BiosCommand,
  402. IN OUT PULONG Eax,
  403. IN OUT PULONG Ebx,
  404. IN OUT PULONG Ecx,
  405. IN OUT PULONG Edx,
  406. IN OUT PULONG Esi,
  407. IN OUT PULONG Edi,
  408. IN OUT PULONG Ebp
  409. );
  410. #endif
  411. // end_ntosp
  412. //
  413. // Profiling functions.
  414. //
  415. NTHALAPI
  416. VOID
  417. HalCalibratePerformanceCounter (
  418. IN LONG volatile *Number,
  419. IN ULONGLONG NewCount
  420. );
  421. NTHALAPI
  422. ULONG_PTR
  423. HalSetProfileInterval (
  424. IN ULONG_PTR Interval
  425. );
  426. NTHALAPI
  427. VOID
  428. HalStartProfileInterrupt (
  429. KPROFILE_SOURCE ProfileSource
  430. );
  431. NTHALAPI
  432. VOID
  433. HalStopProfileInterrupt (
  434. KPROFILE_SOURCE ProfileSource
  435. );
  436. //
  437. // Timer and interrupt functions.
  438. //
  439. // begin_ntosp
  440. NTHALAPI
  441. BOOLEAN
  442. HalQueryRealTimeClock (
  443. OUT PTIME_FIELDS TimeFields
  444. );
  445. // end_ntosp
  446. NTHALAPI
  447. BOOLEAN
  448. HalSetRealTimeClock (
  449. IN PTIME_FIELDS TimeFields
  450. );
  451. #if defined(_M_IX86) || defined(_M_AMD64)
  452. NTHALAPI
  453. VOID
  454. FASTCALL
  455. HalRequestSoftwareInterrupt (
  456. KIRQL RequestIrql
  457. );
  458. ULONG
  459. FASTCALL
  460. HalSystemVectorDispatchEntry (
  461. IN ULONG Vector,
  462. OUT PKINTERRUPT_ROUTINE **FlatDispatch,
  463. OUT PKINTERRUPT_ROUTINE *NoConnection
  464. );
  465. #endif
  466. // begin_ntosp
  467. //
  468. // Firmware interface functions.
  469. //
  470. NTHALAPI
  471. VOID
  472. HalReturnToFirmware (
  473. IN FIRMWARE_REENTRY Routine
  474. );
  475. //
  476. // System interrupts functions.
  477. //
  478. NTHALAPI
  479. VOID
  480. HalDisableSystemInterrupt (
  481. IN ULONG Vector,
  482. IN KIRQL Irql
  483. );
  484. NTHALAPI
  485. BOOLEAN
  486. HalEnableSystemInterrupt (
  487. IN ULONG Vector,
  488. IN KIRQL Irql,
  489. IN KINTERRUPT_MODE InterruptMode
  490. );
  491. // begin_ntddk
  492. //
  493. // I/O driver configuration functions.
  494. //
  495. #if !defined(NO_LEGACY_DRIVERS)
  496. DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReportDetectedDevice
  497. NTHALAPI
  498. NTSTATUS
  499. HalAssignSlotResources (
  500. IN PUNICODE_STRING RegistryPath,
  501. IN PUNICODE_STRING DriverClassName OPTIONAL,
  502. IN PDRIVER_OBJECT DriverObject,
  503. IN PDEVICE_OBJECT DeviceObject,
  504. IN INTERFACE_TYPE BusType,
  505. IN ULONG BusNumber,
  506. IN ULONG SlotNumber,
  507. IN OUT PCM_RESOURCE_LIST *AllocatedResources
  508. );
  509. DECLSPEC_DEPRECATED_DDK // Use Pnp or IoReportDetectedDevice
  510. NTHALAPI
  511. ULONG
  512. HalGetInterruptVector(
  513. IN INTERFACE_TYPE InterfaceType,
  514. IN ULONG BusNumber,
  515. IN ULONG BusInterruptLevel,
  516. IN ULONG BusInterruptVector,
  517. OUT PKIRQL Irql,
  518. OUT PKAFFINITY Affinity
  519. );
  520. DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
  521. NTHALAPI
  522. ULONG
  523. HalSetBusData(
  524. IN BUS_DATA_TYPE BusDataType,
  525. IN ULONG BusNumber,
  526. IN ULONG SlotNumber,
  527. IN PVOID Buffer,
  528. IN ULONG Length
  529. );
  530. #endif // NO_LEGACY_DRIVERS
  531. DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
  532. NTHALAPI
  533. ULONG
  534. HalSetBusDataByOffset(
  535. IN BUS_DATA_TYPE BusDataType,
  536. IN ULONG BusNumber,
  537. IN ULONG SlotNumber,
  538. IN PVOID Buffer,
  539. IN ULONG Offset,
  540. IN ULONG Length
  541. );
  542. DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
  543. NTHALAPI
  544. BOOLEAN
  545. HalTranslateBusAddress(
  546. IN INTERFACE_TYPE InterfaceType,
  547. IN ULONG BusNumber,
  548. IN PHYSICAL_ADDRESS BusAddress,
  549. IN OUT PULONG AddressSpace,
  550. OUT PPHYSICAL_ADDRESS TranslatedAddress
  551. );
  552. //
  553. // Values for AddressSpace parameter of HalTranslateBusAddress
  554. //
  555. // 0x0 - Memory space
  556. // 0x1 - Port space
  557. // 0x2 - 0x1F - Address spaces specific for Alpha
  558. // 0x2 - UserMode view of memory space
  559. // 0x3 - UserMode view of port space
  560. // 0x4 - Dense memory space
  561. // 0x5 - reserved
  562. // 0x6 - UserMode view of dense memory space
  563. // 0x7 - 0x1F - reserved
  564. //
  565. NTHALAPI
  566. PVOID
  567. HalAllocateCrashDumpRegisters(
  568. IN PADAPTER_OBJECT AdapterObject,
  569. IN OUT PULONG NumberOfMapRegisters
  570. );
  571. #if !defined(NO_LEGACY_DRIVERS)
  572. DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
  573. NTHALAPI
  574. ULONG
  575. HalGetBusData(
  576. IN BUS_DATA_TYPE BusDataType,
  577. IN ULONG BusNumber,
  578. IN ULONG SlotNumber,
  579. IN PVOID Buffer,
  580. IN ULONG Length
  581. );
  582. #endif // NO_LEGACY_DRIVERS
  583. DECLSPEC_DEPRECATED_DDK // Use IRP_MN_QUERY_INTERFACE and IRP_MN_READ_CONFIG
  584. NTHALAPI
  585. ULONG
  586. HalGetBusDataByOffset(
  587. IN BUS_DATA_TYPE BusDataType,
  588. IN ULONG BusNumber,
  589. IN ULONG SlotNumber,
  590. IN PVOID Buffer,
  591. IN ULONG Offset,
  592. IN ULONG Length
  593. );
  594. DECLSPEC_DEPRECATED_DDK // Use IoGetDmaAdapter
  595. NTHALAPI
  596. PADAPTER_OBJECT
  597. HalGetAdapter(
  598. IN PDEVICE_DESCRIPTION DeviceDescription,
  599. IN OUT PULONG NumberOfMapRegisters
  600. );
  601. // end_ntddk end_ntosp
  602. #if !defined(NO_LEGACY_DRIVERS)
  603. NTHALAPI
  604. NTSTATUS
  605. HalAdjustResourceList (
  606. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
  607. );
  608. #endif // NO_LEGACY_DRIVERS
  609. // begin_ntddk begin_ntosp
  610. //
  611. // System beep functions.
  612. //
  613. #if !defined(NO_LEGACY_DRIVERS)
  614. NTHALAPI
  615. BOOLEAN
  616. HalMakeBeep(
  617. IN ULONG Frequency
  618. );
  619. #endif // NO_LEGACY_DRIVERS
  620. //
  621. // The following function prototypes are for HAL routines with a prefix of Io.
  622. //
  623. // DMA adapter object functions.
  624. //
  625. // end_ntddk end_ntosp
  626. //
  627. // Multi-Processorfunctions.
  628. //
  629. NTHALAPI
  630. BOOLEAN
  631. HalAllProcessorsStarted (
  632. VOID
  633. );
  634. NTHALAPI
  635. VOID
  636. HalInitializeProcessor (
  637. IN ULONG Number,
  638. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  639. );
  640. NTHALAPI
  641. BOOLEAN
  642. HalStartNextProcessor (
  643. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  644. IN PKPROCESSOR_STATE ProcessorState
  645. );
  646. NTHALAPI
  647. VOID
  648. HalRequestIpi (
  649. IN KAFFINITY Mask
  650. );
  651. //
  652. // The following function prototypes are for HAL routines with a prefix of Kd.
  653. //
  654. // Kernel debugger port functions.
  655. //
  656. NTHALAPI
  657. BOOLEAN
  658. KdPortInitialize (
  659. PDEBUG_PARAMETERS DebugParameters,
  660. PLOADER_PARAMETER_BLOCK LoaderBlock,
  661. BOOLEAN Initialize
  662. );
  663. NTHALAPI
  664. ULONG
  665. KdPortGetByte (
  666. OUT PUCHAR Input
  667. );
  668. NTHALAPI
  669. ULONG
  670. KdPortPollByte (
  671. OUT PUCHAR Input
  672. );
  673. NTHALAPI
  674. VOID
  675. KdPortPutByte (
  676. IN UCHAR Output
  677. );
  678. NTHALAPI
  679. VOID
  680. KdPortRestore (
  681. VOID
  682. );
  683. NTHALAPI
  684. VOID
  685. KdPortSave (
  686. VOID
  687. );
  688. //
  689. // The following function prototypes are for HAL routines with a prefix of Ke.
  690. //
  691. // begin_ntddk begin_ntifs begin_wdm begin_ntosp
  692. //
  693. // Performance counter function.
  694. //
  695. NTHALAPI
  696. LARGE_INTEGER
  697. KeQueryPerformanceCounter (
  698. OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL
  699. );
  700. // begin_ntndis
  701. //
  702. // Stall processor execution function.
  703. //
  704. NTHALAPI
  705. VOID
  706. KeStallExecutionProcessor (
  707. IN ULONG MicroSeconds
  708. );
  709. // end_ntddk end_ntifs end_wdm end_ntndis end_ntosp
  710. //*****************************************************************************
  711. //
  712. // HAL BUS EXTENDERS
  713. //
  714. // Bus handlers
  715. //
  716. // begin_ntddk
  717. typedef
  718. VOID
  719. (*PDEVICE_CONTROL_COMPLETION)(
  720. IN struct _DEVICE_CONTROL_CONTEXT *ControlContext
  721. );
  722. typedef struct _DEVICE_CONTROL_CONTEXT {
  723. NTSTATUS Status;
  724. PDEVICE_HANDLER_OBJECT DeviceHandler;
  725. PDEVICE_OBJECT DeviceObject;
  726. ULONG ControlCode;
  727. PVOID Buffer;
  728. PULONG BufferLength;
  729. PVOID Context;
  730. } DEVICE_CONTROL_CONTEXT, *PDEVICE_CONTROL_CONTEXT;
  731. // end_ntddk
  732. typedef struct _HAL_DEVICE_CONTROL {
  733. //
  734. // Handler this DeviceControl is for
  735. //
  736. struct _BUS_HANDLER *Handler;
  737. struct _BUS_HANDLER *RootHandler;
  738. //
  739. // Bus specific storage for this Context
  740. //
  741. PVOID BusExtensionData;
  742. //
  743. // Reserved for HALs use
  744. //
  745. ULONG HalReserved[4];
  746. //
  747. // Reserved for BusExtneder use
  748. //
  749. ULONG BusExtenderReserved[4];
  750. //
  751. // DeviceControl Context and the CompletionRoutine
  752. //
  753. PDEVICE_CONTROL_COMPLETION CompletionRoutine;
  754. DEVICE_CONTROL_CONTEXT DeviceControl;
  755. } HAL_DEVICE_CONTROL_CONTEXT, *PHAL_DEVICE_CONTROL_CONTEXT;
  756. typedef
  757. ULONG
  758. (*PGETSETBUSDATA)(
  759. IN struct _BUS_HANDLER *BusHandler,
  760. IN struct _BUS_HANDLER *RootHandler,
  761. IN ULONG SlotNumber,
  762. IN PVOID Buffer,
  763. IN ULONG Offset,
  764. IN ULONG Length
  765. );
  766. typedef
  767. ULONG
  768. (*PGETINTERRUPTVECTOR)(
  769. IN struct _BUS_HANDLER *BusHandler,
  770. IN struct _BUS_HANDLER *RootHandler,
  771. IN ULONG BusInterruptLevel,
  772. IN ULONG BusInterruptVector,
  773. OUT PKIRQL Irql,
  774. OUT PKAFFINITY Affinity
  775. );
  776. typedef
  777. BOOLEAN
  778. (*PTRANSLATEBUSADDRESS)(
  779. IN struct _BUS_HANDLER *BusHandler,
  780. IN struct _BUS_HANDLER *RootHandler,
  781. IN PHYSICAL_ADDRESS BusAddress,
  782. IN OUT PULONG AddressSpace,
  783. OUT PPHYSICAL_ADDRESS TranslatedAddress
  784. );
  785. typedef NTSTATUS
  786. (*PADJUSTRESOURCELIST)(
  787. IN struct _BUS_HANDLER *BusHandler,
  788. IN struct _BUS_HANDLER *RootHandler,
  789. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
  790. );
  791. typedef PDEVICE_HANDLER_OBJECT
  792. (*PREFERENCE_DEVICE_HANDLER)(
  793. IN struct _BUS_HANDLER *BusHandler,
  794. IN struct _BUS_HANDLER *RootHandler,
  795. IN ULONG SlotNumber
  796. );
  797. //typedef VOID
  798. //(*PDEREFERENCE_DEVICE_HANDLER)(
  799. // IN PDEVICE_HANDLER_OBJECT DeviceHandler
  800. // );
  801. typedef NTSTATUS
  802. (*PASSIGNSLOTRESOURCES)(
  803. IN struct _BUS_HANDLER *BusHandler,
  804. IN struct _BUS_HANDLER *RootHandler,
  805. IN PUNICODE_STRING RegistryPath,
  806. IN PUNICODE_STRING DriverClassName OPTIONAL,
  807. IN PDRIVER_OBJECT DriverObject,
  808. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  809. IN ULONG SlotNumber,
  810. IN OUT PCM_RESOURCE_LIST *AllocatedResources
  811. );
  812. typedef
  813. NTSTATUS
  814. (*PQUERY_BUS_SLOTS)(
  815. IN struct _BUS_HANDLER *BusHandler,
  816. IN struct _BUS_HANDLER *RootHandler,
  817. IN ULONG BufferSize,
  818. OUT PULONG SlotNumbers,
  819. OUT PULONG ReturnedLength
  820. );
  821. typedef ULONG
  822. (*PGET_SET_DEVICE_INSTANCE_DATA)(
  823. IN struct _BUS_HANDLER *BusHandler,
  824. IN struct _BUS_HANDLER *RootHandler,
  825. IN PDEVICE_HANDLER_OBJECT DeviceHandler,
  826. IN ULONG DataType,
  827. IN PVOID Buffer,
  828. IN ULONG Offset,
  829. IN ULONG Length
  830. );
  831. typedef
  832. NTSTATUS
  833. (*PDEVICE_CONTROL)(
  834. IN PHAL_DEVICE_CONTROL_CONTEXT Context
  835. );
  836. typedef
  837. NTSTATUS
  838. (*PHIBERNATEBRESUMEBUS)(
  839. IN struct _BUS_HANDLER *BusHandler,
  840. IN struct _BUS_HANDLER *RootHandler
  841. );
  842. //
  843. // Supported range structures
  844. //
  845. #define BUS_SUPPORTED_RANGE_VERSION 1
  846. typedef struct _SUPPORTED_RANGE {
  847. struct _SUPPORTED_RANGE *Next;
  848. ULONG SystemAddressSpace;
  849. LONGLONG SystemBase;
  850. LONGLONG Base;
  851. LONGLONG Limit;
  852. } SUPPORTED_RANGE, *PSUPPORTED_RANGE;
  853. typedef struct _SUPPORTED_RANGES {
  854. USHORT Version;
  855. BOOLEAN Sorted;
  856. UCHAR Reserved;
  857. ULONG NoIO;
  858. SUPPORTED_RANGE IO;
  859. ULONG NoMemory;
  860. SUPPORTED_RANGE Memory;
  861. ULONG NoPrefetchMemory;
  862. SUPPORTED_RANGE PrefetchMemory;
  863. ULONG NoDma;
  864. SUPPORTED_RANGE Dma;
  865. } SUPPORTED_RANGES, *PSUPPORTED_RANGES;
  866. //
  867. // Bus handler structure
  868. //
  869. #define BUS_HANDLER_VERSION 1
  870. typedef struct _BUS_HANDLER {
  871. //
  872. // Version of structure
  873. //
  874. ULONG Version;
  875. //
  876. // This bus handler structure is for the following bus
  877. //
  878. INTERFACE_TYPE InterfaceType;
  879. BUS_DATA_TYPE ConfigurationType;
  880. ULONG BusNumber;
  881. //
  882. // Device object for this bus extender, or NULL if it is
  883. // a hal internal bus extender
  884. //
  885. PDEVICE_OBJECT DeviceObject;
  886. //
  887. // The parent handlers for this bus
  888. //
  889. struct _BUS_HANDLER *ParentHandler;
  890. //
  891. // Bus specific strorage
  892. //
  893. PVOID BusData;
  894. //
  895. // Amount of bus specific storage needed for DeviceControl function calls
  896. //
  897. ULONG DeviceControlExtensionSize;
  898. //
  899. // Supported address ranges this bus allows
  900. //
  901. PSUPPORTED_RANGES BusAddresses;
  902. //
  903. // For future use
  904. //
  905. ULONG Reserved[4];
  906. //
  907. // Handlers for this bus
  908. //
  909. PGETSETBUSDATA GetBusData;
  910. PGETSETBUSDATA SetBusData;
  911. PADJUSTRESOURCELIST AdjustResourceList;
  912. PASSIGNSLOTRESOURCES AssignSlotResources;
  913. PGETINTERRUPTVECTOR GetInterruptVector;
  914. PTRANSLATEBUSADDRESS TranslateBusAddress;
  915. PVOID Spare1;
  916. PVOID Spare2;
  917. PVOID Spare3;
  918. PVOID Spare4;
  919. PVOID Spare5;
  920. PVOID Spare6;
  921. PVOID Spare7;
  922. PVOID Spare8;
  923. } BUS_HANDLER, *PBUS_HANDLER;
  924. VOID
  925. HalpInitBusHandler (
  926. VOID
  927. );
  928. typedef
  929. NTSTATUS
  930. (*PINSTALL_BUS_HANDLER)(
  931. IN PBUS_HANDLER Bus
  932. );
  933. typedef
  934. NTSTATUS
  935. (*pHalRegisterBusHandler)(
  936. IN INTERFACE_TYPE InterfaceType,
  937. IN BUS_DATA_TYPE AssociatedConfigurationSpace,
  938. IN ULONG BusNumber,
  939. IN INTERFACE_TYPE ParentBusType,
  940. IN ULONG ParentBusNumber,
  941. IN ULONG SizeofBusExtensionData,
  942. IN PINSTALL_BUS_HANDLER InstallBusHandlers,
  943. OUT PBUS_HANDLER *BusHandler
  944. );
  945. NTSTATUS
  946. HaliRegisterBusHandler (
  947. IN INTERFACE_TYPE InterfaceType,
  948. IN BUS_DATA_TYPE AssociatedConfigurationSpace,
  949. IN ULONG BusNumber,
  950. IN INTERFACE_TYPE ParentBusType,
  951. IN ULONG ParentBusNumber,
  952. IN ULONG SizeofBusExtensionData,
  953. IN PINSTALL_BUS_HANDLER InstallBusHandlers,
  954. OUT PBUS_HANDLER *BusHandler
  955. );
  956. // begin_ntddk begin_ntosp
  957. typedef
  958. PBUS_HANDLER
  959. (FASTCALL *pHalHandlerForBus) (
  960. IN INTERFACE_TYPE InterfaceType,
  961. IN ULONG BusNumber
  962. );
  963. // end_ntddk end_ntosp
  964. PBUS_HANDLER
  965. FASTCALL
  966. HaliReferenceHandlerForBus (
  967. IN INTERFACE_TYPE InterfaceType,
  968. IN ULONG BusNumber
  969. );
  970. PBUS_HANDLER
  971. FASTCALL
  972. HaliHandlerForBus (
  973. IN INTERFACE_TYPE InterfaceType,
  974. IN ULONG BusNumber
  975. );
  976. typedef VOID
  977. (FASTCALL *pHalRefernceBusHandler) (
  978. IN PBUS_HANDLER BusHandler
  979. );
  980. VOID
  981. FASTCALL
  982. HaliDerefernceBusHandler (
  983. IN PBUS_HANDLER BusHandler
  984. );
  985. typedef
  986. PBUS_HANDLER
  987. (FASTCALL *pHalHandlerForConfigSpace) (
  988. IN BUS_DATA_TYPE ConfigSpace,
  989. IN ULONG BusNumber
  990. );
  991. PBUS_HANDLER
  992. FASTCALL
  993. HaliHandlerForConfigSpace (
  994. IN BUS_DATA_TYPE ConfigSpace,
  995. IN ULONG BusNumber
  996. );
  997. // begin_ntddk begin_ntosp
  998. typedef
  999. VOID
  1000. (FASTCALL *pHalReferenceBusHandler) (
  1001. IN PBUS_HANDLER BusHandler
  1002. );
  1003. // end_ntddk end_ntosp
  1004. VOID
  1005. FASTCALL
  1006. HaliReferenceBusHandler (
  1007. IN PBUS_HANDLER BusHandler
  1008. );
  1009. VOID
  1010. FASTCALL
  1011. HaliDereferenceBusHandler (
  1012. IN PBUS_HANDLER BusHandler
  1013. );
  1014. NTSTATUS
  1015. HaliQueryBusSlots (
  1016. IN PBUS_HANDLER BusHandler,
  1017. IN ULONG BufferSize,
  1018. OUT PULONG SlotNumbers,
  1019. OUT PULONG ReturnedLength
  1020. );
  1021. NTSTATUS
  1022. HaliAdjustResourceListRange (
  1023. IN PSUPPORTED_RANGES SupportedRanges,
  1024. IN PSUPPORTED_RANGE InterruptRanges,
  1025. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
  1026. );
  1027. VOID
  1028. HaliLocateHiberRanges (
  1029. IN PVOID MemoryMap
  1030. );
  1031. typedef
  1032. VOID
  1033. (*pHalSetWakeEnable)(
  1034. IN BOOLEAN Enable
  1035. );
  1036. typedef
  1037. VOID
  1038. (*pHalSetWakeAlarm)(
  1039. IN ULONGLONG WakeTime,
  1040. IN PTIME_FIELDS WakeTimeFields
  1041. );
  1042. typedef
  1043. VOID
  1044. (*pHalLocateHiberRanges)(
  1045. IN PVOID MemoryMap
  1046. );
  1047. // begin_ntddk begin_ntosp
  1048. //*****************************************************************************
  1049. // HAL Function dispatch
  1050. //
  1051. typedef enum _HAL_QUERY_INFORMATION_CLASS {
  1052. HalInstalledBusInformation,
  1053. HalProfileSourceInformation,
  1054. HalInformationClassUnused1,
  1055. HalPowerInformation,
  1056. HalProcessorSpeedInformation,
  1057. HalCallbackInformation,
  1058. HalMapRegisterInformation,
  1059. HalMcaLogInformation, // Machine Check Abort Information
  1060. HalFrameBufferCachingInformation,
  1061. HalDisplayBiosInformation,
  1062. HalProcessorFeatureInformation,
  1063. HalNumaTopologyInterface,
  1064. HalErrorInformation, // General MCA, CMC, CPE Error Information.
  1065. HalCmcLogInformation, // Processor Corrected Machine Check Information
  1066. HalCpeLogInformation, // Corrected Platform Error Information
  1067. HalQueryMcaInterface,
  1068. HalQueryAMLIIllegalIOPortAddresses,
  1069. HalQueryMaxHotPlugMemoryAddress,
  1070. HalPartitionIpiInterface,
  1071. HalPlatformInformation
  1072. // information levels >= 0x8000000 reserved for OEM use
  1073. } HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS;
  1074. typedef enum _HAL_SET_INFORMATION_CLASS {
  1075. HalProfileSourceInterval,
  1076. HalProfileSourceInterruptHandler,
  1077. HalMcaRegisterDriver, // Registring Machine Check Abort driver
  1078. HalKernelErrorHandler,
  1079. HalCmcRegisterDriver, // Registring Processor Corrected Machine Check driver
  1080. HalCpeRegisterDriver, // Registring Corrected Platform Error driver
  1081. HalMcaLog,
  1082. HalCmcLog,
  1083. HalCpeLog,
  1084. } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
  1085. typedef
  1086. NTSTATUS
  1087. (*pHalQuerySystemInformation)(
  1088. IN HAL_QUERY_INFORMATION_CLASS InformationClass,
  1089. IN ULONG BufferSize,
  1090. IN OUT PVOID Buffer,
  1091. OUT PULONG ReturnedLength
  1092. );
  1093. NTSTATUS
  1094. HaliQuerySystemInformation(
  1095. IN HAL_SET_INFORMATION_CLASS InformationClass,
  1096. IN ULONG BufferSize,
  1097. IN OUT PVOID Buffer,
  1098. OUT PULONG ReturnedLength
  1099. );
  1100. NTSTATUS
  1101. HaliHandlePCIConfigSpaceAccess(
  1102. IN BOOLEAN Read,
  1103. IN ULONG Addr,
  1104. IN ULONG Size,
  1105. IN OUT PULONG pData
  1106. );
  1107. typedef
  1108. NTSTATUS
  1109. (*pHalSetSystemInformation)(
  1110. IN HAL_SET_INFORMATION_CLASS InformationClass,
  1111. IN ULONG BufferSize,
  1112. IN PVOID Buffer
  1113. );
  1114. NTSTATUS
  1115. HaliSetSystemInformation(
  1116. IN HAL_SET_INFORMATION_CLASS InformationClass,
  1117. IN ULONG BufferSize,
  1118. IN PVOID Buffer
  1119. );
  1120. typedef
  1121. VOID
  1122. (FASTCALL *pHalExamineMBR)(
  1123. IN PDEVICE_OBJECT DeviceObject,
  1124. IN ULONG SectorSize,
  1125. IN ULONG MBRTypeIdentifier,
  1126. OUT PVOID *Buffer
  1127. );
  1128. typedef
  1129. VOID
  1130. (FASTCALL *pHalIoAssignDriveLetters)(
  1131. IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
  1132. IN PSTRING NtDeviceName,
  1133. OUT PUCHAR NtSystemPath,
  1134. OUT PSTRING NtSystemPathString
  1135. );
  1136. typedef
  1137. NTSTATUS
  1138. (FASTCALL *pHalIoReadPartitionTable)(
  1139. IN PDEVICE_OBJECT DeviceObject,
  1140. IN ULONG SectorSize,
  1141. IN BOOLEAN ReturnRecognizedPartitions,
  1142. OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer
  1143. );
  1144. typedef
  1145. NTSTATUS
  1146. (FASTCALL *pHalIoSetPartitionInformation)(
  1147. IN PDEVICE_OBJECT DeviceObject,
  1148. IN ULONG SectorSize,
  1149. IN ULONG PartitionNumber,
  1150. IN ULONG PartitionType
  1151. );
  1152. typedef
  1153. NTSTATUS
  1154. (FASTCALL *pHalIoWritePartitionTable)(
  1155. IN PDEVICE_OBJECT DeviceObject,
  1156. IN ULONG SectorSize,
  1157. IN ULONG SectorsPerTrack,
  1158. IN ULONG NumberOfHeads,
  1159. IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer
  1160. );
  1161. typedef
  1162. NTSTATUS
  1163. (*pHalQueryBusSlots)(
  1164. IN PBUS_HANDLER BusHandler,
  1165. IN ULONG BufferSize,
  1166. OUT PULONG SlotNumbers,
  1167. OUT PULONG ReturnedLength
  1168. );
  1169. typedef
  1170. NTSTATUS
  1171. (*pHalInitPnpDriver)(
  1172. VOID
  1173. );
  1174. NTSTATUS
  1175. HaliInitPnpDriver(
  1176. VOID
  1177. );
  1178. typedef struct _PM_DISPATCH_TABLE {
  1179. ULONG Signature;
  1180. ULONG Version;
  1181. PVOID Function[1];
  1182. } PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE;
  1183. typedef
  1184. NTSTATUS
  1185. (*pHalInitPowerManagement)(
  1186. IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
  1187. OUT PPM_DISPATCH_TABLE *PmHalDispatchTable
  1188. );
  1189. NTSTATUS
  1190. HaliInitPowerManagement(
  1191. IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
  1192. IN OUT PPM_DISPATCH_TABLE *PmHalDispatchTable
  1193. );
  1194. typedef
  1195. struct _DMA_ADAPTER *
  1196. (*pHalGetDmaAdapter)(
  1197. IN PVOID Context,
  1198. IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
  1199. OUT PULONG NumberOfMapRegisters
  1200. );
  1201. struct _DMA_ADAPTER *
  1202. HaliGetDmaAdapter(
  1203. IN PVOID Context,
  1204. IN struct _DEVICE_DESCRIPTION *DeviceDescriptor,
  1205. OUT PULONG NumberOfMapRegisters
  1206. );
  1207. typedef
  1208. NTSTATUS
  1209. (*pHalGetInterruptTranslator)(
  1210. IN INTERFACE_TYPE ParentInterfaceType,
  1211. IN ULONG ParentBusNumber,
  1212. IN INTERFACE_TYPE BridgeInterfaceType,
  1213. IN USHORT Size,
  1214. IN USHORT Version,
  1215. OUT PTRANSLATOR_INTERFACE Translator,
  1216. OUT PULONG BridgeBusNumber
  1217. );
  1218. NTSTATUS
  1219. HaliGetInterruptTranslator(
  1220. IN INTERFACE_TYPE ParentInterfaceType,
  1221. IN ULONG ParentBusNumber,
  1222. IN INTERFACE_TYPE BridgeInterfaceType,
  1223. IN USHORT Size,
  1224. IN USHORT Version,
  1225. OUT PTRANSLATOR_INTERFACE Translator,
  1226. OUT PULONG BridgeBusNumber
  1227. );
  1228. typedef
  1229. BOOLEAN
  1230. (*pHalTranslateBusAddress)(
  1231. IN INTERFACE_TYPE InterfaceType,
  1232. IN ULONG BusNumber,
  1233. IN PHYSICAL_ADDRESS BusAddress,
  1234. IN OUT PULONG AddressSpace,
  1235. OUT PPHYSICAL_ADDRESS TranslatedAddress
  1236. );
  1237. typedef
  1238. NTSTATUS
  1239. (*pHalAssignSlotResources) (
  1240. IN PUNICODE_STRING RegistryPath,
  1241. IN PUNICODE_STRING DriverClassName OPTIONAL,
  1242. IN PDRIVER_OBJECT DriverObject,
  1243. IN PDEVICE_OBJECT DeviceObject,
  1244. IN INTERFACE_TYPE BusType,
  1245. IN ULONG BusNumber,
  1246. IN ULONG SlotNumber,
  1247. IN OUT PCM_RESOURCE_LIST *AllocatedResources
  1248. );
  1249. typedef
  1250. VOID
  1251. (*pHalHaltSystem) (
  1252. VOID
  1253. );
  1254. typedef
  1255. VOID
  1256. (*pHalResetDisplay) (
  1257. VOID
  1258. );
  1259. typedef
  1260. UCHAR
  1261. (*pHalVectorToIDTEntry) (
  1262. ULONG Vector
  1263. );
  1264. typedef
  1265. BOOLEAN
  1266. (*pHalFindBusAddressTranslation) (
  1267. IN PHYSICAL_ADDRESS BusAddress,
  1268. IN OUT PULONG AddressSpace,
  1269. OUT PPHYSICAL_ADDRESS TranslatedAddress,
  1270. IN OUT PULONG_PTR Context,
  1271. IN BOOLEAN NextBus
  1272. );
  1273. typedef
  1274. NTSTATUS
  1275. (*pHalStartMirroring)(
  1276. VOID
  1277. );
  1278. typedef
  1279. NTSTATUS
  1280. (*pHalEndMirroring)(
  1281. IN ULONG PassNumber
  1282. );
  1283. typedef
  1284. NTSTATUS
  1285. (*pHalMirrorPhysicalMemory)(
  1286. IN PHYSICAL_ADDRESS PhysicalAddress,
  1287. IN LARGE_INTEGER NumberOfBytes
  1288. );
  1289. typedef
  1290. NTSTATUS
  1291. (*pHalMirrorVerify)(
  1292. IN PHYSICAL_ADDRESS PhysicalAddress,
  1293. IN LARGE_INTEGER NumberOfBytes
  1294. );
  1295. typedef struct {
  1296. UCHAR Type; //CmResourceType
  1297. BOOLEAN Valid;
  1298. UCHAR Reserved[2];
  1299. PUCHAR TranslatedAddress;
  1300. ULONG Length;
  1301. } DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS;
  1302. typedef struct {
  1303. PHYSICAL_ADDRESS Start;
  1304. PHYSICAL_ADDRESS MaxEnd;
  1305. PVOID VirtualAddress;
  1306. ULONG Length;
  1307. BOOLEAN Cached;
  1308. BOOLEAN Aligned;
  1309. } DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS;
  1310. typedef struct {
  1311. ULONG Bus;
  1312. ULONG Slot;
  1313. USHORT VendorID;
  1314. USHORT DeviceID;
  1315. UCHAR BaseClass;
  1316. UCHAR SubClass;
  1317. UCHAR ProgIf;
  1318. BOOLEAN Initialized;
  1319. DEBUG_DEVICE_ADDRESS BaseAddress[6];
  1320. DEBUG_MEMORY_REQUIREMENTS Memory;
  1321. } DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR;
  1322. typedef
  1323. NTSTATUS
  1324. (*pKdSetupPciDeviceForDebugging)(
  1325. IN PVOID LoaderBlock, OPTIONAL
  1326. IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
  1327. );
  1328. typedef
  1329. NTSTATUS
  1330. (*pKdReleasePciDeviceForDebugging)(
  1331. IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
  1332. );
  1333. typedef
  1334. PVOID
  1335. (*pKdGetAcpiTablePhase0)(
  1336. IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
  1337. IN ULONG Signature
  1338. );
  1339. typedef
  1340. VOID
  1341. (*pKdCheckPowerButton)(
  1342. VOID
  1343. );
  1344. typedef
  1345. VOID
  1346. (*pHalEndOfBoot)(
  1347. VOID
  1348. );
  1349. typedef
  1350. PVOID
  1351. (*pKdMapPhysicalMemory64)(
  1352. IN PHYSICAL_ADDRESS PhysicalAddress,
  1353. IN ULONG NumberPages
  1354. );
  1355. typedef
  1356. VOID
  1357. (*pKdUnmapVirtualAddress)(
  1358. IN PVOID VirtualAddress,
  1359. IN ULONG NumberPages
  1360. );
  1361. typedef struct {
  1362. ULONG Version;
  1363. pHalQuerySystemInformation HalQuerySystemInformation;
  1364. pHalSetSystemInformation HalSetSystemInformation;
  1365. pHalQueryBusSlots HalQueryBusSlots;
  1366. ULONG Spare1;
  1367. pHalExamineMBR HalExamineMBR;
  1368. pHalIoAssignDriveLetters HalIoAssignDriveLetters;
  1369. pHalIoReadPartitionTable HalIoReadPartitionTable;
  1370. pHalIoSetPartitionInformation HalIoSetPartitionInformation;
  1371. pHalIoWritePartitionTable HalIoWritePartitionTable;
  1372. pHalHandlerForBus HalReferenceHandlerForBus;
  1373. pHalReferenceBusHandler HalReferenceBusHandler;
  1374. pHalReferenceBusHandler HalDereferenceBusHandler;
  1375. pHalInitPnpDriver HalInitPnpDriver;
  1376. pHalInitPowerManagement HalInitPowerManagement;
  1377. pHalGetDmaAdapter HalGetDmaAdapter;
  1378. pHalGetInterruptTranslator HalGetInterruptTranslator;
  1379. pHalStartMirroring HalStartMirroring;
  1380. pHalEndMirroring HalEndMirroring;
  1381. pHalMirrorPhysicalMemory HalMirrorPhysicalMemory;
  1382. pHalEndOfBoot HalEndOfBoot;
  1383. pHalMirrorVerify HalMirrorVerify;
  1384. } HAL_DISPATCH, *PHAL_DISPATCH;
  1385. #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)
  1386. extern PHAL_DISPATCH HalDispatchTable;
  1387. #define HALDISPATCH HalDispatchTable
  1388. #else
  1389. extern HAL_DISPATCH HalDispatchTable;
  1390. #define HALDISPATCH (&HalDispatchTable)
  1391. #endif
  1392. #define HAL_DISPATCH_VERSION 3
  1393. #define HalDispatchTableVersion HALDISPATCH->Version
  1394. #define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation
  1395. #define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation
  1396. #define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots
  1397. #define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus
  1398. #define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler
  1399. #define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler
  1400. #define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver
  1401. #define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement
  1402. #define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter
  1403. #define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator
  1404. #define HalStartMirroring HALDISPATCH->HalStartMirroring
  1405. #define HalEndMirroring HALDISPATCH->HalEndMirroring
  1406. #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory
  1407. #define HalEndOfBoot HALDISPATCH->HalEndOfBoot
  1408. #define HalMirrorVerify HALDISPATCH->HalMirrorVerify
  1409. // end_ntddk end_ntosp
  1410. typedef struct {
  1411. ULONG Version;
  1412. pHalHandlerForBus HalHandlerForBus;
  1413. pHalHandlerForConfigSpace HalHandlerForConfigSpace;
  1414. pHalLocateHiberRanges HalLocateHiberRanges;
  1415. pHalRegisterBusHandler HalRegisterBusHandler;
  1416. pHalSetWakeEnable HalSetWakeEnable;
  1417. pHalSetWakeAlarm HalSetWakeAlarm;
  1418. pHalTranslateBusAddress HalPciTranslateBusAddress;
  1419. pHalAssignSlotResources HalPciAssignSlotResources;
  1420. pHalHaltSystem HalHaltSystem;
  1421. pHalFindBusAddressTranslation HalFindBusAddressTranslation;
  1422. pHalResetDisplay HalResetDisplay;
  1423. pKdSetupPciDeviceForDebugging KdSetupPciDeviceForDebugging;
  1424. pKdReleasePciDeviceForDebugging KdReleasePciDeviceForDebugging;
  1425. pKdGetAcpiTablePhase0 KdGetAcpiTablePhase0;
  1426. pKdCheckPowerButton KdCheckPowerButton;
  1427. pHalVectorToIDTEntry HalVectorToIDTEntry;
  1428. pKdMapPhysicalMemory64 KdMapPhysicalMemory64;
  1429. pKdUnmapVirtualAddress KdUnmapVirtualAddress;
  1430. } HAL_PRIVATE_DISPATCH, *PHAL_PRIVATE_DISPATCH;
  1431. #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)
  1432. extern PHAL_PRIVATE_DISPATCH HalPrivateDispatchTable;
  1433. #define HALPDISPATCH HalPrivateDispatchTable
  1434. #else
  1435. extern HAL_PRIVATE_DISPATCH HalPrivateDispatchTable;
  1436. #define HALPDISPATCH (&HalPrivateDispatchTable)
  1437. #endif
  1438. #define HAL_PRIVATE_DISPATCH_VERSION 2
  1439. #define HalRegisterBusHandler HALPDISPATCH->HalRegisterBusHandler
  1440. #define HalHandlerForBus HALPDISPATCH->HalHandlerForBus
  1441. #define HalHandlerForConfigSpace HALPDISPATCH->HalHandlerForConfigSpace
  1442. #define HalLocateHiberRanges HALPDISPATCH->HalLocateHiberRanges
  1443. #define HalSetWakeEnable HALPDISPATCH->HalSetWakeEnable
  1444. #define HalSetWakeAlarm HALPDISPATCH->HalSetWakeAlarm
  1445. #define HalHaltSystem HALPDISPATCH->HalHaltSystem
  1446. #define HalResetDisplay HALPDISPATCH->HalResetDisplay
  1447. #define KdSetupPciDeviceForDebugging HALPDISPATCH->KdSetupPciDeviceForDebugging
  1448. #define KdReleasePciDeviceForDebugging HALPDISPATCH->KdReleasePciDeviceForDebugging
  1449. #define KdGetAcpiTablePhase0 HALPDISPATCH->KdGetAcpiTablePhase0
  1450. #define KdCheckPowerButton HALPDISPATCH->KdCheckPowerButton
  1451. #define HalVectorToIDTEntry HALPDISPATCH->HalVectorToIDTEntry
  1452. #define KdMapPhysicalMemory64 HALPDISPATCH->KdMapPhysicalMemory64
  1453. #define KdUnmapVirtualAddress HALPDISPATCH->KdUnmapVirtualAddress
  1454. // begin_ntddk begin_ntosp
  1455. //
  1456. // HAL System Information Structures.
  1457. //
  1458. // for the information class "HalInstalledBusInformation"
  1459. typedef struct _HAL_BUS_INFORMATION{
  1460. INTERFACE_TYPE BusType;
  1461. BUS_DATA_TYPE ConfigurationType;
  1462. ULONG BusNumber;
  1463. ULONG Reserved;
  1464. } HAL_BUS_INFORMATION, *PHAL_BUS_INFORMATION;
  1465. // for the information class "HalProfileSourceInformation"
  1466. typedef struct _HAL_PROFILE_SOURCE_INFORMATION {
  1467. KPROFILE_SOURCE Source;
  1468. BOOLEAN Supported;
  1469. ULONG Interval;
  1470. } HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
  1471. typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX {
  1472. KPROFILE_SOURCE Source;
  1473. BOOLEAN Supported;
  1474. ULONG_PTR Interval;
  1475. ULONG_PTR DefInterval;
  1476. ULONG_PTR MaxInterval;
  1477. ULONG_PTR MinInterval;
  1478. } HAL_PROFILE_SOURCE_INFORMATION_EX, *PHAL_PROFILE_SOURCE_INFORMATION_EX;
  1479. // for the information class "HalProfileSourceInterval"
  1480. typedef struct _HAL_PROFILE_SOURCE_INTERVAL {
  1481. KPROFILE_SOURCE Source;
  1482. ULONG_PTR Interval;
  1483. } HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
  1484. // for the information class "HalDispayBiosInformation"
  1485. typedef enum _HAL_DISPLAY_BIOS_INFORMATION {
  1486. HalDisplayInt10Bios,
  1487. HalDisplayEmulatedBios,
  1488. HalDisplayNoBios
  1489. } HAL_DISPLAY_BIOS_INFORMATION, *PHAL_DISPLAY_BIOS_INFORMATION;
  1490. // for the information class "HalPowerInformation"
  1491. typedef struct _HAL_POWER_INFORMATION {
  1492. ULONG TBD;
  1493. } HAL_POWER_INFORMATION, *PHAL_POWER_INFORMATION;
  1494. // for the information class "HalProcessorSpeedInformation"
  1495. typedef struct _HAL_PROCESSOR_SPEED_INFO {
  1496. ULONG ProcessorSpeed;
  1497. } HAL_PROCESSOR_SPEED_INFORMATION, *PHAL_PROCESSOR_SPEED_INFORMATION;
  1498. // for the information class "HalCallbackInformation"
  1499. typedef struct _HAL_CALLBACKS {
  1500. PCALLBACK_OBJECT SetSystemInformation;
  1501. PCALLBACK_OBJECT BusCheck;
  1502. } HAL_CALLBACKS, *PHAL_CALLBACKS;
  1503. // for the information class "HalProcessorFeatureInformation"
  1504. typedef struct _HAL_PROCESSOR_FEATURE {
  1505. ULONG UsableFeatureBits;
  1506. } HAL_PROCESSOR_FEATURE;
  1507. // for the information class "HalNumaTopologyInterface"
  1508. typedef ULONG HALNUMAPAGETONODE;
  1509. typedef
  1510. HALNUMAPAGETONODE
  1511. (*PHALNUMAPAGETONODE)(
  1512. IN ULONG_PTR PhysicalPageNumber
  1513. );
  1514. typedef
  1515. NTSTATUS
  1516. (*PHALNUMAQUERYPROCESSORNODE)(
  1517. IN ULONG ProcessorNumber,
  1518. OUT PUSHORT Identifier,
  1519. OUT PUCHAR Node
  1520. );
  1521. typedef struct _HAL_NUMA_TOPOLOGY_INTERFACE {
  1522. ULONG NumberOfNodes;
  1523. PHALNUMAQUERYPROCESSORNODE QueryProcessorNode;
  1524. PHALNUMAPAGETONODE PageToNode;
  1525. } HAL_NUMA_TOPOLOGY_INTERFACE;
  1526. typedef
  1527. NTSTATUS
  1528. (*PHALIOREADWRITEHANDLER)(
  1529. IN BOOLEAN fRead,
  1530. IN ULONG dwAddr,
  1531. IN ULONG dwSize,
  1532. IN OUT PULONG pdwData
  1533. );
  1534. // for the information class "HalQueryIllegalIOPortAddresses"
  1535. typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST
  1536. {
  1537. ULONG BadAddrBegin;
  1538. ULONG BadAddrSize;
  1539. ULONG OSVersionTrigger;
  1540. PHALIOREADWRITEHANDLER IOHandler;
  1541. } HAL_AMLI_BAD_IO_ADDRESS_LIST, *PHAL_AMLI_BAD_IO_ADDRESS_LIST;
  1542. // end_ntosp
  1543. #if defined(_X86_) || defined(_IA64_) || defined(_AMD64_)
  1544. //
  1545. // HalQueryMcaInterface
  1546. //
  1547. typedef
  1548. VOID
  1549. (*PHALMCAINTERFACELOCK)(
  1550. VOID
  1551. );
  1552. typedef
  1553. VOID
  1554. (*PHALMCAINTERFACEUNLOCK)(
  1555. VOID
  1556. );
  1557. typedef
  1558. NTSTATUS
  1559. (*PHALMCAINTERFACEREADREGISTER)(
  1560. IN UCHAR BankNumber,
  1561. IN OUT PVOID Exception
  1562. );
  1563. typedef struct _HAL_MCA_INTERFACE {
  1564. PHALMCAINTERFACELOCK Lock;
  1565. PHALMCAINTERFACEUNLOCK Unlock;
  1566. PHALMCAINTERFACEREADREGISTER ReadRegister;
  1567. } HAL_MCA_INTERFACE;
  1568. typedef
  1569. #if defined(_IA64_)
  1570. ERROR_SEVERITY
  1571. #else // !_IA64_
  1572. VOID
  1573. #endif // !_IA64_
  1574. (*PDRIVER_EXCPTN_CALLBACK) (
  1575. IN PVOID Context,
  1576. IN PMCA_EXCEPTION BankLog
  1577. );
  1578. typedef PDRIVER_EXCPTN_CALLBACK PDRIVER_MCA_EXCEPTION_CALLBACK;
  1579. //
  1580. // Structure to record the callbacks from driver
  1581. //
  1582. typedef struct _MCA_DRIVER_INFO {
  1583. PDRIVER_MCA_EXCEPTION_CALLBACK ExceptionCallback;
  1584. PKDEFERRED_ROUTINE DpcCallback;
  1585. PVOID DeviceContext;
  1586. } MCA_DRIVER_INFO, *PMCA_DRIVER_INFO;
  1587. // For the information class HalKernelErrorHandler
  1588. typedef BOOLEAN (*KERNEL_MCA_DELIVERY)( PVOID Reserved, PVOID Argument2 );
  1589. typedef BOOLEAN (*KERNEL_CMC_DELIVERY)( PVOID Reserved, PVOID Argument2 );
  1590. typedef BOOLEAN (*KERNEL_CPE_DELIVERY)( PVOID Reserved, PVOID Argument2 );
  1591. typedef BOOLEAN (*KERNEL_MCE_DELIVERY)( PVOID Reserved, PVOID Argument2 );
  1592. #define KERNEL_ERROR_HANDLER_VERSION 0x1
  1593. typedef struct
  1594. {
  1595. ULONG Version; // Version of this structure. Required to be 1rst field.
  1596. ULONG Padding;
  1597. KERNEL_MCA_DELIVERY KernelMcaDelivery; // Kernel callback for MCA DPC Queueing.
  1598. KERNEL_CMC_DELIVERY KernelCmcDelivery; // Kernel callback for CMC DPC Queueing.
  1599. KERNEL_CPE_DELIVERY KernelCpeDelivery; // Kernel callback for CPE DPC Queueing.
  1600. KERNEL_MCE_DELIVERY KernelMceDelivery; // Kernel callback for CME DPC Queueing.
  1601. // Includes the kernel notifications for FW
  1602. // interfaces errors.
  1603. } KERNEL_ERROR_HANDLER_INFO, *PKERNEL_ERROR_HANDLER_INFO;
  1604. // KERNEL_MCA_DELIVERY.McaType definition
  1605. #define KERNEL_MCA_UNKNOWN 0x0
  1606. #define KERNEL_MCA_PREVIOUS 0x1
  1607. #define KERNEL_MCA_CORRECTED 0x2
  1608. // KERNEL_MCE_DELIVERY.Reserved.EVENTTYPE definitions
  1609. #define KERNEL_MCE_EVENTTYPE_MCA 0x00
  1610. #define KERNEL_MCE_EVENTTYPE_INIT 0x01
  1611. #define KERNEL_MCE_EVENTTYPE_CMC 0x02
  1612. #define KERNEL_MCE_EVENTTYPE_CPE 0x03
  1613. #define KERNEL_MCE_EVENTTYPE_MASK 0xffff
  1614. #define KERNEL_MCE_EVENTTYPE( _Reverved ) ((USHORT)(ULONG_PTR)(_Reserved))
  1615. // KERNEL_MCE_DELIVERY.Reserved.OPERATION definitions
  1616. #define KERNEL_MCE_OPERATION_CLEAR_STATE_INFO 0x1
  1617. #define KERNEL_MCE_OPERATION_GET_STATE_INFO 0x2
  1618. #define KERNEL_MCE_OPERATION_MASK 0xffff
  1619. #define KERNEL_MCE_OPERATION_SHIFT KERNEL_MCE_EVENTTYPE_MASK
  1620. #define KERNEL_MCE_OPERATION( _Reserved ) \
  1621. ((USHORT)((((ULONG_PTR)(_Reserved)) >> KERNEL_MCE_OPERATION_SHIFT) & KERNEL_MCE_OPERATION_MASK))
  1622. // for information class HalErrorInformation
  1623. #define HAL_ERROR_INFO_VERSION 0x2
  1624. typedef struct _HAL_ERROR_INFO {
  1625. ULONG Version; // Version of this structure
  1626. ULONG Reserved; //
  1627. ULONG McaMaxSize; // Maximum size of a Machine Check Abort record
  1628. ULONG McaPreviousEventsCount; // Flag indicating previous or early-boot MCA event logs.
  1629. ULONG McaCorrectedEventsCount; // Number of corrected MCA events since boot. approx.
  1630. ULONG McaKernelDeliveryFails; // Number of Kernel callback failures. approx.
  1631. ULONG McaDriverDpcQueueFails; // Number of OEM MCA Driver Dpc queueing failures. approx.
  1632. ULONG McaReserved;
  1633. ULONG CmcMaxSize; // Maximum size of a Corrected Machine Check record
  1634. ULONG CmcPollingInterval; // In units of seconds
  1635. ULONG CmcInterruptsCount; // Number of CMC interrupts. approx.
  1636. ULONG CmcKernelDeliveryFails; // Number of Kernel callback failures. approx.
  1637. ULONG CmcDriverDpcQueueFails; // Number of OEM CMC Driver Dpc queueing failures. approx.
  1638. ULONG CmcGetStateFails; // Number of failures in getting the log from FW.
  1639. ULONG CmcClearStateFails; // Number of failures in clearing the log from FW.
  1640. ULONG CmcReserved;
  1641. ULONGLONG CmcLogId; // Last seen record identifier.
  1642. ULONG CpeMaxSize; // Maximum size of a Corrected Platform Event record
  1643. ULONG CpePollingInterval; // In units of seconds
  1644. ULONG CpeInterruptsCount; // Number of CPE interrupts. approx.
  1645. ULONG CpeKernelDeliveryFails; // Number of Kernel callback failures. approx.
  1646. ULONG CpeDriverDpcQueueFails; // Number of OEM CPE Driver Dpc queueing failures. approx.
  1647. ULONG CpeGetStateFails; // Number of failures in getting the log from FW.
  1648. ULONG CpeClearStateFails; // Number of failures in clearing the log from FW.
  1649. ULONG CpeInterruptSources; // Number of SAPIC Platform Interrupt Sources
  1650. ULONGLONG CpeLogId; // Last seen record identifier.
  1651. ULONGLONG KernelReserved[4];
  1652. } HAL_ERROR_INFO, *PHAL_ERROR_INFO;
  1653. //
  1654. // Known values for HAL_ERROR_INFO.CmcPollingInterval.
  1655. //
  1656. #define HAL_CMC_INTERRUPTS_BASED ((ULONG)-1)
  1657. #define HAL_CMC_DISABLED ((ULONG)0)
  1658. //
  1659. // Known values for HAL_ERROR_INFO.CpePollingInterval.
  1660. //
  1661. #define HAL_CPE_INTERRUPTS_BASED ((ULONG)-1)
  1662. #define HAL_CPE_DISABLED ((ULONG)0)
  1663. #define HAL_MCA_INTERRUPTS_BASED ((ULONG)-1)
  1664. #define HAL_MCA_DISABLED ((ULONG)0)
  1665. // end_ntddk
  1666. //
  1667. // Kernel/WMI Tokens for HAL MCE Log Interfaces
  1668. //
  1669. #define McaKernelToken KernelReserved[0]
  1670. #define CmcKernelToken KernelReserved[1]
  1671. #define CpeKernelToken KernelReserved[2]
  1672. // begin_ntddk
  1673. //
  1674. // Driver Callback type for the information class "HalCmcRegisterDriver"
  1675. //
  1676. typedef
  1677. VOID
  1678. (*PDRIVER_CMC_EXCEPTION_CALLBACK) (
  1679. IN PVOID Context,
  1680. IN PCMC_EXCEPTION CmcLog
  1681. );
  1682. //
  1683. // Driver Callback type for the information class "HalCpeRegisterDriver"
  1684. //
  1685. typedef
  1686. VOID
  1687. (*PDRIVER_CPE_EXCEPTION_CALLBACK) (
  1688. IN PVOID Context,
  1689. IN PCPE_EXCEPTION CmcLog
  1690. );
  1691. //
  1692. //
  1693. // Structure to record the callbacks from driver
  1694. //
  1695. typedef struct _CMC_DRIVER_INFO {
  1696. PDRIVER_CMC_EXCEPTION_CALLBACK ExceptionCallback;
  1697. PKDEFERRED_ROUTINE DpcCallback;
  1698. PVOID DeviceContext;
  1699. } CMC_DRIVER_INFO, *PCMC_DRIVER_INFO;
  1700. typedef struct _CPE_DRIVER_INFO {
  1701. PDRIVER_CPE_EXCEPTION_CALLBACK ExceptionCallback;
  1702. PKDEFERRED_ROUTINE DpcCallback;
  1703. PVOID DeviceContext;
  1704. } CPE_DRIVER_INFO, *PCPE_DRIVER_INFO;
  1705. #endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_)
  1706. #if defined(_IA64_)
  1707. typedef
  1708. NTSTATUS
  1709. (*HALSENDCROSSPARTITIONIPI)(
  1710. IN USHORT ProcessorID,
  1711. IN UCHAR HardwareVector
  1712. );
  1713. typedef
  1714. NTSTATUS
  1715. (*HALRESERVECROSSPARTITIONINTERRUPTVECTOR)(
  1716. OUT PULONG Vector,
  1717. OUT PKIRQL Irql,
  1718. IN OUT PKAFFINITY Affinity,
  1719. OUT PUCHAR HardwareVector
  1720. );
  1721. typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE {
  1722. HALSENDCROSSPARTITIONIPI HalSendCrossPartitionIpi;
  1723. HALRESERVECROSSPARTITIONINTERRUPTVECTOR HalReserveCrossPartitionInterruptVector;
  1724. } HAL_CROSS_PARTITION_IPI_INTERFACE;
  1725. #endif
  1726. typedef struct _HAL_PLATFORM_INFORMATION {
  1727. ULONG PlatformFlags;
  1728. } HAL_PLATFORM_INFORMATION, *PHAL_PLATFORM_INFORMATION;
  1729. //
  1730. // These platform flags are carried over from the IPPT table
  1731. // definition if appropriate.
  1732. //
  1733. #define HAL_PLATFORM_DISABLE_PTCG 0x04L
  1734. #define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L
  1735. // begin_wdm begin_ntndis begin_ntosp
  1736. typedef struct _SCATTER_GATHER_ELEMENT {
  1737. PHYSICAL_ADDRESS Address;
  1738. ULONG Length;
  1739. ULONG_PTR Reserved;
  1740. } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
  1741. #pragma warning(disable:4200)
  1742. typedef struct _SCATTER_GATHER_LIST {
  1743. ULONG NumberOfElements;
  1744. ULONG_PTR Reserved;
  1745. SCATTER_GATHER_ELEMENT Elements[];
  1746. } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
  1747. #pragma warning(default:4200)
  1748. // end_ntndis
  1749. typedef struct _DMA_OPERATIONS *PDMA_OPERATIONS;
  1750. typedef struct _DMA_ADAPTER {
  1751. USHORT Version;
  1752. USHORT Size;
  1753. PDMA_OPERATIONS DmaOperations;
  1754. // Private Bus Device Driver data follows,
  1755. } DMA_ADAPTER, *PDMA_ADAPTER;
  1756. typedef VOID (*PPUT_DMA_ADAPTER)(
  1757. PDMA_ADAPTER DmaAdapter
  1758. );
  1759. typedef PVOID (*PALLOCATE_COMMON_BUFFER)(
  1760. IN PDMA_ADAPTER DmaAdapter,
  1761. IN ULONG Length,
  1762. OUT PPHYSICAL_ADDRESS LogicalAddress,
  1763. IN BOOLEAN CacheEnabled
  1764. );
  1765. typedef VOID (*PFREE_COMMON_BUFFER)(
  1766. IN PDMA_ADAPTER DmaAdapter,
  1767. IN ULONG Length,
  1768. IN PHYSICAL_ADDRESS LogicalAddress,
  1769. IN PVOID VirtualAddress,
  1770. IN BOOLEAN CacheEnabled
  1771. );
  1772. typedef NTSTATUS (*PALLOCATE_ADAPTER_CHANNEL)(
  1773. IN PDMA_ADAPTER DmaAdapter,
  1774. IN PDEVICE_OBJECT DeviceObject,
  1775. IN ULONG NumberOfMapRegisters,
  1776. IN PDRIVER_CONTROL ExecutionRoutine,
  1777. IN PVOID Context
  1778. );
  1779. typedef BOOLEAN (*PFLUSH_ADAPTER_BUFFERS)(
  1780. IN PDMA_ADAPTER DmaAdapter,
  1781. IN PMDL Mdl,
  1782. IN PVOID MapRegisterBase,
  1783. IN PVOID CurrentVa,
  1784. IN ULONG Length,
  1785. IN BOOLEAN WriteToDevice
  1786. );
  1787. typedef VOID (*PFREE_ADAPTER_CHANNEL)(
  1788. IN PDMA_ADAPTER DmaAdapter
  1789. );
  1790. typedef VOID (*PFREE_MAP_REGISTERS)(
  1791. IN PDMA_ADAPTER DmaAdapter,
  1792. PVOID MapRegisterBase,
  1793. ULONG NumberOfMapRegisters
  1794. );
  1795. typedef PHYSICAL_ADDRESS (*PMAP_TRANSFER)(
  1796. IN PDMA_ADAPTER DmaAdapter,
  1797. IN PMDL Mdl,
  1798. IN PVOID MapRegisterBase,
  1799. IN PVOID CurrentVa,
  1800. IN OUT PULONG Length,
  1801. IN BOOLEAN WriteToDevice
  1802. );
  1803. typedef ULONG (*PGET_DMA_ALIGNMENT)(
  1804. IN PDMA_ADAPTER DmaAdapter
  1805. );
  1806. typedef ULONG (*PREAD_DMA_COUNTER)(
  1807. IN PDMA_ADAPTER DmaAdapter
  1808. );
  1809. typedef VOID
  1810. (*PDRIVER_LIST_CONTROL)(
  1811. IN struct _DEVICE_OBJECT *DeviceObject,
  1812. IN struct _IRP *Irp,
  1813. IN PSCATTER_GATHER_LIST ScatterGather,
  1814. IN PVOID Context
  1815. );
  1816. typedef NTSTATUS
  1817. (*PGET_SCATTER_GATHER_LIST)(
  1818. IN PDMA_ADAPTER DmaAdapter,
  1819. IN PDEVICE_OBJECT DeviceObject,
  1820. IN PMDL Mdl,
  1821. IN PVOID CurrentVa,
  1822. IN ULONG Length,
  1823. IN PDRIVER_LIST_CONTROL ExecutionRoutine,
  1824. IN PVOID Context,
  1825. IN BOOLEAN WriteToDevice
  1826. );
  1827. typedef VOID
  1828. (*PPUT_SCATTER_GATHER_LIST)(
  1829. IN PDMA_ADAPTER DmaAdapter,
  1830. IN PSCATTER_GATHER_LIST ScatterGather,
  1831. IN BOOLEAN WriteToDevice
  1832. );
  1833. typedef NTSTATUS
  1834. (*PCALCULATE_SCATTER_GATHER_LIST_SIZE)(
  1835. IN PDMA_ADAPTER DmaAdapter,
  1836. IN OPTIONAL PMDL Mdl,
  1837. IN PVOID CurrentVa,
  1838. IN ULONG Length,
  1839. OUT PULONG ScatterGatherListSize,
  1840. OUT OPTIONAL PULONG pNumberOfMapRegisters
  1841. );
  1842. typedef NTSTATUS
  1843. (*PBUILD_SCATTER_GATHER_LIST)(
  1844. IN PDMA_ADAPTER DmaAdapter,
  1845. IN PDEVICE_OBJECT DeviceObject,
  1846. IN PMDL Mdl,
  1847. IN PVOID CurrentVa,
  1848. IN ULONG Length,
  1849. IN PDRIVER_LIST_CONTROL ExecutionRoutine,
  1850. IN PVOID Context,
  1851. IN BOOLEAN WriteToDevice,
  1852. IN PVOID ScatterGatherBuffer,
  1853. IN ULONG ScatterGatherLength
  1854. );
  1855. typedef NTSTATUS
  1856. (*PBUILD_MDL_FROM_SCATTER_GATHER_LIST)(
  1857. IN PDMA_ADAPTER DmaAdapter,
  1858. IN PSCATTER_GATHER_LIST ScatterGather,
  1859. IN PMDL OriginalMdl,
  1860. OUT PMDL *TargetMdl
  1861. );
  1862. typedef struct _DMA_OPERATIONS {
  1863. ULONG Size;
  1864. PPUT_DMA_ADAPTER PutDmaAdapter;
  1865. PALLOCATE_COMMON_BUFFER AllocateCommonBuffer;
  1866. PFREE_COMMON_BUFFER FreeCommonBuffer;
  1867. PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
  1868. PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
  1869. PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
  1870. PFREE_MAP_REGISTERS FreeMapRegisters;
  1871. PMAP_TRANSFER MapTransfer;
  1872. PGET_DMA_ALIGNMENT GetDmaAlignment;
  1873. PREAD_DMA_COUNTER ReadDmaCounter;
  1874. PGET_SCATTER_GATHER_LIST GetScatterGatherList;
  1875. PPUT_SCATTER_GATHER_LIST PutScatterGatherList;
  1876. PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList;
  1877. PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList;
  1878. PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList;
  1879. } DMA_OPERATIONS;
  1880. // end_wdm
  1881. #if defined(_WIN64)
  1882. //
  1883. // Use __inline DMA macros (hal.h)
  1884. //
  1885. #ifndef USE_DMA_MACROS
  1886. #define USE_DMA_MACROS
  1887. #endif
  1888. //
  1889. // Only PnP drivers!
  1890. //
  1891. #ifndef NO_LEGACY_DRIVERS
  1892. #define NO_LEGACY_DRIVERS
  1893. #endif
  1894. #endif // _WIN64
  1895. #if defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_))
  1896. // begin_wdm
  1897. DECLSPEC_DEPRECATED_DDK // Use AllocateCommonBuffer
  1898. FORCEINLINE
  1899. PVOID
  1900. HalAllocateCommonBuffer(
  1901. IN PDMA_ADAPTER DmaAdapter,
  1902. IN ULONG Length,
  1903. OUT PPHYSICAL_ADDRESS LogicalAddress,
  1904. IN BOOLEAN CacheEnabled
  1905. ){
  1906. PALLOCATE_COMMON_BUFFER allocateCommonBuffer;
  1907. PVOID commonBuffer;
  1908. allocateCommonBuffer = *(DmaAdapter)->DmaOperations->AllocateCommonBuffer;
  1909. ASSERT( allocateCommonBuffer != NULL );
  1910. commonBuffer = allocateCommonBuffer( DmaAdapter,
  1911. Length,
  1912. LogicalAddress,
  1913. CacheEnabled );
  1914. return commonBuffer;
  1915. }
  1916. DECLSPEC_DEPRECATED_DDK // Use FreeCommonBuffer
  1917. FORCEINLINE
  1918. VOID
  1919. HalFreeCommonBuffer(
  1920. IN PDMA_ADAPTER DmaAdapter,
  1921. IN ULONG Length,
  1922. IN PHYSICAL_ADDRESS LogicalAddress,
  1923. IN PVOID VirtualAddress,
  1924. IN BOOLEAN CacheEnabled
  1925. ){
  1926. PFREE_COMMON_BUFFER freeCommonBuffer;
  1927. freeCommonBuffer = *(DmaAdapter)->DmaOperations->FreeCommonBuffer;
  1928. ASSERT( freeCommonBuffer != NULL );
  1929. freeCommonBuffer( DmaAdapter,
  1930. Length,
  1931. LogicalAddress,
  1932. VirtualAddress,
  1933. CacheEnabled );
  1934. }
  1935. DECLSPEC_DEPRECATED_DDK // Use AllocateAdapterChannel
  1936. FORCEINLINE
  1937. NTSTATUS
  1938. IoAllocateAdapterChannel(
  1939. IN PDMA_ADAPTER DmaAdapter,
  1940. IN PDEVICE_OBJECT DeviceObject,
  1941. IN ULONG NumberOfMapRegisters,
  1942. IN PDRIVER_CONTROL ExecutionRoutine,
  1943. IN PVOID Context
  1944. ){
  1945. PALLOCATE_ADAPTER_CHANNEL allocateAdapterChannel;
  1946. NTSTATUS status;
  1947. allocateAdapterChannel =
  1948. *(DmaAdapter)->DmaOperations->AllocateAdapterChannel;
  1949. ASSERT( allocateAdapterChannel != NULL );
  1950. status = allocateAdapterChannel( DmaAdapter,
  1951. DeviceObject,
  1952. NumberOfMapRegisters,
  1953. ExecutionRoutine,
  1954. Context );
  1955. return status;
  1956. }
  1957. DECLSPEC_DEPRECATED_DDK // Use FlushAdapterBuffers
  1958. FORCEINLINE
  1959. BOOLEAN
  1960. IoFlushAdapterBuffers(
  1961. IN PDMA_ADAPTER DmaAdapter,
  1962. IN PMDL Mdl,
  1963. IN PVOID MapRegisterBase,
  1964. IN PVOID CurrentVa,
  1965. IN ULONG Length,
  1966. IN BOOLEAN WriteToDevice
  1967. ){
  1968. PFLUSH_ADAPTER_BUFFERS flushAdapterBuffers;
  1969. BOOLEAN result;
  1970. flushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers;
  1971. ASSERT( flushAdapterBuffers != NULL );
  1972. result = flushAdapterBuffers( DmaAdapter,
  1973. Mdl,
  1974. MapRegisterBase,
  1975. CurrentVa,
  1976. Length,
  1977. WriteToDevice );
  1978. return result;
  1979. }
  1980. DECLSPEC_DEPRECATED_DDK // Use FreeAdapterChannel
  1981. FORCEINLINE
  1982. VOID
  1983. IoFreeAdapterChannel(
  1984. IN PDMA_ADAPTER DmaAdapter
  1985. ){
  1986. PFREE_ADAPTER_CHANNEL freeAdapterChannel;
  1987. freeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel;
  1988. ASSERT( freeAdapterChannel != NULL );
  1989. freeAdapterChannel( DmaAdapter );
  1990. }
  1991. DECLSPEC_DEPRECATED_DDK // Use FreeMapRegisters
  1992. FORCEINLINE
  1993. VOID
  1994. IoFreeMapRegisters(
  1995. IN PDMA_ADAPTER DmaAdapter,
  1996. IN PVOID MapRegisterBase,
  1997. IN ULONG NumberOfMapRegisters
  1998. ){
  1999. PFREE_MAP_REGISTERS freeMapRegisters;
  2000. freeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters;
  2001. ASSERT( freeMapRegisters != NULL );
  2002. freeMapRegisters( DmaAdapter,
  2003. MapRegisterBase,
  2004. NumberOfMapRegisters );
  2005. }
  2006. DECLSPEC_DEPRECATED_DDK // Use MapTransfer
  2007. FORCEINLINE
  2008. PHYSICAL_ADDRESS
  2009. IoMapTransfer(
  2010. IN PDMA_ADAPTER DmaAdapter,
  2011. IN PMDL Mdl,
  2012. IN PVOID MapRegisterBase,
  2013. IN PVOID CurrentVa,
  2014. IN OUT PULONG Length,
  2015. IN BOOLEAN WriteToDevice
  2016. ){
  2017. PHYSICAL_ADDRESS physicalAddress;
  2018. PMAP_TRANSFER mapTransfer;
  2019. mapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer;
  2020. ASSERT( mapTransfer != NULL );
  2021. physicalAddress = mapTransfer( DmaAdapter,
  2022. Mdl,
  2023. MapRegisterBase,
  2024. CurrentVa,
  2025. Length,
  2026. WriteToDevice );
  2027. return physicalAddress;
  2028. }
  2029. DECLSPEC_DEPRECATED_DDK // Use GetDmaAlignment
  2030. FORCEINLINE
  2031. ULONG
  2032. HalGetDmaAlignment(
  2033. IN PDMA_ADAPTER DmaAdapter
  2034. )
  2035. {
  2036. PGET_DMA_ALIGNMENT getDmaAlignment;
  2037. ULONG alignment;
  2038. getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment;
  2039. ASSERT( getDmaAlignment != NULL );
  2040. alignment = getDmaAlignment( DmaAdapter );
  2041. return alignment;
  2042. }
  2043. DECLSPEC_DEPRECATED_DDK // Use ReadDmaCounter
  2044. FORCEINLINE
  2045. ULONG
  2046. HalReadDmaCounter(
  2047. IN PDMA_ADAPTER DmaAdapter
  2048. )
  2049. {
  2050. PREAD_DMA_COUNTER readDmaCounter;
  2051. ULONG counter;
  2052. readDmaCounter = *(DmaAdapter)->DmaOperations->ReadDmaCounter;
  2053. ASSERT( readDmaCounter != NULL );
  2054. counter = readDmaCounter( DmaAdapter );
  2055. return counter;
  2056. }
  2057. // end_wdm
  2058. #else
  2059. //
  2060. // DMA adapter object functions.
  2061. //
  2062. NTHALAPI
  2063. NTSTATUS
  2064. HalAllocateAdapterChannel(
  2065. IN PADAPTER_OBJECT AdapterObject,
  2066. IN PWAIT_CONTEXT_BLOCK Wcb,
  2067. IN ULONG NumberOfMapRegisters,
  2068. IN PDRIVER_CONTROL ExecutionRoutine
  2069. );
  2070. DECLSPEC_DEPRECATED_DDK // Use AllocateCommonBuffer
  2071. NTHALAPI
  2072. PVOID
  2073. HalAllocateCommonBuffer(
  2074. IN PADAPTER_OBJECT AdapterObject,
  2075. IN ULONG Length,
  2076. OUT PPHYSICAL_ADDRESS LogicalAddress,
  2077. IN BOOLEAN CacheEnabled
  2078. );
  2079. DECLSPEC_DEPRECATED_DDK // Use FreeCommonBuffer
  2080. NTHALAPI
  2081. VOID
  2082. HalFreeCommonBuffer(
  2083. IN PADAPTER_OBJECT AdapterObject,
  2084. IN ULONG Length,
  2085. IN PHYSICAL_ADDRESS LogicalAddress,
  2086. IN PVOID VirtualAddress,
  2087. IN BOOLEAN CacheEnabled
  2088. );
  2089. DECLSPEC_DEPRECATED_DDK // Use ReadDmaCounter
  2090. NTHALAPI
  2091. ULONG
  2092. HalReadDmaCounter(
  2093. IN PADAPTER_OBJECT AdapterObject
  2094. );
  2095. DECLSPEC_DEPRECATED_DDK // Use FlushAdapterBuffers
  2096. NTHALAPI
  2097. BOOLEAN
  2098. IoFlushAdapterBuffers(
  2099. IN PADAPTER_OBJECT AdapterObject,
  2100. IN PMDL Mdl,
  2101. IN PVOID MapRegisterBase,
  2102. IN PVOID CurrentVa,
  2103. IN ULONG Length,
  2104. IN BOOLEAN WriteToDevice
  2105. );
  2106. DECLSPEC_DEPRECATED_DDK // Use FreeAdapterChannel
  2107. NTHALAPI
  2108. VOID
  2109. IoFreeAdapterChannel(
  2110. IN PADAPTER_OBJECT AdapterObject
  2111. );
  2112. DECLSPEC_DEPRECATED_DDK // Use FreeMapRegisters
  2113. NTHALAPI
  2114. VOID
  2115. IoFreeMapRegisters(
  2116. IN PADAPTER_OBJECT AdapterObject,
  2117. IN PVOID MapRegisterBase,
  2118. IN ULONG NumberOfMapRegisters
  2119. );
  2120. DECLSPEC_DEPRECATED_DDK // Use MapTransfer
  2121. NTHALAPI
  2122. PHYSICAL_ADDRESS
  2123. IoMapTransfer(
  2124. IN PADAPTER_OBJECT AdapterObject,
  2125. IN PMDL Mdl,
  2126. IN PVOID MapRegisterBase,
  2127. IN PVOID CurrentVa,
  2128. IN OUT PULONG Length,
  2129. IN BOOLEAN WriteToDevice
  2130. );
  2131. #endif // USE_DMA_MACROS && (_NTDDK_ || _NTDRIVER_)
  2132. NTSTATUS
  2133. HalGetScatterGatherList (
  2134. IN PADAPTER_OBJECT DmaAdapter,
  2135. IN PDEVICE_OBJECT DeviceObject,
  2136. IN PMDL Mdl,
  2137. IN PVOID CurrentVa,
  2138. IN ULONG Length,
  2139. IN PDRIVER_LIST_CONTROL ExecutionRoutine,
  2140. IN PVOID Context,
  2141. IN BOOLEAN WriteToDevice
  2142. );
  2143. VOID
  2144. HalPutScatterGatherList (
  2145. IN PADAPTER_OBJECT DmaAdapter,
  2146. IN PSCATTER_GATHER_LIST ScatterGather,
  2147. IN BOOLEAN WriteToDevice
  2148. );
  2149. VOID
  2150. HalPutDmaAdapter(
  2151. IN PADAPTER_OBJECT DmaAdapter
  2152. );
  2153. // end_ntddk end_ntosp
  2154. #endif // _HAL_
  2155. // end_nthal