From 2fa5d6535510cb757c95c0dfc6f7d81d7f0a7b72 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Mon, 12 Oct 2020 15:39:21 +0100 Subject: [PATCH] arch/xtensa/src/common: Refactor the mm_ macros into a separate file. Signed-off-by: Abdelatif Guettouche --- arch/xtensa/src/common/xtensa_createstack.c | 13 +----- arch/xtensa/src/common/xtensa_mm.h | 49 ++++++++++++++++++++ arch/xtensa/src/common/xtensa_releasestack.c | 17 +------ 3 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 arch/xtensa/src/common/xtensa_mm.h diff --git a/arch/xtensa/src/common/xtensa_createstack.c b/arch/xtensa/src/common/xtensa_createstack.c index 5b7c6cec17..b936765011 100644 --- a/arch/xtensa/src/common/xtensa_createstack.c +++ b/arch/xtensa/src/common/xtensa_createstack.c @@ -54,6 +54,7 @@ #include #include "xtensa.h" +#include "xtensa_mm.h" /**************************************************************************** * Pre-processor Macros @@ -73,18 +74,6 @@ #define STACK_ALIGN_DOWN(a) ((a) & ~STACK_ALIGN_MASK) #define STACK_ALIGN_UP(a) (((a) + STACK_ALIGN_MASK) & ~STACK_ALIGN_MASK) -#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM -# define UMM_MALLOC(s) up_imm_malloc(s) -# define UMM_MEMALIGN(a,s) up_imm_memalign(a,s) -# define UMM_FREE(p) up_imm_free(p) -# define UMM_HEAPMEMEBER(p) up_imm_heapmember(p) -#else -# define UMM_MALLOC(s) kumm_malloc(s) -# define UMM_MEMALIGN(a,s) kumm_memalign(a,s) -# define UMM_FREE(p) kumm_free(p) -# define UMM_HEAPMEMEBER(p) umm_heapmember(p) -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/arch/xtensa/src/common/xtensa_mm.h b/arch/xtensa/src/common/xtensa_mm.h new file mode 100644 index 0000000000..a95faf5fe6 --- /dev/null +++ b/arch/xtensa/src/common/xtensa_mm.h @@ -0,0 +1,49 @@ +/**************************************************************************** + * arch/xtensa/src/common/xtensa_mm.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __ARCH_XTENSA_SRC_COMMON_XTENSA_MM_H +#define __ARCH_XTENSA_SRC_COMMON_XTENSA_MM_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Pre-processor Macros + ****************************************************************************/ + +#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM +# define UMM_MALLOC(s) up_imm_malloc(s) +# define UMM_MEMALIGN(a,s) up_imm_memalign(a,s) +# define UMM_FREE(p) up_imm_free(p) +# define UMM_HEAPMEMEBER(p) up_imm_heapmember(p) +#else +# define UMM_MALLOC(s) kumm_malloc(s) +# define UMM_MEMALIGN(a,s) kumm_memalign(a,s) +# define UMM_FREE(p) kumm_free(p) +# define UMM_HEAPMEMEBER(p) umm_heapmember(p) +#endif + +#endif /* __ARCH_XTENSA_SRC_COMMON_XTENSA_MM_H */ diff --git a/arch/xtensa/src/common/xtensa_releasestack.c b/arch/xtensa/src/common/xtensa_releasestack.c index 3cc406a43a..836d98f2dd 100644 --- a/arch/xtensa/src/common/xtensa_releasestack.c +++ b/arch/xtensa/src/common/xtensa_releasestack.c @@ -46,22 +46,7 @@ #include #include "xtensa.h" - -/**************************************************************************** - * Pre-processor Macros - ****************************************************************************/ - -#ifdef CONFIG_XTENSA_USE_SEPERATE_IMEM -# define UMM_MALLOC(s) up_imm_malloc(s) -# define UMM_MEMALIGN(a,s) up_imm_memalign(a,s) -# define UMM_FREE(p) up_imm_free(p) -# define UMM_HEAPMEMEBER(p) up_imm_heapmember(p) -#else -# define UMM_MALLOC(s) kumm_malloc(s) -# define UMM_MEMALIGN(a,s) kumm_memalign(a,s) -# define UMM_FREE(p) kumm_free(p) -# define UMM_HEAPMEMEBER(p) umm_heapmember(p) -#endif +#include "xtensa_mm.h" /**************************************************************************** * Public Functions