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

916 Commits

Author SHA1 Message Date
Michael Brown f3e5df3162 [settings] Merge SETTING_IPv4 and SETTING_IPv6
Allow for equivalent IPv4 and IPv6 settings (which requires equivalent
settings to be adjacent within the settings list).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 15:11:15 +00:00
Michael Brown eaa8615648 [settings] Allow for multiple definitions of each predefined setting
Allow for multiple setting definitions with the same name but
different scopes and tags.  For example, allow for a "filename"
setting with default scope and tag value 67 (for DHCPv4) and a
corresponding "filename" setting with IPv6 scope and tag value 59 (for
DHCPv6).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 12:43:28 +00:00
Michael Brown b0942534eb [settings] Force settings into alphabetical order within sections
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 12:43:28 +00:00
Michael Brown 60c4e62e5d [settings] Add fetch_ipv6_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 00:41:49 +00:00
Michael Brown 17451b53e2 [settings] Allow for IPv6 setting types in non-IPv6 builds
Allow for the existence of references to IPv6 setting types without
dragging in the whole IPv6 stack, by placing the definition of
setting_type_ipv6 in core/settings.c and providing weak stub methods
for parse_ipv6_setting() and format_ipv6_setting().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 00:41:49 +00:00
Michael Brown 22001cb206 [settings] Explicitly separate the concept of a completed fetched setting
The fetch_setting() family of functions may currently modify the
definition of the specified setting (e.g. to add missing type
information).  Clean up this interface by requiring callers to provide
an explicit buffer to contain the completed definition of the fetched
setting, if required.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-05 00:37:02 +00:00
Michael Brown a2638a8edd [fbcon] Add support for displaying a cursor
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-02 17:27:37 +00:00
Michael Brown 135bf35b11 [console] Allow '?' as an intermediate byte in ANSI escape sequences
The ANSI escape sequences to show and hide the cursor take the form
"<ESC>[?25h" and "<ESC>[?25l" respectively.  iPXE currently treats the
'?' character as the final byte.  Fix by explicitly treating '?' as an
intermediate byte.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-02 17:20:36 +00:00
Michael Brown decf9dd133 [fbcon] Add generic concept of a frame buffer console
Add support for a simple frame buffer console, using single buffering
and a fixed-width bitmap font.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:55:45 +00:00
Michael Brown c501c980e0 [console] Add concept of generic console configuration
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:55:43 +00:00
Michael Brown b2251743d8 [console] Allow console input and output to be disabled independently
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-28 05:54:53 +00:00
Michael Brown 09f31e9fc4 [image] Add image_pixbuf() to create pixel buffer from image
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Michael Brown 2c161283d5 [image] Allow for non-executable image formats
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Michael Brown 95851d1305 [pixbuf] Add generic concept of a pixel buffer
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Michael Brown 02a63c6dec [console] Pass escape sequence context to ANSI escape sequence handlers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Michael Brown 3102866a7f [main] Defer "initialising devices" message until initialising devices
Allow the "initialising devices" message to show up on consoles which
require initialisation, by deferring it until after initialise() has
completed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-27 11:27:50 +00:00
Michael Brown 4484edd1c0 [settings] Move user-class setting from dhcp.c to settings.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-14 12:35:43 +00:00
Michael Brown 4f078801e9 [base16] Fix comparison of signed and unsigned integers
gcc 4.7.1 fails to report this erroneous comparison unless assertions
are enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-14 12:35:43 +00:00
Michael Brown 43eba2f555 [cmdline] Generate command option help text automatically
Generate the command option help text automatically from the list of
defined options.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-07 17:00:51 +00:00
Michael Brown 3a67224c62 [parseopt] Add parse_netdev_configurator()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-05 17:30:20 +00:00
Michael Brown 92c56e129b [cmdline] Rewrite "sync" command to use monojob_wait()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 17:00:16 +00:00
Michael Brown dc7a023715 [monojob] Report ongoing job status as overall return status on timeout
If a job times out then use the most recent ongoing error status
reported via job_progress() (if available) as the overall return
status.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 16:26:08 +00:00
Michael Brown d1be9f4acc [monojob] Add timeout parameter to monojob_wait()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 16:26:02 +00:00
Michael Brown 5674a3c087 [job] Allow job_progress() to return an ongoing job status code, if known
Some background jobs have a meaningful ongoing status code (e.g. the
current link status for a job waiting for a network link to come up).
Allow this to be exposed via the job_progress() method.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 16:17:28 +00:00
Michael Brown a3346e3587 [interface] Default to calling intf_restart() in response to intf_close()
If an object interface does not provide an intf_close() method, then
default to calling intf_restart().  This allows static objects to
safely ignore intf_close(), without needing to add code solely to
ensure that the interface gets unplugged.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 16:17:28 +00:00
Michael Brown 5e1fa5cd40 [parseopt] Add parse_timeout()
Parsing a timeout value (specified in milliseconds) into an internal
timeout value measured in timer ticks is a common operation.  Provide
a parse_timeout() value to carry out this conversion automatically.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-11-01 02:26:19 +00:00
Michael Brown c597c7a071 [ping] Add generic ping mechanism
Add generic pinger mechanism (analogous to the generic downloader
mechanism) which opens a ping socket, transmits ping requests, and
passes information about ping replies to a callback function.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-10-21 15:08:18 +01:00
Michael Brown 12605efded [resolv] Use sock_aton() to allow parsing of arbitrary numeric addresses
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-10-21 14:34:13 +01:00
Michael Brown 3e975ecf3f [settings] Make built-in settings a linker table
Allow for configurable provision of built-in settings by placing them
in a linker table rather than an array.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-08-27 13:46:12 +01:00
Michael Brown e52380fa3b [uri] Allow URIs to incorporate a parameter list
HTTP POST requires the ability to associate a parameter list with a
URI.  There is no standardised syntax for this.  Use a non-standard
URI syntax to incorporate the specification of a parameter list within
a URI:

  URI = [ absoluteURI | relativeURI ]
	[ "#" fragment ] [ "##params" [ "=" paramsName ] ]

