Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

allproc.c File Reference

#include "ki.h"

Go to the source code of this file.

Defines

#define ROUND_UP(x)   ((sizeof(x) + 63) & (~63))
#define BLOCK1_SIZE   (3 * KERNEL_STACK_SIZE)
#define BLOCK2_SIZE   (ROUND_UP(KPRCB) + ROUND_UP(ETHREAD) + 64)

Functions

VOID KiStartProcessor (IN PLOADER_PARAMETER_BLOCK Loaderblock)
VOID KeStartAllProcessors (VOID)

Variables

ULONG KiBarrierWait = 0
MEMORY_ALLOCATION_DESCRIPTOR KiFreePcrPagesDescriptor


Define Documentation

#define BLOCK1_SIZE   (3 * KERNEL_STACK_SIZE)
 

Definition at line 44 of file ppc/allproc.c.

#define BLOCK2_SIZE   (ROUND_UP(KPRCB) + ROUND_UP(ETHREAD) + 64)
 

Definition at line 45 of file ppc/allproc.c.

#define ROUND_UP  )     ((sizeof(x) + 63) & (~63))
 

Definition at line 43 of file ppc/allproc.c.


Function Documentation

VOID KeStartAllProcessors VOID   ) 
 

Definition at line 72 of file ppc/allproc.c.

References _MEMORY_ALLOCATION_DESCRIPTOR::BasePage, BLOCK1_SIZE, BLOCK2_SIZE, _BOOT_STATUS::BootFinished, _RESTART_BLOCK::BootStatus, ExAllocatePool, ExFreePool(), FALSE, HalStartNextProcessor(), KeLoaderBlock, KeRegisteredProcessors, _LOADER_PARAMETER_BLOCK::KernelStack, KiAdjustInterruptTime(), KiBarrierWait, KiFreePcrPagesDescriptor, KiStartProcessor(), KSEG0_BASE, _MEMORY_ALLOCATION_DESCRIPTOR::ListEntry, LoaderOsloaderHeap, MAXIMUM_PROCESSORS, _LOADER_PARAMETER_BLOCK::MemoryDescriptorListHead, _MEMORY_ALLOCATION_DESCRIPTOR::MemoryType, NonPagedPool, NULL, PAGE_SHIFT, PAGE_SIZE, _MEMORY_ALLOCATION_DESCRIPTOR::PageCount, PMEMORY_ALLOCATION_DESCRIPTOR, _LOADER_PARAMETER_BLOCK::Prcb, ROUND_UP, _LOADER_PARAMETER_BLOCK::Thread, and _LOADER_PARAMETER_BLOCK::u.

