From 107b1d27ea3ab8eb0f7539480be3deb116ee8852 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 17 Jan 2023 14:00:36 +0900 Subject: [PATCH] asmp/worker: Support some libc functions in worker Add some libc functions to libasmpw to increase portability of source code between Main and Sub. Specifically, ctype, fixedmath, string and queue. --- sdk/modules/asmp/Kconfig | 6 +++ sdk/modules/asmp/worker/Makefile | 8 +++- sdk/modules/asmp/worker/worker_libc.mk | 52 ++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 sdk/modules/asmp/worker/worker_libc.mk diff --git a/sdk/modules/asmp/Kconfig b/sdk/modules/asmp/Kconfig index 04a0d9ae8..a28e6efcd 100644 --- a/sdk/modules/asmp/Kconfig +++ b/sdk/modules/asmp/Kconfig @@ -25,6 +25,12 @@ config ASMP_SMALL_BLOCK Use small block size (64 KiB) to memory management. This option is for improve memory usage, but it tends to fragmentation. +config ASMP_WORKER_LIBC + bool "Support some libc functions in worker" + default n + ---help--- + Support some libraries such as ctype, string, queue, fixedmath and etc. in worker. + config ASMP_DEBUG_FEATURE bool "ASMP Framework debug feature" diff --git a/sdk/modules/asmp/worker/Makefile b/sdk/modules/asmp/worker/Makefile index 7108300aa..82123187d 100644 --- a/sdk/modules/asmp/worker/Makefile +++ b/sdk/modules/asmp/worker/Makefile @@ -36,14 +36,17 @@ include $(APPDIR)/Make.defs -include $(SDKDIR)/Make.defs -VPATH = arch +include worker_libc.mk + +VPATH = arch $(LIBC_TGTPATH) SUBDIRS = -DEPPATH = --dep-path arch --dep-path . +DEPPATH = --dep-path arch --dep-path . $(LIBC_DEPPATH) ASRCS = exception.S CSRCS = common.c mpmq.c mpmutex.c mpshm.c CSRCS += cpufifo.c cpuid.c doirq.c startup.c sysctl.c +CSRCS += $(LIBC_CSRCS) AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) @@ -57,6 +60,7 @@ BIN = libasmpw$(LIBEXT) ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src +CFLAGS := $(LIBC_INCPATH) $(CFLAGS) CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(ARCHSRCDIR)$(DELIM)chip"} CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(ARCHSRCDIR)$(DELIM)common"} ifneq ($(CONFIG_ARCH_FAMILY),) diff --git a/sdk/modules/asmp/worker/worker_libc.mk b/sdk/modules/asmp/worker/worker_libc.mk new file mode 100644 index 000000000..bd665c2aa --- /dev/null +++ b/sdk/modules/asmp/worker/worker_libc.mk @@ -0,0 +1,52 @@ +############################################################################ +# modules/asmp/worker/worker_libc.mk +# +# Copyright 2023 Sony Semiconductor Solutions Corporation +# +# 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 of Sony Semiconductor Solutions Corporation 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. +# +############################################################################ + +ifneq ($(CONFIG_ASMP_WORKER_LIBC),) + +NXINC_PATH = $(SDKDIR)/../nuttx/include +LIBC_PATH = $(SDKDIR)/../nuttx/libs/libc + +LIBC_LIBS = ctype +LIBC_LIBS += fixedmath +# LIBC_LIBS += math +LIBC_LIBS += string +LIBC_LIBS += queue + +LIBC_TGTPATH = $(patsubst %,$(LIBC_PATH)/%,$(LIBC_LIBS)) +LIBC_CSRCS = $(notdir $(foreach p,$(LIBC_TGTPATH),$(wildcard $(p)/*.c))) +LIBC_DEPPATH = --dep-path $(NXINC_PATH) --dep-path $(NXINC_PATH)/nuttx/lib $(patsubst %,--dep-path %,$(LIBC_TGTPATH)) +LIBC_INCPATH = -I$(NXINC_PATH) -I$(NXINC_PATH)/nuttx/lib -I$(LIBC_PATH) + +endif