Browse Source

[config] Make PXE stack a compile-time option

For extremely tight space requirements and specific applications, it is
sometimes desirable to create gPXE images that cannot provide the PXE API
functionality to client programs. Add a configuration header option,
PXE_STACK, that can be removed to remove this stack. Also add PXE_MENU
to control the PXE boot menu, which most uses of gPXE do not need.

Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.0.0-rc1
Joshua Oreman 15 years ago
parent
commit
fa4aec8f03

+ 19
- 0
src/arch/i386/include/pxe_call.h View File

@@ -34,5 +34,24 @@ extern void pxe_activate ( struct net_device *netdev );
34 34
 extern int pxe_deactivate ( void );
35 35
 extern int pxe_start_nbp ( void );
36 36
 extern __asmcall void pxe_api_call ( struct i386_all_regs *ix86 );
37
+extern int _pxe_api_call_weak ( struct i386_all_regs *ix86 )
38
+	__attribute__ (( weak ));
39
+
40
+/**
41
+ * Dispatch PXE API call weakly
42
+ *
43
+ * @v ix86		Registers for PXE call
44
+ * @ret present		Zero if the PXE stack is present, nonzero if not
45
+ *
46
+ * A successful return only indicates that the PXE stack was available
47
+ * for dispatching the call; it says nothing about the success of
48
+ * whatever the call asked for.
49
+ */
50
+static inline int pxe_api_call_weak ( struct i386_all_regs *ix86 )
51
+{
52
+	if ( _pxe_api_call_weak != NULL )
53
+		return _pxe_api_call_weak ( ix86 );
54
+	return -1;
55
+}
37 56
 
38 57
 #endif /* _PXE_CALL_H */

+ 12
- 0
src/arch/i386/interface/pxe/pxe_call.c View File

@@ -339,6 +339,18 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
339 339
 	ix86->regs.ax = ret;
340 340
 }
341 341
 
342
+/**
343
+ * Dispatch weak PXE API call with PXE stack available
344
+ *
345
+ * @v ix86		Registers for PXE call
346
+ * @ret present		Zero (PXE stack present)
347
+ */
348
+int _pxe_api_call_weak ( struct i386_all_regs *ix86 )
349
+{
350
+	pxe_api_call ( ix86 );
351
+	return 0;
352
+}
353
+
342 354
 /**
343 355
  * Dispatch PXE loader call
344 356
  *

+ 4
- 2
src/arch/i386/interface/syslinux/comboot_call.c View File

@@ -445,8 +445,10 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
445 445
 		break;
446 446
 
447 447
 	case 0x0009: /* Call PXE Stack */
448
-		pxe_api_call ( ix86 );
449
-		ix86->flags &= ~CF;
448
+		if ( pxe_api_call_weak ( ix86 ) != 0 )
449
+			ix86->flags |= CF;
450
+		else
451
+			ix86->flags &= ~CF;
450 452
 		break;
451 453
 
452 454
 	case 0x000A: /* Get Derivative-Specific Information */

+ 3
- 44
src/arch/i386/prefix/romprefix.S View File

@@ -126,6 +126,7 @@ prodstr_pci_id:
126 126
 	.size prodstr, . - prodstr
127 127
 
128 128
 	.globl	undiheader	
129
+	.weak	undiloader
129 130
 undiheader:
130 131
 	.ascii	"UNDI"			/* Signature */
131 132
 	.byte	undiheader_len		/* Length of structure */
@@ -495,6 +496,7 @@ init_message_done:
495 496
  *
496 497
  * May be either within option ROM space, or within PMM-allocated block.
497 498
  */
499
+	.globl	image_source
498 500
 image_source:
499 501
 	.long	0
500 502
 	.size	image_source, . - image_source
@@ -503,6 +505,7 @@ image_source:
503 505
  *
504 506
  * May be either at HIGHMEM_LOADPOINT, or within PMM-allocated block.
505 507
  */
