summaryrefslogtreecommitdiff
path: root/com32/lib
Commit message (Collapse)AuthorAgeFilesLines
* chrreplace: Don't skip the first characterJosh Triplett2015-09-281-1/+1
| | | | | | | Check if the first character matches the character to replace, rather than skipping it and starting with the second. Signed-off-by: Josh Triplett <josh@joshtriplett.org>
* zlib: use (void(0)) instead of empty #definesPatrick Masotta2015-09-131-6/+6
| | | | | | Originally-By: Patrick Masotta <masottaus@yahoo.com> [Use (void(0)) instead of a dummy function - gene.cumm@gmail.com] Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
* Use z width specifier when printing size_t variableJonathan Boeing2015-05-031-1/+1
| | | | | | | Fixes the warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'size_t' Signed-off-by: Jonathan Boeing <jonathan.n.boeing@gmail.com>
* add missing '\n' to dprintfJonathan Boeing2015-05-031-2/+2
| | | | Signed-off-by: Jonathan Boeing <jonathan.n.boeing@gmail.com>
* com32/lib/syslinux/load_linux.c: update prot_mode_baseScot Doyle2015-04-181-0/+1
| | | | | | | | | | | | | | | | | If the kernel is relocatable and the protected mode code will not fit in the initially determined location, that code will be moved to the next available location. However, beginning with commit 8f470e7b, the code is moved to the initially determined location instead of the next available location because prot_mode_base is no longer updated to the correct location. Since whdr->code32_start is updated, it is pointing to the wrong execution start location, random code is executed and the machine is rebooted. Restore the old behavior by assigning prot_mode_base the value of base. Tested on a machine that exposed this behavior. Signed-off-by: Scot Doyle <lkml14@scotdoyle.com> Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
* load_linux: correct a typeScot Doyle2015-02-141-2/+2
| | | | | | | | Correct base's type to match its initialization from prot_mode_base and passage to syslinux_memmap_find(). Tested with extlinux. Signed-off-by: Scot Doyle <lkml14@scotdoyle.com> Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
* com32: Use z size specifier for printf-ing size_t variableMartin Str|mberg2015-01-051-1/+1
| | | | | | | | | Use the z size specifier to printf-ing size_t variables to get rid of gcc warning format ‘%08x’ expects type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ Author: Martin Str|mberg <ams@ludd.ltu.se> Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
* com32: change '%llx' to use PRIx64Martin Str|mberg2015-01-051-8/+8
| | | | | | | | | | | | Get rid of printf format warning format ‘%llx’ expects type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ Use <inttypes.h> PRIx64 instead of llx to get rid of gcc warning format ‘%llx’ expects type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ Author: Martin Str|mberg <ams@ludd.ltu.se> Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
* Make symbols defined in linker script HIDDENH. Peter Anvin2014-06-101-15/+15
| | | | | | | This makes symbols defined in com32.ld and syslinux.ld HIDDEN, to avoid collisions. Additional linker scripts should have this done, too. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* biosboot: This file is not for EFInocomapiH. Peter Anvin2014-03-131-0/+4
| | | | | | | This file causes dynamic link failures on EFI, and of course has no use in the EFI environment. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Merge branch 'nocomapi'syslinux-6.03-pre7H. Peter Anvin2014-03-032-8/+42
|\
| * comapi: Remove the comapi interfaces completelyH. Peter Anvin2014-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | Remove the last bits of the comapi interfaces completely. This does not install stub handlers for the INT 20-3Fh handlers, as we don't support loading old COMBOOT/COM32/COM32R images anymore. We could put those back if we really need them. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
| * bios: Remove shuffle and boot comapi callH. Peter Anvin2014-02-132-8/+42
| | | | | | | | | | | | | | | | Remove the shuffle and boot comapi call. This is the last of the comapi calls left; we should now be able to completely remove the comapi support. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* | shuffler: Actually get the shuffler size sanelysyslinux-6.03-pre4H. Peter Anvin2014-02-272-13/+8
|/ | | | | | | | | Actually get the shuffler size sanely. At least for now, we are BIOS only, so stub out the functions on EFI (they shouldn't even be compiled for EFI; this stuff should be moved into some kind of BIOS-only directory.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Add const qualifiersGene Cumm2014-01-251-1/+1
| | | | | | Some functions are ignoring the const qualifier. Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
* com32sys_t inreg shall be zeroified prior intcallErwan Velu2014-01-221-0/+1
| | | | | | | | | | | As per commit f775e740a3a817a4ff5ba26bea99dbfd735456b3, inreg parameters of intcall() shall be zeroified. Having unclean inreg could trigger bad behaviors on some hosts. This patch is about adding memset() calls prior any intcall() : - some intcall didn't had any memset at all - some successive intcall() calls didn't memset inreg in between calls
* ansi: switch cindex type to attr_tJames Buren2013-12-111-1/+2
| | | | | | To fully support color tables with more than 256 entries Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* load_linux: Don't use size heuristic for non-relocatable kernelsH. Peter Anvin2013-12-041-33/+40
| | | | | | | | | | | | | | | | For non-relocatable kernels, it really makes no sense to estimate how much space the kernel is going to need, as if we fail, there is really nothing we can do about it. Furthermore, it is actively wrong for zImage kernels (which aren't decompressed in place) and for non-Linux kernels. Additionally, tweak the code for assigning an address to the command line to handle a few more corner cases correctly, be simpler, and not need to build the memory map again since we already are doing that elsewhere. Reported-and-tested-by: Christian Hesse <list@eworm.de> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* chain: Fix chainloading on 6.02Raphael S. Carvalho2013-10-171-8/+14
| | | | | | | | | | | | My commit 09f4ac33 broke 'com32/lib/syslinux/disk.c' __lowmem doesn't work for declarations outside the core. Using __lowmem outside the core wouldn't have the desired effect, then lmalloc must be used instead to store dapa into the correct section (".lowmem"). Reported-by: Dark Raven <drdarkraven@gmail.com> Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* com32/disk: Code cleanup at disk_write_sectors and disk_read_sectors.Raphael S.Carvalho2013-09-301-83/+90
| | | | | | | | Pulled common code out of these functions into new ones. The functions chs_setup and ebios_setup were created for this purpose. Signed-off-by: Raphael S.Carvalho <raphael.scarv@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* module: convert to dprintf() to aid debuggingsyslinux-6.02-pre14Matt Fleming2013-07-263-16/+23
| | | | | | | | dprintf() is much more useful than DBG_PRINT() when trying to figure out where a module is failing to load because we can enable the debug statements at runtime. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* tests: unit test bios_boot_linux()Matt Fleming2013-07-262-1/+201
| | | | | | | | | | | | The constraints for allocating the kernel cmdline buffer under bios are pretty involved and filled with historic rules. Unit test the bios linux loader to ensure we never violate any of them, while at the same time making sure we actually find a usable chunk of memory. This commit is designed to test the changes in commit 77cadda8 ("load_linux: dynamically calculate the cmdline region"). Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* video.h: we need one syslinux_force_text_mode() prototypeMatt Fleming2013-07-261-1/+1
| | | | | | | | | Use the one from syslinux/video.h. This makes it easier to write unit tests for syslinux/load_linux.c without pulling in loads of core definitions from core/include/graphics.h. It can also be argued that syslinux_* symbols should have prototypes in syslinux/*.h files. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* tests: syslinux_memmap_highest() unit testsMatt Fleming2013-07-261-0/+66
| | | | | | Exercise the new syslinux_memmap_highest() function. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* load_linux: dynamically calculate the cmdline regionsyslinux-6.02-pre12Matt Fleming2013-07-252-4/+70
| | | | | | | | | | | | Users are hitting issues where the offset calculated by, (0x9ff0 - cmdline_size) & ~15; is not useable memory, e.g. it is SMT_RESERVED. Instead we should be trying to find the highest lowmem address. Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* load_linux: extract the logic for cmdline_offsetMatt Fleming2013-07-251-4/+10
| | | | | | | There's bits of historical baggage surrounding these values. Pull the calculation out into a separate function for clarity. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* tests: delete test executables after each runMatt Fleming2013-07-241-3/+1
| | | | | | | | | | The unit tests are designed to be small and should build very quickly, so there should be no downside to rebuilding them for every run. The upside is that we don't litter our build trees with target executables and we don't need to explicitly list dependencies in Makefiles to ensure our tests get rebuilt whenever a dependency changes. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* tests: make mmap_entry globally available to unit testsMatt Fleming2013-07-245-25/+9
| | | | | | | | | | There's a bunch of places that need to deal with mmap_entry entries when doing tests, so make the structure readily available. Since we're going to get a collection of header files that could be considered the "unit test infrastructure" we might as well create a new directory for them. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* tests: Syslinux unit testsMatt Fleming2013-07-236-0/+468
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve our faith in the validity of the Syslinux code by writing unit tests where possible. These should be used in addition to the regression tests - unit tests are a means of doing very fine-grained testing of code, whereas the regression tests are end-to-end tests that exercise abstract functionality. Unit tests run on your development machine and above all else, their execution time should be kept to a minimum to encourage repeated runs of the unit testsuite. The Syslinux header hierarchy has been reconstructed under tests/unittest/include. This allows us to reuse header files where appropriate by simply creating a file with the same name and including the original, e.g. tests/unittest/include/com32.h: #include <../../../com32/include/com32.h> Places where we need to override definitions (so that the tests build in a dev environment) obviously won't include the original header file, but such scenarios should be kept to a minimum, since you're not really testing any Syslinux code that way. To execute the collection of unit tests type, make unittest Sample output might look like, Executing unit tests Running library unit tests... [+] zonelist passed [+] movebits passed [+] memscan passed Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* movebits: Handle arbitrary combinations of SMT_FREE and SMT_TERMINALsyslinux-6.02-pre6H. Peter Anvin2013-07-181-29/+13
| | | | | | | In theory we may have multiple subregions with SMT_FREE and SMT_TERMINAL. This can be fairly easily integrated into a small loop. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* zonelist: allow syslinux_memmap_type() to demote SMT_FREE to SMT_TERMINALH. Peter Anvin2013-07-171-5/+16
| | | | | | | Allow syslinux_memmap_type() to report any combination of SMT_FREE and SMT_TERMINAL as SMT_TERMINAL. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* movebits: allow allocation across region boundaryMatt Fleming2013-07-171-1/+16
| | | | | | | It's OK to allocate across some region boundaries, provided that the region types are compatible. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* memscan: build a linked list of memory scannersMatt Fleming2013-07-171-119/+27
| | | | | | | | | | | By registering memory scanners at runtime we can support multiple memory scanner functions, which helps us to isolate them and keep things modular, only registering them for specific platform/derivative combinations. This is preparation for adding a memory scanner that is specific to PXELINUX on bios and understands when the memory region occupied by the PXE stack can be reused. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* movebits: Add SMT_TERMINAL - a last resort region typeMatt Fleming2013-07-172-2/+2
| | | | | | | | | Some memory regions are usable, but only as a last resort just before we hand over control to a kernel image. Add the necessary movebits infrastructure to use these regions when all other options have been exhausted. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* memscan: pass enum syslinux_memmap_types aroundMatt Fleming2013-07-172-10/+12
| | | | | | | | The memscan interface should be using SMT_* to describe the types of memory regions as SMT_* are platform agnostic values. This will allow us to be much more descriptive about the type of memory regions in future. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* movebits: Add syslinux_memmap_find()Matt Fleming2013-07-172-74/+78
| | | | | | | | Refactor the code for finding a suitable location for kernel protected-mode and real-mode data. It's complicated enough that it deserves to be separated into its own function. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* zonelist: rename syslinux_memmap_find()...Matt Fleming2013-07-173-6/+6
| | | | | | | to syslinux_memmap_find_type(), which more accurately reflects its function and frees up the old name for another use. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* Merge tag 'syslinux-5.11-pre8' into firmwaresyslinux-6.02-pre1Matt Fleming2013-07-082-13/+125
|\ | | | | | | | | | | | | | | | | | | | | syslinux-5.11-pre8 Conflicts: NEWS com32/lib/Makefile core/conio.c mk/devel.mk mk/elf.mk
| * Merge branch 'dynamic-debug' into elflinksyslinux-5.11-pre8Matt Fleming2013-07-052-0/+96
| |\
| | * debug.c32: Dynamically enable/disable debug code at runtimeMatt Fleming2013-07-052-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's useful to be able to enable (and disable) debug code at runtime, particularly for allowing users that are unable to build their own Syslinux releases the chance to provide useful debugging output. For example, say a user reports trouble with their PXE stack but doesn't have a development environment setup to turn on the debug code themselves. With this change you can simply request that they do, debug.c32 -e pxe_call unload_pxe open_file to enable the debug in those functions. By only turning on code in specific functions we reduce the chance of disrupting the buggy behaviour and improve the signal to noise ratio for print statements. To disable debug code use the -d flag, debug.c32 -d pxe_call To use this new feature simply do, if (syslinux_debug_enabled) { debug1(); debug2(); .... } from within the function you wish to add debug code. Note that this feature is not limited to print statements - you can put any code within the conditional, such as verifying a checksum or checking for memory leaks. The plan is to leave the dynamic debug code built in for all prereleases and to turn it off for final releases. People may still want to build with all dprintf() statements enabled, and so a new symbol, DYNAMIC_DEBUG, was introduced rather than repurposing the old DEBUG, DEBUG_STDIO and DEBUG_PORT symbols. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * | load_linux: validate sanity of 'initrd_addr_max'syslinux-5.11-pre5Matt Fleming2013-07-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some kernel headers have bogus 'initrd_addr_max' fields. This field should never be zero. Set it to the old upper limit if unspecified. Failure to set a non-zero value for the field results in a bogus 'memlimit' value, thereby unnecessarily reserving part of the memmap. Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * | load_linux: Add dprintf statements to aid debuggingMatt Fleming2013-07-011-12/+29
| |/ | | | | | | | | | | | | It's useful to know why a kernel is failing to load. Sprinkle some dprintf() statements with informative messages. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | firmware: s/set_mode/text_mode/Matt Fleming2013-07-041-1/+1
| | | | | | | | | | | | | | We only ever use ->set_mode() to transition into text mode, so rename it to something more suitable and drop the unused 'mode' argument. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | com32: Catch up with GCC changes to ctor/dtor funcsMatt Fleming2013-06-283-193/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cherry-pick commit e55d4988 ("com32: Include .init_array section in .ctors in linker script") from the elflink branch. People were seeing this bug manifest as an error when using the CONFIG directive. Loading a new main configuration file causes ldlinux.* to be reloaded and relies on its destructor functions being executed. This change was missed during merging because com32/lib/elf32.ld should have been deleted when we added per-architecture linker scripts. Had we done that, we'd have seen a merge conflict. Because the unused file was left around, things merged silently. Delete the unused file with extreme prejudice. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | load_linux: fallback to the BIOS linux loaderMatt Fleming2013-06-241-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BIOS firmware backend is missing a .load_linux pointer, and so anyone trying to boot a Linux kernel under BIOS is hitting the following error message, "No linux boot function registered for firmware" The usual way to handle this kind of abstraction would be to move bios_load_linux() to core/bios.c and assign it to .load_linux, but that would necessitate pulling the movebits and shuffler code into the core. For now, leave the BIOS loader where it is and use it as the default. In future we will want to move this to BIOS-specific code (though not necessarily in the core) because, by having it in the generic loader code, it is currently being built for the EFI backends even though it is never used. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | load_linux: return a non-void value to fix compiler warningMatt Fleming2013-06-191-2/+2
| | | | | | | | | | | | | | | | | | | | ->boot_linux() actually returns an error value, so return it to the caller of syslinux_boot_linux() and fix the following compiler warning, com32/lib/syslinux/load_linux.c: In function ‘syslinux_boot_linux’: com32/lib/syslinux/load_linux.c:527:1: warning: control reaches end of non-void function [-Wreturn-type] Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | ansi: partially revert 937f816addb214ca4c8c1ce977e0357eafa8c617Matt Fleming2013-06-191-5/+1
| | | | | | | | | | | | | | | | | | Commit ("ansi: Improve EFI console support") broke writing to the display under BIOS in an attempt to get things working under EFI. Since the 'cols' and 'rows' arguments aren't used by the EFI console code, revert that chunk of the commit to restore the BIOS functionality. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
* | Merge tag 'syslinux-5.11-pre2' into firmwareMatt Fleming2013-06-172-36/+49
|\ \ | |/ | | | | | | | | | | | | syslinux-5.11-pre2 Conflicts: core/elflink/load_env32.c version
| * PATH: use a linked list internallysyslinux-5.11-pre1Matt Fleming2013-06-131-24/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In retrospect, choosing the colon character as the entry separator for the PATH directive was not a smart move, as that character is also used in TFTP-style paths. This conflict manifests as PXELINUX being unable to find and load files. An example dnsmasq log looks like, dnsmasq-tftp: sent /arch/boot/syslinux/lpxelinux.0 to 192.168.0.90 dnsmasq-tftp: file /arch/ldlinux.c32 not found dnsmasq-tftp: file /arch//ldlinux.c32 not found dnsmasq-tftp: file /arch//boot/isolinux/ldlinux.c32 not found dnsmasq-tftp: file /arch//isolinux/ldlinux.c32 not found dnsmasq-tftp: file /arch//boot/syslinuxldlinux.c32 not found dnsmasq-tftp: sent /arch//boot/syslinux/ldlinux.c32 to 192.168.0.90 dnsmasq-tftp: error 0 No error, file close received from 192.168.0.90 dnsmasq-tftp: failed sending /arch//boot/syslinux/ldlinux.c32 to 192.168.0.90 dnsmasq-tftp: sent /arch/boot/syslinux/archiso.cfg to 192.168.0.90 dnsmasq-tftp: sent /arch/boot/syslinux/whichsys.c32 to 192.168.0.90 dnsmasq-tftp: file /arch/libcom32.c32 not found dnsmasq-tftp: file /arch//libcom32.c32 not found dnsmasq-tftp: file /arch/libcom32.c32 not found dnsmasq-tftp: file /arch//arch//boot/syslinux/libcom32.c32 not found The last line of the log is the indication that there's a problem. Internally, Syslinux adds the location of ldlinux.c32 to PATH by querying the current working directory once ldlinux.c32 is successfully loaded. Under PXELINUX that means the initial PATH string will be, "::/arch/boot/syslinux/" The PATH parsing code doesn't know how to correctly parse the "::" string and hence, the file is searched for relative to the 210 dhcp option directory - /arch/. Implement PATH with a linked list which *greatly* simplifies the path code, and means we no longer have to parse strings backwards and forwards. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
| * load_linux: update errno before returningMatt Fleming2013-04-251-12/+37
| | | | | | | | | | | | | | | | | | | | | | | | syslinux_boot_linux() only returns control to the caller when something has gone wrong, under normal circumstances a kernel is booted. Update errno accordingly in the error paths, so the user no longer sees inaccurate errno values which result in the following kinds of messages, "Booting kernel failed: Bad file descriptor" Signed-off-by: Matt Fleming <matt.fleming@intel.com>