00093 :
00094
00095 This function gains
control after
the system has been bootstrapped and
00096 before
the system has been initialized. Its function
is to initialize
00097
the kernel data structures, initialize
the idle thread and process objects,
00098 initialize
the processor
control block, call
the executive initialization
00099 routine, and then
return to
the system startup routine. This routine
is
00100 also called to initialize
the processor specific structures when a
new
00101 processor
is brought on line.
00102
00103 Arguments:
00104
00105 Process - Supplies a pointer to a
control object of
type process
for
00106
the specified processor.
00107
00108 Thread - Supplies a pointer to a dispatcher object of
type thread
for
00109
the specified processor.
00110
00111 IdleStack - Supplies a pointer
the base of
the real kernel stack
for
00112 idle thread on
the specified processor.
00113
00114 Prcb - Supplies a pointer to a processor
control block
for the specified
00115 processor.
00116
00117 Number - Supplies
the number of
the processor that
is being
00118 initialized.
00119
00120 LoaderBlock - Supplies a pointer to
the loader parameter block.
00121
00122 Return Value:
00123
00124 None.
00125
00126 --*/
00127
00128 {
00129
00130 LONG
Index;
00131 KIRQL OldIrql;
00132
PRESTART_BLOCK RestartBlock;
00133 KPCR *Pcr;
00134
00135
00136
00137
00138
00139
00140 Pcr = (PKPCR)PCRsprg1;
00141
00142
#if !defined(NT_UP)
00143
00144
if (Number != 0) {
00145
KiPhase0SyncIoMap();
00146 }
00147
00148
#endif
00149
00150
00151
00152
00153
00154 Pcr->ProcessorRevision = KeGetPvr() & 0xFFFF;
00155 Pcr->ProcessorVersion = (KeGetPvr() >> 16);
00156
00157
00158
00159
00160
00161
00162
KeProcessorArchitecture = PROCESSOR_ARCHITECTURE_PPC;
00163
KeFeatureBits = 0;
00164
if (
KeProcessorLevel == 0 ||
00165
KeProcessorLevel > (
USHORT)Pcr->ProcessorVersion
00166 ) {
00167
KeProcessorLevel = (
USHORT)Pcr->ProcessorVersion;
00168 }
00169
if (
KeProcessorRevision == 0 ||
00170
KeProcessorRevision > (
USHORT)Pcr->ProcessorRevision
00171 ) {
00172
KeProcessorRevision = (
USHORT)Pcr->ProcessorRevision;
00173 }
00174
00175
00176
00177
00178
00179
HalInitializeProcessor(Number);
00180 HalSweepIcache();
00181
00182
00183
00184
00185
00186
KeLoaderBlock = LoaderBlock;
00187
00188
00189
00190
00191
00192 Prcb->MinorVersion =
PRCB_MINOR_VERSION;
00193 Prcb->MajorVersion =
PRCB_MAJOR_VERSION;
00194 Prcb->BuildType = 0;
00195
00196
#if DBG
00197
00198 Prcb->BuildType |= PRCB_BUILD_DEBUG;
00199
00200
#endif
00201
00202
#if defined(NT_UP)
00203
00204 Prcb->BuildType |= PRCB_BUILD_UNIPROCESSOR;
00205
00206
#endif
00207
00208 Prcb->CurrentThread = Thread;
00209 Prcb->NextThread = (
PKTHREAD)
NULL;
00210 Prcb->IdleThread = Thread;
00211 Prcb->SetMember = 1 << Number;
00212 Prcb->PcrPage = LoaderBlock->u.Ppc.PcrPage;
00213 Prcb->ProcessorState.SpecialRegisters.Sprg0 =
00214 LoaderBlock->u.Ppc.PcrPage <<
PAGE_SHIFT;
00215 Prcb->ProcessorState.SpecialRegisters.Sprg1 = (ULONG)Pcr;
00216
00217
#if !defined(NT_UP)
00218
00219 Prcb->TargetSet = 0;
00220 Prcb->WorkerRoutine =
NULL;
00221 Prcb->RequestSummary = 0;
00222 Prcb->IpiFrozen = 0;
00223
00224
#if NT_INST
00225
00226 Prcb->IpiCounts = &KiIpiCounts[Number];
00227
00228
#endif
00229
00230
#endif
00231
00232 Prcb->MaximumDpcQueueDepth =
KiMaximumDpcQueueDepth;
00233 Prcb->MinimumDpcRate =
KiMinimumDpcRate;
00234 Prcb->AdjustDpcThreshold =
KiAdjustDpcThreshold;
00235
00236
00237
00238
00239
00240 InitializeListHead(&Prcb->DpcListHead);
00241
KeInitializeSpinLock(&Prcb->DpcLock);
00242
00243
00244
00245
00246
00247
KiProcessorBlock[Number] = Prcb;
00248
00249
00250
00251
00252
00253 Pcr->InitialStack = IdleStack;
00254 Pcr->StackLimit = (PVOID)((ULONG)IdleStack - KERNEL_STACK_SIZE);
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
if (Number == 0) {
00267
00268
00269
00270
00271
00272 KxUnexpectedInterrupt.DispatchAddress =
KiUnexpectedInterrupt;
00273
00274
00275
00276
00277
00278
00279 KxUnexpectedInterrupt.DispatchCode[0] =
00280 *(PULONG)(KxUnexpectedInterrupt.DispatchAddress);
00281 KxUnexpectedInterrupt.DispatchCode[1] =
00282 *(((PULONG)(KxUnexpectedInterrupt.DispatchAddress))+1);
00283
00284
00285
00286
00287
00288
KeInitializeSpinLock(&KiContextSwapLock);
00289
00290
00291
00292
00293
00294
00295
00296
KiDmaIoCoherency =
DMA_READ_DCACHE_INVALIDATE |
DMA_WRITE_DCACHE_SNOOP;
00297 }
00298
00299
for (
Index = 0;
Index < MAXIMUM_VECTOR;
Index += 1) {
00300 Pcr->InterruptRoutine[
Index] =
00301 (PKINTERRUPT_ROUTINE)(&KxUnexpectedInterrupt.DispatchCode);
00302 }
00303
00304
00305
00306
00307
00308 Pcr->ProfileCount = 0;
00309 Pcr->ProfileInterval = 0x200000;
00310
00311
00312
00313
00314
00315 Pcr->InterruptRoutine[0] =
KiUnexpectedInterrupt;
00316
00317
00318
00319
00320
00321
00322 Pcr->InterruptRoutine[
APC_LEVEL] =
KiUnexpectedInterrupt;
00323 Pcr->InterruptRoutine[
DISPATCH_LEVEL] =
KiUnexpectedInterrupt;
00324
00325 Pcr->ReservedVectors = (1 <<
PASSIVE_LEVEL) |
00326 (1 <<
APC_LEVEL) |
00327 (1 <<
DISPATCH_LEVEL);
00328
00329
00330
00331
00332
00333
00334 Pcr->CurrentIrql =
APC_LEVEL;
00335 Pcr->SetMember = 1 << Number;
00336 Pcr->NotMember = ~Pcr->SetMember;
00337 Pcr->Number = Number;
00338
00339
00340
00341
00342
00343
00344 Pcr->StallScaleFactor = 50;
00345
00346
00347
00348
00349
00350 Thread->ApcState.Process = Process;
00351
00352
00353
00354
00355
00356
SetMember(Number, KeActiveProcessors);
00357
00358
00359
00360
00361
00362
00363
if ((Number + 1) >
KeNumberProcessors) {
00364
KeNumberProcessors = Number + 1;
00365 }
00366
00367
00368
00369
00370
00371
00372
if (Number == 0) {
00373
00374
00375
00376
00377
00378
if (
KdInitSystem(LoaderBlock, FALSE) ==
FALSE) {
00379
KeBugCheck(PHASE0_INITIALIZATION_FAILED);
00380 }
00381
00382
00383
00384
00385
00386 HalSweepDcache();
00387 HalSweepIcache();
00388
00389
00390
00391
00392
00393
00394
KeFlushCurrentTb();
00395
00396
#if DBG
00397
if ((PCR->IcacheMode) || (PCR->DcacheMode))
00398 {
00399
DbgPrint(
"****** Dynamic Cache Mode Kernel Invocation\n");
00400
if (PCR->IcacheMode)
00401
DbgPrint(
"****** Icache is OFF\n");
00402
if (PCR->DcacheMode)
00403
DbgPrint(
"****** Dcache is OFF\n");
00404 }
00405
#endif
00406
00407
00408
00409
00410
00411 Prcb->RestartBlock = SYSTEM_BLOCK->RestartBlock;
00412
00413
00414
00415
00416
00417
for (
Index = 1;
Index <
MAXIMUM_PROCESSORS;
Index += 1) {
00418
KiProcessorBlock[
Index] = (PKPRCB)
NULL;
00419 }
00420
00421
00422
00423
00424
00425
KiInitSystem();
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
KeInitializeProcess(Process,
00436 (KPRIORITY)0,
00437 (KAFFINITY)(0xffffffff),
00438 (PULONG)(PDE_BASE + ((PDE_BASE >> PDI_SHIFT - 2) & 0xffc)),
00439 FALSE);
00440
00441 Process->ThreadQuantum = MAXCHAR;
00442
00443 }
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
KeInitializeThread(Thread, (PVOID)((ULONG)IdleStack - PAGE_SIZE),
00458 (PKSYSTEM_ROUTINE)KeBugCheck,
00459 (PKSTART_ROUTINE)NULL,
00460 (PVOID)NULL, (PCONTEXT)NULL, (PVOID)NULL, Process);
00461
00462 Thread->InitialStack = IdleStack;
00463 Thread->StackBase = IdleStack;
00464 Thread->StackLimit = (PVOID)((ULONG)IdleStack - KERNEL_STACK_SIZE);
00465 Thread->NextProcessor = Number;
00466 Thread->Priority = HIGH_PRIORITY;
00467 Thread->State =
Running;
00468 Thread->Affinity = (KAFFINITY)(1 << Number);
00469 Thread->WaitIrql =
DISPATCH_LEVEL;
00470
00471
00472
00473
00474
00475
00476
if (Number == 0) {
00477
SetMember(Number, Process->ActiveProcessors);
00478 }
00479
00480
00481
00482
00483
00484
try {
00485
ExpInitializeExecutive(Number, LoaderBlock);
00486
00487 } except (
KiInitExceptionFilter(GetExceptionInformation())) {
00488
KeBugCheck (PHASE0_EXCEPTION);
00489 }
00490
00491
00492
00493
00494
00495
00496
00497
00498
if (Number == 0) {
00499
KiTimeIncrementReciprocal =
KiComputeReciprocal((LONG)KeMaximumIncrement,
00500 &KiTimeIncrementShiftCount);
00501 Prcb->MaximumDpcQueueDepth =
KiMaximumDpcQueueDepth;
00502 Prcb->MinimumDpcRate =
KiMinimumDpcRate;
00503 Prcb->AdjustDpcThreshold =
KiAdjustDpcThreshold;
00504 }
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515 KeRaiseIrqlToDpcLevel(&OldIrql);
00516
KeSetPriorityThread(Thread, (KPRIORITY)0);
00517 Thread->Priority = LOW_REALTIME_PRIORITY;
00518
00519
00520
00521
00522
00523
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
#if !defined(NT_UP)
00534
00535 RestartBlock = Prcb->RestartBlock;
00536
if (RestartBlock !=
NULL) {
00537 RestartBlock->
BootStatus.
BootFinished = 1;
00538 }
00539
00540
00541
00542
00543
00544
00545
if (Number != 0) {
00546
SetMember(Number, KiIdleSummary);
00547 }
00548
00549
#endif
00550
00551
return;
00552 }