2 Memory Detection for Virtual Machines.
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 // The package level header files this module uses
25 // The Library classes this module consumes
27 #include <Library/DebugLib.h>
28 #include <Library/HobLib.h>
29 #include <Library/IoLib.h>
30 #include <Library/PeimEntryPoint.h>
31 #include <Library/ResourcePublicationLib.h>
45 // CMOS 0x34/0x35 specifies the system memory above 16 MB.
46 // * CMOS(0x35) is the high byte
47 // * CMOS(0x34) is the low byte
48 // * The size is specified in 64kb chunks
49 // * Since this is memory above 16MB, the 16MB must be added
50 // into the calculation to get the total memory size.
53 Cmos0x34
= (UINT8
) CmosRead8 (0x34);
54 Cmos0x35
= (UINT8
) CmosRead8 (0x35);
56 return ((((Cmos0x35
<< 8) + Cmos0x34
) << 16) + SIZE_16MB
);
61 Peform Memory Detection
63 @return EFI_SUCCESS The PEIM initialized successfully.
71 EFI_PHYSICAL_ADDRESS MemoryBase
;
73 UINT64 TotalMemorySize
;
75 DEBUG ((EFI_D_ERROR
, "MemDetect called\n"));
78 // Determine total memory size available
80 TotalMemorySize
= (UINT64
)GetSystemMemorySize ();
82 MemoryBase
= 0x800000;
83 MemorySize
= TotalMemorySize
- MemoryBase
- 0x100000;
86 // Publish this memory to the PEI Core
88 Status
= PublishSystemMemory(MemoryBase
, MemorySize
);
89 ASSERT_EFI_ERROR (Status
);
94 AddMemoryBaseSizeHob (MemoryBase
, MemorySize
);
95 AddMemoryRangeHob (0x100000, 0x800000);
96 AddMemoryRangeHob (0x000000, 0x0A0000);