[U-Boot] [RFC][PATCH] Pre-console buffer

Wolfgang Denk wd at denx.de
Sat Aug 27 15:48:01 CEST 2011


Dear Graeme Russ,

In message <1314449645-16900-1-git-send-email-graeme.russ at gmail.com> you wrote:
> This cropped up as an aside to another thread so I thought I would give
> it a go. It's pretty rough-and-ready but it does the trick :)

Hm....the problem is that we need some buffer to store the data.  On
some systems this may work, but on many (most?) it doesnt.

> diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h
> index 2902e61..4ebc5bd 100644
> --- a/arch/x86/include/asm/global_data.h
> +++ b/arch/x86/include/asm/global_data.h
> @@ -44,6 +44,7 @@ typedef	struct global_data {
>  	unsigned long	env_addr;	/* Address  of Environment struct */
>  	unsigned long	cpu_clk;	/* CPU clock in Hz!		*/
>  	unsigned long	bus_clk;
> +	unsigned long	con_buf_idx;	/* Console buffer index */
>  	unsigned long	relocaddr;	/* Start address of U-Boot in RAM */
>  	unsigned long	start_addr_sp;	/* start_addr_stackpointer */
>  	phys_size_t	ram_size;	/* RAM size */
> @@ -65,13 +66,14 @@ extern gd_t *gd;
>  #define GD_ENV_ADDR		5
>  #define GD_CPU_CLK		6
>  #define GD_BUS_CLK		7
> -#define GD_RELOC_ADDR		8
> -#define GD_START_ADDR_SP	9
> -#define GD_RAM_SIZE		10
> -#define GD_RESET_STATUS		11
> -#define GD_JT			12
> +#define GD_CON_BUF_IDX		8
> +#define GD_RELOC_ADDR		9
> +#define GD_START_ADDR_SP	10
> +#define GD_RAM_SIZE		11
> +#define GD_RESET_STATUS		12
> +#define GD_JT			13
> 
> -#define GD_SIZE			13
> +#define GD_SIZE			14

Argh... your whole "Word Offsets into Global Data" needs to be
removed.  This should be auto-generated as asm-offsets.

> --- a/common/console.c
> +++ b/common/console.c
> @@ -323,6 +323,28 @@ int tstc(void)
>  	return serial_tstc();
>  }

Hm... this adds a lot of code, unconditionally.  In thos form this is
not acceptable, especially as many boards cannot make use of this, or
eventually don't want to make use of it.

> +	if (gd->flags & GD_FLG_HAVE_CONSOLE) {
> +		if (gd->flags & GD_FLG_DEVINIT) {
> +			/* Send to the standard output */
> +			fputc(stdout, c);
> +		} else {
> +			/* Send directly to the handler */
> +			serial_putc(c);
> +		}
>  	} else {
> -		/* Send directly to the handler */
> -		serial_putc(c);
> +		pre_console_putc(c);
>  	}
>  }

And this is actually wrong.  If we can use the serial console for
output, we definitely don;t want to use your buffer any more.

> diff --git a/include/configs/eNET.h b/include/configs/eNET.h
> index 548d52c..4fb971f 100644
> --- a/include/configs/eNET.h
> +++ b/include/configs/eNET.h

...and compilation for all other boards breaks?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A bore is someone who persists in holding his own views after we have
enlightened him with ours.


More information about the U-Boot mailing list