Skip to content

Commit

Permalink
Merge remote-tracking branch 'kraxel/roms.1' into staging
Browse files Browse the repository at this point in the history
# By Gerd Hoffmann
# Via Gerd Hoffmann
* kraxel/roms.1:
  roms: add support for building sgabios
  roms: enable parallel seabios / seavgabios builds
  roms: enable ipxe cross builds
  roms: add rules to build slof
  roms: rewrite scripts/refresh-pxe-roms.sh
  roms: parallel ipxe builds
  roms: build lgplvgabios isavga variant
  roms: enable parallel builds for 'make lgplvgabios'
  roms: add 'make clean'

Message-id: 1380532378-22138-1-git-send-email-kraxel@redhat.com
  • Loading branch information
aliguori committed Sep 30, 2013
2 parents eb322b8 + 774e80e commit 349cd52
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 92 deletions.
99 changes: 81 additions & 18 deletions roms/Makefile
@@ -1,6 +1,8 @@

vgabios_variants := stdvga cirrus vmware qxl
vgabios_variants := stdvga cirrus vmware qxl isavga
vgabios_targets := $(subst -isavga,,$(patsubst %,vgabios-%.bin,$(vgabios_variants)))
pxerom_variants := e1000 eepro100 ne2k_pci pcnet rtl8139 virtio
pxerom_targets := 8086100e 80861209 10500940 10222000 10ec8139 1af41000

pxe-rom-e1000 efi-rom-e1000 : VID := 8086
pxe-rom-e1000 efi-rom-e1000 : DID := 100e
Expand All @@ -15,6 +17,22 @@ pxe-rom-rtl8139 efi-rom-rtl8139 : DID := 8139
pxe-rom-virtio efi-rom-virtio : VID := 1af4
pxe-rom-virtio efi-rom-virtio : DID := 1000

#
# cross compiler auto detection
#
path := $(subst :, ,$(PATH))
system := $(shell uname -s | tr "A-Z" "a-z")

# first find cross binutils in path
find-cross-ld = $(firstword $(wildcard $(patsubst %,%/$(1)-*$(system)*-ld,$(path))))
# then check we have cross gcc too
find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld,$(1)))))
# finally strip off path + toolname so we get the prefix
find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1))))

powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64)
x86_64_cross_prefix := $(call find-cross-prefix,x86_64)

#
# EfiRom utility is shipped with edk2 / tianocore, in BaseTools/
#
Expand All @@ -32,46 +50,91 @@ default:
@echo " bios -- update bios.bin (seabios)"
@echo " seavgabios -- update vgabios binaries (seabios)"
@echo " lgplvgabios -- update vgabios binaries (lgpl)"
@echo " sgabios -- update sgabios binaries"
@echo " pxerom -- update nic roms (bios only)"
@echo " efirom -- update nic roms (bios+efi, this needs"
@echo " the EfiRom utility from edk2 / tianocore)"
@echo " slof -- update slof.bin"

bios: config.seabios
sh configure-seabios.sh $<
make -C seabios out/bios.bin
cp seabios/out/bios.bin ../pc-bios/bios.bin
cp seabios/out/*dsdt.aml ../pc-bios/
bios: build-seabios-config-seabios
cp seabios/builds/seabios/bios.bin ../pc-bios/bios.bin
cp seabios/builds/seabios/*dsdt.aml ../pc-bios/

seavgabios: $(patsubst %,seavgabios-%,$(vgabios_variants))

seavgabios-%: config.vga.%
sh configure-seabios.sh $<
make -C seabios out/vgabios.bin
cp seabios/out/vgabios.bin ../pc-bios/vgabios-$*.bin
seavgabios-isavga: build-seabios-config-vga-isavga
cp seabios/builds/vga-isavga/vgabios.bin ../pc-bios/vgabios.bin

seavgabios-%: build-seabios-config-vga-%
cp seabios/builds/vga-$*/vgabios.bin ../pc-bios/vgabios-$*.bin

build-seabios-config-%: config.%
mkdir -p seabios/builds/$*
cp $< seabios/builds/$*/.config
$(MAKE) $(MAKEFLAGS) -C seabios \
KCONFIG_CONFIG=$(CURDIR)/seabios/builds/$*/.config \
OUT=$(CURDIR)/seabios/builds/$*/ oldnoconfig
$(MAKE) $(MAKEFLAGS) -C seabios \
KCONFIG_CONFIG=$(CURDIR)/seabios/builds/$*/.config \
OUT=$(CURDIR)/seabios/builds/$*/ all


lgplvgabios: $(patsubst %,lgplvgabios-%,$(vgabios_variants))

lgplvgabios-%:
make -C vgabios vgabios-$*.bin
lgplvgabios-isavga: build-lgplvgabios
cp vgabios/VGABIOS-lgpl-latest.bin ../pc-bios/vgabios.bin
lgplvgabios-%: build-lgplvgabios
cp vgabios/VGABIOS-lgpl-latest.$*.bin ../pc-bios/vgabios-$*.bin

build-lgplvgabios:
$(MAKE) $(MAKEFLAGS) -C vgabios $(vgabios_targets)


.PHONY: sgabios
sgabios:
$(MAKE) $(MAKEFLAGS) -C sgabios
cp sgabios/sgabios.bin ../pc-bios


pxerom: $(patsubst %,pxe-rom-%,$(pxerom_variants))

