From 11a4d140f58b3c220f90fc3591c3d6e05840cca6 Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Thu, 19 Mar 2020 18:01:49 +0100 Subject: [PATCH] lib: update libmetal to release v2020.01.0 Origin: https://github.com/OpenAMP/libmetal commit: e3dfc2fe85e5ceb8b193c4cf559b17bbd53e8866 Status: merge libmetal new version after removing useless dirs. Release Description: https://github.com/OpenAMP/libmetal/releases/tag/v2020.01.0 Signed-off-by: Arnaud Pouliquen --- README | 2 +- libmetal/MAINTAINERS.md | 4 ++++ libmetal/lib/atomic.h | 2 -- libmetal/lib/device.c | 19 +++++++++---------- libmetal/lib/processor/ceva/cpu.h | 4 +--- libmetal/lib/processor/x86/CMakeLists.txt | 4 ++++ libmetal/lib/processor/x86/atomic.h | 16 ++++++++++++++++ libmetal/lib/processor/x86/cpu.h | 17 +++++++++++++++++ libmetal/lib/shmem.c | 8 ++++---- libmetal/lib/system/linux/device.c | 7 ++++++- libmetal/lib/system/nuttx/irq.c | 5 ++++- libmetal/lib/system/zephyr/mutex.h | 2 +- 12 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 libmetal/lib/processor/x86/CMakeLists.txt create mode 100644 libmetal/lib/processor/x86/atomic.h create mode 100644 libmetal/lib/processor/x86/cpu.h diff --git a/README b/README index 483248f..75da557 100644 --- a/README +++ b/README @@ -27,7 +27,7 @@ URL: https://github.com/OpenAMP/libmetal commit: - a4f763094cb26cd8f7abdff251f57a6a802c039d + e3dfc2fe85e5ceb8b193c4cf559b17bbd53e8866 Maintained-by: External diff --git a/libmetal/MAINTAINERS.md b/libmetal/MAINTAINERS.md index cad4395..5b481d0 100644 --- a/libmetal/MAINTAINERS.md +++ b/libmetal/MAINTAINERS.md @@ -9,6 +9,8 @@ names to be CC'd when submitting a patch. ## Project Administration Wendy Liang +Ed Mooring +Arnaud Pouliquen ### All patches CC here open-amp@googlegroups.com @@ -16,6 +18,8 @@ open-amp@googlegroups.com ## Machines ### Xilinx Platform - Zynq-7000 Wendy Liang +Ed Mooring ### Xilinx Platform - Zynq UltraScale+ MPSoC Wendy Liang +Ed Mooring diff --git a/libmetal/lib/atomic.h b/libmetal/lib/atomic.h index 29a7f9e..3e05631 100644 --- a/libmetal/lib/atomic.h +++ b/libmetal/lib/atomic.h @@ -18,8 +18,6 @@ !defined(__cplusplus) # include # include -#elif defined(__cplusplus) -# include #elif defined(__GNUC__) # include #else diff --git a/libmetal/lib/device.c b/libmetal/lib/device.c index 28fb34d..64758d4 100644 --- a/libmetal/lib/device.c +++ b/libmetal/lib/device.c @@ -43,11 +43,10 @@ int metal_bus_find(const char *name, struct metal_bus **result) metal_list_for_each(&_metal.common.bus_list, node) { bus = metal_container_of(node, struct metal_bus, node); - if (strcmp(bus->name, name) != 0) - continue; - if (result) + if (strcmp(bus->name, name) == 0 && result) { *result = bus; - return 0; + return 0; + } } return -ENOENT; } @@ -106,10 +105,10 @@ int metal_generic_dev_open(struct metal_bus *bus, const char *dev_name, metal_list_for_each(&_metal.common.generic_device_list, node) { dev = metal_container_of(node, struct metal_device, node); - if (strcmp(dev->name, dev_name) != 0) - continue; - *device = dev; - return metal_generic_dev_sys_open(dev); + if (strcmp(dev->name, dev_name) == 0) { + *device = dev; + return metal_generic_dev_sys_open(dev); + } } return -ENODEV; @@ -122,9 +121,9 @@ int metal_generic_dev_dma_map(struct metal_bus *bus, int nents_in, struct metal_sg *sg_out) { + int i; (void)bus; (void)device; - int i; if (sg_out != sg_in) memcpy(sg_out, sg_in, nents_in*(sizeof(struct metal_sg))); @@ -144,10 +143,10 @@ void metal_generic_dev_dma_unmap(struct metal_bus *bus, struct metal_sg *sg, int nents) { + int i; (void)bus; (void)device; (void)dir; - int i; for (i = 0; i < nents; i++) { metal_cache_invalidate(sg[i].virt, sg[i].len); diff --git a/libmetal/lib/processor/ceva/cpu.h b/libmetal/lib/processor/ceva/cpu.h index 21bcf1a..0274e33 100644 --- a/libmetal/lib/processor/ceva/cpu.h +++ b/libmetal/lib/processor/ceva/cpu.h @@ -14,12 +14,10 @@ #define metal_cpu_yield() -#ifdef TEAKLITE4 /* * The dummy implementation is enough here since - * tl42x don't support the out of order and multi core + * ceva dsp don't support the out of order and multi core */ #define __sync_synchronize() -#endif #endif /* __METAL_CEVA_CPU__H__ */ diff --git a/libmetal/lib/processor/x86/CMakeLists.txt b/libmetal/lib/processor/x86/CMakeLists.txt new file mode 100644 index 0000000..9e9c101 --- /dev/null +++ b/libmetal/lib/processor/x86/CMakeLists.txt @@ -0,0 +1,4 @@ +collect (PROJECT_LIB_HEADERS atomic.h) +collect (PROJECT_LIB_HEADERS cpu.h) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/libmetal/lib/processor/x86/atomic.h b/libmetal/lib/processor/x86/atomic.h new file mode 100644 index 0000000..bf98a9d --- /dev/null +++ b/libmetal/lib/processor/x86/atomic.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * @file gcc/atomic.h + * @brief GCC specific atomic primitives for libmetal. + */ + +#ifndef __METAL_X86_ATOMIC__H__ +#define __METAL_X86_ATOMIC__H__ + + +#endif /* __METAL_X86_ATOMIC__H__ */ diff --git a/libmetal/lib/processor/x86/cpu.h b/libmetal/lib/processor/x86/cpu.h new file mode 100644 index 0000000..7484c49 --- /dev/null +++ b/libmetal/lib/processor/x86/cpu.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2015, Xilinx Inc. and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * @file cpu.h + * @brief CPU specific primatives + */ + +#ifndef __METAL_X86_CPU__H__ +#define __METAL_X86_CPU__H__ + +#define metal_cpu_yield() asm volatile("rep; nop") + +#endif /* __METAL_X86_CPU__H__ */ diff --git a/libmetal/lib/shmem.c b/libmetal/lib/shmem.c index 8ff3dca..e78be38 100644 --- a/libmetal/lib/shmem.c +++ b/libmetal/lib/shmem.c @@ -38,10 +38,10 @@ int metal_shmem_open_generic(const char *name, size_t size, shmem = metal_container_of(node, struct metal_generic_shmem, node); if (strcmp(shmem->name, name) != 0) continue; - if (size > metal_io_region_size(&shmem->io)) - continue; - *result = &shmem->io; - return 0; + if (size <= metal_io_region_size(&shmem->io)) { + *result = &shmem->io; + return 0; + } } return -ENOENT; diff --git a/libmetal/lib/system/linux/device.c b/libmetal/lib/system/linux/device.c index 9accba4..b6e4ff0 100644 --- a/libmetal/lib/system/linux/device.c +++ b/libmetal/lib/system/linux/device.c @@ -656,8 +656,13 @@ int metal_linux_get_device_property(struct metal_device *device, fd = open(path, flags, mode); if (fd < 0) return -errno; - status = read(fd, output, len); + if (read(fd, output, len) < 0) { + status = -errno; + close(fd); + return status; + } + status = close(fd); return status < 0 ? -errno : 0; } diff --git a/libmetal/lib/system/nuttx/irq.c b/libmetal/lib/system/nuttx/irq.c index 00fbc66..476eab9 100644 --- a/libmetal/lib/system/nuttx/irq.c +++ b/libmetal/lib/system/nuttx/irq.c @@ -28,12 +28,14 @@ void metal_irq_restore_enable(unsigned int flags) static void metal_cntr_irq_set_enable(struct metal_irq_controller *cntr, int irq, unsigned int enable) { +#ifndef CONFIG_ARCH_NOINTC if (irq >= 0 && irq < cntr->irq_num) { if (enable == METAL_IRQ_ENABLE) up_enable_irq(irq); else up_disable_irq(irq); } +#endif } static int metal_cntr_irq_handler(int irq, void *context, void *data) @@ -78,7 +80,8 @@ static int metal_cntr_irq_attach(struct metal_irq_controller *cntr, int metal_cntr_irq_init(void) { static METAL_IRQ_CONTROLLER_DECLARE(metal_cntr_irq, - 0, NR_IRQS, + 0, + NR_IRQS ? NR_IRQS : 1, NULL, metal_cntr_irq_set_enable, metal_cntr_irq_attach, diff --git a/libmetal/lib/system/zephyr/mutex.h b/libmetal/lib/system/zephyr/mutex.h index 6ab20d4..bfe689f 100644 --- a/libmetal/lib/system/zephyr/mutex.h +++ b/libmetal/lib/system/zephyr/mutex.h @@ -29,7 +29,7 @@ typedef struct k_sem metal_mutex_t; * METAL_MUTEX_INIT - used for initializing an mutex elmenet in a static struct * or global */ -#define METAL_MUTEX_INIT(m) Z_SEM_INITIALIZER(m, 1, 1) +#define METAL_MUTEX_INIT(m) _K_SEM_INITIALIZER(m, 1, 1) /* * METAL_MUTEX_DEFINE - used for defining and initializing a global or * static singleton mutex