aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2023-05-22 14:05:15 +0100
committerMichael Brown <mcb30@ipxe.org>2023-05-22 15:37:11 +0100
commita95439a5188d96988ad7031cace084a13fcede14 (patch)
tree8c909c4247197c0b3103de40d3d5587be0b2bd6b
parent95b8338f0d4674b9f8bb51adf6886212d2b97e4b (diff)
downloadipxe-a95439a5188d96988ad7031cace084a13fcede14.tar.gz
WIP - EFI crutch
-rw-r--r--src/hci/commands/shim_cmd.c16
-rw-r--r--src/include/ipxe/efi/efi_shim.h1
-rw-r--r--src/include/usr/shimmgmt.h3
-rw-r--r--src/interface/efi/efi_shim.c5
-rw-r--r--src/usr/shimmgmt.c11
5 files changed, 31 insertions, 5 deletions
diff --git a/src/hci/commands/shim_cmd.c b/src/hci/commands/shim_cmd.c
index 00bd0acb1..1667e036c 100644
--- a/src/hci/commands/shim_cmd.c
+++ b/src/hci/commands/shim_cmd.c
@@ -40,6 +40,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
struct shim_options {
/** Download timeout */
unsigned long timeout;
+ /** Crutch image name or URI */
+ char *crutch;
/** Require third party loader */
int require_loader;
/** Allow PXE base code protocol */
@@ -50,6 +52,8 @@ struct shim_options {
static struct option_descriptor shim_opts[] = {
OPTION_DESC ( "timeout", 't', required_argument,
struct shim_options, timeout, parse_timeout ),
+ OPTION_DESC ( "crutch", 'c', required_argument,
+ struct shim_options, crutch, parse_string ),
OPTION_DESC ( "require-loader", 'l', no_argument,
struct shim_options, require_loader, parse_flag ),
OPTION_DESC ( "allow-pxe", 'p', no_argument,
@@ -70,6 +74,7 @@ static struct command_descriptor shim_cmd =
static int shim_exec ( int argc, char **argv ) {
struct shim_options opts;
struct image *image = NULL;
+ struct image *crutch = NULL;
struct image *kernel;
char *name_uri;
int download;
@@ -93,11 +98,20 @@ static int shim_exec ( int argc, char **argv ) {
goto err_image;
}
+ /* Acquire crutch image, if applicable */
+ if ( download && opts.crutch &&
+ ( ( rc = imgacquire ( opts.crutch, opts.timeout,
+ &crutch ) ) != 0 ) ) {
+ goto err_crutch;
+ }
+
/* (Un)register as shim */
- if ( ( rc = shim ( image, opts.require_loader, opts.allow_pxe ) ) != 0 )
+ if ( ( rc = shim ( image, crutch, opts.require_loader,
+ opts.allow_pxe ) ) != 0 )
goto err_shim;
err_shim:
+ err_crutch:
err_image:
err_parse:
return rc;
diff --git a/src/include/ipxe/efi/efi_shim.h b/src/include/ipxe/efi/efi_shim.h
index ad8d24dce..bf35adcef 100644
--- a/src/include/ipxe/efi/efi_shim.h
+++ b/src/include/ipxe/efi/efi_shim.h
@@ -15,6 +15,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
extern int efi_shim_require_loader;
extern int efi_shim_allow_pxe;
extern struct image_tag efi_shim __image_tag;
+extern struct image_tag efi_shim_crutch __image_tag;
extern int efi_shim_install ( struct image *shim, EFI_HANDLE handle,
wchar_t **cmdline );
diff --git a/src/include/usr/shimmgmt.h b/src/include/usr/shimmgmt.h
index 5030607ae..250680f0c 100644
--- a/src/include/usr/shimmgmt.h
+++ b/src/include/usr/shimmgmt.h
@@ -11,6 +11,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/image.h>
-extern int shim ( struct image *image, int require_loader, int allow_pxe );
+extern int shim ( struct image *image, struct image *crutch,
+ int require_loader, int allow_pxe );
#endif /* _USR_SHIMMGMT_H */
diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c
index 9b1b69e80..42faaa6dd 100644
--- a/src/interface/efi/efi_shim.c
+++ b/src/interface/efi/efi_shim.c
@@ -89,6 +89,11 @@ struct image_tag efi_shim __image_tag = {
.name = "SHIM",
};
+/** UEFI shim crutch image */
+struct image_tag efi_shim_crutch __image_tag = {
+ .name = "SHIMCRUTCH",
+};
+
/** Original GetMemoryMap() function */
static EFI_GET_MEMORY_MAP efi_shim_orig_map;
diff --git a/src/usr/shimmgmt.c b/src/usr/shimmgmt.c
index ba9c34803..7774a7157 100644
--- a/src/usr/shimmgmt.c
+++ b/src/usr/shimmgmt.c
@@ -37,18 +37,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
* Set shim image
*
* @v image Shim image, or NULL to clear shim
+ * @v crutch Shim crutch image, or NULL to clear crutch
* @v require_loader Require use of a third party loader
* @v allow_pxe Allow use of PXE base code
* @ret rc Return status code
*/
-int shim ( struct image *image, int require_loader, int allow_pxe ) {
+int shim ( struct image *image, struct image *crutch,
+ int require_loader, int allow_pxe ) {
- /* Record (or clear) shim image */
+ /* Record (or clear) shim and crutch images */
image_tag ( image, &efi_shim );
+ image_tag ( crutch, &efi_shim_crutch );
- /* Avoid including image in constructed initrd */
+ /* Avoid including images in constructed initrd */
if ( image )
image_hide ( image );
+ if ( crutch )
+ image_hide ( crutch );
/* Record configuration */
efi_shim_require_loader = require_loader;