// SPDX-License-Identifier: GPL-2.0-or-later /* * Procedures for creating, accessing and interpreting the device tree. * * Paul Mackerras August 1996. * Copyright (C) 1996-2005 Paul Mackerras. * * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. * {engebret|bergner}@us.ibm.com * * Adapted for sparc64 by David S. Miller davem@davemloft.net
*/
if (!ret) {
prom_printf("prom_early_alloc(%lu) failed\n", size);
prom_halt();
}
prom_early_allocated += size;
return ret;
}
/* The following routines deal with the black magic of fully naming a * node. * * Certain well known named nodes are just the simple name string. * * Actual devices have an address specifier appended to the base name * string, like this "foo@addr". The "addr" can be in any number of * formats, and the platform plus the type of the node determine the * format and how it is constructed. * * For children of the ROOT node, the naming convention is fixed and * determined by whether this is a sun4u or sun4v system. * * For children of other nodes, it is bus type specific. So * we walk up the tree until we discover a "device_type" property * we recognize and we go from there. * * As an example, the boot device on my workstation has a full path: * * /pci@1e,600000/ide@d/disk@0,0:c
*/ staticvoid __init sun4v_path_component(struct device_node *dp, char *tmp_buf)
{ constchar *name = of_get_property(dp, "name", NULL); struct linux_prom64_registers *regs; struct property *rprop;
u32 high_bits, low_bits, type;
rprop = of_find_property(dp, "reg", NULL); if (!rprop) return;
prop = of_find_property(dp, "reg", NULL); if (!prop) return;
regs = prop->value;
/* This actually isn't right... should look at the #address-cells * property of the i2c bus node etc. etc.
*/
sprintf(tmp_buf, "%s@%x,%x",
name, regs[0], regs[1]);
}
bool arch_find_n_match_cpu_physical_id(struct device_node *cpun, int cpu, unsignedint *thread)
{ constchar *mid_prop = get_mid_prop(); int this_cpu_id;
/* On hypervisor based platforms we interrogate the 'reg' * property. On everything else we look for a 'upa-portid', * 'portid', or 'cpuid' property.
*/
if (this_cpu_id < 0) {
mid_prop = "cpuid";
this_cpu_id = of_getintprop_default(cpun, mid_prop, -1);
} if (this_cpu_id < 0) {
pr_warn("CPU node missing cpu ID property\n"); returnfalse;
}
} if (this_cpu_id == cpu) { if (thread) { int proc_id = cpu_data(cpu).proc_id;
/* On sparc64, the cpu thread information is obtained * either from OBP or the machine description. We've * actually probed this information already long before * this interface gets called so instead of interrogating * both the OF node and the MDESC again, just use what * we discovered already.
*/ if (proc_id < 0)
proc_id = 0;
*thread = proc_id;
} returntrue;
} returnfalse;
}
staticvoid *fill_in_one_cpu(struct device_node *dp, int cpuid, int arg)
{ struct device_node *portid_parent = NULL; int portid = -1;
if (of_property_present(dp, "cpuid")) { int limit = 2;
portid_parent = dp; while (limit--) {
portid_parent = portid_parent->parent; if (!portid_parent) break;
portid = of_getintprop_default(portid_parent, "portid", -1); if (portid >= 0) break;
}
}
#ifndef CONFIG_SMP /* On uniprocessor we only want the values for the * real physical cpu the kernel booted onto, however * cpu_data() only has one entry at index 0.
*/ if (cpuid != real_hard_smp_processor_id()) return NULL;
cpuid = 0; #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.