MdeModulePkg RamDiskDxe: Do not save 'Size' numeric value by varstore

The 'Size' numeric value used when creating a raw RAM disk does not
require a varstore to save its previous value in the create raw RAM disk
HII page.

The expecting behavior is that after a user created a raw RAM disk, the
next time when the create raw RAM disk page is entered, the 'Size' numeric
will be the default value (EFI_PAGE_SIZE).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
This commit is contained in:
Hao Wu 2016-06-06 13:02:52 +08:00
parent cd64301398
commit 5cf8a917bd
4 changed files with 33 additions and 126 deletions

View File

@ -20,11 +20,6 @@ formset
help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP),
classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
varstore RAM_DISK_CONFIGURATION,
varid = RAM_DISK_CONFIGURATION_VARSTORE_ID,
name = RAM_DISK_CONFIGURATION,
guid = RAM_DISK_FORM_SET_GUID;
//
// Form #1 "Main Form - Add/Remove/Show RAM Disks"
//
@ -65,11 +60,11 @@ formset
subtitle text = STRING_TOKEN(STR_RAM_DISK_NULL_STRING);
numeric varid = RAM_DISK_CONFIGURATION.Size,
numeric
questionid = CREATE_RAW_SIZE_QUESTION_ID,
prompt = STRING_TOKEN(STR_SIZE_PROMPT),
help = STRING_TOKEN(STR_SIZE_HELP),
flags = DISPLAY_UINT_HEX | INTERACTIVE,
flags = NUMERIC_SIZE_8 | DISPLAY_UINT_HEX | INTERACTIVE,
minimum = 1,
maximum = 0xFFFFFFFFFFFFFFFF,
endnumeric;

View File

