ソースを参照

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年前
コミット
0acb016840
6個のファイルの変更99行の追加1行の削除
  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 ファイルの表示

@@ -19,6 +19,7 @@
19 19
 #include <stdio.h>
20 20
 #include <console.h>
21 21
 #include <latch.h>
22
+#include <gpxe/features.h>
22 23
 #include <gpxe/shell_banner.h>
23 24
 
24 25
 /** @file
@@ -33,6 +34,9 @@
33 34
 #define BOLD	"\033[1m"
34 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 41
  * Print shell banner and prompt for shell entry
38 42
  *
@@ -40,6 +44,7 @@
40 44
  */
41 45
 int shell_banner ( void ) {
42 46
 	unsigned long timeout = ( currticks() + BANNER_TIMEOUT );
47
+	char **feature;
43 48
 	int key;
44 49
 	int enter_shell = 0;
45 50
 
@@ -47,7 +52,11 @@ int shell_banner ( void ) {
47 52
 	printf ( NORMAL "\n\n\n" BOLD "gPXE " VERSION
48 53
 		 NORMAL " -- Open Source Boot Firmware -- "
49 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 61
 	/* Wait for key */
53 62
 	while ( currticks() < timeout ) {

+ 5
- 0
src/include/gpxe/dhcp.h ファイルの表示

@@ -168,6 +168,11 @@ struct job_interface;
168 168
  */
169 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 176
 /** Network device descriptor
172 177
  *
173 178
  * Byte 0 is the bus type ID; remaining bytes depend on the bus type.

+ 63
- 0
src/include/gpxe/features.h ファイルの表示

@@ -0,0 +1,63 @@
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 ファイルの表示

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

+ 3
- 0
src/net/tcp/iscsi.c ファイルの表示

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

+ 15
- 0
src/net/udp/dhcp.c ファイルの表示

@@ -70,6 +70,10 @@ static uint8_t dhcp_request_options_data[] = {
70 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 78
  * Name a DHCP packet type
75 79
  *
@@ -508,6 +512,7 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
508 512
 			  struct dhcp_packet *dhcppkt ) {
509 513
 	struct device_description *desc = &netdev->dev->desc;
510 514
 	struct dhcp_netdev_desc dhcp_desc;
515
+	size_t dhcp_features_len;
511 516
 	int rc;
512 517
 
513 518
 	/* Create DHCP packet */
@@ -544,6 +549,16 @@ int create_dhcp_request ( struct net_device *netdev, int msgtype,
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 562
 	/* Add options to identify the network device */
548 563
 	dhcp_desc.type = desc->bus_type;
549 564
 	dhcp_desc.vendor = htons ( desc->vendor );

読み込み中…
キャンセル
保存