summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c
diff options
context:
space:
mode:
Diffstat (limited to 'EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c')
-rw-r--r--EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c223
1 files changed, 144 insertions, 79 deletions
diff --git a/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c b/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c
index 08bba1bbf1..07b82892eb 100644
--- a/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c
+++ b/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c
@@ -24,24 +24,24 @@
#include "ConsolePrefDxe.h"
-#define SPCR_SIG EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
+#define SPCR_SIG EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
-extern UINT8 ConsolePrefHiiBin[];
-extern UINT8 ConsolePrefDxeStrings[];
+extern UINT8 ConsolePrefHiiBin[];
+extern UINT8 ConsolePrefDxeStrings[];
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
-STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
+STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
CONSOLE_PREF_FORMSET_GUID
@@ -50,13 +50,13 @@ STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
-STATIC EFI_EVENT mReadyToBootEvent;
+STATIC EFI_EVENT mReadyToBootEvent;
STATIC
EFI_STATUS
@@ -64,32 +64,39 @@ InstallHiiPages (
VOID
)
{
- EFI_STATUS Status;
- EFI_HII_HANDLE HiiHandle;
- EFI_HANDLE DriverHandle;
+ EFI_STATUS Status;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_HANDLE DriverHandle;
DriverHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mConsolePrefDxeVendorDevicePath,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mConsolePrefDxeVendorDevicePath,
+ NULL
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- HiiHandle = HiiAddPackages (&gConsolePrefFormSetGuid,
- DriverHandle,
- ConsolePrefDxeStrings,
- ConsolePrefHiiBin,
- NULL);
+ HiiHandle = HiiAddPackages (
+ &gConsolePrefFormSetGuid,
+ DriverHandle,
+ ConsolePrefDxeStrings,
+ ConsolePrefHiiBin,
+ NULL
+ );
if (HiiHandle == NULL) {
- gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
+ gBS->UninstallMultipleProtocolInterfaces (
+ DriverHandle,
&gEfiDevicePathProtocolGuid,
&mConsolePrefDxeVendorDevicePath,
- NULL);
+ NULL
+ );
return EFI_OUT_OF_RESOURCES;
}
+
return EFI_SUCCESS;
}
@@ -97,7 +104,7 @@ STATIC
VOID
RemoveDtStdoutPath (
VOID
-)
+ )
{
VOID *Dtb;
INT32 Node;
@@ -106,8 +113,12 @@ RemoveDtStdoutPath (
Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &Dtb);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO, "%a: could not retrieve DT blob - %r\n", __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: could not retrieve DT blob - %r\n",
+ __FUNCTION__,
+ Status
+ ));
return;
}
@@ -118,8 +129,12 @@ RemoveDtStdoutPath (
Error = fdt_delprop (Dtb, Node, "stdout-path");
if (Error) {
- DEBUG ((DEBUG_INFO, "%a: Failed to delete 'stdout-path' property: %a\n",
- __FUNCTION__, fdt_strerror (Error)));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: Failed to delete 'stdout-path' property: %a\n",
+ __FUNCTION__,
+ fdt_strerror (Error)
+ ));
}
}
@@ -129,16 +144,19 @@ RemoveSpcrTable (
VOID
)
{
- EFI_ACPI_SDT_PROTOCOL *Sdt;
- EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
- EFI_STATUS Status;
- UINTN TableIndex;
- EFI_ACPI_SDT_HEADER *TableHeader;
- EFI_ACPI_TABLE_VERSION TableVersion;
- UINTN TableKey;
-
- Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
- (VOID **)&AcpiTable);
+ EFI_ACPI_SDT_PROTOCOL *Sdt;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
+ EFI_STATUS Status;
+ UINTN TableIndex;
+ EFI_ACPI_SDT_HEADER *TableHeader;
+ EFI_ACPI_TABLE_VERSION TableVersion;
+ UINTN TableKey;
+
+ Status = gBS->LocateProtocol (
+ &gEfiAcpiTableProtocolGuid,
+ NULL,
+ (VOID **)&AcpiTable
+ );
if (EFI_ERROR (Status)) {
return;
}
@@ -153,8 +171,12 @@ RemoveSpcrTable (
TableHeader = NULL;
do {
- Status = Sdt->GetAcpiTable (TableIndex++, &TableHeader, &TableVersion,
- &TableKey);
+ Status = Sdt->GetAcpiTable (
+ TableIndex++,
+ &TableHeader,
+ &TableVersion,
+ &TableKey
+ );
if (EFI_ERROR (Status)) {
break;
}
@@ -165,9 +187,14 @@ RemoveSpcrTable (
Status = AcpiTable->UninstallAcpiTable (AcpiTable, TableKey);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN, "%a: failed to uninstall SPCR table - %r\n",
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: failed to uninstall SPCR table - %r\n",
+ __FUNCTION__,
+ Status
+ ));
}
+
break;
} while (TRUE);
}
@@ -180,24 +207,35 @@ OnReadyToBoot (
IN VOID *Context
)
{
- CONSOLE_PREF_VARSTORE_DATA ConsolePref;
- UINTN BufferSize;
- EFI_STATUS Status;
- VOID *Gop;
+ CONSOLE_PREF_VARSTORE_DATA ConsolePref;
+ UINTN BufferSize;
+ EFI_STATUS Status;
+ VOID *Gop;
BufferSize = sizeof (ConsolePref);
- Status = gRT->GetVariable (CONSOLE_PREF_VARIABLE_NAME,
- &gConsolePrefFormSetGuid, NULL, &BufferSize, &ConsolePref);
+ Status = gRT->GetVariable (
+ CONSOLE_PREF_VARIABLE_NAME,
+ &gConsolePrefFormSetGuid,
+ NULL,
+ &BufferSize,
+ &ConsolePref
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: variable '%s' could not be read - bailing!\n", __FUNCTION__,
- CONSOLE_PREF_VARIABLE_NAME));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: variable '%s' could not be read - bailing!\n",
+ __FUNCTION__,
+ CONSOLE_PREF_VARIABLE_NAME
+ ));
return;
}
if (ConsolePref.Console == CONSOLE_PREF_SERIAL) {
- DEBUG ((DEBUG_INFO,
- "%a: serial console preferred - doing nothing\n", __FUNCTION__));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: serial console preferred - doing nothing\n",
+ __FUNCTION__
+ ));
return;
}
@@ -206,9 +244,12 @@ OnReadyToBoot (
//
Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, &Gop);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO,
- "%a: no GOP instances found - doing nothing (%r)\n", __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: no GOP instances found - doing nothing (%r)\n",
+ __FUNCTION__,
+ Status
+ ));
return;
}
@@ -232,34 +273,46 @@ OnReadyToBoot (
EFI_STATUS
EFIAPI
ConsolePrefDxeEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- CONSOLE_PREF_VARSTORE_DATA ConsolePref;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ CONSOLE_PREF_VARSTORE_DATA ConsolePref;
+ UINTN BufferSize;
//
// Get the current console preference from the ConsolePref variable.
//
BufferSize = sizeof (ConsolePref);
- Status = gRT->GetVariable (CONSOLE_PREF_VARIABLE_NAME,
- &gConsolePrefFormSetGuid, NULL, &BufferSize, &ConsolePref);
+ Status = gRT->GetVariable (
+ CONSOLE_PREF_VARIABLE_NAME,
+ &gConsolePrefFormSetGuid,
+ NULL,
+ &BufferSize,
+ &ConsolePref
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO,
+ DEBUG ((
+ DEBUG_INFO,
"%a: no console preference found, defaulting to graphical\n",
- __FUNCTION__));
+ __FUNCTION__
+ ));
ConsolePref.Console = CONSOLE_PREF_GRAPHICAL;
}
if (!EFI_ERROR (Status) &&
- ConsolePref.Console != CONSOLE_PREF_GRAPHICAL &&
- ConsolePref.Console != CONSOLE_PREF_SERIAL) {
- DEBUG ((DEBUG_WARN, "%a: invalid value for %s, defaulting to graphical\n",
- __FUNCTION__, CONSOLE_PREF_VARIABLE_NAME));
+ (ConsolePref.Console != CONSOLE_PREF_GRAPHICAL) &&
+ (ConsolePref.Console != CONSOLE_PREF_SERIAL))
+ {
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: invalid value for %s, defaulting to graphical\n",
+ __FUNCTION__,
+ CONSOLE_PREF_VARIABLE_NAME
+ ));
ConsolePref.Console = CONSOLE_PREF_GRAPHICAL;
- Status = EFI_INVALID_PARAMETER; // trigger setvar below
+ Status = EFI_INVALID_PARAMETER; // trigger setvar below
}
//
@@ -267,21 +320,33 @@ ConsolePrefDxeEntryPoint (
//
if (EFI_ERROR (Status)) {
ZeroMem (&ConsolePref.Reserved, sizeof (ConsolePref.Reserved));
- Status = gRT->SetVariable (CONSOLE_PREF_VARIABLE_NAME,
+ Status = gRT->SetVariable (
+ CONSOLE_PREF_VARIABLE_NAME,
&gConsolePrefFormSetGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (ConsolePref), &ConsolePref);
+ sizeof (ConsolePref),
+ &ConsolePref
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: gRT->SetVariable () failed - %r\n",
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: gRT->SetVariable () failed - %r\n",
+ __FUNCTION__,
+ Status
+ ));
return Status;
}
}
- Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
- OnReadyToBoot, NULL, &gEfiEventReadyToBootGuid,
- &mReadyToBootEvent);
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ OnReadyToBoot,
+ NULL,
+ &gEfiEventReadyToBootGuid,
+ &mReadyToBootEvent
+ );
ASSERT_EFI_ERROR (Status);
return InstallHiiPages ();