Adding an option in HII menu so user can choose memory type to use when creating a RAM Disk in system. Also fixing an issue where RAW disk size change was not stored back to the variable store.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah <tapands...@hpe.com> --- .../Universal/Disk/RamDiskDxe/RamDiskHii.vfr | 12 +++++++ .../Disk/RamDiskDxe/RamDiskHiiStrings.uni | 7 +++- .../Universal/Disk/RamDiskDxe/RamDiskImpl.c | 38 ++++++++++++++++++---- .../Universal/Disk/RamDiskDxe/RamDiskNVData.h | 10 ++++++ 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskHii.vfr b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskHii.vfr index 9c3e3e4..c8bb78b 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskHii.vfr +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskHii.vfr @@ -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 @@ -31,6 +32,17 @@ formset form formid = MAIN_FORM_ID, title = STRING_TOKEN(STR_MAIN_FORM_TITLE); + oneof varid = RAM_DISK_CONFIGURATION.MemType, + questionid = CREATE_RAW_MEMORY_TYPE_QUESTION_ID, + prompt = STRING_TOKEN(STR_MEMORY_TYPE_PROMPT), + help = STRING_TOKEN(STR_MEMORY_TYPE_HELP), + flags = 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); diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskHiiStrings.uni b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskHiiStrings.uni index ee5f6e6..9cc0b08 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskHiiStrings.uni +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskHiiStrings.uni @@ -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." diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c index f402440..ad8af04 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c @@ -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 @@ -367,6 +368,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 @@ -376,18 +378,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) { // @@ -416,8 +420,15 @@ HiiCreateRamDisk ( Size = FileInformation->FileSize; } - StartingAddr = (UINTN) AllocatePool ((UINTN) Size); - if (0 == StartingAddr) { + if (MemoryType == RAM_DISK_BOOT_SERVICE_DATA_MEMORY) { + Status = gBS->AllocatePool (EfiBootServicesData, (UINTN)Size, &StartingAddr); + } else if (MemoryType == RAM_DISK_RESERVED_MEMORY) { + Status = gBS->AllocatePool (EfiReservedMemoryType, (UINTN)Size, &StartingAddr); + } else { + Status = EFI_INVALID_PARAMETER; + } + + if ((StartingAddr == NULL) || EFI_ERROR(Status)) { do { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, @@ -464,7 +475,7 @@ HiiCreateRamDisk ( // Register the newly created RAM disk. // Status = RamDiskRegister ( - StartingAddr, + (*(UINT64 *)(&StartingAddr)), Size, &gEfiVirtualDiskGuid, NULL, @@ -656,6 +667,9 @@ RamDiskCallback ( if (QuestionId == CREATE_RAW_SIZE_QUESTION_ID) { Value->u64 = EFI_PAGE_SIZE; Status = EFI_SUCCESS; + } else if (QuestionId == CREATE_RAW_MEMORY_TYPE_QUESTION_ID) { + Value->u8 = RAM_DISK_BOOT_SERVICE_DATA_MEMORY; + Status = EFI_SUCCESS; } return Status; } @@ -723,7 +737,7 @@ 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, Configuration->MemType); if (EFI_ERROR (Status)) { break; } @@ -737,6 +751,16 @@ RamDiskCallback ( *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT; break; + case CREATE_RAW_MEMORY_TYPE_QUESTION_ID: + Configuration->MemType = Value->u8; + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; + break; + + case CREATE_RAW_SIZE_QUESTION_ID: + Configuration->Size = Value->u64; + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; + break; + default: break; } @@ -764,7 +788,7 @@ RamDiskCallback ( // // Create raw, FileHandle is NULL. // - Status = HiiCreateRamDisk (Configuration->Size, NULL); + Status = HiiCreateRamDisk (Configuration->Size, NULL, Configuration->MemType); if (EFI_ERROR (Status)) { break; } diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskNVData.h b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskNVData.h index 1426320..7219203 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskNVData.h +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskNVData.h @@ -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 @@ -31,12 +32,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 -- 2.6.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel