Changeset 7bd34e5 in mainline


Ignore:
Timestamp:
2011-01-07T14:40:56Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8324b65
Parents:
92f924c8
Message:

Add synchronization via fibril_semaphore

WARNING: fibril_semaphore BREAKS the deadlock detection system
used by fibril synch primitives

Location:
uspace/drv/uhci
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/Makefile

    r92f924c8 r7bd34e5  
    3939        root_hub/root_hub.c \
    4040        uhci.c \
     41        utils/fibril_semaphore.c \
    4142        utils/hc_synchronizer.c
    4243
  • uspace/drv/uhci/root_hub/port.c

    r92f924c8 r7bd34e5  
    185185        return EOK;
    186186}
     187
    187188static usb_address_t assign_address_to_zero_device( device_t *hc )
    188189{
     
    211212
    212213        sync_value_t value;
     214        sync_init(&value);
    213215
    214216        uhci_setup(
     
    217219        uhci_print_verbose("address assignment sent, waiting to complete.\n");
    218220
    219 //      sync_wait_for(&value);
     221        sync_wait_for(&value);
    220222
    221223        uhci_print_info( "Assigned address %#x.\n", usb_address );
  • uspace/drv/uhci/utils/hc_synchronizer.c

    r92f924c8 r7bd34e5  
    11#include "hc_synchronizer.h"
    22
     3void sync_init(sync_value_t *value)
     4{
     5        assert(value);
     6        fibril_semaphore_initialize(&value->done, 0);
     7}
     8/*----------------------------------------------------------------------------*/
    39void sync_wait_for(sync_value_t *value)
    410{
    511        assert( value );
    6         value->waiting_fibril = fibril_get_id();
    7         uhci_print_verbose("turning off fibril %p.\n", value->waiting_fibril);
    8         fibril_switch(FIBRIL_TO_MANAGER);
     12        fibril_semaphore_down(&value->done);
    913}
    1014/*----------------------------------------------------------------------------*/
     
    1620        value->size = size;
    1721        value->result = result;
    18         fibril_add_ready(value->waiting_fibril);
     22        fibril_semaphore_up(&value->done);
    1923}
    2024/*----------------------------------------------------------------------------*/
     
    2529        assert(value);
    2630        value->result = result;
    27         uhci_print_verbose("resuming fibril %p.\n", value->waiting_fibril);
    28         fibril_add_ready(value->waiting_fibril);
     31        fibril_semaphore_up(&value->done);
    2932}
  • uspace/drv/uhci/utils/hc_synchronizer.h

    r92f924c8 r7bd34e5  
    3737#include <assert.h>
    3838#include <driver.h>
    39 #include <fibril.h>
    4039#include <usb/usb.h>
    4140
    4241#include "debug.h"
     42#include "utils/fibril_semaphore.h"
    4343
    4444typedef struct value
    4545{
    4646        /* TODO Think of better fibril synch to use */
    47         fid_t waiting_fibril;
    4847        usb_transaction_outcome_t result;
    4948        size_t size;
    50         bool done;
     49        fibril_semaphore_t done;
    5150} sync_value_t;
     51
     52void sync_init(sync_value_t *value);
    5253
    5354void sync_wait_for(sync_value_t *value);
Note: See TracChangeset for help on using the changeset viewer.