iPXE
Macros | Enumerations | Functions
autoboot.h File Reference

Automatic booting. More...

#include <ipxe/device.h>

Go to the source code of this file.

Macros

#define URIBOOT_NO_SAN
 

Enumerations

enum  uriboot_flags { URIBOOT_NO_SAN_DESCRIBE = 0x0001, URIBOOT_NO_SAN_BOOT = 0x0002, URIBOOT_NO_SAN_UNHOOK = 0x0004 }
 uriboot() flags More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
void set_autoboot_busloc (unsigned int bus_type, unsigned int location)
 Identify autoboot device by bus type and location. More...
 
void set_autoboot_ll_addr (const void *ll_addr, size_t len, unsigned int vlan)
 Identify autoboot device by link-layer address. 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...
 
struct urifetch_next_server_and_filename (struct settings *settings)
 Fetch next-server and filename settings into a URI. More...
 
int netboot (struct net_device *netdev)
 Boot from a network device. More...
 
int ipxe (struct net_device *netdev)
 Main iPXE flow of execution. More...
 
int pxe_menu_boot (struct net_device *netdev)
 Boot using PXE boot menu. More...
 

Detailed Description

Automatic booting.

Definition in file autoboot.h.

Macro Definition Documentation

◆ URIBOOT_NO_SAN

#define URIBOOT_NO_SAN
Value:
URIBOOT_NO_SAN_BOOT | \
URIBOOT_NO_SAN_UNHOOK )

Definition at line 27 of file autoboot.h.

Enumeration Type Documentation

◆ uriboot_flags

uriboot() flags

Enumerator
URIBOOT_NO_SAN_DESCRIBE 
URIBOOT_NO_SAN_BOOT 
URIBOOT_NO_SAN_UNHOOK 

Definition at line 21 of file autoboot.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ set_autoboot_busloc()

void set_autoboot_busloc ( unsigned int  bus_type,
unsigned int  location 
)

Identify autoboot device by bus type and location.

Parameters
bus_typeBus type
locationLocation

Definition at line 491 of file autoboot.c.

491  {
492 
493  /* Record autoboot device description */
494  autoboot_desc.bus_type = bus_type;
495  autoboot_desc.location = location;
496 
497  /* Mark autoboot device as present */
499 }
static int(* is_autoboot_device)(struct net_device *netdev)
Autoboot device tester.
Definition: autoboot.c:69
unsigned int location
Location.
Definition: device.h:30
unsigned int bus_type
Bus type.
Definition: device.h:25
static struct device_description autoboot_desc
Device location of preferred autoboot device, if known.
Definition: autoboot.c:66
static int is_autoboot_busloc(struct net_device *netdev)
Test if network device matches the autoboot device bus type and location.
Definition: autoboot.c:474

References autoboot_desc, device_description::bus_type, is_autoboot_busloc(), is_autoboot_device, and device_description::location.

Referenced by pci_autoboot_init().

◆ 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.

Parameters
ll_addrLink-layer address
lenLength of link-layer address
vlanVLAN tag

Definition at line 521 of file autoboot.c.

522  {
523 
524  /* Record autoboot link-layer address (truncated if necessary) */
525  if ( len > sizeof ( autoboot_ll_addr ) )
526  len = sizeof ( autoboot_ll_addr );
527  memcpy ( autoboot_ll_addr, ll_addr, len );
528 
529  /* Record autoboot VLAN tag */
530  autoboot_vlan = vlan;
531 
532  /* Mark autoboot device as present */
534 }
static unsigned int autoboot_vlan
VLAN tag of preferred autoboot device, if known.
Definition: autoboot.c:63
static uint8_t autoboot_ll_addr[MAX_LL_ADDR_LEN]
Link-layer address of preferred autoboot device, if known.
Definition: autoboot.c:60
static int is_autoboot_ll_addr(struct net_device *netdev)
Test if network device matches the autoboot device link-layer address.
Definition: autoboot.c:507
static int(* is_autoboot_device)(struct net_device *netdev)
Autoboot device tester.
Definition: autoboot.c:69
void * memcpy(void *dest, const void *src, size_t len) __nonnull
ring len
Length.
Definition: dwmac.h:231

