source: mainline/uspace/drv/usbhub/usbhub_private.h@ 070f11e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 070f11e was 6bb83c7, checked in by Matus Dekanek <smekideki@…>, 15 years ago

usbhub uses new api, it is compilable. cannot guarantee functionality

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 * Copyright (c) 2010 Matus Dekanek
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
29/** @addtogroup drvusbhub
30 * @{
31 */
32/** @file
33 * @brief Hub driver private definitions
34 */
35
36#ifndef USBHUB_PRIVATE_H
37#define USBHUB_PRIVATE_H
38
39#include "usbhub.h"
40#include "usblist.h"
41
42#include <adt/list.h>
43#include <bool.h>
44#include <driver.h>
45#include <fibril_synch.h>
46
47#include <usb/classes/hub.h>
48#include <usb/usb.h>
49#include <usb/usbdrv.h>
50
51//#include <usb/devreq.h>
52#include <usb/debug.h>
53
54//************
55//
56// convenience define for malloc
57//
58//************
59#define usb_new(type) (type*)malloc(sizeof(type))
60
61
62//************
63//
64// convenience debug printf for usb hub
65//
66//************
67#define dprintf(level, format, ...) \
68 usb_log_printf((level), format "\n", ##__VA_ARGS__)
69
70
71/**
72 * Create hub structure instance
73 *
74 * Set the address and port count information most importantly.
75 *
76 * @param device
77 * @param hc host controller phone
78 * @return
79 */
80usb_hub_info_t * usb_create_hub_info(device_t * device);
81
82/** List of hubs maanged by this driver */
83extern usb_general_list_t usb_hub_list;
84
85/** Lock for hub list*/
86extern fibril_mutex_t usb_hub_list_lock;
87
88
89/**
90 * Perform complete control read transaction
91 *
92 * Manages all three steps of transaction: setup, read and finalize
93 * @param phone
94 * @param target
95 * @param request Request packet
96 * @param rcvd_buffer Received data
97 * @param rcvd_size
98 * @param actual_size Actual size of received data
99 * @return error code
100 */
101/*
102int usb_drv_sync_control_read(
103 usb_endpoint_pipe_t *pipe,
104 usb_device_request_setup_packet_t * request,
105 void * rcvd_buffer, size_t rcvd_size, size_t * actual_size
106);*/
107
108/**
109 * Perform complete control write transaction
110 *
111 * Manages all three steps of transaction: setup, write and finalize
112 * @param phone
113 * @param target
114 * @param request Request packet to send data
115 * @param sent_buffer
116 * @param sent_size
117 * @return error code
118 */
119/*int usb_drv_sync_control_write(
120 usb_endpoint_pipe_t *pipe,
121 usb_device_request_setup_packet_t * request,
122 void * sent_buffer, size_t sent_size
123);*/
124
125/**
126 * Set the device request to be a get hub descriptor request.
127 * @warning the size is allways set to USB_HUB_MAX_DESCRIPTOR_SIZE
128 * @param request
129 * @param addr
130 */
131static inline void usb_hub_set_descriptor_request(
132usb_device_request_setup_packet_t * request
133){
134 request->index = 0;
135 request->request_type = USB_HUB_REQ_TYPE_GET_DESCRIPTOR;
136 request->request = USB_HUB_REQUEST_GET_DESCRIPTOR;
137 request->value_high = USB_DESCTYPE_HUB;
138 request->value_low = 0;
139 request->length = USB_HUB_MAX_DESCRIPTOR_SIZE;
140}
141
142/**
143 * Clear feature on hub port.
144 *
145 * @param hc Host controller telephone
146 * @param address Hub address
147 * @param port_index Port
148 * @param feature Feature selector
149 * @return Operation result
150 */
151static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe,
152 int port_index,
153 usb_hub_class_feature_t feature) {
154
155 usb_device_request_setup_packet_t clear_request = {
156 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
157 .request = USB_DEVREQ_CLEAR_FEATURE,
158 .length = 0,
159 .index = port_index
160 };
161 clear_request.value = feature;
162 return usb_endpoint_pipe_control_write(pipe, &clear_request,
163 sizeof(clear_request), NULL, 0);
164}
165
166
167
168#endif /* USBHUB_PRIVATE_H */
169
170/**
171 * @}
172 */
Note: See TracBrowser for help on using the repository browser.