Add logic so that a RAM log can be used in place of a console device

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4380 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-02-11 03:50:52 +00:00
parent ddd6b7d383
commit f03655f43a
85 changed files with 732 additions and 380 deletions
+27 -19
View File
@@ -56,7 +56,7 @@
#include <nuttx/kmalloc.h>
#include <nuttx/fs.h>
#include <nuttx/arch.h>
//#include <nuttx/ramlog.h>
#include <nuttx/ramlog.h>
#include <arch/irq.h>
@@ -65,23 +65,6 @@
/****************************************************************************
* Private Types
****************************************************************************/
/* Configuration ************************************************************/
/* CONFIG_RAMLOG - Enables the RAM logging feature
* CONFIG_RAMLOG_CONSOLE - Use the RAM logging device as a system console.
* CONFIG_RAMLOG_SYSLOG - Use the RAM logging device for the syslogging
* interface. This should have:
* CONFIG_SYSLOG=ramlog
* CONFIG_RAMLOG_NPOLLWAITERS - The number of threads than can be waiting
* for this driver on poll(). Default: 4
*/
#ifndef CONFIG_RAMLOG_NPOLLWAITERS
# define CONFIG_RAMLOG_NPOLLWAITERS 4
#endif
#ifndef CONFIG_SYSLOG
# undef CONFIG_RAMLOG_SYSLOG
#endif
/****************************************************************************
* Private Types
@@ -91,7 +74,7 @@ struct ramlog_dev_s
{
volatile uint8_t rl_nwaiters; /* Number of threads waiting for data */
volatile uint16_t rl_head; /* The head index (where data is added) */
volatile uint16_t rl_tail; /* The tail index (where data is remove) */
volatile uint16_t rl_tail; /* The tail index (where data is removed) */
sem_t rl_exclsem; /* Enforces mutually exclusive access */
sem_t rl_waitsem; /* Used to wait for data */
size_t rl_bufsize; /* Size of the RAM buffer */
@@ -135,6 +118,12 @@ static const struct file_operations g_ramlogfops =
#endif
};
/* This is the pre-allocated buffer used for the console RAM log */
#ifdef CONFIG_RAMLOG_CONSOLE
static char g_consoleramlog[CONFIG_RAMLOG_CONSOLE_BUFSIZE];
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -570,6 +559,25 @@ int ramlog_register(FAR const char *devpath, FAR char *buffer, size_t buflen)
return ret;
}
/****************************************************************************
* Name: ramlog_consoleinit
*
* Description:
* Create the RAM logging device and register it at the specified path.
* Mostly likely this path will be /dev/console
*
****************************************************************************/
#ifdef CONFIG_RAMLOG_CONSOLE
int ramlog_consoleinit(void)
{
/* Register a RAM log as the console device */
return ramlog_register("/dev/console", g_consoleramlog,
CONFIG_RAMLOG_CONSOLE_BUFSIZE);
}
#endif
/****************************************************************************
* Name: ramlog
*