/* * Returns the hart ID of the given device tree node, or -ENODEV if the node * isn't an enabled and valid RISC-V hart node.
*/ int riscv_of_processor_hartid(struct device_node *node, unsignedlong *hart)
{ int cpu;
*hart = (unsignedlong)of_get_cpu_hwid(node, 0); if (*hart == ~0UL) {
pr_warn("Found CPU without hart ID\n"); return -ENODEV;
}
cpu = riscv_hartid_to_cpuid(*hart); if (cpu < 0) return cpu;
if (!cpu_possible(cpu)) return -ENODEV;
return 0;
}
int __init riscv_early_of_processor_hartid(struct device_node *node, unsignedlong *hart)
{ constchar *isa;
if (!of_device_is_compatible(node, "riscv")) {
pr_warn("Found incompatible CPU\n"); return -ENODEV;
}
*hart = (unsignedlong)of_get_cpu_hwid(node, 0); if (*hart == ~0UL) {
pr_warn("Found CPU without hart ID\n"); return -ENODEV;
}
if (!of_device_is_available(node)) return -ENODEV;
if (of_property_read_string(node, "riscv,isa-base", &isa)) goto old_interface;
if (IS_ENABLED(CONFIG_32BIT) && strncasecmp(isa, "rv32i", 5)) {
pr_warn("CPU with hartid=%lu does not support rv32i", *hart); return -ENODEV;
}
if (IS_ENABLED(CONFIG_64BIT) && strncasecmp(isa, "rv64i", 5)) {
pr_warn("CPU with hartid=%lu does not support rv64i", *hart); return -ENODEV;
}
if (!of_property_present(node, "riscv,isa-extensions")) return -ENODEV;
if (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 ||
of_property_match_string(node, "riscv,isa-extensions", "m") < 0 ||
of_property_match_string(node, "riscv,isa-extensions", "a") < 0) {
pr_warn("CPU with hartid=%lu does not support ima", *hart); return -ENODEV;
}
return 0;
old_interface: if (!riscv_isa_fallback) {
pr_warn("CPU with hartid=%lu is invalid: this kernel does not parse \"riscv,isa\"",
*hart); return -ENODEV;
}
if (of_property_read_string(node, "riscv,isa", &isa)) {
pr_warn("CPU with hartid=%lu has no \"riscv,isa-base\" or \"riscv,isa\" property\n",
*hart); return -ENODEV;
}
if (IS_ENABLED(CONFIG_32BIT) && strncasecmp(isa, "rv32ima", 7)) {
pr_warn("CPU with hartid=%lu does not support rv32ima", *hart); return -ENODEV;
}
if (IS_ENABLED(CONFIG_64BIT) && strncasecmp(isa, "rv64ima", 7)) {
pr_warn("CPU with hartid=%lu does not support rv64ima", *hart); return -ENODEV;
}
return 0;
}
/* * Find hart ID of the CPU DT node under which given DT node falls. * * To achieve this, we walk up the DT tree until we find an active * RISC-V core (HART) node and extract the cpuid from it.
*/ int riscv_of_parent_hartid(struct device_node *node, unsignedlong *hartid)
{ for (; node; node = node->parent) { if (of_device_is_compatible(node, "riscv")) {
*hartid = (unsignedlong)of_get_cpu_hwid(node, 0); if (*hartid == ~0UL) {
pr_warn("Found CPU without hart ID\n"); return -ENODEV;
} return 0;
}
}
/* * For historical raisins, the isa: line is limited to the lowest common * denominator of extensions supported across all harts. A true list of * extensions supported on this hart is printed later in the hart isa: * line.
*/
seq_puts(m, "isa\t\t: ");
print_isa(m, NULL, ALL_CPUS);
print_mmu(m);
if (acpi_disabled) {
node = of_get_cpu_node(cpu_id, NULL);
/* * Print the ISA extensions specific to this hart, which may show * additional extensions not present across all harts.
*/
seq_puts(m, "hart isa\t: ");
print_isa(m, hart_isa[cpu_id].isa, cpu_id);
seq_puts(m, "\n");
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.