Changeset 73aec008 in mainline for uspace/drv/ns8250/ns8250.c
- Timestamp:
- 2011-03-31T18:23:41Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a30e435
- Parents:
- 917a8c8 (diff), 3acb285 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ns8250/ns8250.c
r917a8c8 r73aec008 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;
Note:
See TracChangeset
for help on using the changeset viewer.