Changes in / [c9113d2:a822cd8] in mainline


Ignore:
Location:
uspace/drv/usbhub
Files:
3 edited

Legend:

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

    rc9113d2 ra822cd8  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
     28#include <usb/usbdrv.h>
    2929#include <driver.h>
    3030#include <errno.h>
    31 #include <async.h>
    32 
    33 #include <usb/usbdrv.h>
    3431#include "usbhub.h"
    3532#include "usbhub_private.h"
     
    4744};
    4845
    49 int 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 
    5846int main(int argc, char *argv[])
    5947{
    6048        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 
    6849        return driver_main(&hub_driver);
    6950}
  • uspace/drv/usbhub/usbhub.h

    rc9113d2 ra822cd8  
    4646        /** Number of ports. */
    4747        int port_count;
    48         /** General usb device info. */
    49         usb_hcd_attached_device_info_t * usb_device;
    50         /** General device info*/
    51         device_t * device;
    52 
     48        /** General device info. */
     49        usb_hcd_attached_device_info_t * device;
    5350} usb_hub_info_t;
    5451
    55 /**
    56  * function running the hub-controlling loop.
    57  * @param noparam fundtion does not need any parameters
    58  */
    59 int 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  */
    66 int usb_add_hub_device(device_t *dev);
    67 
    68 /**
    69  * check changes on all registered hubs
    70  */
    71 void usb_hub_check_hub_changes(void);
    72 
    73 
    74 //int usb_add_hub_device(device_t *);
    75 
    76 
     52int usb_add_hub_device(device_t *);
    7753
    7854#endif
  • uspace/drv/usbhub/utils.c

    rc9113d2 ra822cd8  
    3434 */
    3535#include <driver.h>
    36 #include <bool.h>
    37 #include <errno.h>
    38 
     36#include <usb/devreq.h>
    3937#include <usbhc_iface.h>
    4038#include <usb/usbdrv.h>
    4139#include <usb/descriptor.h>
    42 #include <usb/devreq.h>
     40#include <driver.h>
     41#include <bool.h>
     42#include <errno.h>
    4343#include <usb/classes/hub.h>
    44 
    4544#include "usbhub.h"
    4645#include "usbhub_private.h"
    4746#include "port_status.h"
    48 
     47#include <usb/devreq.h>
     48
     49static void check_hub_changes(void);
    4950
    5051size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71;
     
    301302        //result->device = device;
    302303        result->port_count = -1;
    303         /// \TODO is this correct? is the device stored?
    304         result->device = device;
    305304
    306305
     
    317316        }*/
    318317
    319         result->usb_device = usb_new(usb_hcd_attached_device_info_t);
    320         result->usb_device->address = addr;
     318        result->device = usb_new(usb_hcd_attached_device_info_t);
     319        result->device->address = addr;
    321320
    322321        // get hub descriptor
     
    363362}
    364363
     364/** Callback when new hub device is detected.
     365 *
     366 * @param dev New device.
     367 * @return Error code.
     368 */
    365369int usb_add_hub_device(device_t *dev) {
    366370        printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle);
     
    383387        usb_device_request_setup_packet_t request;
    384388        usb_target_t target;
    385         target.address = hub_info->usb_device->address;
     389        target.address = hub_info->device->address;
    386390        target.endpoint = 0;
    387391        for (port = 0; port < hub_info->port_count; ++port) {
     
    400404        printf("[usb_hub] hub info added to list\n");
    401405        //(void)hub_info;
    402         usb_hub_check_hub_changes();
     406        check_hub_changes();
    403407
    404408        /// \TODO start the check loop, if not already started...
     
    408412
    409413        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);
    413414
    414415        return EOK;
     
    428429 * @param target
    429430 */
     431
    430432static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
    431433        usb_device_request_setup_packet_t request;
     
    457459 * @param target
    458460 */
    459 static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
     461static void usb_hub_finalize_add_device(
    460462                int hc, uint16_t port, usb_target_t target) {
    461463
     
    477479                return;
    478480        }
    479 
    480 
    481481        usb_drv_release_default_address(hc);
    482482
    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        
     483
     484        /// \TODO driver work
     485        //add_child_device.....
    492486}
    493487
     
    525519 * @param target
    526520 */
    527 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
     521static void usb_hub_process_interrupt(int hc, uint16_t port, usb_target_t target) {
    528522        printf("[usb_hub] interrupt at port %d\n", port);
    529523        //determine type of change
     
    560554                printf("[usb_hub] finalizing add device\n");
    561555                if (usb_port_enabled(&status)) {
    562                         usb_hub_finalize_add_device(hub, hc, port, target);
     556                        usb_hub_finalize_add_device(hc, port, target);
    563557                } else {
    564558                        printf("[usb_hub] ERROR: port reset, but port still not enabled\n");
     
    591585/** Check changes on all known hubs.
    592586 */
    593 void usb_hub_check_hub_changes(void) {
     587static void check_hub_changes(void) {
    594588        /*
    595589         * Iterate through all hubs.
     
    600594                        lst_item = lst_item->next) {
    601595                printf("[usb_hub] checking hub changes\n");
    602                 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
    603596                /*
    604597                 * Check status change pipe of this hub.
    605598                 */
    606599
    607                 usb_target_t target;
    608                 target.address = hub_info->usb_device->address;
    609                 target.endpoint = 1;
    610 
    611                 size_t port_count = hub_info->port_count;
     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;
    612608
    613609                /*
    614610                 * Connect to respective HC.
    615611                 */
    616                 int hc = usb_drv_hc_connect(hub_info->device, 0);
     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);
    617616                if (hc < 0) {
    618617                        continue;
     
    643642                        bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
    644643                        if (interrupt) {
    645                                 usb_hub_process_interrupt(hub_info, hc, port, target);
     644                                usb_hub_process_interrupt(hc, port, target);
    646645                        }
    647646                }
Note: See TracChangeset for help on using the changeset viewer.