mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
Add an MTD device wrapper that can used to provide a /dev/config that can be used for retaining configuration data. From Ken Pettit
This commit is contained in:
@@ -5924,4 +5924,7 @@
|
||||
caused an exception in usbdev_reset() later. The driver reference
|
||||
will be nullified later usbdev_unregister when the caller gets the
|
||||
error. From David Sidrane (2013-10-31).
|
||||
|
||||
* drivers/mtd_config.c and include/nuttx/configdata.h: Add a container
|
||||
for an MTD device that can be used to provide a simple, lightweight
|
||||
interface to configation data storage that resides on some storage
|
||||
media that is wrapped as an MTD device. From Ken Pettit (2013-11-1).
|
||||
|
||||
@@ -35,6 +35,13 @@ config MTD_BYTE_WRITE
|
||||
support such writes. The SMART file system can take advantage of
|
||||
this option if it is enabled.
|
||||
|
||||
config MTD_CONFIG
|
||||
bool "Enable Dev Config (MTD based) device"
|
||||
default n
|
||||
---help---
|
||||
Provides a /dev/config device for saving / restoring application
|
||||
configuration data to a standard MTD device or partition.
|
||||
|
||||
comment "MTD Device Drivers"
|
||||
|
||||
config RAMMTD
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
ifeq ($(CONFIG_MTD),y)
|
||||
|
||||
CSRCS += at45db.c flash_eraseall.c ftl.c m25px.c ramtron.c
|
||||
CSRCS += at45db.c flash_eraseall.c ftl.c m25px.c ramtron.c mtd_config.c
|
||||
|
||||
ifeq ($(CONFIG_MTD_PARTITION),y)
|
||||
CSRCS += mtd_partition.c
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,143 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/configdata.h
|
||||
*
|
||||
* Copyright (C) 2013 Ken Pettit. All rights reserved.
|
||||
* Author: Ken Pettit <pettitkd@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_CONFIGDATA_H
|
||||
#define __INCLUDE_NUTTX_CONFIGDATA_H
|
||||
|
||||
/* The configdata device details kernel level services for providing
|
||||
* application config data from kernel control objects, such as partitions
|
||||
* on shared MTD devices, etc.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#ifdef CONFIG_PLATFORM_CONFIGDATA
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
/* CONFIG_AUDIO - Enables Audio driver support
|
||||
* CONFIG_DEBUG_AUDIO - If enabled (with CONFIG_DEBUG and, optionally,
|
||||
* CONFIG_DEBUG_VERBOSE), this will generate output that can be used to
|
||||
* debug Audio drivers.
|
||||
*/
|
||||
|
||||
/* IOCTL Commands ***********************************************************/
|
||||
/* The Audio module uses a standard character driver framework. However, a
|
||||
* lot of the Audio driver functionality is configured via a device control
|
||||
* interface, such as sampling rate, volume, data format, etc.
|
||||
* The Audio ioctl commands are lised below:
|
||||
*
|
||||
* CFGDIOC_GETCONFIG - Get a specified Config Data item.
|
||||
*
|
||||
* ioctl argument: Pointer to a config_data_s structure to receive the
|
||||
* config data. All fields of the strucure must be
|
||||
* specified (i.e. id, instance, pointer and len).
|
||||
*
|
||||
* CFGDIOC_SETCONFIG - Set a specified Config Data Item
|
||||
*
|
||||
* ioctl argument: Pointer to a config_data_s structure to receive the
|
||||
* config data. All fields of the strucure must be
|
||||
* specified (i.e. id, instance, pointer and len).
|
||||
*/
|
||||
|
||||
#define CFGDIOC_GETCONFIG _CFGDIOC(1)
|
||||
#define CFGDIOC_SETCONFIG _CFGDIOC(2)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure is used to get and set config data items */
|
||||
|
||||
struct config_data_s
|
||||
{
|
||||
uint16_t id; /* ID of the config data item */
|
||||
int instance; /* Instance of the item */
|
||||
FAR uint8_t *configdata; /* Pointer to the config data */
|
||||
size_t len; /* Length of the config data buffer */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mtdconfig_register
|
||||
*
|
||||
* Description:
|
||||
* This function binds an instance of an MTD device to the /dev/config
|
||||
* device.
|
||||
*
|
||||
* When this function is called, the MTD device pass in should already
|
||||
* be initialized appropriately to access the physical device or partition.
|
||||
*
|
||||
* Input parameters:
|
||||
* mtd - Pointer to the MTD device to bind with the /dev/config device
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mtdconfig_register(FAR struct mtd_dev_s *mtd);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_PLATFORM_CONFIGDATA */
|
||||
#endif /* __INCLUDE_NUTTX_CONFIGDATA_H */
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/fs/ioctl.h
|
||||
*
|
||||
* Copyright (C) 2008, 2009, 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2008, 2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -68,7 +68,8 @@
|
||||
#define _QEIOCBASE (0x0f00) /* Quadrature encoder ioctl commands */
|
||||
#define _AUDIOIOCBASE (0x1000) /* Audio ioctl commands */
|
||||
#define _SLCDIOCBASE (0x1100) /* Segment LCD ioctl commands */
|
||||
#define _WLIOCBASE (0x1100) /* Wireless modules ioctl commands */
|
||||
#define _WLIOCBASE (0x1200) /* Wireless modules ioctl commands */
|
||||
#define _CFGDIOCBASE (0x1300) /* Config Data device (app config) ioctl commands */
|
||||
|
||||
/* Macros used to manage ioctl commands */
|
||||
|
||||
@@ -251,24 +252,30 @@
|
||||
#define _QEIOCVALID(c) (_IOC_TYPE(c)==_QEIOCBASE)
|
||||
#define _QEIOC(nr) _IOC(_QEIOCBASE,nr)
|
||||
|
||||
/* NuttX Audio driver ioctl definitions ************************************/
|
||||
/* NuttX Audio driver ioctl definitions *************************************/
|
||||
/* (see nuttx/audio/audio.h) */
|
||||
|
||||
#define _AUDIOIOCVALID(c) (_IOC_TYPE(c)==_AUDIOIOCBASE)
|
||||
#define _AUDIOIOC(nr) _IOC(_AUDIOIOCBASE,nr)
|
||||
|
||||
/* Segment LCD driver ioctl definitions ************************************/
|
||||
/* Segment LCD driver ioctl definitions *************************************/
|
||||
/* (see nuttx/include/lcd/slcd_codec.h */
|
||||
|
||||
#define _SLCDIOCVALID(c) (_IOC_TYPE(c)==_SLCDIOCBASE)
|
||||
#define _SLCDIOC(nr) _IOC(_SLCDIOCBASE,nr)
|
||||
|
||||
/* Wireless driver ioctl definitions ************************************/
|
||||
/* Wireless driver ioctl definitions ****************************************/
|
||||
/* (see nuttx/include/wireless/wireless.h */
|
||||
|
||||
#define _WLIOCVALID(c) (_IOC_TYPE(c)==_WLIOCBASE)
|
||||
#define _WLIOC(nr) _IOC(_WLIOCBASE,nr)
|
||||
|
||||
/* Application Config Data driver ioctl definitions *************************/
|
||||
/* (see nuttx/include/configdata.h */
|
||||
|
||||
#define _CFGDIOCVALID(c) (_IOC_TYPE(c)==_CFGDIOCBASE)
|
||||
#define _CFGDIOC(nr) _IOC(_CFGDIOCBASE,nr)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user