2008-03-05 09:52:00 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Microsoft Research Singularity
|
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
//
|
|
|
|
// Note:
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Caution:
|
|
|
|
//
|
|
|
|
|
|
|
|
using Microsoft.Singularity.Hal.Acpi;
|
|
|
|
|
|
|
|
namespace Microsoft.Singularity.Hal
|
|
|
|
{
|
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using Microsoft.Singularity.Io;
|
|
|
|
|
|
|
|
[CLSCompliant(false)]
|
2008-11-17 18:29:00 -05:00
|
|
|
internal class HalMemorySrat : HalMemory
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
2008-11-17 18:29:00 -05:00
|
|
|
// See ProcessorAffinity and MemoryAffinity in the HalMemory.cs
|
2008-03-05 09:52:00 -05:00
|
|
|
|
|
|
|
private static ProcessorAffinity[] processors;
|
|
|
|
private static MemoryAffinity[] memories;
|
2008-11-17 18:29:00 -05:00
|
|
|
private static bool disabled;
|
2008-03-05 09:52:00 -05:00
|
|
|
|
|
|
|
private Srat srat;
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
internal HalMemorySrat(Srat srat)
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
|
|
|
this.srat = srat;
|
|
|
|
if (srat == null) {
|
|
|
|
processors = null;
|
|
|
|
memories = null;
|
2008-11-17 18:29:00 -05:00
|
|
|
disabled = true;
|
2008-03-05 09:52:00 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
processors = new
|
|
|
|
ProcessorAffinity[srat.GetNumberOfProcessors()];
|
|
|
|
memories = new
|
|
|
|
MemoryAffinity [srat.GetNumberOfMemories()];
|
|
|
|
|
|
|
|
for (int i = 0; i < processors.Length; i++) {
|
|
|
|
processors[i].domain = srat.GetProcessorDomain(i);
|
|
|
|
processors[i].apicId = srat.GetProcessorApicId(i);
|
|
|
|
processors[i].flagIgnore = srat.GetProcessorFlagIgnore(i);
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
// Some memory addresses may be outside what is addressable by a UIntPtr
|
|
|
|
// (e.g. an IX with 32-bit addressing on a machine with more than 4 GB
|
|
|
|
// of real memory). If this happens, disable the feature.
|
|
|
|
//
|
|
|
|
// TODO: Someone needs to extend this feature to cover that case.
|
2008-03-05 09:52:00 -05:00
|
|
|
for (int i = 0; i < memories.Length; i++) {
|
2008-11-17 18:29:00 -05:00
|
|
|
ulong endAddr = srat.GetMemoryEndAddress(i);
|
|
|
|
if (endAddr > (ulong) UIntPtr.MaxValue) {
|
|
|
|
DebugStub.WriteLine("Disabling per-processor memory affinity");
|
|
|
|
memories = null;
|
|
|
|
processors = null;
|
|
|
|
disabled = true;
|
|
|
|
return;
|
|
|
|
}
|
2008-03-05 09:52:00 -05:00
|
|
|
memories[i].domain = srat.GetMemoryDomain(i);
|
|
|
|
memories[i].baseAddress = srat.GetMemoryBaseAddress(i);
|
2008-11-17 18:29:00 -05:00
|
|
|
memories[i].endAddress = endAddr;
|
2008-03-05 09:52:00 -05:00
|
|
|
memories[i].memorySize = srat.GetMemorySize(i);
|
|
|
|
memories[i].flagIgnore = srat.GetMemoryFlagIgnore(i);
|
|
|
|
memories[i].flagHotPluggable =
|
|
|
|
srat.GetMemoryFlagHotPluggable(i);
|
|
|
|
memories[i].flagNonVolatile =
|
|
|
|
srat.GetMemoryFlagNonVolatile(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override ProcessorAffinity[] GetProcessorAffinity()
|
|
|
|
{
|
|
|
|
return processors;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override MemoryAffinity[] GetMemoryAffinity()
|
|
|
|
{
|
|
|
|
return memories;
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
public override bool PerProcessorAddressSpaceDisabled()
|
|
|
|
{
|
|
|
|
return disabled;
|
|
|
|
}
|
2008-03-05 09:52:00 -05:00
|
|
|
}
|
|
|
|
}
|