Changeset 1d1bb0f in mainline for uspace/lib
- Timestamp:
- 2011-06-19T13:38:37Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b72efe8
- Parents:
- adfdbd5 (diff), 9724d7f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/lib
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
radfdbd5 r1d1bb0f 540 540 541 541 dstr_size = str_size(dest); 542 if (dstr_size >= size) { 543 return; 544 } 542 545 str_cpy(dest + dstr_size, size - dstr_size, src); 543 546 } -
uspace/lib/drv/Makefile
radfdbd5 r1d1bb0f 36 36 generic/dev_iface.c \ 37 37 generic/log.c \ 38 generic/logbuf.c \ 38 39 generic/remote_hw_res.c \ 39 40 generic/remote_char_dev.c \ -
uspace/lib/drv/include/ddf/log.h
radfdbd5 r1d1bb0f 39 39 extern void ddf_msg(log_level_t, const char *, ...); 40 40 41 extern void ddf_dump_buffer(char *, size_t, const void *, size_t, size_t, 42 size_t); 43 41 44 #endif 42 45 -
uspace/lib/usb/include/usb/usb.h
radfdbd5 r1d1bb0f 69 69 USB_DIRECTION_BOTH 70 70 } usb_direction_t; 71 72 const char *usb_str_direction(usb_direction_t); 71 73 72 74 /** USB speeds. */ -
uspace/lib/usb/src/debug.c
radfdbd5 r1d1bb0f 38 38 #include <stdlib.h> 39 39 #include <stdio.h> 40 #include <ddf/log.h> 40 41 #include <usb/debug.h> 41 42 … … 67 68 if (rc > 0) { 68 69 log_stream = fopen(fname, "w"); 70 if (log_stream != NULL) { 71 setvbuf(log_stream, NULL, _IOFBF, BUFSIZ); 72 } 69 73 free(fname); 70 74 } … … 193 197 bzero(buffer_dump[buffer_dump_index], BUFFER_DUMP_LEN); 194 198 195 if (buffer == NULL) { 196 return "(null)"; 197 } 198 if (size == 0) { 199 return "(empty)"; 200 } 201 if ((dumped_size == 0) || (dumped_size > size)) { 202 dumped_size = size; 203 } 204 205 /* How many bytes are available in the output buffer. */ 206 size_t buffer_remaining_size = BUFFER_DUMP_LEN - 1 - REMAINDER_STR_LEN; 207 char *it = buffer_dump[buffer_dump_index]; 208 209 size_t index = 0; 210 211 while (index < size) { 212 /* Determine space before the number. */ 213 const char *space_before; 214 if (index == 0) { 215 space_before = ""; 216 } else if ((index % BUFFER_DUMP_GROUP_SIZE) == 0) { 217 space_before = " "; 218 } else { 219 space_before = " "; 220 } 221 222 /* 223 * Add the byte as a hexadecimal number plus the space. 224 * We do it into temporary buffer to ensure that always 225 * the whole byte is printed. 226 */ 227 int val = buffer[index]; 228 char current_byte[16]; 229 int printed = snprintf(current_byte, 16, 230 "%s%02x", space_before, val); 231 if (printed < 0) { 232 break; 233 } 234 235 if ((size_t) printed > buffer_remaining_size) { 236 break; 237 } 238 239 /* We can safely add 1, because space for end 0 is reserved. */ 240 str_append(it, buffer_remaining_size + 1, current_byte); 241 242 buffer_remaining_size -= printed; 243 /* Point at the terminator 0. */ 244 it += printed; 245 index++; 246 247 if (index >= dumped_size) { 248 break; 249 } 250 } 251 252 /* Add how many bytes were not printed. */ 253 if (index < size) { 254 snprintf(it, REMAINDER_STR_LEN, 255 REMAINDER_STR_FMT, size - index); 256 } 199 /* Do the actual dump. */ 200 ddf_dump_buffer(buffer_dump[buffer_dump_index], BUFFER_DUMP_LEN, 201 buffer, 1, size, dumped_size); 257 202 258 203 /* Next time, use the other buffer. */ -
uspace/lib/usb/src/hc.c
radfdbd5 r1d1bb0f 98 98 return EBUSY; 99 99 100 async_sess_t *sess = devman_device_connect(EXCHANGE_ SERIALIZE,100 async_sess_t *sess = devman_device_connect(EXCHANGE_ATOMIC, 101 101 connection->hc_handle, 0); 102 102 if (!sess) … … 177 177 { 178 178 async_sess_t *parent_sess = 179 devman_parent_device_connect(EXCHANGE_ SERIALIZE, dev_handle,179 devman_parent_device_connect(EXCHANGE_ATOMIC, dev_handle, 180 180 IPC_FLAG_BLOCKING); 181 181 if (!parent_sess) … … 241 241 { 242 242 async_sess_t *parent_sess = 243 devman_parent_device_connect(EXCHANGE_ SERIALIZE, device_handle,243 devman_parent_device_connect(EXCHANGE_ATOMIC, device_handle, 244 244 IPC_FLAG_BLOCKING); 245 245 if (!parent_sess) -
uspace/lib/usb/src/usb.c
radfdbd5 r1d1bb0f 58 58 }; 59 59 60 static const char *str_direction[] = { 61 "in", 62 "out", 63 "both" 64 }; 65 60 66 /** String representation for USB transfer type. 61 67 * … … 84 90 } 85 91 92 /** String representation of USB direction. 93 * 94 * @param d The direction. 95 * @return Direction as a string (in English). 96 */ 97 const char *usb_str_direction(usb_direction_t d) 98 { 99 if (d >= ARR_SIZE(str_direction)) { 100 return "invalid"; 101 } 102 return str_direction[d]; 103 } 104 86 105 /** String representation of USB speed. 87 106 * -
uspace/lib/usbdev/src/pipes.c
radfdbd5 r1d1bb0f 81 81 { 82 82 async_sess_t *parent_sess = 83 devman_parent_device_connect(EXCHANGE_ SERIALIZE, device->handle,83 devman_parent_device_connect(EXCHANGE_ATOMIC, device->handle, 84 84 IPC_FLAG_BLOCKING); 85 85 if (!parent_sess) … … 122 122 123 123 async_sess_t *parent_sess = 124 devman_parent_device_connect(EXCHANGE_ SERIALIZE, dev->handle,124 devman_parent_device_connect(EXCHANGE_ATOMIC, dev->handle, 125 125 IPC_FLAG_BLOCKING); 126 126 if (!parent_sess) -
uspace/lib/usbhid/src/hidreq.c
radfdbd5 r1d1bb0f 82 82 value |= (type << 8); 83 83 84 usb_log_debug("Sending Set _Report request to the device.\n");84 usb_log_debug("Sending Set Report request to the device.\n"); 85 85 86 86 rc = usb_control_request_set(ctrl_pipe, … … 89 89 90 90 if (rc != EOK) { 91 usb_log_warning("Error sending output report to the keyboard:"92 " %s.\n", str_error(rc));91 usb_log_warning("Error sending Set Report request to the " 92 "device: %s.\n", str_error(rc)); 93 93 return rc; 94 94 } … … 129 129 int rc; 130 130 131 usb_log_debug("Sending Set _Protocol request to the device ("131 usb_log_debug("Sending Set Protocol request to the device (" 132 132 "protocol: %d, iface: %d).\n", protocol, iface_no); 133 133 … … 137 137 138 138 if (rc != EOK) { 139 usb_log_warning("Error sending output report to the keyboard:"140 " %s.\n", str_error(rc));139 usb_log_warning("Error sending Set Protocol request to the " 140 "device: %s.\n", str_error(rc)); 141 141 return rc; 142 142 } … … 177 177 int rc; 178 178 179 usb_log_debug("Sending Set _Idle request to the device ("179 usb_log_debug("Sending Set Idle request to the device (" 180 180 "duration: %u, iface: %d).\n", duration, iface_no); 181 181 … … 187 187 188 188 if (rc != EOK) { 189 usb_log_warning("Error sending output report to the keyboard: "189 usb_log_warning("Error sending Set Idle request to the device: " 190 190 "%s.\n", str_error(rc)); 191 191 return rc; … … 235 235 value |= (type << 8); 236 236 237 usb_log_debug("Sending Get _Report request to the device.\n");237 usb_log_debug("Sending Get Report request to the device.\n"); 238 238 239 239 rc = usb_control_request_get(ctrl_pipe, … … 243 243 244 244 if (rc != EOK) { 245 usb_log_warning("Error sending output report to the keyboard: "245 usb_log_warning("Error sending Get Report request to the device: " 246 246 "%s.\n", str_error(rc)); 247 247 return rc; … … 283 283 int rc; 284 284 285 usb_log_debug("Sending Get _Protocol request to the device ("285 usb_log_debug("Sending Get Protocol request to the device (" 286 286 "iface: %d).\n", iface_no); 287 287 … … 294 294 295 295 if (rc != EOK) { 296 usb_log_warning("Error sending output report to the keyboard:"297 " %s.\n", str_error(rc));296 usb_log_warning("Error sending Get Protocol request to the " 297 "device: %s.\n", str_error(rc)); 298 298 return rc; 299 299 } … … 344 344 int rc; 345 345 346 usb_log_debug("Sending Get _Idle request to the device ("346 usb_log_debug("Sending Get Idle request to the device (" 347 347 "iface: %d).\n", iface_no); 348 348 … … 357 357 358 358 if (rc != EOK) { 359 usb_log_warning("Error sending output report to the keyboard: "359 usb_log_warning("Error sending Get Idle request to the device: " 360 360 "%s.\n", str_error(rc)); 361 361 return rc; -
uspace/lib/usbhost/include/usb/host/batch.h
radfdbd5 r1d1bb0f 61 61 }; 62 62 63 /** Printf formatting string for dumping usb_transfer_batch_t. */ 64 #define USB_TRANSFER_BATCH_FMT "[%d:%d %s %s-%s %zuB/%zu]" 65 66 /** Printf arguments for dumping usb_transfer_batch_t. 67 * @param batch USB transfer batch to be dumped. 68 */ 69 #define USB_TRANSFER_BATCH_ARGS(batch) \ 70 (batch).ep->address, (batch).ep->endpoint, \ 71 usb_str_speed((batch).ep->speed), \ 72 usb_str_transfer_type_short((batch).ep->transfer_type), \ 73 usb_str_direction((batch).ep->direction), \ 74 (batch).buffer_size, (batch).ep->max_packet_size 75 76 63 77 void usb_transfer_batch_init( 64 78 usb_transfer_batch_t *instance, -
uspace/lib/usbhost/src/batch.c
radfdbd5 r1d1bb0f 128 128 memcpy(instance->buffer, instance->data_buffer, instance->buffer_size); 129 129 130 usb_log_debug("Batch(%p) done (T%d.%d, %s %s in, %zuB): %s (%d).\n", 131 instance, instance->ep->address, instance->ep->endpoint, 132 usb_str_speed(instance->ep->speed), 133 usb_str_transfer_type_short(instance->ep->transfer_type), 134 instance->transfered_size, str_error(instance->error), 135 instance->error); 130 usb_log_debug("Batch %p " USB_TRANSFER_BATCH_FMT " completed (%zuB): %s.\n", 131 instance, USB_TRANSFER_BATCH_ARGS(*instance), 132 instance->transfered_size, str_error(instance->error)); 136 133 137 134 instance->callback_in(instance->fun, instance->error, … … 148 145 assert(instance->callback_out); 149 146 150 usb_log_debug("Batch(%p) done (T%d.%d, %s %s out): %s (%d).\n", 151 instance, instance->ep->address, instance->ep->endpoint, 152 usb_str_speed(instance->ep->speed), 153 usb_str_transfer_type_short(instance->ep->transfer_type), 154 str_error(instance->error), instance->error); 147 usb_log_debug("Batch %p " USB_TRANSFER_BATCH_FMT " completed: %s.\n", 148 instance, USB_TRANSFER_BATCH_ARGS(*instance), 149 str_error(instance->error)); 155 150 156 151 instance->callback_out(instance->fun, … … 165 160 { 166 161 assert(instance); 167 usb_log_debug("Batch(%p) disposing.\n", instance); 162 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " disposing.\n", 163 instance, USB_TRANSFER_BATCH_ARGS(*instance)); 168 164 if (instance->private_data) { 169 165 assert(instance->private_data_dtor);
Note:
See TracChangeset
for help on using the changeset viewer.