summaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/tty.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-06 10:20:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-06 10:20:47 -0700
commita417fb99dea8ee47e72060fb36e5f3ff4ea54a5b (patch)
tree788cf90966768c270db150f06917728937150da4 /arch/x86/boot/tty.c
parent9faa1e5942fd647b0dd2fbbdcc04988841cacaf3 (diff)
parent6238b47b58480cd9c092600c05338dbe261b71ce (diff)
Merge branch 'x86-setup-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-setup-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86, setup: move isdigit.h to ctype.h, header files on top. x86, setup: enable early console output from the decompressor x86, setup: reorganize the early console setup x86, setup: Allow global variables and functions in the decompressor x86, setup: Only set early_serial_base after port is initialized x86, setup: Make the setup code also accept console=uart8250 x86, setup: Early-boot serial I/O support
Diffstat (limited to 'arch/x86/boot/tty.c')
-rw-r--r--arch/x86/boot/tty.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/arch/x86/boot/tty.c b/arch/x86/boot/tty.c
index 01ec69c901c7..def2451f46ae 100644
--- a/arch/x86/boot/tty.c
+++ b/arch/x86/boot/tty.c
@@ -10,23 +10,36 @@
* ----------------------------------------------------------------------- */
/*
- * Very simple screen I/O
- * XXX: Probably should add very simple serial I/O?
+ * Very simple screen and serial I/O
*/
#include "boot.h"
+int early_serial_base;
+
+#define XMTRDY 0x20
+
+#define TXR 0 /* Transmit register (WRITE) */
+#define LSR 5 /* Line Status */
+
/*
* These functions are in .inittext so they can be used to signal
* error during initialization.
*/
-void __attribute__((section(".inittext"))) putchar(int ch)
+static void __attribute__((section(".inittext"))) serial_putchar(int ch)
{
- struct biosregs ireg;
+ unsigned timeout = 0xffff;
- if (ch == '\n')
- putchar('\r'); /* \n -> \r\n */
+ while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
+ cpu_relax();
+
+ outb(ch, early_serial_base + TXR);
+}
+
+static void __attribute__((section(".inittext"))) bios_putchar(int ch)
+{
+ struct biosregs ireg;
initregs(&ireg);
ireg.bx = 0x0007;
@@ -36,6 +49,17 @@ void __attribute__((section(".inittext"))) putchar(int ch)
intcall(0x10, &ireg, NULL);
}
+void __attribute__((section(".inittext"))) putchar(int ch)
+{
+ if (ch == '\n')
+ putchar('\r'); /* \n -> \r\n */
+
+ bios_putchar(ch);
+
+ if (early_serial_base != 0)
+ serial_putchar(ch);
+}
+
void __attribute__((section(".inittext"))) puts(const char *str)
{
while (*str)
@@ -112,3 +136,4 @@ int getchar_timeout(void)
return 0; /* Timeout! */
}
+