[ipxe-devel] [PATCH 1/3 v2] Implement scaffolding for new efimap command

Aaron Young Aaron.Young at oracle.com
Wed Feb 6 00:47:02 UTC 2019


Implement scaffolding for new efimap command.

The efimap command will display a list of available
EFI filesystems for use with sanboot command --drive
argument to boot a local UEFI disk.

Signed-off-by: Aaron Young <Aaron.Young at oracle.com>
---
 src/config/config_efi.c       |  8 +++++
 src/config/general.h          |  1 +
 src/hci/commands/efimap_cmd.c | 77 +++++++++++++++++++++++++++++++++++++++++++
 src/include/usr/efiboot.h     | 14 ++++++++
 src/interface/efi/efi_boot.c  | 35 ++++++++++++++++++++
 5 files changed, 135 insertions(+)
 create mode 100644 src/hci/commands/efimap_cmd.c
 create mode 100644 src/include/usr/efiboot.h
 create mode 100644 src/interface/efi/efi_boot.c

diff --git a/src/config/config_efi.c b/src/config/config_efi.c
index 92678d1..29bd14c 100644
--- a/src/config/config_efi.c
+++ b/src/config/config_efi.c
@@ -49,3 +49,11 @@ REQUIRE_OBJECT ( efi_fbcon );
 #ifdef DOWNLOAD_PROTO_FILE
 REQUIRE_OBJECT ( efi_local );
 #endif
+
+/*
+ * Drag in EFI-specific commands
+ *
+ */
+#ifdef EFIMAP_CMD
+REQUIRE_OBJECT ( efimap_cmd );
+#endif
diff --git a/src/config/general.h b/src/config/general.h
index 3c14a2c..a902934 100644
--- a/src/config/general.h
+++ b/src/config/general.h
@@ -154,6 +154,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 //#define PROFSTAT_CMD		/* Profiling commands */
 //#define NTP_CMD		/* NTP commands */
 //#define CERT_CMD		/* Certificate management commands */
+#define EFIMAP_CMD		/* EFI Map command */
 
 /*
  * ROM-specific options
diff --git a/src/hci/commands/efimap_cmd.c b/src/hci/commands/efimap_cmd.c
new file mode 100644
index 0000000..c183cbc
--- /dev/null
+++ b/src/hci/commands/efimap_cmd.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2019 Oracle. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * You can also choose to distribute this program under the terms of
+ * the Unmodified Binary Distribution Licence (as given in the file
+ * COPYING.UBDL), provided that you have satisfied its requirements.
+ */
+
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdio.h>
+#include <errno.h>
+#include <getopt.h>
+#include <string.h>
+#include <ipxe/command.h>
+#include <ipxe/parseopt.h>
+#include <usr/efiboot.h>
+
+/** @file
+ *
+ * EFIMAP command
+ *
+ */
+
+/** "efimap" options */
+struct efimap_options {};
+
+/** "efimap" option list */
+static struct option_descriptor efimap_opts[] = {};
+
+/** "efimap" command descriptor */
+static struct command_descriptor efimap_cmd =
+	COMMAND_DESC ( struct efimap_options, efimap_opts, 0, 0, NULL);
+
+/**
+ * The "efimap" command
+ *
+ * @v argc		Argument count
+ * @v argv		Argument list
+ * @ret rc		Return status code
+ */
+static int efimap_exec ( int argc, char **argv ) {
+	struct efimap_options opts;
+	int rc;
+
+	/* Parse options */
+	if ( ( rc = parse_options ( argc, argv, &efimap_cmd, &opts ) ) != 0 )
+		return rc;
+
+	efi_boot_display_map ();
+
+	return 0;
+}
+
+/** EFIMAP command */
+struct command efimap_commands[] __command = {
+	{
+		.name = "efimap",
+		.exec = efimap_exec,
+	},
+};
diff --git a/src/include/usr/efiboot.h b/src/include/usr/efiboot.h
new file mode 100644
index 0000000..816a0bb
--- /dev/null
+++ b/src/include/usr/efiboot.h
@@ -0,0 +1,14 @@
+#ifndef _USR_EFIBOOT_H
+#define _USR_EFIBOOT_H
+
+/** @file
+ *
+ * EFI boot support
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+extern void efi_boot_display_map ( void );
+
+#endif /* _USR_EFIBOOT_H */
diff --git a/src/interface/efi/efi_boot.c b/src/interface/efi/efi_boot.c
new file mode 100644
index 0000000..9976084
--- /dev/null
+++ b/src/interface/efi/efi_boot.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2019 Oracle. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * You can also choose to distribute this program under the terms of
+ * the Unmodified Binary Distribution Licence (as given in the file
+ * COPYING.UBDL), provided that you have satisfied its requirements.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+/**
+ * @file
+ *
+ * EFI boot local protocols
+ *
+ */
+
+void efi_boot_display_map ( void ) {
+	return;
+}
-- 
1.8.3.1




More information about the ipxe-devel mailing list