Re: [PATCH 1/1] x86: Add config option to setup early serial console

Previous thread: [PATCH 1/1] x86: Add config option to setup early serial console by Mike Travis on Thursday, June 12, 2008 - 3:33 pm. (2 messages)

Next thread: [PATCH 1/1] x86: Add config option to setup early serial console by Mike Travis on Thursday, June 12, 2008 - 3:42 pm. (4 messages)
From: Mike Travis
Date: Thursday, June 12, 2008 - 3:38 pm

* Add config option EARLY_SERIAL_CONSOLE to enable early
   printk's to be directed to the serial console.

Based on linux-next

Signed-off-by: Mike Travis <travis@sgi.com>
---

---
 arch/x86/Kconfig.debug         |    9 +++++++++
 arch/x86/kernel/early_printk.c |    4 ++++
 2 files changed, 13 insertions(+)

--- linux-2.6-next.orig/arch/x86/Kconfig.debug
+++ linux-2.6-next/arch/x86/Kconfig.debug
@@ -29,6 +29,15 @@ config EARLY_PRINTK
 	  with klogd/syslogd or the X server. You should normally N here,
 	  unless you want to debug such a crash.
 
+config EARLY_SERIAL_CONSOLE
+	bool "Early Serial Console"
+	default m
+	help
+	  Initializes the early console to be the serial port.  The default
+	  is to use the VGA console.
+
+	  This is useful for server systems that do not have a VGA console.
+
 config DEBUG_STACKOVERFLOW
 	bool "Check for stack overflows"
 	depends on DEBUG_KERNEL
--- linux-2.6-next.orig/arch/x86/kernel/early_printk.c
+++ linux-2.6-next/arch/x86/kernel/early_printk.c
@@ -193,7 +193,11 @@ static struct console simnow_console = {
 };
 
 /* Direct interface for emergencies */
+#ifdef CONFIG_EARLY_SERIAL_CONSOLE
+static struct console *early_console = &early_serial_console;
+#else
 static struct console *early_console = &early_vga_console;
+#endif
 static int early_console_initialized;
 
 void early_printk(const char *fmt, ...)

-- 

--

From: Mike Travis
Date: Thursday, June 12, 2008 - 3:42 pm

Boy, this just isn't my day... Another typo slipped through...



--

From: H. Peter Anvin
Date: Thursday, June 12, 2008 - 3:42 pm

Is there any reason this can't be done dynamically, via a command-line 
option instead?

We can get to the command line extremely early if need be.

	-hpa
--

From: Mike Travis
Date: Thursday, June 12, 2008 - 3:54 pm

We could.  My current debugging is in x86_64_start_kernel() almost at
the start of the function (before the "Kernel alive" message).  The
code is below.  (cut and pasted so no tabs)

One benefit of a startup option instead of a config option  is we rely
on the standard distribution for the kernel and unless they set this
option it won't do us much good.

(Maybe the failed attempts was trying to tell me something? ;-)

Thanks,
Mike

        /* Cleanup the over mapped high alias */
        cleanup_highmap();

... my debugging is here ...

        for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) {
#ifdef CONFIG_EARLY_PRINTK
                set_intr_gate(i, &early_idt_handlers[i]);
#else
                set_intr_gate(i, early_idt_handler);
#endif
        }
        load_idt((const struct desc_ptr *)&idt_descr);

        early_printk("Kernel alive\n");

        for (i = 0; i < NR_CPUS; i++)
                cpu_pda(i) = &boot_cpu_pda[i];

        pda_init(0);
        copy_bootdata(__va(real_mode_data));

... startup params available here ...

        reserve_early(__pa_symbol(&_text), __pa_symbol(&_end), "TEXT DATA BSS");

#ifdef CONFIG_BLK_DEV_INITRD
        /* Reserve INITRD */
        if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
                unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
                unsigned long ramdisk_size  = boot_params.hdr.ramdisk_size;
                unsigned long ramdisk_end   = ramdisk_image + ramdisk_size;
                reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
        }
#endif





--

From: H. Peter Anvin
Date: Thursday, June 12, 2008 - 3:59 pm

The easiest way to get to something extremely early is to parse it out 
already in the setup code and pass in a flag in struct boot_params. 
Otherwise, the kernel command line is present in memory and can be 
copied or parsed in an ad hoc manner.  For i386 it is copied in place 
already in the assembly code -- for x86-64 it looks like we could 
trivially move copy_bootdata until just past clear_bss().

	-hpa
--

From: Andrew Morton
Date: Thursday, June 12, 2008 - 3:46 pm

On Thu, 12 Jun 2008 15:38:03 -0700

Confused.  What's wrong with console=uart,...?


--

From: Mike Travis
Date: Thursday, June 12, 2008 - 3:58 pm

The problem is that I need the output really, really early before
the console is initialized.
--

From: Andrew Morton
Date: Thursday, June 12, 2008 - 4:10 pm

On Thu, 12 Jun 2008 15:58:08 -0700

Sorry, I meant earlycon=uart..
--

From: Yinghai Lu
Date: Thursday, June 12, 2008 - 4:18 pm

On Thu, Jun 12, 2008 at 4:10 PM, Andrew Morton

the same. it checks earlycon=uart and console=uart...

YH
--

From: Yinghai Lu
Date: Thursday, June 12, 2008 - 4:19 pm

On Thu, Jun 12, 2008 at 4:10 PM, Andrew Morton

could move the parsing from early_param to head_64.c::x86_64_start_kernel

YH
--

Previous thread: [PATCH 1/1] x86: Add config option to setup early serial console by Mike Travis on Thursday, June 12, 2008 - 3:33 pm. (2 messages)

Next thread: [PATCH 1/1] x86: Add config option to setup early serial console by Mike Travis on Thursday, June 12, 2008 - 3:42 pm. (4 messages)