hmod.h 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567
  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. hmod.h
  9. Abstract:
  10. This header contains definitions for external hardware modules. These are
  11. not drivers, but rather pieces of hardware core to the basic operation of
  12. the kernel, including timers, interrupt controllers, DMA controllers, and
  13. debug devices.
  14. Author:
  15. Evan Green 28-Oct-2012
  16. --*/
  17. //
  18. // ------------------------------------------------------------------- Includes
  19. //
  20. //
  21. // --------------------------------------------------------------------- Macros
  22. //
  23. //
  24. // These macros read from and write to a field that might not be aligned.
  25. //
  26. #define READ_UNALIGNED16(_Pointer) \
  27. (USHORT)(((volatile UCHAR *)(_Pointer))[0] | \
  28. (((USHORT)((volatile UCHAR *)(_Pointer))[1]) << 8))
  29. #define WRITE_UNALIGNED16(_Pointer, _Value) \
  30. ((volatile UCHAR *)(_Pointer))[0] = (UCHAR)(_Value), \
  31. ((volatile UCHAR *)(_Pointer))[1] = (UCHAR)((_Value) >> 8)
  32. #define READ_UNALIGNED32(_Pointer) \
  33. (ULONG)(READ_UNALIGNED16(_Pointer) | \
  34. (READ_UNALIGNED16((PUSHORT)(_Pointer) + 1) << 16))
  35. #define WRITE_UNALIGNED32(_Pointer, _Value) \
  36. WRITE_UNALIGNED16((_Pointer), (_Value) & 0xFFFF), \
  37. WRITE_UNALIGNED16((PUSHORT)(_Pointer) + 1, (((_Value) >> 16) & 0xFFFF))
  38. #define READ_UNALIGNED64(_Pointer) \
  39. (ULONGLONG)(READ_UNALIGNED32(_Pointer) | \
  40. (((ULONGLONG)READ_UNALIGNED32((PULONG)(_Pointer) + 1)) << 32))
  41. #define WRITE_UNALIGNED64(_Pointer, _Value) \
  42. WRITE_UNALIGNED32(_Pointer, (_Value) & 0xFFFFFFFF), \
  43. WRITE_UNALIGNED32((PULONG)(_Pointer) + 1, ((_Value) >> 32) & 0xFFFFFFFF)
  44. //
  45. // ---------------------------------------------------------------- Definitions
  46. //
  47. //
  48. // Set the GSI field of an interrupt lines description to this value to
  49. // indicate that this set of lines does not map to any corresponding GSI range.
  50. //
  51. #define INTERRUPT_LINES_GSI_NONE 0xFFFFFFFF
  52. //
  53. // Define the special controller identifier reserved for the CPU itself.
  54. //
  55. #define INTERRUPT_CPU_IDENTIFIER ((UINTN)-1L)
  56. //
  57. // Define the PC CPU interrupt pins.
  58. //
  59. #define INTERRUPT_CPU_LINE_NORMAL_INTERRUPT 0x00000000
  60. #define INTERRUPT_CPU_LINE_NMI 0x00000001
  61. #define INTERRUPT_CPU_LINE_SMI 0x00000002
  62. #define INTERRUPT_CPU_LINE_EXTINT 0x00000003
  63. #define INTERRUPT_PC_MIN_CPU_LINE INTERRUPT_CPU_LINE_NORMAL_INTERRUPT
  64. #define INTERRUPT_PC_MAX_CPU_LINE INTERRUPT_CPU_LINE_EXTINT + 1
  65. //
  66. // Define ARM CPU interrupt pins. Notice how the "normal" interrupt pin is
  67. // always at 0.
  68. //
  69. #define INTERRUPT_CPU_IRQ_PIN 0x00000000
  70. #define INTERRUPT_CPU_FIQ_PIN 0x00000001
  71. #define INTERRUPT_ARM_MIN_CPU_LINE INTERRUPT_CPU_IRQ_PIN
  72. #define INTERRUPT_ARM_MAX_CPU_LINE INTERRUPT_CPU_FIQ_PIN + 1
  73. //
  74. // Define the fixed vectors in the system. The spurious vector must end in 0xF
  75. // as some processors hardwire the lower four bits of the spurious vector
  76. // register.
  77. //
  78. #define VECTOR_SPURIOUS_INTERRUPT 0xFF
  79. #define VECTOR_LOCAL_ERROR 0xFC
  80. //
  81. // Processor description flags.
  82. //
  83. //
  84. // Set this flag if the processor is currently present and available to start.
  85. //
  86. #define PROCESSOR_DESCRIPTION_FLAG_PRESENT 0x00000001
  87. //
  88. // Timer feature flags.
  89. //
  90. //
  91. // Set this flag if the timer's hardware is duplicated across every processor:
  92. // that is, there is an independent timer for each processor.
  93. //
  94. #define TIMER_FEATURE_PER_PROCESSOR 0x00000001
  95. //
  96. // Set this flag if the timer's counter can be read. A readable timer is
  97. // expected to be accessible immediately after it's been initialized, and must
  98. // not generate interrupts or need to generate interrupts to handle rollovers.
  99. // If these conditions cannot be met, do not expose the timer as readable.
  100. //
  101. #define TIMER_FEATURE_READABLE 0x00000002
  102. //
  103. // Set this flag if the timer's counter can be written to. For per-processor
  104. // timers, this is expected to only write to the current processor's counter.
  105. //
  106. #define TIMER_FEATURE_WRITABLE 0x00000004
  107. //
  108. // Set this flag if the timer is capable of generating periodic interrupts.
  109. //
  110. #define TIMER_FEATURE_PERIODIC 0x00000008
  111. //
  112. // Set this flag if the timer is capable of generating one-shot interrupts.
  113. //
  114. #define TIMER_FEATURE_ONE_SHOT 0x00000010
  115. //
  116. // Set this flag if the timer's frequency varies with processor performance
  117. // changes, such as frequency scaling.
  118. //
  119. #define TIMER_FEATURE_P_STATE_VARIANT 0x00000020
  120. //
  121. // Set this flag if the timer stops when the processor is halted.
  122. //
  123. #define TIMER_FEATURE_C_STATE_VARIANT 0x00000040
  124. #define TIMER_FEATURE_VARIANT \
  125. (TIMER_FEATURE_P_STATE_VARIANT | TIMER_FEATURE_C_STATE_VARIANT)
  126. //
  127. // Set this flag only if this timer represents the official processor counter.
  128. // For PC platforms this would be the TSC, for ARM this would be the cycle
  129. // counter.
  130. //
  131. #define TIMER_FEATURE_PROCESSOR_COUNTER 0x00000080
  132. //
  133. // Set this flag if the timer is capable of generating interrupts based on an
  134. // absolute timer value.
  135. //
  136. #define TIMER_FEATURE_ABSOLUTE 0x00000100
  137. //
  138. // Define calendar timer features.
  139. //
  140. //
  141. // Set this flag if calls to write the calendar timer should pass a calendar
  142. // time representation rather than a system time representation.
  143. //
  144. #define CALENDAR_TIMER_FEATURE_WANT_CALENDAR_FORMAT 0x00000001
  145. //
  146. // Set this flag if the calendar timer must be written to at low runlevel. This
  147. // is true for timers that exist over busses like I2C.
  148. //
  149. #define CALENDAR_TIMER_FEATURE_LOW_RUNLEVEL 0x00000002
  150. //
  151. // Interrupt controller feature flags.
  152. //
  153. #define INTERRUPT_FEATURE_LOW_RUN_LEVEL 0x00000001
  154. //
  155. // Interrupt line state flags.
  156. //
  157. //
  158. // Set this flag if the interrupt line should be unmasked.
  159. //
  160. #define INTERRUPT_LINE_STATE_FLAG_ENABLED 0x00000001
  161. //
  162. // Set this flag if the interrupt should be delivered to the processor that
  163. // has the lowest hardware priority level.
  164. //
  165. #define INTERRUPT_LINE_STATE_FLAG_LOWEST_PRIORITY 0x00000002
  166. //
  167. // Set this flag if the interrupt is configured as a wake source.
  168. //
  169. #define INTERRUPT_LINE_STATE_FLAG_WAKE 0x00000004
  170. //
  171. // Set this flag to enable debouncing in the interrupt.
  172. //
  173. #define INTERRUPT_LINE_STATE_FLAG_DEBOUNCE 0x00000008
  174. //
  175. // Define the description table version numbers.
  176. //
  177. #define PROCESSOR_DESCRIPTION_VERSION 1
  178. #define INTERRUPT_LINES_DESCRIPTION_VERSION 1
  179. #define INTERRUPT_CONTROLLER_DESCRIPTION_VERSION 2
  180. #define TIMER_DESCRIPTION_VERSION 1
  181. #define DEBUG_DEVICE_DESCRIPTION_VERSION 1
  182. #define CALENDAR_TIMER_DESCRIPTION_VERSION 2
  183. #define CACHE_CONTROLLER_DESCRIPTION_VERSION 1
  184. //
  185. // Define the cache controller properties version.
  186. //
  187. #define CACHE_CONTROLLER_PROPERTIES_VERSION 1
  188. #define HL_CACHE_FLAG_CLEAN 0x00000001
  189. #define HL_CACHE_FLAG_INVALIDATE 0x00000002
  190. //
  191. // Define the reboot module table version.
  192. //
  193. #define REBOOT_MODULE_DESCRIPTION_VERSION 1
  194. //
  195. // Set this flag if the reboot controller needs to be called at low run level.
  196. // If clear, this routine will be called at or above dispatch.
  197. //
  198. #define REBOOT_MODULE_LOW_LEVEL 0x00000001
  199. //
  200. // ------------------------------------------------------ Data Type Definitions
  201. //
  202. typedef struct _INTERRUPT_CONTROLLER
  203. INTERRUPT_CONTROLLER, *PINTERRUPT_CONTROLLER;
  204. typedef enum _HARDWARE_MODULE_TYPE {
  205. HardwareModuleInvalid,
  206. HardwareModuleInterruptController,
  207. HardwareModuleInterruptLines,
  208. HardwareModuleTimer,
  209. HardwareModuleDebugDevice,
  210. HardwareModuleCalendarTimer,
  211. HardwareModuleCacheController,
  212. HardwareModuleDebugUsbHostController,
  213. HardwareModuleReboot,
  214. HardwareModuleMaxTypes,
  215. } HARDWARE_MODULE_TYPE, *PHARDWARE_MODULE_TYPE;
  216. typedef enum _TIMER_MODE {
  217. TimerModeInvalid,
  218. TimerModePeriodic,
  219. TimerModeOneShot,
  220. TimerModeAbsolute
  221. } TIMER_MODE, *PTIMER_MODE;
  222. typedef enum _INTERRUPT_MODE {
  223. InterruptModeUnknown,
  224. InterruptModeEdge,
  225. InterruptModeLevel,
  226. } INTERRUPT_MODE, *PINTERRUPT_MODE;
  227. typedef enum _INTERRUPT_ACTIVE_LEVEL {
  228. InterruptActiveLevelUnknown,
  229. InterruptActiveLow,
  230. InterruptActiveHigh,
  231. InterruptActiveBoth
  232. } INTERRUPT_ACTIVE_LEVEL, *PINTERRUPT_ACTIVE_LEVEL;
  233. typedef enum _INTERRUPT_LINE_TYPE {
  234. InterruptLineInvalid,
  235. InterruptLineGsi,
  236. InterruptLineControllerSpecified,
  237. } INTERRUPT_LINE_TYPE, *PINTERRUPT_LINE_TYPE;
  238. typedef enum _INTERRUPT_LINES_TYPE {
  239. InterruptLinesInvalid,
  240. InterruptLinesStandardPin,
  241. InterruptLinesProcessorLocal,
  242. InterruptLinesSoftwareOnly,
  243. InterruptLinesOutput,
  244. } INTERRUPT_LINES_TYPE, *PINTERRUPT_LINES_TYPE;
  245. typedef enum _INTERRUPT_ADDRESSING {
  246. InterruptAddressingInvalid,
  247. InterruptAddressingPhysical,
  248. InterruptAddressingLogicalFlat,
  249. InterruptAddressingLogicalClustered,
  250. InterruptAddressingAll,
  251. InterruptAddressingAllExcludingSelf,
  252. InterruptAddressingSelf
  253. } INTERRUPT_ADDRESSING, *PINTERRUPT_ADDRESSING;
  254. typedef enum _INTERRUPT_CAUSE {
  255. InterruptCauseNoInterruptHere,
  256. InterruptCauseLineFired,
  257. InterruptCauseSpuriousInterrupt
  258. } INTERRUPT_CAUSE, *PINTERRUPT_CAUSE;
  259. typedef enum _SYSTEM_RESET_TYPE {
  260. SystemResetInvalid,
  261. SystemResetShutdown,
  262. SystemResetWarm,
  263. SystemResetCold,
  264. SystemResetTypeCount
  265. } SYSTEM_RESET_TYPE, *PSYSTEM_RESET_TYPE;
  266. /*++
  267. Structure Description:
  268. This structure describes a high level lock. Users should not access or
  269. modify members of this structure directly, as its contents is subject to
  270. change without notice.
  271. Members:
  272. Value - Stores the value of the lock.
  273. WasEnabled - Stores an internal boolean indicating the previous interrupt
  274. state.
  275. --*/
  276. typedef struct _HARDWARE_MODULE_LOCK {
  277. ULONG Value;
  278. BOOL WasEnabled;
  279. } HARDWARE_MODULE_LOCK, *PHARDWARE_MODULE_LOCK;
  280. //
  281. // Interrupt controller structures.
  282. //
  283. /*++
  284. Structure Description:
  285. This structure is used to return information about an interrupt controller.
  286. Members:
  287. Controller - Stores a pointer to the controller itself, a kind of handle.
  288. StartingGsi - Stores the starting global system interrupt number of the
  289. controller.
  290. LineCount - Stores the number of lines in the interrupt controller.
  291. --*/
  292. typedef struct _INTERRUPT_CONTROLLER_INFORMATION {
  293. PINTERRUPT_CONTROLLER Controller;
  294. ULONG StartingGsi;
  295. ULONG LineCount;
  296. } INTERRUPT_CONTROLLER_INFORMATION, *PINTERRUPT_CONTROLLER_INFORMATION;
  297. /*++
  298. Structure Description:
  299. This structure defines an interrupt target as actually supported by the
  300. interrupt controller hardware.
  301. Members:
  302. Addressing - Stores the addressing mode of the interrupt.
  303. PhysicalId - Stores the physical ID of the processor being targeted, if the
  304. addressig mode is physical.
  305. LogicalFlatId - Stores the mask of processors being targeted if the
  306. addressing mode is logical flat.
  307. ClusterId - Stores the cluster identifier if the addressing is logical
  308. clustered.
  309. ClusterMask - Stores the mask of processors within the cluster if the
  310. addressing mode is logical clustered.
  311. --*/
  312. typedef struct _INTERRUPT_HARDWARE_TARGET {
  313. INTERRUPT_ADDRESSING Addressing;
  314. union {
  315. ULONG PhysicalId;
  316. ULONG LogicalFlatId;
  317. struct {
  318. ULONG Id;
  319. ULONG Mask;
  320. } Cluster;
  321. } U;
  322. } INTERRUPT_HARDWARE_TARGET, *PINTERRUPT_HARDWARE_TARGET;
  323. /*++
  324. Structure Description:
  325. This structure describes a processor. It is filled out by the hardware
  326. module to describe a processor to the system.
  327. Members:
  328. Version - Stores the version number of this table as understood by the
  329. hardware module. Set this to PROCESSOR_DESCRIPTION_VERSION.
  330. PhysicalId - Stores the processor identifier number. This number will be
  331. referred to by the system when communicating with the hardware module
  332. about a processor.
  333. LogicalFlatId - Stores the logical flat processor ID to use as a processor
  334. target. Set to 0 if logical flat mode is not supported or not supported
  335. for this processor.
  336. FirmwareIdentifier - Stores the processor identifier number used by the
  337. firmware. This number may or may not be the same as the hardware
  338. identifier.
  339. Flags - Stores a set of flags relating to the processor. See
  340. PROCESSOR_DESCRIPTION_FLAG_* definitions for valid values here.
  341. ParkedPhysicalAddress - Stores the physical address where this core has been
  342. parked.
  343. --*/
  344. typedef struct _PROCESSOR_DESCRIPTION {
  345. ULONG Version;
  346. ULONG PhysicalId;
  347. ULONG LogicalFlatId;
  348. ULONG FirmwareIdentifier;
  349. ULONG Flags;
  350. PHYSICAL_ADDRESS ParkedPhysicalAddress;
  351. } PROCESSOR_DESCRIPTION, *PPROCESSOR_DESCRIPTION;
  352. /*++
  353. Structure Description:
  354. This structure describes a set of one or more interrupt lines.
  355. Members:
  356. Version - Stores the version number of this table as understood by the
  357. hardware module. Set this to INTERRUPT_LINES_DESCRIPTION_VERSION.
  358. Type - Stores the general classification for this set of interrupt lines.
  359. Controller - Stores the controller ID for the controller these lines belong
  360. to.
  361. LineStart - Stores the first line, inclusive, of the line segment being
  362. described.
  363. LineEnd - Stores one beyond the last line (aka exclusive) of the line
  364. segment being described.
  365. Gsi - Stores the GSI base for this range. The GSI number in this member
  366. corresponds to the interrupt line at LineStart. The GSI numbers go up
  367. consecutively through the rest of the segment. Specify
  368. INTERRUPT_LINES_GSI_NONE to indicate that the line segment has no GSI
  369. mapping.
  370. OutputControllerIdentifer - Supplies the identifier of the controller this
  371. line segment refers to. This field is only valid for output line
  372. segments, as the lines refer to the destination controller's source
  373. lines.
  374. --*/
  375. typedef struct _INTERRUPT_LINES_DESCRIPTION {
  376. ULONG Version;
  377. INTERRUPT_LINES_TYPE Type;
  378. UINTN Controller;
  379. LONG LineStart;
  380. LONG LineEnd;
  381. ULONG Gsi;
  382. UINTN OutputControllerIdentifier;
  383. } INTERRUPT_LINES_DESCRIPTION, *PINTERRUPT_LINES_DESCRIPTION;
  384. /*++
  385. Structure Description:
  386. This structure describes an interrupt line.
  387. Members:
  388. Type - Stores the classification method used to identify the interrupt line.
  389. Gsi - Stores the global system interrupt number of the interrupt line. Used
  390. when the classification type is GSI.
  391. Controller - Stores the identifier of the controller on which the line
  392. exists. Used when the classification type is Controller specified.
  393. Line - Stores the line number. Negative numbers may be valid here. Used when
  394. the classification type is Controller specified.
  395. --*/
  396. typedef struct _INTERRUPT_LINE {
  397. INTERRUPT_LINE_TYPE Type;
  398. union {
  399. ULONG Gsi;
  400. struct {
  401. UINTN Controller;
  402. LONG Line;
  403. } Local;
  404. } U;
  405. } INTERRUPT_LINE, *PINTERRUPT_LINE;
  406. /*++
  407. Structure Description:
  408. This structure describes the state of an interrupt line.
  409. Members:
  410. Mode - Stores the interrupt trigger mode of the line.
  411. Polarity - Stores the polarity of the interrupt line.
  412. Flags - Stores a bitfield of flags governing the state of the interrupt
  413. line. See INTERRUPT_LINE_STATE_FLAG_* definitions.
  414. Vector - Stores the vector that this interrupt operates on.
  415. Target - Stores the set of processors to target this interrupt line at.
  416. Output - Stores the output line that this interrupt should output to.
  417. HardwarePriority - Stores a pointer to the hardware priority level this
  418. interrupt should be enabled at.
  419. --*/
  420. typedef struct _INTERRUPT_LINE_STATE {
  421. INTERRUPT_MODE Mode;
  422. INTERRUPT_ACTIVE_LEVEL Polarity;
  423. ULONG Flags;
  424. ULONG Vector;
  425. INTERRUPT_HARDWARE_TARGET Target;
  426. INTERRUPT_LINE Output;
  427. ULONG HardwarePriority;
  428. } INTERRUPT_LINE_STATE, *PINTERRUPT_LINE_STATE;
  429. //
  430. // Timer structures.
  431. //
  432. /*++
  433. Structure Description:
  434. This structure describes a timer's interrupt information.
  435. Members:
  436. Line - Stores which interrupt line the timer fires on.
  437. TriggerMode - Stores the trigger mode. Set to unknown to use the default
  438. mode for the interrupt line.
  439. ActiveLevel - Stores the active line level. Set to unknown to use the
  440. default line level for the interrupt controller.
  441. --*/
  442. typedef struct _TIMER_INTERRUPT {
  443. INTERRUPT_LINE Line;
  444. INTERRUPT_MODE TriggerMode;
  445. INTERRUPT_ACTIVE_LEVEL ActiveLevel;
  446. } TIMER_INTERRUPT, *PTIMER_INTERRUPT;
  447. //
  448. // Calendar time provider functions.
  449. //
  450. /*++
  451. Structure Description:
  452. This structure describes an absolute wall clock time as provided to or
  453. from a calendar time hardware module.
  454. Members:
  455. IsCalendarTime - Stores a boolean indicating if the calendar time is
  456. valid for this structure (TRUE) or the system time (FALSE).
  457. CalendarTime - Stores the calendar time to get or set.
  458. SystemTime - Stores the system time to get or set.
  459. --*/
  460. typedef struct _HARDWARE_MODULE_TIME {
  461. BOOL IsCalendarTime;
  462. union {
  463. CALENDAR_TIME CalendarTime;
  464. SYSTEM_TIME SystemTime;
  465. } U;
  466. } HARDWARE_MODULE_TIME, *PHARDWARE_MODULE_TIME;
  467. /*++
  468. Structure Description:
  469. This structure describes the information for a message signaled interrupt
  470. that is to be retrieved from the hardware layer.
  471. Members:
  472. Address - Stores the physical address to which the MSI/MSI-X data is to be
  473. written when the interrupt is triggered.
  474. Data - Stores the data to write to the physical address when the MSI/MSI-X
  475. interrupt is triggered.
  476. --*/
  477. typedef struct _MSI_INFORMATION {
  478. PHYSICAL_ADDRESS Address;
  479. ULONGLONG Data;
  480. } MSI_INFORMATION, *PMSI_INFORMATION;
  481. //
  482. // Interrupt controller functions.
  483. //
  484. typedef
  485. KSTATUS
  486. (*PINTERRUPT_ENUMERATE_PROCESSORS) (
  487. PVOID Context,
  488. PPROCESSOR_DESCRIPTION Descriptions,
  489. ULONG DescriptionsBufferSize
  490. );
  491. /*++
  492. Routine Description:
  493. This routine describes all processors under the jurisdiction of an interrupt
  494. controller.
  495. Arguments:
  496. Context - Supplies the pointer to the controller's context, provided by the
  497. hardware module upon initialization.
  498. Descriptions - Supplies a pointer to a buffer of an array of processor
  499. descriptions that the hardware module is expected to fill out on
  500. success. The number of entries in the array is the number of processors
  501. reported during the interrupt controller registration.
  502. DescriptionBufferSize - Supplies the size of the buffer passed. The hardware
  503. module should fail the routine if the buffer size is smaller than
  504. expected, but should not fail if the buffer size is larger than
  505. expected.
  506. Return Value:
  507. STATUS_SUCCESS on success. The Descriptions buffer will contain
  508. descriptions of all processors under the jurisdiction of the given
  509. interrupt controller.
  510. Other status codes on failure. The contents of the Descriptions buffer is
  511. undefined.
  512. --*/
  513. typedef
  514. KSTATUS
  515. (*PINTERRUPT_INITIALIZE_LOCAL_UNIT) (
  516. PVOID Context,
  517. PULONG Identifier
  518. );
  519. /*++
  520. Routine Description:
  521. This routine initializes the local unit of an interrupt controller. It is
  522. always called on the processor of the local unit to initialize.
  523. Arguments:
  524. Context - Supplies the pointer to the context of the I/O unit that owns
  525. this processor, provided by the hardware module upon initialization.
  526. Identifier - Supplies a pointer where this function will return the
  527. identifier of the processor being initialized.
  528. Return Value:
  529. STATUS_SUCCESS on success.
  530. Other status codes on failure.
  531. --*/
  532. typedef
  533. KSTATUS
  534. (*PINTERRUPT_INITIALIZE_IO_UNIT) (
  535. PVOID Context
  536. );
  537. /*++
  538. Routine Description:
  539. This routine initializes an interrupt controller. It's responsible for
  540. masking all interrupt lines on the controller and setting the current
  541. priority to the lowest (allow all interrupts). Once completed successfully,
  542. it is expected that interrupts can be enabled at the processor core with
  543. no interrupts occurring.
  544. Arguments:
  545. Context - Supplies the pointer to the controller's context, provided by the
  546. hardware module upon initialization.
  547. Return Value:
  548. STATUS_SUCCESS on success.
  549. Other status codes on failure.
  550. --*/
  551. typedef
  552. KSTATUS
  553. (*PINTERRUPT_SET_LOCAL_UNIT_ADDRESSING) (
  554. PVOID Context,
  555. PINTERRUPT_HARDWARE_TARGET Target
  556. );
  557. /*++
  558. Routine Description:
  559. This routine attempts to set the current processor's addressing mode.
  560. Arguments:
  561. Context - Supplies the pointer to the controller's context, provided by the
  562. hardware module upon initialization.
  563. Target - Supplies a pointer to the targeting configuration to set for this
  564. processor.
  565. Return Value:
  566. STATUS_SUCCESS on success.
  567. STATUS_UNSUCCESSFUL if the operation failed.
  568. STATUS_NOT_SUPPORTED if this configuration is never supported on this
  569. hardware.
  570. --*/
  571. typedef
  572. INTERRUPT_CAUSE
  573. (*PINTERRUPT_BEGIN) (
  574. PVOID Context,
  575. PINTERRUPT_LINE FiringLine,
  576. PULONG MagicCandy
  577. );
  578. /*++
  579. Routine Description:
  580. This routine is called when an interrupt fires. Its role is to determine
  581. if an interrupt has fired on the given controller, accept it, and determine
  582. which line fired if any. This routine will always be called with interrupts
  583. disabled at the processor core.
  584. Arguments:
  585. Context - Supplies the pointer to the controller's context, provided by the
  586. hardware module upon initialization.
  587. FiringLine - Supplies a pointer where the interrupt hardware module will
  588. fill in which line fired, if applicable.
  589. MagicCandy - Supplies a pointer where the interrupt hardware module can
  590. store 32 bits of private information regarding this interrupt. This
  591. information will be returned to it when the End Of Interrupt routine
  592. is called.
  593. Return Value:
  594. Returns an interrupt cause indicating whether or not an interrupt line,
  595. spurious interrupt, or no interrupt fired on this controller.
  596. --*/
  597. typedef
  598. VOID
  599. (*PINTERRUPT_FAST_END_OF_INTERRUPT) (
  600. VOID
  601. );
  602. /*++
  603. Routine Description:
  604. This routine signals to the interrupt controller hardware that servicing
  605. of the highest priority interrupt line has been completed. This routine
  606. will always be called with interrupts disabled at the processor core.
  607. Arguments:
  608. None.
  609. Return Value:
  610. None.
  611. --*/
  612. typedef
  613. VOID
  614. (*PINTERRUPT_END_OF_INTERRUPT) (
  615. PVOID Context,
  616. ULONG MagicCandy
  617. );
  618. /*++
  619. Routine Description:
  620. This routine is called after an interrupt has fired and been serviced. Its
  621. role is to tell the interrupt controller that processing has completed.
  622. This routine will always be called with interrupts disabled at the
  623. processor core.
  624. Arguments:
  625. Context - Supplies the pointer to the controller's context, provided by the
  626. hardware module upon initialization.
  627. MagicCandy - Supplies the magic candy that that the interrupt hardware
  628. module stored when the interrupt began.
  629. Return Value:
  630. None.
  631. --*/
  632. typedef
  633. KSTATUS
  634. (*PINTERRUPT_REQUEST_INTERRUPT) (
  635. PVOID Context,
  636. PINTERRUPT_LINE Line,
  637. ULONG Vector,
  638. PINTERRUPT_HARDWARE_TARGET Target
  639. );
  640. /*++
  641. Routine Description:
  642. This routine requests a hardware interrupt on the given line.
  643. Arguments:
  644. Context - Supplies the pointer to the controller's context, provided by the
  645. hardware module upon initialization.
  646. Line - Supplies a pointer to the interrupt line to spark.
  647. Vector - Supplies the vector to generate the interrupt on (for vectored
  648. architectures only).
  649. Target - Supplies a pointer to the set of processors to target.
  650. Return Value:
  651. STATUS_SUCCESS on success.
  652. Error code on failure.
  653. --*/
  654. typedef
  655. KSTATUS
  656. (*PINTERRUPT_START_PROCESSOR) (
  657. PVOID Context,
  658. ULONG Identifier,
  659. PHYSICAL_ADDRESS JumpAddressPhysical
  660. );
  661. /*++
  662. Routine Description:
  663. This routine sends a "start interrupt" to the given processor.
  664. Arguments:
  665. Context - Supplies the pointer to the controller's context, provided by the
  666. hardware module upon initialization.
  667. Identifier - Supplies the identifier of the processor to start.
  668. JumpAddressPhysical - Supplies the physical address of the location that
  669. new processor should jump to.
  670. Return Value:
  671. STATUS_SUCCESS if the start command was successfully sent.
  672. Error code on failure.
  673. --*/
  674. typedef
  675. KSTATUS
  676. (*PINTERRUPT_SET_LINE_STATE) (
  677. PVOID Context,
  678. PINTERRUPT_LINE Line,
  679. PINTERRUPT_LINE_STATE State,
  680. PVOID ResourceData,
  681. UINTN ResourceDataSize
  682. );
  683. /*++
  684. Routine Description:
  685. This routine enables or disables and configures an interrupt line.
  686. Arguments:
  687. Context - Supplies the pointer to the controller's context, provided by the
  688. hardware module upon initialization.
  689. Line - Supplies a pointer to the line to set up. This will always be a
  690. controller specified line.
  691. State - Supplies a pointer to the new configuration of the line.
  692. ResourceData - Supplies an optional pointer to the device specific resource
  693. data for the interrupt line.
  694. ResourceDataSize - Supplies the size of the resource data, in bytes.
  695. Return Value:
  696. Status code.
  697. --*/
  698. typedef
  699. KSTATUS
  700. (*PINTERRUPT_GET_MESSAGE_INFORMATION) (
  701. ULONGLONG Vector,
  702. ULONGLONG VectorCount,
  703. PINTERRUPT_HARDWARE_TARGET Target,
  704. PINTERRUPT_LINE OutputLine,
  705. ULONG Flags,
  706. PMSI_INFORMATION Information
  707. );
  708. /*++
  709. Routine Description:
  710. This routine gathers the appropriate MSI/MSI-X address and data information
  711. for the given set of contiguous interrupt vectors.
  712. Arguments:
  713. Vector - Supplies the first vector for which information is being requested.
  714. VectorCount - Supplies the number of contiguous vectors for which
  715. information is being requested.
  716. Target - Supplies a pointer to the set of processors to target.
  717. OutputLine - Supplies the output line this interrupt line should interrupt
  718. to.
  719. Flags - Supplies a bitfield of flags about the operation. See
  720. INTERRUPT_LINE_STATE_FLAG_* definitions.
  721. Information - Supplies a pointer to an array of MSI/MSI-X information to
  722. be filled in by the routine.
  723. Return Value:
  724. Status code.
  725. --*/
  726. typedef
  727. VOID
  728. (*PINTERRUPT_MASK_LINE) (
  729. PVOID Context,
  730. PINTERRUPT_LINE Line,
  731. BOOL Enable
  732. );
  733. /*++
  734. Routine Description:
  735. This routine masks or unmasks an interrupt line, leaving the rest of the
  736. line state intact.
  737. Arguments:
  738. Context - Supplies the pointer to the controller's context, provided by the
  739. hardware module upon initialization.
  740. Line - Supplies a pointer to the line to maek or unmask. This will always
  741. be a controller specified line.
  742. Enable - Supplies a boolean indicating whether to mask the interrupt,
  743. preventing interrupts from coming through (FALSE), or enable the line
  744. and allow interrupts to come through (TRUE).
  745. Return Value:
  746. None.
  747. --*/
  748. typedef
  749. KSTATUS
  750. (*PINTERRUPT_SAVE_STATE) (
  751. PVOID Context,
  752. PVOID Buffer
  753. );
  754. /*++
  755. Routine Description:
  756. This routine saves the current state of the interrupt controller, which
  757. may lost momentarily in the hardware due to a power transition. Multiple
  758. save functions may be called in a row. If a transition is abandoned, the
  759. restore function is not called.
  760. Arguments:
  761. Context - Supplies the pointer to the controller's context, provided by the
  762. hardware module upon initialization.
  763. Buffer - Supplies a pointer to the save buffer for this processor, the
  764. size of which was reported during registration.
  765. Return Value:
  766. Status code.
  767. --*/
  768. typedef
  769. KSTATUS
  770. (*PINTERRUPT_RESTORE_STATE) (
  771. PVOID Context,
  772. PVOID Buffer
  773. );
  774. /*++
  775. Routine Description:
  776. This routine restores the previous state of the interrupt controller.
  777. Arguments:
  778. Context - Supplies the pointer to the controller's context, provided by the
  779. hardware module upon initialization.
  780. Buffer - Supplies a pointer to the save buffer for this processor, the
  781. size of which was reported during registration.
  782. Return Value:
  783. Status code.
  784. --*/
  785. /*++
  786. Structure Description:
  787. This structure describes the API of a hardware module. It is passed by the
  788. hardware module to the kernel during registration to supply pointers to the
  789. hardware module's functionality.
  790. Members:
  791. InitializeIoUnit - Stores a pointer to a function that initializes
  792. an interrupt controller.
  793. SetLineState - Stores a pointer to a fucntion that configures an interrupt
  794. line.
  795. MaskLine - Stores a pointer to a function used to mask and unmask
  796. interrupt lines (without altering the remaining line state).
  797. BeginInterrupt - Stores a pointer to a function that is called when an
  798. interrupt fires.
  799. FastEndOfInterrupt - Stores a pointer to a function that sends an End Of
  800. Interrupt command to the interrupt controller, signaling the end of
  801. servicing the highest priority line in service. The only difference
  802. between this routine and the normal end of interrupt routine is that
  803. this one takes no parameters. If this routine is supplied, it will
  804. always be used instead of the normal end of interrupt routine.
  805. EndOfInterrupt - Stores a pointer to a function that sends an End Of
  806. Interrupt command to the interrupt controller, singaling the end of
  807. servicing the highest priority line in service.
  808. RequestInterrupt - Stores a pointer to a function that requests a hardware
  809. interrupt on the given line.
  810. EnumerateProcessors - Stores a pointer to a function that describes a set of
  811. processors to the system.
  812. InitializeLocalUnit - Stores a pointer to a function that initializes the
  813. processor-local portion of an interrupt controller. This routine is
  814. called once on each processor during boot and after descructive idle
  815. states.
  816. SetLocalUnitAddressing - Stores a pointer to a function that sets the
  817. destination addressing mode for the current processor.
  818. StartProcessor - Stores a pointer to a function that starts another
  819. processor.
  820. GetMessageInformation - Stores a pointer to a function used to get MSI
  821. message address and data pairs, for controllers that support Message
  822. Signaled Interrupts.
  823. SaveState - Stores a pointer to a function used to save the interrupt
  824. controller state in preparation for a context loss (power transition).
  825. RestoreState - Stores a pointer to a function used to restore previously
  826. saved interrupt controller state after a power transition.
  827. --*/
  828. typedef struct _INTERRUPT_FUNCTION_TABLE {
  829. PINTERRUPT_INITIALIZE_IO_UNIT InitializeIoUnit;
  830. PINTERRUPT_SET_LINE_STATE SetLineState;
  831. PINTERRUPT_MASK_LINE MaskLine;
  832. PINTERRUPT_BEGIN BeginInterrupt;
  833. PINTERRUPT_FAST_END_OF_INTERRUPT FastEndOfInterrupt;
  834. PINTERRUPT_END_OF_INTERRUPT EndOfInterrupt;
  835. PINTERRUPT_REQUEST_INTERRUPT RequestInterrupt;
  836. PINTERRUPT_ENUMERATE_PROCESSORS EnumerateProcessors;
  837. PINTERRUPT_INITIALIZE_LOCAL_UNIT InitializeLocalUnit;
  838. PINTERRUPT_SET_LOCAL_UNIT_ADDRESSING SetLocalUnitAddressing;
  839. PINTERRUPT_START_PROCESSOR StartProcessor;
  840. PINTERRUPT_GET_MESSAGE_INFORMATION GetMessageInformation;
  841. PINTERRUPT_SAVE_STATE SaveState;
  842. PINTERRUPT_RESTORE_STATE RestoreState;
  843. } INTERRUPT_FUNCTION_TABLE, *PINTERRUPT_FUNCTION_TABLE;
  844. //
  845. // Timer functions.
  846. //
  847. typedef
  848. KSTATUS
  849. (*PTIMER_INITIALIZE) (
  850. PVOID Context
  851. );
  852. /*++
  853. Routine Description:
  854. This routine initializes a timer and puts it into a known state. Once
  855. initialized, the timer should not be generating interrupts. If it has a
  856. readable counter, the counter should be counting after the initialize call
  857. has returned. This routine will be called once on boot and after any idle
  858. state transition that is destructive to the timer.
  859. Arguments:
  860. Context - Supplies the pointer to the timer's context, provided by the
  861. hardware module upon initialization.
  862. Return Value:
  863. STATUS_SUCCESS on success.
  864. Other status codes on failure. The timer will not be used if a failure
  865. status code is returned.
  866. --*/
  867. typedef
  868. ULONGLONG
  869. (*PTIMER_READ_COUNTER) (
  870. PVOID Context
  871. );
  872. /*++
  873. Routine Description:
  874. This routine returns the hardware counter's raw value. All unimplemented
  875. bits should be set to 0. This routine will only be called for timers that
  876. have set the readable counter feature bit. The system assumes that all
  877. timers count up. If the hardware actually counts down, the implementation
  878. of this routine should do a subtraction from the maximum value to make it
  879. appear as though the timer counts up.
  880. Arguments:
  881. Context - Supplies the pointer to the timer's context, provided by the
  882. hardware module upon initialization.
  883. Return Value:
  884. Returns the timer's current count.
  885. --*/
  886. typedef
  887. VOID
  888. (*PTIMER_WRITE_COUNTER) (
  889. PVOID Context,
  890. ULONGLONG NewCount
  891. );
  892. /*++
  893. Routine Description:
  894. This routine writes to the timer's hardware counter. This routine will
  895. only be called for timers that have the writable counter feature bit set.
  896. Arguments:
  897. Context - Supplies the pointer to the timer's context, provided by the
  898. hardware module upon initialization.
  899. NewCount - Supplies the value to write into the counter. It is expected that
  900. the counter will not stop after the write.
  901. Return Value:
  902. None.
  903. --*/
  904. typedef
  905. KSTATUS
  906. (*PTIMER_ARM) (
  907. PVOID Context,
  908. TIMER_MODE Mode,
  909. ULONGLONG TickCount
  910. );
  911. /*++
  912. Routine Description:
  913. This routine arms the timer to fire an interrupt after the specified number
  914. of ticks. It is expected that arming the timer may alter the timeline of
  915. the counter.
  916. Arguments:
  917. Context - Supplies the pointer to the timer's context, provided by the
  918. hardware module upon initialization.
  919. Mode - Supplies the mode to arm the timer in. The system will never request
  920. a mode not supported by the timer's feature bits. The mode dictates
  921. how the tick count argument is interpreted.
  922. TickCount - Supplies the interval, in ticks, from now for the timer to fire
  923. in.
  924. Return Value:
  925. STATUS_SUCCESS on success.
  926. Other error codes on failure. The timer will be considered in a failed
  927. state and will no longer be used if a failure code is returned here.
  928. --*/
  929. typedef
  930. VOID
  931. (*PTIMER_DISARM) (
  932. PVOID Context
  933. );
  934. /*++
  935. Routine Description:
  936. This routine disarms the timer, stopping interrupts from firing.
  937. Arguments:
  938. Context - Supplies the pointer to the timer's context, provided by the
  939. hardware module upon initialization.
  940. Return Value:
  941. None.
  942. --*/
  943. typedef
  944. VOID
  945. (*PTIMER_ACKNOWLEDGE_INTERRUPT) (
  946. PVOID Context
  947. );
  948. /*++
  949. Routine Description:
  950. This routine performs any actions necessary upon reciept of a timer's
  951. interrupt. This may involve writing to an acknowledge register to re-enable
  952. the timer to fire again, or other hardware specific actions.
  953. Arguments:
  954. Context - Supplies the pointer to the timer's context, provided by the
  955. hardware module upon initialization.
  956. Return Value:
  957. None.
  958. --*/
  959. /*++
  960. Structure Description:
  961. This structure describes the API of a timer module. It is passed by the
  962. hardware module to the kernel during registration to supply pointers to the
  963. hardware module's functionality.
  964. Members:
  965. Initialize - Stores a pointer to a function that initializes a timer,
  966. making it non-interrupting and getting the counter ticking.
  967. ReadCounter - Stores a pointer to a function that reads the current count
  968. from the timer.
  969. WriteCounter - Stores a pointer to a function that writes a new count to
  970. the timer.
  971. Arm - Stores a pointer to a function that arms the timer to fire an
  972. interrupt at a given number of ticks from now.
  973. AcknowledgeInterrupt - Stores an optional pointer to a function that
  974. performs hardware specific actions in response to an interrupt.
  975. --*/
  976. typedef struct _TIMER_FUNCTION_TABLE {
  977. PTIMER_INITIALIZE Initialize;
  978. PTIMER_READ_COUNTER ReadCounter;
  979. PTIMER_WRITE_COUNTER WriteCounter;
  980. PTIMER_ARM Arm;
  981. PTIMER_DISARM Disarm;
  982. PTIMER_ACKNOWLEDGE_INTERRUPT AcknowledgeInterrupt;
  983. } TIMER_FUNCTION_TABLE, *PTIMER_FUNCTION_TABLE;
  984. //
  985. // Debug device functions.
  986. //
  987. typedef
  988. KSTATUS
  989. (*PDEBUG_DEVICE_RESET) (
  990. PVOID Context,
  991. ULONG BaudRate
  992. );
  993. /*++
  994. Routine Description:
  995. This routine initializes and resets a debug device, preparing it to send
  996. and receive data.
  997. Arguments:
  998. Context - Supplies the pointer to the port's context, provided by the
  999. hardware module upon initialization.
  1000. BaudRate - Supplies the baud rate to set.
  1001. Return Value:
  1002. STATUS_SUCCESS on success.
  1003. Other status codes on failure. The device will not be used if a failure
  1004. status code is returned.
  1005. --*/
  1006. typedef
  1007. KSTATUS
  1008. (*PDEBUG_DEVICE_TRANSMIT) (
  1009. PVOID Context,
  1010. PVOID Data,
  1011. ULONG Size
  1012. );
  1013. /*++
  1014. Routine Description:
  1015. This routine transmits data from the host out through the debug device.
  1016. Arguments:
  1017. Context - Supplies the pointer to the port's context, provided by the
  1018. hardware module upon initialization.
  1019. Data - Supplies a pointer to the data to write.
  1020. Size - Supplies the size to write, in bytes.
  1021. Return Value:
  1022. STATUS_SUCCESS on success.
  1023. STATUS_DEVICE_IO_ERROR if a device error occurred.
  1024. --*/
  1025. typedef
  1026. KSTATUS
  1027. (*PDEBUG_DEVICE_RECEIVE) (
  1028. PVOID Context,
  1029. PVOID Data,
  1030. PULONG Size
  1031. );
  1032. /*++
  1033. Routine Description:
  1034. This routine receives incoming data from the debug device. If no data is
  1035. available, this routine should return immediately. If only some of the
  1036. requested data is available, this routine should return the data that can
  1037. be obtained now and return.
  1038. Arguments:
  1039. Context - Supplies the pointer to the port's context, provided by the
  1040. hardware module upon initialization.
  1041. Data - Supplies a pointer where the read data will be returned on success.
  1042. Size - Supplies a pointer that on input contains the size of the receive
  1043. buffer. On output, returns the number of bytes read.
  1044. Return Value:
  1045. STATUS_SUCCESS on success.
  1046. STATUS_NO_DATA_AVAILABLE if there was no data to be read at the current
  1047. time.
  1048. STATUS_DEVICE_IO_ERROR if a device error occurred.
  1049. --*/
  1050. typedef
  1051. KSTATUS
  1052. (*PDEBUG_DEVICE_GET_STATUS) (
  1053. PVOID Context,
  1054. PBOOL ReceiveDataAvailable
  1055. );
  1056. /*++
  1057. Routine Description:
  1058. This routine returns the current device status.
  1059. Arguments:
  1060. Context - Supplies the pointer to the port's context, provided by the
  1061. hardware module upon initialization.
  1062. ReceiveDataAvailable - Supplies a pointer where a boolean will be returned
  1063. indicating whether or not receive data is available.
  1064. Return Value:
  1065. Status code.
  1066. --*/
  1067. typedef
  1068. VOID
  1069. (*PDEBUG_DEVICE_DISCONNECT) (
  1070. PVOID Context
  1071. );
  1072. /*++
  1073. Routine Description:
  1074. This routine disconnects a device, taking it offline.
  1075. Arguments:
  1076. Context - Supplies the pointer to the port's context, provided by the
  1077. hardware module upon initialization.
  1078. Return Value:
  1079. None.
  1080. --*/
  1081. /*++
  1082. Structure Description:
  1083. This structure describes the API of a debug device.
  1084. Members:
  1085. Reset - Stores a pointer to a function used to reset and initialize the
  1086. device.
  1087. Transmit - Stores a pointer to a function used to transmit data out from
  1088. the debug device.
  1089. Receive - Stores a pointer to a function used to receive data from the
  1090. debug device.
  1091. GetStatus - Stores a pointer to a function used to get the status of the
  1092. device.
  1093. Disconnect - Stores a pointer to a function called when the debug
  1094. connection is being dropped. If it is re-established, Reset will be
  1095. called.
  1096. --*/
  1097. typedef struct _DEBUG_DEVICE_FUNCTION_TABLE {
  1098. PDEBUG_DEVICE_RESET Reset;
  1099. PDEBUG_DEVICE_TRANSMIT Transmit;
  1100. PDEBUG_DEVICE_RECEIVE Receive;
  1101. PDEBUG_DEVICE_GET_STATUS GetStatus;
  1102. PDEBUG_DEVICE_DISCONNECT Disconnect;
  1103. } DEBUG_DEVICE_FUNCTION_TABLE, *PDEBUG_DEVICE_FUNCTION_TABLE;
  1104. //
  1105. // Calendar time functions.
  1106. //
  1107. typedef
  1108. KSTATUS
  1109. (*PCALENDAR_TIMER_INITIALIZE) (
  1110. PVOID Context
  1111. );
  1112. /*++
  1113. Routine Description:
  1114. This routine initializes a calendar timer so that it may be ready for
  1115. read and write calls.
  1116. Arguments:
  1117. Context - Supplies the pointer to the timer's context, provided by the
  1118. hardware module upon initialization.
  1119. Return Value:
  1120. STATUS_SUCCESS on success.
  1121. Other status codes on failure. The timer will not be used if a failure
  1122. status code is returned.
  1123. --*/
  1124. typedef
  1125. KSTATUS
  1126. (*PCALENDAR_TIMER_READ) (
  1127. PVOID Context,
  1128. PHARDWARE_MODULE_TIME CurrentTime
  1129. );
  1130. /*++
  1131. Routine Description:
  1132. This routine returns the calendar timer's current value.
  1133. Arguments:
  1134. Context - Supplies the pointer to the timer's context, provided by the
  1135. hardware module upon initialization.
  1136. CurrentTime - Supplies a pointer where the read current time will be
  1137. returned.
  1138. Return Value:
  1139. STATUS_SUCCESS on success.
  1140. Other status codes on failure.
  1141. --*/
  1142. typedef
  1143. KSTATUS
  1144. (*PCALENDAR_TIMER_WRITE) (
  1145. PVOID Context,
  1146. PHARDWARE_MODULE_TIME NewTime
  1147. );
  1148. /*++
  1149. Routine Description:
  1150. This routine writes to the calendar timer.
  1151. Arguments:
  1152. Context - Supplies the pointer to the timer's context, provided by the
  1153. hardware module upon initialization.
  1154. NewTime - Supplies a pointer to the new time to set. The hardware module
  1155. should set this as quickly as possible. The system will supply either
  1156. a calendar time or a system time in here based on which type the timer
  1157. requested at registration.
  1158. Return Value:
  1159. STATUS_SUCCESS on success.
  1160. Other status codes on failure.
  1161. --*/
  1162. /*++
  1163. Structure Description:
  1164. This structure describes the API of a calendar timer hardware module. It is
  1165. passed by the hardware module to the kernel during registration to supply
  1166. pointers to the hardware module's functionality.
  1167. Members:
  1168. Initialize - Stores a pointer to a function used to initialize the unit.
  1169. Read - Stores a pointer to a function that returns the current calendar
  1170. time from the timer.
  1171. Write - Stores a pointer to a function that sets the current calendar time
  1172. in the timer.
  1173. --*/
  1174. typedef struct _CALENDAR_TIMER_FUNCTION_TABLE {
  1175. PCALENDAR_TIMER_INITIALIZE Initialize;
  1176. PCALENDAR_TIMER_READ Read;
  1177. PCALENDAR_TIMER_WRITE Write;
  1178. } CALENDAR_TIMER_FUNCTION_TABLE, *PCALENDAR_TIMER_FUNCTION_TABLE;
  1179. //
  1180. // Cache controller structures.
  1181. //
  1182. /*++
  1183. Structure Description:
  1184. This structure describes the properties of a cache controller.
  1185. Members:
  1186. Version - Stores the version of the cache controller properties structure.
  1187. The system will set this to the version number it is expecting when
  1188. querying properties. The hardware module should fail if it does not
  1189. support the requested version (e.g. a version greater than its version).
  1190. DataCacheLineSize - Stores the size of a data cache line in bytes.
  1191. InstructionCacheLineSize - Stores the size of an instruction cache line in
  1192. bytes.
  1193. CacheSize - Stores the size of the cache in bytes.
  1194. --*/
  1195. typedef struct _CACHE_CONTROLLER_PROPERTIES {
  1196. ULONG Version;
  1197. ULONG DataCacheLineSize;
  1198. ULONG InstructionCacheLineSize;
  1199. ULONG CacheSize;
  1200. } CACHE_CONTROLLER_PROPERTIES, *PCACHE_CONTROLLER_PROPERTIES;
  1201. //
  1202. // Cache controller functions.
  1203. //
  1204. typedef
  1205. KSTATUS
  1206. (*PCACHE_CONTROLLER_INITIALIZE) (
  1207. PVOID Context
  1208. );
  1209. /*++
  1210. Routine Description:
  1211. This routine initializes a cache controller to enable the cache and prepare
  1212. it for clean and invalidate calls.
  1213. Arguments:
  1214. Context - Supplies the pointer to the cache controller's context, provided
  1215. by the hardware module upon initialization.
  1216. Return Value:
  1217. STATUS_SUCCESS on success.
  1218. Other status codes on failure. The cache controller will not be used if a
  1219. failure status code is returned.
  1220. --*/
  1221. typedef
  1222. VOID
  1223. (*PCACHE_CONTROLLER_FLUSH) (
  1224. PVOID Context,
  1225. ULONG Flags
  1226. );
  1227. /*++
  1228. Routine Description:
  1229. This routine cleans and/or invalidates the cache owned by the cache
  1230. controller.
  1231. Arguments:
  1232. Context - Supplies the pointer to the cache controller's context, provided
  1233. by the hardware module upon initialization.
  1234. Flags - Supplies a bitmask of flush flags. See CACHE_CONTROLLER_FLUSH_FLAG_*
  1235. for definitions.
  1236. Return Value:
  1237. None.
  1238. --*/
  1239. typedef
  1240. VOID
  1241. (*PCACHE_CONTROLLER_FLUSH_REGION) (
  1242. PVOID Context,
  1243. PHYSICAL_ADDRESS Address,
  1244. UINTN SizeInBytes,
  1245. ULONG Flags
  1246. );
  1247. /*++
  1248. Routine Description:
  1249. This routine cleans and/or invalidates a region of the cache owned by the
  1250. cache controller.
  1251. Arguments:
  1252. Context - Supplies the pointer to the cache controller's context, provided
  1253. by the hardware module upon initialization.
  1254. Address - Supplies the starting physical address of the region to flush. It
  1255. must be aligned to the cache line size.
  1256. SizeInBytes - Supplies the number of bytes to flush.
  1257. Flags - Supplies a bitmask of flush flags. See CACHE_CONTROLLER_FLUSH_FLAG_*
  1258. for definitions.
  1259. Return Value:
  1260. None.
  1261. --*/
  1262. typedef
  1263. KSTATUS
  1264. (*PCACHE_CONTROLLER_GET_PROPERTIES) (
  1265. PVOID Context,
  1266. PCACHE_CONTROLLER_PROPERTIES Properties
  1267. );
  1268. /*++
  1269. Routine Description:
  1270. This routine cleans and invalidates the cache owned by the cache controller.
  1271. Arguments:
  1272. Context - Supplies the pointer to the cache controller's context, provided
  1273. by the hardware module upon initialization.
  1274. Properties - Supplies a pointer that receives the properties of the given
  1275. cache controller (e.g. cache line size).
  1276. Return Value:
  1277. STATUS_SUCCESS on success.
  1278. Other status codes on failure.
  1279. --*/
  1280. /*++
  1281. Structure Description:
  1282. This structure describes the API of a cache controller hardware module. It
  1283. is passed by the hardware module to the kernel during registration to
  1284. supply pointers to the hardware module's functionality.
  1285. Members:
  1286. Initialize - Stores a pointer to a function used to initialize the unit.
  1287. Flush - Stores a pointer to a function used to flush a single cache line.
  1288. FlushRegion - Stores a pointer to a function used to flush a region of
  1289. the cache.
  1290. GetProperties - Stores a pointer to a function used to query the cache
  1291. controller.
  1292. --*/
  1293. typedef struct _CACHE_CONTROLLER_FUNCTION_TABLE {
  1294. PCACHE_CONTROLLER_INITIALIZE Initialize;
  1295. PCACHE_CONTROLLER_FLUSH Flush;
  1296. PCACHE_CONTROLLER_FLUSH_REGION FlushRegion;
  1297. PCACHE_CONTROLLER_GET_PROPERTIES GetProperties;
  1298. } CACHE_CONTROLLER_FUNCTION_TABLE, *PCACHE_CONTROLLER_FUNCTION_TABLE;
  1299. //
  1300. // System reset functions
  1301. //
  1302. typedef
  1303. KSTATUS
  1304. (*PREBOOT_PREPARE) (
  1305. PVOID Context,
  1306. SYSTEM_RESET_TYPE ResetType
  1307. );
  1308. /*++
  1309. Routine Description:
  1310. This routine prepares the system for a reboot or system power transition.
  1311. This function is called at low level when possible. During emergency reboot
  1312. situations, this function may not be called.
  1313. Arguments:
  1314. Context - Supplies the pointer to the reboot controller's context, provided
  1315. by the hardware module upon initialization.
  1316. ResetType - Supplies the reset type that is going to occur.
  1317. Return Value:
  1318. STATUS_SUCCESS on success.
  1319. Other status codes on failure.
  1320. --*/
  1321. typedef
  1322. KSTATUS
  1323. (*PREBOOT_SYSTEM) (
  1324. PVOID Context,
  1325. SYSTEM_RESET_TYPE ResetType,
  1326. PVOID Data,
  1327. UINTN Size
  1328. );
  1329. /*++
  1330. Routine Description:
  1331. This routine shuts down or reboots the entire system.
  1332. Arguments:
  1333. Context - Supplies the pointer to the reboot controller's context, provided
  1334. by the hardware module upon initialization.
  1335. ResetType - Supplies the reset type.
  1336. Data - Supplies an optional pointer's worth of platform-specific data.
  1337. Size - Supplies the size of the platform-specific data.
  1338. Return Value:
  1339. STATUS_SUCCESS on success.
  1340. Other status codes on failure.
  1341. --*/
  1342. /*++
  1343. Structure Description:
  1344. This structure describes the API of a reboot hardware module.
  1345. Members:
  1346. Prepare - Supplies a pointer to a function used to prepare the system for
  1347. a reboot or system power transition when done gracefully. During an
  1348. emergency reboot this function may not be called.
  1349. Reboot - Supplies a pointer to a function used to reboot the system.
  1350. --*/
  1351. typedef struct _REBOOT_MODULE_FUNCTION_TABLE {
  1352. PREBOOT_PREPARE Prepare;
  1353. PREBOOT_SYSTEM Reboot;
  1354. } REBOOT_MODULE_FUNCTION_TABLE, *PREBOOT_MODULE_FUNCTION_TABLE;
  1355. //
  1356. // Registration structures.
  1357. //
  1358. /*++
  1359. Structure Description:
  1360. This structure is used to describe an interrupt controller to the system.
  1361. It is passed from the hardware module to the kernel.
  1362. Members:
  1363. TableVersion - Stores the version of the interrupt controller description
  1364. table as understood by the hardware module. Set this to
  1365. INTERRUPT_CONTROLLER_DESCRIPTION_VERSION.
  1366. FunctionTable - Stores the table of pointers to the hardware module's
  1367. functions.
  1368. Context - Stores a pointer's worth of data specific to this interrupt
  1369. controller instance. This pointer will be passed back to the hardware
  1370. module on each call.
  1371. Flags - Stores a bitfield of flags regarding this interrupt controller.
  1372. See INTERRUPT_FEATURE_* flags.
  1373. Identifier - Stores the unique identifier of the interrupt controller.
  1374. This is expected to be unique across all interrupt controllers in the
  1375. system.
  1376. ProcessorCount - Stores the number of processors under the jurisdiction of
  1377. this interrupt controller.
  1378. PriorityCount - Stores the number of hardware priority levels that
  1379. interrupts can be configured at. This value may be 0 to indicate that
  1380. the controller does not support a hardware priority scheme.
  1381. SaveContextSize - Stores the number of bytes needed per processor to save
  1382. the interrupt controller state.
  1383. --*/
  1384. typedef struct _INTERRUPT_CONTROLLER_DESCRIPTION {
  1385. ULONG TableVersion;
  1386. INTERRUPT_FUNCTION_TABLE FunctionTable;
  1387. PVOID Context;
  1388. ULONG Flags;
  1389. UINTN Identifier;
  1390. ULONG ProcessorCount;
  1391. ULONG PriorityCount;
  1392. ULONG SaveContextSize;
  1393. } INTERRUPT_CONTROLLER_DESCRIPTION, *PINTERRUPT_CONTROLLER_DESCRIPTION;
  1394. /*++
  1395. Structure Description:
  1396. This structure is used to describe a timer to the system. It is passed from
  1397. the hardware module to the kernel.
  1398. Members:
  1399. TableVersion - Stores the version of the timer description table as
  1400. understood by the hardware module. Set this to
  1401. TIMER_DESCRIPTION_VERSION.
  1402. FunctionTable - Stores the table of pointers to the hardware module's
  1403. functions.
  1404. Context - Stores a pointer's worth of data specific to this timer instance.
  1405. This pointer will be passed back to the hardware module on each call.
  1406. Identifier - Stores the unique identifier of the timer.
  1407. Features - Stores a bitfield of the timer's features. See TIMER_FEATURE_*
  1408. definitions.
  1409. CounterFrequency - Stores the frequency of the counter, in Hertz. This is
  1410. required even if the counter is not exposed as readable, as it is used
  1411. in calculations for arming tick counts. If the counter's frequency is
  1412. not known, supply 0, and the system will measure the counter's frequency
  1413. using another timer.
  1414. CounterBitWidth - Stores the number of bits in the counter.
  1415. Interrupt - Stores information about how the timer's interrupt is routed
  1416. and configured.
  1417. --*/
  1418. typedef struct _TIMER_DESCRIPTION {
  1419. ULONG TableVersion;
  1420. TIMER_FUNCTION_TABLE FunctionTable;
  1421. PVOID Context;
  1422. ULONG Identifier;
  1423. ULONG Features;
  1424. ULONGLONG CounterFrequency;
  1425. ULONG CounterBitWidth;
  1426. TIMER_INTERRUPT Interrupt;
  1427. } TIMER_DESCRIPTION, *PTIMER_DESCRIPTION;
  1428. /*++
  1429. Structure Description:
  1430. This structure is used to describe a debug device to the system. It is
  1431. passed from the hardware module to the kernel.
  1432. Members:
  1433. TableVersion - Stores the version of the debug device description table as
  1434. understood by the hardware module. Set this to
  1435. DEBUG_DEVICE_DESCRIPTION_VERSION.
  1436. FunctionTable - Stores the table of pointers to the hardware module's
  1437. functions.
  1438. Context - Stores a pointer's worth of data specific to this serial instance.
  1439. This pointer will be passed back to the hardware module on each call.
  1440. PortType - Stores the port type of the debug device as defined by the
  1441. debug port table 2 specification.
  1442. PortSubType - Stores the port subtype of the debug device as defined by the
  1443. debug port table 2 specification.
  1444. Identifier - Stores the unique identifier of the device, often its physical
  1445. base address.
  1446. --*/
  1447. typedef struct _DEBUG_DEVICE_DESCRIPTION {
  1448. ULONG TableVersion;
  1449. DEBUG_DEVICE_FUNCTION_TABLE FunctionTable;
  1450. PVOID Context;
  1451. USHORT PortType;
  1452. USHORT PortSubType;
  1453. ULONGLONG Identifier;
  1454. } DEBUG_DEVICE_DESCRIPTION, *PDEBUG_DEVICE_DESCRIPTION;
  1455. /*++
  1456. Structure Description:
  1457. This structure is used to describe a calendar timer to the system. It is
  1458. passed from the hardware module to the kernel.
  1459. Members:
  1460. TableVersion - Stores the version of the calendar timer description
  1461. table as understood by the hardware module. Set this to
  1462. CALENDAR_TIMER_DESCRIPTION_VERSION.
  1463. FunctionTable - Stores the table of pointers to the hardware module's
  1464. functions.
  1465. Context - Stores a pointer's worth of data specific to this calendar timer
  1466. instance. This pointer will be passed back to the hardware module on
  1467. each call.
  1468. Identifier - Stores the unique identifier of the calendar timer.
  1469. Features - Stores a bitfield of features about the timer. See
  1470. CALENDAR_TIMER_FEATURE_* definitions.
  1471. --*/
  1472. typedef struct _CALENDAR_TIMER_DESCRIPTION {
  1473. ULONG TableVersion;
  1474. CALENDAR_TIMER_FUNCTION_TABLE FunctionTable;
  1475. PVOID Context;
  1476. ULONG Identifier;
  1477. ULONG Features;
  1478. } CALENDAR_TIMER_DESCRIPTION, *PCALENDAR_TIMER_DESCRIPTION;
  1479. /*++
  1480. Structure Description:
  1481. This structure is used to describe a cache controller to the system.
  1482. It is passed from the hardware module to the kernel.
  1483. Members:
  1484. TableVersion - Stores the version of the cache controller description table
  1485. as understood by the hardware module. Set this to
  1486. CACHE_CONTROLLER_DESCRIPTION_VERSION.
  1487. FunctionTable - Stores the table of pointers to the hardware module's
  1488. functions.
  1489. Context - Stores a pointer's worth of data specific to this cache
  1490. controller instance. This pointer will be passed back to the hardware
  1491. module on each call.
  1492. Identifier - Stores the unique identifier of the cache controller.
  1493. PropertiesVersion - Stores the version of the cache controller properties
  1494. as understood by the hardware module. Set this to
  1495. CACHE_CONTROLLER_PROPERTIES_VERSION.
  1496. --*/
  1497. typedef struct _CACHE_CONTROLLER_DESCRIPTION {
  1498. ULONG TableVersion;
  1499. CACHE_CONTROLLER_FUNCTION_TABLE FunctionTable;
  1500. PVOID Context;
  1501. ULONG Identifier;
  1502. ULONG PropertiesVersion;
  1503. } CACHE_CONTROLLER_DESCRIPTION, *PCACHE_CONTROLLER_DESCRIPTION;
  1504. /*++
  1505. Structure Description:
  1506. This structure is used to describe a reboot controller to the system.
  1507. It is passed from the hardware module to the kernel.
  1508. Members:
  1509. TableVersion - Stores the version of the cache controller description table
  1510. as understood by the hardware module. Set this to
  1511. REBOOT_MODULE_DESCRIPTION_VERSION.
  1512. FunctionTable - Stores the table of pointers to the hardware module's
  1513. functions.
  1514. Context - Stores a pointer's worth of data specific to this cache
  1515. controller instance. This pointer will be passed back to the hardware
  1516. module on each call.
  1517. Identifier - Stores the unique identifier of the reboot controller.
  1518. Properties - Stores a bitfield of flags describing the reboot controller.
  1519. See REBOOT_MODULE_* definitions.
  1520. --*/
  1521. typedef struct _REBOOT_MODULE_DESCRIPTION {
  1522. ULONG TableVersion;
  1523. REBOOT_MODULE_FUNCTION_TABLE FunctionTable;
  1524. PVOID Context;
  1525. ULONG Identifier;
  1526. ULONG Properties;
  1527. } REBOOT_MODULE_DESCRIPTION, *PREBOOT_MODULE_DESCRIPTION;
  1528. //
  1529. // Hardware module prototypes.
  1530. //
  1531. typedef
  1532. PVOID
  1533. (*PHARDWARE_MODULE_GET_ACPI_TABLE) (
  1534. ULONG Signature,
  1535. PVOID PreviousTable
  1536. );
  1537. /*++
  1538. Routine Description:
  1539. This routine attempts to find an ACPI description table with the given
  1540. signature.
  1541. Arguments:
  1542. Signature - Supplies the signature of the desired table.
  1543. PreviousTable - Supplies a pointer to the table to start the search from.
  1544. Return Value:
  1545. Returns a pointer to the beginning of the header to the table if the table
  1546. was found, or NULL if the table could not be located.
  1547. --*/
  1548. typedef
  1549. VOID
  1550. (*PHARDWARE_MODULE_ENTRY) (
  1551. VOID
  1552. );
  1553. /*++
  1554. Routine Description:
  1555. This routine is the entry point for a hardware module. Its role is to
  1556. detect the prescense of any of the hardware modules it contains
  1557. implementations for and instantiate them with the kernel.
  1558. Arguments:
  1559. None.
  1560. Return Value:
  1561. None.
  1562. --*/
  1563. //
  1564. // -------------------------------------------------------------------- Globals
  1565. //
  1566. //
  1567. // -------------------------------------------------------- Function Prototypes
  1568. //
  1569. KERNEL_API
  1570. KSTATUS
  1571. HlRegisterHardware (
  1572. HARDWARE_MODULE_TYPE Type,
  1573. PVOID Description
  1574. );
  1575. /*++
  1576. Routine Description:
  1577. This routine registers a hardware module with the system.
  1578. Arguments:
  1579. Type - Supplies the type of resource being registered.
  1580. Description - Supplies a description of the resource being registered.
  1581. Return Value:
  1582. Returns a pointer to the allocation of the requested size on success.
  1583. NULL on failure.
  1584. --*/
  1585. KERNEL_API
  1586. PVOID
  1587. HlGetAcpiTable (
  1588. ULONG Signature,
  1589. PVOID PreviousTable
  1590. );
  1591. /*++
  1592. Routine Description:
  1593. This routine attempts to find an ACPI description table with the given
  1594. signature.
  1595. Arguments:
  1596. Signature - Supplies the signature of the desired table.
  1597. PreviousTable - Supplies a pointer to the table to start the search from.
  1598. Return Value:
  1599. Returns a pointer to the beginning of the header to the table if the table
  1600. was found, or NULL if the table could not be located.
  1601. --*/
  1602. KERNEL_API
  1603. PVOID
  1604. HlAllocateMemory (
  1605. UINTN Size,
  1606. ULONG Tag,
  1607. BOOL Device,
  1608. PPHYSICAL_ADDRESS PhysicalAddress
  1609. );
  1610. /*++
  1611. Routine Description:
  1612. This routine allocates memory from the non-paged pool. This memory will
  1613. never be paged out and can be accessed at any level.
  1614. Arguments:
  1615. Size - Supplies the size of the allocation, in bytes.
  1616. Tag - Supplies an identifier to associate with the allocation, useful for
  1617. debugging and leak detection.
  1618. Device - Supplies a boolean indicating if this memory will be accessed by
  1619. a device directly. If TRUE, the memory will be mapped uncached.
  1620. PhysicalAddress - Supplies an optional pointer where the physical address
  1621. of the allocation is returned.
  1622. Return Value:
  1623. Returns the allocated memory if successful, or NULL on failure.
  1624. --*/
  1625. KERNEL_API
  1626. PVOID
  1627. HlMapPhysicalAddress (
  1628. PHYSICAL_ADDRESS PhysicalAddress,
  1629. ULONG SizeInBytes,
  1630. BOOL CacheDisabled
  1631. );
  1632. /*++
  1633. Routine Description:
  1634. This routine maps a physical address into kernel VA space. It is meant so
  1635. that system components can access memory mapped hardware.
  1636. Arguments:
  1637. PhysicalAddress - Supplies a pointer to the physical address. This address
  1638. must be page aligned.
  1639. SizeInBytes - Supplies the size in bytes of the mapping. This will be
  1640. rounded up to the nearest page size.
  1641. CacheDisabled - Supplies a boolean indicating if the memory is to be mapped
  1642. uncached.
  1643. Return Value:
  1644. Returns a pointer to the virtual address of the mapping on success, or
  1645. NULL on failure.
  1646. --*/
  1647. KERNEL_API
  1648. VOID
  1649. HlUnmapAddress (
  1650. PVOID VirtualAddress,
  1651. ULONG SizeInBytes
  1652. );
  1653. /*++
  1654. Routine Description:
  1655. This routine unmaps memory mapped with MmMapPhysicalMemory.
  1656. Arguments:
  1657. VirtualAddress - Supplies the virtual address to unmap.
  1658. SizeInBytes - Supplies the number of bytes to unmap.
  1659. Return Value:
  1660. None.
  1661. --*/
  1662. KERNEL_API
  1663. VOID
  1664. HlReportPhysicalAddressUsage (
  1665. PHYSICAL_ADDRESS PhysicalAddress,
  1666. ULONGLONG Size
  1667. );
  1668. /*++
  1669. Routine Description:
  1670. This routine is called by a hardware module plugin to notify the system
  1671. about a range of physical address space that is in use by that hardware
  1672. plugin. This helps notify the system to avoid using this address space
  1673. when configuring devices that can remap their memory windows. This function
  1674. should be called during the discovery portion, as it is relevant to the
  1675. system regardless of whether that hardware module is actually initialized
  1676. and used.
  1677. Arguments:
  1678. PhysicalAddress - Supplies the first physical address in use by the hardware
  1679. module.
  1680. Size - Supplies the size of the memory segment, in bytes.
  1681. Return Value:
  1682. None.
  1683. --*/
  1684. KERNEL_API
  1685. VOID
  1686. HlInitializeLock (
  1687. PHARDWARE_MODULE_LOCK Lock
  1688. );
  1689. /*++
  1690. Routine Description:
  1691. This routine initializes a hardware module lock structure. This must be
  1692. called before the lock can be acquired or released.
  1693. Arguments:
  1694. Lock - Supplies a pointer to the lock to initialize.
  1695. Return Value:
  1696. None.
  1697. --*/
  1698. KERNEL_API
  1699. VOID
  1700. HlAcquireLock (
  1701. PHARDWARE_MODULE_LOCK Lock
  1702. );
  1703. /*++
  1704. Routine Description:
  1705. This routine disables interrupts and acquires a high level spin lock.
  1706. Callers should be very careful to avoid doing this in hot paths or for
  1707. very long. This lock is not reentrant.
  1708. Arguments:
  1709. Lock - Supplies a pointer to the lock to acquire.
  1710. Return Value:
  1711. None.
  1712. --*/
  1713. KERNEL_API
  1714. VOID
  1715. HlReleaseLock (
  1716. PHARDWARE_MODULE_LOCK Lock
  1717. );
  1718. /*++
  1719. Routine Description:
  1720. This routine releases a previously acquired high level lock and restores
  1721. interrupts to their previous state.
  1722. Arguments:
  1723. Lock - Supplies a pointer to the lock to release.
  1724. Return Value:
  1725. None.
  1726. --*/