]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[legacy] Allocate legacy driver .bss-like segments at probe time
authorMichael Brown <mcb30@ipxe.org>
Tue, 24 Jun 2025 12:17:19 +0000 (13:17 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 24 Jun 2025 12:41:51 +0000 (13:41 +0100)
Some legacy drivers use large static allocations for transmit and
receive buffers.  To avoid bloating the .bss segment, we currently
implement these as a single common symbol named "_shared_bss" (which
is permissible since only one legacy driver may be active at any one
time).

Switch to dynamic allocation of these .bss-like segments, to avoid the
requirement for using common symbols.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
26 files changed:
src/drivers/net/3c509-eisa.c
src/drivers/net/3c509.c
src/drivers/net/3c515.c
src/drivers/net/3c529.c
src/drivers/net/3c595.c
src/drivers/net/amd8111e.c
src/drivers/net/bnx2.c
src/drivers/net/cs89x0.c
src/drivers/net/davicom.c
src/drivers/net/depca.c
src/drivers/net/dmfe.c
src/drivers/net/eepro.c
src/drivers/net/epic100.c
src/drivers/net/legacy.c
src/drivers/net/ne2k_isa.c
src/drivers/net/ns8390.c
src/drivers/net/prism2_pci.c
src/drivers/net/prism2_plx.c
src/drivers/net/sis900.c
src/drivers/net/smc9000.c
src/drivers/net/sundance.c
src/drivers/net/tlan.c
src/drivers/net/tulip.c
src/drivers/net/w89c840.c
src/include/compiler.h
src/include/nic.h

index 81c60ee913cfffc03f305be0d711b199c0cfd171..ada34a6b9f511338e57ae7c90dc534107eb5efd5 100644 (file)
@@ -35,7 +35,7 @@ static struct eisa_device_id el3_eisa_adapters[] = {
 EISA_DRIVER ( el3_eisa_driver, el3_eisa_adapters );
 
 DRIVER ( "3c509 (EISA)", nic_driver, eisa_driver, el3_eisa_driver,
-        el3_eisa_probe, el3_eisa_disable );
+        el3_eisa_probe, el3_eisa_disable, no_fake_bss );
 
 ISA_ROM ( "3c509-eisa","3c509 (EISA)" );
 
index 4326a835ccddc6d2d31f85f13e7e462983e4b229..0f721315d83ec6f2df4759428aac3e8cce398772 100644 (file)
@@ -316,7 +316,7 @@ static int t509_probe ( struct t509_device *t509 ) {
        DBG ( "Adding 3c509 device %02x (I/O %04x)\n",
              t509->tag, t509->ioaddr );
        return legacy_probe ( t509, legacy_t509_set_drvdata, &t509->dev,
-                             legacy_t509_probe, legacy_t509_disable );
+                             legacy_t509_probe, legacy_t509_disable, 0 );
 }
 
 /**
index 1591e06175beba7aa0edba3797984a17d847355d..353d4579478256d1b10879c78f592d448230ce38 100644 (file)
@@ -64,7 +64,6 @@ static void t3c515_wait(unsigned int nticks)
 /* TJL definations */
 #define HZ      100
 static int if_port;
-static struct corkscrew_private *vp;
 /* Brought directly from 3c515.c by Becker */
 #define CORKSCREW 1
 
@@ -237,6 +236,7 @@ struct corkscrew_private {
         full_bus_master_tx:1, full_bus_master_rx:1,    /* Boomerang  */
         tx_full:1;
 };
