Changeset 8a121b1 in mainline
- Timestamp:
- 2011-10-15T11:58:16Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7c95d6f5
- Parents:
- 2a5b62b
- Location:
- uspace
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/desctree.c
r2a5b62b r8a121b1 50 50 51 51 static void browse_descriptor_tree_internal(usb_dp_parser_t *parser, 52 usb_dp_parser_data_t *data, uint8_t *root, size_t depth,52 usb_dp_parser_data_t *data, const uint8_t *root, size_t depth, 53 53 dump_descriptor_in_tree_t callback, void *arg) 54 54 { … … 57 57 } 58 58 callback(root, depth, arg); 59 uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root);59 const uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root); 60 60 do { 61 61 browse_descriptor_tree_internal(parser, data, child, depth + 1, -
uspace/app/usbinfo/dump.c
r2a5b62b r8a121b1 110 110 } 111 111 112 static void dump_tree_descriptor( uint8_t *descriptor, size_t depth)112 static void dump_tree_descriptor(const uint8_t *descriptor, size_t depth) 113 113 { 114 114 if (descriptor == NULL) { 115 115 return; 116 116 } 117 int type = (int) *(descriptor + 1);117 int type = descriptor[1]; 118 118 const char *name = "unknown"; 119 119 switch (type) { … … 136 136 } 137 137 138 static void dump_tree_internal(usb_dp_parser_t *parser, usb_dp_parser_data_t *data, 139 uint8_t *root, size_t depth) 138 static void dump_tree_internal( 139 usb_dp_parser_t *parser, usb_dp_parser_data_t *data, 140 const uint8_t *root, size_t depth) 140 141 { 141 142 if (root == NULL) { … … 143 144 } 144 145 dump_tree_descriptor(root, depth); 145 uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root);146 const uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root); 146 147 do { 147 148 dump_tree_internal(parser, data, child, depth + 1); -
uspace/app/usbinfo/hid.c
r2a5b62b r8a121b1 55 55 } descriptor_walk_context_t; 56 56 57 static bool is_descriptor_kind( uint8_t *d, usb_descriptor_type_t t)57 static bool is_descriptor_kind(const uint8_t *d, usb_descriptor_type_t t) 58 58 { 59 59 if (d == NULL) { … … 180 180 * @param arg Custom argument, passed as descriptor_walk_context_t. 181 181 */ 182 static void descriptor_walk_callback( uint8_t *raw_descriptor,182 static void descriptor_walk_callback(const uint8_t *raw_descriptor, 183 183 size_t depth, void *arg) 184 184 { -
uspace/app/usbinfo/info.c
r2a5b62b r8a121b1 51 51 } 52 52 53 static void dump_match_ids_from_interface( uint8_t *descriptor, size_t depth,54 void *arg)53 static void dump_match_ids_from_interface( 54 const uint8_t *descriptor, size_t depth, void *arg) 55 55 { 56 56 if (depth != 1) { … … 165 165 166 166 167 static void dump_descriptor_tree_callback( uint8_t *descriptor,168 size_t depth, void *arg)167 static void dump_descriptor_tree_callback( 168 const uint8_t *descriptor, size_t depth, void *arg) 169 169 { 170 170 const char *indent = get_indent(depth + 1); … … 246 246 } 247 247 248 static void find_string_indexes_callback( uint8_t *descriptor,249 size_t depth, void *arg)248 static void find_string_indexes_callback( 249 const uint8_t *descriptor, size_t depth, void *arg) 250 250 { 251 251 size_t descriptor_length = descriptor[0]; -
uspace/app/usbinfo/usbinfo.h
r2a5b62b r8a121b1 74 74 void destroy_device(usbinfo_device_t *); 75 75 76 typedef void (*dump_descriptor_in_tree_t)( uint8_t *, size_t, void *);76 typedef void (*dump_descriptor_in_tree_t)(const uint8_t *, size_t, void *); 77 77 void browse_descriptor_tree(uint8_t *, size_t, usb_dp_descriptor_nesting_t *, 78 78 dump_descriptor_in_tree_t, size_t, void *); -
uspace/drv/bus/usb/usbmid/dump.c
r2a5b62b r8a121b1 47 47 * @param depth Nesting depth. 48 48 */ 49 static void dump_tree_descriptor( uint8_t *data, size_t depth)49 static void dump_tree_descriptor(const uint8_t *data, size_t depth) 50 50 { 51 51 if (data == NULL) { 52 52 return; 53 53 } 54 int type = (int) *(data + 1);54 const int type = data[1]; 55 55 if (type == USB_DESCTYPE_INTERFACE) { 56 56 usb_standard_interface_descriptor_t *descriptor … … 71 71 * @param depth Nesting depth. 72 72 */ 73 static void dump_tree_internal(usb_dp_parser_t *parser, usb_dp_parser_data_t *data, 74 uint8_t *root, size_t depth) 73 static void dump_tree_internal( 74 usb_dp_parser_t *parser, usb_dp_parser_data_t *data, 75 const uint8_t *root, size_t depth) 75 76 { 76 77 if (root == NULL) { … … 78 79 } 79 80 dump_tree_descriptor(root, depth); 80 uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root);81 const uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root); 81 82 do { 82 83 dump_tree_internal(parser, data, child, depth + 1); -
uspace/drv/bus/usb/usbmid/explore.c
r2a5b62b r8a121b1 86 86 }; 87 87 88 uint8_t *interface_ptr = usb_dp_get_nested_descriptor(&parser, &data,89 data.data);88 const uint8_t *interface_ptr = 89 usb_dp_get_nested_descriptor(&parser, &data, data.data); 90 90 if (interface_ptr == NULL) { 91 91 return; -
uspace/lib/usbdev/include/usb/dev/dp.h
r2a5b62b r8a121b1 59 59 typedef struct { 60 60 /** Used descriptor nesting. */ 61 usb_dp_descriptor_nesting_t *nesting;61 const usb_dp_descriptor_nesting_t *nesting; 62 62 } usb_dp_parser_t; 63 63 … … 72 72 } usb_dp_parser_data_t; 73 73 74 uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *, 75 usb_dp_parser_data_t *, uint8_t *); 76 uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *, 77 usb_dp_parser_data_t *, uint8_t *, uint8_t *); 74 typedef void (*walk_callback_t)(const uint8_t *, size_t, void *); 78 75 79 void usb_dp_walk_simple(uint8_t *, size_t, usb_dp_descriptor_nesting_t *, 80 void (*)(uint8_t *, size_t, void *), void *); 76 const uint8_t *usb_dp_get_nested_descriptor(const usb_dp_parser_t *, 77 const usb_dp_parser_data_t *, const uint8_t *); 78 const uint8_t *usb_dp_get_sibling_descriptor(const usb_dp_parser_t *, 79 const usb_dp_parser_data_t *, const uint8_t *, const uint8_t *); 80 81 void usb_dp_walk_simple(uint8_t *, size_t, const usb_dp_descriptor_nesting_t *, 82 walk_callback_t, void *); 81 83 82 84 #endif -
uspace/lib/usbdev/include/usb/dev/driver.h
r2a5b62b r8a121b1 53 53 typedef struct { 54 54 /** Interface descriptor. */ 55 usb_standard_interface_descriptor_t *interface;55 const usb_standard_interface_descriptor_t *interface; 56 56 /** Pointer to start of descriptor tree bound with this interface. */ 57 uint8_t *nested_descriptors;57 const uint8_t *nested_descriptors; 58 58 /** Size of data pointed by nested_descriptors in bytes. */ 59 59 size_t nested_descriptors_size; -
uspace/lib/usbdev/src/altiface.c
r2a5b62b r8a121b1 54 54 assert(config_descr_size > 0); 55 55 56 usb_dp_parser_t dp_parser = {56 const usb_dp_parser_t dp_parser = { 57 57 .nesting = usb_dp_standard_descriptor_nesting 58 58 }; 59 usb_dp_parser_data_t dp_data = {59 const usb_dp_parser_data_t dp_data = { 60 60 .data = config_descr, 61 61 .size = config_descr_size, … … 65 65 size_t alternate_count = 0; 66 66 67 uint8_t *iface_ptr = usb_dp_get_nested_descriptor(&dp_parser,67 const uint8_t *iface_ptr = usb_dp_get_nested_descriptor(&dp_parser, 68 68 &dp_data, config_descr); 69 69 while (iface_ptr != NULL) { … … 140 140 = &alternates->alternatives[0]; 141 141 142 uint8_t *iface_ptr = usb_dp_get_nested_descriptor(&dp_parser,142 const uint8_t *iface_ptr = usb_dp_get_nested_descriptor(&dp_parser, 143 143 &dp_data, dp_data.data); 144 144 while (iface_ptr != NULL) { -
uspace/lib/usbdev/src/dp.c
r2a5b62b r8a121b1 75 75 * @return Whether @p ptr points inside <code>data->data</code> field. 76 76 */ 77 static bool is_valid_descriptor_pointer( usb_dp_parser_data_t *data,78 uint8_t *ptr)77 static bool is_valid_descriptor_pointer(const usb_dp_parser_data_t *data, 78 const uint8_t *ptr) 79 79 { 80 80 if (ptr == NULL) { … … 100 100 * @retval NULL Invalid input or no next descriptor. 101 101 */ 102 static uint8_t *get_next_descriptor(usb_dp_parser_data_t *data,103 uint8_t *current)102 static const uint8_t *get_next_descriptor(const usb_dp_parser_data_t *data, 103 const uint8_t *current) 104 104 { 105 105 assert(is_valid_descriptor_pointer(data, current)); 106 106 107 uint8_t current_length = *current;108 uint8_t *next = current + current_length;107 const uint8_t current_length = *current; 108 const uint8_t *next = current + current_length; 109 109 110 110 if (!is_valid_descriptor_pointer(data, next)) { … … 124 124 * @retval -1 Invalid input. 125 125 */ 126 static int get_descriptor_type( usb_dp_parser_data_t *data,uint8_t *start)126 static int get_descriptor_type(const usb_dp_parser_data_t *data, const uint8_t *start) 127 127 { 128 128 if (start == NULL) { … … 145 145 * @return Whether @p child could be child of @p parent. 146 146 */ 147 static bool is_nested_descriptor_type( usb_dp_parser_t *parser,147 static bool is_nested_descriptor_type(const usb_dp_parser_t *parser, 148 148 int child, int parent) 149 149 { 150 usb_dp_descriptor_nesting_t *nesting = parser->nesting;150 const usb_dp_descriptor_nesting_t *nesting = parser->nesting; 151 151 while ((nesting->child > 0) && (nesting->parent > 0)) { 152 152 if ((nesting->child == child) && (nesting->parent == parent)) { … … 166 166 * @return Whether @p child could be child of @p parent. 167 167 */ 168 static bool is_nested_descriptor( usb_dp_parser_t *parser,169 usb_dp_parser_data_t *data, uint8_t *child,uint8_t *parent)168 static bool is_nested_descriptor(const usb_dp_parser_t *parser, 169 const usb_dp_parser_data_t *data, const uint8_t *child, const uint8_t *parent) 170 170 { 171 171 return is_nested_descriptor_type(parser, … … 183 183 * @retval NULL Invalid input. 184 184 */ 185 uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *parser,186 usb_dp_parser_data_t *data,uint8_t *parent)185 const uint8_t *usb_dp_get_nested_descriptor(const usb_dp_parser_t *parser, 186 const usb_dp_parser_data_t *data, const uint8_t *parent) 187 187 { 188 188 if (!is_valid_descriptor_pointer(data, parent)) { … … 190 190 } 191 191 192 uint8_t *next = get_next_descriptor(data, parent);192 const uint8_t *next = get_next_descriptor(data, parent); 193 193 if (next == NULL) { 194 194 return NULL; … … 211 211 * @retval NULL Invalid input. 212 212 */ 213 static uint8_t *skip_nested_descriptors(usb_dp_parser_t *parser, 214 usb_dp_parser_data_t *data, uint8_t *parent) 215 { 216 uint8_t *child = usb_dp_get_nested_descriptor(parser, data, parent); 213 static const uint8_t *skip_nested_descriptors(const usb_dp_parser_t *parser, 214 const usb_dp_parser_data_t *data, const uint8_t *parent) 215 { 216 const uint8_t *child = 217 usb_dp_get_nested_descriptor(parser, data, parent); 217 218 if (child == NULL) { 218 219 return get_next_descriptor(data, parent); 219 220 } 220 uint8_t *next_child = skip_nested_descriptors(parser, data, child); 221 const uint8_t *next_child = 222 skip_nested_descriptors(parser, data, child); 221 223 while (is_nested_descriptor(parser, data, next_child, parent)) { 222 224 next_child = skip_nested_descriptors(parser, data, next_child); … … 236 238 * @retval NULL Invalid input. 237 239 */ 238 uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *parser, 239 usb_dp_parser_data_t *data, uint8_t *parent, uint8_t *sibling) 240 const uint8_t *usb_dp_get_sibling_descriptor( 241 const usb_dp_parser_t *parser, const usb_dp_parser_data_t *data, 242 const uint8_t *parent, const uint8_t *sibling) 240 243 { 241 244 if (!is_valid_descriptor_pointer(data, parent) … … 244 247 } 245 248 246 uint8_t *possible_sibling = skip_nested_descriptors(parser, data, sibling); 249 const uint8_t *possible_sibling = 250 skip_nested_descriptors(parser, data, sibling); 247 251 if (possible_sibling == NULL) { 248 252 return NULL; … … 269 273 * @param arg Custom (user) argument. 270 274 */ 271 static void usb_dp_browse_simple_internal( usb_dp_parser_t *parser,272 usb_dp_parser_data_t *data,uint8_t *root, size_t depth,273 void (*callback)( uint8_t *, size_t, void *), void *arg)275 static void usb_dp_browse_simple_internal(const usb_dp_parser_t *parser, 276 const usb_dp_parser_data_t *data, const uint8_t *root, size_t depth, 277 void (*callback)(const uint8_t *, size_t, void *), void *arg) 274 278 { 275 279 if (root == NULL) { … … 277 281 } 278 282 callback(root, depth, arg); 279 uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root);283 const uint8_t *child = usb_dp_get_nested_descriptor(parser, data, root); 280 284 do { 281 285 usb_dp_browse_simple_internal(parser, data, child, depth + 1, … … 301 305 */ 302 306 void usb_dp_walk_simple(uint8_t *descriptors, size_t descriptors_size, 303 usb_dp_descriptor_nesting_t *descriptor_nesting,304 void (*callback)(uint8_t *, size_t, void *), void *arg)307 const usb_dp_descriptor_nesting_t *descriptor_nesting, 308 walk_callback_t callback, void *arg) 305 309 { 306 310 if ((descriptors == NULL) || (descriptors_size == 0) … … 309 313 } 310 314 311 usb_dp_parser_data_t data = {315 const usb_dp_parser_data_t data = { 312 316 .data = descriptors, 313 317 .size = descriptors_size, … … 315 319 }; 316 320 317 usb_dp_parser_t parser = {321 const usb_dp_parser_t parser = { 318 322 .nesting = descriptor_nesting 319 323 }; -
uspace/lib/usbdev/src/pipesinit.c
r2a5b62b r8a121b1 68 68 * @return Whether the given descriptor is endpoint descriptor. 69 69 */ 70 static inline bool is_endpoint_descriptor( uint8_t *descriptor)70 static inline bool is_endpoint_descriptor(const uint8_t *descriptor) 71 71 { 72 72 return descriptor[1] == USB_DESCTYPE_ENDPOINT; … … 80 80 */ 81 81 static bool endpoint_fits_description(const usb_endpoint_description_t *wanted, 82 usb_endpoint_description_t *found)82 const usb_endpoint_description_t *found) 83 83 { 84 84 #define _SAME(fieldname) ((wanted->fieldname) == (found->fieldname)) … … 120 120 static usb_endpoint_mapping_t *find_endpoint_mapping( 121 121 usb_endpoint_mapping_t *mapping, size_t mapping_count, 122 usb_endpoint_description_t *found_endpoint,122 const usb_endpoint_description_t *found_endpoint, 123 123 int interface_number, int interface_setting) 124 124 { … … 160 160 usb_device_connection_t *wire) 161 161 { 162 usb_endpoint_description_t description;163 162 164 163 /* … … 167 166 168 167 /* Actual endpoint number is in bits 0..3 */ 169 usb_endpoint_t ep_no = endpoint->endpoint_address & 0x0F; 170 171 /* Endpoint direction is set by bit 7 */ 172 description.direction = (endpoint->endpoint_address & 128) 173 ? USB_DIRECTION_IN : USB_DIRECTION_OUT; 174 /* Transfer type is in bits 0..2 and the enum values corresponds 1:1 */ 175 description.transfer_type = endpoint->attributes & 3; 176 177 /* 178 * Get interface characteristics. 179 */ 180 description.interface_class = interface->interface_class; 181 description.interface_subclass = interface->interface_subclass; 182 description.interface_protocol = interface->interface_protocol; 168 const usb_endpoint_t ep_no = endpoint->endpoint_address & 0x0F; 169 170 const usb_endpoint_description_t description = { 171 /* Endpoint direction is set by bit 7 */ 172 .direction = (endpoint->endpoint_address & 128) 173 ? USB_DIRECTION_IN : USB_DIRECTION_OUT, 174 /* Transfer type is in bits 0..2 and 175 * the enum values corresponds 1:1 */ 176 .transfer_type = endpoint->attributes & 3, 177 178 /* Get interface characteristics. */ 179 .interface_class = interface->interface_class, 180 .interface_subclass = interface->interface_subclass, 181 .interface_protocol = interface->interface_protocol, 182 }; 183 183 184 184 /* … … 225 225 usb_endpoint_mapping_t *mapping, size_t mapping_count, 226 226 usb_dp_parser_t *parser, usb_dp_parser_data_t *parser_data, 227 uint8_t *interface_descriptor)228 { 229 uint8_t *descriptor = usb_dp_get_nested_descriptor(parser,227 const uint8_t *interface_descriptor) 228 { 229 const uint8_t *descriptor = usb_dp_get_nested_descriptor(parser, 230 230 parser_data, interface_descriptor); 231 231 … … 322 322 * Iterate through all interfaces. 323 323 */ 324 uint8_t *interface = usb_dp_get_nested_descriptor(&dp_parser,324 const uint8_t *interface = usb_dp_get_nested_descriptor(&dp_parser, 325 325 &dp_data, configuration_descriptor); 326 326 if (interface == NULL) { … … 329 329 do { 330 330 (void) process_interface(mapping, mapping_count, 331 &dp_parser, &dp_data, 332 interface); 331 &dp_parser, &dp_data, interface); 333 332 interface = usb_dp_get_sibling_descriptor(&dp_parser, &dp_data, 334 333 configuration_descriptor, interface); -
uspace/lib/usbhid/src/hidreport.c
r2a5b62b r8a121b1 69 69 * First nested descriptor of the configuration descriptor. 70 70 */ 71 uint8_t *d =71 const uint8_t *d = 72 72 usb_dp_get_nested_descriptor(&parser, &parser_data, 73 73 dev->descriptors.configuration); … … 92 92 * First nested descriptor of the interface descriptor. 93 93 */ 94 uint8_t *iface_desc = d;94 const uint8_t *iface_desc = d; 95 95 d = usb_dp_get_nested_descriptor(&parser, &parser_data, iface_desc); 96 96
Note:
See TracChangeset
for help on using the changeset viewer.