1 /* 2 * ddi.c Implement the Device Driver Interface (DDI) routines. 3 * Currently, this is only used by the NET layer of LINUX, 4 * but it eventually might move to an upper directory of 5 * the system. 6 * 7 * Version: @(#)ddi.c 1.0.5 04/22/93 8 * 9 * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> 10 */ 11 #include <asm/segment.h>
12 #include <asm/system.h>
13 #include <linux/types.h>
14 #include <linux/config.h>
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/string.h>
18 #include <linux/mm.h>
19 #include <linux/socket.h>
20 #include <linux/ddi.h>
21
22
23 #undefDDI_DEBUG 24 #ifdefDDI_DEBUG 25 # definePRINTK(x) printkx 26 #else 27 # definePRINTK(x) /**/ 28 #endif 29
30
31 externstructddi_devicedevices[]; /* device driver map */ 32 externstructddi_protoprotocols[]; /* network protocols */ 33
34
35 /* 36 * This function gets called with an ASCII string representing the 37 * ID of some DDI driver. We loop through the DDI Devices table 38 * and return the address of the control block that has a matching 39 * "name" field. It is used by upper-level layers that want to 40 * dynamically bind some UNIX-domain "/dev/XXXX" file name to a 41 * DDI device driver. The "iflink(8)" program is an example of 42 * this behaviour. 43 */ 44 structddi_device *
45 ddi_map(constchar *id)
/* */ 46 { 47 registerstructddi_device *dev;
48
49 PRINTK (("DDI: MAP: looking for \"%s\": ", id));
50 dev = devices;
51 while (dev->title != NULL) { 52 if (strncmp(dev->name, id, DDI_MAXNAME) == 0) { 53 PRINTK (("OK at 0x%X\n", dev));
54 return(dev);
55 } 56 dev++;
57 } 58 PRINTK (("NOT FOUND\n"));
59 return(NULL);
60 } 61
62
63 /* 64 * This is the function that is called by a kernel routine during 65 * system startup. Its purpose is to walk trough the "devices" 66 * table (defined above), and to call all moduled defined in it. 67 */ 68 void 69 ddi_init(void)
/* */ 70 { 71 structddi_proto *pro;
72 structddi_device *dev;
73
74 PRINTK (("DDI: Starting up!\n"));
75
76 /* First off, kick all configured protocols. */ 77 pro = protocols;
78 while (pro->name != NULL) { 79 (*pro->init)(pro);
80 pro++;
81 } 82
83 /* Done. Now kick all configured device drivers. */ 84 dev = devices;
85 while (dev->title != NULL) { 86 (*dev->init)(dev);
87 dev++;
88 } 89
90 /* We're all done... */ 91 }