xiaoxiang781216 commented on code in PR #3074: URL: https://github.com/apache/nuttx-apps/pull/3074#discussion_r2083393938
########## examples/optee/optee_main.c: ########## @@ -39,6 +39,16 @@ * Pre-processor definitions ****************************************************************************/ +#undef USE_ALLOC_IOC + +#ifdef USE_ALLOC_IOC +# define tee_shm_alloc tee_shm_mmap +# define tee_shm_free_buf(p, s) munmap(p, s) +#else +# define tee_shm_alloc tee_shm_malloc +# define tee_shm_free_buf(p, s) (void)s; free(p) Review Comment: `((void)s, free(p))` ########## tee/libteec/Makefile: ########## @@ -0,0 +1,66 @@ +############################################################################ +# apps/tee/libteec/Makefile +# +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 Xiaomi Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +LIBTEEC_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBTEEC_VERSION))) +LIBTEEC_URL ?= "https://github.com/OP-TEE/optee_client/archive/refs/tags" +LIBTEEC_ZIP = $(LIBTEEC_VERSION).zip +LIBTEEC_UNPACKNAME = optee_client +UNPACK ?= unzip -q -o + +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/tee/libteec/optee_client/libteec/include Review Comment: remove, done by Make.defs ########## tee/Kconfig: ########## @@ -0,0 +1,10 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# +# This file is autogenerated, do not edit. +# + +menu "TEE Library Support" +source "/mnt/sda/gp/autonomous/fc/evk93/nuttx/apps-gp/tee/libteec/Kconfig" Review Comment: remove the automatically generated file ########## examples/optee/optee_main.c: ########## @@ -235,9 +243,8 @@ static int tee_shm_mmap(int fd, tee_shm_t *shm, bool reg) return ret; } -#endif -static int tee_shm_alloc(int fd, tee_shm_t *shm, bool reg) +int tee_shm_malloc(int fd, tee_shm_t *shm, bool reg) Review Comment: why remove static ########## tee/libteec/Make.defs: ########## @@ -0,0 +1,30 @@ +############################################################################ +# apps/tee/libteec/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 Xiaomi Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################ + +ifneq ($(CONFIG_LIBTEEC),) +CONFIGURED_APPS += $(APPDIR)/tee/libteec + +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/tee/libteec/optee_client/libteec/include +CFLAGS += ${DEFINE_PREFIX}BINARY_PREFIX="\"TEEC\"" Review Comment: `FLAGS += ${DEFINE_PREFIX}BINARY_PREFIX="\"TEEC\""` move to Makefile? ########## examples/optee/optee_main.c: ########## @@ -183,18 +193,16 @@ static int tee_shm_register(int fd, tee_shm_t *shm) return -EINVAL; } - shm->id = (int32_t)(uintptr_t)shm->ptr; - ioc_reg.addr = (uintptr_t)shm->ptr; ioc_reg.length = shm->size; - ioc_reg.flags = TEE_SHM_REGISTER | TEE_SHM_SEC_REGISTER; - ioc_reg.id = shm->id; - return ioctl(fd, TEE_IOC_SHM_REGISTER, (unsigned long)&ioc_reg); + shm->fd = ioctl(fd, TEE_IOC_SHM_REGISTER, (unsigned long)&ioc_reg); + shm->id = ioc_reg.id; + + return shm->fd < 0 ? shm->fd : 0; } -#if 0 /* Not used */ -static int tee_shm_mmap(int fd, tee_shm_t *shm, bool reg) +int tee_shm_mmap(int fd, tee_shm_t *shm, bool reg) Review Comment: why remove static ########## tee/libteec/Make.defs: ########## @@ -0,0 +1,30 @@ +############################################################################ +# apps/tee/libteec/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 Xiaomi Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################ + +ifneq ($(CONFIG_LIBTEEC),) +CONFIGURED_APPS += $(APPDIR)/tee/libteec + +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/tee/libteec/optee_client/libteec/include +CFLAGS += ${DEFINE_PREFIX}BINARY_PREFIX="\"TEEC\"" + +CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/tee/libteec/optee_client/libteec/include +CXXFLAGS += ${DEFINE_PREFIX}BINARY_PREFIX="\"TEEC\"" Review Comment: ditto -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org