/* Attempt next child resolver, if possible */
mux->resolver++;
- if ( mux->resolver >= table_end ( struct resolver, RESOLVERS ) ) {
+ if ( mux->resolver >= table_end ( RESOLVERS ) ) {
DBGC ( mux, "RESOLV %p failed to resolve name\n", mux );
goto finished;
}
return -ENOMEM;
resolv_init ( &mux->parent, &null_resolv_ops, &mux->refcnt );
resolv_init ( &mux->child, &resolv_mux_child_ops, &mux->refcnt );
- mux->resolver = table_start ( struct resolver, RESOLVERS );
+ mux->resolver = table_start ( RESOLVERS );
memcpy ( &mux->sa, sa, sizeof ( mux->sa ) );
memcpy ( mux->name, name, name_len );
};
/** Number of registered configuration settings */
-#define NUM_SETTINGS table_num_entries ( struct setting, SETTINGS )
+#define NUM_SETTINGS table_num_entries ( SETTINGS )
static void load_setting ( struct setting_widget *widget ) __nonnull;
static int save_setting ( struct setting_widget *widget ) __nonnull;
static void init_setting_index ( struct setting_widget *widget,
struct settings *settings,
unsigned int index ) {
- struct setting *all_settings =
- table_start ( struct setting, SETTINGS );
+ struct setting *all_settings = table_start ( SETTINGS );
init_setting ( widget, settings, &all_settings[index],
( SETTINGS_LIST_ROW + index ), SETTINGS_LIST_COL );
};
/** Console driver table */
-#define CONSOLES "consoles"
+#define CONSOLES __table ( struct console_driver, "consoles" )
/**
* Mark a <tt> struct console_driver </tt> as being part of the
* @endcode
*
*/
-#define __console_driver __table ( struct console_driver, CONSOLES, 01 )
+#define __console_driver __table_entry ( CONSOLES, 01 )
/* Function prototypes */
};
/** ARP protocol table */
-#define ARP_NET_PROTOCOLS "arp_net_protocols"
+#define ARP_NET_PROTOCOLS \
+ __table ( struct arp_net_protocol, "arp_net_protocols" )
/** Declare an ARP protocol */
-#define __arp_net_protocol \
- __table ( struct arp_net_protocol, ARP_NET_PROTOCOLS, 01 )
+#define __arp_net_protocol __table_entry ( ARP_NET_PROTOCOLS, 01 )
extern struct net_protocol arp_protocol;
int ( * exec ) ( int argc, char **argv );
};
-#define COMMANDS "commands"
+#define COMMANDS __table ( struct command, "commands" )
-#define __command __table ( struct command, COMMANDS, 01 )
+#define __command __table_entry ( COMMANDS, 01 )
#endif /* _GPXE_COMMAND_H */
};
/** Root device table */
-#define ROOT_DEVICES "root_devices"
+#define ROOT_DEVICES __table ( struct root_device, "root_devices" )
/** Declare a root device */
-#define __root_device __table ( struct root_device, ROOT_DEVICES, 01 )
+#define __root_device __table_entry ( ROOT_DEVICES, 01 )
#endif /* _GPXE_DEVICE_H */
};
/** EFI protocol table */
-#define EFI_PROTOCOLS "efi_protocols"
+#define EFI_PROTOCOLS __table ( struct efi_protocol, "efi_protocols" )
/** Declare an EFI protocol used by gPXE */
-#define __efi_protocol \
- __table ( struct efi_protocol, EFI_PROTOCOLS, 01 )
+#define __efi_protocol __table_entry ( EFI_PROTOCOLS, 01 )
/** Declare an EFI protocol to be required by gPXE
*
};
/** EFI configuration table table */
-#define EFI_CONFIG_TABLES "efi_config_tables"
+#define EFI_CONFIG_TABLES \
+ __table ( struct efi_config_table, "efi_config_tables" )
/** Declare an EFI configuration table used by gPXE */
-#define __efi_config_table \
- __table ( struct efi_config_table, EFI_CONFIG_TABLES, 01 )
+#define __efi_config_table __table_entry ( EFI_CONFIG_TABLES, 01 )
/** Declare an EFI configuration table to be used by gPXE
*
};
/** EISA driver table */
-#define EISA_DRIVERS "eisa_drivers"
+#define EISA_DRIVERS __table ( struct eisa_driver, "eisa_drivers" )
/** Declare an EISA driver */
-#define __eisa_driver __table ( struct eisa_driver, EISA_DRIVERS, 01 )
+#define __eisa_driver __table_entry ( EISA_DRIVERS, 01 )
extern void eisa_device_enabled ( struct eisa_device *eisa, int enabled );
const char *text;
};
-#define ERRORTAB "errortab"
+#define ERRORTAB __table ( struct errortab, "errortab" )
-#define __errortab __table ( struct errortab, ERRORTAB, 01 )
+#define __errortab __table_entry ( ERRORTAB, 01 )
#endif /* _GPXE_ERRORTAB_H */
/** @} */
/** DHCP feature table */
-#define DHCP_FEATURES "dhcp_features"
+#define DHCP_FEATURES __table ( uint8_t, "dhcp_features" )
/** Declare a feature code for DHCP */
-#define __dhcp_feature __table ( uint8_t, DHCP_FEATURES, 01 )
+#define __dhcp_feature __table_entry ( DHCP_FEATURES, 01 )
/** Construct a DHCP feature table entry */
#define DHCP_FEATURE( feature_opt, ... ) \
};
/** Named feature table */
-#define FEATURES "features"
+#define FEATURES __table ( struct feature, "features" )
/** Declare a named feature */
-#define __feature_name( category ) \
- __table ( struct feature, FEATURES, category )
+#define __feature_name( category ) __table_entry ( FEATURES, category )
/** Construct a named feature */
#define FEATURE_NAME( category, text ) \
void ( * send ) ( const char *buf, size_t len );
};
-#define GDB_TRANSPORTS "gdb_transports"
+#define GDB_TRANSPORTS __table ( struct gdb_transport, "gdb_transports" )
-#define __gdb_transport __table ( struct gdb_transport, GDB_TRANSPORTS, 01 )
+#define __gdb_transport __table_entry ( GDB_TRANSPORTS, 01 )
/**
* Look up GDB transport by name
#define PROBE_PXE 03
/** Executable or loadable image type table */
-#define IMAGE_TYPES "image_types"
+#define IMAGE_TYPES __table ( struct image_type, "image_types" )
/** An executable or loadable image type */
-#define __image_type( probe_order ) \
- __table ( struct image_type, IMAGE_TYPES, probe_order )
+#define __image_type( probe_order ) __table_entry ( IMAGE_TYPES, probe_order )
extern struct list_head images;
};
/** Initialisation function table */
-#define INIT_FNS "init_fns"
+#define INIT_FNS __table ( struct init_fn, "init_fns" )
/** Declare an initialisation functon */
-#define __init_fn( init_order ) \
- __table ( struct init_fn, INIT_FNS, init_order )
+#define __init_fn( init_order ) __table_entry ( INIT_FNS, init_order )
/** @defgroup initfn_order Initialisation function ordering
* @{
};
/** Startup/shutdown function table */
-#define STARTUP_FNS "startup_fns"
+#define STARTUP_FNS __table ( struct startup_fn, "startup_fns" )
/** Declare a startup/shutdown function */
#define __startup_fn( startup_order ) \
- __table ( struct startup_fn, STARTUP_FNS, startup_order )
+ __table_entry ( STARTUP_FNS, startup_order )
/** @defgroup startfn_order Startup/shutdown function ordering
*
};
/** ISA driver table */
-#define ISA_DRIVERS "isa_drivers"
+#define ISA_DRIVERS __table ( struct isa_driver, "isa_drivers" )
/** Declare an ISA driver */
-#define __isa_driver __table ( struct isa_driver, ISA_DRIVERS, 01 )
+#define __isa_driver __table_entry ( ISA_DRIVERS, 01 )
/**
* Set ISA driver-private data
};
/** ISAPnP driver table */
-#define ISAPNP_DRIVERS "isapnp_drivers"
+#define ISAPNP_DRIVERS __table ( struct isapnp_driver, "isapnp_drivers" )
/** Declare an ISAPnP driver */
-#define __isapnp_driver __table ( struct isapnp_driver, ISAPNP_DRIVERS, 01 )
+#define __isapnp_driver __table_entry ( ISAPNP_DRIVERS, 01 )
extern uint16_t isapnp_read_port;
};
/** MCA driver table */
-#define MCA_DRIVERS "mca_drivers"
+#define MCA_DRIVERS __table ( struct mca_driver, "mca_drivers" )
/** Declare an MCA driver */
-#define __mca_driver __table ( struct mca_driver, MCA_DRIVERS, 01 )
+#define __mca_driver __table_entry ( MCA_DRIVERS, 01 )
/**
* Set MCA driver-private data
#define NETDEV_LINK_UP 0x0002
/** Link-layer protocol table */
-#define LL_PROTOCOLS "ll_protocols"
+#define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
/** Declare a link-layer protocol */
-#define __ll_protocol __table ( struct ll_protocol, LL_PROTOCOLS, 01 )
+#define __ll_protocol __table_entry ( LL_PROTOCOLS, 01 )
/** Network-layer protocol table */
-#define NET_PROTOCOLS "net_protocols"
+#define NET_PROTOCOLS __table ( struct net_protocol, "net_protocols" )
/** Declare a network-layer protocol */
-#define __net_protocol __table ( struct net_protocol, NET_PROTOCOLS, 01 )
+#define __net_protocol __table_entry ( NET_PROTOCOLS, 01 )
extern struct list_head net_devices;
extern struct net_device_operations null_netdev_operations;
};
/** URI opener table */
-#define URI_OPENERS "uri_openers"
+#define URI_OPENERS __table ( struct uri_opener, "uri_openers" )
/** Register a URI opener */
-#define __uri_opener __table ( struct uri_opener, URI_OPENERS, 01 )
+#define __uri_opener __table_entry ( URI_OPENERS, 01 )
/** A socket opener */
struct socket_opener {
};
/** Socket opener table */
-#define SOCKET_OPENERS "socket_openers"
+#define SOCKET_OPENERS __table ( struct socket_opener, "socket_openers" )
/** Register a socket opener */
-#define __socket_opener __table ( struct socket_opener, SOCKET_OPENERS, 01 )
+#define __socket_opener __table_entry ( SOCKET_OPENERS, 01 )
extern int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri );
extern int xfer_open_uri_string ( struct xfer_interface *xfer,
};
/** PCI driver table */
-#define PCI_DRIVERS "pci_drivers"
+#define PCI_DRIVERS __table ( struct pci_driver, "pci_drivers" )
/** Declare a PCI driver */
-#define __pci_driver __table ( struct pci_driver, PCI_DRIVERS, 01 )
+#define __pci_driver __table_entry ( PCI_DRIVERS, 01 )
#define PCI_DEVFN( slot, func ) ( ( (slot) << 3 ) | (func) )
#define PCI_SLOT( devfn ) ( ( (devfn) >> 3 ) & 0x1f )
}
/** Permanent process table */
-#define PERMANENT_PROCESSES "processes"
+#define PERMANENT_PROCESSES __table ( struct process, "processes" )
/**
* Declare a permanent process
* Permanent processes will be automatically added to the process list
* at initialisation time.
*/
-#define __permanent_process \
- __table ( struct process, PERMANENT_PROCESSES, 01 )
+#define __permanent_process __table_entry ( PERMANENT_PROCESSES, 01 )
#endif /* _GPXE_PROCESS_H */
#define RESOLV_NORMAL 02
/** Resolvers table */
-#define RESOLVERS "resolvers"
+#define RESOLVERS __table ( struct resolver, "resolvers" )
/** Register as a name resolver */
-#define __resolver( resolv_order ) \
- __table ( struct resolver, RESOLVERS, resolv_order )
+#define __resolver( resolv_order ) __table_entry ( RESOLVERS, resolv_order )
extern void resolv_done ( struct resolv_interface *resolv,
struct sockaddr *sa, int rc );
int ( * boot ) ( const char *root_path );
};
-#define SANBOOT_PROTOCOLS "sanboot_protocols"
+#define SANBOOT_PROTOCOLS \
+ __table ( struct sanboot_protocol, "sanboot_protocols" )
-#define __sanboot_protocol \
- __table ( struct sanboot_protocol, SANBOOT_PROTOCOLS, 01 )
+#define __sanboot_protocol __table_entry ( SANBOOT_PROTOCOLS, 01 )
#endif /* _GPXE_SANBOOT_H */
};
/** Configuration setting table */
-#define SETTINGS "settings"
+#define SETTINGS __table ( struct setting, "settings" )
/** Declare a configuration setting */
-#define __setting __table ( struct setting, SETTINGS, 01 )
+#define __setting __table_entry ( SETTINGS, 01 )
/** Settings block operations */
struct settings_operations {
};
/** Configuration setting type table */
-#define SETTING_TYPES "setting_types"
+#define SETTING_TYPES __table ( struct setting_type, "setting_types" )
/** Declare a configuration setting type */
-#define __setting_type \
- __table ( struct setting_type, SETTING_TYPES, 01 )
+#define __setting_type __table_entry ( SETTING_TYPES, 01 )
/**
* A settings applicator
};
/** Settings applicator table */
-#define SETTINGS_APPLICATORS "settings_applicators"
+#define SETTINGS_APPLICATORS \
+ __table ( struct settings_applicator, "settings_applicators" )
/** Declare a settings applicator */
-#define __settings_applicator \
- __table ( struct settings_applicator, SETTINGS_APPLICATORS, 01 )
+#define __settings_applicator __table_entry ( SETTINGS_APPLICATORS, 01 )
/**
* A simple settings block
* The linker script takes care of assembling the tables for us. All
* our table sections have names of the format @c .tbl.NAME.NN where
* @c NAME designates the data structure stored in the table (e.g. @c
- * init_fn) and @c NN is a two-digit decimal number used to impose an
+ * init_fns) and @c NN is a two-digit decimal number used to impose an
* ordering upon the tables if required. @c NN=00 is reserved for the
* symbol indicating "table start", and @c NN=99 is reserved for the
* symbol indicating "table end".
* void ( *frob ) ( void ); // The frobnicating function itself
* };
*
- * #define __frobnicator __table ( struct frobnicator, "frobnicators", 01 )
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
+ *
+ * #define __frobnicator __table_entry ( FROBNICATORS, 01 )
*
* @endcode
*
* void frob_all ( void ) {
* struct frob *frob;
*
- * for_each_table ( frob, "frobnicators" ) {
+ * for_each_table ( frob, FROBNICATORS ) {
* printf ( "Calling frobnicator \"%s\"\n", frob->name );
* frob->frob ();
* }
#define __attribute__( x )
#endif
-#define __table_str( x ) #x
-#define __table_section( table, idx ) \
- __section__ ( ".tbl." table "." __table_str ( idx ) )
+/**
+ * Declare a linker table
+ *
+ * @v type Data type
+ * @v name Table name
+ * @ret table Linker table
+ */
+#define __table( type, name ) ( type, name )
-#define __table_section_start( table ) __table_section ( table, 00 )
-#define __table_section_end( table ) __table_section ( table, 99 )
+/**
+ * Get linker table data type
+ *
+ * @v table Linker table
+ * @ret type Data type
+ */
+#define __table_type( table ) __table_extract_type table
+#define __table_extract_type( type, name ) type
-#define __natural_alignment( type ) __aligned__ ( __alignof__ ( type ) )
+/**
+ * Get linker table name
+ *
+ * @v table Linker table
+ * @ret name Table name
+ */
+#define __table_name( table ) __table_extract_name table
+#define __table_extract_name( type, name ) name
/**
- * Linker table entry.
+ * Get linker table section name
*
- * Declares a data structure to be part of a linker table. Use as
- * e.g.
+ * @v table Linker table
+ * @v idx Sub-table index
+ * @ret section Section name
+ */
+#define __table_section( table, idx ) \
+ ".tbl." __table_name ( table ) "." __table_str ( idx )
+#define __table_str( x ) #x
+
+/**
+ * Get linker table alignment
+ *
+ * @v table Linker table
+ * @ret align Alignment
+ */
+#define __table_alignment( table ) __alignof__ ( __table_type ( table ) )
+
+/**
+ * Declare a linker table entry
+ *
+ * @v table Linker table
+ * @v idx Sub-table index
+ *
+ * Example usage:
*
* @code
*
- * #define __frobnicator __table ( struct frobnicator, "frobnicators", 01 )
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
+ *
+ * #define __frobnicator __table_entry ( FROBNICATORS, 01 )
*
* struct frobnicator my_frob __frobnicator = {
* ...
* };
*
* @endcode
- *
*/
-#define __table( type, table, idx ) \
- __attribute__ (( __table_section ( table, idx ), \
- __natural_alignment ( type ) ))
+#define __table_entry( table, idx ) \
+ __attribute__ (( __section__ ( __table_section ( table, idx ) ) \
+ __aligned__ ( __table_alignment ( table ) ) ))
/**
- * Start of linker table.
+ * Get start of linker table
+ *
+ * @v table Linker table
+ * @ret start Start of linker table
*
- * Return the start of a linker table. Use as e.g.
+ * Example usage:
*
* @code
*
- * struct frobnicator *frobs =
- * table_start ( struct frobnicator, "frobnicators" );
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
*
- * @endcode
+ * struct frobnicator *frobs = table_start ( FROBNICATORS );
*
+ * @endcode
*/
-#define table_start( type, table ) ( { \
- static type __table_start[0] __table ( type, table, 00 ); \
+#define table_start( table ) ( { \
+ static __table_type ( table ) __table_start[0] \
+ __table_entry ( table, 00 ); \
__table_start; } )
/**
- * End of linker table.
+ * Get end of linker table
*
- * Return the end of a linker table. Use as e.g.
+ * @v table Linker table
+ * @ret end End of linker table
+ *
+ * Example usage:
*
* @code
*
- * struct frobnicator *frobs_end =
- * table_end ( struct frobnicator, "frobnicators" );
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
*
- * @endcode
+ * struct frobnicator *frobs_end = table_end ( FROBNICATORS );
*
+ * @endcode
*/
-#define table_end( type, table ) ( { \
- static type __table_end[0] __table ( type, table, 99 ); \
+#define table_end( table ) ( { \
+ static __table_type ( table ) __table_end[0] \
+ __table_entry ( table, 99 ); \
__table_end; } )
/**
- * Calculate number of entries in linker table.
+ * Get number of entries in linker table
*
- * Return the number of entries within a linker table. Use as e.g.
+ * @v table Linker table
+ * @ret num_entries Number of entries in linker table
+ *
+ * Example usage:
*
* @code
*
- * unsigned int num_frobs =
- * table_num_entries ( struct frobnicator, "frobnicators" );
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
+ *
+ * unsigned int num_frobs = table_num_entries ( FROBNICATORS );
*
* @endcode
*
*/
-#define table_num_entries( type, table ) \
- ( ( unsigned int ) ( table_end ( type, table ) - \
- table_start ( type, table ) ) )
+#define table_num_entries( table ) \
+ ( ( unsigned int ) ( table_end ( table ) - \
+ table_start ( table ) ) )
/**
- * Iterate through all entries within a linker table.
+ * Iterate through all entries within a linker table
*
- * Use as e.g.
+ * @v pointer Entry pointer
+ * @v table Linker table
+ *
+ * Example usage:
*
* @code
*
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
+ *
* struct frobnicator *frob;
*
- * for_each_table_entry ( frob, "frobnicators" ) {
+ * for_each_table_entry ( frob, FROBNICATORS ) {
* ...
* }
*
*
*/
#define for_each_table_entry( pointer, table ) \
- for ( pointer = table_start ( typeof ( * pointer ), table ) ; \
- pointer < table_end ( typeof ( * pointer ), table ) ; \
+ for ( pointer = table_start ( table ) ; \
+ pointer < table_end ( table ) ; \
pointer++ )
/**
- * Iterate through all entries within a linker table in reverse order.
+ * Iterate through all entries within a linker table in reverse order
*
- * Use as e.g.
+ * @v pointer Entry pointer
+ * @v table Linker table
+ *
+ * Example usage:
*
* @code
*
+ * #define FROBNICATORS __table ( struct frobnicator, "frobnicators" )
+ *
* struct frobnicator *frob;
*
- * for_each_table_entry_reverse ( frob, "frobnicators" ) {
+ * for_each_table_entry_reverse ( frob, FROBNICATORS ) {
* ...
* }
*
*
*/
#define for_each_table_entry_reverse( pointer, table ) \
- for ( pointer = table_end ( typeof ( * pointer ), table ) - 1 ; \
- pointer >= table_start ( typeof ( * pointer ), table ) ; \
+ for ( pointer = ( table_end ( table ) - 1 ) ; \
+ pointer >= table_start ( table ) ; \
pointer-- )
#endif /* _GPXE_TABLES_H */
};
/** TCP/IP transport-layer protocol table */
-#define TCPIP_PROTOCOLS "tcpip_protocols"
+#define TCPIP_PROTOCOLS __table ( struct tcpip_protocol, "tcpip_protocols" )
/** Declare a TCP/IP transport-layer protocol */
-#define __tcpip_protocol \
- __table ( struct tcpip_protocol, TCPIP_PROTOCOLS, 01 )
+#define __tcpip_protocol __table_entry ( TCPIP_PROTOCOLS, 01 )
/** TCP/IP network-layer protocol table */
-#define TCPIP_NET_PROTOCOLS "tcpip_net_protocols"
+#define TCPIP_NET_PROTOCOLS \
+ __table ( struct tcpip_net_protocol, "tcpip_net_protocols" )
/** Declare a TCP/IP network-layer protocol */
-#define __tcpip_net_protocol \
- __table ( struct tcpip_net_protocol, TCPIP_NET_PROTOCOLS, 01 )
+#define __tcpip_net_protocol __table_entry ( TCPIP_NET_PROTOCOLS, 01 )
extern int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto,
struct sockaddr_tcpip *st_src,
dhcppkt->dhcphdr->ciaddr = ciaddr;
/* Add options to identify the feature list */
- dhcp_features = table_start ( uint8_t, DHCP_FEATURES );
- dhcp_features_len = table_num_entries ( uint8_t, DHCP_FEATURES );
+ dhcp_features = table_start ( DHCP_FEATURES );
+ dhcp_features_len = table_num_entries ( DHCP_FEATURES );
if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_EB_ENCAP, dhcp_features,
dhcp_features_len ) ) != 0 ) {
DBG ( "DHCP could not set features list option: %s\n",