diff --git a/sys/riscv/riscv/identcpu.c b/sys/riscv/riscv/identcpu.c --- a/sys/riscv/riscv/identcpu.c +++ b/sys/riscv/riscv/identcpu.c @@ -69,6 +69,7 @@ struct cpu_desc { const char *cpu_mvendor_name; const char *cpu_march_name; + u_int isa_extensions; /* Single-letter extensions. */ }; struct cpu_desc cpu_desc[MAXCPU]; @@ -210,12 +211,10 @@ * Parse the ISA string, building up the set of HWCAP bits as they are found. */ static void -parse_riscv_isa(struct cpu_desc *desc, char *isa, int len, u_long *hwcapp) +parse_riscv_isa(struct cpu_desc *desc, char *isa, int len) { - u_long hwcap; int i; - hwcap = 0; i = ISA_PREFIX_LEN; while (i < len) { switch(isa[i]) { @@ -227,11 +226,11 @@ #endif case 'i': case 'm': - hwcap |= HWCAP_ISA_BIT(isa[i]); + desc->isa_extensions |= HWCAP_ISA_BIT(isa[i]); i++; break; case 'g': - hwcap |= HWCAP_ISA_G; + desc->isa_extensions |= HWCAP_ISA_G; i++; break; case 's': @@ -275,9 +274,14 @@ i = parse_ext_version(isa, i, NULL, NULL); } +} - if (hwcapp != NULL) - *hwcapp = hwcap; +static void +update_hwcap(struct cpu_desc *desc) +{ + + /* Update the capabilities exposed to userspace via AT_HWCAP. */ + UPDATE_GLOBAL_CAP(elf_hwcap, (u_long)desc->isa_extensions); } #ifdef FDT @@ -285,7 +289,6 @@ identify_cpu_features_fdt(struct cpu_desc *desc) { char isa[1024]; - u_long hwcap; phandle_t node; ssize_t len; pcell_t reg; @@ -330,9 +333,10 @@ */ for (int i = 0; i < len; i++) isa[i] = tolower(isa[i]); - parse_riscv_isa(desc, isa, len, &hwcap); + parse_riscv_isa(desc, isa, len); - UPDATE_GLOBAL_CAP(elf_hwcap, hwcap); + /* Set up capabilities for userspace. */ + update_hwcap(desc); /* We are done. */ break; @@ -422,6 +426,9 @@ hart = PCPU_GET(hart); desc = &cpu_desc[cpu]; + KASSERT(desc->isa_extensions != 0, + ("Empty extension set for CPU %u, did parsing fail?", cpu)); + /* Print details for boot CPU or if we want verbose output */ if (cpu == 0 || bootverbose) { printf("CPU %d: Hart %d\n" @@ -436,5 +443,12 @@ printf(" marchid: %#lx, mimpid: %#lx\n", marchid, mimpid); } + printf(" ISA: %#b\n", desc->isa_extensions, + "\020" + "\01Atomic" + "\03Compressed" + "\04Double" + "\06Float" + "\15Mult/Div"); } }