00078 : 00079 00080 This function is called during phase 1 initialization on the master boot 00081 processor to start all of the other registered processors. 00082 00083 Arguments: 00084 00085 None. 00086 00087 Return Value: 00088 00089 None. 00090 00091 --*/ 00092 00093 { 00094 00095 #if !defined(NT_UP) 00096 00097 ULONG MemoryBlock1; 00098 ULONG MemoryBlock2; 00099 ULONG Number; 00100 ULONG PcrAddress; 00101 ULONG PcrPage; 00102 PKPRCB Prcb; 00103 KPROCESSOR_STATE ProcessorState; 00104 volatile PRESTART_BLOCK RestartBlock; 00105 BOOLEAN Started; 00106 PHYSICAL_ADDRESS PcrPhysicalAddress; 00107 PMEMORY_ALLOCATION_DESCRIPTOR KiPcrPagesDescriptor = KeLoaderBlock->u.Ppc.PcrPagesDescriptor; 00108 00109 // 00110 // If the registered number of processors is greater than the maximum 00111 // number of processors supported, then only allow the maximum number 00112 // of supported processors. 00113 // 00114 00115 if (KeRegisteredProcessors > MAXIMUM_PROCESSORS) { 00116 KeRegisteredProcessors = MAXIMUM_PROCESSORS; 00117 } 00118 00119 // 00120 // Set barrier that will prevent any other processor from entering the 00121 // idle loop until all processors have been started. 00122 // 00123 00124 KiBarrierWait = 1; 00125 00126 // 00127 // Initialize the processor state that will be used to start each of 00128 // processors. Each processor starts in the system initialization code 00129 // with address of the loader parameter block as an argument. 00130 // 00131 00132 RtlZeroMemory(&ProcessorState, sizeof(KPROCESSOR_STATE)); 00133 ProcessorState.ContextFrame.Gpr3 = (ULONG)KeLoaderBlock; 00134 ProcessorState.ContextFrame.Iar = *(PULONG)KiStartProcessor; 00135 00136 Number = 0; 00137 00138 while ((Number+1) < KeRegisteredProcessors) { 00139 00140 // 00141 // Allocate a DPC stack, an idle thread kernel stack, a panic 00142 // stack, a PCR page, a processor block, and an executive thread 00143 // object. If the allocation fails or the allocation cannot be 00144 // made from nonpaged pool, then stop starting processors. 00145 // 00146 00147 if (Number >= KiPcrPagesDescriptor->PageCount) { 00148 break; 00149 } 00150 00151 MemoryBlock1 = (ULONG)ExAllocatePool(NonPagedPool, BLOCK1_SIZE); 00152 if ((PVOID)MemoryBlock1 == NULL) { 00153 break; 00154 } 00155 00156 MemoryBlock2 = (ULONG)ExAllocatePool(NonPagedPool, BLOCK2_SIZE); 00157 if ((PVOID)MemoryBlock2 == NULL) { 00158 ExFreePool((PVOID)MemoryBlock1); 00159 break; 00160 } 00161 00162 // 00163 // Zero both blocks of allocated memory. 00164 // 00165 00166 RtlZeroMemory((PVOID)MemoryBlock1, BLOCK1_SIZE); 00167 RtlZeroMemory((PVOID)MemoryBlock2, BLOCK2_SIZE); 00168 00169 // 00170 // Set address of interrupt stack in loader parameter block. 00171 // 00172 00173 KeLoaderBlock->u.Ppc.InterruptStack = MemoryBlock1 + (1 * KERNEL_STACK_SIZE); 00174 00175 // 00176 // Set address of idle thread kernel stack in loader parameter block. 00177 // 00178 00179 KeLoaderBlock->KernelStack = MemoryBlock1 + (2 * KERNEL_STACK_SIZE); 00180 00181 ProcessorState.ContextFrame.Gpr1 = (ULONG)KeLoaderBlock->KernelStack; 00182 00183 // 00184 // Set address of panic stack in loader parameter block. 00185 // 00186 00187 KeLoaderBlock->u.Ppc.PanicStack = MemoryBlock1 + (3 * KERNEL_STACK_SIZE); 00188 00189 // 00190 // Set the page frame of the PCR page in the loader parameter block. 00191 // 00192 00193 PcrPage = KiPcrPagesDescriptor->BasePage + Number; 00194 PcrAddress = KSEG0_BASE | (PcrPage << PAGE_SHIFT); 00195 RtlZeroMemory((PVOID)PcrAddress, PAGE_SIZE); 00196 ProcessorState.ContextFrame.Gpr4 = PcrAddress; 00197 KeLoaderBlock->u.Ppc.PcrPage = PcrPage; 00198 00199 // 00200 // Copy the physical address of the PCR2 page from the current 00201 // processor's PCR into the loader parameter block for the new 00202 // processor. 00203 // 00204 // Note that in the PCR this is an address rather than a page 00205 // number. 00206 // 00207 00208 KeLoaderBlock->u.Ppc.PcrPage2 = PCR->PcrPage2 >> PAGE_SHIFT; 00209 00210 // 00211 // Set the address of the processor block and executive thread in the 00212 // loader parameter block. 00213 // 00214 00215 KeLoaderBlock->Prcb = (MemoryBlock2 + 63) & ~63; 00216 KeLoaderBlock->Thread = KeLoaderBlock->Prcb + ROUND_UP(KPRCB); 00217 00218 // 00219 // Attempt to start the next processor. If attempt is successful, 00220 // then wait for the processor to get initialized. Otherwise, 00221 // deallocate the processor resources and terminate the loop. 00222 // 00223 00224 Started = HalStartNextProcessor(KeLoaderBlock, &ProcessorState); 00225 00226 if (Started == FALSE) { 00227 00228 ExFreePool((PVOID)MemoryBlock1); 00229 ExFreePool((PVOID)MemoryBlock2); 00230 break; 00231 00232 } else { 00233 00234 // 00235 // Wait until boot is finished on the target processor before 00236 // starting the next processor. Booting is considered to be 00237 // finished when a processor completes its initialization and 00238 // drops into the idle loop. 00239 // 00240 00241 Prcb = (PKPRCB)(KeLoaderBlock->Prcb); 00242 RestartBlock = Prcb->RestartBlock; 00243 while (RestartBlock->BootStatus.BootFinished == 0) { 00244 } 00245 } 00246 00247 Number += 1; 00248 00249 } 00250 00251 // 00252 // Allow all processor that were started to enter the idle loop and 00253 // begin execution. 00254 // 00255 00256 KiBarrierWait = 0; 00257 00258 if ( Number < KiPcrPagesDescriptor->PageCount ) { 00259 if ( Number == 0 ) { 00260 KiPcrPagesDescriptor->MemoryType = LoaderOsloaderHeap; 00261 } else { 00262 KiFreePcrPagesDescriptor.BasePage = KiPcrPagesDescriptor->BasePage + Number; 00263 KiFreePcrPagesDescriptor.PageCount = KiPcrPagesDescriptor->PageCount - Number; 00264 KiFreePcrPagesDescriptor.MemoryType = LoaderOsloaderHeap; 00265 InsertTailList(&KeLoaderBlock->MemoryDescriptorListHead, 00266 &KiFreePcrPagesDescriptor.ListEntry); 00267 } 00268 } 00269 00270 #endif 00271 00272 // 00273 // Reset and synchronize the performance counters of all processors, by 00274 // applying a null adjustment to the interrupt time 00275 // 00276 00277 KiAdjustInterruptTime (0); 00278 return; 00279 } }

VOID KiStartProcessor IN PLOADER_PARAMETER_BLOCK  Loaderblock  ) 
 


Variable Documentation

ULONG KiBarrierWait = 0
 

Definition at line 53 of file ppc/allproc.c.

MEMORY_ALLOCATION_DESCRIPTOR KiFreePcrPagesDescriptor
 

Definition at line 58 of file ppc/allproc.c.

Referenced by KeStartAllProcessors().


Generated on Sat May 15 19:42:52 2004 for test by doxygen 1.3.7