~jsvoboda/helenos/dnsr

« back to all changes in this revision

Viewing changes to uspace/drv/bus/usb/ohci/hw_struct/hcca.h

  • Committer: Jiri Svoboda
  • Date: 2012-11-11 21:31:03 UTC
  • mfrom: (1527.1.178 mainline)
  • Revision ID: jiri@wiwaxia-20121111213103-314bmkettwvlwj97
MergeĀ mainlineĀ changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <stdint.h>
38
38
#include <malloc.h>
39
39
 
 
40
#include "mem_access.h"
 
41
 
 
42
#define HCCA_INT_EP_COUNT  32
 
43
 
40
44
/** Host controller communication area.
41
45
 * Shared memory used for communication between the controller and the driver.
42
46
 */
43
47
typedef struct hcca {
44
 
        uint32_t int_ep[32];
 
48
        /** Interrupt endpoints */
 
49
        uint32_t int_ep[HCCA_INT_EP_COUNT];
 
50
        /** Frame number. */
45
51
        uint16_t frame_number;
46
52
        uint16_t pad1;
 
53
        /** Pointer to the last completed TD. (useless) */
47
54
        uint32_t done_head;
 
55
        /** Padding to make the size 256B */
48
56
        uint32_t reserved[30];
49
57
} hcca_t;
50
58
 
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
 */
 
65
static inline hcca_t * hcca_get(void)
52
66
{
53
67
        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
 */
 
79
static 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
 
55
85
}
56
86
#endif
57
87
/**