71 #define ENOENT_BOOT __einfo_error ( EINFO_ENOENT_BOOT ) 72 #define EINFO_ENOENT_BOOT \ 73 __einfo_uniqify ( EINFO_ENOENT, 0x01, "Nothing to boot" ) 75 #define NORMAL "\033[0m" 76 #define BOLD "\033[1m" 77 #define CYAN "\033[36m" 82 .description =
"Boot scriptlet",
84 .type = &setting_type_string,
98 .description =
"Preserve SAN connection",
100 .type = &setting_type_int8,
106 .
name =
"skip-san-boot",
107 .description =
"Do not boot from SAN device",
109 .type = &setting_type_int8,
130 unsigned int root_path_count,
int drive,
133 const char *san_filename;
137 if ( root_path_count ) {
143 printf (
"Could not open SAN device: %s\n",
153 printf (
"Could not describe SAN devices: %s\n",
155 goto err_san_describe;
169 printf (
"Could not boot image: %s\n",
186 san_filename = san_config->
filename;
188 printf (
"Booting%s%s from SAN device %#02x\n",
189 ( san_filename ?
" " :
"" ),
190 ( san_filename ? san_filename :
"" ),
drive );
192 printf (
"Boot from SAN device %#02x failed: %s\n",
195 printf (
"Skipping boot from SAN device %#02x\n",
209 printf (
"Unregistered SAN device %#02x\n",
drive );
246 char *raw_filename =
NULL;
251 memset ( &next_server, 0,
sizeof ( next_server ) );
261 &next_server.sin.sin_addr );
263 if ( ! raw_filename )
267 if ( next_server.sin.sin_addr.s_addr ) {
268 next_server.sin.sin_family =
AF_INET;
269 printf (
"Next server: %s\n",
270 inet_ntoa ( next_server.sin.sin_addr ) );
278 printf (
"Filename: %s\n", filename );
288 free ( raw_filename );
307 if ( ! raw_root_path )
315 printf (
"Root path: %s\n", root_path );
325 free ( raw_root_path );
337 char *raw_san_filename;
338 char *san_filename =
NULL;
343 if ( ! raw_san_filename )
348 if ( ! san_filename )
350 if ( san_filename[0] )
351 printf (
"SAN filename: %s\n", san_filename );
354 free ( raw_san_filename );
365 struct setting vendor_class_id_setting
367 struct setting pxe_discovery_control_setting
369 struct setting pxe_boot_menu_setting
372 unsigned int pxe_discovery_control;
375 buf,
sizeof ( buf ) );
376 pxe_discovery_control =
379 return ( (
strcmp ( buf,
"PXEClient" ) == 0 ) &&
381 ( ! ( ( pxe_discovery_control &
PXEBS_SKIP ) &&
393 struct uri *filename;
394 struct uri *root_path;
413 printf (
"Booting from PXE menu\n" );
415 goto err_pxe_menu_boot;
428 memset ( &san_config, 0,
sizeof ( san_config ) );
435 if ( filename && root_path &&
438 printf (
"Ignoring unsupported root path\n" );
444 if ( ! ( filename || root_path ) ) {
451 if ( (
rc =
uriboot ( filename, &root_path, ( root_path ? 1 : 0 ),
458 free ( san_filename );
521 unsigned int vlan ) {
556 printf (
"No more network devices\n" );
static unsigned int autoboot_vlan
VLAN tag of preferred autoboot device, if known.
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.
long fetch_intz_setting(struct settings *settings, const struct setting *setting)
Fetch value of signed integer setting, or zero.
struct arbelprm_rc_send_wqe rc
int ifconf(struct net_device *netdev, struct net_device_configurator *configurator, unsigned long timeout)
Perform network device configuration.
Dynamic Host Configuration Protocol.
#define TICKS_PER_SEC
Number of ticks per second.
#define PRODUCT_SHORT_NAME
#define SETTING_SANBOOT_EXTRA
SAN boot additional settings.
int printf(const char *fmt,...)
Write a formatted string to the console.
void set_autoboot_busloc(unsigned int bus_type, unsigned int location)
Identify autoboot device by bus type and location.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void uri_put(struct uri *uri)
Decrement URI reference count.
uint8_t ll_addr_len
Link-layer address length.
int san_describe(void)
Describe SAN devices for SAN-booted operating system.
static void close_other_netdevs(struct net_device *netdev)
Close all but one network device.
int san_hook(unsigned int drive, struct uri **uris, unsigned int count, unsigned int flags)
Hook SAN device.
static int uri_is_absolute(const struct uri *uri)
URI is an absolute URI.
#define FEATURES
Named feature table.
int netboot(struct net_device *netdev)
Boot from a network device.
int fetch_ipv4_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp)
Fetch value of IPv4 address setting.
struct uri * pxe_uri(struct sockaddr *sa_server, const char *filename)
Construct URI from server address and filename.
int san_boot(unsigned int drive, struct san_boot_config *config)
Attempt to boot from a SAN device.
static uint8_t autoboot_ll_addr[MAX_LL_ADDR_LEN]
Link-layer address of preferred autoboot device, if known.
unsigned int san_default_drive(void)
Get default SAN drive number.
int shell(void)
Start command shell.
#define SETTING_MISC
Miscellaneous settings.
char * expand_settings(const char *string)
Expand variables within string.
uint8_t drive
Drive number.
#define DHCP_EB_SCRIPTLET
Scriptlet.
Uniform Resource Identifiers.
struct device * parent
Bus device.
#define IMAGE_AUTO_UNREGISTER
Image will be automatically unregistered after execution.
void ifclose(struct net_device *netdev)
Close network device.
#define ENOTSUP
Operation not supported.
static int is_autoboot_ll_addr(struct net_device *netdev)
Test if network device matches the autoboot device link-layer address.
A hardware device description.
union ena_feature feature
Feature.
int ipxe(struct net_device *netdev)
Main iPXE flow of execution.
int image_exec(struct image *image)
Execute image.
#define DHCP_EB_SKIP_SAN_BOOT
Skip booting from SAN drive.
static int(* is_autoboot_device)(struct net_device *netdev)
Autoboot device tester.
uint64_t tag
Setting tag, if applicable.
const char * scheme
Scheme.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define __unused
Declare a variable or data structure as unused.
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
struct uri * fetch_next_server_and_filename(struct settings *settings)
Fetch next-server and filename settings into a URI.
SAN boot configuration parameters.
void imgstat(struct image *image)
Display status of an image.
static struct net_device * netdev
void route(void)
Print routing table.
const char * filename
Boot filename (or NULL to use default)
int fetch_string_setting(struct settings *settings, const struct setting *setting, char *data, size_t len)
Fetch value of string setting.
int fetch_string_setting_copy(struct settings *settings, const struct setting *setting, char **data)
Fetch value of string setting.
unsigned int location
Location.
const struct setting scriptlet_setting __setting(SETTING_MISC, scriptlet)
The "scriptlet" setting.
static struct image * first_image(void)
Retrieve first image.
Generalized socket address structure.
int fetch_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void *data, size_t len)
Fetch setting.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
#define for_each_netdev(netdev)
Iterate over all network devices.
static struct uri * fetch_root_path(struct settings *settings)
Fetch root-path setting into a URI.
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
#define ENODEV
No such device.
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
const char product_version[]
Product version string.
void set_autoboot_ll_addr(const void *ll_addr, size_t len, unsigned int vlan)
Identify autoboot device by link-layer address.
Data transfer interface opening.
Device should not be included in description tables.
unsigned long fetch_uintz_setting(struct settings *settings, const struct setting *setting)
Fetch value of unsigned integer setting, or zero.
int prompt(const char *text, unsigned long timeout, int key)
Prompt for keypress.
#define DHCP_PXE_BOOT_MENU
PXE boot menu.
static char * fetch_san_filename(struct settings *settings)
Fetch san-filename setting.
#define DHCP_EB_KEEP_SAN
Keep SAN drive registered.
static int autoboot(void)
Boot the system.
__weak int pxe_menu_boot(struct net_device *netdev __unused)
Perform PXE menu boot when PXE stack is not available.
int ifopen(struct net_device *netdev)
Open network device.
struct device * dev
Underlying hardware device.
Network device management.
static int setting_exists(struct settings *settings, const struct setting *setting)
Check existence of predefined setting.
#define DHCP_VENDOR_CLASS_ID
Vendor class identifier.
void san_unhook(unsigned int drive)
Unhook SAN device.
static int shell_banner(void)
Prompt for shell entry.
Skip discovery if filename present.
unsigned int bus_type
Bus type.
int strcmp(const char *first, const char *second)
Compare strings.
static int have_pxe_menu(void)
Check whether or not we have a usable PXE menu.
static struct device_description autoboot_desc
Device location of preferred autoboot device, if known.
struct device_description desc
Device description.
#define __weak
Declare a function as weak (use before the definition)
A Uniform Resource Identifier.
int imgdownload(struct uri *uri, unsigned long timeout, struct image **image)
Download a new image.
Network interface management.
struct uri_opener * xfer_uri_opener(const char *scheme)
Find opener for URI scheme.
void ifstat(struct net_device *netdev)
Print status of network device.
#define DHCP_PXE_DISCOVERY_CONTROL
PXE boot server discovery control.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
static unsigned int vlan_tag(struct net_device *netdev)
Get the VLAN tag.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
#define NULL
NULL pointer (VOID *)
static int is_autoboot_busloc(struct net_device *netdev)
Test if network device matches the autoboot device bus type and location.
#define AF_INET
IPv4 Internet addresses.
struct ll_protocol * ll_protocol
Link-layer protocol.
uint8_t system[ETH_ALEN]
System identifier.
struct uri * parse_uri(const char *uri_string)
Parse URI.
void * memset(void *dest, int character, size_t len) __nonnull