david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

Allowed zero-cost enforced ordering of features in startup banner

list.

Added FEATURE() macros to most relevant (non-driver) files.
This commit is contained in:
Michael Brown 2007-08-02 14:51:03 +01:00
parent 67afe84292
commit 9fd6a0418f
13 changed files with 80 additions and 40 deletions

View File

@ -36,6 +36,9 @@
#include <gpxe/init.h> #include <gpxe/init.h>
#include <gpxe/initrd.h> #include <gpxe/initrd.h>
#include <gpxe/cpio.h> #include <gpxe/cpio.h>
#include <gpxe/features.h>
FEATURE ( FEATURE_IMAGE, "bzImage", DHCP_EB_FEATURE_BZIMAGE, 1 );
struct image_type bzimage_image_type __image_type ( PROBE_NORMAL ); struct image_type bzimage_image_type __image_type ( PROBE_NORMAL );

View File

@ -33,6 +33,9 @@
#include <gpxe/memmap.h> #include <gpxe/memmap.h>
#include <gpxe/elf.h> #include <gpxe/elf.h>
#include <gpxe/init.h> #include <gpxe/init.h>
#include <gpxe/features.h>
FEATURE ( FEATURE_IMAGE, "Multiboot", DHCP_EB_FEATURE_MULTIBOOT, 1 );
struct image_type multiboot_image_type __image_type ( PROBE_MULTIBOOT ); struct image_type multiboot_image_type __image_type ( PROBE_MULTIBOOT );

View File

@ -10,6 +10,7 @@
#include <gpxe/netdevice.h> #include <gpxe/netdevice.h>
#include <gpxe/dhcp.h> #include <gpxe/dhcp.h>
#include <gpxe/image.h> #include <gpxe/image.h>
#include <gpxe/features.h>
/** @file /** @file
* *
@ -26,6 +27,8 @@
* *
*/ */
FEATURE ( FEATURE_IMAGE, "NBI", DHCP_EB_FEATURE_NBI, 1 );
struct image_type nbi_image_type __image_type ( PROBE_NORMAL ); struct image_type nbi_image_type __image_type ( PROBE_NORMAL );
/** /**

View File

@ -29,6 +29,9 @@
#include <gpxe/image.h> #include <gpxe/image.h>
#include <gpxe/segment.h> #include <gpxe/segment.h>
#include <gpxe/netdevice.h> #include <gpxe/netdevice.h>
#include <gpxe/features.h>
FEATURE ( FEATURE_IMAGE, "PXE", DHCP_EB_FEATURE_PXE, 1 );
struct image_type pxe_image_type __image_type ( PROBE_PXE ); struct image_type pxe_image_type __image_type ( PROBE_PXE );

View File

@ -34,8 +34,8 @@
#define BOLD "\033[1m" #define BOLD "\033[1m"
#define CYAN "\033[36m" #define CYAN "\033[36m"
static char * features[0] __table_start ( char *, features ); static struct feature features[0] __table_start ( struct feature, features );
static char * features_end[0] __table_end ( char *, features ); static struct feature features_end[0] __table_end ( struct feature, features );
/** /**
* Print shell banner and prompt for shell entry * Print shell banner and prompt for shell entry
@ -44,7 +44,7 @@ static char * features_end[0] __table_end ( char *, features );
*/ */
int shell_banner ( void ) { int shell_banner ( void ) {
unsigned long timeout = ( currticks() + BANNER_TIMEOUT ); unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
char **feature; struct feature *feature;
int key; int key;
int enter_shell = 0; int enter_shell = 0;
@ -54,7 +54,7 @@ int shell_banner ( void ) {
CYAN "http://etherboot.org" NORMAL "\n" CYAN "http://etherboot.org" NORMAL "\n"
"Features:" ); "Features:" );
for ( feature = features ; feature < features_end ; feature++ ) { for ( feature = features ; feature < features_end ; feature++ ) {
printf ( " %s", *feature ); printf ( " %s", feature->name );
} }
printf ( "\nPress Ctrl-B for the gPXE command line..." ); printf ( "\nPress Ctrl-B for the gPXE command line..." );

View File

@ -11,6 +11,17 @@
* *
*/ */
/**
* @defgroup featurecat Feature categories
* @{
*/
#define FEATURE_PROTOCOL 01 /**< Network protocols */
#define FEATURE_IMAGE 02 /**< Image formats */
#define FEATURE_MISC 03 /**< Miscellaneous */
/** @} */
/** /**
* @defgroup dhcpfeatures DHCP feature option tags * @defgroup dhcpfeatures DHCP feature option tags
* *
@ -20,50 +31,58 @@
* @{ * @{
*/ */
/** PXE API extensions */ #define DHCP_EB_FEATURE_PXE_EXT 0x10 /**< PXE API extensions */
#define DHCP_EB_FEATURE_PXE_EXT 0x10 #define DHCP_EB_FEATURE_ISCSI 0x11 /**< iSCSI protocol */
#define DHCP_EB_FEATURE_AOE 0x12 /**< AoE protocol */
/** iSCSI */ #define DHCP_EB_FEATURE_HTTP 0x13 /**< HTTP protocol */
#define DHCP_EB_FEATURE_ISCSI 0x11 #define DHCP_EB_FEATURE_HTTPS 0x14 /**< HTTPS protocol */
#define DHCP_EB_FEATURE_TFTP 0x15 /**< TFTP protocol */
/** AoE */ #define DHCP_EB_FEATURE_FTP 0x16 /**< FTP protocol */
#define DHCP_EB_FEATURE_AOE 0x12 #define DHCP_EB_FEATURE_DNS 0x17 /**< DNS protocol */
#define DHCP_EB_FEATURE_BZIMAGE 0x18 /**< bzImage format */
/** HTTP */ #define DHCP_EB_FEATURE_MULTIBOOT 0x19 /**< Multiboot format */
#define DHCP_EB_FEATURE_HTTP 0x13 #define DHCP_EB_FEATURE_NBI 0x20 /**< NBI format */
#define DHCP_EB_FEATURE_PXE 0x21 /**< PXE format */
/** HTTPS */
#define DHCP_EB_FEATURE_HTTPS 0x14
/** @} */ /** @} */
/** Declare a feature code for DHCP */ /** Declare a feature code for DHCP */
#define __dhcp_feature __table ( uint8_t, dhcp_features, 01 ) #define __dhcp_feature( category ) \
__table ( uint8_t, dhcp_features, category )
/** Construct a DHCP feature table entry */ /** Construct a DHCP feature table entry */
#define DHCP_FEATURE( feature_opt, version ) \ #define DHCP_FEATURE( category, feature_opt, version ) \
_DHCP_FEATURE ( OBJECT, feature_opt, version ) _DHCP_FEATURE ( category, OBJECT, feature_opt, version )
#define _DHCP_FEATURE( _name, feature_opt, version ) \ #define _DHCP_FEATURE( category, _name, feature_opt, version ) \
__DHCP_FEATURE ( _name, feature_opt, version ) __DHCP_FEATURE ( category, _name, feature_opt, version )
#define __DHCP_FEATURE( _name, feature_opt, version ) \ #define __DHCP_FEATURE( category, _name, feature_opt, version ) \
uint8_t __dhcp_feature_ ## _name [] __dhcp_feature = { \ uint8_t __dhcp_feature_ ## _name [] __dhcp_feature ( category ) = { \
feature_opt, DHCP_BYTE ( version ) \ feature_opt, DHCP_BYTE ( version ) \
}; };
/** A named feature */
struct feature {
/** Feature name */
char *name;
};
/** Declare a named feature */ /** Declare a named feature */
#define __feature_name __table ( char *, features, 01 ) #define __feature_name( category ) \
__table ( struct feature, features, category )
/** Construct a named feature */ /** Construct a named feature */
#define FEATURE_NAME( text ) \ #define FEATURE_NAME( category, text ) \
_FEATURE_NAME ( OBJECT, text ) _FEATURE_NAME ( category, OBJECT, text )
#define _FEATURE_NAME( _name, text ) \ #define _FEATURE_NAME( category, _name, text ) \
__FEATURE_NAME ( _name, text ) __FEATURE_NAME ( category, _name, text )
#define __FEATURE_NAME( _name, text ) \ #define __FEATURE_NAME( category, _name, text ) \
char * __feature_ ## _name __feature_name = text; struct feature __feature_ ## _name __feature_name ( category ) = { \
.name = text, \
};
/** Declare a feature */ /** Declare a feature */
#define FEATURE( text, feature_opt, version ) \ #define FEATURE( category, text, feature_opt, version ) \
FEATURE_NAME ( text ); \ FEATURE_NAME ( category, text ); \
DHCP_FEATURE ( feature_opt, version ); DHCP_FEATURE ( category, feature_opt, version );
#endif /* _GPXE_FEATURES_H */ #endif /* _GPXE_FEATURES_H */

