I did that and now I'm getting a #GP. Which is odd because I'm not performing any operation (that I know of) that causes that exception.
Code: Select all
status = UsbGetDescriptor(UsbIo, (USB_DESC_TYPE_CONFIG << 8) | 0, 0, 9, (void*)&Header, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
status = UsbGetDescriptor(UsbIo, (USB_DESC_TYPE_CONFIG << 8) | 0, 0, Header[2] | Header[3] << 8, (void*)&Header, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
Utilizing preprocessor definitions/enumeration discriminants, this translates to:
Code: Select all
status = UsbGetDescriptor(UsbIo, (0x02 << 8) | 0, 0, 9, (void*)&Header, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
status = UsbGetDescriptor(UsbIo, (0x02 << 8) | 0, 0, Header[2] | Header[3] << 8, (void*)&Header, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
Which is then converted to just:
Code: Select all
status = UsbGetDescriptor(UsbIo, 0x200, 0, 9, (void*)&Header, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
status = UsbGetDescriptor(UsbIo, 0x200, 0, Header[2] | Header[3] << 8, (void*)&Header, &UsbStatus);
if (EFI_ERROR(status)) {
st->BootServices->FreePool(Header);
goto failed;
}
The memory allocation doesn't fail -- I have checks in place for that outcome:
Code: Select all
UINT8* Header = 0;
status = st->BootServices->AllocatePool(EfiBootServicesData, 65536, (void*)&Header);
if (EFI_ERROR(status))
goto failed;
This just gets more and more confusing to me.
Edit: Well I'll be damned. I feel stupid now. I was converting the pointer into a UINT8**. So the code was overwriting my app code. Whoops?
Now I just need to fix my bit manipulation stuff in the Print() call because I'm combining the wrong data.