phantom_device_t * driver_isa_ps2m_probe( int port, int irq, int stage ) { (void) port; (void) stage; //dpc_request_init( &mouse_dpc, push_event ); //hal_mutex_init( &mouse_mutex, "MouseDrv" ); //hal_cond_init( &mouse_cond ); hal_sem_init( &mouse_sem, "MouseDrv" ); hal_spin_init( &elock ); if( seq_number || ps2ms_do_init() ) return 0; if( hal_irq_alloc( irq, ps2ms_int_handler, 0, HAL_IRQ_SHAREABLE ) ) return 0; phantom_device_t * dev = malloc(sizeof(phantom_device_t)); dev->name = "ps2-mouse"; dev->seq_number = seq_number++; hal_start_kernel_thread((void*)mouse_push_event_thread); return dev; }
void init_irq_allocator(void) { int i; for( i = 0; i < MAX_IRQ_COUNT; i++ ) queue_init(&heads[i]); hal_spin_init(&irq_list_lock); }
void phantom_scheduler_init(void) { queue_init(&runq_idle); queue_init(&runq_norm); queue_init(&runq_rt); hal_spin_init(&schedlock); }
void pvm_internal_init_weakref(struct pvm_object_storage * os) { struct data_area_4_weakref * da = (struct data_area_4_weakref *)os->da; da->object.data = 0; #if WEAKREF_SPIN hal_spin_init( &da->lock ); #else hal_mutex_init( &da->mutex, "WeakRef" ); #endif }
void pvm_internal_init_thread(struct pvm_object_storage * os) { struct data_area_4_thread * da = (struct data_area_4_thread *)os->da; hal_spin_init(&da->spin); da->sleep_flag = 0; //hal_cond_init(&(da->wakeup_cond), "VmThrdWake"); da->call_frame = pvm_create_call_frame_object(); da->stack_depth = 1; da->owner.data = 0; da->environment.data = 0; da->code.code = 0; da->code.IP = 0; da->code.IP_max = 0; //da->_this_object = pvm_get_null_object(); pvm_exec_load_fast_acc(da); // Just to fill shadows with something non-null }
static void common_thread_init(phantom_thread_t *t, int stacksize ) { //t->thread_flags = 0; t->priority = THREAD_PRIO_NORM; t->cpu_id = GET_CPU_ID(); #if CONF_NEW_CTTY t_make_ctty( t ); #else if( 0 == t->ctty ) t->ctty = wtty_init( WTTY_SMALL_BUF ); #endif // malloc uses mutex, so we have to use physalloc which is protected with spinlocks physaddr_t pa; t->stack_size = stacksize; //t->stack = calloc( 1, stacksize ); hal_pv_alloc( &pa, &(t->stack), stacksize+PAGE_SIZE ); hal_page_control( pa, t->stack, page_unmap, page_noaccess ); // poor man's guard page - TODO support in page fault t->stack_pa = pa; SHOW_FLOW( 5, "main stk va %p pa %p", t->stack, (void *)pa ); //assert(t->stack != 0); t->kstack_size = stacksize; //t->kstack = calloc( 1, stacksize ); hal_pv_alloc( &pa, &(t->kstack), stacksize+PAGE_SIZE ); hal_page_control( pa, t->kstack, page_unmap, page_noaccess ); // poor man's guard page - TODO support in page fault t->kstack_pa = pa; SHOW_FLOW( 5, "kern stk va %p pa %p", t->kstack, (void *)pa ); #if ARCH_mips // On mips we need unmapped kernel stack for mapping on MIPS is // done with exceptions too and unmapped stack is fault forever. // We achieve this by setting stack virtual address to its // physical address | 0x8000000 - this virt mem area is direct // mapped to physmem at 0 assert( (addr_t)phystokv(t->kstack_pa) > 0x80000000 ); assert( (addr_t)phystokv(t->kstack_pa) < 0xC0000000 ); t->kstack_top = phystokv(t->kstack_pa) +t->kstack_size-4; // Why -4? #else t->kstack_top = t->kstack+t->kstack_size-4; // Why -4? #endif //assert(t->kstack != 0); t->owner = 0; //t->u = 0; t->pid = NO_PID; t->thread_flags = 0;; t->waitcond = 0; hal_spin_init( &(t->waitlock)); queue_init(&(t->chain)); queue_init(&(t->runq_chain)); t->sw_unlock = 0; t->preemption_disabled = 0; }