Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3469 → Rev 3470

/trunk/uspace/lib/libc/include/loader/loader.h
46,7 → 46,8
extern int loader_get_task_id(loader_t *, task_id_t *);
extern int loader_set_pathname(loader_t *, const char *);
extern int loader_set_args(loader_t *, char *const []);
extern int loader_start_program(loader_t *);
extern int loader_load_program(loader_t *);
extern int loader_run(loader_t *);
extern void loader_abort(loader_t *);
 
#endif
/trunk/uspace/lib/libc/include/ipc/loader.h
42,6 → 42,7
LOADER_GET_TASKID,
LOADER_SET_PATHNAME,
LOADER_SET_ARGS,
LOADER_LOAD,
LOADER_RUN
} fb_request_t;
 
/trunk/uspace/lib/libc/generic/task.c
63,7 → 63,7
task_id_t task_id;
int rc;
 
/* Spawn a program loader */
/* Spawn a program loader. */
ldr = loader_spawn();
if (ldr == NULL)
return 0;
73,27 → 73,37
if (rc != EOK)
goto error;
 
/* Send program pathname */
/* Send program pathname. */
rc = loader_set_pathname(ldr, path);
if (rc != EOK)
goto error;
 
/* Send arguments */
/* Send arguments. */
rc = loader_set_args(ldr, argv);
if (rc != EOK)
goto error;
 
/* Request loader to start the program */
rc = loader_start_program(ldr);
/* Load the program. */
rc = loader_load_program(ldr);
if (rc != EOK)
goto error;
 
/* Run it. */
/* Load the program. */
rc = loader_run(ldr);
if (rc != EOK)
goto error;
 
/* Success */
 
free(ldr);
return task_id;
 
/* Error exit */
error:
loader_abort(ldr);
free(ldr);
 
return 0;
}
 
/trunk/uspace/lib/libc/generic/loader.c
205,8 → 205,31
return EOK;
}
 
/** Instruct loader to load the program.
*
* If this function succeeds, the program has been successfully loaded
* and is ready to be executed.
*
* @param ldr Loader connection structure.
* @return Zero on success or negative error code.
*/
int loader_load_program(loader_t *ldr)
{
int rc;
 
rc = async_req_0_0(ldr->phone_id, LOADER_LOAD);
if (rc != EOK)
return rc;
 
return EOK;
}
 
/** Instruct loader to execute the program.
*
* Note that this function blocks until the loader actually replies
* so you cannot expect this function to return if you are debugging
* the task and its thread is stopped.
*
* After using this function, no further operations must be performed
* on the loader structure. It should be de-allocated using free().
*
213,7 → 236,7
* @param ldr Loader connection structure.
* @return Zero on success or negative error code.
*/
int loader_start_program(loader_t *ldr)
int loader_run(loader_t *ldr)
{
int rc;
 
221,7 → 244,6
if (rc != EOK)
return rc;
 
ipc_hangup(ldr->phone_id);
return EOK;
}