Selaa lähdekoodia

Allowed zero-cost enforced ordering of features in startup banner

list.

Added FEATURE() macros to most relevant (non-driver) files.
tags/v0.9.3
Michael Brown 17 vuotta sitten
vanhempi
commit
9fd6a0418f

+ 3
- 0
src/arch/i386/image/bzimage.c Näytä tiedosto

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

+ 3
- 0
src/arch/i386/image/multiboot.c Näytä tiedosto

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

+ 3
- 0
src/arch/i386/image/nbi.c Näytä tiedosto

@@ -10,6 +10,7 @@
10 10
 #include <gpxe/netdevice.h>
11 11
 #include <gpxe/dhcp.h>
12 12
 #include <gpxe/image.h>
13
+#include <gpxe/features.h>
13 14
 
14 15
 /** @file
15 16
  *
@@ -26,6 +27,8 @@
26 27
  *
27 28
  */
28 29
 
30
+FEATURE ( FEATURE_IMAGE, "NBI", DHCP_EB_FEATURE_NBI, 1 );
31
+
29 32
 struct image_type nbi_image_type __image_type ( PROBE_NORMAL );
30 33
 
31 34
 /**

+ 3
- 0
src/arch/i386/image/pxe_image.c Näytä tiedosto

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

+ 4
- 4
src/hci/shell_banner.c Näytä tiedosto

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

+ 51
- 32
src/include/gpxe/features.h Näytä tiedosto

@@ -11,6 +11,17 @@
11 11
  *
12 12
  */
13 13
 
14
+/**
15
+ * @defgroup featurecat Feature categories
16
+ * @{
17
+ */
18
+
19
+#define FEATURE_PROTOCOL		01 /**< Network protocols */
20
+#define FEATURE_IMAGE			02 /**< Image formats */
21
+#define FEATURE_MISC			03 /**< Miscellaneous */
22
+
23
+/** @} */
24
+
14 25
 /**
15 26
  * @defgroup dhcpfeatures DHCP feature option tags
16 27
  *
@@ -20,50 +31,58 @@
20 31
  * @{
21 32
  */
22 33
 
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
-/** HTTP */
33
-#define DHCP_EB_FEATURE_HTTP 0x13
34
-
35
-/** HTTPS */
36
-#define DHCP_EB_FEATURE_HTTPS 0x14
34
+#define DHCP_EB_FEATURE_PXE_EXT		0x10 /**< PXE API extensions */
35
+#define DHCP_EB_FEATURE_ISCSI		0x11 /**< iSCSI protocol */
36
+#define DHCP_EB_FEATURE_AOE		0x12 /**< AoE protocol */
37
+#define DHCP_EB_FEATURE_HTTP		0x13 /**< HTTP protocol */
38
+#define DHCP_EB_FEATURE_HTTPS		0x14 /**< HTTPS protocol */
39
+#define DHCP_EB_FEATURE_TFTP		0x15 /**< TFTP protocol */
40
+#define DHCP_EB_FEATURE_FTP		0x16 /**< FTP protocol */
41
+#define DHCP_EB_FEATURE_DNS		0x17 /**< DNS protocol */
42
+#define DHCP_EB_FEATURE_BZIMAGE		0x18 /**< bzImage format */
43
+#define DHCP_EB_FEATURE_MULTIBOOT	0x19 /**< Multiboot format */
44
+#define DHCP_EB_FEATURE_NBI		0x20 /**< NBI format */
45
+#define DHCP_EB_FEATURE_PXE		0x21 /**< PXE format */
37 46
 
38 47
 /** @} */
39 48
 
40 49
 /** Declare a feature code for DHCP */
41
-#define __dhcp_feature __table ( uint8_t, dhcp_features, 01 )
50
+#define __dhcp_feature( category )					    \
51
+	 __table ( uint8_t, dhcp_features, category )
42 52
 
43 53
 /** Construct a DHCP feature table entry */
44
-#define DHCP_FEATURE( feature_opt, version ) \
45
-	_DHCP_FEATURE ( OBJECT, feature_opt, version )
46
-#define _DHCP_FEATURE( _name, feature_opt, version ) \
47
-	__DHCP_FEATURE ( _name, feature_opt, version )
48
-#define __DHCP_FEATURE( _name, feature_opt, version )		\
49
-	uint8_t __dhcp_feature_ ## _name [] __dhcp_feature = {	\
50
-		feature_opt, DHCP_BYTE ( version )		\
54
+#define DHCP_FEATURE( category, feature_opt, version )			    \
55
+	_DHCP_FEATURE ( category, OBJECT, feature_opt, version )
56
+#define _DHCP_FEATURE( category, _name, feature_opt, version )		    \
57
+	__DHCP_FEATURE ( category, _name, feature_opt, version )
58
+#define __DHCP_FEATURE( category, _name, feature_opt, version )		    \
59
+	uint8_t __dhcp_feature_ ## _name [] __dhcp_feature ( category ) = { \
60
+		feature_opt, DHCP_BYTE ( version )			    \
51 61
 	};
