iPXE
Functions
stdlib.h File Reference
#include <stdint.h>
#include <assert.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
unsigned long strtoul (const char *string, char **endp, int base)
 Convert string to numeric value. More...
 
unsigned long long strtoull (const char *string, char **endp, int base)
 Convert string to numeric value. More...
 
void *__malloc malloc (size_t size)
 Allocate memory. More...
 
void * realloc (void *old_ptr, size_t new_size)
 Reallocate memory. More...
 
void free (void *ptr)
 Free memory. More...
 
void *__malloc zalloc (size_t len)
 Allocate cleared memory. More...
 
static void *__malloc calloc (size_t nmemb, size_t size)
 Allocate cleared memory. More...
 
long int random (void)
 Generate a pseudo-random number between 0 and 2147483647L or 2147483562? More...
 
void srandom (unsigned int seed)
 Seed the pseudo-random number generator. More...
 
static int rand (void)
 
static void srand (unsigned int seed)
 
static __attribute__ ((always_inline)) int abs(int value)
 
int system (const char *command)
 Execute command line. More...
 
__asmcall int main (void)
 Main entry point. More...
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ strtoul()

unsigned long strtoul ( const char *  string,
char **  endp,
int  base 
)

Convert string to numeric value.

Parameters
stringString
endpEnd pointer (or NULL)
baseNumeric base (or zero to autodetect)
Return values
valueNumeric value

Definition at line 441 of file string.c.

441  {
442  unsigned long value = 0;
443  unsigned int digit;
444  int negate;
445 
446  /* Preprocess string */
447  string = strtoul_pre ( string, &negate, &base );
448 
449  /* Process digits */
450  for ( ; ; string++ ) {
451  digit = digit_value ( *string );
452  if ( digit >= ( unsigned int ) base )
453  break;
454  value = ( ( value * base ) + digit );
455  }
456 
457  /* Negate value if, applicable */
458  if ( negate )
459  value = -value;
460 
461  /* Fill in end pointer, if applicable */
462  if ( endp )
463  *endp = ( ( char * ) string );
464 
465  return value;
466 }
unsigned int digit_value(unsigned int character)
Calculate digit value.
Definition: string.c:383
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static const char * strtoul_pre(const char *string, int *negate, int *base)
Preprocess string for strtoul() or strtoull()
Definition: string.c:402
uint16_t base
Base address.
Definition: edd.h:14

References base, digit_value(), strtoul_pre(), and value.

Referenced by aoe_parse_uri(), bzimage_parse_cmdline(), bzimage_parse_cpio_cmdline(), efi_snp_hii_store(), fc_aton(), fc_id_aton(), ftp_parse_value(), ftp_reply(), gdbserial_init(), http_parse_content_length(), http_parse_retry_after(), http_parse_status(), http_rx_chunk_len(), ib_srp_parse_integer(), inet6_aton(), inet_aton(), iscsi_handle_chap_i_value(), iscsi_handle_targetaddress_value(), iscsi_parse_root_path(), mac_address_from_string_specs(), parse_int_setting(), parse_integer(), parse_setting_tag(), pnm_ascii(), scsi_parse_lun(), slam_parse_multicast_address(), string_test_exec(), tftp_process_blksize(), tftp_process_multicast(), tftp_process_tsize(), uri_decode(), uri_port(), and xenstore_read_num().

◆ strtoull()

unsigned long long strtoull ( const char *  string,
char **  endp,
int  base 
)

Convert string to numeric value.

Parameters
stringString
endpEnd pointer (or NULL)
baseNumeric base (or zero to autodetect)
Return values
valueNumeric value

Definition at line 476 of file string.c.

476  {
477  unsigned long long value = 0;
478  unsigned int digit;
479  int negate;
480 
481  /* Preprocess string */
482  string = strtoul_pre ( string, &negate, &base );
483 
484  /* Process digits */
485  for ( ; ; string++ ) {
486  digit = digit_value ( *string );
487  if ( digit >= ( unsigned int ) base )
488  break;
489  value = ( ( value * base ) + digit );
490  }
491 
492  /* Negate value if, applicable */
493  if ( negate )
494  value = -value;
495 
496  /* Fill in end pointer, if applicable */
497  if ( endp )
498  *endp = ( ( char * ) string );
499 
500  return value;
501 }
unsigned int digit_value(unsigned int character)
Calculate digit value.
Definition: string.c:383
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static const char * strtoul_pre(const char *string, int *negate, int *base)
Preprocess string for strtoul() or strtoull()
Definition: string.c:402
uint16_t base
Base address.
Definition: edd.h:14

