forked from nuttx/nuttx-update
drivers/: Remove support for CONFIG_FS_WRITABLE
This commit is contained in:
parent
382513e997
commit
66ab039b89
11 changed files with 75 additions and 284 deletions
|
@ -19,7 +19,6 @@ config DRVR_MKRD
|
||||||
bool "RAM disk wrapper (mkrd)"
|
bool "RAM disk wrapper (mkrd)"
|
||||||
default n
|
default n
|
||||||
select FS_READABLE
|
select FS_READABLE
|
||||||
select FS_WRITABLE
|
|
||||||
---help---
|
---help---
|
||||||
Build the mkrd() function which serves as a wrapper to simplify
|
Build the mkrd() function which serves as a wrapper to simplify
|
||||||
creation of RAM disks. If the boardctrl() interface is enabled,
|
creation of RAM disks. If the boardctrl() interface is enabled,
|
||||||
|
|
|
@ -1,36 +1,20 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/loop/losetup.c
|
* drivers/loop/losetup.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009, 2011, 2014-2015, 2017-2018 Gregory Nutt. All
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* rights reserved.
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* License for the specific language governing permissions and limitations
|
||||||
* the documentation and/or other materials provided with the
|
* under the License.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -79,9 +63,7 @@ struct loop_struct_s
|
||||||
off_t offset; /* Offset (in bytes) to the first sector */
|
off_t offset; /* Offset (in bytes) to the first sector */
|
||||||
uint16_t sectsize; /* The size of one sector */
|
uint16_t sectsize; /* The size of one sector */
|
||||||
uint8_t opencnt; /* Count of open references to the loop device */
|
uint8_t opencnt; /* Count of open references to the loop device */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
bool writeenabled; /* true: can write to device */
|
bool writeenabled; /* true: can write to device */
|
||||||
#endif
|
|
||||||
struct file devfile; /* File struct of char device/file */
|
struct file devfile; /* File struct of char device/file */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,11 +76,9 @@ static int loop_open(FAR struct inode *inode);
|
||||||
static int loop_close(FAR struct inode *inode);
|
static int loop_close(FAR struct inode *inode);
|
||||||
static ssize_t loop_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
static ssize_t loop_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors);
|
size_t start_sector, unsigned int nsectors);
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t loop_write(FAR struct inode *inode,
|
static ssize_t loop_write(FAR struct inode *inode,
|
||||||
FAR const unsigned char *buffer,
|
FAR const unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors);
|
size_t start_sector, unsigned int nsectors);
|
||||||
#endif
|
|
||||||
static int loop_geometry(FAR struct inode *inode,
|
static int loop_geometry(FAR struct inode *inode,
|
||||||
FAR struct geometry *geometry);
|
FAR struct geometry *geometry);
|
||||||
|
|
||||||
|
@ -111,11 +91,7 @@ static const struct block_operations g_bops =
|
||||||
loop_open, /* open */
|
loop_open, /* open */
|
||||||
loop_close, /* close */
|
loop_close, /* close */
|
||||||
loop_read, /* read */
|
loop_read, /* read */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
loop_write, /* write */
|
loop_write, /* write */
|
||||||
#else
|
|
||||||
NULL, /* write */
|
|
||||||
#endif
|
|
||||||
loop_geometry, /* geometry */
|
loop_geometry, /* geometry */
|
||||||
NULL /* ioctl */
|
NULL /* ioctl */
|
||||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
|
@ -270,7 +246,6 @@ static ssize_t loop_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t loop_write(FAR struct inode *inode,
|
static ssize_t loop_write(FAR struct inode *inode,
|
||||||
FAR const unsigned char *buffer,
|
FAR const unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors)
|
size_t start_sector, unsigned int nsectors)
|
||||||
|
@ -310,7 +285,6 @@ static ssize_t loop_write(FAR struct inode *inode,
|
||||||
|
|
||||||
return nbyteswritten / dev->sectsize;
|
return nbyteswritten / dev->sectsize;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: loop_geometry
|
* Name: loop_geometry
|
||||||
|
@ -330,11 +304,7 @@ static int loop_geometry(FAR struct inode *inode,
|
||||||
dev = (FAR struct loop_struct_s *)inode->i_private;
|
dev = (FAR struct loop_struct_s *)inode->i_private;
|
||||||
geometry->geo_available = true;
|
geometry->geo_available = true;
|
||||||
geometry->geo_mediachanged = false;
|
geometry->geo_mediachanged = false;
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
geometry->geo_writeenabled = dev->writeenabled;
|
geometry->geo_writeenabled = dev->writeenabled;
|
||||||
#else
|
|
||||||
geometry->geo_writeenabled = false;
|
|
||||||
#endif
|
|
||||||
geometry->geo_nsectors = dev->nsectors;
|
geometry->geo_nsectors = dev->nsectors;
|
||||||
geometry->geo_sectorsize = dev->sectsize;
|
geometry->geo_sectorsize = dev->sectsize;
|
||||||
return OK;
|
return OK;
|
||||||
|
@ -407,7 +377,6 @@ int losetup(FAR const char *devname, FAR const char *filename,
|
||||||
|
|
||||||
/* Open the file. */
|
/* Open the file. */
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
/* First try to open the device R/W access (unless we are asked
|
/* First try to open the device R/W access (unless we are asked
|
||||||
* to open it readonly).
|
* to open it readonly).
|
||||||
*/
|
*/
|
||||||
|
@ -423,7 +392,6 @@ int losetup(FAR const char *devname, FAR const char *filename,
|
||||||
dev->writeenabled = true; /* Success */
|
dev->writeenabled = true; /* Success */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* If that fails, then try to open the device read-only */
|
/* If that fails, then try to open the device read-only */
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,20 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/mmcsd/mmcsd_sdio.c
|
* drivers/mmcsd/mmcsd_sdio.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2013, 2016-2019 Gregory Nutt. All rights reserved.
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
* Bob Feretich <bob.fereich@rafresearch.com>
|
* this work for additional information regarding copyright ownership. The
|
||||||
* Ivan Ucherdzhiev <ivanucherdjiev@gmail.com>
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* License for the specific language governing permissions and limitations
|
||||||
* the documentation and/or other materials provided with the
|
* under the License.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -190,9 +173,7 @@ static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv,
|
||||||
|
|
||||||
/* Transfer helpers *********************************************************/
|
/* Transfer helpers *********************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static bool mmcsd_wrprotected(FAR struct mmcsd_state_s *priv);
|
static bool mmcsd_wrprotected(FAR struct mmcsd_state_s *priv);
|
||||||
#endif
|
|
||||||
static int mmcsd_eventwait(FAR struct mmcsd_state_s *priv,
|
static int mmcsd_eventwait(FAR struct mmcsd_state_s *priv,
|
||||||
sdio_eventset_t failevents, uint32_t timeout);
|
sdio_eventset_t failevents, uint32_t timeout);
|
||||||
static int mmcsd_transferready(FAR struct mmcsd_state_s *priv);
|
static int mmcsd_transferready(FAR struct mmcsd_state_s *priv);
|
||||||
|
@ -211,7 +192,6 @@ static ssize_t mmcsd_readmultiple(FAR struct mmcsd_state_s *priv,
|
||||||
static ssize_t mmcsd_reload(FAR void *dev, FAR uint8_t *buffer,
|
static ssize_t mmcsd_reload(FAR void *dev, FAR uint8_t *buffer,
|
||||||
off_t startblock, size_t nblocks);
|
off_t startblock, size_t nblocks);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
|
static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
|
||||||
FAR const uint8_t *buffer, off_t startblock);
|
FAR const uint8_t *buffer, off_t startblock);
|
||||||
#ifndef CONFIG_MMCSD_MULTIBLOCK_DISABLE
|
#ifndef CONFIG_MMCSD_MULTIBLOCK_DISABLE
|
||||||
|
@ -222,7 +202,6 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
|
||||||
static ssize_t mmcsd_flush(FAR void *dev, FAR const uint8_t *buffer,
|
static ssize_t mmcsd_flush(FAR void *dev, FAR const uint8_t *buffer,
|
||||||
off_t startblock, size_t nblocks);
|
off_t startblock, size_t nblocks);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Block driver methods *****************************************************/
|
/* Block driver methods *****************************************************/
|
||||||
|
|
||||||
|
@ -230,11 +209,9 @@ static int mmcsd_open(FAR struct inode *inode);
|
||||||
static int mmcsd_close(FAR struct inode *inode);
|
static int mmcsd_close(FAR struct inode *inode);
|
||||||
static ssize_t mmcsd_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
static ssize_t mmcsd_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
||||||
size_t startsector, unsigned int nsectors);
|
size_t startsector, unsigned int nsectors);
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t mmcsd_write(FAR struct inode *inode,
|
static ssize_t mmcsd_write(FAR struct inode *inode,
|
||||||
FAR const unsigned char *buffer, size_t startsector,
|
FAR const unsigned char *buffer, size_t startsector,
|
||||||
unsigned int nsectors);
|
unsigned int nsectors);
|
||||||
#endif
|
|
||||||
static int mmcsd_geometry(FAR struct inode *inode,
|
static int mmcsd_geometry(FAR struct inode *inode,
|
||||||
FAR struct geometry *geometry);
|
FAR struct geometry *geometry);
|
||||||
static int mmcsd_ioctl(FAR struct inode *inode, int cmd,
|
static int mmcsd_ioctl(FAR struct inode *inode, int cmd,
|
||||||
|
@ -264,11 +241,7 @@ static const struct block_operations g_bops =
|
||||||
mmcsd_open, /* open */
|
mmcsd_open, /* open */
|
||||||
mmcsd_close, /* close */
|
mmcsd_close, /* close */
|
||||||
mmcsd_read, /* read */
|
mmcsd_read, /* read */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
mmcsd_write, /* write */
|
mmcsd_write, /* write */
|
||||||
#else
|
|
||||||
NULL, /* write */
|
|
||||||
#endif
|
|
||||||
mmcsd_geometry, /* geometry */
|
mmcsd_geometry, /* geometry */
|
||||||
mmcsd_ioctl /* ioctl */
|
mmcsd_ioctl /* ioctl */
|
||||||
};
|
};
|
||||||
|
@ -1127,7 +1100,6 @@ static int mmcsd_verifystate(FAR struct mmcsd_state_s *priv, uint32_t state)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static bool mmcsd_wrprotected(FAR struct mmcsd_state_s *priv)
|
static bool mmcsd_wrprotected(FAR struct mmcsd_state_s *priv)
|
||||||
{
|
{
|
||||||
/* Check if the card is locked (priv->locked) or write protected either (1)
|
/* Check if the card is locked (priv->locked) or write protected either (1)
|
||||||
|
@ -1138,7 +1110,6 @@ static bool mmcsd_wrprotected(FAR struct mmcsd_state_s *priv)
|
||||||
|
|
||||||
return (priv->wrprotect || priv->locked || SDIO_WRPROTECTED(priv->dev));
|
return (priv->wrprotect || priv->locked || SDIO_WRPROTECTED(priv->dev));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mmcsd_eventwait
|
* Name: mmcsd_eventwait
|
||||||
|
@ -1703,7 +1674,6 @@ static ssize_t mmcsd_reload(FAR void *dev, FAR uint8_t *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
|
static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
|
||||||
FAR const uint8_t *buffer, off_t startblock)
|
FAR const uint8_t *buffer, off_t startblock)
|
||||||
{
|
{
|
||||||
|
@ -1857,7 +1827,6 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mmcsd_writemultiple
|
* Name: mmcsd_writemultiple
|
||||||
|
@ -1869,7 +1838,7 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_MULTIBLOCK_DISABLE)
|
#if !defined(CONFIG_MMCSD_MULTIBLOCK_DISABLE)
|
||||||
static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
|
static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
|
||||||
FAR const uint8_t *buffer, off_t startblock,
|
FAR const uint8_t *buffer, off_t startblock,
|
||||||
size_t nblocks)
|
size_t nblocks)
|
||||||
|
@ -2085,7 +2054,7 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_FS_WRITABLE) && defined(CONFIG_DRVR_WRITEBUFFER)
|
#if defined(CONFIG_DRVR_WRITEBUFFER)
|
||||||
static ssize_t mmcsd_flush(FAR void *dev, FAR const uint8_t *buffer,
|
static ssize_t mmcsd_flush(FAR void *dev, FAR const uint8_t *buffer,
|
||||||
off_t startblock, size_t nblocks)
|
off_t startblock, size_t nblocks)
|
||||||
{
|
{
|
||||||
|
@ -2272,7 +2241,6 @@ static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t mmcsd_write(FAR struct inode *inode, FAR const unsigned char *buffer,
|
static ssize_t mmcsd_write(FAR struct inode *inode, FAR const unsigned char *buffer,
|
||||||
size_t startsector, unsigned int nsectors)
|
size_t startsector, unsigned int nsectors)
|
||||||
{
|
{
|
||||||
|
@ -2335,7 +2303,6 @@ static ssize_t mmcsd_write(FAR struct inode *inode, FAR const unsigned char *buf
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mmcsd_geometry
|
* Name: mmcsd_geometry
|
||||||
|
@ -2371,11 +2338,7 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||||
|
|
||||||
geometry->geo_available = true;
|
geometry->geo_available = true;
|
||||||
geometry->geo_mediachanged = priv->mediachanged;
|
geometry->geo_mediachanged = priv->mediachanged;
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
geometry->geo_writeenabled = !mmcsd_wrprotected(priv);
|
geometry->geo_writeenabled = !mmcsd_wrprotected(priv);
|
||||||
#else
|
|
||||||
geometry->geo_writeenabled = false;
|
|
||||||
#endif
|
|
||||||
geometry->geo_nsectors = priv->nblocks;
|
geometry->geo_nsectors = priv->nblocks;
|
||||||
geometry->geo_sectorsize = priv->blocksize;
|
geometry->geo_sectorsize = priv->blocksize;
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,20 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/mmcsd/mmcsd_spi.c
|
* drivers/mmcsd/mmcsd_spi.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2010, 2011-2013, 2017 Gregory Nutt. All rights reserved.
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* License for the specific language governing permissions and limitations
|
||||||
* the documentation and/or other materials provided with the
|
* under the License.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -78,7 +63,7 @@
|
||||||
|
|
||||||
#define MMCSD_IDMODE_CLOCK (400000)
|
#define MMCSD_IDMODE_CLOCK (400000)
|
||||||
|
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
# define MMCSD_MODE 0666
|
# define MMCSD_MODE 0666
|
||||||
#else
|
#else
|
||||||
# define MMCSD_MODE 0444
|
# define MMCSD_MODE 0444
|
||||||
|
@ -200,7 +185,7 @@ static int mmcsd_getcardinfo(FAR struct mmcsd_slot_s *slot,
|
||||||
|
|
||||||
static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot,
|
static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot,
|
||||||
uint8_t *buffer, int nbytes);
|
uint8_t *buffer, int nbytes);
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot,
|
static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot,
|
||||||
const uint8_t *buffer, int nbytes, uint8_t token);
|
const uint8_t *buffer, int nbytes, uint8_t token);
|
||||||
#endif
|
#endif
|
||||||
|
@ -211,7 +196,7 @@ static int mmcsd_open(FAR struct inode *inode);
|
||||||
static int mmcsd_close(FAR struct inode *inode);
|
static int mmcsd_close(FAR struct inode *inode);
|
||||||
static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer,
|
static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors);
|
size_t start_sector, unsigned int nsectors);
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
static ssize_t mmcsd_write(FAR struct inode *inode,
|
static ssize_t mmcsd_write(FAR struct inode *inode,
|
||||||
const unsigned char *buffer, size_t start_sector,
|
const unsigned char *buffer, size_t start_sector,
|
||||||
unsigned int nsectors);
|
unsigned int nsectors);
|
||||||
|
@ -237,7 +222,7 @@ static const struct block_operations g_bops =
|
||||||
mmcsd_open, /* open */
|
mmcsd_open, /* open */
|
||||||
mmcsd_close, /* close */
|
mmcsd_close, /* close */
|
||||||
mmcsd_read, /* read */
|
mmcsd_read, /* read */
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
mmcsd_write, /* write */
|
mmcsd_write, /* write */
|
||||||
#else
|
#else
|
||||||
NULL, /* write */
|
NULL, /* write */
|
||||||
|
@ -335,13 +320,13 @@ static const struct mmcsd_cmdinfo_s g_cmd12 = {CMD12, MMCSD_CMDRESP_R1, 0xff};
|
||||||
static const struct mmcsd_cmdinfo_s g_cmd16 = {CMD16, MMCSD_CMDRESP_R1, 0xff};
|
static const struct mmcsd_cmdinfo_s g_cmd16 = {CMD16, MMCSD_CMDRESP_R1, 0xff};
|
||||||
static const struct mmcsd_cmdinfo_s g_cmd17 = {CMD17, MMCSD_CMDRESP_R1, 0xff};
|
static const struct mmcsd_cmdinfo_s g_cmd17 = {CMD17, MMCSD_CMDRESP_R1, 0xff};
|
||||||
static const struct mmcsd_cmdinfo_s g_cmd18 = {CMD18, MMCSD_CMDRESP_R1, 0xff};
|
static const struct mmcsd_cmdinfo_s g_cmd18 = {CMD18, MMCSD_CMDRESP_R1, 0xff};
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
static const struct mmcsd_cmdinfo_s g_cmd24 = {CMD24, MMCSD_CMDRESP_R1, 0xff};
|
static const struct mmcsd_cmdinfo_s g_cmd24 = {CMD24, MMCSD_CMDRESP_R1, 0xff};
|
||||||
static const struct mmcsd_cmdinfo_s g_cmd25 = {CMD25, MMCSD_CMDRESP_R1, 0xff};
|
static const struct mmcsd_cmdinfo_s g_cmd25 = {CMD25, MMCSD_CMDRESP_R1, 0xff};
|
||||||
#endif
|
#endif
|
||||||
static const struct mmcsd_cmdinfo_s g_cmd55 = {CMD55, MMCSD_CMDRESP_R1, 0xff};
|
static const struct mmcsd_cmdinfo_s g_cmd55 = {CMD55, MMCSD_CMDRESP_R1, 0xff};
|
||||||
static const struct mmcsd_cmdinfo_s g_cmd58 = {CMD58, MMCSD_CMDRESP_R3, 0xff};
|
static const struct mmcsd_cmdinfo_s g_cmd58 = {CMD58, MMCSD_CMDRESP_R3, 0xff};
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
static const struct mmcsd_cmdinfo_s g_acmd23 = {ACMD23, MMCSD_CMDRESP_R1, 0xff};
|
static const struct mmcsd_cmdinfo_s g_acmd23 = {ACMD23, MMCSD_CMDRESP_R1, 0xff};
|
||||||
#endif
|
#endif
|
||||||
static const struct mmcsd_cmdinfo_s g_acmd41 = {ACMD41, MMCSD_CMDRESP_R1, 0xff};
|
static const struct mmcsd_cmdinfo_s g_acmd41 = {ACMD41, MMCSD_CMDRESP_R1, 0xff};
|
||||||
|
@ -979,7 +964,7 @@ static int mmcsd_recvblock(FAR struct mmcsd_slot_s *slot, uint8_t *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot,
|
static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot,
|
||||||
FAR const uint8_t *buffer, int nbytes,
|
FAR const uint8_t *buffer, int nbytes,
|
||||||
uint8_t token)
|
uint8_t token)
|
||||||
|
@ -1018,7 +1003,7 @@ static int mmcsd_xmitblock(FAR struct mmcsd_slot_s *slot,
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FS_WRITABLE && !CONFIG_MMCSD_READONLY */
|
#endif /* !CONFIG_MMCSD_READONLY */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Block Driver Operations
|
* Block Driver Operations
|
||||||
|
@ -1265,7 +1250,7 @@ errout_with_eio:
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer,
|
static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors)
|
size_t start_sector, unsigned int nsectors)
|
||||||
{
|
{
|
||||||
|
@ -1511,7 +1496,7 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||||
((slot->state & (MMCSD_SLOTSTATUS_NOTREADY | MMCSD_SLOTSTATUS_NODISK)) == 0);
|
((slot->state & (MMCSD_SLOTSTATUS_NOTREADY | MMCSD_SLOTSTATUS_NODISK)) == 0);
|
||||||
geometry->geo_mediachanged =
|
geometry->geo_mediachanged =
|
||||||
((slot->state & MMCSD_SLOTSTATUS_MEDIACHGD) != 0);
|
((slot->state & MMCSD_SLOTSTATUS_MEDIACHGD) != 0);
|
||||||
#if defined(CONFIG_FS_WRITABLE) && !defined(CONFIG_MMCSD_READONLY)
|
#if !defined(CONFIG_MMCSD_READONLY)
|
||||||
geometry->geo_writeenabled =
|
geometry->geo_writeenabled =
|
||||||
((slot->state & MMCSD_SLOTSTATUS_WRPROTECT) == 0);
|
((slot->state & MMCSD_SLOTSTATUS_WRPROTECT) == 0);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -42,7 +42,7 @@ config MTD_PARTITION
|
||||||
config FTL_WRITEBUFFER
|
config FTL_WRITEBUFFER
|
||||||
bool "Enable write buffering in the FTL layer"
|
bool "Enable write buffering in the FTL layer"
|
||||||
default n
|
default n
|
||||||
depends on DRVR_WRITEBUFFER && FS_WRITABLE
|
depends on DRVR_WRITEBUFFER
|
||||||
|
|
||||||
config FTL_READAHEAD
|
config FTL_READAHEAD
|
||||||
bool "Enable read-ahead buffering in the FTL layer"
|
bool "Enable read-ahead buffering in the FTL layer"
|
||||||
|
@ -791,7 +791,6 @@ endchoice # CRC level selection
|
||||||
config MTD_SMART_FSCK
|
config MTD_SMART_FSCK
|
||||||
bool "Enable SMART file system check"
|
bool "Enable SMART file system check"
|
||||||
default n
|
default n
|
||||||
depends on FS_WRITABLE
|
|
||||||
---help---
|
---help---
|
||||||
Enables fsck to check and repair the SMART file system.
|
Enables fsck to check and repair the SMART file system.
|
||||||
|
|
||||||
|
|
|
@ -506,10 +506,7 @@ FAR struct mtd_dev_s *blockmtd_initialize(FAR const char *path, size_t offset,
|
||||||
|
|
||||||
/* Determine the file open mode */
|
/* Determine the file open mode */
|
||||||
|
|
||||||
mode = O_RDOK;
|
mode = O_RDOK |= O_WROK;
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
mode |= O_WROK;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Try to open the file. NOTE that block devices will use a character
|
/* Try to open the file. NOTE that block devices will use a character
|
||||||
* driver proxy.
|
* driver proxy.
|
||||||
|
|
|
@ -71,9 +71,7 @@ struct ftl_struct_s
|
||||||
uint16_t blkper; /* R/W blocks per erase block */
|
uint16_t blkper; /* R/W blocks per erase block */
|
||||||
uint16_t refs; /* Number of references */
|
uint16_t refs; /* Number of references */
|
||||||
bool unlinked; /* The driver has been unlinked */
|
bool unlinked; /* The driver has been unlinked */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
FAR uint8_t *eblock; /* One, in-memory erase block */
|
FAR uint8_t *eblock; /* One, in-memory erase block */
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -86,13 +84,11 @@ static ssize_t ftl_reload(FAR void *priv, FAR uint8_t *buffer,
|
||||||
off_t startblock, size_t nblocks);
|
off_t startblock, size_t nblocks);
|
||||||
static ssize_t ftl_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
static ssize_t ftl_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors);
|
size_t start_sector, unsigned int nsectors);
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
|
static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
|
||||||
off_t startblock, size_t nblocks);
|
off_t startblock, size_t nblocks);
|
||||||
static ssize_t ftl_write(FAR struct inode *inode,
|
static ssize_t ftl_write(FAR struct inode *inode,
|
||||||
FAR const unsigned char *buffer, size_t start_sector,
|
FAR const unsigned char *buffer, size_t start_sector,
|
||||||
unsigned int nsectors);
|
unsigned int nsectors);
|
||||||
#endif
|
|
||||||
static int ftl_geometry(FAR struct inode *inode,
|
static int ftl_geometry(FAR struct inode *inode,
|
||||||
FAR struct geometry *geometry);
|
FAR struct geometry *geometry);
|
||||||
static int ftl_ioctl(FAR struct inode *inode, int cmd,
|
static int ftl_ioctl(FAR struct inode *inode, int cmd,
|
||||||
|
@ -110,11 +106,7 @@ static const struct block_operations g_bops =
|
||||||
ftl_open, /* open */
|
ftl_open, /* open */
|
||||||
ftl_close, /* close */
|
ftl_close, /* close */
|
||||||
ftl_read, /* read */
|
ftl_read, /* read */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
ftl_write, /* write */
|
ftl_write, /* write */
|
||||||
#else
|
|
||||||
NULL, /* write */
|
|
||||||
#endif
|
|
||||||
ftl_geometry, /* geometry */
|
ftl_geometry, /* geometry */
|
||||||
ftl_ioctl /* ioctl */
|
ftl_ioctl /* ioctl */
|
||||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
|
@ -167,12 +159,10 @@ static int ftl_close(FAR struct inode *inode)
|
||||||
#ifdef FTL_HAVE_RWBUFFER
|
#ifdef FTL_HAVE_RWBUFFER
|
||||||
rwb_uninitialize(&dev->rwb);
|
rwb_uninitialize(&dev->rwb);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
if (dev->eblock)
|
if (dev->eblock)
|
||||||
{
|
{
|
||||||
kmm_free(dev->eblock);
|
kmm_free(dev->eblock);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
kmm_free(dev);
|
kmm_free(dev);
|
||||||
}
|
}
|
||||||
|
@ -236,7 +226,6 @@ static ssize_t ftl_read(FAR struct inode *inode, unsigned char *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static int ftl_alloc_eblock(FAR struct ftl_struct_s *dev)
|
static int ftl_alloc_eblock(FAR struct ftl_struct_s *dev)
|
||||||
{
|
{
|
||||||
if (dev->eblock == NULL)
|
if (dev->eblock == NULL)
|
||||||
|
@ -433,7 +422,6 @@ static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
|
||||||
|
|
||||||
return nblocks;
|
return nblocks;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ftl_write
|
* Name: ftl_write
|
||||||
|
@ -442,7 +430,6 @@ static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t ftl_write(FAR struct inode *inode,
|
static ssize_t ftl_write(FAR struct inode *inode,
|
||||||
FAR const unsigned char *buffer,
|
FAR const unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors)
|
size_t start_sector, unsigned int nsectors)
|
||||||
|
@ -459,7 +446,6 @@ static ssize_t ftl_write(FAR struct inode *inode,
|
||||||
return ftl_flush(dev, buffer, start_sector, nsectors);
|
return ftl_flush(dev, buffer, start_sector, nsectors);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ftl_geometry
|
* Name: ftl_geometry
|
||||||
|
@ -481,11 +467,7 @@ static int ftl_geometry(FAR struct inode *inode,
|
||||||
dev = (struct ftl_struct_s *)inode->i_private;
|
dev = (struct ftl_struct_s *)inode->i_private;
|
||||||
geometry->geo_available = true;
|
geometry->geo_available = true;
|
||||||
geometry->geo_mediachanged = false;
|
geometry->geo_mediachanged = false;
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
geometry->geo_writeenabled = true;
|
geometry->geo_writeenabled = true;
|
||||||
#else
|
|
||||||
geometry->geo_writeenabled = false;
|
|
||||||
#endif
|
|
||||||
geometry->geo_nsectors = dev->geo.neraseblocks * dev->blkper;
|
geometry->geo_nsectors = dev->geo.neraseblocks * dev->blkper;
|
||||||
geometry->geo_sectorsize = dev->geo.blocksize;
|
geometry->geo_sectorsize = dev->geo.blocksize;
|
||||||
|
|
||||||
|
@ -583,12 +565,10 @@ static int ftl_unlink(FAR struct inode *inode)
|
||||||
#ifdef FTL_HAVE_RWBUFFER
|
#ifdef FTL_HAVE_RWBUFFER
|
||||||
rwb_uninitialize(&dev->rwb);
|
rwb_uninitialize(&dev->rwb);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
if (dev->eblock)
|
if (dev->eblock)
|
||||||
{
|
{
|
||||||
kmm_free(dev->eblock);
|
kmm_free(dev->eblock);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
kmm_free(dev);
|
kmm_free(dev);
|
||||||
}
|
}
|
||||||
|
@ -664,7 +644,7 @@ int ftl_initialize_by_path(FAR const char *path, FAR struct mtd_dev_s *mtd)
|
||||||
dev->rwb.wrflush = ftl_flush;
|
dev->rwb.wrflush = ftl_flush;
|
||||||
dev->rwb.rhreload = ftl_reload;
|
dev->rwb.rhreload = ftl_reload;
|
||||||
|
|
||||||
#if defined(CONFIG_FS_WRITABLE) && defined(CONFIG_FTL_WRITEBUFFER)
|
#if defined(CONFIG_FTL_WRITEBUFFER)
|
||||||
dev->rwb.wrmaxblocks = dev->blkper;
|
dev->rwb.wrmaxblocks = dev->blkper;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -408,21 +408,17 @@ static ssize_t smart_reload(struct smart_struct_s *dev, FAR uint8_t *buffer,
|
||||||
off_t startblock, size_t nblocks);
|
off_t startblock, size_t nblocks);
|
||||||
static ssize_t smart_read(FAR struct inode *inode, unsigned char *buffer,
|
static ssize_t smart_read(FAR struct inode *inode, unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors);
|
size_t start_sector, unsigned int nsectors);
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t smart_write(FAR struct inode *inode, const unsigned char *buffer,
|
static ssize_t smart_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors);
|
size_t start_sector, unsigned int nsectors);
|
||||||
#endif
|
|
||||||
static int smart_geometry(FAR struct inode *inode, struct geometry *geometry);
|
static int smart_geometry(FAR struct inode *inode, struct geometry *geometry);
|
||||||
static int smart_ioctl(FAR struct inode *inode, int cmd, unsigned long arg);
|
static int smart_ioctl(FAR struct inode *inode, int cmd, unsigned long arg);
|
||||||
|
|
||||||
static int smart_findfreephyssector(FAR struct smart_struct_s *dev,
|
static int smart_findfreephyssector(FAR struct smart_struct_s *dev,
|
||||||
uint8_t canrelocate);
|
uint8_t canrelocate);
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static int smart_writesector(FAR struct smart_struct_s *dev, unsigned long arg);
|
static int smart_writesector(FAR struct smart_struct_s *dev, unsigned long arg);
|
||||||
static inline int smart_allocsector(FAR struct smart_struct_s *dev,
|
static inline int smart_allocsector(FAR struct smart_struct_s *dev,
|
||||||
unsigned long requested);
|
unsigned long requested);
|
||||||
#endif
|
|
||||||
static int smart_readsector(FAR struct smart_struct_s *dev, unsigned long arg);
|
static int smart_readsector(FAR struct smart_struct_s *dev, unsigned long arg);
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_SMART_ENABLE_CRC
|
#ifdef CONFIG_MTD_SMART_ENABLE_CRC
|
||||||
|
@ -457,11 +453,7 @@ static const struct block_operations g_bops =
|
||||||
smart_open, /* open */
|
smart_open, /* open */
|
||||||
smart_close, /* close */
|
smart_close, /* close */
|
||||||
smart_read, /* read */
|
smart_read, /* read */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
smart_write, /* write */
|
smart_write, /* write */
|
||||||
#else
|
|
||||||
NULL, /* write */
|
|
||||||
#endif
|
|
||||||
smart_geometry, /* geometry */
|
smart_geometry, /* geometry */
|
||||||
smart_ioctl /* ioctl */
|
smart_ioctl /* ioctl */
|
||||||
};
|
};
|
||||||
|
@ -907,7 +899,6 @@ static ssize_t smart_read(FAR struct inode *inode, unsigned char *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t smart_write(FAR struct inode *inode,
|
static ssize_t smart_write(FAR struct inode *inode,
|
||||||
FAR const unsigned char *buffer,
|
FAR const unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors)
|
size_t start_sector, unsigned int nsectors)
|
||||||
|
@ -1018,7 +1009,6 @@ static ssize_t smart_write(FAR struct inode *inode,
|
||||||
|
|
||||||
return nsectors;
|
return nsectors;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FS_WRITABLE */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: smart_geometry
|
* Name: smart_geometry
|
||||||
|
@ -1044,11 +1034,7 @@ static int smart_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||||
#endif
|
#endif
|
||||||
geometry->geo_available = true;
|
geometry->geo_available = true;
|
||||||
geometry->geo_mediachanged = false;
|
geometry->geo_mediachanged = false;
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
geometry->geo_writeenabled = true;
|
geometry->geo_writeenabled = true;
|
||||||
#else
|
|
||||||
geometry->geo_writeenabled = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
erasesize = dev->geo.erasesize;
|
erasesize = dev->geo.erasesize;
|
||||||
geometry->geo_nsectors = dev->geo.neraseblocks * erasesize /
|
geometry->geo_nsectors = dev->geo.neraseblocks * erasesize /
|
||||||
|
@ -3042,7 +3028,6 @@ static crc_t smart_calc_sector_crc(FAR struct smart_struct_s *dev)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static inline int smart_llformat(FAR struct smart_struct_s *dev, unsigned long arg)
|
static inline int smart_llformat(FAR struct smart_struct_s *dev, unsigned long arg)
|
||||||
{
|
{
|
||||||
FAR struct smart_sect_header_s *sectorheader;
|
FAR struct smart_sect_header_s *sectorheader;
|
||||||
|
@ -3248,7 +3233,6 @@ static inline int smart_llformat(FAR struct smart_struct_s *dev, unsigned long a
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FS_WRITABLE */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: smart_relocate_sector
|
* Name: smart_relocate_sector
|
||||||
|
@ -3923,7 +3907,6 @@ retry:
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static int smart_garbagecollect(FAR struct smart_struct_s *dev)
|
static int smart_garbagecollect(FAR struct smart_struct_s *dev)
|
||||||
{
|
{
|
||||||
uint16_t collectblock;
|
uint16_t collectblock;
|
||||||
|
@ -4046,7 +4029,6 @@ static int smart_garbagecollect(FAR struct smart_struct_s *dev)
|
||||||
errout:
|
errout:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FS_WRITABLE */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: smart_write_wearstatus
|
* Name: smart_write_wearstatus
|
||||||
|
@ -4254,8 +4236,6 @@ static inline int smart_read_wearstatus(FAR struct smart_struct_s *dev)
|
||||||
#endif
|
#endif
|
||||||
if ((sector != 0) && (physsector == 0xffff))
|
if ((sector != 0) && (physsector == 0xffff))
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
|
|
||||||
/* This logical sector does not exist yet. We must allocate it */
|
/* This logical sector does not exist yet. We must allocate it */
|
||||||
|
|
||||||
ret = smart_allocsector(dev, sector);
|
ret = smart_allocsector(dev, sector);
|
||||||
|
@ -4265,7 +4245,6 @@ static inline int smart_read_wearstatus(FAR struct smart_struct_s *dev)
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the sector */
|
/* Read the sector */
|
||||||
|
@ -4324,7 +4303,6 @@ errout:
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static int smart_write_alloc_sector(FAR struct smart_struct_s *dev,
|
static int smart_write_alloc_sector(FAR struct smart_struct_s *dev,
|
||||||
uint16_t logical, uint16_t physical)
|
uint16_t logical, uint16_t physical)
|
||||||
{
|
{
|
||||||
|
@ -4394,7 +4372,6 @@ static int smart_write_alloc_sector(FAR struct smart_struct_s *dev,
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: smart_validate_crc
|
* Name: smart_validate_crc
|
||||||
|
@ -4460,7 +4437,6 @@ static int smart_validate_crc(FAR struct smart_struct_s *dev)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static int smart_writesector(FAR struct smart_struct_s *dev,
|
static int smart_writesector(FAR struct smart_struct_s *dev,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
|
@ -4857,7 +4833,6 @@ static int smart_writesector(FAR struct smart_struct_s *dev,
|
||||||
errout:
|
errout:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FS_WRITABLE */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: smart_readsector
|
* Name: smart_readsector
|
||||||
|
@ -5016,7 +4991,6 @@ errout:
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static inline int smart_allocsector(FAR struct smart_struct_s *dev,
|
static inline int smart_allocsector(FAR struct smart_struct_s *dev,
|
||||||
unsigned long requested)
|
unsigned long requested)
|
||||||
{
|
{
|
||||||
|
@ -5251,7 +5225,6 @@ static inline int smart_allocsector(FAR struct smart_struct_s *dev,
|
||||||
|
|
||||||
return logsector;
|
return logsector;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FS_WRITABLE */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: smart_freesector
|
* Name: smart_freesector
|
||||||
|
@ -5262,7 +5235,6 @@ static inline int smart_allocsector(FAR struct smart_struct_s *dev,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static inline int smart_freesector(FAR struct smart_struct_s *dev,
|
static inline int smart_freesector(FAR struct smart_struct_s *dev,
|
||||||
unsigned long logicalsector)
|
unsigned long logicalsector)
|
||||||
{
|
{
|
||||||
|
@ -5365,7 +5337,6 @@ static inline int smart_freesector(FAR struct smart_struct_s *dev,
|
||||||
errout:
|
errout:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_FS_WRITABLE */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: smart_ioctl
|
* Name: smart_ioctl
|
||||||
|
@ -5436,7 +5407,6 @@ static int smart_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
|
||||||
ret = smart_readsector(dev, arg);
|
ret = smart_readsector(dev, arg);
|
||||||
goto ok_out;
|
goto ok_out;
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
case BIOC_LLFORMAT:
|
case BIOC_LLFORMAT:
|
||||||
|
|
||||||
/* Perform a low-level format on the flash */
|
/* Perform a low-level format on the flash */
|
||||||
|
@ -5481,7 +5451,6 @@ static int smart_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
goto ok_out;
|
goto ok_out;
|
||||||
#endif /* CONFIG_FS_WRITABLE */
|
|
||||||
|
|
||||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS)
|
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS)
|
||||||
case BIOC_GETPROCFSD:
|
case BIOC_GETPROCFSD:
|
||||||
|
|
|
@ -1,35 +1,20 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/ramdisk.c
|
* drivers/ramdisk.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* License for the specific language governing permissions and limitations
|
||||||
* the documentation and/or other materials provided with the
|
* under the License.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -83,11 +68,7 @@ struct rd_struct_s
|
||||||
uint8_t rd_crefs; /* Open reference count */
|
uint8_t rd_crefs; /* Open reference count */
|
||||||
#endif
|
#endif
|
||||||
uint8_t rd_flags; /* See RDFLAG_* definitions */
|
uint8_t rd_flags; /* See RDFLAG_* definitions */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
FAR uint8_t *rd_buffer; /* RAM disk backup memory */
|
FAR uint8_t *rd_buffer; /* RAM disk backup memory */
|
||||||
#else
|
|
||||||
FAR const uint8_t *rd_buffer; /* ROM disk backup memory */
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -103,11 +84,9 @@ static int rd_close(FAR struct inode *inode);
|
||||||
|
|
||||||
static ssize_t rd_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
static ssize_t rd_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors);
|
size_t start_sector, unsigned int nsectors);
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t rd_write(FAR struct inode *inode,
|
static ssize_t rd_write(FAR struct inode *inode,
|
||||||
FAR const unsigned char *buffer, size_t start_sector,
|
FAR const unsigned char *buffer, size_t start_sector,
|
||||||
unsigned int nsectors);
|
unsigned int nsectors);
|
||||||
#endif
|
|
||||||
static int rd_geometry(FAR struct inode *inode,
|
static int rd_geometry(FAR struct inode *inode,
|
||||||
FAR struct geometry *geometry);
|
FAR struct geometry *geometry);
|
||||||
static int rd_ioctl(FAR struct inode *inode, int cmd,
|
static int rd_ioctl(FAR struct inode *inode, int cmd,
|
||||||
|
@ -131,11 +110,7 @@ static const struct block_operations g_bops =
|
||||||
0, /* close */
|
0, /* close */
|
||||||
#endif
|
#endif
|
||||||
rd_read, /* read */
|
rd_read, /* read */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
rd_write, /* write */
|
rd_write, /* write */
|
||||||
#else
|
|
||||||
NULL, /* write */
|
|
||||||
#endif
|
|
||||||
rd_geometry, /* geometry */
|
rd_geometry, /* geometry */
|
||||||
rd_ioctl, /* ioctl */
|
rd_ioctl, /* ioctl */
|
||||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
|
@ -162,14 +137,12 @@ static void rd_destroy(FAR struct rd_struct_s *dev)
|
||||||
|
|
||||||
/* We we configured to free the RAM disk memory when unlinked? */
|
/* We we configured to free the RAM disk memory when unlinked? */
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
if (RDFLAG_IS_UNLINKED(dev->rd_flags))
|
if (RDFLAG_IS_UNLINKED(dev->rd_flags))
|
||||||
{
|
{
|
||||||
/* Yes.. do it */
|
/* Yes.. do it */
|
||||||
|
|
||||||
kmm_free(dev->rd_buffer);
|
kmm_free(dev->rd_buffer);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* And free the block driver itself */
|
/* And free the block driver itself */
|
||||||
|
|
||||||
|
@ -284,7 +257,6 @@ static ssize_t rd_read(FAR struct inode *inode, unsigned char *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t rd_write(FAR struct inode *inode, const unsigned char *buffer,
|
static ssize_t rd_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||||
size_t start_sector, unsigned int nsectors)
|
size_t start_sector, unsigned int nsectors)
|
||||||
{
|
{
|
||||||
|
@ -315,7 +287,6 @@ static ssize_t rd_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||||
|
|
||||||
return -EFBIG;
|
return -EFBIG;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: rd_geometry
|
* Name: rd_geometry
|
||||||
|
@ -336,11 +307,7 @@ static int rd_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||||
dev = (struct rd_struct_s *)inode->i_private;
|
dev = (struct rd_struct_s *)inode->i_private;
|
||||||
geometry->geo_available = true;
|
geometry->geo_available = true;
|
||||||
geometry->geo_mediachanged = false;
|
geometry->geo_mediachanged = false;
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
geometry->geo_writeenabled = RDFLAG_IS_WRENABLED(dev->rd_flags);
|
geometry->geo_writeenabled = RDFLAG_IS_WRENABLED(dev->rd_flags);
|
||||||
#else
|
|
||||||
geometry->geo_writeenabled = false;
|
|
||||||
#endif
|
|
||||||
geometry->geo_nsectors = dev->rd_nsectors;
|
geometry->geo_nsectors = dev->rd_nsectors;
|
||||||
geometry->geo_sectorsize = dev->rd_sectsize;
|
geometry->geo_sectorsize = dev->rd_sectsize;
|
||||||
|
|
||||||
|
@ -440,13 +407,8 @@ static int rd_unlink(FAR struct inode *inode)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
int ramdisk_register(int minor, FAR uint8_t *buffer, uint32_t nsectors,
|
int ramdisk_register(int minor, FAR uint8_t *buffer, uint32_t nsectors,
|
||||||
uint16_t sectsize, uint8_t rdflags)
|
uint16_t sectsize, uint8_t rdflags)
|
||||||
#else
|
|
||||||
int romdisk_register(int minor, FAR const uint8_t *buffer, uint32_t nsectors,
|
|
||||||
uint16_t sectsize)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
struct rd_struct_s *dev;
|
struct rd_struct_s *dev;
|
||||||
char devname[16];
|
char devname[16];
|
||||||
|
@ -473,10 +435,7 @@ int romdisk_register(int minor, FAR const uint8_t *buffer, uint32_t nsectors,
|
||||||
dev->rd_nsectors = nsectors; /* Number of sectors on device */
|
dev->rd_nsectors = nsectors; /* Number of sectors on device */
|
||||||
dev->rd_sectsize = sectsize; /* The size of one sector */
|
dev->rd_sectsize = sectsize; /* The size of one sector */
|
||||||
dev->rd_buffer = buffer; /* RAM disk backup memory */
|
dev->rd_buffer = buffer; /* RAM disk backup memory */
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
dev->rd_flags = rdflags & RDFLAG_USER;
|
dev->rd_flags = rdflags & RDFLAG_USER;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Create a ramdisk device name */
|
/* Create a ramdisk device name */
|
||||||
|
|
||||||
|
|
|
@ -572,7 +572,6 @@ menuconfig USBMSC
|
||||||
bool "USB Mass storage class device"
|
bool "USB Mass storage class device"
|
||||||
default n
|
default n
|
||||||
select FS_READABLE
|
select FS_READABLE
|
||||||
select FS_WRITABLE
|
|
||||||
---help---
|
---help---
|
||||||
References:
|
References:
|
||||||
"Universal Serial Bus Mass Storage Class, Specification Overview,"
|
"Universal Serial Bus Mass Storage Class, Specification Overview,"
|
||||||
|
|
|
@ -1,35 +1,20 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbhost/usbhost_storage.c
|
* drivers/usbhost/usbhost_storage.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2013, 2015-2017 Gregory Nutt. All rights reserved.
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* License for the specific language governing permissions and limitations
|
||||||
* the documentation and/or other materials provided with the
|
* under the License.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -242,11 +227,9 @@ static int usbhost_open(FAR struct inode *inode);
|
||||||
static int usbhost_close(FAR struct inode *inode);
|
static int usbhost_close(FAR struct inode *inode);
|
||||||
static ssize_t usbhost_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
static ssize_t usbhost_read(FAR struct inode *inode, FAR unsigned char *buffer,
|
||||||
size_t startsector, unsigned int nsectors);
|
size_t startsector, unsigned int nsectors);
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t usbhost_write(FAR struct inode *inode,
|
static ssize_t usbhost_write(FAR struct inode *inode,
|
||||||
FAR const unsigned char *buffer, size_t startsector,
|
FAR const unsigned char *buffer, size_t startsector,
|
||||||
unsigned int nsectors);
|
unsigned int nsectors);
|
||||||
#endif
|
|
||||||
static int usbhost_geometry(FAR struct inode *inode,
|
static int usbhost_geometry(FAR struct inode *inode,
|
||||||
FAR struct geometry *geometry);
|
FAR struct geometry *geometry);
|
||||||
static int usbhost_ioctl(FAR struct inode *inode, int cmd,
|
static int usbhost_ioctl(FAR struct inode *inode, int cmd,
|
||||||
|
@ -289,11 +272,7 @@ static const struct block_operations g_bops =
|
||||||
usbhost_open, /* open */
|
usbhost_open, /* open */
|
||||||
usbhost_close, /* close */
|
usbhost_close, /* close */
|
||||||
usbhost_read, /* read */
|
usbhost_read, /* read */
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
usbhost_write, /* write */
|
usbhost_write, /* write */
|
||||||
#else
|
|
||||||
NULL, /* write */
|
|
||||||
#endif
|
|
||||||
usbhost_geometry, /* geometry */
|
usbhost_geometry, /* geometry */
|
||||||
usbhost_ioctl /* ioctl */
|
usbhost_ioctl /* ioctl */
|
||||||
};
|
};
|
||||||
|
@ -2070,7 +2049,6 @@ static ssize_t usbhost_read(FAR struct inode *inode, unsigned char *buffer,
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
static ssize_t usbhost_write(FAR struct inode *inode, const unsigned char *buffer,
|
static ssize_t usbhost_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||||
size_t startsector, unsigned int nsectors)
|
size_t startsector, unsigned int nsectors)
|
||||||
{
|
{
|
||||||
|
@ -2157,7 +2135,6 @@ static ssize_t usbhost_write(FAR struct inode *inode, const unsigned char *buffe
|
||||||
|
|
||||||
return nbytes < 0 ? (int)nbytes : nsectors;
|
return nbytes < 0 ? (int)nbytes : nsectors;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usbhost_geometry
|
* Name: usbhost_geometry
|
||||||
|
@ -2194,11 +2171,7 @@ static int usbhost_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||||
|
|
||||||
geometry->geo_available = true;
|
geometry->geo_available = true;
|
||||||
geometry->geo_mediachanged = false;
|
geometry->geo_mediachanged = false;
|
||||||
#ifdef CONFIG_FS_WRITABLE
|
|
||||||
geometry->geo_writeenabled = true;
|
geometry->geo_writeenabled = true;
|
||||||
#else
|
|
||||||
geometry->geo_writeenabled = false;
|
|
||||||
#endif
|
|
||||||
geometry->geo_nsectors = priv->nblocks;
|
geometry->geo_nsectors = priv->nblocks;
|
||||||
geometry->geo_sectorsize = priv->blocksize;
|
geometry->geo_sectorsize = priv->blocksize;
|
||||||
usbhost_givesem(&priv->exclsem);
|
usbhost_givesem(&priv->exclsem);
|
||||||
|
|
Loading…
Reference in a new issue