[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH xenbus 2/3] Add a XEN_API to get the maximum physical RAM address



The initialization code in XEN.DLL already scans the physical memory
ranges so it's trivial to store the maximum physical address seen and then
provide a function to return that value.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 include/xen.h    |  6 ++++++
 src/xen/system.c | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/include/xen.h b/include/xen.h
index 98b0748..edfadc9 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -452,4 +452,10 @@ SystemVirtualCpuIndex(
     OUT unsigned int    *vcpu_id
     );
 
+XEN_API
+PHYSICAL_ADDRESS
+SystemMaximumPhysicalAddress(
+    VOID
+    );
+
 #endif  // _XEN_H
diff --git a/src/xen/system.c b/src/xen/system.c
index dbf708d..a7b46d1 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -62,6 +62,7 @@ typedef struct _SYSTEM_CONTEXT {
     ULONG               ProcessorCount;
     PVOID               PowerStateHandle;
     PVOID               ProcessorChangeHandle;
+    PHYSICAL_ADDRESS    MaximumPhysicalAddress;
 } SYSTEM_CONTEXT, *PSYSTEM_CONTEXT;
 
 static SYSTEM_CONTEXT   SystemContext;
@@ -224,6 +225,7 @@ SystemGetMemoryInformation(
     VOID
     )
 {
+    PSYSTEM_CONTEXT         Context = &SystemContext;
     PHYSICAL_MEMORY_RANGE   *Range;
     ULONG                   Index;
     NTSTATUS                status;
@@ -247,10 +249,17 @@ SystemGetMemoryInformation(
              Index,
              Start.HighPart, Start.LowPart,
              End.HighPart, End.LowPart);
+
+        if (End.QuadPart > Context->MaximumPhysicalAddress.QuadPart)
+            Context->MaximumPhysicalAddress.QuadPart = End.QuadPart;
     }
 
     ExFreePool(Range);
 
+    Info("MaximumPhysicalAddress = %08x.%08x\n",
+         Context->MaximumPhysicalAddress.HighPart,
+         Context->MaximumPhysicalAddress.LowPart);
+
     return STATUS_SUCCESS;
 
 fail1:
@@ -1018,6 +1027,17 @@ fail1:
     return status;
 }
 
+XEN_API
+PHYSICAL_ADDRESS
+SystemMaximumPhysicalAddress(
+    VOID
+    )
+{
+    PSYSTEM_CONTEXT Context = &SystemContext;
+
+    return Context->MaximumPhysicalAddress;
+}
+
 VOID
 SystemTeardown(
     VOID
@@ -1032,6 +1052,8 @@ SystemTeardown(
     __SystemFree(Context->Madt);
     Context->Madt = NULL;
 
+    Context->MaximumPhysicalAddress.QuadPart = 0;
+
     (VOID) InterlockedDecrement(&Context->References);
 
     ASSERT(IsZeroMemory(Context, sizeof (SYSTEM_CONTEXT)));
-- 
2.5.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.