References autoboot_ll_addr, autoboot_vlan, is_autoboot_device, is_autoboot_ll_addr(), len, and memcpy().

Referenced by efi_set_autoboot_ll_addr().

◆ uriboot()

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.

Parameters
filenameFilename
root_pathsRoot path(s)
root_path_countNumber of root paths
driveSAN drive (if applicable)
san_configSAN boot configuration parameters
flagsBoot action flags
Return values
rcReturn 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 130 of file autoboot.c.

132  {
133  struct image *image;
134  const char *san_filename;
135  int rc;
136 
137  /* Hook SAN device, if applicable */
138  if ( root_path_count ) {
139  drive = san_hook ( drive, root_paths, root_path_count,
141  SAN_NO_DESCRIBE : 0 ) );
142  if ( drive < 0 ) {
143  rc = drive;
144  printf ( "Could not open SAN device: %s\n",
145  strerror ( rc ) );
146  goto err_san_hook;
147  }
148  printf ( "Registered SAN device %#02x\n", drive );
149  }
150 
151  /* Describe SAN device, if applicable */
152  if ( ! ( flags & URIBOOT_NO_SAN_DESCRIBE ) ) {
153  if ( ( rc = san_describe() ) != 0 ) {
154  printf ( "Could not describe SAN devices: %s\n",
155  strerror ( rc ) );
156  goto err_san_describe;
157  }
158  }
159 
160  /* Allow a root-path-only boot with skip-san enabled to succeed */
161  rc = 0;
162 
163  /* Attempt filename boot if applicable */
164  if ( filename ) {
165  if ( ( rc = imgdownload ( filename, 0, &image ) ) != 0 )
166  goto err_download;
167  imgstat ( image );
169  if ( ( rc = image_exec ( image ) ) != 0 ) {
170  printf ( "Could not boot image: %s\n",
171  strerror ( rc ) );
172  /* Fall through to (possibly) attempt a SAN boot
173  * as a fallback. If no SAN boot is attempted,
174  * our status will become the return status.
175  */
176  } else {
177  /* Always print an extra newline, because we
178  * don't know where the NBP may have left the
179  * cursor.
180  */
181  printf ( "\n" );
182  }
183  }
184 
185  /* Attempt SAN boot if applicable */
186  if ( ! ( flags & URIBOOT_NO_SAN_BOOT ) ) {
187  san_filename = san_config->filename;
188  if ( fetch_intz_setting ( NULL, &skip_san_boot_setting) == 0 ) {
189  printf ( "Booting%s%s from SAN device %#02x\n",
190  ( san_filename ? " " : "" ),
191  ( san_filename ? san_filename : "" ), drive );
192  rc = san_boot ( drive, san_config );
193  printf ( "Boot from SAN device %#02x failed: %s\n",
194  drive, strerror ( rc ) );
195  } else {
196  printf ( "Skipping boot from SAN device %#02x\n",
197  drive );
198  /* Avoid overwriting a possible failure status
199  * from a filename boot.
200  */
201  }
202  }
203 
204  err_download:
205  err_san_describe:
206  /* Unhook SAN device, if applicable */
207  if ( ! ( flags & URIBOOT_NO_SAN_UNHOOK ) ) {
208  if ( fetch_intz_setting ( NULL, &keep_san_setting ) == 0 ) {
209  san_unhook ( drive );
210  printf ( "Unregistered SAN device %#02x\n", drive );
211  } else {
212  printf ( "Preserving SAN device %#02x\n", drive );
213  }
214  }
215  err_san_hook:
216  return rc;
217 }
long fetch_intz_setting(struct settings *settings, const struct setting *setting)
Fetch value of signed integer setting, or zero.
Definition: settings.c:1054
unsigned int flags
Flags.
Definition: image.h:40
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:465
int san_describe(void)
Describe SAN devices for SAN-booted operating system.
int san_hook(unsigned int drive, struct uri **uris, unsigned int count, unsigned int flags)
Hook SAN device.
int san_boot(unsigned int drive, struct san_boot_config *config)
Attempt to boot from a SAN device.
An executable image.
Definition: image.h:24
uint8_t drive
Drive number.
Definition: int13.h:16
#define IMAGE_AUTO_UNREGISTER
Image will be automatically unregistered after execution.
Definition: image.h:83
int image_exec(struct image *image)
Execute image.
Definition: image.c:414
void imgstat(struct image *image)
Display status of an image.
Definition: imgmgmt.c:160
const char * filename
Boot filename (or NULL to use default)
Definition: sanboot.h:113
uint8_t flags
Flags.
Definition: ena.h:18
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
Device should not be included in description tables.
Definition: sanboot.h:107
void san_unhook(unsigned int drive)
Unhook SAN device.
int imgdownload(struct uri *uri, unsigned long timeout, struct image **image)
Download a new image.
Definition: imgmgmt.c:53
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

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().

