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