platform/upstream/syslinux.git
12 years agocore: Delete code that is duplicated in ldlinux
Matt Fleming [Tue, 24 May 2011 09:45:51 +0000 (10:45 +0100)]
core: Delete code that is duplicated in ldlinux

Lots of code that used to be implemented in the core is now
implemented in ldlinux, but code from core was never deleted. Purge
this code.

Also, move all com32 loading to ldlinux since we need to be able to do
various command line things (which are no longer available in the
core).

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
12 years agocore: Reimplement writestr in C
Matt Fleming [Wed, 19 Oct 2011 09:02:42 +0000 (10:02 +0100)]
core: Reimplement writestr in C

Implement writestr in C instead of asm and move writestr.inc into
modules/ because it's required by modules/ver.asm.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
12 years agocore: Reimplement lots asm code in C
Matt Fleming [Tue, 18 Oct 2011 12:13:06 +0000 (13:13 +0100)]
core: Reimplement lots asm code in C

There is an awful lot of code currently implemented in assembly when
it could just as easily be implemented in C. Having it in C makes it
much easier to share code between the BIOS and forthcoming EFI
firmware backend. The following code fragments have been rewritten,

  - timer initialisation
  - adjust_screen()
  - check_esapes() and mem_init()
  - conio.inc
  - plaincon.inc
  - cleanup.inc
  - serirq.inc
  - font.inc
  - graphics
  - writehex

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
12 years agocom32: Add unhexchar
Matt Fleming [Wed, 18 May 2011 14:55:21 +0000 (15:55 +0100)]
com32: Add unhexchar

Add a C implementation of unhexchar() for use in C code. This
implementation should be an exact duplicate of the old asm version.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoMerge remote-tracking branch 'mfleming/for-hpa/elflink/ldlinux' into elflink
H. Peter Anvin [Thu, 28 Jul 2011 21:02:58 +0000 (14:02 -0700)]
Merge remote-tracking branch 'mfleming/for-hpa/elflink/ldlinux' into elflink

13 years agopxelinux: open_file() returns a non-negative handle
Matt Fleming [Tue, 12 Jul 2011 15:21:37 +0000 (16:21 +0100)]
pxelinux: open_file() returns a non-negative handle

The usage of open_file() is wrong in core/fs/pxe/pxe.c. Any
non-negative return value indicates success, not just a return value
of zero.

This bug was introduced in commit ba4fefa9b52b "core: change
load_config() to open_config()". The bug causes pxelinux to fail to
open configuration files.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agopxelinux: open_file() returns a non-negative handle
Matt Fleming [Tue, 12 Jul 2011 15:12:48 +0000 (16:12 +0100)]
pxelinux: open_file() returns a non-negative handle

The usage of open_file() is wrong in core/fs/pxe/pxe.c. Any
non-negative return value indicates success, not just a return value
of zero.

This bug was introduced in commit ba4fefa9b52b "core: change
load_config() to open_config()". The bug causes pxelinux to fail to
open configuration files.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocore: Fix ldlinux.c32 failing to load when not installed in "/"
Matt Fleming [Tue, 12 Jul 2011 10:52:05 +0000 (11:52 +0100)]
core: Fix ldlinux.c32 failing to load when not installed in "/"

Currently, if syslinux is installed in a directory other than "/" we
will fail to load ldlinux.c32.

Because we know where we were installed the simplest fix is to chdir()
to the installation directory before attempting to load
ldlinux.c32. This requires us to add "." to PATH so that we look in
the current working directory when loading ELF modules.

Changing to the install directory needs to handled differently for
different file systems, which is the reason behind the new file system
operation, .chdir_start(). Disk-based Syslinux variants should use
generic_chdir_start() to chdir() to CurrentDirName, which is the
installation path. By using this new fs operation, we can load
ldlinux.c32 when we expand the "."  in PATH, without having to search
the entire filesystem for it. However, iso9660 file systems still
require us to search some directories because it has no notion of an
installation directory.

Previously, changing into the install directory was handled when
opening the config file, but because the config file parser is now
part of the ldlinux.c32 ELF module, it needs to be done much earlier.

Reported-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoMerge branch 'DT_NEEDED-module-deps' into for-hpa/elflink/ldlinux
Matt Fleming [Tue, 7 Jun 2011 19:12:36 +0000 (20:12 +0100)]
Merge branch 'DT_NEEDED-module-deps' into for-hpa/elflink/ldlinux

13 years agoMerge branch 'PATH-based-search' into for-hpa/elflink/ldlinux
Matt Fleming [Tue, 7 Jun 2011 19:12:17 +0000 (20:12 +0100)]
Merge branch 'PATH-based-search' into for-hpa/elflink/ldlinux

Conflicts:
com32/elflink/ldlinux/readconfig.c

13 years agoMerge branch 'fs-config' into for-hpa/elflink/ldlinux
Matt Fleming [Tue, 7 Jun 2011 19:10:59 +0000 (20:10 +0100)]
Merge branch 'fs-config' into for-hpa/elflink/ldlinux

