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

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