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.

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