References base, digit_value(), strtoul_pre(), and value.

◆ malloc()

void* __malloc malloc ( size_t  size)

Allocate memory.

Parameters
sizeRequested size
Return values
ptrMemory, or NULL

Allocates memory with no particular alignment requirement. ptr will be aligned to at least a multiple of sizeof(void*).

Definition at line 583 of file malloc.c.

583  {
584  void *ptr;
585 
586  ptr = realloc ( NULL, size );
587  if ( ASSERTED ) {
588  DBGC ( &heap, "Possible memory corruption detected from %p\n",
589  __builtin_return_address ( 0 ) );
590  }
591  return ptr;
592 }
#define DBGC(...)
Definition: compiler.h:505
static char heap[HEAP_SIZE]
The heap itself.
Definition: malloc.c:110
#define ASSERTED
Definition: assert.h:25
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
Definition: malloc.c:521
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References ASSERTED, DBGC, heap, NULL, realloc(), and size.

Referenced by add_ipv4_miniroute(), add_tls(), aes_unwrap(), aes_wrap(), alloc_iob_raw(), apply_dns_search(), ath5k_hw_rfregs_init(), chap_init(), cmdline_init(), cms_parse_signature_value(), deflate_test_exec(), der_asn1(), derwin(), dhcpv6_rx(), dupwin(), efi_download_start(), efi_local_check_volume_name(), efi_local_len(), eisabus_probe(), fc_ulp_login(), fetch_setting_copy(), format_uri_alloc(), http_format_ntlm_auth(), int13_hook(), ipoib_map_remac(), isabus_probe(), isapnpbus_probe(), iscsi_handle_chap_c_value(), iscsi_handle_chap_r_value(), iscsi_rx_buffered_data(), iscsi_scsi_command(), jme_alloc_rx_resources(), jme_alloc_tx_resources(), loopback_test(), mcabus_probe(), memcpy_test_speed(), mlx_memory_alloc_priv(), net80211_probe_start(), net80211_register(), newwin(), nfs_uri_symlink(), ntlm_authenticate_okx(), ocsp_response(), ocsp_uri_string(), parse_kv(), parse_net_args(), pci_vpd_resize(), pcibus_probe(), peerblk_decrypt(), peerblk_parse_header(), pem_asn1(), rsa_alloc(), sandev_parse_iso9660(), storef_setting(), storen_setting(), strndup(), t509bus_probe(), tls_assemble_block(), tls_assemble_stream(), tls_new_session_ticket(), uhci_enqueue(), usb_config_descriptor(), usb_get_string_descriptor(), usbio_config(), usbio_path(), vasprintf(), vesafb_mode_list(), vmbus_open(), wpa_make_rsn_ie(), wpa_start(), and zalloc().

◆ realloc()

void* realloc ( void *  old_ptr,
size_t  new_size 
)

Reallocate memory.

Parameters
old_ptrMemory previously allocated by malloc(), or NULL
new_sizeRequested size
Return values
new_ptrAllocated memory, or NULL

Allocates memory with no particular alignment requirement. new_ptr will be aligned to at least a multiple of sizeof(void*). If old_ptr is non-NULL, then the contents of the newly allocated memory will be the same as the contents of the previously allocated memory, up to the minimum of the old and new sizes. The old memory will be freed.

If allocation fails the previously allocated block is left untouched and NULL is returned.

Calling realloc() with a new size of zero is a valid way to free a memory block.

Definition at line 521 of file malloc.c.

