]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
MdeModulePkg/Universal: Fix typos in comments
[mirror_edk2.git] / MdeModulePkg / Universal / DriverSampleDxe / DriverSample.c
index 8ec1d4e6e81c57fe422f33c4738094cbf5b9dfe3..3c494e3c83376fe7c6fbedf48df7b8a047d5d66e 100644 (file)
@@ -2,7 +2,7 @@
 This is an example of how a driver might export data to the HII protocol to be\r
 later utilized by the Setup Protocol\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -68,6 +68,48 @@ HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePath1 = {
   }\r
 };\r
 \r
+/**\r
+  Set value of a data element in an Array by its Index.\r
+\r
+  @param  Array                  The data array.\r
+  @param  Type                   Type of the data in this array.\r
+  @param  Index                  Zero based index for data in this array.\r
+  @param  Value                  The value to be set.\r
+\r
+**/\r
+VOID\r
+SetArrayData (\r
+  IN VOID                     *Array,\r
+  IN UINT8                    Type,\r
+  IN UINTN                    Index,\r
+  IN UINT64                   Value\r
+  )\r
+{\r
+\r
+  ASSERT (Array != NULL);\r
+\r
+  switch (Type) {\r
+  case EFI_IFR_TYPE_NUM_SIZE_8:\r
+    *(((UINT8 *) Array) + Index) = (UINT8) Value;\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_16:\r
+    *(((UINT16 *) Array) + Index) = (UINT16) Value;\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_32:\r
+    *(((UINT32 *) Array) + Index) = (UINT32) Value;\r
+    break;\r
+\r
+  case EFI_IFR_TYPE_NUM_SIZE_64:\r
+    *(((UINT64 *) Array) + Index) = (UINT64) Value;\r
+    break;\r
+\r
+  default:\r
+    break;\r
+  }\r
+}\r
+\r
 /**\r
   Add empty function for event process function.\r
 \r
@@ -404,7 +446,7 @@ SetPassword (
   FreePool (TempPassword);\r
 \r
   //\r
-  // Retrive uncommitted data from Browser\r
+  // Retrieve uncommitted data from Browser\r
   //\r
   Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_CONFIGURATION));\r
   ASSERT (Configuration != NULL);\r
@@ -735,6 +777,11 @@ AppendAltCfgString (
     }\r
     StringPtr += Length;\r
 \r
+    //\r
+    // Skip the character "&" before "OFFSET".\r
+    //\r
+    StringPtr ++;\r
+\r
     //\r
     // Calculate Value and convert it to hex string.\r
     //\r
@@ -1283,7 +1330,9 @@ DriverCallback (
   EFI_STRING                      Results;\r
   UINT32                          ProgressErr;\r
   CHAR16                          *TmpStr;\r
-  \r
+  UINTN                           Index;\r
+  UINT64                          BufferValue;\r
+\r
   if (((Value == NULL) && (Action != EFI_BROWSER_ACTION_FORM_OPEN) && (Action != EFI_BROWSER_ACTION_FORM_CLOSE))||\r
     (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1293,6 +1342,7 @@ DriverCallback (
   FormId = 0;\r
   ProgressErr = 0;\r
   Status = EFI_SUCCESS;\r
+  BufferValue = 3;\r
   PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);\r
 \r
   switch (Action) {\r
@@ -1470,6 +1520,12 @@ DriverCallback (
         Value->u8 = DEFAULT_CLASS_STANDARD_VALUE;\r
       break;\r
 \r
+      case 0x1252:\r
+        for (Index = 0; Index < 3; Index ++) {\r
+          SetArrayData (Value, EFI_IFR_TYPE_NUM_SIZE_8, Index, BufferValue--);\r
+        }\r
+      break;\r
+\r
       default:\r
         Status = EFI_UNSUPPORTED;\r
       break;\r
@@ -1834,6 +1890,28 @@ DriverCallback (
     }\r
   break;\r
 \r
+  case EFI_BROWSER_ACTION_SUBMITTED:\r
+    {\r
+      if (QuestionId == 0x1250) {\r
+        //\r
+        // Sample CallBack for EFI_BROWSER_ACTION_SUBMITTED action:\r
+        // Show up a pop-up to show SUBMITTED callback has been triggered.\r
+        //\r
+        do {\r
+          CreatePopUp (\r
+            EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+            &Key,\r
+            L"",\r
+            L"EfiVarstore value has been submitted!",\r
+            L"Press ESC or ENTER to continue ...",\r
+            L"",\r
+            NULL\r
+            );\r
+        } while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));\r
+      }\r
+    }\r
+    break;\r
+\r
   default:\r
     Status = EFI_UNSUPPORTED;\r
     break;\r
@@ -1874,7 +1952,7 @@ DriverSampleInit (
   EFI_STRING                      NameRequestHdr;\r
   MY_EFI_VARSTORE_DATA            *VarStoreConfig;\r
   EFI_INPUT_KEY                   HotKey;\r
-  EFI_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx;\r
+  EDKII_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx;\r
 \r
   //\r
   // Initialize the local variables.\r
@@ -2166,7 +2244,7 @@ DriverSampleInit (
   //\r
   // Example of how to use BrowserEx protocol to register HotKey.\r
   // \r
-  Status = gBS->LocateProtocol (&gEfiFormBrowserExProtocolGuid, NULL, (VOID **) &FormBrowserEx);\r
+  Status = gBS->LocateProtocol (&gEdkiiFormBrowserExProtocolGuid, NULL, (VOID **) &FormBrowserEx);\r
   if (!EFI_ERROR (Status)) {\r
     //\r
     // First unregister the default hot key F9 and F10.\r
@@ -2256,6 +2334,8 @@ DriverSampleUnload (
             DriverHandle[1],\r
             &gEfiDevicePathProtocolGuid,\r
             &mHiiVendorDevicePath1,\r
+            &gEfiHiiConfigAccessProtocolGuid,\r
+            &mPrivateData->ConfigAccess,\r
             NULL\r
            );\r
     DriverHandle[1] = NULL;\r