]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
MdeModulePkg/RamDiskDxe: Update RouteConfig function
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / RamDiskDxe / RamDiskImpl.c
1 /** @file
2 HII Config Access protocol implementation of RamDiskDxe driver.
3
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016-2018 Hewlett Packard Enterprise Development LP<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "RamDiskImpl.h"
17
18 CHAR16 mRamDiskStorageName[] = L"RAM_DISK_CONFIGURATION";
19
20 RAM_DISK_CONFIG_PRIVATE_DATA mRamDiskConfigPrivateDataTemplate = {
21 RAM_DISK_CONFIG_PRIVATE_DATA_SIGNATURE,
22 {
23 EFI_PAGE_SIZE,
24 RAM_DISK_BOOT_SERVICE_DATA_MEMORY
25 },
26 {
27 RamDiskExtractConfig,
28 RamDiskRouteConfig,
29 RamDiskCallback
30 }
31 };
32
33 HII_VENDOR_DEVICE_PATH mRamDiskHiiVendorDevicePath = {
34 {
35 {
36 HARDWARE_DEVICE_PATH,
37 HW_VENDOR_DP,
38 {
39 (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
40 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
41 }
42 },
43 RAM_DISK_FORM_SET_GUID
44 },
45 {
46 END_DEVICE_PATH_TYPE,
47 END_ENTIRE_DEVICE_PATH_SUBTYPE,
48 {
49 (UINT8) (END_DEVICE_PATH_LENGTH),
50 (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
51 }
52 }
53 };
54
55
56 /**
57 This function publish the RAM disk configuration Form.
58
59 @param[in, out] ConfigPrivateData
60 Points to RAM disk configuration private data.
61
62 @retval EFI_SUCCESS HII Form is installed successfully.
63 @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.
64 @retval Others Other errors as indicated.
65
66 **/
67 EFI_STATUS
68 InstallRamDiskConfigForm (
69 IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
70 )
71 {
72 EFI_STATUS Status;
73 EFI_HII_HANDLE HiiHandle;
74 EFI_HANDLE DriverHandle;
75 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
76
77 DriverHandle = NULL;
78 ConfigAccess = &ConfigPrivateData->ConfigAccess;
79 Status = gBS->InstallMultipleProtocolInterfaces (
80 &DriverHandle,
81 &gEfiDevicePathProtocolGuid,
82 &mRamDiskHiiVendorDevicePath,
83 &gEfiHiiConfigAccessProtocolGuid,
84 ConfigAccess,
85 NULL
86 );
87 if (EFI_ERROR (Status)) {
88 return Status;
89 }
90
91 ConfigPrivateData->DriverHandle = DriverHandle;
92
93 //
94 // Publish the HII package list
95 //
96 HiiHandle = HiiAddPackages (
97 &gRamDiskFormSetGuid,
98 DriverHandle,
99 RamDiskDxeStrings,
100 RamDiskHiiBin,
101 NULL
102 );
103 if (HiiHandle == NULL) {
104 gBS->UninstallMultipleProtocolInterfaces (
105 DriverHandle,
106 &gEfiDevicePathProtocolGuid,
107 &mRamDiskHiiVendorDevicePath,
108 &gEfiHiiConfigAccessProtocolGuid,
109 ConfigAccess,
110 NULL
111 );
112 return EFI_OUT_OF_RESOURCES;
113 }
114
115 ConfigPrivateData->HiiHandle = HiiHandle;
116
117 return EFI_SUCCESS;
118 }
119
120
121 /**
122 This function removes RAM disk configuration Form.
123
124 @param[in, out] ConfigPrivateData
125 Points to RAM disk configuration private data.
126
127 **/
128 VOID
129 UninstallRamDiskConfigForm (
130 IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivateData
131 )
132 {
133 //
134 // Uninstall HII package list
135 //
136 if (ConfigPrivateData->HiiHandle != NULL) {
137 HiiRemovePackages (ConfigPrivateData->HiiHandle);
138 ConfigPrivateData->HiiHandle = NULL;
139 }
140
141 //
142 // Uninstall HII Config Access Protocol
143 //
144 if (ConfigPrivateData->DriverHandle != NULL) {
145 gBS->UninstallMultipleProtocolInterfaces (
146 ConfigPrivateData->DriverHandle,
147 &gEfiDevicePathProtocolGuid,
148 &mRamDiskHiiVendorDevicePath,
149 &gEfiHiiConfigAccessProtocolGuid,
150 &ConfigPrivateData->ConfigAccess,
151 NULL
152 );
153 ConfigPrivateData->DriverHandle = NULL;
154 }
155
156 FreePool (ConfigPrivateData);
157 }
158
159
160 /**
161 Unregister all registered RAM disks.
162
163 **/
164 VOID
165 UnregisterAllRamDisks (
166 VOID
167 )
168 {
169 LIST_ENTRY *Entry;
170 LIST_ENTRY *NextEntry;
171 RAM_DISK_PRIVATE_DATA *PrivateData;
172
173 if (!IsListEmpty(&RegisteredRamDisks)) {
174 EFI_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
175 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
176
177 gBS->UninstallMultipleProtocolInterfaces (
178 PrivateData->Handle,
179 &gEfiBlockIoProtocolGuid,
180 &PrivateData->BlockIo,
181 &gEfiBlockIo2ProtocolGuid,
182 &PrivateData->BlockIo2,
183 &gEfiDevicePathProtocolGuid,
184 (EFI_DEVICE_PATH_PROTOCOL *) PrivateData->DevicePath,
185 NULL
186 );
187
188 RemoveEntryList (&PrivateData->ThisInstance);
189
190 if (RamDiskCreateHii == PrivateData->CreateMethod) {
191 //
192 // If a RAM disk is created within HII, then the RamDiskDxe driver
193 // driver is responsible for freeing the allocated memory for the
194 // RAM disk.
195 //
196 FreePool ((VOID *)(UINTN) PrivateData->StartingAddr);
197 }
198
199 FreePool (PrivateData->DevicePath);
200 FreePool (PrivateData);
201 }
202 }
203 }
204
205
206 /**
207 This function allows a caller to extract the current configuration for one
208 or more named elements from the target driver.
209
210 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
211 @param[in] Request A null-terminated Unicode string in
212 <ConfigRequest> format.
213 @param[out] Progress On return, points to a character in the Request
214 string. Points to the string's null terminator if
215 request was successful. Points to the most recent
216 '&' before the first failing name/value pair (or
217 the beginning of the string if the failure is in
218 the first name/value pair) if the request was not
219 successful.
220 @param[out] Results A null-terminated Unicode string in
221 <ConfigAltResp> format which has all values filled
222 in for the names in the Request string. String to
223 be allocated by the called function.
224
225 @retval EFI_SUCCESS The Results is filled with the requested
226 values.
227 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
228 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
229 @retval EFI_NOT_FOUND Routing data doesn't match any storage in
230 this driver.
231
232 **/
233 EFI_STATUS
234 EFIAPI
235 RamDiskExtractConfig (
236 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
237 IN CONST EFI_STRING Request,
238 OUT EFI_STRING *Progress,
239 OUT EFI_STRING *Results
240 )
241 {
242 if (Progress == NULL || Results == NULL) {
243 return EFI_INVALID_PARAMETER;
244 }
245 *Progress = Request;
246 return EFI_NOT_FOUND;
247 }
248
249
250 /**
251 This function processes the results of changes in configuration.
252
253 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
254 @param[in] Configuration A null-terminated Unicode string in <ConfigResp>
255 format.
256 @param[out] Progress A pointer to a string filled in with the offset of
257 the most recent '&' before the first failing
258 name/value pair (or the beginning of the string if
259 the failure is in the first name/value pair) or
260 the terminating NULL if all was successful.
261
262 @retval EFI_SUCCESS The Results is processed successfully.
263 @retval EFI_INVALID_PARAMETER Configuration is NULL.
264 @retval EFI_NOT_FOUND Routing data doesn't match any storage in
265 this driver.
266
267 **/
268 EFI_STATUS
269 EFIAPI
270 RamDiskRouteConfig (
271 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
272 IN CONST EFI_STRING Configuration,
273 OUT EFI_STRING *Progress
274 )
275 {
276 if (Configuration == NULL || Progress == NULL) {
277 return EFI_INVALID_PARAMETER;
278 }
279
280 *Progress = Configuration;
281
282 return EFI_NOT_FOUND;
283 }
284
285
286 /**
287 Allocate memory and register the RAM disk created within RamDiskDxe
288 driver HII.
289
290 @param[in] Size If creating raw, size of the RAM disk to create.
291 If creating from file, zero.
292 @param[in] FileHandle If creating raw, NULL. If creating from file, the
293 file handle.
294 @param[in] MemoryType Type of memory to be used to create RAM Disk.
295
296 @retval EFI_SUCCESS RAM disk is created and registered.
297 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to match the
298 size required.
299
300 **/
301 EFI_STATUS
302 HiiCreateRamDisk (
303 IN UINT64 Size,
304 IN EFI_FILE_HANDLE FileHandle,
305 IN UINT8 MemoryType
306 )
307 {
308 EFI_STATUS Status;
309 UINTN BufferSize;
310 UINT64 *StartingAddr;
311 EFI_INPUT_KEY Key;
312 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
313 RAM_DISK_PRIVATE_DATA *PrivateData;
314 EFI_FILE_INFO *FileInformation;
315
316 FileInformation = NULL;
317 StartingAddr = NULL;
318
319 if (FileHandle != NULL) {
320 //
321 // Create from file.
322 //
323 FileInformation = FileInfo (FileHandle);
324 if (NULL == FileInformation) {
325 do {
326 CreatePopUp (
327 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
328 &Key,
329 L"",
330 L"Not enough memory to get the file information!",
331 L"Press ENTER to continue ...",
332 L"",
333 NULL
334 );
335 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
336
337 return EFI_OUT_OF_RESOURCES;
338 }
339
340 //
341 // Update the size of RAM disk according to the file size.
342 //
343 Size = FileInformation->FileSize;
344 }
345
346 if (Size > (UINTN) -1) {
347 do {
348 CreatePopUp (
349 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
350 &Key,
351 L"",
352 L"The given RAM disk size is too large!",
353 L"Press ENTER to continue ...",
354 L"",
355 NULL
356 );
357 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
358
359 return EFI_OUT_OF_RESOURCES;
360 }
361
362 if (MemoryType == RAM_DISK_BOOT_SERVICE_DATA_MEMORY) {
363 Status = gBS->AllocatePool (
364 EfiBootServicesData,
365 (UINTN)Size,
366 (VOID**)&StartingAddr
367 );
368 } else if (MemoryType == RAM_DISK_RESERVED_MEMORY) {
369 Status = gBS->AllocatePool (
370 EfiReservedMemoryType,
371 (UINTN)Size,
372 (VOID**)&StartingAddr
373 );
374 } else {
375 Status = EFI_INVALID_PARAMETER;
376 }
377
378 if ((StartingAddr == NULL) || EFI_ERROR(Status)) {
379 do {
380 CreatePopUp (
381 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
382 &Key,
383 L"",
384 L"Not enough memory to create the RAM disk!",
385 L"Press ENTER to continue ...",
386 L"",
387 NULL
388 );
389 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
390
391 return EFI_OUT_OF_RESOURCES;
392 }
393
394 if (FileHandle != NULL) {
395 //
396 // Copy the file content to the RAM disk.
397 //
398 BufferSize = (UINTN) Size;
399 FileHandle->Read (
400 FileHandle,
401 &BufferSize,
402 (VOID *)(UINTN) StartingAddr
403 );
404 if (BufferSize != FileInformation->FileSize) {
405 do {
406 CreatePopUp (
407 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
408 &Key,
409 L"",
410 L"File content read error!",
411 L"Press ENTER to continue ...",
412 L"",
413 NULL
414 );
415 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
416
417 return EFI_DEVICE_ERROR;
418 }
419 }
420
421 //
422 // Register the newly created RAM disk.
423 //
424 Status = RamDiskRegister (
425 ((UINT64)(UINTN) StartingAddr),
426 Size,
427 &gEfiVirtualDiskGuid,
428 NULL,
429 &DevicePath
430 );
431 if (EFI_ERROR (Status)) {
432 do {
433 CreatePopUp (
434 EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,
435 &Key,
436 L"",
437 L"Fail to register the newly created RAM disk!",
438 L"Press ENTER to continue ...",
439 L"",
440 NULL
441 );
442 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
443
444 return Status;
445 }
446
447 //
448 // If RAM disk is created within HII, memory should be freed when the
449 // RAM disk is unregisterd.
450 //
451 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (RegisteredRamDisks.BackLink);
452 PrivateData->CreateMethod = RamDiskCreateHii;
453
454 return EFI_SUCCESS;
455 }
456
457
458 /**
459 This function updates the registered RAM disks list on the main form.
460
461 @param[in, out] ConfigPrivate
462 Private data for configurating hii data for RAM
463 disks.
464
465 **/
466 VOID
467 UpdateMainForm (
468 IN OUT RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate
469 )
470 {
471 VOID *StartOpCodeHandle;
472 VOID *EndOpCodeHandle;
473 EFI_IFR_GUID_LABEL *StartLabel;
474 EFI_IFR_GUID_LABEL *EndLabel;
475 LIST_ENTRY *Entry;
476 UINTN Index;
477 RAM_DISK_PRIVATE_DATA *PrivateData;
478 CHAR16 *String;
479 CHAR16 RamDiskStr[128];
480 EFI_STRING_ID StringId;
481
482 //
483 // Init OpCode Handle
484 //
485 StartOpCodeHandle = HiiAllocateOpCodeHandle ();
486 ASSERT (StartOpCodeHandle != NULL);
487
488 EndOpCodeHandle = HiiAllocateOpCodeHandle ();
489 ASSERT (EndOpCodeHandle != NULL);
490
491 //
492 // Create Hii Extend Label OpCode as the start opcode
493 //
494 StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
495 StartOpCodeHandle,
496 &gEfiIfrTianoGuid,
497 NULL,
498 sizeof (EFI_IFR_GUID_LABEL)
499 );
500 StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
501 StartLabel->Number = MAIN_LABEL_LIST_START;
502
503 //
504 // Create Hii Extend Label OpCode as the end opcode
505 //
506 EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
507 EndOpCodeHandle,
508 &gEfiIfrTianoGuid,
509 NULL,
510 sizeof (EFI_IFR_GUID_LABEL)
511 );
512 EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
513 EndLabel->Number = MAIN_LABEL_LIST_END;
514
515 Index = 0;
516 EFI_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
517 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
518 PrivateData->CheckBoxId = (EFI_QUESTION_ID)
519 (MAIN_CHECKBOX_QUESTION_ID_START + Index);
520 //
521 // CheckBox is unchecked by default.
522 //
523 PrivateData->CheckBoxChecked = FALSE;
524 String = RamDiskStr;
525
526 UnicodeSPrint (
527 String,
528 sizeof (RamDiskStr),
529 L" RAM Disk %d: [0x%lx, 0x%lx]\n",
530 Index,
531 PrivateData->StartingAddr,
532 PrivateData->StartingAddr + PrivateData->Size - 1
533 );
534
535 StringId = HiiSetString (ConfigPrivate->HiiHandle, 0, RamDiskStr, NULL);
536 ASSERT (StringId != 0);
537
538 HiiCreateCheckBoxOpCode (
539 StartOpCodeHandle,
540 PrivateData->CheckBoxId,
541 0,
542 0,
543 StringId,
544 STRING_TOKEN (STR_RAM_DISK_LIST_HELP),
545 EFI_IFR_FLAG_CALLBACK,
546 0,
547 NULL
548 );
549
550 Index++;
551 }
552
553 HiiUpdateForm (
554 ConfigPrivate->HiiHandle,
555 &gRamDiskFormSetGuid,
556 MAIN_FORM_ID,
557 StartOpCodeHandle,
558 EndOpCodeHandle
559 );
560
561 HiiFreeOpCodeHandle (StartOpCodeHandle);
562 HiiFreeOpCodeHandle (EndOpCodeHandle);
563 }
564
565
566 /**
567 This function processes the results of changes in configuration.
568
569 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
570 @param[in] Action Specifies the type of action taken by the browser.
571 @param[in] QuestionId A unique value which is sent to the original
572 exporting driver so that it can identify the type
573 of data to expect.
574 @param[in] Type The type of value for the question.
575 @param[in] Value A pointer to the data being sent to the original
576 exporting driver.
577 @param[out] ActionRequest On return, points to the action requested by the
578 callback function.
579
580 @retval EFI_SUCCESS The callback successfully handled the action.
581 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
582 variable and its data.
583 @retval EFI_DEVICE_ERROR The variable could not be saved.
584 @retval EFI_UNSUPPORTED The specified Action is not supported by the
585 callback.
586
587 **/
588 EFI_STATUS
589 EFIAPI
590 RamDiskCallback (
591 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
592 IN EFI_BROWSER_ACTION Action,
593 IN EFI_QUESTION_ID QuestionId,
594 IN UINT8 Type,
595 IN EFI_IFR_TYPE_VALUE *Value,
596 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
597 )
598 {
599 EFI_STATUS Status;
600 RAM_DISK_PRIVATE_DATA *PrivateData;
601 RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
602 EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
603 EFI_FILE_HANDLE FileHandle;
604 LIST_ENTRY *Entry;
605 LIST_ENTRY *NextEntry;
606
607 if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {
608 return EFI_INVALID_PARAMETER;
609 }
610
611 ConfigPrivate = RAM_DISK_CONFIG_PRIVATE_FROM_THIS (This);
612
613 if (Action == EFI_BROWSER_ACTION_RETRIEVE) {
614 Status = EFI_UNSUPPORTED;
615 if (QuestionId == CREATE_RAW_SIZE_QUESTION_ID) {
616 Value->u64 = EFI_PAGE_SIZE;
617 ConfigPrivate->ConfigStore.Size = EFI_PAGE_SIZE;
618 Status = EFI_SUCCESS;
619 } else if (QuestionId == CREATE_RAW_MEMORY_TYPE_QUESTION_ID) {
620 Value->u8 = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
621 ConfigPrivate->ConfigStore.MemType = RAM_DISK_BOOT_SERVICE_DATA_MEMORY;
622 Status = EFI_SUCCESS;
623 }
624 return Status;
625 }
626
627 if ((Action != EFI_BROWSER_ACTION_CHANGED) &&
628 (Action != EFI_BROWSER_ACTION_CHANGING) &&
629 (Action != EFI_BROWSER_ACTION_FORM_OPEN)) {
630 return EFI_UNSUPPORTED;
631 }
632
633 //
634 // Update the RAM disk list show at the main form first.
635 //
636 if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
637 Status = EFI_UNSUPPORTED;
638 if (QuestionId == MAIN_GOTO_FILE_EXPLORER_ID) {
639 UpdateMainForm (ConfigPrivate);
640 Status = EFI_SUCCESS;
641 }
642 return Status;
643 }
644
645 Status = EFI_SUCCESS;
646
647 if (Action == EFI_BROWSER_ACTION_CHANGING) {
648 switch (QuestionId) {
649 case MAIN_GOTO_FILE_EXPLORER_ID:
650 Status = ChooseFile (NULL, NULL, NULL, &FileDevPath);
651 if (EFI_ERROR (Status)) {
652 break;
653 }
654
655 if (FileDevPath != NULL) {
656 //
657 // Open the file.
658 //
659 Status = OpenFileByDevicePath (
660 &FileDevPath,
661 &FileHandle,
662 EFI_FILE_MODE_READ,
663 0
664 );
665 if (EFI_ERROR (Status)) {
666 break;
667 }
668
669 //
670 // Create from file, RAM disk size is zero. It will be updated
671 // according to the file size.
672 //
673 Status = HiiCreateRamDisk (
674 0,
675 FileHandle,
676 ConfigPrivate->ConfigStore.MemType
677 );
678 if (EFI_ERROR (Status)) {
679 break;
680 }
681
682 //
683 // Refresh the registered RAM disks list.
684 //
685 UpdateMainForm (ConfigPrivate);
686 }
687 break;
688
689 default:
690 break;
691 }
692 } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
693 switch (QuestionId) {
694 case MAIN_REMOVE_RD_QUESTION_ID:
695 //
696 // Remove the selected RAM disks
697 //
698 EFI_LIST_FOR_EACH_SAFE (Entry, NextEntry, &RegisteredRamDisks) {
699 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
700 if (PrivateData->CheckBoxChecked) {
701 RamDiskUnregister (
702 (EFI_DEVICE_PATH_PROTOCOL *) PrivateData->DevicePath
703 );
704 }
705 }
706
707 UpdateMainForm (ConfigPrivate);
708
709 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
710 break;
711
712 case CREATE_RAW_SIZE_QUESTION_ID:
713 ConfigPrivate->ConfigStore.Size = Value->u64;
714 break;
715
716 case CREATE_RAW_MEMORY_TYPE_QUESTION_ID:
717 ConfigPrivate->ConfigStore.MemType = Value->u8;
718 break;
719
720 case CREATE_RAW_SUBMIT_QUESTION_ID:
721 //
722 // Create raw, FileHandle is NULL.
723 //
724 Status = HiiCreateRamDisk (
725 ConfigPrivate->ConfigStore.Size,
726 NULL,
727 ConfigPrivate->ConfigStore.MemType
728 );
729 if (EFI_ERROR (Status)) {
730 break;
731 }
732
733 //
734 // Refresh the registered RAM disks list.
735 //
736 UpdateMainForm (ConfigPrivate);
737
738 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
739 break;
740
741 case CREATE_RAW_DISCARD_QUESTION_ID:
742 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
743 break;
744
745 default:
746 //
747 // QuestionIds for checkboxes
748 //
749 if ((QuestionId >= MAIN_CHECKBOX_QUESTION_ID_START) &&
750 (QuestionId < CREATE_RAW_RAM_DISK_FORM_ID)) {
751 EFI_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
752 PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
753 if (PrivateData->CheckBoxId == QuestionId) {
754 PrivateData->CheckBoxChecked = (BOOLEAN) (Value->u8 != 0);
755 }
756 }
757 }
758 break;
759 }
760 }
761
762 return EFI_SUCCESS;
763 }