521  {
522  struct autosized_block *old_block;
523  struct autosized_block *new_block;
524  size_t old_total_size;
525  size_t new_total_size;
526  size_t old_size;
527  void *new_ptr = NOWHERE;
528 
529  /* Allocate new memory if necessary. If allocation fails,
530  * return without touching the old block.
531  */
532  if ( new_size ) {
533  new_total_size = ( new_size +
534  offsetof ( struct autosized_block, data ) );
535  if ( new_total_size < new_size )
536  return NULL;
537  new_block = alloc_memblock ( new_total_size, 1, 0 );
538  if ( ! new_block )
539  return NULL;
540  new_block->size = new_total_size;
541  VALGRIND_MAKE_MEM_NOACCESS ( &new_block->size,
542  sizeof ( new_block->size ) );
543  new_ptr = &new_block->data;
544  VALGRIND_MALLOCLIKE_BLOCK ( new_ptr, new_size, 0, 0 );
545  }
546 
547  /* Copy across relevant part of the old data region (if any),
548  * then free it. Note that at this point either (a) new_ptr
549  * is valid, or (b) new_size is 0; either way, the memcpy() is
550  * valid.
551  */
552  if ( old_ptr && ( old_ptr != NOWHERE ) ) {
553  old_block = container_of ( old_ptr, struct autosized_block,
554  data );
555  VALGRIND_MAKE_MEM_DEFINED ( &old_block->size,
556  sizeof ( old_block->size ) );
557  old_total_size = old_block->size;
558  assert ( old_total_size != 0 );
559  old_size = ( old_total_size -
560  offsetof ( struct autosized_block, data ) );
561  memcpy ( new_ptr, old_ptr,
562  ( ( old_size < new_size ) ? old_size : new_size ) );
563  VALGRIND_FREELIKE_BLOCK ( old_ptr, 0 );
564  free_memblock ( old_block, old_total_size );
565  }
566 
567  if ( ASSERTED ) {
568  DBGC ( &heap, "Possible memory corruption detected from %p\n",
569  __builtin_return_address ( 0 ) );
570  }
571  return new_ptr;
572 }
void free_memblock(void *ptr, size_t size)
Free a memory block.
Definition: malloc.c:404
#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr, _qzz_len)
Definition: memcheck.h:131
char data[0]
Remaining data.
Definition: malloc.c:70
#define DBGC(...)
Definition: compiler.h:505
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
static char heap[HEAP_SIZE]
The heap itself.
Definition: malloc.c:110
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
size_t size
Size of this block.
Definition: malloc.c:68
#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed)
Definition: valgrind.h:4411
#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr, _qzz_len)
Definition: memcheck.h:111
void * alloc_memblock(size_t size, size_t align, size_t offset)
Allocate a memory block.
Definition: malloc.c:279
#define ASSERTED
Definition: assert.h:25
#define NOWHERE
Address for zero-length memory blocks.
Definition: malloc.c:88
A block of allocated memory complete with size information.
Definition: malloc.c:66
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define VALGRIND_FREELIKE_BLOCK(addr, rzB)
Definition: valgrind.h:4421
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References alloc_memblock(), assert(), ASSERTED, container_of, data, autosized_block::data, DBGC, free_memblock(), heap, memcpy(), NOWHERE, NULL, offsetof, autosized_block::size, VALGRIND_FREELIKE_BLOCK, VALGRIND_MAKE_MEM_DEFINED, VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MALLOCLIKE_BLOCK.

Referenced by asn1_grow(), bitmap_resize(), cachedhcp_init(), dhcpopt_init(), efi_ifr_op(), efi_ifr_string(), free(), ibft_alloc_string(), ibft_install(), line_buffer(), malloc(), nvo_realloc(), process_script(), and xferbuf_malloc_realloc().

◆ free()

void free ( void *  ptr)

Free memory.

Parameters
ptrMemory allocated by malloc(), or NULL

Memory allocated with malloc_dma() cannot be freed with free(); it must be freed with free_dma() instead.

If ptr is NULL, no action is taken.

Definition at line 604 of file malloc.c.

604  {
605 
606  realloc ( ptr, 0 );
607  if ( ASSERTED ) {
608  DBGC ( &heap, "Possible memory corruption detected from %p\n",
609  __builtin_return_address ( 0 ) );
610  }
611 }
#define DBGC(...)
Definition: compiler.h:505
static char heap[HEAP_SIZE]
The heap itself.
Definition: malloc.c:110
#define ASSERTED
Definition: assert.h:25
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
Definition: malloc.c:521

References ASSERTED, DBGC, heap, and realloc().

◆ zalloc()

void* __malloc zalloc ( size_t  size)

Allocate cleared memory.

Parameters
sizeRequested size
Return values
ptrAllocated memory

Allocate memory as per malloc(), and zero it.

This function name is non-standard, but pretty intuitive. zalloc(size) is always equivalent to calloc(1,size)

Definition at line 624 of file malloc.c.