+#define vp NIC_FAKE_BSS_PTR ( struct corkscrew_private )
 
 /* The action to take with a media selection timer tick.
    Note that we deviate from the 3Com order by checking 10base2 before AUI.
@@ -759,6 +759,6 @@ static struct isapnp_device_id t515_adapters[] = {
 ISAPNP_DRIVER ( t515_driver, t515_adapters );
 
 DRIVER ( "3c515", nic_driver, isapnp_driver, t515_driver,
-        t515_probe, t515_disable );
+        t515_probe, t515_disable, *vp );
 
 ISA_ROM ( "3c515", "3c515 Fast EtherLink ISAPnP" );
index d68f28ec1c6d95ed7a74532bc66fabac24626ae8..8b408f255b3cd6053700642b8d1ed52600a88af5 100644 (file)
@@ -49,7 +49,7 @@ static struct mca_device_id el3_mca_adapters[] = {
 MCA_DRIVER ( t529_driver, el3_mca_adapters );
 
 DRIVER ( "3c529", nic_driver, mca_driver, t529_driver,
-        t529_probe, t529_disable );
+        t529_probe, t529_disable, no_fake_bss );
 
 ISA_ROM( "3c529", "3c529 == MCA 3c509" );
 
index 7792c17d64fb9f37b1e582dc605e496fb0f393b9..58cfc41ae54c09c66840a26b537ed4a3bef12623 100644 (file)
@@ -541,7 +541,7 @@ PCI_ROM(0x10b7, 0x9805, "3c9805-1",        "3Com9805", 0),          /* Dual Port Server
 PCI_DRIVER ( t595_driver, t595_nics, PCI_NO_CLASS );
 
 DRIVER ( "3C595", nic_driver, pci_driver, t595_driver,
-        t595_probe, t595_disable );
+        t595_probe, t595_disable, no_fake_bss );
 
 /*
  * Local variables:
index 213c4f44b2d36d97df53aec2b8aca3d2c713b123..c21c1183512d91ad9c9e4195c482e22243b39cb3 100644 (file)
@@ -105,8 +105,7 @@ struct amd8111e_priv {
        struct nic *nic;
        void *mmio;
 };
-
-static struct amd8111e_priv amd8111e;
+#define amd8111e NIC_FAKE_BSS ( struct amd8111e_priv )
 
 
 /********************************************************
@@ -683,7 +682,7 @@ static struct pci_device_id amd8111e_nics[] = {
 PCI_DRIVER ( amd8111e_driver, amd8111e_nics, PCI_NO_CLASS );
 
 DRIVER ( "AMD8111E", nic_driver, pci_driver, amd8111e_driver,
-        amd8111e_probe, amd8111e_disable );
+        amd8111e_probe, amd8111e_disable, amd8111e );
 
 /*
  * Local variables:
index 186cc17d4201d3d92fede3a2b7683738be28b478..ae94c9bedac5c11cad24feb02a7e3ca2b0b0f352 100644 (file)
@@ -36,13 +36,14 @@ FILE_LICENCE ( GPL_ANY );
 /* The bnx2 seems to be picky about the alignment of the receive buffers
  * and possibly the status block.
  */
-static struct bss {
+struct bss {
        struct tx_bd tx_desc_ring[TX_DESC_CNT];
        struct rx_bd rx_desc_ring[RX_DESC_CNT];
        unsigned char rx_buf[RX_BUF_CNT][RX_BUF_SIZE];
        struct status_block status_blk;
        struct statistics_block stats_blk;
-} bnx2_bss;
+};
+#define bnx2_bss NIC_FAKE_BSS ( struct bss )
 
 static struct bnx2 bnx2;
 
