Home | History | Annotate | Line # | Download | only in ev64260
mainbus.c revision 1.4
      1  1.4  lukem /*	$NetBSD: mainbus.c,v 1.4 2003/07/15 01:37:35 lukem Exp $	*/
      2  1.1   matt 
      3  1.1   matt /*
      4  1.1   matt  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
      5  1.1   matt  *
      6  1.1   matt  * Redistribution and use in source and binary forms, with or without
      7  1.1   matt  * modification, are permitted provided that the following conditions
      8  1.1   matt  * are met:
      9  1.1   matt  * 1. Redistributions of source code must retain the above copyright
     10  1.1   matt  *    notice, this list of conditions and the following disclaimer.
     11  1.1   matt  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1   matt  *    notice, this list of conditions and the following disclaimer in the
     13  1.1   matt  *    documentation and/or other materials provided with the distribution.
     14  1.1   matt  * 3. All advertising materials mentioning features or use of this software
     15  1.1   matt  *    must display the following acknowledgement:
     16  1.1   matt  *      This product includes software developed by Christopher G. Demetriou
     17  1.1   matt  *	for the NetBSD Project.
     18  1.1   matt  * 4. The name of the author may not be used to endorse or promote products
     19  1.1   matt  *    derived from this software without specific prior written permission
     20  1.1   matt  *
     21  1.1   matt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1   matt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1   matt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1   matt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1   matt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1   matt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1   matt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1   matt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1   matt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1   matt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1   matt  */
     32  1.4  lukem 
     33  1.4  lukem #include <sys/cdefs.h>
     34  1.4  lukem __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.4 2003/07/15 01:37:35 lukem Exp $");
     35  1.1   matt 
     36  1.1   matt #include "mainbus.h"
     37  1.1   matt #include "pci.h"
     38  1.2   matt #include "opt_multiprocessor.h"
     39  1.1   matt #include "opt_pci.h"
     40  1.1   matt 
     41  1.1   matt #include <sys/param.h>
     42  1.1   matt #include <sys/extent.h>
     43  1.1   matt #include <sys/device.h>
     44  1.1   matt #include <sys/malloc.h>
     45  1.1   matt #include <sys/systm.h>
     46  1.1   matt 
     47  1.1   matt #include <machine/bus.h>
     48  1.1   matt 
     49  1.1   matt #include <dev/pci/pcivar.h>
     50  1.1   matt #include <dev/pci/pciconf.h>
     51  1.1   matt 
     52  1.1   matt #include <dev/marvell/gtvar.h>
     53  1.1   matt 
     54  1.1   matt #if NCPU == 0
     55  1.1   matt #error	A cpu device is now required
     56  1.1   matt #endif
     57  1.1   matt 
     58  1.1   matt struct	mainbus_attach_args {
     59  1.1   matt 	const char *mba_busname;
     60  1.1   matt 	int mba_unit;
     61  1.1   matt };
     62  1.1   matt 
     63  1.1   matt int	mainbus_cfprint(void *, const char *);
     64  1.1   matt int	mainbus_match(struct device *, struct cfdata *, void *);
     65  1.1   matt void	mainbus_attach(struct device *, struct device *, void *);
     66  1.1   matt 
     67  1.1   matt CFATTACH_DECL(mainbus, sizeof(struct device),
     68  1.1   matt 	mainbus_match, mainbus_attach, NULL, NULL);
     69  1.1   matt 
     70  1.1   matt int
     71  1.1   matt mainbus_cfprint(void *aux, const char *pnp)
     72  1.1   matt {
     73  1.1   matt 	struct mainbus_attach_args *mba = aux;
     74  1.1   matt 
     75  1.1   matt 	if (pnp)
     76  1.3   matt 		aprint_normal("%s at %s", mba->mba_busname, pnp);
     77  1.3   matt 	aprint_normal(" unit %d", mba->mba_unit);
     78  1.1   matt 	return (UNCONF);
     79  1.1   matt }
     80  1.1   matt 
     81  1.1   matt 
     82  1.1   matt /*
     83  1.1   matt  * Probe for the mainbus; always succeeds.
     84  1.1   matt  */
     85  1.1   matt int
     86  1.1   matt mainbus_match(struct device *parent, struct cfdata *match, void *aux)
     87  1.1   matt {
     88  1.1   matt 	return 1;
     89  1.1   matt }
     90  1.1   matt 
     91  1.1   matt /*
     92  1.1   matt  * Attach the mainbus.
     93  1.1   matt  */
     94  1.1   matt void
     95  1.1   matt mainbus_attach(struct device *parent, struct device *self, void *aux)
     96  1.1   matt {
     97  1.1   matt 	struct mainbus_attach_args mba;
     98  1.1   matt 
     99  1.1   matt 	printf("\n");
    100  1.1   matt 
    101  1.1   matt 	memset(&mba, 0, sizeof(mba));
    102  1.1   matt 
    103  1.1   matt 	/*
    104  1.1   matt 	 * Always find the CPU
    105  1.1   matt 	 */
    106  1.1   matt 	mba.mba_busname = "cpu";
    107  1.1   matt 	mba.mba_unit = 0;
    108  1.1   matt 	config_found(self, &mba, mainbus_cfprint);
    109  1.1   matt 
    110  1.2   matt #ifdef MULTIPROCESSOR
    111  1.1   matt 	/*
    112  1.1   matt 	 * Try for a second one...
    113  1.1   matt 	 */
    114  1.1   matt 	mba.mba_busname = "cpu";
    115  1.1   matt 	mba.mba_unit = 1;
    116  1.1   matt 	config_found(self, &mba, mainbus_cfprint);
    117  1.2   matt #endif
    118  1.1   matt 
    119  1.1   matt 	/*
    120  1.1   matt 	 * Now try to configure the Discovery
    121  1.1   matt 	 */
    122  1.1   matt 	mba.mba_busname = "gt";
    123  1.3   matt 	mba.mba_unit = 0;
    124  1.1   matt 	config_found(self, &mba, mainbus_cfprint);
    125  1.1   matt }
    126  1.1   matt 
    127  1.1   matt static int	cpu_match(struct device *, struct cfdata *, void *);
    128  1.1   matt static void	cpu_attach(struct device *, struct device *, void *);
    129  1.1   matt 
    130  1.1   matt CFATTACH_DECL(cpu, sizeof(struct device), cpu_match, cpu_attach, NULL, NULL);
    131  1.1   matt 
    132  1.1   matt extern struct cfdriver cpu_cd;
    133  1.1   matt 
    134  1.1   matt int
    135  1.1   matt cpu_match(struct device *parent, struct cfdata *cf, void *aux)
    136  1.1   matt {
    137  1.1   matt 	struct mainbus_attach_args *mba = aux;
    138  1.1   matt 
    139  1.1   matt 	if (strcmp(mba->mba_busname, cpu_cd.cd_name) != 0)
    140  1.1   matt 		return 0;
    141  1.1   matt 
    142  1.1   matt 	if (cpu_info[0].ci_dev != NULL)
    143  1.1   matt 		return 0;
    144  1.1   matt 
    145  1.1   matt 	return 1;
    146  1.1   matt }
    147  1.1   matt 
    148  1.1   matt void
    149  1.1   matt cpu_attach(struct device *parent, struct device *self, void *aux)
    150  1.1   matt {
    151  1.1   matt 	(void) cpu_attach_common(self, 0);
    152  1.1   matt }
    153