Browse Source

[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>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
40de412762
3 changed files with 38 additions and 5 deletions
  1. 25
    4
      src/Makefile.housekeeping
  2. 12
    1
      src/arch/i386/prefix/romprefix.S
  3. 1
    0
      src/arch/i386/scripts/i386.lds

+ 25
- 4
src/Makefile.housekeeping View File

@@ -508,6 +508,22 @@ OBJ_CFLAGS	= $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
508 508
 $(BIN)/%.flags :
509 509
 	@$(ECHO) $(OBJ_CFLAGS)
510 510
 
511
+# Device ID tables (using IDs extracted by parserom.pl)
512
+#
513
+define obj_pci_id_asm
514
+	.section ".pci_devlist.$(1)", "a", @progbits
515
+	.globl pci_devlist_$(1)
516
+pci_devlist_$(1):
517
+	.short ( 0x$(1) & 0xffff )
518
+
519
+endef
520
+define obj_isa_id_asm
521
+endef
522
+OBJ_IDS_ASM	= $(foreach ROM,$(ROMS_$(OBJECT)),$(call obj_$(ROM_TYPE_$(ROM))_id_asm,$(ROM)))
523
+OBJ_IDS_ASM_NL	= $(subst $(NEWLINE),\n,$(OBJ_IDS_ASM))
524
+$(BIN)/%.ids :
525
+	@$(ECHO_E) '$(OBJ_IDS_ASM_NL)'
526
+
511 527
 # ICC requires postprocessing objects to fix up table alignments
512 528
 #
513 529
 ifeq ($(CCTYPE),icc)
@@ -522,6 +538,7 @@ endif
522 538
 #
523 539
 COMPILE_c	= $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
524 540
 RULE_c		= $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O)
541
+RULE_c_to_ids.o = $(Q)$(ECHO_E) '$(OBJ_IDS_ASM_NL)' | $(ASSEMBLE_S) -o $@
525 542
 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -DDBGLVL_MAX=$* -c $< -o $@ $(POST_O)
526 543
 RULE_c_to_c	= $(Q)$(COMPILE_c) -E -c $< > $@
527 544
 RULE_c_to_s	= $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
@@ -532,7 +549,7 @@ RULE_S		= $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
532 549
 RULE_S_to_dbg%.o = $(Q)$(PREPROCESS_S) -DDBGLVL_MAX=$* $< | $(ASSEMBLE_S) -o $@
533 550
 RULE_S_to_s	= $(Q)$(PREPROCESS_S) $< > $@
534 551
 
535
-DEBUG_TARGETS	+= dbg%.o c s
552
+GENERIC_TARGETS	+= ids.o dbg%.o c s
536 553
 
537 554
 # List of embedded images included in the last build of embedded.o.
538 555
 # This is needed in order to correctly rebuild embedded.o whenever the
@@ -784,8 +801,8 @@ define rules_template_parts
784 801
 $$(BIN)/$(3).o : $(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)
785 802
 	$$(QM)$(ECHO) "  [BUILD] $$@"
786 803
 	$$(RULE_$(2))
787
-BOBJS += $$(BIN)/$(3).o
788
-$(foreach TGT,$(DEBUG_TARGETS),$(if $(RULE_$(2)_to_$(TGT)),$(NEWLINE)$(call rules_template_target,$(1),$(2),$(3),$(TGT))))
804
+BOBJS += $$(BIN)/$(3).o $(if $(ROMS_$(3)),$$(BIN)/$(3).ids.o)
805
+$(foreach TGT,$(GENERIC_TARGETS),$(if $(RULE_$(2)_to_$(TGT)),$(NEWLINE)$(call rules_template_target,$(1),$(2),$(3),$(TGT))))
789 806
 $$(BIN)/deps/$(1).d : $$($(3)_DEPS)
790 807
 TAGS : $$($(3)_DEPS)
791 808
 endef
@@ -930,6 +947,8 @@ TGT_PCI_DEVICE	= $(PCI_DEVICE_$(TGT_ROM_NAME))
930 947
 TGT_LD_DRIVERS	= $(subst -,_,$(patsubst %,obj_%,$(TGT_DRIVERS)))
