Skip to content

Commit

Permalink
EmbeddedPkg/AndroidBootImgLib: Simplify New Kernel Arg
Browse files Browse the repository at this point in the history
Simplify the logic to get buffer for new kernel arguments from
android boot image.

Signed-off-by: Ashish Singhal <[email protected]>
  • Loading branch information
ashishsingha authored and UEFI Builder committed Dec 8, 2023
1 parent 13e53cb commit 9cc98f1
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,30 +321,37 @@ AndroidBootImgGetFdt (

EFI_STATUS
AndroidBootImgUpdateArgs (
IN VOID *BootImg,
OUT VOID *KernelArgs,
IN UINT32 KernelArgsSize
IN VOID *BootImg,
OUT VOID **KernelArgs
)
{
CHAR8 ImageKernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
EFI_STATUS Status;
UINT32 NewKernelArgSize;

// Get kernel arguments from Android boot image
Status = AndroidBootImgGetKernelArgs (BootImg, ImageKernelArgs);
if (EFI_ERROR (Status)) {
return Status;
}

NewKernelArgSize = ANDROID_BOOTIMG_KERNEL_ARGS_SIZE + PcdGet32 (PcdAndroidKernelCommandLineOverflow);
*KernelArgs = AllocateZeroPool (sizeof (CHAR16) * NewKernelArgSize);
if (*KernelArgs == NULL) {
DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
return EFI_OUT_OF_RESOURCES;
}

AsciiStrToUnicodeStrS (
ImageKernelArgs,
KernelArgs,
KernelArgsSize
*KernelArgs,
NewKernelArgSize
);
// Append platform kernel arguments
if (mAndroidBootImg->AppendArgs) {
Status = mAndroidBootImg->AppendArgs (
KernelArgs,
KernelArgsSize
*KernelArgs,
NewKernelArgSize
);
}

Expand Down Expand Up @@ -612,7 +619,6 @@ AndroidBootImgBoot (
MEMORY_DEVICE_PATH KernelDevicePath;
EFI_HANDLE ImageHandle;
VOID *NewKernelArg;
UINT32 NewKernelArgSize;
EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
VOID *RamdiskData;
UINTN RamdiskSize;
Expand Down Expand Up @@ -643,15 +649,7 @@ AndroidBootImgBoot (
goto Exit;
}

NewKernelArgSize = ANDROID_BOOTIMG_KERNEL_ARGS_SIZE + PcdGet32 (PcdAndroidKernelCommandLineOverflow);
NewKernelArg = AllocateZeroPool (sizeof (CHAR16) * NewKernelArgSize);
if (NewKernelArg == NULL) {
DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}

Status = AndroidBootImgUpdateArgs (Buffer, NewKernelArg, NewKernelArgSize);
Status = AndroidBootImgUpdateArgs (Buffer, &NewKernelArg);
if (EFI_ERROR (Status)) {
goto Exit;
}
Expand Down

0 comments on commit 9cc98f1

Please sign in to comment.