lib: system: re-enable the support of the template machine

The template machine is used in:
cmake/platforms/template-generic.cmake
cmake/platforms/template-freertos.cmake

This reverts a part of:
commit 16493b179f ("lib: system: remove xlnx BSP specific code")

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
This commit is contained in:
Arnaud Pouliquen
2025-10-21 17:32:17 +02:00
committed by Arnaud Pouliquen
parent 2f01e7e793
commit 9f749f092e
9 changed files with 236 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
#include <metal/errno.h>
#include <metal/cpu.h>
#include "./@PROJECT_MACHINE@/sys.h"
#ifdef __cplusplus
extern "C" {
#endif

View File

@@ -0,0 +1,4 @@
collect (PROJECT_LIB_HEADERS sys.h)
collect (PROJECT_LIB_SOURCES sys.c)

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2018, Linaro Inc. and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* @file freertos/template/sys.c
* @brief machine specific system primitives implementation.
*/
#include <metal/io.h>
#include <metal/sys.h>
#include <metal/utilities.h>
#include <stdint.h>
void sys_irq_restore_enable(unsigned int flags)
{
metal_unused(flags);
/* Add implementation here */
}
unsigned int sys_irq_save_disable(void)
{
return 0;
/* Add implementation here */
}
void sys_irq_enable(unsigned int vector)
{
metal_unused(vector);
/* Add implementation here */
}
void sys_irq_disable(unsigned int vector)
{
metal_unused(vector);
/* Add implementation here */
}
void metal_machine_cache_flush(void *addr, unsigned int len)
{
metal_unused(addr);
metal_unused(len);
/* Add implementation here */
}
void metal_machine_cache_invalidate(void *addr, unsigned int len)
{
metal_unused(addr);
metal_unused(len);
/* Add implementation here */
}
void metal_generic_default_poll(void)
{
/* Add implementation here */
}
void *metal_machine_io_mem_map(void *va, metal_phys_addr_t pa,
size_t size, unsigned int flags)
{
metal_unused(pa);
metal_unused(size);
metal_unused(flags);
/* Add implementation here */
return va;
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2018, Linaro Inc. and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* @file freertos/template/sys.h
* @brief freertos template system primitives for libmetal.
*/
#ifndef __METAL_FREERTOS_SYS__H__
#error "Include metal/sys.h instead of metal/freertos/@PROJECT_MACHINE@/sys.h"
#endif
#ifndef __METAL_FREERTOS_TEMPLATE_SYS__H__
#define __METAL_FREERTOS_TEMPLATE_SYS__H__
#include <metal/cpu.h>
#ifdef __cplusplus
extern "C" {
#endif
#define metal_yield() metal_cpu_yield()
#ifdef METAL_INTERNAL
void sys_irq_enable(unsigned int vector);
void sys_irq_disable(unsigned int vector);
#endif /* METAL_INTERNAL */
#ifdef __cplusplus
}
#endif
#endif /* __METAL_FREERTOS_SYS__H__ */

View File

@@ -0,0 +1,5 @@
collect (PROJECT_LIB_HEADERS sys.h)
collect (PROJECT_LIB_SOURCES irq.c)
collect (PROJECT_LIB_SOURCES sys.c)

View File

@@ -24,6 +24,7 @@
#include <stdarg.h>
#include <string.h>
#include "./@PROJECT_MACHINE@/sys.h"
#ifdef __cplusplus
extern "C" {
#endif

View File

@@ -0,0 +1,3 @@
collect (PROJECT_LIB_HEADERS sys.h)
collect (PROJECT_LIB_SOURCES sys.c)

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2018, Linaro Inc. and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* @file generic/template/sys.c
* @brief machine specific system primitives implementation.
*/
#include <metal/io.h>
#include <metal/sys.h>
#include <metal/utilities.h>
#include <stdint.h>
void sys_irq_restore_enable(unsigned int flags)
{
metal_unused(flags);
/* Add implementation here */
}
unsigned int sys_irq_save_disable(void)
{
return 0;
/* Add implementation here */
}
void sys_irq_enable(unsigned int vector)
{
metal_unused(vector);
/* Add implementation here */
}
void sys_irq_disable(unsigned int vector)
{
metal_unused(vector);
/* Add implementation here */
}
void metal_machine_cache_flush(void *addr, unsigned int len)
{
metal_unused(addr);
metal_unused(len);
/* Add implementation here */
}
void metal_machine_cache_invalidate(void *addr, unsigned int len)
{
metal_unused(addr);
metal_unused(len);
/* Add implementation here */
}
void metal_generic_default_poll(void)
{
/* Add implementation here */
}
void *metal_machine_io_mem_map(void *va, metal_phys_addr_t pa,
size_t size, unsigned int flags)
{
metal_unused(pa);
metal_unused(size);
metal_unused(flags);
/* Add implementation here */
return va;
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2018, Linaro Inc. and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* @file generic/template/sys.h
* @brief generic template system primitives for libmetal.
*/
#ifndef __METAL_GENERIC_SYS__H__
#error "Include metal/sys.h instead of metal/generic/@PROJECT_MACHINE@/sys.h"
#endif
#ifndef __METAL_GENERIC_TEMPLATE_SYS__H__
#define __METAL_GENERIC_TEMPLATE_SYS__H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef METAL_INTERNAL
void sys_irq_enable(unsigned int vector);
void sys_irq_disable(unsigned int vector);
#endif /* METAL_INTERNAL */
#ifdef __cplusplus
}
#endif
#endif /* __METAL_GENERIC_TEMPLATE_SYS__H__ */