diff --git a/libmetal/LICENSE.md b/libmetal/LICENSE.md index ec819a9..682bfd3 100644 --- a/libmetal/LICENSE.md +++ b/libmetal/LICENSE.md @@ -29,12 +29,53 @@ 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. +Apache License :2.0 +======================================== + +Copyright [yyyy] [name of copyright owner] + +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. + +GPL 2.0 +======================================== + +Copyright (C) yyyy name of author + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Linux Syscall Note +======================================== + +NOTE! This copyright does *not* cover user programs that use kernel services by normal system calls - this is merely considered normal use of the kernel, and does *not* fall under the heading of "derived work". Also note that the GPL below is copyrighted by the Free Software Foundation, but the instance of code that it refers to (the Linux kernel) is copyrighted by me and others who actually wrote it. + +Also note that the only valid version of the GPL as far as the kernel is concerned is _this_ particular version of the license (ie v2, not v2.2 or v3.x or whatever), unless explicitly otherwise stated. Notes ========================================= Use the following tag instead of the full license text in the individual files: SPDX-License-Identifier: BSD-3-Clause + SPDX-License-Identifier: Apache-2.0 + SPDX-License-Identifier: GPL-2.0 + SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note This enables machine processing of license information based on the SPDX License Identifiers that are here available: http://spdx.org/licenses/ diff --git a/libmetal/VERSION b/libmetal/VERSION index f9c6dae..1b7322b 100644 --- a/libmetal/VERSION +++ b/libmetal/VERSION @@ -1,3 +1,3 @@ VERSION_MAJOR = 1 -VERSION_MINOR = 2 +VERSION_MINOR = 3 VERSION_PATCH = 0 diff --git a/libmetal/cmake/options.cmake b/libmetal/cmake/options.cmake index d6cf568..9e51db4 100644 --- a/libmetal/cmake/options.cmake +++ b/libmetal/cmake/options.cmake @@ -72,5 +72,5 @@ option (WITH_DEFAULT_LOGGER "Build with default logger" ON) option (WITH_DOC "Build with documentation" ON) -set (PROJECT_EC_FLAGS "-Wall -Werror -Wextra" CACHE STRING "") +set (GLOBAL PROPERTY "PROJECT_EC_FLAGS" "-Wall -Werror -Wextra" CACHE STRING "") # vim: expandtab:ts=2:sw=2:smartindent diff --git a/libmetal/lib/CMakeLists.txt b/libmetal/lib/CMakeLists.txt index 121e0c6..e9d5276 100644 --- a/libmetal/lib/CMakeLists.txt +++ b/libmetal/lib/CMakeLists.txt @@ -65,6 +65,8 @@ if (WITH_DEFAULT_LOGGER) add_definitions (-DDEFAULT_LOGGER_ON) endif (WITH_DEFAULT_LOGGER) +get_property (_ec_flgs GLOBAL PROPERTY "PROJECT_EC_FLAGS") + if (WITH_ZEPHYR) zephyr_library_named(metal) add_dependencies(metal offsets_h) @@ -77,10 +79,7 @@ else (WITH_ZEPHYR) add_library (${_lib} SHARED ${_sources}) target_link_libraries (${_lib} ${_deps}) install (TARGETS ${_lib} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - if (PROJECT_EC_FLAGS) - string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS}) - target_compile_options (${_lib} PUBLIC ${_ec_flgs}) - endif (PROJECT_EC_FLAGS) + target_compile_options (${_lib} PUBLIC ${_ec_flgs}) set_target_properties (${_lib} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}" VERSION "${PROJECT_VERSION}" @@ -93,10 +92,7 @@ else (WITH_ZEPHYR) set (_lib ${PROJECT_NAME}-static) add_library (${_lib} STATIC ${_sources}) install (TARGETS ${_lib} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - if (PROJECT_EC_FLAGS) - string(REPLACE " " ";" _ec_flgs ${PROJECT_EC_FLAGS}) - target_compile_options (${_lib} PUBLIC ${_ec_flgs}) - endif (PROJECT_EC_FLAGS) + target_compile_options (${_lib} PUBLIC ${_ec_flgs}) set_target_properties (${_lib} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}" ) diff --git a/libmetal/lib/list.h b/libmetal/lib/list.h index d1286c3..eb0e7b3 100644 --- a/libmetal/lib/list.h +++ b/libmetal/lib/list.h @@ -12,6 +12,7 @@ #ifndef __METAL_LIST__H__ #define __METAL_LIST__H__ +#include #include #ifdef __cplusplus @@ -96,6 +97,18 @@ static inline struct metal_list *metal_list_first(struct metal_list *list) for ((node) = (list)->next; \ (node) != (list); \ (node) = (node)->next) + +static inline bool metal_list_find_node(struct metal_list *list, + struct metal_list *node) +{ + struct metal_list *n; + + metal_list_for_each(list, n) { + if (n == node) + return true; + } + return false; +} /** @} */ #ifdef __cplusplus diff --git a/libmetal/lib/system/freertos/zynqmp_r5/sys.c b/libmetal/lib/system/freertos/zynqmp_r5/sys.c index 358f79e..67405bb 100644 --- a/libmetal/lib/system/freertos/zynqmp_r5/sys.c +++ b/libmetal/lib/system/freertos/zynqmp_r5/sys.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, Xilinx Inc. and Contributors. All rights reserved. + * Copyright (C) 2022, Advanced Micro Devices, Inc. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -20,8 +21,6 @@ #include "xreg_cortexr5.h" #include "xscugic.h" -#define MPU_REGION_SIZE_MIN 0x20 - void sys_irq_restore_enable(unsigned int flags) { Xil_ExceptionEnableMask(~flags); @@ -61,27 +60,16 @@ void metal_weak metal_generic_default_poll(void) metal_asm volatile("wfi"); } +/** + * The code moved to cortexr5/xil_mpu.c:Xil_MemMap() + * NULL in pa masks possible Xil_MemMap() errors. + */ void *metal_machine_io_mem_map(void *va, metal_phys_addr_t pa, size_t size, unsigned int flags) { - size_t rsize = MPU_REGION_SIZE_MIN; - metal_phys_addr_t base_pa; + void *__attribute__((unused)) physaddr; - if (!flags) - return va; - while (1) { - if (rsize < size) { - rsize <<= 1; - continue; - } else { - base_pa = pa & ~(rsize - 1); - if ((base_pa + rsize) < (pa + size)) { - rsize <<= 1; - continue; - } - break; - } - } - Xil_SetMPURegion(base_pa, rsize, flags); + physaddr = Xil_MemMap(pa, size, flags); + metal_assert(physaddr == (void *)pa); return va; } diff --git a/libmetal/lib/system/generic/zynqmp_r5/sys.c b/libmetal/lib/system/generic/zynqmp_r5/sys.c index 357bde6..12aa1ab 100644 --- a/libmetal/lib/system/generic/zynqmp_r5/sys.c +++ b/libmetal/lib/system/generic/zynqmp_r5/sys.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, Xilinx Inc. and Contributors. All rights reserved. + * Copyright (C) 2022, Advanced Micro Devices, Inc. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -20,8 +21,6 @@ #include "xreg_cortexr5.h" #include "xscugic.h" -#define MPU_REGION_SIZE_MIN 0x20 - void sys_irq_restore_enable(unsigned int flags) { Xil_ExceptionEnableMask(~flags); @@ -61,27 +60,16 @@ void metal_weak metal_generic_default_poll(void) metal_asm volatile("wfi"); } +/** + * The code moved to cortexr5/xil_mpu.c:Xil_MemMap() + * NULL in pa masks possible Xil_MemMap() errors. + */ void *metal_machine_io_mem_map(void *va, metal_phys_addr_t pa, size_t size, unsigned int flags) { - size_t rsize = MPU_REGION_SIZE_MIN; - metal_phys_addr_t base_pa; + void *__attribute__((unused)) physaddr; - if (!flags) - return va; - while (1) { - if (rsize < size) { - rsize <<= 1; - continue; - } else { - base_pa = pa & ~(rsize - 1); - if ((base_pa + rsize) < (pa + size)) { - rsize <<= 1; - continue; - } - break; - } - } - Xil_SetMPURegion(base_pa, rsize, flags); + physaddr = Xil_MemMap(pa, size, flags); + metal_assert(physaddr == (void *)pa); return va; } diff --git a/libmetal/lib/system/zephyr/cache.h b/libmetal/lib/system/zephyr/cache.h index 164bff0..36f6a16 100644 --- a/libmetal/lib/system/zephyr/cache.h +++ b/libmetal/lib/system/zephyr/cache.h @@ -25,12 +25,12 @@ extern "C" { static inline void __metal_cache_flush(void *addr, unsigned int len) { - sys_cache_data_range(addr, len, K_CACHE_WB); + sys_cache_data_flush_range(addr, len); } static inline void __metal_cache_invalidate(void *addr, unsigned int len) { - sys_cache_data_range(addr, len, K_CACHE_INVD); + sys_cache_data_invd_range(addr, len); } #ifdef __cplusplus