--- Gnu-Mach/kern/bootstrap.c 2020/09/02 04:42:40 1.1.1.3 +++ Gnu-Mach/kern/bootstrap.c 2020/09/02 04:45:10 1.1.1.4 @@ -29,20 +29,27 @@ /* * Bootstrap the various built-in servers. */ -#include -#include + +#include +#include #include #include -#include "vm_param.h" +#include +#include #include +#include +#include #include +#include +#include #include #include #include #include +#include +#include #include -#include #if MACH_KDB #include @@ -51,7 +58,6 @@ #if OSKIT_MACH #include -#include #include #include #include @@ -59,8 +65,12 @@ #else #include #include -#include +#ifdef MACH_XEN +#include +extern struct start_info boot_info; /* XXX put this in a header! */ +#else /* MACH_XEN */ extern struct multiboot_info boot_info; /* XXX put this in a header! */ +#endif /* MACH_XEN */ #endif #include "boot_script.h" @@ -87,7 +97,7 @@ task_insert_send_right( kern_return_t kr; kr = mach_port_insert_right(task->itk_space, name, - (ipc_object_t)port, MACH_MSG_TYPE_PORT_SEND); + port, MACH_MSG_TYPE_PORT_SEND); if (kr == KERN_SUCCESS) break; assert(kr == KERN_NAME_EXISTS); @@ -98,10 +108,24 @@ task_insert_send_right( void bootstrap_create() { + int compat; + int n = 0; +#ifdef MACH_XEN + struct multiboot_module *bmods = ((struct multiboot_module *) + boot_info.mod_start); + if (bmods) + for (n = 0; bmods[n].mod_start; n++) { + bmods[n].mod_start = kvtophys(bmods[n].mod_start + (vm_offset_t) bmods); + bmods[n].mod_end = kvtophys(bmods[n].mod_end + (vm_offset_t) bmods); + bmods[n].string = kvtophys(bmods[n].string + (vm_offset_t) bmods); + } + boot_info.mods_count = n; + boot_info.flags |= MULTIBOOT_MODS; +#else /* MACH_XEN */ struct multiboot_module *bmods = ((struct multiboot_module *) phystokv(boot_info.mods_addr)); - int compat; +#endif /* MACH_XEN */ if (!(boot_info.flags & MULTIBOOT_MODS) || (boot_info.mods_count == 0)) panic ("No bootstrap code loaded with the kernel!"); @@ -130,19 +154,19 @@ void bootstrap_create() /* Initialize boot script variables. We leak these send rights. */ losers = boot_script_set_variable ("host-port", VAL_PORT, - (int)ipc_port_make_send(realhost.host_priv_self)); + (long)ipc_port_make_send(realhost.host_priv_self)); if (losers) panic ("cannot set boot-script variable host-port: %s", boot_script_error_string (losers)); losers = boot_script_set_variable ("device-port", VAL_PORT, - (int) ipc_port_make_send(master_device_port)); + (long) ipc_port_make_send(master_device_port)); if (losers) panic ("cannot set boot-script variable device-port: %s", boot_script_error_string (losers)); losers = boot_script_set_variable ("kernel-command-line", VAL_STR, - (int) kernel_cmdline); + (long) kernel_cmdline); if (losers) panic ("cannot set boot-script variable %s: %s", "kernel-command-line", boot_script_error_string (losers)); @@ -161,12 +185,12 @@ void bootstrap_create() get_compat_strings(flag_string, root_string); losers = boot_script_set_variable ("boot-args", VAL_STR, - (int) flag_string); + (long) flag_string); if (losers) panic ("cannot set boot-script variable %s: %s", "boot-args", boot_script_error_string (losers)); losers = boot_script_set_variable ("root-device", VAL_STR, - (int) root_string); + (long) root_string); if (losers) panic ("cannot set boot-script variable %s: %s", "root-device", boot_script_error_string (losers)); @@ -187,7 +211,7 @@ void bootstrap_create() char *var = memcpy (alloca (len), *ep, len); char *val = strchr (var, '='); *val++ = '\0'; - losers = boot_script_set_variable (var, VAL_STR, (int) val); + losers = boot_script_set_variable (var, VAL_STR, (long) val); if (losers) panic ("cannot set boot-script variable %s: %s", var, boot_script_error_string (losers)); @@ -208,7 +232,7 @@ void bootstrap_create() if (eq == 0) continue; *eq++ = '\0'; - losers = boot_script_set_variable (word, VAL_STR, (int) eq); + losers = boot_script_set_variable (word, VAL_STR, (long) eq); if (losers) panic ("cannot set boot-script variable %s: %s", word, boot_script_error_string (losers)); @@ -241,8 +265,10 @@ void bootstrap_create() panic ("ERROR in executing boot script: %s", boot_script_error_string (losers)); } - /* XXX at this point, we could free all the memory used - by the boot modules and the boot loader's descriptors and such. */ + /* 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); } static void @@ -354,6 +380,7 @@ static void get_compat_strings(char *fla *cp = '\0'; } +#if 0 /* * Copy boot_data (executable) to the user portion of this task. */ @@ -379,6 +406,7 @@ static boolean_t load_bootstrap_symbols #else static boolean_t load_bootstrap_symbols = FALSE; #endif +#endif @@ -432,7 +460,7 @@ read_exec(void *handle, vm_offset_t file if (file_size > 0) { err = copyout((char *)phystokv (mod->mod_start) + file_ofs, - mem_addr, file_size); + (void *)mem_addr, file_size); assert(err == 0); } @@ -447,10 +475,10 @@ read_exec(void *handle, vm_offset_t file static void copy_bootstrap(void *e, exec_info_t *boot_exec_info) { - register vm_map_t user_map = current_task()->map; + //register vm_map_t user_map = current_task()->map; int err; - if (err = exec_load(boot_read, read_exec, e, boot_exec_info)) + 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 @@ -690,9 +718,7 @@ boot_script_exec_cmd (void *hook, task_t char **argv, char *strings, int stringlen) { struct multiboot_module *mod = hook; - exec_info_t boot_exec_info; - register vm_map_t user_map = current_task()->map; int err; if (task != MACH_PORT_NULL)