Browse Source

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).
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
dad5274522
51 changed files with 184 additions and 135 deletions
  1. 3
    0
      src/arch/i386/drivers/net/undi.c
  2. 1
    0
      src/arch/i386/drivers/net/undinet.c
  3. 3
    1
      src/arch/i386/drivers/net/undionly.c
  4. 4
    2
      src/core/background.c
  5. 4
    2
      src/core/console.c
  6. 8
    4
      src/core/dev.c
  7. 7
    5
      src/core/device.c
  8. 4
    2
      src/core/exec.c
  9. 4
    2
      src/core/init.c
  10. 4
    2
      src/core/resolv.c
  11. 8
    8
      src/core/settings.c
  12. 4
    2
      src/drivers/bus/isa.c
  13. 11
    5
      src/drivers/bus/pci.c
  14. 2
    2
      src/drivers/net/dmfe.c
  15. 5
    5
      src/drivers/net/forcedeth.c
  16. 1
    0
      src/drivers/net/legacy.c
  17. 1
    1
      src/drivers/net/mtd80x.c
  18. 1
    1
      src/drivers/net/natsemi.c
  19. 7
    7
      src/drivers/net/ns83820.c
  20. 1
    1
      src/drivers/net/pcnet32.c
  21. 1
    0
      src/drivers/net/pnic.c
  22. 5
    5
      src/drivers/net/r8169.c
  23. 1
    0
      src/drivers/net/rtl8139.c
  24. 3
    3
      src/drivers/net/sundance.c
  25. 3
    3
      src/drivers/net/tlan.c
  26. 1
    1
      src/drivers/net/tulip.c
  27. 3
    3
      src/drivers/net/via-velocity.c
  28. 4
    2
      src/hci/shell.c
  29. 4
    2
      src/hci/strerror.c
  30. 4
    4
      src/hci/tui/settings_ui.c
  31. 1
    1
      src/include/background.h
  32. 1
    1
      src/include/console.h
  33. 3
    3
      src/include/dev.h
  34. 2
    1
      src/include/gpxe/arp.h
  35. 1
    1
      src/include/gpxe/command.h
  36. 3
    3
      src/include/gpxe/device.h
  37. 1
    1
      src/include/gpxe/errortab.h
  38. 1
    1
      src/include/gpxe/init.h
  39. 5
    2
      src/include/gpxe/netdevice.h
  40. 3
    3
      src/include/gpxe/pci.h
  41. 3
    2
      src/include/gpxe/settings.h
  42. 12
    12
      src/include/gpxe/tables.h
  43. 4
    2
      src/include/gpxe/tcpip.h
  44. 4
    4
      src/include/image.h
  45. 1
    1
      src/include/isa.h
  46. 5
    5
      src/include/proto.h
  47. 1
    1
      src/include/resolv.h
  48. 2
    2
      src/net/arp.c
  49. 8
    4
      src/net/netdevice.c
  50. 8
    8
      src/net/tcpip.c
  51. 3
    2
      src/usr/ifmgmt.c

+ 3
- 0
src/arch/i386/drivers/net/undi.c View File

19
 #include <stdint.h>
19
 #include <stdint.h>
20
 #include <stdlib.h>
20
 #include <stdlib.h>
21
 #include <string.h>
21
 #include <string.h>
22
+#include <vsprintf.h>
22
 #include <gpxe/pci.h>
23
 #include <gpxe/pci.h>
23
 #include <undi.h>
24
 #include <undi.h>
24
 #include <undirom.h>
25
 #include <undirom.h>
96
 	}
97
 	}
97
 
98
 
98
 	/* Add to device hierarchy */
99
 	/* Add to device hierarchy */
100
+	snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
101
+		   "UNDI%04x:%04x", undi->entry.segment, undi->entry.offset );
99
 	undi->dev.parent = &pci->dev;
102
 	undi->dev.parent = &pci->dev;
100
 	INIT_LIST_HEAD ( &undi->dev.children );
103
 	INIT_LIST_HEAD ( &undi->dev.children );
101
 	list_add ( &undi->dev.siblings, &pci->dev.children );
104
 	list_add ( &undi->dev.siblings, &pci->dev.children );

+ 1
- 0
src/arch/i386/drivers/net/undinet.c View File

577
 		return -ENOMEM;
577
 		return -ENOMEM;
578
 	undinic = netdev->priv;
578
 	undinic = netdev->priv;
579
 	undi_set_drvdata ( undi, netdev );
579
 	undi_set_drvdata ( undi, netdev );
580
+	netdev->dev = &undi->dev;
580
 	memset ( undinic, 0, sizeof ( *undinic ) );
581
 	memset ( undinic, 0, sizeof ( *undinic ) );
581
 	undinic->entry = undi->entry;
582
 	undinic->entry = undi->entry;
582
 	DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi );
583
 	DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi );

+ 3
- 1
src/arch/i386/drivers/net/undionly.c View File

58
 	}
58
 	}
59
 
59
 
60
 	/* Add to device hierarchy */
60
 	/* Add to device hierarchy */
61
+	strncpy ( preloaded_undi.dev.name, "UNDI",
62
+		  ( sizeof ( preloaded_undi.dev.name ) - 1 ) );
61
 	preloaded_undi.dev.parent = &rootdev->dev;
63
 	preloaded_undi.dev.parent = &rootdev->dev;
62
 	list_add ( &preloaded_undi.dev.siblings, &rootdev->dev.children);
64
 	list_add ( &preloaded_undi.dev.siblings, &rootdev->dev.children);
63
 	INIT_LIST_HEAD ( &preloaded_undi.dev.children );
65
 	INIT_LIST_HEAD ( &preloaded_undi.dev.children );
91
 
93
 
92
 /** UNDI bus root device */
94
 /** UNDI bus root device */
93
 struct root_device undi_root_device __root_device = {
95
 struct root_device undi_root_device __root_device = {
94
-	.name = "UNDI",
96
+	.dev = { .name = "UNDI" },
95
 	.driver = &undi_root_driver,
97
 	.driver = &undi_root_driver,
96
 };
98
 };

+ 4
- 2
src/core/background.c View File

1
 #include "background.h"
1
 #include "background.h"
2
 
2
 
3
-static struct background backgrounds[0] __table_start ( background );
4
-static struct background backgrounds_end[0] __table_end ( background );
3
+static struct background backgrounds[0]
4
+	__table_start ( struct background, background );
5
+static struct background backgrounds_end[0]
6
+	__table_end ( struct background, background );
5
 
7
 
6
 /** @file */
8
 /** @file */
7
 
9
 

+ 4
- 2
src/core/console.c View File

6
 
6
 
7
 #include "bios.h"
7
 #include "bios.h"
8
 
8
 
9
-static struct console_driver console_drivers[0] __table_start ( console );
10
-static struct console_driver console_drivers_end[0] __table_end ( console );
9
+static struct console_driver console_drivers[0]
10
+	__table_start ( struct console_driver, console );
11
+static struct console_driver console_drivers_end[0]
12
+	__table_end ( struct console_driver, console );
11
 
13
 
12
 /**
14
 /**
13
  * Write a single character to each console device.
15
  * Write a single character to each console device.

+ 8
- 4
src/core/dev.c View File

10
  */
10
  */
11
 
11
 
12
 /* Linker symbols for the various tables */
12
 /* Linker symbols for the various tables */
13
-static struct bus_driver bus_drivers[0] __table_start ( bus_driver );
14
-static struct bus_driver bus_drivers_end[0] __table_end ( bus_driver );
15
-static struct device_driver device_drivers[0] __table_start ( device_driver );
16
-static struct device_driver device_drivers_end[0] __table_end (device_driver );
13
+static struct bus_driver bus_drivers[0]
14
+	__table_start ( struct bus_driver, bus_driver );
15
+static struct bus_driver bus_drivers_end[0]
16
+	__table_end ( struct bus_driver, bus_driver );
17
+static struct device_driver device_drivers[0]
18
+	__table_start ( struct device_driver, device_driver );
19
+static struct device_driver device_drivers_end[0]
20
+	__table_end ( struct device_driver, device_driver );
17
 
