summaryrefslogtreecommitdiffstats
path: root/src/core
Commit message (Collapse)AuthorAgeFilesLines
* [fbcon] Move margin calculations to fbcon.cMichael Brown2015-10-141-14/+36
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fbcon] Allow character height to be selected at runtimeMichael Brown2015-10-141-10/+9Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [malloc] Avoid integer overflow for excessively large memory allocationsMichael Brown2015-09-291-48/+49
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [uri] Generalise tftp_uri() to pxe_uri()Michael Brown2015-09-021-16/+37
| | | | | | | | | | | | | | | | | | 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>
* [settings] Re-add "uristring" setting typeMichael Brown2015-08-252-27/+104
| | | | | | | | | | | | | | | | | | | | 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>
* [image] Detect image type when image is first registeredMichael Brown2015-08-211-41/+42
| | | | | | | | | | | | | | | | | | | 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>
* [test] Allow self-tests to report exit status when running under LinuxMichael Brown2015-08-211-3/+6
| | | | | | | | | 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>
* [block] Add generic block device translatorMichael Brown2015-08-161-0/+261
| | | | | | | 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>
* [serial] Check for UART existence in uart_select()Michael Brown2015-07-311-7/+25
| | | | | | | | | | | 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>
* [linebuf] Support buffering of multiple linesMichael Brown2015-07-281-13/+40
| | | | | | | | 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>
* [pool] Add a generic concept of a pooled connectionMichael Brown2015-07-281-0/+114
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Fix compiler warnings on some gcc versionsMichael Brown2015-07-271-1/+1
| | | | | | | | | | | | | | | | | | 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>
* [downloader] Provide direct access to the underlying data transfer bufferMichael Brown2015-07-221-0/+14
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [downloader] Use generic data-transfer buffer mechanismMichael Brown2015-07-221-74/+18Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xferbuf] Add xfer_buffer() to provide direct access to underlying bufferMichael Brown2015-07-221-0/+39
| | | | | | | Allow data transfer buffer users to provide direct access to their underlying data transfer buffer. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xferbuf] Generalise to handle umalloc()-based buffersMichael Brown2015-07-221-22/+195
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xfer] Add xfer_check_order() utility functionMichael Brown2015-07-221-0/+31
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [xfer] Use intf_poke() to implement xfer_window_changed()Michael Brown2015-07-221-11/+1Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [interface] Add intf_poke() helperMichael Brown2015-07-221-0/+25
| | | | | | | 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>
* [fault] Add inject_corruption() to randomly corrupt dataMichael Brown2015-07-221-0/+29
| | | | | | | 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>
* [fault] Generalise NETDEV_DISCARD_RATE fault injection mechanismMichael Brown2015-07-221-0/+53
| | | | | | | 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>
* [gdb] Allow gdbstub to be started on an arbitrary serial portMichael Brown2015-06-291-7/+36
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [serial] Use new UART abstraction in serial console driverMichael Brown2015-06-292-254/+137Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [gdb] Use new UART abstraction in GDB serial transportMichael Brown2015-06-291-8/+45
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [serial] Add general abstraction of a 16550-compatible UARTMichael Brown2015-06-291-0/+135
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "base64" setting typeMichael Brown2015-04-241-0/+41
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [base64] Add buffer size parameter to base64_encode() and base64_decode()Michael Brown2015-04-241-54/+46Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [base16] Add buffer size parameter to base16_encode() and base16_decode()Michael Brown2015-04-242-89/+30Star
| | | | | | | | | | | | | | 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>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-054-4/+20
| | | | | | | | | | | 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>
* [malloc] Rewrite unrelicensable portions of malloc.cMichael Brown2015-03-031-22/+41
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Rewrite unrelicensable portions of settings.cMichael Brown2015-03-031-6/+13
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Use list_first_entry() when unregistering child settingsMichael Brown2015-03-031-2/+2
| | | | | | | | | 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>
* [libc] Rewrite unrelicensable portions of ctype.hMichael Brown2015-03-021-3/+4
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-0211-11/+51
| | | | | | | | | | 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>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-023-3/+15
| | | | | | | | | | | | | | | 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>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-0252-52/+244
| | | | | | | Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Rewrite strtoul()Michael Brown2015-02-194-126/+134
| | | | | | | | | | 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>
* [ipv4] Rewrite inet_aton()Michael Brown2015-02-191-23/+0Star
| | | | | | | | | | 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>
* [libc] Rewrite string functionsMichael Brown2015-02-171-258/+273
| | | | | | | | | | | | 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>
* [libc] Remove unused string functionsMichael Brown2015-02-161-188/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Allow command help text URI to be customised via config/branding.hMichael Brown2015-02-111-1/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Move branding information to config/branding.hMichael Brown2015-02-111-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [uri] Allow tftp_uri() to construct a URI with a custom portMichael Brown2015-02-061-1/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [iobuf] Add iob_split() to split an I/O buffer into portionsMichael Brown2014-12-181-0/+30
| | | | | | | | | | | 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>
* [malloc] Report caller address as soon as memory corruption is detectedMichael Brown2014-12-151-1/+21
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [malloc] Check integrity of free listMichael Brown2014-12-151-1/+59
| | | | | | | | | | | | | | | | | | 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>
* [malloc] Sanity check parameters to alloc_memblock() and free_memblock()Michael Brown2014-12-151-0/+6
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [malloc] Tidy up debug outputMichael Brown2014-12-151-19/+23
| | | | | | Colourise debug output and move per-allocation messages to DBGLVL_EXTRA. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ping] Allow "ping" command output to be inhibitedMichael Brown2014-10-231-3/+5
| | | | | Originally-implemented-by: Cedric Levasseur <cyr-ius@ipocus.net> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ping] Allow termination after a specified number of packetsMichael Brown2014-10-231-2/+37
| | | | | | | | | | | | | | | | | | | | | | | | | 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>