Changeset 50114ef in mainline for uspace/drv/uhci-hcd/hc.c


Ignore:
Timestamp:
2011-03-24T13:45:48Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
915a851
Parents:
5f80527 (diff), e18e0d6 (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 development/ changes

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/hc.c

    r5f80527 r50114ef  
    4242#include <usb_iface.h>
    4343
    44 #include "uhci_hc.h"
     44#include "hc.h"
    4545
    4646static irq_cmd_t uhci_cmds[] = {
     
    6060};
    6161/*----------------------------------------------------------------------------*/
    62 static int uhci_hc_init_transfer_lists(uhci_hc_t *instance);
    63 static int uhci_hc_init_mem_structures(uhci_hc_t *instance);
    64 static void uhci_hc_init_hw(uhci_hc_t *instance);
    65 
    66 static int uhci_hc_interrupt_emulator(void *arg);
    67 static int uhci_hc_debug_checker(void *arg);
    68 
    69 static bool allowed_usb_packet(
     62static int hc_init_transfer_lists(hc_t *instance);
     63static int hc_init_mem_structures(hc_t *instance);
     64static void hc_init_hw(hc_t *instance);
     65
     66static int hc_interrupt_emulator(void *arg);
     67static int hc_debug_checker(void *arg);
     68
     69static bool usb_is_allowed(
    7070    bool low_speed, usb_transfer_type_t transfer, size_t size);
    7171/*----------------------------------------------------------------------------*/
     
    8282 * interrupt fibrils.
    8383 */
    84 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun,
     84int hc_init(hc_t *instance, ddf_fun_t *fun,
    8585    void *regs, size_t reg_size, bool interrupts)
    8686{
     
    112112            io, reg_size);
    113113
    114         ret = uhci_hc_init_mem_structures(instance);
     114        ret = hc_init_mem_structures(instance);
    115115        CHECK_RET_DEST_FUN_RETURN(ret,
    116116            "Failed to initialize UHCI memory structures.\n");
    117117
    118         uhci_hc_init_hw(instance);
     118        hc_init_hw(instance);
    119119        if (!interrupts) {
    120120                instance->cleaner =
    121                     fibril_create(uhci_hc_interrupt_emulator, instance);
     121                    fibril_create(hc_interrupt_emulator, instance);
    122122                fibril_add_ready(instance->cleaner);
    123123        } else {
     
    125125        }
    126126
    127         instance->debug_checker = fibril_create(uhci_hc_debug_checker, instance);
    128         fibril_add_ready(instance->debug_checker);
     127        instance->debug_checker =
     128            fibril_create(hc_debug_checker, instance);
     129//      fibril_add_ready(instance->debug_checker);
    129130
    130131        return EOK;
     
    137138 * For magic values see UHCI Design Guide
    138139 */
    139 void uhci_hc_init_hw(uhci_hc_t *instance)
     140void hc_init_hw(hc_t *instance)
    140141{
    141142        assert(instance);
     
    185186 *  - frame list page (needs to be one UHCI hw accessible 4K page)
    186187 */
    187 int uhci_hc_init_mem_structures(uhci_hc_t *instance)
     188int hc_init_mem_structures(hc_t *instance)
    188189{
    189190        assert(instance);
     
    214215
    215216        /* Init transfer lists */
    216         ret = uhci_hc_init_transfer_lists(instance);
     217        ret = hc_init_transfer_lists(instance);
    217218        CHECK_RET_DEST_CMDS_RETURN(ret, "Failed to init transfer lists.\n");
    218219        usb_log_debug("Initialized transfer lists.\n");
     
    235236
    236237        /* Init device keeper*/
    237         usb_device_keeper_init(&instance->device_manager);
     238        usb_device_keeper_init(&instance->manager);
    238239        usb_log_debug("Initialized device manager.\n");
    239240
     
    251252 * USB scheduling. Sets pointer table for quick access.
    252253 */
    253 int uhci_hc_init_transfer_lists(uhci_hc_t *instance)
     254int hc_init_transfer_lists(hc_t *instance)
    254255{
    255256        assert(instance);
     
    317318 * Checks for bandwidth availability and appends the batch to the proper queue.
    318319 */
    319 int uhci_hc_schedule(uhci_hc_t *instance, usb_transfer_batch_t *batch)
     320int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch)
    320321{
    321322        assert(instance);
    322323        assert(batch);
    323324        const int low_speed = (batch->speed == USB_SPEED_LOW);
    324         if (!allowed_usb_packet(
     325        if (!usb_is_allowed(
    325326            low_speed, batch->transfer_type, batch->max_packet_size)) {
    326327                usb_log_warning(
    327                     "Invalid USB packet specified %s SPEED %d %zu.\n",
     328                    "Invalid USB transfer specified %s SPEED %d %zu.\n",
    328329                    low_speed ? "LOW" : "FULL" , batch->transfer_type,
    329330                    batch->max_packet_size);
     
    350351 * - resume from suspend state (not implemented)
    351352 */
    352 void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status)
     353void hc_interrupt(hc_t *instance, uint16_t status)
    353354{
    354355        assert(instance);
     
    372373                if (instance->hw_failures < UHCI_ALLOWED_HW_FAIL) {
    373374                        /* reinitialize hw, this triggers virtual disconnect*/
    374                         uhci_hc_init_hw(instance);
     375                        hc_init_hw(instance);
    375376                } else {
    376377                        usb_log_fatal("Too many UHCI hardware failures!.\n");
    377                         uhci_hc_fini(instance);
     378                        hc_fini(instance);
    378379                }
    379380        }
     
    385386 * @return EOK (should never return)
    386387 */
    387 int uhci_hc_interrupt_emulator(void* arg)
     388int hc_interrupt_emulator(void* arg)
    388389{
    389390        usb_log_debug("Started interrupt emulator.\n");
    390         uhci_hc_t *instance = (uhci_hc_t*)arg;
     391        hc_t *instance = (hc_t*)arg;
    391392        assert(instance);
    392393
     
    397398                if (status != 0)
    398399                        usb_log_debug2("UHCI status: %x.\n", status);
    399                 uhci_hc_interrupt(instance, status);
     400                hc_interrupt(instance, status);
    400401                async_usleep(UHCI_CLEANER_TIMEOUT);
    401402        }
     
    408409 * @return EOK (should never return)
    409410 */
    410 int uhci_hc_debug_checker(void *arg)
    411 {
    412         uhci_hc_t *instance = (uhci_hc_t*)arg;
     411int hc_debug_checker(void *arg)
     412{
     413        hc_t *instance = (hc_t*)arg;
    413414        assert(instance);
    414415
     
    470471}
    471472/*----------------------------------------------------------------------------*/
    472 /** Check transfer packets, for USB validity
     473/** Check transfers for USB validity
    473474 *
    474475 * @param[in] low_speed Transfer speed.
    475476 * @param[in] transfer Transer type
    476  * @param[in] size Maximum size of used packets
     477 * @param[in] size Size of data packets
    477478 * @return True if transaction is allowed by USB specs, false otherwise
    478479 */
    479 bool allowed_usb_packet(
     480bool usb_is_allowed(
    480481    bool low_speed, usb_transfer_type_t transfer, size_t size)
    481482{
Note: See TracChangeset for help on using the changeset viewer.