1 /* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * 9 * All advertising materials mentioning features or use of this software 10 * must display the following acknowledgement: 11 * This product includes software developed by the University of 12 * California, Lawrence Berkeley Laboratory. 13 * 14 * %sccs.include.redist.c% 15 * 16 * @(#)device.h 8.1 (Berkeley) 06/02/93 17 * 18 * from: $Header: device.h,v 1.9 93/02/01 19:34:50 torek Exp $ (LBL) 19 */ 20 21 /* 22 * Minimal device structures. 23 * Note that all ``system'' device types are listed here. 24 */ 25 enum devclass { 26 DV_DULL, /* generic, no special info */ 27 DV_CPU, /* CPU (carries resource utilization) */ 28 DV_DISK, /* disk drive (label, etc) */ 29 DV_IFNET, /* network interface */ 30 DV_TAPE, /* tape device */ 31 DV_TTY /* serial line interface (???) */ 32 }; 33 34 struct device { 35 enum devclass dv_class; /* this device's classification */ 36 struct device *dv_next; /* next in list of all */ 37 struct cfdata *dv_cfdata; /* config data that found us */ 38 int dv_unit; /* device unit number */ 39 char dv_xname[16]; /* external name (name + unit) */ 40 struct device *dv_parent; /* pointer to parent device */ 41 }; 42 43 /* `event' counters (use zero or more per device instance, as needed) */ 44 struct evcnt { 45 struct evcnt *ev_next; /* linked list */ 46 struct device *ev_dev; /* associated device */ 47 int ev_count; /* how many have occurred */ 48 char ev_name[8]; /* what to call them (systat display) */ 49 }; 50 51 /* 52 * Configuration data (i.e., data placed in ioconf.c). 53 */ 54 struct cfdata { 55 struct cfdriver *cf_driver; /* config driver */ 56 short cf_unit; /* unit number */ 57 short cf_fstate; /* finding state (below) */ 58 int *cf_loc; /* locators (machine dependent) */ 59 int cf_flags; /* flags from config */ 60 short *cf_parents; /* potential parents */ 61 void (**cf_ivstubs)(); /* config-generated vectors, if any */ 62 }; 63 #define FSTATE_NOTFOUND 0 /* has not been found */ 64 #define FSTATE_FOUND 1 /* has been found */ 65 #define FSTATE_STAR 2 /* duplicable */ 66 67 typedef int (*cfmatch_t) __P((struct device *, struct cfdata *, void *)); 68 69 /* 70 * `configuration' driver (what the machine-independent autoconf uses). 71 * As devices are found, they are applied against all the potential matches. 72 * The one with the best match is taken, and a device structure (plus any 73 * other data desired) is allocated. Pointers to these are placed into 74 * an array of pointers. The array itself must be dynamic since devices 75 * can be found long after the machine is up and running. 76 */ 77 struct cfdriver { 78 void **cd_devs; /* devices found */ 79 char *cd_name; /* device name */ 80 cfmatch_t cd_match; /* returns a match level */ 81 void (*cd_attach) __P((struct device *, struct device *, void *)); 82 enum devclass cd_class; /* device classification */ 83 size_t cd_devsize; /* size of dev data (for malloc) */ 84 void *cd_aux; /* additional driver, if any */ 85 int cd_ndevs; /* size of cd_devs array */ 86 }; 87 88 /* 89 * Configuration printing functions, and their return codes. The second 90 * argument is NULL if the device was configured; otherwise it is the name 91 * of the parent device. The return value is ignored if the device was 92 * configured, so most functions can return UNCONF unconditionally. 93 */ 94 typedef int (*cfprint_t) __P((void *, char *)); 95 #define QUIET 0 /* print nothing */ 96 #define UNCONF 1 /* print " not configured\n" */ 97 #define UNSUPP 2 /* print " not supported\n" */ 98 99 /* 100 * Pseudo-device attach information (function + number of pseudo-devs). 101 */ 102 struct pdevinit { 103 void (*pdev_attach) __P((int)); 104 int pdev_count; 105 }; 106 107 struct device *alldevs; /* head of list of all devices */ 108 struct evcnt *allevents; /* head of list of all events */ 109 110 struct cfdata *config_search __P((cfmatch_t, struct device *, void *)); 111 struct cfdata *config_rootsearch __P((cfmatch_t, char *, void *)); 112 int config_found __P((struct device *, void *, cfprint_t)); 113 int config_rootfound __P((char *, void *)); 114 void config_attach __P((struct device *, struct cfdata *, void *, cfprint_t)); 115 void evcnt_attach __P((struct device *, const char *, struct evcnt *)); 116