From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-sn1nam04olkn0801.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe4c::801]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 71D2B21A08D89 for ; Thu, 1 Jun 2017 10:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=oyFgJmv13OrKmtABOj98AFpL94J1puIlFOwyfi8m3xY=; b=syPIFxWYIsCs4CWuGF6F9BKGqv+XD01cYf3xtxecS+mKF/z79w8tAJWwo8iLUYIn2bF+kH7R5RStouXrIMZshAhesOpyDj1Glklemzc9/mt8NL4S5ogLiJqefLSEi2MB1o9e6ZmZDzzD3+nf5Z+irbd/5z94J4phr/mgvxd6AyxT2721ma2oZLSwtDtYGrt6onEQwn6V+rectl3SDnI7962EnXpXEKj165V8jBhHy+uuEXdqeZ4QgIlvcQx2xAgc0NRqFA3Zf2DECyYv24wnOlRmS0TqlScMEX4kN/45CfE3sMIaoUsAmCBLhDM/MqqF9yyXbs2TZybo4uKq3qwfMg== Received: from CO1NAM04FT041.eop-NAM04.prod.protection.outlook.com (10.152.90.52) by CO1NAM04HT087.eop-NAM04.prod.protection.outlook.com (10.152.91.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1101.12; Thu, 1 Jun 2017 17:37:42 +0000 Received: from MWHPR11MB1822.namprd11.prod.outlook.com (10.152.90.56) by CO1NAM04FT041.mail.protection.outlook.com (10.152.91.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.12 via Frontend Transport; Thu, 1 Jun 2017 17:37:42 +0000 Received: from MWHPR11MB1822.namprd11.prod.outlook.com ([10.175.53.137]) by MWHPR11MB1822.namprd11.prod.outlook.com ([10.175.53.137]) with mapi id 15.01.1143.013; Thu, 1 Jun 2017 17:37:42 +0000 From: Amit kumar To: Andrew Fish CC: "edk2-devel@lists.01.org" Thread-Topic: [edk2] Problem in EFI_BOOT_SERVICES.OpenProtocol() Thread-Index: AQHS2vyT277Y/Y6Og0KJQ+TlxF8XXaIQRScG Date: Thu, 1 Jun 2017 17:37:42 +0000 Message-ID: References: <6B16DFE0-54D1-4CBF-AC56-F255013B6FA5@apple.com> , <19ECB4A0-FFA8-440B-A1B6-79F07BB392F0@apple.com> In-Reply-To: <19ECB4A0-FFA8-440B-A1B6-79F07BB392F0@apple.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: apple.com; dkim=none (message not signed) header.d=none;apple.com; dmarc=none action=none header.from=hotmail.com; x-incomingtopheadermarker: OriginalChecksum:2EA0334A9CAC12F453A2FEBBD6A562FD8A3F8AA13E4771440F3604D193D253D7; UpperCasedChecksum:3D2A5AC372C39953989178CB6E701EFB3C9A332157BBEAF47D56B80C1105893E; SizeAsReceived:7483; Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [EJGhHwD3WaLBhIL9tEUB+gQnHXnDLd/rTlVkltpayltV6Gq/OOxb5g==] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CO1NAM04HT087; 24:08nCV1n9WqFTWLH4z8H11qDyiigi7JdKW/xqtaMfPo9laFNJKKdU36GvqBY7kYpQfqZ56zQBm39bQIUpX63Us9EdkMExO4ueZKUNYpjCMnw=; 7:DntEhExpCnLYWkSWAZY0O9sBokcF7a7MtsNRRnjzY3HN9O3dgr4y8ymLtXiiARm6QFdLrGAGMKhBXbY8sCTz9Oiw9dSGyOH2SOUfkGhtqVUPzkijLqL5kfNGav9SXh7XY2/OZADwJRzQn7d5rbk3s1ZTSsGhy+0CWWnuQ7ZOZwaM8gPHJaYis0Xzm9Y1Tr5GAkQFrkRkCAP6bTj4BZb9LXuvDiUFyWdpZjFFxQsQv0gY73Ot4P1Sp9kzlMK3vlQ4lTV7e1KljDJF35TQshtd0PkBYhJhkchXEJ58QSf1dzPXb0JYGmzoBct+R/UQ5f1V x-incomingheadercount: 46 x-eopattributedmessage: 0 x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(7070007)(98901004); DIR:OUT; SFP:1901; SCL:1; SRVR:CO1NAM04HT087; H:MWHPR11MB1822.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-traffictypediagnostic: CO1NAM04HT087: x-ms-office365-filtering-correlation-id: dae5d953-8786-423d-877a-08d4a914e848 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322274)(1603101448)(1601125374)(1701031045); SRVR:CO1NAM04HT087; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(444000031); SRVR:CO1NAM04HT087; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CO1NAM04HT087; x-forefront-prvs: 0325F6C77B spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Jun 2017 17:37:42.6183 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM04HT087 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:36:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello Andrew, Thanks for quick reply and acknowledging my query. 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 =3D EFI_ALREADY_STARTED= PciIo (The Interface 3rd parameter ) is getting modified and it not NULL a= nymore. > Is this not a problem ? > Amit, I agree it looks like the code will fill in the Interface and return EFI_AL= READY_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/Ha= ndle.c#L1097 // // This is the protocol interface entry for this protocol // if (Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { *Interface =3D Prot->Interface; } Status =3D EFI_SUCCESS; ByDriver =3D FALSE; Exclusive =3D FALSE; for ( Link =3D Prot->OpenList.ForwardLink; Link !=3D &Prot->OpenList; Lin= k =3D Link->ForwardLink) { OpenData =3D CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIG= NATURE); ExactMatch =3D (BOOLEAN)((OpenData->AgentHandle =3D=3D ImageHandle) && (OpenData->Attributes =3D=3D Attributes) && (OpenData->ControllerHandle =3D=3D ControllerHa= ndle)); if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) !=3D 0) { ByDriver =3D TRUE; if (ExactMatch) { Status =3D EFI_ALREADY_STARTED; goto Done; } } if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) !=3D 0) { Exclusive =3D TRUE; } else if (ExactMatch) { OpenData->OpenCount++; Status =3D EFI_SUCCESS; goto Done; } } Thanks, Andrew Fish > Status =3D 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=3DNULL; >> EFI_STATUS Status; >> >> Status =3D gBS->OpenProtocol ( >> Controller, >> &gEfiPciIoProtocolGuid, >> (VOID **) &PciIo, >> This->DriverBindingHandle, >> Controller, >> EFI_OPEN_PROTOCOL_BY_DRIVER >> ); >> >> it returns Status =3D 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 att= ribute 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 w= ith an attribute of BY_DRIVER|EXCLUSIVE whose agent handle is the same as A= gentHandle. > > Thanks, > > Andrew Fish > >> There are a number of reasons that this function call can return an erro= r. 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 I= nterface 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