pxe-rom-%: ipxe/src/config/local/general.h
make -C ipxe/src bin/$(VID)$(DID).rom
pxe-rom-%: build-pxe-roms
cp ipxe/src/bin/$(VID)$(DID).rom ../pc-bios/pxe-$*.rom

efirom: $(patsubst %,efi-rom-%,$(pxerom_variants))

efi-rom-%: ipxe/src/config/local/general.h
make -C ipxe/src bin/$(VID)$(DID).rom
make -C ipxe/src bin-i386-efi/$(VID)$(DID).efidrv
make -C ipxe/src bin-x86_64-efi/$(VID)$(DID).efidrv
efi-rom-%: build-pxe-roms build-efi-roms
$(EFIROM) -f "0x$(VID)" -i "0x$(DID)" -l 0x02 \
-b ipxe/src/bin/$(VID)$(DID).rom \
-ec ipxe/src/bin-i386-efi/$(VID)$(DID).efidrv \
-ec ipxe/src/bin-x86_64-efi/$(VID)$(DID).efidrv \
-o ../pc-bios/efi-$*.rom

build-pxe-roms: ipxe/src/config/local/general.h
$(MAKE) $(MAKEFLAGS) -C ipxe/src GITVERSION="" \
CROSS_COMPILE=$(x86_64_cross_prefix) \
$(patsubst %,bin/%.rom,$(pxerom_targets))

build-efi-roms: build-pxe-roms ipxe/src/config/local/general.h
$(MAKE) $(MAKEFLAGS) -C ipxe/src GITVERSION="" \
CROSS_COMPILE=$(x86_64_cross_prefix) \
$(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \
$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))

ipxe/src/config/local/%: config.ipxe.%
cp $< $@


slof:
$(MAKE) $(MAKEFLAGS) -C SLOF CROSS=$(powerpc64_cross_prefix) qemu
cp SLOF/boot_rom.bin ../pc-bios/slof.bin


clean:
rm -rf seabios/.config seabios/out seabios/builds
$(MAKE) $(MAKEFLAGS) -C vgabios clean
rm -f vgabios/VGABIOS-lgpl-latest*
$(MAKE) $(MAKEFLAGS) -C sgabios clean
rm -f sgabios/.depend
$(MAKE) $(MAKEFLAGS) -C ipxe/src veryclean
$(MAKE) $(MAKEFLAGS) -C SLOF clean
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
80 changes: 6 additions & 74 deletions scripts/refresh-pxe-roms.sh
Expand Up @@ -21,79 +21,11 @@
# Usage: Run from root of qemu tree
# ./scripts/refresh-pxe-roms.sh

QEMU_DIR=$PWD
ROM_DIR="pc-bios"
BUILD_DIR="roms/ipxe"
LOCAL_CONFIG="src/config/local/general.h"

function cleanup ()
{
if [ -n "$SAVED_CONFIG" ]; then
cp "$SAVED_CONFIG" "$BUILD_DIR"/"$LOCAL_CONFIG"
rm "$SAVED_CONFIG"
fi
cd "$QEMU_DIR"
}

function make_rom ()
{
cd "$BUILD_DIR"/src

BUILD_LOG=$(mktemp)

echo Building "$2"...
make bin/"$1".rom > "$BUILD_LOG" 2>&1
if [ $? -ne 0 ]; then
echo Build failed
tail --lines=100 "$BUILD_LOG"
rm "$BUILD_LOG"
cleanup
exit 1
fi
rm "$BUILD_LOG"

cp bin/"$1".rom "$QEMU_DIR"/"$ROM_DIR"/"$2"

cd "$QEMU_DIR"
}

if [ ! -d "$QEMU_DIR"/"$ROM_DIR" ]; then
echo "error: can't find $ROM_DIR directory," \
"run me from the root of the qemu tree"
exit 1
fi

if [ ! -d "$BUILD_DIR"/src ]; then
echo "error: $BUILD_DIR not populated, try:"
echo " git submodule init $BUILD_DIR"
echo " git submodule update $BUILD_DIR"
exit 1
fi

if [ -e "$BUILD_DIR"/"$LOCAL_CONFIG" ]; then
SAVED_CONFIG=$(mktemp)
cp "$BUILD_DIR"/"$LOCAL_CONFIG" "$SAVED_CONFIG"
fi

echo "#undef BANNER_TIMEOUT" > "$BUILD_DIR"/"$LOCAL_CONFIG"
echo "#define BANNER_TIMEOUT 0" >> "$BUILD_DIR"/"$LOCAL_CONFIG"

IPXE_VERSION=$(cd "$BUILD_DIR" && git describe --tags)
if [ -z "$IPXE_VERSION" ]; then
echo "error: unable to retrieve git version"
cleanup
exit 1
targets="pxerom"
if test -x "$(which EfiRom 2>/dev/null)"; then
targets="$targets efirom"
fi

echo "#undef PRODUCT_NAME" >> "$BUILD_DIR"/"$LOCAL_CONFIG"
echo "#define PRODUCT_NAME \"iPXE $IPXE_VERSION\"" >> "$BUILD_DIR"/"$LOCAL_CONFIG"

make_rom 8086100e pxe-e1000.rom
make_rom 80861209 pxe-eepro100.rom
make_rom 10500940 pxe-ne2k_pci.rom
make_rom 10222000 pxe-pcnet.rom
make_rom 10ec8139 pxe-rtl8139.rom
make_rom 1af41000 pxe-virtio.rom

echo done
cleanup
cd roms
make -j4 $targets || exit 1
make clean

0 comments on commit 349cd52

Please sign in to comment.