Browse Source

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).
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
0acb016840
6 changed files with 99 additions and 1 deletions
  1. 10
    1
      src/hci/shell_banner.c
  2. 5
    0
      src/include/gpxe/dhcp.h
  3. 63
    0
      src/include/gpxe/features.h
  4. 3
    0
      src/net/aoe.c
  5. 3
    0
      src/net/tcp/iscsi.c
  6. 15
    0
      src/net/udp/dhcp.c

+ 10
- 1
src/hci/shell_banner.c View File

19
 #include <stdio.h>
19
 #include <stdio.h>
20
 #include <console.h>
20
 #include <console.h>
21
 #include <latch.h>
21
 #include <latch.h>
22
+#include <gpxe/features.h>
22
 #include <gpxe/shell_banner.h>
23
 #include <gpxe/shell_banner.h>
23
 
24
 
24
 /** @file
25
 /** @file
33
 #define BOLD	"\033[1m"
34
 #define BOLD	"\033[1m"
34
 #define CYAN	"\033[36m"
35
 #define CYAN	"\033[36m"
35
 
36
 
37
+static char * features[0] __table_start ( char *, features );
38
+static char * features_end[0] __table_end ( char *, features );
39
+
36
 /**
40
 /**
37
  * Print shell banner and prompt for shell entry
41
  * Print shell banner and prompt for shell entry
38
  *
42
  *
40
  */
44
  */
41
 int shell_banner ( void ) {
45
 int shell_banner ( void ) {
42
 	unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
46
 	unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
47
+	char **feature;
43
 	int key;
48
 	int key;
44
 	int enter_shell = 0;
49
 	int enter_shell = 0;
45
 
50
 
47
 	printf ( NORMAL "\n\n\n" BOLD "gPXE " VERSION
52
 	printf ( NORMAL "\n\n\n" BOLD "gPXE " VERSION
48
 		 NORMAL " -- Open Source Boot Firmware -- "
53
 		 NORMAL " -- Open Source Boot Firmware -- "
49
 		 CYAN "http://etherboot.org" NORMAL "\n"
54
 		 CYAN "http://etherboot.org" NORMAL "\n"
50
-		 "Press Ctrl-B for the gPXE command line..." );
55
+		 "Features:" );
56
+	for ( feature = features ; feature < features_end ; feature++ ) {
57
+		printf ( " %s", *feature );
58
+	}
59
+	printf ( "\nPress Ctrl-B for the gPXE command line..." );
51
 
60
 
52
 	/* Wait for key */
61
 	/* Wait for key */
53
 	while ( currticks() < timeout ) {
62
 	while ( currticks() < timeout ) {

+ 5
- 0
src/include/gpxe/dhcp.h View File

168
  */
168
  */
169
 #define DHCP_EB_SIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 3 )
169
 #define DHCP_EB_SIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 3 )
170
 
170
 
171
+/*
172
+ * Tags in the range 0x10-0x7f are reserved for feature markers
173
+ *
174
+ */
175
+
171
 /** Network device descriptor
176
 /** Network device descriptor
172
  *
177
  *
173
  * Byte 0 is the bus type ID; remaining bytes depend on the bus type.
178
  * Byte 0 is the bus type ID; remaining bytes depend on the bus type.

+ 63
- 0
src/include/gpxe/features.h View File

1
+#ifndef _GPXE_FEATURES_H
2
+#define _GPXE_FEATURES_H
3
+
4
+#include <stdint.h>
5
+#include <gpxe/tables.h>
6
+#include <gpxe/dhcp.h>
7
+
8
+/** @file
9
+ *
10
+ * Feature list
11
+ *
12
+ */
13
+
14
+/**
15
+ * @defgroup dhcpfeatures DHCP feature option tags
16
+ *
17
+ * DHCP feature option tags are Etherboot encapsulated options in the
18
+ * range 0x10-0x7f.
19
+ *
20
+ * @{
21
+ */
22
+
23
+/** PXE API extensions */
24
+#define DHCP_EB_FEATURE_PXE_EXT 0x10
25
+
26
+/** iSCSI */
27
+#define DHCP_EB_FEATURE_ISCSI 0x11
28
+
29
+/** AoE */
30
+#define DHCP_EB_FEATURE_AOE 0x12
31
+
32
+/** @} */
33
+
34
+/** Declare a feature code for DHCP */
35
+#define __dhcp_feature __table ( uint8_t, dhcp_features, 01 )
36
+
37
+/** Construct a DHCP feature table entry */
38
+#define DHCP_FEATURE( feature_opt ) \
39
+	_DHCP_FEATURE ( OBJECT, feature_opt )
40
+#define _DHCP_FEATURE( _name, feature_opt ) \
41
+	__DHCP_FEATURE ( _name, feature_opt )
42
+#define __DHCP_FEATURE( _name, feature_opt )			\
43
+	uint8_t __dhcp_feature_ ## _name [] __dhcp_feature = {	\
44
+		feature_opt, DHCP_BYTE ( 1 )			\
45
+	};
46
+
47
+/** Declare a named feature */
48
+#define __feature_name __table ( char *, features, 01 )
49
+
50
+/** Construct a named feature */
51
+#define FEATURE_NAME( text ) \
52
+	_FEATURE_NAME ( OBJECT, text )
53
+#define _FEATURE_NAME( _name, text ) \
54
+	__FEATURE_NAME ( _name, text )
55
+#define __FEATURE_NAME( _name, text )				\
56
+	char * __feature_ ## _name __feature_name = text;
57
+
58
+/** Declare a feature */
59
+#define FEATURE( text, feature_opt )				\
60
+	FEATURE_NAME ( text );					\
61
+	DHCP_FEATURE ( feature_opt );
62
+
63
+#endif /* _GPXE_FEATURES_H */

+ 3
- 0
src/net/aoe.c View File

31
 #include <gpxe/ata.h>
31
 #include <gpxe/ata.h>
32
 #include <gpxe/netdevice.h>
32
 #include <gpxe/netdevice.h>
33
 #include <gpxe/process.h>
33
 #include <gpxe/process.h>
34
+#include <gpxe/features.h>
34
 #include <gpxe/aoe.h>
35
 #include <gpxe/aoe.h>
35
 
36
 
36
 /** @file
37
 /** @file
39
  *
40
  *
40
  */
41
  */
41
 
42
 
43
+FEATURE ( "AoE", DHCP_EB_FEATURE_AOE );
44
+
42
 struct net_protocol aoe_protocol;
45
 struct net_protocol aoe_protocol;
43
 
46
 
44
 /** List of all AoE sessions */
47
 /** List of all AoE sessions */

+ 3
- 0
src/net/tcp/iscsi.c View File

32
 #include <gpxe/uaccess.h>
32
 #include <gpxe/uaccess.h>
33
 #include <gpxe/tcpip.h>
33
 #include <gpxe/tcpip.h>
34
 #include <gpxe/dhcp.h>
34
 #include <gpxe/dhcp.h>
35
+#include <gpxe/features.h>
35
 #include <gpxe/iscsi.h>
36
 #include <gpxe/iscsi.h>
36
 
37
 
37
 /** @file
38
 /** @file
40
  *
41
  *
41
  */
42
  */
42
 
43
 
44
+FEATURE ( "iSCSI", DHCP_EB_FEATURE_ISCSI );
45
+
43
 /** iSCSI initiator name (explicitly specified) */
46
 /** iSCSI initiator name (explicitly specified) */
44
 static char *iscsi_explicit_initiator_iqn;
47
 static char *iscsi_explicit_initiator_iqn;
45
 
48
 

+ 15
- 0
src/net/udp/dhcp.c View File

70
 	DHCP_END
70
 	DHCP_END
71
 };
71
 };
72
 
72
 
73
+/** DHCP feature codes */
74
+static uint8_t dhcp_features[0] __table_start ( uint8_t, dhcp_features );
75
+static uint8_t dhcp_features_end[0] __table_end ( uint8_t, dhcp_features );
76
+
73
 /**
77
 /**
74
  * Name a DHCP packet type
78
  * Name a DHCP packet type
75
  *
79
  *
508
 			  struct dhcp_packet *dhcppkt ) {
512
 			  struct dhcp_packet *dhcppkt ) {
509
 	struct device_description *desc = &netdev->dev->desc;
513
 	struct device_description *desc = &netdev->dev->desc;
510
 	struct dhcp_netdev_desc dhcp_desc;
514
 	struct dhcp_netdev_desc dhcp_desc;
515
+	size_t dhcp_features_len;
511
 	int rc;
516
 	int rc;
512
 
517
 
513
 	/* Create DHCP packet */
518
 	/* Create DHCP packet */
544
 		}
549
 		}
545
 	}
550
 	}
546
 
551
 
552
+	/* Add options to identify the feature list */
553
+	dhcp_features_len = ( dhcp_features_end - dhcp_features );
554
+	if ( ( rc = set_dhcp_packet_option ( dhcppkt, DHCP_EB_ENCAP,
555
+					     dhcp_features,
556
+					     dhcp_features_len ) ) != 0 ) {
557
+		DBG ( "DHCP could not set features list option: %s\n",
558
+		      strerror ( rc ) );
559
+		return rc;
560
+	}
561
+
547
 	/* Add options to identify the network device */
562
 	/* Add options to identify the network device */
548
 	dhcp_desc.type = desc->bus_type;
563
 	dhcp_desc.type = desc->bus_type;
549
 	dhcp_desc.vendor = htons ( desc->vendor );
564
 	dhcp_desc.vendor = htons ( desc->vendor );

Loading…
Cancel
Save