Ejemplo n.º 1
0
VoodooConnectionLink::VoodooConnectionLink( VoodooLink *link )
     :
     VoodooConnection( link )
{
     D_DEBUG_AT( Voodoo_Connection, "VoodooConnectionLink::%s( %p )\n", __func__, this );

     input.start   = 0;
     input.last    = 0;
     input.end     = 0;
     input.max     = 0;

     output.packets = NULL;
     output.sending = NULL;

     /* Initialize all locks. */
     direct_mutex_init( &output.lock );

     /* Initialize all wait conditions. */
     direct_waitqueue_init( &output.wait );

     /* Set default buffer limit. */
     input.max = VOODOO_CONNECTION_LINK_INPUT_BUF_MAX;

     /* Allocate buffers. */
     size_t input_buffer_size = VOODOO_CONNECTION_LINK_INPUT_BUF_MAX + VOODOO_PACKET_MAX + sizeof(VoodooPacketHeader);

     input.buffer = (u8*) D_MALLOC( input_buffer_size );

     D_INFO( "VoodooConnection/Link: Allocated "_ZU" kB input buffer at %p\n", input_buffer_size/1024, input.buffer );

     direct_tls_register( &output.tls, OutputTLS_Destructor );
}
Ejemplo n.º 2
0
DFBResult
CoreInputHub_Create( u32            queue_id,
                     CoreInputHub **ret_hub )
{
     DFBResult     ret;
     CoreInputHub *hub;

     D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ );

     D_ASSERT( ret_hub != NULL );

     ret = One_Initialize();
     if (ret)
          return ret;

     hub = D_CALLOC( 1, sizeof(CoreInputHub) );
     if (!hub)
          return D_OOM();

     direct_mutex_init( &hub->lock );

     ret = OneQueue_New( ONE_QUEUE_NO_FLAGS, queue_id, &hub->method_qid );
     if (ret)
          goto error;

     ret = OneQueue_New( ONE_QUEUE_VIRTUAL, ONE_QID_NONE, &hub->notify_qid );
     if (ret)
          goto error;

     ret = OneThread_Create( "Input Hub", &hub->thread );
     if (ret)
          goto error;

     ret = OneThread_AddQueue( hub->thread, hub->method_qid, CoreInputHub_Dispatch, hub );
     if (ret)
          goto error;

     D_INFO( "Core/Input/Hub: Running at QID %u\n", hub->method_qid );

     *ret_hub = hub;

     return DFB_OK;


