Browse Source

[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 10 years ago
parent
commit
705907f9a9

+ 1
- 0
src/Makefile View File

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

+ 5
- 2
src/Makefile.housekeeping View File

902
 # derive the variables:
902
 # derive the variables:
903
 # 
903
 # 
904
 # TGT_ELEMENTS : the elements of the target (e.g. "dfe538 prism2_pci")
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
 # TGT_DRIVERS  : the driver for each element (e.g. "rtl8139 prism2_pci")
906
 # TGT_DRIVERS  : the driver for each element (e.g. "rtl8139 prism2_pci")
907
 # TGT_ROM_NAME : the ROM name (e.g. "dfe538")
907
 # TGT_ROM_NAME : the ROM name (e.g. "dfe538")
908
 #
908
 #
909
 DRIVERS_ipxe	= $(DRIVERS)
909
 DRIVERS_ipxe	= $(DRIVERS)
910
 CARD_DRIVER	= $(firstword $(DRIVER_$(1)) $(1))
910
 CARD_DRIVER	= $(firstword $(DRIVER_$(1)) $(1))
911
 TGT_ELEMENTS	= $(subst --, ,$(firstword $(subst ., ,$(notdir $@))))
911
 TGT_ELEMENTS	= $(subst --, ,$(firstword $(subst ., ,$(notdir $@))))
912
-TGT_PREFIX	= $(word 2,$(subst ., ,$(notdir $@)))
913
 TGT_ROM_NAME	= $(firstword $(TGT_ELEMENTS))
912
 TGT_ROM_NAME	= $(firstword $(TGT_ELEMENTS))
914
 TGT_DRIVERS	= $(strip $(if $(DRIVERS_$(TGT_ROM_NAME)), \
913
 TGT_DRIVERS	= $(strip $(if $(DRIVERS_$(TGT_ROM_NAME)), \
915
 			       $(DRIVERS_$(TGT_ROM_NAME)), \
914
 			       $(DRIVERS_$(TGT_ROM_NAME)), \
916
 			       $(foreach TGT_ELEMENT,$(TGT_ELEMENTS), \
915
 			       $(foreach TGT_ELEMENT,$(TGT_ELEMENTS), \
917
 			         $(call CARD_DRIVER,$(TGT_ELEMENT))) ))
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
 # Look up ROM IDs for the current target
922
 # Look up ROM IDs for the current target
920
 # (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the variables:
923
 # (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the variables:

+ 9
- 1
src/arch/i386/Makefile.pcbios View File

16
 #
16
 #
17
 MEDIA		+= rom
17
 MEDIA		+= rom
18
 MEDIA		+= mrom
18
 MEDIA		+= mrom
19
+MEDIA		+= pcirom
20
+MEDIA		+= isarom
19
 MEDIA		+= pxe
21
 MEDIA		+= pxe
20
 MEDIA		+= kpxe
22
 MEDIA		+= kpxe
21
 MEDIA		+= kkpxe
23
 MEDIA		+= kkpxe
31
 #
33
 #
32
 PAD_rom		= $(PERL) $(PADIMG) --blksize=512 --byte=0xff
34
 PAD_rom		= $(PERL) $(PADIMG) --blksize=512 --byte=0xff
33
 PAD_mrom	= $(PAD_rom)
35
 PAD_mrom	= $(PAD_rom)
36
+PAD_pcirom	= $(PAD_rom)
37
+PAD_isarom	= $(PAD_rom)
34
 PAD_dsk		= $(PERL) $(PADIMG) --blksize=512
38
 PAD_dsk		= $(PERL) $(PADIMG) --blksize=512
35
 PAD_hd		= $(PERL) $(PADIMG) --blksize=32768
39
 PAD_hd		= $(PERL) $(PADIMG) --blksize=32768
36
 PAD_exe		= $(PERL) $(PADIMG) --blksize=512
40
 PAD_exe		= $(PERL) $(PADIMG) --blksize=512
39
 #
43
 #
40
 FINALISE_rom	= $(PERL) $(FIXROM)
44
 FINALISE_rom	= $(PERL) $(FIXROM)
41
 FINALISE_mrom	= $(FINALISE_rom)
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
 LIST_NAME_rom := ROMS
51
 LIST_NAME_rom := ROMS
46
 LIST_NAME_mrom := ROMS
52
 LIST_NAME_mrom := ROMS
53
+LIST_NAME_pcirom := ROMS
54
+LIST_NAME_isarom := ROMS
47
 
55
 
48
 # rule to make a non-emulation ISO boot image
56
 # rule to make a non-emulation ISO boot image
49
 NON_AUTO_MEDIA	+= iso
57
 NON_AUTO_MEDIA	+= iso

+ 25
- 0
src/arch/i386/prefix/isaromprefix.S View File

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 View File

94
 	ret
94
 	ret
95
 	.size	print_character, . - print_character
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
  * Utility function: print a NUL-terminated string
121
  * Utility function: print a NUL-terminated string
99
  *
122
  *
231
 	movb	$( '\r' ), %al
254
 	movb	$( '\r' ), %al
232
 	call	print_character
255
 	call	print_character
233
 	/* Print 79 spaces */
256
 	/* Print 79 spaces */
234
-	movb	$( ' ' ), %al
235
 	movw	$79, %cx
257
 	movw	$79, %cx
236
-1:	call	print_character
258
+1:	call	print_space
237
 	loop	1b
259
 	loop	1b
238
 	/* Print CR */
260
 	/* Print CR */
239
-	movb	$( '\r' ), %al
240
 	call	print_character
261
 	call	print_character
241
 	/* Restore registers and return */
262
 	/* Restore registers and return */
242
 	popw	%cx
263
 	popw	%cx

+ 2
- 2
src/arch/i386/prefix/mromprefix.S View File

32
 
32
 
33
 #define ROMPREFIX_EXCLUDE_PAYLOAD 1
33
 #define ROMPREFIX_EXCLUDE_PAYLOAD 1
34
 #define ROMPREFIX_MORE_IMAGES 1
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
 	.text
38
 	.text
39
 	.arch i386
39
 	.arch i386

+ 25
- 0
src/arch/i386/prefix/pciromprefix.S View File

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 View File

44
 #define INDICATOR 0x00
44
 #define INDICATOR 0x00
45
 #else
45
 #else
46
 #define INDICATOR 0x80
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
 #endif
53
 #endif
48
 
54
 
49
 	.text
55
 	.text
64
 	.word	ipxeheader
70
 	.word	ipxeheader
65
 	.org	0x16
71
 	.org	0x16
66
 	.word	undiheader
72
 	.word	undiheader
73
+.ifeqs	BUSTYPE, "PCIR"
67
 	.org	0x18
74
 	.org	0x18
68
 	.word	pciheader
75
 	.word	pciheader
76
+.endif
69
 	.org	0x1a
77
 	.org	0x1a
70
 	.word	pnpheader
78
 	.word	pnpheader
71
 	.size romheader, . - romheader
79
 	.size romheader, . - romheader
77
 	.long	0
85
 	.long	0
78
 	.previous
86
 	.previous
79
 
87
 
88
+.ifeqs	BUSTYPE, "PCIR"
80
 pciheader:
89
 pciheader:
81
 	.ascii	"PCIR"			/* Signature */
90
 	.ascii	"PCIR"			/* Signature */
82
 	.word	pci_vendor_id		/* Vendor identification */ 
91
 	.word	pci_vendor_id		/* Vendor identification */ 
107
 	.long	512
116
 	.long	512
108
 	.long	0
117
 	.long	0
109
 	.previous
118
 	.previous
119
+.endif	/* PCIR */
110
 
120
 
111
 	/* PnP doesn't require any particular alignment, but IBM
121
 	/* PnP doesn't require any particular alignment, but IBM
112
 	 * BIOSes will scan on 16-byte boundaries rather than using
122
 	 * BIOSes will scan on 16-byte boundaries rather than using
148
  */
158
  */
149
 prodstr:
159
 prodstr:
150
 	.ascii	PRODUCT_SHORT_NAME
160
 	.ascii	PRODUCT_SHORT_NAME
161
+.ifeqs	BUSTYPE, "PCIR"
151
 prodstr_separator:
162
 prodstr_separator:
152
 	.byte	0
163
 	.byte	0
153
 	.ascii	"(PCI "
164
 	.ascii	"(PCI "
154
 prodstr_pci_id:
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
 	.size prodstr, . - prodstr
169
 	.size prodstr, . - prodstr
157
 
170
 
158
 	.globl	undiheader	
171
 	.globl	undiheader	
167
 	.word	_data16_memsz		/* Stack segment size */
180
 	.word	_data16_memsz		/* Stack segment size */
168
 	.word	_data16_memsz		/* Data segment size */
181
 	.word	_data16_memsz		/* Data segment size */
169
 	.word	_text16_memsz		/* Code segment size */
182
 	.word	_text16_memsz		/* Code segment size */
170
-	.ascii	"PCIR"			/* Bus type */
183
+	.ascii	BUSTYPE			/* Bus type */
171
 	.equ undiheader_len, . - undiheader
184
 	.equ undiheader_len, . - undiheader
172
 	.size undiheader, . - undiheader
185
 	.size undiheader, . - undiheader
173
 
186
 
208
 	pushw	%cs
221
 	pushw	%cs
209
 	popw	%ds
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
 	/* Print message as early as possible */
224
 	/* Print message as early as possible */
218
 	movw	$init_message, %si
225
 	movw	$init_message, %si
219
 	xorw	%di, %di
226
 	xorw	%di, %di
220
 	call	print_message
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
 	movw	$prodstr_pci_id, %di
244
 	movw	$prodstr_pci_id, %di
225
 	call	print_pci_busdevfn
245
 	call	print_pci_busdevfn
226
 	movb	$( ' ' ), prodstr_separator
246
 	movb	$( ' ' ), prodstr_separator
247
+.endif
227
 
248
 
228
 	/* Print segment address */
249
 	/* Print segment address */
229
-	movb	$( ' ' ), %al
230
 	xorw	%di, %di
250
 	xorw	%di, %di
231
-	call	print_character
251
+	call	print_space
232
 	movw	%cs, %ax
252
 	movw	%cs, %ax
233
 	call	print_hex_word
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
 	pushl	%ebx
257
 	pushl	%ebx
237
 	pushl	%edx
258
 	pushl	%edx
238
 	pushl	%edi
259
 	pushl	%edi
283
 1:	popl	%edi
304
 1:	popl	%edi
284
 	popl	%edx
305
 	popl	%edx
285
 	popl	%ebx
306
 	popl	%ebx
307
+.endif	/* PCIR */
286
 
308
 
287
 	/* Check for PnP BIOS.  Although %es:di should point to the
309
 	/* Check for PnP BIOS.  Although %es:di should point to the
288
 	 * PnP BIOS signature on entry, some BIOSes fail to do this.
310
 	 * PnP BIOS signature on entry, some BIOSes fail to do this.
396
 	loop	1b
418
 	loop	1b
397
 	subb	%bl, checksum
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
 	xorw	%di, %di
426
 	xorw	%di, %di
405
-	call	print_character
427
+	call	print_space
406
 	movw	%gs, %ax
428
 	movw	%gs, %ax
407
 	call	print_hex_word
429
 	call	print_hex_word
408
 	movzbw	romheader_size, %cx
430
 	movzbw	romheader_size, %cx
411
 	xorw	%si, %si
433
 	xorw	%si, %si
412
 	xorw	%di, %di
434
 	xorw	%di, %di
413
 	cs rep	movsb
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
 	testb	$PCI_FUNC_MASK, init_pci_busdevfn
440
 	testb	$PCI_FUNC_MASK, init_pci_busdevfn
417
 	jnz	no_shell
441
 	jnz	no_shell
442
+.endif
418
 	/* Prompt for POST-time shell */
443
 	/* Prompt for POST-time shell */
419
 	movw	$init_message_prompt, %si
444
 	movw	$init_message_prompt, %si
420
 	xorw	%di, %di
445
 	xorw	%di, %di
564
 	.ascii	"\n"
589
 	.ascii	"\n"
565
 	.ascii	PRODUCT_NAME
590
 	.ascii	PRODUCT_NAME
566
 	.ascii	"\n"
591
 	.ascii	"\n"
567
-	.asciz	"iPXE (http://ipxe.org) "
592
+	.asciz	"iPXE (http://ipxe.org)"
568
 	.size	init_message, . - init_message
593
 	.size	init_message, . - init_message
594
+.ifeqs	BUSTYPE, "PCIR"
569
 init_message_pci:
595
 init_message_pci:
570
 	.asciz	" PCI"
596
 	.asciz	" PCI"
571
 	.size	init_message_pci, . - init_message_pci
597
 	.size	init_message_pci, . - init_message_pci
598
+.endif	/* PCIR */
572
 init_message_pnp:
599
 init_message_pnp:
573
 	.asciz	" PnP"
600
 	.asciz	" PnP"
574
 	.size	init_message_pnp, . - init_message_pnp
601
 	.size	init_message_pnp, . - init_message_pnp
591
 /* PCI bus:dev.fn
618
 /* PCI bus:dev.fn
592
  *
619
  *
593
  */
620
  */
621
+.ifeqs	BUSTYPE, "PCIR"
594
 init_pci_busdevfn:
622
 init_pci_busdevfn:
595
 	.word	0
623
 	.word	0
596
 	.size	init_pci_busdevfn, . - init_pci_busdevfn
624
 	.size	init_pci_busdevfn, . - init_pci_busdevfn
625
+.endif	/* PCIR */
597
 
626
 
598
 /* Image source area
627
 /* Image source area
599
  *
628
  *
732
 	lret
761
 	lret
733
 	.section ".text16", "awx", @progbits
762
 	.section ".text16", "awx", @progbits
734
 1:
763
 1:
735
-	/* Retrieve PCI bus:dev.fn */
764
+	/* Retrieve PCI bus:dev.fn, if applicable */
765
+.ifeqs	BUSTYPE, "PCIR"
736
 	movw	init_pci_busdevfn, %ax
766
 	movw	init_pci_busdevfn, %ax
767
+.endif
737
 
768
 
738
 	/* Set up %ds for access to .data16 */
769
 	/* Set up %ds for access to .data16 */
739
 	movw	%bx, %ds
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
 	movw	%ax, autoboot_busdevfn
774
 	movw	%ax, autoboot_busdevfn
775
+.endif
743
 
776
 
744
 	/* Call main() */
777
 	/* Call main() */
745
 	pushl	$main
778
 	pushl	$main

Loading…
Cancel
Save