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 @@
// VFR file used by the 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
@ -26,6 +27,17 @@ formset
form formid = MAIN_FORM_ID,
title = STRING_TOKEN(STR_MAIN_FORM_TITLE);
oneof
questionid = CREATE_RAW_MEMORY_TYPE_QUESTION_ID,
prompt = STRING_TOKEN(STR_MEMORY_TYPE_PROMPT),
help = STRING_TOKEN(STR_MEMORY_TYPE_HELP),
flags = NUMERIC_SIZE_1 | INTERACTIVE,
option text = STRING_TOKEN(STR_RAM_DISK_BOOT_SERVICE_DATA_MEMORY), value = RAM_DISK_BOOT_SERVICE_DATA_MEMORY, flags = DEFAULT;
option text = STRING_TOKEN(STR_RAM_DISK_RESERVED_MEMORY), value = RAM_DISK_RESERVED_MEMORY, flags = 0;
endoneof;
subtitle text = STRING_TOKEN(STR_RAM_DISK_NULL_STRING);
goto CREATE_RAW_RAM_DISK_FORM_ID,
prompt = STRING_TOKEN(STR_GOTO_ADD_RAW_FORM),
help = STRING_TOKEN(STR_GOTO_ADD_RAW_FORM_HELP);

View File

@ -2,7 +2,7 @@
// String definitions for RamDiskDxe driver form.
//
// 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
@ -36,6 +36,11 @@
#string STR_SIZE_PROMPT #language en-US "Size (Hex):"
#string STR_SIZE_HELP #language en-US "The valid RAM disk size should be multiples of the RAM disk block size."
#string STR_MEMORY_TYPE_PROMPT #language en-US "Disk Memory Type:"
#string STR_MEMORY_TYPE_HELP #language en-US "Specifies type of memory to use from available memory pool in system to create a disk."
#string STR_RAM_DISK_BOOT_SERVICE_DATA_MEMORY #language en-US "Boot Service Data"
#string STR_RAM_DISK_RESERVED_MEMORY #language en-US "Reserved"
#string STR_CREATE_AND_EXIT_HELP #language en-US "Create a new RAM disk with the given starting and ending address."
#string STR_CREATE_AND_EXIT_PROMPT #language en-US "Create & Exit"
#string STR_DISCARD_AND_EXIT_HELP #language en-US "Discard and exit."

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;
}

View File

@ -2,6 +2,7 @@
Header file for NV data structure definition.
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
@ -29,12 +30,21 @@
#define CREATE_RAW_SIZE_QUESTION_ID 0x2001
#define CREATE_RAW_SUBMIT_QUESTION_ID 0x2002
#define CREATE_RAW_DISCARD_QUESTION_ID 0x2003
#define CREATE_RAW_MEMORY_TYPE_QUESTION_ID 0x2004
#define RAM_DISK_BOOT_SERVICE_DATA_MEMORY 0x00
#define RAM_DISK_RESERVED_MEMORY 0x01
#define RAM_DISK_MEMORY_TYPE_MAX 0x02
typedef struct {
//
// The size of the RAM disk to be created.
//
UINT64 Size;
//
// Selected RAM Disk Memory Type
//
UINT8 MemType;
} RAM_DISK_CONFIGURATION;
#endif