From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in4.apple.com (mail-out4.apple.com [17.151.62.26]) (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 139F521A08D89 for ; Thu, 1 Jun 2017 10:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1496338740; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fBekQYGJz9PVVZi4qWuus3ap0kcEHXaB7IbseG9haNs=; b=YAOW2J1Ats+ec7+RlPTXFLUnBh2UlItxy+mtmWtR6O+GNDQEmsjTJwShaU/ZvqEm sjOy5SQ2g3p37QWjNJ30XyAvWxj0ydDk8trphIXGf7nYeepF1kjQpucGiOvZpuc0 /xnp/UZ7/6WBK2/Fy30BH5kewHMzaJK1hdOMBDgL3Q3QfosY4fUVF6ex+yx7+9Va DJngJwhZN4OlziAQx2rmeTi4L/LUMaLySBsAzq+XMEH7BVAtoE+0zEyQUwCHjays KbdmvRtVL8ea665+ZjuMidSfq6byzmLQjJTik3dple7julNXTni7wJ/C+E8gKYOP 03YKULBow9YUaU4yje3gww==; Received: from relay2.apple.com (relay2.apple.com [17.128.113.67]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in4.apple.com (Apple Secure Mail Relay) with SMTP id DB.7D.01052.43150395; Thu, 1 Jun 2017 10:39:00 -0700 (PDT) X-AuditID: 11973e12-7285e9a00000041c-86-593051345c8f Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by relay2.apple.com (Apple SCV relay) with SMTP id 88.9E.07829.33150395; Thu, 1 Jun 2017 10:39:00 -0700 (PDT) MIME-version: 1.0 Received: from da0601a-dhcp124.apple.com (da0601a-dhcp124.apple.com [17.226.15.124]) by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0OQV00736QCZZA60@nwk-mmpp-sz13.apple.com>; Thu, 01 Jun 2017 10:38:59 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish Message-id: <5A5C3E91-A28A-412F-83EC-FCB53DA8EAFA@apple.com> Date: Thu, 01 Jun 2017 10:38:59 -0700 In-reply-to: Cc: "edk2-devel@lists.01.org" To: Amit kumar References: <6B16DFE0-54D1-4CBF-AC56-F255013B6FA5@apple.com> <19ECB4A0-FFA8-440B-A1B6-79F07BB392F0@apple.com> X-Mailer: Apple Mail (2.3273) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRmVeSWpSXmKPExsUi2FDorGsSaBBpcGellMW+1zuZLPYcOsrs wOTxuOcMm0f37H8sAUxRXDYpqTmZZalF+nYJXBm3+5YyF1xYyFixYtI91gbGez2MXYycHBIC JhJ/Vj1m6mLk4hASWM0k8ebDVxaYxKrVn1khEocYJToWQSR4BQQlfky+B2YzC4RJXLg9A6p7 LZPEjQXz2EASwgLiEu/ObGIGsdkElCVWzP/A3sXIAdRsI/FzpgxEib3Ep5/vWEFsFgFVick3 V4LZnALxEnuuP4Gaby4x48IXJhBbBKimv30KO8SuV0wSv0/OYIW4VFbi1uxLzCAJCYEjbBIX v/9kmsAoNAvJsbOQHAtha0l8f9QKFOcAsuUlDp6XhQhrSjy794kdwtaWePLuAusCRrZVjEK5 iZk5upl5JnqJBQU5qXrJ+bmbGEERMd1OaAfjqVVWhxgFOBiVeHgtFAwihVgTy4orcw8xSnOw KInz3pAHCgmkJ5akZqemFqQWxReV5qQWH2Jk4uCUamBcdvKthm752nlS3E3Z5ytEyqef3ZUT 11hctdp+dQSHy5q/7c/vJGqefnAiuWbt46hglu0eguEHTO4f7L76fUbPrjlLb7DsZri5vnWG 1L0H6Tp/Ni88EZ+dscRnhvTKHxuWaPeYrSuTvaHMfvF/+a382Ve0azKT8j4/PjeN5bOaT8g/ 08LPztcTlFiKMxINtZiLihMBo9wKI2kCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRmVeSWpSXmKPExsUi2FB8Q9ck0CDS4Np5dot9r3cyWew5dJTZ gcnjcc8ZNo/u2f9YApiiuGxSUnMyy1KL9O0SuDJu9y1lLriwkLFixaR7rA2M93oYuxg5OSQE TCRWrf7M2sXIxSEkcIhRomPRVxaQBK+AoMSPyffAbGaBMIkLt2cwQRStZZK4sWAeG0hCWEBc 4t2ZTcwgNpuAssSK+R/Yuxg5gJptJH7OlIEosZf49PMdK4jNIqAqMfnmSjCbUyBeYs/1J1Dz zSVmXPjCBGKLANX0t09hh9j1ikni98kZrBCXykrcmn2JeQIj/ywk981Cch+ErSXx/VErUJwD yJaXOHheFiKsKfHs3id2CFtb4sm7C6wLGNlWMQoUpeYkVhrpJRYU5KTqJefnbmIEB3Ch8w7G Y8usDjEKcDAq8fBaKBhECrEmlhVX5gIDiYNZSYT3iCZQiDclsbIqtSg/vqg0J7X4EONERqAv JzJLiSbnA+MrryTe0MTEwMTY2MzY2NzEnJbCSuK8h72ALhJITyxJzU5NLUgtgjmKiYNTqoFx yv9VskJLV3zrrDqjoMv/abv5rUlFKsv2ypxfJmcu5ahot/uxxo6TcQcYRFWnfg810Th+fe+u fScrud/59L7U+1wtuyLZPXaLReP8uqn7BI9x3vpSq52wovhmi4768o/vb/yexM7w35tZRExu v7DwrWbnnywvj7AeXFz/g337zKUF76b57q4+psRSnJFoqMVcVJwIAO8lo3nTAgAA X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: Problem in EFI_BOOT_SERVICES.OpenProtocol() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jun 2017 17:37:59 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT > On Jun 1, 2017, at 10:37 AM, Amit kumar wrote: > > Hello Andrew, > > Thanks for quick reply and acknowledging my query. > Please file a bugzilla against the code. Thanks, Andrew Fish > Amit > From: afish@apple.com > on behalf of Andrew Fish > > Sent: Thursday, June 1, 2017 10:59:03 PM > To: Amit kumar > Cc: edk2-devel@lists.01.org > Subject: Re: [edk2] Problem in EFI_BOOT_SERVICES.OpenProtocol() > > > > On Jun 1, 2017, at 10:13 AM, Amit kumar > wrote: > > > > Hello Andrew, > > > > As per UEFI Spec EFI_ALREADY_STARTED is treated as error code, thus PciIo (The Interface 3rd parameter ) should remain NULL. > > But after OpenProtocol call even though Status = EFI_ALREADY_STARTED PciIo (The Interface 3rd parameter ) is getting modified and it not NULL anymore. > > Is this not a problem ? > > > > Amit, > > I agree it looks like the code will fill in the Interface and return EFI_ALREADY_STARTED. And that does seem to conflict with the section of the spec you quote. Good catch. > > https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Hand/Handle.c#L1097 > // > // This is the protocol interface entry for this protocol > // > if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { > *Interface = Prot->Interface; > } > Status = EFI_SUCCESS; > > ByDriver = FALSE; > Exclusive = FALSE; > for ( Link = Prot->OpenList.ForwardLink; Link != &Prot->OpenList; Link = Link->ForwardLink) { > OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE); > ExactMatch = (BOOLEAN)((OpenData->AgentHandle == ImageHandle) && > (OpenData->Attributes == Attributes) && > (OpenData->ControllerHandle == ControllerHandle)); > if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) { > ByDriver = TRUE; > if (ExactMatch) { > Status = EFI_ALREADY_STARTED; > goto Done; > } > } > if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) != 0) { > Exclusive = TRUE; > } else if (ExactMatch) { > OpenData->OpenCount++; > Status = EFI_SUCCESS; > goto Done; > } > } > > Thanks, > > Andrew Fish > > > Status = gBS->OpenProtocol ( > > Controller, > > &gEfiPciIoProtocolGuid, > > (VOID **) &PciIo, > > This->DriverBindingHandle, > > Controller, > > EFI_OPEN_PROTOCOL_BY_DRIVER > > ); > > > > ________________________________ > > From: afish@apple.com > on behalf of Andrew Fish > > > Sent: Thursday, June 1, 2017 10:28:16 PM > > To: Amit kumar > > Cc: edk2-devel@lists.01.org > > Subject: Re: [edk2] Problem in EFI_BOOT_SERVICES.OpenProtocol() > > > > > >> On Jun 1, 2017, at 9:46 AM, Amit kumar > wrote: > >> > >> Hi, > >> I am trying to open PciIoProtocol and facing some issue. > >> > >> below is the code > >> > >> EFI_PCI_IO_PROTOCOL *PciIo=NULL; > >> EFI_STATUS Status; > >> > >> Status = gBS->OpenProtocol ( > >> Controller, > >> &gEfiPciIoProtocolGuid, > >> (VOID **) &PciIo, > >> This->DriverBindingHandle, > >> Controller, > >> EFI_OPEN_PROTOCOL_BY_DRIVER > >> ); > >> > >> it returns Status = EFI_ALREADY_STARTED, but PciIo is not NULL. > >> Is it not supposed to return PciIo as NULL ? > >> As per UEFI 2.6 Spec Section 6.3 page 182. > >> > > > > Amit, > > > > Look at the Status Codes Returned section at the end of that section. > > > > Attributes is BY_DRIVER and there is an item on the open list with an attribute of BY_DRIVER whose agent handle is the same as AgentHandle. > > > > Attributes is BY_DRIVER|EXCLUSIVE and there is an item on the open list with an attribute of BY_DRIVER|EXCLUSIVE whose agent handle is the same as AgentHandle. > > > > Thanks, > > > > Andrew Fish > > > >> There are a number of reasons that this function call can return an error. If an error is returned, then > >> AgentHandle, ControllerHandle, and Attributes are not added to the list of agents > >> consuming the protocol interface specified by Handle and Protocol, and Interface is > >> returned unmodified. > >> > >> Thanks And Regards > >> Amit > >> _______________________________________________ > >> edk2-devel mailing list > >> edk2-devel@lists.01.org > >> https://lists.01.org/mailman/listinfo/edk2-devel > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel