# Targets specific for the NERF firmware # NERF_FULL_SIZE=0xF00000 # 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 EfiPciRootBridgeIoProtocolGuid := 2F707EBB-4A1A-11D4-9A38-0090273FC14D EfiPciEnumerationCompleteProtocolGuid := 30cfe3e7-3de1-4586-be20-deaba1b3b793 EfiPcdProtocolGuid := 13a3f0f6-264a-3ef0-f2e0-dec512342f34 EfiTimerArchProtocolGuid := 26BACCB3-6F42-11D4-BCE7-0080C73C8881 EfiCpuIo2ProtocolGuid := ad61f191-ae5f-4c0e-b9fa-e869d288c64f EfiIioUdsProtocolGuid := A7CED760-C71C-4E1A-ACB1-89604D5216CB EfiSmmAccess2ProtocolGuid := c2702b74-800c-4131-8746-8fb5b89ce4ac EfiSmmControl2ProtocolGuid := 843dc720-ab1e-42cb-9357-8a0078f3561b IntelRegAccessProtocolGuid := FD480A76-B134-4EF7-ADFE-B0E054639807 EfiMpServiceProtocolGuid := 3fdda605-a76e-4f46-ad29-12f4531b3d08 IntelPlatformTypeGuid := a7ced760-c71c-4e1a-acb1-89604d5216cb IntelPlatformCpuPolicy := ADB7B9E6-70B7-48D4-B6A5-18FA15EBCD78 IntelCrystalRidgeGuid := 626967C7-071B-4D9A-9D0C-F112CF0836E9 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) dxe-$(CONFIG_BUNDLE_DXE) += Legacy8259 Legacy8259-guid := 99998642-0737-49BC-81B5-6889CD57D9EA Legacy8259-file := Legacy8259.efi Legacy8259-depex := $(RuntimeArchProtocolGuid) dxe-$(CONFIG_BUNDLE_DXE) += PciBusDxe PciBusDxe-depex := $(RuntimeArchProtocolGuid) dxe-$(CONFIG_BUNDLE_DXE) += PciHostBridgeDxe PciHostBridgeDxe-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.$(BOARD).ffs: $(sort blobs/$(BOARD)/acpi/*) ./bin/create-ffs \ -o $@ \ --guid "$(Acpi-data-guid)" \ --type 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) \ NO=\ $(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) ./bin/create-ffs \ -o "$1.ffs" \ --guid "$($1-guid)" \ --type $(or $($1-filetype),DRIVER) \ --name "$1" \ --version "$(or $($1-version),0.1)" \ --depex "$($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 # Create a compressed FFS from a volume image %.lz.ffs: %.full.vol ./bin/create-ffs \ --compress \ --type FIRMWARE_VOLUME_IMAGE \ -o "$@" \ "$^" # Generate a firmware file with a well known guid nerf-$(BOARD).full.vol: $(addsuffix .ffs,$(dxe-y)) # Acpi-data.$(BOARD).ffs # blobs/r630/acpi-data.ffs.uncompressed $(EDK2_DIR)/GenFv \ --numberblock $$[$(NERF_FULL_SIZE)/0x1000] \ --blocksize 0x1000 \ --FvNameGuid 4652454e-482f-6165-6473-2f4c696e7578 \ -o $@ \ $(addprefix -f ,$^) @head -2 $@.txt @-$(RM) $@.txt $@.map nerf-$(BOARD).vol: nerf-$(BOARD).lz.ffs $(EDK2_DIR)/GenFv \ --numberblock $$[$(NERF_SIZE)/0x1000] \ --blocksize 0x1000 \ --FvNameGuid 01234567-89ab-cdef-5a5a-5a5a5a5a5a5a \ -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 vendor-files-y := $(shell awk \ '/^[0-9A-Fa-f]/ {print "blobs/$(BOARD)/files/file-"$$1"/file.obj"}' \ blobs/$(BOARD)/vendor-files.txt \ ) vendor-$(BOARD).full.vol: \ EmuVariableRuntimeDxe.ffs \ $(vendor-files-y) \ Linux.ffs \ Initrd.ffs \ $(EDK2_DIR)/GenFv \ --numberblock $$[$(NERF_FULL_SIZE)/0x1000] \ --blocksize 0x1000 \ --FvNameGuid 4652454e-482f-6165-6473-2f4c696e7578 \ -o $@ \ $(addprefix -f ,$^) @head -2 $@.txt @-$(RM) $@.txt $@.map vendor-$(BOARD).vol: vendor-$(BOARD).lz.ffs $(EDK2_DIR)/GenFv \ --numberblock $$[$(NERF_SIZE)/0x1000] \ --blocksize 0x1000 \ --FvNameGuid decafbad-89ab-cdef-5a5a-5a5a5a5a5a5a \ -o $@ \ $(addprefix -f ,$^) @head -2 $@.txt @-$(RM) $@.txt $@.map nerf.intermediate: edk2.intermediate nerf-$(BOARD).rom