Quellcode durchsuchen

[build] Allow ISA ROMs to be built

The build process has for a long time assumed that every ROM is a PCI
ROM, and will always include the PCI header and PCI-related
functionality (such as checking the PCI BIOS version, including the
PCI bus:dev.fn address within the ROM product name string, etc.).

While real ISA cards are no longer in use, some virtualisation
environments (notably VirtualBox) have support only for ISA ROMs.
This can cause problems: in particular, VirtualBox will call our
initialisation entry point with random garbage in %ax, which we then
treat as the PCI bus:dev.fn address of the autoboot device: this
generally prevents the default boot sequence from using any network
devices.

Create .isarom and .pcirom prefixes which can be used to explicitly
specify the type of ROM to be created.  (Note that the .mrom prefix
always implies a PCI ROM, since the .mrom mechanism relies on
reconfiguring PCI BARs.)

Make .rom a magic prefix which will automatically select the
appropriate PCI or ISA ROM prefix for ROMs defined via a PCI_ROM() or
ISA_ROM() macro.  To maintain backwards compatibility, we default to
building a PCI ROM for anything which is not directly derived from a
PCI_ROM() or ISA_ROM() macro (e.g. bin/intel.rom).

Add a selection of targets to "make everything" to ensure that the
(relatively obscure) ISA ROM build process is included within the
per-commit QA checks.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 10 Jahren
Ursprung
Commit
705907f9a9

+ 1
- 0
src/Makefile Datei anzeigen

@@ -147,6 +147,7 @@ all : $(ALL)
147 147
 #
148 148
 everything :
149 149
 	$(Q)$(MAKE) --no-print-directory $(ALL) \
150
+		bin/3c509.rom bin/intel.rom bin/intel.mrom \
150 151
 		bin-i386-efi/ipxe.efi bin-i386-efi/ipxe.efidrv \
151 152
 		bin-i386-efi/ipxe.efirom \
152 153
 		bin-x86_64-efi/ipxe.efi bin-x86_64-efi/ipxe.efidrv \

+ 5
- 2
src/Makefile.housekeeping Datei anzeigen

@@ -902,19 +902,22 @@ CLEANUP		+= $(BIN)/NIC	# Doesn't match the $(BIN)/*.* pattern
902 902
 # derive the variables:
903 903
 # 
904 904
 # TGT_ELEMENTS : the elements of the target (e.g. "dfe538 prism2_pci")
905
-# TGT_PREFIX   : the prefix type (e.g. "rom")
905
+# TGT_PREFIX   : the prefix type (e.g. "pcirom")
906 906
 # TGT_DRIVERS  : the driver for each element (e.g. "rtl8139 prism2_pci")
907 907
 # TGT_ROM_NAME : the ROM name (e.g. "dfe538")
908 908
 #
909 909
 DRIVERS_ipxe	= $(DRIVERS)
910 910
 CARD_DRIVER	= $(firstword $(DRIVER_$(1)) $(1))
911 911
 TGT_ELEMENTS	= $(subst --, ,$(firstword $(subst ., ,$(notdir $@))))
912
-TGT_PREFIX	= $(word 2,$(subst ., ,$(notdir $@)))
913 912
 TGT_ROM_NAME	= $(firstword $(TGT_ELEMENTS))
914 913
 TGT_DRIVERS	= $(strip $(if $(DRIVERS_$(TGT_ROM_NAME)), \
915 914
 			       $(DRIVERS_$(TGT_ROM_NAME)), \
916 915
 			       $(foreach TGT_ELEMENT,$(TGT_ELEMENTS), \
917 916
 			         $(call CARD_DRIVER,$(TGT_ELEMENT))) ))
917
+TGT_PREFIX_NAME	= $(word 2,$(subst ., ,$(notdir $@)))
918
+TGT_PREFIX	= $(strip $(if $(filter rom,$(TGT_PREFIX_NAME)), \
919
+			       $(ROM_TYPE_$(TGT_ROM_NAME))rom, \
920
+			       $(TGT_PREFIX_NAME)))
918 921
 
919 922
 # Look up ROM IDs for the current target
920 923
 # (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the variables:

+ 9
- 1
src/arch/i386/Makefile.pcbios Datei anzeigen

@@ -16,6 +16,8 @@ SRCDIRS		+= arch/i386/drivers/net
16 16
 #
17 17
 MEDIA		+= rom
18 18
 MEDIA		+= mrom
19
+MEDIA		+= pcirom
20
+MEDIA		+= isarom
19 21
 MEDIA		+= pxe
20 22
 MEDIA		+= kpxe