21
 
18
 /* Current attempted boot device */
22
 /* Current attempted boot device */
19
 struct dev dev = {
23
 struct dev dev = {

+ 7
- 5
src/core/device.c View File

28
  *
28
  *
29
  */
29
  */
30
 
30
 
31
-static struct root_device root_devices[0] __table_start ( root_devices );
32
-static struct root_device root_devices_end[0] __table_end ( root_devices );
31
+static struct root_device root_devices[0]
32
+	__table_start ( struct root_device, root_devices );
33
+static struct root_device root_devices_end[0]
34
+	__table_end ( struct root_device, root_devices );
33
 
35
 
34
 /** Registered root devices */
36
 /** Registered root devices */
35
 static LIST_HEAD ( devices );
37
 static LIST_HEAD ( devices );
43
 static int rootdev_probe ( struct root_device *rootdev ) {
45
 static int rootdev_probe ( struct root_device *rootdev ) {
44
 	int rc;
46
 	int rc;
45
 
47
 
46
-	DBG ( "Adding %s root bus\n", rootdev->name );
48
+	DBG ( "Adding %s root bus\n", rootdev->dev.name );
47
 	if ( ( rc = rootdev->driver->probe ( rootdev ) ) != 0 ) {
49
 	if ( ( rc = rootdev->driver->probe ( rootdev ) ) != 0 ) {
48
 		DBG ( "Failed to add %s root bus: %s\n",
50
 		DBG ( "Failed to add %s root bus: %s\n",
49
-		      rootdev->name, strerror ( rc ) );
51
+		      rootdev->dev.name, strerror ( rc ) );
50
 		return rc;
52
 		return rc;
51
 	}
53
 	}
52
 
54
 
60
  */
62
  */
61
 static void rootdev_remove ( struct root_device *rootdev ) {
63
 static void rootdev_remove ( struct root_device *rootdev ) {
62
 	rootdev->driver->remove ( rootdev );
64
 	rootdev->driver->remove ( rootdev );
63
-	DBG ( "Removed %s root bus\n", rootdev->name );
65
+	DBG ( "Removed %s root bus\n", rootdev->dev.name );
64
 }
66
 }
65
 
67
 
66
 /**
68
 /**

+ 4
- 2
src/core/exec.c View File

33
  *
33
  *
34
  */
34
  */
35
 
35
 
36
-static struct command commands[0] __table_start ( commands );
37
-static struct command commands_end[0] __table_end ( commands );
36
+static struct command commands[0]
37
+	__table_start ( struct command, commands );
38
+static struct command commands_end[0]
39
+	__table_end ( struct command, commands );
38
 
40
 
39
 /* Avoid dragging in getopt.o unless a command really uses it */
41
 /* Avoid dragging in getopt.o unless a command really uses it */
40
 int optind;
42
 int optind;

+ 4
- 2
src/core/init.c View File

9
 
9
 
10
 #include <gpxe/init.h>
10
 #include <gpxe/init.h>
11
 
11
 
12
-static struct init_fn init_fns[0] __table_start(init_fn);
13
-static struct init_fn init_fns_end[0] __table_end(init_fn);
12
+static struct init_fn init_fns[0]
13
+	__table_start ( struct init_fn, init_fn );
14
+static struct init_fn init_fns_end[0]
15
+	__table_end ( struct init_fn, init_fn );
14
 
16
 
15
 void call_init_fns ( void ) {
17
 void call_init_fns ( void ) {
16
 	struct init_fn *init_fn;
18
 	struct init_fn *init_fn;

+ 4
- 2
src/core/resolv.c View File

1
 #include "resolv.h"
1
 #include "resolv.h"
2
 
2
 
3
-static struct resolver resolvers[0] __table_start(resolver);
4
-static struct resolver resolvers_end[0] __table_end(resolver);
3
+static struct resolver resolvers[0]
4
+	__table_start ( struct resolver, resolver );
5
+static struct resolver resolvers_end[0]
6
+	__table_end ( struct resolver, resolver );
5
 
7
 
6
 /*
8
 /*
7
  * Resolve a name (which may be just a dotted quad IP address) to an
9
  * Resolve a name (which may be just a dotted quad IP address) to an

+ 8
- 8
src/core/settings.c View File

34
  */
34
  */
35
 
35
 
36
 /** Registered configuration setting types */
36
 /** Registered configuration setting types */
37
-static struct config_setting_type
38
-config_setting_types[0] __table_start ( config_setting_types );
39
-static struct config_setting_type
40
-config_setting_types_end[0] __table_end ( config_setting_types );
37
+static struct config_setting_type config_setting_types[0]
38
+	__table_start ( struct config_setting_type, config_setting_types );
39
+static struct config_setting_type config_setting_types_end[0]
40
+	__table_end ( struct config_setting_type, config_setting_types );
41
 
41
 
42
 /** Registered configuration settings */
42
 /** Registered configuration settings */
43
-static struct config_setting
44
-config_settings[0] __table_start ( config_settings );
45
-static struct config_setting
46
-config_settings_end[0] __table_end ( config_settings );
43
+static struct config_setting config_settings[0]
44
+	__table_start ( struct config_setting, config_settings );
45
+static struct config_setting config_settings_end[0]
46
+	__table_end ( struct config_setting, config_settings );
47
 
47
 
48
 /**
48
 /**
49
  * Find configuration setting type
49
  * Find configuration setting type

+ 4
- 2
src/drivers/bus/isa.c View File

45
  * Symbols defined by linker
45
  * Symbols defined by linker
46
  *
46
  *
47
  */
47
  */
48
-static struct isa_driver isa_drivers[0] __table_start ( isa_driver );
49
-static struct isa_driver isa_drivers_end[0] __table_end ( isa_driver );
48
+static struct isa_driver isa_drivers[0]
49
+	__table_start ( struct isa_driver, isa_driver );
50
+static struct isa_driver isa_drivers_end[0]
51
+	__table_end ( struct isa_driver, isa_driver );
50
 
52
 
51
 /*
53
 /*
52
  * Increment a bus_loc structure to the next possible ISA location.
54
  * Increment a bus_loc structure to the next possible ISA location.

+ 11
- 5
src/drivers/bus/pci.c View File

23
 #include <stdlib.h>
23
 #include <stdlib.h>
24
 #include <string.h>
24
 #include <string.h>
25
 #include <errno.h>
25
 #include <errno.h>
26
+#include <vsprintf.h>
26
 #include <gpxe/tables.h>
27
 #include <gpxe/tables.h>
27
 #include <gpxe/device.h>
28
 #include <gpxe/device.h>
28
 #include <gpxe/pci.h>
29
 #include <gpxe/pci.h>
33
  *
34
  *
34
  */
35
  */
35
 
36
 
36
-static struct pci_driver pci_drivers[0] __table_start ( pci_drivers );
37
-static struct pci_driver pci_drivers_end[0] __table_end ( pci_drivers );
37
+static struct pci_driver pci_drivers[0]
38
+	__table_start ( struct pci_driver, pci_drivers );
39
+static struct pci_driver pci_drivers_end[0]
40
+	__table_end ( struct pci_driver, pci_drivers );
38
 
41
 
39
 static void pcibus_remove ( struct root_device *rootdev );
42
 static void pcibus_remove ( struct root_device *rootdev );
40
 
43
 
194
 			     ( id->device != pci->device ) )
197
 			     ( id->device != pci->device ) )
195
 				continue;
198
 				continue;
196
 			pci->driver = driver;
199
 			pci->driver = driver;
197
-			pci->name = id->name;
198
-			DBG ( "...using driver %s\n", pci->name );
200
+			pci->driver_name = id->name;
201
+			DBG ( "...using driver %s\n", pci->driver_name );
199
 			if ( ( rc = driver->probe ( pci, id ) ) != 0 ) {
202
 			if ( ( rc = driver->probe ( pci, id ) ) != 0 ) {
200
 				DBG ( "......probe failed\n" );
203
 				DBG ( "......probe failed\n" );
201
 				continue;
204
 				continue;
276
 			pci_read_bases ( pci );
279
 			pci_read_bases ( pci );
277
 
280
 
278
 			/* Add to device hierarchy */
281
 			/* Add to device hierarchy */
282
+			snprintf ( pci->dev.name, sizeof ( pci->dev.name ),
283
+				   "PCI%02x:%02x.%x", bus,
284
+				   PCI_SLOT ( devfn ), PCI_FUNC ( devfn ) );
279
 			pci->dev.parent = &rootdev->dev;
285
 			pci->dev.parent = &rootdev->dev;
280
 			list_add ( &pci->dev.siblings, &rootdev->dev.children);
286
 			list_add ( &pci->dev.siblings, &rootdev->dev.children);
281
 			INIT_LIST_HEAD ( &pci->dev.children );
287
 			INIT_LIST_HEAD ( &pci->dev.children );
325
 
331
 
326
 /** PCI bus root device */
332
 /** PCI bus root device */
327
 struct root_device pci_root_device __root_device = {
333
 struct root_device pci_root_device __root_device = {
328
-	.name = "PCI",
334
+	.dev = { .name = "PCI" },
329
 	.driver = &pci_root_driver,
335
 	.driver = &pci_root_driver,
330
 };
336
 };

+ 2
- 2
src/drivers/net/dmfe.c View File

457
 
457
 
458
 	BASE = pci->ioaddr;
458
 	BASE = pci->ioaddr;
459
 	printf("dmfe.c: Found %s Vendor=0x%hX Device=0x%hX\n",
459
 	printf("dmfe.c: Found %s Vendor=0x%hX Device=0x%hX\n",
460
-	       pci->name, pci->vendor, pci->device);
460
+	       pci->driver_name, pci->vendor, pci->device);
461
 
461
 
462
 	/* Read Chip revision */
462
 	/* Read Chip revision */
463
 	pci_read_config_dword(pci, PCI_REVISION_ID, &dev_rev);
463
 	pci_read_config_dword(pci, PCI_REVISION_ID, &dev_rev);
488
 		nic->node_addr[i] = db->srom[20 + i];
488
 		nic->node_addr[i] = db->srom[20 + i];
489
 
489
 
490
 	/* Print out some hardware info */
490
 	/* Print out some hardware info */
491
-	DBG ( "%s: %s at ioaddr %4.4lx\n", pci->name, eth_ntoa ( nic->node_addr ), BASE );
491
+	DBG ( "%s: %s at ioaddr %4.4lx\n", pci->driver_name, eth_ntoa ( nic->node_addr ), BASE );
492
 
492
 
493
 	/* Set the card as PCI Bus Master */
493
 	/* Set the card as PCI Bus Master */
494
 	adjust_pci_device(pci);
494
 	adjust_pci_device(pci);

+ 5
- 5
src/drivers/net/forcedeth.c View File

1246
 		return 0;
1246
 		return 0;
1247
 
1247
 
1248
 	printf("forcedeth.c: Found %s, vendor=0x%hX, device=0x%hX\n",
1248
 	printf("forcedeth.c: Found %s, vendor=0x%hX, device=0x%hX\n",
1249
-	       pci->name, pci->vendor, pci->device);
1249
+	       pci->driver_name, pci->vendor, pci->device);
1250
 
1250
 
1251
 	pci_fill_nic ( nic, pci );
1251
 	pci_fill_nic ( nic, pci );
1252
 
1252
 
1306
 	}
1306
 	}
1307
 #endif
1307
 #endif
1308
 
1308
 
1309
-	DBG ( "%s: MAC Address %s\n", pci->name, eth_ntoa ( nic->node_addr ) );
1309
+	DBG ( "%s: MAC Address %s\n", pci->driver_name, eth_ntoa ( nic->node_addr ) );
1310
 
1310
 
1311
  	/* disable WOL */
1311
  	/* disable WOL */
1312
 	writel(0, base + NvRegWakeUpFlags);
1312
 	writel(0, base + NvRegWakeUpFlags);
1381
  		id2 = (id2 & PHYID2_OUI_MASK) >> PHYID2_OUI_SHFT;
1381
  		id2 = (id2 & PHYID2_OUI_MASK) >> PHYID2_OUI_SHFT;
1382
  		dprintf
1382
  		dprintf
1383
 			(("%s: open: Found PHY %hX:%hX at address %d.\n",
1383
 			(("%s: open: Found PHY %hX:%hX at address %d.\n",
1384
-			  pci->name, id1, id2, i));
1384
+			  pci->driver_name, id1, id2, i));
1385
  		np->phyaddr = i;
1385
  		np->phyaddr = i;
1386
  		np->phy_oui = id1 | id2;
1386
  		np->phy_oui = id1 | id2;
1387
  		break;
1387
  		break;
1391
  		 * test loopback? Very odd, but can be correct.
1391
  		 * test loopback? Very odd, but can be correct.
1392
  		 */
1392
  		 */
1393
  		printf
1393
  		printf
1394
-			("%s: open: Could not find a valid PHY.\n", pci->name);
1394
+			("%s: open: Could not find a valid PHY.\n", pci->driver_name);
1395
  	}
1395
  	}
1396
 	
1396
 	
1397
  	if (i != 32) {
1397
  	if (i != 32) {
1400
  	}
1400
  	}
1401
 	
1401
 	
1402
 	dprintf(("%s: forcedeth.c: subsystem: %hX:%hX bound to %s\n",
1402
 	dprintf(("%s: forcedeth.c: subsystem: %hX:%hX bound to %s\n",
1403
-		 pci->name, pci->vendor, pci->dev_id, pci->name));
1403
+		 pci->driver_name, pci->vendor, pci->dev_id, pci->driver_name));
1404
 	if(!forcedeth_reset(nic)) return 0; // no valid link
1404
 	if(!forcedeth_reset(nic)) return 0; // no valid link
1405
 
1405
 
1406
 	/* point to NIC specific routines */
1406
 	/* point to NIC specific routines */

+ 1
- 0
src/drivers/net/legacy.c View File

84
 	netdev->priv = &nic;
84
 	netdev->priv = &nic;
85
 	memset ( &nic, 0, sizeof ( nic ) );
85
 	memset ( &nic, 0, sizeof ( nic ) );
86
 	pci_set_drvdata ( pci, netdev );
86
 	pci_set_drvdata ( pci, netdev );
87
+	netdev->dev = &pci->dev;
87
 
88
 
88
 	netdev->open = legacy_open;
89
 	netdev->open = legacy_open;
89
 	netdev->close = legacy_close;
90
 	netdev->close = legacy_close;

+ 1
- 1
src/drivers/net/mtd80x.c View File

677
     pci_fill_nic ( nic, pci );
677
     pci_fill_nic ( nic, pci );
678
     adjust_pci_device(pci);
678
     adjust_pci_device(pci);
679
 
679
 
680
-    mtdx.nic_name = pci->name;
680
+    mtdx.nic_name = pci->driver_name;
681
     mtdx.dev_id = pci->device;
681
     mtdx.dev_id = pci->device;
682
     mtdx.ioaddr = nic->ioaddr;
682
     mtdx.ioaddr = nic->ioaddr;
683
 
683
 

+ 1
- 1
src/drivers/net/natsemi.c View File

262
     ioaddr     = pci->ioaddr;
262
     ioaddr     = pci->ioaddr;
263
     vendor     = pci->vendor;
263
     vendor     = pci->vendor;
264
     dev_id     = pci->device;
264
     dev_id     = pci->device;
265
-    nic_name   = pci->name;
265
+    nic_name   = pci->driver_name;
266
 
266
 
267
     /* natsemi has a non-standard PM control register
267
     /* natsemi has a non-standard PM control register
268
      * in PCI config space.  Some boards apparently need
268
      * in PCI config space.  Some boards apparently need

+ 7
- 7
src/drivers/net/ns83820.c View File

821
 		return 0;
821
 		return 0;
822
 
822
 
823
 	printf("ns83820.c: Found %s, vendor=0x%hX, device=0x%hX\n",
823
 	printf("ns83820.c: Found %s, vendor=0x%hX, device=0x%hX\n",
824
-	       pci->name, pci->vendor, pci->device);
824
+	       pci->driver_name, pci->vendor, pci->device);
825
 
825
 
826
 	/* point to private storage */
826
 	/* point to private storage */
827
 	ns = &nsx;
827
 	ns = &nsx;
860
 	ns->CFG_cache = readl(ns->base + CFG);
860
 	ns->CFG_cache = readl(ns->base + CFG);
861
 
861
 
862
 	if ((ns->CFG_cache & CFG_PCI64_DET)) {
862
 	if ((ns->CFG_cache & CFG_PCI64_DET)) {
863
-		printf("%s: detected 64 bit PCI data bus.\n", pci->name);
863
+		printf("%s: detected 64 bit PCI data bus.\n", pci->driver_name);
864
 		/*dev->CFG_cache |= CFG_DATA64_EN; */
864
 		/*dev->CFG_cache |= CFG_DATA64_EN; */
865
 		if (!(ns->CFG_cache & CFG_DATA64_EN))
865
 		if (!(ns->CFG_cache & CFG_DATA64_EN))
866
 			printf
866
 			printf
867
 			    ("%s: EEPROM did not enable 64 bit bus.  Disabled.\n",
867
 			    ("%s: EEPROM did not enable 64 bit bus.  Disabled.\n",
868
-			     pci->name);
868
+			     pci->driver_name);
869
 	} else
869
 	} else
870
 		ns->CFG_cache &= ~(CFG_DATA64_EN);
870
 		ns->CFG_cache &= ~(CFG_DATA64_EN);
871
 
871
 
895
 
895
 
896
 	/* setup optical transceiver if we have one */
896
 	/* setup optical transceiver if we have one */
897
 	if (ns->CFG_cache & CFG_TBI_EN) {
897
 	if (ns->CFG_cache & CFG_TBI_EN) {
898
-		dprintf(("%s: enabling optical transceiver\n", pci->name));
898
+		dprintf(("%s: enabling optical transceiver\n", pci->driver_name));
899
 		writel(readl(ns->base + GPIOR) | 0x3e8, ns->base + GPIOR);
899
 		writel(readl(ns->base + GPIOR) | 0x3e8, ns->base + GPIOR);
900
 
900
 
901
 		/* setup auto negotiation feature advertisement */
901
 		/* setup auto negotiation feature advertisement */
916
 
916
 
917
 	/* FIXME: reset_phy is defaulted to 0, should we reset anyway? */
917
 	/* FIXME: reset_phy is defaulted to 0, should we reset anyway? */
918
 	if (reset_phy) {
918
 	if (reset_phy) {
919
-		dprintf(("%s: resetting phy\n", pci->name));
919
+		dprintf(("%s: resetting phy\n", pci->driver_name));
920
 		writel(ns->CFG_cache | CFG_PHY_RST, ns->base + CFG);
920
 		writel(ns->CFG_cache | CFG_PHY_RST, ns->base + CFG);
921
 		writel(ns->CFG_cache, ns->base + CFG);
921
 		writel(ns->CFG_cache, ns->base + CFG);
922
 	}
922
 	}
981
 	ns83820_getmac(nic, nic->node_addr);
981
 	ns83820_getmac(nic, nic->node_addr);
982
 
982
 
983
 	if (using_dac) {
983
 	if (using_dac) {
984
-		dprintf(("%s: using 64 bit addressing.\n", pci->name));
984
+		dprintf(("%s: using 64 bit addressing.\n", pci->driver_name));
985
 	}
985
 	}
986
 
986
 
987
 	dprintf(("%s: DP83820 %d.%d: %! io=0x%hX\n",
987
 	dprintf(("%s: DP83820 %d.%d: %! io=0x%hX\n",
988
-		 pci->name,
988
+		 pci->driver_name,
989
 		 (unsigned) readl(ns->base + SRR) >> 8,
989
 		 (unsigned) readl(ns->base + SRR) >> 8,
990
 		 (unsigned) readl(ns->base + SRR) & 0xff,
990
 		 (unsigned) readl(ns->base + SRR) & 0xff,
991
 		 nic->node_addr, pci->ioaddr));
991
 		 nic->node_addr, pci->ioaddr));

+ 1
- 1
src/drivers/net/pcnet32.c View File

678
 	/* BASE is used throughout to address the card */
678
 	/* BASE is used throughout to address the card */
679
 	ioaddr = pci->ioaddr;
679
 	ioaddr = pci->ioaddr;
680
 	printf("pcnet32.c: Found %s, Vendor=0x%hX Device=0x%hX\n",
680
 	printf("pcnet32.c: Found %s, Vendor=0x%hX Device=0x%hX\n",
681
-	       pci->name, pci->vendor, pci->device);
681
+	       pci->driver_name, pci->vendor, pci->device);
682
 
682
 
683
 	nic->irqno  = 0;
683
 	nic->irqno  = 0;
684
 	pci_fill_nic ( nic, pci );
684
 	pci_fill_nic ( nic, pci );

+ 1
- 0
src/drivers/net/pnic.c View File

234
 	}
234
 	}
235
 	pnic = netdev->priv;
235
 	pnic = netdev->priv;
236
 	pci_set_drvdata ( pci, netdev );
236
 	pci_set_drvdata ( pci, netdev );
237
+	netdev->dev = &pci->dev;
237
 	pnic->ioaddr = pci->ioaddr;
238
 	pnic->ioaddr = pci->ioaddr;
238
 
239
 
239
 	/* API version check */
240
 	/* API version check */

+ 5
- 5
src/drivers/net/r8169.c View File

884
 	int option = -1, Cap10_100 = 0, Cap1000 = 0;
884
 	int option = -1, Cap10_100 = 0, Cap1000 = 0;
885
 
885
 
886
 	printf ( "r8169.c: Found %s, Vendor=%hX Device=%hX\n",
886
 	printf ( "r8169.c: Found %s, Vendor=%hX Device=%hX\n",
887
-	       pci->name, pci->vendor, pci->device );
887
+	       pci->driver_name, pci->vendor, pci->device );
888
 
888
 
889
 	board_idx++;
889
 	board_idx++;
890
 
890
 
899
 	for (i = 0; i < MAC_ADDR_LEN; i++)
899
 	for (i = 0; i < MAC_ADDR_LEN; i++)
900
 		nic->node_addr[i] = RTL_R8(MAC0 + i);
900
 		nic->node_addr[i] = RTL_R8(MAC0 + i);
901
 
901
 
902
-	DBG ( "%s: Identified chip type is '%s'.\n", pci->name,
902
+	DBG ( "%s: Identified chip type is '%s'.\n", pci->driver_name,
903
 		 rtl_chip_info[tpc->chipset].name );
903
 		 rtl_chip_info[tpc->chipset].name );
904
 
904
 
905
 	/* Print out some hardware info */
905
 	/* Print out some hardware info */
906
-	DBG ( "%s: %s at IOAddr %#hX, ", pci->name, eth_ntoa ( nic->node_addr ),
906
+	DBG ( "%s: %s at IOAddr %#hX, ", pci->driver_name, eth_ntoa ( nic->node_addr ),
907
 	       ioaddr );
907
 	       ioaddr );
908
 
908
 
909
 	/* Config PHY */
909
 	/* Config PHY */
965
 			RTL8169_WRITE_GMII_REG(ioaddr, PHY_1000_CTRL_REG,
965
 			RTL8169_WRITE_GMII_REG(ioaddr, PHY_1000_CTRL_REG,
966
 					       Cap1000);
966
 					       Cap1000);
967
 		} else {
967
 		} else {
968
-			DBG ( "%s: Auto-negotiation Enabled.\n",  pci->name );
968
+			DBG ( "%s: Auto-negotiation Enabled.\n",  pci->driver_name );
969
 
969
 
970
 			// enable 10/100 Full/Half Mode, leave PHY_AUTO_NEGO_REG bit4:0 unchanged
970
 			// enable 10/100 Full/Half Mode, leave PHY_AUTO_NEGO_REG bit4:0 unchanged
971
 			RTL8169_WRITE_GMII_REG(ioaddr, PHY_AUTO_NEGO_REG,
971
 			RTL8169_WRITE_GMII_REG(ioaddr, PHY_AUTO_NEGO_REG,
1016
 		udelay(100);
1016
 		udelay(100);
1017
 		printf
1017
 		printf
1018
 		    ("%s: 1000Mbps Full-duplex operation, TBI Link %s!\n",
1018
 		    ("%s: 1000Mbps Full-duplex operation, TBI Link %s!\n",
1019
-		     pci->name,
1019
+		     pci->driver_name,
1020
 		     (RTL_R32(TBICSR) & TBILinkOK) ? "OK" : "Failed");
1020
 		     (RTL_R32(TBICSR) & TBILinkOK) ? "OK" : "Failed");
1021
 
1021
 
1022
 	}
1022
 	}

+ 1
- 0
src/drivers/net/rtl8139.c View File

532
 	}
532
 	}
