Home | History | Annotate | Line # | Download | only in tx
txsim.c revision 1.1
      1  1.1  uch /*	$NetBSD: txsim.c,v 1.1 1999/11/20 19:56:40 uch Exp $ */
      2  1.1  uch 
      3  1.1  uch /*
      4  1.1  uch  * Copyright (c) 1999, by UCHIYAMA Yasushi
      5  1.1  uch  * All rights reserved.
      6  1.1  uch  *
      7  1.1  uch  * Redistribution and use in source and binary forms, with or without
      8  1.1  uch  * modification, are permitted provided that the following conditions
      9  1.1  uch  * are met:
     10  1.1  uch  * 1. Redistributions of source code must retain the above copyright
     11  1.1  uch  *    notice, this list of conditions and the following disclaimer.
     12  1.1  uch  * 2. The name of the developer may NOT be used to endorse or promote products
     13  1.1  uch  *    derived from this software without specific prior written permission.
     14  1.1  uch  *
     15  1.1  uch  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16  1.1  uch  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  1.1  uch  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18  1.1  uch  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  1.1  uch  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  1.1  uch  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21  1.1  uch  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.1  uch  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  1.1  uch  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  1.1  uch  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  1.1  uch  * SUCH DAMAGE.
     26  1.1  uch  *
     27  1.1  uch  */
     28  1.1  uch 
     29  1.1  uch /*
     30  1.1  uch  * TX System Internal Module.
     31  1.1  uch  */
     32  1.1  uch #include "opt_tx39_debug.h"
     33  1.1  uch 
     34  1.1  uch #include <sys/param.h>
     35  1.1  uch #include <sys/systm.h>
     36  1.1  uch #include <sys/device.h>
     37  1.1  uch 
     38  1.1  uch #include <machine/bus.h>
     39  1.1  uch #include <machine/autoconf.h>
     40  1.1  uch 
     41  1.1  uch #include <hpcmips/tx/tx39var.h>
     42  1.1  uch 
     43  1.1  uch int	txsim_match __P((struct device*, struct cfdata*, void*));
     44  1.1  uch void	txsim_attach __P((struct device*, struct device*, void*));
     45  1.1  uch int	txsim_print __P((void*, const char*));
     46  1.1  uch int	txsim_search __P((struct device*, struct cfdata*, void*));
     47  1.1  uch 
     48  1.1  uch struct txsim_softc {
     49  1.1  uch 	struct	device sc_dev;
     50  1.1  uch 	int sc_pri; /* attaching device priority */
     51  1.1  uch };
     52  1.1  uch 
     53  1.1  uch struct cfattach txsim_ca = {
     54  1.1  uch 	sizeof(struct txsim_softc), txsim_match, txsim_attach
     55  1.1  uch };
     56  1.1  uch 
     57  1.1  uch int
     58  1.1  uch txsim_match(parent, match, aux)
     59  1.1  uch 	struct device *parent;
     60  1.1  uch 	struct cfdata *match;
     61  1.1  uch 	void *aux;
     62  1.1  uch {
     63  1.1  uch 	struct mainbus_attach_args *ma = aux;
     64  1.1  uch 
     65  1.1  uch 	if (strcmp(ma->ma_name, match->cf_driver->cd_name))
     66  1.1  uch 		return 0;
     67  1.1  uch 	return 1;
     68  1.1  uch }
     69  1.1  uch 
     70  1.1  uch void
     71  1.1  uch txsim_attach(parent, self, aux)
     72  1.1  uch 	struct device *parent;
     73  1.1  uch 	struct device *self;
     74  1.1  uch 	void *aux;
     75  1.1  uch {
     76  1.1  uch 	struct txsim_softc *sc = (void*)self;
     77  1.1  uch 
     78  1.1  uch 	printf("\n");
     79  1.1  uch 	/*
     80  1.1  uch 	 *	interrupt, clock module is used by other system module.
     81  1.1  uch 	 *	so attach first.
     82  1.1  uch 	 */
     83  1.1  uch 	sc->sc_pri = 2;
     84  1.1  uch 	config_search(txsim_search, self, txsim_print);
     85  1.1  uch 	/*
     86  1.1  uch 	 *	Other system module.
     87  1.1  uch 	 */
     88  1.1  uch 	sc->sc_pri = 1;
     89  1.1  uch 	config_search(txsim_search, self, txsim_print);
     90  1.1  uch }
     91  1.1  uch 
     92  1.1  uch int
     93  1.1  uch txsim_print(aux, pnp)
     94  1.1  uch 	void *aux;
     95  1.1  uch 	const char *pnp;
     96  1.1  uch {
     97  1.1  uch 	return pnp ? QUIET : UNCONF;
     98  1.1  uch }
     99  1.1  uch 
    100  1.1  uch int
    101  1.1  uch txsim_search(parent, cf, aux)
    102  1.1  uch 	struct device *parent;
    103  1.1  uch 	struct cfdata *cf;
    104  1.1  uch 	void *aux;
    105  1.1  uch {
    106  1.1  uch 	struct txsim_softc *sc = (void*)parent;
    107  1.1  uch 	struct txsim_attach_args ta;
    108  1.1  uch 
    109  1.1  uch 	ta.ta_tc = tx_conf_get_tag();
    110  1.1  uch 
    111  1.1  uch 	if ((*cf->cf_attach->ca_match)(parent, cf, &ta) == sc->sc_pri) {
    112  1.1  uch 		config_attach(parent, cf, &ta, txsim_print);
    113  1.1  uch 	}
    114  1.1  uch 
    115  1.1  uch 	return 0;
    116  1.1  uch }
    117