◆ fetch_next_server_and_filename()

struct uri* fetch_next_server_and_filename ( struct settings settings)

Fetch next-server and filename settings into a URI.

Parameters
settingsSettings block
Return values
uriURI, or NULL on failure

Definition at line 242 of file autoboot.c.

242  {
243  union {
244  struct sockaddr sa;
245  struct sockaddr_in sin;
246  } next_server;
247  char *raw_filename = NULL;
248  struct uri *uri = NULL;
249  char *filename;
250 
251  /* Initialise server address */
252  memset ( &next_server, 0, sizeof ( next_server ) );
253 
254  /* If we have a filename, fetch it along with the next-server
255  * setting from the same settings block.
256  */
257  if ( fetch_setting ( settings, &filename_setting, &settings,
258  NULL, NULL, 0 ) >= 0 ) {
259  fetch_string_setting_copy ( settings, &filename_setting,
260  &raw_filename );
261  fetch_ipv4_setting ( settings, &next_server_setting,
262  &next_server.sin.sin_addr );
263  }
264  if ( ! raw_filename )
265  goto err_fetch;
266 
267  /* Populate server address */
268  if ( next_server.sin.sin_addr.s_addr ) {
269  next_server.sin.sin_family = AF_INET;
270  printf ( "Next server: %s\n",
271  inet_ntoa ( next_server.sin.sin_addr ) );
272  }
273 
274  /* Expand filename setting */
275  filename = expand_settings ( raw_filename );
276  if ( ! filename )
277  goto err_expand;
278  if ( filename[0] )
279  printf ( "Filename: %s\n", filename );
280 
281  /* Construct URI */
282  uri = pxe_uri ( &next_server.sa, filename );
283  if ( ! uri )
284  goto err_parse;
285 
286  err_parse:
287  free ( filename );
288  err_expand:
289  free ( raw_filename );
290  err_fetch:
291  return uri;
292 }
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:465
int fetch_ipv4_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp)
Fetch value of IPv4 address setting.
Definition: settings.c:913
struct uri * pxe_uri(struct sockaddr *sa_server, const char *filename)
Construct URI from server address and filename.
Definition: uri.c:809
IPv4 socket address.
Definition: in.h:85
char * expand_settings(const char *string)
Expand variables within string.
Definition: settings.c:2331
struct sockaddr sa
Definition: syslog.c:57
int fetch_string_setting_copy(struct settings *settings, const struct setting *setting, char **data)
Fetch value of string setting.
Definition: settings.c:874
Generalized socket address structure.
Definition: socket.h:97
int fetch_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void *data, size_t len)
Fetch setting.
Definition: settings.c:667
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
Definition: ipv4.c:814
A settings block.
Definition: settings.h:133
A Uniform Resource Identifier.
Definition: uri.h:65
struct sockaddr_in sin
Definition: syslog.c:59
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:64
void * memset(void *dest, int character, size_t len) __nonnull

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().

