mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
This commit brings in the drivers needed to support OpenAMP. These changes were ported from https://github.com/FishsemiCode/nuttx. The current state: Most drivers do now compile but are not yet verfied.
This port was effort of a number of people, I rather arbitrarily gave authorship to Guiding Li because he has the largest number of fundamental quashed commits from the Xiamoi repository. Squashed commit of the following: Author: Xiang Xiao <xiaoxiang@pinecone.net> include/nuttx/b2c.h and libx/libc/string: Add non-standard string functions to deal with cases where there are more than 8-bits in a type char. Author: Gregory Nutt <gnutt@nuttx.org> Fix several build issues/missing definitiona needed for OpenAMP build in drivers/. Add OpenAMP code has been reviewed and ran through tools/nxstyle (with all reports accounted for). Author: Xiang Xiao <xiaoxiang@xiaomi.com> tools/: Fix the minor issue in Makefile Author: Gregory Nutt <gnutt@nuttx.org> drivers/rptun/rptun.c: Review for coding standard. Run against tools/nxstyle. tools/LibTargets.mk: Fix some TABs that were turned into spaces by a copy-paste. fs/hostfs: Add configure and build support for hostfs RPC. drivers/timer: Add configure and build support for syslog RTC. drivers/syslog: Add configure and build support for syslog RPC. drivers/serial: Add configure and build support for serial RPC. Kconfig, tools/*.mk. openamp/: Add basic OpenAMP build support. drivers/rptun: Add configure and build support for OpenAMP tunnel drivers. drivers/net: Update Make.defs and Kconfig for OpenSDA support. Remove drivers/clk/clk-rpmsg.c drivers/power/rpmsg_regulator.c. These depend on upstreaming support for a new subsystem based on the clk/regulator is model from Linux. Removed because we want to separate the activities. We will just try to get the basic OpenAMP support in place for now. Remove drivers/misc/misc_rpmsg.c and include/nuttx/misc/misc_rpmsg.h. These are specific to the Xiaomi application. Author: zhuyanlin <zhuyanlin@pinecone.net> This commit brings in the OpenAMP OS driver/RPC components from https://github.com/FishsemiCode/nuttx. Initial commit is source files only. Additional changes to Kconfig and Make.defs files still needed. Author: Jianli Dong <dongjianli@pinecone.net> This commit brings in the OpenAMP OS driver/RPC components from https://github.com/FishsemiCode/nuttx. Initial commit is source files only. Additional changes to Kconfig and Make.defs files still needed. Author: Guiding Li <liguiding@pinecone.net> This commit brings in the OpenAMP OS driver/RPC components from https://github.com/FishsemiCode/nuttx. Initial commit is source files only. Additional changes to Kconfig and Make.defs files still needed.
This commit is contained in:
@@ -1799,6 +1799,11 @@ source libs/libxx/Kconfig
|
|||||||
source libs/libdsp/Kconfig
|
source libs/libdsp/Kconfig
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
menu "Open Asymmetric Multi Processing"
|
||||||
|
source openamp/Kconfig
|
||||||
|
endmenu
|
||||||
|
|
||||||
menu "Application Configuration"
|
menu "Application Configuration"
|
||||||
source "$APPSDIR/Kconfig"
|
source "$APPSDIR/Kconfig"
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
|||||||
@@ -312,6 +312,17 @@ endif # PIPES
|
|||||||
|
|
||||||
source drivers/power/Kconfig
|
source drivers/power/Kconfig
|
||||||
|
|
||||||
|
menuconfig RPTUN
|
||||||
|
bool "Remote Proc Tunnel Driver Support"
|
||||||
|
default n
|
||||||
|
depends on OPENAMP
|
||||||
|
---help---
|
||||||
|
RPTUN driver is used for multi-cores' communication.
|
||||||
|
|
||||||
|
if RPTUN
|
||||||
|
source drivers/rptun/Kconfig
|
||||||
|
endif # RPTUN
|
||||||
|
|
||||||
menuconfig SENSORS
|
menuconfig SENSORS
|
||||||
bool "Sensor Device Support"
|
bool "Sensor Device Support"
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ include eeprom$(DELIM)Make.defs
|
|||||||
include net$(DELIM)Make.defs
|
include net$(DELIM)Make.defs
|
||||||
include pipes$(DELIM)Make.defs
|
include pipes$(DELIM)Make.defs
|
||||||
include power$(DELIM)Make.defs
|
include power$(DELIM)Make.defs
|
||||||
|
include rptun$(DELIM)Make.defs
|
||||||
include sensors$(DELIM)Make.defs
|
include sensors$(DELIM)Make.defs
|
||||||
include serial$(DELIM)Make.defs
|
include serial$(DELIM)Make.defs
|
||||||
include spi$(DELIM)Make.defs
|
include spi$(DELIM)Make.defs
|
||||||
|
|||||||
@@ -16,6 +16,29 @@ config NETDEV_LOOPBACK
|
|||||||
if NETDEV_LOOPBACK
|
if NETDEV_LOOPBACK
|
||||||
endif # NETDEV_LOOPBACK
|
endif # NETDEV_LOOPBACK
|
||||||
|
|
||||||
|
config NET_RPMSG_DRV
|
||||||
|
bool "RPMSG net driver"
|
||||||
|
depends on NET && OPENAMP
|
||||||
|
select ARCH_HAVE_NETDEV_STATISTICS
|
||||||
|
---help---
|
||||||
|
Use the rpmsg as net device, transfer packet between remoteproc.
|
||||||
|
|
||||||
|
if NET_RPMSG_DRV
|
||||||
|
|
||||||
|
config NET_RPMSG_PRIORITY
|
||||||
|
int "net prmsg priority"
|
||||||
|
default 100
|
||||||
|
---help---
|
||||||
|
The priority for net rmpsg task.
|
||||||
|
|
||||||
|
config NET_RPMSG_STACKSIZE
|
||||||
|
int "net rpmsg stack size"
|
||||||
|
default 2048
|
||||||
|
---help---
|
||||||
|
The stack size allocated for the net rpmsg task.
|
||||||
|
|
||||||
|
endif # NET_RPMSG_DRV
|
||||||
|
|
||||||
config NETDEV_TELNET
|
config NETDEV_TELNET
|
||||||
bool "Telnet driver"
|
bool "Telnet driver"
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ ifeq ($(CONFIG_NETDEV_LOOPBACK),y)
|
|||||||
CSRCS += loopback.c
|
CSRCS += loopback.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NET_RPMSG_DRV),y)
|
||||||
|
CSRCS += rpmsgdrv.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_NETDEV_TELNET),y)
|
ifeq ($(CONFIG_NETDEV_TELNET),y)
|
||||||
CSRCS += telnet.c
|
CSRCS += telnet.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
|
#
|
||||||
|
|
||||||
|
if RPTUN
|
||||||
|
|
||||||
|
config RPTUN_PRIORITY
|
||||||
|
int "rpturn thread priority"
|
||||||
|
default 224
|
||||||
|
|
||||||
|
config RPTUN_STACKSIZE
|
||||||
|
int "rptun stack size"
|
||||||
|
default 2048
|
||||||
|
|
||||||
|
endif
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
############################################################################
|
||||||
|
# drivers/rptun/Make.defs
|
||||||
|
#
|
||||||
|
# Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
# Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Don't build anything if there is no RPTUN support
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_RPTUN),y)
|
||||||
|
|
||||||
|
CSRCS += rptun.c
|
||||||
|
|
||||||
|
DEPPATH += --dep-path rptun
|
||||||
|
VPATH += :rptun
|
||||||
|
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)rptun}
|
||||||
|
endif
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,21 @@ config MCU_SERIAL
|
|||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
config RPMSG_UART
|
||||||
|
bool "UART rpmsg support"
|
||||||
|
default n
|
||||||
|
depends on OPENAMP
|
||||||
|
select ARCH_HAVE_SERIAL_TERMIOS
|
||||||
|
select SERIAL_RXDMA
|
||||||
|
select SERIAL_TXDMA
|
||||||
|
select SERIAL_REMOVABLE
|
||||||
|
select SERIAL_IFLOWCONTROL
|
||||||
|
|
||||||
|
config RPMSG_SERIALINIT
|
||||||
|
bool "Add dummy up_serialinit for UART rpmsg"
|
||||||
|
default !16550_UART && !CMSDK_UART && !MCU_SERIAL
|
||||||
|
depends on RPMSG_UART
|
||||||
|
|
||||||
#
|
#
|
||||||
# Standard serial driver configuration
|
# Standard serial driver configuration
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ ifeq ($(CONFIG_16550_UART),y)
|
|||||||
CSRCS += uart_16550.c
|
CSRCS += uart_16550.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_RPMSG_UART),y)
|
||||||
|
CSRCS += uart_rpmsg.c
|
||||||
|
endif
|
||||||
|
|
||||||
# termios support
|
# termios support
|
||||||
|
|
||||||
ifeq ($(CONFIG_SERIAL_TERMIOS),y)
|
ifeq ($(CONFIG_SERIAL_TERMIOS),y)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -172,6 +172,14 @@ config SYSLOG_CONSOLE
|
|||||||
---help---
|
---help---
|
||||||
Use the system console as a SYSLOG output device.
|
Use the system console as a SYSLOG output device.
|
||||||
|
|
||||||
|
config SYSLOG_RPMSG
|
||||||
|
bool "Log to RPMSG"
|
||||||
|
depends on OPENAMP
|
||||||
|
depends on SCHED_WORKQUEUE
|
||||||
|
select SYSLOG_WRITE
|
||||||
|
---help---
|
||||||
|
Use the rpmsg as a SYSLOG output device, send message to remote proc.
|
||||||
|
|
||||||
config SYSLOG_NONE
|
config SYSLOG_NONE
|
||||||
bool "No SYSLOG device"
|
bool "No SYSLOG device"
|
||||||
---help---
|
---help---
|
||||||
@@ -180,6 +188,18 @@ config SYSLOG_NONE
|
|||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
|
config SYSLOG_RPMSG_WORK_DELAY
|
||||||
|
int "SYSLOG RPMSG work delay(ms)"
|
||||||
|
default 100
|
||||||
|
depends on SYSLOG_RPMSG
|
||||||
|
|
||||||
|
config SYSLOG_RPMSG_SERVER
|
||||||
|
bool "Enable RPMSG server for SYSLOG"
|
||||||
|
default n
|
||||||
|
depends on OPENAMP
|
||||||
|
---help---
|
||||||
|
Use rpmsg to receive message from remote proc.
|
||||||
|
|
||||||
config SYSLOG_FILE
|
config SYSLOG_FILE
|
||||||
bool "Syslog file output"
|
bool "Syslog file output"
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -84,6 +84,14 @@ ifeq ($(CONFIG_SYSLOG_CHARDEV),y)
|
|||||||
CSRCS += syslog_chardev.c
|
CSRCS += syslog_chardev.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SYSLOG_RPMSG),y)
|
||||||
|
CSRCS += syslog_rpmsg.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SYSLOG_RPMSG_SERVER),y)
|
||||||
|
CSRCS += syslog_rpmsg_server.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_CONSOLE_SYSLOG),y)
|
ifeq ($(CONFIG_CONSOLE_SYSLOG),y)
|
||||||
CSRCS += syslog_console.c
|
CSRCS += syslog_console.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -0,0 +1,417 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/syslog/syslog_rpmsg.c
|
||||||
|
* Syslog driver for rpmsg syslog
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/rptun/openamp.h>
|
||||||
|
#include <nuttx/syslog/syslog.h>
|
||||||
|
#include <nuttx/syslog/syslog_rpmsg.h>
|
||||||
|
#include <nuttx/wqueue.h>
|
||||||
|
|
||||||
|
#include "syslog.h"
|
||||||
|
#include "syslog_rpmsg.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define SYSLOG_RPMSG_WORK_DELAY MSEC2TICK(CONFIG_SYSLOG_RPMSG_WORK_DELAY)
|
||||||
|
|
||||||
|
#define SYSLOG_RPMSG_COUNT(h, t, size) ((B2C_OFF(h)>=(t)) ? \
|
||||||
|
B2C_OFF(h)-(t) : \
|
||||||
|
(size)-((t)-B2C_OFF(h)))
|
||||||
|
#define SYSLOG_RPMSG_SPACE(h, t, size) ((size) - 1 - SYSLOG_RPMSG_COUNT(h, t, size))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct syslog_rpmsg_s
|
||||||
|
{
|
||||||
|
volatile size_t head; /* The head index (where data is added) */
|
||||||
|
volatile size_t tail; /* The tail index (where data is removed) */
|
||||||
|
size_t size; /* Size of the RAM buffer */
|
||||||
|
FAR char *buffer; /* Circular RAM buffer */
|
||||||
|
struct work_s work; /* Used for deferred callback work */
|
||||||
|
|
||||||
|
struct rpmsg_endpoint ept;
|
||||||
|
FAR const char *cpuname;
|
||||||
|
bool suspend;
|
||||||
|
bool transfer; /* The transfer flag */
|
||||||
|
ssize_t trans_len; /* The data length when transfer */
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void syslog_rpmsg_work(FAR void *priv_);
|
||||||
|
static void syslog_rpmsg_putc(FAR struct syslog_rpmsg_s *priv, int ch,
|
||||||
|
bool last);
|
||||||
|
static int syslog_rpmsg_flush(void);
|
||||||
|
static ssize_t syslog_rpmsg_write(FAR const char *buffer, size_t buflen);
|
||||||
|
static void syslog_rpmsg_device_created(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv_);
|
||||||
|
static void syslog_rpmsg_device_destroy(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv_);
|
||||||
|
static int syslog_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||||
|
FAR void *data, size_t len, uint32_t src,
|
||||||
|
FAR void *priv_);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static struct syslog_rpmsg_s g_syslog_rpmsg;
|
||||||
|
|
||||||
|
static const struct syslog_channel_s g_syslog_rpmsg_channel =
|
||||||
|
{
|
||||||
|
up_putc,
|
||||||
|
up_putc,
|
||||||
|
syslog_rpmsg_flush,
|
||||||
|
syslog_rpmsg_write,
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void syslog_rpmsg_work(FAR void *priv_)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_transfer_s *msg = NULL;
|
||||||
|
FAR struct syslog_rpmsg_s *priv = priv_;
|
||||||
|
irqstate_t flags;
|
||||||
|
uint32_t space;
|
||||||
|
size_t len;
|
||||||
|
size_t len_end;
|
||||||
|
|
||||||
|
if (is_rpmsg_ept_ready(&priv->ept))
|
||||||
|
{
|
||||||
|
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg)
|
||||||
|
{
|
||||||
|
work_queue(HPWORK, &priv->work, syslog_rpmsg_work, priv,
|
||||||
|
SYSLOG_RPMSG_WORK_DELAY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(msg, 0, sizeof(*msg));
|
||||||
|
|
||||||
|
flags = enter_critical_section();
|
||||||
|
|
||||||
|
if (B2C_REM(priv->head))
|
||||||
|
{
|
||||||
|
priv->head += C2B(1) - B2C_REM(priv->head);
|
||||||
|
}
|
||||||
|
|
||||||
|
space -= sizeof(*msg);
|
||||||
|
len = SYSLOG_RPMSG_COUNT(priv->head, priv->tail, priv->size);
|
||||||
|
len_end = priv->size - priv->tail;
|
||||||
|
|
||||||
|
if (len > space)
|
||||||
|
{
|
||||||
|
len = space;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > len_end)
|
||||||
|
{
|
||||||
|
memcpy(msg->data, &priv->buffer[priv->tail], len_end);
|
||||||
|
memcpy(msg->data + len_end, priv->buffer, len - len_end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy(msg->data, &priv->buffer[priv->tail], len);
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->trans_len = len;
|
||||||
|
priv->transfer = true;
|
||||||
|
|
||||||
|
leave_critical_section(flags);
|
||||||
|
|
||||||
|
msg->header.command = SYSLOG_RPMSG_TRANSFER;
|
||||||
|
msg->count = C2B(len);
|
||||||
|
rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void syslog_rpmsg_putc(FAR struct syslog_rpmsg_s *priv, int ch,
|
||||||
|
bool last)
|
||||||
|
{
|
||||||
|
if (B2C_REM(priv->head) == 0)
|
||||||
|
{
|
||||||
|
priv->buffer[B2C_OFF(priv->head)] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->buffer[B2C_OFF(priv->head)] |= (ch & 0xff) << (8 * B2C_REM(priv->head));
|
||||||
|
|
||||||
|
priv->head += 1;
|
||||||
|
if (priv->head >= C2B(priv->size))
|
||||||
|
{
|
||||||
|
priv->head = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allow overwrite */
|
||||||
|
|
||||||
|
if (priv->head == C2B(priv->tail))
|
||||||
|
{
|
||||||
|
priv->buffer[priv->tail] = 0;
|
||||||
|
|
||||||
|
priv->tail += 1;
|
||||||
|
if (priv->tail >= priv->size)
|
||||||
|
{
|
||||||
|
priv->tail = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->transfer)
|
||||||
|
{
|
||||||
|
priv->trans_len--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last && !priv->suspend && !priv->transfer)
|
||||||
|
{
|
||||||
|
clock_t delay = SYSLOG_RPMSG_WORK_DELAY;
|
||||||
|
size_t space = SYSLOG_RPMSG_SPACE(priv->head, priv->tail, priv->size);
|
||||||
|
|
||||||
|
/* Start work immediately when data more then 75% and meet '\n' */
|
||||||
|
|
||||||
|
if (space < priv->size / 4 && ch == '\n')
|
||||||
|
{
|
||||||
|
delay = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
work_queue(HPWORK, &priv->work, syslog_rpmsg_work, priv, delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int syslog_rpmsg_flush(void)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_s *priv = &g_syslog_rpmsg;
|
||||||
|
|
||||||
|
work_queue(HPWORK, &priv->work, syslog_rpmsg_work, priv, 0);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t syslog_rpmsg_write(FAR const char *buffer, size_t buflen)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_s *priv = &g_syslog_rpmsg;
|
||||||
|
irqstate_t flags;
|
||||||
|
size_t nwritten;
|
||||||
|
|
||||||
|
flags = enter_critical_section();
|
||||||
|
for (nwritten = 1; nwritten <= buflen; nwritten++)
|
||||||
|
{
|
||||||
|
syslog_rpmsg_putc(priv, *buffer++, nwritten == buflen);
|
||||||
|
}
|
||||||
|
|
||||||
|
leave_critical_section(flags);
|
||||||
|
|
||||||
|
return buflen;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void syslog_rpmsg_device_created(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv_)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_s *priv = priv_;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (priv->buffer && strcmp(priv->cpuname, rpmsg_get_cpuname(rdev)) == 0)
|
||||||
|
{
|
||||||
|
priv->ept.priv = priv;
|
||||||
|
|
||||||
|
ret = rpmsg_create_ept(&priv->ept, rdev, SYSLOG_RPMSG_EPT_NAME,
|
||||||
|
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
|
||||||
|
syslog_rpmsg_ept_cb, NULL);
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
work_queue(HPWORK, &priv->work,
|
||||||
|
syslog_rpmsg_work, priv, SYSLOG_RPMSG_WORK_DELAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void syslog_rpmsg_device_destroy(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv_)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_s *priv = priv_;
|
||||||
|
|
||||||
|
if (priv->buffer && strcmp(priv->cpuname, rpmsg_get_cpuname(rdev)) == 0)
|
||||||
|
{
|
||||||
|
rpmsg_destroy_ept(&priv->ept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int syslog_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data,
|
||||||
|
size_t len, uint32_t src, FAR void *priv_)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_s *priv = priv_;
|
||||||
|
FAR struct syslog_rpmsg_header_s *header = data;
|
||||||
|
|
||||||
|
if (header->command == SYSLOG_RPMSG_SUSPEND)
|
||||||
|
{
|
||||||
|
work_cancel(HPWORK, &priv->work);
|
||||||
|
priv->suspend = true;
|
||||||
|
}
|
||||||
|
else if (header->command == SYSLOG_RPMSG_RESUME)
|
||||||
|
{
|
||||||
|
priv->suspend = false;
|
||||||
|
work_queue(HPWORK, &priv->work,
|
||||||
|
syslog_rpmsg_work, priv, SYSLOG_RPMSG_WORK_DELAY);
|
||||||
|
}
|
||||||
|
else if (header->command == SYSLOG_RPMSG_TRANSFER_DONE)
|
||||||
|
{
|
||||||
|
irqstate_t flags;
|
||||||
|
ssize_t len_end;
|
||||||
|
|
||||||
|
flags = enter_critical_section();
|
||||||
|
|
||||||
|
if (priv->trans_len > 0)
|
||||||
|
{
|
||||||
|
len_end = priv->size - priv->tail;
|
||||||
|
|
||||||
|
if (priv->trans_len > len_end)
|
||||||
|
{
|
||||||
|
memset(&priv->buffer[priv->tail], 0, len_end);
|
||||||
|
memset(priv->buffer, 0, priv->trans_len - len_end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset(&priv->buffer[priv->tail], 0, priv->trans_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->tail += priv->trans_len;
|
||||||
|
if (priv->tail >= priv->size)
|
||||||
|
{
|
||||||
|
priv->tail -= priv->size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->transfer = false;
|
||||||
|
|
||||||
|
if (SYSLOG_RPMSG_COUNT(priv->head, priv->tail, priv->size))
|
||||||
|
{
|
||||||
|
work_queue(HPWORK, &priv->work, syslog_rpmsg_work, priv, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
leave_critical_section(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int up_putc(int ch)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_s *priv = &g_syslog_rpmsg;
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
|
flags = enter_critical_section();
|
||||||
|
syslog_rpmsg_putc(priv, ch, true);
|
||||||
|
leave_critical_section(flags);
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
int syslog_rpmsg_init_early(FAR const char *cpuname, FAR void *buffer,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_s *priv = &g_syslog_rpmsg;
|
||||||
|
char prev, cur;
|
||||||
|
size_t i;
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
priv->cpuname = cpuname;
|
||||||
|
priv->buffer = buffer;
|
||||||
|
priv->size = size;
|
||||||
|
|
||||||
|
prev = (priv->buffer[size - 1] >> (CHAR_BIT - 8)) & 0xff;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j * 8 < CHAR_BIT; j++)
|
||||||
|
{
|
||||||
|
cur = (priv->buffer[i] >> j * 8) & 0xff;
|
||||||
|
|
||||||
|
if (!isascii(cur))
|
||||||
|
{
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev && !cur)
|
||||||
|
{
|
||||||
|
priv->head = C2B(i) + j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!prev && cur)
|
||||||
|
{
|
||||||
|
priv->tail = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (i != size)
|
||||||
|
{
|
||||||
|
priv->head = priv->tail = 0;
|
||||||
|
memset(priv->buffer, 0, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return syslog_channel(&g_syslog_rpmsg_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
int syslog_rpmsg_init(void)
|
||||||
|
{
|
||||||
|
return rpmsg_register_callback(&g_syslog_rpmsg,
|
||||||
|
syslog_rpmsg_device_created,
|
||||||
|
syslog_rpmsg_device_destroy,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/syslog/syslog_rpmsg.h
|
||||||
|
* Syslog driver for rpmsg syslog
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 __DRIVERS_SYSLOG_SYSLOG_RPMSG_H
|
||||||
|
#define __DRIVERS_SYSLOG_SYSLOG_RPMSG_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define SYSLOG_RPMSG_EPT_NAME "rpmsg-syslog"
|
||||||
|
|
||||||
|
#define SYSLOG_RPMSG_TRANSFER 0
|
||||||
|
#define SYSLOG_RPMSG_TRANSFER_DONE 1
|
||||||
|
#define SYSLOG_RPMSG_SUSPEND 2
|
||||||
|
#define SYSLOG_RPMSG_RESUME 3
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
begin_packed_struct struct syslog_rpmsg_header_s
|
||||||
|
{
|
||||||
|
uint32_t command;
|
||||||
|
int32_t result;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct syslog_rpmsg_transfer_s
|
||||||
|
{
|
||||||
|
struct syslog_rpmsg_header_s header;
|
||||||
|
int32_t count;
|
||||||
|
char data[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#endif /* __DRIVERS_SYSLOG_SYSLOG_RPMSG_H */
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/syslog/syslog_rpmsg_server.c
|
||||||
|
* Syslog driver for rpmsg syslog server
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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/rptun/openamp.h>
|
||||||
|
#include <nuttx/syslog/syslog.h>
|
||||||
|
#include <nuttx/syslog/syslog_rpmsg.h>
|
||||||
|
|
||||||
|
#include "syslog.h"
|
||||||
|
#include "syslog_rpmsg.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define SYSLOG_RPMSG_MAXLEN 256
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct syslog_rpmsg_server_s
|
||||||
|
{
|
||||||
|
struct rpmsg_endpoint ept;
|
||||||
|
FAR char *tmpbuf;
|
||||||
|
unsigned int nextpos;
|
||||||
|
unsigned int alloced;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void syslog_rpmsg_write(FAR const char *buf1, size_t len1,
|
||||||
|
FAR const char *buf2, size_t len2);
|
||||||
|
static void syslog_rpmsg_ns_bind(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv_, FAR const char *name,
|
||||||
|
uint32_t dest);
|
||||||
|
static void syslog_rpmsg_ns_unbind(FAR struct rpmsg_endpoint *ept);
|
||||||
|
static int syslog_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept,
|
||||||
|
FAR void *data, size_t len, uint32_t src,
|
||||||
|
FAR void *priv_);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void syslog_rpmsg_write(FAR const char *buf1, size_t len1,
|
||||||
|
FAR const char *buf2, size_t len2)
|
||||||
|
{
|
||||||
|
FAR const char *nl;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
nl = memchr(buf2, '\n', len2);
|
||||||
|
DEBUGASSERT(nl != NULL);
|
||||||
|
len = nl + 1 - buf2;
|
||||||
|
|
||||||
|
if (len1 + len <= SYSLOG_RPMSG_MAXLEN)
|
||||||
|
{
|
||||||
|
char tmpbuf[SYSLOG_RPMSG_MAXLEN];
|
||||||
|
|
||||||
|
/* Ensure each syslog_write's buffer end with '\n' */
|
||||||
|
|
||||||
|
memcpy(tmpbuf, buf1, len1);
|
||||||
|
memcpy(tmpbuf + len1, buf2, len);
|
||||||
|
syslog_write(tmpbuf, len1 + len);
|
||||||
|
|
||||||
|
if (len < len2)
|
||||||
|
{
|
||||||
|
syslog_write(nl + 1, len2 - len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Give up, the merge buffer is too big */
|
||||||
|
|
||||||
|
syslog_write(buf1, len1);
|
||||||
|
syslog_write(buf2, len2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void syslog_rpmsg_ns_bind(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv_, FAR const char *name,
|
||||||
|
uint32_t dest)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_server_s *priv;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (strcmp(name, SYSLOG_RPMSG_EPT_NAME))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv = kmm_zalloc(sizeof(struct syslog_rpmsg_server_s));
|
||||||
|
if (!priv)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->ept.priv = priv;
|
||||||
|
|
||||||
|
ret = rpmsg_create_ept(&priv->ept, rdev, SYSLOG_RPMSG_EPT_NAME,
|
||||||
|
RPMSG_ADDR_ANY, dest,
|
||||||
|
syslog_rpmsg_ept_cb, syslog_rpmsg_ns_unbind);
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
kmm_free(priv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void syslog_rpmsg_ns_unbind(FAR struct rpmsg_endpoint *ept)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_server_s *priv = ept->priv;
|
||||||
|
|
||||||
|
if (priv->nextpos)
|
||||||
|
{
|
||||||
|
syslog_rpmsg_write(priv->tmpbuf, priv->nextpos, "\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpmsg_destroy_ept(ept);
|
||||||
|
|
||||||
|
kmm_free(priv->tmpbuf);
|
||||||
|
kmm_free(priv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int syslog_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data,
|
||||||
|
size_t len, uint32_t src, FAR void *priv_)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_server_s *priv = priv_;
|
||||||
|
FAR struct syslog_rpmsg_header_s *header = data;
|
||||||
|
|
||||||
|
if (header->command == SYSLOG_RPMSG_TRANSFER)
|
||||||
|
{
|
||||||
|
FAR struct syslog_rpmsg_transfer_s *msg = data;
|
||||||
|
struct syslog_rpmsg_header_s done;
|
||||||
|
unsigned int copied = msg->count;
|
||||||
|
unsigned int printed = 0;
|
||||||
|
FAR const char *nl;
|
||||||
|
|
||||||
|
nl = memrchr(msg->data, '\n', msg->count);
|
||||||
|
if (nl != NULL)
|
||||||
|
{
|
||||||
|
printed = nl + 1 - msg->data;
|
||||||
|
copied = msg->count - printed;
|
||||||
|
|
||||||
|
if (priv->nextpos)
|
||||||
|
{
|
||||||
|
syslog_rpmsg_write(priv->tmpbuf, priv->nextpos, msg->data, printed);
|
||||||
|
priv->nextpos = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
syslog_write(msg->data, printed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copied != 0)
|
||||||
|
{
|
||||||
|
unsigned int newsize = priv->nextpos + copied;
|
||||||
|
if (newsize > priv->alloced)
|
||||||
|
{
|
||||||
|
char *newbuf = kmm_realloc(priv->tmpbuf, newsize);
|
||||||
|
if (newbuf != NULL)
|
||||||
|
{
|
||||||
|
priv->tmpbuf = newbuf;
|
||||||
|
priv->alloced = newsize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
copied = priv->alloced - priv->nextpos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(priv->tmpbuf + priv->nextpos, msg->data + printed, copied);
|
||||||
|
priv->nextpos += copied;
|
||||||
|
}
|
||||||
|
|
||||||
|
done.command = SYSLOG_RPMSG_TRANSFER_DONE;
|
||||||
|
done.result = printed + copied;
|
||||||
|
rpmsg_send(ept, &done, sizeof(done));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int syslog_rpmsg_server_init(void)
|
||||||
|
{
|
||||||
|
return rpmsg_register_callback(NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
syslog_rpmsg_ns_bind);
|
||||||
|
}
|
||||||
@@ -279,6 +279,14 @@ config MCP794XX_I2C_FREQUENCY
|
|||||||
range 1 400000
|
range 1 400000
|
||||||
|
|
||||||
endif # RTC_MCP794XX
|
endif # RTC_MCP794XX
|
||||||
|
|
||||||
|
config RTC_RPMSG
|
||||||
|
bool "Rpmsg RTC Driver"
|
||||||
|
default n
|
||||||
|
depends on OPENAMP
|
||||||
|
depends on RTC_EXTERNAL
|
||||||
|
select ARCH_HAVE_RTC_SUBSECONDS
|
||||||
|
|
||||||
endif # RTC
|
endif # RTC
|
||||||
|
|
||||||
menuconfig WATCHDOG
|
menuconfig WATCHDOG
|
||||||
|
|||||||
@@ -87,6 +87,12 @@ ifeq ($(CONFIG_RTC_MCP794XX),y)
|
|||||||
TMRVPATH = :timers
|
TMRVPATH = :timers
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_RTC_RPMSG),y)
|
||||||
|
CSRCS += rpmsg_rtc.c
|
||||||
|
TMRDEPPATH = --dep-path timers
|
||||||
|
TMRVPATH = :timers
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_RTC_ARCH),y)
|
ifeq ($(CONFIG_RTC_ARCH),y)
|
||||||
CSRCS += arch_rtc.c
|
CSRCS += arch_rtc.c
|
||||||
TMRDEPPATH = --dep-path timers
|
TMRDEPPATH = --dep-path timers
|
||||||
|
|||||||
@@ -0,0 +1,427 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* drivers/timers/rpmsg_rtc.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li <liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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/clock.h>
|
||||||
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/rptun/openamp.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
|
#include <nuttx/timers/rpmsg_rtc.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPMSG_RTC_EPT_NAME "rpmsg-rtc"
|
||||||
|
|
||||||
|
#define RPMSG_RTC_SET 0
|
||||||
|
#define RPMSG_RTC_GET 1
|
||||||
|
#define RPMSG_RTC_ALARM_SET 2
|
||||||
|
#define RPMSG_RTC_ALARM_CANCEL 3
|
||||||
|
#define RPMSG_RTC_ALARM_FIRE 4
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
begin_packed_struct struct rpmsg_rtc_header_s
|
||||||
|
{
|
||||||
|
uint32_t command;
|
||||||
|
int32_t result;
|
||||||
|
uint64_t cookie;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct rpmsg_rtc_set_s
|
||||||
|
{
|
||||||
|
struct rpmsg_rtc_header_s header;
|
||||||
|
int64_t sec;
|
||||||
|
int32_t nsec;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#define rpmsg_rtc_get_s rpmsg_rtc_set_s
|
||||||
|
|
||||||
|
begin_packed_struct struct rpmsg_rtc_alarm_set_s
|
||||||
|
{
|
||||||
|
struct rpmsg_rtc_header_s header;
|
||||||
|
int64_t sec;
|
||||||
|
int32_t nsec;
|
||||||
|
int32_t id;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct rpmsg_rtc_alarm_cancel_s
|
||||||
|
{
|
||||||
|
struct rpmsg_rtc_header_s header;
|
||||||
|
int32_t id;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#define rpmsg_rtc_alarm_fire_s rpmsg_rtc_alarm_cancel_s
|
||||||
|
|
||||||
|
struct rpmsg_rtc_cookie_s
|
||||||
|
{
|
||||||
|
FAR struct rpmsg_rtc_header_s *msg;
|
||||||
|
sem_t sem;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* This is the private type for the RTC state. It must be cast compatible
|
||||||
|
* with struct rtc_lowerhalf_s.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct rpmsg_rtc_lowerhalf_s
|
||||||
|
{
|
||||||
|
/* This is the contained reference to the read-only, lower-half
|
||||||
|
* operations vtable (which may lie in FLASH or ROM)
|
||||||
|
*/
|
||||||
|
|
||||||
|
FAR const struct rtc_ops_s *ops;
|
||||||
|
|
||||||
|
/* Data following is private to this driver and not visible outside of
|
||||||
|
* this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct rpmsg_endpoint ept;
|
||||||
|
FAR const char *cpuname;
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTC_ALARM
|
||||||
|
struct lower_setalarm_s alarminfo[CONFIG_RTC_NALARMS];
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void rpmsg_rtc_device_created(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv);
|
||||||
|
static void rpmsg_rtc_device_destroy(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv);
|
||||||
|
static void rpmsg_rtc_alarm_fire_handler(FAR struct rpmsg_endpoint *ept,
|
||||||
|
FAR void *data, size_t len,
|
||||||
|
uint32_t src, FAR void *priv);
|
||||||
|
static int rpmsg_rtc_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data,
|
||||||
|
size_t len, uint32_t src, FAR void *priv);
|
||||||
|
|
||||||
|
static int rpmsg_rtc_send_recv(FAR struct rpmsg_rtc_lowerhalf_s *lower,
|
||||||
|
uint32_t command,
|
||||||
|
FAR struct rpmsg_rtc_header_s *msg, int len);
|
||||||
|
static int rpmsg_rtc_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
||||||
|
FAR struct rtc_time *rtctime);
|
||||||
|
static int rpmsg_rtc_settime(FAR struct rtc_lowerhalf_s *lower,
|
||||||
|
FAR const struct rtc_time *rtctime);
|
||||||
|
static bool rpmsg_rtc_havesettime(FAR struct rtc_lowerhalf_s *lower);
|
||||||
|
#ifdef CONFIG_RTC_ALARM
|
||||||
|
static int rpmsg_rtc_setalarm(FAR struct rtc_lowerhalf_s *lower_,
|
||||||
|
FAR const struct lower_setalarm_s *alarminfo);
|
||||||
|
static int rpmsg_rtc_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
||||||
|
FAR const struct lower_setrelative_s *relinfo);
|
||||||
|
static int rpmsg_rtc_cancelalarm(FAR struct rtc_lowerhalf_s *lower,
|
||||||
|
int alarmid);
|
||||||
|
static int rpmsg_rtc_rdalarm(FAR struct rtc_lowerhalf_s *lower_,
|
||||||
|
FAR struct lower_rdalarm_s *alarminfo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static const struct rtc_ops_s g_rpmsg_rtc_ops =
|
||||||
|
{
|
||||||
|
.rdtime = rpmsg_rtc_rdtime,
|
||||||
|
.settime = rpmsg_rtc_settime,
|
||||||
|
.havesettime = rpmsg_rtc_havesettime,
|
||||||
|
#ifdef CONFIG_RTC_ALARM
|
||||||
|
.setalarm = rpmsg_rtc_setalarm,
|
||||||
|
.setrelative = rpmsg_rtc_setrelative,
|
||||||
|
.cancelalarm = rpmsg_rtc_cancelalarm,
|
||||||
|
.rdalarm = rpmsg_rtc_rdalarm,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void rpmsg_rtc_device_created(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv)
|
||||||
|
{
|
||||||
|
FAR struct rpmsg_rtc_lowerhalf_s *lower = priv;
|
||||||
|
|
||||||
|
if (strcmp(lower->cpuname, rpmsg_get_cpuname(rdev)) == 0)
|
||||||
|
{
|
||||||
|
lower->ept.priv = lower;
|
||||||
|
|
||||||
|
rpmsg_create_ept(&lower->ept, rdev, RPMSG_RTC_EPT_NAME,
|
||||||
|
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
|
||||||
|
rpmsg_rtc_ept_cb, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rpmsg_rtc_device_destroy(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv)
|
||||||
|
{
|
||||||
|
FAR struct rpmsg_rtc_lowerhalf_s *lower = priv;
|
||||||
|
|
||||||
|
if (strcmp(lower->cpuname, rpmsg_get_cpuname(rdev)) == 0)
|
||||||
|
{
|
||||||
|
rpmsg_destroy_ept(&lower->ept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rpmsg_rtc_alarm_fire_handler(FAR struct rpmsg_endpoint *ept,
|
||||||
|
FAR void *data, size_t len,
|
||||||
|
uint32_t src, FAR void *priv)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_RTC_ALARM
|
||||||
|
FAR struct rpmsg_rtc_lowerhalf_s *lower = priv;
|
||||||
|
FAR struct rpmsg_rtc_alarm_fire_s *msg = data;
|
||||||
|
FAR struct lower_setalarm_s *alarminfo = &lower->alarminfo[msg->id];
|
||||||
|
|
||||||
|
alarminfo->cb(alarminfo->priv, alarminfo->id);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rpmsg_rtc_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data,
|
||||||
|
size_t len, uint32_t src, FAR void *priv)
|
||||||
|
{
|
||||||
|
FAR struct rpmsg_rtc_header_s *header = data;
|
||||||
|
FAR struct rpmsg_rtc_cookie_s *cookie =
|
||||||
|
(struct rpmsg_rtc_cookie_s *)(uintptr_t)header->cookie;
|
||||||
|
|
||||||
|
switch (header->command)
|
||||||
|
{
|
||||||
|
case RPMSG_RTC_ALARM_FIRE:
|
||||||
|
rpmsg_rtc_alarm_fire_handler(ept, data, len, src, priv);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (cookie)
|
||||||
|
{
|
||||||
|
memcpy(cookie->msg, data, len);
|
||||||
|
nxsem_post(&cookie->sem);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rpmsg_rtc_send_recv(FAR struct rpmsg_rtc_lowerhalf_s *lower,
|
||||||
|
uint32_t command,
|
||||||
|
FAR struct rpmsg_rtc_header_s *msg, int len)
|
||||||
|
{
|
||||||
|
FAR struct rpmsg_rtc_cookie_s cookie;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
nxsem_init(&cookie.sem, 0, 0);
|
||||||
|
nxsem_setprotocol(&cookie.sem, SEM_PRIO_NONE);
|
||||||
|
cookie.msg = msg;
|
||||||
|
|
||||||
|
msg->command = command;
|
||||||
|
msg->result = -ENXIO;
|
||||||
|
msg->cookie = (uintptr_t)&cookie;
|
||||||
|
|
||||||
|
ret = rpmsg_send(&lower->ept, msg, len);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
ret = nxsem_wait(&cookie.sem);
|
||||||
|
if (ret != -EINTR)
|
||||||
|
{
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
ret = msg->result;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fail:
|
||||||
|
nxsem_destroy(&cookie.sem);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rpmsg_rtc_rdtime(FAR struct rtc_lowerhalf_s *lower,
|
||||||
|
FAR struct rtc_time *rtctime)
|
||||||
|
{
|
||||||
|
struct rpmsg_rtc_get_s msg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = rpmsg_rtc_send_recv((FAR struct rpmsg_rtc_lowerhalf_s *)lower,
|
||||||
|
RPMSG_RTC_GET, (struct rpmsg_rtc_header_s *)&msg, sizeof(msg));
|
||||||
|
if (ret >= 0)
|
||||||
|
{
|
||||||
|
time_t time = msg.sec;
|
||||||
|
gmtime_r(&time, (FAR struct tm *)rtctime);
|
||||||
|
rtctime->tm_nsec = msg.nsec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rpmsg_rtc_settime(FAR struct rtc_lowerhalf_s *lower,
|
||||||
|
FAR const struct rtc_time *rtctime)
|
||||||
|
{
|
||||||
|
struct rpmsg_rtc_set_s msg =
|
||||||
|
{
|
||||||
|
.sec = mktime((FAR struct tm *)rtctime),
|
||||||
|
.nsec = rtctime->tm_nsec,
|
||||||
|
};
|
||||||
|
|
||||||
|
return rpmsg_rtc_send_recv((FAR struct rpmsg_rtc_lowerhalf_s *)lower,
|
||||||
|
RPMSG_RTC_SET, (struct rpmsg_rtc_header_s *)&msg, sizeof(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool rpmsg_rtc_havesettime(FAR struct rtc_lowerhalf_s *lower)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTC_ALARM
|
||||||
|
static int rpmsg_rtc_setalarm(FAR struct rtc_lowerhalf_s *lower_,
|
||||||
|
FAR const struct lower_setalarm_s *alarminfo)
|
||||||
|
{
|
||||||
|
FAR struct rpmsg_rtc_lowerhalf_s *lower =
|
||||||
|
(FAR struct rpmsg_rtc_lowerhalf_s *)lower_;
|
||||||
|
struct rpmsg_rtc_alarm_set_s msg =
|
||||||
|
{
|
||||||
|
.sec = mktime((FAR struct tm *)&alarminfo->time),
|
||||||
|
.nsec = alarminfo->time.tm_nsec,
|
||||||
|
.id = alarminfo->id,
|
||||||
|
};
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = rpmsg_rtc_send_recv(lower, RPMSG_RTC_ALARM_SET,
|
||||||
|
(struct rpmsg_rtc_header_s *)&msg, sizeof(msg));
|
||||||
|
if (ret >= 0)
|
||||||
|
{
|
||||||
|
lower->alarminfo[alarminfo->id] = *alarminfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rpmsg_rtc_setrelative(FAR struct rtc_lowerhalf_s *lower,
|
||||||
|
FAR const struct lower_setrelative_s *relinfo)
|
||||||
|
{
|
||||||
|
struct lower_setalarm_s alarminfo =
|
||||||
|
{
|
||||||
|
.id = relinfo->id,
|
||||||
|
.cb = relinfo->cb,
|
||||||
|
.priv = relinfo->priv,
|
||||||
|
};
|
||||||
|
|
||||||
|
time_t time;
|
||||||
|
|
||||||
|
rpmsg_rtc_rdtime(lower, &alarminfo.time);
|
||||||
|
time = mktime((FAR struct tm *)&alarminfo.time);
|
||||||
|
time = time + relinfo->reltime;
|
||||||
|
gmtime_r(&time, (FAR struct tm *)&alarminfo.time);
|
||||||
|
|
||||||
|
return rpmsg_rtc_setalarm(lower, &alarminfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rpmsg_rtc_cancelalarm(FAR struct rtc_lowerhalf_s *lower,
|
||||||
|
int alarmid)
|
||||||
|
{
|
||||||
|
struct rpmsg_rtc_alarm_cancel_s msg =
|
||||||
|
{
|
||||||
|
.id = alarmid,
|
||||||
|
};
|
||||||
|
|
||||||
|
return rpmsg_rtc_send_recv((FAR struct rpmsg_rtc_lowerhalf_s *)lower,
|
||||||
|
RPMSG_RTC_ALARM_CANCEL, (struct rpmsg_rtc_header_s *)&msg,
|
||||||
|
sizeof(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rpmsg_rtc_rdalarm(FAR struct rtc_lowerhalf_s *lower_,
|
||||||
|
FAR struct lower_rdalarm_s *alarminfo)
|
||||||
|
{
|
||||||
|
FAR struct rpmsg_rtc_lowerhalf_s *lower =
|
||||||
|
(FAR struct rpmsg_rtc_lowerhalf_s *)lower_;
|
||||||
|
|
||||||
|
*alarminfo->time = lower->alarminfo[alarminfo->id].time;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: rpmsg_rtc_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* Take remote core RTC as external RTC hardware through rpmsg.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* cpuname - current cpu name
|
||||||
|
* minor - device minor number
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno on failure
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR struct rtc_lowerhalf_s *rpmsg_rtc_initialize(FAR const char *cpuname,
|
||||||
|
int minor)
|
||||||
|
{
|
||||||
|
FAR struct rpmsg_rtc_lowerhalf_s *lower;
|
||||||
|
|
||||||
|
lower = kmm_zalloc(sizeof(*lower));
|
||||||
|
if (lower)
|
||||||
|
{
|
||||||
|
lower->ops = &g_rpmsg_rtc_ops;
|
||||||
|
lower->cpuname = cpuname;
|
||||||
|
|
||||||
|
rpmsg_register_callback(lower,
|
||||||
|
rpmsg_rtc_device_created,
|
||||||
|
rpmsg_rtc_device_destroy,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
rtc_initialize(minor, (FAR struct rtc_lowerhalf_s *)lower);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (FAR struct rtc_lowerhalf_s *)lower;
|
||||||
|
}
|
||||||
@@ -21,3 +21,19 @@ config FS_HOSTFS
|
|||||||
be passed to the 'mount()' routine using the optional 'void *data'
|
be passed to the 'mount()' routine using the optional 'void *data'
|
||||||
parameter.
|
parameter.
|
||||||
|
|
||||||
|
config FS_HOSTFS_RPMSG
|
||||||
|
bool "Host File System Rpmsg"
|
||||||
|
default n
|
||||||
|
depends on FS_HOSTFS
|
||||||
|
depends on OPENAMP
|
||||||
|
---help---
|
||||||
|
Use Host file system to mount directories through rpmsg.
|
||||||
|
This is the driver that sending the message.
|
||||||
|
|
||||||
|
config FS_HOSTFS_RPMSG_SERVER
|
||||||
|
bool "Host File System Rpmsg Server"
|
||||||
|
default n
|
||||||
|
depends on OPENAMP
|
||||||
|
---help---
|
||||||
|
Use Host file system to mount directories through rpmsg.
|
||||||
|
This is the driver that receiving the message.
|
||||||
|
|||||||
+11
-3
@@ -33,16 +33,24 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifeq ($(CONFIG_FS_HOSTFS),y)
|
|
||||||
|
|
||||||
# Files required for HostFS file system support
|
# Files required for HostFS file system support
|
||||||
|
|
||||||
ASRCS +=
|
ASRCS +=
|
||||||
CSRCS += hostfs.c
|
CSRCS +=
|
||||||
|
|
||||||
# Include HOSTFS build support
|
# Include HOSTFS build support
|
||||||
|
|
||||||
DEPPATH += --dep-path hostfs
|
DEPPATH += --dep-path hostfs
|
||||||
VPATH += :hostfs
|
VPATH += :hostfs
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_FS_HOSTFS),y)
|
||||||
|
CSRCS += hostfs.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_FS_HOSTFS_RPMSG),y)
|
||||||
|
CSRCS += hostfs_rpmsg.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_FS_HOSTFS_RPMSG_SERVER),y)
|
||||||
|
CSRCS += hostfs_rpmsg_server.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,201 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* fs/hostfs/hostfs_rpmsg.h
|
||||||
|
* Hostfs rpmsg driver header file
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 __FS_HOSTFS_HOSTFS_RPMSG_H
|
||||||
|
#define __FS_HOSTFS_HOSTFS_RPMSG_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/statfs.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ARRAY_SIZE
|
||||||
|
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HOSTFS_RPMSG_EPT_NAME "rpmsg-hostfs"
|
||||||
|
|
||||||
|
#define HOSTFS_RPMSG_OPEN 1
|
||||||
|
#define HOSTFS_RPMSG_CLOSE 2
|
||||||
|
#define HOSTFS_RPMSG_READ 3
|
||||||
|
#define HOSTFS_RPMSG_WRITE 4
|
||||||
|
#define HOSTFS_RPMSG_LSEEK 5
|
||||||
|
#define HOSTFS_RPMSG_IOCTL 6
|
||||||
|
#define HOSTFS_RPMSG_SYNC 7
|
||||||
|
#define HOSTFS_RPMSG_DUP 8
|
||||||
|
#define HOSTFS_RPMSG_FSTAT 9
|
||||||
|
#define HOSTFS_RPMSG_FTRUNCATE 10
|
||||||
|
#define HOSTFS_RPMSG_OPENDIR 11
|
||||||
|
#define HOSTFS_RPMSG_READDIR 12
|
||||||
|
#define HOSTFS_RPMSG_REWINDDIR 13
|
||||||
|
#define HOSTFS_RPMSG_CLOSEDIR 14
|
||||||
|
#define HOSTFS_RPMSG_STATFS 15
|
||||||
|
#define HOSTFS_RPMSG_UNLINK 16
|
||||||
|
#define HOSTFS_RPMSG_MKDIR 17
|
||||||
|
#define HOSTFS_RPMSG_RMDIR 18
|
||||||
|
#define HOSTFS_RPMSG_RENAME 19
|
||||||
|
#define HOSTFS_RPMSG_STAT 20
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_header_s
|
||||||
|
{
|
||||||
|
uint32_t command;
|
||||||
|
int32_t result;
|
||||||
|
uint64_t cookie;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_open_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t flags;
|
||||||
|
int32_t mode;
|
||||||
|
char pathname[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_close_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t fd;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_read_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t fd;
|
||||||
|
uint32_t count;
|
||||||
|
char buf[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#define hostfs_rpmsg_write_s hostfs_rpmsg_read_s
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_lseek_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t fd;
|
||||||
|
int32_t whence;
|
||||||
|
int32_t offset;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_ioctl_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t fd;
|
||||||
|
int32_t request;
|
||||||
|
int32_t arg;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#define hostfs_rpmsg_sync_s hostfs_rpmsg_close_s
|
||||||
|
#define hostfs_rpmsg_dup_s hostfs_rpmsg_close_s
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_fstat_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t fd;
|
||||||
|
uint32_t reserved;
|
||||||
|
struct stat buf;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_ftruncate_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t fd;
|
||||||
|
int32_t length;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_opendir_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
char pathname[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_readdir_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t fd;
|
||||||
|
uint32_t type;
|
||||||
|
char name[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#define hostfs_rpmsg_rewinddir_s hostfs_rpmsg_close_s
|
||||||
|
#define hostfs_rpmsg_closedir_s hostfs_rpmsg_close_s
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_statfs_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct statfs buf;
|
||||||
|
uint32_t reserved[16];
|
||||||
|
};
|
||||||
|
|
||||||
|
char pathname[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#define hostfs_rpmsg_unlink_s hostfs_rpmsg_opendir_s
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_mkdir_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
int32_t mode;
|
||||||
|
uint32_t reserved;
|
||||||
|
char pathname[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#define hostfs_rpmsg_rmdir_s hostfs_rpmsg_opendir_s
|
||||||
|
#define hostfs_rpmsg_rename_s hostfs_rpmsg_opendir_s
|
||||||
|
|
||||||
|
begin_packed_struct struct hostfs_rpmsg_stat_s
|
||||||
|
{
|
||||||
|
struct hostfs_rpmsg_header_s header;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct stat buf;
|
||||||
|
uint32_t reserved[16];
|
||||||
|
};
|
||||||
|
|
||||||
|
char pathname[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#endif /* __FS_HOSTFS_HOSTFS_RPMSG_H */
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -9,3 +9,6 @@
|
|||||||
/uClibc++
|
/uClibc++
|
||||||
/libcxx
|
/libcxx
|
||||||
/machine
|
/machine
|
||||||
|
/openamp
|
||||||
|
/metal
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/b2c.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_B2C_H
|
||||||
|
#define __INCLUDE_NUTTX_B2C_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CHAR_BIT == 8
|
||||||
|
# define CHAR_BYTE 1
|
||||||
|
# define CHAR_SHIFT 0
|
||||||
|
#elif CHAR_BIT == 16
|
||||||
|
# define CHAR_BYTE 2
|
||||||
|
# define CHAR_SHIFT 1
|
||||||
|
#elif CHAR_BIT == 32
|
||||||
|
# define CHAR_BYTE 4
|
||||||
|
# define CHAR_SHIFT 2
|
||||||
|
#else
|
||||||
|
# error unsupport CHAR_BIT value
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Macros convert between chars and bytes */
|
||||||
|
|
||||||
|
#define B2C(x) (((x) + CHAR_BYTE - 1) >> CHAR_SHIFT)
|
||||||
|
#define C2B(x) ((x) << CHAR_SHIFT)
|
||||||
|
|
||||||
|
#define B2C_OFF(x) ((x) >> CHAR_SHIFT)
|
||||||
|
#define C2B_OFF(x) ((x) << CHAR_SHIFT)
|
||||||
|
|
||||||
|
#define B2C_REM(x) ((x) - C2B_OFF(B2C_OFF(x)))
|
||||||
|
|
||||||
|
#define B2C_SHIFT(x) ((x) - CHAR_SHIFT)
|
||||||
|
#define C2B_SHIFT(x) ((x) + CHAR_SHIFT)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Functions convert between chars and bytes */
|
||||||
|
|
||||||
|
#if CHAR_BIT != 8
|
||||||
|
|
||||||
|
size_t bstrnlen(FAR const char *src, size_t maxlen);
|
||||||
|
|
||||||
|
FAR char *ancstr2bstr(FAR const char *src, size_t maxlen);
|
||||||
|
FAR char *anbstr2cstr(FAR const char *src, size_t maxlen);
|
||||||
|
|
||||||
|
void ncstr2bstr(FAR char *dst, FAR const char *src, size_t maxlen);
|
||||||
|
void nbstr2cstr(FAR char *dst, FAR const char *src, size_t maxlen);
|
||||||
|
|
||||||
|
void cmem2bmem(FAR void *dst, size_t rem, FAR const void *src, size_t len);
|
||||||
|
void bmem2cmem(FAR void *dst, FAR const void *src, size_t rem, size_t len);
|
||||||
|
|
||||||
|
# define cstr2bstr(dst, src) ncstr2bstr(dst, src, SIZE_MAX)
|
||||||
|
# define bstr2cstr(dst, src) nbstr2cstr(dst, src, SIZE_MAX)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# define bstrnlen(src, maxlen) strnlen(src, maxlen)
|
||||||
|
|
||||||
|
# define ancstr2bstr(src, maxlen) strndup(src, maxlen)
|
||||||
|
# define anbstr2cstr(src, maxlen) strndup(src, maxlen)
|
||||||
|
|
||||||
|
# define ncstr2bstr(dst, src, maxlen) strncpy(dst, src, maxlen)
|
||||||
|
# define nbstr2cstr(dst, src, maxlen) strncpy(dst, src, maxlen)
|
||||||
|
|
||||||
|
# define cmem2bmem(dst, rem, src, len) memcpy((FAR char *)(dst) + rem, src, len)
|
||||||
|
# define bmem2cmem(dst, src, rem, len) memcpy(dst, (FAR char *)(src) + rem, len)
|
||||||
|
|
||||||
|
# define cstr2bstr(dst, src) strcpy(dst, src)
|
||||||
|
# define bstr2cstr(dst, src) strcpy(dst, src)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define bstrlen(src) bstrnlen(src, SIZE_MAX)
|
||||||
|
|
||||||
|
#define acstr2bstr(src) ancstr2bstr(src, SIZE_MAX)
|
||||||
|
#define abstr2cstr(src) anbstr2cstr(src, SIZE_MAX)
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_B2C_H */
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/fs/hostfs_rpmsg.h
|
||||||
|
* Hostfs rpmsg driver header file
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_FS_HOSTFS_H
|
||||||
|
#define __INCLUDE_NUTTX_FS_HOSTFS_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FS_HOSTFS_RPMSG
|
||||||
|
int hostfs_rpmsg_init(FAR const char *cpu_name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FS_HOSTFS_RPMSG_SERVER
|
||||||
|
int hostfs_rpmsg_server_init(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_FS_HOSTFS_H */
|
||||||
@@ -96,6 +96,7 @@
|
|||||||
#define _FBIOCBASE (0x2800) /* Frame buffer character driver ioctl commands */
|
#define _FBIOCBASE (0x2800) /* Frame buffer character driver ioctl commands */
|
||||||
#define _NXTERMBASE (0x2900) /* NxTerm character driver ioctl commands */
|
#define _NXTERMBASE (0x2900) /* NxTerm character driver ioctl commands */
|
||||||
#define _RFIOCBASE (0x2a00) /* RF devices ioctl commands */
|
#define _RFIOCBASE (0x2a00) /* RF devices ioctl commands */
|
||||||
|
#define _RPTUNBASE (0x2b00) /* Remote processor tunnel ioctl commands */
|
||||||
|
|
||||||
/* boardctl() commands share the same number space */
|
/* boardctl() commands share the same number space */
|
||||||
|
|
||||||
@@ -506,6 +507,11 @@
|
|||||||
#define _RFIOCVALID(c) (_IOC_TYPE(c)==_RFIOCBASE)
|
#define _RFIOCVALID(c) (_IOC_TYPE(c)==_RFIOCBASE)
|
||||||
#define _RFIOC(nr) _IOC(_RFIOCBASE,nr)
|
#define _RFIOC(nr) _IOC(_RFIOCBASE,nr)
|
||||||
|
|
||||||
|
/* Rptun drivers ************************************************************/
|
||||||
|
|
||||||
|
#define _RPTUNIOCVALID(c) (_IOC_TYPE(c)==_RPTUNBASE)
|
||||||
|
#define _RPTUNIOC(nr) _IOC(_RPTUNBASE,nr)
|
||||||
|
|
||||||
/* boardctl() command definitions *******************************************/
|
/* boardctl() command definitions *******************************************/
|
||||||
|
|
||||||
#define _BOARDIOCVALID(c) (_IOC_TYPE(c)==_BOARDBASE)
|
#define _BOARDIOCVALID(c) (_IOC_TYPE(c)==_BOARDBASE)
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/mbox/mbox.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_MBOX_MBOX_H
|
||||||
|
#define __INCLUDE_NUTTX_MBOX_MBOX_H
|
||||||
|
|
||||||
|
#ifdef CONFIG_MBOX
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Access macros ************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: MBOX_SEND
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Send a 32bits message to remote core from specific channel
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
* ch - Mbox specific channel
|
||||||
|
* msg - Message to send
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK unless an error occurs. Then a negated errno value is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define MBOX_SEND(d,c,m) ((d)->ops->send(d,c,m))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: MBOX_REGISTER_CALLBACK
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Attach to receive a callback when something is received on MBOX
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
* ch - Mbox specific channel
|
||||||
|
* callback - The function to be called when something has been received
|
||||||
|
* arg - A caller provided value to return with the callback
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK unless an error occurs. Then a negated errno value is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define MBOX_REGISTER_CALLBACK(d,c,cb,a) \
|
||||||
|
((d)->ops->registercallback(d,c,cb,a))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: MBOX_UNREGISTER_CALLBACK
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Detach MBOX callback
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
* ch - Mbox specific channel
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK unless an error occurs. Then a negated errno value is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define MBOX_UNREGISTER_CALLBACK(d,c) \
|
||||||
|
((d)->ops->registercallback(d,c,NULL,NULL))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct mbox_dev_s;
|
||||||
|
typedef CODE int (*mbox_receive_t)(FAR void *arg, uintptr_t msg);
|
||||||
|
|
||||||
|
struct mbox_ops_s
|
||||||
|
{
|
||||||
|
CODE int (*send)(FAR struct mbox_dev_s *dev, uint32_t ch, uintptr_t msg);
|
||||||
|
CODE int (*registercallback)(FAR struct mbox_dev_s *dev, uint32_t ch,
|
||||||
|
mbox_receive_t callback, FAR void *arg);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mbox_dev_s
|
||||||
|
{
|
||||||
|
FAR const struct mbox_ops_s *ops;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_MBOX */
|
||||||
|
#endif /* __INCLUDE_NUTTX_MBOX_MBOX_H */
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/net/rpmsg.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Jianli Dong <dongjianli@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_NET_RPMSG_H
|
||||||
|
#define __INCLUDE_NUTTX_NET_RPMSG_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define NET_RPMSG_EPT_NAME "rpmsg-%s"
|
||||||
|
|
||||||
|
#define NET_RPMSG_IFUP 0 /* IP-->LINK */
|
||||||
|
#define NET_RPMSG_IFDOWN 1 /* IP-->LINK */
|
||||||
|
#define NET_RPMSG_ADDMCAST 2 /* IP-->LINK */
|
||||||
|
#define NET_RPMSG_RMMCAST 3 /* IP-->LINK */
|
||||||
|
#define NET_RPMSG_DEVIOCTL 4 /* IP-->LINK */
|
||||||
|
#define NET_RPMSG_SOCKIOCTL 5 /* IP<--LINK */
|
||||||
|
#define NET_RPMSG_TRANSFER 6 /* IP<->LINK */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
begin_packed_struct struct net_rpmsg_lnkaddr_s
|
||||||
|
{
|
||||||
|
uint32_t length;
|
||||||
|
uint8_t addr[16];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct net_rpmsg_header_s
|
||||||
|
{
|
||||||
|
uint32_t command;
|
||||||
|
int32_t result;
|
||||||
|
uint64_t cookie;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct net_rpmsg_ifup_s
|
||||||
|
{
|
||||||
|
struct net_rpmsg_header_s header;
|
||||||
|
struct net_rpmsg_lnkaddr_s lnkaddr;
|
||||||
|
|
||||||
|
/* All addresses in the network order */
|
||||||
|
|
||||||
|
uint32_t ipaddr;
|
||||||
|
uint32_t draddr;
|
||||||
|
uint32_t netmask;
|
||||||
|
uint32_t dnsaddr;
|
||||||
|
uint16_t ipv6addr[8];
|
||||||
|
uint16_t ipv6draddr[8];
|
||||||
|
uint16_t ipv6netmask[8];
|
||||||
|
uint16_t ipv6dnsaddr[8];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#define net_rpmsg_ifdown_s net_rpmsg_header_s
|
||||||
|
|
||||||
|
begin_packed_struct struct net_rpmsg_mcast_s
|
||||||
|
{
|
||||||
|
struct net_rpmsg_header_s header;
|
||||||
|
struct net_rpmsg_lnkaddr_s lnkaddr;
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct net_rpmsg_ioctl_s
|
||||||
|
{
|
||||||
|
struct net_rpmsg_header_s header;
|
||||||
|
uint32_t code;
|
||||||
|
uint32_t length;
|
||||||
|
uint8_t arg[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
begin_packed_struct struct net_rpmsg_transfer_s
|
||||||
|
{
|
||||||
|
struct net_rpmsg_header_s header;
|
||||||
|
uint32_t length;
|
||||||
|
uint8_t data[0];
|
||||||
|
} end_packed_struct;
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_NET_RPMSG_H */
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/net/rpmsgdrv.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Jianli Dong <dongjianli@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_NET_RPMSGDRV_H
|
||||||
|
#define __INCLUDE_NUTTX_NET_RPMSGDRV_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/net/net.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_RPMSG_DRV
|
||||||
|
int net_rpmsg_drv_init(FAR const char *cpuname,
|
||||||
|
FAR const char *devname,
|
||||||
|
enum net_lltype_e lltype);
|
||||||
|
#else
|
||||||
|
#define net_rpmsg_drv_init(cpuname, devname, lltye)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_NET_RPMSGDRV_H */
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/rptun/openamp.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_RPTUN_OPENAMP_H
|
||||||
|
#define __INCLUDE_NUTTX_RPTUN_OPENAMP_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <openamp/open_amp.h>
|
||||||
|
#include <openamp/remoteproc_loader.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_RPTUN
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
typedef void (*rpmsg_dev_cb_t)(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv);
|
||||||
|
typedef void (*rpmsg_bind_cb_t)(FAR struct rpmsg_device *rdev,
|
||||||
|
FAR void *priv, FAR const char *name,
|
||||||
|
uint32_t dest);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *rpmsg_get_cpuname(FAR struct rpmsg_device *rdev);
|
||||||
|
int rpmsg_register_callback(FAR void *priv,
|
||||||
|
rpmsg_dev_cb_t device_created,
|
||||||
|
rpmsg_dev_cb_t device_destroy,
|
||||||
|
rpmsg_bind_cb_t ns_bind);
|
||||||
|
void rpmsg_unregister_callback(FAR void *priv,
|
||||||
|
rpmsg_dev_cb_t device_created,
|
||||||
|
rpmsg_dev_cb_t device_destroy,
|
||||||
|
rpmsg_bind_cb_t ns_bind);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_RPTUN */
|
||||||
|
#endif /*__INCLUDE_NUTTX_RPTUN_OPENAMP_H */
|
||||||
@@ -0,0 +1,311 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/rptun/rptun.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_RPTUN_RPTUN_H
|
||||||
|
#define __INCLUDE_NUTTX_RPTUN_RPTUN_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <nuttx/fs/ioctl.h>
|
||||||
|
#include <openamp/open_amp.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_RPTUN
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUNIOC_START _RPTUNIOC(1)
|
||||||
|
#define RPTUNIOC_STOP _RPTUNIOC(2)
|
||||||
|
|
||||||
|
#define RPTUN_NOTIFY_ALL (UINT32_MAX - 0)
|
||||||
|
|
||||||
|
/* Access macros ************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_GET_CPUNAME
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get remote cpu name
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Cpu name on success, NULL on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_GET_CPUNAME(d) ((d)->ops->get_cpuname(d))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_GET_FIRMWARE
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get remote firmware name
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Firmware name on success, NULL on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_GET_FIRMWARE(d) ((d)->ops->get_firmware(d))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_GET_ADDRENV
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get adress env list
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Addrenv pointer on success, NULL on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_GET_ADDRENV(d) ((d)->ops->get_addrenv(d))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_GET_RESOURCE
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get rptun resouce
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Resource pointer on success, NULL on failure
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_GET_RESOURCE(d) ((d)->ops->get_resource(d))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_IS_AUTOSTART
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* AUTO start or not
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* True autostart, false not autostart
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_IS_AUTOSTART(d) ((d)->ops->is_autostart(d))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_IS_MASTER
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* IS master or not
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* True master, false remote
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_IS_MASTER(d) ((d)->ops->is_master(d))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_START
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* START remote cpu
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK unless an error occurs. Then a negated errno value is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_START(d) ((d)->ops->start(d))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_STOP
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* STOP remote cpu
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK unless an error occurs. Then a negated errno value is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_STOP(d) ((d)->ops->stop(d))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_NOTIFY
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify remote core there is a message to get.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
* vqid - Message to notify
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK unless an error occurs. Then a negated errno value is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_NOTIFY(d,v) ((d)->ops->notify(d,v))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_REGISTER_CALLBACK
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Attach to receive a callback when something is received on RPTUN
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
* callback - The function to be called when something has been received
|
||||||
|
* arg - A caller provided value to return with the callback
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK unless an error occurs. Then a negated errno value is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_REGISTER_CALLBACK(d,c,a) ((d)->ops->register_callback(d,c,a))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: RPTUN_UNREGISTER_CALLBACK
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Detach RPTUN callback
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - Device-specific state data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK unless an error occurs. Then a negated errno value is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define RPTUN_UNREGISTER_CALLBACK(d) ((d)->ops->register_callback(d,NULL,NULL))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
typedef CODE int (*rptun_callback_t)(FAR void *arg, uint32_t vqid);
|
||||||
|
|
||||||
|
struct rptun_addrenv_s
|
||||||
|
{
|
||||||
|
uintptr_t pa;
|
||||||
|
uintptr_t da;
|
||||||
|
size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct __attribute__((aligned(B2C(8)))) rptun_rsc_s
|
||||||
|
{
|
||||||
|
struct resource_table rsc_tbl_hdr;
|
||||||
|
unsigned int offset[2];
|
||||||
|
struct fw_rsc_trace log_trace;
|
||||||
|
struct fw_rsc_vdev rpmsg_vdev;
|
||||||
|
struct fw_rsc_vdev_vring rpmsg_vring0;
|
||||||
|
struct fw_rsc_vdev_vring rpmsg_vring1;
|
||||||
|
unsigned int buf_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rptun_dev_s;
|
||||||
|
struct rptun_ops_s
|
||||||
|
{
|
||||||
|
CODE FAR const char *(*get_cpuname)(FAR struct rptun_dev_s *dev);
|
||||||
|
CODE FAR const char *(*get_firmware)(FAR struct rptun_dev_s *dev);
|
||||||
|
|
||||||
|
CODE FAR const struct rptun_addrenv_s *(*get_addrenv)(FAR struct rptun_dev_s *dev);
|
||||||
|
CODE FAR struct rptun_rsc_s *(*get_resource)(FAR struct rptun_dev_s *dev);
|
||||||
|
|
||||||
|
CODE bool (*is_autostart)(FAR struct rptun_dev_s *dev);
|
||||||
|
CODE bool (*is_master)(FAR struct rptun_dev_s *dev);
|
||||||
|
|
||||||
|
CODE int (*start)(FAR struct rptun_dev_s *dev);
|
||||||
|
CODE int (*stop)(FAR struct rptun_dev_s *dev);
|
||||||
|
CODE int (*notify)(FAR struct rptun_dev_s *dev, uint32_t vqid);
|
||||||
|
CODE int (*register_callback)(FAR struct rptun_dev_s *dev,
|
||||||
|
rptun_callback_t callback, FAR void *arg);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rptun_dev_s
|
||||||
|
{
|
||||||
|
FAR const struct rptun_ops_s *ops;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int rptun_initialize(FAR struct rptun_dev_s *dev);
|
||||||
|
int rptun_boot(FAR const char *cpuname);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_RPTUN */
|
||||||
|
#endif /* __INCLUDE_NUTTX_RPTUN_RPTUN_H */
|
||||||
|
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/serial/uart_rpmsg.h
|
||||||
|
* Serial driver for rpmsg UART
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_SERIAL_UART_RPMSG_H
|
||||||
|
#define __INCLUDE_NUTTX_SERIAL_UART_RPMSG_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_RPMSG_UART
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int uart_rpmsg_init(FAR const char *cpu_name, FAR const char *dev_name,
|
||||||
|
int buf_size, bool isconsole);
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_RPMSG_UART */
|
||||||
|
#endif /* __INCLUDE_NUTTX_SERIAL_UART_RPMSG_H */
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/syslog/syslog_rpmsg.h
|
||||||
|
* Syslog driver for rpmsg syslog
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_SYSLOG_SYSLOG_RPMSG_H
|
||||||
|
#define __INCLUDE_NUTTX_SYSLOG_SYSLOG_RPMSG_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG_RPMSG
|
||||||
|
int syslog_rpmsg_init_early(FAR const char *cpu_name, FAR void *buffer,
|
||||||
|
size_t size);
|
||||||
|
int syslog_rpmsg_init(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG_RPMSG_SERVER
|
||||||
|
int syslog_rpmsg_server_init(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_SYSLOG_SYSLOG_RPMSG_H */
|
||||||
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/timers/rpmsg_rtc.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Guiding Li<liguiding@pinecone.net>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_TIMERS_RPMSG_RTC_H
|
||||||
|
#define __INCLUDE_NUTTX_TIMERS_RPMSG_RTC_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/timers/rtc.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTC_RPMSG
|
||||||
|
|
||||||
|
FAR struct rtc_lowerhalf_s *rpmsg_rtc_initialize(FAR const char *cpu_name,
|
||||||
|
int minor);
|
||||||
|
|
||||||
|
#endif /* CONFIG_RTC_RPMSG */
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_TIMERS_RPMSG_RTC_H */
|
||||||
+1
-3
@@ -44,9 +44,7 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
/****************************************************************************
|
#include <nuttx/b2c.h>
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ we have:
|
|||||||
semaphore - semaphore.h
|
semaphore - semaphore.h
|
||||||
stdio - stdio.h
|
stdio - stdio.h
|
||||||
stdlib - stdlib.h
|
stdlib - stdlib.h
|
||||||
string - string.h (and legacy strings.h)
|
string - string.h (and legacy strings.h and non-standard nuttx/b2c.h)
|
||||||
time - time.h
|
time - time.h
|
||||||
uio - sys/uio.h
|
uio - sys/uio.h
|
||||||
unistd - unistd.h
|
unistd - unistd.h
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libc/stdlib/lib_anbstr2cstr.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "libc.h"
|
||||||
|
|
||||||
|
#if CHAR_BIT != 8
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR char *anbstr2cstr(FAR const char *src, size_t maxlen)
|
||||||
|
{
|
||||||
|
FAR char *dst;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = bstrnlen(src, maxlen);
|
||||||
|
dst = lib_malloc(C2B(len + 1));
|
||||||
|
if (dst)
|
||||||
|
{
|
||||||
|
dst[C2B(len + 1) - 1] = 0;
|
||||||
|
bmem2cmem(dst, src, 0, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libc/stdlib/lib_ancstr2bstr.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "libc.h"
|
||||||
|
|
||||||
|
#if CHAR_BIT != 8
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
FAR char *ancstr2bstr(FAR const char *src, size_t maxlen)
|
||||||
|
{
|
||||||
|
FAR char *dst;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = strnlen(src, maxlen);
|
||||||
|
dst = lib_malloc(B2C(len + 1));
|
||||||
|
if (dst)
|
||||||
|
{
|
||||||
|
dst[B2C(len + 1) - 1] = 0;
|
||||||
|
cmem2bmem(dst, 0, src, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libc/stdlib/lib_bmem2cmem.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
|
||||||
|
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void bmem2cmem(FAR void *dst_, FAR const void *src_, size_t rem, size_t len)
|
||||||
|
{
|
||||||
|
char *dst = dst_;
|
||||||
|
const char *src = src_;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 8 * rem; i < CHAR_BIT; i += 8)
|
||||||
|
{
|
||||||
|
if (len-- == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dst++ = (*src >> i) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
rem = 0;
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libc/stdlib/lib_bstrnlen.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
|
||||||
|
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
size_t bstrnlen(FAR const char *src, size_t maxlen)
|
||||||
|
{
|
||||||
|
size_t len = 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < CHAR_BIT; i += 8, len++)
|
||||||
|
{
|
||||||
|
if (maxlen-- == 0 || ((*src >> i) & 0xff) == 0)
|
||||||
|
{
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libc/stdlib/lib_cmem2bmem.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
|
||||||
|
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void cmem2bmem(FAR void *dst_, size_t rem, FAR const void *src_, size_t len)
|
||||||
|
{
|
||||||
|
char *dst = dst_;
|
||||||
|
const char *src = src_;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 8 * rem; i < CHAR_BIT; i += 8)
|
||||||
|
{
|
||||||
|
if (len-- == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (i == 8 * rem)
|
||||||
|
{
|
||||||
|
*dst = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dst |= (*src++ & 0xff) << i;
|
||||||
|
}
|
||||||
|
|
||||||
|
rem = 0;
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libc/stdlib/lib_nbstr2cstr.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
|
||||||
|
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void nbstr2cstr(FAR char *dst, FAR const char *src, size_t maxlen)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < CHAR_BIT; i += 8)
|
||||||
|
{
|
||||||
|
if (maxlen-- == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dst = (*src >> i) & 0xff;
|
||||||
|
if (*dst++ == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libc/stdlib/lib_ncstr2bstr.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||||
|
*
|
||||||
|
* 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 <stdlib.h>
|
||||||
|
|
||||||
|
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void ncstr2bstr(FAR char *dst, FAR const char *src, size_t maxlen)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < CHAR_BIT; i += 8)
|
||||||
|
{
|
||||||
|
char tmp;
|
||||||
|
|
||||||
|
if (maxlen-- == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (i == 0)
|
||||||
|
{
|
||||||
|
*dst = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = *src++ & 0xff;
|
||||||
|
if (tmp == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*dst |= tmp << i;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/.libmetal_headers
|
||||||
|
/.openamp_headers
|
||||||
|
/libmetal
|
||||||
|
/open-amp
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
|
#
|
||||||
|
|
||||||
|
config OPENAMP
|
||||||
|
bool "Open Asymmetric Multi Processing support"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Enable or disable Open Asymmetric Multi Processing features
|
||||||
|
|
||||||
|
if OPENAMP
|
||||||
|
|
||||||
|
endif # OPENAMP
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
############################################################################
|
||||||
|
# openamp/Makefile
|
||||||
|
#
|
||||||
|
# Copyright (C) 2017 Pinecone Inc. All rights reserved.
|
||||||
|
# Author: Pinecone <pinecone@pinecone.net>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
-include $(TOPDIR)/Make.defs
|
||||||
|
|
||||||
|
ASRCS =
|
||||||
|
CSRCS =
|
||||||
|
|
||||||
|
VPATH := $(SRCDIR)
|
||||||
|
DEPPATH = --dep-path .
|
||||||
|
|
||||||
|
include libmetal/Make.defs
|
||||||
|
include open-amp/Make.defs
|
||||||
|
|
||||||
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||||
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||||
|
|
||||||
|
SRCS = $(ASRCS) $(CSRCS)
|
||||||
|
OBJS = $(AOBJS) $(COBJS)
|
||||||
|
|
||||||
|
BIN = libopenamp$(LIBEXT)
|
||||||
|
|
||||||
|
all: $(BIN)
|
||||||
|
.PHONY: context depend clean distclean dirlinks
|
||||||
|
|
||||||
|
$(AOBJS): %$(OBJEXT): %.S
|
||||||
|
$(call ASSEMBLE, $<, $@)
|
||||||
|
|
||||||
|
$(COBJS): %$(OBJEXT): %.c
|
||||||
|
$(call COMPILE, $<, $@)
|
||||||
|
|
||||||
|
$(BIN): $(OBJS)
|
||||||
|
$(call ARCHIVE, $@, $(OBJS))
|
||||||
|
|
||||||
|
dirlinks::
|
||||||
|
|
||||||
|
.depend: Makefile $(SRCS)
|
||||||
|
$(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $^ >Make.dep
|
||||||
|
$(Q) touch $@
|
||||||
|
|
||||||
|
depend: .depend
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(foreach obj,$(OBJS),$(call DELFILE, $(obj)))
|
||||||
|
$(call DELFILE, $(BIN))
|
||||||
|
$(call CLEAN)
|
||||||
|
|
||||||
|
distclean:: clean
|
||||||
|
$(call DELFILE, Make.dep)
|
||||||
|
$(call DELFILE, .depend)
|
||||||
|
|
||||||
|
-include Make.dep
|
||||||
@@ -166,4 +166,10 @@ else
|
|||||||
CLEANDIRS += crypto
|
CLEANDIRS += crypto
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_OPENAMP),y)
|
||||||
|
KERNDEPDIRS += openamp
|
||||||
|
else
|
||||||
|
CLEANDIRS += openamp
|
||||||
|
endif
|
||||||
|
|
||||||
CLEANDIRS += $(KERNDEPDIRS) $(USERDEPDIRS)
|
CLEANDIRS += $(KERNDEPDIRS) $(USERDEPDIRS)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user