SYSLOG: Now a two phase initialization. Some SYSLOG channels cannot be initialized until later in the bringup

This commit is contained in:
Gregory Nutt 2016-06-21 07:52:24 -06:00
parent 5385266756
commit 62d8f839c7
13 changed files with 85 additions and 37 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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)
if (phase == SYSLOG_INIT_LATE)
{
/* Enable use of a character device as the SYSLOG device */
ret = syslog_dev_channel();
}
#elif defined(CONFIG_RAMLOG_SYSLOG)
if (phase == SYSLOG_INIT_EARLY)
{
/* Use the RAMLOG as the SYSLOG device */
ret = ramlog_syslog_channel();
}
#elif defined(CONFIG_DEV_CONSOLE)
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;
}
#endif

View File

@ -335,6 +335,7 @@ int syslog_flush_intbuffer(FAR const struct syslog_channel_s *channel,
}
while (ch != EOF && ret >= 0);
sched_unlock();
return ret;
}

View File

@ -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
/****************************************************************************

View File

@ -54,6 +54,7 @@
#include <nuttx/mm/shm.h>
#include <nuttx/kmalloc.h>
#include <nuttx/sched_note.h>
#include <nuttx/syslog/syslog.h>
#include <nuttx/init.h>
#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 *********************************************************/