1 /** @file 2 3 Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR> 4 Copyright (c) 2017, Linaro. 5 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 **/ 15 16 #ifndef __ABOOTIMG_H__ 17 #define __ABOOTIMG_H__ 18 19 #include <Library/BaseLib.h> 20 #include <Library/DebugLib.h> 21 #include <Library/MemoryAllocationLib.h> 22 23 #include <Uefi/UefiBaseType.h> 24 #include <Uefi/UefiSpec.h> 25 26 #define BOOTIMG_KERNEL_ARGS_SIZE 512 27 28 #define BOOT_MAGIC "ANDROID!" 29 #define BOOT_MAGIC_LENGTH (sizeof (BOOT_MAGIC) - 1) 30 31 /* It's the value of arm64 efi stub kernel */ 32 #define KERNEL_IMAGE_STEXT_OFFSET 0x12C 33 #define KERNEL_IMAGE_RAW_SIZE_OFFSET 0x130 34 35 #define FDT_SIZE_OFFSET 0x4 36 37 typedef struct { 38 CHAR8 BootMagic[BOOT_MAGIC_LENGTH]; 39 UINT32 KernelSize; 40 UINT32 KernelAddress; 41 UINT32 RamdiskSize; 42 UINT32 RamdiskAddress; 43 UINT32 SecondStageBootloaderSize; 44 UINT32 SecondStageBootloaderAddress; 45 UINT32 KernelTaggsAddress; 46 UINT32 PageSize; 47 UINT32 Reserved[2]; 48 CHAR8 ProductName[16]; 49 CHAR8 KernelArgs[BOOTIMG_KERNEL_ARGS_SIZE]; 50 UINT32 Id[32]; 51 } ANDROID_BOOTIMG_HEADER; 52 53 EFI_STATUS 54 AbootimgGetImgSize ( 55 IN VOID *BootImg, 56 OUT UINTN *ImgSize 57 ); 58 59 EFI_STATUS 60 AbootimgBootRam ( 61 IN VOID *Buffer, 62 IN UINTN BufferSize, 63 IN CHAR16 *BootPathStr, 64 IN CHAR16 *FdtPathStr 65 ); 66 67 EFI_STATUS 68 AbootimgBootPartition ( 69 IN CHAR16 *BootPathStr, 70 IN CHAR16 *FdtPathStr 71 ); 72 73 #endif /* __ABOOTIMG_H__ */ 74