1
0

ke.h 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596
  1. /*++
  2. Copyright (c) 2012 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. ke.h
  5. Abstract:
  6. This header contains definitions for the Kernel Executive.
  7. Author:
  8. Evan Green 5-Aug-2012
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. #include <minoca/kernel/crash.h>
  14. //
  15. // --------------------------------------------------------------------- Macros
  16. //
  17. //
  18. // Define macros for encoding and decoding system version information. These
  19. // can be revised as needed since this encoded structure is not exposed to
  20. // consumers. They use the SYSTEM_VERSION_INFORMATION structure.
  21. //
  22. #define ENCODE_VERSION_INFORMATION(_Major, _Minor, _Revision, _Release, _Debug)\
  23. (((_Major) << 24) | \
  24. ((_Minor) << 16) | \
  25. ((_Revision) << 8) | \
  26. ((_Release) << 4) | \
  27. (_Debug))
  28. #define DECODE_MAJOR_VERSION(_EncodedVersion) (UCHAR)((_EncodedVersion) >> 24)
  29. #define DECODE_MINOR_VERSION(_EncodedVersion) (UCHAR)((_EncodedVersion) >> 16)
  30. #define DECODE_VERSION_REVISION(_EncodedVersion) (UCHAR)((_EncodedVersion) >> 8)
  31. #define DECODE_VERSION_RELEASE(_EncodedVersion) \
  32. (UCHAR)(((_EncodedVersion) >> 4) & 0x0F)
  33. #define DECODE_VERSION_DEBUG(_EncodedVersion) \
  34. (UCHAR)((_EncodedVersion) & 0x0F)
  35. //
  36. // ---------------------------------------------------------------- Definitions
  37. //
  38. //
  39. // Define the generic catch-all Ke tag: Ke!!
  40. //
  41. #define KE_ALLOCATION_TAG 0x2121654B
  42. //
  43. // Define the scheduler allocation tag: KeSc
  44. //
  45. #define KE_SCHEDULER_ALLOCATION_TAG 0x6353654B
  46. //
  47. // Define the event allocation tag: KeEv
  48. //
  49. #define KE_EVENT_ALLOCATION_TAG 0x7645654B
  50. //
  51. // Define the work item allocation tag: KeWo
  52. //
  53. #define KE_WORK_ITEM_ALLOCATION_TAG 0x6F57654B
  54. //
  55. // Define the Ke system information allocation tag: KInf
  56. //
  57. #define KE_INFORMATION_ALLOCATION_TAG 0x666E494B
  58. //
  59. // Define the maximum number of comma-separated values in a kernel argument.
  60. //
  61. #define KERNEL_MAX_ARGUMENT_VALUES 10
  62. #define KERNEL_MAX_COMMAND_LINE 4096
  63. //
  64. // Work queue flags.
  65. //
  66. //
  67. // Set this bit if the work queue should support adding work items at
  68. // dispatch level.
  69. //
  70. #define WORK_QUEUE_FLAG_SUPPORT_DISPATCH_LEVEL 0x00000001
  71. //
  72. // Define the mask of publicly accessible timer flags.
  73. //
  74. #define KTIMER_FLAG_PUBLIC_MASK 0x0
  75. //
  76. // Define user shared data processor feature flags.
  77. //
  78. //
  79. // This bit is set if the processor supports the sysenter instruction.
  80. //
  81. #define X86_FEATURE_SYSENTER 0x00000001
  82. //
  83. // This bit is set if the processor supports the syscall instruction.
  84. //
  85. #define X86_FEATURE_SYSCALL 0x00000002
  86. //
  87. // This bit is set if the processor conforms to at least the Pentium Pro ISA
  88. // (circa 1995).
  89. //
  90. #define X86_FEATURE_I686 0x00000004
  91. //
  92. // This bit is set if the processor supports fxsave/fxrstor instructions.
  93. //
  94. #define X86_FEATURE_FXSAVE 0x00000008
  95. //
  96. // This bit is set if the kernel is ARMv7.
  97. //
  98. #define ARM_FEATURE_V7 0x00000001
  99. //
  100. // This bit is set if the processor supports VFPv2 or beyond.
  101. //
  102. #define ARM_FEATURE_VFP2 0x00000002
  103. //
  104. // This bit is set if the processor supports VFPv3.
  105. //
  106. #define ARM_FEATURE_VFP3 0x00000004
  107. //
  108. // This bit is set if the processor supports NEON advanced SIMD with 32 64-bit
  109. // registers.
  110. //
  111. #define ARM_FEATURE_NEON32 0x00000008
  112. //
  113. // Define the set of DCP flags.
  114. //
  115. #define DPC_FLAG_QUEUED_ON_PROCESSOR 0x00000001
  116. //
  117. // ------------------------------------------------------ Data Type Definitions
  118. //
  119. typedef enum _RUNLEVEL {
  120. RunLevelLow = 0,
  121. RunLevelDispatch = 2,
  122. RunLevelMaxDevice = 11,
  123. RunLevelClock = 13,
  124. RunLevelIpi = 14,
  125. RunLevelHigh = 15,
  126. RunLevelCount = 16
  127. } RUNLEVEL, *PRUNLEVEL;
  128. typedef enum _WORK_PRIORITY {
  129. WorkPriorityInvalid,
  130. WorkPriorityNormal,
  131. WorkPriorityHigh,
  132. } WORK_PRIORITY, *PWORK_PRIORITY;
  133. typedef enum _PROCESSOR_SET_TARGET {
  134. ProcessorTargetInvalid,
  135. ProcessorTargetNone,
  136. ProcessorTargetAny,
  137. ProcessorTargetAll,
  138. ProcessorTargetAllExcludingSelf,
  139. ProcessorTargetSelf,
  140. ProcessorTargetSingleProcessor
  141. } PROCESSOR_SET_TARGET, *PPROCESSOR_SET_TARGET;
  142. typedef enum _WORK_QUEUE_STATE {
  143. WorkQueueStateInvalid,
  144. WorkQueueStateOpen,
  145. WorkQueueStatePaused,
  146. WorkQueueStateWakingForDestroying,
  147. WorkQueueStateDestroying,
  148. WorkQueueStateDestroyed
  149. } WORK_QUEUE_STATE, *PWORK_QUEUE_STATE;
  150. typedef enum _DPC_CRASH_REASON {
  151. DpcCrashReasonInvalid,
  152. DpcCrashDpcBlocked,
  153. DpcCrashReasonDoubleQueueDpc,
  154. DpcCrashReasonNullRoutine,
  155. DpcCrashReasonCorrupt,
  156. } DPC_CRASH_REASON, *PDPC_CRASH_REASON;
  157. typedef enum _SCHEDULER_REASON {
  158. SchedulerReasonInvalid,
  159. SchedulerReasonDispatchInterrupt,
  160. SchedulerReasonThreadBlocking,
  161. SchedulerReasonThreadYielding,
  162. SchedulerReasonThreadSuspending,
  163. SchedulerReasonThreadExiting
  164. } SCHEDULER_REASON, *PSCHEDULER_REASON;
  165. typedef enum _SYSTEM_INFORMATION_SUBSYSTEM {
  166. SystemInformationInvalid,
  167. SystemInformationKe,
  168. SystemInformationIo,
  169. SystemInformationMm,
  170. SystemInformationPs,
  171. SystemInformationHl,
  172. SystemInformationSp,
  173. SystemInformationPm
  174. } SYSTEM_INFORMATION_SUBSYSTEM, *PSYSTEM_INFORMATION_SUBSYSTEM;
  175. typedef enum _KE_INFORMATION_TYPE {
  176. KeInformationInvalid,
  177. KeInformationSystemVersion,
  178. KeInformationFirmwareTable,
  179. KeInformationFirmwareType,
  180. KeInformationProcessorUsage,
  181. KeInformationProcessorCount,
  182. KeInformationKernelCommandLine,
  183. } KE_INFORMATION_TYPE, *PKE_INFORMATION_TYPE;
  184. typedef enum _SYSTEM_RESET_TYPE {
  185. SystemResetInvalid,
  186. SystemResetShutdown,
  187. SystemResetWarm,
  188. SystemResetCold,
  189. SystemResetTypeCount
  190. } SYSTEM_RESET_TYPE, *PSYSTEM_RESET_TYPE;
  191. typedef enum _SYSTEM_FIRMWARE_TYPE {
  192. SystemFirmwareInvalid,
  193. SystemFirmwareUnknown,
  194. SystemFirmwareEfi,
  195. SystemFirmwarePcat,
  196. } SYSTEM_FIRMWARE_TYPE, *PSYSTEM_FIRMWARE_TYPE;
  197. typedef enum _CYCLE_ACCOUNT {
  198. CycleAccountInvalid,
  199. CycleAccountUser,
  200. CycleAccountKernel,
  201. CycleAccountInterrupt,
  202. CycleAccountIdle,
  203. } CYCLE_ACCOUNT, *PCYCLE_ACCOUNT;
  204. typedef enum _TIMER_QUEUE_TYPE {
  205. TimerQueueSoft,
  206. TimerQueueSoftWake,
  207. TimerQueueHard,
  208. TimerQueueCount,
  209. } TIMER_QUEUE_TYPE, *PTIMER_QUEUE_TYPE;
  210. typedef enum _CLOCK_TIMER_MODE {
  211. ClockTimerInvalid,
  212. ClockTimerPeriodic,
  213. ClockTimerOneShot,
  214. ClockTimerOff
  215. } CLOCK_TIMER_MODE, *PCLOCK_TIMER_MODE;
  216. typedef struct _KTIMER KTIMER, *PKTIMER;
  217. typedef struct _KTIMER_DATA KTIMER_DATA, *PKTIMER_DATA;
  218. typedef struct _WORK_ITEM WORK_ITEM, *PWORK_ITEM;
  219. typedef struct _WORK_QUEUE WORK_QUEUE, *PWORK_QUEUE;
  220. typedef struct _SCHEDULER_DATA SCHEDULER_DATA, *PSCHEDULER_DATA;
  221. typedef struct _SCHEDULER_GROUP_ENTRY
  222. SCHEDULER_GROUP_ENTRY, *PSCHEDULER_GROUP_ENTRY;
  223. typedef struct _SCHEDULER_GROUP SCHEDULER_GROUP, *PSCHEDULER_GROUP;
  224. typedef struct _DPC DPC, *PDPC;
  225. typedef struct _PROCESSOR_START_BLOCK
  226. PROCESSOR_START_BLOCK, *PPROCESSOR_START_BLOCK;
  227. typedef
  228. VOID
  229. (*PIPI_ROUTINE) (
  230. PVOID Context
  231. );
  232. /*++
  233. Routine Description:
  234. This routine executes as part of an Inter-Processor Interrupt request. It
  235. is run simultaneously on the set of processors requested.
  236. Arguments:
  237. Context - Supplies the context pointer supplied when the IPI was requested.
  238. Return Value:
  239. None.
  240. --*/
  241. /*++
  242. Structure Description:
  243. This structure describes a set of zero or more processors.
  244. Members:
  245. Target - Stores the processor target.
  246. Number - Stores the processor number if the target indicates a single
  247. processor.
  248. --*/
  249. typedef struct _PROCESSOR_SET {
  250. PROCESSOR_SET_TARGET Target;
  251. union {
  252. ULONG Number;
  253. } U;
  254. } PROCESSOR_SET, *PPROCESSOR_SET;
  255. /*++
  256. Structure Description:
  257. This structure describes the cycle accounting information for a processor.
  258. Members:
  259. UserCycles - Stores the accumulated number of cycles this processor has
  260. spent in user mode.
  261. KernelCycles - Stores the accumulated number of cycles this processor has
  262. spent in kernel mode (not including interrupt and idle time).
  263. InterruptCycles - Stores the accumulated number of cycles this processor
  264. has spent servicing interrupts and DPCs.
  265. IdleCycles - Stores the accumulated number of cycles this processor has
  266. spent idle.
  267. --*/
  268. typedef struct _PROCESSOR_CYCLE_ACCOUNTING {
  269. ULONGLONG UserCycles;
  270. ULONGLONG KernelCycles;
  271. ULONGLONG InterruptCycles;
  272. ULONGLONG IdleCycles;
  273. } PROCESSOR_CYCLE_ACCOUNTING, *PPROCESSOR_CYCLE_ACCOUNTING;
  274. /*++
  275. Structure Description:
  276. This structure contains the context for a scheduling group.
  277. Members:
  278. ListEntry - Stores pointers to the next and previous groups underneath the
  279. parent of this group.
  280. Parent - Stores a pointer to the parent scheduler group.
  281. Children - Stores the head of the list of child scheduler groups this
  282. group owns.
  283. Entries - Stores a pointer to the array of entries for this group.
  284. EntryCount - Stores the element count of the entries array.
  285. ThreadCount - Stores the number of threads, ready or not, that live in the
  286. group.
  287. --*/
  288. struct _SCHEDULER_GROUP {
  289. LIST_ENTRY ListEntry;
  290. PSCHEDULER_GROUP Parent;
  291. LIST_ENTRY Children;
  292. PSCHEDULER_GROUP_ENTRY Entries;
  293. UINTN EntryCount;
  294. UINTN ThreadCount;
  295. };
  296. /*++
  297. Structure Description:
  298. This structure contains the context for a scheduling group on a particular
  299. scheduler (CPU).
  300. Members:
  301. Entry - Stores the regular scheduling entry data.
  302. Children - Stores the head of the list of scheduling entries that are ready
  303. to be run within this group.
  304. ReadyThreadCount - Stores the number of threads inside this group and all
  305. its children (meaning this includes all ready threads inside child and
  306. grandchild groups).
  307. Scheduler - Stores a pointer to the root CPU this group belongs to.
  308. Group - Stores a pointer to the owning group structure.
  309. --*/
  310. struct _SCHEDULER_GROUP_ENTRY {
  311. SCHEDULER_ENTRY Entry;
  312. LIST_ENTRY Children;
  313. UINTN ReadyThreadCount;
  314. PSCHEDULER_DATA Scheduler;
  315. PSCHEDULER_GROUP Group;
  316. };
  317. /*++
  318. Structure Description:
  319. This structure contains the scheduler context for a specific processor.
  320. Members:
  321. Lock - Stores the spin lock serializing access to the scheduling data.
  322. Group - Stores the fixed head scheduling group for this processor.
  323. --*/
  324. struct _SCHEDULER_DATA {
  325. KSPIN_LOCK Lock;
  326. SCHEDULER_GROUP_ENTRY Group;
  327. };
  328. /*++
  329. Structure Description:
  330. This structure contains the state for a pending interrupt on this processor.
  331. Because new interrupts cause the interrupt controller to block all
  332. interrupts at that priority and lower, there can only be at most one
  333. pending interrupt per run level.
  334. Members:
  335. Vector - Stores the interrupt vector.
  336. MagicCandy - Stores the opaque value returned by the interrupt controller
  337. when the interrupt was acknowledged. This is saved because it needs
  338. to be returned to the interrupt controller in the end of interrupt
  339. routine.
  340. InterruptController - Stores a pointer to the interrupt controller that
  341. generated the interrupt.
  342. --*/
  343. typedef struct _PENDING_INTERRUPT {
  344. ULONG Vector;
  345. ULONG MagicCandy;
  346. PVOID InterruptController;
  347. } PENDING_INTERRUPT, *PPENDING_INTERRUPT;
  348. /*++
  349. Structure Description:
  350. This structure contains the state for this processor's dynamic tick
  351. management.
  352. Members:
  353. Mode - Stores the current clock mode.
  354. NextMode - Stores the next clock mode.
  355. DueTime - Stores the next deadline if the current clock mode is one-shot.
  356. CurrentTime - Stores a relatively recent time counter timestamp.
  357. Hard - Stores a boolean indicating if the given due time is hard (must be
  358. met exactly then) or soft (can be met by the next periodic interrupt).
  359. AnyHard - Stores a boolean indicating if there are any hard timers queued
  360. on this processor.
  361. InterruptCount - Stores the total accumulated number of clock interrupts.
  362. NextDebugEvent - Stores the next deadline after which the processor should
  363. perform debug maintenance, either sending out profiling data or
  364. polling the debugger.
  365. --*/
  366. typedef struct _CLOCK_TIMER_DATA {
  367. CLOCK_TIMER_MODE Mode;
  368. CLOCK_TIMER_MODE NextMode;
  369. ULONGLONG DueTime;
  370. ULONGLONG CurrentTime;
  371. BOOL Hard;
  372. BOOL AnyHard;
  373. UINTN InterruptCount;
  374. ULONGLONG NextDebugEvent;
  375. } CLOCK_TIMER_DATA, *PCLOCK_TIMER_DATA;
  376. /*++
  377. Structure Description:
  378. This structure contains the processor identification information.
  379. Members:
  380. Vendor - Stores the CPU vendor. For x86, this contains the EBX portion of
  381. CPUID, function 1. For ARM, this contains the implementor code.
  382. Family - Stores the CPU family ID.
  383. Model - Stores the CPU model ID.
  384. Stepping - Stores the CPU stepping ID.
  385. --*/
  386. typedef struct _PROCESSOR_IDENTIFICATION {
  387. ULONG Vendor;
  388. USHORT Family;
  389. USHORT Model;
  390. USHORT Stepping;
  391. } PROCESSOR_IDENTIFICATION, *PPROCESSOR_IDENTIFICATION;
  392. /*++
  393. Structure Description:
  394. This structure stores the current running state of a processor.
  395. Members:
  396. Self - Stores a pointer to this structure. This is used to get the actual
  397. memory address when the structure is retrieved through unconventional
  398. means (like a segment register).
  399. ProcessorNumber - Stores the zero-based logical processor number.
  400. RunLevel - Stores the current run level of the processor.
  401. Tss - Stores a pointer to the current Task Segment for this processor. This
  402. only applies to PC processors. This member is accessed directly by
  403. assembly code, so its offset must be manually maintained.
  404. Gdt - Stores a pointer to the GDT for this processor. This only applies to
  405. PC processors. This member is accessed directly by assembly code, so
  406. its offset should be manually maintained.
  407. RunningThread - Stores the current thread scheduled on this processor.
  408. PreviousThread - Stores a pointer to the thread that was just scheduled
  409. out, but has yet to be put back on the ready list.
  410. IdleThread - Stores a pointer to the idle thread for this processor.
  411. Scheduler - Stores the scheduler context for this processor.
  412. Idt - Stores a pointer to the Interrupt Descriptor Table.
  413. InterruptTable - Stores an array of pointers to interrupt objects. The
  414. array is indexed by vector number, where the first index is the
  415. minimum vector.
  416. IpiListHead - Stores the list head for IPI request packets.
  417. IpiListLock - Stores the lock protecting access to the IPI list.
  418. PendingInterruptCount - Stores the number of interrupts that are currently
  419. queued to be replayed.
  420. PendingInterrupts - Stores the queue of interrupts that need to be
  421. replayed. This array is the size of the number of hardware levels that
  422. exist, and will always be sorted. It requires that interrupt
  423. controllers never allow interrupts to get through that are less than
  424. or equal to the priority of the current interrupt in service.
  425. PendingDispatchInterrupt - Stores a boolean indicating whether or not a
  426. dispatch level software interrupt is pending.
  427. DpcInProgress - Stores a pointer to the currently executing DPC.
  428. DpcLock - Stores the spin lock protecting the DPC list.
  429. DpcList - Stores the list head of DPCs pending on this processor.
  430. DpcCount - Stores the total number of DPCS that have occurred on this
  431. processor.
  432. TimerData - Stores a pointer to the timer management context.
  433. Clock - Stores the dynamic tick state.
  434. ClockInterruptCount - Stores the number of clock interrupts for this
  435. processor.
  436. CyclePeriodStart - Stores the beginning of the current cycle accounting
  437. period.
  438. CyclePeriodAccount - Stores the attribution of the current cycle accounting
  439. period.
  440. UserCycles - Stores the accumulated number of cycles this processor has
  441. spent in user mode.
  442. KernelCycles - Stores the accumulated number of cycles this processor has
  443. spent in kernel mode (not including interrupt and idle time).
  444. InterruptCycles - Stores the accumulated number of cycles this processor
  445. has spent servicing interrupts and DPCs.
  446. IdleCycles - Stores the accumulated number of cycles this processor has
  447. spent idle.
  448. SwapPage - Stores a pointer to a virtual address that can be used for
  449. temporary mappings.
  450. NmiCount - Stores a count of nested NMIs this processor has taken.
  451. CpuVersion - Stores the processor identification information for this CPU.
  452. --*/
  453. typedef struct _PROCESSOR_BLOCK PROCESSOR_BLOCK, *PPROCESSOR_BLOCK;
  454. struct _PROCESSOR_BLOCK {
  455. PPROCESSOR_BLOCK Self;
  456. ULONG ProcessorNumber;
  457. RUNLEVEL RunLevel;
  458. PVOID Tss;
  459. PVOID Gdt;
  460. PKTHREAD RunningThread;
  461. PKTHREAD PreviousThread;
  462. PKTHREAD IdleThread;
  463. SCHEDULER_DATA Scheduler;
  464. PVOID Idt;
  465. PVOID *InterruptTable;
  466. LIST_ENTRY IpiListHead;
  467. KSPIN_LOCK IpiListLock;
  468. ULONG PendingInterruptCount;
  469. PENDING_INTERRUPT PendingInterrupts[RunLevelCount];
  470. UCHAR PendingDispatchInterrupt;
  471. PDPC DpcInProgress;
  472. KSPIN_LOCK DpcLock;
  473. LIST_ENTRY DpcList;
  474. UINTN DpcCount;
  475. PKTIMER_DATA TimerData;
  476. CLOCK_TIMER_DATA Clock;
  477. ULONGLONG CyclePeriodStart;
  478. CYCLE_ACCOUNT CyclePeriodAccount;
  479. volatile ULONGLONG UserCycles;
  480. volatile ULONGLONG KernelCycles;
  481. volatile ULONGLONG InterruptCycles;
  482. volatile ULONGLONG IdleCycles;
  483. PVOID SwapPage;
  484. UINTN NmiCount;
  485. PROCESSOR_IDENTIFICATION CpuVersion;
  486. };
  487. /*++
  488. Structure Description:
  489. This structure defines usage information for one or more processors.
  490. Members:
  491. ProcessorNumber - Stores the processor number corresponding to the usage,
  492. or -1 if this data represents all processors.
  493. CycleCounterFrequency - Stores the frequency of the cycle counter. If all
  494. processors are included and processors run at different speeds, then
  495. this value may be zero.
  496. Usage - Stores the cycle counter usage information.
  497. --*/
  498. typedef struct _PROCESSOR_USAGE_INFORMATION {
  499. UINTN ProcessorNumber;
  500. ULONGLONG CycleCounterFrequency;
  501. PROCESSOR_CYCLE_ACCOUNTING Usage;
  502. } PROCESSOR_USAGE_INFORMATION, *PPROCESSOR_USAGE_INFORMATION;
  503. /*++
  504. Structure Description:
  505. This structure provides information about the number of processors in the
  506. system.
  507. Members:
  508. MaxProcessorCount - Stores the maximum number of processors that might
  509. be active in the machine.
  510. ActiveProcessorCount - Stores the number of processors online right now.
  511. --*/
  512. typedef struct _PROCESSOR_COUNT_INFORMATION {
  513. UINTN MaxProcessorCount;
  514. UINTN ActiveProcessorCount;
  515. } PROCESSOR_COUNT_INFORMATION, *PPROCESSOR_COUNT_INFORMATION;
  516. /*++
  517. Structure Description:
  518. This structure defines a queued lock. These locks can be used at or below
  519. dispatch level, or only below if paged memory is used.
  520. Members:
  521. Header - Stores the object header.
  522. OwningThread - Stores a pointer to the thread that is holding the lock.
  523. --*/
  524. typedef struct _QUEUED_LOCK {
  525. OBJECT_HEADER Header;
  526. PKTHREAD OwningThread;
  527. } QUEUED_LOCK, *PQUEUED_LOCK;
  528. /*++
  529. Structure Description:
  530. This structure defines an event.
  531. Members:
  532. Header - Stores the object header.
  533. --*/
  534. typedef struct _KEVENT {
  535. OBJECT_HEADER Header;
  536. } KEVENT, *PKEVENT;
  537. /*++
  538. Structure Description:
  539. This structure defines a shared-exclusive lock.
  540. Members:
  541. State - Stores the current state of the shared-exclusive lock. See
  542. SHARED_EXCLUSIVE_LOCK_* definitions.
  543. Event - Stores a pointer to the event that allows for blocking.
  544. ExclusiveWaiters - Stores the number of thread trying to acquire the lock
  545. exclusively.
  546. SharedWaiters - Stores the number of threads trying to acquire the lock
  547. shared.
  548. --*/
  549. typedef struct _SHARED_EXCLUSIVE_LOCK {
  550. volatile ULONG State;
  551. PKEVENT Event;
  552. volatile ULONG ExclusiveWaiters;
  553. volatile ULONG SharedWaiters;
  554. } SHARED_EXCLUSIVE_LOCK, *PSHARED_EXCLUSIVE_LOCK;
  555. /*++
  556. Structure Description:
  557. This structure defines a single kernel argument. An argument takes the
  558. form component.name=value1,value2,...
  559. Members:
  560. Component - Stores a pointer to the string describing the component
  561. receiving the argument.
  562. Name - Stores a pointer to a string containing the name of the argument.
  563. Values - Stores an array of arguments.
  564. ValueCount - Stores the number of valid elements in the array.
  565. --*/
  566. typedef struct _KERNEL_ARGUMENT {
  567. PSTR Component;
  568. PSTR Name;
  569. PSTR Values[KERNEL_MAX_ARGUMENT_VALUES];
  570. ULONG ValueCount;
  571. } KERNEL_ARGUMENT, *PKERNEL_ARGUMENT;
  572. /*++
  573. Structure Description:
  574. This structure defines the kernel command line information.
  575. Members:
  576. Line - Stores a pointer to the complete command line.
  577. LineSize - Stores the size of the command line, including the null
  578. terminator.
  579. Arguments - Stores the array of command arguments. This will be NULL for
  580. user-mode requests; user-mode is responsible for doing its own
  581. splitting.
  582. ArgumentCount - Stores the number of arguments.
  583. --*/
  584. typedef struct _KERNEL_COMMAND_LINE {
  585. PSTR Line;
  586. ULONG LineSize;
  587. PKERNEL_ARGUMENT Arguments;
  588. ULONG ArgumentCount;
  589. } KERNEL_COMMAND_LINE, *PKERNEL_COMMAND_LINE;
  590. typedef
  591. VOID
  592. (*PWORK_ITEM_ROUTINE) (
  593. PVOID Parameter
  594. );
  595. /*++
  596. Routine Description:
  597. This routine prototype represents a work item.
  598. Arguments:
  599. Parameter - Supplies an optional parameter passed in by the creator of the
  600. work item.
  601. Return Value:
  602. None.
  603. --*/
  604. typedef
  605. VOID
  606. (*PDPC_ROUTINE) (
  607. PDPC Dpc
  608. );
  609. /*++
  610. Routine Description:
  611. This routine prototype represents a function that gets called when a DPC
  612. (Deferred Procedure Call) is executed. When this routine is called, it
  613. is safe to requeue or destroy the DPC.
  614. Arguments:
  615. Dpc - Supplies a pointer to the DPC that is running.
  616. Return Value:
  617. None.
  618. --*/
  619. /*++
  620. Structure Description:
  621. This structure defines a Deferred Procedure Call object.
  622. Members:
  623. ListEntry - Stores pointers to the next and previous DPCs in the queue.
  624. DpcRoutine - Stores a pointer to the routine to call when the DPC fires.
  625. UserData - Stores an opaque pointer that the creator of the DPC can use to
  626. store context.
  627. Processor - Stores the processor number this DPC is queued to.
  628. UseCount - Stores the number of entities actively using this object.
  629. Flags - Stores a bitmask of flags for the DPC. See DPC_FLAG_* for
  630. definitions.
  631. --*/
  632. struct _DPC {
  633. LIST_ENTRY ListEntry;
  634. PDPC_ROUTINE DpcRoutine;
  635. PVOID UserData;
  636. ULONG Processor;
  637. volatile ULONG UseCount;
  638. ULONG Flags;
  639. };
  640. /*++
  641. Structure Description:
  642. This structure defines the contents of the user shared data page, which is
  643. shared between kernel mode and user mode.
  644. Members:
  645. EncodedSystemVersion - Stores the encoded system version information.
  646. SystemVersionSerial - Stores the serial system revision.
  647. BuildTime - Stores the system build time (the seconds portion of a system
  648. time structure).
  649. TimeCounterFrequency - Stores the frequency of the time counter. This value
  650. won't change once the system is booted.
  651. ProcessorCounterFrequency - Stores the frequency of the processor counter
  652. on the boot processor. This is roughly related to the processor speed,
  653. but not exactly. For example, on ARM, it may the the processor speed
  654. divided by 64.
  655. TimeOffset - Stores the system time when the time counter was zero.
  656. TimeCounter - Stores the number of ticks since the system was started. This
  657. value is periodically updated and serves only as a reasonable
  658. approximation of the current time counter.
  659. SystemTime - Stores the current system time.
  660. TickCount - Stores the number of clock interrupts that have occurred since
  661. the system started. Clock interrupts do not necessarily occur at the
  662. same interval and thus cannot be used to accurately measure time. This
  663. member is incremented each time the time counter and system time
  664. members are updated, so it can be used to detect torn reads.
  665. TickCount2 - Stores a copy of the tick count value, updated after all the
  666. other time members are updated (with a memory barrier in between the
  667. updates of all other time variables and this one).
  668. CurrentTimeZoneDataSize - Stores the size in bytes needed to get the
  669. current system time zone data.
  670. ProcessorFeatures - Stores a bitfield of architecture-specific feature
  671. flags.
  672. --*/
  673. typedef struct _USER_SHARED_DATA {
  674. ULONG EncodedSystemVersion;
  675. ULONG SystemVersionSerial;
  676. ULONGLONG BuildTime;
  677. ULONGLONG TimeCounterFrequency;
  678. ULONGLONG ProcessorCounterFrequency;
  679. volatile SYSTEM_TIME TimeOffset;
  680. volatile ULONGLONG TimeCounter;
  681. volatile SYSTEM_TIME SystemTime;
  682. volatile ULONGLONG TickCount;
  683. volatile ULONGLONG TickCount2;
  684. volatile ULONG CurrentTimeZoneDataSize;
  685. ULONG ProcessorFeatures;
  686. } USER_SHARED_DATA, *PUSER_SHARED_DATA;
  687. //
  688. // -------------------------------------------------------------------- Globals
  689. //
  690. //
  691. // -------------------------------------------------------- Function Prototypes
  692. //
  693. KERNEL_API
  694. KSTATUS
  695. KeGetSystemVersion (
  696. PSYSTEM_VERSION_INFORMATION VersionInformation,
  697. PVOID Buffer,
  698. PULONG BufferSize
  699. );
  700. /*++
  701. Routine Description:
  702. This routine gets the system version information.
  703. Arguments:
  704. VersionInformation - Supplies a pointer where the system version
  705. information will be returned.
  706. Buffer - Supplies an optional pointer to the buffer to use for the
  707. product name and build string.
  708. BufferSize - Supplies an optional pointer that on input contains the size
  709. of the supplied string buffer in bytes. On output, returns the needed
  710. size of the build string buffer in bytes including the null terminator
  711. characters.
  712. Return Value:
  713. STATUS_SUCCESS on success.
  714. STATUS_BUFFER_TOO_SMALL if the supplied buffer was not big enough to hold
  715. both strings.
  716. --*/
  717. KERNEL_API
  718. PQUEUED_LOCK
  719. KeCreateQueuedLock (
  720. VOID
  721. );
  722. /*++
  723. Routine Description:
  724. This routine creates a new queued lock under the current thread. These locks
  725. can be used at up to dispatch level if non-paged memory is used.
  726. Arguments:
  727. None.
  728. Return Value:
  729. Returns a pointer to the new lock on success.
  730. NULL on failure.
  731. --*/
  732. KERNEL_API
  733. VOID
  734. KeDestroyQueuedLock (
  735. PQUEUED_LOCK Lock
  736. );
  737. /*++
  738. Routine Description:
  739. This routine destroys a queued lock by decrementing its reference count.
  740. Arguments:
  741. Lock - Supplies a pointer to the queued lock to destroy.
  742. Return Value:
  743. None. When the function returns, the lock must not be used again.
  744. --*/
  745. KERNEL_API
  746. VOID
  747. KeAcquireQueuedLock (
  748. PQUEUED_LOCK Lock
  749. );
  750. /*++
  751. Routine Description:
  752. This routine acquires the queued lock. If the lock is held, the thread
  753. blocks until it becomes available.
  754. Arguments:
  755. Lock - Supplies a pointer to the queued lock to acquire.
  756. Return Value:
  757. None. When the function returns, the lock will be held.
  758. --*/
  759. KERNEL_API
  760. KSTATUS
  761. KeAcquireQueuedLockTimed (
  762. PQUEUED_LOCK Lock,
  763. ULONG TimeoutInMilliseconds
  764. );
  765. /*++
  766. Routine Description:
  767. This routine acquires the queued lock. If the lock is held, the thread
  768. blocks until it becomes available or the specified timeout expires.
  769. Arguments:
  770. Lock - Supplies a pointer to the queued lock to acquire.
  771. TimeoutInMilliseconds - Supplies the number of milliseconds that the given
  772. object should be waited on before timing out. Use WAIT_TIME_INDEFINITE
  773. to wait forever on the object.
  774. Return Value:
  775. STATUS_SUCCESS on success.
  776. STATUS_TIMEOUT if the specified amount of time expired and the lock could
  777. not be acquired.
  778. --*/
  779. KERNEL_API
  780. VOID
  781. KeReleaseQueuedLock (
  782. PQUEUED_LOCK Lock
  783. );
  784. /*++
  785. Routine Description:
  786. This routine releases a queued lock that has been previously acquired.
  787. Arguments:
  788. Lock - Supplies a pointer to the queued lock to release.
  789. Return Value:
  790. None.
  791. --*/
  792. KERNEL_API
  793. BOOL
  794. KeTryToAcquireQueuedLock (
  795. PQUEUED_LOCK Lock
  796. );
  797. /*++
  798. Routine Description:
  799. This routine attempts to acquire the queued lock. If the lock is busy, it
  800. does not add this thread to the queue of waiters.
  801. Arguments:
  802. Lock - Supplies a pointer to a queued lock.
  803. Return Value:
  804. Returns TRUE if the lock was acquired, or FALSE otherwise.
  805. --*/
  806. KERNEL_API
  807. BOOL
  808. KeIsQueuedLockHeld (
  809. PQUEUED_LOCK Lock
  810. );
  811. /*++
  812. Routine Description:
  813. This routine determines whether a queued lock is acquired or free.
  814. Arguments:
  815. Lock - Supplies a pointer to the queued lock.
  816. Return Value:
  817. TRUE if the queued lock is held.
  818. FALSE if the queued lock is free.
  819. --*/
  820. KERNEL_API
  821. VOID
  822. KeInitializeSpinLock (
  823. PKSPIN_LOCK Lock
  824. );
  825. /*++
  826. Routine Description:
  827. This routine initializes a spinlock.
  828. Arguments:
  829. Lock - Supplies a pointer to the lock to initialize.
  830. Return Value:
  831. None.
  832. --*/
  833. KERNEL_API
  834. VOID
  835. KeAcquireSpinLock (
  836. PKSPIN_LOCK Lock
  837. );
  838. /*++
  839. Routine Description:
  840. This routine acquires a kernel spinlock. It must be acquired at or below
  841. dispatch level. This routine may yield the processor.
  842. Arguments:
  843. Lock - Supplies a pointer to the lock to acquire.
  844. Return Value:
  845. None.
  846. --*/
  847. KERNEL_API
  848. VOID
  849. KeReleaseSpinLock (
  850. PKSPIN_LOCK Lock
  851. );
  852. /*++
  853. Routine Description:
  854. This routine releases a kernel spinlock.
  855. Arguments:
  856. Lock - Supplies a pointer to the lock to release.
  857. Return Value:
  858. None.
  859. --*/
  860. KERNEL_API
  861. BOOL
  862. KeTryToAcquireSpinLock (
  863. PKSPIN_LOCK Lock
  864. );
  865. /*++
  866. Routine Description:
  867. This routine makes one attempt to acquire a spinlock.
  868. Arguments:
  869. Lock - Supplies a pointer to the lock to attempt to acquire.
  870. Return Value:
  871. TRUE if the lock was acquired.
  872. FALSE if the lock was not acquired.
  873. --*/
  874. KERNEL_API
  875. BOOL
  876. KeIsSpinLockHeld (
  877. PKSPIN_LOCK Lock
  878. );
  879. /*++
  880. Routine Description:
  881. This routine determines whether a spin lock is held or free.
  882. Arguments:
  883. Lock - Supplies a pointer to the lock to check.
  884. Return Value:
  885. TRUE if the lock has been acquired.
  886. FALSE if the lock is free.
  887. --*/
  888. KERNEL_API
  889. PSHARED_EXCLUSIVE_LOCK
  890. KeCreateSharedExclusiveLock (
  891. VOID
  892. );
  893. /*++
  894. Routine Description:
  895. This routine creates a shared-exclusive lock.
  896. Arguments:
  897. None.
  898. Return Value:
  899. Returns a pointer to a shared-exclusive lock on success, or NULL on failure.
  900. --*/
  901. KERNEL_API
  902. VOID
  903. KeDestroySharedExclusiveLock (
  904. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  905. );
  906. /*++
  907. Routine Description:
  908. This routine destroys a shared-exclusive lock.
  909. Arguments:
  910. SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
  911. Return Value:
  912. None.
  913. --*/
  914. KERNEL_API
  915. VOID
  916. KeAcquireSharedExclusiveLockShared (
  917. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  918. );
  919. /*++
  920. Routine Description:
  921. This routine acquired the given shared-exclusive lock in shared mode.
  922. Arguments:
  923. SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
  924. Return Value:
  925. None.
  926. --*/
  927. KERNEL_API
  928. BOOL
  929. KeTryToAcquireSharedExclusiveLockShared (
  930. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  931. );
  932. /*++
  933. Routine Description:
  934. This routine makes a single attempt to acquire the given shared-exclusive
  935. lock in shared mode.
  936. Arguments:
  937. SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
  938. Return Value:
  939. TRUE if the lock was successfully acquired shared.
  940. FALSE if the lock was not successfully acquired shared.
  941. --*/
  942. KERNEL_API
  943. VOID
  944. KeReleaseSharedExclusiveLockShared (
  945. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  946. );
  947. /*++
  948. Routine Description:
  949. This routine releases the given shared-exclusive lock from shared mode.
  950. Arguments:
  951. SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
  952. Return Value:
  953. None.
  954. --*/
  955. KERNEL_API
  956. VOID
  957. KeAcquireSharedExclusiveLockExclusive (
  958. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  959. );
  960. /*++
  961. Routine Description:
  962. This routine acquired the given shared-exclusive lock in exclusive mode.
  963. Arguments:
  964. SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
  965. Return Value:
  966. None.
  967. --*/
  968. KERNEL_API
  969. BOOL
  970. KeTryToAcquireSharedExclusiveLockExclusive (
  971. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  972. );
  973. /*++
  974. Routine Description:
  975. This routine makes a single attempt to acquire the given shared-exclusive
  976. lock exclusively.
  977. Arguments:
  978. SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
  979. Return Value:
  980. TRUE if the lock was successfully acquired exclusively.
  981. FALSE if the lock was not successfully acquired.
  982. --*/
  983. KERNEL_API
  984. VOID
  985. KeReleaseSharedExclusiveLockExclusive (
  986. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  987. );
  988. /*++
  989. Routine Description:
  990. This routine releases the given shared-exclusive lock from exclusive mode.
  991. Arguments:
  992. SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
  993. Return Value:
  994. None.
  995. --*/
  996. KERNEL_API
  997. VOID
  998. KeSharedExclusiveLockConvertToExclusive (
  999. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  1000. );
  1001. /*++
  1002. Routine Description:
  1003. This routine converts a lock that the caller holds shared into one that
  1004. the caller holds exclusive. This routine will most likely fully release
  1005. and reacquire the lock.
  1006. Arguments:
  1007. SharedExclusiveLock - Supplies a pointer to the shared-exclusive lock.
  1008. Return Value:
  1009. None.
  1010. --*/
  1011. KERNEL_API
  1012. BOOL
  1013. KeIsSharedExclusiveLockHeld (
  1014. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  1015. );
  1016. /*++
  1017. Routine Description:
  1018. This routine determines whether a shared-exclusive lock is held or free.
  1019. Arguments:
  1020. SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
  1021. Return Value:
  1022. Returns TRUE if the shared-exclusive lock is held, or FALSE if not.
  1023. --*/
  1024. KERNEL_API
  1025. BOOL
  1026. KeIsSharedExclusiveLockHeldExclusive (
  1027. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  1028. );
  1029. /*++
  1030. Routine Description:
  1031. This routine determines whether a shared-exclusive lock is held exclusively
  1032. or not.
  1033. Arguments:
  1034. SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
  1035. Return Value:
  1036. Returns TRUE if the shared-exclusive lock is held exclusively, or FALSE
  1037. otherwise.
  1038. --*/
  1039. KERNEL_API
  1040. BOOL
  1041. KeIsSharedExclusiveLockHeldShared (
  1042. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  1043. );
  1044. /*++
  1045. Routine Description:
  1046. This routine determines whether a shared-exclusive lock is held shared or
  1047. not.
  1048. Arguments:
  1049. SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
  1050. Return Value:
  1051. Returns TRUE if the shared-exclusive lock is held shared, or FALSE
  1052. otherwise.
  1053. --*/
  1054. KERNEL_API
  1055. BOOL
  1056. KeIsSharedExclusiveLockContended (
  1057. PSHARED_EXCLUSIVE_LOCK SharedExclusiveLock
  1058. );
  1059. /*++
  1060. Routine Description:
  1061. This routine determines whether a shared-exclusive lock is being waited on
  1062. for shared or exclusive access.
  1063. Arguments:
  1064. SharedExclusiveLock - Supplies a pointer to a shared-exclusive lock.
  1065. Return Value:
  1066. Returns TRUE if other threads are waiting to acquire the lock, or FALSE
  1067. if the lock is uncontented.
  1068. --*/
  1069. KERNEL_API
  1070. RUNLEVEL
  1071. KeGetRunLevel (
  1072. VOID
  1073. );
  1074. /*++
  1075. Routine Description:
  1076. This routine gets the running level for the current processor.
  1077. Arguments:
  1078. None.
  1079. Return Value:
  1080. Returns the current run level.
  1081. --*/
  1082. KERNEL_API
  1083. PDPC
  1084. KeCreateDpc (
  1085. PDPC_ROUTINE DpcRoutine,
  1086. PVOID UserData
  1087. );
  1088. /*++
  1089. Routine Description:
  1090. This routine creates a new DPC with the given routine and context data.
  1091. Arguments:
  1092. DpcRoutine - Supplies a pointer to the routine to call when the DPC fires.
  1093. UserData - Supplies a context pointer that can be passed to the routine via
  1094. the DPC when it is called.
  1095. Return Value:
  1096. Returns a pointer to the allocated and initialized (but not queued) DPC.
  1097. --*/
  1098. KERNEL_API
  1099. VOID
  1100. KeDestroyDpc (
  1101. PDPC Dpc
  1102. );
  1103. /*++
  1104. Routine Description:
  1105. This routine destroys a DPC. It will cancel the DPC if it is queued, and
  1106. wait for it to finish if it is running. This routine must be called from
  1107. low level.
  1108. Arguments:
  1109. Dpc - Supplies a pointer to the DPC to destroy.
  1110. Return Value:
  1111. None.
  1112. --*/
  1113. KERNEL_API
  1114. VOID
  1115. KeQueueDpc (
  1116. PDPC Dpc
  1117. );
  1118. /*++
  1119. Routine Description:
  1120. This routine queues a DPC on the current processor.
  1121. Arguments:
  1122. Dpc - Supplies a pointer to the DPC to queue.
  1123. Return Value:
  1124. None.
  1125. --*/
  1126. KERNEL_API
  1127. VOID
  1128. KeQueueDpcOnProcessor (
  1129. PDPC Dpc,
  1130. ULONG ProcessorNumber
  1131. );
  1132. /*++
  1133. Routine Description:
  1134. This routine queues a DPC on the given processor.
  1135. Arguments:
  1136. Dpc - Supplies a pointer to the DPC to queue.
  1137. ProcessorNumber - Supplies the processor number of the processor to queue
  1138. the DPC on.
  1139. Return Value:
  1140. None.
  1141. --*/
  1142. KERNEL_API
  1143. KSTATUS
  1144. KeCancelDpc (
  1145. PDPC Dpc
  1146. );
  1147. /*++
  1148. Routine Description:
  1149. This routine attempts to cancel a DPC that has been queued.
  1150. Arguments:
  1151. Dpc - Supplies a pointer to the DPC to cancel.
  1152. Return Value:
  1153. STATUS_SUCCESS if the DPC was successfully pulled out of a queue.
  1154. STATUS_TOO_LATE if the DPC has already started running.
  1155. --*/
  1156. KERNEL_API
  1157. VOID
  1158. KeFlushDpc (
  1159. PDPC Dpc
  1160. );
  1161. /*++
  1162. Routine Description:
  1163. This routine does not return until the given DPC is out of the system. This
  1164. means that the DPC is neither queued nor running. It's worth noting that
  1165. this routine busy spins at dispatch level, and should therefore be used
  1166. only sparingly. This routine can only be called from low level.
  1167. Arguments:
  1168. Dpc - Supplies a pointer to the DPC to wait for.
  1169. Return Value:
  1170. None.
  1171. --*/
  1172. KERNEL_API
  1173. PKTIMER
  1174. KeCreateTimer (
  1175. ULONG AllocationTag
  1176. );
  1177. /*++
  1178. Routine Description:
  1179. This routine creates a new timer object. Once created, this timer needs to
  1180. be initialized before it can be queued. This routine must be called at or
  1181. below dispatch level.
  1182. Arguments:
  1183. AllocationTag - Supplies a pointer to an identifier to use for the
  1184. allocation that uniquely identifies the driver or module allocating the
  1185. timer.
  1186. Return Value:
  1187. Returns a pointer to the timer on success.
  1188. NULL on resource allocation failure.
  1189. --*/
  1190. KERNEL_API
  1191. VOID
  1192. KeDestroyTimer (
  1193. PKTIMER Timer
  1194. );
  1195. /*++
  1196. Routine Description:
  1197. This routine destroys a timer object. If the timer is currently queued, this
  1198. routine cancels the timer and then destroys it. This routine must be called
  1199. at or below dispatch level.
  1200. Arguments:
  1201. Timer - Supplies a pointer to the timer to destroy.
  1202. Return Value:
  1203. None.
  1204. --*/
  1205. KERNEL_API
  1206. KSTATUS
  1207. KeQueueTimer (
  1208. PKTIMER Timer,
  1209. TIMER_QUEUE_TYPE QueueType,
  1210. ULONGLONG DueTime,
  1211. ULONGLONG Period,
  1212. ULONG Flags,
  1213. PDPC Dpc
  1214. );
  1215. /*++
  1216. Routine Description:
  1217. This routine configures and queues a timer object. The timer must not
  1218. already be queued, otherwise the system will crash. This routine must be
  1219. called at or below dispatch level.
  1220. Arguments:
  1221. Timer - Supplies a pointer to the timer to configure and queue.
  1222. QueueType - Supplies the queue the timer should reside on. Valid values are:
  1223. TimerQueueSoft - The timer will be expired at the first applicable
  1224. clock interrupt, but a clock interrupt will not be scheduled solely
  1225. for this timer. This timer type has the best power management
  1226. profile, but may cause the expiration of the timer to be fairly
  1227. late, as the system will not come out of idle to service this timer.
  1228. The DPC for this timer may run on any processor.
  1229. TimerQueueSoftWake - The timer will be expired at the first applicable
  1230. clock interrupt. If the system was otherwise idle, a clock
  1231. interrupt will be scheduled for this timer. This is a balanced
  1232. choice for timers that can have some slack in their expiration, but
  1233. need to run approximately when scheduled, even if the system is
  1234. idle. The DPC will run on the processor where the timer was queued.
  1235. TimerQueueHard - A clock interrupt will be scheduled for exactly the
  1236. specified deadline. This is the best choice for high performance
  1237. timers that need to expire as close to their deadlines as possible.
  1238. It is the most taxing on power management, as it pulls the system
  1239. out of idle, schedules an extra clock interrupt, and requires
  1240. programming hardware. The DPC will run on the processor where the
  1241. timer was queued.
  1242. DueTime - Supplies the value of the time tick counter when this timer
  1243. should expire (an absolute value in time counter ticks). If this value
  1244. is 0, then an automatic due time of the current time plus the given
  1245. period will be computed.
  1246. Period - Supplies an optional period, in time counter ticks, for periodic
  1247. timers. If this value is non-zero, the period will be added to the
  1248. original due time and the timer will be automatically rearmed.
  1249. Flags - Supplies an optional bitfield of flags. See KTIMER_FLAG_*
  1250. definitions.
  1251. Dpc - Supplies an optional pointer to a DPC that will be queued when this
  1252. timer expires.
  1253. Return Value:
  1254. Status code.
  1255. --*/
  1256. KERNEL_API
  1257. KSTATUS
  1258. KeCancelTimer (
  1259. PKTIMER Timer
  1260. );
  1261. /*++
  1262. Routine Description:
  1263. This routine attempts to cancel a queued timer. This routine must be called
  1264. at or below dispatch level. This routine will ensure that the DPC
  1265. associated with the timer will have either been fully queued or not queued
  1266. by the time this function returns, even if the timer was too late to
  1267. cancel.
  1268. Arguments:
  1269. Timer - Supplies a pointer to the timer to cancel.
  1270. Return Value:
  1271. STATUS_SUCCESS if the timer was successfully cancelled.
  1272. STATUS_TOO_LATE if the timer expired before the timer queue could be
  1273. accessed.
  1274. --*/
  1275. KERNEL_API
  1276. VOID
  1277. KeSignalTimer (
  1278. PKTIMER Timer,
  1279. SIGNAL_OPTION Option
  1280. );
  1281. /*++
  1282. Routine Description:
  1283. This routine sets a timer to the given signal state.
  1284. Arguments:
  1285. Timer - Supplies a pointer to the timer to signal or unsignal.
  1286. Option - Supplies the signaling behavior to apply.
  1287. Return Value:
  1288. None.
  1289. --*/
  1290. KERNEL_API
  1291. SIGNAL_STATE
  1292. KeGetTimerState (
  1293. PKTIMER Timer
  1294. );
  1295. /*++
  1296. Routine Description:
  1297. This routine returns the signal state of a timer.
  1298. Arguments:
  1299. Timer - Supplies a pointer to the timer to get the state of.
  1300. Return Value:
  1301. Returns the signal state of the timer.
  1302. --*/
  1303. KERNEL_API
  1304. ULONGLONG
  1305. KeGetTimerDueTime (
  1306. PKTIMER Timer
  1307. );
  1308. /*++
  1309. Routine Description:
  1310. This routine returns the next due time of the given timer. This could be in
  1311. the past. This routine must be called at or below dispatch level.
  1312. Arguments:
  1313. Timer - Supplies a pointer to the timer to query.
  1314. Return Value:
  1315. Returns the due time of the timer.
  1316. 0 if the timer is not currently queued.
  1317. --*/
  1318. KERNEL_API
  1319. ULONGLONG
  1320. KeConvertMicrosecondsToTimeTicks (
  1321. ULONGLONG Microseconds
  1322. );
  1323. /*++
  1324. Routine Description:
  1325. This routine converts the given number of microseconds into time counter
  1326. ticks.
  1327. Arguments:
  1328. Microseconds - Supplies the microsecond count.
  1329. Return Value:
  1330. Returns the number of time ticks that correspond to the given number of
  1331. microseconds.
  1332. --*/
  1333. KERNEL_API
  1334. ULONGLONG
  1335. KeGetRecentTimeCounter (
  1336. VOID
  1337. );
  1338. /*++
  1339. Routine Description:
  1340. This routine returns a relatively recent snap of the time counter.
  1341. Arguments:
  1342. None.
  1343. Return Value:
  1344. Returns the fairly recent snap of the time counter.
  1345. --*/
  1346. KERNEL_API
  1347. KSTATUS
  1348. KeSetSystemTimeZone (
  1349. PSTR ZoneName,
  1350. PSTR OriginalZoneBuffer,
  1351. PULONG OriginalZoneBufferSize
  1352. );
  1353. /*++
  1354. Routine Description:
  1355. This routine attempts to set the system's time zone.
  1356. Arguments:
  1357. ZoneName - Supplies an optional pointer to the null terminated string
  1358. containing the name of the time zone to set. If this parameter is NULL,
  1359. then the current time zone will be returned an no other changes will
  1360. be made.
  1361. OriginalZoneBuffer - Supplies an optional pointer where the original (or
  1362. current if no new time zone was provided) time zone will be returned.
  1363. This must be allocated in non-paged pool.
  1364. OriginalZoneBufferSize - Supplies a pointer that on input contains the
  1365. size of the original zone buffer in bytes. On output, this value will
  1366. contain the size of the original zone buffer needed to contain the
  1367. name of the current time zone (even if no buffer was provided).
  1368. Return Value:
  1369. Status code.
  1370. --*/
  1371. KERNEL_API
  1372. KSTATUS
  1373. KeGetCurrentTimeZoneOffset (
  1374. PLONG TimeZoneOffset
  1375. );
  1376. /*++
  1377. Routine Description:
  1378. This routine returns the current time zone offset. Note that this data is
  1379. stale as soon as it is returned.
  1380. Arguments:
  1381. TimeZoneOffset - Supplies a pointer where the current (or really
  1382. immediately previous) time zone offset in seconds to be added to GMT
  1383. will be returned.
  1384. Return Value:
  1385. Status code.
  1386. --*/
  1387. KERNEL_API
  1388. KSTATUS
  1389. KeGetSetSystemInformation (
  1390. SYSTEM_INFORMATION_SUBSYSTEM Subsystem,
  1391. UINTN InformationType,
  1392. PVOID Data,
  1393. PUINTN DataSize,
  1394. BOOL Set
  1395. );
  1396. /*++
  1397. Routine Description:
  1398. This routine gets or sets system information.
  1399. Arguments:
  1400. Subsystem - Supplies the subsystem to query or set information of.
  1401. InformationType - Supplies the information type, which is specific to
  1402. the subsystem. The type of this value is generally
  1403. <subsystem>_INFORMATION_TYPE (eg IO_INFORMATION_TYPE).
  1404. Data - Supplies a pointer to the data buffer where the data is either
  1405. returned for a get operation or given for a set operation.
  1406. DataSize - Supplies a pointer that on input contains the size of the
  1407. data buffer. On output, contains the required size of the data buffer.
  1408. Set - Supplies a boolean indicating if this is a get operation (FALSE) or
  1409. a set operation (TRUE).
  1410. Return Value:
  1411. STATUS_SUCCESS if the information was successfully queried or set.
  1412. STATUS_BUFFER_TOO_SMALL if the buffer size specified was too small. The
  1413. required buffer size will be returned in the data size parameter.
  1414. STATUS_DATA_LENGTH_MISMATCH if the buffer size was not correct. The
  1415. correct buffer size will be returned in the data size parameter.
  1416. STATUS_INVALID_PARAMETER if the given subsystem or information type is
  1417. not known.
  1418. Other status codes on other failures.
  1419. --*/
  1420. KERNEL_API
  1421. PKERNEL_ARGUMENT
  1422. KeGetKernelArgument (
  1423. PKERNEL_ARGUMENT Start,
  1424. PSTR Component,
  1425. PSTR Name
  1426. );
  1427. /*++
  1428. Routine Description:
  1429. This routine looks up a kernel command line argument.
  1430. Arguments:
  1431. Start - Supplies an optional pointer to the previous command line argument
  1432. to start from. Supply NULL here initially.
  1433. Component - Supplies a pointer to the component string to look up.
  1434. Name - Supplies a pointer to the argument name to look up.
  1435. Return Value:
  1436. Returns a pointer to a matching kernel argument on success.
  1437. NULL if no argument could be found.
  1438. --*/
  1439. KERNEL_API
  1440. KSTATUS
  1441. KeResetSystem (
  1442. SYSTEM_RESET_TYPE ResetType
  1443. );
  1444. /*++
  1445. Routine Description:
  1446. This routine attempts to reboot the system. This routine must be called
  1447. from low level.
  1448. Arguments:
  1449. ResetType - Supplies the desired system reset type. If the given type is
  1450. not supported and a cold reset is, then a cold reset will be
  1451. performed.
  1452. Return Value:
  1453. Does not return on success, the system is reset.
  1454. STATUS_INVALID_PARAMETER if an invalid reset type was supplied.
  1455. STATUS_NOT_SUPPORTED if the system cannot be reset.
  1456. STATUS_UNSUCCESSFUL if the system did not reset.
  1457. --*/
  1458. INTN
  1459. KeSysTimeZoneControl (
  1460. PVOID SystemCallParameter
  1461. );
  1462. /*++
  1463. Routine Description:
  1464. This routine performs system time zone control operations.
  1465. Arguments:
  1466. SystemCallParameter - Supplies a pointer to the parameters supplied with
  1467. the system call. This structure will be a stack-local copy of the
  1468. actual parameters passed from user-mode.
  1469. Return Value:
  1470. STATUS_SUCCESS or positive integer on success.
  1471. Error status code on failure.
  1472. --*/
  1473. INTN
  1474. KeSysGetSetSystemInformation (
  1475. PVOID SystemCallParameter
  1476. );
  1477. /*++
  1478. Routine Description:
  1479. This routine implements the user mode system call for getting and setting
  1480. system information.
  1481. Arguments:
  1482. SystemCallParameter - Supplies a pointer to the parameters supplied with
  1483. the system call. This structure will be a stack-local copy of the
  1484. actual parameters passed from user-mode.
  1485. Return Value:
  1486. STATUS_SUCCESS or positive integer on success.
  1487. Error status code on failure.
  1488. --*/
  1489. INTN
  1490. KeSysResetSystem (
  1491. PVOID SystemCallParameter
  1492. );
  1493. /*++
  1494. Routine Description:
  1495. This routine implements the system call for resetting the system.
  1496. Arguments:
  1497. SystemCallParameter - Supplies a pointer to the parameters supplied with
  1498. the system call. This structure will be a stack-local copy of the
  1499. actual parameters passed from user-mode.
  1500. Return Value:
  1501. STATUS_SUCCESS or positive integer on success.
  1502. Error status code on failure.
  1503. --*/
  1504. PPROCESSOR_BLOCK
  1505. KeGetCurrentProcessorBlock (
  1506. VOID
  1507. );
  1508. /*++
  1509. Routine Description:
  1510. This routine gets the processor state for the currently executing processor.
  1511. Arguments:
  1512. None.
  1513. Return Value:
  1514. Returns the current processor block.
  1515. --*/
  1516. PPROCESSOR_BLOCK
  1517. KeGetCurrentProcessorBlockForDebugger (
  1518. VOID
  1519. );
  1520. /*++
  1521. Routine Description:
  1522. This routine gets the processor block for the currently executing
  1523. processor. It is intended to be called only by the debugger.
  1524. Arguments:
  1525. None.
  1526. Return Value:
  1527. Returns the current processor block.
  1528. --*/
  1529. ULONG
  1530. KeGetCurrentProcessorNumber (
  1531. VOID
  1532. );
  1533. /*++
  1534. Routine Description:
  1535. This routine gets the processor number for the currently executing
  1536. processor.
  1537. Arguments:
  1538. None.
  1539. Return Value:
  1540. Returns the current zero-indexed processor number.
  1541. --*/
  1542. ULONG
  1543. KeGetActiveProcessorCount (
  1544. VOID
  1545. );
  1546. /*++
  1547. Routine Description:
  1548. This routine gets the number of processors currently running in the
  1549. system.
  1550. Arguments:
  1551. None.
  1552. Return Value:
  1553. Returns the number of active processors currently in the system.
  1554. --*/
  1555. PKTHREAD
  1556. KeGetCurrentThread (
  1557. VOID
  1558. );
  1559. /*++
  1560. Routine Description:
  1561. This routine gets the current thread running on this processor.
  1562. Arguments:
  1563. None.
  1564. Return Value:
  1565. Returns the current run level.
  1566. --*/
  1567. KERNEL_API
  1568. RUNLEVEL
  1569. KeRaiseRunLevel (
  1570. RUNLEVEL RunLevel
  1571. );
  1572. /*++
  1573. Routine Description:
  1574. This routine raises the running level of the current processor to the given
  1575. level.
  1576. Arguments:
  1577. RunLevel - Supplies the new running level of the current processor.
  1578. Return Value:
  1579. Returns the old running level of the processor.
  1580. --*/
  1581. KERNEL_API
  1582. VOID
  1583. KeLowerRunLevel (
  1584. RUNLEVEL RunLevel
  1585. );
  1586. /*++
  1587. Routine Description:
  1588. This routine lowers the running level of the current processor to the given
  1589. level.
  1590. Arguments:
  1591. RunLevel - Supplies the new running level of the current processor.
  1592. Return Value:
  1593. None.
  1594. --*/
  1595. KERNEL_API
  1596. PKEVENT
  1597. KeCreateEvent (
  1598. PVOID ParentObject
  1599. );
  1600. /*++
  1601. Routine Description:
  1602. This routine creates a kernel event. It comes initialized to Not Signaled.
  1603. Arguments:
  1604. ParentObject - Supplies an optional parent object to create the event
  1605. under.
  1606. Return Value:
  1607. Returns a pointer to the event, or NULL if the event could not be created.
  1608. --*/
  1609. KERNEL_API
  1610. VOID
  1611. KeDestroyEvent (
  1612. PKEVENT Event
  1613. );
  1614. /*++
  1615. Routine Description:
  1616. This routine destroys an event created with KeCreateEvent. The event is no
  1617. longer valid after this call.
  1618. Arguments:
  1619. Event - Supplies a pointer to the event to free.
  1620. Return Value:
  1621. None.
  1622. --*/
  1623. KERNEL_API
  1624. KSTATUS
  1625. KeWaitForEvent (
  1626. PKEVENT Event,
  1627. BOOL Interruptible,
  1628. ULONG TimeoutInMilliseconds
  1629. );
  1630. /*++
  1631. Routine Description:
  1632. This routine waits until an event enters a signaled state.
  1633. Arguments:
  1634. Event - Supplies a pointer to the event to wait for.
  1635. Interruptible - Supplies a boolean indicating whether or not the wait can
  1636. be interrupted if a signal is sent to the process on which this thread
  1637. runs. If TRUE is supplied, the caller must check the return status
  1638. code to find out if the wait was really satisfied or just interrupted.
  1639. TimeoutInMilliseconds - Supplies the number of milliseconds that the given
  1640. objects should be waited on before timing out. Use WAIT_TIME_INDEFINITE
  1641. to wait forever on these objects.
  1642. Return Value:
  1643. Status code.
  1644. --*/
  1645. KERNEL_API
  1646. VOID
  1647. KeSignalEvent (
  1648. PKEVENT Event,
  1649. SIGNAL_OPTION Option
  1650. );
  1651. /*++
  1652. Routine Description:
  1653. This routine sets an event to the given signal state.
  1654. Arguments:
  1655. Event - Supplies a pointer to the event to signal or unsignal.
  1656. Option - Supplies the signaling behavior to apply.
  1657. Return Value:
  1658. None.
  1659. --*/
  1660. KERNEL_API
  1661. SIGNAL_STATE
  1662. KeGetEventState (
  1663. PKEVENT Event
  1664. );
  1665. /*++
  1666. Routine Description:
  1667. This routine returns the signal state of an event.
  1668. Arguments:
  1669. Event - Supplies a pointer to the event to get the state of.
  1670. Return Value:
  1671. Returns the signal state of the event.
  1672. --*/
  1673. KERNEL_API
  1674. PWORK_QUEUE
  1675. KeCreateWorkQueue (
  1676. ULONG Flags,
  1677. PSTR Name
  1678. );
  1679. /*++
  1680. Routine Description:
  1681. This routine creates a new work queue.
  1682. Arguments:
  1683. Flags - Supplies a bitfield of flags governing the behavior of the work
  1684. queue. See WORK_QUEUE_FLAG_* definitions.
  1685. Name - Supplies an optional pointer to the name of the worker threads
  1686. created. A copy of this memory will be made. This should only be used
  1687. for debugging, as text may be added to the end of the name supplied
  1688. here to the actual worker thread names.
  1689. Return Value:
  1690. Returns a pointer to the new work queue on success.
  1691. NULL on failure.
  1692. --*/
  1693. KERNEL_API
  1694. VOID
  1695. KeDestroyWorkQueue (
  1696. PWORK_QUEUE WorkQueue
  1697. );
  1698. /*++
  1699. Routine Description:
  1700. This routine destroys a work queue. If there are items on the work queue,
  1701. they will be completed.
  1702. Arguments:
  1703. WorkQueue - Supplies a pointer to the work queue to destroy.
  1704. Return Value:
  1705. None.
  1706. --*/
  1707. KERNEL_API
  1708. VOID
  1709. KeFlushWorkQueue (
  1710. PWORK_QUEUE WorkQueue
  1711. );
  1712. /*++
  1713. Routine Description:
  1714. This routine flushes a work queue. If there are items on the work queue,
  1715. they will be completed before this routine returns.
  1716. Arguments:
  1717. WorkQueue - Supplies a pointer to the work queue to flush.
  1718. Return Value:
  1719. None.
  1720. --*/
  1721. KERNEL_API
  1722. PWORK_ITEM
  1723. KeCreateWorkItem (
  1724. PWORK_QUEUE WorkQueue,
  1725. WORK_PRIORITY Priority,
  1726. PWORK_ITEM_ROUTINE WorkRoutine,
  1727. PVOID Parameter,
  1728. ULONG AllocationTag
  1729. );
  1730. /*++
  1731. Routine Description:
  1732. This routine creates a new reusable work item.
  1733. Arguments:
  1734. WorkQueue - Supplies a pointer to the queue this work item will
  1735. eventually be queued to. Supply NULL to use the system work queue.
  1736. Priority - Supplies the work priority.
  1737. WorkRoutine - Supplies the routine to execute to does the work. This
  1738. routine should be prepared to take one parameter.
  1739. Parameter - Supplies an optional parameter to pass to the worker routine.
  1740. AllocationTag - Supplies an allocation tag to associate with the work item.
  1741. Return Value:
  1742. Returns a pointer to the new work item on success.
  1743. NULL on failure.
  1744. --*/
  1745. KERNEL_API
  1746. VOID
  1747. KeDestroyWorkItem (
  1748. PWORK_ITEM WorkItem
  1749. );
  1750. /*++
  1751. Routine Description:
  1752. This routine destroys a reusable work item. If this is a work item that
  1753. can re-queue itself, then the caller needs to make sure that that can no
  1754. longer happen before trying to destroy the work item.
  1755. Arguments:
  1756. WorkItem - Supplies a pointer to the work item.
  1757. Return Value:
  1758. None.
  1759. --*/
  1760. KERNEL_API
  1761. KSTATUS
  1762. KeCancelWorkItem (
  1763. PWORK_ITEM WorkItem
  1764. );
  1765. /*++
  1766. Routine Description:
  1767. This routine attempts to cancel the work item. If the work item is still on
  1768. its work queue them this routine will pull it off and return successfully.
  1769. Otherwise the work item may have been selected to run and this routine will
  1770. return that the cancel was too late. Keep in mind that "too late" may also
  1771. mean "too early" if the work item was never queued.
  1772. Arguments:
  1773. WorkItem - Supplies a pointer to the work item to cancel.
  1774. Return Value:
  1775. Status code.
  1776. --*/
  1777. KERNEL_API
  1778. VOID
  1779. KeFlushWorkItem (
  1780. PWORK_ITEM WorkItem
  1781. );
  1782. /*++
  1783. Routine Description:
  1784. This routine does not return until the given work item has completed.
  1785. Arguments:
  1786. WorkItem - Supplies a pointer to the work item.
  1787. Return Value:
  1788. None.
  1789. --*/
  1790. KERNEL_API
  1791. VOID
  1792. KeSetWorkItemParameters (
  1793. PWORK_ITEM WorkItem,
  1794. WORK_PRIORITY Priority,
  1795. PWORK_ITEM_ROUTINE WorkRoutine,
  1796. PVOID Parameter
  1797. );
  1798. /*++
  1799. Routine Description:
  1800. This routine resets the parameters of a work item to the given parameters.
  1801. The work item must not be queued. This routine must be called at or below
  1802. dispatch level.
  1803. Arguments:
  1804. WorkItem - Supplies a pointer to the work item to modify.
  1805. Priority - Supplies the new work priority.
  1806. WorkRoutine - Supplies the routine to execute to does the work. This
  1807. routine should be prepared to take one parameter.
  1808. Parameter - Supplies an optional parameter to pass to the worker routine.
  1809. Return Value:
  1810. None.
  1811. --*/
  1812. KERNEL_API
  1813. KSTATUS
  1814. KeQueueWorkItem (
  1815. PWORK_ITEM WorkItem
  1816. );
  1817. /*++
  1818. Routine Description:
  1819. This routine queues a work item onto the work queue for execution as soon
  1820. as possible. This routine must be called from dispatch level or below.
  1821. Arguments:
  1822. WorkItem - Supplies a pointer to the work item to queue.
  1823. Return Value:
  1824. STATUS_SUCCESS on success.
  1825. STATUS_RESOURCE_IN_USE if the work item is already queued.
  1826. --*/
  1827. KERNEL_API
  1828. KSTATUS
  1829. KeCreateAndQueueWorkItem (
  1830. PWORK_QUEUE WorkQueue,
  1831. WORK_PRIORITY Priority,
  1832. PWORK_ITEM_ROUTINE WorkRoutine,
  1833. PVOID Parameter
  1834. );
  1835. /*++
  1836. Routine Description:
  1837. This routine creates and queues a work item. This work item will get
  1838. executed in a worker thread an arbitrary amount of time later. The work item
  1839. will be automatically freed after the work routine is executed.
  1840. Arguments:
  1841. WorkQueue - Supplies a pointer to the queue this work item will
  1842. eventually be queued to. Supply NULL to use the system work queue.
  1843. Priority - Supplies the work priority.
  1844. WorkRoutine - Supplies the routine to execute to doe the work. This
  1845. routine should be prepared to take one parameter.
  1846. Parameter - Supplies an optional parameter to pass to the worker routine.
  1847. Return Value:
  1848. STATUS_SUCCESS on success.
  1849. STATUS_UNSUCCESSFUL on failure.
  1850. --*/
  1851. KERNEL_API
  1852. KSTATUS
  1853. KeGetRandomBytes (
  1854. PVOID Buffer,
  1855. UINTN Size
  1856. );
  1857. /*++
  1858. Routine Description:
  1859. This routine returns pseudo-random bytes from the system's random source.
  1860. Arguments:
  1861. Buffer - Supplies a pointer where the random bytes will be returned on
  1862. success.
  1863. Size - Supplies the number of bytes of random data to get.
  1864. Return Value:
  1865. STATUS_SUCCESS on success.
  1866. STATUS_NO_SUCH_DEVICE if no pseudo-random interface is present.
  1867. --*/
  1868. INTN
  1869. KeSysDelayExecution (
  1870. PVOID SystemCallParameter
  1871. );
  1872. /*++
  1873. Routine Description:
  1874. This routine implements the system call for delaying execution of the
  1875. current thread by a specified amount of time.
  1876. Arguments:
  1877. SystemCallParameter - Supplies a pointer to the parameters supplied with
  1878. the system call. This structure will be a stack-local copy of the
  1879. actual parameters passed from user-mode.
  1880. Return Value:
  1881. STATUS_SUCCESS or positive integer on success.
  1882. Error status code on failure.
  1883. --*/
  1884. INTN
  1885. KeSysSetSystemTime (
  1886. PVOID SystemCallParameter
  1887. );
  1888. /*++
  1889. Routine Description:
  1890. This routine implements the system call for setting the system time.
  1891. Arguments:
  1892. SystemCallParameter - Supplies a pointer to the parameters supplied with
  1893. the system call. This structure will be a stack-local copy of the
  1894. actual parameters passed from user-mode.
  1895. Return Value:
  1896. STATUS_SUCCESS or positive integer on success.
  1897. Error status code on failure.
  1898. --*/
  1899. VOID
  1900. KeClockInterrupt (
  1901. VOID
  1902. );
  1903. /*++
  1904. Routine Description:
  1905. This routine handles periodic clock interrupts, updating system time and
  1906. providing pre-emptive scheduling.
  1907. Arguments:
  1908. None.
  1909. Return Value:
  1910. None.
  1911. --*/
  1912. ULONG
  1913. KeGetClockInterruptCount (
  1914. ULONG ProcessorNumber
  1915. );
  1916. /*++
  1917. Routine Description:
  1918. This routine returns the clock interrupt count of the given processor.
  1919. Arguments:
  1920. ProcessorNumber - Supplies the number of the processor whose clock
  1921. interrupt count is to be returned.
  1922. Return Value:
  1923. Returns the given processor's clock interrupt count.
  1924. --*/
  1925. VOID
  1926. KeUpdateClockForProfiling (
  1927. BOOL ProfilingEnabled
  1928. );
  1929. /*++
  1930. Routine Description:
  1931. This routine configures the clock interrupt handler for profiling.
  1932. Arguments:
  1933. ProfilingEnabled - Supplies a boolean indicating if profiling is being
  1934. enabled (TRUE) or disabled (FALSE).
  1935. Return Value:
  1936. None.
  1937. --*/
  1938. VOID
  1939. KeDispatchSoftwareInterrupt (
  1940. RUNLEVEL RunLevel,
  1941. PTRAP_FRAME TrapFrame
  1942. );
  1943. /*++
  1944. Routine Description:
  1945. This routine handles a software interrupt. Consider it the ISR for
  1946. software interrupts. On entry, interrupts are disabled. This routine may
  1947. enable interrupts, but must exit with the interrupts disabled.
  1948. Arguments:
  1949. RunLevel - Supplies the run level that that interrupt occurred on.
  1950. TrapFrame - Supplies an optional pointer to the trap frame if this interrupt
  1951. is being dispatched off a hardware interrupt. Supplying this variable
  1952. enables checking for any pending user-mode signals.
  1953. Return Value:
  1954. None.
  1955. --*/
  1956. PPROCESSOR_BLOCK
  1957. KeGetProcessorBlock (
  1958. ULONG ProcessorNumber
  1959. );
  1960. /*++
  1961. Routine Description:
  1962. This routine returns the processor block for the given processor number.
  1963. Arguments:
  1964. ProcessorNumber - Supplies the number of the processor.
  1965. Return Value:
  1966. Returns the processor block for the given processor.
  1967. NULL if the input was not a valid processor number.
  1968. --*/
  1969. KSTATUS
  1970. KeSendIpi (
  1971. PIPI_ROUTINE IpiRoutine,
  1972. PVOID IpiContext,
  1973. PPROCESSOR_SET Processors
  1974. );
  1975. /*++
  1976. Routine Description:
  1977. This routine runs the given routine at IPI level on the specified set of
  1978. processors. This routine runs synchronously: the routine will have completed
  1979. running on all processors by the time this routine returns. This routine
  1980. must be called at or below dispatch level.
  1981. Arguments:
  1982. IpiRoutine - Supplies a pointer to the routine to run at IPI level.
  1983. IpiContext - Supplies the value to pass to the IPI routine as a parameter.
  1984. Processors - Supplies the set of processors to run the IPI on.
  1985. Return Value:
  1986. Status code.
  1987. --*/
  1988. KERNEL_API
  1989. VOID
  1990. KeYield (
  1991. VOID
  1992. );
  1993. /*++
  1994. Routine Description:
  1995. This routine yields the current thread's execution. The thread remains in
  1996. the ready state, and may not actually be scheduled out if no other threads
  1997. are ready.
  1998. Arguments:
  1999. None.
  2000. Return Value:
  2001. None.
  2002. --*/
  2003. KERNEL_API
  2004. VOID
  2005. KeGetSystemTime (
  2006. PSYSTEM_TIME Time
  2007. );
  2008. /*++
  2009. Routine Description:
  2010. This routine returns the current system time.
  2011. Arguments:
  2012. Time - Supplies a pointer where the system time will be returned.
  2013. Return Value:
  2014. None.
  2015. --*/
  2016. VOID
  2017. KeGetHighPrecisionSystemTime (
  2018. PSYSTEM_TIME Time
  2019. );
  2020. /*++
  2021. Routine Description:
  2022. This routine returns a high precision snap of the current system time.
  2023. Arguments:
  2024. Time - Supplies a pointer that receives the precise system time.
  2025. Return Value:
  2026. None.
  2027. --*/
  2028. KSTATUS
  2029. KeSetSystemTime (
  2030. PSYSTEM_TIME NewTime,
  2031. ULONGLONG TimeCounter
  2032. );
  2033. /*++
  2034. Routine Description:
  2035. This routine sets the system time.
  2036. Arguments:
  2037. NewTime - Supplies a pointer to the new system time to set.
  2038. TimeCounter - Supplies the time counter value corresponding with the
  2039. moment the new system time was meant to be set by the caller.
  2040. Return Value:
  2041. Status code.
  2042. --*/
  2043. KERNEL_API
  2044. KSTATUS
  2045. KeDelayExecution (
  2046. BOOL Interruptible,
  2047. BOOL TimeTicks,
  2048. ULONGLONG Interval
  2049. );
  2050. /*++
  2051. Routine Description:
  2052. This routine blocks the current thread for the specified amount of time.
  2053. This routine can only be called at low level.
  2054. Arguments:
  2055. Interruptible - Supplies a boolean indicating if the wait can be
  2056. interrupted by a dispatched signal. If TRUE, the caller must check the
  2057. return status code to see if the wait expired or was interrupted.
  2058. TimeTicks - Supplies a boolean indicating if the interval parameter is
  2059. represented in time counter ticks (TRUE) or microseconds (FALSE).
  2060. Interval - Supplies the interval to wait. If the time ticks parameter is
  2061. TRUE, this parameter represents an absolute time in time counter ticks.
  2062. If the time ticks parameter is FALSE, this parameter represents a
  2063. relative time from now in microseconds. If an interval of 0 is
  2064. supplied, this routine is equivalent to KeYield.
  2065. Return Value:
  2066. STATUS_SUCCESS if the wait completed.
  2067. STATUS_INTERRUPTED if the wait was interrupted.
  2068. --*/
  2069. KERNEL_API
  2070. KSTATUS
  2071. KeGetProcessorCycleAccounting (
  2072. ULONG ProcessorNumber,
  2073. PPROCESSOR_CYCLE_ACCOUNTING Accounting
  2074. );
  2075. /*++
  2076. Routine Description:
  2077. This routine returns a snapshot of the given processor's cycle accounting
  2078. information.
  2079. Arguments:
  2080. ProcessorNumber - Supplies the processor number to query.
  2081. Accounting - Supplies a pointer where the processor accounting information
  2082. will be returned.
  2083. Return Value:
  2084. STATUS_SUCCESS on success.
  2085. STATUS_INVALID_PARAMETER if an invalid processor number was supplied.
  2086. --*/
  2087. KERNEL_API
  2088. VOID
  2089. KeGetTotalProcessorCycleAccounting (
  2090. PPROCESSOR_CYCLE_ACCOUNTING Accounting
  2091. );
  2092. /*++
  2093. Routine Description:
  2094. This routine returns a snapshot of the accumulation of all processors'
  2095. cycle accounting information.
  2096. Arguments:
  2097. Accounting - Supplies a pointer where the processor accounting information
  2098. will be returned.
  2099. Return Value:
  2100. None.
  2101. --*/
  2102. VOID
  2103. KeSchedulerEntry (
  2104. SCHEDULER_REASON Reason
  2105. );
  2106. /*++
  2107. Routine Description:
  2108. This routine serves as the entry point to the thread scheduler. It may
  2109. decide to schedule a new thread or simply return.
  2110. Arguments:
  2111. Reason - Supplies the scheduler with the reason why it's being called (ie
  2112. run-level lowering, the thread is waiting, exiting, etc).
  2113. Return Value:
  2114. None.
  2115. --*/
  2116. VOID
  2117. KeSetThreadReady (
  2118. PKTHREAD Thread
  2119. );
  2120. /*++
  2121. Routine Description:
  2122. This routine unblocks a previously blocked thread and adds it to the
  2123. ready queue.
  2124. Arguments:
  2125. Thread - Supplies a pointer to the blocked thread.
  2126. Return Value:
  2127. None.
  2128. --*/
  2129. VOID
  2130. KeSuspendExecution (
  2131. VOID
  2132. );
  2133. /*++
  2134. Routine Description:
  2135. This routine suspends execution of the current thread until such time as
  2136. another thread wakes it (usually because of a user mode signal).
  2137. Arguments:
  2138. None.
  2139. Return Value:
  2140. None. The function returns when another thread has woken this thread.
  2141. --*/
  2142. VOID
  2143. KeUnlinkSchedulerEntry (
  2144. PSCHEDULER_ENTRY Entry
  2145. );
  2146. /*++
  2147. Routine Description:
  2148. This routine unlinks a scheduler entry from its parent group.
  2149. Arguments:
  2150. Entry - Supplies a pointer to the entry to be unlinked.
  2151. Return Value:
  2152. None.
  2153. --*/
  2154. VOID
  2155. KeIdleLoop (
  2156. VOID
  2157. );
  2158. /*++
  2159. Routine Description:
  2160. This routine executes the idle loop. It does not return. It can be
  2161. executed only from the idle thread.
  2162. Arguments:
  2163. None.
  2164. Return Value:
  2165. None.
  2166. --*/
  2167. CYCLE_ACCOUNT
  2168. KeBeginCycleAccounting (
  2169. CYCLE_ACCOUNT CycleAccount
  2170. );
  2171. /*++
  2172. Routine Description:
  2173. This routine begins a new period of cycle accounting for the current
  2174. processor.
  2175. Arguments:
  2176. CycleAccount - Supplies the type of time to attribute these cycles to.
  2177. Return Value:
  2178. Returns the previous type that cycles were being attributed to.
  2179. --*/
  2180. VOID
  2181. KeRegisterCrashDumpFile (
  2182. HANDLE Handle,
  2183. BOOL Register
  2184. );
  2185. /*++
  2186. Routine Description:
  2187. This routine registers a file for use as a crash dump file.
  2188. Arguments:
  2189. Handle - Supplies a handle to the page file to register.
  2190. Register - Supplies a boolean indicating if the page file is registering
  2191. (TRUE) or de-registering (FALSE).
  2192. Return Value:
  2193. None.
  2194. --*/
  2195. //
  2196. // Video printing routines
  2197. //
  2198. VOID
  2199. KeVideoPrintString (
  2200. ULONG XCoordinate,
  2201. ULONG YCoordinate,
  2202. PSTR String
  2203. );
  2204. /*++
  2205. Routine Description:
  2206. This routine prints a null-terminated string to the screen at the
  2207. specified location.
  2208. Arguments:
  2209. Context - Supplies a pointer to the initialized base video context.
  2210. XCoordinate - Supplies the X coordinate of the location on the screen
  2211. to write to.
  2212. YCoordinate - Supplies the Y cooordinate of the location on the screen
  2213. to write to.
  2214. String - Supplies the string to print.
  2215. Return Value:
  2216. None.
  2217. --*/
  2218. VOID
  2219. KeVideoPrintHexInteger (
  2220. ULONG XCoordinate,
  2221. ULONG YCoordinate,
  2222. ULONG Number
  2223. );
  2224. /*++
  2225. Routine Description:
  2226. This routine prints an integer to the screen in the specified location.
  2227. Arguments:
  2228. XCoordinate - Supplies the X coordinate of the location on the screen
  2229. to write to.
  2230. YCoordinate - Supplies the Y cooordinate of the location on the screen
  2231. to write to.
  2232. Number - Supplies the signed integer to print.
  2233. Return Value:
  2234. None.
  2235. --*/
  2236. VOID
  2237. KeVideoPrintInteger (
  2238. ULONG XCoordinate,
  2239. ULONG YCoordinate,
  2240. LONG Number
  2241. );
  2242. /*++
  2243. Routine Description:
  2244. This routine prints an integer to the screen in the specified location.
  2245. Arguments:
  2246. Context - Supplies a pointer to the initialized base video context.
  2247. XCoordinate - Supplies the X coordinate of the location on the screen
  2248. to write to.
  2249. YCoordinate - Supplies the Y cooordinate of the location on the screen
  2250. to write to.
  2251. Number - Supplies the signed integer to print.
  2252. Return Value:
  2253. None.
  2254. --*/
  2255. KSTATUS
  2256. KeVideoGetDimensions (
  2257. PULONG Columns,
  2258. PULONG Rows
  2259. );
  2260. /*++
  2261. Routine Description:
  2262. This routine returns the text dimensions of the kernel's video frame buffer.
  2263. Arguments:
  2264. Columns - Supplies an optional pointer where the number of text columns
  2265. will be returned.
  2266. Rows - Supplies an optional pointer where the number of text rows will be
  2267. returned.
  2268. Return Value:
  2269. STATUS_SUCCESS on success.
  2270. STATUS_NOT_INITIALIZED if there is no frame buffer.
  2271. --*/
  2272. INTN
  2273. KeSystemCallHandler (
  2274. ULONG SystemCallNumber,
  2275. PVOID SystemCallParameter,
  2276. PTRAP_FRAME TrapFrame
  2277. );
  2278. /*++
  2279. Routine Description:
  2280. This routine responds to requests from user mode entered via a system call.
  2281. It may also be called by the restore system call in order to restart a
  2282. system call. This should not be seen as a general way to invoke system call
  2283. behavior from inside the kernel.
  2284. Arguments:
  2285. SystemCallNumber - Supplies the system call number.
  2286. SystemCallParameter - Supplies a pointer to the parameters supplied with
  2287. the system call.
  2288. TrapFrame - Supplies a pointer to the trap frame generated by this jump
  2289. from user mode to kernel mode.
  2290. Return Value:
  2291. STATUS_SUCCESS or positive integer on success.
  2292. Error status code on failure.
  2293. --*/