The inner loop in fb8-toggle-cursor can be implemented with hv-logical-memop
in board-qemu and get an incredible performance boost.

Let's introduce a per-board helper:
- board-js2x: slow RB based, taken from current fb8-toggle-cursor
- board-qemu: faster hv-logical-memop based

With standard graphical settings on board-qemu, we go from 512 hcall
invocations per character down to 16.

Suggested-by: Thomas Huth <th...@redhat.com>
Signed-off-by: Greg Kurz <gk...@linux.vnet.ibm.com>
---
 board-js2x/slof/helper.fs |    4 ++++
 board-qemu/slof/helper.fs |    3 +++
 slof/fs/fbuffer.fs        |    2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs
index 34d60da..918fdc4 100644
--- a/board-js2x/slof/helper.fs
+++ b/board-js2x/slof/helper.fs
@@ -26,3 +26,7 @@
    s" , " $cat
    bdate2human $cat encode-string THEN
 ;
+
+: invert-region ( addr len -- )
+   0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP drop
+;
diff --git a/board-qemu/slof/helper.fs b/board-qemu/slof/helper.fs
index 96da498..da676c7 100644
--- a/board-qemu/slof/helper.fs
+++ b/board-qemu/slof/helper.fs
@@ -33,3 +33,6 @@
   swap -
 ;
 
+: invert-region ( addr len -- )
+   over swap 0 swap 1 hv-logical-memop drop
+;
diff --git a/slof/fs/fbuffer.fs b/slof/fs/fbuffer.fs
index faae6a9..deeba6b 100644
--- a/slof/fs/fbuffer.fs
+++ b/slof/fs/fbuffer.fs
@@ -99,7 +99,7 @@ CREATE bitmap-buffer 400 4 * allot
 : fb8-toggle-cursor ( -- )
        line# fb8-line2addr column# fb8-columns2bytes +
        char-height 0 ?DO
-               dup char-width screen-depth * 0 ?DO dup dup rb@ -1 xor swap rb! 
1+ LOOP drop
+               dup char-width screen-depth * invert-region
                screen-width screen-depth * +
        LOOP drop
 ;

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to