Changeset 4b4c797 in mainline


Ignore:
Timestamp:
2010-11-20T14:07:05Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b22bd4
Parents:
0e126be7
Message:

Directory structure reorganization

USB class-specific headers are in separate directory.

Removed unused/unreachable code.

Files:
4 deleted
21 edited
13 moved

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r0e126be7 r4b4c797  
    142142        $(USPACE_PATH)/app/ping/ping \
    143143        $(USPACE_PATH)/app/stats/stats \
    144         $(USPACE_PATH)/app/usb/usb \
    145144        $(USPACE_PATH)/app/virtusbkbd/vuk \
    146145        $(USPACE_PATH)/app/tasks/tasks \
  • uspace/Makefile

    r0e126be7 r4b4c797  
    5050        app/trace \
    5151        app/top \
    52         app/usb \
    5352        app/virtusbkbd \
    5453        app/netstart \
  • uspace/app/virtusbkbd/Makefile

    r0e126be7 r4b4c797  
    3333
    3434LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBUSBVIRT_PREFIX)/libusbvirt.a
    35 EXTRA_CFLAGS = -I$(LIB_PREFIX)
     35EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIB_PREFIX)
    3636
    3737SOURCES = \
  • uspace/app/virtusbkbd/kbdconfig.c

    r0e126be7 r4b4c797  
    3636#include "kbdconfig.h"
    3737#include "keys.h"
    38 #include <usb/hcd.h>
    39 #include <usb/hid.h>
    40 #include <usb/hidut.h>
    41 #include <usb/classes.h>
     38#include <usb/usb.h>
     39#include <usb/classes/hid.h>
     40#include <usb/classes/hidut.h>
     41#include <usb/classes/classes.h>
    4242
    4343/** Standard device descriptor. */
  • uspace/app/virtusbkbd/keys.h

    r0e126be7 r4b4c797  
    4949/** USB key code. */
    5050typedef enum {
    51         #include <usb/hidutkbd.h>
     51        #include <usb/classes/hidutkbd.h>
    5252} key_code_t;
    5353
  • uspace/app/virtusbkbd/virtusbkbd.c

    r0e126be7 r4b4c797  
    4545#include <async.h>
    4646
    47 #include <usb/hcd.h>
     47#include <usb/usb.h>
    4848#include <usb/descriptor.h>
    49 #include <usb/hid.h>
     49#include <usb/classes/hid.h>
    5050#include <usbvirt/device.h>
    5151#include <usbvirt/hub.h>
  • uspace/drv/uhci/Makefile

    r0e126be7 r4b4c797  
    2929USPACE_PREFIX = ../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
    31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIB_PREFIX)
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
    3232BINARY = uhci
    3333
  • uspace/drv/usbkbd/Makefile

    r0e126be7 r4b4c797  
    2929USPACE_PREFIX = ../..
    3030LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
    31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIB_PREFIX)
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
    3232BINARY = usbkbd
    3333
  • uspace/drv/vhc/Makefile

    r0e126be7 r4b4c797  
    3434EXTRA_CFLAGS += \
    3535        -I$(LIB_PREFIX) \
     36        -I$(LIBUSB_PREFIX)/include \
    3637        -I$(LIBDRV_PREFIX)/include
    3738BINARY = vhc
  • uspace/drv/vhc/conn.h

    r0e126be7 r4b4c797  
    3636#define VHCD_CONN_H_
    3737
    38 #include <usb/hcd.h>
     38#include <usb/usb.h>
    3939#include <usb/hcdhubd.h>
    4040#include "vhcd.h"
  • uspace/drv/vhc/connhost.c

    r0e126be7 r4b4c797  
    3535#include <assert.h>
    3636#include <errno.h>
    37 #include <usb/hcd.h>
     37#include <usb/usb.h>
    3838
    3939#include "vhcd.h"
    4040#include "conn.h"
    4141#include "hc.h"
    42 
    43 typedef struct {
    44         ipc_callid_t caller;
    45         void *buffer;
    46         size_t size;
    47 } async_transaction_t;
    48 
    49 static void async_out_callback(void * buffer, size_t len,
    50     usb_transaction_outcome_t outcome, void * arg)
    51 {
    52         async_transaction_t * trans = (async_transaction_t *)arg;
    53        
    54         dprintf(2, "async_out_callback(buffer, %u, %d, %p) -> %x",
    55             len, outcome, arg, trans->caller);
    56        
    57         // FIXME - answer according to outcome
    58         ipc_answer_1(trans->caller, EOK, 0);
    59        
    60         free(trans);
    61         if (buffer) {
    62                 free(buffer);
    63         }
    64         dprintf(4, "async_out_callback answered");
    65 }
    66 
    67 static void async_to_device(ipc_callid_t iid, ipc_call_t icall, bool setup_transaction)
    68 {
    69         size_t expected_len = IPC_GET_ARG3(icall);
    70         usb_target_t target = {
    71                 .address = IPC_GET_ARG1(icall),
    72                 .endpoint = IPC_GET_ARG2(icall)
    73         };
    74        
    75         dprintf(1, "async_to_device: dev=%d:%d, size=%d, iid=%x",
    76             target.address, target.endpoint, expected_len, iid);
    77        
    78         size_t len = 0;
    79         void * buffer = NULL;
    80         if (expected_len > 0) {
    81                 int rc = async_data_write_accept(&buffer, false,
    82                     1, USB_MAX_PAYLOAD_SIZE,
    83                     0, &len);
    84                
    85                 if (rc != EOK) {
    86                         ipc_answer_0(iid, rc);
    87                         return;
    88                 }
    89         }
    90        
    91         async_transaction_t * trans = malloc(sizeof(async_transaction_t));
    92         trans->caller = iid;
    93         trans->buffer = NULL;
    94         trans->size = 0;
    95        
    96         hc_add_transaction_to_device(setup_transaction, target,
    97             buffer, len,
    98             async_out_callback, trans);
    99        
    100         dprintf(2, "async transaction to device scheduled (%p)", trans);
    101 }
    102 
    103 static void async_in_callback(void * buffer, size_t len,
    104     usb_transaction_outcome_t outcome, void * arg)
    105 {       
    106         async_transaction_t * trans = (async_transaction_t *)arg;
    107        
    108         dprintf(2, "async_in_callback(buffer, %u, %d, %p) -> %x",
    109             len, outcome, arg, trans->caller);
    110        
    111         trans->buffer = buffer;
    112         trans->size = len;
    113        
    114         ipc_callid_t caller = trans->caller;
    115        
    116         if (buffer == NULL) {
    117                 free(trans);
    118                 trans = NULL;
    119         }
    120        
    121        
    122         // FIXME - answer according to outcome
    123         ipc_answer_1(caller, EOK, (ipcarg_t)trans);
    124         dprintf(4, "async_in_callback answered (%#x)", (ipcarg_t)trans);
    125 }
    126 
    127 static void async_from_device(ipc_callid_t iid, ipc_call_t icall)
    128 {
    129         usb_target_t target = {
    130                 .address = IPC_GET_ARG1(icall),
    131                 .endpoint = IPC_GET_ARG2(icall)
    132         };
    133         size_t len = IPC_GET_ARG3(icall);
    134        
    135         dprintf(1, "async_from_device: dev=%d:%d, size=%d, iid=%x",
    136             target.address, target.endpoint, len, iid);
    137        
    138         void * buffer = NULL;
    139         if (len > 0) {
    140                 buffer = malloc(len);
    141         }
    142        
    143         async_transaction_t * trans = malloc(sizeof(async_transaction_t));
    144         trans->caller = iid;
    145         trans->buffer = NULL;
    146         trans->size = 0;
    147        
    148         hc_add_transaction_from_device(target,
    149             buffer, len,
    150             async_in_callback, trans);
    151        
    152         dprintf(2, "async transfer from device scheduled (%p)", trans);
    153 }
    154 
    155 static void async_get_buffer(ipc_callid_t iid, ipc_call_t icall)
    156 {
    157         ipcarg_t buffer_hash = IPC_GET_ARG1(icall);
    158         async_transaction_t * trans = (async_transaction_t *)buffer_hash;
    159         if (trans == NULL) {
    160                 ipc_answer_0(iid, ENOENT);
    161                 return;
    162         }
    163         if (trans->buffer == NULL) {
    164                 ipc_answer_0(iid, EINVAL);
    165                 free(trans);
    166                 return;
    167         }
    168        
    169         ipc_callid_t callid;
    170         size_t accepted_size;
    171         if (!async_data_read_receive(&callid, &accepted_size)) {
    172                 ipc_answer_0(iid, EINVAL);
    173                 return;
    174         }
    175        
    176         if (accepted_size > trans->size) {
    177                 accepted_size = trans->size;
    178         }
    179         async_data_read_finalize(callid, trans->buffer, accepted_size);
    180        
    181         ipc_answer_1(iid, EOK, accepted_size);
    182        
    183         free(trans->buffer);
    184         free(trans);
    185 }
    186 
    187 
    188 /** Connection handler for communcation with host.
    189  * By host is typically meant top-level USB driver.
    190  *
    191  * This function also takes care of proper phone hung-up.
    192  *
    193  * @param phone_hash Incoming phone hash.
    194  */
    195 void connection_handler_host(ipcarg_t phone_hash)
    196 {
    197         dprintf(0, "host connected through phone %#x", phone_hash);
    198        
    199        
    200         while (true) {
    201                 ipc_callid_t callid;
    202                 ipc_call_t call;
    203                
    204                 callid = async_get_call(&call);
    205                
    206                 dprintf(6, "host on %#x calls [%x: %u (%u, %u, %u, %u, %u)]",
    207                     phone_hash,
    208                     callid,
    209                     IPC_GET_METHOD(call),
    210                     IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call),
    211                     IPC_GET_ARG4(call), IPC_GET_ARG5(call));
    212                
    213                 switch (IPC_GET_METHOD(call)) {
    214 
    215                         /* standard IPC methods */
    216 
    217                         case IPC_M_PHONE_HUNGUP:
    218                                 ipc_answer_0(callid, EOK);
    219                                 dprintf(0, "phone%#x: host hung-up",
    220                                     phone_hash);
    221                                 return;
    222                        
    223                         case IPC_M_CONNECT_TO_ME:
    224                                 ipc_answer_0(callid, ELIMIT);
    225                                 break;
    226                        
    227 
    228                         /* USB methods */
    229 
    230                         case IPC_M_USB_HCD_TRANSACTION_SIZE:
    231                                 ipc_answer_1(callid, EOK, USB_MAX_PAYLOAD_SIZE);
    232                                 break;
    233                        
    234                         case IPC_M_USB_HCD_GET_BUFFER_ASYNC:
    235                                 async_get_buffer(callid, call);
    236                                 break;
    237        
    238                         case IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC:
    239                         case IPC_M_USB_HCD_CONTROL_WRITE_DATA_ASYNC:
    240                         case IPC_M_USB_HCD_CONTROL_READ_STATUS_ASYNC:
    241                                 async_to_device(callid, call, false);
    242                                 break;
    243                        
    244                         case IPC_M_USB_HCD_CONTROL_WRITE_SETUP_ASYNC:
    245                         case IPC_M_USB_HCD_CONTROL_READ_SETUP_ASYNC:
    246                                 async_to_device(callid, call, true);
    247                                 break;
    248                        
    249                         case IPC_M_USB_HCD_INTERRUPT_IN_ASYNC:
    250                         case IPC_M_USB_HCD_CONTROL_WRITE_STATUS_ASYNC:
    251                         case IPC_M_USB_HCD_CONTROL_READ_DATA_ASYNC:
    252                                 async_from_device(callid, call);
    253                                 break;
    254                        
    255 
    256                         /* end of known methods */
    257                        
    258                         default:
    259                                 dprintf_inval_call(2, call, phone_hash);
    260                                 ipc_answer_0(callid, EINVAL);
    261                                 break;
    262                 }
    263         }
    264 }
    26542
    26643static int enqueue_transfer_out(usb_hc_device_t *hc,
  • uspace/drv/vhc/devices.h

    r0e126be7 r4b4c797  
    3737
    3838#include <adt/list.h>
    39 #include <usb/hcd.h>
     39#include <usb/usb.h>
    4040
    4141#include "hc.h"
  • uspace/drv/vhc/hc.h

    r0e126be7 r4b4c797  
    3636#define VHCD_HC_H_
    3737
    38 #include <usb/hcd.h>
     38#include <usb/usb.h>
    3939#include <usbvirt/hub.h>
    4040
  • uspace/drv/vhc/hcd.c

    r0e126be7 r4b4c797  
    4545#include <driver.h>
    4646
    47 #include <usb/hcd.h>
     47#include <usb/usb.h>
    4848#include "vhcd.h"
    4949#include "hc.h"
  • uspace/drv/vhc/hub.c

    r0e126be7 r4b4c797  
    3333 * @brief Virtual USB hub.
    3434 */
    35 #include <usb/classes.h>
     35#include <usb/classes/classes.h>
    3636#include <usbvirt/hub.h>
    3737#include <usbvirt/device.h>
  • uspace/drv/vhc/hubops.c

    r0e126be7 r4b4c797  
    3333 * @brief Virtual USB hub operations.
    3434 */
    35 #include <usb/classes.h>
    36 #include <usb/hub.h>
     35#include <usb/classes/classes.h>
     36#include <usb/classes/hub.h>
    3737#include <usbvirt/hub.h>
    3838#include <usbvirt/device.h>
  • uspace/lib/drv/Makefile

    r0e126be7 r4b4c797  
    2929
    3030USPACE_PREFIX = ../..
    31 EXTRA_CFLAGS = -Iinclude -I$(LIB_PREFIX)
     31EXTRA_CFLAGS = -Iinclude -I$(LIBUSB_PREFIX)/include
    3232LIBRARY = libdrv
    3333
  • uspace/lib/usb/Makefile

    r0e126be7 r4b4c797  
    3030LIBRARY = libusb
    3131LIBS = $(LIBDRV_PREFIX)/libdrv.a
    32 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIB_PREFIX)
     32EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -Iinclude
    3333
    3434SOURCES = \
    35         hcd.c \
    36         hcdhubd.c \
    37         usb.c \
    38         usbdrv.c
     35        src/hcdhubd.c \
     36        src/usb.c \
     37        src/usbdrv.c
    3938
    4039include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/usb/include/usb/devreq.h

    r0e126be7 r4b4c797  
    7575                uint16_t value;
    7676        };
    77         /** Auxilary parameter to the request.
     77        /** Auxiliary parameter to the request.
    7878         * Typically, it is offset to something.
    7979         */
  • uspace/lib/usb/include/usb/hcdhubd.h

    r0e126be7 r4b4c797  
    3838#include <adt/list.h>
    3939#include <driver.h>
    40 #include "usb.h"
    41 #include "hcd.h"
     40#include <usb/usb.h>
    4241
    4342/** Endpoint properties. */
  • uspace/lib/usb/include/usb/usb.h

    r0e126be7 r4b4c797  
    9898typedef ipcarg_t usb_handle_t;
    9999
     100/** USB packet identifier. */
     101typedef enum {
     102#define _MAKE_PID_NIBBLE(tag, type) \
     103        ((uint8_t)(((tag) << 2) | (type)))
     104#define _MAKE_PID(tag, type) \
     105        ( \
     106            _MAKE_PID_NIBBLE(tag, type) \
     107            | ((~_MAKE_PID_NIBBLE(tag, type)) << 4) \
     108        )
     109        USB_PID_OUT = _MAKE_PID(0, 1),
     110        USB_PID_IN = _MAKE_PID(2, 1),
     111        USB_PID_SOF = _MAKE_PID(1, 1),
     112        USB_PID_SETUP = _MAKE_PID(3, 1),
     113
     114        USB_PID_DATA0 = _MAKE_PID(0 ,3),
     115        USB_PID_DATA1 = _MAKE_PID(2 ,3),
     116
     117        USB_PID_ACK = _MAKE_PID(0 ,2),
     118        USB_PID_NAK = _MAKE_PID(2 ,2),
     119        USB_PID_STALL = _MAKE_PID(3 ,2),
     120
     121        USB_PID_PRE = _MAKE_PID(3 ,0),
     122        /* USB_PID_ = _MAKE_PID( ,), */
     123#undef _MAKE_PID
     124#undef _MAKE_PID_NIBBLE
     125} usb_packet_id;
     126
    100127#endif
    101128/**
  • uspace/lib/usb/src/hcdhubd.c

    r0e126be7 r4b4c797  
    3333 * @brief HC driver and hub driver (implementation).
    3434 */
    35 #include "hcdhubd.h"
     35#include <usb/hcdhubd.h>
    3636#include <usb_iface.h>
    3737#include <driver.h>
  • uspace/lib/usb/src/usb.c

    r0e126be7 r4b4c797  
    3333 * @brief Base USB types.
    3434 */
    35 #include "usb.h"
     35#include <usb/usb.h>
    3636#include <errno.h>
    3737
  • uspace/lib/usb/src/usbdrv.c

    r0e126be7 r4b4c797  
    3333 * @brief USB driver (implementation).
    3434 */
    35 #include "usbdrv.h"
     35#include <usb/usbdrv.h>
    3636#include <usb_iface.h>
    3737#include <errno.h>
  • uspace/lib/usbvirt/Makefile

    r0e126be7 r4b4c797  
    3131
    3232LIBS = $(LIBUSB_PREFIX)/libusb.a
    33 EXTRA_CFLAGS = -I$(LIB_PREFIX)
     33EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include
    3434
    3535SOURCES = \
  • uspace/lib/usbvirt/callback.c

    r0e126be7 r4b4c797  
    4545
    4646#define NAMESPACE "usb"
     47#define USB_MAX_PAYLOAD_SIZE 1020
    4748
    4849/** Wrapper for SETUP transaction over telephone. */
  • uspace/lib/usbvirt/device.h

    r0e126be7 r4b4c797  
    3636#define LIBUSBVIRT_DEVICE_H_
    3737
    38 #include <usb/hcd.h>
     38#include <usb/usb.h>
    3939#include <usb/descriptor.h>
    4040#include <usb/devreq.h>
Note: See TracChangeset for help on using the changeset viewer.