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

97 Commits

Author SHA1 Message Date
Michael Brown 7bebe9579e [cmdline] Match user expectations for &&, ||, goto, and exit
The && and || operators should be left-associative, since that is how
they are treated in most other languages (including C and Unix
shell).  For example, in the command:

  dhcp net0 && goto dhcp_ok || echo No DHCP on net0

if the "dhcp net0" fails then the "echo" should be executed.

After an "exit" or a successful "goto", further commands on the same
line should never be executed.  For example:

  goto somewhere && echo This should never be printed
  exit 0 && echo This should never be printed
  exit 1 && echo This should never be printed

An "exit" should cause the current shell or script to terminate and
return the specified exit status to its caller.  For example:

  chain test.ipxe && echo Success || echo Failure
    [in test.ipxe]
    #!ipxe
    exit 0

should echo "Success".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-29 14:19:59 +00:00
Michael Brown 84aa702ff8 [script] Allow "exit" to exit a script
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-22 20:29:01 +00:00
Michael Brown 6d68ffee39 [script] Implement "goto" in iPXE scripts
Allow script labels to be defined using the syntax

  :<labelname>

(nothing else allowed on the line, including whitespace).  Labels are
ignored during script execution, but can be used as the target of the
"goto" command.  For example:

  #!ipxe

  goto machine_${net0/ip} || goto machine_default

  # Linux kernel boot
  :machine_10.0.0.101
  :machine_10.0.0.102
  set filename http://my.boot.server/vmlinuz
  goto done

  # Default configuration
  :machine_default
  set filename pxelinux.0
  goto done

  # Boot selected configuration
  :done
  chain ${filename}

Originally-implemented-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Originally-implemented-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-22 04:27:26 +00:00
Piotr Jaroszyński 5bbad9c8f0 [ioapi] Move get_memmap() to the I/O API group
pcbios specific get_memmap() is used by the b44 driver making
all-drivers builds fail on other platforms.  Move it to the I/O API
group and provide a dummy implementation on EFI.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-08-16 16:54:03 +01:00
Joshua Oreman 719ba316df [refcnt] Add ref_no_free handler
Since more reference-counted structures than embedded images might
want to mark themselves unfreeable, expose a dummy ref_no_free().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-06-23 00:34:48 +01:00
Michael Brown 4bfd5b52c1 [refcnt] Add ref_init() wrapper function
Standardise on using ref_init() to initialise an embedded reference
count, to match the coding style used by other embedded objects.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-06-22 14:26:40 +01:00
Geoff Lywood 62149deb11 [efi] Add the "snpnet" driver
Add a new network driver that consumes the EFI Simple Network
Protocol.  Also add a bus driver that can find the Simple Network
Protocol that iPXE was loaded from; the resulting behavior is similar
to the "undionly" driver for BIOS systems.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-06-02 15:15:29 +01:00
Michael Brown 6c0e8c14be [libc] Enable automated extraction of error usage reports
Add preprocessor magic to the error definitions to enable every error
usage to be tracked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-05-31 03:11:57 +01:00
Michael Brown 13dfe2cf51 [script] Accept "#!gpxe" as well as "#!ipxe" as a script magic marker
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-05-22 00:27:10 +01:00
Michael Brown 8406115834 [build] Rename gPXE to iPXE
Access to the gpxe.org and etherboot.org domains and associated
resources has been revoked by the registrant of the domain.  Work
around this problem by renaming project from gPXE to iPXE, and
updating URLs to match.

Also update README, LOG and COPYRIGHTS to remove obsolete information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19 23:43:39 +01:00
Michael Brown 4c5f00f879 [script] Allow for DOS-style line endings in scripts
Windows text editors such as Notepad tend to use CRLF line endings,
which breaks gPXE's signature detection for script images.  Since
scripts are usually very small, they end up falling back to being
detected as valid PXE executable images (since there are no signature
checks for PXE executables).  Executing text files as x86 machine code
tends not to work well.

Fix by allowing for any isspace() character to terminate the "#!gpxe"
signature, and by ensuring that CR characters get stripped during
command line parsing.

Suggested-by: Shao Miller <Shao.Miller@yrdsb.edu.on.ca>
2009-06-03 10:13:29 +01:00
Michael Brown c44a193d0d [legal] Add a selection of FILE_LICENCE declarations
Add FILE_LICENCE declarations to almost all files that make up the
various standard builds of gPXE.
2009-05-18 08:33:25 +01:00
Michael Brown 4b8e021161 [elf] Work around entry point bug in NetBSD kernels
NetBSD kernels are multiboot ELF kernels with an entry point
incorrectly specified as a virtual address rather than a physical
address.

Work around this by looking for the segment that could plausibly
contain the entry point address (interpreted as either a physical or
virtual address), and using that to determine the eventual physical
entry point.