21 23
 MEDIA		+= kkpxe
@@ -31,6 +33,8 @@ MEDIA		+= exe
31 33
 #
32 34
 PAD_rom		= $(PERL) $(PADIMG) --blksize=512 --byte=0xff
33 35
 PAD_mrom	= $(PAD_rom)
36
+PAD_pcirom	= $(PAD_rom)
37
+PAD_isarom	= $(PAD_rom)
34 38
 PAD_dsk		= $(PERL) $(PADIMG) --blksize=512
35 39
 PAD_hd		= $(PERL) $(PADIMG) --blksize=32768
36 40
 PAD_exe		= $(PERL) $(PADIMG) --blksize=512
@@ -39,11 +43,15 @@ PAD_exe		= $(PERL) $(PADIMG) --blksize=512
39 43
 #
40 44
 FINALISE_rom	= $(PERL) $(FIXROM)
41 45
 FINALISE_mrom	= $(FINALISE_rom)
46
+FINALISE_pcirom	= $(FINALISE_rom)
47
+FINALISE_isarom	= $(FINALISE_rom)
42 48
 
43
-# Use $(ROMS) rather than $(DRIVERS) for "allroms" and "allmroms"
49
+# Use $(ROMS) rather than $(DRIVERS) for "allroms", "allmroms", etc.
44 50
 #
45 51
 LIST_NAME_rom := ROMS
46 52
 LIST_NAME_mrom := ROMS
53
+LIST_NAME_pcirom := ROMS
54
+LIST_NAME_isarom := ROMS
47 55
 
48 56
 # rule to make a non-emulation ISO boot image
49 57
 NON_AUTO_MEDIA	+= iso

+ 25
- 0
src/arch/i386/prefix/isaromprefix.S Datei anzeigen

@@ -0,0 +1,25 @@
1
+/*
2
+ * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ *
19
+ */
20
+
21
+FILE_LICENCE ( GPL2_OR_LATER )
22
+
23
+#define BUSTYPE "ISAR"
24
+#define _rom_start _isarom_start
25
+#include "romprefix.S"

+ 24
- 3
src/arch/i386/prefix/libprefix.S Datei anzeigen

@@ -94,6 +94,29 @@ print_character:
94 94
 	ret
95 95
 	.size	print_character, . - print_character
96 96
 
97
+/*****************************************************************************
98
+ * Utility function: print space
99
+ *
100
+ * Parameters:
101
+ *   %ds:di : output buffer (or %di=0 to print to console)
102
+ * Returns:
103
+ *   %ds:di : next character in output buffer (if applicable)
104
+ *****************************************************************************
105
+ */
106
+	.section ".prefix.lib", "awx", @progbits
107
+	.code16
108
+	.globl	print_space
109
+print_space:
110
+	/* Preserve registers */
111
+	pushw	%ax
112
+	/* Print space */
113
+	movb	$( ' ' ), %al
114
+	call	print_character
115
+	/* Restore registers and return */
116
+	popw	%ax
117
+	ret
118
+	.size	print_space, . - print_space
119
+
97 120
 /*****************************************************************************
98 121
  * Utility function: print a NUL-terminated string
99 122
  *
@@ -231,12 +254,10 @@ print_kill_line:
231 254
 	movb	$( '\r' ), %al
232 255
 	call	print_character
233 256
 	/* Print 79 spaces */
234
-	movb	$( ' ' ), %al
235 257
 	movw	$79, %cx
236
-1:	call	print_character
258
+1:	call	print_space
237 259
 	loop	1b
238 260
 	/* Print CR */
239
-	movb	$( '\r' ), %al
240 261
 	call	print_character
241 262
 	/* Restore registers and return */
242 263
 	popw	%cx

+ 2
- 2
src/arch/i386/prefix/mromprefix.S Datei anzeigen

@@ -32,8 +32,8 @@ FILE_LICENCE ( GPL2_OR_LATER )
32 32
 
33 33
 #define ROMPREFIX_EXCLUDE_PAYLOAD 1
34 34
 #define ROMPREFIX_MORE_IMAGES 1
35
-#define _rom_start _mrom_start
36
-#include "romprefix.S"
35
+#define _pcirom_start _mrom_start
36
+#include "pciromprefix.S"
37 37
 
38 38
 	.text
39 39
 	.arch i386

+ 25
- 0
src/arch/i386/prefix/pciromprefix.S Datei anzeigen

@@ -0,0 +1,25 @@
1
+/*
2
+ * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ *
19
+ */
20
+
21
+FILE_LICENCE ( GPL2_OR_LATER )
22
+
23
+#define BUSTYPE "PCIR"
24
+#define _rom_start _pcirom_start
25
+#include "romprefix.S"

