diff options
Diffstat (limited to 'nuttx/drivers')
-rw-r--r-- | nuttx/drivers/ramlog.c | 46 | ||||
-rw-r--r-- | nuttx/drivers/serial/serial.c | 10 |
2 files changed, 32 insertions, 24 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: diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c index cff810743..2d09574f9 100644 --- a/nuttx/drivers/serial/serial.c +++ b/nuttx/drivers/serial/serial.c @@ -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; |