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.

1304 lines
25 KiB

  1. /**
  2. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  3. ***
  4. *** The information and source code contained herein is the exclusive
  5. *** property of Intel Corporation and may not be disclosed, examined
  6. *** or reproduced in whole or in part without explicit written authorization
  7. *** from the company.
  8. **/
  9. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  10. Copyright (c) 1991 Microsoft Corporation
  11. Module Name:
  12. halp.h
  13. Abstract:
  14. This header file defines the private Hardware Architecture Layer (HAL)
  15. interfaces, defines and structures.
  16. Author:
  17. John Vert (jvert) 11-Feb-92
  18. Revision History:
  19. --*/
  20. #ifndef _HALP_H_
  21. #define _HALP_H_
  22. #include "nthal.h"
  23. #include "hal.h"
  24. #define IPI_VECTOR 0xE1
  25. #include "halnls.h"
  26. #if 0
  27. #ifndef _HALI_
  28. #include "..\inc\hali.h"
  29. #endif
  30. #endif
  31. #define HAL_MAXIMUM_PROCESSOR 0x20
  32. /*
  33. * Default clock and profile timer intervals (in 100ns-unit)
  34. */
  35. #define DEFAULT_CLOCK_INTERVAL 100000 // 10 ms
  36. #define MINIMUM_CLOCK_INTERVAL 10000 // 1 ms
  37. #define MAXIMUM_CLOCK_INTERVAL 100000 // 10 ms
  38. //
  39. // Define Realtime Clock register numbers.
  40. //
  41. #define RTC_SECOND 0 // second of minute [0..59]
  42. #define RTC_SECOND_ALARM 1 // seconds to alarm
  43. #define RTC_MINUTE 2 // minute of hour [0..59]
  44. #define RTC_MINUTE_ALARM 3 // minutes to alarm
  45. #define RTC_HOUR 4 // hour of day [0..23]
  46. #define RTC_HOUR_ALARM 5 // hours to alarm
  47. #define RTC_DAY_OF_WEEK 6 // day of week [1..7]
  48. #define RTC_DAY_OF_MONTH 7 // day of month [1..31]
  49. #define RTC_MONTH 8 // month of year [1..12]
  50. #define RTC_YEAR 9 // year [00..99]
  51. #define RTC_CONTROL_REGISTERA 10 // control register A
  52. #define RTC_CONTROL_REGISTERB 11 // control register B
  53. #define RTC_CONTROL_REGISTERC 12 // control register C
  54. #define RTC_CONTROL_REGISTERD 13 // control register D
  55. #define RTC_REGNUMBER_RTC_CR1 0x6A // control register 1
  56. #define RTC_ISA_ADDRESS_PORT 0x070
  57. #define RTC_ISA_DATA_PORT 0x071
  58. extern PVOID HalpRtcAddressPort;
  59. extern PVOID HalpRtcDataPort;
  60. extern PLOADER_PARAMETER_BLOCK KeLoaderBlock;
  61. //
  62. // Define Control Register A structure.
  63. //
  64. typedef struct _RTC_CONTROL_REGISTER_A {
  65. UCHAR RateSelect : 4;
  66. UCHAR TimebaseDivisor : 3;
  67. UCHAR UpdateInProgress : 1;
  68. } RTC_CONTROL_REGISTER_A, *PRTC_CONTROL_REGISTER_A;
  69. //
  70. // Define Control Register B structure.
  71. //
  72. typedef struct _RTC_CONTROL_REGISTER_B {
  73. UCHAR DayLightSavingsEnable : 1;
  74. UCHAR HoursFormat : 1;
  75. UCHAR DataMode : 1;
  76. UCHAR SquareWaveEnable : 1;
  77. UCHAR UpdateInterruptEnable : 1;
  78. UCHAR AlarmInterruptEnable : 1;
  79. UCHAR TimerInterruptEnable : 1;
  80. UCHAR SetTime : 1;
  81. } RTC_CONTROL_REGISTER_B, *PRTC_CONTROL_REGISTER_B;
  82. //
  83. // Define Control Register C structure.
  84. //
  85. typedef struct _RTC_CONTROL_REGISTER_C {
  86. UCHAR Fill : 4;
  87. UCHAR UpdateInterruptFlag : 1;
  88. UCHAR AlarmInterruptFlag : 1;
  89. UCHAR TimeInterruptFlag : 1;
  90. UCHAR InterruptRequest : 1;
  91. } RTC_CONTROL_REGISTER_C, *PRTC_CONTROL_REGISTER_C;
  92. //
  93. // Define Control Register D structure.
  94. //
  95. typedef struct _RTC_CONTROL_REGISTER_D {
  96. UCHAR Fill : 7;
  97. UCHAR ValidTime : 1;
  98. } RTC_CONTROL_REGISTER_D, *PRTC_CONTROL_REGISTER_D;
  99. #define EISA_DMA_CHANNELS 8
  100. extern UCHAR HalpDmaChannelMasks[];
  101. //
  102. // HalpOwnedDisplayBeforeSleep is defined in mpdat.c
  103. //
  104. extern BOOLEAN HalpOwnedDisplayBeforeSleep;
  105. #define PIC_VECTORS 16
  106. #define PRIMARY_VECTOR_BASE 0x30
  107. /*
  108. * PCR address.
  109. * Temporary macros; should already be defined in ntddk.h for IA64
  110. */
  111. #define PCR ((volatile KPCR * const)KIPCR)
  112. #ifndef NEC_98
  113. #define PIC_SLAVE_IRQ 2
  114. #define PIC_SLAVE_REDIRECT 9
  115. #else
  116. #define PIC_SLAVE_IRQ 7
  117. #define PIC_SLAVE_REDIRECT 8
  118. #endif //NEC_98
  119. extern PVOID HalpSleepPageLock;
  120. KIRQL
  121. KfAcquireSpinLock (
  122. PKSPIN_LOCK SpinLock
  123. );
  124. VOID
  125. KfReleaseSpinLock (
  126. IN PKSPIN_LOCK SpinLock,
  127. IN KIRQL NewIrql
  128. );
  129. VOID
  130. KeSetAffinityThread (
  131. PKTHREAD Thread,
  132. KAFFINITY HalpActiveProcessors
  133. );
  134. KIRQL
  135. KfRaiseIrql (
  136. KIRQL NewIrql
  137. );
  138. VOID
  139. KfLowerIrql (
  140. KIRQL NewIrql
  141. );
  142. extern BOOLEAN
  143. KdPollBreakIn (
  144. VOID
  145. );
  146. VOID
  147. HalpSavePicState (
  148. VOID
  149. );
  150. VOID
  151. HalpSaveDmaControllerState (
  152. VOID
  153. );
  154. NTSTATUS
  155. HalAllocateAdapterChannel (
  156. IN PADAPTER_OBJECT AdapterObject,
  157. IN PWAIT_CONTEXT_BLOCK Wcb,
  158. IN ULONG NumberOfMapRegisters,
  159. IN PDRIVER_CONTROL ExecutionRoutine
  160. );
  161. ULONG
  162. HalReadDmaCounter (
  163. IN PADAPTER_OBJECT AdapterObject
  164. );
  165. VOID
  166. HalpSaveTimerState (
  167. VOID
  168. );
  169. VOID
  170. HalpRestorePicState (
  171. VOID
  172. );
  173. VOID
  174. HalpRestoreDmaControllerState (
  175. VOID
  176. );
  177. VOID
  178. HalpRestoreTimerState (
  179. VOID
  180. );
  181. BOOLEAN
  182. HalpIoSapicInitialize (
  183. VOID
  184. );
  185. BOOLEAN
  186. IsPsrDtOn (
  187. VOID
  188. );
  189. BOOLEAN
  190. HalpIoSapicConnectInterrupt (
  191. KIRQL Irql,
  192. IN ULONG Vector
  193. );
  194. NTSTATUS
  195. HalacpiGetInterruptTranslator(
  196. IN INTERFACE_TYPE ParentInterfaceType,
  197. IN ULONG ParentBusNumber,
  198. IN INTERFACE_TYPE BridgeInterfaceType,
  199. IN USHORT Size,
  200. IN USHORT Version,
  201. OUT PTRANSLATOR_INTERFACE Translator,
  202. OUT PULONG BridgeBusNumber
  203. );
  204. #ifdef notyet
  205. typedef struct {
  206. UCHAR MasterMask;
  207. UCHAR SlaveMask;
  208. UCHAR MasterEdgeLevelControl;
  209. UCHAR SlaveEdgeLevelControl;
  210. } PIC_CONTEXT, *PPIC_CONTEXT;
  211. #define EISA_DMA_CHANNELS 8
  212. typedef struct {
  213. UCHAR Dma1ExtendedModePort;
  214. UCHAR Dma2ExtendedModePort;
  215. DMA1_CONTROL Dma1Control;
  216. DMA2_CONTROL Dma2Control;
  217. } DMA_CONTEXT, *PDMA_CONTEXT;
  218. typedef struct {
  219. UCHAR nothing;
  220. } TIMER_CONTEXT, *PTIMER_CONTEXT;
  221. typedef struct {
  222. PIC_CONTEXT PicState;
  223. DMA_CONTEXT DmaState;
  224. } MOTHERBOARD_CONTEXT, *PMOTHERBOARD_CONTEXT;
  225. extern MOTHERBOARD_CONTEXT HalpMotherboardState;
  226. extern UCHAR HalpDmaChannelModes[];
  227. extern PVOID HalpSleepPageLock;
  228. extern UCHAR HalpDmaChannelMasks[];
  229. extern BOOLEAN HalpOwnedDisplayBeforeSleep;
  230. #endif //notyet
  231. VOID
  232. HalpGetProcessorIDs (
  233. VOID
  234. );
  235. VOID
  236. HalpInitializeInterrupts (
  237. VOID
  238. );
  239. VOID
  240. HalInitializeProcessor (
  241. ULONG Number,
  242. PLOADER_PARAMETER_BLOCK LoaderBlock
  243. );
  244. VOID
  245. HalpGetParameters (
  246. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  247. );
  248. VOID
  249. HalpClearClock (
  250. VOID
  251. );
  252. VOID
  253. HalpClockInterrupt (
  254. IN PKINTERRUPT_ROUTINE Interrupt,
  255. IN PKTRAP_FRAME TrapFrame
  256. );
  257. VOID
  258. HalpClockInterruptPn(
  259. IN PKINTERRUPT_ROUTINE Interrupt,
  260. IN PKTRAP_FRAME TrapFrame
  261. );
  262. UCHAR
  263. HalpReadClockRegister (
  264. UCHAR Register
  265. );
  266. VOID
  267. HalpWriteClockRegister (
  268. UCHAR Register,
  269. UCHAR Value
  270. );
  271. // extern VOID
  272. // HalpProfileInterrupt (
  273. // IN PKTRAP_FRAME TrapFrame
  274. // );
  275. ULONGLONG
  276. HalpReadIntervalTimeCounter (
  277. VOID
  278. );
  279. VOID
  280. HalpProgramIntervalTimerVector(
  281. ULONGLONG IntervalTimerVector
  282. );
  283. VOID
  284. HalpClearITC (
  285. VOID );
  286. VOID
  287. HalpInitializeClock (
  288. VOID
  289. );
  290. VOID
  291. HalpInitializeClockPn (
  292. VOID
  293. );
  294. VOID
  295. HalpInitializeClockInterrupts(
  296. VOID
  297. );
  298. VOID
  299. HalpSetInitialClockRate (
  300. VOID
  301. );
  302. VOID
  303. HalpInitializeTimerResolution (
  304. ULONG Rate
  305. );
  306. VOID
  307. HalpUpdateITM (
  308. IN ULONGLONG NewITMValue
  309. );
  310. VOID
  311. HalpSendIPI (
  312. IN USHORT ProcessorID,
  313. IN ULONGLONG Data
  314. );
  315. VOID
  316. HalpOSRendez (
  317. IN USHORT ProcessorID
  318. );
  319. //
  320. // Prototype for system bus handlers
  321. //
  322. NTSTATUS
  323. HalpQuerySimBusSlots (
  324. IN PBUS_HANDLER BusHandler,
  325. IN PBUS_HANDLER RootHandler,
  326. IN ULONG BufferSize,
  327. OUT PULONG SlotNumbers,
  328. OUT PULONG ReturnedLength
  329. );
  330. ULONG
  331. HalpGetSimBusInterruptVector (
  332. IN PBUS_HANDLER BusHandler,
  333. IN PBUS_HANDLER RootHandler,
  334. IN ULONG BusInterruptLevel,
  335. IN ULONG BusInterruptVector,
  336. OUT PKIRQL Irql,
  337. OUT PKAFFINITY Affinity
  338. );
  339. BOOLEAN
  340. HalpTranslateSimBusAddress (
  341. IN PBUS_HANDLER BusHandler,
  342. IN PBUS_HANDLER RootHandler,
  343. IN PHYSICAL_ADDRESS BusAddress,
  344. IN OUT PULONG AddressSpace,
  345. OUT PPHYSICAL_ADDRESS TranslatedAddress
  346. );
  347. VOID
  348. HalpRegisterSimBusHandler (
  349. VOID
  350. );
  351. ULONG
  352. HalpGetSimBusData(
  353. IN PBUS_HANDLER BusHandler,
  354. IN PBUS_HANDLER RootHandler,
  355. IN ULONG SlotNumber,
  356. IN PVOID Buffer,
  357. IN ULONG Offset,
  358. IN ULONG Length
  359. );
  360. ULONG
  361. HalpSetSimBusData(
  362. IN PBUS_HANDLER BusHandler,
  363. IN PBUS_HANDLER RootHandler,
  364. IN ULONG SlotNumber,
  365. IN PVOID Buffer,
  366. IN ULONG Offset,
  367. IN ULONG Length
  368. );
  369. NTSTATUS
  370. HalpAssignSimBusSlotResources (
  371. IN PBUS_HANDLER BusHandler,
  372. IN PBUS_HANDLER RootHandler,
  373. IN PUNICODE_STRING RegistryPath,
  374. IN PUNICODE_STRING DriverClassName OPTIONAL,
  375. IN PDRIVER_OBJECT DriverObject,
  376. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  377. IN ULONG SlotNumber,
  378. IN OUT PCM_RESOURCE_LIST *AllocatedResources
  379. );
  380. NTSTATUS
  381. HalpAdjustSimBusResourceList (
  382. IN PBUS_HANDLER BusHandler,
  383. IN PBUS_HANDLER RootHandler,
  384. IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
  385. );
  386. PDEVICE_HANDLER_OBJECT
  387. HalpReferenceSimDeviceHandler (
  388. IN PBUS_HANDLER BusHandler,
  389. IN PBUS_HANDLER RootHandler,
  390. IN ULONG SlotNumber
  391. );
  392. NTSTATUS
  393. HalpSimDeviceControl (
  394. IN PHAL_DEVICE_CONTROL_CONTEXT Context
  395. );
  396. ULONG
  397. HalGetDeviceData (
  398. IN PBUS_HANDLER BusHandler,
  399. IN PBUS_HANDLER RootHandler,
  400. IN PDEVICE_HANDLER_OBJECT DeviceHandler,
  401. IN ULONG DataType,
  402. IN PVOID Buffer,
  403. IN ULONG Offset,
  404. IN ULONG Length
  405. );
  406. ULONG
  407. HalSetDeviceData (
  408. IN PBUS_HANDLER BusHandler,
  409. IN PBUS_HANDLER RootHandler,
  410. IN PDEVICE_HANDLER_OBJECT DeviceHandler,
  411. IN ULONG DataType,
  412. IN PVOID Buffer,
  413. IN ULONG Offset,
  414. IN ULONG Length
  415. );
  416. NTSTATUS
  417. HalpHibernateHal (
  418. IN PBUS_HANDLER BusHandler,
  419. IN PBUS_HANDLER RootHandler
  420. );
  421. NTSTATUS
  422. HalpResumeHal (
  423. IN PBUS_HANDLER BusHandler,
  424. IN PBUS_HANDLER RootHandler
  425. );
  426. ULONG
  427. HalpGetFeatureBits (
  428. VOID
  429. );
  430. VOID
  431. HalpInitMP(
  432. IN ULONG Phase,
  433. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  434. );
  435. #ifdef RtlMoveMemory
  436. #undef RtlMoveMemory
  437. #undef RtlCopyMemory
  438. #undef RtlFillMemory
  439. #undef RtlZeroMemory
  440. #define RtlCopyMemory(Destination,Source,Length) RtlMoveMemory((Destination),(Source),(Length))
  441. VOID
  442. RtlMoveMemory (
  443. PVOID Destination,
  444. CONST VOID *Source,
  445. ULONG Length
  446. );
  447. VOID
  448. RtlFillMemory (
  449. PVOID Destination,
  450. ULONG Length,
  451. UCHAR Fill
  452. );
  453. VOID
  454. RtlZeroMemory (
  455. PVOID Destination,
  456. ULONG Length
  457. );
  458. #endif
  459. #if 0
  460. #include "ixisa.h"
  461. #endif
  462. //
  463. // Define map register translation entry structure.
  464. //
  465. typedef struct _TRANSLATION_ENTRY {
  466. PVOID VirtualAddress;
  467. ULONG PhysicalAddress;
  468. ULONG Index;
  469. } TRANSLATION_ENTRY, *PTRANSLATION_ENTRY;
  470. //
  471. //
  472. typedef struct _PcMpIoApicEntry {
  473. UCHAR EntryType;
  474. UCHAR IoApicId;
  475. UCHAR IoApicVersion;
  476. UCHAR IoApicFlag;
  477. PVOID IoApicAddress;
  478. } PCMPIOAPIC, *PPCMPIOAPIC;
  479. //
  480. // MP_INFO is defined in pcmp_nt.inc
  481. //
  482. // typedef struct _MP_INFO {
  483. // ULONG ApicVersion; // 82489Dx or Not
  484. // ULONG ProcessorCount; // Number of Enabled Processors
  485. // ULONG NtProcessors; // Number of Running Processors
  486. // ULONG BusCount; // Number of buses in system
  487. // ULONG IOApicCount; // Number of Io Apics in system
  488. // ULONG IntiCount; // Number of Io Apic interrupt input entries
  489. // ULONG LintiCount; // Number of Local Apic interrupt input entries
  490. // ULONG IMCRPresent; // Indicates if the IMCR is present
  491. // ULONG LocalApicBase; // Base of local APIC
  492. // PULONG IoApicBase; // The virtual addresses of the IoApic
  493. // PPCMPIOAPIC IoApicEntryPtr; // Ptr to 1st PC+MP IoApic entry
  494. // ULONG IoApicPhys[]; // The physical addresses of the IoApi
  495. //}MP_INFO, *PMP_INFO;
  496. extern USHORT LOCAL_ID[];
  497. #define VECTOR_SIZE 8
  498. #define IPI_ID_SHIFT 4
  499. #define IpiTOKEN_SHIFT 20
  500. #define IpiTOKEN 0xFFE
  501. #define EID_MASK 0xFF00
  502. #define OS_RENDEZ_VECTOR 0x11
  503. #define RENDEZ_TIME_OUT 0X0FFFFFFFF
  504. //
  505. // Some devices require a phyicially contiguous data buffers for DMA transfers.
  506. // Map registers are used give the appearance that all data buffers are
  507. // contiguous. In order to pool all of the map registers a master
  508. // adapter object is used. This object is allocated and saved internal to this
  509. // file. It contains a bit map for allocation of the registers and a queue
  510. // for requests which are waiting for more map registers. This object is
  511. // allocated during the first request to allocate an adapter which requires
  512. // map registers.
  513. //
  514. // In this system, the map registers are translation entries which point to
  515. // map buffers. Map buffers are physically contiguous and have physical memory
  516. // addresses less than 0x01000000. All of the map registers are allocated
  517. // initialially; however, the map buffers are allocated base in the number of
  518. // adapters which are allocated.
  519. //
  520. // If the master adapter is NULL in the adapter object then device does not
  521. // require any map registers.
  522. //
  523. extern PADAPTER_OBJECT MasterAdapterObject;
  524. extern POBJECT_TYPE *IoAdapterObjectType;
  525. extern BOOLEAN LessThan16Mb;
  526. extern BOOLEAN HalpEisaDma;
  527. //
  528. // Map buffer prameters. These are initialized in HalInitSystem
  529. //
  530. extern PHYSICAL_ADDRESS HalpMapBufferPhysicalAddress;
  531. extern ULONG HalpMapBufferSize;
  532. extern ULONG HalpBusType;
  533. extern ULONG HalpCpuType;
  534. extern UCHAR HalpSerialLen;
  535. extern UCHAR HalpSerialNumber[];
  536. //
  537. // The following macros are taken from mm\ia64\miia64.h. We need them here
  538. // so the HAL can map its own memory before memory-management has been
  539. // initialized, or during a BugCheck.
  540. //
  541. // MiGetPdeAddress returns the address of the PDE which maps the
  542. // given virtual address.
  543. //
  544. #if defined(_WIN64)
  545. #define ADDRESS_BITS 64
  546. #define NT_ADDRESS_BITS 32
  547. #define NT_ADDRESS_MASK (((UINT_PTR)1 << NT_ADDRESS_BITS) -1)
  548. #define MiGetPdeAddress(va) \
  549. ((PHARDWARE_PTE)(((((UINT_PTR)(va) & NT_ADDRESS_MASK) >> PDI_SHIFT) << PTE_SHIFT) + PDE_BASE))
  550. #define MiGetPteAddress(va) \
  551. ((PHARDWARE_PTE)(((((UINT_PTR)(va) & NT_ADDRESS_MASK) >> PAGE_SHIFT) << PTE_SHIFT) + PTE_BASE))
  552. #else
  553. #define MiGetPdeAddress(va) ((PHARDWARE_PTE)(((((ULONG)(va)) >> 22) << 2) + PDE_BASE))
  554. //
  555. // MiGetPteAddress returns the address of the PTE which maps the
  556. // given virtual address.
  557. //
  558. #define MiGetPteAddress(va) ((PHARDWARE_PTE)(((((ULONG)(va)) >> 12) << 2) + PTE_BASE))
  559. #endif // defined(_WIN64)
  560. //
  561. // Resource usage information
  562. //
  563. #pragma pack(1)
  564. typedef struct {
  565. UCHAR Flags;
  566. KIRQL Irql;
  567. UCHAR BusReleativeVector;
  568. } IDTUsage;
  569. typedef struct _HalAddressUsage{
  570. struct _HalAddressUsage *Next;
  571. CM_RESOURCE_TYPE Type; // Port or Memory
  572. UCHAR Flags; // same as IDTUsage.Flags
  573. struct {
  574. ULONG Start;
  575. ULONG Length;
  576. } Element[];
  577. } ADDRESS_USAGE;
  578. #pragma pack()
  579. //
  580. // Added the following line
  581. //
  582. #define MAXIMUM_IDTVECTOR 0x0FF
  583. //
  584. // The following 3 lines are lifted from halp.h of halia64 directory
  585. // to clear the build error from i64timer.c
  586. //
  587. #define DEFAULT_CLOCK_INTERVAL 100000 // 10 ms
  588. #define MINIMUM_CLOCK_INTERVAL 10000 // 1 ms
  589. #define MAXIMUM_CLOCK_INTERVAL 100000 // 10 ms
  590. // IO Port emulation defines
  591. #define IO_PORT_MASK 0x0FFFF;
  592. #define BYTE_ADDRESS_MASK 0x00FFF;
  593. #define BYTE_ADDRESS_CLEAR 0x0FFFC;
  594. // #define ExtVirtualIOBase 0xFFFFFFFFFFC00000
  595. // #define VirtualIOBase 0xFFFFFFFFFFC00000i64
  596. #define VirtualIOBase (UINT_PTR)(KADDRESS_BASE+0xFFC00000)
  597. // extern VOID *VirtualIOBase;
  598. // #define PhysicalIOBase 0x80000000FFC00000i64
  599. #define PhysicalIOBase 0x00000FFFFC000000i64
  600. #define IDTOwned 0x01 // IDT is not available for others
  601. #define InterruptLatched 0x02 // Level or Latched
  602. #define InternalUsage 0x11 // Report usage on internal bus
  603. #define DeviceUsage 0x21 // Report usage on device bus
  604. extern IDTUsage HalpIDTUsage[];
  605. extern ADDRESS_USAGE *HalpAddressUsageList;
  606. #define HalpRegisterAddressUsage(a) \
  607. (a)->Next = HalpAddressUsageList, HalpAddressUsageList = (a);
  608. VOID
  609. HalpInsertTranslationRegister (
  610. IN UINT_PTR IFA,
  611. IN ULONG SlotNumber,
  612. IN ULONGLONG Attribute,
  613. IN ULONGLONG ITIR
  614. );
  615. VOID
  616. HalpFillTbForIOPortSpace (
  617. ULONGLONG PhysicalAddress,
  618. UINT_PTR VirtualAddress,
  619. ULONG SlotNumber
  620. );
  621. //
  622. // Temp definitions to thunk into supporting new bus extension format
  623. //
  624. VOID
  625. HalpRegisterInternalBusHandlers (
  626. VOID
  627. );
  628. PBUS_HANDLER
  629. HalpAllocateBusHandler (
  630. IN INTERFACE_TYPE InterfaceType,
  631. IN BUS_DATA_TYPE BusDataType,
  632. IN ULONG BusNumber,
  633. IN INTERFACE_TYPE ParentBusDataType,
  634. IN ULONG ParentBusNumber,
  635. IN ULONG BusSpecificData
  636. );
  637. #define HalpHandlerForBus HaliHandlerForBus
  638. #define HalpSetBusHandlerParent(c,p) (c)->ParentHandler = p;
  639. //
  640. // Define function prototypes.
  641. //
  642. VOID
  643. HalInitSystemPhase2(
  644. VOID
  645. );
  646. KIRQL
  647. HaliRaiseIrqlToDpcLevel (
  648. VOID
  649. );
  650. BOOLEAN
  651. HalpGrowMapBuffers(
  652. PADAPTER_OBJECT AdapterObject,
  653. ULONG Amount
  654. );
  655. PADAPTER_OBJECT
  656. HalpAllocateAdapter(
  657. IN ULONG MapRegistersPerChannel,
  658. IN PVOID AdapterBaseVa,
  659. IN PVOID MapRegisterBase
  660. );
  661. VOID
  662. HalpDisableAllInterrupts (
  663. VOID
  664. );
  665. VOID
  666. HalpProfileInterrupt(
  667. IN PKTRAP_FRAME TrapFrame
  668. );
  669. VOID
  670. HalpInitializeClock(
  671. VOID
  672. );
  673. VOID
  674. HalpInitializeDisplay(
  675. VOID
  676. );
  677. VOID
  678. HalpInitializeStallExecution(
  679. IN CCHAR ProcessorNumber
  680. );
  681. VOID
  682. HalpRemoveFences (
  683. VOID
  684. );
  685. VOID
  686. HalpInitializePICs(
  687. VOID
  688. );
  689. VOID
  690. HalpIrq13Handler (
  691. VOID
  692. );
  693. VOID
  694. HalpFlushTLB (
  695. VOID
  696. );
  697. VOID
  698. HalpSerialize (
  699. VOID
  700. );
  701. PVOID
  702. HalMapPhysicalMemory(
  703. IN PHYSICAL_ADDRESS PhysicalAddress,
  704. IN ULONG NumberPages
  705. );
  706. PVOID
  707. HalpMapPhysicalMemory(
  708. IN PVOID PhysicalAddress,
  709. IN ULONG NumberPages
  710. );
  711. PVOID
  712. HalpMapPhysicalMemoryWriteThrough(
  713. IN PVOID PhysicalAddress,
  714. IN ULONG NumberPages
  715. );
  716. ULONG
  717. HalpAllocPhysicalMemory(
  718. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  719. IN ULONG MaxPhysicalAddress,
  720. IN ULONG NoPages,
  721. IN BOOLEAN bAlignOn64k
  722. );
  723. VOID
  724. HalpBiosDisplayReset(
  725. IN VOID
  726. );
  727. HAL_DISPLAY_BIOS_INFORMATION
  728. HalpGetDisplayBiosInformation (
  729. VOID
  730. );
  731. VOID
  732. HalpDisplayDebugStatus(
  733. IN PUCHAR Status,
  734. IN ULONG Length
  735. );
  736. VOID
  737. HalpInitializeCmos (
  738. VOID
  739. );
  740. VOID
  741. HalpReadCmosTime (
  742. PTIME_FIELDS TimeFields
  743. );
  744. VOID
  745. HalpWriteCmosTime (
  746. PTIME_FIELDS TimeFields
  747. );
  748. VOID
  749. HalpAcquireCmosSpinLock (
  750. VOID
  751. );
  752. VOID
  753. HalpReleaseCmosSpinLock (
  754. VOID
  755. );
  756. VOID
  757. HalpResetAllProcessors (
  758. VOID
  759. );
  760. VOID
  761. HalpCpuID (
  762. ULONG InEax,
  763. PULONG OutEax,
  764. PULONG OutEbx,
  765. PULONG OutEcx,
  766. PULONG OutEdx
  767. );
  768. ULONGLONG
  769. FASTCALL
  770. RDMSR (
  771. IN ULONG MsrAddress
  772. );
  773. VOID
  774. WRMSR (
  775. IN ULONG MsrAddress,
  776. IN ULONGLONG MsrValue
  777. );
  778. VOID
  779. HalpEnableInterruptHandler (
  780. IN UCHAR ReportFlags,
  781. IN ULONG BusInterruptVector,
  782. IN ULONG SystemInterruptVector,
  783. IN KIRQL SystemIrql,
  784. IN VOID (*HalInterruptServiceRoutine)(VOID),
  785. IN KINTERRUPT_MODE InterruptMode
  786. );
  787. VOID
  788. HalpRegisterVector (
  789. IN UCHAR ReportFlags,
  790. IN ULONG BusInterruptVector,
  791. IN ULONG SystemInterruptVector,
  792. IN KIRQL SystemIrql
  793. );
  794. VOID
  795. HalpReportResourceUsage (
  796. IN PUNICODE_STRING HalName,
  797. IN INTERFACE_TYPE DeviceInterfaceToUse
  798. );
  799. VOID
  800. HalpYearIs(
  801. IN ULONG Year
  802. );
  803. VOID
  804. HalpRecordEisaInterruptVectors(
  805. VOID
  806. );
  807. NTSTATUS
  808. HalIrqTranslateResourcesRoot(
  809. IN PVOID Context,
  810. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  811. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  812. IN ULONG AlternativesCount, OPTIONAL
  813. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  814. IN PDEVICE_OBJECT PhysicalDeviceObject,
  815. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  816. );
  817. NTSTATUS
  818. HalIrqTranslateResourceRequirementsRoot(
  819. IN PVOID Context,
  820. IN PIO_RESOURCE_DESCRIPTOR Source,
  821. IN PDEVICE_OBJECT PhysicalDeviceObject,
  822. OUT PULONG TargetCount,
  823. OUT PIO_RESOURCE_DESCRIPTOR *Target
  824. );
  825. NTSTATUS
  826. HalIrqTranslateResourceRequirementsIsa(
  827. IN PVOID Context,
  828. IN PIO_RESOURCE_DESCRIPTOR Source,
  829. IN PDEVICE_OBJECT PhysicalDeviceObject,
  830. OUT PULONG TargetCount,
  831. OUT PIO_RESOURCE_DESCRIPTOR *Target
  832. );
  833. NTSTATUS
  834. HalIrqTranslateResourcesIsa(
  835. IN PVOID Context,
  836. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  837. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  838. IN ULONG AlternativesCount, OPTIONAL
  839. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  840. IN PDEVICE_OBJECT PhysicalDeviceObject,
  841. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  842. );
  843. //
  844. // Defines for HalpFeatureBits
  845. //
  846. #define HAL_PERF_EVENTS 0x00000001
  847. #define HAL_NO_SPECULATION 0x00000002
  848. #define HAL_MCA_PRESENT 0x00000004 // Intel MCA Available
  849. #define HAL_MCE_PRESENT 0x00000008 // ONLY Pentium style MCE available
  850. extern ULONG HalpFeatureBits;
  851. //
  852. // Added HalpPciIrqMask
  853. //
  854. extern USHORT HalpPciIrqMask;
  855. //
  856. // Defines for Processor Features returned from CPUID instruction
  857. //
  858. #define CPUID_MCA_MASK 0x4000
  859. #define CPUID_MCE_MASK 0x0080
  860. // Added ITIR bit field masks
  861. //
  862. #define ITIR_PPN_MASK 0x7FFF000000000000
  863. #define IoSpaceSize 0x14
  864. #define Attribute_PPN_Mask 0x0000FFFFFFFFF000
  865. #define IoSpaceAttribute 0x0010000000000473
  866. NTSTATUS
  867. HalpGetMcaLog(
  868. OUT PMCA_EXCEPTION Exception,
  869. OUT PULONG ReturnedLength
  870. );
  871. NTSTATUS
  872. HalpMcaRegisterDriver(
  873. IN PMCA_DRIVER_INFO pMcaDriverInfo // Info about registering driver
  874. );
  875. VOID
  876. HalpMcaInit(
  877. VOID
  878. );
  879. //
  880. // Disable the Local APIC on UP (PIC 8259) PentiumPro systems to work around
  881. // spurious interrupt errata.
  882. //
  883. #define APIC_BASE_MSR 0x1B
  884. #define APIC_ENABLED 0x0000000000000800
  885. //
  886. // PnP stuff
  887. //
  888. VOID
  889. HalIrqTranslatorReference(
  890. PVOID Context
  891. );
  892. VOID
  893. HalIrqTranslatorDereference(
  894. PVOID Context
  895. );
  896. NTSTATUS
  897. HalIrqTranslateResources(
  898. IN PVOID Context,
  899. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  900. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  901. IN ULONG AlternativesCount, OPTIONAL
  902. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  903. IN PDEVICE_OBJECT PhysicalDeviceObject,
  904. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  905. );
  906. ULONG
  907. HalpGetIsaIrqState(
  908. ULONG Vector
  909. );
  910. // Definion for IA64 HalpVectorToINTI
  911. #define VECTOR 0xFF;
  912. #define LEVEL 32;
  913. extern UCHAR HalpVectorToINTI[];
  914. extern UCHAR HalpVectorToIRQL[];
  915. // Definition for IA64 complete
  916. //
  917. // ACPI specific stuff
  918. //
  919. // from detect\i386\acpibios.h
  920. typedef struct _ACPI_BIOS_INSTALLATION_CHECK {
  921. UCHAR Signature[8]; // "RSD PTR" (ascii)
  922. UCHAR Checksum;
  923. UCHAR OemId[6]; // An OEM-supplied string
  924. UCHAR reserved; // must be 0
  925. ULONG RsdtAddress; // 32-bit physical address of RSDT
  926. } ACPI_BIOS_INSTALLATION_CHECK, *PACPI_BIOS_INSTALLATION_CHECK;
  927. NTSTATUS
  928. HalpAcpiFindRsdt (
  929. OUT PACPI_BIOS_INSTALLATION_CHECK RsdtPtr
  930. );
  931. NTSTATUS
  932. HalpAcpiFindRsdtPhase0(
  933. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  934. );
  935. NTSTATUS
  936. HalpSetupAcpiPhase0(
  937. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  938. );
  939. PVOID
  940. HalpGetAcpiTable(
  941. ULONG Signature
  942. );
  943. VOID
  944. HalpSleepS5(
  945. VOID
  946. );
  947. VOID
  948. HalProcessorThrottle (
  949. UCHAR
  950. );
  951. VOID
  952. HalpStoreBufferUCHAR (
  953. PUCHAR VirtualAddress,
  954. PUCHAR Buffer,
  955. ULONG Count
  956. );
  957. VOID
  958. HalpStoreBufferUSHORT (
  959. PUSHORT VirtualAddress,
  960. PUSHORT Buffer,
  961. ULONG Count
  962. );
  963. VOID
  964. HalpStoreBufferULONG (
  965. PULONG VirtualAddress,
  966. PULONG Buffer,
  967. ULONG Count
  968. );
  969. VOID
  970. HalpStoreBufferULONGLONG (
  971. PULONGLONG VirtualAddress,
  972. PULONGLONG Buffer,
  973. ULONG Count
  974. );
  975. VOID
  976. HalpLoadBufferUCHAR (
  977. PUCHAR VirtualAddress,
  978. PUCHAR Buffer,
  979. ULONG Count
  980. );
  981. VOID
  982. HalpLoadBufferUSHORT (
  983. PUSHORT VirtualAddress,
  984. PUSHORT Buffer,
  985. ULONG Count
  986. );
  987. VOID
  988. HalpLoadBufferULONG (
  989. PULONG VirtualAddress,
  990. PULONG Buffer,
  991. ULONG Count
  992. );
  993. VOID
  994. HalpLoadBufferULONGLONG (
  995. PULONGLONG VirtualAddress,
  996. PULONGLONG Buffer,
  997. ULONG Count
  998. );
  999. //
  1000. // I/O Port space
  1001. //
  1002. // IoSpaceSize = 0x14 for 2 power 0x14 is 1Meg space size.
  1003. //
  1004. #define IO_SPACE_SIZE 0x14
  1005. // Present bit = 1B to wire the space.
  1006. // Memory Attributes = 1001B for UC Memory type
  1007. // Accessed Bit = 1B to "enable" access without faulting.
  1008. // Dirty Bit = 1B to "enable" write without faulting.
  1009. // Privilege Level = 00B for kernel accesses
  1010. // Access Right = 010B for read/write accesses
  1011. // Exception Deferral= 1B for Exception Deferral.
  1012. // Exceptions are deferred
  1013. // for speculative loads to pages with
  1014. // non-spec. mem. attributes anyway.
  1015. // Protection Key = 0 for kernel mode
  1016. #define IO_SPACE_ATTRIBUTE 0x0010000000000473
  1017. #endif // _HALP_