source: mainline/uspace/drv/bus/usb/ehci/ehci_endpoint.c@ 4e732f1a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 4e732f1a was a24d6825, checked in by Jan Vesely <jano.vesely@…>, 12 years ago

ehci: Implement queue head initialization

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * Copyright (c) 2014 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28/** @addtogroup drvusbehci
29 * @{
30 */
31/** @file
32 * @brief EHCI driver
33 */
34
35#include <assert.h>
36#include <stdlib.h>
37
38#include "utils/malloc32.h"
39#include "ehci_endpoint.h"
40#include "hc.h"
41
42/** Callback to set toggle on ED.
43 *
44 * @param[in] hcd_ep hcd endpoint structure
45 * @param[in] toggle new value of toggle bit
46 */
47static void ehci_ep_toggle_set(void *ehci_ep, int toggle)
48{
49 ehci_endpoint_t *instance = ehci_ep;
50 assert(instance);
51 assert(instance->qh);
52// qh_toggle_set(instance->qh, toggle);
53}
54
55/** Callback to get value of toggle bit.
56 *
57 * @param[in] hcd_ep hcd endpoint structure
58 * @return Current value of toggle bit.
59 */
60static int ehci_ep_toggle_get(void *ehci_ep)
61{
62 ehci_endpoint_t *instance = ehci_ep;
63 assert(instance);
64 assert(instance->qh);
65 return 0;
66// return qh_toggle_get(instance->qh);
67}
68
69/** Creates new hcd endpoint representation.
70 *
71 * @param[in] ep USBD endpoint structure
72 * @return Error code.
73 */
74int ehci_endpoint_init(hcd_t *hcd, endpoint_t *ep)
75{
76 assert(ep);
77 ehci_endpoint_t *ehci_ep = malloc(sizeof(ehci_endpoint_t));
78 if (ehci_ep == NULL)
79 return ENOMEM;
80
81 ehci_ep->qh = malloc32(sizeof(qh_t));
82 if (ehci_ep->qh == NULL) {
83 free(ehci_ep);
84 return ENOMEM;
85 }
86
87 qh_init(ehci_ep->qh, ep);
88 endpoint_set_hc_data(
89 ep, ehci_ep, ehci_ep_toggle_get, ehci_ep_toggle_set);
90 hc_enqueue_endpoint(hcd->driver.data, ep);
91 return EOK;
92}
93
94/** Disposes hcd endpoint structure
95 *
96 * @param[in] hcd driver using this instance.
97 * @param[in] ep endpoint structure.
98 */
99void ehci_endpoint_fini(hcd_t *hcd, endpoint_t *ep)
100{
101 assert(hcd);
102 assert(ep);
103 ehci_endpoint_t *instance = ehci_endpoint_get(ep);
104 hc_dequeue_endpoint(hcd->driver.data, ep);
105 if (instance) {
106 free32(instance->qh);
107 free(instance);
108 }
109 endpoint_clear_hc_data(ep);
110}
111/**
112 * @}
113 */
114
Note: See TracBrowser for help on using the repository browser.