#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/sbuf.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <dev/bhnd/bhndvar.h>
#include <dev/bhnd/bhndreg.h>
#include <dev/bhnd/bhnd_erom.h>
#include <dev/bhnd/cores/chipc/chipcreg.h>
#include <dev/bhnd/nvram/bhnd_nvram.h>
#include "bhnd_chipc_if.h"
#include "bhnd_nvram_if.h"
#include "bhndbvar.h"
#include "bhndb_bus_if.h"
#include "bhndb_hwdata.h"
#include "bhndb_private.h"
static u_long bhndb_debug = 0;
TUNABLE_ULONG("hw.bhndb.debug", &bhndb_debug);
enum {
BHNDB_DEBUG_PRIO = 1 << 0,
};
#define BHNDB_DEBUG(_type) (BHNDB_DEBUG_ ## _type & bhndb_debug)
static bool bhndb_hw_matches(struct bhndb_softc *sc,
struct bhnd_core_info *cores, u_int ncores,
const struct bhndb_hw *hw);
static int bhndb_init_region_cfg(struct bhndb_softc *sc,
bhnd_erom_t *erom,
struct bhndb_resources *r,
struct bhnd_core_info *cores, u_int ncores,
const struct bhndb_hw_priority *table);
static int bhndb_find_hwspec(struct bhndb_softc *sc,
struct bhnd_core_info *cores, u_int ncores,
const struct bhndb_hw **hw);
bhndb_addrspace bhndb_get_addrspace(struct bhndb_softc *sc,
device_t child);
static struct rman *bhndb_get_rman(struct bhndb_softc *sc,
device_t child, int type);
static int bhndb_init_child_resource(struct resource *r,
struct resource *parent,
bhnd_size_t offset,
bhnd_size_t size);
static int bhndb_activate_static_region(
struct bhndb_softc *sc,
struct bhndb_region *region,
device_t child, struct resource *r);
static int bhndb_try_activate_resource(
struct bhndb_softc *sc, device_t child,
struct resource *r, bool *indirect);
static inline struct bhndb_dw_alloc *bhndb_io_resource(struct bhndb_softc *sc,
bus_addr_t addr, bus_size_t size,
bus_size_t *offset, bool *stolen,
bus_addr_t *restore);
int
bhndb_generic_probe(device_t dev)
{
return (BUS_PROBE_NOWILDCARD);
}
static void
bhndb_probe_nomatch(device_t dev, device_t child)
{
const char *name;
name = device_get_name(child);
if (name == NULL)
name = "unknown device";
device_printf(dev, "<%s> (no driver attached)\n", name);
}
static int
bhndb_print_child(device_t dev, device_t child)
{
struct resource_list *rl;
int retval = 0;
retval += bus_print_child_header(dev, child);
rl = BUS_GET_RESOURCE_LIST(dev, child);
if (rl != NULL) {
retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY,
"%#jx");
retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ,
"%jd");
}
retval += bus_print_child_domain(dev, child);
retval += bus_print_child_footer(dev, child);
return (retval);
}
static int
bhndb_child_location(device_t dev, device_t child, struct sbuf *sb)
{
struct bhndb_softc *sc;
sc = device_get_softc(dev);
sbuf_printf(sb, "base=0x%llx",
(unsigned long long) sc->chipid.enum_addr);
return (0);
}
static bool
bhndb_hw_matches(struct bhndb_softc *sc, struct bhnd_core_info *cores,
u_int ncores, const struct bhndb_hw *hw)
{
for (u_int i = 0; i < hw->num_hw_reqs; i++) {
const struct bhnd_core_match *match;
bool found;
match = &hw->hw_reqs[i];
found = false;
for (u_int d = 0; d < ncores; d++) {
struct bhnd_core_info *core = &cores[d];
if (BHNDB_IS_CORE_DISABLED(sc->dev, sc->bus_dev, core))
continue;
if (!bhnd_core_matches(core, match))
continue;
found = true;
break;
}
if (!found)
return (false);
}
return (true);
}
static int
bhndb_init_region_cfg(struct bhndb_softc *sc, bhnd_erom_t *erom,
struct bhndb_resources *br, struct bhnd_core_info *cores, u_int ncores,
const struct bhndb_hw_priority *table)
{
const struct bhndb_hw_priority *hp;
bhnd_addr_t addr;
bhnd_size_t size;
size_t prio_low, prio_default, prio_high;
int error;
prio_low = 0;
prio_default = 0;
prio_high = 0;
for (u_int i = 0; i < ncores; i++) {
const struct bhndb_regwin *regw;
struct bhnd_core_info *core;
struct bhnd_core_match md;
core = &cores[i];
md = bhnd_core_get_match_desc(core);
for (regw = br->cfg->register_windows;
regw->win_type != BHNDB_REGWIN_T_INVALID; regw++)
{
const struct bhndb_port_priority *pp;
uint32_t alloc_flags;
if (regw->win_type != BHNDB_REGWIN_T_CORE)
continue;
if (!bhndb_regwin_match_core(regw, core))
continue;
error = bhnd_erom_lookup_core_addr(erom, &md,
regw->d.core.port_type,
regw->d.core.port,
regw->d.core.region,
NULL,
&addr,
&size);
if (error) {
if (error == ENOENT)
continue;
return (error);
}
if (regw->d.core.offset > size) {
device_printf(sc->dev, "invalid register "
"window offset %#jx for region %#jx+%#jx\n",
regw->d.core.offset, addr, size);
return (EINVAL);
}
addr += regw->d.core.offset;
size = regw->win_size;
pp = bhndb_hw_priorty_find_port(table, core,
regw->d.core.port_type, regw->d.core.port,
regw->d.core.region);
if (pp != NULL) {
alloc_flags = pp->alloc_flags;
} else {
alloc_flags = 0;
}
error = bhndb_add_resource_region(br, addr, size,
BHNDB_PRIORITY_HIGH, alloc_flags, regw);
if (error)
return (error);
}
}
for (u_int i = 0; i < ncores; i++) {
struct bhnd_core_info *core;
struct bhnd_core_match md;
core = &cores[i];
md = bhnd_core_get_match_desc(core);
if (BHNDB_IS_CORE_DISABLED(sc->dev, sc->bus_dev, core))
continue;
hp = bhndb_hw_priority_find_core(table, core);
if (hp == NULL)
continue;
if (hp->priority == BHNDB_PRIORITY_NONE)
continue;
for (u_int i = 0; i < hp->num_ports; i++) {
const struct bhndb_port_priority *pp;
pp = &hp->ports[i];
error = bhnd_erom_lookup_core_addr(erom, &md,
pp->type, pp->port, pp->region,
NULL, &addr, &size);
if (error) {
if (error == ENOENT)
continue;
return (error);
}
if (bhndb_has_static_region_mapping(br, addr, size))
continue;
error = bhndb_add_resource_region(br, addr, size,
pp->priority, pp->alloc_flags, NULL);
if (error)
return (error);
switch (pp->priority) {
case BHNDB_PRIORITY_NONE:
break;
case BHNDB_PRIORITY_LOW:
prio_low++;
break;
case BHNDB_PRIORITY_DEFAULT:
prio_default++;
break;
case BHNDB_PRIORITY_HIGH:
prio_high++;
break;
}
}
}
size_t prio_total = prio_low + prio_default + prio_high;
if (prio_total <= br->dwa_count) {
br->min_prio = BHNDB_PRIORITY_LOW;
} else if (prio_default + prio_high <= br->dwa_count) {
br->min_prio = BHNDB_PRIORITY_DEFAULT;
} else {
br->min_prio = BHNDB_PRIORITY_HIGH;
}
if (BHNDB_DEBUG(PRIO)) {
struct bhndb_region *region;
const char *direct_msg, *type_msg;
bhndb_priority_t prio, prio_min;
uint32_t flags;
prio_min = br->min_prio;
device_printf(sc->dev, "min_prio: %d\n", prio_min);
STAILQ_FOREACH(region, &br->bus_regions, link) {
prio = region->priority;
flags = region->alloc_flags;
direct_msg = prio >= prio_min ? "direct" : "indirect";
type_msg = region->static_regwin ? "static" : "dynamic";
device_printf(sc->dev, "region 0x%llx+0x%llx priority "
"%u %s/%s",
(unsigned long long) region->addr,
(unsigned long long) region->size,
region->priority,
direct_msg, type_msg);
if (flags & BHNDB_ALLOC_FULFILL_ON_OVERCOMMIT)
printf(" [overcommit]\n");
else
printf("\n");
}
}
return (0);
}
static int
bhndb_find_hwspec(struct bhndb_softc *sc, struct bhnd_core_info *cores,
u_int ncores, const struct bhndb_hw **hw)
{
const struct bhndb_hw *next, *hw_table;
hw_table = BHNDB_BUS_GET_HARDWARE_TABLE(sc->parent_dev, sc->dev);
for (next = hw_table; next->hw_reqs != NULL; next++) {
if (!bhndb_hw_matches(sc, cores, ncores, next))
continue;
*hw = next;
return (0);
}
return (ENOENT);
}
int
bhndb_attach(device_t dev, struct bhnd_chipid *cid,
struct bhnd_core_info *cores, u_int ncores,
struct bhnd_core_info *bridge_core, bhnd_erom_class_t *erom_class)
{
struct bhndb_devinfo *dinfo;
struct bhndb_softc *sc;
const struct bhndb_hw *hw;
const struct bhndb_hwcfg *hwcfg;
const struct bhndb_hw_priority *hwprio;
struct bhnd_erom_io *eio;
bhnd_erom_t *erom;
int error;
sc = device_get_softc(dev);
sc->dev = dev;
sc->parent_dev = device_get_parent(dev);
sc->bridge_core = *bridge_core;
sc->chipid = *cid;
if ((error = bhnd_service_registry_init(&sc->services)))
return (error);
BHNDB_LOCK_INIT(sc);
erom = NULL;
if ((error = bhndb_find_hwspec(sc, cores, ncores, &hw))) {
device_printf(sc->dev, "unable to identify device, "
" using generic bridge resource definitions\n");
hwcfg = BHNDB_BUS_GET_GENERIC_HWCFG(sc->parent_dev, dev);
hw = NULL;
} else {
hwcfg = hw->cfg;
}
if (hw != NULL && (bootverbose || BHNDB_DEBUG(PRIO))) {
device_printf(sc->dev, "%s resource configuration\n", hw->name);
}
sc->bus_res = bhndb_alloc_resources(sc->dev, sc->parent_dev, hwcfg);
if (sc->bus_res == NULL) {
device_printf(sc->dev, "failed to allocate bridge resource "
"state\n");
error = ENOMEM;
goto failed;
}
sc->bus_dev = BUS_ADD_CHILD(dev, BHND_PROBE_BUS, "bhnd", DEVICE_UNIT_ANY);
if (sc->bus_dev == NULL) {
error = ENXIO;
goto failed;
}
dinfo = device_get_ivars(sc->bus_dev);
dinfo->addrspace = BHNDB_ADDRSPACE_BRIDGED;
eio = bhnd_erom_iores_new(sc->bus_dev, 0);
if ((erom = bhnd_erom_alloc(erom_class, cid, eio)) == NULL) {
bhnd_erom_io_fini(eio);
error = ENXIO;
goto failed;
}
hwprio = BHNDB_BUS_GET_HARDWARE_PRIO(sc->parent_dev, sc->dev);
error = bhndb_init_region_cfg(sc, erom, sc->bus_res, cores, ncores,
hwprio);
if (error) {
device_printf(sc->dev, "failed to initialize resource "
"priority configuration: %d\n", error);
goto failed;
}
bhnd_erom_free(erom);
erom = NULL;
return (0);
failed:
BHNDB_LOCK_DESTROY(sc);
if (sc->bus_res != NULL)
bhndb_free_resources(sc->bus_res);
if (erom != NULL)
bhnd_erom_free(erom);
bhnd_service_registry_fini(&sc->services);
return (error);
}
int
bhndb_generic_detach(device_t dev)
{
struct bhndb_softc *sc;
int error;
sc = device_get_softc(dev);
if ((error = bus_generic_detach(dev)))
return (error);
if ((error = bhnd_service_registry_fini(&sc->services)))
return (error);
bhndb_free_resources(sc->bus_res);
BHNDB_LOCK_DESTROY(sc);
return (0);
}
int
bhndb_generic_suspend(device_t dev)
{
return (bus_generic_suspend(dev));
}
int
bhndb_generic_resume(device_t dev)
{
struct bhndb_softc *sc;
struct bhndb_resources *bus_res;
struct bhndb_dw_alloc *dwa;
int error;
sc = device_get_softc(dev);
bus_res = sc->bus_res;
BHNDB_LOCK(sc);
error = 0;
for (size_t i = 0; i < bus_res->dwa_count; i++) {
dwa = &bus_res->dw_alloc[i];
if (bhndb_dw_is_free(bus_res, dwa) && dwa->target == 0x0)
continue;
error = BHNDB_SET_WINDOW_ADDR(dev, dwa->win, dwa->target);
if (error)
break;
}
BHNDB_UNLOCK(sc);
if (error) {
device_printf(dev, "Unable to restore hardware configuration; "
"cannot resume: %d\n", error);
return (error);
}
return (bus_generic_resume(dev));
}
static void
bhndb_suspend_resource(device_t dev, device_t child, int type,
struct resource *r)
{
struct bhndb_softc *sc;
struct bhndb_dw_alloc *dwa;
sc = device_get_softc(dev);
if (type != SYS_RES_MEMORY)
return;
BHNDB_LOCK(sc);
dwa = bhndb_dw_find_resource(sc->bus_res, r);
if (dwa == NULL) {
BHNDB_UNLOCK(sc);
return;
}
if (BHNDB_DEBUG(PRIO))
device_printf(child, "suspend resource type=%d 0x%jx+0x%jx\n",
type, rman_get_start(r), rman_get_size(r));
bhndb_dw_release(sc->bus_res, dwa, r);
BHNDB_UNLOCK(sc);
}
static int
bhndb_resume_resource(device_t dev, device_t child, int type,
struct resource *r)
{
struct bhndb_softc *sc;
sc = device_get_softc(dev);
if (type != SYS_RES_MEMORY)
return (0);
if (!(rman_get_flags(r) & RF_ACTIVE))
return (0);
if (BHNDB_DEBUG(PRIO))
device_printf(child, "resume resource type=%d 0x%jx+0x%jx\n",
type, rman_get_start(r), rman_get_size(r));
return (bhndb_try_activate_resource(sc, rman_get_device(r), r, NULL));
}
static int
bhndb_read_ivar(device_t dev, device_t child, int index,
uintptr_t *result)
{
return (ENOENT);
}
static int
bhndb_write_ivar(device_t dev, device_t child, int index,
uintptr_t value)
{
return (ENOENT);
}
bhndb_addrspace
bhndb_get_addrspace(struct bhndb_softc *sc, device_t child)
{
struct bhndb_devinfo *dinfo;
device_t imd_dev;
imd_dev = child;
while (imd_dev != NULL && device_get_parent(imd_dev) != sc->dev)
imd_dev = device_get_parent(imd_dev);
if (imd_dev == NULL)
panic("bhndb address space request for non-child device %s\n",
device_get_nameunit(child));
dinfo = device_get_ivars(imd_dev);
return (dinfo->addrspace);
}
static struct rman *
bhndb_get_rman(struct bhndb_softc *sc, device_t child, int type)
{
switch (bhndb_get_addrspace(sc, child)) {
case BHNDB_ADDRSPACE_NATIVE:
switch (type) {
case SYS_RES_MEMORY:
return (&sc->bus_res->ht_mem_rman);
case SYS_RES_IRQ:
return (NULL);
default:
return (NULL);
}
case BHNDB_ADDRSPACE_BRIDGED:
switch (type) {
case SYS_RES_MEMORY:
return (&sc->bus_res->br_mem_rman);
case SYS_RES_IRQ:
return (&sc->bus_res->br_irq_rman);
default:
return (NULL);
}
}
return (NULL);
}
static device_t
bhndb_add_child(device_t dev, u_int order, const char *name, int unit)
{
struct bhndb_devinfo *dinfo;
device_t child;
child = device_add_child_ordered(dev, order, name, unit);
if (child == NULL)
return (NULL);
dinfo = malloc(sizeof(struct bhndb_devinfo), M_BHND, M_NOWAIT);
if (dinfo == NULL) {
device_delete_child(dev, child);
return (NULL);
}
dinfo->addrspace = BHNDB_ADDRSPACE_NATIVE;
resource_list_init(&dinfo->resources);
device_set_ivars(child, dinfo);
return (child);
}
static void
bhndb_child_deleted(device_t dev, device_t child)
{
struct bhndb_devinfo *dinfo = device_get_ivars(child);
if (dinfo != NULL) {
resource_list_free(&dinfo->resources);
free(dinfo, M_BHND);
}
device_set_ivars(child, NULL);
}
static const struct bhnd_chipid *
bhndb_get_chipid(device_t dev, device_t child)
{
struct bhndb_softc *sc = device_get_softc(dev);
return (&sc->chipid);
}
static bool
bhndb_is_core_disabled(device_t dev, device_t child,
struct bhnd_core_info *core)
{
struct bhndb_softc *sc;
sc = device_get_softc(dev);
if (BHNDB_BUS_IS_CORE_DISABLED(sc->parent_dev, dev, core))
return (true);
if (BHND_DEVCLASS_SUPPORTS_HOSTB(bhnd_core_class(core)))
return (!bhnd_cores_equal(core, &sc->bridge_core));
return (false);
}
static int
bhndb_get_hostb_core(device_t dev, device_t child, struct bhnd_core_info *core)
{
struct bhndb_softc *sc = device_get_softc(dev);
*core = sc->bridge_core;
return (0);
}
static struct bhnd_service_registry *
bhndb_get_service_registry(device_t dev, device_t child)
{
struct bhndb_softc *sc = device_get_softc(dev);
return (&sc->services);
}
static struct resource *
bhndb_alloc_resource(device_t dev, device_t child, int type,
int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
struct bhndb_softc *sc;
struct resource_list_entry *rle;
struct resource *rv;
struct rman *rm;
int error;
bool passthrough, isdefault;
sc = device_get_softc(dev);
passthrough = (device_get_parent(child) != dev);
isdefault = RMAN_IS_DEFAULT_RANGE(start, end);
rle = NULL;
rm = bhndb_get_rman(sc, child, type);
if (rm == NULL) {
return (BUS_ALLOC_RESOURCE(device_get_parent(sc->parent_dev),
child, type, rid, start, end, count, flags));
}
if (!passthrough && isdefault) {
rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child),
type, *rid);
if (rle == NULL) {
device_printf(dev,
"default resource %#x type %d for child %s "
"not found\n", *rid, type,
device_get_nameunit(child));
return (NULL);
}
if (rle->res != NULL) {
device_printf(dev,
"resource entry %#x type %d for child %s is busy\n",
*rid, type, device_get_nameunit(child));
return (NULL);
}
start = rle->start;
end = rle->end;
count = ulmax(count, rle->count);
}
if (start > end || count > ((end - start) + 1))
return (NULL);
rv = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE,
child);
if (rv == NULL)
return (NULL);
rman_set_rid(rv, *rid);
rman_set_type(rv, type);
if (flags & RF_ACTIVE) {
error = bus_activate_resource(child, type, *rid, rv);
if (error) {
device_printf(dev,
"failed to activate entry %#x type %d for "
"child %s: %d\n",
*rid, type, device_get_nameunit(child), error);
rman_release_resource(rv);
return (NULL);
}
}
if (rle != NULL) {
rle->res = rv;
rle->start = rman_get_start(rv);
rle->end = rman_get_end(rv);
rle->count = rman_get_size(rv);
}
return (rv);
}
static int
bhndb_release_resource(device_t dev, device_t child, struct resource *r)
{
struct bhndb_softc *sc;
struct resource_list_entry *rle = NULL;
bool passthrough;
int error;
sc = device_get_softc(dev);
passthrough = (device_get_parent(child) != dev);
if (bhndb_get_rman(sc, child, rman_get_type(r)) == NULL) {
return (BUS_RELEASE_RESOURCE(device_get_parent(sc->parent_dev),
child, r));
}
if (rman_get_flags(r) & RF_ACTIVE) {
error = BUS_DEACTIVATE_RESOURCE(dev, child, r);
if (error)
return (error);
}
if (!passthrough)
rle = resource_list_find(BUS_GET_RESOURCE_LIST(dev, child),
rman_get_type(r), rman_get_rid(r));
if ((error = rman_release_resource(r)))
return (error);
if (rle != NULL)
rle->res = NULL;
return (0);
}
static int
bhndb_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
struct bhndb_softc *sc;
struct rman *rm;
rman_res_t mstart, mend;
int error;
sc = device_get_softc(dev);
error = 0;
rm = bhndb_get_rman(sc, child, rman_get_type(r));
if (rm == NULL) {
return (BUS_ADJUST_RESOURCE(device_get_parent(sc->parent_dev),
child, r, start, end));
}
if (end <= start)
return (EINVAL);
if (!rman_is_region_manager(r, rm))
return (ENXIO);
BHNDB_LOCK(sc);
if (!(rman_get_flags(r) & RF_ACTIVE))
goto done;
error = bhndb_find_resource_limits(sc->bus_res, r, &mstart,
&mend);
if (error)
goto done;
if (start < mstart || end > mend) {
error = EINVAL;
goto done;
}
done:
if (!error)
error = rman_adjust_resource(r, start, end);
BHNDB_UNLOCK(sc);
return (error);
}
static int
bhndb_init_child_resource(struct resource *r,
struct resource *parent, bhnd_size_t offset, bhnd_size_t size)
{
bus_space_handle_t bh, child_bh;
bus_space_tag_t bt;
uintptr_t vaddr;
int error;
vaddr = (uintptr_t) rman_get_virtual(parent);
bt = rman_get_bustag(parent);
bh = rman_get_bushandle(parent);
vaddr += offset;
error = bus_space_subregion(bt, bh, offset, size, &child_bh);
if (error)
return (error);
rman_set_virtual(r, (void *) vaddr);
rman_set_bustag(r, bt);
rman_set_bushandle(r, child_bh);
return (0);
}
static int
bhndb_activate_static_region(struct bhndb_softc *sc,
struct bhndb_region *region, device_t child, struct resource *r)
{
struct resource *bridge_res;
const struct bhndb_regwin *win;
bhnd_size_t parent_offset;
rman_res_t r_start, r_size;
int error;
win = region->static_regwin;
KASSERT(win != NULL && BHNDB_REGWIN_T_IS_STATIC(win->win_type),
("can't activate non-static region"));
r_start = rman_get_start(r);
r_size = rman_get_size(r);
bridge_res = bhndb_host_resource_for_regwin(sc->bus_res->res, win);
if (bridge_res == NULL)
return (ENXIO);
parent_offset = r_start - region->addr;
parent_offset += win->win_offset;
error = bhndb_init_child_resource(r, bridge_res, parent_offset, r_size);
if (error)
return (error);
if ((error = rman_activate_resource(r)))
return (error);
return (0);
}
static struct bhndb_dw_alloc *
bhndb_retain_dynamic_window(struct bhndb_softc *sc, struct resource *r)
{
struct bhndb_dw_alloc *dwa;
rman_res_t r_start, r_size;
int error;
BHNDB_LOCK_ASSERT(sc, MA_OWNED);
r_start = rman_get_start(r);
r_size = rman_get_size(r);
dwa = bhndb_dw_find_mapping(sc->bus_res, r_start, r_size);
if (dwa != NULL) {
if (bhndb_dw_retain(sc->bus_res, dwa, r) == 0)
return (dwa);
return (NULL);
}
dwa = bhndb_dw_next_free(sc->bus_res);
if (dwa == NULL) {
return (NULL);
}
if (dwa->win->win_size < rman_get_size(r))
return (NULL);
error = bhndb_dw_set_addr(sc->dev, sc->bus_res, dwa, rman_get_start(r),
rman_get_size(r));
if (error) {
device_printf(sc->dev, "dynamic window initialization "
"for 0x%llx-0x%llx failed: %d\n",
(unsigned long long) r_start,
(unsigned long long) r_start + r_size - 1,
error);
return (NULL);
}
if (bhndb_dw_retain(sc->bus_res, dwa, r))
return (NULL);
return (dwa);
}
static int
bhndb_try_activate_resource(struct bhndb_softc *sc, device_t child,
struct resource *r, bool *indirect)
{
struct bhndb_region *region;
struct bhndb_dw_alloc *dwa;
bhndb_priority_t dw_priority;
rman_res_t r_start, r_size;
rman_res_t parent_offset;
int error, type;
BHNDB_LOCK_ASSERT(sc, MA_NOTOWNED);
if (indirect != NULL)
*indirect = false;
type = rman_get_type(r);
switch (type) {
case SYS_RES_IRQ:
return (rman_activate_resource(r));
case SYS_RES_MEMORY:
break;
default:
device_printf(sc->dev, "unsupported resource type %d\n", type);
return (ENXIO);
}
KASSERT(type == SYS_RES_MEMORY, ("invalid type: %d", type));
r_start = rman_get_start(r);
r_size = rman_get_size(r);
if (bhndb_get_addrspace(sc, child) == BHNDB_ADDRSPACE_NATIVE) {
struct resource *parent;
parent = bhndb_host_resource_for_range(sc->bus_res->res,
type, r_start, r_size);
if (parent == NULL) {
device_printf(sc->dev, "host resource not found "
"for 0x%llx-0x%llx\n",
(unsigned long long) r_start,
(unsigned long long) r_start + r_size - 1);
return (ENOENT);
}
error = bhndb_init_child_resource(r, parent,
r_start - rman_get_start(parent), r_size);
if (error)
return (error);
return (rman_activate_resource(r));
}
dw_priority = BHNDB_PRIORITY_LOW;
region = bhndb_find_resource_region(sc->bus_res, r_start, r_size);
if (region != NULL)
dw_priority = region->priority;
if (region && region->static_regwin) {
error = bhndb_activate_static_region(sc, region, child, r);
if (error)
device_printf(sc->dev, "static window allocation "
"for 0x%llx-0x%llx failed\n",
(unsigned long long) r_start,
(unsigned long long) r_start + r_size - 1);
return (error);
}
if (dw_priority < sc->bus_res->min_prio) {
if (indirect)
*indirect = true;
return (ENOMEM);
}
BHNDB_LOCK(sc); {
dwa = bhndb_retain_dynamic_window(sc, r);
} BHNDB_UNLOCK(sc);
if (dwa == NULL) {
if (indirect)
*indirect = true;
return (ENOMEM);
}
parent_offset = dwa->win->win_offset;
parent_offset += r_start - dwa->target;
error = bhndb_init_child_resource(r, dwa->parent_res, parent_offset,
dwa->win->win_size);
if (error)
goto failed;
if ((error = rman_activate_resource(r)))
goto failed;
return (0);
failed:
BHNDB_LOCK(sc);
bhndb_dw_release(sc->bus_res, dwa, r);
BHNDB_UNLOCK(sc);
return (error);
}
static int
bhndb_activate_resource(device_t dev, device_t child, struct resource *r)
{
struct bhndb_softc *sc = device_get_softc(dev);
if (bhndb_get_rman(sc, child, rman_get_type(r)) == NULL) {
return (BUS_ACTIVATE_RESOURCE(device_get_parent(sc->parent_dev),
child, r));
}
return (bhndb_try_activate_resource(sc, child, r, NULL));
}
static int
bhndb_deactivate_resource(device_t dev, device_t child, struct resource *r)
{
struct bhndb_dw_alloc *dwa;
struct bhndb_softc *sc;
struct rman *rm;
int error, type;
sc = device_get_softc(dev);
type = rman_get_type(r);
rm = bhndb_get_rman(sc, child, type);
if (rm == NULL) {
return (BUS_DEACTIVATE_RESOURCE(
device_get_parent(sc->parent_dev), child, r));
}
if ((error = rman_deactivate_resource(r)))
return (error);
switch (type) {
case SYS_RES_IRQ:
return (0);
case SYS_RES_MEMORY:
if (bhndb_get_addrspace(sc, child) == BHNDB_ADDRSPACE_BRIDGED) {
BHNDB_LOCK(sc);
dwa = bhndb_dw_find_resource(sc->bus_res, r);
if (dwa != NULL)
bhndb_dw_release(sc->bus_res, dwa, r);
BHNDB_UNLOCK(sc);
}
return (0);
default:
device_printf(dev, "unsupported resource type %d\n", type);
return (ENXIO);
}
}
static struct resource_list *
bhndb_get_resource_list(device_t dev, device_t child)
{
struct bhndb_devinfo *dinfo = device_get_ivars(child);
return (&dinfo->resources);
}
static int
bhndb_activate_bhnd_resource(device_t dev, device_t child,
int type, int rid, struct bhnd_resource *r)
{
struct bhndb_softc *sc;
struct bhndb_region *region;
bhndb_priority_t r_prio;
rman_res_t r_start, r_size;
int error;
bool indirect;
KASSERT(!r->direct,
("direct flag set on inactive resource"));
KASSERT(!(rman_get_flags(r->res) & RF_ACTIVE),
("RF_ACTIVE set on inactive resource"));
sc = device_get_softc(dev);
if (bhndb_get_rman(sc, child, type) == NULL) {
error = BUS_ACTIVATE_RESOURCE(dev, child, r->res);
if (error == 0)
r->direct = true;
return (error);
}
r_start = rman_get_start(r->res);
r_size = rman_get_size(r->res);
if (bhndb_get_addrspace(sc, child) == BHNDB_ADDRSPACE_BRIDGED) {
switch (type) {
case SYS_RES_IRQ:
break;
case SYS_RES_MEMORY:
region = bhndb_find_resource_region(sc->bus_res,
r_start, r_size);
if (region != NULL)
r_prio = region->priority;
else
r_prio = BHNDB_PRIORITY_NONE;
if (r_prio < sc->bus_res->min_prio)
return (0);
break;
default:
device_printf(dev, "unsupported resource type %d\n",
type);
return (ENXIO);
}
}
error = bhndb_try_activate_resource(sc, child, r->res, &indirect);
if (!error) {
r->direct = true;
} else if (indirect) {
error = 0;
r->direct = false;
}
if (BHNDB_DEBUG(PRIO) &&
bhndb_get_addrspace(sc, child) == BHNDB_ADDRSPACE_BRIDGED)
{
device_printf(child, "activated 0x%llx-0x%llx as %s "
"resource\n",
(unsigned long long) r_start,
(unsigned long long) r_start + r_size - 1,
r->direct ? "direct" : "indirect");
}
return (error);
}
static int
bhndb_deactivate_bhnd_resource(device_t dev, device_t child,
int type, int rid, struct bhnd_resource *r)
{
int error;
if (!r->direct)
return (0);
KASSERT(rman_get_flags(r->res) & RF_ACTIVE,
("RF_ACTIVE not set on direct resource"));
error = BUS_DEACTIVATE_RESOURCE(dev, child, r->res);
if (!error)
r->direct = false;
return (error);
}
static struct bhndb_dw_alloc *
bhndb_io_resource_get_window(struct bhndb_softc *sc, bus_addr_t addr,
bus_size_t size, bool *borrowed, bool *stolen, bus_addr_t *restore)
{
struct bhndb_resources *br;
struct bhndb_dw_alloc *dwa;
struct bhndb_region *region;
BHNDB_LOCK_ASSERT(sc, MA_OWNED);
br = sc->bus_res;
*borrowed = false;
*stolen = false;
if ((dwa = bhndb_dw_next_free(br)) != NULL)
return (dwa);
for (size_t i = 0; i < br->dwa_count; i++) {
const struct bhndb_regwin *win;
dwa = &br->dw_alloc[i];
win = dwa->win;
KASSERT(win->win_type == BHNDB_REGWIN_T_DYN,
("invalid register window type"));
if (addr < dwa->target)
continue;
if (addr + size > dwa->target + win->win_size)
continue;
*borrowed = true;
return (dwa);
}
region = bhndb_find_resource_region(br, addr, size);
if (region == NULL)
return (NULL);
if ((region->alloc_flags & BHNDB_ALLOC_FULFILL_ON_OVERCOMMIT) == 0)
return (NULL);
if ((dwa = bhndb_dw_steal(br, restore)) != NULL) {
*stolen = true;
return (dwa);
}
panic("register windows exhausted attempting to map 0x%llx-0x%llx\n",
(unsigned long long) addr, (unsigned long long) addr+size-1);
}
static inline struct bhndb_dw_alloc *
bhndb_io_resource(struct bhndb_softc *sc, bus_addr_t addr, bus_size_t size,
bus_size_t *offset, bool *stolen, bus_addr_t *restore)
{
struct bhndb_dw_alloc *dwa;
bool borrowed;
int error;
BHNDB_LOCK_ASSERT(sc, MA_OWNED);
dwa = bhndb_io_resource_get_window(sc, addr, size, &borrowed, stolen,
restore);
if (addr < dwa->target ||
addr > dwa->target + dwa->win->win_size ||
(dwa->target + dwa->win->win_size) - addr < size)
{
if (borrowed) {
panic("borrowed register window does not map expected "
"range 0x%llx-0x%llx\n",
(unsigned long long) addr,
(unsigned long long) addr+size-1);
}
error = bhndb_dw_set_addr(sc->dev, sc->bus_res, dwa, addr,
size);
if (error) {
panic("failed to set register window target mapping "
"0x%llx-0x%llx\n",
(unsigned long long) addr,
(unsigned long long) addr+size-1);
}
}
*offset = (addr - dwa->target) + dwa->win->win_offset;
return (dwa);
}
#define BHNDB_IO_COMMON_SETUP(_io_size) \
struct bhndb_softc *sc; \
struct bhndb_dw_alloc *dwa; \
struct resource *io_res; \
bus_size_t io_offset; \
bus_addr_t restore; \
bool stolen; \
\
sc = device_get_softc(dev); \
\
BHNDB_LOCK(sc); \
dwa = bhndb_io_resource(sc, rman_get_start(r->res) + \
offset, _io_size, &io_offset, &stolen, &restore); \
io_res = dwa->parent_res; \
\
KASSERT(!r->direct, \
("bhnd_bus slow path used for direct resource")); \
\
KASSERT(rman_get_flags(io_res) & RF_ACTIVE, \
("i/o resource is not active"));
#define BHNDB_IO_COMMON_TEARDOWN() \
if (stolen) { \
bhndb_dw_return_stolen(sc->dev, sc->bus_res, \
dwa, restore); \
} \
BHNDB_UNLOCK(sc);
#define BHNDB_IO_READ(_type, _name) \
static _type \
bhndb_bus_read_ ## _name (device_t dev, device_t child, \
struct bhnd_resource *r, bus_size_t offset) \
{ \
_type v; \
BHNDB_IO_COMMON_SETUP(sizeof(_type)); \
v = bus_read_ ## _name (io_res, io_offset); \
BHNDB_IO_COMMON_TEARDOWN(); \
\
return (v); \
}
#define BHNDB_IO_WRITE(_type, _name) \
static void \
bhndb_bus_write_ ## _name (device_t dev, device_t child, \
struct bhnd_resource *r, bus_size_t offset, _type value) \
{ \
BHNDB_IO_COMMON_SETUP(sizeof(_type)); \
bus_write_ ## _name (io_res, io_offset, value); \
BHNDB_IO_COMMON_TEARDOWN(); \
}
#define BHNDB_IO_MISC(_type, _ptr, _op, _size) \
static void \
bhndb_bus_ ## _op ## _ ## _size (device_t dev, \
device_t child, struct bhnd_resource *r, bus_size_t offset, \
_type _ptr datap, bus_size_t count) \
{ \
BHNDB_IO_COMMON_SETUP(sizeof(_type) * count); \
bus_ ## _op ## _ ## _size (io_res, io_offset, \
datap, count); \
BHNDB_IO_COMMON_TEARDOWN(); \
}
#define BHNDB_IO_METHODS(_type, _size) \
BHNDB_IO_READ(_type, _size) \
BHNDB_IO_WRITE(_type, _size) \
\
BHNDB_IO_READ(_type, stream_ ## _size) \
BHNDB_IO_WRITE(_type, stream_ ## _size) \
\
BHNDB_IO_MISC(_type, *, read_multi, _size) \
BHNDB_IO_MISC(_type, *, write_multi, _size) \
\
BHNDB_IO_MISC(_type, *, read_multi_stream, _size) \
BHNDB_IO_MISC(_type, *, write_multi_stream, _size) \
\
BHNDB_IO_MISC(_type, , set_multi, _size) \
BHNDB_IO_MISC(_type, , set_region, _size) \
BHNDB_IO_MISC(_type, *, read_region, _size) \
BHNDB_IO_MISC(_type, *, write_region, _size) \
\
BHNDB_IO_MISC(_type, *, read_region_stream, _size) \
BHNDB_IO_MISC(_type, *, write_region_stream, _size)
BHNDB_IO_METHODS(uint8_t, 1);
BHNDB_IO_METHODS(uint16_t, 2);
BHNDB_IO_METHODS(uint32_t, 4);
static void
bhndb_bus_barrier(device_t dev, device_t child, struct bhnd_resource *r,
bus_size_t offset, bus_size_t length, int flags)
{
BHNDB_IO_COMMON_SETUP(length);
bus_barrier(io_res, io_offset + offset, length, flags);
BHNDB_IO_COMMON_TEARDOWN();
}
static int
bhndb_bhnd_map_intr(device_t dev, device_t child, u_int intr, rman_res_t *irq)
{
u_int ivec;
int error;
if (intr >= bhnd_get_intr_count(child))
return (EINVAL);
if ((error = bhnd_get_intr_ivec(child, intr, &ivec)))
return (error);
*irq = ivec;
return (0);
}
static void
bhndb_bhnd_unmap_intr(device_t dev, device_t child, rman_res_t irq)
{
}
static int
bhndb_setup_intr(device_t dev, device_t child, struct resource *r,
int flags, driver_filter_t filter, driver_intr_t handler, void *arg,
void **cookiep)
{
struct bhndb_softc *sc;
struct bhndb_intr_isrc *isrc;
struct bhndb_intr_handler *ih;
int error;
sc = device_get_softc(dev);
if ((error = BHNDB_MAP_INTR_ISRC(dev, r, &isrc))) {
device_printf(dev, "failed to fetch isrc: %d\n", error);
return (error);
}
ih = bhndb_alloc_intr_handler(child, r, isrc);
if (ih == NULL)
return (ENOMEM);
error = bus_setup_intr(isrc->is_owner, isrc->is_res, flags, filter,
handler, arg, &ih->ih_cookiep);
if (error) {
bhndb_free_intr_handler(ih);
return (error);
}
BHNDB_LOCK(sc);
bhndb_register_intr_handler(sc->bus_res, ih);
BHNDB_UNLOCK(sc);
*cookiep = ih;
return (0);
}
static int
bhndb_teardown_intr(device_t dev, device_t child, struct resource *r,
void *cookiep)
{
struct bhndb_softc *sc;
struct bhndb_intr_handler *ih;
struct bhndb_intr_isrc *isrc;
int error;
sc = device_get_softc(dev);
BHNDB_LOCK(sc);
ih = bhndb_find_intr_handler(sc->bus_res, cookiep);
if (ih == NULL) {
panic("%s requested teardown of invalid cookiep %p",
device_get_nameunit(child), cookiep);
}
bhndb_deregister_intr_handler(sc->bus_res, ih);
BHNDB_UNLOCK(sc);
isrc = ih->ih_isrc;
error = bus_teardown_intr(isrc->is_owner, isrc->is_res, ih->ih_cookiep);
if (error) {
BHNDB_LOCK(sc);
bhndb_register_intr_handler(sc->bus_res, ih);
BHNDB_UNLOCK(sc);
return (error);
}
bhndb_free_intr_handler(ih);
return (0);
}
static int
bhndb_bind_intr(device_t dev, device_t child, struct resource *irq, int cpu)
{
struct bhndb_softc *sc;
struct bhndb_intr_handler *ih;
struct bhndb_intr_isrc *isrc;
sc = device_get_softc(dev);
isrc = NULL;
BHNDB_LOCK(sc);
STAILQ_FOREACH(ih, &sc->bus_res->bus_intrs, ih_link) {
if (ih->ih_res == irq) {
isrc = ih->ih_isrc;
break;
}
}
BHNDB_UNLOCK(sc);
if (isrc == NULL) {
panic("%s requested bind of invalid irq %#jx-%#jx",
device_get_nameunit(child), rman_get_start(irq),
rman_get_end(irq));
}
return (bus_bind_intr(isrc->is_owner, isrc->is_res, cpu));
}
static int
bhndb_describe_intr(device_t dev, device_t child, struct resource *irq,
void *cookie, const char *descr)
{
struct bhndb_softc *sc;
struct bhndb_intr_handler *ih;
struct bhndb_intr_isrc *isrc;
sc = device_get_softc(dev);
BHNDB_LOCK(sc);
ih = bhndb_find_intr_handler(sc->bus_res, cookie);
if (ih == NULL) {
panic("%s requested invalid cookiep %p",
device_get_nameunit(child), cookie);
}
isrc = ih->ih_isrc;
BHNDB_UNLOCK(sc);
return (BUS_DESCRIBE_INTR(device_get_parent(isrc->is_owner),
isrc->is_owner, isrc->is_res, ih->ih_cookiep, descr));
}
static int
bhndb_config_intr(device_t dev, int irq, enum intr_trigger trig,
enum intr_polarity pol)
{
return (ENXIO);
}
static int
bhndb_remap_intr(device_t dev, device_t child, u_int irq)
{
return (ENXIO);
}
static inline int
bhndb_get_dma_translation(device_t dev, device_t child, u_int width,
uint32_t flags, bus_dma_tag_t *dmat,
struct bhnd_dma_translation *translation)
{
struct bhndb_softc *sc;
const struct bhndb_hwcfg *hwcfg;
const struct bhnd_dma_translation *match;
bus_dma_tag_t match_dmat;
bhnd_addr_t addr_mask, match_addr_mask;
sc = device_get_softc(dev);
hwcfg = sc->bus_res->cfg;
if (sc->bus_res->res->dma_tags == NULL)
return (ENODEV);
if (width > BHND_DMA_ADDR_32BIT) {
if (!(sc->chipid.chip_caps & BHND_CAP_BP64))
width = BHND_DMA_ADDR_32BIT;
}
addr_mask = BHND_DMA_ADDR_BITMASK(width);
match = NULL;
match_addr_mask = 0x0;
match_dmat = NULL;
for (size_t i = 0; i < sc->bus_res->res->num_dma_tags; i++) {
const struct bhnd_dma_translation *dwin;
bhnd_addr_t masked;
dwin = &hwcfg->dma_translations[i];
if ((dwin->base_addr & addr_mask) != dwin->base_addr)
continue;
if ((dwin->flags & flags) != flags)
continue;
masked = (dwin->addr_mask | dwin->addrext_mask) & addr_mask;
if (masked == 0)
continue;
if (match == NULL || masked > match_addr_mask) {
match = dwin;
match_addr_mask = masked;
match_dmat = sc->bus_res->res->dma_tags[i];
}
}
if (match == NULL || match_addr_mask == 0)
return (ENOENT);
if (dmat != NULL)
*dmat = match_dmat;
if (translation != NULL)
*translation = *match;
return (0);
}
static bus_dma_tag_t
bhndb_get_dma_tag(device_t dev, device_t child)
{
struct bhndb_softc *sc = device_get_softc(dev);
return (bus_get_dma_tag(sc->parent_dev));
}
static device_method_t bhndb_methods[] = {
\
DEVMETHOD(device_probe, bhndb_generic_probe),
DEVMETHOD(device_detach, bhndb_generic_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bhndb_generic_suspend),
DEVMETHOD(device_resume, bhndb_generic_resume),
DEVMETHOD(bus_probe_nomatch, bhndb_probe_nomatch),
DEVMETHOD(bus_print_child, bhndb_print_child),
DEVMETHOD(bus_child_location, bhndb_child_location),
DEVMETHOD(bus_add_child, bhndb_add_child),
DEVMETHOD(bus_child_deleted, bhndb_child_deleted),
DEVMETHOD(bus_alloc_resource, bhndb_alloc_resource),
DEVMETHOD(bus_release_resource, bhndb_release_resource),
DEVMETHOD(bus_activate_resource, bhndb_activate_resource),
DEVMETHOD(bus_deactivate_resource, bhndb_deactivate_resource),
DEVMETHOD(bus_setup_intr, bhndb_setup_intr),
DEVMETHOD(bus_teardown_intr, bhndb_teardown_intr),
DEVMETHOD(bus_config_intr, bhndb_config_intr),
DEVMETHOD(bus_bind_intr, bhndb_bind_intr),
DEVMETHOD(bus_describe_intr, bhndb_describe_intr),
DEVMETHOD(bus_remap_intr, bhndb_remap_intr),
DEVMETHOD(bus_get_dma_tag, bhndb_get_dma_tag),
DEVMETHOD(bus_adjust_resource, bhndb_adjust_resource),
DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource),
DEVMETHOD(bus_get_resource_list, bhndb_get_resource_list),
DEVMETHOD(bus_read_ivar, bhndb_read_ivar),
DEVMETHOD(bus_write_ivar, bhndb_write_ivar),
DEVMETHOD(bhndb_get_chipid, bhndb_get_chipid),
DEVMETHOD(bhndb_is_core_disabled, bhndb_is_core_disabled),
DEVMETHOD(bhndb_get_hostb_core, bhndb_get_hostb_core),
DEVMETHOD(bhndb_suspend_resource, bhndb_suspend_resource),
DEVMETHOD(bhndb_resume_resource, bhndb_resume_resource),
DEVMETHOD(bhnd_bus_get_chipid, bhndb_get_chipid),
DEVMETHOD(bhnd_bus_activate_resource, bhndb_activate_bhnd_resource),
DEVMETHOD(bhnd_bus_deactivate_resource, bhndb_deactivate_bhnd_resource),
DEVMETHOD(bhnd_bus_get_nvram_var, bhnd_bus_generic_get_nvram_var),
DEVMETHOD(bhnd_bus_map_intr, bhndb_bhnd_map_intr),
DEVMETHOD(bhnd_bus_unmap_intr, bhndb_bhnd_unmap_intr),
DEVMETHOD(bhnd_bus_get_dma_translation, bhndb_get_dma_translation),
DEVMETHOD(bhnd_bus_get_service_registry,bhndb_get_service_registry),
DEVMETHOD(bhnd_bus_register_provider, bhnd_bus_generic_sr_register_provider),
DEVMETHOD(bhnd_bus_deregister_provider, bhnd_bus_generic_sr_deregister_provider),
DEVMETHOD(bhnd_bus_retain_provider, bhnd_bus_generic_sr_retain_provider),
DEVMETHOD(bhnd_bus_release_provider, bhnd_bus_generic_sr_release_provider),
DEVMETHOD(bhnd_bus_read_1, bhndb_bus_read_1),
DEVMETHOD(bhnd_bus_read_2, bhndb_bus_read_2),
DEVMETHOD(bhnd_bus_read_4, bhndb_bus_read_4),
DEVMETHOD(bhnd_bus_write_1, bhndb_bus_write_1),
DEVMETHOD(bhnd_bus_write_2, bhndb_bus_write_2),
DEVMETHOD(bhnd_bus_write_4, bhndb_bus_write_4),
DEVMETHOD(bhnd_bus_read_stream_1, bhndb_bus_read_stream_1),
DEVMETHOD(bhnd_bus_read_stream_2, bhndb_bus_read_stream_2),
DEVMETHOD(bhnd_bus_read_stream_4, bhndb_bus_read_stream_4),
DEVMETHOD(bhnd_bus_write_stream_1, bhndb_bus_write_stream_1),
DEVMETHOD(bhnd_bus_write_stream_2, bhndb_bus_write_stream_2),
DEVMETHOD(bhnd_bus_write_stream_4, bhndb_bus_write_stream_4),
DEVMETHOD(bhnd_bus_read_multi_1, bhndb_bus_read_multi_1),
DEVMETHOD(bhnd_bus_read_multi_2, bhndb_bus_read_multi_2),
DEVMETHOD(bhnd_bus_read_multi_4, bhndb_bus_read_multi_4),
DEVMETHOD(bhnd_bus_write_multi_1, bhndb_bus_write_multi_1),
DEVMETHOD(bhnd_bus_write_multi_2, bhndb_bus_write_multi_2),
DEVMETHOD(bhnd_bus_write_multi_4, bhndb_bus_write_multi_4),
DEVMETHOD(bhnd_bus_read_multi_stream_1, bhndb_bus_read_multi_stream_1),
DEVMETHOD(bhnd_bus_read_multi_stream_2, bhndb_bus_read_multi_stream_2),
DEVMETHOD(bhnd_bus_read_multi_stream_4, bhndb_bus_read_multi_stream_4),
DEVMETHOD(bhnd_bus_write_multi_stream_1,bhndb_bus_write_multi_stream_1),
DEVMETHOD(bhnd_bus_write_multi_stream_2,bhndb_bus_write_multi_stream_2),
DEVMETHOD(bhnd_bus_write_multi_stream_4,bhndb_bus_write_multi_stream_4),
DEVMETHOD(bhnd_bus_set_multi_1, bhndb_bus_set_multi_1),
DEVMETHOD(bhnd_bus_set_multi_2, bhndb_bus_set_multi_2),
DEVMETHOD(bhnd_bus_set_multi_4, bhndb_bus_set_multi_4),
DEVMETHOD(bhnd_bus_set_region_1, bhndb_bus_set_region_1),
DEVMETHOD(bhnd_bus_set_region_2, bhndb_bus_set_region_2),
DEVMETHOD(bhnd_bus_set_region_4, bhndb_bus_set_region_4),
DEVMETHOD(bhnd_bus_read_region_1, bhndb_bus_read_region_1),
DEVMETHOD(bhnd_bus_read_region_2, bhndb_bus_read_region_2),
DEVMETHOD(bhnd_bus_read_region_4, bhndb_bus_read_region_4),
DEVMETHOD(bhnd_bus_write_region_1, bhndb_bus_write_region_1),
DEVMETHOD(bhnd_bus_write_region_2, bhndb_bus_write_region_2),
DEVMETHOD(bhnd_bus_write_region_4, bhndb_bus_write_region_4),
DEVMETHOD(bhnd_bus_read_region_stream_1,bhndb_bus_read_region_stream_1),
DEVMETHOD(bhnd_bus_read_region_stream_2,bhndb_bus_read_region_stream_2),
DEVMETHOD(bhnd_bus_read_region_stream_4,bhndb_bus_read_region_stream_4),
DEVMETHOD(bhnd_bus_write_region_stream_1,bhndb_bus_write_region_stream_1),
DEVMETHOD(bhnd_bus_write_region_stream_2,bhndb_bus_write_region_stream_2),
DEVMETHOD(bhnd_bus_write_region_stream_4,bhndb_bus_write_region_stream_4),
DEVMETHOD(bhnd_bus_barrier, bhndb_bus_barrier),
DEVMETHOD_END
};
DEFINE_CLASS_0(bhndb, bhndb_driver, bhndb_methods, sizeof(struct bhndb_softc));
MODULE_VERSION(bhndb, 1);
MODULE_DEPEND(bhndb, bhnd, 1, 1, 1);