533
 	rtl = netdev->priv;
533
 	rtl = netdev->priv;
534
 	pci_set_drvdata ( pci, netdev );
534
 	pci_set_drvdata ( pci, netdev );
535
+	netdev->dev = &pci->dev;
535
 	memset ( rtl, 0, sizeof ( *rtl ) );
536
 	memset ( rtl, 0, sizeof ( *rtl ) );
536
 	rtl->ioaddr = pci->ioaddr;
537
 	rtl->ioaddr = pci->ioaddr;
537
 
538
 

+ 3
- 3
src/drivers/net/sundance.c View File

581
 	/* BASE is used throughout to address the card */
581
 	/* BASE is used throughout to address the card */
582
 	BASE = pci->ioaddr;
582
 	BASE = pci->ioaddr;
583
 	printf(" sundance.c: Found %s Vendor=0x%hX Device=0x%hX\n",
583
 	printf(" sundance.c: Found %s Vendor=0x%hX Device=0x%hX\n",
584
-	       pci->name, pci->vendor, pci->device);
584
+	       pci->driver_name, pci->vendor, pci->device);
585
 
585
 
586
 	/* Get the MAC Address by reading the EEPROM */
586
 	/* Get the MAC Address by reading the EEPROM */
587
 	for (i = 0; i < 3; i++) {
587
 	for (i = 0; i < 3; i++) {
603
 	/* point to private storage */
603
 	/* point to private storage */
604
 	sdc = &sdx;
604
 	sdc = &sdx;
605
 
605
 
606
-	sdc->nic_name = pci->name;
606
+	sdc->nic_name = pci->driver_name;
607
 	sdc->mtu = mtu;
607
 	sdc->mtu = mtu;
608
 
608
 
609
 	pci_read_config_byte(pci, PCI_REVISION_ID, &sdc->pci_rev_id);
609
 	pci_read_config_byte(pci, PCI_REVISION_ID, &sdc->pci_rev_id);
611
 	DBG ( "Device revision id: %hx\n", sdc->pci_rev_id );
611
 	DBG ( "Device revision id: %hx\n", sdc->pci_rev_id );
612
 
612
 
613
 	/* Print out some hardware info */
613
 	/* Print out some hardware info */
614
-	DBG ( "%s: %s at ioaddr %hX, ", pci->name, nic->node_addr, BASE);
614
+	DBG ( "%s: %s at ioaddr %hX, ", pci->driver_name, nic->node_addr, BASE);
615
 
615
 
616
 	sdc->mii_preamble_required = 0;
616
 	sdc->mii_preamble_required = 0;
617
 	if (1) {
617
 	if (1) {

+ 3
- 3
src/drivers/net/tlan.c View File

809
 
809
 
810
 	priv->vendor_id = pci->vendor;
810
 	priv->vendor_id = pci->vendor;
811
 	priv->dev_id = pci->device;
811
 	priv->dev_id = pci->device;
812
-	priv->nic_name = pci->name;
812
+	priv->nic_name = pci->driver_name;
813
 	priv->eoc = 0;
813
 	priv->eoc = 0;
814
 
814
 
815
 	err = 0;
815
 	err = 0;
820
 				       (u8 *) & nic->node_addr[i]);
820
 				       (u8 *) & nic->node_addr[i]);
821
 	if (err) {
821
 	if (err) {
822
   	    printf ( "TLAN: %s: Error reading MAC from eeprom: %d\n",
822
   	    printf ( "TLAN: %s: Error reading MAC from eeprom: %d\n",
823
-		    pci->name, err);
823
+		    pci->driver_name, err);
824
 	} else {
824
 	} else {
825
 	    DBG ( "%s: %s at ioaddr %#lX, ", 
825
 	    DBG ( "%s: %s at ioaddr %#lX, ", 
826
-		  pci->name, eth_ntoa ( nic->node_addr ), pci->ioaddr );
826
+		  pci->driver_name, eth_ntoa ( nic->node_addr ), pci->ioaddr );
827
 	}
827
 	}
828
 
828
 
829
 	priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
829
 	priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);

+ 1
- 1
src/drivers/net/tulip.c View File

1252
 
1252
 
1253
     tp->vendor_id  = pci->vendor;
1253
     tp->vendor_id  = pci->vendor;
1254
     tp->dev_id     = pci->device;
1254
     tp->dev_id     = pci->device;
1255
-    tp->nic_name   = pci->name;
1255
+    tp->nic_name   = pci->driver_name;
1256
 
1256
 
1257
     tp->if_port = 0;
1257
     tp->if_port = 0;
1258
     tp->default_port = 0;
1258
     tp->default_port = 0;

+ 3
- 3
src/drivers/net/via-velocity.c View File

673
 	struct mac_regs *regs;
673
 	struct mac_regs *regs;
674
 
674
 
675
 	printf("via-velocity.c: Found %s Vendor=0x%hX Device=0x%hX\n",
675
 	printf("via-velocity.c: Found %s Vendor=0x%hX Device=0x%hX\n",
676
-	       pci->name, pci->vendor, pci->device);
676
+	       pci->driver_name, pci->vendor, pci->device);
677
 
677
 
678
 	/* point to private storage */
678
 	/* point to private storage */
679
 	vptr = &vptx;
679
 	vptr = &vptx;
705
 	for (i = 0; i < 6; i++)
705
 	for (i = 0; i < 6; i++)
706
 		nic->node_addr[i] = readb(&regs->PAR[i]);
706
 		nic->node_addr[i] = readb(&regs->PAR[i]);
707
 
707
 
708
-	DBG ( "%s: %s at ioaddr %#hX\n", pci->name, eth_ntoa ( nic->node_addr ), BASE );
708
+	DBG ( "%s: %s at ioaddr %#hX\n", pci->driver_name, eth_ntoa ( nic->node_addr ), BASE );
709
 
709
 
710
-	velocity_get_options(&vptr->options, 0, pci->name);
710
+	velocity_get_options(&vptr->options, 0, pci->driver_name);
711
 
711
 
712
 	/* 
712
 	/* 
713
 	 *      Mask out the options cannot be set to the chip
713
 	 *      Mask out the options cannot be set to the chip

+ 4
- 2
src/hci/shell.c View File

29
  *
29
  *
30
  */
30
  */
31
 
31
 
32
-static struct command commands[0] __table_start ( commands );
33
-static struct command commands_end[0] __table_end ( commands );
32
+static struct command commands[0]
33
+	__table_start ( struct command, commands );
34
+static struct command commands_end[0]
35
+	__table_end ( struct command, commands );
34
 
36
 
35
 /** The shell prompt string */
37
 /** The shell prompt string */
36
 static const char shell_prompt[] = "gPXE> ";
38
 static const char shell_prompt[] = "gPXE> ";

+ 4
- 2
src/hci/strerror.c View File

18
  *
18
  *
19
  */
19
  */
20
 
20
 
21
-static struct errortab errortab_start[0] __table_start(errortab);
22
-static struct errortab errortab_end[0] __table_end(errortab);
21
+static struct errortab errortab_start[0]
22
+	__table_start ( struct errortab, errortab );
23
+static struct errortab errortab_end[0]
24
+	__table_end ( struct errortab, errortab );
23
 
25
 
24
 /**
26
 /**
25
  * Retrieve string representation of error number.
27
  * Retrieve string representation of error number.

+ 4
- 4
src/hci/tui/settings_ui.c View File

81
 };
81
 };
82
 
82
 
83
 /** Registered configuration settings */
83
 /** Registered configuration settings */
84
-static struct config_setting
85
-config_settings[0] __table_start ( config_settings );
86
-static struct config_setting
87
-config_settings_end[0] __table_end ( config_settings );
84
+static struct config_setting config_settings[0]
85
+	__table_start ( struct config_setting, config_settings );
86
+static struct config_setting config_settings_end[0]
87
+	__table_end ( struct config_setting, config_settings );
88
 #define NUM_SETTINGS ( ( unsigned ) ( config_settings_end - config_settings ) )
88
 #define NUM_SETTINGS ( ( unsigned ) ( config_settings_end - config_settings ) )
89
 
89
 
90
 /**
90
 /**

+ 1
- 1
src/include/background.h View File

40
 };
40
 };
41
 
41
 
42
 /** A member of the background protocols table */
42
 /** A member of the background protocols table */
43
-#define __background __table ( background, 01 )
43
+#define __background __table ( struct background, background, 01 )
44
 
44
 
45
 /* Functions in background.c */
45
 /* Functions in background.c */
46
 
46
 

+ 1
- 1
src/include/console.h View File

93
  * @endcode
93
  * @endcode
94
  *
94
  *
95
  */
95
  */
96
-#define __console_driver __table ( console, 01 )
96
+#define __console_driver __table ( struct console_driver, console, 01 )
97
 
97
 
98
 /* Function prototypes */
98
 /* Function prototypes */
99
 
99
 

+ 3
- 3
src/include/dev.h View File

155
 	const char * ( *name_device ) ( struct bus_dev *bus_dev );
155
 	const char * ( *name_device ) ( struct bus_dev *bus_dev );
156
 };
