#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci_at_mainbus.c,v 1.11 2022/03/31 19:30:17 pgoyette Exp $");
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/mbuf.h>
#include <sys/stat.h>
#include <sys/bus.h>
#include <dev/pci/pcivar.h>
#include <machine/bus_private.h>
#include "ioconf.c"
#include <rump-sys/kern.h>
#include <rump-sys/vfs.h>
#include "pci_user.h"
RUMP_COMPONENT(RUMP_COMPONENT_DEV)
{
extern const struct cdevsw pci_cdevsw;
devmajor_t cmaj, bmaj;
int error;
bmaj = cmaj = -1;
if ((error = devsw_attach("pci", NULL, &bmaj,
&pci_cdevsw, &cmaj)) != 0) {
printf("pci: devsw_attach failed: %d\n", error);
return;
}
config_init_component(cfdriver_ioconf_pci,
cfattach_ioconf_pci, cfdata_ioconf_pci);
if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/pci", '0',
cmaj, 0, 4)) != 0)
printf("pci: failed to create /dev/pci nodes: %d\n", error);
}
RUMP_COMPONENT(RUMP_COMPONENT_DEV_AFTERMAINBUS)
{
struct pcibus_attach_args pba;
device_t mainbus;
memset(&pba, 0, sizeof(pba));
pba.pba_bus = 0;
pba.pba_iot = (bus_space_tag_t)0;
pba.pba_memt = (bus_space_tag_t)1;
pba.pba_dmat = (void *)0x20;
#ifdef _LP64
pba.pba_dmat64 = (void *)0x40;
#endif
pba.pba_flags = PCI_FLAGS_MEM_OKAY |
PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
#ifdef RUMPCOMP_USERFEATURE_PCI_IOSPACE
int error;
error = rumpcomp_pci_iospace_init();
if (!error) {
pba.pba_flags |= PCI_FLAGS_IO_OKAY;
} else {
aprint_error("pci: I/O space init error %d, I/O space not "
"available\n", error);
}
#endif
mainbus = device_find_by_driver_unit("mainbus", 0);
if (!mainbus)
panic("no mainbus. use maintaxi instead?");
config_found(mainbus, &pba, pcibusprint,
CFARGS(.iattr = "pcibus"));
}