Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 818dc00 in mainline


Ignore:
Timestamp:
2010-12-09T00:02:25Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
040068c
Parents:
aca85e4 (diff), 07b9203e (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:

Merge with vojtechhorky/

Files:
7 added
14 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    raca85e4 r818dc00  
    6262./uspace/app/trace/trace
    6363./uspace/app/usb/usb
     64./uspace/app/usbinfo/usbinfo
    6465./uspace/app/virtusbkbd/vuk
    65 ./uspace/dist/app/bdsh
    66 ./uspace/dist/app/edit
    67 ./uspace/dist/app/getterm
    68 ./uspace/dist/app/klog
    69 ./uspace/dist/app/mkfat
    70 ./uspace/dist/app/netecho
    71 ./uspace/dist/app/netstart
    72 ./uspace/dist/app/nettest1
    73 ./uspace/dist/app/nettest2
    74 ./uspace/dist/app/ping
    75 ./uspace/dist/app/redir
    76 ./uspace/dist/app/sbi
    77 ./uspace/dist/app/stats
    78 ./uspace/dist/app/taskdump
    79 ./uspace/dist/app/tasks
    80 ./uspace/dist/app/tester
    81 ./uspace/dist/app/test_serial
    82 ./uspace/dist/app/tetris
    83 ./uspace/dist/app/top
    84 ./uspace/dist/app/trace
    85 ./uspace/dist/app/usb
    86 ./uspace/dist/app/vuk
     66./uspace/dist/app/*
    8767./uspace/dist/cfg/net/general
    8868./uspace/dist/cfg/net/lo
  • boot/Makefile.common

    raca85e4 r818dc00  
    142142        $(USPACE_PATH)/app/ping/ping \
    143143        $(USPACE_PATH)/app/stats/stats \
    144         $(USPACE_PATH)/app/virtusbkbd/vuk \
    145144        $(USPACE_PATH)/app/tasks/tasks \
    146         $(USPACE_PATH)/app/top/top
     145        $(USPACE_PATH)/app/top/top \
     146        $(USPACE_PATH)/app/usbinfo/usbinfo \
     147        $(USPACE_PATH)/app/virtusbkbd/vuk
    147148
    148149ifneq ($(CONFIG_BAREBONE),y)
  • uspace/Makefile

    raca85e4 r818dc00  
    4949        app/trace \
    5050        app/top \
     51        app/usbinfo \
    5152        app/virtusbkbd \
    5253        app/netecho \
  • uspace/drv/uhci/main.c

    raca85e4 r818dc00  
    2727 */
    2828#include <usb/hcdhubd.h>
     29#include <usb/debug.h>
    2930#include <errno.h>
    3031#include "uhci.h"
     
    3637static int uhci_add_device(device_t *device)
    3738{
     39        usb_dprintf(NAME, 1, "uhci_add_device() called\n");
    3840        device->ops = &uhci_ops;
    3941
     
    4143         * We need to announce the presence of our root hub.
    4244         */
     45        usb_dprintf(NAME, 2, "adding root hub\n");
    4346        usb_hcd_add_root_hub(device);
    4447
     
    6164         */
    6265        sleep(5);
     66        usb_dprintf_enable(NAME, 5);
    6367
    6468        return driver_main(&uhci_driver);
  • uspace/drv/vhc/connhost.c

    raca85e4 r818dc00  
    5858                case USB_DIRECTION_IN:
    5959                        transfer->in_callback(transfer->dev,
    60                             size, outcome,
     60                            outcome, size,
    6161                            transfer->arg);
    6262                        break;
  • uspace/drv/vhc/debug.c

    raca85e4 r818dc00  
    3535#include <stdio.h>
    3636#include <ipc/ipc.h>
     37#include <usb/debug.h>
    3738
    3839#include "vhcd.h"
    3940
    40 /** Current debug level. */
    41 int debug_level = 0;
    42 
    43 /** Debugging printf.
    44  * This function is intended for single-line messages as it
    45  * automatically prints debugging prefix at the beginning of the
    46  * line.
    47  *
    48  * @see printf
    49  * @param level Debugging level.
    50  */
    51 void dprintf(int level, const char *format, ...)
    52 {
    53         if (level > debug_level) {
    54                 return;
    55         }
    56        
    57         printf("%s(%d): ", NAME, level);
    58         va_list args;
    59         va_start(args, format);
    60         vprintf(format, args);
    61         va_end(args);
    62         printf("\n");
    63 }
    6441
    6542/** Debug print informing of invalid call.
  • uspace/drv/vhc/hcd.c

    raca85e4 r818dc00  
    111111        printf("%s: virtual USB host controller driver.\n", NAME);
    112112
    113         debug_level = 10;
     113        usb_dprintf_enable(NAME, 10);
    114114
    115115        fid_t fid = fibril_create(hc_manager_fibril, NULL);
  • uspace/drv/vhc/vhcd.h

    raca85e4 r818dc00  
    3636#define VHCD_VHCD_H_
    3737
     38#include <usb/debug.h>
     39
    3840#define NAME "vhc"
    3941#define NAME_DEV "hcd-virt-dev"
     
    4345#define DEVMAP_PATH_DEV NAMESPACE "/" NAME_DEV
    4446
    45 extern int debug_level;
    46 void dprintf(int, const char *, ...);
     47#define dprintf(level, format, ...) \
     48        usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__)
    4749void dprintf_inval_call(int, ipc_call_t, ipcarg_t);
    4850
  • uspace/lib/c/include/ipc/dev_iface.h

    raca85e4 r818dc00  
    5454        DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX)
    5555
     56/*
     57 * The first argument is actually method (as the "real" method is used
     58 * for indexing into interfaces.
     59 */
     60
     61#define DEV_IPC_GET_ARG1(call) IPC_GET_ARG2((call))
     62#define DEV_IPC_GET_ARG2(call) IPC_GET_ARG3((call))
     63#define DEV_IPC_GET_ARG3(call) IPC_GET_ARG4((call))
     64#define DEV_IPC_GET_ARG4(call) IPC_GET_ARG5((call))
     65
    5666
    5767#endif
  • uspace/lib/drv/generic/remote_usbhc.c

    raca85e4 r818dc00  
    108108        }
    109109
    110         devman_handle_t handle = IPC_GET_ARG1(*call);
     110        devman_handle_t handle = DEV_IPC_GET_ARG1(*call);
    111111
    112112        usb_address_t address;
     
    122122    ipc_callid_t callid, ipc_call_t *call)
    123123{
    124         ipcarg_t buffer_hash = IPC_GET_ARG1(*call);
     124        ipcarg_t buffer_hash = DEV_IPC_GET_ARG1(*call);
    125125        async_transaction_t * trans = (async_transaction_t *)buffer_hash;
    126126        if (trans == NULL) {
     
    144144                accepted_size = trans->size;
    145145        }
    146         async_data_read_finalize(callid, trans->buffer, accepted_size);
     146        async_data_read_finalize(cid, trans->buffer, accepted_size);
    147147
    148148        ipc_answer_1(callid, EOK, accepted_size);
     
    211211        }
    212212
    213         usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);
    214         devman_handle_t handle = (devman_handle_t) IPC_GET_ARG2(*call);
     213        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
     214        devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call);
    215215
    216216        int rc = usb_iface->bind_address(device, address, handle);
     
    229229        }
    230230
    231         usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);
     231        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
    232232
    233233        int rc = usb_iface->release_address(device, address);
     
    275275        }
    276276
    277         size_t expected_len = IPC_GET_ARG3(*call);
     277        size_t expected_len = DEV_IPC_GET_ARG3(*call);
    278278        usb_target_t target = {
    279                 .address = IPC_GET_ARG1(*call),
    280                 .endpoint = IPC_GET_ARG2(*call)
     279                .address = DEV_IPC_GET_ARG1(*call),
     280                .endpoint = DEV_IPC_GET_ARG2(*call)
    281281        };
    282282
     
    327327        }
    328328
    329         size_t len = IPC_GET_ARG3(*call);
     329        size_t len = DEV_IPC_GET_ARG3(*call);
    330330        usb_target_t target = {
    331                 .address = IPC_GET_ARG1(*call),
    332                 .endpoint = IPC_GET_ARG2(*call)
     331                .address = DEV_IPC_GET_ARG1(*call),
     332                .endpoint = DEV_IPC_GET_ARG2(*call)
    333333        };
    334334
     
    384384
    385385        usb_target_t target = {
    386                 .address = IPC_GET_ARG1(*call),
    387                 .endpoint = IPC_GET_ARG2(*call)
     386                .address = DEV_IPC_GET_ARG1(*call),
     387                .endpoint = DEV_IPC_GET_ARG2(*call)
    388388        };
    389389
  • uspace/lib/usb/Makefile

    raca85e4 r818dc00  
    3434SOURCES = \
    3535        src/addrkeep.c \
     36        src/debug.c \
     37        src/drvpsync.c \
    3638        src/hcdhubd.c \
    3739        src/hcdrv.c \
  • uspace/lib/usb/include/usb/usb.h

    raca85e4 r818dc00  
    7171/** Default USB address. */
    7272#define USB_ADDRESS_DEFAULT 0
     73/** Maximum address number in USB 1.1. */
     74#define USB11_ADDRESS_MAX 128
    7375
    7476/** USB endpoint number type.
  • uspace/lib/usb/include/usb/usbdrv.h

    raca85e4 r818dc00  
    3838#include <usb/usb.h>
    3939#include <driver.h>
     40#include <usb/devreq.h>
     41#include <usb/descriptor.h>
    4042
    4143int usb_drv_hc_connect(device_t *, unsigned int);
     
    5456    void *, size_t, size_t *, usb_handle_t *);
    5557
     58int usb_drv_psync_interrupt_out(int, usb_target_t, void *, size_t);
     59int usb_drv_psync_interrupt_in(int, usb_target_t, void *, size_t, size_t *);
     60
     61
     62
    5663int usb_drv_async_control_write_setup(int, usb_target_t,
    5764    void *, size_t, usb_handle_t *);
     
    6067int usb_drv_async_control_write_status(int, usb_target_t,
    6168    usb_handle_t *);
     69
     70int usb_drv_psync_control_write_setup(int, usb_target_t, void *, size_t);
     71int usb_drv_psync_control_write_data(int, usb_target_t, void *, size_t);
     72int usb_drv_psync_control_write_status(int, usb_target_t);
     73
    6274
    6375int usb_drv_async_control_read_setup(int, usb_target_t,
     
    6880    usb_handle_t *);
    6981
     82int usb_drv_psync_control_read_setup(int, usb_target_t, void *, size_t);
     83int usb_drv_psync_control_read_data(int, usb_target_t, void *, size_t, size_t *);
     84int usb_drv_psync_control_read_status(int, usb_target_t);
     85
     86
    7087int usb_drv_async_wait_for(usb_handle_t);
    7188
    7289
    7390int usb_drv_req_set_address(int, usb_address_t, usb_address_t);
     91int usb_drv_req_get_device_descriptor(int, usb_address_t,
     92    usb_standard_device_descriptor_t *);
    7493
    7594#endif
  • uspace/lib/usb/src/usbdrvreq.c

    raca85e4 r818dc00  
    3434 */
    3535#include <usb/usbdrv.h>
    36 #include <usb/devreq.h>
    3736#include <errno.h>
    3837
     
    9594}
    9695
     96/** Retrieve device descriptor of connected USB device.
     97 *
     98 * @param[in] phone Open phone to HC driver.
     99 * @param[in] address Device USB address.
     100 * @param[out] descriptor Storage for the device descriptor.
     101 * @return Error code.
     102 * @retval EBADMEM @p descriptor is NULL.
     103 */
     104int usb_drv_req_get_device_descriptor(int phone, usb_address_t address,
     105    usb_standard_device_descriptor_t *descriptor)
     106{
     107        if (descriptor == NULL) {
     108                return EBADMEM;
     109        }
     110
     111        /* Prepare the target. */
     112        usb_target_t target = {
     113                .address = address,
     114                .endpoint = 0
     115        };
     116
     117        /* Prepare the setup packet. */
     118        usb_device_request_setup_packet_t setup_packet = {
     119                .request_type = 128,
     120                .request = USB_DEVREQ_GET_DESCRIPTOR,
     121                .index = 0,
     122                .length = sizeof(usb_standard_device_descriptor_t)
     123        };
     124        setup_packet.value_high = USB_DESCTYPE_DEVICE;
     125        setup_packet.value_low = 0;
     126
     127        usb_handle_t handle;
     128        int rc;
     129
     130        /* Start the control read transfer. */
     131        rc = usb_drv_async_control_read_setup(phone, target,
     132            &setup_packet, sizeof(usb_device_request_setup_packet_t), &handle);
     133        if (rc != EOK) {
     134                return rc;
     135        }
     136        rc = usb_drv_async_wait_for(handle);
     137        if (rc != EOK) {
     138                return rc;
     139        }
     140
     141        /* Retrieve the descriptor. */
     142        size_t actually_transferred = 0;
     143        usb_standard_device_descriptor_t descriptor_tmp;
     144        rc = usb_drv_async_control_read_data(phone, target,
     145            &descriptor_tmp, sizeof(usb_standard_device_descriptor_t),
     146            &actually_transferred, &handle);
     147        if (rc != EOK) {
     148                return rc;
     149        }
     150        rc = usb_drv_async_wait_for(handle);
     151        if (rc != EOK) {
     152                return rc;
     153        }
     154
     155        /* Finish the control read transfer. */
     156        rc = usb_drv_async_control_read_status(phone, target, &handle);
     157        if (rc != EOK) {
     158                return rc;
     159        }
     160        rc = usb_drv_async_wait_for(handle);
     161        if (rc != EOK) {
     162                return rc;
     163        }
     164
     165        if (actually_transferred < sizeof(usb_standard_device_descriptor_t)) {
     166                return ELIMIT;
     167        }
     168
     169        /*
     170         * Everything is okay, copy the descriptor.
     171         */
     172        memcpy(descriptor, &descriptor_tmp,
     173            sizeof(usb_standard_device_descriptor_t));
     174
     175        return EOK;
     176}
     177
     178
     179
    97180/**
    98181 * @}
Note: See TracChangeset for help on using the changeset viewer.