Merge lp:~lynxman/ubuntu/precise/ipxe/newsnapshot into lp:ubuntu/precise/ipxe

Proposed by Marc Cluet
Status: Merged
Merge reported by: James Page
Merged at revision: not available
Proposed branch: lp:~lynxman/ubuntu/precise/ipxe/newsnapshot
Merge into: lp:ubuntu/precise/ipxe
Diff against target: 106244 lines (+81146/-21640)
182 files modified
.pc/applied-patches (+0/-1)
.pc/baseroms-target.diff/src/Makefile.housekeeping (+0/-1153)
debian/changelog (+17/-0)
debian/control (+1/-1)
debian/copyright (+1/-1)
debian/ipxe.install (+3/-1)
debian/patches/disable-baddrivers.diff (+34/-0)
debian/patches/qemu-target.diff (+13/-0)
debian/patches/series (+2/-0)
debian/rules (+30/-1)
src/Makefile (+3/-1)
src/Makefile.housekeeping (+0/-1)
src/arch/i386/Makefile.pcbios (+1/-0)
src/arch/i386/core/cmdline.c (+0/-123)
src/arch/i386/core/relocate.c (+16/-9)
src/arch/i386/core/runtime.c (+249/-0)
src/arch/i386/drivers/net/undi.c (+1/-1)
src/arch/i386/drivers/net/undinet.c (+31/-8)
src/arch/i386/drivers/net/undionly.c (+10/-2)
src/arch/i386/include/bits/errfile.h (+1/-0)
src/arch/i386/include/pxe.h (+48/-3)
src/arch/i386/include/pxe_api.h (+6/-118)
src/arch/i386/interface/pxe/pxe_call.c (+41/-273)
src/arch/i386/interface/pxe/pxe_exit_hook.c (+60/-0)
src/arch/i386/interface/pxe/pxe_file.c (+56/-59)
src/arch/i386/interface/pxe/pxe_preboot.c (+83/-31)
src/arch/i386/interface/pxe/pxe_tftp.c (+19/-5)
src/arch/i386/interface/pxe/pxe_udp.c (+18/-4)
src/arch/i386/interface/pxe/pxe_undi.c (+383/-137)
src/arch/i386/interface/syslinux/comboot_call.c (+2/-2)
src/arch/i386/prefix/exeprefix.S (+1/-1)
src/arch/i386/prefix/kkkpxeprefix.S (+19/-0)
src/arch/i386/prefix/libprefix.S (+19/-24)
src/arch/i386/prefix/lkrnprefix.S (+13/-2)
src/arch/i386/prefix/pxeprefix.S (+9/-6)
src/arch/i386/prefix/romprefix.S (+10/-16)
src/arch/i386/prefix/undiloader.S (+3/-1)
src/arch/i386/transitions/liba20.S (+6/-3)
src/arch/i386/transitions/librm.S (+14/-14)
src/config/defaults/pcbios.h (+2/-0)
src/config/general.h (+6/-6)
src/core/assert.c (+30/-0)
src/core/exec.c (+55/-0)
src/core/getopt.c (+5/-0)
src/core/image.c (+6/-2)
src/crypto/asn1.c (+48/-27)
src/crypto/x509.c (+1/-1)
src/drivers/infiniband/arbel.c (+537/-280)
src/drivers/infiniband/arbel.h (+34/-2)
src/drivers/infiniband/hermon.c (+1043/-921)
src/drivers/infiniband/hermon.h (+23/-2)
src/drivers/infiniband/linda.c (+2430/-0)
src/drivers/infiniband/linda.h (+276/-0)
src/drivers/infiniband/linda_fw.c (+1069/-0)
src/drivers/net/ath/ath.h (+239/-0)
src/drivers/net/ath/ath5k/ath5k.c (+1698/-0)
src/drivers/net/ath/ath5k/ath5k.h (+1279/-0)
src/drivers/net/ath/ath5k/ath5k_attach.c (+340/-0)
src/drivers/net/ath/ath5k/ath5k_caps.c (+154/-0)
src/drivers/net/ath/ath5k/ath5k_desc.c (+544/-0)
src/drivers/net/ath/ath5k/ath5k_dma.c (+631/-0)
src/drivers/net/ath/ath5k/ath5k_eeprom.c (+1760/-0)
src/drivers/net/ath/ath5k/ath5k_gpio.c (+122/-0)
src/drivers/net/ath/ath5k/ath5k_initvals.c (+1560/-0)
src/drivers/net/ath/ath5k/ath5k_pcu.c (+534/-0)
src/drivers/net/ath/ath5k/ath5k_phy.c (+2581/-0)
src/drivers/net/ath/ath5k/ath5k_qcu.c (+390/-0)
src/drivers/net/ath/ath5k/ath5k_reset.c (+1174/-0)
src/drivers/net/ath/ath5k/ath5k_rfkill.c (+107/-0)
src/drivers/net/ath/ath5k/base.h (+145/-0)
src/drivers/net/ath/ath5k/desc.h (+332/-0)
src/drivers/net/ath/ath5k/eeprom.h (+451/-0)
src/drivers/net/ath/ath5k/reg.h (+2589/-0)
src/drivers/net/ath/ath5k/rfbuffer.h (+1181/-0)
src/drivers/net/ath/ath5k/rfgain.h (+516/-0)
src/drivers/net/ath/ath9k/ani.h (+168/-0)
src/drivers/net/ath/ath9k/ar5008_initvals.h (+672/-0)
src/drivers/net/ath/ath9k/ar9001_initvals.h (+1356/-0)
src/drivers/net/ath/ath9k/ar9002_initvals.h (+3264/-0)
src/drivers/net/ath/ath9k/ar9002_phy.h (+613/-0)
src/drivers/net/ath/ath9k/ar9003_2p2_initvals.h (+1864/-0)
src/drivers/net/ath/ath9k/ar9003_eeprom.h (+338/-0)
src/drivers/net/ath/ath9k/ar9003_mac.h (+125/-0)
src/drivers/net/ath/ath9k/ar9003_phy.h (+1124/-0)
src/drivers/net/ath/ath9k/ar9340_initvals.h (+1525/-0)
src/drivers/net/ath/ath9k/ar9485_initvals.h (+1161/-0)
src/drivers/net/ath/ath9k/ath9k.c (+208/-0)
src/drivers/net/ath/ath9k/ath9k.h (+521/-0)
src/drivers/net/ath/ath9k/ath9k_ani.c (+733/-0)
src/drivers/net/ath/ath9k/ath9k_ar5008_phy.c (+1663/-0)
src/drivers/net/ath/ath9k/ath9k_ar9002_calib.c (+997/-0)
src/drivers/net/ath/ath9k/ath9k_ar9002_hw.c (+607/-0)
src/drivers/net/ath/ath9k/ath9k_ar9002_mac.c (+454/-0)
src/drivers/net/ath/ath9k/ath9k_ar9002_phy.c (+578/-0)
src/drivers/net/ath/ath9k/ath9k_ar9003_calib.c (+932/-0)
src/drivers/net/ath/ath9k/ath9k_ar9003_eeprom.c (+5005/-0)
src/drivers/net/ath/ath9k/ath9k_ar9003_hw.c (+409/-0)
src/drivers/net/ath/ath9k/ath9k_ar9003_mac.c (+669/-0)
src/drivers/net/ath/ath9k/ath9k_ar9003_phy.c (+1277/-0)
src/drivers/net/ath/ath9k/ath9k_calib.c (+403/-0)
src/drivers/net/ath/ath9k/ath9k_common.c (+69/-0)
src/drivers/net/ath/ath9k/ath9k_eeprom.c (+551/-0)
src/drivers/net/ath/ath9k/ath9k_eeprom_4k.c (+1078/-0)
src/drivers/net/ath/ath9k/ath9k_eeprom_9287.c (+1019/-0)
src/drivers/net/ath/ath9k/ath9k_eeprom_def.c (+1351/-0)
src/drivers/net/ath/ath9k/ath9k_hw.c (+2067/-0)
src/drivers/net/ath/ath9k/ath9k_init.c (+593/-0)
src/drivers/net/ath/ath9k/ath9k_mac.c (+733/-0)
src/drivers/net/ath/ath9k/ath9k_main.c (+916/-0)
src/drivers/net/ath/ath9k/ath9k_recv.c (+521/-0)
src/drivers/net/ath/ath9k/ath9k_xmit.c (+813/-0)
src/drivers/net/ath/ath9k/calib.h (+115/-0)
src/drivers/net/ath/ath9k/common.h (+56/-0)
src/drivers/net/ath/ath9k/eeprom.h (+714/-0)
src/drivers/net/ath/ath9k/hw-ops.h (+268/-0)
src/drivers/net/ath/ath9k/hw.h (+995/-0)
src/drivers/net/ath/ath9k/mac.h (+708/-0)
src/drivers/net/ath/ath9k/phy.h (+51/-0)
src/drivers/net/ath/ath9k/reg.h (+1919/-0)
src/drivers/net/ath/ath_hw.c (+183/-0)
src/drivers/net/ath/ath_key.c (+82/-0)
src/drivers/net/ath/ath_main.c (+59/-0)
src/drivers/net/ath/ath_regd.c (+602/-0)
src/drivers/net/ath/reg.h (+64/-0)
src/drivers/net/ath/regd.h (+263/-0)
src/drivers/net/ath/regd_common.h (+481/-0)
src/drivers/net/ath5k/ath5k.c (+0/-1698)
src/drivers/net/ath5k/ath5k.h (+0/-1279)
src/drivers/net/ath5k/ath5k_attach.c (+0/-340)
src/drivers/net/ath5k/ath5k_caps.c (+0/-154)
src/drivers/net/ath5k/ath5k_desc.c (+0/-544)
src/drivers/net/ath5k/ath5k_dma.c (+0/-631)
src/drivers/net/ath5k/ath5k_eeprom.c (+0/-1760)
src/drivers/net/ath5k/ath5k_gpio.c (+0/-122)
src/drivers/net/ath5k/ath5k_initvals.c (+0/-1560)
src/drivers/net/ath5k/ath5k_pcu.c (+0/-534)
src/drivers/net/ath5k/ath5k_phy.c (+0/-2581)
src/drivers/net/ath5k/ath5k_qcu.c (+0/-390)
src/drivers/net/ath5k/ath5k_reset.c (+0/-1174)
src/drivers/net/ath5k/ath5k_rfkill.c (+0/-107)
src/drivers/net/ath5k/base.h (+0/-145)
src/drivers/net/ath5k/desc.h (+0/-332)
src/drivers/net/ath5k/eeprom.h (+0/-451)
src/drivers/net/ath5k/reg.h (+0/-2589)
src/drivers/net/ath5k/rfbuffer.h (+0/-1181)
src/drivers/net/ath5k/rfgain.h (+0/-516)
src/drivers/net/bnx2.c (+2697/-0)
src/drivers/net/bnx2.h (+4598/-0)
src/drivers/net/bnx2_fw.h (+3494/-0)
src/drivers/net/e1000/e1000_main.c (+1/-1)
src/drivers/net/e1000e/e1000e_main.c (+1/-1)
src/drivers/net/ipoib.c (+13/-8)
src/drivers/net/rtl8139.c (+1/-1)
src/drivers/net/vmxnet3.c (+669/-0)
src/drivers/net/vmxnet3.h (+497/-0)
src/hci/commands/image_cmd.c (+3/-6)
src/hci/commands/time_cmd.c (+0/-40)
src/image/script.c (+8/-2)
src/include/assert.h (+3/-0)
src/include/ipxe/asn1.h (+12/-0)
src/include/ipxe/dhcp.h (+6/-3)
src/include/ipxe/errfile.h (+3/-0)
src/include/ipxe/list.h (+200/-10)
src/include/ipxe/net80211.h (+1/-1)
src/include/ipxe/pci.h (+3/-0)
src/include/ipxe/tcp.h (+10/-0)
src/include/ipxe/test.h (+45/-0)
src/include/usr/imgmgmt.h (+0/-5)
src/net/fakedhcp.c (+6/-3)
src/net/fc.c (+1/-1)
src/net/infiniband.c (+11/-10)
src/net/netdevice.c (+23/-3)
src/net/tcp.c (+4/-4)
src/net/tcp/iscsi.c (+39/-12)
src/net/udp/dhcp.c (+25/-23)
src/tests/list_test.c (+407/-0)
src/tests/test.c (+142/-0)
src/usr/autoboot.c (+1/-1)
src/usr/imgmgmt.c (+26/-112)
src/usr/lotest.c (+89/-61)
src/util/parserom.pl (+1/-1)
src/util/romcheck.pl (+54/-0)
To merge this branch: bzr merge lp:~lynxman/ubuntu/precise/ipxe/newsnapshot
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Andres Rodriguez (community) Needs Fixing
Review via email: mp+88329@code.launchpad.net

Description of the change

ipxe (1.0.0+git-2.55f6c88-0ubuntu1) precise; urgency=low

  * New snapshot from upstream git repository.
  * Added rules for automatic git branch refresh.
  * Changed rom target from allbaseroms to allroms.
  * Added patch to disable bad roms.

To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote :

Hi Mark

Thanks for proposing this merge; here's some feedback

1) I might be missing something but I can't see "Added rules for automatic git branch refresh." in the changes

2) You should really import the new orig.tar.gz into the branch using "bzr merge-upstream"; that way when a sponsor branches and then does bzr bd -S all of the required data including the orig.tar.gz is present in the branch.

3) Please can you apply all patches; at the moment the branch all of them apart from the new patch applied.

Ping me on IRC if you need help with any of the above.

Cheers

James

review: Needs Fixing
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Hi Marc,

Could you please update the your branch to make it so it matches the new changes to the packaging please?

Other than that looks good. Would also be a good idea to add a debian/watch file.

Cheers.

review: Needs Fixing
Revision history for this message
Marc Cluet (lynxman) wrote :

Hi James

Fixed the branch with your suggestions, could you please review again?

Thanks

> Hi Mark
>
> Thanks for proposing this merge; here's some feedback
>
> 1) I might be missing something but I can't see "Added rules for automatic git
> branch refresh." in the changes
>
> 2) You should really import the new orig.tar.gz into the branch using "bzr
> merge-upstream"; that way when a sponsor branches and then does bzr bd -S all
> of the required data including the orig.tar.gz is present in the branch.
>
> 3) Please can you apply all patches; at the moment the branch all of them
> apart from the new patch applied.
>
> Ping me on IRC if you need help with any of the above.
>
> Cheers
>
> James

Revision history for this message
Marc Cluet (lynxman) wrote :

Hi Andres

Fixed the branch with your suggestions, could you please review again?

Thanks

> Hi Marc,
>
> Could you please update the your branch to make it so it matches the new
> changes to the packaging please?
>
> Other than that looks good. Would also be a good idea to add a debian/watch
> file.
>
> Cheers.

Revision history for this message
James Page (james-page) wrote :

Hi Mark

Thanks for updating the branch; sorry but more comments:

1) Please can you merge the two new changelog entries you have created - its all one change to the package really.

2) I tested the get-orig-source target and I got different results to the orig.tar.gz that is imported into the branch; and some error messages. The target tries to parse the version string into a date format which it then uses to generate the resulting tarball - however as the version string does not contain a valid date it fails.

It would be good to either align the versioning to what the rules are trying todo as this makes more sense.

3) This third point in really for clarity in the changelog:

* Changed rom target from allbaseroms to allroms.
* Added new target allqemu for qemu package.

Why? It would be nice to document in the changelog entry why we are building using different targets.

4) Lintian Warnings

W: ipxe source: brace-expansion-in-debhelper-config-file debian/ipxe.install
W: ipxe source: syntax-error-in-dep5-copyright paragraph 6 after the field license: THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
W: ipxe source: out-of-date-standards-version 3.9.1 (current is 3.9.2)

It would be nice to tidy these up as part of the new upstream release - specifically the first one which works by accident rather than by design and might not work in the future.

Any luck on contacting the upstream maintainer.

Cheers

James

review: Needs Fixing
Revision history for this message
Marc Cluet (lynxman) wrote :

Hi James,

No luck with the upstream maintainer, I contacted him but he wasn't open to collaboration unfortunately.

I've just refreshed the branch with all your suggestions, ready for review.

9. By Marc Cluet

New upstream snapshot.

10. By Marc Cluet

* Added rules for automatic git branch refresh.
* Changed rom target from allbaseroms to allroms.
  - recommended behaviour by upstream, building all full roms is neither
    recommended nor a desired user experience
* Added new target allqemu for qemu package.
  - created new build target to build full rom drivers just for qemu
    package purposes
