/** This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig so that data can be read from the data storage such as UEFI Variable or module's customized storage exposed by EFI_FRAMEWORK_CALLBACK. @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL @param Request A null-terminated Unicode string in <ConfigRequest> format. Note that this includes the routing information as well as the configurable name / value pairs. It is invalid for this string to be in <MultiConfigRequest> format. @param Progress On return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent '&' before the first failing name / value pair (or the beginning of the string if the failure is in the first name / value pair) if the request was not successful @param Results A null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function. @retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance. @retval EFI_SUCCESS The setting is retrived successfully. @retval !EFI_SUCCESS The error returned by UEFI Get Variable or Framework Form Callback Nvread. **/ EFI_STATUS EFIAPI ThunkExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results ) { EFI_STATUS Status; CONFIG_ACCESS_PRIVATE *ConfigAccess; FORMSET_STORAGE *BufferStorage; VOID *Data; UINTN DataSize; FORM_BROWSER_FORMSET *FormSetContext; CHAR16 *VarStoreName; EFI_STRING ConfigRequestHdr; EFI_STRING ConfigRequest; UINTN Size; BOOLEAN AllocatedRequest; LIST_ENTRY *StorageList; EFI_STRING SingleResult; EFI_STRING FinalResults; EFI_STRING StrPointer; if (Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; } *Progress = Request; Status = EFI_SUCCESS; Data = NULL; StrPointer = NULL; SingleResult = NULL; FinalResults = NULL; ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This); FormSetContext = ConfigAccess->ThunkContext->FormSet; if (IsListEmpty (&FormSetContext->StorageListHead)) { // // No VarStorage does exist in this form. // return EFI_NOT_FOUND; } StorageList = GetFirstNode (&FormSetContext->StorageListHead); do { if (Request != NULL) { BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request); if (BufferStorage == NULL) { return EFI_NOT_FOUND; } } else { if (IsNull (&FormSetContext->StorageListHead, StorageList)) { // // No Storage to be extracted into the results. // break; } BufferStorage = FORMSET_STORAGE_FROM_LINK (StorageList); StorageList = GetNextNode (&FormSetContext->StorageListHead, StorageList); } VarStoreName = NULL; ConfigRequestHdr = NULL; ConfigRequest = NULL; Size = 0; AllocatedRequest = FALSE; if (ConfigAccess->ThunkContext->NvMapOverride == NULL) { // // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback. // if (ConfigAccess->FormCallbackProtocol == NULL || ConfigAccess->FormCallbackProtocol->NvRead == NULL) { Status = GetUefiVariable ( BufferStorage, &Data, &DataSize ); } else { Status = CallFormCallBack ( BufferStorage, ConfigAccess->FormCallbackProtocol, &Data, &DataSize ); } } else { // // Use the NvMapOverride. // DataSize = BufferStorage->Size; Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride); if (Data != NULL) { Status = EFI_SUCCESS; } else { Status = EFI_OUT_OF_RESOURCES; } } if (!EFI_ERROR (Status)) { ConfigRequest = Request; if (Request == NULL || (StrStr (Request, L"OFFSET") == NULL)) { // // Request is without any request element, construct full request string. // if ((BufferStorage->VarStoreId == FormSetContext->DefaultVarStoreId) && (FormSetContext->OriginalDefaultVarStoreName != NULL)) { VarStoreName = FormSetContext->OriginalDefaultVarStoreName; } else { VarStoreName = BufferStorage->Name; } // // First Set ConfigRequestHdr string. // ConfigRequestHdr = HiiConstructConfigHdr (&BufferStorage->Guid, VarStoreName, ConfigAccess->ThunkContext->UefiHiiDriverHandle); ASSERT (ConfigRequestHdr != NULL); // // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator // Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); ASSERT (ConfigRequest != NULL); AllocatedRequest = TRUE; UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)DataSize); FreePool (ConfigRequestHdr); } Status = mHiiConfigRoutingProtocol->BlockToConfig ( mHiiConfigRoutingProtocol, ConfigRequest, Data, DataSize, &SingleResult, Progress ); // // Free the allocated config request string. // if (AllocatedRequest) { FreePool (ConfigRequest); ConfigRequest = NULL; } } // // Free the allocated Data // if (Data != NULL) { FreePool (Data); } // // Directly return when meet with error // if (EFI_ERROR (Status)) { break; } // // Merge result into the final results. // if (FinalResults == NULL) { FinalResults = SingleResult; SingleResult = NULL; } else { Size = StrLen (FinalResults); Size = Size + 1; Size = Size + StrLen (SingleResult) + 1; StrPointer = AllocateZeroPool (Size * sizeof (CHAR16)); ASSERT (StrPointer != NULL); StrCpy (StrPointer, FinalResults); FreePool (FinalResults); FinalResults = StrPointer; StrPointer = StrPointer + StrLen (StrPointer); *StrPointer = L'&'; StrCpy (StrPointer + 1, SingleResult); FreePool (SingleResult); } } while (Request == NULL); if (!EFI_ERROR (Status)) { *Results = FinalResults; } else { if (FinalResults != NULL) { FreePool (FinalResults); } } // // Set Progress string to the original request string. // if (Request == NULL) { *Progress = NULL; } else if (StrStr (Request, L"OFFSET") == NULL) { *Progress = Request + StrLen (Request); } return Status; }
/** This function allows a caller to extract the current configuration for one or more named elements from the target driver. @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param[in] Request A null-terminated Unicode string in <ConfigRequest> format. @param[out] Progress On return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent '&' before the first failing name/value pair (or the beginning of the string if the failure is in the first name/value pair) if the request was not successful. @param[out] Results A null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function. @retval EFI_SUCCESS The Results is filled with the requested values. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results. @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name. @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver. **/ EFI_STATUS EFIAPI VlanExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results ) { EFI_STATUS Status; UINTN BufferSize; VLAN_CONFIGURATION Configuration; VLAN_CONFIG_PRIVATE_DATA *PrivateData; EFI_STRING ConfigRequestHdr; EFI_STRING ConfigRequest; BOOLEAN AllocatedRequest; UINTN Size; if (Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; } *Progress = Request; if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gVlanConfigFormSetGuid, mVlanStorageName)) { return EFI_NOT_FOUND; } ConfigRequestHdr = NULL; ConfigRequest = NULL; AllocatedRequest = FALSE; Size = 0; // // Retrieve the pointer to the UEFI HII Config Routing Protocol // if (mHiiConfigRouting == NULL) { gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &mHiiConfigRouting); } ASSERT (mHiiConfigRouting != NULL); // // Convert buffer data to <ConfigResp> by helper function BlockToConfig() // PrivateData = VLAN_CONFIG_PRIVATE_DATA_FROM_THIS (This); ZeroMem (&Configuration, sizeof (VLAN_CONFIGURATION)); BufferSize = sizeof (Configuration); ConfigRequest = Request; if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { // // Request has no request element, construct full request string. // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator // ConfigRequestHdr = HiiConstructConfigHdr (&gVlanConfigFormSetGuid, mVlanStorageName, PrivateData->DriverHandle); Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); ASSERT (ConfigRequest != NULL); AllocatedRequest = TRUE; UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); FreePool (ConfigRequestHdr); } Status = mHiiConfigRouting->BlockToConfig ( mHiiConfigRouting, ConfigRequest, (UINT8 *) &Configuration, BufferSize, Results, Progress ); // // Free the allocated config request string. // if (AllocatedRequest) { FreePool (ConfigRequest); ConfigRequest = NULL; } // // Set Progress string to the original request string. // if (Request == NULL) { *Progress = NULL; } else if (StrStr (Request, L"OFFSET") == NULL) { *Progress = Request + StrLen (Request); } return Status; }
/** This function allows a caller to extract the current configuration for one or more named elements from the target driver. @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param[in] Request A null-terminated Unicode string in <ConfigRequest> format. @param[out] Progress On return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent '&' before the first failing name/value pair (or the beginning of the string if the failure is in the first name/value pair) if the request was not successful. @param[out] Results A null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function. @retval EFI_SUCCESS The Results is filled with the requested values. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results. @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name. @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver. **/ EFI_STATUS EFIAPI TrEEExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results ) { EFI_STATUS Status; UINTN BufferSize; TREE_CONFIGURATION Configuration; TREE_CONFIG_PRIVATE_DATA *PrivateData; EFI_STRING ConfigRequestHdr; EFI_STRING ConfigRequest; BOOLEAN AllocatedRequest; UINTN Size; UINTN Index; if (Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; } *Progress = Request; if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gTrEEConfigFormSetGuid, TREE_STORAGE_NAME)) { return EFI_NOT_FOUND; } ConfigRequestHdr = NULL; ConfigRequest = NULL; AllocatedRequest = FALSE; Size = 0; PrivateData = TREE_CONFIG_PRIVATE_DATA_FROM_THIS (This); // // Convert buffer data to <ConfigResp> by helper function BlockToConfig() // BufferSize = sizeof (Configuration); Status = gRT->GetVariable ( TREE_STORAGE_NAME, &gTrEEConfigFormSetGuid, NULL, &BufferSize, &Configuration ); ASSERT_EFI_ERROR (Status); // // Get data from PCD to make sure data consistant - platform driver is suppose to construct this PCD accroding to Variable // for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) { if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &mTpmInstanceId[Index].TpmInstanceGuid)) { Configuration.TpmDevice = mTpmInstanceId[Index].TpmDevice; break; } } BufferSize = sizeof (Configuration); ConfigRequest = Request; if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { // // Request has no request element, construct full request string. // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator // ConfigRequestHdr = HiiConstructConfigHdr (&gTrEEConfigFormSetGuid, TREE_STORAGE_NAME, PrivateData->DriverHandle); Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); ASSERT (ConfigRequest != NULL); AllocatedRequest = TRUE; UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64) BufferSize); FreePool (ConfigRequestHdr); } Status = gHiiConfigRouting->BlockToConfig ( gHiiConfigRouting, ConfigRequest, (UINT8 *) &Configuration, BufferSize, Results, Progress ); // // Free the allocated config request string. // if (AllocatedRequest) { FreePool (ConfigRequest); } // // Set Progress string to the original request string. // if (Request == NULL) { *Progress = NULL; } else if (StrStr (Request, L"OFFSET") == NULL) { *Progress = Request + StrLen (Request); } return Status; }
/** This function allows the caller to request the current configuration for one or more named elements. The resulting string is in <ConfigAltResp> format. Any and all alternative configuration strings shall also be appended to the end of the current configuration string. If they are, they must appear after the current configuration. They must contain the same routing (GUID, NAME, PATH) as the current configuration string. They must have an additional description indicating the type of alternative configuration the string represents, "ALTCFG=<StringToken>". That <StringToken> (when converted from Hex UNICODE to binary) is a reference to a string in the associated string pack. @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param[in] Request A null-terminated Unicode string in <ConfigRequest> format. Note that this includes the routing information as well as the configurable name / value pairs. It is invalid for this string to be in <MultiConfigRequest> format. @param[out] Progress On return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent "&" before the first failing name / value pair (or the beginning of the string if the failure is in the first name / value pair) if the request was not successful. @param[out] Results A null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function. @retval EFI_SUCCESS The Results string is filled with the values corresponding to all requested names. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the parts of the results that must be stored awaiting possible future protocols. @retval EFI_NOT_FOUND Routing data doesn't match any known driver. Progress set to the first character in the routing header. Note: There is no requirement that the driver validate the routing data. It must skip the <ConfigHdr> in order to process the names. @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set to most recent & before the error or the beginning of the string. @retval EFI_INVALID_PARAMETER Unknown name. Progress points to the & before the name in question.Currently not implemented. **/ EFI_STATUS EFIAPI Ip4DeviceExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results ) { EFI_STATUS Status; UINTN ConfigLen; NIC_IP4_CONFIG_INFO *IfrDeviceNvData; IP4_CONFIG_INSTANCE *Ip4ConfigInstance; IP4_CONFIG_IFR_NVDATA *IfrFormNvData; EFI_STRING ConfigRequestHdr; EFI_STRING ConfigRequest; EFI_STRING DeviceResult; EFI_STRING FormResult; CHAR16 *StrPointer; BOOLEAN AllocatedRequest; UINTN Size; UINTN BufferSize; if (Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; } *Progress = Request; Size = 0; DeviceResult = NULL; FormResult = NULL; ConfigRequest = NULL; Status = EFI_SUCCESS; AllocatedRequest = FALSE; Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This); // // Check Request data in <ConfigHdr>. // if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE); if (IfrDeviceNvData == NULL) { return EFI_OUT_OF_RESOURCES; } ConfigLen = sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2; Status = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance, &ConfigLen, IfrDeviceNvData); if (EFI_ERROR (Status)) { FreePool (IfrDeviceNvData); return EFI_NOT_FOUND; } ConfigRequest = Request; if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { // // Request has no request element, construct full request string. // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator // ConfigRequestHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Ip4ConfigInstance->ChildHandle); Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); ASSERT (ConfigRequest != NULL); AllocatedRequest = TRUE; BufferSize = NIC_ITEM_CONFIG_SIZE; UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); FreePool (ConfigRequestHdr); } // // Convert buffer data to <ConfigResp> by helper function BlockToConfig() // Status = gHiiConfigRouting->BlockToConfig ( gHiiConfigRouting, ConfigRequest, (UINT8 *) IfrDeviceNvData, NIC_ITEM_CONFIG_SIZE, &DeviceResult, Progress ); FreePool (IfrDeviceNvData); // // Free the allocated config request string. // if (AllocatedRequest) { FreePool (ConfigRequest); ConfigRequest = NULL; } if (EFI_ERROR (Status)) { goto Failure; } } if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { IfrFormNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE); if (IfrFormNvData == NULL) { return EFI_OUT_OF_RESOURCES; } Ip4ConfigConvertDeviceConfigDataToIfrNvData (Ip4ConfigInstance, IfrFormNvData); ConfigRequest = Request; if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { // // Request has no request element, construct full request string. // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator // ConfigRequestHdr = HiiConstructConfigHdr (&mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Ip4ConfigInstance->ChildHandle); Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); ASSERT (ConfigRequest != NULL); AllocatedRequest = TRUE; BufferSize = sizeof (IP4_CONFIG_IFR_NVDATA); UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); FreePool (ConfigRequestHdr); } // // Convert buffer data to <ConfigResp> by helper function BlockToConfig() // Status = gHiiConfigRouting->BlockToConfig ( gHiiConfigRouting, ConfigRequest, (UINT8 *) IfrFormNvData, sizeof (IP4_CONFIG_IFR_NVDATA), &FormResult, Progress ); FreePool (IfrFormNvData); // // Free the allocated config request string. // if (AllocatedRequest) { FreePool (ConfigRequest); ConfigRequest = NULL; } if (EFI_ERROR (Status)) { goto Failure; } } if (Request == NULL) { Size = StrLen (DeviceResult); Size = Size + 1; Size = Size + StrLen (FormResult) + 1; *Results = AllocateZeroPool (Size * sizeof (CHAR16)); ASSERT (*Results != NULL); StrPointer = *Results; StrCpy (StrPointer, DeviceResult); StrPointer = StrPointer + StrLen (StrPointer); *StrPointer = L'&'; StrCpy (StrPointer + 1, FormResult); FreePool (DeviceResult); FreePool (FormResult); } else if (HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { *Results = DeviceResult; } else if (HiiIsConfigHdrMatch (Request, &mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { *Results = FormResult; } else { return EFI_NOT_FOUND; } Failure: // // Set Progress string to the original request string. // if (Request == NULL) { *Progress = NULL; } else if (StrStr (Request, L"OFFSET") == NULL) { *Progress = Request + StrLen (Request); } return Status; }
/** This function allows the caller to request the current configuration for one or more named elements. The resulting string is in <ConfigAltResp> format. Any and all alternative configuration strings shall also be appended to the end of the current configuration string. If they are, they must appear after the current configuration. They must contain the same routing (GUID, NAME, PATH) as the current configuration string. They must have an additional description indicating the type of alternative configuration the string represents, "ALTCFG=<StringToken>". That <StringToken> (when converted from Hex UNICODE to binary) is a reference to a string in the associated string pack. @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param[in] Request A null-terminated Unicode string in <ConfigRequest> format. Note that this includes the routing information as well as the configurable name / value pairs. It is invalid for this string to be in <MultiConfigRequest> format. @param[out] Progress On return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent "&" before the first failing name / value pair (or the beginning of the string if the failure is in the first name / value pair) if the request was not successful. @param[out] Results A null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function. @retval EFI_SUCCESS The Results string is filled with the values corresponding to all requested names. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the parts of the results that must be stored awaiting possible future protocols. @retval EFI_NOT_FOUND Routing data doesn't match any known driver. Progress set to the first character in the routing header. Note: There is no requirement that the driver validate the routing data. It must skip the <ConfigHdr> in order to process the names. @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set to most recent & before the error or the beginning of the string. @retval EFI_INVALID_PARAMETER Unknown name. Progress points to the & before the name in question.Currently not implemented. **/ EFI_STATUS EFIAPI Ip4FormExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results ) { EFI_STATUS Status; IP4_CONFIG2_INSTANCE *Ip4Config2Instance; IP4_FORM_CALLBACK_INFO *Private; IP4_CONFIG2_IFR_NVDATA *IfrFormNvData; EFI_STRING ConfigRequestHdr; EFI_STRING ConfigRequest; BOOLEAN AllocatedRequest; EFI_STRING FormResult; UINTN Size; UINTN BufferSize; if (Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; } Status = EFI_SUCCESS; IfrFormNvData = NULL; ConfigRequest = NULL; FormResult = NULL; Size = 0; AllocatedRequest = FALSE; ConfigRequest = Request; Private = IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(This); Ip4Config2Instance = IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Private); BufferSize = sizeof (IP4_CONFIG2_IFR_NVDATA); *Progress = Request; // // Check Request data in <ConfigHdr>. // if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) { IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG2_IFR_NVDATA)); if (IfrFormNvData == NULL) { return EFI_OUT_OF_RESOURCES; } Ip4Config2ConvertConfigNvDataToIfrNvData (Ip4Config2Instance, IfrFormNvData); if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { // // Request has no request element, construct full request string. // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator // ConfigRequestHdr = HiiConstructConfigHdr (&gIp4Config2NvDataGuid, mIp4Config2StorageName, Private->ChildHandle); Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); if (ConfigRequest == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Failure; } AllocatedRequest = TRUE; UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); FreePool (ConfigRequestHdr); } // // Convert buffer data to <ConfigResp> by helper function BlockToConfig() // Status = gHiiConfigRouting->BlockToConfig ( gHiiConfigRouting, ConfigRequest, (UINT8 *) IfrFormNvData, BufferSize, &FormResult, Progress ); FreePool (IfrFormNvData); // // Free the allocated config request string. // if (AllocatedRequest) { FreePool (ConfigRequest); ConfigRequest = NULL; } if (EFI_ERROR (Status)) { goto Failure; } } if (Request == NULL || HiiIsConfigHdrMatch (Request, &gIp4Config2NvDataGuid, mIp4Config2StorageName)) { *Results = FormResult; } else { return EFI_NOT_FOUND; } Failure: // // Set Progress string to the original request string. // if (Request == NULL) { *Progress = NULL; } else if (StrStr (Request, L"OFFSET") == NULL) { *Progress = Request + StrLen (Request); } return Status; }
/** This function allows a caller to extract the current configuration for one or more named elements from the target driver. @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param Request A null-terminated Unicode string in <ConfigRequest> format. @param Progress On return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent '&' before the first failing name/value pair (or the beginning of the string if the failure is in the first name/value pair) if the request was not successful. @param Results A null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function. @retval EFI_SUCCESS The Results is filled with the requested values. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results. @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name. @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver. **/ EFI_STATUS EFIAPI BootMaintExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results ) { EFI_STATUS Status; UINTN BufferSize; BMM_CALLBACK_DATA *Private; EFI_STRING ConfigRequestHdr; EFI_STRING ConfigRequest; BOOLEAN AllocatedRequest; UINTN Size; if (Progress == NULL || Results == NULL) { return EFI_INVALID_PARAMETER; } *Progress = Request; if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gBootMaintFormSetGuid, mBootMaintStorageName)) { return EFI_NOT_FOUND; } ConfigRequestHdr = NULL; ConfigRequest = NULL; AllocatedRequest = FALSE; Size = 0; Private = BMM_CALLBACK_DATA_FROM_THIS (This); // // Convert buffer data to <ConfigResp> by helper function BlockToConfig() // BufferSize = sizeof (BMM_FAKE_NV_DATA); ConfigRequest = Request; if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { // // Request has no request element, construct full request string. // Allocate and fill a buffer large enough to hold the <ConfigHdr> template // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator // ConfigRequestHdr = HiiConstructConfigHdr (&gBootMaintFormSetGuid, mBootMaintStorageName, Private->BmmDriverHandle); Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); ASSERT (ConfigRequest != NULL); AllocatedRequest = TRUE; UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); FreePool (ConfigRequestHdr); } Status = gHiiConfigRouting->BlockToConfig ( gHiiConfigRouting, ConfigRequest, (UINT8 *) &Private->BmmFakeNvData, BufferSize, Results, Progress ); // // Free the allocated config request string. // if (AllocatedRequest) { FreePool (ConfigRequest); ConfigRequest = NULL; } // // Set Progress string to the original request string. // if (Request == NULL) { *Progress = NULL; } else if (StrStr (Request, L"OFFSET") == NULL) { *Progress = Request + StrLen (Request); } return Status; }