hl.h 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475
  1. /*++
  2. Copyright (c) 2012 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. hl.h
  9. Abstract:
  10. This header contains definitions for the kernel's Hardware Layer.
  11. Author:
  12. Evan Green 5-Aug-2012
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. #include <minoca/kernel/regacces.h>
  18. //
  19. // --------------------------------------------------------------------- Macros
  20. //
  21. //
  22. // This macro converts a Binary Coded Decimal value into a binary.
  23. //
  24. #define BCD_TO_BINARY(_BcdValue) \
  25. ((((_BcdValue) >> 4) * 10) + ((_BcdValue) & 0x0F))
  26. #define BINARY_TO_BCD(_BinaryValue) \
  27. ((((_BinaryValue) / 10) << 4) | ((_BinaryValue) % 10))
  28. //
  29. // ---------------------------------------------------------------- Definitions
  30. //
  31. #define HL_POOL_TAG 0x64726148 // 'draH'
  32. #define HL_CRASH_PROCESSOR_INDEXING_ERROR 0x00000001
  33. #define HL_CRASH_SET_PROCESSOR_ADDRESSING_FAILURE 0x00000002
  34. #define HL_CRASH_NO_IO_PORTS 0x00000003
  35. #define HL_CRASH_CLOCK_WONT_START 0x00000004
  36. #define HL_CRASH_PROCESSOR_WONT_START 0x00000005
  37. #define HL_CRASH_INVALID_INTERRUPT_DISCONNECT 0x00000006
  38. #define HL_CRASH_PROCESSOR_HUNG 0x00000007
  39. #define HL_CRASH_RESUME_FAILURE 0x00000008
  40. //
  41. // Define the default system clock rate at system boot, in 100ns units.
  42. //
  43. #define DEFAULT_CLOCK_RATE 156250
  44. //
  45. // Define low level suspend flags.
  46. //
  47. //
  48. // This bit is set when the interrupt controller state needs to be saved.
  49. //
  50. #define HL_SUSPEND_RESTORE_INTERRUPTS 0x00000001
  51. //
  52. // ------------------------------------------------------ Data Type Definitions
  53. //
  54. typedef enum _IPI_TYPE {
  55. IpiTypeInvalid,
  56. IpiTypePacket,
  57. IpiTypeTlbFlush,
  58. IpiTypeNmi,
  59. IpiTypeProfiler,
  60. IpiTypeClock
  61. } IPI_TYPE, *PIPI_TYPE;
  62. typedef enum _INTERRUPT_STATUS {
  63. InterruptStatusNotClaimed,
  64. InterruptStatusClaimed,
  65. InterruptStatusDefer
  66. } INTERRUPT_STATUS, *PINTERRUPT_STATUS;
  67. typedef enum _INTERRUPT_MODEL {
  68. InterruptModelInvalid,
  69. InterruptModelPic,
  70. InterruptModelApic,
  71. } INTERRUPT_MODEL, *PINTERRUPT_MODEL;
  72. typedef enum _HL_INFORMATION_TYPE {
  73. HlInformationInvalid,
  74. HlInformationEfiVariable,
  75. } HL_INFORMATION_TYPE, *PHL_INFORMATION_TYPE;
  76. typedef
  77. INTERRUPT_STATUS
  78. (*PINTERRUPT_SERVICE_ROUTINE) (
  79. PVOID Context
  80. );
  81. /*++
  82. Routine Description:
  83. This routine represents an interrupt service routine.
  84. Arguments:
  85. Context - Supplies the context supplied when this interrupt was initially
  86. connected.
  87. Return Value:
  88. Returns an interrupt status indicating if this ISR is claiming the
  89. interrupt, not claiming the interrupt, or needs the interrupt to be
  90. masked temporarily.
  91. --*/
  92. typedef
  93. VOID
  94. (*PPROCESSOR_START_ROUTINE) (
  95. PPROCESSOR_START_BLOCK StartBlock
  96. );
  97. /*++
  98. Routine Description:
  99. This routine represents a prototype for a processor initialization routine.
  100. Arguments:
  101. StartBlock - Supplies a pointer to the processor start block.
  102. Return Value:
  103. None. This routine does not return.
  104. --*/
  105. /*++
  106. Structure Description:
  107. This structure defines an interrupt.
  108. Members:
  109. Vector - Stores the vector the interrupt is connected to.
  110. Line - Stores the interrupt line this interrupt is connected to.
  111. Mode - Stores the mode of the interrupt (edge or level).
  112. InterruptServiceRoutine - Stores a pointer to the service routine to be
  113. called at interrupt runlevel.
  114. Context - Stores the context to be passed in when this ISR is executed.
  115. InterruptCount - Stores the number of interrupts received. This variable is
  116. not synchronized, so the count may not be exact.
  117. LastTimestamp - Stores the time counter value the last time this interrupt
  118. was sampled. This is used for interrupt storm detection.
  119. DispatchServiceRoutine - Stores an optiontl pointer to the function to
  120. call at dispatch level to service the interrupt.
  121. LowLevelServiceRoutine - Stores an optional pointer to the function to
  122. call at low run level to service the interrupt.
  123. Dpc - Stores a pointer to the DPC that is queued for this interrupt.
  124. WorkItem - Stores a pointer to the work item that is queued for this
  125. interrupt.
  126. QueueStatus - Stores various queue flags. See INTERRUPT_QUEUE_* definitions.
  127. Controller - Stores a pointer to the interrupt controller for this
  128. interrupt.
  129. --*/
  130. typedef struct _KINTERRUPT KINTERRUPT, *PKINTERRUPT;
  131. struct _KINTERRUPT {
  132. PKINTERRUPT NextInterrupt;
  133. INTERRUPT_LINE Line;
  134. INTERRUPT_MODE Mode;
  135. ULONG Vector;
  136. RUNLEVEL RunLevel;
  137. PINTERRUPT_SERVICE_ROUTINE InterruptServiceRoutine;
  138. PVOID Context;
  139. UINTN InterruptCount;
  140. ULONGLONG LastTimestamp;
  141. PINTERRUPT_SERVICE_ROUTINE DispatchServiceRoutine;
  142. PINTERRUPT_SERVICE_ROUTINE LowLevelServiceRoutine;
  143. PDPC Dpc;
  144. PWORK_ITEM WorkItem;
  145. volatile ULONG QueueFlags;
  146. PINTERRUPT_CONTROLLER Controller;
  147. };
  148. /*++
  149. Structure Description:
  150. This structure defines a range of physical address space in use by the
  151. hardware layer.
  152. Members:
  153. ListEntry - Stores pointers to the next and previous physical address usage
  154. structures in the list.
  155. PhysicalAddress - Stores the first physical address in the segment of
  156. physical memory space occupied by this allocation.
  157. Size - Stores the size of the range, in bytes.
  158. --*/
  159. typedef struct _HL_PHYSICAL_ADDRESS_USAGE {
  160. LIST_ENTRY ListEntry;
  161. PHYSICAL_ADDRESS PhysicalAddress;
  162. ULONGLONG Size;
  163. } HL_PHYSICAL_ADDRESS_USAGE, *PHL_PHYSICAL_ADDRESS_USAGE;
  164. /*++
  165. Structure Description:
  166. This structure defines EFI variable information.
  167. Members:
  168. VariableNameSize - Supplies the size of the variable name buffer in bytes.
  169. The buffer immediately follows this structure. Remember that UEFI
  170. strings have characters that are two-bytes wide.
  171. VendorGuid - Supplies the vendor GUID (byte for byte coped to an EFI_GUID).
  172. Attributes - Supplies either the attributes to set or the attributes
  173. returned.
  174. DataSize - Supplies the size of the data buffer in bytes. The data
  175. immediately follows the variable name.
  176. --*/
  177. typedef struct _HL_EFI_VARIABLE_INFORMATION {
  178. UINTN VariableNameSize;
  179. UUID VendorGuid;
  180. ULONG Attributes;
  181. UINTN DataSize;
  182. } HL_EFI_VARIABLE_INFORMATION, *PHL_EFI_VARIABLE_INFORMATION;
  183. /*++
  184. Structure Description:
  185. This structure defines information about the processor counter.
  186. Members:
  187. Frequency - Stores the frequency of the processor counter in Hertz. This
  188. is usually the maximum sustainable frequency, which is also the
  189. frequency at which the system was booted.
  190. Multiplier - Stores the multiplier to translate between this timer's speed
  191. and the actual processor execution speed.
  192. Features - Stores a bitfield of timer features. See TIMER_FEATURE_*
  193. definitions.
  194. --*/
  195. typedef struct _HL_PROCESSOR_COUNTER_INFORMATION {
  196. ULONGLONG Frequency;
  197. ULONG Multiplier;
  198. ULONG Features;
  199. } HL_PROCESSOR_COUNTER_INFORMATION, *PHL_PROCESSOR_COUNTER_INFORMATION;
  200. //
  201. // SuspendBegin is called after all devices have been suspended, but before
  202. // internal hardware layer context has been saved.
  203. //
  204. // Suspend is called after all internal context has been saved, and should
  205. // actually take the CPU or platform down.
  206. //
  207. // Resume is called immediately after the machine context is restored, but
  208. // before all the internal hardware layer state has been restored.
  209. //
  210. // ResumeEnd is called after the internal hardware layer state has been
  211. // restored, but before devices have been resumed.
  212. //
  213. // Complete is not a phase under which the callback is called, but is the
  214. // ending state indicating the transition went through successfully.
  215. //
  216. typedef enum _HL_SUSPEND_PHASE {
  217. HlSuspendPhaseInvalid,
  218. HlSuspendPhaseSuspendBegin = 0x100,
  219. HlSuspendPhaseSuspend = 0x200,
  220. HlSuspendPhaseResume = 0x300,
  221. HlSuspendPhaseResumeEnd = 0x400,
  222. HlSuspendPhaseComplete = 0x1000
  223. } HL_SUSPEND_PHASE, *PHL_SUSPEND_PHASE;
  224. typedef
  225. KSTATUS
  226. (*PHL_SUSPEND_CALLBACK) (
  227. PVOID Context,
  228. HL_SUSPEND_PHASE Phase
  229. );
  230. /*++
  231. Routine Description:
  232. This routine represents a callback during low level suspend or resume.
  233. Arguments:
  234. Context - Supplies the context supplied in the interface.
  235. Phase - Supplies the phase of suspend or resume the callback represents.
  236. Return Value:
  237. Status code. On suspend, failure causes the suspend to abort. On resume,
  238. failure causes a crash.
  239. --*/
  240. typedef
  241. UINTN
  242. (*PHL_PHYSICAL_CALLBACK) (
  243. UINTN Argument
  244. );
  245. /*++
  246. Routine Description:
  247. This routine represents a callback with the MMU disabled. No services
  248. except a small stack are available during this callback.
  249. Arguments:
  250. Argument - Supplies an argument to pass to the function.
  251. Return Value:
  252. Returns an unspecified value significant to the caller.
  253. --*/
  254. /*++
  255. Structure Description:
  256. This structure defines the interface used when going down for a low level
  257. suspend where the processor context will be lost. This interface should
  258. only be used/called by low-level platform drivers that implement suspend.
  259. Members:
  260. Flags - Stores a bitfield of flags governing how the processor is taken
  261. down and brought back up. See HL_SUSPEND_* definitions.
  262. Context - Stores a context pointer passed to the callback routines.
  263. Callback - Stores a pointer to a function that is called for each phase of
  264. suspend and resume.
  265. Phase - Stores the phase at which the suspend or resume operation failed,
  266. if it did.
  267. ResumeAddress - Stores the physical address this processor should resume to.
  268. This will be filled out by the system by the time the suspend phase
  269. is called.
  270. --*/
  271. typedef struct _HL_SUSPEND_INTERFACE {
  272. ULONG Flags;
  273. PVOID Context;
  274. PHL_SUSPEND_CALLBACK Callback;
  275. HL_SUSPEND_PHASE Phase;
  276. PHYSICAL_ADDRESS ResumeAddress;
  277. } HL_SUSPEND_INTERFACE, *PHL_SUSPEND_INTERFACE;
  278. //
  279. // -------------------------------------------------------------------- Globals
  280. //
  281. //
  282. // -------------------------------------------------------- Function Prototypes
  283. //
  284. KERNEL_API
  285. ULONGLONG
  286. HlQueryTimeCounter (
  287. VOID
  288. );
  289. /*++
  290. Routine Description:
  291. This routine queries the time counter hardware and returns a 64-bit
  292. monotonically non-decreasing value that represents the number of timer ticks
  293. since the system was started. This value will continue to count through all
  294. idle and sleep states.
  295. This routine can be called at any runlevel.
  296. Arguments:
  297. None.
  298. Return Value:
  299. Returns the number of timer ticks that have elapsed since the system was
  300. booted. The absolute time between successive ticks can be retrieved from the
  301. Query Time Counter Frequency function.
  302. --*/
  303. KERNEL_API
  304. ULONGLONG
  305. HlQueryProcessorCounter (
  306. VOID
  307. );
  308. /*++
  309. Routine Description:
  310. This routine queries the processor counter hardware and returns a 64-bit
  311. monotonically non-decreasing value that correlates to "processor" time.
  312. This does not necessarily correspond to wall-clock time, as the frequency
  313. of this counter may vary over time. This counter may also vary across
  314. processors, so this routine must be called at dispatch level or higher.
  315. Failing to call this routine at or above dispatch level may cause the
  316. counter's internal accounting to malfunction.
  317. This routine is intended primarily for the scheduler to track processor
  318. cycles. Users looking to measure units of time should query the time
  319. counter.
  320. Arguments:
  321. None.
  322. Return Value:
  323. Returns a 64-bit non-decreasing value corresponding to "processor" time.
  324. --*/
  325. KERNEL_API
  326. ULONGLONG
  327. HlQueryProcessorCounterFrequency (
  328. VOID
  329. );
  330. /*++
  331. Routine Description:
  332. This routine returns the frequency of the processor counter. This frequency
  333. will never change after it is set on boot.
  334. This routine can be called at any runlevel.
  335. Arguments:
  336. None.
  337. Return Value:
  338. Returns the frequency of the time counter, in Hertz.
  339. --*/
  340. KERNEL_API
  341. ULONGLONG
  342. HlQueryTimeCounterFrequency (
  343. VOID
  344. );
  345. /*++
  346. Routine Description:
  347. This routine returns the frequency of the time counter. This frequency will
  348. never change after it is set on boot.
  349. This routine can be called at any runlevel.
  350. Arguments:
  351. None.
  352. Return Value:
  353. Returns the frequency of the time counter, in Hertz.
  354. --*/
  355. KERNEL_API
  356. VOID
  357. HlBusySpin (
  358. ULONG Microseconds
  359. );
  360. /*++
  361. Routine Description:
  362. This routine spins for at least the given number of microseconds by
  363. repeatedly reading a hardware timer. This routine should be avoided if at
  364. all possible, as it simply burns CPU cycles.
  365. This routine can be called at any runlevel.
  366. Arguments:
  367. Microseconds - Supplies the number of microseconds to spin for.
  368. Return Value:
  369. Returns the frequency of the time counter, in Hertz.
  370. --*/
  371. KERNEL_API
  372. KSTATUS
  373. HlUpdateCalendarTime (
  374. VOID
  375. );
  376. /*++
  377. Routine Description:
  378. This routine updates the first available hardware calendar time with a snap
  379. of the current system time.
  380. Arguments:
  381. None.
  382. Return Value:
  383. Status code.
  384. --*/
  385. KERNEL_API
  386. INTERRUPT_MODEL
  387. HlGetInterruptModel (
  388. VOID
  389. );
  390. /*++
  391. Routine Description:
  392. This routine returns the general system interrupt model currently in use.
  393. This routine is only useful to firmware or interrupt configuration parties.
  394. Arguments:
  395. None.
  396. Return Value:
  397. Returns the interrupt model in use.
  398. --*/
  399. KERNEL_API
  400. KSTATUS
  401. HlCreateInterruptController (
  402. ULONG ParentGsi,
  403. ULONG ParentVector,
  404. ULONG LineCount,
  405. PINTERRUPT_CONTROLLER_DESCRIPTION Registration,
  406. PINTERRUPT_CONTROLLER_INFORMATION ResultingInformation
  407. );
  408. /*++
  409. Routine Description:
  410. This routine creates an interrupt controller outside of the normal hardware
  411. module context. It is used primarily by GPIO controllers that function as a
  412. kind of secondary interrupt controller.
  413. Arguments:
  414. ParentGsi - Supplies the global system interrupt number of the interrupt
  415. controller line this controller wires up to.
  416. ParentVector - Supplies the vector of the interrupt that this interrupt
  417. controller wires up to.
  418. LineCount - Supplies the number of lines this interrupt controller contains.
  419. Registration - Supplies a pointer to the interrupt controller information,
  420. filled out correctly by the caller.
  421. ResultingInformation - Supplies a pointer where the interrupt controller
  422. handle and other information will be returned.
  423. Return Value:
  424. Status code.
  425. --*/
  426. KERNEL_API
  427. VOID
  428. HlDestroyInterruptController (
  429. PINTERRUPT_CONTROLLER Controller
  430. );
  431. /*++
  432. Routine Description:
  433. This routine destroys an interrupt controller, taking it offline and
  434. releasing all resources associated with it.
  435. Arguments:
  436. Controller - Supplies a pointer to the controller to destroy.
  437. Return Value:
  438. None.
  439. --*/
  440. KERNEL_API
  441. KSTATUS
  442. HlGetInterruptControllerInformation (
  443. UINTN Identifier,
  444. PINTERRUPT_CONTROLLER_INFORMATION Information
  445. );
  446. /*++
  447. Routine Description:
  448. This routine returns information about an interrupt controller with a
  449. specific ID.
  450. Arguments:
  451. Identifier - Supplies the identifier of the interrupt controller.
  452. Information - Supplies a pointer where the interrupt controller information
  453. will be returned on success.
  454. Return Value:
  455. STATUS_SUCCESS on success.
  456. STATUS_NOT_FOUND if no interrupt controller matching the given identifier
  457. exists in the system.
  458. --*/
  459. KERNEL_API
  460. VOID
  461. HlContinueInterrupt (
  462. HANDLE InterruptHandle,
  463. INTERRUPT_STATUS Status
  464. );
  465. /*++
  466. Routine Description:
  467. This routine continues an interrupt that was previously deferred at low
  468. level.
  469. Arguments:
  470. InterruptHandle - Supplies the connected interrupt handle.
  471. Status - Supplies the final interrupt status that would have been returned
  472. had the interrupt not been deferred. This must either be claimed or
  473. not claimed.
  474. Return Value:
  475. None.
  476. --*/
  477. KERNEL_API
  478. INTERRUPT_STATUS
  479. HlSecondaryInterruptControllerService (
  480. PVOID Context
  481. );
  482. /*++
  483. Routine Description:
  484. This routine implements a standard interrupt service routine for an
  485. interrupt that is wired to another interrupt controller. It will call out
  486. to determine what fired, and begin a new secondary interrupt.
  487. Arguments:
  488. Context - Supplies the context, which must be a pointer to the secondary
  489. interrupt controller that needs service.
  490. Return Value:
  491. Returns an interrupt status indicating if this ISR is claiming the
  492. interrupt, not claiming the interrupt, or needs the interrupt to be
  493. masked temporarily.
  494. --*/
  495. KERNEL_API
  496. KSTATUS
  497. HlGetMsiInformation (
  498. ULONGLONG Vector,
  499. ULONGLONG VectorCount,
  500. PPROCESSOR_SET Processors,
  501. PMSI_INFORMATION Information
  502. );
  503. /*++
  504. Routine Description:
  505. This routine gathers the appropriate MSI/MSI-X address and data information
  506. for the given set of contiguous interrupt vectors.
  507. Arguments:
  508. Vector - Supplies the first vector for which information is being requested.
  509. VectorCount - Supplies the number of contiguous vectors for which
  510. information is being requested.
  511. Processors - Supplies the set of processors that the MSIs should utilize.
  512. Information - Supplies a pointer to an array of MSI/MSI-X information to
  513. be filled in by the routine.
  514. Return Value:
  515. Status code.
  516. --*/
  517. KERNEL_API
  518. KSTATUS
  519. HlGetProcessorIndexFromId (
  520. ULONGLONG PhysicalId,
  521. PULONG ProcessorIndex,
  522. PBOOL Active
  523. );
  524. /*++
  525. Routine Description:
  526. This routine attempts to find the logical processor index of the processor
  527. with the given physical identifier.
  528. Arguments:
  529. PhysicalId - Supplies the processor physical identifier.
  530. ProcessorIndex - Supplies a pointer where the processor index will be
  531. returned on success.
  532. Active - Supplies a pointer where a boolean will be returned indicating if
  533. this processor is present and active within the system.
  534. Return Value:
  535. Status code.
  536. --*/
  537. KERNEL_API
  538. KSTATUS
  539. HlSuspend (
  540. PHL_SUSPEND_INTERFACE Interface
  541. );
  542. /*++
  543. Routine Description:
  544. This routine implements the low level primitive to suspend the processor
  545. and/or platform. This routine does not deal with device states at all, it
  546. simply takes the CPU/platform down.
  547. Arguments:
  548. Interface - Supplies a pointer to the suspend interface to use going down.
  549. Return Value:
  550. Status code. A failing status code indicates that the suspend did not
  551. occur.
  552. --*/
  553. KERNEL_API
  554. UINTN
  555. HlDisableMmu (
  556. PHL_PHYSICAL_CALLBACK PhysicalFunction,
  557. UINTN Argument
  558. );
  559. /*++
  560. Routine Description:
  561. This routine temporarily disables the MMU and calls then given callback
  562. function.
  563. Arguments:
  564. PhysicalFunction - Supplies the physical address of a function to call
  565. with the MMU disabled. Interrupts will also be disabled during this
  566. call.
  567. Argument - Supplies an argument to pass to the function.
  568. Return Value:
  569. Returns the value returned by the callback function.
  570. --*/
  571. KERNEL_API
  572. KSTATUS
  573. HlRegisterHardware (
  574. HARDWARE_MODULE_TYPE Type,
  575. PVOID Description
  576. );
  577. /*++
  578. Routine Description:
  579. This routine registers a hardware module with the system.
  580. Arguments:
  581. Type - Supplies the type of resource being registered.
  582. Description - Supplies a description of the resource being registered.
  583. Return Value:
  584. Returns a pointer to the allocation of the requested size on success.
  585. NULL on failure.
  586. --*/
  587. KSTATUS
  588. HlStartAllProcessors (
  589. PPROCESSOR_START_ROUTINE StartRoutine,
  590. PULONG ProcessorsStarted
  591. );
  592. /*++
  593. Routine Description:
  594. This routine is called on the BSP, and starts all APs.
  595. Arguments:
  596. StartRoutine - Supplies the routine the processors should jump to.
  597. ProcessorsStarted - Supplies a pointer where the number of processors
  598. started will be returned (the total number of processors in the system,
  599. including the boot processor).
  600. Return Value:
  601. Status code.
  602. --*/
  603. KSTATUS
  604. HlSendIpi (
  605. IPI_TYPE IpiType,
  606. PPROCESSOR_SET Processors
  607. );
  608. /*++
  609. Routine Description:
  610. This routine sends an Inter-Processor Interrupt (IPI) to the given set of
  611. processors.
  612. Arguments:
  613. IpiType - Supplies the type of IPI to deliver.
  614. Processors - Supplies the set of processors to deliver the IPI to.
  615. Return Value:
  616. Status code.
  617. --*/
  618. ULONG
  619. HlGetMaximumProcessorCount (
  620. VOID
  621. );
  622. /*++
  623. Routine Description:
  624. This routine returns the maximum number of logical processors that this
  625. machine supports.
  626. Arguments:
  627. None.
  628. Return Value:
  629. Returns the maximum number of logical processors that may exist in the
  630. system.
  631. --*/
  632. VOID
  633. HlDispatchInterrupt (
  634. ULONG Vector,
  635. PTRAP_FRAME TrapFrame
  636. );
  637. /*++
  638. Routine Description:
  639. This routine determines the source of an interrupt and runs the ISR.
  640. Arguments:
  641. Vector - Supplies the vector this interrupt came in on.
  642. TrapFrame - Supplies a pointer to the machine state immediately before the
  643. interrupt.
  644. Return Value:
  645. None.
  646. --*/
  647. RUNLEVEL
  648. HlRaiseRunLevel (
  649. RUNLEVEL RunLevel
  650. );
  651. /*++
  652. Routine Description:
  653. This routine raises the interrupt run level of the system.
  654. Arguments:
  655. RunLevel - Supplies the run level to raise to. This must be greater than
  656. or equal to the current runlevel.
  657. Return Value:
  658. Returns a pointer to the old run level.
  659. --*/
  660. VOID
  661. HlLowerRunLevel (
  662. RUNLEVEL RunLevel
  663. );
  664. /*++
  665. Routine Description:
  666. This routine lowers the interrupt run level of the system.
  667. Arguments:
  668. RunLevel - Supplies the run level to lower to. This must be less than
  669. or equal to the current runlevel.
  670. Return Value:
  671. Returns a pointer to the old run level.
  672. --*/
  673. PKINTERRUPT
  674. HlCreateInterrupt (
  675. ULONG Vector,
  676. PINTERRUPT_SERVICE_ROUTINE InterruptServiceRoutine,
  677. PINTERRUPT_SERVICE_ROUTINE DispatchServiceRoutine,
  678. PINTERRUPT_SERVICE_ROUTINE LowLevelServiceRoutine,
  679. PVOID Context
  680. );
  681. /*++
  682. Routine Description:
  683. This routine creates and initialize a new KINTERRUPT structure.
  684. Arguments:
  685. Vector - Supplies the vector that the interrupt will come in on.
  686. InterruptServiceRoutine - Supplies a pointer to the function to call at
  687. interrupt runlevel when this interrupt comes in.
  688. DispatchServiceRoutine - Supplies a pointer to the function to call at
  689. dispatch level when this interrupt comes in.
  690. LowLevelServiceRoutine - Supplies a pointer to the function to call at
  691. low runlevel when this interrupt comes in.
  692. Context - Supplies a pointer's worth of data that will be passed in to the
  693. service routine when it is called.
  694. Return Value:
  695. Returns a pointer to the newly created interrupt on success. The interrupt
  696. is not connected at this point.
  697. NULL on failure.
  698. --*/
  699. VOID
  700. HlDestroyInterrupt (
  701. PKINTERRUPT Interrupt
  702. );
  703. /*++
  704. Routine Description:
  705. This routine destroys a KINTERRUPT structure.
  706. Arguments:
  707. Interrupt - Supplies a pointer to the interrupt to destroy.
  708. Return Value:
  709. None.
  710. --*/
  711. KSTATUS
  712. HlConnectInterrupt (
  713. PKINTERRUPT Interrupt
  714. );
  715. /*++
  716. Routine Description:
  717. This routine commits an interrupt service routine to active duty. When this
  718. call is completed, it will be called for interrupts coming in on the
  719. specified vector.
  720. Arguments:
  721. Interrupt - Supplies a pointer to the initialized interrupt.
  722. Return Value:
  723. Status code.
  724. --*/
  725. VOID
  726. HlDisconnectInterrupt (
  727. PKINTERRUPT Interrupt
  728. );
  729. /*++
  730. Routine Description:
  731. This routine removes an interrupt service routine from active duty. When
  732. this call is completed, no new interrupts will come in for this device and
  733. vector.
  734. Arguments:
  735. Interrupt - Supplies a pointer to the initialized interrupt.
  736. Return Value:
  737. None.
  738. --*/
  739. KSTATUS
  740. HlEnableInterruptLine (
  741. ULONGLONG GlobalSystemInterruptNumber,
  742. PINTERRUPT_LINE_STATE LineState,
  743. PKINTERRUPT Interrupt,
  744. PVOID ResourceData,
  745. UINTN ResourceDataSize
  746. );
  747. /*++
  748. Routine Description:
  749. This routine enables the given interrupt line.
  750. Arguments:
  751. GlobalSystemInterruptNumber - Supplies the global system interrupt number
  752. to enable.
  753. LineState - Supplies a pointer to the desired line state. Only the mode,
  754. polarity and flags are required by this routine.
  755. Interrupt - Supplies a pointer to the interrupt structure this line will
  756. be connected to.
  757. ResourceData - Supplies an optional pointer to the device specific resource
  758. data for the interrupt line.
  759. ResourceDataSize - Supplies the size of the resource data, in bytes.
  760. Return Value:
  761. Status code.
  762. --*/
  763. VOID
  764. HlDisableInterruptLine (
  765. PKINTERRUPT Interrupt
  766. );
  767. /*++
  768. Routine Description:
  769. This routine disables the given interrupt line. Note that if the line is
  770. being shared by multiple interrupts, it may stay open for the other
  771. devices connected to it.
  772. Arguments:
  773. Interrupt - Supplies a pointer to the interrupt line to disconnect.
  774. Return Value:
  775. None.
  776. --*/
  777. KSTATUS
  778. HlStartProfilerTimer (
  779. VOID
  780. );
  781. /*++
  782. Routine Description:
  783. This routine activates the profiler by arming the profiler timer.
  784. Arguments:
  785. None.
  786. Return Value:
  787. Status code.
  788. --*/
  789. VOID
  790. HlStopProfilerTimer (
  791. VOID
  792. );
  793. /*++
  794. Routine Description:
  795. This routine stops the profiler by disarming the profiler timer.
  796. Arguments:
  797. None.
  798. Return Value:
  799. None.
  800. --*/
  801. KSTATUS
  802. HlQueryCalendarTime (
  803. PSYSTEM_TIME SystemTime,
  804. PULONGLONG TimeCounter
  805. );
  806. /*++
  807. Routine Description:
  808. This routine returns the current calendar time as reported by the hardware
  809. calendar time source.
  810. Arguments:
  811. SystemTime - Supplies a pointer where the system time as read from the
  812. hardware will be returned.
  813. TimeCounter - Supplies a pointer where a time counter value corresponding
  814. with the approximate moment the calendar time was read will be
  815. returned.
  816. Return Value:
  817. STATUS_SUCCESS on success.
  818. STATUS_NO_SUCH_DEVICE if there are no registered calendar timer modules.
  819. Other errors on calendar timer hardware failure.
  820. --*/
  821. VOID
  822. HlSetClockTimer (
  823. CLOCK_TIMER_MODE Mode,
  824. ULONGLONG DueTime,
  825. BOOL Hard
  826. );
  827. /*++
  828. Routine Description:
  829. This routine arms or disarms the main clock timer. This routine must be
  830. called at or above clock level, or with interrupts disabled.
  831. Arguments:
  832. Mode - Supplies the mode to arm the timer in.
  833. DueTime - Supplies the due time in time counter ticks (absolute) to arm the
  834. timer in. This is only used in one-shot mode.
  835. Hard - Supplies a boolean indicating if this is a hard or soft deadline.
  836. This is used only for one-shot mode.
  837. Return Value:
  838. None.
  839. --*/
  840. KSTATUS
  841. HlGetProcessorCounterInformation (
  842. PHL_PROCESSOR_COUNTER_INFORMATION Information
  843. );
  844. /*++
  845. Routine Description:
  846. This routine returns information about the cycle counter built into the
  847. processor.
  848. Arguments:
  849. Information - Supplies a pointer where the processor counter information
  850. will be returned on success.
  851. Return Value:
  852. STATUS_SUCCESS on success.
  853. STATUS_NOT_SUPPORTED if the processor does not have a processor cycle
  854. counter.
  855. --*/
  856. VOID
  857. HlFlushCache (
  858. ULONG Flags
  859. );
  860. /*++
  861. Routine Description:
  862. This routine flushes the cache for every registered cache controller.
  863. Arguments:
  864. Flags - Supplies a bitmask of cache flush flags. See HL_CACHE_FLAG_* for
  865. definitions.
  866. Return Value:
  867. None.
  868. --*/
  869. VOID
  870. HlFlushCacheRegion (
  871. PHYSICAL_ADDRESS Address,
  872. UINTN SizeInBytes,
  873. ULONG Flags
  874. );
  875. /*++
  876. Routine Description:
  877. This routine flushes the given cache region for every registered cache
  878. controller.
  879. Arguments:
  880. Address - Supplies the starting physical address of the region to flush. It
  881. must be aligned to the cache line size.
  882. SizeInBytes - Supplies the number of bytes to flush.
  883. Flags - Supplies a bitmask of cache flush flags. See HL_CACHE_FLAG_* for
  884. definitions.
  885. Return Value:
  886. None.
  887. --*/
  888. ULONG
  889. HlGetDataCacheLineSize (
  890. VOID
  891. );
  892. /*++
  893. Routine Description:
  894. This routine returns the maximum data cache line size out of all registered
  895. cache controllers.
  896. Arguments:
  897. None.
  898. Return Value:
  899. Returns the maximum data cache line size out of all registered cache
  900. controllers in bytes.
  901. --*/
  902. KSTATUS
  903. HlResetSystem (
  904. SYSTEM_RESET_TYPE ResetType,
  905. PVOID Data,
  906. UINTN Size
  907. );
  908. /*++
  909. Routine Description:
  910. This routine resets the system.
  911. Arguments:
  912. ResetType - Supplies the desired reset type. If the desired reset type is
  913. not supported, a cold reset will be attempted.
  914. Data - Supplies a pointer to platform-specific reboot data.
  915. Size - Supplies the size of the platform-specific data in bytes.
  916. Return Value:
  917. Does not return on success, the system is reset.
  918. STATUS_INVALID_PARAMETER if an invalid reset type was supplied.
  919. STATUS_NO_INTERFACE if there are no appropriate reboot capababilities
  920. registered with the system.
  921. Other status codes on other failures.
  922. --*/
  923. KSTATUS
  924. HlGetSetSystemInformation (
  925. BOOL FromKernelMode,
  926. HL_INFORMATION_TYPE InformationType,
  927. PVOID Data,
  928. PUINTN DataSize,
  929. BOOL Set
  930. );
  931. /*++
  932. Routine Description:
  933. This routine gets or sets system information.
  934. Arguments:
  935. FromKernelMode - Supplies a boolean indicating whether or not this request
  936. (and the buffer associated with it) originates from user mode (FALSE)
  937. or kernel mode (TRUE).
  938. InformationType - Supplies the information type.
  939. Data - Supplies a pointer to the data buffer where the data is either
  940. returned for a get operation or given for a set operation.
  941. DataSize - Supplies a pointer that on input contains the size of the
  942. data buffer. On output, contains the required size of the data buffer.
  943. Set - Supplies a boolean indicating if this is a get operation (FALSE) or
  944. a set operation (TRUE).
  945. Return Value:
  946. Status code.
  947. --*/