QcomModulePkg: update the display commandline passed to kernel
The change allows a method to update the display kernel commandline
parameters passed to kernel.
fastboot oem display-cmdline <display_commandline_string>
The above command store the display commandline string passed as argument.
During the device bootup this string is appended with the display commandline
passed from UEFI to ABL.
Change-Id: I1e8ff8aa08cc260e2f211668350a75d367c306b0
Signed-off-by: Rahul Sharma <rahsha@codeaurora.org>
diff --git a/QcomModulePkg/Include/Library/DeviceInfo.h b/QcomModulePkg/Include/Library/DeviceInfo.h
index fe98053..c24d802 100644
--- a/QcomModulePkg/Include/Library/DeviceInfo.h
+++ b/QcomModulePkg/Include/Library/DeviceInfo.h
@@ -1,5 +1,5 @@
/*
- * * Copyright (c) 2011,2014-2015,2017 The Linux Foundation. All rights
+ * Copyright (c) 2011, 2014 - 2015, 2017, 2021 The Linux Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@
#define MAX_VERSION_LEN 64
#define MAX_VB_PARTITIONS 32
#define MAX_USER_KEY_SIZE 2048
+#define MAX_DISPLAY_CMDLINE_LEN 128
enum unlock_type {
UNLOCK = 0,
@@ -54,6 +55,7 @@
UINT32 user_public_key_length;
CHAR8 user_public_key[MAX_USER_KEY_SIZE];
UINT64 rollback_index[MAX_VB_PARTITIONS];
+ CHAR8 Display_Cmdline[MAX_DISPLAY_CMDLINE_LEN];
} DeviceInfo;
struct verified_boot_verity_mode {
@@ -90,4 +92,8 @@
EFI_STATUS
GetUserKey (CHAR8 **UserKey, UINT32 *UserKeySize);
EFI_STATUS EraseUserKey (VOID);
+EFI_STATUS
+StoreDisplayCmdLine (CONST CHAR8 *CmdLine, UINT32 CmdLineLen);
+EFI_STATUS
+ReadDisplayCmdLine (CHAR8 **CmdLine, UINT32 *CmdLineLen);
#endif
diff --git a/QcomModulePkg/Library/BootLib/DeviceInfo.c b/QcomModulePkg/Library/BootLib/DeviceInfo.c
index 49dff29..596bf62 100644
--- a/QcomModulePkg/Library/BootLib/DeviceInfo.c
+++ b/QcomModulePkg/Library/BootLib/DeviceInfo.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2018, 2021 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -93,6 +93,47 @@
}
EFI_STATUS
+StoreDisplayCmdLine (CONST CHAR8 *CmdLine, UINT32 CmdLineLen)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if (CmdLineLen > ARRAY_SIZE (DevInfo.Display_Cmdline))
+ {
+ DEBUG ((EFI_D_ERROR, "DisplayCmdLine, too large!\n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ gBS->SetMem (DevInfo.Display_Cmdline, sizeof (DevInfo.Display_Cmdline), 0);
+ gBS->CopyMem (DevInfo.Display_Cmdline, (CHAR8 *) CmdLine, CmdLineLen);
+
+ Status =
+ ReadWriteDeviceInfo (WRITE_CONFIG, (VOID *)&DevInfo, sizeof (DevInfo));
+ if (Status != EFI_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Unable to store display cmdline: %r\n", Status));
+ return Status;
+ }
+ return Status;
+}
+
+EFI_STATUS
+ReadDisplayCmdLine (CHAR8 **CmdLine, UINT32 *CmdLineLen)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ Status =
+ ReadWriteDeviceInfo (READ_CONFIG, (VOID *)&DevInfo, sizeof (DevInfo));
+ if (Status != EFI_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Unable to read display cmdline: %r\n", Status));
+ return Status;
+ }
+
+ *CmdLine = DevInfo.Display_Cmdline;
+ *CmdLineLen = ARRAY_SIZE (DevInfo.Display_Cmdline);
+
+ return Status;
+}
+
+EFI_STATUS
EnableEnforcingMode (BOOLEAN IsEnabled)
{
EFI_STATUS Status = EFI_SUCCESS;
diff --git a/QcomModulePkg/Library/BootLib/UpdateCmdLine.c b/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
index 4ad3870..5c862e6 100644
--- a/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
+++ b/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
@@ -3,7 +3,7 @@
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
- * Copyright (c) 2009-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-2021, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -66,7 +66,7 @@
STATIC CHAR8 *SkipRamFs = " skip_initramfs";
/* Display command line related structures */
-#define MAX_DISPLAY_CMD_LINE 256
+#define MAX_DISPLAY_CMD_LINE (256 + MAX_DISPLAY_CMDLINE_LEN)
STATIC CHAR8 DisplayCmdLine[MAX_DISPLAY_CMD_LINE];
STATIC UINTN DisplayCmdLineLen = sizeof (DisplayCmdLine);
@@ -277,6 +277,8 @@
STATIC VOID GetDisplayCmdline (VOID)
{
EFI_STATUS Status;
+ CHAR8 *Src = NULL;
+ UINT32 SrcLen = 0;
Status = gRT->GetVariable ((CHAR16 *)L"DisplayPanelConfiguration",
&gQcomTokenSpaceGuid, NULL, &DisplayCmdLineLen,
@@ -284,6 +286,13 @@
if (Status != EFI_SUCCESS) {
DEBUG ((EFI_D_ERROR, "Unable to get Panel Config, %r\n", Status));
}
+
+ Status = ReadDisplayCmdLine (&Src, &SrcLen);
+ if (Status != EFI_SUCCESS) {
+ DEBUG ((EFI_D_ERROR, "Unable to read display cmdline, %r\n", Status));
+ }
+
+ AsciiStrCatS (DisplayCmdLine, DisplayCmdLineLen, Src);
}
/*
diff --git a/QcomModulePkg/Library/FastbootLib/FastbootCmds.c b/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
index 169c55f..10f0e17 100644
--- a/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
+++ b/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
@@ -18,7 +18,7 @@
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
- * Copyright (c) 2015 - 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015 - 2021, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -3142,6 +3142,19 @@
}
STATIC VOID
+CmdOemDisplayCommandLine (CONST CHAR8 *Arg, VOID *Data, UINT32 Size)
+{
+ EFI_STATUS Status;
+
+ Status = StoreDisplayCmdLine (Arg, AsciiStrLen (Arg));
+ if (Status != EFI_SUCCESS) {
+ FastbootFail ("Failed to store display command line");
+ } else {
+ FastbootOkay ("");
+ }
+}
+
+STATIC VOID
CmdOemSelectDisplayPanel (CONST CHAR8 *arg, VOID *data, UINT32 sz)
{
EFI_STATUS Status;
@@ -3695,6 +3708,7 @@
{"reboot-bootloader", CmdRebootBootloader},
{"getvar:", CmdGetVar},
{"download:", CmdDownload},
+ {"oem display-cmdline", CmdOemDisplayCommandLine},
};
/* Register the commands only for non-user builds */