From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-x231.google.com (mail-lf0-x231.google.com [IPv6:2a00:1450:4010:c07::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 30C108233D for ; Wed, 21 Dec 2016 18:00:38 -0800 (PST) Received: by mail-lf0-x231.google.com with SMTP id t196so109676900lff.3 for ; Wed, 21 Dec 2016 18:00:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DYplAVr7sC08DueCJ1GrBHZ9XTC8mdUVXfRwRVWV7fQ=; b=RGoY60Pe+8AVw37lilAP5TahazhTi4UpgVuNf8yA0v8PRU3hw8wGH50ijMJBDTtW1m NqxJxqOKrRfbq7t1UC7qOBe0AxffV2/3CdMUuHF5Eh8swNkApJdG8Y+P92ZZPfQcXI+2 x3JeYSMbMWsY2BXH11xi4ULwyhfQOID8NG1ZGM1eScv2FMwdsN7Ocvps6NYgZmJVrCZV rq+s0l4d2VHw1trSzXUYI+e9CJLOLKroskrde1O1FRUzolKzguYmeB3Jj1UxSzpuNIIl DdMvK1Af1S6r0ADyncv9YUlccAiaLxIH2udUqf2NCO5hfU2Nu4ndHRaLUYtd4JKlq5BC rw6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DYplAVr7sC08DueCJ1GrBHZ9XTC8mdUVXfRwRVWV7fQ=; b=nu0b8uzQxnYVQ7fKqq6xCmVKSse3ZMAOpYIDDWq8Q7wqoqA+HzPyBM0LS/8sBevWDp t6ZnTBrrla4qN2YPMNaWVE31u3gj8t8JRST4jEHCSXcNL5UhJnApnGwpDDhan0j2zEDe LWSULOgI1Ph2C9POrH/nzklSShQWF6JXWLVaiBkNm1BEYVfrmG8W08tNVHnfoEbkurLv f++EQ8JaGt9LZNq5pLhi8xdgPlKhsW7+Nygvlry/gWS44AqvYBb5j6iY19NWLHpVY7ak 5Ty1fwkcdpapiIih2kEw2tFwS9jYNvH9heZLBw+ARPweqzOJnBz0ptgigkSzKTe/ikn2 ha6Q== X-Gm-Message-State: AIkVDXJCGB12A3Oh8godE23mMqeWldcS/cx4EGDDCOnV1HcimnZecP35ylw8RfAO/jrDQpHVnnqAZ51B6WSBmw== X-Received: by 10.25.211.134 with SMTP id k128mr2898550lfg.118.1482372035957; Wed, 21 Dec 2016 18:00:35 -0800 (PST) MIME-Version: 1.0 References: <81635FDE-FDD2-4913-B142-A26340D319D6@apple.com> In-Reply-To: <81635FDE-FDD2-4913-B142-A26340D319D6@apple.com> From: GN Keshava Date: Thu, 22 Dec 2016 02:00:24 +0000 Message-ID: To: Andrew Fish , "Carsey, Jaben" Cc: edk2-devel@lists.01.org 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: Thu, 22 Dec 2016 02:00:38 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks a lot, Andrew and Jaben. I will check these and get back... Thanks again. :) Regards, Keshava On =E0=B2=97=E0=B3=81=E0=B2=B0=E0=B3=81, =E0=B2=A1=E0=B2=BF=E0=B2=B8=E0=B3= =86=E0=B2=82 22, 2016 12:43 =E0=B2=AA=E0=B3=82=E0=B2=B0=E0=B3=8D=E0=B2=B5= =E0=B2=BE=E0=B2=B9=E0=B3=8D=E0=B2=A8 Andrew Fish wrote: > 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 uninitialize= d > values > > If you want to probe the size you need to: > BufferSize =3D 0; > > Status =3D gBS->LocateHandle(ByProtocol, &gEfiShellProtocolGuid, NULL, > &BufferSize, Buffer); // Get BufferSize > if (EFI_ERROR(Status)) > > > Per the spec you would expect to get Status =3D EFI_BUFFER_TOO_SMALL if y= ou > need to grow the size. You should only allocate the buffer and retry if y= ou > 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 =3D 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 =3D 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. I= s > there any special requirement for using this protocol? > > Thanks. > Regards, > Keshava > > ___________________________________ > > >