prop = fdt_getprop_w((void *)dtb_pa, node, "kaslr-seed", &len); if (!prop || len != sizeof(u64)) return 0;
ret = fdt64_to_cpu(*prop);
*prop = 0; return ret;
}
/** * fdt_device_is_available - check if a device is available for use * * @fdt: pointer to the device tree blob * @node: offset of the node whose property to find * * Returns true if the status property is absent or set to "okay" or "ok", * false otherwise
*/ staticbool fdt_device_is_available(constvoid *fdt, int node)
{ constchar *status; int statlen;
status = fdt_getprop(fdt, node, "status", &statlen); if (!status) returntrue;
if (statlen > 0) { if (!strcmp(status, "okay") || !strcmp(status, "ok")) returntrue;
}
returnfalse;
}
/* Copy of fdt_nodename_eq_ */ staticint fdt_node_name_eq(constvoid *fdt, int offset, constchar *s)
{ int olen; int len = strlen(s); constchar *p = fdt_get_name(fdt, offset, &olen);
/** * isa_string_contains - check if isa string contains an extension * * @isa_str: isa string to search * @ext_name: the extension to search for * * Returns true if the extension is in the given isa string, * false otherwise
*/ staticbool isa_string_contains(constchar *isa_str, constchar *ext_name)
{
size_t i, single_end, len = strlen(ext_name); char ext_end;
/* Error must contain rv32/64 */ if (strlen(isa_str) < 4) returnfalse;
if (len == 1) {
single_end = strcspn(isa_str, "sSxXzZ"); /* Search for single chars between rv32/64 and multi-letter extensions */ for (i = 4; i < single_end; i++) { if (tolower(isa_str[i]) == ext_name[0]) returntrue;
} returnfalse;
}
/* Skip to start of multi-letter extensions */
isa_str = strpbrk(isa_str, "sSxXzZ"); while (isa_str) { if (strncasecmp(isa_str, ext_name, len) == 0) {
ext_end = isa_str[len]; /* Check if matches the whole extension. */ if (ext_end == '\0' || ext_end == '_') returntrue;
} /* Multi-letter extensions must be split from other multi-letter * extensions with an "_", the end of a multi-letter extension will * either be the null character or the "_" at the start of the next * multi-letter extension.
*/
isa_str = strchr(isa_str, '_'); if (isa_str)
isa_str++;
}
returnfalse;
}
/** * early_cpu_isa_ext_available - check if cpu node has an extension * * @fdt: pointer to the device tree blob * @node: offset of the cpu node * @ext_name: the extension to search for * * Returns true if the cpu node has the extension, * false otherwise
*/ staticbool early_cpu_isa_ext_available(constvoid *fdt, int node, constchar *ext_name)
{ constvoid *prop; int len;
/** * fdt_early_match_extension_isa - check if all cpu nodes have an extension * * @fdt: pointer to the device tree blob * @ext_name: the extension to search for * * Returns true if the all available the cpu nodes have the extension, * false otherwise
*/ bool fdt_early_match_extension_isa(constvoid *fdt, constchar *ext_name)
{ int node, parent; bool ret = false;
parent = fdt_path_offset(fdt, "/cpus"); if (parent < 0) returnfalse;
fdt_for_each_subnode(node, fdt, parent) { if (!fdt_node_name_eq(fdt, node, "cpu")) continue;
if (!fdt_device_is_available(fdt, node)) continue;
if (!early_cpu_isa_ext_available(fdt, node, ext_name)) returnfalse;
ret = true;
}
return ret;
}
/** * set_satp_mode_from_fdt - determine SATP mode based on the MMU type in fdt * * @dtb_pa: physical address of the device tree blob * * Returns the SATP mode corresponding to the MMU type of the first enabled CPU, * 0 otherwise
*/
u64 set_satp_mode_from_fdt(uintptr_t dtb_pa)
{ constvoid *fdt = (constvoid *)dtb_pa; constchar *mmu_type; int node, parent;
parent = fdt_path_offset(fdt, "/cpus"); if (parent < 0) return 0;
fdt_for_each_subnode(node, fdt, parent) { if (!fdt_node_name_eq(fdt, node, "cpu")) continue;
if (!fdt_device_is_available(fdt, node)) continue;
mmu_type = fdt_getprop(fdt, node, "mmu-type", NULL); if (!mmu_type) break;
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.