forked from nuttx/nuttx-update
Add RAM disk support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@765 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
15926d2f9e
commit
714c61c361
15 changed files with 465 additions and 206 deletions
|
@ -356,7 +356,7 @@
|
|||
deletion logic (timer_delete.c) and one in stream logic (lib_init.c) reported
|
||||
by kwonsk.
|
||||
|
||||
0.3.11 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
0.3.11 2008-06-01 Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
* Add support for recursive mutexes.
|
||||
* Eliminate a memory leak -- contained watchdog instance was not being
|
||||
|
@ -367,3 +367,6 @@
|
|||
* Host simulator no longer uses Linux system calls directly; Now works with Cygwin.
|
||||
* Fix an error that occurs when a POSIX timer is deleted by the timer signal handler.
|
||||
* Add logic to allow the examples/ostest to be run repetitively as an endurance test.
|
||||
* Add a ramdisk block driver
|
||||
|
||||
0.3.12 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||
<p>Last Updated: May 31, 2008</p>
|
||||
<p>Last Updated: June 1, 2008</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -456,7 +456,7 @@
|
|||
</table>
|
||||
|
||||
<p>
|
||||
The 22nd release of NuttX (nuttx-0.3.11) is available for download
|
||||
The 23rd release of NuttX (nuttx-0.3.11) is available for download
|
||||
from the <a href="http://sourceforge.net/project/showfiles.php?group_id=189573">SourceForge</a>
|
||||
website.
|
||||
The change log associated with the release is available <a href="#currentrelease">here</a>.
|
||||
|
@ -464,16 +464,24 @@
|
|||
These unreleased changes are listed <a href="#pendingchanges">here</a>.
|
||||
</p>
|
||||
<p>
|
||||
nuttx-0.3.10 is an important bug fix release.
|
||||
This release incorporates fixes to correct critical list handling errors
|
||||
in task shutdown logic: One in timer deletion logic (timer_delete.c) and one
|
||||
in stream logic (lib_init.c).
|
||||
nuttx-0.3.11 is another important bugfix release.
|
||||
This release fixes several bugs:
|
||||
</p>
|
||||
<ul>
|
||||
<li>Two POSIX timer bugs: a memory leak as well a fatal sequencing error.</li>
|
||||
<li>Several FAT filesystem errors.</li>
|
||||
<li>A deadlock that can occur in <code>opendir()</code></li>
|
||||
</ul>
|
||||
<p>
|
||||
Additional, minor enhancements includes support to ZiLOG EZ80Acclaim
|
||||
microcontrooler (EZ80F91 chip) and configurations fot the ZiLOG z8f64200100kit (Z8F6423)
|
||||
and ez80f0910200kitg (EZ80F091) development kit.
|
||||
A few new features were also added:
|
||||
</p>
|
||||
<ul>
|
||||
<li>Support for recursive mutexes</li>
|
||||
<li>Added a RAM disk block driver</li>
|
||||
<li>The host simulator no longer uses direct Linux system calls and now also works on Cygwin.</li>
|
||||
<li>The OS test was strengthen and now runs as an endurance test</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
As usual, any feedback about bugs or suggestions for improvement would be greatly appreciated.
|
||||
</p>
|
||||
|
@ -973,14 +981,18 @@ Other memory:
|
|||
</table>
|
||||
|
||||
<pre><ul>
|
||||
nuttx-0.3.10 2008-05-15 Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
nuttx-0.3.11 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
* Add support for the ZiLOG EZ80Acclaim microcontrooler (EZ80F91 chip).
|
||||
* Add configuration for the ZiLOG z8f64200100kit development kit, Z8F6423 part.
|
||||
* Add configuration for the ZiLOG ez80f0910200kitg development kit, EZ80F091 part.
|
||||
* Correct critical list handling errors in task shutdown logic: One in timer
|
||||
deletion logic (timer_delete.c) and one in stream logic (lib_init.c) reported
|
||||
by kwonsk.
|
||||
* Add support for recursive mutexes.
|
||||
* Eliminate a memory leak -- contained watchdog instance was not being
|
||||
deleted with a POSIX timer was deleted reported by kwonsk.
|
||||
* Eliminate a deadlock condition in opendir() reported by kwonsk.
|
||||
* Fix several FAT filesystem problems reported by kwonsk (Changes not yet
|
||||
verified).
|
||||
* Host simulator no longer uses Linux system calls directly; Now works with Cygwin.
|
||||
* Fix an error that occurs when a POSIX timer is deleted by the timer signal handler.
|
||||
* Add logic to allow the examples/ostest to be run repetitively as an endurance test.
|
||||
* Add a ramdisk block driver
|
||||
|
||||
pascal-0.1.2 2008-02-10 Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
|
@ -1006,17 +1018,7 @@ buildroot-0.1.0 2007-03-09 <spudmonkey@racsa.co.cr>
|
|||
</table>
|
||||
|
||||
<pre><ul>
|
||||
nuttx-0.3.11 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
* Add support for recursive mutexes.
|
||||
* Eliminate a memory leak -- contained watchdog instance was not being
|
||||
deleted with a POSIX timer was deleted reported by kwonsk.
|
||||
* Eliminate a deadlock condition in opendir() reported by kwonsk.
|
||||
* Fix several FAT filesystem problems reported by kwonsk (Changes not yet
|
||||
verified).
|
||||
* Host simulator no longer uses Linux system calls directly; Now works with Cygwin.
|
||||
* Fix an error that occurs when a POSIX timer is deleted by the timer signal handler.
|
||||
* Add logic to allow the examples/ostest to be run repetitively as an endurance test.
|
||||
nuttx-0.3.12 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
|
|
21
ReleaseNotes
21
ReleaseNotes
|
@ -452,4 +452,25 @@ in stream logic (lib_init.c). This release also includes support to ZiLOG EZ80A
|
|||
microcontrooler (EZ80F91 chip) and configurations fot the ZiLOG z8f64200100kit (Z8F6423)
|
||||
and ez80f0910200kitg (EZ80F091) development kit.
|
||||
|
||||
nuttx=0.3.11
|
||||
^^^^^^^^^^^^
|
||||
|
||||
This is the 23rd release of NuttX. This is another important bugfix release.
|
||||
This releases fixes several bugs:
|
||||
|
||||
* Two POSIX timer bugs: a memory leak as well a fatal sequencing error.
|
||||
* Several FAT filesystem errors.
|
||||
* A deadlock that can occur in opendir()
|
||||
|
||||
A few new features were also added:
|
||||
|
||||
* Support for recursive mutexes
|
||||
* Added a RAM disk block driver
|
||||
* The host simulator no longer uses direct Linux system calls and now also works on Cygwin.
|
||||
* The OS test was strengthen and now runs as an endurance test
|
||||
|
||||
These changes were verified only on the Host simulator under Cygwin. Please report
|
||||
any errors to me.
|
||||
|
||||
This tarball contains a complete CVS snapshot from June 1, 2008.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* up_blockdevice.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -38,11 +38,13 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <nuttx/fs.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/ramdisk.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -60,128 +62,14 @@
|
|||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int up_open(FAR struct inode *inode);
|
||||
static int up_close(FAR struct inode *inode);
|
||||
static ssize_t up_read(FAR struct inode *inode, unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors);
|
||||
static ssize_t up_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors);
|
||||
static int up_geometry(FAR struct inode *inode, struct geometry *geometry);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct block_operations g_bops =
|
||||
{
|
||||
.open = up_open,
|
||||
.close = up_close,
|
||||
.read = up_read,
|
||||
.write = up_write,
|
||||
.geometry = up_geometry,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_open
|
||||
*
|
||||
* Description: Open the block device
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int up_open(FAR struct inode *inode)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_closel
|
||||
*
|
||||
* Description: close the block device
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int up_close(FAR struct inode *inode)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_read
|
||||
*
|
||||
* Description: Read the specified numer of sectors
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t up_read(FAR struct inode *inode, unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors)
|
||||
{
|
||||
if (inode)
|
||||
{
|
||||
char *src = inode->i_private;
|
||||
if (src &&
|
||||
start_sector < NSECTORS &&
|
||||
start_sector + nsectors < NSECTORS)
|
||||
{
|
||||
memcpy(buffer,
|
||||
&src[start_sector*LOGICAL_SECTOR_SIZE],
|
||||
nsectors*LOGICAL_SECTOR_SIZE);
|
||||
return nsectors;
|
||||
}
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_write
|
||||
*
|
||||
* Description: Write the specified number of sectors
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t up_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors)
|
||||
{
|
||||
if (inode)
|
||||
{
|
||||
char *dest = inode->i_private;
|
||||
if (dest &&
|
||||
start_sector < NSECTORS &&
|
||||
start_sector + nsectors < NSECTORS)
|
||||
{
|
||||
memcpy(&dest[start_sector*LOGICAL_SECTOR_SIZE],
|
||||
buffer,
|
||||
nsectors*LOGICAL_SECTOR_SIZE);
|
||||
return nsectors;
|
||||
}
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_geometry
|
||||
*
|
||||
* Description: Return device geometry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int up_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||
{
|
||||
if (geometry)
|
||||
{
|
||||
geometry->geo_available = (inode->i_private != NULL);
|
||||
geometry->geo_mediachanged = FALSE;
|
||||
geometry->geo_writeenabled = TRUE;
|
||||
geometry->geo_nsectors = NSECTORS;
|
||||
geometry->geo_sectorsize = LOGICAL_SECTOR_SIZE;
|
||||
return OK;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -189,13 +77,11 @@ static int up_geometry(FAR struct inode *inode, struct geometry *geometry)
|
|||
/****************************************************************************
|
||||
* Name: up_registerblockdevice
|
||||
*
|
||||
* Description: Register the simulated block device
|
||||
|
||||
* Description: Register the FAT ramdisk
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_registerblockdevice(void)
|
||||
{
|
||||
/* Inode private data is a filesystem image */
|
||||
void *priv = (void*)up_deviceimage();
|
||||
(void)register_blockdriver("/dev/blkdev", &g_bops, 0, priv);
|
||||
rd_register(0, up_deviceimage(), NSECTORS, LOGICAL_SECTOR_SIZE, TRUE);
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ void up_initialize(void)
|
|||
|
||||
devnull_register(); /* Standard /dev/null */
|
||||
up_devconsole(); /* Our private /dev/console */
|
||||
up_registerblockdevice(); /* Our simulated block device /dev/blkdev */
|
||||
up_registerblockdevice(); /* Our FAT ramdisk at /dev/ram0 */
|
||||
#if defined(CONFIG_NET) && defined(linux)
|
||||
uipdriver_init(); /* Our "real" netwok driver */
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
############################################################################
|
||||
# configs/sim/Make.defs
|
||||
# configs/sim/mount/Make.defs
|
||||
#
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
############################################################################
|
||||
# sim/defconfig
|
||||
# sim/mount/defconfig
|
||||
#
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
@ -81,7 +81,7 @@ CONFIG_ARCH_BOARD_SIM=y
|
|||
# CONFIG_DEV_CONSOLE - Set if architecture-specific logic
|
||||
# provides /dev/console. Enables stdout, stderr, stdin.
|
||||
#
|
||||
CONFIG_EXAMPLE=ostest
|
||||
CONFIG_EXAMPLE=mount
|
||||
CONFIG_DEBUG=y
|
||||
CONFIG_DEBUG_VERBOSE=y
|
||||
CONFIG_MM_REGIONS=1
|
||||
|
@ -89,9 +89,9 @@ CONFIG_ARCH_LOWPUTC=y
|
|||
CONFIG_RR_INTERVAL=0
|
||||
CONFIG_SCHED_INSTRUMENTATION=n
|
||||
CONFIG_TASK_NAME_SIZE=32
|
||||
CONFIG_START_YEAR=2007
|
||||
CONFIG_START_MONTH=2
|
||||
CONFIG_START_DAY=27
|
||||
CONFIG_START_YEAR=2008
|
||||
CONFIG_START_MONTH=6
|
||||
CONFIG_START_DAY=1
|
||||
CONFIG_JULIAN_TIME=n
|
||||
CONFIG_DEV_CONSOLE=y
|
||||
|
||||
|
@ -298,6 +298,9 @@ CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
|
|||
CONFIG_EXAMPLES_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
|
||||
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
|
||||
|
||||
#
|
||||
# Settings for examples/mount
|
||||
CONFIG_EXAMPLES_MOUNT_DEVNAME="/dev/ram0"
|
||||
#
|
||||
# Stack and heap information
|
||||
#
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
# sim/setenv.sh
|
||||
#
|
||||
# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -45,6 +45,9 @@ AOBJS = $(ASRCS:.S=$(OBJEXT))
|
|||
CSRCS =
|
||||
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
CSRCS += dev_null.c dev_zero.c serial.c lowconsole.c can.c
|
||||
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
|
||||
CSRCS += ramdisk.c
|
||||
endif
|
||||
endif
|
||||
CSRCS += $(NET_CSRCS)
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
|
250
drivers/ramdisk.c
Normal file
250
drivers/ramdisk.c
Normal file
|
@ -0,0 +1,250 @@
|
|||
/****************************************************************************
|
||||
* drivers/ramdisk.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/fs.h>
|
||||
#include <nuttx/ramdisk.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct rd_struct_s
|
||||
{
|
||||
uint32 rd_nsectors; /* Number of sectors on device */
|
||||
uint16 rd_sectsize; /* The size of one sector */
|
||||
boolean rd_writeenabled; /* TRUE: can write to ram disk */
|
||||
ubyte *rd_buffer; /* RAM disk backup memory */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int rd_open(FAR struct inode *inode);
|
||||
static int rd_close(FAR struct inode *inode);
|
||||
static ssize_t rd_read(FAR struct inode *inode, unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors);
|
||||
static ssize_t rd_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors);
|
||||
static int rd_geometry(FAR struct inode *inode, struct geometry *geometry);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct block_operations g_bops =
|
||||
{
|
||||
rd_open, /* open */
|
||||
rd_close, /* close */
|
||||
rd_read, /* read */
|
||||
rd_write, /* write */
|
||||
rd_geometry, /* geometry */
|
||||
NULL /* ioctl */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rd_open
|
||||
*
|
||||
* Description: Open the block device
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int rd_open(FAR struct inode *inode)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rd_closel
|
||||
*
|
||||
* Description: close the block device
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int rd_close(FAR struct inode *inode)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rd_read
|
||||
*
|
||||
* Description: Read the specified numer of sectors
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t rd_read(FAR struct inode *inode, unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors)
|
||||
{
|
||||
struct rd_struct_s *dev;
|
||||
if (inode)
|
||||
{
|
||||
dev = (struct rd_struct_s *)inode->i_private;
|
||||
if (dev &&
|
||||
start_sector < dev->rd_nsectors &&
|
||||
start_sector + nsectors <= dev->rd_nsectors)
|
||||
{
|
||||
memcpy(buffer,
|
||||
&dev->rd_buffer[start_sector * dev->rd_sectsize],
|
||||
nsectors * dev->rd_sectsize);
|
||||
return nsectors;
|
||||
}
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rd_write
|
||||
*
|
||||
* Description: Write the specified number of sectors
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t rd_write(FAR struct inode *inode, const unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors)
|
||||
{
|
||||
struct rd_struct_s *dev;
|
||||
if (inode)
|
||||
{
|
||||
dev = (struct rd_struct_s *)inode->i_private;
|
||||
if (dev &&
|
||||
start_sector < dev->rd_nsectors &&
|
||||
start_sector + nsectors <= dev->rd_nsectors)
|
||||
{
|
||||
memcpy(&dev->rd_buffer[start_sector * dev->rd_sectsize],
|
||||
buffer,
|
||||
nsectors * dev->rd_sectsize);
|
||||
return nsectors;
|
||||
}
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rd_geometry
|
||||
*
|
||||
* Description: Return device geometry
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int rd_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||
{
|
||||
struct rd_struct_s *dev;
|
||||
if (inode && geometry)
|
||||
{
|
||||
dev = (struct rd_struct_s *)inode->i_private;
|
||||
geometry->geo_available = TRUE;
|
||||
geometry->geo_mediachanged = FALSE;
|
||||
geometry->geo_writeenabled = dev->rd_writeenabled;
|
||||
geometry->geo_nsectors = dev->rd_nsectors;
|
||||
geometry->geo_sectorsize = dev->rd_sectsize;
|
||||
return OK;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rd_register
|
||||
*
|
||||
* Description: Register the a ramdisk
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
int rd_register(int minor, ubyte *buffer, uint32 nsectors, uint16 sectsize,
|
||||
boolean writeenabled)
|
||||
{
|
||||
struct rd_struct_s *dev;
|
||||
char devname[16];
|
||||
int ret = -ENOMEM;
|
||||
|
||||
/* Sanity check */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (minor < 0 || minor > 255 || !buffer || !nsectors || !sectsize)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate a ramdisk device structure */
|
||||
|
||||
dev = (struct rd_struct_s *)malloc(sizeof(struct rd_struct_s));
|
||||
if (dev)
|
||||
{
|
||||
/* Initialize the ramdisk device structure */
|
||||
|
||||
dev->rd_nsectors = nsectors; /* Number of sectors on device */
|
||||
dev->rd_sectsize = sectsize; /* The size of one sector */
|
||||
dev->rd_writeenabled = writeenabled; /* TRUE: can write to ram disk */
|
||||
dev->rd_buffer = buffer; /* RAM disk backup memory */
|
||||
|
||||
/* Create a ramdisk device name */
|
||||
|
||||
snprintf(devname, 16, "/dev/ram%d", minor);
|
||||
|
||||
/* Inode private data is a reference to the ramdisk device stgructure */
|
||||
|
||||
ret = register_blockdriver(devname, &g_bops, 0, dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
free(dev);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
|
@ -107,6 +107,9 @@ examples/mount
|
|||
^^^^^^^^^^^^^^
|
||||
|
||||
This contains a simple test of filesystem mountpoints.
|
||||
|
||||
* CONFIG_EXAMPLES_MOUNT_DEVNAME
|
||||
The name of the device to mount. Default: "/dev/ram0"
|
||||
|
||||
examples/null
|
||||
^^^^^^^^^^^^^
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* mount_main.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -14,7 +14,7 @@
|
|||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
|
@ -54,6 +54,10 @@
|
|||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_MOUNT_DEVNAME
|
||||
# define CONFIG_EXAMPLES_MOUNT_DEVNAME "/dev/ram0"
|
||||
#endif
|
||||
|
||||
#define TEST_USE_STAT 1
|
||||
#define TEST_SHOW_DIRECTORIES 1
|
||||
#define TEST_USE_STATFS 1
|
||||
|
@ -66,7 +70,7 @@
|
|||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const char g_source[] = "/dev/blkdev";
|
||||
static const char g_source[] = CONFIG_EXAMPLES_MOUNT_DEVNAME;
|
||||
static const char g_mntdir[] = "/mnt";
|
||||
static const char g_target[] = "/mnt/fs";
|
||||
static const char g_filesystemtype[] = "vfat";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************
|
||||
/****************************************************************************
|
||||
* fs_registerblockdriver.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -14,7 +14,7 @@
|
|||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
|
@ -31,11 +31,11 @@
|
|||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -43,58 +43,60 @@
|
|||
#include <nuttx/fs.h>
|
||||
#include "fs_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Name: register_driver
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
STATUS register_blockdriver(const char *path,
|
||||
const struct block_operations *bops,
|
||||
mode_t mode, void *private)
|
||||
{
|
||||
struct inode *node;
|
||||
STATUS ret = ERROR;
|
||||
STATUS ret = -ENOMEM;
|
||||
|
||||
/* Insert a dummy node -- we need to hold the inode semaphore
|
||||
* to do this because we will have a momentarily bad structure.
|
||||
/* Insert an inode for the device driver -- we need to hold the inode semaphore
|
||||
* to prevent access to the tree while we this. This is because we will have a
|
||||
* momentarily bad true until we populate the inode with valid data.
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
node = inode_reserve(path);
|
||||
if (node != NULL)
|
||||
{
|
||||
/* We have it, now populate it with block driver specific
|
||||
* information.
|
||||
*/
|
||||
/* We have it, now populate it with block driver specific
|
||||
* information.
|
||||
*/
|
||||
|
||||
INODE_SET_BLOCK(node);
|
||||
INODE_SET_BLOCK(node);
|
||||
|
||||
node->u.i_bops = bops;
|
||||
node->u.i_bops = bops;
|
||||
#ifdef CONFIG_FILE_MODE
|
||||
node->i_mode = mode;
|
||||
node->i_mode = mode;
|
||||
#endif
|
||||
node->i_private = private;
|
||||
ret = OK;
|
||||
node->i_private = private;
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
inode_semgive();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************
|
||||
/****************************************************************************
|
||||
* nuttx/fat.h
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -14,7 +14,7 @@
|
|||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 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.
|
||||
*
|
||||
|
@ -31,20 +31,20 @@
|
|||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __SYS_FAT_H
|
||||
#define __SYS_FAT_H
|
||||
#ifndef __NUTTX_FAT_H
|
||||
#define __NUTTX_FAT_H
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/* File attribute bits in FAT directory entry */
|
||||
|
||||
|
@ -58,15 +58,15 @@
|
|||
#define FATATTR_LONGNAME \
|
||||
(FATATTR_READONLY|FATATTR_HIDDEN|FATATTR_SYSTEM|FATATTR_VOLUMEID)
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
typedef ubyte fat_attrib_t;
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
|
@ -87,4 +87,4 @@ EXTERN int fat_setattrib(const char *path, fat_attrib_t setbits, fat_attrib_t cl
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SYS_FAT_H */
|
||||
#endif /* __NUTTX_FAT_H */
|
||||
|
|
82
include/nuttx/ramdisk.h
Normal file
82
include/nuttx/ramdisk.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/****************************************************************************
|
||||
* nuttx/ramdisk.h
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 __NUTTX_RAMDISK_H
|
||||
#define __NUTTX_RAMDISK_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Non-standard function to register a ramdisk
|
||||
*
|
||||
* minor: Selects suffix of device named /dev/ramN, N={1,2,3...}
|
||||
* nsectors: Number of sectors on device
|
||||
* sectize: The size of one sector
|
||||
* writeenabled: TRUE: can write to ram disk
|
||||
* buffer: RAM disk backup memory
|
||||
*/
|
||||
|
||||
EXTERN int rd_register(int minor, ubyte *buffer, uint32 nsectors,
|
||||
uint16 sectize, boolean writeenabled);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NUTTX_RAMDISK_H */
|
Loading…
Reference in a new issue