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>
This commit is contained in:
Michael Kubacki
2021-12-05 14:53:56 -08:00
committed by mergify[bot]
parent 731c67e1d7
commit e7108d0e96
106 changed files with 9242 additions and 7648 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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__

View File

@ -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;