From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.groups.io with SMTP id smtpd.web11.11031.1583134186868986570 for ; Sun, 01 Mar 2020 23:29:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=tM8Ru6eF; spf=pass (domain: linaro.org, ip: 209.85.221.67, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wr1-f67.google.com with SMTP id v2so11048135wrp.12 for ; Sun, 01 Mar 2020 23:29:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CNiPUIZ4qtRX+prWjwDx831cWK8azyiRx5xybpJMlqY=; b=tM8Ru6eFhGIkIpS8DgsJaMMxPcpYiB9yqzGEv4czqB5WTdgJCzJkSfUcNQs/F9DjFK y/P/hc+QdrHAHniDC6W8m57WfNdND7HrPpsMqEYqIGxsVbKbgkC2qynz3syqjzDj7ox+ 0O2v1F3S8K2KCj9YUJUbQJATMd+sbLSnh+xXH7ssNv35ajvnTCNaMJPZT+QsZJrwhbj/ 5qLO9kjaxPAPPArkQu73Kj+V0BArx9+pGvrZD6zFZQuXitDa3/zXDFQdg/6hPSjoADj2 GZ2i3VAKNjFzyfh1dmUrMU+0P4GZms+NQD2RYKRQCXjTi7fFCPhhZdPAPOA+8Y/knQ6X xceA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CNiPUIZ4qtRX+prWjwDx831cWK8azyiRx5xybpJMlqY=; b=XF8fxt05CT8l2SDH38pkJE6kVYH0WUKt8F7Uwn1wBdaqe6uAC4AG0507HGx/VO9MZj Nr1LHeFx92sk0swuwDMWVQIPST05C/SVQKmMPl8g/uA0MK1PUNBDGcmhBQ87ltdrwjYj 2ZMjqS5Rm4nua097xz4OhmEC2SYlP7rEneZbdNwHf1pDtgA06FZrFHMNIedfYu5cZdvH bVgWk/yIlCHeMnLSEE7112BK0sJLY85cR+LZQK4/ftesyYufzpyJzsO1IQlinhJw+caL n/VuES9eq7kXnukVcd8xz7QphUWtZuE9RkR+KW70gpHwFw9KGTGi3jDJxrD7hYFNIHO6 D1og== X-Gm-Message-State: APjAAAWpZYitiK1zJp2ZQIAwEU8jGUz52Qg/URnLMYEOLWSvRIpZheD0 8D6gbo15T6tba70FZ8OQHmQrqvdZ69kKJg== X-Google-Smtp-Source: APXvYqz+qJ7SJNr/6UNGOvPdHODq6f/gZkL9jMlz/aCMxdy+s0P9d1ciGHKJwklt1bitMO2mMmcTuQ== X-Received: by 2002:adf:de0d:: with SMTP id b13mr20794268wrm.297.1583134184813; Sun, 01 Mar 2020 23:29:44 -0800 (PST) Return-Path: Received: from e123331-lin.home ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id z131sm6347153wmg.25.2020.03.01.23.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 23:29:44 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, Ard Biesheuvel Subject: [PATCH 03/13] OvmfPkg: introduce QemuLoadImageLib library class Date: Mon, 2 Mar 2020 08:29:26 +0100 Message-Id: <20200302072936.29221-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200302072936.29221-1-ard.biesheuvel@linaro.org> References: <20200302072936.29221-1-ard.biesheuvel@linaro.org> 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 --- OvmfPkg/Include/Library/QemuLoadImageLib.h | 78 ++++++++++++++++++++ OvmfPkg/OvmfPkg.dec | 5 ++ 2 files changed, 83 insertions(+) diff --git a/OvmfPkg/Include/Library/QemuLoadImageLib.h b/OvmfPkg/Include/Library/QemuLoadImageLib.h new file mode 100644 index 000000000000..304853096593 --- /dev/null +++ b/OvmfPkg/Include/Library/QemuLoadImageLib.h @@ -0,0 +1,78 @@ +/** @file + Load a kernel image and command line passed to QEMU via + the command line + + Copyright (C) 2020, Arm, Limited. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef QEMU_LOAD_IMAGE_LIB_H__ +#define QEMU_LOAD_IMAGE_LIB_H__ + +#include +#include + +#include + +/** + Download the kernel, the initial ramdisk, and the kernel command line from + QEMU's fw_cfg. The kernel will be instructed via its command line to load + the initrd from the same Simple FileSystem. + + @param[out] ImageHandle The image handle that was allocated for + loading the image + + @retval EFI_SUCCESS The image was loaded successfully. + @retval EFI_NOT_FOUND Kernel image was not found. + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + @retval EFI_PROTOCOL_ERROR Unterminated kernel command line. + + @return Error codes from any of the underlying + functions. +**/ +EFI_STATUS +EFIAPI +QemuLoadKernelImage ( + OUT EFI_HANDLE *ImageHandle + ); + +/** + Transfer control to a kernel image loaded with QemuLoadKernelImage () + + @param[in] ImageHandle Handle of image to be started. + + @retval EFI_INVALID_PARAMETER ImageHandle is either an invalid image handle + or the image has already been initialized with + StartImage + @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the + image should not be started. + + @return Error codes returned by the started image. + On success, the function doesn't return. +**/ +EFI_STATUS +EFIAPI +QemuStartKernelImage ( + IN EFI_HANDLE ImageHandle + ); + +/** + Unloads an image loaded with QemuLoadKernelImage (). + + @param ImageHandle Handle that identifies the image to be + unloaded. + + @retval EFI_SUCCESS The image has been unloaded. + @retval EFI_UNSUPPORTED The image has been started, and does not + support unload. + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + +**/ +EFI_STATUS +EFIAPI +QemuUnloadKernelImage ( + IN EFI_HANDLE ImageHandle + ); + +#endif diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index d88778600517..26f977bad795 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -58,6 +58,11 @@ [LibraryClasses] # QemuBootOrderLib|Include/Library/QemuBootOrderLib.h + ## @libraryclass Load a kernel image and command line passed to QEMU via + # the command line + # + QemuLoadImageLib|Include/Library/QemuLoadImageLib.h + ## @libraryclass Serialize (and deserialize) variables # SerializeVariablesLib|Include/Library/SerializeVariablesLib.h -- 2.17.1