-*)
OPTS_ALL="--all
--annotate
+ --arm-id
+ --arm-model
--online
--bytes
--caches
* - SMBIOS tables (if applicable)
*/
#include "lscpu.h"
+#include <libsmartcols.h>
struct id_part {
const int id;
for (i = 0; i < cxt->ncputypes; i++)
arm_decode(cxt, cxt->cputypes[i]);
}
+
+static struct libscols_table *arm_mktable(struct lscpu_cxt *cxt, const char *tabname)
+{
+ struct libscols_table *tb;
+
+ scols_init_debug(0);
+
+ tb = scols_new_table();
+ if (!tb)
+ err(EXIT_FAILURE, _("failed to allocate output table"));
+ if (cxt->json) {
+ scols_table_enable_json(tb, 1);
+ scols_table_set_name(tb, tabname);
+ }
+ if (cxt->raw)
+ scols_table_enable_raw(tb, 1);
+
+ scols_table_new_column(tb, _("id"), 0, 0);
+ scols_table_new_column(tb, _("name"), 0, 0);
+
+ return tb;
+}
+
+/*
+ * [--arm-id] backend
+ */
+void lscpu_print_arm_implementers(struct lscpu_cxt *cxt)
+{
+ size_t i;
+ struct libscols_table *tb;
+
+ tb = arm_mktable(cxt, "arm-implementers");
+
+ for (i = 0; hw_implementer[i].id != -1; i++) {
+ struct libscols_line *ln;
+ ln = scols_table_new_line(tb, NULL);
+ if (!ln)
+ err(EXIT_FAILURE, _("failed to allocate output line"));
+ scols_line_sprintf(ln, 0, "0x%02x", hw_implementer[i].id);
+ scols_line_set_data(ln, 1, hw_implementer[i].name);
+ }
+
+ scols_print_table(tb);
+ scols_unref_table(tb);
+}
+
+/*
+ * [--arm-id=<impl>] backend
+ */
+void lscpu_print_arm_models(struct lscpu_cxt *cxt, int implementer)
+{
+ size_t i;
+ struct libscols_table *tb;
+ const struct id_part *parts = NULL;
+
+ for (i = 0; hw_implementer[i].id != -1; i++) {
+ if (hw_implementer[i].id == implementer) {
+ parts = hw_implementer[i].parts;
+ break;
+ }
+ }
+ if (!parts)
+ errx(EXIT_FAILURE, _("implementer not found"));
+
+ tb = arm_mktable(cxt, "arm-models");
+
+ for (i = 0; parts[i].id != -1; i++) {
+ struct libscols_line *ln;
+ ln = scols_table_new_line(tb, NULL);
+ if (!ln)
+ err(EXIT_FAILURE, _("failed to allocate output line"));
+ scols_line_sprintf(ln, 0, "0x%03x", parts[i].id);
+ scols_line_set_data(ln, 1, parts[i].name);
+ }
+
+ scols_print_table(tb);
+ scols_unref_table(tb);
+}
+
+/*
+ * [--arm-id=<impl> --arm-model=<model>] backend
+ */
+void lscpu_print_arm_model(struct lscpu_cxt *cxt __attribute__((__unused__)), int implementer, int model)
+{
+ size_t i;
+ const struct id_part *parts = NULL;
+
+ for (i = 0; hw_implementer[i].id != -1; i++) {
+ if (hw_implementer[i].id == implementer) {
+ parts = hw_implementer[i].parts;
+ break;
+ }
+ }
+ if (!parts)
+ errx(EXIT_FAILURE, _("implementer not found"));
+
+ for (i = 0; parts[i].id != -1; i++) {
+ if (parts[i].id == model) {
+ printf("%s\n", parts[i].name);
+ return;
+ }
+ }
+ errx(EXIT_FAILURE, _("model not found"));
+}
+
The CPU logical numbers are not affected by this option.
+*--arm-id*[**=**_list_]::
+Print a list of the known ARM core implementers and their human readable names.
++
+If an argument is given, print a list of the individual core IDs and their
+names, for the given implementer.
+
+*--arm-model* _id_::
+Print the name for this specific core model. This requires passing
+*--arm-id=_id_* to indicate the implementer id as well.
+
include::man-common/annotate.adoc[]
== ENVIRONMENT
fputs(_(" -y, --physical print physical instead of logical IDs\n"), out);
fputs(_(" --hierarchic[=when] use subsections in summary (auto, never, always)\n"), out);
fputs(_(" --output-all print all available columns for -e, -p or -C\n"), out);
+ fputs(_(" --arm-id[=<id>] print the known ARM implementers and their names. If an id is given, print all the cores for that implementer.\n"), out);
+ fputs(_(" --arm-model <id> print the name of the given ARM implementer and model. Requires --arm-id=<id>.\n"), out);
fputs(USAGE_SEPARATOR, out);
fprintf(out, USAGE_LIST_COLUMNS_OPTION(25));
fprintf(out, USAGE_HELP_OPTIONS(25));
char *outarg = NULL;
size_t i, ncolumns = 0;
char *annotate_opt_arg = NULL;
+ unsigned int arm_id = 0xf00; /* Valid values are 0-0xff */
+ unsigned int arm_model = 0xf000; /* Valid values are 0-0xfff */
enum {
OPT_OUTPUT_ALL = CHAR_MAX + 1,
OPT_HIERARCHIC,
OPT_ANNOTATE,
+ OPT_ARM_ID,
+ OPT_ARM_MODEL,
};
static const struct option longopts[] = {
{ "all", no_argument, NULL, 'a' },
{ "output-all", no_argument, NULL, OPT_OUTPUT_ALL },
{ "hierarchic", optional_argument, NULL, OPT_HIERARCHIC },
{ "list-columns", no_argument, NULL, 'H' },
+ { "arm-id", optional_argument, NULL, OPT_ARM_ID },
+ { "arm-model", required_argument, NULL, OPT_ARM_MODEL },
{ NULL, 0, NULL, 0 }
};
} else
hierarchic = 1;
break;
+ case OPT_ARM_ID:
+ if (optarg) {
+ if (cxt->mode != LSCPU_OUTPUT_ARM_SINGLE_MODEL)
+ cxt->mode = LSCPU_OUTPUT_ARM_MODELS;
+ arm_id = str2unum_or_err(optarg, 0, _("failed to parse implementer id"), 0xFF);
+ } else
+ cxt->mode = LSCPU_OUTPUT_ARM_IMPLEMENTERS;
+ break;
+ case OPT_ARM_MODEL:
+ cxt->mode = LSCPU_OUTPUT_ARM_SINGLE_MODEL;
+ arm_model = str2unum_or_err(optarg, 0, _("failed to parse model id"), 0xFFF);
+ break;
case 'H':
collist = 1;
break;
return EXIT_FAILURE;
}
+ if (cxt->mode == LSCPU_OUTPUT_ARM_SINGLE_MODEL && arm_id > 0xff)
+ errx(EXIT_FAILURE, _("--arm-model option needs to be used with --arm-id"));
+
if (argc != optind) {
warnx(_("bad usage"));
errtryhelp(EXIT_FAILURE);
print_cpus_parsable(cxt, columns, ncolumns);
break;
+ case LSCPU_OUTPUT_ARM_IMPLEMENTERS:
+ lscpu_print_arm_implementers(cxt);
+ break;
+ case LSCPU_OUTPUT_ARM_MODELS:
+ lscpu_print_arm_models(cxt, arm_id);
+ break;
+ case LSCPU_OUTPUT_ARM_SINGLE_MODEL:
+ lscpu_print_arm_model(cxt, arm_id, arm_model);
+ break;
}
lscpu_free_context(cxt);
LSCPU_OUTPUT_SUMMARY = 0, /* default */
LSCPU_OUTPUT_CACHES,
LSCPU_OUTPUT_PARSABLE,
- LSCPU_OUTPUT_READABLE
+ LSCPU_OUTPUT_READABLE,
+ LSCPU_OUTPUT_ARM_IMPLEMENTERS,
+ LSCPU_OUTPUT_ARM_MODELS,
+ LSCPU_OUTPUT_ARM_SINGLE_MODEL,
};
struct lscpu_cxt {
void lscpu_decode_arm(struct lscpu_cxt *cxt);
void lscpu_format_isa_riscv(struct lscpu_cputype *ct);
+void lscpu_print_arm_implementers(struct lscpu_cxt *cxt);
+void lscpu_print_arm_models(struct lscpu_cxt *cxt, int implementer);
+void lscpu_print_arm_model(struct lscpu_cxt *cxt, int implementer, int model);
int lookup(char *line, char *pattern, char **value);