@@ -2686,7 +2687,8 @@ static struct pci_device_id bnx2_nics[] = {
 
 PCI_DRIVER ( bnx2_driver, bnx2_nics, PCI_NO_CLASS );
 
-DRIVER ( "BNX2", nic_driver, pci_driver, bnx2_driver, bnx2_probe, bnx2_remove );
+DRIVER ( "BNX2", nic_driver, pci_driver, bnx2_driver,
+        bnx2_probe, bnx2_remove, bnx2_bss );
 
 /*
 static struct pci_driver bnx2_driver __pci_driver = {
index 17b7157a165380883782d2a6a58e5c527d6c0906..fc311a18a206a7dbf5fd0d41a678b42f4646d011 100644 (file)
@@ -725,7 +725,7 @@ ISA_DRIVER ( cs89x0_driver, cs89x0_probe_addrs, cs89x0_probe_addr,
             ISAPNP_VENDOR('C','S','C'), 0x0007 );
 
 DRIVER ( "cs89x0", nic_driver, isa_driver, cs89x0_driver,
-        cs89x0_probe, cs89x0_disable );
+        cs89x0_probe, cs89x0_disable, no_fake_bss );
 
 ISA_ROM ( "cs89x0", "Crystal Semiconductor CS89x0" );
 
index 307ae98116e27ab90f4640a3c5c84335db6e3830..2b063ad1b653533380b07b55e41ffc1c2d15e559 100644 (file)
@@ -134,12 +134,13 @@ static unsigned long ioaddr;
 /* transmit descriptor and buffer */
 #define NTXD 2
 #define NRXD 4
-struct {
+struct davicom_bss {
        struct txdesc txd[NTXD] __attribute__ ((aligned(4)));
        unsigned char txb[BUFLEN] __attribute__ ((aligned(4)));
        struct rxdesc rxd[NRXD] __attribute__ ((aligned(4)));
        unsigned char rxb[NRXD * BUFLEN] __attribute__ ((aligned(4)));
-} davicom_bufs __shared;
+};
+#define davicom_bufs NIC_FAKE_BSS ( struct davicom_bss )
 #define txd davicom_bufs.txd
 #define txb davicom_bufs.txb
 #define rxd davicom_bufs.rxd
@@ -698,7 +699,7 @@ PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132", 0),  /* Needs probably som
 PCI_DRIVER ( davicom_driver, davicom_nics, PCI_NO_CLASS );
 
 DRIVER ( "DAVICOM", nic_driver, pci_driver, davicom_driver,
-        davicom_probe, davicom_disable );
+        davicom_probe, davicom_disable, davicom_bufs );
 
 /*
  * Local variables:
index 30e2fcb0a02072bdea76a7e74acd2d5e0647173b..335928667e1db716799b3d7a8452b4080389bf58 100644 (file)
@@ -789,7 +789,7 @@ ISA_DRIVER ( depca_driver, depca_probe_addrs, depca_probe1,
                     GENERIC_ISAPNP_VENDOR, 0x80f7 );
 
 DRIVER ( "depce", nic_driver, isa_driver, depca_driver,
-        depca_probe, depca_disable );
+        depca_probe, depca_disable, no_fake_bss );
 
 ISA_ROM ( "depca", "Digital DE100 and DE200" );
 
index a76dd792d776c980602a432efdc1ea275c8687fb..2ed108e8c748ad7cad6708a41cb13f5db45dbb19 100644 (file)
@@ -209,14 +209,15 @@ static u8 SF_mode;                /* Special Function: 1:VLAN, 2:RX Flow Control
 /**********************************************
 * Descriptor Ring and Buffer defination
 ***********************************************/
-struct {
+struct dmfe_bss {
        struct tx_desc txd[TX_DESC_CNT] __attribute__ ((aligned(32)));
        unsigned char txb[TX_BUF_ALLOC * TX_DESC_CNT]
        __attribute__ ((aligned(32)));
        struct rx_desc rxd[RX_DESC_CNT] __attribute__ ((aligned(32)));
        unsigned char rxb[RX_ALLOC_SIZE * RX_DESC_CNT]
        __attribute__ ((aligned(32)));
-} dmfe_bufs __shared;
+};
+#define dmfe_bufs NIC_FAKE_BSS ( struct dmfe_bss )
 #define txd dmfe_bufs.txd
 #define txb dmfe_bufs.txb
 #define rxd dmfe_bufs.rxd
