本文整理汇总了C++中OF_peer函数的典型用法代码示例。如果您正苦于以下问题:C++ OF_peer函数的具体用法?C++ OF_peer怎么用?C++ OF_peer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OF_peer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vbus_attach
void
vbus_attach(device_t parent, device_t self, void *aux)
{
struct vbus_softc *sc = device_private(self);
struct mainbus_attach_args *ma = aux;
int node;
sc->sc_bustag = vbus_alloc_bus_tag(sc, ma->ma_bustag);
sc->sc_dmatag = ma->ma_dmatag;
printf("\n");
for (node = OF_child(ma->ma_node); node; node = OF_peer(node)) {
struct vbus_attach_args va;
char buf[32];
bzero(&va, sizeof(va));
va.va_node = node;
if (OF_getprop(node, "name", buf, sizeof(buf)) <= 0)
continue;
va.va_name = buf;
va.va_bustag = sc->sc_bustag;
va.va_dmatag = sc->sc_dmatag;
prom_getprop(node, "reg", sizeof(*va.va_reg),
&va.va_nreg, (void **)&va.va_reg);
prom_getprop(node, "interrupts", sizeof(*va.va_intr),
&va.va_nintr, (void **)&va.va_intr);
config_found(self, &va, vbus_print);
}
struct vbus_attach_args va;
bzero(&va, sizeof(va));
va.va_name = "rtc";
config_found(self, &va, vbus_print);
}
示例2: localbus_attach
static int
localbus_attach(device_t dev)
{
device_t dev_child;
struct localbus_softc *sc;
struct localbus_devinfo *di;
phandle_t dt_node, dt_child;
sc = device_get_softc(dev);
sc->sc_dev = dev;
sc->sc_banks = localbus_banks;
/*
* Walk localbus and add direct subordinates as our children.
*/
dt_node = ofw_bus_get_node(dev);
for (dt_child = OF_child(dt_node); dt_child != 0;
dt_child = OF_peer(dt_child)) {
/* Check and process 'status' property. */
if (!(fdt_is_enabled(dt_child)))
continue;
if (!(fdt_pm_is_enabled(dt_child)))
continue;
di = malloc(sizeof(*di), M_LOCALBUS, M_WAITOK | M_ZERO);
if (ofw_bus_gen_setup_devinfo(&di->di_ofw, dt_child) != 0) {
free(di, M_LOCALBUS);
device_printf(dev, "could not set up devinfo\n");
continue;
}
resource_list_init(&di->di_res);
if (fdt_localbus_reg_decode(dt_child, sc, di)) {
device_printf(dev, "could not process 'reg' "
"property\n");
ofw_bus_gen_destroy_devinfo(&di->di_ofw);
free(di, M_LOCALBUS);
continue;
}
/* Add newbus device for this FDT node */
dev_child = device_add_child(dev, NULL, -1);
if (dev_child == NULL) {
device_printf(dev, "could not add child: %s\n",
di->di_ofw.obd_name);
resource_list_free(&di->di_res);
ofw_bus_gen_destroy_devinfo(&di->di_ofw);
free(di, M_LOCALBUS);
continue;
}
#ifdef DEBUG
device_printf(dev, "added child: %s\n\n", di->di_ofw.obd_name);
#endif
device_set_ivars(dev_child, di);
}
return (bus_generic_attach(dev));
}
示例3: oskit_linux_ofw_findnode
/*
* Search the OFW's device tree for a named node, and return the package
* handle for it.
*/
int
oskit_linux_ofw_findnode(char *name)
{
int node, child;
int oskit_linux_ofw_findnode_child(char *, int);
if (!(node = OF_peer(0)))
panic("No OFW root");
for (child = OF_child(node); child; child = OF_peer(child)) {
if ((node = oskit_linux_ofw_findnode_child(name, child)))
return node;
}
return 0;
}
示例4: ofw_bus_find_compatible
phandle_t
ofw_bus_find_compatible(phandle_t node, const char *onecompat)
{
phandle_t child, ret;
void *compat;
int len;
/*
* Traverse all children of 'start' node, and find first with
* matching 'compatible' property.
*/
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
len = OF_getprop_alloc(child, "compatible", 1, &compat);
if (len >= 0) {
ret = ofw_bus_node_is_compatible(compat, len,
onecompat);
free(compat, M_OFWPROP);
if (ret != 0)
return (child);
}
ret = ofw_bus_find_compatible(child, onecompat);
if (ret != 0)
return (ret);
}
return (0);
}
示例5: pci_from_fdt_node
static void
pci_from_fdt_node(device_t dev_par, phandle_t dt_node, char *name,
char *type, char *compat)
{
u_long reg_base, reg_size;
phandle_t dt_child;
/*
* Retrieve 'reg' property.
*/
if (fdt_regsize(dt_node, ®_base, ®_size) != 0) {
device_printf(dev_par, "could not retrieve 'reg' prop\n");
return;
}
/*
* Walk the PCI node and instantiate newbus devices representing
* logical resources (bridges / ports).
*/
for (dt_child = OF_child(dt_node); dt_child != 0;
dt_child = OF_peer(dt_child)) {
if (!(fdt_is_enabled(dt_child)))
continue;
newbus_pci_create(dev_par, dt_child, reg_base, reg_size);
}
}
示例6: lebuffer_attach
static int
lebuffer_attach(device_t dev)
{
struct lebuffer_devinfo *ldi;
device_t cdev;
phandle_t child;
int children;
children = 0;
for (child = OF_child(ofw_bus_get_node(dev)); child != 0;
child = OF_peer(child)) {
if ((ldi = lebuffer_setup_dinfo(dev, child)) == NULL)
continue;
if (children != 0) {
device_printf(dev,
"<%s>: only one child per buffer supported\n",
ldi->ldi_obdinfo.obd_name);
lebuffer_destroy_dinfo(ldi);
continue;
}
if ((cdev = device_add_child(dev, NULL, -1)) == NULL) {
device_printf(dev, "<%s>: device_add_child failed\n",
ldi->ldi_obdinfo.obd_name);
lebuffer_destroy_dinfo(ldi);
continue;
}
device_set_ivars(cdev, ldi);
children++;
}
return (bus_generic_attach(dev));
}
示例7: ofw_cpulist_attach
static int
ofw_cpulist_attach(device_t dev)
{
struct ofw_cpulist_softc *sc;
phandle_t root, child;
device_t cdev;
struct ofw_bus_devinfo *dinfo;
sc = device_get_softc(dev);
root = ofw_bus_get_node(dev);
sc->sc_addr_cells = 1;
OF_getencprop(root, "#address-cells", &sc->sc_addr_cells,
sizeof(sc->sc_addr_cells));
for (child = OF_child(root); child != 0; child = OF_peer(child)) {
dinfo = malloc(sizeof(*dinfo), M_OFWCPU, M_WAITOK | M_ZERO);
if (ofw_bus_gen_setup_devinfo(dinfo, child) != 0) {
free(dinfo, M_OFWCPU);
continue;
}
cdev = device_add_child(dev, NULL, -1);
if (cdev == NULL) {
device_printf(dev, "<%s>: device_add_child failed\n",
dinfo->obd_name);
ofw_bus_gen_destroy_devinfo(dinfo);
free(dinfo, M_OFWCPU);
continue;
}
device_set_ivars(cdev, dinfo);
}
return (bus_generic_attach(dev));
}
示例8: ofw_pci_find_node
phandle_t
ofw_pci_find_node(int bus, int slot, int func)
{
phandle_t node, bnode;
struct ofw_pci_register pcir;
/*
* Retrieve the bus node from the mapping that was created on
* initialization. The bus numbers the firmware uses cannot be trusted,
* so they might have needed to be changed and this is necessary.
*/
if (bus >= pci_bus_map_sz)
return (0);
bnode = pci_bus_map[bus];
if (bnode == 0)
return (0);
for (node = OF_child(bnode); node != 0 && node != -1;
node = OF_peer(node)) {
if (OF_getprop(node, "reg", &pcir, sizeof(pcir)) == -1)
continue;
if (OFW_PCI_PHYS_HI_DEVICE(pcir.phys_hi) == slot &&
OFW_PCI_PHYS_HI_FUNCTION(pcir.phys_hi) == func)
return (node);
}
return (0);
}
示例9: ofw_spibus_attach
static int
ofw_spibus_attach(device_t dev)
{
struct spibus_softc *sc = device_get_softc(dev);
struct ofw_spibus_devinfo *dinfo;
phandle_t child;
pcell_t clock, paddr;
device_t childdev;
sc->dev = dev;
bus_generic_probe(dev);
bus_enumerate_hinted_children(dev);
/*
* Attach those children represented in the device tree.
*/
for (child = OF_child(ofw_bus_get_node(dev)); child != 0;
child = OF_peer(child)) {
/*
* Try to get the CS number first from the spi-chipselect
* property, then try the reg property.
*/
if (OF_getencprop(child, "spi-chipselect", &paddr,
sizeof(paddr)) == -1) {
if (OF_getencprop(child, "reg", &paddr,
sizeof(paddr)) == -1)
continue;
}
/*
* Get the maximum clock frequency for device, zero means
* use the default bus speed.
*/
if (OF_getencprop(child, "spi-max-frequency", &clock,
sizeof(clock)) == -1)
clock = 0;
/*
* Now set up the SPI and OFW bus layer devinfo and add it
* to the bus.
*/
dinfo = malloc(sizeof(struct ofw_spibus_devinfo), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (dinfo == NULL)
continue;
dinfo->opd_dinfo.cs = paddr;
dinfo->opd_dinfo.clock = clock;
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
0) {
free(dinfo, M_DEVBUF);
continue;
}
childdev = device_add_child(dev, NULL, -1);
device_set_ivars(childdev, dinfo);
}
return (bus_generic_attach(dev));
}
示例10: mtk_pinctrl_configure
static int
mtk_pinctrl_configure(device_t dev, phandle_t cfgxref)
{
struct mtk_pin_group *pintable;
phandle_t node, child;
uint32_t socid;
int ret;
node = OF_node_from_xref(cfgxref);
ret = 0;
/* Now, get the system type, so we can get the proper GPIO mode array */
socid = mtk_soc_get_socid();
switch (socid) {
case MTK_SOC_RT3050: /* fallthrough */
case MTK_SOC_RT3052:
case MTK_SOC_RT3350:
pintable = rt3050_pintable;
break;
case MTK_SOC_RT3352:
pintable = rt3352_pintable;
break;
case MTK_SOC_RT3662: /* fallthrough */
case MTK_SOC_RT3883:
pintable = rt3883_pintable;
break;
case MTK_SOC_RT5350:
pintable = rt5350_pintable;
break;
case MTK_SOC_MT7620A: /* fallthrough */
case MTK_SOC_MT7620N:
pintable = mt7620_pintable;
break;
case MTK_SOC_MT7628: /* fallthrough */
case MTK_SOC_MT7688:
pintable = mt7628_pintable;
break;
case MTK_SOC_MT7621:
pintable = mt7621_pintable;
break;
default:
ret = ENOENT;
goto out;
}
/*
* OpenWRT dts files have single child within the pinctrl nodes, which
* contains the 'ralink,group' and 'ralink,function' properties.
*/
for (child = OF_child(node); child != 0 && child != -1;
child = OF_peer(child)) {
if ((ret = mtk_pinctrl_process_node(dev, pintable, child)) != 0)
return (ret);
}
out:
return (ret);
}
示例11: openprom_node_valid
static int
openprom_node_valid(phandle_t node)
{
if (node == 0)
return (0);
return (openprom_node_search(OF_peer(0), node));
}
示例12: jz4780_pinctrl_attach
static int
jz4780_pinctrl_attach(device_t dev)
{
struct jz4780_pinctrl_softc *sc;
struct resource_list *rs;
struct resource_list_entry *re;
phandle_t dt_parent, dt_child;
int i, ret;
sc = device_get_softc(dev);
sc->dev = dev;
/*
* Fetch our own resource list to dole memory between children
*/
rs = BUS_GET_RESOURCE_LIST(device_get_parent(dev), dev);
if (rs == NULL)
return (ENXIO);
re = resource_list_find(rs, SYS_RES_MEMORY, 0);
if (re == NULL)
return (ENXIO);
simplebus_init(dev, 0);
/* Iterate over this node children, looking for pin controllers */
dt_parent = ofw_bus_get_node(dev);
i = 0;
for (dt_child = OF_child(dt_parent); dt_child != 0;
dt_child = OF_peer(dt_child)) {
struct simplebus_devinfo *ndi;
device_t child;
bus_addr_t phys;
bus_size_t size;
/* Add gpio controller child */
if (!OF_hasprop(dt_child, "gpio-controller"))
continue;
child = simplebus_add_device(dev, dt_child, 0, NULL, -1, NULL);
if (child == NULL)
break;
/* Setup child resources */
phys = CHIP_REG_OFFSET(re->start, i);
size = CHIP_REG_STRIDE;
if (phys + size - 1 <= re->end) {
ndi = device_get_ivars(child);
resource_list_add(&ndi->rl, SYS_RES_MEMORY, 0,
phys, phys + size - 1, size);
}
i++;
}
ret = bus_generic_attach(dev);
if (ret == 0) {
fdt_pinctrl_register(dev, "ingenic,pins");
fdt_pinctrl_configure_tree(dev);
}
return (ret);
}
示例13: openpromcheckid
/*
* Verify target ID is valid (exists in the OPENPROM tree), as
* listed from node ID sid forward.
*/
int
openpromcheckid(int sid, int tid)
{
for (; sid != 0; sid = OF_peer(sid))
if (sid == tid || openpromcheckid(OF_child(sid), tid))
return (1);
return (0);
}
示例14: bare_probe
static int
bare_probe(platform_t plat)
{
if (OF_peer(0) == -1) /* Needs device tree to work */
return (ENXIO);
return (BUS_PROBE_GENERIC);
}
示例15: gic_v3_ofw_bus_attach
/*
* Bus capability support for GICv3.
* Collects and configures device informations and finally
* adds ITS device as a child of GICv3 in Newbus hierarchy.
*/
static int
gic_v3_ofw_bus_attach(device_t dev)
{
struct gic_v3_ofw_devinfo *di;
device_t child;
phandle_t parent, node;
pcell_t addr_cells, size_cells;
parent = ofw_bus_get_node(dev);
if (parent > 0) {
addr_cells = 2;
OF_getencprop(parent, "#address-cells", &addr_cells,
sizeof(addr_cells));
size_cells = 2;
OF_getencprop(parent, "#size-cells", &size_cells,
sizeof(size_cells));
/* Iterate through all GIC subordinates */
for (node = OF_child(parent); node > 0; node = OF_peer(node)) {
/* Allocate and populate devinfo. */
di = malloc(sizeof(*di), M_GIC_V3, M_WAITOK | M_ZERO);
if (ofw_bus_gen_setup_devinfo(&di->di_dinfo, node)) {
if (bootverbose) {
device_printf(dev,
"Could not set up devinfo for ITS\n");
}
free(di, M_GIC_V3);
continue;
}
/* Initialize and populate resource list. */
resource_list_init(&di->di_rl);
ofw_bus_reg_to_rl(dev, node, addr_cells, size_cells,
&di->di_rl);
/* Should not have any interrupts, so don't add any */
/* Add newbus device for this FDT node */
child = device_add_child(dev, NULL, -1);
if (!child) {
if (bootverbose) {
device_printf(dev,
"Could not add child: %s\n",
di->di_dinfo.obd_name);
}
resource_list_free(&di->di_rl);
ofw_bus_gen_destroy_devinfo(&di->di_dinfo);
free(di, M_GIC_V3);
continue;
}
device_set_ivars(child, di);
}
}
return (bus_generic_attach(dev));
}