13CHAR16 mRamDiskStorageName[] = L
"RAM_DISK_CONFIGURATION";
16 RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE,
19 RAM_DISK_BOOT_SERVICE_DATA_MEMORY
38 RAM_DISK_FORM_SET_GUID
42 END_ENTIRE_DEVICE_PATH_SUBTYPE,
44 (UINT8)(END_DEVICE_PATH_LENGTH),
45 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
72 ConfigAccess = &ConfigPrivateData->ConfigAccess;
73 Status =
gBS->InstallMultipleProtocolInterfaces (
75 &gEfiDevicePathProtocolGuid,
76 &mRamDiskHiiVendorDevicePath,
77 &gEfiHiiConfigAccessProtocolGuid,
81 if (EFI_ERROR (Status)) {
85 ConfigPrivateData->DriverHandle = DriverHandle;
97 if (HiiHandle ==
NULL) {
98 gBS->UninstallMultipleProtocolInterfaces (
100 &gEfiDevicePathProtocolGuid,
101 &mRamDiskHiiVendorDevicePath,
102 &gEfiHiiConfigAccessProtocolGuid,
106 return EFI_OUT_OF_RESOURCES;
109 ConfigPrivateData->HiiHandle = HiiHandle;
129 if (ConfigPrivateData->HiiHandle !=
NULL) {
131 ConfigPrivateData->HiiHandle =
NULL;
137 if (ConfigPrivateData->DriverHandle !=
NULL) {
138 gBS->UninstallMultipleProtocolInterfaces (
139 ConfigPrivateData->DriverHandle,
140 &gEfiDevicePathProtocolGuid,
141 &mRamDiskHiiVendorDevicePath,
142 &gEfiHiiConfigAccessProtocolGuid,
143 &ConfigPrivateData->ConfigAccess,
146 ConfigPrivateData->DriverHandle =
NULL;
167 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
169 gBS->UninstallMultipleProtocolInterfaces (
171 &gEfiBlockIoProtocolGuid,
172 &PrivateData->BlockIo,
173 &gEfiBlockIo2ProtocolGuid,
174 &PrivateData->BlockIo2,
175 &gEfiDevicePathProtocolGuid,
182 if (RamDiskCreateHii == PrivateData->CreateMethod) {
229 OUT EFI_STRING *Progress,
230 OUT EFI_STRING *Results
233 if ((Progress ==
NULL) || (Results ==
NULL)) {
234 return EFI_INVALID_PARAMETER;
238 return EFI_NOT_FOUND;
263 IN CONST EFI_STRING Configuration,
264 OUT EFI_STRING *Progress
267 if ((Configuration ==
NULL) || (Progress ==
NULL)) {
268 return EFI_INVALID_PARAMETER;
271 *Progress = Configuration;
273 return EFI_NOT_FOUND;
300 UINT64 *StartingAddr;
306 FileInformation =
NULL;
309 if (FileHandle !=
NULL) {
313 FileInformation =
FileInfo (FileHandle);
314 if (
NULL == FileInformation) {
317 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
320 L
"Not enough memory to get the file information!",
321 L
"Press ENTER to continue ...",
325 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
327 return EFI_OUT_OF_RESOURCES;
336 if (Size > (
UINTN)-1) {
339 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
342 L
"The given RAM disk size is too large!",
343 L
"Press ENTER to continue ...",
347 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
349 return EFI_OUT_OF_RESOURCES;
352 if (MemoryType == RAM_DISK_BOOT_SERVICE_DATA_MEMORY) {
353 Status =
gBS->AllocatePool (
356 (VOID **)&StartingAddr
358 }
else if (MemoryType == RAM_DISK_RESERVED_MEMORY) {
359 Status =
gBS->AllocatePool (
362 (VOID **)&StartingAddr
365 Status = EFI_INVALID_PARAMETER;
368 if ((StartingAddr ==
NULL) || EFI_ERROR (Status)) {
371 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
374 L
"Not enough memory to create the RAM disk!",
375 L
"Press ENTER to continue ...",
379 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
381 return EFI_OUT_OF_RESOURCES;
384 if (FileHandle !=
NULL) {
388 BufferSize = (
UINTN)Size;
392 (VOID *)(
UINTN)StartingAddr
394 if (BufferSize != FileInformation->
FileSize) {
397 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
400 L
"File content read error!",
401 L
"Press ENTER to continue ...",
405 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
407 Status = EFI_DEVICE_ERROR;
416 ((UINT64)(
UINTN)StartingAddr),
418 &gEfiVirtualDiskGuid,
422 if (EFI_ERROR (Status)) {
425 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
428 L
"Fail to register the newly created RAM disk!",
429 L
"Press ENTER to continue ...",
433 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
442 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (RegisteredRamDisks.BackLink);
443 PrivateData->CreateMethod = RamDiskCreateHii;
448 gBS->FreePool (StartingAddr);
465 VOID *StartOpCodeHandle;
466 VOID *EndOpCodeHandle;
473 CHAR16 RamDiskStr[128];
474 EFI_STRING_ID StringId;
480 ASSERT (StartOpCodeHandle !=
NULL);
483 ASSERT (EndOpCodeHandle !=
NULL);
495 StartLabel->
Number = MAIN_LABEL_LIST_START;
507 EndLabel->
Number = MAIN_LABEL_LIST_END;
511 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
512 PrivateData->CheckBoxId = (EFI_QUESTION_ID)
513 (MAIN_CHECKBOX_QUESTION_ID_START + Index);
517 PrivateData->CheckBoxChecked =
FALSE;
523 L
" RAM Disk %d: [0x%lx, 0x%lx]\n",
525 PrivateData->StartingAddr,
526 PrivateData->StartingAddr + PrivateData->Size - 1
530 ASSERT (StringId != 0);
534 PrivateData->CheckBoxId,
539 EFI_IFR_FLAG_CALLBACK,
548 ConfigPrivate->HiiHandle,
549 &gRamDiskFormSetGuid,
585 IN EFI_BROWSER_ACTION Action,
586 IN EFI_QUESTION_ID QuestionId,
589 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
600 if ((This ==
NULL) || (Value ==
NULL) || (ActionRequest ==
NULL)) {
601 return EFI_INVALID_PARAMETER;
604 ConfigPrivate = RAM_DISK_CONFIG_PRIVATE_FROM_THIS (This);
606 if (Action == EFI_BROWSER_ACTION_RETRIEVE) {
607 Status = EFI_UNSUPPORTED;
608 if (QuestionId == CREATE_RAW_SIZE_QUESTION_ID) {
609 Value->u64 = EFI_PAGE_SIZE;
610 ConfigPrivate->ConfigStore.Size = EFI_PAGE_SIZE;
612 }
else if (QuestionId == CREATE_RAW_MEMORY_TYPE_QUESTION_ID) {
613 Value->u8 = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
614 ConfigPrivate->ConfigStore.MemType = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
621 if ((Action != EFI_BROWSER_ACTION_CHANGED) &&
622 (Action != EFI_BROWSER_ACTION_CHANGING) &&
623 (Action != EFI_BROWSER_ACTION_FORM_OPEN))
625 return EFI_UNSUPPORTED;
631 if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
632 Status = EFI_UNSUPPORTED;
633 if (QuestionId == MAIN_GOTO_FILE_EXPLORER_ID) {
643 if (Action == EFI_BROWSER_ACTION_CHANGING) {
644 switch (QuestionId) {
645 case MAIN_GOTO_FILE_EXPLORER_ID:
647 if (EFI_ERROR (Status)) {
651 if (FileDevPath !=
NULL) {
661 if (EFI_ERROR (Status)) {
672 ConfigPrivate->ConfigStore.MemType
674 if (EFI_ERROR (Status)) {
689 }
else if (Action == EFI_BROWSER_ACTION_CHANGED) {
690 switch (QuestionId) {
691 case MAIN_REMOVE_RD_QUESTION_ID:
696 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
697 if (PrivateData->CheckBoxChecked) {
706 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
709 case CREATE_RAW_SIZE_QUESTION_ID:
710 ConfigPrivate->ConfigStore.Size = Value->u64;
713 case CREATE_RAW_MEMORY_TYPE_QUESTION_ID:
714 ConfigPrivate->ConfigStore.MemType = Value->u8;
717 case CREATE_RAW_SUBMIT_QUESTION_ID:
722 ConfigPrivate->ConfigStore.Size,
724 ConfigPrivate->ConfigStore.MemType
726 if (EFI_ERROR (Status)) {
735 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
738 case CREATE_RAW_DISCARD_QUESTION_ID:
739 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
746 if ((QuestionId >= MAIN_CHECKBOX_QUESTION_ID_START) &&
747 (QuestionId < CREATE_RAW_RAM_DISK_FORM_ID))
750 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
751 if (PrivateData->CheckBoxId == QuestionId) {
752 PrivateData->CheckBoxChecked = (BOOLEAN)(Value->u8 != 0);
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
#define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)
#define BASE_LIST_FOR_EACH(Entry, ListHead)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
#define HARDWARE_DEVICE_PATH
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI ChooseFile(IN EFI_DEVICE_PATH_PROTOCOL *RootDirectory, IN CHAR16 *FileType OPTIONAL, IN CHOOSE_HANDLER ChooseHandler OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **File OPTIONAL)
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
UINT8 *EFIAPI HiiCreateGuidOpCode(IN VOID *OpCodeHandle, IN CONST EFI_GUID *Guid, IN CONST VOID *GuidOpCode OPTIONAL, IN UINTN OpCodeSize)
UINT8 *EFIAPI HiiCreateCheckBoxOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 CheckBoxFlags, IN VOID *DefaultsOpCodeHandle OPTIONAL)
EFI_STATUS EFIAPI HiiUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN VOID *StartOpCodeHandle, IN VOID *EndOpCodeHandle OPTIONAL)
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
#define EFI_IFR_EXTEND_OP_LABEL
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
VOID UninstallRamDiskConfigForm(IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData)
EFI_STATUS EFIAPI RamDiskCallback(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
EFI_STATUS HiiCreateRamDisk(IN UINT64 Size, IN EFI_FILE_HANDLE FileHandle, IN UINT8 MemoryType)
EFI_STATUS EFIAPI RamDiskRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
EFI_STATUS EFIAPI RamDiskExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
VOID UpdateMainForm(IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate)
EFI_STATUS InstallRamDiskConfigForm(IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData)
VOID UnregisterAllRamDisks(VOID)
EFI_STATUS EFIAPI RamDiskRegister(IN UINT64 RamDiskBase, IN UINT64 RamDiskSize, IN EFI_GUID *RamDiskType, IN EFI_DEVICE_PATH *ParentDevicePath OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI RamDiskUnregister(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_STATUS EFIAPI EfiOpenFileByDevicePath(IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, OUT EFI_FILE_PROTOCOL **File, IN UINT64 OpenMode, IN UINT64 Attributes)
VOID EFIAPI CreatePopUp(IN UINTN Attribute, OUT EFI_INPUT_KEY *Key OPTIONAL,...)