Home | History | Annotate | Line # | Download | only in dev
hb.c revision 1.2.10.1
      1  1.2.10.1  thorpej /*	$NetBSD: hb.c,v 1.2.10.1 1999/08/02 19:58:23 thorpej Exp $	*/
      2       1.1   tsubai 
      3       1.1   tsubai #include <sys/param.h>
      4       1.1   tsubai #include <sys/systm.h>
      5       1.1   tsubai #include <sys/device.h>
      6       1.1   tsubai 
      7       1.1   tsubai #include <machine/autoconf.h>
      8       1.1   tsubai #include <machine/adrsmap.h>
      9       1.1   tsubai 
     10       1.1   tsubai static int	hb_match __P((struct device *, struct cfdata *, void *));
     11       1.1   tsubai static void	hb_attach __P((struct device *, struct device *, void *));
     12       1.2   tsubai static int	hb_search __P((struct device *, struct cfdata *, void *));
     13       1.1   tsubai static int	hb_print __P((void *, const char *));
     14       1.1   tsubai 
     15       1.1   tsubai struct cfattach hb_ca = {
     16       1.1   tsubai 	sizeof(struct device), hb_match, hb_attach
     17       1.1   tsubai };
     18       1.1   tsubai 
     19       1.1   tsubai extern struct cfdriver hb_cd;
     20       1.1   tsubai 
     21       1.1   tsubai static int
     22       1.1   tsubai hb_match(parent, cf, aux)
     23       1.1   tsubai 	struct device *parent;
     24       1.1   tsubai 	struct cfdata *cf;
     25       1.1   tsubai 	void *aux;
     26       1.1   tsubai {
     27       1.1   tsubai 	struct confargs *ca = aux;
     28       1.1   tsubai 
     29       1.1   tsubai 	if (strcmp(ca->ca_name, hb_cd.cd_name) != 0)
     30       1.1   tsubai 		return 0;
     31       1.1   tsubai 
     32       1.1   tsubai 	return 1;
     33       1.1   tsubai }
     34       1.1   tsubai 
     35       1.1   tsubai static void
     36       1.1   tsubai hb_attach(parent, self, aux)
     37       1.1   tsubai 	struct device *parent;
     38       1.1   tsubai 	struct device *self;
     39       1.1   tsubai 	void *aux;
     40       1.1   tsubai {
     41  1.2.10.1  thorpej 	struct confargs *ca = aux;
     42       1.1   tsubai 
     43       1.1   tsubai 	printf("\n");
     44  1.2.10.1  thorpej 	config_search(hb_search, self, ca);
     45       1.1   tsubai }
     46       1.1   tsubai 
     47       1.2   tsubai static int
     48       1.2   tsubai hb_search(parent, cf, aux)
     49       1.2   tsubai 	struct device *parent;
     50       1.2   tsubai 	struct cfdata *cf;
     51       1.2   tsubai 	void *aux;
     52       1.2   tsubai {
     53       1.2   tsubai 	struct confargs *ca = aux;
     54       1.2   tsubai 
     55       1.2   tsubai 	ca->ca_addr = cf->cf_addr;
     56  1.2.10.1  thorpej 	ca->ca_name = cf->cf_driver->cd_name;
     57       1.2   tsubai 
     58  1.2.10.1  thorpej 	if ((*cf->cf_attach->ca_match)(parent, cf, ca) > 0)
     59       1.2   tsubai 		config_attach(parent, cf, ca, hb_print);
     60       1.2   tsubai 
     61       1.2   tsubai 	return 0;
     62       1.2   tsubai }
     63       1.2   tsubai 
     64       1.1   tsubai /*
     65       1.1   tsubai  * Print out the confargs.  The (parent) name is non-NULL
     66       1.1   tsubai  * when there was no match found by config_found().
     67       1.1   tsubai  */
     68       1.1   tsubai static int
     69       1.1   tsubai hb_print(args, name)
     70       1.1   tsubai 	void *args;
     71       1.1   tsubai 	const char *name;
     72       1.1   tsubai {
     73       1.1   tsubai 	struct confargs *ca = args;
     74       1.1   tsubai 
     75       1.1   tsubai 	/* Be quiet about empty HB locations. */
     76       1.1   tsubai 	if (name)
     77  1.2.10.1  thorpej 		return QUIET;
     78       1.1   tsubai 
     79       1.1   tsubai 	if (ca->ca_addr != -1)
     80       1.1   tsubai 		printf(" addr 0x%x", ca->ca_addr);
     81       1.1   tsubai 
     82  1.2.10.1  thorpej 	return UNCONF;
     83       1.1   tsubai }
     84