2009-01-24 21:21:08 -08:00
|
|
|
/*
|
2012-06-27 19:35:34 -07:00
|
|
|
* Copyright (c) 2009-2012 Travis Geiselbrecht
|
2009-01-24 21:21:08 -08:00
|
|
|
*
|
2019-07-05 17:22:23 -07:00
|
|
|
* Use of this source code is governed by a MIT-style
|
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
|
* https://opensource.org/licenses/MIT
|
2009-01-24 21:21:08 -08:00
|
|
|
*/
|
2019-07-06 14:02:47 -07:00
|
|
|
#pragma once
|
2009-01-24 21:21:08 -08:00
|
|
|
|
2012-09-30 19:50:09 -07:00
|
|
|
#include <stddef.h>
|
2019-06-17 18:28:51 -07:00
|
|
|
#include <lk/compiler.h>
|
2021-05-25 23:04:41 -07:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <sys/types.h>
|
2012-06-27 19:35:34 -07:00
|
|
|
|
2018-12-16 16:49:40 -08:00
|
|
|
__BEGIN_CDECLS
|
2015-06-26 13:39:37 -07:00
|
|
|
|
2009-01-24 21:21:08 -08:00
|
|
|
/* app support api */
|
|
|
|
|
void apps_init(void); /* one time setup */
|
|
|
|
|
|
2021-05-25 23:04:41 -07:00
|
|
|
/* start an app by name.
|
|
|
|
|
* optionally start detached or wait for it to complete.
|
|
|
|
|
*/
|
|
|
|
|
status_t app_start_by_name(const char *name, bool detached);
|
|
|
|
|
|
2009-01-24 21:21:08 -08:00
|
|
|
/* app entry point */
|
2009-01-24 21:44:52 -08:00
|
|
|
struct app_descriptor;
|
|
|
|
|
typedef void (*app_init)(const struct app_descriptor *);
|
|
|
|
|
typedef void (*app_entry)(const struct app_descriptor *, void *args);
|
2009-01-24 21:21:08 -08:00
|
|
|
|
|
|
|
|
/* app startup flags */
|
2021-05-25 23:04:41 -07:00
|
|
|
#define APP_FLAG_NO_AUTOSTART 0x1
|
2012-06-27 19:35:34 -07:00
|
|
|
#define APP_FLAG_CUSTOM_STACK_SIZE 0x2
|
2009-01-24 21:21:08 -08:00
|
|
|
|
|
|
|
|
/* each app needs to define one of these to define its startup conditions */
|
2009-01-24 21:44:52 -08:00
|
|
|
struct app_descriptor {
|
2016-02-14 12:24:01 -08:00
|
|
|
const char *name;
|
|
|
|
|
app_init init;
|
|
|
|
|
app_entry entry;
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
size_t stack_size;
|
2009-01-24 21:21:08 -08:00
|
|
|
};
|
|
|
|
|
|
2021-05-27 03:14:29 -07:00
|
|
|
#define APP_START(appname) const struct app_descriptor _app_##appname __USED __ALIGNED(sizeof(void *)) __SECTION("apps") = { .name = #appname,
|
2014-08-28 16:23:16 -07:00
|
|
|
|
2009-01-24 21:21:08 -08:00
|
|
|
#define APP_END };
|
|
|
|
|
|
2018-12-16 16:49:40 -08:00
|
|
|
__END_CDECLS
|
2015-06-26 13:39:37 -07:00
|
|
|
|