156
 };
157
 
157
 
158
-#define __bus_driver __table ( bus_driver, 01 )
158
+#define __bus_driver __table ( struct bus_driver, bus_driver, 01 )
159
 
159
 
160
 /*
160
 /*
161
  * A structure fully describing the bus-independent parts of a
161
  * A structure fully describing the bus-independent parts of a
181
 	int ( * load ) ( struct type_dev *type_dev, struct buffer *buffer );
181
 	int ( * load ) ( struct type_dev *type_dev, struct buffer *buffer );
182
 };
182
 };
183
 
183
 
184
-#define __type_driver __table ( type_driver, 01 )
184
+#define __type_driver __table ( struct type_driver, type_driver, 01 )
185
 
185
 
186
 /*
186
 /*
187
  * A driver for a device.
187
  * A driver for a device.
198
 			     struct bus_dev *bus_dev );
198
 			     struct bus_dev *bus_dev );
199
 };
199
 };
200
 
200
 
201
-#define __device_driver __table ( device_driver, 01 )
201
+#define __device_driver __table ( struct device_driver, device_driver, 01 )
202
 
202
 
203
 #if 0
203
 #if 0
204
 #define DRIVER(_name,_type_driver,_bus_driver,_bus_info,	 	      \
204
 #define DRIVER(_name,_type_driver,_bus_driver,_bus_info,	 	      \

+ 2
- 1
src/include/gpxe/arp.h View File

27
 };
27
 };
28
 
28
 
29
 /** Declare an ARP protocol */
