Remove TactilityC and Firmware subprojects (#638)
- Removed TactilityC, moved its symbols to existing modules and several new ones (pthread-module, c-symbols-module, cpp-symbols-module, posix-symbols-module, freertos-module). - Removed Firmware subproject and moved main() into Tactility subproject. - Strengthened application archive, path, version, stack-size, and device validation. - Moved symbol resolution for elf_loader to app-esp32-module. - Improved `struct Module` declarations and made module and symbol definitions in modules more consistent. - Removed old http download code from Tactility subproject. - Rename app-module's source files for consistency. - Add missing pthread symbols. - Kernel module symbols are now resolvable on all platforms.
This commit is contained in:
committed by
GitHub
parent
d3556fb536
commit
19b11eb9a8
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <app_esp32/module.h>
|
||||
|
||||
#include <private/elf_symbol.h>
|
||||
|
||||
#include <service/manager.h>
|
||||
|
||||
#include <tactility/error.h>
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
+1
@@ -13,6 +13,7 @@ constexpr auto* TAG = "app_metadata_v1";
|
||||
|
||||
bool app_metadata_parse_v1(const std::map<std::string, std::string>& 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)) {
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
@@ -0,0 +1,195 @@
|
||||
Apache License
|
||||
==============
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
|
||||
### 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.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <tactility/module.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct Module c_symbols_module;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,178 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <c_symbols/module.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
|
||||
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 <cmath> 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 <cstring> 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,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
@@ -0,0 +1,195 @@
|
||||
Apache License
|
||||
==============
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
|
||||
### 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.
|
||||
|
||||
@@ -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 <new>`/`<map>`/`<string>` 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.
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <tactility/module.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct Module cpp_symbols_module;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <cpp_symbols/module.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <new>
|
||||
#include <string>
|
||||
|
||||
#if defined(__GLIBCXX__) || defined(ESP_PLATFORM)
|
||||
#define TT_CPP_SYMBOLS_AVAILABLE 1
|
||||
#include <bits/functexcept.h>
|
||||
#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,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
)
|
||||
@@ -0,0 +1,195 @@
|
||||
Apache License
|
||||
==============
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
|
||||
### 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.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <tactility/module.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct Module freertos_module;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,165 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#ifdef ESP_PLATFORM
|
||||
#include <sdkconfig.h>
|
||||
#endif
|
||||
|
||||
#include <freertos/module.h>
|
||||
|
||||
#include <tactility/freertos/event_groups.h>
|
||||
#include <tactility/freertos/queue.h>
|
||||
#include <tactility/freertos/task.h>
|
||||
#include <tactility/freertos/timers.h>
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ Module gps_module = {
|
||||
.stop = stop,
|
||||
.drivers = nullptr,
|
||||
.symbols = nullptr,
|
||||
.internal = nullptr
|
||||
.internal = nullptr,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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 ()
|
||||
|
||||
@@ -2,14 +2,98 @@
|
||||
#include <http/download.h>
|
||||
#include <http/module.h>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include <sdkconfig.h>
|
||||
#include <esp_http_client.h>
|
||||
#include <lwip/sockets.h>
|
||||
#include <lwip/netdb.h>
|
||||
#include <esp_sntp.h>
|
||||
#include <esp_netif.h>
|
||||
#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE
|
||||
#include <esp_crt_bundle.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#include <sys/select.h>
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
@@ -67,5 +67,5 @@ struct Module lvgl_module = {
|
||||
.start = start,
|
||||
.stop = stop,
|
||||
.symbols = (const struct ModuleSymbol*)lvgl_module_symbols,
|
||||
.internal = NULL
|
||||
.internal = NULL,
|
||||
};
|
||||
|
||||
@@ -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
|
||||
};
|
||||
MODULE_SYMBOL_TERMINATOR,
|
||||
};
|
||||
|
||||
+4
-6
@@ -2,18 +2,16 @@
|
||||
#include <lvgl_window_manager/module.h>
|
||||
#include <lvgl_window_manager/window_manager.h>
|
||||
|
||||
#include <tactility/error.h>
|
||||
#include <tactility/module.h>
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
@@ -0,0 +1,195 @@
|
||||
Apache License
|
||||
==============
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
|
||||
### 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.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <tactility/module.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct Module mbedtls_module;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,109 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <mbedtls/module.h>
|
||||
|
||||
#include <mbedtls/ctr_drbg.h>
|
||||
#include <mbedtls/entropy.h>
|
||||
#include <mbedtls/cipher.h>
|
||||
#include <mbedtls/md.h>
|
||||
#include <mbedtls/bignum.h>
|
||||
#include <mbedtls/rsa.h>
|
||||
#include <mbedtls/pk.h>
|
||||
#include <mbedtls/ecp.h>
|
||||
#include <mbedtls/ecdsa.h>
|
||||
#include <mbedtls/ecdh.h>
|
||||
#include <mbedtls/error.h>
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
@@ -0,0 +1,195 @@
|
||||
Apache License
|
||||
==============
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
|
||||
### 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.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <tactility/module.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct Module posix_symbols_module;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,88 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <posix_symbols/module.h>
|
||||
|
||||
#include <csetjmp>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <strings.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if __has_include(<getopt.h>)
|
||||
#include <getopt.h>
|
||||
#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 <getopt.h> 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,
|
||||
};
|
||||
|
||||
}
|
||||
@@ -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}
|
||||
)
|
||||
@@ -0,0 +1,195 @@
|
||||
Apache License
|
||||
==============
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
|
||||
### 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.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <tactility/module.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern struct Module pthread_module;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,108 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <pthread/module.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// pthread_mutex_timedlock / pthread_rwlock_timed{rd,wr}lock / sem_timedwait belong to POSIX's
|
||||
// optional "Timeouts" feature (_POSIX_TIMEOUTS, from <unistd.h>) - 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,
|
||||
};
|
||||
|
||||
}
|
||||
+5
-3
@@ -4,7 +4,7 @@
|
||||
#include <service/manager.h>
|
||||
#include <service/paths.h>
|
||||
|
||||
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,
|
||||
};
|
||||
Reference in New Issue
Block a user