1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
5 * Copyright 2009 Intel Corporation; author H. Peter Anvin
7 * This file is part of the Linux kernel, and is made available under
8 * the terms of the GNU General Public License version 2.
10 * ----------------------------------------------------------------------- */
13 * Very simple screen and serial I/O
18 int early_serial_base;
22 #define TXR 0 /* Transmit register (WRITE) */
23 #define LSR 5 /* Line Status */
26 * These functions are in .inittext so they can be used to signal
27 * error during initialization.
30 static void __attribute__((section(".inittext"))) serial_putchar(int ch)
32 unsigned timeout = 0xffff;
34 while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
37 outb(ch, early_serial_base + TXR);
40 static void __attribute__((section(".inittext"))) bios_putchar(int ch)
49 intcall(0x10, &ireg, NULL);
52 void __attribute__((section(".inittext"))) putchar(int ch)
55 putchar('\r'); /* \n -> \r\n */
59 if (early_serial_base != 0)
63 void __attribute__((section(".inittext"))) puts(const char *str)
70 * Read the CMOS clock through the BIOS, and return the
74 static u8 gettime(void)
76 struct biosregs ireg, oreg;
80 intcall(0x1a, &ireg, &oreg);
86 * Read from the keyboard
90 struct biosregs ireg, oreg;
94 intcall(0x16, &ireg, &oreg);
99 static int kbd_pending(void)
101 struct biosregs ireg, oreg;
105 intcall(0x16, &ireg, &oreg);
107 return !(oreg.eflags & X86_EFLAGS_ZF);
119 int getchar_timeout(void)
137 return 0; /* Timeout! */