Changeset 1cb4f05 in mainline


Ignore:
Timestamp:
2011-07-11T08:52:43Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aa81adc
Parents:
a00768c
Message:

OHCI: Make error messages consistent and some minor reshuffling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    ra00768c r1cb4f05  
    5656};
    5757
     58static void hc_gain_control(hc_t *instance);
    5859static void hc_start(hc_t *instance);
    59 static int interrupt_emulator(hc_t *instance);
    60 static void hc_gain_control(hc_t *instance);
    6160static int hc_init_transfer_lists(hc_t *instance);
    6261static int hc_init_memory(hc_t *instance);
     62static int interrupt_emulator(hc_t *instance);
     63
     64/*----------------------------------------------------------------------------*/
     65/** Get number of commands used in IRQ code.
     66 * @return Number of commands.
     67 */
     68size_t hc_irq_cmd_count(void)
     69{
     70        return sizeof(ohci_irq_commands) / sizeof(irq_cmd_t);
     71}
     72/*----------------------------------------------------------------------------*/
     73/** Generate IRQ code commands.
     74 * @param[out] cmds Place to store the commands.
     75 * @param[in] cmd_size Size of the place (bytes).
     76 * @param[in] regs Physical address of device's registers.
     77 * @param[in] reg_size Size of the register area (bytes).
     78 *
     79 * @return Error code.
     80 */
     81int hc_get_irq_commands(
     82    irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size)
     83{
     84        if (cmd_size < sizeof(ohci_irq_commands)
     85            || reg_size < sizeof(ohci_regs_t))
     86                return EOVERFLOW;
     87
     88        /* Create register mapping to use in IRQ handler.
     89         * This mapping should be present in kernel only.
     90         * Remove it from here when kernel knows how to create mappings
     91         * and accepts physical addresses in IRQ code.
     92         * TODO: remove */
     93        ohci_regs_t *registers;
     94        const int ret = pio_enable((void*)regs, reg_size, (void**)&registers);
     95
     96        /* Some bogus access to force create mapping. DO NOT remove,
     97         * unless whole virtual addresses in irq is replaced
     98         * NOTE: Compiler won't remove this as ohci_regs_t members
     99         * are declared volatile. */
     100        registers->revision;
     101
     102        if (ret != EOK)
     103                return ret;
     104
     105        memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands));
     106
     107        void *address = (void*)&registers->interrupt_status;
     108        cmds[0].addr = address;
     109        cmds[3].addr = address;
     110        return EOK;
     111}
    63112/*----------------------------------------------------------------------------*/
    64113/** Announce OHCI root hub to the DDF
     
    94143        int ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL,
    95144            USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH, 64, 0, 0);
    96         CHECK_RET_RELEASE(ret, "Failed(%d) to add OHCI rh endpoint 0.\n", ret);
     145        CHECK_RET_RELEASE(ret,
     146            "Failed to add OHCI root hub endpoint 0: %s.\n", str_error(ret));
    97147
    98148        char *match_str = NULL;
    99         /* DDF needs heap allocated string */
     149        /* DDF needs heap allocated string. */
    100150        ret = asprintf(&match_str, "usb&class=hub");
    101151        ret = ret > 0 ? 0 : ret;
    102         CHECK_RET_RELEASE(ret, "Failed(%d) to create match-id string.\n", ret);
     152        CHECK_RET_RELEASE(ret,
     153            "Failed to create match-id string: %s.\n", str_error(ret));
    103154
    104155        ret = ddf_fun_add_match_id(hub_fun, match_str, 100);
    105         CHECK_RET_RELEASE(ret, "Failed(%d) add root hub match-id.\n", ret);
     156        CHECK_RET_RELEASE(ret,
     157            "Failed to add root hub match-id: %s.\n", str_error(ret));
    106158
    107159        ret = ddf_fun_bind(hub_fun);
    108         CHECK_RET_RELEASE(ret, "Failed(%d) to bind root hub function.\n", ret);
     160        CHECK_RET_RELEASE(ret,
     161            "Failed to bind root hub function: %s.\n", str_error(ret));
    109162
    110163        return EOK;
     
    123176{
    124177        assert(instance);
    125         int ret = EOK;
     178
    126179#define CHECK_RET_RETURN(ret, message...) \
    127180if (ret != EOK) { \
     
    130183} else (void)0
    131184
    132         ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
     185        int ret =
     186            pio_enable((void*)regs, reg_size, (void**)&instance->registers);
    133187        CHECK_RET_RETURN(ret,
    134             "Failed(%d) to gain access to device registers: %s.\n",
    135             ret, str_error(ret));
     188            "Failed to gain access to device registers: %s.\n", str_error(ret));
    136189
    137190        list_initialize(&instance->pending_batches);
    138191        usb_device_keeper_init(&instance->manager);
     192
    139193        ret = usb_endpoint_manager_init(&instance->ep_manager,
    140194            BANDWIDTH_AVAILABLE_USB11);
     
    160214        hc_start(instance);
    161215
    162         return EOK;
    163 }
    164 /*----------------------------------------------------------------------------*/
    165 /** Get number of commands used in IRQ code.
    166  * @return Number of commands.
    167  */
    168 size_t hc_irq_cmd_count(void)
    169 {
    170         return sizeof(ohci_irq_commands) / sizeof(irq_cmd_t);
    171 }
    172 /*----------------------------------------------------------------------------*/
    173 /** Generate IRQ code commands.
    174  * @param[out] cmds Place to store the commands.
    175  * @param[in] cmd_size Size of the place (bytes).
    176  * @param[in] regs Physical address of device's registers.
    177  * @param[in] reg_size Size of the register area (bytes).
    178  *
    179  * @return Error code.
    180  */
    181 int hc_get_irq_commands(
    182     irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size)
    183 {
    184         if (cmd_size < sizeof(ohci_irq_commands)
    185             || reg_size < sizeof(ohci_regs_t))
    186                 return EOVERFLOW;
    187 
    188         /* Create register mapping to use in IRQ handler.
    189          * This mapping should be present in kernel only.
    190          * Remove it from here when kernel knows how to create mappings
    191          * and accepts physical addresses in IRQ code.
    192          * TODO: remove */
    193         ohci_regs_t *registers;
    194         const int ret = pio_enable((void*)regs, reg_size, (void**)&registers);
    195 
    196         /* Some bogus access to force create mapping. DO NOT remove,
    197          * unless whole virtual addresses in irq is replaced
    198          * NOTE: Compiler won't remove this as ohci_regs_t members
    199          * are declared volatile. */
    200         registers->revision;
    201 
    202         if (ret != EOK)
    203                 return ret;
    204 
    205         memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands));
    206 
    207         void *address = (void*)&registers->interrupt_status;
    208         cmds[0].addr = address;
    209         cmds[3].addr = address;
    210216        return EOK;
    211217}
     
    606612        int ret = endpoint_list_init(&instance->lists[type], name); \
    607613        if (ret != EOK) { \
    608                 usb_log_error("Failed(%d) to setup %s endpoint list.\n", \
    609                     ret, name); \
     614                usb_log_error("Failed to setup %s endpoint list: %s.\n", \
     615                    name, str_error(ret)); \
    610616                endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]);\
    611617                endpoint_list_fini(&instance->lists[USB_TRANSFER_INTERRUPT]); \
Note: See TracChangeset for help on using the changeset viewer.