From patchwork Fri Apr 6 08:47: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: 895638 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 40HYGw1Ylrz9s1p for ; Fri, 6 Apr 2018 18:47:20 +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 40HYGv6SYPzF1yq for ; Fri, 6 Apr 2018 18:47:19 +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 40HYGl5zddzF1ym for ; Fri, 6 Apr 2018 18:47:11 +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 BE2817D843; Fri, 6 Apr 2018 08:47:08 +0000 (UTC) Received: from thinkpad.redhat.com (unknown [10.40.205.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5F5E1227724; Fri, 6 Apr 2018 08:47:07 +0000 (UTC) From: Laurent Vivier To: slof@lists.ozlabs.org Date: Fri, 6 Apr 2018 10:47:03 +0200 Message-Id: <20180406084704.29048-2-lvivier@redhat.com> In-Reply-To: <20180406084704.29048-1-lvivier@redhat.com> References: <20180406084704.29048-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.2]); Fri, 06 Apr 2018 08:47:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Fri, 06 Apr 2018 08:47:08 +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 v6 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..d247b09 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 + [ ' emit behavior compile, ] + 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 From patchwork Fri Apr 6 08:47:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 895639 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 40HYH00Xs9z9s1p for ; Fri, 6 Apr 2018 18:47:24 +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 40HYGz5ndwzF20q for ; Fri, 6 Apr 2018 18:47:23 +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 40HYGm2qpBzF1yq for ; Fri, 6 Apr 2018 18:47:12 +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 1B93076FB9; Fri, 6 Apr 2018 08:47:10 +0000 (UTC) Received: from thinkpad.redhat.com (unknown [10.40.205.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 212F01227726; Fri, 6 Apr 2018 08:47:08 +0000 (UTC) From: Laurent Vivier To: slof@lists.ozlabs.org Date: Fri, 6 Apr 2018 10:47:04 +0200 Message-Id: <20180406084704.29048-3-lvivier@redhat.com> In-Reply-To: <20180406084704.29048-1-lvivier@redhat.com> References: <20180406084704.29048-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.1]); Fri, 06 Apr 2018 08:47:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 06 Apr 2018 08:47:10 +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 v6 2/2] resolve ihandle and xt handle in the input command (like for the output) 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" Signed-off-by: Laurent Vivier Reviewed-by: Thomas Huth --- slof/fs/term-io.fs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs index d247b09..f32acdd 100644 --- a/slof/fs/term-io.fs +++ b/slof/fs/term-io.fs @@ -10,10 +10,20 @@ \ * IBM Corporation - initial implementation \ ****************************************************************************/ +0 VALUE read-xt 0 VALUE write-xt +VARIABLE stdin VARIABLE stdout +: set-stdin ( ihandle -- ) + \ Close old stdin: + stdin @ ?dup IF close-dev THEN + \ Now set the new stdin: + dup stdin ! + encode-int s" stdin" set-chosen +; + : set-stdout ( ihandle -- ) \ Close old stdout: stdout @ ?dup IF close-dev THEN @@ -24,12 +34,15 @@ VARIABLE stdout : input ( dev-str dev-len -- ) open-dev ?dup IF - \ Close old stdin: - s" stdin" get-chosen IF - decode-int nip nip ?dup IF close-dev THEN + \ find new ihandle and xt handle + dup s" read" rot ihandle>phandle find-method + 0= IF + drop + cr ." Cannot find the read method for the given input console " cr + EXIT THEN - \ Now set the new stdin: - encode-int s" stdin" set-chosen + to read-xt + set-stdin THEN ; @@ -51,7 +64,6 @@ VARIABLE stdout 2dup input output ; - 1 BUFFER: (term-io-char-buf) : term-io-emit ( char -- ) @@ -67,14 +79,12 @@ VARIABLE stdout ' term-io-emit to emit : term-io-key ( -- char ) - s" stdin" get-chosen IF - decode-int nip nip dup 0= IF 0 EXIT THEN - >r BEGIN - (term-io-char-buf) 1 s" read" r@ $call-method + read-xt IF + BEGIN + (term-io-char-buf) 1 read-xt stdin @ call-package 0 > UNTIL (term-io-char-buf) c@ - r> drop ELSE [ ' key behavior compile, ] THEN @@ -88,8 +98,7 @@ VARIABLE stdout \ - if it's an hv console, use hvterm-key? \ otherwise it will always return false : term-io-key? ( -- true|false ) - s" stdin" get-chosen IF - decode-int nip nip dup 0= IF drop 0 EXIT THEN \ return false and exit if no stdin set + stdin @ ?dup IF >r \ store ihandle on return stack s" device_type" r@ ihandle>phandle ( propstr len phandle ) get-property ( true | data dlen false )