e.g.

  http://boot.ipxe.org/demo/boot.php##params
  http://boot.ipxe.org/demo/boot.php##params=mylist

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-08-19 17:22:58 +01:00
Michael Brown 564419c7e1 [params] Add support for the general concept of a form parameter list
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-08-19 17:22:52 +01:00
Michael Brown c692a690da [settings] Expose memory map via settings mechanism
Allow memory map entries to be read using the syntax

  ${memmap/<region>.<properties>.<scale>}

where <region> is the index of the memory region, <properties> is a
bitmask where bit 0 represents the start address and bit 1 represents
the length (allowing the end address to be encoded by having both bits
0 and 1 set), and <scale> is the number of bits by which to shift the
result.

This allows for several values of interest to be encoded.  For
example:

  ${memmap/<region>.1.0:hexraw}   # 64-bit start address of <region>
  ${memmap/<region>.2.0:hexraw}   # 64-bit length of <region>, in bytes
  ${memmap/<region>.3.0:hexraw}   # 64-bit end address of <region>
  ${memmap/<region>.2.10:int32}   # Length of <region>, in kB
  ${memmap/<region>.2.20:int32}   # Length of <region>, in MB

The numeric encoding is slightly more sophisticated than described
here, allowing a single encoding to cover multiple regions.  (See the
source code for details.)  The primary use case for this feature is to
provide the total system memory size (in MB) via the "memsize"
predefined setting.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-08-12 22:00:36 +01:00
Michael Brown 55daa953fb [settings] Allow numeric_setting_value() to handle long setting values
Allow numeric_setting_value() to handle e.g. the byte sequence

  00:00:00:00:12:34:56:78

by returning -ERANGE only if the value actually overflows the return
type.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-08-12 18:25:18 +01:00
Michael Brown c70d4cb1b3 [settings] Introduce the generalised concept of a numeric setting
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-08-01 14:39:58 +01:00
Michael Brown bd6c3a1886 [settings] Remove now-unused fetchf_named_setting() and storef_named_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-22 16:39:32 +01:00
Michael Brown 1625a8c05f [parseopt] Add parse_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-22 16:30:44 +01:00
Michael Brown 46433f9b5e [parseopt] Move parse_settings() to parseopt.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-22 16:16:44 +01:00
Michael Brown b87020a090 [parseopt] Allow parsed option to be modified
Parsing a setting name requires the ability to modify the text being
parsed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-22 16:16:11 +01:00
Michael Brown 8ea5822afd [settings] Remove now-unused store_named_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-19 15:29:23 +01:00
Michael Brown 129a70631a [settings] Eliminate call to fetchf_named_setting() in expand_settings()
Use parse_setting_name() and fetchf_setting_copy() in
expand_settings(), to eliminate the call to fetchf_named_setting().

This change also eliminates the potentially large stack-allocated
buffer in expand_settings().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-19 15:29:21 +01:00
Michael Brown a5be7c4f29 [settings] Add fetchf_setting_copy()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-19 15:23:54 +01:00
Michael Brown 72fb55e437 [settings] Change "not-found" semantics of fetch_setting_copy()
fetch_settings_copy() currently returns success and a NULL data
pointer to indicate a non-existent setting.  This is intended to allow
the caller to differentiate between a non-existent setting and an
error in allocating memory for the copy of the setting.

