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
*
+5 -5
View File
@@ -1,8 +1,8 @@
/************************************************************************************
* drivers/serial/serial.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -139,7 +139,7 @@ static void uart_pollnotify(FAR uart_dev_t *dev, pollevent_t eventset)
{
int i;
for (i = 0; i < CONFIG_DEV_CONSOLE_NPOLLWAITERS; i++)
for (i = 0; i < CONFIG_SERIAL_NPOLLWAITERS; i++)
{
struct pollfd *fds = dev->fds[i];
if (fds)
@@ -449,7 +449,7 @@ int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
* slot for the poll structure reference
*/
for (i = 0; i < CONFIG_DEV_CONSOLE_NPOLLWAITERS; i++)
for (i = 0; i < CONFIG_SERIAL_NPOLLWAITERS; i++)
{
/* Find an available slot */
@@ -463,7 +463,7 @@ int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
}
}
if (i >= CONFIG_DEV_CONSOLE_NPOLLWAITERS)
if (i >= CONFIG_SERIAL_NPOLLWAITERS)
{
fds->priv = NULL;
ret = -EBUSY;