X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FPlatformDriOverrideDxe%2FPlatDriOverrideDxe.c;h=2a684c99dd0f8da79df72ae53b2c86ed8b8056fd;hp=2c1d9d96c5a4634de4885ef13d60e2025e78afe8;hb=284ee2e829ab2453293b7dc4539727ad6c047163;hpb=1d451ff9cf3427c5dc4ba1650d33b1b5aad76d7f diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c index 2c1d9d96c5..2a684c99dd 100644 --- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c @@ -13,8 +13,8 @@ 4. It save all the mapping info in NV variables which will be consumed by platform override protocol driver to publish the platform override protocol. -Copyright (c) 2007 - 2009, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -661,7 +661,7 @@ UpdateBindingDriverSelectPage ( // Switch the item callback key value to its NO. in mDevicePathHandleBuffer // mSelectedCtrIndex = KeyValue - KEY_VALUE_DEVICE_OFFSET; - ASSERT (mSelectedCtrIndex < MAX_CHOICE_NUM); + ASSERT (mSelectedCtrIndex >= 0 && mSelectedCtrIndex < MAX_CHOICE_NUM); mLastSavedDriverImageNum = 0; @@ -1145,7 +1145,7 @@ CommintChanges ( @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_INVALID_PARAMETER Request is illegal syntax, or unknown name. @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver. **/ @@ -1161,25 +1161,73 @@ PlatOverMngrExtractConfig ( EFI_STATUS Status; EFI_CALLBACK_INFO *Private; EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; - - if (Request == NULL) { + EFI_STRING ConfigRequestHdr; + EFI_STRING ConfigRequest; + BOOLEAN AllocatedRequest; + UINTN Size; + UINTN BufferSize; + + if (Progress == NULL || Results == NULL) { + return EFI_INVALID_PARAMETER; + } + + *Progress = Request; + if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mPlatformOverridesManagerGuid, mVariableName)) { return EFI_NOT_FOUND; } - Private = EFI_CALLBACK_INFO_FROM_THIS (This); + ConfigRequestHdr = NULL; + ConfigRequest = NULL; + Size = 0; + AllocatedRequest = FALSE; + + Private = EFI_CALLBACK_INFO_FROM_THIS (This); HiiConfigRouting = Private->HiiConfigRouting; + 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 template + // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator + // + ConfigRequestHdr = HiiConstructConfigHdr (&mPlatformOverridesManagerGuid, mVariableName, Private->DriverHandle); + Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); + ConfigRequest = AllocateZeroPool (Size); + ASSERT (ConfigRequest != NULL); + AllocatedRequest = TRUE; + BufferSize = sizeof (PLAT_OVER_MNGR_DATA); + UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); + FreePool (ConfigRequestHdr); + } // // Convert buffer data to by helper function BlockToConfig() // Status = HiiConfigRouting->BlockToConfig ( HiiConfigRouting, - Request, + ConfigRequest, (UINT8 *) &Private->FakeNvData, sizeof (PLAT_OVER_MNGR_DATA), 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; } @@ -1210,10 +1258,23 @@ PlatOverMngrRouteConfig ( UINT16 KeyValue; PLAT_OVER_MNGR_DATA *FakeNvData; + if (Configuration == NULL || Progress == NULL) { + return EFI_INVALID_PARAMETER; + } + *Progress = Configuration; + + if (!HiiIsConfigHdrMatch (Configuration, &mPlatformOverridesManagerGuid, mVariableName)) { + return EFI_NOT_FOUND; + } + + *Progress = Configuration + StrLen (Configuration); Private = EFI_CALLBACK_INFO_FROM_THIS (This); FakeNvData = &Private->FakeNvData; - if (HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData)) { - return EFI_NOT_FOUND; + if (!HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData)) { + // + // FakeNvData can't be got from SetupBrowser, which doesn't need to be set. + // + return EFI_SUCCESS; } if (mCurrentPage == FORM_ID_DRIVER) { @@ -1273,75 +1334,82 @@ PlatOverMngrCallback ( EFI_STRING_ID NewStringToken; EFI_INPUT_KEY Key; PLAT_OVER_MNGR_DATA *FakeNvData; - - Private = EFI_CALLBACK_INFO_FROM_THIS (This); - FakeNvData = &Private->FakeNvData; - if (HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData)) { - return EFI_NOT_FOUND; - } - if (KeyValue == KEY_VALUE_DEVICE_REFRESH || - KeyValue == KEY_VALUE_DEVICE_FILTER || - KeyValue == KEY_VALUE_DRIVER_GOTO_PREVIOUS - ) { - UpdateDeviceSelectPage (Private, KeyValue, FakeNvData); - // - // Update page title string - // - NewStringToken = STRING_TOKEN (STR_TITLE); - if (HiiSetString (Private->RegisteredHandle, NewStringToken, L"First, Select the controller by device path", NULL) == 0) { - ASSERT (FALSE); + if (Action == EFI_BROWSER_ACTION_CHANGING) { + Private = EFI_CALLBACK_INFO_FROM_THIS (This); + FakeNvData = &Private->FakeNvData; + if (!HiiGetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData)) { + return EFI_NOT_FOUND; } - } - if (((KeyValue >= KEY_VALUE_DEVICE_OFFSET) && (KeyValue < KEY_VALUE_DEVICE_MAX)) || (KeyValue == KEY_VALUE_ORDER_GOTO_PREVIOUS)) { - if (KeyValue == KEY_VALUE_ORDER_GOTO_PREVIOUS) { - KeyValue = (EFI_QUESTION_ID) (mSelectedCtrIndex + KEY_VALUE_DEVICE_OFFSET); + if (KeyValue == KEY_VALUE_DEVICE_REFRESH || + KeyValue == KEY_VALUE_DEVICE_FILTER || + KeyValue == KEY_VALUE_DRIVER_GOTO_PREVIOUS + ) { + UpdateDeviceSelectPage (Private, KeyValue, FakeNvData); + // + // Update page title string + // + NewStringToken = STRING_TOKEN (STR_TITLE); + if (HiiSetString (Private->RegisteredHandle, NewStringToken, L"First, Select the controller by device path", NULL) == 0) { + ASSERT (FALSE); + } } - UpdateBindingDriverSelectPage (Private, KeyValue, FakeNvData); - // - // Update page title string - // - NewStringToken = STRING_TOKEN (STR_TITLE); - if (HiiSetString (Private->RegisteredHandle, NewStringToken, L"Second, Select drivers for the previous selected controller", NULL) == 0) { - ASSERT (FALSE); + + if (((KeyValue >= KEY_VALUE_DEVICE_OFFSET) && (KeyValue < KEY_VALUE_DEVICE_MAX)) || (KeyValue == KEY_VALUE_ORDER_GOTO_PREVIOUS)) { + if (KeyValue == KEY_VALUE_ORDER_GOTO_PREVIOUS) { + KeyValue = (EFI_QUESTION_ID) (mSelectedCtrIndex + KEY_VALUE_DEVICE_OFFSET); + } + UpdateBindingDriverSelectPage (Private, KeyValue, FakeNvData); + // + // Update page title string + // + NewStringToken = STRING_TOKEN (STR_TITLE); + if (HiiSetString (Private->RegisteredHandle, NewStringToken, L"Second, Select drivers for the previous selected controller", NULL) == 0) { + ASSERT (FALSE); + } } - } - if (KeyValue == KEY_VALUE_DRIVER_GOTO_ORDER) { - UpdatePrioritySelectPage (Private, KeyValue, FakeNvData); - // - // Update page title string - // - NewStringToken = STRING_TOKEN (STR_TITLE); - if (HiiSetString (Private->RegisteredHandle, NewStringToken, L"Finally, Set the priority order for the drivers and save them", NULL) == 0) { - ASSERT (FALSE); + if (KeyValue == KEY_VALUE_DRIVER_GOTO_ORDER) { + UpdatePrioritySelectPage (Private, KeyValue, FakeNvData); + // + // Update page title string + // + NewStringToken = STRING_TOKEN (STR_TITLE); + if (HiiSetString (Private->RegisteredHandle, NewStringToken, L"Finally, Set the priority order for the drivers and save them", NULL) == 0) { + ASSERT (FALSE); + } } - } - if (KeyValue == KEY_VALUE_ORDER_SAVE_AND_EXIT) { - Status = CommintChanges (Private, KeyValue, FakeNvData); - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; - if (EFI_ERROR (Status)) { - CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Single Override Info too large, Saving Error!", NULL); - return EFI_DEVICE_ERROR; + if (KeyValue == KEY_VALUE_ORDER_SAVE_AND_EXIT) { + Status = CommintChanges (Private, KeyValue, FakeNvData); + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; + if (EFI_ERROR (Status)) { + CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Single Override Info too large, Saving Error!", NULL); + return EFI_DEVICE_ERROR; + } } - } - if (KeyValue == KEY_VALUE_DEVICE_CLEAR) { + if (KeyValue == KEY_VALUE_DEVICE_CLEAR) { + // + // Deletes all environment variable(s) that contain the override mappings info + // + FreeMappingDatabase (&mMappingDataBase); + Status = SaveOverridesMapping (&mMappingDataBase); + UpdateDeviceSelectPage (Private, KeyValue, FakeNvData); + } // - // Deletes all environment variable(s) that contain the override mappings info + // Pass changed uncommitted data back to Form Browser // - FreeMappingDatabase (&mMappingDataBase); - Status = SaveOverridesMapping (&mMappingDataBase); - UpdateDeviceSelectPage (Private, KeyValue, FakeNvData); - } + HiiSetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData, NULL); + + return EFI_SUCCESS; + } + // - // Pass changed uncommitted data back to Form Browser + // All other action return unsupported. // - HiiSetBrowserData (&mPlatformOverridesManagerGuid, mVariableName, sizeof (PLAT_OVER_MNGR_DATA), (UINT8 *) FakeNvData, NULL); - - return EFI_SUCCESS; + return EFI_UNSUPPORTED; } /** @@ -1361,10 +1429,9 @@ PlatOverMngrCallback ( returned in DriverImageHandle. @retval EFI_NOT_FOUND A driver override for ControllerHandle was not found. - @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is not a - valid handle. DriverImageHandle is not a handle - that was returned on a previous call to - GetDriver(). + @retval EFI_INVALID_PARAMETER The handle specified by ControllerHandle is NULL. + DriverImageHandle is not a handle that was returned + on a previous call to GetDriver(). **/ EFI_STATUS @@ -1593,26 +1660,7 @@ PlatDriOverrideDxeInit ( return EFI_SUCCESS; Finish: - if (mCallbackInfo->DriverHandle != NULL) { - gBS->UninstallMultipleProtocolInterfaces ( - mCallbackInfo->DriverHandle, - &gEfiDevicePathProtocolGuid, - &mHiiVendorDevicePath, - &gEfiHiiConfigAccessProtocolGuid, - &mCallbackInfo->ConfigAccess, - &gEfiPlatformDriverOverrideProtocolGuid, - &mCallbackInfo->PlatformDriverOverride, - NULL - ); - } - - if (mCallbackInfo->RegisteredHandle != NULL) { - HiiRemovePackages (mCallbackInfo->RegisteredHandle); - } - - if (mCallbackInfo != NULL) { - FreePool (mCallbackInfo); - } + PlatDriOverrideDxeUnload (ImageHandle); return Status; } @@ -1630,6 +1678,8 @@ PlatDriOverrideDxeUnload ( IN EFI_HANDLE ImageHandle ) { + ASSERT (mCallbackInfo != NULL); + if (mCallbackInfo->DriverHandle != NULL) { gBS->UninstallMultipleProtocolInterfaces ( mCallbackInfo->DriverHandle, @@ -1647,9 +1697,7 @@ PlatDriOverrideDxeUnload ( HiiRemovePackages (mCallbackInfo->RegisteredHandle); } - if (mCallbackInfo != NULL) { - FreePool (mCallbackInfo); - } + FreePool (mCallbackInfo); return EFI_SUCCESS; }