patch-2.1.105 linux/drivers/net/8390.h
Next file: linux/drivers/net/Config.in
Previous file: linux/drivers/net/8390.c
Back to the patch index
Back to the overall index
- Lines: 145
- Date:
Sun Jun 7 10:37:41 1998
- Orig file:
v2.1.104/linux/drivers/net/8390.h
- Orig date:
Thu May 14 19:47:39 1998
diff -u --recursive --new-file v2.1.104/linux/drivers/net/8390.h linux/drivers/net/8390.h
@@ -1,6 +1,6 @@
/* Generic NS8390 register definitions. */
/* This file is part of Donald Becker's 8390 drivers, and is distributed
- under the same license.
+ under the same license. Auto-loading of 8390.o added by Paul Gortmaker.
Some of these names and comments originated from the Crynwr
packet drivers, which are distributed under the GPL. */
@@ -12,6 +12,11 @@
#include <linux/ioport.h>
#include <linux/skbuff.h>
+/* With kmod, drivers can now load the 8390 module themselves! */
+#ifdef CONFIG_KMOD
+#define LOAD_8390_BY_KMOD
+#endif
+
#define TX_2X_PAGES 12
#define TX_1X_PAGES 6
@@ -33,21 +38,117 @@
unsigned short count; /* header + packet length in bytes */
};
-/* From 8390.c */
+#ifdef notdef
extern int ei_debug;
-extern struct sigaction ei_sigaction;
+#else
+#define ei_debug 1
+#endif
-extern int ethif_init(struct device *dev);
+#ifndef HAVE_AUTOIRQ
+/* From auto_irq.c */
+extern void autoirq_setup(int waittime);
+extern unsigned long autoirq_report(int waittime);
+#endif
+
+#if defined(LOAD_8390_BY_KMOD) && defined(MODULE) && !defined(NS8390_CORE)
+
+/* Function pointers to be mapped onto the 8390 core support */
+static int (*S_ethdev_init)(struct device *dev);
+static void (*S_NS8390_init)(struct device *dev, int startp);
+static int (*S_ei_open)(struct device *dev);
+static int (*S_ei_close)(struct device *dev);
+static void (*S_ei_interrupt)(int irq, void *dev_id, struct pt_regs *regs);
+
+
+#define NS8390_KSYSMS_PRESENT ( \
+ get_module_symbol(NULL, "ethdev_init") != 0 && \
+ get_module_symbol(NULL, "NS8390_init") != 0 && \
+ get_module_symbol(NULL, "ei_open") != 0 && \
+ get_module_symbol(NULL, "ei_close") != 0 && \
+ get_module_symbol(NULL, "ei_interrupt") != 0)
+
+extern __inline__ int load_8390_module(const char *driver)
+{
+
+ if (! NS8390_KSYSMS_PRESENT) {
+ int (*request_mod)(const char *module_name);
+
+ if (get_module_symbol("", "request_module") == 0) {
+ printk("%s: module auto-load (kmod) support not present.\n", driver);
+ printk("%s: unable to auto-load required 8390 module.\n", driver);
+ printk("%s: try \"modprobe 8390\" as root 1st.\n", driver);
+ return -ENOSYS;
+ }
+
+ request_mod = (void*)get_module_symbol("", "request_module");
+ if (request_mod("8390")) {
+ printk("%s: request to load the 8390 module failed.\n", driver);
+ return -ENOSYS;
+ }
+
+ /* Check if module really loaded and is valid */
+ if (! NS8390_KSYSMS_PRESENT) {
+ printk("%s: 8390.o not found/invalid or failed to load.\n", driver);
+ return -ENOSYS;
+ }
+
+ printk(KERN_INFO "%s: auto-loaded 8390 module.\n", driver);
+ }
+
+ /* Map the functions into place */
+ S_ethdev_init = (void*)get_module_symbol(0, "ethdev_init");
+ S_NS8390_init = (void*)get_module_symbol(0, "NS8390_init");
+ S_ei_open = (void*)get_module_symbol(0, "ei_open");
+ S_ei_close = (void*)get_module_symbol(0, "ei_close");
+ S_ei_interrupt = (void*)get_module_symbol(0, "ei_interrupt");
+
+ return 0;
+}
+
+/*
+ * Since a kmod aware driver won't explicitly show a dependence on the
+ * exported 8390 functions (due to the mapping above), the 8390 module
+ * (if present, and not in-kernel) needs to be protected from garbage
+ * collection. NS8390_module is only defined for a modular 8390 core.
+ */
+
+extern __inline__ void lock_8390_module(void)
+{
+ struct module **mod = (struct module**)get_module_symbol(0, "NS8390_module");
+
+ if (mod != NULL && *mod != NULL)
+ __MOD_INC_USE_COUNT(*mod);
+}
+
+extern __inline__ void unlock_8390_module(void)
+{
+ struct module **mod = (struct module**)get_module_symbol(0, "NS8390_module");
+
+ if (mod != NULL && *mod != NULL)
+ __MOD_DEC_USE_COUNT(*mod);
+}
+
+/*
+ * These are last so they only have scope over the driver
+ * code (wd, ne, 3c503, etc.) and not over the above code.
+ */
+#define ethdev_init S_ethdev_init
+#define NS8390_init S_NS8390_init
+#define ei_open S_ei_open
+#define ei_close S_ei_close
+#define ei_interrupt S_ei_interrupt
+
+#else /* not a module or kmod support not wanted */
+
+#define load_8390_module(driver) 0
+#define lock_8390_module() do { } while (0)
+#define unlock_8390_module() do { } while (0)
extern int ethdev_init(struct device *dev);
extern void NS8390_init(struct device *dev, int startp);
extern int ei_open(struct device *dev);
extern int ei_close(struct device *dev);
extern void ei_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-#ifndef HAVE_AUTOIRQ
-/* From auto_irq.c */
-extern void autoirq_setup(int waittime);
-extern unsigned long autoirq_report(int waittime);
#endif
/* Most of these entries should be in 'struct device' (or most of the
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov