Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/root_hub.c

    r7d521e24 rb2387c2  
    5757        .device_version = 0,
    5858        .length = sizeof (usb_standard_device_descriptor_t),
    59         /// \TODO this value is guessed
    6059        .max_packet_size = 8,
    6160        .vendor_id = 0x16db,
    6261        .product_id = 0x0001,
    63         /// \TODO these values migt be different
    6462        .str_serial_number = 0,
    6563        .usb_spec_version = 0x110,
     
    118116 */
    119117static const uint32_t hub_clear_feature_by_writing_one_mask =
    120    RHS_CLEAR_PORT_POWER;
    121    // 1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
     118    RHS_CLEAR_PORT_POWER;
    122119
    123120/**
     
    127124    RHS_LPSC_FLAG |
    128125    RHS_OCIC_FLAG;
    129     //(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
    130     //(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
    131126
    132127/**
     
    135130static const uint32_t hub_set_feature_direct_mask =
    136131    RHS_SET_PORT_POWER;
    137     //(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
    138132
    139133/**
     
    160154    RHPS_PRSC_FLAG;
    161155
    162 /*
    163 
    164     (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
    165     (1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    166     (1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) |
    167     (1 << USB_HUB_FEATURE_PORT_POWER) |
    168     (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
    169     (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
    170     (1 << USB_HUB_FEATURE_C_PORT_SUSPEND) |
    171     (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
    172     (1 << USB_HUB_FEATURE_C_PORT_RESET);
    173  */
    174156//note that USB_HUB_FEATURE_PORT_POWER bit is translated into
    175157//USB_HUB_FEATURE_PORT_LOW_SPEED for port set feature request
     
    179161 */
    180162static const uint32_t port_status_change_mask = RHPS_CHANGE_WC_MASK;
    181 /*    (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
    182     (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
    183     (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
    184     (1 << USB_HUB_FEATURE_C_PORT_RESET) |
    185     (1 << USB_HUB_FEATURE_C_PORT_SUSPEND);
    186 */
    187163
    188164static int create_serialized_hub_descriptor(rh_t *instance);
     
    420396 * create answer to port status_request
    421397 *
    422  * Copy content of corresponding port status register to answer buffer.
     398 * Copy content of corresponding port status register to answer buffer. The
     399 * format of the port status register and port status data is the same (
     400 * see OHCI root hub and USB hub documentation).
    423401 *
    424402 * @param instance root hub instance
     
    431409        if (port < 1 || port > instance->port_count)
    432410                return EINVAL;
    433         uint32_t * uint32_buffer = (uint32_t*) request->data_buffer;
    434411        request->transfered_size = 4;
    435         uint32_buffer[0] = instance->registers->rh_port_status[port - 1];
     412        uint32_t data = instance->registers->rh_port_status[port - 1];
     413        memcpy(request->data_buffer, &data, 4);
    436414#if 0
    437415        int i;
     
    450428 * create answer to port status_request
    451429 *
    452  * Copy content of hub status register to answer buffer.
     430 * This copies flags in hub status register into the buffer. The format of the
     431 * status register and status message is the same, according to USB hub
     432 * specification and OHCI root hub specification.
    453433 *
    454434 * @param instance root hub instance
     
    458438static int process_get_hub_status_request(rh_t *instance,
    459439    usb_transfer_batch_t * request) {
    460         uint32_t * uint32_buffer = (uint32_t*) request->data_buffer;
     440        //uint32_t * uint32_buffer = (uint32_t*) request->data_buffer;
    461441        request->transfered_size = 4;
    462442        //bits, 0,1,16,17
    463443        uint32_t mask = 1 | (1 << 1) | (1 << 16) | (1 << 17);
    464         uint32_buffer[0] = mask & instance->registers->rh_status;
     444        uint32_t data = mask & instance->registers->rh_status;
     445        //uint32_buffer[0] = mask & instance->registers->rh_status;
     446        memcpy(request->data_buffer, &data, 4);
    465447
    466448        return EOK;
     
    485467
    486468        usb_hub_bm_request_type_t request_type = request_packet->request_type;
    487         if (buffer_size < 4/*request_packet->length*/) {///\TODO
     469        if (buffer_size < 4) {
    488470                usb_log_warning("requested more data than buffer size\n");
    489471                return EINVAL;
     
    516498            | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
    517499        bzero(bitmap, instance->interrupt_mask_size);
    518         if (instance->registers->rh_status & mask) {
     500        if ((instance->registers->rh_status & mask) != 0) {
    519501                bitmap[0] = 1;
    520502        }
     
    522504        mask = port_status_change_mask;
    523505        for (port = 1; port <= instance->port_count; ++port) {
    524                 if (mask & instance->registers->rh_port_status[port - 1]) {
     506                if ((mask & instance->registers->rh_port_status[port - 1]) != 0) {
    525507
    526508                        bitmap[(port) / 8] += 1 << (port % 8);
     
    695677            (instance->registers->rh_port_status[port - 1] | (1 << feature))
    696678            & (~port_clear_feature_valid_mask);
    697         /// \TODO any error?
    698 
    699679        return EOK;
    700680}
     
    724704            & (~port_clear_feature_valid_mask))
    725705            | (1 << feature);
    726         /// \TODO any error?
    727706
    728707        return EOK;
     
    942921 * @return
    943922 */
    944 static int process_interrupt_mask_in_instance(rh_t *instance, usb_transfer_batch_t * request) {
     923static int process_interrupt_mask_in_instance(rh_t *instance,
     924    usb_transfer_batch_t * request) {
    945925        memcpy(request->data_buffer, instance->interrupt_buffer,
    946926            instance->interrupt_mask_size);
     
    962942 * @return
    963943 */
    964 static bool is_zeros(void * buffer, size_t size) {
     944static bool is_zeros(void *buffer, size_t size) {
    965945        if (!buffer) return true;
    966946        if (!size) return true;
Note: See TracChangeset for help on using the changeset viewer.