fix last column in BIOS console
PATCH 1/1 fix last column in BIOS console
BIOS console wrapped line at 79 characters. It became the issue after recent changes when extra column for scrolling indications was removed. The effect was that up/down arrows were printed in the first column of the next line.
May be it would be easier to simply use INT10 AH=13. Available documentation indicates that it is available since 1986, so I guess any system that exists today should implement it.
--- grub-core/term/i386/pc/console.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
grub-core/term/i386/pc/console.c +8 -13
@@ -86,13 +86,9 @@ grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),* Put the character C on the console. Because GRUB wants to write a * character with an attribute, this implementation is a bit tricky. * If C is a control character (CR, LF, BEL, BS), use INT 10, AH = 0Eh -* (TELETYPE OUTPUT). Otherwise, save the original position, put a space, -* save the current position, restore the original position, write the -* character and the attribute, and restore the current position. -* -* The reason why this is so complicated is that there is no easy way to -* get the height of the screen, and the TELETYPE OUTPUT BIOS call doesn't -* support setting a background attribute. +* (TELETYPE OUTPUT). Otherwise, use INT 10, AH = 9 to write character +* with attributes and advance cursor. If we are on the last column, +* let BIOS to wrap line correctly. */ static void grub_console_putchar_real (grub_uint8_t c)
@@ -112,19 +108,18 @@ grub_console_putchar_real (grub_uint8_t c)/* get the current position */ pos =grub_console_getxy (NULL ); +/* write the character with the attribute */ +int10_9 (c,1 ); +/* check the column with the width */ if ((pos &0xff00 ) >= (79 <<8 )) {grub_console_putchar_real (0x0d );grub_console_putchar_real (0x0a ); -/* get the current position */ - pos =grub_console_getxy (NULL ); } +else +grub_console_gotoxy (NULL , ((pos &0xff00 ) >>8 ) +1 , (pos &0xff )); -/* write the character with the attribute */ -int10_9 (c,1 ); - -grub_console_gotoxy (NULL , ((pos &0xff00 ) >>8 ) +1 , (pos &0xff )); } static void
Signature · 1 line
tg: (cc35b49..) u/console-last-column (depends on: master)
Quoted 9 lines · Andrey Borzenkov
BIOS console wrapped line at 79 characters. It became the issue after recent changes when extra column for scrolling indications was removed. The effect was that up/down arrows were printed in the first column of the next line.
May be it would be easier to simply use INT10 AH=13. Available documentation indicates that it is available since 1986, so I guess any system that exists today should implement it.
I need to look how we ended up with the current code. It doesn't match its comment which details an algorithm working for any screen dimensions while current code assumes a fixed width. Another corner question is a possibility of usage of vga_text and keep console to the bare minimum. Does anyone have information about BIOSes redirecting their output? The age of the function is no argument about their availability. Loads of functions are not implemented or broken in modern BIOSes. More or less the only guarantee of function working on all BIOSes is if BIOS uses them in a normal bootpath.
Quoted 52 lines
Signed-off-by Andrey Borzenkov <[email protected]>--- grub-core/term/i386/pc/console.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)grub-core/term/i386/pc/console.c +8
-13@@ -86,13 +86,9 @@ grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),* Put the character C on the console. Because GRUB wants to write a * character with an attribute, this implementation is a bit tricky. * If C is a control character (CR, LF, BEL, BS), use INT 10, AH = 0Eh -* (TELETYPE OUTPUT). Otherwise, save the original position, put a space, -* save the current position, restore the original position, write the -* character and the attribute, and restore the current position. -* -* The reason why this is so complicated is that there is no easy way to -* get the height of the screen, and the TELETYPE OUTPUT BIOS call doesn't -* support setting a background attribute. +* (TELETYPE OUTPUT). Otherwise, use INT 10, AH = 9 to write character +* with attributes and advance cursor. If we are on the last column, +* let BIOS to wrap line correctly. */ static void grub_console_putchar_real (grub_uint8_t c)@@ -112,19 +108,18 @@ grub_console_putchar_real (grub_uint8_t c)/* get the current position */ pos =grub_console_getxy (NULL ); +/* write the character with the attribute */ +int10_9 (c,1 ); +/* check the column with the width */ if ((pos &0xff00 ) >= (79 <<8 )) {grub_console_putchar_real (0x0d );grub_console_putchar_real (0x0a ); -/* get the current position */ - pos =grub_console_getxy (NULL ); } +else +grub_console_gotoxy (NULL , ((pos &0xff00 ) >>8 ) +1 , (pos &0xff )); -/* write the character with the attribute */ -int10_9 (c,1 ); - -grub_console_gotoxy (NULL , ((pos &0xff00 ) >>8 ) +1 , (pos &0xff )); } static void
Quoted 12 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 9 lines · Andrey Borzenkov
BIOS console wrapped line at 79 characters. It became the issue after recent changes when extra column for scrolling indications was removed. The effect was that up/down arrows were printed in the first column of the next line.
May be it would be easier to simply use INT10 AH=13. Available documentation indicates that it is available since 1986, so I guess any system that exists today should implement it.
Quoted 10 lines
I need to look how we ended up with the current code. It doesn't match its comment which details an algorithm working for any screen dimensions while current code assumes a fixed width. Another corner question is a possibility of usage of
vga_textand keep console to the bare minimum. Does anyone have information about BIOSes redirecting their output? The age of the function is no argument about their availability. Loads of functions are not implemented or broken in modern BIOSes. More or less the only guarantee of function working on all BIOSes is if BIOS uses them in a normal bootpath.
The code was the same since it was (re)written in 2002 for GRUB Legacy. Your code and original make the same assumptions, so the patch is good. Could you make a membership request on savannah so you can commit patches yourself once they're approved?
Quoted 55 lines
Quoted 52 lines
Signed-off-by Andrey Borzenkov <[email protected]>--- grub-core/term/i386/pc/console.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)grub-core/term/i386/pc/console.c +8
-13@@ -86,13 +86,9 @@ grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),* Put the character C on the console. Because GRUB wants to write a * character with an attribute, this implementation is a bit tricky. * If C is a control character (CR, LF, BEL, BS), use INT 10, AH = 0Eh -* (TELETYPE OUTPUT). Otherwise, save the original position, put a space, -* save the current position, restore the original position, write the -* character and the attribute, and restore the current position. -* -* The reason why this is so complicated is that there is no easy way to -* get the height of the screen, and the TELETYPE OUTPUT BIOS call doesn't -* support setting a background attribute. +* (TELETYPE OUTPUT). Otherwise, use INT 10, AH = 9 to write character +* with attributes and advance cursor. If we are on the last column, +* let BIOS to wrap line correctly. */ static void grub_console_putchar_real (grub_uint8_t c)@@ -112,19 +108,18 @@ grub_console_putchar_real (grub_uint8_t c)/* get the current position */ pos =grub_console_getxy (NULL ); +/* write the character with the attribute */ +int10_9 (c,1 ); +/* check the column with the width */ if ((pos &0xff00 ) >= (79 <<8 )) {grub_console_putchar_real (0x0d );grub_console_putchar_real (0x0a ); -/* get the current position */ - pos =grub_console_getxy (NULL ); } +else +grub_console_gotoxy (NULL , ((pos &0xff00 ) >>8 ) +1 , (pos &0xff )); -/* write the character with the attribute */ -int10_9 (c,1 ); - -grub_console_gotoxy (NULL , ((pos &0xff00 ) >>8 ) +1 , (pos &0xff )); } static void