misc/printk: Make the default char_out routine weak

Architecture init code and/or HAL layers often have a working
"putchar" routine available long before the Zephyr driver layer is
initialized.

Make the default printk() output a weak symbol, so it can be
overridden on these platforms.

Also remove the kconfig depedency on CONSOLE_HAS_DRIVER, as this is a
non-driver mechanism.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2018-08-19 10:58:06 -07:00 committed by Anas Nashif
parent c9a4058605
commit 923e1b60e7
2 changed files with 5 additions and 3 deletions

View File

@ -40,9 +40,12 @@ static void _printk_hex_ulong(out_func_t out, void *ctx,
* @brief Default character output routine that does nothing
* @param c Character to swallow
*
* Note this is defined as a weak symbol, allowing architecture code
* to override it where possible to enable very early logging.
*
* @return 0
*/
static int _nop_char_out(int c)
__attribute__((weak)) int z_arch_printk_char_out(int c)
{
ARG_UNUSED(c);
@ -50,7 +53,7 @@ static int _nop_char_out(int c)
return 0;
}
static int (*_char_out)(int) = _nop_char_out;
int (*_char_out)(int) = z_arch_printk_char_out;
/**
* @brief Install the character output routine for printk

View File

@ -104,7 +104,6 @@ config STACK_SENTINEL
config PRINTK
bool "Send printk() to console"
depends on CONSOLE_HAS_DRIVER
default y
help
This option directs printk() debugging output to the supported