From d760edc055cd7d2304cac485246d5d680f6bbbd5 Mon Sep 17 00:00:00 2001 From: p3xsouger <151133481+pxcs@users.noreply.github.com> Date: Fri, 24 May 2024 23:58:18 +0700 Subject: [PATCH] Add files via upload --- unrar/furi/SConscript | 17 +++++++++++ unrar/furi/flipper.c | 70 +++++++++++++++++++++++++++++++++++++++++++ unrar/furi/flipper.h | 3 ++ unrar/furi/furi.c | 28 +++++++++++++++++ unrar/furi/furi.h | 37 +++++++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 unrar/furi/SConscript create mode 100644 unrar/furi/flipper.c create mode 100644 unrar/furi/flipper.h create mode 100644 unrar/furi/furi.c create mode 100644 unrar/furi/furi.h diff --git a/unrar/furi/SConscript b/unrar/furi/SConscript new file mode 100644 index 0000000..8f8caeb --- /dev/null +++ b/unrar/furi/SConscript @@ -0,0 +1,17 @@ +Import("env") + +env.Append( + LINT_SOURCES=[ + Dir("."), + ] +) + + +libenv = env.Clone(FW_LIB_NAME="furi") +libenv.ApplyLibFlags() + +sources = libenv.GlobRecursive("*.c") + +lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources) +libenv.Install("${LIB_DIST_DIR}", lib) +Return("lib") diff --git a/unrar/furi/flipper.c b/unrar/furi/flipper.c new file mode 100644 index 0000000..c7ba3b4 --- /dev/null +++ b/unrar/furi/flipper.c @@ -0,0 +1,70 @@ +#include "flipper.h" +#include +#include +#include +#include +#include + +#include + +#define TAG "Flipper" + +static void flipper_print_version(const char* target, const Version* version) { + if(version) { + FURI_LOG_I( + TAG, + "\r\n\t%s version:\t%s\r\n" + "\tBuild date:\t\t%s\r\n" + "\tGit Commit:\t\t%s (%s)%s\r\n" + "\tGit Branch:\t\t%s", + target, + version_get_version(version), + version_get_builddate(version), + version_get_githash(version), + version_get_gitbranchnum(version), + version_get_dirty_flag(version) ? " (dirty)" : "", + version_get_gitbranch(version)); + } else { + FURI_LOG_I(TAG, "No build info for %s", target); + } +} + +void flipper_init(void) { + flipper_print_version("Firmware", furi_hal_version_get_firmware_version()); + + FURI_LOG_I(TAG, "Boot mode %d, starting services", furi_hal_rtc_get_boot_mode()); + + for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) { + FURI_LOG_D(TAG, "Starting service %s", FLIPPER_SERVICES[i].name); + + FuriThread* thread = furi_thread_alloc_ex( + FLIPPER_SERVICES[i].name, + FLIPPER_SERVICES[i].stack_size, + FLIPPER_SERVICES[i].app, + NULL); + furi_thread_mark_as_service(thread); + furi_thread_set_appid(thread, FLIPPER_SERVICES[i].appid); + + furi_thread_start(thread); + } + + FURI_LOG_I(TAG, "Startup complete"); +} + +void vApplicationGetIdleTaskMemory( + StaticTask_t** tcb_ptr, + StackType_t** stack_ptr, + uint32_t* stack_size) { + *tcb_ptr = memmgr_alloc_from_pool(sizeof(StaticTask_t)); + *stack_ptr = memmgr_alloc_from_pool(sizeof(StackType_t) * configIDLE_TASK_STACK_DEPTH); + *stack_size = configIDLE_TASK_STACK_DEPTH; +} + +void vApplicationGetTimerTaskMemory( + StaticTask_t** tcb_ptr, + StackType_t** stack_ptr, + uint32_t* stack_size) { + *tcb_ptr = memmgr_alloc_from_pool(sizeof(StaticTask_t)); + *stack_ptr = memmgr_alloc_from_pool(sizeof(StackType_t) * configTIMER_TASK_STACK_DEPTH); + *stack_size = configTIMER_TASK_STACK_DEPTH; +} \ No newline at end of file diff --git a/unrar/furi/flipper.h b/unrar/furi/flipper.h new file mode 100644 index 0000000..674cccf --- /dev/null +++ b/unrar/furi/flipper.h @@ -0,0 +1,3 @@ +#pragma once + +void flipper_init(void); diff --git a/unrar/furi/furi.c b/unrar/furi/furi.c new file mode 100644 index 0000000..628c47e --- /dev/null +++ b/unrar/furi/furi.c @@ -0,0 +1,28 @@ +#include "furi.h" +#include + +#include +#include + +void furi_init(void) { + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED); + + furi_log_init(); + furi_record_init(); +} + +void furi_run(void) { + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED); + +#if(__ARM_ARCH_7A__ == 0U) + /* Service Call interrupt might be configured before kernel start */ + /* and when its priority is lower or equal to BASEPRI, svc instruction */ + /* causes a Hard Fault. */ + NVIC_SetPriority(SVCall_IRQn, 0U); +#endif + + /* Start the kernel scheduler */ + vTaskStartScheduler(); +} diff --git a/unrar/furi/furi.h b/unrar/furi/furi.h new file mode 100644 index 0000000..d8aec91 --- /dev/null +++ b/unrar/furi/furi.h @@ -0,0 +1,37 @@ +#pragma once + +#include + +#include "core/check.h" +#include "core/common_defines.h" +#include "core/event_flag.h" +#include "core/kernel.h" +#include "core/log.h" +#include "core/memmgr.h" +#include "core/memmgr_heap.h" +#include "core/message_queue.h" +#include "core/mutex.h" +#include "core/pubsub.h" +#include "core/record.h" +#include "core/semaphore.h" +#include "core/thread.h" +#include "core/timer.h" +#include "core/string.h" +#include "core/stream_buffer.h" + +#include + +// Workaround for math.h leaking through HAL in older versions +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void furi_init(void); + +void furi_run(void); + +#ifdef __cplusplus +} +#endif