3 * Copyright (c) 2011-2015, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __LINUX_LOADER_H__
16 #define __LINUX_LOADER_H__
18 #include <Library/BdsLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/HiiLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/PerformanceLib.h>
23 #include <Library/PrintLib.h>
24 #include <Library/ShellLib.h>
25 #include <Library/UefiBootServicesTableLib.h>
26 #include <Library/UefiLib.h>
28 #include <Protocol/EfiShellParameters.h>
29 #include <Protocol/EfiShell.h>
37 #define MAX_MSG_LEN 80
39 #define LINUX_UIMAGE_SIGNATURE 0x56190527
40 #define LINUX_KERNEL_MAX_OFFSET (SystemMemoryBase + PcdGet32(PcdArmLinuxKernelMaxOffset))
41 #define LINUX_ATAG_MAX_OFFSET (SystemMemoryBase + PcdGet32(PcdArmLinuxAtagMaxOffset))
42 #define LINUX_FDT_MAX_OFFSET (SystemMemoryBase + PcdGet32(PcdArmLinuxFdtMaxOffset))
44 #define ARM_FDT_MACHINE_TYPE 0xFFFFFFFF
46 // Additional size that could be used for FDT entries added by the UEFI OS Loader
47 // Estimation based on: EDID (300bytes) + bootargs (200bytes) + initrd region (20bytes)
48 // + system memory region (20bytes) + mp_core entries (200 bytes)
49 #define FDT_ADDITIONAL_ENTRIES_SIZE 0x300
54 extern CONST EFI_GUID mLinuxLoaderHiiGuid
;
55 extern EFI_HANDLE mLinuxLoaderHiiHandle
;
60 typedef struct _SYSTEM_MEMORY_RESOURCE
{
61 LIST_ENTRY Link
; // This attribute must be the first entry of this structure (to avoid pointer computation)
62 EFI_PHYSICAL_ADDRESS PhysicalStart
;
63 UINT64 ResourceLength
;
64 } SYSTEM_MEMORY_RESOURCE
;
66 typedef VOID (*LINUX_KERNEL
)(UINT32 Zero
, UINT32 Arch
, UINTN ParametersBase
);
73 IN CONST CHAR8
*Language OPTIONAL
,
74 IN CONST EFI_STRING_ID HiiFormatStringId
,
80 IN CONST CHAR8
*Language OPTIONAL
84 ProcessShellParameters (
85 OUT CHAR16
**KernelPath
,
87 OUT CHAR16
**InitrdPath
,
88 OUT CHAR16
**LinuxCommandLine
,
89 OUT UINTN
*AtagMachineType
93 ProcessAppCommandLine (
94 OUT CHAR16
**KernelTextDevicePath
,
95 OUT CHAR16
**FdtTextDevicePath
,
96 OUT CHAR16
**InitrdTextDevicePath
,
97 OUT CHAR16
**LinuxCommandLine
,
98 OUT UINTN
*AtagMachineType
107 GetSystemMemoryResources (
108 IN LIST_ENTRY
*ResourceList
113 IN EFI_PHYSICAL_ADDRESS SystemMemoryBase
,
114 IN CONST CHAR8
* CommandLineArguments
,
115 IN EFI_PHYSICAL_ADDRESS InitrdImage
,
116 IN UINTN InitrdImageSize
,
117 IN OUT EFI_PHYSICAL_ADDRESS
*FdtBlobBase
,
118 IN OUT UINTN
*FdtBlobSize
122 Start a Linux kernel from a Device Path
124 @param SystemMemoryBase Base of the system memory
125 @param LinuxKernel Device Path to the Linux Kernel
126 @param Parameters Linux kernel arguments
127 @param Fdt Device Path to the Flat Device Tree
128 @param MachineType ARM machine type value
130 @retval EFI_SUCCESS All drivers have been connected
131 @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
132 @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
133 @retval RETURN_UNSUPPORTED ATAG is not support by this architecture
138 IN EFI_PHYSICAL_ADDRESS SystemMemoryBase
,
139 IN EFI_DEVICE_PATH_PROTOCOL
* LinuxKernelDevicePath
,
140 IN EFI_DEVICE_PATH_PROTOCOL
* InitrdDevicePath
,
141 IN CONST CHAR8
* CommandLineArguments
,
146 Start a Linux kernel from a Device Path
148 @param[in] LinuxKernelDevicePath Device Path to the Linux Kernel
149 @param[in] InitrdDevicePath Device Path to the Initrd
150 @param[in] Arguments Linux kernel arguments
152 @retval EFI_SUCCESS All drivers have been connected
153 @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
154 @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
159 IN EFI_PHYSICAL_ADDRESS SystemMemoryBase
,
160 IN EFI_DEVICE_PATH_PROTOCOL
* LinuxKernelDevicePath
,
161 IN EFI_DEVICE_PATH_PROTOCOL
* InitrdDevicePath
,
162 IN EFI_DEVICE_PATH_PROTOCOL
* FdtDevicePath
,
163 IN CONST CHAR8
* Arguments
166 #endif /* __LINUX_LOADER_H__ */