Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision bf848717e8d508127f8be22655d603fdd89fe773)
+++ uspace/drv/nic/rtl8139/driver.c	(revision 9957a97b1f96f509f5b704ed33b6dc9c86d9cc51)
@@ -33,9 +33,9 @@
 #include <libarch/ddi.h>
 #include <libarch/barrier.h>
-#include <nlog.h>
-
-#include <dma.h>
+
+#include <as.h>
+#include <ddf/log.h>
 #include <ddf/interrupt.h>
-#include <devman.h>
+#include <io/log.h>
 #include <nic.h>
 #include <packet_client.h>
@@ -50,7 +50,7 @@
 #include <str.h>
 
-#include "rtl8139_defs.h"
-#include "rtl8139_driver.h"
-#include "rtl8139_general.h"
+#include "defs.h"
+#include "driver.h"
+#include "general.h"
 
 /** Global mutex for work with shared irq structure */
@@ -164,5 +164,5 @@
 	    (RXBUF_SIZE_FLAGS << RCR_RBLEN_SHIFT);
 	
-	nlog_debug("Rewriting rcr: %x -> %x", pio_read_32(rtl8139->io_port + RCR),
+	ddf_msg(LVL_DEBUG, "Rewriting rcr: %x -> %x", pio_read_32(rtl8139->io_port + RCR),
 	    rcr);
 
@@ -373,9 +373,9 @@
 static ddf_dev_ops_t rtl8139_dev_ops;
 
-static int rtl8139_add_device(ddf_dev_t *dev);
+static int rtl8139_dev_add(ddf_dev_t *dev);
 
 /** Basic driver operations for RTL8139 driver */
 static driver_ops_t rtl8139_driver_ops = {
-	.add_device = &rtl8139_add_device,
+	.dev_add = &rtl8139_dev_add,
 };
 
@@ -409,5 +409,5 @@
 	rtl8139_t *rtl8139 = nic_get_specific(nic_data);
 	assert(rtl8139);
-	nlog_debug("Sending packet");
+	ddf_msg(LVL_DEBUG, "Sending packet");
 
 	/* Get the packet data and check if it can be send */
@@ -418,5 +418,5 @@
 
 	if ((packet_length > RTL8139_PACKET_MAX_LENGTH) || !packet_data) {
-		nlog_error("Write packet length error: data %p, length %z", 
+		ddf_msg(LVL_ERROR, "Write packet length error: data %p, length %z", 
 		    packet_data, packet_length);
 		nic_report_send_error(rtl8139->nic_data, NIC_SEC_OTHER, 1);
@@ -527,5 +527,5 @@
 	nic_frame_t *frame = nic_alloc_frame(nic_data, packet_size);
 	if (! frame) {
-		nlog_error("Can not allocate frame for received packet.");
+		ddf_msg(LVL_ERROR, "Can not allocate frame for received packet.");
 		return NULL;
 	}
@@ -533,5 +533,5 @@
 	void *packet_data = packet_suffix(frame->packet, packet_size);
 	if (!packet_data) {
-		nlog_error("Can not get the packet suffix.");
+		ddf_msg(LVL_ERROR, "Can not get the packet suffix.");
 		nic_release_frame(nic_data, frame);
 		return NULL;
@@ -564,5 +564,5 @@
 	pio_write_32(rtl8139->io_port + CAPR, 0);
 	pio_write_32(rtl8139->io_port + RBSTART, 
-	    PTR2U32(rtl8139->rx_buff.physical));
+	    PTR2U32(rtl8139->rx_buff_phys));
 
 	write_barrier();
@@ -588,7 +588,7 @@
 	nic_frame_list_t *frames = nic_alloc_frame_list();
 	if (!frames)
-		nlog_error("Can not allocate frame list for received packets.");
-
-	void *rx_buffer = rtl8139->rx_buff.virtual;
+		ddf_msg(LVL_ERROR, "Can not allocate frame list for received packets.");
+
+	void *rx_buffer = rtl8139->rx_buff_virt;
 
 	/* where to start reading */
@@ -620,5 +620,5 @@
 		if (size == RTL8139_EARLY_SIZE) {
 			/* The packet copying is still in progress, break receiving */
-			nlog_debug("Early threshold reached, not completely coppied");
+			ddf_msg(LVL_DEBUG, "Early threshold reached, not completely coppied");
 			break;
 		}
@@ -626,5 +626,5 @@
 		/* Check if the header is valid, otherwise we are lost in the buffer */
 		if (size == 0 || size > RTL8139_PACKET_MAX_LENGTH) {
-			nlog_error("Receiver error -> receiver reset (size: %4"PRIu16", "
+			ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (size: %4"PRIu16", "
 			    "header 0x%4"PRIx16". Offset: %zu)", size, packet_header, 
 			    rx_offset);
@@ -632,5 +632,5 @@
 		}
 		if (size < RTL8139_RUNT_MAX_SIZE && !(rcs & RSR_RUNT)) {
-			nlog_error("Receiver error -> receiver reset (%"PRIx16")", size);
+			ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (%"PRIx16")", size);
 			goto rx_err;
 		}
@@ -801,5 +801,5 @@
 	pio_write_32(rtl8139->io_port + TIMERINT, timer_val);
 	pio_write_32(rtl8139->io_port + TCTR, 0x0);
-	nlog_debug("rtl8139 timer: %"PRIu32"\treceive: %d", timer_val, receive);
+	ddf_msg(LVL_DEBUG, "rtl8139 timer: %"PRIu32"\treceive: %d", timer_val, receive);
 	return receive;
 }
@@ -925,5 +925,5 @@
 	/* Write transmittion buffer addresses */
 	for(i = 0; i < TX_BUFF_COUNT; ++i) {
-		uint32_t addr = PTR2U32(rtl8139->tx_buff_mem.physical + i*TX_BUFF_SIZE);
+		uint32_t addr = PTR2U32(rtl8139->tx_buff_phys + i*TX_BUFF_SIZE);
 		pio_write_32(io_base + TSAD0 + 4*i, addr);
 	}
@@ -932,5 +932,5 @@
 	nic_set_tx_busy(rtl8139->nic_data, 0);
 
-	pio_write_32(io_base + RBSTART, PTR2U32(rtl8139->rx_buff.physical));
+	pio_write_32(io_base + RBSTART, PTR2U32(rtl8139->rx_buff_phys));
 
 	/* Enable transmitter and receiver */
@@ -949,5 +949,5 @@
 {
 	assert(nic_data);
-	nlog_info("Activating device");
+	ddf_msg(LVL_NOTE, "Activating device");
 
 	rtl8139_t *rtl8139 = nic_get_specific(nic_data);
@@ -962,5 +962,5 @@
 	nic_enable_interrupt(nic_data, rtl8139->irq);
 
-	nlog_debug("Device activated, interrupt %d registered", rtl8139->irq);
+	ddf_msg(LVL_DEBUG, "Device activated, interrupt %d registered", rtl8139->irq);
 	return EOK;
 }
@@ -1079,22 +1079,22 @@
 
 	if (hw_resources->irqs.count != 1) {
-		nlog_error("%s device: unexpected irq count", dev->name);
+		ddf_msg(LVL_ERROR, "%s device: unexpected irq count", dev->name);
 		return EINVAL;
 	};
 	if (hw_resources->io_ranges.count != 1) {
-		nlog_error("%s device: unexpected io ranges count", dev->name);
+		ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", dev->name);
 		return EINVAL;
 	}
 
 	rtl8139->irq = hw_resources->irqs.irqs[0];
-	nlog_debug("%s device: irq 0x%x assigned", dev->name, rtl8139->irq);
+	ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", dev->name, rtl8139->irq);
 
 	rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address);
 	if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) {
-		nlog_error("i/o range assigned to the device "
+		ddf_msg(LVL_ERROR, "i/o range assigned to the device "
 		    "%s is too small.", dev->name);
 		return EINVAL;
 	}
-	nlog_debug("%s device: i/o addr %p assigned.", dev->name, rtl8139->io_addr);
+	ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", dev->name, rtl8139->io_addr);
 
 	return EOK;
@@ -1142,22 +1142,20 @@
 static int rtl8139_buffers_create(rtl8139_t *rtl8139)
 {
-	assert(rtl8139);
 	size_t i = 0;
 	int rc;
 
-	nlog_debug("Creating buffers");
-
-	rtl8139->tx_buff_mem.size = TX_PAGES;
-	rtl8139->tx_buff_mem.mapping_flags = AS_AREA_WRITE;
-	rc = dma_allocate_anonymous(&rtl8139->tx_buff_mem, DMA_32_BITS);
+	ddf_msg(LVL_DEBUG, "Creating buffers");
+
+	rc = dmamem_map_anonymous(TX_PAGES * PAGE_SIZE, AS_AREA_WRITE, 0,
+	    &rtl8139->tx_buff_phys, &rtl8139->tx_buff_virt);
 	if (rc != EOK) {
-		nlog_error("Can not allocate transmitter buffers.");
+		ddf_msg(LVL_ERROR, "Can not allocate transmitter buffers.");
 		goto err_tx_alloc;
 	}
 
-	for(i = 0; i < TX_BUFF_COUNT; ++i)
-		rtl8139->tx_buff[i] = rtl8139->tx_buff_mem.virtual + i * TX_BUFF_SIZE;
-
-	nlog_debug("The transmittion buffers allocated");
+	for (i = 0; i < TX_BUFF_COUNT; ++i)
+		rtl8139->tx_buff[i] = rtl8139->tx_buff_virt + i * TX_BUFF_SIZE;
+
+	ddf_msg(LVL_DEBUG, "The transmittion buffers allocated");
 
 	/* Use the first buffer for next transmittion */
@@ -1166,20 +1164,19 @@
 
 	/* Allocate buffer for receiver */
-	size_t rx_pages = ALIGN_UP(RxBUF_TOT_LENGTH, PAGE_SIZE) / PAGE_SIZE;
-	nlog_debug("Allocating receiver buffer of the size %zd pages", rx_pages);
-
-	rtl8139->rx_buff.size = rx_pages;
-	rtl8139->rx_buff.mapping_flags = AS_AREA_READ;
-	rc = dma_allocate_anonymous(&rtl8139->rx_buff, DMA_32_BITS);
-	if( rc != EOK ) {
-		nlog_error("Can not allocate receiver buffer.");
+	ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %zu bytes",
+	    RxBUF_TOT_LENGTH);
+
+	rc = dmamem_map_anonymous(RxBUF_TOT_LENGTH, AS_AREA_READ, 0,
+	    &rtl8139->rx_buff_phys, &rtl8139->rx_buff_virt);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Can not allocate receive buffer.");
 		goto err_rx_alloc;
 	}
-	nlog_debug("The buffers created");
+	ddf_msg(LVL_DEBUG, "The buffers created");
 
 	return EOK;
 
 err_rx_alloc:
-	dma_free(&rtl8139->tx_buff_mem);
+	dmamem_unmap_anonymous(&rtl8139->tx_buff_virt);
 err_tx_alloc:
 	return rc;
@@ -1194,27 +1191,27 @@
 static int rtl8139_device_initialize(ddf_dev_t *dev)
 {
-	nlog_debug("rtl8139_dev_initialize %s", dev->name);
+	ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", dev->name);
 
 	int ret = EOK;
 
-	nlog_debug("rtl8139: creating device data");
+	ddf_msg(LVL_DEBUG, "rtl8139: creating device data");
 
 	/* Allocate driver data for the device. */
 	rtl8139_t *rtl8139 = rtl8139_create_dev_data(dev);
 	if (rtl8139 == NULL) {
-		nlog_error("Not enough memory for initializing %s.", dev->name);
+		ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", dev->name);
 		return ENOMEM;
 	}
 
-	nlog_debug("rtl8139: dev_data created");
+	ddf_msg(LVL_DEBUG, "rtl8139: dev_data created");
 
 	/* Obtain and fill hardware resources info and connect to parent */
 	ret = rtl8139_get_resource_info(dev);
 	if (ret != EOK) {
-		nlog_error("Can not obatin hw resources information");
+		ddf_msg(LVL_ERROR, "Can not obatin hw resources information");
 		goto failed;
 	}
 
-	nlog_debug("rtl8139: resource_info obtained");
+	ddf_msg(LVL_DEBUG, "rtl8139: resource_info obtained");
 
 	/* Allocate DMA buffers */
@@ -1231,9 +1228,9 @@
 	rtl8139->rcr_data.rcr_base = (0x8 << RCR_ERTH_SHIFT);
 
-	nlog_debug("The device is initialized");
+	ddf_msg(LVL_DEBUG, "The device is initialized");
 	return ret;
 
 failed:
-	nlog_error("The device initialization failed");
+	ddf_msg(LVL_ERROR, "The device initialization failed");
 	rtl8139_dev_cleanup(dev);
 	return ret;
@@ -1248,5 +1245,5 @@
 static int rtl8139_pio_enable(ddf_dev_t *dev)
 {
-	nlog_debug(NAME ": rtl8139_pio_enable %s", dev->name);
+	ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", dev->name);
 
 	rtl8139_t *rtl8139 = nic_get_specific(nic_get_from_ddf_dev(dev));
@@ -1254,5 +1251,5 @@
 	/* Gain control over port's registers. */
 	if (pio_enable(rtl8139->io_addr, RTL8139_IO_SIZE, &rtl8139->io_port)) {
-		nlog_error("Cannot gain the port %lx for device %s.", rtl8139->io_addr,
+		ddf_msg(LVL_ERROR, "Cannot gain the port %lx for device %s.", rtl8139->io_addr,
 		    dev->name);
 		return EADDRNOTAVAIL;
@@ -1282,5 +1279,5 @@
 		if (rtl8139_versions[i].hwverid == hwverid) {
 			rtl8139->hw_version = rtl8139_versions[i].ver_id;
-			nlog_info("HW version found: index %zu, ver_id %d (%s)", i,
+			ddf_msg(LVL_NOTE, "HW version found: index %zu, ver_id %d (%s)", i,
 			    rtl8139_versions[i].ver_id, model_names[rtl8139->hw_version]);
 		}
@@ -1296,8 +1293,8 @@
  * @return EOK if added successfully, negative error code otherwise
  */
-int rtl8139_add_device(ddf_dev_t *dev)
+int rtl8139_dev_add(ddf_dev_t *dev)
 {
 	assert(dev);
-	nlog_info("RTL8139_add_device %s (handle = %d)", dev->name, dev->handle);
+	ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)", dev->name, dev->handle);
 
 	/* Init device structure for rtl8139 */
@@ -1330,5 +1327,5 @@
 	rc = nic_connect_to_services(nic_data);
 	if (rc != EOK) {
-		nlog_error("Failed to connect to services", rc);
+		ddf_msg(LVL_ERROR, "Failed to connect to services", rc);
 		goto err_irq;
 	}
@@ -1336,9 +1333,9 @@
 	rc = nic_register_as_ddf_fun(nic_data, &rtl8139_dev_ops);
 	if (rc != EOK) {
-		nlog_error("Failed to register as DDF function - error %d", rc);
+		ddf_msg(LVL_ERROR, "Failed to register as DDF function - error %d", rc);
 		goto err_irq;
 	}
 
-	nlog_info("The %s device has been successfully initialized.",
+	ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.",
 	    dev->name);
 
@@ -1581,5 +1578,5 @@
 
 	if (allow_send && time > 0) {
-		nlog_warning("Time setting is not supported in set_pause method.");
+		ddf_msg(LVL_WARN, "Time setting is not supported in set_pause method.");
 	}
 	return EOK;
@@ -2121,5 +2118,5 @@
 		pio_write_32(rtl8139->io_port + TCTR, 0);
 
-		nlog_debug("Periodic mode. Interrupt mask %"PRIx16", poll.full_skips %"
+		ddf_msg(LVL_DEBUG, "Periodic mode. Interrupt mask %"PRIx16", poll.full_skips %"
 		    PRIu32", last timer %"PRIu32".", rtl8139->int_mask, 
 		    rtl8139->poll_timer.full_skips, rtl8139->poll_timer.last_val);
@@ -2168,6 +2165,6 @@
 		&rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface);
 
-	nlog_set_min_severity(DEBUG);
-	nlog_info("HelenOS RTL8139 driver started");
+	ddf_log_init(NAME, LVL_ERROR);
+	ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started");
 	return ddf_driver_main(&rtl8139_driver);
 }
