1diff -uparN libmetal-2022.10.0/cmake/platforms/uniproton_arm64_gcc.cmake libmetal/cmake/platforms/uniproton_arm64_gcc.cmake 2--- libmetal-2022.10.0/cmake/platforms/uniproton_arm64_gcc.cmake 1970-01-01 08:00:00.000000000 +0800 3+++ libmetal/cmake/platforms/uniproton_arm64_gcc.cmake 2023-02-22 11:01:30.000000000 +0800 4@@ -0,0 +1,16 @@ 5+#cross-compilation config 6+ 7+set(CMAKE_SYSTEM_PROCESSOR arm) 8+set(PROJECT_SYSTEM uniproton) 9+ 10+set(CMAKE_C_COMPILER_WORKS 1) 11+set(CMAKE_CXX_COMPILER_WORKS 1) 12+ 13+set(CROSS_PREFIX "/opt/buildtools/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-" CACHE STRING "") 14+set(CMAKE_C_COMPILER "${CROSS_PREFIX}gcc" CACHE STRING "") 15+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE STRING "") 16+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER CACHE STRING "") 17+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER CACHE STRING "") 18+set(CMAKE_C_FLAGS "-D_GNU_SOURCE -D_POSIX_THREADS -D_POSIX_THREAD_PRIORITY_SCHEDULING -D_POSIX_PRIORITY_SCHEDULING -D_POSIX_TIMERS -D_POSIX_CPUTIME -D_POSIX_THREAD_CPUTIME -D_POSIX_MONOTONIC_CLOCK -D_POSIX_TIMEOUTS -D_POSIX_CLOCK_SELECTION -D_POSIX_THREAD_PRIO_PROTECT -D_UNIX98_THREAD_MUTEX_ATTRIBUTES -D_POSIX_READER_WRITER_LOCKS" CACHE STRING "") 19+ 20+# vim: expandtab:ts=2:sw=2:smartindent 21diff -uparN libmetal-2022.10.0/CMakeLists.txt libmetal/CMakeLists.txt 22--- libmetal-2022.10.0/CMakeLists.txt 2022-10-28 10:12:23.000000000 +0800 23+++ libmetal/CMakeLists.txt 2023-02-24 16:25:04.000000000 +0800 24@@ -6,7 +6,8 @@ endif() 25 if (POLICY CMP0077) 26 cmake_policy(SET CMP0077 NEW) 27 endif() 28- 29+include_directories(../../include) 30+set (CMAKE_SYSTEM_NAME Uniproton) 31 set (LIBMETAL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 32 33 list (APPEND CMAKE_MODULE_PATH 34diff -uparN libmetal-2022.10.0/lib/system/uniproton/alloc.h libmetal/lib/system/uniproton/alloc.h 35--- libmetal-2022.10.0/lib/system/uniproton/alloc.h 1970-01-01 08:00:00.000000000 +0800 36+++ libmetal/lib/system/uniproton/alloc.h 2023-02-20 14:53:22.000000000 +0800 37@@ -0,0 +1,39 @@ 38+/* 39+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 40+ * 41+ * SPDX-License-Identifier: BSD-3-Clause 42+ */ 43+ 44+/* 45+ * @file uniproton/alloc.h 46+ * @brief Uniproton libmetal memory allocattion definitions. 47+ */ 48+ 49+#ifndef __METAL_ALLOC__H__ 50+#error "Include metal/alloc.h instead of metal/uniproton/alloc.h" 51+#endif 52+ 53+#ifndef __METAL_UNIPROTON_ALLOC__H__ 54+#define __METAL_UNIPROTON_ALLOC__H__ 55+ 56+#include "prt_mem.h" 57+ 58+#ifdef __cplusplus 59+extern "C" { 60+#endif 61+ 62+static inline void *metal_allocate_memory(unsigned int size) 63+{ 64+ return PRT_MemAlloc(OS_MID_SYS, OS_MEM_DEFAULT_PT0, size); 65+} 66+ 67+static inline void metal_free_memory(void *ptr) 68+{ 69+ PRT_MemFree(OS_MID_SYS, ptr); 70+} 71+ 72+#ifdef __cplusplus 73+} 74+#endif 75+ 76+#endif /* __METAL_UNIPROTON_ALLOC__H__ */ 77diff -uparN libmetal-2022.10.0/lib/system/uniproton/assert.h libmetal/lib/system/uniproton/assert.h 78--- libmetal-2022.10.0/lib/system/uniproton/assert.h 1970-01-01 08:00:00.000000000 +0800 79+++ libmetal/lib/system/uniproton/assert.h 2022-12-26 10:59:44.000000000 +0800 80@@ -0,0 +1,26 @@ 81+/* 82+ * Copyright (c) 2018, Xilinx Inc. and Contributors. All rights reserved. 83+ * 84+ * SPDX-License-Identifier: BSD-3-Clause 85+ */ 86+ 87+/* 88+ * @file assert.h 89+ * @brief Uniproton assertion support. 90+ */ 91+ 92+#ifndef __METAL_ASSERT__H__ 93+#error "Include metal/assert.h instead of metal/uniproton/assert.h" 94+#endif 95+ 96+#ifndef __METAL_UNIPROTON_ASSERT__H__ 97+#define __METAL_UNIPROTON_ASSERT__H__ 98+ 99+/** 100+ * @brief Assertion macro. 101+ * @param cond Condition to test. 102+ */ 103+#define metal_sys_assert(cond) 104+ 105+#endif /* __METAL_UNIPROTON_ASSERT__H__ */ 106+ 107diff -uparN libmetal-2022.10.0/lib/system/uniproton/cache.h libmetal/lib/system/uniproton/cache.h 108--- libmetal-2022.10.0/lib/system/uniproton/cache.h 1970-01-01 08:00:00.000000000 +0800 109+++ libmetal/lib/system/uniproton/cache.h 2022-12-26 11:02:08.000000000 +0800 110@@ -0,0 +1,39 @@ 111+/* 112+ * Copyright (c) 2018, Linaro Limited. and Contributors. All rights reserved. 113+ * 114+ * SPDX-License-Identifier: BSD-3-Clause 115+ */ 116+ 117+/* 118+ * @file uniproton/cache.h 119+ * @brief Uniproton cache operation primitives for libmetal. 120+ */ 121+ 122+#ifndef __METAL_CACHE__H__ 123+#error "Include metal/cache.h instead of metal/uniproton/cache.h" 124+#endif 125+ 126+#ifndef __METAL_UNIPROTON_CACHE__H__ 127+#define __METAL_UNIPROTON_CACHE__H__ 128+ 129+#ifdef __cplusplus 130+extern "C" { 131+#endif 132+ 133+static inline void __metal_cache_flush(void *addr, unsigned int len) 134+{ 135+ (void)addr; 136+ (void)len; 137+} 138+ 139+static inline void __metal_cache_invalidate(void *addr, unsigned int len) 140+{ 141+ (void)addr; 142+ (void)len; 143+} 144+ 145+#ifdef __cplusplus 146+} 147+#endif 148+ 149+#endif /* __METAL_UNIPROTON_CACHE__H__ */ 150diff -uparN libmetal-2022.10.0/lib/system/uniproton/CMakeLists.txt libmetal/lib/system/uniproton/CMakeLists.txt 151--- libmetal-2022.10.0/lib/system/uniproton/CMakeLists.txt 1970-01-01 08:00:00.000000000 +0800 152+++ libmetal/lib/system/uniproton/CMakeLists.txt 2022-12-26 14:13:48.000000000 +0800 153@@ -0,0 +1,17 @@ 154+collect (PROJECT_LIB_HEADERS alloc.h) 155+collect (PROJECT_LIB_HEADERS assert.h) 156+collect (PROJECT_LIB_HEADERS cache.h) 157+collect (PROJECT_LIB_HEADERS condition.h) 158+collect (PROJECT_LIB_HEADERS io.h) 159+collect (PROJECT_LIB_HEADERS irq.h) 160+collect (PROJECT_LIB_HEADERS log.h) 161+collect (PROJECT_LIB_HEADERS mutex.h) 162+collect (PROJECT_LIB_HEADERS sleep.h) 163+collect (PROJECT_LIB_HEADERS sys.h) 164+ 165+collect (PROJECT_LIB_SOURCES condition.c) 166+collect (PROJECT_LIB_SOURCES device.c) 167+collect (PROJECT_LIB_SOURCES init.c) 168+collect (PROJECT_LIB_SOURCES shmem.c) 169+ 170+# vim: expandtab:ts=2:sw=2:smartindent 171diff -uparN libmetal-2022.10.0/lib/system/uniproton/condition.c libmetal/lib/system/uniproton/condition.c 172--- libmetal-2022.10.0/lib/system/uniproton/condition.c 1970-01-01 08:00:00.000000000 +0800 173+++ libmetal/lib/system/uniproton/condition.c 2022-12-26 11:06:12.000000000 +0800 174@@ -0,0 +1,33 @@ 175+/* 176+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 177+ * 178+ * SPDX-License-Identifier: BSD-3-Clause 179+ */ 180+ 181+/* 182+ * @file uniproton/condition.c 183+ * @brief Uniproton libmetal condition variable handling. 184+ */ 185+ 186+#include <metal/condition.h> 187+#include <metal/irq.h> 188+#include <metal/errno.h> 189+ 190+int metal_condition_wait(struct metal_condition *cv, 191+ metal_mutex_t *m) 192+{ 193+ unsigned int flags; 194+ 195+ /* Check if the mutex has been acquired */ 196+ if (!cv || !m || !metal_mutex_is_acquired(m)) { 197+ return -EINVAL; 198+ } 199+ 200+ flags = metal_irq_save_disable(); 201+ /* Release the mutex first. */ 202+ metal_mutex_release(m); 203+ metal_irq_restore_enable(flags); 204+ /* Acquire the mutex again. */ 205+ metal_mutex_acquire(m); 206+ return 0; 207+} 208diff -uparN libmetal-2022.10.0/lib/system/uniproton/condition.h libmetal/lib/system/uniproton/condition.h 209--- libmetal-2022.10.0/lib/system/uniproton/condition.h 1970-01-01 08:00:00.000000000 +0800 210+++ libmetal/lib/system/uniproton/condition.h 2022-12-26 11:09:02.000000000 +0800 211@@ -0,0 +1,30 @@ 212+/* 213+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 214+ * 215+ * SPDX-License-Identifier: BSD-3-Clause 216+ */ 217+ 218+/* 219+ * @file uniproton/condition.h 220+ * @brief Uniproton condition variable primitives for libmetal. 221+ */ 222+ 223+#ifndef __METAL_CONDITION__H__ 224+#error "Include metal/condition.h instead of metal/uniproton/condition.h" 225+#endif 226+ 227+#ifndef __METAL_UNIPROTON_CONDITION__H__ 228+#define __METAL_UNIPROTON_CONDITION__H__ 229+ 230+#include <metal/mutex.h> 231+#include <metal/utilities.h> 232+ 233+#ifdef __cplusplus 234+extern "C" { 235+#endif 236+ 237+#ifdef __cplusplus 238+} 239+#endif 240+ 241+#endif /* __METAL_UNIPROTON_CONDITION__H__ */ 242diff -uparN libmetal-2022.10.0/lib/system/uniproton/device.c libmetal/lib/system/uniproton/device.c 243--- libmetal-2022.10.0/lib/system/uniproton/device.c 1970-01-01 08:00:00.000000000 +0800 244+++ libmetal/lib/system/uniproton/device.c 2022-12-26 11:13:30.000000000 +0800 245@@ -0,0 +1,21 @@ 246+/* 247+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 248+ * 249+ * SPDX-License-Identifier: BSD-3-Clause 250+ */ 251+ 252+/* 253+ * @file uniproton/device.c 254+ * @brief Uniproton libmetal device definitions. 255+ */ 256+ 257+#include <metal/device.h> 258+#include <metal/io.h> 259+#include <metal/sys.h> 260+#include <metal/utilities.h> 261+ 262+int metal_generic_dev_sys_open(struct metal_device *dev) 263+{ 264+ return 0; 265+} 266+ 267diff -uparN libmetal-2022.10.0/lib/system/uniproton/init.c libmetal/lib/system/uniproton/init.c 268--- libmetal-2022.10.0/lib/system/uniproton/init.c 1970-01-01 08:00:00.000000000 +0800 269+++ libmetal/lib/system/uniproton/init.c 2022-12-26 11:14:34.000000000 +0800 270@@ -0,0 +1,27 @@ 271+/* 272+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 273+ * 274+ * SPDX-License-Identifier: BSD-3-Clause 275+ */ 276+ 277+/* 278+ * @file uniproton/init.c 279+ * @brief Uniproton libmetal initialization. 280+ */ 281+ 282+#include <metal/device.h> 283+#include <metal/sys.h> 284+ 285+struct metal_state _metal; 286+ 287+int metal_sys_init(const struct metal_init_params *params) 288+{ 289+ (void)params; 290+ metal_bus_register(&metal_generic_bus); 291+ return 0; 292+} 293+ 294+void metal_sys_finish(void) 295+{ 296+ metal_bus_unregister(&metal_generic_bus); 297+} 298diff -uparN libmetal-2022.10.0/lib/system/uniproton/io.h libmetal/lib/system/uniproton/io.h 299--- libmetal-2022.10.0/lib/system/uniproton/io.h 1970-01-01 08:00:00.000000000 +0800 300+++ libmetal/lib/system/uniproton/io.h 2022-12-26 11:16:50.000000000 +0800 301@@ -0,0 +1,37 @@ 302+/* 303+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 304+ * 305+ * SPDX-License-Identifier: BSD-3-Clause 306+ */ 307+ 308+/* 309+ * @file uniproton/io.h 310+ * @brief Uniproton specific io definitions. 311+ */ 312+ 313+#ifndef __METAL_IO__H__ 314+#error "Include metal/io.h instead of metal/uniproton/io.h" 315+#endif 316+ 317+#ifndef __METAL_UNIPROTON_IO__H__ 318+#define __METAL_UNIPROTON_IO__H__ 319+ 320+#ifdef __cplusplus 321+extern "C" { 322+#endif 323+ 324+#ifdef METAL_INTERNAL 325+/** 326+ * @brief memory mapping for an I/O region 327+ */ 328+static inline void metal_sys_io_mem_map(struct metal_io_region *io) 329+{ 330+ (void)io; 331+} 332+#endif 333+ 334+#ifdef __cplusplus 335+} 336+#endif 337+ 338+#endif /* __METAL_UNIPROTON_IO__H__ */ 339diff -uparN libmetal-2022.10.0/lib/system/uniproton/irq.h libmetal/lib/system/uniproton/irq.h 340--- libmetal-2022.10.0/lib/system/uniproton/irq.h 1970-01-01 08:00:00.000000000 +0800 341+++ libmetal/lib/system/uniproton/irq.h 2022-12-26 11:17:54.000000000 +0800 342@@ -0,0 +1,27 @@ 343+/* 344+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 345+ * 346+ * SPDX-License-Identifier: BSD-3-Clause 347+ */ 348+ 349+/* 350+ * @file uniproton/irq.c 351+ * @brief Uniproton libmetal irq definitions. 352+ */ 353+ 354+#ifndef __METAL_IRQ__H__ 355+#error "Include metal/irq.h instead of metal/uniproton/irq.h" 356+#endif 357+ 358+#ifndef __METAL_UNIPROTON_IRQ__H__ 359+#define __METAL_UNIPROTON_IRQ__H__ 360+ 361+#ifdef __cplusplus 362+extern "C" { 363+#endif 364+ 365+#ifdef __cplusplus 366+} 367+#endif 368+ 369+#endif /* __METAL_UNIPROTON_IRQ__H__ */ 370diff -uparN libmetal-2022.10.0/lib/system/uniproton/log.h libmetal/lib/system/uniproton/log.h 371--- libmetal-2022.10.0/lib/system/uniproton/log.h 1970-01-01 08:00:00.000000000 +0800 372+++ libmetal/lib/system/uniproton/log.h 2022-12-26 11:19:38.000000000 +0800 373@@ -0,0 +1,27 @@ 374+/* 375+ * Copyright (c) 2018, Xilinx Inc. and Contributors. All rights reserved. 376+ * 377+ * SPDX-License-Identifier: BSD-3-Clause 378+ */ 379+ 380+/* 381+ * @file uniproton/log.h 382+ * @brief Uniproton libmetal log handler definition. 383+ */ 384+ 385+#ifndef __METAL_METAL_LOG__H__ 386+#error "Include metal/log.h instead of metal/uniproton/log.h" 387+#endif 388+ 389+#ifndef __METAL_UNIPROTON_LOG__H__ 390+#define __METAL_UNIPROTON_LOG__H__ 391+ 392+#ifdef __cplusplus 393+extern "C" { 394+#endif 395+ 396+#ifdef __cplusplus 397+} 398+#endif 399+ 400+#endif /* __METAL_UNIPROTON_LOG__H__ */ 401diff -uparN libmetal-2022.10.0/lib/system/uniproton/mutex.h libmetal/lib/system/uniproton/mutex.h 402--- libmetal-2022.10.0/lib/system/uniproton/mutex.h 1970-01-01 08:00:00.000000000 +0800 403+++ libmetal/lib/system/uniproton/mutex.h 2023-02-23 14:22:12.000000000 +0800 404@@ -0,0 +1,73 @@ 405+/* 406+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 407+ * 408+ * SPDX-License-Identifier: BSD-3-Clause 409+ */ 410+ 411+/* 412+ * @file uniproton/mutex.h 413+ * @brief Uniproton mutex primitives for libmetal. 414+ */ 415+ 416+#ifndef __METAL_MUTEX__H__ 417+#error "Include metal/mutex.h instead of metal/uniproton/mutex.h" 418+#endif 419+ 420+#ifndef __METAL_UNIPROTON_MUTEX__H__ 421+#define __METAL_UNIPROTON_MUTEX__H__ 422+ 423+#include "errno.h" 424+#include "pthread.h" 425+ 426+#ifdef __cplusplus 427+extern "C" { 428+#endif 429+ 430+typedef pthread_mutex_t metal_mutex_t; 431+ 432+/* 433+ * METAL_MUTEX_INIT - used for initializing an mutex element in a static struct 434+ * or global 435+ */ 436+#define METAL_MUTEX_INIT(m) MUTEX_INITIALIZER 437+/* 438+ * METAL_MUTEX_DEFINE - used for defining and initializing a global or 439+ * static singleton mutex 440+ */ 441+#define METAL_MUTEX_DEFINE(m) metal_mutex_t m = MUTEX_INITIALIZER 442+ 443+static inline void __metal_mutex_init(metal_mutex_t *mutex) 444+{ 445+ pthread_mutex_init(mutex, NULL); 446+} 447+ 448+static inline void __metal_mutex_deinit(metal_mutex_t *mutex) 449+{ 450+ pthread_mutex_destroy(mutex); 451+} 452+ 453+static inline int __metal_mutex_try_acquire(metal_mutex_t *mutex) 454+{ 455+ return pthread_mutex_trylock(mutex); 456+} 457+ 458+static inline int __metal_mutex_is_acquired(metal_mutex_t *mutex) 459+{ 460+ 461+} 462+ 463+static inline void __metal_mutex_acquire(metal_mutex_t *mutex) 464+{ 465+ pthread_mutex_lock(mutex); 466+} 467+ 468+static inline void __metal_mutex_release(metal_mutex_t *mutex) 469+{ 470+ pthread_mutex_unlock(mutex); 471+} 472+ 473+#ifdef __cplusplus 474+} 475+#endif 476+ 477+#endif /* __METAL_UNIPROTON_MUTEX__H__ */ 478diff -uparN libmetal-2022.10.0/lib/system/uniproton/shmem.c libmetal/lib/system/uniproton/shmem.c 479--- libmetal-2022.10.0/lib/system/uniproton/shmem.c 1970-01-01 08:00:00.000000000 +0800 480+++ libmetal/lib/system/uniproton/shmem.c 2022-12-26 11:20:44.000000000 +0800 481@@ -0,0 +1,19 @@ 482+/* 483+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 484+ * 485+ * SPDX-License-Identifier: BSD-3-Clause 486+ */ 487+ 488+/* 489+ * 490+ * @file uniproton/shmem.c 491+ * @brief Uniproton libmetal shared memory handling. 492+ */ 493+ 494+#include <metal/shmem.h> 495+ 496+int metal_shmem_open(const char *name, size_t size, 497+ struct metal_io_region **io) 498+{ 499+ return metal_shmem_open_generic(name, size, io); 500+} 501diff -uparN libmetal-2022.10.0/lib/system/uniproton/sleep.h libmetal/lib/system/uniproton/sleep.h 502--- libmetal-2022.10.0/lib/system/uniproton/sleep.h 1970-01-01 08:00:00.000000000 +0800 503+++ libmetal/lib/system/uniproton/sleep.h 2023-02-22 16:55:06.000000000 +0800 504@@ -0,0 +1,34 @@ 505+/* 506+ * Copyright (c) 2018, Linaro Limited. and Contributors. All rights reserved. 507+ * 508+ * SPDX-License-Identifier: BSD-3-Clause 509+ */ 510+ 511+/* 512+ * @file uniproton/sleep.h 513+ * @brief Uniproton sleep primitives for libmetal. 514+ */ 515+ 516+#ifndef __METAL_SLEEP__H__ 517+#error "Include metal/sleep.h instead of metal/uniproton/sleep.h" 518+#endif 519+ 520+#ifndef __METAL_UNIPROTON_SLEEP__H__ 521+#define __METAL_UNIPROTON_SLEEP__H__ 522+ 523+#include "prt_task.h" 524+ 525+#ifdef __cplusplus 526+extern "C" { 527+#endif 528+ 529+static inline int __metal_sleep_usec(unsigned int usec) 530+{ 531+ return PRT_TaskDelay((U32)(usec / 1000)); 532+} 533+ 534+#ifdef __cplusplus 535+} 536+#endif 537+ 538+#endif /* __METAL_UNIPROTON_SLEEP__H__ */ 539diff -uparN libmetal-2022.10.0/lib/system/uniproton/sys.h libmetal/lib/system/uniproton/sys.h 540--- libmetal-2022.10.0/lib/system/uniproton/sys.h 1970-01-01 08:00:00.000000000 +0800 541+++ libmetal/lib/system/uniproton/sys.h 2022-12-26 11:25:18.000000000 +0800 542@@ -0,0 +1,39 @@ 543+/* 544+ * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved. 545+ * 546+ * SPDX-License-Identifier: BSD-3-Clause 547+ */ 548+ 549+/* 550+ * @file uniproton/sys.h 551+ * @brief Uniproton system primitives for libmetal. 552+ */ 553+ 554+#ifndef __METAL_SYS__H__ 555+#error "Include metal/sys.h instead of metal/uniproton/sys.h" 556+#endif 557+ 558+#ifndef __METAL_UNIPROTON_SYS__H__ 559+#define __METAL_UNIPROTON_SYS__H__ 560+ 561+#ifdef __cplusplus 562+extern "C" { 563+#endif 564+ 565+#define METAL_INIT_DEFAULTS \ 566+{ \ 567+ .log_handler = metal_default_log_handler, \ 568+ .log_level = METAL_LOG_INFO, \ 569+} 570+ 571+/** Structure of libmetal runtime state. */ 572+struct metal_state { 573+ /** Common (system independent) data. */ 574+ struct metal_common_state common; 575+}; 576+ 577+#ifdef __cplusplus 578+} 579+#endif 580+ 581+#endif /* __METAL_UNIPROTON_SYS__H__ */ 582