e979ee7ca8e57c59fce1440c79c35550b4853bb7
[people/sha0/gpxe.git] / src / include / gpxe / features.h
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 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
25 /**
26  * @defgroup dhcpfeatures DHCP feature option tags
27  *
28  * DHCP feature option tags are Etherboot encapsulated options in the
29  * range 0x10-0x7f.
30  *
31  * @{
32  */
33
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_SLAM            0x1a /**< SLAM protocol */
45 #define DHCP_EB_FEATURE_NBI             0x20 /**< NBI format */
46 #define DHCP_EB_FEATURE_PXE             0x21 /**< PXE format */
47 #define DHCP_EB_FEATURE_ELF             0x22 /**< ELF format */
48 #define DHCP_EB_FEATURE_COMBOOT         0x23 /**< COMBOOT format */
49 #define DHCP_EB_FEATURE_EFI             0x24 /**< EFI format */
50
51 /** @} */
52
53 /** DHCP feature table */
54 #define DHCP_FEATURES "dhcp_features"
55
56 /** Declare a feature code for DHCP */
57 #define __dhcp_feature __table ( uint8_t, DHCP_FEATURES, 01 )
58
59 /** Construct a DHCP feature table entry */
60 #define DHCP_FEATURE( feature_opt, ... )                                    \
61         _DHCP_FEATURE ( OBJECT, feature_opt, __VA_ARGS__ )
62 #define _DHCP_FEATURE( _name, feature_opt, ... )                            \
63         __DHCP_FEATURE ( _name, feature_opt, __VA_ARGS__ )
64 #define __DHCP_FEATURE( _name, feature_opt, ... )                           \
65         uint8_t __dhcp_feature_ ## _name [] __dhcp_feature = {              \
66                 feature_opt, DHCP_OPTION ( __VA_ARGS__ )                    \
67         };
68
69 /** A named feature */
70 struct feature {
71         /** Feature name */
72         char *name;
73 };
74
75 /** Named feature table */
76 #define FEATURES "features"
77
78 /** Declare a named feature */
79 #define __feature_name( category )                                          \
80         __table ( struct feature, FEATURES, category )
81
82 /** Construct a named feature */
83 #define FEATURE_NAME( category, text )                                      \
84         _FEATURE_NAME ( category, OBJECT, text )
85 #define _FEATURE_NAME( category, _name, text )                              \
86         __FEATURE_NAME ( category, _name, text )
87 #define __FEATURE_NAME( category, _name, text )                             \
88         struct feature __feature_ ## _name __feature_name ( category ) = {  \
89                 .name = text,                                               \
90         };
91
92 /** Declare a feature */
93 #define FEATURE( category, text, feature_opt, version )                     \
94         FEATURE_NAME ( category, text );                                    \
95         DHCP_FEATURE ( feature_opt, version );
96
97 /** Declare the version number feature */
98 #define FEATURE_VERSION( ... )                                              \
99         DHCP_FEATURE ( DHCP_ENCAPSULATED ( DHCP_EB_VERSION ), __VA_ARGS__ )
100
101 #endif /* _GPXE_FEATURES_H */