0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include <linux/netdevice.h>
0027 #include <linux/etherdevice.h>
0028 #include <linux/errno.h>
0029 #include <linux/init.h>
0030 #include <linux/netlink.h>
0031 #include <net/Space.h>
0032
0033
0034
0035
0036
0037 struct netdev_boot_setup {
0038 char name[IFNAMSIZ];
0039 struct ifmap map;
0040 };
0041 #define NETDEV_BOOT_SETUP_MAX 8
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 static struct netdev_boot_setup dev_boot_setup[NETDEV_BOOT_SETUP_MAX];
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 static int netdev_boot_setup_add(char *name, struct ifmap *map)
0063 {
0064 struct netdev_boot_setup *s;
0065 int i;
0066
0067 s = dev_boot_setup;
0068 for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
0069 if (s[i].name[0] == '\0' || s[i].name[0] == ' ') {
0070 memset(s[i].name, 0, sizeof(s[i].name));
0071 strlcpy(s[i].name, name, IFNAMSIZ);
0072 memcpy(&s[i].map, map, sizeof(s[i].map));
0073 break;
0074 }
0075 }
0076
0077 return i >= NETDEV_BOOT_SETUP_MAX ? 0 : 1;
0078 }
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 int netdev_boot_setup_check(struct net_device *dev)
0090 {
0091 struct netdev_boot_setup *s = dev_boot_setup;
0092 int i;
0093
0094 for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
0095 if (s[i].name[0] != '\0' && s[i].name[0] != ' ' &&
0096 !strcmp(dev->name, s[i].name)) {
0097 dev->irq = s[i].map.irq;
0098 dev->base_addr = s[i].map.base_addr;
0099 dev->mem_start = s[i].map.mem_start;
0100 dev->mem_end = s[i].map.mem_end;
0101 return 1;
0102 }
0103 }
0104 return 0;
0105 }
0106 EXPORT_SYMBOL(netdev_boot_setup_check);
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118 static unsigned long netdev_boot_base(const char *prefix, int unit)
0119 {
0120 const struct netdev_boot_setup *s = dev_boot_setup;
0121 char name[IFNAMSIZ];
0122 int i;
0123
0124 sprintf(name, "%s%d", prefix, unit);
0125
0126
0127
0128
0129
0130 if (__dev_get_by_name(&init_net, name))
0131 return 1;
0132
0133 for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++)
0134 if (!strcmp(name, s[i].name))
0135 return s[i].map.base_addr;
0136 return 0;
0137 }
0138
0139
0140
0141
0142 static int __init netdev_boot_setup(char *str)
0143 {
0144 int ints[5];
0145 struct ifmap map;
0146
0147 str = get_options(str, ARRAY_SIZE(ints), ints);
0148 if (!str || !*str)
0149 return 0;
0150
0151
0152 memset(&map, 0, sizeof(map));
0153 if (ints[0] > 0)
0154 map.irq = ints[1];
0155 if (ints[0] > 1)
0156 map.base_addr = ints[2];
0157 if (ints[0] > 2)
0158 map.mem_start = ints[3];
0159 if (ints[0] > 3)
0160 map.mem_end = ints[4];
0161
0162
0163 return netdev_boot_setup_add(str, &map);
0164 }
0165
0166 __setup("netdev=", netdev_boot_setup);
0167
0168 static int __init ether_boot_setup(char *str)
0169 {
0170 return netdev_boot_setup(str);
0171 }
0172 __setup("ether=", ether_boot_setup);
0173
0174
0175
0176
0177
0178
0179 struct devprobe2 {
0180 struct net_device *(*probe)(int unit);
0181 int status;
0182 };
0183
0184 static int __init probe_list2(int unit, struct devprobe2 *p, int autoprobe)
0185 {
0186 struct net_device *dev;
0187
0188 for (; p->probe; p++) {
0189 if (autoprobe && p->status)
0190 continue;
0191 dev = p->probe(unit);
0192 if (!IS_ERR(dev))
0193 return 0;
0194 if (autoprobe)
0195 p->status = PTR_ERR(dev);
0196 }
0197 return -ENODEV;
0198 }
0199
0200
0201
0202
0203 static struct devprobe2 isa_probes[] __initdata = {
0204 #ifdef CONFIG_3C515
0205 {tc515_probe, 0},
0206 #endif
0207 #ifdef CONFIG_ULTRA
0208 {ultra_probe, 0},
0209 #endif
0210 #ifdef CONFIG_WD80x3
0211 {wd_probe, 0},
0212 #endif
0213 #if defined(CONFIG_NE2000)
0214 {ne_probe, 0},
0215 #endif
0216 #ifdef CONFIG_LANCE
0217 {lance_probe, 0},
0218 #endif
0219 #ifdef CONFIG_SMC9194
0220 {smc_init, 0},
0221 #endif
0222 #ifdef CONFIG_CS89x0_ISA
0223 {cs89x0_probe, 0},
0224 #endif
0225 {NULL, 0},
0226 };
0227
0228
0229
0230
0231
0232 static void __init ethif_probe2(int unit)
0233 {
0234 unsigned long base_addr = netdev_boot_base("eth", unit);
0235
0236 if (base_addr == 1)
0237 return;
0238
0239 probe_list2(unit, isa_probes, base_addr == 0);
0240 }
0241
0242
0243 static int __init net_olddevs_init(void)
0244 {
0245 int num;
0246
0247 for (num = 0; num < 8; ++num)
0248 ethif_probe2(num);
0249
0250 #ifdef CONFIG_COPS
0251 cops_probe(0);
0252 cops_probe(1);
0253 cops_probe(2);
0254 #endif
0255
0256 return 0;
0257 }
0258
0259 device_initcall(net_olddevs_init);