Changeset 4c74ac3 in mainline


Ignore:
Timestamp:
2010-12-12T14:46:13Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
16ecc28
Parents:
b666608
Message:

usb hub driver almost complete

Location:
uspace/drv/usbhub
Files:
3 edited

Legend:

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

    rb666608 r4c74ac3  
    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(10000);
     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/usbhub.h

    rb666608 r4c74ac3  
    5353} usb_hub_info_t;
    5454
    55 int usb_add_hub_device(device_t *);
     55/**
     56 * function running the hub-controlling loop.
     57 * @param noparam fundtion does not need any parameters
     58 */
     59int usb_hub_control_loop(void * noparam);
     60
     61/** Callback when new hub device is detected.
     62 *
     63 * @param dev New device.
     64 * @return Error code.
     65 */
     66int usb_add_hub_device(device_t *dev);
     67
     68/**
     69 * check changes on all registered hubs
     70 */
     71void usb_hub_check_hub_changes(void);
     72
     73
     74//int usb_add_hub_device(device_t *);
     75
     76
    5677
    5778#endif
  • uspace/drv/usbhub/utils.c

    rb666608 r4c74ac3  
    4848
    4949
    50 static void check_hub_changes(void);
    51 
    5250size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71;
    5351
     
    365363}
    366364
    367 /** Callback when new hub device is detected.
    368  *
    369  * @param dev New device.
    370  * @return Error code.
    371  */
    372365int usb_add_hub_device(device_t *dev) {
    373366        printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle);
     
    407400        printf("[usb_hub] hub info added to list\n");
    408401        //(void)hub_info;
    409         check_hub_changes();
     402        usb_hub_check_hub_changes();
    410403
    411404        /// \TODO start the check loop, if not already started...
     
    415408
    416409        printf("[usb_hub] hub dev added\n");
     410        printf("\taddress %d, has %d ports \n",
     411                        hub_info->usb_device->address,
     412                        hub_info->port_count);
    417413
    418414        return EOK;
     
    461457 * @param target
    462458 */
    463 static void usb_hub_finalize_add_device(
     459static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
    464460                int hc, uint16_t port, usb_target_t target) {
    465461
     
    484480
    485481        usb_drv_release_default_address(hc);
    486         /*
    487          devman_handle_t dev_handle;
    488         rc = child_device_register_wrapper(hub_dev, "dev",
    489          *      match_id, match_score, &dev_handle);
    490         if (rc != EOK) {
    491                 free(id);
    492         }
    493          *
    494          */
    495 
    496 
    497         /// \TODO driver work
    498         //add_child_device.....
    499         //opResult = usb_drv_bind_address(hc, new_device_address,
    500     //devman_handle_t handle);...
     482
     483        devman_handle_t child_handle;
     484        opResult = usb_drv_register_child_in_devman(hc, hub->device,
     485        new_device_address, &child_handle);
     486        if (opResult != EOK) {
     487                printf("[usb_hub] could not start driver for new device \n");
     488                return;
     489        }
     490        usb_drv_bind_address(hc, new_device_address, child_handle);
     491       
    501492}
    502493
     
    534525 * @param target
    535526 */
    536 static void usb_hub_process_interrupt(int hc, uint16_t port, usb_target_t target) {
     527static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
    537528        printf("[usb_hub] interrupt at port %d\n", port);
    538529        //determine type of change
     
    569560                printf("[usb_hub] finalizing add device\n");
    570561                if (usb_port_enabled(&status)) {
    571                         usb_hub_finalize_add_device(hc, port, target);
     562                        usb_hub_finalize_add_device(hub, hc, port, target);
    572563                } else {
    573564                        printf("[usb_hub] ERROR: port reset, but port still not enabled\n");
     
    600591/** Check changes on all known hubs.
    601592 */
    602 static void check_hub_changes(void) {
     593void usb_hub_check_hub_changes(void) {
    603594        /*
    604595         * Iterate through all hubs.
     
    652643                        bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
    653644                        if (interrupt) {
    654                                 usb_hub_process_interrupt(hc, port, target);
     645                                usb_hub_process_interrupt(hub_info, hc, port, target);
    655646                        }
    656647                }
Note: See TracChangeset for help on using the changeset viewer.