diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-11 03:50:52 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-11 03:50:52 +0000 |
commit | 4a62de545bf87610c2415218e144ddef4dd0e75c (patch) | |
tree | 6c5b47ab79d40800d497f8a470aad5aa569ff9d6 /nuttx/drivers/ramlog.c | |
parent | 24af177eb1a3e7036f8a3ee5342970ddeb151124 (diff) | |
download | px4-nuttx-4a62de545bf87610c2415218e144ddef4dd0e75c.tar.gz px4-nuttx-4a62de545bf87610c2415218e144ddef4dd0e75c.tar.bz2 px4-nuttx-4a62de545bf87610c2415218e144ddef4dd0e75c.zip |
Add logic so that a RAM log can be used in place of a console device
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4380 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/ramlog.c')
-rw-r--r-- | nuttx/drivers/ramlog.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/nuttx/drivers/ramlog.c b/nuttx/drivers/ramlog.c index 79f57636c..741979e7f 100644 --- a/nuttx/drivers/ramlog.c +++ b/nuttx/drivers/ramlog.c @@ -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 ****************************************************************************/ @@ -571,6 +560,25 @@ int ramlog_register(FAR const char *devpath, FAR char *buffer, size_t buflen) } /**************************************************************************** + * 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 * * Description: |