Fix memory barrier in a debug function
[netbsd-mini2440.git] / sys / rump / librump / rumpdev / autoconf.c
blob03539711d4e5392dbd14c2a35dcbae56c4c258cd
1 /* $NetBSD: autoconf.c,v 1.3 2009/10/01 15:21:38 pooka Exp $ */
3 /*
4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * 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 OR
21 * 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.
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.3 2009/10/01 15:21:38 pooka Exp $");
31 #include <sys/param.h>
32 #include <sys/device.h>
33 #include <sys/kernel.h>
35 static int mainbus_match(struct device *, struct cfdata *, void *);
36 static void mainbus_attach(struct device *, struct device *, void *);
37 static int mainbus_search(struct device *, struct cfdata *,
38 const int *, void *);
40 struct mainbus_softc {
41 int mb_nada;
44 static const struct cfiattrdata mainbus_iattrdata = {
45 "mainbus", 0, {
46 { NULL, NULL, 0 },
49 static const struct cfiattrdata * const mainbus_attrs[] = {
50 &mainbus_iattrdata,
51 NULL,
54 CFDRIVER_DECL(mainbus, DV_DULL, mainbus_attrs);
55 CFATTACH_DECL_NEW(mainbus, sizeof(struct mainbus_softc),
56 mainbus_match, mainbus_attach, NULL, NULL);
58 struct cfdriver * const cfdriver_list_initial[] = {
59 &mainbus_cd,
60 NULL
63 static struct cfattach * const mainbus_cfattachinit[] = {
64 &mainbus_ca, NULL
66 const struct cfattachinit cfattachinit[] = {
67 { "mainbus", mainbus_cfattachinit },
68 { NULL, NULL },
71 struct cfdata cfdata[] = {
72 { "mainbus", "mainbus", 0, FSTATE_NOTFOUND, NULL, 0, NULL},
75 const short cfroots[] = {
76 0, /* mainbus */
80 /* actually used */
81 #define MAXPDEVS 256
82 struct pdevinit pdevinit[MAXPDEVS] = {{NULL,0}, }; /* XXX: static limit */
83 static int pdev_total = 0;
85 #include "rump_dev_private.h"
87 void
88 rump_pdev_add(void (*pdev_attach)(int), int pdev_count)
90 struct pdevinit *pdev_new;
92 KASSERT(cold);
94 pdev_new = &pdevinit[pdev_total];
95 pdev_new->pdev_attach = pdev_attach;
96 pdev_new->pdev_count = pdev_count;
98 pdev_total++;
99 KASSERT(pdev_total < MAXPDEVS);
102 void
103 rump_pdev_finalize()
106 rump_pdev_add(NULL, 0);
110 mainbus_match(struct device *parent, struct cfdata *match, void *aux)
113 return 1;
116 void
117 mainbus_attach(struct device *parent, struct device *self, void *aux)
120 aprint_normal("\n");
121 config_search_ia(mainbus_search, self, "mainbus", NULL);
124 static int
125 mainbus_search(struct device *parent, struct cfdata *cf,
126 const int *ldesc, void *aux)
128 struct mainbus_attach_args maa;
130 maa.maa_unit = cf->cf_unit;
131 if (config_match(parent, cf, &maa) > 0)
132 config_attach(parent, cf, &maa, NULL);
134 return 0;