Skip to content

Commit

Permalink
asmp/worker: Support some libc functions in worker
Browse files Browse the repository at this point in the history
Add some libc functions to libasmpw to increase portability of
source code between Main and Sub.
Specifically, ctype, fixedmath, string and queue.
  • Loading branch information
SPRESENSE committed Jan 18, 2023
1 parent 8e845c7 commit 107b1d2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
6 changes: 6 additions & 0 deletions sdk/modules/asmp/Kconfig
Expand Up @@ -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"

Expand Down
8 changes: 6 additions & 2 deletions sdk/modules/asmp/worker/Makefile
Expand Up @@ -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))
Expand All @@ -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),)
Expand Down
52 changes: 52 additions & 0 deletions 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

0 comments on commit 107b1d2

Please sign in to comment.