Changeset bbc7d83e in mainline
- Timestamp:
- 2011-02-01T21:59:43Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a4a8cca
- Parents:
- 0a37e14 (diff), ec293a8 (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
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/Makefile
r0a37e14 rbbc7d83e 44 44 conndev.c \ 45 45 connhost.c \ 46 debug.c \47 46 devices.c \ 48 47 hc.c \ -
uspace/drv/vhc/conndev.c
r0a37e14 rbbc7d83e 99 99 int rc = get_device_name(callback, devname, DEVICE_NAME_MAXLENGTH); 100 100 101 dprintf(0, "virtual device connected (name: %s, id: %x)",101 usb_log_info("New virtual device `%s' (id = %x).\n", 102 102 rc == EOK ? devname : "<unknown>", dev->id); 103 103 … … 122 122 } 123 123 124 dprintf(0, "virtual device disconnected (id: %x)", dev->id);124 usb_log_info("Virtual device disconnected (id = %x).\n", dev->id); 125 125 virtdev_destroy_device(dev); 126 126 } -
uspace/drv/vhc/connhost.c
r0a37e14 rbbc7d83e 219 219 usbhc_iface_transfer_out_callback_t callback, void *arg) 220 220 { 221 dprintf(3, "transfer OUT [%d.%d (%s); %zu]",221 usb_log_debug2("Transfer OUT [%d.%d (%s); %zu].\n", 222 222 target.address, target.endpoint, 223 223 usb_str_transfer_type(transfer_type), … … 239 239 usbhc_iface_transfer_out_callback_t callback, void *arg) 240 240 { 241 dprintf(3, "transfer SETUP [%d.%d (%s); %zu]",241 usb_log_debug2("Transfer SETUP [%d.%d (%s); %zu].\n", 242 242 target.address, target.endpoint, 243 243 usb_str_transfer_type(transfer_type), … … 259 259 usbhc_iface_transfer_in_callback_t callback, void *arg) 260 260 { 261 dprintf(3, "transfer IN [%d.%d (%s); %zu]",261 usb_log_debug2("Transfer IN [%d.%d (%s); %zu].\n", 262 262 target.address, target.endpoint, 263 263 usb_str_transfer_type(transfer_type), -
uspace/drv/vhc/devices.c
r0a37e14 rbbc7d83e 196 196 if (virtual_hub_device.address == transaction->target.address) { 197 197 size_t tmp; 198 dprintf(1, "sending `%s' transaction to hub",198 usb_log_debug2("Sending `%s' transaction to hub.\n", 199 199 usbvirt_str_transaction_type(transaction->type)); 200 200 switch (transaction->type) { … … 222 222 break; 223 223 } 224 dprintf(4, "transaction on hub processed...");225 224 outcome = USB_OUTCOME_OK; 226 225 } -
uspace/drv/vhc/hc.c
r0a37e14 rbbc7d83e 92 92 usb_transaction_outcome_t outcome) 93 93 { 94 dprintf(3, "transaction " TRANSACTION_FORMAT " done, outcome: %s",94 usb_log_debug2("Transaction " TRANSACTION_FORMAT " done: %s.\n", 95 95 TRANSACTION_PRINTF(*transaction), 96 96 usb_str_transaction_outcome(outcome)); … … 108 108 static unsigned int seed = 4573; 109 109 110 printf("%s: transaction processor ready.\n", NAME);110 usb_log_info("Transaction processor ready.\n"); 111 111 112 112 while (true) { … … 125 125 list_remove(first_transaction_link); 126 126 127 128 dprintf(0, "about to process " TRANSACTION_FORMAT " [%s]", 127 usb_log_debug("Processing " TRANSACTION_FORMAT " [%s].\n", 129 128 TRANSACTION_PRINTF(*transaction), ports); 130 129 131 dprintf(3, "processing transaction " TRANSACTION_FORMAT "",132 TRANSACTION_PRINTF(*transaction));133 134 130 usb_transaction_outcome_t outcome; 135 131 outcome = virtdev_send_to_all(transaction); … … 148 144 fid_t fid = fibril_create(hc_manager_fibril, NULL); 149 145 if (fid == 0) { 150 printf(NAME ": failed to start HC manager fibril\n");146 usb_log_fatal("Failed to start HC manager fibril.\n"); 151 147 return; 152 148 } … … 172 168 transaction->callback = callback; 173 169 transaction->callback_arg = arg; 174 175 dprintf(3, "creating transaction " TRANSACTION_FORMAT, 170 171 return transaction; 172 } 173 174 static void hc_add_transaction(transaction_t *transaction) 175 { 176 usb_log_debug("Adding transaction " TRANSACTION_FORMAT ".\n", 176 177 TRANSACTION_PRINTF(*transaction)); 177 178 return transaction; 178 list_append(&transaction->link, &transaction_list); 179 179 } 180 180 … … 190 190 target, transfer_type, 191 191 buffer, len, callback, arg); 192 list_append(&transaction->link, &transaction_list);192 hc_add_transaction(transaction); 193 193 } 194 194 … … 203 203 target, transfer_type, 204 204 buffer, len, callback, arg); 205 list_append(&transaction->link, &transaction_list);205 hc_add_transaction(transaction); 206 206 } 207 207 -
uspace/drv/vhc/hcd.c
r0a37e14 rbbc7d83e 94 94 virtual_hub_device_init(dev); 95 95 96 printf("%s: virtual USB host controller ready.\n", NAME); 96 usb_log_info("Virtual USB host controller ready (id = %zu).\n", 97 (size_t) dev->handle); 97 98 98 99 return EOK; … … 117 118 sleep(5); 118 119 119 usb_ dprintf_enable(NAME, -1);120 usb_log_enable(USB_LOG_LEVEL_INFO, NAME); 120 121 121 122 printf(NAME ": virtual USB host controller driver.\n"); -
uspace/drv/vhc/hub.c
r0a37e14 rbbc7d83e 63 63 = fibril_create(hub_register_in_devman_fibril, hc_dev); 64 64 if (root_hub_registration == 0) { 65 printf(NAME ": failed to create hub registration fibril\n");65 usb_log_fatal("Failed to create hub registration fibril.\n"); 66 66 return; 67 67 } -
uspace/drv/vhc/vhcd.h
r0a37e14 rbbc7d83e 45 45 #define DEVMAP_PATH_DEV NAMESPACE "/" NAME_DEV 46 46 47 #define dprintf(level, format, ...) \ 48 usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__)49 void dprintf_inval_call(int, ipc_call_t, sysarg_t);47 //#define dprintf(level, format, ...) 48 // usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__) 49 //void dprintf_inval_call(int, ipc_call_t, sysarg_t); 50 50 51 51 #endif -
uspace/lib/usb/include/usb/debug.h
r0a37e14 rbbc7d83e 1 1 /* 2 * Copyright (c) 2010 Vojtech Horky2 * Copyright (c) 2010-2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 37 37 #include <stdio.h> 38 38 #include <usb/usb.h> 39 #include <assert.h> 39 40 40 41 void usb_dprintf(const char *tag, int level, const char *format, ...); … … 44 45 const uint8_t *, size_t); 45 46 47 /** Logging level. */ 48 typedef enum { 49 USB_LOG_LEVEL_FATAL, 50 USB_LOG_LEVEL_ERROR, 51 USB_LOG_LEVEL_WARNING, 52 USB_LOG_LEVEL_INFO, 53 USB_LOG_LEVEL_DEBUG, 54 USB_LOG_LEVEL_DEBUG2, 55 USB_LOG_LEVEL_MAX 56 } usb_log_level_t; 57 58 59 void usb_log_enable(usb_log_level_t, const char *); 60 61 void usb_log_printf(usb_log_level_t, const char *, ...); 62 63 #define usb_log_fatal(format, ...) \ 64 usb_log_printf(USB_LOG_LEVEL_FATAL, format, ##__VA_ARGS__) 65 66 #define usb_log_error(format, ...) \ 67 usb_log_printf(USB_LOG_LEVEL_ERROR, format, ##__VA_ARGS__) 68 69 #define usb_log_warning(format, ...) \ 70 usb_log_printf(USB_LOG_LEVEL_WARNING, format, ##__VA_ARGS__) 71 72 #define usb_log_info(format, ...) \ 73 usb_log_printf(USB_LOG_LEVEL_INFO, format, ##__VA_ARGS__) 74 75 #define usb_log_debug(format, ...) \ 76 usb_log_printf(USB_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__) 77 78 #define usb_log_debug2(format, ...) \ 79 usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__) 80 81 82 46 83 #endif 47 84 /** -
uspace/lib/usb/src/debug.c
r0a37e14 rbbc7d83e 1 1 /* 2 * Copyright (c) 2010 Vojtech Horky2 * Copyright (c) 2010-2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 61 61 static FIBRIL_MUTEX_INITIALIZE(tag_list_guard); 62 62 63 /** Level of logging messages. */ 64 static usb_log_level_t log_level = USB_LOG_LEVEL_WARNING; 65 /** Prefix for logging messages. */ 66 static const char *log_prefix = "usb"; 67 /** Serialization mutex for logging functions. */ 68 static FIBRIL_MUTEX_INITIALIZE(log_serializer); 69 63 70 /** Find or create new tag with given name. 64 71 * … … 155 162 } 156 163 164 /** Enable logging. 165 * 166 * @param level Maximal enabled level (including this one). 167 * @param message_prefix Prefix for each printed message. 168 */ 169 void usb_log_enable(usb_log_level_t level, const char *message_prefix) 170 { 171 log_prefix = message_prefix; 172 log_level = level; 173 } 174 175 176 static const char *log_level_name(usb_log_level_t level) 177 { 178 switch (level) { 179 case USB_LOG_LEVEL_FATAL: 180 return " FATAL"; 181 case USB_LOG_LEVEL_ERROR: 182 return " ERROR"; 183 case USB_LOG_LEVEL_WARNING: 184 return " WARN"; 185 case USB_LOG_LEVEL_INFO: 186 return " info"; 187 default: 188 return ""; 189 } 190 } 191 192 /** Print logging message. 193 * 194 * @param level Verbosity level of the message. 195 * @param format Formatting directive. 196 */ 197 void usb_log_printf(usb_log_level_t level, const char *format, ...) 198 { 199 if (level > log_level) { 200 return; 201 } 202 203 FILE *stream = NULL; 204 switch (level) { 205 case USB_LOG_LEVEL_FATAL: 206 case USB_LOG_LEVEL_ERROR: 207 stream = stderr; 208 break; 209 default: 210 stream = stdout; 211 break; 212 } 213 assert(stream != NULL); 214 215 va_list args; 216 va_start(args, format); 217 218 fibril_mutex_lock(&log_serializer); 219 fprintf(stream, "[%s]%s: ", log_prefix, log_level_name(level)); 220 vfprintf(stream, format, args); 221 fibril_mutex_unlock(&log_serializer); 222 223 va_end(args); 224 } 157 225 158 226 /**
Note:
See TracChangeset
for help on using the changeset viewer.