summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4b3c8c2)
raw | patch | inline | side by side (parent: 4b3c8c2)
author | Lokesh Vutla <lokeshvutla@ti.com> | |
Thu, 22 Aug 2019 14:09:55 +0000 (19:39 +0530) | ||
committer | Lokesh Vutla <lokeshvutla@ti.com> | |
Sun, 25 Aug 2019 03:14:04 +0000 (08:44 +0530) |
Add support for show command that supports following args:
- k3conf show hosts: Prints all the available TISCI hosts
- k3conf show threads: Prints all the available TISCI secure proxy threads
- k3conf show device: Prints all the available TISCI devices
- k3conf show device <dev_id>: Prints the corresponding device id information
- k3conf show clock: Prints all the available TISCI clocks
- k3conf show clock <dev_id>: Prints the clocks for corresponding device id
- k3conf show processor: Prints all the available TISCI processors
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
- k3conf show hosts: Prints all the available TISCI hosts
- k3conf show threads: Prints all the available TISCI secure proxy threads
- k3conf show device: Prints all the available TISCI devices
- k3conf show device <dev_id>: Prints the corresponding device id information
- k3conf show clock: Prints all the available TISCI clocks
- k3conf show clock <dev_id>: Prints the clocks for corresponding device id
- k3conf show processor: Prints all the available TISCI processors
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Makefile | patch | blob | history | |
common/cmd_show.c | [new file with mode: 0644] | patch | blob |
common/help.c | patch | blob | history | |
common/k3conf.c | patch | blob | history | |
include/help.h | patch | blob | history | |
include/k3conf.h | [new file with mode: 0644] | patch | blob |
diff --git a/Makefile b/Makefile
index 34672c545859a3ea597492ffb7a5fb87778ad3fc..a5cd1bdaf1b4b0b1665f13de9e4196e57bd81d61 100644 (file)
--- a/Makefile
+++ b/Makefile
common/tisci/tisci_core.c \
common/tisci/tisci_device.c \
common/tisci/tisci_clock.c \
- common/autoadjust_table.c
+ common/autoadjust_table.c \
+ common/cmd_show.c
AM65XSOURCES =\
soc/am65x/am65x_host_info.c \
diff --git a/common/cmd_show.c b/common/cmd_show.c
--- /dev/null
+++ b/common/cmd_show.c
@@ -0,0 +1,292 @@
+/*
+ * K3CONF Command Show
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Lokesh Vutla <lokeshvutla@ti.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <sec_proxy.h>
+#include <tisci.h>
+#include <socinfo.h>
+#include <help.h>
+#include <autoadjust_table.h>
+#include <k3conf.h>
+
+static int show_hosts_info(void)
+{
+ struct ti_sci_host_info *hosts = soc_info.sci_info.host_info;
+ char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ uint32_t row = 0;
+
+ autoadjust_table_init(table);
+ strncpy(table[row][0], "Host ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Host Name", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][2], "Security Status", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][3], "Description", TABLE_MAX_ELT_LEN);
+
+ for (row = 0; row < soc_info.sci_info.num_hosts; row++) {
+ snprintf(table[row + 1][0], TABLE_MAX_ELT_LEN, "%d",
+ hosts[row].host_id);
+ strncpy(table[row + 1][1], hosts[row].host_name,
+ TABLE_MAX_ELT_LEN);
+ strncpy(table[row + 1][2], hosts[row].security_status,
+ TABLE_MAX_ELT_LEN);
+ strncpy(table[row + 1][3], hosts[row].description,
+ TABLE_MAX_ELT_LEN);
+ }
+
+ return autoadjust_table_print(table, row + 1, 4);
+}
+
+static int show_sp_threads_info(void)
+{
+ char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ struct ti_sci_sec_proxy_info *sp;
+ uint32_t row = 0, i;
+
+ autoadjust_table_init(table);
+ strncpy(table[row][0],
+ "Secure Proxy thread allocation for main_sec_proxy0",
+ TABLE_MAX_ELT_LEN);
+ row++;
+ strncpy(table[row][0], "Thread ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Direction", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][2], "No. of msgs", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][3], "Host", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][4], "Host Function", TABLE_MAX_ELT_LEN);
+ row++;
+
+ sp = soc_info.sci_info.sp_info[MAIN_SEC_PROXY];
+ for (i = 0; i < soc_info.sci_info.num_sp_threads[MAIN_SEC_PROXY];
+ row++, i++) {
+ snprintf(table[row][0], TABLE_MAX_ELT_LEN, "%5d", sp[i].sp_id);
+ strncpy(table[row][1], sp[i].sp_dir, TABLE_MAX_ELT_LEN);
+ snprintf(table[row][2], TABLE_MAX_ELT_LEN, "%7d", sp[i].num_msgs);
+ strncpy(table[row][3], sp[i].host, TABLE_MAX_ELT_LEN);
+ strncpy(table[row][4], sp[i].host_function, TABLE_MAX_ELT_LEN);
+ }
+
+ autoadjust_table_generic_fprint(stdout, table, row, 5,
+ TABLE_HAS_SUBTITLE | TABLE_HAS_TITLE);
+ row = 0;
+ autoadjust_table_init(table);
+ strncpy(table[row][0],
+ "Secure Proxy thread allocation for mcu_sec_proxy0",
+ TABLE_MAX_ELT_LEN);
+ row++;
+ strncpy(table[row][0], "Thread ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Direction", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][2], "No. of msgs", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][3], "Host", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][4], "Host Function", TABLE_MAX_ELT_LEN);
+ row++;
+
+ sp = soc_info.sci_info.sp_info[MCU_SEC_PROXY];
+ for (i = 0; i < soc_info.sci_info.num_sp_threads[MCU_SEC_PROXY];
+ row++, i++) {
+ snprintf(table[row][0], TABLE_MAX_ELT_LEN, "%5d", sp[i].sp_id);
+ strncpy(table[row][1], sp[i].sp_dir, TABLE_MAX_ELT_LEN);
+ snprintf(table[row][2], TABLE_MAX_ELT_LEN, "%7d", sp[i].num_msgs);
+ strncpy(table[row][3], sp[i].host, TABLE_MAX_ELT_LEN);
+ strncpy(table[row][4], sp[i].host_function, TABLE_MAX_ELT_LEN);
+ }
+
+ return autoadjust_table_generic_fprint(stdout, table, row, 5,
+ TABLE_HAS_SUBTITLE | TABLE_HAS_TITLE);
+}
+
+static int show_clocks_info(int argc, char *argv[])
+{
+ struct ti_sci_clocks_info *c = soc_info.sci_info.clocks_info;
+ char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ uint32_t row = 0, dev_id;
+ int found = 0, ret;
+
+ autoadjust_table_init(table);
+ strncpy(table[row][0], "Device ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Clock ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][2], "Clock Name", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][3], "Clock Function", TABLE_MAX_ELT_LEN);
+
+ if (argc)
+ goto print_single_device;
+
+ for (row = 0; row < soc_info.sci_info.num_clocks; row++) {
+ snprintf(table[row + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ c[row].dev_id);
+ snprintf(table[row + 1][1], TABLE_MAX_ELT_LEN, "%5d",
+ c[row].clk_id);
+ strncpy(table[row + 1][2], c[row].clk_name, TABLE_MAX_ELT_LEN);
+ strncpy(table[row + 1][3], c[row].clk_function, TABLE_MAX_ELT_LEN);
+ }
+
+ return autoadjust_table_print(table, row + 1, 4);
+
+print_single_device:
+ ret = sscanf(argv[0], "%u", &dev_id);
+ if (ret != 1)
+ return -1;
+
+ for (row = 0; row < soc_info.sci_info.num_clocks; row++) {
+ if (dev_id == c[row].dev_id) {
+ snprintf(table[found + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ c[row].dev_id);
+ snprintf(table[found + 1][1], TABLE_MAX_ELT_LEN, "%5d",
+ c[row].clk_id);
+ strncpy(table[found + 1][2], c[row].clk_name,
+ TABLE_MAX_ELT_LEN);
+ strncpy(table[found + 1][3], c[row].clk_function, TABLE_MAX_ELT_LEN);
+ found++;
+ }
+ }
+
+ if (!found)
+ return -1;
+
+ return autoadjust_table_print(table, found + 1, 4);
+}
+
+static int show_devices_info(int argc, char *argv[])
+{
+ struct ti_sci_devices_info *p = soc_info.sci_info.devices_info;
+ char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ uint32_t row = 0, dev_id;
+ int found = 0, ret;
+
+ autoadjust_table_init(table);
+ strncpy(table[row][0], "Device ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Device Name", TABLE_MAX_ELT_LEN);
+
+ if (argc)
+ goto print_single_device;
+
+ for (row = 0; row < soc_info.sci_info.num_devices; row++) {
+ snprintf(table[row + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ p[row].dev_id);
+ strncpy(table[row + 1][1], p[row].name, TABLE_MAX_ELT_LEN);
+ }
+
+ return autoadjust_table_print(table, row + 1, 2);
+
+print_single_device:
+ ret = sscanf(argv[0], "%u", &dev_id);
+ if (ret != 1)
+ return -1;
+
+ for (row = 0; row < soc_info.sci_info.num_devices; row++) {
+ if (dev_id == p[row].dev_id) {
+ snprintf(table[1][0], TABLE_MAX_ELT_LEN, "%5d",
+ p[row].dev_id);
+ strncpy(table[1][1], p[row].name,
+ TABLE_MAX_ELT_LEN);
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ return -1;
+
+ return autoadjust_table_print(table, 2, 2);
+}
+
+static int show_processors_info(void)
+{
+ struct ti_sci_processors_info *p = soc_info.sci_info.processors_info;
+ char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ uint32_t row = 0;
+
+ autoadjust_table_init(table);
+ strncpy(table[row][0], "Device ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][1], "Processor ID", TABLE_MAX_ELT_LEN);
+ strncpy(table[row][2], "Processor Name", TABLE_MAX_ELT_LEN);
+
+ for (row = 0; row < soc_info.sci_info.num_processors; row++) {
+ snprintf(table[row + 1][0], TABLE_MAX_ELT_LEN, "%5d",
+ p[row].dev_id);
+ snprintf(table[row + 1][1], TABLE_MAX_ELT_LEN, "%7d",
+ p[row].processor_id);
+ strncpy(table[row + 1][2], p[row].name, TABLE_MAX_ELT_LEN);
+ }
+
+ return autoadjust_table_print(table, row + 1, 3);
+}
+
+int process_show_command(int argc, char *argv[])
+{
+ int ret;
+
+ if (argc < 1) {
+ help(HELP_SHOW);
+ return -1;
+ }
+
+ if (!strncmp(argv[0], "host", 4)) {
+ ret = show_hosts_info();
+ if (ret)
+ help(HELP_SHOW_HOST);
+ } else if (!strncmp(argv[0], "thread", 6)) {
+ ret = show_sp_threads_info();
+ if (ret)
+ help(HELP_SHOW_SEC_PROXY);
+ } else if (!strncmp(argv[0], "device", 6)) {
+ argc--;
+ argv++;
+ ret = show_devices_info(argc, argv);
+ if (ret) {
+ fprintf(stderr, "Invalid device arguments\n");
+ help(HELP_SHOW_DEVICE);
+ }
+ } else if (!strncmp(argv[0], "clock", 5)) {
+ argc--;
+ argv++;
+ ret = show_clocks_info(argc, argv);
+ if (ret) {
+ fprintf(stderr, "Invalid clock arguments\n");
+ help(HELP_SHOW_CLOCK);
+ }
+ } else if(!strncmp(argv[0], "processor", 9)) {
+ ret = show_processors_info();
+ if (ret)
+ help(HELP_SHOW_PROCESSOR);
+ } else if (!strcmp(argv[0], "--help")) {
+ help(HELP_SHOW);
+ return 0;
+ } else {
+ fprintf(stderr, "Invalid argument %s\n", argv[1]);
+ help(HELP_SHOW);
+ return -1;
+ }
+ return ret;
+}
diff --git a/common/help.c b/common/help.c
index a8e78a2eef99597b32f165aa67ad4adf8e8aa229..8132015dc307d45cd9dafe759117259160b066f7 100644 (file)
--- a/common/help.c
+++ b/common/help.c
printf("\n\t--version\n");
printf("\t Print k3conf version.\n");
}
+
+ if (cat != HELP_USAGE)
+ printf("\nCOMMANDS\n");
+
+ if ((cat == HELP_ALL) || (cat == HELP_SHOW) ||
+ (cat == HELP_SHOW_HOST)) {
+ printf("\n\tk3conf show hosts\n");
+ printf("\t Prints all the available TISCI hosts\n");
+ }
+ if ((cat == HELP_ALL) || (cat == HELP_SHOW) ||
+ (cat == HELP_SHOW_SEC_PROXY)) {
+ printf("\n\tk3conf show threads\n");
+ printf("\t Prints all the available TISCI secure proxy threads\n");
+ }
+ if ((cat == HELP_ALL) || (cat == HELP_SHOW) ||
+ (cat == HELP_SHOW_DEVICE)) {
+ printf("\n\tk3conf show device\n");
+ printf("\t Prints all the available TISCI devices\n");
+ printf("\n\tk3conf show device <dev_id>\n");
+ printf("\t Prints the corresponding device id information\n");
+ }
+ if ((cat == HELP_ALL) || (cat == HELP_SHOW) ||
+ (cat == HELP_SHOW_CLOCK)) {
+ printf("\n\tk3conf show clock\n");
+ printf("\t Prints all the available TISCI clocks\n");
+ printf("\n\tk3conf show clock <dev_id>\n");
+ printf("\t Prints the clocks for corresponding device id\n");
+ }
+ if ((cat == HELP_ALL) || (cat == HELP_SHOW) ||
+ (cat == HELP_SHOW_PROCESSOR)) {
+ printf("\n\tk3conf show processor\n");
+ printf("\t Prints all the available TISCI processors\n");
+ }
}
diff --git a/common/k3conf.c b/common/k3conf.c
index 19b19084cb2c62c2e6eb96f33a4899599e0574f4..f6fcfc6083634ac1f57ff839c61e90898a942c55 100644 (file)
--- a/common/k3conf.c
+++ b/common/k3conf.c
#include <help.h>
#include <string.h>
#include <autoadjust_table.h>
+#include <k3conf.h>
void k3conf_print_version(FILE *stream)
{
} else if (!strcmp(argv[0], "--version")) {
k3conf_print_version(stdout);
goto main_exit;
+ } else if (!strcmp(argv[0], "show")) {
+ argc--;
+ argv++;
+ k3conf_print_version(stdout);
+ return process_show_command(argc, argv);
} else {
fprintf(stderr, "Invalid argument %s", argv[0]);
help(HELP_USAGE);
diff --git a/include/help.h b/include/help.h
index abaf2592ff6f7dad8ea599f191b869d28ee799d8..c46444f310b49dd429e4366a9049914954844104 100644 (file)
--- a/include/help.h
+++ b/include/help.h
typedef enum {
HELP_USAGE,
+ HELP_SHOW,
+ HELP_SHOW_HOST,
+ HELP_SHOW_SEC_PROXY,
+ HELP_SHOW_DEVICE,
+ HELP_SHOW_CLOCK,
+ HELP_SHOW_PROCESSOR,
HELP_ALL,
HELP_CATEGORY_MAX,
} help_category;
diff --git a/include/k3conf.h b/include/k3conf.h
--- /dev/null
+++ b/include/k3conf.h
@@ -0,0 +1,48 @@
+/*
+ * K3CONF Main Header file.
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Lokesh Vutla <lokeshvutla@ti.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <socinfo.h>
+#include <string.h>
+
+#ifndef __K3CONF_H
+#define __K3CONF_H
+
+int process_show_command(int argc, char *argv[]);
+
+#endif