public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86,setup: add serial_console_port_base in boot_params
@ 2010-07-15 22:27 Yinghai Lu
  2010-07-16  0:12 ` H. Peter Anvin
  2010-07-31  8:34 ` Cyrill Gorcunov
  0 siblings, 2 replies; 12+ messages in thread
From: Yinghai Lu @ 2010-07-15 22:27 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: Pekka Enberg, Cyrill Gorcunov, linux-kernel@vger.kernel.org


to save the early_serial_base.

Also bootloader could fill that field, so setup code could reuse it.

decompress code could reuse early serial console from setup code.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 Documentation/x86/zero-page.txt  |    1 +
 arch/x86/boot/compressed/misc.c  |   25 +++++++++++++++++++++++++
 arch/x86/boot/tty.c              |    7 ++++++-
 arch/x86/include/asm/bootparam.h |    3 ++-
 4 files changed, 34 insertions(+), 2 deletions(-)

Index: linux-2.6/Documentation/x86/zero-page.txt
===================================================================
--- linux-2.6.orig/Documentation/x86/zero-page.txt
+++ linux-2.6/Documentation/x86/zero-page.txt
@@ -12,6 +12,7 @@ Offset	Proto	Name		Meaning
 000/040	ALL	screen_info	Text mode or frame buffer information
 				(struct screen_info)
 040/014	ALL	apm_bios_info	APM BIOS information (struct apm_bios_info)
+054/002 ALL	serial_console_port_base early serial console preset
 058/008	ALL	tboot_addr      Physical address of tboot shared page
 060/010	ALL	ist_info	Intel SpeedStep (IST) BIOS support information
 				(struct ist_info)
Index: linux-2.6/arch/x86/boot/compressed/misc.c
===================================================================
--- linux-2.6.orig/arch/x86/boot/compressed/misc.c
+++ linux-2.6/arch/x86/boot/compressed/misc.c
@@ -125,6 +125,11 @@ static void error(char *m);
  */
 static struct boot_params *real_mode;		/* Pointer to real-mode data */
 static int quiet;
+static int early_serial_base;
+
+#define XMTRDY          0x20
+#define TXR             0       /*  Transmit register (WRITE) */
+#define LSR             5       /*  Line Status               */
 
 void *memset(void *s, int c, size_t n);
 void *memcpy(void *dest, const void *src, size_t n);
@@ -170,6 +175,16 @@ static void scroll(void)
 		vidmem[i] = ' ';
 }
 
+static void serial_putchar(int ch)
+{
+	unsigned timeout = 0xffff;
+
+	while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
+		cpu_relax();
+
+	outb(ch, early_serial_base + TXR);
+}
+
 static void __putstr(int error, const char *s)
 {
 	int x, y, pos;
@@ -179,6 +194,14 @@ static void __putstr(int error, const ch
 	if (!error)
 		return;
 #endif
+	if (early_serial_base) {
+		const char *str = s;
+		while (*str) {
+			if (*str == '\n')
+				serial_putchar('\r');
+			serial_putchar(*str++);
+		}
+	}
 
 	if (real_mode->screen_info.orig_video_mode == 0 &&
 	    lines == 0 && cols == 0)
@@ -319,6 +342,8 @@ asmlinkage void decompress_kernel(void *
 	lines = real_mode->screen_info.orig_video_lines;
 	cols = real_mode->screen_info.orig_video_cols;
 
+	early_serial_base = real_mode->serial_console_port_base;
+
 	free_mem_ptr     = heap;	/* Heap */
 	free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
 
Index: linux-2.6/arch/x86/boot/tty.c
===================================================================
--- linux-2.6.orig/arch/x86/boot/tty.c
+++ linux-2.6/arch/x86/boot/tty.c
@@ -266,8 +266,13 @@ static void parse_console_uart8250(void)
 
 void console_init(void)
 {
-	parse_earlyprintk();
+	early_serial_base = boot_params.serial_console_port_base;
+
+	if (!early_serial_base)
+		parse_earlyprintk();
 
 	if (!early_serial_base)
 		parse_console_uart8250();
+
+	boot_params.serial_console_port_base = early_serial_base;
 }
Index: linux-2.6/arch/x86/include/asm/bootparam.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/bootparam.h
+++ linux-2.6/arch/x86/include/asm/bootparam.h
@@ -93,7 +93,8 @@ struct efi_info {
 struct boot_params {
 	struct screen_info screen_info;			/* 0x000 */
 	struct apm_bios_info apm_bios_info;		/* 0x040 */
-	__u8  _pad2[4];					/* 0x054 */
+	__u16  serial_console_port_base;		/* 0x054 */
+	__u8  _pad2[2];					/* 0x056 */
 	__u64  tboot_addr;				/* 0x058 */
 	struct ist_info ist_info;			/* 0x060 */
 	__u8  _pad3[16];				/* 0x070 */

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-08-03  2:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-15 22:27 [PATCH] x86,setup: add serial_console_port_base in boot_params Yinghai Lu
2010-07-16  0:12 ` H. Peter Anvin
2010-07-16  1:30   ` Yinghai Lu
2010-07-31  8:34 ` Cyrill Gorcunov
2010-07-31 18:21   ` H. Peter Anvin
2010-07-31 18:32     ` Cyrill Gorcunov
2010-07-31 21:02       ` H. Peter Anvin
2010-07-31 21:31         ` Cyrill Gorcunov
2010-08-01  1:53         ` Yinghai Lu
2010-08-01  2:42           ` Eric W. Biederman
2010-08-01  5:20             ` Yinghai Lu
2010-08-03  2:03               ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox