RtlZeroMemory(Processor->Manufacturer, sizeof (Processor->Manufacturer));
}
-static FORCEINLINE ULONG
-__SystemProcessorCount(
- VOID
- )
-{
- PSYSTEM_CONTEXT Context = &SystemContext;
-
- KeMemoryBarrier();
-
- return Context->ProcessorCount;
-}
-
XEN_API
NTSTATUS
SystemProcessorVcpuId(
NTSTATUS status;
status = STATUS_UNSUCCESSFUL;
- if (Cpu >= __SystemProcessorCount())
+ if (Cpu >= Context->ProcessorCount)
goto fail1;
*vcpu_id = Processor->ProcessorID;
NTSTATUS status;
status = STATUS_UNSUCCESSFUL;
- if (Cpu >= __SystemProcessorCount())
+ if (Cpu >= Context->ProcessorCount)
goto fail1;
ASSERT(*Processor->Registered);
NTSTATUS status;
status = STATUS_UNSUCCESSFUL;
- if (Cpu >= __SystemProcessorCount())
+ if (Cpu >= Context->ProcessorCount)
goto fail1;
ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
NTSTATUS status;
UNREFERENCED_PARAMETER(Argument);
+ UNREFERENCED_PARAMETER(Status);
Cpu = Change->NtNumber;
ProcessorChangeName(Change->State));
switch (Change->State) {
- case KeProcessorAddStartNotify: {
- PSYSTEM_PROCESSOR Processor;
- ULONG ProcessorCount;
-
- if (Cpu < Context->ProcessorCount)
- break;
-
- ProcessorCount = Cpu + 1;
- Processor = __SystemAllocate(sizeof (SYSTEM_PROCESSOR) *
- ProcessorCount);
-
- if (Processor == NULL) {
- *Status = STATUS_NO_MEMORY;
- break;
- }
-
- if (Context->ProcessorCount != 0) {
- RtlCopyMemory(Processor,
- Context->Processor,
- sizeof (SYSTEM_PROCESSOR) *
- Context->ProcessorCount);
- __SystemFree(Context->Processor);
- }
-
- Context->Processor = Processor;
- KeMemoryBarrier();
-
- Context->ProcessorCount = ProcessorCount;
+ case KeProcessorAddStartNotify:
break;
- }
+
case KeProcessorAddCompleteNotify: {
PSYSTEM_PROCESSOR Processor;
KeDeregisterProcessorChangeCallback(Context->ProcessorChangeHandle);
Context->ProcessorChangeHandle = NULL;
- for (Cpu = 0; Cpu < __SystemProcessorCount(); Cpu++) {
+ for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++) {
PSYSTEM_PROCESSOR Processor = &Context->Processor[Cpu];
SystemProcessorDeregisterVcpuInfo(Cpu);
ASSERT(IsZeroMemory(Processor, sizeof (SYSTEM_PROCESSOR)));
}
- __SystemFree(Context->Processor);
- Context->Processor = NULL;
- Context->ProcessorCount = 0;
-
SystemFreeVcpuInfo();
}
ULONG Cpu;
NTSTATUS status;
- for (Cpu = 0; Cpu < __SystemProcessorCount(); Cpu++)
+ for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++)
{
PSYSTEM_PROCESSOR Processor = &Context->Processor[Cpu];
if (References != 1)
goto fail1;
+ Context->ProcessorCount = KeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS);
+ Context->Processor = __SystemAllocate(sizeof (SYSTEM_PROCESSOR) * Context->ProcessorCount);
+
+ status = STATUS_NO_MEMORY;
+ if (Context->Processor == NULL)
+ goto fail2;
+
status = SystemGetStartOptions();
if (!NT_SUCCESS(status))
- goto fail2;
+ goto fail3;
status = SystemGetVersionInformation();
if (!NT_SUCCESS(status))
- goto fail3;
+ goto fail4;
status = SystemGetMemoryInformation();
if (!NT_SUCCESS(status))
- goto fail4;
+ goto fail5;
status = SystemGetAcpiInformation();
if (!NT_SUCCESS(status))
- goto fail5;
+ goto fail6;
status = SystemRegisterProcessorChangeCallback();
if (!NT_SUCCESS(status))
- goto fail6;
+ goto fail7;
status = SystemRegisterPowerStateCallback();
if (!NT_SUCCESS(status))
- goto fail7;
+ goto fail8;
status = SystemGetTimeInformation();
if (!NT_SUCCESS(status))
- goto fail8;
+ goto fail9;
status = SystemCheckProcessors();
if (!NT_SUCCESS(status))
- goto fail9;
+ goto fail10;
return STATUS_SUCCESS;
+fail10:
+ Error("fail10\n");
+
fail9:
Error("fail9\n");
+ SystemDeregisterPowerStateCallback();
+
fail8:
Error("fail8\n");
- SystemDeregisterPowerStateCallback();
+ SystemDeregisterProcessorChangeCallback();
fail7:
Error("fail7\n");
- SystemDeregisterProcessorChangeCallback();
+ __SystemFree(Context->Madt);
+ Context->Madt = NULL;
fail6:
Error("fail6\n");
- __SystemFree(Context->Madt);
- Context->Madt = NULL;
-
fail5:
Error("fail5\n");
fail3:
Error("fail3\n");
+ __SystemFree(Context->Processor);
+
fail2:
Error("fail2\n");
+ Context->ProcessorCount = 0;
+
fail1:
Error("fail1 (%08x)\n", status);
return status;
}
-XEN_API
-ULONG
-SystemProcessorCount(
- VOID
- )
-{
- return __SystemProcessorCount();
-}
-
XEN_API
PHYSICAL_ADDRESS
SystemMaximumPhysicalAddress(
Context->MaximumPhysicalAddress.QuadPart = 0;
+ __SystemFree(Context->Processor);
+ Context->ProcessorCount = 0;
+
(VOID) InterlockedDecrement(&Context->References);
ASSERT(IsZeroMemory(Context, sizeof (SYSTEM_CONTEXT)));