Add "name" field to struct device to allow human-readable hardware device

names.

Add "dev" pointer in struct net_device to tie network interfaces back to a
hardware device.

Force natural alignment of data types in __table() macros.  This seems to
prevent gcc from taking the unilateral decision to occasionally increase
their alignment (which screws up the table packing).
This commit is contained in:
Michael Brown
2007-01-10 04:22:09 +00:00
parent cc9b32c405
commit dad5274522
51 changed files with 184 additions and 135 deletions

View File

@@ -27,7 +27,8 @@ struct arp_net_protocol {
};
/** Declare an ARP protocol */
#define __arp_net_protocol __table ( arp_net_protocols, 01 )
#define __arp_net_protocol \
__table ( struct arp_net_protocol, arp_net_protocols, 01 )
extern int arp_resolve ( struct net_device *netdev,
struct net_protocol *net_protocol,

View File

@@ -17,6 +17,6 @@ struct command {
int ( * exec ) ( int argc, char **argv );
};
#define __command __table ( commands, 01 )
#define __command __table ( struct command, commands, 01 )
#endif /* _GPXE_COMMAND_H */

View File

@@ -13,6 +13,8 @@
/** A hardware device */
struct device {
/** Name */
char name[16];
/** Devices on the same bus */
struct list_head siblings;
/** Devices attached to this device */
@@ -28,8 +30,6 @@ struct device {
*
*/
struct root_device {
/** Name */
const char *name;
/** Device chain
*
* A root device has a NULL parent field.
@@ -62,7 +62,7 @@ struct root_driver {
};
/** Declare a root device */
#define __root_device __table ( root_devices, 01 )
#define __root_device __table ( struct root_device, root_devices, 01 )
extern int probe_devices ( void );
extern void remove_devices ( void );

View File

@@ -15,6 +15,6 @@ struct errortab {
const char *text;
};
#define __errortab __table ( errortab, 01 )
#define __errortab __table ( struct errortab, errortab, 01 )
#endif /* _GPXE_ERRORTAB_H */

View File

@@ -46,7 +46,7 @@ struct init_fn {
/* Macro for creating an initialisation function table entry */
#define INIT_FN( init_order, init_func, reset_func, exit_func ) \
struct init_fn PREFIX_OBJECT(init_fn__) \
__table ( init_fn, init_order ) = { \
__table ( struct init_fn, init_fn, init_order ) = { \
.init = init_func, \
.reset = reset_func, \
.exit = exit_func, \

View File

@@ -16,6 +16,7 @@ struct pk_buff;
struct net_device;
struct net_protocol;
struct ll_protocol;
struct device;
/** Maximum length of a link-layer address */
#define MAX_LL_ADDR_LEN 6
@@ -140,6 +141,8 @@ struct net_device {
struct list_head list;
/** Name of this network device */
char name[8];
/** Underlying hardware device */
struct device *dev;
/** List of persistent reference holders */
struct list_head references;
@@ -219,10 +222,10 @@ struct net_device {
#define NETDEV_OPEN 0x0001
/** Declare a link-layer protocol */
#define __ll_protocol __table ( ll_protocols, 01 )
#define __ll_protocol __table ( struct ll_protocol, ll_protocols, 01 )
/** Declare a network-layer protocol */
#define __net_protocol __table ( net_protocols, 01 )
#define __net_protocol __table ( struct net_protocol, net_protocols, 01 )
extern struct list_head net_devices;

View File

@@ -277,8 +277,8 @@ struct pci_device {
* field.
*/
void *priv;
/** Device name */
const char *name;
/** Driver name */
const char *driver_name;
};
/** A PCI driver */
@@ -305,7 +305,7 @@ struct pci_driver {
};
/** Declare a PCI driver */
#define __pci_driver __table ( 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 )

View File

@@ -66,7 +66,8 @@ struct config_setting_type {
};
/** Declare a configuration setting type */
#define __config_setting_type __table ( config_setting_types, 01 )
#define __config_setting_type \
__table ( struct config_setting_type, config_setting_types, 01 )
/**
* A configuration setting
@@ -98,7 +99,7 @@ struct config_setting {
};
/** Declare a configuration setting */
#define __config_setting __table ( config_settings, 01 )
#define __config_setting __table ( struct config_setting, config_settings, 01 )
/**
* Show value of setting

View File

@@ -165,16 +165,17 @@
*/
#ifdef DOXYGEN
#define __attribute__(x)
#define __attribute__( x )
#endif
#define __table_str(x) #x
#define __table_section(table,idx) \
__section__ ( ".tbl." __table_str(table) "." __table_str(idx) )
#define __table_str( x ) #x
#define __table_section( table, idx ) \
__section__ ( ".tbl." __table_str ( table ) "." __table_str ( idx ) )
#define __table_section_start(table) __table_section(table,00)
#define __table_section_end(table) __table_section(table,99)
#define __table_section_start( table ) __table_section ( table, 00 )
#define __table_section_end( table ) __table_section ( table, 99 )
#define __natural_alignment( type ) __aligned__ ( __alignof__ ( type ) )
/**
* Linker table entry.
@@ -191,8 +192,9 @@
* @endcode
*
*/
#define __table(table,idx) \
__attribute__ (( __table_section(table,idx) ))
#define __table( type, table, idx ) \
__attribute__ (( __table_section ( table, idx ), \
__natural_alignment ( type ) ))
/**
* Linker table start marker.
@@ -207,8 +209,7 @@
* @endcode
*
*/
#define __table_start(table) \
__attribute__ (( __table_section_start(table) ))
#define __table_start( type, table ) __table ( type, table, 00 )
/**
* Linker table end marker.
@@ -223,7 +224,6 @@
* @endcode
*
*/
#define __table_end(table) \
__attribute__ (( __table_section_end(table) ))
#define __table_end( type, table ) __table ( type, table, 99 )
#endif /* _GPXE_TABLES_H */

View File

@@ -99,10 +99,12 @@ struct tcpip_net_protocol {
};
/** Declare a TCP/IP transport-layer protocol */
#define __tcpip_protocol __table ( tcpip_protocols, 01 )
#define __tcpip_protocol \
__table ( struct tcpip_protocol, tcpip_protocols, 01 )
/** Declare a TCP/IP network-layer protocol */
#define __tcpip_net_protocol __table ( tcpip_net_protocols, 01 )
#define __tcpip_net_protocol \
__table ( struct tcpip_net_protocol, tcpip_net_protocols, 01 )
extern int tcpip_rx ( struct pk_buff *pkb, uint8_t tcpip_proto,
struct sockaddr_tcpip *st_src,