624  {
625  void *data;
626 
627  data = malloc ( size );
628  if ( data )
629  memset ( data, 0, size );
630  if ( ASSERTED ) {
631  DBGC ( &heap, "Possible memory corruption detected from %p\n",
632  __builtin_return_address ( 0 ) );
633  }
634  return data;
635 }
#define DBGC(...)
Definition: compiler.h:505
static char heap[HEAP_SIZE]
The heap itself.
Definition: malloc.c:110
#define ASSERTED
Definition: assert.h:25
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
void * memset(void *dest, int character, size_t len) __nonnull

References ASSERTED, data, DBGC, heap, malloc(), memset(), and size.

Referenced by add_menu_item(), add_parameter(), alloc_ibdev(), alloc_image(), alloc_netdev(), alloc_pixbuf(), alloc_sandev(), alloc_usb(), alloc_usb_bus(), alloc_usb_hub(), aoecmd_create(), aoedev_open(), ar9300_eeprom_restore_internal(), arbel_alloc(), arbel_create_cq(), arbel_create_qp(), ata_open(), atadev_command(), ath5k_hw_attach(), ath5k_probe(), ath9k_init_softc(), ath_descdma_setup(), atl1e_setup_ring_resources(), autovivify_child_settings(), block_translate(), cachedhcp_init(), calloc(), cms_parse(), cms_signature(), concat_args(), create_downloader(), create_menu(), create_parameters(), create_pinger(), create_validator(), dhcp_deliver(), dhcpv6_register(), dns_resolv(), efi_block_boot_image(), efi_block_install(), efi_driver_start(), efi_file_open(), efi_image_cmdline(), efi_image_path(), efi_local_open(), efi_pxe_install(), efi_snp_hii_fetch(), efi_snp_hii_install(), efi_snp_hii_process(), efi_snp_hii_store(), efi_snp_probe(), efi_usb_install(), efi_usb_open(), efi_usb_probe(), efipci_start(), ehci_endpoint_open(), ehci_probe(), ehci_ring_alloc(), eoib_create_peer(), exanic_probe(), fc_els_create(), fc_ns_query(), fc_peer_create(), fc_port_open(), fc_ulp_create(), fc_xchg_create(), fcoe_probe(), fcpdev_open(), fcpdev_scsi_command(), fetch_string_setting_copy_alloc(), fetchf_setting_copy(), flexboot_nodnic_create_cq(), flexboot_nodnic_create_qp(), flexboot_nodnic_eth_open(), flexboot_nodnic_probe(), fragment_reassemble(), ftp_open(), generic_settings_store(), golan_alloc(), golan_create_cq(), golan_create_qp_aux(), guestinfo_fetch_type(), guestinfo_net_probe(), hermon_alloc(), hermon_create_cq(), hermon_create_qp(), http_connect(), http_open(), http_open_post_uri(), hub_probe(), hv_probe(), hvm_probe(), hw_open(), ib_cmrc_open(), ib_create_conn(), ib_create_cq(), ib_create_madx(), ib_create_mi(), ib_create_path(), ib_create_qp(), ib_mcast_attach(), ib_srp_open(), ibft_install(), init_mlx_utils(), ipv6_add_miniroute(), ipv6_register_settings(), iscsi_open(), linda_create_send_wq(), mlx_memory_zalloc_priv(), ndp_register_settings(), neighbour_create(), net80211_handle_mgmt(), net80211_prepare_assoc(), net80211_probe_start(), net80211_probe_step(), net80211_step_associate(), nfs_open(), nii_map(), numeric_resolv(), ocsp_check(), ocsp_uri_string(), open(), parse_uri(), peerblk_open(), peerdisc_create(), peerdisc_discovered(), peermux_filter(), ping_open(), png_pixbuf(), pxe_menu_parse(), qib7322_create_send_bufs(), qib7322_create_send_wq(), qib7322_probe(), rc80211_init(), resolv(), resolv_setting(), rtl818x_probe(), scsi_open(), scsidev_command(), sec80211_install(), sis190_mii_probe(), skge_probe(), skge_ring_alloc(), sky2_probe(), sky2_up(), slam_open(), srp_open(), srpdev_scsi_command(), start_dhcp(), start_dhcpv6(), start_ipv6conf(), start_ntp(), start_pxebs(), tcp_open(), tftp_core_open(), tg3_alloc_consistent(), tls_send_certificate(), tls_session(), tls_set_cipher(), txnic_bgx_probe(), txnic_pf_probe(), udp_open_common(), uhci_endpoint_open(), uhci_probe(), undipci_probe(), undirom_probe(), uri_dup(), usb_probe_all(), usbio_endpoint_open(), usbio_interfaces(), usbio_interrupt_open(), usbio_start(), usbkbd_probe(), validator_start_download(), virtnet_open_legacy(), virtnet_open_modern(), vmbus_probe(), vmbus_probe_channels(), vp_alloc_vq(), vxge_hw_device_initialize(), x509_alloc_chain(), x509_append(), x509_certificate(), xcm_create(), xenbus_probe_device(), xenstore_response(), xfer_open_named_socket(), xhci_bus_open(), xhci_device_open(), xhci_endpoint_open(), xhci_probe(), xhci_ring_alloc(), xsigo_ib_probe(), and xve_create().

