/** Get the configure parameter for this NIC. @param Instance The IP4 CONFIG Instance. @param ConfigLen The length of the NicConfig buffer. @param NicConfig The buffer to receive the NIC's configure parameter. @retval EFI_SUCCESS The configure parameter for this NIC was obtained successfully . @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL. @retval EFI_NOT_FOUND There is no configure parameter for the NIC in NVRam. @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is NULL. **/ EFI_STATUS EFIAPI EfiNicIp4ConfigGetInfo ( IN IP4_CONFIG_INSTANCE *Instance, IN OUT UINTN *ConfigLen, OUT NIC_IP4_CONFIG_INFO *NicConfig ) { NIC_IP4_CONFIG_INFO *Config; EFI_STATUS Status; UINTN Len; if ((Instance == NULL) || (ConfigLen == NULL)) { return EFI_INVALID_PARAMETER; } // // Read the Nic's configuration parameter from variable // Config = Ip4ConfigGetNicInfo (&Instance->NicAddr); if (Config == NULL) { return EFI_NOT_FOUND; } // // Copy the data to user's buffer // Len = SIZEOF_NIC_IP4_CONFIG_INFO (Config); if ((*ConfigLen < Len) || (NicConfig == NULL)) { Status = EFI_BUFFER_TOO_SMALL; } else { Status = EFI_SUCCESS; CopyMem (NicConfig, Config, Len); Ip4ConfigFixRouteTablePointer (&NicConfig->Ip4Info); } *ConfigLen = Len; FreePool (Config); return Status; }
/** This function applies changes in a driver's configuration. Input is a Configuration, which has the routing data for this driver followed by name / value configuration pairs. The driver must apply those pairs to its configurable storage. If the driver's configuration is stored in a linear block of data and the driver's name / value pairs are in <BlockConfig> format, it may use the ConfigToBlock helper function (above) to simplify the job. Currently not implemented. @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param[in] Configuration A null-terminated Unicode string in <ConfigString> format. @param[out] Progress A pointer to a string filled in with the offset of the most recent '&' before the first failing name / value pair (or the beginn ing of the string if the failure is in the first name / value pair) or the terminating NULL if all was successful. @retval EFI_SUCCESS The results have been distributed or are awaiting distribution. @retval EFI_OUT_OF_MEMORY Not enough memory to store the parts of the results that must be stored awaiting possible future protocols. @retval EFI_INVALID_PARAMETERS Passing in a NULL for the Results parameter would result in this type of error. @retval EFI_NOT_FOUND Target for the specified routing data was not found. **/ EFI_STATUS EFIAPI Ip4DeviceRouteConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress ) { EFI_STATUS Status; UINTN BufferSize; NIC_IP4_CONFIG_INFO *IfrDeviceNvData; IP4_CONFIG_IFR_NVDATA *IfrFormNvData; NIC_IP4_CONFIG_INFO *NicInfo; IP4_CONFIG_INSTANCE *Ip4ConfigInstance; EFI_MAC_ADDRESS ZeroMac; if (Configuration == NULL || Progress == NULL) { return EFI_INVALID_PARAMETER; } // // Reclaim Ip4Config variable // Ip4ConfigReclaimVariable (); *Progress = Configuration; Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This); // // Check Routing data in <ConfigHdr>. // if (HiiIsConfigHdrMatch (Configuration, &gNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { // // Convert buffer data to <ConfigResp> by helper function BlockToConfig() // IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG_IFR_NVDATA)); if (IfrFormNvData == NULL) { return EFI_OUT_OF_RESOURCES; } BufferSize = NIC_ITEM_CONFIG_SIZE; Status = gHiiConfigRouting->ConfigToBlock ( gHiiConfigRouting, Configuration, (UINT8 *) IfrFormNvData, &BufferSize, Progress ); if (!EFI_ERROR (Status)) { Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (IfrFormNvData, Ip4ConfigInstance); } FreePool (IfrFormNvData); } else if (HiiIsConfigHdrMatch (Configuration, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE); if (IfrDeviceNvData == NULL) { return EFI_OUT_OF_RESOURCES; } BufferSize = NIC_ITEM_CONFIG_SIZE; Status = gHiiConfigRouting->ConfigToBlock ( gHiiConfigRouting, Configuration, (UINT8 *) IfrDeviceNvData, &BufferSize, Progress ); if (!EFI_ERROR (Status)) { ZeroMem (&ZeroMac, sizeof (EFI_MAC_ADDRESS)); if (CompareMem (&IfrDeviceNvData->NicAddr.MacAddr, &ZeroMac, IfrDeviceNvData->NicAddr.Len) != 0) { BufferSize = SIZEOF_NIC_IP4_CONFIG_INFO (IfrDeviceNvData); NicInfo = AllocateCopyPool (BufferSize, IfrDeviceNvData); if (NicInfo == NULL) { return EFI_OUT_OF_RESOURCES; } Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE); FreePool (NicInfo); } else { ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo, sizeof (IP4_SETTING_INFO)); Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NULL, TRUE); } } FreePool (IfrDeviceNvData); } else { return EFI_NOT_FOUND; } 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; NIC_IP4_CONFIG_INFO *IfrDeviceNvData; NIC_IP4_CONFIG_INFO *NicConfig; 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; } NicConfig = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance); if (NicConfig == NULL) { return EFI_NOT_FOUND; } CopyMem (IfrDeviceNvData, NicConfig, SIZEOF_NIC_IP4_CONFIG_INFO (NicConfig)); FreePool (NicConfig); 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, &gNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG_IFR_NVDATA)); 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 (&gNicIp4ConfigNvDataGuid, 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, &gNicIp4ConfigNvDataGuid, 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; }