1 /* $NetBSD: autoconf.c,v 1.3 2009/10/01 15:21:38 pooka Exp $ */
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
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
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
*,
40 struct mainbus_softc
{
44 static const struct cfiattrdata mainbus_iattrdata
= {
49 static const struct cfiattrdata
* const mainbus_attrs
[] = {
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
[] = {
63 static struct cfattach
* const mainbus_cfattachinit
[] = {
66 const struct cfattachinit cfattachinit
[] = {
67 { "mainbus", mainbus_cfattachinit
},
71 struct cfdata cfdata
[] = {
72 { "mainbus", "mainbus", 0, FSTATE_NOTFOUND
, NULL
, 0, NULL
},
75 const short cfroots
[] = {
82 struct pdevinit pdevinit
[MAXPDEVS
] = {{NULL
,0}, }; /* XXX: static limit */
83 static int pdev_total
= 0;
85 #include "rump_dev_private.h"
88 rump_pdev_add(void (*pdev_attach
)(int), int pdev_count
)
90 struct pdevinit
*pdev_new
;
94 pdev_new
= &pdevinit
[pdev_total
];
95 pdev_new
->pdev_attach
= pdev_attach
;
96 pdev_new
->pdev_count
= pdev_count
;
99 KASSERT(pdev_total
< MAXPDEVS
);
106 rump_pdev_add(NULL
, 0);
110 mainbus_match(struct device
*parent
, struct cfdata
*match
, void *aux
)
117 mainbus_attach(struct device
*parent
, struct device
*self
, void *aux
)
121 config_search_ia(mainbus_search
, self
, "mainbus", NULL
);
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
);