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

916 Commits

Author SHA1 Message Date
Michael Brown e6111c1517 [time] Allow system clock to be adjusted at runtime
Provide a mechanism to allow an arbitrary adjustment to be applied to
all subsequent calls to time().

Note that the underlying clock source (e.g. the RTC clock) will not be
changed; only the time as reported within iPXE will be affected.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-06-13 15:29:05 +01:00
Michael Brown f76210961c [pci] Support systems with multiple PCI root bridges
Extend the 16-bit PCI bus:dev.fn address to a 32-bit seg🚌dev.fn
address, assuming a segment value of zero in contexts where multiple
segments are unsupported by the underlying data structures (e.g. in
the iBFT or BOFM tables).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-06-09 09:36:28 +01:00
Michael Brown 2c197517f2 [libc] Always use a non-zero seed for the (non-crypto) RNG
The non-cryptographic RNG implemented by random() has the property
that a seed value of zero will result in a generated sequence of
all-zero values.  This situation can arise if currticks() returns zero
at start of day.

Work around this problem by falling back to a fixed non-zero seed if
necessary.

This has no effect on the separate DRBG used by cryptographic code.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-06-09 08:44:32 +01:00
Michael Brown 8dd39b9572 [efi] Work around broken UEFI keyboard drivers
Some UEFI keyboard drivers are blissfully unaware of the existence of
either Ctrl key, and will report "Ctrl-<key>" as just "<key>".  This
breaks substantial portions of the iPXE user interface.

Work around these broken UEFI drivers by allowing "ESC <key>" to be
used as a substitute for "Ctrl-<key>".

Tested-by: Dreamcat4 <dreamcat4@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-25 23:28:41 +01:00
Michael Brown 56c0147deb [settings] Extend numerical setting tags to "unsigned long"
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-20 16:51:56 +01:00
Michael Brown a966570dce [libc] Avoid implicit assumptions about potentially-optimised memcpy()
Do not assume that an architecture-specific optimised memcpy() will
have the same properties as generic_memcpy() in terms of handling
overlapping regions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-05-09 16:23:38 +01:00
Michael Brown b696a5063e [image] Skip misleading "format not recognised" error message
Return success (rather than failure) after an image format has been
correctly identified.

This has no practical effect, since the return value from
image_probe() is deliberately never used, but avoids a somewhat
surprising and misleading "format not recognised" error message when
debugging is enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-28 12:12:50 +01:00
Michael Brown cc8824ad4e [libc] Print "<NULL>" for wide-character NULL strings
The existing code intends to print NULL strings as "<NULL>" (for the
sake of debug messages), but the logic is incorrect when handling
wide-character strings.  Fix the logic and add applicable unit tests.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-04-12 11:53:06 +01:00
Michael Brown ee3122bc54 [libc] Make sleep() interruptible
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-22 16:18:42 +00:00
Michael Brown 311a5732c8 [gdb] Add support for x86_64
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-22 08:44:32 +00:00
Michael Brown 75496817c2 [uri] Support "file:" URIs describing relative paths
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-14 18:03:13 +00:00
Michael Brown 17c1488a44 [uri] Support URIs containing only scheme and path components
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-13 14:51:15 +00:00
Michael Brown 3c84178003 [serial] Add missing #include <string.h>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-12 18:02:20 +00:00
Michael Brown 11396473f5 [pixbuf] Check for unsigned integer overflow on multiplication
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-12 00:09:23 +00:00
Michael Brown d3db00ecf9 [pcbios] Restrict external memory allocations to the low 4GB
When running the 64-bit BIOS version of iPXE, restrict external memory
allocations to the low 4GB to ensure that allocations (such as for
initrds) fall within our identity-mapped memory region, and will be
accessible to the potentially 32-bit operating system.

Move largest_memblock() back to memtop_umalloc.c, since this change
imposes a restriction that applies only to BIOS builds.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-03-08 13:25:09 +00:00
Michael Brown 5bd8427d3d [ioapi] Split ioremap() out to a separate IOMAP API
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-26 15:33:40 +00:00
Michael Brown 12b3b57886 [iobuf] Improve robustness of I/O buffer allocation
Guard against various corner cases (such as zero-length buffers, zero
alignments, and integer overflow when rounding up allocation lengths
and alignments) and ensure that the struct io_buffer is correctly
aligned even when the caller requests a non-zero alignment for the I/O
buffer itself.

