[PATCH umr] Allow reading register by address instead of name

Tom St Denis tstdenis82 at gmail.com
Fri Mar 10 16:10:08 UTC 2017


Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
---
 src/app/main.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/src/app/main.c b/src/app/main.c
index e8f786b39743..88b4feaf0058 100644
--- a/src/app/main.c
+++ b/src/app/main.c
@@ -257,26 +257,34 @@ int main(int argc, char **argv)
 			}
 		} else if (!strcmp(argv[i], "--read") || !strcmp(argv[i], "-r")) {
 			if (i + 1 < argc) {
+				uint32_t reg;
+
 				if (!asic)
 					asic = get_asic();
-				str = strstr(argv[i+1], ".");
-				str2 = strstr(str+1, ".");
-				if (str && str2) {
-					memset(asicname, 0, sizeof asicname);
-					memset(ipname, 0, sizeof ipname);
-					memset(regname, 0, sizeof regname);
-					str[0] = 0;
-					str2[0] = 0;
-					strcpy(asicname, argv[i+1]);
-					strcpy(ipname, str+1);
-					strcpy(regname, str2+1);
+
+				if (sscanf(argv[i+1], "%"SCNx32, &reg) == 1) {
+					reg = umr_read_reg(asic, reg * 4);
+					printf("0x%08lx\n", (unsigned long)reg);
 				} else {
-					printf("Invalid asicname.ipname.regname syntax\n");
-					return EXIT_FAILURE;
+					str = strstr(argv[i+1], ".");
+					str2 = strstr(str+1, ".");
+					if (str && str2) {
+						memset(asicname, 0, sizeof asicname);
+						memset(ipname, 0, sizeof ipname);
+						memset(regname, 0, sizeof regname);
+						str[0] = 0;
+						str2[0] = 0;
+						strcpy(asicname, argv[i+1]);
+						strcpy(ipname, str+1);
+						strcpy(regname, str2+1);
+					} else {
+						printf("Invalid asicname.ipname.regname syntax\n");
+						return EXIT_FAILURE;
+					}
+					umr_scan_asic(asic, asicname, ipname, regname);
+					options.need_scan = 0;
 				}
-				umr_scan_asic(asic, asicname, ipname, regname);
 				++i;
-				options.need_scan = 0;
 			} else {
 				printf("--read requires one parameter\n");
 				return EXIT_FAILURE;
-- 
2.12.0



More information about the amd-gfx mailing list