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