◆ netboot()

int netboot ( struct net_device netdev)

Boot from a network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 392 of file autoboot.c.

392  {
393  struct san_boot_config san_config;
394  struct uri *filename;
395  struct uri *root_path;
396  char *san_filename;
397  int rc;
398 
399  /* Close all other network devices */
401 
402  /* Open device and display device status */
403  if ( ( rc = ifopen ( netdev ) ) != 0 )
404  goto err_ifopen;
405  ifstat ( netdev );
406 
407  /* Configure device */
408  if ( ( rc = ifconf ( netdev, NULL, 0 ) ) != 0 )
409  goto err_dhcp;
410  route();
411 
412  /* Try PXE menu boot, if applicable */
413  if ( have_pxe_menu() ) {
414  printf ( "Booting from PXE menu\n" );
415  rc = pxe_menu_boot ( netdev );
416  goto err_pxe_menu_boot;
417  }
418 
419  /* Fetch next server and filename (if any) */
420  filename = fetch_next_server_and_filename ( NULL );
421 
422  /* Fetch root path (if any) */
423  root_path = fetch_root_path ( NULL );
424 
425  /* Fetch SAN filename (if any) */
426  san_filename = fetch_san_filename ( NULL );
427 
428  /* Construct SAN boot configuration parameters */
429  memset ( &san_config, 0, sizeof ( san_config ) );
430  san_config.filename = san_filename;
431 
432  /* If we have both a filename and a root path, ignore an
433  * unsupported or missing URI scheme in the root path, since
434  * it may represent an NFS root.
435  */
436  if ( filename && root_path &&
437  ( ( ! uri_is_absolute ( root_path ) ) ||
438  ( xfer_uri_opener ( root_path->scheme ) == NULL ) ) ) {
439  printf ( "Ignoring unsupported root path\n" );
440  uri_put ( root_path );
441  root_path = NULL;
442  }
443 
444  /* Check that we have something to boot */
445  if ( ! ( filename || root_path ) ) {
446  rc = -ENOENT_BOOT;
447  printf ( "Nothing to boot: %s\n", strerror ( rc ) );
448  goto err_no_boot;
449  }
450 
451  /* Boot using next server, filename and root path */
452  if ( ( rc = uriboot ( filename, &root_path, ( root_path ? 1 : 0 ),
453  san_default_drive(), &san_config,
454  ( root_path ? 0 : URIBOOT_NO_SAN ) ) ) != 0 )
455  goto err_uriboot;
456 
457  err_uriboot:
458  err_no_boot:
459  free ( san_filename );
460  uri_put ( root_path );
461  uri_put ( filename );
462  err_pxe_menu_boot:
463  err_dhcp:
464  err_ifopen:
465  return rc;
466 }
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.
Definition: autoboot.c:130
#define URIBOOT_NO_SAN
Definition: autoboot.h:27
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int ifconf(struct net_device *netdev, struct net_device_configurator *configurator, unsigned long timeout)
Perform network device configuration.
Definition: ifmgmt.c:275
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:465
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:206
static void close_other_netdevs(struct net_device *netdev)
Close all but one network device.
Definition: autoboot.c:227
static int uri_is_absolute(const struct uri *uri)
URI is an absolute URI.
Definition: uri.h:136
unsigned int san_default_drive(void)
Get default SAN drive number.
Definition: sanboot.c:973
const char * scheme
Scheme.
Definition: uri.h:69
struct uri * fetch_next_server_and_filename(struct settings *settings)
Fetch next-server and filename settings into a URI.
Definition: autoboot.c:242
SAN boot configuration parameters.
Definition: sanboot.h:111
static struct net_device * netdev
Definition: gdbudp.c:53
void route(void)
Print routing table.
Definition: route.c:40
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
static struct uri * fetch_root_path(struct settings *settings)
Fetch root-path setting into a URI.
Definition: autoboot.c:300
static char * fetch_san_filename(struct settings *settings)
Fetch san-filename setting.
Definition: autoboot.c:337
__weak int pxe_menu_boot(struct net_device *netdev __unused)
Perform PXE menu boot when PXE stack is not available.
Definition: autoboot.c:91
int ifopen(struct net_device *netdev)
Open network device.
Definition: ifmgmt.c:66
static int have_pxe_menu(void)
Check whether or not we have a usable PXE menu.
Definition: autoboot.c:365
A Uniform Resource Identifier.
Definition: uri.h:65
struct uri_opener * xfer_uri_opener(const char *scheme)
Find opener for URI scheme.
Definition: open.c:48
void ifstat(struct net_device *netdev)
Print status of network device.
Definition: ifmgmt.c:111
#define ENOENT_BOOT
Definition: autoboot.c:72
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
void * memset(void *dest, int character, size_t len) __nonnull

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().

