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