diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index a58e2a9ddd..6e67239c80 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -246,9 +246,12 @@ void up_initialize(void) up_rnginitialize(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index 5a650957b8..d17ea35808 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -258,9 +258,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index dfa15d6872..44f05aff49 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -184,9 +184,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index 927bd5fcef..16b842099e 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -186,9 +186,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/sh/src/common/up_initialize.c b/arch/sh/src/common/up_initialize.c index bdacd41ba9..ab17338af2 100644 --- a/arch/sh/src/common/up_initialize.c +++ b/arch/sh/src/common/up_initialize.c @@ -178,9 +178,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index 445012443e..a4551745ca 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -168,9 +168,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #if defined(CONFIG_FS_FAT) && !defined(CONFIG_DISABLE_MOUNTPOINT) up_registerblockdevice(); /* Our FAT ramdisk at /dev/ram0 */ diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index 9e0c1ad1c2..7c9078dd5d 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -186,9 +186,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index efdf975d52..35d93f2594 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -186,9 +186,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on only minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index c1a2137a72..5c64a576e9 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -183,9 +183,12 @@ void up_initialize(void) ramlog_consoleinit(); #endif - /* Initialize the system logging device */ + /* Early initialization of the system logging device. Some SYSLOG channel + * can be initialized early in the initialization sequence because they + * depend on minimal OS initialization. + */ - syslog_initialize(); + syslog_initialize(SYSLOG_INIT_EARLY); #ifndef CONFIG_NETDEV_LATEINIT /* Initialize the network */ diff --git a/drivers/syslog/syslog_initialize.c b/drivers/syslog/syslog_initialize.c index 9838737623..0cc7a0c688 100644 --- a/drivers/syslog/syslog_initialize.c +++ b/drivers/syslog/syslog_initialize.c @@ -70,7 +70,7 @@ * as a minimum a call to syslog_channel() to use the device. * * Input Parameters: - * None + * phase - One of {SYSLOG_INIT_EARLY, SYSLOG_INIT_LATE} * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on @@ -78,31 +78,33 @@ * ****************************************************************************/ -int syslog_initialize(void) +int syslog_initialize(enum syslog_init_e phase) { - int ret; - - /* Not much to this yet... more is coming */ + int ret = OK; #if defined(CONFIG_SYSLOG_CHAR) - /* Enable use of a character device as the SYSLOG device */ + if (phase == SYSLOG_INIT_LATE) + { + /* Enable use of a character device as the SYSLOG device */ - ret = syslog_dev_channel(); + ret = syslog_dev_channel(); + } #elif defined(CONFIG_RAMLOG_SYSLOG) - /* Use the RAMLOG as the SYSLOG device */ + if (phase == SYSLOG_INIT_EARLY) + { + /* Use the RAMLOG as the SYSLOG device */ - ret = ramlog_syslog_channel(); + ret = ramlog_syslog_channel(); + } #elif defined(CONFIG_DEV_CONSOLE) - /* Use the console device as the SYSLOG device */ + if (phase == SYSLOG_INIT_LATE) + { + /* Use the console device as the SYSLOG device */ - ret = syslog_console_channel(); - -#else - /* Nothing needs to be done */ - - ret = 0; + ret = syslog_console_channel(); + } #endif diff --git a/drivers/syslog/syslog_intbuffer.c b/drivers/syslog/syslog_intbuffer.c index 8cbda40edf..d7c5674d60 100644 --- a/drivers/syslog/syslog_intbuffer.c +++ b/drivers/syslog/syslog_intbuffer.c @@ -335,6 +335,7 @@ int syslog_flush_intbuffer(FAR const struct syslog_channel_s *channel, } while (ch != EOF && ret >= 0); + sched_unlock(); return ret; } diff --git a/include/nuttx/syslog/syslog.h b/include/nuttx/syslog/syslog.h index c897a34801..255a6e2f3a 100644 --- a/include/nuttx/syslog/syslog.h +++ b/include/nuttx/syslog/syslog.h @@ -93,6 +93,15 @@ * Public Types ****************************************************************************/ +/* Initialization phases */ + +enum syslog_init_e +{ + SYSLOG_INIT_RESET = 0, /* Power on SYSLOG initializaton phase */ + SYSLOG_INIT_EARLY, /* Early initialization in up_initialize() */ + SYSLOG_INIT_LATE /* Late initialization in os_start(). */ +}; + /* This structure provides the interface to a SYSLOG device */ typedef CODE int (*syslog_putc_t)(int ch); @@ -180,9 +189,9 @@ int syslog_channel(FAR const struct syslog_channel_s *channel); ****************************************************************************/ #ifndef CONFIG_ARCH_SYSLOG -int syslog_initialize(void); +int syslog_initialize(enum syslog_init_e phase); #else -# define syslog_initialize() +# define syslog_initialize(phase) #endif /**************************************************************************** diff --git a/sched/init/os_start.c b/sched/init/os_start.c index 732b10f578..1a65af1403 100644 --- a/sched/init/os_start.c +++ b/sched/init/os_start.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include "sched/sched.h" @@ -757,7 +758,15 @@ void os_start(void) DEBUGVERIFY(group_initialize(&g_idletcb[cpu])); g_idletcb[cpu].cmn.group->tg_flags = GROUP_FLAG_NOCLDWAIT; #endif -} + } + + /* Start SYSLOG ***********************************************************/ + /* Late initialization of the system logging device. Some SYSLOG channel + * must be initialized late in the initialization sequence because it may + * depend on having IDLE task file structures setup. + */ + + syslog_initialize(SYSLOG_INIT_LATE); #ifdef CONFIG_SMP /* Start all CPUs *********************************************************/