@@ -1217,7 +1218,7 @@ static struct pci_device_id dmfe_nics[] = {
 PCI_DRIVER ( dmfe_driver, dmfe_nics, PCI_NO_CLASS );
 
 DRIVER ( "DMFE/PCI", nic_driver, pci_driver, dmfe_driver,
-        dmfe_probe, dmfe_disable );
+        dmfe_probe, dmfe_disable, dmfe_bufs );
 
 /*
  * Local variables:
index 97b4c406181b6645932ea5f8f5c7ab4ff48cfe39..3863553fad60042274bb8f4724fa607782231094 100644 (file)
@@ -635,7 +635,7 @@ ISA_DRIVER ( eepro_driver, eepro_probe_addrs, eepro_probe1,
                     GENERIC_ISAPNP_VENDOR, 0x828a );
 
 DRIVER ( "eepro", nic_driver, isa_driver, eepro_driver,
-        eepro_probe, eepro_disable );
+        eepro_probe, eepro_disable, no_fake_bss );
 
 ISA_ROM ( "eepro", "Intel Etherexpress Pro/10" );
 
index 01c0c43c91c574e33b4f0cc0dd1579bf798e3f9e..03b394e6beedcf350370e3fef8eff8c48ab4bb53 100644 (file)
@@ -86,14 +86,15 @@ static unsigned int cur_rx, cur_tx;         /* The next free ring entry */
 static unsigned short  eeprom[64];
 #endif
 static signed char     phys[4];                /* MII device addresses. */
-struct {
+struct epic100_bss {
        struct epic_rx_desc     rx_ring[RX_RING_SIZE]
        __attribute__ ((aligned(4)));
        struct epic_tx_desc     tx_ring[TX_RING_SIZE]
        __attribute__ ((aligned(4)));
        unsigned char           rx_packet[PKT_BUF_SZ * RX_RING_SIZE];
        unsigned char           tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
-} epic100_bufs __shared;
+};
+#define epic100_bufs NIC_FAKE_BSS ( struct epic100_bss )
 #define rx_ring epic100_bufs.rx_ring
 #define tx_ring epic100_bufs.tx_ring
 #define rx_packet epic100_bufs.rx_packet
@@ -525,7 +526,7 @@ PCI_ROM(0x10b8, 0x0006, "smc-83c175", "SMC EPIC/C 83c175", 0),
 PCI_DRIVER ( epic100_driver, epic100_nics, PCI_NO_CLASS );
 
 DRIVER ( "EPIC100", nic_driver, pci_driver, epic100_driver,
-        epic100_probe, epic100_disable );
+        epic100_probe, epic100_disable, epic100_bufs );
 
 /*
  * Local variables:
index 3b208a28bf4c33af893f350f49da41e291983379..b86f77fc8d275af3f46ab4e24a89c0c3ae554e42 100644 (file)
@@ -84,17 +84,22 @@ int legacy_probe ( void *hwdev,
                   void ( * set_drvdata ) ( void *hwdev, void *priv ),
                   struct device *dev,
                   int ( * probe ) ( struct nic *nic, void *hwdev ),
-                  void ( * disable ) ( struct nic *nic, void *hwdev ) ) {
+                  void ( * disable ) ( struct nic *nic, void *hwdev ),
+                  size_t fake_bss_len ) {
        struct net_device *netdev;
        struct nic *nic;
        int rc;
 
-       if ( legacy_registered )
-               return -EBUSY;
-       
+       if ( legacy_registered ) {
+               rc = -EBUSY;
+               goto err_registered;
+       }
+
        netdev = alloc_etherdev ( 0 );
-       if ( ! netdev )
-               return -ENOMEM;
+       if ( ! netdev ) {
+               rc = -ENOMEM;
+               goto err_alloc;
+       }
        netdev_init ( netdev, &legacy_operations );
        nic = &legacy_nic;
        netdev->priv = nic;
@@ -105,6 +110,15 @@ int legacy_probe ( void *hwdev,
        nic->node_addr = netdev->hw_addr;
        nic->irqno = dev->desc.irq;
 
+       if ( fake_bss_len ) {
+               nic->fake_bss = malloc_phys ( fake_bss_len, PAGE_SIZE );
+               if ( ! nic->fake_bss ) {
+                       rc = -ENOMEM;
+                       goto err_fake_bss;
+               }
+       }
+       nic->fake_bss_len = fake_bss_len;
+
        if ( ! probe ( nic, hwdev ) ) {
                rc = -ENODEV;
                goto err_probe;
@@ -133,8 +147,13 @@ int legacy_probe ( void *hwdev,
  err_register:
        disable ( nic, hwdev );
  err_probe:
+       if ( fake_bss_len )
+               free_phys ( nic->fake_bss, fake_bss_len );
+ err_fake_bss:
        netdev_nullify ( netdev );
        netdev_put ( netdev );
+ err_alloc:
+ err_registered:
        return rc;
 }
 
@@ -146,6 +165,8 @@ void legacy_remove ( void *hwdev,
 
        unregister_netdev ( netdev );
        disable ( nic, hwdev );
+       if ( nic->fake_bss_len )
+               free_phys ( nic->fake_bss, nic->fake_bss_len );
        netdev_nullify ( netdev );
        netdev_put ( netdev );
        legacy_registered = 0;
index a923fd3c575e04d10eb24c8f07f25f824548524a..8c8188af3f3f4a83d076b4c3ca4dc6d14cd3a48a 100644 (file)
@@ -370,6 +370,6 @@ ISA_DRIVER ( ne_driver, ne_probe_addrs, ne_probe1,
                GENERIC_ISAPNP_VENDOR, 0x0600 );
 
 DRIVER ( "ne", nic_driver, isapnp_driver, ne_driver,
-               ne_probe, ne_disable );
+        ne_probe, ne_disable, no_fake_bss );
 
 ISA_ROM("ne","NE1000/2000 and clones");
index a81ec6eeabd9c822603ed1effa1e4849ee9ffd8f..bc94aabe349c32b95b0b2ab0e725cdc388c6671a 100644 (file)
@@ -1022,7 +1022,7 @@ PCI_ROM(0x8e2e, 0x3000, "ktiet32p2",    "KTI ET32P2", 0),
 PCI_DRIVER ( nepci_driver, nepci_nics, PCI_NO_CLASS );
 
 DRIVER ( "NE2000/PCI", nic_driver, pci_driver, nepci_driver,
-        nepci_probe, ns8390_disable );
+        nepci_probe, ns8390_disable, no_fake_bss );
 
 #endif /* INCLUDE_NS8390 */
 
