From 2d55f2659e620b86610d25ea545de0aa0cb0538c Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Fri, 4 Jun 2021 12:21:47 +0100 Subject: [PATCH] riscv/esp32c3: Add module text allocator. Signed-off-by: Abdelatif Guettouche --- arch/risc-v/Kconfig | 1 + arch/risc-v/src/esp32c3/Make.defs | 4 ++ arch/risc-v/src/esp32c3/esp32c3_modtext.c | 83 +++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 arch/risc-v/src/esp32c3/esp32c3_modtext.c diff --git a/arch/risc-v/Kconfig b/arch/risc-v/Kconfig index 645d4014e1d..7eb73308ab2 100644 --- a/arch/risc-v/Kconfig +++ b/arch/risc-v/Kconfig @@ -50,6 +50,7 @@ config ARCH_CHIP_ESP32C3 select LIBC_ARCH_MEMCCMP select LIBC_ARCH_MEMMOVE select LIBC_ARCH_MEMSET + select ARCH_HAVE_MODULE_TEXT ---help--- Espressif ESP32-C3 (RV32IMC). diff --git a/arch/risc-v/src/esp32c3/Make.defs b/arch/risc-v/src/esp32c3/Make.defs index 6d44a96a51a..0a1df011aec 100644 --- a/arch/risc-v/src/esp32c3/Make.defs +++ b/arch/risc-v/src/esp32c3/Make.defs @@ -142,6 +142,10 @@ ifeq ($(CONFIG_ESP32C3_AES_ACCELERATOR),y) CHIP_CSRCS += esp32c3_aes.c endif +ifeq ($(CONFIG_ARCH_USE_MODULE_TEXT),y) +CHIP_CSRCS += esp32c3_modtext.c +endif + ifeq ($(CONFIG_ESP32C3_WIRELESS),y) WIRELESS_DRV_UNPACK = esp-wireless-drivers-3rdparty WIRELESS_DRV_ID = 2b53111 diff --git a/arch/risc-v/src/esp32c3/esp32c3_modtext.c b/arch/risc-v/src/esp32c3/esp32c3_modtext.c new file mode 100644 index 00000000000..92b41cb94bd --- /dev/null +++ b/arch/risc-v/src/esp32c3/esp32c3_modtext.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * arch/risc-v/src/esp32c3/esp32c3_modtext.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define D_I_BUS_OFFSET 0x700000 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_module_text_init() + ****************************************************************************/ + +void up_module_text_init() +{ +} + +/**************************************************************************** + * Name: up_module_text_memalign() + ****************************************************************************/ + +FAR void *up_module_text_memalign(size_t align, size_t size) +{ + FAR void *ret; + + ret = kmm_memalign(align, size); + if (ret) + { + ret += D_I_BUS_OFFSET; + } + + return ret; +} + +/**************************************************************************** + * Name: up_module_text_free() + ****************************************************************************/ + +void up_module_text_free(FAR void *p) +{ + if (p) + { + p -= D_I_BUS_OFFSET; + } + + kmm_free(p); +}