Changeset 1b90e90 in mainline


Ignore:
Timestamp:
2012-03-05T20:51:42Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
81716eb
Parents:
45f4f19
Message:

ohci: Improve HCCA structure handling. Add comments.

Fix minor root hub bug.

Location:
uspace/drv/bus/usb/ohci
Files:
3 edited

Legend:

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

    r45f4f19 r1b90e90  
    592592        if (instance->hcca == NULL)
    593593                return ENOMEM;
    594         bzero(instance->hcca, sizeof(hcca_t));
    595594        usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca);
    596595
    597         for (unsigned i = 0; i < 32; ++i) {
    598                 OHCI_WR(instance->hcca->int_ep[i],
     596        for (unsigned i = 0; i < HCCA_INT_EP_COUNT; ++i) {
     597                hcca_set_int_ep(instance->hcca, i,
    599598                    instance->lists[USB_TRANSFER_INTERRUPT].list_head_pa);
    600599        }
  • uspace/drv/bus/usb/ohci/hw_struct/hcca.h

    r45f4f19 r1b90e90  
    3838#include <malloc.h>
    3939
     40#include "mem_access.h"
     41
     42#define HCCA_INT_EP_COUNT  32
     43
    4044/** Host controller communication area.
    4145 * Shared memory used for communication between the controller and the driver.
    4246 */
    4347typedef struct hcca {
    44         uint32_t int_ep[32];
     48        /** Interrupt endpoints */
     49        uint32_t int_ep[HCCA_INT_EP_COUNT];
     50        /** Frame number. */
    4551        uint16_t frame_number;
    4652        uint16_t pad1;
     53        /** Pointer to the last completed TD. (useless) */
    4754        uint32_t done_head;
     55        /** Padding to make the size 256B */
    4856        uint32_t reserved[29];
    4957} __attribute__((packed, aligned)) hcca_t;
    5058
    51 static inline void * hcca_get(void)
     59/** Allocate properly aligned structure.
     60 *
     61 * The returned structure is zeroed upon allocation.
     62 *
     63 * @return Usable HCCA memory structure.
     64 */
     65static inline hcca_t * hcca_get(void)
    5266{
    5367        assert(sizeof(hcca_t) == 256);
    54         return memalign(256, sizeof(hcca_t));
     68        hcca_t *hcca = memalign(256, sizeof(hcca_t));
     69        if (hcca)
     70                bzero(hcca, sizeof(hcca_t));
     71        return hcca;
     72}
     73
     74/** Set HCCA interrupt endpoint pointer table entry.
     75 * @param hcca HCCA memory structure.
     76 * @param index table index.
     77 * @param pa Physical address.
     78 */
     79static inline void hcca_set_int_ep(hcca_t *hcca, unsigned index, uintptr_t pa)
     80{
     81        assert(hcca);
     82        assert(index < HCCA_INT_EP_COUNT);
     83        OHCI_MEM32_WR(hcca->int_ep[index], pa);
     84
    5585}
    5686#endif
  • uspace/drv/bus/usb/ohci/root_hub.c

    r45f4f19 r1b90e90  
    434434                        /* Register format matches the format of port status
    435435                         * field */
    436                         const uint32_t data = uint32_usb2host(OHCI_RD(
     436                        const uint32_t data = uint32_host2usb(OHCI_RD(
    437437                            instance->registers->rh_port_status[port - 1]));
    438438                        TRANSFER_END_DATA(request, &data, sizeof(data));
Note: See TracChangeset for help on using the changeset viewer.