]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/TrEEConfig/TrEEConfigImpl.c
SecurityPkg: Use PcdSet##S to instead of PcdSet##
[mirror_edk2.git] / SecurityPkg / Tcg / TrEEConfig / TrEEConfigImpl.c
index 0df99d607ea0d612ddf82c9d90719d4c3f89f697..2f03adcc8c42406f149dad90baae86bf8de44b1e 100644 (file)
@@ -2,7 +2,7 @@
   HII Config Access protocol implementation of TREE configuration module.\r
   NOTE: This module is only for reference only, each platform should have its own setup page.\r
 \r
-Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2014, 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
@@ -86,96 +86,12 @@ TrEEExtractConfig (
        OUT EFI_STRING                            *Results\r
   )\r
 {\r
-  EFI_STATUS                 Status;\r
-  UINTN                      BufferSize;\r
-  TREE_CONFIGURATION         Configuration;\r
-  TREE_CONFIG_PRIVATE_DATA   *PrivateData;\r
-  EFI_STRING                 ConfigRequestHdr;\r
-  EFI_STRING                 ConfigRequest;\r
-  BOOLEAN                    AllocatedRequest;\r
-  UINTN                      Size;\r
-  UINTN                      Index;\r
-\r
   if (Progress == NULL || Results == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   *Progress = Request;\r
-  if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gTrEEConfigFormSetGuid, TREE_STORAGE_NAME)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  ConfigRequestHdr = NULL;\r
-  ConfigRequest    = NULL;\r
-  AllocatedRequest = FALSE;\r
-  Size             = 0;\r
-\r
-  PrivateData = TREE_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r
-\r
-  //\r
-  // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
-  //  \r
-  BufferSize = sizeof (Configuration);\r
-  Status = gRT->GetVariable (\r
-                  TREE_STORAGE_NAME,\r
-                  &gTrEEConfigFormSetGuid,\r
-                  NULL,\r
-                  &BufferSize,\r
-                  &Configuration\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Get data from PCD to make sure data consistant - platform driver is suppose to construct this PCD accroding to Variable\r
-  //\r
-  for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) {\r
-    if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &mTpmInstanceId[Index].TpmInstanceGuid)) {\r
-      Configuration.TpmDevice = mTpmInstanceId[Index].TpmDevice;\r
-      break;\r
-    }\r
-  }\r
-\r
-  BufferSize = sizeof (Configuration);\r
-  ConfigRequest = Request;\r
-  if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
-    //\r
-    // Request has no request element, construct full request string.\r
-    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
-    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
-    //\r
-    ConfigRequestHdr = HiiConstructConfigHdr (&gTrEEConfigFormSetGuid, TREE_STORAGE_NAME, PrivateData->DriverHandle);\r
-    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
-    ConfigRequest = AllocateZeroPool (Size);\r
-    ASSERT (ConfigRequest != NULL);\r
-    AllocatedRequest = TRUE;\r
-    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64) BufferSize);\r
-    FreePool (ConfigRequestHdr);\r
-  }\r
-\r
-  Status = gHiiConfigRouting->BlockToConfig (\r
-                                gHiiConfigRouting,\r
-                                ConfigRequest,\r
-                                (UINT8 *) &Configuration,\r
-                                BufferSize,\r
-                                Results,\r
-                                Progress\r
-                                );\r
-  //\r
-  // Free the allocated config request string.\r
-  //\r
-  if (AllocatedRequest) {\r
-    FreePool (ConfigRequest);\r
-  }\r
-  //\r
-  // Set Progress string to the original request string.\r
-  //\r
-  if (Request == NULL) {\r
-    *Progress = NULL;\r
-  } else if (StrStr (Request, L"OFFSET") == NULL) {\r
-    *Progress = Request + StrLen (Request);\r
-  }\r
-\r
-  return Status;\r
+  return EFI_NOT_FOUND;\r
 }\r
 \r
 /**\r
@@ -252,59 +168,11 @@ TrEERouteConfig (
        OUT EFI_STRING                          *Progress\r
   )\r
 {\r
-  EFI_STATUS                       Status;\r
-  UINTN                            BufferSize;\r
-  TREE_CONFIGURATION               TrEEConfiguration;\r
-\r
   if (Configuration == NULL || Progress == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  *Progress = Configuration;\r
-  if (!HiiIsConfigHdrMatch (Configuration, &gTrEEConfigFormSetGuid, TREE_STORAGE_NAME)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  BufferSize = sizeof (TrEEConfiguration);\r
-  Status = gRT->GetVariable (\r
-                  TREE_STORAGE_NAME,\r
-                  &gTrEEConfigFormSetGuid,\r
-                  NULL,\r
-                  &BufferSize,\r
-                  &TrEEConfiguration\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()\r
-  //\r
-  BufferSize = sizeof (TREE_CONFIGURATION);\r
-  Status = gHiiConfigRouting->ConfigToBlock (\r
-                                gHiiConfigRouting,\r
-                                Configuration,\r
-                                (UINT8 *) &TrEEConfiguration,\r
-                                &BufferSize,\r
-                                Progress\r
-                                );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Save to variable so platform driver can get it.\r
-  //\r
-  Status = gRT->SetVariable (\r
-                  TREE_STORAGE_NAME,\r
-                  &gTrEEConfigFormSetGuid,\r
-                  EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                  sizeof(TrEEConfiguration),\r
-                  &TrEEConfiguration\r
-                  );\r
-\r
-  SaveTrEEPpRequest (TrEEConfiguration.Tpm2Operation\r
-                     );\r
-\r
-  return Status;\r
+  return EFI_NOT_FOUND;\r
 }\r
 \r
 /**\r
@@ -343,13 +211,17 @@ TrEECallback (
   if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-\r
-  if ((Action != EFI_BROWSER_ACTION_CHANGED) ||\r
-      (QuestionId != KEY_TPM_DEVICE)) {\r
-    return EFI_UNSUPPORTED;\r
+  \r
+  if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
+    if (QuestionId == KEY_TPM_DEVICE) {\r
+      return EFI_SUCCESS;\r
+    }\r
+    if (QuestionId == KEY_TPM2_OPERATION) {\r
+      return SaveTrEEPpRequest (Value->u8);\r
+    }\r
   }\r
 \r
-  return EFI_SUCCESS;\r
+  return EFI_UNSUPPORTED;\r
 }\r
 \r
 /**\r
@@ -413,6 +285,24 @@ InstallTrEEConfigForm (
   \r
   PrivateData->HiiHandle = HiiHandle;\r
 \r
+  //\r
+  // Update static data\r
+  //\r
+  switch (PrivateData->TpmDeviceDetected) {\r
+  case TPM_DEVICE_NULL:\r
+    HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TREE_DEVICE_STATE_CONTENT), L"Not Found", NULL);\r
+    break;\r
+  case TPM_DEVICE_1_2:\r
+    HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TREE_DEVICE_STATE_CONTENT), L"TPM 1.2", NULL);\r
+    break;\r
+  case TPM_DEVICE_2_0_DTPM:\r
+    HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TREE_DEVICE_STATE_CONTENT), L"TPM 2.0 (DTPM)", NULL);\r
+    break;\r
+  default:\r
+    HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TREE_DEVICE_STATE_CONTENT), L"Unknown", NULL);\r
+    break;\r
+  }\r
+\r
   return EFI_SUCCESS;  \r
 }\r
 \r