193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang/** @file 253cf48e083930e279cbd8e12fdd923b7cbd65a9aqwangThis is an example of how a driver might export data to the HII protocol to be 353cf48e083930e279cbd8e12fdd923b7cbd65a9aqwanglater utilized by the Setup Protocol 453cf48e083930e279cbd8e12fdd923b7cbd65a9aqwang 534326197d13c4ff51aedf3c03461b72727d72ac1Eric DongCopyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> 6e5eed7d3641d71d7ea539e5379ea9c6a5cd97004hhtianThis program and the accompanying materials 793e3992d1ea50fb30c48f498d257d4e66252dd9bqwangare licensed and made available under the terms and conditions of the BSD License 893e3992d1ea50fb30c48f498d257d4e66252dd9bqwangwhich accompanies this distribution. The full text of the license may be found at 993e3992d1ea50fb30c48f498d257d4e66252dd9bqwanghttp://opensource.org/licenses/bsd-license.php 1093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 1193e3992d1ea50fb30c48f498d257d4e66252dd9bqwangTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 1293e3992d1ea50fb30c48f498d257d4e66252dd9bqwangWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 1393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 1493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang**/ 1593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 1693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 1793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang#include "DriverSample.h" 1893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 197e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao#define DISPLAY_ONLY_MY_ITEM 0x0002 2093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 2193e3992d1ea50fb30c48f498d257d4e66252dd9bqwangCHAR16 VariableName[] = L"MyIfrNVData"; 2278c2b9a33478ee0cb7e39466fb12191dde56b210ydongCHAR16 MyEfiVar[] = L"MyEfiVar"; 232f3065c0fb21a054956e11ebd6caf5a68bd296e2lgaoEFI_HANDLE DriverHandle[2] = {NULL, NULL}; 247b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming GaoDRIVER_SAMPLE_PRIVATE_DATA *mPrivateData = NULL; 25211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongEFI_EVENT mEvent; 262f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao 272f3065c0fb21a054956e11ebd6caf5a68bd296e2lgaoHII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0 = { 28f6f910dd125144707e3516bbb517b8ec7a388c06rsun { 29f6f910dd125144707e3516bbb517b8ec7a388c06rsun { 30f6f910dd125144707e3516bbb517b8ec7a388c06rsun HARDWARE_DEVICE_PATH, 31f6f910dd125144707e3516bbb517b8ec7a388c06rsun HW_VENDOR_DP, 32f6f910dd125144707e3516bbb517b8ec7a388c06rsun { 33f6f910dd125144707e3516bbb517b8ec7a388c06rsun (UINT8) (sizeof (VENDOR_DEVICE_PATH)), 34f6f910dd125144707e3516bbb517b8ec7a388c06rsun (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) 35f6f910dd125144707e3516bbb517b8ec7a388c06rsun } 36f6f910dd125144707e3516bbb517b8ec7a388c06rsun }, 37c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao DRIVER_SAMPLE_FORMSET_GUID 38f6f910dd125144707e3516bbb517b8ec7a388c06rsun }, 39f6f910dd125144707e3516bbb517b8ec7a388c06rsun { 40f6f910dd125144707e3516bbb517b8ec7a388c06rsun END_DEVICE_PATH_TYPE, 41f6f910dd125144707e3516bbb517b8ec7a388c06rsun END_ENTIRE_DEVICE_PATH_SUBTYPE, 42a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu { 43f6f910dd125144707e3516bbb517b8ec7a388c06rsun (UINT8) (END_DEVICE_PATH_LENGTH), 44f6f910dd125144707e3516bbb517b8ec7a388c06rsun (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) 45f6f910dd125144707e3516bbb517b8ec7a388c06rsun } 46f6f910dd125144707e3516bbb517b8ec7a388c06rsun } 47f6f910dd125144707e3516bbb517b8ec7a388c06rsun}; 48f6f910dd125144707e3516bbb517b8ec7a388c06rsun 492f3065c0fb21a054956e11ebd6caf5a68bd296e2lgaoHII_VENDOR_DEVICE_PATH mHiiVendorDevicePath1 = { 50f6f910dd125144707e3516bbb517b8ec7a388c06rsun { 51f6f910dd125144707e3516bbb517b8ec7a388c06rsun { 52f6f910dd125144707e3516bbb517b8ec7a388c06rsun HARDWARE_DEVICE_PATH, 53f6f910dd125144707e3516bbb517b8ec7a388c06rsun HW_VENDOR_DP, 54f6f910dd125144707e3516bbb517b8ec7a388c06rsun { 55f6f910dd125144707e3516bbb517b8ec7a388c06rsun (UINT8) (sizeof (VENDOR_DEVICE_PATH)), 56f6f910dd125144707e3516bbb517b8ec7a388c06rsun (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) 57f6f910dd125144707e3516bbb517b8ec7a388c06rsun } 58f6f910dd125144707e3516bbb517b8ec7a388c06rsun }, 59c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao DRIVER_SAMPLE_INVENTORY_GUID 60f6f910dd125144707e3516bbb517b8ec7a388c06rsun }, 61f6f910dd125144707e3516bbb517b8ec7a388c06rsun { 62f6f910dd125144707e3516bbb517b8ec7a388c06rsun END_DEVICE_PATH_TYPE, 63f6f910dd125144707e3516bbb517b8ec7a388c06rsun END_ENTIRE_DEVICE_PATH_SUBTYPE, 64a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu { 65f6f910dd125144707e3516bbb517b8ec7a388c06rsun (UINT8) (END_DEVICE_PATH_LENGTH), 66f6f910dd125144707e3516bbb517b8ec7a388c06rsun (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) 67f6f910dd125144707e3516bbb517b8ec7a388c06rsun } 68f6f910dd125144707e3516bbb517b8ec7a388c06rsun } 69f6f910dd125144707e3516bbb517b8ec7a388c06rsun}; 70f6f910dd125144707e3516bbb517b8ec7a388c06rsun 717064c0a5aa3eabe99be9c143e4abaa73d7139609qwang/** 72211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Add empty function for event process function. 73211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 74211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong @param Event The Event need to be process 75211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong @param Context The context of the event. 76211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 77211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong**/ 78211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongVOID 79211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongEFIAPI 80211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongDriverSampleInternalEmptyFunction ( 81211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong IN EFI_EVENT Event, 82211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong IN VOID *Context 83211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ) 84211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong{ 85211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong} 86211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 87211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong/** 88211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Notification function for keystrokes. 89211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 90211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong @param[in] KeyData The key that was pressed. 91211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 92211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong @retval EFI_SUCCESS The operation was successful. 93211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong**/ 94211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongEFI_STATUS 95211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongEFIAPI 96211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongNotificationFunction( 97211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong IN EFI_KEY_DATA *KeyData 98211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ) 99211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong{ 100211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong gBS->SignalEvent (mEvent); 101211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 102211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong return EFI_SUCCESS; 103211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong} 104211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 105211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong/** 106211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Function to start monitoring for CTRL-C using SimpleTextInputEx. 107211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 108211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong @retval EFI_SUCCESS The feature is enabled. 109211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong @retval EFI_OUT_OF_RESOURCES There is not enough mnemory available. 110211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong**/ 111211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongEFI_STATUS 112211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongEFIAPI 113211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongInternalStartMonitor( 114211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong VOID 115211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ) 116211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong{ 117211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx; 118211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_KEY_DATA KeyData; 119211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_STATUS Status; 120211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_HANDLE *Handles; 121211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong UINTN HandleCount; 122211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong UINTN HandleIndex; 123211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_HANDLE NotifyHandle; 124211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 125211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = gBS->LocateHandleBuffer ( 126211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ByProtocol, 127211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &gEfiSimpleTextInputExProtocolGuid, 128211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong NULL, 129211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &HandleCount, 130211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &Handles 131211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ); 132211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { 133211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &SimpleEx); 134211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ASSERT_EFI_ERROR (Status); 135211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 136211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.KeyState.KeyToggleState = 0; 137211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.Key.ScanCode = 0; 138211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED; 139211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.Key.UnicodeChar = L'c'; 140211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 141211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = SimpleEx->RegisterKeyNotify( 142211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong SimpleEx, 143211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &KeyData, 144211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong NotificationFunction, 145211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &NotifyHandle); 146211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong if (EFI_ERROR (Status)) { 147211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong break; 148211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong } 149211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 150211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED; 151211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = SimpleEx->RegisterKeyNotify( 152211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong SimpleEx, 153211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &KeyData, 154211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong NotificationFunction, 155211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &NotifyHandle); 156211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong if (EFI_ERROR (Status)) { 157211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong break; 158211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong } 159211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong } 160211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 161211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong return EFI_SUCCESS; 162211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong} 163211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 164211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong/** 165211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Function to stop monitoring for CTRL-C using SimpleTextInputEx. 166211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 167211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong @retval EFI_SUCCESS The feature is enabled. 168211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong @retval EFI_OUT_OF_RESOURCES There is not enough mnemory available. 169211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong**/ 170211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongEFI_STATUS 171211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongEFIAPI 172211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydongInternalStopMonitor( 173211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong VOID 174211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ) 175211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong{ 176211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx; 177211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_STATUS Status; 178211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_HANDLE *Handles; 179211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_KEY_DATA KeyData; 180211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong UINTN HandleCount; 181211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong UINTN HandleIndex; 182211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_HANDLE NotifyHandle; 183211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 184211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = gBS->LocateHandleBuffer ( 185211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ByProtocol, 186211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &gEfiSimpleTextInputExProtocolGuid, 187211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong NULL, 188211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &HandleCount, 189211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &Handles 190211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ); 191211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { 192211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &SimpleEx); 193211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ASSERT_EFI_ERROR (Status); 194211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 195211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.KeyState.KeyToggleState = 0; 196211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.Key.ScanCode = 0; 197211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED; 198211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.Key.UnicodeChar = L'c'; 199211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 200211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = SimpleEx->RegisterKeyNotify( 201211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong SimpleEx, 202211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &KeyData, 203211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong NotificationFunction, 204211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &NotifyHandle); 205211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong if (!EFI_ERROR (Status)) { 206211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = SimpleEx->UnregisterKeyNotify (SimpleEx, NotifyHandle); 207211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong } 208211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 209211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED; 210211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = SimpleEx->RegisterKeyNotify( 211211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong SimpleEx, 212211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &KeyData, 213211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong NotificationFunction, 214211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &NotifyHandle); 215211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong if (!EFI_ERROR (Status)) { 216211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = SimpleEx->UnregisterKeyNotify (SimpleEx, NotifyHandle); 217211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong } 218211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong } 219211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong return EFI_SUCCESS; 220211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong} 221211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 222211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 223211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong/** 2247064c0a5aa3eabe99be9c143e4abaa73d7139609qwang Encode the password using a simple algorithm. 225a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 2267064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @param Password The string to be encoded. 2277064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @param MaxSize The size of the string. 228a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 2297064c0a5aa3eabe99be9c143e4abaa73d7139609qwang**/ 23093e3992d1ea50fb30c48f498d257d4e66252dd9bqwangVOID 23193e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEncodePassword ( 23293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN CHAR16 *Password, 2335a829f56880a176dc9a90e9d3653c961f9350aa0qwang IN UINTN MaxSize 23493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ) 23593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang{ 23693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINTN Index; 23793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINTN Loop; 23893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang CHAR16 *Buffer; 23993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang CHAR16 *Key; 24093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 24193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Key = L"MAR10648567"; 24293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Buffer = AllocateZeroPool (MaxSize); 24393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ASSERT (Buffer != NULL); 24493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 24593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang for (Index = 0; Key[Index] != 0; Index++) { 24693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang for (Loop = 0; Loop < (UINT8) (MaxSize / 2); Loop++) { 24793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Buffer[Loop] = (CHAR16) (Password[Loop] ^ Key[Index]); 24893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 24993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 25093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 25193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang CopyMem (Password, Buffer, MaxSize); 25293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 25353cf48e083930e279cbd8e12fdd923b7cbd65a9aqwang FreePool (Buffer); 25493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return ; 25593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang} 25693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 2577064c0a5aa3eabe99be9c143e4abaa73d7139609qwang/** 2587064c0a5aa3eabe99be9c143e4abaa73d7139609qwang Validate the user's password. 259a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 2607064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @param PrivateData This driver's private context data. 2617064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @param StringId The user's input. 262a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 2637064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @retval EFI_SUCCESS The user's input matches the password. 2647064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @retval EFI_NOT_READY The user's input does not match the password. 2657064c0a5aa3eabe99be9c143e4abaa73d7139609qwang**/ 26693e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFI_STATUS 26793e3992d1ea50fb30c48f498d257d4e66252dd9bqwangValidatePassword ( 2687064c0a5aa3eabe99be9c143e4abaa73d7139609qwang IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData, 2697064c0a5aa3eabe99be9c143e4abaa73d7139609qwang IN EFI_STRING_ID StringId 27093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ) 27193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang{ 27293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_STATUS Status; 27393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINTN Index; 27493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINTN BufferSize; 27584f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao UINTN PasswordMaxSize; 27693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang CHAR16 *Password; 27793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang CHAR16 *EncodedPassword; 27893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang BOOLEAN OldPassword; 27993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 28093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 28193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Get encoded password first 28293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 28393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION); 28493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = gRT->GetVariable ( 28593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang VariableName, 286c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 28793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang NULL, 28893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &BufferSize, 28993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &PrivateData->Configuration 29093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ); 29193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (EFI_ERROR (Status)) { 29293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 29393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Old password not exist, prompt for new password 29493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 29593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return EFI_SUCCESS; 29693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 29793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 29893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang OldPassword = FALSE; 29984f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao PasswordMaxSize = sizeof (PrivateData->Configuration.WhatIsThePassword2); 30093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 30193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Check whether we have any old password set 30293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 30384f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao for (Index = 0; Index < PasswordMaxSize / sizeof (UINT16); Index++) { 30493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (PrivateData->Configuration.WhatIsThePassword2[Index] != 0) { 30593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang OldPassword = TRUE; 30693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang break; 30793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 30893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 30993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (!OldPassword) { 31093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 31193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Old password not exist, return EFI_SUCCESS to prompt for new password 31293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 31393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return EFI_SUCCESS; 31493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 31593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 31693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 31793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Get user input password 31893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 319cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun Password = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL); 320cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun if (Password == NULL) { 321cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun return EFI_NOT_READY; 322cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun } 32384f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao if (StrSize (Password) > PasswordMaxSize) { 32453cf48e083930e279cbd8e12fdd923b7cbd65a9aqwang FreePool (Password); 325cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun return EFI_NOT_READY; 32693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 32793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 32893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 32993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Validate old password 33093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 33184f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao EncodedPassword = AllocateZeroPool (PasswordMaxSize); 33293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ASSERT (EncodedPassword != NULL); 3335ad66ec6925f1564137752be4d8656d462ebeaf2Dandan Bi StrnCpyS (EncodedPassword, PasswordMaxSize / sizeof (CHAR16), Password, StrLen (Password)); 33484f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao EncodePassword (EncodedPassword, StrLen (EncodedPassword) * sizeof (CHAR16)); 335e35eb8af7b27e0c035f668787d366d05c608ac81lgao if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, PasswordMaxSize) != 0) { 33693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 33793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Old password mismatch, return EFI_NOT_READY to prompt for error message 33893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 33993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = EFI_NOT_READY; 34093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } else { 34193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = EFI_SUCCESS; 34293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 34393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 34453cf48e083930e279cbd8e12fdd923b7cbd65a9aqwang FreePool (Password); 34553cf48e083930e279cbd8e12fdd923b7cbd65a9aqwang FreePool (EncodedPassword); 34693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 34793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 34893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang} 34993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 3507064c0a5aa3eabe99be9c143e4abaa73d7139609qwang/** 3517064c0a5aa3eabe99be9c143e4abaa73d7139609qwang Encode the password using a simple algorithm. 352a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 3537064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @param PrivateData This driver's private context data. 3547064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @param StringId The password from User. 355a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 3567064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @retval EFI_SUCESS The operation is successful. 3577064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @return Other value if gRT->SetVariable () fails. 358a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 3597064c0a5aa3eabe99be9c143e4abaa73d7139609qwang**/ 36093e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFI_STATUS 36193e3992d1ea50fb30c48f498d257d4e66252dd9bqwangSetPassword ( 3627064c0a5aa3eabe99be9c143e4abaa73d7139609qwang IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData, 3637064c0a5aa3eabe99be9c143e4abaa73d7139609qwang IN EFI_STRING_ID StringId 36493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ) 36593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang{ 36693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_STATUS Status; 36793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang CHAR16 *Password; 368cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun CHAR16 *TempPassword; 3695a829f56880a176dc9a90e9d3653c961f9350aa0qwang UINTN PasswordSize; 37093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang DRIVER_SAMPLE_CONFIGURATION *Configuration; 3717e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao UINTN BufferSize; 37293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 37393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 37493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Get Buffer Storage data from EFI variable 37593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 37693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION); 37793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = gRT->GetVariable ( 37893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang VariableName, 379c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 38093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang NULL, 38193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &BufferSize, 38293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &PrivateData->Configuration 38393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ); 38493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (EFI_ERROR (Status)) { 38593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 38693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 38793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 38893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 38993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Get user input password 39093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 391523f48e771b1088c6e2cfddc5c56cde1ef9a2ab0Eric Dong Password = PrivateData->Configuration.WhatIsThePassword2; 392a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2); 3935a829f56880a176dc9a90e9d3653c961f9350aa0qwang ZeroMem (Password, PasswordSize); 394a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 395cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun TempPassword = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL); 396cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun if (TempPassword == NULL) { 397cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun return EFI_NOT_READY; 398cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun } 39984f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao if (StrSize (TempPassword) > PasswordSize) { 400cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun FreePool (TempPassword); 401cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun return EFI_NOT_READY; 40293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 4035ad66ec6925f1564137752be4d8656d462ebeaf2Dandan Bi StrnCpyS (Password, PasswordSize / sizeof (CHAR16), TempPassword, StrLen (TempPassword)); 404cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun FreePool (TempPassword); 40593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 40693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 40793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Retrive uncommitted data from Browser 40893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 4091d451ff9cf3427c5dc4ba1650d33b1b5aad76d7flgao Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_CONFIGURATION)); 4101d451ff9cf3427c5dc4ba1650d33b1b5aad76d7flgao ASSERT (Configuration != NULL); 411c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao if (HiiGetBrowserData (&gDriverSampleFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION), (UINT8 *) Configuration)) { 41293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 41393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Update password's clear text in the screen 41493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 41584f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao CopyMem (Configuration->PasswordClearText, Password, StrSize (Password)); 41693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 41793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 41893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Update uncommitted data of Browser 41993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 4207e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao HiiSetBrowserData ( 421c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 4227e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao VariableName, 4237e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao sizeof (DRIVER_SAMPLE_CONFIGURATION), 4247e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao (UINT8 *) Configuration, 4257e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao NULL 4267e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao ); 42793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 4287e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 4291d451ff9cf3427c5dc4ba1650d33b1b5aad76d7flgao // 4301d451ff9cf3427c5dc4ba1650d33b1b5aad76d7flgao // Free Configuration Buffer 4311d451ff9cf3427c5dc4ba1650d33b1b5aad76d7flgao // 4321d451ff9cf3427c5dc4ba1650d33b1b5aad76d7flgao FreePool (Configuration); 4331d451ff9cf3427c5dc4ba1650d33b1b5aad76d7flgao 43493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 43593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 43693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Set password 43793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 43884f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao EncodePassword (Password, StrLen (Password) * 2); 43993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = gRT->SetVariable( 44093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang VariableName, 441c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 44293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 44393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang sizeof (DRIVER_SAMPLE_CONFIGURATION), 44493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &PrivateData->Configuration 44593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ); 44693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 44793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang} 44893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 44938ebfecb6279417259db116d6b03cdcb03ecc6bblgao/** 45038ebfecb6279417259db116d6b03cdcb03ecc6bblgao Update names of Name/Value storage to current language. 45138ebfecb6279417259db116d6b03cdcb03ecc6bblgao 45238ebfecb6279417259db116d6b03cdcb03ecc6bblgao @param PrivateData Points to the driver private data. 45338ebfecb6279417259db116d6b03cdcb03ecc6bblgao 45438ebfecb6279417259db116d6b03cdcb03ecc6bblgao @retval EFI_SUCCESS All names are successfully updated. 45538ebfecb6279417259db116d6b03cdcb03ecc6bblgao @retval EFI_NOT_FOUND Failed to get Name from HII database. 45638ebfecb6279417259db116d6b03cdcb03ecc6bblgao 45738ebfecb6279417259db116d6b03cdcb03ecc6bblgao**/ 45838ebfecb6279417259db116d6b03cdcb03ecc6bblgaoEFI_STATUS 45938ebfecb6279417259db116d6b03cdcb03ecc6bblgaoLoadNameValueNames ( 46038ebfecb6279417259db116d6b03cdcb03ecc6bblgao IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData 46138ebfecb6279417259db116d6b03cdcb03ecc6bblgao ) 46238ebfecb6279417259db116d6b03cdcb03ecc6bblgao{ 46338ebfecb6279417259db116d6b03cdcb03ecc6bblgao UINTN Index; 46438ebfecb6279417259db116d6b03cdcb03ecc6bblgao 46538ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 46638ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Get Name/Value name string of current language 46738ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 46838ebfecb6279417259db116d6b03cdcb03ecc6bblgao for (Index = 0; Index < NAME_VALUE_NAME_NUMBER; Index++) { 46938ebfecb6279417259db116d6b03cdcb03ecc6bblgao PrivateData->NameValueName[Index] = HiiGetString ( 47038ebfecb6279417259db116d6b03cdcb03ecc6bblgao PrivateData->HiiHandle[0], 47138ebfecb6279417259db116d6b03cdcb03ecc6bblgao PrivateData->NameStringId[Index], 47238ebfecb6279417259db116d6b03cdcb03ecc6bblgao NULL 47338ebfecb6279417259db116d6b03cdcb03ecc6bblgao ); 47438ebfecb6279417259db116d6b03cdcb03ecc6bblgao if (PrivateData->NameValueName[Index] == NULL) { 47538ebfecb6279417259db116d6b03cdcb03ecc6bblgao return EFI_NOT_FOUND; 47638ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 47738ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 47838ebfecb6279417259db116d6b03cdcb03ecc6bblgao 47938ebfecb6279417259db116d6b03cdcb03ecc6bblgao return EFI_SUCCESS; 48038ebfecb6279417259db116d6b03cdcb03ecc6bblgao} 48193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 482ee31d1be529aa074bd5660d0be5cabe9893a11beydong 483ee31d1be529aa074bd5660d0be5cabe9893a11beydong/** 484ee31d1be529aa074bd5660d0be5cabe9893a11beydong Get the value of <Number> in <BlockConfig> format, i.e. the value of OFFSET 485ee31d1be529aa074bd5660d0be5cabe9893a11beydong or WIDTH or VALUE. 486ee31d1be529aa074bd5660d0be5cabe9893a11beydong <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE'=<Number> 487ee31d1be529aa074bd5660d0be5cabe9893a11beydong 488ee31d1be529aa074bd5660d0be5cabe9893a11beydong This is a internal function. 489ee31d1be529aa074bd5660d0be5cabe9893a11beydong 490ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param StringPtr String in <BlockConfig> format and points to the 491ee31d1be529aa074bd5660d0be5cabe9893a11beydong first character of <Number>. 492ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param Number The output value. Caller takes the responsibility 493ee31d1be529aa074bd5660d0be5cabe9893a11beydong to free memory. 494ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param Len Length of the <Number>, in characters. 495ee31d1be529aa074bd5660d0be5cabe9893a11beydong 496ee31d1be529aa074bd5660d0be5cabe9893a11beydong @retval EFI_OUT_OF_RESOURCES Insufficient resources to store neccessary 497ee31d1be529aa074bd5660d0be5cabe9893a11beydong structures. 498ee31d1be529aa074bd5660d0be5cabe9893a11beydong @retval EFI_SUCCESS Value of <Number> is outputted in Number 499ee31d1be529aa074bd5660d0be5cabe9893a11beydong successfully. 500ee31d1be529aa074bd5660d0be5cabe9893a11beydong 501ee31d1be529aa074bd5660d0be5cabe9893a11beydong**/ 502ee31d1be529aa074bd5660d0be5cabe9893a11beydongEFI_STATUS 503ee31d1be529aa074bd5660d0be5cabe9893a11beydongGetValueOfNumber ( 504ee31d1be529aa074bd5660d0be5cabe9893a11beydong IN EFI_STRING StringPtr, 505ee31d1be529aa074bd5660d0be5cabe9893a11beydong OUT UINT8 **Number, 506ee31d1be529aa074bd5660d0be5cabe9893a11beydong OUT UINTN *Len 507ee31d1be529aa074bd5660d0be5cabe9893a11beydong ) 508ee31d1be529aa074bd5660d0be5cabe9893a11beydong{ 509ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_STRING TmpPtr; 510ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN Length; 511ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_STRING Str; 512ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINT8 *Buf; 513ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_STATUS Status; 514ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINT8 DigitUint8; 515ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN Index; 516ee31d1be529aa074bd5660d0be5cabe9893a11beydong CHAR16 TemStr[2]; 517ee31d1be529aa074bd5660d0be5cabe9893a11beydong 518ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (StringPtr == NULL || *StringPtr == L'\0' || Number == NULL || Len == NULL) { 519ee31d1be529aa074bd5660d0be5cabe9893a11beydong return EFI_INVALID_PARAMETER; 520ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 521ee31d1be529aa074bd5660d0be5cabe9893a11beydong 522ee31d1be529aa074bd5660d0be5cabe9893a11beydong Buf = NULL; 523ee31d1be529aa074bd5660d0be5cabe9893a11beydong 524ee31d1be529aa074bd5660d0be5cabe9893a11beydong TmpPtr = StringPtr; 525ee31d1be529aa074bd5660d0be5cabe9893a11beydong while (*StringPtr != L'\0' && *StringPtr != L'&') { 526ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr++; 527ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 528ee31d1be529aa074bd5660d0be5cabe9893a11beydong *Len = StringPtr - TmpPtr; 529ee31d1be529aa074bd5660d0be5cabe9893a11beydong Length = *Len + 1; 530ee31d1be529aa074bd5660d0be5cabe9893a11beydong 531ee31d1be529aa074bd5660d0be5cabe9893a11beydong Str = (EFI_STRING) AllocateZeroPool (Length * sizeof (CHAR16)); 532ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (Str == NULL) { 533ee31d1be529aa074bd5660d0be5cabe9893a11beydong Status = EFI_OUT_OF_RESOURCES; 534ee31d1be529aa074bd5660d0be5cabe9893a11beydong goto Exit; 535ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 536ee31d1be529aa074bd5660d0be5cabe9893a11beydong CopyMem (Str, TmpPtr, *Len * sizeof (CHAR16)); 537ee31d1be529aa074bd5660d0be5cabe9893a11beydong *(Str + *Len) = L'\0'; 538ee31d1be529aa074bd5660d0be5cabe9893a11beydong 539ee31d1be529aa074bd5660d0be5cabe9893a11beydong Length = (Length + 1) / 2; 540ee31d1be529aa074bd5660d0be5cabe9893a11beydong Buf = (UINT8 *) AllocateZeroPool (Length); 541ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (Buf == NULL) { 542ee31d1be529aa074bd5660d0be5cabe9893a11beydong Status = EFI_OUT_OF_RESOURCES; 543ee31d1be529aa074bd5660d0be5cabe9893a11beydong goto Exit; 544ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 545ee31d1be529aa074bd5660d0be5cabe9893a11beydong 546ee31d1be529aa074bd5660d0be5cabe9893a11beydong Length = *Len; 547ee31d1be529aa074bd5660d0be5cabe9893a11beydong ZeroMem (TemStr, sizeof (TemStr)); 548ee31d1be529aa074bd5660d0be5cabe9893a11beydong for (Index = 0; Index < Length; Index ++) { 549ee31d1be529aa074bd5660d0be5cabe9893a11beydong TemStr[0] = Str[Length - Index - 1]; 550ee31d1be529aa074bd5660d0be5cabe9893a11beydong DigitUint8 = (UINT8) StrHexToUint64 (TemStr); 551ee31d1be529aa074bd5660d0be5cabe9893a11beydong if ((Index & 1) == 0) { 552ee31d1be529aa074bd5660d0be5cabe9893a11beydong Buf [Index/2] = DigitUint8; 553ee31d1be529aa074bd5660d0be5cabe9893a11beydong } else { 554ee31d1be529aa074bd5660d0be5cabe9893a11beydong Buf [Index/2] = (UINT8) ((DigitUint8 << 4) + Buf [Index/2]); 555ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 556ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 557ee31d1be529aa074bd5660d0be5cabe9893a11beydong 558ee31d1be529aa074bd5660d0be5cabe9893a11beydong *Number = Buf; 559ee31d1be529aa074bd5660d0be5cabe9893a11beydong Status = EFI_SUCCESS; 560ee31d1be529aa074bd5660d0be5cabe9893a11beydong 561ee31d1be529aa074bd5660d0be5cabe9893a11beydongExit: 562ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (Str != NULL) { 563ee31d1be529aa074bd5660d0be5cabe9893a11beydong FreePool (Str); 564ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 565ee31d1be529aa074bd5660d0be5cabe9893a11beydong 566ee31d1be529aa074bd5660d0be5cabe9893a11beydong return Status; 567ee31d1be529aa074bd5660d0be5cabe9893a11beydong} 568ee31d1be529aa074bd5660d0be5cabe9893a11beydong 569ee31d1be529aa074bd5660d0be5cabe9893a11beydong/** 570ee31d1be529aa074bd5660d0be5cabe9893a11beydong Create altcfg string. 571ee31d1be529aa074bd5660d0be5cabe9893a11beydong 572ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param Result The request result string. 573ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param ConfigHdr The request head info. <ConfigHdr> format. 574ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param Offset The offset of the parameter int he structure. 575ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param Width The width of the parameter. 576ee31d1be529aa074bd5660d0be5cabe9893a11beydong 577ee31d1be529aa074bd5660d0be5cabe9893a11beydong 578ee31d1be529aa074bd5660d0be5cabe9893a11beydong @retval The string with altcfg info append at the end. 579ee31d1be529aa074bd5660d0be5cabe9893a11beydong**/ 580ee31d1be529aa074bd5660d0be5cabe9893a11beydongEFI_STRING 581ee31d1be529aa074bd5660d0be5cabe9893a11beydongCreateAltCfgString ( 582ee31d1be529aa074bd5660d0be5cabe9893a11beydong IN EFI_STRING Result, 583ee31d1be529aa074bd5660d0be5cabe9893a11beydong IN EFI_STRING ConfigHdr, 584ee31d1be529aa074bd5660d0be5cabe9893a11beydong IN UINTN Offset, 585ee31d1be529aa074bd5660d0be5cabe9893a11beydong IN UINTN Width 586ee31d1be529aa074bd5660d0be5cabe9893a11beydong ) 587ee31d1be529aa074bd5660d0be5cabe9893a11beydong{ 588ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_STRING StringPtr; 589ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_STRING TmpStr; 590ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN NewLen; 591ee31d1be529aa074bd5660d0be5cabe9893a11beydong 59246cc3885e68cc19981a4756e1a2d40d35f2eb92fydong NewLen = StrLen (Result); 59333d41385e32425a25da13bdfbfb81f30f226ec18ydong // 59433d41385e32425a25da13bdfbfb81f30f226ec18ydong // String Len = ConfigResp + AltConfig + AltConfig + 1("\0") 59533d41385e32425a25da13bdfbfb81f30f226ec18ydong // 59646cc3885e68cc19981a4756e1a2d40d35f2eb92fydong NewLen = (NewLen + ((1 + StrLen (ConfigHdr) + 8 + 4) + (8 + 4 + 7 + 4 + 7 + 4)) * 2 + 1) * sizeof (CHAR16); 597ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr = AllocateZeroPool (NewLen); 598ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (StringPtr == NULL) { 599ee31d1be529aa074bd5660d0be5cabe9893a11beydong return NULL; 600ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 601ee31d1be529aa074bd5660d0be5cabe9893a11beydong 602ee31d1be529aa074bd5660d0be5cabe9893a11beydong TmpStr = StringPtr; 603ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (Result != NULL) { 6045ad66ec6925f1564137752be4d8656d462ebeaf2Dandan Bi StrCpyS (StringPtr, NewLen / sizeof (CHAR16), Result); 605ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += StrLen (Result); 606ee31d1be529aa074bd5660d0be5cabe9893a11beydong FreePool (Result); 607ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 608ee31d1be529aa074bd5660d0be5cabe9893a11beydong 609ee31d1be529aa074bd5660d0be5cabe9893a11beydong UnicodeSPrint ( 610ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr, 611ee31d1be529aa074bd5660d0be5cabe9893a11beydong (1 + StrLen (ConfigHdr) + 8 + 4 + 1) * sizeof (CHAR16), 612ee31d1be529aa074bd5660d0be5cabe9893a11beydong L"&%s&ALTCFG=%04x", 613ee31d1be529aa074bd5660d0be5cabe9893a11beydong ConfigHdr, 614ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_HII_DEFAULT_CLASS_STANDARD 615ee31d1be529aa074bd5660d0be5cabe9893a11beydong ); 616ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += StrLen (StringPtr); 617ee31d1be529aa074bd5660d0be5cabe9893a11beydong 618ee31d1be529aa074bd5660d0be5cabe9893a11beydong UnicodeSPrint ( 619ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr, 620ee31d1be529aa074bd5660d0be5cabe9893a11beydong (8 + 4 + 7 + 4 + 7 + 4 + 1) * sizeof (CHAR16), 621ee31d1be529aa074bd5660d0be5cabe9893a11beydong L"&OFFSET=%04x&WIDTH=%04x&VALUE=%04x", 622ee31d1be529aa074bd5660d0be5cabe9893a11beydong Offset, 623ee31d1be529aa074bd5660d0be5cabe9893a11beydong Width, 624ee31d1be529aa074bd5660d0be5cabe9893a11beydong DEFAULT_CLASS_STANDARD_VALUE 625ee31d1be529aa074bd5660d0be5cabe9893a11beydong ); 626ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += StrLen (StringPtr); 627ee31d1be529aa074bd5660d0be5cabe9893a11beydong 628ee31d1be529aa074bd5660d0be5cabe9893a11beydong UnicodeSPrint ( 629ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr, 630ee31d1be529aa074bd5660d0be5cabe9893a11beydong (1 + StrLen (ConfigHdr) + 8 + 4 + 1) * sizeof (CHAR16), 631ee31d1be529aa074bd5660d0be5cabe9893a11beydong L"&%s&ALTCFG=%04x", 632ee31d1be529aa074bd5660d0be5cabe9893a11beydong ConfigHdr, 633ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_HII_DEFAULT_CLASS_MANUFACTURING 634ee31d1be529aa074bd5660d0be5cabe9893a11beydong ); 635ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += StrLen (StringPtr); 636ee31d1be529aa074bd5660d0be5cabe9893a11beydong 637ee31d1be529aa074bd5660d0be5cabe9893a11beydong UnicodeSPrint ( 638ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr, 639ee31d1be529aa074bd5660d0be5cabe9893a11beydong (8 + 4 + 7 + 4 + 7 + 4 + 1) * sizeof (CHAR16), 640ee31d1be529aa074bd5660d0be5cabe9893a11beydong L"&OFFSET=%04x&WIDTH=%04x&VALUE=%04x", 641ee31d1be529aa074bd5660d0be5cabe9893a11beydong Offset, 642ee31d1be529aa074bd5660d0be5cabe9893a11beydong Width, 643ee31d1be529aa074bd5660d0be5cabe9893a11beydong DEFAULT_CLASS_MANUFACTURING_VALUE 644ee31d1be529aa074bd5660d0be5cabe9893a11beydong ); 645ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += StrLen (StringPtr); 646ee31d1be529aa074bd5660d0be5cabe9893a11beydong 647ee31d1be529aa074bd5660d0be5cabe9893a11beydong return TmpStr; 648ee31d1be529aa074bd5660d0be5cabe9893a11beydong} 649ee31d1be529aa074bd5660d0be5cabe9893a11beydong 650ee31d1be529aa074bd5660d0be5cabe9893a11beydong/** 651ee31d1be529aa074bd5660d0be5cabe9893a11beydong Check whether need to add the altcfg string. if need to add, add the altcfg 652ee31d1be529aa074bd5660d0be5cabe9893a11beydong string. 653ee31d1be529aa074bd5660d0be5cabe9893a11beydong 654ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param RequestResult The request result string. 655ee31d1be529aa074bd5660d0be5cabe9893a11beydong @param ConfigRequestHdr The request head info. <ConfigHdr> format. 656ee31d1be529aa074bd5660d0be5cabe9893a11beydong 657ee31d1be529aa074bd5660d0be5cabe9893a11beydong**/ 658ee31d1be529aa074bd5660d0be5cabe9893a11beydongVOID 659ee31d1be529aa074bd5660d0be5cabe9893a11beydongAppendAltCfgString ( 660ee31d1be529aa074bd5660d0be5cabe9893a11beydong IN OUT EFI_STRING *RequestResult, 661ee31d1be529aa074bd5660d0be5cabe9893a11beydong IN EFI_STRING ConfigRequestHdr 662ee31d1be529aa074bd5660d0be5cabe9893a11beydong ) 663ee31d1be529aa074bd5660d0be5cabe9893a11beydong{ 664ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_STRING StringPtr; 665ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN Length; 666ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINT8 *TmpBuffer; 667ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN Offset; 668ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN Width; 669ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN BlockSize; 670ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN ValueOffset; 671ee31d1be529aa074bd5660d0be5cabe9893a11beydong UINTN ValueWidth; 672ee31d1be529aa074bd5660d0be5cabe9893a11beydong EFI_STATUS Status; 673ee31d1be529aa074bd5660d0be5cabe9893a11beydong 6744e1005eca7186cbe61aaae09108f6fdf29959f22Eric Dong TmpBuffer = NULL; 675ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr = *RequestResult; 676ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr = StrStr (StringPtr, L"OFFSET"); 677ee31d1be529aa074bd5660d0be5cabe9893a11beydong BlockSize = sizeof (DRIVER_SAMPLE_CONFIGURATION); 678ee31d1be529aa074bd5660d0be5cabe9893a11beydong ValueOffset = OFFSET_OF (DRIVER_SAMPLE_CONFIGURATION, GetDefaultValueFromAccess); 679ee31d1be529aa074bd5660d0be5cabe9893a11beydong ValueWidth = sizeof (((DRIVER_SAMPLE_CONFIGURATION *)0)->GetDefaultValueFromAccess); 680ee31d1be529aa074bd5660d0be5cabe9893a11beydong 681ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (StringPtr == NULL) { 682ee31d1be529aa074bd5660d0be5cabe9893a11beydong return; 683ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 684ee31d1be529aa074bd5660d0be5cabe9893a11beydong 685ee31d1be529aa074bd5660d0be5cabe9893a11beydong while (*StringPtr != 0 && StrnCmp (StringPtr, L"OFFSET=", StrLen (L"OFFSET=")) == 0) { 686ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += StrLen (L"OFFSET="); 687ee31d1be529aa074bd5660d0be5cabe9893a11beydong // 688ee31d1be529aa074bd5660d0be5cabe9893a11beydong // Get Offset 689ee31d1be529aa074bd5660d0be5cabe9893a11beydong // 690ee31d1be529aa074bd5660d0be5cabe9893a11beydong Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 691ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (EFI_ERROR (Status)) { 692ee31d1be529aa074bd5660d0be5cabe9893a11beydong return; 693ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 694ee31d1be529aa074bd5660d0be5cabe9893a11beydong Offset = 0; 695ee31d1be529aa074bd5660d0be5cabe9893a11beydong CopyMem ( 696ee31d1be529aa074bd5660d0be5cabe9893a11beydong &Offset, 697ee31d1be529aa074bd5660d0be5cabe9893a11beydong TmpBuffer, 698ee31d1be529aa074bd5660d0be5cabe9893a11beydong (((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN) 699ee31d1be529aa074bd5660d0be5cabe9893a11beydong ); 700ee31d1be529aa074bd5660d0be5cabe9893a11beydong FreePool (TmpBuffer); 701ee31d1be529aa074bd5660d0be5cabe9893a11beydong 702ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += Length; 703ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (StrnCmp (StringPtr, L"&WIDTH=", StrLen (L"&WIDTH=")) != 0) { 704ee31d1be529aa074bd5660d0be5cabe9893a11beydong return; 705ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 706ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += StrLen (L"&WIDTH="); 707ee31d1be529aa074bd5660d0be5cabe9893a11beydong 708ee31d1be529aa074bd5660d0be5cabe9893a11beydong // 709ee31d1be529aa074bd5660d0be5cabe9893a11beydong // Get Width 710ee31d1be529aa074bd5660d0be5cabe9893a11beydong // 711ee31d1be529aa074bd5660d0be5cabe9893a11beydong Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 712ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (EFI_ERROR (Status)) { 713ee31d1be529aa074bd5660d0be5cabe9893a11beydong return; 714ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 715ee31d1be529aa074bd5660d0be5cabe9893a11beydong Width = 0; 716ee31d1be529aa074bd5660d0be5cabe9893a11beydong CopyMem ( 717ee31d1be529aa074bd5660d0be5cabe9893a11beydong &Width, 718ee31d1be529aa074bd5660d0be5cabe9893a11beydong TmpBuffer, 719ee31d1be529aa074bd5660d0be5cabe9893a11beydong (((Length + 1) / 2) < sizeof (UINTN)) ? ((Length + 1) / 2) : sizeof (UINTN) 720ee31d1be529aa074bd5660d0be5cabe9893a11beydong ); 721ee31d1be529aa074bd5660d0be5cabe9893a11beydong FreePool (TmpBuffer); 722ee31d1be529aa074bd5660d0be5cabe9893a11beydong 723ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += Length; 724ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (StrnCmp (StringPtr, L"&VALUE=", StrLen (L"&VALUE=")) != 0) { 725ee31d1be529aa074bd5660d0be5cabe9893a11beydong return; 726ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 727ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += StrLen (L"&VALUE="); 728ee31d1be529aa074bd5660d0be5cabe9893a11beydong 729ee31d1be529aa074bd5660d0be5cabe9893a11beydong // 730b18e7050464b0809e0c8366219447e87c9124551ydong // Get Value 731ee31d1be529aa074bd5660d0be5cabe9893a11beydong // 732ee31d1be529aa074bd5660d0be5cabe9893a11beydong Status = GetValueOfNumber (StringPtr, &TmpBuffer, &Length); 733ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (EFI_ERROR (Status)) { 734ee31d1be529aa074bd5660d0be5cabe9893a11beydong return; 735ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 736ee31d1be529aa074bd5660d0be5cabe9893a11beydong StringPtr += Length; 737ee31d1be529aa074bd5660d0be5cabe9893a11beydong 738ee31d1be529aa074bd5660d0be5cabe9893a11beydong // 739ee31d1be529aa074bd5660d0be5cabe9893a11beydong // Calculate Value and convert it to hex string. 740ee31d1be529aa074bd5660d0be5cabe9893a11beydong // 741ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (Offset + Width > BlockSize) { 742ee31d1be529aa074bd5660d0be5cabe9893a11beydong return; 743ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 744ee31d1be529aa074bd5660d0be5cabe9893a11beydong 745ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (Offset <= ValueOffset && Offset + Width >= ValueOffset + ValueWidth) { 74633d41385e32425a25da13bdfbfb81f30f226ec18ydong *RequestResult = CreateAltCfgString(*RequestResult, ConfigRequestHdr, ValueOffset, ValueWidth); 74733d41385e32425a25da13bdfbfb81f30f226ec18ydong return; 748ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 749ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 750ee31d1be529aa074bd5660d0be5cabe9893a11beydong} 751ee31d1be529aa074bd5660d0be5cabe9893a11beydong 75293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang/** 75393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang This function allows a caller to extract the current configuration for one 75493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang or more named elements from the target driver. 75593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 75693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. 75793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param Request A null-terminated Unicode string in 75893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang <ConfigRequest> format. 75993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param Progress On return, points to a character in the Request 76093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang string. Points to the string's null terminator if 76193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang request was successful. Points to the most recent 76293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang '&' before the first failing name/value pair (or 76393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang the beginning of the string if the failure is in 76493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang the first name/value pair) if the request was not 76593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang successful. 76693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param Results A null-terminated Unicode string in 76793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang <ConfigAltResp> format which has all values filled 76893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang in for the names in the Request string. String to 76993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang be allocated by the called function. 77093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 77193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_SUCCESS The Results is filled with the requested values. 77293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results. 773e35eb8af7b27e0c035f668787d366d05c608ac81lgao @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name. 77493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_NOT_FOUND Routing data doesn't match any storage in this 77593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang driver. 77693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 77793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang**/ 77893e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFI_STATUS 77993e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFIAPI 78093e3992d1ea50fb30c48f498d257d4e66252dd9bqwangExtractConfig ( 78193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 78293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN CONST EFI_STRING Request, 78393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang OUT EFI_STRING *Progress, 78493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang OUT EFI_STRING *Results 78593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ) 78693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang{ 78793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_STATUS Status; 78893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINTN BufferSize; 78993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang DRIVER_SAMPLE_PRIVATE_DATA *PrivateData; 79093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; 79184f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao EFI_STRING ConfigRequest; 792086cd2c8e932297641aba4986e3376b202365b5algao EFI_STRING ConfigRequestHdr; 79384f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao UINTN Size; 79438ebfecb6279417259db116d6b03cdcb03ecc6bblgao EFI_STRING Value; 79538ebfecb6279417259db116d6b03cdcb03ecc6bblgao UINTN ValueStrLen; 79638ebfecb6279417259db116d6b03cdcb03ecc6bblgao CHAR16 BackupChar; 79738ebfecb6279417259db116d6b03cdcb03ecc6bblgao CHAR16 *StrPointer; 79859aefb7e0dc811a3e66ae23c1730028365354361lgao BOOLEAN AllocatedRequest; 79938ebfecb6279417259db116d6b03cdcb03ecc6bblgao 80059aefb7e0dc811a3e66ae23c1730028365354361lgao if (Progress == NULL || Results == NULL) { 801ae79d2f9ec344703f379a557b873efc9bf70cd1elgao return EFI_INVALID_PARAMETER; 802ae79d2f9ec344703f379a557b873efc9bf70cd1elgao } 80384f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // 80484f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // Initialize the local variables. 80584f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // 806086cd2c8e932297641aba4986e3376b202365b5algao ConfigRequestHdr = NULL; 807086cd2c8e932297641aba4986e3376b202365b5algao ConfigRequest = NULL; 808086cd2c8e932297641aba4986e3376b202365b5algao Size = 0; 809086cd2c8e932297641aba4986e3376b202365b5algao *Progress = Request; 81059aefb7e0dc811a3e66ae23c1730028365354361lgao AllocatedRequest = FALSE; 81193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 81293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This); 81393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang HiiConfigRouting = PrivateData->HiiConfigRouting; 81493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 81593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 81684f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // Get Buffer Storage data from EFI variable. 81784f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // Try to get the current setting from variable. 81893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 81993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION); 82004da0b4a11fd128c08fb0192c02a142285f6fa69lgao Status = gRT->GetVariable ( 82104da0b4a11fd128c08fb0192c02a142285f6fa69lgao VariableName, 822c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 82304da0b4a11fd128c08fb0192c02a142285f6fa69lgao NULL, 82404da0b4a11fd128c08fb0192c02a142285f6fa69lgao &BufferSize, 82504da0b4a11fd128c08fb0192c02a142285f6fa69lgao &PrivateData->Configuration 82604da0b4a11fd128c08fb0192c02a142285f6fa69lgao ); 82704da0b4a11fd128c08fb0192c02a142285f6fa69lgao if (EFI_ERROR (Status)) { 828de482998ed157445fa9d812544b73c3bae702881lgao return EFI_NOT_FOUND; 82904da0b4a11fd128c08fb0192c02a142285f6fa69lgao } 830a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 8318d00a0f1955de7aa4b658009a36df5165d0a75beqwang if (Request == NULL) { 8328d00a0f1955de7aa4b658009a36df5165d0a75beqwang // 83384f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // Request is set to NULL, construct full request string. 8347e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao // 83584f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao 8367e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao // 837a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu // Allocate and fill a buffer large enough to hold the <ConfigHdr> template 83884f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator 83984f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // 840c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao ConfigRequestHdr = HiiConstructConfigHdr (&gDriverSampleFormSetGuid, VariableName, PrivateData->DriverHandle[0]); 84159aefb7e0dc811a3e66ae23c1730028365354361lgao Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); 84284f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao ConfigRequest = AllocateZeroPool (Size); 8431bd57b6e769eb060166e2b6b83b46235140ea536rsun ASSERT (ConfigRequest != NULL); 84459aefb7e0dc811a3e66ae23c1730028365354361lgao AllocatedRequest = TRUE; 845086cd2c8e932297641aba4986e3376b202365b5algao UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); 846086cd2c8e932297641aba4986e3376b202365b5algao FreePool (ConfigRequestHdr); 847ee31d1be529aa074bd5660d0be5cabe9893a11beydong ConfigRequestHdr = NULL; 84884f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao } else { 849de482998ed157445fa9d812544b73c3bae702881lgao // 850de482998ed157445fa9d812544b73c3bae702881lgao // Check routing data in <ConfigHdr>. 851de482998ed157445fa9d812544b73c3bae702881lgao // Note: if only one Storage is used, then this checking could be skipped. 852de482998ed157445fa9d812544b73c3bae702881lgao // 853c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao if (!HiiIsConfigHdrMatch (Request, &gDriverSampleFormSetGuid, NULL)) { 854de482998ed157445fa9d812544b73c3bae702881lgao return EFI_NOT_FOUND; 85584f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao } 85659aefb7e0dc811a3e66ae23c1730028365354361lgao // 85778c2b9a33478ee0cb7e39466fb12191dde56b210ydong // Check whether request for EFI Varstore. EFI varstore get data 85878c2b9a33478ee0cb7e39466fb12191dde56b210ydong // through hii database, not support in this path. 85978c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 860c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao if (HiiIsConfigHdrMatch(Request, &gDriverSampleFormSetGuid, MyEfiVar)) { 86178c2b9a33478ee0cb7e39466fb12191dde56b210ydong return EFI_UNSUPPORTED; 86278c2b9a33478ee0cb7e39466fb12191dde56b210ydong } 86378c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 86459aefb7e0dc811a3e66ae23c1730028365354361lgao // Set Request to the unified request string. 86559aefb7e0dc811a3e66ae23c1730028365354361lgao // 866de482998ed157445fa9d812544b73c3bae702881lgao ConfigRequest = Request; 86738ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 86859aefb7e0dc811a3e66ae23c1730028365354361lgao // Check whether Request includes Request Element. 86938ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 87038ebfecb6279417259db116d6b03cdcb03ecc6bblgao if (StrStr (Request, L"OFFSET") == NULL) { 87138ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 87259aefb7e0dc811a3e66ae23c1730028365354361lgao // Check Request Element does exist in Reques String 87338ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 87459aefb7e0dc811a3e66ae23c1730028365354361lgao StrPointer = StrStr (Request, L"PATH"); 87559aefb7e0dc811a3e66ae23c1730028365354361lgao if (StrPointer == NULL) { 87659aefb7e0dc811a3e66ae23c1730028365354361lgao return EFI_INVALID_PARAMETER; 87759aefb7e0dc811a3e66ae23c1730028365354361lgao } 87859aefb7e0dc811a3e66ae23c1730028365354361lgao if (StrStr (StrPointer, L"&") == NULL) { 87959aefb7e0dc811a3e66ae23c1730028365354361lgao Size = (StrLen (Request) + 32 + 1) * sizeof (CHAR16); 88059aefb7e0dc811a3e66ae23c1730028365354361lgao ConfigRequest = AllocateZeroPool (Size); 8811bd57b6e769eb060166e2b6b83b46235140ea536rsun ASSERT (ConfigRequest != NULL); 88259aefb7e0dc811a3e66ae23c1730028365354361lgao AllocatedRequest = TRUE; 88359aefb7e0dc811a3e66ae23c1730028365354361lgao UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", Request, (UINT64)BufferSize); 88438ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 88559aefb7e0dc811a3e66ae23c1730028365354361lgao } 88659aefb7e0dc811a3e66ae23c1730028365354361lgao } 88738ebfecb6279417259db116d6b03cdcb03ecc6bblgao 88859aefb7e0dc811a3e66ae23c1730028365354361lgao // 88959aefb7e0dc811a3e66ae23c1730028365354361lgao // Check if requesting Name/Value storage 89059aefb7e0dc811a3e66ae23c1730028365354361lgao // 89159aefb7e0dc811a3e66ae23c1730028365354361lgao if (StrStr (ConfigRequest, L"OFFSET") == NULL) { 89259aefb7e0dc811a3e66ae23c1730028365354361lgao // 89359aefb7e0dc811a3e66ae23c1730028365354361lgao // Update Name/Value storage Names 89459aefb7e0dc811a3e66ae23c1730028365354361lgao // 89559aefb7e0dc811a3e66ae23c1730028365354361lgao Status = LoadNameValueNames (PrivateData); 89659aefb7e0dc811a3e66ae23c1730028365354361lgao if (EFI_ERROR (Status)) { 89759aefb7e0dc811a3e66ae23c1730028365354361lgao return Status; 89859aefb7e0dc811a3e66ae23c1730028365354361lgao } 89938ebfecb6279417259db116d6b03cdcb03ecc6bblgao 90059aefb7e0dc811a3e66ae23c1730028365354361lgao // 90159aefb7e0dc811a3e66ae23c1730028365354361lgao // Allocate memory for <ConfigResp>, e.g. Name0=0x11, Name1=0x1234, Name2="ABCD" 90259aefb7e0dc811a3e66ae23c1730028365354361lgao // <Request> ::=<ConfigHdr>&Name0&Name1&Name2 90359aefb7e0dc811a3e66ae23c1730028365354361lgao // <ConfigResp>::=<ConfigHdr>&Name0=11&Name1=1234&Name2=0041004200430044 90459aefb7e0dc811a3e66ae23c1730028365354361lgao // 90559aefb7e0dc811a3e66ae23c1730028365354361lgao BufferSize = (StrLen (ConfigRequest) + 90659aefb7e0dc811a3e66ae23c1730028365354361lgao 1 + sizeof (PrivateData->Configuration.NameValueVar0) * 2 + 90759aefb7e0dc811a3e66ae23c1730028365354361lgao 1 + sizeof (PrivateData->Configuration.NameValueVar1) * 2 + 90859aefb7e0dc811a3e66ae23c1730028365354361lgao 1 + sizeof (PrivateData->Configuration.NameValueVar2) * 2 + 1) * sizeof (CHAR16); 90959aefb7e0dc811a3e66ae23c1730028365354361lgao *Results = AllocateZeroPool (BufferSize); 91059aefb7e0dc811a3e66ae23c1730028365354361lgao ASSERT (*Results != NULL); 9115ad66ec6925f1564137752be4d8656d462ebeaf2Dandan Bi StrCpyS (*Results, BufferSize / sizeof (CHAR16), ConfigRequest); 91259aefb7e0dc811a3e66ae23c1730028365354361lgao Value = *Results; 91338ebfecb6279417259db116d6b03cdcb03ecc6bblgao 91459aefb7e0dc811a3e66ae23c1730028365354361lgao // 91559aefb7e0dc811a3e66ae23c1730028365354361lgao // Append value of NameValueVar0, type is UINT8 91659aefb7e0dc811a3e66ae23c1730028365354361lgao // 91759aefb7e0dc811a3e66ae23c1730028365354361lgao if ((Value = StrStr (*Results, PrivateData->NameValueName[0])) != NULL) { 91859aefb7e0dc811a3e66ae23c1730028365354361lgao Value += StrLen (PrivateData->NameValueName[0]); 91959aefb7e0dc811a3e66ae23c1730028365354361lgao ValueStrLen = ((sizeof (PrivateData->Configuration.NameValueVar0) * 2) + 1); 92059aefb7e0dc811a3e66ae23c1730028365354361lgao CopyMem (Value + ValueStrLen, Value, StrSize (Value)); 92159aefb7e0dc811a3e66ae23c1730028365354361lgao 92259aefb7e0dc811a3e66ae23c1730028365354361lgao BackupChar = Value[ValueStrLen]; 92359aefb7e0dc811a3e66ae23c1730028365354361lgao *Value++ = L'='; 92459aefb7e0dc811a3e66ae23c1730028365354361lgao Value += UnicodeValueToString ( 92559aefb7e0dc811a3e66ae23c1730028365354361lgao Value, 92659aefb7e0dc811a3e66ae23c1730028365354361lgao PREFIX_ZERO | RADIX_HEX, 92759aefb7e0dc811a3e66ae23c1730028365354361lgao PrivateData->Configuration.NameValueVar0, 92859aefb7e0dc811a3e66ae23c1730028365354361lgao sizeof (PrivateData->Configuration.NameValueVar0) * 2 92959aefb7e0dc811a3e66ae23c1730028365354361lgao ); 93059aefb7e0dc811a3e66ae23c1730028365354361lgao *Value = BackupChar; 93159aefb7e0dc811a3e66ae23c1730028365354361lgao } 93259aefb7e0dc811a3e66ae23c1730028365354361lgao 93359aefb7e0dc811a3e66ae23c1730028365354361lgao // 93459aefb7e0dc811a3e66ae23c1730028365354361lgao // Append value of NameValueVar1, type is UINT16 93559aefb7e0dc811a3e66ae23c1730028365354361lgao // 93659aefb7e0dc811a3e66ae23c1730028365354361lgao if ((Value = StrStr (*Results, PrivateData->NameValueName[1])) != NULL) { 93759aefb7e0dc811a3e66ae23c1730028365354361lgao Value += StrLen (PrivateData->NameValueName[1]); 93859aefb7e0dc811a3e66ae23c1730028365354361lgao ValueStrLen = ((sizeof (PrivateData->Configuration.NameValueVar1) * 2) + 1); 93959aefb7e0dc811a3e66ae23c1730028365354361lgao CopyMem (Value + ValueStrLen, Value, StrSize (Value)); 94059aefb7e0dc811a3e66ae23c1730028365354361lgao 94159aefb7e0dc811a3e66ae23c1730028365354361lgao BackupChar = Value[ValueStrLen]; 94259aefb7e0dc811a3e66ae23c1730028365354361lgao *Value++ = L'='; 94359aefb7e0dc811a3e66ae23c1730028365354361lgao Value += UnicodeValueToString ( 94459aefb7e0dc811a3e66ae23c1730028365354361lgao Value, 94559aefb7e0dc811a3e66ae23c1730028365354361lgao PREFIX_ZERO | RADIX_HEX, 94659aefb7e0dc811a3e66ae23c1730028365354361lgao PrivateData->Configuration.NameValueVar1, 94759aefb7e0dc811a3e66ae23c1730028365354361lgao sizeof (PrivateData->Configuration.NameValueVar1) * 2 94859aefb7e0dc811a3e66ae23c1730028365354361lgao ); 94959aefb7e0dc811a3e66ae23c1730028365354361lgao *Value = BackupChar; 95059aefb7e0dc811a3e66ae23c1730028365354361lgao } 95159aefb7e0dc811a3e66ae23c1730028365354361lgao 95259aefb7e0dc811a3e66ae23c1730028365354361lgao // 95359aefb7e0dc811a3e66ae23c1730028365354361lgao // Append value of NameValueVar2, type is CHAR16 * 95459aefb7e0dc811a3e66ae23c1730028365354361lgao // 95559aefb7e0dc811a3e66ae23c1730028365354361lgao if ((Value = StrStr (*Results, PrivateData->NameValueName[2])) != NULL) { 95659aefb7e0dc811a3e66ae23c1730028365354361lgao Value += StrLen (PrivateData->NameValueName[2]); 95759aefb7e0dc811a3e66ae23c1730028365354361lgao ValueStrLen = StrLen (PrivateData->Configuration.NameValueVar2) * 4 + 1; 95859aefb7e0dc811a3e66ae23c1730028365354361lgao CopyMem (Value + ValueStrLen, Value, StrSize (Value)); 95938ebfecb6279417259db116d6b03cdcb03ecc6bblgao 96059aefb7e0dc811a3e66ae23c1730028365354361lgao *Value++ = L'='; 96138ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 96259aefb7e0dc811a3e66ae23c1730028365354361lgao // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044" 96338ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 96459aefb7e0dc811a3e66ae23c1730028365354361lgao StrPointer = (CHAR16 *) PrivateData->Configuration.NameValueVar2; 96559aefb7e0dc811a3e66ae23c1730028365354361lgao for (; *StrPointer != L'\0'; StrPointer++) { 96659aefb7e0dc811a3e66ae23c1730028365354361lgao Value += UnicodeValueToString (Value, PREFIX_ZERO | RADIX_HEX, *StrPointer, 4); 96738ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 96838ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 96959aefb7e0dc811a3e66ae23c1730028365354361lgao 97059aefb7e0dc811a3e66ae23c1730028365354361lgao Status = EFI_SUCCESS; 97159aefb7e0dc811a3e66ae23c1730028365354361lgao } else { 97259aefb7e0dc811a3e66ae23c1730028365354361lgao // 97359aefb7e0dc811a3e66ae23c1730028365354361lgao // Convert buffer data to <ConfigResp> by helper function BlockToConfig() 97459aefb7e0dc811a3e66ae23c1730028365354361lgao // 97559aefb7e0dc811a3e66ae23c1730028365354361lgao Status = HiiConfigRouting->BlockToConfig ( 97659aefb7e0dc811a3e66ae23c1730028365354361lgao HiiConfigRouting, 97759aefb7e0dc811a3e66ae23c1730028365354361lgao ConfigRequest, 97859aefb7e0dc811a3e66ae23c1730028365354361lgao (UINT8 *) &PrivateData->Configuration, 97959aefb7e0dc811a3e66ae23c1730028365354361lgao BufferSize, 98059aefb7e0dc811a3e66ae23c1730028365354361lgao Results, 98159aefb7e0dc811a3e66ae23c1730028365354361lgao Progress 98259aefb7e0dc811a3e66ae23c1730028365354361lgao ); 98333d41385e32425a25da13bdfbfb81f30f226ec18ydong if (!EFI_ERROR (Status)) { 984c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao ConfigRequestHdr = HiiConstructConfigHdr (&gDriverSampleFormSetGuid, VariableName, PrivateData->DriverHandle[0]); 98533d41385e32425a25da13bdfbfb81f30f226ec18ydong AppendAltCfgString(Results, ConfigRequestHdr); 98633d41385e32425a25da13bdfbfb81f30f226ec18ydong } 9878d00a0f1955de7aa4b658009a36df5165d0a75beqwang } 9888d00a0f1955de7aa4b658009a36df5165d0a75beqwang 98993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 99059aefb7e0dc811a3e66ae23c1730028365354361lgao // Free the allocated config request string. 99193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 99259aefb7e0dc811a3e66ae23c1730028365354361lgao if (AllocatedRequest) { 99384f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao FreePool (ConfigRequest); 99459aefb7e0dc811a3e66ae23c1730028365354361lgao } 995ee31d1be529aa074bd5660d0be5cabe9893a11beydong 996ee31d1be529aa074bd5660d0be5cabe9893a11beydong if (ConfigRequestHdr != NULL) { 997ee31d1be529aa074bd5660d0be5cabe9893a11beydong FreePool (ConfigRequestHdr); 998ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 99959aefb7e0dc811a3e66ae23c1730028365354361lgao // 100059aefb7e0dc811a3e66ae23c1730028365354361lgao // Set Progress string to the original request string. 100159aefb7e0dc811a3e66ae23c1730028365354361lgao // 100259aefb7e0dc811a3e66ae23c1730028365354361lgao if (Request == NULL) { 10031f1cb2f2166f48a63b54dfc40f43c1a998e00a37lgao *Progress = NULL; 100459aefb7e0dc811a3e66ae23c1730028365354361lgao } else if (StrStr (Request, L"OFFSET") == NULL) { 100559aefb7e0dc811a3e66ae23c1730028365354361lgao *Progress = Request + StrLen (Request); 100684f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao } 100784f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao 100893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 100993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang} 101093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 101193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 101293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang/** 101393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang This function processes the results of changes in configuration. 101493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 101593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. 101693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param Configuration A null-terminated Unicode string in <ConfigResp> 101793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang format. 101893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param Progress A pointer to a string filled in with the offset of 101993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang the most recent '&' before the first failing 102093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang name/value pair (or the beginning of the string if 102193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang the failure is in the first name/value pair) or 102293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang the terminating NULL if all was successful. 102393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 102493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_SUCCESS The Results is processed successfully. 102593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_INVALID_PARAMETER Configuration is NULL. 102693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_NOT_FOUND Routing data doesn't match any storage in this 102793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang driver. 102893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 102993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang**/ 103093e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFI_STATUS 103193e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFIAPI 103293e3992d1ea50fb30c48f498d257d4e66252dd9bqwangRouteConfig ( 103393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 103493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN CONST EFI_STRING Configuration, 103593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang OUT EFI_STRING *Progress 103693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ) 103793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang{ 103893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_STATUS Status; 103993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINTN BufferSize; 104093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang DRIVER_SAMPLE_PRIVATE_DATA *PrivateData; 104193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; 104238ebfecb6279417259db116d6b03cdcb03ecc6bblgao CHAR16 *Value; 104338ebfecb6279417259db116d6b03cdcb03ecc6bblgao CHAR16 *StrPtr; 104438ebfecb6279417259db116d6b03cdcb03ecc6bblgao CHAR16 TemStr[5]; 104538ebfecb6279417259db116d6b03cdcb03ecc6bblgao UINT8 *DataBuffer; 104638ebfecb6279417259db116d6b03cdcb03ecc6bblgao UINT8 DigitUint8; 104738ebfecb6279417259db116d6b03cdcb03ecc6bblgao UINTN Index; 104838ebfecb6279417259db116d6b03cdcb03ecc6bblgao CHAR16 *StrBuffer; 104993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 1050f5e9ff82b0617a91114a6a04a88cc32db47d87belgao if (Configuration == NULL || Progress == NULL) { 10518d00a0f1955de7aa4b658009a36df5165d0a75beqwang return EFI_INVALID_PARAMETER; 10528d00a0f1955de7aa4b658009a36df5165d0a75beqwang } 10538d00a0f1955de7aa4b658009a36df5165d0a75beqwang 105493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This); 105593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang HiiConfigRouting = PrivateData->HiiConfigRouting; 1056f5e9ff82b0617a91114a6a04a88cc32db47d87belgao *Progress = Configuration; 105793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 105884f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // 10598d00a0f1955de7aa4b658009a36df5165d0a75beqwang // Check routing data in <ConfigHdr>. 10608d00a0f1955de7aa4b658009a36df5165d0a75beqwang // Note: if only one Storage is used, then this checking could be skipped. 10618d00a0f1955de7aa4b658009a36df5165d0a75beqwang // 1062c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao if (!HiiIsConfigHdrMatch (Configuration, &gDriverSampleFormSetGuid, NULL)) { 10638d00a0f1955de7aa4b658009a36df5165d0a75beqwang return EFI_NOT_FOUND; 10648d00a0f1955de7aa4b658009a36df5165d0a75beqwang } 10658d00a0f1955de7aa4b658009a36df5165d0a75beqwang 106693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 106778c2b9a33478ee0cb7e39466fb12191dde56b210ydong // Check whether request for EFI Varstore. EFI varstore get data 106878c2b9a33478ee0cb7e39466fb12191dde56b210ydong // through hii database, not support in this path. 106978c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 1070c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao if (HiiIsConfigHdrMatch(Configuration, &gDriverSampleFormSetGuid, MyEfiVar)) { 107178c2b9a33478ee0cb7e39466fb12191dde56b210ydong return EFI_UNSUPPORTED; 107278c2b9a33478ee0cb7e39466fb12191dde56b210ydong } 107378c2b9a33478ee0cb7e39466fb12191dde56b210ydong 107478c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 107593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Get Buffer Storage data from EFI variable 107693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 107793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION); 107804da0b4a11fd128c08fb0192c02a142285f6fa69lgao Status = gRT->GetVariable ( 107904da0b4a11fd128c08fb0192c02a142285f6fa69lgao VariableName, 1080c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 108104da0b4a11fd128c08fb0192c02a142285f6fa69lgao NULL, 108204da0b4a11fd128c08fb0192c02a142285f6fa69lgao &BufferSize, 108304da0b4a11fd128c08fb0192c02a142285f6fa69lgao &PrivateData->Configuration 108404da0b4a11fd128c08fb0192c02a142285f6fa69lgao ); 108504da0b4a11fd128c08fb0192c02a142285f6fa69lgao if (EFI_ERROR (Status)) { 108604da0b4a11fd128c08fb0192c02a142285f6fa69lgao return Status; 108704da0b4a11fd128c08fb0192c02a142285f6fa69lgao } 108893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 108993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 109038ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Check if configuring Name/Value storage 109138ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 109238ebfecb6279417259db116d6b03cdcb03ecc6bblgao if (StrStr (Configuration, L"OFFSET") == NULL) { 109338ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 109438ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Update Name/Value storage Names 109538ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 109638ebfecb6279417259db116d6b03cdcb03ecc6bblgao Status = LoadNameValueNames (PrivateData); 109738ebfecb6279417259db116d6b03cdcb03ecc6bblgao if (EFI_ERROR (Status)) { 109838ebfecb6279417259db116d6b03cdcb03ecc6bblgao return Status; 109938ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 110038ebfecb6279417259db116d6b03cdcb03ecc6bblgao 110138ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 110238ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Convert value for NameValueVar0 110338ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 110438ebfecb6279417259db116d6b03cdcb03ecc6bblgao if ((Value = StrStr (Configuration, PrivateData->NameValueName[0])) != NULL) { 110538ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 110638ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Skip "Name=" 110738ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 110838ebfecb6279417259db116d6b03cdcb03ecc6bblgao Value += StrLen (PrivateData->NameValueName[0]); 110938ebfecb6279417259db116d6b03cdcb03ecc6bblgao Value++; 111038ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 111138ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Get Value String 111238ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 111338ebfecb6279417259db116d6b03cdcb03ecc6bblgao StrPtr = StrStr (Value, L"&"); 111438ebfecb6279417259db116d6b03cdcb03ecc6bblgao if (StrPtr == NULL) { 111538ebfecb6279417259db116d6b03cdcb03ecc6bblgao StrPtr = Value + StrLen (Value); 111638ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 111738ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 111838ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Convert Value to Buffer data 111938ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 112038ebfecb6279417259db116d6b03cdcb03ecc6bblgao DataBuffer = (UINT8 *) &PrivateData->Configuration.NameValueVar0; 112138ebfecb6279417259db116d6b03cdcb03ecc6bblgao ZeroMem (TemStr, sizeof (TemStr)); 112238ebfecb6279417259db116d6b03cdcb03ecc6bblgao for (Index = 0, StrPtr --; StrPtr >= Value; StrPtr --, Index ++) { 112338ebfecb6279417259db116d6b03cdcb03ecc6bblgao TemStr[0] = *StrPtr; 112438ebfecb6279417259db116d6b03cdcb03ecc6bblgao DigitUint8 = (UINT8) StrHexToUint64 (TemStr); 112538ebfecb6279417259db116d6b03cdcb03ecc6bblgao if ((Index & 1) == 0) { 112638ebfecb6279417259db116d6b03cdcb03ecc6bblgao DataBuffer [Index/2] = DigitUint8; 112738ebfecb6279417259db116d6b03cdcb03ecc6bblgao } else { 112838ebfecb6279417259db116d6b03cdcb03ecc6bblgao DataBuffer [Index/2] = (UINT8) ((UINT8) (DigitUint8 << 4) + DataBuffer [Index/2]); 112938ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 113038ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 113138ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 113238ebfecb6279417259db116d6b03cdcb03ecc6bblgao 113338ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 113438ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Convert value for NameValueVar1 113538ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 113638ebfecb6279417259db116d6b03cdcb03ecc6bblgao if ((Value = StrStr (Configuration, PrivateData->NameValueName[1])) != NULL) { 113738ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 113838ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Skip "Name=" 113938ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 114038ebfecb6279417259db116d6b03cdcb03ecc6bblgao Value += StrLen (PrivateData->NameValueName[1]); 114138ebfecb6279417259db116d6b03cdcb03ecc6bblgao Value++; 114238ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 114338ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Get Value String 114438ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 114538ebfecb6279417259db116d6b03cdcb03ecc6bblgao StrPtr = StrStr (Value, L"&"); 114638ebfecb6279417259db116d6b03cdcb03ecc6bblgao if (StrPtr == NULL) { 114738ebfecb6279417259db116d6b03cdcb03ecc6bblgao StrPtr = Value + StrLen (Value); 114838ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 114938ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 115038ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Convert Value to Buffer data 115138ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 115238ebfecb6279417259db116d6b03cdcb03ecc6bblgao DataBuffer = (UINT8 *) &PrivateData->Configuration.NameValueVar1; 115338ebfecb6279417259db116d6b03cdcb03ecc6bblgao ZeroMem (TemStr, sizeof (TemStr)); 115438ebfecb6279417259db116d6b03cdcb03ecc6bblgao for (Index = 0, StrPtr --; StrPtr >= Value; StrPtr --, Index ++) { 115538ebfecb6279417259db116d6b03cdcb03ecc6bblgao TemStr[0] = *StrPtr; 115638ebfecb6279417259db116d6b03cdcb03ecc6bblgao DigitUint8 = (UINT8) StrHexToUint64 (TemStr); 115738ebfecb6279417259db116d6b03cdcb03ecc6bblgao if ((Index & 1) == 0) { 115838ebfecb6279417259db116d6b03cdcb03ecc6bblgao DataBuffer [Index/2] = DigitUint8; 115938ebfecb6279417259db116d6b03cdcb03ecc6bblgao } else { 116038ebfecb6279417259db116d6b03cdcb03ecc6bblgao DataBuffer [Index/2] = (UINT8) ((UINT8) (DigitUint8 << 4) + DataBuffer [Index/2]); 116138ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 116238ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 116338ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 116438ebfecb6279417259db116d6b03cdcb03ecc6bblgao 116538ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 116638ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Convert value for NameValueVar2 116738ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 116838ebfecb6279417259db116d6b03cdcb03ecc6bblgao if ((Value = StrStr (Configuration, PrivateData->NameValueName[2])) != NULL) { 116938ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 117038ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Skip "Name=" 117138ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 117238ebfecb6279417259db116d6b03cdcb03ecc6bblgao Value += StrLen (PrivateData->NameValueName[2]); 117338ebfecb6279417259db116d6b03cdcb03ecc6bblgao Value++; 117438ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 117538ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Get Value String 117638ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 117738ebfecb6279417259db116d6b03cdcb03ecc6bblgao StrPtr = StrStr (Value, L"&"); 117838ebfecb6279417259db116d6b03cdcb03ecc6bblgao if (StrPtr == NULL) { 117938ebfecb6279417259db116d6b03cdcb03ecc6bblgao StrPtr = Value + StrLen (Value); 118038ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 118138ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 118238ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD" 118338ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 118438ebfecb6279417259db116d6b03cdcb03ecc6bblgao StrBuffer = (CHAR16 *) PrivateData->Configuration.NameValueVar2; 118538ebfecb6279417259db116d6b03cdcb03ecc6bblgao ZeroMem (TemStr, sizeof (TemStr)); 118638ebfecb6279417259db116d6b03cdcb03ecc6bblgao while (Value < StrPtr) { 11875ad66ec6925f1564137752be4d8656d462ebeaf2Dandan Bi StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), Value, 4); 118838ebfecb6279417259db116d6b03cdcb03ecc6bblgao *(StrBuffer++) = (CHAR16) StrHexToUint64 (TemStr); 118938ebfecb6279417259db116d6b03cdcb03ecc6bblgao Value += 4; 119038ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 119138ebfecb6279417259db116d6b03cdcb03ecc6bblgao *StrBuffer = L'\0'; 119238ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 119338ebfecb6279417259db116d6b03cdcb03ecc6bblgao 119438ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 119538ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Store Buffer Storage back to EFI variable 119638ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 119738ebfecb6279417259db116d6b03cdcb03ecc6bblgao Status = gRT->SetVariable( 119838ebfecb6279417259db116d6b03cdcb03ecc6bblgao VariableName, 1199c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 120038ebfecb6279417259db116d6b03cdcb03ecc6bblgao EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 120138ebfecb6279417259db116d6b03cdcb03ecc6bblgao sizeof (DRIVER_SAMPLE_CONFIGURATION), 120238ebfecb6279417259db116d6b03cdcb03ecc6bblgao &PrivateData->Configuration 120338ebfecb6279417259db116d6b03cdcb03ecc6bblgao ); 120438ebfecb6279417259db116d6b03cdcb03ecc6bblgao 120538ebfecb6279417259db116d6b03cdcb03ecc6bblgao return Status; 120638ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 120738ebfecb6279417259db116d6b03cdcb03ecc6bblgao 120838ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 120993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Convert <ConfigResp> to buffer data by helper function ConfigToBlock() 121093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 121193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION); 121293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = HiiConfigRouting->ConfigToBlock ( 121393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang HiiConfigRouting, 121493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Configuration, 121593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang (UINT8 *) &PrivateData->Configuration, 121693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &BufferSize, 121793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Progress 121893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ); 121993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (EFI_ERROR (Status)) { 122093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 122193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 122293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 122393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 122493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Store Buffer Storage back to EFI variable 122593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 122693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = gRT->SetVariable( 122793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang VariableName, 1228c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 122993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 123093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang sizeof (DRIVER_SAMPLE_CONFIGURATION), 123193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &PrivateData->Configuration 123293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ); 123393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 123493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 123593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang} 123693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 123793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 123893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang/** 123993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang This function processes the results of changes in configuration. 124093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 124193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. 124293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param Action Specifies the type of action taken by the browser. 124393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param QuestionId A unique value which is sent to the original 124493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang exporting driver so that it can identify the type 124593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang of data to expect. 124693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param Type The type of value for the question. 124793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param Value A pointer to the data being sent to the original 124893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang exporting driver. 124993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @param ActionRequest On return, points to the action requested by the 125093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang callback function. 125193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 125293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_SUCCESS The callback successfully handled the action. 125393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the 125493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang variable and its data. 125593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_DEVICE_ERROR The variable could not be saved. 125693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang @retval EFI_UNSUPPORTED The specified Action is not supported by the 125793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang callback. 125893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 125993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang**/ 126093e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFI_STATUS 126193e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFIAPI 126293e3992d1ea50fb30c48f498d257d4e66252dd9bqwangDriverCallback ( 126393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 126493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN EFI_BROWSER_ACTION Action, 126593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN EFI_QUESTION_ID QuestionId, 126693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN UINT8 Type, 126793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN EFI_IFR_TYPE_VALUE *Value, 126893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest 126993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ) 127093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang{ 127193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang DRIVER_SAMPLE_PRIVATE_DATA *PrivateData; 127293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_STATUS Status; 12737e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao VOID *StartOpCodeHandle; 12747e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao VOID *OptionsOpCodeHandle; 12757e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao EFI_IFR_GUID_LABEL *StartLabel; 12767e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao VOID *EndOpCodeHandle; 12777e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao EFI_IFR_GUID_LABEL *EndLabel; 1278a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu EFI_INPUT_KEY Key; 1279a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu DRIVER_SAMPLE_CONFIGURATION *Configuration; 128078c2b9a33478ee0cb7e39466fb12191dde56b210ydong MY_EFI_VARSTORE_DATA *EfiData; 1281211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EFI_FORM_ID FormId; 128234326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong EFI_STRING Progress; 128334326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong EFI_STRING Results; 128434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong UINT32 ProgressErr; 128534326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong CHAR16 *TmpStr; 12864a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 12874a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong if (((Value == NULL) && (Action != EFI_BROWSER_ACTION_FORM_OPEN) && (Action != EFI_BROWSER_ACTION_FORM_CLOSE))|| 12884a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong (ActionRequest == NULL)) { 12894a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong return EFI_INVALID_PARAMETER; 12904a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 1291a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 1292a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 1293211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong FormId = 0; 129434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong ProgressErr = 0; 12954a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong Status = EFI_SUCCESS; 12964a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This); 12974a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 12984a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong switch (Action) { 12994a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong case EFI_BROWSER_ACTION_FORM_OPEN: 13004a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong { 13014a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong if (QuestionId == 0x1234) { 13024a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 13034a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Sample CallBack for UEFI FORM_OPEN action: 13044a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Add Save action into Form 3 when Form 1 is opened. 13054a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // This will be done only in FORM_OPEN CallBack of question with ID 0x1234 from Form 1. 13064a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 13074a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This); 13084a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 13094a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 13104a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Initialize the container for dynamic opcodes 13114a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 13124a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle = HiiAllocateOpCodeHandle (); 13134a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ASSERT (StartOpCodeHandle != NULL); 13144a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 13154a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 13164a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Create Hii Extend Label OpCode as the start opcode 13174a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 13184a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); 13194a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; 13204a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartLabel->Number = LABEL_UPDATE2; 13214a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 13224a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateActionOpCode ( 13234a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, // Container for dynamic created opcodes 13244a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x1238, // Question ID 13254a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_SAVE_TEXT), // Prompt text 13264a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_SAVE_TEXT), // Help text 13274a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_IFR_FLAG_CALLBACK, // Question flag 13284a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0 // Action String ID 13294a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 13304a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 13314a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiUpdateForm ( 13324a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong PrivateData->HiiHandle[0], // HII handle 1333c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, // Formset GUID 13344a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x3, // Form ID 13354a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, // Label for where to insert opcodes 13364a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong NULL // Insert data 13374a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 13384a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 13394a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiFreeOpCodeHandle (StartOpCodeHandle); 13404a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 1341211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 1342211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong if (QuestionId == 0x1247) { 1343211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = InternalStartMonitor (); 1344211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ASSERT_EFI_ERROR (Status); 1345211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong } 13464a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 13474a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong break; 13484a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 13494a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong case EFI_BROWSER_ACTION_FORM_CLOSE: 13504a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong { 13514a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong if (QuestionId == 0x5678) { 13524a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 13534a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Sample CallBack for UEFI FORM_CLOSE action: 13544a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Show up a pop-up to specify Form 3 will be closed when exit Form 3. 13554a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 13564a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong do { 13574a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong CreatePopUp ( 13584a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 13594a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong &Key, 13604a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong L"", 13614a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong L"You are going to leave third Form!", 13624a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong L"Press ESC or ENTER to continue ...", 13634a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong L"", 13644a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong NULL 13654a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 13664a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN)); 13674a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 1368211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 1369211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong if (QuestionId == 0x1247) { 1370211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = InternalStopMonitor (); 1371211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ASSERT_EFI_ERROR (Status); 1372211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong } 13734a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 13744a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong break; 13754a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 13764a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong case EFI_BROWSER_ACTION_RETRIEVE: 13774a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong { 137840ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi switch (QuestionId ) { 137940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi case 0x1248: 138040ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi if (Type != EFI_IFR_TYPE_REF) { 138140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi return EFI_INVALID_PARAMETER; 138240ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi } 138340ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi Value->ref.FormId = 0x3; 138440ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi break; 138540ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 138640ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi case 0x5678: 138740ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi case 0x1247: 138840ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 138940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // We will reach here once the Question is refreshed 139040ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 139140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 139240ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 139340ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // Initialize the container for dynamic opcodes 139440ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 139540ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi StartOpCodeHandle = HiiAllocateOpCodeHandle (); 139640ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi ASSERT (StartOpCodeHandle != NULL); 139740ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 139840ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 139940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // Create Hii Extend Label OpCode as the start opcode 140040ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 140140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); 140240ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; 140340ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi if (QuestionId == 0x5678) { 140440ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi StartLabel->Number = LABEL_UPDATE2; 140540ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi FormId = 0x03; 140640ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi PrivateData->Configuration.DynamicRefresh++; 140740ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi } else if (QuestionId == 0x1247 ) { 140840ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi StartLabel->Number = LABEL_UPDATE3; 140940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi FormId = 0x06; 141040ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi PrivateData->Configuration.RefreshGuidCount++; 141140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi } 141240ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 141340ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi HiiCreateActionOpCode ( 141440ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi StartOpCodeHandle, // Container for dynamic created opcodes 141540ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 0x1237, // Question ID 141640ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi STRING_TOKEN(STR_EXIT_TEXT), // Prompt text 141740ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi STRING_TOKEN(STR_EXIT_TEXT), // Help text 141840ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi EFI_IFR_FLAG_CALLBACK, // Question flag 141940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 0 // Action String ID 142040ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi ); 142140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 142240ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi HiiUpdateForm ( 142340ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi PrivateData->HiiHandle[0], // HII handle 142440ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi &gDriverSampleFormSetGuid, // Formset GUID 142540ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi FormId, // Form ID 142640ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi StartOpCodeHandle, // Label for where to insert opcodes 142740ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi NULL // Insert data 142840ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi ); 142940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 143040ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi HiiFreeOpCodeHandle (StartOpCodeHandle); 143140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 143240ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 143340ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // Refresh the Question value 143440ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 143540ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi Status = gRT->SetVariable( 143640ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi VariableName, 143740ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi &gDriverSampleFormSetGuid, 143840ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 143940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi sizeof (DRIVER_SAMPLE_CONFIGURATION), 144040ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi &PrivateData->Configuration 144140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi ); 144240ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi 144340ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi if (QuestionId == 0x5678) { 144440ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 144540ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // Update uncommitted data of Browser 144640ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi // 144740ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi EfiData = AllocateZeroPool (sizeof (MY_EFI_VARSTORE_DATA)); 144840ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi ASSERT (EfiData != NULL); 144940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi if (HiiGetBrowserData (&gDriverSampleFormSetGuid, MyEfiVar, sizeof (MY_EFI_VARSTORE_DATA), (UINT8 *) EfiData)) { 145040ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi EfiData->Field8 = 111; 145140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi HiiSetBrowserData ( 145240ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi &gDriverSampleFormSetGuid, 145340ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi MyEfiVar, 145440ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi sizeof (MY_EFI_VARSTORE_DATA), 145540ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi (UINT8 *) EfiData, 145640ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi NULL 145740ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi ); 145878c2b9a33478ee0cb7e39466fb12191dde56b210ydong } 145940ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi FreePool (EfiData); 146078c2b9a33478ee0cb7e39466fb12191dde56b210ydong } 146140ffc3b9f7ff2821ebfcc5361b3fb2be648c64c5Dandan Bi break; 14624a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 14634a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 14644a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong break; 14654a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 1466ee31d1be529aa074bd5660d0be5cabe9893a11beydong case EFI_BROWSER_ACTION_DEFAULT_STANDARD: 1467ee31d1be529aa074bd5660d0be5cabe9893a11beydong { 1468ee31d1be529aa074bd5660d0be5cabe9893a11beydong switch (QuestionId) { 1469ee31d1be529aa074bd5660d0be5cabe9893a11beydong case 0x1240: 1470ee31d1be529aa074bd5660d0be5cabe9893a11beydong Value->u8 = DEFAULT_CLASS_STANDARD_VALUE; 1471ee31d1be529aa074bd5660d0be5cabe9893a11beydong break; 1472ee31d1be529aa074bd5660d0be5cabe9893a11beydong 1473ee31d1be529aa074bd5660d0be5cabe9893a11beydong default: 1474ee31d1be529aa074bd5660d0be5cabe9893a11beydong Status = EFI_UNSUPPORTED; 1475ee31d1be529aa074bd5660d0be5cabe9893a11beydong break; 1476ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 1477ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 1478ee31d1be529aa074bd5660d0be5cabe9893a11beydong break; 1479ee31d1be529aa074bd5660d0be5cabe9893a11beydong 1480ee31d1be529aa074bd5660d0be5cabe9893a11beydong case EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING: 1481ee31d1be529aa074bd5660d0be5cabe9893a11beydong { 1482ee31d1be529aa074bd5660d0be5cabe9893a11beydong switch (QuestionId) { 1483ee31d1be529aa074bd5660d0be5cabe9893a11beydong case 0x1240: 1484ee31d1be529aa074bd5660d0be5cabe9893a11beydong Value->u8 = DEFAULT_CLASS_MANUFACTURING_VALUE; 1485ee31d1be529aa074bd5660d0be5cabe9893a11beydong break; 1486ee31d1be529aa074bd5660d0be5cabe9893a11beydong 1487ee31d1be529aa074bd5660d0be5cabe9893a11beydong default: 1488ee31d1be529aa074bd5660d0be5cabe9893a11beydong Status = EFI_UNSUPPORTED; 1489ee31d1be529aa074bd5660d0be5cabe9893a11beydong break; 1490ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 1491ee31d1be529aa074bd5660d0be5cabe9893a11beydong } 1492ee31d1be529aa074bd5660d0be5cabe9893a11beydong break; 1493ee31d1be529aa074bd5660d0be5cabe9893a11beydong 14944a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong case EFI_BROWSER_ACTION_CHANGING: 14954a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong { 14964a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong switch (QuestionId) { 149778c2b9a33478ee0cb7e39466fb12191dde56b210ydong case 0x1249: 149878c2b9a33478ee0cb7e39466fb12191dde56b210ydong { 149978c2b9a33478ee0cb7e39466fb12191dde56b210ydong if (Type != EFI_IFR_TYPE_REF) { 150078c2b9a33478ee0cb7e39466fb12191dde56b210ydong return EFI_INVALID_PARAMETER; 150178c2b9a33478ee0cb7e39466fb12191dde56b210ydong } 150278c2b9a33478ee0cb7e39466fb12191dde56b210ydong 150378c2b9a33478ee0cb7e39466fb12191dde56b210ydong Value->ref.FormId = 0x1234; 150478c2b9a33478ee0cb7e39466fb12191dde56b210ydong } 150578c2b9a33478ee0cb7e39466fb12191dde56b210ydong break; 15064a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong case 0x1234: 15075adb8db71e333069509269f832b356adab0678c0lgao // 15085adb8db71e333069509269f832b356adab0678c0lgao // Initialize the container for dynamic opcodes 15095adb8db71e333069509269f832b356adab0678c0lgao // 15105adb8db71e333069509269f832b356adab0678c0lgao StartOpCodeHandle = HiiAllocateOpCodeHandle (); 15115adb8db71e333069509269f832b356adab0678c0lgao ASSERT (StartOpCodeHandle != NULL); 1512a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 15134a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EndOpCodeHandle = HiiAllocateOpCodeHandle (); 15144a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ASSERT (EndOpCodeHandle != NULL); 15154a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 15165adb8db71e333069509269f832b356adab0678c0lgao // 15175adb8db71e333069509269f832b356adab0678c0lgao // Create Hii Extend Label OpCode as the start opcode 15185adb8db71e333069509269f832b356adab0678c0lgao // 15195adb8db71e333069509269f832b356adab0678c0lgao StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); 15205adb8db71e333069509269f832b356adab0678c0lgao StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; 15214a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartLabel->Number = LABEL_UPDATE1; 15224a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 15234a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 15244a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Create Hii Extend Label OpCode as the end opcode 15254a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 15264a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); 15274a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; 15284a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EndLabel->Number = LABEL_END; 15295adb8db71e333069509269f832b356adab0678c0lgao 15305adb8db71e333069509269f832b356adab0678c0lgao HiiCreateActionOpCode ( 15315adb8db71e333069509269f832b356adab0678c0lgao StartOpCodeHandle, // Container for dynamic created opcodes 15324a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x1237, // Question ID 15334a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_EXIT_TEXT), // Prompt text 15344a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_EXIT_TEXT), // Help text 15355adb8db71e333069509269f832b356adab0678c0lgao EFI_IFR_FLAG_CALLBACK, // Question flag 15365adb8db71e333069509269f832b356adab0678c0lgao 0 // Action String ID 1537a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu ); 1538a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 15394a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 15404a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Create Option OpCode 15414a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 15424a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong OptionsOpCodeHandle = HiiAllocateOpCodeHandle (); 15434a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ASSERT (OptionsOpCodeHandle != NULL); 15444a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 15454a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateOneOfOptionOpCode ( 15464a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong OptionsOpCodeHandle, 15474a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN (STR_BOOT_OPTION1), 15484a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0, 15494a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_IFR_NUMERIC_SIZE_1, 15504a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 1 15515adb8db71e333069509269f832b356adab0678c0lgao ); 15525adb8db71e333069509269f832b356adab0678c0lgao 15534a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateOneOfOptionOpCode ( 15544a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong OptionsOpCodeHandle, 15554a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN (STR_BOOT_OPTION2), 15564a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0, 15574a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_IFR_NUMERIC_SIZE_1, 15584a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 2 15594a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 15604a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 15614a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 15624a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Prepare initial value for the dynamic created oneof Question 15634a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 15644a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong PrivateData->Configuration.DynamicOneof = 2; 15654a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong Status = gRT->SetVariable( 15664a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong VariableName, 1567c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 15684a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 15694a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong sizeof (DRIVER_SAMPLE_CONFIGURATION), 15704a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong &PrivateData->Configuration 15714a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 1572a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 15735adb8db71e333069509269f832b356adab0678c0lgao // 15744a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Set initial vlaue of dynamic created oneof Question in Form Browser 15755adb8db71e333069509269f832b356adab0678c0lgao // 15764a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_CONFIGURATION)); 15774a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ASSERT (Configuration != NULL); 1578c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao if (HiiGetBrowserData (&gDriverSampleFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION), (UINT8 *) Configuration)) { 15794a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong Configuration->DynamicOneof = 2; 15804a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 15814a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 15824a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Update uncommitted data of Browser 15834a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 15844a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiSetBrowserData ( 1585c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 15864a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong VariableName, 15874a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong sizeof (DRIVER_SAMPLE_CONFIGURATION), 15884a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong (UINT8 *) Configuration, 15895adb8db71e333069509269f832b356adab0678c0lgao NULL 15905adb8db71e333069509269f832b356adab0678c0lgao ); 15914a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 15924a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong FreePool (Configuration); 15934a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 15944a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateOneOfOpCode ( 15954a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, // Container for dynamic created opcodes 15964a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x8001, // Question ID (or call it "key") 15974a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong CONFIGURATION_VARSTORE_ID, // VarStore ID 15984a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong (UINT16) DYNAMIC_ONE_OF_VAR_OFFSET, // Offset in Buffer Storage 15994a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN (STR_ONE_OF_PROMPT), // Question prompt text 16004a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN (STR_ONE_OF_HELP), // Question help text 16014a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_IFR_FLAG_CALLBACK, // Question flag 16024a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_IFR_NUMERIC_SIZE_1, // Data type of Question Value 16034a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong OptionsOpCodeHandle, // Option Opcode list 16044a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong NULL // Default Opcode is NULl 16054a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 16067e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 16074a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateOrderedListOpCode ( 16084a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, // Container for dynamic created opcodes 16094a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x8002, // Question ID 16104a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong CONFIGURATION_VARSTORE_ID, // VarStore ID 16114a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong (UINT16) DYNAMIC_ORDERED_LIST_VAR_OFFSET, // Offset in Buffer Storage 16124a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN (STR_BOOT_OPTIONS), // Question prompt text 16134a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN (STR_BOOT_OPTIONS), // Question help text 16144a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_IFR_FLAG_RESET_REQUIRED, // Question flag 16154a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0, // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET 16164a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EFI_IFR_NUMERIC_SIZE_1, // Data type of Question value 16174a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 5, // Maximum container 16184a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong OptionsOpCodeHandle, // Option Opcode list 16194a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong NULL // Default Opcode is NULl 16204a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 16217e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 16224a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateTextOpCode ( 16234a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, 16244a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_TEXT_SAMPLE_HELP), 16254a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_TEXT_SAMPLE_HELP), 16264a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_TEXT_SAMPLE_STRING) 16277e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao ); 16287e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 16294a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateDateOpCode ( 16304a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, 16314a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x8004, 16324a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x0, 16334a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x0, 16344a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_DATE_SAMPLE_HELP), 16354a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_DATE_SAMPLE_HELP), 16364a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0, 16374a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong QF_DATE_STORAGE_TIME, 16384a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong NULL 16394a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 16407e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 16414a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateTimeOpCode ( 16424a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, 16434a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x8005, 16444a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x0, 16454a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x0, 16464a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_TIME_SAMPLE_HELP), 16474a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN(STR_TIME_SAMPLE_HELP), 16484a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0, 16494a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong QF_TIME_STORAGE_TIME, 16504a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong NULL 16514a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 16527e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 16534a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiCreateGotoOpCode ( 16544a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, // Container for dynamic created opcodes 16554a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 1, // Target Form ID 16564a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN (STR_GOTO_FORM1), // Prompt text 16574a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong STRING_TOKEN (STR_GOTO_HELP), // Help text 16584a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0, // Question flag 16594a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x8003 // Question ID 16604a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong ); 1661a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 16624a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiUpdateForm ( 16634a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong PrivateData->HiiHandle[0], // HII handle 1664c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, // Formset GUID 16654a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong 0x1234, // Form ID 16664a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong StartOpCodeHandle, // Label for where to insert opcodes 16674a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong EndOpCodeHandle // Replace data 1668a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu ); 16697e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 16704a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiFreeOpCodeHandle (StartOpCodeHandle); 16714a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiFreeOpCodeHandle (OptionsOpCodeHandle); 16724a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong HiiFreeOpCodeHandle (EndOpCodeHandle); 16734a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong break; 16747e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 16754a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong case 0x2000: 16764a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 16774a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // Only used to update the state. 16784a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 16794a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong if ((Type == EFI_IFR_TYPE_STRING) && (Value->string == 0) && 16804a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong (PrivateData->PasswordState == BROWSER_STATE_SET_PASSWORD)) { 16814a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD; 16824a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong return EFI_INVALID_PARAMETER; 16834a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 168493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 16854a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 16864a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // When try to set a new password, user will be chanlleged with old password. 16874a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // The Callback is responsible for validating old password input by user, 16884a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // If Callback return EFI_SUCCESS, it indicates validation pass. 16894a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong // 16904a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong switch (PrivateData->PasswordState) { 16914a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong case BROWSER_STATE_VALIDATE_PASSWORD: 16924a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong Status = ValidatePassword (PrivateData, Value->string); 16934a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong if (Status == EFI_SUCCESS) { 16944a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong PrivateData->PasswordState = BROWSER_STATE_SET_PASSWORD; 16954a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 16964a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong break; 169793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 16984a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong case BROWSER_STATE_SET_PASSWORD: 16994a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong Status = SetPassword (PrivateData, Value->string); 17004a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD; 17014a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong break; 1702e2100bfa651cd0d1295ef13451b9cf4adddb8bfaydong 17034a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong default: 17044a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong break; 170593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 170693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 170793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang break; 170893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 170993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang default: 171093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang break; 171193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 17124a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong } 17134a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong break; 171493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 17153a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case EFI_BROWSER_ACTION_CHANGED: 17163a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong switch (QuestionId) { 17173a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case 0x1237: 17183a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17193a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // User press "Exit now", request Browser to exit 17203a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17213a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; 17223a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong break; 17233a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong 17243a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case 0x1238: 17253a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17263a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // User press "Save now", request Browser to save the uncommitted data. 17273a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17283a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; 17293a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong break; 17303a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong 17313a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case 0x1241: 17323a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case 0x1246: 17333a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17343a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // User press "Submit current form and Exit now", request Browser to submit current form and exit 17353a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17363a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT; 17373a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong break; 17383a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong 17393a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case 0x1242: 17403a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17413a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // User press "Discard current form now", request Browser to discard the uncommitted data. 17423a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17433a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD; 17443a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong break; 17453a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong 17463a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case 0x1243: 17473a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17483a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // User press "Submit current form now", request Browser to save the uncommitted data. 17493a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17503a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY; 17513a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong break; 17523a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong 17533a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case 0x1244: 17543a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong case 0x1245: 17553a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17563a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // User press "Discard current form and Exit now", request Browser to discard the uncommitted data and exit. 17573a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong // 17583a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT; 17593a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong break; 176034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong 176134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong case 0x1231: 176234326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 176334326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 1. Check to see whether system support keyword. 176434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 176534326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong Status = PrivateData->HiiKeywordHandler->GetData (PrivateData->HiiKeywordHandler, 176634326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"NAMESPACE=x-UEFI-ns", 176734326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"KEYWORD=iSCSIBootEnable", 176834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong &Progress, 176934326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong &ProgressErr, 177034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong &Results 177134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong ); 177234326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong if (EFI_ERROR (Status)) { 177334326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong do { 177434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong CreatePopUp ( 177534326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 177634326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong &Key, 177734326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"", 177834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"This system not support this keyword!", 177934326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"Press ENTER to continue ...", 178034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"", 178134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong NULL 178234326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong ); 178334326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); 178434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong 178534326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong Status = EFI_SUCCESS; 178634326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong break; 178734326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong } 178834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong 178934326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 179034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 2. If system support this keyword, just try to change value. 179134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 17923a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong 179334326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 179434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // Change value from '0' to '1' or from '1' to '0' 179534326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 179634326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong TmpStr = StrStr (Results, L"&VALUE="); 179734326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong ASSERT (TmpStr != NULL); 179834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong TmpStr += StrLen (L"&VALUE="); 179934326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong TmpStr++; 180034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong if (*TmpStr == L'0') { 180134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong *TmpStr = L'1'; 180234326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong } else { 180334326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong *TmpStr = L'0'; 180434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong } 180534326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong 180634326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 180734326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 3. Call the keyword handler protocol to change the value. 180834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 180934326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong Status = PrivateData->HiiKeywordHandler->SetData (PrivateData->HiiKeywordHandler, 181034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong Results, 181134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong &Progress, 181234326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong &ProgressErr 181334326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong ); 181434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong if (EFI_ERROR (Status)) { 181534326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong do { 181634326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong CreatePopUp ( 181734326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, 181834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong &Key, 181934326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"", 182034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"Set keyword to the system failed!", 182134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"Press ENTER to continue ...", 182234326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong L"", 182334326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong NULL 182434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong ); 182534326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); 182634326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong 182734326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong Status = EFI_SUCCESS; 182834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong break; 182934326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong } 183034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong break; 183134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong 18323a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong default: 18333a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong break; 18343a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong } 18353a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong break; 18363a4e7a3e73a40eecbb0a977a0e7421ff5743c353ydong 183793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang default: 18384a22b9bc6a5a5cc5e7f868f8ab3ee28cd770c545ydong Status = EFI_UNSUPPORTED; 183993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang break; 184093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 184193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 184293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 184393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang} 184493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 18457064c0a5aa3eabe99be9c143e4abaa73d7139609qwang/** 18467064c0a5aa3eabe99be9c143e4abaa73d7139609qwang Main entry for this driver. 1847a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 18487064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @param ImageHandle Image handle this driver. 18497064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @param SystemTable Pointer to SystemTable. 18507064c0a5aa3eabe99be9c143e4abaa73d7139609qwang 18517064c0a5aa3eabe99be9c143e4abaa73d7139609qwang @retval EFI_SUCESS This function always complete successfully. 18527064c0a5aa3eabe99be9c143e4abaa73d7139609qwang 18537064c0a5aa3eabe99be9c143e4abaa73d7139609qwang**/ 185493e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFI_STATUS 185593e3992d1ea50fb30c48f498d257d4e66252dd9bqwangEFIAPI 185693e3992d1ea50fb30c48f498d257d4e66252dd9bqwangDriverSampleInit ( 185793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN EFI_HANDLE ImageHandle, 185893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang IN EFI_SYSTEM_TABLE *SystemTable 185993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ) 186093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang{ 186193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_STATUS Status; 186293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_HANDLE HiiHandle[2]; 186393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_SCREEN_DESCRIPTOR Screen; 186493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_DATABASE_PROTOCOL *HiiDatabase; 186593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_STRING_PROTOCOL *HiiString; 186693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2; 186793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; 186834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *HiiKeywordHandler; 186993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang CHAR16 *NewString; 187093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINTN BufferSize; 187193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang DRIVER_SAMPLE_CONFIGURATION *Configuration; 187284f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao BOOLEAN ActionFlag; 1873a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu EFI_STRING ConfigRequestHdr; 187482e8c1380fe8d9d94b7585242f1e159bdbbeb778Eric Dong EFI_STRING NameRequestHdr; 187578c2b9a33478ee0cb7e39466fb12191dde56b210ydong MY_EFI_VARSTORE_DATA *VarStoreConfig; 18762b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao EFI_INPUT_KEY HotKey; 18772b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao EFI_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx; 1878a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 187993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 188084f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // Initialize the local variables. 188193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 188284f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao ConfigRequestHdr = NULL; 188333efdf51b0f123259dec0bfcff49af189b46c411ydong NewString = NULL; 188433efdf51b0f123259dec0bfcff49af189b46c411ydong 188593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 188693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Initialize screen dimensions for SendForm(). 188793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Remove 3 characters from top and bottom 188893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 188993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ZeroMem (&Screen, sizeof (EFI_SCREEN_DESCRIPTOR)); 189093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &Screen.RightColumn, &Screen.BottomRow); 189193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 189293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Screen.TopRow = 3; 189393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Screen.BottomRow = Screen.BottomRow - 3; 189493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 189593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 189693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Initialize driver private data 189793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 18987b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData = AllocateZeroPool (sizeof (DRIVER_SAMPLE_PRIVATE_DATA)); 18997b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao if (mPrivateData == NULL) { 190093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return EFI_OUT_OF_RESOURCES; 190193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 190293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 19037b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->Signature = DRIVER_SAMPLE_PRIVATE_SIGNATURE; 190493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 19057b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->ConfigAccess.ExtractConfig = ExtractConfig; 19067b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->ConfigAccess.RouteConfig = RouteConfig; 19077b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->ConfigAccess.Callback = DriverCallback; 19087b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD; 190993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 191093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 191193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Locate Hii Database protocol 191293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 191393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &HiiDatabase); 191493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (EFI_ERROR (Status)) { 191593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 191693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 19177b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->HiiDatabase = HiiDatabase; 191893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 191993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 192093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Locate HiiString protocol 192193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 192293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString); 192393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (EFI_ERROR (Status)) { 192493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 192593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 19267b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->HiiString = HiiString; 192793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 192893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 192993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Locate Formbrowser2 protocol 193093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 193193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2); 193293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (EFI_ERROR (Status)) { 193393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 193493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 19357b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->FormBrowser2 = FormBrowser2; 193693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 193793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 193893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Locate ConfigRouting protocol 193993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 194093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting); 194193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang if (EFI_ERROR (Status)) { 194293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return Status; 194393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 19447b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->HiiConfigRouting = HiiConfigRouting; 194593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 194634326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 194734326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // Locate keyword handler protocol 194834326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong // 194934326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong Status = gBS->LocateProtocol (&gEfiConfigKeywordHandlerProtocolGuid, NULL, (VOID **) &HiiKeywordHandler); 195034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong if (EFI_ERROR (Status)) { 195134326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong return Status; 195234326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong } 19537b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->HiiKeywordHandler = HiiKeywordHandler; 195434326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong 1955f6f910dd125144707e3516bbb517b8ec7a388c06rsun Status = gBS->InstallMultipleProtocolInterfaces ( 195693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &DriverHandle[0], 1957f6f910dd125144707e3516bbb517b8ec7a388c06rsun &gEfiDevicePathProtocolGuid, 19582f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao &mHiiVendorDevicePath0, 195993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang &gEfiHiiConfigAccessProtocolGuid, 19607b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao &mPrivateData->ConfigAccess, 1961f6f910dd125144707e3516bbb517b8ec7a388c06rsun NULL 196293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ); 196393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ASSERT_EFI_ERROR (Status); 196493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 19657b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->DriverHandle[0] = DriverHandle[0]; 1966f6f910dd125144707e3516bbb517b8ec7a388c06rsun 196793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 196893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Publish our HII data 196993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 1970cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun HiiHandle[0] = HiiAddPackages ( 1971c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 1972cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun DriverHandle[0], 1973cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun DriverSampleStrings, 1974cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun VfrBin, 1975cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun NULL 1976cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun ); 1977cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun if (HiiHandle[0] == NULL) { 197893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return EFI_OUT_OF_RESOURCES; 197993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 198093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 19817b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->HiiHandle[0] = HiiHandle[0]; 198293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 198393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 198493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Publish another Fromset 198593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 1986f6f910dd125144707e3516bbb517b8ec7a388c06rsun Status = gBS->InstallMultipleProtocolInterfaces ( 1987f6f910dd125144707e3516bbb517b8ec7a388c06rsun &DriverHandle[1], 1988f6f910dd125144707e3516bbb517b8ec7a388c06rsun &gEfiDevicePathProtocolGuid, 19892f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao &mHiiVendorDevicePath1, 199034326197d13c4ff51aedf3c03461b72727d72ac1Eric Dong &gEfiHiiConfigAccessProtocolGuid, 19917b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao &mPrivateData->ConfigAccess, 1992f6f910dd125144707e3516bbb517b8ec7a388c06rsun NULL 1993f6f910dd125144707e3516bbb517b8ec7a388c06rsun ); 1994f6f910dd125144707e3516bbb517b8ec7a388c06rsun ASSERT_EFI_ERROR (Status); 1995f6f910dd125144707e3516bbb517b8ec7a388c06rsun 19967b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->DriverHandle[1] = DriverHandle[1]; 199793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 1998cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun HiiHandle[1] = HiiAddPackages ( 1999c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleInventoryGuid, 2000cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun DriverHandle[1], 2001cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun DriverSampleStrings, 2002cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun InventoryBin, 2003cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun NULL 2004cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun ); 2005cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun if (HiiHandle[1] == NULL) { 200638ebfecb6279417259db116d6b03cdcb03ecc6bblgao DriverSampleUnload (ImageHandle); 200793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return EFI_OUT_OF_RESOURCES; 200893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 200993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 20107b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->HiiHandle[1] = HiiHandle[1]; 201193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 201293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 2013b204f2b5272363dec5fc4d8fc78c8af4c3eb8288ydong // Update the device path string. 2014b204f2b5272363dec5fc4d8fc78c8af4c3eb8288ydong // 2015863986b3c8e67736d361b68e293d01e6f92f825cRuiyu Ni NewString = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL*)&mHiiVendorDevicePath0, FALSE, FALSE); 201633efdf51b0f123259dec0bfcff49af189b46c411ydong if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_DEVICE_PATH), NewString, NULL) == 0) { 2017b204f2b5272363dec5fc4d8fc78c8af4c3eb8288ydong DriverSampleUnload (ImageHandle); 2018b204f2b5272363dec5fc4d8fc78c8af4c3eb8288ydong return EFI_OUT_OF_RESOURCES; 2019b204f2b5272363dec5fc4d8fc78c8af4c3eb8288ydong } 202033efdf51b0f123259dec0bfcff49af189b46c411ydong if (NewString != NULL) { 202133efdf51b0f123259dec0bfcff49af189b46c411ydong FreePool (NewString); 202233efdf51b0f123259dec0bfcff49af189b46c411ydong } 202333efdf51b0f123259dec0bfcff49af189b46c411ydong 2024b204f2b5272363dec5fc4d8fc78c8af4c3eb8288ydong // 202593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Very simple example of how one would update a string that is already 202693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // in the HII database 202793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 202893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang NewString = L"700 Mhz"; 202993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 2030cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_CPU_STRING2), NewString, NULL) == 0) { 203138ebfecb6279417259db116d6b03cdcb03ecc6bblgao DriverSampleUnload (ImageHandle); 2032cb7d01c0c9fd199742d0fed6aa69dab0c79c3338rsun return EFI_OUT_OF_RESOURCES; 203393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 203493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 203538ebfecb6279417259db116d6b03cdcb03ecc6bblgao HiiSetString (HiiHandle[0], 0, NewString, NULL); 203638ebfecb6279417259db116d6b03cdcb03ecc6bblgao 203738ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 203838ebfecb6279417259db116d6b03cdcb03ecc6bblgao // Initialize Name/Value name String ID 203938ebfecb6279417259db116d6b03cdcb03ecc6bblgao // 20407b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->NameStringId[0] = STR_NAME_VALUE_VAR_NAME0; 20417b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->NameStringId[1] = STR_NAME_VALUE_VAR_NAME1; 20427b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData->NameStringId[2] = STR_NAME_VALUE_VAR_NAME2; 204338ebfecb6279417259db116d6b03cdcb03ecc6bblgao 204493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 204593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Initialize configuration data 204693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 20477b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao Configuration = &mPrivateData->Configuration; 204893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ZeroMem (Configuration, sizeof (DRIVER_SAMPLE_CONFIGURATION)); 204993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 205093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 205193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // Try to read NV config EFI variable first 205293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 2053c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao ConfigRequestHdr = HiiConstructConfigHdr (&gDriverSampleFormSetGuid, VariableName, DriverHandle[0]); 205484f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao ASSERT (ConfigRequestHdr != NULL); 205584f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao 205682e8c1380fe8d9d94b7585242f1e159bdbbeb778Eric Dong NameRequestHdr = HiiConstructConfigHdr (&gDriverSampleFormSetGuid, NULL, DriverHandle[0]); 205782e8c1380fe8d9d94b7585242f1e159bdbbeb778Eric Dong ASSERT (NameRequestHdr != NULL); 205882e8c1380fe8d9d94b7585242f1e159bdbbeb778Eric Dong 205993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION); 2060c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao Status = gRT->GetVariable (VariableName, &gDriverSampleFormSetGuid, NULL, &BufferSize, Configuration); 206184f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao if (EFI_ERROR (Status)) { 206293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 206304da0b4a11fd128c08fb0192c02a142285f6fa69lgao // Store zero data Buffer Storage to EFI variable 206404da0b4a11fd128c08fb0192c02a142285f6fa69lgao // 206504da0b4a11fd128c08fb0192c02a142285f6fa69lgao Status = gRT->SetVariable( 206604da0b4a11fd128c08fb0192c02a142285f6fa69lgao VariableName, 2067c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 206804da0b4a11fd128c08fb0192c02a142285f6fa69lgao EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 206904da0b4a11fd128c08fb0192c02a142285f6fa69lgao sizeof (DRIVER_SAMPLE_CONFIGURATION), 207004da0b4a11fd128c08fb0192c02a142285f6fa69lgao Configuration 207104da0b4a11fd128c08fb0192c02a142285f6fa69lgao ); 20722c775600d5131cd9b55552f938750c7bdb36c478Eric Dong if (EFI_ERROR (Status)) { 20732c775600d5131cd9b55552f938750c7bdb36c478Eric Dong DriverSampleUnload (ImageHandle); 20742c775600d5131cd9b55552f938750c7bdb36c478Eric Dong return Status; 20752c775600d5131cd9b55552f938750c7bdb36c478Eric Dong } 207604da0b4a11fd128c08fb0192c02a142285f6fa69lgao // 207793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // EFI variable for NV config doesn't exit, we should build this variable 207893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // based on default values stored in IFR 207993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 208082e8c1380fe8d9d94b7585242f1e159bdbbeb778Eric Dong ActionFlag = HiiSetToDefaults (NameRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD); 20812c775600d5131cd9b55552f938750c7bdb36c478Eric Dong if (!ActionFlag) { 20822c775600d5131cd9b55552f938750c7bdb36c478Eric Dong DriverSampleUnload (ImageHandle); 20832c775600d5131cd9b55552f938750c7bdb36c478Eric Dong return EFI_INVALID_PARAMETER; 20842c775600d5131cd9b55552f938750c7bdb36c478Eric Dong } 208582e8c1380fe8d9d94b7585242f1e159bdbbeb778Eric Dong 208684f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao ActionFlag = HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD); 20872c775600d5131cd9b55552f938750c7bdb36c478Eric Dong if (!ActionFlag) { 20882c775600d5131cd9b55552f938750c7bdb36c478Eric Dong DriverSampleUnload (ImageHandle); 20892c775600d5131cd9b55552f938750c7bdb36c478Eric Dong return EFI_INVALID_PARAMETER; 20902c775600d5131cd9b55552f938750c7bdb36c478Eric Dong } 209184f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao } else { 209284f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // 209384f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // EFI variable does exist and Validate Current Setting 209484f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao // 209582e8c1380fe8d9d94b7585242f1e159bdbbeb778Eric Dong ActionFlag = HiiValidateSettings (NameRequestHdr); 20962c775600d5131cd9b55552f938750c7bdb36c478Eric Dong if (!ActionFlag) { 20972c775600d5131cd9b55552f938750c7bdb36c478Eric Dong DriverSampleUnload (ImageHandle); 20982c775600d5131cd9b55552f938750c7bdb36c478Eric Dong return EFI_INVALID_PARAMETER; 20992c775600d5131cd9b55552f938750c7bdb36c478Eric Dong } 210082e8c1380fe8d9d94b7585242f1e159bdbbeb778Eric Dong 210184f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao ActionFlag = HiiValidateSettings (ConfigRequestHdr); 21022c775600d5131cd9b55552f938750c7bdb36c478Eric Dong if (!ActionFlag) { 21032c775600d5131cd9b55552f938750c7bdb36c478Eric Dong DriverSampleUnload (ImageHandle); 21042c775600d5131cd9b55552f938750c7bdb36c478Eric Dong return EFI_INVALID_PARAMETER; 21052c775600d5131cd9b55552f938750c7bdb36c478Eric Dong } 210693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 210778c2b9a33478ee0cb7e39466fb12191dde56b210ydong FreePool (ConfigRequestHdr); 2108a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 210978c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 211078c2b9a33478ee0cb7e39466fb12191dde56b210ydong // Initialize efi varstore configuration data 211178c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 21127b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao VarStoreConfig = &mPrivateData->VarStoreConfig; 211378c2b9a33478ee0cb7e39466fb12191dde56b210ydong ZeroMem (VarStoreConfig, sizeof (MY_EFI_VARSTORE_DATA)); 211478c2b9a33478ee0cb7e39466fb12191dde56b210ydong 2115c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao ConfigRequestHdr = HiiConstructConfigHdr (&gDriverSampleFormSetGuid, MyEfiVar, DriverHandle[0]); 211678c2b9a33478ee0cb7e39466fb12191dde56b210ydong ASSERT (ConfigRequestHdr != NULL); 211778c2b9a33478ee0cb7e39466fb12191dde56b210ydong 211878c2b9a33478ee0cb7e39466fb12191dde56b210ydong BufferSize = sizeof (MY_EFI_VARSTORE_DATA); 2119c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao Status = gRT->GetVariable (MyEfiVar, &gDriverSampleFormSetGuid, NULL, &BufferSize, VarStoreConfig); 212078c2b9a33478ee0cb7e39466fb12191dde56b210ydong if (EFI_ERROR (Status)) { 212178c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 212278c2b9a33478ee0cb7e39466fb12191dde56b210ydong // Store zero data to EFI variable Storage. 212378c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 212478c2b9a33478ee0cb7e39466fb12191dde56b210ydong Status = gRT->SetVariable( 212578c2b9a33478ee0cb7e39466fb12191dde56b210ydong MyEfiVar, 2126c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gDriverSampleFormSetGuid, 212778c2b9a33478ee0cb7e39466fb12191dde56b210ydong EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, 212878c2b9a33478ee0cb7e39466fb12191dde56b210ydong sizeof (MY_EFI_VARSTORE_DATA), 212978c2b9a33478ee0cb7e39466fb12191dde56b210ydong VarStoreConfig 213078c2b9a33478ee0cb7e39466fb12191dde56b210ydong ); 21312c775600d5131cd9b55552f938750c7bdb36c478Eric Dong if (EFI_ERROR (Status)) { 21322c775600d5131cd9b55552f938750c7bdb36c478Eric Dong DriverSampleUnload (ImageHandle); 21332c775600d5131cd9b55552f938750c7bdb36c478Eric Dong return Status; 21342c775600d5131cd9b55552f938750c7bdb36c478Eric Dong } 213578c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 213678c2b9a33478ee0cb7e39466fb12191dde56b210ydong // EFI variable for NV config doesn't exit, we should build this variable 213778c2b9a33478ee0cb7e39466fb12191dde56b210ydong // based on default values stored in IFR 213878c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 213978c2b9a33478ee0cb7e39466fb12191dde56b210ydong ActionFlag = HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD); 21402c775600d5131cd9b55552f938750c7bdb36c478Eric Dong if (!ActionFlag) { 21412c775600d5131cd9b55552f938750c7bdb36c478Eric Dong DriverSampleUnload (ImageHandle); 21422c775600d5131cd9b55552f938750c7bdb36c478Eric Dong return EFI_INVALID_PARAMETER; 21432c775600d5131cd9b55552f938750c7bdb36c478Eric Dong } 214478c2b9a33478ee0cb7e39466fb12191dde56b210ydong } else { 214578c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 214678c2b9a33478ee0cb7e39466fb12191dde56b210ydong // EFI variable does exist and Validate Current Setting 214778c2b9a33478ee0cb7e39466fb12191dde56b210ydong // 214878c2b9a33478ee0cb7e39466fb12191dde56b210ydong ActionFlag = HiiValidateSettings (ConfigRequestHdr); 21492c775600d5131cd9b55552f938750c7bdb36c478Eric Dong if (!ActionFlag) { 21502c775600d5131cd9b55552f938750c7bdb36c478Eric Dong DriverSampleUnload (ImageHandle); 21512c775600d5131cd9b55552f938750c7bdb36c478Eric Dong return EFI_INVALID_PARAMETER; 21522c775600d5131cd9b55552f938750c7bdb36c478Eric Dong } 215378c2b9a33478ee0cb7e39466fb12191dde56b210ydong } 215484f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao FreePool (ConfigRequestHdr); 215584f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao 2156211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong Status = gBS->CreateEventEx ( 2157211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong EVT_NOTIFY_SIGNAL, 2158211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong TPL_NOTIFY, 2159211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong DriverSampleInternalEmptyFunction, 2160211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong NULL, 2161c8ad2d7a296c851c2a91519f80dab479df0fdf46lgao &gEfiIfrRefreshIdOpGuid, 2162211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong &mEvent 2163211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ); 2164211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong ASSERT_EFI_ERROR (Status); 21652b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao 21662b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // 21672b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // Example of how to use BrowserEx protocol to register HotKey. 21682b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // 21692b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao Status = gBS->LocateProtocol (&gEfiFormBrowserExProtocolGuid, NULL, (VOID **) &FormBrowserEx); 21702b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao if (!EFI_ERROR (Status)) { 21712b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // 21722b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // First unregister the default hot key F9 and F10. 21732b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // 21742b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao HotKey.UnicodeChar = CHAR_NULL; 21752b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao HotKey.ScanCode = SCAN_F9; 21762b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao FormBrowserEx->RegisterHotKey (&HotKey, 0, 0, NULL); 21772b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao HotKey.ScanCode = SCAN_F10; 21782b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao FormBrowserEx->RegisterHotKey (&HotKey, 0, 0, NULL); 21792b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao 21802b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // 21812b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // Register the default HotKey F9 and F10 again. 21822b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao // 21832b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao HotKey.ScanCode = SCAN_F10; 21847b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao NewString = HiiGetString (mPrivateData->HiiHandle[0], STRING_TOKEN (FUNCTION_TEN_STRING), NULL); 21852b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao ASSERT (NewString != NULL); 21862b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao FormBrowserEx->RegisterHotKey (&HotKey, BROWSER_ACTION_SUBMIT, 0, NewString); 21872b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao HotKey.ScanCode = SCAN_F9; 21887b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao NewString = HiiGetString (mPrivateData->HiiHandle[0], STRING_TOKEN (FUNCTION_NINE_STRING), NULL); 21892b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao ASSERT (NewString != NULL); 21902b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao FormBrowserEx->RegisterHotKey (&HotKey, BROWSER_ACTION_DEFAULT, EFI_HII_DEFAULT_CLASS_STANDARD, NewString); 21912b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao } 21922b826e217e1ab0bbd1b6b354c81f8fc060523b29lgao 219393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 2194a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu // In default, this driver is built into Flash device image, 21957e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao // the following code doesn't run. 219693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang // 21977e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 21982f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao // 21997e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao // Example of how to display only the item we sent to HII 2200a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu // When this driver is not built into Flash device image, 22017e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao // it need to call SendForm to show front page by itself. 22022f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao // 22037e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao if (DISPLAY_ONLY_MY_ITEM <= 1) { 22047e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao // 22057e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao // Have the browser pull out our copy of the data, and only display our data 22067e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao // 22077e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao Status = FormBrowser2->SendForm ( 22087e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao FormBrowser2, 22097e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao &(HiiHandle[DISPLAY_ONLY_MY_ITEM]), 22107e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 1, 22117e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao NULL, 22127e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao 0, 22137e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao NULL, 22147e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao NULL 22157e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao ); 2216a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 221714d59fa188194a6199a04677352d9d47b26ad632lgao HiiRemovePackages (HiiHandle[0]); 2218a6973cff629818f1cd3eec8f469c1bc33ec866b1xdu 221914d59fa188194a6199a04677352d9d47b26ad632lgao HiiRemovePackages (HiiHandle[1]); 22202f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao } 22212f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao 222284f9a9ec8f84f837b3c0addf1f4681d8f8c71db1lgao return EFI_SUCCESS; 22232f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao} 22242f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao 22252f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao/** 22262f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao Unloads the application and its installed protocol. 22272f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao 22282f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao @param[in] ImageHandle Handle that identifies the image to be unloaded. 22292f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao 22302f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao @retval EFI_SUCCESS The image has been unloaded. 22312f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao**/ 22322f3065c0fb21a054956e11ebd6caf5a68bd296e2lgaoEFI_STATUS 22332f3065c0fb21a054956e11ebd6caf5a68bd296e2lgaoEFIAPI 22342f3065c0fb21a054956e11ebd6caf5a68bd296e2lgaoDriverSampleUnload ( 22352f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao IN EFI_HANDLE ImageHandle 22362f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao ) 22372f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao{ 223838ebfecb6279417259db116d6b03cdcb03ecc6bblgao UINTN Index; 2239f0c855b26386c16ba0a70600d72cd09c090db0e0rsun 22407b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao ASSERT (mPrivateData != NULL); 2241f0c855b26386c16ba0a70600d72cd09c090db0e0rsun 22422f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao if (DriverHandle[0] != NULL) { 22432f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao gBS->UninstallMultipleProtocolInterfaces ( 22442f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao DriverHandle[0], 22452f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao &gEfiDevicePathProtocolGuid, 22462f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao &mHiiVendorDevicePath0, 22472f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao &gEfiHiiConfigAccessProtocolGuid, 22487b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao &mPrivateData->ConfigAccess, 22492f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao NULL 22502f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao ); 2251ccee6099223bb2d05e7fcacaab285a9cb7331ad7lgao DriverHandle[0] = NULL; 22522f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao } 22532f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao 22542f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao if (DriverHandle[1] != NULL) { 22552f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao gBS->UninstallMultipleProtocolInterfaces ( 22562f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao DriverHandle[1], 22572f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao &gEfiDevicePathProtocolGuid, 22582f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao &mHiiVendorDevicePath1, 22592f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao NULL 22602f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao ); 2261ccee6099223bb2d05e7fcacaab285a9cb7331ad7lgao DriverHandle[1] = NULL; 22622f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao } 22632f3065c0fb21a054956e11ebd6caf5a68bd296e2lgao 22647b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao if (mPrivateData->HiiHandle[0] != NULL) { 22657b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao HiiRemovePackages (mPrivateData->HiiHandle[0]); 226614d59fa188194a6199a04677352d9d47b26ad632lgao } 226714d59fa188194a6199a04677352d9d47b26ad632lgao 22687b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao if (mPrivateData->HiiHandle[1] != NULL) { 22697b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao HiiRemovePackages (mPrivateData->HiiHandle[1]); 227014d59fa188194a6199a04677352d9d47b26ad632lgao } 227114d59fa188194a6199a04677352d9d47b26ad632lgao 2272f0c855b26386c16ba0a70600d72cd09c090db0e0rsun for (Index = 0; Index < NAME_VALUE_NAME_NUMBER; Index++) { 22737b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao if (mPrivateData->NameValueName[Index] != NULL) { 22747b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao FreePool (mPrivateData->NameValueName[Index]); 227538ebfecb6279417259db116d6b03cdcb03ecc6bblgao } 227693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang } 22777b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao FreePool (mPrivateData); 22787b2c31ae65491e94e906ccb3e4e691ee458f2ecaLiming Gao mPrivateData = NULL; 227993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang 2280211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong gBS->CloseEvent (mEvent); 2281211cc6e5cd697c9ca9d32a8e4f6938494c7aaa0dydong 228293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang return EFI_SUCCESS; 228393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang} 2284