error:
     if (hub->thread)
          OneThread_Destroy( hub->thread );

     if (hub->notify_qid)
          OneQueue_Destroy( hub->notify_qid );

     if (hub->method_qid)
          OneQueue_Destroy( hub->method_qid );

     direct_mutex_deinit( &hub->lock );

     D_FREE( hub );

     return ret;
}
Ejemplo n.º 3
0
void
__D_log_domain_init()
{
     domains_age = 1;

     direct_mutex_init( &domains_lock );
}
Ejemplo n.º 4
0
int
main( int argc, char *argv[] )
{
    DirectResult ret;

    if (parse_cmdline( argc, argv ))
        return -1;

    direct_mutex_init( &lock );
    direct_waitqueue_init( &queue );

    ret = One_Initialize();
    if (ret)
        return ret;

    ret = OneThread_Create( "OneTest", &thread );
    if (ret)
        return ret;

    ret = OneQueue_New( ONE_QUEUE_NO_FLAGS, queue_id, &queue_id );
    if (ret)
        return ret;

    D_INFO( "Queue ID %u\n", queue_id );

    TestWakeUp();

    direct_mutex_deinit( &lock );
    direct_waitqueue_deinit( &queue );

    return 0;
}
Ejemplo n.º 5
0
static DFBResult
dfb_colorhash_core_initialize( CoreDFB                *core,
                               DFBColorHashCore       *data,
                               DFBColorHashCoreShared *shared )
{
     D_DEBUG_AT( Core_ColorHash, "dfb_colorhash_core_initialize( %p, %p, %p )\n", core, data, shared );

     D_ASSERT( data != NULL );
     D_ASSERT( shared != NULL );

     core_colorhash = data; /* FIXME */

     data->core   = core;
     data->shared = shared;

     data->hash = D_CALLOC( HASH_SIZE, sizeof (Colorhash) );
     if (!data->hash)
          return D_OOM();

     direct_mutex_init( &data->hash_lock );

     D_MAGIC_SET( data, DFBColorHashCore );
     D_MAGIC_SET( shared, DFBColorHashCoreShared );

     return DFB_OK;
}
Ejemplo n.º 6
0
void
__D_perf_init()
{
     direct_hash_init( &counter_hash, 7 );
     direct_mutex_init( &counter_lock );

     if (direct_config->perf_dump_interval)
          direct_thread_create( DTT_DEFAULT, direct_perf_dump_thread, NULL, "Perf Dump" );
}
Ejemplo n.º 7
0
DFBResult
CoreInputHubClient_Create( u32                                 remote_qid,
                           const CoreInputHubClientCallbacks  *callbacks,
                           void                               *ctx,
                           CoreInputHubClient                **ret_client )
{
     DFBResult           ret;
     CoreInputHubClient *client;

     D_DEBUG_AT( Core_InputHub, "%s( QID 0x%08x )\n", __FUNCTION__, remote_qid );

     D_ASSERT( callbacks != NULL );
     D_ASSERT( ret_client != NULL );

     One_Initialize();

     client = D_CALLOC( 1, sizeof(CoreInputHubClient) );
     if (!client)
          return D_OOM();

     client->remote_qid = remote_qid;
     client->callbacks  = *callbacks;
     client->ctx        = ctx;

     ret = OneQueue_New( ONE_QUEUE_NO_FLAGS, ONE_QID_NONE, &client->listen_qid );
     if (ret)
          goto error;

     OneQueue_SetName( client->listen_qid, "InputHub/Listener" );

     ret = OneThread_Create( "Input Hub Client", &client->thread );
     if (ret)
          goto error;

     ret = OneThread_AddQueue( client->thread, client->listen_qid, CoreInputHubClient_Dispatch, client );
     if (ret)
          goto error;

     direct_mutex_init( &client->lock );
     direct_waitqueue_init( &client->wq );

     *ret_client = client;

     return DFB_OK;


error:
     if (client->thread)
          OneThread_Destroy( client->thread );

     if (client->listen_qid)
          OneQueue_Destroy( client->listen_qid );

     D_FREE( client );

     return ret;
}
Ejemplo n.º 8
0
DirectResult
direct_processor_init( DirectProcessor            *processor,
                       const char                 *name,
                       const DirectProcessorFuncs *funcs,
                       unsigned int                data_size,
                       void                       *context,
                       int                         idle_ms )
{
     D_ASSERT( processor != NULL );
     D_ASSERT( name != NULL );
     D_ASSERT( funcs != NULL );
     D_ASSERT( funcs->Process != NULL );
     D_ASSERT( data_size > 0 );

     D_DEBUG_AT( Direct_Processor, "%s( %p, %p, %p, %u, %p )\n", __FUNCTION__,
                 processor, name, funcs, data_size, context );

     processor->name = D_STRDUP( name );
     if (!processor->name)
          return D_OOM();

     processor->funcs        = funcs;
     processor->data_size    = data_size;
     processor->context      = context;
     processor->idle_ms      = idle_ms;
     processor->max_recycled = (8000 / data_size) + 1;

     direct_fifo_init( &processor->commands );
     direct_fifo_init( &processor->recycled );

#if 0
     direct_waitqueue_init( &processor->lock_cond, NULL );
     direct_mutex_init( &processor->lock_mutex, NULL );
#endif

     D_MAGIC_SET( processor, DirectProcessor );

     processor->thread = direct_thread_create( DTT_DEFAULT, processor_thread, processor, name );
     if (!processor->thread) {
          D_MAGIC_CLEAR( processor );
          direct_fifo_destroy( &processor->commands );
          direct_fifo_destroy( &processor->recycled );
          D_FREE( processor->name );
          return DR_INIT;
     }

     return DR_OK;
}
Ejemplo n.º 9
0
VoodooDispatcher::VoodooDispatcher( VoodooManager *manager )
     :
     magic(0),
     manager(manager),
     packets(NULL)
{
     D_DEBUG_AT( Voodoo_Dispatcher, "VoodooDispatcher::%s( %p )\n", __func__, this );

     /* Initialize lock. */
     direct_mutex_init( &lock );

     /* Initialize wait queue. */
     direct_waitqueue_init( &queue );

     D_MAGIC_SET( this, VoodooDispatcher );


     dispatch_loop = direct_thread_create( DTT_MESSAGING, DispatchLoopMain, this, "Voodoo Dispatch" );
}
Ejemplo n.º 10
0
static DFBResult
drmkmsInitLayer( CoreLayer                  *layer,
                 void                       *driver_data,
                 void                       *layer_data,
                 DFBDisplayLayerDescription *description,
                 DFBDisplayLayerConfig      *config,
                 DFBColorAdjustment         *adjustment )
{
     DRMKMSData       *drmkms = driver_data;
     DRMKMSDataShared *shared = drmkms->shared;
     DRMKMSLayerData  *data   = layer_data;

     D_DEBUG_AT( DRMKMS_Layer, "%s()\n", __FUNCTION__ );


     data->index       = shared->layerplane_index_count++;
     data->layer_index = shared->layer_index_count++;
     data->level       = 0;

     description->type             = DLTF_GRAPHICS;
     description->caps             = DLCAPS_SURFACE;
     description->surface_caps     = DSCAPS_NONE;
     description->surface_accessor = CSAID_LAYER0;

     direct_snputs( description->name, "DRMKMS Layer", DFB_DISPLAY_LAYER_DESC_NAME_LENGTH );


     config->flags       = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
     config->width       = dfb_config->mode.width  ?: shared->mode[data->layer_index].hdisplay;
     config->height      = dfb_config->mode.height ?: shared->mode[data->layer_index].vdisplay;

     config->pixelformat = dfb_config->mode.format ?: DSPF_ARGB;
     config->buffermode  = DLBM_FRONTONLY;

     direct_mutex_init( &data->lock );

     direct_waitqueue_init( &data->wq_event );

     return DFB_OK;
}
Ejemplo n.º 11
0
static DFBResult
mesaInitLayer( CoreLayer                  *layer,
               void                       *driver_data,
               void                       *layer_data,
               DFBDisplayLayerDescription *description,
               DFBDisplayLayerConfig      *config,
               DFBColorAdjustment         *adjustment )
{
     MesaData *mesa = driver_data;


     mesa->drmeventcontext.version = DRM_EVENT_CONTEXT_VERSION;
     mesa->drmeventcontext.vblank_handler = NULL;
     mesa->drmeventcontext.page_flip_handler = page_flip_handler;

     description->type             = DLTF_GRAPHICS;
     description->caps             = DLCAPS_SURFACE;
     description->surface_caps     = DSCAPS_NONE;
     description->surface_accessor = CSAID_LAYER0;

     direct_snputs( description->name, "Mesa Layer", DFB_DISPLAY_LAYER_DESC_NAME_LENGTH );


     config->flags       = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT;
     config->width       = dfb_config->mode.width  ?: mesa->mode.hdisplay;
     config->height      = dfb_config->mode.height ?: mesa->mode.vdisplay;
     config->pixelformat = dfb_config->mode.format ?: DSPF_ARGB;
     config->buffermode  = DLBM_FRONTONLY;


     direct_mutex_init( &mesa->lock );
     direct_waitqueue_init( &mesa->wq_event );
     direct_waitqueue_init( &mesa->wq_flip );

     mesa->thread = direct_thread_create( DTT_CRITICAL, Mesa_BufferThread_Main, mesa, "Mesa/Buffer" );

     return DFB_OK;
}
Ejemplo n.º 12
0
int
main( int argc, char *argv[] )
{
    DirectResult  ret;
    IFusionDale  *dale;
    int           i;

    //dfb_config_init( &argc, &argv );

    ret = FusionDaleInit( &argc, &argv );
    if (ret) {
        D_DERROR( ret, "FusionDaleInit() failed!\n" );
        return -1;
    }

    ret = FusionDaleCreate( &dale );
    if (ret) {
        D_DERROR( ret, "FusionDaleCreate() failed!\n" );
        return -2;
    }

    ret = dale->EnterComa( dale, "Coma Test", &coma );
    if (ret) {
        D_DERROR( ret, "IFusionDale::EnterComa('Coma Test') failed!\n" );
        return -3;
    }

    direct_mutex_init( &decoupled_calls_lock );
    direct_waitqueue_init( &decoupled_calls_wq );

    for (i=1; i<argc; i++) {
        if (strncmp( argv[i], "create", 6 ) == 0) {
            int n, num;
            int threads = 1;

            if (sscanf( argv[i]+6, "%d,%d", &num, &threads ) >= 1) {
                for (n=0; n<num; n++) {
                    RUN_create( n );
                }

                for (n=0; n<threads; n++) {
                    direct_thread_create( DTT_DEFAULT, DecoupledCall_thread_main, NULL, "Process" );
                }

                pause();
            }
            else
                fprintf( stderr, "Wrong number '%s'!\n", argv[i]+6 );
        }
        else if (strncmp( argv[i], "call", 4 ) == 0) {
            int index, threads = 1;

            if (sscanf( argv[i]+4, "%d,%d", &index, &threads ) >= 1) {
                RUN_call_threaded( index, threads );
            }
            else
                fprintf( stderr, "Wrong number '%s'!\n", argv[i]+4 );
        }
    }

    direct_waitqueue_deinit( &decoupled_calls_wq );
    direct_mutex_deinit( &decoupled_calls_lock );

    coma->Release( coma );

    dale->Release( dale );

    return 0;
}
 ClientList()
 {
      direct_mutex_init( &lock );
 }
