237 Commits
Author SHA1 Message Date
Michael Brown e103495563 [release] Update version to 0.9.7 for release 2009-03-02 02:23:42 +00:00
Michael Brown 518cd2f192 [release] Remove obsolete VERSION file 2009-03-02 02:19:07 +00:00
Thomas Miletich afe59d4636 [sundance] Add reset completion check
Following the example of the Linux driver, we add a check and delay to
make sure that the NIC has finished resetting before the driver issues
any additional commands.

Signed-off-by: Marty Connor <mdc@etherboot.org>
2009-02-27 13:52:03 -05:00
Michael Brown b9d791f4d1 [infiniband] Kill off obsolete mlx_ipoib directory
This directory contains the old Etherboot implementation of IPoIB boot
from Mellanox, which has long been obsoleted by gPXE's own
implementation.
2009-02-25 05:07:41 +00: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
Shao Miller 43834f5d25 [image] Added "chain" command to fetch, load, and execute image
The "chain" command combines the functions of "imgfetch", "imgload",
and "boot".

    chain http://etherboot.org/gtest/gtest.gpxe

is equivalent to:

    kernel http://etherboot.org/gtest/gtest.gpxe
    boot
2009-02-24 05:28:14 +00:00
Michael Brown 784d3f336e [pxe] Set %ax to zero on entry to PXE NBP
This is not strictly an entry requirement, but it does mean that a PXE
NBP returning without setting %ax will appear to have returned
success.
2009-02-23 08:43:27 +00:00
H. Peter Anvin 6a3f5d6db7 [pxeprefix] Search for the PXE entry points through all methods
Search for the PXE entry points (via the !PXE or PXENV+ structures)
through all known combinations of search methods.  Furthermore, if we
find a PXENV+ structure, attempt to use it to find the !PXE structure
if at all possible.
2009-02-23 02:53:38 +00:00
Michael Brown 4dd746a725 [iscsi] Include credentials in iBFT only if used during iSCSI login
Avoid passing credentials in the iBFT that were available but not
required for login.  This works around a problem in the Microsoft
iSCSI initiator, which will refuse to initiate sessions if the CHAP
password is fewer than 12 characters, even if the target ends up not
asking for CHAP authentication.
2009-02-20 21:41:00 +00:00
Michael Brown 78d426d196 [scsi] Fix DBG() message reporting of error number 2009-02-19 10:37:30 +00:00
Michael Brown 9937bf13c9 [crypto] Allow creation of arbitrary CBC cipher algorithms using CBC_CIPHER()
Given any block cipher, a corresponding CBC mode of behaviour for the
cipher can be created using the CBC_CIPHER() macro.
2009-02-19 01:53:25 +00:00
Michael Brown e950dc04ba [crypto] Add our own general-purpose cipher-block chaining routines 2009-02-19 01:23:50 +00:00
Michael Brown b4d3d686cc [crypto] Change cipher_{en,de}crypt() to void functions
It is a programming error, not a runtime error, if we attempt to use
block ciphers with an incorrect blocksize, so use an assert() rather
than an error status return.
2009-02-19 00:06:41 +00:00
Michael Brown a3219b24a8 [crypto] Split crypto_algorithm into {digest,cipher,pubkey}_algorithm
The various types of cryptographic algorithm are fundamentally
different, and it was probably a mistake to try to handle them via a
single common type.

pubkey_algorithm is a placeholder type for now.
2009-02-18 22:17:41 +00:00
Michael Brown 5de8305feb [crypto] Move AES_convert_key() hack into axtls_aes.c
Although the nature of the hack is essentially unchanged, this allows
us to remove the hardcoded assumption in tls.c that the RX cipher is
AES.
2009-02-18 21:33:54 +00:00
Michael Brown 991f907d5b [crypto] Rename aes_algorithm to aes_cbc_algorithm 2009-02-18 21:28:46 +00:00
H. Peter Anvin aaa26f3bd3 [pxe] Initialize EDX on PXE NBP entry and INT 1Ah
The PXE 1.x spec specifies that on NBP entry or on return from INT
1Ah AX=5650h, EDX shall point to the physical address of the PXENV+
structure.  The PXE 2.x spec drops this requirement, simply stating
that EDX is clobbered.  Given the principle "be conservative in what
you send, liberal in what you accept", however, we should implement
this anyway.
2009-02-18 18:13:20 +00:00
Michael Brown b5577553e5 [pxeprefix] Add .kkpxe image type and ability to return via PXE stack
Certain combinations of PXE stack and BIOS result in a broken INT 18
call, which will leave the system displaying a "PRESS ANY KEY TO
REBOOT" message instead of proceeding to the next boot device.  On
these systems, returning via the PXE stack is the only way to continue
to the next boot device.  Returning via the PXE stack works only if we
haven't already blown away the PXE base code in pxeprefix.S.

In most circumstances, we do want to blow away the PXE base code.
Base memory is a limited resource, and it is desirable to reclaim as
much as possible.  When we perform an iSCSI boot, we need to place the
iBFT above the 512kB mark, because otherwise it may not be detected by
the loaded OS; this may not be possible if the PXE base code is still
occupying that memory.

Introduce a new prefix type .kkpxe which will preserve both the PXE
base code and the UNDI driver (as compared to .kpxe, which preserves
the UNDI driver but uninstalls the PXE base code).  This prefix type
can be used on systems that are known to experience the specific
problem of INT 18 being broken, or in builds (such as gpxelinux.0) for
which it is particularly important to know that returning to the BIOS
will work.

Written by H. Peter Anvin <hpa@zytor.com> and Stefan Hajnoczi
<stefanha@gmail.com>, minor structural alterations by Michael Brown
<mcb30@etherboot.org>.
2009-02-18 18:12:32 +00:00
Michael Brown dd44a7c314 [i386] Kill off obsolete boot1a.s file 2009-02-18 04:48:30 +00:00
Michael Brown 7b1a5a7997 [dhcp] Use a default user-class of "gPXE"
This change makes it possible to break the PXE-chaining infinite loop
even when restricted to a Windows DHCP server.
2009-02-17 22:03:28 +00:00
Michael Brown 3206e470d0 [image] Redact password from URIs displayed by imgfetch() 2009-02-17 12:10:35 +00:00
Michael Brown 6de4db5da0 [login] Add "login" command and UI 2009-02-17 12:02:16 +00:00
Michael Brown bea828b9ed [settings] Allow store_setting() to access the root settings block 2009-02-17 11:57:31 +00:00
Michael Brown 54840039f6 [http] Send authentication information whenever username is present
Send authentication information if the username is present, even if
the password is empty.
2009-02-17 11:56:27 +00:00
Michael Brown 67ee41ad6d [editbox] Allow for password widgets that do not display their contents 2009-02-17 11:55:55 +00:00
Michael Brown cff419148c [pxe] Allow Escape to abort PXE menu selections
Other vendor PXE stacks tend to allow the Escape key to be used to
abort menu selection.  Allow Escape (as well as Ctrl-C) to abort
selection.
2009-02-17 07:35:57 +00:00
Michael Brown 06b5132fdc [icmp] Add support for responding to pings 2009-02-17 06:59:15 +00:00
Daniel Verkamp dbbd81c140 [comboot] Implement INT 22h AX=001Bh (Cleanup, shuffle, and boot to real mode) 2009-02-17 03:52:44 +00:00
Michael Brown 5026a35fef [comboot] Restore the real-mode stack pointer on exit from a COMBOOT image
COMBOOT images use INTs to issue API calls; these end up making calls
into gPXE from real mode, and so temporarily change the real-mode
stack pointer.  When our COMBOOT code uses a longjmp() to implement
the various "exit COMBOOT image" API calls, this leaves the real-mode
stack pointer stuck with its temporary value, which causes problems if
we eventually try to exit out of gPXE back to the BIOS.

Fix by adding rmsetjmp() and rmlongjmp() calls (analogous to
sigsetjmp()/siglongjmp()); these save and restore the additional state
needed for real-mode calls to function correctly.
2009-02-17 03:38:40 +00:00
Michael Brown 7f903f03af [comboot] Unhook interrupt vectors after returning from a COMBOOT image 2009-02-17 02:03:16 +00:00
Michael Brown 14eafc5b8d [comboot] Fix reference counting on replacement images
When chaining COMBOOT images, the old images now get freed correctly.
2009-02-17 01:45:12 +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 349868b8fd [uri] Allow use of relative URIs when calling churi() 2009-02-16 04:56:55 +00:00
Michael Brown 7bc4093e1a [build] Cope with oddities in the Fedora 10 assembler
The version of the GNU assembler shipped with Fedora 10
(2.18.50.0.9-8.fc10) complains about character literals in some of our
assembly code.  Changing $'x' to $( 'x' ) seems to fix the problem.
Yes, the whitespace is required; using just $('x') does not work.

Reported by Kevin O'Connor <kevin@koconnor.net>.
2009-02-16 03:53:25 +00:00
Michael Brown b08e255ef1 [build] Fix building on gcc 3
GCC did not support #pragma GCC visibility until version 4.0.
2009-02-16 02:15:17 +00:00
Michael Brown 78a57a6f76 [build] Allow NO_WERROR=1 to inhibit --fatal-warnings as well as -Werror 2009-02-16 01:06:40 +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 f16668dd60 [romprefix] Update ROM checksum even if PMM allocation fails
There are code paths other than PMM allocation that can result in our
changing the ROM checksum.  For example, we attempt to update our
product string to incorporate the PCI bus:dev.fn number.  In a system
that does not support PMM, we could therefore end up with an incorrect
checksum.

Fix by attempting to update the checksum unconditionally.
2009-02-15 11:44:21 +00:00
Michael Brown 79867d34ee [build] Treat warnings as errors in assembly files
Add --fatal-warnings to ASFLAGS; this is the equivalent of -Werror in
CFLAGS (which we have used since July 2007).
2009-02-15 11:05:00 +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 ce2aa66d39 [i386] Add explicit ""aw", @nobits" declarations to stack sections
As reported by Stefan, commit 13d09e6 ("[i386] Simplify linker script
and standardise linker-defined symbol names") breaks gdb, readelf and
associated utilities.

This is caused by the .stack section overwriting a block in the middle
of the .debug_info section (despite being included in the
.bss.textdata section in the output file, which apparently has the
correct attributes for a .bss section).

Fixed by adding explicit flags and type to the stack section
declaration.
2009-02-15 10:02:26 +00:00
Michael Brown 8ae1cac050 [xfer] Make consistent assumptions that xfer metadata can never be NULL
The documentation in xfer.h and xfer.c does not say that the metadata
parameter is optional in calls such as xfer_deliver_iob_meta() and the
deliver_iob() method.  However, some code in net/ is prepared to
accept a NULL pointer, and xfer_deliver_as_iob() passes a NULL pointer
directly to the deliver_iob() method.

Fix this mess of conflicting assumptions by making everything assume
that the metadata parameter is mandatory, and fixing
xfer_deliver_as_iob() to pass in a dummy metadata structure (as is
already done in xfer_deliver_iob()).
2009-02-15 08:44:22 +00:00
Michael Brown 46da51703a [umalloc] Avoid problems when _textdata_memsz is a multiple of 4kB
If it happens that _textdata_memsz ends up being an exact multiple of
4kB, then this will cause the .textdata section (after relocation) to
start on a page boundary.  This means that the hidden memory region
(which is rounded down to the nearest page boundary) will start
exactly at virtual address 0, i.e. UNULL.  This means that
init_eheap() will erroneously assume that it has failed to allocate a
an external heap, since it typically ends up choosing the area that
lies immediately below .textdata, which in this case will be the
region with top==UNULL.

A subsequent error is that memtop_urealloc() passes through the error
return status -ENOMEM to the caller, which (rightly) assumes that the
result represents a valid userptr_t address.

Fixed by using alternative tests for heap non-existence, and by
returning UNULL in case of an error from init_eheap().
2009-02-15 07:56:16 +00:00
Michael Brown 816a32aaee [http] Allow for URI encodings within username and password 2009-02-13 16:26:43 +00:00
Michael Brown ef70f87997 [http] Add support for HTTP Basic authentication 2009-02-13 15:43:17 +00:00
Michael Brown d900ae05d7 [base64] Add base64 encoding functions 2009-02-13 14:54:13 +00:00
Michael Brown 4e6b62c946 [settings] Handle errors in fetchf_uristring()
fetchf_uristring() was failing to handle error values from
fetch_setting(), resulting in its attempting to allocate extremely
large temporary buffers on the stack (and so overrunning the stack and
locking up the machine).

Problem reported by Shao Miller <Shao.Miller@yrdsb.edu.on.ca>.
2009-02-12 09:16:53 +00:00
Michael Brown 8e960eb67c [tls] Use our own ASN.1 routines for certificate parsing
Use our own, more robust, ASN.1 parsing routines to extract the RSA
public key from a server certificate.  Remove the now-unused AXTLS
ASN.1 parser.
2009-02-10 18:30:17 +00:00
Michael Brown 5a99c586cf [crypto] Remove unused files 2009-02-10 15:47:44 +00:00
Itay Gazit 750c19466a [mtnic] Add multiport support and some minor fixes
Signed-off-by: Michael Brown <mcb30@etherboot.org>
2009-02-09 12:43:44 +00:00
Thomas Miletich e9c10ca158 [sundance] Added NIC variant
This previously unsupported NIC variant was was found to work using
the current driver:

     PCI_ROM(0x13f0, 0x0200, "ip100a", "IC+ IP100A"),

Signed-off-by: Marty Connor <mdc@etherboot.org>
2009-02-06 08:41:02 -05:00
Michael Brown 56066a6085 [pxe] Display the "Press F8" prompt rather than displaying menu with timeout
The PXE spec dictates the rather ugly feature that we have to present
a DHCP-specified prompt string to the user, then wait to see if they
press F8 before displaying the menu.

This seems to me to be a significant retrograde step from the current
situation of displaying the menu with the timeout counting down
against the default selected boot option, but apparently the lack of
the "Press F8" prompt causes some confusion.
2009-02-05 19:29:16 +00:00
Michael Brown 881f1f59ef [pxe] Obey lists of PXE Boot Servers and associated Discovery Control bits
Various combinations of options 43.6, 43.7 and 43.8 dictate which
servers we send Boot Server Discovery requests to, and which servers
we should accept responses from.  Obey these options, and remove the
explicit specification of a single Boot Server from start_pxebs() and
dependent functions.
2009-02-05 09:34:32 +00:00
Michael Brown ff2b308506 [pxe] Skip PXE boot server discovery if directed to do so
Option 43.6 can direct us to skip PXE boot server discovery and just
perform a standard DHCP filename boot.
2009-02-05 09:34:05 +00:00
Michael Brown 4b276b8df9 [pxe] Fall back to broadcast if no boot server multicast address exists
fetch_ipv4_setting() will zero its IPv4 address argument if no such
setting exists, rather than leaving it untouched.
2009-02-03 02:44:15 +00:00
Michael Brown dbe84c5aad [iobuf] Add iob_disown() and use it where it simplifies code
There are many functions that take ownership of the I/O buffer they
are passed as a parameter.  The caller should not retain a pointer to
the I/O buffer.  Use iob_disown() to automatically nullify the
caller's pointer, e.g.:

    xfer_deliver_iob ( xfer, iob_disown ( iobuf ) );

This will ensure that iobuf is set to NULL for any code after the call
to xfer_deliver_iob().

iob_disown() is currently used only in places where it simplifies the
code, by avoiding an extra line explicitly setting the I/O buffer
pointer to NULL.  It should ideally be used with each call to any
function that takes ownership of an I/O buffer.  (The SSA
optimisations will ensure that use of iob_disown() gets optimised away
in cases where the caller makes no further use of the I/O buffer
pointer anyway.)

If gcc ever introduces an __attribute__((free)), indicating that use
of a function argument after a function call should generate a
warning, then we should use this to identify all applicable function
call sites, and add iob_disown() as necessary.
2009-02-01 20:16:10 +00:00
Michael Brown 0171098212 [contrib] Update qemu documentation 2009-02-01 20:16:10 +00:00
Michael Brown 4502c04360 [dhcp] Send user class in DHCP requests 2009-02-01 20:06:09 +00:00
Michael Brown 6711ce18a7 [tftp] Guard against invalid data block numbers
A TFTP DATA packet with a block number of zero (representing a
negative offset within the file) could potentially cause problems.
Fixed by explicitly rejecting such packets.

Identified by Stefan Hajnoczi <stefanha@gmail.com>.
2009-02-01 13:07:17 +00:00
Michael Brown e65afc4b10 [dhcp] Split PXE menuing code out of dhcp.c
The DHCP client code now implements only the mechanism of the DHCP and
PXE Boot Server protocols.  Boot Server Discovery can be initiated
manually using the "pxebs" command.  The menuing code is separated out
into a user-level function on a par with boot_root_path(), and is
entered in preference to a normal filename boot if the DHCP vendor
class is "PXEClient" and the PXE boot menu option exists.
2009-02-01 01:21:40 +00:00
Michael Brown d2b0081740 [settings] Avoid duplicate settings block names
Automatically unregister any settings with the same name (and position
within the settings tree) as a newly registered settings block.

This functionality is generalised out from dhcp.c.
2009-01-31 07:32:20 +00:00
Michael Brown b111bdfb00 [scsi] Cope with targets that send multiple CHECK CONDITIONS at power-on
Some targets send a spurious CHECK CONDITION message in response to
the first SCSI command.  We issue (and ignore the status of) an
arbitary harmless SCSI command (a READ CAPACITY (10)) in order to draw
out this response.

The Solaris Comstar target seems to send more than one spurious CHECK
CONDITION response.  Attempt up to SCSI_MAX_DUMMY_READ_CAP dummy READ
CAPACITY (10) commands before assuming that error responses are
meaningful.

Problem reported by Kristof Van Doorsselaere <kvandoor@aserver.com>
and Shiva Shankar <802.11e@gmail.com>.
2009-01-30 13:32:53 +00:00
Michael Brown 52c596bafb [ui] Allow Ctrl-C to cancel wait for net device link-up
This really ought to be handled via monojob.c and the usual Ctrl-C
mechanism that handles cancelling DHCP or file downloads.
2009-01-27 20:09:50 +00:00
Stefan Hajnoczi d10a7e7739 [dns] Append local domain to relative names
Try to qualify relative names in the DNS resolver using the DHCP Domain
Name.  For example:

  DHCP Domain Name: etherboot.org
  (Relative) Name: www

yields:

  www.etherboot.org

Only names with no dots ('.') will be modified.  A name with one or more
dots is unchanged.
2009-01-27 19:26:12 +00:00
Michael Brown a128973ecb [settings] Add fetch_string_setting_copy() 2009-01-27 19:13:47 +00:00
Michael Brown 1284773363 [tftp] Temporary fix for conveying TFTP block size to callers
pxe_tftp.c assumes that the first seek on its data-transfer interface
represents the block size.  Apart from being an ugly hack, this will
also screw up file size calculation for files smaller than one block.

The proper solution would be to extend the data-transfer interface to
support the reporting of stat()-like data.  This is not going to
happen until the cost of adding interface methods is reduced (a fix I
have planned since June 2008).

In the meantime, abuse the xfer_window() method to return the block
size, since it is not being used for anything else and is vaguely
justifiable.

Astonishingly, having returned the incorrect TFTP blocksize via
PXENV_TFTP_OPEN for almost a year seems not to have affected any of
the test cases run during that time; this bug was found only when
someone tried running the heavily-patched version of pxegrub found in
OpenSolaris.
2009-01-27 15:47:00 +00:00
Michael Brown 027c72e0d0 [dhcp] Include support for PXE boot menus
PXE dictates a mechanism for boot menuing, involving prompting the
user with a variable message, waiting for a predefined keypress,
displaying a boot menu, and waiting for a selection.

This breaks the currently desirable abstraction that DHCP is a process
that can happen in the background without any user interaction.
2009-01-25 21:16:47 +00:00
Michael Brown f1d17ae2be [bios] Add F8 function key as a recognised BIOS keycode 2009-01-25 21:12:48 +00:00
Michael Brown ce9690ca39 [console] Allow KEY_xxx constants to cover F8 function key
F8 is represented by the ANSI escape sequence "^[[19~", which is not
representable as a KEY_xxx constant using the current encoding scheme.
Adapt the encoding scheme to allow F8 to be represented, since PXE
requires that we may need to prompt the user to press F8.
2009-01-25 21:10:48 +00:00
Michael Brown 3f814f08e5 [dhcp] Clarify language surrounding ProxyDHCP
Remove the lazy assumption that ProxyDHCP == "DHCP with option 60 set
to PXEClient", and explicitly separate the notion of ProxyDHCP from
the notion of packets containing PXE options.
2009-01-23 01:47:33 +00:00
Michael Brown 773d9631ef [dhcp] Handle missing ProxyDHCP servers
It is possible to configure a DHCP server to hand out PXE options
without a ProxyDHCP server present.  This requires setting option 60
to "PXEClient", which will cause gPXE to attempt ProxyDHCP.

We assume in several places that dhcp->proxydhcpack is set to the
DHCPACK packet containing option 60 set to "PXEClient".  When we
transition into ProxyDHCPREQUEST, set dhcp->proxydhcpack=dhcp->dhcpack
so that this assumption holds true.

We ought to rename several references to "proxydhcp" to something more
accurate, such as "pxedhcp".  Treating a single DHCP response as
potentially both DHCPOFFER and ProxyDHCPOFFER does make the code
smaller, but the variable names get confusing.
2009-01-23 01:32:04 +00:00
Michael Brown 76d05a4da0 [dhcp] Pass PXE boot menu item to PXE Boot Server
Pick out the first boot menu item from the boot menu (option 43.9) and
pass it to the boot server as the boot menu item (option 43.71).

Also improve DHCP debug messages to include more details of the
packets being transmitted.
2009-01-23 01:13:50 +00:00
Michael Brown cf53998901 [tcp] Always set PUSH flag on TCP transmissions
Apparently this can cause a major speedup on some iSCSI targets, which
will otherwise wait for a timer to expire before responding.  It
doesn't seem to hurt other simple TCP test cases (e.g. HTTP
downloads).

Problem and solution identified by Shiva Shankar <802.11e@gmail.com>
2009-01-21 04:22:34 +00:00
Michael Brown 6941793416 [dhcp] Add preliminary support for PXE Boot Servers
Some PXE configurations require us to perform a third DHCP transaction
(in addition to the real DHCP transaction and the ProxyDHCP
transaction) in order to retrieve information from a "Boot Server".

This is an experimental implementation, since the actual behaviour is
not well specified in the PXE spec.
2009-01-21 03:43:26 +00:00
Michael Brown d230b53df2 [tcpip] Allow for transmission to multicast IPv4 addresses
When sending to a multicast address, it may be necessary to specify
the source address explicitly, since the multicast destination address
does not provide enough information to deduce the source address via
the miniroute table.

