lib: update libmetal to release v2021.10.0

Origin:
	https://github.com/OpenAMP/libmetal

commit:
	4ead69b8f4194ea60d4d78bc1d8b57b45b467699

Status:
	merge libmetal new version after removing useless dirs.

Release Description:
	https://github.com/OpenAMP/libmetal/releases/tag/v2021.10.0

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2021-11-01 11:02:30 +01:00 committed by Kumar Gala
parent 39d049d4ae
commit f237c9d420
17 changed files with 88 additions and 49 deletions

2
README
View File

@ -27,7 +27,7 @@ URL:
https://github.com/OpenAMP/libmetal
commit:
04cf5d9e0ef562d676cd3f58530fed4e1901f428
4ead69b8f4194ea60d4d78bc1d8b57b45b467699
Maintained-by:
External

View File

@ -1,6 +1,6 @@
# libmetal Maintainers
libmetal project is maintained by the OpenAMP open source community.
The libmetal project is maintained by the OpenAMP open source community.
Everyone is encouraged to submit issues and changes to improve libmetal.
The intention of this file is to provide a set of names that developers can
@ -8,15 +8,8 @@ consult when they have a question about OpenAMP and to provide a a set of
names to be CC'd when submitting a patch.
## Project Administration
Ed Mooring <ed.mooring@linaro.org>
Ed Mooring <ed.mooring@gmail.com>
Arnaud Pouliquen <arnaud.pouliquen@st.com>
### All patches CC here
openamp-rp@lists.openampproject.org
## Machines
### Xilinx Platform - Zynq-7000
Ed Mooring <ed.mooring@linaro.org>
### Xilinx Platform - Zynq UltraScale+ MPSoC
Ed Mooring <ed.mooring@linaro.org>

View File

@ -1,3 +1,3 @@
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_MINOR = 1
VERSION_PATCH = 0

View File

@ -7,7 +7,8 @@ if (WITH_ZEPHYR)
if (NOT WITH_ZEPHYR_LIB)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
endif()
if (CONFIG_CPU_CORTEX_M)
set (MACHINE "cortexm" CACHE STRING "")
endif (CONFIG_CPU_CORTEX_M)
if (CONFIG_ARM)
set (MACHINE "arm" CACHE STRING "")
endif(CONFIG_ARM)
endif (WITH_ZEPHYR)

View File

