]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/LinuxBootBootManagerLib/LinuxBootBm.c
ArmPkg: Apply uncrustify changes
[mirror_edk2.git] / ArmPkg / Library / LinuxBootBootManagerLib / LinuxBootBm.c
CommitLineData
62540372
NP
1/** @file\r
2 Implementation for PlatformBootManagerLib library class interfaces.\r
3\r
4 Copyright (C) 2015-2016, Red Hat, Inc.\r
5 Copyright (c) 2014 - 2019, ARM Ltd. All rights reserved.<BR>\r
6 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
7 Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
8 Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.<BR>\r
9\r
10 SPDX-License-Identifier: BSD-2-Clause-Patent\r
11\r
12**/\r
13\r
14#include <Uefi.h>\r
15\r
16#include <Guid/EventGroup.h>\r
17#include <Library/BaseLib.h>\r
18#include <Library/BaseMemoryLib.h>\r
19#include <Library/DebugLib.h>\r
20#include <Library/DevicePathLib.h>\r
21#include <Library/MemoryAllocationLib.h>\r
22#include <Library/PcdLib.h>\r
23#include <Library/UefiBootManagerLib.h>\r
24#include <Library/UefiBootServicesTableLib.h>\r
25#include <Library/UefiLib.h>\r
26#include <Library/UefiRuntimeServicesTableLib.h>\r
27#include <Protocol/LoadedImage.h>\r
28#include <Protocol/PlatformBootManager.h>\r
29\r
30/**\r
31 Register a boot option using a file GUID in the FV.\r
32\r
33 @param FileGuid The file GUID name in the FV.\r
34 @param Description The description of the boot option.\r
35 @param Attributes The attributes of the boot option.\r
36\r
37**/\r
38STATIC\r
39VOID\r
40PlatformRegisterFvBootOption (\r
429309e0
MK
41 CONST EFI_GUID *FileGuid,\r
42 CHAR16 *Description,\r
43 UINT32 Attributes\r
62540372
NP
44 )\r
45{\r
429309e0
MK
46 EFI_STATUS Status;\r
47 INTN OptionIndex;\r
48 EFI_BOOT_MANAGER_LOAD_OPTION NewOption;\r
49 EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;\r
50 UINTN BootOptionCount;\r
51 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;\r
52 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
53 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
62540372
NP
54\r
55 Status = gBS->HandleProtocol (\r
56 gImageHandle,\r
57 &gEfiLoadedImageProtocolGuid,\r
58 (VOID **)&LoadedImage\r
59 );\r
60 ASSERT_EFI_ERROR (Status);\r
61\r
62 EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);\r
63 DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);\r
64 ASSERT (DevicePath != NULL);\r
65 DevicePath = AppendDevicePathNode (\r
66 DevicePath,\r
67 (EFI_DEVICE_PATH_PROTOCOL *)&FileNode\r
68 );\r
69 ASSERT (DevicePath != NULL);\r
70\r
71 Status = EfiBootManagerInitializeLoadOption (\r
72 &NewOption,\r
73 LoadOptionNumberUnassigned,\r
74 LoadOptionTypeBoot,\r
75 Attributes,\r
76 Description,\r
77 DevicePath,\r
78 NULL,\r
79 0\r
80 );\r
81 ASSERT_EFI_ERROR (Status);\r
82 FreePool (DevicePath);\r
83\r
84 BootOptions = EfiBootManagerGetLoadOptions (\r
85 &BootOptionCount,\r
86 LoadOptionTypeBoot\r
87 );\r
88\r
89 OptionIndex = EfiBootManagerFindLoadOption (\r
90 &NewOption,\r
91 BootOptions,\r
92 BootOptionCount\r
93 );\r
94\r
95 if (OptionIndex == -1) {\r
96 Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);\r
97 ASSERT_EFI_ERROR (Status);\r
98 }\r
429309e0 99\r
62540372
NP
100 EfiBootManagerFreeLoadOption (&NewOption);\r
101 EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);\r
102}\r
103\r
104/**\r
105 Do the platform specific action before the console is connected.\r
106\r
107 Such as:\r
108 Update console variable;\r
109 Register new Driver#### or Boot####;\r
110 Signal ReadyToLock event.\r
111**/\r
112VOID\r
113EFIAPI\r
114PlatformBootManagerBeforeConsole (\r
115 VOID\r
116 )\r
117{\r
118 //\r
119 // Signal EndOfDxe PI Event\r
120 //\r
121 EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r
122}\r
123\r
124/**\r
125 Do the platform specific action after the console is connected.\r
126\r
127 Such as:\r
128 Dynamically switch output mode;\r
129 Signal console ready platform customized event;\r
130 Run diagnostics like memory testing;\r
131 Connect certain devices;\r
132 Dispatch additional option roms.\r
133**/\r
134VOID\r
135EFIAPI\r
136PlatformBootManagerAfterConsole (\r
137 VOID\r
138 )\r
139{\r
429309e0 140 EFI_GUID LinuxBootFileGuid;\r
62540372
NP
141\r
142 CopyGuid (&LinuxBootFileGuid, PcdGetPtr (PcdLinuxBootFileGuid));\r
143\r
144 if (!CompareGuid (&LinuxBootFileGuid, &gZeroGuid)) {\r
145 //\r
146 // Register LinuxBoot\r
147 //\r
148 PlatformRegisterFvBootOption (\r
149 &LinuxBootFileGuid,\r
150 L"LinuxBoot",\r
151 LOAD_OPTION_ACTIVE\r
152 );\r
153 } else {\r
154 DEBUG ((DEBUG_ERROR, "%a: PcdLinuxBootFileGuid was not set!\n", __FUNCTION__));\r
155 }\r
156}\r
157\r
158/**\r
159 This function is called each second during the boot manager waits the\r
160 timeout.\r
161\r
162 @param TimeoutRemain The remaining timeout.\r
163**/\r
164VOID\r
165EFIAPI\r
166PlatformBootManagerWaitCallback (\r
429309e0 167 UINT16 TimeoutRemain\r
62540372
NP
168 )\r
169{\r
170 return;\r
171}\r
172\r
173/**\r
174 The function is called when no boot option could be launched,\r
175 including platform recovery options and options pointing to applications\r
176 built into firmware volumes.\r
177\r
178 If this function returns, BDS attempts to enter an infinite loop.\r
179**/\r
180VOID\r
181EFIAPI\r
182PlatformBootManagerUnableToBoot (\r
183 VOID\r
184 )\r
185{\r
186 return;\r
187}\r