int main(int argc, char **argv) { kern_return_t rc; mach_port_t security_port; mach_port_t root_ledger_wired; mach_port_t root_ledger_paged; if(argc > 1) { if(argv[1][0] == '-') if(argv[1][1] == 't') { tgdb_debug_flags = -1; debug_flag = 1; } } if (bootstrap_ports(bootstrap_port, &tgdb_host_priv, &device_server_port, &root_ledger_wired, &root_ledger_paged, &security_port)) panic("bootstrap_ports"); threads_init(); printf_init(device_server_port); panic_init(tgdb_host_priv); tgdb_session_init(); if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &tgdb_wait_port_set) != KERN_SUCCESS) { printf("tgdb: can't allocate port set\n"); return 1; } exc_thread = tgdb_thread_create((vm_offset_t) tgdb_thread); if(exc_thread == 0) printf("tgdb_thread_create failed\n"); if((rc = thread_resume(exc_thread)) != KERN_SUCCESS) { printf("tgdb: thread_resume failed %x\n", rc); } /* * Change our scheduling policy to round-robin, and boost our priority. */ tgdb_set_policy(tgdb_host_priv); tgdb_connect(); return 1; /* Only reached on error. */ }
/* * Running in virtual memory, on the interrupt stack. * Does not return. Dispatches initial thread. * * Assumes that master_cpu is set. */ void setup_main(void) { thread_t startup_thread; printf_init(); panic_init(); sched_init(); vm_mem_bootstrap(); ipc_bootstrap(); vm_mem_init(); ipc_init(); /* * As soon as the virtual memory system is up, we record * that this CPU is using the kernel pmap. */ PMAP_ACTIVATE_KERNEL(master_cpu); init_timers(); timeout_init(); #if CDLI > 0 ns_init(); /* Initialize CDLI */ #endif /* CDLI > 0 */ dev_lookup_init(); timeout_init(); machine_init(); machine_info.max_cpus = NCPUS; machine_info.memory_size = mem_size; machine_info.avail_cpus = 0; machine_info.major_version = KERNEL_MAJOR_VERSION; machine_info.minor_version = KERNEL_MINOR_VERSION; #if XPR_DEBUG xprbootstrap(); #endif /* XPR_DEBUG */ /* * Initialize the IPC, task, and thread subsystems. */ clock_init(); utime_init(); ledger_init(); #if THREAD_SWAPPER thread_swapper_init(); #endif /* THREAD_SWAPPER */ #if TASK_SWAPPER task_swapper_init(); #endif /* TASK_SWAPPER */ task_init(); act_init(); thread_init(); subsystem_init(); #if TASK_SWAPPER task_swappable(&realhost, kernel_task, FALSE); #endif /* TASK_SWAPPER */ #if MACH_HOST pset_sys_init(); #endif /* MACH_HOST */ /* * Kick off the time-out driven routines by calling * them the first time. */ recompute_priorities(); compute_mach_factor(); /* * Initialize the Event Trace Analysis Package. * Dynamic Phase: 2 of 2 */ etap_init_phase2(); /* * Create a kernel thread to start the other kernel * threads. Thread_resume (from kernel_thread) calls * thread_setrun, which may look at current thread; * we must avoid this, since there is no current thread. */ /* * Create the thread, and point it at the routine. */ (void) thread_create_at(kernel_task, &startup_thread, start_kernel_threads); #if NCPUS > 1 && PARAGON860 thread_bind(startup_thread, cpu_to_processor(master_cpu)); #endif /* * Pretend it is already running, and resume it. * Since it looks as if it is running, thread_resume * will not try to put it on the run queues. * * We can do all of this without locking, because nothing * else is running yet. */ startup_thread->state |= TH_RUN; (void) thread_resume(startup_thread->top_act); /* * Start the thread. */ cpu_launch_first_thread(startup_thread); /*NOTREACHED*/ panic("cpu_launch_first_thread returns!"); }
int main( int argc, char **argv) { int my_node; mach_port_t master_device_port; mach_port_t security_port; mach_port_t root_ledger_wired; mach_port_t root_ledger_paged; static char here[] = "main"; int need_dp_init = 1; /* * Use 4Kbyte cthread wait stacks. */ cthread_wait_stack_size = 4 * 1024; if (bootstrap_ports(bootstrap_port, &default_pager_host_port, &master_device_port, &root_ledger_wired, &root_ledger_paged, &security_port)) Panic("privileged ports"); printf_init(master_device_port); panic_init(default_pager_host_port); norma_mk = (norma_node_self(default_pager_host_port, &my_node) == KERN_SUCCESS); printf("(default_pager): started%s\n", norma_mk ? " on a NORMA kernel" : ""); /* * Process arguments: * list of attributes, list of device names. * Must do device names after ports are initialised. */ while (--argc > 0) { argv++; if (!dp_parse_argument(*argv)) { if (need_dp_init) { /* * Set up ports, port sets and thread counts. */ default_pager_initialize(default_pager_host_port); need_dp_init = 0; } if (!bs_add_device(*argv, master_device_port)) printf("(default_pager): couldn't add device %s\n", *argv); else printf("(default_pager): added device %s\n", *argv); } } if (need_dp_init) { default_pager_initialize(default_pager_host_port); need_dp_init = 0; } /* * Change our scheduling policy to round-robin, and boost our priority. */ default_pager_set_policy(default_pager_host_port); /* Start threads and message processing. */ for (;;) { default_pager(); /*NOTREACHED*/ } }
/* * Running in virtual memory, on the interrupt stack. * Does not return. Dispatches initial thread. * * Assumes that master_cpu is set. */ void setup_main() { thread_t startup_thread; panic_init(); printf_init(); sched_init(); vm_mem_bootstrap(); ipc_bootstrap(); vm_mem_init(); ipc_init(); /* * As soon as the virtual memory system is up, we record * that this CPU is using the kernel pmap. */ PMAP_ACTIVATE_KERNEL(master_cpu); init_timers(); init_timeout(); #if XPR_DEBUG xprbootstrap(); #endif XPR_DEBUG timestamp_init(); mapable_time_init(); machine_init(); machine_info.max_cpus = NCPUS; machine_info.memory_size = phys_last_addr - phys_first_addr; /* XXX mem_size */ machine_info.avail_cpus = 0; machine_info.major_version = KERNEL_MAJOR_VERSION; machine_info.minor_version = KERNEL_MINOR_VERSION; /* * Initialize the IPC, task, and thread subsystems. */ task_init(); thread_init(); swapper_init(); #if MACH_HOST pset_sys_init(); #endif MACH_HOST /* * Kick off the time-out driven routines by calling * them the first time. */ recompute_priorities(); compute_mach_factor(); /* * Create a kernel thread to start the other kernel * threads. Thread_resume (from kernel_thread) calls * thread_setrun, which may look at current thread; * we must avoid this, since there is no current thread. */ /* * Create the thread, and point it at the routine. */ (void) thread_create(kernel_task, &startup_thread); thread_start(startup_thread, start_kernel_threads); /* * Give it a kernel stack. */ thread_doswapin(startup_thread); /* * Pretend it is already running, and resume it. * Since it looks as if it is running, thread_resume * will not try to put it on the run queues. * * We can do all of this without locking, because nothing * else is running yet. */ startup_thread->state |= TH_RUN; (void) thread_resume(startup_thread); /* * Start the thread. */ cpu_launch_first_thread(startup_thread); /*NOTREACHED*/ }