#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rump_autoconf.c,v 1.4 2026/01/17 02:01:39 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/kernel.h>
static int mainbus_match(device_t, cfdata_t, void *);
static void mainbus_attach(device_t, device_t, void *);
static int mainbus_search(device_t, cfdata_t, const int *, void *);
struct mainbus_softc {
int mb_nada;
};
const struct cfattachinit cfattachinit[] = {
{ NULL, NULL, NULL },
};
struct cfdata cfdata[] = {
{ NULL, NULL, 0, FSTATE_NOTFOUND, NULL, 0, NULL},
{ NULL, NULL, 0, FSTATE_NOTFOUND, NULL, 0, NULL},
};
struct cfdriver * const cfdriver_list_initial[] = {
NULL,
};
#include "ioconf.c"
CFATTACH_DECL_NEW(mainbus, sizeof(struct mainbus_softc),
mainbus_match, mainbus_attach, NULL, NULL);
const short cfroots[] = {
0,
-1
};
#define MAXPDEVS 256
struct pdevinit pdevinit[MAXPDEVS] = {{NULL,0}, };
static int pdev_total = 0;
#include <rump-sys/dev.h>
void
rump_pdev_add(void (*pdev_attach)(int), int pdev_count)
{
struct pdevinit *pdev_new;
KASSERT(cold);
pdev_new = &pdevinit[pdev_total];
pdev_new->pdev_attach = pdev_attach;
pdev_new->pdev_count = pdev_count;
pdev_total++;
KASSERT(pdev_total < MAXPDEVS);
}
void
rump_pdev_finalize()
{
rump_pdev_add(NULL, 0);
}
static int
mainbus_match(device_t parent, cfdata_t match, void *aux)
{
return 1;
}
static void
mainbus_attach(device_t parent, device_t self, void *aux)
{
aprint_normal("\n");
config_search(self, NULL,
CFARGS(.search = mainbus_search,
.iattr = "mainbus"));
}
static int
mainbus_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
{
struct mainbus_attach_args maa;
maa.maa_unit = cf->cf_unit;
if (config_probe(parent, cf, &maa))
config_attach(parent, cf, &maa, NULL, CFARGS_NONE);
return 0;
}
void
rump_mainbus_init(void)
{
memcpy(&cfdata[0], &cfdata_ioconf_mainbus[0], sizeof(cfdata[0]));
}
void
rump_mainbus_attach(void)
{
const struct cfattachinit *cfai = &cfattach_ioconf_mainbus[0];
config_cfdata_attach(cfdata, 0);
config_cfdriver_attach(cfdriver_ioconf_mainbus[0]);
config_cfattach_attach(cfai->cfai_name, cfai->cfai_list[0]);
}