From patchwork Thu May 17 13:16:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 915440 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 40msJY0Bgxz9s3B for ; Thu, 17 May 2018 23:16:29 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40msJX5Z4xzF258 for ; Thu, 17 May 2018 23:16:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lvivier@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40msJD5wxkzF25m for ; Thu, 17 May 2018 23:16:09 +1000 (AEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C116040200A3; Thu, 17 May 2018 13:16:07 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-204-210.brq.redhat.com [10.40.204.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id D39A410E4CFB; Thu, 17 May 2018 13:16:06 +0000 (UTC) From: Laurent Vivier To: slof@lists.ozlabs.org Date: Thu, 17 May 2018 15:16:03 +0200 Message-Id: <20180517131604.30368-2-lvivier@redhat.com> In-Reply-To: <20180517131604.30368-1-lvivier@redhat.com> References: <20180517131604.30368-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 17 May 2018 13:16:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 17 May 2018 13:16:07 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lvivier@redhat.com' RCPT:'' Subject: [SLOF] [PATCH v7 1/2] Fix output word 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: , Cc: Thomas Huth MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" We can select the console output, but it does not really work Implement term-io-emit, as we have term-io-key to really send characters to the output selected by stdout. Resolve xt-handle and ihandle in the output command. Use them in the new term-io-emit function. Signed-off-by: Laurent Vivier Reviewed-by: Thomas Huth --- slof/fs/term-io.fs | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs index 52ce12a..f13ae87 100644 --- a/slof/fs/term-io.fs +++ b/slof/fs/term-io.fs @@ -10,6 +10,17 @@ \ * IBM Corporation - initial implementation \ ****************************************************************************/ +0 VALUE write-xt + +VARIABLE stdout + +: set-stdout ( ihandle -- ) + \ Close old stdout: + stdout @ ?dup IF close-dev THEN + \ Now set the new stdout: + dup stdout ! + encode-int s" stdout" set-chosen +; : input ( dev-str dev-len -- ) open-dev ?dup IF @@ -24,12 +35,15 @@ : output ( dev-str dev-len -- ) open-dev ?dup IF - \ Close old stdout: - s" stdout" get-chosen IF - decode-int nip nip ?dup IF close-dev THEN + \ find new ihandle and xt handle + dup s" write" rot ihandle>phandle find-method + 0= IF + drop + cr ." Cannot find the write method for the given output console " cr + EXIT THEN - \ Now set the new stdout: - encode-int s" stdout" set-chosen + to write-xt + set-stdout THEN ; @@ -40,6 +54,18 @@ 1 BUFFER: (term-io-char-buf) +: term-io-emit ( char -- ) + write-xt IF + (term-io-char-buf) c! + (term-io-char-buf) 1 write-xt stdout @ call-package + drop + ELSE + serial-emit + THEN +; + +' term-io-emit to emit + : term-io-key ( -- char ) s" stdin" get-chosen IF decode-int nip nip dup 0= IF 0 EXIT THEN