1*6dfc32acSmiod /* $OpenBSD: autoconf.h,v 1.20 2024/05/17 20:05:08 miod Exp $ */ 2df39fa9dSjason /* $NetBSD: autoconf.h,v 1.10 2001/07/24 19:32:11 eeh Exp $ */ 3df39fa9dSjason 4df39fa9dSjason /*- 5df39fa9dSjason * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 6df39fa9dSjason * All rights reserved. 7df39fa9dSjason * 8df39fa9dSjason * This code is derived from software contributed to The NetBSD Foundation 9df39fa9dSjason * by Paul Kranenburg. 10df39fa9dSjason * 11df39fa9dSjason * Redistribution and use in source and binary forms, with or without 12df39fa9dSjason * modification, are permitted provided that the following conditions 13df39fa9dSjason * are met: 14df39fa9dSjason * 1. Redistributions of source code must retain the above copyright 15df39fa9dSjason * notice, this list of conditions and the following disclaimer. 16df39fa9dSjason * 2. Redistributions in binary form must reproduce the above copyright 17df39fa9dSjason * notice, this list of conditions and the following disclaimer in the 18df39fa9dSjason * documentation and/or other materials provided with the distribution. 19df39fa9dSjason * 20df39fa9dSjason * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21df39fa9dSjason * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22df39fa9dSjason * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23df39fa9dSjason * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24df39fa9dSjason * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25df39fa9dSjason * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26df39fa9dSjason * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27df39fa9dSjason * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28df39fa9dSjason * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29df39fa9dSjason * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30df39fa9dSjason * POSSIBILITY OF SUCH DAMAGE. 31df39fa9dSjason */ 32df39fa9dSjason 33df39fa9dSjason /* 34df39fa9dSjason * Copyright (c) 1992, 1993 35df39fa9dSjason * The Regents of the University of California. All rights reserved. 36df39fa9dSjason * 37df39fa9dSjason * This software was developed by the Computer Systems Engineering group 38df39fa9dSjason * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 39df39fa9dSjason * contributed to Berkeley. 40df39fa9dSjason * 41df39fa9dSjason * All advertising materials mentioning features or use of this software 42df39fa9dSjason * must display the following acknowledgement: 43df39fa9dSjason * This product includes software developed by the University of 44df39fa9dSjason * California, Lawrence Berkeley Laboratory. 45df39fa9dSjason * 46df39fa9dSjason * Redistribution and use in source and binary forms, with or without 47df39fa9dSjason * modification, are permitted provided that the following conditions 48df39fa9dSjason * are met: 49df39fa9dSjason * 1. Redistributions of source code must retain the above copyright 50df39fa9dSjason * notice, this list of conditions and the following disclaimer. 51df39fa9dSjason * 2. Redistributions in binary form must reproduce the above copyright 52df39fa9dSjason * notice, this list of conditions and the following disclaimer in the 53df39fa9dSjason * documentation and/or other materials provided with the distribution. 5429295d1cSmillert * 3. Neither the name of the University nor the names of its contributors 55df39fa9dSjason * may be used to endorse or promote products derived from this software 56df39fa9dSjason * without specific prior written permission. 57df39fa9dSjason * 58df39fa9dSjason * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 59df39fa9dSjason * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 60df39fa9dSjason * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 61df39fa9dSjason * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 62df39fa9dSjason * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 63df39fa9dSjason * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 64df39fa9dSjason * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 65df39fa9dSjason * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 66df39fa9dSjason * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 67df39fa9dSjason * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 68df39fa9dSjason * SUCH DAMAGE. 69df39fa9dSjason * 70df39fa9dSjason * @(#)autoconf.h 8.2 (Berkeley) 9/30/93 71df39fa9dSjason */ 72df39fa9dSjason 73df39fa9dSjason /* 74df39fa9dSjason * Autoconfiguration information. 75df39fa9dSjason */ 76df39fa9dSjason 77df39fa9dSjason #include <machine/bus.h> 78df39fa9dSjason #include <dev/sbus/sbusvar.h> 79df39fa9dSjason 80df39fa9dSjason /* This is used to map device classes to IPLs */ 81df39fa9dSjason struct intrmap { 82df39fa9dSjason char *in_class; 83df39fa9dSjason int in_lev; 84df39fa9dSjason }; 85df39fa9dSjason extern struct intrmap intrmap[]; 86df39fa9dSjason 87df39fa9dSjason /* The "mainbus" on ultra desktops is actually the UPA bus. We need to 88d277156aSsobrado * separate this from peripheral buses like SBus and PCI because each bus may 89df39fa9dSjason * have different ways of encoding properties, such as "reg" and "interrupts". 90df39fa9dSjason */ 91df39fa9dSjason 924f2edc4eSmiod /* Device register space description */ 934f2edc4eSmiod struct upa_reg { 944f2edc4eSmiod int64_t ur_paddr; 954f2edc4eSmiod int64_t ur_len; 964f2edc4eSmiod }; 974f2edc4eSmiod 98df39fa9dSjason /* 99df39fa9dSjason * Attach arguments presented by mainbus_attach() 100df39fa9dSjason * 101df39fa9dSjason * Large fields first followed by smaller ones to minimize stack space used. 102df39fa9dSjason */ 103df39fa9dSjason struct mainbus_attach_args { 104df39fa9dSjason bus_space_tag_t ma_bustag; /* parent bus tag */ 105df39fa9dSjason bus_dma_tag_t ma_dmatag; 106df39fa9dSjason char *ma_name; /* PROM node name */ 107df39fa9dSjason struct upa_reg *ma_reg; /* "reg" properties */ 108df39fa9dSjason u_int *ma_address; /* "address" properties -- 32 bits */ 109df39fa9dSjason u_int *ma_interrupts; /* "interrupts" properties */ 110df39fa9dSjason int ma_upaid; /* UPA bus ID */ 111df39fa9dSjason int ma_node; /* PROM handle */ 112df39fa9dSjason int ma_nreg; /* Counts for those properties */ 113df39fa9dSjason int ma_naddress; 114df39fa9dSjason int ma_ninterrupts; 115df39fa9dSjason int ma_pri; /* priority (IPL) */ 116df39fa9dSjason }; 117df39fa9dSjason 118df39fa9dSjason /* 119df39fa9dSjason * length; the others convert or make some other guarantee. 120df39fa9dSjason */ 121c4071fd1Smillert long getproplen(int node, char *name); 122c4071fd1Smillert int getprop(int, char *, size_t, int *, void **); 123c4071fd1Smillert char *getpropstring(int node, char *name); 124c4071fd1Smillert int getpropint(int node, char *name, int deflt); 125fa65087eSkettenis int getpropspeed(int node, char *name); 126df39fa9dSjason 127df39fa9dSjason /* Frequently used options node */ 128df39fa9dSjason extern int optionsnode; 129df39fa9dSjason 130df39fa9dSjason /* new interfaces: */ 131c4071fd1Smillert char *getpropstringA(int, char *, char *); 132df39fa9dSjason 133df39fa9dSjason /* 134df39fa9dSjason * `clockfreq' produces a printable representation of a clock frequency 135df39fa9dSjason * (this is just a frill). 136df39fa9dSjason */ 137c4071fd1Smillert char *clockfreq(long freq); 138df39fa9dSjason 139df39fa9dSjason /* Openprom V2 style boot path */ 140e4c60fd4Smiod struct device; 141df39fa9dSjason struct bootpath { 142fb1ca35cSkettenis int node; 143df39fa9dSjason char name[16]; /* name of this node */ 144c5632f19Sjason long val[3]; /* up to three optional values */ 145df39fa9dSjason struct device *dev; /* device that recognised this component */ 146df39fa9dSjason }; 147c4071fd1Smillert struct bootpath *bootpath_store(int, struct bootpath *); 148df39fa9dSjason 149c4071fd1Smillert void bootstrap(int); 150c4071fd1Smillert int firstchild(int); 151c4071fd1Smillert int nextsibling(int); 152c4071fd1Smillert void callrom(void); 153*6dfc32acSmiod struct device *getdevunit(const char *, int); 154c4071fd1Smillert int romgetcursoraddr(int **, int **); 155c4071fd1Smillert int findroot(void); 156c4071fd1Smillert int findnode(int, const char *); 1575adfdce9Skettenis int checkstatus(int); 158c4071fd1Smillert int node_has_property(int, const char *); 159c4071fd1Smillert void device_register(struct device *, void *); 160