◆ ipxe()

int ipxe ( struct net_device netdev)

Main iPXE flow of execution.

Parameters
netdevNetwork device, or NULL
Return values
rcReturn status code

Definition at line 586 of file autoboot.c.

586  {
587  struct feature *feature;
588  struct image *image;
589  char *scriptlet;
590  int rc;
591 
592  /*
593  * Print welcome banner
594  *
595  *
596  * If you wish to brand this build of iPXE, please do so by
597  * defining the string PRODUCT_NAME in config/branding.h.
598  *
599  * While nothing in the GPL prevents you from removing all
600  * references to iPXE or https://ipxe.org, we prefer you not
601  * to do so.
602  *
603  */
604  printf ( NORMAL "\n\n" PRODUCT_NAME "\n" BOLD PRODUCT_SHORT_NAME " %s"
605  NORMAL " -- " PRODUCT_TAG_LINE " -- "
606  CYAN PRODUCT_URI NORMAL "\nFeatures:", product_version );
608  printf ( " %s", feature->name );
609  printf ( "\n" );
610 
611  /* Boot system */
612  if ( ( image = first_image() ) != NULL ) {
613  /* We have an embedded image; execute it */
614  return image_exec ( image );
615  } else if ( shell_banner() ) {
616  /* User wants shell; just give them a shell */
617  return shell();
618  } else {
619  fetch_string_setting_copy ( NULL, &scriptlet_setting,
620  &scriptlet );
621  if ( scriptlet ) {
622  /* User has defined a scriptlet; execute it */
623  rc = system ( scriptlet );
624  free ( scriptlet );
625  return rc;
626  } else {
627  /* Try booting. If booting fails, offer the
628  * user another chance to enter the shell.
629  */
630  if ( netdev ) {
631  rc = netboot ( netdev );
632  } else {
633  rc = autoboot();
634  }
635  if ( shell_banner() )
636  rc = shell();
637  return rc;
638  }
639  }
640 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
char * name
Feature name.
Definition: features.h:81
#define PRODUCT_SHORT_NAME
Definition: branding.h:29
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:465
#define FEATURES
Named feature table.
Definition: features.h:85
int netboot(struct net_device *netdev)
Boot from a network device.
Definition: autoboot.c:392
#define NORMAL
Definition: autoboot.c:76
#define PRODUCT_URI
Definition: branding.h:30
int shell(void)
Start command shell.
Definition: shell.c:82
An executable image.
Definition: image.h:24
union ena_feature feature
Feature.
Definition: ena.h:14
#define CYAN
Definition: autoboot.c:78
int image_exec(struct image *image)
Execute image.
Definition: image.c:414
static struct net_device * netdev
Definition: gdbudp.c:53
int fetch_string_setting_copy(struct settings *settings, const struct setting *setting, char **data)
Fetch value of string setting.
Definition: settings.c:874
static struct image * first_image(void)
Retrieve first image.
Definition: image.h:203
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:386
const char product_version[]
Product version string.
Definition: version.c:71
static int autoboot(void)
Boot the system.
Definition: autoboot.c:539
#define PRODUCT_TAG_LINE
Definition: branding.h:39
A named feature.
Definition: features.h:79
static int shell_banner(void)
Prompt for shell entry.
Definition: autoboot.c:566
#define PRODUCT_NAME
Definition: branding.h:28
#define BOLD
Definition: autoboot.c:77
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
uint8_t system[ETH_ALEN]
System identifier.
Definition: eth_slow.h:25

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().

◆ pxe_menu_boot()

int pxe_menu_boot ( struct net_device netdev)

Boot using PXE boot menu.

Return values
rcReturn status code

Note that a success return status indicates that a PXE boot menu item has been selected, and that the DHCP session should perform a boot server request/ack.

Definition at line 344 of file pxemenu.c.

344  {
345  struct pxe_menu *menu;
346  unsigned int pxe_type;
347  struct settings *pxebs_settings;
348  struct uri *uri;
349  int rc;
350 
351  /* Parse and allocate boot menu */
352  if ( ( rc = pxe_menu_parse ( &menu ) ) != 0 )
353  return rc;
354 
355  /* Make selection from boot menu */
356  if ( ( rc = pxe_menu_prompt_and_select ( menu ) ) != 0 ) {
357  free ( menu );
358  return rc;
359  }
360  pxe_type = menu->items[menu->selection].type;
361 
362  /* Free boot menu */
363  free ( menu );
364 
365  /* Return immediately if local boot selected */
366  if ( ! pxe_type )
367  return 0;
368 
369  /* Attempt PXE Boot Server Discovery */
370  if ( ( rc = pxebs ( netdev, pxe_type ) ) != 0 )
371  return rc;
372 
373  /* Fetch next server and filename */
374  pxebs_settings = find_settings ( PXEBS_SETTINGS_NAME );
375  assert ( pxebs_settings );
376  uri = fetch_next_server_and_filename ( pxebs_settings );
377  if ( ! uri )
378  return -ENOMEM;
379 
380  /* Attempt boot */
381  rc = uriboot ( uri, NULL, 0, 0, NULL, URIBOOT_NO_SAN );
382  uri_put ( uri );
383  return rc;
384 }
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.
Definition: autoboot.c:130
#define URIBOOT_NO_SAN
Definition: autoboot.h:27
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A PXE boot menu.
Definition: pxemenu.c:63
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:206
static int pxe_menu_prompt_and_select(struct pxe_menu *menu)
Prompt for (and make selection from) PXE boot menu.
Definition: pxemenu.c:281
unsigned int selection
Selected menu item.
Definition: pxemenu.c:74
#define ENOMEM
Not enough space.
Definition: errno.h:535
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct uri * fetch_next_server_and_filename(struct settings *settings)
Fetch next-server and filename settings into a URI.
Definition: autoboot.c:242
static struct net_device * netdev
Definition: gdbudp.c:53
#define PXEBS_SETTINGS_NAME
Setting block name used for BootServerDHCP responses.
Definition: dhcp.h:717
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
A settings block.
Definition: settings.h:133
unsigned int type
Boot Server type.
Definition: pxemenu.c:52
struct pxe_menu_item items[0]
Menu items.
Definition: pxemenu.c:76
static int pxe_menu_parse(struct pxe_menu **menu)
Parse and allocate PXE boot menu.
Definition: pxemenu.c:88
struct settings * find_settings(const char *name)
Find settings block.
Definition: settings.c:407
A Uniform Resource Identifier.
Definition: uri.h:65
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
int pxebs(struct net_device *netdev, unsigned int pxe_type)
Definition: dhcpmgmt.c:42

References assert(), ENOMEM, fetch_next_server_and_filename(), find_settings(), free, pxe_menu::items, netdev, NULL, pxe_menu_parse(), pxe_menu_prompt_and_select(), pxebs(), PXEBS_SETTINGS_NAME, rc, pxe_menu::selection, pxe_menu_item::type, uri_put(), uriboot(), and URIBOOT_NO_SAN.