int check_load(t_shell *shell, t_prg *prg) { int res; if ((my_strlen(prg->args[0]) == 4) && !(my_strncmp(prg->args[0], "load", 4))) { res = exec_load(shell, prg->args); return 1; } if ((my_strlen(prg->args[0]) == 6) && !(my_strncmp(prg->args[0], "unload", 6))) return exec_unload(shell, prg->args); return -1; }
static void copy_bootstrap(void *e, struct exec_info *boot_exec_info) { register vm_map_t user_map = current_task()->map; int err; printf("loading...\n"); if (err = exec_load(boot_read, read_exec, e, boot_exec_info)) panic("Cannot load user-bootstrap image: error code %d", err); #if MACH_KDB /* * Enter the bootstrap symbol table. */ #if 0 /*XXX*/ if (load_bootstrap_symbols) (void) X_db_sym_init( (char*) boot_start+lp->sym_offset, (char*) boot_start+lp->sym_offset+lp->sym_size, "bootstrap", (char *) user_map); #endif #if 0 /*XXX*/ if (load_fault_in_text) { vm_offset_t lenp = round_page(lp->text_start+lp->text_size) - trunc_page(lp->text_start); vm_offset_t i = 0; while (i < lenp) { vm_fault(user_map, text_page_start +i, load_protect_text ? VM_PROT_READ|VM_PROT_EXECUTE : VM_PROT_READ|VM_PROT_EXECUTE | VM_PROT_WRITE, 0,0,0); i = round_page (i+1); } } #endif #endif MACH_KDB }
static void user_bootstrap(void) { struct user_bootstrap_info *info = current_thread()->saved.other; exec_info_t boot_exec_info; int err; char **av; /* Load this task up from the executable file in the module. */ err = exec_load(boot_read, read_exec, info->mod, &boot_exec_info); if (err) panic ("Cannot load user executable module (error code %d): %s", err, info->argv[0]); printf ("task loaded:"); /* Set up the stack with arguments. */ build_args_and_stack(&boot_exec_info, info->argv, 0); for (av = info->argv; *av != 0; ++av) printf (" %s", *av); task_suspend (current_task()); /* Tell the bootstrap thread running boot_script_exec_cmd that we are done looking at INFO. */ simple_lock (&info->lock); assert (!info->done); info->done = 1; thread_wakeup ((event_t) info); /* * Exit to user thread. */ thread_bootstrap_return(); /*NOTREACHED*/ }