Skip to content

Commit 210a1ce

Browse files
fthaingeertu
authored andcommitted
m68k: Fix lost column on framebuffer debug console
Move the cursor position rightward after rendering the character, not before. This avoids complications that arise when the recursive console_putc call has to wrap the line and/or scroll the display. This also fixes the linewrap bug that crops off the rightmost column. When the cursor is at the bottom of the display, a linefeed will not move the cursor position further downward. Instead, the display scrolls upward. Avoid the repeated add/subtract sequence by way of a single subtraction at the initialization of console_struct_num_rows. Fixes: 1da177e ("Linux-2.6.12-rc2") Cc: [email protected] Signed-off-by: Finn Thain <[email protected]> Tested-by: Stan Johnson <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/9d4e8c68a456d5f2bc254ac6f87a472d066ebd5e.1743115195.git.fthain@linux-m68k.org Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 8135422 commit 210a1ce

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

arch/m68k/kernel/head.S

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,6 +3400,7 @@ L(console_clear_loop):
34003400

34013401
movel %d4,%d1 /* screen height in pixels */
34023402
divul %a0@(FONT_DESC_HEIGHT),%d1 /* d1 = max num rows */
3403+
subql #1,%d1 /* row range is 0 to num - 1 */
34033404

34043405
movel %d0,%a2@(Lconsole_struct_num_columns)
34053406
movel %d1,%a2@(Lconsole_struct_num_rows)
@@ -3546,15 +3547,14 @@ func_start console_putc,%a0/%a1/%d0-%d7
35463547
cmpib #10,%d7
35473548
jne L(console_not_lf)
35483549
movel %a0@(Lconsole_struct_cur_row),%d0
3549-
addil #1,%d0
3550-
movel %d0,%a0@(Lconsole_struct_cur_row)
35513550
movel %a0@(Lconsole_struct_num_rows),%d1
35523551
cmpl %d1,%d0
35533552
jcs 1f
3554-
subil #1,%d0
3555-
movel %d0,%a0@(Lconsole_struct_cur_row)
35563553
console_scroll
3554+
jra L(console_exit)
35573555
1:
3556+
addql #1,%d0
3557+
movel %d0,%a0@(Lconsole_struct_cur_row)
35583558
jra L(console_exit)
35593559

35603560
L(console_not_lf):
@@ -3581,12 +3581,6 @@ L(console_not_cr):
35813581
*/
35823582
L(console_not_home):
35833583
movel %a0@(Lconsole_struct_cur_column),%d0
3584-
addql #1,%a0@(Lconsole_struct_cur_column)
3585-
movel %a0@(Lconsole_struct_num_columns),%d1
3586-
cmpl %d1,%d0
3587-
jcs 1f
3588-
console_putc #'\n' /* recursion is OK! */
3589-
1:
35903584
movel %a0@(Lconsole_struct_cur_row),%d1
35913585

35923586
/*
@@ -3633,6 +3627,23 @@ L(console_do_font_scanline):
36333627
addq #1,%d1
36343628
dbra %d7,L(console_read_char_scanline)
36353629

3630+
/*
3631+
* Register usage in the code below:
3632+
* a0 = pointer to console globals
3633+
* d0 = cursor column
3634+
* d1 = cursor column limit
3635+
*/
3636+
3637+
lea %pc@(L(console_globals)),%a0
3638+
3639+
movel %a0@(Lconsole_struct_cur_column),%d0
3640+
addql #1,%d0
3641+
movel %d0,%a0@(Lconsole_struct_cur_column) /* Update cursor pos */
3642+
movel %a0@(Lconsole_struct_num_columns),%d1
3643+
cmpl %d1,%d0
3644+
jcs L(console_exit)
3645+
console_putc #'\n' /* Line wrap using tail recursion */
3646+
36363647
L(console_exit):
36373648
func_return console_putc
36383649

0 commit comments

Comments
 (0)