Skip to content

Commit

Permalink
[config] Make PXE stack a compile-time option
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rwcr authored and Marty Connor committed Jan 20, 2010
1 parent 9e9cc8c commit fa4aec8
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 48 deletions.
19 changes: 19 additions & 0 deletions src/arch/i386/include/pxe_call.h
Expand Up @@ -34,5 +34,24 @@ extern void pxe_activate ( struct net_device *netdev );
extern int pxe_deactivate ( void );
extern int pxe_start_nbp ( void );
extern __asmcall void pxe_api_call ( struct i386_all_regs *ix86 );
extern int _pxe_api_call_weak ( struct i386_all_regs *ix86 )
__attribute__ (( weak ));

/**
* Dispatch PXE API call weakly
*
* @v ix86 Registers for PXE call
* @ret present Zero if the PXE stack is present, nonzero if not
*
* A successful return only indicates that the PXE stack was available
* for dispatching the call; it says nothing about the success of
* whatever the call asked for.
*/
static inline int pxe_api_call_weak ( struct i386_all_regs *ix86 )
{
if ( _pxe_api_call_weak != NULL )
return _pxe_api_call_weak ( ix86 );
return -1;
}

#endif /* _PXE_CALL_H */
12 changes: 12 additions & 0 deletions src/arch/i386/interface/pxe/pxe_call.c
Expand Up @@ -339,6 +339,18 @@ __asmcall void pxe_api_call ( struct i386_all_regs *ix86 ) {
ix86->regs.ax = ret;
}

/**
* Dispatch weak PXE API call with PXE stack available
*
* @v ix86 Registers for PXE call
* @ret present Zero (PXE stack present)
*/
int _pxe_api_call_weak ( struct i386_all_regs *ix86 )
{
pxe_api_call ( ix86 );
return 0;
}

/**
* Dispatch PXE loader call
*
Expand Down
6 changes: 4 additions & 2 deletions src/arch/i386/interface/syslinux/comboot_call.c
Expand Up @@ -445,8 +445,10 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
break;

case 0x0009: /* Call PXE Stack */
pxe_api_call ( ix86 );
ix86->flags &= ~CF;
if ( pxe_api_call_weak ( ix86 ) != 0 )
ix86->flags |= CF;
else
ix86->flags &= ~CF;
break;

case 0x000A: /* Get Derivative-Specific Information */
Expand Down
47 changes: 3 additions & 44 deletions src/arch/i386/prefix/romprefix.S
Expand Up @@ -126,6 +126,7 @@ prodstr_pci_id:
.size prodstr, . - prodstr

.globl undiheader
.weak undiloader
undiheader:
.ascii "UNDI" /* Signature */
.byte undiheader_len /* Length of structure */
Expand Down Expand Up @@ -495,6 +496,7 @@ init_message_done:
*
* May be either within option ROM space, or within PMM-allocated block.
*/
.globl image_source
image_source:
.long 0
.size image_source, . - image_source
Expand All @@ -503,6 +505,7 @@ image_source:
*
* May be either at HIGHMEM_LOADPOINT, or within PMM-allocated block.
*/
.globl decompress_to
decompress_to:
.long HIGHMEM_LOADPOINT
.size decompress_to, . - decompress_to
Expand Down Expand Up @@ -644,50 +647,6 @@ exec_message:
.asciz " starting execution\n"
.size exec_message, . - exec_message

/* UNDI loader
*
* Called by an external program to load our PXE stack.
*/
undiloader:
/* Save registers */
pushl %esi
pushl %edi
pushw %ds
pushw %es
pushw %bx
/* ROM segment address to %ds */
pushw %cs
popw %ds
/* UNDI loader parameter structure address into %es:%di */
movw %sp, %bx
movw %ss:18(%bx), %di
movw %ss:20(%bx), %es
/* Install to specified real-mode addresses */
pushw %di
movw %es:12(%di), %bx
movw %es:14(%di), %ax
movl image_source, %esi
movl decompress_to, %edi
call install_prealloc
popw %di
/* Call UNDI loader C code */
pushl $pxe_loader_call
pushw %cs
pushw $1f
pushw %ax
pushw $prot_call
lret
1: popw %bx /* discard */
popw %bx /* discard */
/* Restore registers and return */
popw %bx
popw %es
popw %ds
popl %edi
popl %esi
lret
.size undiloader, . - undiloader

