From patchwork Tue Apr 5 19:33:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 688661 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p35JZCcH005992 for ; Tue, 5 Apr 2011 19:35:32 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 629F29EE9F for ; Tue, 5 Apr 2011 12:35:12 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from cloud01.chad-versace.us (184-106-247-128.static.cloud-ips.com [184.106.247.128]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E1699ECF1 for ; Tue, 5 Apr 2011 12:33:46 -0700 (PDT) Received: from localhost.localdomain (unknown [67.208.96.87]) by cloud01.chad-versace.us (Postfix) with ESMTPSA id 4CB461D411D; Tue, 5 Apr 2011 19:34:34 +0000 (UTC) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Tue, 5 Apr 2011 12:33:36 -0700 Message-Id: <1302032017-1771-3-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1302032017-1771-1-git-send-email-ben@bwidawsk.net> References: <1302032017-1771-1-git-send-email-ben@bwidawsk.net> Subject: [Intel-gfx] [intel-gpu-tools] [PATCH 2/3] intel-gpu-tools update reg_read to use ioctls X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 05 Apr 2011 19:35:53 +0000 (UTC) Redid the arg parsing as well as the register dumps to easily support switching between ioctl, and non-ioctl usage. Signed-off-by: Ben Widawsky --- tools/intel_reg_read.c | 41 +++++++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c index 0259924..d7c4962 100644 --- a/tools/intel_reg_read.c +++ b/tools/intel_reg_read.c @@ -22,7 +22,7 @@ * * Authors: * Zhenyu Wang - * + * Ben Widawsky */ #include @@ -30,32 +30,49 @@ #include #include #include +#include #include "intel_gpu_tools.h" static void dump_range(uint32_t start, uint32_t end) { int i; - for (i = start; i < end; i += 4) - printf("0x%X : 0x%X\n", i, - *(volatile uint32_t *)((volatile char*)mmio + i)); + printf("0x%X : 0x%X\n", i, INREG(i)); +} + +static void usage(const char *app_name) +{ + printf("Usage: %s -i [-f | addr]\n", app_name); + printf("\t -i : use IOCTL read/write driver interface.\n"); + printf("\t -f : read back full range of registers.\n"); + printf("\t WARNING! This could be danger to hang the machine!\n"); + exit(1); } int main(int argc, char** argv) { uint32_t reg; + int opt; + int do_range_dump = 0; - if (argc != 2) { - printf("Usage: %s [-f | addr]\n", argv[0]); - printf("\t -f : read back full range of registers.\n"); - printf("\t WARNING! This could be danger to hang the machine!\n"); - printf("\t addr : in 0xXXXX format\n"); - exit(1); + while ((opt = getopt(argc, argv, "ifh?")) != -1) { + switch (opt) { + case 'i': + use_ioctl_mmio = 1; + break; + case 'f': + do_range_dump = 1; + break; + case 'h': + case '?': + usage(argv[0]); + exit(EXIT_FAILURE); + } } intel_get_mmio(intel_get_pci_device()); - if (!strcmp(argv[1], "-f")) { + if (do_range_dump) { dump_range(0x00000, 0x00fff); /* VGA registers */ dump_range(0x02000, 0x02fff); /* instruction, memory, interrupt control registers */ dump_range(0x03000, 0x031ff); /* FENCE and PPGTT control registers */ @@ -71,7 +88,7 @@ int main(int argc, char** argv) dump_range(0x70000, 0x72fff); /* display and cursor registers */ dump_range(0x73000, 0x73fff); /* performance counters */ } else { - sscanf(argv[1], "0x%x", ®); + reg = strtol(argv[optind], NULL, 0); dump_range(reg, reg + 4); }