diff mbox

[U-Boot,V5] console: Implement pre-console buffer

Message ID 1314874326-10231-1-git-send-email-graeme.russ@gmail.com
State Accepted
Delegated to: Wolfgang Denk
Headers show

Commit Message

Graeme Russ Sept. 1, 2011, 10:52 a.m. UTC
Allow redirection of console output prior to console initialisation to a
temporary buffer.

To enable this functionality, the board (or arch) must define:
 - CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
 - CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
 - CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)

The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
Any earlier characters are silently dropped.

Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
---
Grrrr - Repost of V5 with an SoB. There has to be a better way of
automating patch updates ;)

Changes since V4
 - Fixed typo in README
 - Made *pre_console* functions in console.c static
 - Slight tweak to commit message - Some may choose to set the
   configuration defines at the arch level

Changes since V3
 - Fixed  blank subject caused by gap between the Cc: list and Date:

Changes since V2
 - Cast buffer size to unsigned long to help compilers produce tighter
   code
 - Use inline stub functions to reduce #ifdef clutter
 - Add documentation to README

Changes Since V1
 - Implemented circular buffer
 - Trivial code styl corrections

---
 README                                    |   14 +++++++++
 arch/arm/include/asm/global_data.h        |    3 ++
 arch/avr32/include/asm/global_data.h      |    3 ++
 arch/blackfin/include/asm/global_data.h   |    3 ++
 arch/m68k/include/asm/global_data.h       |    3 ++
 arch/microblaze/include/asm/global_data.h |    3 ++
 arch/mips/include/asm/global_data.h       |    3 ++
 arch/nios2/include/asm/global_data.h      |    3 ++
 arch/powerpc/include/asm/global_data.h    |    3 ++
 arch/sh/include/asm/global_data.h         |    3 ++
 arch/sparc/include/asm/global_data.h      |    3 ++
 arch/x86/include/asm/global_data.h        |    3 ++
 common/console.c                          |   43 +++++++++++++++++++++++++++-
 13 files changed, 88 insertions(+), 2 deletions(-)

--
1.7.5.2.317.g391b14

Comments

Mike Frysinger Sept. 1, 2011, 2:02 p.m. UTC | #1
On Thursday, September 01, 2011 06:52:06 Graeme Russ wrote:
> Grrrr - Repost of V5 with an SoB. There has to be a better way of
> automating patch updates ;)

`git commit --amend` ?  s-o-b tag should be in the changelog and thus not get 
lost during the normal run of things ...
-mike
Simon Glass Sept. 1, 2011, 6:51 p.m. UTC | #2
Hi Graeme,

On Thu, Sep 1, 2011 at 7:02 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Thursday, September 01, 2011 06:52:06 Graeme Russ wrote:
>> Grrrr - Repost of V5 with an SoB. There has to be a better way of
>> automating patch updates ;)
>
> `git commit --amend` ?  s-o-b tag should be in the changelog and thus not get
> lost during the normal run of things ...
> -mike
>

I have a script(TM) which pulls the versions, cover letter, to- and
cc- addresses from the commits. It also runs them through
checkpatch.pl and does its own checks. It makes adding a new version
easier because you just have to update 'Series-version: 2' to
'Series-version: 3' for example. It also collects the change lists
from the various commits and puts them in the cover letter and emails
them out. It's not really U-Boot specific, but it does take a monkey
work out of sending out U-Boot patches.

Perhaps it would help?

Regards,
Simon
Graeme Russ Sept. 1, 2011, 11:34 p.m. UTC | #3
Hi Simon,

On Fri, Sep 2, 2011 at 4:51 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Graeme,
>
> On Thu, Sep 1, 2011 at 7:02 AM, Mike Frysinger <vapier@gentoo.org> wrote:
>> On Thursday, September 01, 2011 06:52:06 Graeme Russ wrote:
>>> Grrrr - Repost of V5 with an SoB. There has to be a better way of
>>> automating patch updates ;)
>>
>> `git commit --amend` ?  s-o-b tag should be in the changelog and thus not get
>> lost during the normal run of things ...
>> -mike
>>
>
> I have a script(TM) which pulls the versions, cover letter, to- and
> cc- addresses from the commits. It also runs them through
> checkpatch.pl and does its own checks. It makes adding a new version
> easier because you just have to update 'Series-version: 2' to
> 'Series-version: 3' for example. It also collects the change lists
> from the various commits and puts them in the cover letter and emails
> them out. It's not really U-Boot specific, but it does take a monkey
> work out of sending out U-Boot patches.
>
> Perhaps it would help?