* Cleaned lintian errors from debian package
  - Removed brace extension in ipxe.install
  - Updated standards to 3.9.2
  - Fixed copyright file not machine readable

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '.pc/applied-patches'
2--- .pc/applied-patches 2011-07-31 20:57:02 +0000
3+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
4@@ -1,1 +0,0 @@
5-baseroms-target.diff
6
7=== removed directory '.pc/baseroms-target.diff'
8=== removed directory '.pc/baseroms-target.diff/src'
9=== removed file '.pc/baseroms-target.diff/src/Makefile.housekeeping'
10--- .pc/baseroms-target.diff/src/Makefile.housekeeping 2011-07-31 20:57:02 +0000
11+++ .pc/baseroms-target.diff/src/Makefile.housekeeping 1970-01-01 00:00:00 +0000
12@@ -1,1153 +0,0 @@
13-# -*- makefile -*- : Force emacs to use Makefile mode
14-#
15-# This file contains various boring housekeeping functions that would
16-# otherwise seriously clutter up the main Makefile.
17-
18-###############################################################################
19-#
20-# Find a usable "echo -e" substitute.
21-#
22-TAB := $(shell $(PRINTF) '\t')
23-ECHO_E_ECHO := $(ECHO)
24-ECHO_E_ECHO_E := $(ECHO) -e
25-ECHO_E_BIN_ECHO := /bin/echo
26-ECHO_E_BIN_ECHO_E := /bin/echo -e
27-ECHO_E_ECHO_TAB := $(shell $(ECHO_E_ECHO) '\t' | cat)
28-ECHO_E_ECHO_E_TAB := $(shell $(ECHO_E_ECHO_E) '\t' | cat)
29-ECHO_E_BIN_ECHO_TAB := $(shell $(ECHO_E_BIN_ECHO) '\t')
30-ECHO_E_BIN_ECHO_E_TAB := $(shell $(ECHO_E_BIN_ECHO_E) '\t')
31-
32-ifeq ($(ECHO_E_ECHO_TAB),$(TAB))
33-ECHO_E := $(ECHO_E_ECHO)
34-endif
35-ifeq ($(ECHO_E_ECHO_E_TAB),$(TAB))
36-ECHO_E := $(ECHO_E_ECHO_E)
37-endif
38-ifeq ($(ECHO_E_BIN_ECHO_TAB),$(TAB))
39-ECHO_E := $(ECHO_E_BIN_ECHO)
40-endif
41-ifeq ($(ECHO_E_BIN_ECHO_E_TAB),$(TAB))
42-ECHO_E := $(ECHO_E_BIN_ECHO_E)
43-endif
44-
45-.echocheck :
46-ifdef ECHO_E
47- @$(TOUCH) $@
48-else
49- @$(PRINTF) '%24s : x%sx\n' 'tab' '$(TAB)'
50- @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_ECHO) \t"' \
51- '$(ECHO_E_ECHO_TAB)'
52- @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_ECHO_E) \t"' \
53- '$(ECHO_E_ECHO_E_TAB)'
54- @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_BIN_ECHO) \t"' \
55- '$(ECHO_E_BIN_ECHO_TAB)'
56- @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_BIN_ECHO_E) \t"' \
57- '$(ECHO_E_BIN_ECHO_E_TAB)'
58- @$(ECHO) "No usable \"echo -e\" substitute found"
59- @exit 1
60-endif
61-MAKEDEPS += .echocheck
62-VERYCLEANUP += .echocheck
63-
64-echo :
65- @$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
66-
67-###############################################################################
68-#
69-# Generate a usable "seq" substitute
70-#
71-define seq
72- $(shell awk 'BEGIN { for ( i = $(1) ; i <= $(2) ; i++ ) print i }')
73-endef
74-
75-###############################################################################
76-#
77-# Determine host OS
78-#
79-HOST_OS := $(shell uname -s)
80-hostos :
81- @$(ECHO) $(HOST_OS)
82-
83-###############################################################################
84-#
85-# Determine compiler
86-
87-CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | cut -d" " -f2)
88-ccdefs:
89- @$(ECHO) $(CCDEFS)
90-
91-ifeq ($(filter __ICC,$(CCDEFS)),__ICC)
92-CCTYPE := icc
93-else
94-CCTYPE := gcc
95-endif
96-cctype:
97- @$(ECHO) $(CCTYPE)
98-
99-###############################################################################
100-#
101-# Check for tools that can cause failed builds
102-#
103-
104-ifeq ($(CCTYPE),gcc)
105-GCC_2_96_BANNER := $(shell $(CC) -v 2>&1 | grep -is 'gcc version 2\.96')
106-ifneq ($(GCC_2_96_BANNER),)
107-$(warning gcc 2.96 is unsuitable for compiling iPXE)
108-$(warning Use gcc 2.95 or a newer version instead)
109-$(error Unsuitable build environment found)
110-endif
111-endif
112-
113-PERL_UNICODE_CHECK := $(shell $(PERL) -e 'use bytes; print chr(255)' | wc -c)
114-ifeq ($(PERL_UNICODE_CHECK),2)
115-$(warning Your Perl version has a Unicode handling bug)
116-$(warning Execute this command before building iPXE:)
117-$(warning export LANG=$${LANG%.UTF-8})
118-$(error Unsuitable build environment found)
119-endif
120-
121-LD_GOLD_BANNER := $(shell $(LD) -v 2>&1 | grep 'GNU gold')
122-ifneq ($(LD_GOLD_BANNER),)
123-$(warning GNU gold is unsuitable for building iPXE)
124-$(warning Use GNU ld instead)
125-$(error Unsuitable build environment found)
126-endif
127-
128-###############################################################################
129-#
130-# Check for various tool workarounds
131-#
132-
133-WORKAROUND_CFLAGS :=
134-WORKAROUND_ASFLAGS :=
135-WORKAROUND_LDFLAGS :=
136-
137-# Make syntax does not allow use of comma or space in certain places.
138-# This ugly workaround is suggested in the manual.
139-#
140-COMMA := ,
141-EMPTY :=
142-SPACE := $(EMPTY) $(EMPTY)
143-
144-# Check for an old version of gas (binutils 2.9.1)
145-#
146-OLDGAS := $(shell $(AS) --version | grep -q '2\.9\.1' && $(ECHO) -DGAS291)
147-WORKAROUND_CFLAGS += $(OLDGAS)
148-oldgas :
149- @$(ECHO) $(oldgas)
150-
151-# Some widespread patched versions of gcc include -fstack-protector by
152-# default, even when -ffreestanding is specified. We therefore need
153-# to disable -fstack-protector if the compiler supports it.
154-#
155-ifeq ($(CCTYPE),gcc)
156-SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
157- -o /dev/null >/dev/null 2>&1
158-SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
159-WORKAROUND_CFLAGS += $(SP_FLAGS)
160-endif
161-
162-# Some widespread patched versions of gcc include -fPIE -Wl,-pie by
163-# default. Note that gcc will exit *successfully* if it fails to
164-# recognise an option that starts with "no", so we have to test for
165-# output on stderr instead of checking the exit status.
166-#
167-ifeq ($(CCTYPE),gcc)
168-PIE_TEST = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ]
169-PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie')
170-WORKAROUND_CFLAGS += $(PIE_FLAGS)
171-endif
172-
173-# gcc 4.4 generates .eh_frame sections by default, which distort the
174-# output of "size". Inhibit this.
175-#
176-ifeq ($(CCTYPE),gcc)
177-CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -x c -c /dev/null \
178- -o /dev/null >/dev/null 2>&1
179-CFI_FLAGS := $(shell $(CFI_TEST) && $(ECHO) '-fno-dwarf2-cfi-asm')
180-WORKAROUND_CFLAGS += $(CFI_FLAGS)
181-endif
182-
183-# gcc 4.6 generates spurious warnings if -Waddress is in force.
184-# Inhibit this.
185-#
186-ifeq ($(CCTYPE),gcc)
187-WNA_TEST = $(CC) -Wno-address -x c -c /dev/null -o /dev/null >/dev/null 2>&1
188-WNA_FLAGS := $(shell $(WNA_TEST) && $(ECHO) '-Wno-address')
189-WORKAROUND_CFLAGS += $(WNA_FLAGS)
190-endif
191-
192-# Some versions of gas choke on division operators, treating them as
193-# comment markers. Specifying --divide will work around this problem,
194-# but isn't available on older gas versions.
195-#
196-DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
197-DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
198-WORKAROUND_ASFLAGS += $(DIVIDE_FLAGS)
199-
200-###############################################################################
201-#
202-# Build verbosity
203-#
204-ifeq ($(V),1)
205-Q :=
206-QM := @\#
207-else
208-Q := @
209-QM := @
210-endif
211-
212-###############################################################################
213-#
214-# Set BIN according to whatever was specified on the command line as
215-# the build target.
216-#
217-
218-# Determine how many different BIN directories are mentioned in the
219-# make goals.
220-#
221-BIN_GOALS := $(filter bin/% bin-%,$(MAKECMDGOALS))
222-BIN_GOALS_BINS := $(sort $(foreach BG,$(BIN_GOALS),\
223- $(firstword $(subst /, ,$(BG)))))
224-NUM_BINS := $(words $(BIN_GOALS_BINS))
225-
226-ifeq ($(NUM_BINS),0)
227-
228-# No BIN directory was specified. Set BIN to "bin" as a sensible
229-# default.
230-
231-BIN := bin
232-
233-else # NUM_BINS == 0
234-
235-ifeq ($(NUM_BINS),1)
236-
237-# If exactly one BIN directory was specified, set BIN to match this
238-# directory.
239-#
240-BIN := $(firstword $(BIN_GOALS_BINS))
241-
242-else # NUM_BINS == 1
243-
244-# More than one BIN directory was specified. We cannot handle the
245-# latter case within a single make invocation, so set up recursive
246-# targets for each BIN directory. Use exactly one target for each BIN
247-# directory since running multiple make invocations within the same
248-# BIN directory is likely to cause problems.
249-#
250-# Leave $(BIN) undefined. This has implications for any target that
251-# depends on $(BIN); such targets should be made conditional upon the
252-# existence of $(BIN).
253-#
254-BIN_GOALS_FIRST := $(foreach BGB,$(BIN_GOALS_BINS),\
255- $(firstword $(filter $(BGB)/%,$(BIN_GOALS))))
256-BIN_GOALS_OTHER := $(filter-out $(BIN_GOALS_FIRST),$(BIN_GOALS))
257-
258-$(BIN_GOALS_FIRST) : % : BIN_RECURSE
259- $(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) \
260- $(filter $(firstword $(subst /, ,$@))/%, $(BIN_GOALS))
261-$(BIN_GOALS_OTHER) : % : BIN_RECURSE
262- $(Q)$(TRUE)
263-.PHONY : BIN_RECURSE
264-
265-endif # NUM_BINS == 1
266-endif # NUM_BINS == 0
267-
268-ifdef BIN
269-
270-# Create $(BIN) directory if it doesn't exist yet
271-#
272-ifeq ($(wildcard $(BIN)),)
273-$(shell $(MKDIR) -p $(BIN))
274-endif
275-
276-# Target to allow e.g. "make bin-efi arch"
277-#
278-$(BIN) :
279- @# Do nothing, silently
280-.PHONY : $(BIN)
281-
282-# Remove everything in $(BIN) for a "make clean"
283-#
284-CLEANUP += $(BIN)/*.* # Avoid picking up directories
285-
286-endif # defined(BIN)
287-
288-# Determine whether or not we need to include the dependency files
289-#
290-NO_DEP_TARGETS := $(BIN) clean veryclean
291-ifeq ($(MAKECMDGOALS),)
292-NEED_DEPS := 1
293-endif
294-ifneq ($(strip $(filter-out $(NO_DEP_TARGETS),$(MAKECMDGOALS))),)
295-NEED_DEPS := 1
296-endif
297-
298-###############################################################################
299-#
300-# Select build architecture and platform based on $(BIN)
301-#
302-# BIN has the form bin[-[arch-]platform]
303-
304-ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
305-PLATFORMS := $(patsubst config/defaults/%.h,%,\
306- $(wildcard config/defaults/*.h))
307-archs :
308- @$(ECHO) $(ARCHS)
309-
310-platforms :
311- @$(ECHO) $(PLATFORMS)
312-
313-ifdef BIN
314-
315-# Determine architecture portion of $(BIN), if present
316-BIN_ARCH := $(strip $(foreach A,$(ARCHS),\
317- $(patsubst bin-$(A)-%,$(A),\
318- $(filter bin-$(A)-%,$(BIN)))))
319-
320-# Determine platform portion of $(BIN), if present
321-ifeq ($(BIN_ARCH),)
322-BIN_PLATFORM := $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
323-else
324-BIN_PLATFORM := $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
325-endif
326-
327-# Determine build architecture
328-DEFAULT_ARCH := i386
329-ARCH := $(firstword $(BIN_ARCH) $(DEFAULT_ARCH))
330-CFLAGS += -DARCH=$(ARCH)
331-arch :
332- @$(ECHO) $(ARCH)
333-.PHONY : arch
334-
335-# Determine build platform
336-DEFAULT_PLATFORM := pcbios
337-PLATFORM := $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
338-CFLAGS += -DPLATFORM=$(PLATFORM)
339-platform :
340- @$(ECHO) $(PLATFORM)
341-
342-endif # defined(BIN)
343-
344-# Include architecture-specific Makefile
345-ifdef ARCH
346-MAKEDEPS += arch/$(ARCH)/Makefile
347-include arch/$(ARCH)/Makefile
348-endif
349-
350-# Include architecture-specific include path
351-ifdef ARCH
352-INCDIRS += arch/$(ARCH)/include
353-INCDIRS += arch/$(ARCH)/include/$(PLATFORM)
354-endif
355-
356-###############################################################################
357-#
358-# Source file handling
359-
360-# SRCDIRS lists all directories containing source files.
361-srcdirs :
362- @$(ECHO) $(SRCDIRS)
363-
364-# SRCS lists all .c or .S files found in any SRCDIR
365-#
366-SRCS += $(wildcard $(patsubst %,%/*.c,$(SRCDIRS)))
367-SRCS += $(wildcard $(patsubst %,%/*.S,$(SRCDIRS)))
368-srcs :
369- @$(ECHO) $(SRCS)
370-
371-# AUTO_SRCS lists all files in SRCS that are not mentioned in
372-# NON_AUTO_SRCS. Files should be added to NON_AUTO_SRCS if they
373-# cannot be built using the standard build template.
374-#
375-AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
376-autosrcs :
377- @$(ECHO) $(AUTO_SRCS)
378-
379-# Just about everything else in this section depends upon having
380-# $(BIN) set
381-
382-ifdef BIN
383-
384-# INCDIRS lists the include path
385-incdirs :
386- @$(ECHO) $(INCDIRS)
387-
388-# Common flags
389-#
390-CFLAGS += $(foreach INC,$(INCDIRS),-I$(INC))
391-CFLAGS += -Os
392-CFLAGS += -g
393-ifeq ($(CCTYPE),gcc)
394-CFLAGS += -ffreestanding
395-CFLAGS += -Wall -W -Wformat-nonliteral
396-endif
397-ifeq ($(CCTYPE),icc)
398-CFLAGS += -fno-builtin
399-CFLAGS += -no-ip
400-CFLAGS += -no-gcc
401-CFLAGS += -diag-disable 111 # Unreachable code
402-CFLAGS += -diag-disable 128 # Unreachable loop
403-CFLAGS += -diag-disable 170 # Array boundary checks
404-CFLAGS += -diag-disable 177 # Unused functions
405-CFLAGS += -diag-disable 181 # printf() format checks
406-CFLAGS += -diag-disable 188 # enum strictness
407-CFLAGS += -diag-disable 193 # Undefined preprocessor identifiers
408-CFLAGS += -diag-disable 280 # switch ( constant )
409-CFLAGS += -diag-disable 310 # K&R parameter lists
410-CFLAGS += -diag-disable 424 # Extra semicolon
411-CFLAGS += -diag-disable 589 # Declarations mid-code
412-CFLAGS += -diag-disable 593 # Unused variables
413-CFLAGS += -diag-disable 810 # Casting ints to smaller ints
414-CFLAGS += -diag-disable 981 # Sequence point violations
415-CFLAGS += -diag-disable 1292 # Ignored attributes
416-CFLAGS += -diag-disable 1338 # void pointer arithmetic
417-CFLAGS += -diag-disable 1361 # Variable-length arrays
418-CFLAGS += -diag-disable 1418 # Missing prototypes
419-CFLAGS += -diag-disable 1419 # Missing prototypes
420-CFLAGS += -diag-disable 1599 # Hidden variables
421-CFLAGS += -Wall -Wmissing-declarations
422-endif
423-CFLAGS += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
424-ASFLAGS += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
425-LDFLAGS += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
426-
427-# Inhibit -Werror if NO_WERROR is specified on make command line
428-#
429-ifneq ($(NO_WERROR),1)
430-CFLAGS += -Werror
431-ASFLAGS += --fatal-warnings
432-endif
433-
434-# Function trace recorder state in the last build. This is needed
435-# in order to correctly rebuild whenever the function recorder is
436-# enabled/disabled.
437-#
438-FNREC_STATE := $(BIN)/.fnrec.state
439-ifeq ($(wildcard $(FNREC_STATE)),)
440-FNREC_OLD := <invalid>
441-else
442-FNREC_OLD := $(shell cat $(FNREC_STATE))
443-endif
444-ifeq ($(FNREC_OLD),$(FNREC))
445-$(FNREC_STATE) :
446-else
447-$(FNREC_STATE) : clean
448-$(shell $(ECHO) "$(FNREC)" > $(FNREC_STATE))
449-endif
450-
451-VERYCLEANUP += $(FNREC_STATE)
452-MAKEDEPS += $(FNREC_STATE)
453-
454-ifeq ($(FNREC),1)
455-# Enabling -finstrument-functions affects gcc's analysis and leads to spurious
456-# warnings about use of uninitialised variables.
457-#
458-CFLAGS += -Wno-uninitialized
459-CFLAGS += -finstrument-functions
460-CFLAGS += -finstrument-functions-exclude-file-list=core/fnrec.c
461-endif
462-
463-# Enable per-item sections and section garbage collection. Note that
464-# some older versions of gcc support -fdata-sections but treat it as
465-# implying -fno-common, which would break our build. Some other older
466-# versions issue a spurious and uninhibitable warning if
467-# -ffunction-sections is used with -g, which would also break our
468-# build since we use -Werror.
469-#
470-ifeq ($(CCTYPE),gcc)
471-DS_TEST = $(ECHO) 'char x;' | \
472- $(CC) -fdata-sections -S -x c - -o - 2>/dev/null | \
473- grep -E '\.comm' > /dev/null
474-DS_FLAGS := $(shell $(DS_TEST) && $(ECHO) '-fdata-sections')
475-FS_TEST = $(CC) -ffunction-sections -g -c -x c /dev/null \
476- -o /dev/null 2>/dev/null
477-FS_FLAGS := $(shell $(FS_TEST) && $(ECHO) '-ffunction-sections')
478-CFLAGS += $(FS_FLAGS) $(DS_FLAGS)
479-endif
480-LDFLAGS += --gc-sections
481-
482-# compiler.h is needed for our linking and debugging system
483-#
484-CFLAGS += -include compiler.h
485-
486-# CFLAGS for specific object types
487-#
488-CFLAGS_c +=
489-CFLAGS_S += -DASSEMBLY
490-
491-# Base object name of the current target
492-#
493-OBJECT = $(firstword $(subst ., ,$(@F)))
494-
495-# CFLAGS for specific object files. You can define
496-# e.g. CFLAGS_rtl8139, and have those flags automatically used when
497-# compiling bin/rtl8139.o.
498-#
499-OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
500-$(BIN)/%.flags :
501- @$(ECHO) $(OBJ_CFLAGS)
502-
503-# ICC requires postprocessing objects to fix up table alignments
504-#
505-ifeq ($(CCTYPE),icc)
506-POST_O = && $(ICCFIX) $@
507-POST_O_DEPS := $(ICCFIX)
508-else
509-POST_O :=
510-POST_O_DEPS :=
511-endif
512-
513-# Rules for specific object types.
514-#
515-COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
516-RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O)
517-RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(subst -,_,$(OBJECT))=$* -c $< -o $@ $(POST_O)
518-RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
519-RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
520-
521-PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
522-ASSEMBLE_S = $(AS) $(ASFLAGS)
523-RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
524-RULE_S_to_dbg%.o = $(Q)$(PREPROCESS_S) -Ddebug_$(subst -,_,$(OBJECT))=$* $< | $(ASSEMBLE_S) -o $@
525-RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
526-
527-DEBUG_TARGETS += dbg%.o c s
528-
529-# We automatically generate rules for any file mentioned in AUTO_SRCS
530-# using the following set of templates. It would be cleaner to use
531-# $(eval ...), but this function exists only in GNU make >= 3.80.
532-
533-# deps_template : generate dependency list for a given source file
534-#
535-# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
536-# $(2) is the source type (e.g. "c")
537-# $(3) is the source base name (e.g. "rtl8139")
538-#
539-define deps_template
540- @$(ECHO) " [DEPS] $(1)"
541- @$(MKDIR) -p $(BIN)/deps/$(dir $(1))
542- @$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
543- -Wno-error -M $(1) -MG -MP | \
544- sed 's/\.o\s*:/_DEPS =/' > $(BIN)/deps/$(1).d
545-endef
546-
547-# rules_template : generate rules for a given source file
548-#
549-# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
550-# $(2) is the source type (e.g. "c")
551-# $(3) is the source base name (e.g. "rtl8139")
552-#
553-define rules_template
554- @$(ECHO) " [RULES] $(1)"
555- @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
556- @$(ECHO_E) '\n$$(BIN)/$(3).o :' \
557- '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
558- '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
559- '\n\t$$(RULE_$(2))\n' \
560- '\nBOBJS += $$(BIN)/$(3).o\n' \
561- $(foreach TGT,$(DEBUG_TARGETS), \
562- $(if $(RULE_$(2)_to_$(TGT)), \
563- '\n$$(BIN)/$(3).$(TGT) :' \
564- '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
565- '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
566- '\n\t$$(RULE_$(2)_to_$(TGT))\n' \
567- '\n$(TGT)_OBJS += $$(BIN)/$(3).$(TGT)\n' ) ) \
568- '\n$(BIN)/deps/$(1).d : $$($(3)_DEPS)\n' \
569- '\nTAGS : $$($(3)_DEPS)\n' > $(BIN)/rules/$(1).r
570- @$(if $(findstring drivers/,$(1)),\
571- $(PERL) $(PARSEROM) $(1) >> $(BIN)/rules/$(1).r)
572-endef
573-
574-# Rule to generate the dependency list file
575-#
576-$(BIN)/deps/%.d : % $(MAKEDEPS)
577- $(call deps_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
578-
579-# Calculate and include the list of dependency list files
580-#
581-AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
582-ifdef NEED_DEPS
583-ifneq ($(AUTO_DEPS),)
584--include $(AUTO_DEPS)
585-endif
586-endif
587-autodeps :
588- @$(ECHO) $(AUTO_DEPS)
589-VERYCLEANUP += $(BIN)/deps
590-
591-# Rule to generate the rules file
592-#
593-$(BIN)/rules/%.r : % $(MAKEDEPS) $(PARSEROM)
594- $(call rules_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
595-
596-# Calculate and include the list of rules files
597-#
598-AUTO_RULES = $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
599-ifdef NEED_DEPS
600-ifneq ($(AUTO_RULES),)
601--include $(AUTO_RULES)
602-endif
603-endif
604-autorules :
605- @$(ECHO) $(AUTO_RULES)
606-VERYCLEANUP += $(BIN)/rules
607-
608-# The following variables are created by the rules files
609-#
610-bobjs :
611- @$(ECHO) $(BOBJS)
612-drivers :
613- @$(ECHO) $(DRIVERS)
614-.PHONY : drivers
615-roms :
616- @$(ECHO) $(ROMS)
617-
618-# List of embedded images included in the last build of embedded.o.
619-# This is needed in order to correctly rebuild embedded.o whenever the
620-# list of objects changes.
621-#
622-EMBED := $(EMBEDDED_IMAGE) # Maintain backwards compatibility
623-EMBEDDED_LIST := $(BIN)/.embedded.list
624-ifeq ($(wildcard $(EMBEDDED_LIST)),)
625-EMBED_OLD := <invalid>
626-else
627-EMBED_OLD := $(shell cat $(EMBEDDED_LIST))
628-endif
629-ifneq ($(EMBED_OLD),$(EMBED))
630-$(shell $(ECHO) "$(EMBED)" > $(EMBEDDED_LIST))
631-endif
632-
633-$(EMBEDDED_LIST) :
634-
635-VERYCLEANUP += $(EMBEDDED_LIST)
636-
637-EMBEDDED_FILES := $(subst $(COMMA), ,$(EMBED))
638-EMBED_ALL := $(foreach i,$(call seq,1,$(words $(EMBEDDED_FILES))),\
639- EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
640- \"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
641-
642-$(BIN)/embedded.o : $(EMBEDDED_FILES) $(EMBEDDED_LIST)
643-
644-# This file uses .incbin inline assembly to include a binary file.
645-# Unfortunately ccache does not detect this dependency and caches builds even
646-# when the binary file has changed.
647-#
648-$(BIN)/embedded.o : override CC := env CCACHE_DISABLE=1 $(CC)
649-
650-CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
651-
652-# Generate error usage information
653-#
654-$(BIN)/%.einfo : $(BIN)/%.o
655- $(QM)$(ECHO) " [EINFO] $@"
656- $(Q)$(OBJCOPY) -O binary -j .einfo --set-section-flags .einfo=alloc \
657- $< $@
658-
659-EINFOS := $(patsubst $(BIN)/%.o,$(BIN)/%.einfo,$(BOBJS))
660-$(BIN)/errors : $(EINFOS) $(EINFO)
661- $(QM)$(ECHO) " [EINFO] $@"
662- $(Q)$(EINFO) $(EINFOS) | sort > $@
663-CLEANUP += $(BIN)/errors # Doesn't match the $(BIN)/*.* pattern
664-
665-# Generate the NIC file from the parsed source files. The NIC file is
666-# only for rom-o-matic.
667-#
668-$(BIN)/NIC : $(AUTO_DEPS)
669- @$(ECHO) '# This is an automatically generated file, do not edit' > $@
670- @$(ECHO) '# It does not affect anything in the build, ' \
671- 'it is only for rom-o-matic' >> $@
672- @$(ECHO) >> $@
673- @perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
674-CLEANUP += $(BIN)/NIC # Doesn't match the $(BIN)/*.* pattern
675-
676-# Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
677-# derive the variables:
678-#
679-# TGT_ELEMENTS : the elements of the target (e.g. "dfe538 prism2_pci")
680-# TGT_PREFIX : the prefix type (e.g. "zrom")
681-# TGT_DRIVERS : the driver for each element (e.g. "rtl8139 prism2_pci")
682-# TGT_ROM_NAME : the ROM name (e.g. "dfe538")
683-# TGT_MEDIA : the media type (e.g. "rom")
684-#
685-DRIVERS_ipxe = $(DRIVERS)
686-CARD_DRIVER = $(firstword $(DRIVER_$(1)) $(1))
687-TGT_ELEMENTS = $(subst --, ,$(firstword $(subst ., ,$(notdir $@))))
688-TGT_PREFIX = $(word 2,$(subst ., ,$(notdir $@)))
689-TGT_ROM_NAME = $(firstword $(TGT_ELEMENTS))
690-TGT_DRIVERS = $(strip $(if $(DRIVERS_$(TGT_ROM_NAME)), \
691- $(DRIVERS_$(TGT_ROM_NAME)), \
692- $(foreach TGT_ELEMENT,$(TGT_ELEMENTS), \
693- $(call CARD_DRIVER,$(TGT_ELEMENT))) ))
694-TGT_MEDIA = $(subst z,,$(TGT_PREFIX))
695-
696-# Look up ROM IDs for the current target
697-# (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
698-#
699-# TGT_PCI_VENDOR : the PCI vendor ID (e.g. "0x1186")
700-# TGT_PCI_DEVICE : the PCI device ID (e.g. "0x1300")
701-#
702-TGT_PCI_VENDOR = $(PCI_VENDOR_$(TGT_ROM_NAME))
703-TGT_PCI_DEVICE = $(PCI_DEVICE_$(TGT_ROM_NAME))
704-
705-# Calculate link-time options for the current target
706-# (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
707-#
708-# TGT_LD_DRIVERS : symbols to require in order to drag in the relevant drivers
709-# (e.g. "obj_rtl8139 obj_prism2_pci")
710-# TGT_LD_IDS : symbols to define in order to fill in ID structures in the
711-# ROM header (e.g."pci_vendor_id=0x1186 pci_device_id=0x1300")
712-#
713-TGT_LD_DRIVERS = $(subst -,_,$(patsubst %,obj_%,$(TGT_DRIVERS)))
714-TGT_LD_IDS = pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
715- pci_device_id=$(firstword $(TGT_PCI_DEVICE) 0)
716-TGT_LD_ENTRY = _$(TGT_PREFIX)_start
717-
718-# Calculate linker flags based on link-time options for the current
719-# target type (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the
720-# variables:
721-#
722-# TGT_LD_FLAGS : target-specific flags to pass to linker (e.g.
723-# "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
724-# --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
725-#
726-TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) obj_config,\
727- -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
728- $(patsubst %,--defsym %,$(TGT_LD_IDS)) \
729- -e $(TGT_LD_ENTRY)
730-
731-# Calculate list of debugging versions of objects to be included in
732-# the target.
733-#
734-DEBUG_LIST = $(subst $(COMMA), ,$(DEBUG))
735-DEBUG_OBJ_LEVEL = $(firstword $(word 2,$(subst :, ,$(1))) 1)
736-DEBUG_OBJ_BASE = $(word 1,$(subst :, ,$(1))).dbg$(call DEBUG_OBJ_LEVEL,$(1))
737-DEBUG_OBJ = $(BIN)/$(call DEBUG_OBJ_BASE,$(1)).o
738-DEBUG_ORIG_OBJ = $(BIN)/$(word 1,$(subst :, ,$(1))).o
739-DEBUG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_OBJ,$(D)))
740-DEBUG_ORIG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_ORIG_OBJ,$(D)))
741-BLIB_OBJS = $(DEBUG_OBJS) $(filter-out $(DEBUG_ORIG_OBJS),$(BOBJS))
742-
743-# Print out all derived information for a given target.
744-#
745-$(BIN)/%.info :
746- @$(ECHO) 'Elements : $(TGT_ELEMENTS)'
747- @$(ECHO) 'Prefix : $(TGT_PREFIX)'
748- @$(ECHO) 'Drivers : $(TGT_DRIVERS)'
749- @$(ECHO) 'ROM name : $(TGT_ROM_NAME)'
750- @$(ECHO) 'Media : $(TGT_MEDIA)'
751- @$(ECHO)
752- @$(ECHO) 'PCI vendor : $(TGT_PCI_VENDOR)'
753- @$(ECHO) 'PCI device : $(TGT_PCI_DEVICE)'
754- @$(ECHO)
755- @$(ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)'
756- @$(ECHO) 'LD ID symbols : $(TGT_LD_IDS)'
757- @$(ECHO) 'LD entry point : $(TGT_LD_ENTRY)'
758- @$(ECHO)
759- @$(ECHO) 'LD target flags : $(TGT_LD_FLAGS)'
760- @$(ECHO)
761- @$(ECHO) 'Debugging objects : $(DEBUG_OBJS)'
762- @$(ECHO) 'Replaced objects : $(DEBUG_ORIG_OBJS)'
763-
764-# List of objects included in the last build of blib. This is needed
765-# in order to correctly rebuild blib whenever the list of objects
766-# changes.
767-#
768-BLIB_LIST := $(BIN)/.blib.list
769-ifeq ($(wildcard $(BLIB_LIST)),)
770-BLIB_OBJS_OLD := <invalid>
771-else
772-BLIB_OBJS_OLD := $(shell cat $(BLIB_LIST))
773-endif
774-ifneq ($(BLIB_OBJS_OLD),$(BLIB_OBJS))
775-$(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
776-endif
777-
778-$(BLIB_LIST) :
779-
780-VERYCLEANUP += $(BLIB_LIST)
781-
782-# Library of all objects
783-#
784-BLIB = $(BIN)/blib.a
785-$(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
786- $(Q)$(RM) $(BLIB)
787- $(QM)$(ECHO) " [AR] $@"
788- $(Q)$(AR) r $@ $(BLIB_OBJS)
789- $(Q)$(RANLIB) $@
790-blib : $(BLIB)
791-
792-# Command to generate build ID. Must be unique for each $(BIN)/%.tmp,
793-# even within the same build run.
794-#
795-BUILD_ID_CMD := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'
796-
797-# Build an intermediate object file from the objects required for the
798-# specified target.
799-#
800-$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
801- $(QM)$(ECHO) " [LD] $@"
802- $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $(BLIB) -o $@ \
803- --defsym _build_id=`$(BUILD_ID_CMD)` -Map $(BIN)/$*.tmp.map
804- $(Q)$(OBJDUMP) -ht $@ | $(PERL) $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map
805-
806-# Keep intermediate object file (useful for debugging)
807-.PRECIOUS : $(BIN)/%.tmp
808-
809-# Show a linker map for the specified target
810-#
811-$(BIN)/%.map : $(BIN)/%.tmp
812- @less $(BIN)/$*.tmp.map
813-
814-# Get objects list for the specified target
815-#
816-define objs_list
817- $(sort $(foreach OBJ_SYMBOL,\
818- $(filter obj_%,$(shell $(NM) $(1) | cut -d" " -f3)),\
819- $(patsubst obj_%,%,$(OBJ_SYMBOL))))
820-endef
821-$(BIN)/%.objs : $(BIN)/%.tmp
822- $(Q)$(ECHO) $(call objs_list,$<)
823-$(BIN)/%.sizes : $(BIN)/%.tmp
824- $(Q)$(SIZE) -t $(foreach OBJ,$(call objs_list,$<),$(wildcard $(BIN)/$(subst _,?,$(OBJ)).o)) | \
825- sort -g
826-
827-# Get dependency list for the specified target
828-#
829-define deps_list
830- $(sort $(foreach OBJ,$(call objs_list,$(1)),$($(OBJ)_DEPS)))
831-endef
832-$(BIN)/%.deps : $(BIN)/%.tmp
833- $(Q)$(ECHO) $(call deps_list,$<)
834-
835-# Get unneeded source files for the specified target
836-#
837-define nodeps_list
838- $(sort $(filter-out $(call deps_list,$(1)),\
839- $(foreach BOBJ,$(BOBJS),\
840- $($(basename $(notdir $(BOBJ)))_DEPS))))
841-endef
842-$(BIN)/%.nodeps : $(BIN)/%.tmp
843- $(Q)$(ECHO) $(call nodeps_list,$<)
844-
845-# Get licensing verdict for the specified target
846-#
847-define licensable_deps_list
848- $(filter-out config/local/%.h,$(call deps_list,$(1)))
849-endef
850-define unlicensed_deps_list
851- $(shell grep -L FILE_LICENCE $(call licensable_deps_list,$(1)))
852-endef
853-define licence_list
854- $(patsubst __licence_%,%,\
855- $(filter __licence_%,$(shell $(NM) $(1) | cut -d" " -f3)))
856-endef
857-$(BIN)/%.licence : $(BIN)/%.tmp
858- $(QM)$(ECHO) " [LICENCE] $@"
859- $(Q)$(if $(strip $(call unlicensed_deps_list,$<)),\
860- echo -n "Unable to determine licence because the following " ;\
861- echo "files are missing a licence declaration:" ;\
862- echo $(call unlicensed_deps_list,$<);\
863- exit 1,\
864- $(PERL) $(LICENCE) $(call licence_list,$<))
865-
866-# Extract compression information from intermediate object file
867-#
868-$(BIN)/%.zinfo : $(BIN)/%.tmp
869- $(QM)$(ECHO) " [ZINFO] $@"
870- $(Q)$(OBJCOPY) -O binary -j .zinfo $< $@
871-
872-# Build raw binary file from intermediate object file
873-#
874-$(BIN)/%.bin : $(BIN)/%.tmp
875- $(QM)$(ECHO) " [BIN] $@"
876- $(Q)$(OBJCOPY) -O binary -R .zinfo $< $@
877-
878-# Compress raw binary file
879-#
880-$(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
881- $(QM)$(ECHO) " [ZBIN] $@"
882- $(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
883-
884-# Rules for each media format. These are generated and placed in an
885-# external Makefile fragment. We could do this via $(eval ...), but
886-# that would require make >= 3.80.
887-#
888-# Note that there's an alternative way to generate most .rom images:
889-# they can be copied from their 'master' ROM image using cp and
890-# reprocessed with makerom to add the PCI IDs and ident string. The
891-# relevant rule would look something like:
892-#
893-# $(BIN)/dfe538%rom : $(BIN)/rtl8139%rom
894-# cat $< $@
895-# $(FINALISE_rom)
896-#
897-# You can derive the ROM/driver relationships using the variables
898-# DRIVER_<rom> and/or ROMS_<driver>.
899-#
900-# We don't currently do this, because (a) it would require generating
901-# yet more Makefile fragments (since you need a rule for each ROM in
902-# ROMS), and (b) the linker is so fast that it probably wouldn't make
903-# much difference to the overall build time.
904-
905-# Add NON_AUTO_MEDIA to the media list, so that they show up in the
906-# output of "make"
907-#
908-MEDIA += $(NON_AUTO_MEDIA)
909-
910-media :
911- @$(ECHO) $(MEDIA)
912-
913-AUTO_MEDIA = $(filter-out $(NON_AUTO_MEDIA),$(MEDIA))
914-automedia :
915- @$(ECHO) $(AUTO_MEDIA)
916-
917-# media_template : create Makefile rules for specified media
918-#
919-# $(1) is the media name (e.g. "rom")
920-#
921-define media_template
922- @$(ECHO) " [MEDIARULES] $(1)"
923- @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
924- @$(ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
925- '\n\t$$(QM)$(ECHO) " [FINISH] $$@"' \
926- '\n\t$$(Q)$$(CP) $$< $$@' \
927- '\n\t$$(Q)$$(PAD_$(1))' \
928- '\n\t$$(Q)$$(FINALISE_$(1))' \
929- > $(BIN)/rules/$(1).media.r
930-endef
931-
932-# Rule to generate the Makefile rules to be included
933-#
934-$(BIN)/rules/%.media.r : $(MAKEDEPS)
935- $(call media_template,$*)
936-
937-# Calculate and include the list of Makefile rules files
938-#
939-MEDIA_RULES = $(patsubst %,$(BIN)/rules/%.media.r,$(AUTO_MEDIA))
940-mediarules :
941- @$(ECHO) $(MEDIA_RULES)
942-ifdef NEED_DEPS
943-ifneq ($(MEDIA_RULES),)
944--include $(MEDIA_RULES)
945-endif
946-endif
947-
948-# Wrap up binary blobs (for embedded images)
949-#
950-$(BIN)/%.o : payload/%.img
951- $(QM)echo " [WRAP] $@"
952- $(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
953- --defsym obj_$*=0
954-
955-BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
956-
957-# The "allXXXs" targets for each suffix
958-#
959-allall: allroms allmroms allpxes allisos alldsks
960-allroms allmroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%)
961-allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
962-
963-# Alias for ipxe.%
964-#
965-$(BIN)/etherboot.% : $(BIN)/ipxe.%
966- ln -sf $(notdir $<) $@
967-
968-endif # defined(BIN)
969-
970-###############################################################################
971-#
972-# The compression utilities
973-#
974-$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
975- $(QM)$(ECHO) " [HOSTCC] $@"
976- $(Q)$(HOST_CC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG \
977- -DBITSIZE=32 -DENDIAN=0 -o $@ $<
978-CLEANUP += $(NRV2B)
979-
980-$(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
981- $(QM)$(ECHO) " [HOSTCC] $@"
982- $(Q)$(HOST_CC) -O2 -o $@ $<
983-CLEANUP += $(ZBIN)
984-
985-###############################################################################
986-#
987-# The EFI image converter
988-#
989-ELF2EFI_CFLAGS := -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
990- -I$(ZLIB_DIR)/include -idirafter include \
991- -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib -L$(ZLIB_DIR)/lib \
992- -lbfd -ldl -liberty -lz -Wl,--no-warn-search-mismatch
993-
994-$(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
995- $(QM)$(ECHO) " [HOSTCC] $@"
996- $(Q)$(HOST_CC) $< $(ELF2EFI_CFLAGS) -DEFI_TARGET_IA32 -O2 -o $@
997-CLEANUP += $(ELF2EFI32)
998-
999-$(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
1000- $(QM)$(ECHO) " [HOSTCC] $@"
1001- $(Q)$(HOST_CC) $< $(ELF2EFI_CFLAGS) -DEFI_TARGET_X64 -O2 -o $@
1002-CLEANUP += $(ELF2EFI64)
1003-
1004-$(EFIROM) : util/efirom.c $(MAKEDEPS)
1005- $(QM)$(ECHO) " [HOSTCC] $@"
1006- $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
1007-CLEANUP += $(EFIROM)
1008-
1009-###############################################################################
1010-#
1011-# The ICC fixup utility
1012-#
1013-$(ICCFIX) : util/iccfix.c $(MAKEDEPS)
1014- $(QM)$(ECHO) " [HOSTCC] $@"
1015- $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
1016-CLEANUP += $(ICCFIX)
1017-
1018-###############################################################################
1019-#
1020-# The error usage information utility
1021-#
1022-$(EINFO) : util/einfo.c $(MAKEDEPS)
1023- $(QM)$(ECHO) " [HOSTCC] $@"
1024- $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
1025-CLEANUP += $(EINFO)
1026-
1027-###############################################################################
1028-#
1029-# Local configs
1030-#
1031-config/local/%.h :
1032- $(Q)touch $@
1033-
1034-###############################################################################
1035-#
1036-# Auto-incrementing build serial number. Append "bs" to your list of
1037-# build targets to get a serial number printed at the end of the
1038-# build. Enable -DBUILD_SERIAL in order to see it when the code runs.
1039-#
1040-BUILDSERIAL_H = config/.buildserial.h
1041-BUILDSERIAL_NOW = config/.buildserial.now
1042-BUILDSERIAL_NEXT = config/.buildserial.next
1043-
1044-$(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) :
1045- $(ECHO) 1 > $@
1046-
1047-$(BUILDSERIAL_H) : $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT)
1048- $(ECHO) '#define BUILD_SERIAL_NUM $(shell cat $<)' > $@
1049-
1050-ifeq ($(filter bs,$(MAKECMDGOALS)),bs)
1051-$(shell diff -q $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) > /dev/null || \
1052- cp -f $(BUILDSERIAL_NEXT) $(BUILDSERIAL_NOW))
1053-endif
1054-
1055-bs : $(BUILDSERIAL_NOW)
1056- @$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
1057- @$(ECHO) "Build serial number is $(shell cat $<)"
1058-
1059-###############################################################################
1060-#
1061-# Build the TAGS file(s) for emacs
1062-#
1063-TAGS :
1064- ctags -e -R -f $@ --exclude=bin
1065-
1066-CLEANUP += TAGS
1067-
1068-###############################################################################
1069-#
1070-# Force rebuild for any given target
1071-#
1072-%.rebuild :
1073- rm -f $*
1074- $(Q)$(MAKE) $*
1075-
1076-###############################################################################
1077-#
1078-# Symbol table checks
1079-#
1080-
1081-ifdef BIN
1082-
1083-SYMTAB = $(BIN)/symtab
1084-$(SYMTAB) : $(BLIB)
1085- $(OBJDUMP) -w -t $< > $@
1086-
1087-CLEANUP += $(BIN)/symtab
1088-
1089-symcheck : $(SYMTAB)
1090- $(PERL) $(SYMCHECK) $<
1091-
1092-endif # defined(BIN)
1093-
1094-###############################################################################
1095-#
1096-# Build bochs symbol table
1097-#
1098-
1099-ifdef BIN
1100-
1101-$(BIN)/%.bxs : $(BIN)/%.tmp
1102- $(NM) $< | cut -d" " -f1,3 > $@
1103-
1104-endif # defined(BIN)
1105-
1106-###############################################################################
1107-#
1108-# Documentation
1109-#
1110-
1111-ifdef BIN
1112-
1113-$(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
1114- $(Q)$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
1115- -e 's{\@INCDIRS\@}{$(filter-out .,$(INCDIRS))}; ' \
1116- -e 's{\@BIN\@}{$(BIN)}; ' \
1117- -e 's{\@ARCH\@}{$(ARCH)}; ' \
1118- $< > $@
1119-
1120-$(BIN)/doc : $(BIN)/doxygen.cfg
1121- $(Q)$(DOXYGEN) $<
1122-
1123-.PHONY : $(BIN)/doc
1124-
1125-doc : $(BIN)/doc
1126-
1127-doc-clean :
1128- $(Q)$(RM) -r $(BIN)/doc
1129-
1130-VERYCLEANUP += $(BIN)/doc
1131-
1132-docview :
1133- @[ -f $(BIN)/doc/html/index.html ] || $(MAKE) $(BIN)/doc
1134- @if [ -n "$$BROWSER" ] ; then \
1135- ( $$BROWSER $(BIN)/doc/html/index.html & ) ; \
1136- else \
1137- $(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
1138- fi
1139-
1140-endif # defined(BIN)
1141-
1142-###############################################################################
1143-#
1144-# Keyboard maps
1145-#
1146-
1147-hci/keymap/keymap_%.c :
1148- $(Q)$(PERL) $(GENKEYMAP) $* > $@
1149-
1150-###############################################################################
1151-#
1152-# Force deletion of incomplete targets
1153-#
1154-
1155-.DELETE_ON_ERROR :
1156-
1157-###############################################################################
1158-#
1159-# Clean-up
1160-#
1161-clean :
1162- $(RM) $(CLEANUP)
1163-
1164-veryclean : clean
1165- $(RM) -r $(VERYCLEANUP)
1166
1167=== modified file 'debian/changelog'
1168--- debian/changelog 2011-12-16 10:43:54 +0000
1169+++ debian/changelog 2012-02-10 16:40:50 +0000
1170@@ -1,3 +1,20 @@
1171+ipxe (1.0.0+git-3.55f6c88-0ubuntu1) precise; urgency=low
1172+
1173+ * New upstream snapshot.
1174+ * Added rules for automatic git branch refresh.
1175+ * Changed rom target from allbaseroms to allroms.
1176+ - recommended behaviour by upstream, building all full roms is neither
1177+ recommended nor a desired user experience
1178+ * Added new target allqemu for qemu package.
1179+ - created new build target to build full rom drivers just for qemu
1180+ package purposes
1181+ * Cleaned lintian errors from debian package
1182+ - Removed brace extension in ipxe.install
1183+ - Updated standards to 3.9.2
1184+ - Fixed copyright file not machine readable
1185+
1186+ -- Marc Cluet <marc.cluet@ubuntu.com> Fri, 10 Feb 2012 16:21:23 +0000
1187+
1188 ipxe (1.0.0+git-2.149b50-1ubuntu4) precise; urgency=low
1189
1190 * Add missing Breaks/Replaces for kvm-ipxe split in
1191
1192=== modified file 'debian/control'
1193--- debian/control 2011-12-16 10:43:54 +0000
1194+++ debian/control 2012-02-10 16:40:50 +0000
1195@@ -5,7 +5,7 @@
1196 XSBC-Original-Maintainer: Bastian Blank <waldi@debian.org>
1197 Build-Depends: debhelper (>= 7.0.50~),
1198 genisoimage, syslinux
1199-Standards-Version: 3.9.1
1200+Standards-Version: 3.9.2
1201 Homepage: http://ipxe.org/
1202 #Vcs-Git: git://git.debian.org/collab-maint/ipxe.git
1203 #Vcs-Browser: http://git.debian.org/?p=collab-maint/ipxe.git;a=summary
1204
1205=== modified file 'debian/copyright'
1206--- debian/copyright 2011-04-11 19:35:36 +0000
1207+++ debian/copyright 2012-02-10 16:40:50 +0000
1208@@ -65,7 +65,7 @@
1209 Permission to use, copy, modify, and distribute this software for any
1210 purpose with or without fee is hereby granted, provided that the above
1211 copyright notice and this permission notice appear in all copies.
1212-
1213+ .
1214 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1215 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1216 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1217
1218=== modified file 'debian/ipxe.install'
1219--- debian/ipxe.install 2011-04-11 19:35:36 +0000
1220+++ debian/ipxe.install 2012-02-10 16:40:50 +0000
1221@@ -1,3 +1,5 @@
1222 src/bin/*.rom usr/lib/ipxe
1223-src/bin/ipxe.{iso,lkrn,pxe} usr/lib/ipxe
1224+src/bin/ipxe.iso usr/lib/ipxe
1225+src/bin/ipxe.lkrn usr/lib/ipxe
1226+src/bin/ipxe.pxe usr/lib/ipxe
1227 src/bin/undionly.kpxe usr/lib/ipxe
1228
1229=== added file 'debian/patches/disable-baddrivers.diff'
1230--- debian/patches/disable-baddrivers.diff 1970-01-01 00:00:00 +0000
1231+++ debian/patches/disable-baddrivers.diff 2012-02-10 16:40:50 +0000
1232@@ -0,0 +1,34 @@
1233+--- a/src/Makefile 2012-01-06 15:49:04.000000000 -0800
1234++++ b/src/Makefile 2012-01-10 14:10:28.120834619 -0800
1235+@@ -92,6 +92,31 @@
1236+ #
1237+ NON_AUTO_SRCS :=
1238+ NON_AUTO_SRCS += drivers/net/prism2.c
1239++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ani.c
1240++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar5008_phy.c
1241++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9002_calib.c
1242++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9002_hw.c
1243++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9002_mac.c
1244++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9002_phy.c
1245++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9003_calib.c
1246++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9003_eeprom.c
1247++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9003_hw.c
1248++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9003_mac.c
1249++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_ar9003_phy.c
1250++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k.c
1251++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_calib.c
1252++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_common.c
1253++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_eeprom_4k.c
1254++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_eeprom_9287.c
1255++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_eeprom.c
1256++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_eeprom_def.c
1257++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_hw.c
1258++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_init.c
1259++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_mac.c
1260++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_main.c
1261++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_recv.c
1262++NON_AUTO_SRCS += drivers/net/ath/ath9k/ath9k_xmit.c
1263++
1264+
1265+ # INCDIRS lists the include path
1266+ #
1267
1268=== added file 'debian/patches/qemu-target.diff'
1269--- debian/patches/qemu-target.diff 1970-01-01 00:00:00 +0000
1270+++ debian/patches/qemu-target.diff 2012-02-10 16:40:50 +0000
1271@@ -0,0 +1,13 @@
1272+--- a/src/Makefile.housekeeping
1273++++ b/src/Makefile.housekeeping
1274+@@ -950,5 +950,10 @@
1275+ allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
1276+
1277++# Create qemu target for qemu package
1278++#
1279++QEMUS = e1000_82540 ne2k_isa pcnet32 rtl8139 virtio-net
1280++allqemu : $(foreach ROM,$(QEMUS),$(BIN)/$(ROM).rom)
1281++
1282+ # Alias for ipxe.%
1283+ #
1284+ $(BIN)/etherboot.% : $(BIN)/ipxe.%
1285
1286=== modified file 'debian/patches/series'
1287--- debian/patches/series 2011-07-31 20:57:02 +0000
1288+++ debian/patches/series 2012-02-10 16:40:50 +0000
1289@@ -1,1 +1,3 @@
1290 baseroms-target.diff
1291+disable-baddrivers.diff
1292+qemu-target.diff
1293
1294=== modified file 'debian/rules'
1295--- debian/rules 2011-11-25 12:58:48 +0000
1296+++ debian/rules 2012-02-10 16:40:50 +0000
1297@@ -8,7 +8,7 @@
1298 dh $@
1299
1300 override_dh_auto_build:
1301- make -C src V=1 NO_WERROR=1 all allbaseroms bin/ipxe.pxe bin/ipxe.lkrn
1302+ make -C src V=1 NO_WERROR=1 all allroms allqemu bin/ipxe.pxe bin/ipxe.lkrn
1303
1304 override_dh_auto_clean:
1305 make -C src veryclean
1306@@ -21,3 +21,32 @@
1307 mv src/bin/pcnet32.rom $(CURDIR)/debian/kvm-ipxe/usr/share/qemu/pxe-pcnet32.rom
1308 mv src/bin/rtl8139.rom $(CURDIR)/debian/kvm-ipxe/usr/share/qemu/pxe-rtl8139.rom
1309 mv src/bin/virtio-net.rom $(CURDIR)/debian/kvm-ipxe/usr/share/qemu/pxe-virtio.rom
1310+
1311+# Stuff for get-orig-source.
1312+upstream_version := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(.*\)-.*/\1/p')
1313+isodate := $(shell dpkg-parsechangelog | sed -ne 's/^Version.*git\(.*\)-.*/\1/p')
1314+unixdate := $(shell date -d $(isodate) +%s)
1315+# Add 24 hours to the Unix time.
1316+unixdate := $(shell expr $(unixdate) + 86400 )
1317+
1318+get-orig-source:
1319+ # Cleaning
1320+ rm -rf ipxe-$(upstream_version)
1321+ rm -f ../ipxe_$(upstream_version).orig.tar.gz
1322+
1323+ # Download the latest GIT version and downgrade it to $(isodate).
1324+ git clone git://git.ipxe.org/ipxe.git ipxe-$(upstream_version)
1325+
1326+# cd ipxe-$(upstream_version) && git reset --hard $(shell cd ipxe-$(upstream_version) && git rev-list --all -n 1 --before=$(unixdate))
1327+#unixdate = 1231196400
1328+#hash of GIT commit = 1d3f869e61dc5139d16596075a9e2c4e9a2f503f
1329+# Ugly hack with "xargs" that works.
1330+ cd ipxe-$(upstream_version) && echo `git rev-list --all -n 1 --before=$(unixdate)` | xargs git reset --hard
1331+
1332+ # Make a pristine package.
1333+# --no-name/-n is important because it won't save the timestamp in the
1334+# 5th to 8th byte of the gzip.
1335+ cd ipxe-$(upstream_version) && git archive --format=tar --prefix=ipxe-$(upstream_version)/ master | gzip -9 --no-name > ../ipxe_$(upstream_version).orig.tar.gz
1336+
1337+ # Clean again, because we use svn-buildpackage afterwards.
1338+ rm -rf ipxe-$(upstream_version)
1339
1340=== modified file 'src/Makefile'
1341--- src/Makefile 2011-04-11 19:35:36 +0000
1342+++ src/Makefile 2012-02-10 16:40:50 +0000
1343@@ -68,7 +68,9 @@
1344 SRCDIRS += drivers/net/igbvf
1345 SRCDIRS += drivers/net/phantom
1346 SRCDIRS += drivers/net/rtl818x
1347-SRCDIRS += drivers/net/ath5k
1348+SRCDIRS += drivers/net/ath
1349+SRCDIRS += drivers/net/ath/ath5k
1350+SRCDIRS += drivers/net/ath/ath9k
1351 SRCDIRS += drivers/net/vxge
1352 SRCDIRS += drivers/net/efi
1353 SRCDIRS += drivers/block
1354
1355=== modified file 'src/Makefile.housekeeping'
1356--- src/Makefile.housekeeping 2011-07-31 20:57:02 +0000
1357+++ src/Makefile.housekeeping 2012-02-10 16:40:50 +0000
1358@@ -946,7 +946,6 @@
1359 #
1360 allall: allroms allmroms allpxes allisos alldsks
1361 allroms allmroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%)
1362-allbaseroms allbasemroms : allbase%s : $(foreach ROM,$(DRIVERS),$(BIN)/$(ROM).%)
1363 allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
1364
1365 # Alias for ipxe.%
1366
1367=== modified file 'src/arch/i386/Makefile.pcbios'
1368--- src/arch/i386/Makefile.pcbios 2011-04-11 19:35:36 +0000
1369+++ src/arch/i386/Makefile.pcbios 2012-02-10 16:40:50 +0000
1370@@ -19,6 +19,7 @@
1371 MEDIA += pxe
1372 MEDIA += kpxe
1373 MEDIA += kkpxe
1374+MEDIA += kkkpxe
1375 MEDIA += lkrn
1376 MEDIA += dsk
1377 MEDIA += nbi
1378
1379=== removed file 'src/arch/i386/core/cmdline.c'
1380--- src/arch/i386/core/cmdline.c 2011-07-31 20:57:02 +0000
1381+++ src/arch/i386/core/cmdline.c 1970-01-01 00:00:00 +0000
1382@@ -1,123 +0,0 @@
1383-/*
1384- * Copyright (C) 2011 Michael Brown <mbrown@fensystems.co.uk>.
1385- *
1386- * This program is free software; you can redistribute it and/or
1387- * modify it under the terms of the GNU General Public License as
1388- * published by the Free Software Foundation; either version 2 of the
1389- * License, or any later version.
1390- *
1391- * This program is distributed in the hope that it will be useful, but
1392- * WITHOUT ANY WARRANTY; without even the implied warranty of
1393- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1394- * General Public License for more details.
1395- *
1396- * You should have received a copy of the GNU General Public License
1397- * along with this program; if not, write to the Free Software
1398- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1399- */
1400-
1401-FILE_LICENCE ( GPL2_OR_LATER );
1402-
1403-/** @file
1404- *
1405- * Command line passed to iPXE
1406- *
1407- */
1408-
1409-#include <stddef.h>
1410-#include <stdint.h>
1411-#include <stdlib.h>
1412-#include <assert.h>
1413-#include <ipxe/init.h>
1414-#include <ipxe/image.h>
1415-#include <ipxe/script.h>
1416-#include <realmode.h>
1417-
1418-/** Command line physical address
1419- *
1420- * This can be set by the prefix.
1421- */
1422-uint32_t __bss16 ( cmdline_phys );
1423-#define cmdline_phys __use_data16 ( cmdline_phys )
1424-
1425-/** Internal copy of the command line */
1426-static char *cmdline_copy;
1427-
1428-/** Free command line image */
1429-static void cmdline_image_free ( struct refcnt *refcnt ) {
1430- struct image *image = container_of ( refcnt, struct image, refcnt );
1431-
1432- DBGC ( image, "CMDLINE freeing command line\n" );
1433- free ( cmdline_copy );
1434-}
1435-
1436-/** Embedded script representing the command line */
1437-static struct image cmdline_image = {
1438- .refcnt = REF_INIT ( cmdline_image_free ),
1439- .name = "<CMDLINE>",
1440- .type = &script_image_type,
1441-};
1442-
1443-/**
1444- * Initialise command line
1445- *
1446- */
1447-static void cmdline_init ( void ) {
1448- struct image *image = &cmdline_image;
1449- userptr_t cmdline_user;
1450- char *cmdline;
1451- char *boot_image;
1452- char *boot_image_end;
1453- size_t len;
1454-
1455- /* Do nothing if no command line was specified */
1456- if ( ! cmdline_phys ) {
1457- DBGC ( image, "CMDLINE found no command line\n" );
1458- return;
1459- }
1460- cmdline_user = phys_to_user ( cmdline_phys );
1461- len = ( strlen_user ( cmdline_user, 0 ) + 1 /* NUL */ );
1462-
1463- /* Allocate and copy command line */
1464- cmdline_copy = malloc ( len );
1465- if ( ! cmdline_copy ) {
1466- DBGC ( image, "CMDLINE could not allocate %zd bytes\n", len );
1467- /* No way to indicate failure */
1468- return;
1469- }
1470- cmdline = cmdline_copy;
1471- copy_from_user ( cmdline, cmdline_user, 0, len );
1472- DBGC ( image, "CMDLINE found \"%s\"\n", cmdline );
1473-
1474- /* Check for unwanted cruft in the command line */
1475- while ( isspace ( *cmdline ) )
1476- cmdline++;
1477- if ( ( boot_image = strstr ( cmdline, "BOOT_IMAGE=" ) ) != NULL ) {
1478- boot_image_end = strchr ( boot_image, ' ' );
1479- if ( boot_image_end ) {
1480- *boot_image_end = '\0';
1481- DBGC ( image, "CMDLINE stripping \"%s\"\n",
1482- boot_image );
1483- strcpy ( boot_image, ( boot_image_end + 1 ) );
1484- } else {
1485- DBGC ( image, "CMDLINE stripping \"%s\"\n",
1486- boot_image );
1487- *boot_image = '\0';
1488- }
1489- }
1490- DBGC ( image, "CMDLINE using \"%s\"\n", cmdline );
1491-
1492- /* Prepare and register image */
1493- cmdline_image.data = virt_to_user ( cmdline );
1494- cmdline_image.len = strlen ( cmdline );
1495- if ( cmdline_image.len )
1496- register_image ( &cmdline_image );
1497-
1498- /* Drop our reference to the image */
1499- image_put ( &cmdline_image );
1500-}
1501-
1502-/** Command line initialisation function */
1503-struct init_fn cmdline_init_fn __init_fn ( INIT_NORMAL ) = {
1504- .initialise = cmdline_init,
1505-};
1506
1507=== modified file 'src/arch/i386/core/relocate.c'
1508--- src/arch/i386/core/relocate.c 2011-04-11 19:35:36 +0000
1509+++ src/arch/i386/core/relocate.c 2012-02-10 16:40:50 +0000
1510@@ -42,7 +42,7 @@
1511 */
1512 __asmcall void relocate ( struct i386_all_regs *ix86 ) {
1513 struct memory_map memmap;
1514- unsigned long start, end, size, padded_size;
1515+ unsigned long start, end, size, padded_size, max;
1516 unsigned long new_start, new_end;
1517 unsigned i;
1518
1519@@ -57,6 +57,13 @@
1520 "...need %lx bytes for %d-byte alignment\n",
1521 start, end, padded_size, max_align );
1522
1523+ /* Determine maximum usable address */
1524+ max = MAX_ADDR;
1525+ if ( ix86->regs.ebp && ( ix86->regs.ebp < max ) ) {
1526+ max = ix86->regs.ebp;
1527+ DBG ( "Limiting relocation to [0,%lx)\n", max );
1528+ }
1529+
1530 /* Walk through the memory map and find the highest address
1531 * below 4GB that iPXE will fit into.
1532 */
1533@@ -67,18 +74,18 @@
1534
1535 DBG ( "Considering [%llx,%llx)\n", region->start, region->end);
1536
1537- /* Truncate block to MAX_ADDR. This will be less than
1538- * 4GB, which means that we can get away with using
1539- * just 32-bit arithmetic after this stage.
1540+ /* Truncate block to maximum address. This will be
1541+ * less than 4GB, which means that we can get away
1542+ * with using just 32-bit arithmetic after this stage.
1543 */
1544- if ( region->start > MAX_ADDR ) {
1545- DBG ( "...starts after MAX_ADDR=%lx\n", MAX_ADDR );
1546+ if ( region->start > max ) {
1547+ DBG ( "...starts after max=%lx\n", max );
1548 continue;
1549 }
1550 r_start = region->start;
1551- if ( region->end > MAX_ADDR ) {
1552- DBG ( "...end truncated to MAX_ADDR=%lx\n", MAX_ADDR );
1553- r_end = MAX_ADDR;
1554+ if ( region->end > max ) {
1555+ DBG ( "...end truncated to max=%lx\n", max );
1556+ r_end = max;
1557 } else {
1558 r_end = region->end;
1559 }
1560
1561=== added file 'src/arch/i386/core/runtime.c'
1562--- src/arch/i386/core/runtime.c 1970-01-01 00:00:00 +0000
1563+++ src/arch/i386/core/runtime.c 2012-02-10 16:40:50 +0000
1564@@ -0,0 +1,249 @@
1565+/*
1566+ * Copyright (C) 2011 Michael Brown <mbrown@fensystems.co.uk>.
1567+ *
1568+ * This program is free software; you can redistribute it and/or
1569+ * modify it under the terms of the GNU General Public License as
1570+ * published by the Free Software Foundation; either version 2 of the
1571+ * License, or any later version.
1572+ *
1573+ * This program is distributed in the hope that it will be useful, but
1574+ * WITHOUT ANY WARRANTY; without even the implied warranty of
1575+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1576+ * General Public License for more details.
1577+ *
1578+ * You should have received a copy of the GNU General Public License
1579+ * along with this program; if not, write to the Free Software
1580+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1581+ */
1582+
1583+FILE_LICENCE ( GPL2_OR_LATER );
1584+
1585+/** @file
1586+ *
1587+ * Command line and initrd passed to iPXE at runtime
1588+ *
1589+ */
1590+
1591+#include <stddef.h>
1592+#include <stdint.h>
1593+#include <stdlib.h>
1594+#include <errno.h>
1595+#include <assert.h>
1596+#include <ipxe/init.h>
1597+#include <ipxe/image.h>
1598+#include <ipxe/script.h>
1599+#include <ipxe/umalloc.h>
1600+#include <realmode.h>
1601+
1602+/** Command line physical address
1603+ *
1604+ * This can be set by the prefix.
1605+ */
1606+uint32_t __bss16 ( cmdline_phys );
1607+#define cmdline_phys __use_data16 ( cmdline_phys )
1608+
1609+/** initrd physical address
1610+ *
1611+ * This can be set by the prefix.
1612+ */
1613+uint32_t __bss16 ( initrd_phys );
1614+#define initrd_phys __use_data16 ( initrd_phys )
1615+
1616+/** initrd length
1617+ *
1618+ * This can be set by the prefix.
1619+ */
1620+uint32_t __bss16 ( initrd_len );
1621+#define initrd_len __use_data16 ( initrd_len )
1622+
1623+/** Internal copy of the command line */
1624+static char *cmdline_copy;
1625+
1626+/** Free command line image */
1627+static void cmdline_image_free ( struct refcnt *refcnt ) {
1628+ struct image *image = container_of ( refcnt, struct image, refcnt );
1629+
1630+ DBGC ( image, "RUNTIME freeing command line\n" );
1631+ free ( cmdline_copy );
1632+}
1633+
1634+/** Embedded script representing the command line */
1635+static struct image cmdline_image = {
1636+ .refcnt = REF_INIT ( cmdline_image_free ),
1637+ .name = "<CMDLINE>",
1638+ .type = &script_image_type,
1639+};
1640+
1641+/** Colour for debug messages */
1642+#define colour &cmdline_image
1643+
1644+/**
1645+ * Strip unwanted cruft from command line
1646+ *
1647+ * @v cmdline Command line
1648+ * @v cruft Initial substring of cruft to strip
1649+ */
1650+static void cmdline_strip ( char *cmdline, const char *cruft ) {
1651+ char *strip;
1652+ char *strip_end;
1653+
1654+ /* Find unwanted cruft, if present */
1655+ if ( ! ( strip = strstr ( cmdline, cruft ) ) )
1656+ return;
1657+
1658+ /* Strip unwanted cruft */
1659+ strip_end = strchr ( strip, ' ' );
1660+ if ( strip_end ) {
1661+ *strip_end = '\0';
1662+ DBGC ( colour, "RUNTIME stripping \"%s\"\n", strip );
1663+ strcpy ( strip, ( strip_end + 1 ) );
1664+ } else {
1665+ DBGC ( colour, "RUNTIME stripping \"%s\"\n", strip );
1666+ *strip = '\0';
1667+ }
1668+}
1669+
1670+/**
1671+ * Initialise command line
1672+ *
1673+ * @ret rc Return status code
1674+ */
1675+static int cmdline_init ( void ) {
1676+ userptr_t cmdline_user;
1677+ char *cmdline;
1678+ size_t len;
1679+ int rc;
1680+
1681+ /* Do nothing if no command line was specified */
1682+ if ( ! cmdline_phys ) {
1683+ DBGC ( colour, "RUNTIME found no command line\n" );
1684+ return 0;
1685+ }
1686+ cmdline_user = phys_to_user ( cmdline_phys );
1687+ len = ( strlen_user ( cmdline_user, 0 ) + 1 /* NUL */ );
1688+
1689+ /* Allocate and copy command line */
1690+ cmdline_copy = malloc ( len );
1691+ if ( ! cmdline_copy ) {
1692+ DBGC ( colour, "RUNTIME could not allocate %zd bytes for "
1693+ "command line\n", len );
1694+ rc = -ENOMEM;
1695+ goto err_alloc_cmdline_copy;
1696+ }
1697+ cmdline = cmdline_copy;
1698+ copy_from_user ( cmdline, cmdline_user, 0, len );
1699+ DBGC ( colour, "RUNTIME found command line \"%s\"\n", cmdline );
1700+
1701+ /* Strip unwanted cruft from the command line */
1702+ cmdline_strip ( cmdline, "BOOT_IMAGE=" );
1703+ cmdline_strip ( cmdline, "initrd=" );
1704+ while ( isspace ( *cmdline ) )
1705+ cmdline++;
1706+ DBGC ( colour, "RUNTIME using command line \"%s\"\n", cmdline );
1707+
1708+ /* Prepare and register image */
1709+ cmdline_image.data = virt_to_user ( cmdline );
1710+ cmdline_image.len = strlen ( cmdline );
1711+ if ( cmdline_image.len ) {
1712+ if ( ( rc = register_image ( &cmdline_image ) ) != 0 ) {
1713+ DBGC ( colour, "RUNTIME could not register command "
1714+ "line: %s\n", strerror ( rc ) );
1715+ goto err_register_image;
1716+ }
1717+ }
1718+
1719+ /* Drop our reference to the image */
1720+ image_put ( &cmdline_image );
1721+
1722+ return 0;
1723+
1724+ err_register_image:
1725+ image_put ( &cmdline_image );
1726+ err_alloc_cmdline_copy:
1727+ return rc;
1728+}
1729+
1730+/**
1731+ * Initialise initrd
1732+ *
1733+ * @ret rc Return status code
1734+ */
1735+static int initrd_init ( void ) {
1736+ struct image *image;
1737+ int rc;
1738+
1739+ /* Do nothing if no initrd was specified */
1740+ if ( ! initrd_phys ) {
1741+ DBGC ( colour, "RUNTIME found no initrd\n" );
1742+ return 0;
1743+ }
1744+ if ( ! initrd_len ) {
1745+ DBGC ( colour, "RUNTIME found empty initrd\n" );
1746+ return 0;
1747+ }
1748+ DBGC ( colour, "RUNTIME found initrd at [%x,%x)\n",
1749+ initrd_phys, ( initrd_phys + initrd_len ) );
1750+
1751+ /* Allocate image */
1752+ image = alloc_image();
1753+ if ( ! image ) {
1754+ DBGC ( colour, "RUNTIME could not allocate image for "
1755+ "initrd\n" );
1756+ goto err_alloc_image;
1757+ }
1758+ image_set_name ( image, "<INITRD>" );
1759+
1760+ /* Allocate and copy initrd content */
1761+ image->data = umalloc ( initrd_len );
1762+ if ( ! image->data ) {
1763+ DBGC ( colour, "RUNTIME could not allocate %zd bytes for "
1764+ "initrd\n", initrd_len );
1765+ goto err_umalloc;
1766+ }
1767+ image->len = initrd_len;
1768+ memcpy_user ( image->data, 0, phys_to_user ( initrd_phys ), 0,
1769+ initrd_len );
1770+
1771+ /* Register image */
1772+ if ( ( rc = register_image ( image ) ) != 0 ) {
1773+ DBGC ( colour, "RUNTIME could not register initrd: %s\n",
1774+ strerror ( rc ) );
1775+ goto err_register_image;
1776+ }
1777+
1778+ /* Drop our reference to the image */
1779+ image_put ( image );
1780+
1781+ return 0;
1782+
1783+ err_register_image:
1784+ err_umalloc:
1785+ image_put ( image );
1786+ err_alloc_image:
1787+ return rc;
1788+}
1789+
1790+/**
1791+ * Initialise command line and initrd
1792+ *
1793+ */
1794+static void runtime_init ( void ) {
1795+ int rc;
1796+
1797+ /* Initialise command line */
1798+ if ( ( rc = cmdline_init() ) != 0 ) {
1799+ /* No way to report failure */
1800+ return;
1801+ }
1802+
1803+ /* Initialise initrd */
1804+ if ( ( rc = initrd_init() ) != 0 ) {
1805+ /* No way to report failure */
1806+ return;
1807+ }
1808+}
1809+
1810+/** Command line and initrd initialisation function */
1811+struct init_fn runtime_init_fn __init_fn ( INIT_NORMAL ) = {
1812+ .initialise = runtime_init,
1813+};
1814
1815=== modified file 'src/arch/i386/drivers/net/undi.c'
1816--- src/arch/i386/drivers/net/undi.c 2011-04-11 19:35:36 +0000
1817+++ src/arch/i386/drivers/net/undi.c 2012-02-10 16:40:50 +0000
1818@@ -140,7 +140,7 @@
1819 PCI_ROM ( 0xffff, 0xffff, "undipci", "UNDI (PCI)", 0 ),
1820 };
1821
1822-struct pci_driver undipci_driver __pci_driver = {
1823+struct pci_driver undipci_driver __pci_driver_fallback = {
1824 .ids = undipci_nics,
1825 .id_count = ( sizeof ( undipci_nics ) / sizeof ( undipci_nics[0] ) ),
1826 .probe = undipci_probe,
1827
1828=== modified file 'src/arch/i386/drivers/net/undinet.c'
1829--- src/arch/i386/drivers/net/undinet.c 2011-07-31 20:57:02 +0000
1830+++ src/arch/i386/drivers/net/undinet.c 2012-02-10 16:40:50 +0000
1831@@ -19,6 +19,7 @@
1832 FILE_LICENCE ( GPL2_OR_LATER );
1833
1834 #include <string.h>
1835+#include <unistd.h>
1836 #include <pxe.h>
1837 #include <realmode.h>
1838 #include <pic8259.h>
1839@@ -34,7 +35,6 @@
1840 #include <undinet.h>
1841 #include <pxeparent.h>
1842
1843-
1844 /** @file
1845 *
1846 * UNDI network device driver
1847@@ -63,6 +63,12 @@
1848
1849 /** @} */
1850
1851+/** Maximum number of times to retry PXENV_UNDI_INITIALIZE */
1852+#define UNDI_INITIALIZE_RETRY_MAX 10
1853+
1854+/** Delay between retries of PXENV_UNDI_INITIALIZE */
1855+#define UNDI_INITIALIZE_RETRY_DELAY_MS 200
1856+
1857 static void undinet_close ( struct net_device *netdev );
1858
1859 /** Address of UNDI entry point */
1860@@ -482,12 +488,13 @@
1861 struct undi_nic *undinic;
1862 struct s_PXENV_START_UNDI start_undi;
1863 struct s_PXENV_UNDI_STARTUP undi_startup;
1864- struct s_PXENV_UNDI_INITIALIZE undi_initialize;
1865+ struct s_PXENV_UNDI_INITIALIZE undi_init;
1866 struct s_PXENV_UNDI_GET_INFORMATION undi_info;
1867 struct s_PXENV_UNDI_GET_IFACE_INFO undi_iface;
1868 struct s_PXENV_UNDI_SHUTDOWN undi_shutdown;
1869 struct s_PXENV_UNDI_CLEANUP undi_cleanup;
1870 struct s_PXENV_STOP_UNDI stop_undi;
1871+ unsigned int retry;
1872 int rc;
1873
1874 /* Allocate net device */
1875@@ -524,12 +531,27 @@
1876 &undi_startup,
1877 sizeof ( undi_startup ) ) ) != 0 )
1878 goto err_undi_startup;
1879- memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
1880- if ( ( rc = pxeparent_call ( undinet_entry,
1881- PXENV_UNDI_INITIALIZE,
1882- &undi_initialize,
1883- sizeof ( undi_initialize ))) != 0 )
1884- goto err_undi_initialize;
1885+ /* On some PXE stacks, PXENV_UNDI_INITIALIZE may fail
1886+ * due to a transient condition (e.g. media test
1887+ * failing because the link has only just come out of
1888+ * reset). We may therefore need to retry this call
1889+ * several times.
1890+ */
1891+ for ( retry = 0 ; ; ) {
1892+ memset ( &undi_init, 0, sizeof ( undi_init ) );
1893+ if ( ( rc = pxeparent_call ( undinet_entry,
1894+ PXENV_UNDI_INITIALIZE,
1895+ &undi_init,
1896+ sizeof ( undi_init ))) ==0)
1897+ break;
1898+ if ( ++retry > UNDI_INITIALIZE_RETRY_MAX )
1899+ goto err_undi_initialize;
1900+ DBGC ( undinic, "UNDINIC %p retrying "
1901+ "PXENV_UNDI_INITIALIZE (retry %d)\n",
1902+ undinic, retry );
1903+ /* Delay to allow link to settle if necessary */
1904+ mdelay ( UNDI_INITIALIZE_RETRY_DELAY_MS );
1905+ }
1906 }
1907 undi->flags |= UNDI_FL_INITIALIZED;
1908
1909@@ -539,6 +561,7 @@
1910 &undi_info, sizeof ( undi_info ) ) ) != 0 )
1911 goto err_undi_get_information;
1912 memcpy ( netdev->hw_addr, undi_info.PermNodeAddress, ETH_ALEN );
1913+ memcpy ( netdev->ll_addr, undi_info.CurrentNodeAddress, ETH_ALEN );
1914 undinic->irq = undi_info.IntNumber;
1915 if ( undinic->irq > IRQ_MAX ) {
1916 DBGC ( undinic, "UNDINIC %p has invalid IRQ %d\n",
1917
1918=== modified file 'src/arch/i386/drivers/net/undionly.c'
1919--- src/arch/i386/drivers/net/undionly.c 2011-04-11 19:35:36 +0000
1920+++ src/arch/i386/drivers/net/undionly.c 2012-02-10 16:40:50 +0000
1921@@ -20,9 +20,11 @@
1922
1923 #include <stdint.h>
1924 #include <stdlib.h>
1925+#include <stdio.h>
1926 #include <string.h>
1927 #include <ipxe/device.h>
1928 #include <ipxe/init.h>
1929+#include <ipxe/pci.h>
1930 #include <undi.h>
1931 #include <undinet.h>
1932 #include <undipreload.h>
1933@@ -62,15 +64,21 @@
1934 }
1935
1936 /* Add to device hierarchy */
1937- strncpy ( undi->dev.name, "UNDI",
1938- ( sizeof ( undi->dev.name ) - 1 ) );
1939+ undi->dev.driver_name = "undionly";
1940 if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) {
1941 undi->dev.desc.bus_type = BUS_TYPE_PCI;
1942 undi->dev.desc.location = undi->pci_busdevfn;
1943 undi->dev.desc.vendor = undi->pci_vendor;
1944 undi->dev.desc.device = undi->pci_device;
1945+ snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
1946+ "UNDI-PCI%02x:%02x.%x",
1947+ PCI_BUS ( undi->pci_busdevfn ),
1948+ PCI_SLOT ( undi->pci_busdevfn ),
1949+ PCI_FUNC ( undi->pci_busdevfn ) );
1950 } else if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) {
1951 undi->dev.desc.bus_type = BUS_TYPE_ISAPNP;
1952+ snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
1953+ "UNDI-ISAPNP" );
1954 }
1955 undi->dev.parent = &rootdev->dev;
1956 list_add ( &undi->dev.siblings, &rootdev->dev.children);
1957
1958=== modified file 'src/arch/i386/include/bits/errfile.h'
1959--- src/arch/i386/include/bits/errfile.h 2011-04-11 19:35:36 +0000
1960+++ src/arch/i386/include/bits/errfile.h 2012-02-10 16:40:50 +0000
1961@@ -15,6 +15,7 @@
1962 #define ERRFILE_biosint ( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
1963 #define ERRFILE_int13 ( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
1964 #define ERRFILE_pxeparent ( ERRFILE_ARCH | ERRFILE_CORE | 0x00060000 )
1965+#define ERRFILE_runtime ( ERRFILE_ARCH | ERRFILE_CORE | 0x00070000 )
1966
1967 #define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
1968 #define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
1969
1970=== modified file 'src/arch/i386/include/pxe.h'
1971--- src/arch/i386/include/pxe.h 2011-04-11 19:35:36 +0000
1972+++ src/arch/i386/include/pxe.h 2012-02-10 16:40:50 +0000
1973@@ -6,8 +6,12 @@
1974 #include "pxe_types.h"
1975 #include "pxe_api.h"
1976 #include <ipxe/device.h>
1977-
1978-/* Parameter block for pxenv_unknown() */
1979+#include <ipxe/tables.h>
1980+
1981+/** PXE API invalid function code */
1982+#define PXENV_UNKNOWN 0xffff
1983+
1984+/** Parameter block for pxenv_unknown() */
1985 struct s_PXENV_UNKNOWN {
1986 PXENV_STATUS_t Status; /**< PXE status code */
1987 } __attribute__ (( packed ));
1988@@ -72,6 +76,45 @@
1989
1990 typedef union u_PXENV_ANY PXENV_ANY_t;
1991
1992+/** A PXE API call */
1993+struct pxe_api_call {
1994+ /** Entry point
1995+ *
1996+ * @v params PXE API call parameters
1997+ * @ret exit PXE API call exit code
1998+ */
1999+ PXENV_EXIT_t ( * entry ) ( union u_PXENV_ANY *params );
2000+ /** Length of parameters */
2001+ uint16_t params_len;
2002+ /** Opcode */
2003+ uint16_t opcode;
2004+};
2005+
2006+/** PXE API call table */
2007+#define PXE_API_CALLS __table ( struct pxe_api_call, "pxe_api_calls" )
2008+
2009+/** Declare a PXE API call */
2010+#define __pxe_api_call __table_entry ( PXE_API_CALLS, 01 )
2011+
2012+/**
2013+ * Define a PXE API call
2014+ *
2015+ * @v _opcode Opcode
2016+ * @v _entry Entry point
2017+ * @v _params_type Type of parameter structure
2018+ * @ret call PXE API call
2019+ */
2020+#define PXE_API_CALL( _opcode, _entry, _params_type ) { \
2021+ .entry = ( ( ( ( PXENV_EXIT_t ( * ) ( _params_type *params ) ) NULL ) \
2022+ == ( ( typeof ( _entry ) * ) NULL ) ) \
2023+ ? ( ( PXENV_EXIT_t ( * ) \
2024+ ( union u_PXENV_ANY *params ) ) _entry ) \
2025+ : ( ( PXENV_EXIT_t ( * ) \
2026+ ( union u_PXENV_ANY *params ) ) _entry ) ), \
2027+ .params_len = sizeof ( _params_type ), \
2028+ .opcode = _opcode, \
2029+ }
2030+
2031 /** An UNDI expansion ROM header */
2032 struct undi_rom_header {
2033 /** Signature
2034@@ -144,9 +187,11 @@
2035 #define PCIR_SIGNATURE \
2036 ( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )
2037
2038-
2039 extern struct net_device *pxe_netdev;
2040
2041 extern void pxe_set_netdev ( struct net_device *netdev );
2042+extern PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
2043+ *tftp_read_file );
2044+extern PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER *undi_loader );
2045
2046 #endif /* PXE_H */
2047
2048=== modified file 'src/arch/i386/include/pxe_api.h'
2049--- src/arch/i386/include/pxe_api.h 2011-04-11 19:35:36 +0000
2050+++ src/arch/i386/include/pxe_api.h 2012-02-10 16:40:50 +0000
2051@@ -252,9 +252,6 @@
2052
2053 typedef struct s_PXENV_UNLOAD_STACK PXENV_UNLOAD_STACK_t;
2054
2055-extern PXENV_EXIT_t pxenv_unload_stack ( struct s_PXENV_UNLOAD_STACK
2056- *unload_stack );
2057-
2058 /** @} */ /* pxenv_unload_stack */
2059
2060 /** @defgroup pxenv_get_cached_info PXENV_GET_CACHED_INFO
2061@@ -403,9 +400,6 @@
2062
2063 typedef struct bootph BOOTPLAYER_t;
2064
2065-extern PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
2066- *get_cached_info );
2067-
2068 /** @} */ /* pxenv_get_cached_info */
2069
2070 /** @defgroup pxenv_restart_tftp PXENV_RESTART_TFTP
2071@@ -423,9 +417,6 @@
2072
2073 typedef struct s_PXENV_RESTART_TFTP PXENV_RESTART_TFTP_t;
2074
2075-extern PXENV_EXIT_t pxenv_restart_tftp ( struct s_PXENV_TFTP_READ_FILE
2076- *restart_tftp );
2077-
2078 /** @} */ /* pxenv_restart_tftp */
2079
2080 /** @defgroup pxenv_start_undi PXENV_START_UNDI
2081@@ -496,8 +487,6 @@
2082
2083 typedef struct s_PXENV_START_UNDI PXENV_START_UNDI_t;
2084
2085-extern PXENV_EXIT_t pxenv_start_undi ( struct s_PXENV_START_UNDI *start_undi );
2086-
2087 /** @} */ /* pxenv_start_undi */
2088
2089 /** @defgroup pxenv_stop_undi PXENV_STOP_UNDI
2090@@ -517,8 +506,6 @@
2091
2092 typedef struct s_PXENV_STOP_UNDI PXENV_STOP_UNDI_t;
2093
2094-extern PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi );
2095-
2096 /** @} */ /* pxenv_stop_undi */
2097
2098 /** @defgroup pxenv_start_base PXENV_START_BASE
2099@@ -538,8 +525,6 @@
2100
2101 typedef struct s_PXENV_START_BASE PXENV_START_BASE_t;
2102
2103-extern PXENV_EXIT_t pxenv_start_base ( struct s_PXENV_START_BASE *start_base );
2104-
2105 /** @} */ /* pxenv_start_base */
2106
2107 /** @defgroup pxenv_stop_base PXENV_STOP_BASE
2108@@ -559,8 +544,6 @@
2109
2110 typedef struct s_PXENV_STOP_BASE PXENV_STOP_BASE_t;
2111
2112-extern PXENV_EXIT_t pxenv_stop_base ( struct s_PXENV_STOP_BASE *stop_base );
2113-
2114 /** @} */ /* pxenv_stop_base */
2115
2116 /** @} */ /* pxe_preboot_api */
2117@@ -600,8 +583,6 @@
2118
2119 typedef struct s_PXENV_TFTP_OPEN PXENV_TFTP_OPEN_t;
2120
2121-extern PXENV_EXIT_t pxenv_tftp_open ( struct s_PXENV_TFTP_OPEN *tftp_open );
2122-
2123 /** @} */ /* pxenv_tftp_open */
2124
2125 /** @defgroup pxenv_tftp_close PXENV_TFTP_CLOSE
2126@@ -621,8 +602,6 @@
2127
2128 typedef struct s_PXENV_TFTP_CLOSE PXENV_TFTP_CLOSE_t;
2129
2130-extern PXENV_EXIT_t pxenv_tftp_close ( struct s_PXENV_TFTP_CLOSE *tftp_close );
2131-
2132 /** @} */ /* pxenv_tftp_close */
2133
2134 /** @defgroup pxenv_tftp_read PXENV_TFTP_READ
2135@@ -645,8 +624,6 @@
2136
2137 typedef struct s_PXENV_TFTP_READ PXENV_TFTP_READ_t;
2138
2139-extern PXENV_EXIT_t pxenv_tftp_read ( struct s_PXENV_TFTP_READ *tftp_read );
2140-
2141 /** @} */ /* pxenv_tftp_read */
2142
2143 /** @defgroup pxenv_tftp_read_file PXENV_TFTP_READ_FILE
2144@@ -690,9 +667,6 @@
2145
2146 typedef struct s_PXENV_TFTP_READ_FILE PXENV_TFTP_READ_FILE_t;
2147
2148-extern PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
2149- *tftp_read_file );
2150-
2151 /** @} */ /* pxenv_tftp_read_file */
2152
2153 /** @defgroup pxenv_tftp_get_fsize PXENV_TFTP_GET_FSIZE
2154@@ -716,9 +690,6 @@
2155
2156 typedef struct s_PXENV_TFTP_GET_FSIZE PXENV_TFTP_GET_FSIZE_t;
2157
2158-extern PXENV_EXIT_t pxenv_tftp_get_fsize ( struct s_PXENV_TFTP_GET_FSIZE
2159- *get_fsize );
2160-
2161 /** @} */ /* pxenv_tftp_get_fsize */
2162
2163 /** @} */ /* pxe_tftp_api */
2164@@ -748,8 +719,6 @@
2165
2166 typedef struct s_PXENV_UDP_OPEN PXENV_UDP_OPEN_t;
2167
2168-extern PXENV_EXIT_t pxenv_udp_open ( struct s_PXENV_UDP_OPEN *udp_open );
2169-
2170 /** @} */ /* pxenv_udp_open */
2171
2172 /** @defgroup pxenv_udp_close PXENV_UDP_CLOSE
2173@@ -769,8 +738,6 @@
2174
2175 typedef struct s_PXENV_UDP_CLOSE PXENV_UDP_CLOSE_t;
2176
2177-extern PXENV_EXIT_t pxenv_udp_close ( struct s_PXENV_UDP_CLOSE *udp_close );
2178-
2179 /** @} */ /* pxenv_udp_close */
2180
2181 /** @defgroup pxenv_udp_write PXENV_UDP_WRITE
2182@@ -796,8 +763,6 @@
2183
2184 typedef struct s_PXENV_UDP_WRITE PXENV_UDP_WRITE_t;
2185
2186-extern PXENV_EXIT_t pxenv_udp_write ( struct s_PXENV_UDP_WRITE *udp_write );
2187-
2188 /** @} */ /* pxenv_udp_write */
2189
2190 /** @defgroup pxenv_udp_read PXENV_UDP_READ
2191@@ -823,8 +788,6 @@
2192
2193 typedef struct s_PXENV_UDP_READ PXENV_UDP_READ_t;
2194
2195-extern PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *udp_read );
2196-
2197 /** @} */ /* pxenv_udp_read */
2198
2199 /** @} */ /* pxe_udp_api */
2200@@ -860,9 +823,6 @@
2201
2202 typedef struct s_PXENV_UNDI_STARTUP PXENV_UNDI_STARTUP_t;
2203
2204-extern PXENV_EXIT_t pxenv_undi_startup ( struct s_PXENV_UNDI_STARTUP
2205- *undi_startup );
2206-
2207 /** @} */ /* pxenv_undi_startup */
2208
2209 /** @defgroup pxenv_undi_cleanup PXENV_UNDI_CLEANUP
2210@@ -882,9 +842,6 @@
2211
2212 typedef struct s_PXENV_UNDI_CLEANUP PXENV_UNDI_CLEANUP_t;
2213
2214-extern PXENV_EXIT_t pxenv_undi_cleanup ( struct s_PXENV_UNDI_CLEANUP
2215- *undi_cleanup );
2216-
2217 /** @} */ /* pxenv_undi_cleanup */
2218
2219 /** @defgroup pxenv_undi_initialize PXENV_UNDI_INITIALIZE
2220@@ -913,9 +870,6 @@
2221
2222 typedef struct s_PXENV_UNDI_INITIALIZE PXENV_UNDI_INITIALIZE_t;
2223
2224-extern PXENV_EXIT_t pxenv_undi_initialize ( struct s_PXENV_UNDI_INITIALIZE
2225- *undi_initialize );
2226-
2227 /** @} */ /* pxenv_undi_initialize */
2228
2229 /** @defgroup pxenv_undi_reset_adapter PXENV_UNDI_RESET_ADAPTER
2230@@ -950,9 +904,6 @@
2231
2232 typedef struct s_PXENV_UNDI_RESET PXENV_UNDI_RESET_t;
2233
2234-extern PXENV_EXIT_t pxenv_undi_reset_adapter ( struct s_PXENV_UNDI_RESET
2235- *undi_reset_adapter );
2236-
2237 /** @} */ /* pxenv_undi_reset_adapter */
2238
2239 /** @defgroup pxenv_undi_shutdown PXENV_UNDI_SHUTDOWN
2240@@ -972,9 +923,6 @@
2241
2242 typedef struct s_PXENV_UNDI_SHUTDOWN PXENV_UNDI_SHUTDOWN_t;
2243
2244-extern PXENV_EXIT_t pxenv_undi_shutdown ( struct s_PXENV_UNDI_SHUTDOWN
2245- *undi_shutdown );
2246-
2247 /** @} */ /* pxenv_undi_shutdown */
2248
2249 /** @defgroup pxenv_undi_open PXENV_UNDI_OPEN
2250@@ -1024,8 +972,6 @@
2251
2252 typedef struct s_PXENV_UNDI_OPEN PXENV_UNDI_OPEN_t;
2253
2254-extern PXENV_EXIT_t pxenv_undi_open ( struct s_PXENV_UNDI_OPEN *undi_open );
2255-
2256 /** @} */ /* pxenv_undi_open */
2257
2258 /** @defgroup pxenv_undi_close PXENV_UNDI_CLOSE
2259@@ -1045,8 +991,6 @@
2260
2261 typedef struct s_PXENV_UNDI_CLOSE PXENV_UNDI_CLOSE_t;
2262
2263-extern PXENV_EXIT_t pxenv_undi_close ( struct s_PXENV_UNDI_CLOSE *undi_close );
2264-
2265 /** @} */ /* pxenv_undi_close */
2266
2267 /** @defgroup pxenv_undi_transmit PXENV_UNDI_TRANSMIT
2268@@ -1122,9 +1066,6 @@
2269
2270 typedef struct s_PXENV_UNDI_TRANSMIT PXENV_UNDI_TRANSMIT_t;
2271
2272-extern PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
2273- *undi_transmit );
2274-
2275 /** @} */ /* pxenv_undi_transmit */
2276
2277 /** @defgroup pxenv_undi_set_mcast_address PXENV_UNDI_SET_MCAST_ADDRESS
2278@@ -1146,9 +1087,6 @@
2279
2280 typedef struct s_PXENV_UNDI_SET_MCAST_ADDRESS PXENV_UNDI_SET_MCAST_ADDRESS_t;
2281
2282-extern PXENV_EXIT_t pxenv_undi_set_mcast_address (
2283- struct s_PXENV_UNDI_SET_MCAST_ADDRESS *undi_set_mcast_address );
2284-
2285 /** @} */ /* pxenv_undi_set_mcast_address */
2286
2287 /** @defgroup pxenv_undi_set_station_address PXENV_UNDI_SET_STATION_ADDRESS
2288@@ -1169,9 +1107,6 @@
2289
2290 typedef struct s_PXENV_UNDI_SET_STATION_ADDRESS PXENV_UNDI_SET_STATION_ADDRESS_t;
2291
2292-extern PXENV_EXIT_t pxenv_undi_set_station_address (
2293- struct s_PXENV_UNDI_SET_STATION_ADDRESS *undi_set_station_address );
2294-
2295 /** @} */ /* pxenv_undi_set_station_address */
2296
2297 /** @defgroup pxenv_undi_set_packet_filter PXENV_UNDI_SET_PACKET_FILTER
2298@@ -1202,9 +1137,6 @@
2299
2300 typedef struct s_PXENV_UNDI_SET_PACKET_FILTER PXENV_UNDI_SET_PACKET_FILTER_t;
2301
2302-extern PXENV_EXIT_t pxenv_undi_set_packet_filter (
2303- struct s_PXENV_UNDI_SET_PACKET_FILTER *undi_set_packet_filter );
2304-
2305 /** @} */ /* pxenv_undi_set_packet_filter */
2306
2307 /** @defgroup pxenv_undi_get_information PXENV_UNDI_GET_INFORMATION
2308@@ -1248,9 +1180,6 @@
2309
2310 typedef struct s_PXENV_UNDI_GET_INFORMATION PXENV_UNDI_GET_INFORMATION_t;
2311
2312-extern PXENV_EXIT_t pxenv_undi_get_information (
2313- struct s_PXENV_UNDI_GET_INFORMATION *undi_get_information );
2314-
2315 /** @} */ /* pxenv_undi_get_information */
2316
2317 /** @defgroup pxenv_undi_get_statistics PXENV_UNDI_GET_STATISTICS
2318@@ -1274,9 +1203,6 @@
2319
2320 typedef struct s_PXENV_UNDI_GET_STATISTICS PXENV_UNDI_GET_STATISTICS_t;
2321
2322-extern PXENV_EXIT_t pxenv_undi_get_statistics (
2323- struct s_PXENV_UNDI_GET_STATISTICS *undi_get_statistics );
2324-
2325 /** @} */ /* pxenv_undi_get_statistics */
2326
2327 /** @defgroup pxenv_undi_clear_statistics PXENV_UNDI_CLEAR_STATISTICS
2328@@ -1296,9 +1222,6 @@
2329
2330 typedef struct s_PXENV_UNDI_CLEAR_STATISTICS PXENV_UNDI_CLEAR_STATISTICS_t;
2331
2332-extern PXENV_EXIT_t pxenv_undi_clear_statistics (
2333- struct s_PXENV_UNDI_CLEAR_STATISTICS *undi_clear_statistics );
2334-
2335 /** @} */ /* pxenv_undi_clear_statistics */
2336
2337 /** @defgroup pxenv_undi_initiate_diags PXENV_UNDI_INITIATE_DIAGS
2338@@ -1318,9 +1241,6 @@
2339
2340 typedef struct s_PXENV_UNDI_INITIATE_DIAGS PXENV_UNDI_INITIATE_DIAGS_t;
2341
2342-extern PXENV_EXIT_t pxenv_undi_initiate_diags (
2343- struct s_PXENV_UNDI_INITIATE_DIAGS *undi_initiate_diags );
2344-
2345 /** @} */ /* pxenv_undi_initiate_diags */
2346
2347 /** @defgroup pxenv_undi_force_interrupt PXENV_UNDI_FORCE_INTERRUPT
2348@@ -1340,9 +1260,6 @@
2349
2350 typedef struct s_PXENV_UNDI_FORCE_INTERRUPT PXENV_UNDI_FORCE_INTERRUPT_t;
2351
2352-extern PXENV_EXIT_t pxenv_undi_force_interrupt (
2353- struct s_PXENV_UNDI_FORCE_INTERRUPT *undi_force_interrupt );
2354-
2355 /** @} */ /* pxenv_undi_force_interrupt */
2356
2357 /** @defgroup pxenv_undi_get_mcast_address PXENV_UNDI_GET_MCAST_ADDRESS
2358@@ -1364,9 +1281,6 @@
2359
2360 typedef struct s_PXENV_UNDI_GET_MCAST_ADDRESS PXENV_UNDI_GET_MCAST_ADDRESS_t;
2361
2362-extern PXENV_EXIT_t pxenv_undi_get_mcast_address (
2363- struct s_PXENV_UNDI_GET_MCAST_ADDRESS *undi_get_mcast_address );
2364-
2365 /** @} */ /* pxenv_undi_get_mcast_address */
2366
2367 /** @defgroup pxenv_undi_get_nic_type PXENV_UNDI_GET_NIC_TYPE
2368@@ -1427,9 +1341,6 @@
2369
2370 typedef struct s_PXENV_UNDI_GET_NIC_TYPE PXENV_UNDI_GET_NIC_TYPE_t;
2371
2372-extern PXENV_EXIT_t pxenv_undi_get_nic_type (
2373- struct s_PXENV_UNDI_GET_NIC_TYPE *undi_get_nic_type );
2374-
2375 /** @} */ /* pxenv_undi_get_nic_type */
2376
2377 /** @defgroup pxenv_undi_get_iface_info PXENV_UNDI_GET_IFACE_INFO
2378@@ -1488,9 +1399,6 @@
2379
2380 typedef struct s_PXENV_UNDI_GET_IFACE_INFO PXENV_UNDI_GET_IFACE_INFO_t;
2381
2382-extern PXENV_EXIT_t pxenv_undi_get_iface_info (
2383- struct s_PXENV_UNDI_GET_IFACE_INFO *undi_get_iface_info );
2384-
2385 /** @} */ /* pxenv_undi_get_iface_info */
2386
2387 /** @defgroup pxenv_undi_get_state PXENV_UNDI_GET_STATE
2388@@ -1524,9 +1432,6 @@
2389
2390 typedef struct s_PXENV_UNDI_GET_STATE PXENV_UNDI_GET_STATE_t;
2391
2392-extern PXENV_EXIT_t pxenv_undi_get_state ( struct s_PXENV_UNDI_GET_STATE
2393- *undi_get_state );
2394-
2395 /** @} */ /* pxenv_undi_get_state */
2396
2397 /** @defgroup pxenv_undi_isr PXENV_UNDI_ISR
2398@@ -1595,8 +1500,6 @@
2399
2400 typedef struct s_PXENV_UNDI_ISR PXENV_UNDI_ISR_t;
2401
2402-extern PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr );
2403-
2404 /** @} */ /* pxenv_undi_isr */
2405
2406 /** @} */ /* pxe_undi_api */
2407@@ -1608,6 +1511,12 @@
2408 * @{
2409 */
2410
2411+/** Minimum possible opcode used within PXE FILE API */
2412+#define PXENV_FILE_MIN 0x00e0
2413+
2414+/** Minimum possible opcode used within PXE FILE API */
2415+#define PXENV_FILE_MAX 0x00ef
2416+
2417 /** @defgroup pxenv_file_open PXENV_FILE_OPEN
2418 *
2419 * FILE OPEN
2420@@ -1628,8 +1537,6 @@
2421
2422 typedef struct s_PXENV_FILE_OPEN PXENV_FILE_OPEN_t;
2423
2424-extern PXENV_EXIT_t pxenv_file_open ( struct s_PXENV_FILE_OPEN *file_open );
2425-
2426 /** @} */ /* pxenv_file_open */
2427
2428 /** @defgroup pxenv_file_close PXENV_FILE_CLOSE
2429@@ -1650,9 +1557,6 @@
2430
2431 typedef struct s_PXENV_FILE_CLOSE PXENV_FILE_CLOSE_t;
2432
2433-extern PXENV_EXIT_t pxenv_file_close ( struct s_PXENV_FILE_CLOSE
2434- *file_close );
2435-
2436 /** @} */ /* pxenv_file_close */
2437
2438 /** @defgroup pxenv_file_select PXENV_FILE_SELECT
2439@@ -1677,9 +1581,6 @@
2440
2441 typedef struct s_PXENV_FILE_SELECT PXENV_FILE_SELECT_t;
2442
2443-extern PXENV_EXIT_t pxenv_file_select ( struct s_PXENV_FILE_SELECT
2444- *file_select );
2445-
2446 /** @} */ /* pxenv_file_select */
2447
2448 /** @defgroup pxenv_file_read PXENV_FILE_READ
2449@@ -1702,8 +1603,6 @@
2450
2451 typedef struct s_PXENV_FILE_READ PXENV_FILE_READ_t;
2452
2453-extern PXENV_EXIT_t pxenv_file_read ( struct s_PXENV_FILE_READ *file_read );
2454-
2455 /** @} */ /* pxenv_file_read */
2456
2457 /** @defgroup pxenv_get_file_size PXENV_GET_FILE_SIZE
2458@@ -1725,9 +1624,6 @@
2459
2460 typedef struct s_PXENV_GET_FILE_SIZE PXENV_GET_FILE_SIZE_t;
2461
2462-extern PXENV_EXIT_t pxenv_get_file_size ( struct s_PXENV_GET_FILE_SIZE
2463- *get_file_size );
2464-
2465 /** @} */ /* pxenv_get_file_size */
2466
2467 /** @defgroup pxenv_file_exec PXENV_FILE_EXEC
2468@@ -1748,8 +1644,6 @@
2469
2470 typedef struct s_PXENV_FILE_EXEC PXENV_FILE_EXEC_t;
2471
2472-extern PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec );
2473-
2474 /** @} */ /* pxenv_file_exec */
2475
2476 /** @defgroup pxenv_file_api_check PXENV_FILE_API_CHECK
2477@@ -1774,8 +1668,6 @@
2478
2479 typedef struct s_PXENV_FILE_API_CHECK PXENV_FILE_API_CHECK_t;
2480
2481-extern PXENV_EXIT_t pxenv_file_api_check ( struct s_PXENV_FILE_API_CHECK *file_api_check );
2482-
2483 /** @} */ /* pxenv_file_api_check */
2484
2485 /** @defgroup pxenv_file_exit_hook PXENV_FILE_EXIT_HOOK
2486@@ -1796,8 +1688,6 @@
2487
2488 typedef struct s_PXENV_FILE_EXIT_HOOK PXENV_FILE_EXIT_HOOK_t;
2489
2490-extern PXENV_EXIT_t pxenv_file_exit_hook ( struct s_PXENV_FILE_EXIT_HOOK *file_exit_hook );
2491-
2492 /** @} */ /* pxenv_file_exit_hook */
2493
2494 /** @} */ /* pxe_file_api */
2495@@ -1847,8 +1737,6 @@
2496
2497 typedef struct s_UNDI_LOADER UNDI_LOADER_t;
2498
2499-extern PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER *undi_loader );
2500-
2501 /** @} */ /* pxe_loader_api */
2502
2503 /** @} */ /* pxe */
2504
2505=== modified file 'src/arch/i386/interface/pxe/pxe_call.c'
2506--- src/arch/i386/interface/pxe/pxe_call.c 2011-04-11 19:35:36 +0000
2507+++ src/arch/i386/interface/pxe/pxe_call.c 2012-02-10 16:40:50 +0000
2508@@ -41,73 +41,6 @@
2509 /** INT 1A hooked flag */
2510 static int int_1a_hooked = 0;
2511
2512-/** A function pointer to hold any PXE API call
2513- *
2514- * Used by pxe_api_call() to avoid large swathes of duplicated code.
2515- */
2516-union pxenv_call {
2517- PXENV_EXIT_t ( * any ) ( union u_PXENV_ANY * );
2518- PXENV_EXIT_t ( * unknown ) ( struct s_PXENV_UNKNOWN * );
2519- PXENV_EXIT_t ( * unload_stack ) ( struct s_PXENV_UNLOAD_STACK * );
2520- PXENV_EXIT_t ( * get_cached_info )
2521- ( struct s_PXENV_GET_CACHED_INFO * );
2522- PXENV_EXIT_t ( * restart_tftp ) ( struct s_PXENV_TFTP_READ_FILE * );
2523- PXENV_EXIT_t ( * start_undi ) ( struct s_PXENV_START_UNDI * );
2524- PXENV_EXIT_t ( * stop_undi ) ( struct s_PXENV_STOP_UNDI * );
2525- PXENV_EXIT_t ( * start_base ) ( struct s_PXENV_START_BASE * );
2526- PXENV_EXIT_t ( * stop_base ) ( struct s_PXENV_STOP_BASE * );
2527- PXENV_EXIT_t ( * tftp_open ) ( struct s_PXENV_TFTP_OPEN * );
2528- PXENV_EXIT_t ( * tftp_close ) ( struct s_PXENV_TFTP_CLOSE * );
2529- PXENV_EXIT_t ( * tftp_read ) ( struct s_PXENV_TFTP_READ * );
2530- PXENV_EXIT_t ( * tftp_read_file ) ( struct s_PXENV_TFTP_READ_FILE * );
2531- PXENV_EXIT_t ( * tftp_get_fsize ) ( struct s_PXENV_TFTP_GET_FSIZE * );
2532- PXENV_EXIT_t ( * udp_open ) ( struct s_PXENV_UDP_OPEN * );
2533- PXENV_EXIT_t ( * udp_close ) ( struct s_PXENV_UDP_CLOSE * );
2534- PXENV_EXIT_t ( * udp_write ) ( struct s_PXENV_UDP_WRITE * );
2535- PXENV_EXIT_t ( * udp_read ) ( struct s_PXENV_UDP_READ * );
2536- PXENV_EXIT_t ( * undi_startup ) ( struct s_PXENV_UNDI_STARTUP * );
2537- PXENV_EXIT_t ( * undi_cleanup ) ( struct s_PXENV_UNDI_CLEANUP * );
2538- PXENV_EXIT_t ( * undi_initialize )
2539- ( struct s_PXENV_UNDI_INITIALIZE * );
2540- PXENV_EXIT_t ( * undi_reset_adapter ) ( struct s_PXENV_UNDI_RESET * );
2541- PXENV_EXIT_t ( * undi_shutdown ) ( struct s_PXENV_UNDI_SHUTDOWN * );
2542- PXENV_EXIT_t ( * undi_open ) ( struct s_PXENV_UNDI_OPEN * );
2543- PXENV_EXIT_t ( * undi_close ) ( struct s_PXENV_UNDI_CLOSE * );
2544- PXENV_EXIT_t ( * undi_transmit ) ( struct s_PXENV_UNDI_TRANSMIT * );
2545- PXENV_EXIT_t ( * undi_set_mcast_address )
2546- ( struct s_PXENV_UNDI_SET_MCAST_ADDRESS * );
2547- PXENV_EXIT_t ( * undi_set_station_address )
2548- ( struct s_PXENV_UNDI_SET_STATION_ADDRESS * );
2549- PXENV_EXIT_t ( * undi_set_packet_filter )
2550- ( struct s_PXENV_UNDI_SET_PACKET_FILTER * );
2551- PXENV_EXIT_t ( * undi_get_information )
2552- ( struct s_PXENV_UNDI_GET_INFORMATION * );
2553- PXENV_EXIT_t ( * undi_get_statistics )
2554- ( struct s_PXENV_UNDI_GET_STATISTICS * );
2555- PXENV_EXIT_t ( * undi_clear_statistics )
2556- ( struct s_PXENV_UNDI_CLEAR_STATISTICS * );
2557- PXENV_EXIT_t ( * undi_initiate_diags )
2558- ( struct s_PXENV_UNDI_INITIATE_DIAGS * );
2559- PXENV_EXIT_t ( * undi_force_interrupt )
2560- ( struct s_PXENV_UNDI_FORCE_INTERRUPT * );
2561- PXENV_EXIT_t ( * undi_get_mcast_address )
2562- ( struct s_PXENV_UNDI_GET_MCAST_ADDRESS * );
2563- PXENV_EXIT_t ( * undi_get_nic_type )
2564- ( struct s_PXENV_UNDI_GET_NIC_TYPE * );
2565- PXENV_EXIT_t ( * undi_get_iface_info )
2566- ( struct s_PXENV_UNDI_GET_IFACE_INFO * );
2567- PXENV_EXIT_t ( * undi_get_state ) ( struct s_PXENV_UNDI_GET_STATE * );
2568- PXENV_EXIT_t ( * undi_isr ) ( struct s_PXENV_UNDI_ISR * );
2569- PXENV_EXIT_t ( * file_open ) ( struct s_PXENV_FILE_OPEN * );
2570- PXENV_EXIT_t ( * file_close ) ( struct s_PXENV_FILE_CLOSE * );
2571- PXENV_EXIT_t ( * file_select ) ( struct s_PXENV_FILE_SELECT * );
2572- PXENV_EXIT_t ( * file_read ) ( struct s_PXENV_FILE_READ * );
2573- PXENV_EXIT_t ( * get_file_size ) ( struct s_PXENV_GET_FILE_SIZE * );
2574- PXENV_EXIT_t ( * file_exec ) ( struct s_PXENV_FILE_EXEC * );
2575- PXENV_EXIT_t ( * file_api_check ) ( struct s_PXENV_FILE_API_CHECK * );
2576- PXENV_EXIT_t ( * file_exit_hook ) ( struct s_PXENV_FILE_EXIT_HOOK * );
2577-};
2578-
2579 /**
2580 * Handle an unknown PXE API call
2581 *
2582@@ -120,6 +53,26 @@
2583 return PXENV_EXIT_FAILURE;
2584 }
2585
2586+/** Unknown PXE API call list */
2587+struct pxe_api_call pxenv_unknown_api __pxe_api_call =
2588+ PXE_API_CALL ( PXENV_UNKNOWN, pxenv_unknown, struct s_PXENV_UNKNOWN );
2589+
2590+/**
2591+ * Locate PXE API call
2592+ *
2593+ * @v opcode Opcode
2594+ * @ret call PXE API call, or NULL
2595+ */
2596+static struct pxe_api_call * find_pxe_api_call ( uint16_t opcode ) {
2597+ struct pxe_api_call *call;
2598+
2599+ for_each_table_entry ( call, PXE_API_CALLS ) {
2600+ if ( call->opcode == opcode )
2601+ return call;
2602+ }
2603+ return NULL;
2604+}
2605+
2606 /**
2607 * Dispatch PXE API call
2608 *
2609@@ -128,220 +81,30 @@
2610 * @ret ax PXE exit code
2611 */
2612 __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
2613- int opcode = ix86->regs.bx;
2614- userptr_t parameters = real_to_user ( ix86->segs.es, ix86->regs.di );
2615- size_t param_len;
2616- union u_PXENV_ANY pxenv_any;
2617- union pxenv_call pxenv_call;
2618+ uint16_t opcode = ix86->regs.bx;
2619+ userptr_t uparams = real_to_user ( ix86->segs.es, ix86->regs.di );
2620+ struct pxe_api_call *call;
2621+ union u_PXENV_ANY params;
2622 PXENV_EXIT_t ret;
2623
2624- switch ( opcode ) {
2625- case PXENV_UNLOAD_STACK:
2626- pxenv_call.unload_stack = pxenv_unload_stack;
2627- param_len = sizeof ( pxenv_any.unload_stack );
2628- break;
2629- case PXENV_GET_CACHED_INFO:
2630- pxenv_call.get_cached_info = pxenv_get_cached_info;
2631- param_len = sizeof ( pxenv_any.get_cached_info );
2632- break;
2633- case PXENV_RESTART_TFTP:
2634- pxenv_call.restart_tftp = pxenv_restart_tftp;
2635- param_len = sizeof ( pxenv_any.restart_tftp );
2636- break;
2637- case PXENV_START_UNDI:
2638- pxenv_call.start_undi = pxenv_start_undi;
2639- param_len = sizeof ( pxenv_any.start_undi );
2640- break;
2641- case PXENV_STOP_UNDI:
2642- pxenv_call.stop_undi = pxenv_stop_undi;
2643- param_len = sizeof ( pxenv_any.stop_undi );
2644- break;
2645- case PXENV_START_BASE:
2646- pxenv_call.start_base = pxenv_start_base;
2647- param_len = sizeof ( pxenv_any.start_base );
2648- break;
2649- case PXENV_STOP_BASE:
2650- pxenv_call.stop_base = pxenv_stop_base;
2651- param_len = sizeof ( pxenv_any.stop_base );
2652- break;
2653- case PXENV_TFTP_OPEN:
2654- pxenv_call.tftp_open = pxenv_tftp_open;
2655- param_len = sizeof ( pxenv_any.tftp_open );
2656- break;
2657- case PXENV_TFTP_CLOSE:
2658- pxenv_call.tftp_close = pxenv_tftp_close;
2659- param_len = sizeof ( pxenv_any.tftp_close );
2660- break;
2661- case PXENV_TFTP_READ:
2662- pxenv_call.tftp_read = pxenv_tftp_read;
2663- param_len = sizeof ( pxenv_any.tftp_read );
2664- break;
2665- case PXENV_TFTP_READ_FILE:
2666- pxenv_call.tftp_read_file = pxenv_tftp_read_file;
2667- param_len = sizeof ( pxenv_any.tftp_read_file );
2668- break;
2669- case PXENV_TFTP_GET_FSIZE:
2670- pxenv_call.tftp_get_fsize = pxenv_tftp_get_fsize;
2671- param_len = sizeof ( pxenv_any.tftp_get_fsize );
2672- break;
2673- case PXENV_UDP_OPEN:
2674- pxenv_call.udp_open = pxenv_udp_open;
2675- param_len = sizeof ( pxenv_any.udp_open );
2676- break;
2677- case PXENV_UDP_CLOSE:
2678- pxenv_call.udp_close = pxenv_udp_close;
2679- param_len = sizeof ( pxenv_any.udp_close );
2680- break;
2681- case PXENV_UDP_WRITE:
2682- pxenv_call.udp_write = pxenv_udp_write;
2683- param_len = sizeof ( pxenv_any.udp_write );
2684- break;
2685- case PXENV_UDP_READ:
2686- pxenv_call.udp_read = pxenv_udp_read;
2687- param_len = sizeof ( pxenv_any.udp_read );
2688- break;
2689- case PXENV_UNDI_STARTUP:
2690- pxenv_call.undi_startup = pxenv_undi_startup;
2691- param_len = sizeof ( pxenv_any.undi_startup );
2692- break;
2693- case PXENV_UNDI_CLEANUP:
2694- pxenv_call.undi_cleanup = pxenv_undi_cleanup;
2695- param_len = sizeof ( pxenv_any.undi_cleanup );
2696- break;
2697- case PXENV_UNDI_INITIALIZE:
2698- pxenv_call.undi_initialize = pxenv_undi_initialize;
2699- param_len = sizeof ( pxenv_any.undi_initialize );
2700- break;
2701- case PXENV_UNDI_RESET_ADAPTER:
2702- pxenv_call.undi_reset_adapter = pxenv_undi_reset_adapter;
2703- param_len = sizeof ( pxenv_any.undi_reset_adapter );
2704- break;
2705- case PXENV_UNDI_SHUTDOWN:
2706- pxenv_call.undi_shutdown = pxenv_undi_shutdown;
2707- param_len = sizeof ( pxenv_any.undi_shutdown );
2708- break;
2709- case PXENV_UNDI_OPEN:
2710- pxenv_call.undi_open = pxenv_undi_open;
2711- param_len = sizeof ( pxenv_any.undi_open );
2712- break;
2713- case PXENV_UNDI_CLOSE:
2714- pxenv_call.undi_close = pxenv_undi_close;
2715- param_len = sizeof ( pxenv_any.undi_close );
2716- break;
2717- case PXENV_UNDI_TRANSMIT:
2718- pxenv_call.undi_transmit = pxenv_undi_transmit;
2719- param_len = sizeof ( pxenv_any.undi_transmit );
2720- break;
2721- case PXENV_UNDI_SET_MCAST_ADDRESS:
2722- pxenv_call.undi_set_mcast_address =
2723- pxenv_undi_set_mcast_address;
2724- param_len = sizeof ( pxenv_any.undi_set_mcast_address );
2725- break;
2726- case PXENV_UNDI_SET_STATION_ADDRESS:
2727- pxenv_call.undi_set_station_address =
2728- pxenv_undi_set_station_address;
2729- param_len = sizeof ( pxenv_any.undi_set_station_address );
2730- break;
2731- case PXENV_UNDI_SET_PACKET_FILTER:
2732- pxenv_call.undi_set_packet_filter =
2733- pxenv_undi_set_packet_filter;
2734- param_len = sizeof ( pxenv_any.undi_set_packet_filter );
2735- break;
2736- case PXENV_UNDI_GET_INFORMATION:
2737- pxenv_call.undi_get_information = pxenv_undi_get_information;
2738- param_len = sizeof ( pxenv_any.undi_get_information );
2739- break;
2740- case PXENV_UNDI_GET_STATISTICS:
2741- pxenv_call.undi_get_statistics = pxenv_undi_get_statistics;
2742- param_len = sizeof ( pxenv_any.undi_get_statistics );
2743- break;
2744- case PXENV_UNDI_CLEAR_STATISTICS:
2745- pxenv_call.undi_clear_statistics = pxenv_undi_clear_statistics;
2746- param_len = sizeof ( pxenv_any.undi_clear_statistics );
2747- break;
2748- case PXENV_UNDI_INITIATE_DIAGS:
2749- pxenv_call.undi_initiate_diags = pxenv_undi_initiate_diags;
2750- param_len = sizeof ( pxenv_any.undi_initiate_diags );
2751- break;
2752- case PXENV_UNDI_FORCE_INTERRUPT:
2753- pxenv_call.undi_force_interrupt = pxenv_undi_force_interrupt;
2754- param_len = sizeof ( pxenv_any.undi_force_interrupt );
2755- break;
2756- case PXENV_UNDI_GET_MCAST_ADDRESS:
2757- pxenv_call.undi_get_mcast_address =
2758- pxenv_undi_get_mcast_address;
2759- param_len = sizeof ( pxenv_any.undi_get_mcast_address );
2760- break;
2761- case PXENV_UNDI_GET_NIC_TYPE:
2762- pxenv_call.undi_get_nic_type = pxenv_undi_get_nic_type;
2763- param_len = sizeof ( pxenv_any.undi_get_nic_type );
2764- break;
2765- case PXENV_UNDI_GET_IFACE_INFO:
2766- pxenv_call.undi_get_iface_info = pxenv_undi_get_iface_info;
2767- param_len = sizeof ( pxenv_any.undi_get_iface_info );
2768- break;
2769- case PXENV_UNDI_ISR:
2770- pxenv_call.undi_isr = pxenv_undi_isr;
2771- param_len = sizeof ( pxenv_any.undi_isr );
2772- break;
2773- case PXENV_FILE_OPEN:
2774- pxenv_call.file_open = pxenv_file_open;
2775- param_len = sizeof ( pxenv_any.file_open );
2776- break;
2777- case PXENV_FILE_CLOSE:
2778- pxenv_call.file_close = pxenv_file_close;
2779- param_len = sizeof ( pxenv_any.file_close );
2780- break;
2781- case PXENV_FILE_SELECT:
2782- pxenv_call.file_select = pxenv_file_select;
2783- param_len = sizeof ( pxenv_any.file_select );
2784- break;
2785- case PXENV_FILE_READ:
2786- pxenv_call.file_read = pxenv_file_read;
2787- param_len = sizeof ( pxenv_any.file_read );
2788- break;
2789- case PXENV_GET_FILE_SIZE:
2790- pxenv_call.get_file_size = pxenv_get_file_size;
2791- param_len = sizeof ( pxenv_any.get_file_size );
2792- break;
2793- case PXENV_FILE_EXEC:
2794- pxenv_call.file_exec = pxenv_file_exec;
2795- param_len = sizeof ( pxenv_any.file_exec );
2796- break;
2797- case PXENV_FILE_API_CHECK:
2798- pxenv_call.file_api_check = pxenv_file_api_check;
2799- param_len = sizeof ( pxenv_any.file_api_check );
2800- break;
2801- case PXENV_FILE_EXIT_HOOK:
2802- pxenv_call.file_exit_hook = pxenv_file_exit_hook;
2803- param_len = sizeof ( pxenv_any.file_exit_hook );
2804- break;
2805- default:
2806- DBG ( "PXENV_UNKNOWN_%hx", opcode );
2807- pxenv_call.unknown = pxenv_unknown;
2808- param_len = sizeof ( pxenv_any.unknown );
2809- break;
2810+ /* Locate API call */
2811+ call = find_pxe_api_call ( opcode );
2812+ if ( ! call ) {
2813+ DBGC ( &pxe_netdev, "PXENV_UNKNOWN_%04x\n", opcode );
2814+ call = &pxenv_unknown_api;
2815 }
2816
2817 /* Copy parameter block from caller */
2818- copy_from_user ( &pxenv_any, parameters, 0, param_len );
2819+ copy_from_user ( &params, uparams, 0, call->params_len );
2820
2821 /* Set default status in case child routine fails to do so */
2822- pxenv_any.Status = PXENV_STATUS_FAILURE;
2823+ params.Status = PXENV_STATUS_FAILURE;
2824
2825 /* Hand off to relevant API routine */
2826- DBG ( "[" );
2827- ret = pxenv_call.any ( &pxenv_any );
2828- if ( pxenv_any.Status != PXENV_STATUS_SUCCESS ) {
2829- DBG ( " %02x", pxenv_any.Status );
2830- }
2831- if ( ret != PXENV_EXIT_SUCCESS ) {
2832- DBG ( ret == PXENV_EXIT_FAILURE ? " err" : " ??" );
2833- }
2834- DBG ( "]" );
2835-
2836+ ret = call->entry ( &params );
2837+
2838 /* Copy modified parameter block back to caller and return */
2839- copy_to_user ( parameters, 0, &pxenv_any, param_len );
2840+ copy_to_user ( uparams, 0, &params, call->params_len );
2841 ix86->regs.ax = ret;
2842 }
2843
2844@@ -351,8 +114,7 @@
2845 * @v ix86 Registers for PXE call
2846 * @ret present Zero (PXE stack present)
2847 */
2848-int pxe_api_call_weak ( struct i386_all_regs *ix86 )
2849-{
2850+int pxe_api_call_weak ( struct i386_all_regs *ix86 ) {
2851 pxe_api_call ( ix86 );
2852 return 0;
2853 }
2854@@ -519,3 +281,9 @@
2855
2856 return rc;
2857 }
2858+
2859+REQUIRE_OBJECT ( pxe_preboot );
2860+REQUIRE_OBJECT ( pxe_undi );
2861+REQUIRE_OBJECT ( pxe_udp );
2862+REQUIRE_OBJECT ( pxe_tftp );
2863+REQUIRE_OBJECT ( pxe_file );
2864
2865=== added file 'src/arch/i386/interface/pxe/pxe_exit_hook.c'
2866--- src/arch/i386/interface/pxe/pxe_exit_hook.c 1970-01-01 00:00:00 +0000
2867+++ src/arch/i386/interface/pxe/pxe_exit_hook.c 2012-02-10 16:40:50 +0000
2868@@ -0,0 +1,60 @@
2869+/** @file
2870+ *
2871+ * PXE exit hook
2872+ *
2873+ */
2874+
2875+/*
2876+ * Copyright (C) 2010 Shao Miller <shao.miller@yrdsb.edu.on.ca>.
2877+ *
2878+ * This program is free software; you can redistribute it and/or
2879+ * modify it under the terms of the GNU General Public License as
2880+ * published by the Free Software Foundation; either version 2 of the
2881+ * License, or any later version.
2882+ *
2883+ * This program is distributed in the hope that it will be useful, but
2884+ * WITHOUT ANY WARRANTY; without even the implied warranty of
2885+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2886+ * General Public License for more details.
2887+ *
2888+ * You should have received a copy of the GNU General Public License
2889+ * along with this program; if not, write to the Free Software
2890+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2891+ */
2892+
2893+FILE_LICENCE ( GPL2_OR_LATER );
2894+
2895+#include <stdint.h>
2896+#include <realmode.h>
2897+#include <pxe.h>
2898+
2899+/** PXE exit hook */
2900+extern segoff_t __data16 ( pxe_exit_hook );
2901+#define pxe_exit_hook __use_data16 ( pxe_exit_hook )
2902+
2903+/**
2904+ * FILE EXIT HOOK
2905+ *
2906+ * @v file_exit_hook Pointer to a struct
2907+ * s_PXENV_FILE_EXIT_HOOK
2908+ * @v s_PXENV_FILE_EXIT_HOOK::Hook SEG16:OFF16 to jump to
2909+ * @ret #PXENV_EXIT_SUCCESS Successfully set hook
2910+ * @ret #PXENV_EXIT_FAILURE We're not an NBP build
2911+ * @ret s_PXENV_FILE_EXIT_HOOK::Status PXE status code
2912+ *
2913+ */
2914+static PXENV_EXIT_t
2915+pxenv_file_exit_hook ( struct s_PXENV_FILE_EXIT_HOOK *file_exit_hook ) {
2916+ DBG ( "PXENV_FILE_EXIT_HOOK" );
2917+
2918+ /* We'll jump to the specified SEG16:OFF16 during exit */
2919+ pxe_exit_hook.segment = file_exit_hook->Hook.segment;
2920+ pxe_exit_hook.offset = file_exit_hook->Hook.offset;
2921+ file_exit_hook->Status = PXENV_STATUS_SUCCESS;
2922+ return PXENV_EXIT_SUCCESS;
2923+}
2924+
2925+/** PXE file API */
2926+struct pxe_api_call pxe_file_api_exit_hook __pxe_api_call =
2927+ PXE_API_CALL ( PXENV_FILE_EXIT_HOOK, pxenv_file_exit_hook,
2928+ struct s_PXENV_FILE_EXIT_HOOK );
2929
2930=== modified file 'src/arch/i386/interface/pxe/pxe_file.c'
2931--- src/arch/i386/interface/pxe/pxe_file.c 2011-04-11 19:35:36 +0000
2932+++ src/arch/i386/interface/pxe/pxe_file.c 2012-02-10 16:40:50 +0000
2933@@ -16,8 +16,6 @@
2934
2935 /*
2936 * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
2937- * Portions (C) 2010 Shao Miller <shao.miller@yrdsb.edu.on.ca>.
2938- * [PXE exit hook logic]
2939 *
2940 * This program is free software; you can redistribute it and/or
2941 * modify it under the terms of the GNU General Public License as
2942@@ -49,7 +47,7 @@
2943 * @ret s_PXENV_FILE_OPEN::FileHandle Handle of opened file
2944 *
2945 */
2946-PXENV_EXIT_t pxenv_file_open ( struct s_PXENV_FILE_OPEN *file_open ) {
2947+static PXENV_EXIT_t pxenv_file_open ( struct s_PXENV_FILE_OPEN *file_open ) {
2948 userptr_t filename;
2949 size_t filename_len;
2950 int fd;
2951@@ -91,7 +89,7 @@
2952 * @ret s_PXENV_FILE_CLOSE::Status PXE status code
2953 *
2954 */
2955-PXENV_EXIT_t pxenv_file_close ( struct s_PXENV_FILE_CLOSE *file_close ) {
2956+static PXENV_EXIT_t pxenv_file_close ( struct s_PXENV_FILE_CLOSE *file_close ) {
2957
2958 DBG ( "PXENV_FILE_CLOSE %d", file_close->FileHandle );
2959
2960@@ -111,7 +109,8 @@
2961 * @ret s_PXENV_FILE_SELECT::Ready Indication of readiness
2962 *
2963 */
2964-PXENV_EXIT_t pxenv_file_select ( struct s_PXENV_FILE_SELECT *file_select ) {
2965+static PXENV_EXIT_t
2966+pxenv_file_select ( struct s_PXENV_FILE_SELECT *file_select ) {
2967 fd_set fdset;
2968 int ready;
2969
2970@@ -143,7 +142,7 @@
2971 * @ret s_PXENV_FILE_READ::BufferSize Length of data read
2972 *
2973 */
2974-PXENV_EXIT_t pxenv_file_read ( struct s_PXENV_FILE_READ *file_read ) {
2975+static PXENV_EXIT_t pxenv_file_read ( struct s_PXENV_FILE_READ *file_read ) {
2976 userptr_t buffer;
2977 ssize_t len;
2978
2979@@ -176,8 +175,8 @@
2980 * @ret s_PXENV_GET_FILE_SIZE::Status PXE status code
2981 * @ret s_PXENV_GET_FILE_SIZE::FileSize Size of file
2982 */
2983-PXENV_EXIT_t pxenv_get_file_size ( struct s_PXENV_GET_FILE_SIZE
2984- *get_file_size ) {
2985+static PXENV_EXIT_t
2986+pxenv_get_file_size ( struct s_PXENV_GET_FILE_SIZE *get_file_size ) {
2987 ssize_t filesize;
2988
2989 DBG ( "PXENV_GET_FILE_SIZE %d", get_file_size->FileHandle );
2990@@ -205,7 +204,7 @@
2991 * @ret s_PXENV_FILE_EXEC::Status PXE status code
2992 *
2993 */
2994-PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec ) {
2995+static PXENV_EXIT_t pxenv_file_exec ( struct s_PXENV_FILE_EXEC *file_exec ) {
2996 userptr_t command;
2997 size_t command_len;
2998 int rc;
2999@@ -233,9 +232,6 @@
3000 return PXENV_EXIT_SUCCESS;
3001 }
3002
3003-segoff_t __data16 ( pxe_exit_hook ) = { 0, 0 };
3004-#define pxe_exit_hook __use_data16 ( pxe_exit_hook )
3005-
3006 /**
3007 * FILE API CHECK
3008 *
3009@@ -250,57 +246,58 @@
3010 * @ret s_PXENV_FILE_API_CHECK::Flags Reserved
3011 *
3012 */
3013-PXENV_EXIT_t pxenv_file_api_check ( struct s_PXENV_FILE_API_CHECK *file_api_check ) {
3014+static PXENV_EXIT_t
3015+pxenv_file_api_check ( struct s_PXENV_FILE_API_CHECK *file_api_check ) {
3016+ struct pxe_api_call *call;
3017+ unsigned int mask = 0;
3018+ unsigned int offset;
3019+
3020 DBG ( "PXENV_FILE_API_CHECK" );
3021
3022+ /* Check for magic value */
3023 if ( file_api_check->Magic != 0x91d447b2 ) {
3024 file_api_check->Status = PXENV_STATUS_BAD_FUNC;
3025 return PXENV_EXIT_FAILURE;
3026- } else if ( file_api_check->Size <
3027- sizeof(struct s_PXENV_FILE_API_CHECK) ) {
3028+ }
3029+
3030+ /* Check for required parameter size */
3031+ if ( file_api_check->Size < sizeof ( *file_api_check ) ) {
3032 file_api_check->Status = PXENV_STATUS_OUT_OF_RESOURCES;
3033 return PXENV_EXIT_FAILURE;
3034- } else {
3035- file_api_check->Status = PXENV_STATUS_SUCCESS;
3036- file_api_check->Size = sizeof(struct s_PXENV_FILE_API_CHECK);
3037- file_api_check->Magic = 0xe9c17b20;
3038- file_api_check->Provider = 0x45585067; /* "iPXE" */
3039- file_api_check->APIMask = 0x0000007f; /* Functions e0-e6 */
3040- /* Check to see if we have a PXE exit hook */
3041- if ( pxe_exit_hook.segment | pxe_exit_hook.offset )
3042- /* Function e7, also */
3043- file_api_check->APIMask |= 0x00000080;
3044- file_api_check->Flags = 0; /* None defined */
3045- return PXENV_EXIT_SUCCESS;
3046- }
3047-}
3048-
3049-/**
3050- * FILE EXIT HOOK
3051- *
3052- * @v file_exit_hook Pointer to a struct
3053- * s_PXENV_FILE_EXIT_HOOK
3054- * @v s_PXENV_FILE_EXIT_HOOK::Hook SEG16:OFF16 to jump to
3055- * @ret #PXENV_EXIT_SUCCESS Successfully set hook
3056- * @ret #PXENV_EXIT_FAILURE We're not an NBP build
3057- * @ret s_PXENV_FILE_EXIT_HOOK::Status PXE status code
3058- *
3059- */
3060-PXENV_EXIT_t pxenv_file_exit_hook ( struct s_PXENV_FILE_EXIT_HOOK
3061- *file_exit_hook ) {
3062- DBG ( "PXENV_FILE_EXIT_HOOK" );
3063-
3064- /* Check to see if we have a PXE exit hook */
3065- if ( pxe_exit_hook.segment | pxe_exit_hook.offset ) {
3066- /* We'll jump to the specified SEG16:OFF16 during exit */
3067- pxe_exit_hook.segment = file_exit_hook->Hook.segment;
3068- pxe_exit_hook.offset = file_exit_hook->Hook.offset;
3069- file_exit_hook->Status = PXENV_STATUS_SUCCESS;
3070- return PXENV_EXIT_SUCCESS;
3071- }
3072-
3073- DBG ( " not NBP" );
3074- file_exit_hook->Status = PXENV_STATUS_UNSUPPORTED;
3075- return PXENV_EXIT_FAILURE;
3076-}
3077-
3078+ }
3079+
3080+ /* Determine supported calls */
3081+ for_each_table_entry ( call, PXE_API_CALLS ) {
3082+ offset = ( call->opcode - PXENV_FILE_MIN );
3083+ if ( offset <= ( PXENV_FILE_MAX - PXENV_FILE_MIN ) )
3084+ mask |= ( 1 << offset );
3085+ }
3086+
3087+ /* Fill in parameters */
3088+ file_api_check->Size = sizeof ( *file_api_check );
3089+ file_api_check->Magic = 0xe9c17b20;
3090+ file_api_check->Provider = 0x45585067; /* "iPXE" */
3091+ file_api_check->APIMask = mask;
3092+ file_api_check->Flags = 0; /* None defined */
3093+
3094+ file_api_check->Status = PXENV_STATUS_SUCCESS;
3095+ return PXENV_EXIT_SUCCESS;
3096+}
3097+
3098+/** PXE file API */
3099+struct pxe_api_call pxe_file_api[] __pxe_api_call = {
3100+ PXE_API_CALL ( PXENV_FILE_OPEN, pxenv_file_open,
3101+ struct s_PXENV_FILE_OPEN ),
3102+ PXE_API_CALL ( PXENV_FILE_CLOSE, pxenv_file_close,
3103+ struct s_PXENV_FILE_CLOSE ),
3104+ PXE_API_CALL ( PXENV_FILE_SELECT, pxenv_file_select,
3105+ struct s_PXENV_FILE_SELECT ),
3106+ PXE_API_CALL ( PXENV_FILE_READ, pxenv_file_read,
3107+ struct s_PXENV_FILE_READ ),
3108+ PXE_API_CALL ( PXENV_GET_FILE_SIZE, pxenv_get_file_size,
3109+ struct s_PXENV_GET_FILE_SIZE ),
3110+ PXE_API_CALL ( PXENV_FILE_EXEC, pxenv_file_exec,
3111+ struct s_PXENV_FILE_EXEC ),
3112+ PXE_API_CALL ( PXENV_FILE_API_CHECK, pxenv_file_api_check,
3113+ struct s_PXENV_FILE_API_CHECK ),
3114+};
3115
3116=== modified file 'src/arch/i386/interface/pxe/pxe_preboot.c'
3117--- src/arch/i386/interface/pxe/pxe_preboot.c 2011-04-11 19:35:36 +0000
3118+++ src/arch/i386/interface/pxe/pxe_preboot.c 2012-02-10 16:40:50 +0000
3119@@ -89,6 +89,26 @@
3120 [CACHED_INFO_BINL] = { create_fakepxebsack },
3121 };
3122
3123+/**
3124+ * Name PXENV_GET_CACHED_INFO packet type
3125+ *
3126+ * @v packet_type Packet type
3127+ * @ret name Name of packet type
3128+ */
3129+static inline __attribute__ (( always_inline )) const char *
3130+pxenv_get_cached_info_name ( int packet_type ) {
3131+ switch ( packet_type ) {
3132+ case PXENV_PACKET_TYPE_DHCP_DISCOVER:
3133+ return "DHCPDISCOVER";
3134+ case PXENV_PACKET_TYPE_DHCP_ACK:
3135+ return "DHCPACK";
3136+ case PXENV_PACKET_TYPE_CACHED_REPLY:
3137+ return "BINL";
3138+ default:
3139+ return "<INVALID>";
3140+ }
3141+}
3142+
3143 /* The case in which the caller doesn't supply a buffer is really
3144 * awkward to support given that we have multiple sources of options,
3145 * and that we don't actually store the DHCP packets. (We may not
3146@@ -110,8 +130,9 @@
3147 * @ret ...
3148 *
3149 */
3150-PXENV_EXIT_t pxenv_unload_stack ( struct s_PXENV_UNLOAD_STACK *unload_stack ) {
3151- DBG ( "PXENV_UNLOAD_STACK" );
3152+static PXENV_EXIT_t
3153+pxenv_unload_stack ( struct s_PXENV_UNLOAD_STACK *unload_stack ) {
3154+ DBGC ( &pxe_netdev, "PXENV_UNLOAD_STACK\n" );
3155
3156 unload_stack->Status = PXENV_STATUS_SUCCESS;
3157 return PXENV_EXIT_SUCCESS;
3158@@ -121,8 +142,8 @@
3159 *
3160 * Status: working
3161 */
3162-PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
3163- *get_cached_info ) {
3164+static PXENV_EXIT_t
3165+pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO *get_cached_info ) {
3166 struct pxe_dhcp_packet_creator *creator;
3167 union pxe_cached_info *info;
3168 unsigned int idx;
3169@@ -130,15 +151,24 @@
3170 userptr_t buffer;
3171 int rc;
3172
3173- DBG ( "PXENV_GET_CACHED_INFO %d", get_cached_info->PacketType );
3174+ DBGC ( &pxe_netdev, "PXENV_GET_CACHED_INFO %s to %04x:%04x+%x",
3175+ pxenv_get_cached_info_name ( get_cached_info->PacketType ),
3176+ get_cached_info->Buffer.segment,
3177+ get_cached_info->Buffer.offset, get_cached_info->BufferSize );
3178
3179- DBG ( " to %04x:%04x+%x", get_cached_info->Buffer.segment,
3180- get_cached_info->Buffer.offset, get_cached_info->BufferSize );
3181+ /* Sanity check */
3182+ if ( ! pxe_netdev ) {
3183+ DBGC ( &pxe_netdev, "PXENV_GET_CACHED_INFO called with no "
3184+ "network device\n" );
3185+ get_cached_info->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3186+ return PXENV_EXIT_FAILURE;
3187+ }
3188
3189 /* Sanity check */
3190 idx = ( get_cached_info->PacketType - 1 );
3191 if ( idx >= NUM_CACHED_INFOS ) {
3192- DBG ( " bad PacketType" );
3193+ DBGC ( &pxe_netdev, " bad PacketType %d\n",
3194+ get_cached_info->PacketType );
3195 goto err;
3196 }
3197 info = &cached_info[idx];
3198@@ -149,7 +179,8 @@
3199 creator = &pxe_dhcp_packet_creators[idx];
3200 if ( ( rc = creator->create ( pxe_netdev, info,
3201 sizeof ( *info ) ) ) != 0 ) {
3202- DBG ( " failed to build packet" );
3203+ DBGC ( &pxe_netdev, " failed to build packet: %s\n",
3204+ strerror ( rc ) );
3205 goto err;
3206 }
3207 }
3208@@ -184,23 +215,24 @@
3209 get_cached_info->Buffer.segment = rm_ds;
3210 get_cached_info->Buffer.offset = __from_data16 ( info );
3211 get_cached_info->BufferSize = sizeof ( *info );
3212- DBG ( " returning %04x:%04x+%04x['%x']",
3213- get_cached_info->Buffer.segment,
3214- get_cached_info->Buffer.offset,
3215- get_cached_info->BufferSize,
3216- get_cached_info->BufferLimit );
3217+ DBGC ( &pxe_netdev, " using %04x:%04x+%04x['%x']",
3218+ get_cached_info->Buffer.segment,
3219+ get_cached_info->Buffer.offset,
3220+ get_cached_info->BufferSize,
3221+ get_cached_info->BufferLimit );
3222 } else {
3223 /* Copy packet to client buffer */
3224 if ( len > sizeof ( *info ) )
3225 len = sizeof ( *info );
3226 if ( len < sizeof ( *info ) )
3227- DBG ( " buffer may be too short" );
3228+ DBGC ( &pxe_netdev, " buffer may be too short" );
3229 buffer = real_to_user ( get_cached_info->Buffer.segment,
3230 get_cached_info->Buffer.offset );
3231 copy_to_user ( buffer, 0, info, len );
3232 get_cached_info->BufferSize = len;
3233 }
3234
3235+ DBGC ( &pxe_netdev, "\n" );
3236 get_cached_info->Status = PXENV_STATUS_SUCCESS;
3237 return PXENV_EXIT_SUCCESS;
3238
3239@@ -213,11 +245,11 @@
3240 *
3241 * Status: working
3242 */
3243-PXENV_EXIT_t pxenv_restart_tftp ( struct s_PXENV_TFTP_READ_FILE
3244- *restart_tftp ) {
3245+static PXENV_EXIT_t
3246+pxenv_restart_tftp ( struct s_PXENV_TFTP_READ_FILE *restart_tftp ) {
3247 PXENV_EXIT_t tftp_exit;
3248
3249- DBG ( "PXENV_RESTART_TFTP " );
3250+ DBGC ( &pxe_netdev, "PXENV_RESTART_TFTP\n" );
3251
3252 /* Words cannot describe the complete mismatch between the PXE
3253 * specification and any possible version of reality...
3254@@ -236,13 +268,13 @@
3255 *
3256 * Status: working
3257 */
3258-PXENV_EXIT_t pxenv_start_undi ( struct s_PXENV_START_UNDI *start_undi ) {
3259+static PXENV_EXIT_t pxenv_start_undi ( struct s_PXENV_START_UNDI *start_undi ) {
3260 unsigned int bus_type;
3261 unsigned int location;
3262 struct net_device *netdev;
3263
3264- DBG ( "PXENV_START_UNDI %04x:%04x:%04x",
3265- start_undi->AX, start_undi->BX, start_undi->DX );
3266+ DBGC ( &pxe_netdev, "PXENV_START_UNDI %04x:%04x:%04x\n",
3267+ start_undi->AX, start_undi->BX, start_undi->DX );
3268
3269 /* Determine bus type and location. Use a heuristic to decide
3270 * whether we are PCI or ISAPnP
3271@@ -266,11 +298,13 @@
3272 /* Look for a matching net device */
3273 netdev = find_netdev_by_location ( bus_type, location );
3274 if ( ! netdev ) {
3275- DBG ( " no net device found" );
3276+ DBGC ( &pxe_netdev, "PXENV_START_UNDI could not find matching "
3277+ "net device\n" );
3278 start_undi->Status = PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC;
3279 return PXENV_EXIT_FAILURE;
3280 }
3281- DBG ( " using netdev %s", netdev->name );
3282+ DBGC ( &pxe_netdev, "PXENV_START_UNDI found net device %s\n",
3283+ netdev->name );
3284
3285 /* Activate PXE */
3286 pxe_activate ( netdev );
3287@@ -283,8 +317,8 @@
3288 *
3289 * Status: working
3290 */
3291-PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
3292- DBG ( "PXENV_STOP_UNDI" );
3293+static PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
3294+ DBGC ( &pxe_netdev, "PXENV_STOP_UNDI\n" );
3295
3296 /* Deactivate PXE */
3297 pxe_deactivate();
3298@@ -294,8 +328,8 @@
3299
3300 /* Check to see if we still have any hooked interrupts */
3301 if ( hooked_bios_interrupts != 0 ) {
3302- DBG ( "PXENV_STOP_UNDI failed: %d interrupts still hooked\n",
3303- hooked_bios_interrupts );
3304+ DBGC ( &pxe_netdev, "PXENV_STOP_UNDI failed: %d interrupts "
3305+ "still hooked\n", hooked_bios_interrupts );
3306 stop_undi->Status = PXENV_STATUS_KEEP_UNDI;
3307 return PXENV_EXIT_FAILURE;
3308 }
3309@@ -308,8 +342,8 @@
3310 *
3311 * Status: won't implement (requires major structural changes)
3312 */
3313-PXENV_EXIT_t pxenv_start_base ( struct s_PXENV_START_BASE *start_base ) {
3314- DBG ( "PXENV_START_BASE" );
3315+static PXENV_EXIT_t pxenv_start_base ( struct s_PXENV_START_BASE *start_base ) {
3316+ DBGC ( &pxe_netdev, "PXENV_START_BASE\n" );
3317
3318 start_base->Status = PXENV_STATUS_UNSUPPORTED;
3319 return PXENV_EXIT_FAILURE;
3320@@ -319,8 +353,8 @@
3321 *
3322 * Status: working
3323 */
3324-PXENV_EXIT_t pxenv_stop_base ( struct s_PXENV_STOP_BASE *stop_base ) {
3325- DBG ( "PXENV_STOP_BASE" );
3326+static PXENV_EXIT_t pxenv_stop_base ( struct s_PXENV_STOP_BASE *stop_base ) {
3327+ DBGC ( &pxe_netdev, "PXENV_STOP_BASE\n" );
3328
3329 /* The only time we will be called is when the NBP is trying
3330 * to shut down the PXE stack. There's nothing we need to do
3331@@ -330,3 +364,21 @@
3332 stop_base->Status = PXENV_STATUS_SUCCESS;
3333 return PXENV_EXIT_SUCCESS;
3334 }
3335+
3336+/** PXE preboot API */
3337+struct pxe_api_call pxe_preboot_api[] __pxe_api_call = {
3338+ PXE_API_CALL ( PXENV_UNLOAD_STACK, pxenv_unload_stack,
3339+ struct s_PXENV_UNLOAD_STACK ),
3340+ PXE_API_CALL ( PXENV_GET_CACHED_INFO, pxenv_get_cached_info,
3341+ struct s_PXENV_GET_CACHED_INFO ),
3342+ PXE_API_CALL ( PXENV_RESTART_TFTP, pxenv_restart_tftp,
3343+ struct s_PXENV_TFTP_READ_FILE ),
3344+ PXE_API_CALL ( PXENV_START_UNDI, pxenv_start_undi,
3345+ struct s_PXENV_START_UNDI ),
3346+ PXE_API_CALL ( PXENV_STOP_UNDI, pxenv_stop_undi,
3347+ struct s_PXENV_STOP_UNDI ),
3348+ PXE_API_CALL ( PXENV_START_BASE, pxenv_start_base,
3349+ struct s_PXENV_START_BASE ),
3350+ PXE_API_CALL ( PXENV_STOP_BASE, pxenv_stop_base,
3351+ struct s_PXENV_STOP_BASE ),
3352+};
3353
3354=== modified file 'src/arch/i386/interface/pxe/pxe_tftp.c'
3355--- src/arch/i386/interface/pxe/pxe_tftp.c 2011-04-11 19:35:36 +0000
3356+++ src/arch/i386/interface/pxe/pxe_tftp.c 2012-02-10 16:40:50 +0000
3357@@ -233,7 +233,7 @@
3358 * view of the PXE API, it is conceptually impossible to issue any
3359 * other PXE API call "if an MTFTP connection is active".
3360 */
3361-PXENV_EXIT_t pxenv_tftp_open ( struct s_PXENV_TFTP_OPEN *tftp_open ) {
3362+static PXENV_EXIT_t pxenv_tftp_open ( struct s_PXENV_TFTP_OPEN *tftp_open ) {
3363 int rc;
3364
3365 DBG ( "PXENV_TFTP_OPEN" );
3366@@ -285,7 +285,7 @@
3367 * call this function with a 32-bit stack segment. (See the relevant
3368 * @ref pxe_x86_pmode16 "implementation note" for more details.)
3369 */
3370-PXENV_EXIT_t pxenv_tftp_close ( struct s_PXENV_TFTP_CLOSE *tftp_close ) {
3371+static PXENV_EXIT_t pxenv_tftp_close ( struct s_PXENV_TFTP_CLOSE *tftp_close ) {
3372 DBG ( "PXENV_TFTP_CLOSE" );
3373
3374 pxe_tftp_close ( &pxe_tftp, 0 );
3375@@ -354,7 +354,7 @@
3376 * call this function with a 32-bit stack segment. (See the relevant
3377 * @ref pxe_x86_pmode16 "implementation note" for more details.)
3378 */
3379-PXENV_EXIT_t pxenv_tftp_read ( struct s_PXENV_TFTP_READ *tftp_read ) {
3380+static PXENV_EXIT_t pxenv_tftp_read ( struct s_PXENV_TFTP_READ *tftp_read ) {
3381 int rc;
3382
3383 DBG ( "PXENV_TFTP_READ to %04x:%04x",
3384@@ -531,8 +531,8 @@
3385 * a file from a TFTP server listening on the standard TFTP port.
3386 * "Consistency" is not a word in Intel's vocabulary.
3387 */
3388-PXENV_EXIT_t pxenv_tftp_get_fsize ( struct s_PXENV_TFTP_GET_FSIZE
3389- *tftp_get_fsize ) {
3390+static PXENV_EXIT_t pxenv_tftp_get_fsize ( struct s_PXENV_TFTP_GET_FSIZE
3391+ *tftp_get_fsize ) {
3392 int rc;
3393
3394 DBG ( "PXENV_TFTP_GET_FSIZE" );
3395@@ -562,3 +562,17 @@
3396 tftp_get_fsize->Status = PXENV_STATUS ( rc );
3397 return ( rc ? PXENV_EXIT_FAILURE : PXENV_EXIT_SUCCESS );
3398 }
3399+
3400+/** PXE TFTP API */
3401+struct pxe_api_call pxe_tftp_api[] __pxe_api_call = {
3402+ PXE_API_CALL ( PXENV_TFTP_OPEN, pxenv_tftp_open,
3403+ struct s_PXENV_TFTP_OPEN ),
3404+ PXE_API_CALL ( PXENV_TFTP_CLOSE, pxenv_tftp_close,
3405+ struct s_PXENV_TFTP_CLOSE ),
3406+ PXE_API_CALL ( PXENV_TFTP_READ, pxenv_tftp_read,
3407+ struct s_PXENV_TFTP_READ ),
3408+ PXE_API_CALL ( PXENV_TFTP_READ_FILE, pxenv_tftp_read_file,
3409+ struct s_PXENV_TFTP_READ_FILE ),
3410+ PXE_API_CALL ( PXENV_TFTP_GET_FSIZE, pxenv_tftp_get_fsize,
3411+ struct s_PXENV_TFTP_GET_FSIZE ),
3412+};
3413
3414=== modified file 'src/arch/i386/interface/pxe/pxe_udp.c'
3415--- src/arch/i386/interface/pxe/pxe_udp.c 2011-04-11 19:35:36 +0000
3416+++ src/arch/i386/interface/pxe/pxe_udp.c 2012-02-10 16:40:50 +0000
3417@@ -159,7 +159,7 @@
3418 * parameter.
3419 *
3420 */
3421-PXENV_EXIT_t pxenv_udp_open ( struct s_PXENV_UDP_OPEN *pxenv_udp_open ) {
3422+static PXENV_EXIT_t pxenv_udp_open ( struct s_PXENV_UDP_OPEN *pxenv_udp_open ) {
3423 int rc;
3424
3425 DBG ( "PXENV_UDP_OPEN" );
3426@@ -202,7 +202,8 @@
3427 * @ref pxe_x86_pmode16 "implementation note" for more details.)
3428 *
3429 */
3430-PXENV_EXIT_t pxenv_udp_close ( struct s_PXENV_UDP_CLOSE *pxenv_udp_close ) {
3431+static PXENV_EXIT_t
3432+pxenv_udp_close ( struct s_PXENV_UDP_CLOSE *pxenv_udp_close ) {
3433 DBG ( "PXENV_UDP_CLOSE\n" );
3434
3435 /* Close UDP connection */
3436@@ -253,7 +254,8 @@
3437 * parameter.
3438 *
3439 */
3440-PXENV_EXIT_t pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) {
3441+static PXENV_EXIT_t
3442+pxenv_udp_write ( struct s_PXENV_UDP_WRITE *pxenv_udp_write ) {
3443 struct sockaddr_in dest;
3444 struct xfer_metadata meta = {
3445 .src = ( struct sockaddr * ) &pxe_udp.local,
3446@@ -359,7 +361,7 @@
3447 * expects us to do so, and will fail if we don't.
3448 *
3449 */
3450-PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) {
3451+static PXENV_EXIT_t pxenv_udp_read ( struct s_PXENV_UDP_READ *pxenv_udp_read ) {
3452 struct in_addr dest_ip_wanted = { .s_addr = pxenv_udp_read->dest_ip };
3453 struct in_addr dest_ip;
3454 uint16_t d_port_wanted = pxenv_udp_read->d_port;
3455@@ -405,3 +407,15 @@
3456 pxenv_udp_read->Status = PXENV_STATUS_FAILURE;
3457 return PXENV_EXIT_FAILURE;
3458 }
3459+
3460+/** PXE UDP API */
3461+struct pxe_api_call pxe_udp_api[] __pxe_api_call = {
3462+ PXE_API_CALL ( PXENV_UDP_OPEN, pxenv_udp_open,
3463+ struct s_PXENV_UDP_OPEN ),
3464+ PXE_API_CALL ( PXENV_UDP_CLOSE, pxenv_udp_close,
3465+ struct s_PXENV_UDP_CLOSE ),
3466+ PXE_API_CALL ( PXENV_UDP_WRITE, pxenv_udp_write,
3467+ struct s_PXENV_UDP_WRITE ),
3468+ PXE_API_CALL ( PXENV_UDP_READ, pxenv_udp_read,
3469+ struct s_PXENV_UDP_READ ),
3470+};
3471
3472=== modified file 'src/arch/i386/interface/pxe/pxe_undi.c'
3473--- src/arch/i386/interface/pxe/pxe_undi.c 2011-07-31 20:57:02 +0000
3474+++ src/arch/i386/interface/pxe/pxe_undi.c 2012-02-10 16:40:50 +0000
3475@@ -58,11 +58,14 @@
3476 * @v netdev Network device, or NULL
3477 */
3478 void pxe_set_netdev ( struct net_device *netdev ) {
3479+
3480 if ( pxe_netdev ) {
3481 netdev_rx_unfreeze ( pxe_netdev );
3482 netdev_put ( pxe_netdev );
3483 }
3484+
3485 pxe_netdev = NULL;
3486+
3487 if ( netdev )
3488 pxe_netdev = netdev_get ( netdev );
3489 }
3490@@ -75,11 +78,14 @@
3491 static int pxe_netdev_open ( void ) {
3492 int rc;
3493
3494+ assert ( pxe_netdev != NULL );
3495+
3496 if ( ( rc = netdev_open ( pxe_netdev ) ) != 0 )
3497 return rc;
3498
3499 netdev_rx_freeze ( pxe_netdev );
3500 netdev_irq ( pxe_netdev, 1 );
3501+
3502 return 0;
3503 }
3504
3505@@ -88,6 +94,8 @@
3506 *
3507 */
3508 static void pxe_netdev_close ( void ) {
3509+
3510+ assert ( pxe_netdev != NULL );
3511 netdev_rx_unfreeze ( pxe_netdev );
3512 netdev_irq ( pxe_netdev, 0 );
3513 netdev_close ( pxe_netdev );
3514@@ -104,7 +112,8 @@
3515 unsigned int i;
3516
3517 for ( i = 0 ; i < mcast->MCastAddrCount ; i++ ) {
3518- DBG ( " %s", ll_protocol->ntoa ( mcast->McastAddr[i] ) );
3519+ DBGC ( &pxe_netdev, " %s",
3520+ ll_protocol->ntoa ( mcast->McastAddr[i] ) );
3521 }
3522 }
3523
3524@@ -112,8 +121,17 @@
3525 *
3526 * Status: working
3527 */
3528-PXENV_EXIT_t pxenv_undi_startup ( struct s_PXENV_UNDI_STARTUP *undi_startup ) {
3529- DBG ( "PXENV_UNDI_STARTUP\n" );
3530+static PXENV_EXIT_t
3531+pxenv_undi_startup ( struct s_PXENV_UNDI_STARTUP *undi_startup ) {
3532+ DBGC ( &pxe_netdev, "PXENV_UNDI_STARTUP\n" );
3533+
3534+ /* Sanity check */
3535+ if ( ! pxe_netdev ) {
3536+ DBGC ( &pxe_netdev, "PXENV_UNDI_STARTUP called with no "
3537+ "network device\n" );
3538+ undi_startup->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3539+ return PXENV_EXIT_FAILURE;
3540+ }
3541
3542 undi_startup->Status = PXENV_STATUS_SUCCESS;
3543 return PXENV_EXIT_SUCCESS;
3544@@ -123,9 +141,19 @@
3545 *
3546 * Status: working
3547 */
3548-PXENV_EXIT_t pxenv_undi_cleanup ( struct s_PXENV_UNDI_CLEANUP *undi_cleanup ) {
3549- DBG ( "PXENV_UNDI_CLEANUP\n" );
3550-
3551+static PXENV_EXIT_t
3552+pxenv_undi_cleanup ( struct s_PXENV_UNDI_CLEANUP *undi_cleanup ) {
3553+ DBGC ( &pxe_netdev, "PXENV_UNDI_CLEANUP\n" );
3554+
3555+ /* Sanity check */
3556+ if ( ! pxe_netdev ) {
3557+ DBGC ( &pxe_netdev, "PXENV_UNDI_CLEANUP called with no "
3558+ "network device\n" );
3559+ undi_cleanup->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3560+ return PXENV_EXIT_FAILURE;
3561+ }
3562+
3563+ /* Close network device */
3564 pxe_netdev_close();
3565
3566 undi_cleanup->Status = PXENV_STATUS_SUCCESS;
3567@@ -136,10 +164,18 @@
3568 *
3569 * Status: working
3570 */
3571-PXENV_EXIT_t pxenv_undi_initialize ( struct s_PXENV_UNDI_INITIALIZE
3572- *undi_initialize ) {
3573- DBG ( "PXENV_UNDI_INITIALIZE protocolini %08x\n",
3574- undi_initialize->ProtocolIni );
3575+static PXENV_EXIT_t
3576+pxenv_undi_initialize ( struct s_PXENV_UNDI_INITIALIZE *undi_initialize ) {
3577+ DBGC ( &pxe_netdev, "PXENV_UNDI_INITIALIZE protocolini %08x\n",
3578+ undi_initialize->ProtocolIni );
3579+
3580+ /* Sanity check */
3581+ if ( ! pxe_netdev ) {
3582+ DBGC ( &pxe_netdev, "PXENV_UNDI_INITIALIZE called with no "
3583+ "network device\n" );
3584+ undi_initialize->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3585+ return PXENV_EXIT_FAILURE;
3586+ }
3587
3588 undi_initialize->Status = PXENV_STATUS_SUCCESS;
3589 return PXENV_EXIT_SUCCESS;
3590@@ -149,18 +185,27 @@
3591 *
3592 * Status: working
3593 */
3594-PXENV_EXIT_t pxenv_undi_reset_adapter ( struct s_PXENV_UNDI_RESET
3595- *undi_reset_adapter ) {
3596+static PXENV_EXIT_t
3597+pxenv_undi_reset_adapter ( struct s_PXENV_UNDI_RESET *undi_reset_adapter ) {
3598 int rc;
3599
3600- DBG ( "PXENV_UNDI_RESET_ADAPTER" );
3601+ DBGC ( &pxe_netdev, "PXENV_UNDI_RESET_ADAPTER" );
3602 pxe_dump_mcast_list ( &undi_reset_adapter->R_Mcast_Buf );
3603- DBG ( "\n" );
3604-
3605+ DBGC ( &pxe_netdev, "\n" );
3606+
3607+ /* Sanity check */
3608+ if ( ! pxe_netdev ) {
3609+ DBGC ( &pxe_netdev, "PXENV_UNDI_RESET_ADAPTER called with no "
3610+ "network device\n" );
3611+ undi_reset_adapter->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3612+ return PXENV_EXIT_FAILURE;
3613+ }
3614+
3615+ /* Close and reopen network device */
3616 pxe_netdev_close();
3617 if ( ( rc = pxe_netdev_open() ) != 0 ) {
3618- DBG ( "PXENV_UNDI_RESET_ADAPTER could not reopen %s: %s\n",
3619- pxe_netdev->name, strerror ( rc ) );
3620+ DBGC ( &pxe_netdev, "PXENV_UNDI_RESET_ADAPTER could not "
3621+ "reopen %s: %s\n", pxe_netdev->name, strerror ( rc ) );
3622 undi_reset_adapter->Status = PXENV_STATUS ( rc );
3623 return PXENV_EXIT_FAILURE;
3624 }
3625@@ -173,10 +218,19 @@
3626 *
3627 * Status: working
3628 */
3629-PXENV_EXIT_t pxenv_undi_shutdown ( struct s_PXENV_UNDI_SHUTDOWN
3630- *undi_shutdown ) {
3631- DBG ( "PXENV_UNDI_SHUTDOWN\n" );
3632-
3633+static PXENV_EXIT_t
3634+pxenv_undi_shutdown ( struct s_PXENV_UNDI_SHUTDOWN *undi_shutdown ) {
3635+ DBGC ( &pxe_netdev, "PXENV_UNDI_SHUTDOWN\n" );
3636+
3637+ /* Sanity check */
3638+ if ( ! pxe_netdev ) {
3639+ DBGC ( &pxe_netdev, "PXENV_UNDI_SHUTDOWN called with no "
3640+ "network device\n" );
3641+ undi_shutdown->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3642+ return PXENV_EXIT_FAILURE;
3643+ }
3644+
3645+ /* Close network device */
3646 pxe_netdev_close();
3647
3648 undi_shutdown->Status = PXENV_STATUS_SUCCESS;
3649@@ -187,17 +241,26 @@
3650 *
3651 * Status: working
3652 */
3653-PXENV_EXIT_t pxenv_undi_open ( struct s_PXENV_UNDI_OPEN *undi_open ) {
3654+static PXENV_EXIT_t pxenv_undi_open ( struct s_PXENV_UNDI_OPEN *undi_open ) {
3655 int rc;
3656
3657- DBG ( "PXENV_UNDI_OPEN flag %04x filter %04x",
3658- undi_open->OpenFlag, undi_open->PktFilter );
3659+ DBGC ( &pxe_netdev, "PXENV_UNDI_OPEN flag %04x filter %04x",
3660+ undi_open->OpenFlag, undi_open->PktFilter );
3661 pxe_dump_mcast_list ( &undi_open->R_Mcast_Buf );
3662- DBG ( "\n" );
3663-
3664+ DBGC ( &pxe_netdev, "\n" );
3665+
3666+ /* Sanity check */
3667+ if ( ! pxe_netdev ) {
3668+ DBGC ( &pxe_netdev, "PXENV_UNDI_OPEN called with no "
3669+ "network device\n" );
3670+ undi_open->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3671+ return PXENV_EXIT_FAILURE;
3672+ }
3673+
3674+ /* Open network device */
3675 if ( ( rc = pxe_netdev_open() ) != 0 ) {
3676- DBG ( "PXENV_UNDI_OPEN could not open %s: %s\n",
3677- pxe_netdev->name, strerror ( rc ) );
3678+ DBGC ( &pxe_netdev, "PXENV_UNDI_OPEN could not open %s: %s\n",
3679+ pxe_netdev->name, strerror ( rc ) );
3680 undi_open->Status = PXENV_STATUS ( rc );
3681 return PXENV_EXIT_FAILURE;
3682 }
3683@@ -210,9 +273,18 @@
3684 *
3685 * Status: working
3686 */
3687-PXENV_EXIT_t pxenv_undi_close ( struct s_PXENV_UNDI_CLOSE *undi_close ) {
3688- DBG ( "PXENV_UNDI_CLOSE\n" );
3689-
3690+static PXENV_EXIT_t pxenv_undi_close ( struct s_PXENV_UNDI_CLOSE *undi_close ) {
3691+ DBGC ( &pxe_netdev, "PXENV_UNDI_CLOSE\n" );
3692+
3693+ /* Sanity check */
3694+ if ( ! pxe_netdev ) {
3695+ DBGC ( &pxe_netdev, "PXENV_UNDI_CLOSE called with no "
3696+ "network device\n" );
3697+ undi_close->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3698+ return PXENV_EXIT_FAILURE;
3699+ }
3700+
3701+ /* Close network device */
3702 pxe_netdev_close();
3703
3704 undi_close->Status = PXENV_STATUS_SUCCESS;
3705@@ -223,20 +295,28 @@
3706 *
3707 * Status: working
3708 */
3709-PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
3710- *undi_transmit ) {
3711+static PXENV_EXIT_t
3712+pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT *undi_transmit ) {
3713 struct s_PXENV_UNDI_TBD tbd;
3714 struct DataBlk *datablk;
3715 struct io_buffer *iobuf;
3716 struct net_protocol *net_protocol;
3717- struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
3718+ struct ll_protocol *ll_protocol;
3719 char destaddr[MAX_LL_ADDR_LEN];
3720 const void *ll_dest;
3721 size_t len;
3722 unsigned int i;
3723 int rc;
3724
3725- DBG2 ( "PXENV_UNDI_TRANSMIT" );
3726+ /* Sanity check */
3727+ if ( ! pxe_netdev ) {
3728+ DBGC ( &pxe_netdev, "PXENV_UNDI_TRANSMIT called with no "
3729+ "network device\n" );
3730+ undi_transmit->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3731+ return PXENV_EXIT_FAILURE;
3732+ }
3733+
3734+ DBGC2 ( &pxe_netdev, "PXENV_UNDI_TRANSMIT" );
3735
3736 /* Forcibly enable interrupts and freeze receive queue
3737 * processing at this point, to work around callers that never
3738@@ -254,29 +334,32 @@
3739 net_protocol = NULL;
3740 break;
3741 default:
3742- DBG2 ( " %02x invalid protocol\n", undi_transmit->Protocol );
3743+ DBGC2 ( &pxe_netdev, " %02x invalid protocol\n",
3744+ undi_transmit->Protocol );
3745 undi_transmit->Status = PXENV_STATUS_UNDI_INVALID_PARAMETER;
3746 return PXENV_EXIT_FAILURE;
3747 }
3748- DBG2 ( " %s", ( net_protocol ? net_protocol->name : "RAW" ) );
3749+ DBGC2 ( &pxe_netdev, " %s",
3750+ ( net_protocol ? net_protocol->name : "RAW" ) );
3751
3752 /* Calculate total packet length */
3753 copy_from_real ( &tbd, undi_transmit->TBD.segment,
3754 undi_transmit->TBD.offset, sizeof ( tbd ) );
3755 len = tbd.ImmedLength;
3756- DBG2 ( " %04x:%04x+%x", tbd.Xmit.segment, tbd.Xmit.offset,
3757- tbd.ImmedLength );
3758+ DBGC2 ( &pxe_netdev, " %04x:%04x+%x", tbd.Xmit.segment, tbd.Xmit.offset,
3759+ tbd.ImmedLength );
3760 for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {
3761 datablk = &tbd.DataBlock[i];
3762 len += datablk->TDDataLen;
3763- DBG2 ( " %04x:%04x+%x", datablk->TDDataPtr.segment,
3764- datablk->TDDataPtr.offset, datablk->TDDataLen );
3765+ DBGC2 ( &pxe_netdev, " %04x:%04x+%x",
3766+ datablk->TDDataPtr.segment, datablk->TDDataPtr.offset,
3767+ datablk->TDDataLen );
3768 }
3769
3770 /* Allocate and fill I/O buffer */
3771 iobuf = alloc_iob ( MAX_LL_HEADER_LEN + len );
3772 if ( ! iobuf ) {
3773- DBG2 ( " could not allocate iobuf\n" );
3774+ DBGC2 ( &pxe_netdev, " could not allocate iobuf\n" );
3775 undi_transmit->Status = PXENV_STATUS_OUT_OF_RESOURCES;
3776 return PXENV_EXIT_FAILURE;
3777 }
3778@@ -295,24 +378,26 @@
3779 if ( net_protocol != NULL ) {
3780
3781 /* Calculate destination address */
3782+ ll_protocol = pxe_netdev->ll_protocol;
3783 if ( undi_transmit->XmitFlag == XMT_DESTADDR ) {
3784 copy_from_real ( destaddr,
3785 undi_transmit->DestAddr.segment,
3786 undi_transmit->DestAddr.offset,
3787 ll_protocol->ll_addr_len );
3788 ll_dest = destaddr;
3789- DBG2 ( " DEST %s", ll_protocol->ntoa ( ll_dest ) );
3790+ DBGC2 ( &pxe_netdev, " DEST %s",
3791+ ll_protocol->ntoa ( ll_dest ) );
3792 } else {
3793 ll_dest = pxe_netdev->ll_broadcast;
3794- DBG2 ( " BCAST" );
3795+ DBGC2 ( &pxe_netdev, " BCAST" );
3796 }
3797
3798 /* Add link-layer header */
3799 if ( ( rc = ll_protocol->push ( pxe_netdev, iobuf, ll_dest,
3800 pxe_netdev->ll_addr,
3801 net_protocol->net_proto ))!=0){
3802- DBG2 ( " could not add link-layer header: %s\n",
3803- strerror ( rc ) );
3804+ DBGC2 ( &pxe_netdev, " could not add link-layer "
3805+ "header: %s\n", strerror ( rc ) );
3806 free_iob ( iobuf );
3807 undi_transmit->Status = PXENV_STATUS ( rc );
3808 return PXENV_EXIT_FAILURE;
3809@@ -326,10 +411,10 @@
3810 undi_tx_count++;
3811
3812 /* Transmit packet */
3813- DBG2 ( "\n" );
3814+ DBGC2 ( &pxe_netdev, "\n" );
3815 if ( ( rc = netdev_tx ( pxe_netdev, iobuf ) ) != 0 ) {
3816- DBG2 ( "PXENV_UNDI_TRANSMIT could not transmit: %s\n",
3817- strerror ( rc ) );
3818+ DBGC2 ( &pxe_netdev, "PXENV_UNDI_TRANSMIT could not transmit: "
3819+ "%s\n", strerror ( rc ) );
3820 undi_tx_count--;
3821 undi_transmit->Status = PXENV_STATUS ( rc );
3822 return PXENV_EXIT_FAILURE;
3823@@ -343,12 +428,21 @@
3824 *
3825 * Status: working (for NICs that support receive-all-multicast)
3826 */
3827-PXENV_EXIT_t
3828+static PXENV_EXIT_t
3829 pxenv_undi_set_mcast_address ( struct s_PXENV_UNDI_SET_MCAST_ADDRESS
3830 *undi_set_mcast_address ) {
3831- DBG ( "PXENV_UNDI_SET_MCAST_ADDRESS" );
3832+ DBGC ( &pxe_netdev, "PXENV_UNDI_SET_MCAST_ADDRESS" );
3833 pxe_dump_mcast_list ( &undi_set_mcast_address->R_Mcast_Buf );
3834- DBG ( "\n" );
3835+ DBGC ( &pxe_netdev, "\n" );
3836+
3837+ /* Sanity check */
3838+ if ( ! pxe_netdev ) {
3839+ DBGC ( &pxe_netdev, "PXENV_UNDI_SET_MCAST_ADDRESS called with "
3840+ "no network device\n" );
3841+ undi_set_mcast_address->Status =
3842+ PXENV_STATUS_UNDI_INVALID_STATE;
3843+ return PXENV_EXIT_FAILURE;
3844+ }
3845
3846 undi_set_mcast_address->Status = PXENV_STATUS_SUCCESS;
3847 return PXENV_EXIT_SUCCESS;
3848@@ -358,19 +452,29 @@
3849 *
3850 * Status: working
3851 */
3852-PXENV_EXIT_t
3853+static PXENV_EXIT_t
3854 pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
3855 *undi_set_station_address ) {
3856- struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
3857-
3858- DBG ( "PXENV_UNDI_SET_STATION_ADDRESS %s",
3859- ll_protocol->ntoa ( undi_set_station_address->StationAddress ) );
3860+ struct ll_protocol *ll_protocol;
3861+
3862+ /* Sanity check */
3863+ if ( ! pxe_netdev ) {
3864+ DBGC ( &pxe_netdev, "PXENV_UNDI_SET_STATION_ADDRESS called "
3865+ "with no network device\n" );
3866+ undi_set_station_address->Status =
3867+ PXENV_STATUS_UNDI_INVALID_STATE;
3868+ return PXENV_EXIT_FAILURE;
3869+ }
3870+
3871+ ll_protocol = pxe_netdev->ll_protocol;
3872+ DBGC ( &pxe_netdev, "PXENV_UNDI_SET_STATION_ADDRESS %s",
3873+ ll_protocol->ntoa ( undi_set_station_address->StationAddress ) );
3874
3875 /* If adapter is open, the change will have no effect; return
3876 * an error
3877 */
3878 if ( netdev_is_open ( pxe_netdev ) ) {
3879- DBG ( " failed: netdev is open\n" );
3880+ DBGC ( &pxe_netdev, " failed: netdev is open\n" );
3881 undi_set_station_address->Status =
3882 PXENV_STATUS_UNDI_INVALID_STATE;
3883 return PXENV_EXIT_FAILURE;
3884@@ -381,7 +485,7 @@
3885 &undi_set_station_address->StationAddress,
3886 ll_protocol->ll_addr_len );
3887
3888- DBG ( "\n" );
3889+ DBGC ( &pxe_netdev, "\n" );
3890 undi_set_station_address->Status = PXENV_STATUS_SUCCESS;
3891 return PXENV_EXIT_SUCCESS;
3892 }
3893@@ -391,12 +495,21 @@
3894 * Status: won't implement (would require driver API changes for no
3895 * real benefit)
3896 */
3897-PXENV_EXIT_t
3898+static PXENV_EXIT_t
3899 pxenv_undi_set_packet_filter ( struct s_PXENV_UNDI_SET_PACKET_FILTER
3900 *undi_set_packet_filter ) {
3901
3902- DBG ( "PXENV_UNDI_SET_PACKET_FILTER %02x\n",
3903- undi_set_packet_filter->filter );
3904+ DBGC ( &pxe_netdev, "PXENV_UNDI_SET_PACKET_FILTER %02x\n",
3905+ undi_set_packet_filter->filter );
3906+
3907+ /* Sanity check */
3908+ if ( ! pxe_netdev ) {
3909+ DBGC ( &pxe_netdev, "PXENV_UNDI_SET_PACKET_FILTER called with "
3910+ "no network device\n" );
3911+ undi_set_packet_filter->Status =
3912+ PXENV_STATUS_UNDI_INVALID_STATE;
3913+ return PXENV_EXIT_FAILURE;
3914+ }
3915
3916 /* Pretend that we succeeded, otherwise the 3Com DOS UNDI
3917 * driver refuses to load. (We ignore the filter value in the
3918@@ -411,22 +524,33 @@
3919 *
3920 * Status: working
3921 */
3922-PXENV_EXIT_t pxenv_undi_get_information ( struct s_PXENV_UNDI_GET_INFORMATION
3923- *undi_get_information ) {
3924- struct device *dev = pxe_netdev->dev;
3925- struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
3926- size_t ll_addr_len = ll_protocol->ll_addr_len;
3927-
3928- DBG ( "PXENV_UNDI_GET_INFORMATION" );
3929-
3930+static PXENV_EXIT_t
3931+pxenv_undi_get_information ( struct s_PXENV_UNDI_GET_INFORMATION
3932+ *undi_get_information ) {
3933+ struct device *dev;
3934+ struct ll_protocol *ll_protocol;
3935+
3936+ /* Sanity check */
3937+ if ( ! pxe_netdev ) {
3938+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_INFORMATION called with no "
3939+ "network device\n" );
3940+ undi_get_information->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3941+ return PXENV_EXIT_FAILURE;
3942+ }
3943+
3944+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_INFORMATION" );
3945+
3946+ /* Fill in information */
3947+ dev = pxe_netdev->dev;
3948+ ll_protocol = pxe_netdev->ll_protocol;
3949 undi_get_information->BaseIo = dev->desc.ioaddr;
3950 undi_get_information->IntNumber =
3951 ( netdev_irq_supported ( pxe_netdev ) ? dev->desc.irq : 0 );
3952 /* Cheat: assume all cards can cope with this */
3953 undi_get_information->MaxTranUnit = ETH_MAX_MTU;
3954 undi_get_information->HwType = ntohs ( ll_protocol->ll_proto );
3955- undi_get_information->HwAddrLen = ll_addr_len;
3956- assert ( ll_addr_len <=
3957+ undi_get_information->HwAddrLen = ll_protocol->ll_addr_len;
3958+ assert ( ll_protocol->ll_addr_len <=
3959 sizeof ( undi_get_information->CurrentNodeAddress ) );
3960 memcpy ( &undi_get_information->CurrentNodeAddress,
3961 pxe_netdev->ll_addr,
3962@@ -441,10 +565,10 @@
3963 undi_get_information->RxBufCt = 1;
3964 undi_get_information->TxBufCt = 1;
3965
3966- DBG ( " io %04x irq %d mtu %d %s %s\n",
3967- undi_get_information->BaseIo, undi_get_information->IntNumber,
3968- undi_get_information->MaxTranUnit, ll_protocol->name,
3969- ll_protocol->ntoa ( &undi_get_information->CurrentNodeAddress ));
3970+ DBGC ( &pxe_netdev, " io %04x irq %d mtu %d %s %s\n",
3971+ undi_get_information->BaseIo, undi_get_information->IntNumber,
3972+ undi_get_information->MaxTranUnit, ll_protocol->name,
3973+ ll_protocol->ntoa ( &undi_get_information->CurrentNodeAddress ));
3974 undi_get_information->Status = PXENV_STATUS_SUCCESS;
3975 return PXENV_EXIT_SUCCESS;
3976 }
3977@@ -453,20 +577,31 @@
3978 *
3979 * Status: working
3980 */
3981-PXENV_EXIT_t pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
3982- *undi_get_statistics ) {
3983- DBG ( "PXENV_UNDI_GET_STATISTICS" );
3984-
3985+static PXENV_EXIT_t
3986+pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
3987+ *undi_get_statistics ) {
3988+
3989+ /* Sanity check */
3990+ if ( ! pxe_netdev ) {
3991+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_STATISTICS called with no "
3992+ "network device\n" );
3993+ undi_get_statistics->Status = PXENV_STATUS_UNDI_INVALID_STATE;
3994+ return PXENV_EXIT_FAILURE;
3995+ }
3996+
3997+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_STATISTICS" );
3998+
3999+ /* Report statistics */
4000 undi_get_statistics->XmtGoodFrames = pxe_netdev->tx_stats.good;
4001 undi_get_statistics->RcvGoodFrames = pxe_netdev->rx_stats.good;
4002 undi_get_statistics->RcvCRCErrors = pxe_netdev->rx_stats.bad;
4003 undi_get_statistics->RcvResourceErrors = pxe_netdev->rx_stats.bad;
4004+ DBGC ( &pxe_netdev, " txok %d rxok %d rxcrc %d rxrsrc %d\n",
4005+ undi_get_statistics->XmtGoodFrames,
4006+ undi_get_statistics->RcvGoodFrames,
4007+ undi_get_statistics->RcvCRCErrors,
4008+ undi_get_statistics->RcvResourceErrors );
4009
4010- DBG ( " txok %d rxok %d rxcrc %d rxrsrc %d\n",
4011- undi_get_statistics->XmtGoodFrames,
4012- undi_get_statistics->RcvGoodFrames,
4013- undi_get_statistics->RcvCRCErrors,
4014- undi_get_statistics->RcvResourceErrors );
4015 undi_get_statistics->Status = PXENV_STATUS_SUCCESS;
4016 return PXENV_EXIT_SUCCESS;
4017 }
4018@@ -475,10 +610,20 @@
4019 *
4020 * Status: working
4021 */
4022-PXENV_EXIT_t pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
4023- *undi_clear_statistics ) {
4024- DBG ( "PXENV_UNDI_CLEAR_STATISTICS\n" );
4025-
4026+static PXENV_EXIT_t
4027+pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
4028+ *undi_clear_statistics ) {
4029+ DBGC ( &pxe_netdev, "PXENV_UNDI_CLEAR_STATISTICS\n" );
4030+
4031+ /* Sanity check */
4032+ if ( ! pxe_netdev ) {
4033+ DBGC ( &pxe_netdev, "PXENV_UNDI_CLEAR_STATISTICS called with "
4034+ "no network device\n" );
4035+ undi_clear_statistics->Status = PXENV_STATUS_UNDI_INVALID_STATE;
4036+ return PXENV_EXIT_FAILURE;
4037+ }
4038+
4039+ /* Clear statistics */
4040 memset ( &pxe_netdev->tx_stats, 0, sizeof ( pxe_netdev->tx_stats ) );
4041 memset ( &pxe_netdev->rx_stats, 0, sizeof ( pxe_netdev->rx_stats ) );
4042
4043@@ -491,9 +636,18 @@
4044 * Status: won't implement (would require driver API changes for no
4045 * real benefit)
4046 */
4047-PXENV_EXIT_t pxenv_undi_initiate_diags ( struct s_PXENV_UNDI_INITIATE_DIAGS
4048- *undi_initiate_diags ) {
4049- DBG ( "PXENV_UNDI_INITIATE_DIAGS failed: unsupported\n" );
4050+static PXENV_EXIT_t
4051+pxenv_undi_initiate_diags ( struct s_PXENV_UNDI_INITIATE_DIAGS
4052+ *undi_initiate_diags ) {
4053+ DBGC ( &pxe_netdev, "PXENV_UNDI_INITIATE_DIAGS failed: unsupported\n" );
4054+
4055+ /* Sanity check */
4056+ if ( ! pxe_netdev ) {
4057+ DBGC ( &pxe_netdev, "PXENV_UNDI_INITIATE_DIAGS called with no "
4058+ "network device\n" );
4059+ undi_initiate_diags->Status = PXENV_STATUS_UNDI_INVALID_STATE;
4060+ return PXENV_EXIT_FAILURE;
4061+ }
4062
4063 undi_initiate_diags->Status = PXENV_STATUS_UNSUPPORTED;
4064 return PXENV_EXIT_FAILURE;
4065@@ -504,9 +658,19 @@
4066 * Status: won't implement (would require driver API changes for no
4067 * perceptible benefit)
4068 */
4069-PXENV_EXIT_t pxenv_undi_force_interrupt ( struct s_PXENV_UNDI_FORCE_INTERRUPT
4070- *undi_force_interrupt ) {
4071- DBG ( "PXENV_UNDI_FORCE_INTERRUPT failed: unsupported\n" );
4072+static PXENV_EXIT_t
4073+pxenv_undi_force_interrupt ( struct s_PXENV_UNDI_FORCE_INTERRUPT
4074+ *undi_force_interrupt ) {
4075+ DBGC ( &pxe_netdev,
4076+ "PXENV_UNDI_FORCE_INTERRUPT failed: unsupported\n" );
4077+
4078+ /* Sanity check */
4079+ if ( ! pxe_netdev ) {
4080+ DBGC ( &pxe_netdev, "PXENV_UNDI_FORCE_INTERRUPT called with no "
4081+ "network device\n" );
4082+ undi_force_interrupt->Status = PXENV_STATUS_UNDI_INVALID_STATE;
4083+ return PXENV_EXIT_FAILURE;
4084+ }
4085
4086 undi_force_interrupt->Status = PXENV_STATUS_UNSUPPORTED;
4087 return PXENV_EXIT_FAILURE;
4088@@ -516,23 +680,35 @@
4089 *
4090 * Status: working
4091 */
4092-PXENV_EXIT_t
4093+static PXENV_EXIT_t
4094 pxenv_undi_get_mcast_address ( struct s_PXENV_UNDI_GET_MCAST_ADDRESS
4095 *undi_get_mcast_address ) {
4096- struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
4097+ struct ll_protocol *ll_protocol;
4098 struct in_addr ip = { .s_addr = undi_get_mcast_address->InetAddr };
4099 int rc;
4100
4101- DBG ( "PXENV_UNDI_GET_MCAST_ADDRESS %s", inet_ntoa ( ip ) );
4102-
4103+ /* Sanity check */
4104+ if ( ! pxe_netdev ) {
4105+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_MCAST_ADDRESS called with "
4106+ "no network device\n" );
4107+ undi_get_mcast_address->Status =
4108+ PXENV_STATUS_UNDI_INVALID_STATE;
4109+ return PXENV_EXIT_FAILURE;
4110+ }
4111+
4112+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_MCAST_ADDRESS %s",
4113+ inet_ntoa ( ip ) );
4114+
4115+ /* Hash address using the network device's link-layer protocol */
4116+ ll_protocol = pxe_netdev->ll_protocol;
4117 if ( ( rc = ll_protocol->mc_hash ( AF_INET, &ip,
4118 undi_get_mcast_address->MediaAddr ))!=0){
4119- DBG ( " failed: %s\n", strerror ( rc ) );
4120+ DBGC ( &pxe_netdev, " failed: %s\n", strerror ( rc ) );
4121 undi_get_mcast_address->Status = PXENV_STATUS ( rc );
4122 return PXENV_EXIT_FAILURE;
4123 }
4124- DBG ( "=>%s\n",
4125- ll_protocol->ntoa ( undi_get_mcast_address->MediaAddr ) );
4126+ DBGC ( &pxe_netdev, "=>%s\n",
4127+ ll_protocol->ntoa ( undi_get_mcast_address->MediaAddr ) );
4128
4129 undi_get_mcast_address->Status = PXENV_STATUS_SUCCESS;
4130 return PXENV_EXIT_SUCCESS;
4131@@ -542,15 +718,24 @@
4132 *
4133 * Status: working
4134 */
4135-PXENV_EXIT_t pxenv_undi_get_nic_type ( struct s_PXENV_UNDI_GET_NIC_TYPE
4136- *undi_get_nic_type ) {
4137- struct device *dev = pxe_netdev->dev;
4138-
4139- DBG ( "PXENV_UNDI_GET_NIC_TYPE" );
4140-
4141+static PXENV_EXIT_t pxenv_undi_get_nic_type ( struct s_PXENV_UNDI_GET_NIC_TYPE
4142+ *undi_get_nic_type ) {
4143+ struct device *dev;
4144+
4145+ /* Sanity check */
4146+ if ( ! pxe_netdev ) {
4147+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_NIC_TYPE called with "
4148+ "no network device\n" );
4149+ undi_get_nic_type->Status = PXENV_STATUS_UNDI_INVALID_STATE;
4150+ return PXENV_EXIT_FAILURE;
4151+ }
4152+
4153+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_NIC_TYPE" );
4154+
4155+ /* Fill in information */
4156 memset ( &undi_get_nic_type->info, 0,
4157 sizeof ( undi_get_nic_type->info ) );
4158-
4159+ dev = pxe_netdev->dev;
4160 switch ( dev->desc.bus_type ) {
4161 case BUS_TYPE_PCI: {
4162 struct pci_nic_info *info = &undi_get_nic_type->info.pci;
4163@@ -567,13 +752,14 @@
4164 * is possible that some NBPs will not provide space
4165 * for them, and so we must not fill them in.
4166 */
4167- DBG ( " PCI %02x:%02x.%x %04x:%04x ('%04x:%04x') %02x%02x%02x "
4168- "rev %02x\n", PCI_BUS ( info->BusDevFunc ),
4169- PCI_SLOT ( info->BusDevFunc ),
4170- PCI_FUNC ( info->BusDevFunc ), info->Vendor_ID,
4171- info->Dev_ID, info->SubVendor_ID, info->SubDevice_ID,
4172- info->Base_Class, info->Sub_Class, info->Prog_Intf,
4173- info->Rev );
4174+ DBGC ( &pxe_netdev, " PCI %02x:%02x.%x %04x:%04x "
4175+ "('%04x:%04x') %02x%02x%02x rev %02x\n",
4176+ PCI_BUS ( info->BusDevFunc ),
4177+ PCI_SLOT ( info->BusDevFunc ),
4178+ PCI_FUNC ( info->BusDevFunc ), info->Vendor_ID,
4179+ info->Dev_ID, info->SubVendor_ID, info->SubDevice_ID,
4180+ info->Base_Class, info->Sub_Class, info->Prog_Intf,
4181+ info->Rev );
4182 break; }
4183 case BUS_TYPE_ISAPNP: {
4184 struct pnp_nic_info *info = &undi_get_nic_type->info.pnp;
4185@@ -585,12 +771,12 @@
4186 /* Cheat: remaining fields are probably unnecessary,
4187 * and would require adding extra code to isapnp.c.
4188 */
4189- DBG ( " ISAPnP CSN %04x %08x %02x%02x%02x\n",
4190- info->CardSelNum, info->EISA_Dev_ID,
4191- info->Base_Class, info->Sub_Class, info->Prog_Intf );
4192+ DBGC ( &pxe_netdev, " ISAPnP CSN %04x %08x %02x%02x%02x\n",
4193+ info->CardSelNum, info->EISA_Dev_ID,
4194+ info->Base_Class, info->Sub_Class, info->Prog_Intf );
4195 break; }
4196 default:
4197- DBG ( " failed: unknown bus type\n" );
4198+ DBGC ( &pxe_netdev, " failed: unknown bus type\n" );
4199 undi_get_nic_type->Status = PXENV_STATUS_FAILURE;
4200 return PXENV_EXIT_FAILURE;
4201 }
4202@@ -603,9 +789,19 @@
4203 *
4204 * Status: working
4205 */
4206-PXENV_EXIT_t pxenv_undi_get_iface_info ( struct s_PXENV_UNDI_GET_IFACE_INFO
4207- *undi_get_iface_info ) {
4208- DBG ( "PXENV_UNDI_GET_IFACE_INFO" );
4209+static PXENV_EXIT_t
4210+pxenv_undi_get_iface_info ( struct s_PXENV_UNDI_GET_IFACE_INFO
4211+ *undi_get_iface_info ) {
4212+
4213+ /* Sanity check */
4214+ if ( ! pxe_netdev ) {
4215+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_IFACE_INFO called with "
4216+ "no network device\n" );
4217+ undi_get_iface_info->Status = PXENV_STATUS_UNDI_INVALID_STATE;
4218+ return PXENV_EXIT_FAILURE;
4219+ }
4220+
4221+ DBGC ( &pxe_netdev, "PXENV_UNDI_GET_IFACE_INFO" );
4222
4223 /* Just hand back some info, doesn't really matter what it is.
4224 * Most PXE stacks seem to take this approach.
4225@@ -622,30 +818,23 @@
4226 memset ( undi_get_iface_info->Reserved, 0,
4227 sizeof(undi_get_iface_info->Reserved) );
4228
4229- DBG ( " %s %dbps flags %08x\n", undi_get_iface_info->IfaceType,
4230- undi_get_iface_info->LinkSpeed,
4231- undi_get_iface_info->ServiceFlags );
4232+ DBGC ( &pxe_netdev, " %s %dbps flags %08x\n",
4233+ undi_get_iface_info->IfaceType, undi_get_iface_info->LinkSpeed,
4234+ undi_get_iface_info->ServiceFlags );
4235 undi_get_iface_info->Status = PXENV_STATUS_SUCCESS;
4236 return PXENV_EXIT_SUCCESS;
4237 }
4238
4239 /* PXENV_UNDI_GET_STATE
4240 *
4241- * Status: impossible
4242+ * Status: impossible due to opcode collision
4243 */
4244-PXENV_EXIT_t pxenv_undi_get_state ( struct s_PXENV_UNDI_GET_STATE
4245- *undi_get_state ) {
4246- DBG ( "PXENV_UNDI_GET_STATE failed: unsupported\n" );
4247-
4248- undi_get_state->Status = PXENV_STATUS_UNSUPPORTED;
4249- return PXENV_EXIT_FAILURE;
4250-};
4251
4252 /* PXENV_UNDI_ISR
4253 *
4254 * Status: working
4255 */
4256-PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
4257+static PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
4258 struct io_buffer *iobuf;
4259 size_t len;
4260 struct ll_protocol *ll_protocol;
4261@@ -658,9 +847,18 @@
4262 unsigned int prottype;
4263 int rc;
4264
4265- /* Use coloured debug, since UNDI ISR messages are likely to
4266- * be interspersed amongst other UNDI messages.
4267+ /* Use a different debug colour, since UNDI ISR messages are
4268+ * likely to be interspersed amongst other UNDI messages.
4269 */
4270+
4271+ /* Sanity check */
4272+ if ( ! pxe_netdev ) {
4273+ DBGC ( &pxenv_undi_isr, "PXENV_UNDI_ISR called with "
4274+ "no network device\n" );
4275+ undi_isr->Status = PXENV_STATUS_UNDI_INVALID_STATE;
4276+ return PXENV_EXIT_FAILURE;
4277+ }
4278+
4279 DBGC2 ( &pxenv_undi_isr, "PXENV_UNDI_ISR" );
4280
4281 /* Just in case some idiot actually looks at these fields when
4282@@ -820,3 +1018,51 @@
4283 undi_isr->Status = PXENV_STATUS_SUCCESS;
4284 return PXENV_EXIT_SUCCESS;
4285 }
4286+
4287+/** PXE UNDI API */
4288+struct pxe_api_call pxe_undi_api[] __pxe_api_call = {
4289+ PXE_API_CALL ( PXENV_UNDI_STARTUP, pxenv_undi_startup,
4290+ struct s_PXENV_UNDI_STARTUP ),
4291+ PXE_API_CALL ( PXENV_UNDI_CLEANUP, pxenv_undi_cleanup,
4292+ struct s_PXENV_UNDI_CLEANUP ),
4293+ PXE_API_CALL ( PXENV_UNDI_INITIALIZE, pxenv_undi_initialize,
4294+ struct s_PXENV_UNDI_INITIALIZE ),
4295+ PXE_API_CALL ( PXENV_UNDI_RESET_ADAPTER, pxenv_undi_reset_adapter,
4296+ struct s_PXENV_UNDI_RESET ),
4297+ PXE_API_CALL ( PXENV_UNDI_SHUTDOWN, pxenv_undi_shutdown,
4298+ struct s_PXENV_UNDI_SHUTDOWN ),
4299+ PXE_API_CALL ( PXENV_UNDI_OPEN, pxenv_undi_open,
4300+ struct s_PXENV_UNDI_OPEN ),
4301+ PXE_API_CALL ( PXENV_UNDI_CLOSE, pxenv_undi_close,
4302+ struct s_PXENV_UNDI_CLOSE ),
4303+ PXE_API_CALL ( PXENV_UNDI_TRANSMIT, pxenv_undi_transmit,
4304+ struct s_PXENV_UNDI_TRANSMIT ),
4305+ PXE_API_CALL ( PXENV_UNDI_SET_MCAST_ADDRESS,
4306+ pxenv_undi_set_mcast_address,
4307+ struct s_PXENV_UNDI_SET_MCAST_ADDRESS ),
4308+ PXE_API_CALL ( PXENV_UNDI_SET_STATION_ADDRESS,
4309+ pxenv_undi_set_station_address,
4310+ struct s_PXENV_UNDI_SET_STATION_ADDRESS ),
4311+ PXE_API_CALL ( PXENV_UNDI_SET_PACKET_FILTER,
4312+ pxenv_undi_set_packet_filter,
4313+ struct s_PXENV_UNDI_SET_PACKET_FILTER ),
4314+ PXE_API_CALL ( PXENV_UNDI_GET_INFORMATION, pxenv_undi_get_information,
4315+ struct s_PXENV_UNDI_GET_INFORMATION ),
4316+ PXE_API_CALL ( PXENV_UNDI_GET_STATISTICS, pxenv_undi_get_statistics,
4317+ struct s_PXENV_UNDI_GET_STATISTICS ),
4318+ PXE_API_CALL ( PXENV_UNDI_CLEAR_STATISTICS, pxenv_undi_clear_statistics,
4319+ struct s_PXENV_UNDI_CLEAR_STATISTICS ),
4320+ PXE_API_CALL ( PXENV_UNDI_INITIATE_DIAGS, pxenv_undi_initiate_diags,
4321+ struct s_PXENV_UNDI_INITIATE_DIAGS ),
4322+ PXE_API_CALL ( PXENV_UNDI_FORCE_INTERRUPT, pxenv_undi_force_interrupt,
4323+ struct s_PXENV_UNDI_FORCE_INTERRUPT ),
4324+ PXE_API_CALL ( PXENV_UNDI_GET_MCAST_ADDRESS,
4325+ pxenv_undi_get_mcast_address,
4326+ struct s_PXENV_UNDI_GET_MCAST_ADDRESS ),
4327+ PXE_API_CALL ( PXENV_UNDI_GET_NIC_TYPE, pxenv_undi_get_nic_type,
4328+ struct s_PXENV_UNDI_GET_NIC_TYPE ),
4329+ PXE_API_CALL ( PXENV_UNDI_GET_IFACE_INFO, pxenv_undi_get_iface_info,
4330+ struct s_PXENV_UNDI_GET_IFACE_INFO ),
4331+ PXE_API_CALL ( PXENV_UNDI_ISR, pxenv_undi_isr,
4332+ struct s_PXENV_UNDI_ISR ),
4333+};
4334
4335=== modified file 'src/arch/i386/interface/syslinux/comboot_call.c'
4336--- src/arch/i386/interface/syslinux/comboot_call.c 2011-04-11 19:35:36 +0000
4337+++ src/arch/i386/interface/syslinux/comboot_call.c 2012-02-10 16:40:50 +0000
4338@@ -185,7 +185,7 @@
4339
4340 /* Fetch initrd */
4341 if ( ( rc = imgdownload_string ( initrd_file, NULL, NULL,
4342- register_and_put_image ))!=0){
4343+ NULL ) ) != 0 ) {
4344 DBG ( "COMBOOT: could not fetch initrd: %s\n",
4345 strerror ( rc ) );
4346 return rc;
4347@@ -200,7 +200,7 @@
4348
4349 /* Allocate and fetch kernel */
4350 if ( ( rc = imgdownload_string ( kernel_file, NULL, cmdline,
4351- register_and_replace_image ) ) != 0 ) {
4352+ image_replace ) ) != 0 ) {
4353 DBG ( "COMBOOT: could not fetch kernel: %s\n",
4354 strerror ( rc ) );
4355 return rc;
4356
4357=== modified file 'src/arch/i386/prefix/exeprefix.S'
4358--- src/arch/i386/prefix/exeprefix.S 2011-04-11 19:35:36 +0000
4359+++ src/arch/i386/prefix/exeprefix.S 2012-02-10 16:40:50 +0000
4360@@ -113,7 +113,7 @@
4361 call alloc_basemem
4362 xorl %esi, %esi
4363 movl $EXE_DECOMPRESS_ADDRESS, %edi
4364- clc
4365+ xorl %ebp, %ebp
4366 call install_prealloc
4367
4368 /* Set up real-mode stack */
4369
4370=== added file 'src/arch/i386/prefix/kkkpxeprefix.S'
4371--- src/arch/i386/prefix/kkkpxeprefix.S 1970-01-01 00:00:00 +0000
4372+++ src/arch/i386/prefix/kkkpxeprefix.S 2012-02-10 16:40:50 +0000
4373@@ -0,0 +1,19 @@
4374+/*****************************************************************************
4375+ * PXE prefix that keeps the whole PXE stack present and provides an exit hook
4376+ *
4377+ * This prefix is essentially intended solely for the case of ipxelinux.0
4378+ *****************************************************************************
4379+ */
4380+
4381+FILE_LICENCE ( GPL2_OR_LATER )
4382+
4383+/* Since we have the whole stack, we can use cached DHCP information */
4384+REQUIRE_OBJECT ( pxeparent_dhcp )
4385+
4386+/* Provide the PXENV_FILE_EXIT_HOOK API call */
4387+REQUIRE_OBJECT ( pxe_exit_hook )
4388+
4389+#define PXELOADER_KEEP_UNDI
4390+#define PXELOADER_KEEP_PXE
4391+#define _pxe_start _kkkpxe_start
4392+#include "pxeprefix.S"
4393
4394=== modified file 'src/arch/i386/prefix/libprefix.S'
4395--- src/arch/i386/prefix/libprefix.S 2011-04-11 19:35:36 +0000
4396+++ src/arch/i386/prefix/libprefix.S 2012-02-10 16:40:50 +0000
4397@@ -326,7 +326,6 @@
4398 #ifndef KEEP_IT_REAL
4399
4400 /* Preserve registers */
4401- pushfw
4402 pushl %eax
4403 pushl %ebp
4404
4405@@ -397,7 +396,6 @@
4406 /* Restore registers and return */
4407 popl %ebp
4408 popl %eax
4409- popfw
4410 ret
4411
4412 #else /* KEEP_IT_REAL */
4413@@ -614,17 +612,19 @@
4414 /* Preserve registers */
4415 pushl %esi
4416 pushl %edi
4417+ pushl %ebp
4418 /* Allocate space for .text16 and .data16 */
4419 call alloc_basemem
4420 /* Image source = %cs:0000 */
4421 xorl %esi, %esi
4422 /* Image destination = default */
4423 xorl %edi, %edi
4424- /* Allow relocation */
4425- clc
4426+ /* Allow arbitrary relocation */
4427+ xorl %ebp, %ebp
4428 /* Install text and data segments */
4429 call install_prealloc
4430 /* Restore registers and return */
4431+ popl %ebp
4432 popl %edi
4433 popl %esi
4434 ret
4435@@ -640,7 +640,7 @@
4436 * %bx : .data16 segment address
4437 * %esi : Image source physical address (or zero for %cs:0000)
4438 * %edi : Decompression temporary area physical address (or zero for default)
4439- * CF set : Avoid relocating to top of memory
4440+ * %ebp : Maximum end address for relocation (or zero for no maximum)
4441 * Corrupts:
4442 * none
4443 ****************************************************************************
4444@@ -655,14 +655,13 @@
4445 pushw %ds
4446 pushw %es
4447 cld /* Sanity: clear the direction flag asap */
4448- pushfw
4449
4450 /* Set up %ds for (read-only) access to .prefix */
4451 pushw %cs
4452 popw %ds
4453
4454- /* Copy decompression temporary area physical address to %ebp */
4455- movl %edi, %ebp
4456+ /* Save decompression temporary area physical address */
4457+ pushl %edi
4458
4459 /* Install .text16.early */
4460 progress " .text16.early\n"
4461@@ -747,6 +746,9 @@
4462 /* Set up %ds for access to .data16 */
4463 movw %bx, %ds
4464
4465+ /* Restore decompression temporary area physical address */
4466+ popl %edi
4467+
4468 #ifdef KEEP_IT_REAL
4469 /* Initialise libkir */
4470 movw %ax, (init_libkir_vector+2)
4471@@ -754,7 +756,7 @@
4472 #else
4473 /* Find a suitable decompression temporary area, if none specified */
4474 pushl %eax
4475- testl %ebp, %ebp
4476+ testl %edi, %edi
4477 jnz 1f
4478 /* Use INT 15,88 to find the highest available address via INT
4479 * 15,88. This limits us to around 64MB, which should avoid
4480@@ -762,14 +764,14 @@
4481 */
4482 movb $0x88, %ah
4483 int $0x15
4484- movw %ax, %bp
4485- addl $0x400, %ebp
4486- subl $_textdata_memsz_kb, %ebp
4487- shll $10, %ebp
4488+ movw %ax, %di
4489+ addl $0x400, %edi
4490+ subl $_textdata_memsz_kb, %edi
4491+ shll $10, %edi
4492 /* Sanity check: if we have ended up below 1MB, use 1MB */
4493- cmpl $0x100000, %ebp
4494+ cmpl $0x100000, %edi
4495 jae 1f
4496- movl $0x100000, %ebp
4497+ movl $0x100000, %edi
4498 1: popl %eax
4499
4500 /* Install .text and .data to temporary area in high memory,
4501@@ -777,22 +779,17 @@
4502 * properly.
4503 */
4504 progress " .textdata\n"
4505- movl %ebp, %edi
4506+ pushl %edi
4507 movl $_textdata_filesz, %ecx
4508 movl $_textdata_memsz, %edx
4509 call install_block
4510+ popl %edi
4511
4512 /* Initialise librm at current location */
4513 progress " init_librm\n"
4514 movw %ax, (init_librm_vector+2)
4515- movl %ebp, %edi
4516 lcall *init_librm_vector
4517
4518- /* Skip relocation if CF was set on entry */
4519- popfw
4520- pushfw
4521- jc skip_relocate
4522-
4523 /* Call relocate() to determine target address for relocation.
4524 * relocate() will return with %esi, %edi and %ecx set up
4525 * ready for the copy to the new location.
4526@@ -815,7 +812,6 @@
4527 /* Initialise librm at new location */
4528 progress " init_librm\n"
4529 lcall *init_librm_vector
4530-skip_relocate:
4531 #endif
4532
4533 /* Close access to payload */
4534@@ -824,7 +820,6 @@
4535 lcall *close_payload_vector
4536
4537 /* Restore registers */
4538- popfw
4539 popw %es
4540 popw %ds
4541 popal
4542
4543=== modified file 'src/arch/i386/prefix/lkrnprefix.S'
4544--- src/arch/i386/prefix/lkrnprefix.S 2011-04-11 19:35:36 +0000
4545+++ src/arch/i386/prefix/lkrnprefix.S 2012-02-10 16:40:50 +0000
4546@@ -160,7 +160,7 @@
4547 pad2:
4548 .byte 0, 0, 0
4549 cmdline_size:
4550- .long 0
4551+ .long 0x7ff
4552 hardware_subarch:
4553 .long 0
4554 hardware_subarch_data:
4555@@ -196,8 +196,15 @@
4556 /* Retrieve command-line pointer */
4557 movl %es:cmd_line_ptr, %edx
4558
4559+ /* Retrieve initrd pointer and size */
4560+ movl %es:ramdisk_image, %ebp
4561+ movl %es:ramdisk_size, %ecx
4562+
4563 /* Install iPXE */
4564- call install
4565+ call alloc_basemem
4566+ xorl %esi, %esi
4567+ xorl %edi, %edi
4568+ call install_prealloc
4569
4570 /* Set up real-mode stack */
4571 movw %bx, %ss
4572@@ -215,6 +222,10 @@
4573 /* Store command-line pointer */
4574 movl %edx, cmdline_phys
4575
4576+ /* Store initrd pointer and size */
4577+ movl %ebp, initrd_phys
4578+ movl %ecx, initrd_len
4579+
4580 /* Run iPXE */
4581 pushl $main
4582 pushw %cs
4583
4584=== modified file 'src/arch/i386/prefix/pxeprefix.S'
4585--- src/arch/i386/prefix/pxeprefix.S 2011-04-11 19:35:36 +0000
4586+++ src/arch/i386/prefix/pxeprefix.S 2012-02-10 16:40:50 +0000
4587@@ -721,11 +721,7 @@
4588 .section ".text16", "ax", @progbits
4589 1:
4590 /* Update the exit hook */
4591- movw %cs,pxe_exit_hook+2
4592- push %ax
4593- mov $2f,%ax
4594- mov %ax,pxe_exit_hook
4595- pop %ax
4596+ movw %cs, ( pxe_exit_hook + 2 )
4597
4598 /* Run main program */
4599 pushl $main
4600@@ -743,7 +739,14 @@
4601 /* Jump to hook if applicable */
4602 ljmpw *pxe_exit_hook
4603
4604-2: /* Check PXE stack magic */
4605+ .section ".data16", "aw", @progbits
4606+ .globl pxe_exit_hook
4607+pxe_exit_hook:
4608+ .word exit_ipxe, 0
4609+ .previous
4610+
4611+exit_ipxe:
4612+ /* Check PXE stack magic */
4613 popl %eax
4614 cmpl $STACK_MAGIC, %eax
4615 jne 1f
4616
4617=== modified file 'src/arch/i386/prefix/romprefix.S'
4618--- src/arch/i386/prefix/romprefix.S 2011-07-31 20:57:02 +0000
4619+++ src/arch/i386/prefix/romprefix.S 2012-02-10 16:40:50 +0000
4620@@ -414,7 +414,7 @@
4621 * picked up by the initial shell prompt, and we will drop
4622 * into a shell.
4623 */
4624- stc /* Inhibit relocation */
4625+ movl $0xa0000, %ebp /* Inhibit relocation during POST */
4626 pushw %cs
4627 call exec
4628 2:
4629@@ -445,7 +445,7 @@
4630 /* Preserve registers */
4631 pushl %eax
4632 pushw %di
4633- movw $' ', %di
4634+ movw $( ' ' ), %di
4635 get_pmm_find:
4636 /* Try to find existing block */
4637 pushl %ebx /* PMM handle */
4638@@ -474,7 +474,7 @@
4639 pushw %dx
4640 pushw %ax
4641 popl %esi
4642- movw $'+', %di /* Indicate allocation attempt */
4643+ movw $( '+' ), %di /* Indicate allocation attempt */
4644 testl %esi, %esi
4645 jnz get_pmm_done
4646 stc
4647@@ -614,7 +614,7 @@
4648 * Called by the PnP BIOS when it wants to boot us.
4649 */
4650 bev_entry:
4651- clc /* Allow relocation */
4652+ xorl %ebp, %ebp /* Allow relocation */
4653 pushw %cs
4654 call exec
4655 lret
4656@@ -649,7 +649,7 @@
4657 /* Leave keypress in buffer and start iPXE. The keypress will
4658 * cause the usual initial Ctrl-B prompt to be skipped.
4659 */
4660- clc /* Allow relocation */
4661+ xorl %ebp, %ebp /* Allow relocation */
4662 pushw %cs
4663 call exec
4664 1: /* Try to call original INT 19 vector */
4665@@ -681,9 +681,6 @@
4666 pushw %cs
4667 popw %ds
4668
4669- /* Preserve state of CF */
4670- lahf
4671-
4672 /* Print message as soon as possible */
4673 movw $prodstr, %si
4674 xorw %di, %di
4675@@ -693,8 +690,8 @@
4676
4677 /* Store magic word on BIOS stack and remember BIOS %ss:sp */
4678 pushl $STACK_MAGIC
4679- movw %ss, %dx
4680- movw %sp, %bp
4681+ movw %ss, %cx
4682+ movw %sp, %dx
4683
4684 /* Obtain a reasonably-sized temporary stack */
4685 xorw %bx, %bx
4686@@ -702,10 +699,7 @@
4687 movw $0x7c00, %sp
4688
4689 /* Install iPXE */
4690- sahf
4691- pushfw
4692 call alloc_basemem
4693- popfw
4694 movl image_source, %esi
4695 movl decompress_to, %edi
4696 call install_prealloc
4697@@ -728,14 +722,14 @@
4698 pushl $main
4699 pushw %cs
4700 call prot_call
4701- popl %ecx /* discard */
4702+ popl %eax /* discard */
4703
4704 /* Uninstall iPXE */
4705 call uninstall
4706
4707 /* Restore BIOS stack */
4708- movw %dx, %ss
4709- movw %bp, %sp
4710+ movw %cx, %ss
4711+ movw %dx, %sp
4712
4713 /* Check magic word on BIOS stack */
4714 popl %eax
4715
4716=== modified file 'src/arch/i386/prefix/undiloader.S'
4717--- src/arch/i386/prefix/undiloader.S 2011-04-11 19:35:36 +0000
4718+++ src/arch/i386/prefix/undiloader.S 2012-02-10 16:40:50 +0000
4719@@ -14,6 +14,7 @@
4720 /* Save registers */
4721 pushl %esi
4722 pushl %edi
4723+ pushl %ebp
4724 pushw %ds
4725 pushw %es
4726 pushw %bx
4727@@ -30,7 +31,7 @@
4728 movw %es:14(%di), %ax
4729 movl image_source, %esi
4730 movl decompress_to, %edi
4731- clc /* Allow relocation */
4732+ xorl %ebp, %ebp /* Allow relocation */
4733 call install_prealloc
4734 popw %di
4735 /* Call UNDI loader C code */
4736@@ -46,6 +47,7 @@
4737 popw %bx
4738 popw %es
4739 popw %ds
4740+ popl %ebp
4741 popl %edi
4742 popl %esi
4743 lret
4744
4745=== modified file 'src/arch/i386/transitions/liba20.S'
4746--- src/arch/i386/transitions/liba20.S 2011-04-11 19:35:36 +0000
4747+++ src/arch/i386/transitions/liba20.S 2012-02-10 16:40:50 +0000
4748@@ -96,8 +96,11 @@
4749 .section ".text16.early", "awx", @progbits
4750 .code16
4751 enable_a20_bios:
4752- /* Preserve registers */
4753- pushw %ax
4754+
4755+ /* Preserve registers. Be very paranoid, since some BIOSes
4756+ * are reported to clobber %ebx
4757+ */
4758+ pushal
4759
4760 /* Attempt INT 15,2401 */
4761 movw $0x2401, %ax
4762@@ -108,7 +111,7 @@
4763 call test_a20_short
4764
4765 99: /* Restore registers and return */
4766- popw %ax
4767+ popal
4768 ret
4769 .size enable_a20_bios, . - enable_a20_bios
4770
4771
4772=== modified file 'src/arch/i386/transitions/librm.S'
4773--- src/arch/i386/transitions/librm.S 2011-04-11 19:35:36 +0000
4774+++ src/arch/i386/transitions/librm.S 2012-02-10 16:40:50 +0000
4775@@ -97,18 +97,18 @@
4776 pushl %eax
4777 pushl %ebx
4778
4779- /* Store _virt_offset and set up virtual_cs and virtual_ds segments */
4780+ /* Store virt_offset and set up virtual_cs and virtual_ds segments */
4781 movl %edi, %eax
4782 movw $virtual_cs, %bx
4783 call set_seg_base
4784 movw $virtual_ds, %bx
4785 call set_seg_base
4786- movl %edi, _virt_offset
4787+ movl %edi, rm_virt_offset
4788
4789 /* Negate virt_offset */
4790 negl %edi
4791
4792- /* Store rm_cs and _text16, set up real_cs segment */
4793+ /* Store rm_cs and text16, set up real_cs segment */
4794 xorl %eax, %eax
4795 movw %cs, %ax
4796 movw %ax, rm_cs
4797@@ -116,9 +116,9 @@
4798 movw $real_cs, %bx
4799 call set_seg_base
4800 addr32 leal (%eax, %edi), %ebx
4801- movl %ebx, _text16
4802+ movl %ebx, rm_text16
4803
4804- /* Store rm_ds and _data16, set up real_ds segment */
4805+ /* Store rm_ds and data16, set up real_ds segment */
4806 xorl %eax, %eax
4807 movw %ds, %ax
4808 movw %ax, %cs:rm_ds
4809@@ -126,7 +126,7 @@
4810 movw $real_ds, %bx
4811 call set_seg_base
4812 addr32 leal (%eax, %edi), %ebx
4813- movl %ebx, _data16
4814+ movl %ebx, rm_data16
4815
4816 /* Set GDT and IDT base */
4817 movl %eax, gdt_base
4818@@ -182,12 +182,12 @@
4819 movw %cs:rm_ds, %ax
4820 movw %ax, %ds
4821
4822- /* Add _virt_offset, _text16 and _data16 to stack to be
4823+ /* Add virt_offset, text16 and data16 to stack to be
4824 * copied, and also copy the return address.
4825 */
4826- pushl _virt_offset
4827- pushl _text16
4828- pushl _data16
4829+ pushl rm_virt_offset
4830+ pushl rm_text16
4831+ pushl rm_data16
4832 addw $16, %cx /* %ecx must be less than 64kB anyway */
4833
4834 /* Real-mode %ss:%sp => %ebp:%edx and virtual address => %esi */
4835@@ -197,7 +197,7 @@
4836 movl %ebp, %eax
4837 shll $4, %eax
4838 addr32 leal (%eax,%edx), %esi
4839- subl _virt_offset, %esi
4840+ subl rm_virt_offset, %esi
4841
4842 /* Switch to protected mode */
4843 cli
4844@@ -557,9 +557,9 @@
4845 */
4846 /* Internal copies, created by init_librm (which runs in real mode) */
4847 .section ".data16", "aw", @progbits
4848-_virt_offset: .long 0
4849-_text16: .long 0
4850-_data16: .long 0
4851+rm_virt_offset: .long 0
4852+rm_text16: .long 0
4853+rm_data16: .long 0
4854
4855 /* Externally-visible copies, created by real_to_prot */
4856 .section ".data", "aw", @progbits
4857
4858=== modified file 'src/config/defaults/pcbios.h'
4859--- src/config/defaults/pcbios.h 2011-04-11 19:35:36 +0000
4860+++ src/config/defaults/pcbios.h 2012-02-10 16:40:50 +0000
4861@@ -34,4 +34,6 @@
4862 #define SANBOOT_PROTO_IB_SRP /* Infiniband SCSI RDMA protocol */
4863 #define SANBOOT_PROTO_FCP /* Fibre Channel protocol */
4864
4865+#define REBOOT_CMD /* Reboot command */
4866+
4867 #endif /* CONFIG_DEFAULTS_PCBIOS_H */
4868
4869=== modified file 'src/config/general.h'
4870--- src/config/general.h 2011-07-31 20:57:02 +0000
4871+++ src/config/general.h 2012-02-10 16:40:50 +0000
4872@@ -120,12 +120,12 @@
4873 #define DHCP_CMD /* DHCP management commands */
4874 #define SANBOOT_CMD /* SAN boot commands */
4875 #define LOGIN_CMD /* Login command */
4876-#undef TIME_CMD /* Time commands */
4877-#undef DIGEST_CMD /* Image crypto digest commands */
4878-#undef LOTEST_CMD /* Loopback testing commands */
4879-#undef VLAN_CMD /* VLAN commands */
4880-#undef PXE_CMD /* PXE commands */
4881-#undef REBOOT_CMD /* Reboot command */
4882+//#define TIME_CMD /* Time commands */
4883+//#define DIGEST_CMD /* Image crypto digest commands */
4884+//#define LOTEST_CMD /* Loopback testing commands */
4885+//#define VLAN_CMD /* VLAN commands */
4886+//#define PXE_CMD /* PXE commands */
4887+//#define REBOOT_CMD /* Reboot command */
4888
4889 /*
4890 * ROM-specific options
4891
4892=== added file 'src/core/assert.c'
4893--- src/core/assert.c 1970-01-01 00:00:00 +0000
4894+++ src/core/assert.c 2012-02-10 16:40:50 +0000
4895@@ -0,0 +1,30 @@
4896+/*
4897+ * Copyright (C) 2011 Michael Brown <mbrown@fensystems.co.uk>.
4898+ *
4899+ * This program is free software; you can redistribute it and/or
4900+ * modify it under the terms of the GNU General Public License as
4901+ * published by the Free Software Foundation; either version 2 of the
4902+ * License, or any later version.
4903+ *
4904+ * This program is distributed in the hope that it will be useful, but
4905+ * WITHOUT ANY WARRANTY; without even the implied warranty of
4906+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4907+ * General Public License for more details.
4908+ *
4909+ * You should have received a copy of the GNU General Public License
4910+ * along with this program; if not, write to the Free Software
4911+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4912+ */
4913+
4914+FILE_LICENCE ( GPL2_OR_LATER );
4915+
4916+/** @file
4917+ *
4918+ * Assertions
4919+ *
4920+ */
4921+
4922+#include <assert.h>
4923+
4924+/** Number of assertion failures triggered */
4925+unsigned int assertion_failures = 0;
4926
4927=== modified file 'src/core/exec.c'
4928--- src/core/exec.c 2011-07-31 20:57:02 +0000
4929+++ src/core/exec.c 2012-02-10 16:40:50 +0000
4930@@ -31,6 +31,10 @@
4931 #include <ipxe/command.h>
4932 #include <ipxe/parseopt.h>
4933 #include <ipxe/settings.h>
4934+#include <ipxe/console.h>
4935+#include <ipxe/keys.h>
4936+#include <ipxe/process.h>
4937+#include <ipxe/nap.h>
4938 #include <ipxe/shell.h>
4939
4940 /** @file
4941@@ -527,3 +531,54 @@
4942 .name = "iseq",
4943 .exec = iseq_exec,
4944 };
4945+
4946+/** "sleep" options */
4947+struct sleep_options {};
4948+
4949+/** "sleep" option list */
4950+static struct option_descriptor sleep_opts[] = {};
4951+
4952+/** "sleep" command descriptor */
4953+static struct command_descriptor sleep_cmd =
4954+ COMMAND_DESC ( struct sleep_options, sleep_opts, 1, 1, "<seconds>" );
4955+
4956+/**
4957+ * "sleep" command
4958+ *
4959+ * @v argc Argument count
4960+ * @v argv Argument list
4961+ * @ret rc Return status code
4962+ */
4963+static int sleep_exec ( int argc, char **argv ) {
4964+ struct sleep_options opts;
4965+ unsigned int seconds;
4966+ unsigned long start;
4967+ unsigned long delay;
4968+ int rc;
4969+
4970+ /* Parse options */
4971+ if ( ( rc = parse_options ( argc, argv, &sleep_cmd, &opts ) ) != 0 )
4972+ return rc;
4973+
4974+ /* Parse number of seconds */
4975+ if ( ( rc = parse_integer ( argv[optind], &seconds ) ) != 0 )
4976+ return rc;
4977+
4978+ /* Delay for specified number of seconds */
4979+ start = currticks();
4980+ delay = ( seconds * TICKS_PER_SEC );
4981+ while ( ( currticks() - start ) <= delay ) {
4982+ step();
4983+ if ( iskey() && ( getchar() == CTRL_C ) )
4984+ return -ECANCELED;
4985+ cpu_nap();
4986+ }
4987+
4988+ return 0;
4989+}
4990+
4991+/** "sleep" command */
4992+struct command sleep_command __command = {
4993+ .name = "sleep",
4994+ .exec = sleep_exec,
4995+};
4996
4997=== modified file 'src/core/getopt.c'
4998--- src/core/getopt.c 2011-04-11 19:35:36 +0000
4999+++ src/core/getopt.c 2012-02-10 16:40:50 +0000
5000@@ -239,6 +239,11 @@
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: