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