<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 17, 2021, at 10:06 AM, Ethin Probst <<a href="mailto:harlydavidsen@gmail.com" class="">harlydavidsen@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Okay, so I just tried dh -v 7EDE4C18 (that was the handle that I'm<br class="">getting from `HandleBuffer()`) and it says "dh: Handle - '7EDE4C18'<br class="">not found". So I'm definitely confused because that's what<br class="">`HandleBuffer()` is getting me. Should I pre-allocate the buffer?<br class=""><br class=""></div></div></blockquote><div><br class=""></div><div>Ethin,</div><div><br class=""></div><div>The UEFI Shell `dh` command  UI uses handle numbers from 0 - N as hex digits. You have use these abstract values with the `dh` command. For example:  use `dh -v A1` to see the actual handle value for A1 (7EBA9598). You can search handles that contain a specific protocol...</div><div><br class=""></div><div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffff0b" class="">Shell> </span><span style="font-variant-ligatures: no-common-ligatures" class="">dh -p PciIo</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Handle dump by protocol 'PCIIO'</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A1</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(PciRoot(0x0)/Pci(0x0,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A2</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(PciRoot(0x0)/Pci(0x1,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A3</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(PciRoot(0x0)/Pci(0x2,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A4</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(..0)/Pci(0x2,0x0)/Pci(0x0,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A5</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(..0)/Pci(0x2,0x0)/Pci(0x1,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A6</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(..0)/Pci(0x2,0x0)/Pci(0x2,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A7</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(..0)/Pci(0x2,0x0)/Pci(0x3,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A8</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(..0)/Pci(0x2,0x0)/Pci(0x4,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A9</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(..0)/Pci(0x2,0x0)/Pci(0x5,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">AA</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(PciRoot(0x0)/Pci(0x1E,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">AB</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class="">: </span><span style="font-variant-ligatures: no-common-ligatures" class="">DiskIO</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">BlockIO</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">FA920010-6785-4941-B6EC-498C579F160A</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class="">(..)/Pci(0x1E,0x0)/Pci(0x0,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">AC</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">ISAACPI</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(PciRoot(0x0)/Pci(0x1F,0x0)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">AD</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures" class="">(PciRoot(0x0)/Pci(0x1F,0x3)) </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffff0b" class="">Shell> </span><span style="font-variant-ligatures: no-common-ligatures" class="">dh -v A1</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff" class="">A1</span><span style="font-variant-ligatures: no-common-ligatures" class="">: 7EBA9598</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">PCIIO</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">7EBA8AA8</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class="">)</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  Segment #.....: 00</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  Bus #.........: 00</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  Device #......: 00</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  Function #....: 00</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  ROM Size......: 0</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  ROM Location..: 00000000</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  Vendor ID.....: 8086</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  Device ID.....: 29C0</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  Class Code....: 00 00 06</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  Configuration Header :</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">       8680C029070000000000000600000000</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">       00000000000000000000000000000000</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">       000000000000000000000000F41A0011</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">       000000000000000000000000FF000000</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">DevicePath</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">7EBA9E18</span><span style="font-variant-ligatures: no-common-ligatures; color: #b2b2b2" class="">)</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(178, 178, 178); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  PciRoot(0x0)/Pci(0x0,0x0)</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div>Thanks,</div><div><br class=""></div><div>Andrew Fish</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="">On 7/17/21, Ethin Probst <<a href="mailto:harlydavidsen@gmail.com" class="">harlydavidsen@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class="">I mean, possible... The code I'm using to initialize the handle buffer is<br class="">this:<br class=""><br class="">```C<br class="">EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE imageHandle, IN EFI_SYSTEM_TABLE*<br class="">st) {<br class="">  Print(L"Attempting to find USB IO protocol\n");<br class="">  UINTN numHandles = 0;<br class="">  UINTN i = 0;<br class="">  UINT32 UsbStatus = 0;<br class="">  EFI_HANDLE* handles = NULL;<br class="">  EFI_USB_IO_PROTOCOL* UsbIo = NULL;<br class="">  EFI_STATUS status = st->BootServices->LocateHandleBuffer(ByProtocol,<br class="">&gEfiUsbIoProtocolGuid, NULL, &numHandles, &handles);<br class="">  if (EFI_ERROR(status)) {<br class="">    Print(L"Cannot find any handles for USB devices, reason: %r\n",<br class="">status);<br class="">    return EFI_ABORTED;<br class="">  }<br class="">  Print(L"Found %d USB devices; enumerating\n", numHandles);<br class="">  for (; i < numHandles; ++i) {<br class="">    Print(L"Trying to open handle %d (%x)... ", i, handles[i]);<br class="">    status = st->BootServices->OpenProtocol(handles[i],<br class="">&gEfiUsbIoProtocolGuid, (void**)&UsbIo, imageHandle, NULL,<br class="">EFI_OPEN_PROTOCOL_EXCLUSIVE);<br class="">    if (EFI_ERROR(status)) {<br class="">      Print(L"%r, skipping\n", status);<br class="">      continue;<br class="">    }<br class="">    // ...<br class="">```<br class="">I've done my best to follow SEI secure C coding standards, like<br class="">initializing all variables, regardless of type -- e.g. initializing<br class="">pointers to 0/NULL. But I will definitely try that idea.<br class=""><br class="">On 7/17/21, Andrew Fish <<a href="mailto:afish@apple.com" class="">afish@apple.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class=""><br class=""><blockquote type="cite" class="">On Jul 17, 2021, at 9:41 AM, Ethin Probst <<a href="mailto:harlydavidsen@gmail.com" class="">harlydavidsen@gmail.com</a>><br class="">wrote:<br class=""><br class="">Hey all,<br class=""><br class="">So my UsbAudio.efi app has hit a bit of a roadblock. This code:<br class=""><br class="">```C<br class="">   status = st->BootServices->OpenProtocol(handles[i],<br class="">&gEfiUsbIoProtocolGuid, (void**)&UsbIo, imageHandle, NULL,<br class="">EFI_OPEN_PROTOCOL_EXCLUSIVE);<br class="">   if (EFI_ERROR(status)) {<br class="">     Print(L"%r, skipping\n", status);<br class="">     continue;<br class="">   }<br class="">```<br class=""></blockquote><br class="">How are you constructing handle[]? Could it have gotten stale? You could<br class="">print out the value of handle[I] on the failure.<br class=""><br class="">The contents of a handle are not defined, but the current implementation<br class="">is<br class="">a pointer to an IHANDLE internal data structure in the DXE Core. If you<br class="">are<br class="">at the UEFI Shell and you `dh -v <handleNum> it will show the <handleNum><br class="">and the value.<br class=""><br class="">Shell> dh -v 98<br class="">98: 6d5CF18<br class="">….<br class=""><br class="">I think you can `dh -p UsbIo’ to get the list of the UsbIo handles.<br class=""><br class="">So you can poke around and see what is happening on that handle.<br class=""><br class="">I guess the handle[] array could be getting corrupted? So you could check<br class="">for that?<br class=""><br class="">Thanks,<br class=""><br class="">Andrew Fish<br class=""><br class=""><blockquote type="cite" class="">Is giving me EFI_INVALID_PARAMETER and I don’t know why. I don't think<br class="">I'm violating any of its constraints, according to the specification,<br class="">and I haven't touched this code since it was written. It also happens<br class="">irregularly: sometimes it happens on the USB audio streaming device,<br class="">or if I have a device plugged in it might happen on that device, you<br class="">get the idea. But it doesn't consistently fail. Does anybody have any<br class="">idea what's going on?<br class=""><br class="">--<br class="">Signed,<br class="">Ethin D. Probst<br class=""></blockquote><br class=""><br class=""></blockquote><br class=""><br class="">--<br class="">Signed,<br class="">Ethin D. Probst<br class=""><br class=""></blockquote><br class=""><br class="">-- <br class="">Signed,<br class="">Ethin D. Probst<br class=""><br class=""><br class=""><br class=""><br class=""><br class=""></div></div></blockquote></div><br class=""></body></html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr>   Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/77854">View/Reply Online (#77854)</a> |    |  <a target="_blank" href="https://groups.io/mt/84272862/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>