508
+	.globl	decompress_to
506 509
 decompress_to:
507 510
 	.long	HIGHMEM_LOADPOINT
508 511
 	.size	decompress_to, . - decompress_to
@@ -644,50 +647,6 @@ exec_message:
644 647
 	.asciz	" starting execution\n"
645 648
 	.size exec_message, . - exec_message
646 649
 
647
-/* UNDI loader
648
- *
649
- * Called by an external program to load our PXE stack.
650
- */
651
-undiloader:
652
-	/* Save registers */
653
-	pushl	%esi
654
-	pushl	%edi
655
-	pushw	%ds
656
-	pushw	%es
657
-	pushw	%bx
658
-	/* ROM segment address to %ds */
659
-	pushw	%cs
660
-	popw	%ds
661
-	/* UNDI loader parameter structure address into %es:%di */
662
-	movw	%sp, %bx
663
-	movw	%ss:18(%bx), %di
664
-	movw	%ss:20(%bx), %es
665
-	/* Install to specified real-mode addresses */
666
-	pushw	%di
667
-	movw	%es:12(%di), %bx
668
-	movw	%es:14(%di), %ax
669
-	movl	image_source, %esi
670
-	movl	decompress_to, %edi
671
-	call	install_prealloc
672
-	popw	%di
673
-	/* Call UNDI loader C code */
674
-	pushl	$pxe_loader_call
675
-	pushw	%cs
676
-	pushw	$1f
677
-	pushw	%ax
678
-	pushw	$prot_call
679
-	lret
680
-1:	popw	%bx	/* discard */
681
-	popw	%bx	/* discard */
682
-	/* Restore registers and return */
683
-	popw	%bx
684
-	popw	%es
685
-	popw	%ds
686
-	popl	%edi
687
-	popl	%esi
688
-	lret
689
-	.size undiloader, . - undiloader
690
-
691 650
 /* Wait for key press specified by %bl (masked by %bh)
692 651
  *
693 652
  * Used by init and INT19 code when prompting user.  If the specified

+ 49
- 0
src/arch/i386/prefix/undiloader.S View File

@@ -0,0 +1,49 @@
1
+	.text
2
+	.code16
3
+	.arch i386
4
+	.section ".prefix", "ax", @progbits
5
+
6
+/* UNDI loader
7
+ *
8
+ * Called by an external program to load our PXE stack.
9
+ */
10
+	.globl	undiloader
11
+undiloader:
12
+	/* Save registers */
13
+	pushl	%esi
14
+	pushl	%edi
15
+	pushw	%ds
16
+	pushw	%es
17
+	pushw	%bx
18
+	/* ROM segment address to %ds */
19
+	pushw	%cs
20
+	popw	%ds
21
+	/* UNDI loader parameter structure address into %es:%di */
22
+	movw	%sp, %bx
23
+	movw	%ss:18(%bx), %di
24
+	movw	%ss:20(%bx), %es
25
+	/* Install to specified real-mode addresses */
26
+	pushw	%di
27
+	movw	%es:12(%di), %bx
28
+	movw	%es:14(%di), %ax
29
+	movl	image_source, %esi
30
+	movl	decompress_to, %edi
31
+	call	install_prealloc
32
+	popw	%di
33
+	/* Call UNDI loader C code */
34
+	pushl	$pxe_loader_call
35
+	pushw	%cs
36
+	pushw	$1f
37
+	pushw	%ax
38
+	pushw	$prot_call
39
+	lret
40
+1:	popw	%bx	/* discard */
41
+	popw	%bx	/* discard */
42
+	/* Restore registers and return */
43
+	popw	%bx
44
+	popw	%es
45
+	popw	%ds
46
+	popl	%edi
47
+	popl	%esi
48
+	lret
49
+	.size undiloader, . - undiloader

+ 11
- 0
src/config/config.c View File

@@ -91,6 +91,17 @@ REQUIRE_OBJECT ( efi_console );
91 91
 REQUIRE_OBJECT ( ipv4 );
