Implement support for module symbols (#475)
* **New Features** - Adds module symbol support and per-module symbol tables, including LVGL symbol exports moved into a dedicated table. * **API** - Adds symbol-resolution APIs and an accessor to enable dynamic lookup between modules. * **Bug Fixes / Chores** - Explicitly initializes module symbol pointers across device and platform modules to avoid uninitialized state. * **Tests** - Updates tests to account for symbol pointer initialization.
This commit is contained in:
committed by
GitHub
parent
9f721e6655
commit
1f9e7f82fd
@@ -0,0 +1,68 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include <lvgl.h>
|
||||
#include <string.h>
|
||||
#include <tactility/module.h>
|
||||
#include <tactility/lvgl_module.h>
|
||||
|
||||
extern const struct ModuleSymbol lvgl_module_symbols[];
|
||||
error_t lvgl_arch_start();
|
||||
error_t lvgl_arch_stop();
|
||||
|
||||
static bool is_running = false;
|
||||
static bool is_configured = false;
|
||||
|
||||
struct LvglModuleConfig lvgl_module_config = {
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
#ifdef ESP_PLATFORM
|
||||
0,
|
||||
#endif
|
||||
};
|
||||
|
||||
void lvgl_module_configure(const struct LvglModuleConfig config) {
|
||||
is_configured = true;
|
||||
memcpy(&lvgl_module_config, &config, sizeof(struct LvglModuleConfig));
|
||||
}
|
||||
|
||||
static error_t start() {
|
||||
if (!is_configured) {
|
||||
return ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (is_running) {
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
error_t result = lvgl_arch_start();
|
||||
if (result == ERROR_NONE) {
|
||||
is_running = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static error_t stop() {
|
||||
if (!is_running) {
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
error_t error = lvgl_arch_stop();
|
||||
if (error == ERROR_NONE) {
|
||||
is_running = false;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
bool lvgl_is_running() {
|
||||
return is_running;
|
||||
}
|
||||
|
||||
struct Module lvgl_module = {
|
||||
.name = "lvgl",
|
||||
.start = start,
|
||||
.stop = stop,
|
||||
.symbols = (const struct ModuleSymbol*)lvgl_module_symbols
|
||||
};
|
||||
Reference in New Issue
Block a user