Changes in / [0864122:bdbb6f6] in mainline
- Files:
-
- 4 added
- 5 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r0864122 rbdbb6f6 528 528 ! [PLATFORM=sparc64&MACHINE=generic] CONFIG_AOUT_ISOFS_B (y) 529 529 530 % Run devman on startup 531 ! CONFIG_START_DEVMAN (y/n) 532 533 % Launch (devman) test drivers 534 ! [CONFIG_START_DEVMAN=y&CONFIG_DEBUG=y] CONFIG_TEST_DRIVERS (y/n) 535 530 536 % Load disk drivers on startup 531 537 ! CONFIG_START_BD (n/y) … … 548 554 % Line debugging information 549 555 ! [CONFIG_STRIP_BINARIES!=y] CONFIG_LINE_DEBUG (n/y) 550 551 % Launch (devman) test drivers552 ! [CONFIG_DEBUG=y] CONFIG_TEST_DRIVERS (y/n)553 -
kernel/generic/src/mm/backend_elf.c
r0864122 rbdbb6f6 91 91 if (!as_area_check_access(area, access)) 92 92 return AS_PF_FAULT; 93 94 ASSERT((addr >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) && 95 (addr < entry->p_vaddr + entry->p_memsz)); 93 94 if (addr < ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) 95 return AS_PF_FAULT; 96 97 if (addr >= entry->p_vaddr + entry->p_memsz) 98 return AS_PF_FAULT; 99 96 100 i = (addr - ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) >> PAGE_WIDTH; 97 101 base = (uintptr_t) -
uspace/app/bdsh/cmds/modules/ls/ls.c
r0864122 rbdbb6f6 38 38 #include <dirent.h> 39 39 #include <fcntl.h> 40 #include <getopt.h> 40 41 #include <sys/types.h> 41 42 #include <sys/stat.h> 42 43 #include <str.h> 44 #include <sort.h> 43 45 44 46 #include "errors.h" … … 46 48 #include "util.h" 47 49 #include "entry.h" 48 #include "ls.h"49 50 #include "cmds.h" 50 51 52 /* Various values that can be returned by ls_scope() */ 53 #define LS_BOGUS 0 54 #define LS_FILE 1 55 #define LS_DIR 2 56 57 /** Structure to represent a directory entry. 58 * 59 * Useful to keep together important information 60 * for sorting directory entries. 61 */ 62 struct dir_elem_t { 63 char *name; 64 struct stat s; 65 }; 66 51 67 static const char *cmdname = "ls"; 52 68 53 static void ls_scan_dir(const char *d, DIR *dirp) 54 { 69 static struct option const long_options[] = { 70 { "help", no_argument, 0, 'h' }, 71 { "unsort", no_argument, 0, 'u' }, 72 { 0, 0, 0, 0 } 73 }; 74 75 /** Print an entry. 76 * 77 * ls_print currently does nothing more than print the entry. 78 * In the future, we will likely pass the absolute path, and 79 * some sort of ls_options structure that controls how each 80 * entry is printed and what is printed about it. 81 * 82 * Now we just print basic DOS style lists. 83 * 84 * @param de Directory element. 85 */ 86 static void ls_print(struct dir_elem_t *de) 87 { 88 if (de->s.is_file) 89 printf("%-40s\t%llu\n", de->name, (long long) de->s.size); 90 else if (de->s.is_directory) 91 printf("%-40s\t<dir>\n", de->name); 92 else 93 printf("%-40s\n", de->name); 94 } 95 96 97 /** Compare 2 directory elements. 98 * 99 * It compares 2 elements of a directory : a file is considered 100 * as bigger than a directory, and if they have the same type, 101 * they are compared alphabetically. 102 * 103 * @param a Pointer to the structure of the first element. 104 * @param b Pointer to the structure of the second element. 105 * @param arg Pointer for an other and optionnal argument. 106 * 107 * @return -1 if a < b, 1 otherwise. 108 */ 109 static int ls_cmp(void *a, void *b, void *arg) 110 { 111 struct dir_elem_t *da = a; 112 struct dir_elem_t *db = b; 113 114 if ((da->s.is_directory && db->s.is_file) || 115 ((da->s.is_directory == db->s.is_directory) && 116 str_cmp(da->name, db->name) < 0)) 117 return -1; 118 else 119 return 1; 120 } 121 122 /** Scan a directory. 123 * 124 * Scan the content of a directory and print it. 125 * 126 * @param d Name of the directory. 127 * @param dirp Directory stream. 128 * @param sort 1 if the output must be sorted, 129 * 0 otherwise. 130 */ 131 static void ls_scan_dir(const char *d, DIR *dirp, int sort) 132 { 133 int alloc_blocks = 20; 134 int i; 135 int nbdirs = 0; 136 int rc; 137 int len; 138 char *buff; 139 struct dir_elem_t *tmp; 140 struct dir_elem_t *tosort; 55 141 struct dirent *dp; 56 char *buff; 57 58 if (! dirp) 142 143 if (!dirp) 59 144 return; 60 145 61 buff = (char *) malloc(PATH_MAX);62 if ( NULL ==buff) {146 buff = (char *) malloc(PATH_MAX); 147 if (!buff) { 63 148 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 64 149 return; 65 150 } 66 151 152 tosort = (struct dir_elem_t *) malloc(alloc_blocks * sizeof(*tosort)); 153 if (!tosort) { 154 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 155 free(buff); 156 return; 157 } 158 67 159 while ((dp = readdir(dirp))) { 68 memset(buff, 0, sizeof(buff)); 69 /* Don't worry if inserting a double slash, this will be fixed by 70 * absolutize() later with subsequent calls to open() or readdir() */ 71 snprintf(buff, PATH_MAX - 1, "%s/%s", d, dp->d_name); 72 ls_print(dp->d_name, buff); 73 } 74 160 if (nbdirs + 1 > alloc_blocks) { 161 alloc_blocks += alloc_blocks; 162 163 tmp = (struct dir_elem_t *) realloc(tosort, 164 alloc_blocks * sizeof(struct dir_elem_t)); 165 if (!tmp) { 166 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 167 goto out; 168 } 169 tosort = tmp; 170 } 171 172 /* fill the name field */ 173 tosort[nbdirs].name = (char *) malloc(str_length(dp->d_name) + 1); 174 if (!tosort[nbdirs].name) { 175 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 176 goto out; 177 } 178 179 str_cpy(tosort[nbdirs].name, str_length(dp->d_name) + 1, dp->d_name); 180 len = snprintf(buff, PATH_MAX - 1, "%s/%s", d, tosort[nbdirs].name); 181 buff[len] = '\0'; 182 183 rc = stat(buff, &tosort[nbdirs++].s); 184 if (rc != 0) { 185 printf("ls: skipping bogus node %s\n", buff); 186 printf("rc=%d\n", rc); 187 goto out; 188 } 189 } 190 191 if (sort) { 192 if (!qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), 193 ls_cmp, NULL)) { 194 printf("Sorting error.\n"); 195 } 196 } 197 198 for (i = 0; i < nbdirs; i++) 199 ls_print(&tosort[i]); 200 201 out: 202 for(i = 0; i < nbdirs; i++) 203 free(tosort[i].name); 204 free(tosort); 75 205 free(buff); 76 77 return;78 }79 80 /* ls_print currently does nothing more than print the entry.81 * in the future, we will likely pass the absolute path, and82 * some sort of ls_options structure that controls how each83 * entry is printed and what is printed about it.84 *85 * Now we just print basic DOS style lists */86 87 static void ls_print(const char *name, const char *pathname)88 {89 struct stat s;90 int rc;91 92 rc = stat(pathname, &s);93 if (rc != 0) {94 /* Odd chance it was deleted from the time readdir() found it */95 printf("ls: skipping bogus node %s\n", pathname);96 printf("rc=%d\n", rc);97 return;98 }99 100 if (s.is_file)101 printf("%-40s\t%llu\n", name, (long long) s.size);102 else if (s.is_directory)103 printf("%-40s\t<dir>\n", name);104 else105 printf("%-40s\n", name);106 107 return;108 206 } 109 207 … … 114 212 } else { 115 213 help_cmd_ls(HELP_SHORT); 116 printf(" `%s' [path], if no path is given the current " 117 "working directory is used.\n", cmdname); 214 printf( 215 "Usage: %s [options] [path]\n" 216 "If not path is given, the current working directory is used.\n" 217 "Options:\n" 218 " -h, --help A short option summary\n" 219 " -u, --unsort Do not sort directory entries\n", 220 cmdname); 118 221 } 119 222 … … 124 227 { 125 228 unsigned int argc; 126 struct stat s; 127 char *buff; 229 struct dir_elem_t de; 128 230 DIR *dirp; 231 int c, opt_ind; 232 int sort = 1; 129 233 130 234 argc = cli_count_args(argv); 131 132 buff = (char *) malloc(PATH_MAX); 133 if (NULL == buff) { 235 236 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 237 c = getopt_long(argc, argv, "hu", long_options, &opt_ind); 238 switch (c) { 239 case 'h': 240 help_cmd_ls(HELP_LONG); 241 return CMD_SUCCESS; 242 case 'u': 243 sort = 0; 244 break; 245 } 246 } 247 248 argc -= optind; 249 250 de.name = (char *) malloc(PATH_MAX); 251 if (!de.name) { 134 252 cli_error(CL_ENOMEM, "%s: ", cmdname); 135 253 return CMD_FAILURE; 136 254 } 137 memset( buff, 0, sizeof(buff));138 139 if (argc == 1)140 getcwd( buff, PATH_MAX);255 memset(de.name, 0, sizeof(PATH_MAX)); 256 257 if (argc == 0) 258 getcwd(de.name, PATH_MAX); 141 259 else 142 str_cpy( buff, PATH_MAX, argv[1]);143 144 if (stat( buff, &s)) {145 cli_error(CL_ENOENT, buff);146 free( buff);260 str_cpy(de.name, PATH_MAX, argv[optind]); 261 262 if (stat(de.name, &de.s)) { 263 cli_error(CL_ENOENT, de.name); 264 free(de.name); 147 265 return CMD_FAILURE; 148 266 } 149 267 150 if ( s.is_file) {151 ls_print( buff, buff);268 if (de.s.is_file) { 269 ls_print(&de); 152 270 } else { 153 dirp = opendir( buff);271 dirp = opendir(de.name); 154 272 if (!dirp) { 155 273 /* May have been deleted between scoping it and opening it */ 156 cli_error(CL_EFAIL, "Could not stat %s", buff);157 free( buff);274 cli_error(CL_EFAIL, "Could not stat %s", de.name); 275 free(de.name); 158 276 return CMD_FAILURE; 159 277 } 160 ls_scan_dir( buff, dirp);278 ls_scan_dir(de.name, dirp, sort); 161 279 closedir(dirp); 162 280 } 163 281 164 free( buff);282 free(de.name); 165 283 166 284 return CMD_SUCCESS; -
uspace/app/init/init.c
r0864122 rbdbb6f6 272 272 mount_tmpfs(); 273 273 274 #ifdef CONFIG_START_DEVMAN 275 spawn("/srv/devman"); 276 #endif 274 277 spawn("/srv/apic"); 275 278 spawn("/srv/i8259"); -
uspace/drv/isa/isa.c
r0864122 rbdbb6f6 53 53 54 54 #include <ddf/driver.h> 55 #include <ddf/log.h> 55 56 #include <ops/hw_res.h> 56 57 … … 134 135 fd = open(conf_path, O_RDONLY); 135 136 if (fd < 0) { 136 printf(NAME ": unable to open %s\n", conf_path);137 ddf_msg(LVL_ERROR, "Unable to open %s\n", conf_path); 137 138 goto cleanup; 138 139 } … … 141 142 142 143 len = lseek(fd, 0, SEEK_END); 143 lseek(fd, 0, SEEK_SET); 144 lseek(fd, 0, SEEK_SET); 144 145 if (len == 0) { 145 printf(NAME ": fun_conf_read error: configuration file '%s' "146 "is empty.\n",conf_path);146 ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.\n", 147 conf_path); 147 148 goto cleanup; 148 149 } … … 150 151 buf = malloc(len + 1); 151 152 if (buf == NULL) { 152 printf(NAME ": fun_conf_read error: memory allocation failed.\n");153 ddf_msg(LVL_ERROR, "Memory allocation failed.\n"); 153 154 goto cleanup; 154 155 } 155 156 156 157 if (0 >= read(fd, buf, len)) { 157 printf(NAME ": fun_conf_read error: unable to read file '%s'.\n", 158 conf_path); 158 ddf_msg(LVL_ERROR, "Unable to read file '%s'.\n", conf_path); 159 159 goto cleanup; 160 160 } … … 252 252 fun->hw_resources.count++; 253 253 254 printf(NAME ": added irq 0x%x to function %s\n", irq,254 ddf_msg(LVL_NOTE, "Added irq 0x%x to function %s\n", irq, 255 255 fun->fnode->name); 256 256 } … … 270 270 fun->hw_resources.count++; 271 271 272 printf(NAME ": added io range (addr=0x%x, size=0x%x) to "272 ddf_msg(LVL_NOTE, "Added io range (addr=0x%x, size=0x%x) to " 273 273 "function %s\n", (unsigned int) addr, (unsigned int) len, 274 274 fun->fnode->name); … … 331 331 score = (int)strtol(val, &end, 10); 332 332 if (val == end) { 333 printf(NAME " : error - could not read match score for"334 " function%s.\n", fun->fnode->name);333 ddf_msg(LVL_ERROR, "Cannot read match score for function " 334 "%s.\n", fun->fnode->name); 335 335 return; 336 336 } … … 339 339 get_match_id(&id, val); 340 340 if (id == NULL) { 341 printf(NAME " : error - could not read match id for "342 "function %s.\n",fun->fnode->name);341 ddf_msg(LVL_ERROR, "Cannot read match ID for function %s.\n", 342 fun->fnode->name); 343 343 return; 344 344 } 345 345 346 printf(NAME ": adding match id '%s' with score %d to function %s\n", id,347 score, fun->fnode->name);346 ddf_msg(LVL_DEBUG, "Adding match id '%s' with score %d to " 347 "function %s\n", id, score, fun->fnode->name); 348 348 349 349 rc = ddf_fun_add_match_id(fun->fnode, id, score); 350 if (rc != EOK) 351 printf(NAME ": error adding match ID: %s\n", str_error(rc)); 350 if (rc != EOK) { 351 ddf_msg(LVL_ERROR, "Failed adding match ID: %s\n", 352 str_error(rc)); 353 } 352 354 } 353 355 … … 375 377 if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) && 376 378 !prop_parse(fun, line, "irq", &fun_parse_irq) && 377 !prop_parse(fun, line, "match", &fun_parse_match_id)) 378 { 379 printf(NAME " error undefined device property at line '%s'\n",380 line);379 !prop_parse(fun, line, "match", &fun_parse_match_id)) { 380 381 ddf_msg(LVL_ERROR, "Undefined device property at line '%s'\n", 382 line); 381 383 } 382 384 } … … 439 441 fun->fnode->ops = &isa_fun_ops; 440 442 441 printf(NAME ":Binding function %s.\n", fun->fnode->name);443 ddf_msg(LVL_DEBUG, "Binding function %s.\n", fun->fnode->name); 442 444 443 445 /* XXX Handle error */ … … 467 469 static int isa_add_device(ddf_dev_t *dev) 468 470 { 469 printf(NAME ":isa_add_device, device handle = %d\n",471 ddf_msg(LVL_DEBUG, "isa_add_device, device handle = %d\n", 470 472 (int) dev->handle); 471 473 472 474 /* Make the bus device more visible. Does not do anything. */ 473 printf(NAME ": adding a 'ctl' function\n");475 ddf_msg(LVL_DEBUG, "Adding a 'ctl' function\n"); 474 476 475 477 ddf_fun_t *ctl = ddf_fun_create(dev, fun_exposed, "ctl"); 476 478 if (ctl == NULL) { 477 printf(NAME ": Errorcreating control function.\n");479 ddf_msg(LVL_ERROR, "Failed creating control function.\n"); 478 480 return EXDEV; 479 481 } 480 482 481 483 if (ddf_fun_bind(ctl) != EOK) { 482 printf(NAME ": Errorbinding control function.\n");484 ddf_msg(LVL_ERROR, "Failed binding control function.\n"); 483 485 return EXDEV; 484 486 } … … 486 488 /* Add functions as specified in the configuration file. */ 487 489 isa_functions_add(dev); 488 printf(NAME ": finished the enumeration oflegacy functions\n");490 ddf_msg(LVL_NOTE, "Finished enumerating legacy functions\n"); 489 491 490 492 return EOK; … … 493 495 static void isa_init() 494 496 { 497 ddf_log_init(NAME, LVL_ERROR); 495 498 isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops; 496 499 } -
uspace/drv/ns8250/ns8250.c
r0864122 rbdbb6f6 55 55 #include <ddf/driver.h> 56 56 #include <ddf/interrupt.h> 57 #include <ddf/log.h> 57 58 #include <ops/char_dev.h> 58 59 … … 275 276 static bool ns8250_pio_enable(ns8250_t *ns) 276 277 { 277 printf(NAME ":ns8250_pio_enable %s\n", ns->dev->name);278 ddf_msg(LVL_DEBUG, "ns8250_pio_enable %s\n", ns->dev->name); 278 279 279 280 /* Gain control over port's registers. */ 280 281 if (pio_enable((void *)(uintptr_t) ns->io_addr, REG_COUNT, 281 282 (void **) &ns->port)) { 282 printf(NAME ": error - cannot gain the port %#" PRIx32 " for device "283 " %s.\n", ns->io_addr, ns->dev->name);283 ddf_msg(LVL_ERROR, "Cannot map the port %#" PRIx32 284 " for device %s.\n", ns->io_addr, ns->dev->name); 284 285 return false; 285 286 } … … 295 296 static bool ns8250_dev_probe(ns8250_t *ns) 296 297 { 297 printf(NAME ":ns8250_dev_probe %s\n", ns->dev->name);298 ddf_msg(LVL_DEBUG, "ns8250_dev_probe %s\n", ns->dev->name); 298 299 299 300 ioport8_t *port_addr = ns->port; … … 313 314 pio_write_8(port_addr + 4, olddata); 314 315 315 if (!res) 316 printf(NAME ": device %s is not present.\n", ns->dev->name); 316 if (!res) { 317 ddf_msg(LVL_DEBUG, "Device %s is not present.\n", 318 ns->dev->name); 319 } 317 320 318 321 return res; … … 326 329 static int ns8250_dev_initialize(ns8250_t *ns) 327 330 { 328 printf(NAME ":ns8250_dev_initialize %s\n", ns->dev->name);331 ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s\n", ns->dev->name); 329 332 330 333 int ret = EOK; … … 337 340 IPC_FLAG_BLOCKING); 338 341 if (ns->dev->parent_phone < 0) { 339 printf(NAME ": failed to connect to the parent driver of the"342 ddf_msg(LVL_ERROR, "Failed to connect to parent driver of " 340 343 "device %s.\n", ns->dev->name); 341 344 ret = ns->dev->parent_phone; … … 346 349 ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources); 347 350 if (ret != EOK) { 348 printf(NAME ": failed to get hw resources for thedevice "351 ddf_msg(LVL_ERROR, "Failed to get HW resources for device " 349 352 "%s.\n", ns->dev->name); 350 353 goto failed; … … 362 365 ns->irq = res->res.interrupt.irq; 363 366 irq = true; 364 printf(NAME ": the %s devicewas asigned irq = 0x%x.\n",367 ddf_msg(LVL_NOTE, "Device %s was asigned irq = 0x%x.\n", 365 368 ns->dev->name, ns->irq); 366 369 break; … … 369 372 ns->io_addr = res->res.io_range.address; 370 373 if (res->res.io_range.size < REG_COUNT) { 371 printf(NAME ": i/o range assigned to the device"372 " %s is too small.\n", ns->dev->name);374 ddf_msg(LVL_ERROR, "I/O range assigned to " 375 "device %s is too small.\n", ns->dev->name); 373 376 ret = ELIMIT; 374 377 goto failed; 375 378 } 376 379 ioport = true; 377 printf(NAME ": the %s device was asigned i/oaddress = "380 ddf_msg(LVL_NOTE, "Device %s was asigned I/O address = " 378 381 "0x%x.\n", ns->dev->name, ns->io_addr); 379 382 break; … … 385 388 386 389 if (!irq || !ioport) { 387 printf(NAME ": missing hw resource(s) for thedevice %s.\n",390 ddf_msg(LVL_ERROR, "Missing HW resource(s) for device %s.\n", 388 391 ns->dev->name); 389 392 ret = ENOENT; … … 470 473 471 474 if (baud_rate < 50 || MAX_BAUD_RATE % baud_rate != 0) { 472 printf(NAME ": error - somebody tried to set invalid baud rate "473 "%d\n",baud_rate);475 ddf_msg(LVL_ERROR, "Invalid baud rate %d requested.\n", 476 baud_rate); 474 477 return EINVAL; 475 478 } … … 654 657 if (ns->client_connected) { 655 658 if (!buf_push_back(&ns->input_buffer, val)) { 656 printf(NAME ": buffer overflow on "659 ddf_msg(LVL_WARN, "Buffer overflow on " 657 660 "%s.\n", ns->dev->name); 658 661 } else { 659 printf(NAME ": the character %c saved "662 ddf_msg(LVL_DEBUG2, "Character %c saved " 660 663 "to the buffer of %s.\n", 661 664 val, ns->dev->name); … … 714 717 int rc; 715 718 716 printf(NAME ":ns8250_add_device %s (handle = %d)\n",719 ddf_msg(LVL_DEBUG, "ns8250_add_device %s (handle = %d)\n", 717 720 dev->name, (int) dev->handle); 718 721 … … 749 752 /* Register interrupt handler. */ 750 753 if (ns8250_register_interrupt_handler(ns) != EOK) { 751 printf(NAME ": failed to register interrupt handler.\n");754 ddf_msg(LVL_ERROR, "Failed to register interrupt handler.\n"); 752 755 rc = EADDRNOTAVAIL; 753 756 goto fail; … … 757 760 rc = ns8250_interrupt_enable(ns); 758 761 if (rc != EOK) { 759 printf(NAME ": failed to enable the interrupt. Error code = "762 ddf_msg(LVL_ERROR, "Failed to enable the interrupt. Error code = " 760 763 "%d.\n", rc); 761 764 goto fail; … … 764 767 fun = ddf_fun_create(dev, fun_exposed, "a"); 765 768 if (fun == NULL) { 766 printf(NAME ": errorcreating function.\n");769 ddf_msg(LVL_ERROR, "Failed creating function.\n"); 767 770 goto fail; 768 771 } … … 772 775 rc = ddf_fun_bind(fun); 773 776 if (rc != EOK) { 774 printf(NAME ": errorbinding function.\n");777 ddf_msg(LVL_ERROR, "Failed binding function.\n"); 775 778 goto fail; 776 779 } … … 780 783 ddf_fun_add_to_class(fun, "serial"); 781 784 782 printf(NAME ": the %s device has beensuccessfully initialized.\n",785 ddf_msg(LVL_NOTE, "Device %s successfully initialized.\n", 783 786 dev->name); 784 787 … … 862 865 fibril_mutex_unlock(&data->mutex); 863 866 864 printf(NAME ":ns8250_get_props: baud rate %d, parity 0x%x, word "867 ddf_msg(LVL_DEBUG, "ns8250_get_props: baud rate %d, parity 0x%x, word " 865 868 "length %d, stop bits %d\n", *baud_rate, *parity, *word_length, 866 869 *stop_bits); … … 879 882 unsigned int parity, unsigned int word_length, unsigned int stop_bits) 880 883 { 881 printf(NAME ":ns8250_set_props: baud rate %d, parity 0x%x, word "884 ddf_msg(LVL_DEBUG, "ns8250_set_props: baud rate %d, parity 0x%x, word " 882 885 "length %d, stop bits %d\n", baud_rate, parity, word_length, 883 886 stop_bits); … … 940 943 static void ns8250_init(void) 941 944 { 945 ddf_log_init(NAME, LVL_ERROR); 946 942 947 ns8250_dev_ops.open = &ns8250_open; 943 948 ns8250_dev_ops.close = &ns8250_close; -
uspace/drv/pciintel/pci.c
r0864122 rbdbb6f6 48 48 49 49 #include <ddf/driver.h> 50 #include <ddf/log.h> 50 51 #include <devman.h> 51 52 #include <ipc/devman.h> … … 225 226 226 227 if (match_id_str == NULL) { 227 printf(NAME ": out of memory creating match ID.\n");228 ddf_msg(LVL_ERROR, "Out of memory creating match ID.\n"); 228 229 return; 229 230 } … … 231 232 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90); 232 233 if (rc != EOK) { 233 printf(NAME ": erroradding match ID: %s\n",234 ddf_msg(LVL_ERROR, "Failed adding match ID: %s\n", 234 235 str_error(rc)); 235 236 } … … 323 324 324 325 if (range_addr != 0) { 325 printf(NAME ": function %s : ", fun->fnode->name);326 printf("address = %" PRIx64, range_addr);327 printf(", size = %x\n",(unsigned int) range_size);326 ddf_msg(LVL_DEBUG, "Function %s : address = %" PRIx64 327 ", size = %x\n", fun->fnode->name, range_addr, 328 (unsigned int) range_size); 328 329 } 329 330 … … 350 351 hw_res_list->count++; 351 352 352 printf(NAME ": function %s uses irq %x.\n", fun->fnode->name, irq);353 ddf_msg(LVL_NOTE, "Function %s uses irq %x.\n", fun->fnode->name, irq); 353 354 } 354 355 … … 406 407 char *fun_name = pci_fun_create_name(fun); 407 408 if (fun_name == NULL) { 408 printf(NAME ": out of memory.\n");409 ddf_msg(LVL_ERROR, "Out of memory.\n"); 409 410 return; 410 411 } … … 412 413 fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name); 413 414 if (fnode == NULL) { 414 printf(NAME ": errorcreating function.\n");415 ddf_msg(LVL_ERROR, "Failed creating function.\n"); 415 416 return; 416 417 } … … 426 427 fnode->driver_data = fun; 427 428 428 printf(NAME ": adding new function %s.\n",429 ddf_msg(LVL_DEBUG, "Adding new function %s.\n", 429 430 fnode->name); 430 431 … … 443 444 child_bus = pci_conf_read_8(fun, 444 445 PCI_BRIDGE_SEC_BUS_NUM); 445 printf(NAME ": device is pci-to-pci bridge, " 446 "secondary bus number = %d.\n", bus_num); 446 ddf_msg(LVL_DEBUG, "Device is pci-to-pci " 447 "bridge, secondary bus number = %d.\n", 448 bus_num); 447 449 if (child_bus > bus_num) 448 450 pci_bus_scan(bus, child_bus); … … 466 468 int rc; 467 469 468 printf(NAME ":pci_add_device\n");470 ddf_msg(LVL_DEBUG, "pci_add_device\n"); 469 471 dnode->parent_phone = -1; 470 472 471 473 bus = pci_bus_new(); 472 474 if (bus == NULL) { 473 printf(NAME ":pci_add_device allocation failed.\n");475 ddf_msg(LVL_ERROR, "pci_add_device allocation failed.\n"); 474 476 rc = ENOMEM; 475 477 goto fail; … … 481 483 IPC_FLAG_BLOCKING); 482 484 if (dnode->parent_phone < 0) { 483 printf(NAME ":pci_add_device failed to connect to the "485 ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the " 484 486 "parent's driver.\n"); 485 487 rc = dnode->parent_phone; … … 491 493 rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources); 492 494 if (rc != EOK) { 493 printf(NAME ": pci_add_device failed to get hw resources for"494 " the device.\n");495 ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources " 496 "for the device.\n"); 495 497 goto fail; 496 498 } 497 499 got_res = true; 498 500 499 printf(NAME ":conf_addr = %" PRIx64 ".\n",501 ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".\n", 500 502 hw_resources.resources[0].res.io_range.address); 501 503 … … 509 511 if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 8, 510 512 &bus->conf_addr_port)) { 511 printf(NAME ": failed to enable configuration ports.\n");513 ddf_msg(LVL_ERROR, "Failed to enable configuration ports.\n"); 512 514 rc = EADDRNOTAVAIL; 513 515 goto fail; … … 516 518 517 519 /* Make the bus device more visible. It has no use yet. */ 518 printf(NAME ": adding a 'ctl' function\n");520 ddf_msg(LVL_DEBUG, "Adding a 'ctl' function\n"); 519 521 520 522 ctl = ddf_fun_create(bus->dnode, fun_exposed, "ctl"); … … 532 534 533 535 /* Enumerate functions. */ 534 printf(NAME ": scanning the bus\n");536 ddf_msg(LVL_DEBUG, "Scanning the bus\n"); 535 537 pci_bus_scan(bus, 0); 536 538 … … 554 556 static void pciintel_init(void) 555 557 { 558 ddf_log_init(NAME, LVL_ERROR); 556 559 pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops; 557 560 } -
uspace/drv/root/root.c
r0864122 rbdbb6f6 52 52 53 53 #include <ddf/driver.h> 54 #include <ddf/log.h> 54 55 #include <devman.h> 55 56 #include <ipc/devman.h> … … 89 90 int rc; 90 91 91 printf(NAME ": adding new function for virtual devices.\n");92 printf(NAME ": function node is `%s' (%d %s)\n", name,92 ddf_msg(LVL_DEBUG, "Adding new function for virtual devices. " 93 "Function node is `%s' (%d %s)\n", name, 93 94 VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID); 94 95 95 96 fun = ddf_fun_create(dev, fun_inner, name); 96 97 if (fun == NULL) { 97 printf(NAME ": errorcreating function %s\n", name);98 ddf_msg(LVL_ERROR, "Failed creating function %s\n", name); 98 99 return ENOMEM; 99 100 } … … 102 103 VIRTUAL_FUN_MATCH_SCORE); 103 104 if (rc != EOK) { 104 printf(NAME ": erroradding match IDs to function %s\n", name);105 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n", name); 105 106 ddf_fun_destroy(fun); 106 107 return rc; … … 109 110 rc = ddf_fun_bind(fun); 110 111 if (rc != EOK) { 111 printf(NAME ": errorbinding function %s: %s\n", name,112 ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name, 112 113 str_error(rc)); 113 114 ddf_fun_destroy(fun); … … 136 137 platform = sysinfo_get_data("platform", &platform_size); 137 138 if (platform == NULL) { 138 printf(NAME ":Failed to obtain platform name.\n");139 ddf_msg(LVL_ERROR, "Failed to obtain platform name.\n"); 139 140 return ENOENT; 140 141 } … … 143 144 platform = realloc(platform, platform_size + 1); 144 145 if (platform == NULL) { 145 printf(NAME ":Memory allocation failed.\n");146 ddf_msg(LVL_ERROR, "Memory allocation failed.\n"); 146 147 return ENOMEM; 147 148 } … … 151 152 /* Construct match ID. */ 152 153 if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) { 153 printf(NAME ":Memory allocation failed.\n");154 ddf_msg(LVL_ERROR, "Memory allocation failed.\n"); 154 155 return ENOMEM; 155 156 } 156 157 157 158 /* Add function. */ 158 printf(NAME ": adding platform function\n");159 printf(NAME ": function node is `%s' (%d %s)\n", PLATFORM_FUN_NAME,160 PLATFORM_FUN_MATCH_SCORE,match_id);159 ddf_msg(LVL_DEBUG, "Adding platform function. Function node is `%s' " 160 " (%d %s)\n", PLATFORM_FUN_NAME, PLATFORM_FUN_MATCH_SCORE, 161 match_id); 161 162 162 163 fun = ddf_fun_create(dev, fun_inner, name); 163 164 if (fun == NULL) { 164 printf(NAME ": error creating function %s\n", name);165 ddf_msg(LVL_ERROR, "Error creating function %s\n", name); 165 166 return ENOMEM; 166 167 } … … 168 169 rc = ddf_fun_add_match_id(fun, match_id, PLATFORM_FUN_MATCH_SCORE); 169 170 if (rc != EOK) { 170 printf(NAME ": error adding match IDs to function %s\n", name); 171 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n", 172 name); 171 173 ddf_fun_destroy(fun); 172 174 return rc; … … 175 177 rc = ddf_fun_bind(fun); 176 178 if (rc != EOK) { 177 printf(NAME ": errorbinding function %s: %s\n", name,179 ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name, 178 180 str_error(rc)); 179 181 ddf_fun_destroy(fun); … … 191 193 static int root_add_device(ddf_dev_t *dev) 192 194 { 193 printf(NAME ":root_add_device, device handle=%" PRIun "\n",195 ddf_msg(LVL_DEBUG, "root_add_device, device handle=%" PRIun "\n", 194 196 dev->handle); 195 197 … … 204 206 int res = add_platform_fun(dev); 205 207 if (EOK != res) 206 printf(NAME ": failed to addchild device for platform.\n");208 ddf_msg(LVL_ERROR, "Failed adding child device for platform.\n"); 207 209 208 210 return res; … … 212 214 { 213 215 printf(NAME ": HelenOS root device driver\n"); 216 217 ddf_log_init(NAME, LVL_ERROR); 214 218 return ddf_driver_main(&root_driver); 215 219 } -
uspace/drv/rootpc/rootpc.c
r0864122 rbdbb6f6 47 47 48 48 #include <ddf/driver.h> 49 #include <ddf/log.h> 49 50 #include <devman.h> 50 51 #include <ipc/devman.h> … … 119 120 rootpc_fun_t *fun) 120 121 { 121 printf(NAME ": adding new function '%s'.\n", name);122 ddf_msg(LVL_DEBUG, "Adding new function '%s'.\n", name); 122 123 123 124 ddf_fun_t *fnode = NULL; … … 145 146 /* Register function. */ 146 147 if (ddf_fun_bind(fnode) != EOK) { 147 printf(NAME ": errorbinding function %s.\n", name);148 ddf_msg(LVL_ERROR, "Failed binding function %s.\n", name); 148 149 goto failure; 149 150 } … … 158 159 ddf_fun_destroy(fnode); 159 160 160 printf(NAME ": failed to addfunction '%s'.\n", name);161 ddf_msg(LVL_ERROR, "Failed adding function '%s'.\n", name); 161 162 162 163 return false; … … 176 177 static int rootpc_add_device(ddf_dev_t *dev) 177 178 { 178 printf(NAME ":rootpc_add_device, device handle = %d\n",179 ddf_msg(LVL_DEBUG, "rootpc_add_device, device handle = %d\n", 179 180 (int)dev->handle); 180 181 181 182 /* Register functions. */ 182 183 if (!rootpc_add_functions(dev)) { 183 printf(NAME ": failed to add functions for PC platform.\n");184 ddf_msg(LVL_ERROR, "Failed to add functions for PC platform.\n"); 184 185 } 185 186 … … 189 190 static void root_pc_init(void) 190 191 { 192 ddf_log_init(NAME, LVL_ERROR); 191 193 rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops; 192 194 } -
uspace/drv/rootvirt/rootvirt.c
r0864122 rbdbb6f6 40 40 #include <str_error.h> 41 41 #include <ddf/driver.h> 42 #include <ddf/log.h> 42 43 43 44 #define NAME "rootvirt" … … 83 84 int rc; 84 85 85 printf(NAME ": registering function `%s' (match \"%s\")\n",86 ddf_msg(LVL_DEBUG, "Registering function `%s' (match \"%s\")\n", 86 87 vfun->name, vfun->match_id); 87 88 88 89 fun = ddf_fun_create(vdev, fun_inner, vfun->name); 89 90 if (fun == NULL) { 90 printf(NAME ": errorcreating function %s\n", vfun->name);91 ddf_msg(LVL_ERROR, "Failed creating function %s\n", vfun->name); 91 92 return ENOMEM; 92 93 } … … 94 95 rc = ddf_fun_add_match_id(fun, vfun->match_id, 10); 95 96 if (rc != EOK) { 96 printf(NAME ": erroradding match IDs to function %s\n",97 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n", 97 98 vfun->name); 98 99 ddf_fun_destroy(fun); … … 102 103 rc = ddf_fun_bind(fun); 103 104 if (rc != EOK) { 104 printf(NAME ": errorbinding function %s: %s\n", vfun->name,105 ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", vfun->name, 105 106 str_error(rc)); 106 107 ddf_fun_destroy(fun); … … 108 109 } 109 110 110 printf(NAME ": registered child device `%s'\n", vfun->name);111 ddf_msg(LVL_NOTE, "Registered child device `%s'\n", vfun->name); 111 112 return EOK; 112 113 } … … 124 125 } 125 126 126 printf(NAME ":add_device(handle=%d)\n", (int)dev->handle);127 ddf_msg(LVL_DEBUG, "add_device(handle=%d)\n", (int)dev->handle); 127 128 128 129 /* … … 142 143 { 143 144 printf(NAME ": HelenOS virtual devices root driver\n"); 145 146 ddf_log_init(NAME, LVL_ERROR); 144 147 return ddf_driver_main(&rootvirt_driver); 145 148 } -
uspace/drv/test1/test1.c
r0864122 rbdbb6f6 35 35 #include <str_error.h> 36 36 #include <ddf/driver.h> 37 #include <ddf/log.h> 37 38 38 39 #include "test1.h" … … 64 65 int rc; 65 66 66 printf(NAME ": registering function `%s': %s.\n", name, message);67 ddf_msg(LVL_DEBUG, "Registering function `%s': %s.\n", name, message); 67 68 68 69 fun = ddf_fun_create(parent, fun_inner, name); 69 70 if (fun == NULL) { 70 printf(NAME ": errorcreating function %s\n", name);71 ddf_msg(LVL_ERROR, "Failed creating function %s\n", name); 71 72 rc = ENOMEM; 72 73 goto leave; … … 75 76 rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score); 76 77 if (rc != EOK) { 77 printf(NAME ": error adding match IDs to function %s\n", name); 78 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n", 79 name); 78 80 goto leave; 79 81 } … … 81 83 rc = ddf_fun_bind(fun); 82 84 if (rc != EOK) { 83 printf(NAME ": errorbinding function %s: %s\n", name,85 ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name, 84 86 str_error(rc)); 85 87 goto leave; 86 88 } 87 89 88 printf(NAME ": registered child device `%s'\n", name);90 ddf_msg(LVL_NOTE, "Registered child device `%s'\n", name); 89 91 rc = EOK; 90 91 92 92 93 leave: 93 94 if (rc != expected_rc) { 94 95 fprintf(stderr, 95 NAME ": Unexpected error registering function `%s'.\n" \96 NAME ": Unexpected error registering function `%s'.\n" 96 97 NAME ": Expected \"%s\" but got \"%s\".\n", 97 98 name, str_error(expected_rc), str_error(rc)); … … 127 128 int rc; 128 129 129 printf(NAME ":add_device(name=\"%s\", handle=%d)\n",130 ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)\n", 130 131 dev->name, (int) dev->handle); 131 132 132 133 fun_a = ddf_fun_create(dev, fun_exposed, "a"); 133 134 if (fun_a == NULL) { 134 printf(NAME ": errorcreating function 'a'.\n");135 ddf_msg(LVL_ERROR, "Failed creating function 'a'.\n"); 135 136 return ENOMEM; 136 137 } … … 138 139 rc = ddf_fun_bind(fun_a); 139 140 if (rc != EOK) { 140 printf(NAME ": errorbinding function 'a'.\n");141 ddf_msg(LVL_ERROR, "Failed binding function 'a'.\n"); 141 142 return rc; 142 143 } … … 160 161 } 161 162 162 printf(NAME ": device `%s' accepted.\n", dev->name);163 ddf_msg(LVL_DEBUG, "Device `%s' accepted.\n", dev->name); 163 164 164 165 return EOK; … … 168 169 { 169 170 printf(NAME ": HelenOS test1 virtual device driver\n"); 171 ddf_log_init(NAME, LVL_ERROR); 170 172 return ddf_driver_main(&test1_driver); 171 173 } -
uspace/drv/test2/test2.c
r0864122 rbdbb6f6 36 36 #include <str_error.h> 37 37 #include <ddf/driver.h> 38 #include <ddf/log.h> 38 39 39 40 #define NAME "test2" … … 64 65 int rc; 65 66 66 printf(NAME ": registering function `%s': %s.\n", name, message);67 ddf_msg(LVL_DEBUG, "Registering function `%s': %s.\n", name, message); 67 68 68 69 fun = ddf_fun_create(parent, fun_inner, name); 69 70 if (fun == NULL) { 70 printf(NAME ": errorcreating function %s\n", name);71 ddf_msg(LVL_ERROR, "Failed creating function %s\n", name); 71 72 return ENOMEM; 72 73 } … … 74 75 rc = ddf_fun_add_match_id(fun, match_id, match_score); 75 76 if (rc != EOK) { 76 printf(NAME ": error adding match IDs to function %s\n", name); 77 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n", 78 name); 77 79 ddf_fun_destroy(fun); 78 80 return rc; … … 81 83 rc = ddf_fun_bind(fun); 82 84 if (rc != EOK) { 83 printf(NAME ": errorbinding function %s: %s\n", name,85 ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name, 84 86 str_error(rc)); 85 87 ddf_fun_destroy(fun); … … 87 89 } 88 90 89 printf(NAME ": registered child device `%s'\n", name);91 ddf_msg(LVL_NOTE, "Registered child device `%s'\n", name); 90 92 return EOK; 91 93 } … … 111 113 fun_a = ddf_fun_create(dev, fun_exposed, "a"); 112 114 if (fun_a == NULL) { 113 printf(NAME ": errorcreating function 'a'.\n");115 ddf_msg(LVL_ERROR, "Failed creating function 'a'.\n"); 114 116 return ENOMEM; 115 117 } … … 117 119 rc = ddf_fun_bind(fun_a); 118 120 if (rc != EOK) { 119 printf(NAME ": errorbinding function 'a'.\n");121 ddf_msg(LVL_ERROR, "Failed binding function 'a'.\n"); 120 122 return rc; 121 123 } … … 128 130 static int test2_add_device(ddf_dev_t *dev) 129 131 { 130 printf(NAME ":test2_add_device(name=\"%s\", handle=%d)\n",132 ddf_msg(LVL_DEBUG, "test2_add_device(name=\"%s\", handle=%d)\n", 131 133 dev->name, (int) dev->handle); 132 134 … … 134 136 fid_t postpone = fibril_create(postponed_birth, dev); 135 137 if (postpone == 0) { 136 printf(NAME ": fibril_create() error\n");138 ddf_msg(LVL_ERROR, "fibril_create() failed.\n"); 137 139 return ENOMEM; 138 140 } … … 149 151 { 150 152 printf(NAME ": HelenOS test2 virtual device driver\n"); 153 ddf_log_init(NAME, LVL_ERROR); 151 154 return ddf_driver_main(&test2_driver); 152 155 } -
uspace/lib/c/Makefile
r0864122 rbdbb6f6 76 76 generic/io/io.c \ 77 77 generic/io/printf.c \ 78 generic/io/log.c \ 78 79 generic/io/klog.c \ 79 80 generic/io/snprintf.c \ -
uspace/lib/drv/Makefile
r0864122 rbdbb6f6 35 35 generic/driver.c \ 36 36 generic/dev_iface.c \ 37 generic/log.c \ 37 38 generic/remote_hw_res.c \ 38 39 generic/remote_char_dev.c -
uspace/lib/drv/generic/driver.c
r0864122 rbdbb6f6 273 273 274 274 res = driver->driver_ops->add_device(dev); 275 if (res == EOK) { 276 printf("%s: new device with handle=%" PRIun " was added.\n", 277 driver->name, dev_handle); 278 } else { 279 printf("%s: failed to add a new device with handle = %" PRIun ".\n", 280 driver->name, dev_handle); 275 if (res != EOK) 281 276 delete_device(dev); 282 }283 277 284 278 async_answer_0(iid, res); -
uspace/srv/devman/devman.c
r0864122 rbdbb6f6 34 34 #include <fcntl.h> 35 35 #include <sys/stat.h> 36 #include <io/log.h> 36 37 #include <ipc/driver.h> 37 38 #include <ipc/devman.h> … … 146 147 fibril_mutex_unlock(&drivers_list->drivers_mutex); 147 148 148 printf(NAME": the '%s' driverwas added to the list of available "149 log_msg(LVL_NOTE, "Driver `%s' was added to the list of available " 149 150 "drivers.\n", drv->name); 150 151 } … … 237 238 bool read_match_ids(const char *conf_path, match_id_list_t *ids) 238 239 { 239 printf(NAME ": read_match_ids conf_path = %s.\n", conf_path);240 log_msg(LVL_DEBUG, "read_match_ids(conf_path=\"%s\")\n", conf_path); 240 241 241 242 bool suc = false; … … 247 248 fd = open(conf_path, O_RDONLY); 248 249 if (fd < 0) { 249 printf(NAME ": unable to open %s\n", conf_path); 250 log_msg(LVL_ERROR, "Unable to open `%s' for reading: %s.\n", 251 conf_path, str_error(fd)); 250 252 goto cleanup; 251 253 } … … 255 257 lseek(fd, 0, SEEK_SET); 256 258 if (len == 0) { 257 printf(NAME ": configuration file '%s' is empty.\n", conf_path); 259 log_msg(LVL_ERROR, "Configuration file '%s' is empty.\n", 260 conf_path); 258 261 goto cleanup; 259 262 } … … 261 264 buf = malloc(len + 1); 262 265 if (buf == NULL) { 263 printf(NAME ": memory allocation failed when parsing file "266 log_msg(LVL_ERROR, "Memory allocation failed when parsing file " 264 267 "'%s'.\n", conf_path); 265 268 goto cleanup; … … 268 271 ssize_t read_bytes = safe_read(fd, buf, len); 269 272 if (read_bytes <= 0) { 270 printf(NAME ": unable to read file '%s'.\n", conf_path);273 log_msg(LVL_ERROR, "Unable to read file '%s'.\n", conf_path); 271 274 goto cleanup; 272 275 } … … 306 309 bool get_driver_info(const char *base_path, const char *name, driver_t *drv) 307 310 { 308 printf(NAME ": get_driver_info base_path = %s, name = %s.\n",311 log_msg(LVL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")\n", 309 312 base_path, name); 310 313 … … 338 341 struct stat s; 339 342 if (stat(drv->binary_path, &s) == ENOENT) { /* FIXME!! */ 340 printf(NAME ": driver not found at path %s.", drv->binary_path); 343 log_msg(LVL_ERROR, "Driver not found at path `%s'.", 344 drv->binary_path); 341 345 goto cleanup; 342 346 } … … 365 369 int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path) 366 370 { 367 printf(NAME ": lookup_available_drivers, dir = %s\n", dir_path);371 log_msg(LVL_DEBUG, "lookup_available_drivers(dir=\"%s\")\n", dir_path); 368 372 369 373 int drv_cnt = 0; … … 399 403 dev_node_t *dev; 400 404 401 printf(NAME ": create_root_nodes\n");405 log_msg(LVL_DEBUG, "create_root_nodes()\n"); 402 406 403 407 fibril_rwlock_write_lock(&tree->rwlock); … … 484 488 void attach_driver(dev_node_t *dev, driver_t *drv) 485 489 { 486 printf(NAME ": attach_driver %s to device %s\n",487 d rv->name, dev->pfun->pathname);490 log_msg(LVL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")\n", 491 dev->pfun->pathname, drv->name); 488 492 489 493 fibril_mutex_lock(&drv->driver_mutex); … … 507 511 assert(fibril_mutex_is_locked(&drv->driver_mutex)); 508 512 509 printf(NAME ": start_driver '%s'\n", drv->name);513 log_msg(LVL_DEBUG, "start_driver(drv=\"%s\")\n", drv->name); 510 514 511 515 rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL); 512 516 if (rc != EOK) { 513 printf(NAME ": error spawning %s (%s)\n",514 drv->name, str_error(rc));517 log_msg(LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.\n", 518 drv->name, drv->binary_path, str_error(rc)); 515 519 return false; 516 520 } … … 574 578 int phone; 575 579 576 printf(NAME ": pass_devices_to_driver(`%s')\n", driver->name); 580 log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")\n", 581 driver->name); 577 582 578 583 fibril_mutex_lock(&driver->driver_mutex); … … 641 646 * immediately and possibly started here as well. 642 647 */ 643 printf(NAME ": driver %s goes intorunning state.\n", driver->name);648 log_msg(LVL_DEBUG, "Driver `%s' enters running state.\n", driver->name); 644 649 driver->state = DRIVER_RUNNING; 645 650 … … 658 663 void initialize_running_driver(driver_t *driver, dev_tree_t *tree) 659 664 { 660 printf(NAME ": initialize_running_driver (`%s')\n", driver->name); 665 log_msg(LVL_DEBUG, "initialize_running_driver(driver=\"%s\")\n", 666 driver->name); 661 667 662 668 /* … … 748 754 * access any structures that would affect driver_t. 749 755 */ 750 printf(NAME ": add_device (driver `%s', device `%s')\n", drv->name,751 d ev->pfun->name);756 log_msg(LVL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")\n", 757 drv->name, dev->pfun->name); 752 758 753 759 sysarg_t rc; … … 810 816 driver_t *drv = find_best_match_driver(drivers_list, dev); 811 817 if (drv == NULL) { 812 printf(NAME ": no driver found for device '%s'.\n",818 log_msg(LVL_ERROR, "No driver found for device `%s'.\n", 813 819 dev->pfun->pathname); 814 820 return false; … … 848 854 bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list) 849 855 { 850 printf(NAME ": init_device_tree.\n");856 log_msg(LVL_DEBUG, "init_device_tree()\n"); 851 857 852 858 tree->current_handle = 0; … … 1027 1033 fun->pathname = (char *) malloc(pathsize); 1028 1034 if (fun->pathname == NULL) { 1029 printf(NAME ": failed to allocate device path.\n");1035 log_msg(LVL_ERROR, "Failed to allocate device path.\n"); 1030 1036 return false; 1031 1037 } … … 1058 1064 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 1059 1065 1066 log_msg(LVL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])\n", 1067 dev, pfun, pfun->pathname); 1068 1060 1069 /* Add the node to the handle-to-node map. */ 1061 1070 dev->handle = ++tree->current_handle; … … 1064 1073 1065 1074 /* Add the node to the list of its parent's children. */ 1066 printf("insert_dev_node: dev=%p, dev->pfun := %p\n", dev, pfun);1067 1075 dev->pfun = pfun; 1068 1076 pfun->child = dev; -
uspace/srv/devman/main.c
r0864122 rbdbb6f6 43 43 #include <stdio.h> 44 44 #include <errno.h> 45 #include <str_error.h> 45 46 #include <bool.h> 46 47 #include <fibril_synch.h> … … 51 52 #include <sys/stat.h> 52 53 #include <ctype.h> 54 #include <io/log.h> 53 55 #include <ipc/devman.h> 54 56 #include <ipc/driver.h> … … 71 73 driver_t *driver = NULL; 72 74 73 printf(NAME ": devman_driver_register\n");75 log_msg(LVL_DEBUG, "devman_driver_register\n"); 74 76 75 77 iid = async_get_call(&icall); … … 88 90 } 89 91 90 printf(NAME ": the %s driver is trying to register by the service.\n",92 log_msg(LVL_DEBUG, "The `%s' driver is trying to register.\n", 91 93 drv_name); 92 94 … … 95 97 96 98 if (driver == NULL) { 97 printf(NAME ": no driver named %swas found.\n", drv_name);99 log_msg(LVL_ERROR, "No driver named `%s' was found.\n", drv_name); 98 100 free(drv_name); 99 101 drv_name = NULL; … … 106 108 107 109 /* Create connection to the driver. */ 108 printf(NAME ": creating connection to the %s driver.\n", driver->name); 110 log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.\n", 111 driver->name); 109 112 ipc_call_t call; 110 113 ipc_callid_t callid = async_get_call(&call); … … 118 121 set_driver_phone(driver, IPC_GET_ARG5(call)); 119 122 120 printf(NAME ": the %s driver was successfully registered as running.\n", 123 log_msg(LVL_NOTE, 124 "The `%s' driver was successfully registered as running.\n", 121 125 driver->name); 122 126 … … 142 146 callid = async_get_call(&call); 143 147 if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) { 144 printf(NAME ": ERROR: devman_receive_match_id - invalid "145 " protocol.\n");148 log_msg(LVL_ERROR, 149 "Invalid protocol when trying to receive match id.\n"); 146 150 async_answer_0(callid, EINVAL); 147 151 delete_match_id(match_id); … … 150 154 151 155 if (match_id == NULL) { 152 printf(NAME ": ERROR: devman_receive_match_id - failed to " 153 "allocate match id.\n"); 156 log_msg(LVL_ERROR, "Failed to allocate match id.\n"); 154 157 async_answer_0(callid, ENOMEM); 155 158 return ENOMEM; … … 165 168 if (rc != EOK) { 166 169 delete_match_id(match_id); 167 printf(NAME ": devman_receive_match_id - failed to receive "168 "match id string.\n");170 log_msg(LVL_ERROR, "Failed to receive match id string: %s.\n", 171 str_error(rc)); 169 172 return rc; 170 173 } … … 172 175 list_append(&match_id->link, &match_ids->ids); 173 176 174 printf(NAME ": received match id '%s', score = %d\n",177 log_msg(LVL_DEBUG, "Received match id `%s', score %d.\n", 175 178 match_id->id, match_id->score); 176 179 return rc; … … 228 231 if (ftype != fun_inner && ftype != fun_exposed) { 229 232 /* Unknown function type */ 230 printf(NAME ": Error, unknown function type provided by driver!\n"); 233 log_msg(LVL_ERROR, 234 "Unknown function type %d provided by driver.\n", 235 (int) ftype); 231 236 232 237 fibril_rwlock_write_unlock(&tree->rwlock); … … 275 280 fibril_rwlock_write_unlock(&tree->rwlock); 276 281 277 printf(NAME ": devman_add_function %s\n", fun->pathname);282 log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\")\n", fun->pathname); 278 283 279 284 devman_receive_match_ids(match_count, &fun->match_ids); … … 357 362 devmap_register_class_dev(class_info); 358 363 359 printf(NAME ": function'%s' added to class '%s', class name '%s' was "360 "asigned to it\n",fun->pathname, class_name, class_info->dev_name);364 log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.\n", 365 fun->pathname, class_name, class_info->dev_name); 361 366 362 367 async_answer_0(callid, EOK); … … 373 378 374 379 initialize_running_driver(driver, &device_tree); 375 printf(NAME ": the %s driver was successfully initialized.\n",380 log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized.\n", 376 381 driver->name); 377 382 return 0; … … 395 400 fid_t fid = fibril_create(init_running_drv, driver); 396 401 if (fid == 0) { 397 printf(NAME ": Error creating fibril for the initialization of "398 " the newly registered running driver.\n");402 log_msg(LVL_ERROR, "Failed to create initialization fibril " \ 403 "for driver `%s' .\n", driver->name); 399 404 return; 400 405 } … … 531 536 */ 532 537 if (dev == NULL) { 533 printf(NAME ": devman_forward error - no device or function with"534 " handle %" PRIun " was found.\n", handle);538 log_msg(LVL_ERROR, "IPC forwarding failed - no device or " 539 "function with handle %" PRIun " was found.\n", handle); 535 540 async_answer_0(iid, ENOENT); 536 541 return; … … 538 543 539 544 if (fun == NULL && !drv_to_parent) { 540 printf(NAME ": devman_forward error - cannot connect to " 541 "handle %" PRIun ", refers to a device.\n", handle); 545 log_msg(LVL_ERROR, NAME ": devman_forward error - cannot " 546 "connect to handle %" PRIun ", refers to a device.\n", 547 handle); 542 548 async_answer_0(iid, ENOENT); 543 549 return; … … 560 566 561 567 if (driver == NULL) { 562 printf(NAME ": devman_forward error - the device is not in %" PRIun563 " usable state.\n", handle);568 log_msg(LVL_ERROR, "IPC forwarding refused - " \ 569 "the device %" PRIun " is not in usable state.\n", handle); 564 570 async_answer_0(iid, ENOENT); 565 571 return; … … 573 579 574 580 if (driver->phone <= 0) { 575 printf(NAME ": devman_forward: cound not forward to driver %s ",576 driver->name);577 printf("the driver's phone is %" PRIun ").\n",driver->phone);581 log_msg(LVL_ERROR, 582 "Could not forward to driver `%s' (phone is %d).\n", 583 driver->name, (int) driver->phone); 578 584 async_answer_0(iid, EINVAL); 579 585 return; … … 581 587 582 588 if (fun != NULL) { 583 printf(NAME ": devman_forward: forward connection to function %s to " 584 "driver %s.\n", fun->pathname, driver->name); 589 log_msg(LVL_DEBUG, 590 "Forwarding request for `%s' function to driver `%s'.\n", 591 fun->pathname, driver->name); 585 592 } else { 586 printf(NAME ": devman_forward: forward connection to device %s to " 587 "driver %s.\n", dev->pfun->pathname, driver->name); 593 log_msg(LVL_DEBUG, 594 "Forwarding request for `%s' device to driver `%s'.\n", 595 dev->pfun->pathname, driver->name); 588 596 } 589 597 … … 617 625 async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0, 618 626 IPC_FF_NONE); 619 printf(NAME ": devman_connection_devmapper: forwarded connection to " 620 "device %s to driver %s.\n", fun->pathname, dev->drv->name); 627 log_msg(LVL_DEBUG, 628 "Forwarding devmapper request for `%s' function to driver `%s'.\n", 629 fun->pathname, dev->drv->name); 621 630 } 622 631 … … 653 662 static bool devman_init(void) 654 663 { 655 printf(NAME ":devman_init - looking for available drivers.\n");664 log_msg(LVL_DEBUG, "devman_init - looking for available drivers.\n"); 656 665 657 666 /* Initialize list of available drivers. */ … … 659 668 if (lookup_available_drivers(&drivers_list, 660 669 DRIVER_DEFAULT_STORE) == 0) { 661 printf(NAME "no drivers found.");670 log_msg(LVL_FATAL, "no drivers found."); 662 671 return false; 663 672 } 664 673 665 printf(NAME ": devman_init- list of drivers has been initialized.\n");674 log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized.\n"); 666 675 667 676 /* Create root device node. */ 668 677 if (!init_device_tree(&device_tree, &drivers_list)) { 669 printf(NAME " failed to initialize device tree.");678 log_msg(LVL_FATAL, "Failed to initialize device tree."); 670 679 return false; 671 680 } … … 688 697 printf(NAME ": HelenOS Device Manager\n"); 689 698 699 if (log_init(NAME, LVL_ERROR) != EOK) { 700 printf(NAME ": Error initializing logging subsystem.\n"); 701 return -1; 702 } 703 690 704 if (!devman_init()) { 691 printf(NAME ": Error while initializing service\n");705 log_msg(LVL_ERROR, "Error while initializing service.\n"); 692 706 return -1; 693 707 } … … 697 711 698 712 /* Register device manager at naming service. */ 699 if (service_register(SERVICE_DEVMAN) != EOK) 713 if (service_register(SERVICE_DEVMAN) != EOK) { 714 log_msg(LVL_ERROR, "Failed registering as a service.\n"); 700 715 return -1; 701 702 printf(NAME ": Accepting connections\n"); 716 } 717 718 printf(NAME ": Accepting connections.\n"); 703 719 async_manager(); 704 720
Note:
See TracChangeset
for help on using the changeset viewer.