In the event of any ambiguity, precedence is given to interpretation
of the entry point as a physical address.
2009-04-24 03:42:34 +01:00
Michael Brown f7d2168c8e [segment] Add "Requested memory not available" error message
prep_segment() can sometimes fail because an image requests memory
that is already in use by gPXE.  This will happen if
e.g. undionly.kpxe is used to boot memtest86; the memtest86 image is
an old-format kernel that needs to be loaded at 9000:0000, but this
area of memory may well already be in use by the underlying PXE stack.

Add a human-friendly error message, so that the cause is more
immediately visible.
2009-03-31 04:38:48 +01:00
Michael Brown 4f3bab1a55 [image] Allow for zero embedded images
Having a default script containing

  #!gpxe
  autoboot

can cause problems when entering commands to load and start a kernel
manually; the default script image will still be present when the
kernel is started and so will be treated as an initrd.  It is possible
to work around this by typing "imgfree" before any other commands, but
this is counter-intuitive.

Fix by allowing the embedded image list to be empty (in which case we
just call autoboot()), and making this the default.

Reported by alkisg@gmail.com.
2009-02-24 05:57:56 +00:00
Michael Brown 8904cd55f1 [comboot] Allow for tail recursion of COMBOOT images
Multi-level menus via COMBOOT rely on the COMBOOT program being able
to exit and invoke a new COMBOOT program (the next menu).  This works,
but rapidly (within about five iterations) runs out of space in gPXE's
internal stack, since each new image is executed in a new function
context.

Fix by allowing tail recursion between images; an image can now
specify a replacement image for itself, and image_exec() will perform
the necessary tail recursion.
2009-02-17 00:47:35 +00:00
Michael Brown 24e948f030 [image] Avoid claiming zero-length images as valid
Both the script and PXE images types will claim a zero-length image.
Inhibit this to avoid end-user surprises.
2009-02-16 00:30:48 +00:00
Michael Brown 076154a1c6 [image] Allow multiple embedded images
This patch extends the embedded image feature to allow multiple
embedded images instead of just one.

gPXE now always boots the first embedded image on startup instead of
doing the hardcoded DHCP boot (aka autoboot).

Based heavily upon a patch by Stefan Hajnoczi <stefanha@gmail.com>.
2009-02-16 00:30:36 +00:00
Michael Brown c9e5b12473 [i386] Add explicit flags and type on all .section declarations
Try to avoid future problems caused by implicit section flags and/or
type information by instituting a policy that all .section
declarations must explicitly state the flags and type.

Most of this change was achieved using

    perl -pi \
      -e 's/".text"$/".text", "ax", \@progbits/ ; ' \
      -e 's/".text16"$/".text16", "ax", \@progbits/ ; ' \
      -e 's/".text16.null"$/".text16.null", "ax", \@progbits/ ; ' \
      -e 's/".text16.data"$/".text16.data", "aw", \@progbits/ ; ' \
      -e 's/".data"$/".data", "aw", \@progbits/ ; ' \
      -e 's/".data16"$/".data16", "aw", \@progbits/ ; ' \
      -e 's/".bss"$/".bss", "aw", \@nobits/ ; ' \
      -e 's/".bss16"$/".bss16", "aw", \@nobits/ ; ' \
      -e 's/".prefix"$/".prefix", "ax", \@progbits/ ; ' \
      -e 's/".prefix.lib"$/".prefix.lib", "awx", \@progbits/ ; ' \
      -e 's/".prefix.data"$/".prefix.data", "aw", \@progbits/ ; ' \
      -e 's/".weak"$/".weak", "a", \@nobits/ ; ' \
      `git grep -l '\.section'`
2009-02-15 10:59:53 +00:00
Michael Brown 3f85626fa9 [efi] Add efi_strerror()
EFI_STATUS is defined as an INTN, which maps to UINT32 (i.e. unsigned
int) on i386 and UINT64 (i.e. unsigned long) on x86_64.  This would
require a cast each time the error status is printed.

Add efi_strerror() to avoid this ickiness and simultaneously enable
prettier reporting of EFI status codes.
2008-11-19 19:22:49 +00:00
Michael Brown b59e0cc56e [i386] Change [u]int32_t to [unsigned] int, rather than [unsigned] long
This brings us in to line with Linux definitions, and also simplifies
adding x86_64 support since both platforms have 2-byte shorts, 4-byte
ints and 8-byte long longs.
2008-11-19 19:15:44 +00:00
Michael Brown 81d92c6d34 [efi] Add EFI image format and basic runtime environment
We have EFI APIs for CPU I/O, PCI I/O, timers, console I/O, user
access and user memory allocation.

EFI executables are created using the vanilla GNU toolchain, with the
EXE header handcrafted in assembly and relocations generated by a
custom efilink utility.
2008-10-13 10:24:14 +01:00
Michael Brown 18aa0e79d2 [pcbios] Add extra debugging messages relating to the system memory map 2008-09-07 21:38:41 +01:00
Michael Brown dbe9269f3a [bzimage] Kill off the initrd image type
We can just treat all non-kernel images as initrds, which matches our
behaviour for multiboot kernels.  This allows us to eliminate initrd as
an image type, and treat the "initrd" command as just another synonym for
"imgfetch".
2008-07-08 01:30:11 +01:00
Michael Brown 2596a9aa9c [misc] Fix building on OpenBSD
OpenBSD throws compiler warnings that we can't reproduce on Linux, for
some reason.