Conflicts:
com32/elflink/ldlinux/readconfig.c

13 years agoMerge branch 'pxelinux' into for-hpa/elflink/ldlinux
Matt Fleming [Tue, 7 Jun 2011 19:06:01 +0000 (20:06 +0100)]
Merge branch 'pxelinux' into for-hpa/elflink/ldlinux

Conflicts:
core/pxelinux.asm

13 years agoldlinux: Support "kbdmap"
Matt Fleming [Fri, 27 May 2011 16:57:32 +0000 (17:57 +0100)]
ldlinux: Support "kbdmap"

Add support to the ldlinux config file parser for the "kbdmap"
directive.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Support "font"
Matt Fleming [Fri, 27 May 2011 16:57:05 +0000 (17:57 +0100)]
ldlinux: Support "font"

Add support for parsing the "font" config directive to ldlinux.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Parse "display" in config files
Matt Fleming [Fri, 27 May 2011 16:49:39 +0000 (17:49 +0100)]
ldlinux: Parse "display" in config files

Teach ldlinux to parse the "display" directive.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Add support for parsing "serial" config directive
Matt Fleming [Fri, 27 May 2011 16:10:32 +0000 (17:10 +0100)]
ldlinux: Add support for parsing "serial" config directive

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Use DT_NEEDED for module dependencies
Matt Fleming [Mon, 6 Jun 2011 13:12:45 +0000 (14:12 +0100)]
ldlinux: Use DT_NEEDED for module dependencies

The ELF file format uses DT_NEEDED entries in the dynamic section to
name any shared library dependencies. Instead of rolling our own
dependency logic via the modules.dep file and elf_gen_dep.sh script
use the DT_NEEDED entries.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Use open_config() to open config files
Matt Fleming [Mon, 6 Jun 2011 21:45:33 +0000 (22:45 +0100)]
ldlinux: Use open_config() to open config files

