public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] pritnf() in arch_cpu_init()
Date: Mon, 18 May 2015 10:41:17 +0000	[thread overview]
Message-ID: <1431945677.4238.20.camel@synopsys.com> (raw)

Hi Simon,

I was looking at how to output error message from very early init and
found IMHO senseless code in "arch/x86/cpu/coreboot/coreboot.c":
---------------->8------------------
int arch_cpu_init(void)
{
	int ret = get_coreboot_info(&lib_sysinfo);
	if (ret != 0) {
		printf("Failed to parse coreboot tables.\n");
		return ret;
	}
---------------->8------------------

The problem here is arch_cpu_init() executed much earlier compared to
serial/console init, refer to "init_sequence_f":
---------------->8------------------
line 764:	arch_cpu_init,
...
line 807:	serial_init,	/* serial communications setup */
		console_init_f,	/* stage 1 init of console */
---------------->8------------------

So printf() output is only available in pre-console buffer if
CONFIG_PRE_CONSOLE_BUFFER is configured. Otherwise CPU will end up in
halt before anything gets printed to console.

I would propose to create a special very-early flavour of printf() which
is only built if pre-console buffer is configured. That way we:

 [1] By default get rid of printf() in early CPU init code that might as
well be used in SPL build (so there will be no extra dependency on
pritnf/console)

 [2] Save some space in memory footprint with removal of the string.

I'm pretty sure there're more places when printf() is used before
console gets initialized but let's first discuss it with this particular
example.

-Alexey

             reply	other threads:[~2015-05-18 10:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 10:41 Alexey Brodkin [this message]
2015-05-18 20:46 ` [U-Boot] pritnf() in arch_cpu_init() Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431945677.4238.20.camel@synopsys.com \
    --to=alexey.brodkin@synopsys.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox