Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74b7bc0954 | ||
|
|
7166bc7b2d | ||
|
|
e78bcb6175 | ||
|
|
02a0215873 | ||
|
|
8e8a348fd4 | ||
|
|
246ddf5ee4 | ||
|
|
a2686a55c4 | ||
|
|
b48f37e69a | ||
|
|
14a739ba6a | ||
|
|
d3d8f20626 | ||
|
|
fc49421c7e | ||
|
|
5dd5107976 | ||
|
|
0ebbbb95fa | ||
|
|
7d36a1b7b0 | ||
|
|
3f85626fa9 | ||
|
|
d9b3d09910 | ||
|
|
b59e0cc56e | ||
|
|
849e4b12d6 | ||
|
|
dc60c24146 | ||
|
|
446b6d5fdd | ||
|
|
fca2dcabb8 | ||
|
|
ab96932ab3 | ||
|
|
0a8a17e669 | ||
|
|
85f82f09e9 | ||
|
|
cc93556725 | ||
|
|
c661945e82 | ||
|
|
54fbd11221 | ||
|
|
464bf35cc0 | ||
|
|
8a80e7ace1 | ||
|
|
1b3edd9e11 | ||
|
|
2ca2607b1b | ||
|
|
125c6d66a8 | ||
|
|
9e5fd8ec59 | ||
|
|
c0ec00f47f | ||
|
|
9a35830d1f | ||
|
|
663904a7bc | ||
|
|
830e19eb54 | ||
|
|
0de5f7af6d | ||
|
|
d9751edafa | ||
|
|
dd34500188 | ||
|
|
180d99fc22 | ||
|
|
9a52ba0cfa | ||
|
|
46f43d8ea7 | ||
|
|
43aa69d7b3 | ||
|
|
ed196a3ed2 | ||
|
|
29e6f9835e | ||
|
|
aa95744915 | ||
|
|
5e6b82104d | ||
|
|
32bc76f902 | ||
|
|
467c4f77c3 | ||
|
|
0a6c66a830 | ||
|
|
621101c36a | ||
|
|
1bc2adea9a | ||
|
|
664f4cf365 | ||
|
|
df033de24f | ||
|
|
7a4c129af7 | ||
|
|
3fe6bede74 | ||
|
|
d4c8273569 | ||
|
|
bcc70d6b99 | ||
|
|
612f4e7a99 | ||
|
|
cbf9003d66 | ||
|
|
85f09b5fc0 | ||
|
|
22979c511e | ||
|
|
d9c38d14d6 | ||
|
|
5600955bdd | ||
|
|
7982e79d3c | ||
|
|
04f3206581 | ||
|
|
58dd6e04c5 | ||
|
|
744b98d273 | ||
|
|
c99b16c974 | ||
|
|
3a505dfc35 | ||
|
|
6b9cc25556 | ||
|
|
832668105e | ||
|
|
64e5ca0582 | ||
|
|
81d92c6d34 | ||
|
|
54c024e0af | ||
|
|
d4e152e766 | ||
|
|
07e8f18f33 | ||
|
|
831e4cfc27 | ||
|
|
6554b79ff9 | ||
|
|
667819becc | ||
|
|
c0835339d0 | ||
|
|
658c6dba59 | ||
|
|
16f1e35775 | ||
|
|
e6f276ece3 | ||
|
|
f945d6d201 | ||
|
|
941b4c2adb | ||
|
|
8a4ccebec9 | ||
|
|
fd67452807 | ||
|
|
e226a8d8d9 | ||
|
|
8c7deba349 | ||
|
|
aef6d0df5c | ||
|
|
992bbf309c | ||
|
|
8e38669d54 | ||
|
|
a1e11a6beb | ||
|
|
1641b5d39b | ||
|
|
ee2df1d6d6 | ||
|
|
8956a36be5 | ||
|
|
b40b4f2dbf | ||
|
|
0b5c39d167 | ||
|
|
2e812235f4 | ||
|
|
ac663cf509 | ||
|
|
13d09e6719 | ||
|
|
3029eb0e84 | ||
|
|
5c695db474 | ||
|
|
98abd48a26 | ||
|
|
3f80f9e1a6 | ||
|
|
cdd619d11f | ||
|
|
96ea558e98 | ||
|
|
e817a347fb | ||
|
|
a2588547f9 | ||
|
|
f0b942ef42 | ||
|
|
160b950af8 | ||
|
|
19a0452205 | ||
|
|
521549d900 | ||
|
|
9dccbc0af2 | ||
|
|
91802c6e85 | ||
|
|
afe1323c76 | ||
|
|
9b01a9fd9c | ||
|
|
60c3b69c31 | ||
|
|
8c3e95ce42 | ||
|
|
df02c54f86 | ||
|
|
76f6cad8af | ||
|
|
e899f100ca | ||
|
|
e8b6077566 | ||
|
|
6f87d622e1 | ||
|
|
1dda75c9cd | ||
|
|
040f7cdf3a | ||
|
|
0015601f0b | ||
|
|
50dc9344b7 | ||
|
|
e3c5507178 | ||
|
|
39047c5636 | ||
|
|
2d41dead08 | ||
|
|
6eaefa16a8 |
@@ -0,0 +1,20 @@
|
||||
Index: memory/memory.cc
|
||||
===================================================================
|
||||
RCS file: /cvsroot/bochs/bochs/memory/memory.cc,v
|
||||
retrieving revision 1.71
|
||||
diff -u -r1.71 memory.cc
|
||||
--- memory/memory.cc 18 Oct 2008 18:10:14 -0000 1.71
|
||||
+++ memory/memory.cc 21 Oct 2008 19:47:07 -0000
|
||||
@@ -172,7 +172,11 @@
|
||||
break;
|
||||
|
||||
case 0x0: // Writes to ROM, Inhibit
|
||||
- BX_DEBUG(("Write to ROM ignored: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
|
||||
+ if ((a20addr & 0xfffe0000) == 0x000e0000) {
|
||||
+ BX_DEBUG(("Write to ROM ignored: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
|
||||
+ } else {
|
||||
+ BX_MEM_THIS rom[(a20addr & EXROM_MASK) + BIOSROMSZ] = *data_ptr;
|
||||
+ }
|
||||
break;
|
||||
|
||||
default:
|
||||
+71
-121
@@ -1,19 +1,17 @@
|
||||
# Location to place generated files
|
||||
###############################################################################
|
||||
#
|
||||
BIN := bin
|
||||
|
||||
# Initialise variables that get added to throughout the various Makefiles
|
||||
# Initialise various variables
|
||||
#
|
||||
MAKEDEPS := Makefile .toolcheck .echocheck
|
||||
SRCDIRS :=
|
||||
SRCS :=
|
||||
NON_AUTO_SRCS :=
|
||||
DRIVERS :=
|
||||
ROMS :=
|
||||
MEDIA :=
|
||||
NON_AUTO_MEDIA :=
|
||||
|
||||
# Locations of utilities
|
||||
CLEANUP :=
|
||||
CFLAGS :=
|
||||
ASFLAGS :=
|
||||
LDFLAGS :=
|
||||
MAKEDEPS := Makefile
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Locations of tools
|
||||
#
|
||||
HOST_CC := gcc
|
||||
RM := rm -f
|
||||
@@ -35,109 +33,18 @@ NM := $(CROSS_COMPILE)nm
|
||||
OBJDUMP := $(CROSS_COMPILE)objdump
|
||||
PARSEROM := $(PERL) ./util/parserom.pl
|
||||
MAKEROM := $(PERL) ./util/makerom.pl
|
||||
MKCONFIG := $(PERL) ./util/mkconfig.pl
|
||||
SYMCHECK := $(PERL) ./util/symcheck.pl
|
||||
SORTOBJDUMP := $(PERL) ./util/sortobjdump.pl
|
||||
NRV2B := ./util/nrv2b
|
||||
ZBIN := ./util/zbin
|
||||
EFILINK := ./util/efilink
|
||||
DOXYGEN := doxygen
|
||||
|
||||
# If invoked with no build target, print out a helpfully suggestive
|
||||
# message.
|
||||
###############################################################################
|
||||
#
|
||||
noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb $(BIN)/undionly.kpxe
|
||||
@$(ECHO) '==========================================================='
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'To create a bootable floppy, type'
|
||||
@$(ECHO) ' cat $(BIN)/gpxe.dsk > /dev/fd0'
|
||||
@$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
|
||||
@$(ECHO) 'data already on the disk.'
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'To create a bootable USB key, type'
|
||||
@$(ECHO) ' cat $(BIN)/gpxe.usb > /dev/sdX'
|
||||
@$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
|
||||
@$(ECHO) 'disk on your system. This will erase any data already on'
|
||||
@$(ECHO) 'the USB key.'
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
|
||||
@$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.'
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'These images contain drivers for all supported cards. You'
|
||||
@$(ECHO) 'can build more customised images, and ROM images, using'
|
||||
@$(ECHO) ' make bin/<rom-name>.<output-format>'
|
||||
@$(ECHO)
|
||||
@$(ECHO) '==========================================================='
|
||||
|
||||
# If no architecture is specified in Config or on the command-line,
|
||||
# use that of the build machine.
|
||||
#
|
||||
ARCH ?= $(shell uname -m | sed -e s,i[3456789]86,i386,)
|
||||
|
||||
# handle x86_64 like i386, but set -m32 option for 32bit code only
|
||||
ifeq ($(ARCH),x86_64)
|
||||
ARCH := i386
|
||||
CFLAGS += -m32
|
||||
ASFLAGS += --32
|
||||
LDFLAGS += -m elf_i386
|
||||
endif
|
||||
|
||||
# Drag in architecture-specific Config
|
||||
#
|
||||
MAKEDEPS += arch/$(ARCH)/Config
|
||||
include arch/$(ARCH)/Config
|
||||
|
||||
# Common flags
|
||||
#
|
||||
CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
|
||||
CFLAGS += -Os -ffreestanding
|
||||
CFLAGS += -Wall -W
|
||||
CFLAGS += -g
|
||||
CFLAGS += $(EXTRA_CFLAGS)
|
||||
ASFLAGS += $(EXTRA_ASFLAGS)
|
||||
LDFLAGS += $(EXTRA_LDFLAGS)
|
||||
|
||||
# Embedded image, if present
|
||||
#
|
||||
EMBEDDED_IMAGE ?= /dev/null
|
||||
|
||||
ifneq ($(NO_WERROR),1)
|
||||
CFLAGS += -Werror
|
||||
endif
|
||||
|
||||
# CFLAGS for specific object types
|
||||
#
|
||||
CFLAGS_c +=
|
||||
CFLAGS_S += -DASSEMBLY
|
||||
|
||||
# Base object name of the current target
|
||||
#
|
||||
OBJECT = $(firstword $(subst ., ,$(@F)))
|
||||
|
||||
# CFLAGS for specific object files. You can define
|
||||
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
|
||||
# compiling bin/rtl8139.o.
|
||||
#
|
||||
OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
|
||||
$(BIN)/%.flags :
|
||||
@$(ECHO) $(OBJ_CFLAGS)
|
||||
|
||||
# Rules for specific object types.
|
||||
#
|
||||
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
|
||||
RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
|
||||
RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
|
||||
RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
|
||||
RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
|
||||
|
||||
PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
|
||||
ASSEMBLE_S = $(AS) $(ASFLAGS)
|
||||
RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
|
||||
RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
|
||||
|
||||
DEBUG_TARGETS += dbg%.o c s
|
||||
|
||||
# SRCDIRS lists all directories containing source files.
|
||||
#
|
||||
SRCDIRS :=
|
||||
SRCDIRS += libgcc
|
||||
SRCDIRS += core
|
||||
SRCDIRS += proto
|
||||
@@ -151,7 +58,7 @@ SRCDIRS += drivers/block
|
||||
SRCDIRS += drivers/nvs
|
||||
SRCDIRS += drivers/bitbash
|
||||
SRCDIRS += drivers/infiniband
|
||||
SRCDIRS += interface/pxe
|
||||
SRCDIRS += interface/pxe interface/efi
|
||||
SRCDIRS += tests
|
||||
SRCDIRS += crypto crypto/axtls crypto/matrixssl
|
||||
SRCDIRS += hci hci/commands hci/tui
|
||||
@@ -161,25 +68,68 @@ SRCDIRS += usr
|
||||
# NON_AUTO_SRCS lists files that are excluded from the normal
|
||||
# automatic build system.
|
||||
#
|
||||
NON_AUTO_SRCS += core/elf_loader.c
|
||||
NON_AUTO_SRCS :=
|
||||
NON_AUTO_SRCS += drivers/net/prism2.c
|
||||
|
||||
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
|
||||
# the automatic build system and varies by target; it includes the
|
||||
# "-p 0x1234,0x5678" string to set the PCI IDs.
|
||||
###############################################################################
|
||||
#
|
||||
FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
|
||||
-i$(IDENT) -s 0 $@
|
||||
|
||||
# Some ROMs require specific flags to be passed to makerom.pl
|
||||
# Default build target: build the most common targets and print out a
|
||||
# helpfully suggestive message
|
||||
#
|
||||
MAKEROM_FLAGS_3c503 = -3
|
||||
all : bin/blib.a bin/gpxe.dsk bin/gpxe.iso bin/gpxe.usb bin/undionly.kpxe
|
||||
@$(ECHO) '==========================================================='
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'To create a bootable floppy, type'
|
||||
@$(ECHO) ' cat bin/gpxe.dsk > /dev/fd0'
|
||||
@$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
|
||||
@$(ECHO) 'data already on the disk.'
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'To create a bootable USB key, type'
|
||||
@$(ECHO) ' cat bin/gpxe.usb > /dev/sdX'
|
||||
@$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
|
||||
@$(ECHO) 'disk on your system. This will erase any data already on'
|
||||
@$(ECHO) 'the USB key.'
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
|
||||
@$(ECHO) 'bin/gpxe.iso to a blank CD-ROM.'
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'These images contain drivers for all supported cards. You'
|
||||
@$(ECHO) 'can build more customised images, and ROM images, using'
|
||||
@$(ECHO) ' make bin/<rom-name>.<output-format>'
|
||||
@$(ECHO)
|
||||
@$(ECHO) '==========================================================='
|
||||
|
||||
# Drag in architecture-specific Makefile
|
||||
###############################################################################
|
||||
#
|
||||
# Build targets that do nothing but might be tried by users
|
||||
#
|
||||
configure :
|
||||
@$(ECHO) "No configuration needed."
|
||||
|
||||
install :
|
||||
@$(ECHO) "No installation required."
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Version number calculations
|
||||
#
|
||||
VERSION_MAJOR = 0
|
||||
VERSION_MINOR = 9
|
||||
VERSION_PATCH = 6
|
||||
EXTRAVERSION =
|
||||
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
|
||||
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
|
||||
CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \
|
||||
-DVERSION_MINOR=$(VERSION_MINOR) \
|
||||
-DVERSION=\"$(VERSION)\"
|
||||
IDENT = '$(@F) $(VERSION) (GPL) etherboot.org'
|
||||
version :
|
||||
@$(ECHO) $(VERSION)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Drag in the bulk of the build system
|
||||
#
|
||||
MAKEDEPS += arch/$(ARCH)/Makefile
|
||||
include arch/$(ARCH)/Makefile
|
||||
|
||||
# Drag in the automatic build system and other housekeeping functions
|
||||
MAKEDEPS += Makefile.housekeeping
|
||||
include Makefile.housekeeping
|
||||
|
||||
+336
-114
@@ -1,50 +1,10 @@
|
||||
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||
|
||||
#
|
||||
# This file contains various boring housekeeping functions that would
|
||||
# otherwise seriously clutter up the main Makefile.
|
||||
|
||||
# Objects to be removed by "make clean"
|
||||
###############################################################################
|
||||
#
|
||||
CLEANUP := $(BIN)/*.* # *.* to avoid catching the "CVS" directory
|
||||
|
||||
# Version number calculations
|
||||
#
|
||||
VERSION_MAJOR = 0
|
||||
VERSION_MINOR = 9
|
||||
VERSION_PATCH = 4
|
||||
EXTRAVERSION =
|
||||
MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
|
||||
VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
|
||||
CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \
|
||||
-DVERSION_MINOR=$(VERSION_MINOR) \
|
||||
-DVERSION=\"$(VERSION)\"
|
||||
IDENT = '$(@F) $(VERSION) (GPL) etherboot.org'
|
||||
version :
|
||||
@$(ECHO) $(VERSION)
|
||||
|
||||
configure :
|
||||
@$(ECHO) "No configuration needed."
|
||||
|
||||
install :
|
||||
@$(ECHO) "No installation required. Generated images will be placed in the" $(BIN) "directory."
|
||||
|
||||
# Check for tools that can cause failed builds
|
||||
#
|
||||
.toolcheck : Makefile
|
||||
@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
|
||||
$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
|
||||
$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
|
||||
exit 1; \
|
||||
fi
|
||||
@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
|
||||
$(ECHO) 'Your Perl version has a Unicode handling bug'; \
|
||||
$(ECHO) 'Execute this command before compiling Etherboot:'; \
|
||||
$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
|
||||
exit 1; \
|
||||
fi
|
||||
@$(TOUCH) $@
|
||||
VERYCLEANUP += .toolcheck
|
||||
|
||||
# Find a usable "echo -e" substitute.
|
||||
#
|
||||
TAB := $(shell $(PRINTF) '\t')
|
||||
@@ -58,16 +18,16 @@ ECHO_E_BIN_ECHO_TAB := $(shell $(ECHO_E_BIN_ECHO) '\t')
|
||||
ECHO_E_BIN_ECHO_E_TAB := $(shell $(ECHO_E_BIN_ECHO_E) '\t')
|
||||
|
||||
ifeq ($(ECHO_E_ECHO_TAB),$(TAB))
|
||||
ECHO_E ?= $(ECHO_E_ECHO)
|
||||
ECHO_E := $(ECHO_E_ECHO)
|
||||
endif
|
||||
ifeq ($(ECHO_E_ECHO_E_TAB),$(TAB))
|
||||
ECHO_E ?= $(ECHO_E_ECHO_E)
|
||||
ECHO_E := $(ECHO_E_ECHO_E)
|
||||
endif
|
||||
ifeq ($(ECHO_E_BIN_ECHO_TAB),$(TAB))
|
||||
ECHO_E ?= $(ECHO_E_BIN_ECHO)
|
||||
ECHO_E := $(ECHO_E_BIN_ECHO)
|
||||
endif
|
||||
ifeq ($(ECHO_E_BIN_ECHO_E_TAB),$(TAB))
|
||||
ECHO_E ?= $(ECHO_E_BIN_ECHO_E)
|
||||
ECHO_E := $(ECHO_E_BIN_ECHO_E)
|
||||
endif
|
||||
|
||||
.echocheck :
|
||||
@@ -86,20 +46,44 @@ else
|
||||
@$(ECHO) "No usable \"echo -e\" substitute found"
|
||||
@exit 1
|
||||
endif
|
||||
MAKEDEPS += .echocheck
|
||||
VERYCLEANUP += .echocheck
|
||||
|
||||
echo :
|
||||
@$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
|
||||
|
||||
# Build verbosity
|
||||
###############################################################################
|
||||
#
|
||||
# Determine host OS
|
||||
#
|
||||
HOST_OS := $(shell uname -s)
|
||||
hostos :
|
||||
@$(ECHO) $(HOST_OS)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Check for tools that can cause failed builds
|
||||
#
|
||||
.toolcheck :
|
||||
@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
|
||||
$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
|
||||
$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
|
||||
exit 1; \
|
||||
fi
|
||||
@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
|
||||
$(ECHO) 'Your Perl version has a Unicode handling bug'; \
|
||||
$(ECHO) 'Execute this command before compiling Etherboot:'; \
|
||||
$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
|
||||
exit 1; \
|
||||
fi
|
||||
@$(TOUCH) $@
|
||||
MAKEDEPS += .toolcheck
|
||||
VERYCLEANUP += .toolcheck
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Check for various tool workarounds
|
||||
#
|
||||
ifeq ($(V),1)
|
||||
Q =
|
||||
QM = @\#
|
||||
else
|
||||
Q = @
|
||||
QM = @
|
||||
endif
|
||||
|
||||
# Check for an old version of gas (binutils 2.9.1)
|
||||
#
|
||||
@@ -112,18 +96,154 @@ oldgas :
|
||||
# default, even when -ffreestanding is specified. We therefore need
|
||||
# to disable -fstack-protector if the compiler supports it.
|
||||
#
|
||||
SP_TEST = $(CC) -fno-stack-protector -x c -E - < /dev/null >/dev/null 2>&1
|
||||
SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
|
||||
-o /dev/null >/dev/null 2>&1
|
||||
SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
|
||||
CFLAGS += $(SP_FLAGS)
|
||||
|
||||
# compiler.h is needed for our linking and debugging system
|
||||
###############################################################################
|
||||
#
|
||||
CFLAGS += -include compiler.h
|
||||
# Build verbosity
|
||||
#
|
||||
ifeq ($(V),1)
|
||||
Q :=
|
||||
QM := @\#
|
||||
else
|
||||
Q := @
|
||||
QM := @
|
||||
endif
|
||||
|
||||
# config/%.h files are generated from config.h using mkconfig.pl
|
||||
config/%.h : config*.h
|
||||
$(MKCONFIG) config.h
|
||||
CLEANUP += config/*.h
|
||||
###############################################################################
|
||||
#
|
||||
# Set BIN according to whatever was specified on the command line as
|
||||
# the build target.
|
||||
#
|
||||
|
||||
# Determine how many different BIN directories are mentioned in the
|
||||
# make goals.
|
||||
#
|
||||
BIN_GOALS := $(filter bin/% bin-%,$(MAKECMDGOALS))
|
||||
BIN_GOAL_BINS := $(foreach BG,$(BIN_GOALS),$(firstword $(subst /, ,$(BG))))
|
||||
NUM_BINS := $(words $(sort $(BIN_GOAL_BINS)))
|
||||
|
||||
ifeq ($(NUM_BINS),0)
|
||||
|
||||
# No BIN directory was specified. Set BIN to "bin" as a sensible
|
||||
# default.
|
||||
|
||||
BIN := bin
|
||||
|
||||
else # NUM_BINS == 0
|
||||
|
||||
ifeq ($(NUM_BINS),1)
|
||||
|
||||
# If exactly one BIN directory was specified, set BIN to match this
|
||||
# directory.
|
||||
#
|
||||
BIN := $(firstword $(BIN_GOAL_BINS))
|
||||
|
||||
else # NUM_BINS == 1
|
||||
|
||||
# More than one BIN directory was specified. We cannot handle the
|
||||
# latter case within a single make invocation, so set up recursive
|
||||
# targets for each BIN directory.
|
||||
#
|
||||
# Leave $(BIN) undefined. This has implications for any target that
|
||||
# depends on $(BIN); such targets should be made conditional upon the
|
||||
# existence of $(BIN).
|
||||
#
|
||||
$(BIN_GOALS) : % : BIN_RECURSE
|
||||
$(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) $@
|
||||
.PHONY : BIN_RECURSE
|
||||
|
||||
endif # NUM_BINS == 1
|
||||
endif # NUM_BINS == 0
|
||||
|
||||
ifdef BIN
|
||||
|
||||
# Create $(BIN) directory if it doesn't exist yet
|
||||
#
|
||||
ifeq ($(wildcard $(BIN)),)
|
||||
$(shell $(MKDIR) -p $(BIN))
|
||||
endif
|
||||
|
||||
# Target to allow e.g. "make bin-efi arch"
|
||||
#
|
||||
$(BIN) :
|
||||
@# Do nothing, silently
|
||||
.PHONY : $(BIN)
|
||||
|
||||
# Remove everything in $(BIN) for a "make clean"
|
||||
#
|
||||
CLEANUP += $(BIN)/*.* # Avoid picking up directories
|
||||
|
||||
endif # defined(BIN)
|
||||
|
||||
# Determine whether or not we need to include the dependency files
|
||||
#
|
||||
NO_DEP_TARGETS := $(BIN) clean veryclean
|
||||
ifeq ($(MAKECMDGOALS),)
|
||||
NEED_DEPS := 1
|
||||
endif
|
||||
ifneq ($(strip $(filter-out $(NO_DEP_TARGETS),$(MAKECMDGOALS))),)
|
||||
NEED_DEPS := 1
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Select build architecture and platform based on $(BIN)
|
||||
#
|
||||
# BIN has the form bin[-[arch-]platform]
|
||||
|
||||
ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
|
||||
PLATFORMS := $(patsubst config/defaults/%.h,%,\
|
||||
$(wildcard config/defaults/*.h))
|
||||
archs :
|
||||
@$(ECHO) $(ARCHS)
|
||||
|
||||
platforms :
|
||||
@$(ECHO) $(PLATFORMS)
|
||||
|
||||
ifdef BIN
|
||||
|
||||
# Determine architecture portion of $(BIN), if present
|
||||
BIN_ARCH := $(strip $(foreach A,$(ARCHS),\
|
||||
$(patsubst bin-$(A)-%,$(A),\
|
||||
$(filter bin-$(A)-%,$(BIN)))))
|
||||
|
||||
# Determine platform portion of $(BIN), if present
|
||||
ifeq ($(BIN_ARCH),)
|
||||
BIN_PLATFORM := $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
|
||||
else
|
||||
BIN_PLATFORM := $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
|
||||
endif
|
||||
|
||||
# Determine build architecture
|
||||
DEFAULT_ARCH := i386
|
||||
ARCH := $(firstword $(BIN_ARCH) $(DEFAULT_ARCH))
|
||||
CFLAGS += -DARCH=$(ARCH)
|
||||
arch :
|
||||
@$(ECHO) $(ARCH)
|
||||
.PHONY : arch
|
||||
|
||||
# Determine build platform
|
||||
DEFAULT_PLATFORM := pcbios
|
||||
PLATFORM := $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
|
||||
CFLAGS += -DPLATFORM=$(PLATFORM)
|
||||
platform :
|
||||
@$(ECHO) $(PLATFORM)
|
||||
|
||||
endif # defined(BIN)
|
||||
|
||||
# Include architecture-specific Makefile
|
||||
ifdef ARCH
|
||||
MAKEDEPS += arch/$(ARCH)/Makefile
|
||||
include arch/$(ARCH)/Makefile
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Source file handling
|
||||
|
||||
# SRCDIRS lists all directories containing source files.
|
||||
srcdirs :
|
||||
@@ -144,6 +264,67 @@ AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
|
||||
autosrcs :
|
||||
@$(ECHO) $(AUTO_SRCS)
|
||||
|
||||
# Just about everything else in this section depends upon having
|
||||
# $(BIN) set
|
||||
|
||||
ifdef BIN
|
||||
|
||||
# Common flags
|
||||
#
|
||||
CFLAGS += -I include -I arch/$(ARCH)/include -I .
|
||||
CFLAGS += -Os -ffreestanding
|
||||
CFLAGS += -Wall -W -Wformat-nonliteral
|
||||
CFLAGS += -g
|
||||
CFLAGS += $(EXTRA_CFLAGS)
|
||||
ASFLAGS += $(EXTRA_ASFLAGS)
|
||||
LDFLAGS += $(EXTRA_LDFLAGS)
|
||||
|
||||
# Embedded image, if present
|
||||
#
|
||||
EMBEDDED_IMAGE = /dev/null
|
||||
|
||||
# Inhibit -Werror if NO_WERROR is specified on make command line
|
||||
#
|
||||
ifneq ($(NO_WERROR),1)
|
||||
CFLAGS += -Werror
|
||||
endif
|
||||
|
||||
# compiler.h is needed for our linking and debugging system
|
||||
#
|
||||
CFLAGS += -include compiler.h
|
||||
|
||||
# CFLAGS for specific object types
|
||||
#
|
||||
CFLAGS_c +=
|
||||
CFLAGS_S += -DASSEMBLY
|
||||
|
||||
# Base object name of the current target
|
||||
#
|
||||
OBJECT = $(firstword $(subst ., ,$(@F)))
|
||||
|
||||
# CFLAGS for specific object files. You can define
|
||||
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
|
||||
# compiling bin/rtl8139.o.
|
||||
#
|
||||
OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
|
||||
$(BIN)/%.flags :
|
||||
@$(ECHO) $(OBJ_CFLAGS)
|
||||
|
||||
# Rules for specific object types.
|
||||
#
|
||||
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
|
||||
RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
|
||||
RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
|
||||
RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
|
||||
RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
|
||||
|
||||
PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
|
||||
ASSEMBLE_S = $(AS) $(ASFLAGS)
|
||||
RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
|
||||
RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
|
||||
|
||||
DEBUG_TARGETS += dbg%.o c s
|
||||
|
||||
# We automatically generate rules for any file mentioned in AUTO_SRCS
|
||||
# using the following set of templates. It would be cleaner to use
|
||||
# $(eval ...), but this function exists only in GNU make >= 3.80.
|
||||
@@ -157,7 +338,7 @@ autosrcs :
|
||||
#
|
||||
define src_template
|
||||
|
||||
@$(ECHO) "Generating Makefile rules for $(1)"
|
||||
@$(ECHO) " [DEPS] $(1)"
|
||||
@$(MKDIR) -p $(dir $(2))
|
||||
@$(RM) $(2)
|
||||
@$(TOUCH) $(2)
|
||||
@@ -182,13 +363,13 @@ define obj_template
|
||||
-Wno-error -MM $(1) -MT "$(4)_DEPS" -MG -MP | \
|
||||
sed 's/_DEPS\s*:/_DEPS =/' >> $(2)
|
||||
@$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
|
||||
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \
|
||||
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
|
||||
'\n\t$$(RULE_$(3))\n' \
|
||||
'\nBOBJS += $$(BIN)/$(4).o\n' \
|
||||
$(foreach TGT,$(DEBUG_TARGETS), \
|
||||
$(if $(RULE_$(3)_to_$(TGT)), \
|
||||
'\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
|
||||
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \
|
||||
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
|
||||
'\n\t$$(RULE_$(3)_to_$(TGT))\n' \
|
||||
'\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
|
||||
'\n$(2) : $$($(4)_DEPS)\n' \
|
||||
@@ -205,7 +386,11 @@ $(BIN)/deps/%.d : % $(MAKEDEPS) $(PARSEROM)
|
||||
# Calculate and include the list of Makefile rules files
|
||||
#
|
||||
AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
|
||||
ifdef NEED_DEPS
|
||||
ifneq ($(AUTO_DEPS),)
|
||||
-include $(AUTO_DEPS)
|
||||
endif
|
||||
endif
|
||||
autodeps :
|
||||
@$(ECHO) $(AUTO_DEPS)
|
||||
VERYCLEANUP += $(BIN)/deps
|
||||
@@ -237,7 +422,7 @@ $(BIN)/NIC : $(AUTO_DEPS)
|
||||
'it is only for rom-o-matic' >> $@
|
||||
@$(ECHO) >> $@
|
||||
@perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
|
||||
CLEANUP += $(BIN)/NIC
|
||||
CLEANUP += $(BIN)/NIC # Doesn't match the $(BIN)/*.* pattern
|
||||
|
||||
# Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
|
||||
# derive the variables:
|
||||
@@ -342,8 +527,13 @@ $(BIN)/%.info :
|
||||
# in order to correctly rebuild blib whenever the list of objects
|
||||
# changes.
|
||||
#
|
||||
BLIB_LIST = $(BIN)/.blib.list
|
||||
ifneq ($(shell cat $(BLIB_LIST)),$(BLIB_OBJS))
|
||||
BLIB_LIST := $(BIN)/.blib.list
|
||||
ifeq ($(wildcard $(BLIB_LIST)),)
|
||||
BLIB_LIST_OBJS :=
|
||||
else
|
||||
BLIB_LIST_OBJS := $(shell cat $(BLIB_LIST))
|
||||
endif
|
||||
ifneq ($(BLIB_LIST_OBJS),$(BLIB_OBJS))
|
||||
$(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
|
||||
endif
|
||||
|
||||
@@ -396,10 +586,6 @@ $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
|
||||
$(QM)$(ECHO) " [ZBIN] $@"
|
||||
$(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
|
||||
|
||||
# Build bochs symbol table
|
||||
$(BIN)/%.bxs : $(BIN)/%.tmp
|
||||
$(NM) $< | cut -d" " -f1,3 > $@
|
||||
|
||||
# Rules for each media format. These are generated and placed in an
|
||||
# external Makefile fragment. We could do this via $(eval ...), but
|
||||
# that would require make >= 3.80.
|
||||
@@ -435,7 +621,7 @@ automedia :
|
||||
#
|
||||
define media_template
|
||||
|
||||
@$(ECHO) "Generating Makefile rules for $(1) media"
|
||||
@$(ECHO) " [MEDIADEPS] $(1)"
|
||||
@$(MKDIR) -p $(dir $(2))
|
||||
@$(RM) $(2)
|
||||
@$(TOUCH) $(2)
|
||||
@@ -459,7 +645,20 @@ $(BIN)/deps/%.media.d : $(MAKEDEPS)
|
||||
MEDIA_DEPS = $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
|
||||
mediadeps :
|
||||
@$(ECHO) $(MEDIA_DEPS)
|
||||
ifdef NEED_DEPS
|
||||
ifneq ($(MEDIA_DEPS),)
|
||||
-include $(MEDIA_DEPS)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Wrap up binary blobs (for embedded images)
|
||||
#
|
||||
$(BIN)/%.o : payload/%.img
|
||||
$(QM)echo " [WRAP] $@"
|
||||
$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
|
||||
--defsym obj_$*=0
|
||||
|
||||
BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
|
||||
|
||||
# The "allXXXs" targets for each suffix
|
||||
#
|
||||
@@ -472,15 +671,23 @@ allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%
|
||||
$(BIN)/etherboot.% : $(BIN)/gpxe.%
|
||||
ln -sf $(notdir $<) $@
|
||||
|
||||
# Wrap up binary blobs
|
||||
endif # defined(BIN)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
$(BIN)/%.o : payload/%.img
|
||||
$(QM)echo " [WRAP] $@"
|
||||
$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
|
||||
--defsym obj_$*=0
|
||||
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
|
||||
# the automatic build system and varies by target; it includes the
|
||||
# "-p 0x1234,0x5678" string to set the PCI IDs.
|
||||
#
|
||||
FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
|
||||
-i$(IDENT) -s 0 $@
|
||||
|
||||
BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
|
||||
# Some ROMs require specific flags to be passed to makerom.pl
|
||||
#
|
||||
MAKEROM_FLAGS_3c503 = -3
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# The compression utilities
|
||||
#
|
||||
$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
|
||||
@@ -494,6 +701,17 @@ $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
|
||||
$(Q)$(HOST_CC) -O2 -o $@ $<
|
||||
CLEANUP += $(ZBIN)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# The EFI custom linker
|
||||
#
|
||||
$(EFILINK) : util/efilink.c $(MAKEDEPS)
|
||||
$(QM)$(ECHO) " [HOSTCC] $@"
|
||||
$(Q)$(HOST_CC) -O2 -o $@ $< -lbfd -liberty
|
||||
CLEANUP += $(EFILINK)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Auto-incrementing build serial number. Append "bs" to your list of
|
||||
# build targets to get a serial number printed at the end of the
|
||||
# build. Enable -DBUILD_SERIAL in order to see it when the code runs.
|
||||
@@ -517,27 +735,30 @@ bs : $(BUILDSERIAL_NOW)
|
||||
@$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
|
||||
@$(ECHO) "Build serial number is $(shell cat $<)"
|
||||
|
||||
# List of available architectures
|
||||
###############################################################################
|
||||
#
|
||||
ARCHS = $(filter-out CVS,$(patsubst arch/%,%,$(wildcard arch/*)))
|
||||
archs :
|
||||
@$(ECHO) $(ARCHS)
|
||||
|
||||
OTHER_ARCHS = $(filter-out $(ARCH),$(ARCHS))
|
||||
otherarchs :
|
||||
@$(ECHO) $(OTHER_ARCHS)
|
||||
|
||||
# Build the TAGS file for emacs
|
||||
# Build the TAGS file(s) for emacs
|
||||
#
|
||||
TAGS : TAGS.$(ARCH)
|
||||
TAGS :
|
||||
ctags -e -R -f $@ --exclude=bin
|
||||
|
||||
TAGS.$(ARCH) :
|
||||
ctags -e -R -f $@ --exclude=bin \
|
||||
$(foreach ARCH,$(OTHER_ARCHS),--exclude=arch/$(ARCH))
|
||||
CLEANUP += TAGS*
|
||||
CLEANUP += TAGS
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Force rebuild for any given target
|
||||
#
|
||||
%.rebuild :
|
||||
rm -f $*
|
||||
$(Q)$(MAKE) $*
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Symbol table checks
|
||||
#
|
||||
|
||||
ifdef BIN
|
||||
|
||||
SYMTAB = $(BIN)/symtab
|
||||
$(SYMTAB) : $(BLIB)
|
||||
$(OBJDUMP) -w -t $< > $@
|
||||
@@ -547,14 +768,27 @@ CLEANUP += $(BIN)/symtab
|
||||
symcheck : $(SYMTAB)
|
||||
$(SYMCHECK) $<
|
||||
|
||||
# Force rebuild for any given target
|
||||
#
|
||||
$(BIN)/%.rebuild :
|
||||
rm -f $(BIN)/$*
|
||||
$(MAKE) $(MAKEFLAGS) $(BIN)/$*
|
||||
endif # defined(BIN)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Build bochs symbol table
|
||||
#
|
||||
|
||||
ifdef BIN
|
||||
|
||||
$(BIN)/%.bxs : $(BIN)/%.tmp
|
||||
$(NM) $< | cut -d" " -f1,3 > $@
|
||||
|
||||
endif # defined(BIN)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Documentation
|
||||
#
|
||||
|
||||
ifdef BIN
|
||||
|
||||
$(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
|
||||
$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
|
||||
-e 's{\@BIN\@}{$(BIN)}; ' \
|
||||
@@ -578,6 +812,10 @@ docview :
|
||||
$(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
|
||||
fi
|
||||
|
||||
endif # defined(BIN)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Clean-up
|
||||
#
|
||||
clean :
|
||||
@@ -585,19 +823,3 @@ clean :
|
||||
|
||||
veryclean : clean
|
||||
$(RM) -r $(VERYCLEANUP)
|
||||
|
||||
# Make clean tarballs for release
|
||||
|
||||
tarball : ../VERSION
|
||||
($(ECHO) -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
|
||||
$(RM) -r /tmp/$(USER)/gpxe-$(VERSION)
|
||||
mkdir -p /tmp/$(USER)/gpxe-$(VERSION)
|
||||
cp -rP .. /tmp/$(USER)/gpxe-$(VERSION)
|
||||
( cd /tmp/$(USER)/gpxe-$(VERSION)/src ; $(MAKE) veryclean ; $(RM) -r bin/deps )
|
||||
( cd /tmp/$(USER); tar cf /tmp/$(USER)/gpxe-$(VERSION).tar --exclude ".git*" --exclude "#*" \
|
||||
--exclude "*~" gpxe-$(VERSION) )
|
||||
bzip2 -9 < /tmp/$(USER)/gpxe-$(VERSION).tar > /tmp/$(USER)/gpxe-$(VERSION).tar.bz2
|
||||
gzip -9 < /tmp/$(USER)/gpxe-$(VERSION).tar > /tmp/$(USER)/gpxe-$(VERSION).tar.gz
|
||||
$(RM) -r /tmp/$(USER)/gpxe-$(VERSION)
|
||||
$(RM) /tmp/$(USER)/gpxe-$(VERSION).tar
|
||||
( cd /tmp/$(USER) ; tar -zxf /tmp/$(USER)/gpxe-$(VERSION).tar.gz )
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
# -*- makefile -*-
|
||||
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
#
|
||||
# IMPORTANT!
|
||||
#
|
||||
# The use of this file to set options that affect only single object
|
||||
# files is deprecated, because changing anything in this file results
|
||||
# in a complete rebuild, which is slow. All options are gradually
|
||||
# being migrated to config.h, which does not suffer from this problem.
|
||||
#
|
||||
# Only options that affect the entire build (e.g. overriding the $(CC)
|
||||
# Makefile variable) should be placed in here.
|
||||
#
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
|
||||
|
||||
# Config for i386 Etherboot
|
||||
#
|
||||
# Do not delete the tag OptionDescription and /OptionDescription
|
||||
# It is used to automatically generate the documentation.
|
||||
#
|
||||
# @OptionDescrition@
|
||||
#
|
||||
# BIOS interface options:
|
||||
#
|
||||
# -DPCBIOS
|
||||
# Compile in support for the normal pcbios
|
||||
# -DLINUXBIOS
|
||||
# Compile in support for LinuxBIOS
|
||||
# -DBBS_BUT_NOT_PNP_COMPLIANT
|
||||
# Some BIOSes claim to be PNP but they don't conform
|
||||
# to the BBS spec which specifies that ES:DI must
|
||||
# point to the string $PnP on entry. This option
|
||||
# works around those. This option must be added to
|
||||
# LCONFIG.
|
||||
# -DNO_DELAYED_INT
|
||||
# Take control as soon as BIOS detects the ROM.
|
||||
# Normally hooks onto INT18H or INT19H. Use only if you
|
||||
# have a very non-conformant BIOS as it bypasses
|
||||
# BIOS initialisation of devices. This only works for
|
||||
# legacy ROMs, i.e. PCI_PNP_HEADER not defined.
|
||||
# This option was formerly called NOINT19H.
|
||||
# -DBOOT_INT18H
|
||||
# Etherboot normally hooks onto INT19H for legacy ROMs.
|
||||
# You can choose to hook onto INT18H (BASIC interpreter
|
||||
# entry point) instead. This entry point is used when
|
||||
# all boot devices have been exhausted. This option must
|
||||
# be added to LCONFIG.
|
||||
# -DCONFIG_PCI_DIRECT
|
||||
# Define this for PCI BIOSes that do not implement
|
||||
# BIOS32 or not correctly. Normally not needed.
|
||||
# Only works for BIOSes of a certain era.
|
||||
# -DCONFIG_TSC_CURRTICKS
|
||||
# Uses the processor time stamp counter instead of reading
|
||||
# the BIOS time counter. This allows Etherboot to work
|
||||
# even without a BIOS. This only works on late model
|
||||
# 486s and above.
|
||||
# -DCONFIG_NO_TIMER2
|
||||
# Some systems do not have timer2 implemented.
|
||||
# If you have a RTC this will allow you to roughly calibrate
|
||||
# it using outb instructions.
|
||||
#
|
||||
# Extended cpu options
|
||||
|
||||
# -DCONFIG_X86_64
|
||||
# Compile in support for booting x86_64 64bit binaries.
|
||||
#
|
||||
# PXE loader options:
|
||||
#
|
||||
# -DPXELOADER_KEEP_ALL
|
||||
# Prevent PXE loader (prefix) from unloading the
|
||||
# PXE stack. You will want to use this if, for
|
||||
# example, you are booting via PXE-on-floppy.
|
||||
# You may want to use it under certain
|
||||
# circumstances when using the Etherboot UNDI
|
||||
# driver; these are complex and best practice is
|
||||
# not yet established.
|
||||
#
|
||||
# Obscure options you probably don't need to touch:
|
||||
#
|
||||
# -DIGNORE_E820_MAP
|
||||
# Ignore the memory map returned by the E820 BIOS
|
||||
# call. May be necessary on some buggy BIOSes.
|
||||
# -DT503_AUI
|
||||
# Use AUI by default on 3c503 cards.
|
||||
# -DFLATTEN_REAL_MODE
|
||||
# Use 4GB segment limits when calling out to or
|
||||
# returning to real-mode code. This is necessary to
|
||||
# work around some buggy code (e.g. OpenBSD's pxeboot)
|
||||
# that uses flat real-mode without being sufficiently
|
||||
# paranoid about the volatility of its segment limits.
|
||||
|
||||
#
|
||||
# @/OptionDescription@
|
||||
|
||||
# BIOS select don't change unless you know what you are doing
|
||||
# CFLAGS+= -DPCBIOS
|
||||
|
||||
# Compile in k8/hammer support
|
||||
# CFLAGS+= -DCONFIG_X86_64
|
||||
|
||||
# Options to make a version of Etherboot that will work under linuxBIOS.
|
||||
# CFLAGS+= -DLINUXBIOS -DCONFIG_TSC_CURRTICKS -DCONSOLE_SERIAL -DCOMCONSOLE=0x3f8 -DCOMPRESERVE -DCONFIG_PCI_DIRECT -DELF_IMAGE
|
||||
|
||||
# These options affect the loader that is prepended to the Etherboot image
|
||||
# LCONFIG+= -DBBS_BUT_NOT_PNP_COMPLIANT
|
||||
# LCONFIG+= -DBOOT_INT18H
|
||||
|
||||
# Produce code that will work with OpenBSD's pxeboot
|
||||
# CFLAGS+= -DFLATTEN_REAL_MODE
|
||||
|
||||
CFLAGS+= -fstrength-reduce -fomit-frame-pointer -march=i386
|
||||
# Squeeze the code in as little space as possible.
|
||||
# gcc3 needs a different syntax to gcc2 if you want to avoid spurious warnings.
|
||||
GCC_VERSION = $(subst ., ,$(shell $(CC) -dumpversion))
|
||||
GCC_MAJORVERSION = $(firstword $(GCC_VERSION))
|
||||
ifeq ($(GCC_MAJORVERSION),2)
|
||||
CFLAGS+= -malign-jumps=1 -malign-loops=1 -malign-functions=1
|
||||
else
|
||||
CFLAGS+= -falign-jumps=1 -falign-loops=1 -falign-functions=1
|
||||
endif
|
||||
|
||||
# this is almost always a win. the kernel uses it, too.
|
||||
CFLAGS+= -mpreferred-stack-boundary=2
|
||||
|
||||
# use regparm for all functions - C functions called from assembly (or
|
||||
# vice versa) need __cdecl now
|
||||
CFLAGS+= -mregparm=3
|
||||
|
||||
# use -mrtd (same __cdecl requirements as above)
|
||||
CFLAGS+= -mrtd
|
||||
|
||||
# this is the logical complement to -mregparm=3.
|
||||
# it doesn't currently buy us anything, but if anything ever tries
|
||||
# to return small structures, let's be prepared
|
||||
CFLAGS+= -freg-struct-return
|
||||
|
||||
LDFLAGS+= -N --no-check-sections
|
||||
|
||||
ifeq "$(shell uname -s)" "FreeBSD"
|
||||
CFLAGS+= -DIMAGE_FREEBSD -DELF_IMAGE -DAOUT_IMAGE
|
||||
endif
|
||||
|
||||
# An alternate location for isolinux.bin can be set here
|
||||
# ISOLINUX_BIN=/path/to/isolinux.bin
|
||||
+70
-66
@@ -1,3 +1,59 @@
|
||||
# Force i386-only instructions
|
||||
#
|
||||
CFLAGS += -march=i386
|
||||
|
||||
# Code size reduction.
|
||||
#
|
||||
CFLAGS += -fstrength-reduce -fomit-frame-pointer
|
||||
|
||||
# Code size reduction. gcc3 needs a different syntax to gcc2 if you
|
||||
# want to avoid spurious warnings.
|
||||
#
|
||||
GCC_VERSION := $(subst ., ,$(shell $(CC) -dumpversion))
|
||||
GCC_MAJOR := $(firstword $(GCC_VERSION))
|
||||
ifeq ($(GCC_MAJOR),2)
|
||||
CFLAGS += -malign-jumps=1 -malign-loops=1 -malign-functions=1
|
||||
else
|
||||
CFLAGS += -falign-jumps=1 -falign-loops=1 -falign-functions=1
|
||||
endif
|
||||
|
||||
# Code size reduction. This is almost always a win. The kernel uses it, too.
|
||||
#
|
||||
CFLAGS += -mpreferred-stack-boundary=2
|
||||
|
||||
# Code size reduction. Use regparm for all functions - C functions
|
||||
# called from assembly (or vice versa) need __asmcall now
|
||||
#
|
||||
CFLAGS += -mregparm=3
|
||||
|
||||
# Code size reduction. Use -mrtd (same __asmcall requirements as above)
|
||||
CFLAGS += -mrtd
|
||||
|
||||
# Code size reduction. This is the logical complement to -mregparm=3.
|
||||
# It doesn't currently buy us anything, but if anything ever tries to
|
||||
# return small structures, let's be prepared
|
||||
#
|
||||
CFLAGS += -freg-struct-return
|
||||
|
||||
# Force 32-bit code even on an x86-64 machine
|
||||
#
|
||||
CFLAGS += -m32
|
||||
ASFLAGS += --32
|
||||
ifeq ($(HOST_OS),FreeBSD)
|
||||
LDFLAGS += -m elf_i386_fbsd
|
||||
else
|
||||
LDFLAGS += -m elf_i386
|
||||
endif
|
||||
|
||||
# EFI requires -fshort-wchar, and nothing else currently uses wchar_t
|
||||
#
|
||||
CFLAGS += -fshort-wchar
|
||||
|
||||
# We need to undefine the default macro "i386" when compiling .S
|
||||
# files, otherwise ".arch i386" translates to ".arch 1"...
|
||||
#
|
||||
CFLAGS += -Ui386
|
||||
|
||||
# Locations of utilities
|
||||
#
|
||||
ISOLINUX_BIN = /usr/lib/syslinux/isolinux.bin
|
||||
@@ -12,6 +68,7 @@ SRCDIRS += arch/i386/drivers/net
|
||||
SRCDIRS += arch/i386/interface/pcbios
|
||||
SRCDIRS += arch/i386/interface/pxe
|
||||
SRCDIRS += arch/i386/interface/syslinux
|
||||
SRCDIRS += arch/i386/interface/efi
|
||||
|
||||
# The various xxx_loader.c files are #included into core/loader.c and
|
||||
# should not be compiled directly.
|
||||
@@ -22,85 +79,32 @@ NON_AUTO_SRCS += arch/i386/core/wince_loader.c
|
||||
|
||||
# unnrv2b.S is used to generate a 16-bit as well as a 32-bit object.
|
||||
#
|
||||
OBJS_unnrv2b = unnrv2b unnrv2b16
|
||||
CFLAGS_unnrv2b16 = -DCODE16
|
||||
OBJS_unnrv2b = unnrv2b unnrv2b16
|
||||
CFLAGS_unnrv2b16 = -DCODE16
|
||||
|
||||
# We need to undefine the default macro "i386" when compiling .S
|
||||
# files, otherwise ".arch i386" translates to ".arch 1"...
|
||||
# Include platform-specific Makefile
|
||||
#
|
||||
CFLAGS_S += -Ui386
|
||||
|
||||
# The i386 linker script
|
||||
#
|
||||
LDSCRIPT = arch/i386/scripts/i386.lds
|
||||
|
||||
# Media types.
|
||||
#
|
||||
MEDIA += rom
|
||||
MEDIA += pxe
|
||||
MEDIA += kpxe
|
||||
MEDIA += elf
|
||||
MEDIA += elfd
|
||||
MEDIA += lmelf
|
||||
MEDIA += lmelfd
|
||||
MEDIA += lkrn
|
||||
MEDIA += bImage
|
||||
MEDIA += dsk
|
||||
MEDIA += nbi
|
||||
MEDIA += hd
|
||||
MEDIA += raw
|
||||
MEDIA += com
|
||||
MEDIA += exe
|
||||
|
||||
# Special target for building Master Boot Record binary
|
||||
$(BIN)/mbr.bin : $(BIN)/mbr.o
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
MAKEDEPS += arch/i386/Makefile.$(PLATFORM)
|
||||
include arch/i386/Makefile.$(PLATFORM)
|
||||
|
||||
# Some suffixes (e.g. %.fd0) are generated directly from other
|
||||
# finished files (e.g. %.dsk), rather than having their own prefix.
|
||||
|
||||
# rule to write disk images to /dev/fd0
|
||||
NON_AUTO_MEDIA += fd0
|
||||
NON_AUTO_MEDIA += fd0
|
||||
%fd0 : %dsk
|
||||
dd if=$< bs=512 conv=sync of=/dev/fd0
|
||||
sync
|
||||
$(QM)$(ECHO) " [DD] $@"
|
||||
$(Q)dd if=$< bs=512 conv=sync of=/dev/fd0
|
||||
$(Q)sync
|
||||
|
||||
# rule to create padded disk images
|
||||
NON_AUTO_MEDIA += pdsk
|
||||
NON_AUTO_MEDIA += pdsk
|
||||
%pdsk : %dsk
|
||||
cp $< $@
|
||||
$(PERL) ./util/dskpad.pl $@
|
||||
|
||||
# rule to make a non-emulation ISO boot image
|
||||
NON_AUTO_MEDIA += iso
|
||||
%iso: %lkrn util/geniso
|
||||
ISOLINUX_BIN=$(ISOLINUX_BIN) bash util/geniso $@ $<
|
||||
|
||||
# rule to make a floppy emulation ISO boot image
|
||||
NON_AUTO_MEDIA += liso
|
||||
%liso: %lkrn util/genliso
|
||||
bash util/genliso $@ $<
|
||||
|
||||
# rule to make a USB disk image
|
||||
$(BIN)/usbdisk.bin : $(BIN)/usbdisk.o
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
NON_AUTO_MEDIA += usb
|
||||
%usb: $(BIN)/usbdisk.bin %hd
|
||||
cat $^ > $@
|
||||
$(QM)$(ECHO) " [DSKPAD] $@"
|
||||
$(Q)cp $< $@
|
||||
$(Q)$(PERL) ./util/dskpad.pl $@
|
||||
|
||||
# Add NON_AUTO_MEDIA to the media list, so that they show up in the
|
||||
# output of "make"
|
||||
#
|
||||
MEDIA += $(NON_AUTO_MEDIA)
|
||||
|
||||
# Shortcut to allow typing just
|
||||
# make bin-kir/%
|
||||
# rather than
|
||||
# make -f arch/i386/kir-Makefile bin-kir/%
|
||||
# for building a KEEP_IT_REAL flavour.
|
||||
#
|
||||
$(BIN)-kir/% : kir-target
|
||||
$(MAKE) -f arch/i386/kir-Makefile $(MAKECMDGOALS)
|
||||
|
||||
.PHONY : kir-target
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||
|
||||
# The EFI linker script
|
||||
#
|
||||
LDSCRIPT = arch/i386/scripts/efi.lds
|
||||
|
||||
# Use a relocatable link; we perform final relocations in the efilink utility.
|
||||
#
|
||||
LDFLAGS += -r -d -S
|
||||
|
||||
# Media types.
|
||||
#
|
||||
NON_AUTO_MEDIA += efi
|
||||
|
||||
# Rule for building EFI files
|
||||
#
|
||||
$(BIN)/%.efi.tmp-reloc : $(BIN)/%.efi.tmp $(EFILINK)
|
||||
$(QM)$(ECHO) " [EFILINK] $@"
|
||||
$(Q)$(LD) -e 0 -o /dev/null $< # Check for unresolved symbols
|
||||
$(Q)$(EFILINK) $< $@
|
||||
|
||||
$(BIN)/%.efi : $(BIN)/%.efi.tmp-reloc
|
||||
$(QM)$(ECHO) " [FINISH] $@"
|
||||
$(Q)$(OBJCOPY) -Obinary $< $@
|
||||
@@ -0,0 +1,54 @@
|
||||
# -*- makefile -*- : Force emacs to use Makefile mode
|
||||
|
||||
# The i386 linker script
|
||||
#
|
||||
LDSCRIPT = arch/i386/scripts/i386.lds
|
||||
|
||||
# Stop ld from complaining about our customised linker script
|
||||
#
|
||||
LDFLAGS += -N --no-check-sections
|
||||
|
||||
# Media types.
|
||||
#
|
||||
MEDIA += rom
|
||||
MEDIA += pxe
|
||||
MEDIA += kpxe
|
||||
MEDIA += elf
|
||||
MEDIA += elfd
|
||||
MEDIA += lmelf
|
||||
MEDIA += lmelfd
|
||||
MEDIA += lkrn
|
||||
MEDIA += bImage
|
||||
MEDIA += dsk
|
||||
MEDIA += nbi
|
||||
MEDIA += hd
|
||||
MEDIA += raw
|
||||
MEDIA += com
|
||||
MEDIA += exe
|
||||
|
||||
# rule to make a non-emulation ISO boot image
|
||||
NON_AUTO_MEDIA += iso
|
||||
%iso: %lkrn util/geniso
|
||||
$(QM)$(ECHO) " [GENISO] $@"
|
||||
$(Q)ISOLINUX_BIN=$(ISOLINUX_BIN) bash util/geniso $@ $<
|
||||
|
||||
# rule to make a floppy emulation ISO boot image
|
||||
NON_AUTO_MEDIA += liso
|
||||
%liso: %lkrn util/genliso
|
||||
$(QM)$(ECHO) " [GENLISO] $@"
|
||||
$(Q)bash util/genliso $@ $<
|
||||
|
||||
# Special target for building Master Boot Record binary
|
||||
$(BIN)/mbr.bin : $(BIN)/mbr.o
|
||||
$(QM)$(ECHO) " [OBJCOPY] $@"
|
||||
$(Q)$(OBJCOPY) -O binary $< $@
|
||||
|
||||
# rule to make a USB disk image
|
||||
$(BIN)/usbdisk.bin : $(BIN)/usbdisk.o
|
||||
$(QM)$(ECHO) " [OBJCOPY] $@"
|
||||
$(Q)$(OBJCOPY) -O binary $< $@
|
||||
|
||||
NON_AUTO_MEDIA += usb
|
||||
%usb: $(BIN)/usbdisk.bin %hd
|
||||
$(QM)$(ECHO) " [FINISH] $@"
|
||||
$(Q)cat $^ > $@
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <realmode.h>
|
||||
|
||||
void __asmcall _dump_regs ( struct i386_all_regs *ix86 ) {
|
||||
|
||||
__asm__ __volatile__ (
|
||||
TEXT16_CODE ( ".globl dump_regs\n\t"
|
||||
"\ndump_regs:\n\t"
|
||||
"pushl $_dump_regs\n\t"
|
||||
"pushw %%cs\n\t"
|
||||
"call prot_call\n\t"
|
||||
"addr32 leal 4(%%esp), %%esp\n\t"
|
||||
"ret\n\t" ) : : );
|
||||
|
||||
printf ( "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
|
||||
"ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n"
|
||||
"CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x\n",
|
||||
ix86->regs.eax, ix86->regs.ebx, ix86->regs.ecx,
|
||||
ix86->regs.edx, ix86->regs.esi, ix86->regs.edi,
|
||||
ix86->regs.ebp, ix86->regs.esp,
|
||||
ix86->segs.cs, ix86->segs.ss, ix86->segs.ds,
|
||||
ix86->segs.es, ix86->segs.fs, ix86->segs.gs );
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* Interrupt Descriptor Table (IDT) setup and interrupt handlers for GDB stub.
|
||||
*/
|
||||
|
||||
#include <virtaddr.h>
|
||||
#include <librm.h>
|
||||
|
||||
#define SIZEOF_I386_REGS 32
|
||||
#define SIZEOF_I386_FLAGS 4
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <virtaddr.h>
|
||||
#include <gpxe/uaccess.h>
|
||||
#include <gpxe/gdbstub.h>
|
||||
#include <gdbmach.h>
|
||||
|
||||
@@ -60,10 +60,10 @@ static struct hwbp *gdbmach_find_hwbp ( int type, unsigned long addr, size_t len
|
||||
}
|
||||
|
||||
static void gdbmach_commit_hwbp ( struct hwbp *bp ) {
|
||||
int regnum = bp - hwbps;
|
||||
unsigned int regnum = bp - hwbps;
|
||||
|
||||
/* Set breakpoint address */
|
||||
assert ( regnum >= 0 && regnum < sizeof hwbps / sizeof hwbps [ 0 ] );
|
||||
assert ( regnum < ( sizeof hwbps / sizeof hwbps [ 0 ] ) );
|
||||
switch ( regnum ) {
|
||||
case 0:
|
||||
__asm__ __volatile__ ( "movl %0, %%dr0\n" : : "r" ( bp->addr ) );
|
||||
@@ -142,7 +142,7 @@ static void gdbmach_enable_hwbps ( void ) {
|
||||
__asm__ __volatile__ ( "movl %0, %%dr7\n" : : "r" ( dr7 ) );
|
||||
}
|
||||
|
||||
__cdecl void gdbmach_handler ( int signo, gdbreg_t *regs ) {
|
||||
__asmcall void gdbmach_handler ( int signo, gdbreg_t *regs ) {
|
||||
gdbmach_disable_hwbps();
|
||||
gdbstub_handler ( signo, regs );
|
||||
gdbmach_enable_hwbps();
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
#include <realmode.h>
|
||||
#include <bios.h>
|
||||
|
||||
/**************************************************************************
|
||||
* Save power by halting the CPU until the next interrupt
|
||||
**************************************************************************/
|
||||
void cpu_nap ( void ) {
|
||||
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
||||
"hlt\n\t"
|
||||
"cli\n\t" ) : : );
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include <gpxe/pci.h>
|
||||
#include <pcidirect.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
@@ -36,3 +35,10 @@ void pcidirect_prepare ( struct pci_device *pci, int where ) {
|
||||
( where & ~3 ) ), PCIDIRECT_CONFIG_ADDRESS );
|
||||
}
|
||||
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_max_bus );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_byte );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_word );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_dword );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_byte );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_word );
|
||||
PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_dword );
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gpxe/io.h>
|
||||
#include <pic8259.h>
|
||||
|
||||
/** @file
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/** @file
|
||||
*
|
||||
* RDTSC timer
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <gpxe/timer.h>
|
||||
#include <gpxe/timer2.h>
|
||||
|
||||
/**
|
||||
* Number of TSC ticks per microsecond
|
||||
*
|
||||
* This is calibrated on the first use of the timer.
|
||||
*/
|
||||
static unsigned long rdtsc_ticks_per_usec;
|
||||
|
||||
/**
|
||||
* Delay for a fixed number of microseconds
|
||||
*
|
||||
* @v usecs Number of microseconds for which to delay
|
||||
*/
|
||||
static void rdtsc_udelay ( unsigned long usecs ) {
|
||||
unsigned long start;
|
||||
unsigned long elapsed;
|
||||
|
||||
/* Sanity guard, since we may divide by this */
|
||||
if ( ! usecs )
|
||||
usecs = 1;
|
||||
|
||||
start = currticks();
|
||||
if ( rdtsc_ticks_per_usec ) {
|
||||
/* Already calibrated; busy-wait until done */
|
||||
do {
|
||||
elapsed = ( currticks() - start );
|
||||
} while ( elapsed < ( usecs * rdtsc_ticks_per_usec ) );
|
||||
} else {
|
||||
/* Not yet calibrated; use timer2 and calibrate
|
||||
* based on result.
|
||||
*/
|
||||
timer2_udelay ( usecs );
|
||||
elapsed = ( currticks() - start );
|
||||
rdtsc_ticks_per_usec = ( elapsed / usecs );
|
||||
DBG ( "RDTSC timer calibrated: %ld ticks in %ld usecs "
|
||||
"(%ld MHz)\n", elapsed, usecs,
|
||||
( rdtsc_ticks_per_usec << TSC_SHIFT ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of ticks per second
|
||||
*
|
||||
* @ret ticks_per_sec Number of ticks per second
|
||||
*/
|
||||
static unsigned long rdtsc_ticks_per_sec ( void ) {
|
||||
|
||||
/* Calibrate timer, if not already done */
|
||||
if ( ! rdtsc_ticks_per_usec )
|
||||
udelay ( 1 );
|
||||
|
||||
/* Sanity check */
|
||||
assert ( rdtsc_ticks_per_usec != 0 );
|
||||
|
||||
return ( rdtsc_ticks_per_usec * 1000 * 1000 );
|
||||
}
|
||||
|
||||
PROVIDE_TIMER ( rdtsc, udelay, rdtsc_udelay );
|
||||
PROVIDE_TIMER_INLINE ( rdtsc, currticks );
|
||||
PROVIDE_TIMER ( rdtsc, ticks_per_sec, rdtsc_ticks_per_sec );
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <io.h>
|
||||
#include <gpxe/io.h>
|
||||
#include <registers.h>
|
||||
#include <gpxe/memmap.h>
|
||||
|
||||
@@ -18,8 +18,8 @@ extern char _max_align[];
|
||||
#define max_align ( ( unsigned int ) _max_align )
|
||||
|
||||
/* Linker symbols */
|
||||
extern char _text[];
|
||||
extern char _end[];
|
||||
extern char _textdata[];
|
||||
extern char _etextdata[];
|
||||
|
||||
/* within 1MB of 4GB is too close.
|
||||
* MAX_ADDR is the maximum address we can easily do DMA to.
|
||||
@@ -39,7 +39,7 @@ extern char _end[];
|
||||
* address space, and returns the physical address of the new location
|
||||
* to the prefix in %edi.
|
||||
*/
|
||||
__cdecl void relocate ( struct i386_all_regs *ix86 ) {
|
||||
__asmcall void relocate ( struct i386_all_regs *ix86 ) {
|
||||
struct memory_map memmap;
|
||||
unsigned long start, end, size, padded_size;
|
||||
unsigned long new_start, new_end;
|
||||
@@ -47,8 +47,8 @@ __cdecl void relocate ( struct i386_all_regs *ix86 ) {
|
||||
|
||||
/* Get memory map and current location */
|
||||
get_memmap ( &memmap );
|
||||
start = virt_to_phys ( _text );
|
||||
end = virt_to_phys ( _end );
|
||||
start = virt_to_phys ( _textdata );
|
||||
end = virt_to_phys ( _etextdata );
|
||||
size = ( end - start );
|
||||
padded_size = ( size + max_align - 1 );
|
||||
|
||||
|
||||
@@ -1,325 +0,0 @@
|
||||
#include "virtaddr.h"
|
||||
|
||||
.equ MSR_K6_EFER, 0xC0000080
|
||||
.equ EFER_LME, 0x00000100
|
||||
.equ X86_CR4_PAE, 0x00000020
|
||||
.equ CR0_PG, 0x80000000
|
||||
|
||||
#ifdef GAS291
|
||||
#define DATA32 data32;
|
||||
#define ADDR32 addr32;
|
||||
#define LJMPI(x) ljmp x
|
||||
#else
|
||||
#define DATA32 data32
|
||||
#define ADDR32 addr32
|
||||
/* newer GAS295 require #define LJMPI(x) ljmp *x */
|
||||
#define LJMPI(x) ljmp x
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: if you write a subroutine that is called from C code (gcc/egcs),
|
||||
* then you only have to take care of %ebx, %esi, %edi and %ebp. These
|
||||
* registers must not be altered under any circumstance. All other registers
|
||||
* may be clobbered without any negative side effects. If you don't follow
|
||||
* this rule then you'll run into strange effects that only occur on some
|
||||
* gcc versions (because the register allocator may use different registers).
|
||||
*
|
||||
* All the data32 prefixes for the ljmp instructions are necessary, because
|
||||
* the assembler emits code with a relocation address of 0. This means that
|
||||
* all destinations are initially negative, which the assembler doesn't grok,
|
||||
* because for some reason negative numbers don't fit into 16 bits. The addr32
|
||||
* prefixes are there for the same reasons, because otherwise the memory
|
||||
* references are only 16 bit wide. Theoretically they are all superfluous.
|
||||
* One last note about prefixes: the data32 prefixes on all call _real_to_prot
|
||||
* instructions could be removed if the _real_to_prot function is changed to
|
||||
* deal correctly with 16 bit return addresses. I tried it, but failed.
|
||||
*/
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.code32
|
||||
|
||||
/* This is a struct os_entry_regs */
|
||||
.globl os_regs
|
||||
os_regs: .space 56
|
||||
|
||||
/**************************************************************************
|
||||
XSTART32 - Transfer control to the kernel just loaded
|
||||
**************************************************************************/
|
||||
.globl xstart32
|
||||
xstart32:
|
||||
/* Save the callee save registers */
|
||||
movl %ebp, os_regs + 32
|
||||
movl %esi, os_regs + 36
|
||||
movl %edi, os_regs + 40
|
||||
movl %ebx, os_regs + 44
|
||||
|
||||
/* save the return address */
|
||||
popl %eax
|
||||
movl %eax, os_regs + 48
|
||||
|
||||
/* save the stack pointer */
|
||||
movl %esp, os_regs + 52
|
||||
|
||||
/* Get the new destination address */
|
||||
popl %ecx
|
||||
|
||||
/* Store the physical address of xend on the stack */
|
||||
movl $xend32, %ebx
|
||||
addl virt_offset, %ebx
|
||||
pushl %ebx
|
||||
|
||||
/* Store the destination address on the stack */
|
||||
pushl $PHYSICAL_CS
|
||||
pushl %ecx
|
||||
|
||||
/* Cache virt_offset */
|
||||
movl virt_offset, %ebp
|
||||
|
||||
/* Switch to using physical addresses */
|
||||
call _virt_to_phys
|
||||
|
||||
/* Save the target stack pointer */
|
||||
movl %esp, os_regs + 12(%ebp)
|
||||
leal os_regs(%ebp), %esp
|
||||
|
||||
/* Store the pointer to os_regs */
|
||||
movl %esp, os_regs_ptr(%ebp)
|
||||
|
||||
/* Load my new registers */
|
||||
popal
|
||||
movl (-32 + 12)(%esp), %esp
|
||||
|
||||
/* Jump to the new kernel
|
||||
* The lret switches to a flat code segment
|
||||
*/
|
||||
lret
|
||||
|
||||
.balign 4
|
||||
.globl xend32
|
||||
xend32:
|
||||
/* Fixup %eflags */
|
||||
nop
|
||||
cli
|
||||
cld
|
||||
|
||||
/* Load %esp with &os_regs + virt_offset */
|
||||
.byte 0xbc /* movl $0, %esp */
|
||||
os_regs_ptr:
|
||||
.long 0
|
||||
|
||||
/* Save the result registers */
|
||||
addl $32, %esp
|
||||
pushal
|
||||
|
||||
/* Compute virt_offset */
|
||||
movl %esp, %ebp
|
||||
subl $os_regs, %ebp
|
||||
|
||||
/* Load the stack pointer and convert it to physical address */
|
||||
movl 52(%esp), %esp
|
||||
addl %ebp, %esp
|
||||
|
||||
/* Enable the virtual addresses */
|
||||
leal _phys_to_virt(%ebp), %eax
|
||||
call *%eax
|
||||
|
||||
/* Restore the callee save registers */
|
||||
movl os_regs + 32, %ebp
|
||||
movl os_regs + 36, %esi
|
||||
movl os_regs + 40, %edi
|
||||
movl os_regs + 44, %ebx
|
||||
movl os_regs + 48, %edx
|
||||
movl os_regs + 52, %esp
|
||||
|
||||
/* Get the C return value */
|
||||
movl os_regs + 28, %eax
|
||||
|
||||
jmpl *%edx
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
.arch sledgehammer
|
||||
/**************************************************************************
|
||||
XSTART_lm - Transfer control to the kernel just loaded in long mode
|
||||
**************************************************************************/
|
||||
.globl xstart_lm
|
||||
xstart_lm:
|
||||
/* Save the callee save registers */
|
||||
pushl %ebp
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
|
||||
/* Cache virt_offset && (virt_offset & 0xfffff000) */
|
||||
movl virt_offset, %ebp
|
||||
movl %ebp, %ebx
|
||||
andl $0xfffff000, %ebx
|
||||
|
||||
/* Switch to using physical addresses */
|
||||
call _virt_to_phys
|
||||
|
||||
/* Initialize the page tables */
|
||||
/* Level 4 */
|
||||
leal 0x23 + pgt_level3(%ebx), %eax
|
||||
leal pgt_level4(%ebx), %edi
|
||||
movl %eax, (%edi)
|
||||
|
||||
/* Level 3 */
|
||||
leal 0x23 + pgt_level2(%ebx), %eax
|
||||
leal pgt_level3(%ebx), %edi
|
||||
movl %eax, 0x00(%edi)
|
||||
addl $4096, %eax
|
||||
movl %eax, 0x08(%edi)
|
||||
addl $4096, %eax
|
||||
movl %eax, 0x10(%edi)
|
||||
addl $4096, %eax
|
||||
movl %eax, 0x18(%edi)
|
||||
|
||||
/* Level 2 */
|
||||
movl $0xe3, %eax
|
||||
leal pgt_level2(%ebx), %edi
|
||||
leal 16384(%edi), %esi
|
||||
pgt_level2_loop:
|
||||
movl %eax, (%edi)
|
||||
addl $8, %edi
|
||||
addl $0x200000, %eax
|
||||
cmp %esi, %edi
|
||||
jne pgt_level2_loop
|
||||
|
||||
/* Point at the x86_64 page tables */
|
||||
leal pgt_level4(%ebx), %edi
|
||||
movl %edi, %cr3
|
||||
|
||||
|
||||
/* Setup for the return from 64bit mode */
|
||||
/* 64bit align the stack */
|
||||
movl %esp, %ebx /* original stack pointer + 16 */
|
||||
andl $0xfffffff8, %esp
|
||||
|
||||
/* Save original stack pointer + 16 */
|
||||
pushl %ebx
|
||||
|
||||
/* Save virt_offset */
|
||||
pushl %ebp
|
||||
|
||||
/* Setup for the jmp to 64bit long mode */
|
||||
leal start_lm(%ebp), %eax
|
||||
movl %eax, 0x00 + start_lm_addr(%ebp)
|
||||
movl $LM_CODE_SEG, %eax
|
||||
movl %eax, 0x04 + start_lm_addr(%ebp)
|
||||
|
||||
/* Setup for the jump out of 64bit long mode */
|
||||
leal end_lm(%ebp), %eax
|
||||
movl %eax, 0x00 + end_lm_addr(%ebp)
|
||||
movl $FLAT_CODE_SEG, %eax
|
||||
movl %eax, 0x04 + end_lm_addr(%ebp)
|
||||
|
||||
/* Enable PAE mode */
|
||||
movl %cr4, %eax
|
||||
orl $X86_CR4_PAE, %eax
|
||||
movl %eax, %cr4
|
||||
|
||||
/* Enable long mode */
|
||||
movl $MSR_K6_EFER, %ecx
|
||||
rdmsr
|
||||
orl $EFER_LME, %eax
|
||||
wrmsr
|
||||
|
||||
/* Start paging, entering 32bit compatiblity mode */
|
||||
movl %cr0, %eax
|
||||
orl $CR0_PG, %eax
|
||||
movl %eax, %cr0
|
||||
|
||||
/* Enter 64bit long mode */
|
||||
ljmp *start_lm_addr(%ebp)
|
||||
.code64
|
||||
start_lm:
|
||||
/* Load 64bit data segments */
|
||||
movl $LM_DATA_SEG, %eax
|
||||
movl %eax, %ds
|
||||
movl %eax, %es
|
||||
movl %eax, %ss
|
||||
|
||||
andq $0xffffffff, %rbx
|
||||
/* Get the address to jump to */
|
||||
movl 20(%rbx), %edx
|
||||
andq $0xffffffff, %rdx
|
||||
|
||||
/* Get the argument pointer */
|
||||
movl 24(%rbx), %ebx
|
||||
andq $0xffffffff, %rbx
|
||||
|
||||
/* Jump to the 64bit code */
|
||||
call *%rdx
|
||||
|
||||
/* Preserve the result */
|
||||
movl %eax, %edx
|
||||
|
||||
/* Fixup %eflags */
|
||||
cli
|
||||
cld
|
||||
|
||||
/* Switch to 32bit compatibility mode */
|
||||
ljmp *end_lm_addr(%rip)
|
||||
|
||||
.code32
|
||||
end_lm:
|
||||
/* Disable paging */
|
||||
movl %cr0, %eax
|
||||
andl $~CR0_PG, %eax
|
||||
movl %eax, %cr0
|
||||
|
||||
/* Disable long mode */
|
||||
movl $MSR_K6_EFER, %ecx
|
||||
rdmsr
|
||||
andl $~EFER_LME, %eax
|
||||
wrmsr
|
||||
|
||||
/* Disable PAE */
|
||||
movl %cr4, %eax
|
||||
andl $~X86_CR4_PAE, %eax
|
||||
movl %eax, %cr4
|
||||
|
||||
/* Compute virt_offset */
|
||||
popl %ebp
|
||||
|
||||
/* Compute the original stack pointer + 16 */
|
||||
popl %ebx
|
||||
movl %ebx, %esp
|
||||
|
||||
/* Enable the virtual addresses */
|
||||
leal _phys_to_virt(%ebp), %eax
|
||||
call *%eax
|
||||
|
||||
/* Restore the callee save registers */
|
||||
popl %ebx
|
||||
popl %esi
|
||||
popl %edi
|
||||
popl %ebp
|
||||
|
||||
/* Get the C return value */
|
||||
movl %edx, %eax
|
||||
|
||||
/* Return */
|
||||
ret
|
||||
|
||||
.arch i386
|
||||
#endif /* CONFIG_X86_64 */
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
.section ".bss"
|
||||
.p2align 12
|
||||
/* Include a dummy space in case we are loaded badly aligned */
|
||||
.space 4096
|
||||
/* Reserve enough space for a page table convering 4GB with 2MB pages */
|
||||
pgt_level4:
|
||||
.space 4096
|
||||
pgt_level3:
|
||||
.space 4096
|
||||
pgt_level2:
|
||||
.space 16384
|
||||
start_lm_addr:
|
||||
.space 8
|
||||
end_lm_addr:
|
||||
.space 8
|
||||
#endif
|
||||
@@ -12,12 +12,11 @@
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <bits/timer2.h>
|
||||
#include <gpxe/timer.h>
|
||||
#include <io.h>
|
||||
#include <gpxe/timer2.h>
|
||||
#include <gpxe/io.h>
|
||||
|
||||
/* Timers tick over at this rate */
|
||||
#define TIMER2_TICK_RATE 1193180U
|
||||
#define TIMER2_TICKS_PER_SEC 1193180U
|
||||
|
||||
/* Parallel Peripheral Controller Port B */
|
||||
#define PPC_PORTB 0x61
|
||||
@@ -52,8 +51,7 @@
|
||||
#define BINARY_COUNT 0x00
|
||||
#define BCD_COUNT 0x01
|
||||
|
||||
static void load_timer2(unsigned int ticks)
|
||||
{
|
||||
static void load_timer2 ( unsigned int ticks ) {
|
||||
/*
|
||||
* Now let's take care of PPC channel 2
|
||||
*
|
||||
@@ -75,15 +73,13 @@ static void load_timer2(unsigned int ticks)
|
||||
outb(ticks >> 8, TIMER2_PORT);
|
||||
}
|
||||
|
||||
static int timer2_running(void)
|
||||
{
|
||||
static int timer2_running ( void ) {
|
||||
return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
|
||||
}
|
||||
|
||||
void i386_timer2_udelay(unsigned int usecs)
|
||||
{
|
||||
load_timer2((usecs * TIMER2_TICK_RATE)/USECS_IN_SEC);
|
||||
while (timer2_running())
|
||||
;
|
||||
void timer2_udelay ( unsigned long usecs ) {
|
||||
load_timer2 ( ( usecs * TIMER2_TICKS_PER_SEC ) / ( 1000 * 1000 ) );
|
||||
while (timer2_running()) {
|
||||
/* Do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "stddef.h"
|
||||
#include "string.h"
|
||||
#include "io.h"
|
||||
#include <gpxe/io.h>
|
||||
#include "console.h"
|
||||
#include <gpxe/init.h>
|
||||
#include "vga.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "virtaddr.h"
|
||||
#include "librm.h"
|
||||
|
||||
.arch i386
|
||||
.text
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gpxe/io.h>
|
||||
#include <gpxe/x86_io.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
* gPXE I/O API for x86
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read 64-bit qword from memory-mapped device
|
||||
*
|
||||
* @v io_addr I/O address
|
||||
* @ret data Value read
|
||||
*
|
||||
* This routine uses MMX instructions.
|
||||
*/
|
||||
static uint64_t x86_readq ( volatile uint64_t *io_addr ) {
|
||||
uint64_t data;
|
||||
__asm__ __volatile__ ( "pushl %%edx\n\t"
|
||||
"pushl %%eax\n\t"
|
||||
"movq (%1), %%mm0\n\t"
|
||||
"movq %%mm0, (%%esp)\n\t"
|
||||
"popl %%eax\n\t"
|
||||
"popl %%edx\n\t"
|
||||
"emms\n\t"
|
||||
: "=A" ( data ) : "r" ( io_addr ) );
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write 64-bit qword to memory-mapped device
|
||||
*
|
||||
* @v data Value to write
|
||||
* @v io_addr I/O address
|
||||
*
|
||||
* This routine uses MMX instructions.
|
||||
*/
|
||||
static void x86_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
|
||||
__asm__ __volatile__ ( "pushl %%edx\n\t"
|
||||
"pushl %%eax\n\t"
|
||||
"movq (%%esp), %%mm0\n\t"
|
||||
"movq %%mm0, (%1)\n\t"
|
||||
"popl %%eax\n\t"
|
||||
"popl %%edx\n\t"
|
||||
"emms\n\t"
|
||||
: : "A" ( data ), "r" ( io_addr ) );
|
||||
}
|
||||
|
||||
PROVIDE_IOAPI_INLINE ( x86, phys_to_bus );
|
||||
PROVIDE_IOAPI_INLINE ( x86, bus_to_phys );
|
||||
PROVIDE_IOAPI_INLINE ( x86, ioremap );
|
||||
PROVIDE_IOAPI_INLINE ( x86, iounmap );
|
||||
PROVIDE_IOAPI_INLINE ( x86, io_to_bus );
|
||||
PROVIDE_IOAPI_INLINE ( x86, readb );
|
||||
PROVIDE_IOAPI_INLINE ( x86, readw );
|
||||
PROVIDE_IOAPI_INLINE ( x86, readl );
|
||||
PROVIDE_IOAPI ( x86, readq, x86_readq );
|
||||
PROVIDE_IOAPI_INLINE ( x86, writeb );
|
||||
PROVIDE_IOAPI_INLINE ( x86, writew );
|
||||
PROVIDE_IOAPI_INLINE ( x86, writel );
|
||||
PROVIDE_IOAPI ( x86, writeq, x86_writeq );
|
||||
PROVIDE_IOAPI_INLINE ( x86, inb );
|
||||
PROVIDE_IOAPI_INLINE ( x86, inw );
|
||||
PROVIDE_IOAPI_INLINE ( x86, inl );
|
||||
PROVIDE_IOAPI_INLINE ( x86, outb );
|
||||
PROVIDE_IOAPI_INLINE ( x86, outw );
|
||||
PROVIDE_IOAPI_INLINE ( x86, outl );
|
||||
PROVIDE_IOAPI_INLINE ( x86, insb );
|
||||
PROVIDE_IOAPI_INLINE ( x86, insw );
|
||||
PROVIDE_IOAPI_INLINE ( x86, insl );
|
||||
PROVIDE_IOAPI_INLINE ( x86, outsb );
|
||||
PROVIDE_IOAPI_INLINE ( x86, outsw );
|
||||
PROVIDE_IOAPI_INLINE ( x86, outsl );
|
||||
PROVIDE_IOAPI_INLINE ( x86, iodelay );
|
||||
PROVIDE_IOAPI_INLINE ( x86, mb );
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <biosint.h>
|
||||
#include <pnpbios.h>
|
||||
#include <basemem_packet.h>
|
||||
#include <gpxe/io.h>
|
||||
#include <gpxe/iobuf.h>
|
||||
#include <gpxe/netdevice.h>
|
||||
#include <gpxe/if_ether.h>
|
||||
@@ -700,7 +701,7 @@ int undinet_probe ( struct undi_device *undi ) {
|
||||
&undi_iface,
|
||||
sizeof ( undi_iface ) ) ) != 0 )
|
||||
goto err_undi_get_iface_info;
|
||||
DBGC ( undinic, "UNDINIC %p has type %s and link speed %ld\n",
|
||||
DBGC ( undinic, "UNDINIC %p has type %s and link speed %d\n",
|
||||
undinic, undi_iface.IfaceType, undi_iface.LinkSpeed );
|
||||
if ( strncmp ( ( ( char * ) undi_iface.IfaceType ), "Etherboot",
|
||||
sizeof ( undi_iface.IfaceType ) ) == 0 ) {
|
||||
|
||||
@@ -52,7 +52,7 @@ static int undirom_parse_pxeromid ( struct undi_rom *undirom,
|
||||
sizeof ( undi_rom_id ) );
|
||||
if ( undi_rom_id.Signature != UNDI_ROM_ID_SIGNATURE ) {
|
||||
DBGC ( undirom, "UNDIROM %p has bad PXE ROM ID signature "
|
||||
"%08lx\n", undirom, undi_rom_id.Signature );
|
||||
"%08x\n", undirom, undi_rom_id.Signature );
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ static int undirom_parse_pcirheader ( struct undi_rom *undirom,
|
||||
sizeof ( pcir_header ) );
|
||||
if ( pcir_header.signature != PCIR_SIGNATURE ) {
|
||||
DBGC ( undirom, "UNDIROM %p has bad PCI expansion header "
|
||||
"signature %08lx\n", undirom, pcir_header.signature );
|
||||
"signature %08x\n", undirom, pcir_header.signature );
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Etherboot routines for PCBIOS firmware.
|
||||
*
|
||||
* Body of routines taken from old pcbios.S
|
||||
*/
|
||||
|
||||
#include <gpxe/init.h>
|
||||
#include <gpxe/timer.h>
|
||||
#include <stdio.h>
|
||||
#include <realmode.h>
|
||||
#include <bios.h>
|
||||
#include <bits/timer2.h>
|
||||
|
||||
/* A bit faster actually, but we don't care. */
|
||||
#define TIMER2_TICKS_PER_SEC 18
|
||||
|
||||
/*
|
||||
* Use direct memory access to BIOS variables, longword 0040:006C (ticks
|
||||
* today) and byte 0040:0070 (midnight crossover flag) instead of calling
|
||||
* timeofday BIOS interrupt.
|
||||
*/
|
||||
|
||||
static tick_t bios_currticks ( void ) {
|
||||
static int days = 0;
|
||||
uint32_t ticks;
|
||||
uint8_t midnight;
|
||||
|
||||
/* Re-enable interrupts so that the timer interrupt can occur */
|
||||
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"cli\n\t" ) : : );
|
||||
|
||||
get_real ( ticks, BDA_SEG, 0x006c );
|
||||
get_real ( midnight, BDA_SEG, 0x0070 );
|
||||
|
||||
if ( midnight ) {
|
||||
midnight = 0;
|
||||
put_real ( midnight, BDA_SEG, 0x0070 );
|
||||
days += 0x1800b0;
|
||||
}
|
||||
|
||||
return ( (days + ticks) * (USECS_IN_SEC / TIMER2_TICKS_PER_SEC) );
|
||||
}
|
||||
|
||||
static int bios_ts_init(void)
|
||||
{
|
||||
DBG("BIOS timer installed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct timer bios_ts __timer ( 02 ) = {
|
||||
.init = bios_ts_init,
|
||||
.udelay = i386_timer2_udelay,
|
||||
.currticks = bios_currticks,
|
||||
};
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
|
||||
#include <gpxe/init.h>
|
||||
#include <gpxe/timer.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <bits/cpu.h>
|
||||
#include <bits/timer2.h>
|
||||
#include <io.h>
|
||||
|
||||
|
||||
#define rdtsc(low,high) \
|
||||
__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
|
||||
|
||||
#define rdtscll(val) \
|
||||
__asm__ __volatile__ ("rdtsc" : "=A" (val))
|
||||
|
||||
|
||||
/* Measure how many clocks we get in one microsecond */
|
||||
static inline uint64_t calibrate_tsc(void)
|
||||
{
|
||||
|
||||
uint64_t rdtsc_start;
|
||||
uint64_t rdtsc_end;
|
||||
|
||||
rdtscll(rdtsc_start);
|
||||
i386_timer2_udelay(USECS_IN_MSEC);
|
||||
rdtscll(rdtsc_end);
|
||||
|
||||
return (rdtsc_end - rdtsc_start) / USECS_IN_MSEC;
|
||||
}
|
||||
|
||||
static uint32_t clocks_per_usec = 0;
|
||||
|
||||
/* We measure time in microseconds. */
|
||||
static tick_t rdtsc_currticks(void)
|
||||
{
|
||||
uint64_t clocks;
|
||||
|
||||
/* Read the Time Stamp Counter */
|
||||
rdtscll(clocks);
|
||||
|
||||
return clocks / clocks_per_usec;
|
||||
}
|
||||
|
||||
static int rdtsc_ts_init(void)
|
||||
{
|
||||
|
||||
struct cpuinfo_x86 cpu_info;
|
||||
|
||||
get_cpuinfo(&cpu_info);
|
||||
if (cpu_info.features & X86_FEATURE_TSC) {
|
||||
clocks_per_usec= calibrate_tsc();
|
||||
if (clocks_per_usec) {
|
||||
DBG("RDTSC ticksource installed. CPU running at %ld Mhz\n",
|
||||
clocks_per_usec);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
DBG("RDTSC ticksource not available on this machine.\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
struct timer rdtsc_ts __timer (01) = {
|
||||
.init = rdtsc_ts_init,
|
||||
.udelay = generic_currticks_udelay,
|
||||
.currticks = rdtsc_currticks,
|
||||
};
|
||||
|
||||
@@ -25,6 +25,26 @@
|
||||
|
||||
#define SMAP 0x534d4150
|
||||
|
||||
/* Most documentation refers to the E820 buffer as being 20 bytes, and
|
||||
* the API makes it perfectly legitimate to pass only a 20-byte buffer
|
||||
* and expect to get valid data. However, some morons at ACPI decided
|
||||
* to extend the data structure by adding an extra "extended
|
||||
* attributes" field and by including critical information within this
|
||||
* field, such as whether or not the region is enabled. A caller who
|
||||
* passes in only a 20-byte buffer therefore risks getting very, very
|
||||
* misleading information.
|
||||
*
|
||||
* I have personally witnessed an HP BIOS that returns a value of
|
||||
* 0x0009 in the extended attributes field. If we don't pass this
|
||||
* value through to the caller, 32-bit WinPE will die, usually with a
|
||||
* PAGE_FAULT_IN_NONPAGED_AREA blue screen of death.
|
||||
*
|
||||
* Allow a ridiculously large maximum value (64 bytes) for the E820
|
||||
* buffer as a guard against insufficiently creative idiots in the
|
||||
* future.
|
||||
*/
|
||||
#define E820MAXSIZE 64
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Allowed memory windows
|
||||
@@ -46,7 +66,7 @@
|
||||
.align 16
|
||||
.globl hidemem_base
|
||||
.globl hidemem_umalloc
|
||||
.globl hidemem_text
|
||||
.globl hidemem_textdata
|
||||
memory_windows:
|
||||
base_memory_window: .long 0x00000000, 0x00000000 /* Start of memory */
|
||||
|
||||
@@ -56,7 +76,7 @@ ext_memory_window: .long 0x000a0000, 0x00000000 /* 640kB mark */
|
||||
hidemem_umalloc: .long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||
.long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||
|
||||
hidemem_text: .long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||
hidemem_textdata: .long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||
.long 0xffffffff, 0xffffffff /* Changes at runtime */
|
||||
|
||||
.long 0xffffffff, 0xffffffff /* End of memory */
|
||||
@@ -204,19 +224,22 @@ get_underlying_e820:
|
||||
|
||||
/* If the requested region is in the cache, return it */
|
||||
cmpw %bx, underlying_e820_index
|
||||
jne 1f
|
||||
jne 2f
|
||||
pushw %di
|
||||
pushw %si
|
||||
movw $underlying_e820_cache, %si
|
||||
movw $20, %cx
|
||||
cmpl underlying_e820_cache_size, %ecx
|
||||
jbe 1f
|
||||
movl underlying_e820_cache_size, %ecx
|
||||
1: pushl %ecx
|
||||
rep movsb
|
||||
popl %ecx
|
||||
popw %si
|
||||
popw %di
|
||||
movw $20, %cx
|
||||
incw %bx
|
||||
movl %edx, %eax
|
||||
ret
|
||||
1:
|
||||
2:
|
||||
/* If the requested region is earlier than the cached region,
|
||||
* invalidate the cache.
|
||||
*/
|
||||
@@ -245,28 +268,35 @@ get_underlying_e820:
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
pushl %edx
|
||||
pushl %esi /* Some implementations corrupt %esi, so we */
|
||||
pushl %edi /* preserve %esi, %edi and %ebp to be paranoid */
|
||||
pushl %ebp
|
||||
pushw %es
|
||||
pushw %di
|
||||
pushw %ds
|
||||
popw %es
|
||||
movw $underlying_e820_cache, %di
|
||||
movl $20, %ecx
|
||||
movl underlying_e820_ebx, %ebx
|
||||
cmpl $E820MAXSIZE, %ecx
|
||||
jbe 1f
|
||||
movl $E820MAXSIZE, %ecx
|
||||
1: movl underlying_e820_ebx, %ebx
|
||||
stc
|
||||
pushfw
|
||||
lcall *%cs:int15_vector
|
||||
popw %di
|
||||
popw %es
|
||||
popl %ebp
|
||||
popl %edi
|
||||
popl %esi
|
||||
/* Check for error return from underlying e820 call */
|
||||
jc 1f /* CF set: error */
|
||||
jc 2f /* CF set: error */
|
||||
cmpl $SMAP, %eax
|
||||
je 2f /* 'SMAP' missing: error */
|
||||
1: /* An error occurred: return values returned by underlying e820 call */
|
||||
je 3f /* 'SMAP' missing: error */
|
||||
2: /* An error occurred: return values returned by underlying e820 call */
|
||||
stc /* Force CF set if SMAP was missing */
|
||||
addr32 leal 16(%esp), %esp /* avoid changing other flags */
|
||||
ret
|
||||
2: /* No error occurred */
|
||||
3: /* No error occurred */
|
||||
movl %ebx, underlying_e820_ebx
|
||||
movl %ecx, underlying_e820_cache_size
|
||||
popl %edx
|
||||
popl %ecx
|
||||
popl %ebx
|
||||
@@ -290,9 +320,14 @@ underlying_e820_ebx:
|
||||
|
||||
.section ".bss16"
|
||||
underlying_e820_cache:
|
||||
.space 20
|
||||
.space E820MAXSIZE
|
||||
.size underlying_e820_cache, . - underlying_e820_cache
|
||||
|
||||
.section ".bss16"
|
||||
underlying_e820_cache_size:
|
||||
.long 0
|
||||
.size underlying_e820_cache_size, . - underlying_e820_cache_size
|
||||
|
||||
/****************************************************************************
|
||||
* Get windowed e820 region, without empty region stripping
|
||||
*
|
||||
@@ -436,15 +471,17 @@ get_mangled_e820:
|
||||
|
||||
/* Peek ahead to see if there are any further nonempty regions */
|
||||
pushal
|
||||
subw $20, %sp
|
||||
pushw %es
|
||||
movw %sp, %bp
|
||||
subw %cx, %sp
|
||||
movl $0xe820, %eax
|
||||
movl $SMAP, %edx
|
||||
movl $20, %ecx
|
||||
pushw %ss
|
||||
popw %es
|
||||
movw %sp, %di
|
||||
call get_nonempty_e820
|
||||
addr32 leal 20(%esp), %esp /* avoid changing flags */
|
||||
movw %bp, %sp
|
||||
popw %es
|
||||
popal
|
||||
jnc 99f /* There are further nonempty regions */
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <realmode.h>
|
||||
#include <bios.h>
|
||||
#include <gpxe/io.h>
|
||||
#include <gpxe/timer.h>
|
||||
|
||||
#define K_RDWR 0x60 /* keyboard data & cmds (read/write) */
|
||||
@@ -48,9 +49,9 @@ static void empty_8042 ( void ) {
|
||||
time = currticks() + TICKS_PER_SEC; /* max wait of 1 second */
|
||||
while ( ( inb ( K_CMD ) & ( K_IBUF_FUL | K_OBUF_FUL ) ) &&
|
||||
currticks() < time ) {
|
||||
SLOW_DOWN_IO;
|
||||
( void ) inb ( K_RDWR );
|
||||
SLOW_DOWN_IO;
|
||||
iodelay();
|
||||
( void ) inb_p ( K_RDWR );
|
||||
iodelay();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ static int gateA20_is_set ( int retries ) {
|
||||
/* Avoid false negatives */
|
||||
test_pattern++;
|
||||
|
||||
SLOW_DOWN_IO;
|
||||
iodelay();
|
||||
|
||||
/* Always retry at least once, to avoid false negatives */
|
||||
} while ( retries-- >= 0 );
|
||||
@@ -145,9 +146,9 @@ void gateA20_set ( void ) {
|
||||
scp_a = inb ( SCP_A );
|
||||
scp_a &= ~0x01; /* Avoid triggering a reset */
|
||||
scp_a |= 0x02; /* Enable A20 */
|
||||
SLOW_DOWN_IO;
|
||||
iodelay();
|
||||
outb ( scp_a, SCP_A );
|
||||
SLOW_DOWN_IO;
|
||||
iodelay();
|
||||
if ( gateA20_is_set ( A20_SCPA_RETRIES ) ) {
|
||||
DBG ( "Enabled gate A20 using "
|
||||
"Fast Gate A20\n" );
|
||||
|
||||
@@ -55,8 +55,8 @@ extern struct hidden_region __data16 ( hidemem_umalloc );
|
||||
#define hidemem_umalloc __use_data16 ( hidemem_umalloc )
|
||||
|
||||
/** Hidden text memory */
|
||||
extern struct hidden_region __data16 ( hidemem_text );
|
||||
#define hidemem_text __use_data16 ( hidemem_text )
|
||||
extern struct hidden_region __data16 ( hidemem_textdata );
|
||||
#define hidemem_textdata __use_data16 ( hidemem_textdata )
|
||||
|
||||
/** Assembly routine in e820mangler.S */
|
||||
extern void int15();
|
||||
@@ -66,12 +66,12 @@ extern struct segoff __text16 ( int15_vector );
|
||||
#define int15_vector __use_text16 ( int15_vector )
|
||||
|
||||
/* The linker defines these symbols for us */
|
||||
extern char _text[];
|
||||
extern char _end[];
|
||||
extern char _text16_size[];
|
||||
#define _text16_size ( ( unsigned int ) _text16_size )
|
||||
extern char _data16_size[];
|
||||
#define _data16_size ( ( unsigned int ) _data16_size )
|
||||
extern char _textdata[];
|
||||
extern char _etextdata[];
|
||||
extern char _text16_memsz[];
|
||||
#define _text16_memsz ( ( unsigned int ) _text16_memsz )
|
||||
extern char _data16_memsz[];
|
||||
#define _data16_memsz ( ( unsigned int ) _data16_memsz )
|
||||
|
||||
/**
|
||||
* Hide region of memory from system memory map
|
||||
@@ -110,7 +110,7 @@ void hide_basemem ( void ) {
|
||||
*
|
||||
*/
|
||||
void hide_umalloc ( physaddr_t start, physaddr_t end ) {
|
||||
assert ( end <= virt_to_phys ( _text ) );
|
||||
assert ( end <= virt_to_phys ( _textdata ) );
|
||||
hide_region ( &hidemem_umalloc, start, end );
|
||||
}
|
||||
|
||||
@@ -118,9 +118,9 @@ void hide_umalloc ( physaddr_t start, physaddr_t end ) {
|
||||
* Hide .text and .data
|
||||
*
|
||||
*/
|
||||
void hide_text ( void ) {
|
||||
hide_region ( &hidemem_text, virt_to_phys ( _text ),
|
||||
virt_to_phys ( _end ) );
|
||||
void hide_textdata ( void ) {
|
||||
hide_region ( &hidemem_textdata, virt_to_phys ( _textdata ),
|
||||
virt_to_phys ( _etextdata ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,8 +148,8 @@ static void hide_etherboot ( void ) {
|
||||
|
||||
/* Initialise the hidden regions */
|
||||
hide_basemem();
|
||||
hide_umalloc ( virt_to_phys ( _text ), virt_to_phys ( _text ) );
|
||||
hide_text();
|
||||
hide_umalloc ( virt_to_phys ( _textdata ), virt_to_phys ( _textdata ) );
|
||||
hide_textdata();
|
||||
|
||||
/* Some really moronic BIOSes bring up the PXE stack via the
|
||||
* UNDI loader entry point and then don't bother to unload it
|
||||
@@ -161,8 +161,8 @@ static void hide_etherboot ( void ) {
|
||||
* We use a heuristic to guess whether or not we are being
|
||||
* loaded sensibly.
|
||||
*/
|
||||
rm_cs_top = ( ( ( rm_cs << 4 ) + _text16_size + 1024 - 1 ) >> 10 );
|
||||
rm_ds_top = ( ( ( rm_ds << 4 ) + _data16_size + 1024 - 1 ) >> 10 );
|
||||
rm_cs_top = ( ( ( rm_cs << 4 ) + _text16_memsz + 1024 - 1 ) >> 10 );
|
||||
rm_ds_top = ( ( ( rm_ds << 4 ) + _data16_memsz + 1024 - 1 ) >> 10 );
|
||||
fbms = get_fbms();
|
||||
if ( ( rm_cs_top < fbms ) && ( rm_ds_top < fbms ) ) {
|
||||
DBG ( "Detected potentially unsafe UNDI load at CS=%04x "
|
||||
|
||||
@@ -41,6 +41,8 @@ struct e820_entry {
|
||||
uint64_t len;
|
||||
/** Type of region */
|
||||
uint32_t type;
|
||||
/** Extended attributes (optional) */
|
||||
uint32_t attrs;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
#define E820_TYPE_RAM 1 /**< Normal memory */
|
||||
@@ -48,6 +50,12 @@ struct e820_entry {
|
||||
#define E820_TYPE_ACPI 3 /**< ACPI reclaim memory */
|
||||
#define E820_TYPE_NVS 4 /**< ACPI NVS memory */
|
||||
|
||||
#define E820_ATTR_ENABLED 0x00000001UL
|
||||
#define E820_ATTR_NONVOLATILE 0x00000002UL
|
||||
#define E820_ATTR_UNKNOWN 0xfffffffcUL
|
||||
|
||||
#define E820_MIN_SIZE 20
|
||||
|
||||
/** Buffer for INT 15,e820 calls */
|
||||
static struct e820_entry __bss16 ( e820buf );
|
||||
#define e820buf __use_data16 ( e820buf )
|
||||
@@ -148,39 +156,77 @@ static int meme820 ( struct memory_map *memmap ) {
|
||||
struct memory_region *region = memmap->regions;
|
||||
uint32_t next = 0;
|
||||
uint32_t smap;
|
||||
size_t size;
|
||||
unsigned int flags;
|
||||
unsigned int discard_c, discard_d, discard_D;
|
||||
unsigned int discard_D;
|
||||
|
||||
/* Clear the E820 buffer. Do this once before starting,
|
||||
* rather than on each call; some BIOSes rely on the contents
|
||||
* being preserved between calls.
|
||||
*/
|
||||
memset ( &e820buf, 0, sizeof ( e820buf ) );
|
||||
|
||||
do {
|
||||
__asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
|
||||
/* Some BIOSes corrupt %esi for fun. Guard against
|
||||
* this by telling gcc that all non-output registers
|
||||
* may be corrupted.
|
||||
*/
|
||||
__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t"
|
||||
"stc\n\t"
|
||||
"int $0x15\n\t"
|
||||
"pushfw\n\t"
|
||||
"popw %w0\n\t" )
|
||||
: "=r" ( flags ), "=a" ( smap ),
|
||||
"=b" ( next ), "=D" ( discard_D ),
|
||||
"=c" ( discard_c ), "=d" ( discard_d )
|
||||
"popw %%dx\n\t"
|
||||
"popl %%ebp\n\t" )
|
||||
: "=a" ( smap ), "=b" ( next ),
|
||||
"=c" ( size ), "=d" ( flags ),
|
||||
"=D" ( discard_D )
|
||||
: "a" ( 0xe820 ), "b" ( next ),
|
||||
"D" ( __from_data16 ( &e820buf ) ),
|
||||
"c" ( sizeof ( e820buf ) ),
|
||||
"d" ( SMAP )
|
||||
: "memory" );
|
||||
: "esi", "memory" );
|
||||
|
||||
if ( smap != SMAP ) {
|
||||
DBG ( "INT 15,e820 failed SMAP signature check\n" );
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if ( size < E820_MIN_SIZE ) {
|
||||
DBG ( "INT 15,e820 returned only %zd bytes\n", size );
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ( flags & CF ) {
|
||||
DBG ( "INT 15,e820 terminated on CF set\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
DBG ( "INT 15,e820 region [%llx,%llx) type %d\n",
|
||||
DBG ( "INT 15,e820 region [%llx,%llx) type %d",
|
||||
e820buf.start, ( e820buf.start + e820buf.len ),
|
||||
( int ) e820buf.type );
|
||||
if ( size > offsetof ( typeof ( e820buf ), attrs ) ) {
|
||||
DBG ( " (%s", ( ( e820buf.attrs & E820_ATTR_ENABLED )
|
||||
? "enabled" : "disabled" ) );
|
||||
if ( e820buf.attrs & E820_ATTR_NONVOLATILE )
|
||||
DBG ( ", non-volatile" );
|
||||
if ( e820buf.attrs & E820_ATTR_UNKNOWN )
|
||||
DBG ( ", other [%08x]", e820buf.attrs );
|
||||
DBG ( ")" );
|
||||
}
|
||||
DBG ( "\n" );
|
||||
|
||||
/* Discard non-RAM regions */
|
||||
if ( e820buf.type != E820_TYPE_RAM )
|
||||
continue;
|
||||
|
||||
/* Check extended attributes, if present */
|
||||
if ( size > offsetof ( typeof ( e820buf ), attrs ) ) {
|
||||
if ( ! ( e820buf.attrs & E820_ATTR_ENABLED ) )
|
||||
continue;
|
||||
if ( e820buf.attrs & E820_ATTR_NONVOLATILE )
|
||||
continue;
|
||||
}
|
||||
|
||||
region->start = e820buf.start;
|
||||
region->end = e820buf.start + e820buf.len;
|
||||
region++;
|
||||
|
||||
@@ -24,6 +24,16 @@
|
||||
#include <gpxe/uuid.h>
|
||||
#include <smbios.h>
|
||||
|
||||
/** SMBIOS settings tag magic number */
|
||||
#define SMBIOS_TAG_MAGIC 0x5B /* "SmBios" */
|
||||
|
||||
/**
|
||||
* Construct SMBIOS empty tag
|
||||
*
|
||||
* @ret tag SMBIOS setting tag
|
||||
*/
|
||||
#define SMBIOS_EMPTY_TAG ( SMBIOS_TAG_MAGIC << 24 )
|
||||
|
||||
/**
|
||||
* Construct SMBIOS raw-data tag
|
||||
*
|
||||
@@ -33,7 +43,8 @@
|
||||
* @ret tag SMBIOS setting tag
|
||||
*/
|
||||
#define SMBIOS_RAW_TAG( _type, _structure, _field ) \
|
||||
( ( (_type) << 16 ) | \
|
||||
( ( SMBIOS_TAG_MAGIC << 24 ) | \
|
||||
( (_type) << 16 ) | \
|
||||
( offsetof ( _structure, _field ) << 8 ) | \
|
||||
( sizeof ( ( ( _structure * ) 0 )->_field ) ) )
|
||||
|
||||
@@ -46,7 +57,8 @@
|
||||
* @ret tag SMBIOS setting tag
|
||||
*/
|
||||
#define SMBIOS_STRING_TAG( _type, _structure, _field ) \
|
||||
( ( (_type) << 16 ) | \
|
||||
( ( SMBIOS_TAG_MAGIC << 24 ) | \
|
||||
( (_type) << 16 ) | \
|
||||
( offsetof ( _structure, _field ) << 8 ) )
|
||||
|
||||
/**
|
||||
@@ -78,16 +90,18 @@ static int smbios_fetch ( struct settings *settings __unused,
|
||||
struct setting *setting,
|
||||
void *data, size_t len ) {
|
||||
struct smbios_structure structure;
|
||||
unsigned int tag_magic;
|
||||
unsigned int tag_type;
|
||||
unsigned int tag_offset;
|
||||
unsigned int tag_len;
|
||||
int rc;
|
||||
|
||||
/* Split tag into type, offset and length */
|
||||
tag_type = ( setting->tag >> 16 );
|
||||
tag_magic = ( setting->tag >> 24 );
|
||||
tag_type = ( ( setting->tag >> 16 ) & 0xff );
|
||||
tag_offset = ( ( setting->tag >> 8 ) & 0xff );
|
||||
tag_len = ( setting->tag & 0xff );
|
||||
if ( ! tag_type )
|
||||
if ( tag_magic != SMBIOS_TAG_MAGIC )
|
||||
return -ENOENT;
|
||||
|
||||
/* Find SMBIOS structure */
|
||||
@@ -127,6 +141,7 @@ static struct settings_operations smbios_settings_operations = {
|
||||
static struct settings smbios_settings = {
|
||||
.refcnt = NULL,
|
||||
.name = "smbios",
|
||||
.tag_magic = SMBIOS_EMPTY_TAG,
|
||||
.siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
|
||||
.children = LIST_HEAD_INIT ( smbios_settings.children ),
|
||||
.op = &smbios_settings_operations,
|
||||
|
||||
@@ -400,7 +400,7 @@ static int bzimage_load_header ( struct image *image,
|
||||
copy_from_user ( bzhdr, image->data, BZI_HDR_OFFSET,
|
||||
sizeof ( *bzhdr ) );
|
||||
if ( bzhdr->header != BZI_SIGNATURE ) {
|
||||
DBGC ( image, "bzImage %p bad signature %08lx\n",
|
||||
DBGC ( image, "bzImage %p bad signature %08x\n",
|
||||
image, bzhdr->header );
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ multiboot_build_module_list ( struct image *image,
|
||||
|
||||
/* Dump module configuration */
|
||||
for ( i = 0 ; i < count ; i++ ) {
|
||||
DBGC ( image, "MULTIBOOT %p module %d is [%lx,%lx)\n",
|
||||
DBGC ( image, "MULTIBOOT %p module %d is [%x,%x)\n",
|
||||
image, i, modules[i].mod_start,
|
||||
modules[i].mod_end );
|
||||
}
|
||||
@@ -282,11 +282,13 @@ static int multiboot_exec ( struct image *image ) {
|
||||
/* Jump to OS with flat physical addressing */
|
||||
DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
|
||||
image, entry );
|
||||
__asm__ __volatile__ ( PHYS_CODE ( "call *%%edi\n\t" )
|
||||
__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t"
|
||||
"call *%%edi\n\t"
|
||||
"popl %%ebp\n\t" )
|
||||
: : "a" ( MULTIBOOT_BOOTLOADER_MAGIC ),
|
||||
"b" ( virt_to_phys ( &mbinfo ) ),
|
||||
"D" ( entry )
|
||||
: "ecx", "edx", "esi", "ebp", "memory" );
|
||||
: "ecx", "edx", "esi", "memory" );
|
||||
|
||||
DBGC ( image, "MULTIBOOT %p returned\n", image );
|
||||
|
||||
@@ -416,7 +418,7 @@ static int multiboot_load ( struct image *image ) {
|
||||
image );
|
||||
return rc;
|
||||
}
|
||||
DBGC ( image, "MULTIBOOT %p found header with flags %08lx\n",
|
||||
DBGC ( image, "MULTIBOOT %p found header with flags %08x\n",
|
||||
image, hdr.mb.flags );
|
||||
|
||||
/* This is a multiboot image, valid or otherwise */
|
||||
@@ -425,7 +427,7 @@ static int multiboot_load ( struct image *image ) {
|
||||
|
||||
/* Abort if we detect flags that we cannot support */
|
||||
if ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) {
|
||||
DBGC ( image, "MULTIBOOT %p flags %08lx not supported\n",
|
||||
DBGC ( image, "MULTIBOOT %p flags %08x not supported\n",
|
||||
image, ( hdr.mb.flags & MB_UNSUPPORTED_FLAGS ) );
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
@@ -366,22 +366,6 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess boot network device
|
||||
*
|
||||
* @ret netdev Boot network device
|
||||
*/
|
||||
static struct net_device * guess_boot_netdev ( void ) {
|
||||
struct net_device *boot_netdev;
|
||||
|
||||
/* Just use the first network device */
|
||||
for_each_netdev ( boot_netdev ) {
|
||||
return boot_netdev;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare DHCP parameter block for NBI image
|
||||
*
|
||||
@@ -392,7 +376,7 @@ static int nbi_prepare_dhcp ( struct image *image ) {
|
||||
struct net_device *boot_netdev;
|
||||
int rc;
|
||||
|
||||
boot_netdev = guess_boot_netdev();
|
||||
boot_netdev = last_opened_netdev();
|
||||
if ( ! boot_netdev ) {
|
||||
DBGC ( image, "NBI %p could not identify a network device\n",
|
||||
image );
|
||||
|
||||
@@ -42,18 +42,14 @@ struct image_type pxe_image_type __image_type ( PROBE_PXE );
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int pxe_exec ( struct image *image ) {
|
||||
struct net_device *netdev;
|
||||
int rc;
|
||||
|
||||
/* Ensure that PXE stack is ready to use */
|
||||
pxe_init_structures();
|
||||
pxe_hook_int1a();
|
||||
|
||||
/* Arbitrarily pick the first open network device to use for PXE */
|
||||
for_each_netdev ( netdev ) {
|
||||
pxe_set_netdev ( netdev );
|
||||
break;
|
||||
}
|
||||
/* Arbitrarily pick the most recently opened network device */
|
||||
pxe_set_netdev ( last_opened_netdev() );
|
||||
|
||||
/* Many things will break if pxe_netdev is NULL */
|
||||
if ( ! pxe_netdev ) {
|
||||
|
||||
@@ -5,7 +5,4 @@
|
||||
#define BDA_FBMS 0x0013
|
||||
#define BDA_NUM_DRIVES 0x0075
|
||||
|
||||
extern unsigned long currticks ( void );
|
||||
extern void cpu_nap ( void );
|
||||
|
||||
#endif /* BIOS_H */
|
||||
|
||||
@@ -6,9 +6,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <realmode.h>
|
||||
|
||||
struct segoff;
|
||||
|
||||
extern int hooked_bios_interrupts;
|
||||
/**
|
||||
* Hooked interrupt count
|
||||
*
|
||||
* At exit, after unhooking all possible interrupts, this counter
|
||||
* should be examined. If it is non-zero, it means that we failed to
|
||||
* unhook at least one interrupt vector, and so must not free up the
|
||||
* memory we are using. (Note that this also implies that we should
|
||||
* re-hook INT 15 in order to hide ourselves from the memory map).
|
||||
*/
|
||||
extern uint16_t __text16 ( hooked_bios_interrupts );
|
||||
#define hooked_bios_interrupts __use_text16 ( hooked_bios_interrupts )
|
||||
|
||||
extern void hook_bios_interrupt ( unsigned int interrupt, unsigned int handler,
|
||||
struct segoff *chain_vector );
|
||||
extern int unhook_bios_interrupt ( unsigned int interrupt,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef _BITS_COMPILER_H
|
||||
#define _BITS_COMPILER_H
|
||||
|
||||
#ifndef ASSEMBLY
|
||||
|
||||
/** Declare a function with standard calling conventions */
|
||||
#define __asmcall __attribute__ (( cdecl, regparm(0) ))
|
||||
|
||||
/**
|
||||
* Declare a function with libgcc implicit linkage
|
||||
*
|
||||
* It seems as though gcc expects its implicit arithmetic functions to
|
||||
* be cdecl, even if -mrtd is specified. This is somewhat
|
||||
* inconsistent; for example, if -mregparm=3 is used then the implicit
|
||||
* functions do become regparm(3).
|
||||
*
|
||||
* The implicit calls to memcpy() and memset() which gcc can generate
|
||||
* do not seem to have this inconsistency; -mregparm and -mrtd affect
|
||||
* them in the same way as any other function.
|
||||
*/
|
||||
#define __libgcc __attribute__ (( cdecl ))
|
||||
|
||||
#endif /* ASSEMBLY */
|
||||
|
||||
#endif /* _BITS_COMPILER_H */
|
||||
@@ -1,91 +0,0 @@
|
||||
#ifndef I386_BITS_ELF_H
|
||||
#define I386_BITS_ELF_H
|
||||
|
||||
#include "cpu.h"
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
/* ELF Defines for the 64bit version of the current architecture */
|
||||
#define EM_CURRENT_64 EM_X86_64
|
||||
#define EM_CURRENT_64_PRESENT ( \
|
||||
CPU_FEATURE_P(cpu_info.x86_capability, LM) && \
|
||||
CPU_FEATURE_P(cpu_info.x86_capability, PAE) && \
|
||||
CPU_FEATURE_P(cpu_info.x86_capability, PSE))
|
||||
|
||||
#define ELF_CHECK_X86_64_ARCH(x) \
|
||||
(EM_CURRENT_64_PRESENT && ((x).e_machine == EM_X86_64))
|
||||
#define __unused_i386
|
||||
#else
|
||||
#define ELF_CHECK_X86_64_ARCH(x) 0
|
||||
#define __unused_i386 __unused
|
||||
#endif
|
||||
|
||||
|
||||
/* ELF Defines for the current architecture */
|
||||
#define EM_CURRENT EM_386
|
||||
#define ELFDATA_CURRENT ELFDATA2LSB
|
||||
|
||||
#define ELF_CHECK_I386_ARCH(x) \
|
||||
(((x).e_machine == EM_386) || ((x).e_machine == EM_486))
|
||||
|
||||
#define ELF_CHECK_ARCH(x) \
|
||||
((ELF_CHECK_I386_ARCH(x) || ELF_CHECK_X86_64_ARCH(x)) && \
|
||||
((x).e_entry <= 0xffffffffUL))
|
||||
|
||||
#ifdef IMAGE_FREEBSD
|
||||
/*
|
||||
* FreeBSD has this rather strange "feature" of its design.
|
||||
* At some point in its evolution, FreeBSD started to rely
|
||||
* externally on private/static/debug internal symbol information.
|
||||
* That is, some of the interfaces that software uses to access
|
||||
* and work with the FreeBSD kernel are made available not
|
||||
* via the shared library symbol information (the .DYNAMIC section)
|
||||
* but rather the debug symbols. This means that any symbol, not
|
||||
* just publicly defined symbols can be (and are) used by system
|
||||
* tools to make the system work. (such as top, swapinfo, swapon,
|
||||
* etc)
|
||||
*
|
||||
* Even worse, however, is the fact that standard ELF loaders do
|
||||
* not know how to load the symbols since they are not within
|
||||
* an ELF PT_LOAD section. The kernel needs these symbols to
|
||||
* operate so the following changes/additions to the boot
|
||||
* loading of EtherBoot have been made to get the kernel to load.
|
||||
* All of the changes are within IMAGE_FREEBSD such that the
|
||||
* extra/changed code only compiles when FREEBSD support is
|
||||
* enabled.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Section header for FreeBSD (debug symbol kludge!) support
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Word sh_name; /* Section name (index into the
|
||||
section header string table). */
|
||||
Elf32_Word sh_type; /* Section type. */
|
||||
Elf32_Word sh_flags; /* Section flags. */
|
||||
Elf32_Addr sh_addr; /* Address in memory image. */
|
||||
Elf32_Off sh_offset; /* Offset in file. */
|
||||
Elf32_Size sh_size; /* Size in bytes. */
|
||||
Elf32_Word sh_link; /* Index of a related section. */
|
||||
Elf32_Word sh_info; /* Depends on section type. */
|
||||
Elf32_Size sh_addralign; /* Alignment in bytes. */
|
||||
Elf32_Size sh_entsize; /* Size of each entry in section. */
|
||||
} Elf32_Shdr;
|
||||
|
||||
/* sh_type */
|
||||
#define SHT_SYMTAB 2 /* symbol table section */
|
||||
#define SHT_STRTAB 3 /* string table section */
|
||||
|
||||
/*
|
||||
* Module information subtypes (for the metadata that we need to build)
|
||||
*/
|
||||
#define MODINFO_END 0x0000 /* End of list */
|
||||
#define MODINFO_NAME 0x0001 /* Name of module (string) */
|
||||
#define MODINFO_TYPE 0x0002 /* Type of module (string) */
|
||||
#define MODINFO_METADATA 0x8000 /* Module-specfic */
|
||||
|
||||
#define MODINFOMD_SSYM 0x0003 /* start of symbols */
|
||||
#define MODINFOMD_ESYM 0x0004 /* end of symbols */
|
||||
|
||||
#endif /* IMAGE_FREEBSD */
|
||||
|
||||
#endif /* I386_BITS_ELF_H */
|
||||
@@ -1,5 +0,0 @@
|
||||
#define ARCH_ELF_CLASS ELFCLASS32
|
||||
#define ARCH_ELF_DATA ELFDATA2LSB
|
||||
#define ARCH_ELF_MACHINE_OK(x) ((x)==EM_386 || (x)==EM_486)
|
||||
typedef Elf32_Ehdr Elf_ehdr;
|
||||
typedef Elf32_Phdr Elf_phdr;
|
||||
@@ -6,7 +6,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ERRFILE_umalloc ( ERRFILE_ARCH | ERRFILE_CORE | 0x00000000 )
|
||||
#define ERRFILE_memtop_umalloc ( ERRFILE_ARCH | ERRFILE_CORE | 0x00000000 )
|
||||
#define ERRFILE_memmap ( ERRFILE_ARCH | ERRFILE_CORE | 0x00010000 )
|
||||
#define ERRFILE_pnpbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00020000 )
|
||||
#define ERRFILE_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef _BITS_IO_H
|
||||
#define _BITS_IO_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* i386-specific I/O API implementations
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gpxe/x86_io.h>
|
||||
|
||||
#endif /* _BITS_IO_H */
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _BITS_NAP_H
|
||||
#define _BITS_NAP_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* i386-specific CPU sleeping API implementations
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gpxe/bios_nap.h>
|
||||
#include <gpxe/efi/efix86_nap.h>
|
||||
|
||||
#endif /* _BITS_MAP_H */
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _BITS_PCI_IO_H
|
||||
#define _BITS_PCI_IO_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* i386-specific PCI I/O API implementations
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gpxe/pcibios.h>
|
||||
#include <gpxe/pcidirect.h>
|
||||
|
||||
#endif /* _BITS_PCI_IO_H */
|
||||
@@ -7,12 +7,12 @@ typedef signed long off_t;
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed long int32_t;
|
||||
typedef signed int int32_t;
|
||||
typedef signed long long int64_t;
|
||||
|
||||
typedef unsigned long physaddr_t;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _BITS_TIMER_H
|
||||
#define _BITS_TIMER_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* i386-specific timer API implementations
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gpxe/bios_timer.h>
|
||||
#include <gpxe/rdtsc_timer.h>
|
||||
|
||||
#endif /* _BITS_TIMER_H */
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef BITS_TIMER2_H
|
||||
#define BITS_TIMER2_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void i386_timer2_udelay(unsigned int usecs);
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,12 @@
|
||||
#ifndef _BITS_UACCESS_H
|
||||
#define _BITS_UACCESS_H
|
||||
|
||||
#include <realmode.h>
|
||||
/** @file
|
||||
*
|
||||
* i386-specific user access API implementations
|
||||
*
|
||||
*/
|
||||
|
||||
#include <librm.h>
|
||||
|
||||
#endif /* _BITS_UACCESS_H */
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef _BITS_UMALLOC_H
|
||||
#define _BITS_UMALLOC_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* i386-specific user memory allocation API implementations
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gpxe/memtop_umalloc.h>
|
||||
|
||||
#endif /* _BITS_UMALLOC_H */
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint32_t gdbreg_t;
|
||||
typedef unsigned long gdbreg_t;
|
||||
|
||||
/* The register snapshot, this must be in sync with interrupt handler and the
|
||||
* GDB protocol. */
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _GPXE_BIOS_NAP_H
|
||||
#define _GPXE_BIOS_NAP_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* BIOS CPU sleeping
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef NAP_PCBIOS
|
||||
#define NAP_PREFIX_pcbios
|
||||
#else
|
||||
#define NAP_PREFIX_pcbios __pcbios_
|
||||
#endif
|
||||
|
||||
#endif /* _GPXE_BIOS_NAP_H */
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef _GPXE_BIOS_TIMER_H
|
||||
#define _GPXE_BIOS_TIMER_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* BIOS timer
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef TIMER_PCBIOS
|
||||
#define TIMER_PREFIX_pcbios
|
||||
#else
|
||||
#define TIMER_PREFIX_pcbios __pcbios_
|
||||
#endif
|
||||
|
||||
#include <gpxe/timer2.h>
|
||||
|
||||
/**
|
||||
* Delay for a fixed number of microseconds
|
||||
*
|
||||
* @v usecs Number of microseconds for which to delay
|
||||
*/
|
||||
static inline __always_inline void
|
||||
TIMER_INLINE ( pcbios, udelay ) ( unsigned long usecs ) {
|
||||
/* BIOS timer is not high-resolution enough for udelay(), so
|
||||
* we use timer2
|
||||
*/
|
||||
timer2_udelay ( usecs );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of ticks per second
|
||||
*
|
||||
* @ret ticks_per_sec Number of ticks per second
|
||||
*/
|
||||
static inline __always_inline unsigned long
|
||||
TIMER_INLINE ( pcbios, ticks_per_sec ) ( void ) {
|
||||
/* BIOS timer ticks over at 18.2 ticks per second */
|
||||
return 18;
|
||||
}
|
||||
|
||||
#endif /* _GPXE_BIOS_TIMER_H */
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _GPXE_EFIX86_NAP_H
|
||||
#define _GPXE_EFIX86_NAP_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* EFI CPU sleeping
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef NAP_EFIX86
|
||||
#define NAP_PREFIX_efix86
|
||||
#else
|
||||
#define NAP_PREFIX_efix86 __efix86_
|
||||
#endif
|
||||
|
||||
#endif /* _GPXE_EFIX86_NAP_H */
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _GPXE_MEMTOP_UMALLOC_H
|
||||
#define _GPXE_MEMTOP_UMALLOC_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* External memory allocation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef UMALLOC_MEMTOP
|
||||
#define UMALLOC_PREFIX_memtop
|
||||
#else
|
||||
#define UMALLOC_PREFIX_memtop __memtop_
|
||||
#endif
|
||||
|
||||
#endif /* _GPXE_MEMTOP_UMALLOC_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _PCIBIOS_H
|
||||
#define _PCIBIOS_H
|
||||
#ifndef _GPXE_PCIBIOS_H
|
||||
#define _GPXE_PCIBIOS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -9,6 +9,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef PCIAPI_PCBIOS
|
||||
#define PCIAPI_PREFIX_pcbios
|
||||
#else
|
||||
#define PCIAPI_PREFIX_pcbios __pcbios_
|
||||
#endif
|
||||
|
||||
struct pci_device;
|
||||
|
||||
#define PCIBIOS_INSTALLATION_CHECK 0xb1010000
|
||||
@@ -19,7 +25,6 @@ struct pci_device;
|
||||
#define PCIBIOS_WRITE_CONFIG_WORD 0xb10c0000
|
||||
#define PCIBIOS_WRITE_CONFIG_DWORD 0xb10d0000
|
||||
|
||||
extern int pcibios_max_bus ( void );
|
||||
extern int pcibios_read ( struct pci_device *pci, uint32_t command,
|
||||
uint32_t *value );
|
||||
extern int pcibios_write ( struct pci_device *pci, uint32_t command,
|
||||
@@ -33,9 +38,10 @@ extern int pcibios_write ( struct pci_device *pci, uint32_t command,
|
||||
* @v value Value read
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcibios_read_config_byte ( struct pci_device *pci, unsigned int where,
|
||||
uint8_t *value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( pcbios, pci_read_config_byte ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint8_t *value ) {
|
||||
uint32_t tmp;
|
||||
int rc;
|
||||
|
||||
@@ -52,9 +58,10 @@ pcibios_read_config_byte ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value read
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcibios_read_config_word ( struct pci_device *pci, unsigned int where,
|
||||
uint16_t *value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( pcbios, pci_read_config_word ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint16_t *value ) {
|
||||
uint32_t tmp;
|
||||
int rc;
|
||||
|
||||
@@ -71,9 +78,10 @@ pcibios_read_config_word ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value read
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcibios_read_config_dword ( struct pci_device *pci, unsigned int where,
|
||||
uint32_t *value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( pcbios, pci_read_config_dword ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint32_t *value ) {
|
||||
return pcibios_read ( pci, PCIBIOS_READ_CONFIG_DWORD | where, value );
|
||||
}
|
||||
|
||||
@@ -85,9 +93,10 @@ pcibios_read_config_dword ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value to be written
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcibios_write_config_byte ( struct pci_device *pci, unsigned int where,
|
||||
uint8_t value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( pcbios, pci_write_config_byte ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint8_t value ) {
|
||||
return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_BYTE | where, value );
|
||||
}
|
||||
|
||||
@@ -99,9 +108,10 @@ pcibios_write_config_byte ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value to be written
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcibios_write_config_word ( struct pci_device *pci, unsigned int where,
|
||||
uint16_t value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( pcbios, pci_write_config_word ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint16_t value ) {
|
||||
return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_WORD | where, value );
|
||||
}
|
||||
|
||||
@@ -113,10 +123,11 @@ pcibios_write_config_word ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value to be written
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcibios_write_config_dword ( struct pci_device *pci, unsigned int where,
|
||||
uint32_t value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( pcbios, pci_write_config_dword ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint32_t value ) {
|
||||
return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_DWORD | where, value);
|
||||
}
|
||||
|
||||
#endif /* _PCIBIOS_H */
|
||||
#endif /* _GPXE_PCIBIOS_H */
|
||||
@@ -2,7 +2,13 @@
|
||||
#define _PCIDIRECT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <io.h>
|
||||
#include <gpxe/io.h>
|
||||
|
||||
#ifdef PCIAPI_DIRECT
|
||||
#define PCIAPI_PREFIX_direct
|
||||
#else
|
||||
#define PCIAPI_PREFIX_direct __direct_
|
||||
#endif
|
||||
|
||||
/** @file
|
||||
*
|
||||
@@ -22,7 +28,8 @@ extern void pcidirect_prepare ( struct pci_device *pci, int where );
|
||||
*
|
||||
* @ret max_bus Maximum bus number
|
||||
*/
|
||||
static inline int pcidirect_max_bus ( void ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( direct, pci_max_bus ) ( void ) {
|
||||
/* No way to work this out via Type 1 accesses */
|
||||
return 0xff;
|
||||
}
|
||||
@@ -35,9 +42,10 @@ static inline int pcidirect_max_bus ( void ) {
|
||||
* @v value Value read
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcidirect_read_config_byte ( struct pci_device *pci, unsigned int where,
|
||||
uint8_t *value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( direct, pci_read_config_byte ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint8_t *value ) {
|
||||
pcidirect_prepare ( pci, where );
|
||||
*value = inb ( PCIDIRECT_CONFIG_DATA + ( where & 3 ) );
|
||||
return 0;
|
||||
@@ -51,9 +59,10 @@ pcidirect_read_config_byte ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value read
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcidirect_read_config_word ( struct pci_device *pci, unsigned int where,
|
||||
uint16_t *value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( direct, pci_read_config_word ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint16_t *value ) {
|
||||
pcidirect_prepare ( pci, where );
|
||||
*value = inw ( PCIDIRECT_CONFIG_DATA + ( where & 2 ) );
|
||||
return 0;
|
||||
@@ -67,9 +76,10 @@ pcidirect_read_config_word ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value read
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcidirect_read_config_dword ( struct pci_device *pci, unsigned int where,
|
||||
uint32_t *value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( direct, pci_read_config_dword ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint32_t *value ) {
|
||||
pcidirect_prepare ( pci, where );
|
||||
*value = inl ( PCIDIRECT_CONFIG_DATA );
|
||||
return 0;
|
||||
@@ -83,9 +93,10 @@ pcidirect_read_config_dword ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value to be written
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcidirect_write_config_byte ( struct pci_device *pci, unsigned int where,
|
||||
uint8_t value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( direct, pci_write_config_byte ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint8_t value ) {
|
||||
pcidirect_prepare ( pci, where );
|
||||
outb ( value, PCIDIRECT_CONFIG_DATA + ( where & 3 ) );
|
||||
return 0;
|
||||
@@ -99,9 +110,10 @@ pcidirect_write_config_byte ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value to be written
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcidirect_write_config_word ( struct pci_device *pci, unsigned int where,
|
||||
uint16_t value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( direct, pci_write_config_word ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint16_t value ) {
|
||||
pcidirect_prepare ( pci, where );
|
||||
outw ( value, PCIDIRECT_CONFIG_DATA + ( where & 2 ) );
|
||||
return 0;
|
||||
@@ -115,9 +127,10 @@ pcidirect_write_config_word ( struct pci_device *pci, unsigned int where,
|
||||
* @v value Value to be written
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) int
|
||||
pcidirect_write_config_dword ( struct pci_device *pci, unsigned int where,
|
||||
uint32_t value ) {
|
||||
static inline __always_inline int
|
||||
PCIAPI_INLINE ( direct, pci_write_config_dword ) ( struct pci_device *pci,
|
||||
unsigned int where,
|
||||
uint32_t value ) {
|
||||
pcidirect_prepare ( pci, where );
|
||||
outl ( value, PCIDIRECT_CONFIG_DATA );
|
||||
return 0;
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef _GPXE_RDTSC_TIMER_H
|
||||
#define _GPXE_RDTSC_TIMER_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* RDTSC timer
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef TIMER_RDTSC
|
||||
#define TIMER_PREFIX_rdtsc
|
||||
#else
|
||||
#define TIMER_PREFIX_rdtsc __rdtsc_
|
||||
#endif
|
||||
|
||||
/**
|
||||
* RDTSC values can easily overflow an unsigned long. We discard the
|
||||
* low-order bits in order to obtain sensibly-scaled values.
|
||||
*/
|
||||
#define TSC_SHIFT 8
|
||||
|
||||
/**
|
||||
* Get current system time in ticks
|
||||
*
|
||||
* @ret ticks Current time, in ticks
|
||||
*/
|
||||
static inline __always_inline unsigned long
|
||||
TIMER_INLINE ( rdtsc, currticks ) ( void ) {
|
||||
unsigned long ticks;
|
||||
|
||||
__asm__ __volatile__ ( "rdtsc\n\t"
|
||||
"shrdl %1, %%edx, %%eax\n\t"
|
||||
: "=a" ( ticks ) : "i" ( TSC_SHIFT ) : "edx" );
|
||||
return ticks;
|
||||
}
|
||||
|
||||
#endif /* _GPXE_RDTSC_TIMER_H */
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef _GPXE_TIMER2_H
|
||||
#define _GPXE_TIMER2_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Timer chip control
|
||||
*
|
||||
*/
|
||||
|
||||
extern void timer2_udelay ( unsigned long usecs );
|
||||
|
||||
#endif /* _GPXE_TIMER2_H */
|
||||
@@ -0,0 +1,151 @@
|
||||
#ifndef _GPXE_X86_IO_H
|
||||
#define _GPXE_X86_IO_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* gPXE I/O API for x86
|
||||
*
|
||||
* i386 uses direct pointer dereferences for accesses to memory-mapped
|
||||
* I/O space, and the inX/outX instructions for accesses to
|
||||
* port-mapped I/O space.
|
||||
*
|
||||
* 64-bit atomic accesses (readq() and writeq()) use MMX instructions,
|
||||
* and will crash original Pentium and earlier CPUs. Fortunately, no
|
||||
* hardware that requires atomic 64-bit accesses will physically fit
|
||||
* into a machine with such an old CPU anyway.
|
||||
*/
|
||||
|
||||
#ifdef IOAPI_X86
|
||||
#define IOAPI_PREFIX_x86
|
||||
#else
|
||||
#define IOAPI_PREFIX_x86 __x86_
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Memory space mappings
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Physical<->Bus and Bus<->I/O address mappings
|
||||
*
|
||||
*/
|
||||
|
||||
static inline __always_inline unsigned long
|
||||
IOAPI_INLINE ( x86, phys_to_bus ) ( unsigned long phys_addr ) {
|
||||
return phys_addr;
|
||||
}
|
||||
|
||||
static inline __always_inline unsigned long
|
||||
IOAPI_INLINE ( x86, bus_to_phys ) ( unsigned long bus_addr ) {
|
||||
return bus_addr;
|
||||
}
|
||||
|
||||
static inline __always_inline void *
|
||||
IOAPI_INLINE ( x86, ioremap ) ( unsigned long bus_addr, size_t len __unused ) {
|
||||
return phys_to_virt ( bus_addr );
|
||||
}
|
||||
|
||||
static inline __always_inline void
|
||||
IOAPI_INLINE ( x86, iounmap ) ( volatile const void *io_addr __unused ) {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
static inline __always_inline unsigned long
|
||||
IOAPI_INLINE ( x86, io_to_bus ) ( volatile const void *io_addr ) {
|
||||
return virt_to_phys ( io_addr );
|
||||
}
|
||||
|
||||
/*
|
||||
* MMIO reads and writes up to 32 bits
|
||||
*
|
||||
*/
|
||||
|
||||
#define X86_READX( _api_func, _type ) \
|
||||
static inline __always_inline _type \
|
||||
IOAPI_INLINE ( x86, _api_func ) ( volatile _type *io_addr ) { \
|
||||
return *io_addr; \
|
||||
}
|
||||
X86_READX ( readb, uint8_t );
|
||||
X86_READX ( readw, uint16_t );
|
||||
X86_READX ( readl, uint32_t );
|
||||
|
||||
#define X86_WRITEX( _api_func, _type ) \
|
||||
static inline __always_inline void \
|
||||
IOAPI_INLINE ( x86, _api_func ) ( _type data, \
|
||||
volatile _type *io_addr ) { \
|
||||
*io_addr = data; \
|
||||
}
|
||||
X86_WRITEX ( writeb, uint8_t );
|
||||
X86_WRITEX ( writew, uint16_t );
|
||||
X86_WRITEX ( writel, uint32_t );
|
||||
|
||||
/*
|
||||
* PIO reads and writes up to 32 bits
|
||||
*
|
||||
*/
|
||||
|
||||
#define X86_INX( _insn_suffix, _type, _reg_prefix ) \
|
||||
static inline __always_inline _type \
|
||||
IOAPI_INLINE ( x86, in ## _insn_suffix ) ( volatile _type *io_addr ) { \
|
||||
_type data; \
|
||||
__asm__ __volatile__ ( "in" #_insn_suffix " %w1, %" _reg_prefix "0" \
|
||||
: "=a" ( data ) : "Nd" ( io_addr ) ); \
|
||||
return data; \
|
||||
} \
|
||||
static inline __always_inline void \
|
||||
IOAPI_INLINE ( x86, ins ## _insn_suffix ) ( volatile _type *io_addr, \
|
||||
_type *data, \
|
||||
unsigned int count ) { \
|
||||
unsigned int discard_D; \
|
||||
__asm__ __volatile__ ( "rep ins" #_insn_suffix \
|
||||
: "=D" ( discard_D ) \
|
||||
: "d" ( io_addr ), "c" ( count ), \
|
||||
"0" ( data ) ); \
|
||||
}
|
||||
X86_INX ( b, uint8_t, "b" );
|
||||
X86_INX ( w, uint16_t, "w" );
|
||||
X86_INX ( l, uint32_t, "k" );
|
||||
|
||||
#define X86_OUTX( _insn_suffix, _type, _reg_prefix ) \
|
||||
static inline __always_inline void \
|
||||
IOAPI_INLINE ( x86, out ## _insn_suffix ) ( _type data, \
|
||||
volatile _type *io_addr ) { \
|
||||
__asm__ __volatile__ ( "out" #_insn_suffix " %" _reg_prefix "0, %w1" \
|
||||
: : "a" ( data ), "Nd" ( io_addr ) ); \
|
||||
} \
|
||||
static inline __always_inline void \
|
||||
IOAPI_INLINE ( x86, outs ## _insn_suffix ) ( volatile _type *io_addr, \
|
||||
const _type *data, \
|
||||
unsigned int count ) { \
|
||||
unsigned int discard_S; \
|
||||
__asm__ __volatile__ ( "rep outs" #_insn_suffix \
|
||||
: "=S" ( discard_S ) \
|
||||
: "d" ( io_addr ), "c" ( count ), \
|
||||
"0" ( data ) ); \
|
||||
}
|
||||
X86_OUTX ( b, uint8_t, "b" );
|
||||
X86_OUTX ( w, uint16_t, "w" );
|
||||
X86_OUTX ( l, uint32_t, "k" );
|
||||
|
||||
/*
|
||||
* Slow down I/O
|
||||
*
|
||||
*/
|
||||
|
||||
static inline __always_inline void
|
||||
IOAPI_INLINE ( x86, iodelay ) ( void ) {
|
||||
__asm__ __volatile__ ( "outb %al, $0x80" );
|
||||
}
|
||||
|
||||
/*
|
||||
* Memory barrier
|
||||
*
|
||||
*/
|
||||
|
||||
static inline __always_inline void
|
||||
IOAPI_INLINE ( x86, mb ) ( void ) {
|
||||
__asm__ __volatile__ ( "lock; addl $0, 0(%%esp)" : : : "memory" );
|
||||
}
|
||||
|
||||
#endif /* _GPXE_X86_IO_H */
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gpxe/list.h>
|
||||
#include <realmode.h>
|
||||
|
||||
struct block_device;
|
||||
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
#ifndef ETHERBOOT_IO_H
|
||||
#define ETHERBOOT_IO_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "virtaddr.h"
|
||||
|
||||
/* virt_to_bus converts an addresss inside of etherboot [_start, _end]
|
||||
* into a memory access cards can use.
|
||||
*/
|
||||
#define virt_to_bus virt_to_phys
|
||||
|
||||
|
||||
/* bus_to_virt reverses virt_to_bus, the address must be output
|
||||
* from virt_to_bus to be valid. This function does not work on
|
||||
* all bus addresses.
|
||||
*/
|
||||
#define bus_to_virt phys_to_virt
|
||||
|
||||
/* ioremap converts a random 32bit bus address into something
|
||||
* etherboot can access.
|
||||
*/
|
||||
static inline void *ioremap(unsigned long bus_addr, unsigned long length __unused)
|
||||
{
|
||||
return bus_to_virt(bus_addr);
|
||||
}
|
||||
|
||||
/* iounmap cleans up anything ioremap had to setup */
|
||||
static inline void iounmap(void *virt_addr __unused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This file contains the definitions for the x86 IO instructions
|
||||
* inb/inw/inl/outb/outw/outl and the "string versions" of the same
|
||||
* (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
|
||||
* versions of the single-IO instructions (inb_p/inw_p/..).
|
||||
*
|
||||
* This file is not meant to be obfuscating: it's just complicated
|
||||
* to (a) handle it all in a way that makes gcc able to optimize it
|
||||
* as well as possible and (b) trying to avoid writing the same thing
|
||||
* over and over again with slight variations and possibly making a
|
||||
* mistake somewhere.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Thanks to James van Artsdalen for a better timing-fix than
|
||||
* the two short jumps: using outb's to a nonexistent port seems
|
||||
* to guarantee better timings even on fast machines.
|
||||
*
|
||||
* On the other hand, I'd like to be sure of a non-existent port:
|
||||
* I feel a bit unsafe about using 0x80 (should be safe, though)
|
||||
*
|
||||
* Linus
|
||||
*/
|
||||
|
||||
#ifdef SLOW_IO_BY_JUMPING
|
||||
#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
|
||||
#else
|
||||
#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
|
||||
#endif
|
||||
|
||||
#ifdef REALLY_SLOW_IO
|
||||
#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
|
||||
#else
|
||||
#define SLOW_DOWN_IO __SLOW_DOWN_IO
|
||||
#endif
|
||||
|
||||
/*
|
||||
* readX/writeX() are used to access memory mapped devices. On some
|
||||
* architectures the memory mapped IO stuff needs to be accessed
|
||||
* differently. On the x86 architecture, we just read/write the
|
||||
* memory location directly.
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) unsigned long
|
||||
_readb ( volatile uint8_t *addr ) {
|
||||
unsigned long data = *addr;
|
||||
DBGIO ( "[%08lx] => %02lx\n", virt_to_phys ( addr ), data );
|
||||
return data;
|
||||
}
|
||||
static inline __attribute__ (( always_inline )) unsigned long
|
||||
_readw ( volatile uint16_t *addr ) {
|
||||
unsigned long data = *addr;
|
||||
DBGIO ( "[%08lx] => %04lx\n", virt_to_phys ( addr ), data );
|
||||
return data;
|
||||
}
|
||||
static inline __attribute__ (( always_inline )) unsigned long
|
||||
_readl ( volatile uint32_t *addr ) {
|
||||
unsigned long data = *addr;
|
||||
DBGIO ( "[%08lx] => %08lx\n", virt_to_phys ( addr ), data );
|
||||
return data;
|
||||
}
|
||||
#define readb( addr ) _readb ( ( volatile uint8_t * ) (addr) )
|
||||
#define readw( addr ) _readw ( ( volatile uint16_t * ) (addr) )
|
||||
#define readl( addr ) _readl ( ( volatile uint32_t * ) (addr) )
|
||||
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
_writeb ( unsigned long data, volatile uint8_t *addr ) {
|
||||
DBGIO ( "[%08lx] <= %02lx\n", virt_to_phys ( addr ), data );
|
||||
*addr = data;
|
||||
}
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
_writew ( unsigned long data, volatile uint16_t *addr ) {
|
||||
DBGIO ( "[%08lx] <= %04lx\n", virt_to_phys ( addr ), data );
|
||||
*addr = data;
|
||||
}
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
_writel ( unsigned long data, volatile uint32_t *addr ) {
|
||||
DBGIO ( "[%08lx] <= %08lx\n", virt_to_phys ( addr ), data );
|
||||
*addr = data;
|
||||
}
|
||||
#define writeb( b, addr ) _writeb ( (b), ( volatile uint8_t * ) (addr) )
|
||||
#define writew( b, addr ) _writew ( (b), ( volatile uint16_t * ) (addr) )
|
||||
#define writel( b, addr ) _writel ( (b), ( volatile uint32_t * ) (addr) )
|
||||
|
||||
#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
|
||||
#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
|
||||
|
||||
/*
|
||||
* Force strict CPU ordering.
|
||||
* And yes, this is required on UP too when we're talking
|
||||
* to devices.
|
||||
*
|
||||
* For now, "wmb()" doesn't actually do anything, as all
|
||||
* Intel CPU's follow what Intel calls a *Processor Order*,
|
||||
* in which all writes are seen in the program order even
|
||||
* outside the CPU.
|
||||
*
|
||||
* I expect future Intel CPU's to have a weaker ordering,
|
||||
* but I'd also expect them to finally get their act together
|
||||
* and add some real memory barriers if so.
|
||||
*
|
||||
* Some non intel clones support out of order store. wmb() ceases to be a
|
||||
* nop for these.
|
||||
*/
|
||||
|
||||
#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
|
||||
#define rmb() mb()
|
||||
#define wmb() mb();
|
||||
|
||||
|
||||
/*
|
||||
* Talk about misusing macros..
|
||||
*/
|
||||
|
||||
#define __OUT1(s,x) \
|
||||
extern void __out##s(unsigned x value, unsigned short port); \
|
||||
extern inline void __out##s(unsigned x value, unsigned short port) {
|
||||
|
||||
#define __OUT2(s,s1,s2) \
|
||||
__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
|
||||
|
||||
#define __OUT(s,s1,x) \
|
||||
__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
|
||||
__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
|
||||
__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
|
||||
__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
|
||||
|
||||
#define __IN1(s,x) \
|
||||
extern unsigned x __in##s(unsigned short port); \
|
||||
extern inline unsigned x __in##s(unsigned short port) { unsigned x _v;
|
||||
|
||||
#define __IN2(s,s1,s2) \
|
||||
__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
|
||||
|
||||
#define __IN(s,s1,x,i...) \
|
||||
__IN1(s,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
|
||||
__IN1(s##c,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
|
||||
__IN1(s##_p,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
|
||||
__IN1(s##c_p,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
|
||||
|
||||
#define __INS(s) \
|
||||
extern void ins##s(unsigned short port, void * addr, unsigned long count); \
|
||||
extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
|
||||
{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
|
||||
: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
|
||||
|
||||
#define __OUTS(s) \
|
||||
extern void outs##s(unsigned short port, const void * addr, unsigned long count); \
|
||||
extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
|
||||
{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
|
||||
: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
|
||||
|
||||
__IN(b,"", char)
|
||||
__IN(w,"",short)
|
||||
__IN(l,"", long)
|
||||
|
||||
__OUT(b,"b",char)
|
||||
__OUT(w,"w",short)
|
||||
__OUT(l,,int)
|
||||
|
||||
__INS(b)
|
||||
__INS(w)
|
||||
__INS(l)
|
||||
|
||||
__OUTS(b)
|
||||
__OUTS(w)
|
||||
__OUTS(l)
|
||||
|
||||
/*
|
||||
* Note that due to the way __builtin_constant_p() works, you
|
||||
* - can't use it inside a inline function (it will never be true)
|
||||
* - you don't have to worry about side effects within the __builtin..
|
||||
*/
|
||||
#define outb(val,port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__outbc((val),(port)) : \
|
||||
__outb((val),(port)))
|
||||
|
||||
#define inb(port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__inbc(port) : \
|
||||
__inb(port))
|
||||
|
||||
#define outb_p(val,port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__outbc_p((val),(port)) : \
|
||||
__outb_p((val),(port)))
|
||||
|
||||
#define inb_p(port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__inbc_p(port) : \
|
||||
__inb_p(port))
|
||||
|
||||
#define outw(val,port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__outwc((val),(port)) : \
|
||||
__outw((val),(port)))
|
||||
|
||||
#define inw(port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__inwc(port) : \
|
||||
__inw(port))
|
||||
|
||||
#define outw_p(val,port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__outwc_p((val),(port)) : \
|
||||
__outw_p((val),(port)))
|
||||
|
||||
#define inw_p(port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__inwc_p(port) : \
|
||||
__inw_p(port))
|
||||
|
||||
#define outl(val,port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__outlc((val),(port)) : \
|
||||
__outl((val),(port)))
|
||||
|
||||
#define inl(port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__inlc(port) : \
|
||||
__inl(port))
|
||||
|
||||
#define outl_p(val,port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__outlc_p((val),(port)) : \
|
||||
__outl_p((val),(port)))
|
||||
|
||||
#define inl_p(port) \
|
||||
((__builtin_constant_p((port)) && (port) < 256) ? \
|
||||
__inlc_p(port) : \
|
||||
__inl_p(port))
|
||||
|
||||
#endif /* ETHERBOOT_IO_H */
|
||||
+98
-205
@@ -1,21 +1,109 @@
|
||||
#ifndef LIBRM_H
|
||||
#define LIBRM_H
|
||||
|
||||
/* Drag in protected-mode segment selector values */
|
||||
#include "virtaddr.h"
|
||||
#include "realmode.h"
|
||||
/* Segment selectors as used in our protected-mode GDTs.
|
||||
*
|
||||
* Don't change these unless you really know what you're doing.
|
||||
*/
|
||||
|
||||
#define VIRTUAL_CS 0x08
|
||||
#define VIRTUAL_DS 0x10
|
||||
#define PHYSICAL_CS 0x18
|
||||
#define PHYSICAL_DS 0x20
|
||||
#define REAL_CS 0x28
|
||||
#define REAL_DS 0x30
|
||||
#if 0
|
||||
#define LONG_CS 0x38
|
||||
#define LONG_DS 0x40
|
||||
#endif
|
||||
|
||||
#ifndef ASSEMBLY
|
||||
|
||||
#include "stddef.h"
|
||||
#include "string.h"
|
||||
#ifdef UACCESS_LIBRM
|
||||
#define UACCESS_PREFIX_librm
|
||||
#else
|
||||
#define UACCESS_PREFIX_librm __librm_
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Data structures and type definitions
|
||||
/* Variables in librm.S */
|
||||
extern unsigned long virt_offset;
|
||||
|
||||
/**
|
||||
* Convert physical address to user pointer
|
||||
*
|
||||
* @v phys_addr Physical address
|
||||
* @ret userptr User pointer
|
||||
*/
|
||||
static inline __always_inline userptr_t
|
||||
UACCESS_INLINE ( librm, phys_to_user ) ( unsigned long phys_addr ) {
|
||||
return ( phys_addr - virt_offset );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert user buffer to physical address
|
||||
*
|
||||
* @v userptr User pointer
|
||||
* @v offset Offset from user pointer
|
||||
* @ret phys_addr Physical address
|
||||
*/
|
||||
static inline __always_inline unsigned long
|
||||
UACCESS_INLINE ( librm, user_to_phys ) ( userptr_t userptr, off_t offset ) {
|
||||
return ( userptr + offset + virt_offset );
|
||||
}
|
||||
|
||||
static inline __always_inline userptr_t
|
||||
UACCESS_INLINE ( librm, virt_to_user ) ( volatile const void *addr ) {
|
||||
return trivial_virt_to_user ( addr );
|
||||
}
|
||||
|
||||
static inline __always_inline void *
|
||||
UACCESS_INLINE ( librm, user_to_virt ) ( userptr_t userptr, off_t offset ) {
|
||||
return trivial_user_to_virt ( userptr, offset );
|
||||
}
|
||||
|
||||
static inline __always_inline userptr_t
|
||||
UACCESS_INLINE ( librm, userptr_add ) ( userptr_t userptr, off_t offset ) {
|
||||
return trivial_userptr_add ( userptr, offset );
|
||||
}
|
||||
|
||||
static inline __always_inline void
|
||||
UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off,
|
||||
userptr_t src, off_t src_off,
|
||||
size_t len ) {
|
||||
trivial_memcpy_user ( dest, dest_off, src, src_off, len );
|
||||
}
|
||||
|
||||
static inline __always_inline void
|
||||
UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off,
|
||||
userptr_t src, off_t src_off,
|
||||
size_t len ) {
|
||||
trivial_memmove_user ( dest, dest_off, src, src_off, len );
|
||||
}
|
||||
|
||||
static inline __always_inline void
|
||||
UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset,
|
||||
int c, size_t len ) {
|
||||
trivial_memset_user ( buffer, offset, c, len );
|
||||
}
|
||||
|
||||
static inline __always_inline size_t
|
||||
UACCESS_INLINE ( librm, strlen_user ) ( userptr_t buffer, off_t offset ) {
|
||||
return trivial_strlen_user ( buffer, offset );
|
||||
}
|
||||
|
||||
static inline __always_inline off_t
|
||||
UACCESS_INLINE ( librm, memchr_user ) ( userptr_t buffer, off_t offset,
|
||||
int c, size_t len ) {
|
||||
return trivial_memchr_user ( buffer, offset, c, len );
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Access to variables in .data16 and .text16
|
||||
*
|
||||
*/
|
||||
|
||||
/* Access to variables in .data16 and .text16 */
|
||||
extern char *data16;
|
||||
extern char *text16;
|
||||
|
||||
@@ -72,178 +160,6 @@ extern uint16_t __text16 ( rm_ds );
|
||||
*/
|
||||
extern void gateA20_set ( void );
|
||||
|
||||
/*
|
||||
* librm_mgmt: functions for manipulating base memory and executing
|
||||
* real-mode code.
|
||||
*
|
||||
* Full API documentation for these functions is in realmode.h.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Macro for obtaining a physical address from a segment:offset pair. */
|
||||
#define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )
|
||||
|
||||
/* Copy to/from base memory */
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
copy_to_real_librm ( unsigned int dest_seg, unsigned int dest_off,
|
||||
void *src, size_t n ) {
|
||||
memcpy ( VIRTUAL ( dest_seg, dest_off ), src, n );
|
||||
}
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
copy_from_real_librm ( void *dest, unsigned int src_seg,
|
||||
unsigned int src_off, size_t n ) {
|
||||
memcpy ( dest, VIRTUAL ( src_seg, src_off ), n );
|
||||
}
|
||||
#define put_real_librm( var, dest_seg, dest_off ) \
|
||||
do { \
|
||||
* ( ( typeof(var) * ) VIRTUAL ( dest_seg, dest_off ) ) = var; \
|
||||
} while ( 0 )
|
||||
#define get_real_librm( var, src_seg, src_off ) \
|
||||
do { \
|
||||
var = * ( ( typeof(var) * ) VIRTUAL ( src_seg, src_off ) ); \
|
||||
} while ( 0 )
|
||||
#define copy_to_real copy_to_real_librm
|
||||
#define copy_from_real copy_from_real_librm
|
||||
#define put_real put_real_librm
|
||||
#define get_real get_real_librm
|
||||
|
||||
/**
|
||||
* A pointer to a user buffer
|
||||
*
|
||||
* Even though we could just use a void *, we use an intptr_t so that
|
||||
* attempts to use normal pointers show up as compiler warnings. Such
|
||||
* code is actually valid for librm, but not for libkir (i.e. under
|
||||
* KEEP_IT_REAL), so it's good to have the warnings even under librm.
|
||||
*/
|
||||
typedef intptr_t userptr_t;
|
||||
|
||||
/**
|
||||
* Add offset to user pointer
|
||||
*
|
||||
* @v ptr User pointer
|
||||
* @v offset Offset
|
||||
* @ret new_ptr New pointer value
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) userptr_t
|
||||
userptr_add ( userptr_t ptr, off_t offset ) {
|
||||
return ( ptr + offset );
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy data to user buffer
|
||||
*
|
||||
* @v buffer User buffer
|
||||
* @v offset Offset within user buffer
|
||||
* @v src Source
|
||||
* @v len Length
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
copy_to_user ( userptr_t buffer, off_t offset, const void *src, size_t len ) {
|
||||
memcpy ( ( ( void * ) buffer + offset ), src, len );
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy data from user buffer
|
||||
*
|
||||
* @v dest Destination
|
||||
* @v buffer User buffer
|
||||
* @v offset Offset within user buffer
|
||||
* @v len Length
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
copy_from_user ( void *dest, userptr_t buffer, off_t offset, size_t len ) {
|
||||
memcpy ( dest, ( ( void * ) buffer + offset ), len );
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy data between user buffers
|
||||
*
|
||||
* @v dest Destination user buffer
|
||||
* @v dest_off Offset within destination buffer
|
||||
* @v src Source user buffer
|
||||
* @v src_off Offset within source buffer
|
||||
* @v len Length
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
memcpy_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
|
||||
size_t len ) {
|
||||
memcpy ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
|
||||
len );
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy data between user buffers, allowing for overlap
|
||||
*
|
||||
* @v dest Destination user buffer
|
||||
* @v dest_off Offset within destination buffer
|
||||
* @v src Source user buffer
|
||||
* @v src_off Offset within source buffer
|
||||
* @v len Length
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
memmove_user ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off,
|
||||
size_t len ) {
|
||||
memmove ( ( ( void * ) dest + dest_off ), ( ( void * ) src + src_off ),
|
||||
len );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill user buffer with a constant byte
|
||||
*
|
||||
* @v buffer User buffer
|
||||
* @v offset Offset within buffer
|
||||
* @v c Constant byte with which to fill
|
||||
* @v len Length
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
memset_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
|
||||
memset ( ( ( void * ) buffer + offset ), c, len );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find length of NUL-terminated string in user buffer
|
||||
*
|
||||
* @v buffer User buffer
|
||||
* @v offset Offset within buffer
|
||||
* @ret len Length of string (excluding NUL)
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) size_t
|
||||
strlen_user ( userptr_t buffer, off_t offset ) {
|
||||
return strlen ( ( void * ) buffer + offset );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find character in user buffer
|
||||
*
|
||||
* @v buffer User buffer
|
||||
* @v offset Starting offset within buffer
|
||||
* @v c Character to search for
|
||||
* @v len Length of user buffer
|
||||
* @ret offset Offset of character, or <0 if not found
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) off_t
|
||||
memchr_user ( userptr_t buffer, off_t offset, int c, size_t len ) {
|
||||
void *found;
|
||||
|
||||
found = memchr ( ( ( void * ) buffer + offset ), c, len );
|
||||
return ( found ? ( found - ( void * ) buffer ) : -1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert virtual address to user buffer
|
||||
*
|
||||
* @v virtual Virtual address
|
||||
* @ret buffer User buffer
|
||||
*
|
||||
* This constructs a user buffer from an ordinary pointer. Use it
|
||||
* when you need to pass a pointer to an internal buffer to a function
|
||||
* that expects a @c userptr_t.
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) userptr_t
|
||||
virt_to_user ( void * virtual ) {
|
||||
return ( ( intptr_t ) virtual );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert segment:offset address to user buffer
|
||||
*
|
||||
@@ -251,32 +167,9 @@ virt_to_user ( void * virtual ) {
|
||||
* @v offset Real-mode offset
|
||||
* @ret buffer User buffer
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) userptr_t
|
||||
static inline __always_inline userptr_t
|
||||
real_to_user ( unsigned int segment, unsigned int offset ) {
|
||||
return virt_to_user ( VIRTUAL ( segment, offset ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert physical address to user buffer
|
||||
*
|
||||
* @v physical Physical address
|
||||
* @ret buffer User buffer
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) userptr_t
|
||||
phys_to_user ( physaddr_t physical ) {
|
||||
return virt_to_user ( phys_to_virt ( physical ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert user buffer to physical address
|
||||
*
|
||||
* @v buffer User buffer
|
||||
* @v offset Offset within user buffer
|
||||
* @ret physical Physical address
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) physaddr_t
|
||||
user_to_phys ( userptr_t buffer, off_t offset ) {
|
||||
return virt_to_phys ( ( void * ) buffer + offset );
|
||||
return ( phys_to_user ( ( segment << 4 ) + offset ) );
|
||||
}
|
||||
|
||||
extern uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size );
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef _PCI_IO_H
|
||||
#define _PCI_IO_H
|
||||
|
||||
#include <pcibios.h>
|
||||
#include <pcidirect.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
* i386 PCI configuration space access
|
||||
*
|
||||
* We have two methods of PCI configuration space access: the PCI BIOS
|
||||
* and direct Type 1 accesses. Selecting between them is via the
|
||||
* compile-time switch -DCONFIG_PCI_DIRECT.
|
||||
*
|
||||
*/
|
||||
|
||||
#if CONFIG_PCI_DIRECT
|
||||
#define pci_max_bus pcidirect_max_bus
|
||||
#define pci_read_config_byte pcidirect_read_config_byte
|
||||
#define pci_read_config_word pcidirect_read_config_word
|
||||
#define pci_read_config_dword pcidirect_read_config_dword
|
||||
#define pci_write_config_byte pcidirect_write_config_byte
|
||||
#define pci_write_config_word pcidirect_write_config_word
|
||||
#define pci_write_config_dword pcidirect_write_config_dword
|
||||
#else /* CONFIG_PCI_DIRECT */
|
||||
#define pci_max_bus pcibios_max_bus
|
||||
#define pci_read_config_byte pcibios_read_config_byte
|
||||
#define pci_read_config_word pcibios_read_config_word
|
||||
#define pci_read_config_dword pcibios_read_config_dword
|
||||
#define pci_write_config_byte pcibios_write_config_byte
|
||||
#define pci_write_config_word pcibios_write_config_word
|
||||
#define pci_write_config_dword pcibios_write_config_dword
|
||||
#endif /* CONFIG_PCI_DIRECT */
|
||||
|
||||
#endif /* _PCI_IO_H */
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Architecture-specific portion of pxe.h for Etherboot
|
||||
*
|
||||
* This file has to define the types SEGOFF16_t, SEGDESC_t and
|
||||
* SEGSEL_t for use in other PXE structures. See pxe.h for details.
|
||||
*/
|
||||
|
||||
#ifndef PXE_ADDR_H
|
||||
#define PXE_ADDR_H
|
||||
|
||||
#define IS_NULL_SEGOFF16(x) ( ( (x).segment == 0 ) && ( (x).offset == 0 ) )
|
||||
#define SEGOFF16_TO_PTR(x) ( VIRTUAL( (x).segment, (x).offset ) )
|
||||
#define PTR_TO_SEGOFF16(ptr,segoff16) \
|
||||
(segoff16).segment = SEGMENT(ptr); \
|
||||
(segoff16).offset = OFFSET(ptr);
|
||||
|
||||
#endif /* PXE_ADDR_H */
|
||||
@@ -30,6 +30,6 @@ extern void pxe_hook_int1a ( void );
|
||||
extern int pxe_unhook_int1a ( void );
|
||||
extern void pxe_init_structures ( void );
|
||||
extern int pxe_start_nbp ( void );
|
||||
extern __cdecl void pxe_api_call ( struct i386_all_regs *ix86 );
|
||||
extern __asmcall void pxe_api_call ( struct i386_all_regs *ix86 );
|
||||
|
||||
#endif /* _PXE_CALL_H */
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "stdint.h"
|
||||
#include "pxe_addr.h" /* Architecture-specific PXE definitions */
|
||||
#include "errno.h" /* PXE status codes */
|
||||
#include <stdint.h>
|
||||
#include <errno.h> /* PXE status codes */
|
||||
|
||||
/** @addtogroup pxe Preboot eXecution Environment (PXE) API
|
||||
* @{
|
||||
@@ -1,45 +1,15 @@
|
||||
#ifndef REALMODE_H
|
||||
#define REALMODE_H
|
||||
|
||||
#ifndef ASSEMBLY
|
||||
|
||||
#include "stdint.h"
|
||||
#include "registers.h"
|
||||
#include "io.h"
|
||||
#include <stdint.h>
|
||||
#include <registers.h>
|
||||
#include <gpxe/uaccess.h>
|
||||
|
||||
/*
|
||||
* Data structures and type definitions
|
||||
*
|
||||
*/
|
||||
|
||||
/* Segment:offset structure. Note that the order within the structure
|
||||
* is offset:segment.
|
||||
*/
|
||||
struct segoff {
|
||||
uint16_t offset;
|
||||
uint16_t segment;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
typedef struct segoff segoff_t;
|
||||
|
||||
/* Macro hackery needed to stringify bits of inline assembly */
|
||||
#define RM_XSTR(x) #x
|
||||
#define RM_STR(x) RM_XSTR(x)
|
||||
|
||||
/* Drag in the selected real-mode transition library header */
|
||||
#ifdef KEEP_IT_REAL
|
||||
#include "libkir.h"
|
||||
#else
|
||||
#include "librm.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The API to some functions is identical between librm and libkir, so
|
||||
* they are documented here, even though the prototypes are in librm.h
|
||||
* and libkir.h.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Declaration of variables in .data16
|
||||
*
|
||||
@@ -92,24 +62,53 @@ typedef struct segoff segoff_t;
|
||||
* assembler output to make sure that it's doing the right thing.
|
||||
*/
|
||||
|
||||
/*
|
||||
* void copy_to_real ( uint16_t dest_seg, uint16_t dest_off,
|
||||
* void *src, size_t n )
|
||||
* void copy_from_real ( void *dest, uint16_t src_seg, uint16_t src_off,
|
||||
* size_t n )
|
||||
/**
|
||||
* Copy data to base memory
|
||||
*
|
||||
* These functions can be used to copy data to and from arbitrary
|
||||
* locations in base memory.
|
||||
* @v dest_seg Destination segment
|
||||
* @v dest_off Destination offset
|
||||
* @v src Source
|
||||
* @v len Length
|
||||
*/
|
||||
static inline __always_inline void
|
||||
copy_to_real ( unsigned int dest_seg, unsigned int dest_off,
|
||||
void *src, size_t n ) {
|
||||
copy_to_user ( real_to_user ( dest_seg, dest_off ), 0, src, n );
|
||||
}
|
||||
|
||||
/*
|
||||
* put_real ( variable, uint16_t dest_seg, uint16_t dest_off )
|
||||
* get_real ( variable, uint16_t src_seg, uint16_t src_off )
|
||||
/**
|
||||
* Copy data to base memory
|
||||
*
|
||||
* These macros can be used to read or write single variables to and
|
||||
* from arbitrary locations in base memory. "variable" must be a
|
||||
* variable of either 1, 2 or 4 bytes in length.
|
||||
* @v dest Destination
|
||||
* @v src_seg Source segment
|
||||
* @v src_off Source offset
|
||||
* @v len Length
|
||||
*/
|
||||
static inline __always_inline void
|
||||
copy_from_real ( void *dest, unsigned int src_seg,
|
||||
unsigned int src_off, size_t n ) {
|
||||
copy_from_user ( dest, real_to_user ( src_seg, src_off ), 0, n );
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a single variable to base memory
|
||||
*
|
||||
* @v var Variable to write
|
||||
* @v dest_seg Destination segment
|
||||
* @v dest_off Destination offset
|
||||
*/
|
||||
#define put_real( var, dest_seg, dest_off ) \
|
||||
copy_to_real ( (dest_seg), (dest_off), &(var), sizeof (var) )
|
||||
|
||||
/**
|
||||
* Read a single variable from base memory
|
||||
*
|
||||
* @v var Variable to read
|
||||
* @v src_seg Source segment
|
||||
* @v src_off Source offset
|
||||
*/
|
||||
#define get_real( var, src_seg, src_off ) \
|
||||
copy_from_real ( &(var), (src_seg), (src_off), sizeof (var) )
|
||||
|
||||
/*
|
||||
* REAL_CODE ( asm_code_str )
|
||||
@@ -123,6 +122,4 @@ typedef struct segoff segoff_t;
|
||||
*
|
||||
*/
|
||||
|
||||
#endif /* ASSEMBLY */
|
||||
|
||||
#endif /* REALMODE_H */
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "compiler.h" /* for doxygen */
|
||||
#include "stdint.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* A 16-bit general register.
|
||||
@@ -184,4 +183,14 @@ struct i386_all_regs {
|
||||
#define SF ( 1 << 7 )
|
||||
#define OF ( 1 << 11 )
|
||||
|
||||
/* Segment:offset structure. Note that the order within the structure
|
||||
* is offset:segment.
|
||||
*/
|
||||
struct segoff {
|
||||
uint16_t offset;
|
||||
uint16_t segment;
|
||||
} PACKED;
|
||||
|
||||
typedef struct segoff segoff_t;
|
||||
|
||||
#endif /* REGISTERS_H */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define JBLEN 6
|
||||
typedef unsigned long jmp_buf[JBLEN];
|
||||
|
||||
extern int __cdecl setjmp (jmp_buf env);
|
||||
extern void __cdecl longjmp (jmp_buf env, int val);
|
||||
extern int __asmcall setjmp (jmp_buf env);
|
||||
extern void __asmcall longjmp (jmp_buf env, int val);
|
||||
|
||||
#endif /* ETHERBOOT_SETJMP_H */
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
#ifndef VIRTADDR_H
|
||||
#define VIRTADDR_H
|
||||
|
||||
/* Segment selectors as used in our protected-mode GDTs.
|
||||
*
|
||||
* Don't change these unless you really know what you're doing.
|
||||
*/
|
||||
|
||||
#define VIRTUAL_CS 0x08
|
||||
#define VIRTUAL_DS 0x10
|
||||
#define PHYSICAL_CS 0x18
|
||||
#define PHYSICAL_DS 0x20
|
||||
#define REAL_CS 0x28
|
||||
#define REAL_DS 0x30
|
||||
#if 0
|
||||
#define LONG_CS 0x38
|
||||
#define LONG_DS 0x40
|
||||
#endif
|
||||
|
||||
#ifndef ASSEMBLY
|
||||
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
|
||||
#ifndef KEEP_IT_REAL
|
||||
|
||||
/*
|
||||
* Without -DKEEP_IT_REAL, we are in 32-bit protected mode with a
|
||||
* fixed link address but an unknown physical start address. Our GDT
|
||||
* sets up code and data segments with an offset of virt_offset, so
|
||||
* that link-time addresses can still work.
|
||||
*
|
||||
*/
|
||||
|
||||
/* C-callable function prototypes */
|
||||
|
||||
extern void relocate_to ( uint32_t new_phys_addr );
|
||||
|
||||
/* Variables in virtaddr.S */
|
||||
extern unsigned long virt_offset;
|
||||
|
||||
/*
|
||||
* Convert between virtual and physical addresses
|
||||
*
|
||||
*/
|
||||
static inline unsigned long virt_to_phys ( volatile const void *virt_addr ) {
|
||||
return ( ( unsigned long ) virt_addr ) + virt_offset;
|
||||
}
|
||||
|
||||
static inline void * phys_to_virt ( unsigned long phys_addr ) {
|
||||
return ( void * ) ( phys_addr - virt_offset );
|
||||
}
|
||||
|
||||
static inline void copy_to_phys ( physaddr_t dest, const void *src,
|
||||
size_t len ) {
|
||||
memcpy ( phys_to_virt ( dest ), src, len );
|
||||
}
|
||||
|
||||
static inline void copy_from_phys ( void *dest, physaddr_t src, size_t len ) {
|
||||
memcpy ( dest, phys_to_virt ( src ), len );
|
||||
}
|
||||
|
||||
static inline void copy_phys_to_phys ( physaddr_t dest, physaddr_t src,
|
||||
size_t len ) {
|
||||
memcpy ( phys_to_virt ( dest ), phys_to_virt ( src ), len );
|
||||
}
|
||||
|
||||
#else /* KEEP_IT_REAL */
|
||||
|
||||
/*
|
||||
* With -DKEEP_IT_REAL, we are in 16-bit real mode with fixed link
|
||||
* addresses and a segmented memory model. We have separate code and
|
||||
* data segments.
|
||||
*
|
||||
* Because we may be called in 16-bit protected mode (damn PXE spec),
|
||||
* we cannot simply assume that physical = segment * 16 + offset.
|
||||
* Instead, we have to look up the physical start address of the
|
||||
* segment in the !PXE structure. We have to assume that
|
||||
* virt_to_phys() is called only on pointers within the data segment,
|
||||
* because nothing passes segment information to us.
|
||||
*
|
||||
* We don't implement phys_to_virt at all, because there will be many
|
||||
* addresses that simply cannot be reached via a virtual address when
|
||||
* the virtual address space is limited to 64kB!
|
||||
*/
|
||||
|
||||
static inline unsigned long virt_to_phys ( volatile const void *virt_addr ) {
|
||||
/* Cheat: just for now, do the segment*16+offset calculation */
|
||||
uint16_t ds;
|
||||
|
||||
__asm__ ( "movw %%ds, %%ax" : "=a" ( ds ) : );
|
||||
return ( 16 * ds + ( ( unsigned long ) virt_addr ) );
|
||||
}
|
||||
|
||||
/* Define it as a deprecated function so that we get compile-time
|
||||
* warnings, rather than just the link-time errors.
|
||||
*/
|
||||
extern void * phys_to_virt ( unsigned long phys_addr )
|
||||
__attribute__ ((deprecated));
|
||||
|
||||
#endif /* KEEP_IT_REAL */
|
||||
|
||||
#endif /* ASSEMBLY */
|
||||
|
||||
#endif /* VIRTADDR_H */
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gpxe/nap.h>
|
||||
#include <gpxe/efi/efi.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
* gPXE CPU sleeping API for EFI
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sleep until next interrupt
|
||||
*
|
||||
*/
|
||||
static void efix86_cpu_nap ( void ) {
|
||||
/*
|
||||
* I can't find any EFI API that allows us to put the CPU to
|
||||
* sleep. The CpuSleep() function is defined in CpuLib.h, but
|
||||
* isn't part of any exposed protocol so we have no way to
|
||||
* call it.
|
||||
*
|
||||
* The EFI shell doesn't seem to bother sleeping the CPU; it
|
||||
* just sits there idly burning power.
|
||||
*
|
||||
*/
|
||||
__asm__ __volatile__ ( "hlt" );
|
||||
}
|
||||
|
||||
PROVIDE_NAP ( efix86, cpu_nap, efix86_cpu_nap );
|
||||
@@ -6,27 +6,11 @@
|
||||
#include <gpxe/ata.h>
|
||||
#include <gpxe/netdevice.h>
|
||||
#include <gpxe/settings.h>
|
||||
#include <gpxe/sanboot.h>
|
||||
#include <gpxe/abft.h>
|
||||
#include <int13.h>
|
||||
#include <usr/aoeboot.h>
|
||||
|
||||
/**
|
||||
* Guess boot network device
|
||||
*
|
||||
* @ret netdev Boot network device
|
||||
*/
|
||||
static struct net_device * guess_boot_netdev ( void ) {
|
||||
struct net_device *boot_netdev;
|
||||
|
||||
/* Just use the first network device */
|
||||
for_each_netdev ( boot_netdev ) {
|
||||
return boot_netdev;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int aoeboot ( const char *root_path ) {
|
||||
static int aoeboot ( const char *root_path ) {
|
||||
struct ata_device ata;
|
||||
struct int13_drive drive;
|
||||
int rc;
|
||||
@@ -37,7 +21,7 @@ int aoeboot ( const char *root_path ) {
|
||||
printf ( "AoE booting from %s\n", root_path );
|
||||
|
||||
/* FIXME: ugly, ugly hack */
|
||||
struct net_device *netdev = guess_boot_netdev();
|
||||
struct net_device *netdev = last_opened_netdev();
|
||||
|
||||
if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
|
||||
printf ( "Could not attach AoE device: %s\n",
|
||||
@@ -71,3 +55,8 @@ int aoeboot ( const char *root_path ) {
|
||||
error_attach:
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct sanboot_protocol aoe_sanboot_protocol __sanboot_protocol = {
|
||||
.prefix = "aoe:",
|
||||
.boot = aoeboot,
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <gpxe/nap.h>
|
||||
#include <realmode.h>
|
||||
|
||||
/**
|
||||
* Save power by halting the CPU until the next interrupt
|
||||
*
|
||||
*/
|
||||
static void bios_cpu_nap ( void ) {
|
||||
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
||||
"hlt\n\t"
|
||||
"cli\n\t" ) : : );
|
||||
}
|
||||
|
||||
PROVIDE_NAP ( pcbios, cpu_nap, bios_cpu_nap );
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/** @file
|
||||
*
|
||||
* BIOS timer
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gpxe/timer.h>
|
||||
#include <realmode.h>
|
||||
#include <bios.h>
|
||||
|
||||
/**
|
||||
* Get current system time in ticks
|
||||
*
|
||||
* @ret ticks Current time, in ticks
|
||||
*
|
||||
* Use direct memory access to BIOS variables, longword 0040:006C
|
||||
* (ticks today) and byte 0040:0070 (midnight crossover flag) instead
|
||||
* of calling timeofday BIOS interrupt.
|
||||
*/
|
||||
static unsigned long bios_currticks ( void ) {
|
||||
static int days = 0;
|
||||
uint32_t ticks;
|
||||
uint8_t midnight;
|
||||
|
||||
/* Re-enable interrupts so that the timer interrupt can occur */
|
||||
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"cli\n\t" ) : : );
|
||||
|
||||
get_real ( ticks, BDA_SEG, 0x006c );
|
||||
get_real ( midnight, BDA_SEG, 0x0070 );
|
||||
|
||||
if ( midnight ) {
|
||||
midnight = 0;
|
||||
put_real ( midnight, BDA_SEG, 0x0070 );
|
||||
days += 0x1800b0;
|
||||
}
|
||||
|
||||
return ( days + ticks );
|
||||
}
|
||||
|
||||
PROVIDE_TIMER_INLINE ( pcbios, udelay );
|
||||
PROVIDE_TIMER ( pcbios, currticks, bios_currticks );
|
||||
PROVIDE_TIMER_INLINE ( pcbios, ticks_per_sec );
|
||||
@@ -7,17 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hooked interrupt count
|
||||
*
|
||||
* At exit, after unhooking all possible interrupts, this counter
|
||||
* should be examined. If it is non-zero, it means that we failed to
|
||||
* unhook at least one interrupt vector, and so must not free up the
|
||||
* memory we are using. (Note that this also implies that we should
|
||||
* re-hook INT 15 in order to hide ourselves from the memory map).
|
||||
*/
|
||||
int hooked_bios_interrupts = 0;
|
||||
|
||||
/**
|
||||
* Hook INT vector
|
||||
*
|
||||
|
||||
@@ -144,7 +144,7 @@ static int int13_rw_sectors ( struct int13_drive *drive,
|
||||
static int int13_read_sectors ( struct int13_drive *drive,
|
||||
struct i386_all_regs *ix86 ) {
|
||||
DBG ( "Read: " );
|
||||
return int13_rw_sectors ( drive, ix86, drive->blockdev->read );
|
||||
return int13_rw_sectors ( drive, ix86, drive->blockdev->op->read );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +163,7 @@ static int int13_read_sectors ( struct int13_drive *drive,
|
||||
static int int13_write_sectors ( struct int13_drive *drive,
|
||||
struct i386_all_regs *ix86 ) {
|
||||
DBG ( "Write: " );
|
||||
return int13_rw_sectors ( drive, ix86, drive->blockdev->write );
|
||||
return int13_rw_sectors ( drive, ix86, drive->blockdev->op->write );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +275,7 @@ static int int13_extended_rw ( struct int13_drive *drive,
|
||||
static int int13_extended_read ( struct int13_drive *drive,
|
||||
struct i386_all_regs *ix86 ) {
|
||||
DBG ( "Extended read: " );
|
||||
return int13_extended_rw ( drive, ix86, drive->blockdev->read );
|
||||
return int13_extended_rw ( drive, ix86, drive->blockdev->op->read );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,7 +288,7 @@ static int int13_extended_read ( struct int13_drive *drive,
|
||||
static int int13_extended_write ( struct int13_drive *drive,
|
||||
struct i386_all_regs *ix86 ) {
|
||||
DBG ( "Extended write: " );
|
||||
return int13_extended_rw ( drive, ix86, drive->blockdev->write );
|
||||
return int13_extended_rw ( drive, ix86, drive->blockdev->op->write );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +322,7 @@ static int int13_get_extended_parameters ( struct int13_drive *drive,
|
||||
* INT 13 handler
|
||||
*
|
||||
*/
|
||||
static __cdecl void int13 ( struct i386_all_regs *ix86 ) {
|
||||
static __asmcall void int13 ( struct i386_all_regs *ix86 ) {
|
||||
int command = ix86->regs.ah;
|
||||
unsigned int bios_drive = ix86->regs.dl;
|
||||
struct int13_drive *drive;
|
||||
@@ -488,8 +488,8 @@ static void guess_int13_geometry ( struct int13_drive *drive ) {
|
||||
/* Scan through partition table and modify guesses for heads
|
||||
* and sectors_per_track if we find any used partitions.
|
||||
*/
|
||||
if ( drive->blockdev->read ( drive->blockdev, 0, 1,
|
||||
virt_to_user ( &mbr ) ) == 0 ) {
|
||||
if ( drive->blockdev->op->read ( drive->blockdev, 0, 1,
|
||||
virt_to_user ( &mbr ) ) == 0 ) {
|
||||
for ( i = 0 ; i < 4 ; i++ ) {
|
||||
partition = &mbr.partitions[i];
|
||||
if ( ! partition->type )
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <gpxe/netdevice.h>
|
||||
#include <gpxe/ibft.h>
|
||||
#include <gpxe/init.h>
|
||||
#include <gpxe/sanboot.h>
|
||||
#include <int13.h>
|
||||
#include <usr/autoboot.h>
|
||||
#include <usr/iscsiboot.h>
|
||||
|
||||
struct setting keep_san_setting __setting = {
|
||||
.name = "keep-san",
|
||||
@@ -20,23 +20,7 @@ struct setting keep_san_setting __setting = {
|
||||
.type = &setting_type_int8,
|
||||
};
|
||||
|
||||
/**
|
||||
* Guess boot network device
|
||||
*
|
||||
* @ret netdev Boot network device
|
||||
*/
|
||||
static struct net_device * guess_boot_netdev ( void ) {
|
||||
struct net_device *boot_netdev;
|
||||
|
||||
/* Just use the first network device */
|
||||
for_each_netdev ( boot_netdev ) {
|
||||
return boot_netdev;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int iscsiboot ( const char *root_path ) {
|
||||
static int iscsiboot ( const char *root_path ) {
|
||||
struct scsi_device *scsi;
|
||||
struct int13_drive *drive;
|
||||
int keep_san;
|
||||
@@ -69,7 +53,7 @@ int iscsiboot ( const char *root_path ) {
|
||||
drive->blockdev = &scsi->blockdev;
|
||||
|
||||
/* FIXME: ugly, ugly hack */
|
||||
struct net_device *netdev = guess_boot_netdev();
|
||||
struct net_device *netdev = last_opened_netdev();
|
||||
struct iscsi_session *iscsi =
|
||||
container_of ( scsi->backend, struct iscsi_session, refcnt );
|
||||
ibft_fill_data ( netdev, iscsi );
|
||||
@@ -100,3 +84,8 @@ int iscsiboot ( const char *root_path ) {
|
||||
err_alloc_scsi:
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct sanboot_protocol iscsi_sanboot_protocol __sanboot_protocol = {
|
||||
.prefix = "iscsi:",
|
||||
.boot = iscsiboot,
|
||||
};
|
||||
@@ -36,9 +36,6 @@
|
||||
/** Equivalent of NOWHERE for user pointers */
|
||||
#define UNOWHERE ( ~UNULL )
|
||||
|
||||
/** Start of Etherboot text, as defined by the linker */
|
||||
extern char _text[];
|
||||
|
||||
/** An external memory block */
|
||||
struct external_memory {
|
||||
/** Size of this memory block (excluding this header) */
|
||||
@@ -135,7 +132,7 @@ static void ecollect_free ( void ) {
|
||||
* Calling realloc() with a new size of zero is a valid way to free a
|
||||
* memory block.
|
||||
*/
|
||||
userptr_t urealloc ( userptr_t ptr, size_t new_size ) {
|
||||
static userptr_t memtop_urealloc ( userptr_t ptr, size_t new_size ) {
|
||||
struct external_memory extmem;
|
||||
userptr_t new = ptr;
|
||||
size_t align;
|
||||
@@ -200,25 +197,4 @@ userptr_t urealloc ( userptr_t ptr, size_t new_size ) {
|
||||
return ( new_size ? new : UNOWHERE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate external memory
|
||||
*
|
||||
* @v size Requested size
|
||||
* @ret ptr Memory, or UNULL
|
||||
*
|
||||
* Memory is guaranteed to be aligned to a page boundary.
|
||||
*/
|
||||
userptr_t umalloc ( size_t size ) {
|
||||
return urealloc ( UNULL, size );
|
||||
}
|
||||
|
||||
/**
|
||||
* Free external memory
|
||||
*
|
||||
* @v ptr Memory allocated by umalloc(), or UNULL
|
||||
*
|
||||
* If @c ptr is UNULL, no action is taken.
|
||||
*/
|
||||
void ufree ( userptr_t ptr ) {
|
||||
urealloc ( ptr, 0 );
|
||||
}
|
||||
PROVIDE_UMALLOC ( memtop, urealloc, memtop_urealloc );
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gpxe/pci.h>
|
||||
#include <pcibios.h>
|
||||
#include <realmode.h>
|
||||
|
||||
/** @file
|
||||
@@ -32,7 +31,7 @@
|
||||
*
|
||||
* @ret max_bus Maximum bus number
|
||||
*/
|
||||
int pcibios_max_bus ( void ) {
|
||||
static int pcibios_max_bus ( void ) {
|
||||
int discard_a, discard_D;
|
||||
uint8_t max_bus;
|
||||
|
||||
@@ -104,3 +103,11 @@ int pcibios_write ( struct pci_device *pci, uint32_t command, uint32_t value ){
|
||||
|
||||
return ( ( status >> 8 ) & 0xff );
|
||||
}
|
||||
|
||||
PROVIDE_PCIAPI ( pcbios, pci_max_bus, pcibios_max_bus );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_byte );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_word );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_dword );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_byte );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_word );
|
||||
PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_dword );
|
||||
@@ -119,7 +119,7 @@ static PXENV_EXIT_t pxenv_unknown ( struct s_PXENV_UNKNOWN *pxenv_unknown ) {
|
||||
* @v es:di Address of PXE parameter block
|
||||
* @ret ax PXE exit code
|
||||
*/
|
||||
__cdecl void pxe_api_call ( struct i386_all_regs *ix86 ) {
|
||||
__asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
|
||||
int opcode = ix86->regs.bx;
|
||||
userptr_t parameters = real_to_user ( ix86->segs.es, ix86->regs.di );
|
||||
size_t param_len;
|
||||
@@ -339,7 +339,7 @@ __cdecl void pxe_api_call ( struct i386_all_regs *ix86 ) {
|
||||
* @v es:di Address of PXE parameter block
|
||||
* @ret ax PXE exit code
|
||||
*/
|
||||
__cdecl void pxe_loader_call ( struct i386_all_regs *ix86 ) {
|
||||
__asmcall void pxe_loader_call ( struct i386_all_regs *ix86 ) {
|
||||
userptr_t uparams = real_to_user ( ix86->segs.es, ix86->regs.di );
|
||||
struct s_UNDI_LOADER params;
|
||||
PXENV_EXIT_t ret;
|
||||
|
||||
@@ -44,10 +44,10 @@ ppxe:
|
||||
.byte SegDescCnt /* SegDescCnt */
|
||||
.word 0 /* FirstSelector */
|
||||
pxe_segments:
|
||||
.word 0, 0, 0, _data16_size /* Stack */
|
||||
.word 0, 0, 0, _data16_size /* UNDIData */
|
||||
.word 0, 0, 0, _text16_size /* UNDICode */
|
||||
.word 0, 0, 0, _text16_size /* UNDICodeWrite */
|
||||
.word 0, 0, 0, _data16_memsz /* Stack */
|
||||
.word 0, 0, 0, _data16_memsz /* UNDIData */
|
||||
.word 0, 0, 0, _text16_memsz /* UNDICode */
|
||||
.word 0, 0, 0, _text16_memsz /* UNDICodeWrite */
|
||||
.word 0, 0, 0, 0 /* BC_Data */
|
||||
.word 0, 0, 0, 0 /* BC_Code */
|
||||
.word 0, 0, 0, 0 /* BC_CodeWrite */
|
||||
@@ -76,15 +76,15 @@ pxenv:
|
||||
.long 0 /* PMEntry */
|
||||
.word 0 /* PMSelector */
|
||||
.word 0 /* StackSeg */
|
||||
.word _data16_size /* StackSize */
|
||||
.word _data16_memsz /* StackSize */
|
||||
.word 0 /* BC_CodeSeg */
|
||||
.word 0 /* BC_CodeSize */
|
||||
.word 0 /* BC_DataSeg */
|
||||
.word 0 /* BC_DataSize */
|
||||
.word 0 /* UNDIDataSeg */
|
||||
.word _data16_size /* UNDIDataSize */
|
||||
.word _data16_memsz /* UNDIDataSize */
|
||||
.word 0 /* UNDICodeSeg */
|
||||
.word _text16_size /* UNDICodeSize */
|
||||
.word _text16_memsz /* UNDICodeSize */
|
||||
.word ppxe, 0 /* PXEPtr */
|
||||
.equ pxenv_length, . - pxenv
|
||||
.size pxenv, . - pxenv
|
||||
|
||||
@@ -485,7 +485,7 @@ PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
|
||||
*tftp_read_file ) {
|
||||
int rc;
|
||||
|
||||
DBG ( "PXENV_TFTP_READ_FILE to %08lx+%lx", tftp_read_file->Buffer,
|
||||
DBG ( "PXENV_TFTP_READ_FILE to %08x+%x", tftp_read_file->Buffer,
|
||||
tftp_read_file->BufferSize );
|
||||
|
||||
/* Open TFTP file */
|
||||
@@ -199,9 +199,10 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
|
||||
struct DataBlk *datablk;
|
||||
struct io_buffer *iobuf;
|
||||
struct net_protocol *net_protocol;
|
||||
struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
|
||||
char destaddr[MAX_LL_ADDR_LEN];
|
||||
const void *ll_dest;
|
||||
size_t ll_hlen = pxe_netdev->ll_protocol->ll_header_len;
|
||||
size_t ll_hlen = ll_protocol->ll_header_len;
|
||||
size_t len;
|
||||
unsigned int i;
|
||||
int rc;
|
||||
@@ -259,17 +260,17 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
|
||||
copy_from_real ( destaddr,
|
||||
undi_transmit->DestAddr.segment,
|
||||
undi_transmit->DestAddr.offset,
|
||||
pxe_netdev->ll_protocol->ll_addr_len );
|
||||
ll_protocol->ll_addr_len );
|
||||
ll_dest = destaddr;
|
||||
} else {
|
||||
DBG ( " BCAST" );
|
||||
ll_dest = pxe_netdev->ll_protocol->ll_broadcast;
|
||||
ll_dest = ll_protocol->ll_broadcast;
|
||||
}
|
||||
|
||||
/* Add link-layer header */
|
||||
if ( ( rc = pxe_netdev->ll_protocol->push ( iobuf, pxe_netdev,
|
||||
net_protocol,
|
||||
ll_dest )) != 0 ){
|
||||
if ( ( rc = ll_protocol->push ( iobuf, ll_dest,
|
||||
pxe_netdev->ll_addr,
|
||||
net_protocol->net_proto ))!=0){
|
||||
free_iob ( iobuf );
|
||||
undi_transmit->Status = PXENV_STATUS ( rc );
|
||||
return PXENV_EXIT_FAILURE;
|
||||
@@ -391,10 +392,10 @@ PXENV_EXIT_t pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
|
||||
*undi_get_statistics ) {
|
||||
DBG ( "PXENV_UNDI_GET_STATISTICS" );
|
||||
|
||||
undi_get_statistics->XmtGoodFrames = pxe_netdev->stats.tx_ok;
|
||||
undi_get_statistics->RcvGoodFrames = pxe_netdev->stats.rx_ok;
|
||||
undi_get_statistics->RcvCRCErrors = pxe_netdev->stats.rx_err;
|
||||
undi_get_statistics->RcvResourceErrors = pxe_netdev->stats.rx_err;
|
||||
undi_get_statistics->XmtGoodFrames = pxe_netdev->tx_stats.good;
|
||||
undi_get_statistics->RcvGoodFrames = pxe_netdev->rx_stats.good;
|
||||
undi_get_statistics->RcvCRCErrors = pxe_netdev->rx_stats.bad;
|
||||
undi_get_statistics->RcvResourceErrors = pxe_netdev->rx_stats.bad;
|
||||
|
||||
undi_get_statistics->Status = PXENV_STATUS_SUCCESS;
|
||||
return PXENV_EXIT_SUCCESS;
|
||||
@@ -408,7 +409,8 @@ PXENV_EXIT_t pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
|
||||
*undi_clear_statistics ) {
|
||||
DBG ( "PXENV_UNDI_CLEAR_STATISTICS" );
|
||||
|
||||
memset ( &pxe_netdev->stats, 0, sizeof ( pxe_netdev->stats ) );
|
||||
memset ( &pxe_netdev->tx_stats, 0, sizeof ( pxe_netdev->tx_stats ) );
|
||||
memset ( &pxe_netdev->rx_stats, 0, sizeof ( pxe_netdev->rx_stats ) );
|
||||
|
||||
undi_clear_statistics->Status = PXENV_STATUS_SUCCESS;
|
||||
return PXENV_EXIT_SUCCESS;
|
||||
@@ -545,6 +547,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
|
||||
struct io_buffer *iobuf;
|
||||
size_t len;
|
||||
struct ll_protocol *ll_protocol;
|
||||
const void *ll_dest;
|
||||
const void *ll_source;
|
||||
uint16_t net_proto;
|
||||
size_t ll_hlen;
|
||||
@@ -625,9 +628,8 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
|
||||
|
||||
/* Strip link-layer header */
|
||||
ll_protocol = pxe_netdev->ll_protocol;
|
||||
if ( ( rc = ll_protocol->pull ( iobuf, pxe_netdev,
|
||||
&net_proto,
|
||||
&ll_source ) ) != 0 ) {
|
||||
if ( ( rc = ll_protocol->pull ( iobuf, &ll_dest, &ll_source,
|
||||
&net_proto ) ) != 0 ) {
|
||||
/* Assume unknown net_proto and no ll_source */
|
||||
net_proto = 0;
|
||||
ll_source = NULL;
|
||||
@@ -41,7 +41,7 @@ uint16_t __bss16 ( com32_saved_sp );
|
||||
/**
|
||||
* Interrupt call helper
|
||||
*/
|
||||
void __cdecl com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physaddr_t outregs_phys ) {
|
||||
void __asmcall com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physaddr_t outregs_phys ) {
|
||||
|
||||
memcpy_user ( virt_to_user( &com32_regs ), 0,
|
||||
phys_to_user ( inregs_phys ), 0,
|
||||
@@ -111,7 +111,7 @@ void __cdecl com32_intcall ( uint8_t interrupt, physaddr_t inregs_phys, physaddr
|
||||
/**
|
||||
* Farcall helper
|
||||
*/
|
||||
void __cdecl com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t outregs_phys ) {
|
||||
void __asmcall com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t outregs_phys ) {
|
||||
|
||||
memcpy_user ( virt_to_user( &com32_regs ), 0,
|
||||
phys_to_user ( inregs_phys ), 0,
|
||||
@@ -170,7 +170,7 @@ void __cdecl com32_farcall ( uint32_t proc, physaddr_t inregs_phys, physaddr_t o
|
||||
/**
|
||||
* CDECL farcall helper
|
||||
*/
|
||||
int __cdecl com32_cfarcall ( uint32_t proc, physaddr_t stack, size_t stacksz ) {
|
||||
int __asmcall com32_cfarcall ( uint32_t proc, physaddr_t stack, size_t stacksz ) {
|
||||
int32_t eax;
|
||||
|
||||
copy_user_to_rm_stack ( phys_to_user ( stack ), stacksz );
|
||||
|
||||
@@ -212,7 +212,7 @@ void comboot_run_kernel ( )
|
||||
/**
|
||||
* Terminate program interrupt handler
|
||||
*/
|
||||
static __cdecl void int20 ( struct i386_all_regs *ix86 __unused ) {
|
||||
static __asmcall void int20 ( struct i386_all_regs *ix86 __unused ) {
|
||||
longjmp ( comboot_return, COMBOOT_RETURN_EXIT );
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ static __cdecl void int20 ( struct i386_all_regs *ix86 __unused ) {
|
||||
/**
|
||||
* DOS-compatible API
|
||||
*/
|
||||
static __cdecl void int21 ( struct i386_all_regs *ix86 ) {
|
||||
static __asmcall void int21 ( struct i386_all_regs *ix86 ) {
|
||||
ix86->flags |= CF;
|
||||
|
||||
switch ( ix86->regs.ah ) {
|
||||
@@ -287,7 +287,7 @@ static __cdecl void int21 ( struct i386_all_regs *ix86 ) {
|
||||
/**
|
||||
* SYSLINUX API
|
||||
*/
|
||||
static __cdecl void int22 ( struct i386_all_regs *ix86 ) {
|
||||
static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
|
||||
ix86->flags |= CF;
|
||||
|
||||
switch ( ix86->regs.ax ) {
|
||||
|
||||
@@ -144,8 +144,8 @@ got_sectors:
|
||||
/* Jump to loaded copy */
|
||||
ljmp $SYSSEG, $start_runtime
|
||||
|
||||
endseg: .word SYSSEG + _load_size_pgh
|
||||
.section ".zinfo.fixup", "a" /* Compressor fixup information */
|
||||
endseg: .word SYSSEG + _filesz_pgh
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBW"
|
||||
.long endseg
|
||||
.long 16
|
||||
@@ -353,6 +353,7 @@ msg1end:
|
||||
.word 0xAA55
|
||||
|
||||
start_runtime:
|
||||
/* Install gPXE */
|
||||
call install
|
||||
|
||||
/* Set up real-mode stack */
|
||||
@@ -368,7 +369,10 @@ start_runtime:
|
||||
pushl $main
|
||||
pushw %cs
|
||||
call prot_call
|
||||
popl %eax /* discard */
|
||||
popl %ecx /* discard */
|
||||
|
||||
/* Uninstall gPXE */
|
||||
call uninstall
|
||||
|
||||
/* Boot next device */
|
||||
int $0x18
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
.text
|
||||
.code32
|
||||
.arch i386
|
||||
.section ".prefix", "a", @progbits
|
||||
.org 0x00
|
||||
|
||||
/* DOS (.com) header
|
||||
*
|
||||
* EFI executables seem to leave most of this empty
|
||||
*/
|
||||
mzhdr:
|
||||
.ascii "MZ" /* Magic number */
|
||||
.word 0 /* Bytes on last page of file */
|
||||
.word 0 /* Pages in file */
|
||||
.word 0 /* Relocations */
|
||||
.word 0 /* Size of header in paragraphs */
|
||||
.word 0 /* Minimum extra paragraphs needed */
|
||||
.word 0 /* Maximum extra paragraphs needed */
|
||||
.word 0 /* Initial (relative) SS value */
|
||||
.word 0 /* Initial SP value */
|
||||
.word 0 /* "Checksum" */
|
||||
.word 0 /* Initial IP value */
|
||||
.word 0 /* Initial (relative) CS value */
|
||||
.word 0 /* File address of relocation table */
|
||||
.word 0 /* Ovesrlay number */
|
||||
.word 0, 0, 0, 0 /* Reserved words */
|
||||
.word 0 /* OEM identifier (for e_oeminfo) */
|
||||
.word 0 /* OEM information; e_oemid specific */
|
||||
.word 0, 0, 0, 0, 0 /* Reserved words */
|
||||
.word 0, 0, 0, 0, 0 /* Reserved words */
|
||||
.long pehdr_lma /* File address of new exe header */
|
||||
.size mzhdr, . - mzhdr
|
||||
|
||||
/* PE header */
|
||||
.org 0xc0 /* For compatibility with MS toolchain */
|
||||
pehdr:
|
||||
.ascii "PE\0\0" /* Magic number */
|
||||
.word 0x014c /* CPU architecture: i386 */
|
||||
.word num_pe_sections /* Number of sections */
|
||||
.long 0x10d1a884 /* Timestamp */
|
||||
.long 0 /* Symbol table */
|
||||
.long 0 /* Number of symbols */
|
||||
.word opthdr_size /* Size of optional header */
|
||||
.word 0x2102 /* Characteristics */
|
||||
.size pehdr, . - pehdr
|
||||
.equ pehdr_lma, pehdr - mzhdr
|
||||
|
||||
/* "Optional" header */
|
||||
opthdr:
|
||||
.word 0x010b /* Magic number */
|
||||
.byte 0 /* Linker major version number */
|
||||
.byte 0 /* Linker minor version number */
|
||||
.long _text_filesz /* Size of text section */
|
||||
.long _data_filesz /* Size of data section */
|
||||
.long _bss_filesz /* Size of bss section */
|
||||
.long efi_entry_lma /* Entry point */
|
||||
.long _text_lma /* Text section start RVA */
|
||||
.long _data_lma /* Data section start RVA */
|
||||
.long 0 /* Image base address */
|
||||
.long _max_align /* Section alignment */
|
||||
.long _max_align /* File alignment */
|
||||
.word 0 /* Operating system major version number */
|
||||
.word 0 /* Operating system minor version number */
|
||||
.word 0 /* Image major version number */
|
||||
.word 0 /* Image minor version number */
|
||||
.word 0 /* Subsystem major version number */
|
||||
.word 0 /* Subsystem minor version number */
|
||||
.long 0 /* Reserved */
|
||||
.long _filesz /* Total image size */
|
||||
.long _prefix_filesz /* Total header size */
|
||||
.long 0 /* "Checksum" */
|
||||
.word 0x0a /* Subsystem: EFI */
|
||||
.word 0 /* DLL characteristics */
|
||||
.long 0 /* Size of stack reserve */
|
||||
.long 0 /* Size of stack commit */
|
||||
.long 0 /* Size of heap reserve */
|
||||
.long 0 /* Size of heap commit */
|
||||
.long 0 /* Loader flags */
|
||||
.long 16 /* Number of data directory entries */
|
||||
.long 0, 0 /* Export directory */
|
||||
.long 0, 0 /* Import directory */
|
||||
.long 0, 0 /* Resource directory */
|
||||
.long 0, 0 /* Exception directory */
|
||||
.long 0, 0 /* Security directory */
|
||||
.long _reloc_lma, _reloc_filesz /* Base relocation directory */
|
||||
.long debugdir_lma, debugdir_size /* Debug directory */
|
||||
.long 0, 0 /* Description directory */
|
||||
.long 0, 0 /* Special directory */
|
||||
.long 0, 0 /* Thread storage directory */
|
||||
.long 0, 0 /* Load configuration directory */
|
||||
.long 0, 0 /* Bound import directory */
|
||||
.long 0, 0 /* Import address table directory */
|
||||
.long 0, 0 /* Delay import directory */
|
||||
.long 0, 0 /* Reserved */
|
||||
.long 0, 0 /* Reserved */
|
||||
.size opthdr, . - opthdr
|
||||
.equ opthdr_size, . - opthdr
|
||||
|
||||
/* PE sections */
|
||||
pe_sections:
|
||||
text_section:
|
||||
.asciz ".text" /* Section name */
|
||||
.align 8
|
||||
.long _text_filesz /* Section size */
|
||||
.long _text_lma /* Relative Virtual Address */
|
||||
.long _text_filesz /* Section size (rounded up) */
|
||||
.long _text_lma /* Pointer to raw data */
|
||||
.long 0 /* Link-time relocations */
|
||||
.long 0 /* Line numbers */
|
||||
.word 0 /* Number of link-time relocations */
|
||||
.word 0 /* Number of line numbers */
|
||||
.long 0x68000020 /* Characteristics */
|
||||
rodata_section:
|
||||
.asciz ".rodata" /* Section name */
|
||||
.align 8
|
||||
.long _rodata_filesz /* Section size */
|
||||
.long _rodata_lma /* Relative Virtual Address */
|
||||
.long _rodata_filesz /* Section size (rounded up) */
|
||||
.long _rodata_lma /* Pointer to raw data */
|
||||
.long 0 /* Link-time relocations */
|
||||
.long 0 /* Line numbers */
|
||||
.word 0 /* Number of link-time relocations */
|
||||
.word 0 /* Number of line numbers */
|
||||
.long 0x48000040 /* Characteristics */
|
||||
data_section:
|
||||
.asciz ".data" /* Section name */
|
||||
.align 8
|
||||
.long _data_filesz /* Section size */
|
||||
.long _data_lma /* Relative Virtual Address */
|
||||
.long _data_filesz /* Section size (rounded up) */
|
||||
.long _data_lma /* Pointer to raw data */
|
||||
.long 0 /* Link-time relocations */
|
||||
.long 0 /* Line numbers */
|
||||
.word 0 /* Number of link-time relocations */
|
||||
.word 0 /* Number of line numbers */
|
||||
.long 0xc8000040 /* Characteristics */
|
||||
reloc_section:
|
||||
.asciz ".reloc" /* Section name */
|
||||
.align 8
|
||||
.long _reloc_filesz /* Section size */
|
||||
.long _reloc_lma /* Relative Virtual Address */
|
||||
.long _reloc_filesz /* Section size (rounded up) */
|
||||
.long _reloc_lma /* Pointer to raw data */
|
||||
.long 0 /* Link-time relocations */
|
||||
.long 0 /* Line numbers */
|
||||
.word 0 /* Number of link-time relocations */
|
||||
.word 0 /* Number of line numbers */
|
||||
.long 0x42000040 /* Characteristics */
|
||||
|
||||
pe_sections_end:
|
||||
.size pe_sections, . - pe_sections
|
||||
.equ num_pe_sections, ( ( . - pe_sections ) / 0x28 )
|
||||
|
||||
/* Debug directory */
|
||||
.section ".rodata"
|
||||
.globl debugdir
|
||||
debugdir:
|
||||
.long 0 /* Characteristics */
|
||||
.long 0x10d1a884 /* Timestamp */
|
||||
.word 0 /* Major version */
|
||||
.word 0 /* Minor version */
|
||||
.long 0x02 /* RSDS? */
|
||||
.long codeview_rsds_size /* Size of data */
|
||||
.long codeview_rsds_lma /* RVA */
|
||||
.long codeview_rsds_lma /* File offset */
|
||||
.size debugdir, . - debugdir
|
||||
.equ debugdir_size, . - debugdir
|
||||
/* Codeview structure */
|
||||
.globl codeview_rsds
|
||||
codeview_rsds:
|
||||
.ascii "RSDS" /* Magic number */
|
||||
.long 0, 0, 0, 0, 0 /* Unused by EFI */
|
||||
.asciz "efiprefix.pdb"
|
||||
.size codeview_rsds, . - codeview_rsds
|
||||
.equ codeview_rsds_size, . - codeview_rsds
|
||||
@@ -63,9 +63,9 @@ max_sector:
|
||||
max_head:
|
||||
.byte 0
|
||||
load_length:
|
||||
.long _load_size_sect
|
||||
.long _filesz_sect
|
||||
|
||||
.section ".zinfo.fixup", "a" /* Compressor fixup information */
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBL"
|
||||
.long load_length
|
||||
.long 512
|
||||
@@ -82,6 +82,7 @@ load_failed:
|
||||
.byte 0x55, 0xaa
|
||||
|
||||
start_image:
|
||||
/* Install gPXE */
|
||||
call install
|
||||
|
||||
/* Set up real-mode stack */
|
||||
@@ -97,7 +98,10 @@ start_image:
|
||||
pushl $main
|
||||
pushw %cs
|
||||
call prot_call
|
||||
popl %eax /* discard */
|
||||
popl %ecx /* discard */
|
||||
|
||||
/* Uninstall gPXE */
|
||||
call uninstall
|
||||
|
||||
/* Boot next device */
|
||||
int $0x18
|
||||
|
||||
@@ -199,6 +199,39 @@ print_pci_busdevfn:
|
||||
ret
|
||||
.size print_pci_busdevfn, . - print_pci_busdevfn
|
||||
|
||||
/*****************************************************************************
|
||||
* Utility function: clear current line
|
||||
*
|
||||
* Parameters:
|
||||
* %ds:di : output buffer (or %di=0 to print to console)
|
||||
* Returns:
|
||||
* %ds:di : next character in output buffer (if applicable)
|
||||
*****************************************************************************
|
||||
*/
|
||||
.section ".prefix.lib"
|
||||
.code16
|
||||
.globl print_kill_line
|
||||
print_kill_line:
|
||||
/* Preserve registers */
|
||||
pushw %ax
|
||||
pushw %cx
|
||||
/* Print CR */
|
||||
movb $'\r', %al
|
||||
call print_character
|
||||
/* Print 79 spaces */
|
||||
movb $' ', %al
|
||||
movw $79, %cx
|
||||
1: call print_character
|
||||
loop 1b
|
||||
/* Print CR */
|
||||
movb $'\r', %al
|
||||
call print_character
|
||||
/* Restore registers and return */
|
||||
popw %cx
|
||||
popw %ax
|
||||
ret
|
||||
.size print_kill_line, . - print_kill_line
|
||||
|
||||
/****************************************************************************
|
||||
* pm_call (real-mode near call)
|
||||
*
|
||||
@@ -308,7 +341,7 @@ pm_call:
|
||||
/* Switch CPU to protected mode and load up segment registers */
|
||||
pushl %eax
|
||||
cli
|
||||
lgdt PM_CALL_VAR(gdt)(%bp)
|
||||
data32 lgdt PM_CALL_VAR(gdt)(%bp)
|
||||
movl %cr0, %eax
|
||||
orb $CR0_PE, %al
|
||||
movl %eax, %cr0
|
||||
@@ -344,7 +377,7 @@ pm_call:
|
||||
popw %es
|
||||
popw %fs
|
||||
popw %gs
|
||||
lgdt PM_CALL_VAR(pm_saved_gdt)(%bp)
|
||||
data32 lgdt PM_CALL_VAR(pm_saved_gdt)(%bp)
|
||||
popfl
|
||||
movw %bp, %sp
|
||||
popw %bp
|
||||
@@ -504,30 +537,88 @@ install_block:
|
||||
.code16
|
||||
.globl alloc_basemem
|
||||
alloc_basemem:
|
||||
/* Preserve registers */
|
||||
pushw %fs
|
||||
|
||||
/* FBMS => %ax as segment address */
|
||||
movw $0x40, %ax
|
||||
movw %ax, %fs
|
||||
pushw $0x40
|
||||
popw %fs
|
||||
movw %fs:0x13, %ax
|
||||
shlw $6, %ax
|
||||
|
||||
/* .data16 segment address */
|
||||
subw $_data16_size_pgh, %ax
|
||||
/* Calculate .data16 segment address */
|
||||
subw $_data16_memsz_pgh, %ax
|
||||
pushw %ax
|
||||
|
||||
/* .text16 segment address */
|
||||
subw $_text16_size_pgh, %ax
|
||||
/* Calculate .text16 segment address */
|
||||
subw $_text16_memsz_pgh, %ax
|
||||
pushw %ax
|
||||
|
||||
/* Update FBMS */
|
||||
shrw $6, %ax
|
||||
movw %ax, %fs:0x13
|
||||
|
||||
/* Return */
|
||||
/* Retrieve .text16 and .data16 segment addresses */
|
||||
popw %ax
|
||||
popw %bx
|
||||
|
||||
/* Restore registers and return */
|
||||
popw %fs
|
||||
ret
|
||||
.size alloc_basemem, . - alloc_basemem
|
||||
|
||||
/****************************************************************************
|
||||
* free_basemem (real-mode near call)
|
||||
*
|
||||
* Free space allocated with alloc_basemem.
|
||||
*
|
||||
* Parameters:
|
||||
* %ax : .text16 segment address
|
||||
* %bx : .data16 segment address
|
||||
* Returns:
|
||||
* %ax : 0 if successfully freed
|
||||
* Corrupts:
|
||||
* none
|
||||
****************************************************************************
|
||||
*/
|
||||
.section ".text16"
|
||||
.code16
|
||||
.globl free_basemem
|
||||
free_basemem:
|
||||
/* Preserve registers */
|
||||
pushw %fs
|
||||
|
||||
/* Check FBMS counter */
|
||||
pushw %ax
|
||||
shrw $6, %ax
|
||||
pushw $0x40
|
||||
popw %fs
|
||||
cmpw %ax, %fs:0x13
|
||||
popw %ax
|
||||
jne 1f
|
||||
|
||||
/* Check hooked interrupt count */
|
||||
cmpw $0, %cs:hooked_bios_interrupts
|
||||
jne 1f
|
||||
|
||||
/* OK to free memory */
|
||||
addw $_text16_memsz_pgh, %ax
|
||||
addw $_data16_memsz_pgh, %ax
|
||||
shrw $6, %ax
|
||||
movw %ax, %fs:0x13
|
||||
xorw %ax, %ax
|
||||
|
||||
1: /* Restore registers and return */
|
||||
popw %fs
|
||||
ret
|
||||
.size free_basemem, . - free_basemem
|
||||
|
||||
.section ".text16.data"
|
||||
.globl hooked_bios_interrupts
|
||||
hooked_bios_interrupts:
|
||||
.word 0
|
||||
.size hooked_bios_interrupts, . - hooked_bios_interrupts
|
||||
|
||||
/****************************************************************************
|
||||
* install (real-mode near call)
|
||||
*
|
||||
@@ -594,19 +685,19 @@ install_prealloc:
|
||||
jnz 1f
|
||||
movw %cs, %si
|
||||
shll $4, %esi
|
||||
1: addl $_payload_offset, %esi
|
||||
1: addl $_payload_lma, %esi
|
||||
|
||||
/* Install .text16 and .data16 */
|
||||
pushl %edi
|
||||
movzwl %ax, %edi
|
||||
shll $4, %edi
|
||||
movl $_text16_size, %ecx
|
||||
movl $_text16_memsz, %ecx
|
||||
movl %ecx, %edx
|
||||
call install_block /* .text16 */
|
||||
movzwl %bx, %edi
|
||||
shll $4, %edi
|
||||
movl $_data16_progbits_size, %ecx
|
||||
movl $_data16_size, %edx
|
||||
movl $_data16_filesz, %ecx
|
||||
movl $_data16_memsz, %edx
|
||||
call install_block /* .data16 */
|
||||
popl %edi
|
||||
|
||||
@@ -622,8 +713,8 @@ install_prealloc:
|
||||
* prior to reading the E820 memory map and relocating
|
||||
* properly.
|
||||
*/
|
||||
movl $_textdata_progbits_size, %ecx
|
||||
movl $_textdata_size, %edx
|
||||
movl $_textdata_filesz, %ecx
|
||||
movl $_textdata_memsz, %edx
|
||||
call install_block
|
||||
|
||||
/* Initialise librm at current location */
|
||||
@@ -676,30 +767,53 @@ prot_call_vector:
|
||||
.size prot_call_vector, . - prot_call_vector
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* uninstall (real-mode near call)
|
||||
*
|
||||
* Uninstall all text and data segments.
|
||||
*
|
||||
* Parameters:
|
||||
* %ax : .text16 segment address
|
||||
* %bx : .data16 segment address
|
||||
* Returns:
|
||||
* none
|
||||
* Corrupts:
|
||||
* none
|
||||
****************************************************************************
|
||||
*/
|
||||
.section ".text16"
|
||||
.code16
|
||||
.globl uninstall
|
||||
uninstall:
|
||||
call free_basemem
|
||||
ret
|
||||
.size uninstall, . - uninstall
|
||||
|
||||
|
||||
|
||||
/* File split information for the compressor */
|
||||
#if COMPRESS
|
||||
.section ".zinfo", "a"
|
||||
.section ".zinfo", "a", @progbits
|
||||
.ascii "COPY"
|
||||
.long _prefix_load_offset
|
||||
.long _prefix_progbits_size
|
||||
.long _prefix_lma
|
||||
.long _prefix_filesz
|
||||
.long _max_align
|
||||
.ascii "PACK"
|
||||
.long _text16_load_offset
|
||||
.long _text16_progbits_size
|
||||
.long _text16_lma
|
||||
.long _text16_filesz
|
||||
.long _max_align
|
||||
.ascii "PACK"
|
||||
.long _data16_load_offset
|
||||
.long _data16_progbits_size
|
||||
.long _data16_lma
|
||||
.long _data16_filesz
|
||||
.long _max_align
|
||||
.ascii "PACK"
|
||||
.long _textdata_load_offset
|
||||
.long _textdata_progbits_size
|
||||
.long _textdata_lma
|
||||
.long _textdata_filesz
|
||||
.long _max_align
|
||||
#else /* COMPRESS */
|
||||
.section ".zinfo", "a"
|
||||
.section ".zinfo", "a", @progbits
|
||||
.ascii "COPY"
|
||||
.long _prefix_load_offset
|
||||
.long _load_size
|
||||
.long _prefix_lma
|
||||
.long _filesz
|
||||
.long _max_align
|
||||
#endif /* COMPRESS */
|
||||
|
||||
@@ -92,9 +92,9 @@ setup_sects:
|
||||
root_flags:
|
||||
.word 0
|
||||
syssize:
|
||||
.long _load_size_pgh - PREFIXPGH
|
||||
.long _filesz_pgh - PREFIXPGH
|
||||
|
||||
.section ".zinfo.fixup", "a" /* Compressor fixup information */
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBL"
|
||||
.long syssize
|
||||
.long 16
|
||||
@@ -189,6 +189,7 @@ run_gpxe:
|
||||
movw %ax, %ss
|
||||
movw $0x7c00, %sp
|
||||
|
||||
/* Install gPXE */
|
||||
call install
|
||||
|
||||
/* Set up real-mode stack */
|
||||
@@ -204,7 +205,10 @@ run_gpxe:
|
||||
pushl $main
|
||||
pushw %cs
|
||||
call prot_call
|
||||
popl %eax /* discard */
|
||||
popl %ecx /* discard */
|
||||
|
||||
/* Uninstall gPXE */
|
||||
call uninstall
|
||||
|
||||
/* Boot next device */
|
||||
int $0x18
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user