Instead of duplicating the logic for finding config files on different
filesystems in both ldlinux/readconfig.c and core/fs/* use the
open_config() wrapper that calls into the fs-specific open_config().

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocore: Return a file descriptor from open_config()
Matt Fleming [Mon, 6 Jun 2011 21:17:03 +0000 (22:17 +0100)]
core: Return a file descriptor from open_config()

Wrap open_config() the same way that open() wraps open_file(). The
only user of open_config() requires access to a file descriptor so it
makes sense to return a file descriptor.

The file handle implementation is a historic piece of code and this
patch tries to hide it as they will likely be removed at a future
point in time. Furthermore, the file handle code is very core-specific
and should not be exposed to any callers of open_config().

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocore: open_file() returns a non-negative handle id
Matt Fleming [Mon, 6 Jun 2011 17:19:02 +0000 (18:19 +0100)]
core: open_file() returns a non-negative handle id

We currently only take the success path if open_file() returns 0 but
open_file() returns a handle ID which is a non-negative number.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: PATH-based module lookup
Matt Fleming [Mon, 6 Jun 2011 10:09:42 +0000 (11:09 +0100)]
ldlinux: PATH-based module lookup

Add support for specifying directories to search when loading
modules. A new config directive, "PATH", instructs the module loading
code to search the directories listed in a colon-separated list when
loading a module.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocore: change load_config() to open_config()
H. Peter Anvin [Sat, 28 May 2011 00:45:59 +0000 (17:45 -0700)]
core: change load_config() to open_config()

Change load_config() to open_config(), which is a method that works
just like open_file().  This we can use to get the original
configuration file.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
13 years agocore: fix warnings in core/mem/init.c
H. Peter Anvin [Sat, 28 May 2011 00:45:22 +0000 (17:45 -0700)]
core: fix warnings in core/mem/init.c

Fix warnings (that block -Werror) in core/mem/init.c

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
13 years agocore.h: add a few include files needed pretty much everywhere
H. Peter Anvin [Sat, 28 May 2011 00:44:48 +0000 (17:44 -0700)]
core.h: add a few include files needed pretty much everywhere

Some include files we might as well centralize...

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
13 years agocore: Load the 32-bit environment at startup
Matt Fleming [Fri, 27 May 2011 16:09:27 +0000 (17:09 +0100)]
core: Load the 32-bit environment at startup

Do the same as the other Syslinux variants and initialise the 32-bit
environment when we boot.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Add support for parsing pxeretry option
Matt Fleming [Wed, 25 May 2011 22:29:05 +0000 (23:29 +0100)]
ldlinux: Add support for parsing pxeretry option

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Initialise ipappend strings
Matt Fleming [Wed, 25 May 2011 19:26:23 +0000 (20:26 +0100)]
ldlinux: Initialise ipappend strings

Previouly __syslinux_get_ipappend_strings() was called as a
__constructor. However, as constructors are executed before we load
any ELF modules we need to explicitly call this function to initialise
the ipappend string.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Fix "prompt" config option parsing
Matt Fleming [Wed, 25 May 2011 14:35:53 +0000 (15:35 +0100)]
ldlinux: Fix "prompt" config option parsing

Previously, we were looking for the value of the prompt option 8
characters after the first 'p', clearly since "prompt" is only 6
characters we should be searching after the sixth character.

I noticed this bug when specifying "prompt 1" in my config file and
Syslinux still tried to boot the default kernel.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Remove __constructor attribute
Matt Fleming [Wed, 25 May 2011 07:45:37 +0000 (08:45 +0100)]
ldlinux: Remove __constructor attribute

The __constructor tag only makes sense in the core as the constructor
functions are executed from load_env32(), before any modules have been
loaded. Therefore, applying __constructor to code inside ldlinux is
pointless as unless the functions are called explicitly, they will
never be executed.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Add support for Auxillary Data Vector
Matt Fleming [Wed, 25 May 2011 07:39:47 +0000 (08:39 +0100)]
ldlinux: Add support for Auxillary Data Vector

Move all the code for the ADV into ldlinux so that it doesn't have any
dependencies on other modules.

We also need a way to initialize the ADV from ldlinux, so add another
vector to the comboot API.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Add localboot support
Matt Fleming [Tue, 24 May 2011 10:54:10 +0000 (11:54 +0100)]
ldlinux: Add localboot support

Add a few tweaks to enable ldlinux to localboot a hard disk. Most of
the support was already there, there were just a few bug fixes in
execute().

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Search in isolinux/ directory for config files
Matt Fleming [Tue, 24 May 2011 10:37:49 +0000 (11:37 +0100)]
ldlinux: Search in isolinux/ directory for config files

If we're running from an ISO image we should be looking in the
isolinux/ directory for isolinux.cfg, not in the top-level directory.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agohdt: libmenu.a no longer exists
Matt Fleming [Fri, 29 Apr 2011 10:20:11 +0000 (11:20 +0100)]
hdt: libmenu.a no longer exists

Don't link against libmenu.a, it no longer exists as it was removed in
commit 74518b8b691c ("elflink: Make ELF the default object format").

This fixes the following build error,

make[2]: *** No rule to make target `../cmenu/libmenu/libmenu.a', needed by `hdt.c32'.  Stop.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoload_env32 should not include menu.h
H. Peter Anvin [Wed, 27 Apr 2011 21:27:35 +0000 (14:27 -0700)]
load_env32 should not include menu.h

Remove stay #include that does not resolve.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
13 years agoelf_gen_dep.sh: Prioritise symbols exported by core
Matt Fleming [Fri, 15 Apr 2011 20:35:48 +0000 (21:35 +0100)]
elf_gen_dep.sh: Prioritise symbols exported by core

It's possible for multiple modules to export the same symbol. We
always favour the symbols exported from core/ because this means that
modules will have less runtime dependencies.

For example, some symbols required by ldlinux.c32 are exported by both
core/ and libmenu.c32. Because we don't want ldlinux.c32 to have any
dependencies, we need to make sure we resolve to the symbol exported
by core/.

Note that now the order in which we extract global symbols from ELF
files in elf_gen_dep.sh is important, because this dictates our order
of preference and hence core/isolinux.elf and core/pxelinux.elf need
to come first.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelf_gen_dep.sh: Don't calculate dependencies for whitespace symbols
Matt Fleming [Fri, 15 Apr 2011 20:27:37 +0000 (21:27 +0100)]
elf_gen_dep.sh: Don't calculate dependencies for whitespace symbols

Don't try to resolve dependencies for a symbol whose name is purely
made up of whitespace.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelflink: Don't require every module to have init/exit functions
Matt Fleming [Fri, 15 Apr 2011 20:10:55 +0000 (21:10 +0100)]
elflink: Don't require every module to have init/exit functions

Don't complain or refuse to load a module if it doesn't contain an
init or exit function, as many of the init/exit functions are in fact
empty.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelflink: Don't compile in debug output by default
Matt Fleming [Fri, 15 Apr 2011 20:03:51 +0000 (21:03 +0100)]
elflink: Don't compile in debug output by default

Turn off ELF_DEBUG, we really don't need to see the "[ELF] MODULE
UNLOADED" message everytime we finish executing an ELF module.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelflink: ldlinux should not have any dependencies
Matt Fleming [Tue, 26 Apr 2011 09:02:13 +0000 (10:02 +0100)]
elflink: ldlinux should not have any dependencies

ldlinux currently requires the get_key() symbol, which means it has a
dependency on libutil_com.c32. ldlinux.c32 really should be a
standalone module so let's move get_key.c into ldlinux/.

However, moving get_key.c creates a new problem - native linux
applications such as com32/samples/keytest.c require the get_key()
symbol which is currently exported by libutil_lnx.a. To fix this, we
create a new native linux library that exports any required symbols
from ldlinux. With this change we need to update com32/Makefile so
that we build com32/elfink/ldlinux before com32/samples, and seeing as
ldlinux now has no dependencies, we may as well move it to the front
of $SUBDIRS.

Also, update elf_gen_dep.sh to skip ldlinux.c32 and not search for
dependencies for any of its unresolved symbols. This way, if anyone
inadvertently introduces a dependency that cannot be resolved by the
core, ldlinux.c32 will fail to load at runtime (which guarantees that
the newly introduced dependency won't go unnoticed).

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoexit.c: Truncate exit status to uint8_t
Matt Fleming [Fri, 15 Apr 2011 10:48:37 +0000 (11:48 +0100)]
exit.c: Truncate exit status to uint8_t

The valid range for an exit status is 0 - 255, so we need to truncate
the value passed to _exit().

I noticed this when a module was doing _exit(-1), and ended up calling

longjmp(.., 0xffffffff + 1)

which meant that setjmp() in spawn_load() returned 0. Obviously, we
wanted the setjmp() to return 256 (0xff + 1), because the code in
spawn_load() handles the return value like so,

ret_val = setjmp(module->u.x.process_exit);

if (ret_val)
ret_val--;              /* Valid range is 0-255 */
else if (!module->main_func)
ret_val = -1;
else
exit((module->main_func)(argc, argv)); /* Actually run! */