Could you send it through please?

It would be neat if we could grab the Message-ID from get-send-email
and track so that In-Replt-To: can be automatically set for the next
version

Regards,

Graeme
Mike Frysinger Sept. 2, 2011, 2:41 a.m. UTC | #4
On Thursday, September 01, 2011 19:34:51 Graeme Russ wrote:
> It would be neat if we could grab the Message-ID from get-send-email
> and track so that In-Replt-To: can be automatically set for the next
> version

ive always just viewed the raw e-mail (in kmail, just hit "v" to view 
everything) and copied & pasted it into git send-email.

but a script that would connect to gmane's nntp interface, fetch the headers, 
and then auto d/l the relevant thread and extract the message id would be 
pretty cool.
-mike
Simon Glass Sept. 2, 2011, 2:58 a.m. UTC | #5
Hi Graeme,

On Thu, Sep 1, 2011 at 4:34 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
> Hi Simon,
>
> On Fri, Sep 2, 2011 at 4:51 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Graeme,
>>
>> On Thu, Sep 1, 2011 at 7:02 AM, Mike Frysinger <vapier@gentoo.org> wrote:
>>> On Thursday, September 01, 2011 06:52:06 Graeme Russ wrote:
>>>> Grrrr - Repost of V5 with an SoB. There has to be a better way of
>>>> automating patch updates ;)
>>>
>>> `git commit --amend` ?  s-o-b tag should be in the changelog and thus not get
>>> lost during the normal run of things ...
>>> -mike
>>>
>>
>> I have a script(TM) which pulls the versions, cover letter, to- and
>> cc- addresses from the commits. It also runs them through
>> checkpatch.pl and does its own checks. It makes adding a new version
>> easier because you just have to update 'Series-version: 2' to
>> 'Series-version: 3' for example. It also collects the change lists
>> from the various commits and puts them in the cover letter and emails
>> them out. It's not really U-Boot specific, but it does take a monkey
>> work out of sending out U-Boot patches.
>>
>> Perhaps it would help?
>
> Could you send it through please?

Yes will put it in the queue behind the sandbox patches. It needs a
little clean up. Should I do it as a patch against the tools
directory?

>
> It would be neat if we could grab the Message-ID from get-send-email
> and track so that In-Replt-To: can be automatically set for the next
> version

Should be possible although I haven't anything like that. I do have a
library which filters terminal output as it displays it though, which
might suit for watching git send-email.

Regards,
Simon

>
> Regards,
>
> Graeme
>
Simon Glass Sept. 21, 2011, 11:18 p.m. UTC | #6
Hi Graeme,

On Thu, Sep 1, 2011 at 3:52 AM, Graeme Russ <graeme.russ@gmail.com> wrote:
> Allow redirection of console output prior to console initialisation to a
> temporary buffer.
>
> To enable this functionality, the board (or arch) must define:
>  - CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
>  - CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
>  - CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)
>
> The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
> Any earlier characters are silently dropped.
>
> Signed-off-by: Graeme Russ <graeme.russ@gmail.com>

I tested this on a Tegra2 Seaboard.

Tested-by: Simon Glass <sjg@chromium.org>

Regards,
Simon

