Index: kernel/generic/src/ddi/ddi.c
===================================================================
--- kernel/generic/src/ddi/ddi.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ kernel/generic/src/ddi/ddi.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -229,7 +229,11 @@
     void *virt_ptr, uintptr_t bound)
 {
-	uintptr_t virt = (uintptr_t) -1;
-	int rc = physmem_map(ALIGN_DOWN(phys, FRAME_SIZE), pages, flags,
-	    &virt, bound);
+	uintptr_t virt;
+	int rc = copy_from_uspace(&virt, virt_ptr, sizeof(virt));
+	if (rc != EOK)
+		return rc;
+	
+	rc = physmem_map(ALIGN_DOWN(phys, FRAME_SIZE), pages, flags, &virt,
+	    bound);
 	if (rc != EOK)
 		return rc;
@@ -390,6 +394,10 @@
 			return rc;
 		
+		uintptr_t virt;
+		rc = copy_from_uspace(&virt, virt_ptr, sizeof(virt));
+		if (rc != EOK)
+			return rc;
+		
 		uintptr_t phys;
-		uintptr_t virt = (uintptr_t) -1;
 		rc = dmamem_map_anonymous(size, constraint, map_flags, flags,
 		    &phys, &virt, bound);
Index: uspace/app/kio/kio.c
===================================================================
--- uspace/app/kio/kio.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/app/kio/kio.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -63,5 +63,5 @@
 
 /* Pointer to kio area */
-static wchar_t *kio;
+static wchar_t *kio = (wchar_t *) AS_AREA_ANY;
 static size_t kio_length;
 
Index: uspace/drv/audio/sb16/dsp.c
===================================================================
--- uspace/drv/audio/sb16/dsp.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/drv/audio/sb16/dsp.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -178,5 +178,5 @@
 	
 	uintptr_t pa = 0;
-	void *buffer = NULL;
+	void *buffer = AS_AREA_ANY;
 	
 	int ret = dmamem_map_anonymous(size, DMAMEM_16MiB | 0x0000ffff,
Index: uspace/drv/block/ahci/ahci.c
===================================================================
--- uspace/drv/block/ahci/ahci.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/drv/block/ahci/ahci.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -234,5 +234,5 @@
 	
 	uintptr_t phys;
-	void *ibuf;
+	void *ibuf = AS_AREA_ANY;
 	int rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB,
 	    AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &ibuf);
@@ -277,5 +277,5 @@
 	
 	uintptr_t phys;
-	void *ibuf;
+	void *ibuf = AS_AREA_ANY;
 	int rc = dmamem_map_anonymous(sata->block_size, DMAMEM_4GiB,
 	    AS_AREA_READ | AS_AREA_WRITE, 0, &phys, &ibuf);
@@ -436,8 +436,8 @@
 	
 	uintptr_t phys;
-	sata_identify_data_t *idata;
+	sata_identify_data_t *idata = AS_AREA_ANY;
 	int rc = dmamem_map_anonymous(SATA_IDENTIFY_DEVICE_BUFFER_LENGTH,
 	    DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys,
-	    (void **) &idata);
+	    (void *) &idata);
 	if (rc != EOK) {
 		ddf_msg(LVL_ERROR, "Cannot allocate buffer to identify device.");
@@ -630,8 +630,8 @@
 	
 	uintptr_t phys;
-	sata_identify_data_t *idata;
+	sata_identify_data_t *idata = AS_AREA_ANY;
 	int rc = dmamem_map_anonymous(SATA_SET_FEATURE_BUFFER_LENGTH,
 	    DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys,
-	    (void **) &idata);
+	    (void *) &idata);
 	if (rc != EOK) {
 		ddf_msg(LVL_ERROR, "Cannot allocate buffer for device set mode.");
@@ -938,7 +938,7 @@
 	size_t size = 4096;
 	uintptr_t phys = 0;
-	void *virt_fb = NULL;
-	void *virt_cmd = NULL;
-	void *virt_table = NULL;
+	void *virt_fb = AS_AREA_ANY;
+	void *virt_cmd = AS_AREA_ANY;
+	void *virt_table = AS_AREA_ANY;
 	ddf_fun_t *fun;
 	
@@ -1155,9 +1155,9 @@
 	
 	/* Map AHCI registers. */
-	ahci->memregs = NULL;
+	ahci->memregs = AS_AREA_ANY;
 	
 	physmem_map(RNGABS(hw_res_parsed.mem_ranges.ranges[0]),
 	    AHCI_MEMREGS_PAGES_COUNT, AS_AREA_READ | AS_AREA_WRITE,
-	    (void **) &ahci->memregs);
+	    (void *) &ahci->memregs);
 	if (ahci->memregs == NULL)
 		goto error_map_registers;
Index: uspace/drv/bus/usb/uhci/utils/malloc32.h
===================================================================
--- uspace/drv/bus/usb/uhci/utils/malloc32.h	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/drv/bus/usb/uhci/utils/malloc32.h	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -103,5 +103,5 @@
 {
 	uintptr_t phys;
-	void *address;
+	void *address = AS_AREA_ANY;
 	
 	const int ret = dmamem_map_anonymous(UHCI_REQUIRED_PAGE_SIZE,
Index: uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c
===================================================================
--- uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -38,5 +38,5 @@
 #include <ddf/log.h>
 #include <ddi.h>
-#include <abi/mm/as.h>
+#include <as.h>
 
 #include "amdm37x_dispc.h"
@@ -274,5 +274,5 @@
 	const size_t size = ALIGN_UP(x * y * bpp, PAGE_SIZE);
 	uintptr_t pa;
-	void *buffer;
+	void *buffer = AS_AREA_ANY;
 	int ret = dmamem_map_anonymous(size, DMAMEM_4GiB,
 	    AS_AREA_READ | AS_AREA_WRITE, 0, &pa, &buffer);
Index: uspace/drv/fb/kfb/port.c
===================================================================
--- uspace/drv/fb/kfb/port.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/drv/fb/kfb/port.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -333,4 +333,6 @@
 	
 	kfb.size = scanline * height;
+	kfb.addr = AS_AREA_ANY;
+	
 	rc = physmem_map(paddr + offset,
 	    ALIGN_UP(kfb.size, PAGE_SIZE) >> PAGE_WIDTH,
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/drv/nic/e1k/e1k.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -1375,4 +1375,5 @@
 	fibril_mutex_lock(&e1000->rx_lock);
 	
+	e1000->rx_ring_virt = AS_AREA_ANY;
 	int rc = dmamem_map_anonymous(
 	    E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t),
@@ -1396,9 +1397,8 @@
 	}
 	
-	size_t i;
-	uintptr_t frame_phys;
-	void *frame_virt;
-	
-	for (i = 0; i < E1000_RX_FRAME_COUNT; i++) {
+	for (size_t i = 0; i < E1000_RX_FRAME_COUNT; i++) {
+		uintptr_t frame_phys;
+		void *frame_virt = AS_AREA_ANY;
+		
 		rc = dmamem_map_anonymous(E1000_MAX_SEND_FRAME_SIZE,
 		    DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0,
@@ -1412,5 +1412,5 @@
 	
 	/* Write descriptor */
-	for (i = 0; i < E1000_RX_FRAME_COUNT; i++)
+	for (size_t i = 0; i < E1000_RX_FRAME_COUNT; i++)
 		e1000_fill_new_rx_descriptor(nic, i);
 	
@@ -1421,5 +1421,5 @@
 	
 error:
-	for (i = 0; i < E1000_RX_FRAME_COUNT; i++) {
+	for (size_t i = 0; i < E1000_RX_FRAME_COUNT; i++) {
 		if (e1000->rx_frame_virt[i] != NULL) {
 			dmamem_unmap_anonymous(e1000->rx_frame_virt[i]);
@@ -1571,5 +1571,5 @@
 	
 	e1000->tx_ring_phys = 0;
-	e1000->tx_ring_virt = NULL;
+	e1000->tx_ring_virt = AS_AREA_ANY;
 	
 	e1000->tx_frame_phys = NULL;
@@ -1597,4 +1597,5 @@
 	
 	for (i = 0; i < E1000_TX_FRAME_COUNT; i++) {
+		e1000->tx_frame_virt[i] = AS_AREA_ANY;
 		rc = dmamem_map_anonymous(E1000_MAX_SEND_FRAME_SIZE,
 		    DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/drv/nic/rtl8139/driver.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -1141,5 +1141,6 @@
 
 	ddf_msg(LVL_DEBUG, "Creating buffers");
-
+	
+	rtl8139->tx_buff_virt = AS_AREA_ANY;
 	rc = dmamem_map_anonymous(TX_PAGES * PAGE_SIZE, DMAMEM_4GiB,
 	    AS_AREA_WRITE, 0, &rtl8139->tx_buff_phys, &rtl8139->tx_buff_virt);
@@ -1161,5 +1162,6 @@
 	ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %d bytes",
 	    RxBUF_TOT_LENGTH);
-
+	
+	rtl8139->rx_buff_virt = AS_AREA_ANY;
 	rc = dmamem_map_anonymous(RxBUF_TOT_LENGTH, DMAMEM_4GiB,
 	    AS_AREA_READ, 0, &rtl8139->rx_buff_phys, &rtl8139->rx_buff_virt);
Index: uspace/lib/c/generic/ddi.c
===================================================================
--- uspace/lib/c/generic/ddi.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/lib/c/generic/ddi.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -71,8 +71,10 @@
  * @param flags Flags for the new address space area.
  * @param virt  Virtual address of the starting page.
- *
- * @return EOK on success
- * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability
- * @return ENOENT if there is no task with specified ID
+ *              If set to AS_AREA_ANY ((void *) -1), a suitable value
+ *              is found by the kernel, otherwise the kernel tries to
+ *              obey the desired value.
+ *
+ * @return EOK on success.
+ * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
  * @return ENOMEM if there was some problem in creating
  *         the address space area.
@@ -85,4 +87,24 @@
 }
 
+/** Lock a piece physical memory for DMA transfers.
+ *
+ * The mapping of the specified virtual memory address
+ * to physical memory address is locked in order to
+ * make it safe for DMA transferts.
+ *
+ * Caller of this function must have the CAP_MEM_MANAGER capability.
+ *
+ * @param virt      Virtual address of the memory to be locked.
+ * @param size      Number of bytes to lock.
+ * @param map_flags Desired virtual memory area flags.
+ * @param flags     Flags for the physical memory address.
+ * @param phys      Locked physical memory address.
+ *
+ * @return EOK on success.
+ * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
+ * @return ENOMEM if there was some problem in creating
+ *         the address space area.
+ *
+ */
 int dmamem_map(void *virt, size_t size, unsigned int map_flags,
     unsigned int flags, uintptr_t *phys)
@@ -93,4 +115,24 @@
 }
 
+/** Map a piece of physical memory suitable for DMA transfers.
+ *
+ * Caller of this function must have the CAP_MEM_MANAGER capability.
+ *
+ * @param size       Number of bytes to map.
+ * @param constraint Bit mask defining the contraint on the physical
+ *                   address to be mapped.
+ * @param map_flags  Desired virtual memory area flags.
+ * @param flags      Flags for the physical memory address.
+ * @param virt       Virtual address of the starting page.
+ *                   If set to AS_AREA_ANY ((void *) -1), a suitable value
+ *                   is found by the kernel, otherwise the kernel tries to
+ *                   obey the desired value.
+ *
+ * @return EOK on success.
+ * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
+ * @return ENOMEM if there was some problem in creating
+ *         the address space area.
+ *
+ */
 int dmamem_map_anonymous(size_t size, uintptr_t constraint,
     unsigned int map_flags, unsigned int flags, uintptr_t *phys, void **virt)
@@ -221,5 +263,5 @@
 	size_t pages = SIZE2PAGES(offset + size);
 	
-	void *virt_page;
+	void *virt_page = AS_AREA_ANY;
 	int rc = physmem_map(phys_frame, pages,
 	    AS_AREA_READ | AS_AREA_WRITE, &virt_page);
Index: uspace/lib/c/generic/time.c
===================================================================
--- uspace/lib/c/generic/time.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/lib/c/generic/time.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -555,5 +555,5 @@
 		}
 		
-		void *addr;
+		void *addr = AS_AREA_ANY;
 		rc = physmem_map(faddr, 1, AS_AREA_READ | AS_AREA_CACHEABLE,
 		    &addr);
Index: uspace/srv/bd/rd/rd.c
===================================================================
--- uspace/srv/bd/rd/rd.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/srv/bd/rd/rd.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -60,5 +60,5 @@
 
 /** Pointer to the ramdisk's image */
-static void *rd_addr;
+static void *rd_addr = AS_AREA_ANY;
 
 /** Size of the ramdisk */
Index: uspace/srv/hid/input/port/niagara.c
===================================================================
--- uspace/srv/hid/input/port/niagara.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/srv/hid/input/port/niagara.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -74,11 +74,8 @@
 	uint64_t read_ptr;
 	char data[INPUT_BUFFER_SIZE];
-}
-	__attribute__ ((packed))
-	__attribute__ ((aligned(PAGE_SIZE)))
-	*input_buffer_t;
+} __attribute__((packed)) __attribute__((aligned(PAGE_SIZE))) *input_buffer_t;
 
 /* virtual address of the shared buffer */
-static input_buffer_t input_buffer;
+static input_buffer_t input_buffer = (input_buffer_t) AS_AREA_ANY;
 
 static volatile bool polling_disabled = false;
@@ -87,5 +84,5 @@
 /**
  * Initializes the Niagara driver.
- * Maps the shared buffer and creates the polling thread. 
+ * Maps the shared buffer and creates the polling thread.
  */
 static int niagara_port_init(kbd_dev_t *kdev)
Index: uspace/srv/hid/output/port/ega.c
===================================================================
--- uspace/srv/hid/output/port/ega.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/srv/hid/output/port/ega.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -215,4 +215,5 @@
 	
 	ega.size = (ega.cols * ega.rows) << 1;
+	ega.addr = AS_AREA_ANY;
 	
 	rc = physmem_map(paddr,
Index: uspace/srv/hid/output/port/kchar.c
===================================================================
--- uspace/srv/hid/output/port/kchar.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/srv/hid/output/port/kchar.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -84,4 +84,6 @@
 		return rc;
 	
+	kchar.addr = AS_AREA_ANY;
+	
 	rc = physmem_map(paddr,
 	    ALIGN_UP(1, PAGE_SIZE) >> PAGE_WIDTH,
Index: uspace/srv/hid/output/port/niagara.c
===================================================================
--- uspace/srv/hid/output/port/niagara.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/srv/hid/output/port/niagara.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -104,4 +104,6 @@
 		return rc;
 	
+	niagara.fifo = (output_fifo_t *) AS_AREA_ANY;
+	
 	rc = physmem_map(paddr, 1, AS_AREA_READ | AS_AREA_WRITE,
 	    (void *) &niagara.fifo);
Index: uspace/srv/hw/irc/obio/obio.c
===================================================================
--- uspace/srv/hw/irc/obio/obio.c	(revision 527f1ca698c19887792eba16533a0495b1b17014)
+++ uspace/srv/hw/irc/obio/obio.c	(revision bf9cb2ff74be98b6ea519f4cd121a9fe9ff54ebc)
@@ -70,5 +70,5 @@
 
 static uintptr_t base_phys;
-static volatile uint64_t *base_virt;
+static volatile uint64_t *base_virt = (volatile uint64_t *) AS_AREA_ANY;
 
 /** Handle one connection to obio.
