iPXE
|
Automatic booting. More...
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/netdevice.h>
#include <ipxe/vlan.h>
#include <ipxe/dhcp.h>
#include <ipxe/settings.h>
#include <ipxe/image.h>
#include <ipxe/sanboot.h>
#include <ipxe/uri.h>
#include <ipxe/open.h>
#include <ipxe/init.h>
#include <ipxe/keys.h>
#include <ipxe/version.h>
#include <ipxe/shell.h>
#include <ipxe/features.h>
#include <ipxe/timer.h>
#include <usr/ifmgmt.h>
#include <usr/route.h>
#include <usr/imgmgmt.h>
#include <usr/prompt.h>
#include <usr/autoboot.h>
#include <config/general.h>
#include <config/branding.h>
Go to the source code of this file.
Macros | |
#define | ENOENT_BOOT __einfo_error ( EINFO_ENOENT_BOOT ) |
#define | EINFO_ENOENT_BOOT __einfo_uniqify ( EINFO_ENOENT, 0x01, "Nothing to boot" ) |
#define | NORMAL "\033[0m" |
#define | BOLD "\033[1m" |
#define | CYAN "\033[36m" |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
const struct setting scriptlet_setting | __setting (SETTING_MISC, scriptlet) |
The "scriptlet" setting. More... | |
__weak int | pxe_menu_boot (struct net_device *netdev __unused) |
Perform PXE menu boot when PXE stack is not available. More... | |
const struct setting keep_san_setting | __setting (SETTING_SANBOOT_EXTRA, keep-san) |
The "keep-san" setting. More... | |
const struct setting skip_san_boot_setting | __setting (SETTING_SANBOOT_EXTRA, skip-san-boot) |
The "skip-san-boot" setting. More... | |
int | uriboot (struct uri *filename, struct uri **root_paths, unsigned int root_path_count, int drive, struct san_boot_config *san_config, unsigned int flags) |
Boot from filename and root-path URIs. More... | |
static void | close_other_netdevs (struct net_device *netdev) |
Close all but one network device. More... | |
struct uri * | fetch_next_server_and_filename (struct settings *settings) |
Fetch next-server and filename settings into a URI. More... | |
static struct uri * | fetch_root_path (struct settings *settings) |
Fetch root-path setting into a URI. More... | |
static char * | fetch_san_filename (struct settings *settings) |
Fetch san-filename setting. More... | |
static int | have_pxe_menu (void) |
Check whether or not we have a usable PXE menu. More... | |
int | netboot (struct net_device *netdev) |
Boot from a network device. More... | |
static int | is_autoboot_busloc (struct net_device *netdev) |
Test if network device matches the autoboot device bus type and location. More... | |
void | set_autoboot_busloc (unsigned int bus_type, unsigned int location) |
Identify autoboot device by bus type and location. More... | |
static int | is_autoboot_ll_addr (struct net_device *netdev) |
Test if network device matches the autoboot device link-layer address. More... | |
void | set_autoboot_ll_addr (const void *ll_addr, size_t len, unsigned int vlan) |
Identify autoboot device by link-layer address. More... | |
static int | autoboot (void) |
Boot the system. More... | |
static int | shell_banner (void) |
Prompt for shell entry. More... | |
int | ipxe (struct net_device *netdev) |
Main iPXE flow of execution. More... | |
Variables | |
static uint8_t | autoboot_ll_addr [MAX_LL_ADDR_LEN] |
Link-layer address of preferred autoboot device, if known. More... | |
static unsigned int | autoboot_vlan |
VLAN tag of preferred autoboot device, if known. More... | |
static struct device_description | autoboot_desc |
Device location of preferred autoboot device, if known. More... | |
static int(* | is_autoboot_device )(struct net_device *netdev) |
Autoboot device tester. More... | |
Automatic booting.
Definition in file autoboot.c.
#define ENOENT_BOOT __einfo_error ( EINFO_ENOENT_BOOT ) |
Definition at line 71 of file autoboot.c.
#define EINFO_ENOENT_BOOT __einfo_uniqify ( EINFO_ENOENT, 0x01, "Nothing to boot" ) |
Definition at line 72 of file autoboot.c.
#define NORMAL "\033[0m" |
Definition at line 75 of file autoboot.c.
#define BOLD "\033[1m" |
Definition at line 76 of file autoboot.c.
#define CYAN "\033[36m" |
Definition at line 77 of file autoboot.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
const struct setting scriptlet_setting __setting | ( | SETTING_MISC | , |
scriptlet | |||
) |
The "scriptlet" setting.
__weak int pxe_menu_boot | ( | struct net_device *netdev | __unused | ) |
Perform PXE menu boot when PXE stack is not available.
Definition at line 90 of file autoboot.c.
References ENOTSUP.
Referenced by netboot().
const struct setting keep_san_setting __setting | ( | SETTING_SANBOOT_EXTRA | , |
keep- | san | ||
) |
The "keep-san" setting.
const struct setting skip_san_boot_setting __setting | ( | SETTING_SANBOOT_EXTRA | , |
skip-san- | boot | ||
) |
The "skip-san-boot" setting.
int uriboot | ( | struct uri * | filename, |
struct uri ** | root_paths, | ||
unsigned int | root_path_count, | ||
int | drive, | ||
struct san_boot_config * | san_config, | ||
unsigned int | flags | ||
) |
Boot from filename and root-path URIs.
filename | Filename |
root_paths | Root path(s) |
root_path_count | Number of root paths |
drive | SAN drive (if applicable) |
san_config | SAN boot configuration parameters |
flags | Boot action flags |
rc | Return status code |
The somewhat tortuous flow of control in this function exists in order to ensure that the "sanboot" command remains identical in function to a SAN boot via a DHCP-specified root path, and to provide backwards compatibility for the "keep-san" and "skip-san-boot" options.
Definition at line 129 of file autoboot.c.
References drive, fetch_intz_setting(), san_boot_config::filename, flags, image::flags, IMAGE_AUTO_UNREGISTER, image_exec(), imgdownload(), imgstat(), NULL, printf(), rc, san_boot(), san_describe(), san_hook(), SAN_NO_DESCRIBE, san_unhook(), strerror(), URIBOOT_NO_SAN_BOOT, URIBOOT_NO_SAN_DESCRIBE, and URIBOOT_NO_SAN_UNHOOK.
Referenced by netboot(), pxe_menu_boot(), and sanboot_core_exec().
|
static |
Close all but one network device.
Called before a fresh boot attempt in order to free up memory. We don't just close the device immediately after the boot fails, because there may still be TCP connections in the process of closing.
Definition at line 226 of file autoboot.c.
References for_each_netdev, ifclose(), and netdev.
Referenced by netboot().
Fetch next-server and filename settings into a URI.
settings | Settings block |
uri | URI, or NULL on failure |
Definition at line 241 of file autoboot.c.
References AF_INET, expand_settings(), fetch_ipv4_setting(), fetch_setting(), fetch_string_setting_copy(), free, inet_ntoa(), memset(), NULL, printf(), pxe_uri(), sa, and sin.
Referenced by netboot(), and pxe_menu_boot().
Fetch root-path setting into a URI.
settings | Settings block |
uri | URI, or NULL on failure |
Definition at line 299 of file autoboot.c.
References expand_settings(), fetch_string_setting_copy(), free, NULL, parse_uri(), and printf().
Referenced by netboot().
|
static |
Fetch san-filename setting.
settings | Settings block |
san_filename | SAN filename, or NULL on failure |
Definition at line 336 of file autoboot.c.
References expand_settings(), fetch_string_setting_copy(), free, NULL, and printf().
Referenced by netboot().
|
static |
Check whether or not we have a usable PXE menu.
have_menu | A usable PXE menu is present |
Definition at line 364 of file autoboot.c.
References DHCP_PXE_BOOT_MENU, DHCP_PXE_DISCOVERY_CONTROL, DHCP_VENDOR_CLASS_ID, fetch_string_setting(), fetch_uintz_setting(), NULL, PXEBS_SKIP, setting_exists(), strcmp(), and setting::tag.
Referenced by netboot().
int netboot | ( | struct net_device * | netdev | ) |
Boot from a network device.
netdev | Network device |
rc | Return status code |
Definition at line 391 of file autoboot.c.
References close_other_netdevs(), ENOENT_BOOT, fetch_next_server_and_filename(), fetch_root_path(), fetch_san_filename(), san_boot_config::filename, free, have_pxe_menu(), ifconf(), ifopen(), ifstat(), memset(), netdev, NULL, printf(), pxe_menu_boot(), rc, route(), san_default_drive(), uri::scheme, strerror(), uri_is_absolute(), uri_put(), uriboot(), URIBOOT_NO_SAN, and xfer_uri_opener().
Referenced by autoboot(), autoboot_payload(), and ipxe().
|
static |
Test if network device matches the autoboot device bus type and location.
netdev | Network device |
is_autoboot | Network device matches the autoboot device |
Definition at line 473 of file autoboot.c.
References autoboot_desc, device_description::bus_type, device::desc, net_device::dev, device_description::location, netdev, and device::parent.
Referenced by set_autoboot_busloc().
void set_autoboot_busloc | ( | unsigned int | bus_type, |
unsigned int | location | ||
) |
Identify autoboot device by bus type and location.
bus_type | Bus type |
location | Location |
Definition at line 490 of file autoboot.c.
References autoboot_desc, device_description::bus_type, is_autoboot_busloc(), is_autoboot_device, and device_description::location.
Referenced by pci_autoboot_init().
|
static |
Test if network device matches the autoboot device link-layer address.
netdev | Network device |
is_autoboot | Network device matches the autoboot device |
Definition at line 506 of file autoboot.c.
References autoboot_ll_addr, autoboot_vlan, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memcmp(), netdev, and vlan_tag().
Referenced by set_autoboot_ll_addr().
void set_autoboot_ll_addr | ( | const void * | ll_addr, |
size_t | len, | ||
unsigned int | vlan | ||
) |
Identify autoboot device by link-layer address.
ll_addr | Link-layer address |
len | Length of link-layer address |
vlan | VLAN tag |
Definition at line 520 of file autoboot.c.
References autoboot_ll_addr, autoboot_vlan, is_autoboot_device, is_autoboot_ll_addr(), len, and memcpy().
Referenced by efi_set_autoboot_ll_addr().
|
static |
Boot the system.
Definition at line 538 of file autoboot.c.
References ENODEV, for_each_netdev, is_autoboot_device, netboot(), netdev, printf(), and rc.
Referenced by ipxe().
|
static |
Prompt for shell entry.
enter_shell | User wants to enter shell |
Definition at line 565 of file autoboot.c.
References BANNER_TIMEOUT, CTRL_B, printf(), PRODUCT_SHORT_NAME, prompt(), and TICKS_PER_SEC.
Referenced by ipxe().
int ipxe | ( | struct net_device * | netdev | ) |
Main iPXE flow of execution.
netdev | Network device, or NULL |
rc | Return status code |
Definition at line 585 of file autoboot.c.
References autoboot(), BOLD, CYAN, feature, FEATURES, fetch_string_setting_copy(), first_image(), for_each_table_entry, free, image_exec(), feature::name, netboot(), netdev, NORMAL, NULL, printf(), PRODUCT_NAME, PRODUCT_SHORT_NAME, PRODUCT_TAG_LINE, PRODUCT_URI, product_version, rc, shell(), shell_banner(), and system.
Referenced by efi_snp_load_file(), and main().
|
static |
Link-layer address of preferred autoboot device, if known.
Definition at line 59 of file autoboot.c.
Referenced by is_autoboot_ll_addr(), and set_autoboot_ll_addr().
|
static |
VLAN tag of preferred autoboot device, if known.
Definition at line 62 of file autoboot.c.
Referenced by is_autoboot_ll_addr(), and set_autoboot_ll_addr().
|
static |
Device location of preferred autoboot device, if known.
Definition at line 65 of file autoboot.c.
Referenced by is_autoboot_busloc(), and set_autoboot_busloc().
|
static |
Autoboot device tester.
Definition at line 68 of file autoboot.c.
Referenced by autoboot(), set_autoboot_busloc(), and set_autoboot_ll_addr().