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

Changeset 09ace19 in mainline


Ignore:
Timestamp:
2011-08-25T15:33:41Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
f974519
Parents:
cc34f5f0
Message:

ohci: remove unused code

Location:
uspace/drv/bus/usb/ohci
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/Makefile

    rcc34f5f0 r09ace19  
    4747        endpoint_list.c \
    4848        hc.c \
    49         iface.c \
    5049        main.c \
    5150        ohci.c \
  • uspace/drv/bus/usb/ohci/batch.c

    rcc34f5f0 r09ace19  
    4343#include "hw_struct/endpoint_descriptor.h"
    4444#include "hw_struct/transfer_descriptor.h"
    45 /*
     45
    4646static void batch_control_write(usb_transfer_batch_t *instance);
    4747static void batch_control_read(usb_transfer_batch_t *instance);
     
    5252static void batch_bulk_in(usb_transfer_batch_t *instance);
    5353static void batch_bulk_out(usb_transfer_batch_t *instance);
    54 */
     54
    5555static void batch_setup_control(usb_transfer_batch_t *batch)
    5656{
     
    173173        return EOK;
    174174#undef CHECK_NULL_DISPOSE_RETURN
    175 }
    176 /*----------------------------------------------------------------------------*/
    177 /** Allocate memory initialize internal structures
    178  *
    179  * @param[in] fun DDF function to pass to callback.
    180  * @param[in] ep Communication target
    181  * @param[in] buffer Data source/destination.
    182  * @param[in] buffer_size Size of the buffer.
    183  * @param[in] setup_buffer Setup data source (if not NULL)
    184  * @param[in] setup_size Size of setup_buffer (should be always 8)
    185  * @param[in] func_in function to call on inbound transfer completion
    186  * @param[in] func_out function to call on outbound transfer completion
    187  * @param[in] arg additional parameter to func_in or func_out
    188  * @return Valid pointer if all structures were successfully created,
    189  * NULL otherwise.
    190  *
    191  * Allocates and initializes structures needed by the OHCI hw for the transfer.
    192  */
    193 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep,
    194     char *buffer, size_t buffer_size,
    195     const char *setup_buffer, size_t setup_size,
    196     usbhc_iface_transfer_in_callback_t func_in,
    197     usbhc_iface_transfer_out_callback_t func_out, void *arg)
    198 {
    199 #define CHECK_NULL_DISPOSE_RETURN(ptr, message...) \
    200         if (ptr == NULL) { \
    201                 usb_log_error(message); \
    202                 if (instance) { \
    203                         usb_transfer_batch_dispose(instance); \
    204                 } \
    205                 return NULL; \
    206         } else (void)0
    207 
    208         usb_transfer_batch_t *instance = malloc(sizeof(usb_transfer_batch_t));
    209         CHECK_NULL_DISPOSE_RETURN(instance,
    210             "Failed to allocate batch instance.\n");
    211         usb_transfer_batch_init(instance, ep, buffer, NULL, buffer_size,
    212             NULL, setup_size, func_in, func_out, arg, fun, NULL,
    213             ohci_batch_dispose);
    214 
    215         const ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep);
    216         assert(ohci_ep);
    217 
    218         ohci_transfer_batch_t *data = calloc(sizeof(ohci_transfer_batch_t), 1);
    219         CHECK_NULL_DISPOSE_RETURN(data, "Failed to allocate batch data.\n");
    220         instance->private_data = data;
    221 
    222         data->td_count =
    223             ((buffer_size + OHCI_TD_MAX_TRANSFER - 1) / OHCI_TD_MAX_TRANSFER);
    224         /* Control transfer need Setup and Status stage */
    225         if (ep->transfer_type == USB_TRANSFER_CONTROL) {
    226                 data->td_count += 2;
    227         }
    228 
    229         /* We need an extra place for TD that is currently assigned to hcd_ep*/
    230         data->tds = calloc(sizeof(td_t*), data->td_count + 1);
    231         CHECK_NULL_DISPOSE_RETURN(data->tds,
    232             "Failed to allocate transfer descriptors.\n");
    233 
    234         /* Add TD left over by the previous transfer */
    235         data->tds[0] = ohci_ep->td;
    236         data->leave_td = 0;
    237         unsigned i = 1;
    238         for (; i <= data->td_count; ++i) {
    239                 data->tds[i] = malloc32(sizeof(td_t));
    240                 CHECK_NULL_DISPOSE_RETURN(data->tds[i],
    241                     "Failed to allocate TD %d.\n", i );
    242         }
    243 
    244         data->ed = ohci_ep->ed;
    245 
    246         /* NOTE: OHCI is capable of handling buffer that crosses page boundaries
    247          * it is, however, not capable of handling buffer that occupies more
    248          * than two pages (the first page is computed using start pointer, the
    249          * other using the end pointer) */
    250         if (setup_size + buffer_size > 0) {
    251                 data->device_buffer = malloc32(setup_size + buffer_size);
    252                 CHECK_NULL_DISPOSE_RETURN(data->device_buffer,
    253                     "Failed to allocate device accessible buffer.\n");
    254                 instance->setup_buffer = data->device_buffer;
    255                 instance->data_buffer = data->device_buffer + setup_size;
    256                 memcpy(instance->setup_buffer, setup_buffer, setup_size);
    257         }
    258 
    259         return instance;
    260175}
    261176/*----------------------------------------------------------------------------*/
  • uspace/drv/bus/usb/ohci/batch.h

    rcc34f5f0 r09ace19  
    4141#include <usb/host/batch.h>
    4242
    43 usb_transfer_batch_t * batch_get(
    44     ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size,
    45     const char *setup_buffer, size_t setup_size,
    46     usbhc_iface_transfer_in_callback_t func_in,
    47     usbhc_iface_transfer_out_callback_t func_out,
    48     void *arg);
    49 
    5043int batch_init_ohci(usb_transfer_batch_t *batch);
    51 
    5244bool batch_is_complete(usb_transfer_batch_t *batch);
    53 
    54 void batch_commit(usb_transfer_batch_t *instance);
    55 
    56 void batch_control_write(usb_transfer_batch_t *instance);
    57 
    58 void batch_control_read(usb_transfer_batch_t *instance);
    59 
    60 void batch_interrupt_in(usb_transfer_batch_t *instance);
    61 
    62 void batch_interrupt_out(usb_transfer_batch_t *instance);
    63 
    64 void batch_bulk_in(usb_transfer_batch_t *instance);
    65 
    66 void batch_bulk_out(usb_transfer_batch_t *instance);
     45void batch_commit(usb_transfer_batch_t *batch);
    6746#endif
    6847/**
  • uspace/drv/bus/usb/ohci/hc.c

    rcc34f5f0 r09ace19  
    6161static int hc_init_memory(hc_t *instance);
    6262static int interrupt_emulator(hc_t *instance);
    63 /*----------------------------------------------------------------------------*/
    64 static int schedule(hcd_t *hcd, usb_transfer_batch_t *batch)
    65 {
    66         assert(hcd);
    67         batch_init_ohci(batch);
    68         return hc_schedule(hcd->private_data, batch);
    69 }
     63static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    7064/*----------------------------------------------------------------------------*/
    7165/** Get number of commands used in IRQ code.
     
    211205
    212206        list_initialize(&instance->pending_batches);
    213         usb_device_keeper_init(&instance->manager);
    214 
    215         ret = usb_endpoint_manager_init(&instance->ep_manager,
    216             BANDWIDTH_AVAILABLE_USB11);
    217         CHECK_RET_RETURN(ret, "Failed to initialize endpoint manager: %s.\n",
    218             str_error(ret));
    219207
    220208        ret = hcd_init(&instance->generic, BANDWIDTH_AVAILABLE_USB11);
     
    222210            str_error(ret));
    223211        instance->generic.private_data = instance;
    224         instance->generic.schedule = schedule;
     212        instance->generic.schedule = hc_schedule;
    225213        instance->generic.ep_add_hook = ohci_endpoint_init;
    226214
     
    302290}
    303291/*----------------------------------------------------------------------------*/
    304 /** Create and register endpoint structures.
    305  *
    306  * @param[in] instance OHCI driver structure.
    307  * @param[in] address USB address of the device.
    308  * @param[in] endpoint USB endpoint number.
    309  * @param[in] speed Communication speeed of the device.
    310  * @param[in] type Endpoint's transfer type.
    311  * @param[in] direction Endpoint's direction.
    312  * @param[in] mps Maximum packet size the endpoint accepts.
    313  * @param[in] size Maximum allowed buffer size.
    314  * @param[in] interval Time between transfers(interrupt transfers only).
    315  * @return Error code
    316  */
    317 int hc_add_endpoint(
    318     hc_t *instance, usb_address_t address, usb_endpoint_t endpoint,
    319     usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction,
    320     size_t mps, size_t size, unsigned interval)
    321 {
    322         endpoint_t *ep =
    323             endpoint_get(address, endpoint, direction, type, speed, mps);
    324         if (ep == NULL)
    325                 return ENOMEM;
    326 
    327         int ret = ohci_endpoint_init(&instance->generic, ep);
    328         if (ret != EOK) {
    329                 endpoint_destroy(ep);
    330                 return ret;
    331         }
    332 
    333         ret = usb_endpoint_manager_register_ep(&instance->ep_manager, ep, size);
    334         if (ret != EOK) {
    335                 endpoint_destroy(ep);
    336                 return ret;
    337         }
    338         hc_enqueue_endpoint(instance, ep);
    339 
    340         return EOK;
    341 }
    342 /*----------------------------------------------------------------------------*/
    343 /** Dequeue and delete endpoint structures
    344  *
    345  * @param[in] instance OHCI hc driver structure.
    346  * @param[in] address USB address of the device.
    347  * @param[in] endpoint USB endpoint number.
    348  * @param[in] direction Direction of the endpoint.
    349  * @return Error code
    350  */
    351 int hc_remove_endpoint(hc_t *instance, usb_address_t address,
    352     usb_endpoint_t endpoint, usb_direction_t direction)
    353 {
    354         assert(instance);
    355         fibril_mutex_lock(&instance->guard);
    356         endpoint_t *ep = usb_endpoint_manager_get_ep(&instance->ep_manager,
    357             address, endpoint, direction, NULL);
    358         if (ep == NULL) {
    359                 usb_log_error("Endpoint unregister failed: No such EP.\n");
    360                 fibril_mutex_unlock(&instance->guard);
    361                 return ENOENT;
    362         }
    363 
    364         ohci_endpoint_t *ohci_ep = ohci_endpoint_get(ep);
    365         if (ohci_ep) {
    366                 hc_dequeue_endpoint(instance, ep);
    367         } else {
    368                 usb_log_warning("Endpoint without hcd equivalent structure.\n");
    369         }
    370         int ret = usb_endpoint_manager_unregister_ep(&instance->ep_manager,
    371             address, endpoint, direction);
    372         fibril_mutex_unlock(&instance->guard);
    373         return ret;
    374 }
    375 /*----------------------------------------------------------------------------*/
    376 /** Get access to endpoint structures
    377  *
    378  * @param[in] instance OHCI hc driver structure.
    379  * @param[in] address USB address of the device.
    380  * @param[in] endpoint USB endpoint number.
    381  * @param[in] direction Direction of the endpoint.
    382  * @param[out] bw Reserved bandwidth.
    383  * @return Error code
    384  */
    385 endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address,
    386     usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw)
    387 {
    388         assert(instance);
    389         fibril_mutex_lock(&instance->guard);
    390         endpoint_t *ep = usb_endpoint_manager_get_ep(&instance->ep_manager,
    391             address, endpoint, direction, bw);
    392         fibril_mutex_unlock(&instance->guard);
    393         return ep;
    394 }
    395 /*----------------------------------------------------------------------------*/
    396292/** Add USB transfer to the schedule.
    397293 *
     
    400296 * @return Error code.
    401297 */
    402 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch)
    403 {
    404         assert(instance);
    405         assert(batch);
    406         assert(batch->ep);
     298int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch)
     299{
     300        assert(hcd);
     301        batch_init_ohci(batch);
     302        hc_t *instance = hcd->private_data;
     303        assert(instance);
    407304
    408305        /* Check for root hub communication */
  • uspace/drv/bus/usb/ohci/hc.h

    rcc34f5f0 r09ace19  
    5353/** Main OHCI driver structure */
    5454typedef struct hc {
    55         /** USB bus driver, devices and addresses */
    56         usb_device_keeper_t manager;
    57         /** USB bus driver, endpoints */
    58         usb_endpoint_manager_t ep_manager;
    59 
    6055        /** Generic USB hc driver */
    6156        hcd_t generic;
     
    9186 * @param[in] instance Host controller structure to use.
    9287 */
    93 static inline void hc_fini(hc_t *instance)
    94         { /* TODO: implement*/ };
     88static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ };
    9589
    9690void hc_enqueue_endpoint(hc_t *instance, endpoint_t *ep);
    9791void hc_dequeue_endpoint(hc_t *instance, endpoint_t *ep);
    9892
    99 int hc_add_endpoint(hc_t *instance, usb_address_t address, usb_endpoint_t ep,
    100     usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction,
    101     size_t max_packet_size, size_t size, unsigned interval);
    102 int hc_remove_endpoint(hc_t *instance, usb_address_t address,
    103     usb_endpoint_t endpoint, usb_direction_t direction);
    104 endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address,
    105     usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw);
    106 
    107 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
    10893void hc_interrupt(hc_t *instance, uint32_t status);
    109 
    110 /** Get and cast pointer to the driver data
    111  *
    112  * @param[in] fun DDF function pointer
    113  * @return cast pointer to driver_data
    114  */
    115 static inline hc_t * fun_to_hc(ddf_fun_t *fun)
    116         { return fun->driver_data; }
    11794#endif
    11895/**
  • uspace/drv/bus/usb/ohci/ohci.c

    rcc34f5f0 r09ace19  
    4242
    4343#include "ohci.h"
    44 #include "iface.h"
    4544#include "pci.h"
    4645#include "hc.h"
Note: See TracChangeset for help on using the changeset viewer.