mirror of
				https://github.com/acidanthera/audk.git
				synced 2025-10-31 19:23:54 +01:00 
			
		
		
		
	IntelFrameworkModule/LegacyBios: Use reserved memory for legacy data
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>
This commit is contained in:
		
							parent
							
								
									7cd8a57599
								
							
						
					
					
						commit
						b22a62be5c
					
				| @ -1,6 +1,6 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
| 
 | 
 | ||||||
| Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR> | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> | ||||||
| 
 | 
 | ||||||
| This program and the accompanying materials | This program and the accompanying materials | ||||||
| are licensed and made available under the terms and conditions | are licensed and made available under the terms and conditions | ||||||
| @ -43,10 +43,10 @@ UINTN                 mStructureTablePages     = 0; | |||||||
| BOOLEAN               mEndOfDxe                = FALSE; | BOOLEAN               mEndOfDxe                = FALSE; | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode |   Allocate memory for legacy usage. | ||||||
|   memory. |  | ||||||
| 
 | 
 | ||||||
|   @param  AllocateType               Allocated Legacy Memory Type |   @param  AllocateType               The type of allocation to perform. | ||||||
|  |   @param  MemoryType                 The type of memory to allocate. | ||||||
|   @param  StartPageAddress           Start address of range |   @param  StartPageAddress           Start address of range | ||||||
|   @param  Pages                      Number of pages to allocate |   @param  Pages                      Number of pages to allocate | ||||||
|   @param  Result                     Result of allocation |   @param  Result                     Result of allocation | ||||||
| @ -58,6 +58,7 @@ BOOLEAN               mEndOfDxe                = FALSE; | |||||||
| EFI_STATUS | EFI_STATUS | ||||||
| AllocateLegacyMemory ( | AllocateLegacyMemory ( | ||||||
|   IN  EFI_ALLOCATE_TYPE         AllocateType, |   IN  EFI_ALLOCATE_TYPE         AllocateType, | ||||||
|  |   IN  EFI_MEMORY_TYPE           MemoryType, | ||||||
|   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress, |   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress, | ||||||
|   IN  UINTN                     Pages, |   IN  UINTN                     Pages, | ||||||
|   OUT EFI_PHYSICAL_ADDRESS      *Result |   OUT EFI_PHYSICAL_ADDRESS      *Result | ||||||
| @ -72,7 +73,7 @@ AllocateLegacyMemory ( | |||||||
|   MemPage = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress; |   MemPage = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPageAddress; | ||||||
|   Status = gBS->AllocatePages ( |   Status = gBS->AllocatePages ( | ||||||
|                   AllocateType, |                   AllocateType, | ||||||
|                   EfiBootServicesCode, |                   MemoryType, | ||||||
|                   Pages, |                   Pages, | ||||||
|                   &MemPage |                   &MemPage | ||||||
|                   ); |                   ); | ||||||
| @ -974,6 +975,7 @@ LegacyBiosInstall ( | |||||||
|   //
 |   //
 | ||||||
|   AllocateLegacyMemory ( |   AllocateLegacyMemory ( | ||||||
|     AllocateAddress, |     AllocateAddress, | ||||||
|  |     EfiReservedMemoryType, | ||||||
|     0, |     0, | ||||||
|     1, |     1, | ||||||
|     &MemoryAddress |     &MemoryAddress | ||||||
| @ -999,6 +1001,7 @@ LegacyBiosInstall ( | |||||||
| 
 | 
 | ||||||
|   Status = AllocateLegacyMemory ( |   Status = AllocateLegacyMemory ( | ||||||
|              AllocateAddress, |              AllocateAddress, | ||||||
|  |              EfiReservedMemoryType, | ||||||
|              CONVENTIONAL_MEMORY_TOP - MemorySize, |              CONVENTIONAL_MEMORY_TOP - MemorySize, | ||||||
|              EFI_SIZE_TO_PAGES (MemorySize), |              EFI_SIZE_TO_PAGES (MemorySize), | ||||||
|              &MemoryAddress |              &MemoryAddress | ||||||
| @ -1027,6 +1030,7 @@ LegacyBiosInstall ( | |||||||
|   for (MemStart = MemoryAddress; MemStart < MemoryAddress + MemorySize; MemStart += 0x1000) { |   for (MemStart = MemoryAddress; MemStart < MemoryAddress + MemorySize; MemStart += 0x1000) { | ||||||
|     Status = AllocateLegacyMemory ( |     Status = AllocateLegacyMemory ( | ||||||
|                AllocateAddress, |                AllocateAddress, | ||||||
|  |                EfiBootServicesCode, | ||||||
|                MemStart, |                MemStart, | ||||||
|                1, |                1, | ||||||
|                &StartAddress |                &StartAddress | ||||||
| @ -1046,6 +1050,7 @@ LegacyBiosInstall ( | |||||||
|   ASSERT ((MemorySize & 0xFFF) == 0);   |   ASSERT ((MemorySize & 0xFFF) == 0);   | ||||||
|   Status = AllocateLegacyMemory ( |   Status = AllocateLegacyMemory ( | ||||||
|              AllocateMaxAddress, |              AllocateMaxAddress, | ||||||
|  |              EfiBootServicesCode, | ||||||
|              CONVENTIONAL_MEMORY_TOP, |              CONVENTIONAL_MEMORY_TOP, | ||||||
|              EFI_SIZE_TO_PAGES (MemorySize), |              EFI_SIZE_TO_PAGES (MemorySize), | ||||||
|              &MemoryAddressUnder1MB |              &MemoryAddressUnder1MB | ||||||
| @ -1059,6 +1064,7 @@ LegacyBiosInstall ( | |||||||
|   //
 |   //
 | ||||||
|   Status = AllocateLegacyMemory ( |   Status = AllocateLegacyMemory ( | ||||||
|              AllocateMaxAddress, |              AllocateMaxAddress, | ||||||
|  |              EfiReservedMemoryType, | ||||||
|              CONVENTIONAL_MEMORY_TOP, |              CONVENTIONAL_MEMORY_TOP, | ||||||
|              (sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 2, |              (sizeof (LOW_MEMORY_THUNK) / EFI_PAGE_SIZE) + 2, | ||||||
|              &MemoryAddress |              &MemoryAddress | ||||||
| @ -1086,6 +1092,7 @@ LegacyBiosInstall ( | |||||||
|   //   
 |   //   
 | ||||||
|   Status = AllocateLegacyMemory ( |   Status = AllocateLegacyMemory ( | ||||||
|              AllocateMaxAddress, |              AllocateMaxAddress, | ||||||
|  |              EfiBootServicesCode, | ||||||
|              0x1000000, |              0x1000000, | ||||||
|              EFI_SIZE_TO_PAGES (MemorySize), |              EFI_SIZE_TO_PAGES (MemorySize), | ||||||
|              &MemoryAddress |              &MemoryAddress | ||||||
| @ -1096,6 +1103,7 @@ LegacyBiosInstall ( | |||||||
|     //   
 |     //   
 | ||||||
|     Status = AllocateLegacyMemory ( |     Status = AllocateLegacyMemory ( | ||||||
|                AllocateMaxAddress, |                AllocateMaxAddress, | ||||||
|  |                EfiBootServicesCode, | ||||||
|                0xFFFFFFFF, |                0xFFFFFFFF, | ||||||
|                EFI_SIZE_TO_PAGES (MemorySize), |                EFI_SIZE_TO_PAGES (MemorySize), | ||||||
|                &MemoryAddress |                &MemoryAddress | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
| 
 | 
 | ||||||
| Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> | ||||||
| 
 | 
 | ||||||
| This program and the accompanying materials | This program and the accompanying materials | ||||||
| are licensed and made available under the terms and conditions | are licensed and made available under the terms and conditions | ||||||
| @ -1261,10 +1261,10 @@ GenerateSoftInit ( | |||||||
|   ); |   ); | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|   Do an AllocatePages () of type AllocateMaxAddress for EfiBootServicesCode |   Allocate memory for legacy usage. | ||||||
|   memory. |  | ||||||
| 
 | 
 | ||||||
|   @param  AllocateType               Allocated Legacy Memory Type |   @param  AllocateType               The type of allocation to perform. | ||||||
|  |   @param  MemoryType                 The type of memory to allocate. | ||||||
|   @param  StartPageAddress           Start address of range |   @param  StartPageAddress           Start address of range | ||||||
|   @param  Pages                      Number of pages to allocate |   @param  Pages                      Number of pages to allocate | ||||||
|   @param  Result                     Result of allocation |   @param  Result                     Result of allocation | ||||||
| @ -1276,6 +1276,7 @@ GenerateSoftInit ( | |||||||
| EFI_STATUS | EFI_STATUS | ||||||
| AllocateLegacyMemory ( | AllocateLegacyMemory ( | ||||||
|   IN  EFI_ALLOCATE_TYPE         AllocateType, |   IN  EFI_ALLOCATE_TYPE         AllocateType, | ||||||
|  |   IN  EFI_MEMORY_TYPE           MemoryType, | ||||||
|   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress, |   IN  EFI_PHYSICAL_ADDRESS      StartPageAddress, | ||||||
|   IN  UINTN                     Pages, |   IN  UINTN                     Pages, | ||||||
|   OUT EFI_PHYSICAL_ADDRESS      *Result |   OUT EFI_PHYSICAL_ADDRESS      *Result | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user