> ---
> Grrrr - Repost of V5 with an SoB. There has to be a better way of
> automating patch updates ;)
>
> Changes since V4
>  - Fixed typo in README
>  - Made *pre_console* functions in console.c static
>  - Slight tweak to commit message - Some may choose to set the
>   configuration defines at the arch level
>
> Changes since V3
>  - Fixed  blank subject caused by gap between the Cc: list and Date:
>
> Changes since V2
>  - Cast buffer size to unsigned long to help compilers produce tighter
>   code
>  - Use inline stub functions to reduce #ifdef clutter
>  - Add documentation to README
>
> Changes Since V1
>  - Implemented circular buffer
>  - Trivial code styl corrections
>
> ---
>  README                                    |   14 +++++++++
>  arch/arm/include/asm/global_data.h        |    3 ++
>  arch/avr32/include/asm/global_data.h      |    3 ++
>  arch/blackfin/include/asm/global_data.h   |    3 ++
>  arch/m68k/include/asm/global_data.h       |    3 ++
>  arch/microblaze/include/asm/global_data.h |    3 ++
>  arch/mips/include/asm/global_data.h       |    3 ++
>  arch/nios2/include/asm/global_data.h      |    3 ++
>  arch/powerpc/include/asm/global_data.h    |    3 ++
>  arch/sh/include/asm/global_data.h         |    3 ++
>  arch/sparc/include/asm/global_data.h      |    3 ++
>  arch/x86/include/asm/global_data.h        |    3 ++
>  common/console.c                          |   43 +++++++++++++++++++++++++++-
>  13 files changed, 88 insertions(+), 2 deletions(-)
>
> diff --git a/README b/README
> index 0886987..cf6c01f 100644
[snip]
Simon Glass Oct. 4, 2011, 5:30 a.m. UTC | #7
Hi Graeme,

On Wed, Sep 21, 2011 at 4:18 PM, Simon Glass <sjg@chromium.org> wrote:

> Hi Graeme,
>
> On Thu, Sep 1, 2011 at 3:52 AM, Graeme Russ <graeme.russ@gmail.com> wrote:
> > Allow redirection of console output prior to console initialisation to a
> > temporary buffer.
> >
> > To enable this functionality, the board (or arch) must define:
> >  - CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
> >  - CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
> >  - CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)
> >
> > The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
> > Any earlier characters are silently dropped.
> >
> > Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
>
> I tested this on a Tegra2 Seaboard.
>
> Tested-by: Simon Glass <sjg@chromium.org>
>

Further to this, I pushed it a little further and managed to get early
console output from the AVP (an ARM7) before the Cortex-A9s are fired up on
a Tegra20/30. That's pretty early!

This is a great patch and very useful for early bring-up I think. I hope it
will be merged this window. Any other comments?

Regards,
Simon


>
> Regards,
> Simon
>
> > ---
> > Grrrr - Repost of V5 with an SoB. There has to be a better way of
> > automating patch updates ;)
> >
> > Changes since V4
> >  - Fixed typo in README
> >  - Made *pre_console* functions in console.c static
> >  - Slight tweak to commit message - Some may choose to set the
> >   configuration defines at the arch level
> >
> > Changes since V3
> >  - Fixed  blank subject caused by gap between the Cc: list and Date:
> >
> > Changes since V2
> >  - Cast buffer size to unsigned long to help compilers produce tighter
> >   code
> >  - Use inline stub functions to reduce #ifdef clutter
> >  - Add documentation to README
> >
> > Changes Since V1
> >  - Implemented circular buffer
> >  - Trivial code styl corrections
> >
> > ---
> >  README                                    |   14 +++++++++
> >  arch/arm/include/asm/global_data.h        |    3 ++
> >  arch/avr32/include/asm/global_data.h      |    3 ++
> >  arch/blackfin/include/asm/global_data.h   |    3 ++
> >  arch/m68k/include/asm/global_data.h       |    3 ++
> >  arch/microblaze/include/asm/global_data.h |    3 ++
> >  arch/mips/include/asm/global_data.h       |    3 ++
> >  arch/nios2/include/asm/global_data.h      |    3 ++
> >  arch/powerpc/include/asm/global_data.h    |    3 ++
> >  arch/sh/include/asm/global_data.h         |    3 ++
> >  arch/sparc/include/asm/global_data.h      |    3 ++
> >  arch/x86/include/asm/global_data.h        |    3 ++
> >  common/console.c                          |   43
> +++++++++++++++++++++++++++-
> >  13 files changed, 88 insertions(+), 2 deletions(-)
> >
> > diff --git a/README b/README
> > index 0886987..cf6c01f 100644
> [snip]
>
Wolfgang Denk Oct. 5, 2011, 6:50 p.m. UTC | #8
Dear Graeme Russ,

