Changeset 82122f3 in mainline for uspace/drv


Ignore:
Timestamp:
2010-12-17T14:51:41Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1f383dde
Parents:
692f13e4 (diff), 11658b64 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged development into lelian/hidd

Location:
uspace/drv
Files:
4 added
1 deleted
22 edited
1 moved

Legend:

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

    r692f13e4 r82122f3  
    887887    ipc_call_t *call)
    888888{
    889         ipcarg_t method = IPC_GET_METHOD(*call);
     889        sysarg_t method = IPC_GET_IMETHOD(*call);
    890890        int ret;
    891891        unsigned int baud_rate, parity, word_length, stop_bits;
  • uspace/drv/uhci/main.c

    r692f13e4 r82122f3  
    2929#include <usb/debug.h>
    3030#include <errno.h>
     31#include <driver.h>
    3132#include "uhci.h"
    3233
  • uspace/drv/usbhub/main.c

    r692f13e4 r82122f3  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #include <usb/usbdrv.h>
     28
    2929#include <driver.h>
    3030#include <errno.h>
     31#include <async.h>
     32
     33#include <usb/usbdrv.h>
    3134#include "usbhub.h"
    3235#include "usbhub_private.h"
     
    4447};
    4548
     49int usb_hub_control_loop(void * noparam){
     50        while(true){
     51                usb_hub_check_hub_changes();
     52                async_usleep(1000 * 1000);
     53        }
     54        return 0;
     55}
     56
     57
    4658int main(int argc, char *argv[])
    4759{
    4860        usb_lst_init(&usb_hub_list);
     61        fid_t fid = fibril_create(usb_hub_control_loop, NULL);
     62        if (fid == 0) {
     63                printf("%s: failed to start fibril for HUB devices\n", NAME);
     64                return ENOMEM;
     65        }
     66        fibril_add_ready(fid);
     67
    4968        return driver_main(&hub_driver);
    5069}
  • uspace/drv/usbhub/port_status.h

    r692f13e4 r82122f3  
    5555        request->index = port;
    5656        request->request_type = USB_HUB_REQ_TYPE_GET_PORT_STATUS;
    57         request->request = USB_HUB_REQUEST_GET_STATE;
     57        request->request = USB_HUB_REQUEST_GET_STATUS;
    5858        request->value = 0;
    5959        request->length = 4;
  • uspace/drv/usbhub/usbhub.h

    r692f13e4 r82122f3  
    4040#include "usb/hcdhubd.h"
    4141
    42 
     42/** basic information about device attached to hub */
     43typedef struct{
     44        usb_address_t address;
     45        devman_handle_t devman_handle;
     46}usb_hub_attached_device_t;
    4347
    4448/** Information about attached hub. */
     
    4650        /** Number of ports. */
    4751        int port_count;
    48         /** General device info. */
    49         usb_hcd_attached_device_info_t * device;
     52        /** attached device handles */
     53        usb_hub_attached_device_t * attached_devs;
     54        /** General usb device info. */
     55        usb_hcd_attached_device_info_t * usb_device;
     56        /** General device info*/
     57        device_t * device;
     58
    5059} usb_hub_info_t;
    5160
    52 int usb_add_hub_device(device_t *);
     61/**
     62 * function running the hub-controlling loop.
     63 * @param noparam fundtion does not need any parameters
     64 */
     65int usb_hub_control_loop(void * noparam);
     66
     67/** Callback when new hub device is detected.
     68 *
     69 * @param dev New device.
     70 * @return Error code.
     71 */
     72int usb_add_hub_device(device_t *dev);
     73
     74/**
     75 * check changes on all registered hubs
     76 */
     77void usb_hub_check_hub_changes(void);
     78
     79
     80//int usb_add_hub_device(device_t *);
     81
     82
    5383
    5484#endif
  • uspace/drv/usbhub/usbhub.ma

    r692f13e4 r82122f3  
    1110 usb&hub
     210 usb&class=hub
  • uspace/drv/usbhub/usbhub_private.h

    r692f13e4 r82122f3  
    182182}
    183183
     184static inline int usb_hub_clear_port_feature(int hc, usb_address_t address,
     185    int port_index,
     186    usb_hub_class_feature_t feature) {
     187        usb_target_t target = {
     188                .address = address,
     189                .endpoint = 0
     190        };
     191        usb_device_request_setup_packet_t clear_request = {
     192                .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
     193                .request = USB_DEVREQ_CLEAR_FEATURE,
     194                .length = 0,
     195                .index = port_index
     196        };
     197        clear_request.value = feature;
     198        return usb_drv_psync_control_write(hc, target, &clear_request,
     199            sizeof(clear_request), NULL, 0);
     200}
     201
    184202
    185203
  • uspace/drv/usbhub/utils.c

    r692f13e4 r82122f3  
    3434 */
    3535#include <driver.h>
    36 #include <usb/devreq.h>
     36#include <bool.h>
     37#include <errno.h>
     38
    3739#include <usbhc_iface.h>
    3840#include <usb/usbdrv.h>
    3941#include <usb/descriptor.h>
    40 #include <driver.h>
    41 #include <bool.h>
    42 #include <errno.h>
     42#include <usb/devreq.h>
    4343#include <usb/classes/hub.h>
     44
    4445#include "usbhub.h"
    4546#include "usbhub_private.h"
    4647#include "port_status.h"
    47 #include <usb/devreq.h>
    48 
    49 static void check_hub_changes(void);
     48
    5049
    5150size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71;
     
    302301        //result->device = device;
    303302        result->port_count = -1;
     303        /// \TODO is this correct? is the device stored?
     304        result->device = device;
    304305
    305306
     
    316317        }*/
    317318
    318         result->device = usb_new(usb_hcd_attached_device_info_t);
    319         result->device->address = addr;
     319        result->usb_device = usb_new(usb_hcd_attached_device_info_t);
     320        result->usb_device->address = addr;
    320321
    321322        // get hub descriptor
     
    350351        //printf("[usb_hub] setting port count to %d\n",descriptor->ports_count);
    351352        result->port_count = descriptor->ports_count;
     353        result->attached_devs = (usb_hub_attached_device_t*)
     354            malloc((result->port_count+1) * sizeof(usb_hub_attached_device_t));
     355        int i;
     356        for(i=0;i<result->port_count+1;++i){
     357                result->attached_devs[i].devman_handle=0;
     358                result->attached_devs[i].address=0;
     359        }
    352360        //printf("[usb_hub] freeing data\n");
    353361        free(serialized_descriptor);
     
    362370}
    363371
    364 /** Callback when new hub device is detected.
    365  *
    366  * @param dev New device.
    367  * @return Error code.
    368  */
    369372int usb_add_hub_device(device_t *dev) {
    370373        printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle);
     
    387390        usb_device_request_setup_packet_t request;
    388391        usb_target_t target;
    389         target.address = hub_info->device->address;
     392        target.address = hub_info->usb_device->address;
    390393        target.endpoint = 0;
    391         for (port = 0; port < hub_info->port_count; ++port) {
     394
     395        //get configuration descriptor
     396        // this is not fully correct - there are more configurations
     397        // and all should be checked
     398        usb_standard_device_descriptor_t std_descriptor;
     399        opResult = usb_drv_req_get_device_descriptor(hc, target.address,
     400    &std_descriptor);
     401        if(opResult!=EOK){
     402                printf("[usb_hub] could not get device descriptor, %d\n",opResult);
     403                return 1;///\TODO some proper error code needed
     404        }
     405        printf("[usb_hub] hub has %d configurations\n",std_descriptor.configuration_count);
     406        if(std_descriptor.configuration_count<1){
     407                printf("[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE\n");
     408        }
     409        usb_standard_configuration_descriptor_t config_descriptor;
     410        opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
     411        target.address, 0,
     412        &config_descriptor);
     413        if(opResult!=EOK){
     414                printf("[usb_hub] could not get configuration descriptor, %d\n",opResult);
     415                return 1;///\TODO some proper error code needed
     416        }
     417        //set configuration
     418        request.request_type = 0;
     419        request.request = USB_DEVREQ_SET_CONFIGURATION;
     420        request.index=0;
     421        request.length=0;
     422        request.value_high=0;
     423        request.value_low = config_descriptor.configuration_number;
     424        opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
     425        if (opResult != EOK) {
     426                printf("[usb_hub]something went wrong when setting hub`s configuration, %d\n", opResult);
     427        }
     428
     429
     430        for (port = 1; port < hub_info->port_count+1; ++port) {
    392431                usb_hub_set_power_port_request(&request, port);
    393432                opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
     433                printf("[usb_hub] powering port %d\n",port);
    394434                if (opResult != EOK) {
    395435                        printf("[usb_hub]something went wrong when setting hub`s %dth port\n", port);
     
    397437        }
    398438        //ports powered, hub seems to be enabled
     439       
    399440
    400441        ipc_hangup(hc);
     
    404445        printf("[usb_hub] hub info added to list\n");
    405446        //(void)hub_info;
    406         check_hub_changes();
     447        usb_hub_check_hub_changes();
    407448
    408449        /// \TODO start the check loop, if not already started...
     
    412453
    413454        printf("[usb_hub] hub dev added\n");
     455        printf("\taddress %d, has %d ports \n",
     456                        hub_info->usb_device->address,
     457                        hub_info->port_count);
     458        printf("\tused configuration %d\n",config_descriptor.configuration_number);
    414459
    415460        return EOK;
     
    429474 * @param target
    430475 */
    431 
    432476static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
    433477        usb_device_request_setup_packet_t request;
    434478        int opResult;
    435479        printf("[usb_hub] some connection changed\n");
    436 
     480        //get default address
    437481        opResult = usb_drv_reserve_default_address(hc);
    438482        if (opResult != EOK) {
     
    459503 * @param target
    460504 */
    461 static void usb_hub_finalize_add_device(
     505static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
    462506                int hc, uint16_t port, usb_target_t target) {
    463507
    464         usb_device_request_setup_packet_t request;
    465508        int opResult;
    466509        printf("[usb_hub] finalizing add device\n");
    467         usb_address_t new_device_address =
    468                         usb_drv_request_address(hc);
    469         usb_hub_set_set_address_request
    470                         (&request, new_device_address);
     510        opResult = usb_hub_clear_port_feature(hc, target.address,
     511            port, USB_HUB_FEATURE_C_PORT_RESET);
     512        if (opResult != EOK) {
     513                goto release;
     514        }
     515
     516        /* Request address at from host controller. */
     517        usb_address_t new_device_address = usb_drv_request_address(hc);
     518        if (new_device_address < 0) {
     519                printf("[usb_hub] failed to get free USB address\n");
     520                opResult = new_device_address;
     521                goto release;
     522        }
     523        printf("[usb_hub] setting new address\n");
     524        opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
     525            new_device_address);
     526
     527        if (opResult != EOK) {
     528                printf("[usb_hub] could not set address for new device\n");
     529                goto release;
     530        }
     531
     532release:
     533        printf("[usb_hub] releasing default address\n");
     534        usb_drv_release_default_address(hc);
     535        if (opResult != EOK) {
     536                return;
     537        }
     538
     539        devman_handle_t child_handle;
     540        opResult = usb_drv_register_child_in_devman(hc, hub->device,
     541            new_device_address, &child_handle);
     542        if (opResult != EOK) {
     543                printf("[usb_hub] could not start driver for new device \n");
     544                return;
     545        }
     546        hub->attached_devs[port].devman_handle = child_handle;
     547        hub->attached_devs[port].address = new_device_address;
     548
     549        opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
     550        if (opResult != EOK) {
     551                printf("[usb_hub] could not assign address of device in hcd \n");
     552                return;
     553        }
     554        printf("[usb_hub] new device address %d, handle %zu\n",
     555            new_device_address, child_handle);
     556       
     557}
     558
     559/**
     560 * unregister device address in hc, close the port
     561 * @param hc
     562 * @param port
     563 * @param target
     564 */
     565static void usb_hub_removed_device(
     566    usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
     567        //usb_device_request_setup_packet_t request;
     568        int opResult;
     569        //disable port
     570        /*usb_hub_set_disable_port_request(&request, port);
    471571        opResult = usb_drv_sync_control_write(
    472572                        hc, target,
     
    475575                        );
    476576        if (opResult != EOK) {
    477                 printf("[usb_hub] could not set address for new device\n");
    478                 //will retry later...
    479                 return;
    480         }
    481         usb_drv_release_default_address(hc);
    482 
    483 
    484         /// \TODO driver work
    485         //add_child_device.....
    486 }
    487 
    488 /**
    489  * unregister device address in hc, close the port
    490  * @param hc
    491  * @param port
    492  * @param target
    493  */
    494 static void usb_hub_removed_device(int hc, uint16_t port, usb_target_t target) {
    495         usb_device_request_setup_packet_t request;
    496         int opResult;
    497         //disable port
    498         usb_hub_set_disable_port_request(&request, port);
    499         opResult = usb_drv_sync_control_write(
    500                         hc, target,
    501                         &request,
    502                         NULL, 0
    503                         );
    504         if (opResult != EOK) {
    505577                //continue;
    506578                printf("[usb_hub] something went wrong when disabling a port\n");
    507         }
    508         //remove device
     579        }*/
     580        /// \TODO remove device
     581
     582        hub->attached_devs[port].devman_handle=0;
    509583        //close address
    510         //
    511 
    512         ///\TODO this code is not complete
     584        if(hub->attached_devs[port].address!=0){
     585                opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
     586                if(opResult != EOK) {
     587                        printf("[usb_hub] could not release address of removed device: %d\n",opResult);
     588                }
     589                hub->attached_devs[port].address = 0;
     590        }else{
     591                printf("[usb_hub] this is strange, disconnected device had no address\n");
     592                //device was disconnected before it`s port was reset - return default address
     593                usb_drv_release_default_address(hc);
     594        }
    513595}
    514596
     
    519601 * @param target
    520602 */
    521 static void usb_hub_process_interrupt(int hc, uint16_t port, usb_target_t target) {
     603static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
     604        uint16_t port, usb_address_t address) {
    522605        printf("[usb_hub] interrupt at port %d\n", port);
    523606        //determine type of change
     607        usb_target_t target;
     608        target.address=address;
     609        target.endpoint=0;
    524610        usb_port_status_t status;
    525611        size_t rcvd_size;
     
    527613        int opResult;
    528614        usb_hub_set_port_status_request(&request, port);
     615        //endpoint 0
    529616
    530617        opResult = usb_drv_sync_control_read(
     
    543630        //something connected/disconnected
    544631        if (usb_port_connect_change(&status)) {
     632                opResult = usb_hub_clear_port_feature(hc, target.address,
     633                    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
     634                // TODO: check opResult
    545635                if (usb_port_dev_connected(&status)) {
    546636                        printf("[usb_hub] some connection changed\n");
    547637                        usb_hub_init_add_device(hc, port, target);
    548638                } else {
    549                         usb_hub_removed_device(hc, port, target);
     639                        usb_hub_removed_device(hub, hc, port, target);
    550640                }
    551641        }
    552642        //port reset
    553643        if (usb_port_reset_completed(&status)) {
    554                 printf("[usb_hub] finalizing add device\n");
     644                printf("[usb_hub] port reset complete\n");
    555645                if (usb_port_enabled(&status)) {
    556                         usb_hub_finalize_add_device(hc, port, target);
     646                        usb_hub_finalize_add_device(hub, hc, port, target);
    557647                } else {
    558648                        printf("[usb_hub] ERROR: port reset, but port still not enabled\n");
     
    565655        usb_port_set_dev_connected(&status, false);
    566656        if (status) {
    567                 printf("[usb_hub]there was some unsupported change on port\n");
     657                printf("[usb_hub]there was some unsupported change on port %d\n",port);
    568658        }
    569659        /// \TODO handle other changes
     
    585675/** Check changes on all known hubs.
    586676 */
    587 static void check_hub_changes(void) {
     677void usb_hub_check_hub_changes(void) {
    588678        /*
    589679         * Iterate through all hubs.
     
    593683                        lst_item != &usb_hub_list;
    594684                        lst_item = lst_item->next) {
    595                 printf("[usb_hub] checking hub changes\n");
     685                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
    596686                /*
    597687                 * Check status change pipe of this hub.
    598688                 */
    599689
    600                 usb_target_t target = {
    601                         .address = 5,
    602                         .endpoint = 1
    603                 };
    604                 /// \TODO uncomment once it works correctly
    605                 //target.address = usb_create_hub_info(lst_item)->device->address;
    606 
    607                 size_t port_count = 7;
     690                usb_target_t target;
     691                target.address = hub_info->usb_device->address;
     692                target.endpoint = 1;/// \TODO get from endpoint descriptor
     693                printf("[usb_hub] checking changes for hub at addr %d\n",
     694                    target.address);
     695
     696                size_t port_count = hub_info->port_count;
    608697
    609698                /*
    610699                 * Connect to respective HC.
    611700                 */
    612                 /// \FIXME this is incorrect code: here
    613                 /// must be used particular device instead of NULL
    614                 //which one?
    615                 int hc = usb_drv_hc_connect(NULL, 0);
     701                int hc = usb_drv_hc_connect(hub_info->device, 0);
    616702                if (hc < 0) {
    617703                        continue;
     
    619705
    620706                // FIXME: count properly
    621                 size_t byte_length = (port_count / 8) + 1;
     707                size_t byte_length = ((port_count+1) / 8) + 1;
    622708
    623709                void *change_bitmap = malloc(byte_length);
     
    639725                }
    640726                unsigned int port;
    641                 for (port = 0; port < port_count; ++port) {
     727                for (port = 1; port < port_count+1; ++port) {
    642728                        bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
    643729                        if (interrupt) {
    644                                 usb_hub_process_interrupt(hc, port, target);
     730                                usb_hub_process_interrupt(
     731                                        hub_info, hc, port, hub_info->usb_device->address);
    645732                        }
    646733                }
  • uspace/drv/usbkbd/main.c

    r692f13e4 r82122f3  
    4040#define NAME "usbkbd"
    4141
    42 static const usb_endpoint_t CONTROL_EP = 0;
     42#define GUESSED_POLL_ENDPOINT 1
    4343
    4444/*
     
    130130
    131131        // default endpoint
    132         kbd_dev->default_ep = CONTROL_EP;
     132        kbd_dev->poll_endpoint = GUESSED_POLL_ENDPOINT;
    133133       
    134134        /*
     
    178178        usb_target_t poll_target = {
    179179                .address = kbd_dev->address,
    180                 .endpoint = kbd_dev->default_ep
     180                .endpoint = kbd_dev->poll_endpoint
    181181        };
    182182
    183183        while (true) {
     184                async_usleep(1000 * 1000);
    184185                rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone,
    185186                    poll_target, buffer, BUFFER_SIZE, &actual_size, &handle);
  • uspace/drv/usbkbd/usbkbd.ma

    r692f13e4 r82122f3  
    1110 usb&class=hid
     210 usb&class=HID
     310 usb&interface&class=HID
    2410 usb&hid
  • uspace/drv/vhc/Makefile

    r692f13e4 r82122f3  
    3333        $(LIBDRV_PREFIX)/libdrv.a
    3434EXTRA_CFLAGS += \
    35         -I$(LIB_PREFIX) \
     35        -I$(LIBUSBVIRT_PREFIX)/include \
    3636        -I$(LIBUSB_PREFIX)/include \
    3737        -I$(LIBDRV_PREFIX)/include
     
    3939
    4040SOURCES = \
     41        hub/hub.c \
     42        hub/virthub.c \
     43        hub/virthubops.c \
    4144        conndev.c \
    4245        connhost.c \
     
    4548        hc.c \
    4649        hcd.c \
    47         hub.c \
    48         hubops.c
     50        hub.c
    4951
    5052include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/vhc/conn.h

    r692f13e4 r82122f3  
    4242#include "devices.h"
    4343
    44 void connection_handler_host(ipcarg_t);
     44void connection_handler_host(sysarg_t);
    4545
    4646usb_hcd_transfer_ops_t vhc_transfer_ops;
  • uspace/drv/vhc/conndev.c

    r692f13e4 r82122f3  
    4747{
    4848        ipc_call_t answer_data;
    49         ipcarg_t answer_rc;
     49        sysarg_t answer_rc;
    5050        aid_t req;
    5151        int rc;
     
    8383    ipc_callid_t icallid, ipc_call_t *icall)
    8484{
    85         ipcarg_t method = IPC_GET_METHOD(*icall);
     85        sysarg_t method = IPC_GET_IMETHOD(*icall);
    8686
    8787        if (method == IPC_M_CONNECT_TO_ME) {
  • uspace/drv/vhc/connhost.c

    r692f13e4 r82122f3  
    9393    usbhc_iface_transfer_out_callback_t callback, void *arg)
    9494{
    95         printf(NAME ": transfer OUT [%d.%d (%s); %zu]\n",
     95        dprintf(3, "transfer OUT [%d.%d (%s); %zu]",
    9696            target.address, target.endpoint,
    9797            usb_str_transfer_type(transfer_type),
     
    102102        transfer->out_callback = callback;
    103103
    104         hc_add_transaction_to_device(false, target, buffer, size,
     104        hc_add_transaction_to_device(false, target, transfer_type, buffer, size,
    105105            universal_callback, transfer);
    106106
     
    113113    usbhc_iface_transfer_out_callback_t callback, void *arg)
    114114{
    115         printf(NAME ": transfer SETUP [%d.%d (%s); %zu]\n",
     115        dprintf(3, "transfer SETUP [%d.%d (%s); %zu]",
    116116            target.address, target.endpoint,
    117117            usb_str_transfer_type(transfer_type),
     
    122122        transfer->out_callback = callback;
    123123
    124         hc_add_transaction_to_device(true, target, buffer, size,
     124        hc_add_transaction_to_device(true, target, transfer_type, buffer, size,
    125125            universal_callback, transfer);
    126126
     
    133133    usbhc_iface_transfer_in_callback_t callback, void *arg)
    134134{
    135         printf(NAME ": transfer IN [%d.%d (%s); %zu]\n",
     135        dprintf(3, "transfer IN [%d.%d (%s); %zu]",
    136136            target.address, target.endpoint,
    137137            usb_str_transfer_type(transfer_type),
     
    142142        transfer->in_callback = callback;
    143143
    144         hc_add_transaction_from_device(target, buffer, size,
     144        hc_add_transaction_from_device(target, transfer_type, buffer, size,
    145145            universal_callback, transfer);
    146146
  • uspace/drv/vhc/debug.c

    r692f13e4 r82122f3  
    4242/** Debug print informing of invalid call.
    4343 */
    44 void dprintf_inval_call(int level, ipc_call_t call, ipcarg_t phone_hash)
     44void dprintf_inval_call(int level, ipc_call_t call, sysarg_t phone_hash)
    4545{
    4646        dprintf(level, "phone%#x: invalid call [%u (%u, %u, %u, %u, %u)]",
    4747            phone_hash,
    48             IPC_GET_METHOD(call),
     48            IPC_GET_IMETHOD(call),
    4949            IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call),
    5050            IPC_GET_ARG4(call), IPC_GET_ARG5(call));
  • uspace/drv/vhc/devices.c

    r692f13e4 r82122f3  
    4747#include "devices.h"
    4848#include "hub.h"
     49#include "hub/virthub.h"
    4950#include "vhcd.h"
    5051
     
    6970        list_append(&dev->link, &devices);
    7071       
    71         hub_add_device(dev);
     72        virthub_connect_device(&virtual_hub_device, dev);
    7273       
    7374        return dev;
     
    7879void virtdev_destroy_device(virtdev_connection_t *dev)
    7980{
    80         hub_remove_device(dev);
     81        virthub_disconnect_device(&virtual_hub_device, dev);
    8182        list_remove(&dev->link);
    8283        free(dev);
     
    9495                    = list_get_instance(pos, virtdev_connection_t, link);
    9596               
    96                 if (!hub_can_device_signal(dev)) {
     97                if (!virthub_is_device_enabled(&virtual_hub_device, dev)) {
    9798                        continue;
    9899                }
    99100               
    100101                ipc_call_t answer_data;
    101                 ipcarg_t answer_rc;
     102                sysarg_t answer_rc;
    102103                aid_t req;
    103104                int rc = EOK;
     
    145146         * (if the address matches).
    146147         */
    147         if (virthub_dev.address == transaction->target.address) {
     148        if (virtual_hub_device.address == transaction->target.address) {
    148149                size_t tmp;
    149                 dprintf(3, "sending `%s' transaction to hub",
     150                dprintf(1, "sending `%s' transaction to hub",
    150151                    usbvirt_str_transaction_type(transaction->type));
    151152                switch (transaction->type) {
    152153                        case USBVIRT_TRANSACTION_SETUP:
    153                                 virthub_dev.transaction_setup(&virthub_dev,
     154                                virtual_hub_device.transaction_setup(
     155                                    &virtual_hub_device,
    154156                                    transaction->target.endpoint,
    155157                                    transaction->buffer, transaction->len);
     
    157159                               
    158160                        case USBVIRT_TRANSACTION_IN:
    159                                 virthub_dev.transaction_in(&virthub_dev,
     161                                virtual_hub_device.transaction_in(
     162                                    &virtual_hub_device,
    160163                                    transaction->target.endpoint,
    161164                                    transaction->buffer, transaction->len,
     
    167170                               
    168171                        case USBVIRT_TRANSACTION_OUT:
    169                                 virthub_dev.transaction_out(&virthub_dev,
     172                                virtual_hub_device.transaction_out(
     173                                    &virtual_hub_device,
    170174                                    transaction->target.endpoint,
    171175                                    transaction->buffer, transaction->len);
  • uspace/drv/vhc/hc.c

    r692f13e4 r82122f3  
    5050#include "hub.h"
    5151
    52 #define USLEEP_BASE (500 * 1000)
    53 
    54 #define USLEEP_VAR 5000
     52#define USLEEP_BASE (0 * 5 * 1000)
     53
     54#define USLEEP_VAR 50
    5555
    5656#define SHORTENING_VAR 15
     
    6868static link_t transaction_list;
    6969
    70 #define TRANSACTION_FORMAT "T[%d:%d %s (%d)]"
     70#define TRANSACTION_FORMAT "T[%d.%d %s/%s (%d)]"
    7171#define TRANSACTION_PRINTF(t) \
    7272        (t).target.address, (t).target.endpoint, \
     73        usb_str_transfer_type((t).transfer_type), \
    7374        usbvirt_str_transaction_type((t).type), \
    7475        (int)(t).len
     
    7778        list_get_instance(lnk, transaction_t, link)
    7879
     80#define HUB_STATUS_MAX_LEN (HUB_PORT_COUNT + 64)
     81
    7982static inline unsigned int pseudo_random(unsigned int *seed)
    8083{
     
    8992    usb_transaction_outcome_t outcome)
    9093{
    91         dprintf(3, "processing transaction " TRANSACTION_FORMAT ", outcome: %s",
     94        dprintf(3, "transaction " TRANSACTION_FORMAT " done, outcome: %s",
    9295            TRANSACTION_PRINTF(*transaction),
    9396            usb_str_transaction_outcome(outcome));
     
    99102/** Host controller manager main function.
    100103 */
    101 void hc_manager(void)
     104static int hc_manager_fibril(void *arg)
    102105{
    103106        list_initialize(&transaction_list);
     
    114117                }
    115118               
    116                 char ports[HUB_PORT_COUNT + 2];
    117                 hub_get_port_statuses(ports, HUB_PORT_COUNT + 1);
    118                 dprintf(3, "virtual hub: addr=%d ports=%s",
    119                     virthub_dev.address, ports);
     119                char ports[HUB_STATUS_MAX_LEN + 1];
     120                virthub_get_status(&virtual_hub_device, ports, HUB_STATUS_MAX_LEN);
    120121               
    121122                link_t *first_transaction_link = transaction_list.next;
     
    124125                list_remove(first_transaction_link);
    125126               
     127
     128                dprintf(0, "about to process " TRANSACTION_FORMAT " [%s]",
     129                    TRANSACTION_PRINTF(*transaction), ports);
     130
    126131                dprintf(3, "processing transaction " TRANSACTION_FORMAT "",
    127132                    TRANSACTION_PRINTF(*transaction));
     
    134139                free(transaction);
    135140        }
     141
     142        assert(false && "unreachable");
     143        return EOK;
     144}
     145
     146void hc_manager(void)
     147{
     148        fid_t fid = fibril_create(hc_manager_fibril, NULL);
     149        if (fid == 0) {
     150                printf(NAME ": failed to start HC manager fibril\n");
     151                return;
     152        }
     153        fibril_add_ready(fid);
    136154}
    137155
     
    139157 */
    140158static transaction_t *transaction_create(usbvirt_transaction_type_t type,
    141     usb_target_t target,
     159    usb_target_t target, usb_transfer_type_t transfer_type,
    142160    void * buffer, size_t len,
    143161    hc_transaction_done_callback_t callback, void * arg)
     
    147165        list_initialize(&transaction->link);
    148166        transaction->type = type;
     167        transaction->transfer_type = transfer_type;
    149168        transaction->target = target;
    150169        transaction->buffer = buffer;
     
    153172        transaction->callback_arg = arg;
    154173       
    155         dprintf(1, "creating transaction " TRANSACTION_FORMAT,
     174        dprintf(3, "creating transaction " TRANSACTION_FORMAT,
    156175            TRANSACTION_PRINTF(*transaction));
    157176       
     
    162181 */
    163182void hc_add_transaction_to_device(bool setup, usb_target_t target,
     183    usb_transfer_type_t transfer_type,
    164184    void * buffer, size_t len,
    165185    hc_transaction_done_callback_t callback, void * arg)
    166186{
    167187        transaction_t *transaction = transaction_create(
    168             setup ? USBVIRT_TRANSACTION_SETUP : USBVIRT_TRANSACTION_OUT, target,
     188            setup ? USBVIRT_TRANSACTION_SETUP : USBVIRT_TRANSACTION_OUT,
     189            target, transfer_type,
    169190            buffer, len, callback, arg);
    170191        list_append(&transaction->link, &transaction_list);
     
    174195 */
    175196void hc_add_transaction_from_device(usb_target_t target,
     197    usb_transfer_type_t transfer_type,
    176198    void * buffer, size_t len,
    177199    hc_transaction_done_callback_t callback, void * arg)
    178200{
    179201        transaction_t *transaction = transaction_create(USBVIRT_TRANSACTION_IN,
    180             target, buffer, len, callback, arg);
     202            target, transfer_type,
     203            buffer, len, callback, arg);
    181204        list_append(&transaction->link, &transaction_list);
    182205}
  • uspace/drv/vhc/hc.h

    r692f13e4 r82122f3  
    5555        /** Transaction type. */
    5656        usbvirt_transaction_type_t type;
     57        /** Transfer type. */
     58        usb_transfer_type_t transfer_type;
    5759        /** Device address. */
    5860        usb_target_t target;
     
    7173void hc_manager(void);
    7274
    73 void hc_add_transaction_to_device(bool setup, usb_target_t target,
     75void hc_add_transaction_to_device(bool setup,
     76    usb_target_t target, usb_transfer_type_t transfer_type,
    7477    void * buffer, size_t len,
    7578    hc_transaction_done_callback_t callback, void * arg);
    7679
    77 void hc_add_transaction_from_device(usb_target_t target,
     80void hc_add_transaction_from_device(
     81    usb_target_t target, usb_transfer_type_t transfer_type,
    7882    void * buffer, size_t len,
    7983    hc_transaction_done_callback_t callback, void * arg);
  • uspace/drv/vhc/hcd.c

    r692f13e4 r82122f3  
    7979         * Initialize our hub and announce its presence.
    8080         */
    81         hub_init(dev);
     81        virtual_hub_device_init(dev);
    8282
    8383        printf("%s: virtual USB host controller ready.\n", NAME);
     
    9595};
    9696
    97 /** Fibril wrapper for HC transaction manager.
    98  *
    99  * @param arg Not used.
    100  * @return Nothing, return argument is unreachable.
    101  */
    102 static int hc_manager_fibril(void *arg)
    103 {
    104         hc_manager();
    105         return EOK;
    106 }
    10797
    10898int main(int argc, char * argv[])
    10999{       
    110         printf("%s: virtual USB host controller driver.\n", NAME);
    111 
    112         usb_dprintf_enable(NAME, 10);
    113 
    114         fid_t fid = fibril_create(hc_manager_fibril, NULL);
    115         if (fid == 0) {
    116                 printf("%s: failed to start HC manager fibril\n", NAME);
    117                 return ENOMEM;
    118         }
    119         fibril_add_ready(fid);
    120 
    121100        /*
    122101         * Temporary workaround. Wait a little bit to be the last driver
    123102         * in devman output.
    124103         */
    125         sleep(4);
     104        sleep(5);
     105
     106        usb_dprintf_enable(NAME, 0);
     107
     108        printf(NAME ": virtual USB host controller driver.\n");
     109
     110        hc_manager();
    126111
    127112        return driver_main(&vhc_driver);
  • uspace/drv/vhc/hub.c

    r692f13e4 r82122f3  
    4040#include <stdlib.h>
    4141#include <driver.h>
     42#include <usb/usbdrv.h>
    4243
     44#include "hub.h"
     45#include "hub/virthub.h"
    4346#include "vhcd.h"
    44 #include "hub.h"
    45 #include "hubintern.h"
    46 #include "conn.h"
    4747
     48usbvirt_device_t virtual_hub_device;
    4849
    49 /** Standard device descriptor. */
    50 usb_standard_device_descriptor_t std_device_descriptor = {
    51         .length = sizeof(usb_standard_device_descriptor_t),
    52         .descriptor_type = USB_DESCTYPE_DEVICE,
    53         .usb_spec_version = 0x110,
    54         .device_class = USB_CLASS_HUB,
    55         .device_subclass = 0,
    56         .device_protocol = 0,
    57         .max_packet_size = 64,
    58         .configuration_count = 1
    59 };
     50static int hub_register_in_devman_fibril(void *arg);
    6051
    61 /** Standard interface descriptor. */
    62 usb_standard_interface_descriptor_t std_interface_descriptor = {
    63         .length = sizeof(usb_standard_interface_descriptor_t),
    64         .descriptor_type = USB_DESCTYPE_INTERFACE,
    65         .interface_number = 0,
    66         .alternate_setting = 0,
    67         .endpoint_count = 1,
    68         .interface_class = USB_CLASS_HUB,
    69         .interface_subclass = 0,
    70         .interface_protocol = 0,
    71         .str_interface = 0
    72 };
     52void virtual_hub_device_init(device_t *hc_dev)
     53{
     54        virthub_init(&virtual_hub_device);
    7355
    74 hub_descriptor_t hub_descriptor = {
    75         .length = sizeof(hub_descriptor_t),
    76         .type = USB_DESCTYPE_HUB,
    77         .port_count = HUB_PORT_COUNT,
    78         .characteristics = 0,
    79         .power_on_warm_up = 50, /* Huh? */
    80         .max_current = 100, /* Huh again. */
    81         .removable_device = { 0 },
    82         .port_power = { 0xFF }
    83 };
     56        /*
     57         * We need to register the root hub.
     58         * This must be done in separate fibril because the device
     59         * we are connecting to are ourselves and we cannot connect
     60         * before leaving the add_device() function.
     61         */
     62        fid_t root_hub_registration
     63            = fibril_create(hub_register_in_devman_fibril, hc_dev);
     64        if (root_hub_registration == 0) {
     65                printf(NAME ": failed to register root hub\n");
     66                return;
     67        }
    8468
    85 /** Endpoint descriptor. */
    86 usb_standard_endpoint_descriptor_t endpoint_descriptor = {
    87         .length = sizeof(usb_standard_endpoint_descriptor_t),
    88         .descriptor_type = USB_DESCTYPE_ENDPOINT,
    89         .endpoint_address = HUB_STATUS_CHANGE_PIPE | 128,
    90         .attributes = USB_TRANSFER_INTERRUPT,
    91         .max_packet_size = 8,
    92         .poll_interval = 0xFF
    93 };
    94 
    95 /** Standard configuration descriptor. */
    96 usb_standard_configuration_descriptor_t std_configuration_descriptor = {
    97         .length = sizeof(usb_standard_configuration_descriptor_t),
    98         .descriptor_type = USB_DESCTYPE_CONFIGURATION,
    99         .total_length =
    100                 sizeof(usb_standard_configuration_descriptor_t)
    101                 + sizeof(std_interface_descriptor)
    102                 + sizeof(hub_descriptor)
    103                 + sizeof(endpoint_descriptor)
    104                 ,
    105         .interface_count = 1,
    106         .configuration_number = HUB_CONFIGURATION_ID,
    107         .str_configuration = 0,
    108         .attributes = 128, /* denotes bus-powered device */
    109         .max_power = 50
    110 };
    111 
    112 /** All hub configuration descriptors. */
    113 static usbvirt_device_configuration_extras_t extra_descriptors[] = {
    114         {
    115                 .data = (uint8_t *) &std_interface_descriptor,
    116                 .length = sizeof(std_interface_descriptor)
    117         },
    118         {
    119                 .data = (uint8_t *) &hub_descriptor,
    120                 .length = sizeof(hub_descriptor)
    121         },
    122         {
    123                 .data = (uint8_t *) &endpoint_descriptor,
    124                 .length = sizeof(endpoint_descriptor)
    125         }
    126 };
    127 
    128 /** Hub configuration. */
    129 usbvirt_device_configuration_t configuration = {
    130         .descriptor = &std_configuration_descriptor,
    131         .extra = extra_descriptors,
    132         .extra_count = sizeof(extra_descriptors)/sizeof(extra_descriptors[0])
    133 };
    134 
    135 /** Hub standard descriptors. */
    136 usbvirt_descriptors_t descriptors = {
    137         .device = &std_device_descriptor,
    138         .configuration = &configuration,
    139         .configuration_count = 1,
    140 };
    141 
    142 /** Hub as a virtual device. */
    143 usbvirt_device_t virthub_dev = {
    144         .ops = &hub_ops,
    145         .descriptors = &descriptors,
    146         .lib_debug_level = 4,
    147         .lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL
    148 };
    149 
    150 /** Hub device. */
    151 hub_device_t hub_dev;
    152 
    153 static usb_address_t hub_set_address(usbvirt_device_t *hub)
    154 {
    155         usb_address_t new_address;
    156         int rc = vhc_iface.request_address(NULL, &new_address);
    157         if (rc != EOK) {
    158                 return rc;
    159         }
    160        
    161         usb_device_request_setup_packet_t setup_packet = {
    162                 .request_type = 0,
    163                 .request = USB_DEVREQ_SET_ADDRESS,
    164                 .index = 0,
    165                 .length = 0,
    166         };
    167         setup_packet.value = new_address;
    168 
    169         hub->transaction_setup(hub, 0, &setup_packet, sizeof(setup_packet));
    170         hub->transaction_in(hub, 0, NULL, 0, NULL);
    171        
    172         return new_address;
     69        fibril_add_ready(root_hub_registration);
    17370}
    17471
    175 /** Initialize virtual hub. */
    176 void hub_init(device_t *hc_dev)
     72/** Register root hub in devman.
     73 *
     74 * @param arg Host controller device (type <code>device_t *</code>).
     75 * @return Error code.
     76 */
     77int hub_register_in_devman_fibril(void *arg)
    17778{
    178         size_t i;
    179         for (i = 0; i < HUB_PORT_COUNT; i++) {
    180                 hub_port_t *port = &hub_dev.ports[i];
    181                
    182                 port->device = NULL;
    183                 port->state = HUB_PORT_STATE_NOT_CONFIGURED;
    184                 port->status_change = 0;
    185         }
    186        
    187         usbvirt_connect_local(&virthub_dev);
    188        
    189         dprintf(1, "virtual hub (%d ports) created", HUB_PORT_COUNT);
     79        device_t *hc_dev = (device_t *) arg;
    19080
    191         usb_address_t hub_address = hub_set_address(&virthub_dev);
    192         if (hub_address < 0) {
    193                 dprintf(1, "problem changing hub address (%s)",
    194                     str_error(hub_address));
     81        int hc = usb_drv_hc_connect(hc_dev, IPC_FLAG_BLOCKING);
     82        if (hc < 0) {
     83                printf(NAME ": failed to register root hub\n");
     84                return hc;
    19585        }
    19686
    197         dprintf(2, "virtual hub address changed to %d", hub_address);
     87        usb_drv_reserve_default_address(hc);
    19888
    199         char *id;
    200         int rc = asprintf(&id, "usb&hub");
    201         if (rc <= 0) {
    202                 return;
    203         }
     89        usb_address_t hub_address = usb_drv_request_address(hc);
     90        usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, hub_address);
     91
     92        usb_drv_release_default_address(hc);
     93
    20494        devman_handle_t hub_handle;
    205         rc = child_device_register_wrapper(hc_dev, "hub", id, 10, &hub_handle);
    206         if (rc != EOK) {
    207                 free(id);
    208         }
     95        usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle);
     96        usb_drv_bind_address(hc, hub_address, hub_handle);
    20997
    210         vhc_iface.bind_address(NULL, hub_address, hub_handle); 
    211 
    212         dprintf(2, "virtual hub has devman handle %d", (int) hub_handle);
     98        return EOK;
    21399}
    214 
    215 /** Connect device to the hub.
    216  *
    217  * @param device Device to be connected.
    218  * @return Port where the device was connected to.
    219  */
    220 size_t hub_add_device(virtdev_connection_t *device)
    221 {
    222         size_t i;
    223         for (i = 0; i < HUB_PORT_COUNT; i++) {
    224                 hub_port_t *port = &hub_dev.ports[i];
    225                
    226                 if (port->device != NULL) {
    227                         continue;
    228                 }
    229                
    230                 port->device = device;
    231                
    232                 /*
    233                  * TODO:
    234                  * If the hub was configured, we can normally
    235                  * announce the plug-in.
    236                  * Otherwise, we will wait until hub is configured
    237                  * and announce changes in single burst.
    238                  */
    239                 //if (port->state == HUB_PORT_STATE_DISCONNECTED) {
    240                         port->state = HUB_PORT_STATE_DISABLED;
    241                         set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
    242                 //}
    243                
    244                 return i;
    245         }
    246100       
    247         return (size_t)-1;
    248 }
    249 
    250 /** Disconnect device from the hub. */
    251 void hub_remove_device(virtdev_connection_t *device)
    252 {
    253         size_t i;
    254         for (i = 0; i < HUB_PORT_COUNT; i++) {
    255                 hub_port_t *port = &hub_dev.ports[i];
    256                
    257                 if (port->device != device) {
    258                         continue;
    259                 }
    260                
    261                 port->device = NULL;
    262                 port->state = HUB_PORT_STATE_DISCONNECTED;
    263                
    264                 set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
    265         }
    266 }
    267 
    268 /** Tell whether device port is open.
    269  *
    270  * @return Whether communication to and from the device can go through the hub.
    271  */
    272 bool hub_can_device_signal(virtdev_connection_t * device)
    273 {
    274         size_t i;
    275         for (i = 0; i < HUB_PORT_COUNT; i++) {
    276                 if (hub_dev.ports[i].device == device) {
    277                         return hub_dev.ports[i].state == HUB_PORT_STATE_ENABLED;
    278                 }
    279         }
    280        
    281         return false;
    282 }
    283 
    284 /** Format hub port status.
    285  *
    286  * @param result Buffer where to store status string.
    287  * @param len Number of characters that is possible to store in @p result
    288  *      (excluding trailing zero).
    289  */
    290 void hub_get_port_statuses(char *result, size_t len)
    291 {
    292         if (len > HUB_PORT_COUNT) {
    293                 len = HUB_PORT_COUNT;
    294         }
    295         size_t i;
    296         for (i = 0; i < len; i++) {
    297                 result[i] = hub_port_state_as_char(hub_dev.ports[i].state);
    298         }
    299         result[len] = 0;
    300 }
    301101
    302102/**
  • uspace/drv/vhc/hub.h

    r692f13e4 r82122f3  
    4040
    4141#include "devices.h"
     42#include "hub/hub.h"
     43#include "hub/virthub.h"
    4244
    43 #define HUB_PORT_COUNT 6
     45extern usbvirt_device_t virtual_hub_device;
    4446
    45 #define BITS2BYTES(bits) \
    46     (bits ? ((((bits)-1)>>3)+1) : 0)
    47 
    48 extern usbvirt_device_t virthub_dev;
    49 
    50 void hub_init(device_t *);
    51 size_t hub_add_device(virtdev_connection_t *);
    52 void hub_remove_device(virtdev_connection_t *);
    53 bool hub_can_device_signal(virtdev_connection_t *);
    54 void hub_get_port_statuses(char *result, size_t len);
     47void virtual_hub_device_init(device_t *);
    5548
    5649#endif
  • uspace/drv/vhc/hub/virthub.h

    r692f13e4 r82122f3  
    3131 */
    3232/** @file
    33  * @brief
     33 * @brief USB hub as a virtual USB device.
    3434 */
    35 #ifndef VHCD_HUBINTERN_H_
    36 #define VHCD_HUBINTERN_H_
     35#ifndef VHC_HUB_VIRTHUB_H_
     36#define VHC_HUB_VIRTHUB_H_
    3737
     38#include <usbvirt/device.h>
     39#include "../devices.h"
    3840#include "hub.h"
    3941
     
    4244/** Configuration value for hub configuration. */
    4345#define HUB_CONFIGURATION_ID 1
     46
    4447
    4548/** Hub descriptor.
     
    6871} __attribute__ ((packed)) hub_descriptor_t;
    6972
    70 /** Hub port internal state.
    71  * Some states (e.g. port over current) are not covered as they are not
    72  * simulated at all.
    73  */
    74 typedef enum {
    75         HUB_PORT_STATE_NOT_CONFIGURED,
    76         HUB_PORT_STATE_POWERED_OFF,
    77         HUB_PORT_STATE_DISCONNECTED,
    78         HUB_PORT_STATE_DISABLED,
    79         HUB_PORT_STATE_RESETTING,
    80         HUB_PORT_STATE_ENABLED,
    81         HUB_PORT_STATE_SUSPENDED,
    82         HUB_PORT_STATE_RESUMING,
    83         /* HUB_PORT_STATE_, */
    84 } hub_port_state_t;
    85 
    86 /** Convert hub port state to a char. */
    87 static inline char hub_port_state_as_char(hub_port_state_t state) {
    88         switch (state) {
    89                 case HUB_PORT_STATE_NOT_CONFIGURED:
    90                         return '-';
    91                 case HUB_PORT_STATE_POWERED_OFF:
    92                         return 'O';
    93                 case HUB_PORT_STATE_DISCONNECTED:
    94                         return 'X';
    95                 case HUB_PORT_STATE_DISABLED:
    96                         return 'D';
    97                 case HUB_PORT_STATE_RESETTING:
    98                         return 'R';
    99                 case HUB_PORT_STATE_ENABLED:
    100                         return 'E';
    101                 case HUB_PORT_STATE_SUSPENDED:
    102                         return 'S';
    103                 case HUB_PORT_STATE_RESUMING:
    104                         return 'F';
    105                 default:
    106                         return '?';
    107         }
    108 }
    109 
    110 /** Hub status change mask bits. */
    111 typedef enum {
    112         HUB_STATUS_C_PORT_CONNECTION = (1 << 0),
    113         HUB_STATUS_C_PORT_ENABLE = (1 << 1),
    114         HUB_STATUS_C_PORT_SUSPEND = (1 << 2),
    115         HUB_STATUS_C_PORT_OVER_CURRENT = (1 << 3),
    116         HUB_STATUS_C_PORT_RESET = (1 << 4),
    117         /* HUB_STATUS_C_ = (1 << ), */
    118 } hub_status_change_t;
    119 
    120 /** Hub port information. */
    121 typedef struct {
    122         virtdev_connection_t *device;
    123         hub_port_state_t state;
    124         uint16_t status_change;
    125 } hub_port_t;
    126 
    127 /** Hub device type. */
    128 typedef struct {
    129         hub_port_t ports[HUB_PORT_COUNT];
    130 } hub_device_t;
    131 
    132 extern hub_device_t hub_dev;
    133 
     73extern usbvirt_device_ops_t hub_ops;
    13474extern hub_descriptor_t hub_descriptor;
    13575
    136 extern usbvirt_device_ops_t hub_ops;
    137 
    138 void clear_port_status_change(hub_port_t *, uint16_t);
    139 void set_port_status_change(hub_port_t *, uint16_t);
    140 
     76int virthub_init(usbvirt_device_t *);
     77int virthub_connect_device(usbvirt_device_t *, virtdev_connection_t *);
     78int virthub_disconnect_device(usbvirt_device_t *, virtdev_connection_t *);
     79bool virthub_is_device_enabled(usbvirt_device_t *, virtdev_connection_t *);
     80void virthub_get_status(usbvirt_device_t *, char *, size_t);
    14181
    14282#endif
  • uspace/drv/vhc/vhcd.h

    r692f13e4 r82122f3  
    4747#define dprintf(level, format, ...) \
    4848        usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__)
    49 void dprintf_inval_call(int, ipc_call_t, ipcarg_t);
     49void dprintf_inval_call(int, ipc_call_t, sysarg_t);
    5050
    5151#endif
Note: See TracChangeset for help on using the changeset viewer.