summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/console.h5
-rw-r--r--src/include/gpxe/arp.h5
-rw-r--r--src/include/gpxe/command.h4
-rw-r--r--src/include/gpxe/device.h5
-rw-r--r--src/include/gpxe/efi/efi.h10
-rw-r--r--src/include/gpxe/eisa.h5
-rw-r--r--src/include/gpxe/errortab.h4
-rw-r--r--src/include/gpxe/features.h10
-rw-r--r--src/include/gpxe/gdbstub.h4
-rw-r--r--src/include/gpxe/image.h5
-rw-r--r--src/include/gpxe/init.h10
-rw-r--r--src/include/gpxe/isa.h5
-rw-r--r--src/include/gpxe/isapnp.h5
-rw-r--r--src/include/gpxe/mca.h5
-rw-r--r--src/include/gpxe/netdevice.h10
-rw-r--r--src/include/gpxe/open.h10
-rw-r--r--src/include/gpxe/pci.h5
-rw-r--r--src/include/gpxe/process.h5
-rw-r--r--src/include/gpxe/resolv.h5
-rw-r--r--src/include/gpxe/sanboot.h4
-rw-r--r--src/include/gpxe/settings.h15
-rw-r--r--src/include/gpxe/tables.h100
-rw-r--r--src/include/gpxe/tcpip.h10
23 files changed, 197 insertions, 49 deletions
diff --git a/src/include/console.h b/src/include/console.h
index 9addd5265..fd36cd5b8 100644
--- a/src/include/console.h
+++ b/src/include/console.h
@@ -85,6 +85,9 @@ struct console_driver {
int ( *iskey ) ( void );
};
+/** Console driver table */
+#define CONSOLES "consoles"
+
/**
* Mark a <tt> struct console_driver </tt> as being part of the
* console drivers table.
@@ -102,7 +105,7 @@ struct console_driver {
* @endcode
*
*/
-#define __console_driver __table ( struct console_driver, console, 01 )
+#define __console_driver __table ( struct console_driver, CONSOLES, 01 )
/* Function prototypes */
diff --git a/src/include/gpxe/arp.h b/src/include/gpxe/arp.h
index 6464ce0c5..5bdd1d56a 100644
--- a/src/include/gpxe/arp.h
+++ b/src/include/gpxe/arp.h
@@ -26,9 +26,12 @@ struct arp_net_protocol {
const void *net_addr );
};
+/** ARP protocol table */
+#define ARP_NET_PROTOCOLS "arp_net_protocols"
+
/** Declare an ARP protocol */
#define __arp_net_protocol \
- __table ( struct arp_net_protocol, arp_net_protocols, 01 )
+ __table ( struct arp_net_protocol, ARP_NET_PROTOCOLS, 01 )
extern struct net_protocol arp_protocol;
diff --git a/src/include/gpxe/command.h b/src/include/gpxe/command.h
index 5d8057ab5..ee270dfdd 100644
--- a/src/include/gpxe/command.h
+++ b/src/include/gpxe/command.h
@@ -17,6 +17,8 @@ struct command {
int ( * exec ) ( int argc, char **argv );
};
-#define __command __table ( struct command, commands, 01 )
+#define COMMANDS "commands"
+
+#define __command __table ( struct command, COMMANDS, 01 )
#endif /* _GPXE_COMMAND_H */
diff --git a/src/include/gpxe/device.h b/src/include/gpxe/device.h
index f40cc95a2..bcc848aad 100644
--- a/src/include/gpxe/device.h
+++ b/src/include/gpxe/device.h
@@ -102,7 +102,10 @@ struct root_driver {
void ( * remove ) ( struct root_device *rootdev );
};
+/** Root device table */
+#define ROOT_DEVICES "root_devices"
+
/** Declare a root device */
-#define __root_device __table ( struct root_device, root_devices, 01 )
+#define __root_device __table ( struct root_device, ROOT_DEVICES, 01 )
#endif /* _GPXE_DEVICE_H */
diff --git a/src/include/gpxe/efi/efi.h b/src/include/gpxe/efi/efi.h
index c7f63b6c7..c44e09cb1 100644
--- a/src/include/gpxe/efi/efi.h
+++ b/src/include/gpxe/efi/efi.h
@@ -54,9 +54,12 @@ struct efi_protocol {
void **protocol;
};
+/** EFI protocol table */
+#define EFI_PROTOCOLS "efi_protocols"
+
/** Declare an EFI protocol used by gPXE */
#define __efi_protocol \
- __table ( struct efi_protocol, efi_protocols, 01 )
+ __table ( struct efi_protocol, EFI_PROTOCOLS, 01 )
/** Declare an EFI protocol to be required by gPXE
*
@@ -86,9 +89,12 @@ struct efi_config_table {
int required;
};
+/** EFI configuration table table */
+#define EFI_CONFIG_TABLES "efi_config_tables"
+
/** Declare an EFI configuration table used by gPXE */
#define __efi_config_table \
- __table ( struct efi_config_table, efi_config_tables, 01 )
+ __table ( struct efi_config_table, EFI_CONFIG_TABLES, 01 )
/** Declare an EFI configuration table to be used by gPXE
*
diff --git a/src/include/gpxe/eisa.h b/src/include/gpxe/eisa.h
index e9d890e16..1f3a9caa1 100644
--- a/src/include/gpxe/eisa.h
+++ b/src/include/gpxe/eisa.h
@@ -79,8 +79,11 @@ struct eisa_driver {
void ( * remove ) ( struct eisa_device *eisa );
};
+/** EISA driver table */
+#define EISA_DRIVERS "eisa_drivers"
+
/** Declare an EISA driver */
-#define __eisa_driver __table ( struct eisa_driver, eisa_drivers, 01 )
+#define __eisa_driver __table ( struct eisa_driver, EISA_DRIVERS, 01 )
extern void eisa_device_enabled ( struct eisa_device *eisa, int enabled );
diff --git a/src/include/gpxe/errortab.h b/src/include/gpxe/errortab.h
index e9a56768f..8e746f029 100644
--- a/src/include/gpxe/errortab.h
+++ b/src/include/gpxe/errortab.h
@@ -14,6 +14,8 @@ struct errortab {
const char *text;
};
-#define __errortab __table ( struct errortab, errortab, 01 )
+#define ERRORTAB "errortab"
+
+#define __errortab __table ( struct errortab, ERRORTAB, 01 )
#endif /* _GPXE_ERRORTAB_H */
diff --git a/src/include/gpxe/features.h b/src/include/gpxe/features.h
index 32c316947..e979ee7ca 100644
--- a/src/include/gpxe/features.h
+++ b/src/include/gpxe/features.h
@@ -50,8 +50,11 @@
/** @} */
+/** DHCP feature table */
+#define DHCP_FEATURES "dhcp_features"
+
/** Declare a feature code for DHCP */
-#define __dhcp_feature __table ( uint8_t, dhcp_features, 01 )
+#define __dhcp_feature __table ( uint8_t, DHCP_FEATURES, 01 )
/** Construct a DHCP feature table entry */
#define DHCP_FEATURE( feature_opt, ... ) \
@@ -69,9 +72,12 @@ struct feature {
char *name;
};
+/** Named feature table */
+#define FEATURES "features"
+
/** Declare a named feature */
#define __feature_name( category ) \
- __table ( struct feature, features, category )
+ __table ( struct feature, FEATURES, category )
/** Construct a named feature */
#define FEATURE_NAME( category, text ) \
diff --git a/src/include/gpxe/gdbstub.h b/src/include/gpxe/gdbstub.h
index bf5d24d23..624b15f7a 100644
--- a/src/include/gpxe/gdbstub.h
+++ b/src/include/gpxe/gdbstub.h
@@ -45,7 +45,9 @@ struct gdb_transport {
void ( * send ) ( const char *buf, size_t len );
};
-#define __gdb_transport __table ( struct gdb_transport, gdb_transports, 01 )
+#define GDB_TRANSPORTS "gdb_transports"
+
+#define __gdb_transport __table ( struct gdb_transport, GDB_TRANSPORTS, 01 )
/**
* Look up GDB transport by name
diff --git a/src/include/gpxe/image.h b/src/include/gpxe/image.h
index b953e1509..cb3bb361b 100644
--- a/src/include/gpxe/image.h
+++ b/src/include/gpxe/image.h
@@ -123,9 +123,12 @@ struct image_type {
*/
#define PROBE_PXE 03
+/** Executable or loadable image type table */
+#define IMAGE_TYPES "image_types"
+
/** An executable or loadable image type */
#define __image_type( probe_order ) \
- __table ( struct image_type, image_types, probe_order )
+ __table ( struct image_type, IMAGE_TYPES, probe_order )
extern struct list_head images;
diff --git a/src/include/gpxe/init.h b/src/include/gpxe/init.h
index e0e9f9c84..9ce56d77f 100644
--- a/src/include/gpxe/init.h
+++ b/src/include/gpxe/init.h
@@ -13,9 +13,12 @@ struct init_fn {
void ( * initialise ) ( void );
};
+/** Initialisation function table */
+#define INIT_FNS "init_fns"
+
/** Declare an initialisation functon */
#define __init_fn( init_order ) \
- __table ( struct init_fn, init_fns, init_order )
+ __table ( struct init_fn, INIT_FNS, init_order )
/** @defgroup initfn_order Initialisation function ordering
* @{
@@ -49,9 +52,12 @@ struct startup_fn {
void ( * shutdown ) ( int flags );
};
+/** Startup/shutdown function table */
+#define STARTUP_FNS "startup_fns"
+
/** Declare a startup/shutdown function */
#define __startup_fn( startup_order ) \
- __table ( struct startup_fn, startup_fns, startup_order )
+ __table ( struct startup_fn, STARTUP_FNS, startup_order )
/** @defgroup startfn_order Startup/shutdown function ordering
*
diff --git a/src/include/gpxe/isa.h b/src/include/gpxe/isa.h
index bb25dbce0..947cb986f 100644
--- a/src/include/gpxe/isa.h
+++ b/src/include/gpxe/isa.h
@@ -58,8 +58,11 @@ struct isa_driver {
void ( * remove ) ( struct isa_device *isa );
};
+/** ISA driver table */
+#define ISA_DRIVERS "isa_drivers"
+
/** Declare an ISA driver */
-#define __isa_driver __table ( struct isa_driver, isa_drivers, 01 )
+#define __isa_driver __table ( struct isa_driver, ISA_DRIVERS, 01 )
/**
* Set ISA driver-private data
diff --git a/src/include/gpxe/isapnp.h b/src/include/gpxe/isapnp.h
index 07797a993..4a7c78175 100644
--- a/src/include/gpxe/isapnp.h
+++ b/src/include/gpxe/isapnp.h
@@ -223,8 +223,11 @@ struct isapnp_driver {
void ( * remove ) ( struct isapnp_device *isapnp );
};
+/** ISAPnP driver table */
+#define ISAPNP_DRIVERS "isapnp_drivers"
+
/** Declare an ISAPnP driver */
-#define __isapnp_driver __table ( struct isapnp_driver, isapnp_drivers, 01 )
+#define __isapnp_driver __table ( struct isapnp_driver, ISAPNP_DRIVERS, 01 )
extern uint16_t isapnp_read_port;
diff --git a/src/include/gpxe/mca.h b/src/include/gpxe/mca.h
index 21f9e74d7..d1f38c8ed 100644
--- a/src/include/gpxe/mca.h
+++ b/src/include/gpxe/mca.h
@@ -77,8 +77,11 @@ struct mca_driver {
void ( * remove ) ( struct mca_device *mca );
};
+/** MCA driver table */
+#define MCA_DRIVERS "mca_drivers"
+
/** Declare an MCA driver */
-#define __mca_driver __table ( struct mca_driver, mca_drivers, 01 )
+#define __mca_driver __table ( struct mca_driver, MCA_DRIVERS, 01 )
/**
* Set MCA driver-private data
diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h
index f1585de07..9d1c9d07c 100644
--- a/src/include/gpxe/netdevice.h
+++ b/src/include/gpxe/netdevice.h
@@ -279,11 +279,17 @@ struct net_device {
/** Network device has link */
#define NETDEV_LINK_UP 0x0002
+/** Link-layer protocol table */
+#define LL_PROTOCOLS "ll_protocols"
+
/** Declare a link-layer protocol */
-#define __ll_protocol __table ( struct ll_protocol, ll_protocols, 01 )
+#define __ll_protocol __table ( struct ll_protocol, LL_PROTOCOLS, 01 )
+
+/** Network-layer protocol table */
+#define NET_PROTOCOLS "net_protocols"
/** Declare a network-layer protocol */
-#define __net_protocol __table ( struct net_protocol, net_protocols, 01 )
+#define __net_protocol __table ( struct net_protocol, NET_PROTOCOLS, 01 )
extern struct list_head net_devices;
extern struct net_device_operations null_netdev_operations;
diff --git a/src/include/gpxe/open.h b/src/include/gpxe/open.h
index 81d5fc246..69a8b3f44 100644
--- a/src/include/gpxe/open.h
+++ b/src/include/gpxe/open.h
@@ -58,8 +58,11 @@ struct uri_opener {
int ( * open ) ( struct xfer_interface *xfer, struct uri *uri );
};
+/** URI opener table */
+#define URI_OPENERS "uri_openers"
+
/** Register a URI opener */
-#define __uri_opener __table ( struct uri_opener, uri_openers, 01 )
+#define __uri_opener __table ( struct uri_opener, URI_OPENERS, 01 )
/** A socket opener */
struct socket_opener {
@@ -78,8 +81,11 @@ struct socket_opener {
struct sockaddr *local );
};
+/** Socket opener table */
+#define SOCKET_OPENERS "socket_openers"
+
/** Register a socket opener */
-#define __socket_opener __table ( struct socket_opener, socket_openers, 01 )
+#define __socket_opener __table ( struct socket_opener, 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,
diff --git a/src/include/gpxe/pci.h b/src/include/gpxe/pci.h
index 1ccdb100b..86bd8f79e 100644
--- a/src/include/gpxe/pci.h
+++ b/src/include/gpxe/pci.h
@@ -308,8 +308,11 @@ struct pci_driver {
void ( * remove ) ( struct pci_device *pci );
};
+/** PCI driver table */
+#define PCI_DRIVERS "pci_drivers"
+
/** Declare a PCI driver */
-#define __pci_driver __table ( struct pci_driver, pci_drivers, 01 )
+#define __pci_driver __table ( struct pci_driver, PCI_DRIVERS, 01 )
#define PCI_DEVFN( slot, func ) ( ( (slot) << 3 ) | (func) )
#define PCI_SLOT( devfn ) ( ( (devfn) >> 3 ) & 0x1f )
diff --git a/src/include/gpxe/process.h b/src/include/gpxe/process.h
index 8d9b109a5..705c9f676 100644
--- a/src/include/gpxe/process.h
+++ b/src/include/gpxe/process.h
@@ -63,6 +63,9 @@ process_init ( struct process *process,
process_add ( process );
}
+/** Permanent process table */
+#define PERMANENT_PROCESSES "processes"
+
/**
* Declare a permanent process
*
@@ -70,6 +73,6 @@ process_init ( struct process *process,
* at initialisation time.
*/
#define __permanent_process \
- __table ( struct process, processes, 01 )
+ __table ( struct process, PERMANENT_PROCESSES, 01 )
#endif /* _GPXE_PROCESS_H */
diff --git a/src/include/gpxe/resolv.h b/src/include/gpxe/resolv.h
index e73c82011..d276522e5 100644
--- a/src/include/gpxe/resolv.h
+++ b/src/include/gpxe/resolv.h
@@ -149,9 +149,12 @@ struct resolver {
/** Normal resolver priority */
#define RESOLV_NORMAL 02
+/** Resolvers table */
+#define RESOLVERS "resolvers"
+
/** Register as a name resolver */
#define __resolver( resolv_order ) \
- __table ( struct resolver, resolvers, resolv_order )
+ __table ( struct resolver, RESOLVERS, resolv_order )
extern void resolv_done ( struct resolv_interface *resolv,
struct sockaddr *sa, int rc );
diff --git a/src/include/gpxe/sanboot.h b/src/include/gpxe/sanboot.h
index ea26a3562..68fd0b9be 100644
--- a/src/include/gpxe/sanboot.h
+++ b/src/include/gpxe/sanboot.h
@@ -8,7 +8,9 @@ struct sanboot_protocol {
int ( * boot ) ( const char *root_path );
};
+#define SANBOOT_PROTOCOLS "sanboot_protocols"
+
#define __sanboot_protocol \
- __table ( struct sanboot_protocol, sanboot_protocols, 01 )
+ __table ( struct sanboot_protocol, SANBOOT_PROTOCOLS, 01 )
#endif /* _GPXE_SANBOOT_H */
diff --git a/src/include/gpxe/settings.h b/src/include/gpxe/settings.h
index fe9c8082c..4f7f98efa 100644
--- a/src/include/gpxe/settings.h
+++ b/src/include/gpxe/settings.h
@@ -36,8 +36,11 @@ struct setting {
unsigned int tag;
};
+/** Configuration setting table */
+#define SETTINGS "settings"
+
/** Declare a configuration setting */
-#define __setting __table ( struct setting, settings, 01 )
+#define __setting __table ( struct setting, SETTINGS, 01 )
/** Settings block operations */
struct settings_operations {
@@ -123,9 +126,12 @@ struct setting_type {
char *buf, size_t len );
};
+/** Configuration setting type table */
+#define SETTING_TYPES "setting_types"
+
/** Declare a configuration setting type */
#define __setting_type \
- __table ( struct setting_type, setting_types, 01 )
+ __table ( struct setting_type, SETTING_TYPES, 01 )
/**
* A settings applicator
@@ -139,9 +145,12 @@ struct settings_applicator {
int ( * apply ) ( void );
};
+/** Settings applicator table */
+#define SETTINGS_APPLICATORS "settings_applicators"
+
/** Declare a settings applicator */
#define __settings_applicator \
- __table ( struct settings_applicator, settings_applicators, 01 )
+ __table ( struct settings_applicator, SETTINGS_APPLICATORS, 01 )
/**
* A simple settings block
diff --git a/src/include/gpxe/tables.h b/src/include/gpxe/tables.h
index b2c56ab67..5d4a43c54 100644
--- a/src/include/gpxe/tables.h
+++ b/src/include/gpxe/tables.h
@@ -115,7 +115,7 @@
* void ( *frob ) ( void ); // The frobnicating function itself
* };
*
- * #define __frobnicator __table ( frobnicators, 01 )
+ * #define __frobnicator __table ( struct frobnicator, "frobnicators", 01 )
*
* @endcode
*
@@ -145,14 +145,11 @@
*
* #include "frob.h"
*
- * static struct frob frob_start[0] __table_start ( frobnicators );
- * static struct frob frob_end[0] __table_end ( frobnicators );
- *
* // Call all linked-in frobnicators
* void frob_all ( void ) {
* struct frob *frob;
*
- * for ( frob = frob_start ; frob < frob_end ; frob++ ) {
+ * for_each_table ( frob, "frobnicators" ) {
* printf ( "Calling frobnicator \"%s\"\n", frob->name );
* frob->frob ();
* }
@@ -170,7 +167,7 @@
#define __table_str( x ) #x
#define __table_section( table, idx ) \
- __section__ ( ".tbl." __table_str ( table ) "." __table_str ( idx ) )
+ __section__ ( ".tbl." table "." __table_str ( idx ) )
#define __table_section_start( table ) __table_section ( table, 00 )
#define __table_section_end( table ) __table_section ( table, 99 )
@@ -185,45 +182,110 @@
*
* @code
*
- * struct my_foo __table ( foo, 01 ) = {
+ * #define __frobnicator __table ( struct frobnicator, "frobnicators", 01 )
+ *
+ * struct frobnicator my_frob __frobnicator = {
* ...
* };
*
* @endcode
*
*/
-#define __table( type, table, idx ) \
- __attribute__ (( __table_section ( table, idx ), \
+#define __table( type, table, idx ) \
+ __attribute__ (( __table_section ( table, idx ), \
__natural_alignment ( type ) ))
/**
- * Linker table start marker.
+ * Start of linker table.
+ *
+ * Return the start of a linker table. Use as e.g.
+ *
+ * @code
+ *
+ * struct frobnicator *frobs =
+ * table_start ( struct frobnicator, "frobnicators" );
+ *
+ * @endcode
+ *
+ */
+#define table_start( type, table ) ( { \
+ static type __table_start[0] __table ( type, table, 00 ); \
+ __table_start; } )
+
+/**
+ * End of linker table.
+ *
+ * Return the end of a linker table. Use as e.g.
+ *
+ * @code
+ *
+ * struct frobnicator *frobs_end =
+ * table_end ( struct frobnicator, "frobnicators" );
+ *
+ * @endcode
+ *
+ */
+#define table_end( type, table ) ( { \
+ static type __table_end[0] __table ( type, table, 99 ); \
+ __table_end; } )
+
+/**
+ * Calculate number of entries in linker table.
+ *
+ * Return the number of entries within a linker table. Use as e.g.
+ *
+ * @code
+ *
+ * unsigned int num_frobs =
+ * table_num_entries ( struct frobnicator, "frobnicators" );
+ *
+ * @endcode
+ *
+ */
+#define table_num_entries( type, table ) \
+ ( ( unsigned int ) ( table_end ( type, table ) - \
+ table_start ( type, table ) ) )
+
+/**
+ * Iterate through all entries within a linker table.
*
- * Declares a data structure (usually an empty data structure) to be
- * the start of a linker table. Use as e.g.
+ * Use as e.g.
*
* @code
*
- * static struct foo_start[0] __table_start ( foo );
+ * struct frobnicator *frob;
+ *
+ * for_each_table_entry ( frob, "frobnicators" ) {
+ * ...
+ * }
*
* @endcode
*
*/
-#define __table_start( type, table ) __table ( type, table, 00 )
+#define for_each_table_entry( pointer, table ) \
+ for ( pointer = table_start ( typeof ( * pointer ), table ) ; \
+ pointer < table_end ( typeof ( * pointer ), table ) ; \
+ pointer++ )
/**
- * Linker table end marker.
+ * Iterate through all entries within a linker table in reverse order.
*
- * Declares a data structure (usually an empty data structure) to be
- * the end of a linker table. Use as e.g.
+ * Use as e.g.
*
* @code
*
- * static struct foo_end[0] __table_end ( foo );
+ * struct frobnicator *frob;
+ *
+ * for_each_table_entry_reverse ( frob, "frobnicators" ) {
+ * ...
+ * }
*
* @endcode
*
*/
-#define __table_end( type, table ) __table ( type, table, 99 )
+#define for_each_table_entry_reverse( pointer, table ) \
+ for ( pointer = table_end ( typeof ( * pointer ), table ) - 1 ; \
+ pointer >= table_start ( typeof ( * pointer ), table ) ; \
+ pointer-- )
#endif /* _GPXE_TABLES_H */
diff --git a/src/include/gpxe/tcpip.h b/src/include/gpxe/tcpip.h
index da89530e6..5200b5ed5 100644
--- a/src/include/gpxe/tcpip.h
+++ b/src/include/gpxe/tcpip.h
@@ -98,13 +98,19 @@ struct tcpip_net_protocol {
uint16_t *trans_csum );
};
+/** TCP/IP transport-layer protocol table */
+#define TCPIP_PROTOCOLS "tcpip_protocols"
+
/** Declare a TCP/IP transport-layer protocol */
#define __tcpip_protocol \
- __table ( struct tcpip_protocol, tcpip_protocols, 01 )
+ __table ( struct tcpip_protocol, TCPIP_PROTOCOLS, 01 )
+
+/** TCP/IP network-layer protocol table */
+#define TCPIP_NET_PROTOCOLS "tcpip_net_protocols"
/** Declare a TCP/IP network-layer protocol */
#define __tcpip_net_protocol \
- __table ( struct tcpip_net_protocol, tcpip_net_protocols, 01 )
+ __table ( struct tcpip_net_protocol, TCPIP_NET_PROTOCOLS, 01 )
extern int tcpip_rx ( struct io_buffer *iobuf, uint8_t tcpip_proto,
struct sockaddr_tcpip *st_src,