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 * 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 Laboratories. 13 * 14 * %sccs.include.redist.c% 15 * 16 * @(#)autoconf.h 7.2 (Berkeley) 07/21/92 17 * 18 * from: $Header: autoconf.h,v 1.8 92/06/24 08:55:42 torek Exp $ (LBL) 19 */ 20 21 /* 22 * Autoconfiguration information. 23 */ 24 25 /* 26 * Most devices are configured according to information kept in 27 * the FORTH PROMs. In particular, we extract the `name', `reg', 28 * and `address' properties of each device attached to the mainbus; 29 * other drives may also use this information. The mainbus itself 30 * (which `is' the CPU, in some sense) gets just the node, with a 31 * fake name ("mainbus"). 32 */ 33 #define RA_MAXINTR 8 /* max interrupts per device */ 34 struct romaux { 35 const char *ra_name; /* name from FORTH PROM */ 36 int ra_node; /* FORTH PROM node ID */ 37 int ra_iospace; /* register space (obio, etc) */ 38 void *ra_paddr; /* register physical address */ 39 int ra_len; /* register length */ 40 void *ra_vaddr; /* ROM mapped virtual address, or 0 */ 41 struct rom_intr { /* interrupt information: */ 42 int int_pri; /* priority (IPL) */ 43 int int_vec; /* vector (always 0?) */ 44 } ra_intr[RA_MAXINTR]; 45 int ra_nintr; /* number of interrupt info elements */ 46 }; 47 48 /* 49 * The various getprop* functions obtain `properties' from the ROMs. 50 * getprop() obtains a property as a byte-sequence, and returns its 51 * length; the others convert or make some other guarantee. 52 */ 53 int getprop __P((int node, char *name, void *buf, int bufsiz)); 54 char *getpropstring __P((int node, char *name)); 55 int getpropint __P((int node, char *name, int deflt)); 56 57 /* Frequently used options node */ 58 extern int optionsnode; 59 60 /* 61 * The romprop function gets physical and virtual addresses from the PROM 62 * and fills in a romaux. It returns 1 on success, 0 if the physical 63 * address is not available as a "reg" property. 64 */ 65 int romprop __P((struct romaux *ra, const char *name, int node)); 66 67 /* 68 * The matchbyname function is useful in drivers that are matched 69 * by romaux name, i.e., all `mainbus attached' devices. It expects 70 * its aux pointer to point to a pointer to the name (the address of 71 * a romaux structure suffices, for instance). 72 */ 73 int matchbyname __P((struct device *, struct cfdata *cf, void *aux)); 74 75 /* 76 * `clockfreq' produces a printable representation of a clock frequency 77 * (this is just a frill). 78 */ 79 char *clockfreq __P((int freq)); 80 81 /* 82 * mapiodev maps an I/O device to a virtual address, returning the address. 83 * mapdev does the real work: you can supply a special virtual address and 84 * it will use that instead of creating one, but you must only do this if 85 * you get it from ../sparc/vaddrs.h. 86 */ 87 void *mapdev __P((void *pa, int va, int size)); 88 #define mapiodev(pa, size) mapdev(pa, 0, size) 89 90 /* 91 * Memory description arrays. Shared between pmap.c and autoconf.c; no 92 * one else should use this (except maybe mem.c, e.g., if we fix the VM to 93 * handle discontiguous physical memory). 94 */ 95 struct memarr { 96 u_int addr; 97 u_int len; 98 }; 99 int makememarr(struct memarr *, int max, int which); 100 #define MEMARR_AVAILPHYS 0 101 #define MEMARR_TOTALPHYS 1 102 103 /* Pass a string to the FORTH interpreter. May fail silently. */ 104 void rominterpret __P((char *)); 105