--- Gnu-Mach/kern/bootstrap.c 2020/09/02 04:47:23 1.1.1.5 +++ Gnu-Mach/kern/bootstrap.c 2020/09/02 04:51:54 1.1.1.7 @@ -107,10 +107,24 @@ task_insert_send_right( return name; } +static void +free_bootstrap_pages(phys_addr_t start, phys_addr_t end) +{ + struct vm_page *page; + + while (start < end) + { + page = vm_page_lookup_pa(start); + assert(page != NULL); + vm_page_manage(page); + start += PAGE_SIZE; + } +} + void bootstrap_create(void) { int compat; - int n = 0; + unsigned n = 0; #ifdef MACH_XEN struct multiboot_module *bmods = ((struct multiboot_module *) boot_info.mod_start); @@ -150,7 +164,8 @@ void bootstrap_create(void) } else { - int i, losers; + unsigned i; + int losers; /* Initialize boot script variables. We leak these send rights. */ losers = boot_script_set_variable @@ -265,7 +280,7 @@ void bootstrap_create(void) /* XXX we could free the memory used by the boot loader's descriptors and such. */ for (n = 0; n < boot_info.mods_count; n++) - vm_page_create(bmods[n].mod_start, bmods[n].mod_end); + free_bootstrap_pages(bmods[n].mod_start, bmods[n].mod_end); } static void @@ -719,13 +734,14 @@ boot_script_exec_cmd (void *hook, task_t thread_t thread; struct user_bootstrap_info info = { mod, argv, 0, }; simple_lock_init (&info.lock); - simple_lock (&info.lock); err = thread_create ((task_t)task, &thread); assert(err == 0); + simple_lock (&info.lock); thread->saved.other = &info; thread_start (thread, user_bootstrap); - thread_resume (thread); + err = thread_resume (thread); + assert(err == 0); /* We need to synchronize with the new thread and block this main thread until it has finished referring to our local state. */ @@ -734,6 +750,8 @@ boot_script_exec_cmd (void *hook, task_t thread_sleep ((event_t) &info, simple_lock_addr(info.lock), FALSE); simple_lock (&info.lock); } + simple_unlock (&info.lock); + thread_deallocate (thread); printf ("\n"); } @@ -768,6 +786,7 @@ static void user_bootstrap(void) simple_lock (&info->lock); assert (!info->done); info->done = 1; + simple_unlock (&info->lock); thread_wakeup ((event_t) info); /* @@ -820,10 +839,18 @@ boot_script_task_resume (struct cmd *cmd int boot_script_prompt_task_resume (struct cmd *cmd) { +#if ! MACH_KDB char xx[5]; +#endif - printf ("Hit return to resume %s...", cmd->path); + printf ("Pausing for %s...\n", cmd->path); + +#if ! MACH_KDB + printf ("Hit to resume bootstrap."); safe_gets (xx, sizeof xx); +#else + SoftDebugger("Hit `c' to resume bootstrap."); +#endif return boot_script_task_resume (cmd); } @@ -833,6 +860,7 @@ boot_script_free_task (task_t task, int { if (aborting) task_terminate (task); + task_deallocate (task); } int