diff --git a/.github/actions/build-simulator/action.yml b/.github/actions/build-simulator/action.yml index 8507fcac..80eeb5ae 100644 --- a/.github/actions/build-simulator/action.yml +++ b/.github/actions/build-simulator/action.yml @@ -45,7 +45,7 @@ runs: run: cmake -S ./ -B buildsim - name: "Build Tests" shell: bash - run: cmake --build buildsim --target FirmwareSim + run: cmake --build buildsim --target Tactility - name: 'Release' shell: bash run: Buildscripts/release-simulator.sh buildsim release/Simulator-${{ inputs.os_name }}-${{ inputs.platform_name }} diff --git a/Buildscripts/TactilitySDK/CMakeLists.txt b/Buildscripts/TactilitySDK/CMakeLists.txt index 6fd65e2a..9a8f9a51 100644 --- a/Buildscripts/TactilitySDK/CMakeLists.txt +++ b/Buildscripts/TactilitySDK/CMakeLists.txt @@ -1,6 +1,5 @@ idf_component_register( INCLUDE_DIRS - "Libraries/TactilityC/include" "Libraries/TactilityKernel/include" "Libraries/TactilityFreeRtos/Include" "Libraries/lvgl/include" @@ -11,13 +10,11 @@ idf_component_register( ) # Regular and core features -add_prebuilt_library(TactilityC Libraries/TactilityC/binary/libTactilityC.a) add_prebuilt_library(TactilityKernel Libraries/TactilityKernel/binary/libTactilityKernel.a) add_prebuilt_library(lvgl Libraries/lvgl/binary/liblvgl.a) add_prebuilt_library(minmea Libraries/minmea/binary/libminmea.a) add_prebuilt_library(minitar Libraries/minitar/binary/libminitar.a) -target_link_libraries(${COMPONENT_LIB} INTERFACE TactilityC) target_link_libraries(${COMPONENT_LIB} INTERFACE TactilityKernel) target_link_libraries(${COMPONENT_LIB} INTERFACE lvgl) target_link_libraries(${COMPONENT_LIB} INTERFACE minmea) diff --git a/Buildscripts/build-all.py b/Buildscripts/build-all.py index f8395e39..8bcfa6ac 100644 --- a/Buildscripts/build-all.py +++ b/Buildscripts/build-all.py @@ -5,7 +5,6 @@ import time def build(device: str) -> bool: print(f"Building {device}...") - shutil.rmtree(os.path.join('Firmware', 'Generated'), ignore_errors=True) result = subprocess.run(['python', 'device.py', device], capture_output=True, text=True) if result.returncode != 0: print(f"Failed to select device {device}") diff --git a/Buildscripts/release-sdk.py b/Buildscripts/release-sdk.py index 144c8a50..9ef18e0e 100644 --- a/Buildscripts/release-sdk.py +++ b/Buildscripts/release-sdk.py @@ -131,11 +131,6 @@ def main(): # Mapping logic mappings = [ {'src': 'version.txt', 'dst': ''}, - # TactilityC - {'src': 'build/esp-idf/TactilityC/libTactilityC.a', 'dst': 'Libraries/TactilityC/binary/'}, - {'src': 'TactilityC/Include/*', 'dst': 'Libraries/TactilityC/include/'}, - {'src': 'TactilityC/CMakeLists.txt', 'dst': 'Libraries/TactilityC/'}, - {'src': 'TactilityC/LICENSE*.*', 'dst': 'Libraries/TactilityC/'}, # TactilityFreeRtos {'src': 'TactilityFreeRtos/Include/**', 'dst': 'Libraries/TactilityFreeRtos/Include/'}, {'src': 'TactilityFreeRtos/CMakeLists.txt', 'dst': 'Libraries/TactilityFreeRtos/'}, diff --git a/Buildscripts/release-simulator.sh b/Buildscripts/release-simulator.sh index 16ab106d..e1545c41 100755 --- a/Buildscripts/release-simulator.sh +++ b/Buildscripts/release-simulator.sh @@ -9,9 +9,9 @@ build_path=$1 target_path=$2 -mkdir -p $target_path +mkdir -p "$target_path" -cp version.txt $target_path -cp $build_path/Firmware/FirmwareSim $target_path/ -cp -r Data/data $target_path/ -cp -r Data/system $target_path/ +cp version.txt "$target_path" +cp "$build_path/Tactility/Tactility" "$target_path/" +cp -r Data/data "$target_path/" +cp -r Data/system "$target_path/" diff --git a/CMakeLists.txt b/CMakeLists.txt index e81d1b2f..84818cca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,17 +33,21 @@ if (DEFINED ENV{ESP_IDF_VERSION}) message("Using ESP-IDF ${Cyan}v$ENV{ESP_IDF_VERSION}${ColorReset}") include($ENV{IDF_PATH}/tools/cmake/project.cmake) - set(COMPONENTS Firmware) + set(COMPONENTS Tactility) set(EXTRA_COMPONENT_DIRS - "Firmware" + # Tactility must be discovered first: its CMakeLists.txt calls init_tactility_globals(), + # which other components' CMakeLists.txt (e.g. lvgl-module) rely on having already run to + # read back TACTILITY_DEVICE_ID/TACTILITY_DEVICE_PROJECT via get_property(). ESP-IDF's + # requirements-discovery pass processes EXTRA_COMPONENT_DIRS in an isolated sub-process, in + # the order listed here, so this must stay first now that Firmware no longer exists as a + # separate component. + "Tactility" "Devices/${TACTILITY_DEVICE_PROJECT}" "Drivers" "Modules" "Platforms/platform-esp32" "TactilityKernel" "TactilityKernelCpp" - "Tactility" - "TactilityC" "TactilityFreeRtos" "Libraries/elf_loader" "Libraries/esp_epaper" @@ -71,9 +75,7 @@ if (DEFINED ENV{ESP_IDF_VERSION}) else () message("Building for sim target") - # Devices/simulator/Source/Simulator.cpp always defines its own hardwareConfiguration; without - # this, Firmware/Source/Main.cpp's #else branch also defines an empty one (its ESP32-only - # fallback for devices migrated off the deprecated HAL), causing a duplicate-definition link error. + # eps-idf generates these from Kconfig, but posix build isn't set up with Kconfig. add_compile_definitions(CONFIG_TT_DEVICE_ID="simulator") add_compile_definitions(CONFIG_TT_DEVICE_NAME="Simulator") add_compile_definitions(CONFIG_TT_DEVICE_VENDOR="") @@ -99,9 +101,15 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION}) add_subdirectory(Libraries/minitar) add_subdirectory(Libraries/minmea) add_subdirectory(Modules/lvgl-module) + add_subdirectory(Modules/c-symbols-module) + add_subdirectory(Modules/cpp-symbols-module) add_subdirectory(Modules/crypt-module) + add_subdirectory(Modules/freertos-module) add_subdirectory(Modules/gps-module) add_subdirectory(Modules/http-module) + add_subdirectory(Modules/mbedtls-module) + add_subdirectory(Modules/posix-symbols-module) + add_subdirectory(Modules/pthread-module) add_subdirectory(Modules/service-module) add_subdirectory(Modules/app-module) add_subdirectory(Modules/lvgl-window-manager-module) @@ -130,9 +138,6 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION}) add_subdirectory(Libraries/lvgl) # Added as idf component for ESP and as library for other targets target_link_libraries(lvgl PRIVATE SDL2-static) - # Sim app - add_subdirectory(Firmware) - # Tests add_subdirectory(Tests) diff --git a/Devices/simulator/CMakeLists.txt b/Devices/simulator/CMakeLists.txt index 0da5b10e..f51dbb59 100644 --- a/Devices/simulator/CMakeLists.txt +++ b/Devices/simulator/CMakeLists.txt @@ -13,7 +13,8 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION}) ) target_link_libraries(simulator - PRIVATE Tactility + PRIVATE TactilityKernel + PRIVATE TactilityFreeRtos PRIVATE lvgl PRIVATE SDL2-static ) diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 529a79db..9fd8bb37 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -7,6 +7,7 @@ ## Higher Priority +- Get rid of TactilityC in favour of TactilityKernel and kernel modules - Add tests for app stdin/stdout - CrashDiagnostics shouldn't show a QR when there's no callstack - Apps currently have a `Context` object with an `appInstanceId` in it, purely for being able to close the app. @@ -16,9 +17,7 @@ - Move USB host task stacks to SPIRAM when available: esp32_usbhost*.cpp - Get rid of WiFi service (Wifi.cpp/h) in Tactility.cpp - Make it more clear to end-users that an SD card is required to run Tactility -- Make it possible to override stack size for an app via config file (loaded at boot), and make it possible to set preferred memory location (e.g. internal/external) - Add bold fonts for e-ink readability improvement -- Httpd.cpp: warn if running on same CPU core (or task) as UI/LVGL/window manager. - Improve Setup: Show "Step done" screen - Improve Setup: Add keyboard/keypad navigation explanation - display.h API: get_backlight does not change ref counting, but it should @@ -28,10 +27,8 @@ - LilyGO T-Dongle S3: 1 button control, stop auto-launching web server - Core2: support power off via software - Create `#define` for empty module (for modules that fully rely on device.properties and don't define drivers or have start/stop logic) -- Get rid of TactilityC in favour of TactilityKernel and kernel modules - Improve SPI kernel driver (implement read, write, transactions) - Add font design tokens such as "regular", "title" and "smaller". Perhaps via the LVGL kernel module. -- Fix glitches when installing app via App Hub with 4.3" Waveshare - TCA9534 keyboards should use interrupts - External app loading: Check the version of Tactility and check ESP target hardware to check for compatibility Check during installation process, but also when starting (SD card might have old app install from before Tactility OS update) @@ -45,6 +42,7 @@ ## Medium Priority +- lvgl-module's spinner relies on hard-coded spinner asset from Tactility main project. - esp_lvgl_port settings has a large stack size (~9kB) to fix stackoverflow when LVGL events (e.g. button click) do actions like file operations do actions like file operations. Can we reduce the callstack? - `struct Driver` has an `.owner`, but it's not always set. Either validate on Module construct that it matches, or otherwise set it during module start. The problem: NULL parent currently means that driver is not removable. This clashes with setting it dynamically. Consider some kind of flag to determine removability. - Consider moving certain drivers into separate modules: audio, bt, wifi, etc @@ -52,9 +50,9 @@ - Consider implementing LVGL gridnav in apps https://lvgl.io/docs/open/9.3/details/auxiliary-modules/gridnav.html - Make USB host driver disabled by default, so it doesn't consume memory - TactilityTool: Make API compatibility table (and check for compatibility in the tool itself) -- Improve EspLcdDisplay to contain all the standard configuration options, and implement a default init function. Add a configuration class. -- Unify the way displays are dimmed. Some implementations turn off the display when it's fully dimmed. Make this a separate functionality. - Bug: Crash handling app cannot be exited with an EncoderDevice. (current work-around is to manually reset the device) +- Move HttpServer implementation to http-module +- Use GPS time to set/update the current time ## Lower Priority @@ -62,20 +60,14 @@ - lvgl-module has a keyboard.cpp that creates a `keyboard_group`. This group is set as the default group, so it can also work with trackball(= LVGL "encoder"). Make a separate group that is the default group. The keyboard can then use it (or use its own). The basic idea is to invert the ownership: now the keyboard group is made the default group, but it's probably more logical to have the default group used by the keyboard. -- lvgl-module's spinner relies on hard-coded spinner asset from Tactility main project. - Localize all apps - Support hot-plugging SD card (note: this is not possible if they require the CS pin hack) - Explore LVGL9's FreeRTOS functionality -- CrashHandler: use "corrupted" flag -- CrashHandler: process other types of crashes (WDT?) -- Use GPS time to set/update the current time - Consider using non_null (either via MS GSL, or custom) - Fix system time to not be 1980 (use build year as a minimum). Consider keeping track of the last known time. - Use std::span or string_view in StringUtils https://youtu.be/FRkJCvHWdwQ?t=2754 - Mutex: Implement give/take from ISR support (works only for non-recursive ones) - Show a warning screen if firmware encryption or secure boot are off when saving WiFi credentials. -- Remove flex_flow from app_container in Gui.cpp -- Bug: CYD 2432S032C screen rotation fails due to touch driver issue - Calculator app should show regular text input field on non-touch devices that have a keyboard (Cardputer, T-Lora Pager) - Allow for WSAD keys to navigate LVGL (this is extra nice for cardputer, but just handy in general) - Create a "How to" app for a device. It could explain things like keyboard navigation on first start. diff --git a/Firmware/CMakeLists.txt b/Firmware/CMakeLists.txt deleted file mode 100644 index 3d9f21bb..00000000 --- a/Firmware/CMakeLists.txt +++ /dev/null @@ -1,147 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -file(GLOB_RECURSE SOURCE_FILES "Source/*.c*") - -get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) - -# Get the project and device id -if (DEFINED ENV{ESP_IDF_VERSION}) - include("../Buildscripts/device.cmake") - init_tactility_globals("../sdkconfig") - get_property(TACTILITY_DEVICE_PROJECT GLOBAL PROPERTY TACTILITY_DEVICE_PROJECT) - get_property(TACTILITY_DEVICE_ID GLOBAL PROPERTY TACTILITY_DEVICE_ID) -else () - set(TACTILITY_DEVICE_ID simulator) - set(COMPONENT_LIB FirmwareSim) - set(TACTILITY_DEVICE_PROJECT Simulator) -endif () - -set(DEVICETREE_LOCATION "${PROJECT_ROOT}/Devices/${TACTILITY_DEVICE_ID}") - -# Check if device has Bluetooth enabled -# Fixes the sdkconfig bluetooth enable options from getting nuked on non-P4+C6 builds when idf build runs -if (DEFINED ENV{ESP_IDF_VERSION}) - file(READ "${DEVICETREE_LOCATION}/device.properties" device_properties_content) - if (device_properties_content MATCHES "hardware\\.bluetooth=true") - list(APPEND REQUIRES_LIST bt) - endif() -endif() - -# -# DTS compiler python dependencies -# - -execute_process( - COMMAND python -m pip install lark==1.3.1 pyyaml==6.0.3 - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" -) - -# -# Devicetree dependency collection -# - -# REQUIRES_LIST below is computed once, at configure time. Without this, editing -# devicetree.yaml (e.g. adding a driver dependency) doesn't trigger a cmake reconfigure, -# so the new component's include dirs never reach the compiler until a fullclean. -set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS - "${DEVICETREE_LOCATION}/devicetree.yaml" -) - -execute_process( - COMMAND python "${PROJECT_ROOT}/Buildscripts/DevicetreeCompiler/dependencies.py" "${DEVICETREE_LOCATION}" - WORKING_DIRECTORY "${PROJECT_ROOT}" - OUTPUT_VARIABLE DEVICE_DEPENDENCIES - OUTPUT_STRIP_TRAILING_WHITESPACE -) -# Tokenize to array of lines -separate_arguments(DEVICE_DEPENDENCIES UNIX_COMMAND "${DEVICE_DEPENDENCIES}") - -# -# "Generated/" directory creation -# - -set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/Generated") -# Ensure the directory is built in the correct CMake build phase -# If the check is not done, then another directory is created in the root of the build folder. -if (DEFINED CMAKE_CURRENT_BINARY_DIR) - file(MAKE_DIRECTORY "${GENERATED_DIR}") -endif () - -# -# Component -# - -list(APPEND REQUIRES_LIST - Tactility - TactilityKernel -) - -# Add devicetree dependencies -foreach(dts_dependency IN LISTS DEVICE_DEPENDENCIES) - message("Adding DTS dependency ${dts_dependency}") - list(APPEND REQUIRES_LIST ${dts_dependency}) -endforeach() - -if (DEFINED ENV{ESP_IDF_VERSION}) - list(APPEND REQUIRES_LIST - TactilityC - ) - - idf_component_register( - SRCS ${SOURCE_FILES} "${GENERATED_DIR}/devicetree.c" - REQUIRES ${REQUIRES_LIST} - ) -else () - list(APPEND REQUIRES_LIST - Tactility - TactilityFreeRtos - lvgl-module - lvgl-window-manager-module - app-module - crypt-module - gps-module - http-module - gps-generic-module - gps-meshtastic-module - service-module - SDL2::SDL2-static - SDL2-static - ) - add_executable(FirmwareSim ${SOURCE_FILES} "${GENERATED_DIR}/devicetree.c") - target_link_libraries(FirmwareSim PRIVATE ${REQUIRES_LIST}) -endif () - -# -# Devicetree code generation -# - -# A plain add_custom_command(OUTPUT ...) only reruns when its explicit DEPENDS (devicetree.yaml) -# changes, since ninja computes dirtiness up front, before any command in this invocation runs. -# The devicetree's real inputs span many files (dts, bindings yaml, driver headers) that a single -# DEPENDS can't enumerate, so this used to be forced to always-rerun via a separate "AlwaysRun" -# custom target that deleted devicetree.c first (DEPENDS on a *target* only creates an order-only -# ninja edge). That delete was invisible to ninja's DAG: on an up-to-date build, ninja would still -# run AlwaysRun (custom targets with no real output are always considered dirty) and delete the -# file, but *not* rerun the generation edge (its own explicit input hadn't changed) or recompile -# devicetree.c.obj (also considered clean) - silently leaving devicetree.c missing on disk until -# some later, unrelated build finally noticed and regenerated it. In between, any build that did -# need to (re)compile devicetree.c.obj hit "No such file or directory". -# -# add_custom_target(... COMMAND ...) has no such problem: unlike add_custom_command(OUTPUT ...), -# a custom target with a COMMAND always reruns on every ninja invocation, so generation and the -# stale artifact removal happen atomically in one edge. BYPRODUCTS tells ninja which files this -# target produces, so it still wires a proper (non-order-only) dependency for the sources that -# consume them. -add_custom_target(Generated ALL - COMMAND python "${CMAKE_SOURCE_DIR}/Buildscripts/DevicetreeCompiler/compile.py" - "${DEVICETREE_LOCATION}" "${GENERATED_DIR}" - BYPRODUCTS "${GENERATED_DIR}/devicetree.c" "${GENERATED_DIR}/devicetree.h" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" - COMMENT "Generating devicetree source files..." -) -set_source_files_properties("${GENERATED_DIR}/devicetree.c" PROPERTIES GENERATED TRUE) -set_source_files_properties("${GENERATED_DIR}/devicetree.h" PROPERTIES GENERATED TRUE) -# Update target for generated code -target_sources(${COMPONENT_LIB} PRIVATE "${GENERATED_DIR}/devicetree.c") -target_include_directories(${COMPONENT_LIB} PRIVATE "${GENERATED_DIR}") -add_dependencies(${COMPONENT_LIB} Generated) diff --git a/Modules/app-esp32-module/source/module.cpp b/Modules/app-esp32-module/source/module.cpp index cfd0e016..85c7a014 100644 --- a/Modules/app-esp32-module/source/module.cpp +++ b/Modules/app-esp32-module/source/module.cpp @@ -1,6 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include + #include #include @@ -10,11 +12,23 @@ extern "C" { extern ServiceManifest loader_service_manifest; +// Overrides elf_loader's default KConfig-based symbol resolver with one that looks up symbols +// across every started kernel module's own symbol table instead. +uintptr_t app_esp32_symbol_resolver(const char* symbolName) { + uintptr_t symbol_address; + if (module_resolve_symbol_global(symbolName, &symbol_address)) { + return symbol_address; + } + return 0; +} + static error_t start() { + elf_set_symbol_resolver(app_esp32_symbol_resolver); return service_manager_add(&loader_service_manifest, /*auto_start=*/true); } static error_t stop() { + elf_set_symbol_resolver(nullptr); return service_manager_remove(loader_service_manifest.id); } @@ -24,7 +38,7 @@ Module app_esp32_module = { .stop = stop, .drivers = nullptr, .symbols = nullptr, - .internal = nullptr + .internal = nullptr, }; } diff --git a/Modules/app-module/source/app_install.cpp b/Modules/app-module/source/install.cpp similarity index 91% rename from Modules/app-module/source/app_install.cpp rename to Modules/app-module/source/install.cpp index 74482653..66a92b9a 100644 --- a/Modules/app-module/source/app_install.cpp +++ b/Modules/app-module/source/install.cpp @@ -37,6 +37,28 @@ std::string last_path_segment(const std::string& path) { return index == std::string::npos ? path : path.substr(index + 1); } +// Rejects absolute paths and ".." components, so a crafted tar entry can't extract outside destination_path (CWE-22). +bool is_tar_entry_path_safe(const std::string& path) { + if (path.empty() || path.front() == '/') { + return false; + } + + size_t start = 0; + while (start <= path.size()) { + size_t slash = path.find('/', start); + size_t length = (slash == std::string::npos ? path.size() : slash) - start; + if (path.compare(start, length, "..") == 0) { + return false; + } + if (slash == std::string::npos) { + break; + } + start = slash + 1; + } + + return true; +} + // mkdir -p. bool ensure_directory(const std::string& path) { if (path.empty() || app_fs_is_directory(path)) { @@ -80,8 +102,9 @@ bool get_app_install_directory(std::string& out_path) { bool untar_file(minitar* archive, const minitar_entry* entry, const std::string& destination_path) { auto absolute_path = destination_path + "/" + entry->metadata.path; - if (!ensure_directory_recursive(destination_path)) { - LOG_E(TAG, "Can't find or create directory %s", destination_path.c_str()); + auto parent_path = absolute_path.substr(0, absolute_path.find_last_of('/')); + if (!ensure_directory_recursive(parent_path)) { + LOG_E(TAG, "Can't find or create directory %s", parent_path.c_str()); return false; } @@ -111,6 +134,11 @@ bool untar(const std::string& tar_path, const std::string& destination_path) { minitar_entry entry {}; while (minitar_read_entry(&archive, &entry) == 0) { LOG_I(TAG, "Extracting %s", entry.metadata.path); + if (!is_tar_entry_path_safe(entry.metadata.path)) { + LOG_E(TAG, "Rejecting unsafe tar entry path: %s", entry.metadata.path); + success = false; + break; + } if (entry.metadata.type == MTAR_DIRECTORY) { if (std::strcmp(entry.metadata.name, ".") == 0 || std::strcmp(entry.metadata.name, "..") == 0 || std::strcmp(entry.metadata.name, "/") == 0) { continue; @@ -336,7 +364,12 @@ error_t app_install(const char* source_path) { return ERROR_NOT_FOUND; } - auto staging_path = app_parent_path + "/" + last_path_segment(source_path); + auto source_name = last_path_segment(source_path); + if (source_name.empty() || source_name == "." || source_name == "..") { + LOG_E(TAG, "Invalid source path %s", source_path); + return ERROR_INVALID_ARGUMENT; + } + auto staging_path = app_parent_path + "/" + source_name; acquire_staging_lock(staging_path); delete_recursively(staging_path); diff --git a/Modules/app-module/source/app_internal_loader.cpp b/Modules/app-module/source/internal_loader.cpp similarity index 100% rename from Modules/app-module/source/app_internal_loader.cpp rename to Modules/app-module/source/internal_loader.cpp diff --git a/Modules/app-module/source/app_metadata_parsing.cpp b/Modules/app-module/source/metadata_parsing.cpp similarity index 100% rename from Modules/app-module/source/app_metadata_parsing.cpp rename to Modules/app-module/source/metadata_parsing.cpp diff --git a/Modules/app-module/source/app_metadata_parsing_v1.cpp b/Modules/app-module/source/metadata_parsing_v1.cpp similarity index 96% rename from Modules/app-module/source/app_metadata_parsing_v1.cpp rename to Modules/app-module/source/metadata_parsing_v1.cpp index 96e2b36c..d6f74200 100644 --- a/Modules/app-module/source/app_metadata_parsing_v1.cpp +++ b/Modules/app-module/source/metadata_parsing_v1.cpp @@ -13,6 +13,7 @@ constexpr auto* TAG = "app_metadata_v1"; bool app_metadata_parse_v1(const std::map& properties, AppMetadata& out_metadata) { // [manifest] + LOG_W(TAG, "This manifest version is deprecated. Replace it with the newer version."); std::string format_version; if (!app_metadata_get_value(properties, "[manifest]version", format_version)) { diff --git a/Modules/app-module/source/app_metadata_parsing_v2.cpp b/Modules/app-module/source/metadata_parsing_v2.cpp similarity index 100% rename from Modules/app-module/source/app_metadata_parsing_v2.cpp rename to Modules/app-module/source/metadata_parsing_v2.cpp diff --git a/Modules/app-module/source/symbols.cpp b/Modules/app-module/source/module.cpp similarity index 94% rename from Modules/app-module/source/symbols.cpp rename to Modules/app-module/source/module.cpp index 8b32b26e..80ef97fa 100644 --- a/Modules/app-module/source/symbols.cpp +++ b/Modules/app-module/source/module.cpp @@ -17,7 +17,7 @@ extern "C" { extern ServiceManifest app_internal_loader_service_manifest; -const ModuleSymbol app_module_symbols[] = { +static const ModuleSymbol SYMBOLS[] = { // app/event DEFINE_MODULE_SYMBOL(app_event_subscribe), DEFINE_MODULE_SYMBOL(app_event_subscribe_with_app_id), @@ -54,7 +54,7 @@ const ModuleSymbol app_module_symbols[] = { // app/scheduler DEFINE_MODULE_SYMBOL(app_scheduler_current_app_id), // terminator - MODULE_SYMBOL_TERMINATOR + MODULE_SYMBOL_TERMINATOR, }; static error_t start() { @@ -70,8 +70,8 @@ Module app_module = { .start = start, .stop = stop, .drivers = nullptr, - .symbols = app_module_symbols, - .internal = nullptr + .symbols = SYMBOLS, + .internal = nullptr, }; } diff --git a/Modules/app-module/source/app_paths.cpp b/Modules/app-module/source/paths.cpp similarity index 100% rename from Modules/app-module/source/app_paths.cpp rename to Modules/app-module/source/paths.cpp diff --git a/Modules/app-module/tests/source/app_event_test.cpp b/Modules/app-module/tests/source/event_test.cpp similarity index 100% rename from Modules/app-module/tests/source/app_event_test.cpp rename to Modules/app-module/tests/source/event_test.cpp diff --git a/Modules/app-module/tests/source/app_manager_test.cpp b/Modules/app-module/tests/source/manager_test.cpp similarity index 100% rename from Modules/app-module/tests/source/app_manager_test.cpp rename to Modules/app-module/tests/source/manager_test.cpp diff --git a/Modules/c-symbols-module/CMakeLists.txt b/Modules/c-symbols-module/CMakeLists.txt new file mode 100644 index 00000000..a7787d4b --- /dev/null +++ b/Modules/c-symbols-module/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.20) + +include("${CMAKE_CURRENT_LIST_DIR}/../../Buildscripts/module.cmake") + +file(GLOB_RECURSE SOURCE_FILES "source/*.c*") + +tactility_add_module(c-symbols-module + SRCS ${SOURCE_FILES} + INCLUDE_DIRS include/ + REQUIRES TactilityKernel +) diff --git a/TactilityC/LICENSE-Apache-2.0.md b/Modules/c-symbols-module/LICENSE-Apache-2.0.md similarity index 100% rename from TactilityC/LICENSE-Apache-2.0.md rename to Modules/c-symbols-module/LICENSE-Apache-2.0.md diff --git a/Modules/c-symbols-module/include/c_symbols/module.h b/Modules/c-symbols-module/include/c_symbols/module.h new file mode 100644 index 00000000..d7fd0fdc --- /dev/null +++ b/Modules/c-symbols-module/include/c_symbols/module.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct Module c_symbols_module; + +#ifdef __cplusplus +} +#endif diff --git a/Modules/c-symbols-module/source/module.cpp b/Modules/c-symbols-module/source/module.cpp new file mode 100644 index 00000000..4b6ee1f4 --- /dev/null +++ b/Modules/c-symbols-module/source/module.cpp @@ -0,0 +1,178 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { + +static const ModuleSymbol SYMBOLS[] = { + // stdlib.h + DEFINE_MODULE_SYMBOL(malloc), + DEFINE_MODULE_SYMBOL(calloc), + DEFINE_MODULE_SYMBOL(realloc), + DEFINE_MODULE_SYMBOL(free), + DEFINE_MODULE_SYMBOL(rand), + DEFINE_MODULE_SYMBOL(srand), + DEFINE_MODULE_SYMBOL(atof), + DEFINE_MODULE_SYMBOL(atoi), + DEFINE_MODULE_SYMBOL(atol), + DEFINE_MODULE_SYMBOL(system), + DEFINE_MODULE_SYMBOL(getenv), + DEFINE_MODULE_SYMBOL(qsort), + // time.h + DEFINE_MODULE_SYMBOL(strftime), + DEFINE_MODULE_SYMBOL(time), + DEFINE_MODULE_SYMBOL(difftime), + DEFINE_MODULE_SYMBOL(localtime), + DEFINE_MODULE_SYMBOL(mktime), + // math.h + DEFINE_MODULE_SYMBOL(acoshf), + DEFINE_MODULE_SYMBOL(acosf), + DEFINE_MODULE_SYMBOL(asinhf), + DEFINE_MODULE_SYMBOL(asinf), + DEFINE_MODULE_SYMBOL(atanhf), + DEFINE_MODULE_SYMBOL(atanf), + DEFINE_MODULE_SYMBOL(atan2f), + DEFINE_MODULE_SYMBOL(coshf), + DEFINE_MODULE_SYMBOL(cosf), + DEFINE_MODULE_SYMBOL(sinhf), + DEFINE_MODULE_SYMBOL(sinf), + DEFINE_MODULE_SYMBOL(tanhf), + DEFINE_MODULE_SYMBOL(tanf), + DEFINE_MODULE_SYMBOL(expf), + DEFINE_MODULE_SYMBOL(ldexpf), + DEFINE_MODULE_SYMBOL(logf), + DEFINE_MODULE_SYMBOL(log10f), + DEFINE_MODULE_SYMBOL(powf), + DEFINE_MODULE_SYMBOL(sqrtf), + DEFINE_MODULE_SYMBOL(fmodf), + DEFINE_MODULE_SYMBOL(frexpf), + DEFINE_MODULE_SYMBOL(modff), + DEFINE_MODULE_SYMBOL(ceilf), + DEFINE_MODULE_SYMBOL(fabsf), + DEFINE_MODULE_SYMBOL(floorf), + DEFINE_MODULE_SYMBOL(fmaxf), + DEFINE_MODULE_SYMBOL(fminf), + DEFINE_MODULE_SYMBOL(roundf), + // Explicit signatures: libstdc++/libc++'s float/double/long double overloads make a + // bare `&acos` etc. ambiguous. esp-idf newlib's plain, unoverloaded functions match these signatures + // exactly, so the cast is a no-op there - one list works for all platforms: + DEFINE_MODULE_SYMBOL_SIGNATURE(acos, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(asin, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(atan, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(atan2, double (*)(double, double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(cos, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(sin, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(sinh, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(tan, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(exp, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(ldexp, double (*)(double, int)), + DEFINE_MODULE_SYMBOL_SIGNATURE(log, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(log10, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(pow, double (*)(double, double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(sqrt, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(fmod, double (*)(double, double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(frexp, double (*)(double, int*)), + DEFINE_MODULE_SYMBOL_SIGNATURE(modf, double (*)(double, double*)), + DEFINE_MODULE_SYMBOL_SIGNATURE(ceil, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(fabs, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(floor, double (*)(double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(fmax, double (*)(double, double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(fmin, double (*)(double, double)), + DEFINE_MODULE_SYMBOL_SIGNATURE(round, double (*)(double)), + // cassert / cstdio + DEFINE_MODULE_SYMBOL(abort), + DEFINE_MODULE_SYMBOL(fclose), + DEFINE_MODULE_SYMBOL(feof), + DEFINE_MODULE_SYMBOL(ferror), + DEFINE_MODULE_SYMBOL(fflush), + DEFINE_MODULE_SYMBOL(fgetc), + DEFINE_MODULE_SYMBOL(fgetpos), + DEFINE_MODULE_SYMBOL(fgets), + DEFINE_MODULE_SYMBOL(fopen), + DEFINE_MODULE_SYMBOL(freopen), + DEFINE_MODULE_SYMBOL(setvbuf), + DEFINE_MODULE_SYMBOL(fputc), + DEFINE_MODULE_SYMBOL(fputs), + DEFINE_MODULE_SYMBOL(fprintf), + DEFINE_MODULE_SYMBOL(fread), + DEFINE_MODULE_SYMBOL(fseek), + DEFINE_MODULE_SYMBOL(fsetpos), + DEFINE_MODULE_SYMBOL(fscanf), + DEFINE_MODULE_SYMBOL(ftell), + DEFINE_MODULE_SYMBOL(fwrite), + DEFINE_MODULE_SYMBOL(getc), + DEFINE_MODULE_SYMBOL(putc), + DEFINE_MODULE_SYMBOL(putchar), + DEFINE_MODULE_SYMBOL(puts), + DEFINE_MODULE_SYMBOL(printf), + DEFINE_MODULE_SYMBOL(sscanf), + DEFINE_MODULE_SYMBOL(snprintf), + DEFINE_MODULE_SYMBOL(sprintf), + DEFINE_MODULE_SYMBOL(vsprintf), + DEFINE_MODULE_SYMBOL(vsnprintf), + DEFINE_MODULE_SYMBOL(vfprintf), + DEFINE_MODULE_SYMBOL(rename), + DEFINE_MODULE_SYMBOL(rewind), + DEFINE_MODULE_SYMBOL(remove), + // cstring + DEFINE_MODULE_SYMBOL(strlen), + DEFINE_MODULE_SYMBOL(strcmp), + DEFINE_MODULE_SYMBOL(strncmp), + DEFINE_MODULE_SYMBOL(strncpy), + DEFINE_MODULE_SYMBOL(strcpy), + DEFINE_MODULE_SYMBOL(strcat), + // Explicit signatures due to libstdc++'s C++ overloads on some platforms + DEFINE_MODULE_SYMBOL_SIGNATURE(strchr, const char* (*)(const char*, int)), + DEFINE_MODULE_SYMBOL_SIGNATURE(strstr, const char* (*)(const char*, const char*)), + DEFINE_MODULE_SYMBOL_SIGNATURE(strrchr, const char* (*)(const char*, int)), + DEFINE_MODULE_SYMBOL_SIGNATURE(strpbrk, const char* (*)(const char*, const char*)), + DEFINE_MODULE_SYMBOL_SIGNATURE(memchr, const void* (*)(const void*, int, size_t)), + DEFINE_MODULE_SYMBOL(strerror), + DEFINE_MODULE_SYMBOL(strtod), + DEFINE_MODULE_SYMBOL(strtol), + DEFINE_MODULE_SYMBOL(strtoul), + DEFINE_MODULE_SYMBOL(strcspn), + DEFINE_MODULE_SYMBOL(strncat), + DEFINE_MODULE_SYMBOL(strspn), + DEFINE_MODULE_SYMBOL(strcoll), + DEFINE_MODULE_SYMBOL(memset), + DEFINE_MODULE_SYMBOL(memcpy), + DEFINE_MODULE_SYMBOL(memcmp), + DEFINE_MODULE_SYMBOL(memmove), + // ctype.h + DEFINE_MODULE_SYMBOL(isalnum), + DEFINE_MODULE_SYMBOL(isalpha), + DEFINE_MODULE_SYMBOL(iscntrl), + DEFINE_MODULE_SYMBOL(isdigit), + DEFINE_MODULE_SYMBOL(isgraph), + DEFINE_MODULE_SYMBOL(islower), + DEFINE_MODULE_SYMBOL(isprint), + DEFINE_MODULE_SYMBOL(ispunct), + DEFINE_MODULE_SYMBOL(isspace), + DEFINE_MODULE_SYMBOL(isupper), + DEFINE_MODULE_SYMBOL(isxdigit), + DEFINE_MODULE_SYMBOL(tolower), + DEFINE_MODULE_SYMBOL(toupper), + // locale.h + DEFINE_MODULE_SYMBOL(localeconv), + MODULE_SYMBOL_TERMINATOR +}; + +Module c_symbols_module = { + .name = "c-symbols", + .start = nullptr, + .stop = nullptr, + .drivers = nullptr, + .symbols = SYMBOLS, + .internal = nullptr, +}; + +} diff --git a/Modules/cpp-symbols-module/CMakeLists.txt b/Modules/cpp-symbols-module/CMakeLists.txt new file mode 100644 index 00000000..efaaa5f1 --- /dev/null +++ b/Modules/cpp-symbols-module/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.20) + +include("${CMAKE_CURRENT_LIST_DIR}/../../Buildscripts/module.cmake") + +file(GLOB_RECURSE SOURCE_FILES "source/*.c*") + +tactility_add_module(cpp-symbols-module + SRCS ${SOURCE_FILES} + INCLUDE_DIRS include/ + REQUIRES TactilityKernel +) diff --git a/Modules/cpp-symbols-module/LICENSE-Apache-2.0.md b/Modules/cpp-symbols-module/LICENSE-Apache-2.0.md new file mode 100644 index 00000000..f5f4b8b5 --- /dev/null +++ b/Modules/cpp-symbols-module/LICENSE-Apache-2.0.md @@ -0,0 +1,195 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/Modules/cpp-symbols-module/README.md b/Modules/cpp-symbols-module/README.md new file mode 100644 index 00000000..6e1c333f --- /dev/null +++ b/Modules/cpp-symbols-module/README.md @@ -0,0 +1,62 @@ +# cpp-symbols-module + +Exports the C++ runtime/ABI symbols that side-loaded ELF apps need but that don't come from any +single library header - compiler-generated helpers (`operator new`/`delete`, vtable guard +variables) and libstdc++ internals that are normally only reachable through template +instantiation, not a plain function call. Apps still `#include `/``/`` etc. +directly; this module only makes sure the actual out-of-line definitions resolve when their ELF +is loaded into the firmware. + +ESP32-only: several of these symbols are mangled for a 32-bit ABI (`j` = `unsigned int`, used +here to represent `size_t`). On a 64-bit host those would mangle differently (e.g. `_Znwm` +instead of `_Znwj`), so this module doesn't build for the POSIX simulator. + +## Supported symbols + +### Compiler/runtime ABI support + +- `operator new(unsigned int)` / `operator delete(void*, unsigned int)` (`_Znwj` / `_ZdlPvj`) +- `std::nothrow` +- `__cxa_pure_virtual` - called through a pure-virtual slot before a derived class's vtable is + fully constructed; see [Bare metal C++](https://arobenko.github.io/bare_metal_cpp/). +- `__cxa_guard_acquire` / `__cxa_guard_release` / `__cxa_guard_abort` / `__cxa_guard_dummy` - + thread-safe one-time initialization of function-local `static` variables. + +### libstdc++ exception helpers + +Out-of-line `std::__throw_*` functions libstdc++ headers call instead of throwing directly, to +keep the throw site small: + +- `std::__throw_bad_alloc` +- `std::__throw_bad_array_new_length` +- `std::__throw_bad_function_call` +- `std::__throw_length_error` +- `std::__throw_logic_error` +- `std::__throw_out_of_range_fmt` +- `std::__throw_system_error` + +### `std::map` / `std::set` (red-black tree internals) + +Non-template helpers shared by every `std::map`/`std::set` instantiation: + +- `std::_Rb_tree_increment` / `std::_Rb_tree_decrement` +- `std::_Rb_tree_insert_and_rebalance` + +### `std::string` + +- `basic_string::_M_replace_cold` - the rarely-taken slow path of `std::string::replace`, + split out of the header-inlined fast path. + +## Adding a new symbol + +1. Find the mangled name (`nm`/`c++filt`, or the linker's "undefined reference" error from an + app build). +2. Add an `extern "C"` declaration for it in `source/module.cpp` if the name isn't already a + valid identifier you can reference directly (mangled names usually are, e.g. `_ZSt19...`). +3. Add a `DEFINE_MODULE_SYMBOL(...)` entry (or a manual `{ "mangled_name", (void*)&expr }` pair + when the address isn't reachable through the mangled identifier itself, e.g. `std::nothrow` + or the `__throw_*` functions). + +## License + +This module is licensed under the [Apache v2.0](LICENSE-Apache-2.0.md) license. diff --git a/Modules/cpp-symbols-module/include/cpp_symbols/module.h b/Modules/cpp-symbols-module/include/cpp_symbols/module.h new file mode 100644 index 00000000..d47145f0 --- /dev/null +++ b/Modules/cpp-symbols-module/include/cpp_symbols/module.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct Module cpp_symbols_module; + +#ifdef __cplusplus +} +#endif diff --git a/Modules/cpp-symbols-module/source/module.cpp b/Modules/cpp-symbols-module/source/module.cpp new file mode 100644 index 00000000..916f56d2 --- /dev/null +++ b/Modules/cpp-symbols-module/source/module.cpp @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#include +#include +#include +#include + +#if defined(__GLIBCXX__) || defined(ESP_PLATFORM) +#define TT_CPP_SYMBOLS_AVAILABLE 1 +#include +#else +#define TT_CPP_SYMBOLS_AVAILABLE 0 +#endif + +#if TT_CPP_SYMBOLS_AVAILABLE +extern "C" { + // cplusplus: compiler/runtime ABI support +#ifdef ESP_PLATFORM + // Mangled for a 32-bit ABI ("j" = unsigned int, i.e. size_t on ESP32's ILP32). A 64-bit host's + // libstdc++ exports these under different (m-suffixed) mangled names, so they don't apply there. + extern void* _Znwj(uint32_t size); // operator new(unsigned int) + extern void _ZdlPvj(void* p, uint64_t size); // operator delete(void*, unsigned int) +#endif + extern void __cxa_pure_virtual(); + // cxx_guards.cpp + extern int __cxa_guard_acquire(void* pg); + extern void __cxa_guard_release(void* pg) throw(); + extern void __cxa_guard_abort(void* pg) throw(); +#ifdef ESP_PLATFORM + // Not part of the Itanium C++ ABI that desktop libstdc++ implements; ESP-IDF's toolchain only. + extern void __cxa_guard_dummy(void); +#endif + + // stl: std::map / std::set red-black tree non-template helpers. We use the mangled names + // directly (same pattern as the basic_string cold path below) to avoid ambiguity from the + // overloaded const/non-const variants in stl_tree.h. + void* _ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base(void*); + void* _ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base(void*); + void _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_(bool, void*, void*, void*); + +#ifdef ESP_PLATFORM + // string - same 32-bit-ABI mangling caveat as operator new/delete above. + void _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE15_M_replace_coldEPcjPKcjj(void*, char*, unsigned int, char const*, unsigned int, unsigned int); +#endif +} +#endif + +static const ModuleSymbol SYMBOLS[] = { +#if TT_CPP_SYMBOLS_AVAILABLE + // cplusplus +#ifdef ESP_PLATFORM + DEFINE_MODULE_SYMBOL(_Znwj), // operator new(unsigned int) + DEFINE_MODULE_SYMBOL(_ZdlPvj), // operator delete(void*, unsigned int) +#endif + { "_ZSt7nothrow", (void*)&std::nothrow }, + DEFINE_MODULE_SYMBOL(__cxa_pure_virtual), // class-related, see https://arobenko.github.io/bare_metal_cpp/ + DEFINE_MODULE_SYMBOL(__cxa_guard_acquire), + DEFINE_MODULE_SYMBOL(__cxa_guard_release), + DEFINE_MODULE_SYMBOL(__cxa_guard_abort), +#ifdef ESP_PLATFORM + DEFINE_MODULE_SYMBOL(__cxa_guard_dummy), +#endif + // stl - Note: You have to use the mangled names here + { "_ZSt17__throw_bad_allocv", (void*)&(std::__throw_bad_alloc) }, + { "_ZSt28__throw_bad_array_new_lengthv", (void*)&(std::__throw_bad_array_new_length) }, + { "_ZSt25__throw_bad_function_callv", (void*)&(std::__throw_bad_function_call) }, + { "_ZSt20__throw_length_errorPKc", (void*)&(std::__throw_length_error) }, + { "_ZSt19__throw_logic_errorPKc", (void*)&std::__throw_logic_error }, + { "_ZSt24__throw_out_of_range_fmtPKcz", (void*)&std::__throw_out_of_range_fmt }, + { "_ZSt20__throw_system_errori", (void*)&std::__throw_system_error }, + // stl - std::map / std::set (red-black tree internals) + DEFINE_MODULE_SYMBOL(_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base), + DEFINE_MODULE_SYMBOL(_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base), + DEFINE_MODULE_SYMBOL(_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_), +#ifdef ESP_PLATFORM + // string - Note: You have to use the mangled names here + DEFINE_MODULE_SYMBOL(_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE15_M_replace_coldEPcjPKcjj), +#endif +#endif // TT_CPP_SYMBOLS_AVAILABLE + MODULE_SYMBOL_TERMINATOR +}; + +extern "C" { + +Module cpp_symbols_module = { + .name = "cpp-symbols", + .start = nullptr, + .stop = nullptr, + .drivers = nullptr, + .symbols = SYMBOLS, + .internal = nullptr, +}; + +} diff --git a/Modules/crypt-module/source/module.cpp b/Modules/crypt-module/source/module.cpp index 501c6cbd..8fcd0232 100644 --- a/Modules/crypt-module/source/module.cpp +++ b/Modules/crypt-module/source/module.cpp @@ -5,7 +5,7 @@ extern "C" { -static const ModuleSymbol crypt_module_symbols[] = { +static const ModuleSymbol SYMBOLS[] = { DEFINE_MODULE_SYMBOL(crypt_get_iv), DEFINE_MODULE_SYMBOL(crypt_generate_iv), DEFINE_MODULE_SYMBOL(crypt_encrypt), @@ -17,7 +17,11 @@ static const ModuleSymbol crypt_module_symbols[] = { Module crypt_module = { .name = "crypt", - .symbols = crypt_module_symbols + .start = nullptr, + .stop = nullptr, + .drivers = nullptr, + .symbols = SYMBOLS, + .internal = nullptr, }; } diff --git a/Modules/freertos-module/CMakeLists.txt b/Modules/freertos-module/CMakeLists.txt new file mode 100644 index 00000000..4e142b48 --- /dev/null +++ b/Modules/freertos-module/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.20) + +include("${CMAKE_CURRENT_LIST_DIR}/../../Buildscripts/module.cmake") + +file(GLOB_RECURSE SOURCE_FILES "source/*.c*") + +list(APPEND REQUIRES_LIST + TactilityKernel +) + +if (NOT DEFINED ENV{ESP_IDF_VERSION}) + list(APPEND REQUIRES_LIST + freertos_kernel + ) +endif () + +tactility_add_module(freertos-module + SRCS ${SOURCE_FILES} + INCLUDE_DIRS include/ + REQUIRES ${REQUIRES_LIST} +) diff --git a/Modules/freertos-module/LICENSE-Apache-2.0.md b/Modules/freertos-module/LICENSE-Apache-2.0.md new file mode 100644 index 00000000..f5f4b8b5 --- /dev/null +++ b/Modules/freertos-module/LICENSE-Apache-2.0.md @@ -0,0 +1,195 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/Modules/freertos-module/include/freertos/module.h b/Modules/freertos-module/include/freertos/module.h new file mode 100644 index 00000000..1055e6f0 --- /dev/null +++ b/Modules/freertos-module/include/freertos/module.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct Module freertos_module; + +#ifdef __cplusplus +} +#endif diff --git a/Modules/freertos-module/source/module.cpp b/Modules/freertos-module/source/module.cpp new file mode 100644 index 00000000..f7c372d3 --- /dev/null +++ b/Modules/freertos-module/source/module.cpp @@ -0,0 +1,165 @@ +// SPDX-License-Identifier: Apache-2.0 +#ifdef ESP_PLATFORM +#include +#endif + +#include + +#include +#include +#include +#include + +extern "C" { + +static const ModuleSymbol SYMBOLS[] = { + // Task + DEFINE_MODULE_SYMBOL(uxTaskGetStackHighWaterMark), + DEFINE_MODULE_SYMBOL(uxTaskGetNumberOfTasks), + DEFINE_MODULE_SYMBOL(uxTaskGetTaskNumber), + DEFINE_MODULE_SYMBOL(uxTaskPriorityGet), + DEFINE_MODULE_SYMBOL(uxTaskPriorityGetFromISR), + DEFINE_MODULE_SYMBOL(vTaskDelay), + DEFINE_MODULE_SYMBOL(vTaskDelete), +#ifdef ESP_PLATFORM + // ESP-IDF FreeRTOS extension (memory-capability-aware alloc); not in vanilla FreeRTOS-Kernel. + DEFINE_MODULE_SYMBOL(vTaskDeleteWithCaps), +#endif + DEFINE_MODULE_SYMBOL(vTaskSetTimeOutState), + DEFINE_MODULE_SYMBOL(vTaskPrioritySet), + DEFINE_MODULE_SYMBOL(vTaskSetTaskNumber), + DEFINE_MODULE_SYMBOL(vTaskSetThreadLocalStoragePointer), +#ifdef ESP_PLATFORM + // ESP-IDF FreeRTOS extension (TLS pointer with destructor callback, used by pthread emulation). + DEFINE_MODULE_SYMBOL(vTaskSetThreadLocalStoragePointerAndDelCallback), +#endif + DEFINE_MODULE_SYMBOL(vTaskGetInfo), + DEFINE_MODULE_SYMBOL(vTaskResume), + DEFINE_MODULE_SYMBOL(vTaskSuspend), + DEFINE_MODULE_SYMBOL(xTaskCreate), + DEFINE_MODULE_SYMBOL(xTaskAbortDelay), + DEFINE_MODULE_SYMBOL(xTaskCheckForTimeOut), +#ifdef ESP_PLATFORM + // Xtensa_ESP32 port only; the POSIX port has no multi-core pinning. + DEFINE_MODULE_SYMBOL(xTaskCreatePinnedToCore), +#endif +#if configSUPPORT_STATIC_ALLOCATION == 1 + DEFINE_MODULE_SYMBOL(xTaskCreateStatic), +#ifdef ESP_PLATFORM + DEFINE_MODULE_SYMBOL(xTaskCreateStaticPinnedToCore), +#endif +#endif +#ifdef ESP_PLATFORM + // ESP-IDF FreeRTOS extensions (memory-capability-aware alloc); not in vanilla FreeRTOS-Kernel. + DEFINE_MODULE_SYMBOL(xTaskCreateWithCaps), + DEFINE_MODULE_SYMBOL(xTaskCreatePinnedToCoreWithCaps), +#endif + DEFINE_MODULE_SYMBOL(xTaskDelayUntil), + DEFINE_MODULE_SYMBOL(xTaskGenericNotify), + DEFINE_MODULE_SYMBOL(xTaskGenericNotifyFromISR), + DEFINE_MODULE_SYMBOL(ulTaskGenericNotifyTake), + DEFINE_MODULE_SYMBOL(xTaskGetCurrentTaskHandle), + DEFINE_MODULE_SYMBOL(xTaskGetTickCount), + DEFINE_MODULE_SYMBOL(xTaskGetTickCountFromISR), + DEFINE_MODULE_SYMBOL(pvTaskGetThreadLocalStoragePointer), + DEFINE_MODULE_SYMBOL(pvTaskIncrementMutexHeldCount), + // EventGroup + DEFINE_MODULE_SYMBOL(xEventGroupCreate), +#ifdef ESP_PLATFORM + // ESP-IDF FreeRTOS extension (memory-capability-aware alloc); not in vanilla FreeRTOS-Kernel. + DEFINE_MODULE_SYMBOL(xEventGroupCreateWithCaps), +#endif +#if configSUPPORT_STATIC_ALLOCATION == 1 + DEFINE_MODULE_SYMBOL(xEventGroupCreateStatic), + DEFINE_MODULE_SYMBOL(xEventGroupGetStaticBuffer), +#endif + DEFINE_MODULE_SYMBOL(xEventGroupClearBits), + DEFINE_MODULE_SYMBOL(xEventGroupClearBitsFromISR), + DEFINE_MODULE_SYMBOL(vEventGroupDelete), + DEFINE_MODULE_SYMBOL(xEventGroupGetBitsFromISR), + DEFINE_MODULE_SYMBOL(xEventGroupSetBits), + DEFINE_MODULE_SYMBOL(xEventGroupSetBitsFromISR), + DEFINE_MODULE_SYMBOL(xEventGroupSync), + DEFINE_MODULE_SYMBOL(xEventGroupWaitBits), + // Queue + DEFINE_MODULE_SYMBOL(vQueueDelete), +#ifdef ESP_PLATFORM + // ESP-IDF FreeRTOS extension (memory-capability-aware alloc); not in vanilla FreeRTOS-Kernel. + DEFINE_MODULE_SYMBOL(vQueueDeleteWithCaps), +#endif + DEFINE_MODULE_SYMBOL(vQueueSetQueueNumber), + DEFINE_MODULE_SYMBOL(vQueueWaitForMessageRestricted), + DEFINE_MODULE_SYMBOL(uxQueueGetQueueNumber), + DEFINE_MODULE_SYMBOL(uxQueueMessagesWaiting), + DEFINE_MODULE_SYMBOL(uxQueueMessagesWaitingFromISR), + DEFINE_MODULE_SYMBOL(uxQueueSpacesAvailable), + DEFINE_MODULE_SYMBOL(xQueueCreateCountingSemaphore), +#if configSUPPORT_STATIC_ALLOCATION == 1 + DEFINE_MODULE_SYMBOL(xQueueCreateCountingSemaphoreStatic), + DEFINE_MODULE_SYMBOL(xQueueCreateMutexStatic), + DEFINE_MODULE_SYMBOL(xQueueGenericCreateStatic), +#endif + DEFINE_MODULE_SYMBOL(xQueueCreateMutex), + DEFINE_MODULE_SYMBOL(xQueueCreateSet), + DEFINE_MODULE_SYMBOL(xQueueGetMutexHolder), + DEFINE_MODULE_SYMBOL(xQueueGetMutexHolderFromISR), + DEFINE_MODULE_SYMBOL(xQueueGiveMutexRecursive), + DEFINE_MODULE_SYMBOL(xQueueTakeMutexRecursive), + DEFINE_MODULE_SYMBOL(xQueueGenericCreate), + DEFINE_MODULE_SYMBOL(xQueueGenericReset), + DEFINE_MODULE_SYMBOL(xQueueGenericSend), + DEFINE_MODULE_SYMBOL(xQueueGenericSendFromISR), + DEFINE_MODULE_SYMBOL(xQueueSemaphoreTake), + DEFINE_MODULE_SYMBOL(xQueueReceive), + // Timer + DEFINE_MODULE_SYMBOL(pvTimerGetTimerID), + DEFINE_MODULE_SYMBOL(xTimerCreate), +#if configSUPPORT_STATIC_ALLOCATION == 1 + DEFINE_MODULE_SYMBOL(xTimerCreateStatic), +#endif + DEFINE_MODULE_SYMBOL(xTimerGenericCommand), + DEFINE_MODULE_SYMBOL(xTimerIsTimerActive), + DEFINE_MODULE_SYMBOL(xTimerGetExpiryTime), + DEFINE_MODULE_SYMBOL(xTimerPendFunctionCall), + DEFINE_MODULE_SYMBOL(xTimerPendFunctionCallFromISR), + DEFINE_MODULE_SYMBOL(xTimerGetPeriod), + DEFINE_MODULE_SYMBOL(uxTimerGetReloadMode), + DEFINE_MODULE_SYMBOL(uxTimerGetTimerNumber), + DEFINE_MODULE_SYMBOL(vTimerSetReloadMode), + DEFINE_MODULE_SYMBOL(vTimerSetTimerID), + DEFINE_MODULE_SYMBOL(vTimerSetTimerNumber), + // portmacro.h + DEFINE_MODULE_SYMBOL(vPortYield), + DEFINE_MODULE_SYMBOL(vPortEnterCritical), + DEFINE_MODULE_SYMBOL(vPortExitCritical), +#if defined(CONFIG_IDF_TARGET_ESP32P4) || defined(CONFIG_IDF_TARGET_ESP32S3) + DEFINE_MODULE_SYMBOL(xPortEnterCriticalTimeout), +#endif +#if (configNUM_CORES > 1) + DEFINE_MODULE_SYMBOL(vPortExitCriticalCompliance), +#endif +#ifdef CONFIG_IDF_TARGET_ESP32P4 + DEFINE_MODULE_SYMBOL(vPortExitCriticalMultiCore), +#endif +#ifdef ESP_PLATFORM + // freertos_tasks_c_additions.h - Xtensa_ESP32 port / ESP-IDF newlib integration only. + DEFINE_MODULE_SYMBOL(xPortInIsrContext), + DEFINE_MODULE_SYMBOL(xPortCanYield), + DEFINE_MODULE_SYMBOL(xPortGetCoreID), + DEFINE_MODULE_SYMBOL(xPortGetTickRateHz), + DEFINE_MODULE_SYMBOL(xPortInterruptedFromISRContext), + DEFINE_MODULE_SYMBOL(__getreent), +#endif + MODULE_SYMBOL_TERMINATOR, +}; + +Module freertos_module = { + .name = "freertos", + .start = nullptr, + .stop = nullptr, + .drivers = nullptr, + .symbols = SYMBOLS, + .internal = nullptr, +}; + +} diff --git a/Modules/gps-module/source/module.cpp b/Modules/gps-module/source/module.cpp index 29f546e3..c6935d87 100644 --- a/Modules/gps-module/source/module.cpp +++ b/Modules/gps-module/source/module.cpp @@ -24,7 +24,7 @@ Module gps_module = { .stop = stop, .drivers = nullptr, .symbols = nullptr, - .internal = nullptr + .internal = nullptr, }; } diff --git a/Modules/http-module/CMakeLists.txt b/Modules/http-module/CMakeLists.txt index 97675817..d671181a 100644 --- a/Modules/http-module/CMakeLists.txt +++ b/Modules/http-module/CMakeLists.txt @@ -11,6 +11,9 @@ list(APPEND REQUIRES_LIST if (DEFINED ENV{ESP_IDF_VERSION}) list(APPEND REQUIRES_LIST esp_http_client + esp_netif + lwip + mbedtls ) list(FILTER SOURCE_FILES EXCLUDE REGEX ".*download_mock\\.cpp$") else () diff --git a/Modules/http-module/source/module.cpp b/Modules/http-module/source/module.cpp index dcb176a9..b04d929d 100644 --- a/Modules/http-module/source/module.cpp +++ b/Modules/http-module/source/module.cpp @@ -2,14 +2,98 @@ #include #include +#ifdef ESP_PLATFORM +#include +#include +#include +#include +#include +#include +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE +#include +#endif +#endif + + +#include extern "C" { -static const ModuleSymbol http_module_symbols[] = { +static const ModuleSymbol SYMBOLS[] = { DEFINE_MODULE_SYMBOL(http_download_subscribe), DEFINE_MODULE_SYMBOL(http_download_unsubscribe), DEFINE_MODULE_SYMBOL(http_download_poll), DEFINE_MODULE_SYMBOL(http_download_start), DEFINE_MODULE_SYMBOL(http_download_cancel), + // posix + DEFINE_MODULE_SYMBOL(select), +#ifdef ESP_PLATFORM + // esp_netif.h + DEFINE_MODULE_SYMBOL(esp_netif_get_ip_info), + DEFINE_MODULE_SYMBOL(esp_netif_get_handle_from_ifkey), + // lwip/sockets.h + DEFINE_MODULE_SYMBOL(lwip_setsockopt), + DEFINE_MODULE_SYMBOL(lwip_socket), + DEFINE_MODULE_SYMBOL(lwip_recv), + DEFINE_MODULE_SYMBOL(lwip_getpeername), + DEFINE_MODULE_SYMBOL(lwip_bind), + DEFINE_MODULE_SYMBOL(lwip_listen), + DEFINE_MODULE_SYMBOL(lwip_close), + DEFINE_MODULE_SYMBOL(lwip_accept), + DEFINE_MODULE_SYMBOL(lwip_getsockname), + DEFINE_MODULE_SYMBOL(lwip_send), + DEFINE_MODULE_SYMBOL(lwip_connect), + DEFINE_MODULE_SYMBOL(lwip_select), + DEFINE_MODULE_SYMBOL(lwip_gethostbyname), + DEFINE_MODULE_SYMBOL(ipaddr_addr), + // esp_sntp.h + DEFINE_MODULE_SYMBOL(sntp_get_sync_status), + // esp_http +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE + // Needed for HTTPS: an app passes this as crt_bundle_attach to validate certificates against + // the bundle already compiled into the firmware (CONFIG_MBEDTLS_CERTIFICATE_BUNDLE). + DEFINE_MODULE_SYMBOL(esp_crt_bundle_attach), +#endif + DEFINE_MODULE_SYMBOL(esp_http_client_init), + DEFINE_MODULE_SYMBOL(esp_http_client_perform), + DEFINE_MODULE_SYMBOL(esp_http_client_cancel_request), + DEFINE_MODULE_SYMBOL(esp_http_client_set_url), + DEFINE_MODULE_SYMBOL(esp_http_client_set_post_field), + DEFINE_MODULE_SYMBOL(esp_http_client_get_post_field), + DEFINE_MODULE_SYMBOL(esp_http_client_set_header), + DEFINE_MODULE_SYMBOL(esp_http_client_get_header), + DEFINE_MODULE_SYMBOL(esp_http_client_get_username), + DEFINE_MODULE_SYMBOL(esp_http_client_set_username), + DEFINE_MODULE_SYMBOL(esp_http_client_get_password), + DEFINE_MODULE_SYMBOL(esp_http_client_set_password), + DEFINE_MODULE_SYMBOL(esp_http_client_set_authtype), + DEFINE_MODULE_SYMBOL(esp_http_client_get_user_data), + DEFINE_MODULE_SYMBOL(esp_http_client_set_user_data), + DEFINE_MODULE_SYMBOL(esp_http_client_get_errno), + DEFINE_MODULE_SYMBOL(esp_http_client_get_and_clear_last_tls_error), + DEFINE_MODULE_SYMBOL(esp_http_client_set_method), + DEFINE_MODULE_SYMBOL(esp_http_client_set_timeout_ms), + DEFINE_MODULE_SYMBOL(esp_http_client_delete_header), + DEFINE_MODULE_SYMBOL(esp_http_client_delete_all_headers), + DEFINE_MODULE_SYMBOL(esp_http_client_open), + DEFINE_MODULE_SYMBOL(esp_http_client_write), + DEFINE_MODULE_SYMBOL(esp_http_client_fetch_headers), + DEFINE_MODULE_SYMBOL(esp_http_client_is_chunked_response), + DEFINE_MODULE_SYMBOL(esp_http_client_read), + DEFINE_MODULE_SYMBOL(esp_http_client_get_status_code), + DEFINE_MODULE_SYMBOL(esp_http_client_get_content_length), + DEFINE_MODULE_SYMBOL(esp_http_client_close), + DEFINE_MODULE_SYMBOL(esp_http_client_cleanup), + DEFINE_MODULE_SYMBOL(esp_http_client_get_transport_type), + DEFINE_MODULE_SYMBOL(esp_http_client_set_redirection), + DEFINE_MODULE_SYMBOL(esp_http_client_reset_redirect_counter), + DEFINE_MODULE_SYMBOL(esp_http_client_set_auth_data), + DEFINE_MODULE_SYMBOL(esp_http_client_add_auth), + DEFINE_MODULE_SYMBOL(esp_http_client_is_complete_data_received), + DEFINE_MODULE_SYMBOL(esp_http_client_read_response), + DEFINE_MODULE_SYMBOL(esp_http_client_flush_response), + DEFINE_MODULE_SYMBOL(esp_http_client_get_url), + DEFINE_MODULE_SYMBOL(esp_http_client_get_chunk_length), +#endif MODULE_SYMBOL_TERMINATOR }; @@ -18,7 +102,7 @@ Module http_module = { .start = nullptr, .stop = nullptr, .drivers = nullptr, - .symbols = http_module_symbols, + .symbols = SYMBOLS, .internal = nullptr, }; diff --git a/Modules/lvgl-module/source/module.c b/Modules/lvgl-module/source/module.c index 3f6ab699..ec07d370 100644 --- a/Modules/lvgl-module/source/module.c +++ b/Modules/lvgl-module/source/module.c @@ -67,5 +67,5 @@ struct Module lvgl_module = { .start = start, .stop = stop, .symbols = (const struct ModuleSymbol*)lvgl_module_symbols, - .internal = NULL + .internal = NULL, }; diff --git a/Modules/lvgl-module/source/symbols.c b/Modules/lvgl-module/source/symbols.c index b5a0c6a2..56b5103b 100644 --- a/Modules/lvgl-module/source/symbols.c +++ b/Modules/lvgl-module/source/symbols.c @@ -531,5 +531,5 @@ const struct ModuleSymbol lvgl_module_symbols[] = { // lv_area DEFINE_MODULE_SYMBOL(lv_area_get_width), DEFINE_MODULE_SYMBOL(lv_area_get_height), - MODULE_SYMBOL_TERMINATOR -}; \ No newline at end of file + MODULE_SYMBOL_TERMINATOR, +}; diff --git a/Modules/lvgl-window-manager-module/source/symbols.cpp b/Modules/lvgl-window-manager-module/source/module.cpp similarity index 72% rename from Modules/lvgl-window-manager-module/source/symbols.cpp rename to Modules/lvgl-window-manager-module/source/module.cpp index b41acce2..116fd541 100644 --- a/Modules/lvgl-window-manager-module/source/symbols.cpp +++ b/Modules/lvgl-window-manager-module/source/module.cpp @@ -2,18 +2,16 @@ #include #include -#include #include extern "C" { -const ModuleSymbol lvgl_window_manager_module_symbols[] = { +static const ModuleSymbol SYMBOLS[] = { DEFINE_MODULE_SYMBOL(window_manager_create), DEFINE_MODULE_SYMBOL(window_manager_remove), DEFINE_MODULE_SYMBOL(window_manager_get_state), DEFINE_MODULE_SYMBOL(window_manager_await_state_change), - // terminator - MODULE_SYMBOL_TERMINATOR + MODULE_SYMBOL_TERMINATOR, }; Module lvgl_window_manager_module = { @@ -21,8 +19,8 @@ Module lvgl_window_manager_module = { .start = window_manager_start, .stop = window_manager_stop, .drivers = nullptr, - .symbols = lvgl_window_manager_module_symbols, - .internal = nullptr + .symbols = SYMBOLS, + .internal = nullptr, }; } diff --git a/Modules/mbedtls-module/CMakeLists.txt b/Modules/mbedtls-module/CMakeLists.txt new file mode 100644 index 00000000..29142bc5 --- /dev/null +++ b/Modules/mbedtls-module/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.20) + +include("${CMAKE_CURRENT_LIST_DIR}/../../Buildscripts/module.cmake") + +file(GLOB_RECURSE SOURCE_FILES "source/*.c*") + +tactility_add_module(mbedtls-module + SRCS ${SOURCE_FILES} + INCLUDE_DIRS include/ + REQUIRES TactilityKernel mbedtls +) diff --git a/Modules/mbedtls-module/LICENSE-Apache-2.0.md b/Modules/mbedtls-module/LICENSE-Apache-2.0.md new file mode 100644 index 00000000..f5f4b8b5 --- /dev/null +++ b/Modules/mbedtls-module/LICENSE-Apache-2.0.md @@ -0,0 +1,195 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/Modules/mbedtls-module/include/mbedtls/module.h b/Modules/mbedtls-module/include/mbedtls/module.h new file mode 100644 index 00000000..bb766c31 --- /dev/null +++ b/Modules/mbedtls-module/include/mbedtls/module.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct Module mbedtls_module; + +#ifdef __cplusplus +} +#endif diff --git a/Modules/mbedtls-module/source/module.cpp b/Modules/mbedtls-module/source/module.cpp new file mode 100644 index 00000000..2f275a68 --- /dev/null +++ b/Modules/mbedtls-module/source/module.cpp @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { + +static const ModuleSymbol SYMBOLS[] = { + // CTR_DRBG (random number generation) + DEFINE_MODULE_SYMBOL(mbedtls_ctr_drbg_init), + DEFINE_MODULE_SYMBOL(mbedtls_ctr_drbg_free), + DEFINE_MODULE_SYMBOL(mbedtls_ctr_drbg_seed), + DEFINE_MODULE_SYMBOL(mbedtls_ctr_drbg_random), + // Entropy + DEFINE_MODULE_SYMBOL(mbedtls_entropy_init), + DEFINE_MODULE_SYMBOL(mbedtls_entropy_free), + DEFINE_MODULE_SYMBOL(mbedtls_entropy_func), + // Cipher + DEFINE_MODULE_SYMBOL(mbedtls_cipher_init), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_free), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_setup), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_setkey), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_set_iv), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_reset), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_update), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_finish), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_get_block_size), + DEFINE_MODULE_SYMBOL(mbedtls_cipher_info_from_type), + // Message digest / HMAC + DEFINE_MODULE_SYMBOL(mbedtls_md), + DEFINE_MODULE_SYMBOL(mbedtls_md_init), + DEFINE_MODULE_SYMBOL(mbedtls_md_free), + DEFINE_MODULE_SYMBOL(mbedtls_md_setup), + DEFINE_MODULE_SYMBOL(mbedtls_md_starts), + DEFINE_MODULE_SYMBOL(mbedtls_md_update), + DEFINE_MODULE_SYMBOL(mbedtls_md_finish), + DEFINE_MODULE_SYMBOL(mbedtls_md_hmac_starts), + DEFINE_MODULE_SYMBOL(mbedtls_md_hmac_update), + DEFINE_MODULE_SYMBOL(mbedtls_md_hmac_finish), + DEFINE_MODULE_SYMBOL(mbedtls_md_info_from_type), + // Bignum (MPI) + DEFINE_MODULE_SYMBOL(mbedtls_mpi_init), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_free), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_read_binary), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_write_binary), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_size), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_bitlen), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_lset), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_set_bit), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_fill_random), + DEFINE_MODULE_SYMBOL(mbedtls_mpi_exp_mod), + // RSA + DEFINE_MODULE_SYMBOL(mbedtls_rsa_init), + DEFINE_MODULE_SYMBOL(mbedtls_rsa_free), + DEFINE_MODULE_SYMBOL(mbedtls_rsa_copy), + DEFINE_MODULE_SYMBOL(mbedtls_rsa_get_len), + DEFINE_MODULE_SYMBOL(mbedtls_rsa_check_pubkey), + DEFINE_MODULE_SYMBOL(mbedtls_rsa_check_privkey), + DEFINE_MODULE_SYMBOL(mbedtls_rsa_pkcs1_sign), + DEFINE_MODULE_SYMBOL(mbedtls_rsa_pkcs1_verify), + // Public key abstraction + DEFINE_MODULE_SYMBOL(mbedtls_pk_init), + DEFINE_MODULE_SYMBOL(mbedtls_pk_free), + DEFINE_MODULE_SYMBOL(mbedtls_pk_get_type), + DEFINE_MODULE_SYMBOL(mbedtls_pk_parse_key), + DEFINE_MODULE_SYMBOL(mbedtls_pk_parse_keyfile), + // ECP (elliptic curves) + DEFINE_MODULE_SYMBOL(mbedtls_ecp_group_load), + DEFINE_MODULE_SYMBOL(mbedtls_ecp_point_init), + DEFINE_MODULE_SYMBOL(mbedtls_ecp_point_free), + DEFINE_MODULE_SYMBOL(mbedtls_ecp_point_read_binary), + DEFINE_MODULE_SYMBOL(mbedtls_ecp_point_write_binary), + DEFINE_MODULE_SYMBOL(mbedtls_ecp_check_pubkey), + DEFINE_MODULE_SYMBOL(mbedtls_ecp_check_privkey), + DEFINE_MODULE_SYMBOL(mbedtls_ecp_mul), + // ECDSA + DEFINE_MODULE_SYMBOL(mbedtls_ecdsa_init), + DEFINE_MODULE_SYMBOL(mbedtls_ecdsa_free), + DEFINE_MODULE_SYMBOL(mbedtls_ecdsa_genkey), + DEFINE_MODULE_SYMBOL(mbedtls_ecdsa_from_keypair), + DEFINE_MODULE_SYMBOL(mbedtls_ecdsa_sign), + DEFINE_MODULE_SYMBOL(mbedtls_ecdsa_verify), + // ECDH + DEFINE_MODULE_SYMBOL(mbedtls_ecdh_compute_shared), + // Error strings + DEFINE_MODULE_SYMBOL(mbedtls_strerror), + MODULE_SYMBOL_TERMINATOR, +}; + +Module mbedtls_module = { + .name = "mbedtls", + .start = nullptr, + .stop = nullptr, + .drivers = nullptr, + .symbols = SYMBOLS, + .internal = nullptr, +}; + +} diff --git a/Modules/posix-symbols-module/CMakeLists.txt b/Modules/posix-symbols-module/CMakeLists.txt new file mode 100644 index 00000000..f3b5b1db --- /dev/null +++ b/Modules/posix-symbols-module/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.20) + +include("${CMAKE_CURRENT_LIST_DIR}/../../Buildscripts/module.cmake") + +file(GLOB_RECURSE SOURCE_FILES "source/*.c*") + +tactility_add_module(posix-symbols-module + SRCS ${SOURCE_FILES} + INCLUDE_DIRS include/ + REQUIRES TactilityKernel +) diff --git a/Modules/posix-symbols-module/LICENSE-Apache-2.0.md b/Modules/posix-symbols-module/LICENSE-Apache-2.0.md new file mode 100644 index 00000000..f5f4b8b5 --- /dev/null +++ b/Modules/posix-symbols-module/LICENSE-Apache-2.0.md @@ -0,0 +1,195 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/Modules/posix-symbols-module/include/posix_symbols/module.h b/Modules/posix-symbols-module/include/posix_symbols/module.h new file mode 100644 index 00000000..623473f3 --- /dev/null +++ b/Modules/posix-symbols-module/include/posix_symbols/module.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct Module posix_symbols_module; + +#ifdef __cplusplus +} +#endif diff --git a/Modules/posix-symbols-module/source/module.cpp b/Modules/posix-symbols-module/source/module.cpp new file mode 100644 index 00000000..3ac1ea6a --- /dev/null +++ b/Modules/posix-symbols-module/source/module.cpp @@ -0,0 +1,88 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __has_include() +#include +#define POSIX_SYMBOLS_HAS_GETOPT_LONG 1 +#endif + +extern "C" { + +static const ModuleSymbol SYMBOLS[] = { + // unistd.h + DEFINE_MODULE_SYMBOL(usleep), + DEFINE_MODULE_SYMBOL(sleep), + DEFINE_MODULE_SYMBOL(exit), + DEFINE_MODULE_SYMBOL(close), + DEFINE_MODULE_SYMBOL(rmdir), + DEFINE_MODULE_SYMBOL(unlink), + DEFINE_MODULE_SYMBOL(open), + DEFINE_MODULE_SYMBOL(access), + DEFINE_MODULE_SYMBOL(isatty), + DEFINE_MODULE_SYMBOL(read), + DEFINE_MODULE_SYMBOL(write), + DEFINE_MODULE_SYMBOL(lseek), + // strings.h +#if defined(__BSD_VISIBLE) && __BSD_VISIBLE + DEFINE_MODULE_SYMBOL(explicit_bzero), +#endif + DEFINE_MODULE_SYMBOL(strcasecmp), + DEFINE_MODULE_SYMBOL(strncasecmp), + // string.h + DEFINE_MODULE_SYMBOL(strdup), + DEFINE_MODULE_SYMBOL(stpcpy), + // time.h + DEFINE_MODULE_SYMBOL(clock_gettime), + DEFINE_MODULE_SYMBOL(localtime_r), + // setjmp.h + DEFINE_MODULE_SYMBOL(longjmp), + DEFINE_MODULE_SYMBOL(setjmp), + // dirent.h + DEFINE_MODULE_SYMBOL(opendir), + DEFINE_MODULE_SYMBOL(closedir), + DEFINE_MODULE_SYMBOL(readdir), + // fcntl.h + DEFINE_MODULE_SYMBOL(fcntl), + // sys/stat.h + DEFINE_MODULE_SYMBOL(stat), + DEFINE_MODULE_SYMBOL(mkdir), + // stdlib.h + DEFINE_MODULE_SYMBOL(rand_r), + DEFINE_MODULE_SYMBOL(setenv), + DEFINE_MODULE_SYMBOL(unsetenv), + // stdio.h - lets an app find the descriptor behind a stream. Needed when stdin/stdout have + // been pointed somewhere other than descriptors 0 and 1, e.g. an app that owns a terminal. + DEFINE_MODULE_SYMBOL(fileno), + // getopt.h - optind/opterr/optarg/optopt are POSIX; getopt_long is a GNU/BSD extension, only + // exported when is actually available. + DEFINE_MODULE_SYMBOL(optind), + DEFINE_MODULE_SYMBOL(opterr), + DEFINE_MODULE_SYMBOL(optarg), + DEFINE_MODULE_SYMBOL(optopt), +#ifdef POSIX_SYMBOLS_HAS_GETOPT_LONG + DEFINE_MODULE_SYMBOL(getopt_long), +#endif + MODULE_SYMBOL_TERMINATOR, +}; + +Module posix_symbols_module = { + .name = "posix-symbols", + .start = nullptr, + .stop = nullptr, + .drivers = nullptr, + .symbols = SYMBOLS, + .internal = nullptr, +}; + +} diff --git a/Modules/pthread-module/CMakeLists.txt b/Modules/pthread-module/CMakeLists.txt new file mode 100644 index 00000000..6eff3f66 --- /dev/null +++ b/Modules/pthread-module/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.20) + +include("${CMAKE_CURRENT_LIST_DIR}/../../Buildscripts/module.cmake") + +file(GLOB_RECURSE SOURCE_FILES "source/*.c*") + +list(APPEND REQUIRES_LIST + TactilityKernel +) + +if (NOT DEFINED ENV{ESP_IDF_VERSION}) + find_package(Threads REQUIRED) + list(APPEND REQUIRES_LIST + Threads::Threads + ) +endif () + +tactility_add_module(pthread-module + SRCS ${SOURCE_FILES} + INCLUDE_DIRS include/ + REQUIRES ${REQUIRES_LIST} +) diff --git a/Modules/pthread-module/LICENSE-Apache-2.0.md b/Modules/pthread-module/LICENSE-Apache-2.0.md new file mode 100644 index 00000000..f5f4b8b5 --- /dev/null +++ b/Modules/pthread-module/LICENSE-Apache-2.0.md @@ -0,0 +1,195 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### Terms and Conditions for use, reproduction, and distribution + +#### 1. Definitions + +“License” shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +“Licensor” shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +“Legal Entity” shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, “control” means **(i)** the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the +outstanding shares, or **(iii)** beneficial ownership of such entity. + +“You” (or “Your”) shall mean an individual or Legal Entity exercising +permissions granted by this License. + +“Source” form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +“Object” form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +“Work” shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +“Derivative Works” shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +“Contribution” shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +“submitted” means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as “Not a Contribution.” + +“Contributor” shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +#### 2. Grant of Copyright License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +#### 3. Grant of Patent License + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +#### 4. Redistribution + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +* **(a)** You must give any other recipients of the Work or Derivative Works a copy of +this License; and +* **(b)** You must cause any modified files to carry prominent notices stating that You +changed the files; and +* **(c)** You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. + +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +#### 5. Submission of Contributions + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +#### 6. Trademarks + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +#### 7. Disclaimer of Warranty + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +#### 8. Limitation of Liability + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +#### 9. Accepting Warranty or Additional Liability + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +_END OF TERMS AND CONDITIONS_ + +### APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets `[]` replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same “printed page” as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/Modules/pthread-module/include/pthread/module.h b/Modules/pthread-module/include/pthread/module.h new file mode 100644 index 00000000..0f06a3be --- /dev/null +++ b/Modules/pthread-module/include/pthread/module.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct Module pthread_module; + +#ifdef __cplusplus +} +#endif diff --git a/Modules/pthread-module/source/module.cpp b/Modules/pthread-module/source/module.cpp new file mode 100644 index 00000000..b9b449d8 --- /dev/null +++ b/Modules/pthread-module/source/module.cpp @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: Apache-2.0 +#include + +#include +#include +#include + +// pthread_mutex_timedlock / pthread_rwlock_timed{rd,wr}lock / sem_timedwait belong to POSIX's +// optional "Timeouts" feature (_POSIX_TIMEOUTS, from ) - Apple's libc never implements +// it, so this is the portable, spec-sanctioned test rather than an OS-name check. +#if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 +#define TT_PTHREAD_HAS_TIMEOUTS 1 +#else +#define TT_PTHREAD_HAS_TIMEOUTS 0 +#endif + +#if !defined(ESP_PLATFORM) && defined(__GLIBC_PREREQ) +#if __GLIBC_PREREQ(2, 30) +#define TT_PTHREAD_HAS_CLOCKWAIT 1 +#else +#define TT_PTHREAD_HAS_CLOCKWAIT 0 +#endif +#else +#define TT_PTHREAD_HAS_CLOCKWAIT 0 +#endif + +extern "C" { + +static const ModuleSymbol SYMBOLS[] = { + // pthread + DEFINE_MODULE_SYMBOL(pthread_attr_init), + DEFINE_MODULE_SYMBOL(pthread_attr_setstacksize), + DEFINE_MODULE_SYMBOL(pthread_create), + DEFINE_MODULE_SYMBOL(pthread_detach), + DEFINE_MODULE_SYMBOL(pthread_exit), + DEFINE_MODULE_SYMBOL(pthread_join), + // pthread_cond + DEFINE_MODULE_SYMBOL(pthread_cond_init), + DEFINE_MODULE_SYMBOL(pthread_cond_broadcast), +#if TT_PTHREAD_HAS_CLOCKWAIT + DEFINE_MODULE_SYMBOL(pthread_cond_clockwait), +#endif + DEFINE_MODULE_SYMBOL(pthread_cond_destroy), + DEFINE_MODULE_SYMBOL(pthread_cond_signal), + DEFINE_MODULE_SYMBOL(pthread_cond_timedwait), + // pthread_mutex + DEFINE_MODULE_SYMBOL(pthread_mutex_destroy), + DEFINE_MODULE_SYMBOL(pthread_mutex_init), + DEFINE_MODULE_SYMBOL(pthread_mutex_lock), +#if TT_PTHREAD_HAS_TIMEOUTS + DEFINE_MODULE_SYMBOL(pthread_mutex_timedlock), +#endif + DEFINE_MODULE_SYMBOL(pthread_mutex_trylock), + DEFINE_MODULE_SYMBOL(pthread_mutex_unlock), + // pthread_mutexattr + DEFINE_MODULE_SYMBOL(pthread_mutexattr_destroy), +#ifndef ESP_PLATFORM + DEFINE_MODULE_SYMBOL(pthread_mutexattr_getpshared), + DEFINE_MODULE_SYMBOL(pthread_mutexattr_setpshared), +#endif + DEFINE_MODULE_SYMBOL(pthread_mutexattr_gettype), + DEFINE_MODULE_SYMBOL(pthread_mutexattr_init), + DEFINE_MODULE_SYMBOL(pthread_mutexattr_settype), + // sem + DEFINE_MODULE_SYMBOL(sem_destroy), + DEFINE_MODULE_SYMBOL(sem_getvalue), + DEFINE_MODULE_SYMBOL(sem_init), + DEFINE_MODULE_SYMBOL(sem_post), +#if TT_PTHREAD_HAS_TIMEOUTS + DEFINE_MODULE_SYMBOL(sem_timedwait), +#endif + DEFINE_MODULE_SYMBOL(sem_trywait), + DEFINE_MODULE_SYMBOL(sem_wait), + // pthread_rwlock +#if TT_PTHREAD_HAS_CLOCKWAIT + DEFINE_MODULE_SYMBOL(pthread_rwlock_clockrdlock), + DEFINE_MODULE_SYMBOL(pthread_rwlock_clockwrlock), +#endif +#if TT_PTHREAD_HAS_TIMEOUTS + DEFINE_MODULE_SYMBOL(pthread_rwlock_timedrdlock), + DEFINE_MODULE_SYMBOL(pthread_rwlock_timedwrlock), +#endif +#ifndef ESP_PLATFORM + DEFINE_MODULE_SYMBOL(pthread_rwlockattr_destroy), + DEFINE_MODULE_SYMBOL(pthread_rwlockattr_getpshared), + DEFINE_MODULE_SYMBOL(pthread_rwlockattr_init), + DEFINE_MODULE_SYMBOL(pthread_rwlockattr_setpshared), +#endif + DEFINE_MODULE_SYMBOL(pthread_rwlock_destroy), + DEFINE_MODULE_SYMBOL(pthread_rwlock_init), + DEFINE_MODULE_SYMBOL(pthread_rwlock_rdlock), + DEFINE_MODULE_SYMBOL(pthread_rwlock_tryrdlock), + DEFINE_MODULE_SYMBOL(pthread_rwlock_trywrlock), + DEFINE_MODULE_SYMBOL(pthread_rwlock_unlock), + DEFINE_MODULE_SYMBOL(pthread_rwlock_wrlock), + MODULE_SYMBOL_TERMINATOR, +}; + +Module pthread_module = { + .name = "pthread", + .start = nullptr, + .stop = nullptr, + .drivers = nullptr, + .symbols = SYMBOLS, + .internal = nullptr, +}; + +} diff --git a/Modules/service-module/source/symbols.cpp b/Modules/service-module/source/module.cpp similarity index 90% rename from Modules/service-module/source/symbols.cpp rename to Modules/service-module/source/module.cpp index f54c4b3c..a465ee32 100644 --- a/Modules/service-module/source/symbols.cpp +++ b/Modules/service-module/source/module.cpp @@ -4,7 +4,7 @@ #include #include -const ModuleSymbol service_module_symbols[] = { +static const ModuleSymbol SYMBOLS[] = { // service/service_instance DEFINE_MODULE_SYMBOL(service_instance_construct), DEFINE_MODULE_SYMBOL(service_instance_destruct), @@ -30,7 +30,9 @@ const ModuleSymbol service_module_symbols[] = { Module service_module = { .name = "service", + .start = nullptr, + .stop = nullptr, .drivers = nullptr, - .symbols = service_module_symbols, - .internal = nullptr + .symbols = SYMBOLS, + .internal = nullptr, }; diff --git a/Platforms/platform-esp32/CMakeLists.txt b/Platforms/platform-esp32/CMakeLists.txt index 4295d9c5..5fa0a61c 100644 --- a/Platforms/platform-esp32/CMakeLists.txt +++ b/Platforms/platform-esp32/CMakeLists.txt @@ -4,12 +4,14 @@ file(GLOB_RECURSE SOURCES "source/*.c**") set(PRIV_REQUIRES_LIST "") if ("${IDF_TARGET}" STREQUAL "esp32s3" OR "${IDF_TARGET}" STREQUAL "esp32p4") - # esp32_usb_device_controller.cpp / esp32_usb_hid_device.cpp include tinyusb.h - only - # available on targets with TinyUSB device-mode support (mirrors Tactility/CMakeLists.txt's - # own esp_tinyusb requirement). list(APPEND PRIV_REQUIRES_LIST esp_tinyusb) endif () +if ("${IDF_TARGET}" STREQUAL "esp32p4") + list(APPEND PRIV_REQUIRES_LIST esp_driver_ppa) + list(APPEND PRIV_REQUIRES_LIST esp_mm) +endif () + idf_component_register( SRCS ${SOURCES} INCLUDE_DIRS "include/" diff --git a/Platforms/platform-esp32/source/module.cpp b/Platforms/platform-esp32/source/module.cpp index 750931ab..a0a490c2 100644 --- a/Platforms/platform-esp32/source/module.cpp +++ b/Platforms/platform-esp32/source/module.cpp @@ -2,11 +2,324 @@ #include #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_IDF_TARGET_ESP32P4 +#include +#include +#endif + #include #include +// GCC soft-float / compiler-rt helpers an app may need but can't reach through a header - +// reference: https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html +// ESP32P4 (RISC-V, native single-precision FPU) only needs the double-precision + 64-bit-div +// subset; every other (Xtensa) target needs the full single- and double-precision set. extern "C" { +#ifndef CONFIG_IDF_TARGET_ESP32P4 + extern float __addsf3(float a, float b); + extern double __adddf3(double a, double b); + extern float __subsf3(float a, float b); + extern double __subdf3(double a, double b); + extern float __mulsf3(float a, float b); + extern double __muldf3(double a, double b); + extern float __divsf3(float a, float b); + extern double __divdf3(double a, double b); + extern float __negsf2(float a); + extern double __negdf2(double a); + extern double __extendsfdf2(float a); + extern float __truncdfsf2(double a); + extern int __fixsfsi(float a); + extern int __fixdfsi(double a); + extern long __fixsfdi(float a); + extern long __fixdfdi(double a); + extern unsigned int __fixunssfsi(float a); + extern unsigned int __fixunsdfsi(double a); + extern unsigned long __fixunssfdi(float a); + extern unsigned long __fixunsdfdi(double a); + extern float __floatsisf(int i); + extern double __floatsidf(int i); + extern float __floatdisf(long i); + extern double __floatdidf(long i); + extern float __floatunsisf(unsigned int i); + extern double __floatunsidf(unsigned int i); + extern float __floatundisf(unsigned long i); + extern double __floatundidf(unsigned long i); + float __powisf2(float a, int b); + double __powidf2(double a, int b); + int __cmpdf2(double a, double b); + int __unordsf2(float a, float b); + int __unorddf2(double a, double b); + int __eqsf2(float a, float b); + int __eqdf2(double a, double b); + int __nesf2(float a, float b); + int __nedf2(double a, double b); + int __gesf2(float a, float b); + int __gedf2(double a, double b); + int __ltsf2(float a, float b); + int __ltdf2(double a, double b); + int __lesf2(float a, float b); + int __ledf2(double a, double b); + int __gtsf2(float a, float b); + int __gtdf2(double a, double b); + // GCC integer arithmetic helpers (needed on 32-bit targets for 64-bit ops) + long long __divdi3(long long a, long long b); + long long __moddi3(long long a, long long b); + unsigned long long __udivdi3(unsigned long long a, unsigned long long b); + unsigned long long __umoddi3(unsigned long long a, unsigned long long b); +#else + extern double __adddf3(double a, double b); + extern double __subdf3(double a, double b); + extern double __muldf3(double a, double b); + extern double __divdf3(double a, double b); + extern double __negdf2(double a); + extern double __extendsfdf2(float a); + extern float __truncdfsf2(double a); + extern int __fixdfsi(double a); + extern long __fixdfdi(double a); + extern unsigned int __fixunsdfsi(double a); + extern unsigned long __fixunssfdi(float a); + extern unsigned long __fixunsdfdi(double a); + extern double __floatsidf(int i); + extern float __floatdisf(long i); + extern double __floatdidf(long i); + extern double __floatunsidf(unsigned int i); + extern float __floatundisf(unsigned long i); + extern double __floatundidf(unsigned long i); + float __powisf2(float a, int b); + double __powidf2(double a, int b); + int __cmpdf2(double a, double b); + int __unorddf2(double a, double b); + int __eqdf2(double a, double b); + int __nedf2(double a, double b); + int __gedf2(double a, double b); + int __ltdf2(double a, double b); + int __ledf2(double a, double b); + int __gtdf2(double a, double b); + // GCC integer/bitwise helpers (compiler-rt) + int __clzsi2(unsigned int x); + // GCC 64-bit integer arithmetic helpers (needed for 64-bit div on 32-bit RISC-V) + long long __divdi3(long long a, long long b); + unsigned long long __udivdi3(unsigned long long a, unsigned long long b); +#endif +} + +extern "C" { + +static const ModuleSymbol platform_esp32_symbols[] = { + // cassert + DEFINE_MODULE_SYMBOL(__assert_func), + // esp_log + DEFINE_MODULE_SYMBOL(esp_log), + DEFINE_MODULE_SYMBOL(esp_log_level_set), + DEFINE_MODULE_SYMBOL(esp_log_set_vprintf), + DEFINE_MODULE_SYMBOL(esp_log_write), + DEFINE_MODULE_SYMBOL(esp_log_timestamp), + // esp_err + DEFINE_MODULE_SYMBOL(esp_err_to_name), + DEFINE_MODULE_SYMBOL(_esp_error_check_failed), + // esp random + DEFINE_MODULE_SYMBOL(esp_random), + DEFINE_MODULE_SYMBOL(esp_fill_random), + // esp_event_loop + DEFINE_MODULE_SYMBOL(esp_event_loop_create), + DEFINE_MODULE_SYMBOL(esp_event_loop_delete), + DEFINE_MODULE_SYMBOL(esp_event_loop_create_default), + DEFINE_MODULE_SYMBOL(esp_event_loop_delete_default), + DEFINE_MODULE_SYMBOL(esp_event_loop_run), + DEFINE_MODULE_SYMBOL(esp_event_handler_register), + DEFINE_MODULE_SYMBOL(esp_event_handler_register_with), + DEFINE_MODULE_SYMBOL(esp_event_handler_instance_register_with), + DEFINE_MODULE_SYMBOL(esp_event_handler_instance_register), + DEFINE_MODULE_SYMBOL(esp_event_handler_unregister), + DEFINE_MODULE_SYMBOL(esp_event_handler_unregister_with), + DEFINE_MODULE_SYMBOL(esp_event_handler_instance_unregister_with), + DEFINE_MODULE_SYMBOL(esp_event_handler_instance_unregister), + DEFINE_MODULE_SYMBOL(esp_event_post), + DEFINE_MODULE_SYMBOL(esp_event_post_to), + DEFINE_MODULE_SYMBOL(esp_event_isr_post), + DEFINE_MODULE_SYMBOL(esp_event_isr_post_to), + // sys/errno.h + DEFINE_MODULE_SYMBOL(__errno), + // esp_vfs.h + DEFINE_MODULE_SYMBOL(esp_vfs_register), + DEFINE_MODULE_SYMBOL(esp_vfs_unregister), + // driver/gpio.h + DEFINE_MODULE_SYMBOL(gpio_config), + DEFINE_MODULE_SYMBOL(gpio_get_level), + DEFINE_MODULE_SYMBOL(gpio_set_level), + DEFINE_MODULE_SYMBOL(gpio_reset_pin), + // driver/i2s_common.h + DEFINE_MODULE_SYMBOL(i2s_new_channel), + DEFINE_MODULE_SYMBOL(i2s_del_channel), + DEFINE_MODULE_SYMBOL(i2s_channel_enable), + DEFINE_MODULE_SYMBOL(i2s_channel_disable), + DEFINE_MODULE_SYMBOL(i2s_channel_write), + DEFINE_MODULE_SYMBOL(i2s_channel_get_info), + DEFINE_MODULE_SYMBOL(i2s_channel_read), + DEFINE_MODULE_SYMBOL(i2s_channel_register_event_callback), + DEFINE_MODULE_SYMBOL(i2s_channel_preload_data), + DEFINE_MODULE_SYMBOL(i2s_channel_tune_rate), + // driver/i2s_std.h + DEFINE_MODULE_SYMBOL(i2s_channel_init_std_mode), + DEFINE_MODULE_SYMBOL(i2s_channel_reconfig_std_clock), + DEFINE_MODULE_SYMBOL(i2s_channel_reconfig_std_slot), + DEFINE_MODULE_SYMBOL(i2s_channel_reconfig_std_gpio), + // miniz.h + DEFINE_MODULE_SYMBOL(tinfl_decompress), + DEFINE_MODULE_SYMBOL(tinfl_decompress_mem_to_callback), + DEFINE_MODULE_SYMBOL(tinfl_decompress_mem_to_mem), + DEFINE_MODULE_SYMBOL(tdefl_init), + DEFINE_MODULE_SYMBOL(tdefl_compress), + DEFINE_MODULE_SYMBOL(tdefl_compress_buffer), + DEFINE_MODULE_SYMBOL(tdefl_compress_mem_to_mem), + DEFINE_MODULE_SYMBOL(tdefl_compress_mem_to_output), + DEFINE_MODULE_SYMBOL(tdefl_get_adler32), + DEFINE_MODULE_SYMBOL(tdefl_get_prev_return_status), + // ledc + DEFINE_MODULE_SYMBOL(ledc_update_duty), + DEFINE_MODULE_SYMBOL(ledc_set_freq), + DEFINE_MODULE_SYMBOL(ledc_channel_config), + DEFINE_MODULE_SYMBOL(ledc_set_duty), + DEFINE_MODULE_SYMBOL(ledc_set_fade), + DEFINE_MODULE_SYMBOL(ledc_set_fade_with_step), + DEFINE_MODULE_SYMBOL(ledc_set_fade_with_time), + DEFINE_MODULE_SYMBOL(ledc_set_fade_step_and_start), + DEFINE_MODULE_SYMBOL(ledc_set_fade_time_and_start), + DEFINE_MODULE_SYMBOL(ledc_set_pin), + DEFINE_MODULE_SYMBOL(ledc_timer_config), + DEFINE_MODULE_SYMBOL(ledc_timer_pause), + DEFINE_MODULE_SYMBOL(ledc_timer_resume), + DEFINE_MODULE_SYMBOL(ledc_timer_rst), + // esp_heap_caps.h + DEFINE_MODULE_SYMBOL(heap_caps_get_total_size), + DEFINE_MODULE_SYMBOL(heap_caps_get_allocated_size), + DEFINE_MODULE_SYMBOL(heap_caps_get_free_size), + DEFINE_MODULE_SYMBOL(heap_caps_get_largest_free_block), + DEFINE_MODULE_SYMBOL(heap_caps_aligned_alloc), + DEFINE_MODULE_SYMBOL(heap_caps_malloc), + DEFINE_MODULE_SYMBOL(heap_caps_calloc), + DEFINE_MODULE_SYMBOL(heap_caps_free), + // esp_timer.h + DEFINE_MODULE_SYMBOL(esp_timer_create), + DEFINE_MODULE_SYMBOL(esp_timer_stop), + DEFINE_MODULE_SYMBOL(esp_timer_delete), + DEFINE_MODULE_SYMBOL(esp_timer_start_periodic), + DEFINE_MODULE_SYMBOL(esp_timer_start_once), + DEFINE_MODULE_SYMBOL(esp_timer_get_time), +#ifdef CONFIG_IDF_TARGET_ESP32P4 + // driver/ppa.h + DEFINE_MODULE_SYMBOL(ppa_register_client), + DEFINE_MODULE_SYMBOL(ppa_unregister_client), + DEFINE_MODULE_SYMBOL(ppa_do_scale_rotate_mirror), + // esp_cache.h + DEFINE_MODULE_SYMBOL(esp_cache_msync), +#endif + // esp_system.h + DEFINE_MODULE_SYMBOL(esp_restart), + // soft float +#ifndef CONFIG_IDF_TARGET_ESP32P4 + DEFINE_MODULE_SYMBOL(__addsf3), + DEFINE_MODULE_SYMBOL(__adddf3), + DEFINE_MODULE_SYMBOL(__subsf3), + DEFINE_MODULE_SYMBOL(__subdf3), + DEFINE_MODULE_SYMBOL(__mulsf3), + DEFINE_MODULE_SYMBOL(__muldf3), + DEFINE_MODULE_SYMBOL(__divsf3), + DEFINE_MODULE_SYMBOL(__divdf3), + DEFINE_MODULE_SYMBOL(__negsf2), + DEFINE_MODULE_SYMBOL(__negdf2), + DEFINE_MODULE_SYMBOL(__extendsfdf2), + DEFINE_MODULE_SYMBOL(__truncdfsf2), + DEFINE_MODULE_SYMBOL(__fixsfsi), + DEFINE_MODULE_SYMBOL(__fixdfsi), + DEFINE_MODULE_SYMBOL(__fixsfdi), + DEFINE_MODULE_SYMBOL(__fixdfdi), + DEFINE_MODULE_SYMBOL(__fixunssfsi), + DEFINE_MODULE_SYMBOL(__fixunsdfsi), + DEFINE_MODULE_SYMBOL(__fixunssfdi), + DEFINE_MODULE_SYMBOL(__fixunsdfdi), + DEFINE_MODULE_SYMBOL(__floatsisf), + DEFINE_MODULE_SYMBOL(__floatsidf), + DEFINE_MODULE_SYMBOL(__floatdisf), + DEFINE_MODULE_SYMBOL(__floatdidf), + DEFINE_MODULE_SYMBOL(__floatunsisf), + DEFINE_MODULE_SYMBOL(__floatunsidf), + DEFINE_MODULE_SYMBOL(__floatundisf), + DEFINE_MODULE_SYMBOL(__floatundidf), + DEFINE_MODULE_SYMBOL(__powisf2), + DEFINE_MODULE_SYMBOL(__powidf2), + DEFINE_MODULE_SYMBOL(__unordsf2), + DEFINE_MODULE_SYMBOL(__unorddf2), + DEFINE_MODULE_SYMBOL(__eqsf2), + DEFINE_MODULE_SYMBOL(__eqdf2), + DEFINE_MODULE_SYMBOL(__nesf2), + DEFINE_MODULE_SYMBOL(__nedf2), + DEFINE_MODULE_SYMBOL(__gesf2), + DEFINE_MODULE_SYMBOL(__gedf2), + DEFINE_MODULE_SYMBOL(__ltsf2), + DEFINE_MODULE_SYMBOL(__ltdf2), + DEFINE_MODULE_SYMBOL(__lesf2), + DEFINE_MODULE_SYMBOL(__ledf2), + DEFINE_MODULE_SYMBOL(__gtsf2), + DEFINE_MODULE_SYMBOL(__gtdf2), + DEFINE_MODULE_SYMBOL(__divdi3), + DEFINE_MODULE_SYMBOL(__moddi3), + DEFINE_MODULE_SYMBOL(__udivdi3), + DEFINE_MODULE_SYMBOL(__umoddi3), +#else + DEFINE_MODULE_SYMBOL(__adddf3), + DEFINE_MODULE_SYMBOL(__subdf3), + DEFINE_MODULE_SYMBOL(__muldf3), + DEFINE_MODULE_SYMBOL(__divdf3), + DEFINE_MODULE_SYMBOL(__negdf2), + DEFINE_MODULE_SYMBOL(__extendsfdf2), + DEFINE_MODULE_SYMBOL(__truncdfsf2), + DEFINE_MODULE_SYMBOL(__fixdfsi), + DEFINE_MODULE_SYMBOL(__fixdfdi), + DEFINE_MODULE_SYMBOL(__fixunsdfsi), + DEFINE_MODULE_SYMBOL(__fixunssfdi), + DEFINE_MODULE_SYMBOL(__fixunsdfdi), + DEFINE_MODULE_SYMBOL(__floatsidf), + DEFINE_MODULE_SYMBOL(__floatdisf), + DEFINE_MODULE_SYMBOL(__floatdidf), + DEFINE_MODULE_SYMBOL(__floatunsidf), + DEFINE_MODULE_SYMBOL(__floatundisf), + DEFINE_MODULE_SYMBOL(__floatundidf), + DEFINE_MODULE_SYMBOL(__powisf2), + DEFINE_MODULE_SYMBOL(__powidf2), + DEFINE_MODULE_SYMBOL(__unorddf2), + DEFINE_MODULE_SYMBOL(__eqdf2), + DEFINE_MODULE_SYMBOL(__nedf2), + DEFINE_MODULE_SYMBOL(__gedf2), + DEFINE_MODULE_SYMBOL(__ltdf2), + DEFINE_MODULE_SYMBOL(__ledf2), + DEFINE_MODULE_SYMBOL(__gtdf2), + DEFINE_MODULE_SYMBOL(__clzsi2), + DEFINE_MODULE_SYMBOL(__divdi3), + DEFINE_MODULE_SYMBOL(__udivdi3), +#endif + MODULE_SYMBOL_TERMINATOR, +}; extern Driver esp32_adc_oneshot_driver; extern Driver esp32_gpio_driver; @@ -78,7 +391,7 @@ static Driver* const platform_esp32_drivers[] = { &esp32_wifi_driver, &esp32_wifi_pinned_driver, #endif -#if defined(CONFIG_BT_NIMBLE_ENABLED) +#ifdef CONFIG_BT_NIMBLE_ENABLED &esp32_bluetooth_driver, &esp32_ble_serial_driver, &esp32_ble_midi_driver, @@ -106,14 +419,16 @@ static Driver* const platform_esp32_drivers[] = { #if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_CDC_ENABLED &esp32_usb_cdc_device_driver, #endif - nullptr + nullptr, }; Module platform_esp32_module = { .name = "platform-esp32", + .start = nullptr, + .stop = nullptr, .drivers = platform_esp32_drivers, - .symbols = nullptr, - .internal = nullptr + .symbols = platform_esp32_symbols, + .internal = nullptr, }; } diff --git a/Platforms/platform-posix/source/module.cpp b/Platforms/platform-posix/source/module.cpp index 9d9b8d0e..9ad622bc 100644 --- a/Platforms/platform-posix/source/module.cpp +++ b/Platforms/platform-posix/source/module.cpp @@ -10,11 +10,13 @@ static Driver* const platform_posix_drivers[] = { nullptr }; -struct Module platform_posix_module = { +Module platform_posix_module = { .name = "platform-posix", + .start = nullptr, + .stop = nullptr, .drivers = platform_posix_drivers, .symbols = nullptr, - .internal = nullptr + .internal = nullptr, }; } diff --git a/Tactility/CMakeLists.txt b/Tactility/CMakeLists.txt index 27b3577e..f9535f0c 100644 --- a/Tactility/CMakeLists.txt +++ b/Tactility/CMakeLists.txt @@ -2,25 +2,59 @@ cmake_minimum_required(VERSION 3.20) include("${CMAKE_CURRENT_LIST_DIR}/../Buildscripts/module.cmake") +get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) + file(GLOB_RECURSE SOURCE_FILES Source/*.c*) +# Get the project and device id +if (DEFINED ENV{ESP_IDF_VERSION}) + include("../Buildscripts/device.cmake") + init_tactility_globals("../sdkconfig") + get_property(TACTILITY_DEVICE_PROJECT GLOBAL PROPERTY TACTILITY_DEVICE_PROJECT) + get_property(TACTILITY_DEVICE_ID GLOBAL PROPERTY TACTILITY_DEVICE_ID) +else () + set(TACTILITY_DEVICE_ID simulator) + set(COMPONENT_LIB Tactility) + set(TACTILITY_DEVICE_PROJECT Simulator) +endif () + +set(DEVICETREE_LOCATION "${PROJECT_ROOT}/Devices/${TACTILITY_DEVICE_ID}") + list(APPEND REQUIRES_LIST + # Main projects TactilityKernel TactilityKernelCpp TactilityFreeRtos + # Modules/* lvgl-module lvgl-window-manager-module app-module + c-symbols-module + cpp-symbols-module crypt-module + freertos-module gps-module http-module + mbedtls-module + posix-symbols-module + pthread-module gps-generic-module gps-meshtastic-module service-module + # Libraries/* lv_screenshot minitar ) +# Check if device has Bluetooth enabled +# Fixes the sdkconfig bluetooth enable options from getting nuked on non-P4+C6 builds when idf build runs +if (DEFINED ENV{ESP_IDF_VERSION}) + file(READ "${DEVICETREE_LOCATION}/device.properties" device_properties_content) + if (device_properties_content MATCHES "hardware\\.bluetooth=true") + list(APPEND REQUIRES_LIST bt) + endif() +endif() + if (DEFINED ENV{ESP_IDF_VERSION}) list(APPEND REQUIRES_LIST @@ -62,14 +96,69 @@ else () endif () -tactility_add_module(Tactility - SRCS ${SOURCE_FILES} - INCLUDE_DIRS Include/ - PRIV_INCLUDE_DIRS Private/ - REQUIRES ${REQUIRES_LIST} +# +# Devicetree code generation: DTS compiler python dependencies +# + +execute_process( + COMMAND python -m pip install lark==1.3.1 pyyaml==6.0.3 + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) +# +# Devicetree code generation: Devicetree dependency collection +# + +# REQUIRES_LIST below is computed once, at configure time. Without this, editing +# devicetree.yaml (e.g. adding a driver dependency) doesn't trigger a cmake reconfigure, +# so the new component's include dirs never reach the compiler until a fullclean. +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + "${DEVICETREE_LOCATION}/devicetree.yaml" + "${DEVICETREE_LOCATION}/device.properties" # due to the "hardware.bluetooth = true" search in this file from this CMakeLists.txt +) + +execute_process( + COMMAND python "${PROJECT_ROOT}/Buildscripts/DevicetreeCompiler/dependencies.py" "${DEVICETREE_LOCATION}" + WORKING_DIRECTORY "${PROJECT_ROOT}" + OUTPUT_VARIABLE DEVICE_DEPENDENCIES + OUTPUT_STRIP_TRAILING_WHITESPACE +) +# Tokenize to array of lines +separate_arguments(DEVICE_DEPENDENCIES UNIX_COMMAND "${DEVICE_DEPENDENCIES}") + +# Devicetree dependencies go on a separate list, not REQUIRES_LIST itself: the "simulator" device +# component links back against Tactility, so folding it into Tactility's own REQUIRES here would +# create a dependency cycle. They only apply to the Tactility target itself once it's built as the +# final executable (both platforms), never to a library consumer like TactilityTests. +set(TACTILITY_REQUIRES_LIST ${REQUIRES_LIST}) +foreach(dts_dependency IN LISTS DEVICE_DEPENDENCIES) + message("Adding DTS dependency ${dts_dependency}") + list(APPEND TACTILITY_REQUIRES_LIST ${dts_dependency}) +endforeach() + +# +# Devicetree code generation: "Generated/" directory creation +# + +set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/Generated") +# Ensure the directory is built in the correct CMake build phase +# If the check is not done, then another directory is created in the root of the build folder. +if (DEFINED CMAKE_CURRENT_BINARY_DIR) + file(MAKE_DIRECTORY "${GENERATED_DIR}") +endif () + +# +# Component +# + if (DEFINED ENV{ESP_IDF_VERSION}) + idf_component_register( + SRCS ${SOURCE_FILES} "${GENERATED_DIR}/devicetree.c" + INCLUDE_DIRS Include/ + PRIV_INCLUDE_DIRS Private/ + REQUIRES ${TACTILITY_REQUIRES_LIST} + ) + idf_component_optional_requires(PRIVATE bt) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -84,6 +173,34 @@ if (DEFINED ENV{ESP_IDF_VERSION}) fatfs_create_spiflash_image(data "${CMAKE_CURRENT_SOURCE_DIR}/../Data/data" FLASH_IN_PROJECT PRESERVE_TIME) endif () endif () - +else () + list(APPEND TACTILITY_REQUIRES_LIST + SDL2::SDL2-static + SDL2-static + ) + add_executable(Tactility ${SOURCE_FILES}) + target_include_directories(Tactility PUBLIC Include/) + target_include_directories(Tactility PRIVATE Private/) + target_link_libraries(Tactility PRIVATE ${TACTILITY_REQUIRES_LIST}) endif () +# +# Devicetree code generation: custom target +# + +# A custom target (not add_custom_command(OUTPUT ...)) so this always reruns: the devicetree's +# real inputs span many files (dts, bindings yaml, driver headers) that no fixed DEPENDS list can +# enumerate. BYPRODUCTS still wires a proper dependency for the sources that consume the output. +add_custom_target(Generated ALL + COMMAND python "${CMAKE_SOURCE_DIR}/Buildscripts/DevicetreeCompiler/compile.py" + "${DEVICETREE_LOCATION}" "${GENERATED_DIR}" + BYPRODUCTS "${GENERATED_DIR}/devicetree.c" "${GENERATED_DIR}/devicetree.h" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Generating devicetree source files..." +) +set_source_files_properties("${GENERATED_DIR}/devicetree.c" PROPERTIES GENERATED TRUE) +set_source_files_properties("${GENERATED_DIR}/devicetree.h" PROPERTIES GENERATED TRUE) +# Update target for generated code +target_sources(${COMPONENT_LIB} PRIVATE "${GENERATED_DIR}/devicetree.c") +target_include_directories(${COMPONENT_LIB} PRIVATE "${GENERATED_DIR}") +add_dependencies(${COMPONENT_LIB} Generated) diff --git a/Tactility/Include/Tactility/network/Http.h b/Tactility/Include/Tactility/network/Http.h deleted file mode 100644 index 9be0ac78..00000000 --- a/Tactility/Include/Tactility/network/Http.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include -#include - -namespace tt::network::http { - /** - * Download a file from a URL. - * The server must send the Content-Length header. - * @param url download source URL - * @param certFilePath the path to the .pem file - * @param downloadFilePath The path to downloadd the file to. The parent directories must exist. - * @param onSuccess the success result callback - * @param onError the error result callback - */ - void download( - const std::string& url, - const std::string& certFilePath, - const std::string &downloadFilePath, - const std::function& onSuccess, - const std::function& onError -); - -} diff --git a/Firmware/Kconfig b/Tactility/Kconfig similarity index 100% rename from Firmware/Kconfig rename to Tactility/Kconfig diff --git a/Firmware/Source/Main.cpp b/Tactility/Source/Main.cpp similarity index 54% rename from Firmware/Source/Main.cpp rename to Tactility/Source/Main.cpp index 8c902c8c..cc861a42 100644 --- a/Firmware/Source/Main.cpp +++ b/Tactility/Source/Main.cpp @@ -2,20 +2,13 @@ #include -#ifdef ESP_PLATFORM -#include -#else +#ifndef ESP_PLATFORM #include #endif extern "C" { void app_main() { - -#ifdef ESP_PLATFORM - tt_init_tactility_c(); // ELF bindings for side-loading on ESP32 -#endif - tt::run(dts_modules, dts_devices); } diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 0b37880f..cf9a5c79 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -36,12 +36,18 @@ #include #include +#include +#include #include +#include #include #include #include #include +#include +#include +#include #include #include @@ -472,13 +478,23 @@ void run(Module* const dtsModules[], const DtsDevice dtsDevices[]) { return; } + // The following groups of symbols are sorted by the estimated chance of them occurring + + // C/C++/Posix symbols + check(module_ensure_started(&c_symbols_module) == ERROR_NONE); + check(module_ensure_started(&posix_symbols_module) == ERROR_NONE); + check(module_ensure_started(&cpp_symbols_module) == ERROR_NONE); + // OS level symbols + check(module_ensure_started(&freertos_module) == ERROR_NONE); + check(module_ensure_started(&pthread_module) == ERROR_NONE); + // Other libraries + check(module_ensure_started(&http_module) == ERROR_NONE); + check(module_ensure_started(&app_module) == ERROR_NONE); check(module_ensure_started(&crypt_module) == ERROR_NONE); + check(module_ensure_started(&mbedtls_module) == ERROR_NONE); check(module_ensure_started(&gps_module) == ERROR_NONE); check(module_ensure_started(&gps_generic_module) == ERROR_NONE); check(module_ensure_started(&gps_meshtastic_module) == ERROR_NONE); - check(module_ensure_started(&http_module) == ERROR_NONE); - // Registers the APP_LOCATION_MEMORY app loader (boot/launcher need it below). - check(module_ensure_started(&app_module) == ERROR_NONE); #ifdef ESP_PLATFORM check(module_ensure_started(&app_esp32_module) == ERROR_NONE); #endif diff --git a/Tactility/Source/network/Http.cpp b/Tactility/Source/network/Http.cpp deleted file mode 100644 index 8431dd7a..00000000 --- a/Tactility/Source/network/Http.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#include - -#include - -#ifdef ESP_PLATFORM -#include -#include -#endif - -namespace tt::network::http { - -constexpr auto* TAG = "HTTP"; - -void download( - const std::string& url, - const std::string& certFilePath, - const std::string &downloadFilePath, - const std::function& onSuccess, - const std::function& onError -) { - LOG_I(TAG, "Downloading from %s to %s", url.c_str(), downloadFilePath.c_str()); -#ifdef ESP_PLATFORM - getMainDispatcher().dispatch([url, certFilePath, downloadFilePath, onSuccess, onError] { - LOG_I(TAG, "Loading certificate"); - auto certificate = file::readString(certFilePath); - if (certificate == nullptr) { - onError("Failed to read certificate"); - return; - } - - auto certificate_length = strlen(reinterpret_cast(certificate.get())) + 1; - - // TODO: Fix for missing initializer warnings - auto config = std::make_unique(); - memset(config.get(), 0, sizeof(esp_http_client_config_t)); - config->url = url.c_str(); - config->auth_type = HTTP_AUTH_TYPE_NONE; - config->cert_pem = reinterpret_cast(certificate.get()); - config->cert_len = certificate_length; - config->tls_version = ESP_HTTP_CLIENT_TLS_VER_TLS_1_2; - config->method = HTTP_METHOD_GET; - config->timeout_ms = 5000; - config->transport_type = HTTP_TRANSPORT_OVER_SSL; - - auto client = std::make_unique(); - if (!client->init(std::move(config))) { - onError("Failed to initialize client"); - return; - } - - if (!client->open()) { - onError("Failed to open connection"); - return; - } - - if (!client->fetchHeaders()) { - onError("Failed to get request headers"); - return; - } - - if (!client->isStatusCodeOk()) { - onError("Server response is not OK"); - return; - } - - auto bytes_left = client->getContentLength(); - - LOG_I(TAG, "Opening %s", downloadFilePath.c_str()); - auto* file = fopen(downloadFilePath.c_str(), "wb"); - if (file == nullptr) { - onError("Failed to open file"); - return; - } - - LOG_I(TAG, "Writing %d bytes to %s", bytes_left, downloadFilePath.c_str()); - char buffer[512]; - while (bytes_left > 0) { - int data_read = client->read(buffer, 512); - if (data_read <= 0) { - fclose(file); - onError("Failed to read data"); - return; - } - bytes_left -= data_read; - if (fwrite(buffer, 1, data_read, file) != data_read) { - fclose(file); - onError("Failed to write all bytes"); - return; - } - taskYIELD(); - } - fclose(file); - LOG_I(TAG, "Downloaded %s to %s", url.c_str(), downloadFilePath.c_str()); - onSuccess(); - }); -#else - getMainDispatcher().dispatch([onError] { - onError("Not implemented"); - }); -#endif -} - -} diff --git a/Tactility/Tests/CMakeLists.txt b/Tactility/Tests/CMakeLists.txt index faa05a87..ca512fd8 100644 --- a/Tactility/Tests/CMakeLists.txt +++ b/Tactility/Tests/CMakeLists.txt @@ -4,25 +4,44 @@ enable_language(C CXX ASM) file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/Source/*.cpp) -add_executable(TactilityTests EXCLUDE_FROM_ALL ${TEST_SOURCES}) + +# Compile Tactility's own sources directly rather than linking the Tactility executable target. +# Main.cpp is excluded - it pulls in the device's Module/devicetree symbols, which would drag +# the whole device stack into the test binary just to get plain helpers like file/String. +file(GLOB_RECURSE TACTILITY_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/../Source/*.c*) +list(FILTER TACTILITY_SOURCES EXCLUDE REGEX ".*/Main\\.cpp$") + +add_executable(TactilityTests EXCLUDE_FROM_ALL ${TEST_SOURCES} ${TACTILITY_SOURCES}) target_include_directories(TactilityTests PRIVATE ${DOCTESTINC}) +target_include_directories(TactilityTests PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../Include) +target_include_directories(TactilityTests PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../Private) add_test(NAME TactilityTests COMMAND TactilityTests) target_link_libraries(TactilityTests PRIVATE - Tactility TactilityKernel + TactilityKernelCpp + TactilityFreeRtos platform-posix lvgl-module lvgl-window-manager-module app-module + c-symbols-module + cpp-symbols-module crypt-module + freertos-module gps-module http-module + mbedtls-module + posix-symbols-module + pthread-module gps-generic-module gps-meshtastic-module service-module + lv_screenshot + minitar lvgl + cJSON SDL2::SDL2-static SDL2-static ) diff --git a/Firmware/idf_component.yml b/Tactility/idf_component.yml similarity index 100% rename from Firmware/idf_component.yml rename to Tactility/idf_component.yml diff --git a/TactilityC/CMakeLists.txt b/TactilityC/CMakeLists.txt deleted file mode 100644 index ed6a01a5..00000000 --- a/TactilityC/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -include("${CMAKE_CURRENT_LIST_DIR}/../Buildscripts/module.cmake") - -list(APPEND REQUIRES_LIST - lvgl -) - -list(APPEND PRIV_REQUIRES_LIST - Tactility - TactilityKernel - mbedtls -) - -if (DEFINED ENV{ESP_IDF_VERSION}) - list(APPEND PRIV_REQUIRES_LIST elf_loader) -endif () - -if (IDF_TARGET STREQUAL "esp32p4") - list(APPEND PRIV_REQUIRES_LIST esp_driver_ppa esp_mm) -endif () - -file(GLOB_RECURSE SOURCE_FILES Source/*.c*) - -tactility_add_module(TactilityC - SRCS ${SOURCE_FILES} - INCLUDE_DIRS Include/ - PRIV_INCLUDE_DIRS Private/ - REQUIRES ${REQUIRES_LIST} - PRIV_REQUIRES ${PRIV_REQUIRES_LIST} -) diff --git a/TactilityC/Include/tt_app_alertdialog.h b/TactilityC/Include/tt_app_alertdialog.h deleted file mode 100644 index 6f476bdb..00000000 --- a/TactilityC/Include/tt_app_alertdialog.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * Show a dialog with the provided title, message and 0, 1 or more buttons. - * @warning AlertDialog is now a new-model app (see Modules/app-module); it delivers its result - * via APP_EVENT_RESULT to a caller's app_instance_id, which side-loaded ELF apps don't have. - * The dialog will show, but this app's onResult callback will NOT be invoked with the button - * that was pressed - there is currently no bridge back to the old ELF app result mechanism. - * @param[in] parent_id parent app ID or 0 - * @param[in] title the title to show in the toolbar - * @param[in] message the message to display - * @param[in] buttonLabels the buttons to show, or null when there are none to show - * @param[in] buttonLabelCount the amount of buttons (0 or more) - * @return the launch ID of the dialog (kept for source compatibility; no onResult will follow) - */ -AppInstanceId tt_app_alertdialog_start(AppInstanceId parent_id, const char* title, const char* message, const char* buttonLabels[], uint32_t buttonLabelCount); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/TactilityC/Include/tt_app_fileselection.h b/TactilityC/Include/tt_app_fileselection.h deleted file mode 100644 index 5916a067..00000000 --- a/TactilityC/Include/tt_app_fileselection.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Show a file selection dialog that allows the user to select an existing file. - * @return the launch ID of the dialog - */ -AppInstanceId tt_app_fileselection_start_for_existing_file(AppInstanceId app_id); - -/** - * Show a file selection dialog that allows the user to select a new or existing file. - * @return the launch ID of the dialog - */ -AppInstanceId tt_app_fileselection_start_for_existing_or_new_file(AppInstanceId app_id); - -/** - * @return the path picked by the last FileSelection dialog that closed with result == Ok (see - * tt::app::fileselection::getLastPath()). Only one dialog is expected to be open at a time. - * @param[out] buffer the buffer to store the selected path in - * @param[in] bufferSize the size of the buffer (must include room for the null terminator) - * @retval false @a bufferSize was too small - @a buffer is left untouched - * @retval true @a buffer was filled - */ -bool tt_app_fileselection_get_result_path(char* buffer, uint32_t bufferSize); - -#ifdef __cplusplus -} -#endif diff --git a/TactilityC/Include/tt_app_selectiondialog.h b/TactilityC/Include/tt_app_selectiondialog.h deleted file mode 100644 index 005409ca..00000000 --- a/TactilityC/Include/tt_app_selectiondialog.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Start an app that displays a list of items and allows the user to select one. - * @param[in] parent_id parent app ID or 0 - * @param[in] title the title to show in the toolbar - * @param[in] argc the amount of items that the list contains - * @param[in] argv the labels of the items in the list - * @return the app instance ID of the dialog, which can be compared in onResult to identify the source - */ -AppInstanceId tt_app_selectiondialog_start(AppInstanceId parent_id, const char* title, int argc, const char* argv[]); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/TactilityC/Include/tt_init.h b/TactilityC/Include/tt_init.h deleted file mode 100644 index 0439e733..00000000 --- a/TactilityC/Include/tt_init.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Initialization method for TactilityC - * @warning This is called from the main firmware. Don't call this from an external app! - */ -void tt_init_tactility_c(); - -#ifdef __cplusplus -} -#endif diff --git a/TactilityC/Private/symbols/cplusplus.h b/TactilityC/Private/symbols/cplusplus.h deleted file mode 100644 index bdead21b..00000000 --- a/TactilityC/Private/symbols/cplusplus.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym cplusplus_symbols[]; diff --git a/TactilityC/Private/symbols/esp_event.h b/TactilityC/Private/symbols/esp_event.h deleted file mode 100644 index 6136904f..00000000 --- a/TactilityC/Private/symbols/esp_event.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym esp_event_symbols[]; diff --git a/TactilityC/Private/symbols/esp_http_client.h b/TactilityC/Private/symbols/esp_http_client.h deleted file mode 100644 index 3242fafa..00000000 --- a/TactilityC/Private/symbols/esp_http_client.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym esp_http_client_symbols[]; diff --git a/TactilityC/Private/symbols/freertos.h b/TactilityC/Private/symbols/freertos.h deleted file mode 100644 index 93176a23..00000000 --- a/TactilityC/Private/symbols/freertos.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym freertos_symbols[]; diff --git a/TactilityC/Private/symbols/gcc_soft_float.h b/TactilityC/Private/symbols/gcc_soft_float.h deleted file mode 100644 index 94d675bd..00000000 --- a/TactilityC/Private/symbols/gcc_soft_float.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym gcc_soft_float_symbols[]; diff --git a/TactilityC/Private/symbols/mbedtls.h b/TactilityC/Private/symbols/mbedtls.h deleted file mode 100644 index 768c00d6..00000000 --- a/TactilityC/Private/symbols/mbedtls.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym mbedtls_symbols[]; diff --git a/TactilityC/Private/symbols/pthread.h b/TactilityC/Private/symbols/pthread.h deleted file mode 100644 index 302314ef..00000000 --- a/TactilityC/Private/symbols/pthread.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym pthread_symbols[]; diff --git a/TactilityC/Private/symbols/stl.h b/TactilityC/Private/symbols/stl.h deleted file mode 100644 index 10587020..00000000 --- a/TactilityC/Private/symbols/stl.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym stl_symbols[]; diff --git a/TactilityC/Private/symbols/string.h b/TactilityC/Private/symbols/string.h deleted file mode 100644 index e9d6a12b..00000000 --- a/TactilityC/Private/symbols/string.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern const esp_elfsym string_symbols[]; diff --git a/TactilityC/Source/symbols/cplusplus.cpp b/TactilityC/Source/symbols/cplusplus.cpp deleted file mode 100644 index f5c12acf..00000000 --- a/TactilityC/Source/symbols/cplusplus.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include - -#include - -extern "C" { - extern void* _Znwj(uint32_t size); // operator new(unsigned int) - extern void _ZdlPvj(void* p, uint64_t size); // operator delete(void*, unsigned int) - extern void __cxa_pure_virtual(); - // cxx_guards.cpp - extern int __cxa_guard_acquire(void* pg); - extern void __cxa_guard_release(void* pg) throw(); - extern void __cxa_guard_abort(void* pg) throw(); - extern void __cxa_guard_dummy(void); -} - -const esp_elfsym cplusplus_symbols[] = { - ESP_ELFSYM_EXPORT(_Znwj), // operator new(unsigned int) - ESP_ELFSYM_EXPORT(_ZdlPvj), // operator delete(void*, unsigned int) - { "_ZSt7nothrow", (void*)&std::nothrow }, - // cxx_guards - ESP_ELFSYM_EXPORT(__cxa_pure_virtual), // class-related, see https://arobenko.github.io/bare_metal_cpp/ - ESP_ELFSYM_EXPORT(__cxa_guard_acquire), - ESP_ELFSYM_EXPORT(__cxa_guard_release), - ESP_ELFSYM_EXPORT(__cxa_guard_abort), - ESP_ELFSYM_EXPORT(__cxa_guard_dummy), - // delimiter - ESP_ELFSYM_END -}; diff --git a/TactilityC/Source/symbols/esp_event.cpp b/TactilityC/Source/symbols/esp_event.cpp deleted file mode 100644 index 6be6135f..00000000 --- a/TactilityC/Source/symbols/esp_event.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -#include - -#include - -const esp_elfsym esp_event_symbols[] = { - ESP_ELFSYM_EXPORT(esp_event_loop_create), - ESP_ELFSYM_EXPORT(esp_event_loop_delete), - ESP_ELFSYM_EXPORT(esp_event_loop_create_default), - ESP_ELFSYM_EXPORT(esp_event_loop_delete_default), - ESP_ELFSYM_EXPORT(esp_event_loop_run), - ESP_ELFSYM_EXPORT(esp_event_handler_register), - ESP_ELFSYM_EXPORT(esp_event_handler_register_with), - ESP_ELFSYM_EXPORT(esp_event_handler_instance_register_with), - ESP_ELFSYM_EXPORT(esp_event_handler_instance_register), - ESP_ELFSYM_EXPORT(esp_event_handler_unregister), - ESP_ELFSYM_EXPORT(esp_event_handler_unregister_with), - ESP_ELFSYM_EXPORT(esp_event_handler_instance_unregister_with), - ESP_ELFSYM_EXPORT(esp_event_handler_instance_unregister), - ESP_ELFSYM_EXPORT(esp_event_post), - ESP_ELFSYM_EXPORT(esp_event_post_to), - ESP_ELFSYM_EXPORT(esp_event_isr_post), - ESP_ELFSYM_EXPORT(esp_event_isr_post_to), - // delimiter - ESP_ELFSYM_END -}; diff --git a/TactilityC/Source/symbols/esp_http_client.cpp b/TactilityC/Source/symbols/esp_http_client.cpp deleted file mode 100644 index 89b5791b..00000000 --- a/TactilityC/Source/symbols/esp_http_client.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -#include - -#include -#include -#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE -#include -#endif - -const esp_elfsym esp_http_client_symbols[] = { -#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE - // Needed for HTTPS: an app passes this as crt_bundle_attach to validate certificates against - // the bundle already compiled into the firmware (CONFIG_MBEDTLS_CERTIFICATE_BUNDLE). - ESP_ELFSYM_EXPORT(esp_crt_bundle_attach), -#endif - ESP_ELFSYM_EXPORT(esp_http_client_init), - ESP_ELFSYM_EXPORT(esp_http_client_perform), - ESP_ELFSYM_EXPORT(esp_http_client_cancel_request), - ESP_ELFSYM_EXPORT(esp_http_client_set_url), - ESP_ELFSYM_EXPORT(esp_http_client_set_post_field), - ESP_ELFSYM_EXPORT(esp_http_client_get_post_field), - ESP_ELFSYM_EXPORT(esp_http_client_set_header), - ESP_ELFSYM_EXPORT(esp_http_client_get_header), - ESP_ELFSYM_EXPORT(esp_http_client_get_username), - ESP_ELFSYM_EXPORT(esp_http_client_set_username), - ESP_ELFSYM_EXPORT(esp_http_client_get_password), - ESP_ELFSYM_EXPORT(esp_http_client_set_password), - ESP_ELFSYM_EXPORT(esp_http_client_cancel_request), - ESP_ELFSYM_EXPORT(esp_http_client_set_authtype), - ESP_ELFSYM_EXPORT(esp_http_client_get_user_data), - ESP_ELFSYM_EXPORT(esp_http_client_set_user_data), - ESP_ELFSYM_EXPORT(esp_http_client_get_errno), - ESP_ELFSYM_EXPORT(esp_http_client_get_and_clear_last_tls_error), - ESP_ELFSYM_EXPORT(esp_http_client_set_method), - ESP_ELFSYM_EXPORT(esp_http_client_set_timeout_ms), - ESP_ELFSYM_EXPORT(esp_http_client_delete_header), - ESP_ELFSYM_EXPORT(esp_http_client_delete_all_headers), - ESP_ELFSYM_EXPORT(esp_http_client_open), - ESP_ELFSYM_EXPORT(esp_http_client_write), - ESP_ELFSYM_EXPORT(esp_http_client_fetch_headers), - ESP_ELFSYM_EXPORT(esp_http_client_is_chunked_response), - ESP_ELFSYM_EXPORT(esp_http_client_read), - ESP_ELFSYM_EXPORT(esp_http_client_get_status_code), - ESP_ELFSYM_EXPORT(esp_http_client_get_content_length), - ESP_ELFSYM_EXPORT(esp_http_client_close), - ESP_ELFSYM_EXPORT(esp_http_client_cleanup), - ESP_ELFSYM_EXPORT(esp_http_client_get_transport_type), - ESP_ELFSYM_EXPORT(esp_http_client_set_redirection), - ESP_ELFSYM_EXPORT(esp_http_client_reset_redirect_counter), - ESP_ELFSYM_EXPORT(esp_http_client_set_auth_data), - ESP_ELFSYM_EXPORT(esp_http_client_add_auth), - ESP_ELFSYM_EXPORT(esp_http_client_is_complete_data_received), - ESP_ELFSYM_EXPORT(esp_http_client_read_response), - ESP_ELFSYM_EXPORT(esp_http_client_flush_response), - ESP_ELFSYM_EXPORT(esp_http_client_get_url), - ESP_ELFSYM_EXPORT(esp_http_client_get_chunk_length), - // delimiter - ESP_ELFSYM_END -}; diff --git a/TactilityC/Source/symbols/freertos.cpp b/TactilityC/Source/symbols/freertos.cpp deleted file mode 100644 index 26389e1a..00000000 --- a/TactilityC/Source/symbols/freertos.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -const esp_elfsym freertos_symbols[] = { - // Task - ESP_ELFSYM_EXPORT(uxTaskGetStackHighWaterMark), - ESP_ELFSYM_EXPORT(uxTaskGetNumberOfTasks), - ESP_ELFSYM_EXPORT(uxTaskGetTaskNumber), - ESP_ELFSYM_EXPORT(uxTaskPriorityGet), - ESP_ELFSYM_EXPORT(uxTaskPriorityGetFromISR), - ESP_ELFSYM_EXPORT(vTaskDelay), - ESP_ELFSYM_EXPORT(vTaskDelete), - ESP_ELFSYM_EXPORT(vTaskDeleteWithCaps), - ESP_ELFSYM_EXPORT(vTaskSetTimeOutState), - ESP_ELFSYM_EXPORT(vTaskPrioritySet), - ESP_ELFSYM_EXPORT(vTaskSetTaskNumber), - ESP_ELFSYM_EXPORT(vTaskSetThreadLocalStoragePointer), - ESP_ELFSYM_EXPORT(vTaskSetThreadLocalStoragePointerAndDelCallback), - ESP_ELFSYM_EXPORT(vTaskGetInfo), - ESP_ELFSYM_EXPORT(vTaskResume), - ESP_ELFSYM_EXPORT(vTaskSuspend), - ESP_ELFSYM_EXPORT(xTaskCreate), - ESP_ELFSYM_EXPORT(xTaskAbortDelay), - ESP_ELFSYM_EXPORT(xTaskCheckForTimeOut), - ESP_ELFSYM_EXPORT(xTaskCreatePinnedToCore), - ESP_ELFSYM_EXPORT(xTaskCreateStatic), - ESP_ELFSYM_EXPORT(xTaskCreateStaticPinnedToCore), - ESP_ELFSYM_EXPORT(xTaskCreateWithCaps), - ESP_ELFSYM_EXPORT(xTaskCreatePinnedToCoreWithCaps), - ESP_ELFSYM_EXPORT(xTaskDelayUntil), - ESP_ELFSYM_EXPORT(xTaskGenericNotify), - ESP_ELFSYM_EXPORT(xTaskGenericNotifyFromISR), - ESP_ELFSYM_EXPORT(ulTaskGenericNotifyTake), - ESP_ELFSYM_EXPORT(xTaskGetCurrentTaskHandle), - ESP_ELFSYM_EXPORT(xTaskGetTickCount), - ESP_ELFSYM_EXPORT(xTaskGetTickCountFromISR), - ESP_ELFSYM_EXPORT(pvTaskGetThreadLocalStoragePointer), - ESP_ELFSYM_EXPORT(pvTaskIncrementMutexHeldCount), - // EventGroup - ESP_ELFSYM_EXPORT(xEventGroupCreate), - ESP_ELFSYM_EXPORT(xEventGroupCreateWithCaps), - ESP_ELFSYM_EXPORT(xEventGroupCreateStatic), - ESP_ELFSYM_EXPORT(xEventGroupClearBits), - ESP_ELFSYM_EXPORT(xEventGroupClearBitsFromISR), - ESP_ELFSYM_EXPORT(vEventGroupDelete), - ESP_ELFSYM_EXPORT(xEventGroupGetStaticBuffer), - ESP_ELFSYM_EXPORT(xEventGroupGetBitsFromISR), - ESP_ELFSYM_EXPORT(xEventGroupSetBits), - ESP_ELFSYM_EXPORT(xEventGroupSetBitsFromISR), - ESP_ELFSYM_EXPORT(xEventGroupSync), - ESP_ELFSYM_EXPORT(xEventGroupWaitBits), - // Queue - ESP_ELFSYM_EXPORT(vQueueDelete), - ESP_ELFSYM_EXPORT(vQueueDeleteWithCaps), - ESP_ELFSYM_EXPORT(vQueueSetQueueNumber), - ESP_ELFSYM_EXPORT(vQueueWaitForMessageRestricted), - ESP_ELFSYM_EXPORT(uxQueueGetQueueNumber), - ESP_ELFSYM_EXPORT(uxQueueMessagesWaiting), - ESP_ELFSYM_EXPORT(uxQueueMessagesWaitingFromISR), - ESP_ELFSYM_EXPORT(uxQueueSpacesAvailable), - ESP_ELFSYM_EXPORT(xQueueCreateCountingSemaphore), - ESP_ELFSYM_EXPORT(xQueueCreateCountingSemaphoreStatic), - ESP_ELFSYM_EXPORT(xQueueCreateMutex), - ESP_ELFSYM_EXPORT(xQueueCreateMutexStatic), - ESP_ELFSYM_EXPORT(xQueueCreateSet), - ESP_ELFSYM_EXPORT(xQueueGetMutexHolder), - ESP_ELFSYM_EXPORT(xQueueGetMutexHolderFromISR), - ESP_ELFSYM_EXPORT(xQueueGiveMutexRecursive), - ESP_ELFSYM_EXPORT(xQueueTakeMutexRecursive), - ESP_ELFSYM_EXPORT(xQueueGenericCreate), - ESP_ELFSYM_EXPORT(xQueueGenericCreateStatic), - ESP_ELFSYM_EXPORT(xQueueGenericReset), - ESP_ELFSYM_EXPORT(xQueueGenericSend), - ESP_ELFSYM_EXPORT(xQueueGenericSendFromISR), - ESP_ELFSYM_EXPORT(xQueueSemaphoreTake), - ESP_ELFSYM_EXPORT(xQueueReceive), - // Timer - ESP_ELFSYM_EXPORT(pvTimerGetTimerID), - ESP_ELFSYM_EXPORT(xTimerCreate), - ESP_ELFSYM_EXPORT(xTimerCreateStatic), - ESP_ELFSYM_EXPORT(xTimerGenericCommand), - ESP_ELFSYM_EXPORT(xTimerIsTimerActive), - ESP_ELFSYM_EXPORT(xTimerGetExpiryTime), - ESP_ELFSYM_EXPORT(xTimerPendFunctionCall), - ESP_ELFSYM_EXPORT(xTimerPendFunctionCallFromISR), - ESP_ELFSYM_EXPORT(xTimerGetPeriod), - ESP_ELFSYM_EXPORT(uxTimerGetReloadMode), - ESP_ELFSYM_EXPORT(uxTimerGetTimerNumber), - ESP_ELFSYM_EXPORT(vTimerSetReloadMode), - ESP_ELFSYM_EXPORT(vTimerSetTimerID), - ESP_ELFSYM_EXPORT(vTimerSetTimerNumber), - // portmacro.h - ESP_ELFSYM_EXPORT(vPortYield), - ESP_ELFSYM_EXPORT(vPortEnterCritical), - ESP_ELFSYM_EXPORT(vPortExitCritical), -#if defined(CONFIG_IDF_TARGET_ESP32P4) || defined(CONFIG_IDF_TARGET_ESP32S3) - ESP_ELFSYM_EXPORT(xPortEnterCriticalTimeout), -#endif -#if defined(CONFIG_IDF_TARGET_ESP32P4) - ESP_ELFSYM_EXPORT(vPortExitCriticalMultiCore), -#endif - ESP_ELFSYM_EXPORT(xPortInIsrContext), - ESP_ELFSYM_EXPORT(xPortCanYield), - ESP_ELFSYM_EXPORT(xPortGetCoreID), - ESP_ELFSYM_EXPORT(xPortGetTickRateHz), - ESP_ELFSYM_EXPORT(xPortInterruptedFromISRContext), - // delimiter - ESP_ELFSYM_END -}; diff --git a/TactilityC/Source/symbols/gcc_soft_float.cpp b/TactilityC/Source/symbols/gcc_soft_float.cpp deleted file mode 100644 index 7700db74..00000000 --- a/TactilityC/Source/symbols/gcc_soft_float.cpp +++ /dev/null @@ -1,301 +0,0 @@ -#include -#ifndef CONFIG_IDF_TARGET_ESP32P4 - -#include -#include - -#include - -#include - -// Reference: https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html - -extern "C" { - -extern float __addsf3(float a, float b); -extern double __adddf3(double a, double b); -// extern long double __addtf3(long double a, long double b); -// extern long double __addxf3(long double a, long double b); - -extern float __subsf3(float a, float b); -extern double __subdf3(double a, double b); -// extern long double __subtf3(long double a, long double b); -// extern long double __subxf3(long double a, long double b); - -extern float __mulsf3(float a, float b); -extern double __muldf3(double a, double b); -// extern long double __multf3(long double a, long double b); -// extern long double __mulxf3(long double a, long double b); - -extern float __divsf3(float a, float b); -extern double __divdf3(double a, double b); -// extern long double __divtf3(long double a, long double b); -// extern long double __divxf3(long double a, long double b); - -extern float __negsf2(float a); -extern double __negdf2(double a); -// extern long double __negtf2(long double a); -// extern long double __negxf2(long double a); - -extern double __extendsfdf2(float a); -// extern long double __extendsftf2(float a); -// extern long double __extendsfxf2(float a); -// extern long double __extenddftf2(double a); -// extern long double __extenddfxf2(double a); - -// extern double __truncxfdf2(long double a); -// extern double __trunctfdf2(long double a); -// extern float __truncxfsf2(long double a); -// extern float __trunctfsf2(long double a); -extern float __truncdfsf2(double a); - -extern int __fixsfsi(float a); -extern int __fixdfsi(double a); -// extern int __fixtfsi(long double a); -// extern int __fixxfsi(long double a); - -extern long __fixsfdi(float a); -extern long __fixdfdi(double a); -// extern long __fixtfdi(long double a); -// extern long __fixxfdi(long double a); - -// extern long long __fixsfti(float a); -// extern long long __fixdfti(double a); -// extern long long __fixtfti(long double a); -// extern long long __fixxfti(long double a); - -extern unsigned int __fixunssfsi(float a); -extern unsigned int __fixunsdfsi(double a); -// extern unsigned int __fixunstfsi(long double a); -// extern unsigned int __fixunsxfsi(long double a); - -extern unsigned long __fixunssfdi(float a); -extern unsigned long __fixunsdfdi(double a); -// extern unsigned long __fixunstfdi(long double a); -// extern unsigned long __fixunsxfdi(long double a); - -// extern unsigned long long __fixunssfti(float a); -// extern unsigned long long __fixunsdfti(double a); -// extern unsigned long long __fixunstfti(long double a); -// extern unsigned long long __fixunsxfti(long double a); - -extern float __floatsisf(int i); -extern double __floatsidf(int i); -// extern long double __floatsitf(int i); -// extern long double __floatsixf(int i); - -extern float __floatdisf(long i); -extern double __floatdidf(long i); -// extern long double __floatditf(long i); -// extern long double __floatdixf(long i); - -// extern float __floattisf(long long i); -// extern double __floattidf(long long i); -// extern long double __floattitf(long long i); -// extern long double __floattixf(long long i); - -extern float __floatunsisf(unsigned int i); -extern double __floatunsidf(unsigned int i); -// extern long double __floatunsitf(unsigned int i); -// extern long double __floatunsixf(unsigned int i); - -extern float __floatundisf(unsigned long i); -extern double __floatundidf(unsigned long i); -// extern long double __floatunditf(unsigned long i); -// extern long double __floatundixf(unsigned long i); - -// extern float __floatuntisf(unsigned long long i); -// extern double __floatuntidf(unsigned long long i); -// extern long double __floatuntitf(unsigned long long i); -// extern long double __floatuntixf(unsigned long long i); - -float __powisf2(float a, int b); -double __powidf2(double a, int b); -// long double __powitf2(long double a, int b); -// long double __powixf2(long double a, int b); - -// int __cmpsf2(float a, float b); -int __cmpdf2(double a, double b); -// int __cmptf2(long double a, long double b); - -int __unordsf2(float a, float b); -int __unorddf2(double a, double b); -// int __unordtf2(long double a, long double b); - -int __eqsf2(float a, float b); -int __eqdf2(double a, double b); -// int __eqtf2(long double a, long double b); - -int __nesf2(float a, float b); -int __nedf2(double a, double b); -// int __netf2(long double a, long double b); - -int __gesf2(float a, float b); -int __gedf2(double a, double b); -// int __getf2(long double a, long double b); - -int __ltsf2(float a, float b); -int __ltdf2(double a, double b); -// int __lttf2(long double a, long double b); - -int __lesf2(float a, float b); -int __ledf2(double a, double b); -// int __letf2(long double a, long double b); - -int __gtsf2(float a, float b); -int __gtdf2(double a, double b); -// int __gttf2(long double a, long double b); - -// GCC integer arithmetic helpers (needed on 32-bit targets for 64-bit ops) -long long __divdi3(long long a, long long b); -long long __moddi3(long long a, long long b); -unsigned long long __udivdi3(unsigned long long a, unsigned long long b); -unsigned long long __umoddi3(unsigned long long a, unsigned long long b); - -} // extern "C" - -const esp_elfsym gcc_soft_float_symbols[] = { - ESP_ELFSYM_EXPORT(__addsf3), - ESP_ELFSYM_EXPORT(__adddf3), - // ESP_ELFSYM_EXPORT(__addtf3), - // ESP_ELFSYM_EXPORT(__addxf3), - - ESP_ELFSYM_EXPORT(__subsf3), - ESP_ELFSYM_EXPORT(__subdf3), - // ESP_ELFSYM_EXPORT(__subtf3), - // ESP_ELFSYM_EXPORT(__subxf3), - - ESP_ELFSYM_EXPORT(__mulsf3), - ESP_ELFSYM_EXPORT(__muldf3), - // ESP_ELFSYM_EXPORT(__multf3), - // ESP_ELFSYM_EXPORT(__mulxf3), - - ESP_ELFSYM_EXPORT(__divsf3), - ESP_ELFSYM_EXPORT(__divdf3), - // ESP_ELFSYM_EXPORT(__divtf3), - // ESP_ELFSYM_EXPORT(__divxf3), - - ESP_ELFSYM_EXPORT(__negsf2), - ESP_ELFSYM_EXPORT(__negdf2), - // ESP_ELFSYM_EXPORT(__negtf2), - // ESP_ELFSYM_EXPORT(__negxf2), - - ESP_ELFSYM_EXPORT(__extendsfdf2), - // ESP_ELFSYM_EXPORT(__extendsftf2), - // ESP_ELFSYM_EXPORT(__extendsfxf2), - // ESP_ELFSYM_EXPORT(__extenddftf2), - // ESP_ELFSYM_EXPORT(__extenddfxf2), - - // ESP_ELFSYM_EXPORT(__truncxfdf2), - // ESP_ELFSYM_EXPORT(__trunctfdf2), - // ESP_ELFSYM_EXPORT(__truncxfsf2), - // ESP_ELFSYM_EXPORT(__trunctfsf2), - ESP_ELFSYM_EXPORT(__truncdfsf2), - - ESP_ELFSYM_EXPORT(__fixsfsi), - ESP_ELFSYM_EXPORT(__fixdfsi), - // ESP_ELFSYM_EXPORT(__fixtfsi), - // ESP_ELFSYM_EXPORT(__fixxfsi), - - ESP_ELFSYM_EXPORT(__fixsfdi), - ESP_ELFSYM_EXPORT(__fixdfdi), - // ESP_ELFSYM_EXPORT(__fixtfdi), - // ESP_ELFSYM_EXPORT(__fixxfdi), - - // ESP_ELFSYM_EXPORT(__fixsfti), - // ESP_ELFSYM_EXPORT(__fixdfti), - // ESP_ELFSYM_EXPORT(__fixtfti), - // ESP_ELFSYM_EXPORT(__fixxfti), - - ESP_ELFSYM_EXPORT(__fixunssfsi), - ESP_ELFSYM_EXPORT(__fixunsdfsi), - // ESP_ELFSYM_EXPORT(__fixunstfsi), - // ESP_ELFSYM_EXPORT(__fixunsxfsi), - - ESP_ELFSYM_EXPORT(__fixunssfdi), - ESP_ELFSYM_EXPORT(__fixunsdfdi), - // ESP_ELFSYM_EXPORT(__fixunstfdi), - // ESP_ELFSYM_EXPORT(__fixunsxfdi), - - // ESP_ELFSYM_EXPORT(__fixunssfti), - // ESP_ELFSYM_EXPORT(__fixunsdfti), - // ESP_ELFSYM_EXPORT(__fixunstfti), - // ESP_ELFSYM_EXPORT(__fixunsxfti), - - ESP_ELFSYM_EXPORT(__floatsisf), - ESP_ELFSYM_EXPORT(__floatsidf), - // ESP_ELFSYM_EXPORT(__floatsitf), - // ESP_ELFSYM_EXPORT(__floatsixf), - - ESP_ELFSYM_EXPORT(__floatdisf), - ESP_ELFSYM_EXPORT(__floatdidf), - // ESP_ELFSYM_EXPORT(__floatditf), - // ESP_ELFSYM_EXPORT(__floatdixf), - - // ESP_ELFSYM_EXPORT(__floattisf), - // ESP_ELFSYM_EXPORT(__floattidf), - // ESP_ELFSYM_EXPORT(__floattitf), - // ESP_ELFSYM_EXPORT(__floattixf), - - ESP_ELFSYM_EXPORT(__floatunsisf), - ESP_ELFSYM_EXPORT(__floatunsidf), - // ESP_ELFSYM_EXPORT(__floatunsitf), - // ESP_ELFSYM_EXPORT(__floatunsixf), - - ESP_ELFSYM_EXPORT(__floatundisf), - ESP_ELFSYM_EXPORT(__floatundidf), - // ESP_ELFSYM_EXPORT(__floatunditf), - // ESP_ELFSYM_EXPORT(__floatundixf), - - // ESP_ELFSYM_EXPORT(__floatuntisf), - // ESP_ELFSYM_EXPORT(__floatuntidf), - // ESP_ELFSYM_EXPORT(__floatuntitf), - // ESP_ELFSYM_EXPORT(__floatuntixf), - - ESP_ELFSYM_EXPORT(__powisf2), - ESP_ELFSYM_EXPORT(__powidf2), - // ESP_ELFSYM_EXPORT(__powitf2), - // ESP_ELFSYM_EXPORT(__powixf2), - - // ESP_ELFSYM_EXPORT(__cmpsf2), - // ESP_ELFSYM_EXPORT(__cmpdf2), - // ESP_ELFSYM_EXPORT(__cmptf2), - - ESP_ELFSYM_EXPORT(__unordsf2), - ESP_ELFSYM_EXPORT(__unorddf2), - // ESP_ELFSYM_EXPORT(__unordtf2), - - ESP_ELFSYM_EXPORT(__eqsf2), - ESP_ELFSYM_EXPORT(__eqdf2), - // ESP_ELFSYM_EXPORT(__eqtf2), - - ESP_ELFSYM_EXPORT(__nesf2), - ESP_ELFSYM_EXPORT(__nedf2), - // ESP_ELFSYM_EXPORT(__netf2), - - ESP_ELFSYM_EXPORT(__gesf2), - ESP_ELFSYM_EXPORT(__gedf2), - // ESP_ELFSYM_EXPORT(__getf2), - - ESP_ELFSYM_EXPORT(__ltsf2), - ESP_ELFSYM_EXPORT(__ltdf2), - // ESP_ELFSYM_EXPORT(__lttf2), - - ESP_ELFSYM_EXPORT(__lesf2), - ESP_ELFSYM_EXPORT(__ledf2), - // ESP_ELFSYM_EXPORT(__letf2), - - ESP_ELFSYM_EXPORT(__gtsf2), - ESP_ELFSYM_EXPORT(__gtdf2), - // ESP_ELFSYM_EXPORT(__gttf2), - - // GCC integer arithmetic helpers - ESP_ELFSYM_EXPORT(__divdi3), - ESP_ELFSYM_EXPORT(__moddi3), - ESP_ELFSYM_EXPORT(__udivdi3), - ESP_ELFSYM_EXPORT(__umoddi3), - - ESP_ELFSYM_END -}; - -#endif \ No newline at end of file diff --git a/TactilityC/Source/symbols/gcc_soft_float_p4.cpp b/TactilityC/Source/symbols/gcc_soft_float_p4.cpp deleted file mode 100644 index 4c6fab1f..00000000 --- a/TactilityC/Source/symbols/gcc_soft_float_p4.cpp +++ /dev/null @@ -1,275 +0,0 @@ -#include -#ifdef CONFIG_IDF_TARGET_ESP32P4 - -#include -#include - -#include - -#include - -// Reference: https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html - -extern "C" { - -extern double __adddf3(double a, double b); -// extern long double __addtf3(long double a, long double b); -// extern long double __addxf3(long double a, long double b); - -extern double __subdf3(double a, double b); -// extern long double __subtf3(long double a, long double b); -// extern long double __subxf3(long double a, long double b); - -extern double __muldf3(double a, double b); -// extern long double __multf3(long double a, long double b); -// extern long double __mulxf3(long double a, long double b); - -extern double __divdf3(double a, double b); -// extern long double __divtf3(long double a, long double b); -// extern long double __divxf3(long double a, long double b); - -extern double __negdf2(double a); -// extern long double __negtf2(long double a); -// extern long double __negxf2(long double a); - -extern double __extendsfdf2(float a); - -// extern long double __extendsftf2(float a); -// extern long double __extendsfxf2(float a); -// extern long double __extenddftf2(double a); -// extern long double __extenddfxf2(double a); - -// extern double __truncxfdf2(long double a); -// extern double __trunctfdf2(long double a); -// extern float __truncxfsf2(long double a); -// extern float __trunctfsf2(long double a); -extern float __truncdfsf2(double a); - -extern int __fixdfsi(double a); -// extern int __fixtfsi(long double a); -// extern int __fixxfsi(long double a); - -extern long __fixdfdi(double a); -// extern long __fixtfdi(long double a); -// extern long __fixxfdi(long double a); - -// extern long long __fixsfti(float a); -// extern long long __fixdfti(double a); -// extern long long __fixtfti(long double a); -// extern long long __fixxfti(long double a); - -// extern unsigned int __fixunssfsi(float a); -extern unsigned int __fixunsdfsi(double a); -// extern unsigned int __fixunstfsi(long double a); -// extern unsigned int __fixunsxfsi(long double a); - -extern unsigned long __fixunssfdi(float a); -extern unsigned long __fixunsdfdi(double a); -// extern unsigned long __fixunstfdi(long double a); -// extern unsigned long __fixunsxfdi(long double a); - -// extern unsigned long long __fixunssfti(float a); -// extern unsigned long long __fixunsdfti(double a); -// extern unsigned long long __fixunstfti(long double a); -// extern unsigned long long __fixunsxfti(long double a); - -// extern float __floatsisf(int i); -extern double __floatsidf(int i); -// extern long double __floatsitf(int i); -// extern long double __floatsixf(int i); - -extern float __floatdisf(long i); -extern double __floatdidf(long i); -// extern long double __floatditf(long i); -// extern long double __floatdixf(long i); - -// extern float __floattisf(long long i); -// extern double __floattidf(long long i); -// extern long double __floattitf(long long i); -// extern long double __floattixf(long long i); - -extern double __floatunsidf(unsigned int i); -// extern long double __floatunsitf(unsigned int i); -// extern long double __floatunsixf(unsigned int i); - -extern float __floatundisf(unsigned long i); -extern double __floatundidf(unsigned long i); -// extern long double __floatunditf(unsigned long i); -// extern long double __floatundixf(unsigned long i); - -// extern float __floatuntisf(unsigned long long i); -// extern double __floatuntidf(unsigned long long i); -// extern long double __floatuntitf(unsigned long long i); -// extern long double __floatuntixf(unsigned long long i); - -float __powisf2(float a, int b); -double __powidf2(double a, int b); -// long double __powitf2(long double a, int b); -// long double __powixf2(long double a, int b); - -// int __cmpsf2(float a, float b); -int __cmpdf2(double a, double b); -// int __cmptf2(long double a, long double b); - -int __unorddf2(double a, double b); -// int __unordtf2(long double a, long double b); - -int __eqdf2(double a, double b); -// int __eqtf2(long double a, long double b); - -int __nedf2(double a, double b); -// int __netf2(long double a, long double b); - -int __gedf2(double a, double b); -// int __getf2(long double a, long double b); - -int __ltdf2(double a, double b); -// int __lttf2(long double a, long double b); - -int __ledf2(double a, double b); -// int __letf2(long double a, long double b); - -int __gtdf2(double a, double b); -// int __gttf2(long double a, long double b); - -// GCC integer/bitwise helpers (compiler-rt) -int __clzsi2(unsigned int x); - -// GCC 64-bit integer arithmetic helpers (needed for 64-bit div on 32-bit RISC-V) -long long __divdi3(long long a, long long b); -unsigned long long __udivdi3(unsigned long long a, unsigned long long b); - -} // extern "C" - -const esp_elfsym gcc_soft_float_symbols[] = { - ESP_ELFSYM_EXPORT(__adddf3), - // ESP_ELFSYM_EXPORT(__addtf3), - // ESP_ELFSYM_EXPORT(__addxf3), - - ESP_ELFSYM_EXPORT(__subdf3), - // ESP_ELFSYM_EXPORT(__subtf3), - // ESP_ELFSYM_EXPORT(__subxf3), - - ESP_ELFSYM_EXPORT(__muldf3), - // ESP_ELFSYM_EXPORT(__multf3), - // ESP_ELFSYM_EXPORT(__mulxf3), - - ESP_ELFSYM_EXPORT(__divdf3), - // ESP_ELFSYM_EXPORT(__divtf3), - // ESP_ELFSYM_EXPORT(__divxf3), - - ESP_ELFSYM_EXPORT(__negdf2), - // ESP_ELFSYM_EXPORT(__negtf2), - // ESP_ELFSYM_EXPORT(__negxf2), - - ESP_ELFSYM_EXPORT(__extendsfdf2), - - // ESP_ELFSYM_EXPORT(__extendsftf2), - // ESP_ELFSYM_EXPORT(__extendsfxf2), - // ESP_ELFSYM_EXPORT(__extenddftf2), - // ESP_ELFSYM_EXPORT(__extenddfxf2), - - // ESP_ELFSYM_EXPORT(__truncxfdf2), - // ESP_ELFSYM_EXPORT(__trunctfdf2), - // ESP_ELFSYM_EXPORT(__truncxfsf2), - // ESP_ELFSYM_EXPORT(__trunctfsf2), - ESP_ELFSYM_EXPORT(__truncdfsf2), - - ESP_ELFSYM_EXPORT(__fixdfsi), - // ESP_ELFSYM_EXPORT(__fixtfsi), - // ESP_ELFSYM_EXPORT(__fixxfsi), - - ESP_ELFSYM_EXPORT(__fixdfdi), - // ESP_ELFSYM_EXPORT(__fixtfdi), - // ESP_ELFSYM_EXPORT(__fixxfdi), - - // ESP_ELFSYM_EXPORT(__fixsfti), - // ESP_ELFSYM_EXPORT(__fixdfti), - // ESP_ELFSYM_EXPORT(__fixtfti), - // ESP_ELFSYM_EXPORT(__fixxfti), - - // ESP_ELFSYM_EXPORT(__fixunssfsi), - ESP_ELFSYM_EXPORT(__fixunsdfsi), - // ESP_ELFSYM_EXPORT(__fixunstfsi), - // ESP_ELFSYM_EXPORT(__fixunsxfsi), - - ESP_ELFSYM_EXPORT(__fixunssfdi), - ESP_ELFSYM_EXPORT(__fixunsdfdi), - // ESP_ELFSYM_EXPORT(__fixunstfdi), - // ESP_ELFSYM_EXPORT(__fixunsxfdi), - - // ESP_ELFSYM_EXPORT(__fixunssfti), - // ESP_ELFSYM_EXPORT(__fixunsdfti), - // ESP_ELFSYM_EXPORT(__fixunstfti), - // ESP_ELFSYM_EXPORT(__fixunsxfti), - - // ESP_ELFSYM_EXPORT(__floatsisf), - ESP_ELFSYM_EXPORT(__floatsidf), - // ESP_ELFSYM_EXPORT(__floatsitf), - // ESP_ELFSYM_EXPORT(__floatsixf), - - ESP_ELFSYM_EXPORT(__floatdisf), - ESP_ELFSYM_EXPORT(__floatdidf), - // ESP_ELFSYM_EXPORT(__floatditf), - // ESP_ELFSYM_EXPORT(__floatdixf), - - // ESP_ELFSYM_EXPORT(__floattisf), - // ESP_ELFSYM_EXPORT(__floattidf), - // ESP_ELFSYM_EXPORT(__floattitf), - // ESP_ELFSYM_EXPORT(__floattixf), - - ESP_ELFSYM_EXPORT(__floatunsidf), - // ESP_ELFSYM_EXPORT(__floatunsitf), - // ESP_ELFSYM_EXPORT(__floatunsixf), - - ESP_ELFSYM_EXPORT(__floatundisf), - ESP_ELFSYM_EXPORT(__floatundidf), - // ESP_ELFSYM_EXPORT(__floatunditf), - // ESP_ELFSYM_EXPORT(__floatundixf), - - // ESP_ELFSYM_EXPORT(__floatuntisf), - // ESP_ELFSYM_EXPORT(__floatuntidf), - // ESP_ELFSYM_EXPORT(__floatuntitf), - // ESP_ELFSYM_EXPORT(__floatuntixf), - - ESP_ELFSYM_EXPORT(__powisf2), - ESP_ELFSYM_EXPORT(__powidf2), - // ESP_ELFSYM_EXPORT(__powitf2), - // ESP_ELFSYM_EXPORT(__powixf2), - - // ESP_ELFSYM_EXPORT(__cmpsf2), - // ESP_ELFSYM_EXPORT(__cmpdf2), - // ESP_ELFSYM_EXPORT(__cmptf2), - - ESP_ELFSYM_EXPORT(__unorddf2), - // ESP_ELFSYM_EXPORT(__unordtf2), - - ESP_ELFSYM_EXPORT(__eqdf2), - // ESP_ELFSYM_EXPORT(__eqtf2), - - ESP_ELFSYM_EXPORT(__nedf2), - // ESP_ELFSYM_EXPORT(__netf2), - - ESP_ELFSYM_EXPORT(__gedf2), - // ESP_ELFSYM_EXPORT(__getf2), - - ESP_ELFSYM_EXPORT(__ltdf2), - // ESP_ELFSYM_EXPORT(__lttf2), - - ESP_ELFSYM_EXPORT(__ledf2), - // ESP_ELFSYM_EXPORT(__letf2), - - ESP_ELFSYM_EXPORT(__gtdf2), - // ESP_ELFSYM_EXPORT(__gttf2), - - // GCC integer/bitwise helpers - ESP_ELFSYM_EXPORT(__clzsi2), - - // GCC 64-bit integer arithmetic helpers - ESP_ELFSYM_EXPORT(__divdi3), - ESP_ELFSYM_EXPORT(__udivdi3), - - ESP_ELFSYM_END -}; - -#endif \ No newline at end of file diff --git a/TactilityC/Source/symbols/mbedtls.cpp b/TactilityC/Source/symbols/mbedtls.cpp deleted file mode 100644 index 17cdf224..00000000 --- a/TactilityC/Source/symbols/mbedtls.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -const esp_elfsym mbedtls_symbols[] = { - // CTR_DRBG (random number generation) - ESP_ELFSYM_EXPORT(mbedtls_ctr_drbg_init), - ESP_ELFSYM_EXPORT(mbedtls_ctr_drbg_free), - ESP_ELFSYM_EXPORT(mbedtls_ctr_drbg_seed), - ESP_ELFSYM_EXPORT(mbedtls_ctr_drbg_random), - // Entropy - ESP_ELFSYM_EXPORT(mbedtls_entropy_init), - ESP_ELFSYM_EXPORT(mbedtls_entropy_free), - ESP_ELFSYM_EXPORT(mbedtls_entropy_func), - // Cipher - ESP_ELFSYM_EXPORT(mbedtls_cipher_init), - ESP_ELFSYM_EXPORT(mbedtls_cipher_free), - ESP_ELFSYM_EXPORT(mbedtls_cipher_setup), - ESP_ELFSYM_EXPORT(mbedtls_cipher_setkey), - ESP_ELFSYM_EXPORT(mbedtls_cipher_set_iv), - ESP_ELFSYM_EXPORT(mbedtls_cipher_reset), - ESP_ELFSYM_EXPORT(mbedtls_cipher_update), - ESP_ELFSYM_EXPORT(mbedtls_cipher_finish), - ESP_ELFSYM_EXPORT(mbedtls_cipher_get_block_size), - ESP_ELFSYM_EXPORT(mbedtls_cipher_info_from_type), - // Message digest / HMAC - ESP_ELFSYM_EXPORT(mbedtls_md), - ESP_ELFSYM_EXPORT(mbedtls_md_init), - ESP_ELFSYM_EXPORT(mbedtls_md_free), - ESP_ELFSYM_EXPORT(mbedtls_md_setup), - ESP_ELFSYM_EXPORT(mbedtls_md_starts), - ESP_ELFSYM_EXPORT(mbedtls_md_update), - ESP_ELFSYM_EXPORT(mbedtls_md_finish), - ESP_ELFSYM_EXPORT(mbedtls_md_hmac_starts), - ESP_ELFSYM_EXPORT(mbedtls_md_hmac_update), - ESP_ELFSYM_EXPORT(mbedtls_md_hmac_finish), - ESP_ELFSYM_EXPORT(mbedtls_md_info_from_type), - // Bignum (MPI) - ESP_ELFSYM_EXPORT(mbedtls_mpi_init), - ESP_ELFSYM_EXPORT(mbedtls_mpi_free), - ESP_ELFSYM_EXPORT(mbedtls_mpi_read_binary), - ESP_ELFSYM_EXPORT(mbedtls_mpi_write_binary), - ESP_ELFSYM_EXPORT(mbedtls_mpi_size), - ESP_ELFSYM_EXPORT(mbedtls_mpi_bitlen), - ESP_ELFSYM_EXPORT(mbedtls_mpi_lset), - ESP_ELFSYM_EXPORT(mbedtls_mpi_set_bit), - ESP_ELFSYM_EXPORT(mbedtls_mpi_fill_random), - ESP_ELFSYM_EXPORT(mbedtls_mpi_exp_mod), - // RSA - ESP_ELFSYM_EXPORT(mbedtls_rsa_init), - ESP_ELFSYM_EXPORT(mbedtls_rsa_free), - ESP_ELFSYM_EXPORT(mbedtls_rsa_copy), - ESP_ELFSYM_EXPORT(mbedtls_rsa_get_len), - ESP_ELFSYM_EXPORT(mbedtls_rsa_check_pubkey), - ESP_ELFSYM_EXPORT(mbedtls_rsa_check_privkey), - ESP_ELFSYM_EXPORT(mbedtls_rsa_pkcs1_sign), - ESP_ELFSYM_EXPORT(mbedtls_rsa_pkcs1_verify), - // Public key abstraction - ESP_ELFSYM_EXPORT(mbedtls_pk_init), - ESP_ELFSYM_EXPORT(mbedtls_pk_free), - ESP_ELFSYM_EXPORT(mbedtls_pk_get_type), - ESP_ELFSYM_EXPORT(mbedtls_pk_parse_key), - ESP_ELFSYM_EXPORT(mbedtls_pk_parse_keyfile), - // ECP (elliptic curves) - ESP_ELFSYM_EXPORT(mbedtls_ecp_group_load), - ESP_ELFSYM_EXPORT(mbedtls_ecp_point_init), - ESP_ELFSYM_EXPORT(mbedtls_ecp_point_free), - ESP_ELFSYM_EXPORT(mbedtls_ecp_point_read_binary), - ESP_ELFSYM_EXPORT(mbedtls_ecp_point_write_binary), - ESP_ELFSYM_EXPORT(mbedtls_ecp_check_pubkey), - ESP_ELFSYM_EXPORT(mbedtls_ecp_check_privkey), - ESP_ELFSYM_EXPORT(mbedtls_ecp_mul), - // ECDSA - ESP_ELFSYM_EXPORT(mbedtls_ecdsa_init), - ESP_ELFSYM_EXPORT(mbedtls_ecdsa_free), - ESP_ELFSYM_EXPORT(mbedtls_ecdsa_genkey), - ESP_ELFSYM_EXPORT(mbedtls_ecdsa_from_keypair), - ESP_ELFSYM_EXPORT(mbedtls_ecdsa_sign), - ESP_ELFSYM_EXPORT(mbedtls_ecdsa_verify), - // ECDH - ESP_ELFSYM_EXPORT(mbedtls_ecdh_compute_shared), - // Error strings - ESP_ELFSYM_EXPORT(mbedtls_strerror), - // delimiter - ESP_ELFSYM_END -}; diff --git a/TactilityC/Source/symbols/pthread.cpp b/TactilityC/Source/symbols/pthread.cpp deleted file mode 100644 index 45e842c3..00000000 --- a/TactilityC/Source/symbols/pthread.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#include - -#include - -const esp_elfsym pthread_symbols[] = { - ESP_ELFSYM_EXPORT(pthread_create), - ESP_ELFSYM_EXPORT(pthread_attr_init), - ESP_ELFSYM_EXPORT(pthread_attr_setstacksize), - ESP_ELFSYM_EXPORT(pthread_detach), - ESP_ELFSYM_EXPORT(pthread_join), - ESP_ELFSYM_EXPORT(pthread_exit), - ESP_ELFSYM_EXPORT(pthread_mutex_init), - ESP_ELFSYM_EXPORT(pthread_mutex_destroy), - ESP_ELFSYM_EXPORT(pthread_mutex_lock), - ESP_ELFSYM_EXPORT(pthread_mutex_trylock), - ESP_ELFSYM_EXPORT(pthread_mutex_unlock), - ESP_ELFSYM_EXPORT(pthread_mutex_timedlock), - // delimiter - ESP_ELFSYM_END -}; diff --git a/TactilityC/Source/symbols/stl.cpp b/TactilityC/Source/symbols/stl.cpp deleted file mode 100644 index 7def89d3..00000000 --- a/TactilityC/Source/symbols/stl.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -#include - -#include - -#include - -extern "C" { - -// std::map / std::set red-black tree non-template helpers. -// We use the mangled names directly (same pattern as string.cpp) to avoid -// ambiguity from the overloaded const/non-const variants in stl_tree.h. -void* _ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base(void*); -void* _ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base(void*); -void _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_(bool, void*, void*, void*); - -} - -const esp_elfsym stl_symbols[] = { - // Note: You have to use the mangled names here - { "_ZSt17__throw_bad_allocv", (void*)&(std::__throw_bad_alloc) }, - { "_ZSt28__throw_bad_array_new_lengthv", (void*)&(std::__throw_bad_array_new_length) }, - { "_ZSt25__throw_bad_function_callv", (void*)&(std::__throw_bad_function_call) }, - { "_ZSt20__throw_length_errorPKc", (void*)&(std::__throw_length_error) }, - { "_ZSt19__throw_logic_errorPKc", (void*)&std::__throw_logic_error }, - { "_ZSt24__throw_out_of_range_fmtPKcz", (void*)&std::__throw_out_of_range_fmt }, - { "_ZSt20__throw_system_errori", (void*)&std::__throw_system_error }, - // std::map / std::set (red-black tree internals) - DEFINE_MODULE_SYMBOL(_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base), - DEFINE_MODULE_SYMBOL(_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base), - DEFINE_MODULE_SYMBOL(_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_), - // delimiter - ESP_ELFSYM_END -}; diff --git a/TactilityC/Source/symbols/string.cpp b/TactilityC/Source/symbols/string.cpp deleted file mode 100644 index f560855c..00000000 --- a/TactilityC/Source/symbols/string.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -#include - -extern "C" void _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE15_M_replace_coldEPcjPKcjj(void*, char*, unsigned int, char const*, unsigned int, unsigned int); - -const esp_elfsym string_symbols[] = { - // Note: You have to use the mangled names here - { "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE15_M_replace_coldEPcjPKcjj", (void*)&_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE15_M_replace_coldEPcjPKcjj}, - // { "", (void*)&(std::) }, - // delimiter - ESP_ELFSYM_END -}; diff --git a/TactilityC/Source/tt_app_alertdialog.cpp b/TactilityC/Source/tt_app_alertdialog.cpp deleted file mode 100644 index 63cb6084..00000000 --- a/TactilityC/Source/tt_app_alertdialog.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "tt_app_alertdialog.h" - -#include - -extern "C" { - -AppInstanceId tt_app_alertdialog_start(AppInstanceId parent_id, const char* title, const char* message, const char* buttonLabels[], uint32_t buttonLabelCount) { - std::vector list; - for (int i = 0; i < buttonLabelCount; i++) { - list.emplace_back(buttonLabels[i]); - } - // TODO: Get caller app instance id from task context? - return tt::app::alertdialog::start(parent_id, title, message, list); -} - -} diff --git a/TactilityC/Source/tt_app_fileselection.cpp b/TactilityC/Source/tt_app_fileselection.cpp deleted file mode 100644 index 7a8e64c4..00000000 --- a/TactilityC/Source/tt_app_fileselection.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "tt_app_fileselection.h" -#include - -#include -#include - -extern "C" { - -AppInstanceId tt_app_fileselection_start_for_existing_file(AppInstanceId app_id) { - return tt::app::fileselection::startForExistingFile(app_id); -} - -AppInstanceId tt_app_fileselection_start_for_existing_or_new_file(AppInstanceId app_id) { - return tt::app::fileselection::startForExistingOrNewFile(app_id); -} - -bool tt_app_fileselection_get_result_path(char* buffer, uint32_t bufferSize) { - const std::string path = tt::app::fileselection::getLastPath(); - if (path.length() + 1 > bufferSize) { - return false; - } - std::strcpy(buffer, path.c_str()); - return true; -} - -} diff --git a/TactilityC/Source/tt_app_selectiondialog.cpp b/TactilityC/Source/tt_app_selectiondialog.cpp deleted file mode 100644 index 73b91d88..00000000 --- a/TactilityC/Source/tt_app_selectiondialog.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "tt_app_selectiondialog.h" -#include - -extern "C" { - -AppInstanceId tt_app_selectiondialog_start(AppInstanceId parent_id, const char* title, int argc, const char* argv[]) { - std::vector list; - for (int i = 0; i < argc; i++) { - list.emplace_back(argv[i]); - } - return tt::app::selectiondialog::start(parent_id, title, list); -} - -} diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp deleted file mode 100644 index 533d057e..00000000 --- a/TactilityC/Source/tt_init.cpp +++ /dev/null @@ -1,471 +0,0 @@ -#ifdef ESP_PLATFORM - -#include "tt_app_alertdialog.h" -#include "tt_app_fileselection.h" -#include "tt_app_selectiondialog.h" - -#include "symbols/cplusplus.h" -#include "symbols/esp_event.h" -#include "symbols/esp_http_client.h" -#include "symbols/freertos.h" -#include "symbols/gcc_soft_float.h" -#include "symbols/mbedtls.h" -#include "symbols/pthread.h" -#include "symbols/stl.h" -#include "symbols/string.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#ifdef CONFIG_IDF_TARGET_ESP32P4 -#include -#include -#endif - -extern "C" { - -extern double __floatsidf(int x); -extern void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression); - -const esp_elfsym main_symbols[] { - // stdlib.h - ESP_ELFSYM_EXPORT(malloc), - ESP_ELFSYM_EXPORT(calloc), - ESP_ELFSYM_EXPORT(realloc), - ESP_ELFSYM_EXPORT(free), - ESP_ELFSYM_EXPORT(rand), - ESP_ELFSYM_EXPORT(srand), - ESP_ELFSYM_EXPORT(rand_r), - ESP_ELFSYM_EXPORT(atof), - ESP_ELFSYM_EXPORT(atoi), - ESP_ELFSYM_EXPORT(atol), - ESP_ELFSYM_EXPORT(system), - // esp random - ESP_ELFSYM_EXPORT(esp_random), - ESP_ELFSYM_EXPORT(esp_fill_random), - // esp other - ESP_ELFSYM_EXPORT(__floatsidf), - ESP_ELFSYM_EXPORT(_esp_error_check_failed), - // unistd.h - ESP_ELFSYM_EXPORT(usleep), - ESP_ELFSYM_EXPORT(sleep), - ESP_ELFSYM_EXPORT(exit), - ESP_ELFSYM_EXPORT(close), - ESP_ELFSYM_EXPORT(rmdir), - ESP_ELFSYM_EXPORT(unlink), - ESP_ELFSYM_EXPORT(open), - // strings.h - ESP_ELFSYM_EXPORT(explicit_bzero), - ESP_ELFSYM_EXPORT(strcasecmp), - ESP_ELFSYM_EXPORT(strncasecmp), - // time.h - ESP_ELFSYM_EXPORT(clock_gettime), - ESP_ELFSYM_EXPORT(strftime), - ESP_ELFSYM_EXPORT(time), - ESP_ELFSYM_EXPORT(difftime), - ESP_ELFSYM_EXPORT(localtime_r), - ESP_ELFSYM_EXPORT(localtime), - ESP_ELFSYM_EXPORT(mktime), - // esp_sntp.h - ESP_ELFSYM_EXPORT(sntp_get_sync_status), - // math.h - ESP_ELFSYM_EXPORT(acos), - ESP_ELFSYM_EXPORT(acoshf), - ESP_ELFSYM_EXPORT(acosf), - ESP_ELFSYM_EXPORT(asin), - ESP_ELFSYM_EXPORT(asinhf), - ESP_ELFSYM_EXPORT(asinf), - ESP_ELFSYM_EXPORT(atan), - ESP_ELFSYM_EXPORT(atanhf), - ESP_ELFSYM_EXPORT(atanf), - ESP_ELFSYM_EXPORT(cos), - ESP_ELFSYM_EXPORT(coshf), - ESP_ELFSYM_EXPORT(cosf), - ESP_ELFSYM_EXPORT(sin), - ESP_ELFSYM_EXPORT(sinhf), - ESP_ELFSYM_EXPORT(sinf), - ESP_ELFSYM_EXPORT(tan), - ESP_ELFSYM_EXPORT(tanhf), - ESP_ELFSYM_EXPORT(tanf), - ESP_ELFSYM_EXPORT(frexp), - ESP_ELFSYM_EXPORT(frexpf), - ESP_ELFSYM_EXPORT(modf), - ESP_ELFSYM_EXPORT(modff), - ESP_ELFSYM_EXPORT(ceil), - ESP_ELFSYM_EXPORT(ceilf), - ESP_ELFSYM_EXPORT(fabs), - ESP_ELFSYM_EXPORT(fabsf), - ESP_ELFSYM_EXPORT(floor), - ESP_ELFSYM_EXPORT(floorf), - ESP_ELFSYM_EXPORT(fmax), - ESP_ELFSYM_EXPORT(fmaxf), - ESP_ELFSYM_EXPORT(fmin), - ESP_ELFSYM_EXPORT(fminf), - ESP_ELFSYM_EXPORT(round), - ESP_ELFSYM_EXPORT(roundf), -#ifndef _REENT_ONLY - ESP_ELFSYM_EXPORT(acos), - ESP_ELFSYM_EXPORT(acosf), - ESP_ELFSYM_EXPORT(asin), - ESP_ELFSYM_EXPORT(asinf), - ESP_ELFSYM_EXPORT(atan2), - ESP_ELFSYM_EXPORT(atan2f), - ESP_ELFSYM_EXPORT(sinh), - ESP_ELFSYM_EXPORT(sinhf), - ESP_ELFSYM_EXPORT(exp), - ESP_ELFSYM_EXPORT(expf), - ESP_ELFSYM_EXPORT(ldexp), - ESP_ELFSYM_EXPORT(ldexpf), - ESP_ELFSYM_EXPORT(log), - ESP_ELFSYM_EXPORT(logf), - ESP_ELFSYM_EXPORT(log10), - ESP_ELFSYM_EXPORT(log10f), - ESP_ELFSYM_EXPORT(pow), - ESP_ELFSYM_EXPORT(powf), - ESP_ELFSYM_EXPORT(sqrt), - ESP_ELFSYM_EXPORT(sqrtf), - ESP_ELFSYM_EXPORT(fmod), - ESP_ELFSYM_EXPORT(fmodf), -#endif - // sys/errno.h - ESP_ELFSYM_EXPORT(__errno), - // freertos_tasks_c_additions.h - ESP_ELFSYM_EXPORT(__getreent), -#ifdef __HAVE_LOCALE_INFO__ - // ctype.h - ESP_ELFSYM_EXPORT(__locale_ctype_ptr), -#else - ESP_ELFSYM_EXPORT(_ctype_), -#endif - // getopt.h - ESP_ELFSYM_EXPORT(getopt_long), - ESP_ELFSYM_EXPORT(optind), - ESP_ELFSYM_EXPORT(opterr), - ESP_ELFSYM_EXPORT(optarg), - ESP_ELFSYM_EXPORT(optopt), - // setjmp.h - ESP_ELFSYM_EXPORT(longjmp), - ESP_ELFSYM_EXPORT(setjmp), - // cassert - ESP_ELFSYM_EXPORT(__assert_func), - // cstdio - ESP_ELFSYM_EXPORT(abort), - ESP_ELFSYM_EXPORT(fclose), - ESP_ELFSYM_EXPORT(feof), - ESP_ELFSYM_EXPORT(ferror), - ESP_ELFSYM_EXPORT(fflush), - ESP_ELFSYM_EXPORT(fgetc), - ESP_ELFSYM_EXPORT(fgetpos), - ESP_ELFSYM_EXPORT(fgets), - ESP_ELFSYM_EXPORT(fopen), - ESP_ELFSYM_EXPORT(freopen), - // Lets an app find the descriptor behind a stream. Needed when stdin/stdout have been pointed - // somewhere other than descriptors 0 and 1, which is the case for an app that owns a terminal. - ESP_ELFSYM_EXPORT(fileno), - ESP_ELFSYM_EXPORT(setvbuf), - ESP_ELFSYM_EXPORT(fputc), - ESP_ELFSYM_EXPORT(fputs), - ESP_ELFSYM_EXPORT(fprintf), - ESP_ELFSYM_EXPORT(fread), - ESP_ELFSYM_EXPORT(fseek), - ESP_ELFSYM_EXPORT(fsetpos), - ESP_ELFSYM_EXPORT(fscanf), - ESP_ELFSYM_EXPORT(ftell), - ESP_ELFSYM_EXPORT(fwrite), - ESP_ELFSYM_EXPORT(getc), - ESP_ELFSYM_EXPORT(putc), - ESP_ELFSYM_EXPORT(putchar), - ESP_ELFSYM_EXPORT(puts), - ESP_ELFSYM_EXPORT(printf), - ESP_ELFSYM_EXPORT(sscanf), - ESP_ELFSYM_EXPORT(snprintf), - ESP_ELFSYM_EXPORT(sprintf), - ESP_ELFSYM_EXPORT(vsprintf), - ESP_ELFSYM_EXPORT(vsnprintf), - ESP_ELFSYM_EXPORT(vfprintf), - // cstring - ESP_ELFSYM_EXPORT(strlen), - ESP_ELFSYM_EXPORT(strcmp), - ESP_ELFSYM_EXPORT(strncmp), - ESP_ELFSYM_EXPORT(strncpy), - ESP_ELFSYM_EXPORT(strcpy), - ESP_ELFSYM_EXPORT(strcat), - ESP_ELFSYM_EXPORT(strchr), - ESP_ELFSYM_EXPORT(strstr), - ESP_ELFSYM_EXPORT(strerror), - ESP_ELFSYM_EXPORT(strtod), - ESP_ELFSYM_EXPORT(strrchr), - ESP_ELFSYM_EXPORT(strtol), - ESP_ELFSYM_EXPORT(strtoul), - ESP_ELFSYM_EXPORT(strcspn), - ESP_ELFSYM_EXPORT(strncat), - ESP_ELFSYM_EXPORT(strpbrk), - ESP_ELFSYM_EXPORT(strspn), - ESP_ELFSYM_EXPORT(strcoll), - ESP_ELFSYM_EXPORT(memset), - ESP_ELFSYM_EXPORT(memcpy), - ESP_ELFSYM_EXPORT(memcmp), - ESP_ELFSYM_EXPORT(memchr), - ESP_ELFSYM_EXPORT(memmove), - ESP_ELFSYM_EXPORT(strdup), - ESP_ELFSYM_EXPORT(stpcpy), - - // ctype - ESP_ELFSYM_EXPORT(isalnum), - ESP_ELFSYM_EXPORT(isalpha), - ESP_ELFSYM_EXPORT(iscntrl), - ESP_ELFSYM_EXPORT(isdigit), - ESP_ELFSYM_EXPORT(isgraph), - ESP_ELFSYM_EXPORT(islower), - ESP_ELFSYM_EXPORT(isprint), - ESP_ELFSYM_EXPORT(ispunct), - ESP_ELFSYM_EXPORT(isspace), - ESP_ELFSYM_EXPORT(isupper), - ESP_ELFSYM_EXPORT(isxdigit), - ESP_ELFSYM_EXPORT(tolower), - ESP_ELFSYM_EXPORT(toupper), - // ESP-IDF - ESP_ELFSYM_EXPORT(esp_log), - // Lets an app that has taken over the display quieten firmware logging: with stdout redirected - // to a terminal the app owns, anything logged appears on screen as if the app had printed it. - ESP_ELFSYM_EXPORT(esp_log_level_set), - // Lets an app redirect firmware logging somewhere other than stdout. An app that has pointed - // stdout at its own terminal needs this: without it, every ESP_LOG from any component in the - // system - NTP, RTC, TLS - paints over the app's display. - ESP_ELFSYM_EXPORT(esp_log_set_vprintf), - ESP_ELFSYM_EXPORT(esp_log_write), - ESP_ELFSYM_EXPORT(esp_log_timestamp), - ESP_ELFSYM_EXPORT(esp_err_to_name), - // Tactility - ESP_ELFSYM_EXPORT(tt_app_fileselection_start_for_existing_file), - ESP_ELFSYM_EXPORT(tt_app_fileselection_start_for_existing_or_new_file), - ESP_ELFSYM_EXPORT(tt_app_fileselection_get_result_path), - ESP_ELFSYM_EXPORT(tt_app_selectiondialog_start), - ESP_ELFSYM_EXPORT(tt_app_alertdialog_start), - - // stdio.h - ESP_ELFSYM_EXPORT(rename), - ESP_ELFSYM_EXPORT(rewind), - ESP_ELFSYM_EXPORT(remove), - // dirent.h - ESP_ELFSYM_EXPORT(opendir), - ESP_ELFSYM_EXPORT(closedir), - ESP_ELFSYM_EXPORT(readdir), - // fcntl.h - ESP_ELFSYM_EXPORT(fcntl), - // lwip/sockets.h - ESP_ELFSYM_EXPORT(lwip_setsockopt), - ESP_ELFSYM_EXPORT(lwip_socket), - ESP_ELFSYM_EXPORT(lwip_recv), - ESP_ELFSYM_EXPORT(lwip_getpeername), - ESP_ELFSYM_EXPORT(lwip_bind), - ESP_ELFSYM_EXPORT(lwip_listen), - ESP_ELFSYM_EXPORT(lwip_close), - ESP_ELFSYM_EXPORT(lwip_accept), - ESP_ELFSYM_EXPORT(lwip_getsockname), - ESP_ELFSYM_EXPORT(lwip_send), - ESP_ELFSYM_EXPORT(lwip_connect), - ESP_ELFSYM_EXPORT(lwip_select), - ESP_ELFSYM_EXPORT(lwip_gethostbyname), - ESP_ELFSYM_EXPORT(ipaddr_addr), - // POSIX socket names (VFS wrappers used when apps include ) - ESP_ELFSYM_EXPORT(select), - // stdlib.h - environment and sorting - ESP_ELFSYM_EXPORT(getenv), - ESP_ELFSYM_EXPORT(setenv), - ESP_ELFSYM_EXPORT(unsetenv), - ESP_ELFSYM_EXPORT(qsort), - // unistd.h - ESP_ELFSYM_EXPORT(access), - ESP_ELFSYM_EXPORT(isatty), - ESP_ELFSYM_EXPORT(read), - ESP_ELFSYM_EXPORT(write), - ESP_ELFSYM_EXPORT(lseek), - // sys/stat.h - ESP_ELFSYM_EXPORT(stat), - ESP_ELFSYM_EXPORT(mkdir), - // esp_vfs.h - lets an app register a device node (e.g. a terminal at /dev/...) so that plain - // printf/stdout reaches it. Note the registration is global and outlives the app unless it - // unregisters: an app that takes this must release it on shutdown, or the next one inherits a - // path whose callbacks point into unloaded memory. - ESP_ELFSYM_EXPORT(esp_vfs_register), - ESP_ELFSYM_EXPORT(esp_vfs_unregister), - // esp_netif.h - ESP_ELFSYM_EXPORT(esp_netif_get_ip_info), - ESP_ELFSYM_EXPORT(esp_netif_get_handle_from_ifkey), - // Locale - ESP_ELFSYM_EXPORT(localeconv), - // driver/gpio.h - ESP_ELFSYM_EXPORT(gpio_config), - ESP_ELFSYM_EXPORT(gpio_get_level), - ESP_ELFSYM_EXPORT(gpio_set_level), - ESP_ELFSYM_EXPORT(gpio_reset_pin), - // driver/i2s_common.h - ESP_ELFSYM_EXPORT(i2s_new_channel), - ESP_ELFSYM_EXPORT(i2s_del_channel), - ESP_ELFSYM_EXPORT(i2s_channel_enable), - ESP_ELFSYM_EXPORT(i2s_channel_disable), - ESP_ELFSYM_EXPORT(i2s_channel_write), - ESP_ELFSYM_EXPORT(i2s_channel_get_info), - ESP_ELFSYM_EXPORT(i2s_channel_read), - ESP_ELFSYM_EXPORT(i2s_channel_register_event_callback), - ESP_ELFSYM_EXPORT(i2s_channel_preload_data), - ESP_ELFSYM_EXPORT(i2s_channel_tune_rate), - // driver/i2s_std.h - ESP_ELFSYM_EXPORT(i2s_channel_init_std_mode), - ESP_ELFSYM_EXPORT(i2s_channel_reconfig_std_clock), - ESP_ELFSYM_EXPORT(i2s_channel_reconfig_std_slot), - ESP_ELFSYM_EXPORT(i2s_channel_reconfig_std_gpio), - // miniz.h - ESP_ELFSYM_EXPORT(tinfl_decompress), - ESP_ELFSYM_EXPORT(tinfl_decompress_mem_to_callback), - ESP_ELFSYM_EXPORT(tinfl_decompress_mem_to_mem), - // Compression, the counterpart to the tinfl_* decompression above. Like those, these live in - // the chip's ROM rather than in flash, so exporting them costs nothing. - // - // Note this is miniz, not zlib: ESP-IDF builds it with MINIZ_NO_ZLIB_APIS, so deflate/inflate, - // crc32 and the gz* file API do not exist anywhere in the firmware. An app wanting gzip files - // has to use the tdefl_/tinfl_ interfaces directly, or vendor zlib itself. - ESP_ELFSYM_EXPORT(tdefl_init), - ESP_ELFSYM_EXPORT(tdefl_compress), - ESP_ELFSYM_EXPORT(tdefl_compress_buffer), - ESP_ELFSYM_EXPORT(tdefl_compress_mem_to_mem), - ESP_ELFSYM_EXPORT(tdefl_compress_mem_to_output), - ESP_ELFSYM_EXPORT(tdefl_get_adler32), - ESP_ELFSYM_EXPORT(tdefl_get_prev_return_status), - // ledc - ESP_ELFSYM_EXPORT(ledc_update_duty), - ESP_ELFSYM_EXPORT(ledc_set_freq), - ESP_ELFSYM_EXPORT(ledc_channel_config), - ESP_ELFSYM_EXPORT(ledc_set_duty), - ESP_ELFSYM_EXPORT(ledc_set_fade), - ESP_ELFSYM_EXPORT(ledc_set_fade_with_step), - ESP_ELFSYM_EXPORT(ledc_set_fade_with_time), - ESP_ELFSYM_EXPORT(ledc_set_fade_step_and_start), - ESP_ELFSYM_EXPORT(ledc_set_fade_time_and_start), - ESP_ELFSYM_EXPORT(ledc_set_pin), - ESP_ELFSYM_EXPORT(ledc_timer_config), - ESP_ELFSYM_EXPORT(ledc_timer_pause), - ESP_ELFSYM_EXPORT(ledc_timer_resume), - ESP_ELFSYM_EXPORT(ledc_timer_rst), - // esp_heap_caps.h - ESP_ELFSYM_EXPORT(heap_caps_get_total_size), - ESP_ELFSYM_EXPORT(heap_caps_get_allocated_size), - ESP_ELFSYM_EXPORT(heap_caps_get_free_size), - ESP_ELFSYM_EXPORT(heap_caps_get_largest_free_block), - ESP_ELFSYM_EXPORT(heap_caps_aligned_alloc), - ESP_ELFSYM_EXPORT(heap_caps_malloc), - ESP_ELFSYM_EXPORT(heap_caps_calloc), - ESP_ELFSYM_EXPORT(heap_caps_free), - // esp_timer.h - ESP_ELFSYM_EXPORT(esp_timer_create), - ESP_ELFSYM_EXPORT(esp_timer_stop), - ESP_ELFSYM_EXPORT(esp_timer_delete), - ESP_ELFSYM_EXPORT(esp_timer_start_periodic), - ESP_ELFSYM_EXPORT(esp_timer_start_once), - ESP_ELFSYM_EXPORT(esp_timer_get_time), -#ifdef CONFIG_IDF_TARGET_ESP32P4 - // driver/ppa.h - ESP_ELFSYM_EXPORT(ppa_register_client), - ESP_ELFSYM_EXPORT(ppa_unregister_client), - ESP_ELFSYM_EXPORT(ppa_do_scale_rotate_mirror), - // esp_cache.h - ESP_ELFSYM_EXPORT(esp_cache_msync), - // esp_system.h - ESP_ELFSYM_EXPORT(esp_restart), -#endif - // delimiter - ESP_ELFSYM_END -}; - -uintptr_t resolve_symbol(const esp_elfsym* source, const char* symbolName) { - const esp_elfsym* symbol_iterator = source; - while (symbol_iterator->name != nullptr) { - if (strcmp(symbol_iterator->name, symbolName) == 0) { - return reinterpret_cast(symbol_iterator->sym); - } - symbol_iterator++; - } - return 0; -} - -uintptr_t tt_symbol_resolver(const char* symbolName) { - static const std::vector all_symbols = { - main_symbols, - gcc_soft_float_symbols, - stl_symbols, - cplusplus_symbols, - pthread_symbols, - freertos_symbols, - string_symbols, - esp_event_symbols, - esp_http_client_symbols, - mbedtls_symbols, - }; - - for (const auto* symbols : all_symbols) { - const uintptr_t address = resolve_symbol(symbols, symbolName); - if (address != 0) { - return address; - } - } - - uintptr_t symbol_address; - if (module_resolve_symbol_global(symbolName, &symbol_address)) { - return symbol_address; - } - - return 0; -} - -void tt_init_tactility_c() { - elf_set_symbol_resolver(tt_symbol_resolver); -} - -} - -// extern "C" - -#else // Simulator - -extern "C" { - -void tt_init_tactility_c() { -} - -} - -#endif // ESP_PLATFORM diff --git a/TactilityKernel/include/tactility/module.h b/TactilityKernel/include/tactility/module.h index b91091cb..682f088c 100644 --- a/TactilityKernel/include/tactility/module.h +++ b/TactilityKernel/include/tactility/module.h @@ -13,6 +13,9 @@ #endif #define DEFINE_MODULE_SYMBOL(symbol) { #symbol, (void*)&symbol } +/** For an overloaded symbol (e.g. libc++/libstdc++'s float/double/long double math overloads), + * where a bare `&symbol` is ambiguous - `type` picks the overload to take the address of. */ +#define DEFINE_MODULE_SYMBOL_SIGNATURE(symbol, type) { #symbol, (void*)(type)&symbol } #ifdef __cplusplus extern "C" { diff --git a/TactilityKernel/source/drivers/gpio_backlight.cpp b/TactilityKernel/source/drivers/gpio_backlight.cpp index c5b3d9f5..0c91c876 100644 --- a/TactilityKernel/source/drivers/gpio_backlight.cpp +++ b/TactilityKernel/source/drivers/gpio_backlight.cpp @@ -125,7 +125,7 @@ static error_t stop(Device* device) { // endregion -extern Module root_module; +extern Module kernel_module; Driver gpio_backlight_driver = { .name = "gpio_backlight", @@ -134,7 +134,7 @@ Driver gpio_backlight_driver = { .stop_device = stop, .api = &GPIO_BACKLIGHT_API, .device_type = &BACKLIGHT_TYPE, - .owner = &root_module, + .owner = &kernel_module, .internal = nullptr }; diff --git a/TactilityKernel/source/drivers/gpio_hog.cpp b/TactilityKernel/source/drivers/gpio_hog.cpp index 9b2672d7..f66f0218 100644 --- a/TactilityKernel/source/drivers/gpio_hog.cpp +++ b/TactilityKernel/source/drivers/gpio_hog.cpp @@ -57,7 +57,7 @@ static error_t stop(Device* device) { return ERROR_NONE; } -extern Module root_module; +extern Module kernel_module; Driver gpio_hog_driver = { .name = "gpio_hog", @@ -66,6 +66,6 @@ Driver gpio_hog_driver = { .stop_device = stop, .api = nullptr, .device_type = &GPIO_HOG_TYPE, - .owner = &root_module, + .owner = &kernel_module, .internal = nullptr }; diff --git a/TactilityKernel/source/drivers/pwm_backlight.cpp b/TactilityKernel/source/drivers/pwm_backlight.cpp index 5135cdd9..59cba124 100644 --- a/TactilityKernel/source/drivers/pwm_backlight.cpp +++ b/TactilityKernel/source/drivers/pwm_backlight.cpp @@ -126,7 +126,7 @@ static error_t stop(Device* device) { // endregion -extern Module root_module; +extern Module kernel_module; Driver pwm_backlight_driver = { .name = "pwm_backlight", @@ -135,7 +135,7 @@ Driver pwm_backlight_driver = { .stop_device = stop, .api = &PWM_BACKLIGHT_API, .device_type = &BACKLIGHT_TYPE, - .owner = &root_module, + .owner = &kernel_module, .internal = nullptr }; diff --git a/TactilityKernel/source/drivers/rgb_led_gpio.cpp b/TactilityKernel/source/drivers/rgb_led_gpio.cpp index af22fba1..98232562 100644 --- a/TactilityKernel/source/drivers/rgb_led_gpio.cpp +++ b/TactilityKernel/source/drivers/rgb_led_gpio.cpp @@ -146,7 +146,7 @@ static error_t stop(Device* device) { // endregion -extern Module root_module; +extern Module kernel_module; Driver rgb_led_gpio_driver = { .name = "rgb_led_gpio", @@ -155,7 +155,7 @@ Driver rgb_led_gpio_driver = { .stop_device = stop, .api = &RGB_LED_GPIO_API, .device_type = &RGB_LED_TYPE, - .owner = &root_module, + .owner = &kernel_module, .internal = nullptr }; diff --git a/TactilityKernel/source/drivers/rgb_led_pwm.cpp b/TactilityKernel/source/drivers/rgb_led_pwm.cpp index 814086b1..c5ebb8fb 100644 --- a/TactilityKernel/source/drivers/rgb_led_pwm.cpp +++ b/TactilityKernel/source/drivers/rgb_led_pwm.cpp @@ -141,7 +141,7 @@ static error_t stop(Device* device) { // endregion -extern Module root_module; +extern Module kernel_module; Driver rgb_led_pwm_driver = { .name = "rgb_led_pwm", @@ -150,7 +150,7 @@ Driver rgb_led_pwm_driver = { .stop_device = stop, .api = &RGB_LED_PWM_API, .device_type = &RGB_LED_TYPE, - .owner = &root_module, + .owner = &kernel_module, .internal = nullptr }; diff --git a/TactilityKernel/source/kernel_init.cpp b/TactilityKernel/source/kernel_init.cpp index 20164563..359b5596 100644 --- a/TactilityKernel/source/kernel_init.cpp +++ b/TactilityKernel/source/kernel_init.cpp @@ -11,42 +11,44 @@ extern "C" { extern const ModuleSymbol KERNEL_SYMBOLS[]; -static error_t start() { - extern Driver root_driver; - if (driver_construct_add(&root_driver) != ERROR_NONE) return ERROR_RESOURCE; - extern Driver battery_sense_driver; - if (driver_construct_add(&battery_sense_driver) != ERROR_NONE) return ERROR_RESOURCE; - extern Driver battery_sense_power_supply_driver; - if (driver_construct_add(&battery_sense_power_supply_driver) != ERROR_NONE) return ERROR_RESOURCE; - extern Driver gpio_hog_driver; - if (driver_construct_add(&gpio_hog_driver) != ERROR_NONE) return ERROR_RESOURCE; - extern Driver pwm_backlight_driver; - if (driver_construct_add(&pwm_backlight_driver) != ERROR_NONE) return ERROR_RESOURCE; - extern Driver gpio_backlight_driver; - if (driver_construct_add(&gpio_backlight_driver) != ERROR_NONE) return ERROR_RESOURCE; - extern Driver rgb_led_gpio_driver; - if (driver_construct_add(&rgb_led_gpio_driver) != ERROR_NONE) return ERROR_RESOURCE; - extern Driver rgb_led_pwm_driver; - if (driver_construct_add(&rgb_led_pwm_driver) != ERROR_NONE) return ERROR_RESOURCE; - return ERROR_NONE; -} +extern Driver root_driver; +extern Driver battery_sense_driver; +extern Driver battery_sense_power_supply_driver; +extern Driver gpio_hog_driver; +extern Driver pwm_backlight_driver; +extern Driver gpio_backlight_driver; +extern Driver rgb_led_gpio_driver; +extern Driver rgb_led_pwm_driver; -static error_t stop() { - return ERROR_NONE; -} +/** + * @warning Because the drivers have no owning module, they cannot be unbound. + * This is fine for now because we never unload the kernel once it's loaded. + */ +static Driver* const KERNEL_DRIVERS[] = { + &root_driver, + &battery_sense_driver, + &battery_sense_power_supply_driver, + &gpio_hog_driver, + &pwm_backlight_driver, + &gpio_backlight_driver, + &rgb_led_gpio_driver, + &rgb_led_pwm_driver, + nullptr, +}; -Module root_module = { +Module kernel_module = { .name = "kernel", - .start = start, - .stop = stop, - .symbols = (const struct ModuleSymbol*)KERNEL_SYMBOLS, - .internal = nullptr + .start = nullptr, + .stop = nullptr, + .drivers = KERNEL_DRIVERS, + .symbols = static_cast(KERNEL_SYMBOLS), + .internal = nullptr, }; error_t kernel_init(Module* const dts_modules[], const DtsDevice dts_devices[]) { LOG_I(TAG, "init"); - if (module_construct_add_start(&root_module) != ERROR_NONE) { + if (module_construct_add_start(&kernel_module) != ERROR_NONE) { LOG_E(TAG, "root module init failed"); return ERROR_RESOURCE; } diff --git a/TactilityKernel/source/symbols.c b/TactilityKernel/source/symbols.c index 4dc88f32..c59d3060 100644 --- a/TactilityKernel/source/symbols.c +++ b/TactilityKernel/source/symbols.c @@ -570,5 +570,5 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = { DEFINE_MODULE_SYMBOL(properties_file_set), DEFINE_MODULE_SYMBOL(properties_file_for_each), // terminator - MODULE_SYMBOL_TERMINATOR + MODULE_SYMBOL_TERMINATOR, };