heads/Makefile.nerf

148 lines
3.9 KiB
Makefile
Raw Normal View History

#
# Targets specific for the NERF firmware
#
# this assumes that we've already made the edk2 things, via
# edk2.intermediate or something like that.
EDK2_DIR := $(build)/$(edk2_dir)/BaseTools/BinWrappers/PosixLike
# This should be done in some sort of automated way
# it is currently a little risk prone...
initrd: initrd.intermediate
cat blobs/r630/acpi.cpio initrd.cpio > $(build)/$(linux_dir)/initrd.cpio
GenSec-name = $(EDK2_DIR)/GenSec \
-S EFI_SECTION_USER_INTERFACE \
-o "$1" \
-n $2 \
GenSec-version = $(EDK2_DIR)/GenSec \
-S EFI_SECTION_VERSION \
-o "$1" \
-n $2 \
GenSec-pe = $(EDK2_DIR)/GenSec \
-S EFI_SECTION_PE32 \
-o "$1" \
"$2" \
$(build)/$(linux_dir)/arch/x86/boot/bzImage: linux.intermediate
linux-pe.sec: $(build)/$(linux_dir)/arch/x86/boot/bzImage
$(call GenSec-pe,$@,$<)
linux-name.sec:
$(call GenSec-name,$@,"HeadsNERF")
linux-version.sec:
$(call GenSec-version,$@,"0.1")
# Linux depends on the RuntimeArchProtocolGuid to have been installed,
# so we hand code a PUSH GUID, END dependecy file.
linux-dep.sec:
perl -e 'print chr(hex($$_)) for @ARGV' > $@.tmp \
02 \
e1 b4 df b7 \
2f 05 \
9f 44 \
87 be \
98 18 fc 91 b7 33 \
08 \
$(EDK2_DIR)/GenSec \
-S EFI_SECTION_DXE_DEPEX \
-o $@ \
$@.tmp
-$(RM) $@.tmp
# The RuntimeDxe has no dependencies, so we create an empty
# DEPEX file for it (TRUE, END). GenDepex could be used, but its
# commandline parser makes no sense.
nop-dep.sec:
perl -e 'print chr(hex($$_)) for qw/06 08/' > $@.tmp
$(EDK2_DIR)/GenSec \
-S EFI_SECTION_DXE_DEPEX \
-o $@ \
$@.tmp
-$(RM) $@.tmp
linux.ffs: linux-pe.sec linux-name.sec linux-version.sec nop-dep.sec
$(EDK2_DIR)/GenFfs \
-t EFI_FV_FILETYPE_DRIVER \
-g DECAFBAD-4865-6164-732d-2f2d4e455246 \
--align 64K \
$(addprefix -i ,$^) \
-o $@ \
$(build)/$(edk2_dir)/DxeCore.efi: edk2.intermediate
DxeCore-pe.sec: $(build)/$(edk2_dir)/DxeCore.efi
$(call GenSec-pe,$@,$<)
DxeCore-name.sec:
$(call GenSec-name,$@,"DxeCore")
DxeCore-version.sec:
$(call GenSec-version,$@,"1.0")
DxeCore.ffs: DxeCore-pe.sec DxeCore-name.sec DxeCore-version.sec
$(EDK2_DIR)/GenFfs \
-t EFI_FV_FILETYPE_DXE_CORE \
-g D6A2CB7F-6A18-4E2F-B43B-9920A733700A \
--align 1K \
$(addprefix -i ,$^) \
-o $@ \
$(build)/$(edk2_dir)/RuntimeDxe.efi: edk2.intermediate
RuntimeDxe-pe.sec: $(build)/$(edk2_dir)/RuntimeDxe.efi
$(call GenSec-pe,$@,$<)
RuntimeDxe-name.sec:
$(call GenSec-name,$@,"RuntimeDxe")
RuntimeDxe-version.sec:
$(call GenSec-version,$@,"1.0")
RuntimeDxe.ffs: RuntimeDxe-pe.sec RuntimeDxe-name.sec RuntimeDxe-version.sec nop-dep.sec
$(EDK2_DIR)/GenFfs \
-t EFI_FV_FILETYPE_DRIVER \
-g B601F8C4-43B7-4784-95B1-F4226CB40CEE \
--align 64K \
$(addprefix -i ,$^) \
-o $@ \
# If you have to fit within the normal UEFI image, the volume is
# limited to 0x47 blocks.
#
# But you can also replace the entire region from 0x310000
# up to PEI at 0xE40000, which leaves us almost 11 MB of space.
nerf.vol: DxeCore.ffs RuntimeDxe.ffs linux.ffs
$(EDK2_DIR)/GenFv \
--numberblock 0xB3 \
--blocksize 0x10000 \
--FvNameGuid 4652454e-482f-6165-6473-2f4c696e7578 \
-o $@ \
$(addprefix -f ,$^)
@head -2 $@.txt
-$(RM) $@.txt $@.map
# You must provide your own r630.rom as input
# the ifd is only the first 64k, but we take all the way to the ME region
# dd < r630.rom bs=$[0x10000] skip=$[0x00] count=$[0x02] > blobs/r630/ifd.bin
# dd < r630.rom bs=$[0x10000] skip=$[0x02] count=$[0x2F] > blobs/r630/me.bin
# dd < r630.rom bs=$[0x10000] skip=$[0xe4] count=$[0x1C] > blobs/r630/pei.bin
#
# and unlock the IFD (from coreboot) to allow flashrom to write to the ROM.
# ifdtool -u blobs/r630/ifd.bin && mv blobs/r630/ifd.bin.new blobs/r630/ifd.bin
nerf-r630.rom: \
blobs/r630/ifd.bin \
blobs/r630/me.bin \
nerf.vol \
blobs/r630/pei.bin \
cat $^ > $@
@if [ `stat -c'%s' $@` -ne 16777216 ]; then \
echo -n >&2 "$@ SHOULD BE 16MB. size "; \
stat -c'%s' $@ >&2 ; \
mv $@ $@.bad; \
exit 1; \
fi
nerf.intermediate: nerf-r630.rom