STATIC\r
EFI_STATUS\r
ScanOrAdd64BitE820Ram (\r
+ IN BOOLEAN AddHighHob,\r
+ OUT UINT64 *LowMemory OPTIONAL,\r
OUT UINT64 *MaxAddress OPTIONAL\r
)\r
{\r
return EFI_PROTOCOL_ERROR;\r
}\r
\r
+ if (LowMemory != NULL) {\r
+ *LowMemory = 0;\r
+ }\r
+\r
if (MaxAddress != NULL) {\r
*MaxAddress = BASE_4GB;\r
}\r
E820Entry.Length,\r
E820Entry.Type\r
));\r
- if ((E820Entry.Type == EfiAcpiAddressRangeMemory) &&\r
- (E820Entry.BaseAddr >= BASE_4GB))\r
- {\r
- if (MaxAddress == NULL) {\r
+ if (E820Entry.Type == EfiAcpiAddressRangeMemory) {\r
+ if (AddHighHob && (E820Entry.BaseAddr >= BASE_4GB)) {\r
UINT64 Base;\r
UINT64 End;\r
\r
End\r
));\r
}\r
- } else {\r
+ }\r
+\r
+ if (MaxAddress || LowMemory) {\r
UINT64 Candidate;\r
\r
Candidate = E820Entry.BaseAddr + E820Entry.Length;\r
- if (Candidate > *MaxAddress) {\r
+ if (MaxAddress && (Candidate > *MaxAddress)) {\r
*MaxAddress = Candidate;\r
DEBUG ((\r
DEBUG_VERBOSE,\r
*MaxAddress\r
));\r
}\r
+\r
+ if (LowMemory && (Candidate > *LowMemory) && (Candidate < BASE_4GB)) {\r
+ *LowMemory = Candidate;\r
+ DEBUG ((\r
+ DEBUG_VERBOSE,\r
+ "%a: LowMemory=0x%Lx\n",\r
+ __FUNCTION__,\r
+ *LowMemory\r
+ ));\r
+ }\r
}\r
}\r
}\r
// Otherwise, get the flat size of the memory above 4GB from the CMOS (which\r
// can only express a size smaller than 1TB), and add it to 4GB.\r
//\r
- Status = ScanOrAdd64BitE820Ram (&FirstNonAddress);\r
+ Status = ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress);\r
if (EFI_ERROR (Status)) {\r
FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();\r
}\r
// entries. Otherwise, create a single memory HOB with the flat >=4GB\r
// memory size read from the CMOS.\r
//\r
- Status = ScanOrAdd64BitE820Ram (NULL);\r
+ Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL);\r
if (EFI_ERROR (Status) && (UpperMemorySize != 0)) {\r
AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);\r
}\r