Skip to contentSkip to conversation

x86, setup: Check early serial console per string instead of one char

PATCH In review Yinghai Lu 2 participants 4 messages Oct 11, 2010 x86

lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/1 x86, setup: Check early serial console per string instead of one char

Move out serial_putchar() calling out of putchar
Let puts() to call serial_putchar() directly.

So only need to check early_serial_base per string.

---
 arch/x86/boot/tty.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
arch/x86/boot/tty.c +10 -4
Index: linux-2.6/arch/x86/boot/tty.c
===================================================================
@@ -52,16 +52,22 @@ static void __attribute__((section(".ini
 void __attribute__((section(".inittext"))) putchar(int ch)
 {
 	if (ch == '\n')
-		putchar('\r');	/* \n -> \r\n */
+		bios_putchar('\r');	/* \n -> \r\n */
 
 	bios_putchar(ch);
-
-	if (early_serial_base != 0)
-		serial_putchar(ch);
 }
 
 void __attribute__((section(".inittext"))) puts(const char *str)
 {
+	if (early_serial_base) {
+		const char *s = str;
+		while (*s) {
+			if (*s == '\n')
+				serial_putchar('\r');
+			serial_putchar(*s++);
+		}
+	}
+
 	while (*str)
 		putchar(*str++);
 }
#1 lore raw
Quoted 8 lines · Yinghai Lu

Move out serial_putchar() calling out of putchar
Let puts() to call serial_putchar() directly.

So only need to check early_serial_base per string.

This seems to add a bunch of code for zero benefit. Testing a global variable is zero cost compared to either a BIOS call or poking a serial port.

-hpa

author
#2 lore raw
Quoted 5 lines · H. Peter Anvin
Quoted 4 lines · Yinghai Lu

Move out serial_putchar() calling out of putchar
Let puts() to call serial_putchar() directly.

Quoted 8 lines
Quoted 4 lines

So only need to check early_serial_base per string.

This seems to add a bunch of code for zero benefit. Testing a global variable is zero cost compared to either a BIOS call or poking a serial port.

some server have bios serial console redirection support, and bios int call could send char to screen and serial port.

in that case, take out serial_putchar from putchar could produce more readable print out from serial console

Thanks

Yinghai

#3 lore raw
Quoted 9 lines · Yinghai Lu
Quoted 4 lines

This seems to add a bunch of code for zero benefit. Testing a global variable is zero cost compared to either a BIOS call or poking a serial port.

some server have bios serial console redirection support, and bios int call could send char to screen and serial port.

in that case, take out serial_putchar from putchar could produce more readable print out from serial console

That doesn't appear to have anything to do with this code change. What you're saying is that "if BIOS does serial console redirection, we shouldn't output to both the serial console and the BIOS console", which is of course a truism, but that doesn't justify in any way this particular code reconfiguration.

-hpa