View File

@ -40,7 +40,7 @@
* *
*/ */
FEATURE ( "AoE", DHCP_EB_FEATURE_AOE, 1 ); FEATURE ( FEATURE_PROTOCOL, "AoE", DHCP_EB_FEATURE_AOE, 1 );
struct net_protocol aoe_protocol; struct net_protocol aoe_protocol;

View File

@ -11,6 +11,7 @@
#include <gpxe/xfer.h> #include <gpxe/xfer.h>
#include <gpxe/open.h> #include <gpxe/open.h>
#include <gpxe/uri.h> #include <gpxe/uri.h>
#include <gpxe/features.h>
#include <gpxe/ftp.h> #include <gpxe/ftp.h>
/** @file /** @file
@ -19,6 +20,8 @@
* *
*/ */
FEATURE ( FEATURE_PROTOCOL, "FTP", DHCP_EB_FEATURE_FTP, 1 );
/** /**
* FTP states * FTP states
* *

View File

@ -43,7 +43,7 @@
#include <gpxe/features.h> #include <gpxe/features.h>
#include <gpxe/http.h> #include <gpxe/http.h>
FEATURE ( "HTTP", DHCP_EB_FEATURE_HTTP, 1 ); FEATURE ( FEATURE_PROTOCOL, "HTTP", DHCP_EB_FEATURE_HTTP, 1 );
/** HTTP receive state */ /** HTTP receive state */
enum http_rx_state { enum http_rx_state {

View File

@ -29,7 +29,7 @@
#include <gpxe/http.h> #include <gpxe/http.h>
#include <gpxe/features.h> #include <gpxe/features.h>
FEATURE ( "HTTPS", DHCP_EB_FEATURE_HTTPS, 1 ); FEATURE ( FEATURE_PROTOCOL, "HTTPS", DHCP_EB_FEATURE_HTTPS, 1 );
/** /**
* Initiate an HTTPS connection * Initiate an HTTPS connection

View File

@ -41,7 +41,7 @@
* *
*/ */
FEATURE ( "iSCSI", DHCP_EB_FEATURE_ISCSI, 1 ); FEATURE ( FEATURE_PROTOCOL, "iSCSI", DHCP_EB_FEATURE_ISCSI, 1 );
/** iSCSI initiator name (explicitly specified) */ /** iSCSI initiator name (explicitly specified) */
static char *iscsi_explicit_initiator_iqn; static char *iscsi_explicit_initiator_iqn;

View File

@ -31,6 +31,7 @@
#include <gpxe/retry.h> #include <gpxe/retry.h>
#include <gpxe/tcpip.h> #include <gpxe/tcpip.h>
#include <gpxe/dhcp.h> #include <gpxe/dhcp.h>
#include <gpxe/features.h>
#include <gpxe/dns.h> #include <gpxe/dns.h>
/** @file /** @file
@ -39,6 +40,8 @@
* *
*/ */
FEATURE ( FEATURE_PROTOCOL, "DNS", DHCP_EB_FEATURE_DNS, 1 );
/** The DNS server */ /** The DNS server */
static struct sockaddr_tcpip nameserver = { static struct sockaddr_tcpip nameserver = {
.st_port = htons ( DNS_PORT ), .st_port = htons ( DNS_PORT ),

View File

@ -30,6 +30,7 @@
#include <gpxe/uri.h> #include <gpxe/uri.h>
#include <gpxe/tcpip.h> #include <gpxe/tcpip.h>
#include <gpxe/retry.h> #include <gpxe/retry.h>
#include <gpxe/features.h>
#include <gpxe/tftp.h> #include <gpxe/tftp.h>
/** @file /** @file
@ -38,6 +39,8 @@
* *
*/ */
FEATURE ( FEATURE_PROTOCOL, "TFTP", DHCP_EB_FEATURE_TFTP, 1 );
/** /**
* A TFTP request * A TFTP request
* *