mirror of https://github.com/ipxe/ipxe.git
[build] Allow building PCI ROMs with device ID lists
PCI v3.0 supports a "device list" which allows the ROM to claim support for multiple PCI device IDs (but only a single vendor ID). Add support for building such ROMs by scanning the build target element list and incorporating any device IDs into the ROM's device list header. For example: make bin/8086153a--8086153b.mrom would build a ROM claiming support for both 8086:153a and 8086:153b. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/36/head
parent
fb31365db4
commit
40de412762
|
@ -508,6 +508,22 @@ OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
|
|||
$(BIN)/%.flags :
|
||||
@$(ECHO) $(OBJ_CFLAGS)
|
||||
|
||||
# Device ID tables (using IDs extracted by parserom.pl)
|
||||
#
|
||||
define obj_pci_id_asm
|
||||
.section ".pci_devlist.$(1)", "a", @progbits
|
||||
.globl pci_devlist_$(1)
|
||||
pci_devlist_$(1):
|
||||
.short ( 0x$(1) & 0xffff )
|
||||
|
||||
endef
|
||||
define obj_isa_id_asm
|
||||
endef
|
||||
OBJ_IDS_ASM = $(foreach ROM,$(ROMS_$(OBJECT)),$(call obj_$(ROM_TYPE_$(ROM))_id_asm,$(ROM)))
|
||||
OBJ_IDS_ASM_NL = $(subst $(NEWLINE),\n,$(OBJ_IDS_ASM))
|
||||
$(BIN)/%.ids :
|
||||
@$(ECHO_E) '$(OBJ_IDS_ASM_NL)'
|
||||
|
||||
# ICC requires postprocessing objects to fix up table alignments
|
||||
#
|
||||
ifeq ($(CCTYPE),icc)
|
||||
|
@ -522,6 +538,7 @@ endif
|
|||
#
|
||||
COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
|
||||
RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O)
|
||||
RULE_c_to_ids.o = $(Q)$(ECHO_E) '$(OBJ_IDS_ASM_NL)' | $(ASSEMBLE_S) -o $@
|
||||
RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -DDBGLVL_MAX=$* -c $< -o $@ $(POST_O)
|
||||
RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
|
||||
RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
|
||||
|
@ -532,7 +549,7 @@ RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
|
|||
RULE_S_to_dbg%.o = $(Q)$(PREPROCESS_S) -DDBGLVL_MAX=$* $< | $(ASSEMBLE_S) -o $@
|
||||
RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
|
||||
|
||||
DEBUG_TARGETS += dbg%.o c s
|
||||
GENERIC_TARGETS += ids.o dbg%.o c s
|
||||
|
||||
# List of embedded images included in the last build of embedded.o.
|
||||
# This is needed in order to correctly rebuild embedded.o whenever the
|
||||
|
@ -784,8 +801,8 @@ define rules_template_parts
|
|||
$$(BIN)/$(3).o : $(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)
|
||||
$$(QM)$(ECHO) " [BUILD] $$@"
|
||||
$$(RULE_$(2))
|
||||
BOBJS += $$(BIN)/$(3).o
|
||||
$(foreach TGT,$(DEBUG_TARGETS),$(if $(RULE_$(2)_to_$(TGT)),$(NEWLINE)$(call rules_template_target,$(1),$(2),$(3),$(TGT))))
|
||||
BOBJS += $$(BIN)/$(3).o $(if $(ROMS_$(3)),$$(BIN)/$(3).ids.o)
|
||||
$(foreach TGT,$(GENERIC_TARGETS),$(if $(RULE_$(2)_to_$(TGT)),$(NEWLINE)$(call rules_template_target,$(1),$(2),$(3),$(TGT))))
|
||||
$$(BIN)/deps/$(1).d : $$($(3)_DEPS)
|
||||
TAGS : $$($(3)_DEPS)
|
||||
endef
|
||||
|
@ -930,6 +947,8 @@ TGT_PCI_DEVICE = $(PCI_DEVICE_$(TGT_ROM_NAME))
|
|||
TGT_LD_DRIVERS = $(subst -,_,$(patsubst %,obj_%,$(TGT_DRIVERS)))
|
||||
TGT_LD_IDS = pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
|
||||
pci_device_id=$(firstword $(TGT_PCI_DEVICE) 0)
|
||||
TGT_LD_DEVLIST = $(foreach ELEM,$(TGT_ELEMENTS),$(if $(PCI_VENDOR_$(ELEM)),\
|
||||
pci_devlist_$(patsubst 0x%,%,$(PCI_VENDOR_$(ELEM)))$(patsubst 0x%,%,$(PCI_DEVICE_$(ELEM)))))
|
||||
TGT_LD_ENTRY = _$(TGT_PREFIX)_start
|
||||
|
||||
# Calculate linker flags based on link-time options for the current
|
||||
|
@ -940,7 +959,8 @@ TGT_LD_ENTRY = _$(TGT_PREFIX)_start
|
|||
# "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
|
||||
# --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
|
||||
#
|
||||
TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) obj_config,\
|
||||
TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) \
|
||||
$(TGT_LD_DEVLIST) obj_config,\
|
||||
-u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
|
||||
$(patsubst %,--defsym %,$(TGT_LD_IDS)) \
|
||||
-e $(TGT_LD_ENTRY)
|
||||
|
@ -970,6 +990,7 @@ $(BIN)/%.info :
|
|||
@$(ECHO)
|
||||
@$(ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)'
|
||||
@$(ECHO) 'LD ID symbols : $(TGT_LD_IDS)'
|
||||
@$(ECHO) 'LD devlist symbols : $(TGT_LD_DEVLIST)'
|
||||
@$(ECHO) 'LD entry point : $(TGT_LD_ENTRY)'
|
||||
@$(ECHO)
|
||||
@$(ECHO) 'LD target flags : $(TGT_LD_FLAGS)'
|
||||
|
|
|
@ -91,7 +91,7 @@ pciheader:
|
|||
.ascii "PCIR" /* Signature */
|
||||
.word pci_vendor_id /* Vendor identification */
|
||||
.word pci_device_id /* Device identification */
|
||||
.word 0x0000 /* Device list pointer */
|
||||
.word ( pci_devlist - pciheader ) /* Device list pointer */
|
||||
.word pciheader_len /* PCI data structure length */
|
||||
.byte 0x03 /* PCI data structure revision */
|
||||
.byte 0x02, 0x00, 0x00 /* Class code */
|
||||
|
@ -107,6 +107,17 @@ pciheader_runtime_length:
|
|||
.equ pciheader_len, . - pciheader
|
||||
.size pciheader, . - pciheader
|
||||
|
||||
/* PCI additional device list (filled in by linker) */
|
||||
.section ".pci_devlist.00000000", "a", @progbits
|
||||
pci_devlist:
|
||||
.previous
|
||||
.section ".pci_devlist.ffffffff", "a", @progbits
|
||||
pci_devlist_end:
|
||||
.short 0x0000 /* List terminator */
|
||||
.previous
|
||||
/* Ensure that terminator is always present */
|
||||
.reloc pciheader, RELOC_TYPE_NONE, pci_devlist_end
|
||||
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii ZINFO_TYPE_ADxW
|
||||
.long pciheader_image_length
|
||||
|
|
|
@ -41,6 +41,7 @@ SECTIONS {
|
|||
.prefix 0x0 : AT ( _prefix_lma ) {
|
||||
_prefix = .;
|
||||
*(.prefix)
|
||||
*(SORT(.pci_devlist.*))
|
||||
*(.prefix.*)
|
||||
_mprefix = .;
|
||||
} .bss.prefix (NOLOAD) : AT ( _end_lma ) {
|
||||
|
|
Loading…
Reference in New Issue