[SLOF] [PATCH v2 1/2] fbuffer: Improve invert-region helper

Thomas Huth thuth at redhat.com
Tue Aug 4 05:18:27 AEST 2015


On 03/08/15 12:52, Nikunj A Dadhania wrote:
> Thomas Huth <thuth at redhat.com> writes:
> 
>> The introduction of invert-region already speeded up the cursor
>> drawing very much. But there is still space for improvement:
>> So far invert-region is accessing the memory only byte by byte,
>> but with some additional logic that checks the alignment of the
>> address and the length of the area, we can also make this function
>> to access the memory with half-word, word or long-word accesses.
>> With this additional logic, invert-region-x is also no longer
>> necessary and thus can be removed.
>>
>> Signed-off-by: Thomas Huth <thuth at redhat.com>
>> ---
>>  board-js2x/slof/helper.fs | 13 ++++++++-----
>>  board-qemu/slof/helper.fs | 14 ++++++++++----
>>  slof/fs/fbuffer.fs        |  2 +-
>>  3 files changed, 19 insertions(+), 10 deletions(-)
>>
>> diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs
>> index 6030330..1e2b030 100644
>> --- a/board-js2x/slof/helper.fs
>> +++ b/board-js2x/slof/helper.fs
>> @@ -28,9 +28,12 @@
>>  ;
>>
>>  : invert-region ( addr len -- )
>> -   0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP drop
>> -;
>> -
>> -: invert-region-x ( addr len -- )
>> -   /x / 0 ?DO dup dup rx@ -1 xor swap rx! xa1+ LOOP drop
>> +   2dup or 7 and CASE
>> +      0 OF 3 rshift 0 ?DO dup dup rx@ -1 xor swap rx! xa1+ LOOP ENDOF
>> +      4 OF 2 rshift 0 ?DO dup dup rl@ -1 xor swap rl! la1+ LOOP ENDOF
>> +      3 and
>> +      2 OF 1 rshift 0 ?DO dup dup rw@ -1 xor swap rw! wa1+ LOOP ENDOF
>> +      dup OF 0 ?DO dup dup rb@ -1 xor swap rb! 1+ LOOP ENDOF
>> +   ENDCASE
>> +   drop
>>  ;
>> diff --git a/board-qemu/slof/helper.fs b/board-qemu/slof/helper.fs
>> index c807bc6..40d4abc 100644
>> --- a/board-qemu/slof/helper.fs
>> +++ b/board-qemu/slof/helper.fs
>> @@ -33,10 +33,16 @@
>>    swap -
>>  ;
>>
>> -: invert-region ( addr len -- )
>> -   over swap 0 swap 1 hv-logical-memop drop
>> +: invert-region-cs ( addr len cellsize -- )
>> +   >r over swap r@ rshift r> swap 1 hv-logical-memop drop
>>  ;
>>
>> -: invert-region-x ( addr len -- )
>> -   over swap /x / 3 swap 1 hv-logical-memop drop
>> +: invert-region ( addr len -- )
>> +   2dup or 7 and CASE
> 
> For example if we get  ( 1000 107 ) in the stack, we would still do
> byte-by-byte, do we need to address this case as well ?
> 
> First finish aligned 0x100 length, and then byte-by-byte for 7bytes left?

Theoretically yes, but the function is currently only used for drawing
the cursor and blinking the screen. And the screen and cursor width are
always multiple of 8, so I think this is currently not worth the effort.
We just might reconsider if we ever use this function for something
different with uneven size in the future.

 Thomas



More information about the SLOF mailing list