]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: introduce QemuLoadImageLib library class
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 28 Feb 2020 16:04:01 +0000 (17:04 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 5 Mar 2020 19:45:05 +0000 (19:45 +0000)
Introduce the QemuLoadImageLib library class that we will instantiate
to load the kernel image passed via the QEMU command line using the
standard LoadImage boot service.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2566
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/Include/Library/QemuLoadImageLib.h [new file with mode: 0644]
OvmfPkg/OvmfPkg.dec

diff --git a/OvmfPkg/Include/Library/QemuLoadImageLib.h b/OvmfPkg/Include/Library/QemuLoadImageLib.h
new file mode 100644 (file)
index 0000000..746b74f
--- /dev/null
@@ -0,0 +1,84 @@
+/** @file\r
+  Load a kernel image and command line passed to QEMU via\r
+  the command line\r
+\r
+  Copyright (C) 2020, Arm, Limited.\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#ifndef QEMU_LOAD_IMAGE_LIB_H__\r
+#define QEMU_LOAD_IMAGE_LIB_H__\r
+\r
+#include <Uefi/UefiBaseType.h>\r
+#include <Base.h>\r
+\r
+#include <Protocol/LoadedImage.h>\r
+\r
+/**\r
+  Download the kernel, the initial ramdisk, and the kernel command line from\r
+  QEMU's fw_cfg. The kernel will be instructed via its command line to load\r
+  the initrd from the same Simple FileSystem where the kernel was loaded from.\r
+\r
+  @param[out] ImageHandle       The image handle that was allocated for\r
+                                loading the image\r
+\r
+  @retval EFI_SUCCESS           The image was loaded successfully.\r
+  @retval EFI_NOT_FOUND         Kernel image was not found.\r
+  @retval EFI_OUT_OF_RESOURCES  Memory allocation failed.\r
+  @retval EFI_PROTOCOL_ERROR    Unterminated kernel command line.\r
+  @retval EFI_ACCESS_DENIED     The underlying LoadImage boot service call\r
+                                returned EFI_SECURITY_VIOLATION, and the image\r
+                                was unloaded again.\r
+\r
+  @return                       Error codes from any of the underlying\r
+                                functions.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuLoadKernelImage (\r
+  OUT EFI_HANDLE          *ImageHandle\r
+  );\r
+\r
+/**\r
+  Transfer control to a kernel image loaded with QemuLoadKernelImage ()\r
+\r
+  @param[in,out]  ImageHandle     Handle of image to be started. May assume a\r
+                                  different value on return if the image was\r
+                                  reloaded.\r
+\r
+  @retval EFI_INVALID_PARAMETER   ImageHandle is either an invalid image handle\r
+                                  or the image has already been initialized with\r
+                                  StartImage\r
+  @retval EFI_SECURITY_VIOLATION  The current platform policy specifies that the\r
+                                  image should not be started.\r
+\r
+  @return                         Error codes returned by the started image.\r
+                                  On success, the function doesn't return.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuStartKernelImage (\r
+  IN  OUT EFI_HANDLE          *ImageHandle\r
+  );\r
+\r
+/**\r
+  Unloads an image loaded with QemuLoadKernelImage ().\r
+\r
+  @param  ImageHandle             Handle that identifies the image to be\r
+                                  unloaded.\r
+\r
+  @retval EFI_SUCCESS             The image has been unloaded.\r
+  @retval EFI_UNSUPPORTED         The image has been started, and does not\r
+                                  support unload.\r
+  @retval EFI_INVALID_PARAMETER   ImageHandle is not a valid image handle.\r
+\r
+  @return                         Exit code from the image's unload function.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+QemuUnloadKernelImage (\r
+  IN  EFI_HANDLE          ImageHandle\r
+  );\r
+\r
+#endif\r
index a21b279d140a51b09891d44e60a8461a544e99e2..055caaa430410adbc6cdee18df97ac5f2b696f5c 100644 (file)
   #\r
   QemuBootOrderLib|Include/Library/QemuBootOrderLib.h\r
 \r
+  ##  @libraryclass  Load a kernel image and command line passed to QEMU via\r
+  #                  the command line\r
+  #\r
+  QemuLoadImageLib|Include/Library/QemuLoadImageLib.h\r
+\r
   ##  @libraryclass  Serialize (and deserialize) variables\r
   #\r
   SerializeVariablesLib|Include/Library/SerializeVariablesLib.h\r