david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
Commit Graph

617 Commits

Author SHA1 Message Date
Michael Brown b36882be34 [settings] Fix setting expansion
Commit 5fbd020 ("[settings] Display canonical setting name in output
of "show" command") introduced a regression causing all setting
expansions (e.g. "${net0/mac}") to expand to an empty string.

Fix by returning the formatted value length from
fetchf_named_setting(), as expected by the caller.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 10:08:16 +00:00
Michael Brown 247ac80556 [settings] Display canonical setting name in "config" user interface
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 21:26:05 +00:00
Michael Brown 5fbd0207b2 [settings] Display canonical setting name in output of "show" command
Enable the "show" command to display the full, canonicalised name of
the fetched setting.  For example:

  iPXE> show mac
  net0/mac:hex = 52:54:00:12:34:56

  iPXE> dhcp && show ip
  DHCP (net0 52:54:00:12:34:56)... ok
  net0.dhcp/ip:ipv4 = 10.0.0.168

  iPXE> show net0/6
  net0.dhcp/dns:ipv4 = 10.0.0.6

Inspired-by: Glenn Brown <glenn@myri.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 20:13:50 +00:00
Michael Brown ba8dd80487 [settings] Provide fetch_setting_origin()
Inspired-by: Glenn Brown <glenn@myri.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 19:55:06 +00:00
Glenn Brown f732fa28c8 [settings] Expose settings_name()
Expose settings_name(), shrink the unnecessarily large static buffer,
properly name root settings block, and simplify.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 19:55:05 +00:00
Michael Brown f5fd4dec3b [settings] Formalise notion of setting applicability
Expose a function setting_applies() to allow a caller to determine
whether or not a particular setting is applicable to a particular
settings block.

Restrict DHCP-backed settings blocks to accepting only DHCP-based
settings.

Restrict network device settings blocks to accepting only DHCP-based
settings and network device-specific settings such as "mac".

Inspired-by: Glenn Brown <glenn@myri.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-22 19:54:58 +00:00
Michael Brown 1c0ff6e1a7 [console] Move include/console.h to include/ipxe/console.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 20:09:26 +00:00
Michael Brown 4562223420 [image] Avoid ending up with multiple selected images on re-registration
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 17:21:34 +00:00
Michael Brown 9fa4ac2e9a [image] Simplify use of imgdownload()
Allow imgdownload() to be called without first having to allocate (and
so keep track of) an image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 16:57:34 +00:00
Michael Brown ae92700fd4 [image] Generalise "currently-running script" to "currently-running image"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 13:38:56 +00:00
Michael Brown d17a84a056 [image] Move the register_and_{select|boot}_image() functions to imgmgmt.c
These functions are used only as the "action" parameters to
imgdownload() or imgfetch(), and so belong in imgmgmt.c rather than
image.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-09 13:11:35 +00:00
Michael Brown 3936136e5e [monojob] Display percentage progress, if available
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 23:55:57 +00:00
Michael Brown 202cf094eb [main] Remove shell prompt when using an embedded image
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 20:42:36 +00:00
Michael Brown 7752541bb7 [image] Use list_first_entry() to clarify logic in main()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 19:53:58 +00:00
Michael Brown c4b6c244b0 [prompt] Replace shell_banner() with a generic prompt() function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 19:53:53 +00:00
Michael Brown 9d633bdc71 [console] Add a timeout parameter to getkey()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 19:37:30 +00:00
Michael Brown 2969a8567f [console] Avoid timer wraparound problems in getchar_timeout()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 19:22:20 +00:00
Michael Brown a281c4080b [cmdline] Add generic concat_args() function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 19:21:43 +00:00
Michael Brown 659c55c1a9 [image] Allow image_set_cmdline() to clear the command line
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 02:43:56 +00:00
Michael Brown 34b6ecb2f1 [image] Simplify image management
Refactor the {load,exec} image operations as {probe,exec}.  This makes
the probe mechanism cleaner, eliminates some forward declarations,
avoids holding magic state in image->priv, eliminates the possibility
of screwing up between the "load" and "exec" stages, and makes the
documentation simpler since the concept of "loading" (as distinct from
"executing") no longer needs to be explained.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-07 00:37:50 +00:00
Michael Brown 7d5dcc9299 [parseopt] Refer to online documentation for command help
The online documentation (e.g. http://ipxe.org/cmd/ifopen), though not
yet complete, is far more comprehensive than could be provided within
the iPXE binary.  Save around 200 bytes (compressed) by removing the
command descriptions from the interactive help, and instead referring
users directly to the web page describing the relevant command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-04 12:18:51 +00:00
Michael Brown 48a4001152 [settings] Make fetch_string_setting_copy() easier to use
Most callers of functions in the fetch_setting() family treat any
errors as meaning "non-existent setting".  In the case of
fetch_string_setting_copy(), an existent setting can still result in
an error due to memory allocation failure.

Allow the caller to distinguish between a non-existent setting and an
error in allocating memory for the copy, by returning success (and a
NULL buffer pointer) for a non-existent setting.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-03 20:03:08 +00:00
Michael Brown 09695f7be9 [settings] Avoid fetch_string_setting_copy() leaving an uninitialised pointer
For consistency with other functions in the fetch_setting() family,
ensure that fetch_string_setting_copy() always initialises the pointer
to the fetched setting even if fetching fails.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-03 17:13:44 +00:00
Michael Brown 3c9c27b8e6 [image] Allow download job to complete before acting upon image
Allow the monojob controlling the download to complete before calling
register_image() and friends.  This allows the trailing "ok" from
monojob.c to be printed before the image starts executing (and
possibly printing output of its own).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-02 19:29:24 +00:00
Michael Brown 990cbb8f2c [settings] Generalise expand_command() to expand_settings()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-28 00:16:18 +00:00
Michael Brown 962cada830 [init] Remove concept of "shutdown exit flags"
Remove the concept of shutdown exit flags, and replace it with a
counter used to keep track of exposed interfaces that require devices
to remain active.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-27 20:40:26 +00:00
Michael Brown 35a50399a5 [xfer] Expose xfer_uri_opener()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-27 18:46:07 +00:00
Michael Brown 17d28f4877 [nvo] Allow resizing of non-volatile stored option blocks
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-19 13:52:48 +00:00
Michael Brown 1651d4f6d7 [nvo] Remove the non-volatile options fragment list
Since its implementation several years ago, no driver has used a
fragment list containing more than a single fragment.  Simplify the
NVO core and the drivers that use it by removing the whole concept of
the fragment list, and using a simple (address,length) pair instead.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-11 21:24:40 +00:00
Michael Brown 17b6a3c506 [dhcp] Allow use of custom reallocation functions for DHCP option blocks
Allow functions other than realloc() to be used to reallocate DHCP
option block data, and specify the reallocation function at the time
of calling dhcpopt_init().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-01-11 21:24:40 +00:00
Michael Brown cb838cc419 [settings] Add fetch_ipv4_array_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-09 15:34:12 +00:00
Michael Brown 66531a5918 [debug] Add DBG_MD5() and related macros
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-09 13:13:31 +00:00
Michael Brown 9252fead9a [legal] Add missing copyright header and FILE_LICENCE macro
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-09 13:12:59 +00:00
Michael Brown ea0fcb9460 [fnrec] Enhance function recording
Enhance the information collected by the function recorder to include
the call site and entry/exit counts.  This allows fnrec.pl to produce
a call tree such as:

    step (from core/getkey.c:46 = 0x17e90) {
      ref_increment (from core/process.c:93 = 0x73ec) { }
      net_step (from core/process.c:96 = 0x73f1) {
        net_poll (from net/netdevice.c:741 = 0xbce6) {
          netdev_poll (from net/netdevice.c:700 = 0xbc58) { }
          netdev_rx_dequeue (from net/netdevice.c:709 = 0xbc65) { }
        }
      }
      ref_decrement (from core/process.c:96 = 0x73f9) { }
    }

Note that inlined functions are reported, confusingly, as extra calls
to the *containing* function.  Minimise this confusion by adding the
attribute "no_instrument_function" to all functions declared as
inline.  (Static functions that have been inlined autonomously by gcc
will still be problematic, but these are far fewer in number.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-09 13:11:27 +00:00
Shao Miller 3b51710156 [legal] Add FILE_LICENCE macro to some GPL-v2-or-later files
Changes were made to files where the licence text within the files
themselves confirms that the files are GPL version 2 or later.

Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-03 23:38:15 +00:00
Shao Miller 79a3799c41 [legal] Add FILE_LICENCE macro to some GPL-v2 files
Changes were made to files where the licence text within the files
themselves confirms that the files are GPL version 2.

Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-03 23:23:35 +00:00
Michael Brown 67b45186a5 [settings] Apply settings block name in register_settings()
Pass the settings block name as a parameter to register_settings(),
rather than defining it with settings_init() (and then possibly
changing it by directly manipulating settings->name).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-12-01 16:35:00 +00:00
Michael Brown 7bebe9579e [cmdline] Match user expectations for &&, ||, goto, and exit
The && and || operators should be left-associative, since that is how
they are treated in most other languages (including C and Unix
shell).  For example, in the command:

  dhcp net0 && goto dhcp_ok || echo No DHCP on net0

if the "dhcp net0" fails then the "echo" should be executed.

After an "exit" or a successful "goto", further commands on the same
line should never be executed.  For example:

  goto somewhere && echo This should never be printed
  exit 0 && echo This should never be printed
  exit 1 && echo This should never be printed

An "exit" should cause the current shell or script to terminate and
return the specified exit status to its caller.  For example:

  chain test.ipxe && echo Success || echo Failure
    [in test.ipxe]
    #!ipxe
    exit 0

should echo "Success".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-29 14:19:59 +00:00
Michael Brown 01df5c510f [parseopt] Allow "0x"-prefixed hexadecimal values in integer-valued options
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-29 14:18:43 +00:00
Michael Brown b87ed3295e [nvo] Allow fragment list to be omitted
Allow the fragment list to be omitted when calling nvo_init().
Omitting the list will cause the whole of the NVS device to be used
for NVO storage.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-25 00:05:20 +00:00
Michael Brown 66679fe7df [cmdline] Fix multi-layer variable expansion (again)
Expansion of the (admittedly perverse) "aaa}bbb${ccc" will currently
fail because expand_command() does not check that the closing "}"
occurs later than the opening "${".

Fix by ensuring that the most recent opening "${" is used to match
against the first *subsequent* closing "}".

Total cost of this change: -12 bytes, bringing the overall cost of
this feature to -4 bytes.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-23 00:18:11 +00:00
Michael Brown c1327e43ab [cmdline] Fix multi-layer variable expansion
Expansion of ${${foo}} will currently fail, because the first
opening "${" will be incorrectly matched against the first closing
"}", leading to an attempt to expand the variable "${foo".

Fix by ensuring that the most recent opening "${" is used to match
against the first closing "}".

Total cost: 8 bytes.  :)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-22 21:34:35 +00:00
Michael Brown ba92a46710 [cmdline] Add "isset" command
The "isset" command can be used to determine whether or not a setting
is present.  For example:

  isset ${net0/ip} || dhcp net0   # If we have no IP address, try DHCP

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-22 20:41:52 +00:00
Michael Brown 84aa702ff8 [script] Allow "exit" to exit a script
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-22 20:29:01 +00:00
Michael Brown 9ba988809d [cmdline] Add trivial logical operators to iPXE command lines
Make the "||" and "&&" operators available within iPXE commands.  For
example:

   dhcp net0 || set net0/ip 192.168.0.2

would attempt to acquire an IP address via DHCP, falling back to a
static address if DHCP fails.

As a side-effect, comments may now be appended to any line.  For
example:

  dhcp net0 || set net0/ip 192.168.0.2   # Try DHCP first, then static

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-22 01:47:07 +00:00
Michael Brown 216fd0a5cf [parseopt] Add generic option-parsing library
Command implementations tend to include a substantial amount of common
boilerplate code revolving around the parsing of command-line options
and arguments.  This increases the size cost of each command.

Introduce an option-parsing library that abstracts out the common
operations involved in command implementations.  This enables the size
of each individual command to be reduced, and also enhances
consistency between commands.

Total size of the library is 704 bytes, to be amortised across all
command implementations.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-21 20:38:26 +00:00
Michael Brown 312ae024d8 [settings] Add "hexhyp" setting type
Provide a "hexhyp" setting type, which functions identically to the
"hex" setting type except that it uses a hyphen instead of a colon as
the byte delimiter.

For example, if ${mac} expands to "52:54:00:12:34:56", then
${mac:hexhyp} will expand to "52-54-00-12-34-56".

Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-13 00:28:26 +00:00
Michael Brown 13e4b9ec49 [malloc] Avoid immediately clobbering reference count when freeing memory
Rearrange the fields in struct memory_block (without altering
MIN_MEMBLOCK_SIZE) so that the "count" field of a reference-counted
object is left intact when the memory containing the object is freed.
This allows for the possibility of detecting reference-counting errors
such as double-freeing.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-08 03:35:35 +00:00
Michael Brown 6e41f2cf18 [refcnt] Check reference validity on each use of ref_get() and ref_put()
Check that the reference count is valid (i.e. non-negative) on each
call to ref_get() and ref_put(), using an assert() at the point of
use.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-08 03:35:35 +00:00
Michael Brown fc69ab94d9 [malloc] Use list_for_each_entry_safe() when we may delete a list entry
free_memblock() currently uses list_for_each_entry() to iterate over
the free list, and may delete an entry over which it iterates.  While
there is no way that the deleted list entry could be overwritten
before we reference it, this does rely upon list_del() leaving the
"next" pointer intact, which is not guaranteed.  Discovered while
tracking down a list-corruption bug (as a result of having modified
list_del() to sanitise the deleted list entry).

Fix by using list_for_each_entry_safe().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-08 03:15:56 +00:00