#include <kern/timer_call.h>
#include <kern/xpr.h>
#include <kern/zalloc.h>
+#include <vm/vm_shared_memory_server.h>
#include <vm/vm_kern.h>
#include <vm/vm_init.h>
#include <vm/vm_map.h>
#include <vm/vm_page.h>
#include <vm/vm_pageout.h>
#include <machine/pmap.h>
+#include <machine/commpage.h>
#include <sys/version.h>
#ifdef __ppc__
/* Forwards */
void cpu_launch_first_thread(
- thread_t thread);
+ thread_t thread);
void start_kernel_threads(void);
-void swapin_thread();
/*
* Running in virtual memory, on the interrupt stack.
*/
ledger_init();
task_init();
- act_init();
thread_init();
- subsystem_init();
/*
* Initialize the Event Trace Analysis Package.
/*
* 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.
+ * threads.
*/
- startup_thread = kernel_thread_with_priority(
- kernel_task, MAXPRI_KERNEL,
- start_kernel_threads, TRUE, FALSE);
-
- /*
- * 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);
+ startup_thread = kernel_thread_create(start_kernel_threads, MAXPRI_KERNEL);
+
/*
* Start the thread.
*/
+ startup_thread->state = TH_RUN;
+ pset_run_incr(startup_thread->processor_set);
+
cpu_launch_first_thread(startup_thread);
/*NOTREACHED*/
panic("cpu_launch_first_thread returns!");
thread_t thread;
spl_t s;
- thread = kernel_thread_with_priority(
- kernel_task, MAXPRI_KERNEL,
- idle_thread, TRUE, FALSE);
+ thread = kernel_thread_create(idle_thread, MAXPRI_KERNEL);
+
s = splsched();
thread_lock(thread);
- thread_bind_locked(thread, processor);
+ thread->bound_processor = processor;
processor->idle_thread = thread;
thread->ref_count++;
- thread->state |= TH_IDLE;
- thread_go_locked(thread, THREAD_AWAKENED);
+ thread->sched_pri = thread->priority = IDLEPRI;
+ thread->state = (TH_RUN | TH_IDLE);
thread_unlock(thread);
splx(s);
}
+ /*
+ * Initialize the thread reaper mechanism.
+ */
+ thread_reaper_init();
+
/*
* Initialize the stack swapin mechanism.
*/
mapping_adjust();
#endif
- /*
- * Initialize the thread reaper mechanism.
- */
- thread_reaper();
-
/*
* Create the clock service.
*/
*/
device_service_create();
- shared_file_boot_time_init();
+ shared_file_boot_time_init(ENV_DEFAULT_ROOT, machine_slot[cpu_number()].cpu_type);
#ifdef IOKIT
{
PE_init_iokit();
}
#endif
+
+ (void) spllo(); /* Allow interruptions */
+
+ /*
+ * Fill in the comm area (mapped into every task address space.)
+ */
+ commpage_populate();
/*
* Start the user bootstrap.
*/
- (void) spllo(); /* Allow interruptions */
-
#ifdef MACH_BSD
{
extern void bsd_init(void);
}
#endif
+#if __ppc__
+ serial_keyboard_init(); /* Start serial keyboard if wanted */
+#endif
+
thread_bind(current_thread(), PROCESSOR_NULL);
/*
if (thread == THREAD_NULL) {
thread = machine_wake_thread;
machine_wake_thread = THREAD_NULL;
- thread_bind(thread, myprocessor);
}
+
cpu_launch_first_thread(thread);
/*NOTREACHED*/
panic("slave_main");
void
start_cpu_thread(void)
{
- processor_t processor;
-
- processor = cpu_to_processor(cpu_number());
-
slave_machine_init();
- if (processor->processor_self == IP_NULL) {
- ipc_processor_init(processor);
- ipc_processor_enable(processor);
- }
-
(void) thread_terminate(current_act());
}
thread_t thread)
{
register int mycpu = cpu_number();
+ processor_t processor = cpu_to_processor(mycpu);
- /* initialize preemption disabled */
- cpu_data[mycpu].preemption_level = 1;
-
- cpu_up(mycpu);
+ clock_get_uptime(&processor->last_dispatch);
start_timer(&kernel_timer[mycpu]);
- clock_get_uptime(&cpu_to_processor(mycpu)->last_dispatch);
-
- if (thread == THREAD_NULL) {
- thread = cpu_to_processor(mycpu)->idle_thread;
- if (thread == THREAD_NULL)
- panic("cpu_launch_first_thread");
- }
+ machine_thread_set_current(thread);
+ cpu_up(mycpu);
rtclock_reset(); /* start realtime clock ticking */
PMAP_ACTIVATE_KERNEL(mycpu);
- thread_machine_set_current(thread);
thread_lock(thread);
thread->state &= ~TH_UNINT;
- _mk_sp_thread_begin(thread);
+ thread->last_processor = processor;
+ processor->active_thread = thread;
+ processor->current_pri = thread->sched_pri;
+ _mk_sp_thread_begin(thread, processor);
thread_unlock(thread);
timer_switch(&thread->system_timer);
PMAP_ACTIVATE_USER(thread->top_act, mycpu);
/* preemption enabled by load_context */
- load_context(thread);
+ machine_load_context(thread);
/*NOTREACHED*/
}