]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 25 Apr 2018 07:05:54 +0000 (15:05 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 9 May 2018 04:09:36 +0000 (12:09 +0800)
Certain Legacy USB implementation needs to access legacy data (BDA,
etc.) from SMM environment. While currently it's not allowed to
access BS memory from SMM after EndofDxe, change the legacy data
to use reserved memory type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBiosInterface.h

index fca08a8fa26d4be275576f8b6156290f96a9e5fc..9466e3e4ddd5eef1ab021e123f6095fcc8486f69 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -43,10 +43,10 @@ UINTN                 mStructureTablePages     = 0;
 BOOLEAN               mEndOfDxe                = FALSE;\r
 \r
 /**\r
-  Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode\r
-  memory.\r
+  Allocate memory for legacy usage.\r
 \r
-  @param  AllocateType               Allocated Legacy Memory Type\r
+  @param  AllocateType               The type of allocation to perform.\r
+  @param  MemoryType                 The type of memory to allocate.\r
   @param  StartPageAddress           Start address of range\r
   @param  Pages                      Number of pages to allocate\r
   @param  Result                     Result of allocation\r
@@ -58,6 +58,7 @@ BOOLEAN               mEndOfDxe                = FALSE;
 EFI_STATUS\r
 AllocateLegacyMemory (\r
   IN  EFI_ALLOCATE_TYPE         AllocateType,\r
+  IN  EFI_MEMORY_TYPE           MemoryType,\r
   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress,\r
   IN  UINTN                     Pages,\r
   OUT EFI_PHYSICAL_ADDRESS      *Result\r
@@ -72,7 +73,7 @@ AllocateLegacyMemory (
   MemPage = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress;\r
   Status = gBS->AllocatePages (\r
                   AllocateType,\r
-                  EfiBootServicesCode,\r
+                  MemoryType,\r
                   Pages,\r
                   &MemPage\r
                   );\r
@@ -974,6 +975,7 @@ LegacyBiosInstall (
   //\r
   AllocateLegacyMemory (\r
     AllocateAddress,\r
+    EfiReservedMemoryType,\r
     0,\r
     1,\r
     &MemoryAddress\r
@@ -999,6 +1001,7 @@ LegacyBiosInstall (
 \r
   Status = AllocateLegacyMemory (\r
              AllocateAddress,\r
+             EfiReservedMemoryType,\r
              CONVENTIONAL_MEMORY_TOP - MemorySize,\r
              EFI_SIZE_TO_PAGES (MemorySize),\r
              &MemoryAddress\r
@@ -1027,6 +1030,7 @@ LegacyBiosInstall (
   for (MemStart = MemoryAddress; MemStart < MemoryAddress + MemorySize; MemStart += 0x1000) {\r
     Status = AllocateLegacyMemory (\r
                AllocateAddress,\r
+               EfiBootServicesCode,\r
                MemStart,\r
                1,\r
                &StartAddress\r
@@ -1046,6 +1050,7 @@ LegacyBiosInstall (
   ASSERT ((MemorySize & 0xFFF) == 0);  \r
   Status = AllocateLegacyMemory (\r
              AllocateMaxAddress,\r
+             EfiBootServicesCode,\r
              CONVENTIONAL_MEMORY_TOP,\r
              EFI_SIZE_TO_PAGES (MemorySize),\r
              &MemoryAddressUnder1MB\r
@@ -1059,6 +1064,7 @@ LegacyBiosInstall (
   //\r
   Status = AllocateLegacyMemory (\r
              AllocateMaxAddress,\r
+             EfiReservedMemoryType,\r
              CONVENTIONAL_MEMORY_TOP,\r
              (sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 2,\r
              &MemoryAddress\r
@@ -1086,6 +1092,7 @@ LegacyBiosInstall (
   //   \r
   Status = AllocateLegacyMemory (\r
              AllocateMaxAddress,\r
+             EfiBootServicesCode,\r
              0x1000000,\r
              EFI_SIZE_TO_PAGES (MemorySize),\r
              &MemoryAddress\r
@@ -1096,6 +1103,7 @@ LegacyBiosInstall (
     //   \r
     Status = AllocateLegacyMemory (\r
                AllocateMaxAddress,\r
+               EfiBootServicesCode,\r
                0xFFFFFFFF,\r
                EFI_SIZE_TO_PAGES (MemorySize),\r
                &MemoryAddress\r
index cc2fc9fc135839596f909bd300ef812f31aae050..9f3a1a693cbc6ac0566a79974da32c840c7cdffa 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -1261,10 +1261,10 @@ GenerateSoftInit (
   );\r
 \r
 /**\r
-  Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode\r
-  memory.\r
+  Allocate memory for legacy usage.\r
 \r
-  @param  AllocateType               Allocated Legacy Memory Type\r
+  @param  AllocateType               The type of allocation to perform.\r
+  @param  MemoryType                 The type of memory to allocate.\r
   @param  StartPageAddress           Start address of range\r
   @param  Pages                      Number of pages to allocate\r
   @param  Result                     Result of allocation\r
@@ -1276,6 +1276,7 @@ GenerateSoftInit (
 EFI_STATUS\r
 AllocateLegacyMemory (\r
   IN  EFI_ALLOCATE_TYPE         AllocateType,\r
+  IN  EFI_MEMORY_TYPE           MemoryType,\r
   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress,\r
   IN  UINTN                     Pages,\r
   OUT EFI_PHYSICAL_ADDRESS      *Result\r