/** Unload the driver. @param[in] ImageHandle Handle that identifies the image to evict. @retval EFI_SUCCESS The image has been unloaded. **/ EFI_STATUS EFIAPI PlatformUnload ( IN EFI_HANDLE ImageHandle ) { if (mGopEvent == NULL) { // // The GOP callback ran successfully and unregistered itself. Release the // resources allocated there. // ASSERT (mGopModes != NULL); FreePool (mGopModes); } else { // // Otherwise we need to unregister the callback. // ASSERT (mGopModes == NULL); gBS->CloseEvent (mGopEvent); } // // Release resources allocated by the entry point. // HiiRemovePackages (mInstalledPackages); gBS->UninstallMultipleProtocolInterfaces (ImageHandle, &gEfiDevicePathProtocolGuid, &mPkgDevicePath, &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess, NULL); return EFI_SUCCESS; }
/** Uninstall HII Config Access protocol for network device and free resource. @param[in] Instance The IP4 Config instance. @retval EFI_SUCCESS The HII Config Access protocol is uninstalled. @retval Others Other errors as indicated. **/ EFI_STATUS Ip4ConfigDeviceUnload ( IN IP4_CONFIG_INSTANCE *Instance ) { // // Remove HII package list // HiiRemovePackages (Instance->RegisteredHandle); // // Close the child handle // gBS->CloseProtocol ( Instance->Controller, &gEfiManagedNetworkServiceBindingProtocolGuid, Instance->Image, Instance->ChildHandle ); // // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL // gBS->UninstallMultipleProtocolInterfaces ( Instance->ChildHandle, &gEfiDevicePathProtocolGuid, Instance->HiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &Instance->HiiConfigAccessProtocol, NULL ); return EFI_SUCCESS; }
VOID UninitializeStringSupport ( VOID ) { HiiRemovePackages (gStringPackHandle); }
/** Destructor of Customized Display Library Instance. @param ImageHandle The firmware allocated handle for the EFI image. @param SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The destructor completed successfully. @retval Other value The destructor did not complete successfully. **/ EFI_STATUS EFIAPI LegacyBootMaintUiLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; if (mLegacyBootOptionPrivate->DriverHandle != NULL) { Status = gBS->UninstallMultipleProtocolInterfaces ( mLegacyBootOptionPrivate->DriverHandle, &gEfiDevicePathProtocolGuid, &mLegacyBootOptionHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &mLegacyBootOptionPrivate->ConfigAccess, NULL ); ASSERT_EFI_ERROR (Status); HiiRemovePackages (mLegacyBootOptionPrivate->HiiHandle); FreePool (mLegacyBootOptionPrivate->MaintainMapData); FreePool (mLegacyBootOptionPrivate); } return EFI_SUCCESS; }
/** Remove the installed packages from the HiiDatabase. **/ VOID FreeFrontPage( VOID ) { EFI_STATUS Status; Status = gBS->UninstallMultipleProtocolInterfaces ( gFrontPagePrivate.DriverHandle, &gEfiDevicePathProtocolGuid, &mFrontPageHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &gFrontPagePrivate.ConfigAccess, NULL ); ASSERT_EFI_ERROR (Status); // // Publish our HII data // HiiRemovePackages (gFrontPagePrivate.HiiHandle); if (gFrontPagePrivate.LanguageToken != NULL) { FreePool (gFrontPagePrivate.LanguageToken); gFrontPagePrivate.LanguageToken = NULL; } }
/** This function removes TREE configuration Form. @param[in, out] PrivateData Points to TREE configuration private data. **/ VOID UninstallTrEEConfigForm ( IN OUT TREE_CONFIG_PRIVATE_DATA *PrivateData ) { // // Uninstall HII package list // if (PrivateData->HiiHandle != NULL) { HiiRemovePackages (PrivateData->HiiHandle); PrivateData->HiiHandle = NULL; } // // Uninstall HII Config Access Protocol // if (PrivateData->DriverHandle != NULL) { gBS->UninstallMultipleProtocolInterfaces ( PrivateData->DriverHandle, &gEfiDevicePathProtocolGuid, &mTrEEHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &PrivateData->ConfigAccess, NULL ); PrivateData->DriverHandle = NULL; } FreePool (PrivateData); }
VOID FreeBMPackage( VOID ) { BMM_CALLBACK_DATA *BmmCallbackInfo; if (mStartOpCodeHandle != NULL) { HiiFreeOpCodeHandle (mStartOpCodeHandle); } if (mEndOpCodeHandle != NULL) { HiiFreeOpCodeHandle (mEndOpCodeHandle); } FreeAllMenu (); CleanUpStringDepository (); BmmCallbackInfo = mBmmCallbackInfo; // // Remove our IFR data from HII database // HiiRemovePackages (BmmCallbackInfo->BmmHiiHandle); HiiRemovePackages (BmmCallbackInfo->FeHiiHandle); gBS->UninstallMultipleProtocolInterfaces ( BmmCallbackInfo->FeDriverHandle, &gEfiDevicePathProtocolGuid, &mFeHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &BmmCallbackInfo->FeConfigAccess, NULL ); gBS->UninstallMultipleProtocolInterfaces ( BmmCallbackInfo->BmmDriverHandle, &gEfiDevicePathProtocolGuid, &mBmmHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &BmmCallbackInfo->BmmConfigAccess, NULL ); FreePool (BmmCallbackInfo->LoadContext); FreePool (BmmCallbackInfo); }
/** Destructor for the library. free any resources. @param ImageHandle The image handle of the process. @param SystemTable The EFI System Table pointer. */ EFI_STATUS EFIAPI UefiShellAcpiViewCommandLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { if (gShellAcpiViewHiiHandle != NULL) { HiiRemovePackages (gShellAcpiViewHiiHandle); } return EFI_SUCCESS; }
/** Destructor for the library. free any resources. @param ImageHandle The image handle of the process. @param SystemTable The EFI System Table pointer. **/ EFI_STATUS EFIAPI ShellLevel1CommandsLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { if (gShellLevel1HiiHandle != NULL) { HiiRemovePackages(gShellLevel1HiiHandle); } return (EFI_SUCCESS); }
/** Destructor of Customized Display Library Instance. @param ImageHandle The firmware allocated handle for the EFI image. @param SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The destructor completed successfully. @retval Other value The destructor did not complete successfully. **/ EFI_STATUS EFIAPI CustomizedDisplayLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { HiiRemovePackages(mCDLStringPackHandle); FreeLibStrings (); return EFI_SUCCESS; }
/** This function remove the VLAN configuration Form for a network device. The child handle for HII Config Access protocol will be destroyed. @param[in, out] PrivateData Points to VLAN configuration private data. **/ VOID UninstallVlanConfigForm ( IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData ) { // // Free MAC string // if (PrivateData->MacString != NULL) { FreePool (PrivateData->MacString); PrivateData->MacString = NULL; } // // Uninstall HII package list // if (PrivateData->HiiHandle != NULL) { HiiRemovePackages (PrivateData->HiiHandle); PrivateData->HiiHandle = NULL; } // // End the parent-child relationship. // gBS->CloseProtocol ( PrivateData->ControllerHandle, &gEfiVlanConfigProtocolGuid, PrivateData->ImageHandle, PrivateData->DriverHandle ); // // Uninstall HII Config Access Protocol // if (PrivateData->DriverHandle != NULL) { gBS->UninstallMultipleProtocolInterfaces ( PrivateData->DriverHandle, &gEfiDevicePathProtocolGuid, PrivateData->ChildDevicePath, &gEfiHiiConfigAccessProtocolGuid, &PrivateData->ConfigAccess, NULL ); PrivateData->DriverHandle = NULL; if (PrivateData->ChildDevicePath != NULL) { FreePool (PrivateData->ChildDevicePath); PrivateData->ChildDevicePath = NULL; } } }
/** Destructor for the library. free any resources. @param ImageHandle The image handle of the process. @param SystemTable The EFI System Table pointer. **/ EFI_STATUS EFIAPI UefiShellDebug1CommandsLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { if (gShellDebug1HiiHandle != NULL) { HiiRemovePackages(gShellDebug1HiiHandle); } BcfgLibraryUnregisterBcfgCommand(ImageHandle, SystemTable); return (EFI_SUCCESS); }
EFI_STATUS EFIAPI ShellFUpdateCommandDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { if (gShellFUpdateHiiHandle != NULL) { HiiRemovePackages (gShellFUpdateHiiHandle); } return EFI_SUCCESS; }
/** Unload the configuration form, this includes: delete all the configuration entries, uninstall the form callback protocol, and free the resources used. @param[in] Private Pointer to the driver private data. @retval EFI_SUCCESS The configuration form is unloaded. @retval Others Failed to unload the form. **/ EFI_STATUS HttpBootConfigFormUnload ( IN HTTP_BOOT_PRIVATE_DATA *Private ) { HTTP_BOOT_FORM_CALLBACK_INFO *CallbackInfo; CallbackInfo = &Private->CallbackInfo; if (CallbackInfo->ChildHandle != NULL) { // // Close the child handle // gBS->CloseProtocol ( Private->Controller, &gEfiHttpServiceBindingProtocolGuid, Private->Image, CallbackInfo->ChildHandle ); // // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL // gBS->UninstallMultipleProtocolInterfaces ( CallbackInfo->ChildHandle, &gEfiDevicePathProtocolGuid, CallbackInfo->HiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &CallbackInfo->ConfigAccess, NULL ); CallbackInfo->ChildHandle = NULL; } if (CallbackInfo->HiiVendorDevicePath != NULL) { FreePool (CallbackInfo->HiiVendorDevicePath); CallbackInfo->HiiVendorDevicePath = NULL; } if (CallbackInfo->RegisteredHandle != NULL) { // // Remove HII package list // HiiRemovePackages (CallbackInfo->RegisteredHandle); CallbackInfo->RegisteredHandle = NULL; } return EFI_SUCCESS; }
EFI_STATUS UnLoadFont() { EFI_STATUS Status = 0; EFI_HII_HANDLE * handles = 0; UINT32 i = 0; handles = HiiGetHiiHandles(&gDMFontPackageListGuid); if(handles == 0){ return -1; } while(handles[i] != 0){ HiiRemovePackages( handles[i]); i++; } FreePool(handles); return Status; }
/** Entry point of Tftp standalone application. @param ImageHandle The image handle of the process. @param SystemTable The EFI System Table pointer. @retval EFI_SUCCESS Tftp command is executed sucessfully. @retval EFI_ABORTED HII package was failed to initialize. @retval others Other errors when executing tftp command. **/ EFI_STATUS EFIAPI TftpAppInitialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; mTftpHiiHandle = InitializeHiiPackage (ImageHandle); if (mTftpHiiHandle == NULL) { return EFI_ABORTED; } Status = (EFI_STATUS)RunTftp (ImageHandle, SystemTable); HiiRemovePackages (mTftpHiiHandle); return Status; }
/** Remove the installed packages from the HII Database. **/ VOID FreeBootManager ( VOID ) { EFI_STATUS Status; Status = gBS->UninstallMultipleProtocolInterfaces ( gBootManagerPrivate.DriverHandle, &gEfiDevicePathProtocolGuid, &mBootManagerHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &gBootManagerPrivate.ConfigAccess, NULL ); ASSERT_EFI_ERROR (Status); HiiRemovePackages (gBootManagerPrivate.HiiHandle); }
EFI_STATUS ShellDynCmdRunAxfUninstall ( IN EFI_HANDLE ImageHandle ) { EFI_STATUS Status; if (gRunAxfHiiHandle != NULL) { HiiRemovePackages (gRunAxfHiiHandle); } Status = gBS->UninstallMultipleProtocolInterfaces (ImageHandle, &gEfiShellDynamicCommandProtocolGuid, &mShellDynCmdProtocolRunAxf, NULL); if (EFI_ERROR (Status)) { return Status; } return EFI_SUCCESS; }
/** Unloads the application and its installed protocol. @param[in] ImageHandle Handle that identifies the image to be unloaded. @param[in] SystemTable System Table @retval EFI_SUCCESS The image has been unloaded. **/ EFI_STATUS EFIAPI BootManagerUiLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; Status = gBS->UninstallMultipleProtocolInterfaces ( gBootManagerPrivate.DriverHandle, &gEfiDevicePathProtocolGuid, &mBootManagerHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &gBootManagerPrivate.ConfigAccess, NULL ); ASSERT_EFI_ERROR (Status); HiiRemovePackages (gBootManagerPrivate.HiiHandle); return EFI_SUCCESS; }
/** Unloads the application and its installed protocol. @param ImageHandle Handle that identifies the image to be unloaded. @param SystemTable The system table. @retval EFI_SUCCESS The image has been unloaded. **/ EFI_STATUS EFIAPI BootMaintenanceManagerUiLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { if (mStartOpCodeHandle != NULL) { HiiFreeOpCodeHandle (mStartOpCodeHandle); } if (mEndOpCodeHandle != NULL) { HiiFreeOpCodeHandle (mEndOpCodeHandle); } FreeAllMenu (); // // Remove our IFR data from HII database // HiiRemovePackages (mBmmCallbackInfo->BmmHiiHandle); gBS->UninstallMultipleProtocolInterfaces ( mBmmCallbackInfo->BmmDriverHandle, &gEfiDevicePathProtocolGuid, &mBmmHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &mBmmCallbackInfo->BmmConfigAccess, NULL ); FreePool (mBmmCallbackInfo->LoadContext); return EFI_SUCCESS; }
/** This function remove the VLAN configuration Form for a network device. The child handle for HII Config Access protocol will be destroyed. @param[in, out] PrivateData Points to VLAN configuration private data. @retval EFI_SUCCESS HII Form has been uninstalled successfully. @retval Others Other errors as indicated. **/ EFI_STATUS UninstallVlanConfigForm ( IN OUT VLAN_CONFIG_PRIVATE_DATA *PrivateData ) { EFI_STATUS Status; EFI_VLAN_CONFIG_PROTOCOL *VlanConfig; // // End the parent-child relationship. // Status = gBS->CloseProtocol ( PrivateData->ControllerHandle, &gEfiVlanConfigProtocolGuid, PrivateData->ImageHandle, PrivateData->DriverHandle ); if (EFI_ERROR (Status)) { return Status; } // // Uninstall HII Config Access Protocol // if (PrivateData->DriverHandle != NULL) { Status = gBS->UninstallMultipleProtocolInterfaces ( PrivateData->DriverHandle, &gEfiDevicePathProtocolGuid, PrivateData->ChildDevicePath, &gEfiHiiConfigAccessProtocolGuid, &PrivateData->ConfigAccess, NULL ); if (EFI_ERROR (Status)) { gBS->OpenProtocol ( PrivateData->ControllerHandle, &gEfiVlanConfigProtocolGuid, (VOID **)&VlanConfig, PrivateData->ImageHandle, PrivateData->DriverHandle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); return Status; } PrivateData->DriverHandle = NULL; if (PrivateData->ChildDevicePath != NULL) { FreePool (PrivateData->ChildDevicePath); PrivateData->ChildDevicePath = NULL; } } // // Free MAC string // if (PrivateData->MacString != NULL) { FreePool (PrivateData->MacString); PrivateData->MacString = NULL; } // // Uninstall HII package list // if (PrivateData->HiiHandle != NULL) { HiiRemovePackages (PrivateData->HiiHandle); PrivateData->HiiHandle = NULL; } return EFI_SUCCESS; }
/** This is the declaration of an EFI image entry point. This entry point is the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers, including both device drivers and bus drivers. The entry point for the IfConfig6 application which parses the command line input and calls the IfConfig6 process. @param[in] ImageHandle The image handle of this application. @param[in] SystemTable The pointer to the EFI System Table. @retval EFI_SUCCESS The operation completed successfully. @retval Others Some errors occur. **/ EFI_STATUS EFIAPI IfConfig6Initialize ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; IFCONFIG6_PRIVATE_DATA *Private; LIST_ENTRY *ParamPackage; CONST CHAR16 *ValueStr; ARG_LIST *ArgList; CHAR16 *ProblemParam; CHAR16 *Str; Private = NULL; // // Register our string package with HII and return the handle to it. // mHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, IfConfig6Strings, NULL); ASSERT (mHiiHandle != NULL); Status = ShellCommandLineParseEx (mIfConfig6CheckList, &ParamPackage, &ProblemParam, TRUE, FALSE); if (EFI_ERROR (Status)) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_COMMAND), mHiiHandle, ProblemParam); goto ON_EXIT; } // // To handle no option. // if (!ShellCommandLineGetFlag (ParamPackage, L"-r") && !ShellCommandLineGetFlag (ParamPackage, L"-s") && !ShellCommandLineGetFlag (ParamPackage, L"-?") && !ShellCommandLineGetFlag (ParamPackage, L"-l")) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_LACK_OPTION), mHiiHandle); goto ON_EXIT; } // // To handle conflict options. // if (((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-s"))) || ((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-l"))) || ((ShellCommandLineGetFlag (ParamPackage, L"-r")) && (ShellCommandLineGetFlag (ParamPackage, L"-?"))) || ((ShellCommandLineGetFlag (ParamPackage, L"-s")) && (ShellCommandLineGetFlag (ParamPackage, L"-l"))) || ((ShellCommandLineGetFlag (ParamPackage, L"-s")) && (ShellCommandLineGetFlag (ParamPackage, L"-?"))) || ((ShellCommandLineGetFlag (ParamPackage, L"-l")) && (ShellCommandLineGetFlag (ParamPackage, L"-?")))) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_CONFLICT_OPTIONS), mHiiHandle); goto ON_EXIT; } // // To show the help information of ifconfig6 command. // if (ShellCommandLineGetFlag (ParamPackage, L"-?")) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_HELP), mHiiHandle); goto ON_EXIT; } Status = EFI_INVALID_PARAMETER; Private = AllocateZeroPool (sizeof (IFCONFIG6_PRIVATE_DATA)); if (Private == NULL) { Status = EFI_OUT_OF_RESOURCES; goto ON_EXIT; } InitializeListHead (&Private->IfList); // // To get interface name for the list option. // if (ShellCommandLineGetFlag (ParamPackage, L"-l")) { Private->OpCode = IfConfig6OpList; ValueStr = ShellCommandLineGetValue (ParamPackage, L"-l"); if (ValueStr != NULL) { Str = AllocateCopyPool (StrSize (ValueStr), ValueStr); ASSERT (Str != NULL); Private->IfName = Str; } } // // To get interface name for the clear option. // if (ShellCommandLineGetFlag (ParamPackage, L"-r")) { Private->OpCode = IfConfig6OpClear; ValueStr = ShellCommandLineGetValue (ParamPackage, L"-r"); if (ValueStr != NULL) { Str = AllocateCopyPool (StrSize (ValueStr), ValueStr); ASSERT (Str != NULL); Private->IfName = Str; } } // // To get interface name and corresponding Args for the set option. // if (ShellCommandLineGetFlag (ParamPackage, L"-s")) { ValueStr = ShellCommandLineGetValue (ParamPackage, L"-s"); if (ValueStr == NULL) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_INTERFACE), mHiiHandle); goto ON_EXIT; } // // To split the configuration into multi-section. // ArgList = SplitStrToList (ValueStr, L' '); ASSERT (ArgList != NULL); Private->OpCode = IfConfig6OpSet; Private->IfName = ArgList->Arg; Private->VarArg = ArgList->Next; if (Private->IfName == NULL || Private->VarArg == NULL) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_LACK_COMMAND), mHiiHandle); goto ON_EXIT; } } // // Main process of ifconfig6. // Status = IfConfig6 (Private); ON_EXIT: ShellCommandLineFreeVarList (ParamPackage); HiiRemovePackages (mHiiHandle); if (Private != NULL) IfConfig6Cleanup (Private); return Status; }
/** Initialize the Boot Maintenance Utitliy. @retval EFI_SUCCESS utility ended successfully @retval others contain some errors **/ EFI_STATUS InitializeBM ( VOID ) { EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; BMM_CALLBACK_DATA *BmmCallbackInfo; EFI_STATUS Status; UINT8 *Ptr; Status = EFI_SUCCESS; // // Create CallbackData structures for Driver Callback // BmmCallbackInfo = AllocateZeroPool (sizeof (BMM_CALLBACK_DATA)); if (BmmCallbackInfo == NULL) { return EFI_OUT_OF_RESOURCES; } // // Create LoadOption in BmmCallbackInfo for Driver Callback // Ptr = AllocateZeroPool (sizeof (BM_LOAD_CONTEXT) + sizeof (BM_FILE_CONTEXT) + sizeof (BM_HANDLE_CONTEXT) + sizeof (BM_MENU_ENTRY)); if (Ptr == NULL) { FreePool (BmmCallbackInfo); return EFI_OUT_OF_RESOURCES; } // // Initialize Bmm callback data. // BmmCallbackInfo->LoadContext = (BM_LOAD_CONTEXT *) Ptr; Ptr += sizeof (BM_LOAD_CONTEXT); BmmCallbackInfo->FileContext = (BM_FILE_CONTEXT *) Ptr; Ptr += sizeof (BM_FILE_CONTEXT); BmmCallbackInfo->HandleContext = (BM_HANDLE_CONTEXT *) Ptr; Ptr += sizeof (BM_HANDLE_CONTEXT); BmmCallbackInfo->MenuEntry = (BM_MENU_ENTRY *) Ptr; BmmCallbackInfo->Signature = BMM_CALLBACK_DATA_SIGNATURE; BmmCallbackInfo->BmmConfigAccess.ExtractConfig = BootMaintExtractConfig; BmmCallbackInfo->BmmConfigAccess.RouteConfig = FakeRouteConfig; BmmCallbackInfo->BmmConfigAccess.Callback = BootMaintCallback; BmmCallbackInfo->BmmPreviousPageId = FORM_MAIN_ID; BmmCallbackInfo->BmmCurrentPageId = FORM_MAIN_ID; BmmCallbackInfo->FeConfigAccess.ExtractConfig = FakeExtractConfig; BmmCallbackInfo->FeConfigAccess.RouteConfig = FakeRouteConfig; BmmCallbackInfo->FeConfigAccess.Callback = FileExplorerCallback; BmmCallbackInfo->FeCurrentState = FileExplorerStateInActive; BmmCallbackInfo->FeDisplayContext = FileExplorerDisplayUnknown; // // Install Device Path Protocol and Config Access protocol to driver handle // Status = gBS->InstallMultipleProtocolInterfaces ( &BmmCallbackInfo->BmmDriverHandle, &gEfiDevicePathProtocolGuid, &mBmmHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &BmmCallbackInfo->BmmConfigAccess, NULL ); if (EFI_ERROR (Status)) { goto Exit; } // // Install Device Path Protocol and Config Access protocol to driver handle // Status = gBS->InstallMultipleProtocolInterfaces ( &BmmCallbackInfo->FeDriverHandle, &gEfiDevicePathProtocolGuid, &mFeHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &BmmCallbackInfo->FeConfigAccess, NULL ); if (EFI_ERROR (Status)) { goto Exit; } // // Post our Boot Maint VFR binary to the HII database. // BmmCallbackInfo->BmmHiiHandle = HiiAddPackages ( &gBootMaintFormSetGuid, BmmCallbackInfo->BmmDriverHandle, BmBin, BdsDxeStrings, NULL ); ASSERT (BmmCallbackInfo->BmmHiiHandle != NULL); // // Post our File Explorer VFR binary to the HII database. // BmmCallbackInfo->FeHiiHandle = HiiAddPackages ( &gFileExploreFormSetGuid, BmmCallbackInfo->FeDriverHandle, FEBin, BdsDxeStrings, NULL ); ASSERT (BmmCallbackInfo->FeHiiHandle != NULL); // // Init OpCode Handle and Allocate space for creation of Buffer // mStartOpCodeHandle = HiiAllocateOpCodeHandle (); if (mStartOpCodeHandle == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Exit; } mEndOpCodeHandle = HiiAllocateOpCodeHandle (); if (mEndOpCodeHandle == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Exit; } // // Create Hii Extend Label OpCode as the start opcode // mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mStartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; // // Create Hii Extend Label OpCode as the end opcode // mEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mEndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); mEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; mEndLabel->Number = LABEL_END; InitializeStringDepository (); InitAllMenu (BmmCallbackInfo); CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleInpMenu); CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleOutMenu); CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &ConsoleErrMenu); CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &BootOptionMenu); CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &DriverOptionMenu); CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &TerminalMenu); CreateMenuStringToken (BmmCallbackInfo, BmmCallbackInfo->BmmHiiHandle, &DriverMenu); UpdateBootDelPage (BmmCallbackInfo); UpdateDrvDelPage (BmmCallbackInfo); if (TerminalMenu.MenuNumber > 0) { BmmCallbackInfo->CurrentTerminal = 0; UpdateTerminalPage (BmmCallbackInfo); } Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios); if (!EFI_ERROR (Status)) { RefreshUpdateData (); mStartLabel->Number = FORM_BOOT_LEGACY_DEVICE_ID; // // If LegacyBios Protocol is installed, add 3 tags about legacy boot option // in BootOption form: legacy FD/HD/CD/NET/BEV // HiiCreateGotoOpCode ( mStartOpCodeHandle, FORM_SET_FD_ORDER_ID, STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_FD_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, FORM_SET_FD_ORDER_ID ); HiiCreateGotoOpCode ( mStartOpCodeHandle, FORM_SET_HD_ORDER_ID, STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_HD_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, FORM_SET_HD_ORDER_ID ); HiiCreateGotoOpCode ( mStartOpCodeHandle, FORM_SET_CD_ORDER_ID, STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_CD_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, FORM_SET_CD_ORDER_ID ); HiiCreateGotoOpCode ( mStartOpCodeHandle, FORM_SET_NET_ORDER_ID, STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_NET_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, FORM_SET_NET_ORDER_ID ); HiiCreateGotoOpCode ( mStartOpCodeHandle, FORM_SET_BEV_ORDER_ID, STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE), STRING_TOKEN (STR_FORM_SET_BEV_ORDER_TITLE), EFI_IFR_FLAG_CALLBACK, FORM_SET_BEV_ORDER_ID ); HiiUpdateForm ( BmmCallbackInfo->BmmHiiHandle, &gBootMaintFormSetGuid, FORM_BOOT_SETUP_ID, mStartOpCodeHandle, // Label FORM_BOOT_LEGACY_DEVICE_ID mEndOpCodeHandle // LABEL_END ); } // // Dispatch BMM main formset and File Explorer formset. // FormSetDispatcher (BmmCallbackInfo); // // Remove our IFR data from HII database // HiiRemovePackages (BmmCallbackInfo->BmmHiiHandle); HiiRemovePackages (BmmCallbackInfo->FeHiiHandle); CleanUpStringDepository (); FreeAllMenu (); Exit: if (mStartOpCodeHandle != NULL) { HiiFreeOpCodeHandle (mStartOpCodeHandle); } if (mEndOpCodeHandle != NULL) { HiiFreeOpCodeHandle (mEndOpCodeHandle); } if (BmmCallbackInfo->FeDriverHandle != NULL) { gBS->UninstallMultipleProtocolInterfaces ( BmmCallbackInfo->FeDriverHandle, &gEfiDevicePathProtocolGuid, &mFeHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &BmmCallbackInfo->FeConfigAccess, NULL ); } if (BmmCallbackInfo->BmmDriverHandle != NULL) { gBS->UninstallMultipleProtocolInterfaces ( BmmCallbackInfo->BmmDriverHandle, &gEfiDevicePathProtocolGuid, &mBmmHiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &BmmCallbackInfo->BmmConfigAccess, NULL ); } FreePool (BmmCallbackInfo->LoadContext); FreePool (BmmCallbackInfo); return Status; }
/** The user Entry Point for Application. The user code starts with this function as the real entry point for the image goes into a library that calls this function. @param[in] ImageHandle The firmware allocated handle for the EFI image. @param[in] SystemTable A pointer to the EFI System Table. @retval EFI_SUCCESS The entry point is executed successfully. @retval other Some error occurs when executing this entry point. **/ EFI_STATUS EFIAPI InitializeUserInterface ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_HII_HANDLE HiiHandle; EFI_STATUS Status; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut; UINTN BootTextColumn; UINTN BootTextRow; if (!mModeInitialized) { // // After the console is ready, get current video resolution // and text mode before launching setup at first time. // Status = gBS->HandleProtocol ( gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID**)&GraphicsOutput ); if (EFI_ERROR (Status)) { GraphicsOutput = NULL; } Status = gBS->HandleProtocol ( gST->ConsoleOutHandle, &gEfiSimpleTextOutProtocolGuid, (VOID**)&SimpleTextOut ); if (EFI_ERROR (Status)) { SimpleTextOut = NULL; } if (GraphicsOutput != NULL) { // // Get current video resolution and text mode. // mBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution; mBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution; } if (SimpleTextOut != NULL) { Status = SimpleTextOut->QueryMode ( SimpleTextOut, SimpleTextOut->Mode->Mode, &BootTextColumn, &BootTextRow ); mBootTextModeColumn = (UINT32)BootTextColumn; mBootTextModeRow = (UINT32)BootTextRow; } // // Get user defined text mode for setup. // mSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution); mSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution); mSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn); mSetupTextModeRow = PcdGet32 (PcdSetupConOutRow); mModeInitialized = TRUE; } gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL); gST->ConOut->ClearScreen (gST->ConOut); // // Install customized fonts needed by Front Page // HiiHandle = ExportFonts (); ASSERT (HiiHandle != NULL); InitializeStringSupport (); UiSetConsoleMode (TRUE); UiEntry (FALSE); UiSetConsoleMode (FALSE); UninitializeStringSupport (); HiiRemovePackages (HiiHandle); return EFI_SUCCESS; }
/** Dump performance data. @param[in] ImageHandle The image handle. @param[in] SystemTable The system table. @retval EFI_SUCCESS Command completed successfully. @retval EFI_INVALID_PARAMETER Command usage error. @retval EFI_ABORTED The user aborts the operation. @retval value Unknown error. **/ EFI_STATUS EFIAPI InitializeDp ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { UINT64 Freq; UINT64 Ticker; UINT32 ListIndex; LIST_ENTRY *ParamPackage; CONST CHAR16 *CmdLineArg; EFI_STRING StringPtr; UINTN Number2Display; EFI_STATUS Status; BOOLEAN SummaryMode; BOOLEAN VerboseMode; BOOLEAN AllMode; BOOLEAN RawMode; BOOLEAN TraceMode; BOOLEAN ProfileMode; BOOLEAN ExcludeMode; BOOLEAN CumulativeMode; CONST CHAR16 *CustomCumulativeToken; PERF_CUM_DATA *CustomCumulativeData; EFI_STRING StringDpOptionQh; EFI_STRING StringDpOptionLh; EFI_STRING StringDpOptionUh; EFI_STRING StringDpOptionLv; EFI_STRING StringDpOptionUs; EFI_STRING StringDpOptionLs; EFI_STRING StringDpOptionUa; EFI_STRING StringDpOptionUr; EFI_STRING StringDpOptionUt; EFI_STRING StringDpOptionUp; EFI_STRING StringDpOptionLx; EFI_STRING StringDpOptionLn; EFI_STRING StringDpOptionLt; EFI_STRING StringDpOptionLi; EFI_STRING StringDpOptionLc; SummaryMode = FALSE; VerboseMode = FALSE; AllMode = FALSE; RawMode = FALSE; TraceMode = FALSE; ProfileMode = FALSE; ExcludeMode = FALSE; CumulativeMode = FALSE; CustomCumulativeData = NULL; StringDpOptionQh = NULL; StringDpOptionLh = NULL; StringDpOptionUh = NULL; StringDpOptionLv = NULL; StringDpOptionUs = NULL; StringDpOptionLs = NULL; StringDpOptionUa = NULL; StringDpOptionUr = NULL; StringDpOptionUt = NULL; StringDpOptionUp = NULL; StringDpOptionLx = NULL; StringDpOptionLn = NULL; StringDpOptionLt = NULL; StringDpOptionLi = NULL; StringDpOptionLc = NULL; StringPtr = NULL; // Get DP's entry time as soon as possible. // This is used as the Shell-Phase end time. // Ticker = GetPerformanceCounter (); // Register our string package with HII and return the handle to it. // gHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, DPStrings, NULL); ASSERT (gHiiHandle != NULL); // Initial the command list // InitialShellParamList (); /**************************************************************************** **** Process Command Line arguments **** ****************************************************************************/ Status = ShellCommandLineParse (DpParamList, &ParamPackage, NULL, TRUE); if (EFI_ERROR(Status)) { PrintToken (STRING_TOKEN (STR_DP_INVALID_ARG)); ShowHelp(); } else { StringDpOptionQh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_QH), NULL); StringDpOptionLh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LH), NULL); StringDpOptionUh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UH), NULL); if (ShellCommandLineGetFlag (ParamPackage, StringDpOptionQh) || ShellCommandLineGetFlag (ParamPackage, StringDpOptionLh) || ShellCommandLineGetFlag (ParamPackage, StringDpOptionUh)) { ShowHelp(); } else { StringDpOptionLv = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LV), NULL); StringDpOptionUs = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_US), NULL); StringDpOptionLs = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LS), NULL); StringDpOptionUa = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UA), NULL); StringDpOptionUr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UR), NULL); StringDpOptionUt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UT), NULL); StringDpOptionUp = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UP), NULL); StringDpOptionLx = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LX), NULL); StringDpOptionLn = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LN), NULL); StringDpOptionLt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LT), NULL); StringDpOptionLi = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LI), NULL); StringDpOptionLc = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LC), NULL); // Boolean Options // VerboseMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLv); SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, StringDpOptionUs) || ShellCommandLineGetFlag (ParamPackage, StringDpOptionLs)); AllMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUa); RawMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUr); #if PROFILING_IMPLEMENTED TraceMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUt); ProfileMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUp); #endif // PROFILING_IMPLEMENTED ExcludeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLx); mShowId = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLi); CumulativeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLc); // Options with Values CmdLineArg = ShellCommandLineGetValue (ParamPackage, StringDpOptionLn); if (CmdLineArg == NULL) { Number2Display = DEFAULT_DISPLAYCOUNT; } else { Number2Display = StrDecimalToUintn(CmdLineArg); if (Number2Display == 0) { Number2Display = MAXIMUM_DISPLAYCOUNT; } } CmdLineArg = ShellCommandLineGetValue (ParamPackage, StringDpOptionLt); if (CmdLineArg == NULL) { mInterestThreshold = DEFAULT_THRESHOLD; // 1ms := 1,000 us } else { mInterestThreshold = StrDecimalToUint64(CmdLineArg); } // Handle Flag combinations and default behaviors // If both TraceMode and ProfileMode are FALSE, set them both to TRUE if ((! TraceMode) && (! ProfileMode)) { TraceMode = TRUE; #if PROFILING_IMPLEMENTED ProfileMode = TRUE; #endif // PROFILING_IMPLEMENTED } // // Init the custom cumulative data. // CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, StringDpOptionLc); if (CustomCumulativeToken != NULL) { CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA)); ASSERT (CustomCumulativeData != NULL); CustomCumulativeData->MinDur = 0; CustomCumulativeData->MaxDur = 0; CustomCumulativeData->Count = 0; CustomCumulativeData->Duration = 0; CustomCumulativeData->Name = AllocateZeroPool (StrLen (CustomCumulativeToken) + 1); UnicodeStrToAsciiStr (CustomCumulativeToken, CustomCumulativeData->Name); } /**************************************************************************** **** Timer specific processing **** ****************************************************************************/ // Get the Performance counter characteristics: // Freq = Frequency in Hz // StartCount = Value loaded into the counter when it starts counting // EndCount = Value counter counts to before it needs to be reset // Freq = GetPerformanceCounterProperties (&TimerInfo.StartCount, &TimerInfo.EndCount); // Convert the Frequency from Hz to KHz TimerInfo.Frequency = (UINT32)DivU64x32 (Freq, 1000); // Determine in which direction the performance counter counts. TimerInfo.CountUp = (BOOLEAN) (TimerInfo.EndCount >= TimerInfo.StartCount); /**************************************************************************** **** Print heading **** ****************************************************************************/ // print DP's build version PrintToken (STRING_TOKEN (STR_DP_BUILD_REVISION), DP_MAJOR_VERSION, DP_MINOR_VERSION); // print performance timer characteristics PrintToken (STRING_TOKEN (STR_DP_KHZ), TimerInfo.Frequency); // Print Timer frequency in KHz if ((VerboseMode) && (! RawMode) ) { StringPtr = HiiGetString (gHiiHandle, (EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL); ASSERT (StringPtr != NULL); PrintToken (STRING_TOKEN (STR_DP_TIMER_PROPERTIES), // Print Timer count range and direction StringPtr, TimerInfo.StartCount, TimerInfo.EndCount ); PrintToken (STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mInterestThreshold); } /* ************************************************************************** **** Print Sections based on command line options **** **** Option modes have the following priority: **** v Verbose -- Valid in combination with any other options **** t Threshold -- Modifies All, Raw, and Cooked output **** Default is 0 for All and Raw mode **** Default is DEFAULT_THRESHOLD for "Cooked" mode **** n Number2Display Used by All and Raw mode. Otherwise ignored. **** A All -- R and S options are ignored **** R Raw -- S option is ignored **** s Summary -- Modifies "Cooked" output only **** Cooked (Default) **** **** The All, Raw, and Cooked modes are modified by the Trace and Profile **** options. **** !T && !P := (0) Default, Both are displayed **** T && !P := (1) Only Trace records are displayed **** !T && P := (2) Only Profile records are displayed **** T && P := (3) Same as Default, both are displayed ****************************************************************************/ GatherStatistics (CustomCumulativeData); if (CumulativeMode) { ProcessCumulative (CustomCumulativeData); } else if (AllMode) { if (TraceMode) { Status = DumpAllTrace( Number2Display, ExcludeMode); if (Status == EFI_ABORTED) { goto Done; } } if (ProfileMode) { DumpAllProfile( Number2Display, ExcludeMode); } } else if (RawMode) { if (TraceMode) { Status = DumpRawTrace( Number2Display, ExcludeMode); if (Status == EFI_ABORTED) { goto Done; } } if (ProfileMode) { DumpRawProfile( Number2Display, ExcludeMode); } } else { //------------- Begin Cooked Mode Processing if (TraceMode) { ProcessPhases ( Ticker ); if ( ! SummaryMode) { Status = ProcessHandles ( ExcludeMode); if (Status == EFI_ABORTED) { goto Done; } Status = ProcessPeims (); if (Status == EFI_ABORTED) { goto Done; } Status = ProcessGlobal (); if (Status == EFI_ABORTED) { goto Done; } ProcessCumulative (NULL); } } if (ProfileMode) { DumpAllProfile( Number2Display, ExcludeMode); } } //------------- End of Cooked Mode Processing if ( VerboseMode || SummaryMode) { DumpStatistics(); } } } Done: // // Free the memory allocate from HiiGetString // ListIndex = 0; while (DpParamList[ListIndex].Name != NULL) { FreePool (DpParamList[ListIndex].Name); ListIndex ++; } FreePool (DpParamList); SafeFreePool (StringDpOptionQh); SafeFreePool (StringDpOptionLh); SafeFreePool (StringDpOptionUh); SafeFreePool (StringDpOptionLv); SafeFreePool (StringDpOptionUs); SafeFreePool (StringDpOptionLs); SafeFreePool (StringDpOptionUa); SafeFreePool (StringDpOptionUr); SafeFreePool (StringDpOptionUt); SafeFreePool (StringDpOptionUp); SafeFreePool (StringDpOptionLx); SafeFreePool (StringDpOptionLn); SafeFreePool (StringDpOptionLt); SafeFreePool (StringDpOptionLi); SafeFreePool (StringDpOptionLc); SafeFreePool (StringPtr); SafeFreePool (mPrintTokenBuffer); if (CustomCumulativeData != NULL) { SafeFreePool (CustomCumulativeData->Name); } SafeFreePool (CustomCumulativeData); HiiRemovePackages (gHiiHandle); return Status; }
INTN EFIAPI ShellAppMain ( IN UINTN Argc, IN CHAR16 **Argv ) { EFI_STATUS Status; UINTN Index; UINT32 FileSize; UINT32 BufferSize; UINT8 *FileBuffer; UINT8 *Buffer; EFI_PHYSICAL_ADDRESS Address; UINTN CountOfBlocks; EFI_TPL OldTpl; BOOLEAN ResetRequired; BOOLEAN FlashError; Index = 0; FileSize = 0; BufferSize = 0; FileBuffer = NULL; Buffer = NULL; Address = 0; CountOfBlocks = 0; ResetRequired = FALSE; FlashError = FALSE; Status = EFI_SUCCESS; mInputData.FullFlashUpdate = TRUE; // // Publish our HII data. // HiiHandle = HiiAddPackages ( &gEfiCallerIdGuid, NULL, FirmwareUpdateStrings, NULL ); if (HiiHandle == NULL) { Status = EFI_OUT_OF_RESOURCES; goto Done; } // // Locate the SPI protocol. // Status = gBS->LocateProtocol ( &gEfiSpiProtocolGuid, NULL, (VOID **)&mSpiProtocol ); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_SPI_NOT_FOUND), HiiHandle); return EFI_DEVICE_ERROR; } // // Parse the command line. // Status = ParseCommandLine (Argc, Argv); if (EFI_ERROR (Status)) { PrintHelpInfo (); Status = EFI_SUCCESS; goto Done; } // // Display sign-on information. // PrintToken (STRING_TOKEN (STR_FWUPDATE_FIRMWARE_VOL_UPDATE), HiiHandle); PrintToken (STRING_TOKEN (STR_FWUPDATE_VERSION), HiiHandle); PrintToken (STRING_TOKEN (STR_FWUPDATE_COPYRIGHT), HiiHandle); // // Test to see if the firmware needs to be updated. // if (mInputData.UpdateFromFile) { // // Get the file to use in the update. // PrintToken (STRING_TOKEN (STR_FWUPDATE_READ_FILE), HiiHandle, mInputData.FileName); Status = ReadFileData (mInputData.FileName, &FileBuffer, &FileSize); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_FWUPDATE_READ_FILE_ERROR), HiiHandle, mInputData.FileName); goto Done; } // // Check that the file and flash sizes match. // if (FileSize != PcdGet32 (PcdFlashChipSize)) { PrintToken (STRING_TOKEN (STR_FWUPDATE_SIZE), HiiHandle); Status = EFI_UNSUPPORTED; goto Done; } // // Display flash update information. // PrintToken (STRING_TOKEN (STR_FWUPDATE_UPDATING_FIRMWARE), HiiHandle); // // Update it. // Buffer = FileBuffer; BufferSize = FileSize; Address = PcdGet32 (PcdFlashChipBase); CountOfBlocks = (UINTN) (BufferSize / BLOCK_SIZE); // // Raise TPL to TPL_NOTIFY to block any event handler, // while still allowing RaiseTPL(TPL_NOTIFY) within // output driver during Print(). // OldTpl = gBS->RaiseTPL (TPL_NOTIFY); for (Index = 0; Index < CountOfBlocks; Index++) { // // Handle block based on address and contents. // if (!UpdateBlock (Address)) { DEBUG((EFI_D_INFO, "Skipping block at 0x%lx\n", Address)); } else if (!EFI_ERROR (InternalCompareBlock (Address, Buffer))) { DEBUG((EFI_D_INFO, "Skipping block at 0x%lx (already programmed)\n", Address)); } else { // // Display a dot for each block being updated. // Print (L"."); // // Flag that the flash image will be changed and the system must be rebooted // to use the change. // ResetRequired = TRUE; // // Make updating process uninterruptable, // so that the flash memory area is not accessed by other entities // which may interfere with the updating process. // Status = InternalEraseBlock (Address); ASSERT_EFI_ERROR(Status); if (EFI_ERROR (Status)) { gBS->RestoreTPL (OldTpl); FlashError = TRUE; goto Done; } Status = InternalWriteBlock ( Address, Buffer, (BufferSize > BLOCK_SIZE ? BLOCK_SIZE : BufferSize) ); if (EFI_ERROR (Status)) { gBS->RestoreTPL (OldTpl); FlashError = TRUE; goto Done; } } // // Move to next block to update. // Address += BLOCK_SIZE; Buffer += BLOCK_SIZE; if (BufferSize > BLOCK_SIZE) { BufferSize -= BLOCK_SIZE; } else { BufferSize = 0; } } gBS->RestoreTPL (OldTpl); // // Print result of update. // if (!FlashError) { if (ResetRequired) { Print (L"\n"); PrintToken (STRING_TOKEN (STR_FWUPDATE_UPDATE_SUCCESS), HiiHandle); } else { PrintToken (STRING_TOKEN (STR_FWUPDATE_NO_RESET), HiiHandle); } } else { goto Done; } } // // All flash updates are done so see if the system needs to be reset. // if (ResetRequired && !FlashError) { // // Update successful. // for (Index = 5; Index > 0; Index--) { PrintToken (STRING_TOKEN (STR_FWUPDATE_SHUTDOWN), HiiHandle, Index); gBS->Stall (1000000); } gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL); PrintToken (STRING_TOKEN (STR_FWUPDATE_MANUAL_RESET), HiiHandle); CpuDeadLoop (); } Done: // // Print flash update failure message if error detected. // if (FlashError) { PrintToken (STRING_TOKEN (STR_FWUPDATE_UPDATE_FAILED), HiiHandle, Index); } // // Do cleanup. // if (HiiHandle != NULL) { HiiRemovePackages (HiiHandle); } if (FileBuffer) { gBS->FreePool (FileBuffer); } return Status; }
/** Entry point for this driver. @param[in] ImageHandle Image handle of this driver. @param[in] SystemTable Pointer to SystemTable. @retval EFI_SUCESS Driver has loaded successfully. @retval EFI_OUT_OF_RESOURCES Failed to install HII packages. @return Error codes from lower level functions. **/ EFI_STATUS EFIAPI PlatformInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; ExecutePlatformConfig (); mConfigAccess.ExtractConfig = &ExtractConfig; mConfigAccess.RouteConfig = &RouteConfig; mConfigAccess.Callback = &Callback; // // Declare ourselves suitable for HII communication. // Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle, &gEfiDevicePathProtocolGuid, &mPkgDevicePath, &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess, NULL); if (EFI_ERROR (Status)) { return Status; } // // Publish the HII package list to HII Database. // mInstalledPackages = HiiAddPackages ( &gEfiCallerIdGuid, // PackageListGuid ImageHandle, // associated DeviceHandle PlatformDxeStrings, // 1st package PlatformFormsBin, // 2nd package NULL // terminator ); if (mInstalledPackages == NULL) { Status = EFI_OUT_OF_RESOURCES; goto UninstallProtocols; } Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, &GopInstalled, NULL /* Context */, &mGopEvent); if (EFI_ERROR (Status)) { goto RemovePackages; } Status = gBS->RegisterProtocolNotify (&gEfiGraphicsOutputProtocolGuid, mGopEvent, &mGopTracker); if (EFI_ERROR (Status)) { goto CloseGopEvent; } // // Check already installed GOPs. // Status = gBS->SignalEvent (mGopEvent); ASSERT_EFI_ERROR (Status); return EFI_SUCCESS; CloseGopEvent: gBS->CloseEvent (mGopEvent); RemovePackages: HiiRemovePackages (mInstalledPackages); UninstallProtocols: gBS->UninstallMultipleProtocolInterfaces (ImageHandle, &gEfiDevicePathProtocolGuid, &mPkgDevicePath, &gEfiHiiConfigAccessProtocolGuid, &mConfigAccess, NULL); return Status; }
/** Uninstall the HII Config Access protocol for network devices and free up the resources. @param[in, out] Instance The IP4 config2 instance to unload a form. **/ VOID Ip4Config2FormUnload ( IN OUT IP4_CONFIG2_INSTANCE *Instance ) { IP4_SERVICE *IpSb; IP4_FORM_CALLBACK_INFO *CallbackInfo; IP4_CONFIG2_NVDATA *Ip4NvData; IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance); ASSERT (IpSb != NULL); CallbackInfo = &Instance->CallbackInfo; if (CallbackInfo->ChildHandle != NULL) { // // Close the child handle // gBS->CloseProtocol ( IpSb->Controller, &gEfiManagedNetworkServiceBindingProtocolGuid, IpSb->Image, CallbackInfo->ChildHandle ); // // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL // gBS->UninstallMultipleProtocolInterfaces ( CallbackInfo->ChildHandle, &gEfiDevicePathProtocolGuid, CallbackInfo->HiiVendorDevicePath, &gEfiHiiConfigAccessProtocolGuid, &CallbackInfo->HiiConfigAccessProtocol, NULL ); } if (CallbackInfo->HiiVendorDevicePath != NULL) { FreePool (CallbackInfo->HiiVendorDevicePath); } if (CallbackInfo->RegisteredHandle != NULL) { // // Remove HII package list // HiiRemovePackages (CallbackInfo->RegisteredHandle); } Ip4NvData = &Instance->Ip4NvData; if(Ip4NvData->ManualAddress != NULL) { FreePool(Ip4NvData->ManualAddress); } if(Ip4NvData->GatewayAddress != NULL) { FreePool(Ip4NvData->GatewayAddress); } if(Ip4NvData->DnsAddress != NULL) { FreePool(Ip4NvData->DnsAddress); } Ip4NvData->ManualAddressCount = 0; Ip4NvData->GatewayAddressCount = 0; Ip4NvData->DnsAddressCount = 0; }