Changeset d81ef61c in mainline


Ignore:
Timestamp:
2011-02-18T14:24:55Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
50ba203
Parents:
fe1776c2
Message:

uncompilable changes, partially applying pipe api

Location:
uspace/drv/usbhub
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/usbhub.c

    rfe1776c2 rd81ef61c  
    4141#include <usb/descriptor.h>
    4242#include <usb/devreq.h>
     43#include <usb/request.h>
    4344#include <usb/classes/hub.h>
    4445
     
    4748#include "port_status.h"
    4849#include "usb/usb.h"
     50#include "usb/pipes.h"
    4951
    5052static usb_iface_t hub_usb_iface = {
     
    6264//*********************************************
    6365
    64 usb_hub_info_t * usb_create_hub_info(device_t * device, int hc) {
     66usb_hub_info_t * usb_create_hub_info(device_t * device) {
    6567        usb_hub_info_t* result = usb_new(usb_hub_info_t);
     68        usb_device_connection_initialize_from_device(&result->connection, device);
     69        usb_endpoint_pipe_initialize_default_control(&result->endpoints.control,
     70            &result->connection);
     71       
     72
    6673        //result->device = device;
    6774        result->port_count = -1;
     
    6976        result->device = device;
    7077
    71 
    72         dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);
    73         if (hc < 0) {
    74                 return result;
    75         }
    76         //get some hub info
    77         usb_address_t addr = usb_drv_get_my_address(hc, device);
    78         dprintf(USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr);
    79         /*if(addr<0){
    80                 //return result;
    81 
    82         }*/
    83 
    8478        result->usb_device = usb_new(usb_hcd_attached_device_info_t);
    85         result->usb_device->address = addr;
    86 
     79       
    8780        // get hub descriptor
    8881
     
    9386        int opResult;
    9487        dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
    95        
    96         opResult = usb_drv_req_get_descriptor(hc, addr,
     88        usb_endpoint_pipe_start_session(&result->endpoints.control);
     89        opResult = usb_request_get_descriptor(&result->endpoints.control,
    9790                        USB_REQUEST_TYPE_CLASS,
    9891                        USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
    9992                        USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
     93        usb_endpoint_pipe_end_session(&result->endpoints.control);
     94
     95        /* Initialize the interrupt endpoint.
     96        usb_endpoint_pipe_initalize(
     97                &hub_data->endpoints->status_change,
     98                &endpiont_descriptor, &hub_data->connection);
     99
     100         */ /// \TODO add this call
    100101
    101102        if (opResult != EOK) {
     
    142143        dev->ops = &hub_device_ops;
    143144
    144         //create the hub structure
    145         //get hc connection
    146         int hc = usb_drv_hc_connect_auto(dev, 0);
    147         if (hc < 0) {
    148                 return hc;
    149         }
    150 
    151         usb_hub_info_t * hub_info = usb_create_hub_info(dev, hc);
     145
     146        usb_hub_info_t * hub_info = usb_create_hub_info(dev);
     147        usb_endpoint_pipe_start_session(&hub_info->endpoints.control);
    152148        int port;
    153149        int opResult;
    154         usb_target_t target;
    155         target.address = hub_info->usb_device->address;
    156         target.endpoint = 0;
     150        //usb_target_t target;
     151        //target.address = hub_info->usb_device->address;
     152        //target.endpoint = 0;
    157153
    158154        //get configuration descriptor
     
    160156        // and all should be checked
    161157        usb_standard_device_descriptor_t std_descriptor;
    162         opResult = usb_drv_req_get_device_descriptor(hc, target.address,
     158        opResult = usb_request_get_device_descriptor(&hub_info->endpoints.control,
    163159            &std_descriptor);
    164160        if(opResult!=EOK){
     
    173169        /// \TODO check other configurations
    174170        usb_standard_configuration_descriptor_t config_descriptor;
    175         opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
    176         target.address, 0,
     171        opResult = usb_request_get_bare_configuration_descriptor(
     172            &hub_info->endpoints.control, 0,
    177173        &config_descriptor);
    178174        if(opResult!=EOK){
     
    181177        }
    182178        //set configuration
    183         opResult = usb_drv_req_set_configuration(hc, target.address,
     179        opResult = usb_request_set_configuration(&hub_info->endpoints.control,
    184180    config_descriptor.configuration_number);
    185181
     
    191187        for (port = 1; port < hub_info->port_count+1; ++port) {
    192188                usb_hub_set_power_port_request(&request, port);
    193                 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
     189                opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control,
     190                                &request,sizeof(usb_device_request_setup_packet_t), NULL, 0);
    194191                dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port);
    195192                if (opResult != EOK) {
     
    199196        //ports powered, hub seems to be enabled
    200197
    201         async_hangup(hc);
     198        usb_endpoint_pipe_end_session(&hub_info->endpoints.control);
     199        //async_hangup(hc);
    202200
    203201        //add the hub to list
     
    251249 * @param target
    252250 */
    253 static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
     251static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port) {
    254252        usb_device_request_setup_packet_t request;
    255253        int opResult;
    256254        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    257255        //get default address
     256        ///////////////here ended pipe api upgrading
     257        gfdl;gfdgldglglkfgklfjfkld;sjgk;fgklsjgld
    258258        opResult = usb_drv_reserve_default_address(hc);
    259259        if (opResult != EOK) {
     
    374374 * @param target
    375375 */
    376 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
    377         uint16_t port, usb_address_t address) {
     376static void usb_hub_process_interrupt(usb_hub_info_t * hub,
     377        uint16_t port) {
    378378        dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);
    379379        //determine type of change
     380        int opResult = usb_endpoint_pipe_start_session(&hub->endpoints.control);
     381        usb_endpoint_pipe_t *pipe = &hub->endpoints.control;
     382        if(opResult != EOK){
     383                continue;
     384        }
     385
     386        /*
    380387        usb_target_t target;
    381388        target.address=address;
    382389        target.endpoint=0;
     390        */
     391
    383392        usb_port_status_t status;
    384393        size_t rcvd_size;
    385394        usb_device_request_setup_packet_t request;
    386         int opResult;
     395        //int opResult;
    387396        usb_hub_set_port_status_request(&request, port);
    388397        //endpoint 0
    389398
    390         opResult = usb_drv_sync_control_read(
    391                         hc, target,
    392                         &request,
     399        opResult = usb_endpoint_pipe_control_read(
     400                        pipe,
     401                        &request, sizeof(usb_device_request_setup_packet_t),
    393402                        &status, 4, &rcvd_size
    394403                        );
     
    403412        //something connected/disconnected
    404413        if (usb_port_connect_change(&status)) {
    405                 opResult = usb_hub_clear_port_feature(hc, target.address,
     414                opResult = usb_hub_clear_port_feature(&hub->endpoints.control,
    406415                    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
    407416                // TODO: check opResult
    408417                if (usb_port_dev_connected(&status)) {
    409418                        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    410                         usb_hub_init_add_device(hc, port, target);
     419                        usb_hub_init_add_device(hub, port);
    411420                } else {
    412                         usb_hub_removed_device(hub, hc, port, target);
     421                        usb_hub_removed_device(hub, port);
    413422                }
    414423        }
     
    417426                dprintf(USB_LOG_LEVEL_INFO, "port reset complete");
    418427                if (usb_port_enabled(&status)) {
    419                         usb_hub_finalize_add_device(hub, hc, port, target);
     428                        usb_hub_finalize_add_device(hub, port);
    420429                } else {
    421430                        dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled");
     
    433442        /// \TODO handle other changes
    434443        /// \TODO debug log for various situations
     444        usb_endpoint_pipe_end_session(&hub->endpoints.control);
     445
    435446
    436447}
     
    450461                fibril_mutex_unlock(&usb_hub_list_lock);
    451462                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
     463                int opResult;
     464
     465                opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change);
     466                if(opResult != EOK){
     467                        continue;
     468                }
    452469                /*
    453470                 * Check status change pipe of this hub.
    454471                 */
    455 
     472                /*
    456473                usb_target_t target;
    457474                target.address = hub_info->usb_device->address;
     
    459476                dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
    460477                    target.address);
    461 
     478                */
    462479                size_t port_count = hub_info->port_count;
    463480
    464481                /*
    465482                 * Connect to respective HC.
    466                  */
     483                 *
    467484                int hc = usb_drv_hc_connect_auto(hub_info->device, 0);
    468485                if (hc < 0) {
    469486                        continue;
    470                 }
     487                }*/
    471488
    472489                /// FIXME: count properly
     
    480497                 * Send the request.
    481498                 */
    482                 int opResult = usb_drv_async_interrupt_in(hc, target,
     499                opResult = usb_endpoint_pipe_read(
     500                                &hub_info->endpoints.status_change,
    483501                                change_bitmap, byte_length, &actual_size,
    484                                 &handle);
     502                                );
    485503
    486504                usb_drv_async_wait_for(handle);
     
    497515                        if (interrupt) {
    498516                                usb_hub_process_interrupt(
    499                                         hub_info, hc, port, hub_info->usb_device->address);
     517                                        hub_info, port);
    500518                        }
    501519                }
     520                usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    502521                free(change_bitmap);
    503 
    504                 async_hangup(hc);
     522               
     523
     524                //async_hangup(hc);
    505525                fibril_mutex_lock(&usb_hub_list_lock);
    506526        }
  • uspace/drv/usbhub/usbhub.h

    rfe1776c2 rd81ef61c  
    4040#include "usb/hcdhubd.h"
    4141
     42#include <usb/pipes.h>
     43
    4244/** basic information about device attached to hub */
    4345typedef struct{
     
    4648}usb_hub_attached_device_t;
    4749
     50/* Hub endpoints. */
     51typedef struct {
     52        usb_endpoint_pipe_t control;
     53        usb_endpoint_pipe_t status_change;
     54} usb_hub_endpoints_t;
     55
     56
     57
    4858/** Information about attached hub. */
    4959typedef struct {
    5060        /** Number of ports. */
    5161        int port_count;
    52         /** attached device handles */
     62        /** attached device handles, for each port one */
    5363        usb_hub_attached_device_t * attached_devs;
    5464        /** General usb device info. */
     
    5666        /** General device info*/
    5767        device_t * device;
     68        /** connection to hcd */
     69        usb_device_connection_t connection;
     70        /** hub endpoints */
     71        usb_hub_endpoints_t endpoints;
    5872
    5973} usb_hub_info_t;
  • uspace/drv/usbhub/usbhub_private.h

    rfe1776c2 rd81ef61c  
    7777 * @return
    7878 */
    79 usb_hub_info_t * usb_create_hub_info(device_t * device, int hc);
     79usb_hub_info_t * usb_create_hub_info(device_t * device);
    8080
    8181/** List of hubs maanged by this driver */
     
    9898 * @return error code
    9999 */
     100/*
    100101int usb_drv_sync_control_read(
    101     int phone, usb_target_t target,
     102    usb_endpoint_pipe_t *pipe,
    102103    usb_device_request_setup_packet_t * request,
    103104    void * rcvd_buffer, size_t rcvd_size, size_t * actual_size
    104 );
     105);*/
    105106
    106107/**
     
    115116 * @return error code
    116117 */
    117 int usb_drv_sync_control_write(
    118     int phone, usb_target_t target,
     118/*int usb_drv_sync_control_write(
     119    usb_endpoint_pipe_t *pipe,
    119120    usb_device_request_setup_packet_t * request,
    120121    void * sent_buffer, size_t sent_size
    121 );
     122);*/
    122123
    123124/**
     
    147148 * @return Operation result
    148149 */
    149 static inline int usb_hub_clear_port_feature(int hc, usb_address_t address,
     150static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe,
    150151    int port_index,
    151152    usb_hub_class_feature_t feature) {
    152         usb_target_t target = {
    153                 .address = address,
    154                 .endpoint = 0
    155         };
     153       
    156154        usb_device_request_setup_packet_t clear_request = {
    157155                .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
     
    161159        };
    162160        clear_request.value = feature;
    163         return usb_drv_psync_control_write(hc, target, &clear_request,
     161        return usb_endpoint_pipe_control_write(pipe, &clear_request,
    164162            sizeof(clear_request), NULL, 0);
    165163}
Note: See TracChangeset for help on using the changeset viewer.