]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Add a XEN_API to get the maximum physical RAM address
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 31 Jan 2018 11:52:37 +0000 (11:52 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 31 Jan 2018 15:04:35 +0000 (15:04 +0000)
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@citrix.com>
include/xen.h
src/xen/system.c

index 98b0748324fea1e68e677654527081d371054a70..edfadc9c240cd207e9ac1d83f1a1a6bb739dd252 100644 (file)
@@ -452,4 +452,10 @@ SystemVirtualCpuIndex(
     OUT unsigned int    *vcpu_id
     );
 
+XEN_API
+PHYSICAL_ADDRESS
+SystemMaximumPhysicalAddress(
+    VOID
+    );
+
 #endif  // _XEN_H
index dbf708d0f87d1239d7db1d050b60cccd8f6d53ef..a7b46d131382afd527ae1d8a664920c795ee356b 100644 (file)
@@ -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)));