29
 /** Declare an ARP protocol */
30
-#define __arp_net_protocol __table ( arp_net_protocols, 01 )
30
+#define __arp_net_protocol \
31
+	__table ( struct arp_net_protocol, arp_net_protocols, 01 )
31
 
32
 
32
 extern int arp_resolve ( struct net_device *netdev,
33
 extern int arp_resolve ( struct net_device *netdev,
33
 			 struct net_protocol *net_protocol,
34
 			 struct net_protocol *net_protocol,

+ 1
- 1
src/include/gpxe/command.h View File

17
 	int ( * exec ) ( int argc, char **argv );
17
 	int ( * exec ) ( int argc, char **argv );
18
 };
18
 };
19
 
19
 
20
-#define __command __table ( commands, 01 )
20
+#define __command __table ( struct command, commands, 01 )
21
 
21
 
22
 #endif /* _GPXE_COMMAND_H */
22
 #endif /* _GPXE_COMMAND_H */

+ 3
- 3
src/include/gpxe/device.h View File

13
 
13
 
14
 /** A hardware device */
14
 /** A hardware device */
15
 struct device {
15
 struct device {
16
+	/** Name */
17
+	char name[16];
16
 	/** Devices on the same bus */
18
 	/** Devices on the same bus */
17
 	struct list_head siblings;
19
 	struct list_head siblings;
18
 	/** Devices attached to this device */
20
 	/** Devices attached to this device */
28
  *
30
  *
29
  */
31
  */
30
 struct root_device {
32
 struct root_device {
31
-	/** Name */
32
-	const char *name;
33
 	/** Device chain
33
 	/** Device chain
34
 	 *
34
 	 *
35
 	 * A root device has a NULL parent field.
35
 	 * A root device has a NULL parent field.
62
 };
62
 };
63
 
63
 
64
 /** Declare a root device */
64
 /** Declare a root device */
65
-#define __root_device __table ( root_devices, 01 )
65
+#define __root_device __table ( struct root_device, root_devices, 01 )
66
 
66
 
67
 extern int probe_devices ( void );
67
 extern int probe_devices ( void );
68
 extern void remove_devices ( void );
68
 extern void remove_devices ( void );

+ 1
- 1
src/include/gpxe/errortab.h View File

15
 	const char *text;
15
 	const char *text;
16
 };
16
 };
17
 
17
 
18
-#define __errortab __table ( errortab, 01 )
18
+#define __errortab __table ( struct errortab, errortab, 01 )
19
 
19
 
20
 #endif /* _GPXE_ERRORTAB_H */
20
 #endif /* _GPXE_ERRORTAB_H */

+ 1
- 1
src/include/gpxe/init.h View File

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

+ 5
- 2
src/include/gpxe/netdevice.h View File

16
 struct net_device;
16
 struct net_device;
17
 struct net_protocol;
17
 struct net_protocol;
18
 struct ll_protocol;
18
 struct ll_protocol;
19
+struct device;
19
 
20
 
20
 /** Maximum length of a link-layer address */
21
 /** Maximum length of a link-layer address */
21
 #define MAX_LL_ADDR_LEN 6
22
 #define MAX_LL_ADDR_LEN 6
140
 	struct list_head list;
141
 	struct list_head list;
141
 	/** Name of this network device */
142
 	/** Name of this network device */
142
 	char name[8];
143
 	char name[8];
144
+	/** Underlying hardware device */
145
+	struct device *dev;
143
 	/** List of persistent reference holders */
146
 	/** List of persistent reference holders */
144
 	struct list_head references;
147
 	struct list_head references;
145
 
148
 
219
 #define NETDEV_OPEN 0x0001
222
 #define NETDEV_OPEN 0x0001
220
 
223
 
221
 /** Declare a link-layer protocol */
224
 /** Declare a link-layer protocol */
222
-#define __ll_protocol  __table ( ll_protocols, 01 )
225
+#define __ll_protocol  __table ( struct ll_protocol, ll_protocols, 01 )
223
 
226
 
224
 /** Declare a network-layer protocol */
227
 /** Declare a network-layer protocol */
225
-#define __net_protocol __table ( net_protocols, 01 )
228
+#define __net_protocol __table ( struct net_protocol, net_protocols, 01 )
226
 
229
 
227
 extern struct list_head net_devices;
230
 extern struct list_head net_devices;
228
 
231
 

+ 3
- 3
src/include/gpxe/pci.h View File

277
 	 * field.
277
 	 * field.
278
 	 */
278
 	 */
279
 	void *priv;
279
 	void *priv;
280
-	/** Device name */
281
-	const char *name;
280
+	/** Driver name */
281
+	const char *driver_name;
282
 };
282
 };