931 948
 TGT_LD_IDS	= pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
932 949
 		  pci_device_id=$(firstword $(TGT_PCI_DEVICE) 0)
950
+TGT_LD_DEVLIST	= $(foreach ELEM,$(TGT_ELEMENTS),$(if $(PCI_VENDOR_$(ELEM)),\
951
+		    pci_devlist_$(patsubst 0x%,%,$(PCI_VENDOR_$(ELEM)))$(patsubst 0x%,%,$(PCI_DEVICE_$(ELEM)))))
933 952
 TGT_LD_ENTRY	= _$(TGT_PREFIX)_start
934 953
 
935 954
 # Calculate linker flags based on link-time options for the current
@@ -940,7 +959,8 @@ TGT_LD_ENTRY	= _$(TGT_PREFIX)_start
940 959
 #		 "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
941 960
 #		  --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
942 961
 #
943
-TGT_LD_FLAGS	= $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) obj_config,\
962
+TGT_LD_FLAGS	= $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) \
963
+		    $(TGT_LD_DEVLIST) obj_config,\
944 964
 		    -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
945 965
 		  $(patsubst %,--defsym %,$(TGT_LD_IDS)) \
946 966
 		  -e $(TGT_LD_ENTRY)
@@ -970,6 +990,7 @@ $(BIN)/%.info :
970 990
 	@$(ECHO)
971 991
 	@$(ECHO) 'LD driver symbols    : $(TGT_LD_DRIVERS)'
972 992
 	@$(ECHO) 'LD ID symbols        : $(TGT_LD_IDS)'
993
+	@$(ECHO) 'LD devlist symbols   : $(TGT_LD_DEVLIST)'
973 994
 	@$(ECHO) 'LD entry point       : $(TGT_LD_ENTRY)'
974 995
 	@$(ECHO)
975 996
 	@$(ECHO) 'LD target flags      : $(TGT_LD_FLAGS)'

+ 12
- 1
src/arch/i386/prefix/romprefix.S View File

@@ -91,7 +91,7 @@ pciheader:
91 91
 	.ascii	"PCIR"			/* Signature */
92 92
 	.word	pci_vendor_id		/* Vendor identification */ 
93 93
 	.word	pci_device_id		/* Device identification */
94
-	.word	0x0000			/* Device list pointer */
94
+	.word	( pci_devlist - pciheader ) /* Device list pointer */
95 95
 	.word	pciheader_len		/* PCI data structure length */
96 96
 	.byte	0x03			/* PCI data structure revision */
97 97
 	.byte	0x02, 0x00, 0x00	/* Class code */
@@ -107,6 +107,17 @@ pciheader_runtime_length:
107 107
 	.equ pciheader_len, . - pciheader
108 108
 	.size pciheader, . - pciheader
109 109
 
110
+	/* PCI additional device list (filled in by linker) */
111
+	.section ".pci_devlist.00000000", "a", @progbits
112
+pci_devlist:
113
+	.previous
114
+	.section ".pci_devlist.ffffffff", "a", @progbits
115
+pci_devlist_end:
116
+	.short	0x0000 /* List terminator */
117
+	.previous
118
+	/* Ensure that terminator is always present */
119
+	.reloc pciheader, RELOC_TYPE_NONE, pci_devlist_end
120
+
110 121
 	.section ".zinfo.fixup", "a", @progbits	/* Compressor fixups */
111 122
 	.ascii	ZINFO_TYPE_ADxW
112 123
 	.long	pciheader_image_length

+ 1
- 0
src/arch/i386/scripts/i386.lds View File

@@ -41,6 +41,7 @@ SECTIONS {
41 41
     .prefix 0x0 : AT ( _prefix_lma ) {
42 42
 	_prefix = .;
43 43
 	*(.prefix)
44
+	*(SORT(.pci_devlist.*))
44 45
 	*(.prefix.*)
45 46
 	_mprefix = .;
46 47
     } .bss.prefix (NOLOAD) : AT ( _end_lma ) {

Loading…
Cancel
Save