index 9940f76a77b01b4f02490cb39d184c52bcdc810b..128bdedc1ed711d6d2aa122ee7d3d4bc5bf1e08b 100644 (file)
@@ -55,7 +55,7 @@ PCI_ROM(0x1260, 0x3873, "prism2_pci", "Harris Semiconductor Prism2.5 clone", 0),
 PCI_DRIVER ( prism2_pci_driver, prism2_pci_nics, PCI_NO_CLASS );
 
 DRIVER ( "Prism2/PCI", nic_driver, pci_driver, prism2_pci_driver,
-        prism2_pci_probe, prism2_pci_disable );
+        prism2_pci_probe, prism2_pci_disable, no_fake_bss );
 
 /*
  * Local variables:
index f3200e89c3da247a0835292420b02b910eb95bd0..dac63ba9f8b669147ef5ae7e285d6cfb26eb07da 100644 (file)
@@ -119,9 +119,8 @@ PCI_ROM(0xec80, 0xec00, "f5d6000",       "Belkin F5D6000", 0),
 
 PCI_DRIVER ( prism2_plx_driver, prism2_plx_nics, PCI_NO_CLASS );
 
-
 DRIVER ( "Prism2/PLX", nic_driver, pci_driver, prism2_plx_driver,
-        prism2_plx_probe, prism2_plx_disable );
+        prism2_plx_probe, prism2_plx_disable, no_fake_bss );
 
 /*
  * Local variables:
index c8fd3e9b56c0bdd940922d593641cee9a0b41e68..59deb8df91d6331ca7493a8587e417a91e15925f 100644 (file)
@@ -65,12 +65,13 @@ static unsigned int cur_phy;
 
 static unsigned int cur_rx;
 
-struct {
+struct sis900_bss {
     BufferDesc txd;
     BufferDesc rxd[NUM_RX_DESC];
     unsigned char txb[TX_BUF_SIZE];
     unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE];
-} sis900_bufs __shared;
+};
+#define sis900_bufs NIC_FAKE_BSS ( struct sis900_bss )
 #define txd sis900_bufs.txd
 #define rxd sis900_bufs.rxd
 #define txb sis900_bufs.txb
@@ -1291,7 +1292,7 @@ PCI_ROM(0x1039, 0x7016, "sis7016", "SIS7016", 0),
 PCI_DRIVER ( sis900_driver, sis900_nics, PCI_NO_CLASS );
 
 DRIVER ( "SIS900", nic_driver, pci_driver, sis900_driver,
-        sis900_probe, sis900_disable );
+        sis900_probe, sis900_disable, sis900_bufs );
 
 /*
  * Local variables:
index c9762d580eab42ccc80624b9186b5629b6d1cef4..420aca9bd6d33d6628d67ad7d0a3b8c1579c2cb8 100644 (file)
@@ -939,7 +939,7 @@ ISA_DRIVER ( smc9000_driver, smc9000_probe_addrs, smc9000_probe_addr,
                     GENERIC_ISAPNP_VENDOR, 0x8228 );
 
 DRIVER ( "SMC9000", nic_driver, isa_driver, smc9000_driver,
-        smc9000_probe, smc9000_disable );
+        smc9000_probe, smc9000_disable, no_fake_bss );
 
 ISA_ROM ( "smc9000", "SMC9000" );
 
index 0439c983fd6f412dbce6e9f9c2e89f8fab6efdb6..964365ef67e512664be679f53c07a45bc7566681 100644 (file)
@@ -233,10 +233,11 @@ static struct netdev_desc rx_ring[RX_RING_SIZE];
 
 /* Create a static buffer of size PKT_BUF_SZ for each RX and TX descriptor.
    All descriptors point to a part of this buffer */