There actually is code in spawn_load() to properly truncate 'ret_val',
but it is applied too late. The truncation needs to happen when we
pass the exit status to longjmp().

Suggested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelflink: Make ELF the default object format
Matt Fleming [Tue, 26 Apr 2011 08:59:53 +0000 (09:59 +0100)]
elflink: Make ELF the default object format

com32/elflink/modules was originally created to house ELF modules and
keep them separate from the COM32 modules as the elflink branch was
being developed. However, this has inadvertently created a maintenance
nightmare because code was copied from elsewhere in the tree into
com32/elflink/modules, resulting in duplication. Bug fixes have been
going into the original code but have not been merged onto the elflink
branch, leaving the duplicate code in com32/elflink/modules buggy.

So let's delete this directory. There really is no reason to keep ELF
and COM32 modules separate because there's no reason to need both
COM32 and ELF modules to coexist. ELF is a far superior object file
format and all modules are not emitted as ELF objects.

Now that we're outputting ELF modules we can use dynamic memory
instead of the cs_bounce bounce buffer.

This commit requires a certain amount of shuffling for some
files. quicksort.c isn't a module and belongs as part of the util
library. cli.h belongs in com32/include so that other modules can make
use of the cli code in ldlinux.c32.

All libraries are now ELF shared libraries which are only loaded to
fixup unresolved symbols for executable modules and renamed from *.a
to *.c32. This reduces the runtime memory footprint because libraries
are only loaded when needed and because every executable no longer
gets its own copy of code/data (as it would if linking with a static
library). Also, remove MINLIBOBJS from libcom32.c32 because it is
already part of libcom32min.a and we don't want to have any duplicate
symbols between the core (which links with libcom32min.a) and
libcom32.c32.

Welcome to the New World Order of ELF modules!

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelflink: Delete core-elf.h
Matt Fleming [Wed, 13 Apr 2011 23:59:12 +0000 (00:59 +0100)]
elflink: Delete core-elf.h

This header file really just duplicates code that is available in
other header files. It has no reason to exist.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocom32: Move menu.h
Matt Fleming [Wed, 13 Apr 2011 23:52:23 +0000 (00:52 +0100)]
com32: Move menu.h

menu.h is required by the menu code in com32/menu and also by
ldlinux. So move it to a more neutral place.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocom32: We only need one refstr.h
Matt Fleming [Wed, 13 Apr 2011 23:50:08 +0000 (00:50 +0100)]
com32: We only need one refstr.h

Delete the duplicate refstr.h and move the remaining copy into
com32/include so that it can be included by both ldlinux and the menu
code.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocmenu: Rename menu.h to cmenu.h
Matt Fleming [Wed, 13 Apr 2011 22:00:16 +0000 (23:00 +0100)]
cmenu: Rename menu.h to cmenu.h

In preparation for moving com32/menu/menu.h to com32/include/ let's
rename com32/cmenu/menu.h. This stops us having two header files named
menu.h which would mean that we'd have to be super careful with our
include paths to ensure we included the correct header.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocom32: Remove klibc.c32
Matt Fleming [Tue, 12 Apr 2011 21:28:57 +0000 (22:28 +0100)]
com32: Remove klibc.c32

We don't need this anymore as it includes DYNOBJS but libcom32.c32
also includes those objects and we can now dynamically load
libcom32.c32 at runtime.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocom32: Put deleted object files back into the Makefile
Matt Fleming [Wed, 13 Apr 2011 11:54:49 +0000 (12:54 +0100)]
com32: Put deleted object files back into the Makefile