+ 55
- 22
src/arch/i386/prefix/romprefix.S Datei anzeigen

@@ -44,6 +44,12 @@ FILE_LICENCE ( GPL2_OR_LATER )
44 44
 #define INDICATOR 0x00
45 45
 #else
46 46
 #define INDICATOR 0x80
47
+#endif
48
+
49
+/* Default to building a PCI ROM if no bus type is specified
50
+ */
51
+#ifndef BUSTYPE
52
+#define BUSTYPE "PCIR"
47 53
 #endif
48 54
 
49 55
 	.text
@@ -64,8 +70,10 @@ checksum:
64 70
 	.word	ipxeheader
65 71
 	.org	0x16
66 72
 	.word	undiheader
73
+.ifeqs	BUSTYPE, "PCIR"
67 74
 	.org	0x18
68 75
 	.word	pciheader
76
+.endif
69 77
 	.org	0x1a
70 78
 	.word	pnpheader
71 79
 	.size romheader, . - romheader
@@ -77,6 +85,7 @@ checksum:
77 85
 	.long	0
78 86
 	.previous
79 87
 
88
+.ifeqs	BUSTYPE, "PCIR"
80 89
 pciheader:
81 90
 	.ascii	"PCIR"			/* Signature */
82 91
 	.word	pci_vendor_id		/* Vendor identification */ 
@@ -107,6 +116,7 @@ pciheader_runtime_length:
107 116
 	.long	512
108 117
 	.long	0
109 118
 	.previous
119
+.endif	/* PCIR */
110 120
 
111 121
 	/* PnP doesn't require any particular alignment, but IBM
112 122
 	 * BIOSes will scan on 16-byte boundaries rather than using
@@ -148,11 +158,14 @@ mfgstr:
148 158
  */
149 159
 prodstr:
150 160
 	.ascii	PRODUCT_SHORT_NAME
161
+.ifeqs	BUSTYPE, "PCIR"
151 162
 prodstr_separator:
152 163
 	.byte	0
153 164
 	.ascii	"(PCI "
154 165
 prodstr_pci_id:
155
-	.asciz	"xx:xx.x)"		/* Filled in by init code */
166
+	.ascii	"xx:xx.x)"		/* Filled in by init code */
167
+.endif	/* PCIR */
168
+	.byte	0
156 169
 	.size prodstr, . - prodstr
157 170
 
158 171
 	.globl	undiheader	
@@ -167,7 +180,7 @@ undiheader:
167 180
 	.word	_data16_memsz		/* Stack segment size */
168 181
 	.word	_data16_memsz		/* Data segment size */
169 182
 	.word	_text16_memsz		/* Code segment size */
170
-	.ascii	"PCIR"			/* Bus type */
183
+	.ascii	BUSTYPE			/* Bus type */
171 184
 	.equ undiheader_len, . - undiheader
172 185
 	.size undiheader, . - undiheader
173 186
 
@@ -208,31 +221,39 @@ init:
208 221
 	pushw	%cs
209 222
 	popw	%ds
210 223
 
211
-	/* Store PCI 3.0 runtime segment address for later use */
212
-	movw	%bx, %gs
213
-
214
-	/* Store PCI bus:dev.fn address */
215
-	movw	%ax, init_pci_busdevfn
216
-
217 224
 	/* Print message as early as possible */
218 225
 	movw	$init_message, %si
219 226
 	xorw	%di, %di
220 227
 	call	print_message
221
-	call	print_pci_busdevfn
222 228
 
223
-	/* Fill in product name string, if possible */
229
+	/* Store PCI 3.0 runtime segment address for later use, if
230
+	 * applicable.
231
+	 */
232
+.ifeqs	BUSTYPE, "PCIR"
233
+	movw	%bx, %gs
234
+.endif
235
+
236
+	/* Store PCI bus:dev.fn address, print PCI bus:dev.fn, and add
237
+	 * PCI bus:dev.fn to product name string, if applicable.
238
+	 */
239
+.ifeqs	BUSTYPE, "PCIR"
240
+	xorw	%di, %di
241
+	call	print_space
242
+	movw	%ax, init_pci_busdevfn
243
+	call	print_pci_busdevfn
224 244
 	movw	$prodstr_pci_id, %di
225 245
 	call	print_pci_busdevfn
226 246
 	movb	$( ' ' ), prodstr_separator
247
+.endif
227 248
 
228 249
 	/* Print segment address */
229
-	movb	$( ' ' ), %al
230 250
 	xorw	%di, %di