-struct {
+struct sundance_bss {
        unsigned char txb[PKT_BUF_SZ * TX_RING_SIZE];
        unsigned char rxb[RX_RING_SIZE * PKT_BUF_SZ];
-} rx_tx_buf __shared;
+};
+#define rx_tx_buf NIC_FAKE_BSS ( struct sundance_bss )
 #define rxb rx_tx_buf.rxb
 #define txb rx_tx_buf.txb
 
@@ -888,7 +889,7 @@ static struct pci_device_id sundance_nics[] = {
 PCI_DRIVER ( sundance_driver, sundance_nics, PCI_NO_CLASS );
 
 DRIVER ( "SUNDANCE/PCI", nic_driver, pci_driver, sundance_driver,
-        sundance_probe, sundance_disable );
+        sundance_probe, sundance_disable, rx_tx_buf );
 
 /*
  * Local variables:
index 245766a877c2186f161e49bf4d1a35ca458b44be..01193006fe59c451f7f48965481e5211623b6d80 100644 (file)
@@ -179,12 +179,13 @@ struct TLanList {
        } buffer[TLAN_BUFFERS_PER_LIST];
 };
 
-struct {
+struct tlan_bss {
        struct TLanList tx_ring[TLAN_NUM_TX_LISTS];
        unsigned char txb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_TX_LISTS];
        struct TLanList rx_ring[TLAN_NUM_RX_LISTS];
        unsigned char rxb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_RX_LISTS];
-} tlan_buffers __shared;
+};
+#define tlan_buffers NIC_FAKE_BSS ( struct tlan_bss )
 #define tx_ring tlan_buffers.tx_ring
 #define txb tlan_buffers.txb
 #define rx_ring tlan_buffers.rx_ring
@@ -1715,7 +1716,7 @@ static struct pci_device_id tlan_nics[] = {
 PCI_DRIVER ( tlan_driver, tlan_nics, PCI_NO_CLASS );
 
 DRIVER ( "TLAN/PCI", nic_driver, pci_driver, tlan_driver,
-        tlan_probe, tlan_disable );
+        tlan_probe, tlan_disable, tlan_buffers );
 
 /*
  * Local variables:
index c01bc208eebfd93c9ed39a2817d6e47e8b8439d7..1030e369853108ec82947ffee27c4f5f4513bc08 100644 (file)
@@ -426,13 +426,14 @@ struct tulip_private {
 
 #define TX_RING_SIZE   2
 #define RX_RING_SIZE   4
-struct {
+struct tulip_bss {
     struct tulip_tx_desc tx_ring[TX_RING_SIZE];
     unsigned char txb[BUFLEN];
     struct tulip_rx_desc rx_ring[RX_RING_SIZE];
     unsigned char rxb[RX_RING_SIZE * BUFLEN];
     struct tulip_private tpx;
-} tulip_bss __shared __attribute__ ((aligned(4)));
+};
+#define tulip_bss NIC_FAKE_BSS ( struct tulip_bss )
 #define tx_ring tulip_bss.tx_ring
 #define txb tulip_bss.txb
 #define rx_ring tulip_bss.rx_ring
@@ -1958,7 +1959,7 @@ PCI_ROM(0x8086, 0x0039, "intel21145",  "Intel Tulip", 0),
 PCI_DRIVER ( tulip_driver, tulip_nics, PCI_NO_CLASS );
 
 DRIVER ( "Tulip", nic_driver, pci_driver, tulip_driver,
-        tulip_probe, tulip_disable );
+        tulip_probe, tulip_disable, tulip_bss );
 
 /*
  * Local variables:
index 0c222214e0c62ec587e0b5fc04fecfc1cc9fa665..33a6658d2a3df8a559492d9d514fdb45fd183882 100644 (file)
@@ -254,10 +254,11 @@ static struct winbond_private
 
 static int ioaddr;
 static unsigned short eeprom [0x40];
-struct {
+struct w89c840_bss {
        char        rx_packet[PKT_BUF_SZ * RX_RING_SIZE];
        char        tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
-} w89c840_buf __shared;
+};
+#define w89c840_buf NIC_FAKE_BSS ( struct w89c840_bss )
 
 static int  eeprom_read(long ioaddr, int location);
 static int  mdio_read(int base_address, int phy_id, int location);
@@ -956,7 +957,7 @@ static void init_ring(void)
 
 
 DRIVER ( "W89C840F", nic_driver, pci_driver, w89c840_driver,
-        w89c840_probe, w89c840_disable );
+        w89c840_probe, w89c840_disable, w89c840_buf );
 
 /*
  * Local variables:
index ec03f6f96455ee44ee45b499db7ac9002acef41b..f8e9488293bb7fde1791f1c7585f89f9802ac889 100644 (file)
@@ -623,28 +623,6 @@ char __debug_disable(OBJECT) = ( DBGLVL_MAX & ~DBGLVL_DFLT );
  */
 #define inline inline __attribute__ (( no_instrument_function ))
 