@ -39,7 +39,7 @@ int metal_io_block_read(struct metal_io_region *io, unsigned long offset,
unsigned char *dest = dst;
int retlen;
if (offset >= io->size)
if (!ptr)
return -ERANGE;
if ((offset + len) > io->size)
len = io->size - offset;
@ -76,7 +76,7 @@ int metal_io_block_write(struct metal_io_region *io, unsigned long offset,
const unsigned char *source = src;
int retlen;
if (offset >= io->size)
if (!ptr)
return -ERANGE;
if ((offset + len) > io->size)
len = io->size - offset;
@ -112,7 +112,7 @@ int metal_io_block_set(struct metal_io_region *io, unsigned long offset,
unsigned char *ptr = metal_io_virt(io, offset);
int retlen = len;
if (offset >= io->size)
if (!ptr)
return -ERANGE;
if ((offset + len) > io->size)
len = io->size - offset;

View File

@ -132,7 +132,7 @@ static inline void *
metal_io_virt(struct metal_io_region *io, unsigned long offset)
{
return (io->virt != METAL_BAD_VA && offset < io->size
? (uint8_t *)io->virt + offset
? (void *)((uintptr_t)io->virt + offset)
: NULL);
}
@ -145,7 +145,7 @@ metal_io_virt(struct metal_io_region *io, unsigned long offset)
static inline unsigned long
metal_io_virt_to_offset(struct metal_io_region *io, void *virt)
{
size_t offset = (uint8_t *)virt - (uint8_t *)io->virt;
size_t offset = (uintptr_t)virt - (uintptr_t)io->virt;
return (offset < io->size ? offset : METAL_BAD_OFFSET);
}

View File

@ -0,0 +1,2 @@
collect (PROJECT_LIB_HEADERS atomic.h)
collect (PROJECT_LIB_HEADERS cpu.h)

View File

@ -0,0 +1,15 @@
/*
* Copyright (c) 2021, Xiaomi Inc. and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* @file xtensa/atomic.h
* @brief Xtensa specific atomic primitives for libmetal.
*/
#ifndef __METAL_XTENSA_ATOMIC__H__
#define __METAL_XTENSA_ATOMIC__H__
#endif /* __METAL_XTENSA_ATOMIC__H__ */

View File

@ -0,0 +1,18 @@
/*
* Copyright (c) 2021, Xiaomi Inc. and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* @file cpu.h
* @brief CPU specific primatives
*/
#ifndef __METAL_XTENSA_CPU__H__
#define __METAL_XTENSA_CPU__H__
#define metal_cpu_yield()
#define __sync_synchronize()
#endif /* __METAL_XTENSA_CPU__H__ */

View File

@ -16,24 +16,34 @@
#ifndef __METAL_FREERTOS_MUTEX__H__
#define __METAL_FREERTOS_MUTEX__H__
#include <metal/atomic.h>
#include <metal/assert.h>
#include "FreeRTOS.h"
#include "semphr.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
atomic_int v;
SemaphoreHandle_t m;
} metal_mutex_t;
#define METAL_MUTEX_UNLOCKED 0
#define METAL_MUTEX_LOCKED 1
/*
* METAL_MUTEX_INIT - used for initializing an mutex element in a static struct
* or global
*/
#define METAL_MUTEX_INIT(m) { ATOMIC_VAR_INIT(METAL_MUTEX_UNLOCKED) }
#if defined(__GNUC__)
#define METAL_MUTEX_INIT(m) { NULL }; \
_Pragma("GCC warning\"static initialisation of the mutex is deprecated\"")
#elif defined(__ICCARM__)
#define DO_PRAGMA(x) _Pragma(#x)
#define METAL_MUTEX_INIT(m) { NULL }; \
DO_PRAGMA(message("Warning: static initialisation of the mutex is deprecated"))
#else
#define METAL_MUTEX_INIT(m) { NULL }
#endif
/*
* METAL_MUTEX_DEFINE - used for defining and initializing a global or
* static singleton mutex
@ -42,44 +52,40 @@ typedef struct {
static inline void __metal_mutex_init(metal_mutex_t *mutex)
{
atomic_store(&mutex->v, METAL_MUTEX_UNLOCKED);
metal_assert(mutex);
mutex->m = xSemaphoreCreateMutex();
metal_assert(mutex->m);
}
static inline void __metal_mutex_deinit(metal_mutex_t *mutex)
{
(void)mutex;
metal_assert(mutex && mutex->m);
vSemaphoreDelete(mutex->m);
mutex->m = NULL;
}
static inline int __metal_mutex_try_acquire(metal_mutex_t *mutex)
{
int unlocked = METAL_MUTEX_UNLOCKED;
if (atomic_compare_exchange_strong(&mutex->v, &unlocked,
METAL_MUTEX_LOCKED)) {
return 1; /* acquired */
} else {
return 0; /* not acquired */
}
metal_assert(mutex && mutex->m);
return xSemaphoreTake(mutex->m, (TickType_t)0);
}
static inline void __metal_mutex_acquire(metal_mutex_t *mutex)
{
int unlocked = METAL_MUTEX_UNLOCKED;
while (!atomic_compare_exchange_weak(&mutex->v, &unlocked,
METAL_MUTEX_LOCKED)) {
;
}
metal_assert(mutex && mutex->m);
xSemaphoreTake(mutex->m, portMAX_DELAY);
}
static inline void __metal_mutex_release(metal_mutex_t *mutex)
{
atomic_store(&mutex->v, METAL_MUTEX_UNLOCKED);
metal_assert(mutex && mutex->m);
xSemaphoreGive(mutex->m);
}
static inline int __metal_mutex_is_acquired(metal_mutex_t *mutex)
{
return atomic_load(&mutex->v);
metal_assert(mutex && mutex->m);
return (!xSemaphoreGetMutexHolder(mutex->m)) ? 0 : 1;
}
#ifdef __cplusplus

View File

@ -5,7 +5,7 @@
*/
/*
* @file generic/template/sys.c
* @file freertos/template/sys.c
* @brief machine specific system primitives implementation.
*/

View File

@ -266,7 +266,12 @@ static void metal_uio_dev_close(struct linux_bus *lbus,
struct linux_device *ldev)
{
(void)lbus;
unsigned int i;
for (i = 0; i < ldev->device.num_regions; i++) {
metal_unmap(ldev->device.regions[i].virt,
ldev->device.regions[i].size);
}
if (ldev->override) {
sysfs_write_attribute(ldev->override, "", 1);
ldev->override = NULL;

View File

@ -75,13 +75,13 @@ static void metal_io_close_(struct metal_io_region *io)
static metal_phys_addr_t metal_io_offset_to_phys_(struct metal_io_region *io,
unsigned long offset)
{
return up_addrenv_va_to_pa((char *)io->virt + offset);
return up_addrenv_va_to_pa((void *)((uintptr_t)io->virt + offset));
}
static unsigned long metal_io_phys_to_offset_(struct metal_io_region *io,
metal_phys_addr_t phys)
{
return (char *)up_addrenv_pa_to_va(phys) - (char *)io->virt;
return (uintptr_t)up_addrenv_pa_to_va(phys) - (uintptr_t)io->virt;
}
static metal_phys_addr_t metal_io_phys_start_;

View File

@ -25,13 +25,12 @@ extern "C" {
static inline void __metal_cache_flush(void *addr, unsigned int len)
{
sys_cache_flush((vaddr_t) addr, len);
sys_cache_data_range(addr, len, K_CACHE_WB);
}
static inline void __metal_cache_invalidate(void *addr, unsigned int len)
{
metal_unused(addr);
metal_unused(len);
sys_cache_data_range(addr, len, K_CACHE_INVD);
}
#ifdef __cplusplus