Skip to content

Commit 00973d0

Browse files
committed
New pal for zephyr
1 parent df1319c commit 00973d0

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

runtime/platform/zephyr.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* @file
11+
* PAL implementations for Arm Zephyr RTOS.
12+
*/
13+
14+
#include <executorch/runtime/platform/platform.h>
15+
#include <zephyr/kernel.h>
16+
#include <zephyr/sys/printk.h>
17+
18+
void et_pal_init(void) {}
19+
20+
ET_NORETURN void et_pal_abort(void) {
21+
k_panic();
22+
// k_panic() should never return, but ensure compiler knows this
23+
while (1) {
24+
/* Never reached */
25+
}
26+
}
27+
28+
et_timestamp_t et_pal_current_ticks(void) {
29+
return k_uptime_ticks();
30+
}
31+
32+
et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) {
33+
return { NSEC_PER_SEC, sys_clock_hw_cycles_per_sec() };
34+
}
35+
36+
void et_pal_emit_log_message(
37+
ET_UNUSED et_timestamp_t timestamp,
38+
ET_UNUSED et_pal_log_level_t level,
39+
ET_UNUSED const char* filename,
40+
ET_UNUSED const char* function,
41+
ET_UNUSED size_t line,
42+
const char* message,
43+
ET_UNUSED size_t length) {
44+
printk("%s\n", message);
45+
}
46+
47+
void* et_pal_allocate(size_t size) {
48+
return k_malloc(size);
49+
}
50+
51+
void et_pal_free(void* ptr) {
52+
k_free(ptr);
53+
}

0 commit comments

Comments
 (0)