-/**
- * Shared data.
- *
- * To save space in the binary when multiple-driver images are
- * compiled, uninitialised data areas can be shared between drivers.
- * This will typically be used to share statically-allocated receive
- * and transmit buffers between drivers.
- *
- * Use as e.g.
- *
- * @code
- *
- *   struct {
- *     char    rx_buf[NUM_RX_BUF][RX_BUF_SIZE];
- *     char    tx_buf[TX_BUF_SIZE];
- *   } my_static_data __shared;
- *
- * @endcode
- *
- */
-#define __shared __asm__ ( "_shared_bss" ) __aligned
-
 #endif /* ASSEMBLY */
 /** @} */
 
index 678e23075a8017e79a8e17d29a28fd8085de1fd4..779d1d3945b673810317e2b59900abee68e2004e 100644 (file)
@@ -57,8 +57,14 @@ struct nic {
        unsigned int            mbps;
        duplex_t                duplex;
        void                    *priv_data;     /* driver private data */
+       void                    *fake_bss;
+       size_t                  fake_bss_len;
 };
 
+#define NIC_FAKE_BSS_PTR( type ) ( ( type * ) legacy_nic.fake_bss )
+#define NIC_FAKE_BSS( type ) ( * NIC_FAKE_BSS_PTR ( type ) )
+extern struct {} no_fake_bss;
+
 struct nic_operations {
        int ( *connect ) ( struct nic * );
        int ( *poll ) ( struct nic *, int retrieve );
@@ -90,7 +96,8 @@ extern int legacy_probe ( void *hwdev,
                          void ( * set_drvdata ) ( void *hwdev, void *priv ),
                          struct device *dev,
                          int ( * probe ) ( struct nic *nic, void *hwdev ),
-                         void ( * disable ) ( struct nic *nic, void *hwdev ));
+                         void ( * disable ) ( struct nic *nic, void *hwdev ),
+                         size_t fake_bss_len );
 void legacy_remove ( void *hwdev,
                     void * ( * get_drvdata ) ( void *hwdev ),
                     void ( * disable ) ( struct nic *nic, void *hwdev ) );