Allow the source address specified via the data-xfer metadata to be
passed down through the TCP/IP stack to the IPv4 layer, which can use
it as a default source address.
2009-01-21 03:40:39 +00:00
Michael Brown b4a95a8974 [ethernet] Fix eth_mc_hash() return status
eth_mc_hash() was missing a return within a switch statement, and so
always falling through to the default case and returning failure.
2009-01-21 03:38:25 +00:00
Michael Brown 7be5fa82e3 [dhcp] Centralise DHCP successful state transitions
Move all the DHCP state transition logic into a single function
dhcp_next_state().  This will make it easier to add support for PXE
Boot Servers, since it abstracts away the difference between "mark
DHCP as complete" and "transition to boot server discovery".
2009-01-21 01:31:52 +00:00
Michael Brown d7de30e5e4 [dhcp] Allow for missing server ID in ProxyDHCPACK
The Linux PXE server (http://www.kano.org.uk/projects/pxe) does not
set the server identifier in its ProxyDHCP responses.  If the server
ID is missing, do not treat this as an error.

This resolves the "vague and unsettling memory" mentioned in commit
fdb8481d ("[dhcp] Verify server identifier on ProxyDHCPACKs").

Note that we already accept ProxyDHCPOFFERs without a server
identifier; they get treated as potential BOOTP packets.
2009-01-21 00:55:42 +00:00
Michael Brown 08f6d22410 [efi] Expose both GUIDs for the EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
At some point, it seems that someone decided to change the GUID for
the EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL.  Current EFI builds
ignore the older GUID, older EFI builds ignore the newer GUID, so we
have to expose both.
2009-01-12 20:53:38 +00:00
Michael Brown aa86afe890 [efi] Add an EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL interface
This allegedly optional interface seems to be compulsory if you want
EFI's PXE code to bother trying to use your network interface.
2009-01-12 19:11:30 +00:00
Michael Brown cced04ef3b [efi] Provide component name protocol and device path protocol interfaces
Include a minimal component name protocol so that the driver name
shows up as something other than "<UNKNOWN>" in the driver list, and a
device path protocol so that the network interface shows up as a
separate device in the device list, rather than being attached
directly to the PCI device.

Incidentally, the EFI component name protocol reaches new depths for
signal-to-noise ratio in program code.  A typical instance within the
EFI development kit will use an additional 300 lines of code to
provide slightly less functionality than GNU gettext achieves with
three additional characters.
2009-01-12 19:10:53 +00:00
Michael Brown 8fd81349b3 [efi] Ensure EFI ROM checksum is zero
The UEFI specification does not mention ROM checksums, and reassigns
the field typically used as a checksum byte.  The UEFI shell
"loadpcirom" utility does not verify ROM checksums, but it seems that
some UEFI BIOSes do.
2009-01-09 20:52:26 +00:00
Michael Brown 48b2f70ee4 [util] Tidy up output of disrom.pl 2009-01-09 19:38:53 +00:00
Michael Brown ba1016f378 [dhcp] Include gPXE version number within DHCP request 2009-01-08 08:39:05 +00:00
Michael Brown 3e220aa73e [main] Print an "initialising devices" banner
Some devices take a very long time to initialise.  This can make it
difficult to visually distinguish between the error cases of failing
to start executing C code and failing to initialise a device.

Add a "gPXE initialising devices..." message.  The trailing ellipsis
indicates to the user that this may take some time, and the presence
of the message indicates to the developer that relocation etc. all
succeeded.
2009-01-08 03:48:30 +00:00
Michael Brown fb72336fe6 [efi] Add efirom utility and .efirom image format 2009-01-08 02:19:18 +00:00
Michael Brown 765efac771 [efi] Allow for .efidrv images as well as .efi images
Merge in the changes that allow for building EFI driver images (that
can be loaded using the EFI shell's "load" command) as well as EFI
applications.
2009-01-07 23:43:26 +00:00
Michael Brown 314779eb36 [efi] Use elf2efi utility in place of efilink
elf2efi converts a suitable ELF executable (containing relocation
information, and with appropriate virtual addresses) into an EFI
executable.  It is less tightly coupled with the gPXE build process
and, in particular, does not require the use of a hand-crafted PE
image header in efiprefix.S.

elf2efi correctly handles .bss sections, which significantly reduces
the size of the gPXE EFI executable.
2009-01-07 22:59:05 +00:00
Michael Brown 85e5e25c52 [build] Avoid strict-aliasing warnings when building with gcc 4.4
Conventional usage of the various struct sockaddr_xxx types involves
liberal use of casting, which tends to trigger strict-aliasing
warnings from gcc.  Avoid these now and in future by marking all the
relevant types with __attribute__((may_alias)).
2009-01-05 19:20:26 -08:00
Michael Brown 21cfab4fb8 [efi] Inhibit harmless ld warning on unresolved symbol check
The check for unresolved symbols does not explicitly specify an output
architecture format, and so causes a warning when building an i386 EFI
binary on an x86_64 platform.  This warning is harmless, and
specifying the output architecture in multiple places is cumbersome,
so just inhibit the warning.
2009-01-05 12:54:40 -08:00
Michael Brown 53a7dd26cd [infiniband] Call ib_open() only when opening the IPoIB net device
Defer the call to ib_open() until we want to actually open the device,
rather than when the device is registered.
2009-01-02 21:04:31 +00:00
Marty Connor 8674bc05a0 [pcbios] Add additional sanity check for bogus e820 map
At POST time some BIOSes return invalid e820 maps even though
they indicate that the data is valid.  We add a check that the first
region returned by e820 is RAM type and declare the map to be invalid
if it is not.

This extends the sanity checks from 8b20e5d ("[pcbios] Sanity-check
the INT15,e820 and INT15,e801 memory maps").
2008-12-18 17:28:57 +00:00
Michael Brown 57bbf0ec98 [etherfabric] Make use of pci_bar_start() 64-bit clean
Driver was storing the result of pci_bar_start() and pci_bar_size() in
an int, rather than an unsigned long.

(Bug was introduced in the vendor's tree in commit eac85cd "Port
etherfabric driver to net_device api".)
2008-12-12 19:18:04 +00:00
Michael Brown 1941c933f8 [pci] Enable memory cycles in adjust_pci_device()
adjust_pci_device() has historically enabled bus-mastering and I/O
cycles, but has never previously needed to enable memory cycles.  Some
EFI systems seem not to enable memory cycles by default, so add that
to the list of PCI command register bits that we force on.
2008-12-12 19:15:00 +00:00
Marty Connor 1206999288 [e1000] Use PCI_BASE_ADDRESS_* symbols instead of integers
When compiling for the Linux kernel, PCI_BASE_ADDRESS_0 == 0, and
PCI_BASE_ADDRESS_1 == 1.  This is not so when compiling for gPXE.  We
must use the symbolic names rather than integers to get the correct
values.

Bug identified and patch supplied by:

   George Chou <george.chou@advantech.com>
2008-12-05 16:35:33 +00:00
Michael Brown ce0a0ccf5c [x86_64] Add support for compilation as an x86_64 binary
Currently the only supported platform for x86_64 is EFI.

Building an EFI64 gPXE requires a version of gcc that supports
__attribute__((ms_abi)).  This currently means a development build of
gcc; the feature should be present when gcc 4.4 is released.

In the meantime; you can grab a suitable gcc tree from

  git://git.etherboot.org/scm/people/mcb30/gcc/.git
2008-12-05 00:06:27 +00:00
Michael Brown b0d2c9a4d5 [hermon] Fix permissions broken in 3a799e9 ("Add PCI ID for ConnectX QDR card")
The patch file supplied for commit 3a799e9 ("[hermon] Add PCI ID for
ConnectX QDR card") accidentally marked drivers/infiniband/hermon.c as
being executable.
2008-12-04 23:27:21 +00:00
Michael Brown 29480dd715 [efi] Use EFI-native mechanism for accessing SMBIOS table
EFI provides a copy of the SMBIOS table accessible via the EFI system
table, which we should use instead of manually scanning through the
F000:0000 segment.
2008-12-04 23:19:12 +00:00
Michael Brown 045a22764a [efi] Allow use of EFI configuration tables
EFI passes in copies of SMBIOS and other system configuration tables
via the EFI system table.  Allow configuration tables to be requested
using a mechanism similar to the current method for requesting EFI
protocols.
2008-12-04 23:18:32 +00:00
Michael Brown 3a799e99ca [hermon] Add PCI ID for ConnectX QDR card
Patch provided by Itay Gazit <itaygazit@gmail.com>.
2008-12-04 20:48:53 +00:00
Michael Brown 4d7c650164 [romprefix] Change from opt-in to opt-out when booting via INT19
On non-BBS systems, we have to hook INT 19 in order to be able to boot
from the gPXE ROM at all.  However, doing this unconditionally will
prevent the user from booting via any other devices.

Previously, the INT 19 entry point would prompt the user to press B in
order to boot from gPXE, which makes it impossible to perform an
unattended network boot.  We now prompt the user to press N to skip
booting from gPXE, which allows for unattended operation.

This should be a better match for most real-world scenarios.  Most
modern systems support BBS and so are unaffected by this change.  Very
old (non-BBS) systems tend not to have PXE ROMs by default anyway; if
the user has added a gPXE ROM then they probably do want to boot from
the network.  Newer non-BBS systems are essentially limited to IBM
servers, which will recapture the INT 19 vector anyway and implement
their own boot-ordering selection mechanism.
2008-12-04 16:46:16 +00:00
Marty Connor 708e6e0613 [release] Update version to 0.9.6+ post release 2008-11-23 17:01:17 -05:00
Marty Connor 74b7bc0954 [release] Update version to 0.9.6 for release 2008-11-23 16:44:45 -05:00
Pantelis Koukousoulas 7166bc7b2d [b44] Add driver for Broadcom bcm44xx cards
This driver is based on Stefan Hajnoczi's summer work, which
is in turn based on version 1.01 of the linux b44 driver.
I just assembled the pieces and fixed/added a few pieces
here and there to make it work for my hardware.

The most major limitation is that this driver won't work
on systems with >1GB RAM due to the card not having enough
address bits for that and gPXE not working around this
limitation.

Still, other than that the driver works well enough for
at least 2 users :) and the above limitation can always
be fixed when somebody wants it bad enough :)

Signed-off-by: Pantelis Koukousoulas <pktoss@gmail.com>
2008-11-21 23:22:50 +00:00
Michael Brown e78bcb6175 [netdevice] Kill off the various guess_boot_netdev() functions
Remove the assortment of miscellaneous hacks to guess the "network
boot device", and replace them each with a call to last_opened_netdev().

It still isn't guaranteed correct, but it won't be any worse than
before, and it will at least be consistent.
2008-11-21 20:34:42 +00:00
Michael Brown 02a0215873 [netdevice] Provide function to retrieve the most recently opened net device
There are currently four places within the codebase that use a
heuristic to guess the "boot network device", with varying degrees of
success.  Add a feature to the net device core to maintain a list of
open network devices, in order of opening, and provide a function
last_opened_netdev() to retrieve the most recently opened net device.
This should do a better job than the current assortment of
guess_boot_netdev() functions.
2008-11-21 20:34:02 +00:00
Michael Brown 8e8a348fd4 [pxe] Select the correct network device on multiport cards
When trying to find the "first open network device", it helps to
actually check the NETDEV_OPEN flag.
2008-11-21 19:45:05 +00:00
Michael Brown 246ddf5ee4 [aoe] Use an AoE config query to identify the target MAC address
The AoE spec does not specify that the source MAC address of a
received packet actually matches the MAC address of the AoE target.
In principle an AoE server can respond to an AoE request on any
interface available to it, which may not be an address configured to
accept AoE requests.

This issue is resolved by implementing AoE device discovery.  The
purpose of AoE discovery is to find out which addresses an AoE target
can use for requests.  An AoE configuration command is sent when the
AoE attach is attempted.  The AoE target must respond to that
configuration query from an interface that can accept requests.

Based on a patch from Ryan Thomas <ryan@coraid.com>
2008-11-19 21:42:33 +00:00
Laurent Vivier a2686a55c4 [blockdev] Move block device operations to structure block_device_operations
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
2008-11-19 20:04:43 +00:00
Laurent Vivier b48f37e69a [virtio] Split virtio-net.c into several files.
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
2008-11-19 19:58:51 +00:00
Laurent Vivier 14a739ba6a [virtio] Consolidate virtio-net static data into a struct vring_virtqueue
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
2008-11-19 19:55:54 +00:00
Laurent Vivier d3d8f20626 [virtio] Remove dependency on nic for virtio PCI functions
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
2008-11-19 19:51:38 +00:00
Laurent Vivier fc49421c7e [virtio] Consolidate vring_get_buf() by using a buffer list to add to the vring
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
2008-11-19 19:50:51 +00:00
Laurent Vivier 5dd5107976 [virtio] Move virtio-pci.h and virtio-ring.h to include/gpxe
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
2008-11-19 19:48:30 +00:00
Michael Brown 0ebbbb95fa [x86_64] Fix assorted 64-bit compilation errors and warnings
Remove various 32-bit assumptions scattered throughout the codebase.
The code is still not necessarily 64-bit clean, but will at least
compile.
2008-11-19 19:33:05 +00:00
Michael Brown 7d36a1b7b0 [build] Explicitly link efilink against -liberty
On some systems, libbfd is supplied only as a static library; linking
will fail unless -liberty is also specified.
2008-11-19 19:24:48 +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 d9b3d09910 [i386] Move iSCSI and AoE boot code to arch/i386/interface/pcbios 2008-11-19 19:20:45 +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 849e4b12d6 [libgcc] Make __libgcc architecture-specific 2008-11-19 19:14:24 +00:00
Michael Brown dc60c24146 [i386] Rename __cdecl to __asmcall
__cdecl is a misleading name, since it currently encapsulates both
cdecl and regparm(0) attributes.  Rename to __asmcall.
2008-11-19 19:12:53 +00:00
Michael Brown 446b6d5fdd [pxe] Move all PXE files to arch/i386
The initial PXE implementation in Etherboot had the goal of being
architecture-agnostic, but this goal has not been realised.
2008-11-18 22:27:02 +00:00
Michael Brown fca2dcabb8 [elf] Kill off unused <bits/elf.h> and <bits/elf_x.h> header files 2008-11-18 22:16:15 +00:00
Michael Brown ab96932ab3 [efi] Update to latest UEFI headers 2008-11-18 21:54:51 +00:00
Michael Brown 0a8a17e669 [i386] Free allocated base memory on exit, if possible
Code paths that automatically allocate memory from the FBMS at 40:13
should also free it, if possible.

Freeing this memory will not be possible if either

  1. The FBMS has been modified since our allocation, or

  2. We have not been able to unhook one or more BIOS interrupt vectors.
2008-11-18 19:43:13 +00:00
Marty Connor 85f82f09e9 [r8169] New rtl8169 family driver
This is a completely rewritten version of the rtl8169 family driver
using the gPXE driver API.
2008-11-18 04:04:07 +00:00
Michael Brown cc93556725 [build] Fix calculation of _filesz
_filesz was incorrectly forced to be aligned up to MAX_ALIGN.  In a
non-compressed build, this would cause a build failure unless _filesz
happened to already be aligned to MAX_ALIGN.
2008-11-17 19:58:02 -08:00
Michael Brown c661945e82 [build] Discard junk sections created by newer gcc versions 2008-11-18 03:46:27 +00:00
Michael Brown 54fbd11221 [build] Keep gcc 4.4 happy
gcc 4.4 adds another few warnings, and also seems to complain if we
place %ebp in the clobber list for any inline asm.
2008-11-18 01:52:40 +00:00
Michael Brown 464bf35cc0 [linda] Add missing copyright notices 2008-11-18 00:14:10 +00:00
Michael Brown 8a80e7ace1 [linda] Purge references to 8051 2008-11-17 23:55:43 +00:00
Michael Brown 1b3edd9e11 [infiniband] Respect hop pointer when building directed route SMP return path
The return path in directed route SMPs lists the egress ports in order
from SM to node, rather than from node to SM.

To write to the correct offset within the return path, we need to
parse the hop pointer.  This is held within the class-specific data
portion of the MAD header, which was previously unused by us and
defined to be a uint16_t.  Define this field to be a union type; this
requires some rearrangement of ib_mad.h and corresponding changes to
ipoib.c.
2008-11-12 15:35:45 +00:00
Michael Brown 2ca2607b1b [romprefix] Use smaller PMM allocations if possible
The only way that PMM allows us to request a block in a region with
A20=0 is to ask for a block with an alignment of 2MB.  Due to the PMM
API design, the only way we can do this is to ask for a block with a
size of 2MB.

Unfortunately, some BIOSes will hit problems if we allocate a 2MB
block.  In particular, it may not be possible to enter the BIOS setup
screen; the BIOS setup code attempts a PMM allocation, fails, and
hangs the machine.

We now try allocating only as much as we need via PMM.  If the
allocated block has A20=1, we free the allocated block, double the
allocation size, and try again.  Repeat until either we obtain a block
with A20=0 or allocation fails.  (This is guaranteed to terminate by
the time we reach an allocation size of 2MB.)
2008-11-11 20:00:13 +00:00
Michael Brown 125c6d66a8 [linda] Add support for QLogic 7220-based Infiniband HCAs
These cards very nearly support our current IB Verbs model.  There is
one minor difference: multicast packets will always be delivered by
the hardware to QP0, so the driver has to redirect them to the
appropriate QP.  This means that QP owners may see receive completions
for buffers that they never posted.  Nothing in our current codebase
will break because of this.
2008-11-11 05:58:47 +00:00
Michael Brown 9e5fd8ec59 [infiniband] Add raw packet parser and constructor
This can be used with cards that require the driver to construct and
parse packet headers manually.  Headers are optionally handled
out-of-line from the packet payload, since some such cards will split
received headers into a separate ring buffer.
2008-11-11 05:31:19 +00:00
Michael Brown c0ec00f47f [infiniband] Add a standalone subnet management agent
This generic SMA code can be used for any cards that do not provide
firmware-based embedded SMAs.
2008-11-11 05:31:18 +00:00
Michael Brown 9a35830d1f [ipoib] Kill off the IPoIB pseudo-header
Some Infiniband cards will not be as accommodating as the Arbel and
Hermon cards in providing enough space for us to push a fake extra
header at the start of the received packet.  We must therefore make do
with squeezing enough information to identify source and destination
addresses into the two bytes of padding within a genuine IPoIB
link-layer header.
2008-11-11 05:31:08 +00:00
Michael Brown 663904a7bc [infiniband] Split subnet management agent client out into ib_smc.c
Not all Infiniband cards have embedded subnet management agents.
Split out the code that communicates with such an embedded SMA into a
separate ib_smc.c file, and have drivers call ib_smc_update()
explicitly when they suspect that the answers given by the embedded
SMA may have changed.
2008-11-11 05:31:07 +00:00
Michael Brown 830e19eb54 [infiniband] Pass address vector in receive completions
Receive completion handlers now get passed an address vector
containing the information extracted from the packet headers
(including the GRH, if present), and only the payload remains in the
I/O buffer.

This breaks the symmetry between transmit and receive completions, so
remove the ib_completer_t type and use an ib_completion_queue_operations
structure instead.

Rename the "destination QPN" and "destination LID" fields in struct
ib_address_vector to reflect its new dual usage.

Since the ib_completion structure now contains only an IB status code,
("syndrome") replace it with a generic gPXE integer status code.
2008-11-11 05:31:07 +00:00
Michael Brown 0de5f7af6d [infiniband] Maintain queue fill level as a property of a work queue
Both queue owners and drivers often need to keep track of the fill
level, so let's make it a generic property.
2008-11-11 05:31:06 +00:00
Michael Brown d9751edafa [infiniband] Flush uncompleted work queue entries at QP teardown
Avoid leaking I/O buffers in ib_destroy_qp() by completing any
outstanding work queue entries with a generic error code.  This
requires the completion handlers to be available to ib_destroy_qp(),
which is done by making them static configuration parameters of the CQ
(set by ib_create_cq()) rather than being provided on each call to
ib_poll_cq().

This mimics the functionality of netdev_{tx,rx}_flush().  The netdev
flush functions would previously have been catching any I/O buffers
leaked by the IPoIB data queue (though not by the IPoIB metadata
queue).
2008-11-11 05:31:06 +00:00
Pantelis Koukousoulas dd34500188 [ne2k_isa] Restore support for ne2k isa cards
Add the simplified ne2k_isa driver.  It is just a selective copy+paste
of the relevant parts from ns8390.c plus a little trivial hacking to
make it actually work.

It is true that the code is pretty ugly, but:
  a) ns8390.c is worse
  b) It is only 372 lines and no #ifdefs
  c) It works both in qemu/bochs and in real hardware
     and we all know it is easier to cleanup working code

Hope someone will find the time to rewrite this driver properly,
but until then at least for me this is an ok solution.

Signed-off-by: Pantelis Koukousoulas <pktoss@gmail.com>
2008-11-08 13:01:20 +00:00
Pantelis Koukousoulas 180d99fc22 [isa] Fix a small typo in isa.c.
With this patch ISA drivers actually get probed so they have a fair
chance of working now.

Signed-off-by: Pantelis Koukousoulas <pktoss@gmail.com>
2008-11-08 12:54:18 +00:00
Michael Brown 9a52ba0cfa [netdevice] Retain and report detailed error breakdowns
netdev_rx_err() and netdev_tx_complete_err() get passed the error
code, but currently use it only in debug messages.

Retain error numbers and frequencey counts for up to
NETDEV_MAX_UNIQUE_ERRORS (4) different errors for each of TX and RX.
This allows the "ifstat" command to report the reasons for TX/RX
errors in most cases, even in non-debug builds.
2008-11-08 05:30:30 +00:00
Michael Brown 46f43d8ea7 [phantom] Do not halt PEGs on driver shutdown
Halting the PEGs breaks platforms where there is sideband access to
the NIC (e.g. HP machines using iLO).  (We have to retain the
unhalting code because on some other platforms (e.g. IBM blades with
BOFM) the pre-PXE firmware must halt the PEGs to avoid issues with the
BIOS rereading via the expansion ROM BAR.)
2008-11-08 05:10:23 +00:00
Michael Brown 43aa69d7b3 [aoe] Start retry timer before potential temporary transmission failure
The retry timer needs to be running as soon as we know that we are
trying to transmit a command.  If transmission fails because of a
temporary error condition, then the timer will allow us to retry the
transmission later.
2008-11-08 04:36:42 +00:00
Michael Brown ed196a3ed2 [settings] Ensure fetch_string_setting() returns a NUL-terminated string
This fixes a regression introduced in commit 612f4e7:

  [settings] Avoid returning uninitialised data on error in fetch_xxx_setting()

in which the memset() was moved from fetch_string_setting() to
fetch_setting(), in order that it would be useful for non-string
setting types.  However, this neglects to take into account the fact
that fetch_string_setting() shrinks its buffer by one byte (to allow
for the NUL) before calling fetch_setting().

Restore the memset() in fetch_string_setting(), so that the
terminating NUL is guaranteed to actually be a NUL.
2008-11-07 03:48:29 +00:00
Michael Brown 29e6f9835e [i386] Add data32 prefixes to all lgdt/lidt instructions
With a 16-bit operand, lgdt/lidt will load only a 24-bit base address,
ignoring the high-order bits.  This meant that we could fail to fully
restore the GDT across a call into gPXE, if the GDT happened to be
located above the 16MB mark.

Not all of our lgdt/lidt instructions require a data32 prefix (for
example, reloading the real-mode IDT can never require a 32-bit base
address), but by adding them everywhere we will hopefully not forget
the necessary ones in future.
2008-11-07 03:48:25 +00:00
Michael Brown aa95744915 [phantom] Allow for PXE boot to be enabled/disabled on a per-port basis
This is something of an ugly hack to accommodate an OEM requirement.
The NIC has only one expansion ROM BAR, rather than one per port.  To
allow individual ports to be selectively enabled/disabled for PXE boot
(as required), we must therefore leave the expansion ROM always
enabled, and place the per-port enable/disable logic within the gPXE
driver.
2008-11-01 01:55:13 +00:00
Michael Brown 5e6b82104d [romprefix] Add vendor branding facilities and guidelines
Some hardware vendors have been known to remove all gPXE-related
branding from ROMs that they build.  While this is not prohibited by
the GPL, it is a little impolite.

