- 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