core: dynamically size the heap

Dynamically size the heap to 1/16 of available high memory.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core, diskio: allocate the disk cache from the heap

Since network buffers are allocated from the heap, and the heap is now
dynamically sized, it makes sense we allocate the disk cache here,
too.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core: remove the .hugebss section

There are no more users of the .hugebss section, so remove it from
existence.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Merge remote-tracking branch 'origin/master' into lwip

Resolved Conflicts:
	com32/include/netinet/in.h

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
pxe: remove non-lwIP definition of DNS_MAX_SERVERS

There is only need for one definition of DNS_MAX_SERVERS, and it needs
to be the one in lwIP, so use it everywhere.

Furthermore, there is no longer any need for us to define
DNS_MAX_PACKET.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Merge remote-tracking branch 'origin/master' into lwip

Resolved Conflicts:
	NEWS

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Generalize ipappend handling as "sysappend", and move to PM code

Generalize the ipappend handling to cover all the derivatives, and
rename it "sysappend" ("ipappend" is a valid alias for all
derivatives.)  Move all the string handling to protected mode.
Currently only pxelinux exports strings, but the plan is to change
that in the future.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
pxe, http: send the sysappend/ipappend strings as cookies

When using http, send the sysappend/ipappend strings as cookies
prefixed with _Syslinux_ ... the implementation of this may change.
This is using the "old" cookie format for compactness (single header,
for all cookies, and no $Version tag.)  PHP at least seems perfectly
happy to deal with it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Merge remote-tracking branch 'origin/master' into lwip
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
Merge branch 'for-hpa/elflink/ldlinux' into elflink
Merge branch 'for-hpa/elflink/core' into elflink
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>
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>
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>
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>
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>
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>
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>
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>