@ -18,6 +18,9 @@ CHAR16 mRamDiskStorageName[] = L"RAM_DISK_CONFIGURATION";
RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate = {
RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE,
{
EFI_PAGE_SIZE
},
{
RamDiskExtractConfig,
RamDiskRouteConfig,
@ -234,87 +237,11 @@ RamDiskExtractConfig (
OUT EFI_STRING *Results
)
{
EFI_STATUS Status;
UINTN BufferSize;
RAM_DISK_CONFIGURATION *Configuration;
EFI_STRING ConfigRequest;
EFI_STRING ConfigRequestHdr;
RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
UINTN Size;
BOOLEAN AllocatedRequest;
if (Progress == NULL || Results == NULL) {
return EFI_INVALID_PARAMETER;
}
*Progress = Request;
if ((Request != NULL) &&
!HiiIsConfigHdrMatch (Request, &gRamDiskFormSetGuid, mRamDiskStorageName)) {
return EFI_NOT_FOUND;
}
ConfigRequestHdr = NULL;
ConfigRequest = NULL;
AllocatedRequest = FALSE;
Size = 0;
//
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
//
ConfigPrivate = RAM_DISK_CONFIG_PRIVATE_FROM_THIS (This);
BufferSize = sizeof (RAM_DISK_CONFIGURATION);
Configuration = AllocateZeroPool (BufferSize);
if (Configuration == NULL) {
return EFI_OUT_OF_RESOURCES;
}
ConfigRequest = Request;
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
//
// Request has no request element, construct full request string.
// Allocate and fill a buffer large enough to hold the <ConfigHdr> template
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
//
ConfigRequestHdr = HiiConstructConfigHdr (
&gRamDiskFormSetGuid,
mRamDiskStorageName,
ConfigPrivate->DriverHandle
);
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr);
}
Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting,
ConfigRequest,
(UINT8 *) &Configuration,
BufferSize,
Results,
Progress
);
//
// Free the allocated config request string and RAM disk configuration data.
//
if (AllocatedRequest) {
FreePool (ConfigRequest);
ConfigRequest = NULL;
}
FreePool (Configuration);
//
// Set Progress string to the original request string.
//
if (Request == NULL) {
*Progress = NULL;
} else if (StrStr (Request, L"OFFSET") == NULL) {
*Progress = Request + StrLen (Request);
}
return Status;
return EFI_NOT_FOUND;
}
@ -348,14 +275,7 @@ RamDiskRouteConfig (
return EFI_INVALID_PARAMETER;
}
*Progress = Configuration;
if (!HiiIsConfigHdrMatch (Configuration, &gRamDiskFormSetGuid, mRamDiskStorageName)) {
return EFI_NOT_FOUND;
}
*Progress = Configuration + StrLen (Configuration);
return EFI_SUCCESS;
return EFI_NOT_FOUND;
}
@ -416,6 +336,22 @@ HiiCreateRamDisk (
Size = FileInformation->FileSize;
}
if (Size > (UINTN) -1) {
do {
CreatePopUp (
EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
&Key,
L"",
L"The given RAM disk size is too large!",
L"Press ENTER to continue ...",
L"",
NULL
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
return EFI_OUT_OF_RESOURCES;
}
StartingAddr = (UINTN) AllocatePool ((UINTN) Size);
if (0 == StartingAddr) {
do {
@ -641,7 +577,6 @@ RamDiskCallback (
EFI_STATUS Status;
RAM_DISK_PRIVATE_DATA *PrivateData;
RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
RAM_DISK_CONFIGURATION *Configuration;
EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
EFI_FILE_HANDLE FileHandle;
LIST_ENTRY *Entry;
@ -651,10 +586,13 @@ RamDiskCallback (
return EFI_INVALID_PARAMETER;
}
ConfigPrivate = RAM_DISK_CONFIG_PRIVATE_FROM_THIS (This);
if (Action == EFI_BROWSER_ACTION_RETRIEVE) {
Status = EFI_UNSUPPORTED;
if (QuestionId == CREATE_RAW_SIZE_QUESTION_ID) {
Value->u64 = EFI_PAGE_SIZE;
ConfigPrivate->ConfigStore.Size = EFI_PAGE_SIZE;
Status = EFI_SUCCESS;
}
return Status;
@ -666,8 +604,6 @@ RamDiskCallback (
return EFI_UNSUPPORTED;
}
ConfigPrivate = RAM_DISK_CONFIG_PRIVATE_FROM_THIS (This);
//
// Update the RAM disk list show at the main form first.
//
@ -680,23 +616,8 @@ RamDiskCallback (
return Status;
}
//
// Get Browser data
//
Configuration = AllocateZeroPool (sizeof (RAM_DISK_CONFIGURATION));
if (Configuration == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_SUCCESS;
HiiGetBrowserData (
&gRamDiskFormSetGuid,
mRamDiskStorageName,
sizeof (RAM_DISK_CONFIGURATION),
(UINT8 *) Configuration
);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
switch (QuestionId) {
case MAIN_GOTO_FILE_EXPLORER_ID:
@ -733,8 +654,6 @@ RamDiskCallback (
//
UpdateMainForm (ConfigPrivate);
}
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
break;
default:
@ -760,11 +679,15 @@ RamDiskCallback (
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
break;
case CREATE_RAW_SIZE_QUESTION_ID:
ConfigPrivate->ConfigStore.Size = Value->u64;
break;
case CREATE_RAW_SUBMIT_QUESTION_ID:
//
// Create raw, FileHandle is NULL.
//
Status = HiiCreateRamDisk (Configuration->Size, NULL);
Status = HiiCreateRamDisk (ConfigPrivate->ConfigStore.Size, NULL);
if (EFI_ERROR (Status)) {
break;
}
@ -798,16 +721,5 @@ RamDiskCallback (
}
}
if (!EFI_ERROR (Status)) {
HiiSetBrowserData (
&gRamDiskFormSetGuid,
mRamDiskStorageName,
sizeof (RAM_DISK_CONFIGURATION),
(UINT8 *) Configuration,
NULL
);
}
FreePool (Configuration);
return EFI_SUCCESS;
}

View File

@ -136,6 +136,8 @@ typedef struct {
typedef struct {
UINTN Signature;
RAM_DISK_CONFIGURATION ConfigStore;
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
EFI_HANDLE DriverHandle;
EFI_HII_HANDLE HiiHandle;

View File

@ -18,8 +18,6 @@
#include <Guid/HiiPlatformSetupFormset.h>
#include <Guid/RamDiskHii.h>
#define RAM_DISK_CONFIGURATION_VARSTORE_ID 0x0001
#define MAIN_FORM_ID 0x1000
#define MAIN_GOTO_FILE_EXPLORER_ID 0x1001
#define MAIN_REMOVE_RD_QUESTION_ID 0x1002