From patchwork Tue Oct 24 01:31:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 829754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yLbNy0Q5xz9s83 for ; Tue, 24 Oct 2017 12:32:34 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yLbNx6GY7zDqkj for ; Tue, 24 Oct 2017 12:32:33 +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 3yLbNv1JCczDqZ3 for ; Tue, 24 Oct 2017 12:32:31 +1100 (AEDT) Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 7E38A3A60021; Mon, 23 Oct 2017 21:30:50 -0400 (EDT) From: Alexey Kardashevskiy To: slof@lists.ozlabs.org Date: Tue, 24 Oct 2017 12:31:48 +1100 Message-Id: <20171024013153.28200-2-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 1/6] tree: Rework set-chosen-cpu and store /chosen ihandle and phandle 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" This replaces current set-chosen-cpu with a cleaner and faster implementation which does not clobber the current node and stores the chosen CPU phandle/ihandle. This adds a helper to get the chosen CPU unit address. This moves chosen cpu words to root.fs as otherwise it is quite hard to maintain dependencies. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Segher Boessenkool --- board-qemu/slof/tree.fs | 6 ------ slof/fs/root.fs | 11 +++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/board-qemu/slof/tree.fs b/board-qemu/slof/tree.fs index cc35fa3..d95fde3 100644 --- a/board-qemu/slof/tree.fs +++ b/board-qemu/slof/tree.fs @@ -155,12 +155,6 @@ populate-pci-busses 6c0 cp -\ Do not assume that cpu0 is available -: set-chosen-cpu - " /cpus" find-device - get-node child dup 0= ABORT" CPU not found" - node>path open-dev encode-int s" cpu" set-chosen -; set-chosen-cpu s" /memory@0" open-dev encode-int s" memory" set-chosen diff --git a/slof/fs/root.fs b/slof/fs/root.fs index 44d087a..3818790 100644 --- a/slof/fs/root.fs +++ b/slof/fs/root.fs @@ -33,6 +33,17 @@ defer continue-client : get-chosen ( name len -- [ prop len ] success ) chosen get-property 0= ; +\ Do not assume that cpu0 is available +VARIABLE chosen-cpu-ihandle +: set-chosen-cpu ( -- ) + s" /cpus" find-node dup 0= ABORT" /cpus not found" + child dup 0= ABORT" /cpus/cpu not found" + 0 0 rot open-node + dup chosen-cpu-ihandle ! encode-int s" cpu" set-chosen +; + +: chosen-cpu-unit ( -- ret ) chosen-cpu-ihandle @ ihandle>phandle >unit ; + \ Look for an exising root, create one if needed " /" find-node dup 0= IF drop