231
-	call	print_character
251
+	call	print_space
232 252
 	movw	%cs, %ax
233 253
 	call	print_hex_word
234 254
 
235
-	/* Check for PCI BIOS version */
255
+	/* Check for PCI BIOS version, if applicable */
256
+.ifeqs	BUSTYPE, "PCIR"
236 257
 	pushl	%ebx
237 258
 	pushl	%edx
238 259
 	pushl	%edi
@@ -283,6 +304,7 @@ no_pci3:
283 304
 1:	popl	%edi
284 305
 	popl	%edx
285 306
 	popl	%ebx
307
+.endif	/* PCIR */
286 308
 
287 309
 	/* Check for PnP BIOS.  Although %es:di should point to the
288 310
 	 * PnP BIOS signature on entry, some BIOSes fail to do this.
@@ -396,13 +418,13 @@ no_pmm:
396 418
 	loop	1b
397 419
 	subb	%bl, checksum
398 420
 
399
-	/* Copy self to option ROM space.  Required for PCI3.0, which
400
-	 * loads us to a temporary location in low memory.  Will be a
401
-	 * no-op for lower PCI versions.
421
+	/* Copy self to option ROM space, if applicable.  Required for
422
+	 * PCI3.0, which loads us to a temporary location in low
423
+	 * memory.  Will be a no-op for lower PCI versions.
402 424
 	 */
403
-	movb	$( ' ' ), %al
425
+.ifeqs	BUSTYPE, "PCIR"
404 426
 	xorw	%di, %di
405
-	call	print_character
427
+	call	print_space
406 428
 	movw	%gs, %ax
407 429
 	call	print_hex_word
408 430
 	movzbw	romheader_size, %cx
@@ -411,10 +433,13 @@ no_pmm:
411 433
 	xorw	%si, %si
412 434
 	xorw	%di, %di
413 435
 	cs rep	movsb
436
+.endif
414 437
 
415
-	/* Skip prompt if this is not the first PCI function */
438
+	/* Skip prompt if this is not the first PCI function, if applicable */
439
+.ifeqs	BUSTYPE, "PCIR"
416 440
 	testb	$PCI_FUNC_MASK, init_pci_busdevfn
417 441
 	jnz	no_shell
442
+.endif
418 443
 	/* Prompt for POST-time shell */
419 444
 	movw	$init_message_prompt, %si
420 445
 	xorw	%di, %di
@@ -564,11 +589,13 @@ init_message:
564 589
 	.ascii	"\n"
565 590
 	.ascii	PRODUCT_NAME
566 591
 	.ascii	"\n"
567
-	.asciz	"iPXE (http://ipxe.org) "
592
+	.asciz	"iPXE (http://ipxe.org)"
568 593
 	.size	init_message, . - init_message
594
+.ifeqs	BUSTYPE, "PCIR"
569 595
 init_message_pci:
570 596
 	.asciz	" PCI"
571 597
 	.size	init_message_pci, . - init_message_pci
598
+.endif	/* PCIR */
572 599
 init_message_pnp:
573 600
 	.asciz	" PnP"
574 601
 	.size	init_message_pnp, . - init_message_pnp
@@ -591,9 +618,11 @@ init_message_done:
591 618
 /* PCI bus:dev.fn
592 619
  *
593 620
  */
621
+.ifeqs	BUSTYPE, "PCIR"
594 622
 init_pci_busdevfn:
595 623
 	.word	0
596 624
 	.size	init_pci_busdevfn, . - init_pci_busdevfn
625
+.endif	/* PCIR */
597 626
 
598 627
 /* Image source area
599 628
  *
@@ -732,14 +761,18 @@ exec:	/* Set %ds = %cs */
732 761
 	lret
733 762
 	.section ".text16", "awx", @progbits
734 763
 1:
735
-	/* Retrieve PCI bus:dev.fn */
764
+	/* Retrieve PCI bus:dev.fn, if applicable */
765
+.ifeqs	BUSTYPE, "PCIR"
736 766
 	movw	init_pci_busdevfn, %ax
767
+.endif
737 768
 
738 769
 	/* Set up %ds for access to .data16 */
739 770
 	movw	%bx, %ds
740 771
 
741
-	/* Store PCI bus:dev.fn */
772
+	/* Store PCI bus:dev.fn, if applicable */
773
+.ifeqs	BUSTYPE, "PCIR"
742 774
 	movw	%ax, autoboot_busdevfn
775
+.endif
743 776
 
744 777
 	/* Call main() */
745 778
 	pushl	$main

Laden…
Abbrechen
Speichern