soc_info: Add user argument to provide host id
authorLokesh Vutla <lokeshvutla@ti.com>
Wed, 11 Sep 2019 08:17:46 +0000 (13:47 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Wed, 11 Sep 2019 08:46:53 +0000 (14:16 +0530)
User might want to spoof a host_id than using the default
host id. So provide a command line argument to pass host id.
Be careful while using this argument, firewalls are enabled.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
common/help.c
common/k3conf.c
common/socinfo.c
include/socinfo.h

index 078f5a2ab1eb23aa303e88fab2a1b28779b762b3..92ec38076799fe4b7ee4b57b1a21bca0557dd961 100644 (file)
@@ -49,7 +49,7 @@ void help(help_category cat)
                printf("\tk3conf - TI K3 Configuration Diagnostic Tool\n");
 
                printf("\nSYNOPSIS\n");
-               printf("\tk3conf [--version] [--help] [--cpuinfo] <command> [<args>]\n");
+               printf("\tk3conf [--host <id>] [--version] [--help] [--cpuinfo] <command> [<args>]\n");
                if (cat == HELP_USAGE)
                        printf("\n\tSee 'k3conf --help' for more information.\n\n");
        }
@@ -68,6 +68,9 @@ void help(help_category cat)
                        " to any other area.\n");
 
                printf("\nOPTIONS\n");
+               printf("\t--host <id>\n");
+               printf("\t    Use this host id for communicating with sysfw\n\n");
+
                printf("\t--help\n");
                printf("\t    Print k3conf help.\n");
 
index 0e068c14cfc9993e1d4d9c095ec320509e1515d2..d95a950c2a19e22a1ac6fc2ac111753564748499 100644 (file)
 #include <autoadjust_table.h>
 #include <k3conf.h>
 
+#ifdef DEBUG
+#define dprintf(format, ...)    printf(format, ## __VA_ARGS__)
+#else
+#define dprintf(format, ...)
+#endif
+
 void k3conf_print_version(FILE *stream)
 {
        char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
@@ -84,6 +90,7 @@ void k3conf_print_version(FILE *stream)
 
 int main(int argc, char *argv[])
 {
+       uint32_t host_id;
        int ret = 0;
 
        /* Scan user arguments for options */
@@ -96,7 +103,20 @@ int main(int argc, char *argv[])
                goto main_exit;
        }
 
-       if (soc_init())
+       host_id = DEFAULT_HOST_ID;
+       if (!strcmp(argv[0], "--host")) {
+               argc--; argv++;
+               ret = sscanf(argv[0], "%u", &host_id);
+               if (ret != 1) {
+                       fprintf(stderr, "Invalid host id %s\n", argv[0]);
+                       return -1;
+               }
+               dprintf("%s: host_id from user = %d\n", __func__,
+                       soc_info.host_id);
+               argc--; argv++;
+       }
+
+       if (soc_init(host_id))
                goto main_exit;
 
        if (!strcmp(argv[0], "--help")) {
index d2b60d8fccb8735bcc14305383424e4eac00eae1..0d96a6b813a627ce0a6aaf234809787a6e374195 100644 (file)
@@ -122,7 +122,7 @@ static void j721e_init(void)
        sci_info->num_clocks = J721E_MAX_CLOCKS;
 }
 
-int soc_init(void)
+int soc_init(uint32_t host_id)
 {
        memset(&soc_info, 0, sizeof(soc_info));
 
@@ -146,7 +146,7 @@ int soc_init(void)
        strcat(soc_info.soc_full_name, " PG");
        strcat(soc_info.soc_full_name, soc_revision[soc_info.rev]);
 
-       soc_info.host_id = DEFAULT_HOST_ID;
+       soc_info.host_id = host_id;
 
        if (soc_info.soc == AM654)
                am654_init();
index 719e8f55fae38c52ce2d642baa251ba3585294c5..be0293298d36b9af4e990b026f46deef66624004 100644 (file)
@@ -65,7 +65,7 @@ struct k3conf_soc_info {
 };
 
 extern struct k3conf_soc_info soc_info;
-int soc_init(void);
+int soc_init(uint32_t host_id);
 int soc_is_j721e(void);
 int soc_is_am654(void);