drivers/mkrd.c: Forgot to add file in last commit.
This commit is contained in:
parent
be325924fb
commit
03bf18d097
49
TODO
49
TODO
|
@ -37,7 +37,7 @@ apps/ and other Add-Ons:
|
|||
(1) System libraries apps/system (apps/system)
|
||||
(1) Modbus (apps/modbus)
|
||||
(1) Pascal add-on (pcode/)
|
||||
(4) Other Applications & Tests (apps/examples/)
|
||||
(5) Other Applications & Tests (apps/examples/)
|
||||
|
||||
o Task/Scheduler (sched/)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -927,20 +927,21 @@ o Kernel/Protected Build
|
|||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Title: NSH PARTITIONING.
|
||||
Description: There are issues with several NSH commands in the NuttX kernel
|
||||
and protected build modes (where NuttX is built as a monolithic
|
||||
kernel and user code must trap into the protected kernel via
|
||||
syscalls). The current NSH implementation has several commands
|
||||
that call directly into kernel internal functions for which
|
||||
there is no syscall available. The commands cause link failures
|
||||
in the kernel/protected build mode and must currently be disabled.
|
||||
Here are known problems that must be fixed:
|
||||
Description: There are issues with NSH in the NuttX kernel and protected
|
||||
build modes (where NuttX is built as a monolithic kernel and
|
||||
user code must trap into the protected kernel via syscalls).
|
||||
This can cause link failures in the kernel/protected build
|
||||
mode and must currently be disabled.
|
||||
|
||||
COMMAND KERNEL INTERFACE(s)
|
||||
-------- ----------------------------------------------
|
||||
mkrd ramdisk_register()
|
||||
Many such issues have been fixed. Here are the known
|
||||
remaingin problems that must be fixed:
|
||||
|
||||
See http://www.nuttx.org/doku.php?id=wiki:howtos:protected-ramdisk
|
||||
- apps/nshlib/nsh_romfsetc.c: The function nsh_romfsetc()
|
||||
calles romdisk_register() directly in order to register
|
||||
the application ROMFS file system. This logic needs to
|
||||
be redesigned. The best solution would simply to be to
|
||||
to create the romdisk in the board start-up logic. This
|
||||
would, however, have impacts to NuttX users.
|
||||
|
||||
Status: Open
|
||||
Priority: Medium/High -- the kernel build configuration is not fully fielded
|
||||
|
@ -2734,6 +2735,8 @@ o Network Utilities (apps/netutils/)
|
|||
o NuttShell (NSH) (apps/nshlib)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
See some NHS issues under "Kernel/Protected Build" as well.
|
||||
|
||||
Title: IFCONFIG AND MULTIPLE NETWORK INTERFACES
|
||||
Description: The ifconfig command will not behave correctly if an interface
|
||||
is provided and there are multiple interfaces. It should only
|
||||
|
@ -2840,3 +2843,23 @@ o Other Applications & Tests (apps/examples/)
|
|||
the artifact is larger.
|
||||
Status: Open
|
||||
Priority: Medium.
|
||||
|
||||
Title: ILLEGAL CALLS TO romdisk_register()
|
||||
Desription: Several examples (and other things under apps/) make illegal
|
||||
calls to romdisk_register(). This both violates the portable
|
||||
POSIX OS interface and makes these applications un-usable in
|
||||
PROTECTED and KERNEL build modes.
|
||||
|
||||
Non-compliant examples include:
|
||||
|
||||
examples/bastest, examples/elf, examples/module,
|
||||
examples/nxflat, examples/posix_spawn, examples/romfs,
|
||||
examples/sotest, examples/thttpd, examples/unionfs
|
||||
|
||||
Other non-compliant logic:
|
||||
|
||||
graphics/traveler/trv_romfs.c, nshlib/nsh_romfsetc.c
|
||||
|
||||
The NSH issue is listed under"Kernel/Protected Build" as well.
|
||||
Status: Open
|
||||
Priority: Medium.
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/****************************************************************************
|
||||
* drivers/mkrd.c
|
||||
*
|
||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* 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 <nuttx/kmalloc.h>
|
||||
#include <nuttx/drivers/ramdisk.h>
|
||||
|
||||
#ifdef CONFIG_FS_WRITABLE
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mkrd
|
||||
*
|
||||
* Description:
|
||||
* This is a wrapper function around ramdisk_register. It combines the
|
||||
* necessary operations to create a RAM disk into a single callable
|
||||
* function. Memory for the RAM disk is allocated, appropriated, from
|
||||
* the kernel heap (in build modes where there is a distinct kernel heap).
|
||||
*
|
||||
* Input Parameters:
|
||||
* minor: Selects suffix of device named /dev/ramN, N={1,2,3...}
|
||||
* nsectors: Number of sectors on device
|
||||
* sectize: The size of one sector
|
||||
* rdflags: See RDFLAG_* definitions. Typically
|
||||
* RDFLAG_WRENABLED | RDFLAG_FUNLINK
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mkrd(int minor, uint32_t nsectors, uint16_t sectsize, uint8_t rdflags)
|
||||
{
|
||||
FAR uint8_t *buffer;
|
||||
int ret;
|
||||
|
||||
/* Allocate the memory backing up the ramdisk from the kernel heap */
|
||||
|
||||
buffer = (FAR uint8_t *)kmm_malloc(sectsize * nsectors);
|
||||
if (buffer == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_INFO
|
||||
memset(buffer, 0, sectsize * nsectors);
|
||||
#endif
|
||||
finfo("RAMDISK at %p\n", buffer);
|
||||
|
||||
/* Then register the ramdisk */
|
||||
|
||||
ret = ramdisk_register(minor, buffer, nsectors, sectsize, rdflags);
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: ramdisk_register() failed: %d\n", ret);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FS_WRITABLE */
|
Loading…
Reference in New Issue