52 62
 
63
+/** A named feature */
64
+struct feature {
65
+	/** Feature name */
66
+	char *name;
67
+};
68
+
53 69
 /** Declare a named feature */
54
-#define __feature_name __table ( char *, features, 01 )
70
+#define __feature_name( category )					    \
71
+	__table ( struct feature, features, category )
55 72
 
56 73
 /** Construct a named feature */
57
-#define FEATURE_NAME( text ) \
58
-	_FEATURE_NAME ( OBJECT, text )
59
-#define _FEATURE_NAME( _name, text ) \
60
-	__FEATURE_NAME ( _name, text )
61
-#define __FEATURE_NAME( _name, text )				\
62
-	char * __feature_ ## _name __feature_name = text;
74
+#define FEATURE_NAME( category, text )					    \
75
+	_FEATURE_NAME ( category, OBJECT, text )
76
+#define _FEATURE_NAME( category, _name, text )				    \
77
+	__FEATURE_NAME ( category, _name, text )
78
+#define __FEATURE_NAME( category, _name, text )				    \
79
+	struct feature __feature_ ## _name __feature_name ( category ) = {  \
80
+		.name = text,						    \
81
+	};
63 82
 
64 83
 /** Declare a feature */
65
-#define FEATURE( text, feature_opt, version )			\
66
-	FEATURE_NAME ( text );					\
67
-	DHCP_FEATURE ( feature_opt, version );
84
+#define FEATURE( category, text, feature_opt, version )			    \
85
+	FEATURE_NAME ( category, text );				    \
86
+	DHCP_FEATURE ( category, feature_opt, version );
68 87
 
69 88
 #endif /* _GPXE_FEATURES_H */

+ 1
- 1
src/net/aoe.c Näytä tiedosto

@@ -40,7 +40,7 @@
40 40
  *
41 41
  */
42 42
 
43
-FEATURE ( "AoE", DHCP_EB_FEATURE_AOE, 1 );
43
+FEATURE ( FEATURE_PROTOCOL, "AoE", DHCP_EB_FEATURE_AOE, 1 );
44 44
 
45 45
 struct net_protocol aoe_protocol;
46 46
 

+ 3
- 0
src/net/tcp/ftp.c Näytä tiedosto

@@ -11,6 +11,7 @@
11 11
 #include <gpxe/xfer.h>
12 12
 #include <gpxe/open.h>
13 13
 #include <gpxe/uri.h>
14
+#include <gpxe/features.h>
14 15
 #include <gpxe/ftp.h>
15 16
 
16 17
 /** @file
@@ -19,6 +20,8 @@
19 20
  *
20 21
  */
21 22
 
23
+FEATURE ( FEATURE_PROTOCOL, "FTP", DHCP_EB_FEATURE_FTP, 1 );
24
+
22 25
 /**
23 26
  * FTP states
24 27
  *

+ 1
- 1
src/net/tcp/http.c Näytä tiedosto

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

+ 1
- 1
src/net/tcp/https.c Näytä tiedosto

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

+ 1
- 1
src/net/tcp/iscsi.c Näytä tiedosto

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

+ 3
- 0
src/net/udp/dns.c Näytä tiedosto

@@ -31,6 +31,7 @@
31 31
 #include <gpxe/retry.h>
32 32
 #include <gpxe/tcpip.h>
33 33
 #include <gpxe/dhcp.h>
34
+#include <gpxe/features.h>
34 35
 #include <gpxe/dns.h>
35 36
 
36 37
 /** @file
@@ -39,6 +40,8 @@
39 40
  *
40 41
  */
41 42
 
43
+FEATURE ( FEATURE_PROTOCOL, "DNS", DHCP_EB_FEATURE_DNS, 1 );
44
+
42 45
 /** The DNS server */
43 46
 static struct sockaddr_tcpip nameserver = {
44 47
 	.st_port = htons ( DNS_PORT ),

+ 3
- 0
src/net/udp/tftp.c Näytä tiedosto

@@ -30,6 +30,7 @@
30 30
 #include <gpxe/uri.h>
31 31
 #include <gpxe/tcpip.h>
32 32
 #include <gpxe/retry.h>
33
+#include <gpxe/features.h>
33 34
 #include <gpxe/tftp.h>
34 35
 
35 36
 /** @file
@@ -38,6 +39,8 @@
38 39
  *
39 40
  */
40 41
 
42
+FEATURE ( FEATURE_PROTOCOL, "TFTP", DHCP_EB_FEATURE_TFTP, 1 );
43
+
41 44
 /**
42 45
  * A TFTP request
43 46
  *

Loading…
Peruuta
Tallenna