Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
internally instead of requiring the caller to allocate it.
This commit is contained in:
parent
fc54707f7d
commit
95e3bfe889
@ -884,7 +884,6 @@ mv_pcib_route_interrupt(device_t bus, device_t dev, int pin)
|
||||
struct ofw_pci_register reg;
|
||||
uint32_t pintr, mintr;
|
||||
phandle_t iparent;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(pintr)];
|
||||
|
||||
sc = device_get_softc(bus);
|
||||
pintr = pin;
|
||||
@ -897,7 +896,7 @@ mv_pcib_route_interrupt(device_t bus, device_t dev, int pin)
|
||||
|
||||
if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), &sc->sc_pci_iinfo, ®,
|
||||
sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr),
|
||||
&iparent, maskbuf))
|
||||
&iparent))
|
||||
return (ofw_bus_map_intr(dev, iparent, mintr));
|
||||
|
||||
/* Maybe it's a real interrupt, not an intpin */
|
||||
|
@ -251,8 +251,9 @@ ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz)
|
||||
int
|
||||
ofw_bus_lookup_imap(phandle_t node, struct ofw_bus_iinfo *ii, void *reg,
|
||||
int regsz, void *pintr, int pintrsz, void *mintr, int mintrsz,
|
||||
phandle_t *iparent, void *maskbuf)
|
||||
phandle_t *iparent)
|
||||
{
|
||||
uint8_t maskbuf[regsz + pintrsz];
|
||||
int rv;
|
||||
|
||||
if (ii->opi_imapsz <= 0)
|
||||
|
@ -68,7 +68,7 @@ bus_child_pnpinfo_str_t ofw_bus_gen_child_pnpinfo_str;
|
||||
/* Routines for processing firmware interrupt maps */
|
||||
void ofw_bus_setup_iinfo(phandle_t, struct ofw_bus_iinfo *, int);
|
||||
int ofw_bus_lookup_imap(phandle_t, struct ofw_bus_iinfo *, void *, int,
|
||||
void *, int, void *, int, phandle_t *, void *);
|
||||
void *, int, void *, int, phandle_t *);
|
||||
int ofw_bus_search_intrmap(void *, int, void *, int, void *, int, void *,
|
||||
void *, void *, int, phandle_t *);
|
||||
|
||||
|
@ -259,7 +259,6 @@ ofw_pci_route_interrupt(device_t bus, device_t dev, int pin)
|
||||
uint32_t pintr, mintr[2];
|
||||
int intrcells;
|
||||
phandle_t iparent;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(pintr)];
|
||||
|
||||
sc = device_get_softc(bus);
|
||||
pintr = pin;
|
||||
@ -272,7 +271,7 @@ ofw_pci_route_interrupt(device_t bus, device_t dev, int pin)
|
||||
|
||||
intrcells = ofw_bus_lookup_imap(ofw_bus_get_node(dev),
|
||||
&sc->sc_pci_iinfo, ®, sizeof(reg), &pintr, sizeof(pintr),
|
||||
mintr, sizeof(mintr), &iparent, maskbuf);
|
||||
mintr, sizeof(mintr), &iparent);
|
||||
if (intrcells) {
|
||||
pintr = ofw_bus_map_intr(dev, iparent, mintr[0]);
|
||||
if (intrcells == 2)
|
||||
|
@ -134,9 +134,9 @@ ofw_pcib_pci_route_interrupt(device_t bridge, device_t dev, int intpin)
|
||||
struct ofw_pcib_softc *sc;
|
||||
struct ofw_bus_iinfo *ii;
|
||||
struct ofw_pci_register reg;
|
||||
cell_t pintr, mintr;
|
||||
cell_t pintr, mintr[2];
|
||||
int intrcells;
|
||||
phandle_t iparent;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(pintr)];
|
||||
|
||||
sc = device_get_softc(bridge);
|
||||
ii = &sc->ops_iinfo;
|
||||
@ -149,15 +149,20 @@ ofw_pcib_pci_route_interrupt(device_t bridge, device_t dev, int intpin)
|
||||
(pci_get_slot(dev) << OFW_PCI_PHYS_HI_DEVICESHIFT) |
|
||||
(pci_get_function(dev) << OFW_PCI_PHYS_HI_FUNCTIONSHIFT);
|
||||
|
||||
if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), ii, ®,
|
||||
sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr),
|
||||
&iparent, maskbuf)) {
|
||||
intrcells = ofw_bus_lookup_imap(ofw_bus_get_node(dev), ii, ®,
|
||||
sizeof(reg), &pintr, sizeof(pintr), mintr, sizeof(mintr),
|
||||
&iparent);
|
||||
if (intrcells) {
|
||||
/*
|
||||
* If we've found a mapping, return it and don't map
|
||||
* it again on higher levels - that causes problems
|
||||
* in some cases, and never seems to be required.
|
||||
*/
|
||||
return (ofw_bus_map_intr(dev, iparent, mintr));
|
||||
mintr[0] = ofw_bus_map_intr(dev, iparent, mintr[0]);
|
||||
if (intrcells == 2)
|
||||
ofw_bus_config_intr(dev, mintr[0], mintr[1]);
|
||||
|
||||
return (mintr[0]);
|
||||
}
|
||||
} else if (intpin >= 1 && intpin <= 4) {
|
||||
/*
|
||||
|
@ -638,7 +638,6 @@ ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, phandle_t node)
|
||||
uint64_t start;
|
||||
uint32_t rintr;
|
||||
int i, nintr, nreg, rv;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(intr)];
|
||||
|
||||
edi = malloc(sizeof(*edi), M_DEVBUF, M_ZERO | M_WAITOK);
|
||||
if (ofw_bus_gen_setup_devinfo(&edi->edi_obdinfo, node) != 0) {
|
||||
@ -673,7 +672,7 @@ ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, phandle_t node)
|
||||
intr = intrs[i];
|
||||
rv = ofw_bus_lookup_imap(node, &sc->sc_iinfo, ®,
|
||||
sizeof(reg), &intr, sizeof(intr), &rintr,
|
||||
sizeof(rintr), NULL, maskbuf);
|
||||
sizeof(rintr), NULL);
|
||||
#ifndef SUN4V
|
||||
if (rv != 0)
|
||||
rintr = INTMAP_VEC(sc->sc_ign, rintr);
|
||||
|
@ -129,7 +129,6 @@ ofw_isa_route_intr(device_t bridge, phandle_t node, struct ofw_bus_iinfo *ii,
|
||||
ofw_isa_intr_t intr)
|
||||
{
|
||||
struct isa_regs reg;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(intr)];
|
||||
device_t pbridge;
|
||||
ofw_isa_intr_t mintr;
|
||||
|
||||
@ -139,7 +138,7 @@ ofw_isa_route_intr(device_t bridge, phandle_t node, struct ofw_bus_iinfo *ii,
|
||||
* fully specified, so we may not continue to map.
|
||||
*/
|
||||
if (!ofw_bus_lookup_imap(node, ii, ®, sizeof(reg),
|
||||
&intr, sizeof(intr), &mintr, sizeof(mintr), NULL, maskbuf)) {
|
||||
&intr, sizeof(intr), &mintr, sizeof(mintr), NULL)) {
|
||||
/* Try routing at the parent bridge. */
|
||||
mintr = PCIB_ROUTE_INTERRUPT(pbridge, bridge, intr);
|
||||
}
|
||||
|
@ -1470,13 +1470,12 @@ fire_route_interrupt(device_t bridge, device_t dev, int pin)
|
||||
struct fire_softc *sc;
|
||||
struct ofw_pci_register reg;
|
||||
ofw_pci_intr_t pintr, mintr;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(pintr)];
|
||||
|
||||
sc = device_get_softc(bridge);
|
||||
pintr = pin;
|
||||
if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), &sc->sc_pci_iinfo,
|
||||
®, sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr),
|
||||
NULL, maskbuf) != 0)
|
||||
NULL) != 0)
|
||||
return (mintr);
|
||||
|
||||
device_printf(bridge, "could not route pin %d for device %d.%d\n",
|
||||
|
@ -70,7 +70,6 @@ ofw_pcib_gen_route_interrupt(device_t bridge, device_t dev, int intpin)
|
||||
struct ofw_bus_iinfo *ii;
|
||||
struct ofw_pci_register reg;
|
||||
ofw_pci_intr_t pintr, mintr;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(pintr)];
|
||||
|
||||
sc = device_get_softc(bridge);
|
||||
ii = &sc->ops_iinfo;
|
||||
@ -78,7 +77,7 @@ ofw_pcib_gen_route_interrupt(device_t bridge, device_t dev, int intpin)
|
||||
pintr = intpin;
|
||||
if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), ii, ®,
|
||||
sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr),
|
||||
NULL, maskbuf)) {
|
||||
NULL)) {
|
||||
/*
|
||||
* If we've found a mapping, return it and don't map
|
||||
* it again on higher levels - that causes problems
|
||||
|
@ -1046,13 +1046,12 @@ psycho_route_interrupt(device_t bridge, device_t dev, int pin)
|
||||
struct ofw_pci_register reg;
|
||||
bus_addr_t intrmap;
|
||||
ofw_pci_intr_t pintr, mintr;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(pintr)];
|
||||
|
||||
sc = device_get_softc(bridge);
|
||||
pintr = pin;
|
||||
if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), &sc->sc_pci_iinfo,
|
||||
®, sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr),
|
||||
NULL, maskbuf))
|
||||
NULL))
|
||||
return (mintr);
|
||||
/*
|
||||
* If this is outside of the range for an intpin, it's likely a full
|
||||
|
@ -1119,13 +1119,12 @@ schizo_route_interrupt(device_t bridge, device_t dev, int pin)
|
||||
struct schizo_softc *sc;
|
||||
struct ofw_pci_register reg;
|
||||
ofw_pci_intr_t pintr, mintr;
|
||||
uint8_t maskbuf[sizeof(reg) + sizeof(pintr)];
|
||||
|
||||
sc = device_get_softc(bridge);
|
||||
pintr = pin;
|
||||
if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), &sc->sc_pci_iinfo,
|
||||
®, sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr),
|
||||
NULL, maskbuf))
|
||||
NULL))
|
||||
return (mintr);
|
||||
|
||||
device_printf(bridge, "could not route pin %d for device %d.%d\n",
|
||||
|
Loading…
Reference in New Issue
Block a user