124 lines
3.5 KiB
Diff
124 lines
3.5 KiB
Diff
|
From d8b13f259660ed37f219db40f3d93f2ae81d4945 Mon Sep 17 00:00:00 2001
|
||
|
From: Laurent Vivier <lvivier@redhat.com>
|
||
|
Date: Tue, 29 May 2018 11:09:33 +0200
|
||
|
Subject: [PATCH 2/2] resolve ihandle and xt handle in the input command (like
|
||
|
for the output)
|
||
|
|
||
|
RH-Author: Laurent Vivier <lvivier@redhat.com>
|
||
|
Message-id: <20180529110933.1441-3-lvivier@redhat.com>
|
||
|
Patchwork-id: 80502
|
||
|
O-Subject: [RHEL7.6 SLOF PATCH 2/2] resolve ihandle and xt handle in the input command (like for the output)
|
||
|
Bugzilla: 1495467
|
||
|
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
||
|
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
||
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
||
|
|
||
|
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
||
|
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
||
|
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
||
|
(cherry picked from commit 85d5b4d62d0563163bd12d06a783fbc04a4d9069)
|
||
|
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
||
|
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
||
|
---
|
||
|
slof/fs/term-io.fs | 40 ++++++++++++++++++++++++----------------
|
||
|
1 file changed, 24 insertions(+), 16 deletions(-)
|
||
|
|
||
|
diff --git a/slof/fs/term-io.fs b/slof/fs/term-io.fs
|
||
|
index f13ae87..5b94b26 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,16 +79,14 @@ 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, ]
|
||
|
+ serial-key
|
||
|
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 )
|
||
|
@@ -115,8 +124,7 @@ VARIABLE stdout
|
||
|
2drop r> drop false EXIT \ unknown device_type cleanup return-stack, return false
|
||
|
THEN
|
||
|
ELSE
|
||
|
- \ stdin not set, return false
|
||
|
- false
|
||
|
+ serial-key?
|
||
|
THEN
|
||
|
;
|
||
|
|
||
|
--
|
||
|
1.8.3.1
|
||
|
|