Files
tactility/Modules/app-module/include/app/loader.h
T
Ken Van Hoeylandt a0b2ee7ebc Run executables directly (#645)
- Apps can be launched directly from file paths (including Files app support)
- Added executable detection to identify unsupported or invalid binaries before launch.
- App startup is now streamlined through separate registered-app and direct-execution interfaces.
- Existing app launch points were migrated to the updated startup APIs.
2026-09-04 21:23:08 +02:00

60 lines
2.0 KiB
C

// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <app/manifest.h>
#include <tactility/error.h>
#include <stdbool.h>
#include <stdint.h>
#include "location.h"
#ifdef __cplusplus
extern "C" {
#endif
/** service-module id the AppLoaderApi implementation for AppManifest::location.type ==
* APP_LOCATION_MEMORY must register under. Implemented by app-module itself (source/app_internal_loader.cpp). */
#define APP_LOADER_MEMORY_SERVICE_ID "app-loader-memory"
/** service-module id the AppLoaderApi implementation for AppManifest::location.type ==
* APP_LOCATION_PATH must register under. Implemented by a platform module (e.g. app-esp32-module). */
#define APP_LOADER_PATH_SERVICE_ID "app-loader-path"
/** Entry point signature for an APP_LOCATION_MEMORY app.
* AppManifest::location.location holds this cast to void*. */
typedef int32_t (*AppMainFn)(int argc, char* argv[]);
typedef void* AppRuntime;
/**
* Pluggable mechanism for loading and executing an app.
*/
struct AppLoaderApi {
/**
* Prepares an app instance for execution (e.g. read + relocate its binary).
* @param[in] location the location to load the elf from
* @param[out] out_runtime opaque handle to whatever load() allocated; passed back to run()/unload()
*/
error_t (*load)(struct AppLocation location, AppRuntime* out_runtime);
/**
* Blocking: runs the app to completion.
* @param[in] runtime handle produced by load()
* @param[in] app_instance_id the running instance's id
* @param[in] argc the amount of arguments in @a argv
* @param[in] argv the array of string pointers (can be NULL)
*/
int32_t (*run)(AppRuntime runtime, uint32_t app_instance_id, int argc, char* argv[]);
/** Releases whatever load() allocated. Called after run() returns. */
void (*unload)(AppRuntime runtime);
/**
* Reports whether this loader could load and run whatever @a location points at, without actually loading it.
*/
bool (*is_executable)(struct AppLocation location);
};
#ifdef __cplusplus
}
#endif