283
 
283
 
284
 /** A PCI driver */
284
 /** A PCI driver */
305
 };
305
 };
306
 
306
 
307
 /** Declare a PCI driver */
307
 /** Declare a PCI driver */
308
-#define __pci_driver __table ( pci_drivers, 01 )
308
+#define __pci_driver __table ( struct pci_driver, pci_drivers, 01 )
309
 
309
 
310
 #define PCI_DEVFN( slot, func )	( ( (slot) << 3 ) | (func) )
310
 #define PCI_DEVFN( slot, func )	( ( (slot) << 3 ) | (func) )
311
 #define PCI_SLOT( devfn )	( ( (devfn) >> 3 ) & 0x1f )
311
 #define PCI_SLOT( devfn )	( ( (devfn) >> 3 ) & 0x1f )

+ 3
- 2
src/include/gpxe/settings.h View File

66
 };
66
 };
67
 
67
 
68
 /** Declare a configuration setting type */
68
 /** Declare a configuration setting type */
69
-#define	__config_setting_type __table ( config_setting_types, 01 )
69
+#define	__config_setting_type \
70
+	__table ( struct config_setting_type, config_setting_types, 01 )
70
 
71
 
71
 /**
72
 /**
72
  * A configuration setting
73
  * A configuration setting
98
 };
99
 };
99
 
100
 
100
 /** Declare a configuration setting */
