Use PCD for PMM size and EndOpromShadowAddress to remove hard code value in CSM module.

Signed-off-by: li-elvin
Reviewed-by: jyao1

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12519 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
li-elvin 2011-10-10 01:43:13 +00:00
parent c4042207d6
commit befbc4f3fb
5 changed files with 27 additions and 39 deletions

View File

@ -29,11 +29,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //
LEGACY_BIOS_INSTANCE mPrivateData; LEGACY_BIOS_INSTANCE mPrivateData;
//
// The end of OPROM shadow address
//
UINTN mEndOpromShadowAddress = 0;
/** /**
Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode
memory. memory.
@ -387,23 +382,6 @@ ShadowAndStartLegacy16 (
// //
Table->EfiSystemTable = (UINT32) (UINTN) gST; Table->EfiSystemTable = (UINT32) (UINTN) gST;
//
// Get the end of OPROM shadow address
//
Status = Private->LegacyBiosPlatform->GetPlatformInfo (
Private->LegacyBiosPlatform,
EfiGetPlatformEndOpromShadowAddr,
NULL,
NULL,
&mEndOpromShadowAddress,
NULL,
0,
0
);
if (EFI_ERROR (Status)) {
mEndOpromShadowAddress = 0xDFFFF;
}
// //
// IPF CSM integration -Bug // IPF CSM integration -Bug
// //
@ -905,17 +883,19 @@ LegacyBiosInstall (
} }
// //
// Allocate a 64k area (16 4k pages) for 16-bit code for scratch pad and zero it out // Allocate low PMM memory and zero it out
// //
MemorySize = PcdGet32 (PcdLowPmmMemorySize);
ASSERT ((MemorySize & 0xFFF) == 0);
Status = AllocateLegacyMemory ( Status = AllocateLegacyMemory (
AllocateMaxAddress, AllocateMaxAddress,
CONVENTIONAL_MEMORY_TOP, CONVENTIONAL_MEMORY_TOP,
16, EFI_SIZE_TO_PAGES (MemorySize),
&MemoryAddressUnder1MB &MemoryAddressUnder1MB
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
ZeroMem ((VOID *) ((UINTN) MemoryAddressUnder1MB), 0x10000); ZeroMem ((VOID *) ((UINTN) MemoryAddressUnder1MB), MemorySize);
// //
// Allocate space for thunker and Init Thunker // Allocate space for thunker and Init Thunker
@ -940,20 +920,22 @@ LegacyBiosInstall (
// //
EfiToLegacy16InitTable->BiosLessThan1MB = (UINT32) MemoryAddressUnder1MB; EfiToLegacy16InitTable->BiosLessThan1MB = (UINT32) MemoryAddressUnder1MB;
EfiToLegacy16InitTable->LowPmmMemory = (UINT32) MemoryAddressUnder1MB; EfiToLegacy16InitTable->LowPmmMemory = (UINT32) MemoryAddressUnder1MB;
EfiToLegacy16InitTable->LowPmmMemorySizeInBytes = 0x10000; EfiToLegacy16InitTable->LowPmmMemorySizeInBytes = MemorySize;
// //
// Allocate 4 MB of PMM Memory under 16 MB // Allocate high PMM Memory under 16 MB
// //
MemorySize = PcdGet32 (PcdHighPmmMemorySize);
ASSERT ((MemorySize & 0xFFF) == 0);
Status = AllocateLegacyMemory ( Status = AllocateLegacyMemory (
AllocateMaxAddress, AllocateMaxAddress,
0x1000000, 0x1000000,
0x400, EFI_SIZE_TO_PAGES (MemorySize),
&MemoryAddress &MemoryAddress
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
EfiToLegacy16InitTable->HiPmmMemory = (UINT32) (EFI_PHYSICAL_ADDRESS) (UINTN) MemoryAddress; EfiToLegacy16InitTable->HiPmmMemory = (UINT32) (EFI_PHYSICAL_ADDRESS) (UINTN) MemoryAddress;
EfiToLegacy16InitTable->HiPmmMemorySizeInBytes = PMM_MEMORY_SIZE; EfiToLegacy16InitTable->HiPmmMemorySizeInBytes = MemorySize;
} }
// //

View File

@ -137,6 +137,9 @@
[Pcd] [Pcd]
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLegacyBiosCacheLegacyRegion gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLegacyBiosCacheLegacyRegion
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEbdaReservedMemorySize gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEbdaReservedMemorySize
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEndOpromShadowAddress
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLowPmmMemorySize
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdHighPmmMemorySize
[Depex] [Depex]
gEfiLegacyRegion2ProtocolGuid AND gEfiLegacyInterruptProtocolGuid AND gEfiLegacyBiosPlatformProtocolGuid AND gEfiLegacy8259ProtocolGuid AND gEfiGenericMemTestProtocolGuid AND gEfiCpuArchProtocolGuid AND gEfiTimerArchProtocolGuid gEfiLegacyRegion2ProtocolGuid AND gEfiLegacyInterruptProtocolGuid AND gEfiLegacyBiosPlatformProtocolGuid AND gEfiLegacy8259ProtocolGuid AND gEfiGenericMemTestProtocolGuid AND gEfiCpuArchProtocolGuid AND gEfiTimerArchProtocolGuid

View File

@ -158,11 +158,6 @@ typedef struct {
#endif #endif
//
// Miscellaneous numbers
//
#define PMM_MEMORY_SIZE 0x400000 // 4 MB
#pragma pack(1) #pragma pack(1)
// //
@ -494,8 +489,6 @@ extern BBS_TABLE *mBbsTable;
extern EFI_GENERIC_MEMORY_TEST_PROTOCOL *gGenMemoryTest; extern EFI_GENERIC_MEMORY_TEST_PROTOCOL *gGenMemoryTest;
extern UINTN mEndOpromShadowAddress;
#define PORT_70 0x70 #define PORT_70 0x70
#define PORT_71 0x71 #define PORT_71 0x71

View File

@ -2301,7 +2301,7 @@ LegacyBiosInstallRom (
// then test if there is enough space for its RT code // then test if there is enough space for its RT code
// //
RuntimeAddress = Private->OptionRom; RuntimeAddress = Private->OptionRom;
if (RuntimeAddress + *RuntimeImageLength > mEndOpromShadowAddress) { if (RuntimeAddress + *RuntimeImageLength > PcdGet32 (PcdEndOpromShadowAddress)) {
DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__)); DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__));
gBS->FreePages (PhysicalAddress, EFI_SIZE_TO_PAGES (ImageSize)); gBS->FreePages (PhysicalAddress, EFI_SIZE_TO_PAGES (ImageSize));
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
@ -2312,7 +2312,7 @@ LegacyBiosInstallRom (
// test if there is enough space for its INIT code // test if there is enough space for its INIT code
// //
InitAddress = PCI_START_ADDRESS (Private->OptionRom); InitAddress = PCI_START_ADDRESS (Private->OptionRom);
if (InitAddress + ImageSize > mEndOpromShadowAddress) { if (InitAddress + ImageSize > PcdGet32 (PcdEndOpromShadowAddress)) {
DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__)); DEBUG ((EFI_D_ERROR, "return LegacyBiosInstallRom(%d): EFI_OUT_OF_RESOURCES (no more space for OpROM)\n", __LINE__));
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }

View File

@ -181,4 +181,14 @@
# make sure the memory size is large enough to meet boot script executor requiremnt in S3 phase. # make sure the memory size is large enough to meet boot script executor requiremnt in S3 phase.
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3BootScriptStackSize|0x8000|UINT32|0x30000007 gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3BootScriptStackSize|0x8000|UINT32|0x30000007
## The PCD is used to specify the end of address below 1MB for the OPROM.
# The last shadowed OpROM should not exceed this address.
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdEndOpromShadowAddress|0xdffff|UINT32|0x30000008
## The PCD is used to specify the low PMM (Post Memory Manager) size with bytes below 1MB.
# The value should be a multiple of 4KB.
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLowPmmMemorySize|0x10000|UINT32|0x30000009
## The PCD is used to specify the high PMM (Post Memory Manager) size with bytes above 1MB.
# The value should be a multiple of 4KB.
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdHighPmmMemorySize|0x400000|UINT32|0x3000000a