For some reason that I can't understand, some object files were
removed from this Makefile in the following commit,

    |commit 0cb6490fa96f752c01bbb9add2c9ca6dbf99ece2
    |Author: Feng Tang <feng.tang@intel.com>
    |Date:   Thu Jun 3 10:48:22 2010 +0800
    |
    |   elflink: start merge with pathbased branch
    |
    |   modify these files to make compile pass
    |
    |       modified:   com32/MCONFIG
    |       modified:   com32/Makefile
    |       modified:   com32/include/klibc/compiler.h
    |       modified:   com32/include/sys/elfcommon.h
    |       modified:   com32/lib/Makefile
    |       modified:   com32/lib/free.c
    |       modified:   com32/lib/malloc.c

However, with this patch things continue to compile correctly so I'm
unsure why they were ever removed. Furthermore, pieces of code in
com32/ refer to symbols defined in these these object files and so
they are required in order to load modules.

These missing object files were discovered when loading libcom32.c32,
which wouldn't load because it was complaining about unresolved
symbols.

The removal of core/strncasecmp.c needs some explanation. There are
currently two identical copies of strncasecmp.c, one in com32/lib and
one in core/, and while the core copy is part of core/libcom32.a, the
copy in com32/lib isn't compiled. Now, because there are no references
to strncasecmp within core/ the symbol isn't pulled in from libcom32.a
and exported as a global symbol by the core. So, if ELF modules have
references to strncasecmp they cannot be resolved at runtime.

To fix this I've included strncasecmp.o in libcom32min.a which
isolinux.elf, ldlinux.elf and pxelinux.elf link against with
--whole-archive, which means that even if there are no references to
strncasecmp within the core, that symbol is still exported.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelflink: Move more code from core/ into ldlinux
Matt Fleming [Fri, 8 Apr 2011 12:21:51 +0000 (13:21 +0100)]
elflink: Move more code from core/ into ldlinux

ldlinux now contains all the code necessary to load and execute
modules, none is contained in the core.

