diff mbox

SGABIOS: fix wrong video attrs for int 10h, ah==13h

Message ID 20170309165120.960B540827A6@vostest4.mno.stratus.com
State New
Headers show

Commit Message

herbierobinson March 7, 2017, 1:30 a.m. UTC
Fix Bug #1670509: wrong video attrs for int 10h, ah==13h
The subroutine set_cursor_position is trashing %bx.
Unfortunately, %bl contains the video attribute for write_string.

The fix saves %bx in the function prolog and restores it in
the epilog.  Also, remove save and restore in set_current_cursor,
because set_cursor_position does it.

Signed-off-by: herbierobinson <Herbie.Robinson@stratus.com>
---
 sgabios.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Laurent Vivier March 9, 2017, 5:38 p.m. UTC | #1
On 07/03/2017 02:30, herbierobinson wrote:
> Fix Bug #1670509: wrong video attrs for int 10h, ah==13h
> The subroutine set_cursor_position is trashing %bx.
> Unfortunately, %bl contains the video attribute for write_string.
> 
> The fix saves %bx in the function prolog and restores it in
> the epilog.  Also, remove save and restore in set_current_cursor,
> because set_cursor_position does it.
> 
> Signed-off-by: herbierobinson <Herbie.Robinson@stratus.com>
> ---
>  sgabios.S | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sgabios.S b/sgabios.S
> index 275d063..da5acc2 100644
> --- a/sgabios.S
> +++ b/sgabios.S
> @@ -1728,6 +1728,7 @@ write_string_tail:
>  
>  set_cursor_position:
>    pushw %ax
> +  pushw %bx
>    pushw %ds
>    pushw $BDA_SEG
>    popw %ds                             /* ds = 0x40 */
> @@ -1738,6 +1739,7 @@ set_cursor_position:
>    movw %ax, %bx                        /* bx = cursor save offset */
>    movw %dx, (%bx)                      /* save new cursor value */
>    popw %ds
> +  popw %bx
>    popw %ax
>    ret
>  
> @@ -1752,12 +1754,10 @@ set_cursor_position:
>  
>  set_current_cursor:
>    pushw %ds
> -  pushw %bx
>    pushw $BDA_SEG
>    popw %ds                             /* ds = 0x40 */
>    movb BDA_ACTIVE_PAGE, %bh

Well, we are trashing %bh here, I think the push/pop %bx is needed.
[comment says "all registers preserved except flags"]

>    call set_cursor_position
> -  popw %bx
>    popw %ds
>    ret
>  
>
diff mbox

Patch

diff --git a/sgabios.S b/sgabios.S
index 275d063..da5acc2 100644
--- a/sgabios.S
+++ b/sgabios.S
@@ -1728,6 +1728,7 @@  write_string_tail:
 
 set_cursor_position:
   pushw %ax
+  pushw %bx
   pushw %ds
   pushw $BDA_SEG
   popw %ds                             /* ds = 0x40 */
@@ -1738,6 +1739,7 @@  set_cursor_position:
   movw %ax, %bx                        /* bx = cursor save offset */
   movw %dx, (%bx)                      /* save new cursor value */
   popw %ds
+  popw %bx
   popw %ax
   ret
 
@@ -1752,12 +1754,10 @@  set_cursor_position:
 
 set_current_cursor:
   pushw %ds
-  pushw %bx
   pushw $BDA_SEG
   popw %ds                             /* ds = 0x40 */
   movb BDA_ACTIVE_PAGE, %bh
   call set_cursor_position
-  popw %bx
   popw %ds
   ret