summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Application
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:53:56 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commite7108d0e9655b1795c94ac372b0449f28dd907df (patch)
treeb153716589979b9e42e9b85281ff8b7511ba272f /EmbeddedPkg/Application
parent731c67e1d77b7741a91762d17659fc9fbcb9e305 (diff)
downloadedk2-e7108d0e9655b1795c94ac372b0449f28dd907df.tar.gz
edk2-e7108d0e9655b1795c94ac372b0449f28dd907df.tar.bz2
edk2-e7108d0e9655b1795c94ac372b0449f28dd907df.zip
EmbeddedPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the EmbeddedPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
Diffstat (limited to 'EmbeddedPkg/Application')
-rw-r--r--EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c41
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c42
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c138
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h16
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c98
5 files changed, 191 insertions, 144 deletions
diff --git a/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c b/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c
index 940738e0dd..5e3c9c587a 100644
--- a/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c
+++ b/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c
@@ -20,28 +20,31 @@
/* Validate the node is media hard drive type */
EFI_STATUS
ValidateAndroidMediaDevicePath (
- IN EFI_DEVICE_PATH *DevicePath
+ IN EFI_DEVICE_PATH *DevicePath
)
{
- EFI_DEVICE_PATH_PROTOCOL *Node, *NextNode;
+ EFI_DEVICE_PATH_PROTOCOL *Node, *NextNode;
NextNode = DevicePath;
while (NextNode != NULL) {
Node = NextNode;
- if (Node->Type == MEDIA_DEVICE_PATH &&
- Node->SubType == MEDIA_HARDDRIVE_DP) {
+ if ((Node->Type == MEDIA_DEVICE_PATH) &&
+ (Node->SubType == MEDIA_HARDDRIVE_DP))
+ {
return EFI_SUCCESS;
}
+
NextNode = NextDevicePathNode (Node);
}
+
return EFI_INVALID_PARAMETER;
}
EFI_STATUS
EFIAPI
AndroidBootAppEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -56,9 +59,12 @@ AndroidBootAppEntryPoint (
BootPathStr = (CHAR16 *)PcdGetPtr (PcdAndroidBootDevicePath);
ASSERT (BootPathStr != NULL);
- Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL,
- (VOID **)&EfiDevicePathFromTextProtocol);
- ASSERT_EFI_ERROR(Status);
+ Status = gBS->LocateProtocol (
+ &gEfiDevicePathFromTextProtocolGuid,
+ NULL,
+ (VOID **)&EfiDevicePathFromTextProtocol
+ );
+ ASSERT_EFI_ERROR (Status);
DevicePath = (EFI_DEVICE_PATH *)EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (BootPathStr);
ASSERT (DevicePath != NULL);
@@ -67,8 +73,11 @@ AndroidBootAppEntryPoint (
return Status;
}
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid,
- &DevicePath, &Handle);
+ Status = gBS->LocateDevicePath (
+ &gEfiDevicePathProtocolGuid,
+ &DevicePath,
+ &Handle
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -76,7 +85,7 @@ AndroidBootAppEntryPoint (
Status = gBS->OpenProtocol (
Handle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -86,12 +95,13 @@ AndroidBootAppEntryPoint (
return Status;
}
- MediaId = BlockIo->Media->MediaId;
+ MediaId = BlockIo->Media->MediaId;
BlockSize = BlockIo->Media->BlockSize;
- Buffer = AllocatePages (EFI_SIZE_TO_PAGES (sizeof(ANDROID_BOOTIMG_HEADER)));
+ Buffer = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (ANDROID_BOOTIMG_HEADER)));
if (Buffer == NULL) {
return EFI_BUFFER_TOO_SMALL;
}
+
/* Load header of boot.img */
Status = BlockIo->ReadBlocks (
BlockIo,
@@ -105,8 +115,9 @@ AndroidBootAppEntryPoint (
DEBUG ((DEBUG_ERROR, "Failed to get AndroidBootImg Size: %r\n", Status));
return Status;
}
+
BootImgSize = ALIGN_VALUE (BootImgSize, BlockSize);
- FreePages (Buffer, EFI_SIZE_TO_PAGES (sizeof(ANDROID_BOOTIMG_HEADER)));
+ FreePages (Buffer, EFI_SIZE_TO_PAGES (sizeof (ANDROID_BOOTIMG_HEADER)));
/* Both PartitionStart and PartitionSize are counted as block size. */
Buffer = AllocatePages (EFI_SIZE_TO_PAGES (BootImgSize));
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
index 54b7bee162..8b224ed59f 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
@@ -16,24 +16,28 @@
// present, but RamdiskSize will be set to 0.
EFI_STATUS
ParseAndroidBootImg (
- IN VOID *BootImg,
+ IN VOID *BootImg,
OUT VOID **Kernel,
- OUT UINTN *KernelSize,
+ OUT UINTN *KernelSize,
OUT VOID **Ramdisk,
- OUT UINTN *RamdiskSize,
- OUT CHAR8 *KernelArgs
+ OUT UINTN *RamdiskSize,
+ OUT CHAR8 *KernelArgs
)
{
- ANDROID_BOOTIMG_HEADER *Header;
- UINT8 *BootImgBytePtr;
+ ANDROID_BOOTIMG_HEADER *Header;
+ UINT8 *BootImgBytePtr;
// Cast to UINT8 so we can do pointer arithmetic
- BootImgBytePtr = (UINT8 *) BootImg;
+ BootImgBytePtr = (UINT8 *)BootImg;
- Header = (ANDROID_BOOTIMG_HEADER *) BootImg;
+ Header = (ANDROID_BOOTIMG_HEADER *)BootImg;
- if (AsciiStrnCmp ((CONST CHAR8 *)Header->BootMagic, ANDROID_BOOT_MAGIC,
- ANDROID_BOOT_MAGIC_LENGTH) != 0) {
+ if (AsciiStrnCmp (
+ (CONST CHAR8 *)Header->BootMagic,
+ ANDROID_BOOT_MAGIC,
+ ANDROID_BOOT_MAGIC_LENGTH
+ ) != 0)
+ {
return EFI_INVALID_PARAMETER;
}
@@ -43,18 +47,22 @@ ParseAndroidBootImg (
ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize));
- *KernelSize = Header->KernelSize;
- *Kernel = BootImgBytePtr + Header->PageSize;
+ *KernelSize = Header->KernelSize;
+ *Kernel = BootImgBytePtr + Header->PageSize;
*RamdiskSize = Header->RamdiskSize;
if (Header->RamdiskSize != 0) {
- *Ramdisk = (VOID *) (BootImgBytePtr
- + Header->PageSize
- + ALIGN_VALUE (Header->KernelSize, Header->PageSize));
+ *Ramdisk = (VOID *)(BootImgBytePtr
+ + Header->PageSize
+ + ALIGN_VALUE (Header->KernelSize, Header->PageSize));
}
- AsciiStrnCpyS (KernelArgs, ANDROID_BOOTIMG_KERNEL_ARGS_SIZE, Header->KernelArgs,
- ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
+ AsciiStrnCpyS (
+ KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE,
+ Header->KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
+ );
return EFI_SUCCESS;
}
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
index 32d5c755d7..b16478bea0 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
@@ -25,10 +25,10 @@
* FASTBOOT_PLATFORM_PROTOCOL to implement the Android Fastboot protocol.
*/
-STATIC FASTBOOT_TRANSPORT_PROTOCOL *mTransport;
-STATIC FASTBOOT_PLATFORM_PROTOCOL *mPlatform;
+STATIC FASTBOOT_TRANSPORT_PROTOCOL *mTransport;
+STATIC FASTBOOT_PLATFORM_PROTOCOL *mPlatform;
-STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
+STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
typedef enum {
ExpectCmdState,
@@ -36,45 +36,45 @@ typedef enum {
FastbootStateMax
} ANDROID_FASTBOOT_STATE;
-STATIC ANDROID_FASTBOOT_STATE mState = ExpectCmdState;
+STATIC ANDROID_FASTBOOT_STATE mState = ExpectCmdState;
// When in ExpectDataState, the number of bytes of data to expect:
-STATIC UINT64 mNumDataBytes;
+STATIC UINT64 mNumDataBytes;
// .. and the number of bytes so far received this data phase
-STATIC UINT64 mBytesReceivedSoFar;
+STATIC UINT64 mBytesReceivedSoFar;
// .. and the buffer to save data into
-STATIC UINT8 *mDataBuffer = NULL;
+STATIC UINT8 *mDataBuffer = NULL;
// Event notify functions, from which gBS->Exit shouldn't be called, can signal
// this event when the application should exit
-STATIC EFI_EVENT mFinishedEvent;
+STATIC EFI_EVENT mFinishedEvent;
-STATIC EFI_EVENT mFatalSendErrorEvent;
+STATIC EFI_EVENT mFatalSendErrorEvent;
// This macro uses sizeof - only use it on arrays (i.e. string literals)
-#define SEND_LITERAL(Str) mTransport->Send ( \
+#define SEND_LITERAL(Str) mTransport->Send ( \
sizeof (Str) - 1, \
Str, \
&mFatalSendErrorEvent \
)
-#define MATCH_CMD_LITERAL(Cmd, Buf) !AsciiStrnCmp (Cmd, Buf, sizeof (Cmd) - 1)
+#define MATCH_CMD_LITERAL(Cmd, Buf) !AsciiStrnCmp (Cmd, Buf, sizeof (Cmd) - 1)
-#define IS_LOWERCASE_ASCII(Char) (Char >= 'a' && Char <= 'z')
+#define IS_LOWERCASE_ASCII(Char) (Char >= 'a' && Char <= 'z')
-#define FASTBOOT_STRING_MAX_LENGTH 256
-#define FASTBOOT_COMMAND_MAX_LENGTH 64
+#define FASTBOOT_STRING_MAX_LENGTH 256
+#define FASTBOOT_COMMAND_MAX_LENGTH 64
STATIC
VOID
HandleGetVar (
- IN CHAR8 *CmdArg
+ IN CHAR8 *CmdArg
)
{
- CHAR8 Response[FASTBOOT_COMMAND_MAX_LENGTH + 1] = "OKAY";
- EFI_STATUS Status;
+ CHAR8 Response[FASTBOOT_COMMAND_MAX_LENGTH + 1] = "OKAY";
+ EFI_STATUS Status;
// Respond to getvar:version with 0.4 (version of Fastboot protocol)
- if (!AsciiStrnCmp ("version", CmdArg, sizeof ("version") - 1 )) {
+ if (!AsciiStrnCmp ("version", CmdArg, sizeof ("version") - 1)) {
SEND_LITERAL ("OKAY" ANDROID_FASTBOOT_VERSION);
} else {
// All other variables are assumed to be platform specific
@@ -90,11 +90,11 @@ HandleGetVar (
STATIC
VOID
HandleDownload (
- IN CHAR8 *NumBytesString
+ IN CHAR8 *NumBytesString
)
{
- CHAR8 Response[13];
- CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
+ CHAR8 Response[13];
+ CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
// Argument is 8-character ASCII string hex representation of number of bytes
// that will be sent in the data phase.
@@ -122,11 +122,15 @@ HandleDownload (
SEND_LITERAL ("FAILNot enough memory");
} else {
ZeroMem (Response, sizeof Response);
- AsciiSPrint (Response, sizeof Response, "DATA%x",
- (UINT32)mNumDataBytes);
+ AsciiSPrint (
+ Response,
+ sizeof Response,
+ "DATA%x",
+ (UINT32)mNumDataBytes
+ );
mTransport->Send (sizeof Response - 1, Response, &mFatalSendErrorEvent);
- mState = ExpectDataState;
+ mState = ExpectDataState;
mBytesReceivedSoFar = 0;
}
}
@@ -134,7 +138,7 @@ HandleDownload (
STATIC
VOID
HandleFlash (
- IN CHAR8 *PartitionName
+ IN CHAR8 *PartitionName
)
{
EFI_STATUS Status;
@@ -171,7 +175,7 @@ HandleFlash (
STATIC
VOID
HandleErase (
- IN CHAR8 *PartitionName
+ IN CHAR8 *PartitionName
)
{
EFI_STATUS Status;
@@ -196,7 +200,7 @@ HandleBoot (
VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
mTextOut->OutputString (mTextOut, L"Booting downloaded image\r\n");
@@ -214,13 +218,14 @@ HandleBoot (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed to boot downloaded image: %r\n", Status));
}
+
// We shouldn't get here
}
STATIC
VOID
HandleOemCommand (
- IN CHAR8 *Command
+ IN CHAR8 *Command
)
{
EFI_STATUS Status;
@@ -241,10 +246,10 @@ STATIC
VOID
AcceptCmd (
IN UINTN Size,
- IN CONST CHAR8 *Data
+ IN CONST CHAR8 *Data
)
{
- CHAR8 Command[FASTBOOT_COMMAND_MAX_LENGTH + 1];
+ CHAR8 Command[FASTBOOT_COMMAND_MAX_LENGTH + 1];
// Max command size is 64 bytes
if (Size > FASTBOOT_COMMAND_MAX_LENGTH) {
@@ -282,6 +287,7 @@ AcceptCmd (
// Here we just reboot normally.
SEND_LITERAL ("INFOreboot-bootloader not supported, rebooting normally.");
}
+
SEND_LITERAL ("OKAY");
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
@@ -313,12 +319,12 @@ STATIC
VOID
AcceptData (
IN UINTN Size,
- IN VOID *Data
+ IN VOID *Data
)
{
- UINT32 RemainingBytes = mNumDataBytes - mBytesReceivedSoFar;
- CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
- STATIC UINTN Count = 0;
+ UINT32 RemainingBytes = mNumDataBytes - mBytesReceivedSoFar;
+ CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
+ STATIC UINTN Count = 0;
// Protocol doesn't say anything about sending extra data so just ignore it.
if (Size > RemainingBytes) {
@@ -331,7 +337,7 @@ AcceptData (
// Show download progress. Don't do it for every packet as outputting text
// might be time consuming - do it on the last packet and on every 32nd packet
- if ((Count++ % 32) == 0 || Size == RemainingBytes) {
+ if (((Count++ % 32) == 0) || (Size == RemainingBytes)) {
// (Note no newline in format string - it will overwrite the line each time)
UnicodeSPrint (
OutputString,
@@ -363,23 +369,24 @@ STATIC
VOID
DataReady (
IN EFI_EVENT Event,
- IN VOID *Context
+ IN VOID *Context
)
{
UINTN Size;
- VOID *Data;
+ VOID *Data;
EFI_STATUS Status;
do {
Status = mTransport->Receive (&Size, &Data);
if (!EFI_ERROR (Status)) {
if (mState == ExpectCmdState) {
- AcceptCmd (Size, (CHAR8 *) Data);
+ AcceptCmd (Size, (CHAR8 *)Data);
} else if (mState == ExpectDataState) {
AcceptData (Size, Data);
} else {
ASSERT (FALSE);
}
+
FreePool (Data);
}
} while (!EFI_ERROR (Status));
@@ -401,7 +408,7 @@ STATIC
VOID
FatalErrorNotify (
IN EFI_EVENT Event,
- IN VOID *Context
+ IN VOID *Context
)
{
mTextOut->OutputString (mTextOut, L"Fatal error sending command response. Exiting.\r\n");
@@ -411,30 +418,30 @@ FatalErrorNotify (
EFI_STATUS
EFIAPI
FastbootAppEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_EVENT ReceiveEvent;
EFI_EVENT WaitEventArray[2];
UINTN EventIndex;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
EFI_INPUT_KEY Key;
mDataBuffer = NULL;
Status = gBS->LocateProtocol (
- &gAndroidFastbootTransportProtocolGuid,
- NULL,
- (VOID **) &mTransport
- );
+ &gAndroidFastbootTransportProtocolGuid,
+ NULL,
+ (VOID **)&mTransport
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Fastboot Transport Protocol: %r\n", Status));
return Status;
}
- Status = gBS->LocateProtocol (&gAndroidFastbootPlatformProtocolGuid, NULL, (VOID **) &mPlatform);
+ Status = gBS->LocateProtocol (&gAndroidFastbootPlatformProtocolGuid, NULL, (VOID **)&mPlatform);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Fastboot Platform Protocol: %r\n", Status));
return Status;
@@ -446,15 +453,17 @@ FastbootAppEntryPoint (
return Status;
}
- Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **) &mTextOut);
+ Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **)&mTextOut);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "Fastboot: Couldn't open Text Output Protocol: %r\n", Status
+ DEBUG ((
+ DEBUG_ERROR,
+ "Fastboot: Couldn't open Text Output Protocol: %r\n",
+ Status
));
return Status;
}
- Status = gBS->LocateProtocol (&gEfiSimpleTextInProtocolGuid, NULL, (VOID **) &TextIn);
+ Status = gBS->LocateProtocol (&gEfiSimpleTextInProtocolGuid, NULL, (VOID **)&TextIn);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Text Input Protocol: %r\n", Status));
return Status;
@@ -483,27 +492,28 @@ FastbootAppEntryPoint (
// Create event to pass to FASTBOOT_TRANSPORT_PROTOCOL.Send, signalling a
// fatal error
Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- FatalErrorNotify,
- NULL,
- &mFatalSendErrorEvent
- );
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ FatalErrorNotify,
+ NULL,
+ &mFatalSendErrorEvent
+ );
ASSERT_EFI_ERROR (Status);
-
// Start listening for data
Status = mTransport->Start (
- ReceiveEvent
- );
+ ReceiveEvent
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't start transport: %r\n", Status));
return Status;
}
// Talk to the user
- mTextOut->OutputString (mTextOut,
- L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press RETURN or SPACE key to quit.\r\n");
+ mTextOut->OutputString (
+ mTextOut,
+ L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press RETURN or SPACE key to quit.\r\n"
+ );
// Quit when the user presses any key, or mFinishedEvent is signalled
WaitEventArray[0] = mFinishedEvent;
@@ -513,7 +523,8 @@ FastbootAppEntryPoint (
Status = TextIn->ReadKeyStroke (gST->ConIn, &Key);
if (Key.ScanCode == SCAN_NULL) {
if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) ||
- (Key.UnicodeChar == L' ')) {
+ (Key.UnicodeChar == L' '))
+ {
break;
}
}
@@ -523,6 +534,7 @@ FastbootAppEntryPoint (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Warning: Fastboot Transport Stop: %r\n", Status));
}
+
mPlatform->UnInit ();
return EFI_SUCCESS;
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
index 88720f9648..3923c03428 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
@@ -14,24 +14,24 @@
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
-#define BOOTIMG_KERNEL_ARGS_SIZE 512
+#define BOOTIMG_KERNEL_ARGS_SIZE 512
-#define ANDROID_FASTBOOT_VERSION "0.4"
+#define ANDROID_FASTBOOT_VERSION "0.4"
EFI_STATUS
BootAndroidBootImg (
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
EFI_STATUS
ParseAndroidBootImg (
- IN VOID *BootImg,
+ IN VOID *BootImg,
OUT VOID **Kernel,
- OUT UINTN *KernelSize,
+ OUT UINTN *KernelSize,
OUT VOID **Ramdisk,
- OUT UINTN *RamdiskSize,
- OUT CHAR8 *KernelArgs
+ OUT UINTN *RamdiskSize,
+ OUT CHAR8 *KernelArgs
);
#endif //ifdef __ANDROID_FASTBOOT_APP_H__
diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
index c9b885b073..163ac7ecc9 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
@@ -18,12 +18,12 @@
// Device Path representing an image in memory
#pragma pack(1)
typedef struct {
- MEMMAP_DEVICE_PATH Node1;
- EFI_DEVICE_PATH_PROTOCOL End;
+ MEMMAP_DEVICE_PATH Node1;
+ EFI_DEVICE_PATH_PROTOCOL End;
} MEMORY_DEVICE_PATH;
#pragma pack()
-STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
+STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
{
{
{
@@ -44,7 +44,6 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
} // End
};
-
/**
Start an EFI Application from a Device Path
@@ -59,19 +58,25 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
STATIC
EFI_STATUS
StartEfiApplication (
- IN EFI_HANDLE ParentImageHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN UINTN LoadOptionsSize,
- IN VOID* LoadOptions
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN UINTN LoadOptionsSize,
+ IN VOID *LoadOptions
)
{
- EFI_STATUS Status;
- EFI_HANDLE ImageHandle;
- EFI_LOADED_IMAGE_PROTOCOL* LoadedImage;
+ EFI_STATUS Status;
+ EFI_HANDLE ImageHandle;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
// Load the image from the device path with Boot Services function
- Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, NULL, 0,
- &ImageHandle);
+ Status = gBS->LoadImage (
+ TRUE,
+ ParentImageHandle,
+ DevicePath,
+ NULL,
+ 0,
+ &ImageHandle
+ );
if (EFI_ERROR (Status)) {
//
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
@@ -82,19 +87,23 @@ StartEfiApplication (
if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (ImageHandle);
}
+
return Status;
}
// Passed LoadOptions to the EFI Application
if (LoadOptionsSize != 0) {
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage);
+ Status = gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- LoadedImage->LoadOptionsSize = LoadOptionsSize;
- LoadedImage->LoadOptions = LoadOptions;
+ LoadedImage->LoadOptionsSize = LoadOptionsSize;
+ LoadedImage->LoadOptions = LoadOptions;
}
// Before calling the image, enable the Watchdog Timer for the 5 Minute period
@@ -109,27 +118,27 @@ StartEfiApplication (
EFI_STATUS
BootAndroidBootImg (
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
- VOID *Kernel;
- UINTN KernelSize;
- VOID *Ramdisk;
- UINTN RamdiskSize;
- MEMORY_DEVICE_PATH KernelDevicePath;
- CHAR16 *LoadOptions, *NewLoadOptions;
+ EFI_STATUS Status;
+ CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
+ VOID *Kernel;
+ UINTN KernelSize;
+ VOID *Ramdisk;
+ UINTN RamdiskSize;
+ MEMORY_DEVICE_PATH KernelDevicePath;
+ CHAR16 *LoadOptions, *NewLoadOptions;
Status = ParseAndroidBootImg (
- Buffer,
- &Kernel,
- &KernelSize,
- &Ramdisk,
- &RamdiskSize,
- KernelArgs
- );
+ Buffer,
+ &Kernel,
+ &KernelSize,
+ &Ramdisk,
+ &RamdiskSize,
+ KernelArgs
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -138,8 +147,8 @@ BootAndroidBootImg (
// Have to cast to UINTN before casting to EFI_PHYSICAL_ADDRESS in order to
// appease GCC.
- KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel;
- KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel + KernelSize;
+ KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Kernel;
+ KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Kernel + KernelSize;
// Initialize Linux command line
LoadOptions = CatSPrint (NULL, L"%a", KernelArgs);
@@ -148,19 +157,26 @@ BootAndroidBootImg (
}
if (RamdiskSize != 0) {
- NewLoadOptions = CatSPrint (LoadOptions, L" initrd=0x%x,0x%x",
- (UINTN)Ramdisk, RamdiskSize);
+ NewLoadOptions = CatSPrint (
+ LoadOptions,
+ L" initrd=0x%x,0x%x",
+ (UINTN)Ramdisk,
+ RamdiskSize
+ );
FreePool (LoadOptions);
if (NewLoadOptions == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
LoadOptions = NewLoadOptions;
}
- Status = StartEfiApplication (gImageHandle,
- (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath,
+ Status = StartEfiApplication (
+ gImageHandle,
+ (EFI_DEVICE_PATH_PROTOCOL *)&KernelDevicePath,
StrSize (LoadOptions),
- LoadOptions);
+ LoadOptions
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Couldn't Boot Linux: %d\n", Status));
Status = EFI_DEVICE_ERROR;