Original patch from Dewey Hylton <dewey@hyltown.com>.
2008-06-27 22:35:26 +01:00
Michael Brown 0ea821c7b7 [script] Remove arbitrary limit on script line lengths 2008-06-18 00:43:58 +01:00
Michael Brown 77a5cc6b13 [ELF] Add ability to boot ELF images generated by wraplinux and mkelfImage
Delete ELF as a generic image type.  The method for invoking an
ELF-based image (as well as any tables that must be set up to allow it
to boot) will always depend on the specific architecture.  core/elf.c
now only provides the elf_load() function, to avoid duplicating
functionality between ELF-based image types.

Add arch/i386/image/elfboot.c, to handle the generic case of 32-bit
x86 ELF images.  We don't currently set up any multiboot tables, ELF
notes, etc.  This seems to be sufficient for loading kernels generated
using both wraplinux and coreboot's mkelfImage.

Note that while Etherboot 5.4 allowed ELF images to return, we don't.
There is no callback mechanism for the loaded image to shut down gPXE,
which means that we have to shut down before invoking the image.  This
means that we lose device state, protection against being trampled on,
etc.  It is not safe to continue afterwards.
2008-06-09 13:50:00 +01:00
Michael Brown d615b00443 [embed] Add missing register_image() to image/embedded.c
When the embedded image is a script, the unregister_image() performed by
image/script.c corrupts memory, since image/embedded.c omitted the call
to register_image().

This is the first bug fixed using Stefan Hajnoczi's gdb stub for gPXE.
2008-06-04 00:02:23 +01:00
Michael Brown 74fd544101 Added the embedded pxelinux payload patch from hpa. 2008-01-08 15:51:36 +00:00
Michael Brown df868476e7 Various warnings fixups for OpenBSD with gcc-3.3.5. 2007-12-07 00:11:43 +00:00
Michael Brown cfcc41d407 Set current working URI to be that of the executable image when
executing any image, not just a script.  (This will enable pxelinux to
use relative URIs, should it wish to.)
2007-08-07 06:50:12 -07:00
Michael Brown 1ae40765a6 Set current working URI equal to script URI during script execution. 2007-08-02 20:27:19 +01:00
Michael Brown 02de18eb3e Cope with non-newline-terminated scripts.
Print error status using strerror().
2007-08-02 01:12:42 +01:00
Michael Brown b256900d4f Scripts temporarily deregister themselves while executing. This
allows us to avoid execution loops without having to hack around the
image registration order.
2007-06-09 19:00:34 +01:00
Michael Brown 10c9b03cdb Actually, the initrd image should be architecture-independent. 2007-01-14 15:07:11 +00:00
Michael Brown 797edf28b7 Replace image->entry with image->priv. 2007-01-14 04:04:28 +00:00
Michael Brown a6afbe762c Make DEBUG=script echo the commands as they are executed 2007-01-12 10:06:59 +00:00
Michael Brown 67aedf34fa Use systematic names for XXX_IMAGE.
Add scripts as an image format (since it's trivial to do).
2007-01-12 09:00:48 +00:00
Michael Brown 6fdc6c81a6 Force probing of multiboot before ELF. 2007-01-12 08:10:35 +00:00
Michael Brown 1d313234b3 Rename copy_user() to memcpy_user(). Add memmove_user() and
userptr_add().
2007-01-12 03:14:15 +00:00
Michael Brown f59ad50504 Provide registration mechanism for loaded images, so that we can e.g.
refer to them by name from the command line, or build them into a
multiboot module list.

Use setting image->type to disambiguate between "not my image" and "bad
image"; this avoids relying on specific values of the error code.
2007-01-11 23:43:29 +00:00
Michael Brown 7cf4a72389 Add placeholder elf_execute() 2007-01-11 17:44:07 +00:00
Michael Brown 819cd3f41c Limit -ENOEXEC to mean "this is not in my format". 2007-01-11 17:06:25 +00:00
Michael Brown c810baad37 Use generic "struct image" rather than "struct elf". 2007-01-11 16:10:32 +00:00
Michael Brown 230f16538f Create include/gpxe/elf.h for the ELF bits that aren't part of the ELF
standard and so don't belong in include/elf.h
2007-01-11 15:25:07 +00:00
Michael Brown 7ad1c2eaa8 Removed the Etherboot-specific ELF-image code and replaced it with a
generic ELF loader, to be used by the multiboot code.
2007-01-11 14:44:03 +00:00
Michael Brown 3634e705b7 Remove osloader.c and replace with a prep_segment() that uses userptr_t
and get_memmap() in image/segment.c
2007-01-11 14:32:26 +00:00