/* Wait for key press specified by %bl (masked by %bh)
*
* Used by init and INT19 code when prompting user. If the specified
Expand Down
49 changes: 49 additions & 0 deletions src/arch/i386/prefix/undiloader.S
@@ -0,0 +1,49 @@
.text
.code16
.arch i386
.section ".prefix", "ax", @progbits

/* UNDI loader
*
* Called by an external program to load our PXE stack.
*/
.globl undiloader
undiloader:
/* Save registers */
pushl %esi
pushl %edi
pushw %ds
pushw %es
pushw %bx
/* ROM segment address to %ds */
pushw %cs
popw %ds
/* UNDI loader parameter structure address into %es:%di */
movw %sp, %bx
movw %ss:18(%bx), %di
movw %ss:20(%bx), %es
/* Install to specified real-mode addresses */
pushw %di
movw %es:12(%di), %bx
movw %es:14(%di), %ax
movl image_source, %esi
movl decompress_to, %edi
call install_prealloc
popw %di
/* Call UNDI loader C code */
pushl $pxe_loader_call
pushw %cs
pushw $1f
pushw %ax
pushw $prot_call
lret
1: popw %bx /* discard */
popw %bx /* discard */
/* Restore registers and return */
popw %bx
popw %es
popw %ds
popl %edi
popl %esi
lret
.size undiloader, . - undiloader
11 changes: 11 additions & 0 deletions src/config/config.c
Expand Up @@ -91,6 +91,17 @@ REQUIRE_OBJECT ( efi_console );
REQUIRE_OBJECT ( ipv4 );
#endif

/*
* Drag in all requested PXE support
*
*/
#ifdef PXE_MENU
REQUIRE_OBJECT ( pxemenu );
#endif
#ifdef PXE_STACK
REQUIRE_OBJECT ( pxe_call );
#endif

/*
* Drag in all requested download protocols
*
Expand Down
24 changes: 24 additions & 0 deletions src/config/config_romprefix.c
@@ -0,0 +1,24 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2, or (at
* your option) any later version.
*/

FILE_LICENCE ( GPL2_OR_LATER );

#include <config/general.h>

/** @file
*
* ROM prefix configuration options
*
*/

/*
* Provide UNDI loader if PXE stack is requested
*
*/
#ifdef PXE_STACK
REQUIRE_OBJECT ( undiloader );
#endif
2 changes: 2 additions & 0 deletions src/config/defaults/pcbios.h
Expand Up @@ -25,6 +25,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define IMAGE_BZIMAGE /* Linux bzImage image support */
#define IMAGE_COMBOOT /* SYSLINUX COMBOOT image support */

#define PXE_STACK /* PXE stack in gPXE - required for PXELINUX */
#define PXE_MENU /* PXE menu booting */
#define PXE_CMD /* PXE commands */

#define SANBOOT_PROTO_ISCSI /* iSCSI protocol */
Expand Down
7 changes: 7 additions & 0 deletions src/config/general.h
Expand Up @@ -41,6 +41,13 @@ FILE_LICENCE ( GPL2_OR_LATER );

#define NET_PROTO_IPV4 /* IPv4 protocol */

/*
* PXE support
*
*/
//#undef PXE_STACK /* PXE stack in gPXE - you want this! */
//#undef PXE_MENU /* PXE menu booting */

/*
* Download protocols
*
Expand Down
4 changes: 3 additions & 1 deletion src/include/usr/autoboot.h
Expand Up @@ -18,6 +18,8 @@ extern void autoboot ( void );
extern int boot_next_server_and_filename ( struct in_addr next_server,
const char *filename );
extern int boot_root_path ( const char *root_path );
extern int pxe_menu_boot ( struct net_device *netdev );

extern int pxe_menu_boot ( struct net_device *netdev )
__attribute__ (( weak ));

#endif /* _USR_AUTOBOOT_H */
2 changes: 1 addition & 1 deletion src/usr/autoboot.c
Expand Up @@ -151,7 +151,7 @@ static int netboot ( struct net_device *netdev ) {
buf, sizeof ( buf ) );
pxe_discovery_control =
fetch_uintz_setting ( NULL, &pxe_discovery_control_setting );
if ( ( strcmp ( buf, "PXEClient" ) == 0 ) &&
if ( ( strcmp ( buf, "PXEClient" ) == 0 ) && pxe_menu_boot != NULL &&
setting_exists ( NULL, &pxe_boot_menu_setting ) &&
( ! ( ( pxe_discovery_control & PXEBS_SKIP ) &&
setting_exists ( NULL, &filename_setting ) ) ) ) {
Expand Down

0 comments on commit fa4aec8

Please sign in to comment.