2005-11-22 16:37:45 +00:00
|
|
|
/*-
|
2008-12-15 15:31:10 +00:00
|
|
|
* Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>.
|
2005-11-22 16:37:45 +00:00
|
|
|
* Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification, immediately at the beginning of the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2010-05-28 10:43:56 +00:00
|
|
|
#include "opt_platform.h"
|
2005-11-22 16:37:45 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/errno.h>
|
2008-12-15 15:31:10 +00:00
|
|
|
#include <sys/libkern.h>
|
2005-11-22 16:37:45 +00:00
|
|
|
|
2008-12-15 15:31:10 +00:00
|
|
|
#include <dev/ofw/ofw_bus.h>
|
2005-11-22 16:37:45 +00:00
|
|
|
#include <dev/ofw/ofw_bus_subr.h>
|
|
|
|
#include <dev/ofw/openfirm.h>
|
|
|
|
|
|
|
|
#include "ofw_bus_if.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
ofw_bus_gen_setup_devinfo(struct ofw_bus_devinfo *obd, phandle_t node)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (obd == NULL)
|
|
|
|
return (ENOMEM);
|
|
|
|
/* The 'name' property is considered mandatory. */
|
|
|
|
if ((OF_getprop_alloc(node, "name", 1, (void **)&obd->obd_name)) == -1)
|
|
|
|
return (EINVAL);
|
|
|
|
OF_getprop_alloc(node, "compatible", 1, (void **)&obd->obd_compat);
|
|
|
|
OF_getprop_alloc(node, "device_type", 1, (void **)&obd->obd_type);
|
|
|
|
OF_getprop_alloc(node, "model", 1, (void **)&obd->obd_model);
|
MFC r261351, r261352, r261355, r261396, r261397, r261398, r261403, r261404,
r261405
Open Firmware interrupt specifiers can consist of arbitrary-length byte
strings and include arbitrary information (IRQ line/domain/sense). When the
ofw_bus_map_intr() API was introduced, it assumed that, as on most systems,
these were either 1 cell, containing an interrupt line, or 2, containing
a line number plus a sense code. It turns out a non-negligible number of
ARM systems use 3 (or even 4!) cells for interrupts, so make this more
general.
Provide a simpler and more standards-compliant simplebus implementation to
get the Routerboard 800 up and running with the vendor device tree. This
does not implement some BERI-specific features (which hopefully won't be
necessary soon), so move the old code to mips/beri, with a higher attach
priority when built, until MIPS interrupt domain support is rearranged.
Allow nesting of simplebuses.
Add a set of helpers (ofw_bus_get_status() and ofw_bus_status_okay()) to
process "status" properties of OF nodes.
Fix one remnant endian flaw in nexus.
2014-05-15 14:26:11 +00:00
|
|
|
OF_getprop_alloc(node, "status", 1, (void **)&obd->obd_status);
|
2005-11-22 16:37:45 +00:00
|
|
|
obd->obd_node = node;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ofw_bus_gen_destroy_devinfo(struct ofw_bus_devinfo *obd)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (obd == NULL)
|
|
|
|
return;
|
|
|
|
if (obd->obd_compat != NULL)
|
|
|
|
free(obd->obd_compat, M_OFWPROP);
|
|
|
|
if (obd->obd_model != NULL)
|
|
|
|
free(obd->obd_model, M_OFWPROP);
|
|
|
|
if (obd->obd_name != NULL)
|
|
|
|
free(obd->obd_name, M_OFWPROP);
|
|
|
|
if (obd->obd_type != NULL)
|
|
|
|
free(obd->obd_type, M_OFWPROP);
|
MFC r261351, r261352, r261355, r261396, r261397, r261398, r261403, r261404,
r261405
Open Firmware interrupt specifiers can consist of arbitrary-length byte
strings and include arbitrary information (IRQ line/domain/sense). When the
ofw_bus_map_intr() API was introduced, it assumed that, as on most systems,
these were either 1 cell, containing an interrupt line, or 2, containing
a line number plus a sense code. It turns out a non-negligible number of
ARM systems use 3 (or even 4!) cells for interrupts, so make this more
general.
Provide a simpler and more standards-compliant simplebus implementation to
get the Routerboard 800 up and running with the vendor device tree. This
does not implement some BERI-specific features (which hopefully won't be
necessary soon), so move the old code to mips/beri, with a higher attach
priority when built, until MIPS interrupt domain support is rearranged.
Allow nesting of simplebuses.
Add a set of helpers (ofw_bus_get_status() and ofw_bus_status_okay()) to
process "status" properties of OF nodes.
Fix one remnant endian flaw in nexus.
2014-05-15 14:26:11 +00:00
|
|
|
if (obd->obd_status != NULL)
|
|
|
|
free(obd->obd_status, M_OFWPROP);
|
2005-11-22 16:37:45 +00:00
|
|
|
}
|
|
|
|
|
2009-06-14 00:05:38 +00:00
|
|
|
int
|
2008-12-15 15:31:10 +00:00
|
|
|
ofw_bus_gen_child_pnpinfo_str(device_t cbdev, device_t child, char *buf,
|
|
|
|
size_t buflen)
|
|
|
|
{
|
2009-06-14 00:05:38 +00:00
|
|
|
|
2008-12-15 15:31:10 +00:00
|
|
|
if (ofw_bus_get_name(child) != NULL) {
|
|
|
|
strlcat(buf, "name=", buflen);
|
|
|
|
strlcat(buf, ofw_bus_get_name(child), buflen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ofw_bus_get_compat(child) != NULL) {
|
|
|
|
strlcat(buf, " compat=", buflen);
|
|
|
|
strlcat(buf, ofw_bus_get_compat(child), buflen);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
};
|
2005-11-22 16:37:45 +00:00
|
|
|
|
|
|
|
const char *
|
|
|
|
ofw_bus_gen_get_compat(device_t bus, device_t dev)
|
|
|
|
{
|
|
|
|
const struct ofw_bus_devinfo *obd;
|
2009-06-14 00:05:38 +00:00
|
|
|
|
|
|
|
obd = OFW_BUS_GET_DEVINFO(bus, dev);
|
2005-11-22 16:37:45 +00:00
|
|
|
if (obd == NULL)
|
|
|
|
return (NULL);
|
|
|
|
return (obd->obd_compat);
|
|
|
|
}
|
2009-06-14 00:05:38 +00:00
|
|
|
|
2005-11-22 16:37:45 +00:00
|
|
|
const char *
|
|
|
|
ofw_bus_gen_get_model(device_t bus, device_t dev)
|
|
|
|
{
|
|
|
|
const struct ofw_bus_devinfo *obd;
|
|
|
|
|
2009-06-14 00:05:38 +00:00
|
|
|
obd = OFW_BUS_GET_DEVINFO(bus, dev);
|
2005-11-22 16:37:45 +00:00
|
|
|
if (obd == NULL)
|
|
|
|
return (NULL);
|
|
|
|
return (obd->obd_model);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
ofw_bus_gen_get_name(device_t bus, device_t dev)
|
|
|
|
{
|
|
|
|
const struct ofw_bus_devinfo *obd;
|
|
|
|
|
2009-06-14 00:05:38 +00:00
|
|
|
obd = OFW_BUS_GET_DEVINFO(bus, dev);
|
2005-11-22 16:37:45 +00:00
|
|
|
if (obd == NULL)
|
|
|
|
return (NULL);
|
|
|
|
return (obd->obd_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
phandle_t
|
|
|
|
ofw_bus_gen_get_node(device_t bus, device_t dev)
|
|
|
|
{
|
|
|
|
const struct ofw_bus_devinfo *obd;
|
|
|
|
|
2009-06-14 00:05:38 +00:00
|
|
|
obd = OFW_BUS_GET_DEVINFO(bus, dev);
|
2005-11-22 16:37:45 +00:00
|
|
|
if (obd == NULL)
|
|
|
|
return (0);
|
|
|
|
return (obd->obd_node);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
ofw_bus_gen_get_type(device_t bus, device_t dev)
|
|
|
|
{
|
|
|
|
const struct ofw_bus_devinfo *obd;
|
|
|
|
|
2009-06-14 00:05:38 +00:00
|
|
|
obd = OFW_BUS_GET_DEVINFO(bus, dev);
|
2005-11-22 16:37:45 +00:00
|
|
|
if (obd == NULL)
|
|
|
|
return (NULL);
|
|
|
|
return (obd->obd_type);
|
|
|
|
}
|
2008-12-15 15:31:10 +00:00
|
|
|
|
MFC r261351, r261352, r261355, r261396, r261397, r261398, r261403, r261404,
r261405
Open Firmware interrupt specifiers can consist of arbitrary-length byte
strings and include arbitrary information (IRQ line/domain/sense). When the
ofw_bus_map_intr() API was introduced, it assumed that, as on most systems,
these were either 1 cell, containing an interrupt line, or 2, containing
a line number plus a sense code. It turns out a non-negligible number of
ARM systems use 3 (or even 4!) cells for interrupts, so make this more
general.
Provide a simpler and more standards-compliant simplebus implementation to
get the Routerboard 800 up and running with the vendor device tree. This
does not implement some BERI-specific features (which hopefully won't be
necessary soon), so move the old code to mips/beri, with a higher attach
priority when built, until MIPS interrupt domain support is rearranged.
Allow nesting of simplebuses.
Add a set of helpers (ofw_bus_get_status() and ofw_bus_status_okay()) to
process "status" properties of OF nodes.
Fix one remnant endian flaw in nexus.
2014-05-15 14:26:11 +00:00
|
|
|
const char *
|
|
|
|
ofw_bus_get_status(device_t dev)
|
|
|
|
{
|
|
|
|
const struct ofw_bus_devinfo *obd;
|
|
|
|
|
|
|
|
obd = OFW_BUS_GET_DEVINFO(device_get_parent(dev), dev);
|
|
|
|
if (obd == NULL)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
return (obd->obd_status);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ofw_bus_status_okay(device_t dev)
|
|
|
|
{
|
|
|
|
const char *status;
|
|
|
|
|
|
|
|
status = ofw_bus_get_status(dev);
|
|
|
|
if (status == NULL || strcmp(status, "okay") == 0)
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2010-05-28 10:43:56 +00:00
|
|
|
int
|
|
|
|
ofw_bus_is_compatible(device_t dev, const char *onecompat)
|
|
|
|
{
|
|
|
|
phandle_t node;
|
|
|
|
const char *compat;
|
|
|
|
int len, onelen, l;
|
|
|
|
|
|
|
|
if ((compat = ofw_bus_get_compat(dev)) == NULL)
|
|
|
|
return (0);
|
|
|
|
|
2012-03-15 22:53:39 +00:00
|
|
|
if ((node = ofw_bus_get_node(dev)) == -1)
|
2010-05-28 10:43:56 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
/* Get total 'compatible' prop len */
|
|
|
|
if ((len = OF_getproplen(node, "compatible")) <= 0)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
onelen = strlen(onecompat);
|
|
|
|
|
|
|
|
while (len > 0) {
|
2012-08-18 11:25:07 +00:00
|
|
|
if (strlen(compat) == onelen &&
|
|
|
|
strncasecmp(compat, onecompat, onelen) == 0)
|
2010-05-28 10:43:56 +00:00
|
|
|
/* Found it. */
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
/* Slide to the next sub-string. */
|
|
|
|
l = strlen(compat) + 1;
|
|
|
|
compat += l;
|
|
|
|
len -= l;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ofw_bus_is_compatible_strict(device_t dev, const char *compatible)
|
|
|
|
{
|
|
|
|
const char *compat;
|
2012-08-18 11:25:07 +00:00
|
|
|
size_t len;
|
2010-05-28 10:43:56 +00:00
|
|
|
|
|
|
|
if ((compat = ofw_bus_get_compat(dev)) == NULL)
|
|
|
|
return (0);
|
|
|
|
|
2012-08-18 11:25:07 +00:00
|
|
|
len = strlen(compatible);
|
|
|
|
if (strlen(compat) == len &&
|
|
|
|
strncasecmp(compat, compatible, len) == 0)
|
2010-05-28 10:43:56 +00:00
|
|
|
return (1);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2013-12-13 17:23:47 +00:00
|
|
|
const struct ofw_compat_data *
|
|
|
|
ofw_bus_search_compatible(device_t dev, const struct ofw_compat_data *compat)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (compat == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (; compat->ocd_str != NULL; ++compat) {
|
|
|
|
if (ofw_bus_is_compatible(dev, compat->ocd_str))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (compat);
|
|
|
|
}
|
|
|
|
|
2012-08-18 11:25:07 +00:00
|
|
|
int
|
|
|
|
ofw_bus_has_prop(device_t dev, const char *propname)
|
|
|
|
{
|
|
|
|
phandle_t node;
|
|
|
|
|
|
|
|
if ((node = ofw_bus_get_node(dev)) == -1)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (OF_hasprop(node, propname));
|
|
|
|
}
|
|
|
|
|
2008-12-15 15:31:10 +00:00
|
|
|
void
|
|
|
|
ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz)
|
|
|
|
{
|
|
|
|
pcell_t addrc;
|
|
|
|
int msksz;
|
|
|
|
|
2014-05-13 17:59:17 +00:00
|
|
|
if (OF_getencprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1)
|
2008-12-15 15:31:10 +00:00
|
|
|
addrc = 2;
|
|
|
|
ii->opi_addrc = addrc * sizeof(pcell_t);
|
|
|
|
|
2014-05-13 17:59:17 +00:00
|
|
|
ii->opi_imapsz = OF_getencprop_alloc(node, "interrupt-map", 1,
|
2008-12-15 15:31:10 +00:00
|
|
|
(void **)&ii->opi_imap);
|
|
|
|
if (ii->opi_imapsz > 0) {
|
2014-05-13 17:59:17 +00:00
|
|
|
msksz = OF_getencprop_alloc(node, "interrupt-map-mask", 1,
|
2008-12-15 15:31:10 +00:00
|
|
|
(void **)&ii->opi_imapmsk);
|
|
|
|
/*
|
2009-06-14 00:05:38 +00:00
|
|
|
* Failure to get the mask is ignored; a full mask is used
|
|
|
|
* then. We barf on bad mask sizes, however.
|
2008-12-15 15:31:10 +00:00
|
|
|
*/
|
2009-06-14 00:05:38 +00:00
|
|
|
if (msksz != -1 && msksz != ii->opi_addrc + intrsz)
|
2008-12-15 15:31:10 +00:00
|
|
|
panic("ofw_bus_setup_iinfo: bad interrupt-map-mask "
|
|
|
|
"property!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
MFC r258800, r258802, r258805, r258806, r258807, r258851, r258857,
r259199, r259484, r259513, r259514, r259516
The kernel stack guard pages are only below the stack pointer, not above.
Remove unnecessary double-setting of the thread's onfault state in
copyinstr().
Open Firmware mandates that certain cross-references, in particular those
in /chosen, be ihandles. The ePAPR spec makes those cross-reference phandles,
since FDT has no concept of ihandles. Have the OF FDT CI module interpret
queries about ihandles as cross-reference phandles.
Real OF systems have an ihandle under /chosen/stdout, not a phandle. Use
the right type.
Rearchitect platform memory map parsing to make it less
Open Firmware-centric.
Remove fdtbus_bs_tag definition, which is now obsolete. The remainder of
this file is also slated for future demolition.
Return the correct IEEE 1275 code for "nextprop".
Use the common Open Firmware PCI interrupt routing code instead of the
duplicate version in dev/fdt.
Configure interrupt sense based on device tree information.
Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
internally instead of requiring the caller to allocate it.
2014-05-14 14:17:51 +00:00
|
|
|
phandle_t *iparent)
|
2008-12-15 15:31:10 +00:00
|
|
|
{
|
MFC r258800, r258802, r258805, r258806, r258807, r258851, r258857,
r259199, r259484, r259513, r259514, r259516
The kernel stack guard pages are only below the stack pointer, not above.
Remove unnecessary double-setting of the thread's onfault state in
copyinstr().
Open Firmware mandates that certain cross-references, in particular those
in /chosen, be ihandles. The ePAPR spec makes those cross-reference phandles,
since FDT has no concept of ihandles. Have the OF FDT CI module interpret
queries about ihandles as cross-reference phandles.
Real OF systems have an ihandle under /chosen/stdout, not a phandle. Use
the right type.
Rearchitect platform memory map parsing to make it less
Open Firmware-centric.
Remove fdtbus_bs_tag definition, which is now obsolete. The remainder of
this file is also slated for future demolition.
Return the correct IEEE 1275 code for "nextprop".
Use the common Open Firmware PCI interrupt routing code instead of the
duplicate version in dev/fdt.
Configure interrupt sense based on device tree information.
Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
internally instead of requiring the caller to allocate it.
2014-05-14 14:17:51 +00:00
|
|
|
uint8_t maskbuf[regsz + pintrsz];
|
2008-12-15 15:31:10 +00:00
|
|
|
int rv;
|
|
|
|
|
|
|
|
if (ii->opi_imapsz <= 0)
|
|
|
|
return (0);
|
|
|
|
KASSERT(regsz >= ii->opi_addrc,
|
|
|
|
("ofw_bus_lookup_imap: register size too small: %d < %d",
|
|
|
|
regsz, ii->opi_addrc));
|
2014-05-13 16:59:50 +00:00
|
|
|
if (node != -1) {
|
2014-05-13 17:59:17 +00:00
|
|
|
rv = OF_getencprop(node, "reg", reg, regsz);
|
2014-05-13 16:59:50 +00:00
|
|
|
if (rv < regsz)
|
|
|
|
panic("ofw_bus_lookup_imap: cannot get reg property");
|
|
|
|
}
|
2008-12-15 15:31:10 +00:00
|
|
|
return (ofw_bus_search_intrmap(pintr, pintrsz, reg, ii->opi_addrc,
|
|
|
|
ii->opi_imap, ii->opi_imapsz, ii->opi_imapmsk, maskbuf, mintr,
|
2010-06-18 14:06:27 +00:00
|
|
|
mintrsz, iparent));
|
2008-12-15 15:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Map an interrupt using the firmware reg, interrupt-map and
|
|
|
|
* interrupt-map-mask properties.
|
|
|
|
* The interrupt property to be mapped must be of size intrsz, and pointed to
|
2009-06-14 00:05:38 +00:00
|
|
|
* by intr. The regs property of the node for which the mapping is done must
|
2008-12-15 15:31:10 +00:00
|
|
|
* be passed as regs. This property is an array of register specifications;
|
|
|
|
* the size of the address part of such a specification must be passed as
|
2009-06-14 00:05:38 +00:00
|
|
|
* physsz. Only the first element of the property is used.
|
2008-12-15 15:31:10 +00:00
|
|
|
* imap and imapsz hold the interrupt mask and it's size.
|
|
|
|
* imapmsk is a pointer to the interrupt-map-mask property, which must have
|
|
|
|
* a size of physsz + intrsz; it may be NULL, in which case a full mask is
|
|
|
|
* assumed.
|
|
|
|
* maskbuf must point to a buffer of length physsz + intrsz.
|
|
|
|
* The interrupt is returned in result, which must point to a buffer of length
|
|
|
|
* rintrsz (which gives the expected size of the mapped interrupt).
|
MFC r258800, r258802, r258805, r258806, r258807, r258851, r258857,
r259199, r259484, r259513, r259514, r259516
The kernel stack guard pages are only below the stack pointer, not above.
Remove unnecessary double-setting of the thread's onfault state in
copyinstr().
Open Firmware mandates that certain cross-references, in particular those
in /chosen, be ihandles. The ePAPR spec makes those cross-reference phandles,
since FDT has no concept of ihandles. Have the OF FDT CI module interpret
queries about ihandles as cross-reference phandles.
Real OF systems have an ihandle under /chosen/stdout, not a phandle. Use
the right type.
Rearchitect platform memory map parsing to make it less
Open Firmware-centric.
Remove fdtbus_bs_tag definition, which is now obsolete. The remainder of
this file is also slated for future demolition.
Return the correct IEEE 1275 code for "nextprop".
Use the common Open Firmware PCI interrupt routing code instead of the
duplicate version in dev/fdt.
Configure interrupt sense based on device tree information.
Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
internally instead of requiring the caller to allocate it.
2014-05-14 14:17:51 +00:00
|
|
|
* Returns number of cells in the interrupt if a mapping was found, 0 otherwise.
|
2008-12-15 15:31:10 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
|
|
|
|
void *imap, int imapsz, void *imapmsk, void *maskbuf, void *result,
|
2010-06-18 14:06:27 +00:00
|
|
|
int rintrsz, phandle_t *iparent)
|
2008-12-15 15:31:10 +00:00
|
|
|
{
|
|
|
|
phandle_t parent;
|
2009-06-14 00:05:38 +00:00
|
|
|
uint8_t *ref = maskbuf;
|
|
|
|
uint8_t *uiintr = intr;
|
|
|
|
uint8_t *uiregs = regs;
|
|
|
|
uint8_t *uiimapmsk = imapmsk;
|
|
|
|
uint8_t *mptr;
|
2008-12-15 15:31:10 +00:00
|
|
|
pcell_t pintrsz;
|
|
|
|
int i, rsz, tsz;
|
|
|
|
|
|
|
|
rsz = -1;
|
|
|
|
if (imapmsk != NULL) {
|
|
|
|
for (i = 0; i < physsz; i++)
|
|
|
|
ref[i] = uiregs[i] & uiimapmsk[i];
|
|
|
|
for (i = 0; i < intrsz; i++)
|
|
|
|
ref[physsz + i] = uiintr[i] & uiimapmsk[physsz + i];
|
|
|
|
} else {
|
|
|
|
bcopy(regs, ref, physsz);
|
|
|
|
bcopy(intr, ref + physsz, intrsz);
|
|
|
|
}
|
|
|
|
|
|
|
|
mptr = imap;
|
|
|
|
i = imapsz;
|
|
|
|
while (i > 0) {
|
|
|
|
bcopy(mptr + physsz + intrsz, &parent, sizeof(parent));
|
2014-05-13 17:59:17 +00:00
|
|
|
if (OF_searchencprop(OF_xref_phandle(parent),
|
|
|
|
"#interrupt-cells", &pintrsz, sizeof(pintrsz)) == -1)
|
2008-12-15 15:31:10 +00:00
|
|
|
pintrsz = 1; /* default */
|
|
|
|
pintrsz *= sizeof(pcell_t);
|
2009-01-03 19:38:47 +00:00
|
|
|
|
2009-06-14 00:05:38 +00:00
|
|
|
/* Compute the map stride size. */
|
2009-01-03 19:38:47 +00:00
|
|
|
tsz = physsz + intrsz + sizeof(phandle_t) + pintrsz;
|
|
|
|
KASSERT(i >= tsz, ("ofw_bus_search_intrmap: truncated map"));
|
2009-06-14 00:05:38 +00:00
|
|
|
|
2008-12-15 15:31:10 +00:00
|
|
|
if (bcmp(ref, mptr, physsz + intrsz) == 0) {
|
|
|
|
bcopy(mptr + physsz + intrsz + sizeof(parent),
|
MFC r258800, r258802, r258805, r258806, r258807, r258851, r258857,
r259199, r259484, r259513, r259514, r259516
The kernel stack guard pages are only below the stack pointer, not above.
Remove unnecessary double-setting of the thread's onfault state in
copyinstr().
Open Firmware mandates that certain cross-references, in particular those
in /chosen, be ihandles. The ePAPR spec makes those cross-reference phandles,
since FDT has no concept of ihandles. Have the OF FDT CI module interpret
queries about ihandles as cross-reference phandles.
Real OF systems have an ihandle under /chosen/stdout, not a phandle. Use
the right type.
Rearchitect platform memory map parsing to make it less
Open Firmware-centric.
Remove fdtbus_bs_tag definition, which is now obsolete. The remainder of
this file is also slated for future demolition.
Return the correct IEEE 1275 code for "nextprop".
Use the common Open Firmware PCI interrupt routing code instead of the
duplicate version in dev/fdt.
Configure interrupt sense based on device tree information.
Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
internally instead of requiring the caller to allocate it.
2014-05-14 14:17:51 +00:00
|
|
|
result, MIN(rintrsz, pintrsz));
|
2010-06-18 14:06:27 +00:00
|
|
|
|
|
|
|
if (iparent != NULL)
|
|
|
|
*iparent = parent;
|
MFC r258800, r258802, r258805, r258806, r258807, r258851, r258857,
r259199, r259484, r259513, r259514, r259516
The kernel stack guard pages are only below the stack pointer, not above.
Remove unnecessary double-setting of the thread's onfault state in
copyinstr().
Open Firmware mandates that certain cross-references, in particular those
in /chosen, be ihandles. The ePAPR spec makes those cross-reference phandles,
since FDT has no concept of ihandles. Have the OF FDT CI module interpret
queries about ihandles as cross-reference phandles.
Real OF systems have an ihandle under /chosen/stdout, not a phandle. Use
the right type.
Rearchitect platform memory map parsing to make it less
Open Firmware-centric.
Remove fdtbus_bs_tag definition, which is now obsolete. The remainder of
this file is also slated for future demolition.
Return the correct IEEE 1275 code for "nextprop".
Use the common Open Firmware PCI interrupt routing code instead of the
duplicate version in dev/fdt.
Configure interrupt sense based on device tree information.
Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
internally instead of requiring the caller to allocate it.
2014-05-14 14:17:51 +00:00
|
|
|
return (pintrsz/sizeof(pcell_t));
|
2008-12-15 15:31:10 +00:00
|
|
|
}
|
|
|
|
mptr += tsz;
|
|
|
|
i -= tsz;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
2014-05-13 16:59:50 +00:00
|
|
|
|