From patchwork Fri Dec 2 05:38:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 701807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tVNJJ4jynz9t9b for ; Fri, 2 Dec 2016 16:39:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZFMJJflH"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tVNJJ3gPdzDvkD for ; Fri, 2 Dec 2016 16:39:28 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZFMJJflH"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tVNJ41szDzDt3R for ; Fri, 2 Dec 2016 16:39:16 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZFMJJflH"; dkim-atps=neutral Received: by mail-pg0-x242.google.com with SMTP id p66so6829208pga.2 for ; Thu, 01 Dec 2016 21:39:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w8e+/UEcppvkhVeixIXxiluUtlMbqVraapklinBfWiY=; b=ZFMJJflHe5xBIxJjp85C2Z5LllM1BNkai1ZdnFOUqfLGAK2vJ35CcL4rD3voI3hc8T IlmXFcSfWfAKi+ZyGl9m+4168U98xM8wTIbfIodkH5KKIcQUrm4GGj0s91MlrRbc65Ae lRDwUk6CVsJUEowKn6oIuhxBR8+Pw1He+tU+a0GLGQZKElJm81DJ0doE5YuYd2A4zZE8 EMfyILbNZGE6cgbqvJ6PJjq4bxXNm5It7yG9ORcT61CSpo24bChjbzWlW2wdJSFvN+gX RBDRtdJJxvIYeVoaByqc9wJcrS2mYjYyIh4B+Qr8TJPL/yKccREC9DUbjSh/FWmm9T68 47vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w8e+/UEcppvkhVeixIXxiluUtlMbqVraapklinBfWiY=; b=cWZpLoeeoZCuJff9ADwebvNAf21l7QshbKhgFP3HJ7byNooLaHptU7VYq5mUgb3Puq BTq92YzhSD4qkBLbAHXGt274NQFYOLOt+nWbDvCKlUldEyyQBGBWT6jQU+Qxv3+D2z8P 3B7qixSHClc9d/TdtRSa46GSO3k1KlHact+c/B2I/qCqYtstFXLBwt4iTSF48/lJNS8a 8sqdtCiZTeouZ3GF1z2mRvn57oa6bPOEUTh3hm3ihCwr6ygJ0eY9jKeor9/xbEpIbNDG la5TKPaoXO7KFbiljXi6jcdzoEsH/quC9vEe/t4JpN1dZWWBj/pNvRN3YJEt6xAnaZC7 MUag== X-Gm-Message-State: AKaTC03CQhVwFFnPyCy1rifesGh6qgoKjiZ0Tf+JMMq45b99A8qATDTuRHTjLAhruOtMnQ== X-Received: by 10.99.173.68 with SMTP id y4mr75207936pgo.54.1480657154714; Thu, 01 Dec 2016 21:39:14 -0800 (PST) Received: from canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id r21sm4020332pfd.44.2016.12.01.21.39.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2016 21:39:14 -0800 (PST) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Fri, 2 Dec 2016 16:38:59 +1100 Message-Id: <1480657140-3955-2-git-send-email-oohall@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1480657140-3955-1-git-send-email-oohall@gmail.com> References: <1480657140-3955-1-git-send-email-oohall@gmail.com> Subject: [Skiboot] [PATCH 2/3] mambo_utils: add p_str [limit] X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Adds a helper function to mambo_utils.tcl that prints the NUL terminated string at , and optionally limits the output to a fixed number of characters. Signed-off-by: Oliver O'Halloran --- external/mambo/mambo_utils.tcl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/external/mambo/mambo_utils.tcl b/external/mambo/mambo_utils.tcl index e1243432cdaf..879db92528a8 100644 --- a/external/mambo/mambo_utils.tcl +++ b/external/mambo/mambo_utils.tcl @@ -161,6 +161,25 @@ proc hexdump { location count } { } } +proc get_char { addr } { + return [expr [mysim memory display "$addr" 1]] +} + +proc p_str { addr { limit 0 } } { + set addr_limit 0xfffffffffffffffff + if { $limit > 0 } { set addr_limit [expr $limit + $addr] } + set s "" + + for {} { [get_char "$addr"] != 0} { incr addr 1 } { + # memory display returns hex values with a leading 0x + set c [format %c [get_char "$addr"]] + set s [string cat "$s" "$c"] + if { $addr == $addr_limit } { break } + } + + puts "$s" +} + proc slbv {} { puts [mysim cpu 0 display slb valid] }