MdeModulePkg/RamDiskDxe: Add Memory Type selection support in Ramdisk HII

Adding an option in HII menu so user can choose memory type to use when
creating a RAM Disk in system.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Samer El-Haj-Mahmoud <elhaj@hpe.com>
This commit is contained in:
Tapan Shah
2016-06-03 02:34:10 +08:00
committed by Hao Wu
parent 5cf8a917bd
commit 4b1f464688
4 changed files with 72 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
HII Config Access protocol implementation of RamDiskDxe driver.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -19,7 +20,8 @@ CHAR16 mRamDiskStorageName[] = L"RAM_DISK_CONFIGURATION";
RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate = {
RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE,
{
EFI_PAGE_SIZE
EFI_PAGE_SIZE,
RAM_DISK_BOOT_SERVICE_DATA_MEMORY
},
{
RamDiskExtractConfig,
@@ -287,6 +289,7 @@ RamDiskRouteConfig (
If creating from file, zero.
@param[in] FileHandle If creating raw, NULL. If creating from file, the
file handle.
@param[in] MemoryType Type of memory to be used to create RAM Disk.
@retval EFI_SUCCESS RAM disk is created and registered.
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to match the
@@ -296,18 +299,20 @@ RamDiskRouteConfig (
EFI_STATUS
HiiCreateRamDisk (
IN UINT64 Size,
IN EFI_FILE_HANDLE FileHandle
IN EFI_FILE_HANDLE FileHandle,
IN UINT8 MemoryType
)
{
EFI_STATUS Status;
UINTN BufferSize;
UINT64 StartingAddr;
UINT64 *StartingAddr;
EFI_INPUT_KEY Key;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
RAM_DISK_PRIVATE_DATA *PrivateData;
EFI_FILE_INFO *FileInformation;
FileInformation = NULL;
StartingAddr = NULL;
if (FileHandle != NULL) {
//
@@ -352,8 +357,23 @@ HiiCreateRamDisk (
return EFI_OUT_OF_RESOURCES;
}
StartingAddr = (UINTN) AllocatePool ((UINTN) Size);
if (0 == StartingAddr) {
if (MemoryType == RAM_DISK_BOOT_SERVICE_DATA_MEMORY) {
Status = gBS->AllocatePool (
EfiBootServicesData,
(UINTN)Size,
(VOID**)&StartingAddr
);
} else if (MemoryType == RAM_DISK_RESERVED_MEMORY) {
Status = gBS->AllocatePool (
EfiReservedMemoryType,
(UINTN)Size,
(VOID**)&StartingAddr
);
} else {
Status = EFI_INVALID_PARAMETER;
}
if ((StartingAddr == NULL) || EFI_ERROR(Status)) {
do {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
@@ -400,7 +420,7 @@ HiiCreateRamDisk (
// Register the newly created RAM disk.
//
Status = RamDiskRegister (
StartingAddr,
((UINT64)(UINTN) StartingAddr),
Size,
&gEfiVirtualDiskGuid,
NULL,
@@ -594,6 +614,10 @@ RamDiskCallback (
Value->u64 = EFI_PAGE_SIZE;
ConfigPrivate->ConfigStore.Size = EFI_PAGE_SIZE;
Status = EFI_SUCCESS;
} else if (QuestionId == CREATE_RAW_MEMORY_TYPE_QUESTION_ID) {
Value->u8 = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
ConfigPrivate->ConfigStore.MemType = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
Status = EFI_SUCCESS;
}
return Status;
}
@@ -644,7 +668,11 @@ RamDiskCallback (
// Create from file, RAM disk size is zero. It will be updated
// according to the file size.
//
Status = HiiCreateRamDisk (0, FileHandle);
Status = HiiCreateRamDisk (
0,
FileHandle,
ConfigPrivate->ConfigStore.MemType
);
if (EFI_ERROR (Status)) {
break;
}
@@ -683,11 +711,19 @@ RamDiskCallback (
ConfigPrivate->ConfigStore.Size = Value->u64;
break;
case CREATE_RAW_MEMORY_TYPE_QUESTION_ID:
ConfigPrivate->ConfigStore.MemType = Value->u8;
break;
case CREATE_RAW_SUBMIT_QUESTION_ID:
//
// Create raw, FileHandle is NULL.
//
Status = HiiCreateRamDisk (ConfigPrivate->ConfigStore.Size, NULL);
Status = HiiCreateRamDisk (
ConfigPrivate->ConfigStore.Size,
NULL,
ConfigPrivate->ConfigStore.MemType
);
if (EFI_ERROR (Status)) {
break;
}