--- Gnu-Mach/kern/startup.c 2020/09/02 04:36:57 1.1.1.1 +++ Gnu-Mach/kern/startup.c 2020/09/02 04:47:27 1.1.1.5 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -27,12 +27,7 @@ * Mach kernel startup. */ - -#include -#include -#include -#include -#include +#include #include #include @@ -40,48 +35,50 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include #include #include -#include #include -#include +#include +#include +#include +#include #include #include #include #include +#include +#include #include +#include #include +#include #include +#include - - -extern void vm_mem_init(); -extern void vm_mem_bootstrap(); -extern void init_timeout(); -extern void machine_init(); - -extern void idle_thread(); -extern void vm_pageout(); -extern void reaper_thread(); -extern void swapin_thread(); -extern void sched_thread(); - -extern void bootstrap_create(); -extern void device_service_create(); - -void cpu_launch_first_thread(); /* forward */ -void start_kernel_threads(); /* forward */ +#if MACH_KDB +#include +#endif /* MACH_KDB */ + +#if ! MACH_KBD +boolean_t reboot_on_panic = TRUE; +#endif #if NCPUS > 1 -extern void start_other_cpus(); -extern void action_thread(); -#endif NCPUS > 1 +#include +#include +#endif /* NCPUS > 1 */ /* XX */ extern vm_offset_t phys_first_addr, phys_last_addr; +extern char *kernel_cmdline; /* * Running in virtual memory, on the interrupt stack. @@ -89,10 +86,27 @@ extern vm_offset_t phys_first_addr, phys * * Assumes that master_cpu is set. */ -void setup_main() +void setup_main(void) { thread_t startup_thread; +#if MACH_KDB + /* + * Cause a breakpoint trap to the debugger before proceeding + * any further if the proper option flag was specified + * on the kernel's command line. + * XXX check for surrounding spaces. + */ + if (strstr(kernel_cmdline, "-d ")) { + cninit(); /* need console for debugger */ + SoftDebugger("init"); + } +#else /* MACH_KDB */ + if (strstr (kernel_cmdline, "-H ")) { + reboot_on_panic = FALSE; + } +#endif /* MACH_KDB */ + panic_init(); printf_init(); @@ -113,14 +127,14 @@ void setup_main() #if XPR_DEBUG xprbootstrap(); -#endif XPR_DEBUG +#endif /* XPR_DEBUG */ timestamp_init(); - mapable_time_init(); - machine_init(); + mapable_time_init(); + machine_info.max_cpus = NCPUS; machine_info.memory_size = phys_last_addr - phys_first_addr; /* XXX mem_size */ machine_info.avail_cpus = 0; @@ -135,15 +149,15 @@ void setup_main() swapper_init(); #if MACH_HOST pset_sys_init(); -#endif MACH_HOST +#endif /* MACH_HOST */ /* * Kick off the time-out driven routines by calling * them the first time. */ - recompute_priorities(); + recompute_priorities(NULL); compute_mach_factor(); - + /* * Create a kernel thread to start the other kernel * threads. Thread_resume (from kernel_thread) calls @@ -184,9 +198,9 @@ void setup_main() * Now running in a thread. Create the rest of the kernel threads * and the bootstrap task. */ -void start_kernel_threads() +void start_kernel_threads(void) { - register int i; + int i; /* * Create the idle threads and the other @@ -218,7 +232,7 @@ void start_kernel_threads() * Allow other CPUs to run. */ start_other_cpus(); -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ /* * Create the device service. @@ -226,18 +240,13 @@ void start_kernel_threads() device_service_create(); /* - * Initialize NORMA ipc system. + * Initialize kernel task's creation time. + * When we created the kernel task in task_init, the mapped + * time was not yet available. Now, last thing before starting + * the user bootstrap, record the current time as the kernel + * task's creation time. */ -#if NORMA_IPC - norma_ipc_init(); -#endif NORMA_IPC - - /* - * Initialize NORMA vm system. - */ -#if NORMA_VM - norma_vm_init(); -#endif NORMA_VM + record_time_stamp (&kernel_task->creation_time); /* * Start the user bootstrap. @@ -246,7 +255,7 @@ void start_kernel_threads() #if XPR_DEBUG xprinit(); /* XXX */ -#endif XPR_DEBUG +#endif /* XPR_DEBUG */ /* * Become the pageout daemon. @@ -257,20 +266,19 @@ void start_kernel_threads() } #if NCPUS > 1 -void slave_main() +void slave_main(void) { cpu_launch_first_thread(THREAD_NULL); } -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ /* * Start up the first thread on a CPU. * First thread is specified for the master CPU. */ -void cpu_launch_first_thread(th) - register thread_t th; +void cpu_launch_first_thread(thread_t th) { - register int mycpu; + int mycpu; mycpu = cpu_number(); @@ -288,7 +296,6 @@ void cpu_launch_first_thread(th) if (th == THREAD_NULL) panic("cpu_launch_first_thread"); - startrtclock(); /* needs an active thread */ PMAP_ACTIVATE_KERNEL(mycpu); active_threads[mycpu] = th; @@ -300,6 +307,8 @@ void cpu_launch_first_thread(th) PMAP_ACTIVATE_USER(vm_map_pmap(th->task->map), th, mycpu); + startrtclock(); /* needs an active thread */ + load_context(th); /*NOTREACHED*/ }