◆ calloc()

static void* __malloc calloc ( size_t  nmemb,
size_t  size 
)
inlinestatic

Allocate cleared memory.

Parameters
nmembNumber of members
sizeSize of each member
Return values
ptrAllocated memory

Allocate memory as per malloc(), and zero it.

This is implemented as a static inline, with the body of the function in zalloc(), since in most cases nmemb will be 1 and doing the multiply is just wasteful.

Definition at line 45 of file stdlib.h.

45  {
46  return zalloc ( nmemb * size );
47 }
void *__malloc zalloc(size_t len)
Allocate cleared memory.
Definition: malloc.c:624
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16

References size, and zalloc().

Referenced by ath5k_desc_alloc(), ath5k_eeprom_convert_pcal_info_2413(), ath5k_eeprom_convert_pcal_info_5111(), ath5k_eeprom_convert_pcal_info_5112(), and slk_init().

◆ random()

long int random ( void  )

Generate a pseudo-random number between 0 and 2147483647L or 2147483562?

Return values
randPseudo-random number

Definition at line 30 of file random.c.

30  {
31  int32_t q;
32 
33  if ( ! rnd_seed ) /* Initialize linear congruential generator */
34  srandom ( currticks() );
35 
36  /* simplified version of the LCG given in Bruce Schneier's
37  "Applied Cryptography" */
38  q = ( rnd_seed / 53668 );
39  rnd_seed = ( 40014 * ( rnd_seed - 53668 * q ) - 12211 * q );
40  if ( rnd_seed < 0 )
41  rnd_seed += 2147483563L;
42  return rnd_seed;
43 }
static int32_t rnd_seed
Definition: random.c:12
void srandom(unsigned int seed)
Seed the pseudo-random number generator.
Definition: random.c:19
signed int int32_t
Definition: stdint.h:17
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42

References currticks(), rnd_seed, and srandom().

Referenced by arbel_alloc_qpn(), cipher_cost(), digest_cost(), dns_send_packet(), efi_pxe_udp_write(), efi_snp_hii_random_guid(), eth_random_addr(), forcedeth_open(), hermon_alloc_qpn(), http_digest_authenticate(), ib_create_conn(), ib_create_qp(), inject_corruption_nonzero(), inject_fault_nonzero(), iscsi_handle_chap_c_value(), iscsi_open_connection(), loopback_test(), memcpy_test_speed(), ntlm_response(), peerdisc_create(), profile_test_exec(), rand(), start_dhcp(), start_dhcpv6(), tcp_open(), tcpip_bind(), tcpip_random_okx(), tls_new_server_hello(), tls_send_client_hello(), vmbus_open(), and wep_encrypt().

◆ srandom()

void srandom ( unsigned int  seed)

Seed the pseudo-random number generator.

Parameters
seedSeed value

Definition at line 19 of file random.c.

19  {
20  rnd_seed = seed;
21  if ( ! rnd_seed )
22  rnd_seed = 4; /* Chosen by fair dice roll */
23 }
static int32_t rnd_seed
Definition: random.c:12

References rnd_seed.

Referenced by random(), srand(), and tcpip_random_okx().

◆ rand()

static int rand ( void  )
inlinestatic

Definition at line 59 of file stdlib.h.

59  {
60  return random();
61 }
long int random(void)
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
Definition: random.c:30

References random().

Referenced by cipher_cost(), digest_cost(), mlx_utils_rand_priv(), oncrpc_init_session(), and register_netdev().

◆ srand()

static void srand ( unsigned int  seed)
inlinestatic

Definition at line 63 of file stdlib.h.

63  {
64  srandom ( seed );
65 }
void srandom(unsigned int seed)
Seed the pseudo-random number generator.
Definition: random.c:19

References srandom().

