diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c index cc3f6fb97f..2c74a80308 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c @@ -15,6 +15,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Ip4Config.h" #include "NicIp4Variable.h" +// +// Ip4 Config Protocol +// +GLOBAL_REMOVE_IF_UNREFERENCED EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate = { + EfiIp4ConfigStart, + EfiIp4ConfigStop, + EfiIp4ConfigGetData +}; /** Get the NIC's configure information from the IP4 configure variable. @@ -651,9 +659,3 @@ Ip4ConfigCleanConfig ( Ip4ConfigCleanDhcp4 (Instance); } -EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate = { - EfiIp4ConfigStart, - EfiIp4ConfigStop, - EfiIp4ConfigGetData -}; - diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h index 87bc25c2f1..eacd893890 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h @@ -42,7 +42,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE; // // Global variables @@ -84,7 +83,7 @@ typedef struct _IP4CONFIG_CALLBACK_INFO { EFI_IPv4_ADDRESS Gateway; } IP4_SETTING_INFO; -struct _IP4_CONFIG_INSTANCE { +typedef struct _IP4_CONFIG_INSTANCE { UINT32 Signature; EFI_HANDLE Controller; EFI_HANDLE Image; @@ -129,7 +128,7 @@ struct _IP4_CONFIG_INSTANCE { EFI_DHCP4_PROTOCOL *Dhcp4; EFI_HANDLE Dhcp4Handle; EFI_EVENT Dhcp4Event; -}; +} IP4_CONFIG_INSTANCE; #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \ CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE) @@ -388,4 +387,113 @@ Ip4ConfigDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer ); +/** + Starts running the configuration policy for the EFI IPv4 Protocol driver. + + The Start() function is called to determine and to begin the platform + configuration policy by the EFI IPv4 Protocol driver. This determination may + be as simple as returning EFI_UNSUPPORTED if there is no EFI IPv4 Protocol + driver configuration policy. It may be as involved as loading some defaults + from nonvolatile storage, downloading dynamic data from a DHCP server, and + checking permissions with a site policy server. + Starting the configuration policy is just the beginning. It may finish almost + instantly or it may take several minutes before it fails to retrieve configuration + information from one or more servers. Once the policy is started, drivers + should use the DoneEvent parameter to determine when the configuration policy + has completed. EFI_IP4_CONFIG_PROTOCOL.GetData() must then be called to + determine if the configuration succeeded or failed. + Until the configuration completes successfully, EFI IPv4 Protocol driver instances + that are attempting to use default configurations must return EFI_NO_MAPPING. + Once the configuration is complete, the EFI IPv4 Configuration Protocol driver + signals DoneEvent. The configuration may need to be updated in the future, + however; in this case, the EFI IPv4 Configuration Protocol driver must signal + ReconfigEvent, and all EFI IPv4 Protocol driver instances that are using default + configurations must return EFI_NO_MAPPING until the configuration policy has + been rerun. + + @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. + @param DoneEvent Event that will be signaled when the EFI IPv4 + Protocol driver configuration policy completes + execution. This event must be of type EVT_NOTIFY_SIGNAL. + @param ReconfigEvent Event that will be signaled when the EFI IPv4 + Protocol driver configuration needs to be updated. + This event must be of type EVT_NOTIFY_SIGNAL. + + @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol + driver is now running. + @retval EFI_INVALID_PARAMETER One or more of the following parameters is NULL: + This + DoneEvent + ReconfigEvent + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_ALREADY_STARTED The configuration policy for the EFI IPv4 Protocol + driver was already started. + @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. + @retval EFI_UNSUPPORTED This interface does not support the EFI IPv4 Protocol + driver configuration. + +**/ +EFI_STATUS +EFIAPI +EfiIp4ConfigStart ( + IN EFI_IP4_CONFIG_PROTOCOL *This, + IN EFI_EVENT DoneEvent, + IN EFI_EVENT ReconfigEvent + ); + +/** + Stops running the configuration policy for the EFI IPv4 Protocol driver. + + The Stop() function stops the configuration policy for the EFI IPv4 Protocol driver. + All configuration data will be lost after calling Stop(). + + @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. + + @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol + driver has been stopped. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol + driver was not started. + +**/ +EFI_STATUS +EFIAPI +EfiIp4ConfigStop ( + IN EFI_IP4_CONFIG_PROTOCOL *This + ); + +/** + Returns the default configuration data (if any) for the EFI IPv4 Protocol driver. + + The GetData() function returns the current configuration data for the EFI IPv4 + Protocol driver after the configuration policy has completed. + + @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. + @param ConfigDataSize On input, the size of the ConfigData buffer. + On output, the count of bytes that were written + into the ConfigData buffer. + @param ConfigData Pointer to the EFI IPv4 Configuration Protocol + driver configuration data structure. + Type EFI_IP4_IPCONFIG_DATA is defined in + "Related Definitions" below. + + @retval EFI_SUCCESS The EFI IPv4 Protocol driver configuration has been returned. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol + driver is not running. + @retval EFI_NOT_READY EFI IPv4 Protocol driver configuration is still running. + @retval EFI_ABORTED EFI IPv4 Protocol driver configuration could not complete. + Currently not implemented. + @retval EFI_BUFFER_TOO_SMALL *ConfigDataSize is smaller than the configuration + data buffer or ConfigData is NULL. + +**/ +EFI_STATUS +EFIAPI +EfiIp4ConfigGetData ( + IN EFI_IP4_CONFIG_PROTOCOL *This, + IN OUT UINTN *ConfigDataSize, + OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL + ); + #endif diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c index dfa4cdcd8f..c620abd70b 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c @@ -26,6 +26,60 @@ EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = { NULL }; +// +// The intance of template of IP4 Config private data +// +IP4_CONFIG_INSTANCE mIp4ConfigTemplate = { + IP4_CONFIG_INSTANCE_SIGNATURE, + NULL, + NULL, + (EFI_DEVICE_PATH_PROTOCOL *) NULL, + { + NULL, + NULL, + NULL + }, + { + NULL, + NULL, + NULL + }, + NULL, + (EFI_DEVICE_PATH_PROTOCOL *) NULL, + NULL, + { + FALSE, + FALSE, + { + 0 + }, + { + 0 + }, + { + 0 + } + }, + 0, + (EFI_MANAGED_NETWORK_PROTOCOL *) NULL, + NULL, + NULL, + NULL, + EFI_NOT_READY, + { + 0, + 0, + { + 0 + } + }, + (CHAR16 *) NULL, + (NIC_IP4_CONFIG_INFO *) NULL, + (EFI_DHCP4_PROTOCOL *) NULL, + NULL, + NULL +}; + /** The entry point for IP4 config driver which install the driver binding and component name protocol on its image. @@ -180,14 +234,13 @@ Ip4ConfigDriverBindingStart ( // // Allocate an instance then initialize it // - Instance = AllocateZeroPool (sizeof (IP4_CONFIG_INSTANCE)); + Instance = AllocateCopyPool (sizeof (IP4_CONFIG_INSTANCE), &mIp4ConfigTemplate); if (Instance == NULL) { Status = EFI_OUT_OF_RESOURCES; goto ON_ERROR; } - Instance->Signature = IP4_CONFIG_INSTANCE_SIGNATURE; Instance->Controller = ControllerHandle; Instance->Image = This->DriverBindingHandle; Instance->ParentDevicePath = ParentDevicePath; @@ -198,15 +251,6 @@ Ip4ConfigDriverBindingStart ( Instance->Mnp = Mnp; Instance->MnpHandle = MnpHandle; - Instance->DoneEvent = NULL; - Instance->ReconfigEvent = NULL; - Instance->Result = EFI_NOT_READY; - Instance->NicConfig = NULL; - - Instance->Dhcp4 = NULL; - Instance->Dhcp4Handle = NULL; - Instance->Dhcp4Event = NULL; - Status = Mnp->GetModeData (Mnp, NULL, &SnpMode); if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) { diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c index fa78678ade..ca03a80239 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c @@ -37,7 +37,7 @@ GetSubnetMaskPrefixLength ( // // The SubnetMask is in network byte order. // - ReverseMask = (SubnetMask->Addr[0] << 24) | (SubnetMask->Addr[1] << 16) | (SubnetMask->Addr[2] << 8) | (SubnetMask->Addr[3]); + ReverseMask = SwapBytes32 (*(UINT32 *)&SubnetMask[0]); // // Reverse it.