From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in2.apple.com (mail-out2.apple.com [17.151.62.25]) (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 108A021A02920 for ; Thu, 1 Jun 2017 10:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1496338144; 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=j+FOIyo+Lus0nUqHL42Frcds/Zp9yohvSUKXirOYmIg=; b=WOf4TWsY3aNVjEy9P74a23gKB4gev1jinw+Wc5P5q1xJ9/J5Bc4M35LqX5PZE4Di X1LON6JqSn4KSx7/7G2A0XUg6Yv82tjnjRK1eu1OF6/y9JPPbJr21nGLtmmQKgQ5 TfYUMu9JliEF19d8wQgTf6Bv7rkrgF+H/VOnaEZdTn/v+DAVmCKmg16riACbHw6U NmhCf4cAzz5BzPtZRTJrkY0uC51FAEKCAjVWejTVTze4vMpZCAgZxvPjOUauVbm/ JbI9xgJmWLMPGxPEBkjJYJwJHH9cXowaEcEF/u6CPPb0VZcQJn2mzs9GbMjBa0n4 0Dkhcer3CE3FFLpjqXGjaA==; Received: from relay6.apple.com (relay6.apple.com [17.128.113.90]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in2.apple.com (Apple Secure Mail Relay) with SMTP id 37.1F.12614.0EE40395; Thu, 1 Jun 2017 10:29:04 -0700 (PDT) X-AuditID: 11973e11-167519a000003146-de-59304ee04bd2 Received: from nwk-mmpp-sz09.apple.com (nwk-mmpp-sz09.apple.com [17.128.115.80]) by relay6.apple.com (Apple SCV relay) with SMTP id AB.E2.09762.0EE40395; Thu, 1 Jun 2017 10:29:04 -0700 (PDT) MIME-version: 1.0 Received: from da0601a-dhcp124.apple.com (da0601a-dhcp124.apple.com [17.226.15.124]) by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0OQV00DJ9PWFC260@nwk-mmpp-sz09.apple.com>; Thu, 01 Jun 2017 10:29:04 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Thu, 01 Jun 2017 10:29:03 -0700 Cc: "edk2-devel@lists.01.org" Message-id: <19ECB4A0-FFA8-440B-A1B6-79F07BB392F0@apple.com> References: <6B16DFE0-54D1-4CBF-AC56-F255013B6FA5@apple.com> To: Amit kumar X-Mailer: Apple Mail (2.3273) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNLMWRmVeSWpSXmKPExsUi2FAYpfvAzyDSYOczaYt9r3cyWew5dJTZ gcnjcc8ZNo/u2f9YApiiuGxSUnMyy1KL9O0SuDLO93xgKvipUPF501f2BsZlEl2MnBwSAiYS q57uZO9i5OIQEljNJPFx5V0WmMS8h79ZIBIHGSWOvD7DBpLgFRCU+DH5HlCCg4NZQF7i4HlZ kDCzgJbE90etUPVrmSRa93xkBUkIC4hLvDuziRnCtpf49PMdWJxNQFlixfwP7CA2p0C8xLmv 88HmswioSjS9XMMKMdRcYsaFL0wQe20k7r99BRYXEnjCKHGzKQ/EFgGq72+fwg5xtKzErdmX mEGOkBBYwiZx6MZNtgmMwrOQ3D0L4e5ZSO5ewMi8ilEoNzEzRzczz0gvsaAgJ1UvOT93EyMo tKfbCe5gPL7K6hCjAAejEg+vhYJBpBBrYllxZe4hRmkOFiVx3hvyQCGB9MSS1OzU1ILUovii 0pzU4kOMTBycUg2MOxprFfNun8p0/vHE7fuHz8KOL3+ttJmQ/7o8M13+b+vX/Kxj3S5xlWvs b11u81W/ZKxVZsDOw8I1Z67zJ7XDQlU1RwOFp7+58Xeya0Hgz7sX3HR6GCSOvOq2U5w57+SK k1y2Mp3f5I54y5euU75qffrcpwa/emPp5zImh+WOLNtlIWfc4jNRiaU4I9FQi7moOBEAQLUK oU4CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42IRbCgO0H3gZxBpcPWJkMW+1zuZLPYcOsrs wOTxuOcMm0f37H8sAUxRXDYpqTmZZalF+nYJXBnnez4wFfxUqPi86St7A+MyiS5GTg4JAROJ eQ9/s3QxcnEICRxklDjy+gwbSIJXQFDix+R7QAkODmYBeYmD52VBwswCWhLfH7VC1a9lkmjd 85EVJCEsIC7x7swmZgjbXuLTz3dgcTYBZYkV8z+wg9icAvES577OB5vPIqAq0fRyDSvEUHOJ GRe+MEHstZG4//YVWFxI4AmjxM2mPBBbBKi+v30KO8TRshK3Zl9insAoMAvJqbMQTp2F5NQF jMyrGAWKUnMSK830EgsKclL1kvNzNzGCQ7Ewagdjw3KrQ4wCHIxKPLwWCgaRQqyJZcWVuYcY JTiYlUR4j2gChXhTEiurUovy44tKc1KLDzFWAd0/kVlKNDkfGCd5JfGGJiYGJsbGZsbG5ibm VBFWEuc95AW0WSA9sSQ1OzW1ILUIZjkTB6dUA2PTxsbOfZP+aVm9LJ1jEzLhQGLYE4Oe1R6z jhhnXpQ2W6VgdPp7yWITpfpzPS4HpJc8W3E2x91D4MgfSda41TP2iBg8yt9eZfxkX5yZ1Sam f7KLIr7yT420SpniH9Tddcsk4ajQU3E2x9O5Gz2+Sv8S4yyqsn4870zytuaP1VPv/Dwkumrf xSVKLMUZiYZazEXFiQCAg1u4oAIAAA== 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:28:03 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > 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