/*!
 * \brief Initialize Ethernet hardware.
 *
 * Resets the LAN91C111 Ethernet controller, initializes all required 
 * hardware registers and starts a background thread for incoming 
 * Ethernet traffic.
 *
 * Applications should do not directly call this function. It is 
 * automatically executed during during device registration by 
 * NutRegisterDevice().
 *
 * If the network configuration hasn't been set by the application
 * before registering the specified device, this function will
 * call NutNetLoadConfig() to get the MAC address.
 *
 * \param dev Identifies the device to initialize.
 */
static int LancInit(lanc111_nic_t *nic)
{
    assert( 0 == hal_cond_init( &nic->ni_rx_rdy, DEBUG_MSG_PREFIX ) );

    assert( 0 == hal_cond_init( &maq, DEBUG_MSG_PREFIX ".MAQ" ) );
    assert( 0 == hal_cond_init( &nic->ni_tx_rdy, DEBUG_MSG_PREFIX ) );

    return 0;
}
Example #2
0
static void deferred_refdec_init(void)
{
    hal_mutex_init( &deferred_refdec_mutex, "refdec");

    hal_cond_init(  &start_refdec_cond, "refdec st" );
    hal_cond_init(  &end_refdec_cond, "refdec end" );

    deferred_refdec_thread_id = hal_start_thread( deferred_refdec_thread, 0, 0 );
    assert(deferred_refdec_thread_id > 0 );

    inited = 1;
}
Example #3
0
void phantom_snap_threads_interlock_init( void )
{
#if !NEW_SNAP_SYNC
    if(
       hal_cond_init( &phantom_snap_wait_4_vm_enter, "Snap W4E" ) ||
       hal_cond_init( &phantom_snap_wait_4_vm_leave, "Snap W4L" ) ||
       hal_cond_init( &phantom_vm_wait_4_snap, "Snap W4S" ) ||

       hal_mutex_init( &interlock_mutex, "Snap ILck" ) ||
       hal_cond_init( &vm_thread_wakeup_cond, "VmSleep")
      )
        panic("Can't init thread/snap interlocks");
#endif
}
Example #4
0
void dpc_init()
{
    SHOW_FLOW0( 1, "Starting DPC");
    hal_cond_init( &dpc_thread_sleep_stone, "DPC" );
    spinlock_init( &dpc_request_lock );

    hal_mutex_init(&unused_dpc_mutex, "DPC");

    SHOW_FLOW0( 1, "Starting DPC thread...");
    //dpc_thread_object =
    hal_start_kernel_thread(dpc_thread);

#if !DPC_WAKE_TIMER
    SHOW_FLOW0( 1, " starting DPC waker thread...");
    //dpc_timed_waker_thread_object =
    hal_start_kernel_thread(dpc_timed_waker_thread);
#else
    dpc_timer_wake(0);
#endif

    while(!dpc_init_ok)
    {
        SHOW_FLOW0( 2, " wait for DPC threads...");
        hal_sleep_msec(1); // wait for thread to start
    }

    SHOW_FLOW0( 0, "DPC start done");
}
Example #5
0
static errno_t threads_test()
{

    hal_cond_init(&c, "threadTest");
    hal_mutex_init(&m, "threadTest");
    hal_sem_init(&s, "threadTest");

    int i = 40;
    n_t_empty = i;
    while(i-- > 0)
        phantom_create_thread( t_empty, "Empty", 0 );

    pressEnter("will create thread");
    phantom_create_thread( thread1, "__T1__", 0 );
    phantom_create_thread( thread1, "__T2__", 0 );
    //phantom_create_thread( thread1, "__T3__" );

    //phantom_create_thread( t_wait, "__TW__" );
    int tid = hal_start_kernel_thread_arg( t_wait, "__TW__" );

    i = 40;
    while(i-- > 0)
    {
        if(TEST_CHATTY) pressEnter("will yield");
        YIELD();

        if(TEST_CHATTY) printf("!! back in main\n");
    }

    t_kill_thread( tid );
    hal_sleep_msec( 30 );

    thread_stop_request = 1;
    hal_sleep_msec( 10 );

    thread_activity_counter = 0;
    hal_sleep_msec( 1000 );
    if( thread_activity_counter )
    {
        SHOW_ERROR0( 0, "Can't stop thread" );
        return -1;
    }

    while(n_t_empty > 0)
    {
        SHOW_FLOW( 0, "wait for %d threads", n_t_empty );
        hal_sleep_msec(500);
    }

    if(p._ah.refCount != 1)
    {
        SHOW_ERROR( 0, "p._ah.refCount = %d", p._ah.refCount );
        test_fail_msg( -1, "refcount" );
    }
    else
        SHOW_ERROR( 0, "p._ah.refCount = %d, SUCCESS", p._ah.refCount );

    return 0;
}
Example #6
0
wtty_t * wtty_init( size_t bufferSize )
{
    wtty_t *w = calloc( 1, sizeof(wtty_t) );
    assert(w);

#if CONF_WTTY_SIZE
    //w->size = WTTY_DEFAULT_BUFSIZE; // make to be param, check
    w->size = bufferSize;
    if( w->size < WTTY_MIN_BUFSIZE ) w->size = WTTY_MIN_BUFSIZE;

    w->buf = calloc( 1, w->size );
    assert(w->buf);
#endif

    //w->getpos = 0;
    //w->putpos = 0;
    hal_mutex_init( &w->mutex, "wtty" );
    hal_cond_init( &w->rcond, "wtty.r" );
    hal_cond_init( &w->wcond, "wtty.w" );

    w->started = 1;

    return w;
}
Example #7
0
void init_main_event_q()
{
    queue_init(&ev_unused_events);
    queue_init(&ev_main_event_q);

    hal_mutex_init( &ev_main_q_mutex, "Main EvQ" );
    hal_mutex_init( &ev_unused_q_mutex, "Free EvQ" );

    hal_cond_init( &ev_have_event, "UIEvent" );

    hal_mutex_lock( &ev_unused_q_mutex );
    int i = MIN_EVENT_POOL;
    while(i--)
        ev_allocate_event();
    hal_mutex_unlock( &ev_unused_q_mutex );

#if EVENTS_ENABLED
    hal_start_kernel_thread( ev_push_thread );


    ev_engine_active = 1;

#if KEY_EVENTS
    phantom_set_console_getchar( phantom_window_getc );
    hal_start_kernel_thread( ev_keyboard_read_thread );
#endif
#endif

#if DELIVER2THREAD
    hal_start_kernel_thread( w_event_deliver_thread );
#endif

#if VIDEO_NEW_BG_WIN
    w_bg_win_init();
#endif

}