hb.c revision 1.2 1 /* $NetBSD: hb.c,v 1.2 1998/06/05 14:19:22 tsubai 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 char *hbdevs[] = {
36 "clock",
37 "fb",
38 "zsc",
39 "kb",
40 "ms",
41 "le",
42 "sc",
43 NULL
44 };
45
46 static void
47 hb_attach(parent, self, aux)
48 struct device *parent;
49 struct device *self;
50 void *aux;
51 {
52 struct confargs ca;
53 char **p = hbdevs;
54
55 printf("\n");
56 bzero(&ca, sizeof(ca));
57
58 while (*p) {
59 ca.ca_name = *p;
60 config_search(hb_search, self, &ca);
61 p++;
62 }
63 }
64
65 static int
66 hb_search(parent, cf, aux)
67 struct device *parent;
68 struct cfdata *cf;
69 void *aux;
70 {
71 struct confargs *ca = aux;
72
73 ca->ca_addr = cf->cf_addr;
74
75 if ((*cf->cf_attach->ca_match)(parent, cf, ca) != 0)
76 config_attach(parent, cf, ca, hb_print);
77
78 return 0;
79 }
80
81 /*
82 * Print out the confargs. The (parent) name is non-NULL
83 * when there was no match found by config_found().
84 */
85 static int
86 hb_print(args, name)
87 void *args;
88 const char *name;
89 {
90 struct confargs *ca = args;
91
92 /* Be quiet about empty HB locations. */
93 if (name)
94 return(QUIET);
95
96 if (ca->ca_addr != -1)
97 printf(" addr 0x%x", ca->ca_addr);
98
99 return(UNCONF);
100 }
101
102