In message <1314874326-10231-1-git-send-email-graeme.russ@gmail.com> you wrote:
> Allow redirection of console output prior to console initialisation to a
> temporary buffer.
> 
> To enable this functionality, the board (or arch) must define:
>  - CONFIG_PRE_CONSOLE_BUFFER - Enable pre-console buffer
>  - CONFIG_PRE_CON_BUF_ADDR - Base address of pre-console buffer
>  - CONFIG_PRE_CON_BUF_SZ - Size of pre-console buffer (in bytes)
> 
> The pre-console buffer will buffer the last CONFIG_PRE_CON_BUF_SZ bytes
> Any earlier characters are silently dropped.
> 
> Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
> ---
> Grrrr - Repost of V5 with an SoB. There has to be a better way of
> automating patch updates ;)
> 
> Changes since V4
>  - Fixed typo in README
>  - Made *pre_console* functions in console.c static
>  - Slight tweak to commit message - Some may choose to set the
>    configuration defines at the arch level
> 
> Changes since V3
>  - Fixed  blank subject caused by gap between the Cc: list and Date:
> 
> Changes since V2
>  - Cast buffer size to unsigned long to help compilers produce tighter
>    code
>  - Use inline stub functions to reduce #ifdef clutter
>  - Add documentation to README
> 
> Changes Since V1
>  - Implemented circular buffer
>  - Trivial code styl corrections
> 
> ---
>  README                                    |   14 +++++++++
>  arch/arm/include/asm/global_data.h        |    3 ++
>  arch/avr32/include/asm/global_data.h      |    3 ++
>  arch/blackfin/include/asm/global_data.h   |    3 ++
>  arch/m68k/include/asm/global_data.h       |    3 ++
>  arch/microblaze/include/asm/global_data.h |    3 ++
>  arch/mips/include/asm/global_data.h       |    3 ++
>  arch/nios2/include/asm/global_data.h      |    3 ++
>  arch/powerpc/include/asm/global_data.h    |    3 ++
>  arch/sh/include/asm/global_data.h         |    3 ++
>  arch/sparc/include/asm/global_data.h      |    3 ++
>  arch/x86/include/asm/global_data.h        |    3 ++
>  common/console.c                          |   43 +++++++++++++++++++++++++++-
>  13 files changed, 88 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/README b/README
index 0886987..cf6c01f 100644
--- a/README
+++ b/README
@@ -619,6 +619,20 @@  The following options need to be configured:
 		must be defined, to setup the maximum idle timeout for
 		the SMC.

+- Pre-Console Buffer:
+                Prior to the console being initialised (i.e. serial UART
+                initialised etc) all console output is silently discarded.
+                Defining CONFIG_PRE_CONSOLE_BUFFER will cause U-Boot to
+                buffer any console messages prior to the console being
+                initialised to a buffer of size CONFIG_PRE_CON_BUF_SZ
+                bytes located at CONFIG_PRE_CON_BUF_ADDR. The buffer is
+                a circular buffer, so if more than CONFIG_PRE_CON_BUF_SZ
+                bytes are output before the console is  initialised, the
+                earlier bytes are discarded.
+
+                'Sane' compilers will generate smaller code if
+                CONFIG_PRE_CON_BUF_SZ is a power of 2
+
 - Boot Delay:	CONFIG_BOOTDELAY - in seconds
 		Delay before automatically booting the default image;
 		set to -1 to disable autoboot.
diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index 4fc51fd..b85b7fe 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -38,6 +38,9 @@  typedef	struct	global_data {
 	unsigned long	flags;
 	unsigned long	baudrate;
 	unsigned long	have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 	unsigned long	env_addr;	/* Address  of Environment struct */
 	unsigned long	env_valid;	/* Checksum of Environment valid? */
 	unsigned long	fb_base;	/* base address of frame buffer */
diff --git a/arch/avr32/include/asm/global_data.h b/arch/avr32/include/asm/global_data.h
index 4ef8fc5..5c654bd 100644
--- a/arch/avr32/include/asm/global_data.h
+++ b/arch/avr32/include/asm/global_data.h
@@ -38,6 +38,9 @@  typedef	struct	global_data {
 	unsigned long	baudrate;
 	unsigned long	stack_end;	/* highest stack address */
 	unsigned long	have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 	unsigned long	reloc_off;	/* Relocation Offset */
 	unsigned long	env_addr;	/* Address of env struct */
 	unsigned long	env_valid;	/* Checksum of env valid? */
diff --git a/arch/blackfin/include/asm/global_data.h b/arch/blackfin/include/asm/global_data.h
index eba5e93..f7aa711 100644
--- a/arch/blackfin/include/asm/global_data.h
+++ b/arch/blackfin/include/asm/global_data.h
@@ -45,6 +45,9 @@  typedef struct global_data {
 	unsigned long board_type;
 	unsigned long baudrate;
 	unsigned long have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 	phys_size_t ram_size;		/* RAM size */
 	unsigned long env_addr;	/* Address  of Environment struct */
 	unsigned long env_valid;	/* Checksum of Environment valid? */
diff --git a/arch/m68k/include/asm/global_data.h b/arch/m68k/include/asm/global_data.h
index fc486fd..0ba2b43 100644
--- a/arch/m68k/include/asm/global_data.h
+++ b/arch/m68k/include/asm/global_data.h
@@ -57,6 +57,9 @@  typedef	struct	global_data {
 	unsigned long	env_addr;	/* Address  of Environment struct	*/
 	unsigned long	env_valid;	/* Checksum of Environment valid?	*/
 	unsigned long	have_console;	/* serial_init() was called		*/
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
 	unsigned long	fb_base;	/* Base addr of framebuffer memory */
 #endif
diff --git a/arch/microblaze/include/asm/global_data.h b/arch/microblaze/include/asm/global_data.h
index 557ad27..6e8537c 100644
--- a/arch/microblaze/include/asm/global_data.h
+++ b/arch/microblaze/include/asm/global_data.h
@@ -39,6 +39,9 @@  typedef	struct	global_data {
 	unsigned long	flags;
 	unsigned long	baudrate;
 	unsigned long	have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 	unsigned long	env_addr;	/* Address  of Environment struct */
 	unsigned long	env_valid;	/* Checksum of Environment valid? */
 	unsigned long	fb_base;	/* base address of frame buffer */
diff --git a/arch/mips/include/asm/global_data.h b/arch/mips/include/asm/global_data.h
index 271a290..b193517 100644
--- a/arch/mips/include/asm/global_data.h
+++ b/arch/mips/include/asm/global_data.h
@@ -41,6 +41,9 @@  typedef	struct	global_data {
 	unsigned long	flags;
 	unsigned long	baudrate;
 	unsigned long	have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 	phys_size_t	ram_size;	/* RAM size */
 	unsigned long	reloc_off;	/* Relocation Offset */
 	unsigned long	env_addr;	/* Address  of Environment struct */
diff --git a/arch/nios2/include/asm/global_data.h b/arch/nios2/include/asm/global_data.h
index 2c4a719..d9f0664 100644
--- a/arch/nios2/include/asm/global_data.h
+++ b/arch/nios2/include/asm/global_data.h
@@ -29,6 +29,9 @@  typedef	struct	global_data {
 	unsigned long	baudrate;
 	unsigned long	cpu_clk;	/* CPU clock in Hz!		*/
 	unsigned long	have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 	phys_size_t	ram_size;	/* RAM size */
 	unsigned long	env_addr;	/* Address  of Environment struct */
 	unsigned long	env_valid;	/* Checksum of Environment valid */
diff --git a/arch/powerpc/include/asm/global_data.h b/arch/powerpc/include/asm/global_data.h
index a33ca2f..7fcaf38 100644
--- a/arch/powerpc/include/asm/global_data.h
+++ b/arch/powerpc/include/asm/global_data.h
@@ -138,6 +138,9 @@  typedef	struct	global_data {
 	unsigned long	env_addr;	/* Address  of Environment struct	*/
 	unsigned long	env_valid;	/* Checksum of Environment valid?	*/
 	unsigned long	have_console;	/* serial_init() was called		*/
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 #if defined(CONFIG_SYS_ALLOC_DPRAM) || defined(CONFIG_CPM2)
 	unsigned int	dp_alloc_base;
 	unsigned int	dp_alloc_top;
diff --git a/arch/sh/include/asm/global_data.h b/arch/sh/include/asm/global_data.h
index 0c09ba9..1b782fc 100644
--- a/arch/sh/include/asm/global_data.h
+++ b/arch/sh/include/asm/global_data.h
@@ -34,6 +34,9 @@  typedef	struct global_data
 	unsigned long	baudrate;
 	unsigned long	cpu_clk;	/* CPU clock in Hz! */
 	unsigned long	have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 	phys_size_t	ram_size;	/* RAM size */
 	unsigned long	env_addr;	/* Address  of Environment struct */
 	unsigned long	env_valid;	/* Checksum of Environment valid */
diff --git a/arch/sparc/include/asm/global_data.h b/arch/sparc/include/asm/global_data.h
index 9b14674..a1e4b44 100644
--- a/arch/sparc/include/asm/global_data.h
+++ b/arch/sparc/include/asm/global_data.h
@@ -53,6 +53,9 @@  typedef struct global_data {
 	unsigned long env_valid;	/* Checksum of Environment valid?       */
 	unsigned long have_console;	/* serial_init() was called */

+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
 	unsigned long fb_base;	/* Base address of framebuffer memory   */
 #endif
diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h
index f977dbe..6cf7955 100644
--- a/arch/x86/include/asm/global_data.h
+++ b/arch/x86/include/asm/global_data.h
@@ -40,6 +40,9 @@  typedef	struct global_data {
 	unsigned long	flags;
 	unsigned long	baudrate;
 	unsigned long	have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
 	unsigned long	reloc_off;	/* Relocation Offset */
 	unsigned long	load_off;	/* Load Offset */
 	unsigned long	env_addr;	/* Address  of Environment struct */
diff --git a/common/console.c b/common/console.c
index b23d933..f17875e 100644
--- a/common/console.c
+++ b/common/console.c
@@ -329,6 +329,39 @@  int tstc(void)
 	return serial_tstc();
 }

+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+#define CIRC_BUF_IDX(idx) ((idx) % (unsigned long)CONFIG_PRE_CON_BUF_SZ)
+
+static void pre_console_putc(const char c)
+{
+	char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR;
+
+	buffer[CIRC_BUF_IDX(gd->precon_buf_idx++)] = c;
+}
+
+static void pre_console_puts(const char *s)
+{
+	while (*s)
+		pre_console_putc(*s++);
+}
+
+static void print_pre_console_buffer(void)
+{
+	unsigned long i = 0;
+	char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR;
+
+	if (gd->precon_buf_idx > CONFIG_PRE_CON_BUF_SZ)
+		i = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ;
+
+	while (i < gd->precon_buf_idx)
+		putc(buffer[CIRC_BUF_IDX(i++)]);
+}
+#else
+static inline void pre_console_putc(const char c) {}
+static inline void pre_console_puts(const char *s) {}
+static inline void print_pre_console_buffer(void) {}
+#endif
+
 void putc(const char c)
 {
 #ifdef CONFIG_SILENT_CONSOLE
@@ -342,7 +375,7 @@  void putc(const char c)
 #endif

 	if (!gd->have_console)
-		return;
+		return pre_console_putc(c);

 	if (gd->flags & GD_FLG_DEVINIT) {
 		/* Send to the standard output */
@@ -366,7 +399,7 @@  void puts(const char *s)
 #endif

 	if (!gd->have_console)
-		return;
+		return pre_console_puts(s);

 	if (gd->flags & GD_FLG_DEVINIT) {
 		/* Send to the standard output */
@@ -383,8 +416,10 @@  int printf(const char *fmt, ...)
 	uint i;
 	char printbuffer[CONFIG_SYS_PBSIZE];

+#ifndef CONFIG_PRE_CONSOLE_BUFFER
 	if (!gd->have_console)
 		return 0;
+#endif

 	va_start(args, fmt);

@@ -404,8 +439,10 @@  int vprintf(const char *fmt, va_list args)
 	uint i;
 	char printbuffer[CONFIG_SYS_PBSIZE];

+#ifndef CONFIG_PRE_CONSOLE_BUFFER
 	if (!gd->have_console)
 		return 0;
+#endif

 	/* For this to work, printbuffer must be larger than
 	 * anything we ever want to print.
@@ -547,6 +584,8 @@  int console_init_f(void)
 		gd->flags |= GD_FLG_SILENT;
 #endif

+	print_pre_console_buffer();
+
 	return 0;
 }