101
 /** Declare a configuration setting */
101
-#define	__config_setting __table ( config_settings, 01 )
102
+#define	__config_setting __table ( struct config_setting, config_settings, 01 )
102
 
103
 
103
 /**
104
 /**
104
  * Show value of setting
105
  * Show value of setting

+ 12
- 12
src/include/gpxe/tables.h View File

165
  */
165
  */
166
 
166
 
167
 #ifdef DOXYGEN
167
 #ifdef DOXYGEN
168
-#define __attribute__(x)
168
+#define __attribute__( x )
169
 #endif
169
 #endif
170
 
170
 
171
-#define __table_str(x) #x
172
-#define __table_section(table,idx) \
173
-	__section__ ( ".tbl." __table_str(table) "." __table_str(idx) )
171
+#define __table_str( x ) #x
172
+#define __table_section( table, idx ) \
173
+	__section__ ( ".tbl." __table_str ( table ) "." __table_str ( idx ) )
174
 
174
 
175
-#define __table_section_start(table) __table_section(table,00)
176
-#define __table_section_end(table) __table_section(table,99)
175
+#define __table_section_start( table ) __table_section ( table, 00 )
176
+#define __table_section_end( table ) __table_section ( table, 99 )
177
 
177
 
178
+#define __natural_alignment( type ) __aligned__ ( __alignof__ ( type ) )
178
 
179
 
179
 /**
180
 /**
180
  * Linker table entry.
181
  * Linker table entry.
191
  * @endcode
192
  * @endcode
192
  *
193
  *
193
  */
194
  */
194
-#define __table(table,idx) \
195
-	__attribute__ (( __table_section(table,idx) ))
195
+#define __table( type, table, idx )				\
196
+	__attribute__ (( __table_section ( table, idx ),	\
197
+			 __natural_alignment ( type ) ))
196
 
198
 
197
 /**
199
 /**
198
  * Linker table start marker.
200
  * Linker table start marker.
207
  * @endcode
209
  * @endcode
208
  *
210
  *
209
  */
211
  */
210
-#define __table_start(table) \
211
-	__attribute__ (( __table_section_start(table) ))
212
+#define __table_start( type, table ) __table ( type, table, 00 )
212
 
213
 
213
 /**
214
 /**
214
  * Linker table end marker.
215
  * Linker table end marker.
223
  * @endcode
224
  * @endcode
224
  *
225
  *
225
  */
226
  */
226
-#define __table_end(table) \
227
-	__attribute__ (( __table_section_end(table) ))
227
+#define __table_end( type, table ) __table ( type, table, 99 )
228
 
228
 
229
 #endif /* _GPXE_TABLES_H */
229
 #endif /* _GPXE_TABLES_H */

+ 4
- 2
src/include/gpxe/tcpip.h View File

99
 };
99
 };
100
 
100
 
101
 /** Declare a TCP/IP transport-layer protocol */
101
 /** Declare a TCP/IP transport-layer protocol */
102
-#define	__tcpip_protocol __table ( tcpip_protocols, 01 )
102
+#define	__tcpip_protocol \
103
+	__table ( struct tcpip_protocol, tcpip_protocols, 01 )
103
 
104
 
104
 /** Declare a TCP/IP network-layer protocol */
105
 /** Declare a TCP/IP network-layer protocol */
105
-#define	__tcpip_net_protocol __table ( tcpip_net_protocols, 01 )
106
+#define	__tcpip_net_protocol \
107
+	__table ( struct tcpip_net_protocol, tcpip_net_protocols, 01 )
106
 
108
 
107
 extern int tcpip_rx ( struct pk_buff *pkb, uint8_t tcpip_proto,
109
 extern int tcpip_rx ( struct pk_buff *pkb, uint8_t tcpip_proto,
108
 		      struct sockaddr_tcpip *st_src,
110
 		      struct sockaddr_tcpip *st_src,

+ 4
- 4
src/include/image.h View File

13
 	int ( * boot ) ( void *context );
13
 	int ( * boot ) ( void *context );
14
 };
14
 };
15
 
15
 
16
-#define __image_start		__table_start(image)
17
-#define __image			__table(image,01)
18
-#define __default_image		__table(image,02)
19
-#define __image_end		__table_end(image)
16
+#define __image_start		__table_start ( struct image, image )
17
+#define __image			__table ( struct image, image, 01 )
18
+#define __default_image		__table ( struct image, image, 02 )
19
+#define __image_end		__table_end ( struct image, image )
20
 
20
 
21
 /* Functions in image.c */
21
 /* Functions in image.c */
22
 
22
 

+ 1
- 1
src/include/isa.h View File

54
  *
