1 /* 2 * Copyright (c) 1992 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software developed by the Computer Systems 6 * Engineering group at Lawrence Berkeley Laboratory under DARPA 7 * contract BG 91-66 and contributed to Berkeley. 8 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)device.h 7.2 (Berkeley) 04/01/92 12 * 13 * from: $Header: device.h,v 1.3 92/01/15 18:25:53 torek Exp $ (LBL) 14 */ 15 16 /* 17 * Minimal device structures. 18 */ 19 enum devtype { DV_DULL, DV_DISK, DV_TAPE, DV_TTY }; 20 21 struct device { 22 /* enum devclass dv_class; /* class */ 23 char *dv_name; /* device name */ 24 int dv_unit; /* device unit number */ 25 int dv_flags; /* flags (copied from config) */ 26 char *dv_xname; /* expanded name (name + unit) */ 27 struct device *dv_parent; /* pointer to parent device */ 28 }; 29 30 /* 31 * Configuration data (i.e., data placed in ioconf.c). 32 */ 33 struct cfdata { 34 struct cfdriver *cf_driver; /* config driver */ 35 short cf_unit; /* unit number */ 36 short cf_fstate; /* finding state (below) */ 37 int *cf_loc; /* locators (machine dependent) */ 38 int cf_flags; /* flags from config */ 39 short *cf_parents; /* potential parents */ 40 void (**cf_ivstubs)(); /* config-generated vectors, if any */ 41 }; 42 #define FSTATE_NOTFOUND 0 /* has not been found */ 43 #define FSTATE_FOUND 1 /* has been found */ 44 #define FSTATE_STAR 2 /* duplicable leaf (unimplemented) */ 45 46 typedef int (*cfmatch_t) __P((struct device *, struct cfdata *, void *)); 47 48 /* 49 * `configuration' driver (what the machine-independent autoconf uses). 50 * As devices are found, they are applied against all the potential matches. 51 * The one with the best match is taken, and a device structure (plus any 52 * other data desired) is allocated. Pointers to these are placed into 53 * an array of pointers. The array itself must be dynamic since devices 54 * can be found long after the machine is up and running. 55 */ 56 struct cfdriver { 57 void **cd_devs; /* devices found */ 58 char *cd_name; /* device name */ 59 cfmatch_t cd_match; /* returns a match level */ 60 void (*cd_attach) __P((struct device *, struct device *, void *)); 61 size_t cd_devsize; /* size of dev data (for malloc) */ 62 void *cd_aux; /* additional driver, if any */ 63 int cd_ndevs; /* size of cd_devs array */ 64 }; 65 66 /* 67 * Configuration printing functions, and their return codes. The second 68 * argument is NULL if the device was configured; otherwise it is the name 69 * of the parent device. The return value is ignored if the device was 70 * configured, so most functions can return UNCONF unconditionally. 71 */ 72 typedef int (*cfprint_t) __P((void *, char *)); 73 #define QUIET 0 /* print nothing */ 74 #define UNCONF 1 /* print " not configured\n" */ 75 #define UNSUPP 2 /* print " not supported\n" */ 76 77 struct cfdata *config_search __P((cfmatch_t, struct device *, void *)); 78 struct cfdata *config_rootsearch __P((cfmatch_t, char *, void *)); 79 int config_found __P((struct device *, void *, cfprint_t)); 80 int config_rootfound __P((char *, void *)); 81 void config_attach __P((struct device *, struct cfdata *, void *, cfprint_t)); 82