92 92
 #endif
93 93
 
94
+/*
95
+ * Drag in all requested PXE support
96
+ *
97
+ */
98
+#ifdef PXE_MENU
99
+REQUIRE_OBJECT ( pxemenu );
100
+#endif
101
+#ifdef PXE_STACK
102
+REQUIRE_OBJECT ( pxe_call );
103
+#endif
104
+
94 105
 /*
95 106
  * Drag in all requested download protocols
96 107
  *

+ 24
- 0
src/config/config_romprefix.c View File

@@ -0,0 +1,24 @@
1
+/*
2
+ * This program is free software; you can redistribute it and/or
3
+ * modify it under the terms of the GNU General Public License as
4
+ * published by the Free Software Foundation; either version 2, or (at
5
+ * your option) any later version.
6
+ */
7
+
8
+FILE_LICENCE ( GPL2_OR_LATER );
9
+
10
+#include <config/general.h>
11
+
12
+/** @file
13
+ *
14
+ * ROM prefix configuration options
15
+ *
16
+ */
17
+
18
+/*
19
+ * Provide UNDI loader if PXE stack is requested
20
+ *
21
+ */
22
+#ifdef PXE_STACK
23
+REQUIRE_OBJECT ( undiloader );
24
+#endif

+ 2
- 0
src/config/defaults/pcbios.h View File

@@ -25,6 +25,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
25 25
 #define IMAGE_BZIMAGE		/* Linux bzImage image support */
26 26
 #define IMAGE_COMBOOT		/* SYSLINUX COMBOOT image support */
27 27
 
28
+#define PXE_STACK		/* PXE stack in gPXE - required for PXELINUX */
29
+#define PXE_MENU		/* PXE menu booting */
28 30
 #define	PXE_CMD			/* PXE commands */
29 31
 
30 32
 #define	SANBOOT_PROTO_ISCSI	/* iSCSI protocol */

+ 7
- 0
src/config/general.h View File

@@ -41,6 +41,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
41 41
 
42 42
 #define	NET_PROTO_IPV4		/* IPv4 protocol */
43 43
 
44
+/*
45
+ * PXE support
46
+ *
47
+ */
48
+//#undef	PXE_STACK		/* PXE stack in gPXE - you want this! */
49
+//#undef	PXE_MENU		/* PXE menu booting */
50
+
44 51
 /*
45 52
  * Download protocols
46 53
  *

+ 3
- 1
src/include/usr/autoboot.h View File

@@ -18,6 +18,8 @@ extern void autoboot ( void );
18 18
 extern int boot_next_server_and_filename ( struct in_addr next_server,
19 19
 					   const char *filename );
20 20
 extern int boot_root_path ( const char *root_path );
21
-extern int pxe_menu_boot ( struct net_device *netdev );
21
+
22
+extern int pxe_menu_boot ( struct net_device *netdev )
23
+	__attribute__ (( weak ));
22 24
 
23 25
 #endif /* _USR_AUTOBOOT_H */

+ 1
- 1
src/usr/autoboot.c View File

@@ -151,7 +151,7 @@ static int netboot ( struct net_device *netdev ) {
151 151
 			       buf, sizeof ( buf ) );
152 152
 	pxe_discovery_control =
153 153
 		fetch_uintz_setting ( NULL, &pxe_discovery_control_setting );
154
-	if ( ( strcmp ( buf, "PXEClient" ) == 0 ) &&
154
+	if ( ( strcmp ( buf, "PXEClient" ) == 0 ) && pxe_menu_boot != NULL &&
155 155
 	     setting_exists ( NULL, &pxe_boot_menu_setting ) &&
156 156
 	     ( ! ( ( pxe_discovery_control & PXEBS_SKIP ) &&
157 157
 		   setting_exists ( NULL, &filename_setting ) ) ) ) {

Loading…
Cancel
Save