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.

2377 lines
55 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. halp.h
  5. Abstract:
  6. This header file defines the private Hardware Architecture Layer (HAL)
  7. interfaces, defines and structures.
  8. Author:
  9. John Vert (jvert) 11-Feb-92
  10. Revision History:
  11. --*/
  12. #ifndef _HALP_H_
  13. #define _HALP_H_
  14. #include "nthal.h"
  15. #include "hal.h"
  16. #include "halnls.h"
  17. #include "kxia64.h"
  18. #include "acpitabl.h"
  19. //
  20. // Pickup the pnp guid definitions.
  21. //
  22. #include "wdmguid.h"
  23. #ifndef _HALI_
  24. #include "..\inc\hali.h"
  25. #endif
  26. #include "i64fw.h"
  27. #define SAPIC_SPURIOUS_LEVEL 0
  28. #define DPC_LEVEL 2
  29. #define CMCI_LEVEL 3
  30. #define SAPIC_SPURIOUS_VECTOR 0x0F
  31. #define CMCI_VECTOR (CMCI_LEVEL << VECTOR_IRQL_SHIFT) // 0x30
  32. #define CPEI_VECTOR (CMCI_VECTOR+1) // 0x31
  33. // CPEI_VECTOR is defined relative to CMCI_VECTOR,
  34. // CPEI_LEVEL is defined from CPEI_VECTOR.
  35. #define CPEI_LEVEL (CPEI_VECTOR >> VECTOR_IRQL_SHIFT)
  36. #define SYNCH_VECTOR (SYNCH_LEVEL << VECTOR_IRQL_SHIFT) // 0xD0
  37. #define CLOCK_VECTOR (CLOCK_LEVEL << VECTOR_IRQL_SHIFT) // 0xD0
  38. #define IPI_VECTOR (IPI_LEVEL << VECTOR_IRQL_SHIFT) // 0xE0
  39. #define PROFILE_VECTOR (PROFILE_LEVEL << VECTOR_IRQL_SHIFT) // 0xF0
  40. #define PERF_VECTOR (PROFILE_VECTOR+1) // 0xF1
  41. #define MC_RZ_VECTOR (0xD+(HIGH_LEVEL << VECTOR_IRQL_SHIFT)) // 0xFD
  42. #define MC_WKUP_VECTOR (MC_RZ_VECTOR+1) // 0xFE
  43. #if DBG
  44. //
  45. // _HALIA64_DPFLTR_LEVEL: HALIA64 specific DbgPrintEx() levels.
  46. //
  47. #ifndef DPFLTR_COMPONENT_PRIVATE_MINLEVEL
  48. //
  49. // FIXFIX - 01/2000: The DPFLTR LEVEL definitions do not specify a maximum.
  50. // We are defining DPFLTR_INFO_LEVEL as the default max.
  51. //
  52. #define DPFLTR_COMPONENT_PRIVATE_MINLEVEL (DPFLTR_INFO_LEVEL + 1)
  53. #endif // !DPFLTR_COMPONENT_PRIVATE_MINLEVEL
  54. typedef enum _HALIA64_DPFLTR_LEVEL {
  55. HALIA64_DPFLTR_PNP_LEVEL = DPFLTR_COMPONENT_PRIVATE_MINLEVEL,
  56. HALIA64_DPFLTR_PROFILE_LEVEL,
  57. HALIA64_DPFLTR_MCE_LEVEL, // Machine Check Events level
  58. HALIA64_DPFLTR_MAX_LEVEL,
  59. HALIA64_DPFLTR_MAXMASK = (((unsigned int)0xffffffff) >> ((unsigned int)(32-HALIA64_DPFLTR_MAX_LEVEL)))
  60. } HALIA64_DPFLTR_LEVEL;
  61. #define HAL_FATAL_ERROR DPFLTR_ERROR_LEVEL
  62. #define HAL_ERROR DPFLTR_ERROR_LEVEL
  63. #define HAL_WARNING DPFLTR_WARNING_LEVEL
  64. #define HAL_INFO DPFLTR_INFO_LEVEL
  65. #define HAL_VERBOSE DPFLTR_INFO_LEVEL
  66. #define HAL_PNP HALIA64_DPFLTR_PNP_LEVEL
  67. #define HAL_PROFILE HALIA64_DPFLTR_PROFILE_LEVEL
  68. #define HAL_MCE HALIA64_DPFLTR_MCE_LEVEL
  69. extern ULONG HalpUseDbgPrint;
  70. VOID
  71. __cdecl
  72. HalpDebugPrint(
  73. ULONG Level,
  74. PCCHAR Message,
  75. ...
  76. );
  77. #define HalDebugPrint( _x_ ) HalpDebugPrint _x_
  78. #else // !DBG
  79. #define HalDebugPrint( _x_ )
  80. #endif // !DBG
  81. //
  82. // HALP_VALIDATE_LOW_IRQL()
  83. //
  84. // This macro validates the call at low irql - passive or apc levels - and returns
  85. // STATUS_UNSUCCESSFUL if high irql.
  86. //
  87. #define HALP_VALIDATE_LOW_IRQL() \
  88. if (KeGetCurrentIrql() > APC_LEVEL) { \
  89. HalDebugPrint((HAL_ERROR,"HAL: code called at IRQL %d > APC_LEVEL\n", KeGetCurrentIrql() )); \
  90. ASSERT(FALSE); \
  91. return( STATUS_UNSUCCESSFUL ); \
  92. }
  93. #define HAL_MAXIMUM_PROCESSOR 32
  94. #define MAX_NODES HAL_MAXIMUM_PROCESSOR
  95. #define HAL_MAXIMUM_LID_ID 256
  96. //
  97. // Default clock and profile timer intervals (in 100ns-unit)
  98. //
  99. #define DEFAULT_CLOCK_INTERVAL 100000 // 10 ms
  100. #define MINIMUM_CLOCK_INTERVAL 10000 // 1 ms
  101. #define MAXIMUM_CLOCK_INTERVAL 100000 // 10 ms
  102. extern double HalpITCTicksPer100ns;
  103. extern ULONG HalpCPUMHz;
  104. //
  105. // Define Realtime Clock register numbers.
  106. //
  107. #define RTC_SECOND 0 // second of minute [0..59]
  108. #define RTC_SECOND_ALARM 1 // seconds to alarm
  109. #define RTC_MINUTE 2 // minute of hour [0..59]
  110. #define RTC_MINUTE_ALARM 3 // minutes to alarm
  111. #define RTC_HOUR 4 // hour of day [0..23]
  112. #define RTC_HOUR_ALARM 5 // hours to alarm
  113. #define RTC_DAY_OF_WEEK 6 // day of week [1..7]
  114. #define RTC_DAY_OF_MONTH 7 // day of month [1..31]
  115. #define RTC_MONTH 8 // month of year [1..12]
  116. #define RTC_YEAR 9 // year [00..99]
  117. #define RTC_CENTURY 0x32 // Century byte offset
  118. #define RTC_CONTROL_REGISTERA 10 // control register A
  119. #define RTC_CONTROL_REGISTERB 11 // control register B
  120. #define RTC_CONTROL_REGISTERC 12 // control register C
  121. #define RTC_CONTROL_REGISTERD 13 // control register D
  122. #define RTC_REGNUMBER_RTC_CR1 0x6A // control register 1
  123. #define RTC_ISA_ADDRESS_PORT 0x070
  124. #define RTC_ISA_DATA_PORT 0x071
  125. #include <efi.h>
  126. #define EFI_PHYSICAL_GET_VARIABLE_INDEX 0xFF // GetVariable;
  127. #define EFI_PHYSICAL_SET_VARIABLE_INDEX 0xFE // SetVariable;
  128. //
  129. // Time Services
  130. //
  131. #define EFI_GET_TIME_INDEX 0 // GetTime;
  132. #define EFI_SET_TIME_INDEX 1 // SetTime;
  133. #define EFI_GET_WAKEUP_TIME_INDEX 2 // GetWakeupTime;
  134. #define EFI_SET_WAKEUP_TIME_INDEX 3 // SetWakeupTime;
  135. //
  136. // Virtual memory services
  137. //
  138. #define EFI_SET_VIRTUAL_ADDRESS_MAP_INDEX 4 // SetVirtualAddressMap;
  139. #define EFI_CONVERT_POINTER_INDEX 5 // ConvertPointer;
  140. //
  141. // Variable serviers
  142. //
  143. #define EFI_GET_VARIABLE_INDEX 6 // GetVariable;
  144. #define EFI_GET_NEXT_VARIABLE_NAME_INDEX 7 // GetNextVariableName;
  145. #define EFI_SET_VARIABLE_INDEX 8 // SetVariable;
  146. //
  147. // Misc
  148. //
  149. #define EFI_GET_NEXT_HIGH_MONO_COUNT_INDEX 9 // GetNextHighMonotonicCount;
  150. #define EFI_RESET_SYSTEM_INDEX 0xA // ResetSystem;
  151. //
  152. // Task priority functions
  153. //
  154. #define EFI_RAISE_TPL_INDEX 0xB // Raise TPL
  155. #define EFI_RESTORE_TPL_INDEX 0xC // Restore TPL
  156. //
  157. // Memory functions
  158. //
  159. #define EFI_ALLOCATE_PAGES_INDEX 0xD // AllocatePages
  160. #define EFI_FREE_PAGES_INDEX 0xE // FreePages
  161. #define EFI_GET_MEMORY_MAP_INDEX 0xF // GetMemoryMap
  162. #define EFI_ALLOCATE_POOL_INDEX 0x10 // AllocatePool
  163. #define EFI_FREE_POOL_INDEX 0x11 // FreePool
  164. //
  165. // Event & timer functions
  166. //
  167. #define EFI_CREATE_EVENT_INDEX 0x12 // CreateEvent
  168. #define EFI_SET_TIMER_INDEX 0x13 // SetTimer
  169. #define EFI_WAIT_FOR_EVENT_INDEX 0x14 // WaitForEvent
  170. #define EFI_SIGNAL_EVENT_INDEX 0x15 // SignalEvent
  171. #define EFI_CLOSE_EVENT_INDEX 0x16 // CloseEvent
  172. #define EFI_NOTIFY_IDLE_INDEX 0x17 // NotifyIdle
  173. //
  174. // Protocol handler functions
  175. //
  176. #define EFI_INSTALL_PROTOCOL_INTERFACE_INDEX 0x18 // InstallProtocolInterface;
  177. #define EFI_REINSTALL_PROTOCOL_INTERFACE_INDEX 0x19 // ReinstallProtocolInterface;
  178. #define EFI_UNINSTALL_PROTOCOL_INTERFACE_INDEX 0x1A // UninstallProtocolInterface;
  179. #define EFI_HANDLE_PROTOCOL_INDEX 0x1B // HandleProtocol;
  180. #define EFI_REGISTER_PROTOCOL_NOTIFY_INDEX 0x1C // RegisterProtocolNotify;
  181. #define EFI_LOCATE_HANDLE_INDEX_INDEX 0x1D // LocateHandle;
  182. #define EFI_LOCATE_DEVICE_PATH_INDEX 0x1E // LocateDevicePath;
  183. #define EFI_UNREFERENCE_HANDLE_INDEX 0x1F // UnreferenceHandle;
  184. #define EFI_LOCATE_PROTOCOL_INDEX 0x20 // LocateProtocol;
  185. //
  186. // Image functions
  187. //
  188. #define EFI_IMAGE_LOAD_INDEX 0x21 // LoadImage;
  189. #define EFI_IMAGE_START_INDEX 0x22 // StartImage;
  190. #define EFI_EXIT_INDEX 0x23 // Exit;
  191. #define EFI_IMAGE_UNLOAD_INDEX 0x24 // UnloadImage;
  192. #define EFI_EXIT_BOOT_SERVICES_INDEX 0x25 // ExitBootServices;
  193. //
  194. // Misc functions
  195. //
  196. #define EFI_GET_NEXT_MONOTONIC_COUNT_INDEX 0x26 // GetNextMonotonicCount;
  197. #define EFI_STALL_INDEX 0x27 // Stall;
  198. #define EFI_SET_WATCHDOG_TIMER_INDEX 0x28 // SetWatchdogTimer;
  199. #define EFI_VARIABLE_ATTRIBUTE \
  200. EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
  201. extern PVOID HalpRtcAddressPort;
  202. extern PVOID HalpRtcDataPort;
  203. extern PLOADER_PARAMETER_BLOCK KeLoaderBlock;
  204. //
  205. // Define Control Register A structure.
  206. //
  207. typedef struct _RTC_CONTROL_REGISTER_A {
  208. UCHAR RateSelect : 4;
  209. UCHAR TimebaseDivisor : 3;
  210. UCHAR UpdateInProgress : 1;
  211. } RTC_CONTROL_REGISTER_A, *PRTC_CONTROL_REGISTER_A;
  212. //
  213. // Define Control Register B structure.
  214. //
  215. typedef struct _RTC_CONTROL_REGISTER_B {
  216. UCHAR DayLightSavingsEnable : 1;
  217. UCHAR HoursFormat : 1;
  218. UCHAR DataMode : 1;
  219. UCHAR SquareWaveEnable : 1;
  220. UCHAR UpdateInterruptEnable : 1;
  221. UCHAR AlarmInterruptEnable : 1;
  222. UCHAR TimerInterruptEnable : 1;
  223. UCHAR SetTime : 1;
  224. } RTC_CONTROL_REGISTER_B, *PRTC_CONTROL_REGISTER_B;
  225. //
  226. // Define Control Register C structure.
  227. //
  228. typedef struct _RTC_CONTROL_REGISTER_C {
  229. UCHAR Fill : 4;
  230. UCHAR UpdateInterruptFlag : 1;
  231. UCHAR AlarmInterruptFlag : 1;
  232. UCHAR TimeInterruptFlag : 1;
  233. UCHAR InterruptRequest : 1;
  234. } RTC_CONTROL_REGISTER_C, *PRTC_CONTROL_REGISTER_C;
  235. //
  236. // Define Control Register D structure.
  237. //
  238. typedef struct _RTC_CONTROL_REGISTER_D {
  239. UCHAR Fill : 7;
  240. UCHAR ValidTime : 1;
  241. } RTC_CONTROL_REGISTER_D, *PRTC_CONTROL_REGISTER_D;
  242. #define EISA_DMA_CHANNELS 8
  243. extern UCHAR HalpDmaChannelMasks[];
  244. //
  245. // HalpOwnedDisplayBeforeSleep is defined in mpdat.c
  246. //
  247. extern BOOLEAN HalpOwnedDisplayBeforeSleep;
  248. #define PIC_VECTORS 16
  249. #define PRIMARY_VECTOR_BASE 0x30
  250. extern ULONG HalpDefaultInterruptAffinity;
  251. //
  252. // Thierry / PeterJ 02/00:
  253. // Instead of implementing our own IPI generic call, we use KiIpiGenericCall().
  254. //
  255. typedef
  256. ULONG_PTR
  257. (*PKIPI_BROADCAST_WORKER)(
  258. IN ULONG_PTR Argument
  259. );
  260. ULONG_PTR
  261. KiIpiGenericCall (
  262. IN PKIPI_BROADCAST_WORKER BroadcastFunction,
  263. IN ULONG_PTR Context
  264. );
  265. //
  266. // ROUND UP SIZE macros:
  267. //
  268. // SIZE_T
  269. // ROUND_UP_SIZE_T(
  270. // IN SIZE_T _SizeT,
  271. // IN ULONG _Pow2,
  272. // )
  273. //
  274. #define ROUND_UP_SIZE_T(_SizeT, _Pow2) \
  275. ( (SIZE_T) ( (((SIZE_T)(_SizeT))+(_Pow2)-1) & (~(((LONG)(_Pow2))-1)) ) )
  276. #define ROUND_UP_SIZE(/* SIZE_T */ _SizeT) ROUND_UP_SIZE_T((_SizeT), sizeof(SIZE_T))
  277. //
  278. // PCR address.
  279. // Temporary macros; should already be defined in ntddk.h for IA64
  280. //
  281. #define PCR ((volatile KPCR * const)KIPCR)
  282. //
  283. // PCR has HalReserved area. The following will be the offsets reserved
  284. // by HAL in the HalReserved area.
  285. //
  286. #define CURRENT_ITM_VALUE_INDEX 0
  287. #define PROCESSOR_ID_INDEX 1
  288. #define PROCESSOR_INDEX_BEFORE_PROFILING 5 // ToBeIncremented if new index
  289. // PROCESSOR_PROFILING_INDEX:
  290. // HalReserved[] base of indexes used for Performance Profiling based
  291. // on the IA64 Performance Counters. Refer to ia64prof.h:_HALPROFILE_PCR.
  292. //
  293. #define PROCESSOR_PROFILING_INDEX (PROCESSOR_INDEX_BEFORE_PROFILING + 1)
  294. #define PIC_SLAVE_IRQ 2
  295. #define PIC_SLAVE_REDIRECT 9
  296. extern PVOID HalpSleepPageLock;
  297. NTSTATUS
  298. HalpQueryFrequency(
  299. PULONGLONG ITCFrequency,
  300. PULONGLONG ProcessorFrequency
  301. );
  302. VOID
  303. HalpSynchICache (
  304. VOID
  305. );
  306. VOID
  307. KeSetAffinityThread (
  308. PKTHREAD Thread,
  309. KAFFINITY HalpActiveProcessors
  310. );
  311. extern BOOLEAN
  312. KdPollBreakIn (
  313. VOID
  314. );
  315. NTSTATUS
  316. HalAllocateAdapterChannel (
  317. IN PADAPTER_OBJECT AdapterObject,
  318. IN PWAIT_CONTEXT_BLOCK Wcb,
  319. IN ULONG NumberOfMapRegisters,
  320. IN PDRIVER_CONTROL ExecutionRoutine
  321. );
  322. NTSTATUS
  323. HalRealAllocateAdapterChannel(
  324. IN PADAPTER_OBJECT AdapterObject,
  325. IN PDEVICE_OBJECT DeviceObject,
  326. IN ULONG NumberOfMapRegisters,
  327. IN PDRIVER_CONTROL ExecutionRoutine,
  328. IN PVOID Context
  329. );
  330. ULONG
  331. HalReadDmaCounter (
  332. IN PADAPTER_OBJECT AdapterObject
  333. );
  334. VOID
  335. HalpInitializeInterrupts (
  336. VOID
  337. );
  338. VOID
  339. HalpInitIntiInfo(
  340. VOID
  341. );
  342. VOID
  343. HalpInitEOITable(
  344. VOID
  345. );
  346. VOID
  347. HalpWriteEOITable(
  348. IN ULONG Vector,
  349. IN PULONG_PTR EoiAddress,
  350. IN ULONG Number
  351. );
  352. VOID
  353. HalInitializeProcessor (
  354. ULONG Number,
  355. PLOADER_PARAMETER_BLOCK LoaderBlock
  356. );
  357. VOID
  358. HalpInitIoMemoryBase (
  359. VOID
  360. );
  361. VOID
  362. HalpInitializeX86Int10Call (
  363. VOID
  364. );
  365. VOID
  366. HalpGetParameters (
  367. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  368. );
  369. VOID
  370. HalpClearClock (
  371. VOID
  372. );
  373. VOID
  374. HalpIpiInterruptHandler(
  375. IN PKINTERRUPT_ROUTINE Interrupt,
  376. IN PKTRAP_FRAME TrapFrame
  377. );
  378. VOID
  379. HalpSpuriousHandler (
  380. IN PKINTERRUPT_ROUTINE Interrupt,
  381. IN PKTRAP_FRAME TrapFrame
  382. );
  383. VOID
  384. HalpCMCIHandler (
  385. IN PKINTERRUPT_ROUTINE Interrupt,
  386. IN PKTRAP_FRAME TrapFrame
  387. );
  388. VOID
  389. HalpCPEIHandler (
  390. IN PKINTERRUPT_ROUTINE Interrupt,
  391. IN PKTRAP_FRAME TrapFrame
  392. );
  393. VOID
  394. HalpMcRzHandler (
  395. IN PKINTERRUPT_ROUTINE Interrupt,
  396. IN PKTRAP_FRAME TrapFrame
  397. );
  398. VOID
  399. HalpMcWkupHandler (
  400. IN PKINTERRUPT_ROUTINE Interrupt,
  401. IN PKTRAP_FRAME TrapFrame
  402. );
  403. NTSTATUS
  404. HalpEfiInitialization (
  405. PLOADER_PARAMETER_BLOCK LoaderBlock
  406. );
  407. VOID
  408. HalpPerfInterrupt (
  409. IN PKINTERRUPT_ROUTINE Interrupt,
  410. IN PKTRAP_FRAME TrapFrame
  411. );
  412. ULONG_PTR
  413. HalpSetProfileInterruptHandler(
  414. IN ULONG_PTR ProfileInterruptHandler
  415. );
  416. VOID
  417. HalpSetInternalVector (
  418. IN ULONG InternalVector,
  419. IN VOID (*HalInterruptServiceRoutine)(VOID)
  420. );
  421. VOID
  422. HalpClockInterrupt (
  423. IN PKINTERRUPT_ROUTINE Interrupt,
  424. IN PKTRAP_FRAME TrapFrame
  425. );
  426. VOID
  427. HalpClockInterruptPn(
  428. IN PKINTERRUPT_ROUTINE Interrupt,
  429. IN PKTRAP_FRAME TrapFrame
  430. );
  431. VOID
  432. HalpInitializeClock (
  433. VOID
  434. );
  435. VOID
  436. HalpInitializeClockPn (
  437. VOID
  438. );
  439. VOID
  440. HalpInitializeClockInterrupts(
  441. VOID
  442. );
  443. VOID
  444. HalpSetInitialClockRate (
  445. VOID
  446. );
  447. VOID
  448. HalpInitializeTimerResolution (
  449. ULONG Rate
  450. );
  451. VOID
  452. HalpInitApicDebugMappings(
  453. VOID
  454. );
  455. VOID
  456. HalpSendIPI (
  457. IN USHORT ProcessorID,
  458. IN ULONGLONG Data
  459. );
  460. VOID
  461. HalpMcWakeUp (
  462. VOID
  463. );
  464. VOID
  465. HalpOSRendez (
  466. IN USHORT ProcessorID
  467. );
  468. VOID
  469. HalSweepDcache (
  470. VOID
  471. );
  472. VOID
  473. HalSweepIcache (
  474. VOID
  475. );
  476. VOID
  477. HalSweepIcacheRange (
  478. IN PVOID BaseAddress,
  479. IN SIZE_T Length
  480. );
  481. VOID
  482. HalSweepDcacheRange (
  483. IN PVOID BaseAddress,
  484. IN SIZE_T Length
  485. );
  486. VOID
  487. HalSweepCacheRange (
  488. IN PVOID BaseAddress,
  489. IN SIZE_T Length
  490. );
  491. VOID
  492. HalpSweepcacheLines (
  493. IN PVOID BaseAddress,
  494. IN SIZE_T NumberOfLines
  495. );
  496. LONGLONG
  497. HalCallPal (
  498. IN ULONGLONG FunctionIndex,
  499. IN ULONGLONG Arguement1,
  500. IN ULONGLONG Arguement2,
  501. IN ULONGLONG Arguement3,
  502. OUT PULONGLONG ReturnValue0,
  503. OUT PULONGLONG ReturnValue1,
  504. OUT PULONGLONG ReturnValue2,
  505. OUT PULONGLONG ReturnValue3
  506. );
  507. ULONG
  508. HalGetDeviceData (
  509. IN PBUS_HANDLER BusHandler,
  510. IN PBUS_HANDLER RootHandler,
  511. IN PDEVICE_HANDLER_OBJECT DeviceHandler,
  512. IN ULONG DataType,
  513. IN PVOID Buffer,
  514. IN ULONG Offset,
  515. IN ULONG Length
  516. );
  517. ULONG
  518. HalSetDeviceData (
  519. IN PBUS_HANDLER BusHandler,
  520. IN PBUS_HANDLER RootHandler,
  521. IN PDEVICE_HANDLER_OBJECT DeviceHandler,
  522. IN ULONG DataType,
  523. IN PVOID Buffer,
  524. IN ULONG Offset,
  525. IN ULONG Length
  526. );
  527. NTSTATUS
  528. HalpHibernateHal (
  529. IN PBUS_HANDLER BusHandler,
  530. IN PBUS_HANDLER RootHandler
  531. );
  532. NTSTATUS
  533. HalpResumeHal (
  534. IN PBUS_HANDLER BusHandler,
  535. IN PBUS_HANDLER RootHandler
  536. );
  537. ULONG
  538. HalpGetFeatureBits (
  539. VOID
  540. );
  541. NTSTATUS
  542. HalpGetApicIdByProcessorNumber(
  543. IN UCHAR Processor,
  544. IN OUT USHORT *ApicId
  545. );
  546. ULONG
  547. HalpGetProcessorNumberByApicId(
  548. USHORT ApicId
  549. );
  550. VOID
  551. HalpAddNodeNumber(
  552. ULONG
  553. );
  554. #define HalpVectorToNode(vector) ((vector)>>8)
  555. #define HalpVector(node, idtentry) ((node)<<8|(idtentry))
  556. extern UCHAR HalpMaxProcsPerCluster;
  557. //
  558. // Always called with the IDT form of the vector
  559. //
  560. #define HalpSetHandlerAddressToVector(Vector, Handler) \
  561. PCR-> InterruptRoutine[Vector] = (PKINTERRUPT_ROUTINE)Handler;
  562. #define HalpEnableInterrupts() __ssm(1 << PSR_I)
  563. BOOLEAN
  564. HalpDisableInterrupts (
  565. VOID
  566. );
  567. ULONG
  568. HalpAcquireHighLevelLock (
  569. PKSPIN_LOCK Lock
  570. );
  571. VOID
  572. HalpReleaseHighLevelLock (
  573. PKSPIN_LOCK Lock,
  574. ULONG OldLevel
  575. );
  576. #ifdef RtlMoveMemory
  577. #undef RtlMoveMemory
  578. #undef RtlCopyMemory
  579. #undef RtlFillMemory
  580. #undef RtlZeroMemory
  581. #define RtlCopyMemory(Destination,Source,Length) RtlMoveMemory((Destination),(Source),(Length))
  582. VOID
  583. RtlMoveMemory (
  584. PVOID Destination,
  585. CONST VOID *Source,
  586. ULONG Length
  587. );
  588. VOID
  589. RtlFillMemory (
  590. PVOID Destination,
  591. ULONG Length,
  592. UCHAR Fill
  593. );
  594. VOID
  595. RtlZeroMemory (
  596. PVOID Destination,
  597. ULONG Length
  598. );
  599. #endif
  600. #include "ixisa.h"
  601. //
  602. // Define map register translation entry structure.
  603. //
  604. typedef struct _TRANSLATION_ENTRY {
  605. PVOID VirtualAddress;
  606. ULONG PhysicalAddress;
  607. ULONG Index;
  608. } TRANSLATION_ENTRY, *PTRANSLATION_ENTRY;
  609. //
  610. //
  611. //
  612. typedef struct _PROCESSOR_INFO {
  613. UCHAR NtProcessorNumber;
  614. UCHAR AcpiProcessorID;
  615. USHORT LocalApicID;
  616. } PROCESSOR_INFO, *PPROCESSOR_INFO;
  617. extern PROCESSOR_INFO HalpProcessorInfo[HAL_MAXIMUM_PROCESSOR];
  618. struct _MPINFO {
  619. ULONG ProcessorCount;
  620. ULONG IoSapicCount;
  621. };
  622. extern struct _MPINFO HalpMpInfo;
  623. //
  624. // HAL private Mask of all of the active processors.
  625. //
  626. // The specific processors bits are based on their _KPCR.Number values.
  627. extern KAFFINITY HalpActiveProcessors;
  628. #define VECTOR_SIZE 8
  629. #define IPI_ID_SHIFT 4
  630. #define IpiTOKEN_SHIFT 20
  631. #define IpiTOKEN 0xFFE
  632. #define EID_MASK 0xFF00
  633. //
  634. // Should be read from SST
  635. //
  636. #define DEFAULT_OS_RENDEZ_VECTOR 0xF0
  637. #define RENDEZ_TIME_OUT 0XFFFF
  638. //
  639. // Some devices require a phyicially contiguous data buffers for DMA transfers.
  640. // Map registers are used give the appearance that all data buffers are
  641. // contiguous. In order to pool all of the map registers a master
  642. // adapter object is used. This object is allocated and saved internal to this
  643. // file. It contains a bit map for allocation of the registers and a queue
  644. // for requests which are waiting for more map registers. This object is
  645. // allocated during the first request to allocate an adapter which requires
  646. // map registers.
  647. //
  648. // In this system, the map registers are translation entries which point to
  649. // map buffers. Map buffers are physically contiguous and have physical memory
  650. // addresses less than 0x01000000. All of the map registers are allocated
  651. // initialially; however, the map buffers are allocated base in the number of
  652. // adapters which are allocated.
  653. //
  654. // If the master adapter is NULL in the adapter object then device does not
  655. // require any map registers.
  656. //
  657. extern PADAPTER_OBJECT MasterAdapterObject;
  658. extern POBJECT_TYPE *IoAdapterObjectType;
  659. extern BOOLEAN NoMemoryAbove4Gb;
  660. extern BOOLEAN HalpEisaDma;
  661. //
  662. // Map buffer prameters. These are initialized in HalInitSystem
  663. //
  664. extern PHYSICAL_ADDRESS HalpMapBufferPhysicalAddress;
  665. extern ULONG HalpMapBufferSize;
  666. extern ULONG HalpBusType;
  667. extern ULONG HalpCpuType;
  668. extern UCHAR HalpSerialLen;
  669. extern UCHAR HalpSerialNumber[];
  670. //
  671. // Resource usage information
  672. //
  673. #pragma pack(1)
  674. typedef struct {
  675. UCHAR Flags;
  676. KIRQL Irql;
  677. UCHAR BusReleativeVector;
  678. } IDTUsage;
  679. typedef struct _HalAddressUsage{
  680. struct _HalAddressUsage *Next;
  681. CM_RESOURCE_TYPE Type; // Port or Memory
  682. UCHAR Flags; // same as IDTUsage.Flags
  683. struct {
  684. ULONG Start;
  685. ULONG Length;
  686. } Element[];
  687. } ADDRESS_USAGE;
  688. #pragma pack()
  689. //
  690. // Added the following line
  691. //
  692. #define MAXIMUM_IDTVECTOR 0x0FF
  693. #define IDTOwned 0x01 // IDT is not available for others
  694. #define InterruptLatched 0x02 // Level or Latched
  695. #define InternalUsage 0x11 // Report usage on internal bus
  696. #define DeviceUsage 0x21 // Report usage on device bus
  697. extern IDTUsage HalpIDTUsage[];
  698. extern ADDRESS_USAGE *HalpAddressUsageList;
  699. #define HalpRegisterAddressUsage(a) \
  700. (a)->Next = HalpAddressUsageList, HalpAddressUsageList = (a);
  701. //
  702. // Temp definitions to thunk into supporting new bus extension format
  703. //
  704. VOID
  705. HalpRegisterInternalBusHandlers (
  706. VOID
  707. );
  708. PBUS_HANDLER
  709. HalpAllocateBusHandler (
  710. IN INTERFACE_TYPE InterfaceType,
  711. IN BUS_DATA_TYPE BusDataType,
  712. IN ULONG BusNumber,
  713. IN INTERFACE_TYPE ParentBusDataType,
  714. IN ULONG ParentBusNumber,
  715. IN ULONG BusSpecificData
  716. );
  717. #define HalpHandlerForBus HaliHandlerForBus
  718. #define HalpSetBusHandlerParent(c,p) (c)->ParentHandler = p;
  719. //
  720. // Define function prototypes.
  721. //
  722. VOID
  723. HalInitSystemPhase2(
  724. VOID
  725. );
  726. KIRQL
  727. HaliRaiseIrqlToDpcLevel (
  728. VOID
  729. );
  730. BOOLEAN
  731. HalpGrowMapBuffers(
  732. PADAPTER_OBJECT AdapterObject,
  733. ULONG Amount
  734. );
  735. PADAPTER_OBJECT
  736. HalpAllocateAdapter(
  737. IN ULONG MapRegistersPerChannel,
  738. IN PVOID AdapterBaseVa,
  739. IN PVOID MapRegisterBase
  740. );
  741. KIRQL
  742. HalpDisableAllInterrupts (
  743. VOID
  744. );
  745. VOID
  746. HalpReenableInterrupts (
  747. KIRQL NewIrql
  748. );
  749. VOID
  750. HalpSetInitialProfileState(
  751. VOID
  752. );
  753. VOID
  754. HalpProfileInterrupt (
  755. IN PKINTERRUPT_ROUTINE Interrupt,
  756. IN PKTRAP_FRAME TrapFrame
  757. );
  758. typedef
  759. VOID
  760. (*PHAL_PROFILE_INTERRUPT_HANDLER)(
  761. IN PKTRAP_FRAME TrapFrame
  762. );
  763. VOID
  764. HalpInitializeClock(
  765. VOID
  766. );
  767. VOID
  768. HalpInitializeStallExecution(
  769. IN CCHAR ProcessorNumber
  770. );
  771. VOID
  772. HalpRemoveFences (
  773. VOID
  774. );
  775. VOID
  776. HalpInitializePICs(
  777. BOOLEAN EnableInterrupts
  778. );
  779. VOID
  780. HalpIrq13Handler (
  781. VOID
  782. );
  783. VOID
  784. HalpFlushTLB (
  785. VOID
  786. );
  787. VOID
  788. HalpSerialize (
  789. VOID
  790. );
  791. PVOID
  792. HalpMapPhysicalMemory(
  793. IN PHYSICAL_ADDRESS PhysicalAddress,
  794. IN ULONG NumberPages,
  795. IN MEMORY_CACHING_TYPE CacheType
  796. );
  797. PVOID
  798. HalpMapPhysicalMemory64(
  799. IN PHYSICAL_ADDRESS PhysicalAddress,
  800. IN ULONG NumberPages
  801. );
  802. VOID
  803. HalpUnmapVirtualAddress(
  804. IN PVOID VirtualAddress,
  805. IN ULONG NumberPages
  806. );
  807. BOOLEAN
  808. HalpVirtualToPhysical(
  809. IN ULONG_PTR VirtualAddress,
  810. OUT PPHYSICAL_ADDRESS PhysicalAddress
  811. );
  812. PVOID
  813. HalpMapPhysicalMemoryWriteThrough(
  814. IN PVOID PhysicalAddress,
  815. IN ULONG NumberPages
  816. );
  817. PVOID
  818. HalpAllocPhysicalMemory(
  819. IN PLOADER_PARAMETER_BLOCK LoaderBlock,
  820. IN ULONG_PTR MaxPhysicalAddress,
  821. IN ULONG NoPages,
  822. IN BOOLEAN bAlignOn64k
  823. );
  824. VOID
  825. HalpBiosDisplayReset(
  826. IN VOID
  827. );
  828. HAL_DISPLAY_BIOS_INFORMATION
  829. HalpGetDisplayBiosInformation (
  830. VOID
  831. );
  832. VOID
  833. HalpInitializeCmos (
  834. VOID
  835. );
  836. VOID
  837. HalpReadCmosTime (
  838. PTIME_FIELDS TimeFields
  839. );
  840. VOID
  841. HalpWriteCmosTime (
  842. PTIME_FIELDS TimeFields
  843. );
  844. VOID
  845. HalpAcquireCmosSpinLock (
  846. VOID
  847. );
  848. VOID
  849. HalpReleaseCmosSpinLock (
  850. VOID
  851. );
  852. VOID
  853. HalpResetAllProcessors (
  854. VOID
  855. );
  856. VOID
  857. HalpCpuID (
  858. ULONG InEax,
  859. PULONG OutEax,
  860. PULONG OutEbx,
  861. PULONG OutEcx,
  862. PULONG OutEdx
  863. );
  864. VOID
  865. HalpYieldProcessor (
  866. VOID
  867. );
  868. ULONGLONG
  869. FASTCALL
  870. RDMSR (
  871. IN ULONG MsrAddress
  872. );
  873. VOID
  874. WRMSR (
  875. IN ULONG MsrAddress,
  876. IN ULONGLONG MsrValue
  877. );
  878. VOID
  879. HalpRegisterVector (
  880. IN UCHAR ReportFlags,
  881. IN ULONG BusInterruptVector,
  882. IN ULONG SystemInterruptVector,
  883. IN KIRQL SystemIrql
  884. );
  885. VOID
  886. HalpReportResourceUsage (
  887. IN PUNICODE_STRING HalName,
  888. IN INTERFACE_TYPE DeviceInterfaceToUse
  889. );
  890. VOID
  891. HalpYearIs(
  892. IN ULONG Year
  893. );
  894. VOID
  895. HalpRecordEisaInterruptVectors(
  896. VOID
  897. );
  898. VOID
  899. HalpMcaCurrentProcessorSetConfig(
  900. VOID
  901. );
  902. NTSTATUS
  903. HalpGetNextProcessorApicId(
  904. IN ULONG ProcessorNumber,
  905. IN OUT UCHAR *ApicId
  906. );
  907. //
  908. // Defines for HalpFeatureBits
  909. //
  910. typedef enum _HALP_FEATURE {
  911. HAL_PERF_EVENTS = 0x00000001,
  912. HAL_NO_SPECULATION = 0x00000002,
  913. HAL_MCA_PRESENT = 0x00000004,
  914. HAL_CMC_PRESENT = 0x00000008,
  915. HAL_CPE_PRESENT = 0x00000010,
  916. HAL_MCE_OEMDRIVERS_ENABLED = 0x00000020,
  917. HAL_MCE_PROCNUMBER = 0x01000000,
  918. HALP_FEATURE_INIT = (HAL_MCA_PRESENT|HAL_MCE_PROCNUMBER)
  919. } HALP_FEATURE;
  920. extern ULONG HalpFeatureBits;
  921. //
  922. // Added HalpPciIrqMask
  923. //
  924. extern USHORT HalpPciIrqMask;
  925. //
  926. // Defines for Processor Features returned from CPUID instruction
  927. //
  928. #define CPUID_MCA_MASK 0x4000
  929. #define CPUID_MCE_MASK 0x0080
  930. #define CPUID_VME_MASK 0x0002
  931. //
  932. // Added ITIR bit field masks
  933. //
  934. #define ITIR_PPN_MASK 0x7FFF000000000000
  935. #define IoSpaceSize 0x14
  936. #define Attribute_PPN_Mask 0x0000FFFFFFFFF000
  937. #define IoSpaceAttribute 0x0010000000000473
  938. //
  939. // IA64 ERROR Apis
  940. //
  941. #define HALP_KERNEL_TOKEN 0x4259364117
  942. NTSTATUS
  943. HalpGetMceInformation(
  944. IN PHAL_ERROR_INFO ErrorInfo,
  945. OUT PULONG ErrorInfoLength
  946. );
  947. NTSTATUS
  948. HalpMceRegisterKernelDriver(
  949. IN PKERNEL_ERROR_HANDLER_INFO KernelErrorHandler,
  950. IN ULONG InfoSize
  951. );
  952. typedef struct _HALP_MCELOGS_STATS *PHALP_MCELOGS_STATS; // forward declaration.
  953. NTSTATUS
  954. HalpGetFwMceLog(
  955. IN ULONG MceType,
  956. IN PERROR_RECORD_HEADER Record,
  957. IN PHALP_MCELOGS_STATS MceLogsStats,
  958. IN BOOLEAN DoClearLog
  959. );
  960. //
  961. // IA64 Machine Check Error Logs:
  962. // WMI requires processor LID being stored in the Log.
  963. // This LID corresponds to the processor on which the SAL_PROC was executed on.
  964. //
  965. // TEMPTEMP: Implementation is temporary, until we implement HAL SW Error Section.
  966. // It currently used the LID value stored in HalReserved[PROCESSOR_ID_INDEX]
  967. // at processor initialization.
  968. // Note that the current FW builds do not update the _ERROR_PROCESSOR.CRLid field,
  969. // assuming there is a _ERROR_PROCESSOR section in the record.
  970. //
  971. // This function should be in sync with the mce.h function GetFwMceLogProcessorNumber().
  972. //
  973. __inline
  974. VOID
  975. HalpSetFwMceLogProcessorNumber(
  976. PERROR_RECORD_HEADER Log
  977. )
  978. {
  979. USHORT lid = (USHORT)(PCR->HalReserved[PROCESSOR_ID_INDEX]);
  980. PERROR_SECTION_HEADER section = (PERROR_SECTION_HEADER)((ULONG64)Log + sizeof(*Log));
  981. Log->TimeStamp.Reserved = (UCHAR)((lid >> 8) & 0xff);
  982. section->Reserved = (UCHAR)(lid & 0xff);
  983. } // HalpSetFwMceLogProcessorNumber()
  984. #define HalpGetFwMceLogProcessorNumber( /* PERROR_RECORD_HEADER */ _Log ) \
  985. GetFwMceLogProcessorNumber( (_Log) )
  986. #define HALP_FWMCE_DO_CLEAR_LOG (TRUE)
  987. #define HALP_FWMCE_DONOT_CLEAR_LOG (FALSE)
  988. #define HALP_MCA_STATEDUMP_SIZE (1024 * sizeof(ULONGLONG)) // 8KB
  989. #define HALP_MCA_BACKSTORE_SIZE (4 * 1024 * sizeof(ULONGLONG)) // 32KB
  990. #define HALP_MCA_STACK_SIZE (4 * 1024 * sizeof(ULONGLONG)) // 32KB
  991. #define HALP_INIT_STATEDUMP_SIZE (1024 * sizeof(ULONGLONG)) // 8KB
  992. #define HALP_INIT_BACKSTORE_SIZE (4 * 1024 * sizeof(ULONGLONG)) // 32KB
  993. #define HALP_INIT_STACK_SIZE (4 * 1024 * sizeof(ULONGLONG)) // 32KB
  994. BOOLEAN
  995. HalpAllocateMceStacks(
  996. IN ULONG Number
  997. );
  998. BOOLEAN
  999. HalpPreAllocateMceRecords(
  1000. IN ULONG Number
  1001. );
  1002. //
  1003. // IA64 MCA Apis
  1004. //
  1005. VOID
  1006. HalpMCAEnable (
  1007. VOID
  1008. );
  1009. NTSTATUS
  1010. HalpGetMcaLog(
  1011. OUT PMCA_EXCEPTION Buffer,
  1012. IN ULONG BufferSize,
  1013. OUT PULONG ReturnedLength
  1014. );
  1015. NTSTATUS
  1016. HalpSetMcaLog(
  1017. IN PMCA_EXCEPTION Buffer,
  1018. IN ULONG BufferSize
  1019. );
  1020. NTSTATUS
  1021. HalpMcaRegisterDriver(
  1022. IN PMCA_DRIVER_INFO pMcaDriverInfo // Info about registering driver
  1023. );
  1024. VOID
  1025. HalpMcaInit(
  1026. VOID
  1027. );
  1028. VOID
  1029. HalpMCADisable(
  1030. VOID
  1031. );
  1032. //
  1033. // MCA (but non-OS_MCA related) KeBugCheckEx wrapper:
  1034. //
  1035. #define HalpMcaKeBugCheckEx( _McaBugCheckType, _McaLog, _McaAllocatedLogSize, _Arg4 ) \
  1036. KeBugCheckEx( MACHINE_CHECK_EXCEPTION, (ULONG_PTR)(_McaBugCheckType), \
  1037. (ULONG_PTR)(_McaLog), \
  1038. (ULONG_PTR)(_McaAllocatedLogSize), \
  1039. (ULONG_PTR)(_Arg4) )
  1040. //
  1041. // IA64 Default number of MCA Error Records which size is SAL_GET_STATE_INFO_SIZE.MCA
  1042. //
  1043. // Really the size is rounded up to a multiple of the page size.
  1044. //
  1045. #define HALP_DEFAULT_PROCESSOR_MCA_RECORDS 1
  1046. //
  1047. // IA64 Default number of INIT Event Records which size is SAL_GET_STATE_INFO_SIZE.INIT
  1048. //
  1049. // Really the size is rounded up to a multiple of the page size.
  1050. //
  1051. #define HALP_DEFAULT_PROCESSOR_INIT_RECORDS 1
  1052. //
  1053. // IA64 CMC Apis related to:
  1054. //
  1055. // - Processor
  1056. // - Platform
  1057. //
  1058. NTSTATUS
  1059. HalpGetCmcLog(
  1060. OUT PCMC_EXCEPTION Buffer,
  1061. IN ULONG BufferSize,
  1062. OUT PULONG ReturnedLength
  1063. );
  1064. NTSTATUS
  1065. HalpSetCmcLog(
  1066. IN PCMC_EXCEPTION Buffer,
  1067. IN ULONG BufferSize
  1068. );
  1069. NTSTATUS
  1070. HalpCmcRegisterDriver(
  1071. IN PCMC_DRIVER_INFO pCmcDriverInfo // Info about registering driver
  1072. );
  1073. NTSTATUS
  1074. HalpGetCpeLog(
  1075. OUT PCPE_EXCEPTION Buffer,
  1076. IN ULONG BufferSize,
  1077. OUT PULONG ReturnedLength
  1078. );
  1079. NTSTATUS
  1080. HalpSetCpeLog(
  1081. IN PCPE_EXCEPTION Buffer,
  1082. IN ULONG BufferSize
  1083. );
  1084. NTSTATUS
  1085. HalpCpeRegisterDriver(
  1086. IN PCPE_DRIVER_INFO pCmcDriverInfo // Info about registering driver
  1087. );
  1088. #define HalpWriteCMCVector( Value ) __setReg(CV_IA64_SaCMCV, Value)
  1089. ULONG_PTR
  1090. HalpSetCMCVector(
  1091. IN ULONG_PTR CmcVector
  1092. );
  1093. //
  1094. // IA64 generic MCE Definitions.
  1095. //
  1096. #define HALP_MCELOGS_MAXCOUNT 50L
  1097. typedef struct _HALP_MCELOGS_STATS { // The following counts are for the entire boot session.
  1098. ULONG MaxLogSize; // Maximum size of the information logged by SAL.
  1099. LONG Count1; // Event type specific Counter.
  1100. LONG Count2; // Event type specific Counter.
  1101. LONG KernelDeliveryFails; // Number of Kernel callback failures.
  1102. LONG DriverDpcQueueFails; // Number of OEM CMC Driver Dpc queueing failures.
  1103. ULONG PollingInterval; // Polling interval in seconds. Only used for CPE.
  1104. ULONG GetStateFails; // Number of failures in getting the log from FW.
  1105. ULONG ClearStateFails; // Number of failures in clearing the log from FW.
  1106. ULONGLONG LogId; // Last record identifier.
  1107. } HALP_MCELOGS_STATS, *PHALP_MCELOGS_STATS;
  1108. //
  1109. // MC Event Type specific definition for HALP_MCELOGS_STATS.Count*
  1110. //
  1111. #define CmcInterruptCount Count1 // CMC interrupts count.
  1112. #define CpeInterruptCount Count1 // CMC interrupts count.
  1113. #define McaPreviousCount Count1 // MCA previous events counter.
  1114. #define McaCorrectedCount Count2 // MCA corrected events counter.
  1115. typedef struct _HALP_MCELOGS_HEADER {
  1116. ULONG Count; // Current number of saved logs.
  1117. ULONG MaxCount; // Maximum number of saved logs.
  1118. ULONG Overflow; // Number of overflows
  1119. ULONG Tag; // Pool allocation tag.
  1120. ULONG AllocateFails; // Number of failed allocations.
  1121. ULONG Padding;
  1122. SINGLE_LIST_ENTRY Logs; // List header of saved logs.
  1123. } HALP_MCELOGS_HEADER, *PHALP_MCELOGS_HEADER;
  1124. #define HalpMceLogFromListEntry( _ListEntry ) \
  1125. ((PERROR_RECORD_HEADER)((ULONG_PTR)(_ListEntry) + sizeof(SINGLE_LIST_ENTRY)))
  1126. //
  1127. // IA64 MCA Info Structure
  1128. //
  1129. // to keep track of MCA features available on installed hardware
  1130. //
  1131. //
  1132. typedef struct _HALP_MCA_INFO {
  1133. FAST_MUTEX Mutex; // non-recursive Mutex for low irql ops.
  1134. HALP_MCELOGS_STATS Stats; // Information about log collection and interrupts.
  1135. PVOID KernelToken; // Kernel identification.
  1136. LONG DpcNotification; // Notify kernel or driver at Dispatch level.
  1137. LONG NoBugCheck; // Flag to disable bugcheck calls under OS_MCA.
  1138. KERNEL_MCA_DELIVERY KernelDelivery; // Kernel-WMI registered notification.
  1139. HALP_MCELOGS_HEADER KernelLogs; // Saved logs for Kernel queries.
  1140. MCA_DRIVER_INFO DriverInfo; // Info about registered OEM MCA driver
  1141. KDPC DriverDpc; // DPC object for MCA
  1142. HALP_MCELOGS_HEADER DriverLogs; // Saved logs for OEM MCA driver.
  1143. } HALP_MCA_INFO, *PHALP_MCA_INFO;
  1144. extern HALP_MCA_INFO HalpMcaInfo;
  1145. #define HalpInitializeMcaMutex() ExInitializeFastMutex( &HalpMcaInfo.Mutex )
  1146. #define HalpInitializeMcaInfo() \
  1147. { \
  1148. HalpInitializeMcaMutex(); \
  1149. HalpMcaInfo.KernelLogs.Tag = 'KacM'; \
  1150. HalpMcaInfo.KernelLogs.Logs.Next = NULL; \
  1151. HalpMcaInfo.DriverLogs.Tag = 'DacM'; \
  1152. HalpMcaInfo.DriverLogs.Logs.Next = NULL; \
  1153. }
  1154. #define HalpAcquireMcaMutex() ExAcquireFastMutex( &HalpMcaInfo.Mutex )
  1155. #define HalpReleaseMcaMutex() ExReleaseFastMutex( &HalpMcaInfo.Mutex )
  1156. __inline
  1157. ULONG
  1158. HalpGetMaxMcaLogSizeProtected(
  1159. VOID
  1160. )
  1161. {
  1162. ULONG maxSize;
  1163. HalpAcquireMcaMutex();
  1164. maxSize = HalpMcaInfo.Stats.MaxLogSize;
  1165. HalpReleaseMcaMutex();
  1166. return( maxSize );
  1167. } // HalpGetMaxMcaLogSizeProtected()
  1168. //
  1169. // IA64 HAL private MCE definitions.
  1170. //
  1171. // Note on current implementation: we use the MCA_INFO.Mutex.
  1172. //
  1173. #define HalpInitializeMceMutex()
  1174. #define HalpAcquireMceMutex() ExAcquireFastMutex( &HalpMcaInfo.Mutex )
  1175. #define HalpReleaseMceMutex() ExReleaseFastMutex( &HalpMcaInfo.Mutex )
  1176. extern KERNEL_MCE_DELIVERY HalpMceKernelDelivery;
  1177. //
  1178. // HalpMceDeliveryArgument1( )
  1179. //
  1180. // Note that the low 32 bits are only used for now...
  1181. //
  1182. #define HalpMceDeliveryArgument1( _MceOperation, _MceEventType ) \
  1183. ((PVOID)(ULONG_PTR) ((((_MceOperation) & KERNEL_MCE_OPERATION_MASK) << KERNEL_MCE_OPERATION_SHIFT) | ((_MceEventType) & KERNEL_MCE_EVENTTYPE_MASK) ) )
  1184. //
  1185. // IA64 INIT Info Structure
  1186. //
  1187. // to keep track of INIT features available on installed hardware
  1188. //
  1189. typedef struct _HALP_INIT_INFO {
  1190. FAST_MUTEX Mutex;
  1191. ULONG MaxLogSize; // Maximum size of the information logged by SAL.
  1192. } HALP_INIT_INFO, *PHALP_INIT_INFO;
  1193. extern HALP_INIT_INFO HalpInitInfo;
  1194. #define HalpInitializeInitMutex() ExInitializeFastMutex( &HalpInitInfo.Mutex )
  1195. #define HalpAcquireInitMutex() ExAcquireFastMutex( &HalpInitInfo.Mutex )
  1196. #define HalpReleaseInitMutex() ExReleaseFastMutex( &HalpInitInfo.Mutex )
  1197. __inline
  1198. ULONG
  1199. HalpGetMaxInitLogSizeProtected(
  1200. VOID
  1201. )
  1202. {
  1203. ULONG maxSize;
  1204. HalpAcquireInitMutex();
  1205. maxSize = HalpInitInfo.MaxLogSize;
  1206. HalpReleaseInitMutex();
  1207. return( maxSize );
  1208. } // HalpGetMaxInitLogSizeProtected()
  1209. //
  1210. // IA64 CMC
  1211. //
  1212. //
  1213. // HALP_CMC_DEFAULT_POLLING_INTERVAL
  1214. // HALP_CMC_MINIMUM_POLLING_INTERVAL
  1215. //
  1216. // If these should be exposed to WMI or OEM CMC driver, we will expose them in ntos\inc\hal.h
  1217. //
  1218. #define HALP_CMC_DEFAULT_POLLING_INTERVAL ((ULONG)60)
  1219. #define HALP_CMC_MINIMUM_POLLING_INTERVAL ((ULONG)15)
  1220. //
  1221. // IA64 CMC Info Structure
  1222. //
  1223. // to keep track of CMC features available on installed hardware
  1224. //
  1225. // Implementation Notes - Thierry 09/15/2000.
  1226. //
  1227. // - HAL_CMC_INFO and HAL_CPE_INFO have identical definitions at this time.
  1228. // The merging of the code and data definitions was considered and even implemented.
  1229. // However, because of the lack of testing with these FW/SAL features, I decided to
  1230. // keep them separate. After further testing of the IA64 CMC/CPE features, we might
  1231. // decide to merge them or not...
  1232. //
  1233. // MP notes 08/2000:
  1234. //
  1235. // HALP_CMC_INFO.HalpCmcInfo
  1236. // - only one static instance of this structure.
  1237. // - HAL global variable.
  1238. //
  1239. // HAL_CMC_INFO.Mutex
  1240. // - Initialized by HalpInitializeOSMCA() on BSP.
  1241. // - Used to synchronize accesses to structure members accessed at passive level operations.
  1242. //
  1243. // HAL_CMC_INFO.Stats.MaxLogSize
  1244. // - is updated by HalpInitializeOSMCA() on BSP. Not modified later.
  1245. // - does not require any MP protection for further read accesses.
  1246. //
  1247. // HAL_CMC_INFO.Stats.InterruptsCount
  1248. // - Incremented with interlock at CMCI_LEVEL.
  1249. // - Read at passive level. Approximation is fine.
  1250. //
  1251. // HAL_CMC_INFO.Stats.KernelDeliveryFails
  1252. // - Incremented with interlock at CMCI_LEVEL.
  1253. // - Read at passive level. Approximation is fine.
  1254. //
  1255. // HAL_CMC_INFO.Stats.KernelDeliveryFails
  1256. // - Increment with interlock at CMCI_LEVEL.
  1257. // - Read at passive level. Approximation is fine.
  1258. //
  1259. // HAL_CMC_INFO.Stats.GetStateFails
  1260. // - Incremented at passive level under CMC Mutex protection.
  1261. // - Read at passive level with CMC Mutex protection.
  1262. //
  1263. // HAL_CMC_INFO.Stats.ClearStateFails
  1264. // - Incremented at passive level under CMC Mutex protection.
  1265. // - Read at passive level with CMC Mutex protection.
  1266. //
  1267. // HAL_CMC_INFO.Stats.LogId
  1268. // - Updated at passive level under CMC Mutex protection.
  1269. // - Read at passive level with CMC Mutex protection.
  1270. //
  1271. // HAL_CMC_INFO.KernelToken
  1272. // - is updated by HalpInitializeOSMCA() on BSP. Not modified later.
  1273. // - does not require any MP protection for further read accesses.
  1274. //
  1275. // HAL_CMC_INFO.KernelDelivery
  1276. // - is updated by HalpMceRegisterKernelDriver() under CMC Mutex protection.
  1277. // FIXFIX - 09/21/2000 - This initialization has a small window of where a CMC interrupt
  1278. // could occur and the memory change is not committed. ToBeFixed.
  1279. // - Loaded as CMCI_LEVEL and branched to.
  1280. // - Read at passive level as a flag under CMC Mutex protection.
  1281. //
  1282. // HAL_CMC_INFO.KernelLogs
  1283. // - This entire structure is initialized and updated at passive level under CMC Mutex
  1284. // protection with the exception of KernelLogs.Tag initialized by HalpInitializeCmcInfo(),
  1285. // called by HalpMcaInit(). HalpMcaInit() is called at end of phase 1 with Phase1 thread
  1286. // and is executed *before* any HalpGetMceLog() calls could be done.
  1287. //
  1288. // HAL_CMC_INFO.DriverInfo
  1289. // HAL_CMC_INFO.Dpc
  1290. // - is updated by HalpCmcRegisterlDriver() under CMC Mutex protection.
  1291. // FIXFIX - 09/21/2000 - This initialization has a small window of where a CMC interrupt
  1292. // could occur and the memory change is not committed. ToBeFixed.
  1293. // - Loaded as CMCI_LEVEL and branched to.
  1294. // - Read at passive level as a flag under CMC Mutex protection.
  1295. //
  1296. // HAL_CMC_INFO.DriverLogs
  1297. // - This entire structure is initialized and updated at passive level under CMC Mutex
  1298. // protection with the exception of KernelLogs.Tag initialized by HalpInitializeCmcInfo(),
  1299. // called by HalpMcaInit(). HalpMcaInit() is called at end of phase 1 with Phase1 thread
  1300. // and is executed *before* any HalpGetMceLog() calls could be done.
  1301. //
  1302. typedef struct _HALP_CMC_INFO {
  1303. FAST_MUTEX Mutex; // non-recursive Mutex for low irql operations.
  1304. HALP_MCELOGS_STATS Stats; // Information about log collection and interrupts.
  1305. PVOID KernelToken; // Kernel identification.
  1306. KERNEL_CMC_DELIVERY KernelDelivery; // Kernel callback called at CMCI_LEVEL.
  1307. HALP_MCELOGS_HEADER KernelLogs; // Saved logs for Kernel queries.
  1308. CMC_DRIVER_INFO DriverInfo; // Info about OEM CMC registered driver
  1309. KDPC DriverDpc; // DPC object for OEM CMC driver.
  1310. HALP_MCELOGS_HEADER DriverLogs; // Saved logs for OEM CMC driver.
  1311. } HALP_CMC_INFO, *PHALP_CMC_INFO;
  1312. extern HALP_CMC_INFO HalpCmcInfo;
  1313. #define HalpInitializeCmcMutex() ExInitializeFastMutex( &HalpCmcInfo.Mutex )
  1314. #define HalpInitializeCmcInfo() \
  1315. { \
  1316. HalpInitializeCmcMutex(); \
  1317. HalpCmcInfo.KernelLogs.Tag = 'KcmC'; \
  1318. HalpCmcInfo.KernelLogs.Logs.Next = NULL; \
  1319. HalpCmcInfo.DriverLogs.Tag = 'DcmC'; \
  1320. HalpCmcInfo.DriverLogs.Logs.Next = NULL; \
  1321. }
  1322. #define HalpAcquireCmcMutex() ExAcquireFastMutex( &HalpCmcInfo.Mutex )
  1323. #define HalpReleaseCmcMutex() ExReleaseFastMutex( &HalpCmcInfo.Mutex )
  1324. //
  1325. // IA64 CPE
  1326. //
  1327. //
  1328. // HALP_CPE_DEFAULT_POLLING_INTERVAL
  1329. // HALP_CPE_MINIMUM_POLLING_INTERVAL
  1330. //
  1331. // If these should be exposed to WMI or OEM CPE driver, we will expose them in ntos\inc\hal.h
  1332. //
  1333. #define HALP_CPE_DEFAULT_POLLING_INTERVAL ((ULONG)60)
  1334. #define HALP_CPE_MINIMUM_POLLING_INTERVAL ((ULONG)15)
  1335. //
  1336. // HALP_CPE_MAX_INTERRUPT_SOURCES defines the size of SAPIC CPE related data structures.
  1337. //
  1338. // TEMPORARY - The CPE Interrupt model based data structures should be allocated while
  1339. // passing through the ACPI platform interrupt source entries.
  1340. // This will eliminate this static limitation in the number of CPEs.
  1341. //
  1342. #define HALP_CPE_MAX_INTERRUPT_SOURCES 16
  1343. //
  1344. // IA64 CPE Info Structure
  1345. //
  1346. // to keep track of CPE features available on installed hardware
  1347. //
  1348. // Implementation Notes - Thierry 09/15/2000.
  1349. //
  1350. // - HAL_CMC_INFO and HAL_CPE_INFO have identical definitions at this time.
  1351. // The merging of the code and data definitions was considered and even implemented.
  1352. // However, because of the lack of testing with these FW/SAL features, I decided to
  1353. // keep them separate. After further testing of the IA64 CMC/CPE features, we might
  1354. // decide to merge them or not...
  1355. //
  1356. // MP notes 08/2000:
  1357. //
  1358. // As specified above, the MP notes are similar to the HALP_CMC_INFO structure MP notes.
  1359. // With the exception of:
  1360. //
  1361. // HAL_CPE_INFO.Stats.PollingInterval
  1362. // - is updated by HalpCPEEnable() on BSP. Not modified later.
  1363. // - does not require any MP protection for further read accesses.
  1364. //
  1365. typedef struct _HALP_CPE_INFO {
  1366. FAST_MUTEX Mutex; // non-recursive Mutex for low irql operations.
  1367. HALP_MCELOGS_STATS Stats; // Information about log collection and interrupts.
  1368. PVOID KernelToken; // Kernel identification.
  1369. KERNEL_CPE_DELIVERY KernelDelivery; // Kernel callback called at CPEI_LEVEL.
  1370. HALP_MCELOGS_HEADER KernelLogs; // Saved logs for Kernel queries.
  1371. CPE_DRIVER_INFO DriverInfo; // Info about OEM CPE registered driver
  1372. KDPC DriverDpc; // DPC object for OEM CPE driver.
  1373. HALP_MCELOGS_HEADER DriverLogs; // Saved logs for OEM CPE driver.
  1374. } HALP_CPE_INFO, *PHALP_CPE_INFO;
  1375. extern HALP_CPE_INFO HalpCpeInfo;
  1376. #define HalpInitializeCpeMutex() ExInitializeFastMutex( &HalpCpeInfo.Mutex )
  1377. #define HalpInitializeCpeInfo() \
  1378. { \
  1379. HalpInitializeCpeMutex(); \
  1380. HalpCpeInfo.KernelLogs.Tag = 'KepC'; \
  1381. HalpCpeInfo.KernelLogs.Logs.Next = NULL; \
  1382. HalpCpeInfo.DriverLogs.Tag = 'DepC'; \
  1383. HalpCpeInfo.DriverLogs.Logs.Next = NULL; \
  1384. }
  1385. #define HalpAcquireCpeMutex() ExAcquireFastMutex( &HalpCpeInfo.Mutex )
  1386. #define HalpReleaseCpeMutex() ExReleaseFastMutex( &HalpCpeInfo.Mutex )
  1387. __inline
  1388. ULONG
  1389. HalpGetMaxCpeLogSizeProtected(
  1390. VOID
  1391. )
  1392. {
  1393. ULONG maxSize;
  1394. HalpAcquireCpeMutex();
  1395. maxSize = HalpCpeInfo.Stats.MaxLogSize;
  1396. HalpReleaseCpeMutex();
  1397. return( maxSize );
  1398. } // HalpGetMaxCpeLogSizeProtected()
  1399. __inline
  1400. ULONG
  1401. HalpGetMaxCpeLogSizeAndPollingIntervalProtected(
  1402. PULONG PollingInterval
  1403. )
  1404. {
  1405. ULONG maxSize;
  1406. HalpAcquireCpeMutex();
  1407. maxSize = HalpCpeInfo.Stats.MaxLogSize;
  1408. *PollingInterval = HalpCpeInfo.Stats.PollingInterval;
  1409. HalpReleaseCpeMutex();
  1410. return( maxSize );
  1411. } // HalpGetMaxCpeLogSizeAndPollingIntervalProtected()
  1412. //
  1413. // IA64 SAL_MC_SET_PARAMS.time_out default value.
  1414. //
  1415. #define HALP_DEFAULT_MC_RENDEZ_TIMEOUT 1000
  1416. //
  1417. // IA64 bugcheck MACHINE_CHECK_EXCEPTION parameters
  1418. //
  1419. // arg0: MACHINE_EXCEPTION
  1420. // arg1: HAL_BUGCHECK_MCE_TYPE
  1421. // arg2: mcaLog
  1422. // arg3: mcaAllocatedLogSize
  1423. // arg4: salStatus
  1424. //
  1425. typedef enum _HAL_BUGCHECK_MCE_TYPE {
  1426. HAL_BUGCHECK_MCA_ASSERT = 1,
  1427. HAL_BUGCHECK_MCA_GET_STATEINFO = 2,
  1428. HAL_BUGCHECK_MCA_CLEAR_STATEINFO = 3,
  1429. HAL_BUGCHECK_MCA_FATAL = 4,
  1430. HAL_BUGCHECK_MCA_MAX = 10,
  1431. HAL_BUGCHECK_INIT_ASSERT = 11,
  1432. HAL_BUGCHECK_INIT_GET_STATEINFO = 12,
  1433. HAL_BUGCHECK_INIT_CLEAR_STATEINFO = 13,
  1434. HAL_BUGCHECK_INIT_FATAL = 14,
  1435. HAL_BUGCHECK_INIT_MAX = 20,
  1436. } HAL_BUGCHECK_MCE_TYPE;
  1437. //
  1438. // PnP stuff
  1439. //
  1440. #define HAL_BUS_INTERFACE_STD_VERSION 1
  1441. #define HAL_IRQ_TRANSLATOR_VERSION 0
  1442. #define HAL_MEMIO_TRANSLATOR_VERSION 1
  1443. #define HAL_PORT_RANGE_INTERFACE_VERSION 0
  1444. VOID
  1445. HalTranslatorReference(
  1446. PVOID Context
  1447. );
  1448. VOID
  1449. HalTranslatorDereference(
  1450. PVOID Context
  1451. );
  1452. NTSTATUS
  1453. HalIrqTranslateResources(
  1454. IN PVOID Context,
  1455. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  1456. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  1457. IN ULONG AlternativesCount, OPTIONAL
  1458. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  1459. IN PDEVICE_OBJECT PhysicalDeviceObject,
  1460. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  1461. );
  1462. NTSTATUS
  1463. HalIrqTranslateResourcesRoot(
  1464. IN PVOID Context,
  1465. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  1466. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  1467. IN ULONG AlternativesCount, OPTIONAL
  1468. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  1469. IN PDEVICE_OBJECT PhysicalDeviceObject,
  1470. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  1471. );
  1472. NTSTATUS
  1473. HalIrqTranslateResourceRequirementsRoot(
  1474. IN PVOID Context,
  1475. IN PIO_RESOURCE_DESCRIPTOR Source,
  1476. IN PDEVICE_OBJECT PhysicalDeviceObject,
  1477. OUT PULONG TargetCount,
  1478. OUT PIO_RESOURCE_DESCRIPTOR *Target
  1479. );
  1480. NTSTATUS
  1481. HalIrqTranslateResourceRequirementsIsa(
  1482. IN PVOID Context,
  1483. IN PIO_RESOURCE_DESCRIPTOR Source,
  1484. IN PDEVICE_OBJECT PhysicalDeviceObject,
  1485. OUT PULONG TargetCount,
  1486. OUT PIO_RESOURCE_DESCRIPTOR *Target
  1487. );
  1488. NTSTATUS
  1489. HalIrqTranslateResourcesIsa(
  1490. IN PVOID Context,
  1491. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  1492. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  1493. IN ULONG AlternativesCount, OPTIONAL
  1494. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  1495. IN PDEVICE_OBJECT PhysicalDeviceObject,
  1496. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  1497. );
  1498. NTSTATUS
  1499. HalpTransMemIoResourceRequirement(
  1500. IN PVOID Context,
  1501. IN PIO_RESOURCE_DESCRIPTOR Source,
  1502. IN PDEVICE_OBJECT PhysicalDeviceObject,
  1503. OUT PULONG TargetCount,
  1504. OUT PIO_RESOURCE_DESCRIPTOR *Target
  1505. );
  1506. NTSTATUS
  1507. HalpTransMemIoResource(
  1508. IN PVOID Context,
  1509. IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
  1510. IN RESOURCE_TRANSLATION_DIRECTION Direction,
  1511. IN ULONG AlternativesCount, OPTIONAL
  1512. IN IO_RESOURCE_DESCRIPTOR Alternatives[], OPTIONAL
  1513. IN PDEVICE_OBJECT PhysicalDeviceObject,
  1514. OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target
  1515. );
  1516. ULONG
  1517. HalpGetIsaIrqState(
  1518. ULONG Vector
  1519. );
  1520. //
  1521. // HAL port range services.
  1522. //
  1523. NTSTATUS
  1524. HalpQueryAllocatePortRange(
  1525. IN BOOLEAN IsSparse,
  1526. IN BOOLEAN PrimaryIsMmio,
  1527. IN PVOID VirtBaseAddr OPTIONAL,
  1528. IN PHYSICAL_ADDRESS PhysBaseAddr, // Only valid if PrimaryIsMmio = TRUE
  1529. IN ULONG Length, // Only valid if PrimaryIsMmio = TRUE
  1530. OUT PUSHORT NewRangeId
  1531. );
  1532. VOID
  1533. HalpFreePortRange(
  1534. IN USHORT RangeId
  1535. );
  1536. //
  1537. // Definition for IA64 HalpVectorToINTI
  1538. //
  1539. #define VECTOR 0xFF;
  1540. #define LEVEL 32;
  1541. extern ULONG HalpVectorToINTI[];
  1542. extern UCHAR HalpVectorToIRQL[];
  1543. VOID
  1544. HalpEnableNMI (
  1545. VOID
  1546. );
  1547. ULONG
  1548. HalpInti2BusInterruptLevel(
  1549. ULONG Inti
  1550. );
  1551. ULONG
  1552. HalpINTItoVector(
  1553. ULONG Inti
  1554. );
  1555. VOID
  1556. HalpSetINTItoVector(
  1557. ULONG Inti,
  1558. ULONG Vector
  1559. );
  1560. VOID
  1561. HalpSetRedirEntry (
  1562. IN ULONG InterruptInput,
  1563. IN ULONG Entry,
  1564. IN USHORT ThisCpuApicID
  1565. );
  1566. VOID
  1567. HalpGetRedirEntry (
  1568. IN ULONG InterruptInput,
  1569. IN PULONG Entry,
  1570. IN PULONG Destination
  1571. );
  1572. VOID
  1573. HalpDisableRedirEntry(
  1574. IN ULONG InterruptInput
  1575. );
  1576. //
  1577. // Definition for IA64 complete
  1578. //
  1579. //
  1580. // ACPI specific stuff
  1581. //
  1582. //
  1583. // from detect\i386\acpibios.h
  1584. //
  1585. typedef struct _ACPI_BIOS_INSTALLATION_CHECK {
  1586. UCHAR Signature[8]; // "RSD PTR" (ascii)
  1587. UCHAR Checksum;
  1588. UCHAR OemId[6]; // An OEM-supplied string
  1589. UCHAR reserved; // must be 0
  1590. ULONG RsdtAddress; // 32-bit physical address of RSDT
  1591. } ACPI_BIOS_INSTALLATION_CHECK, *PACPI_BIOS_INSTALLATION_CHECK;
  1592. NTSTATUS
  1593. HalpAcpiFindRsdtPhase0(
  1594. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  1595. );
  1596. NTSTATUS
  1597. HalpSetupAcpiPhase0(
  1598. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  1599. );
  1600. ULONG
  1601. HalpAcpiNumProcessors(
  1602. VOID
  1603. );
  1604. VOID
  1605. HaliHaltSystem(
  1606. VOID
  1607. );
  1608. VOID
  1609. HalpCheckPowerButton(
  1610. VOID
  1611. );
  1612. NTSTATUS
  1613. HalpRegisterHibernate(
  1614. VOID
  1615. );
  1616. VOID
  1617. HalpSleepS5(
  1618. VOID
  1619. );
  1620. VOID
  1621. HalProcessorThrottle (
  1622. IN UCHAR Throttle
  1623. );
  1624. VOID
  1625. HalpSaveDmaControllerState(
  1626. VOID
  1627. );
  1628. VOID
  1629. HalpSaveTimerState(
  1630. VOID
  1631. );
  1632. VOID
  1633. HalpSetAcpiEdgeLevelRegister(
  1634. VOID
  1635. );
  1636. VOID
  1637. HalpRestoreDmaControllerState(
  1638. VOID
  1639. );
  1640. VOID
  1641. HalpRestoreTimerState(
  1642. VOID
  1643. );
  1644. NTSTATUS
  1645. HalacpiGetInterruptTranslator(
  1646. IN INTERFACE_TYPE ParentInterfaceType,
  1647. IN ULONG ParentBusNumber,
  1648. IN INTERFACE_TYPE BridgeInterfaceType,
  1649. IN USHORT Size,
  1650. IN USHORT Version,
  1651. OUT PTRANSLATOR_INTERFACE Translator,
  1652. OUT PULONG BridgeBusNumber
  1653. );
  1654. VOID
  1655. HalpInitNonBusHandler (
  1656. VOID
  1657. );
  1658. VOID
  1659. HalpPowerStateCallback(
  1660. IN PVOID CallbackContext,
  1661. IN PVOID Argument1,
  1662. IN PVOID Argument2
  1663. );
  1664. VOID
  1665. HalpSetMaxLegacyPciBusNumber (
  1666. IN ULONG BusNumber
  1667. );
  1668. #ifdef notyet
  1669. typedef struct {
  1670. UCHAR Dma1ExtendedModePort;
  1671. UCHAR Dma2ExtendedModePort;
  1672. DMA1_CONTROL Dma1Control;
  1673. DMA2_CONTROL Dma2Control;
  1674. } DMA_CONTEXT, *PDMA_CONTEXT;
  1675. typedef struct {
  1676. UCHAR nothing;
  1677. } TIMER_CONTEXT, *PTIMER_CONTEXT;
  1678. typedef struct {
  1679. PIC_CONTEXT PicState;
  1680. DMA_CONTEXT DmaState;
  1681. } MOTHERBOARD_CONTEXT, *PMOTHERBOARD_CONTEXT;
  1682. extern MOTHERBOARD_CONTEXT HalpMotherboardState;
  1683. extern UCHAR HalpDmaChannelModes[];
  1684. extern PVOID HalpSleepPageLock;
  1685. extern UCHAR HalpDmaChannelMasks[];
  1686. extern BOOLEAN HalpOwnedDisplayBeforeSleep;
  1687. #endif // notyet
  1688. //
  1689. // External Interrupt Control Registers macros.
  1690. //
  1691. #define HalpReadLID() __getReg(CV_IA64_SaLID)
  1692. #define HalpClearLID() __setReg(CV_IA64_SaLID, (unsigned __int64)0)
  1693. #define HalpReadTPR() __getReg(CV_IA64_SaTPR)
  1694. //
  1695. // ITM/ITC macros
  1696. //
  1697. #define HalpReadITC() __getReg(CV_IA64_ApITC)
  1698. #define HalpReadITM() __getReg(CV_IA64_ApITM)
  1699. #define HalpWriteITC(Value) __setReg(CV_IA64_ApITC, Value)
  1700. #define HalpWriteITM(Value) __setReg(CV_IA64_ApITM, Value)
  1701. //
  1702. // set itv control register
  1703. //
  1704. #define HalpWriteITVector(Vector) __setReg(CV_IA64_SaITV, Vector)
  1705. //
  1706. // I/O Port space
  1707. //
  1708. // IoSpaceSize = 0x16 for 2 power 0x16 is 4Meg space size (ports 0x0000 - 0x1000)
  1709. //
  1710. #define IO_SPACE_SIZE 0x1A
  1711. //
  1712. // Present bit = 1B to wire the space.
  1713. // Memory Attributes = 100B for UC Memory type
  1714. // Accessed Bit = 1B to "enable" access without faulting.
  1715. // Dirty Bit = 1B to "enable" write without faulting.
  1716. // Privilege Level = 00B for kernel accesses
  1717. // Access Right = 010B for read/write accesses
  1718. // Exception Deferral= 1B for Exception Deferral.
  1719. // Exceptions are deferred
  1720. // for speculative loads to pages with
  1721. // non-spec. mem. attributes anyway.
  1722. //
  1723. // Protection Key = 0 for kernel mode
  1724. //
  1725. #define IO_SPACE_ATTRIBUTE TR_VALUE(1, 0, 3, 0, 1, 1, 4, 1)
  1726. #define HAL_READ_REGISTER_UCHAR(x) \
  1727. (__mf(), *(volatile UCHAR * const)(x))
  1728. #define WRITE_REGISTER_UCHAR(x, y) { \
  1729. *(volatile UCHAR * const)(x) = y; \
  1730. KeFlushWriteBuffer(); \
  1731. }
  1732. //
  1733. // Firmware interface
  1734. //
  1735. VOID HalpInitSalPalNonBsp();
  1736. VOID InternalTestSal();
  1737. ARC_STATUS
  1738. HalGetEnvironmentVariable (
  1739. IN PCHAR Variable,
  1740. IN USHORT Length,
  1741. OUT PCHAR Buffer
  1742. );
  1743. ARC_STATUS
  1744. HalSetEnvironmentVariable (
  1745. IN PCHAR Variable,
  1746. IN PCHAR Buffer
  1747. );
  1748. VOID
  1749. HalpSetInitProfileRate (
  1750. VOID
  1751. );
  1752. VOID
  1753. HalpInitializeProfiling (
  1754. ULONG Number
  1755. );
  1756. NTSTATUS
  1757. HalpProfileSourceInformation (
  1758. OUT PVOID Buffer,
  1759. IN ULONG BufferLength,
  1760. OUT PULONG ReturnedLength
  1761. );
  1762. NTSTATUS
  1763. HalSetProfileSourceInterval(
  1764. IN KPROFILE_SOURCE ProfileSource,
  1765. IN OUT ULONG_PTR *Interval
  1766. );
  1767. //
  1768. // Performance Monitor Registers
  1769. //
  1770. // FIXFIX - Thierry 01/2000.
  1771. //
  1772. // The following functions are defined until the compiler supports
  1773. // the intrinsics __setReg() and __getReg() for the CV_IA64_PFCx,
  1774. // CV_IA64_PFDx and CV_IA64_SaPMV registers.
  1775. // Anyway, because of the micro-architecture differences,
  1776. // and because the implementation of intrinsics cannot handle all the
  1777. // micro-architecture differences, it seems useful to keep these
  1778. // functions around.
  1779. //
  1780. #if 0
  1781. #define HalpReadPerfMonVectorReg() __getReg(CV_IA64_SaPMV)
  1782. #define HalpReadPerfMonCnfgReg0() __getReg(CV_IA64_PFC0)
  1783. #define HalpReadPerfMonCnfgReg4() __getReg(CV_IA64_PFC4)
  1784. #define HalpReadPerfMonDataReg0() __getReg(CV_IA64_PFD0)
  1785. #define HalpReadPerfMonDataReg4() __getReg(CV_IA64_PFD4)
  1786. #define HalpWritePerfMonDataReg0(Value) __setReg(CV_IA64_PFD0, Value)
  1787. #define HalpWritePerfMonDataReg4(Value) __setReg(CV_IA64_PFD4, Value)
  1788. #define HalpWritePerfMonCnfgReg0(Value) __setReg(CV_IA64_PFC0, Value)
  1789. #define HalpWritePerfMonCnfgReg4(Value) __setReg(CV_IA64_PFC4, Value)
  1790. #define HalpWritePerfMonVectorReg(Value) __setReg(CV_IA64_SaPMV,Value)
  1791. #else // !0
  1792. VOID
  1793. HalpWritePerfMonVectorReg(
  1794. ULONGLONG Value
  1795. );
  1796. ULONGLONG
  1797. HalpReadPerfMonVectorReg(
  1798. VOID
  1799. );
  1800. VOID
  1801. HalpWritePerfMonCnfgReg(
  1802. ULONG Register,
  1803. ULONGLONG Value
  1804. );
  1805. #define HalpWritePerfMonCnfgReg0(_Value) HalpWritePerfMonCnfgReg(0UL, _Value)
  1806. #define HalpWritePerfMonCnfgReg4(_Value) HalpWritePerfMonCnfgReg(4UL, _Value)
  1807. ULONGLONG
  1808. HalpReadPerfMonCnfgReg(
  1809. ULONG Register
  1810. );
  1811. #define HalpReadPerfMonCnfgReg0() HalpReadPerfMonCnfgReg(0UL)
  1812. #define HalpReadPerfMonCnfgReg4() HalpReadPerfMonCnfgReg(4UL)
  1813. VOID
  1814. HalpWritePerfMonDataReg(
  1815. ULONG Register,
  1816. ULONGLONG Value
  1817. );
  1818. #define HalpWritePerfMonDataReg0(_Value) HalpWritePerfMonDataReg(0UL, _Value)
  1819. #define HalpWritePerfMonDataReg4(_Value) HalpWritePerfMonDataReg(4UL, _Value)
  1820. ULONGLONG
  1821. HalpReadPerfMonDataReg(
  1822. ULONG Register
  1823. );
  1824. #define HalpReadPerfMonDataReg0() HalpReadPerfMonDataReg(0UL)
  1825. #define HalpReadPerfMonDataReg4() HalpReadPerfMonDataReg(4UL)
  1826. #endif // !0
  1827. EFI_STATUS
  1828. HalpCallEfi(
  1829. IN ULONGLONG FunctionId,
  1830. IN ULONGLONG Arg1,
  1831. IN ULONGLONG Arg2,
  1832. IN ULONGLONG Arg3,
  1833. IN ULONGLONG Arg4,
  1834. IN ULONGLONG Arg5,
  1835. IN ULONGLONG Arg6,
  1836. IN ULONGLONG Arg7,
  1837. IN ULONGLONG Arg8
  1838. );
  1839. EFI_STATUS
  1840. HalpCallEfiPhysical (
  1841. IN ULONGLONG Arg1,
  1842. IN ULONGLONG Arg2,
  1843. IN ULONGLONG Arg3,
  1844. IN ULONGLONG Arg4,
  1845. IN ULONGLONG Arg5,
  1846. IN ULONGLONG Arg6,
  1847. IN ULONGLONG EP,
  1848. IN ULONGLONG GP
  1849. );
  1850. ULONG
  1851. HalpReadGenAddr(
  1852. IN PGEN_ADDR GenAddr
  1853. );
  1854. VOID
  1855. HalpWriteGenAddr(
  1856. IN PGEN_ADDR GenAddr,
  1857. IN ULONG Value
  1858. );
  1859. USHORT
  1860. HalpReadAcpiRegister(
  1861. IN ACPI_REG_TYPE AcpiReg,
  1862. IN ULONG Register
  1863. );
  1864. VOID
  1865. HalpWriteAcpiRegister(
  1866. IN ACPI_REG_TYPE AcpiReg,
  1867. IN ULONG Register,
  1868. IN USHORT Value
  1869. );
  1870. //
  1871. // Debugging support functions
  1872. //
  1873. VOID
  1874. HalpRegisterPciDebuggingDeviceInfo(
  1875. VOID
  1876. );
  1877. //
  1878. // Functions related to platform properties as exposed by the IPPT
  1879. // table.
  1880. //
  1881. BOOLEAN
  1882. HalpIsInternalInterruptVector(
  1883. IN ULONG SystemVector
  1884. );
  1885. NTSTATUS
  1886. HalpReserveCrossPartitionInterruptVector (
  1887. OUT PULONG Vector,
  1888. OUT PKIRQL Irql,
  1889. IN OUT PKAFFINITY Affinity,
  1890. OUT PUCHAR HardwareVector
  1891. );
  1892. NTSTATUS
  1893. HalpSendCrossPartitionIpi(
  1894. IN USHORT ProcessorID,
  1895. IN UCHAR HardwareVector
  1896. );
  1897. NTSTATUS
  1898. HalpGetCrossPartitionIpiInterface(
  1899. OUT HAL_CROSS_PARTITION_IPI_INTERFACE * IpiInterface
  1900. );
  1901. NTSTATUS
  1902. HalpGetPlatformProperties(
  1903. OUT PULONG Properties
  1904. );
  1905. #endif // _HALP_