1 /* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. 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 Laboratory. 13 * 14 * %sccs.include.redist.c% 15 * 16 * @(#)autoconf.h 8.2 (Berkeley) 09/30/93 17 * 18 * from: $Header: autoconf.h,v 1.11 93/09/28 05:26:41 leres 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 struct bootpath *ra_bp; /* used for locating boot device */ 47 }; 48 49 /* 50 * The various getprop* functions obtain `properties' from the ROMs. 51 * getprop() obtains a property as a byte-sequence, and returns its 52 * length; the others convert or make some other guarantee. 53 */ 54 int getprop __P((int node, char *name, void *buf, int bufsiz)); 55 char *getpropstring __P((int node, char *name)); 56 int getpropint __P((int node, char *name, int deflt)); 57 58 /* Frequently used options node */ 59 extern int optionsnode; 60 61 /* 62 * The romprop function gets physical and virtual addresses from the PROM 63 * and fills in a romaux. It returns 1 on success, 0 if the physical 64 * address is not available as a "reg" property. 65 */ 66 int romprop __P((struct romaux *ra, const char *name, int node)); 67 68 /* 69 * The matchbyname function is useful in drivers that are matched 70 * by romaux name, i.e., all `mainbus attached' devices. It expects 71 * its aux pointer to point to a pointer to the name (the address of 72 * a romaux structure suffices, for instance). 73 */ 74 int matchbyname __P((struct device *, struct cfdata *cf, void *aux)); 75 76 /* 77 * `clockfreq' produces a printable representation of a clock frequency 78 * (this is just a frill). 79 */ 80 char *clockfreq __P((int freq)); 81 82 /* 83 * mapiodev maps an I/O device to a virtual address, returning the address. 84 * mapdev does the real work: you can supply a special virtual address and 85 * it will use that instead of creating one, but you must only do this if 86 * you get it from ../sparc/vaddrs.h. 87 */ 88 void *mapdev __P((void *pa, int va, int size)); 89 #define mapiodev(pa, size) mapdev(pa, 0, size) 90 91 /* 92 * Memory description arrays. Shared between pmap.c and autoconf.c; no 93 * one else should use this (except maybe mem.c, e.g., if we fix the VM to 94 * handle discontiguous physical memory). 95 */ 96 struct memarr { 97 u_int addr; 98 u_int len; 99 }; 100 int makememarr(struct memarr *, int max, int which); 101 #define MEMARR_AVAILPHYS 0 102 #define MEMARR_TOTALPHYS 1 103 104 /* Pass a string to the FORTH interpreter. May fail silently. */ 105 void rominterpret __P((char *)); 106 107 /* Openprom V2 style boot path */ 108 struct bootpath { 109 char name[8]; /* name of this node */ 110 int val[2]; /* up to two optional values */ 111 }; 112 113 struct device *bootdv; /* found during autoconfiguration */ 114 115 /* Parse a disk string into a dev_t, return device struct pointer */ 116 struct device *parsedisk __P((char *, int, int, dev_t *)); 117