Ejemplo n.º 14
0
void
__D_result_init()
{
     direct_mutex_init( &result_mutex );
}
Ejemplo n.º 15
0
DirectResult
voodoo_link_init_connect( VoodooLink *link,
                          const char *hostname,
                          int         port,
                          bool        raw )
{
     int                 ret; 
     struct sockaddr_in  addr;
     Link               *l;

     D_INFO( "Voodoo/Link: Connecting to '%s:%d'...\n", hostname, port );

     StartWinsock();

     l = D_CALLOC( 1, sizeof(Link) );
     if (!l)
          return D_OOM();

     l->socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
     if (l->socket == INVALID_SOCKET) {
          ret = errno2result( errno );
          D_PERROR( "Voodoo/Link: Socket creation failed!\n" );
          D_FREE( l );
          return ret;
     }

     addr.sin_family      = AF_INET;
     addr.sin_addr.s_addr = inet_addr( hostname );
     addr.sin_port        = htons( port );

     ret = connect( l->socket, (const struct sockaddr*) &addr, sizeof(addr) );
     if (ret < 0) {
          ret = errno2result( errno );
          D_PERROR( "Voodoo/Link: Socket connect failed!\n" );
          // FIXME: how to close the socket?
          D_FREE( l );
          return ret;
     }

     direct_mutex_init( &l->lock );

     l->event  = WSACreateEvent();

     if (!raw) {
          link->code = 0x80008676;

          if (send( l->socket, (const char*) &link->code, sizeof(link->code), 0 ) != 4) {
               D_ERROR( "Voodoo/Link: Coult not write initial four bytes!\n" );
               // FIXME: how to close the socket?
               D_FREE( l );
               return DR_IO;
          }
     }

     link->priv        = l;
     link->Close       = Close;
     link->Read        = Read;
     link->Write       = Write;
     link->SendReceive = SendReceive;
     link->WakeUp      = WakeUp;
     link->WaitForData = WaitForData;

     return DR_OK;
}
Ejemplo n.º 16
0
void
__D_mem_init()
{
     direct_mutex_init( &alloc_lock );
}