From nobody Sat Nov 2 14:26:33 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1487038414821724.7807618889078; Mon, 13 Feb 2017 18:13:34 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 355B68206F; Mon, 13 Feb 2017 18:13:33 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E991E81FC3 for ; Mon, 13 Feb 2017 18:13:31 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2017 18:13:31 -0800 Received: from shwdeopenpsi011.ccr.corp.intel.com (HELO SHWDEOPENPSI011.local) ([10.239.9.8]) by FMSMGA003.fm.intel.com with SMTP; 13 Feb 2017 18:13:30 -0800 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,158,1484035200"; d="scan'208";a="820568682" Date: Tue, 14 Feb 2017 10:13:31 +0800 From: lushifex To: edk2-devel@lists.01.org Message-ID: X-Mailer: TortoiseGit MIME-Version: 1.0 Subject: [edk2] [Patch][edk2-platforms/devel-MinnowBoard3] Fixed Map-r issue. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: , david.wei@intel.com Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: lushifex Reviewed-by: David Wei --- .../SouthCluster/Include/MediaDeviceDriver.h | 22 ++- .../Sdio/Dxe/MMC/MmcMediaDeviceDxe/MMCSDTransfer.c | 4 +- .../Dxe/MMC/MmcMediaDeviceDxe/MediaDeviceDriver.c | 219 ++++++++++++++---= ---- 3 files changed, 169 insertions(+), 76 deletions(-) diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/MediaDevi= ceDriver.h b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/MediaDevi= ceDriver.h index 243ee9a..1c9ad1c 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/MediaDeviceDrive= r.h +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/MediaDeviceDrive= r.h @@ -1,7 +1,7 @@ /** @file Media Device Driver header. =20 - Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -172,6 +172,7 @@ MediaDeviceDriverEntryPoint ( /** MediaDeviceDriverInstallBlockIo =20 + @param[in] This @param[in] CardData =20 @retval EFI_STATUS @@ -179,23 +180,38 @@ MediaDeviceDriverEntryPoint ( **/ EFI_STATUS MediaDeviceDriverInstallBlockIo ( - IN CARD_DATA *CardData + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN CARD_DATA *CardData ); =20 /** MediaDeviceDriverUninstallBlockIo =20 + @param[in] This @param[in] CardData + @param[in] Handle =20 @retval EFI_STATUS =20 **/ EFI_STATUS MediaDeviceDriverUninstallBlockIo ( - IN CARD_DATA *CardData + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN CARD_DATA *CardData, + IN EFI_HANDLE Handle ); =20 /** + MediaDeviceDriverAllPartitionNotPresent + + @param[in] CardData + +**/ +BOOLEAN +MediaDeviceDriverAllPartitionNotPresent ( + IN CARD_DATA *CardData + ); +/** MediaDeviceComponentNameGetDriverName =20 @param[in] This diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcM= ediaDeviceDxe/MMCSDTransfer.c b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluste= r/Sdio/Dxe/MMC/MmcMediaDeviceDxe/MMCSDTransfer.c index a6280a5..d367326 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcMediaDev= iceDxe/MMCSDTransfer.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcMediaDev= iceDxe/MMCSDTransfer.c @@ -1,7 +1,7 @@ /** @file SMMC transfer specific functions. =20 - Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -2268,7 +2268,7 @@ SetEmmcWpOnEvent( // // Enable the eMMC protection // - if (TRUE) { + if (FALSE) { if (!WriteProtectDone) { Status =3D MmcReadExtCsd (CardData); if (EFI_ERROR (Status)) { diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcM= ediaDeviceDxe/MediaDeviceDriver.c b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCl= uster/Sdio/Dxe/MMC/MmcMediaDeviceDxe/MediaDeviceDriver.c index 36c6e13..7f5bd11 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcMediaDev= iceDxe/MediaDeviceDriver.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Sdio/Dxe/MMC/MmcMediaDev= iceDxe/MediaDeviceDriver.c @@ -1,7 +1,7 @@ /** @file UEFI Driver Entry and Binding support. =20 - Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -28,6 +28,7 @@ EFI_DRIVER_BINDING_PROTOCOL gMediaDeviceDriverBinding =3D= { NULL }; =20 +EFI_EMMC_CARD_INFO_PROTOCOL *gEfiEmmcCardInfo =3D NULL; =20 /** Entry point for EFI drivers. @@ -229,7 +230,7 @@ MediaDeviceDriverBindingStart ( } =20 =20 - Status =3D MediaDeviceDriverInstallBlockIo (CardData); + Status =3D MediaDeviceDriverInstallBlockIo (This, CardData); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "MediaDeviceDriverBindingStart: Fail to install g= EfiBlockIoProtocolGuid \n")); goto Exit; @@ -246,7 +247,20 @@ MediaDeviceDriverBindingStart ( ); if (EFI_ERROR (Status)) { Status =3D EFI_OUT_OF_RESOURCES; - MediaDeviceDriverUninstallBlockIo (CardData); + for (Loop =3D 0; Loop < MAX_NUMBER_OF_PARTITIONS; Loop++) { + if (!CardData->Partitions[Loop].Present) { + continue; + } + gBS->UninstallMultipleProtocolInterfaces ( + CardData->Partitions[Loop].Handle, + &gEfiBlockIoProtocolGuid, + &CardData->Partitions[Loop].BlockIo, + &gEfiDevicePathProtocolGuid, + CardData->Partitions[Loop].DevPath, + NULL + ); + } + goto Exit; } if (EfiEmmcCardInfoRegister !=3D NULL) { =20 @@ -263,9 +277,24 @@ MediaDeviceDriverBindingStart ( ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "MediaDeviceDriverBindingStart: Install eMMC Ca= rd info protocol failed\n")); - MediaDeviceDriverUninstallBlockIo (CardData); + for (Loop =3D 0; Loop < MAX_NUMBER_OF_PARTITIONS; Loop++) { + if (!CardData->Partitions[Loop].Present) { + continue; + } + gBS->UninstallMultipleProtocolInterfaces ( + CardData->Partitions[Loop].Handle, + &gEfiBlockIoProtocolGuid, + &CardData->Partitions[Loop].BlockIo, + &gEfiDevicePathProtocolGuid, + CardData->Partitions[Loop].DevPath, + NULL + ); + } + goto Exit; } + + gEfiEmmcCardInfo =3D EfiEmmcCardInfoRegister; } =20 DEBUG ((DEBUG_INFO, "MediaDeviceDriverBindingStart: Started\n")); @@ -275,7 +304,7 @@ Exit: DEBUG ((EFI_D_ERROR, "MediaDeviceDriverBindingStart: End with failure\= n")); if (CardData !=3D NULL && MmcHostIo !=3D NULL) { if (CardData->RawBufferPointer !=3D NULL) { - gBS->FreePages ((EFI_PHYSICAL_ADDRESS) CardData->RawBufferPointer,= EFI_SIZE_TO_PAGES (MmcHostIo->HostCapability.BoundarySize * 2)); + gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) CardData->RawBuffer= Pointer, EFI_SIZE_TO_PAGES (MmcHostIo->HostCapability.BoundarySize * 2)); } FreePool (CardData); } @@ -314,70 +343,102 @@ MediaDeviceDriverBindingStop ( { EFI_STATUS Status; CARD_DATA *CardData; - EFI_BLOCK_IO_PROTOCOL *BlockIo; + BOOLEAN AllChildrenStopped; + UINTN Index; + UINTN Pages =3D 0; =20 - // - // First find BlockIo Protocol - // - Status =3D gBS->OpenProtocol ( - Controller, - &gEfiBlockIoProtocolGuid, - (VOID**) &BlockIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); + Status =3D EFI_SUCCESS; + CardData =3D gEfiEmmcCardInfo->CardData; =20 - if (EFI_ERROR (Status)) { - return Status; - } + if (NumberOfChildren =3D=3D 0) { + Status =3D gBS->UninstallMultipleProtocolInterfaces ( + Controller, + &gEfiEmmcCardInfoProtocolGuid, + gEfiEmmcCardInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "MediaDeviceDriverBindingStop: UNINSTALL gEfiEm= mcCardInfoProtocolGuid FAILURE\n")); + return Status; + } =20 - gBS->CloseProtocol ( + FreeUnicodeStringTable (CardData->ControllerNameTable); + + Pages =3D (2 * (CardData->MmcHostIo->HostCapability.BoundarySize)); + if (CardData->RawBufferPointer !=3D NULL) { + FreePages (CardData->RawBufferPointer, EFI_SIZE_TO_PAGES(Pages)); + } + + Status =3D gBS->CloseProtocol ( Controller, &gEfiMmcHostIoProtocolGuid, This->DriverBindingHandle, Controller ); =20 - CardData =3D CARD_DATA_FROM_THIS (BlockIo); + if (MediaDeviceDriverAllPartitionNotPresent(CardData)) { + FreePool (CardData); + FreePool (gEfiEmmcCardInfo); + gEfiEmmcCardInfo =3D NULL; + } =20 - // - // Uninstall Block I/O protocol from the device handle - // - Status =3D MediaDeviceDriverUninstallBlockIo (CardData); - if (EFI_ERROR (Status)) { return Status; } =20 - if (CardData !=3D NULL) { - FreeUnicodeStringTable (CardData->ControllerNameTable); - if (CardData->RawBufferPointer !=3D NULL) { - FreePool (CardData->RawBufferPointer); + AllChildrenStopped =3D TRUE; + for (Index =3D 0; Index < NumberOfChildren; Index++) { + Status =3D MediaDeviceDriverUninstallBlockIo(This, CardData, ChildHand= leBuffer[Index]); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "MediaDeviceDriverBindingStop: UNINSTALL block = io FAILURE\n")); + AllChildrenStopped =3D FALSE; + break; } - FreePool (CardData); } =20 return Status; } =20 =20 +BOOLEAN +MediaDeviceDriverAllPartitionNotPresent ( + IN CARD_DATA *CardData + ) +{ + BOOLEAN AllPartitionNotPresent; + UINTN Loop; + MMC_PARTITION_DATA *Partition; + + Partition =3D CardData->Partitions; + + AllPartitionNotPresent =3D TRUE; + + for (Loop =3D 0; Loop < MAX_NUMBER_OF_PARTITIONS; Partition++, Loop++) { + if (Partition->Present) { + AllPartitionNotPresent =3D FALSE; + break; + } + } + + return AllPartitionNotPresent; +} + + STATIC struct { - CONTROLLER_DEVICE_PATH Controller; + DEVICE_LOGICAL_UNIT_DEVICE_PATH LogicalUnit; EFI_DEVICE_PATH_PROTOCOL End; -} ControllerDevPathTemplate =3D { +} EmmcDevPathTemplate =3D { { { - HARDWARE_DEVICE_PATH, - HW_CONTROLLER_DP, + MESSAGING_DEVICE_PATH, + MSG_DEVICE_LOGICAL_UNIT_DP, { - sizeof (CONTROLLER_DEVICE_PATH), + sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH), 0 }, }, 0 }, - { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, @@ -392,6 +453,7 @@ struct { /** MediaDeviceDriverInstallBlockIo =20 + @param[in] This Pointer to the EFI_DRIVER_BINDING_PR= OTOCOL. @param[in] CardData Pointer to CARD_DATA =20 @retval EFI_INVALID_PARAMETER @@ -401,13 +463,15 @@ struct { **/ EFI_STATUS MediaDeviceDriverInstallBlockIo ( - IN CARD_DATA *CardData + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN CARD_DATA *CardData ) { EFI_STATUS Status; - UINTN Loop; + UINT8 Loop; MMC_PARTITION_DATA *Partition; EFI_DEVICE_PATH_PROTOCOL *MainPath; + EFI_MMC_HOST_IO_PROTOCOL *MmcHostIo =3D NULL; =20 Partition =3D CardData->Partitions; =20 @@ -430,13 +494,12 @@ MediaDeviceDriverInstallBlockIo ( Partition->Handle =3D NULL; Partition->CardData =3D CardData; =20 - ControllerDevPathTemplate.Controller.ControllerNumber =3D (UINT32) Loo= p; + EmmcDevPathTemplate.LogicalUnit.Lun =3D Loop; Partition->DevPath =3D AppendDevicePath ( MainPath, - (EFI_DEVICE_PATH_PROTOCOL *) &ControllerDevPathTemplate + (EFI_DEVICE_PATH_PROTOCOL *) &EmmcDevPathTemplate ); - if (Partition->DevPath =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; break; @@ -460,29 +523,16 @@ MediaDeviceDriverInstallBlockIo ( ); =20 // - // Handle Boot partitions + // Open parent controller by child // - if (CardData->CardType =3D=3D MMCCard) { - // - // skip unbootable partitions display on boot manager - // - // Loop [0] OS boot partition - // Loop [1] BIOS LBP1 - // Loop [2] BIOS LBP2 - // Loop [3] GPP1 - // Loop [4] GPP2 - // Loop [5] GPP3 - // Loop [6] GPP4 - // - if (Loop !=3D 0) { - Status =3D gBS->InstallProtocolInterface ( - &(Partition->Handle), - &gEfiUnbootablePartitionGuid, - EFI_NATIVE_INTERFACE, - NULL - ); - } - } + Status =3D gBS->OpenProtocol ( + CardData->Handle, + &gEfiMmcHostIoProtocolGuid, + (VOID **) &MmcHostIo, + This->DriverBindingHandle, + Partition->Handle, + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER + ); } =20 return Status; @@ -492,7 +542,9 @@ MediaDeviceDriverInstallBlockIo ( /** MediaDeviceDriverUninstallBlockIo =20 + @param[in] This Pointer to the EFI_DRIVER_BINDING_P= ROTOCOL. @param[in] CardData Pointer to CARD_DATA + @param[in] Handle Handle of Partition =20 @retval EFI_INVALID_PARAMETER @retval EFI_UNSUPPORTED @@ -501,7 +553,9 @@ MediaDeviceDriverInstallBlockIo ( **/ EFI_STATUS MediaDeviceDriverUninstallBlockIo ( - IN CARD_DATA *CardData + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN CARD_DATA *CardData, + IN EFI_HANDLE Handle ) { EFI_STATUS Status; @@ -512,17 +566,40 @@ MediaDeviceDriverUninstallBlockIo ( Status =3D EFI_SUCCESS; =20 for (Loop =3D 0; Loop < MAX_NUMBER_OF_PARTITIONS; Partition++, Loop++) { - if (!Partition->Present) { - continue; + if (!Partition->Present || Partition->Handle !=3D Handle) { + continue; } =20 - Status =3D gBS->UninstallProtocolInterface ( + // + // Close MmcHostIoProtocol by child + // + Status =3D gBS->CloseProtocol ( + CardData->Handle, + &gEfiMmcHostIoProtocolGuid, + This->DriverBindingHandle, + Partition->Handle + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "CloseProtocol gEfiMmcHostIoProtocolGuid FAILUR= E \n")); + return Status; + } + + Status =3D gBS->UninstallMultipleProtocolInterfaces ( Partition->Handle, &gEfiBlockIoProtocolGuid, - &Partition->BlockIo + &Partition->BlockIo, + &gEfiDevicePathProtocolGuid, + Partition->DevPath, + NULL ); + Partition->Present =3D FALSE; + DEBUG ((EFI_D_ERROR, "MediaDeviceDriverBindingStop gEfiBlockIoProtocol= Guid removed. %x\n", Status)); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "MediaDeviceDriverUninstallBlockIo UNISTALL FAI= LURE \n")); + } + return Status; } =20 - return Status; + return EFI_INVALID_PARAMETER; } =20 --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel