From patchwork Mon May 14 10:03:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 912816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40kx9c5fs8z9s02 for ; Mon, 14 May 2018 20:03:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40kx9c4S66zF2M9 for ; Mon, 14 May 2018 20:03:48 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=ozlabs.ru (client-ip=107.173.13.209; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from ozlabs.ru (unknown [107.173.13.209]) by lists.ozlabs.org (Postfix) with ESMTP id 40kx9R0YWkzF1KG for ; Mon, 14 May 2018 20:03:37 +1000 (AEST) Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 72AEDAE801DC; Mon, 14 May 2018 06:02:36 -0400 (EDT) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Mon, 14 May 2018 20:03:31 +1000 Message-Id: <20180514100332.32990-2-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514100332.32990-1-aik@ozlabs.ru> References: <20180514100332.32990-1-aik@ozlabs.ru> Subject: [SLOF] [PATCH slof 1/2] fdt: Factor out code to replace a phandle in place X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" We generate a fake XICS phandle in QEMU and SLOF replaces that phandle with the real one (i.e. SLOF's node address) in interrupt-parent and interrupt-map properties. These properties are handled differently - the interrupt-map is fixed in place while interrupt-parent is decoded+encoded+set as a property. This changes interrupt-parent fixing code to do what the interrupt-map code does because soon we are going to have more phandles to fix and some contain an array of phandles (such as "ibm,npu"). Signed-off-by: Alexey Kardashevskiy --- board-qemu/slof/fdt.fs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs index 8e8921f..5284ae6 100644 --- a/board-qemu/slof/fdt.fs +++ b/board-qemu/slof/fdt.fs @@ -279,6 +279,23 @@ fdt-claim-reserve 2drop ; +: fdt-replace-l, 4 - swap 4 + swap ; + +: (fdt-replace-phandles) ( old new propname propnamelen node ) + get-property IF 2drop EXIT THEN + BEGIN + dup + WHILE ( old new prop-addr prop-len ) + over l@ + 4 pick = IF + 2 pick 2 pick l! \ replace old with new in place + TRUE TO (fdt-phandle-replaced) + THEN + fdt-replace-l, + REPEAT + 2drop 2drop +; + \ Replace one phandle "old" with a phandle "new" in "node" and recursively \ in its child nodes: : fdt-replace-all-phandles ( old new node -- ) @@ -288,14 +305,8 @@ fdt-claim-reserve ( old new prop-addr prop-len R: node ) fdt-replace-interrupt-map THEN - s" interrupt-parent" r@ get-property 0= IF - ( old new prop-addr prop-len R: node ) - decode-int -rot 2drop ( old new val R: node ) - 2 pick = IF ( old new R: node ) - dup encode-int s" interrupt-parent" r@ set-property - TRUE TO (fdt-phandle-replaced) - THEN - THEN + + 2dup s" interrupt-parent" r@ (fdt-replace-phandles) \ ... add more properties that have to be fixed here ... r> \ Now recurse over all child nodes: ( old new node )