@@ -210,7 +217,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) {
 }
 
 #undef DRIVER
-#define DRIVER(_name_text,_unused2,_unused3,_name,_probe,_disable)       \
+#define DRIVER( _name_text, _unused2, _unused3, _name, _probe, _disable,  \
+               _fake_bss )                                               \
        static __attribute__ (( unused )) const char                      \
        _name ## _text[] = _name_text;                                    \
        static inline int                                                 \
@@ -225,7 +233,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) {
        _name ## _pci_legacy_probe ( struct pci_device *pci ) {           \
                return legacy_probe ( pci, legacy_pci_set_drvdata,        \
                                      &pci->dev, _name ## _probe,         \
-                                     _name ## _disable );                \
+                                     _name ## _disable,                  \
+                                     sizeof ( _fake_bss ) );             \
        }                                                                 \
        static inline void                                                \
        _name ## _pci_legacy_remove ( struct pci_device *pci ) {          \
@@ -237,7 +246,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) {
                         const struct isapnp_device_id *id __unused ) {   \
                return legacy_probe ( isapnp, legacy_isapnp_set_drvdata,  \
                                      &isapnp->dev, _name ## _probe,      \
-                                     _name ## _disable );                \
+                                     _name ## _disable,                  \
+                                     sizeof ( _fake_bss ) );             \
        }                                                                 \
        static inline void                                                \
        _name ## _isapnp_legacy_remove ( struct isapnp_device *isapnp ) { \
@@ -249,7 +259,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) {
                             const struct eisa_device_id *id __unused ) { \
                return legacy_probe ( eisa, legacy_eisa_set_drvdata,      \
                                      &eisa->dev, _name ## _probe,        \
-                                     _name ## _disable );                \
+                                     _name ## _disable,                  \
+                                     sizeof ( _fake_bss ) );             \
        }                                                                 \
        static inline void                                                \
        _name ## _eisa_legacy_remove ( struct eisa_device *eisa ) {       \
@@ -261,7 +272,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) {
                              const struct mca_device_id *id __unused ) { \
                return legacy_probe ( mca, legacy_mca_set_drvdata,        \
                                      &mca->dev, _name ## _probe,         \
-                                     _name ## _disable );                \
+                                     _name ## _disable,                  \
+                                     sizeof ( _fake_bss ) );             \
        }                                                                 \
        static inline void                                                \
        _name ## _mca_legacy_remove ( struct mca_device *mca ) {          \
@@ -272,7 +284,8 @@ static inline void * legacy_isa_get_drvdata ( void *hwdev ) {
        _name ## _isa_legacy_probe ( struct isa_device *isa ) {           \
                return legacy_probe ( isa, legacy_isa_set_drvdata,        \
                                      &isa->dev, _name ## _probe,         \
-                                     _name ## _disable );                \
+                                     _name ## _disable,                  \
+                                     sizeof ( _fake_bss ) );             \
        }                                                                 \
        static inline void                                                \
        _name ## _isa_legacy_remove ( struct isa_device *isa ) {          \