This change also allows us to change the spawn_load() prototype and to
push the job of processing arguments to executable functions (e.g. the
contents of char *argv[] as passed to a module's main function) into
ldlinux/execute.c instead of doing it in spawn_load(). Moving it into
ldlinux/ makes sense because the only core user of spawn_load() is
load_env32() and we don't require any sort of argument processing in
that path.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelflink: Remove MODULE_MAIN() from executable ELF modules
Matt Fleming [Thu, 7 Apr 2011 20:02:02 +0000 (21:02 +0100)]
elflink: Remove MODULE_MAIN() from executable ELF modules

To make it easier to move existing COM32 modules over to ELF modules
without having to modify them we need to search for and run their
main() functions when they're loaded instead of requiring their
initial function to be labeled with MODULE_MAIN().

Currently, we require all executable ELF modules to specify their
initial function with the use of the MODULE_MAIN() macro and not via
the traditional method of naming it main(). However, there are weird
restrictions on what functions can be passed to MODULE_MAIN(), for
instance, they must be declared static.

This patch makes life much simpler and allows executable ELF modules
to be loaded without the MODULE_MAIN() wrapper, but rather by naming
their initial function main(). All the modules in com32/modules can
now be run as ELF modules without any modifications.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agocom32: console is already initialised when we enter main()
Matt Fleming [Fri, 8 Apr 2011 12:52:30 +0000 (13:52 +0100)]
com32: console is already initialised when we enter main()

There's no need to initialise the console when we enter main() as
ldlinux.c32 will already have initialised it for us. Leaving the calls
to openconsole() causes the console settings to be reset whenever we
run a module.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoexit: Delete exit.S and references to __exit_handler
Matt Fleming [Tue, 12 Apr 2011 21:24:36 +0000 (22:24 +0100)]
exit: Delete exit.S and references to __exit_handler

We stopped using exit.S (and thus __exit_handler) in 71d5d1ba646e
("elflink: change the exit.c, remove the exit.S to make process exit
working") when we moved to using the C version of _exit(). If we don't
remove the symbol __exit_handler we'll encounter undefined symbol
errors when moving libcom32.a over to an ELF shared library.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agomk: LDFLAGS use elf_i386 emulation for ld
Matt Fleming [Tue, 12 Apr 2011 21:23:55 +0000 (22:23 +0100)]
mk: LDFLAGS use elf_i386 emulation for ld

elf32_i386 isn't a valid ld emulation mode. Presumably no one is using
$(LDFLAGS) set in this file.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agomk: Add rule for emitting .c32 ELF files
Matt Fleming [Thu, 7 Apr 2011 20:00:31 +0000 (21:00 +0100)]
mk: Add rule for emitting .c32 ELF files

We currently open code the Makefile rules for outputting .c32 files,
so provide a pattern rule to make things easier.

There are no users of this rule yet, but we'll make use of it when we
switch all modules over to ELF.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoelflink: Move elf MCONFIG to mk/elf.mk
Matt Fleming [Thu, 7 Apr 2011 17:12:51 +0000 (18:12 +0100)]
elflink: Move elf MCONFIG to mk/elf.mk

Catch up with recent changes to the Makefile fragments in the MCONFIG
files.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoMerge branch 'for-hpa/elflink/core' into elflink
Matt Fleming [Tue, 26 Apr 2011 08:51:32 +0000 (09:51 +0100)]
Merge branch 'for-hpa/elflink/core' into elflink

13 years agoMerge branch 'for-hpa/elflink/ldlinux' into elflink
Matt Fleming [Tue, 26 Apr 2011 08:51:14 +0000 (09:51 +0100)]
Merge branch 'for-hpa/elflink/ldlinux' into elflink

13 years agoMerge remote-tracking branch 'zytor/master' into elflink
Matt Fleming [Tue, 26 Apr 2011 08:46:34 +0000 (09:46 +0100)]
Merge remote-tracking branch 'zytor/master' into elflink

We need the recent Makefile filename changes to be merged into the
elflink branch because it will make things simpler when converting all
modules to ELF format.

Conflicts:
com32/Makefile
com32/modules/Makefile
version

13 years agohdt: add back -I$(com32)
H. Peter Anvin [Tue, 26 Apr 2011 08:30:29 +0000 (01:30 -0700)]
hdt: add back -I$(com32)

hdt picks up include files from outside the include directory and so
needs an explicit -I$(com32).  This probably should be fixed.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agosysdump: add $(LIBS) to the link rule
H. Peter Anvin [Tue, 26 Apr 2011 08:29:28 +0000 (01:29 -0700)]
sysdump: add $(LIBS) to the link rule

$(C_LIBS) doesn't include $(LIBS) so we need to add it explicitly.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agoMerge remote-tracking branch 'mfleming/for-hpa/makefile-cleanup'
H. Peter Anvin [Tue, 26 Apr 2011 08:18:18 +0000 (01:18 -0700)]
Merge remote-tracking branch 'mfleming/for-hpa/makefile-cleanup'

Resolved Conflicts:
com32/hdt/Makefile
com32/sysdump/Makefile

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agoisolinux: remove broken and obsolete open_file_t
H. Peter Anvin [Tue, 26 Apr 2011 03:18:07 +0000 (20:18 -0700)]
isolinux: remove broken and obsolete open_file_t

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agoisolinux: remove .img file support
H. Peter Anvin [Tue, 26 Apr 2011 03:16:07 +0000 (20:16 -0700)]
isolinux: remove .img file support

Remove disk image support from ISOLINUX.  Very few BIOSes support this
call correctly, and it is likely to have been broken for a very long
time anyway.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agocom32: inet_ntoa() takes struct in_addr
H. Peter Anvin [Tue, 26 Apr 2011 00:15:40 +0000 (17:15 -0700)]
com32: inet_ntoa() takes struct in_addr

The standard definition for inet_ntoa() is to take struct in_addr, and
not doing that causes a conflict on the lwip branch.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agohdt: remove set-but-unused variable
H. Peter Anvin [Tue, 26 Apr 2011 00:00:22 +0000 (17:00 -0700)]
hdt: remove set-but-unused variable

Remove a set but unused variable in HDT, which prevents building with
gcc 4.6.  This is probably a bug; presumably the active flag should be
presented to the user, too.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agoMerge remote-tracking branch 'sherbszt/gfxboot32'
H. Peter Anvin [Mon, 25 Apr 2011 22:24:33 +0000 (15:24 -0700)]
Merge remote-tracking branch 'sherbszt/gfxboot32'

13 years agogfxboot: pass current working dir to gfxboot core
Steffen Winterfeldt [Tue, 19 Apr 2011 13:27:26 +0000 (15:27 +0200)]
gfxboot: pass current working dir to gfxboot core

Pass current working dir to (and back from) gfxboot core via gfx_config
struct. This way I can implement a chdir() in the gfxboot core without
the need for additional 16-bit comboot calls. gfxboot may change the
directory, so you have to read and apply the current setting in boot() (to
read kernel etc. from right location).

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
13 years agoMerge remote-tracking branch 'hdt/master'
H. Peter Anvin [Mon, 25 Apr 2011 21:34:30 +0000 (14:34 -0700)]
Merge remote-tracking branch 'hdt/master'

13 years agodiag/geodsp: zero-fill sectors in -1 mode
H. Peter Anvin [Mon, 25 Apr 2011 21:32:08 +0000 (14:32 -0700)]
diag/geodsp: zero-fill sectors in -1 mode

In -1 mode, zero-fill the sector instead of writing whatever garbage
was in the buffer already.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agodiag/geodsp: fix ordering of args to fread/fwrite in mk-lba-img
H. Peter Anvin [Mon, 25 Apr 2011 21:27:28 +0000 (14:27 -0700)]
diag/geodsp: fix ordering of args to fread/fwrite in mk-lba-img

If we want the return value to be in bytes, make sure we pass the byte
count in the nmemb field instead of the size field.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agodiag/geodsp: Avoid large intermediate files
H. Peter Anvin [Mon, 25 Apr 2011 19:39:08 +0000 (12:39 -0700)]
diag/geodsp: Avoid large intermediate files

Allow the generation program mk-lba-img to merge the prefix file and
output to stdout, so it can be fed directly to the compressor; that
way we avoid generating huge intermediate files on disk.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agoppmtolss16: remove obsolete Perl construct
H. Peter Anvin [Mon, 25 Apr 2011 19:22:21 +0000 (12:22 -0700)]
ppmtolss16: remove obsolete Perl construct

defined() on an array is considered obsolete; instead check for a
nonzero number of elements with scalar().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agogfxboot: handle INITRD config line
Steffen Winterfeldt [Tue, 19 Apr 2011 13:27:26 +0000 (15:27 +0200)]
gfxboot: handle INITRD config line

Handle case where there is no initrd= option but a separate initrd config line.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
13 years agoversion: now working on version 4.05
H. Peter Anvin [Fri, 22 Apr 2011 04:32:01 +0000 (21:32 -0700)]
version: now working on version 4.05

4.04 is out, next version will be 4.05 (or later).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agohdt: Final release 0.5.0
Erwan Velu [Thu, 21 Apr 2011 19:47:57 +0000 (21:47 +0200)]
hdt: Final release 0.5.0

Thanks for all who participe in this release.

13 years agohdt: Using dashed instead of . into label name
Erwan Velu [Thu, 21 Apr 2011 19:43:54 +0000 (21:43 +0200)]
hdt: Using dashed instead of . into label name

When generating floppy images some version of mtools (< 4.0.14) are
buggy and generate incorrect labels. So using > 4.0.13 is recommended.

Anyway, let's use _ into the volume name, that cleaner :

We now have
  disk label="HDT_0_5_0_B"
instead of
  disk label="HDT_0~5~0-B"

13 years agohdt: Fixing ACPI display
Erwan Velu [Wed, 20 Apr 2011 19:06:14 +0000 (21:06 +0200)]
hdt: Fixing ACPI display

Some screenshots shows that we have some troubles for aligning items.
This is now fixed.

13 years agohdt: New release beta5
Erwan Velu [Wed, 20 Apr 2011 18:44:29 +0000 (20:44 +0200)]
hdt: New release beta5

13 years agolibupload: Adding tftp.h missing file
Erwan Velu [Wed, 20 Apr 2011 18:21:21 +0000 (20:21 +0200)]
libupload: Adding tftp.h missing file

Oups, this while wasn't commited :/

13 years agohdt: Showing specific message for auto mode
Erwan Velu [Wed, 20 Apr 2011 18:20:22 +0000 (20:20 +0200)]
hdt: Showing specific message for auto mode

That's a nice info to know that some output were generated by the
automatic mode.

13 years agohdt: Removing useless printf in dump mode
Erwan Velu [Wed, 20 Apr 2011 18:14:45 +0000 (20:14 +0200)]
hdt: Removing useless printf in dump mode

This message was clearly boring to read ;o)

13 years agolibupload: Fixing tftp return value
Erwan Velu [Wed, 20 Apr 2011 18:12:24 +0000 (20:12 +0200)]
libupload: Fixing tftp return value

The default return value for the tftp mode.
This made the tftp to return error even if the upload was succesful.

13 years agohdt: New release Beta4
Erwan Velu [Tue, 19 Apr 2011 18:23:20 +0000 (20:23 +0200)]
hdt: New release Beta4

13 years agohdt: Adding dump mode on pre-built images
Erwan Velu [Tue, 19 Apr 2011 18:05:35 +0000 (20:05 +0200)]
hdt: Adding dump mode on pre-built images

As we now have a dump mode, let's add an entry in our menu for that.

13 years agohdt: Preventing dump mode if no PXE config
Erwan Velu [Tue, 19 Apr 2011 18:00:46 +0000 (20:00 +0200)]
hdt: Preventing dump mode if no PXE config

Dump mode can only work if PXE is present.

13 years agoMerge commit 'syslinux-4.04' into dynamic-sector
H. Peter Anvin [Mon, 18 Apr 2011 21:53:45 +0000 (14:53 -0700)]
Merge commit 'syslinux-4.04' into dynamic-sector

13 years agospec: Use BuildRequires, add diag/ subdirectory syslinux-4.04
H. Peter Anvin [Mon, 18 Apr 2011 21:24:17 +0000 (14:24 -0700)]
spec: Use BuildRequires, add diag/ subdirectory

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 years agodiag: Don't remove BTARGET on make clean
H. Peter Anvin [Mon, 18 Apr 2011 21:12:58 +0000 (14:12 -0700)]
diag: Don't remove BTARGET on make clean

"make clean" should not remove BTARGET

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
13 years agoMerge branch 'master' of git://git.kernel.org/pub/scm/boot/syslinux/syslinux
Erwan Velu [Mon, 18 Apr 2011 21:12:22 +0000 (23:12 +0200)]
Merge branch 'master' of git://git./boot/syslinux/syslinux

13 years agoMerge remote-tracking branch 'pcacjr/syslinux-update-for-hpa'
H. Peter Anvin [Mon, 18 Apr 2011 21:11:26 +0000 (14:11 -0700)]
Merge remote-tracking branch 'pcacjr/syslinux-update-for-hpa'

13 years agohdt: Reporting TFTP errors in dump mode
Erwan Velu [Mon, 18 Apr 2011 21:08:21 +0000 (23:08 +0200)]
hdt: Reporting TFTP errors in dump mode

If we get some errors from the tftp, let's report it to the user.
This will make user's life easier to understand why the dumping mode
isn't working.

13 years agolibupload: Implementing error code on tftp
Erwan Velu [Mon, 18 Apr 2011 21:07:39 +0000 (23:07 +0200)]
libupload: Implementing error code on tftp

When using the tftp backend, let's return the errors we got on the
server.

13 years agomenu: allow "menu hiddenkey" to take multiple keys; run unlabel
H. Peter Anvin [Mon, 18 Apr 2011 21:06:54 +0000 (14:06 -0700)]
menu: allow "menu hiddenkey" to take multiple keys; run unlabel

- Allow "menu hiddenkey" to take a comma-separated list of keys.
- Run unlabel() on the commands passed to menu hiddenkey.
  XXX: Consider moving unlabelling to post-menu instead.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
13 years agohdt: Fixing automatic mode parsing
Erwan Velu [Mon, 18 Apr 2011 20:37:15 +0000 (22:37 +0200)]
hdt: Fixing automatic mode parsing

Parsing of the auto='' mode was weak an non functionnal in many
configuration like

auto='dump'

This is now fixed.

13 years agoNEWS: Document MENU HIDDENKEY
H. Peter Anvin [Mon, 18 Apr 2011 20:53:19 +0000 (13:53 -0700)]
NEWS: Document MENU HIDDENKEY

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
13 years agolibupload: Fixing memset call
Erwan Velu [Mon, 18 Apr 2011 19:07:33 +0000 (21:07 +0200)]
libupload: Fixing memset call

We have to use the size of the element, not the size of the pointer.

13 years agohdt: New release 0.5.0-beta3
Erwan Velu [Sun, 17 Apr 2011 17:44:21 +0000 (19:44 +0200)]
hdt: New release 0.5.0-beta3

13 years agocpuid: Using generic model if cyrix id is unknown
Erwan Velu [Sat, 16 Apr 2011 18:34:40 +0000 (20:34 +0200)]
cpuid: Using generic model if cyrix id is unknown

When using the specific Cyrix call to determine the model, if the model
is unknown, let's consider the generic call was right.

This insure a better display of the model id.

13 years agoldlinux: Pass entire cmdline to execute()
Matt Fleming [Fri, 8 Apr 2011 12:15:43 +0000 (13:15 +0100)]
ldlinux: Pass entire cmdline to execute()

We need to pass the entire cmdline to execute(), not just the kernel
name. execute() does all the required processing of cmdline arguments
and passes them to the loader in the correct format, e.g. for COM32
modules the cmdline arguments need to be passed in the traditional
char *argv[] way.

So stop using strtok() which modifies its first argument and means we
therefore lose the cmdline after the kernel name.

Previously, the "argc" and "argv" arguments that are passed to a
module's main() function contained bogus values.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux: Move cmdline processing out of cli.c
Matt Fleming [Wed, 6 Apr 2011 13:37:43 +0000 (14:37 +0100)]
ldlinux: Move cmdline processing out of cli.c

While it makes perfect sense for cli.c to read input from the user and
parse certain characters (Ctrl-R, TABs, etc), once that processing is
done it should be up to the caller to decide what to do with the
expanded cmdline string. For example, the logic to figure out what
type of kernel we're loading (calculated from a kernel's filename
extension as typed on the command-line) is currently in cli.c, and
that is just wrong. That kind of logic belongs in ldlinux.c

So move process_command() from cli.c to ldlinux.c and extend it so
that if the user types a label name at the prompt, we load the kernel
for that label as described in the config file.

Now that we've moved all cli history code into edit_cmdline() it seems
like a good time to turn it on permanently.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
13 years agoldlinux, cli: Do not assign 'comm_counter' unnecessarily
Matt Fleming [Wed, 6 Apr 2011 11:59:29 +0000 (12:59 +0100)]
ldlinux, cli: Do not assign 'comm_counter' unnecessarily

There's no need to assign a value to 'comm_counter' at the start of
the edit_cmdline() because it is always assigned before being used.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>