Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 1 addition & 67 deletions examples/arm/executor_runner/arm_executor_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <executorch/runtime/platform/log.h>
#include <executorch/runtime/platform/platform.h>
#include <executorch/runtime/platform/runtime.h>
#include <executorch/runtime/platform/defualt/arm_baremetal.hpp>
#include <stdio.h>
#include <unistd.h>
#include <memory>
Expand Down Expand Up @@ -161,73 +162,6 @@ unsigned char* ethosu_fast_scratch = dedicated_sram;
}
#endif

void et_pal_init(void) {
// Enable ARM PMU Clock
ARM_PMU_Enable();
DCB->DEMCR |= DCB_DEMCR_TRCENA_Msk; // Trace enable
ARM_PMU_CYCCNT_Reset();
ARM_PMU_CNTR_Enable(PMU_CNTENSET_CCNTR_ENABLE_Msk);
}

/**
* Implementation of the et_pal_<funcs>()
*
* This functions are hardware adaption type of functions for things like
* time/logging/memory allocation that could call your RTOS or need to to
* be implemnted in some way.
*/

ET_NORETURN void et_pal_abort(void) {
#if !defined(SEMIHOSTING)
__builtin_trap();
#else
_exit(-1);
#endif
}

et_timestamp_t et_pal_current_ticks(void) {
return ARM_PMU_Get_CCNTR();
}

et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) {
// Since we don't know the CPU freq for your target and justs cycles in the
// FVP for et_pal_current_ticks() we return a conversion ratio of 1
return {1, 1};
}

/**
* Emit a log message via platform output (serial port, console, etc).
*/
void et_pal_emit_log_message(
ET_UNUSED et_timestamp_t timestamp,
et_pal_log_level_t level,
const char* filename,
ET_UNUSED const char* function,
size_t line,
const char* message,
ET_UNUSED size_t length) {
fprintf(
stderr,
"%c [executorch:%s:%zu %s()] %s\n",
level,
filename,
line,
function,
message);
}

/**
* Dynamic memory allocators intended to be used by temp_allocator
* to implement malloc()/free() type of allocations.
* Currenyly not used.
*/

void* et_pal_allocate(ET_UNUSED size_t size) {
return nullptr;
}

void et_pal_free(ET_UNUSED void* ptr) {}

namespace {

/// Lightweight heapless container that constructs and stores a T in-place.
Expand Down
71 changes: 71 additions & 0 deletions runtime/platform/default/arm_baremetal.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef __ARM_BARE_METAL_HPP__
#define __ARM_BARE_METAL_HPP__

void et_pal_init(void) {
// Enable ARM PMU Clock
ARM_PMU_Enable();
DCB->DEMCR |= DCB_DEMCR_TRCENA_Msk; // Trace enable
ARM_PMU_CYCCNT_Reset();
ARM_PMU_CNTR_Enable(PMU_CNTENSET_CCNTR_ENABLE_Msk);
}

/**
* Implementation of the et_pal_<funcs>()
*
* This functions are hardware adaption type of functions for things like
* time/logging/memory allocation that could call your RTOS or need to to
* be implemnted in some way.
*/

ET_NORETURN void et_pal_abort(void) {
#if !defined(SEMIHOSTING)
__builtin_trap();
#else
_exit(-1);
#endif
}

et_timestamp_t et_pal_current_ticks(void) {
return ARM_PMU_Get_CCNTR();
}

et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) {
// Since we don't know the CPU freq for your target and justs cycles in the
// FVP for et_pal_current_ticks() we return a conversion ratio of 1
return {1, 1};
}

/**
* Emit a log message via platform output (serial port, console, etc).
*/
void et_pal_emit_log_message(
ET_UNUSED et_timestamp_t timestamp,
et_pal_log_level_t level,
const char* filename,
ET_UNUSED const char* function,
size_t line,
const char* message,
ET_UNUSED size_t length) {
fprintf(
stderr,
"%c [executorch:%s:%zu %s()] %s\n",
level,
filename,
line,
function,
message);
}

/**
* Dynamic memory allocators intended to be used by temp_allocator
* to implement malloc()/free() type of allocations.
* Currenyly not used.
*/

void* et_pal_allocate(ET_UNUSED size_t size) {
return nullptr;
}

void et_pal_free(ET_UNUSED void* ptr) {}

#endif // __ARM_BARE_METAL_HPP__
Loading