]>
Commit | Line | Data |
---|---|---|
23b01c83 RC |
1 | /** @file\r |
2 | *\r | |
3 | * Copyright (c) 2011-2015, ARM Limited. All rights reserved.\r | |
4 | *\r | |
5 | * This program and the accompanying materials\r | |
6 | * are licensed and made available under the terms and conditions of the BSD License\r | |
7 | * which accompanies this distribution. The full text of the license may be found at\r | |
8 | * http://opensource.org/licenses/bsd-license.php\r | |
9 | *\r | |
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | *\r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef __LINUX_LOADER_H__\r | |
16 | #define __LINUX_LOADER_H__\r | |
17 | \r | |
18 | #include <Library/BdsLib.h>\r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/HiiLib.h>\r | |
21 | #include <Library/MemoryAllocationLib.h>\r | |
22 | #include <Library/PerformanceLib.h>\r | |
23 | #include <Library/PrintLib.h>\r | |
24 | #include <Library/ShellLib.h>\r | |
25 | #include <Library/UefiBootServicesTableLib.h>\r | |
26 | #include <Library/UefiLib.h>\r | |
27 | \r | |
28 | #include <Protocol/EfiShellParameters.h>\r | |
29 | #include <Protocol/EfiShell.h>\r | |
30 | \r | |
31 | #include <libfdt.h>\r | |
32 | \r | |
33 | //\r | |
34 | // Definitions\r | |
35 | //\r | |
36 | \r | |
37 | #define MAX_MSG_LEN 80\r | |
38 | \r | |
39 | #define LINUX_UIMAGE_SIGNATURE 0x56190527\r | |
40 | #define LINUX_KERNEL_MAX_OFFSET (SystemMemoryBase + PcdGet32(PcdArmLinuxKernelMaxOffset))\r | |
41 | #define LINUX_ATAG_MAX_OFFSET (SystemMemoryBase + PcdGet32(PcdArmLinuxAtagMaxOffset))\r | |
42 | #define LINUX_FDT_MAX_OFFSET (SystemMemoryBase + PcdGet32(PcdArmLinuxFdtMaxOffset))\r | |
43 | \r | |
44 | #define ARM_FDT_MACHINE_TYPE 0xFFFFFFFF\r | |
45 | \r | |
46 | // Additional size that could be used for FDT entries added by the UEFI OS Loader\r | |
47 | // Estimation based on: EDID (300bytes) + bootargs (200bytes) + initrd region (20bytes)\r | |
48 | // + system memory region (20bytes) + mp_core entries (200 bytes)\r | |
49 | #define FDT_ADDITIONAL_ENTRIES_SIZE 0x300\r | |
50 | \r | |
51 | //\r | |
52 | // Global variables\r | |
53 | //\r | |
54 | extern CONST EFI_GUID mLinuxLoaderHiiGuid;\r | |
55 | extern EFI_HANDLE mLinuxLoaderHiiHandle;\r | |
56 | \r | |
57 | //\r | |
58 | // Local Types\r | |
59 | //\r | |
60 | typedef struct _SYSTEM_MEMORY_RESOURCE {\r | |
61 | LIST_ENTRY Link; // This attribute must be the first entry of this structure (to avoid pointer computation)\r | |
62 | EFI_PHYSICAL_ADDRESS PhysicalStart;\r | |
63 | UINT64 ResourceLength;\r | |
64 | } SYSTEM_MEMORY_RESOURCE;\r | |
65 | \r | |
66 | typedef VOID (*LINUX_KERNEL)(UINT32 Zero, UINT32 Arch, UINTN ParametersBase);\r | |
67 | \r | |
68 | //\r | |
69 | // Functions\r | |
70 | //\r | |
71 | EFI_STATUS\r | |
72 | PrintHii (\r | |
73 | IN CONST CHAR8 *Language OPTIONAL,\r | |
74 | IN CONST EFI_STRING_ID HiiFormatStringId,\r | |
75 | ...\r | |
76 | );\r | |
77 | \r | |
78 | VOID\r | |
79 | PrintHelp (\r | |
80 | IN CONST CHAR8 *Language OPTIONAL\r | |
81 | );\r | |
82 | \r | |
83 | EFI_STATUS\r | |
84 | ProcessShellParameters (\r | |
85 | OUT CHAR16 **KernelPath,\r | |
86 | OUT CHAR16 **FdtPath,\r | |
87 | OUT CHAR16 **InitrdPath,\r | |
88 | OUT CHAR16 **LinuxCommandLine,\r | |
89 | OUT UINTN *AtagMachineType\r | |
90 | );\r | |
91 | \r | |
92 | EFI_STATUS\r | |
93 | ProcessAppCommandLine (\r | |
94 | OUT CHAR16 **KernelTextDevicePath,\r | |
95 | OUT CHAR16 **FdtTextDevicePath,\r | |
96 | OUT CHAR16 **InitrdTextDevicePath,\r | |
97 | OUT CHAR16 **LinuxCommandLine,\r | |
98 | OUT UINTN *AtagMachineType\r | |
99 | );\r | |
100 | \r | |
101 | VOID\r | |
102 | PrintPerformance (\r | |
103 | VOID\r | |
104 | );\r | |
105 | \r | |
106 | EFI_STATUS\r | |
107 | GetSystemMemoryResources (\r | |
108 | IN LIST_ENTRY *ResourceList\r | |
109 | );\r | |
110 | \r | |
111 | EFI_STATUS\r | |
112 | PrepareFdt (\r | |
113 | IN EFI_PHYSICAL_ADDRESS SystemMemoryBase,\r | |
114 | IN CONST CHAR8* CommandLineArguments,\r | |
115 | IN EFI_PHYSICAL_ADDRESS InitrdImage,\r | |
116 | IN UINTN InitrdImageSize,\r | |
117 | IN OUT EFI_PHYSICAL_ADDRESS *FdtBlobBase,\r | |
118 | IN OUT UINTN *FdtBlobSize\r | |
119 | );\r | |
120 | \r | |
121 | /**\r | |
122 | Start a Linux kernel from a Device Path\r | |
123 | \r | |
124 | @param SystemMemoryBase Base of the system memory\r | |
125 | @param LinuxKernel Device Path to the Linux Kernel\r | |
126 | @param Parameters Linux kernel arguments\r | |
127 | @param Fdt Device Path to the Flat Device Tree\r | |
128 | @param MachineType ARM machine type value\r | |
129 | \r | |
130 | @retval EFI_SUCCESS All drivers have been connected\r | |
131 | @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found\r | |
132 | @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.\r | |
133 | @retval RETURN_UNSUPPORTED ATAG is not support by this architecture\r | |
134 | \r | |
135 | **/\r | |
136 | EFI_STATUS\r | |
137 | BootLinuxAtag (\r | |
138 | IN EFI_PHYSICAL_ADDRESS SystemMemoryBase,\r | |
139 | IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,\r | |
140 | IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,\r | |
141 | IN CONST CHAR8* CommandLineArguments,\r | |
142 | IN UINTN MachineType\r | |
143 | );\r | |
144 | \r | |
145 | /**\r | |
146 | Start a Linux kernel from a Device Path\r | |
147 | \r | |
148 | @param[in] LinuxKernelDevicePath Device Path to the Linux Kernel\r | |
149 | @param[in] InitrdDevicePath Device Path to the Initrd\r | |
150 | @param[in] Arguments Linux kernel arguments\r | |
151 | \r | |
152 | @retval EFI_SUCCESS All drivers have been connected\r | |
153 | @retval EFI_NOT_FOUND The Linux kernel Device Path has not been found\r | |
154 | @retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.\r | |
155 | \r | |
156 | **/\r | |
157 | EFI_STATUS\r | |
158 | BootLinuxFdt (\r | |
159 | IN EFI_PHYSICAL_ADDRESS SystemMemoryBase,\r | |
160 | IN EFI_DEVICE_PATH_PROTOCOL* LinuxKernelDevicePath,\r | |
161 | IN EFI_DEVICE_PATH_PROTOCOL* InitrdDevicePath,\r | |
162 | IN EFI_DEVICE_PATH_PROTOCOL* FdtDevicePath,\r | |
163 | IN CONST CHAR8* Arguments\r | |
164 | );\r | |
165 | \r | |
166 | #endif /* __LINUX_LOADER_H__ */\r |