source: mainline/uspace/drv/usbhub/usbhub_private.h@ 3eaa5a5

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 3eaa5a5 was 3eaa5a5, checked in by Vojtech Horky <vojtechhorky@…>, 15 years ago

Removal of unused structures

  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[b5ec347]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
[281ebae]29/** @addtogroup drvusbhub
[b5ec347]30 * @{
31 */
32/** @file
[f40a1e2]33 * @brief Hub driver private definitions
[b5ec347]34 */
35
36#ifndef USBHUB_PRIVATE_H
37#define USBHUB_PRIVATE_H
38
39#include "usbhub.h"
[e080332]40
[b5ec347]41#include <adt/list.h>
42#include <bool.h>
[eb1a2f4]43#include <ddf/driver.h>
[ba5ab09]44#include <fibril_synch.h>
[5097bed4]45
[6bb83c7]46#include <usb/classes/hub.h>
[b5ec347]47#include <usb/usb.h>
[e080332]48#include <usb/debug.h>
[0f21c0c]49#include <usb/request.h>
[b5ec347]50
51//************
52//
53// convenience define for malloc
54//
55//************
56#define usb_new(type) (type*)malloc(sizeof(type))
57
58
59/**
[f40a1e2]60 * Create hub structure instance
[b5ec347]61 *
[98d06b8]62 * Set the address and port count information most importantly.
63 *
[b5ec347]64 * @param device
[98d06b8]65 * @param hc host controller phone
[b5ec347]66 * @return
67 */
[eb1a2f4]68usb_hub_info_t * usb_create_hub_info(ddf_dev_t * device);
[b5ec347]69
[98d06b8]70/**
[f40a1e2]71 * Set the device request to be a get hub descriptor request.
[98d06b8]72 * @warning the size is allways set to USB_HUB_MAX_DESCRIPTOR_SIZE
73 * @param request
74 * @param addr
75 */
[10096231]76static inline void usb_hub_set_descriptor_request(
[98d06b8]77usb_device_request_setup_packet_t * request
78){
79 request->index = 0;
80 request->request_type = USB_HUB_REQ_TYPE_GET_DESCRIPTOR;
81 request->request = USB_HUB_REQUEST_GET_DESCRIPTOR;
[10096231]82 request->value_high = USB_DESCTYPE_HUB;
83 request->value_low = 0;
[98d06b8]84 request->length = USB_HUB_MAX_DESCRIPTOR_SIZE;
85}
86
[f40a1e2]87/**
88 * Clear feature on hub port.
89 *
90 * @param hc Host controller telephone
91 * @param address Hub address
92 * @param port_index Port
93 * @param feature Feature selector
94 * @return Operation result
95 */
[a372663]96static inline int usb_hub_clear_port_feature(usb_pipe_t *pipe,
[f9a0cef]97 int port_index,
98 usb_hub_class_feature_t feature) {
[d81ef61c]99
[f9a0cef]100 usb_device_request_setup_packet_t clear_request = {
101 .request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
102 .request = USB_DEVREQ_CLEAR_FEATURE,
103 .length = 0,
104 .index = port_index
105 };
106 clear_request.value = feature;
[3954a63b]107 return usb_pipe_control_write(pipe, &clear_request,
[f9a0cef]108 sizeof(clear_request), NULL, 0);
109}
110
[d493ac17]111/**
[09daa8b]112 * create uint8_t array with serialized descriptor
[d493ac17]113 *
114 * @param descriptor
115 * @return newly created serializd descriptor pointer
116 */
117void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
118
119/**
[09daa8b]120 * create deserialized desriptor structure out of serialized descriptor
[d493ac17]121 *
122 * The serialized descriptor must be proper usb hub descriptor,
123 * otherwise an eerror might occur.
124 *
125 * @param sdescriptor serialized descriptor
126 * @return newly created deserialized descriptor pointer
127 */
128usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
[98d06b8]129
[b5ec347]130
131#endif /* USBHUB_PRIVATE_H */
132
133/**
134 * @}
135 */
Note: See TracBrowser for help on using the repository browser.