The underlying settings blocks' fetch() methods provide no way to
perform an existence check separate from an attempt to fetch the
setting.  A "non-existent setting" therefore means simply a setting
for which an error was encountered when attempting to fetch from every
settings block within the subtree.

Since any underlying error within a settings block (e.g. a GuestRPC
failure when attempting to retrieve a VMware GuestInfo setting) will
produce the effect of a "non-existent setting", it seems somewhat
meaningless to give special treatment to memory allocation errors
within fetch_setting_copy().

Remove the special treatment and simplify the semantics of
fetch_setting_copy() by directly passing through any underlying error
(including non-existence) encountered while fetching the setting.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-19 15:15:28 +01:00
Michael Brown 5ffcae69c0 [settings] Expose parse_setting_name()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-19 14:25:41 +01:00
Michael Brown 77c70ac0cd [settings] Remove default_type parameter from parse_setting_name()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-19 14:25:35 +01:00
Michael Brown 78178608e9 [settings] Remove temporary name buffer parameter from parse_setting_name()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-18 15:58:05 +01:00
Michael Brown 3880ebeb18 [settings] Avoid potentially large stack allocations
Avoid potentially large stack allocations in fetchf_setting() and
storef_setting().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-18 15:50:02 +01:00
Michael Brown 063645118c [settings] Clarify usage of the term "named setting"
There are currently two conflicting usages of the term "named setting"
within iPXE: one refers to predefined settings (such as show up in the
"config" UI), the other refers to settings identified by a name (such
as "net0.dhcp/ip").

Split these usages into the term "predefined setting" and "named
setting" to avoid ambiguity.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-18 15:50:02 +01:00
Marin Hannache c0af8c0433 [cmdline] Add "poweroff" command
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-15 13:49:48 +02:00
Michael Brown 49d14f0d8d [base16] Ensure base16_encode() always terminates its result string
base16_encode() will fail to generate a terminating NUL if the length
of the raw data is zero, since the loop calling sprintf() will never
execute.

Fix by explicitly terminating the result with a NUL.

Reported-by: Marin Hannache <git@mareo.fr>
Debugged-by: Marin Hannache <git@mareo.fr>
Tested-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-15 00:06:45 +02:00
Marin Hannache c5ece71972 [legal] Add FILE_LICENCE for core/errno.c
Signed-off-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-14 23:40:25 +02:00
Robin Smidsrød 7016164056 [settings] Add "version" builtin setting
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-13 22:15:51 +02:00
Michael Brown 66ea458125 [settings] Make "netX" settings block function as a symbolic link
Add a facility for settings blocks to act as symbolic links to other
settings blocks, and reimplement the "netX" virtual settings block
using this facility.

