From patchwork Tue Oct 24 01:31:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 829751 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 3yLbNY5d1bz9sNx for ; Tue, 24 Oct 2017 12:32:13 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yLbNY3bkwzDqlH for ; Tue, 24 Oct 2017 12:32:13 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=ozlabs.ru (client-ip=107.173.13.209; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.173.13.209]) by lists.ozlabs.org (Postfix) with ESMTP id 3yLbNP5l3tzDqZ3 for ; Tue, 24 Oct 2017 12:32:05 +1100 (AEDT) Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 66E923A60050; Mon, 23 Oct 2017 21:30:56 -0400 (EDT) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Tue, 24 Oct 2017 12:31:51 +1100 Message-Id: <20171024013153.28200-5-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171024013153.28200-1-aik@ozlabs.ru> References: <20171024013153.28200-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof v6 4/6] board-qemu: Fix slof-build-id length X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" The existing code hardcodes the length of /openprom/model to 10 characters even though it is less than that - len("aik")==3. All 10 chars go to the device tree blob and DTC complains on such a property as there are characters after terminating null: aik@fstn1-p1:~$ dtc -f -I dtb -O dts -o dbg.dts dbg.dtb Warning (model_is_string): "model" property in /openprom is not a string This uses the real length and limits it by 10 to avoid breaking something. Since the same code parses the build id field, this moves from-cstring to a common place for both js2x and qemu boards. Signed-off-by: Alexey Kardashevskiy --- board-js2x/slof/helper.fs | 2 +- board-qemu/slof/helper.fs | 8 +------- slof/fs/base.fs | 5 +++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs index c522c90..d2f19e6 100644 --- a/board-js2x/slof/helper.fs +++ b/board-js2x/slof/helper.fs @@ -11,7 +11,7 @@ \ ****************************************************************************/ : slof-build-id ( -- str len ) - flash-header 10 + a + flash-header 10 + dup from-cstring a min ; : slof-revision s" 001" ; diff --git a/board-qemu/slof/helper.fs b/board-qemu/slof/helper.fs index 40d4abc..4b2c1ee 100644 --- a/board-qemu/slof/helper.fs +++ b/board-qemu/slof/helper.fs @@ -11,7 +11,7 @@ \ ****************************************************************************/ : slof-build-id ( -- str len ) - flash-header 10 + a + flash-header 10 + dup from-cstring a min ; : slof-revision s" 001" ; @@ -27,12 +27,6 @@ bdate2human $cat encode-string THEN ; -\ Fetch C string -: from-cstring ( addr - len ) - dup dup BEGIN c@ 0 <> WHILE 1 + dup REPEAT - swap - -; - : invert-region-cs ( addr len cellsize -- ) >r over swap r@ rshift r> swap 1 hv-logical-memop drop ; diff --git a/slof/fs/base.fs b/slof/fs/base.fs index 0aca5f5..e2104fb 100644 --- a/slof/fs/base.fs +++ b/slof/fs/base.fs @@ -107,6 +107,11 @@ CONSTANT <2constant> : str= ( str1 len1 str2 len2 -- equal? ) rot over <> IF 3drop false ELSE comp 0= THEN ; +: from-cstring ( addr - len ) + dup dup BEGIN c@ 0 <> WHILE 1 + dup REPEAT + swap - +; + : test-string ( param len -- true | false ) 0 ?DO dup i + c@ \ Get character / byte at current index