Add a facility for adding branding messages via two #defines
(PRODUCT_NAME and PRODUCT_SHORT_NAME) in config/general.h.  This
should accommodate all known OEM-mandated branding requirements.
Vendors with branding requirements that cannot be satisfied by using
PRODUCT_NAME and/or PRODUCT_SHORT_NAME should contact us so that we
can extended this facility as necessary.
2008-10-31 19:10:28 +00:00
Michael Brown 32bc76f902 [phantom] Assume one net device per PCI function
The Phantom firmware selectively disables PCI functions based on the
board type, with the end result that we see one PCI function for each
network port.  This allows us to eliminate the code for reading from
flash and, more importantly, removes knowledge of the board type magic
number from the gPXE driver.
2008-10-31 01:55:58 +00:00
Michael Brown 467c4f77c3 [hacks] Improve the guess_boot_netdev() logic
This function is a major kludge, but can be made slightly more
accurate by ignoring net devices that aren't open.  Eventually it
needs to be removed entirely.
2008-10-31 01:51:26 +00:00
Michael Brown 0a6c66a830 [settings] Add the notion of a "tag magic" to numbered settings
Settings can be constructed using a dotted-decimal notation, to allow
for access to unnamed settings.  The default interpretation is as a
DHCP option number (with encapsulated options represented as
"<encapsulating option>.<encapsulated option>".

In several contexts (e.g. SMBIOS, Phantom CLP), it is useful to
interpret the dotted-decimal notation as referring to non-DHCP
options.  In this case, it becomes necessary for these contexts to
ignore standard DHCP options, otherwise we end up trying to, for
example, retrieve the boot filename from SMBIOS.

Allow settings blocks to specify a "tag magic".  When dotted-decimal
notation is used to construct a setting, the tag magic value of the
originating settings block will be ORed in to the tag number.
Store/fetch methods can then check for the magic number before
interpreting arbitrarily-numbered settings.
2008-10-30 21:47:14 +00:00
Michael Brown 621101c36a [romprefix] Further sanity checks for the PCI 3 runtime segment address
This extends the sanity checks on the runtime segment address provided
in %bx, first implemented in commit 5600955.

We now allow the ROM to be placed anywhere above a000:0000 (rather
than c000:0000, as before), since this is the region allowed by the
PCI 3 spec.  If the BIOS asks us to place the runtime image such that
it would overlap with the init-time image (which is explicitly
prohibited by the PCI 3 spec), then we assume that the BIOS is faulty
and ignore the provided runtime segment address.

Testing on a SuperMicro BIOS providing overlapping segment addresses
shows that ignoring the provided runtime segment address is safe to do
in these circumstances.
2008-10-29 01:16:52 +00:00
Michael Brown 1bc2adea9a [phantom] Add CLP settings interface
This interface provides access to firmware settings (e.g. MAC address)
that will apply to all drivers loaded for the duration of the current
system boot.
2008-10-28 18:49:58 +00:00
Michael Brown 664f4cf365 [phantom] Unhalt/halt all PEGs during driver startup/shutdown
A hardware bug means that reads through the expansion ROM BAR can
return corrupted data if the PEGs are running.  This breaks platforms
that re-read the expansion ROM after invoking gPXE code, such as IBM
blade servers.

Halt PEGs during driver shutdown, and unhalt PEGs during driver
startup if we detect that this is not the first startup since
power-on.
2008-10-28 18:47:44 +00:00
Michael Brown df033de24f [phantom] Add line count limit to phantom_dmesg()
The Phantom firmware debug logs can be extremely long, so add the
ability to restrict the output to the last N lines.
2008-10-28 18:47:00 +00:00
Michael Brown 7a4c129af7 [ioapi] Fix broken implementation of insX() in the x86 I/O API 2008-10-27 00:29:16 +00:00
Michael Brown 3fe6bede74 [uri] Avoid interpreting DOS-style path names as opaque URIs
A DOS-style full path name such as "C:\Program Files\tftpboot\nbp.0"
satisfies the syntax requirements for a URI with a scheme of "C" and
an opaque portion of "\Program Files\tftpboot\nbp.0".

Add a check in parse_uri() to ignore schemes that are apparently only
a single character long; this avoids interpreting DOS-style paths in
this way, and shouldn't affect any practical URI scheme.
2008-10-24 04:08:43 +01:00
Michael Brown d4c8273569 [phantom] Change register space abstraction to match other drivers
Most other Phantom drivers define a register space in terms of a 64M
virtual address space.  While this doesn't map in any meaningful way
to the actual addresses used on the latest cards, it makes maintenance
easier if we do the same.
2008-10-24 03:52:17 +01:00
Michael Brown bcc70d6b99 [pcbios] Guard against register corruption in INT 15,e820 implementations
Someone at Dell must have a full-time job designing ways to screw up
implementations of INT 15,e820.  This latest gem is courtesy of a Dell
Xanadu system, which arbitrarily decides to obliterate the contents of
%esi.

Preserve %esi, %edi and %ebp across calls to INT 15,e820, in case
someone tries a variation on this trick in future.
2008-10-23 04:20:45 +01:00
Michael Brown 612f4e7a99 [settings] Avoid returning uninitialised data on error in fetch_xxx_setting()
Callers (e.g. usr/autoboot.c) may not check the return values from
fetch_xxx_setting(), assuming that in error cases the returned setting
value will be "empty" (for some sensible value of "empty").

In particular, if the DHCP server did not specify a next-server
address, this would result in gPXE using uninitialised data for the
TFTP server IP address.
2008-10-22 22:07:13 +01:00
Michael Brown cbf9003d66 [tftp] Add EUNIQ_xx values to differentiate the many EINVAL errors 2008-10-21 23:00:13 +01:00
Michael Brown 85f09b5fc0 [tg3] Add PCI ID for BCM5786
Contributed by Steve Cayford <cayfo001@umn.edu>
2008-10-21 22:31:10 +01:00
Michael Brown 22979c511e [contrib] Add patch to enable writable ROM images in bochs
Some of the gPXE romprefix.S code attempts to write to the ROM image,
as allowed by the PCI spec.  We do gracefully handle the case of
read-only ROM images (for ISA ROMs and for normal bochs/qemu
operation), but it can be handy to be able to use bochs to debug the
code paths that depend on writable ROM images.
2008-10-21 20:49:10 +01:00
Michael Brown d9c38d14d6 [build] Fix building on FreeBSD
FreeBSD requires the object format to be specified as elf_i386_fbsd,
rather than elf_i386.

Based on a patch from Eygene Ryabinkin <rea-fbsd@codelabs.ru>
2008-10-17 18:24:04 +01:00
Michael Brown 5600955bdd [romprefix] Sanity-check the runtime segment address for PCI 3
Some PCI 3 BIOSes seem to provide a garbage value in %bx, which should
contain the runtime segment address.  Perform a basic sanity check: we
reject the segment if it is below the start of option ROM space.  If
the sanity check fails, we assume that the BIOS was not expecting us
to be a PCI 3 ROM, and we just leave our image in situ.
2008-10-17 18:12:24 +01:00
Michael Brown 7982e79d3c [build] Use ".bss.*" names for uninitialised-data sections
The section name seems to have significance for some versions of
binutils.

There is no way to instruct gcc that sections such as .bss16 contain
uninitialised data; it will emit them with contents explicitly set to
zero.  We therefore have to rely on the linker script to force these
sections to become uninitialised-data sections.  We do this by marking
them as NOLOAD; this seems to be the closest semantic equivalent in the
linker script language.

However, this gets ignored by some versions of ld (including 2.17 as
shipped with Debian Etch), which mark the resulting sections with
(CONTENTS,ALLOC,LOAD,DATA).  Combined with the fact that this version of
ld seems to ignore the specified LMA for these sections, this means that
they end up overlapping other sections, and so parts of .prefix (for
example) get obliterated by .data16's bss section.

Rename the .bss sections from .section_bss to .bss.section; this seems to
cause these versions of ld to treat them as uninitialised data.
2008-10-17 03:12:11 +01:00
Michael Brown 04f3206581 [build] Fix building on Ubuntu 8.04
Not fully understood, but it seems that the LMA of bss sections matters
for some newer binutils builds.  Force all bss sections to have an LMA
at the end of the file, so that they don't interfere with other
sections.

The symptom was that objcopy -O binary -j .zinfo would extract the
.zinfo section from bin/xxx.tmp as a blob of the correct length, but
with zero contents.  This would then cause the [ZBIN] stage of the
build to fail.

Also explicitly state that .zinfo(.*) sections have @progbits, in case
some future assembler or linker variant decides to omit them.
2008-10-17 01:55:58 +01:00
Michael Brown 58dd6e04c5 [etherfabric] Merge changes from vendor tree
Also clean up minor errors in the use of debug macros.
2008-10-17 01:51:41 +01:00
Eduardo Habkost 744b98d273 virtio-net: Fix kick/wait logic
The virtnet_transmit() logic for waiting the packet to be transmitted is
reversed: we can't wait the packet to be transmitted if we didn't kick()
the ring yet. The vring_more_used() while loop logic is reversed also,
that explains why the code works today.

The current code risks trying to free a buffer from the used ring
when none was available, that will happen most times because KVM
doesn't handle the packet immediately on kick(). Luckily it was working
because it was unlikely to have a buffer still queued for transmit when
virtnet_transmit() was called.

Also, adds a BUG_ON() to vring_get_buf(), to catch cases where we try
to free a buffer from the used ring when there was none available.

Patch for Etherboot. gPXE has the same problem on the code, but I hadn't
a chance to test gPXE using virtio-net yet.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2008-10-16 20:32:56 +01:00
Michael Brown c99b16c974 [efi] Add basic implementation of EFI SIMPLE_NETWORK_PROTOCOL
This implementation is tested and working, but not currently tied in
to the EFI build.
2008-10-16 05:38:23 +01:00
Michael Brown 3a505dfc35 [netdevice] Change link-layer push() and pull() methods to take raw types
EFI requires us to be able to specify the source address for
individual transmitted packets, and to be able to extract the
destination address on received packets.

Take advantage of this to rationalise the push() and pull() methods so
that push() takes a (dest,source,proto) tuple and pull() returns a
(dest,source,proto) tuple.
2008-10-16 05:13:40 +01:00
Michael Brown 6b9cc25556 [netdevice] Split multicast hashing out into an mc_hash method
Multicast hashing is an ugly overlap between network and link layers.
EFI requires us to provide access to this functionality, so move it
out of ipv4.c and expose it as a method of the link layer.
2008-10-16 05:12:56 +01:00
Michael Brown 832668105e [netdevice] Add maximum packet length as a net device property
Currently this length is set at device allocation time, and is never
changed.
2008-10-16 05:11:47 +01:00
Michael Brown 64e5ca0582 [efi] Fix linker script for ld 2.17.50.0.9
Some versions of ld choke on the "AT ( _xxx_lma )" in efi.lds with an
error saying "nonconstant expression for load base".  Since these were
only explicitly setting the LMA to the address that it would have had
anyway, they can be safely omitted.
2008-10-13 10:41:38 +01: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 54c024e0af [sanboot] Quick and dirty hack to make SAN boot protocols selectable 2008-10-13 10:05:51 +01:00
Michael Brown d4e152e766 [config] Make the default image type selection platform-dependent 2008-10-13 09:37:51 +01:00
Michael Brown 07e8f18f33 [monojob] Release reference on completed job
monojob_wait() was holding a reference to the completed job, meaning that
various objects would not be freed until the next job was plugged in to
the monojob interface.
2008-10-13 05:34:08 +01:00
Michael Brown 831e4cfc27 [umalloc] Formalise the user memory allocation API 2008-10-13 05:33:14 +01:00
Michael Brown 6554b79ff9 [uaccess] Formalise the uaccess API
The userptr_t is now the fundamental type that gets used for conversions.
For example, virt_to_phys() is implemented in terms of virt_to_user() and
user_to_phys().
2008-10-13 04:10:34 +01:00
Michael Brown 667819becc [timer] Remove now-obsolete references to TIMER_BIOS and TIMER_RDTSC 2008-10-13 00:23:18 +01:00
Michael Brown c0835339d0 [nap] Formalise the CPU sleeping API 2008-10-12 23:36:53 +01:00
Michael Brown 658c6dba59 [monojob] Allow for extremely slow system timers
The EFI timer runs at one tick per second, so using ">" rather than ">="
results in a two-second gap between dots.
2008-10-12 21:30:37 +01:00
Michael Brown 16f1e35775 [timer] Formalise the timer API
We now have two implementations for the timer API: one using the
time-of-day counter at 40:70 and one using RDTSC.  Both make use of
timer2_udelay().
2008-10-12 20:22:02 +01:00
Michael Brown e6f276ece3 [process] Add DBG2() messages to help track down frozen processes 2008-10-12 15:11:29 +01:00
Michael Brown f945d6d201 [retry] Use a separate flag to indicate that a retry timer is running
Using start==0 to indicate a stopped timer is dangerous, because 0 is a
valid value for the current tick counter.
2008-10-12 15:11:20 +01:00
Michael Brown 941b4c2adb [commands] Fix config command to accept zero arguments 2008-10-12 15:11:10 +01:00
Michael Brown 8a4ccebec9 [pci] Formalise the PCI I/O API 2008-10-12 12:54:12 +01:00
Michael Brown fd67452807 [legacy] Add missing #include <gpxe/io.h> 2008-10-12 12:52:56 +01:00
Michael Brown e226a8d8d9 [phantom] Add missing #include <gpxe/io.h> 2008-10-12 12:52:47 +01:00
Michael Brown 8c7deba349 [config] Split console configuration out to config/console.h 2008-10-12 02:30:31 +01:00
Michael Brown aef6d0df5c [ioapi] Absorb virt_to_phys() and phys_to_virt() into the I/O API 2008-10-12 02:15:34 +01:00
Michael Brown 992bbf309c [i386] Remove obsolete functions from virtaddr.h
The copy_{to,from}_phys() functions were obsoleted long ago by
copy_{to,from}_user().

relocate_to() also disappeared some time ago.
2008-10-12 02:14:26 +01:00
Michael Brown 8e38669d54 [rtl8139] Add missing #include <string.h> 2008-10-12 02:14:16 +01:00
Michael Brown a1e11a6beb [natsemi] Add missing #include <string.h> 2008-10-12 02:14:10 +01:00
Michael Brown 1641b5d39b [e1000] Add missing #include <string.h> 2008-10-12 02:14:05 +01:00
Michael Brown ee2df1d6d6 [ioapi] Remove old io.h file and switch all users over to <gpxe/io.h> 2008-10-12 01:06:27 +01:00
Michael Brown 8956a36be5 [ioapi] Formalise the I/O API as used in i386-pcbios 2008-10-12 01:03:17 +01:00
Michael Brown b40b4f2dbf [cs89x0] Simplify obscure loop syntax 2008-10-12 00:54:58 +01:00
Michael Brown 0b5c39d167 [e1000] Fix dubious syntax in e1000 I/O wrapper macros 2008-10-12 00:54:44 +01:00
Michael Brown 2e812235f4 [makefile] Add -Wformat-nonliteral as an extra warning category
-Wformat-nonliteral is not enabled by -Wall and needs to be explicitly
 specified.

Modified the few files that use nonliteral format strings to work with
this new setting in place.

Inspired by a patch from Carl Karsten <carl@personnelware.com> and an
identical patch from Rorschach <r0rschach@lavabit.com>.
2008-10-10 18:41:24 +01:00
Michael Brown ac663cf509 [efi] Add EFI headers from the EFI Development Kit (edk2)
The intention is to include near-verbatim copies of the EFI headers
required by gPXE.  This is achieved using the import.pl script in
src/include/gpxe/efi.

Note that import.pl will modify any #include lines in each imported
header to reflect its new location within the gPXE tree.  It will also
tidy up the file by removing carriage return characters and trailing
whitespace.
2008-10-10 04:04:07 +01:00
Michael Brown 13d09e6719 [i386] Simplify linker script and standardise linker-defined symbol names
Reduce the number of sections within the linker script to match the
number of practical sections within the output file.

Define _section, _msection, _esection, _section_filesz, _section_memsz,
and _section_lma for each section, replacing the mixture of symbols that
previously existed.

In particular, replace _text and _end with _textdata and _etextdata, to
make it explicit within code that uses these symbols that the .text and
.data sections are always treated as a single contiguous block.
2008-10-10 03:59:57 +01:00
Michael Brown 3029eb0e84 [makefile] Reduce verbosity of various NON_AUTO_MEDIA rules 2008-10-10 03:57:31 +01:00
Michael Brown 5c695db474 [makefile] Split platform-dependent portions out of arch/i386/Makefile 2008-10-10 03:45:34 +01:00
Michael Brown 98abd48a26 [makefile] Inhibit warnings if AUTO_DEPS or MEDIA_DEPS are empty lists 2008-10-10 03:42:56 +01:00
Michael Brown 3f80f9e1a6 [makefile] Add missing dependency on arch/$(ARCH)/Makefile to MAKEDEPS 2008-10-10 03:42:37 +01:00
Michael Brown cdd619d11f [util] Don't die on undefined symbols in sortobjdump.pl
Undefined symbols shouldn't reach sortobjdump.pl, but if they do then it
is not a helpful place to report the error.
2008-10-10 03:42:22 +01:00
Michael Brown 96ea558e98 [util] Add optional debug messages to zbin.c 2008-10-10 03:42:08 +01:00
Michael Brown e817a347fb [makefile] Split config.h out into config/*.h and kill off mkconfig.pl 2008-10-08 02:17:32 +01:00
Michael Brown a2588547f9 [makefile] Add support for multiple build platforms
Allow for the build CPU architecture and platform to be specified as part
of the make command goals.  For example:

  make bin/rtl8139.rom      # Standard i386 PC-BIOS build

  make bin-efi/rtl8139.efi  # i386 EFI build

The generic syntax is "bin[-[arch-]platform]", with the default
architecture being "i386" (regardless of the host architecture) and the
default platform being "pcbios".

Non-path targets such as "srcs" can be specified using e.g.

  make bin-efi srcs

Note that this changeset is merely Makefile restructuring to allow the
build architecture and platform to be determined by the make command
goals, and to export these to compiled code via the ARCH and PLATFORM
defines.  It doesn't actually introduce any new build platforms.
2008-10-08 02:17:25 +01:00
Michael Brown f0b942ef42 [makefile] Kill off arch/$(ARCH)/Config
The arch/i386/Config file has long been marked as deprecated.  Move all
the pertinent bits to arch/i386/Makefile instead and remove
arch/i386/Config.
2008-10-07 22:46:43 +01:00
Michael Brown 160b950af8 [libc] Define wchar_t in a gcc-compatible way
gcc defines the magic __WCHAR_TYPE__ macro, in order to convey
information about whether or not the user selected -fshort-wchar.
2008-10-07 22:27:55 +01:00
Michael Brown 19a0452205 [libc] Add function declaration for main() in stdlib.h 2008-10-07 22:04:50 +01:00
Michael Brown 521549d900 [crypto] Rename <gpxe/bitops.h> to <gpxe/rotate.h> 2008-10-01 19:24:56 +01:00
Michael Brown 9dccbc0af2 [i2c] Generalise i2c bit-bashing support to addressless devices
Some devices (e.g. the Atmel AT24C11) have no concept of a device
address; they respond to every device address and use this value as
the word address.  Some other devices use part of the device address
field to extend the word address field.

Generalise the i2c bit-bashing support to handle this by defining the
device address length and word address length as properties of an i2c
device.  The word address is assumed to overflow into the device
address field if the address used exceeds the width of the word
address field.

Also add a bus reset mechanism.  i2c chips don't usually have a reset
line, so rebooting the host will not clear any bizarre state that the
chip may be in.  We reset the bus by clocking SCL until we see SDA
high, at which point we know we can generate a start condition and
have it seen by all devices.  We then generate a stop condition to
leave the bus in a known state prior to use.

Finally, add some extra debugging messages to i2c_bit.c.
2008-10-01 19:24:56 +01:00
Michael Brown 91802c6e85 [makefile] Fix -fno-stack-protector test on older versions of gcc
Some older versions of gcc don't complain about unknown compiler flags
unless you ask them to actually compile; asking them to merely
preprocess won't trigger the error.

Fix the -fno-stack-protector test by making it attempt to compile an
empty file, rather than preprocess an empty file.
2008-10-01 19:24:56 +01:00
Michael Brown afe1323c76 [compiler] Allow for selective disabling of debug levels at runtime
The usefulness of DBGLVL_IO is limited by the fact that many cards
require large numbers of uninteresting I/O reads/writes at device
probe time, typically when driving a bit-bashing I2C/SPI bus to read
the MAC address.

This patch adds the DBG_DISABLE() and DBG_ENABLE() macros, which can
be used to temporarily disable and re-enable selected debug levels.
Note that debug levels must still be enabled in the build in order to
function at all: you can't use DBG_ENABLE(DBGLVL_IO) in an object
built with DEBUG=object:1 and expect it to do anything.
2008-10-01 19:24:56 +01:00
Michael Brown 9b01a9fd9c [compiler] Add __always_inline macro 2008-10-01 19:24:56 +01:00
Marty Connor 60c3b69c31 [release] Update version to 0.9.5+ post release 2008-10-01 13:46:16 -04:00
Marty Connor 8c3e95ce42 [release] Update version to 0.9.5 for release 2008-10-01 13:38:45 -04:00
Michael Brown df02c54f86 [arbel] Fix off-by-one error in the failure path in arbel_probe() 2008-10-01 08:11:03 +01:00
Michael Brown 76f6cad8af [hermon] Fix off-by-one error in the failure path in hermon_probe() 2008-10-01 08:10:50 +01:00
H. Peter Anvin e899f100ca [makefile] Quote argument to sed containing []
[] are shell metacharacters, and they can get confused by files in the
local directory.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-30 21:54:41 +01:00
H. Peter Anvin e8b6077566 [makefile] Avoid using ?=
?= in a Makefile means that that variable can be overridden by the
environment.  This is confusing to users, especially with a generic
name like "ARCH".

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-30 21:53:34 +01:00
Michael Brown 6f87d622e1 [tg3] Add PCI ID
Reported working by Martin Kreiner <m.kreiner@levigo.de>
2008-09-29 16:00:09 +01:00
Michael Brown 1dda75c9cd [pcbios] Allow for larger-than-20-byte buffers in e820mangler.S
Although the E820 API allows for a caller to provide only a 20-byte
buffer, there exists at least one combination (HP BIOS, 32-bit WinPE)
that relies on information found only in the "extended attributes"
field, which requires a 24-byte buffer.

Allow for up to a 64-byte E820 buffer, in the hope of coping with
future idiocies like this one.
2008-09-29 05:11:51 +01:00
Michael Brown 040f7cdf3a [pcbios] Print INT 15,E820 extended attributes, if present
The ACPI specification defines an additional 4-byte field at offset 20
for an E820 memory map entry.  This field is presumably optional,
since generally E820 gets given only a 20-byte buffer to fill.
However, the bits of this optional field are defined as:

  bit 0 : region is enabled
  bit 1 : region is non-volatile memory rather than RAM

so it seems as though callers that pass in only a 20-byte buffer may
be missing out on some rather important information.
2008-09-29 03:55:13 +01:00
Michael Brown 0015601f0b [gdb] Fix a compiler warning that shows up only when assertions are enabled
gcc should (I think) be warning about this anyway, but seems to do so
only when assertions are enabled for this object.
2008-09-29 01:00:14 +01:00
Michael Brown 50dc9344b7 [pcbios] Save/restore %es in INT 15,e820
Our INT 15,e820 code was setting %es=%ss (as part of the "look ahead
in the memory map" logic), but failing to restore %es afterwards.
This is a serious bug, but wasn't affecting many platforms because
almost all callers seem to set %es=%ss anyway.
2008-09-29 00:36:11 +01:00
Michael Brown e3c5507178 [i386] Add dump_regs() debug call
Use as "call dump_regs" from any real-mode code within .text16.
Should preserve all registers and flags.
2008-09-28 23:06:53 +01:00
Michael Brown 39047c5636 [hermon] Allocate only as much memory as is needed for ICM and ICM AUX
Use individual page mappings rather than a single whole-region
mapping, to avoid the waste of memory that occurs due to the
constraint that each mapped block must be aligned on its own size.
2008-09-28 20:43:18 +01:00
Michael Brown 2d41dead08 [iscsi] Fix LUN parsing in the iSCSI root-path 2008-09-27 23:53:31 +01:00
Marty Connor 6eaefa16a8 [release] Update version post release to 0.9.4+ 2008-09-26 16:05:55 -04:00
475 changed files with 46241 additions and 31267 deletions
-1
View File
@@ -1 +0,0 @@
0.9.4 2008-09-26
+11 -18
View File
@@ -1,5 +1,5 @@
Running Etherboot within qemu
=============================
Running gPXE within qemu
========================
Michael Brown <mbrown@fensystems.co.uk>
@@ -9,13 +9,10 @@ To get qemu running is fairly simple:
make
2. Get the qemu source code:
cvs -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/qemu \
login
cvs -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/qemu \
co qemu
svn co svn://svn.savannah.nongnu.org/qemu/trunk qemu
2a. Patch the qemu code. There is currently a bug that causes qemu to
execute Etherboot incredibly slowly. The bug seems to be related
execute gPXE incredibly slowly. The bug seems to be related
to the relative prioritisation of CPU and I/O operations within
qemu. This patch (which I found via Google) isn't a proper fix,
but it does work around the problem:
@@ -23,13 +20,9 @@ To get qemu running is fairly simple:
3. Configure qemu with
pushd qemu
./configure --enable-system
./configure --target-list=i386-softmmu,x86_64-softmmu
popd
Note that qemu will not compile with gcc4; if your system's
default compiler is gcc4 then specify the path to gcc3 using
e.g. --cc=gcc-3.3.6
4. Build qemu:
make -C qemu
@@ -44,7 +37,7 @@ To get qemu running is fairly simple:
range dynamic-bootp 10.254.254.1 10.254.254.1;
}
You will also need to add in any of your usual declarations for
Etherboot, e.g. 'filename "vmlinuz.ltsp";'. Note that this setup
gPXE, e.g. 'filename "vmlinuz.ltsp";'. Note that this setup
assumes that your DHCP server, TFTP server etc. all live on the
machine you are using for running qemu. If not, then you're on
your own.
@@ -52,7 +45,7 @@ To get qemu running is fairly simple:
7. As root, restart dhcpd
/etc/init.d/dhcpd restart
8. Build Etherboot floppy disk images and pad to 1.44MB
8. Build gPXE floppy disk images and pad to 1.44MB
pushd ../../src
make bin/rtl8139.pdsk
popd
@@ -62,8 +55,8 @@ To get qemu running is fairly simple:
-net nic,model=rtl8139 -net tap,ifname=tap0 \
-boot a -fda ../../src/bin/rtl8139.pdsk
You should see qemu start up, load up Etherboot and attempt to boot
from the network.
You should see qemu start up, load up gPXE and attempt to boot from
the network.
@@ -71,8 +64,8 @@ Serial console
==============
You can use the program "serial-console" to obtain a virtual serial
console for Etherboot running within qemu. Run "./serial-console" on
a spare tty (e.g. a separate xterm window) before starting qemu, and
console for gPXE running within qemu. Run "./serial-console" on a
spare tty (e.g. a separate xterm window) before starting qemu, and
ensure that you have enabled CONSOLE_SERIAL in config.h.
When serial-console starts, it will print out the message "Slave pty
+20
View File
@@ -0,0 +1,20 @@
Index: memory/memory.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/memory/memory.cc,v
retrieving revision 1.71
diff -u -r1.71 memory.cc
--- memory/memory.cc 18 Oct 2008 18:10:14 -0000 1.71
+++ memory/memory.cc 21 Oct 2008 19:47:07 -0000
@@ -172,7 +172,11 @@
break;
case 0x0: // Writes to ROM, Inhibit
- BX_DEBUG(("Write to ROM ignored: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
+ if ((a20addr & 0xfffe0000) == 0x000e0000) {
+ BX_DEBUG(("Write to ROM ignored: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
+ } else {
+ BX_MEM_THIS rom[(a20addr & EXROM_MASK) + BIOSROMSZ] = *data_ptr;
+ }
break;
default:
+4
View File
@@ -0,0 +1,4 @@
#!gpxe
dhcp net0
imgload img1
boot img1
+8
View File
@@ -0,0 +1,8 @@
#!gpxe
ifopen net0
set net0/ip 10.0.2.15
set net0/netmask 255.255.255.0
set net0/gateway 10.0.2.2
set net0/dns 10.0.2.3
kernel http://etherboot.org/gtest/gtest.gpxe
boot gtest.gpxe
+74 -121
View File
@@ -1,19 +1,17 @@
# Location to place generated files
###############################################################################
#
BIN := bin
# Initialise variables that get added to throughout the various Makefiles
# Initialise various variables
#
MAKEDEPS := Makefile .toolcheck .echocheck
SRCDIRS :=
SRCS :=
NON_AUTO_SRCS :=
DRIVERS :=
ROMS :=
MEDIA :=
NON_AUTO_MEDIA :=
# Locations of utilities
CLEANUP :=
CFLAGS :=
ASFLAGS :=
LDFLAGS :=
MAKEDEPS := Makefile
###############################################################################
#
# Locations of tools
#
HOST_CC := gcc
RM := rm -f
@@ -35,109 +33,20 @@ NM := $(CROSS_COMPILE)nm
OBJDUMP := $(CROSS_COMPILE)objdump
PARSEROM := $(PERL) ./util/parserom.pl
MAKEROM := $(PERL) ./util/makerom.pl
MKCONFIG := $(PERL) ./util/mkconfig.pl
SYMCHECK := $(PERL) ./util/symcheck.pl
SORTOBJDUMP := $(PERL) ./util/sortobjdump.pl
NRV2B := ./util/nrv2b
ZBIN := ./util/zbin
ELF2EFI32 := ./util/elf2efi32
ELF2EFI64 := ./util/elf2efi64
EFIROM := ./util/efirom
DOXYGEN := doxygen
# If invoked with no build target, print out a helpfully suggestive
# message.
###############################################################################
#
noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb $(BIN)/undionly.kpxe
@$(ECHO) '==========================================================='
@$(ECHO)
@$(ECHO) 'To create a bootable floppy, type'
@$(ECHO) ' cat $(BIN)/gpxe.dsk > /dev/fd0'
@$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
@$(ECHO) 'data already on the disk.'
@$(ECHO)
@$(ECHO) 'To create a bootable USB key, type'
@$(ECHO) ' cat $(BIN)/gpxe.usb > /dev/sdX'
@$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
@$(ECHO) 'disk on your system. This will erase any data already on'
@$(ECHO) 'the USB key.'
@$(ECHO)
@$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
@$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.'
@$(ECHO)
@$(ECHO) 'These images contain drivers for all supported cards. You'
@$(ECHO) 'can build more customised images, and ROM images, using'
@$(ECHO) ' make bin/<rom-name>.<output-format>'
@$(ECHO)
@$(ECHO) '==========================================================='
# If no architecture is specified in Config or on the command-line,
# use that of the build machine.
#
ARCH ?= $(shell uname -m | sed -e s,i[3456789]86,i386,)
# handle x86_64 like i386, but set -m32 option for 32bit code only
ifeq ($(ARCH),x86_64)
ARCH := i386
CFLAGS += -m32
ASFLAGS += --32
LDFLAGS += -m elf_i386
endif
# Drag in architecture-specific Config
#
MAKEDEPS += arch/$(ARCH)/Config
include arch/$(ARCH)/Config
# Common flags
#
CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
CFLAGS += -Os -ffreestanding
CFLAGS += -Wall -W
CFLAGS += -g
CFLAGS += $(EXTRA_CFLAGS)
ASFLAGS += $(EXTRA_ASFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS)
# Embedded image, if present
#
EMBEDDED_IMAGE ?= /dev/null
ifneq ($(NO_WERROR),1)
CFLAGS += -Werror
endif
# CFLAGS for specific object types
#
CFLAGS_c +=
CFLAGS_S += -DASSEMBLY
# Base object name of the current target
#
OBJECT = $(firstword $(subst ., ,$(@F)))
# CFLAGS for specific object files. You can define
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
# compiling bin/rtl8139.o.
#
OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
$(BIN)/%.flags :
@$(ECHO) $(OBJ_CFLAGS)
# Rules for specific object types.
#
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
ASSEMBLE_S = $(AS) $(ASFLAGS)
RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
DEBUG_TARGETS += dbg%.o c s
# SRCDIRS lists all directories containing source files.
#
SRCDIRS :=
SRCDIRS += libgcc
SRCDIRS += core
SRCDIRS += proto
@@ -151,7 +60,7 @@ SRCDIRS += drivers/block
SRCDIRS += drivers/nvs
SRCDIRS += drivers/bitbash
SRCDIRS += drivers/infiniband
SRCDIRS += interface/pxe
SRCDIRS += interface/pxe interface/efi interface/smbios
SRCDIRS += tests
SRCDIRS += crypto crypto/axtls crypto/matrixssl
SRCDIRS += hci hci/commands hci/tui
@@ -161,25 +70,69 @@ SRCDIRS += usr
# NON_AUTO_SRCS lists files that are excluded from the normal
# automatic build system.
#
NON_AUTO_SRCS += core/elf_loader.c
NON_AUTO_SRCS :=
NON_AUTO_SRCS += drivers/net/prism2.c
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
# the automatic build system and varies by target; it includes the
# "-p 0x1234,0x5678" string to set the PCI IDs.
###############################################################################
#
FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
-i$(IDENT) -s 0 $@
# Some ROMs require specific flags to be passed to makerom.pl
# Default build target: build the most common targets and print out a
# helpfully suggestive message
#
MAKEROM_FLAGS_3c503 = -3
all : bin/blib.a bin/gpxe.dsk bin/gpxe.iso bin/gpxe.usb bin/undionly.kpxe
@$(ECHO) '==========================================================='
@$(ECHO)
@$(ECHO) 'To create a bootable floppy, type'
@$(ECHO) ' cat bin/gpxe.dsk > /dev/fd0'
@$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
@$(ECHO) 'data already on the disk.'
@$(ECHO)
@$(ECHO) 'To create a bootable USB key, type'
@$(ECHO) ' cat bin/gpxe.usb > /dev/sdX'
@$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
@$(ECHO) 'disk on your system. This will erase any data already on'
@$(ECHO) 'the USB key.'
@$(ECHO)
@$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
@$(ECHO) 'bin/gpxe.iso to a blank CD-ROM.'
@$(ECHO)
@$(ECHO) 'These images contain drivers for all supported cards. You'
@$(ECHO) 'can build more customised images, and ROM images, using'
@$(ECHO) ' make bin/<rom-name>.<output-format>'
@$(ECHO)
@$(ECHO) '==========================================================='
# Drag in architecture-specific Makefile
###############################################################################
#
# Build targets that do nothing but might be tried by users
#
configure :
@$(ECHO) "No configuration needed."
install :
@$(ECHO) "No installation required."
###############################################################################
#
# Version number calculations
#
VERSION_MAJOR = 0
VERSION_MINOR = 9
VERSION_PATCH = 7
EXTRAVERSION =
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DVERSION_PATCH=$(VERSION_PATCH) \
-DVERSION=\"$(VERSION)\"
IDENT = '$(@F) $(VERSION) (GPL) etherboot.org'
version :
@$(ECHO) $(VERSION)
###############################################################################
#
# Drag in the bulk of the build system
#
MAKEDEPS += arch/$(ARCH)/Makefile
include arch/$(ARCH)/Makefile
# Drag in the automatic build system and other housekeeping functions
MAKEDEPS += Makefile.housekeeping
include Makefile.housekeeping
+376 -121
View File
@@ -1,50 +1,10 @@
# -*- makefile -*- : Force emacs to use Makefile mode
#
# This file contains various boring housekeeping functions that would
# otherwise seriously clutter up the main Makefile.
# Objects to be removed by "make clean"
###############################################################################
#
CLEANUP := $(BIN)/*.* # *.* to avoid catching the "CVS" directory
# Version number calculations
#
VERSION_MAJOR = 0
VERSION_MINOR = 9
VERSION_PATCH = 4
EXTRAVERSION =
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DVERSION=\"$(VERSION)\"
IDENT = '$(@F) $(VERSION) (GPL) etherboot.org'
version :
@$(ECHO) $(VERSION)
configure :
@$(ECHO) "No configuration needed."
install :
@$(ECHO) "No installation required. Generated images will be placed in the" $(BIN) "directory."
# Check for tools that can cause failed builds
#
.toolcheck : Makefile
@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
exit 1; \
fi
@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
$(ECHO) 'Your Perl version has a Unicode handling bug'; \
$(ECHO) 'Execute this command before compiling Etherboot:'; \
$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
exit 1; \
fi
@$(TOUCH) $@
VERYCLEANUP += .toolcheck
# Find a usable "echo -e" substitute.
#
TAB := $(shell $(PRINTF) '\t')
@@ -58,16 +18,16 @@ ECHO_E_BIN_ECHO_TAB := $(shell $(ECHO_E_BIN_ECHO) '\t')
ECHO_E_BIN_ECHO_E_TAB := $(shell $(ECHO_E_BIN_ECHO_E) '\t')
ifeq ($(ECHO_E_ECHO_TAB),$(TAB))
ECHO_E ?= $(ECHO_E_ECHO)
ECHO_E := $(ECHO_E_ECHO)
endif
ifeq ($(ECHO_E_ECHO_E_TAB),$(TAB))
ECHO_E ?= $(ECHO_E_ECHO_E)
ECHO_E := $(ECHO_E_ECHO_E)
endif
ifeq ($(ECHO_E_BIN_ECHO_TAB),$(TAB))
ECHO_E ?= $(ECHO_E_BIN_ECHO)
ECHO_E := $(ECHO_E_BIN_ECHO)
endif
ifeq ($(ECHO_E_BIN_ECHO_E_TAB),$(TAB))
ECHO_E ?= $(ECHO_E_BIN_ECHO_E)
ECHO_E := $(ECHO_E_BIN_ECHO_E)
endif
.echocheck :
@@ -86,20 +46,51 @@ else
@$(ECHO) "No usable \"echo -e\" substitute found"
@exit 1
endif
MAKEDEPS += .echocheck
VERYCLEANUP += .echocheck
echo :
@$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
# Build verbosity
###############################################################################
#
ifeq ($(V),1)
Q =
QM = @\#
else
Q = @
QM = @
endif
# Determine host OS
#
HOST_OS := $(shell uname -s)
hostos :
@$(ECHO) $(HOST_OS)
###############################################################################
#
# Check for tools that can cause failed builds
#
.toolcheck :
@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
exit 1; \
fi
@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
$(ECHO) 'Your Perl version has a Unicode handling bug'; \
$(ECHO) 'Execute this command before compiling Etherboot:'; \
$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
exit 1; \
fi
@$(TOUCH) $@
MAKEDEPS += .toolcheck
VERYCLEANUP += .toolcheck
###############################################################################
#
# Check for various tool workarounds
#
# Make syntax does not allow use of comma or space in certain places.
# This ugly workaround is suggested in the manual.
#
COMMA := ,
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
# Check for an old version of gas (binutils 2.9.1)
#
@@ -112,18 +103,154 @@ oldgas :
# default, even when -ffreestanding is specified. We therefore need
# to disable -fstack-protector if the compiler supports it.
#
SP_TEST = $(CC) -fno-stack-protector -x c -E - < /dev/null >/dev/null 2>&1
SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
-o /dev/null >/dev/null 2>&1
SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
CFLAGS += $(SP_FLAGS)
# compiler.h is needed for our linking and debugging system
###############################################################################
#
CFLAGS += -include compiler.h
# Build verbosity
#
ifeq ($(V),1)
Q :=
QM := @\#
else
Q := @
QM := @
endif
# config/%.h files are generated from config.h using mkconfig.pl
config/%.h : config*.h
$(MKCONFIG) config.h
CLEANUP += config/*.h
###############################################################################
#
# Set BIN according to whatever was specified on the command line as
# the build target.
#
# Determine how many different BIN directories are mentioned in the
# make goals.
#
BIN_GOALS := $(filter bin/% bin-%,$(MAKECMDGOALS))
BIN_GOAL_BINS := $(foreach BG,$(BIN_GOALS),$(firstword $(subst /, ,$(BG))))
NUM_BINS := $(words $(sort $(BIN_GOAL_BINS)))
ifeq ($(NUM_BINS),0)
# No BIN directory was specified. Set BIN to "bin" as a sensible
# default.
BIN := bin
else # NUM_BINS == 0
ifeq ($(NUM_BINS),1)
# If exactly one BIN directory was specified, set BIN to match this
# directory.
#
BIN := $(firstword $(BIN_GOAL_BINS))
else # NUM_BINS == 1
# More than one BIN directory was specified. We cannot handle the
# latter case within a single make invocation, so set up recursive
# targets for each BIN directory.
#
# Leave $(BIN) undefined. This has implications for any target that
# depends on $(BIN); such targets should be made conditional upon the
# existence of $(BIN).
#
$(BIN_GOALS) : % : BIN_RECURSE
$(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) $@
.PHONY : BIN_RECURSE
endif # NUM_BINS == 1
endif # NUM_BINS == 0
ifdef BIN
# Create $(BIN) directory if it doesn't exist yet
#
ifeq ($(wildcard $(BIN)),)
$(shell $(MKDIR) -p $(BIN))
endif
# Target to allow e.g. "make bin-efi arch"
#
$(BIN) :
@# Do nothing, silently
.PHONY : $(BIN)
# Remove everything in $(BIN) for a "make clean"
#
CLEANUP += $(BIN)/*.* # Avoid picking up directories
endif # defined(BIN)
# Determine whether or not we need to include the dependency files
#
NO_DEP_TARGETS := $(BIN) clean veryclean
ifeq ($(MAKECMDGOALS),)
NEED_DEPS := 1
endif
ifneq ($(strip $(filter-out $(NO_DEP_TARGETS),$(MAKECMDGOALS))),)
NEED_DEPS := 1
endif
###############################################################################
#
# Select build architecture and platform based on $(BIN)
#
# BIN has the form bin[-[arch-]platform]
ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
PLATFORMS := $(patsubst config/defaults/%.h,%,\
$(wildcard config/defaults/*.h))
archs :
@$(ECHO) $(ARCHS)
platforms :
@$(ECHO) $(PLATFORMS)
ifdef BIN
# Determine architecture portion of $(BIN), if present
BIN_ARCH := $(strip $(foreach A,$(ARCHS),\
$(patsubst bin-$(A)-%,$(A),\
$(filter bin-$(A)-%,$(BIN)))))
# Determine platform portion of $(BIN), if present
ifeq ($(BIN_ARCH),)
BIN_PLATFORM := $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
else
BIN_PLATFORM := $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
endif
# Determine build architecture
DEFAULT_ARCH := i386
ARCH := $(firstword $(BIN_ARCH) $(DEFAULT_ARCH))
CFLAGS += -DARCH=$(ARCH)
arch :
@$(ECHO) $(ARCH)
.PHONY : arch
# Determine build platform
DEFAULT_PLATFORM := pcbios
PLATFORM := $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
CFLAGS += -DPLATFORM=$(PLATFORM)
platform :
@$(ECHO) $(PLATFORM)
endif # defined(BIN)
# Include architecture-specific Makefile
ifdef ARCH
MAKEDEPS += arch/$(ARCH)/Makefile
include arch/$(ARCH)/Makefile
endif
###############################################################################
#
# Source file handling
# SRCDIRS lists all directories containing source files.
srcdirs :
@@ -144,6 +271,64 @@ AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
autosrcs :
@$(ECHO) $(AUTO_SRCS)
# Just about everything else in this section depends upon having
# $(BIN) set
ifdef BIN
# Common flags
#
CFLAGS += -I include -I arch/$(ARCH)/include -I .
CFLAGS += -Os -ffreestanding
CFLAGS += -Wall -W -Wformat-nonliteral
CFLAGS += -g
CFLAGS += $(EXTRA_CFLAGS)
ASFLAGS += $(EXTRA_ASFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS)
# Inhibit -Werror if NO_WERROR is specified on make command line
#
ifneq ($(NO_WERROR),1)
CFLAGS += -Werror
ASFLAGS += --fatal-warnings
endif
# compiler.h is needed for our linking and debugging system
#
CFLAGS += -include compiler.h
# CFLAGS for specific object types
#
CFLAGS_c +=
CFLAGS_S += -DASSEMBLY
# Base object name of the current target
#
OBJECT = $(firstword $(subst ., ,$(@F)))
# CFLAGS for specific object files. You can define
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
# compiling bin/rtl8139.o.
#
OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
$(BIN)/%.flags :
@$(ECHO) $(OBJ_CFLAGS)
# Rules for specific object types.
#
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
ASSEMBLE_S = $(AS) $(ASFLAGS)
RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
DEBUG_TARGETS += dbg%.o c s
# We automatically generate rules for any file mentioned in AUTO_SRCS
# using the following set of templates. It would be cleaner to use
# $(eval ...), but this function exists only in GNU make >= 3.80.
@@ -157,7 +342,7 @@ autosrcs :
#
define src_template
@$(ECHO) "Generating Makefile rules for $(1)"
@$(ECHO) " [DEPS] $(1)"
@$(MKDIR) -p $(dir $(2))
@$(RM) $(2)
@$(TOUCH) $(2)
@@ -182,13 +367,13 @@ define obj_template
-Wno-error -MM $(1) -MT "$(4)_DEPS" -MG -MP | \
sed 's/_DEPS\s*:/_DEPS =/' >> $(2)
@$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
'\n\t$$(RULE_$(3))\n' \
'\nBOBJS += $$(BIN)/$(4).o\n' \
$(foreach TGT,$(DEBUG_TARGETS), \
$(if $(RULE_$(3)_to_$(TGT)), \
'\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
'\n\t$$(RULE_$(3)_to_$(TGT))\n' \
'\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
'\n$(2) : $$($(4)_DEPS)\n' \
@@ -205,7 +390,11 @@ $(BIN)/deps/%.d : % $(MAKEDEPS) $(PARSEROM)
# Calculate and include the list of Makefile rules files
#
AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
ifdef NEED_DEPS
ifneq ($(AUTO_DEPS),)
-include $(AUTO_DEPS)
endif
endif
autodeps :
@$(ECHO) $(AUTO_DEPS)
VERYCLEANUP += $(BIN)/deps
@@ -220,13 +409,31 @@ drivers :
roms :
@$(ECHO) $(ROMS)
# Embedded binary
$(BIN)/embedimg.bin: $(EMBEDDED_IMAGE)
$(QM)$(ECHO) " [COPY] $@"
$(Q)$(CP) -f $(EMBEDDED_IMAGE) $@
# List of embedded images included in the last build of embedded.o.
# This is needed in order to correctly rebuild embedded.o whenever the
# list of objects changes.
#
EMBEDDED_LIST := $(BIN)/.embedded.list
ifeq ($(wildcard $(EMBEDDED_LIST)),)
EMBEDDED_LIST_IMAGE :=
else
EMBEDDED_LIST_IMAGE := $(shell cat $(EMBEDDED_LIST))
endif
ifneq ($(EMBEDDED_LIST_IMAGE),$(EMBEDDED_IMAGE))
$(shell $(ECHO) "$(EMBEDDED_IMAGE)" > $(EMBEDDED_LIST))
endif
$(BIN)/embed.o: $(BIN)/embedimg.bin
CFLAGS_embed = -DEMBEDIMG=\"$(BIN)/embedimg.bin\"
$(EMBEDDED_LIST) :
VERYCLEANUP += $(EMBEDDED_LIST)
EMBEDDED_FILES := $(subst $(COMMA), ,$(EMBEDDED_IMAGE))
EMBED_ALL := $(foreach i,$(shell seq 1 $(words $(EMBEDDED_FILES))),\
EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
\"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
$(BIN)/embedded.o : $(EMBEDDED_FILES) $(EMBEDDED_LIST)
CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
# Generate the NIC file from the parsed source files. The NIC file is
# only for rom-o-matic.
@@ -237,7 +444,7 @@ $(BIN)/NIC : $(AUTO_DEPS)
'it is only for rom-o-matic' >> $@
@$(ECHO) >> $@
@perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
CLEANUP += $(BIN)/NIC
CLEANUP += $(BIN)/NIC # Doesn't match the $(BIN)/*.* pattern
# Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
# derive the variables:
@@ -305,7 +512,6 @@ TGT_MAKEROM_FLAGS = $(strip $(MAKEROM_FLAGS_$(TGT_ROM_NAME)) \
# Calculate list of debugging versions of objects to be included in
# the target.
#
COMMA := ,
DEBUG_LIST = $(subst $(COMMA), ,$(DEBUG))
DEBUG_OBJ_LEVEL = $(firstword $(word 2,$(subst :, ,$(1))) 1)
DEBUG_OBJ_BASE = $(word 1,$(subst :, ,$(1))).dbg$(call DEBUG_OBJ_LEVEL,$(1))
@@ -342,8 +548,13 @@ $(BIN)/%.info :
# in order to correctly rebuild blib whenever the list of objects
# changes.
#
BLIB_LIST = $(BIN)/.blib.list
ifneq ($(shell cat $(BLIB_LIST)),$(BLIB_OBJS))
BLIB_LIST := $(BIN)/.blib.list
ifeq ($(wildcard $(BLIB_LIST)),)
BLIB_LIST_OBJS :=
else
BLIB_LIST_OBJS := $(shell cat $(BLIB_LIST))
endif
ifneq ($(BLIB_LIST_OBJS),$(BLIB_OBJS))
$(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
endif
@@ -396,10 +607,6 @@ $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
$(QM)$(ECHO) " [ZBIN] $@"
$(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
# Build bochs symbol table
$(BIN)/%.bxs : $(BIN)/%.tmp
$(NM) $< | cut -d" " -f1,3 > $@
# Rules for each media format. These are generated and placed in an
# external Makefile fragment. We could do this via $(eval ...), but
# that would require make >= 3.80.
@@ -435,7 +642,7 @@ automedia :
#
define media_template
@$(ECHO) "Generating Makefile rules for $(1) media"
@$(ECHO) " [MEDIADEPS] $(1)"
@$(MKDIR) -p $(dir $(2))
@$(RM) $(2)
@$(TOUCH) $(2)
@@ -459,7 +666,20 @@ $(BIN)/deps/%.media.d : $(MAKEDEPS)
MEDIA_DEPS = $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
mediadeps :
@$(ECHO) $(MEDIA_DEPS)
ifdef NEED_DEPS
ifneq ($(MEDIA_DEPS),)
-include $(MEDIA_DEPS)
endif
endif
# Wrap up binary blobs (for embedded images)
#
$(BIN)/%.o : payload/%.img
$(QM)echo " [WRAP] $@"
$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
--defsym obj_$*=0
BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
# The "allXXXs" targets for each suffix
#
@@ -472,15 +692,23 @@ allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%
$(BIN)/etherboot.% : $(BIN)/gpxe.%
ln -sf $(notdir $<) $@
# Wrap up binary blobs
endif # defined(BIN)
###############################################################################
#
$(BIN)/%.o : payload/%.img
$(QM)echo " [WRAP] $@"
$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
--defsym obj_$*=0
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
# the automatic build system and varies by target; it includes the
# "-p 0x1234,0x5678" string to set the PCI IDs.
#
FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
-i$(IDENT) -s 0 $@
BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
# Some ROMs require specific flags to be passed to makerom.pl
#
MAKEROM_FLAGS_3c503 = -3
###############################################################################
#
# The compression utilities
#
$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
@@ -494,6 +722,29 @@ $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
$(Q)$(HOST_CC) -O2 -o $@ $<
CLEANUP += $(ZBIN)
###############################################################################
#
# The EFI image converter
#
$(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) -DMDE_CPU_IA32 -idirafter include -O2 \
-o $@ $< -lbfd -liberty
CLEANUP += $(ELF2EFI32)
$(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) -DMDE_CPU_X64 -idirafter include -O2 \
-o $@ $< -lbfd -liberty
CLEANUP += $(ELF2EFI64)
$(EFIROM) : util/efirom.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
CLEANUP += $(EFIROM)
###############################################################################
#
# Auto-incrementing build serial number. Append "bs" to your list of
# build targets to get a serial number printed at the end of the
# build. Enable -DBUILD_SERIAL in order to see it when the code runs.
@@ -517,27 +768,30 @@ bs : $(BUILDSERIAL_NOW)
@$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
@$(ECHO) "Build serial number is $(shell cat $<)"
# List of available architectures
###############################################################################
#
ARCHS = $(filter-out CVS,$(patsubst arch/%,%,$(wildcard arch/*)))
archs :
@$(ECHO) $(ARCHS)
OTHER_ARCHS = $(filter-out $(ARCH),$(ARCHS))
otherarchs :
@$(ECHO) $(OTHER_ARCHS)
# Build the TAGS file for emacs
# Build the TAGS file(s) for emacs
#
TAGS : TAGS.$(ARCH)
TAGS :
ctags -e -R -f $@ --exclude=bin
TAGS.$(ARCH) :
ctags -e -R -f $@ --exclude=bin \
$(foreach ARCH,$(OTHER_ARCHS),--exclude=arch/$(ARCH))
CLEANUP += TAGS*
CLEANUP += TAGS
###############################################################################
#
# Force rebuild for any given target
#
%.rebuild :
rm -f $*
$(Q)$(MAKE) $*
###############################################################################
#
# Symbol table checks
#
ifdef BIN
SYMTAB = $(BIN)/symtab
$(SYMTAB) : $(BLIB)
$(OBJDUMP) -w -t $< > $@
@@ -547,14 +801,27 @@ CLEANUP += $(BIN)/symtab
symcheck : $(SYMTAB)
$(SYMCHECK) $<
# Force rebuild for any given target
#
$(BIN)/%.rebuild :
rm -f $(BIN)/$*
$(MAKE) $(MAKEFLAGS) $(BIN)/$*
endif # defined(BIN)
###############################################################################
#
# Build bochs symbol table
#
ifdef BIN
$(BIN)/%.bxs : $(BIN)/%.tmp
$(NM) $< | cut -d" " -f1,3 > $@
endif # defined(BIN)
###############################################################################
#
# Documentation
#
ifdef BIN
$(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
-e 's{\@BIN\@}{$(BIN)}; ' \
@@ -578,6 +845,10 @@ docview :
$(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
fi
endif # defined(BIN)
###############################################################################
#
# Clean-up
#
clean :
@@ -585,19 +856,3 @@ clean :
veryclean : clean
$(RM) -r $(VERYCLEANUP)
# Make clean tarballs for release
tarball : ../VERSION
($(ECHO) -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
$(RM) -r /tmp/$(USER)/gpxe-$(VERSION)
mkdir -p /tmp/$(USER)/gpxe-$(VERSION)
cp -rP .. /tmp/$(USER)/gpxe-$(VERSION)
( cd /tmp/$(USER)/gpxe-$(VERSION)/src ; $(MAKE) veryclean ; $(RM) -r bin/deps )
( cd /tmp/$(USER); tar cf /tmp/$(USER)/gpxe-$(VERSION).tar --exclude ".git*" --exclude "#*" \
--exclude "*~" gpxe-$(VERSION) )
bzip2 -9 < /tmp/$(USER)/gpxe-$(VERSION).tar > /tmp/$(USER)/gpxe-$(VERSION).tar.bz2
gzip -9 < /tmp/$(USER)/gpxe-$(VERSION).tar > /tmp/$(USER)/gpxe-$(VERSION).tar.gz
$(RM) -r /tmp/$(USER)/gpxe-$(VERSION)
$(RM) /tmp/$(USER)/gpxe-$(VERSION).tar
( cd /tmp/$(USER) ; tar -zxf /tmp/$(USER)/gpxe-$(VERSION).tar.gz )
-148
View File
@@ -1,148 +0,0 @@
# -*- makefile -*-
##############################################################################
##############################################################################
#
# IMPORTANT!
#
# The use of this file to set options that affect only single object
# files is deprecated, because changing anything in this file results
# in a complete rebuild, which is slow. All options are gradually
# being migrated to config.h, which does not suffer from this problem.
#
# Only options that affect the entire build (e.g. overriding the $(CC)
# Makefile variable) should be placed in here.
#
##############################################################################
##############################################################################
# Config for i386 Etherboot
#
# Do not delete the tag OptionDescription and /OptionDescription
# It is used to automatically generate the documentation.
#
# @OptionDescrition@
#
# BIOS interface options:
#
# -DPCBIOS
# Compile in support for the normal pcbios
# -DLINUXBIOS
# Compile in support for LinuxBIOS
# -DBBS_BUT_NOT_PNP_COMPLIANT
# Some BIOSes claim to be PNP but they don't conform
# to the BBS spec which specifies that ES:DI must
# point to the string $PnP on entry. This option
# works around those. This option must be added to
# LCONFIG.
# -DNO_DELAYED_INT
# Take control as soon as BIOS detects the ROM.
# Normally hooks onto INT18H or INT19H. Use only if you
# have a very non-conformant BIOS as it bypasses
# BIOS initialisation of devices. This only works for
# legacy ROMs, i.e. PCI_PNP_HEADER not defined.
# This option was formerly called NOINT19H.
# -DBOOT_INT18H
# Etherboot normally hooks onto INT19H for legacy ROMs.
# You can choose to hook onto INT18H (BASIC interpreter
# entry point) instead. This entry point is used when
# all boot devices have been exhausted. This option must
# be added to LCONFIG.
# -DCONFIG_PCI_DIRECT
# Define this for PCI BIOSes that do not implement
# BIOS32 or not correctly. Normally not needed.
# Only works for BIOSes of a certain era.
# -DCONFIG_TSC_CURRTICKS
# Uses the processor time stamp counter instead of reading
# the BIOS time counter. This allows Etherboot to work
# even without a BIOS. This only works on late model
# 486s and above.
# -DCONFIG_NO_TIMER2
# Some systems do not have timer2 implemented.
# If you have a RTC this will allow you to roughly calibrate
# it using outb instructions.
#
# Extended cpu options
# -DCONFIG_X86_64
# Compile in support for booting x86_64 64bit binaries.
#
# PXE loader options:
#
# -DPXELOADER_KEEP_ALL
# Prevent PXE loader (prefix) from unloading the
# PXE stack. You will want to use this if, for
# example, you are booting via PXE-on-floppy.
# You may want to use it under certain
# circumstances when using the Etherboot UNDI
# driver; these are complex and best practice is
# not yet established.
#
# Obscure options you probably don't need to touch:
#
# -DIGNORE_E820_MAP
# Ignore the memory map returned by the E820 BIOS
# call. May be necessary on some buggy BIOSes.
# -DT503_AUI
# Use AUI by default on 3c503 cards.
# -DFLATTEN_REAL_MODE
# Use 4GB segment limits when calling out to or
# returning to real-mode code. This is necessary to
# work around some buggy code (e.g. OpenBSD's pxeboot)
# that uses flat real-mode without being sufficiently
# paranoid about the volatility of its segment limits.
#
# @/OptionDescription@
# BIOS select don't change unless you know what you are doing
# CFLAGS+= -DPCBIOS
# Compile in k8/hammer support
# CFLAGS+= -DCONFIG_X86_64
# Options to make a version of Etherboot that will work under linuxBIOS.
# CFLAGS+= -DLINUXBIOS -DCONFIG_TSC_CURRTICKS -DCONSOLE_SERIAL -DCOMCONSOLE=0x3f8 -DCOMPRESERVE -DCONFIG_PCI_DIRECT -DELF_IMAGE
# These options affect the loader that is prepended to the Etherboot image
# LCONFIG+= -DBBS_BUT_NOT_PNP_COMPLIANT
# LCONFIG+= -DBOOT_INT18H
# Produce code that will work with OpenBSD's pxeboot
# CFLAGS+= -DFLATTEN_REAL_MODE
CFLAGS+= -fstrength-reduce -fomit-frame-pointer -march=i386
# Squeeze the code in as little space as possible.
# gcc3 needs a different syntax to gcc2 if you want to avoid spurious warnings.
GCC_VERSION = $(subst ., ,$(shell $(CC) -dumpversion))
GCC_MAJORVERSION = $(firstword $(GCC_VERSION))
ifeq ($(GCC_MAJORVERSION),2)
CFLAGS+= -malign-jumps=1 -malign-loops=1 -malign-functions=1
else
CFLAGS+= -falign-jumps=1 -falign-loops=1 -falign-functions=1
endif
# this is almost always a win. the kernel uses it, too.
CFLAGS+= -mpreferred-stack-boundary=2
# use regparm for all functions - C functions called from assembly (or
# vice versa) need __cdecl now
CFLAGS+= -mregparm=3
# use -mrtd (same __cdecl requirements as above)
CFLAGS+= -mrtd
# this is the logical complement to -mregparm=3.
# it doesn't currently buy us anything, but if anything ever tries
# to return small structures, let's be prepared
CFLAGS+= -freg-struct-return
LDFLAGS+= -N --no-check-sections
ifeq "$(shell uname -s)" "FreeBSD"
CFLAGS+= -DIMAGE_FREEBSD -DELF_IMAGE -DAOUT_IMAGE
endif
# An alternate location for isolinux.bin can be set here
# ISOLINUX_BIN=/path/to/isolinux.bin
+72 -64
View File
@@ -1,3 +1,59 @@
# Force i386-only instructions
#
CFLAGS += -march=i386
# Code size reduction.
#
CFLAGS += -fstrength-reduce -fomit-frame-pointer
# Code size reduction. gcc3 needs a different syntax to gcc2 if you
# want to avoid spurious warnings.
#
GCC_VERSION := $(subst ., ,$(shell $(CC) -dumpversion))
GCC_MAJOR := $(firstword $(GCC_VERSION))
ifeq ($(GCC_MAJOR),2)
CFLAGS += -malign-jumps=1 -malign-loops=1 -malign-functions=1
else
CFLAGS += -falign-jumps=1 -falign-loops=1 -falign-functions=1
endif
# Code size reduction. This is almost always a win. The kernel uses it, too.
#
CFLAGS += -mpreferred-stack-boundary=2
# Code size reduction. Use regparm for all functions - C functions
# called from assembly (or vice versa) need __asmcall now
#
CFLAGS += -mregparm=3
# Code size reduction. Use -mrtd (same __asmcall requirements as above)
CFLAGS += -mrtd
# Code size reduction. This is the logical complement to -mregparm=3.
# It doesn't currently buy us anything, but if anything ever tries to
# return small structures, let's be prepared
#
CFLAGS += -freg-struct-return
# Force 32-bit code even on an x86-64 machine
#
CFLAGS += -m32
ASFLAGS += --32
ifeq ($(HOST_OS),FreeBSD)
LDFLAGS += -m elf_i386_fbsd
else
LDFLAGS += -m elf_i386
endif
# EFI requires -fshort-wchar, and nothing else currently uses wchar_t
#
CFLAGS += -fshort-wchar
# We need to undefine the default macro "i386" when compiling .S
# files, otherwise ".arch i386" translates to ".arch 1"...
#
CFLAGS += -Ui386
# Locations of utilities
#
ISOLINUX_BIN = /usr/lib/syslinux/isolinux.bin
@@ -22,85 +78,37 @@ NON_AUTO_SRCS += arch/i386/core/wince_loader.c
# unnrv2b.S is used to generate a 16-bit as well as a 32-bit object.
#
OBJS_unnrv2b = unnrv2b unnrv2b16
CFLAGS_unnrv2b16 = -DCODE16
OBJS_unnrv2b = unnrv2b unnrv2b16
CFLAGS_unnrv2b16 = -DCODE16
# We need to undefine the default macro "i386" when compiling .S
# files, otherwise ".arch i386" translates to ".arch 1"...
# Include common x86 Makefile
#
CFLAGS_S += -Ui386
MAKEDEPS += arch/x86/Makefile
include arch/x86/Makefile
# The i386 linker script
# Include platform-specific Makefile
#
LDSCRIPT = arch/i386/scripts/i386.lds
# Media types.
#
MEDIA += rom
MEDIA += pxe
MEDIA += kpxe
MEDIA += elf
MEDIA += elfd
MEDIA += lmelf
MEDIA += lmelfd
MEDIA += lkrn
MEDIA += bImage
MEDIA += dsk
MEDIA += nbi
MEDIA += hd
MEDIA += raw
MEDIA += com
MEDIA += exe
# Special target for building Master Boot Record binary
$(BIN)/mbr.bin : $(BIN)/mbr.o
$(OBJCOPY) -O binary $< $@
MAKEDEPS += arch/i386/Makefile.$(PLATFORM)
include arch/i386/Makefile.$(PLATFORM)
# Some suffixes (e.g. %.fd0) are generated directly from other
# finished files (e.g. %.dsk), rather than having their own prefix.
# rule to write disk images to /dev/fd0
NON_AUTO_MEDIA += fd0
NON_AUTO_MEDIA += fd0
%fd0 : %dsk
dd if=$< bs=512 conv=sync of=/dev/fd0
sync
$(QM)$(ECHO) " [DD] $@"
$(Q)dd if=$< bs=512 conv=sync of=/dev/fd0
$(Q)sync
# rule to create padded disk images
NON_AUTO_MEDIA += pdsk
NON_AUTO_MEDIA += pdsk
%pdsk : %dsk
cp $< $@
$(PERL) ./util/dskpad.pl $@
# rule to make a non-emulation ISO boot image
NON_AUTO_MEDIA += iso
%iso: %lkrn util/geniso
ISOLINUX_BIN=$(ISOLINUX_BIN) bash util/geniso $@ $<
# rule to make a floppy emulation ISO boot image
NON_AUTO_MEDIA += liso
%liso: %lkrn util/genliso
bash util/genliso $@ $<
# rule to make a USB disk image
$(BIN)/usbdisk.bin : $(BIN)/usbdisk.o
$(OBJCOPY) -O binary $< $@
NON_AUTO_MEDIA += usb
%usb: $(BIN)/usbdisk.bin %hd
cat $^ > $@
$(QM)$(ECHO) " [DSKPAD] $@"
$(Q)cp $< $@
$(Q)$(PERL) ./util/dskpad.pl $@
# Add NON_AUTO_MEDIA to the media list, so that they show up in the
# output of "make"
#
MEDIA += $(NON_AUTO_MEDIA)
# Shortcut to allow typing just
# make bin-kir/%
# rather than
# make -f arch/i386/kir-Makefile bin-kir/%
# for building a KEEP_IT_REAL flavour.
#
$(BIN)-kir/% : kir-target
$(MAKE) -f arch/i386/kir-Makefile $(MAKECMDGOALS)
.PHONY : kir-target
+10
View File
@@ -0,0 +1,10 @@
# -*- makefile -*- : Force emacs to use Makefile mode
# Specify EFI image builder
#
ELF2EFI = $(ELF2EFI32)
# Include generic EFI Makefile
#
MAKEDEPS += arch/x86/Makefile.efi
include arch/x86/Makefile.efi
+55
View File
@@ -0,0 +1,55 @@
# -*- makefile -*- : Force emacs to use Makefile mode
# The i386 linker script
#
LDSCRIPT = arch/i386/scripts/i386.lds
# Stop ld from complaining about our customised linker script
#
LDFLAGS += -N --no-check-sections
# Media types.
#
MEDIA += rom
MEDIA += pxe
MEDIA += kpxe
MEDIA += kkpxe
MEDIA += elf
MEDIA += elfd
MEDIA += lmelf
MEDIA += lmelfd
MEDIA += lkrn
MEDIA += bImage
MEDIA += dsk
MEDIA += nbi
MEDIA += hd
MEDIA += raw
MEDIA += com
MEDIA += exe
# rule to make a non-emulation ISO boot image
NON_AUTO_MEDIA += iso
%iso: %lkrn util/geniso
$(QM)$(ECHO) " [GENISO] $@"
$(Q)ISOLINUX_BIN=$(ISOLINUX_BIN) bash util/geniso $@ $<
# rule to make a floppy emulation ISO boot image
NON_AUTO_MEDIA += liso
%liso: %lkrn util/genliso
$(QM)$(ECHO) " [GENLISO] $@"
$(Q)bash util/genliso $@ $<
# Special target for building Master Boot Record binary
$(BIN)/mbr.bin : $(BIN)/mbr.o
$(QM)$(ECHO) " [OBJCOPY] $@"
$(Q)$(OBJCOPY) -O binary $< $@
# rule to make a USB disk image
$(BIN)/usbdisk.bin : $(BIN)/usbdisk.o
$(QM)$(ECHO) " [OBJCOPY] $@"
$(Q)$(OBJCOPY) -O binary $< $@
NON_AUTO_MEDIA += usb
%usb: $(BIN)/usbdisk.bin %hd
$(QM)$(ECHO) " [FINISH] $@"
$(Q)cat $^ > $@
+23
View File
@@ -0,0 +1,23 @@
#include <stdio.h>
#include <realmode.h>
void __asmcall _dump_regs ( struct i386_all_regs *ix86 ) {
__asm__ __volatile__ (
TEXT16_CODE ( ".globl dump_regs\n\t"
"\ndump_regs:\n\t"
"pushl $_dump_regs\n\t"
"pushw %%cs\n\t"
"call prot_call\n\t"
"addr32 leal 4(%%esp), %%esp\n\t"
"ret\n\t" ) : : );
printf ( "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
"ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n"
"CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x\n",
ix86->regs.eax, ix86->regs.ebx, ix86->regs.ecx,
ix86->regs.edx, ix86->regs.esi, ix86->regs.edi,
ix86->regs.ebp, ix86->regs.esp,
ix86->segs.cs, ix86->segs.ss, ix86->segs.ds,
ix86->segs.es, ix86->segs.fs, ix86->segs.gs );
}
+4 -4
View File
@@ -2,7 +2,7 @@
* Interrupt Descriptor Table (IDT) setup and interrupt handlers for GDB stub.
*/
#include <virtaddr.h>
#include <librm.h>
#define SIZEOF_I386_REGS 32
#define SIZEOF_I386_FLAGS 4
@@ -11,7 +11,7 @@
* Interrupt Descriptor Table
****************************************************************************
*/
.section ".data16"
.section ".data16", "aw", @progbits
.globl idtr
idtr:
idt_limit:
@@ -68,7 +68,7 @@ idt_fixed:
* Destroys %ax, %bx, and %di.
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
.code16
.globl idt_init
idt_init:
@@ -100,7 +100,7 @@ idt_init:
* Interrupt handlers
****************************************************************************
*/
.section ".text"
.section ".text", "ax", @progbits
.code32
/* POSIX signal numbers for reporting traps to GDB */
+4 -4
View File
@@ -19,7 +19,7 @@
#include <stddef.h>
#include <stdio.h>
#include <assert.h>
#include <virtaddr.h>
#include <gpxe/uaccess.h>
#include <gpxe/gdbstub.h>
#include <gdbmach.h>
@@ -60,10 +60,10 @@ static struct hwbp *gdbmach_find_hwbp ( int type, unsigned long addr, size_t len
}
static void gdbmach_commit_hwbp ( struct hwbp *bp ) {
int regnum = bp - hwbps;
unsigned int regnum = bp - hwbps;
/* Set breakpoint address */
assert ( regnum >= 0 && regnum < sizeof hwbps / sizeof hwbps [ 0 ] );
assert ( regnum < ( sizeof hwbps / sizeof hwbps [ 0 ] ) );
switch ( regnum ) {
case 0:
__asm__ __volatile__ ( "movl %0, %%dr0\n" : : "r" ( bp->addr ) );
@@ -142,7 +142,7 @@ static void gdbmach_enable_hwbps ( void ) {
__asm__ __volatile__ ( "movl %0, %%dr7\n" : : "r" ( dr7 ) );
}
__cdecl void gdbmach_handler ( int signo, gdbreg_t *regs ) {
__asmcall void gdbmach_handler ( int signo, gdbreg_t *regs ) {
gdbmach_disable_hwbps();
gdbstub_handler ( signo, regs );
gdbmach_enable_hwbps();
-12
View File
@@ -1,12 +0,0 @@
#include <realmode.h>
#include <bios.h>
/**************************************************************************
* Save power by halting the CPU until the next interrupt
**************************************************************************/
void cpu_nap ( void ) {
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
"hlt\n\t"
"cli\n\t" ) : : );
}
+1
View File
@@ -16,6 +16,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gpxe/io.h>
#include <pic8259.h>
/** @file
+87
View File
@@ -0,0 +1,87 @@
/*
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
*
* RDTSC timer
*
*/
#include <assert.h>
#include <gpxe/timer.h>
#include <gpxe/timer2.h>
/**
* Number of TSC ticks per microsecond
*
* This is calibrated on the first use of the timer.
*/
static unsigned long rdtsc_ticks_per_usec;
/**
* Delay for a fixed number of microseconds
*
* @v usecs Number of microseconds for which to delay
*/
static void rdtsc_udelay ( unsigned long usecs ) {
unsigned long start;
unsigned long elapsed;
/* Sanity guard, since we may divide by this */
if ( ! usecs )
usecs = 1;
start = currticks();
if ( rdtsc_ticks_per_usec ) {
/* Already calibrated; busy-wait until done */
do {
elapsed = ( currticks() - start );
} while ( elapsed < ( usecs * rdtsc_ticks_per_usec ) );
} else {
/* Not yet calibrated; use timer2 and calibrate
* based on result.
*/
timer2_udelay ( usecs );
elapsed = ( currticks() - start );
rdtsc_ticks_per_usec = ( elapsed / usecs );
DBG ( "RDTSC timer calibrated: %ld ticks in %ld usecs "
"(%ld MHz)\n", elapsed, usecs,
( rdtsc_ticks_per_usec << TSC_SHIFT ) );
}
}
/**
* Get number of ticks per second
*
* @ret ticks_per_sec Number of ticks per second
*/
static unsigned long rdtsc_ticks_per_sec ( void ) {
/* Calibrate timer, if not already done */
if ( ! rdtsc_ticks_per_usec )
udelay ( 1 );
/* Sanity check */
assert ( rdtsc_ticks_per_usec != 0 );
return ( rdtsc_ticks_per_usec * 1000 * 1000 );
}
PROVIDE_TIMER ( rdtsc, udelay, rdtsc_udelay );
PROVIDE_TIMER_INLINE ( rdtsc, currticks );
PROVIDE_TIMER ( rdtsc, ticks_per_sec, rdtsc_ticks_per_sec );
+6 -6
View File
@@ -1,4 +1,4 @@
#include <io.h>
#include <gpxe/io.h>
#include <registers.h>
#include <gpxe/memmap.h>
@@ -18,8 +18,8 @@ extern char _max_align[];
#define max_align ( ( unsigned int ) _max_align )
/* Linker symbols */
extern char _text[];
extern char _end[];
extern char _textdata[];
extern char _etextdata[];
/* within 1MB of 4GB is too close.
* MAX_ADDR is the maximum address we can easily do DMA to.
@@ -39,7 +39,7 @@ extern char _end[];
* address space, and returns the physical address of the new location
* to the prefix in %edi.
*/
__cdecl void relocate ( struct i386_all_regs *ix86 ) {
__asmcall void relocate ( struct i386_all_regs *ix86 ) {
struct memory_map memmap;
unsigned long start, end, size, padded_size;
unsigned long new_start, new_end;
@@ -47,8 +47,8 @@ __cdecl void relocate ( struct i386_all_regs *ix86 ) {
/* Get memory map and current location */
get_memmap ( &memmap );
start = virt_to_phys ( _text );
end = virt_to_phys ( _end );
start = virt_to_phys ( _textdata );
end = virt_to_phys ( _etextdata );
size = ( end - start );
padded_size = ( size + max_align - 1 );
+1 -1
View File
@@ -4,7 +4,7 @@
* Internal stack
****************************************************************************
*/
.section ".stack"
.section ".stack", "aw", @nobits
.align 8
.globl _stack
_stack:
+1 -1
View File
@@ -4,7 +4,7 @@
* Internal stack
****************************************************************************
*/
.section ".stack16"
.section ".stack16", "aw", @nobits
.align 8
.globl _stack16
_stack16:
-325
View File
@@ -1,325 +0,0 @@
#include "virtaddr.h"
.equ MSR_K6_EFER, 0xC0000080
.equ EFER_LME, 0x00000100
.equ X86_CR4_PAE, 0x00000020
.equ CR0_PG, 0x80000000
#ifdef GAS291
#define DATA32 data32;
#define ADDR32 addr32;
#define LJMPI(x) ljmp x
#else
#define DATA32 data32
#define ADDR32 addr32
/* newer GAS295 require #define LJMPI(x) ljmp *x */
#define LJMPI(x) ljmp x
#endif
/*
* NOTE: if you write a subroutine that is called from C code (gcc/egcs),
* then you only have to take care of %ebx, %esi, %edi and %ebp. These
* registers must not be altered under any circumstance. All other registers
* may be clobbered without any negative side effects. If you don't follow
* this rule then you'll run into strange effects that only occur on some
* gcc versions (because the register allocator may use different registers).
*
* All the data32 prefixes for the ljmp instructions are necessary, because
* the assembler emits code with a relocation address of 0. This means that
* all destinations are initially negative, which the assembler doesn't grok,
* because for some reason negative numbers don't fit into 16 bits. The addr32
* prefixes are there for the same reasons, because otherwise the memory
* references are only 16 bit wide. Theoretically they are all superfluous.
* One last note about prefixes: the data32 prefixes on all call _real_to_prot
* instructions could be removed if the _real_to_prot function is changed to
* deal correctly with 16 bit return addresses. I tried it, but failed.
*/
.text
.arch i386
.code32
/* This is a struct os_entry_regs */
.globl os_regs
os_regs: .space 56
/**************************************************************************
XSTART32 - Transfer control to the kernel just loaded
**************************************************************************/
.globl xstart32
xstart32:
/* Save the callee save registers */
movl %ebp, os_regs + 32
movl %esi, os_regs + 36
movl %edi, os_regs + 40
movl %ebx, os_regs + 44
/* save the return address */
popl %eax
movl %eax, os_regs + 48
/* save the stack pointer */
movl %esp, os_regs + 52
/* Get the new destination address */
popl %ecx
/* Store the physical address of xend on the stack */
movl $xend32, %ebx
addl virt_offset, %ebx
pushl %ebx
/* Store the destination address on the stack */
pushl $PHYSICAL_CS
pushl %ecx
/* Cache virt_offset */
movl virt_offset, %ebp
/* Switch to using physical addresses */
call _virt_to_phys
/* Save the target stack pointer */
movl %esp, os_regs + 12(%ebp)
leal os_regs(%ebp), %esp
/* Store the pointer to os_regs */
movl %esp, os_regs_ptr(%ebp)
/* Load my new registers */
popal
movl (-32 + 12)(%esp), %esp
/* Jump to the new kernel
* The lret switches to a flat code segment
*/
lret
.balign 4
.globl xend32
xend32:
/* Fixup %eflags */
nop
cli
cld
/* Load %esp with &os_regs + virt_offset */
.byte 0xbc /* movl $0, %esp */
os_regs_ptr:
.long 0
/* Save the result registers */
addl $32, %esp
pushal
/* Compute virt_offset */
movl %esp, %ebp
subl $os_regs, %ebp
/* Load the stack pointer and convert it to physical address */
movl 52(%esp), %esp
addl %ebp, %esp
/* Enable the virtual addresses */
leal _phys_to_virt(%ebp), %eax
call *%eax
/* Restore the callee save registers */
movl os_regs + 32, %ebp
movl os_regs + 36, %esi
movl os_regs + 40, %edi
movl os_regs + 44, %ebx
movl os_regs + 48, %edx
movl os_regs + 52, %esp
/* Get the C return value */
movl os_regs + 28, %eax
jmpl *%edx
#ifdef CONFIG_X86_64
.arch sledgehammer
/**************************************************************************
XSTART_lm - Transfer control to the kernel just loaded in long mode
**************************************************************************/
.globl xstart_lm
xstart_lm:
/* Save the callee save registers */
pushl %ebp
pushl %esi
pushl %edi
pushl %ebx
/* Cache virt_offset && (virt_offset & 0xfffff000) */
movl virt_offset, %ebp
movl %ebp, %ebx
andl $0xfffff000, %ebx
/* Switch to using physical addresses */
call _virt_to_phys
/* Initialize the page tables */
/* Level 4 */
leal 0x23 + pgt_level3(%ebx), %eax
leal pgt_level4(%ebx), %edi
movl %eax, (%edi)
/* Level 3 */
leal 0x23 + pgt_level2(%ebx), %eax
leal pgt_level3(%ebx), %edi
movl %eax, 0x00(%edi)
addl $4096, %eax
movl %eax, 0x08(%edi)
addl $4096, %eax
movl %eax, 0x10(%edi)
addl $4096, %eax
movl %eax, 0x18(%edi)
/* Level 2 */
movl $0xe3, %eax
leal pgt_level2(%ebx), %edi
leal 16384(%edi), %esi
pgt_level2_loop:
movl %eax, (%edi)
addl $8, %edi
addl $0x200000, %eax
cmp %esi, %edi
jne pgt_level2_loop
/* Point at the x86_64 page tables */
leal pgt_level4(%ebx), %edi
movl %edi, %cr3
/* Setup for the return from 64bit mode */
/* 64bit align the stack */
movl %esp, %ebx /* original stack pointer + 16 */
andl $0xfffffff8, %esp
/* Save original stack pointer + 16 */
pushl %ebx
/* Save virt_offset */
pushl %ebp
/* Setup for the jmp to 64bit long mode */
leal start_lm(%ebp), %eax
movl %eax, 0x00 + start_lm_addr(%ebp)
movl $LM_CODE_SEG, %eax
movl %eax, 0x04 + start_lm_addr(%ebp)
/* Setup for the jump out of 64bit long mode */
leal end_lm(%ebp), %eax
movl %eax, 0x00 + end_lm_addr(%ebp)
movl $FLAT_CODE_SEG, %eax
movl %eax, 0x04 + end_lm_addr(%ebp)
/* Enable PAE mode */
movl %cr4, %eax
orl $X86_CR4_PAE, %eax
movl %eax, %cr4
/* Enable long mode */
movl $MSR_K6_EFER, %ecx
rdmsr
orl $EFER_LME, %eax
wrmsr
/* Start paging, entering 32bit compatiblity mode */
movl %cr0, %eax
orl $CR0_PG, %eax
movl %eax, %cr0
/* Enter 64bit long mode */
ljmp *start_lm_addr(%ebp)
.code64
start_lm:
/* Load 64bit data segments */
movl $LM_DATA_SEG, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %ss
andq $0xffffffff, %rbx
/* Get the address to jump to */
movl 20(%rbx), %edx
andq $0xffffffff, %rdx
/* Get the argument pointer */
movl 24(%rbx), %ebx
andq $0xffffffff, %rbx
/* Jump to the 64bit code */
call *%rdx
/* Preserve the result */
movl %eax, %edx
/* Fixup %eflags */
cli
cld
/* Switch to 32bit compatibility mode */
ljmp *end_lm_addr(%rip)
.code32
end_lm:
/* Disable paging */
movl %cr0, %eax
andl $~CR0_PG, %eax
movl %eax, %cr0
/* Disable long mode */
movl $MSR_K6_EFER, %ecx
rdmsr
andl $~EFER_LME, %eax
wrmsr
/* Disable PAE */
movl %cr4, %eax
andl $~X86_CR4_PAE, %eax
movl %eax, %cr4
/* Compute virt_offset */
popl %ebp
/* Compute the original stack pointer + 16 */
popl %ebx
movl %ebx, %esp
/* Enable the virtual addresses */
leal _phys_to_virt(%ebp), %eax
call *%eax
/* Restore the callee save registers */
popl %ebx
popl %esi
popl %edi
popl %ebp
/* Get the C return value */
movl %edx, %eax
/* Return */
ret
.arch i386
#endif /* CONFIG_X86_64 */
#ifdef CONFIG_X86_64
.section ".bss"
.p2align 12
/* Include a dummy space in case we are loaded badly aligned */
.space 4096
/* Reserve enough space for a page table convering 4GB with 2MB pages */
pgt_level4:
.space 4096
pgt_level3:
.space 4096
pgt_level2:
.space 16384
start_lm_addr:
.space 8
end_lm_addr:
.space 8
#endif
@@ -12,12 +12,11 @@
*/
#include <stddef.h>
#include <bits/timer2.h>
#include <gpxe/timer.h>
#include <io.h>
#include <gpxe/timer2.h>
#include <gpxe/io.h>
/* Timers tick over at this rate */
#define TIMER2_TICK_RATE 1193180U
#define TIMER2_TICKS_PER_SEC 1193180U
/* Parallel Peripheral Controller Port B */
#define PPC_PORTB 0x61
@@ -52,8 +51,7 @@
#define BINARY_COUNT 0x00
#define BCD_COUNT 0x01
static void load_timer2(unsigned int ticks)
{
static void load_timer2 ( unsigned int ticks ) {
/*
* Now let's take care of PPC channel 2
*
@@ -75,15 +73,13 @@ static void load_timer2(unsigned int ticks)
outb(ticks >> 8, TIMER2_PORT);
}
static int timer2_running(void)
{
static int timer2_running ( void ) {
return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
}
void i386_timer2_udelay(unsigned int usecs)
{
load_timer2((usecs * TIMER2_TICK_RATE)/USECS_IN_SEC);
while (timer2_running())
;
void timer2_udelay ( unsigned long usecs ) {
load_timer2 ( ( usecs * TIMER2_TICKS_PER_SEC ) / ( 1000 * 1000 ) );
while (timer2_running()) {
/* Do nothing */
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
#include "stddef.h"
#include "string.h"
#include "io.h"
#include <gpxe/io.h>
#include "console.h"
#include <gpxe/init.h>
#include "vga.h"
+1 -1
View File
@@ -4,7 +4,7 @@
*
*/
#include "virtaddr.h"
#include "librm.h"
.arch i386
.text
+94
View File
@@ -0,0 +1,94 @@
/*
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gpxe/io.h>
#include <gpxe/x86_io.h>
/** @file
*
* gPXE I/O API for x86
*
*/
/**
* Read 64-bit qword from memory-mapped device
*
* @v io_addr I/O address
* @ret data Value read
*
* This routine uses MMX instructions.
*/
static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
uint64_t data;
__asm__ __volatile__ ( "pushl %%edx\n\t"
"pushl %%eax\n\t"
"movq (%1), %%mm0\n\t"
"movq %%mm0, (%%esp)\n\t"
"popl %%eax\n\t"
"popl %%edx\n\t"
"emms\n\t"
: "=A" ( data ) : "r" ( io_addr ) );
return data;
}
/**
* Write 64-bit qword to memory-mapped device
*
* @v data Value to write
* @v io_addr I/O address
*
* This routine uses MMX instructions.
*/
static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
__asm__ __volatile__ ( "pushl %%edx\n\t"
"pushl %%eax\n\t"
"movq (%%esp), %%mm0\n\t"
"movq %%mm0, (%1)\n\t"
"popl %%eax\n\t"
"popl %%edx\n\t"
"emms\n\t"
: : "A" ( data ), "r" ( io_addr ) );
}
PROVIDE_IOAPI_INLINE ( x86, phys_to_bus );
PROVIDE_IOAPI_INLINE ( x86, bus_to_phys );
PROVIDE_IOAPI_INLINE ( x86, ioremap );
PROVIDE_IOAPI_INLINE ( x86, iounmap );
PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
PROVIDE_IOAPI_INLINE ( x86, readb );
PROVIDE_IOAPI_INLINE ( x86, readw );
PROVIDE_IOAPI_INLINE ( x86, readl );
PROVIDE_IOAPI ( x86, readq, x86_readq );
PROVIDE_IOAPI_INLINE ( x86, writeb );
PROVIDE_IOAPI_INLINE ( x86, writew );
PROVIDE_IOAPI_INLINE ( x86, writel );
PROVIDE_IOAPI ( x86, writeq, x86_writeq );
PROVIDE_IOAPI_INLINE ( x86, inb );
PROVIDE_IOAPI_INLINE ( x86, inw );
PROVIDE_IOAPI_INLINE ( x86, inl );
PROVIDE_IOAPI_INLINE ( x86, outb );
PROVIDE_IOAPI_INLINE ( x86, outw );
PROVIDE_IOAPI_INLINE ( x86, outl );
PROVIDE_IOAPI_INLINE ( x86, insb );
PROVIDE_IOAPI_INLINE ( x86, insw );
PROVIDE_IOAPI_INLINE ( x86, insl );
PROVIDE_IOAPI_INLINE ( x86, outsb );
PROVIDE_IOAPI_INLINE ( x86, outsw );
PROVIDE_IOAPI_INLINE ( x86, outsl );
PROVIDE_IOAPI_INLINE ( x86, iodelay );
PROVIDE_IOAPI_INLINE ( x86, mb );
+2 -4
View File
@@ -10,11 +10,9 @@
.text
.arch i386
.section ".text16", "ax", @progbits
.section ".data16", "aw", @progbits
.code16
.section ".text16"
.section ".text16", "ax", @progbits
.globl undiisr
undiisr:
@@ -75,7 +73,7 @@ exit: /* Restore registers and return */
popw %ds
iret
.section ".data16"
.section ".data16", "aw", @progbits
undinet_params:
status: .word 0
funcflag: .word 0
+37 -24
View File
@@ -23,6 +23,7 @@
#include <biosint.h>
#include <pnpbios.h>
#include <basemem_packet.h>
#include <gpxe/io.h>
#include <gpxe/iobuf.h>
#include <gpxe/netdevice.h>
#include <gpxe/if_ether.h>
@@ -481,8 +482,7 @@ static void undinet_poll ( struct net_device *netdev ) {
undi_isr.Frame.offset, frag_len );
if ( iob_len ( iobuf ) == len ) {
/* Whole packet received; deliver it */
netdev_rx ( netdev, iobuf );
iobuf = NULL;
netdev_rx ( netdev, iob_disown ( iobuf ) );
/* Etherboot 5.4 fails to return all packets
* under mild load; pretend it retriggered.
*/
@@ -669,15 +669,19 @@ int undinet_probe ( struct undi_device *undi ) {
undi->flags |= UNDI_FL_STARTED;
/* Bring up UNDI stack */
memset ( &undi_startup, 0, sizeof ( undi_startup ) );
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP, &undi_startup,
sizeof ( undi_startup ) ) ) != 0 )
goto err_undi_startup;
memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
&undi_initialize,
sizeof ( undi_initialize ) ) ) != 0 )
goto err_undi_initialize;
if ( ! ( undi->flags & UNDI_FL_INITIALIZED ) ) {
memset ( &undi_startup, 0, sizeof ( undi_startup ) );
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP,
&undi_startup,
sizeof ( undi_startup ) ) ) != 0 )
goto err_undi_startup;
memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
&undi_initialize,
sizeof ( undi_initialize ))) != 0 )
goto err_undi_initialize;
}
undi->flags |= UNDI_FL_INITIALIZED;
/* Get device information */
memset ( &undi_info, 0, sizeof ( undi_info ) );
@@ -700,7 +704,7 @@ int undinet_probe ( struct undi_device *undi ) {
&undi_iface,
sizeof ( undi_iface ) ) ) != 0 )
goto err_undi_get_iface_info;
DBGC ( undinic, "UNDINIC %p has type %s and link speed %ld\n",
DBGC ( undinic, "UNDINIC %p has type %s and link speed %d\n",
undinic, undi_iface.IfaceType, undi_iface.LinkSpeed );
if ( strncmp ( ( ( char * ) undi_iface.IfaceType ), "Etherboot",
sizeof ( undi_iface.IfaceType ) ) == 0 ) {
@@ -731,11 +735,13 @@ int undinet_probe ( struct undi_device *undi ) {
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
sizeof ( undi_cleanup ) );
undi->flags &= ~UNDI_FL_INITIALIZED;
err_undi_startup:
/* Unhook UNDI stack */
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
sizeof ( stop_undi ) );
undi->flags &= ~UNDI_FL_STARTED;
err_start_undi:
netdev_nullify ( netdev );
netdev_put ( netdev );
@@ -758,19 +764,26 @@ void undinet_remove ( struct undi_device *undi ) {
/* Unregister net device */
unregister_netdev ( netdev );
/* Shut down UNDI stack */
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
sizeof ( undi_shutdown ) );
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
sizeof ( undi_cleanup ) );
/* If we are preparing for an OS boot, or if we cannot exit
* via the PXE stack, then shut down the PXE stack.
*/
if ( ! ( undi->flags & UNDI_FL_KEEP_ALL ) ) {
/* Unhook UNDI stack */
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
sizeof ( stop_undi ) );
undi->flags &= ~UNDI_FL_STARTED;
/* Shut down UNDI stack */
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
sizeof ( undi_shutdown ) );
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
sizeof ( undi_cleanup ) );
undi->flags &= ~UNDI_FL_INITIALIZED;
/* Unhook UNDI stack */
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
sizeof ( stop_undi ) );
undi->flags &= ~UNDI_FL_STARTED;
}
/* Clear entry point */
memset ( &undinet_entry_point, 0, sizeof ( undinet_entry_point ) );
+18
View File
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <gpxe/device.h>
#include <gpxe/init.h>
#include <undi.h>
#include <undinet.h>
#include <undipreload.h>
@@ -107,3 +108,20 @@ struct root_device undi_root_device __root_device = {
.dev = { .name = "UNDI" },
.driver = &undi_root_driver,
};
/**
* Prepare for exit
*
* @v flags Shutdown flags
*/
static void undionly_shutdown ( int flags ) {
/* If we are shutting down to boot an OS, clear the "keep PXE
* stack" flag.
*/
if ( flags & SHUTDOWN_BOOT )
preloaded_undi.flags &= ~UNDI_FL_KEEP_ALL;
}
struct startup_fn startup_undionly __startup_fn ( STARTUP_LATE ) = {
.shutdown = undionly_shutdown,
};
+2 -2
View File
@@ -52,7 +52,7 @@ static int undirom_parse_pxeromid ( struct undi_rom *undirom,
sizeof ( undi_rom_id ) );
if ( undi_rom_id.Signature != UNDI_ROM_ID_SIGNATURE ) {
DBGC ( undirom, "UNDIROM %p has bad PXE ROM ID signature "
"%08lx\n", undirom, undi_rom_id.Signature );
"%08x\n", undirom, undi_rom_id.Signature );
return -EINVAL;
}
@@ -94,7 +94,7 @@ static int undirom_parse_pcirheader ( struct undi_rom *undirom,
sizeof ( pcir_header ) );
if ( pcir_header.signature != PCIR_SIGNATURE ) {
DBGC ( undirom, "UNDIROM %p has bad PCI expansion header "
"signature %08lx\n", undirom, pcir_header.signature );
"signature %08x\n", undirom, pcir_header.signature );
return -EINVAL;
}
-57
View File
@@ -1,57 +0,0 @@
/*
* Etherboot routines for PCBIOS firmware.
*
* Body of routines taken from old pcbios.S
*/
#include <gpxe/init.h>
#include <gpxe/timer.h>
#include <stdio.h>
#include <realmode.h>
#include <bios.h>
#include <bits/timer2.h>
/* A bit faster actually, but we don't care. */
#define TIMER2_TICKS_PER_SEC 18
/*
* Use direct memory access to BIOS variables, longword 0040:006C (ticks
* today) and byte 0040:0070 (midnight crossover flag) instead of calling
* timeofday BIOS interrupt.
*/
static tick_t bios_currticks ( void ) {
static int days = 0;
uint32_t ticks;
uint8_t midnight;
/* Re-enable interrupts so that the timer interrupt can occur */
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
"nop\n\t"
"nop\n\t"
"cli\n\t" ) : : );
get_real ( ticks, BDA_SEG, 0x006c );
get_real ( midnight, BDA_SEG, 0x0070 );
if ( midnight ) {
midnight = 0;
put_real ( midnight, BDA_SEG, 0x0070 );
days += 0x1800b0;
}
return ( (days + ticks) * (USECS_IN_SEC / TIMER2_TICKS_PER_SEC) );
}
static int bios_ts_init(void)
{
DBG("BIOS timer installed\n");
return 0;
}
struct timer bios_ts __timer ( 02 ) = {
.init = bios_ts_init,
.udelay = i386_timer2_udelay,
.currticks = bios_currticks,
};
-69
View File
@@ -1,69 +0,0 @@
#include <gpxe/init.h>
#include <gpxe/timer.h>
#include <errno.h>
#include <stdio.h>
#include <bits/cpu.h>
#include <bits/timer2.h>
#include <io.h>
#define rdtsc(low,high) \
__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
#define rdtscll(val) \
__asm__ __volatile__ ("rdtsc" : "=A" (val))
/* Measure how many clocks we get in one microsecond */
static inline uint64_t calibrate_tsc(void)
{
uint64_t rdtsc_start;
uint64_t rdtsc_end;
rdtscll(rdtsc_start);
i386_timer2_udelay(USECS_IN_MSEC);
rdtscll(rdtsc_end);
return (rdtsc_end - rdtsc_start) / USECS_IN_MSEC;
}
static uint32_t clocks_per_usec = 0;
/* We measure time in microseconds. */
static tick_t rdtsc_currticks(void)
{
uint64_t clocks;
/* Read the Time Stamp Counter */
rdtscll(clocks);
return clocks / clocks_per_usec;
}
static int rdtsc_ts_init(void)
{
struct cpuinfo_x86 cpu_info;
get_cpuinfo(&cpu_info);
if (cpu_info.features & X86_FEATURE_TSC) {
clocks_per_usec= calibrate_tsc();
if (clocks_per_usec) {
DBG("RDTSC ticksource installed. CPU running at %ld Mhz\n",
clocks_per_usec);
return 0;
}
}
DBG("RDTSC ticksource not available on this machine.\n");
return -ENODEV;
}
struct timer rdtsc_ts __timer (01) = {
.init = rdtsc_ts_init,
.udelay = generic_currticks_udelay,
.currticks = rdtsc_currticks,
};
+3 -1
View File
@@ -193,13 +193,14 @@ static const char *ansi_input = "";
* dense range, so subtracting a constant and treating them as offsets
* into an array works efficiently.
*/
#define BIOS_KEY_MIN 0x47
#define BIOS_KEY_MIN 0x42
/** Offset into list of interesting BIOS scancodes */
#define BIOS_KEY(scancode) ( (scancode) - BIOS_KEY_MIN )
/** Mapping from BIOS scan codes to ANSI escape sequences */
static const char *ansi_sequences[] = {
[ BIOS_KEY ( 0x42 ) ] = "[19~", /* F8 (required for PXE) */
[ BIOS_KEY ( 0x47 ) ] = "[H", /* Home */
[ BIOS_KEY ( 0x48 ) ] = "[A", /* Up arrow */
[ BIOS_KEY ( 0x4b ) ] = "[D", /* Left arrow */
@@ -222,6 +223,7 @@ static const char * scancode_to_ansi_seq ( unsigned int scancode ) {
sizeof ( ansi_sequences[0] ) ) ) {
return ansi_sequences[bios_key];
}
DBG ( "Unrecognised BIOS scancode %02x\n", scancode );
return NULL;
}
+72 -38
View File
@@ -18,13 +18,30 @@
.text
.arch i386
.section ".text16", "ax", @progbits
.section ".data16", "aw", @progbits
.section ".text16.data", "aw", @progbits
.code16
#define SMAP 0x534d4150
/* Most documentation refers to the E820 buffer as being 20 bytes, and
* the API makes it perfectly legitimate to pass only a 20-byte buffer
* and expect to get valid data. However, some morons at ACPI decided
* to extend the data structure by adding an extra "extended
* attributes" field and by including critical information within this
* field, such as whether or not the region is enabled. A caller who
* passes in only a 20-byte buffer therefore risks getting very, very
* misleading information.
*
* I have personally witnessed an HP BIOS that returns a value of
* 0x0009 in the extended attributes field. If we don't pass this
* value through to the caller, 32-bit WinPE will die, usually with a
* PAGE_FAULT_IN_NONPAGED_AREA blue screen of death.
*
* Allow a ridiculously large maximum value (64 bytes) for the E820
* buffer as a guard against insufficiently creative idiots in the
* future.
*/
#define E820MAXSIZE 64
/****************************************************************************
*
* Allowed memory windows
@@ -42,11 +59,11 @@
*
****************************************************************************
*/
.section ".data16"
.section ".data16", "aw", @progbits
.align 16
.globl hidemem_base
.globl hidemem_umalloc
.globl hidemem_text
.globl hidemem_textdata
memory_windows:
base_memory_window: .long 0x00000000, 0x00000000 /* Start of memory */
@@ -56,7 +73,7 @@ ext_memory_window: .long 0x000a0000, 0x00000000 /* 640kB mark */
hidemem_umalloc: .long 0xffffffff, 0xffffffff /* Changes at runtime */
.long 0xffffffff, 0xffffffff /* Changes at runtime */
hidemem_text: .long 0xffffffff, 0xffffffff /* Changes at runtime */
hidemem_textdata: .long 0xffffffff, 0xffffffff /* Changes at runtime */
.long 0xffffffff, 0xffffffff /* Changes at runtime */
.long 0xffffffff, 0xffffffff /* End of memory */
@@ -74,7 +91,7 @@ memory_windows_end:
* %ecx:%ebx Length of windowed region
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
window_region:
/* Convert (start,len) to (start, end) */
addl %eax, %ebx
@@ -112,7 +129,7 @@ window_region:
* %ax Modified memory above 1M in 1kB blocks
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
patch_1m:
pushal
/* Convert to (start,len) format and call truncate */
@@ -142,7 +159,7 @@ patch_1m:
* %bx Modified memory above 16M in 64kB blocks
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
patch_16m:
pushal
/* Convert to (start,len) format and call truncate */
@@ -173,7 +190,7 @@ patch_16m:
* %bx Modified memory above 16MB, in 64kB blocks
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
patch_1m_16m:
call patch_1m
call patch_16m
@@ -199,24 +216,27 @@ patch_1m_16m:
*
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
get_underlying_e820:
/* If the requested region is in the cache, return it */
cmpw %bx, underlying_e820_index
jne 1f
jne 2f
pushw %di
pushw %si
movw $underlying_e820_cache, %si
movw $20, %cx
cmpl underlying_e820_cache_size, %ecx
jbe 1f
movl underlying_e820_cache_size, %ecx
1: pushl %ecx
rep movsb
popl %ecx
popw %si
popw %di
movw $20, %cx
incw %bx
movl %edx, %eax
ret
1:
2:
/* If the requested region is earlier than the cached region,
* invalidate the cache.
*/
@@ -245,28 +265,35 @@ get_underlying_e820:
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi /* Some implementations corrupt %esi, so we */
pushl %edi /* preserve %esi, %edi and %ebp to be paranoid */
pushl %ebp
pushw %es
pushw %di
pushw %ds
popw %es
movw $underlying_e820_cache, %di
movl $20, %ecx
movl underlying_e820_ebx, %ebx
cmpl $E820MAXSIZE, %ecx
jbe 1f
movl $E820MAXSIZE, %ecx
1: movl underlying_e820_ebx, %ebx
stc
pushfw
lcall *%cs:int15_vector
popw %di
popw %es
popl %ebp
popl %edi
popl %esi
/* Check for error return from underlying e820 call */
jc 1f /* CF set: error */
jc 2f /* CF set: error */
cmpl $SMAP, %eax
je 2f /* 'SMAP' missing: error */
1: /* An error occurred: return values returned by underlying e820 call */
je 3f /* 'SMAP' missing: error */
2: /* An error occurred: return values returned by underlying e820 call */
stc /* Force CF set if SMAP was missing */
addr32 leal 16(%esp), %esp /* avoid changing other flags */
ret
2: /* No error occurred */
3: /* No error occurred */
movl %ebx, underlying_e820_ebx
movl %ecx, underlying_e820_cache_size
popl %edx
popl %ecx
popl %ebx
@@ -278,21 +305,26 @@ get_underlying_e820:
jmp get_underlying_e820
.size get_underlying_e820, . - get_underlying_e820
.section ".data16"
.section ".data16", "aw", @progbits
underlying_e820_index:
.word 0xffff /* Initialise to an invalid value */
.size underlying_e820_index, . - underlying_e820_index
.section ".bss16"
.section ".bss16", "aw", @nobits
underlying_e820_ebx:
.long 0
.size underlying_e820_ebx, . - underlying_e820_ebx
.section ".bss16"
.section ".bss16", "aw", @nobits
underlying_e820_cache:
.space 20
.space E820MAXSIZE
.size underlying_e820_cache, . - underlying_e820_cache
.section ".bss16", "aw", @nobits
underlying_e820_cache_size:
.long 0
.size underlying_e820_cache_size, . - underlying_e820_cache_size
/****************************************************************************
* Get windowed e820 region, without empty region stripping
*
@@ -307,7 +339,7 @@ underlying_e820_cache:
*
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
get_windowed_e820:
/* Preserve registers */
@@ -382,7 +414,7 @@ get_windowed_e820:
*
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
get_nonempty_e820:
/* Record entry parameters */
@@ -427,7 +459,7 @@ get_nonempty_e820:
*
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
get_mangled_e820:
/* Get a nonempty region */
@@ -436,15 +468,17 @@ get_mangled_e820:
/* Peek ahead to see if there are any further nonempty regions */
pushal
subw $20, %sp
pushw %es
movw %sp, %bp
subw %cx, %sp
movl $0xe820, %eax
movl $SMAP, %edx
movl $20, %ecx
pushw %ss
popw %es
movw %sp, %di
call get_nonempty_e820
addr32 leal 20(%esp), %esp /* avoid changing flags */
movw %bp, %sp
popw %es
popal
jnc 99f /* There are further nonempty regions */
@@ -459,7 +493,7 @@ get_mangled_e820:
* INT 15,e820 handler
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
int15_e820:
pushw %ds
pushw %cs:rm_ds
@@ -473,7 +507,7 @@ int15_e820:
* INT 15,e801 handler
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
int15_e801:
/* Call previous handler */
pushfw
@@ -499,7 +533,7 @@ int15_e801:
* INT 15,88 handler
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
int15_88:
/* Call previous handler */
pushfw
@@ -520,7 +554,7 @@ int15_88:
* INT 15 handler
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
.globl int15
int15:
/* See if we want to intercept this call */
@@ -543,7 +577,7 @@ int15:
ljmp *%cs:int15_vector
.size int15, . - int15
.section ".text16.data"
.section ".text16.data", "aw", @progbits
.globl int15_vector
int15_vector:
.long 0
+7 -6
View File
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <realmode.h>
#include <bios.h>
#include <gpxe/io.h>
#include <gpxe/timer.h>
#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
@@ -48,9 +49,9 @@ static void empty_8042 ( void ) {
time = currticks() + TICKS_PER_SEC; /* max wait of 1 second */
while ( ( inb ( K_CMD ) & ( K_IBUF_FUL | K_OBUF_FUL ) ) &&
currticks() < time ) {
SLOW_DOWN_IO;
( void ) inb ( K_RDWR );
SLOW_DOWN_IO;
iodelay();
( void ) inb_p ( K_RDWR );
iodelay();
}
}
@@ -77,7 +78,7 @@ static int gateA20_is_set ( int retries ) {
/* Avoid false negatives */
test_pattern++;
SLOW_DOWN_IO;
iodelay();
/* Always retry at least once, to avoid false negatives */
} while ( retries-- >= 0 );
@@ -145,9 +146,9 @@ void gateA20_set ( void ) {
scp_a = inb ( SCP_A );
scp_a &= ~0x01; /* Avoid triggering a reset */
scp_a |= 0x02; /* Enable A20 */
SLOW_DOWN_IO;
iodelay();
outb ( scp_a, SCP_A );
SLOW_DOWN_IO;
iodelay();
if ( gateA20_is_set ( A20_SCPA_RETRIES ) ) {
DBG ( "Enabled gate A20 using "
"Fast Gate A20\n" );
+16 -16
View File
@@ -55,8 +55,8 @@ extern struct hidden_region __data16 ( hidemem_umalloc );
#define hidemem_umalloc __use_data16 ( hidemem_umalloc )
/** Hidden text memory */
extern struct hidden_region __data16 ( hidemem_text );
#define hidemem_text __use_data16 ( hidemem_text )
extern struct hidden_region __data16 ( hidemem_textdata );
#define hidemem_textdata __use_data16 ( hidemem_textdata )
/** Assembly routine in e820mangler.S */
extern void int15();
@@ -66,12 +66,12 @@ extern struct segoff __text16 ( int15_vector );
#define int15_vector __use_text16 ( int15_vector )
/* The linker defines these symbols for us */
extern char _text[];
extern char _end[];
extern char _text16_size[];
#define _text16_size ( ( unsigned int ) _text16_size )
extern char _data16_size[];
#define _data16_size ( ( unsigned int ) _data16_size )
extern char _textdata[];
extern char _etextdata[];
extern char _text16_memsz[];
#define _text16_memsz ( ( unsigned int ) _text16_memsz )
extern char _data16_memsz[];
#define _data16_memsz ( ( unsigned int ) _data16_memsz )
/**
* Hide region of memory from system memory map
@@ -110,7 +110,7 @@ void hide_basemem ( void ) {
*
*/
void hide_umalloc ( physaddr_t start, physaddr_t end ) {
assert ( end <= virt_to_phys ( _text ) );
assert ( end <= virt_to_phys ( _textdata ) );
hide_region ( &hidemem_umalloc, start, end );
}
@@ -118,9 +118,9 @@ void hide_umalloc ( physaddr_t start, physaddr_t end ) {
* Hide .text and .data
*
*/
void hide_text ( void ) {
hide_region ( &hidemem_text, virt_to_phys ( _text ),
virt_to_phys ( _end ) );
void hide_textdata ( void ) {
hide_region ( &hidemem_textdata, virt_to_phys ( _textdata ),
virt_to_phys ( _etextdata ) );
}
/**
@@ -148,8 +148,8 @@ static void hide_etherboot ( void ) {
/* Initialise the hidden regions */
hide_basemem();
hide_umalloc ( virt_to_phys ( _text ), virt_to_phys ( _text ) );
hide_text();
hide_umalloc ( virt_to_phys ( _textdata ), virt_to_phys ( _textdata ) );
hide_textdata();
/* Some really moronic BIOSes bring up the PXE stack via the
* UNDI loader entry point and then don't bother to unload it
@@ -161,8 +161,8 @@ static void hide_etherboot ( void ) {
* We use a heuristic to guess whether or not we are being
* loaded sensibly.
*/
rm_cs_top = ( ( ( rm_cs << 4 ) + _text16_size + 1024 - 1 ) >> 10 );
rm_ds_top = ( ( ( rm_ds << 4 ) + _data16_size + 1024 - 1 ) >> 10 );
rm_cs_top = ( ( ( rm_cs << 4 ) + _text16_memsz + 1024 - 1 ) >> 10 );
rm_ds_top = ( ( ( rm_ds << 4 ) + _data16_memsz + 1024 - 1 ) >> 10 );
fbms = get_fbms();
if ( ( rm_cs_top < fbms ) && ( rm_ds_top < fbms ) ) {
DBG ( "Detected potentially unsafe UNDI load at CS=%04x "
+61 -8
View File
@@ -41,6 +41,8 @@ struct e820_entry {
uint64_t len;
/** Type of region */
uint32_t type;
/** Extended attributes (optional) */
uint32_t attrs;
} __attribute__ (( packed ));
#define E820_TYPE_RAM 1 /**< Normal memory */
@@ -48,6 +50,12 @@ struct e820_entry {
#define E820_TYPE_ACPI 3 /**< ACPI reclaim memory */
#define E820_TYPE_NVS 4 /**< ACPI NVS memory */
#define E820_ATTR_ENABLED 0x00000001UL
#define E820_ATTR_NONVOLATILE 0x00000002UL
#define E820_ATTR_UNKNOWN 0xfffffffcUL
#define E820_MIN_SIZE 20
/** Buffer for INT 15,e820 calls */
static struct e820_entry __bss16 ( e820buf );
#define e820buf __use_data16 ( e820buf )
@@ -148,39 +156,84 @@ static int meme820 ( struct memory_map *memmap ) {
struct memory_region *region = memmap->regions;
uint32_t next = 0;
uint32_t smap;
size_t size;
unsigned int flags;
unsigned int discard_c, discard_d, discard_D;
unsigned int discard_D;
/* Clear the E820 buffer. Do this once before starting,
* rather than on each call; some BIOSes rely on the contents
* being preserved between calls.
*/
memset ( &e820buf, 0, sizeof ( e820buf ) );
do {
__asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
/* Some BIOSes corrupt %esi for fun. Guard against
* this by telling gcc that all non-output registers
* may be corrupted.
*/
__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t"
"stc\n\t"
"int $0x15\n\t"
"pushfw\n\t"
"popw %w0\n\t" )
: "=r" ( flags ), "=a" ( smap ),
"=b" ( next ), "=D" ( discard_D ),
"=c" ( discard_c ), "=d" ( discard_d )
"popw %%dx\n\t"
"popl %%ebp\n\t" )
: "=a" ( smap ), "=b" ( next ),
"=c" ( size ), "=d" ( flags ),
"=D" ( discard_D )
: "a" ( 0xe820 ), "b" ( next ),
"D" ( __from_data16 ( &e820buf ) ),
"c" ( sizeof ( e820buf ) ),
"d" ( SMAP )
: "memory" );
: "esi", "memory" );
if ( smap != SMAP ) {
DBG ( "INT 15,e820 failed SMAP signature check\n" );
return -ENOTSUP;
}
if ( size < E820_MIN_SIZE ) {
DBG ( "INT 15,e820 returned only %zd bytes\n", size );
return -EINVAL;
}
if ( flags & CF ) {
DBG ( "INT 15,e820 terminated on CF set\n" );
break;
}
DBG ( "INT 15,e820 region [%llx,%llx) type %d\n",
/* If first region is not RAM, assume map is invalid */
if ( ( memmap->count == 0 ) &&
( e820buf.type != E820_TYPE_RAM ) ) {
DBG ( "INT 15,e820 failed, first entry not RAM\n" );
return -EINVAL;
}
DBG ( "INT 15,e820 region [%llx,%llx) type %d",
e820buf.start, ( e820buf.start + e820buf.len ),
( int ) e820buf.type );
if ( size > offsetof ( typeof ( e820buf ), attrs ) ) {
DBG ( " (%s", ( ( e820buf.attrs & E820_ATTR_ENABLED )
? "enabled" : "disabled" ) );
if ( e820buf.attrs & E820_ATTR_NONVOLATILE )
DBG ( ", non-volatile" );
if ( e820buf.attrs & E820_ATTR_UNKNOWN )
DBG ( ", other [%08x]", e820buf.attrs );
DBG ( ")" );
}
DBG ( "\n" );
/* Discard non-RAM regions */
if ( e820buf.type != E820_TYPE_RAM )
continue;
/* Check extended attributes, if present */
if ( size > offsetof ( typeof ( e820buf ), attrs ) ) {
if ( ! ( e820buf.attrs & E820_ATTR_ENABLED ) )
continue;
if ( e820buf.attrs & E820_ATTR_NONVOLATILE )
continue;
}
region->start = e820buf.start;
region->end = e820buf.start + e820buf.len;
region++;
+1 -1
View File
@@ -400,7 +400,7 @@ static int bzimage_load_header ( struct image *image,
copy_from_user ( bzhdr, image->data, BZI_HDR_OFFSET,
sizeof ( *bzhdr ) );
if ( bzhdr->header != BZI_SIGNATURE ) {
DBGC ( image, "bzImage %p bad signature %08lx\n",
DBGC ( image, "bzImage %p bad signature %08x\n",
image, bzhdr->header );
return -ENOEXEC;
}
+26 -18
View File
@@ -52,7 +52,7 @@ static int com32_exec ( struct image *image ) {
int state;
uint32_t avail_mem_top;
state = setjmp ( comboot_return );
state = rmsetjmp ( comboot_return );
switch ( state ) {
case 0: /* First time through; invoke COM32 program */
@@ -70,20 +70,20 @@ static int com32_exec ( struct image *image ) {
}
DBGC ( image, "COM32 %p: available memory top = 0x%x\n",
image, (int)avail_mem_top );
image, avail_mem_top );
assert ( avail_mem_top != 0 );
com32_external_esp = phys_to_virt ( avail_mem_top );
/* Hook COMBOOT API interrupts */
hook_comboot_interrupts( );
hook_comboot_interrupts();
/* Temporarily de-register image, so that a "boot" command
* doesn't throw us into an execution loop. Hold a reference
* to avoid the image's being freed.
/* Unregister image, so that a "boot" command doesn't
* throw us into an execution loop. We never
* reregister ourselves; COMBOOT images expect to be
* removed on exit.
*/
image_get ( image );
unregister_image ( image );
__asm__ __volatile__ (
@@ -111,25 +111,33 @@ static int com32_exec ( struct image *image ) {
/* %6 */ "r" ( COM32_START_PHYS )
:
"memory" );
DBGC ( image, "COM32 %p: returned\n", image );
break;
case COMBOOT_RETURN_RUN_KERNEL:
DBGC ( image, "COM32 %p: returned to run kernel...\n", image );
comboot_run_kernel ( );
case COMBOOT_EXIT:
DBGC ( image, "COM32 %p: exited\n", image );
break;
case COMBOOT_RETURN_EXIT:
case COMBOOT_EXIT_RUN_KERNEL:
DBGC ( image, "COM32 %p: exited to run kernel %p\n",
image, comboot_replacement_image );
image->replacement = comboot_replacement_image;
comboot_replacement_image = NULL;
image_autoload ( image->replacement );
break;
case COMBOOT_EXIT_COMMAND:
DBGC ( image, "COM32 %p: exited after executing command\n",
image );
break;
default:
assert ( 0 );
break;
}
comboot_force_text_mode ( );
DBGC ( image, "COM32 %p returned\n", image );
/* Re-register image and return */
register_image ( image );
image_put ( image );
unhook_comboot_interrupts();
comboot_force_text_mode();
return 0;
}
+26 -18
View File
@@ -133,7 +133,7 @@ static int comboot_exec ( struct image *image ) {
userptr_t seg_userptr = real_to_user ( COMBOOT_PSP_SEG, 0 );
int state;
state = setjmp ( comboot_return );
state = rmsetjmp ( comboot_return );
switch ( state ) {
case 0: /* First time through; invoke COMBOOT program */
@@ -142,16 +142,16 @@ static int comboot_exec ( struct image *image ) {
comboot_init_psp ( image, seg_userptr );
/* Hook COMBOOT API interrupts */
hook_comboot_interrupts ( );
hook_comboot_interrupts();
DBGC ( image, "executing 16-bit COMBOOT image at %4x:0100\n",
COMBOOT_PSP_SEG );
COMBOOT_PSP_SEG );
/* Temporarily de-register image, so that a "boot" command
* doesn't throw us into an execution loop. Hold a reference
* to avoid the image's being freed.
/* Unregister image, so that a "boot" command doesn't
* throw us into an execution loop. We never
* reregister ourselves; COMBOOT images expect to be
* removed on exit.
*/
image_get ( image );
unregister_image ( image );
/* Store stack segment at 0x38 and stack pointer at 0x3A
@@ -180,26 +180,34 @@ static int comboot_exec ( struct image *image ) {
"xorw %%bp, %%bp\n\t"
"lret\n\t" )
: : "r" ( COMBOOT_PSP_SEG ) : "eax" );
DBGC ( image, "COMBOOT %p: returned\n", image );
break;
case COMBOOT_RETURN_RUN_KERNEL:
DBGC ( image, "COMBOOT %p: returned to run kernel...\n", image );
comboot_run_kernel ( );
case COMBOOT_EXIT:
DBGC ( image, "COMBOOT %p: exited\n", image );
break;
case COMBOOT_RETURN_EXIT:
case COMBOOT_EXIT_RUN_KERNEL:
DBGC ( image, "COMBOOT %p: exited to run kernel %p\n",
image, comboot_replacement_image );
image->replacement = comboot_replacement_image;
comboot_replacement_image = NULL;
image_autoload ( image->replacement );
break;
case COMBOOT_EXIT_COMMAND:
DBGC ( image, "COMBOOT %p: exited after executing command\n",
image );
break;
default:
assert ( 0 );
break;
}
comboot_force_text_mode ( );
unhook_comboot_interrupts();
comboot_force_text_mode();
DBGC ( image, "COMBOOT %p returned\n", image );
/* Re-register image and return */
register_image ( image );
image_put ( image );
return 0;
}
+7 -5
View File
@@ -220,7 +220,7 @@ multiboot_build_module_list ( struct image *image,
/* Dump module configuration */
for ( i = 0 ; i < count ; i++ ) {
DBGC ( image, "MULTIBOOT %p module %d is [%lx,%lx)\n",
DBGC ( image, "MULTIBOOT %p module %d is [%x,%x)\n",
image, i, modules[i].mod_start,
modules[i].mod_end );
}
@@ -282,11 +282,13 @@ static int multiboot_exec ( struct image *image ) {
/* Jump to OS with flat physical addressing */
DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
image, entry );
__asm__ __volatile__ ( PHYS_CODE ( "call *%%edi\n\t" )
__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t"
"call *%%edi\n\t"
"popl %%ebp\n\t" )
: : "a" ( MULTIBOOT_BOOTLOADER_MAGIC ),
"b" ( virt_to_phys ( &mbinfo ) ),
"D" ( entry )
: "ecx", "edx", "esi", "ebp", "memory" );
: "ecx", "edx", "esi", "memory" );
DBGC ( image, "MULTIBOOT %p returned\n", image );
@@ -416,7 +418,7 @@ static int multiboot_load ( struct image *image ) {
image );
return rc;
}
DBGC ( image, "MULTIBOOT %p found header with flags %08lx\n",
DBGC ( image, "MULTIBOOT %p found header with flags %08x\n",
image, hdr.mb.flags );
/* This is a multiboot image, valid or otherwise */
@@ -425,7 +427,7 @@ static int multiboot_load ( struct image *image ) {
/* Abort if we detect flags that we cannot support */
if ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) {
DBGC ( image, "MULTIBOOT %p flags %08lx not supported\n",
DBGC ( image, "MULTIBOOT %p flags %08x not supported\n",
image, ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) );
return -ENOTSUP;
}
+1 -17
View File
@@ -366,22 +366,6 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
return rc;
}
/**
* Guess boot network device
*
* @ret netdev Boot network device
*/
static struct net_device * guess_boot_netdev ( void ) {
struct net_device *boot_netdev;
/* Just use the first network device */
for_each_netdev ( boot_netdev ) {
return boot_netdev;
}
return NULL;
}
/**
* Prepare DHCP parameter block for NBI image
*
@@ -392,7 +376,7 @@ static int nbi_prepare_dhcp ( struct image *image ) {
struct net_device *boot_netdev;
int rc;
boot_netdev = guess_boot_netdev();
boot_netdev = last_opened_netdev();
if ( ! boot_netdev ) {
DBGC ( image, "NBI %p could not identify a network device\n",
image );
+8 -6
View File
@@ -42,18 +42,14 @@ struct image_type pxe_image_type __image_type ( PROBE_PXE );
* @ret rc Return status code
*/
static int pxe_exec ( struct image *image ) {
struct net_device *netdev;
int rc;
/* Ensure that PXE stack is ready to use */
pxe_init_structures();
pxe_hook_int1a();
/* Arbitrarily pick the first open network device to use for PXE */
for_each_netdev ( netdev ) {
pxe_set_netdev ( netdev );
break;
}
/* Arbitrarily pick the most recently opened network device */
pxe_set_netdev ( last_opened_netdev() );
/* Many things will break if pxe_netdev is NULL */
if ( ! pxe_netdev ) {
@@ -92,6 +88,12 @@ int pxe_load ( struct image *image ) {
if ( filesz > ( 0xa0000 - 0x7c00 ) )
return -ENOEXEC;
/* Rejecting zero-length images is also useful, since these
* end up looking to the user like bugs in gPXE.
*/
if ( ! filesz )
return -ENOEXEC;
/* There are no signature checks for PXE; we will accept anything */
if ( ! image->type )
image->type = &pxe_image_type;
-3
View File
@@ -5,7 +5,4 @@
#define BDA_FBMS 0x0013
#define BDA_NUM_DRIVES 0x0075
extern unsigned long currticks ( void );
extern void cpu_nap ( void );
#endif /* BIOS_H */
+14 -1
View File
@@ -6,9 +6,22 @@
*
*/
#include <realmode.h>
struct segoff;
extern int hooked_bios_interrupts;
/**
* Hooked interrupt count
*
* At exit, after unhooking all possible interrupts, this counter
* should be examined. If it is non-zero, it means that we failed to
* unhook at least one interrupt vector, and so must not free up the
* memory we are using. (Note that this also implies that we should
* re-hook INT 15 in order to hide ourselves from the memory map).
*/
extern uint16_t __text16 ( hooked_bios_interrupts );
#define hooked_bios_interrupts __use_text16 ( hooked_bios_interrupts )
extern void hook_bios_interrupt ( unsigned int interrupt, unsigned int handler,
struct segoff *chain_vector );
extern int unhook_bios_interrupt ( unsigned int interrupt,
+5 -40
View File
@@ -2,7 +2,7 @@
#define ETHERBOOT_BITS_BYTESWAP_H
static inline __attribute__ ((always_inline, const)) uint16_t
__i386_bswap_16(uint16_t x)
__bswap_variable_16(uint16_t x)
{
__asm__("xchgb %b0,%h0\n\t"
: "=q" (x)
@@ -11,7 +11,7 @@ __i386_bswap_16(uint16_t x)
}
static inline __attribute__ ((always_inline, const)) uint32_t
__i386_bswap_32(uint32_t x)
__bswap_variable_32(uint32_t x)
{
__asm__("xchgb %b0,%h0\n\t"
"rorl $16,%0\n\t"
@@ -22,7 +22,7 @@ __i386_bswap_32(uint32_t x)
}
static inline __attribute__ ((always_inline, const)) uint64_t
__i386_bswap_64(uint64_t x)
__bswap_variable_64(uint64_t x)
{
union {
uint64_t qword;
@@ -30,47 +30,12 @@ __i386_bswap_64(uint64_t x)
} u;
u.qword = x;
u.dword[0] = __i386_bswap_32(u.dword[0]);
u.dword[1] = __i386_bswap_32(u.dword[1]);
u.dword[0] = __bswap_variable_32(u.dword[0]);
u.dword[1] = __bswap_variable_32(u.dword[1]);
__asm__("xchgl %0,%1"
: "=r" ( u.dword[0] ), "=r" ( u.dword[1] )
: "0" ( u.dword[0] ), "1" ( u.dword[1] ) );
return u.qword;
}
#define __bswap_constant_16(x) \
((uint16_t)((((uint16_t)(x) & 0x00ff) << 8) | \
(((uint16_t)(x) & 0xff00) >> 8)))
#define __bswap_constant_32(x) \
((uint32_t)((((uint32_t)(x) & 0x000000ffU) << 24) | \
(((uint32_t)(x) & 0x0000ff00U) << 8) | \
(((uint32_t)(x) & 0x00ff0000U) >> 8) | \
(((uint32_t)(x) & 0xff000000U) >> 24)))
#define __bswap_constant_64(x) \
((uint64_t)((((uint64_t)(x) & 0x00000000000000ffULL) << 56) | \
(((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
(((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
(((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
(((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
(((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
(((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
(((uint64_t)(x) & 0xff00000000000000ULL) >> 56)))
#define __bswap_16(x) \
((uint16_t)(__builtin_constant_p(x) ? \
__bswap_constant_16(x) : \
__i386_bswap_16(x)))
#define __bswap_32(x) \
((uint32_t)(__builtin_constant_p(x) ? \
__bswap_constant_32(x) : \
__i386_bswap_32(x)))
#define __bswap_64(x) \
((uint64_t)(__builtin_constant_p(x) ? \
__bswap_constant_64(x) : \
__i386_bswap_64(x)))
#endif /* ETHERBOOT_BITS_BYTESWAP_H */
+25
View File
@@ -0,0 +1,25 @@
#ifndef _BITS_COMPILER_H
#define _BITS_COMPILER_H
#ifndef ASSEMBLY
/** Declare a function with standard calling conventions */
#define __asmcall __attribute__ (( cdecl, regparm(0) ))
/**
* Declare a function with libgcc implicit linkage
*
* It seems as though gcc expects its implicit arithmetic functions to
* be cdecl, even if -mrtd is specified. This is somewhat
* inconsistent; for example, if -mregparm=3 is used then the implicit
* functions do become regparm(3).
*
* The implicit calls to memcpy() and memset() which gcc can generate
* do not seem to have this inconsistency; -mregparm and -mrtd affect
* them in the same way as any other function.
*/
#define __libgcc __attribute__ (( cdecl ))
#endif /* ASSEMBLY */
#endif /* _BITS_COMPILER_H */
-91
View File
@@ -1,91 +0,0 @@
#ifndef I386_BITS_ELF_H
#define I386_BITS_ELF_H
#include "cpu.h"
#ifdef CONFIG_X86_64
/* ELF Defines for the 64bit version of the current architecture */
#define EM_CURRENT_64 EM_X86_64
#define EM_CURRENT_64_PRESENT ( \
CPU_FEATURE_P(cpu_info.x86_capability, LM) && \
CPU_FEATURE_P(cpu_info.x86_capability, PAE) && \
CPU_FEATURE_P(cpu_info.x86_capability, PSE))
#define ELF_CHECK_X86_64_ARCH(x) \
(EM_CURRENT_64_PRESENT && ((x).e_machine == EM_X86_64))
#define __unused_i386
#else
#define ELF_CHECK_X86_64_ARCH(x) 0
#define __unused_i386 __unused
#endif
/* ELF Defines for the current architecture */
#define EM_CURRENT EM_386
#define ELFDATA_CURRENT ELFDATA2LSB
#define ELF_CHECK_I386_ARCH(x) \
(((x).e_machine == EM_386) || ((x).e_machine == EM_486))
#define ELF_CHECK_ARCH(x) \
((ELF_CHECK_I386_ARCH(x) || ELF_CHECK_X86_64_ARCH(x)) && \
((x).e_entry <= 0xffffffffUL))
#ifdef IMAGE_FREEBSD
/*
* FreeBSD has this rather strange "feature" of its design.
* At some point in its evolution, FreeBSD started to rely
* externally on private/static/debug internal symbol information.
* That is, some of the interfaces that software uses to access
* and work with the FreeBSD kernel are made available not
* via the shared library symbol information (the .DYNAMIC section)
* but rather the debug symbols. This means that any symbol, not
* just publicly defined symbols can be (and are) used by system
* tools to make the system work. (such as top, swapinfo, swapon,
* etc)
*
* Even worse, however, is the fact that standard ELF loaders do
* not know how to load the symbols since they are not within
* an ELF PT_LOAD section. The kernel needs these symbols to
* operate so the following changes/additions to the boot
* loading of EtherBoot have been made to get the kernel to load.
* All of the changes are within IMAGE_FREEBSD such that the
* extra/changed code only compiles when FREEBSD support is
* enabled.
*/
/*
* Section header for FreeBSD (debug symbol kludge!) support
*/
typedef struct {
Elf32_Word sh_name; /* Section name (index into the
section header string table). */
Elf32_Word sh_type; /* Section type. */
Elf32_Word sh_flags; /* Section flags. */
Elf32_Addr sh_addr; /* Address in memory image. */
Elf32_Off sh_offset; /* Offset in file. */
Elf32_Size sh_size; /* Size in bytes. */
Elf32_Word sh_link; /* Index of a related section. */
Elf32_Word sh_info; /* Depends on section type. */
Elf32_Size sh_addralign; /* Alignment in bytes. */
Elf32_Size sh_entsize; /* Size of each entry in section. */
} Elf32_Shdr;
/* sh_type */
#define SHT_SYMTAB 2 /* symbol table section */
#define SHT_STRTAB 3 /* string table section */
/*
* Module information subtypes (for the metadata that we need to build)
*/
#define MODINFO_END 0x0000 /* End of list */
#define MODINFO_NAME 0x0001 /* Name of module (string) */
#define MODINFO_TYPE 0x0002 /* Type of module (string) */
#define MODINFO_METADATA 0x8000 /* Module-specfic */
#define MODINFOMD_SSYM 0x0003 /* start of symbols */
#define MODINFOMD_ESYM 0x0004 /* end of symbols */
#endif /* IMAGE_FREEBSD */
#endif /* I386_BITS_ELF_H */
-5
View File
@@ -1,5 +0,0 @@
#define ARCH_ELF_CLASS ELFCLASS32
#define ARCH_ELF_DATA ELFDATA2LSB
#define ARCH_ELF_MACHINE_OK(x) ((x)==EM_386 || (x)==EM_486)
typedef Elf32_Ehdr Elf_ehdr;
typedef Elf32_Phdr Elf_phdr;
+3 -3
View File
@@ -6,13 +6,12 @@
* @{
*/
#define ERRFILE_umalloc ( ERRFILE_ARCH | ERRFILE_CORE | 0x00000000 )
#define ERRFILE_memtop_umalloc ( ERRFILE_ARCH | ERRFILE_CORE | 0x00000000 )
#define ERRFILE_memmap ( ERRFILE_ARCH | ERRFILE_CORE | 0x00010000 )
#define ERRFILE_pnpbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00020000 )
#define ERRFILE_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
#define ERRFILE_bios_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
#define ERRFILE_biosint ( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
#define ERRFILE_int13 ( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
#define ERRFILE_smbios_settings ( ERRFILE_ARCH | ERRFILE_CORE | 0x00060000 )
#define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
#define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
@@ -24,6 +23,7 @@
#define ERRFILE_comboot ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00070000 )
#define ERRFILE_com32 ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00080000 )
#define ERRFILE_comboot_resolv ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00090000 )
#define ERRFILE_comboot_call ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000a0000 )
#define ERRFILE_undi ( ERRFILE_ARCH | ERRFILE_NET | 0x00000000 )
#define ERRFILE_undiload ( ERRFILE_ARCH | ERRFILE_NET | 0x00010000 )
+12
View File
@@ -0,0 +1,12 @@
#ifndef _BITS_IO_H
#define _BITS_IO_H
/** @file
*
* i386-specific I/O API implementations
*
*/
#include <gpxe/x86_io.h>
#endif /* _BITS_IO_H */
+13
View File
@@ -0,0 +1,13 @@
#ifndef _BITS_NAP_H
#define _BITS_NAP_H
/** @file
*
* i386-specific CPU sleeping API implementations
*
*/
#include <gpxe/bios_nap.h>
#include <gpxe/efi/efix86_nap.h>
#endif /* _BITS_MAP_H */
+12
View File
@@ -0,0 +1,12 @@
#ifndef _BITS_SMBIOS_H
#define _BITS_SMBIOS_H
/** @file
*
* i386-specific SMBIOS API implementations
*
*/
#include <gpxe/bios_smbios.h>
#endif /* _BITS_SMBIOS_H */
+4 -4
View File
@@ -1,18 +1,18 @@
#ifndef _BITS_STDINT_H
#define _BITS_STDINT_H
typedef typeof(sizeof(int)) size_t;
typedef signed long ssize_t;
typedef unsigned int size_t;
typedef signed int ssize_t;
typedef signed long off_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed long int32_t;
typedef signed int int32_t;
typedef signed long long int64_t;
typedef unsigned long physaddr_t;
+13
View File
@@ -0,0 +1,13 @@
#ifndef _BITS_TIMER_H
#define _BITS_TIMER_H
/** @file
*
* i386-specific timer API implementations
*
*/
#include <gpxe/bios_timer.h>
#include <gpxe/rdtsc_timer.h>
#endif /* _BITS_TIMER_H */
-8
View File
@@ -1,8 +0,0 @@
#ifndef BITS_TIMER2_H
#define BITS_TIMER2_H
#include <stddef.h>
void i386_timer2_udelay(unsigned int usecs);
#endif
+7 -1
View File
@@ -1,6 +1,12 @@
#ifndef _BITS_UACCESS_H
#define _BITS_UACCESS_H
#include <realmode.h>
/** @file
*
* i386-specific user access API implementations
*
*/
#include <librm.h>
#endif /* _BITS_UACCESS_H */
+12
View File
@@ -0,0 +1,12 @@
#ifndef _BITS_UMALLOC_H
#define _BITS_UMALLOC_H
/** @file
*
* i386-specific user memory allocation API implementations
*
*/
#include <gpxe/memtop_umalloc.h>
#endif /* _BITS_UMALLOC_H */
+41 -10
View File
@@ -57,6 +57,40 @@ typedef struct {
com32_reg32_t eflags; /* Offset 40 */
} com32sys_t;
typedef struct {
uint32_t eax; /* Offset 0 */
uint32_t ecx; /* Offset 4 */
uint32_t edx; /* Offset 8 */
uint32_t ebx; /* Offset 12 */
uint32_t esp; /* Offset 16 */
uint32_t ebp; /* Offset 20 */
uint32_t esi; /* Offset 24 */
uint32_t edi; /* Offset 28 */
uint32_t eip; /* Offset 32 */
} syslinux_pm_regs;
typedef struct {
uint16_t es; /* Offset 0 */
uint16_t _unused_cs; /* Offset 2 */
uint16_t ds; /* Offset 4 */
uint16_t ss; /* Offset 6 */
uint16_t fs; /* Offset 8 */
uint16_t gs; /* Offset 10 */
uint32_t eax; /* Offset 12 */
uint32_t ecx; /* Offset 16 */
uint32_t edx; /* Offset 20 */
uint32_t ebx; /* Offset 24 */
uint32_t esp; /* Offset 28 */
uint32_t ebp; /* Offset 32 */
uint32_t esi; /* Offset 36 */
uint32_t edi; /* Offset 40 */
uint16_t ip; /* Offset 44 */
uint16_t cs; /* Offset 46 */
} syslinux_rm_regs;
typedef struct {
uint32_t dest;
uint32_t src;
@@ -64,6 +98,7 @@ typedef struct {
} comboot_shuffle_descriptor;
extern void hook_comboot_interrupts ( );
extern void unhook_comboot_interrupts ( );
/* These are not the correct prototypes, but it doens't matter,
* as we only ever get the address of these functions;
@@ -77,20 +112,16 @@ extern void com32_cfarcall_wrapper ( );
extern int comboot_resolv ( const char *name, struct in_addr *address );
/* setjmp/longjmp context buffer used to return after loading an image */
extern jmp_buf comboot_return;
extern rmjmp_buf comboot_return;
/* Command line to execute when returning via comboot_return
* with COMBOOT_RETURN_RUN_KERNEL
*/
extern char *comboot_kernel_cmdline;
/* Execute comboot_image_cmdline */
extern void comboot_run_kernel ( );
/* Replacement image when exiting with COMBOOT_EXIT_RUN_KERNEL */
extern struct image *comboot_replacement_image;
extern void *com32_external_esp;
#define COMBOOT_RETURN_EXIT 1
#define COMBOOT_RETURN_RUN_KERNEL 2
#define COMBOOT_EXIT 1
#define COMBOOT_EXIT_RUN_KERNEL 2
#define COMBOOT_EXIT_COMMAND 3
extern void comboot_force_text_mode ( void );
+1 -1
View File
@@ -12,7 +12,7 @@
#include <stdint.h>
typedef uint32_t gdbreg_t;
typedef unsigned long gdbreg_t;
/* The register snapshot, this must be in sync with interrupt handler and the
* GDB protocol. */
+16
View File
@@ -0,0 +1,16 @@
#ifndef _GPXE_BIOS_NAP_H
#define _GPXE_BIOS_NAP_H
/** @file
*
* BIOS CPU sleeping
*
*/
#ifdef NAP_PCBIOS
#define NAP_PREFIX_pcbios
#else
#define NAP_PREFIX_pcbios __pcbios_
#endif
#endif /* _GPXE_BIOS_NAP_H */
+16
View File
@@ -0,0 +1,16 @@
#ifndef _GPXE_BIOS_SMBIOS_H
#define _GPXE_BIOS_SMBIOS_H
/** @file
*
* Standard PC-BIOS SMBIOS interface
*
*/
#ifdef SMBIOS_PCBIOS
#define SMBIOS_PREFIX_pcbios
#else
#define SMBIOS_PREFIX_pcbios __pcbios_
#endif
#endif /* _GPXE_BIOS_SMBIOS_H */
+42
View File
@@ -0,0 +1,42 @@
#ifndef _GPXE_BIOS_TIMER_H
#define _GPXE_BIOS_TIMER_H
/** @file
*
* BIOS timer
*
*/
#ifdef TIMER_PCBIOS
#define TIMER_PREFIX_pcbios
#else
#define TIMER_PREFIX_pcbios __pcbios_
#endif
#include <gpxe/timer2.h>
/**
* Delay for a fixed number of microseconds
*
* @v usecs Number of microseconds for which to delay
*/
static inline __always_inline void
TIMER_INLINE ( pcbios, udelay ) ( unsigned long usecs ) {
/* BIOS timer is not high-resolution enough for udelay(), so
* we use timer2
*/
timer2_udelay ( usecs );
}
/**
* Get number of ticks per second
*
* @ret ticks_per_sec Number of ticks per second
*/
static inline __always_inline unsigned long
TIMER_INLINE ( pcbios, ticks_per_sec ) ( void ) {
/* BIOS timer ticks over at 18.2 ticks per second */
return 18;
}
#endif /* _GPXE_BIOS_TIMER_H */
@@ -0,0 +1,16 @@
#ifndef _GPXE_MEMTOP_UMALLOC_H
#define _GPXE_MEMTOP_UMALLOC_H
/** @file
*
* External memory allocation
*
*/
#ifdef UMALLOC_MEMTOP
#define UMALLOC_PREFIX_memtop
#else
#define UMALLOC_PREFIX_memtop __memtop_
#endif
#endif /* _GPXE_MEMTOP_UMALLOC_H */
+37
View File
@@ -0,0 +1,37 @@
#ifndef _GPXE_RDTSC_TIMER_H
#define _GPXE_RDTSC_TIMER_H
/** @file
*
* RDTSC timer
*
*/
#ifdef TIMER_RDTSC
#define TIMER_PREFIX_rdtsc
#else
#define TIMER_PREFIX_rdtsc __rdtsc_
#endif
/**
* RDTSC values can easily overflow an unsigned long. We discard the
* low-order bits in order to obtain sensibly-scaled values.
*/
#define TSC_SHIFT 8
/**
* Get current system time in ticks
*
* @ret ticks Current time, in ticks
*/
static inline __always_inline unsigned long
TIMER_INLINE ( rdtsc, currticks ) ( void ) {
unsigned long ticks;
__asm__ __volatile__ ( "rdtsc\n\t"
"shrdl %1, %%edx, %%eax\n\t"
: "=a" ( ticks ) : "i" ( TSC_SHIFT ) : "edx" );
return ticks;
}
#endif /* _GPXE_RDTSC_TIMER_H */
+12
View File
@@ -0,0 +1,12 @@
#ifndef _GPXE_TIMER2_H
#define _GPXE_TIMER2_H
/** @file
*
* Timer chip control
*
*/
extern void timer2_udelay ( unsigned long usecs );
#endif /* _GPXE_TIMER2_H */
+151
View File
@@ -0,0 +1,151 @@
#ifndef _GPXE_X86_IO_H
#define _GPXE_X86_IO_H
/** @file
*
* gPXE I/O API for x86
*
* i386 uses direct pointer dereferences for accesses to memory-mapped
* I/O space, and the inX/outX instructions for accesses to
* port-mapped I/O space.
*
* 64-bit atomic accesses (readq() and writeq()) use MMX instructions,
* and will crash original Pentium and earlier CPUs. Fortunately, no
* hardware that requires atomic 64-bit accesses will physically fit
* into a machine with such an old CPU anyway.
*/
#ifdef IOAPI_X86
#define IOAPI_PREFIX_x86
#else
#define IOAPI_PREFIX_x86 __x86_
#endif
/*
* Memory space mappings
*
*/
/*
* Physical<->Bus and Bus<->I/O address mappings
*
*/
static inline __always_inline unsigned long
IOAPI_INLINE ( x86, phys_to_bus ) ( unsigned long phys_addr ) {
return phys_addr;
}
static inline __always_inline unsigned long
IOAPI_INLINE ( x86, bus_to_phys ) ( unsigned long bus_addr ) {
return bus_addr;
}
static inline __always_inline void *
IOAPI_INLINE ( x86, ioremap ) ( unsigned long bus_addr, size_t len __unused ) {
return phys_to_virt ( bus_addr );
}
static inline __always_inline void
IOAPI_INLINE ( x86, iounmap ) ( volatile const void *io_addr __unused ) {
/* Nothing to do */
}
static inline __always_inline unsigned long
IOAPI_INLINE ( x86, io_to_bus ) ( volatile const void *io_addr ) {
return virt_to_phys ( io_addr );
}
/*
* MMIO reads and writes up to 32 bits
*
*/
#define X86_READX( _api_func, _type ) \
static inline __always_inline _type \
IOAPI_INLINE ( x86, _api_func ) ( volatile _type *io_addr ) { \
return *io_addr; \
}
X86_READX ( readb, uint8_t );
X86_READX ( readw, uint16_t );
X86_READX ( readl, uint32_t );
#define X86_WRITEX( _api_func, _type ) \
static inline __always_inline void \
IOAPI_INLINE ( x86, _api_func ) ( _type data, \
volatile _type *io_addr ) { \
*io_addr = data; \
}
X86_WRITEX ( writeb, uint8_t );
X86_WRITEX ( writew, uint16_t );
X86_WRITEX ( writel, uint32_t );
/*
* PIO reads and writes up to 32 bits
*
*/
#define X86_INX( _insn_suffix, _type, _reg_prefix ) \
static inline __always_inline _type \
IOAPI_INLINE ( x86, in ## _insn_suffix ) ( volatile _type *io_addr ) { \
_type data; \
__asm__ __volatile__ ( "in" #_insn_suffix " %w1, %" _reg_prefix "0" \
: "=a" ( data ) : "Nd" ( io_addr ) ); \
return data; \
} \
static inline __always_inline void \
IOAPI_INLINE ( x86, ins ## _insn_suffix ) ( volatile _type *io_addr, \
_type *data, \
unsigned int count ) { \
unsigned int discard_D; \
__asm__ __volatile__ ( "rep ins" #_insn_suffix \
: "=D" ( discard_D ) \
: "d" ( io_addr ), "c" ( count ), \
"0" ( data ) ); \
}
X86_INX ( b, uint8_t, "b" );
X86_INX ( w, uint16_t, "w" );
X86_INX ( l, uint32_t, "k" );
#define X86_OUTX( _insn_suffix, _type, _reg_prefix ) \
static inline __always_inline void \
IOAPI_INLINE ( x86, out ## _insn_suffix ) ( _type data, \
volatile _type *io_addr ) { \
__asm__ __volatile__ ( "out" #_insn_suffix " %" _reg_prefix "0, %w1" \
: : "a" ( data ), "Nd" ( io_addr ) ); \
} \
static inline __always_inline void \
IOAPI_INLINE ( x86, outs ## _insn_suffix ) ( volatile _type *io_addr, \
const _type *data, \
unsigned int count ) { \
unsigned int discard_S; \
__asm__ __volatile__ ( "rep outs" #_insn_suffix \
: "=S" ( discard_S ) \
: "d" ( io_addr ), "c" ( count ), \
"0" ( data ) ); \
}
X86_OUTX ( b, uint8_t, "b" );
X86_OUTX ( w, uint16_t, "w" );
X86_OUTX ( l, uint32_t, "k" );
/*
* Slow down I/O
*
*/
static inline __always_inline void
IOAPI_INLINE ( x86, iodelay ) ( void ) {
__asm__ __volatile__ ( "outb %al, $0x80" );
}
/*
* Memory barrier
*
*/
static inline __always_inline void
IOAPI_INLINE ( x86, mb ) ( void ) {
__asm__ __volatile__ ( "lock; addl $0, 0(%%esp)" : : : "memory" );
}
#endif /* _GPXE_X86_IO_H */
+1
View File
@@ -9,6 +9,7 @@
#include <stdint.h>
#include <gpxe/list.h>
#include <realmode.h>
struct block_device;
-265
View File
@@ -1,265 +0,0 @@
#ifndef ETHERBOOT_IO_H
#define ETHERBOOT_IO_H
#include <stdint.h>
#include "virtaddr.h"
/* virt_to_bus converts an addresss inside of etherboot [_start, _end]
* into a memory access cards can use.
*/
#define virt_to_bus virt_to_phys
/* bus_to_virt reverses virt_to_bus, the address must be output
* from virt_to_bus to be valid. This function does not work on
* all bus addresses.
*/
#define bus_to_virt phys_to_virt
/* ioremap converts a random 32bit bus address into something
* etherboot can access.
*/
static inline void *ioremap(unsigned long bus_addr, unsigned long length __unused)
{
return bus_to_virt(bus_addr);
}
/* iounmap cleans up anything ioremap had to setup */
static inline void iounmap(void *virt_addr __unused)
{
return;
}
/*
* This file contains the definitions for the x86 IO instructions
* inb/inw/inl/outb/outw/outl and the "string versions" of the same
* (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
* versions of the single-IO instructions (inb_p/inw_p/..).
*
* This file is not meant to be obfuscating: it's just complicated
* to (a) handle it all in a way that makes gcc able to optimize it
* as well as possible and (b) trying to avoid writing the same thing
* over and over again with slight variations and possibly making a
* mistake somewhere.
*/
/*
* Thanks to James van Artsdalen for a better timing-fix than
* the two short jumps: using outb's to a nonexistent port seems
* to guarantee better timings even on fast machines.
*
* On the other hand, I'd like to be sure of a non-existent port:
* I feel a bit unsafe about using 0x80 (should be safe, though)
*
* Linus
*/
#ifdef SLOW_IO_BY_JUMPING
#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
#else
#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
#endif
#ifdef REALLY_SLOW_IO
#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
#else
#define SLOW_DOWN_IO __SLOW_DOWN_IO
#endif
/*
* readX/writeX() are used to access memory mapped devices. On some
* architectures the memory mapped IO stuff needs to be accessed
* differently. On the x86 architecture, we just read/write the
* memory location directly.
*/
static inline __attribute__ (( always_inline )) unsigned long
_readb ( volatile uint8_t *addr ) {
unsigned long data = *addr;
DBGIO ( "[%08lx] => %02lx\n", virt_to_phys ( addr ), data );
return data;
}
static inline __attribute__ (( always_inline )) unsigned long
_readw ( volatile uint16_t *addr ) {
unsigned long data = *addr;
DBGIO ( "[%08lx] => %04lx\n", virt_to_phys ( addr ), data );
return data;
}
static inline __attribute__ (( always_inline )) unsigned long
_readl ( volatile uint32_t *addr ) {
unsigned long data = *addr;
DBGIO ( "[%08lx] => %08lx\n", virt_to_phys ( addr ), data );
return data;
}
#define readb( addr ) _readb ( ( volatile uint8_t * ) (addr) )
#define readw( addr ) _readw ( ( volatile uint16_t * ) (addr) )
#define readl( addr ) _readl ( ( volatile uint32_t * ) (addr) )
static inline __attribute__ (( always_inline )) void
_writeb ( unsigned long data, volatile uint8_t *addr ) {
DBGIO ( "[%08lx] <= %02lx\n", virt_to_phys ( addr ), data );
*addr = data;
}
static inline __attribute__ (( always_inline )) void
_writew ( unsigned long data, volatile uint16_t *addr ) {
DBGIO ( "[%08lx] <= %04lx\n", virt_to_phys ( addr ), data );
*addr = data;
}
static inline __attribute__ (( always_inline )) void
_writel ( unsigned long data, volatile uint32_t *addr ) {
DBGIO ( "[%08lx] <= %08lx\n", virt_to_phys ( addr ), data );
*addr = data;
}
#define writeb( b, addr ) _writeb ( (b), ( volatile uint8_t * ) (addr) )
#define writew( b, addr ) _writew ( (b), ( volatile uint16_t * ) (addr) )
#define writel( b, addr ) _writel ( (b), ( volatile uint32_t * ) (addr) )
#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
/*
* Force strict CPU ordering.
* And yes, this is required on UP too when we're talking
* to devices.
*
* For now, "wmb()" doesn't actually do anything, as all
* Intel CPU's follow what Intel calls a *Processor Order*,
* in which all writes are seen in the program order even
* outside the CPU.
*
* I expect future Intel CPU's to have a weaker ordering,
* but I'd also expect them to finally get their act together
* and add some real memory barriers if so.
*
* Some non intel clones support out of order store. wmb() ceases to be a
* nop for these.
*/
#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
#define rmb() mb()
#define wmb() mb();
/*
* Talk about misusing macros..
*/
#define __OUT1(s,x) \
extern void __out##s(unsigned x value, unsigned short port); \
extern inline void __out##s(unsigned x value, unsigned short port) {
#define __OUT2(s,s1,s2) \
__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
#define __OUT(s,s1,x) \
__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
#define __IN1(s,x) \
extern unsigned x __in##s(unsigned short port); \
extern inline unsigned x __in##s(unsigned short port) { unsigned x _v;
#define __IN2(s,s1,s2) \
__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
#define __IN(s,s1,x,i...) \
__IN1(s,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
__IN1(s##c,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
__IN1(s##_p,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
__IN1(s##c_p,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
#define __INS(s) \
extern void ins##s(unsigned short port, void * addr, unsigned long count); \
extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
#define __OUTS(s) \
extern void outs##s(unsigned short port, const void * addr, unsigned long count); \
extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
__IN(b,"", char)
__IN(w,"",short)
__IN(l,"", long)
__OUT(b,"b",char)
__OUT(w,"w",short)
__OUT(l,,int)
__INS(b)
__INS(w)
__INS(l)
__OUTS(b)
__OUTS(w)
__OUTS(l)
/*
* Note that due to the way __builtin_constant_p() works, you
* - can't use it inside a inline function (it will never be true)
* - you don't have to worry about side effects within the __builtin..
*/
#define outb(val,port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outbc((val),(port)) : \
__outb((val),(port)))
#define inb(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inbc(port) : \
__inb(port))
#define outb_p(val,port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outbc_p((val),(port)) : \
__outb_p((val),(port)))
#define inb_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inbc_p(port) : \
__inb_p(port))
#define outw(val,port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outwc((val),(port)) : \
__outw((val),(port)))
#define inw(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inwc(port) : \
__inw(port))
#define outw_p(val,port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outwc_p((val),(port)) : \
__outw_p((val),(port)))
#define inw_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inwc_p(port) : \
__inw_p(port))
#define outl(val,port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outlc((val),(port)) : \
__outl((val),(port)))
#define inl(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inlc(port) : \
__inl(port))
#define outl_p(val,port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__outlc_p((val),(port)) : \
__outl_p((val),(port)))
#define inl_p(port) \
((__builtin_constant_p((port)) && (port) < 256) ? \
__inlc_p(port) : \
__inl_p(port))
#endif /* ETHERBOOT_IO_H */
+98 -205
View File
@@ -1,21 +1,109 @@
#ifndef LIBRM_H
#define LIBRM_H
/* Drag in protected-mode segment selector values */
#include "virtaddr.h"
#include "realmode.h"
/* Segment selectors as used in our protected-mode GDTs.
*
* Don't change these unless you really know what you're doing.
*/
#define VIRTUAL_CS 0x08
#define VIRTUAL_DS 0x10
#define PHYSICAL_CS 0x18
#define PHYSICAL_DS 0x20
#define REAL_CS 0x28
#define REAL_DS 0x30
#if 0
#define LONG_CS 0x38
#define LONG_DS 0x40
#endif
#ifndef ASSEMBLY
#include "stddef.h"
#include "string.h"
#ifdef UACCESS_LIBRM
#define UACCESS_PREFIX_librm
#else
#define UACCESS_PREFIX_librm __librm_
#endif
/*
* Data structures and type definitions
/* Variables in librm.S */
extern unsigned long virt_offset;
/**
* Convert physical address to user pointer
*
* @v phys_addr Physical address
* @ret userptr User pointer
*/
static inline __always_inline userptr_t
UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) {
return ( phys_addr - virt_offset );
}
/**
* Convert user buffer to physical address
*
* @v userptr User pointer
* @v offset Offset from user pointer
* @ret phys_addr Physical address
*/
static inline __always_inline unsigned long
UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) {
return ( userptr + offset + virt_offset );
}
static inline __always_inline userptr_t
UACCESS_INLINE ( librm, virt_to_user ) ( volatile const void *addr ) {
return trivial_virt_to_user ( addr );
}
static inline __always_inline void *
UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) {
return trivial_user_to_virt ( userptr, offset );
}
static inline __always_inline userptr_t
UACCESS_INLINE ( librm, userptr_add ) ( userptr_t userptr, off_t offset ) {
return trivial_userptr_add ( userptr, offset );
}
static inline __always_inline void
UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off,
userptr_t src, off_t src_off,
size_t len ) {
trivial_memcpy_user ( dest, dest_off, src, src_off, len );
}
static inline __always_inline void
UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off,
userptr_t src, off_t src_off,
size_t len ) {
trivial_memmove_user ( dest, dest_off, src, src_off, len );
}
static inline __always_inline void
UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset,
int c, size_t len ) {
trivial_memset_user ( buffer, offset, c, len );
}
static inline __always_inline size_t
UACCESS_INLINE ( librm, strlen_user ) ( userptr_t buffer, off_t offset ) {
return trivial_strlen_user ( buffer, offset );
}
static inline __always_inline off_t
UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset,
int c, size_t len ) {
return trivial_memchr_user ( buffer, offset, c, len );
}
/******************************************************************************
*
* Access to variables in .data16 and .text16
*
*/
/* Access to variables in .data16 and .text16 */
extern char *data16;
extern char *text16;
@@ -72,178 +160,6 @@ extern uint16_t __text16 ( rm_ds );
*/
extern void gateA20_set ( void );
/*
* librm_mgmt: functions for manipulating base memory and executing
* real-mode code.
*
* Full API documentation for these functions is in realmode.h.
*
*/
/* Macro for obtaining a physical address from a segment:offset pair. */
#define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )
/* Copy to/from base memory */
static inline __attribute__ (( always_inline )) void
copy_to_real_librm ( unsigned int dest_seg, unsigned int dest_off,
void *src, size_t n ) {
memcpy ( VIRTUAL ( dest_seg, dest_off ), src, n );
}
static inline __attribute__ (( always_inline )) void
copy_from_real_librm ( void *dest, unsigned int src_seg,
unsigned int src_off, size_t n ) {
memcpy ( dest, VIRTUAL ( src_seg, src_off ), n );
}
#define put_real_librm( var, dest_seg, dest_off ) \
do { \
* ( ( typeof(var) * ) VIRTUAL ( dest_seg, dest_off ) ) = var; \
} while ( 0 )
#define get_real_librm( var, src_seg, src_off ) \
do { \
var = * ( ( typeof(var) * ) VIRTUAL ( src_seg, src_off ) ); \
} while ( 0 )
#define copy_to_real copy_to_real_librm
#define copy_from_real copy_from_real_librm
#define put_real put_real_librm
#define get_real get_real_librm
/**
* A pointer to a user buffer
*
* Even though we could just use a void *, we use an intptr_t so that
* attempts to use normal pointers show up as compiler warnings. Such
* code is actually valid for librm, but not for libkir (i.e. under
* KEEP_IT_REAL), so it's good to have the warnings even under librm.
*/
typedef intptr_t userptr_t;
/**
* Add offset to user pointer
*
* @v ptr User pointer
* @v offset Offset
* @ret new_ptr New pointer value
*/
static inline __attribute__ (( always_inline )) userptr_t
userptr_add ( userptr_t ptr, off_t offset ) {
return ( ptr + offset );
}
/**
* Copy data to user buffer
*
* @v buffer User buffer
* @v offset Offset within user buffer
* @v src Source
* @v len Length
*/
static inline __attribute__ (( always_inline )) void
copy_to_user ( userptr_t buffer, off_t offset, const void *src, size_t len ) {
memcpy ( ( ( void * ) buffer + offset ), src, len );
}
/**
* Copy data from user buffer
*
* @v dest Destination
* @v buffer User buffer
* @v offset Offset within user buffer
* @v len Length
*/
static inline __attribute__ (( always_inline )) void
copy_from_user ( void *dest, userptr_t buffer, off_t offset, size_t len ) {
memcpy ( dest, ( ( void * ) buffer + offset ), len );
}
/**
* Copy data between user buffers
*
* @v dest Destination user buffer
* @v dest_off Offset within destination buffer
* @v src Source user buffer
* @v src_off Offset within source buffer
* @v len Length
*/
static inline __attribute__ (( always_inline )) void
memcpy_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
size_t len ) {
memcpy ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
len );
}
/**
* Copy data between user buffers, allowing for overlap
*
* @v dest Destination user buffer
* @v dest_off Offset within destination buffer
* @v src Source user buffer
* @v src_off Offset within source buffer
* @v len Length
*/
static inline __attribute__ (( always_inline )) void
memmove_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
size_t len ) {
memmove ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
len );
}
/**
* Fill user buffer with a constant byte
*
* @v buffer User buffer
* @v offset Offset within buffer
* @v c Constant byte with which to fill
* @v len Length
*/
static inline __attribute__ (( always_inline )) void
memset_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
memset ( ( ( void * ) buffer + offset ), c, len );
}
/**
* Find length of NUL-terminated string in user buffer
*
* @v buffer User buffer
* @v offset Offset within buffer
* @ret len Length of string (excluding NUL)
*/
static inline __attribute__ (( always_inline )) size_t
strlen_user ( userptr_t buffer, off_t offset ) {
return strlen ( ( void * ) buffer + offset );
}
/**
* Find character in user buffer
*
* @v buffer User buffer
* @v offset Starting offset within buffer
* @v c Character to search for
* @v len Length of user buffer
* @ret offset Offset of character, or <0 if not found
*/
static inline __attribute__ (( always_inline )) off_t
memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
void *found;
found = memchr ( ( ( void * ) buffer + offset ), c, len );
return ( found ? ( found - ( void * ) buffer ) : -1 );
}
/**
* Convert virtual address to user buffer
*
* @v virtual Virtual address
* @ret buffer User buffer
*
* This constructs a user buffer from an ordinary pointer. Use it
* when you need to pass a pointer to an internal buffer to a function
* that expects a @c userptr_t.
*/
static inline __attribute__ (( always_inline )) userptr_t
virt_to_user ( void * virtual ) {
return ( ( intptr_t ) virtual );
}
/**
* Convert segment:offset address to user buffer
*
@@ -251,32 +167,9 @@ virt_to_user ( void * virtual ) {
* @v offset Real-mode offset
* @ret buffer User buffer
*/
static inline __attribute__ (( always_inline )) userptr_t
static inline __always_inline userptr_t
real_to_user ( unsigned int segment, unsigned int offset ) {
return virt_to_user ( VIRTUAL ( segment, offset ) );
}
/**
* Convert physical address to user buffer
*
* @v physical Physical address
* @ret buffer User buffer
*/
static inline __attribute__ (( always_inline )) userptr_t
phys_to_user ( physaddr_t physical ) {
return virt_to_user ( phys_to_virt ( physical ) );
}
/**
* Convert user buffer to physical address
*
* @v buffer User buffer
* @v offset Offset within user buffer
* @ret physical Physical address
*/
static inline __attribute__ (( always_inline )) physaddr_t
user_to_phys ( userptr_t buffer, off_t offset ) {
return virt_to_phys ( ( void * ) buffer + offset );
return ( phys_to_user ( ( segment << 4 ) + offset ) );
}
extern uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size );
-35
View File
@@ -1,35 +0,0 @@
#ifndef _PCI_IO_H
#define _PCI_IO_H
#include <pcibios.h>
#include <pcidirect.h>
/** @file
*
* i386 PCI configuration space access
*
* We have two methods of PCI configuration space access: the PCI BIOS
* and direct Type 1 accesses. Selecting between them is via the
* compile-time switch -DCONFIG_PCI_DIRECT.
*
*/
#if CONFIG_PCI_DIRECT
#define pci_max_bus pcidirect_max_bus
#define pci_read_config_byte pcidirect_read_config_byte
#define pci_read_config_word pcidirect_read_config_word
#define pci_read_config_dword pcidirect_read_config_dword
#define pci_write_config_byte pcidirect_write_config_byte
#define pci_write_config_word pcidirect_write_config_word
#define pci_write_config_dword pcidirect_write_config_dword
#else /* CONFIG_PCI_DIRECT */
#define pci_max_bus pcibios_max_bus
#define pci_read_config_byte pcibios_read_config_byte
#define pci_read_config_word pcibios_read_config_word
#define pci_read_config_dword pcibios_read_config_dword
#define pci_write_config_byte pcibios_write_config_byte
#define pci_write_config_word pcibios_write_config_word
#define pci_write_config_dword pcibios_write_config_dword
#endif /* CONFIG_PCI_DIRECT */
#endif /* _PCI_IO_H */
-17
View File
@@ -1,17 +0,0 @@
/*
* Architecture-specific portion of pxe.h for Etherboot
*
* This file has to define the types SEGOFF16_t, SEGDESC_t and
* SEGSEL_t for use in other PXE structures. See pxe.h for details.
*/
#ifndef PXE_ADDR_H
#define PXE_ADDR_H
#define IS_NULL_SEGOFF16(x) ( ( (x).segment == 0 ) && ( (x).offset == 0 ) )
#define SEGOFF16_TO_PTR(x) ( VIRTUAL( (x).segment, (x).offset ) )
#define PTR_TO_SEGOFF16(ptr,segoff16) \
(segoff16).segment = SEGMENT(ptr); \
(segoff16).offset = OFFSET(ptr);
#endif /* PXE_ADDR_H */
+1 -1
View File
@@ -30,6 +30,6 @@ extern void pxe_hook_int1a ( void );
extern int pxe_unhook_int1a ( void );
extern void pxe_init_structures ( void );
extern int pxe_start_nbp ( void );
extern __cdecl void pxe_api_call ( struct i386_all_regs *ix86 );
extern __asmcall void pxe_api_call ( struct i386_all_regs *ix86 );
#endif /* _PXE_CALL_H */
@@ -7,9 +7,8 @@
*
*/
#include "stdint.h"
#include "pxe_addr.h" /* Architecture-specific PXE definitions */
#include "errno.h" /* PXE status codes */
#include <stdint.h>
#include <errno.h> /* PXE status codes */
/** @addtogroup pxe Preboot eXecution Environment (PXE) API
* @{
+45 -48
View File
@@ -1,45 +1,15 @@
#ifndef REALMODE_H
#define REALMODE_H
#ifndef ASSEMBLY
#include "stdint.h"
#include "registers.h"
#include "io.h"
#include <stdint.h>
#include <registers.h>
#include <gpxe/uaccess.h>
/*
* Data structures and type definitions
*
*/
/* Segment:offset structure. Note that the order within the structure
* is offset:segment.
*/
struct segoff {
uint16_t offset;
uint16_t segment;
} __attribute__ (( packed ));
typedef struct segoff segoff_t;
/* Macro hackery needed to stringify bits of inline assembly */
#define RM_XSTR(x) #x
#define RM_STR(x) RM_XSTR(x)
/* Drag in the selected real-mode transition library header */
#ifdef KEEP_IT_REAL
#include "libkir.h"
#else
#include "librm.h"
#endif
/*
* The API to some functions is identical between librm and libkir, so
* they are documented here, even though the prototypes are in librm.h
* and libkir.h.
*
*/
/*
* Declaration of variables in .data16
*
@@ -92,24 +62,53 @@ typedef struct segoff segoff_t;
* assembler output to make sure that it's doing the right thing.
*/
/*
* void copy_to_real ( uint16_t dest_seg, uint16_t dest_off,
* void *src, size_t n )
* void copy_from_real ( void *dest, uint16_t src_seg, uint16_t src_off,
* size_t n )
/**
* Copy data to base memory
*
* These functions can be used to copy data to and from arbitrary
* locations in base memory.
* @v dest_seg Destination segment
* @v dest_off Destination offset
* @v src Source
* @v len Length
*/
static inline __always_inline void
copy_to_real ( unsigned int dest_seg, unsigned int dest_off,
void *src, size_t n ) {
copy_to_user ( real_to_user ( dest_seg, dest_off ), 0, src, n );
}
/*
* put_real ( variable, uint16_t dest_seg, uint16_t dest_off )
* get_real ( variable, uint16_t src_seg, uint16_t src_off )
/**
* Copy data to base memory
*
* These macros can be used to read or write single variables to and
* from arbitrary locations in base memory. "variable" must be a
* variable of either 1, 2 or 4 bytes in length.
* @v dest Destination
* @v src_seg Source segment
* @v src_off Source offset
* @v len Length
*/
static inline __always_inline void
copy_from_real ( void *dest, unsigned int src_seg,
unsigned int src_off, size_t n ) {
copy_from_user ( dest, real_to_user ( src_seg, src_off ), 0, n );
}
/**
* Write a single variable to base memory
*
* @v var Variable to write
* @v dest_seg Destination segment
* @v dest_off Destination offset
*/
#define put_real( var, dest_seg, dest_off ) \
copy_to_real ( (dest_seg), (dest_off), &(var), sizeof (var) )
/**
* Read a single variable from base memory
*
* @v var Variable to read
* @v src_seg Source segment
* @v src_off Source offset
*/
#define get_real( var, src_seg, src_off ) \
copy_from_real ( &(var), (src_seg), (src_off), sizeof (var) )
/*
* REAL_CODE ( asm_code_str )
@@ -123,6 +122,4 @@ typedef struct segoff segoff_t;
*
*/
#endif /* ASSEMBLY */
#endif /* REALMODE_H */
+11 -2
View File
@@ -10,8 +10,7 @@
*
*/
#include "compiler.h" /* for doxygen */
#include "stdint.h"
#include <stdint.h>
/**
* A 16-bit general register.
@@ -184,4 +183,14 @@ struct i386_all_regs {
#define SF ( 1 << 7 )
#define OF ( 1 << 11 )
/* Segment:offset structure. Note that the order within the structure
* is offset:segment.
*/
struct segoff {
uint16_t offset;
uint16_t segment;
} PACKED;
typedef struct segoff segoff_t;
#endif /* REGISTERS_H */
+31 -5
View File
@@ -1,12 +1,38 @@
#ifndef ETHERBOOT_SETJMP_H
#define ETHERBOOT_SETJMP_H
#include <stdint.h>
#include <realmode.h>
/* Define a type for use by setjmp and longjmp */
#define JBLEN 6
typedef unsigned long jmp_buf[JBLEN];
/** A jump buffer */
typedef struct {
uint32_t retaddr;
uint32_t ebx;
uint32_t esp;
uint32_t ebp;
uint32_t esi;
uint32_t edi;
} jmp_buf[1];
extern int __cdecl setjmp (jmp_buf env);
extern void __cdecl longjmp (jmp_buf env, int val);
/** A real-mode-extended jump buffer */
typedef struct {
jmp_buf env;
uint16_t rm_ss;
uint16_t rm_sp;
} rmjmp_buf[1];
extern int __asmcall setjmp ( jmp_buf env );
extern void __asmcall longjmp ( jmp_buf env, int val );
#define rmsetjmp( _env ) ( { \
(_env)->rm_ss = rm_ss; \
(_env)->rm_sp = rm_sp; \
setjmp ( (_env)->env ); } ) \
#define rmlongjmp( _env, _val ) do { \
rm_ss = (_env)->rm_ss; \
rm_sp = (_env)->rm_sp; \
longjmp ( (_env)->env, (_val) ); \
} while ( 0 )
#endif /* ETHERBOOT_SETJMP_H */
-60
View File
@@ -1,60 +0,0 @@
#ifndef _SMBIOS_H
#define _SMBIOS_H
/** @file
*
* System Management BIOS
*/
#include <stdint.h>
/** An SMBIOS structure header */
struct smbios_header {
/** Type */
uint8_t type;
/** Length */
uint8_t len;
/** Handle */
uint16_t handle;
} __attribute__ (( packed ));
/** SMBIOS structure descriptor */
struct smbios_structure {
/** Copy of SMBIOS structure header */
struct smbios_header header;
/** Offset of structure within SMBIOS */
size_t offset;
/** Length of strings section */
size_t strings_len;
};
/** SMBIOS system information structure */
struct smbios_system_information {
/** SMBIOS structure header */
struct smbios_header header;
/** Manufacturer string */
uint8_t manufacturer;
/** Product string */
uint8_t product;
/** Version string */
uint8_t version;
/** Serial number string */
uint8_t serial;
/** UUID */
uint8_t uuid[16];
/** Wake-up type */
uint8_t wakeup;
} __attribute__ (( packed ));
/** SMBIOS system information structure type */
#define SMBIOS_TYPE_SYSTEM_INFORMATION 1
extern int find_smbios_structure ( unsigned int type,
struct smbios_structure *structure );
extern int read_smbios_structure ( struct smbios_structure *structure,
void *data, size_t len );
extern int read_smbios_string ( struct smbios_structure *structure,
unsigned int index,
void *data, size_t len );
#endif /* _SMBIOS_H */
+6
View File
@@ -95,4 +95,10 @@ static inline void * undi_get_drvdata ( struct undi_device *undi ) {
/** UNDI flag: START_UNDI has been called */
#define UNDI_FL_STARTED 0x0001
/** UNDI flag: UNDI_STARTUP and UNDI_INITIALIZE have been called */
#define UNDI_FL_INITIALIZED 0x0002
/** UNDI flag: keep stack resident */
#define UNDI_FL_KEEP_ALL 0x0004
#endif /* _UNDI_H */
-105
View File
@@ -1,105 +0,0 @@
#ifndef VIRTADDR_H
#define VIRTADDR_H
/* Segment selectors as used in our protected-mode GDTs.
*
* Don't change these unless you really know what you're doing.
*/
#define VIRTUAL_CS 0x08
#define VIRTUAL_DS 0x10
#define PHYSICAL_CS 0x18
#define PHYSICAL_DS 0x20
#define REAL_CS 0x28
#define REAL_DS 0x30
#if 0
#define LONG_CS 0x38
#define LONG_DS 0x40
#endif
#ifndef ASSEMBLY
#include "stdint.h"
#include "string.h"
#ifndef KEEP_IT_REAL
/*
* Without -DKEEP_IT_REAL, we are in 32-bit protected mode with a
* fixed link address but an unknown physical start address. Our GDT
* sets up code and data segments with an offset of virt_offset, so
* that link-time addresses can still work.
*
*/
/* C-callable function prototypes */
extern void relocate_to ( uint32_t new_phys_addr );
/* Variables in virtaddr.S */
extern unsigned long virt_offset;
/*
* Convert between virtual and physical addresses
*
*/
static inline unsigned long virt_to_phys ( volatile const void *virt_addr ) {
return ( ( unsigned long ) virt_addr ) + virt_offset;
}
static inline void * phys_to_virt ( unsigned long phys_addr ) {
return ( void * ) ( phys_addr - virt_offset );
}
static inline void copy_to_phys ( physaddr_t dest, const void *src,
size_t len ) {
memcpy ( phys_to_virt ( dest ), src, len );
}
static inline void copy_from_phys ( void *dest, physaddr_t src, size_t len ) {
memcpy ( dest, phys_to_virt ( src ), len );
}
static inline void copy_phys_to_phys ( physaddr_t dest, physaddr_t src,
size_t len ) {
memcpy ( phys_to_virt ( dest ), phys_to_virt ( src ), len );
}
#else /* KEEP_IT_REAL */
/*
* With -DKEEP_IT_REAL, we are in 16-bit real mode with fixed link
* addresses and a segmented memory model. We have separate code and
* data segments.
*
* Because we may be called in 16-bit protected mode (damn PXE spec),
* we cannot simply assume that physical = segment * 16 + offset.
* Instead, we have to look up the physical start address of the
* segment in the !PXE structure. We have to assume that
* virt_to_phys() is called only on pointers within the data segment,
* because nothing passes segment information to us.
*
* We don't implement phys_to_virt at all, because there will be many
* addresses that simply cannot be reached via a virtual address when
* the virtual address space is limited to 64kB!
*/
static inline unsigned long virt_to_phys ( volatile const void *virt_addr ) {
/* Cheat: just for now, do the segment*16+offset calculation */
uint16_t ds;
__asm__ ( "movw %%ds, %%ax" : "=a" ( ds ) : );
return ( 16 * ds + ( ( unsigned long ) virt_addr ) );
}
/* Define it as a deprecated function so that we get compile-time
* warnings, rather than just the link-time errors.
*/
extern void * phys_to_virt ( unsigned long phys_addr )
__attribute__ ((deprecated));
#endif /* KEEP_IT_REAL */
#endif /* ASSEMBLY */
#endif /* VIRTADDR_H */
@@ -6,27 +6,11 @@
#include <gpxe/ata.h>
#include <gpxe/netdevice.h>
#include <gpxe/settings.h>
#include <gpxe/sanboot.h>
#include <gpxe/abft.h>
#include <int13.h>
#include <usr/aoeboot.h>
/**
* Guess boot network device
*
* @ret netdev Boot network device
*/
static struct net_device * guess_boot_netdev ( void ) {
struct net_device *boot_netdev;
/* Just use the first network device */
for_each_netdev ( boot_netdev ) {
return boot_netdev;
}
return NULL;
}
int aoeboot ( const char *root_path ) {
static int aoeboot ( const char *root_path ) {
struct ata_device ata;
struct int13_drive drive;
int rc;
@@ -37,7 +21,7 @@ int aoeboot ( const char *root_path ) {
printf ( "AoE booting from %s\n", root_path );
/* FIXME: ugly, ugly hack */
struct net_device *netdev = guess_boot_netdev();
struct net_device *netdev = last_opened_netdev();
if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
printf ( "Could not attach AoE device: %s\n",
@@ -71,3 +55,8 @@ int aoeboot ( const char *root_path ) {
error_attach:
return rc;
}
struct sanboot_protocol aoe_sanboot_protocol __sanboot_protocol = {
.prefix = "aoe:",
.boot = aoeboot,
};
+14
View File
@@ -0,0 +1,14 @@
#include <gpxe/nap.h>
#include <realmode.h>
/**
* Save power by halting the CPU until the next interrupt
*
*/
static void bios_cpu_nap ( void ) {
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
"hlt\n\t"
"cli\n\t" ) : : );
}
PROVIDE_NAP ( pcbios, cpu_nap, bios_cpu_nap );
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <gpxe/uaccess.h>
#include <gpxe/smbios.h>
#include <realmode.h>
#include <pnpbios.h>
/** @file
*
* System Management BIOS
*
*/
/**
* Find SMBIOS
*
* @v smbios SMBIOS entry point descriptor structure to fill in
* @ret rc Return status code
*/
static int bios_find_smbios ( struct smbios *smbios ) {
union {
struct smbios_entry entry;
uint8_t bytes[256]; /* 256 is maximum length possible */
} u;
static unsigned int offset = 0;
size_t len;
unsigned int i;
uint8_t sum;
/* Try to find SMBIOS */
for ( ; offset < 0x10000 ; offset += 0x10 ) {
/* Read start of header and verify signature */
copy_from_real ( &u.entry, BIOS_SEG, offset,
sizeof ( u.entry ));
if ( u.entry.signature != SMBIOS_SIGNATURE )
continue;
/* Read whole header and verify checksum */
len = u.entry.len;
copy_from_real ( &u.bytes, BIOS_SEG, offset, len );
for ( i = 0 , sum = 0 ; i < len ; i++ ) {
sum += u.bytes[i];
}
if ( sum != 0 ) {
DBG ( "SMBIOS at %04x:%04x has bad checksum %02x\n",
BIOS_SEG, offset, sum );
continue;
}
/* Fill result structure */
DBG ( "Found SMBIOS v%d.%d entry point at %04x:%04x\n",
u.entry.major, u.entry.minor, BIOS_SEG, offset );
smbios->address = phys_to_user ( u.entry.smbios_address );
smbios->len = u.entry.smbios_len;
smbios->count = u.entry.smbios_count;
return 0;
}
DBG ( "No SMBIOS found\n" );
return -ENODEV;
}
PROVIDE_SMBIOS ( pcbios, find_smbios, bios_find_smbios );
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
*
* BIOS timer
*
*/
#include <gpxe/timer.h>
#include <realmode.h>
#include <bios.h>
/**
* Get current system time in ticks
*
* @ret ticks Current time, in ticks
*
* Use direct memory access to BIOS variables, longword 0040:006C
* (ticks today) and byte 0040:0070 (midnight crossover flag) instead
* of calling timeofday BIOS interrupt.
*/
static unsigned long bios_currticks ( void ) {
static int days = 0;
uint32_t ticks;
uint8_t midnight;
/* Re-enable interrupts so that the timer interrupt can occur */
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
"nop\n\t"
"nop\n\t"
"cli\n\t" ) : : );
get_real ( ticks, BDA_SEG, 0x006c );
get_real ( midnight, BDA_SEG, 0x0070 );
if ( midnight ) {
midnight = 0;
put_real ( midnight, BDA_SEG, 0x0070 );
days += 0x1800b0;
}
return ( days + ticks );
}
PROVIDE_TIMER_INLINE ( pcbios, udelay );
PROVIDE_TIMER ( pcbios, currticks, bios_currticks );
PROVIDE_TIMER_INLINE ( pcbios, ticks_per_sec );
-11
View File
@@ -7,17 +7,6 @@
*
*/
/**
* Hooked interrupt count
*
* At exit, after unhooking all possible interrupts, this counter
* should be examined. If it is non-zero, it means that we failed to
* unhook at least one interrupt vector, and so must not free up the
* memory we are using. (Note that this also implies that we should
* re-hook INT 15 in order to hide ourselves from the memory map).
*/
int hooked_bios_interrupts = 0;
/**
* Hook INT vector
*
@@ -136,6 +136,17 @@ static void ibft_set_ipaddr_option ( struct ibft_ipaddr *ipaddr,
ibft_set_ipaddr ( ipaddr, in );
}
/**
* Read IP address from iBFT (for debugging)
*
* @v strings iBFT string block descriptor
* @v string String field
* @ret ipaddr IP address string
*/
static const char * ibft_ipaddr ( struct ibft_ipaddr *ipaddr ) {
return inet_ntoa ( ipaddr->in );
}
/**
* Allocate a string within iBFT
*
@@ -214,6 +225,18 @@ static int ibft_set_string_option ( struct ibft_string_block *strings,
return 0;
}
/**
* Read string from iBFT (for debugging)
*
* @v strings iBFT string block descriptor
* @v string String field
* @ret data String content (or "<empty>")
*/
static const char * ibft_string ( struct ibft_string_block *strings,
struct ibft_string *string ) {
return ( ( ( char * ) strings->table ) + string->offset );
}
/**
* Fill in NIC portion of iBFT
*
@@ -231,11 +254,16 @@ static int ibft_fill_nic ( struct ibft_nic *nic,
/* Extract values from DHCP configuration */
ibft_set_ipaddr_option ( &nic->ip_address, &ip_setting );
DBG ( "iBFT NIC IP = %s\n", ibft_ipaddr ( &nic->ip_address ) );
ibft_set_ipaddr_option ( &nic->gateway, &gateway_setting );
DBG ( "iBFT NIC gateway = %s\n", ibft_ipaddr ( &nic->gateway ) );
ibft_set_ipaddr_option ( &nic->dns[0], &dns_setting );
DBG ( "iBFT NIC DNS = %s\n", ibft_ipaddr ( &nic->dns[0] ) );
if ( ( rc = ibft_set_string_option ( strings, &nic->hostname,
&hostname_setting ) ) != 0 )
return rc;
DBG ( "iBFT NIC hostname = %s\n",
ibft_string ( strings, &nic->hostname ) );
/* Derive subnet mask prefix from subnet mask */
fetch_ipv4_setting ( NULL, &netmask_setting, &netmask_addr );
@@ -245,11 +273,15 @@ static int ibft_fill_nic ( struct ibft_nic *nic,
netmask_addr.s_addr >>= 1;
}
nic->subnet_mask_prefix = netmask_count;
DBG ( "iBFT NIC subnet = /%d\n", nic->subnet_mask_prefix );
/* Extract values from net-device configuration */
memcpy ( nic->mac_address, netdev->ll_addr,
sizeof ( nic->mac_address ) );
DBG ( "iBFT NIC MAC = %s\n",
netdev->ll_protocol->ntoa ( nic->mac_address ) );
nic->pci_bus_dev_func = netdev->dev->desc.location;
DBG ( "iBFT NIC PCI = %04x\n", nic->pci_bus_dev_func );
return 0;
}
@@ -269,6 +301,8 @@ static int ibft_fill_initiator ( struct ibft_initiator *initiator,
if ( ( rc = ibft_set_string ( strings, &initiator->initiator_name,
initiator_iqn ) ) != 0 )
return rc;
DBG ( "iBFT initiator hostname = %s\n",
ibft_string ( strings, &initiator->initiator_name ) );
return 0;
}
@@ -286,17 +320,23 @@ static int ibft_fill_target_chap ( struct ibft_target *target,
struct iscsi_session *iscsi ) {
int rc;
if ( ! iscsi->initiator_username )
if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_FORWARD_REQUIRED ) )
return 0;
assert ( iscsi->initiator_username );
assert ( iscsi->initiator_password );
target->chap_type = IBFT_CHAP_ONE_WAY;
if ( ( rc = ibft_set_string ( strings, &target->chap_name,
iscsi->initiator_username ) ) != 0 )
return rc;
DBG ( "iBFT target username = %s\n",
ibft_string ( strings, &target->chap_name ) );
if ( ( rc = ibft_set_string ( strings, &target->chap_secret,
iscsi->initiator_password ) ) != 0 )
return rc;
DBG ( "iBFT target password = <redacted>\n" );
return 0;
}
@@ -313,19 +353,25 @@ static int ibft_fill_target_reverse_chap ( struct ibft_target *target,
struct iscsi_session *iscsi ) {
int rc;
if ( ! iscsi->target_username )
if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_REVERSE_REQUIRED ) )
return 0;
assert ( iscsi->target_password );
assert ( iscsi->initiator_username );
assert ( iscsi->initiator_password );
assert ( iscsi->target_username );
assert ( iscsi->target_password );
target->chap_type = IBFT_CHAP_MUTUAL;
if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_name,
iscsi->target_username ) ) != 0 )
return rc;
DBG ( "iBFT target reverse username = %s\n",
ibft_string ( strings, &target->chap_name ) );
if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_secret,
iscsi->target_password ) ) != 0 )
return rc;
DBG ( "iBFT target reverse password = <redacted>\n" );
return 0;
}
@@ -346,10 +392,14 @@ static int ibft_fill_target ( struct ibft_target *target,
/* Fill in Target values */
ibft_set_ipaddr ( &target->ip_address, sin_target->sin_addr );
DBG ( "iBFT target IP = %s\n", ibft_ipaddr ( &target->ip_address ) );
target->socket = ntohs ( sin_target->sin_port );
DBG ( "iBFT target port = %d\n", target->socket );
if ( ( rc = ibft_set_string ( strings, &target->target_name,
iscsi->target_iqn ) ) != 0 )
return rc;
DBG ( "iBFT target name = %s\n",
ibft_string ( strings, &target->target_name ) );
if ( ( rc = ibft_fill_target_chap ( target, strings, iscsi ) ) != 0 )
return rc;
if ( ( rc = ibft_fill_target_reverse_chap ( target, strings,
+7 -7
View File
@@ -144,7 +144,7 @@ static int int13_rw_sectors ( struct int13_drive *drive,
static int int13_read_sectors ( struct int13_drive *drive,
struct i386_all_regs *ix86 ) {
DBG ( "Read: " );
return int13_rw_sectors ( drive, ix86, drive->blockdev->read );
return int13_rw_sectors ( drive, ix86, drive->blockdev->op->read );
}
/**
@@ -163,7 +163,7 @@ static int int13_read_sectors ( struct int13_drive *drive,
static int int13_write_sectors ( struct int13_drive *drive,
struct i386_all_regs *ix86 ) {
DBG ( "Write: " );
return int13_rw_sectors ( drive, ix86, drive->blockdev->write );
return int13_rw_sectors ( drive, ix86, drive->blockdev->op->write );
}
/**
@@ -275,7 +275,7 @@ static int int13_extended_rw ( struct int13_drive *drive,
static int int13_extended_read ( struct int13_drive *drive,
struct i386_all_regs *ix86 ) {
DBG ( "Extended read: " );
return int13_extended_rw ( drive, ix86, drive->blockdev->read );
return int13_extended_rw ( drive, ix86, drive->blockdev->op->read );
}
/**
@@ -288,7 +288,7 @@ static int int13_extended_read ( struct int13_drive *drive,
static int int13_extended_write ( struct int13_drive *drive,
struct i386_all_regs *ix86 ) {
DBG ( "Extended write: " );
return int13_extended_rw ( drive, ix86, drive->blockdev->write );
return int13_extended_rw ( drive, ix86, drive->blockdev->op->write );
}
/**
@@ -322,7 +322,7 @@ static int int13_get_extended_parameters ( struct int13_drive *drive,
* INT 13 handler
*
*/
static __cdecl void int13 ( struct i386_all_regs *ix86 ) {
static __asmcall void int13 ( struct i386_all_regs *ix86 ) {
int command = ix86->regs.ah;
unsigned int bios_drive = ix86->regs.dl;
struct int13_drive *drive;
@@ -488,8 +488,8 @@ static void guess_int13_geometry ( struct int13_drive *drive ) {
/* Scan through partition table and modify guesses for heads
* and sectors_per_track if we find any used partitions.
*/
if ( drive->blockdev->read ( drive->blockdev, 0, 1,
virt_to_user ( &mbr ) ) == 0 ) {
if ( drive->blockdev->op->read ( drive->blockdev, 0, 1,
virt_to_user ( &mbr ) ) == 0 ) {
for ( i = 0 ; i < 4 ; i++ ) {
partition = &mbr.partitions[i];
if ( ! partition->type )
@@ -9,9 +9,9 @@
#include <gpxe/netdevice.h>
#include <gpxe/ibft.h>
#include <gpxe/init.h>
#include <gpxe/sanboot.h>
#include <int13.h>
#include <usr/autoboot.h>
#include <usr/iscsiboot.h>
struct setting keep_san_setting __setting = {
.name = "keep-san",
@@ -20,23 +20,7 @@ struct setting keep_san_setting __setting = {
.type = &setting_type_int8,
};
/**
* Guess boot network device
*
* @ret netdev Boot network device
*/
static struct net_device * guess_boot_netdev ( void ) {
struct net_device *boot_netdev;
/* Just use the first network device */
for_each_netdev ( boot_netdev ) {
return boot_netdev;
}
return NULL;
}
int iscsiboot ( const char *root_path ) {
static int iscsiboot ( const char *root_path ) {
struct scsi_device *scsi;
struct int13_drive *drive;
int keep_san;
@@ -69,7 +53,7 @@ int iscsiboot ( const char *root_path ) {
drive->blockdev = &scsi->blockdev;
/* FIXME: ugly, ugly hack */
struct net_device *netdev = guess_boot_netdev();
struct net_device *netdev = last_opened_netdev();
struct iscsi_session *iscsi =
container_of ( scsi->backend, struct iscsi_session, refcnt );
ibft_fill_data ( netdev, iscsi );
@@ -100,3 +84,8 @@ int iscsiboot ( const char *root_path ) {
err_alloc_scsi:
return rc;
}
struct sanboot_protocol iscsi_sanboot_protocol __sanboot_protocol = {
.prefix = "iscsi:",
.boot = iscsiboot,
};
@@ -36,9 +36,6 @@
/** Equivalent of NOWHERE for user pointers */
#define UNOWHERE ( ~UNULL )
/** Start of Etherboot text, as defined by the linker */
extern char _text[];
/** An external memory block */
struct external_memory {
/** Size of this memory block (excluding this header) */
@@ -95,7 +92,7 @@ static int init_eheap ( void ) {
}
}
if ( ! top ) {
if ( ! heap_size ) {
DBG ( "No external heap available\n" );
return -ENOMEM;
}
@@ -135,16 +132,16 @@ static void ecollect_free ( void ) {
* Calling realloc() with a new size of zero is a valid way to free a
* memory block.
*/
userptr_t urealloc ( userptr_t ptr, size_t new_size ) {
static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
struct external_memory extmem;
userptr_t new = ptr;
size_t align;
int rc;
/* Initialise external memory allocator if necessary */
if ( ! top ) {
if ( bottom == top ) {
if ( ( rc = init_eheap() ) != 0 )
return rc;
return UNULL;
}
/* Get block properties into extmem */
@@ -200,25 +197,4 @@ userptr_t urealloc ( userptr_t ptr, size_t new_size ) {
return ( new_size ? new : UNOWHERE );
}
/**
* Allocate external memory
*
* @v size Requested size
* @ret ptr Memory, or UNULL
*
* Memory is guaranteed to be aligned to a page boundary.
*/
userptr_t umalloc ( size_t size ) {
return urealloc ( UNULL, size );
}
/**
* Free external memory
*
* @v ptr Memory allocated by umalloc(), or UNULL
*
* If @c ptr is UNULL, no action is taken.
*/
void ufree ( userptr_t ptr ) {
urealloc ( ptr, 0 );
}
PROVIDE_UMALLOC ( memtop, urealloc, memtop_urealloc );
@@ -18,7 +18,6 @@
#include <stdint.h>
#include <gpxe/pci.h>
#include <pcibios.h>
#include <realmode.h>
/** @file
@@ -32,7 +31,7 @@
*
* @ret max_bus Maximum bus number
*/
int pcibios_max_bus ( void ) {
static int pcibios_max_bus ( void ) {
int discard_a, discard_D;
uint8_t max_bus;
@@ -104,3 +103,11 @@ int pcibios_write ( struct pci_device *pci, uint32_t command, uint32_t value ){
return ( ( status >> 8 ) & 0xff );
}
PROVIDE_PCIAPI ( pcbios, pci_max_bus, pcibios_max_bus );
PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_byte );
PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_word );
PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_dword );
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_byte );
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_word );
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_dword );
+13 -11
View File
@@ -119,7 +119,7 @@ static PXENV_EXIT_t pxenv_unknown ( struct s_PXENV_UNKNOWN *pxenv_unknown ) {
* @v es:di Address of PXE parameter block
* @ret ax PXE exit code
*/
__cdecl void pxe_api_call ( struct i386_all_regs *ix86 ) {
__asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
int opcode = ix86->regs.bx;
userptr_t parameters = real_to_user ( ix86->segs.es, ix86->regs.di );
size_t param_len;
@@ -339,7 +339,7 @@ __cdecl void pxe_api_call ( struct i386_all_regs *ix86 ) {
* @v es:di Address of PXE parameter block
* @ret ax PXE exit code
*/
__cdecl void pxe_loader_call ( struct i386_all_regs *ix86 ) {
__asmcall void pxe_loader_call ( struct i386_all_regs *ix86 ) {
userptr_t uparams = real_to_user ( ix86->segs.es, ix86->regs.di );
struct s_UNDI_LOADER params;
PXENV_EXIT_t ret;
@@ -433,22 +433,24 @@ void pxe_init_structures ( void ) {
* @ret rc Return status code
*/
int pxe_start_nbp ( void ) {
int discard_b, discard_c;
int discard_b, discard_c, discard_d, discard_D;
uint16_t rc;
/* Far call to PXE NBP */
__asm__ __volatile__ ( REAL_CODE ( "pushw %%cx\n\t"
"pushw %%ax\n\t"
"movw %%cx, %%es\n\t"
__asm__ __volatile__ ( REAL_CODE ( "movw %%cx, %%es\n\t"
"pushw %%es\n\t"
"pushw %%di\n\t"
"sti\n\t"
"lcall $0, $0x7c00\n\t"
"addw $4, %%sp\n\t" )
: "=a" ( rc ), "=b" ( discard_b ),
"=c" ( discard_c )
: "a" ( __from_text16 ( &ppxe ) ),
"b" ( __from_text16 ( &pxenv ) ),
"c" ( rm_cs )
: "edx", "esi", "edi", "ebp", "memory" );
"=c" ( discard_c ), "=d" ( discard_d ),
"=D" ( discard_D )
: "a" ( 0 ), "b" ( __from_text16 ( &pxenv ) ),
"c" ( rm_cs ),
"d" ( virt_to_phys ( &pxenv ) ),
"D" ( __from_text16 ( &ppxe ) )
: "esi", "ebp", "memory" );
return rc;
}
+21 -20
View File
@@ -18,15 +18,12 @@
*/
.arch i386
.section ".text16", "awx", @progbits
.section ".text16.data", "aw", @progbits
.section ".data16", "aw", @progbits
/****************************************************************************
* !PXE structure
****************************************************************************
*/
.section ".text16.data"
.section ".text16.data", "aw", @progbits
.globl ppxe
.align 16
ppxe:
@@ -44,10 +41,10 @@ ppxe:
.byte SegDescCnt /* SegDescCnt */
.word 0 /* FirstSelector */
pxe_segments:
.word 0, 0, 0, _data16_size /* Stack */
.word 0, 0, 0, _data16_size /* UNDIData */
.word 0, 0, 0, _text16_size /* UNDICode */
.word 0, 0, 0, _text16_size /* UNDICodeWrite */
.word 0, 0, 0, _data16_memsz /* Stack */
.word 0, 0, 0, _data16_memsz /* UNDIData */
.word 0, 0, 0, _text16_memsz /* UNDICode */
.word 0, 0, 0, _text16_memsz /* UNDICodeWrite */
.word 0, 0, 0, 0 /* BC_Data */
.word 0, 0, 0, 0 /* BC_Code */
.word 0, 0, 0, 0 /* BC_CodeWrite */
@@ -56,7 +53,7 @@ pxe_segments:
.size ppxe, . - ppxe
/* Define undiheader=0 as a weak symbol for non-ROM builds */
.section ".weak"
.section ".weak", "a", @nobits
.weak undiheader
undiheader:
@@ -64,7 +61,7 @@ undiheader:
* PXENV+ structure
****************************************************************************
*/
.section ".text16.data"
.section ".text16.data", "aw", @progbits
.globl pxenv
.align 16
pxenv:
@@ -76,15 +73,15 @@ pxenv:
.long 0 /* PMEntry */
.word 0 /* PMSelector */
.word 0 /* StackSeg */
.word _data16_size /* StackSize */
.word _data16_memsz /* StackSize */
.word 0 /* BC_CodeSeg */
.word 0 /* BC_CodeSize */
.word 0 /* BC_DataSeg */
.word 0 /* BC_DataSize */
.word 0 /* UNDIDataSeg */
.word _data16_size /* UNDIDataSize */
.word _data16_memsz /* UNDIDataSize */
.word 0 /* UNDICodeSeg */
.word _text16_size /* UNDICodeSize */
.word _text16_memsz /* UNDICodeSize */
.word ppxe, 0 /* PXEPtr */
.equ pxenv_length, . - pxenv
.size pxenv, . - pxenv
@@ -108,12 +105,12 @@ pxenv:
* somebody at Wyse has difficulty distinguishing between the
* words "may" and "must"...
*/
.section ".text16.null"
.section ".text16.null", "ax", @progbits
.code16
pxenv_null_entry:
jmp pxenv_entry
.section ".text16"
.section ".text16", "ax", @progbits
.code16
pxenv_entry:
pushl $pxe_api_call
@@ -137,7 +134,7 @@ pxenv_entry:
* none
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
.code16
pxe_entry:
pxe_entry_sp:
@@ -181,12 +178,13 @@ pxe_entry_common:
* Returns:
* %ax : 0x564e
* %es:bx : Far pointer to the PXENV+ structure
* %edx : Physical address of the PXENV+ structure
* CF cleared
* Corrupts:
* none
****************************************************************************
*/
.section ".text16"
.section ".text16", "ax", @progbits
.code16
.globl pxe_int_1a
pxe_int_1a:
@@ -194,9 +192,12 @@ pxe_int_1a:
cmpw $0x5650, %ax
jne 1f
/* INT 1A,5650 - PXE installation check */
pushw %cs
popw %es
xorl %edx, %edx
movw %cs, %dx
movw %dx, %es
movw $pxenv, %bx
shll $4, %edx
addl $pxenv, %edx
movw $0x564e, %ax
popfw
clc
@@ -205,6 +206,6 @@ pxe_int_1a:
popfw
ljmp *%cs:pxe_int_1a_vector
.section ".text16.data"
.section ".text16.data", "aw", @progbits
.globl pxe_int_1a_vector
pxe_int_1a_vector: .long 0
@@ -82,7 +82,7 @@ struct pxe_dhcp_packet_creator {
static struct pxe_dhcp_packet_creator pxe_dhcp_packet_creators[] = {
[CACHED_INFO_DHCPDISCOVER] = { create_fakedhcpdiscover },
[CACHED_INFO_DHCPACK] = { create_fakedhcpack },
[CACHED_INFO_BINL] = { create_fakeproxydhcpack },
[CACHED_INFO_BINL] = { create_fakepxebsack },
};
/* The case in which the caller doesn't supply a buffer is really

Some files were not shown because too many files have changed in this diff Show More