The primary advantage of this approach is that unscoped settings such
as ${mac} and ${filename} will now reflect the settings obtained from
the most recently opened network device: in most cases, this will mean
the settings obtained from the most recent DHCP attempt.  This should
improve conformance to the principle of least astonishment.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-13 15:11:45 +02:00
Michael Brown 3dbcce51ea [settings] Add "busdevfn" setting type
Allow network device's "busloc" setting to be formatted as a PCI
bus:dev.fn address using e.g. ${net0/busloc:busdevfn}.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-12 22:38:19 +02:00
Michael Brown 9f3bbaca07 [settings] Add "hexraw" setting type
Originally-implemented-by: Jeppe Toustrup <ipxe@tenzer.dk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-12 15:14:36 +02:00
Michael Brown 7774ceed2f [settings] Use hex_decode() to parse hex settings
Use hex_decode() to parse "hex" and "hexhyp" settings.  Note that this
parser is stricter than the old parser; it now requires exactly two
hex digits for each byte.  (The old parser was based upon strtoul()
and so would allow leading whitespace and a leading plus or minus
sign.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-12 15:14:36 +02:00
Michael Brown 076f58c4bf [base16] Generalise base16_decode() to hex_decode()
Provide a generic hex_decode() routine which can be shared between the
Base16 code and the "hex" and "hexhyp" settings parsers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-07-12 15:14:36 +02:00
Michael Brown 15d2f947f5 [settings] Eliminate settings "tag magic"
Create an explicit concept of "settings scope" and eliminate the magic
values used for numerical setting tags.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-05-01 19:52:12 +01:00
Michael Brown 0e2ba15a58 [settings] Expose build architecture and platform via settings
Expose the build architecture (e.g. "i386" or "x86_64") via
${buildarch} and the firmware platform (e.g. "pcbios" or "efi") via
${platform}.  These settings directly expose the ARCH and PLATFORM
variables from the Makefile.

Note that the build architecture reflects the architecture for which
iPXE was compiled, not the architecture on which iPXE is currently
running.  The "cpuid" command can be used to detect a 64-bit system at
runtime.

Requested-by: James A. Peltier <jpeltier@sfu.ca>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-04-06 11:33:34 +01:00
Michael Brown e68a6ca225 [cmdline] Add ability to perform a warm reboot
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-22 13:54:44 +00:00
Michael Brown 71cd508838 [efi] Add "reboot" command for EFI
Abstract out the ability to reboot the system to a separate reboot()
function (with platform-specific implementations), add an EFI
implementation, and make the existing "reboot" command available under
EFI.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-22 13:44:02 +00:00
Michael Brown 033f4c92ca [autoboot] Split main control flow out of main() into a new function ipxe()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-03-13 22:24:13 +00:00
Michael Brown 0acc52519d [tls] Concatenate received non-data records before processing
Allow non-data records to be split across multiple received I/O
buffers, to accommodate large certificate chains.

Reported-by: Nicola Volpini <Nicola.Volpini@kambi.com>
Tested-by: Nicola Volpini <Nicola.Volpini@kambi.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-01-31 09:59:36 +00:00
Michael Brown fd141fb669 [umalloc] Split largest_memblock() function out from init_eheap()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-06 17:44:40 +00:00
Michael Brown 54a861a7bd [list] Reduce overall code size by externalising many list functions
Typical saving is 10-20 bytes in each file using list functions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-02 16:21:06 +00:00
Michael Brown 4867085c0c [build] Include version number within only a single object file
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-11-02 14:46:39 +00:00
Michael Brown c86790df5c [settings] Add fetchf_named_setting_copy()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-24 20:42:42 -07:00
Michael Brown 1d38168064 [autoboot] Avoid excess backspacing after displaying Ctrl-B prompt
Remove the newline from the "Press Ctrl-B..." prompt string, so that
prompt() does not attempt to backspace beyond the start of the line.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-23 14:07:50 -07:00
Michael Brown 0fd29e15b5 [nvo] Expose nvo_applies()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-15 18:32:16 +01:00
Michael Brown 08a6ae86a2 [nvo] Expose non-volatile options block name
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-15 18:32:16 +01:00
Michael Brown 5ad445fd0b [settings] Treat an empty formatted value as meaning "delete setting"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-15 18:32:16 +01:00
Michael Brown 1c2b6d29ea [settings] Expose find_child_settings()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-15 18:32:16 +01:00
Michael Brown 51b65d5f9c [libc] Add wcslen() function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-15 18:32:16 +01:00
Shao Miller a712dae709 [serial] Don't enable serial console without serial support
serial_console_init() would enable serial console support without
knowing if the serial driver succeeded or not.  As a result, the
serial console would interfere with a normal keyboard on a system
lacking serial support.

Reported-by: Jan ONDREJ (SAL) <ondrejj(at)salstar.sk>
Signed-off-by: Shao Miller <sha0.miller@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-10-05 15:18:57 +01:00
Michael Brown 25ec56e0ec [settings] Use a generic setting's own type as its default type
When fetching a named setting using a name that does not explicitly
specify a type, default to using the type stored when the setting was
created, rather than always defaulting to "string".  This allows the
behaviour of user-defined settings to match the behaviour of
predefined settings (which have a sensible default type).

For example:

  set server:ipv4 192.168.0.1
  echo ${server}

will now print "192.168.0.1", rather than trying to print out the raw
IPv4 address bytes as a string.

The downside of this change is that existing tricks for printing
special characters within scripts may require (backwards-compatible)
modification.  For example, the "clear screen" sequence:

  set esc:hex 1b
  set cls ${esc}[2J
  echo ${cls}

will now have to become

  set esc:hex 1b
  set cls ${esc:string}[2J  # Must now explicitly specify ":string"
  echo ${cls}

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-09-10 14:25:04 +01:00
Michael Brown 96be171be5 [iobuf] Allow allocation of I/O buffers with a specified alignment offset
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-31 21:22:52 +01:00
Michael Brown e2becce186 [malloc] Allow allocation of memory with a specified alignment offset
Allow for allocation of memory blocks having a specified offset from a
specified physical alignment, such as being 12 bytes before a 2kB
boundary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-31 21:22:45 +01:00
Michael Brown 183a70e8b7 [console] Sleep while waiting for user input
Reduce CPU usage while waiting for user input.  This is particularly
important for virtual machines, where CPU is a shared resource.

Reported-by: Alessandro Salvatori <alessandro@embrane.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-24 09:56:36 +01:00
Michael Brown c3b4860ce3 [legal] Update FSF mailing address in GPL licence texts
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 19:55:45 +01:00
Michael Brown 5d3c368efb [image] Add "--replace" option
Expose image tail-recursion to iPXE scripts via the "--replace"
option.  This functions similarly to exec() under Unix: the
currently-executing script is replaced with the new image (as opposed
to running the new image as a subroutine).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 12:45:15 +01:00
Michael Brown d3c660b671 [image] Add "--autofree" option
Allow images to be automatically freed after execution completes
(successfully or otherwise).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 12:44:40 +01:00
Michael Brown 58ed3b1cee [libc] Add support for "%lc" and "%ls" format specifiers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-19 16:33:33 +01:00
Michael Brown c5c257788f [settings] Expose exit status of failed command via ${errno}
Allow scripts to report errors in more detail by exposing the most
recent error via the ${errno} setting.  For example:

    chain ${filename} || goto failed
    ...
    :failed
    imgfree http://192.168.0.1/ipxe_error.php?error=${errno}

Note that ${errno} is valid only immediately after executing a failed
command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-12 15:46:24 +01:00
Michael Brown 5b4958388d [cmdline] Store exit status of failed command in errno
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-12 15:42:29 +01:00
Michael Brown 6825b2e7bf [malloc] Increase heap size to 512kB
The maximum TCP throughput is fundamentally limited by the amount of
available receive buffer space.  Increase the heap size from 128kB to
512kB to allow the use of larger TCP windows.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-09 10:13:47 +01:00
Michael Brown 8d95e1d6ff [malloc] Discard cached items less aggressively
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-09 10:08:37 +01:00
Michael Brown 4a8a7bd91a [iobuf] Allocate I/O buffer descriptor separately to conserve aligned memory
I/O buffers are allocated on aligned boundaries.  The I/O buffer
descriptor (the struct io_buffer) is currently attached to the end of
the I/O buffer.  When the size of the buffer is close to its
alignment, this can waste large amounts of aligned memory.

For example, a network card using 2048-byte receive buffers will end
up allocating 2072 bytes on a 2048-byte boundary.  This effectively
wastes 50% of the available memory.

Improve the situation by allocating the descriptor separately from the
main I/O buffer if inline allocation would cause the total allocated
size to cross the alignment boundary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-08 17:54:53 +01:00
Michael Brown f3d197a529 [cmdline] Do not ignore empty initial arguments in concat_args()
Reported-by: Oliver Rath <rath@mglug.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-04 13:37:08 +01:00
Michael Brown a5c016d93e [iobuf] Relax alignment requirement for small I/O buffers
iPXE currently aligns all I/O buffers on a 2kB boundary.  This is
overkill for transmitted packets, which are typically much smaller
than 2kB.

Align I/O buffers on their own size.  This reduces the alignment
requirement for small buffers, while preserving the guarantee that I/O
buffers will never cross boundaries that might cause problems for some
DMA engines.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-29 16:07:12 +01:00
Michael Brown 85917ba8dd [monojob] Check for keypresses only once per timer tick
Checking for keypresses takes a non-negligible amount of time, and
measurably affects our RTT.  Minimise the impact by checking for
keypresses only once per timer tick.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-28 16:02:37 +01:00
Michael Brown 7ea6764031 [settings] Move "domain" setting from dns.c to settings.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-20 14:39:03 +01:00
Michael Brown 021d7b21b7 [pending] Add concept of "pending operations"
iPXE is fundamentally asynchronous in operation: some operations
continue in the background even after the foreground has continued to
a new task.  For example, the closing FIN/ACK exchanges of a TCP
connection will take place in the background after an HTTP download
has completed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-06-09 18:48:28 +01:00
Michael Brown 89a354d553 [monojob] Allow monojob to be completely silent
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-22 00:47:19 +01:00
Michael Brown 40e68e1119 [base64] Avoid overrunning input data buffer
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-20 16:47:57 +01:00
Michael Brown c124f21f56 [image] Avoid potential NULL pointer dereference
Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-08 21:05:25 +01:00
Michael Brown 2e4be01690 [xferbuf] Add generic data-transfer buffer
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-08 19:16:46 +01:00
Michael Brown 6f3e7e90fc [malloc] Allow Valgrind to be used when all assertions are enabled
The free-memory-block traversal code triggers multiple warnings from
Valgrind when assertions are enabled, since the list consistency
checks performed by list_check() end up accessing areas that have been
marked as inaccessible.

Fix by ensuring that any memory areas that will be accessed by
list_check() are marked as defined when necessary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-04 17:16:35 +01:00
Michael Brown df2773193e [malloc] Discard all cached data on shutdown
Allow detection of genuine memory leaks by ensuring that all cached
data is freed on shutdown.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-04 15:15:34 +01:00
Michael Brown de2616165b [xfer] Avoid using stack-allocated memory in xfer_printf()
xfer_printf() occasionally has to deal with strings that are
potentially long, such as HTTP URIs with multiple query parameters.
Allocating these on the stack can lead to stack overruns and memory
corruption.

Fix by using vasprintf() instead of a stack allocation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-23 20:30:48 +01:00
Michael Brown 31e60de676 [settings] Add fetch_setting_copy()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-19 16:10:07 +01:00
Michael Brown 52e5ddce68 [tftp] Allow builds without TFTP support
Allow TFTP to be configured out by moving the next-server setting
definition (which is used by autoboot.c) from tftp.c to settings.c.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-17 11:50:11 +01:00
Michael Brown 831b16adde [settings] Split fetching and storing out of setting type handlers
Refactor setting type handlers to parse and format values, rather than
storing and fetching formatted values.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-17 10:46:50 +01:00
Michael Brown 1d33649516 [libc] Allow strtoul() to interpret negative numbers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-04-17 10:42:08 +01:00
Michael Brown 275fdae9bb [image] Fix use-after-free in debug messages
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-30 20:50:25 +01:00
Michael Brown 3425726cf3 [menu] Add menu commands
Allow iPXE scripts to create menus.  For example:

    #!ipxe

    menu iSCSI boot demonstration
    item install         Install Fedora to ${root-path}
    item --default boot  Boot from ${root-path}
    item shell           Enter iPXE shell
    item exit            Exit to BIOS
    choose label && goto ${label}

    :boot
    sanboot ${root-path}

    :install
    sanhook ${root-path}
    chain http://${next-server}/fedora.ipxe

    :shell
    shell

    :exit

Inspired-by: Robin Smidsrød <robin@smidsrod.no>
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-29 14:02:02 +01:00
Michael Brown 0d2fba2887 [menu] Add the abstract concept of a menu
Inspired-by: Robin Smidsrød <robin@smidsrod.no>
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-29 13:44:48 +01:00
Michael Brown 0b1fe005b3 [parseopt] Allow "prompt" command to accept character literals for --key
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-29 00:21:19 +01:00
Michael Brown 730c972124 [image] Log image executions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-27 11:11:28 +01:00
Michael Brown 82ecaaac91 [console] Remove "log message" usage from interactive console defaults
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-27 00:51:50 +01:00
Michael Brown cef3beaba4 [downloader] Use a more meaningful error message when out of memory
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-27 00:43:07 +01:00
Michael Brown 9445cb9f8b [downloader] Abort download immediately if buffer resizing fails
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-27 00:38:19 +01:00
Michael Brown 5a91f5646a [downloader] Log final status of all downloads
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 22:47:50 +01:00
Michael Brown c2875ae329 [console] Do not share ANSI escape context between lineconsole users
An ANSI escape sequence context cannot be shared between multiple
users.  Make the ANSI escape sequence context part of the line console
definition and provide individual contexts for each user.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 21:58:50 +01:00
Michael Brown 24b7296319 [console] Add "log message" console usage and an internal syslog() call
Provide an internal syslog() function (unrelated to the syslog
console) which can be used to create log messages with specified
priorities.

The build-time constant LOG_LEVEL can be used to select the minimum
required priority for log messages.  Any messages that do not have a
sufficient priority will be ignored (and will be optimised away at
compile-time).

The default LOG_LEVEL is LOG_NONE.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 19:58:14 +01:00
Michael Brown e024cd39a8 [console] Allow usage to be defined independently for each console
Add the concept of a "console usage", such as "standard output" or
"debug messages".  Allow usages to be associated with each console
independently.  For example, to send debugging output via the serial
port, while preventing it from appearing on the local console:

  #define CONSOLE_SERIAL CONSOLE_USAGE_ALL
  #define CONSOLE_PCBIOS ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_DEBUG )

If no usages are explicitly specified, then a default set of usages
will be applied.  For example:

  #define CONSOLE_SERIAL

will have the same affect as

  #define CONSOLE_SERIAL CONSOLE_USAGE_ALL

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 17:40:01 +01:00
Michael Brown b35d454422 [console] Remove unused "btext" console
The "btext" console has been disabled by a "#if 0" since 2007.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 15:47:34 +01:00
Michael Brown a6d49c17c9 [console] Move putchar() and getchar() declarations to stdio.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-26 14:43:52 +01:00
Michael Brown 1c127a6962 [image] Simplify image management commands and internal API
Remove the name, cmdline, and action parameters from imgdownload() and
imgdownload_string().  These functions now simply download and return
an image.

Add the function imgacquire(), which will interpret a "name or URI
string" parameter and return either an existing image or a newly
downloaded image.

Use imgacquire() to merge similar image-management commands that
currently differ only by whether they take the name of an existing
image or the URI of a new image to download.  For example, "chain" and
"imgexec" can now be merged.

Extend imgstat and imgfree commands to take an optional list of
images.

Remove the arbitrary restriction on the length of image names.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-24 23:12:04 +00:00
Michael Brown 97dcc824bf [image] Add concept of trusted images
Trusted images may always be executed.  Untrusted images may be
executed only if the current image trust requirement allows untrusted
images.

Images can be marked as trusted using image_trust(), and marked as
untrusted using image_untrust().

The current image trust requirement can be changed using
image_set_trust().  It is possible to make the change permanent, in
which case any future attempts to change the image trust requirement
will fail.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-22 16:16:02 +00:00
Michael Brown 846bde90e6 [time] Define an API for getting the current time
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-19 22:13:27 +00:00
Michael Brown bd6805a8c1 [libc] Add mktime() function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-03-19 17:35:46 +00:00
Michael Brown 851b93fbc3 [syslog] Separate out generic line-based console functionality
Abstract out the generic line-handling portions of the syslog
putchar() routine, to allow use by other console types.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-02-28 23:10:01 +00:00
Marin Hannache be90241ec2 [getopt] Accept "--" as an end-of-options marker
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-11-02 00:23:57 +00:00
Michael Brown 790035f78d [image] Eliminate the register_and_xxx_image() functions
All users of imgdownload() require registration of the image, so make
registration an integral part of imgdownload() itself and simplify the
"action" parameter to be one of image_select(), image_exec() et al.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-25 01:41:41 +01:00
Michael Brown 59e4c37741 [cmdline] Allow "sleep" command to be interrupted
Allow Ctrl-C to be used to abort a "sleep" command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-24 15:52:57 +01:00
Michael Brown f177a6f09f [cmdline] Fix up "sleep" argument parsing
Use parse_integer() rather than strtoul() to allow parsing errors to
be reported in a meaningful way.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-24 15:52:14 +01:00
Michael Brown bf2da3122b [cmdline] Make "sleep" command available by default
The "sleep" command is generally useful to have.  For example:

  :dhcp_retry
  dhcp && goto dhcp_done
  sleep 5
  goto dhcp_retry
  :dhcp_done

Make the "sleep" command available by default, leaving TIME_CMD
controlling only the (fairly specialist) "time" command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-24 15:39:05 +01:00
Michael Brown dc821ca961 [libc] Allow assertion failures to be counted
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-10-14 14:33:31 +01:00
Michael Brown 66cbae73bd [libc] Allow for zero-padded decimals in printf()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-07-06 14:52:53 +01:00
Michael Brown 3915b660fd [hw] Eliminate polling while waiting for window to open
Polling for the data-transfer window to become open is wasteful.  We
can eliminate the polling loop by using hw_step() as the handler for
an xfer_window_changed() event.

If the window is already open at the time of instantiation, then
xfer_window_changed() may never be called.  We can cover this case by
using hw_step() as the step() method of a one-shot process.  Since the
signature for an xfer_window_changed() method is identical to the
signature for a process step() method, the same function can be used
for both.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-06-28 14:45:11 +01:00
Michael Brown 5694b71b11 [resolv] Use a one-shot process for the numeric resolver
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-06-28 14:45:09 +01:00
Michael Brown ccc2655540 [process] Add support for one-shot processes
Some processes execute only once, and exist solely in order to defer
execution until after the relevant instantiator method has returned.
Such processes do not need to be automatically rescheduled when
executing.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-06-28 14:45:09 +01:00
Michael Brown e01ec74601 [process] Pass containing object pointer to process step() methods
Give the step() method a pointer to the containing object, rather than
a pointer to the process.  This is consistent with the operation of
interface methods, and allows a single function to serve as both an
interface method and a process step() method.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-06-28 14:45:08 +01:00
Michael Brown ba3633782b [xfer] Send xfer_window_changed() after xfer_vredirect()
Modify the default action for xfer_vredirect() to automatically send
xfer_window_changed() messages to both the new child and the parent
interfaces.  This will allow the elimination of processes that simply
poll on xfer_window() to determine when a redirection has completed
successfully.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-06-28 14:45:08 +01:00
Michael Brown c49659c4f2 [parseopt] Disambiguate the various EINVAL errors
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-05-18 09:39:27 +01:00
Michael Brown 5d2802e403 [sanboot] Add "sanhook" and "sanunhook" commands
Expose the multiple-SAN-drive capability of the iPXE core via the iPXE
command line by adding commands to hook and unhook additional drives.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-24 16:44:34 +01:00
Michael Brown 3ca5656208 [parseopt] Allow for pre-initialised option sets
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-24 15:32:06 +01:00
Greg Jednaszewski 3726b3d94a [cmdline] Add "iseq" command
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-08 19:34:20 +01:00
Michael Brown 7aee315f61 [cmdline] Simplify "isset" command
There is no plausible scenario I can think of in which "isset" would
be used with more than one argument.  Simplify the code by specifying
that exactly one argument is required.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-08 03:19:06 +01:00
Michael Brown 06f1878fb8 [cmdline] Fix "isset" command
Commit b5f5f73 ("[cmdline] Expand settings within each command-line
token individually") introduced a regression into the "isset" command:
it is now possible for command-line arguments to be empty strings, and
so "isset" cannot simply check for a non-empty argument list.

Restore previous behaviour by checking for the presence of any
non-empty arguments, rather than checking for a non-empty argument
list.

Reported-by: Nemtallah Daher <n.daher@csuohio.edu>
Tested-by: Nemtallah Daher <n.daher@csuohio.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-04-01 20:09:51 +01:00
Michael Brown 2f6e7bde77 [main] Add the "scriptlet" setting
A scriptlet is a single iPXE command that can be stored in
non-volatile option storage and used to override the default
"autoboot" behaviour without having to reflash the iPXE image.

For example, a scriptlet could contain

    autoboot || reboot

to instruct iPXE to reboot the system if booting fails.

Unlike an embedded image, the presence of a scriptlet does not inhibit
the initial "Press Ctrl-B..." prompt.  This allows the user to recover
from setting a faulty scriptlet.

Originally-implemented-by: Glenn Brown <glenn@myri.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-28 18:50:27 +01:00
Michael Brown b5f5f735c1 [cmdline] Expand settings within each command-line token individually
Perform settings expansion after tokenisation, and only at the point
of executing each command.  This allows statements such as

   dhcp && echo ${net0/ip}

to work correctly.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-28 17:35:23 +01:00
Michael Brown 1f4c5f90c3 [cmdline] Allow ";" as an unconditional command separator
It is currently possible to construct a sequence of commands to be
executed regardless of success or failure using "|| &&" as the command
separator.  (The "||" captures the failure case, the blank command
converts it to a success case.)

Allow ";" to be used as a more visually appealing (and
space-efficient) alternative.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-28 16:32:30 +01:00
Piotr Jaroszyński b604e8a388 [linux] Make malloc and linux_umalloc valgrindable
Make the allocators used by malloc and linux_umalloc valgrindable.
Include valgrind headers in the codebase to avoid a build dependency
on valgrind.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-27 21:03:05 +01:00
Michael Brown ac12324f52 [cmdline] Allow "echo -n" to inhibit trailing newline
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-27 12:49:18 +01:00
Michael Brown a246434299 [parseopt] Add support for boolean options
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-27 12:46:55 +01:00
Michael Brown 5590faf14a [monojob] Avoid overflow when calculating percentage progress
Normalise the progress figures to ensure that multiplication by 100
(to produce a percentage) cannot result in integer overflow.

Reported-by: Sven Dreyer <sven@dreyer-net.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-26 13:14:53 +00:00
Michael Brown 02a6f46c09 [settings] Match terminology in online documentation
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 21:21:12 +00:00
Michael Brown 071b4000d9 [settings] Avoid memory leak when unregistering autovivified settings blocks
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 20:17:24 +00:00
Michael Brown 8482451812 [settings] Impose a fixed order on settings
Improve the appearance of the "config" user interface by ensuring that
settings appear in some kind of logical order.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-23 11:57:29 +00:00
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
Michael Brown ea631f6fb8 [list] Add list_first_entry()
There are several points in the iPXE codebase where
list_for_each_entry() is (ab)used to extract only the first entry from
a list.  Add a macro list_first_entry() to make this code easier to
read.

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