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