riscv_fill_hwcap
これ以上は, #TODO で深追いしないが、どうもdevice treeの"riscv,isa" entryから読んでいるらしい code:arch/riscv/kernel/cpufeature.c
void riscv_fill_hwcap(void)
{
struct device_node *node;
const char *isa;
size_t i, j, isa_len;
static unsigned long isa2hwcap256 = {0}; isa2hwcap'i' = isa2hwcap'I' = COMPAT_HWCAP_ISA_I; isa2hwcap'm' = isa2hwcap'M' = COMPAT_HWCAP_ISA_M; isa2hwcap'a' = isa2hwcap'A' = COMPAT_HWCAP_ISA_A; isa2hwcap'f' = isa2hwcap'F' = COMPAT_HWCAP_ISA_F; isa2hwcap'd' = isa2hwcap'D' = COMPAT_HWCAP_ISA_D; isa2hwcap'c' = isa2hwcap'C' = COMPAT_HWCAP_ISA_C; elf_hwcap = 0;
bitmap_zero(riscv_isa, RISCV_ISA_EXT_MAX);
for_each_of_cpu_node(node) {
unsigned long this_hwcap = 0;
unsigned long this_isa = 0;
if (riscv_of_processor_hartid(node) < 0)
continue;
if (of_property_read_string(node, "riscv,isa", &isa)) {
pr_warn("Unable to find \"riscv,isa\" devicetree entry\n");
continue;
}
i = 0;
isa_len = strlen(isa);
#if defined(CONFIG_32BIT) if (!strncmp(isa, "rv32", 4))
i += 4;
#elif defined(CONFIG_64BIT) if (!strncmp(isa, "rv64", 4))
i += 4;
for (; i < isa_len; ++i) {
this_hwcap |= isa2hwcap[(unsigned char)(isai)]; if ('a' <= isai && isai <= 'z') this_isa |= (1UL << (isai - 'a')); }
/*
* All "okay" hart should have same isa. Set HWCAP based on
* common capabilities of every "okay" hart, in case they don't
* have.
*/
if (elf_hwcap)
elf_hwcap &= this_hwcap;
else
elf_hwcap = this_hwcap;
else
}
/* We don't support systems with F but without D, so mask those out
* here. */
if ((elf_hwcap & COMPAT_HWCAP_ISA_F) && !(elf_hwcap & COMPAT_HWCAP_ISA_D)) {
pr_info("This kernel does not support systems with F but not D\n");
elf_hwcap &= ~COMPAT_HWCAP_ISA_F;
}
memset(print_str, 0, sizeof(print_str));
for (i = 0, j = 0; i < BITS_PER_LONG; i++)
if (riscv_isa0 & BIT_MASK(i)) print_strj++ = (char)('a' + i); pr_info("riscv: ISA extensions %s\n", print_str);
memset(print_str, 0, sizeof(print_str));
for (i = 0, j = 0; i < BITS_PER_LONG; i++)
if (elf_hwcap & BIT_MASK(i))
print_strj++ = (char)('a' + i); pr_info("riscv: ELF capabilities %s\n", print_str);
if (elf_hwcap & (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D))
has_fpu = true;
}