ReactOS 0.4.15-dev-7931-gfd331f1
kiinit.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for kiinit.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define __ARMV6__   KeIsArmV6
 

Functions

VOID NTAPI KdPortPutByteEx (PCPPORT PortInformation, UCHAR ByteToSend)
 
VOID NTAPI KiInitMachineDependent (VOID)
 
VOID NTAPI KiInitializeKernel (IN PKPROCESS InitProcess, IN PKTHREAD InitThread, IN PVOID IdleStack, IN PKPRCB Prcb, IN CCHAR Number, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI KiInitializePcr (IN ULONG ProcessorNumber, IN PKIPCR Pcr, IN PKTHREAD IdleThread, IN PVOID PanicStack, IN PVOID InterruptStack)
 
VOID KiInitializeMachineType (VOID)
 
DECLSPEC_NORETURN VOID KiInitializeSystem (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
ULONG DbgPrintEarly (const char *fmt,...)
 

Variables

KINTERRUPT KxUnexpectedInterrupt
 
BOOLEAN KeIsArmV6
 
ULONG KeNumberProcessIds
 
ULONG KeNumberTbEntries
 
ULONG ProcessCount
 
PVOID KiArmVectorTable
 

Macro Definition Documentation

◆ __ARMV6__

#define __ARMV6__   KeIsArmV6

Definition at line 30 of file kiinit.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file kiinit.c.

Function Documentation

◆ DbgPrintEarly()

ULONG DbgPrintEarly ( const char fmt,
  ... 
)

Definition at line 431 of file kiinit.c.

432{
434 unsigned int i;
435 char Buffer[1024];
437
438 va_start(args, fmt);
439 i = vsprintf(Buffer, fmt, args);
440 va_end(args);
441
442 /* Output the message */
443 while (*String != 0)
444 {
445 if (*String == '\n')
446 {
447 KdPortPutByteEx(NULL, '\r');
448 }
450 String++;
451 }
452
453 return STATUS_SUCCESS;
454}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
VOID NTAPI KdPortPutByteEx(PCPPORT PortInformation, UCHAR ByteToSend)
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define args
Definition: format.c:66
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: match.c:390
Definition: dsound.c:943
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

◆ KdPortPutByteEx()

VOID NTAPI KdPortPutByteEx ( PCPPORT  PortInformation,
UCHAR  ByteToSend 
)

Referenced by DbgPrintEarly().

◆ KiInitializeKernel()

VOID NTAPI KiInitializeKernel ( IN PKPROCESS  InitProcess,
IN PKTHREAD  InitThread,
IN PVOID  IdleStack,
IN PKPRCB  Prcb,
IN CCHAR  Number,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

FIXME: just a wild guess

Definition at line 44 of file kiinit.c.

50{
51 PKIPCR Pcr = (PKIPCR)KeGetPcr();
52 ULONG PageDirectory[2];
53 ULONG i;
54
55 /* Set the default NX policy (opt-in) */
56 SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
57
58 /* Initialize spinlocks and DPC data */
60
61 /* Set stack pointers */
62 //Pcr->InitialStack = IdleStack;
63 Pcr->Prcb.SpBase = IdleStack; // ???
64
65 /* Check if this is the Boot CPU */
66 if (!Number)
67 {
68 /* Setup the unexpected interrupt */
70 for (i = 0; i < 4; i++)
71 {
72 /* Copy the template code */
74 }
75
76 /* Set DMA coherency */
78
79 /* Sweep D-Cache */
81
82 /* Set boot-level flags */
84 KeFeatureBits = 0;
88#if 0
89 /* Set the current MP Master KPRCB to the Boot PRCB */
90 Prcb->MultiThreadSetMaster = Prcb;
91#endif
92 /* Lower to APC_LEVEL */
94
95 /* Initialize portable parts of the OS */
97
98 /* Initialize the Idle Process and the Process Listhead */
100 PageDirectory[0] = 0;
101 PageDirectory[1] = 0;
102 KeInitializeProcess(InitProcess,
103 0,
105 PageDirectory,
106 FALSE);
107 InitProcess->QuantumReset = MAXCHAR;
108 }
109 else
110 {
111 /* FIXME-V6: See if we want to support MP */
112 DPRINT1("ARM MPCore not supported\n");
113 }
114
115 /* Setup the Idle Thread */
116 KeInitializeThread(InitProcess,
117 InitThread,
118 NULL,
119 NULL,
120 NULL,
121 NULL,
122 NULL,
123 IdleStack);
124 InitThread->NextProcessor = Number;
125 InitThread->Priority = HIGH_PRIORITY;
126 InitThread->State = Running;
127 InitThread->Affinity = 1 << Number;
128 InitThread->WaitIrql = DISPATCH_LEVEL;
129 InitProcess->ActiveProcessors = 1 << Number;
130
131 /* HACK for MmUpdatePageDir */
132 ((PETHREAD)InitThread)->ThreadsProcess = (PEPROCESS)InitProcess;
133
134 /* Set up the thread-related fields in the PRCB */
135 Prcb->CurrentThread = InitThread;
136 Prcb->NextThread = NULL;
137 Prcb->IdleThread = InitThread;
138
139 /* Initialize the Kernel Executive */
140 ExpInitializeExecutive(Number, LoaderBlock);
141
142 /* Only do this on the boot CPU */
143 if (!Number)
144 {
145 /* Calculate the time reciprocal */
149
150 /* Update DPC Values in case they got updated by the executive */
151 Prcb->MaximumDpcQueueDepth = KiMaximumDpcQueueDepth;
152 Prcb->MinimumDpcRate = KiMinimumDpcRate;
153 Prcb->AdjustDpcThreshold = KiAdjustDpcThreshold;
154 }
155
156 /* Raise to Dispatch */
158
159 /* Set the Idle Priority to 0. This will jump into Phase 1 */
160 KeSetPriorityThread(InitThread, 0);
161
162 /* If there's no thread scheduled, put this CPU in the Idle summary */
163 KiAcquirePrcbLock(Prcb);
164 if (!Prcb->NextThread) KiIdleSummary |= 1 << Number;
165 KiReleasePrcbLock(Prcb);
166
167 /* Raise back to HIGH_LEVEL and clear the PRCB for the loader block */
169 LoaderBlock->Prcb = 0;
170}
KINTERRUPT KxUnexpectedInterrupt
Definition: kiinit.c:24
#define DPRINT1
Definition: precomp.h:8
#define MAXULONG_PTR
Definition: basetsd.h:103
#define FALSE
Definition: types.h:117
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
VOID HalSweepDcache(VOID)
Definition: processor.c:107
#define HIGH_PRIORITY
FORCEINLINE VOID KiReleasePrcbLock(IN PKPRCB Prcb)
Definition: ke_x.h:230
FORCEINLINE VOID KiAcquirePrcbLock(IN PKPRCB Prcb)
Definition: ke_x.h:220
struct _KIPCR * PKIPCR
#define KeGetPcr()
Definition: ketypes.h:81
#define PROCESSOR_ARCHITECTURE_ARM
Definition: ketypes.h:110
@ Running
Definition: ketypes.h:390
struct _EPROCESS * PEPROCESS
Definition: nt_native.h:30
struct _ETHREAD * PETHREAD
Definition: nt_native.h:29
VOID NTAPI ExpInitializeExecutive(IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:923
LARGE_INTEGER KiTimeIncrementReciprocal
Definition: timerobj.c:18
ULONG KiAdjustDpcThreshold
Definition: dpc.c:21
ULONG KiMaximumDpcQueueDepth
Definition: dpc.c:19
VOID __cdecl KiInterruptTemplate(VOID)
KAFFINITY KiIdleSummary
Definition: thrdschd.c:25
VOID NTAPI KeInitializeThread(IN PKPROCESS Process, IN OUT PKTHREAD Thread, IN PKSYSTEM_ROUTINE SystemRoutine, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext, IN PCONTEXT Context, IN PVOID Teb, IN PVOID KernelStack)
Definition: thrdobj.c:891
ULONG KeFeatureBits
Definition: krnlinit.c:22
UCHAR KiTimeIncrementShiftCount
Definition: timerobj.c:19
USHORT KeProcessorLevel
Definition: krnlinit.c:20
ULONG KiMinimumDpcRate
Definition: dpc.c:20
VOID NTAPI KiInitSystem(VOID)
Definition: krnlinit.c:71
LARGE_INTEGER NTAPI KiComputeReciprocal(IN LONG Divisor, OUT PUCHAR Shift)
Definition: krnlinit.c:123
VOID NTAPI KeInitializeProcess(struct _KPROCESS *Process, KPRIORITY Priority, KAFFINITY Affinity, PULONG_PTR DirectoryTableBase, IN BOOLEAN Enable)
USHORT KeProcessorRevision
Definition: krnlinit.c:21
VOID NTAPI KiInitSpinLocks(IN PKPRCB Prcb, IN CCHAR Number)
Definition: krnlinit.c:187
LIST_ENTRY KiProcessListHead
Definition: procobj.c:18
USHORT KeProcessorArchitecture
Definition: krnlinit.c:19
ULONG KiDmaIoCoherency
Definition: cpu.c:29
VOID KiUnexpectedInterrupt(VOID)
Definition: interrupt.c:51
ULONG KeMaximumIncrement
Definition: clock.c:20
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:207
unsigned short USHORT
Definition: pedump.c:61
#define SharedUserData
ULONG Cp15_Cr0_CpuId
Definition: ketypes.h:409
PKINTERRUPT_ROUTINE DispatchAddress
Definition: ketypes.h:947
ULONG DispatchCode[DISPATCH_LENGTH]
Definition: ketypes.h:968
KPRCB Prcb
Definition: ketypes.h:961
PVOID SpBase
Definition: ketypes.h:838
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:648
KARM_ARCH_STATE ArchState
Definition: ketypes.h:652
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1319
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
#define MAXCHAR
Definition: umtypes.h:112
#define NX_SUPPORT_POLICY_OPTIN
Definition: ketypes.h:1262

Referenced by KiInitializeSystem(), and KiSystemStartupBootStack().

◆ KiInitializeMachineType()

VOID KiInitializeMachineType ( VOID  )

Definition at line 309 of file kiinit.c.

310{
311 /* Detect ARM version */
313
314 /* Set the number of TLB entries and ASIDs */
316 if (__ARMV6__)
317 {
318 /* 256 ASIDs on v6/v7 */
319 KeNumberProcessIds = 256;
320 }
321 else
322 {
323 /* The TLB is VIVT on v4/v5 */
325 }
326}
FORCEINLINE ARM_ID_CODE_REGISTER KeArmIdCodeRegisterGet(VOID)
Definition: intrin_i.h:31
BOOLEAN KeIsArmV6
Definition: kiinit.c:25
ULONG KeNumberTbEntries
Definition: kiinit.c:27
ULONG KeNumberProcessIds
Definition: kiinit.c:26
#define __ARMV6__
Definition: kiinit.c:30

Referenced by KiInitializeSystem(), and KiSystemStartup().

◆ KiInitializePcr()

VOID NTAPI KiInitializePcr ( IN ULONG  ProcessorNumber,
IN PKIPCR  Pcr,
IN PKTHREAD  IdleThread,
IN PVOID  PanicStack,
IN PVOID  InterruptStack 
)

Definition at line 178 of file kiinit.c.

183{
184 ULONG i;
185
186 /* Set the Current Thread */
187 Pcr->Prcb.CurrentThread = IdleThread;
188
189 /* Set pointers to ourselves */
190 Pcr->Self = (PKPCR)Pcr;
191 Pcr->CurrentPrcb = &Pcr->Prcb;
192
193 /* Set the PCR Version */
194 Pcr->MajorVersion = PCR_MAJOR_VERSION;
195 Pcr->MinorVersion = PCR_MINOR_VERSION;
196
197 /* Set the PCRB Version */
198 Pcr->Prcb.MajorVersion = PRCB_MAJOR_VERSION;
199 Pcr->Prcb.MinorVersion = PRCB_MINOR_VERSION;
200
201 /* Set the Build Type */
202 Pcr->Prcb.BuildType = 0;
203#ifndef CONFIG_SMP
204 Pcr->Prcb.BuildType |= PRCB_BUILD_UNIPROCESSOR;
205#endif
206#if DBG
207 Pcr->Prcb.BuildType |= PRCB_BUILD_DEBUG;
208#endif
209
210 /* Set the Processor Number and current Processor Mask */
211 Pcr->Prcb.Number = (UCHAR)ProcessorNumber;
212 Pcr->Prcb.SetMember = 1 << ProcessorNumber;
213
214 /* Set the PRCB for this Processor */
215 KiProcessorBlock[ProcessorNumber] = Pcr->CurrentPrcb;
216
217 /* Start us out at PASSIVE_LEVEL */
218 Pcr->CurrentIrql = PASSIVE_LEVEL;
219
220 /* Set the stacks */
221 Pcr->Prcb.PanicStackBase = (ULONG)PanicStack;
222 Pcr->Prcb.IsrStack = InterruptStack;
223#if 0
224 /* Setup the processor set */
225 Pcr->Prcb.MultiThreadProcessorSet = Pcr->Prcb.SetMember;
226#endif
227
228 /* Copy cache information from the loader block */
229 Pcr->Prcb.Cache[FirstLevelDcache].Type = CacheData;
230 Pcr->Prcb.Cache[FirstLevelDcache].Level = 1;
231 Pcr->Prcb.Cache[FirstLevelDcache].Associativity = 0; // FIXME
232 Pcr->Prcb.Cache[FirstLevelDcache].LineSize = KeLoaderBlock->u.Arm.FirstLevelDcacheFillSize;
233 Pcr->Prcb.Cache[FirstLevelDcache].Size = KeLoaderBlock->u.Arm.FirstLevelDcacheSize;
234
235 Pcr->Prcb.Cache[SecondLevelDcache].Type = CacheData;
236 Pcr->Prcb.Cache[SecondLevelDcache].Level = 2;
237 Pcr->Prcb.Cache[SecondLevelDcache].Associativity = 0; // FIXME
238 Pcr->Prcb.Cache[SecondLevelDcache].LineSize = KeLoaderBlock->u.Arm.SecondLevelDcacheFillSize;
239 Pcr->Prcb.Cache[SecondLevelDcache].Size = KeLoaderBlock->u.Arm.SecondLevelDcacheSize;
240
241 Pcr->Prcb.Cache[FirstLevelIcache].Type = CacheInstruction;
242 Pcr->Prcb.Cache[FirstLevelIcache].Level = 1;
243 Pcr->Prcb.Cache[FirstLevelIcache].Associativity = 0; // FIXME
244 Pcr->Prcb.Cache[FirstLevelIcache].LineSize = KeLoaderBlock->u.Arm.FirstLevelIcacheFillSize;
245 Pcr->Prcb.Cache[FirstLevelIcache].Size = KeLoaderBlock->u.Arm.FirstLevelIcacheSize;
246
247 Pcr->Prcb.Cache[SecondLevelIcache].Type = CacheInstruction;
248 Pcr->Prcb.Cache[SecondLevelIcache].Level = 2;
249 Pcr->Prcb.Cache[SecondLevelIcache].Associativity = 0; // FIXME
250 Pcr->Prcb.Cache[SecondLevelIcache].LineSize = KeLoaderBlock->u.Arm.SecondLevelIcacheFillSize;
251 Pcr->Prcb.Cache[SecondLevelIcache].Size = KeLoaderBlock->u.Arm.SecondLevelIcacheSize;
252
253 /* Set global d-cache fill and alignment values */
254 if (Pcr->Prcb.Cache[SecondLevelDcache].Size == 0)
255 {
256 /* Use the first level */
257 Pcr->Prcb.Cache[GlobalDcache] = Pcr->Prcb.Cache[FirstLevelDcache];
258 }
259 else
260 {
261 /* Use the second level */
262 Pcr->Prcb.Cache[GlobalDcache] = Pcr->Prcb.Cache[SecondLevelDcache];
263 }
264
265 /* Set the alignment */
266 //Pcr->DcacheAlignment = Pcr->DcacheFillSize - 1;
267
268 /* Set global i-cache fill and alignment values */
269 if (Pcr->Prcb.Cache[SecondLevelIcache].Size == 0)
270 {
271 /* Use the first level */
272 Pcr->Prcb.Cache[GlobalIcache] = Pcr->Prcb.Cache[FirstLevelIcache];
273 }
274 else
275 {
276 /* Use the second level */
277 Pcr->Prcb.Cache[GlobalIcache] = Pcr->Prcb.Cache[SecondLevelIcache];
278 }
279
280 /* Set the alignment */
281 //Pcr->IcacheAlignment = Pcr->IcacheFillSize - 1;
282
283 /* Set processor information */
284 //Pcr->ProcessorId = KeArmIdCodeRegisterGet().AsUlong;
285
286 /* Set all interrupt routines to unexpected interrupts as well */
287 for (i = 0; i < MAXIMUM_VECTOR; i++)
288 {
289 /* Point to the same template */
291 }
292
293 /* Set default stall factor */
294 Pcr->StallScaleFactor = 50;
295
296 /* Setup software interrupts */
298 Pcr->Idt[APC_LEVEL] = KiApcInterrupt;
300#if 0
301 Pcr->ReservedVectors = (1 << PASSIVE_LEVEL) |
302 (1 << APC_LEVEL) |
303 (1 << DISPATCH_LEVEL) |
304 (1 << IPI_LEVEL);
305#endif
306}
VOID NTAPI KiDispatchInterrupt(VOID)
Definition: thrdini.c:305
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define IPI_LEVEL
Definition: env_spec_w32.h:701
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
#define PRCB_MINOR_VERSION
Definition: ketypes.h:306
#define PRCB_MAJOR_VERSION
Definition: ketypes.h:307
#define PRCB_BUILD_UNIPROCESSOR
Definition: ketypes.h:309
#define PRCB_BUILD_DEBUG
Definition: ketypes.h:308
@ GlobalDcache
Definition: ketypes.h:742
@ SecondLevelIcache
Definition: ketypes.h:741
@ FirstLevelIcache
Definition: ketypes.h:740
@ SecondLevelDcache
Definition: ketypes.h:739
@ FirstLevelDcache
Definition: ketypes.h:738
@ GlobalIcache
Definition: ketypes.h:743
VOID KiApcInterrupt(VOID)
Definition: trapc.c:229
#define MAXIMUM_VECTOR
Definition: ke.h:26
VOID KiPassiveRelease(VOID)
PKPRCB KiProcessorBlock[]
Definition: krnlinit.c:32
#define PCR_MINOR_VERSION
Definition: ke.h:290
struct _KPCR * PKPCR
#define PCR_MAJOR_VERSION
Definition: ke.h:291
ARM_LOADER_BLOCK Arm
Definition: arc.h:566
union _LOADER_PARAMETER_BLOCK::@3379 u
void * PVOID
Definition: typedefs.h:50
@ CacheInstruction
Definition: ketypes.h:45
@ CacheData
Definition: ketypes.h:46
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ KiInitializeSystem()

DECLSPEC_NORETURN VOID KiInitializeSystem ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 330 of file kiinit.c.

331{
332 ULONG Cpu;
333 PKTHREAD InitialThread;
334 PKPROCESS InitialProcess;
335 ARM_CONTROL_REGISTER ControlRegister;
336 PKIPCR Pcr = (PKIPCR)KeGetPcr();
338
339 /* Flush the TLB */
340 KeFlushTb();
341
342 /* Save the loader block and get the current CPU */
343 KeLoaderBlock = LoaderBlock;
344 Cpu = KeNumberProcessors;
345
346 /* Save the initial thread and process */
347 InitialThread = (PKTHREAD)LoaderBlock->Thread;
348 InitialProcess = (PKPROCESS)LoaderBlock->Process;
349
350 /* Clean the APC List Head */
351 InitializeListHead(&InitialThread->ApcState.ApcListHead[KernelMode]);
352
353 /* Initialize the machine type */
355
356 /* Skip initial setup if this isn't the Boot CPU */
357 if (Cpu) goto AppCpuInit;
358
359 /* Initialize the PCR */
361 KiInitializePcr(Cpu,
362 Pcr,
363 InitialThread,
364 (PVOID)LoaderBlock->u.Arm.PanicStack,
365 (PVOID)LoaderBlock->u.Arm.InterruptStack);
366
367 /* Now sweep caches */
370
371 /* Set us as the current process */
372 InitialThread->ApcState.Process = InitialProcess;
373
374AppCpuInit:
375 /* Setup CPU-related fields */
376 Pcr->Prcb.Number = Cpu;
377 Pcr->Prcb.SetMember = 1 << Cpu;
378
379 /* Initialize the Processor with HAL */
381
382 /* Set active processors */
385
386 /* Check if this is the boot CPU */
387 if (!Cpu)
388 {
389 /* Initialize debugging system */
391
392 /* Check for break-in */
394 }
395
396 /* Raise to HIGH_LEVEL */
398
399 /* Set the exception address to high */
400 ControlRegister = KeArmControlRegisterGet();
401 ControlRegister.HighVectors = TRUE;
402 KeArmControlRegisterSet(ControlRegister);
403
404 /* Setup the exception vector table */
405 RtlCopyMemory((PVOID)0xFFFF0000, &KiArmVectorTable, 14 * sizeof(PVOID));
406
407 /* Initialize the rest of the kernel now */
408 KiInitializeKernel((PKPROCESS)LoaderBlock->Process,
409 (PKTHREAD)LoaderBlock->Thread,
410 (PVOID)LoaderBlock->KernelStack,
411 &Pcr->Prcb,
412 Pcr->Prcb.Number,
414
415 /* Set the priority of this thread to 0 */
417 Thread->Priority = 0;
418
419 /* Force interrupts enabled and lower IRQL back to DISPATCH_LEVEL */
420 _enable();
422
423 /* Set the right wait IRQL */
424 Thread->WaitIrql = DISPATCH_LEVEL;
425
426 /* Jump into the idle loop */
427 KiIdleLoop();
428}
static VOID KiInitializePcr(_Out_ PKIPCR Pcr, _In_ ULONG ProcessorNumber, _In_ PKGDTENTRY64 GdtBase, _In_ PKIDTENTRY64 IdtBase, _In_ PKTSS64 TssBase, _In_ PKTHREAD IdleThread, _In_ PVOID DpcStack)
Definition: kiinit.c:92
FORCEINLINE VOID KeArmControlRegisterSet(IN ARM_CONTROL_REGISTER ControlRegister)
Definition: intrin_i.h:135
FORCEINLINE ARM_CONTROL_REGISTER KeArmControlRegisterGet(VOID)
Definition: intrin_i.h:18
VOID NTAPI KiInitializeKernel(IN PKPROCESS InitProcess, IN PKTHREAD InitThread, IN PVOID IdleStack, IN PKPRCB Prcb, IN CCHAR Number, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kiinit.c:44
VOID KiInitializeMachineType(VOID)
Definition: kiinit.c:309
PVOID KiArmVectorTable
#define TRUE
Definition: types.h:120
#define PAGE_SIZE
Definition: env_spec_w32.h:49
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID FASTCALL KfLowerIrql(IN KIRQL NewIrql)
Definition: pic.c:232
VOID HalSweepIcache(VOID)
Definition: processor.c:135
VOID NTAPI HalInitializeProcessor(IN ULONG ProcessorNumber, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: processor.c:48
#define KeGetCurrentThread
Definition: hal.h:55
void __cdecl _enable(void)
Definition: intrin_arm.h:373
BOOLEAN NTAPI KdInitSystem(_In_ ULONG BootPhase, _In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kdinit.c:142
BOOLEAN NTAPI KdPollBreakIn(VOID)
Definition: kdlock.c:75
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
#define KernelMode
Definition: asm.h:34
#define DBG_STATUS_CONTROL_C
Definition: kdtypes.h:39
struct _KTHREAD * PKTHREAD
Definition: nt_native.h:28
VOID KeFlushTb(VOID)
Definition: cpu.c:36
KAFFINITY KeActiveProcessors
Definition: krnlinit.c:23
DECLSPEC_NORETURN VOID KiIdleLoop(VOID)
Definition: stubs.c:99
UINT64 SetMember
Definition: ketypes.h:647
USHORT Number
Definition: ketypes.h:628
KAPC_STATE ApcState
Definition: ketypes.h:1778
PKPROCESS Process
Definition: ketypes.h:1908
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)

◆ KiInitMachineDependent()

VOID NTAPI KiInitMachineDependent ( VOID  )

Definition at line 36 of file kiinit.c.

37{
38 /* There is nothing to do on ARM */
39 return;
40}

Variable Documentation

◆ KeIsArmV6

BOOLEAN KeIsArmV6

Definition at line 25 of file kiinit.c.

Referenced by KiInitializeMachineType().

◆ KeNumberProcessIds

ULONG KeNumberProcessIds

Definition at line 26 of file kiinit.c.

Referenced by KiInitializeMachineType().

◆ KeNumberTbEntries

ULONG KeNumberTbEntries

Definition at line 27 of file kiinit.c.

Referenced by KiInitializeMachineType().

◆ KiArmVectorTable

PVOID KiArmVectorTable
extern

Referenced by KiInitializeSystem().

◆ KxUnexpectedInterrupt

KINTERRUPT KxUnexpectedInterrupt

Definition at line 24 of file kiinit.c.

Referenced by KiInitializeKernel(), and KiInitializePcr().

◆ ProcessCount

ULONG ProcessCount

Definition at line 28 of file kiinit.c.