This commit corrects a problem with NSH: NSH was calling the OS internal function ramdisk_register() in violation of the portable POSIX interface. This commit solves the problem by introducing a new boardctl() function BOARDIOC_MKRD which moves the RAM disk creation into the OS.

Squashed commit of the following:

    drivers/:  Run tools/nxstyle against all drivers/*.c.

    boards/boardctl.c:  Add new boardctl() command, BOARDIOC_MKRD, that can be used to create a RAM disk.  This will replace the illegal call to ramdisk_register() currently used by NSH.

    drivers/mkrd.c:  Add wrapper around ramdisk_register() for creating a proper ramdisk.
This commit is contained in:
Gregory Nutt
2019-10-26 09:35:32 -06:00
parent dae3640dc5
commit be325924fb
7 changed files with 96 additions and 18 deletions
+28 -2
View File
@@ -48,6 +48,7 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Values for rdflags */
#define RDFLAG_WRENABLED (1 << 0) /* Bit 0: 1=Can write to RAM disk */
@@ -93,11 +94,36 @@ extern "C"
#ifdef CONFIG_FS_WRITABLE
int ramdisk_register(int minor, FAR uint8_t *buffer, uint32_t nsectors,
uint16_t sectize, uint8_t rdflags);
uint16_t sectsize, uint8_t rdflags);
#define romdisk_register(m,b,n,s) ramdisk_register(m,(FAR uint8_t *)b,n,s,0)
#else
int romdisk_register(int minor, FAR const uint8_t *buffer, uint32_t nsectors,
uint16_t sectize);
uint16_t sectsize);
#endif
/****************************************************************************
* 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.
*
****************************************************************************/
#ifdef CONFIG_FS_WRITABLE
int mkrd(int minor, uint32_t nsectors, uint16_t sectsize, uint8_t rdflags);
#endif
#undef EXTERN
+29 -10
View File
@@ -96,6 +96,12 @@
* which to receive the board unique ID.
* DEPENDENCIES: Board logic must provide the board_uniqueid() interface.
*
* CMD: BOARDIOC_MKRD
* DESCRIPTION: Create a RAM disk
* ARG: Pointer to read-only instance of struct boardioc_mkrd_s.
* CONFIGURATION: CONFIG_FS_WRITABLE
* DEPENDENCIES: None
*
* CMD: BOARDIOC_APP_SYMTAB
* DESCRIPTION: Select the application symbol table. This symbol table
* provides the symbol definitions exported to application
@@ -181,15 +187,16 @@
#define BOARDIOC_POWEROFF _BOARDIOC(0x0003)
#define BOARDIOC_RESET _BOARDIOC(0x0004)
#define BOARDIOC_UNIQUEID _BOARDIOC(0x0005)
#define BOARDIOC_APP_SYMTAB _BOARDIOC(0x0006)
#define BOARDIOC_OS_SYMTAB _BOARDIOC(0x0007)
#define BOARDIOC_BUILTINS _BOARDIOC(0x0008)
#define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x0009)
#define BOARDIOC_NX_START _BOARDIOC(0x000a)
#define BOARDIOC_VNC_START _BOARDIOC(0x000b)
#define BOARDIOC_NXTERM _BOARDIOC(0x000c)
#define BOARDIOC_NXTERM_IOCTL _BOARDIOC(0x000d)
#define BOARDIOC_TESTSET _BOARDIOC(0x000e)
#define BOARDIOC_MKRD _BOARDIOC(0x0006)
#define BOARDIOC_APP_SYMTAB _BOARDIOC(0x0007)
#define BOARDIOC_OS_SYMTAB _BOARDIOC(0x0008)
#define BOARDIOC_BUILTINS _BOARDIOC(0x0009)
#define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x000a)
#define BOARDIOC_NX_START _BOARDIOC(0x000b)
#define BOARDIOC_VNC_START _BOARDIOC(0x000c)
#define BOARDIOC_NXTERM _BOARDIOC(0x000d)
#define BOARDIOC_NXTERM_IOCTL _BOARDIOC(0x000e)
#define BOARDIOC_TESTSET _BOARDIOC(0x000f)
/* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support.
* In this case, all commands not recognized by boardctl() will be forwarded
@@ -198,7 +205,7 @@
* User defined board commands may begin with this value:
*/
#define BOARDIOC_USER _BOARDIOC(0x000f)
#define BOARDIOC_USER _BOARDIOC(0x0010)
/****************************************************************************
* Public Type Definitions
@@ -206,6 +213,18 @@
/* Structures used with IOCTL commands */
#ifdef CONFIG_FS_WRITABLE
/* Describes the RAM disk to be created */
struct boardioc_mkrd_s
{
uint8_t minor; /* Minor device number of the RAM disk. */
uint32_t nsectors; /* The number of sectors in the RAM disk */
uint16_t sectsize; /* The size of one sector in bytes */
uint8_t rdflags; /* See RD_FLAGS_* definitions in include/nuttx/ramdisk.h */
};
#endif
/* In order to full describe a symbol table, a vector containing the address
* of the symbol table and the number of elements in the symbol table is
* required.