Add self-tests to verify that the resulting alignments and lengths are
correct for a range of allocations.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-11 19:04:23 +00:00
Michael Brown e2b1140486 [malloc] Guard against unsigned integer overflow
Commit f3fbb5f ("[malloc] Avoid integer overflow for excessively large
memory allocations") fixed signed integer overflow issues caused by
the use of ssize_t, but did not guard against unsigned integer
overflow.

Add explicit checks for unsigned integer overflow where needed.  As a
side bonus, erroneous calls to malloc_dma() with an (illegal) size of
zero will now fail cleanly.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-06 10:47:45 +00:00
Michael Brown e55ec845e6 [uri] Apply URI decoding for all parsed URIs
The various early-exit paths in parse_uri() accidentally bypass the
URI field decoding.  The result is that opaque or relative URIs do not
undergo URI field decoding, resulting in double-encoding when the URIs
are subsequently used.  For example:

  #!ipxe
  set mac ${macstring}
  imgfetch /boot/by-mac/${mac:uristring}

would result in an HTTP GET such as

  GET /boot/by-mac/00%253A0c%253A29%253Ac5%253A39%253Aa1 HTTP/1.1

rather than the expected

  GET /boot/by-mac/00%3A0c%3A29%3Ac5%3A39%3Aa1 HTTP/1.1

Fix by ensuring that URI decoding is always applied regardless of the
URI format.

Reported-by: Andrew Widdersheim <awiddersheim@inetu.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-26 16:16:13 +00:00
Michael Brown f0e9e55442 [tftp] Mangle initial slash on TFTP URIs
TFTP URIs are intrinsically problematic, since:

- TFTP servers may use either normal slashes or backslashes as a
  directory separator,

- TFTP servers allow filenames to be specified using relative paths
  (with no initial directory separator),

- TFTP filenames present in a DHCP filename field may use special
  characters such as "?" or "#" that prevent parsing as a generic URI.

As of commit 7667536 ("[uri] Refactor URI parsing and formatting"), we
have directly constructed TFTP URIs from DHCP next-server and filename
pairs, avoiding the generic URI parser.  This eliminated the problems
related to special characters, but indirectly made it impossible to
parse a "tftp://..." URI string into a TFTP URI with a non-absolute
path.

Re-introduce the convention of requiring an extra slash in a
"tftp://..." URI string in order to specify a TFTP URI with an initial
slash in the filename.  For example:

  tftp://192.168.0.1/boot/pxelinux.0  => RRQ "boot/pxelinux.0"
  tftp://192.168.0.1//boot/pxelinux.0 => RRQ "/boot/pxelinux.0"

This is ugly, but there seems to be no other sensible way to provide
the ability to specify all possible TFTP filenames.

A side-effect of this change is that format_uri() will no longer add a
spurious initial "/" when formatting a relative URI string.  This
improves the console output when fetching an image specified via a
relative URI.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-21 18:00:33 +00:00
Michael Brown 295ad11367 [uri] Avoid potentially large stack allocation
Avoid potentially large stack allocation in resolve_path().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-21 15:53:44 +00:00
Michael Brown 47dcd392dc [debug] Allow debug colourisation to be disabled
Some BIOS console redirection capabilities do not work well with the
colourised debug messages used by iPXE.  We already allow the range of
colours to be controlled via the DBGCOL=... build parameter.  Extend
this syntax to allow DBGCOL=0 to be used to mean "disable colours".

Requested-by: Wissam Shoukair <wissams@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-12 15:39:14 +00:00
Michael Brown a8bef53908 [downloader] Update image URI in response to a redirection
Update the image's recorded URI when a download redirection occurs.
This ensures that URIs relative to a redirected download are resolved
correctly.

In particular, this allows for the use of relative URIs in scripts
that are themselves downloaded via a redirection, such as the HTTP 301
redirection used to fix up URIs pointing to directories but omitting
the trailing slash (e.g. "http://boot.ipxe.org/demo", which will be
redirected to "http://boot.ipxe.org/demo/").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-09 13:30:42 +00:00
Michael Brown 57fa0db03f [image] Provide image_set_uri() to modify an image's URI
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-01-09 13:22:37 +00:00
Michael Brown 79afe60b09 [fbcon] Move margin calculations to fbcon.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-10-14 22:16:45 +01:00
Michael Brown bc69777a40 [fbcon] Allow character height to be selected at runtime
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-10-14 22:16:40 +01:00
Michael Brown f3fbb5ff1c [malloc] Avoid integer overflow for excessively large memory allocations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-29 01:07:08 +01:00
Michael Brown 53d2d9e3c3 [uri] Generalise tftp_uri() to pxe_uri()
Merge the functionality of parse_next_server_and_filename() and
tftp_uri() into a single pxe_uri(), which takes a server address
(IPv4/IPv6/none) and a filename, and produces a URI using the rule:

 - if the filename is a hierarchical absolute URI (i.e. includes a
   scheme such as "http://" or "tftp://") then use that URI and ignore
   the server address,

 - otherwise, if the server address is recognised (according to
   sa_family) then construct a TFTP URI based on the server address,
   port, and filename

 - otherwise fail.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-02 13:38:53 +01:00
Michael Brown ba3695353a [settings] Re-add "uristring" setting type
Commit 09b057c ("[settings] Remove "uristring" setting type") removed
support for URI-encoded settings via the "uristring" setting type, on
the basis that such encoding was no longer necessary to avoid problems
with the command line parser.

Other valid use cases for the "uristring" setting type do exist: for
example, a password containing a '/' character expanded via

  chain http://username:${password:uristring}@server.name/boot.php

Restore the existence of the "uristring" setting, avoiding the
potentially large stack allocations that were used in the old code
prior to commit 09b057c ("[settings] Remove "uristring" setting
type").

Requested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-25 13:31:46 +01:00
Michael Brown abfe94a90a [image] Detect image type when image is first registered
The current usage pattern of image_probe() is a legacy from the time
before commit 34b6ecb ("[image] Simplify image management") when
loading an image to its executable location in memory was a separate
action from actually executing the image.

Call image_probe() as soon as an image is registered.  This allows
"imgstat" to display image type information for all images and allows
image-consuming code to assume that image->type is already set
correctly.

Ignore failures if image_probe() does not recognise the image, since
we do expect to handle unrecognised images (initrds, modules, etc).
Unrecognised images will be left with a NULL image->type, which
image-consuming code can easily check.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-21 16:25:11 +01:00
Michael Brown f58ebbdfb5 [test] Allow self-tests to report exit status when running under Linux
Allow the return status from an embedded image to propagate out to the
eventual return status from main().  When running under Linux, this
allows the pass/fail result of unit tests to be observable without
having to visually inspect the console output.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-21 15:46:28 +01:00
Michael Brown 09236e6030 [block] Add generic block device translator
Add a generic mechanism for providing block devices on top of a data
transfer interface (such as HTTP).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-08-16 00:48:34 +01:00
Michael Brown 2849932c48 [serial] Check for UART existence in uart_select()
Check for existence of the UART in uart_select(), not just in
uart_init().  This allows uart_select() to refuse to set a non-working
address in uart->base, which in turns means that the serial console
code will not attempt to use a non-existent UART.

Reported-by: Torgeir Wulfsberg <Torgeir.Wulfsberg@kongsberg.com>
Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-31 11:19:19 +01:00
Michael Brown 1e4ff872be [linebuf] Support buffering of multiple lines
Allow line buffer to accumulate multiple lines, with buffered_line()
returning each freshly-completed line as it is encountered.  This
allows buffered lines to be subsequently processed as a group.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 16:59:11 +01:00
Michael Brown 20d35b0145 [pool] Add a generic concept of a pooled connection
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-28 16:37:00 +01:00
Michael Brown 99d351605a [build] Fix compiler warnings on some gcc versions
xfer_buffer() uses intf_get_dest_op() to obtain the destination
interface for xfer_deliver(), in order to check that this is the same
interface which provides xfer_buffer().  The return value from
intf_get_dest_op() (which contains the actual method implementing
xfer_deliver()) is not used.

On some gcc versions, this triggers a "value computed is not used"
warning, since the explicit type cast included within the
intf_get_dest_op() macro is treated as a "value computed".

Fix by explicitly casting the result of intf_get_dest_op() to void.

Reported-by: Matthew Helton <mwhelton@gmail.com>
Reported-by: James A. Peltier <jpeltier@sfu.ca>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-27 15:21:17 +01:00
Michael Brown 2b15ae5507 [downloader] Provide direct access to the underlying data transfer buffer
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown ae5e7f0cf4 [downloader] Use generic data-transfer buffer mechanism
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 07b0d4fa30 [xferbuf] Add xfer_buffer() to provide direct access to underlying buffer
Allow data transfer buffer users to provide direct access to their
underlying data transfer buffer.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown cbbd6b761e [xferbuf] Generalise to handle umalloc()-based buffers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 0dc85aed03 [xfer] Add xfer_check_order() utility function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 7194f38131 [xfer] Use intf_poke() to implement xfer_window_changed()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 81c80c8ba9 [interface] Add intf_poke() helper
Reduce the cost of implementing object methods which convey no
information beyond the fact that the method has been called.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown 89816af2a4 [fault] Add inject_corruption() to randomly corrupt data
Provide an inject_corruption() function that can be used to randomly
corrupt data bytes with configurable probabilities.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown d0325b1da6 [fault] Generalise NETDEV_DISCARD_RATE fault injection mechanism
Provide a generic inject_fault() function that can be used to inject
random faults with configurable probabilities.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-07-22 21:17:47 +01:00
Michael Brown a0f60d26f5 [gdb] Allow gdbstub to be started on an arbitrary serial port
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 16:44:16 +01:00
Michael Brown 2a696ab963 [serial] Use new UART abstraction in serial console driver
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 11:04:10 +01:00
Michael Brown 5e622dc085 [gdb] Use new UART abstraction in GDB serial transport
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 11:03:12 +01:00
Michael Brown 611c9e39da [serial] Add general abstraction of a 16550-compatible UART
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-06-29 11:03:05 +01:00
Michael Brown dc15a5a779 [settings] Add "base64" setting type
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 15:36:41 +01:00
Michael Brown 1205721cbd [base64] Add buffer size parameter to base64_encode() and base64_decode()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 15:32:04 +01:00
Michael Brown 9aa8090d06 [base16] Add buffer size parameter to base16_encode() and base16_decode()
The current API for Base16 (and Base64) encoding requires the caller
to always provide sufficient buffer space.  This prevents the use of
the generic encoding/decoding functionality in some situations, such
as in formatting the hex setting types.

Implement a generic hex_encode() (based on the existing
format_hex_setting()), implement base16_encode() and base16_decode()
in terms of the more generic hex_encode() and hex_decode(), and update
all callers to provide the additional buffer length parameter.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-04-24 14:41:32 +01:00
Michael Brown 1a4e94a828 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Relicense files with kind permission from

    Stefan Hajnoczi <stefanha@redhat.com>

alongside the contributors who have already granted such relicensing
permission.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-05 11:40:13 +00:00
Michael Brown b2f38da888 [malloc] Rewrite unrelicensable portions of malloc.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 15:24:15 +00:00
Michael Brown 70124dd3be [settings] Rewrite unrelicensable portions of settings.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 00:42:25 +00:00
Michael Brown 0af3d14a23 [settings] Use list_first_entry() when unregistering child settings
Unregistering a child settings block can have almost arbitrary
effects, due to the call to apply_settings().  Avoid potentially
dereferencing a stale pointer by using list_first_entry() rather than
list_for_each_entry_safe() to iterate over the list of child settings.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 00:29:42 +00:00
Michael Brown d1f0e89e4e [libc] Rewrite unrelicensable portions of ctype.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 16:35:37 +00:00
Michael Brown 2f020a8df3 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
These files cannot be automatically relicensed by util/relicense.pl
since they either contain unusual but trivial contributions (such as
the addition of __nonnull function attributes), or contain lines
dating back to the initial git revision (and so require manual
knowledge of the code's origin).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 16:35:29 +00:00
Michael Brown 626ccf76ea [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Relicence files with kind permission from the following contributors:

  Alex Williamson <alex.williamson@redhat.com>
  Eduardo Habkost <ehabkost@redhat.com>
  Greg Jednaszewski <jednaszewski@gmail.com>
  H. Peter Anvin <hpa@zytor.com>
  Marin Hannache <git@mareo.fr>
  Robin Smidsrød <robin@smidsrod.no>
  Shao Miller <sha0.miller@gmail.com>
  Thomas Horsten <thomas@horsten.com>

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 14:50:42 +00:00
Michael Brown b6ee89ffb5 [legal] Relicense files under GPL2_OR_LATER_OR_UBDL
Relicense files for which I am the sole author (as identified by
util/relicense.pl).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-02 14:17:31 +00:00
Michael Brown a32b1e9e35 [libc] Rewrite strtoul()
The implementation of strtoul() has a partially unknown provenance.
Rewrite this code to avoid potential licensing uncertainty.

Since we now use -ffunction-sections, there is no need to place
strtoull() in a separate file from strtoul().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-19 16:00:01 +00:00
Michael Brown bb1abb2b21 [ipv4] Rewrite inet_aton()
The implementation of inet_aton() has an unknown provenance.  Rewrite
this code to avoid potential licensing uncertainty.

Also move the code from core/misc.c to its logical home in net/ipv4.c,
and add a few extra test cases.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-19 14:02:07 +00:00
Michael Brown 8ee39f7432 [libc] Rewrite string functions
Some of the C library string functions have an unknown provenance.
Reimplement all such functions to avoid potential licensing
uncertainty.

Remove the inline-assembler versions of strlen(), memswap(), and
strncmp(); these save a minimal amount of space (around 40 bytes in
total) and are not performance-critical.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-16 23:16:20 +00:00
Michael Brown b54167b8b6 [libc] Remove unused string functions
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-16 16:25:20 +00:00
Michael Brown 92f3bd901e [build] Allow command help text URI to be customised via config/branding.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-11 14:11:28 +00:00
Michael Brown 1c3fb3c61a [build] Move branding information to config/branding.h
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-11 12:51:58 +00:00
Michael Brown e2a26f76de [uri] Allow tftp_uri() to construct a URI with a custom port
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-02-06 12:18:18 +00:00
Michael Brown c86b22221d [iobuf] Add iob_split() to split an I/O buffer into portions
RNDIS devices may provide multiple packets encapsulated into a single
message.  Provide an API to allow the RNDIS driver to split an I/O
buffer into smaller portions.

The current implementation will always copy the underlying data,
rather than splitting the buffer in situ.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-18 14:46:38 +00:00
Michael Brown 35c5379760 [malloc] Report caller address as soon as memory corruption is detected
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-15 14:48:02 +00:00
Michael Brown 7871666740 [malloc] Check integrity of free list
Check the integrity of the free memory block list before and after any
modifications to the list.  We check that certain invariants are
preserved:

 - the list is a well-formed doubly linked list

 - all blocks are at least MIN_MEMBLOCK_SIZE

 - no block extends beyond the end of our address space

 - blocks remain sorted in ascending order of address

 - no blocks are adjacent (i.e. any adjacent blocks have been merged)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-15 14:45:05 +00:00
Michael Brown 9154f2aef3 [malloc] Sanity check parameters to alloc_memblock() and free_memblock()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-15 14:42:26 +00:00
Michael Brown 998e69ae14 [malloc] Tidy up debug output
Colourise debug output and move per-allocation messages to DBGLVL_EXTRA.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-15 14:39:55 +00:00
Michael Brown dea6a6c1a0 [ping] Allow "ping" command output to be inhibited
Originally-implemented-by: Cedric Levasseur <cyr-ius@ipocus.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-23 16:52:08 +01:00
Michael Brown 1c34ca70d1 [ping] Allow termination after a specified number of packets
Add the "-c <count>" option to the "ping" command, allowing for
automatic termination after a specified number of packets.

When a number of packets is specified:

  - if a serious error (i.e. length mismatch or content mismatch)
    occurs, then the ping will be immediately terminated with the relevant
    status code;

  - if at least one response is received successfully, and all errors
    are non-serious (i.e. timeouts or out-of-sequence responses), then
    the ping will be terminated after the final response (or timeout)
    with a success status;

  - if no responses are received successfully, then the ping will be
    terminated after the final timeout with ETIMEDOUT.

If no number of packets is specified, then the ping will continue
until manually interrupted.

Originally-implemented-by: Cedric Levasseur <cyr-ius@ipocus.net>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-23 16:39:42 +01:00
Michael Brown d1afe731ea [ping] Report timed-out pings via the callback function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-10-23 15:04:10 +01:00
Michael Brown 8290a95513 [build] Expose build timestamp, build name, and product names
Expose the build timestamp (measured in seconds since the Epoch) and
the build name (e.g. "rtl8139.rom" or "ipxe.efi"), and provide the
product name and product short name in a single centralised location.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-24 15:32:35 +01:00
Michael Brown 13a74e0d27 [debug] Allow debug message colours to be customised via DBGCOL=...
When multiple iPXE binaries are running concurrently (e.g. in the case
of undionly.kpxe using an underlying iPXE driver via the UNDI
interface) it would be helpful to be able to visually distinguish
debug messages from each binary.

Allow the range of debug colours used to be customised via the
DBGCOL=...  build parameter.  For example:

  # Restrict to colours 31-33 (red, green, yellow)
  make DBGCOL=31-33

  # Restrict to colours 34-36 (blue, magenta, cyan)
  make DBGCOL=34-36

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-06-16 16:53:26 +01:00
Michael Brown 2b4be69eee [libc] Prevent strndup() from reading beyond the end of the string
strndup() may be called on a string which is not NUL-terminated.  Use
strnlen() instead of strlen() to ensure that we do not read beyond the
end of such a string.

Add self-tests for strndup(), including a test case with an
unterminated string.

Originally-fixed-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-18 21:09:49 +01:00
Michael Brown 6f410a16d9 [profile] Allow interrupts to be excluded from profiling results
Interrupt processing adds noise to profiling results.  Allow
interrupts (from within protected mode) to be profiled separately,
with time spent within the interrupt handler being excluded from any
other profiling currently in progress.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-05-04 13:39:42 +01:00
Michael Brown 23b671daf4 [librm] Allow interrupts in protected mode
When running in a virtual machine, switching to real mode may be
expensive.  Allow interrupts to be enabled while in protected mode and
reflected down to the real-mode interrupt handlers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-29 18:24:04 +01:00
Michael Brown 4e78733094 [downloader] Profile receive datapath
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-28 12:31:39 +01:00
Michael Brown e5f6a9be38 [profile] Add generic profiling infrastructure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-27 23:14:43 +01:00
Michael Brown 3ffd309375 [libc] Add isqrt() function to find integer square roots
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-26 18:19:49 +01:00
Michael Brown dce7107fc0 [libc] Add inline assembly implementation of flsl() using BSR instruction
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-24 14:49:08 +01:00
Peter Pickford d644ad41f5 [serial] Enable UART FIFOs
Escape sequences received via the serial console can fail since the
cpu_nap() in getchar_timeout() can delay processing for more than the
time it takes for a single character to arrive.

Fix by enabling the UART FIFOs.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-04-22 13:59:21 +01:00
Michael Brown a17ee3610d [console] Fix display of characters with top bit set
Inhibit implicit sign-padding of characters with the top bit set
(e.g. accented characters), which confuses the mucurses library by
colliding with the bits used to store character attributes and
colours.

Reported-by: Marc Delisle <Marc.Delisle@cegepsherbrooke.qc.ca>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-13 14:21:59 +00:00
Michael Brown b850a6be28 [monojob] Reset timeout when progress is made
Redefine the timeout parameter from "time since start of job" to "time
since progress was last made".  This does not affect any existing
behaviour, since all existing users of the timeout parameter do not
provide progress indication.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-03-10 13:16:18 +00:00
Michael Brown c165e8d1fc [image] Ensure every image has a fully resolved URI
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-27 13:32:58 +00:00
Michael Brown 7667536527 [uri] Refactor URI parsing and formatting
Add support for parsing of URIs containing literal IPv6 addresses
(e.g. "http://[fe80::69ff:fe50:5845%25net0]/boot.ipxe").

Duplicate URIs by directly copying the relevant fields, rather than by
formatting and reparsing a URI string.  This relaxes the requirements
on the URI formatting code and allows it to focus on generating
human-readable URIs (e.g. by not escaping ':' characters within
literal IPv6 addresses).  As a side-effect, this allows relative URIs
containing parameter lists (e.g. "../boot.php##params") to function
as expected.

Add validity check for FTP paths to ensure that only printable
characters are accepted (since FTP is a human-readable line-based
protocol with no support for character escaping).

Construct TFTP next-server+filename URIs directly, rather than parsing
a constructed "tftp://..." string,

Add self-tests for URI functions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-27 13:32:53 +00:00
Michael Brown c7b69ac793 [params] Use reference counters for form parameter lists
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-26 23:34:07 +00:00
Michael Brown 09b057ce84 [settings] Remove "uristring" setting type
Commit b5f5f73 ("[cmdline] Expand settings within each command-line
token individually") effectively rendered the "uristring" setting type
obsolete, since strings containing whitespace no longer break the
command line parser.  The concept of the "uristring" type is not well
defined, since URI escaping rules depend on which portion of a URI is
being escaped.

Remove the "uristring" type, converting it into an alias for the
"string" setting type so as to avoid breaking existing scripts.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-02-26 23:34:07 +00:00
Michael Brown 3ee2c4ac1c [fbcon] Allow ANSI CUP with missing arguments
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 22:43:55 +00:00
Michael Brown 608d6cac9e [fbcon] Allow for an arbitrary margin around the text area
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:26:31 +00:00
Michael Brown 7fc380e950 [fbcon] Centre background picture on console
Centre the background picture on the console, to give a more
consistent result when the aspect ratio does not match the requested
width and height.

Once drawn for the first time, nothing should ever overwrite the
margins of the display.  We can therefore eliminate the logic used to
redraw only the margin areas, and use much simpler code to draw the
complete initial background image.

Simplify the redrawing logic further by making the background picture
buffer equal in size to the frame buffer.  In the common case of a
background picture which is designed to fill the screen, this wastes
no extra memory, and the combined code simplifications reduce the size
of fbcon.o by approximately 15%.

Redefine the concept of "margin" to match the intuitive definition
(i.e. the size of the gap, rather than the position of the boundary
line).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-22 14:16:34 +00:00
Michael Brown a4e8ef72ab [libc] Add isprint()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-01-06 01:46:20 +01:00
Michael Brown f6dce77b15 [console] Add concept of a "magic" colour
The magic basic colour can be remapped at runtime from COLOR_NORMAL_BG
(usually blue) to COLOR_DEFAULT (which will be transparent as a
background colour on the framebuffer console).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-09 15:34:14 +00:00
Michael Brown 7025f5c648 [console] Add centralised concept of colours and colour pairs
Add a centralised concept of colours and colour pairs (using the
default colour pairs as configured via config/colour.h).  A colour
pair consists of a pair of colour indices.

Add the ability to redefine both a colour pair and an individual
colour index, with minimal overhead if this feature is not required
(e.g. because the relevant shell commands are not present in the
build).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-09 15:34:07 +00:00
Michael Brown 4c51f9602d [fbcon] Always draw cursor using current foreground and background colours
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-09 15:34:07 +00:00
Michael Brown 4d9f100240 [fbcon] Update the console width and height after changing mode
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-06 17:52:05 +00:00
Michael Brown 03401f9d21 [console] Allow consoles to update the recorded console size
Provide a mechanism for consoles to update the recorded console width
and height, and use this width and height to provide the curses COLS
and LINES variables.

We choose not to use ANSI escape sequences to obtain the width and
height, for two reasons:

- iPXE's model is that all output is sent to all consoles; we could
  therefore end up with multiple consoles reporting conflicting widths
  and heights

- when a serial console is in use, we probably don't want to resize
  the output shown on the BIOS console to match the size of the serial
  console, since it's likely that the serial console is in use only
  for debugging.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2013-12-06 17:47:54 +00:00