54
  *
55
  */
55
  */
56
 #define ISA_DRIVER( _name, _probe_addrs, _probe_addr, _mfg_id, _prod_id )   \
56
 #define ISA_DRIVER( _name, _probe_addrs, _probe_addr, _mfg_id, _prod_id )   \
57
-struct isa_driver _name __table(isa_driver,01 ) = {			    \
57
+struct isa_driver _name __table ( struct isa_driver, isa_driver, 01 ) = {   \
58
 	.probe_addrs = _probe_addrs,					    \
58
 	.probe_addrs = _probe_addrs,					    \
59
 	.addr_count = sizeof ( _probe_addrs ) / sizeof ( _probe_addrs[0] ), \
59
 	.addr_count = sizeof ( _probe_addrs ) / sizeof ( _probe_addrs[0] ), \
60
 	.probe_addr = _probe_addr,					    \
60
 	.probe_addr = _probe_addr,					    \

+ 5
- 5
src/include/proto.h View File

18
  * should use __protocol.
18
  * should use __protocol.
19
  *
19
  *
20
  */
20
  */
21
-#define __protocol_start		__table_start(protocol)
22
-#define __protocol			__table(protocol,01)
23
-#define __default_protocol_start	__table(protocol,02)
24
-#define __default_protocol		__table(protocol,03)
25
-#define __protocol_end			__table_end(protocol)
21
+#define __protocol_start	 __table_start ( struct protocol, protocol )
22
+#define __protocol		 __table ( struct protocol, protocol, 01 )
23
+#define __default_protocol_start __table ( struct protocol, protocol, 02 )
24
+#define __default_protocol	 __table ( struct protocol, protocol, 03 )
25
+#define __protocol_end		 __table_end ( struct protocol, protocol )
26
 
26
 
27
 /*
27
 /*
28
  * Functions in proto.c
28
  * Functions in proto.c

+ 1
- 1
src/include/resolv.h View File

9
 	int ( * resolv ) ( struct in_addr *address, const char *name );
9
 	int ( * resolv ) ( struct in_addr *address, const char *name );
10
 };
10
 };
11
 
11
 
12
-#define __resolver __table(resolver,01)
12
+#define __resolver __table ( struct resolver, resolver, 01 )
13
 
13
 
14
 extern int resolv ( struct in_addr *address, const char *name );
14
 extern int resolv ( struct in_addr *address, const char *name );
15
 
15
 

+ 2
- 2
src/net/arp.c View File

38
 
38
 
39
 /** Registered ARP protocols */
39
 /** Registered ARP protocols */
40
 static struct arp_net_protocol arp_net_protocols[0]
40
 static struct arp_net_protocol arp_net_protocols[0]
41
-	__table_start ( arp_net_protocols );
41
+	__table_start ( struct arp_net_protocol, arp_net_protocols );
42
 static struct arp_net_protocol arp_net_protocols_end[0]
42
 static struct arp_net_protocol arp_net_protocols_end[0]
43
-	__table_end ( arp_net_protocols );
43
+	__table_end ( struct arp_net_protocol, arp_net_protocols );
44
 
44
 
45
 /** An ARP cache entry */
45
 /** An ARP cache entry */
46
 struct arp_entry {
46
 struct arp_entry {

+ 8
- 4
src/net/netdevice.c View File

27
 #include <gpxe/tables.h>
27
 #include <gpxe/tables.h>
28
 #include <gpxe/process.h>
28
 #include <gpxe/process.h>
29
 #include <gpxe/init.h>
29
 #include <gpxe/init.h>
30
+#include <gpxe/device.h>
30
 #include <gpxe/netdevice.h>
31
 #include <gpxe/netdevice.h>
31
 
32
 
32
 /** @file
33
 /** @file
36
  */
37
  */
37
 
38
 
38
 /** Registered network-layer protocols */
39
 /** Registered network-layer protocols */
39
-static struct net_protocol net_protocols[0] __table_start ( net_protocols );
40
-static struct net_protocol net_protocols_end[0] __table_end ( net_protocols );
40
+static struct net_protocol net_protocols[0]
41
+	__table_start ( struct net_protocol, net_protocols );
42
+static struct net_protocol net_protocols_end[0]
43
+	__table_end ( struct net_protocol, net_protocols );
41
 
44
 
42
 /** List of network devices */
45
 /** List of network devices */
43
 struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
46
 struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
200
 
203
 
201
 	/* Add to device list */
204
 	/* Add to device list */
202
 	list_add_tail ( &netdev->list, &net_devices );
205
 	list_add_tail ( &netdev->list, &net_devices );
203
-	DBGC ( netdev, "NETDEV %p registered as %s (%s)\n",
204
-	       netdev, netdev->name, netdev_hwaddr ( netdev ) );
206
+	DBGC ( netdev, "NETDEV %p registered as %s (phys %s hwaddr %s)\n",
207
+	       netdev, netdev->name, netdev->dev->name,
208
+	       netdev_hwaddr ( netdev ) );
205
 
209
 
206
 	return 0;
210
 	return 0;
207
 }
211
 }

+ 8
- 8
src/net/tcpip.c View File

15
  */
15
  */
16
 
16
 
17
 /** Registered network-layer protocols that support TCP/IP */
17
 /** Registered network-layer protocols that support TCP/IP */
18
-static struct tcpip_net_protocol
19
-tcpip_net_protocols[0] __table_start ( tcpip_net_protocols );
20
-static struct tcpip_net_protocol
21
-tcpip_net_protocols_end[0] __table_end ( tcpip_net_protocols );
18
+static struct tcpip_net_protocol tcpip_net_protocols[0]
19
+	__table_start ( struct tcpip_net_protocol, tcpip_net_protocols );
20
+static struct tcpip_net_protocol tcpip_net_protocols_end[0]
21
+	__table_end ( struct tcpip_net_protocol, tcpip_net_protocols );
22
 
22
 
23
 /** Registered transport-layer protocols that support TCP/IP */
23
 /** Registered transport-layer protocols that support TCP/IP */
24
-static struct tcpip_protocol
25
-tcpip_protocols[0]__table_start ( tcpip_protocols );
26
-static struct tcpip_protocol
27
-tcpip_protocols_end[0] __table_end ( tcpip_protocols );
24
+static struct tcpip_protocol tcpip_protocols[0]
25
+	__table_start ( struct tcpip_protocol, tcpip_protocols );
26
+static struct tcpip_protocol tcpip_protocols_end[0]
27
+	__table_end ( struct tcpip_protocol, tcpip_protocols );
28
 
28
 
29
 /** Process a received TCP/IP packet
29
 /** Process a received TCP/IP packet
30
  *
30
  *

+ 3
- 2
src/usr/ifmgmt.c View File

19
 #include <string.h>
19
 #include <string.h>
20
 #include <vsprintf.h>
20
 #include <vsprintf.h>
21
 #include <gpxe/netdevice.h>
21
 #include <gpxe/netdevice.h>
22
+#include <gpxe/device.h>
22
 #include <usr/ifmgmt.h>
23
 #include <usr/ifmgmt.h>
23
 
24
 
24
 /** @file
25
 /** @file
60
  * @v netdev		Network device
61
  * @v netdev		Network device
61
  */
62
  */
62
 void ifstat ( struct net_device *netdev ) {
63
 void ifstat ( struct net_device *netdev ) {
63
-	printf ( "%s %s %s\n",
64
-		 netdev->name, netdev_hwaddr ( netdev ),
64
+	printf ( "%s: %s on %s (%s)\n",
65
+		 netdev->name, netdev_hwaddr ( netdev ), netdev->dev->name,
65
 		 ( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ) );
66
 		 ( ( netdev->state & NETDEV_OPEN ) ? "open" : "closed" ) );
66
 }
67
 }

Loading…
Cancel
Save