mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-18 21:43:14 +00:00
Add FEATURE() macro, plus code to display features at startup time,
and generate DHCP options to indicate features to DHCP server (and to PXE NBPs).
This commit is contained in:
parent
857c5db4dd
commit
0acb016840
@ -19,6 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <console.h>
|
||||
#include <latch.h>
|
||||
#include <gpxe/features.h>
|
||||
#include <gpxe/shell_banner.h>
|
||||
|
||||
/** @file
|
||||
@ -33,6 +34,9 @@
|
||||
#define BOLD "\033[1m"
|
||||
#define CYAN "\033[36m"
|
||||
|
||||
static char * features[0] __table_start ( char *, features );
|
||||
static char * features_end[0] __table_end ( char *, features );
|
||||
|
||||
/**
|
||||
* Print shell banner and prompt for shell entry
|
||||
*
|
||||
@ -40,6 +44,7 @@
|
||||
*/
|
||||
int shell_banner ( void ) {
|
||||
unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
|
||||
char **feature;
|
||||
int key;
|
||||
int enter_shell = 0;
|
||||
|
||||
@ -47,7 +52,11 @@ int shell_banner ( void ) {
|
||||
printf ( NORMAL "\n\n\n" BOLD "gPXE " VERSION
|
||||
NORMAL " -- Open Source Boot Firmware -- "
|
||||
CYAN "http://etherboot.org" NORMAL "\n"
|
||||
"Press Ctrl-B for the gPXE command line..." );
|
||||
"Features:" );
|
||||
for ( feature = features ; feature < features_end ; feature++ ) {
|
||||
printf ( " %s", *feature );
|
||||
}
|
||||
printf ( "\nPress Ctrl-B for the gPXE command line..." );
|
||||
|
||||
/* Wait for key */
|
||||
while ( currticks() < timeout ) {
|
||||
|
@ -168,6 +168,11 @@ struct job_interface;
|
||||
*/
|
||||
#define DHCP_EB_SIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 3 )
|
||||
|
||||
/*
|
||||
* Tags in the range 0x10-0x7f are reserved for feature markers
|
||||
*
|
||||
*/
|
||||
|
||||
/** Network device descriptor
|
||||
*
|
||||
* Byte 0 is the bus type ID; remaining bytes depend on the bus type.
|
||||
|
63
src/include/gpxe/features.h
Normal file
63
src/include/gpxe/features.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef _GPXE_FEATURES_H
|
||||
#define _GPXE_FEATURES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gpxe/tables.h>
|
||||
#include <gpxe/dhcp.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Feature list
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup dhcpfeatures DHCP feature option tags
|
||||
*
|
||||
* DHCP feature option tags are Etherboot encapsulated options in the
|
||||
* range 0x10-0x7f.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** PXE API extensions */
|
||||
#define DHCP_EB_FEATURE_PXE_EXT 0x10
|
||||
|
||||
/** iSCSI */
|
||||
#define DHCP_EB_FEATURE_ISCSI 0x11
|
||||
|
||||
/** AoE */
|
||||
#define DHCP_EB_FEATURE_AOE 0x12
|
||||
|
||||
/** @} */
|
||||
|
||||
/** Declare a feature code for DHCP */
|
||||
#define __dhcp_feature __table ( uint8_t, dhcp_features, 01 )
|
||||
|
||||
/** Construct a DHCP feature table entry */
|
||||
#define DHCP_FEATURE( feature_opt ) \
|
||||
_DHCP_FEATURE ( OBJECT, feature_opt )
|
||||
#define _DHCP_FEATURE( _name, feature_opt ) \
|
||||
__DHCP_FEATURE ( _name, feature_opt )
|
||||
#define __DHCP_FEATURE( _name, feature_opt ) \
|
||||
uint8_t __dhcp_feature_ ## _name [] __dhcp_feature = { \
|
||||
feature_opt, DHCP_BYTE ( 1 ) \
|
||||
};
|
||||
|
||||
/** Declare a named feature */
|
||||
#define __feature_name __table ( char *, features, 01 )
|
||||
|
||||
/** Construct a named feature */
|
||||
#define FEATURE_NAME( text ) \
|
||||
_FEATURE_NAME ( OBJECT, text )
|
||||
#define _FEATURE_NAME( _name, text ) \
|
||||
__FEATURE_NAME ( _name, text )
|
||||
#define __FEATURE_NAME( _name, text ) \
|
||||
char * __feature_ ## _name __feature_name = text;
|
||||
|
||||
/** Declare a feature */
|
||||
#define FEATURE( text, feature_opt ) \
|
||||
FEATURE_NAME ( text ); \
|
||||
DHCP_FEATURE ( feature_opt );
|
||||
|
||||
#endif /* _GPXE_FEATURES_H */
|
@ -31,6 +31,7 @@
|
||||
#include <gpxe/ata.h>
|
||||
#include <gpxe/netdevice.h>
|
||||
#include <gpxe/process.h>
|
||||
#include <gpxe/features.h>
|
||||
#include <gpxe/aoe.h>
|
||||
|
||||
/** @file
|
||||
@ -39,6 +40,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
FEATURE ( "AoE", DHCP_EB_FEATURE_AOE );
|
||||
|
||||
struct net_protocol aoe_protocol;
|
||||
|
||||
/** List of all AoE sessions */
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <gpxe/uaccess.h>
|
||||
#include <gpxe/tcpip.h>
|
||||
#include <gpxe/dhcp.h>
|
||||
#include <gpxe/features.h>
|
||||
#include <gpxe/iscsi.h>
|
||||
|
||||
/** @file
|
||||
@ -40,6 +41,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
FEATURE ( "iSCSI", DHCP_EB_FEATURE_ISCSI );
|
||||
|
||||
/** iSCSI initiator name (explicitly specified) */
|
||||
static char *iscsi_explicit_initiator_iqn;
|
||||
|
||||
|
@ -70,6 +70,10 @@ static uint8_t dhcp_request_options_data[] = {
|
||||
DHCP_END
|
||||
};
|
||||
|
||||
/** DHCP feature codes */
|
||||
static uint8_t dhcp_features[0] __table_start ( uint8_t, dhcp_features );
|
||||
static uint8_t dhcp_features_end[0] __table_end ( uint8_t, dhcp_features );
|
||||
|
||||
/**
|
||||
* Name a DHCP packet type
|
||||
*
|
||||
@ -508,6 +512,7 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
|
||||
struct dhcp_packet *dhcppkt ) {
|
||||
struct device_description *desc = &netdev->dev->desc;
|
||||
struct dhcp_netdev_desc dhcp_desc;
|
||||
size_t dhcp_features_len;
|
||||
int rc;
|
||||
|
||||
/* Create DHCP packet */
|
||||
@ -544,6 +549,16 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
|
||||
}
|
||||
}
|
||||
|
||||
/* Add options to identify the feature list */
|
||||
dhcp_features_len = ( dhcp_features_end - dhcp_features );
|
||||
if ( ( rc = set_dhcp_packet_option ( dhcppkt, DHCP_EB_ENCAP,
|
||||
dhcp_features,
|
||||
dhcp_features_len ) ) != 0 ) {
|
||||
DBG ( "DHCP could not set features list option: %s\n",
|
||||
strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Add options to identify the network device */
|
||||
dhcp_desc.type = desc->bus_type;
|
||||
dhcp_desc.vendor = htons ( desc->vendor );
|
||||
|
Loading…
x
Reference in New Issue
Block a user