28#define SPCR_SIG EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
30extern UINT8 ConsolePrefHiiBin[];
31extern UINT8 ConsolePrefDxeStrings[];
48 CONSOLE_PREF_FORMSET_GUID
52 END_ENTIRE_DEVICE_PATH_SUBTYPE,
54 (UINT8)(END_DEVICE_PATH_LENGTH),
55 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
73 Status =
gBS->InstallMultipleProtocolInterfaces (
75 &gEfiDevicePathProtocolGuid,
76 &mConsolePrefDxeVendorDevicePath,
79 if (EFI_ERROR (Status)) {
84 &gConsolePrefFormSetGuid,
86 ConsolePrefDxeStrings,
91 if (HiiHandle ==
NULL) {
92 gBS->UninstallMultipleProtocolInterfaces (
94 &gEfiDevicePathProtocolGuid,
95 &mConsolePrefDxeVendorDevicePath,
98 return EFI_OUT_OF_RESOURCES;
116 if (EFI_ERROR (Status)) {
119 "%a: could not retrieve DT blob - %r\n",
126 Node = fdt_path_offset (Dtb,
"/chosen");
131 Error = fdt_delprop (Dtb, Node,
"stdout-path");
135 "%a: Failed to delete 'stdout-path' property: %a\n",
153 EFI_ACPI_TABLE_VERSION TableVersion;
156 Status =
gBS->LocateProtocol (
157 &gEfiAcpiTableProtocolGuid,
161 if (EFI_ERROR (Status)) {
165 Status =
gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid,
NULL, (VOID **)&Sdt);
166 if (EFI_ERROR (Status)) {
175 Status = Sdt->GetAcpiTable (
181 if (EFI_ERROR (Status)) {
185 if (TableHeader->Signature != SPCR_SIG) {
189 Status = AcpiTable->UninstallAcpiTable (AcpiTable, TableKey);
190 if (EFI_ERROR (Status)) {
193 "%a: failed to uninstall SPCR table - %r\n",
216 BufferSize =
sizeof (ConsolePref);
217 Status =
gRT->GetVariable (
218 CONSOLE_PREF_VARIABLE_NAME,
219 &gConsolePrefFormSetGuid,
224 if (EFI_ERROR (Status)) {
227 "%a: variable '%s' could not be read - bailing!\n",
229 CONSOLE_PREF_VARIABLE_NAME
234 if (ConsolePref.Console == CONSOLE_PREF_SERIAL) {
237 "%a: serial console preferred - doing nothing\n",
246 Status =
gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid,
NULL, &Gop);
247 if (EFI_ERROR (Status)) {
250 "%a: no GOP instances found - doing nothing (%r)\n",
257 RemoveDtStdoutPath ();
288 BufferSize =
sizeof (ConsolePref);
289 Status =
gRT->GetVariable (
290 CONSOLE_PREF_VARIABLE_NAME,
291 &gConsolePrefFormSetGuid,
296 if (EFI_ERROR (Status)) {
299 "%a: no console preference found, defaulting to graphical\n",
302 ConsolePref.Console = CONSOLE_PREF_GRAPHICAL;
305 if (!EFI_ERROR (Status) &&
306 (ConsolePref.Console != CONSOLE_PREF_GRAPHICAL) &&
307 (ConsolePref.Console != CONSOLE_PREF_SERIAL))
311 "%a: invalid value for %s, defaulting to graphical\n",
313 CONSOLE_PREF_VARIABLE_NAME
315 ConsolePref.Console = CONSOLE_PREF_GRAPHICAL;
316 Status = EFI_INVALID_PARAMETER;
322 if (EFI_ERROR (Status)) {
323 ZeroMem (&ConsolePref.Reserved, sizeof (ConsolePref.Reserved));
324 Status =
gRT->SetVariable (
325 CONSOLE_PREF_VARIABLE_NAME,
326 &gConsolePrefFormSetGuid,
328 sizeof (ConsolePref),
332 if (EFI_ERROR (Status)) {
335 "%a: gRT->SetVariable () failed - %r\n",
343 Status =
gBS->CreateEventEx (
348 &gEfiEventReadyToBootGuid,
353 return InstallHiiPages ();
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI ConsolePrefDxeEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define HARDWARE_DEVICE_PATH
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
EFI_RUNTIME_SERVICES * gRT
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
#define EFI_VARIABLE_NON_VOLATILE