[menu] Add menu commands

Allow iPXE scripts to create menus.  For example:

    #!ipxe

    menu iSCSI boot demonstration
    item install         Install Fedora to ${root-path}
    item --default boot  Boot from ${root-path}
    item shell           Enter iPXE shell
    item exit            Exit to BIOS
    choose label && goto ${label}

    :boot
    sanboot ${root-path}

    :install
    sanhook ${root-path}
    chain http://${next-server}/fedora.ipxe

    :shell
    shell

    :exit

Inspired-by: Robin Smidsrød <robin@smidsrod.no>
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2012-03-29 00:05:22 +01:00
parent 493f194531
commit 3425726cf3
7 changed files with 312 additions and 0 deletions

View File

@@ -252,6 +252,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define ERRFILE_cms ( ERRFILE_OTHER | 0x002a0000 )
#define ERRFILE_imgtrust ( ERRFILE_OTHER | 0x002b0000 )
#define ERRFILE_menu_ui ( ERRFILE_OTHER | 0x002c0000 )
#define ERRFILE_menu_cmd ( ERRFILE_OTHER | 0x002d0000 )
/** @} */

View File

@@ -52,6 +52,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define DHCP_EB_FEATURE_EFI 0x24 /**< EFI format */
#define DHCP_EB_FEATURE_FCOE 0x25 /**< FCoE protocol */
#define DHCP_EB_FEATURE_VLAN 0x26 /**< VLAN support */
#define DHCP_EB_FEATURE_MENU 0x27 /**< Menu support */
/** @} */

View File

@@ -13,6 +13,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <stddef.h>
struct net_device;
struct menu;
/** A command-line option descriptor */
struct option_descriptor {
@@ -116,6 +117,7 @@ struct command_descriptor {
extern int parse_string ( const char *text, const char **value );
extern int parse_integer ( const char *text, unsigned int *value );
extern int parse_netdev ( const char *text, struct net_device **netdev );
extern int parse_menu ( const char *text, struct menu **menu );
extern int parse_flag ( const char *text __unused, int *flag );
extern int parse_key ( const char *text, unsigned int *key );
extern void print_usage ( struct command_descriptor *cmd, char **argv );