From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in6.apple.com (mail-out6.apple.com [17.151.62.28]) (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 6A2F882303 for ; Wed, 21 Dec 2016 11:13:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1482347595; 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=PFOiNiqUu+AOwvW9eQNJWBhUq0fBADK+8AJG4QzsukM=; b=W0LH2RrnZ2xFfKRvHpwjZezfxhtDTUqUWc+6kI71tWAfgWoWUG73QKGOefy/Z8g8 nccm8v2H/aoPnlM7LkdcdU838JQIy7zpHG47VGhxstmeGSweNxFJoIzyGXg6dyRj ElTjyLCJavuFHBgVYJ+l6m+jE9X3Ypx0nocw8/fxNrad+XdMIo90TRWW+aD2uHMH BxQfmzKzO5U3LJTSNWSKuPsq7Q58/cGoVtZkQHwv/9hFnGWg3Wu9HtmLImlkNtHF xKmBG1twQ0WWvO0gv/GKrv8dWYLb5HcKfuu/RPSgAMbVONNwxMvo+1bADgYi1M40 /BkJJ6NsT07xjJLnxDCTCA==; Received: from relay5.apple.com (relay5.apple.com [17.128.113.88]) by mail-in6.apple.com (Apple Secure Mail Relay) with SMTP id 17.0E.07408.B44DA585; Wed, 21 Dec 2016 11:13:15 -0800 (PST) X-AuditID: 11973e15-bb6989a000001cf0-09-585ad44b9fb1 Received: from nwk-mmpp-sz11.apple.com (nwk-mmpp-sz11.apple.com [17.128.115.155]) by relay5.apple.com (Apple SCV relay) with SMTP id 3F.C9.27929.B44DA585; Wed, 21 Dec 2016 11:13:15 -0800 (PST) MIME-version: 1.0 Received: from [17.153.27.116] by nwk-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.1.1.0 64bit (built Jun 15 2016)) with ESMTPSA id <0OIJ00FSFUQ2W910@nwk-mmpp-sz11.apple.com>; Wed, 21 Dec 2016 11:13:15 -0800 (PST) Sender: afish@apple.com From: Andrew Fish Message-id: <81635FDE-FDD2-4913-B142-A26340D319D6@apple.com> Date: Wed, 21 Dec 2016 11:13:14 -0800 In-reply-to: Cc: "edk2-devel@lists.01.org" To: GN Keshava References: X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsUi2FAYoet9JSrCYMEKS4s9h44yW7R/aWF1 YPLYOesuu0f37H8sAUxRXDYpqTmZZalF+nYJXBnXzs5hKuhdzVSx/2FWA+PGdqYuRk4OCQET iWdzzjKD2EICexklFq0XhImv+tDC0sXIBRQ/xCgxYf5xdpAEr4CgxI/J91hAbGaBMIlvO6+y QjS/Y5R4sCAfxBYWEJd4d2YT2FA2AWWJFfM/QPXaSCz/MI0JoiZS4v7vU2A2i4CqxLQHh8Bs ToFgibuvOpkh5ptLzLjwBSwuAlTz/ucGJohdARKrZ2wEmskBdKisxOxfXiB3SgicYZN4cuUH 0wRGoVlITp2F5FQIW0vi+6NWoDgHkC0vcfC8LERYU+LZvU/sELa2xJN3F1gXMLKtYhTKTczM 0c3MM9NLLCjISdVLzs/dxAiKhOl2ojsYz6yyOsQowMGoxMPrMCUqQog1say4MvcQozQHi5I4 r/WDyAghgfTEktTs1NSC1KL4otKc1OJDjEwcnFINjPenqr9Zu0pLoyTxUEJYI0f5zd45ssvN JWZu2uC5+3anTnFgr+YTTs7Gb9xnXesSQxqOHL77VmgGh3XOtnD1T6u7z5WsTNlqsKHwjmfQ FQPJhXNiI4r2C4SsmqGZq7PjwMvz6c9dMidM1vxYf+y8vdvZqTLCXRPEeg2fnhXcW//v5ZZ7 /78LHFNiKc5INNRiLipOBAB/e1gOZQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsUi2FA8W9f7SlSEQfdnI4s9h44yW7R/aWF1 YPLYOesuu0f37H8sAUxRXDYpqTmZZalF+nYJXBnXzs5hKuhdzVSx/2FWA+PGdqYuRk4OCQET iVUfWlggbDGJC/fWs3UxcnEICRxilJgw/zg7SIJXQFDix+R7YEXMAmES33ZeZQWxhQTeMUo8 WJAPYgsLiEu8O7OJGcRmE1CWWDH/A1SvjcTyD9OYIGoiJe7/PgVmswioSkx7cAjM5hQIlrj7 qpMZYr65xIwLX8DiIkA1739uYILYFSCxesZGoJkcQIfKSsz+5TWBUWAWkutmIbkOwtaS+P6o FSjOAWTLSxw8LwsR1pR4du8TO4StLfHk3QXWBYxsqxgFilJzEitN9RILCnJS9ZLzczcxgkO6 MGIH4/9lVocYBTgYlXh4HaZERQixJpYVV+YCg4iDWUmEN+YCUIg3JbGyKrUoP76oNCe1+BDj REagHycyS4km5wMjLq8k3tDExMDE2NjM2NjcxJyWwkrivBZ8ERFCAumJJanZqakFqUUwRzFx cEo1MM7ZLLP8SHHIn+ciKUz2Ztc6zi5ZvSVH/GTQh/NFp+5NZluqZn9+xv2obbZirfPXqT3c 06Puy/I3bYXWUaFt1pGp7y5yp5yYsnTXR9u05Xw3Yq4eOvBptbYY/6Jbe7983CbLfu9WThrX u7DrV3yiFLimB3002a5kpv3F3f58S1i9euVKgX5PWyslluKMREMt5qLiRADQp5It3AIAAA== X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: LocateHandle for gEfiShellProtocolGuid is failing in my application 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: , X-List-Received-Date: Wed, 21 Dec 2016 19:13:16 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT > On Dec 20, 2016, at 11:32 PM, GN Keshava wrote: > > Hi, > > I'm developing a shell application. A call to LocateHandle for > gEfiShellProtocolGuid is failing with Status 0x0E. > > Below is my code. Please let me know what I'm doing wrong. > Assuming this is your entire code fragment you are passing 2 uninitialized values If you want to probe the size you need to: BufferSize = 0; > Status = gBS->LocateHandle(ByProtocol, &gEfiShellProtocolGuid, NULL, > &BufferSize, Buffer); // Get BufferSize > if (EFI_ERROR(Status)) Per the spec you would expect to get Status = EFI_BUFFER_TOO_SMALL if you need to grow the size. You should only allocate the buffer and retry if you get EFI_BUFFER_TOO_SMALL. You don't handle the case of EFI_NOT_FOUND. FYI the error codes are defined in the UEFI Spec and exist here in the code: https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Base.h /// /// The buffer was not large enough to hold the requested data. /// The required buffer size is returned in the appropriate /// parameter when this error occurs. /// #define RETURN_BUFFER_TOO_SMALL ENCODE_ERROR (5) ... /// /// The item was not found. /// #define RETURN_NOT_FOUND ENCODE_ERROR (14) #define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode))) MAX_BIT is going to be defined as BIT63 or BIT31 depending on the CPU architecture you are using. > Print(L"LocateHandle Status 0x%x\n",Status); > > Status = gBS->AllocatePool(EfiBootServicesData, BufferSize, > (void**)&Buffer); > if (EFI_ERROR(Status)) > Print(L"AllocatePool Status 0x%x\n",Status); > I mentioned in the other mail that you can use %r to get a string for the error. Thanks, Andrew Fish > Status = gBS->LocateHandle(ByProtocol, &gEfiShellProtocolGuid, NULL, > &BufferSize, Buffer); > if (EFI_ERROR(Status)) > Print(L"LocateHandle Status 0x%x\n",Status); > > All calls failing with Status being 0x0E. Please help me to solve this. Is > there any special requirement for using this protocol? > > Thanks. > Regards, > Keshava > ___________________________________