74 lines
1.6 KiB
C
74 lines
1.6 KiB
C
|
|
#ifndef LAUNCH_H_
|
||
|
|
#define LAUNCH_H_
|
||
|
|
|
||
|
|
#include <mango/types.h>
|
||
|
|
|
||
|
|
enum launch_status {
|
||
|
|
LAUNCH_OK,
|
||
|
|
/* a memory allocation failed */
|
||
|
|
LAUNCH_ERR_NO_MEMORY,
|
||
|
|
/* executable file is corrupt or of an unrecognised format. */
|
||
|
|
LAUNCH_ERR_INVALID_EXECUTABLE,
|
||
|
|
/* executable file IS valid and IS of a recognised format, but is
|
||
|
|
* not supported by this machine (different class, architecture,
|
||
|
|
* version, etc).
|
||
|
|
*/
|
||
|
|
LAUNCH_ERR_UNSUPPORTED_EXECUTABLE,
|
||
|
|
/* a particular dependency of the executable could not be resolved. */
|
||
|
|
LAUNCH_ERR_CANNOT_RESOLVE_DEPENDENCY,
|
||
|
|
LAUNCH_ERR_MEMORY_MAP_FAILED,
|
||
|
|
LAUNCH_ERR_IMAGE_DATA_LOAD_FAILED,
|
||
|
|
LAUNCH_ERR_INTERPRETER_REQUIRED,
|
||
|
|
LAUNCH_ERR_TASK_CREATION_FAILED,
|
||
|
|
LAUNCH_ERR_THREAD_CREATION_FAILED,
|
||
|
|
};
|
||
|
|
|
||
|
|
enum launch_flags {
|
||
|
|
LAUNCH_F_NONE = 0,
|
||
|
|
};
|
||
|
|
|
||
|
|
struct launch_ctx;
|
||
|
|
|
||
|
|
typedef enum launch_status (*launch_resolve_library_function)(
|
||
|
|
struct launch_ctx *,
|
||
|
|
const char *,
|
||
|
|
kern_handle_t *,
|
||
|
|
void *);
|
||
|
|
|
||
|
|
struct launch_ctx {
|
||
|
|
launch_resolve_library_function ctx_resolve_library;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct launch_parameters {
|
||
|
|
kern_handle_t p_parent_task;
|
||
|
|
kern_handle_t p_local_address_space;
|
||
|
|
kern_handle_t p_executable;
|
||
|
|
|
||
|
|
const char *p_task_name;
|
||
|
|
|
||
|
|
int p_argc;
|
||
|
|
const char **p_argv;
|
||
|
|
|
||
|
|
int p_envc;
|
||
|
|
const char **p_envp;
|
||
|
|
|
||
|
|
void *p_resolver_arg;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct launch_result {
|
||
|
|
kern_handle_t r_task;
|
||
|
|
kern_handle_t r_thread;
|
||
|
|
kern_handle_t r_address_space;
|
||
|
|
};
|
||
|
|
|
||
|
|
extern enum launch_status launch_ctx_init(struct launch_ctx *ctx);
|
||
|
|
extern void launch_ctx_cleanup(struct launch_ctx *ctx);
|
||
|
|
|
||
|
|
extern enum launch_status launch_ctx_execute(
|
||
|
|
struct launch_ctx *ctx,
|
||
|
|
const struct launch_parameters *params,
|
||
|
|
enum launch_flags flags,
|
||
|
|
struct launch_result *result);
|
||
|
|
|
||
|
|
#endif
|