From 047502a759b2ad397bf4a651c0e7e3cc5f6ab101 Mon Sep 17 00:00:00 2001 From: BujSet Date: Tue, 1 Jul 2025 15:36:23 +0000 Subject: [PATCH 1/2] New pal for zephyr --- runtime/platform/zephyr.cpp | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 runtime/platform/zephyr.cpp diff --git a/runtime/platform/zephyr.cpp b/runtime/platform/zephyr.cpp new file mode 100644 index 00000000000..b76cbb81345 --- /dev/null +++ b/runtime/platform/zephyr.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * @file + * PAL implementations for Arm Zephyr RTOS. + */ + +#include +#include +#include + +void et_pal_init(void) {} + +ET_NORETURN void et_pal_abort(void) { + k_panic(); + // k_panic() should never return, but ensure compiler knows this + while (1) { + /* Never reached */ + } +} + +et_timestamp_t et_pal_current_ticks(void) { + return k_uptime_ticks(); +} + +et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) { + return { NSEC_PER_SEC, sys_clock_hw_cycles_per_sec() }; +} + +void et_pal_emit_log_message( + ET_UNUSED et_timestamp_t timestamp, + ET_UNUSED et_pal_log_level_t level, + ET_UNUSED const char* filename, + ET_UNUSED const char* function, + ET_UNUSED size_t line, + const char* message, + ET_UNUSED size_t length) { + printk("%s\n", message); +} + +void* et_pal_allocate(size_t size) { + return k_malloc(size); +} + +void et_pal_free(void* ptr) { + k_free(ptr); +} From 48ad280b0c33ada17374b306629d9e46d4d89e9e Mon Sep 17 00:00:00 2001 From: BujSet Date: Tue, 1 Jul 2025 19:33:35 +0000 Subject: [PATCH 2/2] Linting --- runtime/platform/zephyr.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime/platform/zephyr.cpp b/runtime/platform/zephyr.cpp index b76cbb81345..cb98fb68f1a 100644 --- a/runtime/platform/zephyr.cpp +++ b/runtime/platform/zephyr.cpp @@ -18,19 +18,19 @@ void et_pal_init(void) {} ET_NORETURN void et_pal_abort(void) { - k_panic(); - // k_panic() should never return, but ensure compiler knows this - while (1) { - /* Never reached */ - } + k_panic(); + // k_panic() should never return, but ensure compiler knows this + while (1) { + /* Never reached */ + } } et_timestamp_t et_pal_current_ticks(void) { - return k_uptime_ticks(); + return k_uptime_ticks(); } et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) { - return { NSEC_PER_SEC, sys_clock_hw_cycles_per_sec() }; + return {NSEC_PER_SEC, sys_clock_hw_cycles_per_sec()}; } void et_pal_emit_log_message( @@ -41,7 +41,7 @@ void et_pal_emit_log_message( ET_UNUSED size_t line, const char* message, ET_UNUSED size_t length) { - printk("%s\n", message); + printk("%s\n", message); } void* et_pal_allocate(size_t size) { @@ -50,4 +50,4 @@ void* et_pal_allocate(size_t size) { void et_pal_free(void* ptr) { k_free(ptr); -} +}