/** Display VLAN configuration of a network interface. @param[in] Handle Handle of the network interface. @param[in] NicIndex Index of the network interface. **/ VOID ShowNicVlanInfo ( IN EFI_HANDLE Handle, IN UINTN NicIndex ) { CHAR16 *MacStr; EFI_STATUS Status; UINTN Index; EFI_VLAN_CONFIG_PROTOCOL *VlanConfig; UINT16 NumberOfVlan; EFI_VLAN_FIND_DATA *VlanData; VlanConfig = OpenVlanConfigProtocol (Handle); if (VlanConfig == NULL) { return ; } MacStr = NULL; Status = NetLibGetMacString (Handle, mImageHandle, &MacStr); if (EFI_ERROR (Status)) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_MAC_FAIL), mHiiHandle, Status); goto Exit; } ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_ETH_MAC), mHiiHandle, NicIndex, MacStr); Status = VlanConfig->Find (VlanConfig, NULL, &NumberOfVlan, &VlanData); if (EFI_ERROR (Status)) { if (Status == EFI_NOT_FOUND) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_NO_VLAN), mHiiHandle); } else { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_FIND_FAIL), mHiiHandle, Status); } goto Exit; } for (Index = 0; Index < NumberOfVlan; Index++) { ShellPrintHiiEx ( -1, -1, NULL, STRING_TOKEN (STR_VCONFIG_VLAN_DISPLAY), mHiiHandle, VlanData[Index].VlanId, VlanData[Index].Priority ); } FreePool (VlanData); Exit: CloseVlanConfigProtocol (Handle); if (MacStr != NULL) { FreePool (MacStr); } }
/** This function publish the VLAN configuration Form for a network device. The HII Config Access protocol will be installed on a child handle of the network device. @param[in, out] PrivateData Points to VLAN configuration private data. @retval EFI_SUCCESS HII Form is installed for this network device. @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation. @retval Others Other errors as indicated. **/ EFI_STATUS InstallVlanConfigForm ( IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData ) { EFI_STATUS Status; EFI_HII_HANDLE HiiHandle; EFI_HANDLE DriverHandle; CHAR16 Str[26 + sizeof (EFI_MAC_ADDRESS) * 2 + 1]; CHAR16 *MacString; EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath; EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; EFI_VLAN_CONFIG_PROTOCOL *VlanConfig; // // Create child handle and install HII Config Access Protocol // ChildDevicePath = AppendDevicePathNode ( PrivateData->ParentDevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *) &mHiiVendorDevicePathNode ); if (ChildDevicePath == NULL) { return EFI_OUT_OF_RESOURCES; } PrivateData->ChildDevicePath = ChildDevicePath; DriverHandle = NULL; ConfigAccess = &PrivateData->ConfigAccess; Status = gBS->InstallMultipleProtocolInterfaces ( &DriverHandle, &gEfiDevicePathProtocolGuid, ChildDevicePath, &gEfiHiiConfigAccessProtocolGuid, ConfigAccess, NULL ); if (EFI_ERROR (Status)) { return Status; } PrivateData->DriverHandle = DriverHandle; // // Establish the parent-child relationship between the new created // child handle and the ControllerHandle. // Status = gBS->OpenProtocol ( PrivateData->ControllerHandle, &gEfiVlanConfigProtocolGuid, (VOID **)&VlanConfig, PrivateData->ImageHandle, PrivateData->DriverHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); if (EFI_ERROR (Status)) { return Status; } // // Publish the HII package list // HiiHandle = HiiAddPackages ( &gVlanConfigFormSetGuid, DriverHandle, VlanConfigDxeStrings, VlanConfigBin, NULL ); if (HiiHandle == NULL) { return EFI_OUT_OF_RESOURCES; } PrivateData->HiiHandle = HiiHandle; // // Update formset title help string. // MacString = NULL; Status = NetLibGetMacString (PrivateData->ControllerHandle, PrivateData->ImageHandle, &MacString); if (EFI_ERROR (Status)) { return Status; } PrivateData->MacString = MacString; StrCpy (Str, L"VLAN Configuration (MAC:"); StrnCat (Str, MacString, sizeof (EFI_MAC_ADDRESS) * 2); StrCat (Str, L")"); HiiSetString ( HiiHandle, STRING_TOKEN (STR_VLAN_FORM_SET_TITLE_HELP), Str, NULL ); // // Update form title help string. // HiiSetString ( HiiHandle, STRING_TOKEN (STR_VLAN_FORM_HELP), Str, NULL ); return EFI_SUCCESS; }
/** Publish the smbios type 1. @param Event Event whose notification function is being invoked (gEfiDxeSmmReadyToLockProtocolGuid). @param Context Pointer to the notification functions context, which is implementation dependent. @retval None **/ EFI_STATUS EFIAPI AddSmbiosManuCallback ( IN EFI_EVENT Event, IN VOID *Context ) { CHAR8 *OptionalStrStart; UINTN ManuStrLen; UINTN VerStrLen; UINTN PdNameStrLen; UINTN SerialNumStrLen; UINTN SkuNumberStrLen; UINTN FamilyNameStrLen; EFI_STATUS Status; EFI_STRING Manufacturer; EFI_STRING ProductName; EFI_STRING Version; EFI_STRING SerialNumber; EFI_STRING SkuNumber; EFI_STRING FamilyName; STRING_REF TokenToGet; EFI_SMBIOS_HANDLE SmbiosHandle; SMBIOS_TABLE_TYPE1 *SmbiosRecord; EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData; EFI_SMBIOS_PROTOCOL *Smbios; CHAR16 Buffer[40]; CHAR16 *MacStr; EFI_HANDLE *Handles; UINTN BufferSize; CHAR16 PlatformNameBuffer[40]; ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)Context; // // First check for invalid parameters. // if (Context == NULL || mPlatformInfo == NULL) { return EFI_INVALID_PARAMETER; } Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID *) &Smbios); ASSERT_EFI_ERROR (Status); if (BOARD_ID_MINNOW2_COMPATIBLE == mPlatformInfo->BoardId) { // Detect the board is compatible board platform UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Compatible "); } else { UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Max "); } // // Silicon Steppings // switch (PchStepping()) { case PchA0: UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A0 PLATFORM"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL); UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A0"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL); DEBUG ((EFI_D_ERROR, "A0 Stepping Detected\n")); break; case PchA1: UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A1 PLATFORM"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL); UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A1"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL); DEBUG ((EFI_D_ERROR, "A1 Stepping Detected\n")); break; case PchB0: UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B0 PLATFORM"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL); UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B0"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL); DEBUG ((EFI_D_ERROR, "B0 Stepping Detected\n")); break; case PchB1: UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B1 PLATFORM"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL); UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B1"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL); DEBUG ((EFI_D_ERROR, "B1 Stepping Detected\n")); break; case PchB2: UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B2 PLATFORM"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL); UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B2"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL); DEBUG ((EFI_D_ERROR, "B2 Stepping Detected\n")); break; case PchB3: UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B3 PLATFORM"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL); UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B3"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL); DEBUG ((EFI_D_ERROR, "B3 Stepping Detected\n")); break; case PchC0: UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"C0 PLATFORM"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL); UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"C0"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL); DEBUG ((EFI_D_ERROR, "C0 Stepping Detected\n")); break; case PchD0: UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"D0 PLATFORM"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL); UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"D0"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL); DEBUG ((EFI_D_ERROR, "D0 Stepping Detected\n")); break; default: DEBUG ((EFI_D_ERROR, "Unknow Stepping Detected\n")); break; } if (BOARD_ID_MINNOW2_COMPATIBLE == mPlatformInfo->BoardId) { UnicodeSPrint (Buffer, sizeof (Buffer),L"Compatible Vendor"); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER), Buffer, NULL); } TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER); Manufacturer = SmbiosMiscGetString (TokenToGet); ManuStrLen = StrLen(Manufacturer); if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; } TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME); ProductName = SmbiosMiscGetString (TokenToGet); PdNameStrLen = StrLen(ProductName); if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; } TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION); Version = SmbiosMiscGetString (TokenToGet); VerStrLen = StrLen(Version); if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; } // //Get handle infomation // BufferSize = 0; Handles = NULL; Status = gBS->LocateHandle ( ByProtocol, &gEfiSimpleNetworkProtocolGuid, NULL, &BufferSize, Handles ); if (Status == EFI_BUFFER_TOO_SMALL) { Handles = AllocateZeroPool(BufferSize); if (Handles == NULL) { return (EFI_OUT_OF_RESOURCES); } Status = gBS->LocateHandle( ByProtocol, &gEfiSimpleNetworkProtocolGuid, NULL, &BufferSize, Handles ); } // //Get the MAC string // Status = NetLibGetMacString ( *Handles, NULL, &MacStr ); if (EFI_ERROR (Status)) { return Status; } SerialNumber = MacStr; SerialNumStrLen = StrLen(SerialNumber); if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; } TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SKU_NUMBER); SkuNumber = SmbiosMiscGetString (TokenToGet); SkuNumberStrLen = StrLen(SkuNumber); if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; } TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_FAMILY_NAME1); FamilyName = SmbiosMiscGetString (TokenToGet); FamilyNameStrLen = StrLen(FamilyName); if (FamilyNameStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; } // // Two zeros following the last string. // SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1); ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1); SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION; SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1); // // Make handle chosen by smbios protocol.add automatically. // SmbiosRecord->Hdr.Handle = 0; // // Manu will be the 1st optional string following the formatted structure. // SmbiosRecord->Manufacturer = 1; // // ProductName will be the 2nd optional string following the formatted structure. // SmbiosRecord->ProductName = 2; // // Version will be the 3rd optional string following the formatted structure. // SmbiosRecord->Version = 3; // // Version will be the 4th optional string following the formatted structure. // SmbiosRecord->SerialNumber = 4; SmbiosRecord->SKUNumber= 5; SmbiosRecord->Family= 6; // // Unique UUID // ForType1InputData->SystemUuid.Data1 = PcdGet32 (PcdProductSerialNumber); ForType1InputData->SystemUuid.Data4[0] = PcdGet8 (PcdEmmcManufacturerId); CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16); SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType; OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1); UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1); UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1); UnicodeStrToAsciiStr(SkuNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); UnicodeStrToAsciiStr(FamilyName, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen +1); // // Now we have got the full smbios record, call smbios protocol to add this record. // SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; Status = Smbios-> Add( Smbios, NULL, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord ); FreePool(SmbiosRecord); return Status; }
/** Install HII Config Access protocol for network device and allocate resource. @param[in] Instance The IP4 Config instance. @retval EFI_SUCCESS The HII Config Access protocol is installed. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. @retval Others Other errors as indicated. **/ EFI_STATUS Ip4ConfigDeviceInit ( IN IP4_CONFIG_INSTANCE *Instance ) { EFI_STATUS Status; EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; VENDOR_DEVICE_PATH VendorDeviceNode; EFI_SERVICE_BINDING_PROTOCOL *MnpSb; CHAR16 *MacString; CHAR16 MenuString[128]; CHAR16 PortString[128]; CHAR16 *OldMenuString; ConfigAccess = &Instance->HiiConfigAccessProtocol; ConfigAccess->ExtractConfig = Ip4DeviceExtractConfig; ConfigAccess->RouteConfig = Ip4DeviceRouteConfig; ConfigAccess->Callback = Ip4FormCallback; // // Construct device path node for EFI HII Config Access protocol, // which consists of controller physical device path and one hardware // vendor guid node. // ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH)); VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH; VendorDeviceNode.Header.SubType = HW_VENDOR_DP; CopyGuid (&VendorDeviceNode.Guid, &gEfiNicIp4ConfigVariableGuid); SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH)); Instance->HiiVendorDevicePath = AppendDevicePathNode ( Instance->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode ); Instance->ChildHandle = NULL; // // Install Device Path Protocol and Config Access protocol on new handle // Status = gBS->InstallMultipleProtocolInterfaces ( &Instance->ChildHandle, &gEfiDevicePathProtocolGuid, Instance->HiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, ConfigAccess, NULL ); if (!EFI_ERROR (Status)) { // // Open the Parent Handle for the child // Status = gBS->OpenProtocol ( Instance->Controller, &gEfiManagedNetworkServiceBindingProtocolGuid, (VOID **) &MnpSb, Instance->Image, Instance->ChildHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); } ASSERT_EFI_ERROR (Status); // // Publish our HII data // Instance->RegisteredHandle = HiiAddPackages ( &mNicIp4ConfigNvDataGuid, Instance->ChildHandle, Ip4ConfigDxeStrings, Ip4ConfigDxeBin, NULL ); if (Instance->RegisteredHandle == NULL) { return EFI_OUT_OF_RESOURCES; } // // Append MAC string in the menu string and tile string // Status = NetLibGetMacString (Instance->Controller, Instance->Image, &MacString); if (!EFI_ERROR (Status)) { OldMenuString = HiiGetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_CONFIG_FORM_TITLE), NULL); UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString); HiiSetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_CONFIG_FORM_TITLE), MenuString, NULL); UnicodeSPrint (PortString, 128, L"MAC:%s", MacString); HiiSetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_DEVICE_FORM_TITLE), PortString, NULL); FreePool (MacString); } return Status; }
/** Install HII Config Access protocol for network device and allocate resource. @param[in, out] Instance The IP4 config2 Instance. @retval EFI_SUCCESS The HII Config Access protocol is installed. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. @retval Others Other errors as indicated. **/ EFI_STATUS Ip4Config2FormInit ( IN OUT IP4_CONFIG2_INSTANCE *Instance ) { EFI_STATUS Status; IP4_SERVICE *IpSb; IP4_FORM_CALLBACK_INFO *CallbackInfo; EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; VENDOR_DEVICE_PATH VendorDeviceNode; EFI_SERVICE_BINDING_PROTOCOL *MnpSb; CHAR16 *MacString; CHAR16 MenuString[128]; CHAR16 PortString[128]; CHAR16 *OldMenuString; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance); ASSERT (IpSb != NULL); CallbackInfo = &Instance->CallbackInfo; CallbackInfo->Signature = IP4_FORM_CALLBACK_INFO_SIGNATURE; Status = gBS->HandleProtocol ( IpSb->Controller, &gEfiDevicePathProtocolGuid, (VOID **) &ParentDevicePath ); if (EFI_ERROR (Status)) { return Status; } // // Construct device path node for EFI HII Config Access protocol, // which consists of controller physical device path and one hardware // vendor guid node. // ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH)); VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH; VendorDeviceNode.Header.SubType = HW_VENDOR_DP; CopyGuid (&VendorDeviceNode.Guid, &gEfiCallerIdGuid); SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH)); CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode ( ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode ); if (CallbackInfo->HiiVendorDevicePath == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Error; } ConfigAccess = &CallbackInfo->HiiConfigAccessProtocol; ConfigAccess->ExtractConfig = Ip4FormExtractConfig; ConfigAccess->RouteConfig = Ip4FormRouteConfig; ConfigAccess->Callback = Ip4FormCallback; // // Install Device Path Protocol and Config Access protocol on new handle // Status = gBS->InstallMultipleProtocolInterfaces ( &CallbackInfo->ChildHandle, &gEfiDevicePathProtocolGuid, CallbackInfo->HiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, ConfigAccess, NULL ); if (!EFI_ERROR (Status)) { // // Open the Parent Handle for the child // Status = gBS->OpenProtocol ( IpSb->Controller, &gEfiManagedNetworkServiceBindingProtocolGuid, (VOID **) &MnpSb, IpSb->Image, CallbackInfo->ChildHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); } if (EFI_ERROR (Status)) { goto Error; } // // Publish our HII data // CallbackInfo->RegisteredHandle = HiiAddPackages ( &gIp4Config2NvDataGuid, CallbackInfo->ChildHandle, Ip4DxeStrings, Ip4Config2Bin, NULL ); if (CallbackInfo->RegisteredHandle == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Error; } // // Append MAC string in the menu help string and tile help string // Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &MacString); if (!EFI_ERROR (Status)) { OldMenuString = HiiGetString ( CallbackInfo->RegisteredHandle, STRING_TOKEN (STR_IP4_CONFIG2_FORM_HELP), NULL ); UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString); HiiSetString ( CallbackInfo->RegisteredHandle, STRING_TOKEN (STR_IP4_CONFIG2_FORM_HELP), MenuString, NULL ); UnicodeSPrint (PortString, 128, L"MAC:%s", MacString); HiiSetString ( CallbackInfo->RegisteredHandle, STRING_TOKEN (STR_IP4_DEVICE_FORM_HELP), PortString, NULL ); FreePool (MacString); FreePool (OldMenuString); return EFI_SUCCESS; } Error: Ip4Config2FormUnload (Instance); return Status; }
/** Initialize the configuration form. @param[in] Private Pointer to the driver private data. @retval EFI_SUCCESS The configuration form is initialized. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. **/ EFI_STATUS HttpBootConfigFormInit ( IN HTTP_BOOT_PRIVATE_DATA *Private ) { EFI_STATUS Status; HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo; VENDOR_DEVICE_PATH VendorDeviceNode; EFI_SERVICE_BINDING_PROTOCOL *HttpSb; CHAR16 *MacString; CHAR16 *OldMenuString; CHAR16 MenuString[128]; CallbackInfo = &Private->CallbackInfo; if (CallbackInfo->Initilized) { return EFI_SUCCESS; } CallbackInfo->Signature = HTTP_BOOT_FORM_CALLBACK_INFO_SIGNATURE; // // Construct device path node for EFI HII Config Access protocol, // which consists of controller physical device path and one hardware // vendor guid node. // ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH)); VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH; VendorDeviceNode.Header.SubType = HW_VENDOR_DP; CopyGuid (&VendorDeviceNode.Guid, &gEfiCallerIdGuid); SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH)); CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode ( Private->ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode ); if (CallbackInfo->HiiVendorDevicePath == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Error; } CallbackInfo->ConfigAccess.ExtractConfig = HttpBootFormExtractConfig; CallbackInfo->ConfigAccess.RouteConfig = HttpBootFormRouteConfig; CallbackInfo->ConfigAccess.Callback = HttpBootFormCallback; // // Install Device Path Protocol and Config Access protocol to driver handle. // Status = gBS->InstallMultipleProtocolInterfaces ( &CallbackInfo->ChildHandle, &gEfiDevicePathProtocolGuid, CallbackInfo->HiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &CallbackInfo->ConfigAccess, NULL ); if (!EFI_ERROR (Status)) { // // Open the Parent Handle for the child // Status = gBS->OpenProtocol ( Private->Controller, &gEfiHttpServiceBindingProtocolGuid, (VOID **) &HttpSb, Private->Image, CallbackInfo->ChildHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); } if (EFI_ERROR (Status)) { goto Error; } // // Publish our HII data. // CallbackInfo->RegisteredHandle = HiiAddPackages ( &gHttpBootConfigGuid, CallbackInfo->ChildHandle, HttpBootDxeStrings, HttpBootConfigVfrBin, NULL ); if (CallbackInfo->RegisteredHandle == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Error; } // // Append MAC string in the menu help string // Status = NetLibGetMacString (Private->Controller, Private->Image, &MacString); if (!EFI_ERROR (Status)) { OldMenuString = HiiGetString ( CallbackInfo->RegisteredHandle, STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP), NULL ); UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString); HiiSetString ( CallbackInfo->RegisteredHandle, STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP), MenuString, NULL ); FreePool (MacString); FreePool (OldMenuString); return EFI_SUCCESS; } Error: HttpBootConfigFormUnload (Private); return Status; }