1 /* 2 * Copyright (c) 2009-2012 Travis Geiselbrecht 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 #pragma once 9 10 #include <stddef.h> 11 #include <lk/compiler.h> 12 #include <stdbool.h> 13 #include <sys/types.h> 14 15 __BEGIN_CDECLS 16 17 /* app support api */ 18 void apps_init(void); /* one time setup */ 19 20 /* start an app by name. 21 * optionally start detached or wait for it to complete. 22 */ 23 status_t app_start_by_name(const char *name, bool detached); 24 25 /* app entry point */ 26 struct app_descriptor; 27 typedef void (*app_init)(const struct app_descriptor *); 28 typedef void (*app_entry)(const struct app_descriptor *, void *args); 29 30 /* app startup flags */ 31 #define APP_FLAG_NO_AUTOSTART 0x1 32 #define APP_FLAG_CUSTOM_STACK_SIZE 0x2 33 34 /* each app needs to define one of these to define its startup conditions */ 35 struct app_descriptor { 36 const char *name; 37 app_init init; 38 app_entry entry; 39 unsigned int flags; 40 size_t stack_size; 41 }; 42 43 #define APP_START(appname) const struct app_descriptor _app_##appname __USED __ALIGNED(sizeof(void *)) __SECTION("apps") = { .name = #appname, 44 45 #define APP_END }; 46 47 __END_CDECLS 48 49