# 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 # build/edk2-UDK2017/Build/MdeModule/DEBUG_GCC5/X64/MdeModulePkg/Core/Dxe/DxeMain/OUTPUT # wtf edk2 doesn't hve a way to turn the inf file into an executable? # this build system sucks RuntimeArchProtocolGuid := b7dfb4e1-052f-449f-87be-9818fc91b733 AcpiTableProtocolGuid := FFE06BDD-6107-46A6-7BB2-5A9C7EC5275C SmbiosProtocolGuid := 03583ff6-cb36-4940-947e-b9b39f4afaf7 VariableArchProtocolGuid := 1E5668E2-8481-11D4-BCF1-0080C73C8881 dxe-$(CONFIG_BUNDLE_DXE) += DxeCore DxeCore-filetype := DXE_CORE DxeCore-guid := D6A2CB7F-6A18-4E2F-B43B-9920A733700A #DxeCore-align := 1K dxe-$(CONFIG_BUNDLE_DXE) += RuntimeDxe RuntimeDxe-depex := TRUE RuntimeDxe-guid := B601F8C4-43B7-4784-95B1-F4226CB40CEE dxe-$(CONFIG_BUNDLE_DXE) += AcpiTableDxe AcpiTableDxe-guid := 9622E42C-8E38-4a08-9E8F-54F784652F6B AcpiTableDxe-depex := $(RuntimeArchProtocolGuid) dxe-$(CONFIG_BUNDLE_DXE) += AcpiPlatform AcpiPlatform-guid := cb933912-df8f-4305-b1f9-7b44fa11395c AcpiPlatform-depex := \ $(RuntimeArchProtocolGuid) \ $(AcpiTableProtocolGuid) \ dxe-$(CONFIG_BUNDLE_DXE) += SmbiosDxe SmbiosDxe-guid := F9D88642-0737-49BC-81B5-6889CD57D9EA SmbiosDxe-depex := $(RuntimeArchProtocolGuid) # the VariableStore doesn't work with most vendor firmwares for some reason. # instead we link in the EmuRuntimeDxe, which avoids the dxe-n += VariableRuntimeDxe VariableRuntimeDxe-guid := CBD2E4D5-7068-4FF5-B462-9822B4AD8D60 VariableRuntimeDxe-depex := $(RuntimeArchProtocolGuid) dxe-$(CONFIG_BUNDLE_DXE) += EmuVariableRuntimeDxe EmuVariableRuntimeDxe-guid := CBD2E4D5-7068-4FF5-B462-9822B4AD8D60 EmuVariableRuntimeDxe-depex := $(RuntimeArchProtocolGuid) #dxe-y += Acpi-data Acpi-data-file := /dev/null Acpi-data-guid := 7E374E25-8E01-4FEE-87F2-390C23C606CD Acpi-data-filetype := FREEFORM Acpi-data.ffs: $(sort blobs/$(BOARD)/acpi/*) ./create-ffs \ -o $@ \ -g $(Acpi-data-guid) \ -t FREEFORM \ $^ dxe-y += Linux Linux-file := $(build)/$(linux_dir)/arch/x86/boot/bzImage Linux-version := $(linux-version) Linux-guid := DECAFBAD-6548-6461-732d-2f2d4e455246 Linux-depex := \ $(RuntimeArchProtocolGuid) \ $(AcpiTableProtocolGuid) \ $(SmbiosProtocolGuid) \ $(VariableArchProtocolGuid) \ dxe-y += Initrd Initrd-file := initrd.cpio.xz Initrd-filetype := FREEFORM Initrd-guid := 74696e69-6472-632e-7069-6f2f62696f73 #$(build)/$(linux_dir)/arch/x86/boot/bzImage: linux.intermediate define build-ffs = $1.ffs: $(or $($1-file),$(build)/$(edk2_dir)/Build/MdeModule/DEBUG_GCC5/X64/$1.efi) ./create-ffs \ -o "$1.ffs" \ -g $($1-guid) \ -t $(or $($1-filetype),DRIVER) \ -n "$1" \ -v "$(or $($1-version),0.1)" \ -d "$($1-depex)" \ $$^ # add a dependency on the edk2 module if we are picking up an # edk2 build DXEexecutable. ifndef $($1-file) $(build)/$(edk2_dir)/Build/MdeModule/DEBUG_GCC5/X64/$1.efi: edk2.intermediate endif endef # For everything that we will include in our DXE filesystem, we # have to instatiate targets for the ffs and file sections. # If there is no DEPEX defined, do not create a depex file dependency $(call map,build-ffs,$(dxe-y)) $(build)/$(linux_dir)/arch/x86/boot/bzImage: linux.intermediate # Generate a firmware file with a well known guid # 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. # # x3550m5 -- pei starts at 0xb00000, bios is from 0x1000 == 0xaff nerf.vol: $(addsuffix .ffs,$(dxe-y)) Acpi-data.ffs # blobs/r630/acpi-data.ffs.uncompressed $(EDK2_DIR)/GenFv \ --numberblock $$[$(NERF_SIZE)/0x1000] \ --blocksize 0x1000 \ --FvNameGuid 4652454e-482f-6165-6473-2f4c696e7578 \ -o $@ \ $(addprefix -f ,$^) @head -2 $@.txt -$(RM) $@.txt $@.map # You must provide your own r630.rom as input for the ME and PEI sections. # the ifd is only the first 64k, but we take all the way to the ME region # 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 blobs/$(BOARD)/me.bin: blobs/$(BOARD)/$(BOARD).rom dd < $< bs=$$[0x10000] skip=$$[$(ME_OFFSET)/0x10000] count=$$[$(ME_SIZE)/0x10000] > $@ blobs/$(BOARD)/pei.bin: blobs/$(BOARD)/$(BOARD).rom dd < $< bs=$$[0x10000] skip=$$[$(PEI_OFFSET)/0x10000] count=$$[$(PEI_SIZE)/0x10000] > $@ nerf-$(BOARD).rom: \ blobs/$(BOARD)/ifd.bin \ blobs/$(BOARD)/me.bin \ nerf.vol \ blobs/$(BOARD)/pei.bin \ cat $^ > $@ @if [ `stat -c'%s' $@` -ne $(ROM_SIZE) ]; then \ echo -n >&2 "$@ SHOULD BE 16MB. size "; \ stat -c'%s' $@ >&2 ; \ mv $@ $@.bad; \ exit 1; \ fi # # Generate a compressed section # LZMA guid is EE4E5898-3914-4259-9D6E-DC7BD79403CF # Embedded filesystem is 8C8CE578-8A3D-4F1C-9935-896185C32DD3 # acpi-lz.ffs: blobs/$(BOARD)/acpi-data.ffs $(EDK2_DIR)/GenFfs \ -t EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE \ -g 8C8CE578-8A3D-4F1C-9935-896185C32DD3 \ -o $<.ffs.fv \ -a 16 \ -i $< $(EDK2_DIR)/LzmaCompress \ -e \ -q \ -o $<.fv.lz \ $<.fv $(EDK2_DIR)/GenSec \ -s EFI_SECTION_GUID_DEFINED \ -g EE4E5898-3914-4259-9D6E-DC7BD79403CF \ -r PROCESSING_REQUIRED \ -o $<.fv.lz.sec \ $<.fv.lz $(EDK2_DIR)/GenFfs \ -t EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE \ -g 8C8CE578-8A3D-4F1C-9935-896185C32DD3 \ -i $<.fv.lz.sec \ -o $@ nerf.intermediate: edk2.intermediate nerf-$(BOARD).rom