diff options
author | Dmitry Shmidt <dimitrysh@google.com> | 2017-11-27 14:33:42 -0800 |
---|---|---|
committer | Dmitry Shmidt <dimitrysh@google.com> | 2017-11-27 14:33:42 -0800 |
commit | c767e03a897271846ee23a3a8066f5a5b51caff5 (patch) | |
tree | a3ccd632124b4509d16649bcbea8f9296bc1b253 | |
parent | b89f554257ada86b93dc643a8d9df70ebdc0b56a (diff) | |
parent | 1778bb96035b575566aa528570cda0a7c522e305 (diff) | |
download | edk2-o-mr1-iot-preview-6.tar.gz |
Merge remote-tracking branch 'aosp/upstream-hikey-aosp' into bugedkandroid-o-mr1-iot-preview-6o-mr1-iot-preview-6
Change-Id: Ieaf6f2423b5d896b8239b1ca46c01697bf83228e
5 files changed, 60 insertions, 10 deletions
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c index edda0f094..9bab41b0e 100644 --- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c @@ -163,6 +163,9 @@ HandleDownload ( SEND_LITERAL ("FAILNot enough memory");
} else {
ZeroMem (Response, sizeof Response);
+ if (mTransport->RequestReceive) {
+ mTransport->RequestReceive (mNumDataBytes);
+ }
AsciiSPrint (Response, sizeof Response, "DATA%x",
(UINT32)mNumDataBytes);
mTransport->Send (sizeof Response - 1, Response, &mFatalSendErrorEvent);
@@ -608,6 +611,12 @@ DataReady ( EFI_STATUS Status;
do {
+ // Indicate lower layer driver that how much bytes are expected.
+ if (mState == ExpectDataState) {
+ Size = mNumDataBytes;
+ } else {
+ Size = 0;
+ }
Status = mTransport->Receive (&Size, &Data);
if (!EFI_ERROR (Status)) {
if (mState == ExpectCmdState) {
diff --git a/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c b/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c index e7da1fa5f..eab9a4ed1 100644 --- a/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c +++ b/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c @@ -247,11 +247,24 @@ FastbootTransportUsbReceive ( return EFI_SUCCESS;
}
+EFI_STATUS
+FastbootTransportUsbRequestReceive (
+ IN UINTN BufferSize
+ )
+{
+DEBUG ((DEBUG_ERROR, "#%a, %d, BufferSize:%d\n", __func__, __LINE__, BufferSize));
+ if (mUsbDevice->Request) {
+ return mUsbDevice->Request (BufferSize);
+ }
+ return EFI_SUCCESS;
+}
+
STATIC FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
FastbootTransportUsbStart,
FastbootTransportUsbStop,
FastbootTransportUsbSend,
- FastbootTransportUsbReceive
+ FastbootTransportUsbReceive,
+ FastbootTransportUsbRequestReceive
};
EFI_STATUS
diff --git a/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h b/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h index 807068717..0f7af44d0 100644 --- a/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h +++ b/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h @@ -121,11 +121,18 @@ EFI_STATUS OUT VOID **Buffer
);
+typedef
+EFI_STATUS
+(*FASTBOOT_TRANSPORT_REQUEST_RECEIVE) (
+ IN UINTN BufferSize
+ );
+
typedef struct _FASTBOOT_TRANSPORT_PROTOCOL {
FASTBOOT_TRANSPORT_START Start;
FASTBOOT_TRANSPORT_STOP Stop;
FASTBOOT_TRANSPORT_SEND Send;
FASTBOOT_TRANSPORT_RECEIVE Receive;
+ FASTBOOT_TRANSPORT_REQUEST_RECEIVE RequestReceive;
} FASTBOOT_TRANSPORT_PROTOCOL;
#endif
diff --git a/EmbeddedPkg/Include/Protocol/UsbDevice.h b/EmbeddedPkg/Include/Protocol/UsbDevice.h index 13a48dda0..68fbdc237 100644 --- a/EmbeddedPkg/Include/Protocol/UsbDevice.h +++ b/EmbeddedPkg/Include/Protocol/UsbDevice.h @@ -108,9 +108,16 @@ EFI_STATUS IN USB_DEVICE_TX_CALLBACK TxCallback
);
+typedef
+EFI_STATUS
+(*USB_DEVICE_REQUEST_RECEIVE) (
+ IN UINTN BufferSize
+ );
+
struct _USB_DEVICE_PROTOCOL {
USB_DEVICE_START Start;
USB_DEVICE_SEND Send;
+ USB_DEVICE_REQUEST_RECEIVE Request;
};
typedef struct _USB_DEVICE_PROTOCOL USB_DEVICE_PROTOCOL;
diff --git a/EmbeddedPkg/Library/AbootimgLib/AbootimgLib.c b/EmbeddedPkg/Library/AbootimgLib/AbootimgLib.c index 1cb52ce99..5104a3bb4 100644 --- a/EmbeddedPkg/Library/AbootimgLib/AbootimgLib.c +++ b/EmbeddedPkg/Library/AbootimgLib/AbootimgLib.c @@ -311,10 +311,11 @@ AbootimgBootKernel ( VOID *DwnldKernel; UINTN DwnldKernelSize; EFI_HANDLE ImageHandle; - EFI_PHYSICAL_ADDRESS ImgFdtBase; + EFI_PHYSICAL_ADDRESS FdtBase; VOID *NewKernelArg; EFI_LOADED_IMAGE_PROTOCOL *ImageInfo; MEMORY_DEVICE_PATH KernelDevicePath; + INTN err; Status = AbootimgGetKernelInfo ( Buffer, @@ -334,20 +335,33 @@ AbootimgBootKernel ( return Status; } - /* For flatten image, Fdt is attached at the end of kernel. - Get real kernel size. + /* + * FDT location: + * 1. at the end of flattern image. + * 2. in the boot image of storage device. */ - ImgKernelSize = *(UINT32 *)((EFI_PHYSICAL_ADDRESS)(UINTN)ImgKernel + KERNEL_IMAGE_STEXT_OFFSET) + - *(UINT32 *)((EFI_PHYSICAL_ADDRESS)(UINTN)ImgKernel + KERNEL_IMAGE_RAW_SIZE_OFFSET); + DwnldKernelSize = *(UINT32 *)((EFI_PHYSICAL_ADDRESS)(UINTN)DwnldKernel + KERNEL_IMAGE_STEXT_OFFSET) + + *(UINT32 *)((EFI_PHYSICAL_ADDRESS)(UINTN)DwnldKernel + KERNEL_IMAGE_RAW_SIZE_OFFSET); + FdtBase = (EFI_PHYSICAL_ADDRESS)(UINTN)DwnldKernel + DwnldKernelSize; + err = fdt_check_header ((VOID*)(UINTN)FdtBase); + if (err != 0) { + // Can not find the device tree header at the end of downloaded kernel + // Check FDT at the end of kernel image of boot image instead. + ImgKernelSize = *(UINT32 *)((EFI_PHYSICAL_ADDRESS)(UINTN)ImgKernel + KERNEL_IMAGE_STEXT_OFFSET) + + *(UINT32 *)((EFI_PHYSICAL_ADDRESS)(UINTN)ImgKernel + KERNEL_IMAGE_RAW_SIZE_OFFSET); + FdtBase = (EFI_PHYSICAL_ADDRESS)(UINTN)ImgKernel + ImgKernelSize; + err = fdt_check_header ((VOID*)(UINTN)FdtBase); + } + if (err != 0) { + Print (L"ERROR: Device Tree header not valid (err:%d)\n", err); + return EFI_INVALID_PARAMETER; + } NewKernelArg = AllocateZeroPool (BOOTIMG_KERNEL_ARGS_SIZE << 1); if (NewKernelArg == NULL) { DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n")); return EFI_OUT_OF_RESOURCES; } - - /* FDT is at the end of kernel image */ - ImgFdtBase = (EFI_PHYSICAL_ADDRESS)(UINTN)ImgKernel + ImgKernelSize; - Status = AbootimgInstallFdt (ImgBuffer, ImgFdtBase, NewKernelArg); + Status = AbootimgInstallFdt (ImgBuffer, FdtBase, NewKernelArg); if (EFI_ERROR (Status)) { FreePool (NewKernelArg); return EFI_INVALID_PARAMETER; |