1 /* 2 * Copyright (c) 1992 The Regents of the University of California. 3 * 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 * %sccs.include.redist.c% 10 * 11 * @(#)device.h 7.4 (Berkeley) 07/10/92 12 * 13 * from: $Header: device.h,v 1.6 92/06/11 17:56:45 torek Exp $ (LBL) 14 */ 15 16 /* 17 * Minimal device structures. 18 * Note that all ``system'' device types are listed here. 19 */ 20 enum devclass { 21 DV_DULL, /* generic, no special info */ 22 DV_CPU, /* CPU (carries resource utilization) */ 23 DV_DISK, /* disk drive (label, etc) */ 24 DV_IFNET, /* network interface */ 25 DV_TAPE, /* tape device */ 26 DV_TTY /* serial line interface (???) */ 27 }; 28 29 struct device { 30 enum devclass dv_class; /* this device's classification */ 31 struct device *dv_next; /* next in list of all */ 32 struct cfdata *dv_cfdata; /* config data that found us */ 33 char *dv_name; /* device name */ 34 int dv_unit; /* device unit number */ 35 char *dv_xname; /* expanded name (name + unit) */ 36 struct device *dv_parent; /* pointer to parent device */ 37 }; 38 39 /* 40 * Configuration data (i.e., data placed in ioconf.c). 41 */ 42 struct cfdata { 43 struct cfdriver *cf_driver; /* config driver */ 44 short cf_unit; /* unit number */ 45 short cf_fstate; /* finding state (below) */ 46 int *cf_loc; /* locators (machine dependent) */ 47 int cf_flags; /* flags from config */ 48 short *cf_parents; /* potential parents */ 49 void (**cf_ivstubs)(); /* config-generated vectors, if any */ 50 }; 51 #define FSTATE_NOTFOUND 0 /* has not been found */ 52 #define FSTATE_FOUND 1 /* has been found */ 53 #define FSTATE_STAR 2 /* duplicable */ 54 55 typedef int (*cfmatch_t) __P((struct device *, struct cfdata *, void *)); 56 57 /* 58 * `configuration' driver (what the machine-independent autoconf uses). 59 * As devices are found, they are applied against all the potential matches. 60 * The one with the best match is taken, and a device structure (plus any 61 * other data desired) is allocated. Pointers to these are placed into 62 * an array of pointers. The array itself must be dynamic since devices 63 * can be found long after the machine is up and running. 64 */ 65 struct cfdriver { 66 void **cd_devs; /* devices found */ 67 char *cd_name; /* device name */ 68 cfmatch_t cd_match; /* returns a match level */ 69 void (*cd_attach) __P((struct device *, struct device *, void *)); 70 enum devclass cd_class; /* device classification */ 71 size_t cd_devsize; /* size of dev data (for malloc) */ 72 void *cd_aux; /* additional driver, if any */ 73 int cd_ndevs; /* size of cd_devs array */ 74 }; 75 76 /* 77 * Configuration printing functions, and their return codes. The second 78 * argument is NULL if the device was configured; otherwise it is the name 79 * of the parent device. The return value is ignored if the device was 80 * configured, so most functions can return UNCONF unconditionally. 81 */ 82 typedef int (*cfprint_t) __P((void *, char *)); 83 #define QUIET 0 /* print nothing */ 84 #define UNCONF 1 /* print " not configured\n" */ 85 #define UNSUPP 2 /* print " not supported\n" */ 86 87 struct device *alldevs; /* head of list of all devices */ 88 89 struct cfdata *config_search __P((cfmatch_t, struct device *, void *)); 90 struct cfdata *config_rootsearch __P((cfmatch_t, char *, void *)); 91 int config_found __P((struct device *, void *, cfprint_t)); 92 int config_rootfound __P((char *, void *)); 93 void config_attach __P((struct device *, struct cfdata *, void *, cfprint_t)); 94