MCPcopy Create free account
hub / github.com/HelenOS/helenos / program_create_loader

Function program_create_loader

kernel/generic/src/proc/program.c:170–194  ·  view source on GitHub ↗

Create a task from the program loader image. * * @param prg Buffer for storing program info. * @param name Name to set for the program's task. * * @return EOK on success or an error code. * */

Source from the content-addressed store, hash-verified

168 *
169 */
170errno_t program_create_loader(program_t *prg, char *name)
171{
172 as_t *as = as_create(0);
173 if (!as)
174 return ENOMEM;
175
176 void *loader = program_loader;
177 if (!loader) {
178 as_release(as);
179 log(LF_OTHER, LVL_ERROR,
180 "Cannot spawn loader as none was registered");
181 return ENOENT;
182 }
183
184 prg->loader_status = elf_load((elf_header_t *) program_loader, as);
185 if (prg->loader_status != EOK) {
186 as_release(as);
187 log(LF_OTHER, LVL_ERROR, "Cannot spawn loader (%s)",
188 str_error(prg->loader_status));
189 return prg->loader_status;
190 }
191
192 return program_create(as, ((elf_header_t *) program_loader)->e_entry,
193 name, prg);
194}
195
196/** Make program ready.
197 *

Callers 1

sys_program_spawn_loaderFunction · 0.85

Calls 6

as_createFunction · 0.85
as_releaseFunction · 0.85
program_createFunction · 0.85
logFunction · 0.50
elf_loadFunction · 0.50
str_errorFunction · 0.50

Tested by

no test coverage detected