summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c31
-rw-r--r--OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.uni3
2 files changed, 34 insertions, 0 deletions
diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
index 47ed26b50d..ed8fbaa770 100644
--- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
+++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
@@ -54,6 +54,33 @@ STATIC CONST SINGLE_NODE_VENDOR_MEDIA_DEVPATH mInitrdDevicePath = {
};
STATIC
+BOOLEAN
+IsOtherInitrdDevicePathAlreadyInstalled (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_HANDLE Handle;
+
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&mInitrdDevicePath;
+ Status = gBS->LocateDevicePath (&gEfiLoadFile2ProtocolGuid, &DevicePath,
+ &Handle);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ //
+ // Check whether the existing instance is one that we installed during
+ // a previous invocation.
+ //
+ if (Handle == mInitrdLoadFile2Handle) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+STATIC
EFI_STATUS
EFIAPI
InitrdLoadFile2 (
@@ -217,6 +244,10 @@ RunInitrd (
} else {
ASSERT(FALSE);
}
+ } else if (IsOtherInitrdDevicePathAlreadyInstalled ()) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ALREADY_INSTALLED),
+ mLinuxInitrdShellCommandHiiHandle, L"initrd");
+ ShellStatus = SHELL_UNSUPPORTED;
} else {
if (ShellCommandLineGetCount (Package) > 2) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
diff --git a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.uni b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.uni
index a88fa6e364..4b6b1285ff 100644
--- a/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.uni
+++ b/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.uni
@@ -18,6 +18,7 @@
#langdef en-US "english"
#string STR_GEN_PROBLEM #language en-US "%H%s%N: Unknown flag - '%H%s%N'\r\n"
+#string STR_GEN_ALREADY_INSTALLED #language en-US "%H%s%N: Linux initrd already provided by platform\r\n"
#string STR_GEN_TOO_MANY #language en-US "%H%s%N: Too many arguments.\r\n"
#string STR_GEN_TOO_FEW #language en-US "%H%s%N: Too few arguments.\r\n"
#string STR_GEN_FIND_FAIL #language en-US "%H%s%N: File not found - '%H%s%N'\r\n"
@@ -47,3 +48,5 @@
" Consumers of the LoadFile2 protocol on the LINUX_EFI_INITRD_MEDIA_GUID\r\n"
" device path that are started via means other than the shell will be able\r\n"
" to locate the protocol and invoke it.\r\n"
+" 3. Exposing an initrd using this command is only supported if no initrd is\r\n"
+" already being exposed by another driver on the platform.\r\n"