Referenced by cipher_cost(), digest_cost(), and register_netdev().

◆ __attribute__()

static __attribute__ ( (always_inline)  )
inlinestatic

Definition at line 74 of file stdlib.h.

74  {
75  return __builtin_abs ( value );
76 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13

References value.

◆ system()

int system ( const char *  command)

Execute command line.

Parameters
commandCommand line
Return values
rcReturn status code

Execute the named command and arguments.

Definition at line 287 of file exec.c.

287  {
288  int count = split_command ( ( char * ) command, NULL );
289  char *all_tokens[ count + 1 ];
290  int ( * process_next ) ( int rc );
291  char *command_copy;
292  char **tokens;
293  int argc;
294  int process;
295  int rc = 0;
296 
297  /* Create modifiable copy of command */
298  command_copy = strdup ( command );
299  if ( ! command_copy )
300  return -ENOMEM;
301 
302  /* Split command into tokens */
303  split_command ( command_copy, all_tokens );
304  all_tokens[count] = NULL;
305 
306  /* Process individual commands */
307  process = 1;
308  for ( tokens = all_tokens ; ; tokens += ( argc + 1 ) ) {
309 
310  /* Find command terminator */
311  argc = command_terminator ( tokens, &process_next );
312 
313  /* Expand tokens and execute command */
314  if ( process ) {
315  char *argv[ argc + 1 ];
316 
317  /* Expand tokens */
318  if ( ( rc = expand_tokens ( argc, tokens, argv ) ) != 0)
319  break;
320  argv[argc] = NULL;
321 
322  /* Execute command */
323  rc = execv ( argv[0], argv );
324 
325  /* Free tokens */
326  free_tokens ( argv );
327  }
328 
329  /* Stop processing, if applicable */
331  break;
332 
333  /* Stop processing if we have reached the end of the
334  * command.
335  */
336  if ( ! process_next )
337  break;
338 
339  /* Determine whether or not to process next command */
340  process = process_next ( rc );
341  }
342 
343  /* Free modified copy of command */
344  free ( command_copy );
345 
346  return rc;
347 }
A process.
Definition: process.h:17
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A command-line command.
Definition: command.h:9
static void free_tokens(char **argv)
Free an expanded token list.
Definition: exec.c:272
static int expand_tokens(int argc, char **tokens, char **argv)
Expand settings within a token list.
Definition: exec.c:248
#define ENOMEM
Not enough space.
Definition: errno.h:534
Stop processing current command line.
Definition: shell.h:22
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
char * strdup(const char *src)
Duplicate string.
Definition: string.c:350
int shell_stopped(int stop)
Test and consume shell stop state.
Definition: exec.c:227
uint16_t count
Number of entries.
Definition: ena.h:22
static int command_terminator(char **tokens, int(**process_next)(int rc))
Find command terminator.
Definition: exec.c:183
static int split_command(char *command, char **tokens)
Split command line into tokens.
Definition: exec.c:121
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
int execv(const char *command, char *const argv[])
Execute command.
Definition: exec.c:60

References command_terminator(), count, ENOMEM, execv(), expand_tokens(), free, free_tokens(), NULL, rc, SHELL_STOP_COMMAND, shell_stopped(), split_command(), and strdup().

◆ main()

__asmcall int main ( void  )

Main entry point.

Return values
rcReturn status code

Definition at line 28 of file main.c.

28  {
29  int rc;
30 
31  /* Perform one-time-only initialisation (e.g. heap) */
32  initialise();
33 
34  /* Some devices take an unreasonably long time to initialise */
35  printf ( "%s initialising devices...", product_short_name );
36  startup();
37  printf ( "ok\n" );
38 
39  /* Attempt to boot */
40  if ( ( rc = ipxe ( NULL ) ) != 0 )
41  goto err_ipxe;
42 
43  err_ipxe:
44  shutdown_exit();
45  return rc;
46 }
const char product_short_name[]
Product short name string.
Definition: version.c:75
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:464
void initialise(void)
Initialise iPXE.
Definition: init.c:52
int ipxe(struct net_device *netdev)
Main iPXE flow of execution.
Definition: autoboot.c:567
static void shutdown_exit(void)
Shut down system for exit back to firmware.
Definition: init.h:84
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void startup(void)
Start up iPXE.
Definition: init.c:67

References initialise(), ipxe(), NULL, printf(), product_short_name, rc, shutdown_exit(), and startup().

Referenced by _efi_start().