Index: boot/arch/ia64/include/types.h
===================================================================
--- boot/arch/ia64/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ boot/arch/ia64/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -35,5 +35,5 @@
 
 typedef uint64_t size_t;
-typedef uint64_t unative_t;
+typedef uint64_t sysarg_t;
 typedef uint64_t uintptr_t;
 
@@ -61,5 +61,5 @@
 	unsigned int memmap_items;
 
-	unative_t *sapic;
+	sysarg_t *sapic;
 	unsigned long sys_freq;
 	unsigned long freq_scale;
Index: boot/arch/ppc32/include/types.h
===================================================================
--- boot/arch/ppc32/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ boot/arch/ppc32/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -35,5 +35,5 @@
 typedef uint32_t size_t;
 typedef uint32_t uintptr_t;
-typedef uint32_t unative_t;
+typedef uint32_t sysarg_t;
 typedef int32_t native_t;
 
Index: boot/arch/sparc64/include/types.h
===================================================================
--- boot/arch/sparc64/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ boot/arch/sparc64/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -35,5 +35,5 @@
 typedef uint64_t size_t;
 typedef uint64_t uintptr_t;
-typedef uint64_t unative_t;
+typedef uint64_t sysarg_t;
 typedef int64_t native_t;
 
Index: boot/genarch/include/ofw.h
===================================================================
--- boot/genarch/include/ofw.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ boot/genarch/include/ofw.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,5 +40,5 @@
 #define OFW_TREE_PROPERTY_MAX_VALUELEN  64
 
-typedef unative_t ofw_arg_t;
+typedef sysarg_t ofw_arg_t;
 typedef native_t ofw_ret_t;
 typedef uint32_t ofw_prop_t;
Index: contrib/arch/hadlbppp.py
===================================================================
--- contrib/arch/hadlbppp.py	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/hadlbppp.py	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1151,5 +1151,5 @@
 					continue
 				
-				if ((token == "ipcarg_t") or (token == "unative_t")):
+				if (token == "sysarg_t"):
 					output += "\n%s%s " % (tabs(indent), token)
 					context.add(PROTOTYPE)
Index: contrib/arch/kernel/kernel.adl
===================================================================
--- contrib/arch/kernel/kernel.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/kernel/kernel.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -5,5 +5,5 @@
 interface sys_klog {
 		/* Print using kernel facility */
-		unative_t sys_klog(int fd, const void *buf, size_t size);
+		sysarg_t sys_klog(int fd, const void *buf, size_t size);
 	protocol:
 		?sys_klog*
@@ -12,8 +12,8 @@
 interface sys_console {
 		/* Enable kernel console */
-		unative_t sys_debug_enable_console(void);
+		sysarg_t sys_debug_enable_console(void);
 		
 		/* Disable kernel console */
-		unative_t sys_debug_disable_console(void);
+		sysarg_t sys_debug_disable_console(void);
 	protocol:
 		(
@@ -25,5 +25,5 @@
 interface sys_tls {
 		/* Set thread-local storage pointer (on architectures where kernel mode is required) */
-		unative_t sys_tls_set(unative_t addr);
+		sysarg_t sys_tls_set(sysarg_t addr);
 	protocol:
 		?sys_tls_set*
@@ -32,11 +32,11 @@
 interface sys_thread {
 		/* Create new thread */
-		unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, size_t name_len, thread_id_t *uspace_thread_id);
+		sysarg_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name, size_t name_len, thread_id_t *uspace_thread_id);
 		
 		/* Terminate current thread */
-		unative_t sys_thread_exit(int uspace_status);
+		sysarg_t sys_thread_exit(int uspace_status);
 		
 		/* Get current thread id */
-		unative_t sys_thread_get_id(thread_id_t *uspace_thread_id);
+		sysarg_t sys_thread_get_id(thread_id_t *uspace_thread_id);
 	protocol:
 		(
@@ -49,8 +49,8 @@
 interface sys_task {
 		/* Set name fo the current task */
-		unative_t sys_task_set_name(const char *uspace_name, size_t name_len);
+		sysarg_t sys_task_set_name(const char *uspace_name, size_t name_len);
 		
 		/* Get current task id */
-		unative_t sys_task_get_id(task_id_t *uspace_task_id);
+		sysarg_t sys_task_get_id(task_id_t *uspace_task_id);
 	protocol:
 		(
@@ -62,5 +62,5 @@
 interface sys_program {
 		/* Spawn a new instance of clonable loader service */
-		unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len);
+		sysarg_t sys_program_spawn_loader(char *uspace_name, size_t name_len);
 	protocol:
 		?sys_program_spawn_loader*
@@ -69,8 +69,8 @@
 interface sys_futex {
 		/* Sleep in a futex wait queue */
-		unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, int flags);
+		sysarg_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, int flags);
 		
 		/* Wakeup one thread waiting in futex wait queue */
-		unative_t sys_futex_wakeup(uintptr_t uaddr);
+		sysarg_t sys_futex_wakeup(uintptr_t uaddr);
 	protocol:
 		(
@@ -82,5 +82,5 @@
 interface sys_smc {
 		/* Enforce self-modifying code cache coherency */
-		unative_t sys_smc_coherence(uintptr_t va, size_t size);
+		sysarg_t sys_smc_coherence(uintptr_t va, size_t size);
 	protocol:
 		?sys_smc_coherence*
@@ -89,14 +89,14 @@
 interface sys_as {
 		/* Create new address space area */
-		unative_t sys_as_area_create(uintptr_t address, size_t size, int flags);
+		sysarg_t sys_as_area_create(uintptr_t address, size_t size, int flags);
 		
 		/* Resize an address space area */
-		unative_t sys_as_area_resize(uinptr_t address, size_t size, int flags);
+		sysarg_t sys_as_area_resize(uinptr_t address, size_t size, int flags);
 		
 		/* Change flags of an address space area */
-		unative_t sys_as_area_change_flags(uintptr_t address, int flags);
+		sysarg_t sys_as_area_change_flags(uintptr_t address, int flags);
 		
 		/* Destroy an address space area */
-		unative_t sys_as_area_destroy(uintptr_t address);
+		sysarg_t sys_as_area_destroy(uintptr_t address);
 	protocol:
 		(
@@ -110,35 +110,35 @@
 interface sys_ipc {
 		/* Fast synchronous IPC call */
-		unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method, unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data);
+		sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, ipc_data_t *data);
 		
 		/* Slow synchronous IPC call */
-		unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question, ipc_data_t *answer);
+		sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t *question, ipc_data_t *answer);
 		
 		/* Fast asynchronous IPC call */
-		unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method, unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4);
+		sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4);
 		
 		/* Slow asynchronous IPC call */
-		unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data);
+		sysarg_t sys_ipc_call_async_slow(sysarg_t phoneid, ipc_data_t *data);
 		
 		/* Fast forward a received IPC call to another destination */
-		unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid, unative_t method, unative_t arg1, unative_t arg2, int mode);
+		sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2, int mode);
 		
 		/* Slow forward a received IPC call to another destination */
-		unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid, ipc_data_t *data, int mode);
+		sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t phoneid, ipc_data_t *data, int mode);
 		
 		/* Fast answer an IPC call */
-		unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval, unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4);
+		sysarg_t sys_ipc_answer_fast(sysarg_t callid, sysarg_t retval, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4);
 		
 		/* Slow answer an IPC call */
-		unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data);
+		sysarg_t sys_ipc_answer_slow(sysarg_t callid, ipc_data_t *data);
 		
 		/* Hang up a phone */
-		unative_t sys_ipc_hangup(int phoneid);
+		sysarg_t sys_ipc_hangup(int phoneid);
 		
 		/* Wait for an incoming IPC call or answer */
-		unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, int flags);
+		sysarg_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec, int flags);
 		
 		/* Interrupt one thread of the current task from waiting on IPC call */
-		unative_t sys_ipc_poke(void);
+		sysarg_t sys_ipc_poke(void);
 	protocol:
 		(
@@ -159,5 +159,5 @@
 interface sys_event {
 		/* Subscribe to kernel event notifications */
-		unative_t sys_event_subscribe(unative_t evno, unative_t method);
+		sysarg_t sys_event_subscribe(sysarg_t evno, sysarg_t method);
 	protocol:
 		?sys_event_subscribe*
@@ -166,8 +166,20 @@
 interface sys_cap {
 		/* Grant capabilities to a task */
-		unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps);
+#ifdef __32_BITS__
+		sysarg_t sys_cap_grant(sysarg64_t *uspace_taskid, cap_t caps);
+#endif
+		
+#ifdef __64_BITS__
+		sysarg_t sys_cap_grant(sysarg_t taskid, cap_t caps);
+#endif
 		
 		/* Revoke capabilities from a task */
-		unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps);
+#ifdef __32_BITS__
+		sysarg_t sys_cap_revoke(sysarg64_t *uspace_taskid, cap_t caps);
+#endif
+		
+#ifdef __64_BITS__
+		sysarg_t sys_cap_revoke(sysarg_t taskid, cap_t caps);
+#endif
 	protocol:
 		(
@@ -179,20 +191,20 @@
 interface sys_ddi {
 		/* Enable access I/O address space for the current task */
-		unative_t sys_enable_iospace(ddi_ioarg_t *uspace_io_arg);
+		sysarg_t sys_enable_iospace(ddi_ioarg_t *uspace_io_arg);
 		
 		/* Map physical memory to the current task's address space */
-		unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base, unative_t pages, unative_t flags);
+		sysarg_t sys_physmem_map(sysarg_t phys_base, sysarg_t virt_base, sysarg_t pages, sysarg_t flags);
 		
 		/* Enable or disable preemption */
-		unative_t sys_preempt_control(int enable);
+		sysarg_t sys_preempt_control(int enable);
 		
 		/* Assign unique device number */
-		unative_t sys_device_assign_devno(void);
+		sysarg_t sys_device_assign_devno(void);
 		
 		/* Connect an IRQ handler to the current task */
-		unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method, irq_code_t *ucode);
+		sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t method, irq_code_t *ucode);
 		
 		/* Disconnect an IRQ handler from the current task */
-		unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno);
+		sysarg_t sys_ipc_unregister_irq(inr_t inr, devno_t devno);
 	protocol:
 		(
@@ -208,8 +220,8 @@
 interface sys_sysinfo {
 		/* Check for sysinfo key validity */
-		unative_t sys_sysinfo_valid(unative_t ptr, unative_t len);
+		sysarg_t sys_sysinfo_valid(sysarg_t ptr, sysarg_t len);
 		
 		/* Get sysinfo key value */
-		unative_t sys_sysinfo_value(unatice_t ptr, unative_t len);
+		sysarg_t sys_sysinfo_value(unatice_t ptr, sysarg_t len);
 	protocol:
 		(
@@ -221,5 +233,11 @@
 interface sys_debug {
 		/* Connect to the kernel debugging answerbox of a given task */
-		unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg);
+#ifdef __32_BITS__
+		sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid);
+#endif
+		
+#ifdef __64_BITS__
+		sysarg_t sys_ipc_connect_kbox(sysarg_t taskid);
+#endif
 	protocol:
 		?sys_ipc_connect_kbox*
Index: contrib/arch/uspace/srv/bd/bd.adl
===================================================================
--- contrib/arch/uspace/srv/bd/bd.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/bd/bd.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,14 +1,14 @@
 interface bd extends service {
 		/* Share out data buffer */
-		ipcarg_t ipc_m_share_out(in ipcarg_t as_area_base, in ipcarg_t as_area_size, in ipcarg_t flags, out ipcarg_t dst_as_area_base);
+		sysarg_t ipc_m_share_out(in sysarg_t as_area_base, in sysarg_t as_area_size, in sysarg_t flags, out sysarg_t dst_as_area_base);
 		
 		/* Get block size */
-		ipcarg_t get_block_size(out ipcarg_t block_size);
+		sysarg_t get_block_size(out sysarg_t block_size);
 		
 		/* Read blocks via shared data buffer */
-		ipcarg_t read_blocks(in ipcarg_t index_lower, in ipcarg_t index_upper, in ipcarg_t count);
+		sysarg_t read_blocks(in sysarg_t index_lower, in sysarg_t index_upper, in sysarg_t count);
 		
 		/* Write blocks via shared data buffer */
-		ipcarg_t write_blocks(in ipcarg_t index_lower, in ipcarg_t index_upper, in ipcarg_t count);
+		sysarg_t write_blocks(in sysarg_t index_lower, in sysarg_t index_upper, in sysarg_t count);
 	protocol:
 		[bd.bp]
Index: contrib/arch/uspace/srv/console/console.adl
===================================================================
--- contrib/arch/uspace/srv/console/console.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/console/console.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,41 +1,41 @@
 interface console extends service {
 		/* Read characters from console */
-		ipcarg_t read(out_copy stream data);
+		sysarg_t read(out_copy stream data);
 		
 		/* Write characters to console */
-		ipcarg_t write(in_copy stream data);
+		sysarg_t write(in_copy stream data);
 		
 		/* Get last event from event queue */
-		ipcarg_t get_event(out ipcarg_t type, out ipcarg_t key, out ipcarg_t mods, out ipcarg_t char);
+		sysarg_t get_event(out sysarg_t type, out sysarg_t key, out sysarg_t mods, out sysarg_t char);
 		
 		/* Flush output buffer */
-		ipcarg_t sync(void);
+		sysarg_t sync(void);
 		
 		/* Clear console */
-		ipcarg_t clear(void);
+		sysarg_t clear(void);
 		
 		/* Move cursor to given position */
-		ipcarg_t goto(in ipcarg_t col, in ipcarg_t row);
+		sysarg_t goto(in sysarg_t col, in sysarg_t row);
 		
 		/* Get console dimensions (in character cells) */
-		ipcarg_t get_size(out ipcarg_t cols, in ipcarg_t rows);
+		sysarg_t get_size(out sysarg_t cols, in sysarg_t rows);
 		
 		/* Get color capabilities */
-		ipcarg_t get_color_cap(void);
+		sysarg_t get_color_cap(void);
 		
 		/* Set abstract text style */
-		ipcarg_t set_style(in ipcarg_t style);
+		sysarg_t set_style(in sysarg_t style);
 		
 		/* Set EGA-based text color */
-		ipcarg_t set_color(in ipcarg_t fb_color, in ipcarg_t bg_color, in ipcarg_t attr);
+		sysarg_t set_color(in sysarg_t fb_color, in sysarg_t bg_color, in sysarg_t attr);
 		
 		/* Set RGB-based text color */
-		ipcarg_t set_rgb_color(in ipcarg_t fb_color, in ipcarg_t bg_color);
+		sysarg_t set_rgb_color(in sysarg_t fb_color, in sysarg_t bg_color);
 		
 		/* Set cursor visibility */
-		ipcarg_t cursor_visibility(in ipcarg_t visible);
+		sysarg_t cursor_visibility(in sysarg_t visible);
 		
 		/* Switch to kernel debugging console (if available) */
-		ipcarg_t kcon_enable(void);
+		sysarg_t kcon_enable(void);
 	protocol:
 		[console.bp]
Index: contrib/arch/uspace/srv/devmap/devmap.adl
===================================================================
--- contrib/arch/uspace/srv/devmap/devmap.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/devmap/devmap.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,26 +1,26 @@
 interface devmap_driver {
 		/* Establish connection (iface is DEVMAP_DRIVER) */
-		ipcarg_t ipc_m_connect_me_to(in ipcarg_t iface);
+		sysarg_t ipc_m_connect_me_to(in sysarg_t iface);
 		
 		/* Register as a new driver */
-		ipcarg_t driver_register(in_copy string name);
+		sysarg_t driver_register(in_copy string name);
 		
 		/* Unregister all devices and the driver itself */
-		ipcarg_t driver_unregister(void);
+		sysarg_t driver_unregister(void);
 		
 		/* Register new device and return handle */
-		ipcarg_t device_register(in_copy string name, out ipcarg_t handle);
+		sysarg_t device_register(in_copy string name, out sysarg_t handle);
 		
 		/* Unregister device */
-		ipcarg_t device_unregister(in ipcarg_t handle);
+		sysarg_t device_unregister(in sysarg_t handle);
 		
 		/* Resolve device name to handle */
-		ipcarg_t device_get_handle(in ipcarg_t flags, in_copy string name);
+		sysarg_t device_get_handle(in sysarg_t flags, in_copy string name);
 		
 		/* Get device name for a given handle */
-		ipcarg_t device_get_name(in ipcarg_t handle);
+		sysarg_t device_get_name(in sysarg_t handle);
 		
 		/* Close connection */
-		ipcarg_t ipc_m_phone_hungup(void);
+		sysarg_t ipc_m_phone_hungup(void);
 	protocol:
 		[devmap_driver.bp]
@@ -29,26 +29,26 @@
 interface devmap_client {
 		/* Establish connection (iface is DEVMAP_CLIENT) or forward to device (iface is DEVMAP_CONNECT_TO_DEVICE) */
-		ipcarg_t ipc_m_connect_me_to(in ipcarg_t iface, in ipcarg_t handle);
+		sysarg_t ipc_m_connect_me_to(in sysarg_t iface, in sysarg_t handle);
 		
 		/* Resolve device name to handle */
-		ipcarg_t device_get_handle(in ipcarg_t flags, in_copy string name);
+		sysarg_t device_get_handle(in sysarg_t flags, in_copy string name);
 		
 		/* Get device name for a given handle */
-		ipcarg_t device_get_name(in ipcarg_t handle);
+		sysarg_t device_get_name(in sysarg_t handle);
 		
 		/* Clone NULL device */
-		ipcarg_t device_null_create(out ipcarg_t index);
+		sysarg_t device_null_create(out sysarg_t index);
 		
 		/* Destroy NULL device */
-		ipcarg_t device_null_destroy(in ipcarg_t index);
+		sysarg_t device_null_destroy(in sysarg_t index);
 		
 		/* Get number of devices */
-		ipcarg_t device_get_count(out ipcarg_t count);
+		sysarg_t device_get_count(out sysarg_t count);
 		
 		/* Get an array of (device_name, handle) pairs */
-		ipcarg_t device_get_devices(out_copy stream data);
+		sysarg_t device_get_devices(out_copy stream data);
 		
 		/* Close connection */
-		ipcarg_t ipc_m_phone_hungup(void);
+		sysarg_t ipc_m_phone_hungup(void);
 	protocol:
 		[devmap_client.bp]
Index: contrib/arch/uspace/srv/fb/fb.adl
===================================================================
--- contrib/arch/uspace/srv/fb/fb.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/fb/fb.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,98 +1,98 @@
 interface fb extends service {
 		/* Get screen resolution */
-		ipcarg_t get_resolution(out ipcarg_t width, out ipcarg_t height);
+		sysarg_t get_resolution(out sysarg_t width, out sysarg_t height);
 		
 		/* Yield screen */
-		ipcarg_t screen_yield(void);
+		sysarg_t screen_yield(void);
 		
 		/* Reclaim screen */
-		ipcarg_t screen_reclaim(void);
+		sysarg_t screen_reclaim(void);
 		
 		/* Set mouse cursor position on screen */
-		ipcarg_t pointer_move(in ipcarg_t x, in ipcarg_t y);
+		sysarg_t pointer_move(in sysarg_t x, in sysarg_t y);
 		
 		/* Create new viewport */
-		ipcarg_t viewport_create(in ipcarg_t origin, in ipcarg_t dimension);
+		sysarg_t viewport_create(in sysarg_t origin, in sysarg_t dimension);
 		
 		/* Get viewport size in character cells */
-		ipcarg_t get_csize(out ipcarg_t width, out ipcarg_t height);
+		sysarg_t get_csize(out sysarg_t width, out sysarg_t height);
 		
 		/* Clear viewport character buffer */
-		ipcarg_t clear(void);
+		sysarg_t clear(void);
 		
 		/* Scroll viewport character buffer */
-		ipcarg_t scroll(in ipcarg_t lines);
+		sysarg_t scroll(in sysarg_t lines);
 		
 		/* Set active viewport */
-		ipcarg_t viewport_switch(in ipcarg_t index);
+		sysarg_t viewport_switch(in sysarg_t index);
 		
 		/* Delete viewport */
-		ipcarg_t viewport_delete(in ipcarg_t index);
+		sysarg_t viewport_delete(in sysarg_t index);
 		
 		/* Get color capabilities of the screen */
-		ipcarg_t get_color_cap(void);
+		sysarg_t get_color_cap(void);
 		
 		/* Set abstract text style */
-		ipcarg_t set_style(in ipcarg_t style);
+		sysarg_t set_style(in sysarg_t style);
 		
 		/* Set EGA-based text color */
-		ipcarg_t set_color(in ipcarg_t fg_color, in ipcarg_t bg_color, in ipcarg_t atrr);
+		sysarg_t set_color(in sysarg_t fg_color, in sysarg_t bg_color, in sysarg_t atrr);
 		
 		/* Set RGB-based text color */
-		ipcarg_t set_rgb_color(in ipcarg_t fg_color, in ipcarg_t bg_color);
+		sysarg_t set_rgb_color(in sysarg_t fg_color, in sysarg_t bg_color);
 		
 		/* Put a character to a given position in viewport character buffer */
-		ipcarg_t putchar(in ipcarg_t char, in ipcarg_t col, in ipcarg_t row);
+		sysarg_t putchar(in sysarg_t char, in sysarg_t col, in sysarg_t row);
 		
 		/* Set character cursor visibility in viewport */
-		ipcarg_t cursor_visibility(in ipcarg_t visible);
+		sysarg_t cursor_visibility(in sysarg_t visible);
 		
 		/* Set character cursor position in viewport */
-		ipcarg_t cursor_goto(in ipcarg_t col, in ipcarg_t row);
+		sysarg_t cursor_goto(in sysarg_t col, in sysarg_t row);
 		
 		/* Prepare memory sharing of bitmaps */
-		ipcarg_t prepare_shm(in ipcarg_t as_area_base);
+		sysarg_t prepare_shm(in sysarg_t as_area_base);
 		
 		/* Share bitmap or text data */
-		ipcarg_t ipc_m_share_out(in ipcarg_t as_area_base, in ipcarg_t as_area_size, out ipcarg_t dst_as_area);
+		sysarg_t ipc_m_share_out(in sysarg_t as_area_base, in sysarg_t as_area_size, out sysarg_t dst_as_area);
 		
 		/* Drop memory sharing */
-		ipcarg_t drop_shm(void);
+		sysarg_t drop_shm(void);
 		
 		/* Draw PPM data from shared memory to viewport */
-		ipcarg_t draw_ppm(in ipcarg_t x, in ipcarg_t y);
+		sysarg_t draw_ppm(in sysarg_t x, in sysarg_t y);
 		
 		/* Put characters from shared memory to viewport */
-		ipcarg_t draw_text_data(in ipcarg_t x, in ipcarg_t y, in ipcarg_t width, in ipcarg_t height);
+		sysarg_t draw_text_data(in sysarg_t x, in sysarg_t y, in sysarg_t width, in sysarg_t height);
 		
 		/* Convert PPM data from shared memory to pixmap */
-		ipcarg_t shm2pixmap(void);
+		sysarg_t shm2pixmap(void);
 		
 		/* Save viewport contents to a pixmap */
-		ipcarg_t vp2pixmap(in ipcarg_t vp_index);
+		sysarg_t vp2pixmap(in sysarg_t vp_index);
 		
 		/* Draw pixmap to viewport */
-		ipcarg_t vp_draw_pixmap(in ipcarg_t vp_index, in ipcarg_t pm_index);
+		sysarg_t vp_draw_pixmap(in sysarg_t vp_index, in sysarg_t pm_index);
 		
 		/* Discard pixmap */
-		ipcarg_t drop_pixmap(in ipcarg_t pm_index);
+		sysarg_t drop_pixmap(in sysarg_t pm_index);
 		
 		/* Create new (empty) animation for a viewport */
-		ipcarg_t anim_create(in ipcarg_t vp_index);
+		sysarg_t anim_create(in sysarg_t vp_index);
 		
 		/* Append a pixmap to an animation */
-		ipcarg_t anim_addpixmap(in ipcarg_t anim_index, in ipcarg_t pm_index);
+		sysarg_t anim_addpixmap(in sysarg_t anim_index, in sysarg_t pm_index);
 		
 		/* Change a viewport associated with an animation */
-		ipcarg_t anim_chgvp(in ipcarg_t anim_index, in ipcarg_t vp_index);
+		sysarg_t anim_chgvp(in sysarg_t anim_index, in sysarg_t vp_index);
 		
 		/* Start animation playback */
-		ipcarg_t anim_start(in ipcarg_t anim_index);
+		sysarg_t anim_start(in sysarg_t anim_index);
 		
 		/* Stop animation playback */
-		ipcarg_t anim_stop(in ipcarg_t anim_index);
+		sysarg_t anim_stop(in sysarg_t anim_index);
 		
 		/* Delete animation */
-		ipcarg_t anim_drop(in ipcarg_t anim_index);
+		sysarg_t anim_drop(in sysarg_t anim_index);
 	protocol:
 		[fb.bp]
Index: contrib/arch/uspace/srv/kbd/kbd.adl
===================================================================
--- contrib/arch/uspace/srv/kbd/kbd.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/kbd/kbd.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,11 +1,11 @@
 interface kbd extends service {
 		/* Callback connection */
-		ipcarg_t ipc_m_connect_to_me(void);
+		sysarg_t ipc_m_connect_to_me(void);
 		
 		/* Yield hardware */
-		ipcarg_t yield(void);
+		sysarg_t yield(void);
 		
 		/* Reclaim hardware */
-		ipcarg_t reclaim(void);
+		sysarg_t reclaim(void);
 	protocol:
 		[kbd.bp]
@@ -14,5 +14,5 @@
 interface event {
 		/* Send keyboard event */
-		ipcarg_t event(in ipcarg_t type, in ipcarg_t key, in ipcarg_t mods, in ipcarg_t char);
+		sysarg_t event(in sysarg_t type, in sysarg_t key, in sysarg_t mods, in sysarg_t char);
 	protocol:
 		[event.bp]
Index: contrib/arch/uspace/srv/loader/loader.adl
===================================================================
--- contrib/arch/uspace/srv/loader/loader.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/loader/loader.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,20 +1,20 @@
 interface loader extends service {
 		/* Set task pathname */
-		ipcarg_t set_pathname(in_copy string pathname);
+		sysarg_t set_pathname(in_copy string pathname);
 		
 		/* Set task arguments */
-		ipcarg_t set_args(in_copy stream args);
+		sysarg_t set_args(in_copy stream args);
 		
 		/* Set task initial files */
-		ipcarg_t set_files(in_copy stream files);
+		sysarg_t set_files(in_copy stream files);
 		
 		/* Get task ID */
-		ipcarg_t get_taskid(out_copy stream id);
+		sysarg_t get_taskid(out_copy stream id);
 		
 		/* Load binary */
-		ipcarg_t load(void);
+		sysarg_t load(void);
 		
 		/* Run binary */
-		ipcarg_t run(void);
+		sysarg_t run(void);
 	protocol:
 		[loader.bp]
Index: contrib/arch/uspace/srv/ns/ns.adl
===================================================================
--- contrib/arch/uspace/srv/ns/ns.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/ns/ns.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,26 +1,26 @@
 interface ns {
 		/* Register a clonable service or a generic service */
-		ipcarg_t ipc_m_connect_to_me(in ipcarg_t service);
+		sysarg_t ipc_m_connect_to_me(in sysarg_t service);
 		
 		/* Connect to a clonable service or a generic service */
-		ipcarg_t ipc_m_connect_me_to(in ipcarg_t service, in ipcarg_t arg2, in ipcarg_t arg3, in ipcarg_t flags);
+		sysarg_t ipc_m_connect_me_to(in sysarg_t service, in sysarg_t arg2, in sysarg_t arg3, in sysarg_t flags);
 		
 		/* Share real-time clock page or klog page */
-		ipcarg_t ipc_m_share_in(in ipcarg_t as_area_base, in ipcarg_t as_area_size, in ipcarg_t service);
+		sysarg_t ipc_m_share_in(in sysarg_t as_area_base, in sysarg_t as_area_size, in sysarg_t service);
 		
 		/* For IPC testing purposes */
-		ipcarg_t ping(void);
+		sysarg_t ping(void);
 		
 		/* Wait for task exit and get exit status and return value */
-		ipcarg_t task_wait(in ipcarg_t id_lower, in ipcarg_t id_upper, out ipcarg_t status, out ipcarg_t retval);
+		sysarg_t task_wait(in sysarg_t id_lower, in sysarg_t id_upper, out sysarg_t status, out sysarg_t retval);
 		
 		/* Introduce a new loader task id in such a way it cannot be spoofed */
-		ipcarg_t id_intro(in ipcarg_t id_lower, in ipcarg_t id_upper);
+		sysarg_t id_intro(in sysarg_t id_lower, in sysarg_t id_upper);
 		
 		/* Set task return value */
-		ipcarg_t retval(in ipcarg_t retval);
+		sysarg_t retval(in sysarg_t retval);
 		
 		/* Implicit connection close */
-		ipcarg_t ipc_m_phone_hungup(void);
+		sysarg_t ipc_m_phone_hungup(void);
 	protocol:
 		[ns.bp]
Index: contrib/arch/uspace/srv/ns/service.adl
===================================================================
--- contrib/arch/uspace/srv/ns/service.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/ns/service.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -2,7 +2,7 @@
 		/* Establish connection with the service
 		   (this call is forwarded from Naming Service or Device Mapper) */
-		ipcarg_t ipc_m_connect_me_to(void);
+		sysarg_t ipc_m_connect_me_to(void);
 		
 		/* Close connection */
-		ipcarg_t ipc_m_phone_hungup(void);
+		sysarg_t ipc_m_phone_hungup(void);
 };
Index: contrib/arch/uspace/srv/vfs/vfs.adl
===================================================================
--- contrib/arch/uspace/srv/vfs/vfs.adl	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/arch/uspace/srv/vfs/vfs.adl	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,50 +1,50 @@
 interface vfs extends service {
 		/* Register a filesystem driver */
-		ipcarg_t register(in_copy string name);
+		sysarg_t register(in_copy string name);
 		
 		/* Mount filesystem */
-		ipcarg_t mount(in ipcarg_t device, in ipcarg_t flags, in_copy string point, in_copy string opts, in_copy string fs);
+		sysarg_t mount(in sysarg_t device, in sysarg_t flags, in_copy string point, in_copy string opts, in_copy string fs);
 		
 		/* Open file */
-		ipcarg_t open(in ipcarg_t lflag, in ipcarg_t oflag, in ipcarg_t mode, in_copy string path, out ipcarg_t fd);
+		sysarg_t open(in sysarg_t lflag, in sysarg_t oflag, in sysarg_t mode, in_copy string path, out sysarg_t fd);
 		
 		/* Open file using node */
-		ipcarg_t open_node(in ipcarg_t fs_handle, in ipcarg_t dev_handle, in ipcarg_t index, in ipcarg_t oflag, out ipcarg_t fd);
+		sysarg_t open_node(in sysarg_t fs_handle, in sysarg_t dev_handle, in sysarg_t index, in sysarg_t oflag, out sysarg_t fd);
 		
 		/* Read data from file */
-		ipcarg_t read(in ipcarg_t fd, out_copy stream data);
+		sysarg_t read(in sysarg_t fd, out_copy stream data);
 		
 		/* Write data to file */
-		ipcarg_t write(in ipcarg_t fd, in_copy stream data);
+		sysarg_t write(in sysarg_t fd, in_copy stream data);
 		
 		/* Seek in file */
-		ipcarg_t seek(in ipcarg_t fd, in ipcarg_t offset, in ipcarg_t whence);
+		sysarg_t seek(in sysarg_t fd, in sysarg_t offset, in sysarg_t whence);
 		
 		/* Truncate file */
-		ipcarg_t truncate(in ipcarg_t fd, in ipcarg_t size);
+		sysarg_t truncate(in sysarg_t fd, in sysarg_t size);
 		
 		/* Get file metadata */
-		ipcarg_t fstat(in ipcarg_t fd, out_copy stream stat);
+		sysarg_t fstat(in sysarg_t fd, out_copy stream stat);
 		
 		/* Get directory entry metadata */
-		ipcarg_t stat(in_copy string path, out_copy stream stat);
+		sysarg_t stat(in_copy string path, out_copy stream stat);
 		
 		/* Create directory */
-		ipcarg_t mkdir(in ipcarg_t mode, in_copy string path);
+		sysarg_t mkdir(in sysarg_t mode, in_copy string path);
 		
 		/* Delete directory entry */
-		ipcarg_t unlink(in ipcarg_t lflag, in_copy string path);
+		sysarg_t unlink(in sysarg_t lflag, in_copy string path);
 		
 		/* Rename directory entry */
-		ipcarg_t rename(in_copy string old, in_copy string new);
+		sysarg_t rename(in_copy string old, in_copy string new);
 		
 		/* Flush file buffers */
-		ipcarg_t sync(in ipcarg_t fd);
+		sysarg_t sync(in sysarg_t fd);
 		
 		/* In-protocol status value */
-		ipcarg_t ipc_m_ping(void);
+		sysarg_t ipc_m_ping(void);
 		
 		/* Close connection */
-		ipcarg_t ipc_m_phone_hungup(void);
+		sysarg_t ipc_m_phone_hungup(void);
 	protocol:
 		[vfs.bp]
@@ -53,32 +53,32 @@
 interface fs extends service {
 		/* Notify filesystem that it was mounted */
-		ipcarg_t mounted(in ipcarg_t dev_handle, in_copy string opts);
+		sysarg_t mounted(in sysarg_t dev_handle, in_copy string opts);
 		
 		/* Mount filesystem */
-		ipcarg_t mount(in ipcarg_t device, in ipcarg_t flags, in_copy string point, in_copy string opts, ...);
+		sysarg_t mount(in sysarg_t device, in sysarg_t flags, in_copy string point, in_copy string opts, ...);
 		
 		/* Open file by node */
-		ipcarg_t open_node(in ipcarg_t lflag, in ipcarg_t oflag, in ipcarg_t mode, ...);
+		sysarg_t open_node(in sysarg_t lflag, in sysarg_t oflag, in sysarg_t mode, ...);
 		
 		/* Lookup file */
-		ipcarg_t lookup(in ipcarg_t lflag, in ipcarg_t oflag, in ipcarg_t mode, ...);
+		sysarg_t lookup(in sysarg_t lflag, in sysarg_t oflag, in sysarg_t mode, ...);
 		
 		/* Read data from file */
-		ipcarg_t read(in ipcarg_t dev_handle, in ipcarg_t fs_index, in ipcarg_t offset, out_copy stream data);
+		sysarg_t read(in sysarg_t dev_handle, in sysarg_t fs_index, in sysarg_t offset, out_copy stream data);
 		
 		/* Write data to file */
-		ipcarg_t write(in ipcarg_t dev_handle, in ipcarg_t fs_index, in ipcarg_t offset, in_copy stream data);
+		sysarg_t write(in sysarg_t dev_handle, in sysarg_t fs_index, in sysarg_t offset, in_copy stream data);
 		
 		/* Truncate file */
-		ipcarg_t truncate(in ipcarg_t dev_handle, in ipcarg_t fs_index, in ipcarg_t size);
+		sysarg_t truncate(in sysarg_t dev_handle, in sysarg_t fs_index, in sysarg_t size);
 		
 		/* Get directory entry metadata */
-		ipcarg_t stat(in ipcarg_t dev_handle, in ipcarg_t fs_index, out_copy stream stat);
+		sysarg_t stat(in sysarg_t dev_handle, in sysarg_t fs_index, out_copy stream stat);
 		
 		/* Flush file buffers */
-		ipcarg_t sync(in ipcarg_t dev_handle, in ipcarg_t fs_index);
+		sysarg_t sync(in sysarg_t dev_handle, in sysarg_t fs_index);
 		
 		/* Notify on file close */
-		ipcarg_t close(in ipcarg_t dev_handle, in ipcarg_t fs_index);
+		sysarg_t close(in sysarg_t dev_handle, in sysarg_t fs_index);
 };
 
Index: contrib/highlight/adl.syntax
===================================================================
--- contrib/highlight/adl.syntax	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ contrib/highlight/adl.syntax	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -17,5 +17,5 @@
 	keyword whole delegate yellow
 	
-	keyword whole ipcarg_t yellow
+	keyword whole sysarg_t yellow
 	keyword whole string yellow
 	keyword whole stream yellow
Index: kernel/arch/abs32le/include/types.h
===================================================================
--- kernel/arch/abs32le/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/abs32le/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -46,5 +46,5 @@
 typedef uint32_t ipl_t;
 
-typedef uint32_t unative_t;
+typedef uint32_t sysarg_t;
 typedef int32_t native_t;
 typedef uint32_t atomic_count_t;
@@ -57,6 +57,6 @@
 
 #define PRIdn  PRId32  /**< Format for native_t. */
-#define PRIun  PRIu32  /**< Format for unative_t. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: kernel/arch/abs32le/src/abs32le.c
===================================================================
--- kernel/arch/abs32le/src/abs32le.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/abs32le/src/abs32le.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -86,5 +86,5 @@
 }
 
-unative_t sys_tls_set(unative_t addr)
+sysarg_t sys_tls_set(sysarg_t addr)
 {
 	return EOK;
Index: kernel/arch/amd64/include/asm.h
===================================================================
--- kernel/arch/amd64/include/asm.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/amd64/include/asm.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -304,5 +304,5 @@
 }
 
-NO_TRACE static inline unative_t read_msr(uint32_t msr)
+NO_TRACE static inline sysarg_t read_msr(uint32_t msr)
 {
 	uint32_t ax, dx;
@@ -343,5 +343,5 @@
 	asm volatile (
 		"invlpg %[addr]\n"
-		:: [addr] "m" (*((unative_t *) addr))
+		:: [addr] "m" (*((sysarg_t *) addr))
 	);
 }
@@ -398,7 +398,7 @@
 }
 
-#define GEN_READ_REG(reg) NO_TRACE static inline unative_t read_ ##reg (void) \
+#define GEN_READ_REG(reg) NO_TRACE static inline sysarg_t read_ ##reg (void) \
 	{ \
-		unative_t res; \
+		sysarg_t res; \
 		asm volatile ( \
 			"movq %%" #reg ", %[res]" \
@@ -408,5 +408,5 @@
 	}
 
-#define GEN_WRITE_REG(reg) NO_TRACE static inline void write_ ##reg (unative_t regn) \
+#define GEN_WRITE_REG(reg) NO_TRACE static inline void write_ ##reg (sysarg_t regn) \
 	{ \
 		asm volatile ( \
Index: kernel/arch/amd64/include/proc/thread.h
===================================================================
--- kernel/arch/amd64/include/proc/thread.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/amd64/include/proc/thread.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -41,5 +41,5 @@
 
 typedef struct {
-	unative_t tls;
+	sysarg_t tls;
 	/** User and kernel RSP for syscalls. */
 	uint64_t syscall_rsp[2];
Index: kernel/arch/amd64/include/types.h
===================================================================
--- kernel/arch/amd64/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/amd64/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -43,5 +43,5 @@
 typedef uint64_t ipl_t;
 
-typedef uint64_t unative_t;
+typedef uint64_t sysarg_t;
 typedef int64_t native_t;
 typedef uint64_t atomic_count_t;
@@ -54,6 +54,6 @@
 
 #define PRIdn  PRId64  /**< Format for native_t. */
-#define PRIun  PRIu64  /**< Format for unative_t. */
-#define PRIxn  PRIx64  /**< Format for hexadecimal unative_t. */
+#define PRIun  PRIu64  /**< Format for sysarg_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
Index: kernel/arch/amd64/src/amd64.c
===================================================================
--- kernel/arch/amd64/src/amd64.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/amd64/src/amd64.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -256,5 +256,5 @@
  * we need not to go to CPL0 to read it.
  */
-unative_t sys_tls_set(unative_t addr)
+sysarg_t sys_tls_set(sysarg_t addr)
 {
 	THREAD->arch.tls = addr;
Index: kernel/arch/amd64/src/debugger.c
===================================================================
--- kernel/arch/amd64/src/debugger.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/amd64/src/debugger.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -125,5 +125,5 @@
 	
 	/* Disable breakpoint in DR7 */
-	unative_t dr7 = read_dr7();
+	sysarg_t dr7 = read_dr7();
 	dr7 &= ~(0x02U << (curidx * 2));
 	
@@ -152,15 +152,15 @@
 		if (!(flags & BKPOINT_INSTR)) {
 #ifdef __32_BITS__
-			dr7 |= ((unative_t) 0x03U) << (18 + 4 * curidx);
+			dr7 |= ((sysarg_t) 0x03U) << (18 + 4 * curidx);
 #endif
 			
 #ifdef __64_BITS__
-			dr7 |= ((unative_t) 0x02U) << (18 + 4 * curidx);
+			dr7 |= ((sysarg_t) 0x02U) << (18 + 4 * curidx);
 #endif
 			
 			if ((flags & BKPOINT_WRITE))
-				dr7 |= ((unative_t) 0x01U) << (16 + 4 * curidx);
+				dr7 |= ((sysarg_t) 0x01U) << (16 + 4 * curidx);
 			else if ((flags & BKPOINT_READ_WRITE))
-				dr7 |= ((unative_t) 0x03U) << (16 + 4 * curidx);
+				dr7 |= ((sysarg_t) 0x03U) << (16 + 4 * curidx);
 		}
 		
@@ -227,5 +227,5 @@
 	if (!(breakpoints[slot].flags & BKPOINT_INSTR)) {
 		if ((breakpoints[slot].flags & BKPOINT_CHECK_ZERO)) {
-			if (*((unative_t *) breakpoints[slot].address) != 0)
+			if (*((sysarg_t *) breakpoints[slot].address) != 0)
 				return;
 			
@@ -234,5 +234,5 @@
 		} else {
 			printf("Data watchpoint - new data: %#" PRIxn "\n",
-			    *((unative_t *) breakpoints[slot].address));
+			    *((sysarg_t *) breakpoints[slot].address));
 		}
 	}
@@ -279,5 +279,5 @@
 #endif
 	
-	unative_t dr6 = read_dr6();
+	sysarg_t dr6 = read_dr6();
 	
 	unsigned int i;
@@ -384,5 +384,5 @@
 int cmd_del_breakpoint(cmd_arg_t *argv)
 {
-	unative_t bpno = argv->intval;
+	sysarg_t bpno = argv->intval;
 	if (bpno > BKPOINTS_MAX) {
 		printf("Invalid breakpoint number.\n");
Index: kernel/arch/arm32/include/types.h
===================================================================
--- kernel/arch/arm32/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/arm32/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -50,5 +50,5 @@
 typedef uint32_t ipl_t;
 
-typedef uint32_t unative_t;
+typedef uint32_t sysarg_t;
 typedef int32_t native_t;
 typedef uint32_t atomic_count_t;
@@ -61,6 +61,6 @@
 
 #define PRIdn  PRId32  /**< Format for native_t. */
-#define PRIun  PRIu32  /**< Format for unative_t. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: kernel/arch/arm32/src/mach/testarm/testarm.c
===================================================================
--- kernel/arch/arm32/src/mach/testarm/testarm.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/arm32/src/mach/testarm/testarm.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -123,5 +123,5 @@
 	sysinfo_set_item_val("kbd", NULL, true);
 	sysinfo_set_item_val("kbd.inr", NULL, GXEMUL_KBD_IRQ);
-	sysinfo_set_item_val("kbd.address.virtual", NULL, (unative_t) gxemul_kbd);
+	sysinfo_set_item_val("kbd.address.virtual", NULL, (sysarg_t) gxemul_kbd);
 #endif
 }
Index: kernel/arch/ia32/include/asm.h
===================================================================
--- kernel/arch/ia32/include/asm.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ia32/include/asm.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -64,7 +64,7 @@
 }
 
-#define GEN_READ_REG(reg) NO_TRACE static inline unative_t read_ ##reg (void) \
+#define GEN_READ_REG(reg) NO_TRACE static inline sysarg_t read_ ##reg (void) \
 	{ \
-		unative_t res; \
+		sysarg_t res; \
 		asm volatile ( \
 			"movl %%" #reg ", %[res]" \
@@ -74,5 +74,5 @@
 	}
 
-#define GEN_WRITE_REG(reg) NO_TRACE static inline void write_ ##reg (unative_t regn) \
+#define GEN_WRITE_REG(reg) NO_TRACE static inline void write_ ##reg (sysarg_t regn) \
 	{ \
 		asm volatile ( \
@@ -366,5 +366,5 @@
 	asm volatile (
 		"invlpg %[addr]\n"
-		:: [addr] "m" (*(unative_t *) addr)
+		:: [addr] "m" (*(sysarg_t *) addr)
 	);
 }
Index: kernel/arch/ia32/include/proc/thread.h
===================================================================
--- kernel/arch/ia32/include/proc/thread.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ia32/include/proc/thread.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -39,5 +39,5 @@
 
 typedef struct {
-	unative_t tls;
+	sysarg_t tls;
 } thread_arch_t;
 
Index: kernel/arch/ia32/include/types.h
===================================================================
--- kernel/arch/ia32/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ia32/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -43,5 +43,5 @@
 typedef uint32_t ipl_t;
 
-typedef uint32_t unative_t;
+typedef uint32_t sysarg_t;
 typedef int32_t native_t;
 typedef uint32_t atomic_count_t;
@@ -54,6 +54,6 @@
 
 #define PRIdn  PRId32  /**< Format for native_t. */
-#define PRIun  PRIu32  /**< Format for unative_t. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: kernel/arch/ia32/src/ia32.c
===================================================================
--- kernel/arch/ia32/src/ia32.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ia32/src/ia32.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -211,5 +211,5 @@
  * selector, and the descriptor->base is the correct address.
  */
-unative_t sys_tls_set(unative_t addr)
+sysarg_t sys_tls_set(sysarg_t addr)
 {
 	THREAD->arch.tls = addr;
Index: kernel/arch/ia64/include/bootinfo.h
===================================================================
--- kernel/arch/ia64/include/bootinfo.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ia64/include/bootinfo.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -62,5 +62,5 @@
 	unsigned int memmap_items;
 	
-	unative_t *sapic;
+	sysarg_t *sapic;
 	unsigned long sys_freq;
 	unsigned long freq_scale;
Index: kernel/arch/ia64/include/types.h
===================================================================
--- kernel/arch/ia64/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ia64/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -43,11 +43,11 @@
 typedef uint64_t ipl_t;
 
-typedef uint64_t unative_t;
+typedef uint64_t sysarg_t;
 typedef int64_t native_t;
 typedef uint64_t atomic_count_t;
 
 typedef struct {
-	unative_t fnc;
-	unative_t gp;
+	sysarg_t fnc;
+	sysarg_t gp;
 } __attribute__((may_alias)) fncptr_t;
 
@@ -56,6 +56,6 @@
 
 #define PRIdn  PRId64  /**< Format for native_t. */
-#define PRIun  PRIu64  /**< Format for unative_t. */
-#define PRIxn  PRIx64  /**< Format for hexadecimal unative_t. */
+#define PRIun  PRIu64  /**< Format for sysarg_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
Index: kernel/arch/ia64/src/ia64.c
===================================================================
--- kernel/arch/ia64/src/ia64.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ia64/src/ia64.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -104,5 +104,5 @@
 static void iosapic_init(void)
 {
-	uint64_t IOSAPIC = PA2KA((unative_t)(iosapic_base)) | FW_OFFSET;
+	uint64_t IOSAPIC = PA2KA((sysarg_t)(iosapic_base)) | FW_OFFSET;
 	int i;
 	
@@ -251,5 +251,5 @@
  * We use r13 (a.k.a. tp) for this purpose.
  */
-unative_t sys_tls_set(unative_t addr)
+sysarg_t sys_tls_set(sysarg_t addr)
 {
 	return 0;
@@ -274,6 +274,6 @@
 void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller)
 {
-	fptr->fnc = (unative_t) addr;
-	fptr->gp = ((unative_t *) caller)[1];
+	fptr->fnc = (sysarg_t) addr;
+	fptr->gp = ((sysarg_t *) caller)[1];
 	
 	return (void *) fptr;
Index: kernel/arch/mips32/include/debugger.h
===================================================================
--- kernel/arch/mips32/include/debugger.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/mips32/include/debugger.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -58,8 +58,8 @@
 
 typedef struct  {
-	uintptr_t address;          /**< Breakpoint address */
-	unative_t instruction;      /**< Original instruction */
-	unative_t nextinstruction;  /**< Original instruction following break */
-	unsigned int flags;         /**< Flags regarding breakpoint */
+	uintptr_t address;         /**< Breakpoint address */
+	sysarg_t instruction;      /**< Original instruction */
+	sysarg_t nextinstruction;  /**< Original instruction following break */
+	unsigned int flags;        /**< Flags regarding breakpoint */
 	size_t counter;
 	void (*bkfunc)(void *, istate_t *);
@@ -68,5 +68,5 @@
 extern bpinfo_t breakpoints[BKPOINTS_MAX];
 
-extern bool is_jump(unative_t);
+extern bool is_jump(sysarg_t);
 
 extern void debugger_init(void);
Index: kernel/arch/mips32/include/fpu_context.h
===================================================================
--- kernel/arch/mips32/include/fpu_context.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/mips32/include/fpu_context.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -38,9 +38,9 @@
 #include <typedefs.h>
 
-#define FPU_CONTEXT_ALIGN    sizeof(unative_t)
+#define FPU_CONTEXT_ALIGN    sizeof(sysarg_t)
 
 typedef struct {
-	unative_t dregs[32];
-	unative_t cregs[32];
+	sysarg_t dregs[32];
+	sysarg_t cregs[32];
 } fpu_context_t;
 
Index: kernel/arch/mips32/include/types.h
===================================================================
--- kernel/arch/mips32/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/mips32/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -43,5 +43,5 @@
 typedef uint32_t ipl_t;
 
-typedef uint32_t unative_t;
+typedef uint32_t sysarg_t;
 typedef int32_t native_t;
 typedef uint32_t atomic_count_t;
@@ -54,6 +54,6 @@
 
 #define PRIdn  PRId32  /**< Format for native_t. */
-#define PRIun  PRIu32  /**< Format for unative_t. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: kernel/arch/mips32/src/debugger.c
===================================================================
--- kernel/arch/mips32/src/debugger.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/mips32/src/debugger.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -134,5 +134,5 @@
  *
  */
-bool is_jump(unative_t instr)
+bool is_jump(sysarg_t instr)
 {
 	unsigned int i;
@@ -166,6 +166,6 @@
 			return 0;
 		} else if ((breakpoints[i].address == (uintptr_t) argv->intval +
-		    sizeof(unative_t)) || (breakpoints[i].address ==
-		    (uintptr_t) argv->intval - sizeof(unative_t))) {
+		    sizeof(sysarg_t)) || (breakpoints[i].address ==
+		    (uintptr_t) argv->intval - sizeof(sysarg_t))) {
 			printf("Adjacent breakpoints not supported, conflict "
 			    "with %d.\n", i);
@@ -194,6 +194,6 @@
 	
 	cur->address = (uintptr_t) argv->intval;
-	cur->instruction = ((unative_t *) cur->address)[0];
-	cur->nextinstruction = ((unative_t *) cur->address)[1];
+	cur->instruction = ((sysarg_t *) cur->address)[0];
+	cur->nextinstruction = ((sysarg_t *) cur->address)[1];
 	if (argv == &add_argv) {
 		cur->flags = 0;
@@ -209,5 +209,5 @@
 	
 	/* Set breakpoint */
-	*((unative_t *) cur->address) = 0x0d;
+	*((sysarg_t *) cur->address) = 0x0d;
 	smc_coherence(cur->address);
 	
@@ -341,5 +341,5 @@
 		/* Reinst only breakpoint */
 		if ((breakpoints[i].flags & BKPOINT_REINST) &&
-		    (fireaddr == breakpoints[i].address + sizeof(unative_t))) {
+		    (fireaddr == breakpoints[i].address + sizeof(sysarg_t))) {
 			cur = &breakpoints[i];
 			break;
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/mips32/src/mips32.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -233,5 +233,5 @@
  * possible to have it separately in the future.
  */
-unative_t sys_tls_set(unative_t addr)
+sysarg_t sys_tls_set(sysarg_t addr)
 {
 	return 0;
Index: kernel/arch/ppc32/include/exception.h
===================================================================
--- kernel/arch/ppc32/include/exception.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ppc32/include/exception.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -98,10 +98,10 @@
 }
 
-NO_TRACE static inline unative_t istate_get_pc(istate_t *istate)
+NO_TRACE static inline sysarg_t istate_get_pc(istate_t *istate)
 {
 	return istate->pc;
 }
 
-NO_TRACE static inline unative_t istate_get_fp(istate_t *istate)
+NO_TRACE static inline sysarg_t istate_get_fp(istate_t *istate)
 {
 	return istate->sp;
Index: kernel/arch/ppc32/include/types.h
===================================================================
--- kernel/arch/ppc32/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/ppc32/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -43,5 +43,5 @@
 typedef uint32_t ipl_t;
 
-typedef uint32_t unative_t;
+typedef uint32_t sysarg_t;
 typedef int32_t native_t;
 typedef uint32_t atomic_count_t;
@@ -54,6 +54,6 @@
 
 #define PRIdn  PRId32  /**< Format for native_t. */
-#define PRIun  PRIu32  /**< Format for unative_t. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal unative_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: kernel/arch/sparc64/include/mm/sun4u/tlb.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4u/tlb.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/sparc64/include/mm/sun4u/tlb.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -678,5 +678,5 @@
 }
 
-extern void fast_instruction_access_mmu_miss(unative_t, istate_t *);
+extern void fast_instruction_access_mmu_miss(sysarg_t, istate_t *);
 extern void fast_data_access_mmu_miss(tlb_tag_access_reg_t, istate_t *);
 extern void fast_data_access_protection(tlb_tag_access_reg_t , istate_t *);
Index: kernel/arch/sparc64/include/mm/sun4v/tlb.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4v/tlb.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/sparc64/include/mm/sun4v/tlb.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -141,7 +141,7 @@
 }
 
-extern void fast_instruction_access_mmu_miss(unative_t, istate_t *);
-extern void fast_data_access_mmu_miss(unative_t, istate_t *);
-extern void fast_data_access_protection(unative_t, istate_t *);
+extern void fast_instruction_access_mmu_miss(sysarg_t, istate_t *);
+extern void fast_data_access_mmu_miss(sysarg_t, istate_t *);
+extern void fast_data_access_protection(sysarg_t, istate_t *);
 
 extern void dtlb_insert_mapping(uintptr_t, uintptr_t, int, bool, bool);
Index: kernel/arch/sparc64/include/types.h
===================================================================
--- kernel/arch/sparc64/include/types.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/sparc64/include/types.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -43,5 +43,5 @@
 typedef uint64_t ipl_t;
 
-typedef uint64_t unative_t;
+typedef uint64_t sysarg_t;
 typedef int64_t native_t;
 typedef uint64_t atomic_count_t;
@@ -56,6 +56,6 @@
 
 #define PRIdn  PRId64  /**< Format for native_t. */
-#define PRIun  PRIu64  /**< Format for unative_t. */
-#define PRIxn  PRIx64  /**< Format for hexadecimal unative_t. */
+#define PRIun  PRIu64  /**< Format for sysarg_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
Index: kernel/arch/sparc64/src/mm/sun4u/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4u/tlb.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/sparc64/src/mm/sun4u/tlb.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -200,5 +200,5 @@
 
 /** ITLB miss handler. */
-void fast_instruction_access_mmu_miss(unative_t unused, istate_t *istate)
+void fast_instruction_access_mmu_miss(sysarg_t unused, istate_t *istate)
 {
 	uintptr_t page_16k = ALIGN_DOWN(istate->tpc, PAGE_SIZE);
Index: kernel/arch/sparc64/src/mm/sun4v/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4v/tlb.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/arch/sparc64/src/mm/sun4v/tlb.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -213,5 +213,5 @@
 
 /** ITLB miss handler. */
-void fast_instruction_access_mmu_miss(unative_t unused, istate_t *istate)
+void fast_instruction_access_mmu_miss(sysarg_t unused, istate_t *istate)
 {
 	uintptr_t va = ALIGN_DOWN(istate->tpc, PAGE_SIZE);
Index: kernel/genarch/src/acpi/acpi.c
===================================================================
--- kernel/genarch/src/acpi/acpi.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/genarch/src/acpi/acpi.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -116,5 +116,5 @@
 		    / sizeof(struct acpi_signature_map); j++) {
 			struct acpi_sdt_header *hdr =
-			    (struct acpi_sdt_header *) (unative_t) acpi_rsdt->entry[i];
+			    (struct acpi_sdt_header *) (sysarg_t) acpi_rsdt->entry[i];
 			
 			map_sdt(hdr);
Index: kernel/genarch/src/acpi/madt.c
===================================================================
--- kernel/genarch/src/acpi/madt.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/genarch/src/acpi/madt.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -165,5 +165,5 @@
 		/* Remember index of the first io apic entry */
 		madt_io_apic_entry_index = i;
-		io_apic = (uint32_t *) (unative_t) ioa->io_apic_address;
+		io_apic = (uint32_t *) (sysarg_t) ioa->io_apic_address;
 	} else {
 		/* Currently not supported */
@@ -190,5 +190,5 @@
 	struct madt_apic_header *hdr;
 	
-	l_apic = (uint32_t *) (unative_t) acpi_madt->l_apic_address;
+	l_apic = (uint32_t *) (sysarg_t) acpi_madt->l_apic_address;
 	
 	/* Count MADT entries */
Index: kernel/genarch/src/mm/page_ht.c
===================================================================
--- kernel/genarch/src/mm/page_ht.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/genarch/src/mm/page_ht.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -52,6 +52,6 @@
 #include <align.h>
 
-static size_t hash(unative_t[]);
-static bool compare(unative_t[], size_t, link_t *);
+static size_t hash(sysarg_t[]);
+static bool compare(sysarg_t[], size_t, link_t *);
 static void remove_callback(link_t *);
 
@@ -96,5 +96,5 @@
  *
  */
-size_t hash(unative_t key[])
+size_t hash(sysarg_t key[])
 {
 	as_t *as = (as_t *) key[KEY_AS];
@@ -115,5 +115,5 @@
 	 *
 	 */
-	index |= ((unative_t) as) & (PAGE_HT_ENTRIES - 1);
+	index |= ((sysarg_t) as) & (PAGE_HT_ENTRIES - 1);
 	
 	return index;
@@ -129,5 +129,5 @@
  *
  */
-bool compare(unative_t key[], size_t keys, link_t *item)
+bool compare(sysarg_t key[], size_t keys, link_t *item)
 {
 	ASSERT(item);
@@ -180,5 +180,5 @@
     unsigned int flags)
 {
-	unative_t key[2] = {
+	sysarg_t key[2] = {
 		(uintptr_t) as,
 		page = ALIGN_DOWN(page, PAGE_SIZE)
@@ -220,5 +220,5 @@
 void ht_mapping_remove(as_t *as, uintptr_t page)
 {
-	unative_t key[2] = {
+	sysarg_t key[2] = {
 		(uintptr_t) as,
 		page = ALIGN_DOWN(page, PAGE_SIZE)
@@ -247,5 +247,5 @@
 pte_t *ht_mapping_find(as_t *as, uintptr_t page)
 {
-	unative_t key[2] = {
+	sysarg_t key[2] = {
 		(uintptr_t) as,
 		page = ALIGN_DOWN(page, PAGE_SIZE)
Index: kernel/generic/include/adt/hash_table.h
===================================================================
--- kernel/generic/include/adt/hash_table.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/adt/hash_table.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -48,5 +48,5 @@
 	 * @return Index into hash table.
 	 */
-	size_t (* hash)(unative_t key[]);
+	size_t (* hash)(sysarg_t key[]);
 	
 	/** Hash table item comparison function.
@@ -57,5 +57,5 @@
 	 * @return true if the keys match, false otherwise.
 	 */
-	bool (*compare)(unative_t key[], size_t keys, link_t *item);
+	bool (*compare)(sysarg_t key[], size_t keys, link_t *item);
 
 	/** Hash table item removal callback.
@@ -79,7 +79,7 @@
 extern void hash_table_create(hash_table_t *h, size_t m, size_t max_keys,
     hash_table_operations_t *op);
-extern void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item);
-extern link_t *hash_table_find(hash_table_t *h, unative_t key[]);
-extern void hash_table_remove(hash_table_t *h, unative_t key[], size_t keys);
+extern void hash_table_insert(hash_table_t *h, sysarg_t key[], link_t *item);
+extern link_t *hash_table_find(hash_table_t *h, sysarg_t key[]);
+extern void hash_table_remove(hash_table_t *h, sysarg_t key[], size_t keys);
 
 #endif
Index: kernel/generic/include/console/console.h
===================================================================
--- kernel/generic/include/console/console.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/console/console.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -67,11 +67,11 @@
 extern wchar_t getc(indev_t *indev);
 extern size_t gets(indev_t *indev, char *buf, size_t buflen);
-extern unative_t sys_klog(int fd, const void *buf, size_t size);
+extern sysarg_t sys_klog(int fd, const void *buf, size_t size);
 
 extern void grab_console(void);
 extern void release_console(void);
 
-extern unative_t sys_debug_enable_console(void);
-extern unative_t sys_debug_disable_console(void);
+extern sysarg_t sys_debug_enable_console(void);
+extern sysarg_t sys_debug_disable_console(void);
 
 #endif /* KERN_CONSOLE_H_ */
Index: kernel/generic/include/console/kconsole.h
===================================================================
--- kernel/generic/include/console/kconsole.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/console/kconsole.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -62,5 +62,5 @@
 	size_t len;
 	/** Integer value. */
-	unative_t intval;
+	sysarg_t intval;
 	/** Resulting type of variable arg */
 	cmd_arg_type_t vartype;
Index: kernel/generic/include/ddi/ddi.h
===================================================================
--- kernel/generic/include/ddi/ddi.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/ddi/ddi.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -52,7 +52,7 @@
 extern void ddi_parea_register(parea_t *);
 
-extern unative_t sys_physmem_map(unative_t, unative_t, unative_t, unative_t);
-extern unative_t sys_iospace_enable(ddi_ioarg_t *);
-extern unative_t sys_interrupt_enable(int irq, int enable);
+extern sysarg_t sys_physmem_map(sysarg_t, sysarg_t, sysarg_t, sysarg_t);
+extern sysarg_t sys_iospace_enable(ddi_ioarg_t *);
+extern sysarg_t sys_interrupt_enable(int irq, int enable);
 
 /*
Index: kernel/generic/include/ddi/device.h
===================================================================
--- kernel/generic/include/ddi/device.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/ddi/device.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -39,5 +39,5 @@
 
 extern devno_t device_assign_devno(void);
-extern unative_t sys_device_assign_devno(void);
+extern sysarg_t sys_device_assign_devno(void);
 
 #endif
Index: kernel/generic/include/ddi/irq.h
===================================================================
--- kernel/generic/include/ddi/irq.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/ddi/irq.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -122,6 +122,6 @@
 	/** Answerbox for notifications. */
 	answerbox_t *answerbox;
-	/** Method to be used for the notification. */
-	unative_t method;
+	/** Interface and method to be used for the notification. */
+	sysarg_t imethod;
 	/** Arguments that will be sent if the IRQ is claimed. */
 	uint32_t scratch[IPC_CALL_LEN];
Index: kernel/generic/include/ipc/event.h
===================================================================
--- kernel/generic/include/ipc/event.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/ipc/event.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -47,6 +47,6 @@
 	/** Answerbox for notifications. */
 	answerbox_t *answerbox;
-	/** Method to be used for the notification. */
-	unative_t method;
+	/** Interface and method to be used for the notification. */
+	sysarg_t imethod;
 	/** Counter. */
 	size_t counter;
@@ -54,5 +54,5 @@
 
 extern void event_init(void);
-extern unative_t sys_event_subscribe(unative_t, unative_t);
+extern sysarg_t sys_event_subscribe(sysarg_t, sysarg_t);
 extern bool event_is_subscribed(event_type_t);
 extern void event_cleanup_answerbox(answerbox_t *);
@@ -71,6 +71,6 @@
 	event_notify((e), (a1), (a2), (a3), (a4), (a5))
 
-extern void event_notify(event_type_t, unative_t, unative_t, unative_t,
-    unative_t, unative_t);
+extern void event_notify(event_type_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t);
 
 #endif
Index: kernel/generic/include/ipc/ipc.h
===================================================================
--- kernel/generic/include/ipc/ipc.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/ipc/ipc.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -84,5 +84,5 @@
 /* Macros for manipulating calling data */
 #define IPC_SET_RETVAL(data, retval)  ((data).args[0] = (retval))
-#define IPC_SET_METHOD(data, val)     ((data).args[0] = (val))
+#define IPC_SET_IMETHOD(data, val)    ((data).args[0] = (val))
 #define IPC_SET_ARG1(data, val)       ((data).args[1] = (val))
 #define IPC_SET_ARG2(data, val)       ((data).args[2] = (val))
@@ -91,6 +91,6 @@
 #define IPC_SET_ARG5(data, val)       ((data).args[5] = (val))
 
-#define IPC_GET_METHOD(data)  ((data).args[0])
-#define IPC_GET_RETVAL(data)  ((data).args[0])
+#define IPC_GET_IMETHOD(data)  ((data).args[0])
+#define IPC_GET_RETVAL(data)   ((data).args[0])
 
 #define IPC_GET_ARG1(data)  ((data).args[1])
@@ -116,6 +116,13 @@
 #define IPC_FF_ROUTE_FROM_ME  (1 << 0)
 
+/** Kernel IPC interfaces
+ *
+ */
+#define IPC_IF_KERNEL  0
+
 /** System-specific methods - only through special syscalls
- * These methods have special behaviour
+ *
+ * These methods have special behaviour. These methods also
+ * have the implicit kernel interface 0.
  *
  */
@@ -311,5 +318,5 @@
 
 typedef struct {
-	unative_t args[IPC_CALL_LEN];
+	sysarg_t args[IPC_CALL_LEN];
 	phone_t *phone;
 } ipc_data_t;
@@ -331,5 +338,5 @@
 	
 	/** Private data to internal IPC. */
-	unative_t priv;
+	sysarg_t priv;
 	
 	/** Data passed from/to userspace. */
@@ -368,5 +375,5 @@
 
 extern void ipc_cleanup(void);
-extern void ipc_backsend_err(phone_t *, call_t *, unative_t);
+extern void ipc_backsend_err(phone_t *, call_t *, sysarg_t);
 extern void ipc_answerbox_slam_phones(answerbox_t *, bool);
 extern void ipc_cleanup_call_list(link_t *);
Index: kernel/generic/include/ipc/ipcrsc.h
===================================================================
--- kernel/generic/include/ipc/ipcrsc.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/ipc/ipcrsc.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -39,5 +39,5 @@
 #include <ipc/ipc.h>
 
-extern call_t * get_call(unative_t callid);
+extern call_t * get_call(sysarg_t callid);
 extern int phone_alloc(task_t *t);
 extern void phone_connect(int phoneid, answerbox_t *box);
Index: kernel/generic/include/ipc/irq.h
===================================================================
--- kernel/generic/include/ipc/irq.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/ipc/irq.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -44,5 +44,5 @@
 #include <adt/list.h>
 
-extern int ipc_irq_register(answerbox_t *, inr_t, devno_t, unative_t,
+extern int ipc_irq_register(answerbox_t *, inr_t, devno_t, sysarg_t,
     irq_code_t *);
 
@@ -75,6 +75,6 @@
 	ipc_irq_send_msg((irq), (a1), (a2), (a3), (a4), (a5))
 
-extern void ipc_irq_send_msg(irq_t *, unative_t, unative_t, unative_t, unative_t,
-    unative_t);
+extern void ipc_irq_send_msg(irq_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t);
 
 #endif
Index: kernel/generic/include/ipc/sysipc.h
===================================================================
--- kernel/generic/include/ipc/sysipc.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/ipc/sysipc.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,26 +40,34 @@
 #include <typedefs.h>
 
-extern unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method, 
-    unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data);
-extern unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,
-    ipc_data_t *reply);
-extern unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method, 
-    unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4);
-extern unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data);
-extern unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval, 
-    unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4);
-extern unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data);
-extern unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
-    unsigned int nonblocking);
-extern unative_t sys_ipc_poke(void);
-extern unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
-    unative_t method, unative_t arg1, unative_t arg2, unsigned int mode);
-extern unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid,
-    ipc_data_t *data, unsigned int mode);
-extern unative_t sys_ipc_hangup(unative_t phoneid);
-extern unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method,
-    irq_code_t *ucode);
-extern unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno);
-extern unative_t sys_ipc_connect_kbox(sysarg64_t *task_id);
+extern sysarg_t sys_ipc_call_sync_fast(sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, ipc_data_t *);
+extern sysarg_t sys_ipc_call_sync_slow(sysarg_t, ipc_data_t *, ipc_data_t *);
+extern sysarg_t sys_ipc_call_async_fast(sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t);
+extern sysarg_t sys_ipc_call_async_slow(sysarg_t, ipc_data_t *);
+extern sysarg_t sys_ipc_answer_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t);
+extern sysarg_t sys_ipc_answer_slow(sysarg_t, ipc_data_t *);
+extern sysarg_t sys_ipc_wait_for_call(ipc_data_t *, uint32_t, unsigned int);
+extern sysarg_t sys_ipc_poke(void);
+extern sysarg_t sys_ipc_forward_fast(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, unsigned int);
+extern sysarg_t sys_ipc_forward_slow(sysarg_t, sysarg_t, ipc_data_t *,
+    unsigned int);
+extern sysarg_t sys_ipc_hangup(sysarg_t);
+extern sysarg_t sys_ipc_register_irq(inr_t, devno_t, sysarg_t, irq_code_t *);
+extern sysarg_t sys_ipc_unregister_irq(inr_t, devno_t);
+
+#ifdef __32_BITS__
+
+extern sysarg_t sys_ipc_connect_kbox(sysarg64_t *);
+
+#endif  /* __32_BITS__ */
+
+#ifdef __64_BITS__
+
+extern sysarg_t sys_ipc_connect_kbox(sysarg_t);
+
+#endif  /* __64_BITS__ */
 
 #endif
Index: kernel/generic/include/mm/as.h
===================================================================
--- kernel/generic/include/mm/as.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/mm/as.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -303,8 +303,8 @@
 
 /* Address space area related syscalls. */
-extern unative_t sys_as_area_create(uintptr_t, size_t, unsigned int);
-extern unative_t sys_as_area_resize(uintptr_t, size_t, unsigned int);
-extern unative_t sys_as_area_change_flags(uintptr_t, unsigned int);
-extern unative_t sys_as_area_destroy(uintptr_t);
+extern sysarg_t sys_as_area_create(uintptr_t, size_t, unsigned int);
+extern sysarg_t sys_as_area_resize(uintptr_t, size_t, unsigned int);
+extern sysarg_t sys_as_area_change_flags(uintptr_t, unsigned int);
+extern sysarg_t sys_as_area_destroy(uintptr_t);
 
 /* Introspection functions. */
Index: kernel/generic/include/mm/frame.h
===================================================================
--- kernel/generic/include/mm/frame.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/mm/frame.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -144,5 +144,5 @@
 
 #define IS_BUDDY_ORDER_OK(index, order) \
-    ((~(((unative_t) -1) << (order)) & (index)) == 0)
+    ((~(((sysarg_t) -1) << (order)) & (index)) == 0)
 #define IS_BUDDY_LEFT_BLOCK(zone, frame) \
     (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x01) == 0)
Index: kernel/generic/include/proc/program.h
===================================================================
--- kernel/generic/include/proc/program.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/proc/program.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -59,5 +59,5 @@
 extern void program_ready(program_t *);
 
-extern unative_t sys_program_spawn_loader(char *, size_t);
+extern sysarg_t sys_program_spawn_loader(char *, size_t);
 
 #endif
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/proc/task.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -145,6 +145,13 @@
 #endif
 
-extern unative_t sys_task_get_id(task_id_t *);
-extern unative_t sys_task_set_name(const char *, size_t);
+#ifdef __32_BITS__
+extern sysarg_t sys_task_get_id(sysarg64_t *);
+#endif
+
+#ifdef __64_BITS__
+extern sysarg_t sys_task_get_id(void);
+#endif
+
+extern sysarg_t sys_task_set_name(const char *, size_t);
 
 #endif
Index: kernel/generic/include/proc/thread.h
===================================================================
--- kernel/generic/include/proc/thread.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/proc/thread.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -241,9 +241,9 @@
 
 /* Thread syscall prototypes. */
-extern unative_t sys_thread_create(uspace_arg_t *, char *, size_t,
+extern sysarg_t sys_thread_create(uspace_arg_t *, char *, size_t,
     thread_id_t *);
-extern unative_t sys_thread_exit(int);
-extern unative_t sys_thread_get_id(thread_id_t *);
-extern unative_t sys_thread_usleep(uint32_t);
+extern sysarg_t sys_thread_exit(int);
+extern sysarg_t sys_thread_get_id(thread_id_t *);
+extern sysarg_t sys_thread_usleep(uint32_t);
 
 #endif
Index: kernel/generic/include/security/cap.h
===================================================================
--- kernel/generic/include/security/cap.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/security/cap.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -48,5 +48,4 @@
 #define __CAP_H__
 
-#include <syscall/sysarg64.h>
 #include <typedefs.h>
 
@@ -55,5 +54,5 @@
  * privilege to/from other tasks.
  */
-#define CAP_CAP			(1<<0)
+#define CAP_CAP  (1 << 0)
 
 /**
@@ -61,5 +60,5 @@
  * to other tasks.
  */
-#define CAP_MEM_MANAGER		(1<<1)
+#define CAP_MEM_MANAGER  (1 << 1)
 
 /**
@@ -67,15 +66,26 @@
  * to other tasks.
  */
-#define CAP_IO_MANAGER		(1<<2)
+#define CAP_IO_MANAGER  (1 << 2)
 
 /**
  * CAP_IRQ_REG entitles its holder to register IRQ handlers.
  */
-#define CAP_IRQ_REG		(1<<3) 
+#define CAP_IRQ_REG  (1 << 3)
 
 typedef uint32_t cap_t;
 
-extern unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps);
-extern unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps);
+#ifdef __32_BITS__
+
+extern sysarg_t sys_cap_grant(sysarg64_t *, cap_t);
+extern sysarg_t sys_cap_revoke(sysarg64_t *, cap_t);
+
+#endif  /* __32_BITS__ */
+
+#ifdef __64_BITS__
+
+extern sysarg_t sys_cap_grant(sysarg_t, cap_t);
+extern sysarg_t sys_cap_revoke(sysarg_t, cap_t);
+
+#endif  /* __64_BITS__ */
 
 #endif
Index: kernel/generic/include/synch/futex.h
===================================================================
--- kernel/generic/include/synch/futex.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/synch/futex.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -52,6 +52,6 @@
 
 extern void futex_init(void);
-extern unative_t sys_futex_sleep(uintptr_t);
-extern unative_t sys_futex_wakeup(uintptr_t);
+extern sysarg_t sys_futex_sleep(uintptr_t);
+extern sysarg_t sys_futex_wakeup(uintptr_t);
 
 extern void futex_cleanup(void);
Index: kernel/generic/include/synch/smc.h
===================================================================
--- kernel/generic/include/synch/smc.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/synch/smc.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -36,5 +36,5 @@
 #define KERN_SMC_H_
 
-extern unative_t sys_smc_coherence(uintptr_t va, size_t size);
+extern sysarg_t sys_smc_coherence(uintptr_t va, size_t size);
 
 #endif
Index: rnel/generic/include/syscall/sysarg64.h
===================================================================
--- kernel/generic/include/syscall/sysarg64.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup generic
- * @{
- */
-
-/**
- * @file
- * @brief Wrapper for explicit 64-bit arguments passed to syscalls.
- */
-
-#ifndef KERN_SYSARG64_H_
-#define KERN_SYSARG64_H_
-
-typedef struct {
-	unsigned long long value;
-} sysarg64_t;
-
-#endif
-
-/** @}
- */
Index: kernel/generic/include/syscall/syscall.h
===================================================================
--- kernel/generic/include/syscall/syscall.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/syscall/syscall.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -38,5 +38,5 @@
 typedef enum {
 	SYS_KLOG = 0,
-	SYS_TLS_SET = 1, /* Hardcoded in AMD64, IA32 uspace - fibril.S */
+	SYS_TLS_SET = 1,  /* Hardcoded for AMD64, IA-32 (fibril.S in uspace) */
 	
 	SYS_THREAD_CREATE,
@@ -71,4 +71,5 @@
 	SYS_IPC_REGISTER_IRQ,
 	SYS_IPC_UNREGISTER_IRQ,
+	SYS_IPC_CONNECT_KBOX,
 	
 	SYS_EVENT_SUBSCRIBE,
@@ -90,5 +91,4 @@
 	SYS_DEBUG_DISABLE_CONSOLE,
 	
-	SYS_IPC_CONNECT_KBOX,
 	SYSCALL_END
 } syscall_t;
@@ -98,11 +98,11 @@
 #include <typedefs.h>
 
-typedef unative_t (*syshandler_t)(unative_t, unative_t, unative_t, unative_t,
-    unative_t, unative_t);
+typedef sysarg_t (*syshandler_t)(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t);
 
 extern syshandler_t syscall_table[SYSCALL_END];
-extern unative_t syscall_handler(unative_t, unative_t, unative_t, unative_t,
-    unative_t, unative_t, unative_t);
-extern unative_t sys_tls_set(unative_t);
+extern sysarg_t syscall_handler(sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t);
+extern sysarg_t sys_tls_set(sysarg_t);
 
 #endif
Index: kernel/generic/include/sysinfo/sysinfo.h
===================================================================
--- kernel/generic/include/sysinfo/sysinfo.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/sysinfo/sysinfo.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -65,5 +65,5 @@
 
 /** Gerated numeric value function */
-typedef unative_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
+typedef sysarg_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
 
 /** Generated binary data function */
@@ -82,5 +82,5 @@
  */
 typedef union {
-	unative_t val;              /**< Constant numberic value */
+	sysarg_t val;               /**< Constant numberic value */
 	sysinfo_fn_val_t fn_val;    /**< Generated numeric value function */
 	sysinfo_fn_data_t fn_data;  /**< Generated binary data function */
@@ -99,5 +99,5 @@
 	sysinfo_item_val_type_t tag;  /**< Return value type */
 	union {
-		unative_t val;            /**< Numberic value */
+		sysarg_t val;             /**< Numberic value */
 		sysinfo_data_t data;      /**< Binary data */
 	};
@@ -130,5 +130,5 @@
 } sysinfo_item_t;
 
-extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, unative_t);
+extern void sysinfo_set_item_val(const char *, sysinfo_item_t **, sysarg_t);
 extern void sysinfo_set_item_data(const char *, sysinfo_item_t **, void *,
     size_t);
@@ -145,8 +145,8 @@
 extern void sysinfo_dump(sysinfo_item_t *);
 
-extern unative_t sys_sysinfo_get_tag(void *, size_t);
-extern unative_t sys_sysinfo_get_value(void *, size_t, void *);
-extern unative_t sys_sysinfo_get_data_size(void *, size_t, void *);
-extern unative_t sys_sysinfo_get_data(void *, size_t, void *, size_t);
+extern sysarg_t sys_sysinfo_get_tag(void *, size_t);
+extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *);
+extern sysarg_t sys_sysinfo_get_data_size(void *, size_t, void *);
+extern sysarg_t sys_sysinfo_get_data(void *, size_t, void *, size_t);
 
 #endif
Index: kernel/generic/include/time/clock.h
===================================================================
--- kernel/generic/include/time/clock.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/time/clock.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -42,7 +42,7 @@
 /** Uptime structure */
 typedef struct {
-	unative_t seconds1;
-	unative_t useconds;
-	unative_t seconds2;
+	sysarg_t seconds1;
+	sysarg_t useconds;
+	sysarg_t seconds2;
 } uptime_t;
 
Index: kernel/generic/include/typedefs.h
===================================================================
--- kernel/generic/include/typedefs.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/typedefs.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -73,4 +73,11 @@
 typedef volatile uint32_t ioport32_t;
 
+#ifdef __32_BITS__
+
+/** Explicit 64-bit arguments passed to syscalls. */
+typedef uint64_t sysarg64_t;
+
+#endif /* __32_BITS__ */
+
 #endif
 
Index: kernel/generic/include/udebug/udebug.h
===================================================================
--- kernel/generic/include/udebug/udebug.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/udebug/udebug.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -212,5 +212,5 @@
 	waitq_t go_wq;
 	call_t *go_call;
-	unative_t syscall_args[6];
+	sysarg_t syscall_args[6];
 	istate_t *uspace_state;
 
@@ -229,6 +229,6 @@
 void udebug_thread_initialize(udebug_thread_t *ut);
 
-void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
-    unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc,
+void udebug_syscall_event(sysarg_t a1, sysarg_t a2, sysarg_t a3,
+    sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id, sysarg_t rc,
     bool end_variant);
 
Index: kernel/generic/include/udebug/udebug_ops.h
===================================================================
--- kernel/generic/include/udebug/udebug_ops.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/include/udebug/udebug_ops.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -52,5 +52,5 @@
 int udebug_regs_read(thread_t *t, void **buffer);
 
-int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer);
+int udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer);
 
 #endif
Index: kernel/generic/src/adt/hash_table.c
===================================================================
--- kernel/generic/src/adt/hash_table.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/adt/hash_table.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -82,5 +82,5 @@
  * @param item Item to be inserted into the hash table.
  */
-void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item)
+void hash_table_insert(hash_table_t *h, sysarg_t key[], link_t *item)
 {
 	size_t chain;
@@ -105,5 +105,5 @@
  * @return Matching item on success, NULL if there is no such item.
  */
-link_t *hash_table_find(hash_table_t *h, unative_t key[])
+link_t *hash_table_find(hash_table_t *h, sysarg_t key[])
 {
 	link_t *cur;
@@ -138,5 +138,5 @@
  * @param keys Number of keys in the key array.
  */
-void hash_table_remove(hash_table_t *h, unative_t key[], size_t keys)
+void hash_table_remove(hash_table_t *h, sysarg_t key[], size_t keys)
 {
 	size_t chain;
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/console/cmd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -601,5 +601,5 @@
 	
 	/* This doesn't have to be very accurate */
-	unative_t sec = uptime->seconds1;
+	sysarg_t sec = uptime->seconds1;
 	
 	printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
@@ -656,5 +656,5 @@
 	uintptr_t symaddr;
 	char *symbol;
-	unative_t (*fnc)(void);
+	sysarg_t (*fnc)(void);
 	fncptr_t fptr;
 	int rc;
@@ -672,5 +672,5 @@
 
 		ipl = interrupts_disable();
-		fnc = (unative_t (*)(void)) arch_construct_function(&fptr,
+		fnc = (sysarg_t (*)(void)) arch_construct_function(&fptr,
 		    (void *) symaddr, (void *) cmd_call0);
 		printf("Calling %s() (%p)\n", symbol, (void *) symaddr);
@@ -720,6 +720,6 @@
 	uintptr_t symaddr;
 	char *symbol;
-	unative_t (*fnc)(unative_t, ...);
-	unative_t arg1 = argv[1].intval;
+	sysarg_t (*fnc)(sysarg_t, ...);
+	sysarg_t arg1 = argv[1].intval;
 	fncptr_t fptr;
 	int rc;
@@ -737,5 +737,5 @@
 
 		ipl = interrupts_disable();
-		fnc = (unative_t (*)(unative_t, ...))
+		fnc = (sysarg_t (*)(sysarg_t, ...))
 		    arch_construct_function(&fptr, (void *) symaddr,
 		    (void *) cmd_call1);
@@ -756,7 +756,7 @@
 	uintptr_t symaddr;
 	char *symbol;
-	unative_t (*fnc)(unative_t, unative_t, ...);
-	unative_t arg1 = argv[1].intval;
-	unative_t arg2 = argv[2].intval;
+	sysarg_t (*fnc)(sysarg_t, sysarg_t, ...);
+	sysarg_t arg1 = argv[1].intval;
+	sysarg_t arg2 = argv[2].intval;
 	fncptr_t fptr;
 	int rc;
@@ -774,5 +774,5 @@
 
 		ipl = interrupts_disable();
-		fnc = (unative_t (*)(unative_t, unative_t, ...))
+		fnc = (sysarg_t (*)(sysarg_t, sysarg_t, ...))
 		    arch_construct_function(&fptr, (void *) symaddr,
 		    (void *) cmd_call2);
@@ -792,8 +792,8 @@
 	uintptr_t symaddr;
 	char *symbol;
-	unative_t (*fnc)(unative_t, unative_t, unative_t, ...);
-	unative_t arg1 = argv[1].intval;
-	unative_t arg2 = argv[2].intval;
-	unative_t arg3 = argv[3].intval;
+	sysarg_t (*fnc)(sysarg_t, sysarg_t, sysarg_t, ...);
+	sysarg_t arg1 = argv[1].intval;
+	sysarg_t arg2 = argv[2].intval;
+	sysarg_t arg3 = argv[3].intval;
 	fncptr_t fptr;
 	int rc;
@@ -811,5 +811,5 @@
 
 		ipl = interrupts_disable();
-		fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...))
+		fnc = (sysarg_t (*)(sysarg_t, sysarg_t, sysarg_t, ...))
 		    arch_construct_function(&fptr, (void *) symaddr,
 		    (void *) cmd_call3);
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/console/console.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -162,5 +162,5 @@
 	ddi_parea_register(&klog_parea);
 	
-	sysinfo_set_item_val("klog.faddr", NULL, (unative_t) faddr);
+	sysinfo_set_item_val("klog.faddr", NULL, (sysarg_t) faddr);
 	sysinfo_set_item_val("klog.pages", NULL, KLOG_PAGES);
 	
@@ -193,5 +193,5 @@
 
 /** Tell kernel to get keyboard/console access again */
-unative_t sys_debug_enable_console(void)
+sysarg_t sys_debug_enable_console(void)
 {
 #ifdef CONFIG_KCONSOLE
@@ -204,5 +204,5 @@
 
 /** Tell kernel to relinquish keyboard/console access */
-unative_t sys_debug_disable_console(void)
+sysarg_t sys_debug_disable_console(void)
 {
 	release_console();
@@ -333,5 +333,5 @@
  *
  */
-unative_t sys_klog(int fd, const void *buf, size_t size)
+sysarg_t sys_klog(int fd, const void *buf, size_t size)
 {
 	char *data;
@@ -339,15 +339,15 @@
 	
 	if (size > PAGE_SIZE)
-		return (unative_t) ELIMIT;
+		return (sysarg_t) ELIMIT;
 	
 	if (size > 0) {
 		data = (char *) malloc(size + 1, 0);
 		if (!data)
-			return (unative_t) ENOMEM;
+			return (sysarg_t) ENOMEM;
 		
 		rc = copy_from_uspace(data, buf, size);
 		if (rc) {
 			free(data);
-			return (unative_t) rc;
+			return (sysarg_t) rc;
 		}
 		data[size] = 0;
Index: kernel/generic/src/console/kconsole.c
===================================================================
--- kernel/generic/src/console/kconsole.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/console/kconsole.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -426,5 +426,5 @@
 
 NO_TRACE static bool parse_int_arg(const char *text, size_t len,
-    unative_t *result)
+    sysarg_t *result)
 {
 	bool isaddr = false;
@@ -461,9 +461,9 @@
 		case EOK:
 			if (isaddr)
-				*result = (unative_t) symaddr;
+				*result = (sysarg_t) symaddr;
 			else if (isptr)
-				*result = **((unative_t **) symaddr);
+				*result = **((sysarg_t **) symaddr);
 			else
-				*result = *((unative_t *) symaddr);
+				*result = *((sysarg_t *) symaddr);
 			break;
 		default:
@@ -483,7 +483,7 @@
 			return false;
 		case EOK:
-			*result = (unative_t) value;
+			*result = (sysarg_t) value;
 			if (isptr)
-				*result = *((unative_t *) *result);
+				*result = *((sysarg_t *) *result);
 			break;
 		default:
@@ -629,5 +629,5 @@
 					    cmdline + start + 1,
 					    (end - start) - 1);
-					cmd->argv[i].intval = (unative_t) buf;
+					cmd->argv[i].intval = (sysarg_t) buf;
 					cmd->argv[i].vartype = ARG_TYPE_STRING;
 				} else {
Index: kernel/generic/src/ddi/ddi.c
===================================================================
--- kernel/generic/src/ddi/ddi.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ddi/ddi.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -232,8 +232,8 @@
  *
  */
-unative_t sys_physmem_map(unative_t phys_base, unative_t virt_base,
-    unative_t pages, unative_t flags)
-{
-	return (unative_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base,
+sysarg_t sys_physmem_map(sysarg_t phys_base, sysarg_t virt_base,
+    sysarg_t pages, sysarg_t flags)
+{
+	return (sysarg_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base,
 	    FRAME_SIZE), ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE),
 	    (size_t) pages, (int) flags);
@@ -247,12 +247,12 @@
  *
  */
-unative_t sys_iospace_enable(ddi_ioarg_t *uspace_io_arg)
+sysarg_t sys_iospace_enable(ddi_ioarg_t *uspace_io_arg)
 {
 	ddi_ioarg_t arg;
 	int rc = copy_from_uspace(&arg, uspace_io_arg, sizeof(ddi_ioarg_t));
 	if (rc != 0)
-		return (unative_t) rc;
-	
-	return (unative_t) ddi_iospace_enable((task_id_t) arg.task_id,
+		return (sysarg_t) rc;
+	
+	return (sysarg_t) ddi_iospace_enable((task_id_t) arg.task_id,
 	    (uintptr_t) arg.ioaddr, (size_t) arg.size);
 }
@@ -265,5 +265,5 @@
  * @retutn Zero on success, error code otherwise.
  */
-unative_t sys_interrupt_enable(int irq, int enable)
+sysarg_t sys_interrupt_enable(int irq, int enable)
 {
 /* FIXME: this needs to be generic code, or better not be in kernel at all. */
Index: kernel/generic/src/ddi/device.c
===================================================================
--- kernel/generic/src/ddi/device.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ddi/device.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -54,7 +54,7 @@
 }
 
-unative_t sys_device_assign_devno(void)
+sysarg_t sys_device_assign_devno(void)
 {
-	return (unative_t) device_assign_devno();
+	return (sysarg_t) device_assign_devno();
 }
 
Index: kernel/generic/src/ddi/irq.c
===================================================================
--- kernel/generic/src/ddi/irq.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ddi/irq.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -106,6 +106,6 @@
  *
  */
-static size_t irq_ht_hash(unative_t *key);
-static bool irq_ht_compare(unative_t *key, size_t keys, link_t *item);
+static size_t irq_ht_hash(sysarg_t *key);
+static bool irq_ht_compare(sysarg_t *key, size_t keys, link_t *item);
 static void irq_ht_remove(link_t *item);
 
@@ -123,6 +123,6 @@
  *
  */
-static size_t irq_lin_hash(unative_t *key);
-static bool irq_lin_compare(unative_t *key, size_t keys, link_t *item);
+static size_t irq_lin_hash(sysarg_t *key);
+static bool irq_lin_compare(sysarg_t *key, size_t keys, link_t *item);
 static void irq_lin_remove(link_t *item);
 
@@ -194,7 +194,7 @@
 void irq_register(irq_t *irq)
 {
-	unative_t key[] = {
-		(unative_t) irq->inr,
-		(unative_t) irq->devno
+	sysarg_t key[] = {
+		(sysarg_t) irq->inr,
+		(sysarg_t) irq->devno
 	};
 	
@@ -212,7 +212,7 @@
 {
 	link_t *lnk;
-	unative_t key[] = {
-		(unative_t) inr,
-		(unative_t) -1    /* Search will use claim() instead of devno */
+	sysarg_t key[] = {
+		(sysarg_t) inr,
+		(sysarg_t) -1    /* Search will use claim() instead of devno */
 	};
 	
@@ -235,7 +235,7 @@
 {
 	link_t *lnk;
-	unative_t key[] = {
-		(unative_t) inr,
-		(unative_t) -1    /* Search will use claim() instead of devno */
+	sysarg_t key[] = {
+		(sysarg_t) inr,
+		(sysarg_t) -1    /* Search will use claim() instead of devno */
 	};
 	
@@ -306,5 +306,5 @@
  *
  */
-size_t irq_ht_hash(unative_t key[])
+size_t irq_ht_hash(sysarg_t key[])
 {
 	inr_t inr = (inr_t) key[KEY_INR];
@@ -333,5 +333,5 @@
  *
  */
-bool irq_ht_compare(unative_t key[], size_t keys, link_t *item)
+bool irq_ht_compare(sysarg_t key[], size_t keys, link_t *item)
 {
 	irq_t *irq = hash_table_get_instance(item, irq_t, link);
@@ -381,5 +381,5 @@
  *
  */
-size_t irq_lin_hash(unative_t key[])
+size_t irq_lin_hash(sysarg_t key[])
 {
 	inr_t inr = (inr_t) key[KEY_INR];
@@ -408,5 +408,5 @@
  *
  */
-bool irq_lin_compare(unative_t key[], size_t keys, link_t *item)
+bool irq_lin_compare(sysarg_t key[], size_t keys, link_t *item)
 {
 	irq_t *irq = list_get_instance(item, irq_t, link);
Index: kernel/generic/src/interrupt/interrupt.c
===================================================================
--- kernel/generic/src/interrupt/interrupt.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/interrupt/interrupt.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -197,5 +197,5 @@
 		/* Notify the subscriber that a fault occurred. */
 		event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
-		    UPPER32(TASK->taskid), (unative_t) THREAD);
+		    UPPER32(TASK->taskid), (sysarg_t) THREAD);
 		
 #ifdef CONFIG_UDEBUG
@@ -263,5 +263,5 @@
 		
 		const char *symbol =
-		    symtab_fmt_name_lookup((unative_t) exc_table[i].handler);
+		    symtab_fmt_name_lookup((sysarg_t) exc_table[i].handler);
 		
 #ifdef __32_BITS__
Index: kernel/generic/src/ipc/event.c
===================================================================
--- kernel/generic/src/ipc/event.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ipc/event.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -57,9 +57,9 @@
 		events[i].answerbox = NULL;
 		events[i].counter = 0;
-		events[i].method = 0;
+		events[i].imethod = 0;
 	}
 }
 
-static int event_subscribe(event_type_t evno, unative_t method,
+static int event_subscribe(event_type_t evno, sysarg_t imethod,
     answerbox_t *answerbox)
 {
@@ -73,5 +73,5 @@
 	if (events[evno].answerbox == NULL) {
 		events[evno].answerbox = answerbox;
-		events[evno].method = method;
+		events[evno].imethod = imethod;
 		events[evno].counter = 0;
 		res = EOK;
@@ -84,8 +84,8 @@
 }
 
-unative_t sys_event_subscribe(unative_t evno, unative_t method)
+sysarg_t sys_event_subscribe(sysarg_t evno, sysarg_t imethod)
 {
-	return (unative_t) event_subscribe((event_type_t) evno, (unative_t)
-	    method, &TASK->answerbox);
+	return (sysarg_t) event_subscribe((event_type_t) evno, (sysarg_t)
+	    imethod, &TASK->answerbox);
 }
 
@@ -113,5 +113,5 @@
 			events[i].answerbox = NULL;
 			events[i].counter = 0;
-			events[i].method = 0;
+			events[i].imethod = 0;
 		}
 		spinlock_unlock(&events[i].lock);
@@ -119,6 +119,6 @@
 }
 
-void event_notify(event_type_t evno, unative_t a1, unative_t a2, unative_t a3,
-    unative_t a4, unative_t a5)
+void event_notify(event_type_t evno, sysarg_t a1, sysarg_t a2, sysarg_t a3,
+    sysarg_t a4, sysarg_t a5)
 {
 	ASSERT(evno < EVENT_END);
@@ -130,5 +130,5 @@
 			call->flags |= IPC_CALL_NOTIF;
 			call->priv = ++events[evno].counter;
-			IPC_SET_METHOD(call->data, events[evno].method);
+			IPC_SET_IMETHOD(call->data, events[evno].imethod);
 			IPC_SET_ARG1(call->data, a1);
 			IPC_SET_ARG2(call->data, a2);
Index: kernel/generic/src/ipc/ipc.c
===================================================================
--- kernel/generic/src/ipc/ipc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ipc/ipc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -270,5 +270,5 @@
  *
  */
-void ipc_backsend_err(phone_t *phone, call_t *call, unative_t err)
+void ipc_backsend_err(phone_t *phone, call_t *call, sysarg_t err)
 {
 	call->data.phone = phone;
@@ -367,5 +367,5 @@
 		
 		call_t *call = ipc_call_alloc(0);
-		IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
+		IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
 		call->flags |= IPC_CALL_DISCARD_ANSWER;
 		_ipc_call(phone, box, call);
@@ -547,5 +547,5 @@
 			 * disconnected.
 			 */
-			IPC_SET_METHOD(call->data, IPC_M_PHONE_HUNGUP);
+			IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
 			call->flags |= IPC_CALL_DISCARD_ANSWER;
 			_ipc_call(phone, box, call);
@@ -741,5 +741,5 @@
 		    " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call,
 		    call->sender->taskid,
-		    IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
+		    IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data),
 		    IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
 		    IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
@@ -757,5 +757,5 @@
 		    " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", call,
 		    call->sender->taskid,
-		    IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
+		    IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data),
 		    IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
 		    IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
@@ -771,5 +771,5 @@
 		printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun
 		    " A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n",
-		    call, IPC_GET_METHOD(call->data), IPC_GET_ARG1(call->data),
+		    call, IPC_GET_IMETHOD(call->data), IPC_GET_ARG1(call->data),
 		    IPC_GET_ARG2(call->data), IPC_GET_ARG3(call->data),
 		    IPC_GET_ARG4(call->data), IPC_GET_ARG5(call->data),
Index: kernel/generic/src/ipc/ipcrsc.c
===================================================================
--- kernel/generic/src/ipc/ipcrsc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ipc/ipcrsc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -144,5 +144,5 @@
  *
  */
-call_t *get_call(unative_t callid)
+call_t *get_call(sysarg_t callid)
 {
 	link_t *lst;
@@ -153,5 +153,5 @@
 	    lst != &TASK->answerbox.dispatched_calls; lst = lst->next) {
 		call_t *call = list_get_instance(lst, call_t, link);
-		if ((unative_t) call == callid) {
+		if ((sysarg_t) call == callid) {
 			result = call;
 			break;
Index: kernel/generic/src/ipc/irq.c
===================================================================
--- kernel/generic/src/ipc/irq.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ipc/irq.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -42,5 +42,6 @@
  *
  * The structure of a notification message is as follows:
- * - METHOD: method as registered by the SYS_IPC_REGISTER_IRQ syscall
+ * - IMETHOD: interface and method as registered by the SYS_IPC_REGISTER_IRQ
+ *            syscall
  * - ARG1: payload modified by a 'top-half' handler
  * - ARG2: payload modified by a 'top-half' handler
@@ -49,5 +50,5 @@
  * - ARG5: payload modified by a 'top-half' handler
  * - in_phone_hash: interrupt counter (may be needed to assure correct order
- *         in multithreaded drivers)
+ *                  in multithreaded drivers)
  *
  * Note on synchronization for ipc_irq_register(), ipc_irq_unregister(),
@@ -130,9 +131,10 @@
 /** Register an answerbox as a receiving end for IRQ notifications.
  *
- * @param box    Receiving answerbox.
- * @param inr    IRQ number.
- * @param devno  Device number.
- * @param method Method to be associated with the notification.
- * @param ucode  Uspace pointer to top-half pseudocode.
+ * @param box     Receiving answerbox.
+ * @param inr     IRQ number.
+ * @param devno   Device number.
+ * @param imethod Interface and method to be associated
+ *                with the notification.
+ * @param ucode   Uspace pointer to top-half pseudocode.
  *
  * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success.
@@ -140,9 +142,9 @@
  */
 int ipc_irq_register(answerbox_t *box, inr_t inr, devno_t devno,
-    unative_t method, irq_code_t *ucode)
-{
-	unative_t key[] = {
-		(unative_t) inr,
-		(unative_t) devno
+    sysarg_t imethod, irq_code_t *ucode)
+{
+	sysarg_t key[] = {
+		(sysarg_t) inr,
+		(sysarg_t) devno
 	};
 	
@@ -167,5 +169,5 @@
 	irq->notif_cfg.notify = true;
 	irq->notif_cfg.answerbox = box;
-	irq->notif_cfg.method = method;
+	irq->notif_cfg.imethod = imethod;
 	irq->notif_cfg.code = code;
 	irq->notif_cfg.counter = 0;
@@ -213,7 +215,7 @@
 int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno)
 {
-	unative_t key[] = {
-		(unative_t) inr,
-		(unative_t) devno
+	sysarg_t key[] = {
+		(sysarg_t) inr,
+		(sysarg_t) devno
 	};
 	
@@ -290,5 +292,5 @@
 		}
 		
-		unative_t key[2];
+		sysarg_t key[2];
 		key[0] = irq->inr;
 		key[1] = irq->devno;
@@ -444,5 +446,5 @@
 		
 		/* Set up args */
-		IPC_SET_METHOD(call->data, irq->notif_cfg.method);
+		IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod);
 		IPC_SET_ARG1(call->data, irq->notif_cfg.scratch[1]);
 		IPC_SET_ARG2(call->data, irq->notif_cfg.scratch[2]);
@@ -465,6 +467,6 @@
  *
  */
-void ipc_irq_send_msg(irq_t *irq, unative_t a1, unative_t a2, unative_t a3,
-    unative_t a4, unative_t a5)
+void ipc_irq_send_msg(irq_t *irq, sysarg_t a1, sysarg_t a2, sysarg_t a3,
+    sysarg_t a4, sysarg_t a5)
 {
 	irq_spinlock_lock(&irq->lock, true);
@@ -481,5 +483,5 @@
 		call->priv = ++irq->notif_cfg.counter;
 		
-		IPC_SET_METHOD(call->data, irq->notif_cfg.method);
+		IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod);
 		IPC_SET_ARG1(call->data, a1);
 		IPC_SET_ARG2(call->data, a2);
Index: kernel/generic/src/ipc/kbox.c
===================================================================
--- kernel/generic/src/ipc/kbox.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ipc/kbox.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -167,5 +167,5 @@
 			continue;  /* Try again. */
 		
-		switch (IPC_GET_METHOD(call->data)) {
+		switch (IPC_GET_IMETHOD(call->data)) {
 		
 		case IPC_M_DEBUG_ALL:
@@ -192,5 +192,4 @@
 }
 
-
 /** Connect phone to a task kernel-box specified by id.
  *
Index: kernel/generic/src/ipc/sysipc.c
===================================================================
--- kernel/generic/src/ipc/sysipc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/ipc/sysipc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -49,4 +49,5 @@
 #include <syscall/copy.h>
 #include <security/cap.h>
+#include <console/console.h>
 #include <mm/as.h>
 #include <print.h>
@@ -68,5 +69,5 @@
  *
  */
-static int phone_get(unative_t phoneid, phone_t **phone)
+static int phone_get(sysarg_t phoneid, phone_t **phone)
 {
 	if (phoneid >= IPC_MAX_PHONES)
@@ -77,14 +78,15 @@
 }
 
-/** Decide if the method is a system method.
- *
- * @param method Method to be decided.
- *
- * @return true if the method is a system method.
- *
- */
-static inline bool method_is_system(unative_t method)
-{
-	if (method <= IPC_M_LAST_SYSTEM)
+/** Decide if the interface and method is a system method.
+ *
+ * @param imethod Interface and method to be decided.
+ *
+ * @return True if the interface and method is a system
+ *         interface and method.
+ *
+ */
+static inline bool method_is_system(sysarg_t imethod)
+{
+	if (imethod <= IPC_M_LAST_SYSTEM)
 		return true;
 	
@@ -92,17 +94,17 @@
 }
 
-/** Decide if the message with this method is forwardable.
- *
- * - some system messages may be forwarded, for some of them
- *   it is useless
- *
- * @param method Method to be decided.
- *
- * @return true if the method is forwardable.
- *
- */
-static inline bool method_is_forwardable(unative_t method)
-{
-	switch (method) {
+/** Decide if the message with this interface and method is forwardable.
+ *
+ * Some system messages may be forwarded, for some of them
+ * it is useless.
+ *
+ * @param imethod Interface and method to be decided.
+ *
+ * @return True if the interface and method is forwardable.
+ *
+ */
+static inline bool method_is_forwardable(sysarg_t imethod)
+{
+	switch (imethod) {
 	case IPC_M_CONNECTION_CLONE:
 	case IPC_M_CONNECT_ME:
@@ -115,16 +117,16 @@
 }
 
-/** Decide if the message with this method is immutable on forward.
- *
- * - some system messages may be forwarded but their content cannot be altered
- *
- * @param method Method to be decided.
- *
- * @return true if the method is immutable on forward.
- *
- */
-static inline bool method_is_immutable(unative_t method)
-{
-	switch (method) {
+/** Decide if the message with this interface and method is immutable on forward.
+ *
+ * Some system messages may be forwarded but their content cannot be altered.
+ *
+ * @param imethod Interface and method to be decided.
+ *
+ * @return True if the interface and method is immutable on forward.
+ *
+ */
+static inline bool method_is_immutable(sysarg_t imethod)
+{
+	switch (imethod) {
 	case IPC_M_SHARE_OUT:
 	case IPC_M_SHARE_IN:
@@ -152,5 +154,5 @@
 static inline bool answer_need_old(call_t *call)
 {
-	switch (IPC_GET_METHOD(call->data)) {
+	switch (IPC_GET_IMETHOD(call->data)) {
 	case IPC_M_CONNECTION_CLONE:
 	case IPC_M_CONNECT_ME:
@@ -196,5 +198,5 @@
 		return 0;
 	
-	if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECTION_CLONE) {
+	if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECTION_CLONE) {
 		int phoneid = IPC_GET_ARG1(*olddata);
 		phone_t *phone = &TASK->phones[phoneid];
@@ -218,5 +220,5 @@
 			mutex_unlock(&phone->lock);
 		}
-	} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_ME) {
+	} else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME) {
 		phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata);
 		
@@ -237,5 +239,5 @@
 			mutex_unlock(&phone->lock);
 		}
-	} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_TO_ME) {
+	} else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_TO_ME) {
 		int phoneid = IPC_GET_ARG5(*olddata);
 		
@@ -248,7 +250,7 @@
 			/* Set 'phone hash' as arg5 of response */
 			IPC_SET_ARG5(answer->data,
-			    (unative_t) &TASK->phones[phoneid]);
-		}
-	} else if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_ME_TO) {
+			    (sysarg_t) &TASK->phones[phoneid]);
+		}
+	} else if (IPC_GET_IMETHOD(*olddata) == IPC_M_CONNECT_ME_TO) {
 		/* If the users accepted call, connect */
 		if (IPC_GET_RETVAL(answer->data) == EOK) {
@@ -256,5 +258,5 @@
 			    &TASK->answerbox);
 		}
-	} else if (IPC_GET_METHOD(*olddata) == IPC_M_SHARE_OUT) {
+	} else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_OUT) {
 		if (!IPC_GET_RETVAL(answer->data)) {
 			/* Accepted, handle as_area receipt */
@@ -270,5 +272,5 @@
 			return rc;
 		}
-	} else if (IPC_GET_METHOD(*olddata) == IPC_M_SHARE_IN) {
+	} else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_IN) {
 		if (!IPC_GET_RETVAL(answer->data)) { 
 			irq_spinlock_lock(&answer->sender->lock, true);
@@ -281,5 +283,5 @@
 			IPC_SET_RETVAL(answer->data, rc);
 		}
-	} else if (IPC_GET_METHOD(*olddata) == IPC_M_DATA_READ) {
+	} else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_READ) {
 		ASSERT(!answer->buffer);
 		if (!IPC_GET_RETVAL(answer->data)) {
@@ -310,5 +312,5 @@
 			}
 		}
-	} else if (IPC_GET_METHOD(*olddata) == IPC_M_DATA_WRITE) {
+	} else if (IPC_GET_IMETHOD(*olddata) == IPC_M_DATA_WRITE) {
 		ASSERT(answer->buffer);
 		if (!IPC_GET_RETVAL(answer->data)) {
@@ -363,5 +365,5 @@
 static int request_preprocess(call_t *call, phone_t *phone)
 {
-	switch (IPC_GET_METHOD(call->data)) {
+	switch (IPC_GET_IMETHOD(call->data)) {
 	case IPC_M_CONNECTION_CLONE: {
 		phone_t *cloned_phone;
@@ -399,5 +401,5 @@
 	}
 	case IPC_M_CONNECT_ME:
-		IPC_SET_ARG5(call->data, (unative_t) phone);
+		IPC_SET_ARG5(call->data, (sysarg_t) phone);
 		break;
 	case IPC_M_CONNECT_ME_TO: {
@@ -407,5 +409,5 @@
 		
 		/* Set arg5 for server */
-		IPC_SET_ARG5(call->data, (unative_t) &TASK->phones[newphid]);
+		IPC_SET_ARG5(call->data, (sysarg_t) &TASK->phones[newphid]);
 		call->flags |= IPC_CALL_CONN_ME_TO;
 		call->priv = newphid;
@@ -503,5 +505,5 @@
 static int process_request(answerbox_t *box, call_t *call)
 {
-	if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME) {
+	if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME) {
 		int phoneid = phone_alloc(TASK);
 		if (phoneid < 0) { /* Failed to allocate phone */
@@ -514,5 +516,5 @@
 	}
 	
-	switch (IPC_GET_METHOD(call->data)) {
+	switch (IPC_GET_IMETHOD(call->data)) {
 	case IPC_M_DEBUG_ALL:
 		return -1;
@@ -530,9 +532,9 @@
  *
  * @param phoneid Phone handle for the call.
- * @param method  Method of the call.
+ * @param imethod Interface and method of the call.
  * @param arg1    Service-defined payload argument.
  * @param arg2    Service-defined payload argument.
  * @param arg3    Service-defined payload argument.
- * @param data    Address of userspace structure where the reply call will
+ * @param data    Address of user-space structure where the reply call will
  *                be stored.
  *
@@ -541,13 +543,13 @@
  *
  */
-unative_t sys_ipc_call_sync_fast(unative_t phoneid, unative_t method,
-    unative_t arg1, unative_t arg2, unative_t arg3, ipc_data_t *data)
+sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t imethod,
+    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, ipc_data_t *data)
 {
 	phone_t *phone;
 	if (phone_get(phoneid, &phone) != EOK)
 		return ENOENT;
-
+	
 	call_t *call = ipc_call_alloc(0);
-	IPC_SET_METHOD(call->data, method);
+	IPC_SET_IMETHOD(call->data, imethod);
 	IPC_SET_ARG1(call->data, arg1);
 	IPC_SET_ARG2(call->data, arg2);
@@ -579,5 +581,4 @@
 		
 		process_answer(call);
-		
 	} else
 		IPC_SET_RETVAL(call->data, res);
@@ -593,13 +594,13 @@
 /** Make a synchronous IPC call allowing to transmit the entire payload.
  *
- * @param phoneid  Phone handle for the call.
- * @param question Userspace address of call data with the request.
- * @param reply    Userspace address of call data where to store the
- *                 answer.
+ * @param phoneid Phone handle for the call.
+ * @param request User-space address of call data with the request.
+ * @param reply   User-space address of call data where to store the
+ *                answer.
  *
  * @return Zero on success or an error code.
  *
  */
-unative_t sys_ipc_call_sync_slow(unative_t phoneid, ipc_data_t *question,
+sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t *request,
     ipc_data_t *reply)
 {
@@ -607,11 +608,11 @@
 	if (phone_get(phoneid, &phone) != EOK)
 		return ENOENT;
-
+	
 	call_t *call = ipc_call_alloc(0);
-	int rc = copy_from_uspace(&call->data.args, &question->args,
+	int rc = copy_from_uspace(&call->data.args, &request->args,
 	    sizeof(call->data.args));
 	if (rc != 0) {
 		ipc_call_free(call);
-		return (unative_t) rc;
+		return (sysarg_t) rc;
 	}
 	
@@ -647,5 +648,6 @@
  * made over a phone.
  *
- * @param phone Phone to check the limit against. 
+ * @param phone Phone to check the limit against.
+ *
  * @return 0 if limit not reached or -1 if limit exceeded.
  *
@@ -665,5 +667,5 @@
  *
  * @param phoneid Phone handle for the call.
- * @param method  Method of the call.
+ * @param imethod Interface and method of the call.
  * @param arg1    Service-defined payload argument.
  * @param arg2    Service-defined payload argument.
@@ -677,16 +679,16 @@
  *
  */
-unative_t sys_ipc_call_async_fast(unative_t phoneid, unative_t method,
-    unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4)
+sysarg_t sys_ipc_call_async_fast(sysarg_t phoneid, sysarg_t imethod,
+    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
 {
 	phone_t *phone;
 	if (phone_get(phoneid, &phone) != EOK)
 		return IPC_CALLRET_FATAL;
-
+	
 	if (check_call_limit(phone))
 		return IPC_CALLRET_TEMPORARY;
 	
 	call_t *call = ipc_call_alloc(0);
-	IPC_SET_METHOD(call->data, method);
+	IPC_SET_IMETHOD(call->data, imethod);
 	IPC_SET_ARG1(call->data, arg1);
 	IPC_SET_ARG2(call->data, arg2);
@@ -707,5 +709,5 @@
 		ipc_backsend_err(phone, call, res);
 	
-	return (unative_t) call;
+	return (sysarg_t) call;
 }
 
@@ -718,5 +720,5 @@
  *
  */
-unative_t sys_ipc_call_async_slow(unative_t phoneid, ipc_data_t *data)
+sysarg_t sys_ipc_call_async_slow(sysarg_t phoneid, ipc_data_t *data)
 {
 	phone_t *phone;
@@ -732,5 +734,5 @@
 	if (rc != 0) {
 		ipc_call_free(call);
-		return (unative_t) rc;
+		return (sysarg_t) rc;
 	}
 	
@@ -742,5 +744,5 @@
 		ipc_backsend_err(phone, call, res);
 	
-	return (unative_t) call;
+	return (sysarg_t) call;
 }
 
@@ -751,5 +753,5 @@
  * @param callid  Hash of the call to forward.
  * @param phoneid Phone handle to use for forwarding.
- * @param method  New method to use for the forwarded call.
+ * @param imethod New interface and method to use for the forwarded call.
  * @param arg1    New value of the first argument for the forwarded call.
  * @param arg2    New value of the second argument for the forwarded call.
@@ -767,7 +769,7 @@
  *
  */
-static unative_t sys_ipc_forward_common(unative_t callid, unative_t phoneid,
-    unative_t method, unative_t arg1, unative_t arg2, unative_t arg3,
-    unative_t arg4, unative_t arg5, unsigned int mode, bool slow)
+static sysarg_t sys_ipc_forward_common(sysarg_t callid, sysarg_t phoneid,
+    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
+    sysarg_t arg4, sysarg_t arg5, unsigned int mode, bool slow)
 {
 	call_t *call = get_call(callid);
@@ -784,5 +786,5 @@
 	}
 	
-	if (!method_is_forwardable(IPC_GET_METHOD(call->data))) {
+	if (!method_is_forwardable(IPC_GET_IMETHOD(call->data))) {
 		IPC_SET_RETVAL(call->data, EFORWARD);
 		ipc_answer(&TASK->answerbox, call);
@@ -791,15 +793,15 @@
 	
 	/*
-	 * Userspace is not allowed to change method of system methods on
-	 * forward, allow changing ARG1, ARG2, ARG3 and ARG4 by means of method,
-	 * arg1, arg2 and arg3.
-	 * If the method is immutable, don't change anything.
+	 * Userspace is not allowed to change interface and method of system
+	 * methods on forward, allow changing ARG1, ARG2, ARG3 and ARG4 by
+	 * means of method, arg1, arg2 and arg3.
+	 * If the interface and method is immutable, don't change anything.
 	 */
-	if (!method_is_immutable(IPC_GET_METHOD(call->data))) {
-		if (method_is_system(IPC_GET_METHOD(call->data))) {
-			if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME)
+	if (!method_is_immutable(IPC_GET_IMETHOD(call->data))) {
+		if (method_is_system(IPC_GET_IMETHOD(call->data))) {
+			if (IPC_GET_IMETHOD(call->data) == IPC_M_CONNECT_TO_ME)
 				phone_dealloc(IPC_GET_ARG5(call->data));
 			
-			IPC_SET_ARG1(call->data, method);
+			IPC_SET_ARG1(call->data, imethod);
 			IPC_SET_ARG2(call->data, arg1);
 			IPC_SET_ARG3(call->data, arg2);
@@ -813,5 +815,5 @@
 			}
 		} else {
-			IPC_SET_METHOD(call->data, method);
+			IPC_SET_IMETHOD(call->data, imethod);
 			IPC_SET_ARG1(call->data, arg1);
 			IPC_SET_ARG2(call->data, arg2);
@@ -829,14 +831,14 @@
 /** Forward a received call to another destination - fast version.
  *
- * In case the original method is a system method, ARG1, ARG2 and ARG3 are
- * overwritten in the forwarded message with the new method and the new
- * arg1 and arg2, respectively. Otherwise the METHOD, ARG1 and ARG2 are
- * rewritten with the new method, arg1 and arg2, respectively. Also note there
- * is a set of immutable methods, for which the new method and arguments are not
- * set and these values are ignored.
+ * In case the original interface and method is a system method, ARG1, ARG2
+ * and ARG3 are overwritten in the forwarded message with the new method and
+ * the new arg1 and arg2, respectively. Otherwise the IMETHOD, ARG1 and ARG2
+ * are rewritten with the new interface and method, arg1 and arg2, respectively.
+ * Also note there is a set of immutable methods, for which the new method and
+ * arguments are not set and these values are ignored.
  *
  * @param callid  Hash of the call to forward.
  * @param phoneid Phone handle to use for forwarding.
- * @param method  New method to use for the forwarded call.
+ * @param imethod New interface and method to use for the forwarded call.
  * @param arg1    New value of the first argument for the forwarded call.
  * @param arg2    New value of the second argument for the forwarded call.
@@ -846,8 +848,8 @@
  *
  */
-unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid,
-    unative_t method, unative_t arg1, unative_t arg2, unsigned int mode)
-{
-	return sys_ipc_forward_common(callid, phoneid, method, arg1, arg2, 0, 0,
+sysarg_t sys_ipc_forward_fast(sysarg_t callid, sysarg_t phoneid,
+    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode)
+{
+	return sys_ipc_forward_common(callid, phoneid, imethod, arg1, arg2, 0, 0,
 	    0, mode, false); 
 }
@@ -856,9 +858,9 @@
  *
  * This function is the slow verision of the sys_ipc_forward_fast interface.
- * It can copy all five new arguments and the new method from the userspace.
- * It naturally extends the functionality of the fast version. For system
- * methods, it additionally stores the new value of arg3 to ARG4. For non-system
- * methods, it additionally stores the new value of arg3, arg4 and arg5,
- * respectively, to ARG3, ARG4 and ARG5, respectively.
+ * It can copy all five new arguments and the new interface and method from
+ * the userspace. It naturally extends the functionality of the fast version.
+ * For system methods, it additionally stores the new value of arg3 to ARG4.
+ * For non-system methods, it additionally stores the new value of arg3, arg4
+ * and arg5, respectively, to ARG3, ARG4 and ARG5, respectively.
  *
  * @param callid  Hash of the call to forward.
@@ -870,5 +872,5 @@
  *
  */
-unative_t sys_ipc_forward_slow(unative_t callid, unative_t phoneid,
+sysarg_t sys_ipc_forward_slow(sysarg_t callid, sysarg_t phoneid,
     ipc_data_t *data, unsigned int mode)
 {
@@ -877,8 +879,8 @@
 	    sizeof(newdata.args));
 	if (rc != 0)
-		return (unative_t) rc;
+		return (sysarg_t) rc;
 	
 	return sys_ipc_forward_common(callid, phoneid,
-	    IPC_GET_METHOD(newdata), IPC_GET_ARG1(newdata),
+	    IPC_GET_IMETHOD(newdata), IPC_GET_ARG1(newdata),
 	    IPC_GET_ARG2(newdata), IPC_GET_ARG3(newdata),
 	    IPC_GET_ARG4(newdata), IPC_GET_ARG5(newdata), mode, true); 
@@ -900,6 +902,6 @@
  *
  */
-unative_t sys_ipc_answer_fast(unative_t callid, unative_t retval,
-    unative_t arg1, unative_t arg2, unative_t arg3, unative_t arg4)
+sysarg_t sys_ipc_answer_fast(sysarg_t callid, sysarg_t retval,
+    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
 {
 	/* Do not answer notification callids */
@@ -945,5 +947,5 @@
  *
  */
-unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data)
+sysarg_t sys_ipc_answer_slow(sysarg_t callid, ipc_data_t *data)
 {
 	/* Do not answer notification callids */
@@ -982,5 +984,5 @@
  *
  */
-unative_t sys_ipc_hangup(unative_t phoneid)
+sysarg_t sys_ipc_hangup(sysarg_t phoneid)
 {
 	phone_t *phone;
@@ -1008,5 +1010,5 @@
  *
  */
-unative_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
+sysarg_t sys_ipc_wait_for_call(ipc_data_t *calldata, uint32_t usec,
     unsigned int flags)
 {
@@ -1037,5 +1039,5 @@
 		ipc_call_free(call);
 		
-		return ((unative_t) call) | IPC_CALLID_NOTIFICATION;
+		return ((sysarg_t) call) | IPC_CALLID_NOTIFICATION;
 	}
 	
@@ -1051,5 +1053,5 @@
 		ipc_call_free(call);
 		
-		return ((unative_t) call) | IPC_CALLID_ANSWERED;
+		return ((sysarg_t) call) | IPC_CALLID_ANSWERED;
 	}
 	
@@ -1079,5 +1081,5 @@
 	}
 	
-	return (unative_t) call;
+	return (sysarg_t) call;
 }
 
@@ -1085,5 +1087,5 @@
  *
  */
-unative_t sys_ipc_poke(void)
+sysarg_t sys_ipc_poke(void)
 {
 	waitq_unsleep(&TASK->answerbox.wq);
@@ -1093,13 +1095,13 @@
 /** Connect an IRQ handler to a task.
  *
- * @param inr    IRQ number.
- * @param devno  Device number.
- * @param method Method to be associated with the notification.
- * @param ucode  Uspace pointer to the top-half pseudocode.
+ * @param inr     IRQ number.
+ * @param devno   Device number.
+ * @param imethod Interface and method to be associated with the notification.
+ * @param ucode   Uspace pointer to the top-half pseudocode.
  *
  * @return EPERM or a return code returned by ipc_irq_register().
  *
  */
-unative_t sys_ipc_register_irq(inr_t inr, devno_t devno, unative_t method,
+sysarg_t sys_ipc_register_irq(inr_t inr, devno_t devno, sysarg_t imethod,
     irq_code_t *ucode)
 {
@@ -1107,5 +1109,5 @@
 		return EPERM;
 	
-	return ipc_irq_register(&TASK->answerbox, inr, devno, method, ucode);
+	return ipc_irq_register(&TASK->answerbox, inr, devno, imethod, ucode);
 }
 
@@ -1118,5 +1120,5 @@
  *
  */
-unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno)
+sysarg_t sys_ipc_unregister_irq(inr_t inr, devno_t devno)
 {
 	if (!(cap_get(TASK) & CAP_IRQ_REG))
@@ -1128,27 +1130,45 @@
 }
 
-#include <console/console.h>
-
-/** Syscall connect to a task by id.
+#ifdef __32_BITS__
+
+/** Syscall connect to a task by ID (32 bits)
  *
  * @return Phone id on success, or negative error code.
  *
  */
-unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg)
+sysarg_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid)
 {
 #ifdef CONFIG_UDEBUG
-	sysarg64_t taskid_arg;
-	int rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
+	sysarg64_t taskid;
+	int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t));
 	if (rc != 0)
-		return (unative_t) rc;
-	
-	LOG("sys_ipc_connect_kbox(%" PRIu64 ")", taskid_arg.value);
-	
-	return ipc_connect_kbox(taskid_arg.value);
+		return (sysarg_t) rc;
+	
+	return ipc_connect_kbox((task_id_t) taskid);
 #else
-	return (unative_t) ENOTSUP;
+	return (sysarg_t) ENOTSUP;
 #endif
 }
 
+#endif  /* __32_BITS__ */
+
+#ifdef __64_BITS__
+
+/** Syscall connect to a task by ID (64 bits)
+ *
+ * @return Phone id on success, or negative error code.
+ *
+ */
+sysarg_t sys_ipc_connect_kbox(sysarg_t taskid)
+{
+#ifdef CONFIG_UDEBUG
+	return ipc_connect_kbox((task_id_t) taskid);
+#else
+	return (sysarg_t) ENOTSUP;
+#endif
+}
+
+#endif  /* __64_BITS__ */
+
 /** @}
  */
Index: kernel/generic/src/lib/memstr.c
===================================================================
--- kernel/generic/src/lib/memstr.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/lib/memstr.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -62,15 +62,15 @@
 	unsigned int i, j;
 	
-	if (ALIGN_UP((uintptr_t) src, sizeof(unative_t)) != (uintptr_t) src ||
-	    ALIGN_UP((uintptr_t) dst, sizeof(unative_t)) != (uintptr_t) dst) {
+	if (ALIGN_UP((uintptr_t) src, sizeof(sysarg_t)) != (uintptr_t) src ||
+	    ALIGN_UP((uintptr_t) dst, sizeof(sysarg_t)) != (uintptr_t) dst) {
 		for (i = 0; i < cnt; i++)
 			((uint8_t *) dst)[i] = ((uint8_t *) src)[i];
 	} else { 
-		for (i = 0; i < cnt / sizeof(unative_t); i++)
-			((unative_t *) dst)[i] = ((unative_t *) src)[i];
+		for (i = 0; i < cnt / sizeof(sysarg_t); i++)
+			((sysarg_t *) dst)[i] = ((sysarg_t *) src)[i];
 		
-		for (j = 0; j < cnt % sizeof(unative_t); j++)
-			((uint8_t *)(((unative_t *) dst) + i))[j] =
-			    ((uint8_t *)(((unative_t *) src) + i))[j];
+		for (j = 0; j < cnt % sizeof(sysarg_t); j++)
+			((uint8_t *)(((sysarg_t *) dst) + i))[j] =
+			    ((uint8_t *)(((sysarg_t *) src) + i))[j];
 	}
 		
Index: kernel/generic/src/lib/rd.c
===================================================================
--- kernel/generic/src/lib/rd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/lib/rd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -96,5 +96,5 @@
 	sysinfo_set_item_val("rd.size", NULL, dsize);
 	sysinfo_set_item_val("rd.address.physical", NULL,
-	    (unative_t)	KA2PA((void *) header + hsize));
+	    (sysarg_t) KA2PA((void *) header + hsize));
 
 	return RE_OK;
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/mm/as.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -2000,29 +2000,29 @@
 
 /** Wrapper for as_area_create(). */
-unative_t sys_as_area_create(uintptr_t address, size_t size, unsigned int flags)
+sysarg_t sys_as_area_create(uintptr_t address, size_t size, unsigned int flags)
 {
 	if (as_area_create(AS, flags | AS_AREA_CACHEABLE, size, address,
 	    AS_AREA_ATTR_NONE, &anon_backend, NULL))
-		return (unative_t) address;
+		return (sysarg_t) address;
 	else
-		return (unative_t) -1;
+		return (sysarg_t) -1;
 }
 
 /** Wrapper for as_area_resize(). */
-unative_t sys_as_area_resize(uintptr_t address, size_t size, unsigned int flags)
-{
-	return (unative_t) as_area_resize(AS, address, size, 0);
+sysarg_t sys_as_area_resize(uintptr_t address, size_t size, unsigned int flags)
+{
+	return (sysarg_t) as_area_resize(AS, address, size, 0);
 }
 
 /** Wrapper for as_area_change_flags(). */
-unative_t sys_as_area_change_flags(uintptr_t address, unsigned int flags)
-{
-	return (unative_t) as_area_change_flags(AS, flags, address);
+sysarg_t sys_as_area_change_flags(uintptr_t address, unsigned int flags)
+{
+	return (sysarg_t) as_area_change_flags(AS, flags, address);
 }
 
 /** Wrapper for as_area_destroy(). */
-unative_t sys_as_area_destroy(uintptr_t address)
-{
-	return (unative_t) as_area_destroy(AS, address);
+sysarg_t sys_as_area_destroy(uintptr_t address)
+{
+	return (sysarg_t) as_area_destroy(AS, address);
 }
 
Index: kernel/generic/src/mm/slab.c
===================================================================
--- kernel/generic/src/mm/slab.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/mm/slab.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -612,6 +612,6 @@
 	cache->name = name;
 	
-	if (align < sizeof(unative_t))
-		align = sizeof(unative_t);
+	if (align < sizeof(sysarg_t))
+		align = sizeof(sysarg_t);
 	
 	size = ALIGN_UP(size, align);
Index: kernel/generic/src/proc/program.c
===================================================================
--- kernel/generic/src/proc/program.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/proc/program.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -210,5 +210,5 @@
  *
  */
-unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len)
+sysarg_t sys_program_spawn_loader(char *uspace_name, size_t name_len)
 {
 	/* Cap length of name and copy it from userspace. */
@@ -219,5 +219,5 @@
 	int rc = copy_from_uspace(namebuf, uspace_name, name_len);
 	if (rc != 0)
-		return (unative_t) rc;
+		return (sysarg_t) rc;
 	
 	namebuf[name_len] = 0;
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/proc/task.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -290,13 +290,15 @@
 }
 
-/** Syscall for reading task ID from userspace.
- *
- * @param uspace_task_id Userspace address of 8-byte buffer
- *                       where to store current task ID.
+#ifdef __32_BITS__
+
+/** Syscall for reading task ID from userspace (32 bits)
+ *
+ * @param uspace_taskid Pointer to user-space buffer
+ *                      where to store current task ID.
  *
  * @return Zero on success or an error code from @ref errno.h.
  *
  */
-unative_t sys_task_get_id(task_id_t *uspace_task_id)
+sysarg_t sys_task_get_id(sysarg64_t *uspace_taskid)
 {
 	/*
@@ -304,7 +306,27 @@
 	 * the lifespan of the task.
 	 */
-	return (unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid,
+	return (sysarg_t) copy_to_uspace(uspace_taskid, &TASK->taskid,
 	    sizeof(TASK->taskid));
 }
+
+#endif  /* __32_BITS__ */
+
+#ifdef __64_BITS__
+
+/** Syscall for reading task ID from userspace (64 bits)
+ *
+ * @return Current task ID.
+ *
+ */
+sysarg_t sys_task_get_id(void)
+{
+	/*
+	 * No need to acquire lock on TASK because taskid remains constant for
+	 * the lifespan of the task.
+	 */
+	return TASK->taskid;
+}
+
+#endif  /* __64_BITS__ */
 
 /** Syscall for setting the task name.
@@ -318,5 +340,5 @@
  *
  */
-unative_t sys_task_set_name(const char *uspace_name, size_t name_len)
+sysarg_t sys_task_set_name(const char *uspace_name, size_t name_len)
 {
 	int rc;
@@ -330,5 +352,5 @@
 	rc = copy_from_uspace(namebuf, uspace_name, name_len);
 	if (rc != 0)
-		return (unative_t) rc;
+		return (sysarg_t) rc;
 	
 	namebuf[name_len] = '\0';
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/proc/thread.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -755,5 +755,5 @@
  *
  */
-unative_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
+sysarg_t sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name,
     size_t name_len, thread_id_t *uspace_thread_id)
 {
@@ -764,5 +764,5 @@
 	int rc = copy_from_uspace(namebuf, uspace_name, name_len);
 	if (rc != 0)
-		return (unative_t) rc;
+		return (sysarg_t) rc;
 	
 	namebuf[name_len] = 0;
@@ -779,5 +779,5 @@
 	if (rc != 0) {
 		free(kernel_uarg);
-		return (unative_t) rc;
+		return (sysarg_t) rc;
 	}
 	
@@ -804,5 +804,5 @@
 				free(kernel_uarg);
 				
-				return (unative_t) rc;
+				return (sysarg_t) rc;
 			 }
 		}
@@ -827,5 +827,5 @@
 		free(kernel_uarg);
 	
-	return (unative_t) ENOMEM;
+	return (sysarg_t) ENOMEM;
 }
 
@@ -833,5 +833,5 @@
  *
  */
-unative_t sys_thread_exit(int uspace_status)
+sysarg_t sys_thread_exit(int uspace_status)
 {
 	thread_exit();
@@ -849,5 +849,5 @@
  *
  */
-unative_t sys_thread_get_id(thread_id_t *uspace_thread_id)
+sysarg_t sys_thread_get_id(thread_id_t *uspace_thread_id)
 {
 	/*
@@ -856,10 +856,10 @@
 	 *
 	 */
-	return (unative_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,
+	return (sysarg_t) copy_to_uspace(uspace_thread_id, &THREAD->tid,
 	    sizeof(THREAD->tid));
 }
 
 /** Syscall wrapper for sleeping. */
-unative_t sys_thread_usleep(uint32_t usec)
+sysarg_t sys_thread_usleep(uint32_t usec)
 {
 	thread_usleep(usec);
Index: kernel/generic/src/security/cap.c
===================================================================
--- kernel/generic/src/security/cap.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/security/cap.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -41,5 +41,4 @@
 #include <proc/task.h>
 #include <synch/spinlock.h>
-#include <syscall/sysarg64.h>
 #include <syscall/copy.h>
 #include <arch.h>
@@ -79,26 +78,21 @@
  * The calling task must have the CAP_CAP capability.
  *
- * @param uspace_taskid_arg Userspace structure holding destination task ID.
- * @param caps Capabilities to grant.
- *
- * @return Zero on success or an error code from @ref errno.h.
- *
- */
-unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps)
+ * @param taskid Destination task ID.
+ * @param caps   Capabilities to grant.
+ *
+ * @return Zero on success or an error code from @ref errno.h.
+ *
+ */
+static sysarg_t cap_grant(task_id_t taskid, cap_t caps)
 {
 	if (!(cap_get(TASK) & CAP_CAP))
-		return (unative_t) EPERM;
-	
-	sysarg64_t taskid_arg;
-	int rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
-	if (rc != 0)
-		return (unative_t) rc;
+		return (sysarg_t) EPERM;
 	
 	irq_spinlock_lock(&tasks_lock, true);
-	task_t *task = task_find_by_id((task_id_t) taskid_arg.value);
+	task_t *task = task_find_by_id(taskid);
 	
 	if ((!task) || (!context_check(CONTEXT, task->context))) {
 		irq_spinlock_unlock(&tasks_lock, true);
-		return (unative_t) ENOENT;
+		return (sysarg_t) ENOENT;
 	}
 	
@@ -116,23 +110,18 @@
  * attempt to revoke capabilities from itself.
  *
- * @param uspace_taskid_arg Userspace structure holding destination task ID.
- * @param caps Capabilities to revoke.
- *
- * @return Zero on success or an error code from @ref errno.h.
- *
- */
-unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps)
-{
-	sysarg64_t taskid_arg;
-	int rc = copy_from_uspace(&taskid_arg, uspace_taskid_arg, sizeof(sysarg64_t));
-	if (rc != 0)
-		return (unative_t) rc;
-	
+ * @param taskid Destination task ID.
+ * @param caps   Capabilities to revoke.
+ *
+ * @return Zero on success or an error code from @ref errno.h.
+ *
+ */
+static sysarg_t cap_revoke(task_id_t taskid, cap_t caps)
+{
 	irq_spinlock_lock(&tasks_lock, true);
 	
-	task_t *task = task_find_by_id((task_id_t) taskid_arg.value);
+	task_t *task = task_find_by_id(taskid);
 	if ((!task) || (!context_check(CONTEXT, task->context))) {
 		irq_spinlock_unlock(&tasks_lock, true);
-		return (unative_t) ENOENT;
+		return (sysarg_t) ENOENT;
 	}
 	
@@ -147,5 +136,5 @@
 		irq_spinlock_unlock(&TASK->lock, false);
 		irq_spinlock_unlock(&tasks_lock, true);
-		return (unative_t) EPERM;
+		return (sysarg_t) EPERM;
 	}
 	
@@ -157,4 +146,84 @@
 }
 
+#ifdef __32_BITS__
+
+/** Grant capabilities to a task (32 bits)
+ *
+ * The calling task must have the CAP_CAP capability.
+ *
+ * @param uspace_taskid User-space pointer to destination task ID.
+ * @param caps          Capabilities to grant.
+ *
+ * @return Zero on success or an error code from @ref errno.h.
+ *
+ */
+sysarg_t sys_cap_grant(sysarg64_t *uspace_taskid, cap_t caps)
+{
+	sysarg64_t taskid;
+	int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t));
+	if (rc != 0)
+		return (sysarg_t) rc;
+	
+	return cap_grant((task_id_t) taskid, caps);
+}
+
+/** Revoke capabilities from a task (32 bits)
+ *
+ * The calling task must have the CAP_CAP capability or the caller must
+ * attempt to revoke capabilities from itself.
+ *
+ * @param uspace_taskid User-space pointer to destination task ID.
+ * @param caps          Capabilities to revoke.
+ *
+ * @return Zero on success or an error code from @ref errno.h.
+ *
+ */
+sysarg_t sys_cap_revoke(sysarg64_t *uspace_taskid, cap_t caps)
+{
+	sysarg64_t taskid;
+	int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(sysarg64_t));
+	if (rc != 0)
+		return (sysarg_t) rc;
+	
+	return cap_revoke((task_id_t) taskid, caps);
+}
+
+#endif  /* __32_BITS__ */
+
+#ifdef __64_BITS__
+
+/** Grant capabilities to a task (64 bits)
+ *
+ * The calling task must have the CAP_CAP capability.
+ *
+ * @param taskid Destination task ID.
+ * @param caps   Capabilities to grant.
+ *
+ * @return Zero on success or an error code from @ref errno.h.
+ *
+ */
+sysarg_t sys_cap_grant(sysarg_t taskid, cap_t caps)
+{
+	return cap_grant((task_id_t) taskid, caps);
+}
+
+/** Revoke capabilities from a task (64 bits)
+ *
+ * The calling task must have the CAP_CAP capability or the caller must
+ * attempt to revoke capabilities from itself.
+ *
+ * @param taskid Destination task ID.
+ * @param caps   Capabilities to revoke.
+ *
+ * @return Zero on success or an error code from @ref errno.h.
+ *
+ */
+sysarg_t sys_cap_revoke(sysarg_t taskid, cap_t caps)
+{
+	return cap_revoke((task_id_t) taskid, caps);
+}
+
+#endif  /* __64_BITS__ */
+
 /** @}
  */
Index: kernel/generic/src/synch/futex.c
===================================================================
--- kernel/generic/src/synch/futex.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/synch/futex.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -60,6 +60,6 @@
 
 static futex_t *futex_find(uintptr_t paddr);
-static size_t futex_ht_hash(unative_t *key);
-static bool futex_ht_compare(unative_t *key, size_t keys, link_t *item);
+static size_t futex_ht_hash(sysarg_t *key);
+static bool futex_ht_compare(sysarg_t *key, size_t keys, link_t *item);
 static void futex_ht_remove_callback(link_t *item);
 
@@ -108,5 +108,5 @@
  *			synch.h.
  */
-unative_t sys_futex_sleep(uintptr_t uaddr)
+sysarg_t sys_futex_sleep(uintptr_t uaddr)
 {
 	futex_t *futex;
@@ -122,5 +122,5 @@
 	if (!t || !PTE_VALID(t) || !PTE_PRESENT(t)) {
 		page_table_unlock(AS, true);
-		return (unative_t) ENOENT;
+		return (sysarg_t) ENOENT;
 	}
 	paddr = PTE_GET_FRAME(t) + (uaddr - ALIGN_DOWN(uaddr, PAGE_SIZE));
@@ -136,5 +136,5 @@
 	udebug_stoppable_end();
 #endif
-	return (unative_t) rc;
+	return (sysarg_t) rc;
 }
 
@@ -145,5 +145,5 @@
  * @return		ENOENT if there is no physical mapping for uaddr.
  */
-unative_t sys_futex_wakeup(uintptr_t uaddr)
+sysarg_t sys_futex_wakeup(uintptr_t uaddr)
 {
 	futex_t *futex;
@@ -158,5 +158,5 @@
 	if (!t || !PTE_VALID(t) || !PTE_PRESENT(t)) {
 		page_table_unlock(AS, true);
-		return (unative_t) ENOENT;
+		return (sysarg_t) ENOENT;
 	}
 	paddr = PTE_GET_FRAME(t) + (uaddr - ALIGN_DOWN(uaddr, PAGE_SIZE));
@@ -235,5 +235,5 @@
  * @return		Index into futex hash table.
  */
-size_t futex_ht_hash(unative_t *key)
+size_t futex_ht_hash(sysarg_t *key)
 {
 	return (*key & (FUTEX_HT_SIZE - 1));
@@ -247,5 +247,5 @@
  * @return		True if the item matches the key. False otherwise.
  */
-bool futex_ht_compare(unative_t *key, size_t keys, link_t *item)
+bool futex_ht_compare(sysarg_t *key, size_t keys, link_t *item)
 {
 	futex_t *futex;
Index: kernel/generic/src/synch/smc.c
===================================================================
--- kernel/generic/src/synch/smc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/synch/smc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -42,5 +42,5 @@
 #include <synch/smc.h>
 
-unative_t sys_smc_coherence(uintptr_t va, size_t size)
+sysarg_t sys_smc_coherence(uintptr_t va, size_t size)
 {
 	if (overlaps(va, size, (uintptr_t) NULL, PAGE_SIZE))
Index: kernel/generic/src/syscall/syscall.c
===================================================================
--- kernel/generic/src/syscall/syscall.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/syscall/syscall.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -56,6 +56,6 @@
 
 /** Dispatch system call */
-unative_t syscall_handler(unative_t a1, unative_t a2, unative_t a3,
-    unative_t a4, unative_t a5, unative_t a6, unative_t id)
+sysarg_t syscall_handler(sysarg_t a1, sysarg_t a2, sysarg_t a3,
+    sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id)
 {
 	/* Do userpace accounting */
@@ -74,5 +74,5 @@
 #endif
 	
-	unative_t rc;
+	sysarg_t rc;
 	if (id < SYSCALL_END) {
 		rc = syscall_table[id](a1, a2, a3, a4, a5, a6);
@@ -147,4 +147,5 @@
 	(syshandler_t) sys_ipc_register_irq,
 	(syshandler_t) sys_ipc_unregister_irq,
+	(syshandler_t) sys_ipc_connect_kbox,
 	
 	/* Event notification syscalls. */
@@ -169,7 +170,5 @@
 	/* Debug calls */
 	(syshandler_t) sys_debug_enable_console,
-	(syshandler_t) sys_debug_disable_console,
-	
-	(syshandler_t) sys_ipc_connect_kbox
+	(syshandler_t) sys_debug_disable_console
 };
 
Index: kernel/generic/src/sysinfo/stats.c
===================================================================
--- kernel/generic/src/sysinfo/stats.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/sysinfo/stats.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -87,5 +87,5 @@
  *
  */
-static unative_t get_stats_uptime(struct sysinfo_item *item)
+static sysarg_t get_stats_uptime(struct sysinfo_item *item)
 {
 	/* This doesn't have to be very accurate */
Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -296,5 +296,5 @@
  */
 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root,
-    unative_t val)
+    sysarg_t val)
 {
 	/* Protect sysinfo tree consistency */
@@ -481,5 +481,5 @@
 		sysinfo_indent(depth);
 		
-		unative_t val;
+		sysarg_t val;
 		size_t size;
 		
@@ -660,5 +660,5 @@
  *
  */
-unative_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size)
+sysarg_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size)
 {
 	/*
@@ -679,5 +679,5 @@
 		ret.tag = SYSINFO_VAL_DATA;
 	
-	return (unative_t) ret.tag;
+	return (sysarg_t) ret.tag;
 }
 
@@ -696,5 +696,5 @@
  *
  */
-unative_t sys_sysinfo_get_value(void *path_ptr, size_t path_size,
+sysarg_t sys_sysinfo_get_value(void *path_ptr, size_t path_size,
     void *value_ptr)
 {
@@ -715,5 +715,5 @@
 		rc = EINVAL;
 	
-	return (unative_t) rc;
+	return (sysarg_t) rc;
 }
 
@@ -732,5 +732,5 @@
  *
  */
-unative_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size,
+sysarg_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size,
     void *size_ptr)
 {
@@ -752,5 +752,5 @@
 		rc = EINVAL;
 	
-	return (unative_t) rc;
+	return (sysarg_t) rc;
 }
 
@@ -774,5 +774,5 @@
  *
  */
-unative_t sys_sysinfo_get_data(void *path_ptr, size_t path_size,
+sysarg_t sys_sysinfo_get_data(void *path_ptr, size_t path_size,
     void *buffer_ptr, size_t buffer_size)
 {
@@ -797,5 +797,5 @@
 		free(ret.data.data);
 	
-	return (unative_t) rc;
+	return (sysarg_t) rc;
 }
 
Index: kernel/generic/src/time/clock.c
===================================================================
--- kernel/generic/src/time/clock.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/time/clock.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -70,5 +70,5 @@
  *
  */
-static unative_t secfrag = 0;
+static sysarg_t secfrag = 0;
 
 /** Initialize realtime clock counter
@@ -100,6 +100,6 @@
 	 *
 	 */
-	sysinfo_set_item_val("clock.cacheable", NULL, (unative_t) true);
-	sysinfo_set_item_val("clock.faddr", NULL, (unative_t) faddr);
+	sysinfo_set_item_val("clock.cacheable", NULL, (sysarg_t) true);
+	sysinfo_set_item_val("clock.faddr", NULL, (sysarg_t) faddr);
 }
 
Index: kernel/generic/src/udebug/udebug.c
===================================================================
--- kernel/generic/src/udebug/udebug.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/udebug/udebug.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -219,6 +219,6 @@
  *
  */
-void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
-    unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc,
+void udebug_syscall_event(sysarg_t a1, sysarg_t a2, sysarg_t a3,
+    sysarg_t a4, sysarg_t a5, sysarg_t a6, sysarg_t id, sysarg_t rc,
     bool end_variant)
 {
@@ -314,5 +314,5 @@
 	IPC_SET_RETVAL(call->data, 0);
 	IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
-	IPC_SET_ARG2(call->data, (unative_t) thread);
+	IPC_SET_ARG2(call->data, (sysarg_t) thread);
 	
 	/*
Index: kernel/generic/src/udebug/udebug_ipc.c
===================================================================
--- kernel/generic/src/udebug/udebug_ipc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/udebug/udebug_ipc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -210,6 +210,6 @@
 static void udebug_receive_name_read(call_t *call)
 {
-	unative_t uspace_addr;
-	unative_t to_copy;
+	sysarg_t uspace_addr;
+	sysarg_t to_copy;
 	size_t data_size;
 	size_t buf_size;
@@ -257,6 +257,6 @@
 static void udebug_receive_areas_read(call_t *call)
 {
-	unative_t uspace_addr;
-	unative_t to_copy;
+	sysarg_t uspace_addr;
+	sysarg_t to_copy;
 	size_t data_size;
 	size_t buf_size;
@@ -304,5 +304,5 @@
 {
 	thread_t *t;
-	unative_t uspace_addr;
+	sysarg_t uspace_addr;
 	int rc;
 	void *buffer;
@@ -328,5 +328,5 @@
 	   (no way to distinguish method in answer) */
 	IPC_SET_ARG1(call->data, uspace_addr);
-	IPC_SET_ARG2(call->data, 6 * sizeof(unative_t));
+	IPC_SET_ARG2(call->data, 6 * sizeof(sysarg_t));
 	call->buffer = buffer;
 
@@ -341,6 +341,6 @@
 {
 	thread_t *t;
-	unative_t uspace_addr;
-	unative_t to_copy;
+	sysarg_t uspace_addr;
+	sysarg_t to_copy;
 	void *buffer;
 	int rc;
@@ -382,6 +382,6 @@
 static void udebug_receive_mem_read(call_t *call)
 {
-	unative_t uspace_dst;
-	unative_t uspace_src;
+	sysarg_t uspace_dst;
+	sysarg_t uspace_src;
 	unsigned size;
 	void *buffer;
Index: kernel/generic/src/udebug/udebug_ops.c
===================================================================
--- kernel/generic/src/udebug/udebug_ops.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/generic/src/udebug/udebug_ops.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -371,5 +371,5 @@
 	
 	/* Allocate a buffer to hold thread IDs */
-	unative_t *id_buffer = malloc(buf_size + 1, 0);
+	sysarg_t *id_buffer = malloc(buf_size + 1, 0);
 	
 	mutex_lock(&TASK->udebug.lock);
@@ -385,5 +385,5 @@
 	/* Copy down the thread IDs */
 	
-	size_t max_ids = buf_size / sizeof(unative_t);
+	size_t max_ids = buf_size / sizeof(sysarg_t);
 	size_t copied_ids = 0;
 	size_t extra_ids = 0;
@@ -404,5 +404,5 @@
 		if (copied_ids < max_ids) {
 			/* Using thread struct pointer as identification hash */
-			id_buffer[copied_ids++] = (unative_t) thread;
+			id_buffer[copied_ids++] = (sysarg_t) thread;
 		} else
 			extra_ids++;
@@ -414,6 +414,6 @@
 	
 	*buffer = id_buffer;
-	*stored = copied_ids * sizeof(unative_t);
-	*needed = (copied_ids + extra_ids) * sizeof(unative_t);
+	*stored = copied_ids * sizeof(sysarg_t);
+	*needed = (copied_ids + extra_ids) * sizeof(sysarg_t);
 	
 	return 0;
@@ -463,5 +463,5 @@
 {
 	/* Prepare a buffer to hold the arguments. */
-	unative_t *arg_buffer = malloc(6 * sizeof(unative_t), 0);
+	sysarg_t *arg_buffer = malloc(6 * sizeof(sysarg_t), 0);
 	
 	/* On success, this will lock t->udebug.lock. */
@@ -478,5 +478,5 @@
 	
 	/* Copy to a local buffer before releasing the lock. */
-	memcpy(arg_buffer, thread->udebug.syscall_args, 6 * sizeof(unative_t));
+	memcpy(arg_buffer, thread->udebug.syscall_args, 6 * sizeof(sysarg_t));
 	
 	_thread_op_end(thread);
@@ -539,5 +539,5 @@
  *
  */
-int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer)
+int udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer)
 {
 	/* Verify task state */
Index: kernel/test/fpu/fpu1_ia64.c
===================================================================
--- kernel/test/fpu/fpu1_ia64.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/test/fpu/fpu1_ia64.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -85,5 +85,5 @@
 		
 		if ((int) (100000000 * e) != E_10e8) {
-			TPRINTF("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
+			TPRINTF("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (sysarg_t) (100000000 * e), (sysarg_t) E_10e8);
 			atomic_inc(&threads_fault);
 			break;
@@ -118,5 +118,5 @@
 		
 		if ((int) (1000000 * pi) != PI_10e8) {
-			TPRINTF("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100));
+			TPRINTF("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (sysarg_t) (1000000 * pi), (sysarg_t) (PI_10e8 / 100));
 			atomic_inc(&threads_fault);
 			break;
Index: kernel/test/fpu/fpu1_x86.c
===================================================================
--- kernel/test/fpu/fpu1_x86.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/test/fpu/fpu1_x86.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -83,5 +83,5 @@
 		if ((int) (100000000 * e) != E_10e8) {
 			TPRINTF("tid%" PRIu64 ": e*10e8=%" PRIun " should be %" PRIun "\n",
-			    THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
+			    THREAD->tid, (sysarg_t) (100000000 * e), (sysarg_t) E_10e8);
 			atomic_inc(&threads_fault);
 			break;
@@ -117,5 +117,5 @@
 		if ((int) (100000000 * pi) != PI_10e8) {
 			TPRINTF("tid%" PRIu64 ": pi*10e8=%" PRIun " should be %" PRIun "\n",
-			    THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
+			    THREAD->tid, (sysarg_t) (100000000 * pi), (sysarg_t) PI_10e8);
 			atomic_inc(&threads_fault);
 			break;
Index: kernel/test/fpu/mips2.c
===================================================================
--- kernel/test/fpu/mips2.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/test/fpu/mips2.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -48,5 +48,5 @@
 {
 	int i;
-	int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
+	int arg __attribute__((aligned(16))) = (int) ((sysarg_t) data);
 	int after_arg __attribute__((aligned(16)));
 	
@@ -80,5 +80,5 @@
 {
 	int i;
-	int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
+	int arg __attribute__((aligned(16))) = (int) ((sysarg_t) data);
 	int after_arg __attribute__((aligned(16)));
 	
@@ -123,5 +123,5 @@
 		thread_t *t;
 		
-		if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) {
+		if (!(t = thread_create(testit1, (void *) ((sysarg_t) 2 * i), TASK, 0, "testit1", false))) {
 			TPRINTF("could not create thread %u\n", 2 * i);
 			break;
@@ -130,5 +130,5 @@
 		total++;
 		
-		if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) {
+		if (!(t = thread_create(testit2, (void *) ((sysarg_t) 2 * i + 1), TASK, 0, "testit2", false))) {
 			TPRINTF("could not create thread %u\n", 2 * i + 1);
 			break;
Index: kernel/test/fpu/sse1.c
===================================================================
--- kernel/test/fpu/sse1.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/test/fpu/sse1.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -48,5 +48,5 @@
 {
 	int i;
-	int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
+	int arg __attribute__((aligned(16))) = (int) ((sysarg_t) data);
 	int after_arg __attribute__((aligned(16)));
 	
@@ -79,5 +79,5 @@
 {
 	int i;
-	int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
+	int arg __attribute__((aligned(16))) = (int) ((sysarg_t) data);
 	int after_arg __attribute__((aligned(16)));
 	
@@ -121,5 +121,5 @@
 		thread_t *t;
 		
-		if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) {
+		if (!(t = thread_create(testit1, (void *) ((sysarg_t) 2 * i), TASK, 0, "testit1", false))) {
 			TPRINTF("could not create thread %u\n", 2 * i);
 			break;
@@ -128,5 +128,5 @@
 		total++;
 		
-		if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) {
+		if (!(t = thread_create(testit2, (void *) ((sysarg_t) 2 * i + 1), TASK, 0, "testit2", false))) {
 			TPRINTF("could not create thread %u\n", 2 * i + 1);
 			break;
Index: kernel/test/mm/slab1.c
===================================================================
--- kernel/test/mm/slab1.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/test/mm/slab1.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -123,5 +123,5 @@
 static void slabtest(void *data)
 {
-	int offs = (int) (unative_t) data;
+	int offs = (int) (sysarg_t) data;
 	int i, j;
 	
@@ -156,5 +156,5 @@
 	semaphore_initialize(&thr_sem, 0);
 	for (i = 0; i < THREADS; i++) {  
-		if (!(t = thread_create(slabtest, (void *) (unative_t) i, TASK, 0, "slabtest", false))) {
+		if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, 0, "slabtest", false))) {
 			TPRINTF("Could not create thread %d\n", i);
 		} else
Index: kernel/test/print/print2.c
===================================================================
--- kernel/test/print/print2.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ kernel/test/print/print2.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -48,5 +48,5 @@
 	TPRINTF("Real output:     [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21);
 	
-	unative_t nat = UINTN_C(0x12345678);
+	sysarg_t nat = UINTN_C(0x12345678);
 	
 	TPRINTF("Testing printf(\"%%#" PRIx64 " %%#" PRIx32 " %%#" PRIx16 " %%#" PRIx8 " %%#" PRIxn " %%#" PRIx64 " %%s\", (uint64_t) UINT64_C(0x1234567887654321), (uint32_t) UINT32_C(0x12345678), (uint16_t) UINT16_C(0x1234), (uint8_t) UINT8_C(0x12), nat, (uint64_t) UINT64_C(0x1234567887654321), \"Lovely string\"):\n");
Index: uspace/app/edit/edit.c
===================================================================
--- uspace/app/edit/edit.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/edit/edit.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -100,6 +100,6 @@
 static bool cursor_visible;
 
-static ipcarg_t scr_rows;
-static ipcarg_t scr_columns;
+static sysarg_t scr_rows;
+static sysarg_t scr_columns;
 
 #define ROW_BUF_SIZE 4096
@@ -684,5 +684,5 @@
 	
 	int i;
-	ipcarg_t j;
+	sysarg_t j;
 	for (i = rows; i < pane.rows; ++i) {
 		console_set_pos(con, 0, i);
Index: uspace/app/tester/hw/serial/serial1.c
===================================================================
--- uspace/app/tester/hw/serial/serial1.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/tester/hw/serial/serial1.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -93,8 +93,8 @@
 	}
 	
-	ipcarg_t old_baud;
-	ipcarg_t old_par;
-	ipcarg_t old_stop;
-	ipcarg_t old_word_size;
+	sysarg_t old_baud;
+	sysarg_t old_par;
+	sysarg_t old_stop;
+	sysarg_t old_word_size;
 	
 	res = ipc_call_sync_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud,
Index: uspace/app/tester/ipc/register.c
===================================================================
--- uspace/app/tester/ipc/register.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/tester/ipc/register.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -56,5 +56,5 @@
 		int retval;
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			TPRINTF("Phone %" PRIun " hung up\n", icall->in_phone_hash);
@@ -79,5 +79,5 @@
 	async_set_client_connection(client_connection);
 	
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	int res = ipc_connect_to_me(PHONE_NS, IPC_TEST_SERVICE, 0, 0, &phonead);
 	if (res != 0)
Index: uspace/app/tetris/input.c
===================================================================
--- uspace/app/tetris/input.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/tetris/input.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -97,5 +97,5 @@
 	struct timeval starttv, endtv, *s;
 	static ipc_call_t charcall;
-	ipcarg_t rc;
+	sysarg_t rc;
 	
 	/*
Index: uspace/app/tetris/screen.c
===================================================================
--- uspace/app/tetris/screen.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/tetris/screen.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -120,5 +120,5 @@
 }
 
-void moveto(ipcarg_t r, ipcarg_t c)
+void moveto(sysarg_t r, sysarg_t c)
 {
 	fflush(stdout);
@@ -135,5 +135,5 @@
 static bool get_display_color_sup(void)
 {
-	ipcarg_t ccap;
+	sysarg_t ccap;
 	int rc = console_get_color_cap(fphone(stdout), &ccap);
 	
Index: uspace/app/tetris/screen.h
===================================================================
--- uspace/app/tetris/screen.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/tetris/screen.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -53,11 +53,11 @@
 
 typedef struct {
-	ipcarg_t ws_row;
-	ipcarg_t ws_col;
+	sysarg_t ws_row;
+	sysarg_t ws_col;
 } winsize_t;
 
 extern winsize_t winsize;
 
-extern void moveto(ipcarg_t r, ipcarg_t c);
+extern void moveto(sysarg_t r, sysarg_t c);
 extern void clear_screen(void);
 
Index: uspace/app/top/input.c
===================================================================
--- uspace/app/top/input.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/top/input.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -99,5 +99,5 @@
 	struct timeval starttv, endtv, *s;
 	static ipc_call_t charcall;
-	ipcarg_t rc;
+	sysarg_t rc;
 	
 	/*
Index: uspace/app/top/screen.c
===================================================================
--- uspace/app/top/screen.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/top/screen.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -47,6 +47,6 @@
 #include "top.h"
 
-static ipcarg_t warn_col = 0;
-static ipcarg_t warn_row = 0;
+static sysarg_t warn_col = 0;
+static sysarg_t warn_row = 0;
 
 static void screen_style_normal(void)
@@ -62,5 +62,5 @@
 }
 
-static void screen_moveto(ipcarg_t col, ipcarg_t row)
+static void screen_moveto(sysarg_t col, sysarg_t row)
 {
 	fflush(stdout);
@@ -68,5 +68,5 @@
 }
 
-static void screen_get_pos(ipcarg_t *col, ipcarg_t *row)
+static void screen_get_pos(sysarg_t *col, sysarg_t *row)
 {
 	fflush(stdout);
@@ -74,5 +74,5 @@
 }
 
-static void screen_get_size(ipcarg_t *col, ipcarg_t *row)
+static void screen_get_size(sysarg_t *col, sysarg_t *row)
 {
 	fflush(stdout);
@@ -94,13 +94,13 @@
 static void screen_newline(void)
 {
-	ipcarg_t cols;
-	ipcarg_t rows;
+	sysarg_t cols;
+	sysarg_t rows;
 	screen_get_size(&cols, &rows);
 	
-	ipcarg_t c;
-	ipcarg_t r;
+	sysarg_t c;
+	sysarg_t r;
 	screen_get_pos(&c, &r);
 	
-	ipcarg_t i;
+	sysarg_t i;
 	for (i = c + 1; i < cols; i++)
 		puts(" ");
@@ -142,10 +142,10 @@
 static void print_string(const char *str)
 {
-	ipcarg_t cols;
-	ipcarg_t rows;
+	sysarg_t cols;
+	sysarg_t rows;
 	screen_get_size(&cols, &rows);
 	
-	ipcarg_t c;
-	ipcarg_t r;
+	sysarg_t c;
+	sysarg_t r;
 	screen_get_pos(&c, &r);
 	
@@ -282,10 +282,10 @@
 static inline void print_tasks(data_t *data)
 {
-	ipcarg_t cols;
-	ipcarg_t rows;
+	sysarg_t cols;
+	sysarg_t rows;
 	screen_get_size(&cols, &rows);
 	
-	ipcarg_t col;
-	ipcarg_t row;
+	sysarg_t col;
+	sysarg_t row;
 	screen_get_pos(&col, &row);
 	
@@ -329,10 +329,10 @@
 static inline void print_ipc(data_t *data)
 {
-	ipcarg_t cols;
-	ipcarg_t rows;
+	sysarg_t cols;
+	sysarg_t rows;
 	screen_get_size(&cols, &rows);
 	
-	ipcarg_t col;
-	ipcarg_t row;
+	sysarg_t col;
+	sysarg_t row;
 	screen_get_pos(&col, &row);
 	
@@ -396,10 +396,10 @@
 static inline void print_excs(data_t *data)
 {
-	ipcarg_t cols;
-	ipcarg_t rows;
+	sysarg_t cols;
+	sysarg_t rows;
 	screen_get_size(&cols, &rows);
 	
-	ipcarg_t col;
-	ipcarg_t row;
+	sysarg_t col;
+	sysarg_t row;
 	screen_get_pos(&col, &row);
 	
@@ -439,10 +439,10 @@
 static void print_help(void)
 {
-	ipcarg_t cols;
-	ipcarg_t rows;
+	sysarg_t cols;
+	sysarg_t rows;
 	screen_get_size(&cols, &rows);
 	
-	ipcarg_t col;
-	ipcarg_t row;
+	sysarg_t col;
+	sysarg_t row;
 	screen_get_pos(&col, &row);
 	
Index: uspace/app/trace/ipcp.c
===================================================================
--- uspace/app/trace/ipcp.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/trace/ipcp.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -46,5 +46,5 @@
 
 typedef struct {
-	ipcarg_t phone_hash;
+	sysarg_t phone_hash;
 	ipc_call_t question;
 	oper_t *oper;
@@ -124,5 +124,5 @@
 }
 
-static void ipc_m_print(proto_t *proto, ipcarg_t method)
+static void ipc_m_print(proto_t *proto, sysarg_t method)
 {
 	oper_t *oper;
@@ -192,5 +192,5 @@
 	unsigned long key[1];
 	oper_t *oper;
-	ipcarg_t *args;
+	sysarg_t *args;
 	int i;
 
@@ -204,5 +204,5 @@
 		    (void *) hash, phone,
 		    (proto ? proto->name : "n/a"));
-		ipc_m_print(proto, IPC_GET_METHOD(*call));
+		ipc_m_print(proto, IPC_GET_IMETHOD(*call));
 		printf(" args: (%" PRIun ", %" PRIun ", %" PRIun ", "
 		    "%" PRIun ", %" PRIun ")\n",
@@ -214,5 +214,5 @@
 
 		if (proto != NULL) {
-			oper = proto_get_oper(proto, IPC_GET_METHOD(*call));
+			oper = proto_get_oper(proto, IPC_GET_IMETHOD(*call));
 		} else {
 			oper = NULL;
@@ -262,12 +262,12 @@
     ipc_call_t *answer)
 {
-	ipcarg_t phone;
-	ipcarg_t method;
-	ipcarg_t service;
-	ipcarg_t retval;
+	sysarg_t phone;
+	sysarg_t method;
+	sysarg_t service;
+	sysarg_t retval;
 	proto_t *proto;
 	int cphone;
 
-	ipcarg_t *resp;
+	sysarg_t *resp;
 	oper_t *oper;
 	int i;
@@ -276,5 +276,5 @@
 
 	phone = pcall->phone_hash;
-	method = IPC_GET_METHOD(pcall->question);
+	method = IPC_GET_IMETHOD(pcall->question);
 	retval = IPC_GET_RETVAL(*answer);
 
Index: uspace/app/trace/proto.c
===================================================================
--- uspace/app/trace/proto.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/trace/proto.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -53,5 +53,5 @@
 
 typedef struct {
-	ipcarg_t method;
+	sysarg_t method;
 	oper_t *oper;
 	link_t link;
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/trace/trace.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -287,5 +287,5 @@
 {
 	ipc_call_t call;
-	ipcarg_t phoneid;
+	sysarg_t phoneid;
 	
 	if (sc_rc == (sysarg_t) IPC_CALLRET_FATAL ||
@@ -295,5 +295,5 @@
 	phoneid = sc_args[0];
 
-	IPC_SET_METHOD(call, sc_args[1]);
+	IPC_SET_IMETHOD(call, sc_args[1]);
 	IPC_SET_ARG1(call, sc_args[2]);
 	IPC_SET_ARG2(call, sc_args[3]);
@@ -331,5 +331,5 @@
 	phoneidx = sc_args[0];
 
-	IPC_SET_METHOD(question, sc_args[1]);
+	IPC_SET_IMETHOD(question, sc_args[1]);
 	IPC_SET_ARG1(question, sc_args[2]);
 	IPC_SET_ARG2(question, sc_args[3]);
Index: uspace/app/usbinfo/dump.c
===================================================================
--- uspace/app/usbinfo/dump.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/usbinfo/dump.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -69,4 +69,17 @@
 }
 
+void dump_match_ids(match_id_list_t *matches)
+{
+	printf("Match ids:\n");
+	link_t *link;
+	for (link = matches->ids.next;
+	    link != &matches->ids;
+	    link = link->next) {
+		match_id_t *match = list_get_instance(link, match_id_t, link);
+
+		printf(INDENT "%d %s\n", match->score, match->id);
+	}
+}
+
 void dump_standard_device_descriptor(usb_standard_device_descriptor_t *d)
 {
Index: uspace/app/usbinfo/main.c
===================================================================
--- uspace/app/usbinfo/main.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/usbinfo/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -112,4 +112,18 @@
 
 	/*
+	 * Dump information about possible match ids.
+	 */
+	match_id_list_t match_id_list;
+	init_match_ids(&match_id_list);
+	rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address);
+	if (rc != EOK) {
+		fprintf(stderr,
+		    NAME ": failed to fetch match ids of the device: %s.\n",
+		    str_error(rc));
+		return rc;
+	}
+	dump_match_ids(&match_id_list);
+
+	/*
 	 * Get device descriptor and dump it.
 	 */
Index: uspace/app/usbinfo/usbinfo.h
===================================================================
--- uspace/app/usbinfo/usbinfo.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/usbinfo/usbinfo.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -39,4 +39,5 @@
 #include <usb/descriptor.h>
 #include <usb/debug.h>
+#include <ipc/devman.h>
 
 
@@ -44,4 +45,5 @@
 
 void dump_buffer(const char *, const uint8_t *, size_t);
+void dump_match_ids(match_id_list_t *matches);
 void dump_standard_device_descriptor(usb_standard_device_descriptor_t *);
 void dump_standard_configuration_descriptor(int, 
Index: uspace/app/virtusbkbd/Makefile
===================================================================
--- uspace/app/virtusbkbd/Makefile	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/virtusbkbd/Makefile	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -33,5 +33,5 @@
 
 LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBUSBVIRT_PREFIX)/libusbvirt.a
-EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIB_PREFIX) -I$(LIBDRV_PREFIX)/include
+EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBUSBVIRT_PREFIX)/include -I$(LIBDRV_PREFIX)/include
 
 SOURCES = \
Index: uspace/app/virtusbkbd/stdreq.c
===================================================================
--- uspace/app/virtusbkbd/stdreq.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/virtusbkbd/stdreq.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -39,23 +39,5 @@
 #include "kbdconfig.h"
 
-static int on_get_descriptor(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data);
-
-usbvirt_standard_device_request_ops_t standard_request_ops = {
-	.on_get_status = NULL,
-	.on_clear_feature = NULL,
-	.on_set_feature = NULL,
-	.on_set_address = NULL,
-	.on_get_descriptor = on_get_descriptor,
-	.on_set_descriptor = NULL,
-	.on_get_configuration = NULL,
-	.on_set_configuration = NULL,
-	.on_get_interface = NULL,
-	.on_set_interface = NULL,
-	.on_synch_frame = NULL
-};
-
-
-static int on_get_descriptor(struct usbvirt_device *dev,
+int stdreq_on_get_descriptor(struct usbvirt_device *dev,
     usb_device_request_setup_packet_t *request, uint8_t *data)
 {
Index: uspace/app/virtusbkbd/stdreq.h
===================================================================
--- uspace/app/virtusbkbd/stdreq.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/virtusbkbd/stdreq.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -38,5 +38,6 @@
 #include <usbvirt/device.h>
 
-extern usbvirt_standard_device_request_ops_t standard_request_ops;
+int stdreq_on_get_descriptor(usbvirt_device_t *,
+    usb_device_request_setup_packet_t *, uint8_t *);
 
 #endif
Index: uspace/app/virtusbkbd/virtusbkbd.c
===================================================================
--- uspace/app/virtusbkbd/virtusbkbd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/app/virtusbkbd/virtusbkbd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -55,5 +55,6 @@
 #include "stdreq.h"
 
-#define LOOPS 5
+/** Pause between individual key-presses in seconds. */
+#define KEY_PRESS_DELAY 2
 #define NAME "virt-usb-kbd"
 
@@ -75,10 +76,26 @@
 }
 
-static int on_class_request(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data)
-{	
-	printf("%s: class request (%d)\n", NAME, (int) request->request);
-	
-	return EOK;
+
+/** Compares current and last status of pressed keys.
+ *
+ * @warning Has side-efect - changes status_last field.
+ *
+ * @param status_now Status now.
+ * @param status_last Last status.
+ * @param len Size of status.
+ * @return Whether they are the same.
+ */
+static bool keypress_check_with_last_request(uint8_t *status_now,
+    uint8_t *status_last, size_t len)
+{
+	bool same = true;
+	size_t i;
+	for (i = 0; i < len; i++) {
+		if (status_now[i] != status_last[i]) {
+			status_last[i] = status_now[i];
+			same = false;
+		}
+	}
+	return same;
 }
 
@@ -86,4 +103,6 @@
     usb_endpoint_t endpoint, void *buffer, size_t size, size_t *actual_size)
 {
+	static uint8_t last_data[2 + KB_MAX_KEYS_AT_ONCE];
+
 	if (size < 2 + KB_MAX_KEYS_AT_ONCE) {
 		return EINVAL;
@@ -101,4 +120,10 @@
 	}
 	
+	if (keypress_check_with_last_request(data, last_data,
+	    2 + KB_MAX_KEYS_AT_ONCE)) {
+		*actual_size = 0;
+		return EOK;
+	}
+
 	memcpy(buffer, &data, *actual_size);
 	
@@ -106,4 +131,25 @@
 }
 
+static usbvirt_control_transfer_handler_t endpoint_zero_handlers[] = {
+	{
+		.request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(
+		    USB_DIRECTION_IN,
+		    USBVIRT_REQUEST_TYPE_STANDARD,
+		    USBVIRT_REQUEST_RECIPIENT_DEVICE),
+		.request = USB_DEVREQ_GET_DESCRIPTOR,
+		.name = "GetDescriptor",
+		.callback = stdreq_on_get_descriptor
+	},
+	{
+		.request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(
+		    USB_DIRECTION_IN,
+		    USBVIRT_REQUEST_TYPE_CLASS,
+		    USBVIRT_REQUEST_RECIPIENT_DEVICE),
+		.request = USB_DEVREQ_GET_DESCRIPTOR,
+		.name = "GetDescriptor",
+		.callback = stdreq_on_get_descriptor
+	},
+	USBVIRT_CONTROL_TRANSFER_HANDLER_LAST
+};
 
 /** Keyboard callbacks.
@@ -111,6 +157,5 @@
  */
 static usbvirt_device_ops_t keyboard_ops = {
-	.standard_request_ops = &standard_request_ops,
-	.on_class_device_request = on_class_request,
+	.control_transfer_handlers = endpoint_zero_handlers,
 	.on_data = on_incoming_data,
 	.on_data_request = on_request_for_data
@@ -152,4 +197,6 @@
 	.ops = &keyboard_ops,
 	.descriptors = &descriptors,
+	.lib_debug_level = 3,
+	.lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL,
 	.name = "keyboard"
 };
@@ -177,5 +224,5 @@
 	printf("\n");
 	
-	fibril_sleep(1);
+	fibril_sleep(KEY_PRESS_DELAY);
 }
 
@@ -223,6 +270,9 @@
 	
 	printf("%s: Simulating keyboard events...\n", NAME);
-	kb_process_events(&status, keyboard_events, keyboard_events_count,
-	    on_keyboard_change);
+	fibril_sleep(10);
+	while (1) {
+		kb_process_events(&status, keyboard_events, keyboard_events_count,
+			on_keyboard_change);
+	}
 	
 	printf("%s: Terminating...\n", NAME);
Index: uspace/drv/ns8250/ns8250.c
===================================================================
--- uspace/drv/ns8250/ns8250.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/ns8250/ns8250.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -887,5 +887,5 @@
     ipc_call_t *call)
 {
-	ipcarg_t method = IPC_GET_METHOD(*call);
+	sysarg_t method = IPC_GET_IMETHOD(*call);
 	int ret;
 	unsigned int baud_rate, parity, word_length, stop_bits;
Index: uspace/drv/uhci/main.c
===================================================================
--- uspace/drv/uhci/main.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/uhci/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -29,4 +29,5 @@
 #include <usb/debug.h>
 #include <errno.h>
+#include <driver.h>
 #include "uhci.h"
 
Index: uspace/drv/usbhub/main.c
===================================================================
--- uspace/drv/usbhub/main.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/usbhub/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -26,7 +26,10 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#include <usb/usbdrv.h>
+
 #include <driver.h>
 #include <errno.h>
+#include <async.h>
+
+#include <usb/usbdrv.h>
 #include "usbhub.h"
 #include "usbhub_private.h"
@@ -44,7 +47,23 @@
 };
 
+int usb_hub_control_loop(void * noparam){
+	while(true){
+		usb_hub_check_hub_changes();
+		async_usleep(1000 * 1000);
+	}
+	return 0;
+}
+
+
 int main(int argc, char *argv[])
 {
 	usb_lst_init(&usb_hub_list);
+	fid_t fid = fibril_create(usb_hub_control_loop, NULL);
+	if (fid == 0) {
+		printf("%s: failed to start fibril for HUB devices\n", NAME);
+		return ENOMEM;
+	}
+	fibril_add_ready(fid);
+
 	return driver_main(&hub_driver);
 }
Index: uspace/drv/usbhub/port_status.h
===================================================================
--- uspace/drv/usbhub/port_status.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/usbhub/port_status.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -55,5 +55,5 @@
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_GET_PORT_STATUS;
-	request->request = USB_HUB_REQUEST_GET_STATE;
+	request->request = USB_HUB_REQUEST_GET_STATUS;
 	request->value = 0;
 	request->length = 4;
Index: uspace/drv/usbhub/usbhub.h
===================================================================
--- uspace/drv/usbhub/usbhub.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/usbhub/usbhub.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,5 +40,9 @@
 #include "usb/hcdhubd.h"
 
-
+/** basic information about device attached to hub */
+typedef struct{
+	usb_address_t address;
+	devman_handle_t devman_handle;
+}usb_hub_attached_device_t;
 
 /** Information about attached hub. */
@@ -46,9 +50,35 @@
 	/** Number of ports. */
 	int port_count;
-	/** General device info. */
-	usb_hcd_attached_device_info_t * device;
+	/** attached device handles */
+	usb_hub_attached_device_t * attached_devs;
+	/** General usb device info. */
+	usb_hcd_attached_device_info_t * usb_device;
+	/** General device info*/
+	device_t * device;
+
 } usb_hub_info_t;
 
-int usb_add_hub_device(device_t *);
+/**
+ * function running the hub-controlling loop.
+ * @param noparam fundtion does not need any parameters
+ */
+int usb_hub_control_loop(void * noparam);
+
+/** Callback when new hub device is detected.
+ *
+ * @param dev New device.
+ * @return Error code.
+ */
+int usb_add_hub_device(device_t *dev);
+
+/**
+ * check changes on all registered hubs
+ */
+void usb_hub_check_hub_changes(void);
+
+
+//int usb_add_hub_device(device_t *);
+
+
 
 #endif
Index: uspace/drv/usbhub/usbhub.ma
===================================================================
--- uspace/drv/usbhub/usbhub.ma	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/usbhub/usbhub.ma	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,1 +1,2 @@
 10 usb&hub
+10 usb&class=hub
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/usbhub/usbhub_private.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -182,4 +182,22 @@
 }
 
+static inline int usb_hub_clear_port_feature(int hc, usb_address_t address,
+    int port_index,
+    usb_hub_class_feature_t feature) {
+	usb_target_t target = {
+		.address = address,
+		.endpoint = 0
+	};
+	usb_device_request_setup_packet_t clear_request = {
+		.request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
+		.request = USB_DEVREQ_CLEAR_FEATURE,
+		.length = 0,
+		.index = port_index
+	};
+	clear_request.value = feature;
+	return usb_drv_psync_control_write(hc, target, &clear_request,
+	    sizeof(clear_request), NULL, 0);
+}
+
 
 
Index: uspace/drv/usbhub/utils.c
===================================================================
--- uspace/drv/usbhub/utils.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/usbhub/utils.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,18 +34,17 @@
  */
 #include <driver.h>
-#include <usb/devreq.h>
+#include <bool.h>
+#include <errno.h>
+
 #include <usbhc_iface.h>
 #include <usb/usbdrv.h>
 #include <usb/descriptor.h>
-#include <driver.h>
-#include <bool.h>
-#include <errno.h>
+#include <usb/devreq.h>
 #include <usb/classes/hub.h>
+
 #include "usbhub.h"
 #include "usbhub_private.h"
 #include "port_status.h"
-#include <usb/devreq.h>
-
-static void check_hub_changes(void);
+
 
 size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71;
@@ -302,4 +301,6 @@
 	//result->device = device;
 	result->port_count = -1;
+	/// \TODO is this correct? is the device stored?
+	result->device = device;
 
 
@@ -316,6 +317,6 @@
 	}*/
 
-	result->device = usb_new(usb_hcd_attached_device_info_t);
-	result->device->address = addr;
+	result->usb_device = usb_new(usb_hcd_attached_device_info_t);
+	result->usb_device->address = addr;
 
 	// get hub descriptor
@@ -350,4 +351,11 @@
 	//printf("[usb_hub] setting port count to %d\n",descriptor->ports_count);
 	result->port_count = descriptor->ports_count;
+	result->attached_devs = (usb_hub_attached_device_t*)
+	    malloc((result->port_count+1) * sizeof(usb_hub_attached_device_t));
+	int i;
+	for(i=0;i<result->port_count+1;++i){
+		result->attached_devs[i].devman_handle=0;
+		result->attached_devs[i].address=0;
+	}
 	//printf("[usb_hub] freeing data\n");
 	free(serialized_descriptor);
@@ -362,9 +370,4 @@
 }
 
-/** Callback when new hub device is detected.
- *
- * @param dev New device.
- * @return Error code.
- */
 int usb_add_hub_device(device_t *dev) {
 	printf(NAME ": add_hub_device(handle=%d)\n", (int) dev->handle);
@@ -387,9 +390,46 @@
 	usb_device_request_setup_packet_t request;
 	usb_target_t target;
-	target.address = hub_info->device->address;
+	target.address = hub_info->usb_device->address;
 	target.endpoint = 0;
-	for (port = 0; port < hub_info->port_count; ++port) {
+
+	//get configuration descriptor
+	// this is not fully correct - there are more configurations
+	// and all should be checked
+	usb_standard_device_descriptor_t std_descriptor;
+	opResult = usb_drv_req_get_device_descriptor(hc, target.address,
+    &std_descriptor);
+	if(opResult!=EOK){
+		printf("[usb_hub] could not get device descriptor, %d\n",opResult);
+		return 1;///\TODO some proper error code needed
+	}
+	printf("[usb_hub] hub has %d configurations\n",std_descriptor.configuration_count);
+	if(std_descriptor.configuration_count<1){
+		printf("[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE\n");
+	}
+	usb_standard_configuration_descriptor_t config_descriptor;
+	opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
+        target.address, 0,
+        &config_descriptor);
+	if(opResult!=EOK){
+		printf("[usb_hub] could not get configuration descriptor, %d\n",opResult);
+		return 1;///\TODO some proper error code needed
+	}
+	//set configuration
+	request.request_type = 0;
+	request.request = USB_DEVREQ_SET_CONFIGURATION;
+	request.index=0;
+	request.length=0;
+	request.value_high=0;
+	request.value_low = config_descriptor.configuration_number;
+	opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
+	if (opResult != EOK) {
+		printf("[usb_hub]something went wrong when setting hub`s configuration, %d\n", opResult);
+	}
+
+
+	for (port = 1; port < hub_info->port_count+1; ++port) {
 		usb_hub_set_power_port_request(&request, port);
 		opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
+		printf("[usb_hub] powering port %d\n",port);
 		if (opResult != EOK) {
 			printf("[usb_hub]something went wrong when setting hub`s %dth port\n", port);
@@ -397,4 +437,5 @@
 	}
 	//ports powered, hub seems to be enabled
+	
 
 	ipc_hangup(hc);
@@ -404,5 +445,5 @@
 	printf("[usb_hub] hub info added to list\n");
 	//(void)hub_info;
-	check_hub_changes();
+	usb_hub_check_hub_changes();
 
 	/// \TODO start the check loop, if not already started...
@@ -412,4 +453,8 @@
 
 	printf("[usb_hub] hub dev added\n");
+	printf("\taddress %d, has %d ports \n",
+			hub_info->usb_device->address,
+			hub_info->port_count);
+	printf("\tused configuration %d\n",config_descriptor.configuration_number);
 
 	return EOK;
@@ -429,10 +474,9 @@
  * @param target
  */
-
 static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
 	usb_device_request_setup_packet_t request;
 	int opResult;
 	printf("[usb_hub] some connection changed\n");
-
+	//get default address
 	opResult = usb_drv_reserve_default_address(hc);
 	if (opResult != EOK) {
@@ -459,14 +503,70 @@
  * @param target
  */
-static void usb_hub_finalize_add_device(
+static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
 		int hc, uint16_t port, usb_target_t target) {
 
-	usb_device_request_setup_packet_t request;
 	int opResult;
 	printf("[usb_hub] finalizing add device\n");
-	usb_address_t new_device_address =
-			usb_drv_request_address(hc);
-	usb_hub_set_set_address_request
-			(&request, new_device_address);
+	opResult = usb_hub_clear_port_feature(hc, target.address,
+	    port, USB_HUB_FEATURE_C_PORT_RESET);
+	if (opResult != EOK) {
+		goto release;
+	}
+
+	/* Request address at from host controller. */
+	usb_address_t new_device_address = usb_drv_request_address(hc);
+	if (new_device_address < 0) {
+		printf("[usb_hub] failed to get free USB address\n");
+		opResult = new_device_address;
+		goto release;
+	}
+	printf("[usb_hub] setting new address\n");
+	opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
+	    new_device_address);
+
+	if (opResult != EOK) {
+		printf("[usb_hub] could not set address for new device\n");
+		goto release;
+	}
+
+release:
+	printf("[usb_hub] releasing default address\n");
+	usb_drv_release_default_address(hc);
+	if (opResult != EOK) {
+		return;
+	}
+
+	devman_handle_t child_handle;
+	opResult = usb_drv_register_child_in_devman(hc, hub->device,
+            new_device_address, &child_handle);
+	if (opResult != EOK) {
+		printf("[usb_hub] could not start driver for new device \n");
+		return;
+	}
+	hub->attached_devs[port].devman_handle = child_handle;
+	hub->attached_devs[port].address = new_device_address;
+
+	opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
+	if (opResult != EOK) {
+		printf("[usb_hub] could not assign address of device in hcd \n");
+		return;
+	}
+	printf("[usb_hub] new device address %d, handle %zu\n",
+	    new_device_address, child_handle);
+	
+}
+
+/**
+ * unregister device address in hc, close the port
+ * @param hc
+ * @param port
+ * @param target
+ */
+static void usb_hub_removed_device(
+    usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
+	//usb_device_request_setup_packet_t request;
+	int opResult;
+	//disable port
+	/*usb_hub_set_disable_port_request(&request, port);
 	opResult = usb_drv_sync_control_write(
 			hc, target,
@@ -475,40 +575,22 @@
 			);
 	if (opResult != EOK) {
-		printf("[usb_hub] could not set address for new device\n");
-		//will retry later...
-		return;
-	}
-	usb_drv_release_default_address(hc);
-
-
-	/// \TODO driver work
-	//add_child_device.....
-}
-
-/**
- * unregister device address in hc, close the port
- * @param hc
- * @param port
- * @param target
- */
-static void usb_hub_removed_device(int hc, uint16_t port, usb_target_t target) {
-	usb_device_request_setup_packet_t request;
-	int opResult;
-	//disable port
-	usb_hub_set_disable_port_request(&request, port);
-	opResult = usb_drv_sync_control_write(
-			hc, target,
-			&request,
-			NULL, 0
-			);
-	if (opResult != EOK) {
 		//continue;
 		printf("[usb_hub] something went wrong when disabling a port\n");
-	}
-	//remove device
+	}*/
+	/// \TODO remove device
+
+	hub->attached_devs[port].devman_handle=0;
 	//close address
-	//
-
-	///\TODO this code is not complete
+	if(hub->attached_devs[port].address!=0){
+		opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
+		if(opResult != EOK) {
+			printf("[usb_hub] could not release address of removed device: %d\n",opResult);
+		}
+		hub->attached_devs[port].address = 0;
+	}else{
+		printf("[usb_hub] this is strange, disconnected device had no address\n");
+		//device was disconnected before it`s port was reset - return default address
+		usb_drv_release_default_address(hc);
+	}
 }
 
@@ -519,7 +601,11 @@
  * @param target
  */
-static void usb_hub_process_interrupt(int hc, uint16_t port, usb_target_t target) {
+static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
+        uint16_t port, usb_address_t address) {
 	printf("[usb_hub] interrupt at port %d\n", port);
 	//determine type of change
+	usb_target_t target;
+	target.address=address;
+	target.endpoint=0;
 	usb_port_status_t status;
 	size_t rcvd_size;
@@ -527,4 +613,5 @@
 	int opResult;
 	usb_hub_set_port_status_request(&request, port);
+	//endpoint 0
 
 	opResult = usb_drv_sync_control_read(
@@ -543,16 +630,19 @@
 	//something connected/disconnected
 	if (usb_port_connect_change(&status)) {
+		opResult = usb_hub_clear_port_feature(hc, target.address,
+		    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
+		// TODO: check opResult
 		if (usb_port_dev_connected(&status)) {
 			printf("[usb_hub] some connection changed\n");
 			usb_hub_init_add_device(hc, port, target);
 		} else {
-			usb_hub_removed_device(hc, port, target);
+			usb_hub_removed_device(hub, hc, port, target);
 		}
 	}
 	//port reset
 	if (usb_port_reset_completed(&status)) {
-		printf("[usb_hub] finalizing add device\n");
+		printf("[usb_hub] port reset complete\n");
 		if (usb_port_enabled(&status)) {
-			usb_hub_finalize_add_device(hc, port, target);
+			usb_hub_finalize_add_device(hub, hc, port, target);
 		} else {
 			printf("[usb_hub] ERROR: port reset, but port still not enabled\n");
@@ -565,5 +655,5 @@
 	usb_port_set_dev_connected(&status, false);
 	if (status) {
-		printf("[usb_hub]there was some unsupported change on port\n");
+		printf("[usb_hub]there was some unsupported change on port %d\n",port);
 	}
 	/// \TODO handle other changes
@@ -585,5 +675,5 @@
 /** Check changes on all known hubs.
  */
-static void check_hub_changes(void) {
+void usb_hub_check_hub_changes(void) {
 	/*
 	 * Iterate through all hubs.
@@ -593,25 +683,21 @@
 			lst_item != &usb_hub_list;
 			lst_item = lst_item->next) {
-		printf("[usb_hub] checking hub changes\n");
+		usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
 		/*
 		 * Check status change pipe of this hub.
 		 */
 
-		usb_target_t target = {
-			.address = 5,
-			.endpoint = 1
-		};
-		/// \TODO uncomment once it works correctly
-		//target.address = usb_create_hub_info(lst_item)->device->address;
-
-		size_t port_count = 7;
+		usb_target_t target;
+		target.address = hub_info->usb_device->address;
+		target.endpoint = 1;/// \TODO get from endpoint descriptor
+		printf("[usb_hub] checking changes for hub at addr %d\n",
+		    target.address);
+
+		size_t port_count = hub_info->port_count;
 
 		/*
 		 * Connect to respective HC.
 		 */
-		/// \FIXME this is incorrect code: here
-		/// must be used particular device instead of NULL
-		//which one?
-		int hc = usb_drv_hc_connect(NULL, 0);
+		int hc = usb_drv_hc_connect(hub_info->device, 0);
 		if (hc < 0) {
 			continue;
@@ -619,5 +705,5 @@
 
 		// FIXME: count properly
-		size_t byte_length = (port_count / 8) + 1;
+		size_t byte_length = ((port_count+1) / 8) + 1;
 
 		void *change_bitmap = malloc(byte_length);
@@ -639,8 +725,9 @@
 		}
 		unsigned int port;
-		for (port = 0; port < port_count; ++port) {
+		for (port = 1; port < port_count+1; ++port) {
 			bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
 			if (interrupt) {
-				usb_hub_process_interrupt(hc, port, target);
+				usb_hub_process_interrupt(
+				        hub_info, hc, port, hub_info->usb_device->address);
 			}
 		}
Index: uspace/drv/usbkbd/main.c
===================================================================
--- uspace/drv/usbkbd/main.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/usbkbd/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,5 +40,5 @@
 #define NAME "usbkbd"
 
-static const usb_endpoint_t CONTROL_EP = 0;
+#define GUESSED_POLL_ENDPOINT 1
 
 /*
@@ -130,5 +130,5 @@
 
 	// default endpoint
-	kbd_dev->default_ep = CONTROL_EP;
+	kbd_dev->poll_endpoint = GUESSED_POLL_ENDPOINT;
 	
 	/*
@@ -178,8 +178,9 @@
 	usb_target_t poll_target = {
 		.address = kbd_dev->address,
-		.endpoint = kbd_dev->default_ep
+		.endpoint = kbd_dev->poll_endpoint
 	};
 
 	while (true) {
+		async_usleep(1000 * 1000);
 		rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone,
 		    poll_target, buffer, BUFFER_SIZE, &actual_size, &handle);
Index: uspace/drv/usbkbd/usbkbd.ma
===================================================================
--- uspace/drv/usbkbd/usbkbd.ma	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/usbkbd/usbkbd.ma	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1,2 +1,4 @@
 10 usb&class=hid
+10 usb&class=HID
+10 usb&interface&class=HID
 10 usb&hid
Index: uspace/drv/vhc/Makefile
===================================================================
--- uspace/drv/vhc/Makefile	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/Makefile	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -33,5 +33,5 @@
 	$(LIBDRV_PREFIX)/libdrv.a
 EXTRA_CFLAGS += \
-	-I$(LIB_PREFIX) \
+	-I$(LIBUSBVIRT_PREFIX)/include \
 	-I$(LIBUSB_PREFIX)/include \
 	-I$(LIBDRV_PREFIX)/include
@@ -39,4 +39,7 @@
 
 SOURCES = \
+	hub/hub.c \
+	hub/virthub.c \
+	hub/virthubops.c \
 	conndev.c \
 	connhost.c \
@@ -45,6 +48,5 @@
 	hc.c \
 	hcd.c \
-	hub.c \
-	hubops.c
+	hub.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/vhc/conn.h
===================================================================
--- uspace/drv/vhc/conn.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/conn.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -42,5 +42,5 @@
 #include "devices.h"
 
-void connection_handler_host(ipcarg_t);
+void connection_handler_host(sysarg_t);
 
 usb_hcd_transfer_ops_t vhc_transfer_ops;
Index: uspace/drv/vhc/conndev.c
===================================================================
--- uspace/drv/vhc/conndev.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/conndev.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -47,5 +47,5 @@
 {
 	ipc_call_t answer_data;
-	ipcarg_t answer_rc;
+	sysarg_t answer_rc;
 	aid_t req;
 	int rc;
@@ -83,5 +83,5 @@
     ipc_callid_t icallid, ipc_call_t *icall)
 {
-	ipcarg_t method = IPC_GET_METHOD(*icall);
+	sysarg_t method = IPC_GET_IMETHOD(*icall);
 
 	if (method == IPC_M_CONNECT_TO_ME) {
Index: uspace/drv/vhc/connhost.c
===================================================================
--- uspace/drv/vhc/connhost.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/connhost.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -93,5 +93,5 @@
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
-	printf(NAME ": transfer OUT [%d.%d (%s); %zu]\n",
+	dprintf(3, "transfer OUT [%d.%d (%s); %zu]",
 	    target.address, target.endpoint,
 	    usb_str_transfer_type(transfer_type),
@@ -102,5 +102,5 @@
 	transfer->out_callback = callback;
 
-	hc_add_transaction_to_device(false, target, buffer, size,
+	hc_add_transaction_to_device(false, target, transfer_type, buffer, size,
 	    universal_callback, transfer);
 
@@ -113,5 +113,5 @@
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
-	printf(NAME ": transfer SETUP [%d.%d (%s); %zu]\n",
+	dprintf(3, "transfer SETUP [%d.%d (%s); %zu]",
 	    target.address, target.endpoint,
 	    usb_str_transfer_type(transfer_type),
@@ -122,5 +122,5 @@
 	transfer->out_callback = callback;
 
-	hc_add_transaction_to_device(true, target, buffer, size,
+	hc_add_transaction_to_device(true, target, transfer_type, buffer, size,
 	    universal_callback, transfer);
 
@@ -133,5 +133,5 @@
     usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
-	printf(NAME ": transfer IN [%d.%d (%s); %zu]\n",
+	dprintf(3, "transfer IN [%d.%d (%s); %zu]",
 	    target.address, target.endpoint,
 	    usb_str_transfer_type(transfer_type),
@@ -142,5 +142,5 @@
 	transfer->in_callback = callback;
 
-	hc_add_transaction_from_device(target, buffer, size,
+	hc_add_transaction_from_device(target, transfer_type, buffer, size,
 	    universal_callback, transfer);
 
Index: uspace/drv/vhc/debug.c
===================================================================
--- uspace/drv/vhc/debug.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/debug.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -42,9 +42,9 @@
 /** Debug print informing of invalid call.
  */
-void dprintf_inval_call(int level, ipc_call_t call, ipcarg_t phone_hash)
+void dprintf_inval_call(int level, ipc_call_t call, sysarg_t phone_hash)
 {
 	dprintf(level, "phone%#x: invalid call [%u (%u, %u, %u, %u, %u)]",
 	    phone_hash,
-	    IPC_GET_METHOD(call),
+	    IPC_GET_IMETHOD(call),
 	    IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call),
 	    IPC_GET_ARG4(call), IPC_GET_ARG5(call));
Index: uspace/drv/vhc/devices.c
===================================================================
--- uspace/drv/vhc/devices.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/devices.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -47,4 +47,5 @@
 #include "devices.h"
 #include "hub.h"
+#include "hub/virthub.h"
 #include "vhcd.h"
 
@@ -69,5 +70,5 @@
 	list_append(&dev->link, &devices);
 	
-	hub_add_device(dev);
+	virthub_connect_device(&virtual_hub_device, dev);
 	
 	return dev;
@@ -78,5 +79,5 @@
 void virtdev_destroy_device(virtdev_connection_t *dev)
 {
-	hub_remove_device(dev);
+	virthub_disconnect_device(&virtual_hub_device, dev);
 	list_remove(&dev->link);
 	free(dev);
@@ -94,10 +95,10 @@
 		    = list_get_instance(pos, virtdev_connection_t, link);
 		
-		if (!hub_can_device_signal(dev)) {
+		if (!virthub_is_device_enabled(&virtual_hub_device, dev)) {
 			continue;
 		}
 		
 		ipc_call_t answer_data;
-		ipcarg_t answer_rc;
+		sysarg_t answer_rc;
 		aid_t req;
 		int rc = EOK;
@@ -145,11 +146,12 @@
 	 * (if the address matches).
 	 */
-	if (virthub_dev.address == transaction->target.address) {
+	if (virtual_hub_device.address == transaction->target.address) {
 		size_t tmp;
-		dprintf(3, "sending `%s' transaction to hub",
+		dprintf(1, "sending `%s' transaction to hub",
 		    usbvirt_str_transaction_type(transaction->type));
 		switch (transaction->type) {
 			case USBVIRT_TRANSACTION_SETUP:
-				virthub_dev.transaction_setup(&virthub_dev,
+				virtual_hub_device.transaction_setup(
+				    &virtual_hub_device,
 				    transaction->target.endpoint,
 				    transaction->buffer, transaction->len);
@@ -157,5 +159,6 @@
 				
 			case USBVIRT_TRANSACTION_IN:
-				virthub_dev.transaction_in(&virthub_dev,
+				virtual_hub_device.transaction_in(
+				    &virtual_hub_device,
 				    transaction->target.endpoint,
 				    transaction->buffer, transaction->len,
@@ -167,5 +170,6 @@
 				
 			case USBVIRT_TRANSACTION_OUT:
-				virthub_dev.transaction_out(&virthub_dev,
+				virtual_hub_device.transaction_out(
+				    &virtual_hub_device,
 				    transaction->target.endpoint,
 				    transaction->buffer, transaction->len);
Index: uspace/drv/vhc/hc.c
===================================================================
--- uspace/drv/vhc/hc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/hc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -50,7 +50,7 @@
 #include "hub.h"
 
-#define USLEEP_BASE (500 * 1000)
-
-#define USLEEP_VAR 5000
+#define USLEEP_BASE (0 * 5 * 1000)
+
+#define USLEEP_VAR 50
 
 #define SHORTENING_VAR 15
@@ -68,7 +68,8 @@
 static link_t transaction_list;
 
-#define TRANSACTION_FORMAT "T[%d:%d %s (%d)]"
+#define TRANSACTION_FORMAT "T[%d.%d %s/%s (%d)]"
 #define TRANSACTION_PRINTF(t) \
 	(t).target.address, (t).target.endpoint, \
+	usb_str_transfer_type((t).transfer_type), \
 	usbvirt_str_transaction_type((t).type), \
 	(int)(t).len
@@ -77,4 +78,6 @@
 	list_get_instance(lnk, transaction_t, link)
 
+#define HUB_STATUS_MAX_LEN (HUB_PORT_COUNT + 64)
+
 static inline unsigned int pseudo_random(unsigned int *seed)
 {
@@ -89,5 +92,5 @@
     usb_transaction_outcome_t outcome)
 {
-	dprintf(3, "processing transaction " TRANSACTION_FORMAT ", outcome: %s",
+	dprintf(3, "transaction " TRANSACTION_FORMAT " done, outcome: %s",
 	    TRANSACTION_PRINTF(*transaction),
 	    usb_str_transaction_outcome(outcome));
@@ -99,5 +102,5 @@
 /** Host controller manager main function.
  */
-void hc_manager(void)
+static int hc_manager_fibril(void *arg)
 {
 	list_initialize(&transaction_list);
@@ -114,8 +117,6 @@
 		}
 		
-		char ports[HUB_PORT_COUNT + 2];
-		hub_get_port_statuses(ports, HUB_PORT_COUNT + 1);
-		dprintf(3, "virtual hub: addr=%d ports=%s",
-		    virthub_dev.address, ports);
+		char ports[HUB_STATUS_MAX_LEN + 1];
+		virthub_get_status(&virtual_hub_device, ports, HUB_STATUS_MAX_LEN);
 		
 		link_t *first_transaction_link = transaction_list.next;
@@ -124,4 +125,8 @@
 		list_remove(first_transaction_link);
 		
+
+		dprintf(0, "about to process " TRANSACTION_FORMAT " [%s]",
+		    TRANSACTION_PRINTF(*transaction), ports);
+
 		dprintf(3, "processing transaction " TRANSACTION_FORMAT "",
 		    TRANSACTION_PRINTF(*transaction));
@@ -134,4 +139,17 @@
 		free(transaction);
 	}
+
+	assert(false && "unreachable");
+	return EOK;
+}
+
+void hc_manager(void)
+{
+	fid_t fid = fibril_create(hc_manager_fibril, NULL);
+	if (fid == 0) {
+		printf(NAME ": failed to start HC manager fibril\n");
+		return;
+	}
+	fibril_add_ready(fid);
 }
 
@@ -139,5 +157,5 @@
  */
 static transaction_t *transaction_create(usbvirt_transaction_type_t type,
-    usb_target_t target,
+    usb_target_t target, usb_transfer_type_t transfer_type,
     void * buffer, size_t len,
     hc_transaction_done_callback_t callback, void * arg)
@@ -147,4 +165,5 @@
 	list_initialize(&transaction->link);
 	transaction->type = type;
+	transaction->transfer_type = transfer_type;
 	transaction->target = target;
 	transaction->buffer = buffer;
@@ -153,5 +172,5 @@
 	transaction->callback_arg = arg;
 	
-	dprintf(1, "creating transaction " TRANSACTION_FORMAT,
+	dprintf(3, "creating transaction " TRANSACTION_FORMAT,
 	    TRANSACTION_PRINTF(*transaction));
 	
@@ -162,9 +181,11 @@
  */
 void hc_add_transaction_to_device(bool setup, usb_target_t target,
+    usb_transfer_type_t transfer_type,
     void * buffer, size_t len,
     hc_transaction_done_callback_t callback, void * arg)
 {
 	transaction_t *transaction = transaction_create(
-	    setup ? USBVIRT_TRANSACTION_SETUP : USBVIRT_TRANSACTION_OUT, target,
+	    setup ? USBVIRT_TRANSACTION_SETUP : USBVIRT_TRANSACTION_OUT,
+	    target, transfer_type,
 	    buffer, len, callback, arg);
 	list_append(&transaction->link, &transaction_list);
@@ -174,9 +195,11 @@
  */
 void hc_add_transaction_from_device(usb_target_t target,
+    usb_transfer_type_t transfer_type,
     void * buffer, size_t len,
     hc_transaction_done_callback_t callback, void * arg)
 {
 	transaction_t *transaction = transaction_create(USBVIRT_TRANSACTION_IN,
-	    target, buffer, len, callback, arg);
+	    target, transfer_type,
+	    buffer, len, callback, arg);
 	list_append(&transaction->link, &transaction_list);
 }
Index: uspace/drv/vhc/hc.h
===================================================================
--- uspace/drv/vhc/hc.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/hc.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -55,4 +55,6 @@
 	/** Transaction type. */
 	usbvirt_transaction_type_t type;
+	/** Transfer type. */
+	usb_transfer_type_t transfer_type;
 	/** Device address. */
 	usb_target_t target;
@@ -71,9 +73,11 @@
 void hc_manager(void);
 
-void hc_add_transaction_to_device(bool setup, usb_target_t target,
+void hc_add_transaction_to_device(bool setup,
+    usb_target_t target, usb_transfer_type_t transfer_type,
     void * buffer, size_t len,
     hc_transaction_done_callback_t callback, void * arg);
 
-void hc_add_transaction_from_device(usb_target_t target,
+void hc_add_transaction_from_device(
+    usb_target_t target, usb_transfer_type_t transfer_type,
     void * buffer, size_t len,
     hc_transaction_done_callback_t callback, void * arg);
Index: uspace/drv/vhc/hcd.c
===================================================================
--- uspace/drv/vhc/hcd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/hcd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -79,5 +79,5 @@
 	 * Initialize our hub and announce its presence.
 	 */
-	hub_init(dev);
+	virtual_hub_device_init(dev);
 
 	printf("%s: virtual USB host controller ready.\n", NAME);
@@ -95,33 +95,18 @@
 };
 
-/** Fibril wrapper for HC transaction manager.
- *
- * @param arg Not used.
- * @return Nothing, return argument is unreachable.
- */
-static int hc_manager_fibril(void *arg)
-{
-	hc_manager();
-	return EOK;
-}
 
 int main(int argc, char * argv[])
 {	
-	printf("%s: virtual USB host controller driver.\n", NAME);
-
-	usb_dprintf_enable(NAME, 10);
-
-	fid_t fid = fibril_create(hc_manager_fibril, NULL);
-	if (fid == 0) {
-		printf("%s: failed to start HC manager fibril\n", NAME);
-		return ENOMEM;
-	}
-	fibril_add_ready(fid);
-
 	/*
 	 * Temporary workaround. Wait a little bit to be the last driver
 	 * in devman output.
 	 */
-	sleep(4);
+	sleep(5);
+
+	usb_dprintf_enable(NAME, 0);
+
+	printf(NAME ": virtual USB host controller driver.\n");
+
+	hc_manager();
 
 	return driver_main(&vhc_driver);
Index: uspace/drv/vhc/hub.c
===================================================================
--- uspace/drv/vhc/hub.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/hub.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,263 +40,63 @@
 #include <stdlib.h>
 #include <driver.h>
+#include <usb/usbdrv.h>
 
+#include "hub.h"
+#include "hub/virthub.h"
 #include "vhcd.h"
-#include "hub.h"
-#include "hubintern.h"
-#include "conn.h"
 
+usbvirt_device_t virtual_hub_device;
 
-/** Standard device descriptor. */
-usb_standard_device_descriptor_t std_device_descriptor = {
-	.length = sizeof(usb_standard_device_descriptor_t),
-	.descriptor_type = USB_DESCTYPE_DEVICE,
-	.usb_spec_version = 0x110,
-	.device_class = USB_CLASS_HUB,
-	.device_subclass = 0,
-	.device_protocol = 0,
-	.max_packet_size = 64,
-	.configuration_count = 1
-};
+static int hub_register_in_devman_fibril(void *arg);
 
-/** Standard interface descriptor. */
-usb_standard_interface_descriptor_t std_interface_descriptor = {
-	.length = sizeof(usb_standard_interface_descriptor_t),
-	.descriptor_type = USB_DESCTYPE_INTERFACE,
-	.interface_number = 0,
-	.alternate_setting = 0,
-	.endpoint_count = 1,
-	.interface_class = USB_CLASS_HUB,
-	.interface_subclass = 0,
-	.interface_protocol = 0,
-	.str_interface = 0
-};
+void virtual_hub_device_init(device_t *hc_dev)
+{
+	virthub_init(&virtual_hub_device);
 
-hub_descriptor_t hub_descriptor = {
-	.length = sizeof(hub_descriptor_t),
-	.type = USB_DESCTYPE_HUB,
-	.port_count = HUB_PORT_COUNT,
-	.characteristics = 0, 
-	.power_on_warm_up = 50, /* Huh? */
-	.max_current = 100, /* Huh again. */
-	.removable_device = { 0 },
-	.port_power = { 0xFF }
-};
+	/*
+	 * We need to register the root hub.
+	 * This must be done in separate fibril because the device
+	 * we are connecting to are ourselves and we cannot connect
+	 * before leaving the add_device() function.
+	 */
+	fid_t root_hub_registration
+	    = fibril_create(hub_register_in_devman_fibril, hc_dev);
+	if (root_hub_registration == 0) {
+		printf(NAME ": failed to register root hub\n");
+		return;
+	}
 
-/** Endpoint descriptor. */
-usb_standard_endpoint_descriptor_t endpoint_descriptor = {
-	.length = sizeof(usb_standard_endpoint_descriptor_t),
-	.descriptor_type = USB_DESCTYPE_ENDPOINT,
-	.endpoint_address = HUB_STATUS_CHANGE_PIPE | 128,
-	.attributes = USB_TRANSFER_INTERRUPT,
-	.max_packet_size = 8,
-	.poll_interval = 0xFF
-};
-
-/** Standard configuration descriptor. */
-usb_standard_configuration_descriptor_t std_configuration_descriptor = {
-	.length = sizeof(usb_standard_configuration_descriptor_t),
-	.descriptor_type = USB_DESCTYPE_CONFIGURATION,
-	.total_length = 
-		sizeof(usb_standard_configuration_descriptor_t)
-		+ sizeof(std_interface_descriptor)
-		+ sizeof(hub_descriptor)
-		+ sizeof(endpoint_descriptor)
-		,
-	.interface_count = 1,
-	.configuration_number = HUB_CONFIGURATION_ID,
-	.str_configuration = 0,
-	.attributes = 128, /* denotes bus-powered device */
-	.max_power = 50
-};
-
-/** All hub configuration descriptors. */
-static usbvirt_device_configuration_extras_t extra_descriptors[] = {
-	{
-		.data = (uint8_t *) &std_interface_descriptor,
-		.length = sizeof(std_interface_descriptor)
-	},
-	{
-		.data = (uint8_t *) &hub_descriptor,
-		.length = sizeof(hub_descriptor)
-	},
-	{
-		.data = (uint8_t *) &endpoint_descriptor,
-		.length = sizeof(endpoint_descriptor)
-	}
-};
-
-/** Hub configuration. */
-usbvirt_device_configuration_t configuration = {
-	.descriptor = &std_configuration_descriptor,
-	.extra = extra_descriptors,
-	.extra_count = sizeof(extra_descriptors)/sizeof(extra_descriptors[0])
-};
-
-/** Hub standard descriptors. */
-usbvirt_descriptors_t descriptors = {
-	.device = &std_device_descriptor,
-	.configuration = &configuration,
-	.configuration_count = 1,
-};
-
-/** Hub as a virtual device. */
-usbvirt_device_t virthub_dev = {
-	.ops = &hub_ops,
-	.descriptors = &descriptors,
-	.lib_debug_level = 4,
-	.lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL
-};
-
-/** Hub device. */
-hub_device_t hub_dev;
-
-static usb_address_t hub_set_address(usbvirt_device_t *hub)
-{
-	usb_address_t new_address;
-	int rc = vhc_iface.request_address(NULL, &new_address);
-	if (rc != EOK) {
-		return rc;
-	}
-	
-	usb_device_request_setup_packet_t setup_packet = {
-		.request_type = 0,
-		.request = USB_DEVREQ_SET_ADDRESS,
-		.index = 0,
-		.length = 0,
-	};
-	setup_packet.value = new_address;
-
-	hub->transaction_setup(hub, 0, &setup_packet, sizeof(setup_packet));
-	hub->transaction_in(hub, 0, NULL, 0, NULL);
-	
-	return new_address;
+	fibril_add_ready(root_hub_registration);
 }
 
-/** Initialize virtual hub. */
-void hub_init(device_t *hc_dev)
+/** Register root hub in devman.
+ *
+ * @param arg Host controller device (type <code>device_t *</code>).
+ * @return Error code.
+ */
+int hub_register_in_devman_fibril(void *arg)
 {
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		hub_port_t *port = &hub_dev.ports[i];
-		
-		port->device = NULL;
-		port->state = HUB_PORT_STATE_NOT_CONFIGURED;
-		port->status_change = 0;
-	}
-	
-	usbvirt_connect_local(&virthub_dev);
-	
-	dprintf(1, "virtual hub (%d ports) created", HUB_PORT_COUNT);
+	device_t *hc_dev = (device_t *) arg;
 
-	usb_address_t hub_address = hub_set_address(&virthub_dev);
-	if (hub_address < 0) {
-		dprintf(1, "problem changing hub address (%s)",
-		    str_error(hub_address));
+	int hc = usb_drv_hc_connect(hc_dev, IPC_FLAG_BLOCKING);
+	if (hc < 0) {
+		printf(NAME ": failed to register root hub\n");
+		return hc;
 	}
 
-	dprintf(2, "virtual hub address changed to %d", hub_address);
+	usb_drv_reserve_default_address(hc);
 
-	char *id;
-	int rc = asprintf(&id, "usb&hub");
-	if (rc <= 0) {
-		return;
-	}
+	usb_address_t hub_address = usb_drv_request_address(hc);
+	usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, hub_address);
+
+	usb_drv_release_default_address(hc);
+
 	devman_handle_t hub_handle;
-	rc = child_device_register_wrapper(hc_dev, "hub", id, 10, &hub_handle);
-	if (rc != EOK) {
-		free(id);
-	}
+	usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle);
+	usb_drv_bind_address(hc, hub_address, hub_handle);
 
-	vhc_iface.bind_address(NULL, hub_address, hub_handle);	
-
-	dprintf(2, "virtual hub has devman handle %d", (int) hub_handle);
+	return EOK;
 }
-
-/** Connect device to the hub.
- *
- * @param device Device to be connected.
- * @return Port where the device was connected to.
- */
-size_t hub_add_device(virtdev_connection_t *device)
-{
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		hub_port_t *port = &hub_dev.ports[i];
-		
-		if (port->device != NULL) {
-			continue;
-		}
-		
-		port->device = device;
-		
-		/*
-		 * TODO:
-		 * If the hub was configured, we can normally
-		 * announce the plug-in.
-		 * Otherwise, we will wait until hub is configured
-		 * and announce changes in single burst.
-		 */
-		//if (port->state == HUB_PORT_STATE_DISCONNECTED) {
-			port->state = HUB_PORT_STATE_DISABLED;
-			set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
-		//}
-		
-		return i;
-	}
 	
-	return (size_t)-1;
-}
-
-/** Disconnect device from the hub. */
-void hub_remove_device(virtdev_connection_t *device)
-{
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		hub_port_t *port = &hub_dev.ports[i];
-		
-		if (port->device != device) {
-			continue;
-		}
-		
-		port->device = NULL;
-		port->state = HUB_PORT_STATE_DISCONNECTED;
-		
-		set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
-	}
-}
-
-/** Tell whether device port is open.
- *
- * @return Whether communication to and from the device can go through the hub.
- */
-bool hub_can_device_signal(virtdev_connection_t * device)
-{
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		if (hub_dev.ports[i].device == device) {
-			return hub_dev.ports[i].state == HUB_PORT_STATE_ENABLED;
-		}
-	}
-	
-	return false;
-}
-
-/** Format hub port status.
- *
- * @param result Buffer where to store status string.
- * @param len Number of characters that is possible to store in @p result
- * 	(excluding trailing zero).
- */
-void hub_get_port_statuses(char *result, size_t len)
-{
-	if (len > HUB_PORT_COUNT) {
-		len = HUB_PORT_COUNT;
-	}
-	size_t i;
-	for (i = 0; i < len; i++) {
-		result[i] = hub_port_state_as_char(hub_dev.ports[i].state);
-	}
-	result[len] = 0;
-}
 
 /**
Index: uspace/drv/vhc/hub.h
===================================================================
--- uspace/drv/vhc/hub.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/hub.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,17 +40,10 @@
 
 #include "devices.h"
+#include "hub/hub.h"
+#include "hub/virthub.h"
 
-#define HUB_PORT_COUNT 6
+extern usbvirt_device_t virtual_hub_device;
 
-#define BITS2BYTES(bits) \
-    (bits ? ((((bits)-1)>>3)+1) : 0)
-
-extern usbvirt_device_t virthub_dev;
-
-void hub_init(device_t *);
-size_t hub_add_device(virtdev_connection_t *);
-void hub_remove_device(virtdev_connection_t *);
-bool hub_can_device_signal(virtdev_connection_t *);
-void hub_get_port_statuses(char *result, size_t len);
+void virtual_hub_device_init(device_t *);
 
 #endif
Index: uspace/drv/vhc/hub/hub.c
===================================================================
--- uspace/drv/vhc/hub/hub.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/drv/vhc/hub/hub.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,489 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Representation of an USB hub (implementation).
+ */
+#include <usb/classes/classes.h>
+#include <usbvirt/hub.h>
+#include <usbvirt/device.h>
+#include <errno.h>
+#include <str_error.h>
+#include <stdlib.h>
+#include <driver.h>
+#include <usb/usbdrv.h>
+
+#include "hub.h"
+
+
+/** Produce a byte from bit values.
+ */
+#define MAKE_BYTE(b0, b1, b2, b3, b4, b5, b6, b7) \
+	(( \
+		((b0) << 0) \
+		| ((b1) << 1) \
+		| ((b2) << 2) \
+		| ((b3) << 3) \
+		| ((b4) << 4) \
+		| ((b5) << 5) \
+		| ((b6) << 6) \
+		| ((b7) << 7) \
+	))
+
+/* Static functions. */
+static hub_port_t *get_hub_port(hub_t *, size_t);
+static void set_port_status_change(hub_port_t *, hub_status_change_t);
+static void clear_port_status_change(hub_port_t *, uint16_t);
+static int set_port_state_delayed_fibril(void *);
+static void set_port_state_delayed(hub_t *, size_t, suseconds_t,
+    hub_port_state_t, hub_port_state_t);
+
+/** Convert hub port state to a char. */
+char hub_port_state_to_char(hub_port_state_t state) {
+	switch (state) {
+		case HUB_PORT_STATE_NOT_CONFIGURED:
+			return '-';
+		case HUB_PORT_STATE_POWERED_OFF:
+			return 'O';
+		case HUB_PORT_STATE_DISCONNECTED:
+			return 'X';
+		case HUB_PORT_STATE_DISABLED:
+			return 'D';
+		case HUB_PORT_STATE_RESETTING:
+			return 'R';
+		case HUB_PORT_STATE_ENABLED:
+			return 'E';
+		case HUB_PORT_STATE_SUSPENDED:
+			return 'S';
+		case HUB_PORT_STATE_RESUMING:
+			return 'F';
+		default:
+			return '?';
+	}
+}
+
+/** Initialize single hub port.
+ *
+ * @param port Port to be initialized.
+ * @param index Port index (one based).
+ */
+static void hub_init_port(hub_port_t *port, size_t index)
+{
+	port->connected_device = NULL;
+	port->index = index;
+	port->state = HUB_PORT_STATE_NOT_CONFIGURED;
+	port->status_change = 0;
+}
+
+/** Initialize the hub.
+ *
+ * @param hub Hub to be initialized.
+ */
+void hub_init(hub_t *hub)
+{
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_init_port(&hub->ports[i], i + 1);
+	}
+	hub->custom_data = NULL;
+	fibril_mutex_initialize(&hub->guard);
+}
+
+/** Connect a device to the hub.
+ *
+ * @param hub Hub to connect device to.
+ * @param device Device to be connected.
+ * @return Index of port the device was connected to.
+ * @retval -1 No free port available.
+ */
+size_t hub_connect_device(hub_t *hub, void *device)
+{
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_port_t *port = &hub->ports[i];
+
+		if (port->connected_device != NULL) {
+			continue;
+		}
+
+		port->connected_device = device;
+
+		/*
+		 * TODO:
+		 * If the hub was configured, we can normally
+		 * announce the plug-in.
+		 * Otherwise, we will wait until hub is configured
+		 * and announce changes in single burst.
+		 */
+		//if (port->state == HUB_PORT_STATE_DISCONNECTED) {
+			port->state = HUB_PORT_STATE_DISABLED;
+			set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
+		//}
+
+		return i;
+	}
+
+	return (size_t) -1;
+}
+
+/** Find port device is connected to.
+ *
+ * @param hub Hub in question.
+ * @param device Device in question.
+ * @return Port index (zero based).
+ * @retval -1 Device is not connected.
+ */
+size_t hub_find_device(hub_t *hub, void *device)
+{
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_port_t *port = &hub->ports[i];
+
+		if (port->connected_device == device) {
+			return i;
+		}
+	}
+
+	return 0;
+}
+
+/** Acquire exclusive access to the hub.
+ *
+ * @param hub Hub in question.
+ */
+void hub_acquire(hub_t *hub)
+{
+	fibril_mutex_lock(&hub->guard);
+}
+
+/** Give up exclusive access to the hub.
+ *
+ * @param hub Hub in question.
+ */
+void hub_release(hub_t *hub)
+{
+	fibril_mutex_unlock(&hub->guard);
+}
+
+/** Change port state.
+ *
+ * @param hub Hub the port belongs to.
+ * @param port_index Port index (zero based).
+ * @param state New port state.
+ */
+void hub_set_port_state(hub_t *hub, size_t port_index, hub_port_state_t state)
+{
+	hub_port_t *port = get_hub_port(hub, port_index);
+	if (port == NULL) {
+		return;
+	}
+
+	switch (state) {
+		case HUB_PORT_STATE_POWERED_OFF:
+			clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
+			clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
+			clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);
+			break;
+		case HUB_PORT_STATE_RESUMING:
+			set_port_state_delayed(hub, port_index,
+			    10, state, HUB_PORT_STATE_ENABLED);
+			break;
+		case HUB_PORT_STATE_RESETTING:
+			set_port_state_delayed(hub, port_index,
+			    10, state, HUB_PORT_STATE_ENABLED);
+			break;
+		case HUB_PORT_STATE_ENABLED:
+			if (port->state == HUB_PORT_STATE_RESETTING) {
+				set_port_status_change(port, HUB_STATUS_C_PORT_RESET);
+			}
+			break;
+		default:
+			break;
+	}
+
+	port->state = state;
+}
+
+/** Change state of all ports.
+ *
+ * @param hub Hub in question.
+ * @param state New state for all ports.
+ */
+void hub_set_port_state_all(hub_t *hub, hub_port_state_t state)
+{
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_set_port_state(hub, i, state);
+	}
+}
+
+/** Get port state.
+ *
+ * @param hub Hub the port belongs to.
+ * @param port_index Port index (zero based).
+ * @return Port state.
+ */
+hub_port_state_t hub_get_port_state(hub_t *hub, size_t port_index)
+{
+	hub_port_t *port = get_hub_port(hub, port_index);
+	if (port == NULL) {
+		return HUB_PORT_STATE_UNKNOWN;
+	}
+
+	return port->state;
+}
+
+/** Clear port status change bit.
+ *
+ * @param hub Hub the port belongs to.
+ * @param port_index Port index (zero based).
+ * @param change Change to be cleared.
+ */
+void hub_clear_port_status_change(hub_t *hub, size_t port_index,
+    hub_status_change_t change)
+{
+	hub_port_t *port = get_hub_port(hub, port_index);
+	if (port == NULL) {
+		return;
+	}
+
+	clear_port_status_change(port, change);
+}
+
+/** Get port status change bits.
+ *
+ * @param hub Hub the port belongs to.
+ * @param port_index Port index (zero based).
+ * @return Port status change bitmap in standard format.
+ */
+uint16_t hub_get_port_status_change(hub_t *hub, size_t port_index)
+{
+	hub_port_t *port = get_hub_port(hub, port_index);
+	if (port == NULL) {
+		return 0;
+	}
+
+	return port->status_change;
+}
+
+/** Get port status bits.
+ *
+ * @param hub Hub the port belongs to.
+ * @param port_index Port index (zero based).
+ * @return Port status bitmap in standard format.
+ */
+uint32_t hub_get_port_status(hub_t *hub, size_t port_index)
+{
+	hub_port_t *port = get_hub_port(hub, port_index);
+	if (port == NULL) {
+		return 0;
+	}
+
+	uint32_t status;
+	status = MAKE_BYTE(
+	    /* Current connect status. */
+	    port->connected_device == NULL ? 0 : 1,
+	    /* Port enabled/disabled. */
+	    port->state == HUB_PORT_STATE_ENABLED ? 1 : 0,
+	    /* Suspend. */
+	    (port->state == HUB_PORT_STATE_SUSPENDED)
+		|| (port->state == HUB_PORT_STATE_RESUMING) ? 1 : 0,
+	    /* Over-current. */
+	    0,
+	    /* Reset. */
+	    port->state == HUB_PORT_STATE_RESETTING ? 1 : 0,
+	    /* Reserved. */
+	    0, 0, 0)
+
+	    | (MAKE_BYTE(
+	    /* Port power. */
+	    port->state == HUB_PORT_STATE_POWERED_OFF ? 0 : 1,
+	    /* Full-speed device. */
+	    0,
+	    /* Reserved. */
+	    0, 0, 0, 0, 0, 0
+	    )) << 8;
+
+	status |= (port->status_change << 16);
+
+	return status;
+}
+
+/** Create hub status change bitmap.
+ *
+ * @warning This function assumes that the whole bitmap fits into 8 bits.
+ *
+ * @param hub Hub in question.
+ * @return Hub status change bitmap.
+ */
+uint8_t hub_get_status_change_bitmap(hub_t *hub)
+{
+	uint8_t change_map = 0;
+
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_port_t *port = &hub->ports[i];
+
+		if (port->status_change != 0) {
+			change_map |= (1 << port->index);
+		}
+	}
+
+	return change_map;
+}
+
+
+/*
+ *
+ * STATIC (HELPER) FUNCTIONS
+ *
+ */
+
+/** Find a port in a hub.
+ *
+ * @param hub Hub in question.
+ * @param port Port index (zero based).
+ * @return Port structure.
+ * @retval NULL Invalid port index.
+ */
+static hub_port_t *get_hub_port(hub_t *hub, size_t port)
+{
+	if (port >= HUB_PORT_COUNT) {
+		return NULL;
+	}
+
+	return &hub->ports[port];
+}
+
+/** Adds a port status change to a port.
+ *
+ * @param port The port with status change.
+ * @param change Change to be added to the status.
+ */
+static void set_port_status_change(hub_port_t *port,
+    hub_status_change_t change)
+{
+	assert(port != NULL);
+	port->status_change |= change;
+}
+
+/** Clears a port status change on a port.
+ *
+ * @param port The port with status change.
+ * @param change Change to be removed from the status.
+ */
+static void clear_port_status_change(hub_port_t *port,
+    uint16_t change)
+{
+	assert(port != NULL);
+	port->status_change &= (~change);
+}
+
+/** Structure for automatic (delayed) port state change. */
+struct delay_port_state_change {
+	/** Delay in microseconds. */
+	suseconds_t delay;
+	/** Old state of the port. */
+	hub_port_state_t old_state;
+	/** New state of the port. */
+	hub_port_state_t new_state;
+	/** Port index (zero based). */
+	size_t port;
+	/** Hub. */
+	hub_t *hub;
+};
+
+/** Fibril responsible for delayed port state change.
+ *
+ * @param arg Pointer to delay_port_state_change.
+ * @return Always EOK.
+ */
+static int set_port_state_delayed_fibril(void *arg)
+{
+	struct delay_port_state_change *change
+	    = (struct delay_port_state_change *) arg;
+
+	async_usleep(change->delay);
+
+	hub_acquire(change->hub);
+
+	hub_port_t *port = get_hub_port(change->hub, change->port);
+	assert(port != NULL);
+
+	if (port->state == change->old_state) {
+		hub_set_port_state(change->hub, change->port,
+		    change->new_state);
+	}
+
+	hub_release(change->hub);
+
+	free(change);
+
+	return EOK;
+}
+
+/** Change port state with a delay.
+ *
+ * @warning If the port state changes during the waiting phase, the state
+ * is not changed.
+ *
+ * @param hub Hub in question.
+ * @param port_index Port index (zero based).
+ * @param delay_time_ms Delay time in miliseconds.
+ * @param old_state Old (current) state of the port.
+ * @param new_state New state of the port.
+ */
+static void set_port_state_delayed(hub_t *hub, size_t port_index,
+    suseconds_t delay_time_ms,
+    hub_port_state_t old_state, hub_port_state_t new_state)
+{
+	struct delay_port_state_change *change
+	    = malloc(sizeof(struct delay_port_state_change));
+
+	change->hub = hub;
+	change->port = port_index;
+	change->delay = delay_time_ms * 1000;
+	change->old_state = old_state;
+	change->new_state = new_state;
+	fid_t fibril = fibril_create(set_port_state_delayed_fibril, change);
+	if (fibril == 0) {
+		printf("Failed to create fibril\n");
+		free(change);
+		return;
+	}
+	fibril_add_ready(fibril);
+}
+
+
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hub/hub.h
===================================================================
--- uspace/drv/vhc/hub/hub.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/drv/vhc/hub/hub.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Representation of an USB hub.
+ */
+#ifndef VHC_HUB_HUB_H_
+#define VHC_HUB_HUB_H_
+
+#include <fibril_synch.h>
+
+#define HUB_PORT_COUNT 2
+#define BITS2BYTES(bits) (bits ? ((((bits)-1)>>3)+1) : 0)
+
+/** Hub port internal state.
+ * Some states (e.g. port over current) are not covered as they are not
+ * simulated at all.
+ */
+typedef enum {
+	HUB_PORT_STATE_UNKNOWN,
+	HUB_PORT_STATE_NOT_CONFIGURED,
+	HUB_PORT_STATE_POWERED_OFF,
+	HUB_PORT_STATE_DISCONNECTED,
+	HUB_PORT_STATE_DISABLED,
+	HUB_PORT_STATE_RESETTING,
+	HUB_PORT_STATE_ENABLED,
+	HUB_PORT_STATE_SUSPENDED,
+	HUB_PORT_STATE_RESUMING,
+	/* HUB_PORT_STATE_, */
+} hub_port_state_t;
+
+char hub_port_state_to_char(hub_port_state_t);
+
+/** Hub status change mask bits. */
+typedef enum {
+	HUB_STATUS_C_PORT_CONNECTION = (1 << 0),
+	HUB_STATUS_C_PORT_ENABLE = (1 << 1),
+	HUB_STATUS_C_PORT_SUSPEND = (1 << 2),
+	HUB_STATUS_C_PORT_OVER_CURRENT = (1 << 3),
+	HUB_STATUS_C_PORT_RESET = (1 << 4),
+	/* HUB_STATUS_C_ = (1 << ), */
+} hub_status_change_t;
+
+/** Hub port information. */
+typedef struct {
+	/** Custom pointer to connected device. */
+	void *connected_device;
+	/** Port index (one based). */
+	size_t index;
+	/** Port state. */
+	hub_port_state_t state;
+	/** Status change bitmap. */
+	uint16_t status_change;
+} hub_port_t;
+
+/** Hub device type. */
+typedef struct {
+	/** Hub ports. */
+	hub_port_t ports[HUB_PORT_COUNT];
+	/** Custom hub data. */
+	void *custom_data;
+	/** Access guard to the whole hub. */
+	fibril_mutex_t guard;
+} hub_t;
+
+void hub_init(hub_t *);
+size_t hub_connect_device(hub_t *, void *);
+size_t hub_find_device(hub_t *, void *);
+void hub_acquire(hub_t *);
+void hub_release(hub_t *);
+void hub_set_port_state(hub_t *, size_t, hub_port_state_t);
+void hub_set_port_state_all(hub_t *, hub_port_state_t);
+hub_port_state_t hub_get_port_state(hub_t *, size_t);
+void hub_clear_port_status_change(hub_t *, size_t, hub_status_change_t);
+uint16_t hub_get_port_status_change(hub_t *, size_t);
+uint32_t hub_get_port_status(hub_t *, size_t);
+uint8_t hub_get_status_change_bitmap(hub_t *);
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hub/virthub.c
===================================================================
--- uspace/drv/vhc/hub/virthub.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/drv/vhc/hub/virthub.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief
+ */
+#include <usb/classes/classes.h>
+#include <usbvirt/hub.h>
+#include <usbvirt/device.h>
+#include <assert.h>
+#include <errno.h>
+#include <str_error.h>
+#include <stdlib.h>
+#include <driver.h>
+#include <usb/usbdrv.h>
+
+#include "virthub.h"
+#include "hub.h"
+
+
+/** Standard device descriptor. */
+usb_standard_device_descriptor_t std_device_descriptor = {
+	.length = sizeof(usb_standard_device_descriptor_t),
+	.descriptor_type = USB_DESCTYPE_DEVICE,
+	.usb_spec_version = 0x110,
+	.device_class = USB_CLASS_HUB,
+	.device_subclass = 0,
+	.device_protocol = 0,
+	.max_packet_size = 64,
+	.configuration_count = 1
+};
+
+/** Standard interface descriptor. */
+usb_standard_interface_descriptor_t std_interface_descriptor = {
+	.length = sizeof(usb_standard_interface_descriptor_t),
+	.descriptor_type = USB_DESCTYPE_INTERFACE,
+	.interface_number = 0,
+	.alternate_setting = 0,
+	.endpoint_count = 1,
+	.interface_class = USB_CLASS_HUB,
+	.interface_subclass = 0,
+	.interface_protocol = 0,
+	.str_interface = 0
+};
+
+/** Hub descriptor. */
+hub_descriptor_t hub_descriptor = {
+	.length = sizeof(hub_descriptor_t),
+	.type = USB_DESCTYPE_HUB,
+	.port_count = HUB_PORT_COUNT,
+	.characteristics = 0, 
+	.power_on_warm_up = 50, /* Huh? */
+	.max_current = 100, /* Huh again. */
+	.removable_device = { 0 },
+	.port_power = { 0xFF }
+};
+
+/** Endpoint descriptor. */
+usb_standard_endpoint_descriptor_t endpoint_descriptor = {
+	.length = sizeof(usb_standard_endpoint_descriptor_t),
+	.descriptor_type = USB_DESCTYPE_ENDPOINT,
+	.endpoint_address = HUB_STATUS_CHANGE_PIPE | 128,
+	.attributes = USB_TRANSFER_INTERRUPT,
+	.max_packet_size = 8,
+	.poll_interval = 0xFF
+};
+
+/** Standard configuration descriptor. */
+usb_standard_configuration_descriptor_t std_configuration_descriptor = {
+	.length = sizeof(usb_standard_configuration_descriptor_t),
+	.descriptor_type = USB_DESCTYPE_CONFIGURATION,
+	.total_length = 
+		sizeof(usb_standard_configuration_descriptor_t)
+		+ sizeof(std_interface_descriptor)
+		+ sizeof(hub_descriptor)
+		+ sizeof(endpoint_descriptor)
+		,
+	.interface_count = 1,
+	.configuration_number = HUB_CONFIGURATION_ID,
+	.str_configuration = 0,
+	.attributes = 128, /* denotes bus-powered device */
+	.max_power = 50
+};
+
+/** All hub configuration descriptors. */
+static usbvirt_device_configuration_extras_t extra_descriptors[] = {
+	{
+		.data = (uint8_t *) &std_interface_descriptor,
+		.length = sizeof(std_interface_descriptor)
+	},
+	{
+		.data = (uint8_t *) &hub_descriptor,
+		.length = sizeof(hub_descriptor)
+	},
+	{
+		.data = (uint8_t *) &endpoint_descriptor,
+		.length = sizeof(endpoint_descriptor)
+	}
+};
+
+/** Hub configuration. */
+usbvirt_device_configuration_t configuration = {
+	.descriptor = &std_configuration_descriptor,
+	.extra = extra_descriptors,
+	.extra_count = sizeof(extra_descriptors)/sizeof(extra_descriptors[0])
+};
+
+/** Hub standard descriptors. */
+usbvirt_descriptors_t descriptors = {
+	.device = &std_device_descriptor,
+	.configuration = &configuration,
+	.configuration_count = 1,
+};
+
+/** Initializes virtual hub device.
+ *
+ * @param dev Virtual USB device backend.
+ * @return Error code.
+ */
+int virthub_init(usbvirt_device_t *dev)
+{
+	if (dev == NULL) {
+		return EBADMEM;
+	}
+	dev->ops = &hub_ops;
+	dev->descriptors = &descriptors;
+	dev->lib_debug_level = 0;
+	dev->lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL;
+
+	hub_t *hub = malloc(sizeof(hub_t));
+	if (hub == NULL) {
+		return ENOMEM;
+	}
+
+	hub_init(hub);
+	dev->device_data = hub;
+
+	usbvirt_connect_local(dev);
+
+	return EOK;
+}
+
+/** Connect a device to a virtual hub.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param conn Device to be connected.
+ * @return Port device was connected to.
+ */
+int virthub_connect_device(usbvirt_device_t *dev, virtdev_connection_t *conn)
+{
+	assert(dev != NULL);
+	assert(conn != NULL);
+
+	hub_t *hub = (hub_t *) dev->device_data;
+
+	hub_acquire(hub);
+	size_t port = hub_connect_device(hub, conn);
+	hub_release(hub);
+
+	return port;
+}
+
+/** Disconnect a device from a virtual hub.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param conn Device to be disconnected.
+ * @return Error code.
+ */
+int virthub_disconnect_device(usbvirt_device_t *dev, virtdev_connection_t *conn)
+{
+	assert(dev != NULL);
+	assert(conn != NULL);
+
+	hub_t *hub = (hub_t *) dev->device_data;
+
+	hub_acquire(hub);
+	/* TODO: implement. */
+	hub_release(hub);
+
+	return ENOTSUP;
+}
+
+/** Whether trafic is propagated to given device.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param conn Connected device.
+ * @return Whether port is signalling to the device.
+ */
+bool virthub_is_device_enabled(usbvirt_device_t *dev, virtdev_connection_t *conn)
+{
+	assert(dev != NULL);
+	assert(conn != NULL);
+
+	hub_t *hub = (hub_t *) dev->device_data;
+
+	hub_acquire(hub);
+
+	hub_port_state_t state = HUB_PORT_STATE_UNKNOWN;
+	size_t port = hub_find_device(hub, conn);
+	if (port != (size_t) -1) {
+		state = hub_get_port_state(hub, port);
+	}
+	hub_release(hub);
+
+	return state == HUB_PORT_STATE_ENABLED;
+}
+
+/** Format status of a virtual hub.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param[out] status Hub status information.
+ * @param[in] len Size of the @p status buffer.
+ */
+void virthub_get_status(usbvirt_device_t *dev, char *status, size_t len)
+{
+	assert(dev != NULL);
+	if (len == 0) {
+		return;
+	}
+
+	hub_t *hub = (hub_t *) dev->device_data;
+
+	char port_status[HUB_PORT_COUNT + 1];
+
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		port_status[i] = hub_port_state_to_char(
+		    hub_get_port_state(hub, i));
+	}
+	port_status[HUB_PORT_COUNT] = 0;
+
+	snprintf(status, len, "vhub:%s", port_status);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hub/virthub.h
===================================================================
--- uspace/drv/vhc/hub/virthub.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/drv/vhc/hub/virthub.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief USB hub as a virtual USB device.
+ */
+#ifndef VHC_HUB_VIRTHUB_H_
+#define VHC_HUB_VIRTHUB_H_
+
+#include <usbvirt/device.h>
+#include "../devices.h"
+#include "hub.h"
+
+/** Endpoint number for status change pipe. */
+#define HUB_STATUS_CHANGE_PIPE 1
+/** Configuration value for hub configuration. */
+#define HUB_CONFIGURATION_ID 1
+
+
+/** Hub descriptor.
+ */
+typedef struct {
+	/** Size of this descriptor in bytes. */
+	uint8_t length;
+	/** Descriptor type (USB_DESCTYPE_HUB). */
+	uint8_t type;
+	/** Number of downstream ports. */
+	uint8_t port_count;
+	/** Hub characteristics. */
+	uint16_t characteristics;
+	/** Time from power-on to stabilized current.
+	 * Expressed in 2ms unit.
+	 */
+	uint8_t power_on_warm_up;
+	/** Maximum current (in mA). */
+	uint8_t max_current;
+	/** Whether device at given port is removable. */
+	uint8_t removable_device[BITS2BYTES(HUB_PORT_COUNT+1)];
+	/** Port power control.
+	 * This is USB1.0 compatibility field, all bits must be 1.
+	 */
+	uint8_t port_power[BITS2BYTES(HUB_PORT_COUNT+1)];
+} __attribute__ ((packed)) hub_descriptor_t;
+
+extern usbvirt_device_ops_t hub_ops;
+extern hub_descriptor_t hub_descriptor;
+
+int virthub_init(usbvirt_device_t *);
+int virthub_connect_device(usbvirt_device_t *, virtdev_connection_t *);
+int virthub_disconnect_device(usbvirt_device_t *, virtdev_connection_t *);
+bool virthub_is_device_enabled(usbvirt_device_t *, virtdev_connection_t *);
+void virthub_get_status(usbvirt_device_t *, char *, size_t);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hub/virthubops.c
===================================================================
--- uspace/drv/vhc/hub/virthubops.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/drv/vhc/hub/virthubops.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,433 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Virtual USB hub operations.
+ */
+#include <errno.h>
+#include <usb/classes/hub.h>
+#include "virthub.h"
+#include "hub.h"
+
+/** Callback when device changes states. */
+static void on_state_change(struct usbvirt_device *dev,
+    usbvirt_device_state_t old_state, usbvirt_device_state_t new_state)
+{
+	hub_t *hub = (hub_t *)dev->device_data;
+
+	hub_acquire(hub);
+
+	switch (new_state) {
+		case USBVIRT_STATE_CONFIGURED:
+			hub_set_port_state_all(hub, HUB_PORT_STATE_POWERED_OFF);
+			break;
+		case USBVIRT_STATE_ADDRESS:
+			hub_set_port_state_all(hub, HUB_PORT_STATE_NOT_CONFIGURED);
+			break;
+		default:
+			break;
+	}
+
+	hub_release(hub);
+}
+
+/** Callback for data request. */
+static int req_on_data(struct usbvirt_device *dev,
+    usb_endpoint_t endpoint,
+    void *buffer, size_t size, size_t *actual_size)
+{
+	if (endpoint != HUB_STATUS_CHANGE_PIPE) {
+		return EINVAL;
+	}
+	
+	hub_t *hub = (hub_t *)dev->device_data;
+
+	hub_acquire(hub);
+
+	uint8_t change_map = hub_get_status_change_bitmap(hub);
+		
+	uint8_t *b = (uint8_t *) buffer;
+	if (size > 0) {
+		*b = change_map;
+		*actual_size = 1;
+	}
+	
+	hub_release(hub);
+
+	return EOK;
+}
+
+/** Handle ClearHubFeature request.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param request The SETUP packet of the control request.
+ * @param data Extra data (when DATA stage present).
+ * @return Error code.
+ */
+static int req_clear_hub_feature(usbvirt_device_t *dev,
+    usb_device_request_setup_packet_t *request,
+    uint8_t *data)
+{
+	return ENOTSUP;
+}
+
+/** Handle ClearPortFeature request.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param request The SETUP packet of the control request.
+ * @param data Extra data (when DATA stage present).
+ * @return Error code.
+ */
+static int req_clear_port_feature(usbvirt_device_t *dev,
+    usb_device_request_setup_packet_t *request,
+    uint8_t *data)
+{
+	int rc;
+	size_t port = request->index - 1;
+	usb_hub_class_feature_t feature = request->value;
+	hub_t *hub = (hub_t *) dev->device_data;
+
+	hub_acquire(hub);
+
+	hub_port_state_t port_state = hub_get_port_state(hub, port);
+
+	switch (feature) {
+		case USB_HUB_FEATURE_PORT_ENABLE:
+			if ((port_state != HUB_PORT_STATE_NOT_CONFIGURED)
+			    && (port_state != HUB_PORT_STATE_POWERED_OFF)) {
+				hub_set_port_state(hub, port, HUB_PORT_STATE_DISABLED);
+			}
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_PORT_SUSPEND:
+			if (port_state != HUB_PORT_STATE_SUSPENDED) {
+				rc = EOK;
+				break;
+			}
+			hub_set_port_state(hub, port, HUB_PORT_STATE_RESUMING);
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_PORT_POWER:
+			if (port_state != HUB_PORT_STATE_NOT_CONFIGURED) {
+				hub_set_port_state(hub, port, HUB_PORT_STATE_POWERED_OFF);
+			}
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_C_PORT_CONNECTION:
+			hub_clear_port_status_change(hub, port, HUB_STATUS_C_PORT_CONNECTION);
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_C_PORT_ENABLE:
+			hub_clear_port_status_change(hub, port, HUB_STATUS_C_PORT_ENABLE);
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_C_PORT_SUSPEND:
+			hub_clear_port_status_change(hub, port, HUB_STATUS_C_PORT_SUSPEND);
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
+			hub_clear_port_status_change(hub, port, HUB_STATUS_C_PORT_OVER_CURRENT);
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_C_PORT_RESET:
+			hub_clear_port_status_change(hub, port, HUB_STATUS_C_PORT_RESET);
+			rc = EOK;
+			break;
+
+		default:
+			rc = ENOTSUP;
+			break;
+	}
+
+	hub_release(hub);
+
+	return rc;
+}
+
+/** Handle GetBusState request.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param request The SETUP packet of the control request.
+ * @param data Extra data (when DATA stage present).
+ * @return Error code.
+ */
+static int req_get_bus_state(usbvirt_device_t *dev,
+    usb_device_request_setup_packet_t *request,
+    uint8_t *data)
+{
+	return ENOTSUP;
+}
+
+/** Handle GetDescriptor request.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param request The SETUP packet of the control request.
+ * @param data Extra data (when DATA stage present).
+ * @return Error code.
+ */
+static int req_get_descriptor(usbvirt_device_t *dev,
+    usb_device_request_setup_packet_t *request,
+    uint8_t *data)
+{
+	if (request->value_high == USB_DESCTYPE_HUB) {
+		int rc = dev->control_transfer_reply(dev, 0,
+		    &hub_descriptor, hub_descriptor.length);
+
+		return rc;
+	}
+	/* Let the framework handle all the rest. */
+	return EFORWARD;
+}
+
+/** Handle GetHubStatus request.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param request The SETUP packet of the control request.
+ * @param data Extra data (when DATA stage present).
+ * @return Error code.
+ */
+static int req_get_hub_status(usbvirt_device_t *dev,
+    usb_device_request_setup_packet_t *request,
+    uint8_t *data)
+{
+	uint32_t hub_status = 0;
+
+	return dev->control_transfer_reply(dev, 0,
+	    &hub_status, sizeof(hub_status));
+}
+
+/** Handle GetPortStatus request.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param request The SETUP packet of the control request.
+ * @param data Extra data (when DATA stage present).
+ * @return Error code.
+ */
+static int req_get_port_status(usbvirt_device_t *dev,
+    usb_device_request_setup_packet_t *request,
+    uint8_t *data)
+{
+	hub_t *hub = (hub_t *) dev->device_data;
+
+	hub_acquire(hub);
+
+	uint32_t status = hub_get_port_status(hub, request->index - 1);
+
+	hub_release(hub);
+
+	return dev->control_transfer_reply(dev, 0, &status, 4);
+}
+
+/** Handle SetHubFeature request.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param request The SETUP packet of the control request.
+ * @param data Extra data (when DATA stage present).
+ * @return Error code.
+ */
+static int req_set_hub_feature(usbvirt_device_t *dev,
+    usb_device_request_setup_packet_t *request,
+    uint8_t *data)
+{
+	return ENOTSUP;
+}
+
+/** Handle SetPortFeature request.
+ *
+ * @param dev Virtual device representing the hub.
+ * @param request The SETUP packet of the control request.
+ * @param data Extra data (when DATA stage present).
+ * @return Error code.
+ */
+static int req_set_port_feature(usbvirt_device_t *dev,
+    usb_device_request_setup_packet_t *request,
+    uint8_t *data)
+{
+	int rc;
+	size_t port = request->index - 1;
+	usb_hub_class_feature_t feature = request->value;
+	hub_t *hub = (hub_t *) dev->device_data;
+
+	hub_acquire(hub);
+
+	hub_port_state_t port_state = hub_get_port_state(hub, port);
+
+	switch (feature) {
+		case USB_HUB_FEATURE_PORT_RESET:
+			if (port_state != HUB_PORT_STATE_POWERED_OFF) {
+				hub_set_port_state(hub, port, HUB_PORT_STATE_RESETTING);
+			}
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_PORT_SUSPEND:
+			if (port_state == HUB_PORT_STATE_ENABLED) {
+				hub_set_port_state(hub, port, HUB_PORT_STATE_SUSPENDED);
+			}
+			rc = EOK;
+			break;
+
+		case USB_HUB_FEATURE_PORT_POWER:
+			if (port_state == HUB_PORT_STATE_POWERED_OFF) {
+				hub_set_port_state(hub, port, HUB_PORT_STATE_DISCONNECTED);
+			}
+			rc = EOK;
+			break;
+
+		default:
+			break;
+	}
+
+	hub_release(hub);
+
+	return rc;
+}
+
+
+/** IN class request. */
+#define CLASS_REQ_IN(recipient) \
+	USBVIRT_MAKE_CONTROL_REQUEST_TYPE(USB_DIRECTION_IN, \
+	USBVIRT_REQUEST_TYPE_CLASS, recipient)
+/** OUT class request. */
+#define CLASS_REQ_OUT(recipient) \
+	USBVIRT_MAKE_CONTROL_REQUEST_TYPE(USB_DIRECTION_OUT, \
+	USBVIRT_REQUEST_TYPE_CLASS, recipient)
+
+/** Recipient: other. */
+#define REC_OTHER USBVIRT_REQUEST_RECIPIENT_OTHER
+/** Recipient: device. */
+#define REC_DEVICE USBVIRT_REQUEST_RECIPIENT_DEVICE
+/** Direction: in. */
+#define DIR_IN USB_DIRECTION_IN
+/** Direction: out. */
+#define DIR_OUT USB_DIRECTION_OUT
+
+/** Create a class request.
+ *
+ * @param direction Request direction.
+ * @param recipient Request recipient.
+ * @param req Request code.
+ */
+#define CLASS_REQ(direction, recipient, req) \
+	.request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, \
+	    USBVIRT_REQUEST_TYPE_CLASS, recipient), \
+	.request = req
+
+/** Create a standard request.
+ *
+ * @param direction Request direction.
+ * @param recipient Request recipient.
+ * @param req Request code.
+ */
+#define STD_REQ(direction, recipient, req) \
+	.request_type = USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, \
+	    USBVIRT_REQUEST_TYPE_STANDARD, recipient), \
+	.request = req
+
+/** Hub operations on control endpoint zero. */
+static usbvirt_control_transfer_handler_t endpoint_zero_handlers[] = {
+	{
+		STD_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		.name = "GetDescriptor",
+		.callback = req_get_descriptor
+	},
+	{
+		CLASS_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		.name = "GetDescriptor",
+		.callback = req_get_descriptor
+	},
+	{
+		CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetPortStatus",
+		.callback = req_get_port_status
+	},
+	{
+		CLASS_REQ(DIR_OUT, REC_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
+		.name = "ClearHubFeature",
+		.callback = req_clear_hub_feature
+	},
+	{
+		CLASS_REQ(DIR_OUT, REC_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE),
+		.name = "ClearPortFeature",
+		.callback = req_clear_port_feature
+	},
+	{
+		CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATE),
+		.name = "GetBusState",
+		.callback = req_get_bus_state
+	},
+	{
+		CLASS_REQ(DIR_IN, REC_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR),
+		.name = "GetHubDescriptor",
+		.callback = req_get_descriptor
+	},
+	{
+		CLASS_REQ(DIR_IN, REC_DEVICE, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetHubStatus",
+		.callback = req_get_hub_status
+	},
+	{
+		CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetPortStatus",
+		.callback = req_get_port_status
+	},
+	{
+		CLASS_REQ(DIR_OUT, REC_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
+		.name = "SetHubFeature",
+		.callback = req_set_hub_feature
+	},
+	{
+		CLASS_REQ(DIR_OUT, REC_OTHER, USB_HUB_REQUEST_SET_FEATURE),
+		.name = "SetPortFeature",
+		.callback = req_set_port_feature
+	},
+	USBVIRT_CONTROL_TRANSFER_HANDLER_LAST
+};
+
+
+/** Hub operations. */
+usbvirt_device_ops_t hub_ops = {
+	.control_transfer_handlers = endpoint_zero_handlers,
+	.on_data = NULL,
+	.on_data_request = req_on_data,
+	.on_state_change = on_state_change,
+};
+
+/**
+ * @}
+ */
Index: pace/drv/vhc/hubintern.h
===================================================================
--- uspace/drv/vhc/hubintern.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,145 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief
- */
-#ifndef VHCD_HUBINTERN_H_
-#define VHCD_HUBINTERN_H_
-
-#include "hub.h"
-
-/** Endpoint number for status change pipe. */
-#define HUB_STATUS_CHANGE_PIPE 1
-/** Configuration value for hub configuration. */
-#define HUB_CONFIGURATION_ID 1
-
-/** Hub descriptor.
- */
-typedef struct {
-	/** Size of this descriptor in bytes. */
-	uint8_t length;
-	/** Descriptor type (USB_DESCTYPE_HUB). */
-	uint8_t type;
-	/** Number of downstream ports. */
-	uint8_t port_count;
-	/** Hub characteristics. */
-	uint16_t characteristics;
-	/** Time from power-on to stabilized current.
-	 * Expressed in 2ms unit.
-	 */
-	uint8_t power_on_warm_up;
-	/** Maximum current (in mA). */
-	uint8_t max_current;
-	/** Whether device at given port is removable. */
-	uint8_t removable_device[BITS2BYTES(HUB_PORT_COUNT+1)];
-	/** Port power control.
-	 * This is USB1.0 compatibility field, all bits must be 1.
-	 */
-	uint8_t port_power[BITS2BYTES(HUB_PORT_COUNT+1)];
-} __attribute__ ((packed)) hub_descriptor_t;
-
-/** Hub port internal state.
- * Some states (e.g. port over current) are not covered as they are not
- * simulated at all.
- */
-typedef enum {
-	HUB_PORT_STATE_NOT_CONFIGURED,
-	HUB_PORT_STATE_POWERED_OFF,
-	HUB_PORT_STATE_DISCONNECTED,
-	HUB_PORT_STATE_DISABLED,
-	HUB_PORT_STATE_RESETTING,
-	HUB_PORT_STATE_ENABLED,
-	HUB_PORT_STATE_SUSPENDED,
-	HUB_PORT_STATE_RESUMING,
-	/* HUB_PORT_STATE_, */
-} hub_port_state_t;
-
-/** Convert hub port state to a char. */
-static inline char hub_port_state_as_char(hub_port_state_t state) {
-	switch (state) {
-		case HUB_PORT_STATE_NOT_CONFIGURED:
-			return '-';
-		case HUB_PORT_STATE_POWERED_OFF:
-			return 'O';
-		case HUB_PORT_STATE_DISCONNECTED:
-			return 'X';
-		case HUB_PORT_STATE_DISABLED:
-			return 'D';
-		case HUB_PORT_STATE_RESETTING:
-			return 'R';
-		case HUB_PORT_STATE_ENABLED:
-			return 'E';
-		case HUB_PORT_STATE_SUSPENDED:
-			return 'S';
-		case HUB_PORT_STATE_RESUMING:
-			return 'F';
-		default:
-			return '?';
-	}
-}
-
-/** Hub status change mask bits. */
-typedef enum {
-	HUB_STATUS_C_PORT_CONNECTION = (1 << 0),
-	HUB_STATUS_C_PORT_ENABLE = (1 << 1),
-	HUB_STATUS_C_PORT_SUSPEND = (1 << 2),
-	HUB_STATUS_C_PORT_OVER_CURRENT = (1 << 3),
-	HUB_STATUS_C_PORT_RESET = (1 << 4),
-	/* HUB_STATUS_C_ = (1 << ), */
-} hub_status_change_t;
-
-/** Hub port information. */
-typedef struct {
-	virtdev_connection_t *device;
-	hub_port_state_t state;
-	uint16_t status_change;
-} hub_port_t;
-
-/** Hub device type. */
-typedef struct {
-	hub_port_t ports[HUB_PORT_COUNT];
-} hub_device_t;
-
-extern hub_device_t hub_dev;
-
-extern hub_descriptor_t hub_descriptor;
-
-extern usbvirt_device_ops_t hub_ops;
-
-void clear_port_status_change(hub_port_t *, uint16_t);
-void set_port_status_change(hub_port_t *, uint16_t);
-
-
-#endif
-/**
- * @}
- */
Index: pace/drv/vhc/hubops.c
===================================================================
--- uspace/drv/vhc/hubops.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,393 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Virtual USB hub operations.
- */
-#include <usb/classes/classes.h>
-#include <usb/classes/hub.h>
-#include <usbvirt/hub.h>
-#include <usbvirt/device.h>
-#include <errno.h>
-
-#include "vhcd.h"
-#include "hub.h"
-#include "hubintern.h"
-
-/** Produce a byte from bit values.
- */
-#define MAKE_BYTE(b0, b1, b2, b3, b4, b5, b6, b7) \
-	(( \
-		((b0) << 0) \
-		| ((b1) << 1) \
-		| ((b2) << 2) \
-		| ((b3) << 3) \
-		| ((b4) << 4) \
-		| ((b5) << 5) \
-		| ((b6) << 6) \
-		| ((b7) << 7) \
-	))
-
-static int on_get_descriptor(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data);
-static int on_class_request(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data);
-static int on_data_request(struct usbvirt_device *dev,
-    usb_endpoint_t endpoint,
-    void *buffer, size_t size, size_t *actual_size);
-
-/** Standard USB requests. */
-static usbvirt_standard_device_request_ops_t standard_request_ops = {
-	.on_get_status = NULL,
-	.on_clear_feature = NULL,
-	.on_set_feature = NULL,
-	.on_set_address = NULL,
-	.on_get_descriptor = on_get_descriptor,
-	.on_set_descriptor = NULL,
-	.on_get_configuration = NULL,
-	.on_set_configuration = NULL,
-	.on_get_interface = NULL,
-	.on_set_interface = NULL,
-	.on_synch_frame = NULL
-};
-
-/** Hub operations. */
-usbvirt_device_ops_t hub_ops = {
-	.standard_request_ops = &standard_request_ops,
-	.on_class_device_request = on_class_request,
-	.on_data = NULL,
-	.on_data_request = on_data_request
-};
-
-/** Callback for GET_DESCRIPTOR request. */
-static int on_get_descriptor(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data)
-{
-	if (request->value_high == USB_DESCTYPE_HUB) {
-		int rc = dev->control_transfer_reply(dev, 0,
-		    &hub_descriptor, hub_descriptor.length);
-		
-		return rc;
-	}
-	/* Let the framework handle all the rest. */
-	return EFORWARD;
-}
-
-/** Change port status and updates status change status fields.
- */
-static void set_port_state(hub_port_t *port, hub_port_state_t state)
-{
-	port->state = state;
-	if (state == HUB_PORT_STATE_POWERED_OFF) {
-		clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
-		clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
-		clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);
-	}
-	if (state == HUB_PORT_STATE_RESUMING) {
-		async_usleep(10*1000);
-		if (port->state == state) {
-			set_port_state(port, HUB_PORT_STATE_ENABLED);
-		}
-	}
-	if (state == HUB_PORT_STATE_RESETTING) {
-		async_usleep(10*1000);
-		if (port->state == state) {
-			set_port_status_change(port, HUB_STATUS_C_PORT_RESET);
-			set_port_state(port, HUB_PORT_STATE_ENABLED);
-		}
-	}
-}
-
-/** Get access to a port or return with EINVAL. */
-#define _GET_PORT(portvar, index) \
-	do { \
-		if (virthub_dev.state != USBVIRT_STATE_CONFIGURED) { \
-			return EINVAL; \
-		} \
-		if (((index) == 0) || ((index) > HUB_PORT_COUNT)) { \
-			return EINVAL; \
-		} \
-	} while (false); \
-	hub_port_t *portvar = &hub_dev.ports[index]
-
-
-static int clear_hub_feature(uint16_t feature)
-{
-	return ENOTSUP;
-}
-
-static int clear_port_feature(uint16_t feature, uint16_t portindex)
-{	
-	_GET_PORT(port, portindex);
-	
-	switch (feature) {
-		case USB_HUB_FEATURE_PORT_ENABLE:
-			if ((port->state != HUB_PORT_STATE_NOT_CONFIGURED)
-			    && (port->state != HUB_PORT_STATE_POWERED_OFF)) {
-				set_port_state(port, HUB_PORT_STATE_DISABLED);
-			}
-			return EOK;
-		
-		case USB_HUB_FEATURE_PORT_SUSPEND:
-			if (port->state != HUB_PORT_STATE_SUSPENDED) {
-				return EOK;
-			}
-			set_port_state(port, HUB_PORT_STATE_RESUMING);
-			return EOK;
-			
-		case USB_HUB_FEATURE_PORT_POWER:
-			if (port->state != HUB_PORT_STATE_NOT_CONFIGURED) {
-				set_port_state(port, HUB_PORT_STATE_POWERED_OFF);
-			}
-			return EOK;
-		
-		case USB_HUB_FEATURE_C_PORT_CONNECTION:
-			clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
-			return EOK;
-		
-		case USB_HUB_FEATURE_C_PORT_ENABLE:
-			clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
-			return EOK;
-		
-		case USB_HUB_FEATURE_C_PORT_SUSPEND:
-			clear_port_status_change(port, HUB_STATUS_C_PORT_SUSPEND);
-			return EOK;
-			
-		case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
-			clear_port_status_change(port, HUB_STATUS_C_PORT_OVER_CURRENT);
-			return EOK;
-	}
-	
-	return ENOTSUP;
-}
-
-static int get_bus_state(uint16_t portindex)
-{
-	return ENOTSUP;
-}
-
-static int get_hub_descriptor(struct usbvirt_device *dev,
-    uint8_t descriptor_index,
-    uint8_t descriptor_type, uint16_t length)
-{
-	if (descriptor_type == USB_DESCTYPE_HUB) {
-		int rc = dev->control_transfer_reply(dev, 0,
-		    &hub_descriptor, hub_descriptor.length);
-
-		return rc;
-
-	}
-
-	return ENOTSUP;
-}
-
-static int get_hub_status(void)
-{
-	uint32_t hub_status = 0;
-	
-	return virthub_dev.control_transfer_reply(&virthub_dev, 0,
-	    &hub_status, 4);
-}
-
-static int get_port_status(uint16_t portindex)
-{
-	_GET_PORT(port, portindex);
-	
-	uint32_t status;
-	status = MAKE_BYTE(
-	    /* Current connect status. */
-	    port->device == NULL ? 0 : 1,
-	    /* Port enabled/disabled. */
-	    port->state == HUB_PORT_STATE_ENABLED ? 1 : 0,
-	    /* Suspend. */
-	    (port->state == HUB_PORT_STATE_SUSPENDED)
-	        || (port->state == HUB_PORT_STATE_RESUMING) ? 1 : 0,
-	    /* Over-current. */
-	    0,
-	    /* Reset. */
-	    port->state == HUB_PORT_STATE_RESETTING ? 1 : 0,
-	    /* Reserved. */
-	    0, 0, 0)
-	    
-	    | (MAKE_BYTE(
-	    /* Port power. */
-	    port->state == HUB_PORT_STATE_POWERED_OFF ? 0 : 1,
-	    /* Full-speed device. */
-	    0,
-	    /* Reserved. */
-	    0, 0, 0, 0, 0, 0
-	    )) << 8;
-	    
-	status |= (port->status_change << 16);
-	
-	return virthub_dev.control_transfer_reply(&virthub_dev, 0, &status, 4);
-}
-
-
-static int set_hub_feature(uint16_t feature)
-{
-	return ENOTSUP;
-}
-
-static int set_port_feature(uint16_t feature, uint16_t portindex)
-{
-	_GET_PORT(port, portindex);
-	
-	switch (feature) {
-		case USB_HUB_FEATURE_PORT_RESET:
-			if (port->state != HUB_PORT_STATE_POWERED_OFF) {
-				set_port_state(port, HUB_PORT_STATE_RESETTING);
-			}
-			return EOK;
-		
-		case USB_HUB_FEATURE_PORT_SUSPEND:
-			if (port->state == HUB_PORT_STATE_ENABLED) {
-				set_port_state(port, HUB_PORT_STATE_SUSPENDED);
-			}
-			return EOK;
-		
-		case USB_HUB_FEATURE_PORT_POWER:
-			if (port->state == HUB_PORT_STATE_POWERED_OFF) {
-				set_port_state(port, HUB_PORT_STATE_DISCONNECTED);
-			}
-			return EOK;
-	}
-	return ENOTSUP;
-}
-
-#undef _GET_PORT
-
-
-/** Callback for class request. */
-static int on_class_request(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data)
-{	
-	dprintf(2, "hub class request (%d)\n", (int) request->request);
-	
-	uint8_t recipient = request->request_type & 31;
-	uint8_t direction = request->request_type >> 7;
-	
-#define _VERIFY(cond) \
-	do { \
-		if (!(cond)) { \
-			dprintf(0, "WARN: invalid class request (%s not met).\n", \
-			    NAME, #cond); \
-			return EINVAL; \
-		} \
-	} while (0)
-	
-	switch (request->request) {
-		case USB_HUB_REQUEST_CLEAR_FEATURE:
-			_VERIFY(direction == 0);
-			_VERIFY(request->length == 0);
-			if (recipient == 0) {
-				_VERIFY(request->index == 0);
-				return clear_hub_feature(request->value);
-			} else {
-				_VERIFY(recipient == 3);
-				return clear_port_feature(request->value,
-				    request->index);
-			}
-			
-		case USB_HUB_REQUEST_GET_STATE:
-			return get_bus_state(request->index);
-			
-		case USB_HUB_REQUEST_GET_DESCRIPTOR:
-			return get_hub_descriptor(dev, request->value_low,
-			    request->value_high, request->length);
-			
-		case USB_HUB_REQUEST_GET_STATUS:
-			if (recipient == 0) {
-				return get_hub_status();
-			} else {
-				return get_port_status(request->index);
-			}
-			
-		case USB_HUB_REQUEST_SET_FEATURE:
-			if (recipient == 0) {
-				return set_hub_feature(request->value);
-			} else {
-				return set_port_feature(request->value, request->index);
-			}
-			
-		default:
-			break;
-	}
-	
-#undef _VERIFY	
-
-
-	return EOK;
-}
-
-void clear_port_status_change(hub_port_t *port, uint16_t change)
-{
-	port->status_change &= (~change);
-}
-
-void set_port_status_change(hub_port_t *port, uint16_t change)
-{
-	port->status_change |= change;
-}
-
-/** Callback for data request. */
-static int on_data_request(struct usbvirt_device *dev,
-    usb_endpoint_t endpoint,
-    void *buffer, size_t size, size_t *actual_size)
-{
-	if (endpoint != HUB_STATUS_CHANGE_PIPE) {
-		return EINVAL;
-	}
-	
-	uint8_t change_map = 0;
-	
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		hub_port_t *port = &hub_dev.ports[i];
-		
-		if (port->status_change != 0) {
-			change_map |= (1 << (i + 1));
-		}
-	}
-	
-	uint8_t *b = (uint8_t *) buffer;
-	if (size > 0) {
-		*b = change_map;
-		*actual_size = 1;
-	}
-	
-	return EOK;
-}
-
-
-/**
- * @}
- */
Index: uspace/drv/vhc/vhcd.h
===================================================================
--- uspace/drv/vhc/vhcd.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/drv/vhc/vhcd.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -47,5 +47,5 @@
 #define dprintf(level, format, ...) \
 	usb_dprintf(NAME, (level), format "\n", ##__VA_ARGS__)
-void dprintf_inval_call(int, ipc_call_t, ipcarg_t);
+void dprintf_inval_call(int, ipc_call_t, sysarg_t);
 
 #endif
Index: uspace/lib/block/libblock.c
===================================================================
--- uspace/lib/block/libblock.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/block/libblock.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -862,5 +862,5 @@
 static int get_block_size(int dev_phone, size_t *bsize)
 {
-	ipcarg_t bs;
+	sysarg_t bs;
 	int rc;
 
@@ -875,5 +875,5 @@
 static int get_num_blocks(int dev_phone, aoff64_t *nblocks)
 {
-	ipcarg_t nb_l, nb_h;
+	sysarg_t nb_l, nb_h;
 	int rc;
 
Index: uspace/lib/c/arch/abs32le/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/abs32le/include/inttypes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/arch/abs32le/include/inttypes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,7 +34,7 @@
 #define LIBC_abs32le_INTTYPES_H_
 
-#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: uspace/lib/c/arch/amd64/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/amd64/include/inttypes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/arch/amd64/include/inttypes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,7 +34,7 @@
 #define LIBC_amd64_INTTYPES_H_
 
-#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIdn  PRId64  /**< Format for native_t. */
+#define PRIun  PRIu64  /**< Format for sysarg_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
Index: uspace/lib/c/arch/arm32/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/arm32/include/inttypes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/arch/arm32/include/inttypes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,7 +34,7 @@
 #define LIBC_arm32_INTTYPES_H_
 
-#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: uspace/lib/c/arch/ia32/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/ia32/include/inttypes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/arch/ia32/include/inttypes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,7 +34,7 @@
 #define LIBC_ia32_INTTYPES_H_
 
-#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: uspace/lib/c/arch/ia64/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/ia64/include/inttypes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/arch/ia64/include/inttypes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,7 +34,7 @@
 #define LIBC_ia64_INTTYPES_H_
 
-#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIdn  PRId64  /**< Format for native_t. */
+#define PRIun  PRIu64  /**< Format for sysarg_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
Index: uspace/lib/c/arch/mips32/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/mips32/include/inttypes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/arch/mips32/include/inttypes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,7 +34,7 @@
 #define LIBC_mips32_INTTYPES_H_
 
-#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: uspace/lib/c/arch/ppc32/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/ppc32/include/inttypes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/arch/ppc32/include/inttypes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,7 +34,7 @@
 #define LIBC_ppc32_INTTYPES_H_
 
-#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu32  /**< Format for atomic_count_t. */
 
Index: uspace/lib/c/arch/sparc64/include/inttypes.h
===================================================================
--- uspace/lib/c/arch/sparc64/include/inttypes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/arch/sparc64/include/inttypes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,7 +34,7 @@
 #define LIBC_sparc64_INTTYPES_H_
 
-#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
-#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
+#define PRIdn  PRId64  /**< Format for native_t. */
+#define PRIun  PRIu64  /**< Format for sysarg_t. */
+#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t. */
 #define PRIua  PRIu64  /**< Format for atomic_count_t. */
 
Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/async.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -120,5 +120,5 @@
 	ipc_call_t *dataptr;
 	
-	ipcarg_t retval;
+	sysarg_t retval;
 } amsg_t;
 
@@ -140,5 +140,5 @@
 	
 	/** Incoming phone hash. */
-	ipcarg_t in_phone_hash;
+	sysarg_t in_phone_hash;
 	
 	/** Messages that should be delivered to this fibril. */
@@ -288,5 +288,5 @@
 	list_append(&msg->link, &conn->msg_queue);
 	
-	if (IPC_GET_METHOD(*call) == IPC_M_PHONE_HUNGUP)
+	if (IPC_GET_IMETHOD(*call) == IPC_M_PHONE_HUNGUP)
 		conn->close_callid = callid;
 	
@@ -401,5 +401,5 @@
 			 */
 			memset(call, 0, sizeof(ipc_call_t));
-			IPC_SET_METHOD(*call, IPC_M_PHONE_HUNGUP);
+			IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP);
 			futex_up(&async_futex);
 			return conn->close_callid;
@@ -529,5 +529,5 @@
  *
  */
-fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid,
+fid_t async_new_connection(sysarg_t in_phone_hash, ipc_callid_t callid,
     ipc_call_t *call, void (*cfibril)(ipc_callid_t, ipc_call_t *))
 {
@@ -588,5 +588,5 @@
 	}
 	
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_CONNECT_ME:
 	case IPC_M_CONNECT_ME_TO:
@@ -807,6 +807,6 @@
  *
  */
-aid_t async_send_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
+aid_t async_send_fast(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr)
 {
 	amsg_t *msg = malloc(sizeof(*msg));
@@ -846,6 +846,6 @@
  *
  */
-aid_t async_send_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
+aid_t async_send_slow(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
     ipc_call_t *dataptr)
 {
@@ -875,5 +875,5 @@
  *
  */
-void async_wait_for(aid_t amsgid, ipcarg_t *retval)
+void async_wait_for(aid_t amsgid, sysarg_t *retval)
 {
 	amsg_t *msg = (amsg_t *) amsgid;
@@ -911,5 +911,5 @@
  *
  */
-int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout)
+int async_wait_timeout(aid_t amsgid, sysarg_t *retval, suseconds_t timeout)
 {
 	amsg_t *msg = (amsg_t *) amsgid;
@@ -1023,7 +1023,7 @@
  *
  */
-ipcarg_t async_req_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t *r1, ipcarg_t *r2,
-    ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5)
+sysarg_t async_req_fast(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t *r1, sysarg_t *r2,
+    sysarg_t *r3, sysarg_t *r4, sysarg_t *r5)
 {
 	ipc_call_t result;
@@ -1031,5 +1031,5 @@
 	    &result);
 	
-	ipcarg_t rc;
+	sysarg_t rc;
 	async_wait_for(eid, &rc);
 	
@@ -1072,7 +1072,7 @@
  *
  */
-ipcarg_t async_req_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *r1,
-    ipcarg_t *r2, ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5)
+sysarg_t async_req_slow(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *r1,
+    sysarg_t *r2, sysarg_t *r3, sysarg_t *r4, sysarg_t *r5)
 {
 	ipc_call_t result;
@@ -1080,5 +1080,5 @@
 	    &result);
 	
-	ipcarg_t rc;
+	sysarg_t rc;
 	async_wait_for(eid, &rc);
 	
@@ -1113,8 +1113,8 @@
  */
 int
-async_connect_me_to(int phoneid, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3)
+async_connect_me_to(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3)
 {
 	int rc;
-	ipcarg_t newphid;
+	sysarg_t newphid;
 
 	rc = async_req_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, NULL,
@@ -1140,9 +1140,9 @@
  */
 int
-async_connect_me_to_blocking(int phoneid, ipcarg_t arg1, ipcarg_t arg2,
-    ipcarg_t arg3)
+async_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3)
 {
 	int rc;
-	ipcarg_t newphid;
+	sysarg_t newphid;
 
 	rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
@@ -1166,11 +1166,11 @@
  * @return		Zero on success or a negative error code from errno.h.
  */
-int async_share_in_start(int phoneid, void *dst, size_t size, ipcarg_t arg,
+int async_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
     int *flags)
 {
 	int res;
 	sysarg_t tmp_flags;
-	res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst,
-	    (ipcarg_t) size, arg, NULL, &tmp_flags);
+	res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
+	    (sysarg_t) size, arg, NULL, &tmp_flags);
 	if (flags)
 		*flags = tmp_flags;
@@ -1199,5 +1199,5 @@
 
 	*callid = async_get_call(&data);
-	if (IPC_GET_METHOD(data) != IPC_M_SHARE_IN)
+	if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN)
 		return 0;
 	*size = (size_t) IPC_GET_ARG2(data);
@@ -1231,6 +1231,6 @@
 int async_share_out_start(int phoneid, void *src, int flags)
 {
-	return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (ipcarg_t) src, 0,
-	    (ipcarg_t) flags);
+	return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
+	    (sysarg_t) flags);
 }
 
@@ -1259,5 +1259,5 @@
 
 	*callid = async_get_call(&data);
-	if (IPC_GET_METHOD(data) != IPC_M_SHARE_OUT)
+	if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT)
 		return 0;
 	*size = (size_t) IPC_GET_ARG2(data);
@@ -1292,6 +1292,6 @@
 int async_data_read_start(int phoneid, void *dst, size_t size)
 {
-	return async_req_2_0(phoneid, IPC_M_DATA_READ, (ipcarg_t) dst,
-	    (ipcarg_t) size);
+	return async_req_2_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
+	    (sysarg_t) size);
 }
 
@@ -1317,5 +1317,5 @@
 
 	*callid = async_get_call(&data);
-	if (IPC_GET_METHOD(data) != IPC_M_DATA_READ)
+	if (IPC_GET_IMETHOD(data) != IPC_M_DATA_READ)
 		return 0;
 	if (size)
@@ -1345,6 +1345,6 @@
  *
  */
-int async_data_read_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
+int async_data_read_forward_fast(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr)
 {
 	ipc_callid_t callid;
@@ -1369,5 +1369,5 @@
 	}
 	
-	ipcarg_t rc;
+	sysarg_t rc;
 	async_wait_for(msg, &rc);
 	
@@ -1386,6 +1386,6 @@
 int async_data_write_start(int phoneid, const void *src, size_t size)
 {
-	return async_req_2_0(phoneid, IPC_M_DATA_WRITE, (ipcarg_t) src,
-	    (ipcarg_t) size);
+	return async_req_2_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src,
+	    (sysarg_t) size);
 }
 
@@ -1412,5 +1412,5 @@
 	
 	*callid = async_get_call(&data);
-	if (IPC_GET_METHOD(data) != IPC_M_DATA_WRITE)
+	if (IPC_GET_IMETHOD(data) != IPC_M_DATA_WRITE)
 		return 0;
 	
@@ -1531,6 +1531,6 @@
  *
  */
-int async_data_write_forward_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
+int async_data_write_forward_fast(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr)
 {
 	ipc_callid_t callid;
@@ -1555,5 +1555,5 @@
 	}
 	
-	ipcarg_t rc;
+	sysarg_t rc;
 	async_wait_for(msg, &rc);
 	
Index: uspace/lib/c/generic/cap.c
===================================================================
--- uspace/lib/c/generic/cap.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/cap.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -31,6 +31,6 @@
  */
 /**
- * @file	cap.c
- * @brief	Functions to grant/revoke capabilities to/from a task.
+ * @file  cap.c
+ * @brief Functions to grant/revoke capabilities to/from a task.
  */
 
@@ -38,36 +38,43 @@
 #include <task.h>
 #include <libc.h>
-#include <kernel/syscall/sysarg64.h>
 
 /** Grant capabilities to a task.
  *
- * @param id Destination task ID.
+ * @param id   Destination task ID.
  * @param caps Capabilities to grant.
  *
  * @return Zero on success or a value from @ref errno.h on failure.
+ *
  */
 int cap_grant(task_id_t id, unsigned int caps)
 {
-	sysarg64_t arg;
+#ifdef __32_BITS__
+	sysarg64_t arg = (sysarg64_t) id;
+	return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) &arg, (sysarg_t) caps);
+#endif
 	
-	arg.value = (unsigned long long) id;
-
-	return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) &arg, (sysarg_t) caps);
+#ifdef __64_BITS__
+	return __SYSCALL2(SYS_CAP_GRANT, (sysarg_t) id, (sysarg_t) caps);
+#endif
 }
 
 /** Revoke capabilities from a task.
  *
- * @param id Destination task ID.
+ * @param id   Destination task ID.
  * @param caps Capabilities to revoke.
  *
  * @return Zero on success or a value from @ref errno.h on failure.
+ *
  */
 int cap_revoke(task_id_t id, unsigned int caps)
 {
-	sysarg64_t arg;
+#ifdef __32_BITS__
+	sysarg64_t arg = (sysarg64_t) id;
+	return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) &arg, (sysarg_t) caps);
+#endif
 	
-	arg.value = (unsigned long long) id;
-
-	return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) &arg, (sysarg_t) caps);
+#ifdef __64_BITS__
+	return __SYSCALL2(SYS_CAP_REVOKE, (sysarg_t) id, (sysarg_t) caps);
+#endif
 }
 
Index: uspace/lib/c/generic/clipboard.c
===================================================================
--- uspace/lib/c/generic/clipboard.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/clipboard.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -75,5 +75,5 @@
 		clip_connect();
 		
-		ipcarg_t rc = async_req_1_0(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_NONE);
+		sysarg_t rc = async_req_1_0(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_NONE);
 		
 		async_serialize_end();
@@ -85,7 +85,7 @@
 		
 		aid_t req = async_send_1(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_DATA, NULL);
-		ipcarg_t rc = async_data_write_start(clip_phone, (void *) str, size);
+		sysarg_t rc = async_data_write_start(clip_phone, (void *) str, size);
 		if (rc != EOK) {
-			ipcarg_t rc_orig;
+			sysarg_t rc_orig;
 			async_wait_for(req, &rc_orig);
 			async_serialize_end();
@@ -119,7 +119,7 @@
 		clip_connect();
 		
-		ipcarg_t size;
-		ipcarg_t tag;
-		ipcarg_t rc = async_req_0_2(clip_phone, CLIPBOARD_CONTENT, &size, &tag);
+		sysarg_t size;
+		sysarg_t tag;
+		sysarg_t rc = async_req_0_2(clip_phone, CLIPBOARD_CONTENT, &size, &tag);
 		
 		async_serialize_end();
@@ -158,5 +158,5 @@
 			
 			if (rc != EOK) {
-				ipcarg_t rc_orig;
+				sysarg_t rc_orig;
 				async_wait_for(req, &rc_orig);
 				async_serialize_end();
Index: uspace/lib/c/generic/device/char.c
===================================================================
--- uspace/lib/c/generic/device/char.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/device/char.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -76,5 +76,5 @@
 	}
 	
-	ipcarg_t rc;
+	sysarg_t rc;
 	if (ret != EOK) {
 		async_wait_for(req, &rc);
Index: uspace/lib/c/generic/device/hw_res.c
===================================================================
--- uspace/lib/c/generic/device/hw_res.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/device/hw_res.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,5 +40,5 @@
 bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
 {
-	ipcarg_t count = 0;
+	sysarg_t count = 0;
 	int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count);
 	hw_resources->count = count;
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/devman.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -95,5 +95,5 @@
 	aid_t req = async_send_2(phone, DEVMAN_DRIVER_REGISTER, 0, 0, &answer);
 	
-	ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
+	sysarg_t retval = async_data_write_start(phone, name, str_size(name));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
@@ -104,5 +104,5 @@
 	async_set_client_connection(conn);
 	
-	ipcarg_t callback_phonehash;
+	sysarg_t callback_phonehash;
 	ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash);
 	async_wait_for(req, &retval);
@@ -155,5 +155,5 @@
 	aid_t req = async_send_2(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, match_count, &answer);
 
-	ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
+	sysarg_t retval = async_data_write_start(phone, name, str_size(name));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
@@ -192,5 +192,5 @@
 	aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, devman_handle, &answer);
 	
-	ipcarg_t retval = async_data_write_start(phone, class_name, str_size(class_name));
+	sysarg_t retval = async_data_write_start(phone, class_name, str_size(class_name));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
@@ -230,8 +230,8 @@
 	
 	if (flags & IPC_FLAG_BLOCKING) {
-		phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,
+		phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,
 		    DEVMAN_CONNECT_TO_DEVICE, handle);
 	} else {
-		phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAN,
+		phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAN,
 		    DEVMAN_CONNECT_TO_DEVICE, handle);
 	}
@@ -268,5 +268,5 @@
 	    &answer);
 	
-	ipcarg_t retval = async_data_write_start(phone, pathname, str_size(pathname));
+	sysarg_t retval = async_data_write_start(phone, pathname, str_size(pathname));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
Index: uspace/lib/c/generic/devmap.c
===================================================================
--- uspace/lib/c/generic/devmap.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/devmap.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -107,5 +107,5 @@
 	aid_t req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
 	
-	ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
+	sysarg_t retval = async_data_write_start(phone, name, str_size(name));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
@@ -116,5 +116,5 @@
 	async_set_client_connection(conn);
 	
-	ipcarg_t callback_phonehash;
+	sysarg_t callback_phonehash;
 	ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash);
 	async_wait_for(req, &retval);
@@ -145,5 +145,5 @@
 	    &answer);
 	
-	ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
+	sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
@@ -181,5 +181,5 @@
 	    &answer);
 	
-	ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
+	sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
@@ -217,5 +217,5 @@
 	    &answer);
 	
-	ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
+	sysarg_t retval = async_data_write_start(phone, name, str_size(name));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
@@ -247,5 +247,5 @@
 		return phone;
 	
-	ipcarg_t type;
+	sysarg_t type;
 	int retval = async_req_1_1(phone, DEVMAP_HANDLE_PROBE, handle, &type);
 	if (retval != EOK)
@@ -277,5 +277,5 @@
 		return -1;
 	
-	ipcarg_t null_id;
+	sysarg_t null_id;
 	int retval = async_req_0_1(phone, DEVMAP_NULL_CREATE, &null_id);
 	if (retval != EOK)
@@ -292,10 +292,10 @@
 		return;
 	
-	async_req_1_0(phone, DEVMAP_NULL_DESTROY, (ipcarg_t) null_id);
+	async_req_1_0(phone, DEVMAP_NULL_DESTROY, (sysarg_t) null_id);
 }
 
 static size_t devmap_count_namespaces_internal(int phone)
 {
-	ipcarg_t count;
+	sysarg_t count;
 	int retval = async_req_0_1(phone, DEVMAP_GET_NAMESPACE_COUNT, &count);
 	if (retval != EOK)
@@ -307,5 +307,5 @@
 static size_t devmap_count_devices_internal(int phone, devmap_handle_t ns_handle)
 {
-	ipcarg_t count;
+	sysarg_t count;
 	int retval = async_req_1_1(phone, DEVMAP_GET_DEVICE_COUNT, ns_handle, &count);
 	if (retval != EOK)
@@ -375,5 +375,5 @@
 		}
 		
-		ipcarg_t retval;
+		sysarg_t retval;
 		async_wait_for(req, &retval);
 		async_serialize_end();
@@ -427,5 +427,5 @@
 		}
 		
-		ipcarg_t retval;
+		sysarg_t retval;
 		async_wait_for(req, &retval);
 		async_serialize_end();
Index: uspace/lib/c/generic/event.c
===================================================================
--- uspace/lib/c/generic/event.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/event.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -49,5 +49,5 @@
  * @return Value returned by the kernel.
  */
-int event_subscribe(event_type_t e, ipcarg_t method)
+int event_subscribe(event_type_t e, sysarg_t method)
 {
 	return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) e, (sysarg_t) method);
Index: uspace/lib/c/generic/io/console.c
===================================================================
--- uspace/lib/c/generic/io/console.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/io/console.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -45,5 +45,5 @@
 }
 
-int console_get_size(int phone, ipcarg_t *cols, ipcarg_t *rows)
+int console_get_size(int phone, sysarg_t *cols, sysarg_t *rows)
 {
 	return async_req_0_2(phone, CONSOLE_GET_SIZE, cols, rows);
@@ -71,5 +71,5 @@
 }
 
-int console_get_color_cap(int phone, ipcarg_t *ccap)
+int console_get_color_cap(int phone, sysarg_t *ccap)
 {
 	return async_req_0_1(phone, CONSOLE_GET_COLOR_CAP, ccap);
@@ -81,10 +81,10 @@
 }
 
-int console_get_pos(int phone, ipcarg_t *col, ipcarg_t *row)
+int console_get_pos(int phone, sysarg_t *col, sysarg_t *row)
 {
 	return async_req_0_2(phone, CONSOLE_GET_POS, col, row);
 }
 
-void console_set_pos(int phone, ipcarg_t col, ipcarg_t row)
+void console_set_pos(int phone, sysarg_t col, sysarg_t row)
 {
 	async_msg_2(phone, CONSOLE_GOTO, col, row);
@@ -93,8 +93,8 @@
 bool console_get_event(int phone, console_event_t *event)
 {
-	ipcarg_t type;
-	ipcarg_t key;
-	ipcarg_t mods;
-	ipcarg_t c;
+	sysarg_t type;
+	sysarg_t key;
+	sysarg_t mods;
+	sysarg_t c;
 	
 	int rc = async_req_0_4(phone, CONSOLE_GET_EVENT, &type, &key, &mods, &c);
Index: uspace/lib/c/generic/io/screenbuffer.c
===================================================================
--- uspace/lib/c/generic/io/screenbuffer.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/io/screenbuffer.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -67,6 +67,6 @@
  *
  */
-screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, ipcarg_t size_x,
-    ipcarg_t size_y)
+screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, sysarg_t size_x,
+    sysarg_t size_y)
 {
 	scr->buffer = (keyfield_t *) malloc(sizeof(keyfield_t) * size_x * size_y);
@@ -110,7 +110,7 @@
  *
  */
-void screenbuffer_clear_line(screenbuffer_t *scr, ipcarg_t line)
+void screenbuffer_clear_line(screenbuffer_t *scr, sysarg_t line)
 {
-	ipcarg_t x;
+	sysarg_t x;
 	
 	for (x = 0; x < scr->size_x; x++) {
@@ -141,5 +141,5 @@
  *
  */
-void screenbuffer_goto(screenbuffer_t *scr, ipcarg_t x, ipcarg_t y)
+void screenbuffer_goto(screenbuffer_t *scr, sysarg_t x, sysarg_t y)
 {
 	scr->position_x = x % scr->size_x;
Index: uspace/lib/c/generic/ipc.c
===================================================================
--- uspace/lib/c/generic/ipc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/ipc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -38,5 +38,5 @@
  */
 /** @file
- */ 
+ */
 
 #include <ipc/ipc.h>
@@ -104,7 +104,7 @@
  */
 int
-ipc_call_sync_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
-    ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3,
-    ipcarg_t *result4, ipcarg_t *result5)
+ipc_call_sync_fast(int phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3, sysarg_t *result1, sysarg_t *result2, sysarg_t *result3,
+    sysarg_t *result4, sysarg_t *result5)
 {
 	ipc_call_t resdata;
@@ -131,29 +131,29 @@
 /** Make a synchronous call transmitting 5 arguments of payload.
  *
- * @param phoneid	Phone handle for the call.
- * @param method	Requested method.
- * @param arg1		Service-defined payload argument.
- * @param arg2		Service-defined payload argument.
- * @param arg3		Service-defined payload argument.
- * @param arg4		Service-defined payload argument.
- * @param arg5		Service-defined payload argument.
- * @param result1	If non-NULL, storage for the first return argument.
- * @param result2	If non-NULL, storage for the second return argument.
- * @param result3	If non-NULL, storage for the third return argument.
- * @param result4	If non-NULL, storage for the fourth return argument.
- * @param result5	If non-NULL, storage for the fifth return argument.
- *
- * @return		Negative value means IPC error.
- *			Otherwise the RETVAL of the answer.
+ * @param phoneid Phone handle for the call.
+ * @param imethod Requested interface and method.
+ * @param arg1    Service-defined payload argument.
+ * @param arg2    Service-defined payload argument.
+ * @param arg3    Service-defined payload argument.
+ * @param arg4    Service-defined payload argument.
+ * @param arg5    Service-defined payload argument.
+ * @param result1 If non-NULL, storage for the first return argument.
+ * @param result2 If non-NULL, storage for the second return argument.
+ * @param result3 If non-NULL, storage for the third return argument.
+ * @param result4 If non-NULL, storage for the fourth return argument.
+ * @param result5 If non-NULL, storage for the fifth return argument.
+ *
+ * @return Negative value means IPC error.
+ *         Otherwise the RETVAL of the answer.
+ *
  */
 int
-ipc_call_sync_slow(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
-    ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *result1,
-    ipcarg_t *result2, ipcarg_t *result3, ipcarg_t *result4, ipcarg_t *result5)
+ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *result1,
+    sysarg_t *result2, sysarg_t *result3, sysarg_t *result4, sysarg_t *result5)
 {
 	ipc_call_t data;
-	int callres;
-
-	IPC_SET_METHOD(data, method);
+	
+	IPC_SET_IMETHOD(data, imethod);
 	IPC_SET_ARG1(data, arg1);
 	IPC_SET_ARG2(data, arg2);
@@ -161,10 +161,10 @@
 	IPC_SET_ARG4(data, arg4);
 	IPC_SET_ARG5(data, arg5);
-
-	callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid, (sysarg_t) &data,
-	    (sysarg_t) &data);
+	
+	int callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid,
+	    (sysarg_t) &data, (sysarg_t) &data);
 	if (callres)
 		return callres;
-
+	
 	if (result1)
 		*result1 = IPC_GET_ARG1(data);
@@ -177,5 +177,5 @@
 	if (result5)
 		*result5 = IPC_GET_ARG5(data);
-
+	
 	return IPC_GET_RETVAL(data);
 }
@@ -183,8 +183,9 @@
 /** Syscall to send asynchronous message.
  *
- * @param phoneid	Phone handle for the call.
- * @param data		Call data with the request.
- *
- * @return		Hash of the call or an error code.
+ * @param phoneid Phone handle for the call.
+ * @param data    Call data with the request.
+ *
+ * @return Hash of the call or an error code.
+ *
  */
 static ipc_callid_t _ipc_call_async(int phoneid, ipc_call_t *data)
@@ -277,23 +278,23 @@
  * If the call cannot be temporarily made, queue it.
  *
- * @param phoneid	Phone handle for the call.
- * @param method	Requested method.
- * @param arg1		Service-defined payload argument.
- * @param arg2		Service-defined payload argument.
- * @param arg3		Service-defined payload argument.
- * @param arg4		Service-defined payload argument.
- * @param private	Argument to be passed to the answer/error callback.
- * @param callback	Answer or error callback.
- * @param can_preempt	If non-zero, the current fibril will be preempted in
- *			case the kernel temporarily refuses to accept more
- *			asynchronous calls.
- */
-void ipc_call_async_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, void *private,
+ * @param phoneid     Phone handle for the call.
+ * @param imethod     Requested interface and method.
+ * @param arg1        Service-defined payload argument.
+ * @param arg2        Service-defined payload argument.
+ * @param arg3        Service-defined payload argument.
+ * @param arg4        Service-defined payload argument.
+ * @param private     Argument to be passed to the answer/error callback.
+ * @param callback    Answer or error callback.
+ * @param can_preempt If non-zero, the current fibril will be preempted in
+ *                    case the kernel temporarily refuses to accept more
+ *                    asynchronous calls.
+ *
+ */
+void ipc_call_async_fast(int phoneid, sysarg_t imethod, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, void *private,
     ipc_async_callback_t callback, int can_preempt)
 {
 	async_call_t *call = NULL;
-	ipc_callid_t callid;
-
+	
 	if (callback) {
 		call = ipc_prepare_async(private, callback);
@@ -301,5 +302,5 @@
 			return;
 	}
-
+	
 	/*
 	 * We need to make sure that we get callid before another thread
@@ -307,7 +308,7 @@
 	 */
 	futex_down(&ipc_futex);
-	callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1,
-	    arg2, arg3, arg4);
-
+	ipc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid,
+	    imethod, arg1, arg2, arg3, arg4);
+	
 	if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) {
 		if (!call) {
@@ -316,5 +317,5 @@
 				return;
 		}
-		IPC_SET_METHOD(call->u.msg.data, method);
+		IPC_SET_IMETHOD(call->u.msg.data, imethod);
 		IPC_SET_ARG1(call->u.msg.data, arg1);
 		IPC_SET_ARG2(call->u.msg.data, arg2);
@@ -337,20 +338,20 @@
  * If the call cannot be temporarily made, queue it.
  *
- * @param phoneid	Phone handle for the call.
- * @param method	Requested method.
- * @param arg1		Service-defined payload argument.
- * @param arg2		Service-defined payload argument.
- * @param arg3		Service-defined payload argument.
- * @param arg4		Service-defined payload argument.
- * @param arg5		Service-defined payload argument.
- * @param private	Argument to be passed to the answer/error callback.
- * @param callback	Answer or error callback.
- * @param can_preempt	If non-zero, the current fibril will be preempted in
- *			case the kernel temporarily refuses to accept more
- *			asynchronous calls.
- *
- */
-void ipc_call_async_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, void *private,
+ * @param phoneid     Phone handle for the call.
+ * @param imethod     Requested interface and method.
+ * @param arg1        Service-defined payload argument.
+ * @param arg2        Service-defined payload argument.
+ * @param arg3        Service-defined payload argument.
+ * @param arg4        Service-defined payload argument.
+ * @param arg5        Service-defined payload argument.
+ * @param private     Argument to be passed to the answer/error callback.
+ * @param callback    Answer or error callback.
+ * @param can_preempt If non-zero, the current fibril will be preempted in
+ *                    case the kernel temporarily refuses to accept more
+ *                    asynchronous calls.
+ *
+ */
+void ipc_call_async_slow(int phoneid, sysarg_t imethod, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private,
     ipc_async_callback_t callback, int can_preempt)
 {
@@ -362,5 +363,5 @@
 		return;
 
-	IPC_SET_METHOD(call->u.msg.data, method);
+	IPC_SET_IMETHOD(call->u.msg.data, imethod);
 	IPC_SET_ARG1(call->u.msg.data, arg1);
 	IPC_SET_ARG2(call->u.msg.data, arg2);
@@ -393,6 +394,6 @@
  * @return		Zero on success or a value from @ref errno.h on failure.
  */
-ipcarg_t ipc_answer_fast(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4)
+sysarg_t ipc_answer_fast(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
 {
 	return __SYSCALL6(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2, arg3,
@@ -412,6 +413,6 @@
  * @return		Zero on success or a value from @ref errno.h on failure.
  */
-ipcarg_t ipc_answer_slow(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5)
+sysarg_t ipc_answer_slow(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
 {
 	ipc_call_t data;
@@ -585,5 +586,5 @@
  */
 int ipc_connect_to_me(int phoneid, int arg1, int arg2, int arg3, 
-    ipcarg_t *phonehash)
+    sysarg_t *phonehash)
 {
 	return ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2,
@@ -602,5 +603,5 @@
 int ipc_connect_me_to(int phoneid, int arg1, int arg2, int arg3)
 {
-	ipcarg_t newphid;
+	sysarg_t newphid;
 	int res;
 
@@ -626,5 +627,5 @@
 int ipc_connect_me_to_blocking(int phoneid, int arg1, int arg2, int arg3)
 {
-	ipcarg_t newphid;
+	sysarg_t newphid;
 	int res;
 
@@ -676,12 +677,12 @@
 /** Forward a received call to another destination.
  *
- * @param callid	Hash of the call to forward.
- * @param phoneid	Phone handle to use for forwarding.
- * @param method	New method for the forwarded call.
- * @param arg1		New value of the first argument for the forwarded call.
- * @param arg2		New value of the second argument for the forwarded call.
- * @param mode		Flags specifying mode of the forward operation.
- *
- * @return		Zero on success or an error code.
+ * @param callid  Hash of the call to forward.
+ * @param phoneid Phone handle to use for forwarding.
+ * @param imethod New interface and method for the forwarded call.
+ * @param arg1    New value of the first argument for the forwarded call.
+ * @param arg2    New value of the second argument for the forwarded call.
+ * @param mode    Flags specifying mode of the forward operation.
+ *
+ * @return Zero on success or an error code.
  *
  * For non-system methods, the old method, arg1 and arg2 are rewritten by the
@@ -690,19 +691,19 @@
  * methods are forwarded verbatim.
  */
-int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method,
-    ipcarg_t arg1, ipcarg_t arg2, int mode)
-{
-	return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1, 
+int ipc_forward_fast(ipc_callid_t callid, int phoneid, int imethod,
+    sysarg_t arg1, sysarg_t arg2, int mode)
+{
+	return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, imethod, arg1,
 	    arg2, mode);
 }
 
 
-int ipc_forward_slow(ipc_callid_t callid, int phoneid, int method,
-    ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
+int ipc_forward_slow(ipc_callid_t callid, int phoneid, int imethod,
+    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
     int mode)
 {
 	ipc_call_t data;
-
-	IPC_SET_METHOD(data, method);
+	
+	IPC_SET_IMETHOD(data, imethod);
 	IPC_SET_ARG1(data, arg1);
 	IPC_SET_ARG2(data, arg2);
@@ -710,5 +711,5 @@
 	IPC_SET_ARG4(data, arg4);
 	IPC_SET_ARG5(data, arg5);
-
+	
 	return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data, mode);
 }
@@ -725,10 +726,10 @@
  * @return		Zero on success or a negative error code from errno.h.
  */
-int ipc_share_in_start(int phoneid, void *dst, size_t size, ipcarg_t arg,
+int ipc_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg,
     int *flags)
 {
 	sysarg_t tmp_flags = 0;
-	int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (ipcarg_t) dst,
-	    (ipcarg_t) size, arg, NULL, &tmp_flags);
+	int res = ipc_call_sync_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,
+	    (sysarg_t) size, arg, NULL, &tmp_flags);
 	
 	if (flags)
@@ -751,5 +752,5 @@
 int ipc_share_in_finalize(ipc_callid_t callid, void *src, int flags)
 {
-	return ipc_answer_2(callid, EOK, (ipcarg_t) src, (ipcarg_t) flags);
+	return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) flags);
 }
 
@@ -764,6 +765,6 @@
 int ipc_share_out_start(int phoneid, void *src, int flags)
 {
-	return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (ipcarg_t) src, 0,
-	    (ipcarg_t) flags);
+	return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
+	    (sysarg_t) flags);
 }
 
@@ -780,5 +781,5 @@
 int ipc_share_out_finalize(ipc_callid_t callid, void *dst)
 {
-	return ipc_answer_1(callid, EOK, (ipcarg_t) dst);
+	return ipc_answer_1(callid, EOK, (sysarg_t) dst);
 }
 
@@ -794,6 +795,6 @@
 int ipc_data_read_start(int phoneid, void *dst, size_t size)
 {
-	return ipc_call_sync_2_0(phoneid, IPC_M_DATA_READ, (ipcarg_t) dst,
-	    (ipcarg_t) size);
+	return ipc_call_sync_2_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
+	    (sysarg_t) size);
 }
 
@@ -812,5 +813,5 @@
 int ipc_data_read_finalize(ipc_callid_t callid, const void *src, size_t size)
 {
-	return ipc_answer_2(callid, EOK, (ipcarg_t) src, (ipcarg_t) size);
+	return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) size);
 }
 
@@ -825,6 +826,6 @@
 int ipc_data_write_start(int phoneid, const void *src, size_t size)
 {
-	return ipc_call_sync_2_0(phoneid, IPC_M_DATA_WRITE, (ipcarg_t) src,
-	    (ipcarg_t) size);
+	return ipc_call_sync_2_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src,
+	    (sysarg_t) size);
 }
 
@@ -842,19 +843,22 @@
 int ipc_data_write_finalize(ipc_callid_t callid, void *dst, size_t size)
 {
-	return ipc_answer_2(callid, EOK, (ipcarg_t) dst, (ipcarg_t) size);
-}
-
-#include <kernel/syscall/sysarg64.h>
+	return ipc_answer_2(callid, EOK, (sysarg_t) dst, (sysarg_t) size);
+}
+
 /** Connect to a task specified by id.
+ *
  */
 int ipc_connect_kbox(task_id_t id)
 {
-	sysarg64_t arg;
-
-	arg.value = (unsigned long long) id;
-
+#ifdef __32_BITS__
+	sysarg64_t arg = (sysarg64_t) id;
 	return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) &arg);
-}
- 
+#endif
+	
+#ifdef __64_BITS__
+	return __SYSCALL1(SYS_IPC_CONNECT_KBOX, (sysarg_t) id);
+#endif
+}
+
 /** @}
  */
Index: uspace/lib/c/generic/loader.c
===================================================================
--- uspace/lib/c/generic/loader.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/loader.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -96,5 +96,5 @@
 	}
 	
-	ipcarg_t retval;
+	sysarg_t retval;
 	async_wait_for(req, &retval);
 	return (int) retval;
@@ -131,5 +131,5 @@
 	}
 	
-	ipcarg_t retval;
+	sysarg_t retval;
 	async_wait_for(req, &retval);
 	return (int) retval;
@@ -166,5 +166,5 @@
 	free(pa);
 	
-	ipcarg_t retval;
+	sysarg_t retval;
 	async_wait_for(req, &retval);
 	return (int) retval;
@@ -213,5 +213,5 @@
 	ipc_call_t answer;
 	aid_t req = async_send_0(ldr->phone_id, LOADER_SET_ARGS, &answer);
-	ipcarg_t rc = async_data_write_start(ldr->phone_id, (void *) arg_buf, buffer_size);
+	sysarg_t rc = async_data_write_start(ldr->phone_id, (void *) arg_buf, buffer_size);
 	if (rc != EOK) {
 		async_wait_for(req, NULL);
@@ -267,5 +267,5 @@
 	ipc_call_t answer;
 	aid_t req = async_send_0(ldr->phone_id, LOADER_SET_FILES, &answer);
-	ipcarg_t rc = async_data_write_start(ldr->phone_id, (void *) files_buf,
+	sysarg_t rc = async_data_write_start(ldr->phone_id, (void *) files_buf,
 	    count * sizeof(fdi_node_t));
 	if (rc != EOK) {
Index: uspace/lib/c/generic/net/icmp_api.c
===================================================================
--- uspace/lib/c/generic/net/icmp_api.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/net/icmp_api.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -81,5 +81,5 @@
 {
 	aid_t message_id;
-	ipcarg_t result;
+	sysarg_t result;
 
 	if (addrlen <= 0)
@@ -87,5 +87,5 @@
 
 	message_id = async_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl,
-	    tos, (ipcarg_t) dont_fragment, NULL);
+	    tos, (sysarg_t) dont_fragment, NULL);
 
 	// send the address
Index: uspace/lib/c/generic/net/modules.c
===================================================================
--- uspace/lib/c/generic/net/modules.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/net/modules.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -67,21 +67,21 @@
 		switch (answer_count) {
 		case 0:
-			ipc_answer_0(callid, (ipcarg_t) result);
+			ipc_answer_0(callid, (sysarg_t) result);
 			break;
 		case 1:
-			ipc_answer_1(callid, (ipcarg_t) result,
+			ipc_answer_1(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer));
 			break;
 		case 2:
-			ipc_answer_2(callid, (ipcarg_t) result,
+			ipc_answer_2(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer));
 			break;
 		case 3:
-			ipc_answer_3(callid, (ipcarg_t) result,
+			ipc_answer_3(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
 			    IPC_GET_ARG3(*answer));
 			break;
 		case 4:
-			ipc_answer_4(callid, (ipcarg_t) result,
+			ipc_answer_4(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
 			    IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer));
@@ -89,5 +89,5 @@
 		case 5:
 		default:
-			ipc_answer_5(callid, (ipcarg_t) result,
+			ipc_answer_5(callid, (sysarg_t) result,
 			    IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer),
 			    IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer),
@@ -111,5 +111,5 @@
  *			function.
  */
-int bind_service(services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3,
+int bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
     async_client_conn_t client_receiver)
 {
@@ -134,6 +134,6 @@
  *
  */
-int bind_service_timeout(services_t need, ipcarg_t arg1, ipcarg_t arg2,
-    ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout)
+int bind_service_timeout(services_t need, sysarg_t arg1, sysarg_t arg2,
+    sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout)
 {
 	int rc;
@@ -143,5 +143,5 @@
 	if (phone >= 0) {
 		/* Request the bidirectional connection */
-		ipcarg_t phonehash;
+		sysarg_t phonehash;
 		
 		rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash);
@@ -283,5 +283,5 @@
 		IPC_SET_RETVAL(*answer, 0);
 		// just to be precize
-		IPC_SET_METHOD(*answer, 0);
+		IPC_SET_IMETHOD(*answer, 0);
 		IPC_SET_ARG1(*answer, 0);
 		IPC_SET_ARG2(*answer, 0);
Index: uspace/lib/c/generic/net/socket_client.c
===================================================================
--- uspace/lib/c/generic/net/socket_client.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/net/socket_client.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -214,5 +214,5 @@
 	callid = async_get_call(&call);
 
-	switch (IPC_GET_METHOD(call)) {
+	switch (IPC_GET_IMETHOD(call)) {
 	case NET_SOCKET_RECEIVED:
 	case NET_SOCKET_ACCEPTED:
@@ -229,5 +229,5 @@
 		}
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case NET_SOCKET_RECEIVED:
 			fibril_mutex_lock(&socket->receive_lock);
@@ -278,5 +278,5 @@
 	}
 
-	ipc_answer_0(callid, (ipcarg_t) rc);
+	ipc_answer_0(callid, (sysarg_t) rc);
 	goto loop;
 }
@@ -404,6 +404,6 @@
 	int socket_id;
 	services_t service;
-	ipcarg_t fragment_size;
-	ipcarg_t header_size;
+	sysarg_t fragment_size;
+	sysarg_t header_size;
 	int rc;
 
@@ -494,5 +494,5 @@
 		dyn_fifo_destroy(&socket->accepted);
 		free(socket);
-		async_msg_3(phone, NET_SOCKET_CLOSE, (ipcarg_t) socket_id, 0,
+		async_msg_3(phone, NET_SOCKET_CLOSE, (sysarg_t) socket_id, 0,
 		    service);
 		return rc;
@@ -516,10 +516,10 @@
  */
 static int
-socket_send_data(int socket_id, ipcarg_t message, ipcarg_t arg2,
+socket_send_data(int socket_id, sysarg_t message, sysarg_t arg2,
     const void *data, size_t datalength)
 {
 	socket_t *socket;
 	aid_t message_id;
-	ipcarg_t result;
+	sysarg_t result;
 
 	if (!data)
@@ -540,5 +540,5 @@
 	// request the message
 	message_id = async_send_3(socket->phone, message,
-	    (ipcarg_t) socket->socket_id, arg2, socket->service, NULL);
+	    (sysarg_t) socket->socket_id, arg2, socket->service, NULL);
 	// send the address
 	async_data_write_start(socket->phone, data, datalength);
@@ -600,5 +600,5 @@
 	// request listen backlog change
 	result = (int) async_req_3_0(socket->phone, NET_SOCKET_LISTEN,
-	    (ipcarg_t) socket->socket_id, (ipcarg_t) backlog, socket->service);
+	    (sysarg_t) socket->socket_id, (sysarg_t) backlog, socket->service);
 
 	fibril_rwlock_read_unlock(&socket_globals.lock);
@@ -625,5 +625,5 @@
 	socket_t *new_socket;
 	aid_t message_id;
-	ipcarg_t ipc_result;
+	sysarg_t ipc_result;
 	int result;
 	ipc_call_t answer;
@@ -683,5 +683,5 @@
 	// request accept
 	message_id = async_send_5(socket->phone, NET_SOCKET_ACCEPT,
-	    (ipcarg_t) socket->socket_id, 0, socket->service, 0,
+	    (sysarg_t) socket->socket_id, 0, socket->service, 0,
 	    new_socket->socket_id, &answer);
 
@@ -782,5 +782,5 @@
 	// request close
 	rc = (int) async_req_3_0(socket->phone, NET_SOCKET_CLOSE,
-	    (ipcarg_t) socket->socket_id, 0, socket->service);
+	    (sysarg_t) socket->socket_id, 0, socket->service);
 	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&socket_globals.lock);
@@ -815,5 +815,5 @@
  */
 static int
-sendto_core(ipcarg_t message, int socket_id, const void *data,
+sendto_core(sysarg_t message, int socket_id, const void *data,
     size_t datalength, int flags, const struct sockaddr *toaddr,
     socklen_t addrlen)
@@ -821,5 +821,5 @@
 	socket_t *socket;
 	aid_t message_id;
-	ipcarg_t result;
+	sysarg_t result;
 	size_t fragments;
 	ipc_call_t answer;
@@ -855,7 +855,7 @@
 	// request send
 	message_id = async_send_5(socket->phone, message,
-	    (ipcarg_t) socket->socket_id,
+	    (sysarg_t) socket->socket_id,
 	    (fragments == 1 ? datalength : socket->data_fragment_size),
-	    socket->service, (ipcarg_t) flags, fragments, &answer);
+	    socket->service, (sysarg_t) flags, fragments, &answer);
 
 	// send the address if given
@@ -973,10 +973,10 @@
  */
 static int
-recvfrom_core(ipcarg_t message, int socket_id, void *data, size_t datalength,
+recvfrom_core(sysarg_t message, int socket_id, void *data, size_t datalength,
     int flags, struct sockaddr *fromaddr, socklen_t *addrlen)
 {
 	socket_t *socket;
 	aid_t message_id;
-	ipcarg_t ipc_result;
+	sysarg_t ipc_result;
 	int result;
 	size_t fragments;
@@ -1031,6 +1031,6 @@
 		// request packet data
 		message_id = async_send_4(socket->phone, message,
-		    (ipcarg_t) socket->socket_id, 0, socket->service,
-		    (ipcarg_t) flags, &answer);
+		    (sysarg_t) socket->socket_id, 0, socket->service,
+		    (sysarg_t) flags, &answer);
 
 		// read the address if desired
@@ -1060,6 +1060,6 @@
 		// request packet data
 		message_id = async_send_4(socket->phone, message,
-		    (ipcarg_t) socket->socket_id, 0, socket->service,
-		    (ipcarg_t) flags, &answer);
+		    (sysarg_t) socket->socket_id, 0, socket->service,
+		    (sysarg_t) flags, &answer);
 
 		// read the address if desired
@@ -1160,5 +1160,5 @@
 	socket_t *socket;
 	aid_t message_id;
-	ipcarg_t result;
+	sysarg_t result;
 
 	if (!value || !optlen)
@@ -1179,5 +1179,5 @@
 	// request option value
 	message_id = async_send_3(socket->phone, NET_SOCKET_GETSOCKOPT,
-	    (ipcarg_t) socket->socket_id, (ipcarg_t) optname, socket->service,
+	    (sysarg_t) socket->socket_id, (sysarg_t) optname, socket->service,
 	    NULL);
 
@@ -1214,5 +1214,5 @@
 	// send the value
 	return socket_send_data(socket_id, NET_SOCKET_SETSOCKOPT,
-	    (ipcarg_t) optname, value, optlen);
+	    (sysarg_t) optname, value, optlen);
 }
 
Index: uspace/lib/c/generic/task.c
===================================================================
--- uspace/lib/c/generic/task.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/task.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -47,8 +47,14 @@
 task_id_t task_get_id(void)
 {
+#ifdef __32_BITS__
 	task_id_t task_id;
 	(void) __SYSCALL1(SYS_TASK_GET_ID, (sysarg_t) &task_id);
 	
 	return task_id;
+#endif  /* __32_BITS__ */
+	
+#ifdef __64_BITS__
+	return (task_id_t) __SYSCALL0(SYS_TASK_GET_ID);
+#endif  /* __64_BITS__ */
 }
 
@@ -211,5 +217,5 @@
 int task_wait(task_id_t id, task_exit_t *texit, int *retval)
 {
-	ipcarg_t te, rv;
+	sysarg_t te, rv;
 	int rc;
 
Index: uspace/lib/c/generic/udebug.c
===================================================================
--- uspace/lib/c/generic/udebug.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/udebug.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -57,5 +57,5 @@
 	size_t *copied, size_t *needed)
 {
-	ipcarg_t a_copied, a_needed;
+	sysarg_t a_copied, a_needed;
 	int rc;
 
@@ -72,5 +72,5 @@
 	size_t *copied, size_t *needed)
 {
-	ipcarg_t a_copied, a_needed;
+	sysarg_t a_copied, a_needed;
 	int rc;
 
@@ -87,5 +87,5 @@
 	size_t *copied, size_t *needed)
 {
-	ipcarg_t a_copied, a_needed;
+	sysarg_t a_copied, a_needed;
 	int rc;
 
@@ -120,5 +120,5 @@
     sysarg_t *val0, sysarg_t *val1)
 {
-	ipcarg_t a_ev_type;
+	sysarg_t a_ev_type;
 	int rc;
 
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -158,7 +158,7 @@
 	vfs_connect();
 	
-	ipcarg_t rc_orig;
+	sysarg_t rc_orig;
 	aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, devmap_handle, flags, NULL);
-	ipcarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size);
+	sysarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size);
 	if (rc != EOK) {
 		async_wait_for(req, &rc_orig);
@@ -238,6 +238,6 @@
 int unmount(const char *mp)
 {
-	ipcarg_t rc;
-	ipcarg_t rc_orig;
+	sysarg_t rc;
+	sysarg_t rc_orig;
 	aid_t req;
 	size_t mpa_size;
@@ -282,8 +282,8 @@
 	ipc_call_t answer;
 	aid_t req = async_send_3(vfs_phone, VFS_IN_OPEN, lflag, oflag, 0, &answer);
-	ipcarg_t rc = async_data_write_start(vfs_phone, abs, abs_size);
-	
-	if (rc != EOK) {
-		ipcarg_t rc_orig;
+	sysarg_t rc = async_data_write_start(vfs_phone, abs, abs_size);
+	
+	if (rc != EOK) {
+		sysarg_t rc_orig;
 		async_wait_for(req, &rc_orig);
 		
@@ -330,5 +330,5 @@
 	    node->devmap_handle, node->index, oflag, &answer);
 	
-	ipcarg_t rc;
+	sysarg_t rc;
 	async_wait_for(req, &rc);
 	async_serialize_end();
@@ -343,5 +343,5 @@
 int close(int fildes)
 {
-	ipcarg_t rc;
+	sysarg_t rc;
 	
 	futex_down(&vfs_phone_futex);
@@ -359,5 +359,5 @@
 ssize_t read(int fildes, void *buf, size_t nbyte) 
 {
-	ipcarg_t rc;
+	sysarg_t rc;
 	ipc_call_t answer;
 	aid_t req;
@@ -370,5 +370,5 @@
 	rc = async_data_read_start(vfs_phone, (void *)buf, nbyte);
 	if (rc != EOK) {
-		ipcarg_t rc_orig;
+		sysarg_t rc_orig;
 	
 		async_wait_for(req, &rc_orig);
@@ -391,5 +391,5 @@
 ssize_t write(int fildes, const void *buf, size_t nbyte) 
 {
-	ipcarg_t rc;
+	sysarg_t rc;
 	ipc_call_t answer;
 	aid_t req;
@@ -402,5 +402,5 @@
 	rc = async_data_write_start(vfs_phone, (void *)buf, nbyte);
 	if (rc != EOK) {
-		ipcarg_t rc_orig;
+		sysarg_t rc_orig;
 	
 		async_wait_for(req, &rc_orig);
@@ -427,5 +427,5 @@
 	vfs_connect();
 	
-	ipcarg_t rc = async_req_1_0(vfs_phone, VFS_IN_SYNC, fildes);
+	sysarg_t rc = async_req_1_0(vfs_phone, VFS_IN_SYNC, fildes);
 	
 	async_serialize_end();
@@ -441,7 +441,7 @@
 	vfs_connect();
 	
-	ipcarg_t newoff_lo;
-	ipcarg_t newoff_hi;
-	ipcarg_t rc = async_req_4_2(vfs_phone, VFS_IN_SEEK, fildes,
+	sysarg_t newoff_lo;
+	sysarg_t newoff_hi;
+	sysarg_t rc = async_req_4_2(vfs_phone, VFS_IN_SEEK, fildes,
 	    LOWER32(offset), UPPER32(offset), whence,
 	    &newoff_lo, &newoff_hi);
@@ -458,5 +458,5 @@
 int ftruncate(int fildes, aoff64_t length)
 {
-	ipcarg_t rc;
+	sysarg_t rc;
 	
 	futex_down(&vfs_phone_futex);
@@ -474,5 +474,5 @@
 int fstat(int fildes, struct stat *stat)
 {
-	ipcarg_t rc;
+	sysarg_t rc;
 	aid_t req;
 
@@ -484,5 +484,5 @@
 	rc = async_data_read_start(vfs_phone, (void *) stat, sizeof(struct stat));
 	if (rc != EOK) {
-		ipcarg_t rc_orig;
+		sysarg_t rc_orig;
 		
 		async_wait_for(req, &rc_orig);
@@ -503,6 +503,6 @@
 int stat(const char *path, struct stat *stat)
 {
-	ipcarg_t rc;
-	ipcarg_t rc_orig;
+	sysarg_t rc;
+	sysarg_t rc_orig;
 	aid_t req;
 	
@@ -593,5 +593,5 @@
 int mkdir(const char *path, mode_t mode)
 {
-	ipcarg_t rc;
+	sysarg_t rc;
 	aid_t req;
 	
@@ -608,5 +608,5 @@
 	rc = async_data_write_start(vfs_phone, pa, pa_size);
 	if (rc != EOK) {
-		ipcarg_t rc_orig;
+		sysarg_t rc_orig;
 	
 		async_wait_for(req, &rc_orig);
@@ -628,5 +628,5 @@
 static int _unlink(const char *path, int lflag)
 {
-	ipcarg_t rc;
+	sysarg_t rc;
 	aid_t req;
 	
@@ -643,5 +643,5 @@
 	rc = async_data_write_start(vfs_phone, pa, pa_size);
 	if (rc != EOK) {
-		ipcarg_t rc_orig;
+		sysarg_t rc_orig;
 
 		async_wait_for(req, &rc_orig);
@@ -673,6 +673,6 @@
 int rename(const char *old, const char *new)
 {
-	ipcarg_t rc;
-	ipcarg_t rc_orig;
+	sysarg_t rc;
+	sysarg_t rc_orig;
 	aid_t req;
 	
@@ -810,6 +810,6 @@
 	vfs_connect();
 	
-	ipcarg_t ret;
-	ipcarg_t rc = async_req_2_1(vfs_phone, VFS_IN_DUP, oldfd, newfd, &ret);
+	sysarg_t ret;
+	sysarg_t rc = async_req_2_1(vfs_phone, VFS_IN_DUP, oldfd, newfd, &ret);
 	
 	async_serialize_end();
Index: uspace/lib/c/include/async.h
===================================================================
--- uspace/lib/c/include/async.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/async.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -84,14 +84,14 @@
 	    (arg5), (dataptr))
 
-extern aid_t async_send_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr);
-extern aid_t async_send_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5,
+extern aid_t async_send_fast(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr);
+extern aid_t async_send_slow(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5,
     ipc_call_t *dataptr);
-extern void async_wait_for(aid_t amsgid, ipcarg_t *result);
-extern int async_wait_timeout(aid_t amsgid, ipcarg_t *retval,
+extern void async_wait_for(aid_t amsgid, sysarg_t *result);
+extern int async_wait_timeout(aid_t amsgid, sysarg_t *retval,
     suseconds_t timeout);
 
-extern fid_t async_new_connection(ipcarg_t in_phone_hash, ipc_callid_t callid,
+extern fid_t async_new_connection(sysarg_t in_phone_hash, ipc_callid_t callid,
     ipc_call_t *call, void (*cthread)(ipc_callid_t, ipc_call_t *));
 extern void async_usleep(suseconds_t timeout);
@@ -242,10 +242,10 @@
 	    (arg5), (rc1), (rc2), (rc3), (rc4), (rc5))
 
-extern ipcarg_t async_req_fast(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t *r1, ipcarg_t *r2,
-    ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5);
-extern ipcarg_t async_req_slow(int phoneid, ipcarg_t method, ipcarg_t arg1,
-    ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *r1,
-    ipcarg_t *r2, ipcarg_t *r3, ipcarg_t *r4, ipcarg_t *r5);
+extern sysarg_t async_req_fast(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t *r1, sysarg_t *r2,
+    sysarg_t *r3, sysarg_t *r4, sysarg_t *r5);
+extern sysarg_t async_req_slow(int phoneid, sysarg_t method, sysarg_t arg1,
+    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *r1,
+    sysarg_t *r2, sysarg_t *r3, sysarg_t *r4, sysarg_t *r5);
 
 static inline void async_serialize_start(void)
@@ -259,6 +259,6 @@
 }
 
-extern int async_connect_me_to(int, ipcarg_t, ipcarg_t, ipcarg_t);
-extern int async_connect_me_to_blocking(int, ipcarg_t, ipcarg_t, ipcarg_t);
+extern int async_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t);
+extern int async_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t);
 
 /*
@@ -274,5 +274,5 @@
 	async_share_in_start((phoneid), (dst), (size), (arg), (flags))
 
-extern int async_share_in_start(int, void *, size_t, ipcarg_t, int *);
+extern int async_share_in_start(int, void *, size_t, sysarg_t, int *);
 extern int async_share_in_receive(ipc_callid_t *, size_t *);
 extern int async_share_in_finalize(ipc_callid_t, void *, int );
@@ -314,6 +314,6 @@
 extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
 
-extern int async_data_read_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t,
-    ipcarg_t, ipcarg_t, ipc_call_t *);
+extern int async_data_read_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, ipc_call_t *);
 
 /*
@@ -356,6 +356,6 @@
 extern void async_data_write_void(const int);
 
-extern int async_data_write_forward_fast(int, ipcarg_t, ipcarg_t, ipcarg_t,
-    ipcarg_t, ipcarg_t, ipc_call_t *);
+extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, ipc_call_t *);
 
 #endif
Index: uspace/lib/c/include/event.h
===================================================================
--- uspace/lib/c/include/event.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/event.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -39,5 +39,5 @@
 #include <ipc/ipc.h>
 
-extern int event_subscribe(event_type_t, ipcarg_t);
+extern int event_subscribe(event_type_t, sysarg_t);
 
 #endif
Index: uspace/lib/c/include/io/console.h
===================================================================
--- uspace/lib/c/include/io/console.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/io/console.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -68,7 +68,7 @@
 extern void console_clear(int phone);
 
-extern int console_get_size(int phone, ipcarg_t *cols, ipcarg_t *rows);
-extern int console_get_pos(int phone, ipcarg_t *col, ipcarg_t *row);
-extern void console_set_pos(int phone, ipcarg_t col, ipcarg_t row);
+extern int console_get_size(int phone, sysarg_t *cols, sysarg_t *rows);
+extern int console_get_pos(int phone, sysarg_t *col, sysarg_t *row);
+extern void console_set_pos(int phone, sysarg_t col, sysarg_t row);
 
 extern void console_set_style(int phone, uint8_t style);
@@ -78,5 +78,5 @@
 
 extern void console_cursor_visibility(int phone, bool show);
-extern int console_get_color_cap(int phone, ipcarg_t *ccap);
+extern int console_get_color_cap(int phone, sysarg_t *ccap);
 extern void console_kcon_enable(int phone);
 
Index: uspace/lib/c/include/io/screenbuffer.h
===================================================================
--- uspace/lib/c/include/io/screenbuffer.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/io/screenbuffer.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -84,10 +84,10 @@
 	keyfield_t *buffer;      /**< Screen content - characters and
 	                              their attributes (used as a circular buffer) */
-	ipcarg_t size_x;         /**< Number of columns  */
-	ipcarg_t size_y;         /**< Number of rows */
+	sysarg_t size_x;         /**< Number of columns  */
+	sysarg_t size_y;         /**< Number of rows */
 	
 	/** Coordinates of last printed character for determining cursor position */
-	ipcarg_t position_x;
-	ipcarg_t position_y;
+	sysarg_t position_x;
+	sysarg_t position_y;
 	
 	attrs_t attrs;           /**< Current attributes. */
@@ -109,5 +109,5 @@
  *
  */
-static inline keyfield_t *get_field_at(screenbuffer_t *scr, ipcarg_t x, ipcarg_t y)
+static inline keyfield_t *get_field_at(screenbuffer_t *scr, sysarg_t x, sysarg_t y)
 {
 	return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
@@ -143,10 +143,10 @@
 
 extern void screenbuffer_putchar(screenbuffer_t *, wchar_t);
-extern screenbuffer_t *screenbuffer_init(screenbuffer_t *, ipcarg_t, ipcarg_t);
+extern screenbuffer_t *screenbuffer_init(screenbuffer_t *, sysarg_t, sysarg_t);
 
 extern void screenbuffer_clear(screenbuffer_t *);
-extern void screenbuffer_clear_line(screenbuffer_t *, ipcarg_t);
+extern void screenbuffer_clear_line(screenbuffer_t *, sysarg_t);
 extern void screenbuffer_copy_buffer(screenbuffer_t *, keyfield_t *);
-extern void screenbuffer_goto(screenbuffer_t *, ipcarg_t, ipcarg_t);
+extern void screenbuffer_goto(screenbuffer_t *, sysarg_t, sysarg_t);
 extern void screenbuffer_set_style(screenbuffer_t *, uint8_t);
 extern void screenbuffer_set_color(screenbuffer_t *, uint8_t, uint8_t, uint8_t);
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/ipc/devman.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -42,5 +42,5 @@
 #define DEVMAN_NAME_MAXLEN 256
 
-typedef ipcarg_t devman_handle_t;
+typedef sysarg_t devman_handle_t;
 
 /** Ids of device models used for device-to-driver matching.
Index: uspace/lib/c/include/ipc/devmap.h
===================================================================
--- uspace/lib/c/include/ipc/devmap.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/ipc/devmap.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,5 +40,5 @@
 #define DEVMAP_NAME_MAXLEN  255
 
-typedef ipcarg_t devmap_handle_t;
+typedef sysarg_t devmap_handle_t;
 
 typedef enum {
Index: uspace/lib/c/include/ipc/ip.h
===================================================================
--- uspace/lib/c/include/ipc/ip.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/ipc/ip.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -93,5 +93,5 @@
 #define IP_SET_HEADERLEN(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG2(*answer, argument); \
 	} while (0)
Index: uspace/lib/c/include/ipc/ipc.h
===================================================================
--- uspace/lib/c/include/ipc/ipc.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/ipc/ipc.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -44,9 +44,7 @@
 #define IPC_FLAG_BLOCKING  0x01
 
-typedef sysarg_t ipcarg_t;
-
 typedef struct {
-	ipcarg_t args[IPC_CALL_LEN];
-	ipcarg_t in_phone_hash;
+	sysarg_t args[IPC_CALL_LEN];
+	sysarg_t in_phone_hash;
 } ipc_call_t;
 
@@ -183,10 +181,10 @@
 	    (arg4), (arg5), (res1), (res2), (res3), (res4), (res5))
 
-extern int ipc_call_sync_fast(int, ipcarg_t, ipcarg_t, ipcarg_t, ipcarg_t,
-    ipcarg_t *, ipcarg_t *, ipcarg_t *, ipcarg_t *, ipcarg_t *);
-
-extern int ipc_call_sync_slow(int, ipcarg_t, ipcarg_t, ipcarg_t, ipcarg_t,
-    ipcarg_t, ipcarg_t, ipcarg_t *, ipcarg_t *, ipcarg_t *, ipcarg_t *,
-    ipcarg_t *);
+extern int ipc_call_sync_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *);
+
+extern int ipc_call_sync_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t *, sysarg_t *, sysarg_t *, sysarg_t *,
+    sysarg_t *);
 
 extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, uint32_t, int);
@@ -220,8 +218,8 @@
 	ipc_answer_slow((callid), (retval), (arg1), (arg2), (arg3), (arg4), (arg5))
 
-extern ipcarg_t ipc_answer_fast(ipc_callid_t, ipcarg_t, ipcarg_t, ipcarg_t,
-    ipcarg_t, ipcarg_t);
-extern ipcarg_t ipc_answer_slow(ipc_callid_t, ipcarg_t, ipcarg_t, ipcarg_t,
-    ipcarg_t, ipcarg_t, ipcarg_t);
+extern sysarg_t ipc_answer_fast(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t);
+extern sysarg_t ipc_answer_slow(ipc_callid_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t);
 
 /*
@@ -255,10 +253,10 @@
 	    (arg4), (arg5), (private), (callback), (can_preempt))
 
-extern void ipc_call_async_fast(int, ipcarg_t, ipcarg_t, ipcarg_t, ipcarg_t,
-    ipcarg_t, void *, ipc_async_callback_t, int);
-extern void ipc_call_async_slow(int, ipcarg_t, ipcarg_t, ipcarg_t, ipcarg_t,
-    ipcarg_t, ipcarg_t, void *, ipc_async_callback_t, int);
-
-extern int ipc_connect_to_me(int, int, int, int, ipcarg_t *);
+extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, void *, ipc_async_callback_t, int);
+extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, void *, ipc_async_callback_t, int);
+
+extern int ipc_connect_to_me(int, int, int, int, sysarg_t *);
 extern int ipc_connect_me_to(int, int, int, int);
 extern int ipc_connect_me_to_blocking(int, int, int, int);
@@ -266,7 +264,7 @@
 extern int ipc_register_irq(int, int, int, irq_code_t *);
 extern int ipc_unregister_irq(int, int);
-extern int ipc_forward_fast(ipc_callid_t, int, int, ipcarg_t, ipcarg_t, int);
-extern int ipc_forward_slow(ipc_callid_t, int, int, ipcarg_t, ipcarg_t,
-    ipcarg_t, ipcarg_t, ipcarg_t, int);
+extern int ipc_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int);
+extern int ipc_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t,
+    sysarg_t, sysarg_t, sysarg_t, int);
 
 /*
@@ -282,5 +280,5 @@
 	ipc_share_in_start((phoneid), (dst), (size), (arg), (flags))
 
-extern int ipc_share_in_start(int, void *, size_t, ipcarg_t, int *);
+extern int ipc_share_in_start(int, void *, size_t, sysarg_t, int *);
 extern int ipc_share_in_finalize(ipc_callid_t, void *, int );
 extern int ipc_share_out_start(int, void *, int);
Index: uspace/lib/c/include/ipc/net.h
===================================================================
--- uspace/lib/c/include/ipc/net.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/ipc/net.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -192,5 +192,5 @@
  */
 #define IS_NET_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_FIRST, NET_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_FIRST, NET_LAST)
 
 /** Returns a value indicating whether the IPC call is an ARP message.
@@ -198,5 +198,5 @@
  */
 #define IS_NET_ARP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
 
 /** Returns a value indicating whether the IPC call is an Ethernet message.
@@ -204,5 +204,5 @@
  */
 #define IS_NET_ETH_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
 
 /** Returns a value indicating whether the IPC call is an ICMP message.
@@ -210,5 +210,5 @@
  */
 #define IS_NET_ICMP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
 
 /** Returns a value indicating whether the IPC call is an inter-network layer
@@ -217,5 +217,5 @@
  */
 #define IS_NET_IL_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IL_FIRST, NET_IL_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IL_FIRST, NET_IL_LAST)
 
 /** Returns a value indicating whether the IPC call is an IP message.
@@ -223,5 +223,5 @@
  */
 #define IS_NET_IP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_IP_FIRST, NET_IP_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IP_FIRST, NET_IP_LAST)
 
 /** Returns a value indicating whether the IPC call is a generic networking
@@ -230,5 +230,5 @@
  */
 #define IS_NET_NET_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NET_FIRST, NET_NET_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NET_FIRST, NET_NET_LAST)
 
 /** Returns a value indicating whether the IPC call is a network interface layer
@@ -237,5 +237,5 @@
  */
 #define IS_NET_NIL_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
 
 /** Returns a value indicating whether the IPC call is a packet manaagement
@@ -244,5 +244,5 @@
  */
 #define IS_NET_PACKET_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
 
 /** Returns a value indicating whether the IPC call is a socket message.
@@ -250,5 +250,5 @@
  */
 #define IS_NET_SOCKET_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
 
 /** Returns a value indicating whether the IPC call is a TCP message.
@@ -256,5 +256,5 @@
  */
 #define IS_NET_TCP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
 
 /** Returns a value indicating whether the IPC call is a transport layer message.
@@ -262,5 +262,5 @@
  */
 #define IS_NET_TL_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_TL_FIRST, NET_TL_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TL_FIRST, NET_TL_LAST)
 
 /** Returns a value indicating whether the IPC call is a UDP message.
@@ -268,5 +268,5 @@
  */
 #define IS_NET_UDP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_METHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
 
 /*@}*/
@@ -370,5 +370,5 @@
 #define IPC_SET_DEVICE(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG1(*answer, argument); \
 	} while (0)
@@ -379,5 +379,5 @@
 #define IPC_SET_ADDR(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG1(*answer, argument); \
 	} while (0)
@@ -388,5 +388,5 @@
 #define IPC_SET_PREFIX(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG2(*answer, argument); \
 	} while (0)
@@ -397,5 +397,5 @@
 #define IPC_SET_CONTENT(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG3(*answer, argument); \
 	} while (0)
@@ -406,5 +406,5 @@
 #define IPC_SET_SUFFIX(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG4(*answer, argument); \
 	} while (0)
Index: uspace/lib/c/include/ipc/socket.h
===================================================================
--- uspace/lib/c/include/ipc/socket.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/ipc/socket.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -84,5 +84,5 @@
 #define SOCKET_SET_SOCKET_ID(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG1(answer, argument); \
 	} while (0)
@@ -102,5 +102,5 @@
 #define SOCKET_SET_READ_DATA_LENGTH(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG1(answer, argument); \
 	} while (0)
@@ -147,5 +147,5 @@
 #define SOCKET_SET_DATA_FRAGMENT_SIZE(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG2(answer, argument); \
 	} while (0)
@@ -156,5 +156,5 @@
 #define SOCKET_SET_ADDRESS_LENGTH(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG3(answer, argument);\
 	} while (0)
@@ -174,5 +174,5 @@
 #define SOCKET_SET_HEADER_SIZE(answer, value) \
 	do { \
-		ipcarg_t argument = (ipcarg_t) (value); \
+		sysarg_t argument = (sysarg_t) (value); \
 		IPC_SET_ARG3(answer, argument); \
 	} while (0)
Index: uspace/lib/c/include/libc.h
===================================================================
--- uspace/lib/c/include/libc.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/libc.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,4 +40,11 @@
 #include <libarch/syscall.h>
 
+#ifdef __32_BITS__
+
+/** Explicit 64-bit arguments passed to syscalls. */
+typedef uint64_t sysarg64_t;
+
+#endif /* __32_BITS__ */
+
 #define __SYSCALL0(id) \
 	__syscall0(0, 0, 0, 0, 0, 0, id)
@@ -53,5 +60,5 @@
 	__syscall5(p1, p2, p3, p4, p5, 0, id)
 #define __SYSCALL6(id, p1, p2, p3, p4, p5, p6) \
-    __syscall6(p1, p2, p3, p4, p5, p6, id)
+	__syscall6(p1, p2, p3, p4, p5, p6, id)
 
 extern void __main(void *pcb_ptr);
Index: uspace/lib/c/include/net/modules.h
===================================================================
--- uspace/lib/c/include/net/modules.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/c/include/net/modules.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -74,7 +74,7 @@
 
 extern void answer_call(ipc_callid_t, int, ipc_call_t *, int);
-extern int bind_service(services_t, ipcarg_t, ipcarg_t, ipcarg_t,
+extern int bind_service(services_t, sysarg_t, sysarg_t, sysarg_t,
     async_client_conn_t);
-extern int bind_service_timeout(services_t, ipcarg_t, ipcarg_t, ipcarg_t,
+extern int bind_service_timeout(services_t, sysarg_t, sysarg_t, sysarg_t,
     async_client_conn_t, suseconds_t);
 extern int connect_to_service(services_t);
Index: uspace/lib/clui/tinput.c
===================================================================
--- uspace/lib/clui/tinput.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/clui/tinput.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -140,6 +140,6 @@
 static void tinput_update_origin(tinput_t *ti)
 {
-	ipcarg_t width = ti->col0 + ti->nc;
-	ipcarg_t rows = (width / ti->con_cols) + 1;
+	sysarg_t width = ti->col0 + ti->nc;
+	sysarg_t rows = (width / ti->con_cols) + 1;
 	
 	/* Update row0 if the screen scrolled. */
@@ -153,8 +153,8 @@
 		return;
 	
-	ipcarg_t new_width = ti->col0 + ti->nc + 1;
+	sysarg_t new_width = ti->col0 + ti->nc + 1;
 	if (new_width % ti->con_cols == 0) {
 		/* Advancing to new line. */
-		ipcarg_t new_height = (new_width / ti->con_cols) + 1;
+		sysarg_t new_height = (new_width / ti->con_cols) + 1;
 		if (new_height >= ti->con_rows) {
 			/* Disallow text longer than 1 page for now. */
@@ -184,6 +184,6 @@
 		return;
 	
-	ipcarg_t new_width = ti->col0 + ti->nc + ilen;
-	ipcarg_t new_height = (new_width / ti->con_cols) + 1;
+	sysarg_t new_width = ti->col0 + ti->nc + ilen;
+	sysarg_t new_height = (new_width / ti->con_cols) + 1;
 	if (new_height >= ti->con_rows) {
 		/* Disallow text longer than 1 page for now. */
Index: uspace/lib/clui/tinput.h
===================================================================
--- uspace/lib/clui/tinput.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/clui/tinput.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -51,10 +51,10 @@
 	
 	/** Screen coordinates of the top-left corner of the text field */
-	ipcarg_t col0;
-	ipcarg_t row0;
+	sysarg_t col0;
+	sysarg_t row0;
 	
 	/** Screen dimensions */
-	ipcarg_t con_cols;
-	ipcarg_t con_rows;
+	sysarg_t con_cols;
+	sysarg_t con_rows;
 	
 	/** Number of characters in @c buffer */
Index: uspace/lib/drv/generic/dev_iface.c
===================================================================
--- uspace/lib/drv/generic/dev_iface.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/drv/generic/dev_iface.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -56,5 +56,5 @@
 
 remote_iface_func_ptr_t
-get_remote_method(remote_iface_t *rem_iface, ipcarg_t iface_method_idx)
+get_remote_method(remote_iface_t *rem_iface, sysarg_t iface_method_idx)
 {
 	if (iface_method_idx >= rem_iface->method_count) {
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/drv/generic/driver.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -81,5 +81,5 @@
 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)
 {
-	int id = (int)IPC_GET_METHOD(*icall);
+	int id = (int)IPC_GET_IMETHOD(*icall);
 	interrupt_context_t *ctx;
 	
@@ -200,5 +200,5 @@
 		ipc_callid_t callid = async_get_call(&call);
 
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			cont = false;
@@ -254,5 +254,5 @@
 		ipc_call_t call;
 		callid = async_get_call(&call);
-		ipcarg_t method = IPC_GET_METHOD(call);
+		sysarg_t method = IPC_GET_IMETHOD(call);
 		int iface_idx;
 		
@@ -308,5 +308,5 @@
 
 			/* get the method of the remote interface */
-			ipcarg_t iface_method_idx = IPC_GET_ARG1(call);
+			sysarg_t iface_method_idx = IPC_GET_ARG1(call);
 			remote_iface_func_ptr_t iface_method_ptr =
 			    get_remote_method(rem_iface, iface_method_idx);
@@ -346,5 +346,5 @@
 {
 	/* Select interface */
-	switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
+	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
 	case DRIVER_DEVMAN:
 		/* handle PnP events from device manager */
Index: uspace/lib/drv/generic/remote_usbhc.c
===================================================================
--- uspace/lib/drv/generic/remote_usbhc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/drv/generic/remote_usbhc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -122,5 +122,5 @@
     ipc_callid_t callid, ipc_call_t *call)
 {
-	ipcarg_t buffer_hash = DEV_IPC_GET_ARG1(*call);
+	sysarg_t buffer_hash = DEV_IPC_GET_ARG1(*call);
 	async_transaction_t * trans = (async_transaction_t *)buffer_hash;
 	if (trans == NULL) {
@@ -197,5 +197,5 @@
 		ipc_answer_0(callid, rc);
 	} else {
-		ipc_answer_1(callid, EOK, (ipcarg_t) address);
+		ipc_answer_1(callid, EOK, (sysarg_t) address);
 	}
 }
@@ -254,5 +254,5 @@
 
 	// FIXME - answer according to outcome
-	ipc_answer_1(trans->caller, EOK, (ipcarg_t)trans);
+	ipc_answer_1(trans->caller, EOK, (sysarg_t)trans);
 
 	trans->size = actual_size;
Index: uspace/lib/drv/include/driver.h
===================================================================
--- uspace/lib/drv/include/driver.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/drv/include/driver.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -79,5 +79,5 @@
 
 remote_iface_t *get_remote_iface(int);
-remote_iface_func_ptr_t get_remote_method(remote_iface_t *, ipcarg_t);
+remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t);
 
 
Index: uspace/lib/fs/libfs.c
===================================================================
--- uspace/lib/fs/libfs.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/fs/libfs.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -155,5 +155,5 @@
 	devmap_handle_t mr_devmap_handle = (devmap_handle_t) IPC_GET_ARG4(*request);
 	int res;
-	ipcarg_t rc;
+	sysarg_t rc;
 	
 	ipc_call_t call;
@@ -163,5 +163,5 @@
 	callid = async_get_call(&call);
 	int mountee_phone = (int) IPC_GET_ARG1(call);
-	if ((IPC_GET_METHOD(call) != IPC_M_CONNECTION_CLONE) ||
+	if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) ||
 	    (mountee_phone < 0)) {
 		ipc_answer_0(callid, EINVAL);
Index: uspace/lib/fs/libfs.h
===================================================================
--- uspace/lib/fs/libfs.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/fs/libfs.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -86,5 +86,5 @@
 typedef struct {
 	int fs_handle;           /**< File system handle. */
-	ipcarg_t vfs_phonehash;  /**< Initial VFS phonehash. */
+	sysarg_t vfs_phonehash;  /**< Initial VFS phonehash. */
 	uint8_t *plb_ro;         /**< Read-only PLB view. */
 } fs_reg_t;
Index: uspace/lib/net/generic/generic.c
===================================================================
--- uspace/lib/net/generic/generic.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/net/generic/generic.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -59,6 +59,6 @@
     int state, services_t target)
 {
-	async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id,
-	    (ipcarg_t) state, target);
+	async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
+	    (sysarg_t) state, target);
 	
 	return EOK;
@@ -81,6 +81,6 @@
     int arg2, services_t service)
 {
-	return (int) async_req_3_0(phone, (ipcarg_t) message,
-	    (ipcarg_t) device_id, (ipcarg_t) arg2, (ipcarg_t) service);
+	return (int) async_req_3_0(phone, (sysarg_t) message,
+	    (sysarg_t) device_id, (sysarg_t) arg2, (sysarg_t) service);
 }
 
@@ -103,5 +103,5 @@
 {
 	aid_t message_id;
-	ipcarg_t result;
+	sysarg_t result;
 	int string;
 
@@ -110,6 +110,6 @@
 
 	// request the address
-	message_id = async_send_1(phone, (ipcarg_t) message,
-	    (ipcarg_t) device_id, NULL);
+	message_id = async_send_1(phone, (sysarg_t) message,
+	    (sysarg_t) device_id, NULL);
 	string = measured_strings_return(phone, address, data, 1);
 	async_wait_for(message_id, &result);
@@ -143,11 +143,11 @@
 		return EBADMEM;
 	
-	ipcarg_t addr_len;
-	ipcarg_t prefix;
-	ipcarg_t content;
-	ipcarg_t suffix;
-	
-	ipcarg_t result = async_req_1_4(phone, (ipcarg_t) message,
-	    (ipcarg_t) device_id, &addr_len, &prefix, &content, &suffix);
+	sysarg_t addr_len;
+	sysarg_t prefix;
+	sysarg_t content;
+	sysarg_t suffix;
+	
+	sysarg_t result = async_req_1_4(phone, (sysarg_t) message,
+	    (sysarg_t) device_id, &addr_len, &prefix, &content, &suffix);
 	
 	packet_dimension->prefix = (size_t) prefix;
@@ -175,9 +175,9 @@
 {
 	if (error) {
-		async_msg_4(phone, (ipcarg_t) message, (ipcarg_t) device_id,
-		    (ipcarg_t) packet_id, (ipcarg_t) target, (ipcarg_t) error);
+		async_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
+		    (sysarg_t) packet_id, (sysarg_t) target, (sysarg_t) error);
 	} else {
-		async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id,
-		    (ipcarg_t) packet_id, (ipcarg_t) target);
+		async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
+		    (sysarg_t) packet_id, (sysarg_t) target);
 	}
 	
@@ -201,9 +201,9 @@
 {
 	if (error) {
-		async_msg_4(phone, (ipcarg_t) message, (ipcarg_t) device_id,
-		    (ipcarg_t) packet_id, (ipcarg_t) sender, (ipcarg_t) error);
+		async_msg_4(phone, (sysarg_t) message, (sysarg_t) device_id,
+		    (sysarg_t) packet_id, (sysarg_t) sender, (sysarg_t) error);
 	} else {
-		async_msg_3(phone, (ipcarg_t) message, (ipcarg_t) device_id,
-		    (ipcarg_t) packet_id, (ipcarg_t) sender);
+		async_msg_3(phone, (sysarg_t) message, (sysarg_t) device_id,
+		    (sysarg_t) packet_id, (sysarg_t) sender);
 	}
 	
@@ -237,5 +237,5 @@
 {
 	aid_t message_id;
-	ipcarg_t result;
+	sysarg_t result;
 	int string;
 
@@ -246,6 +246,6 @@
 
 	// request the translation
-	message_id = async_send_3(phone, (ipcarg_t) message,
-	    (ipcarg_t) device_id, (ipcarg_t) count, (ipcarg_t) service, NULL);
+	message_id = async_send_3(phone, (sysarg_t) message,
+	    (sysarg_t) device_id, (sysarg_t) count, (sysarg_t) service, NULL);
 	measured_strings_send(phone, configuration, count);
 	string = measured_strings_return(phone, translation, data, count);
Index: uspace/lib/net/generic/packet_remote.c
===================================================================
--- uspace/lib/net/generic/packet_remote.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/net/generic/packet_remote.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -86,5 +86,5 @@
 	}
 	
-	ipcarg_t result;
+	sysarg_t result;
 	async_wait_for(message, &result);
 	
@@ -116,5 +116,5 @@
 	*packet = pm_find(packet_id);
 	if (!*packet) {
-		ipcarg_t size;
+		sysarg_t size;
 		
 		rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id,
@@ -151,6 +151,6 @@
     size_t max_prefix, size_t max_suffix)
 {
-	ipcarg_t packet_id;
-	ipcarg_t size;
+	sysarg_t packet_id;
+	sysarg_t size;
 	int rc;
 	
@@ -182,6 +182,6 @@
 packet_t *packet_get_1_remote(int phone, size_t content)
 {
-	ipcarg_t packet_id;
-	ipcarg_t size;
+	sysarg_t packet_id;
+	sysarg_t size;
 	int rc;
 	
Index: uspace/lib/net/il/arp_remote.c
===================================================================
--- uspace/lib/net/il/arp_remote.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/net/il/arp_remote.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -86,8 +86,8 @@
 {
 	aid_t message_id;
-	ipcarg_t result;
+	sysarg_t result;
 
 	message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS,
-	    (ipcarg_t) device_id, protocol, NULL);
+	    (sysarg_t) device_id, protocol, NULL);
 	measured_strings_send(arp_phone, address, 1);
 	async_wait_for(message_id, &result);
@@ -106,5 +106,5 @@
 {
 	return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE,
-	    (ipcarg_t) device_id);
+	    (sysarg_t) device_id);
 }
 
@@ -136,8 +136,8 @@
 {
 	aid_t message_id;
-	ipcarg_t result;
+	sysarg_t result;
 
 	message_id = async_send_3(arp_phone, NET_ARP_DEVICE,
-	    (ipcarg_t) device_id, protocol, netif, NULL);
+	    (sysarg_t) device_id, protocol, netif, NULL);
 	measured_strings_send(arp_phone, address, 1);
 	async_wait_for(message_id, &result);
Index: uspace/lib/net/il/ip_remote.c
===================================================================
--- uspace/lib/net/il/ip_remote.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/net/il/ip_remote.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -67,6 +67,6 @@
 {
 	return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE,
-	    (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr,
-	    (ipcarg_t) address.s_addr, (ipcarg_t) netmask.s_addr);
+	    (sysarg_t) device_id, (sysarg_t) gateway.s_addr,
+	    (sysarg_t) address.s_addr, (sysarg_t) netmask.s_addr);
 }
 
@@ -86,5 +86,5 @@
     async_client_conn_t receiver)
 {
-	return (int) bind_service(service, (ipcarg_t) protocol, me, service,
+	return (int) bind_service(service, (sysarg_t) protocol, me, service,
 	    receiver);
 }
@@ -151,5 +151,5 @@
 	ipc_call_t answer;
 	aid_t message_id = async_send_1(ip_phone, NET_IP_GET_ROUTE,
-	    (ipcarg_t) protocol, &answer);
+	    (sysarg_t) protocol, &answer);
 	
 	if ((async_data_write_start(ip_phone, destination, addrlen) == EOK) &&
@@ -164,5 +164,5 @@
 	}
 	
-	ipcarg_t result;
+	sysarg_t result;
 	async_wait_for(message_id, &result);
 	
@@ -244,5 +244,5 @@
 {
 	return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY,
-	    (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr);
+	    (sysarg_t) device_id, (sysarg_t) gateway.s_addr);
 }
 
Index: uspace/lib/net/netif/netif_local.c
===================================================================
--- uspace/lib/net/netif/netif_local.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/net/netif/netif_local.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -366,5 +366,5 @@
 	
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_PHONE_HUNGUP:
 		return EOK;
Index: uspace/lib/net/netif/netif_remote.c
===================================================================
--- uspace/lib/net/netif/netif_remote.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/net/netif/netif_remote.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -144,8 +144,8 @@
 	
 	aid_t message_id = async_send_1(netif_phone, NET_NETIF_STATS,
-	    (ipcarg_t) device_id, NULL);
+	    (sysarg_t) device_id, NULL);
 	async_data_read_start(netif_phone, stats, sizeof(*stats));
 	
-	ipcarg_t result;
+	sysarg_t result;
 	async_wait_for(message_id, &result);
 	
Index: uspace/lib/net/tl/icmp_remote.c
===================================================================
--- uspace/lib/net/tl/icmp_remote.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/net/tl/icmp_remote.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -65,6 +65,6 @@
     icmp_param_t mtu, packet_t *packet)
 {
-	async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (ipcarg_t) code,
-	    (ipcarg_t) packet_get_id(packet), (ipcarg_t) mtu);
+	async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (sysarg_t) code,
+	    (sysarg_t) packet_get_id(packet), (sysarg_t) mtu);
 	return EOK;
 }
@@ -85,5 +85,5 @@
 {
 	async_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0,
-	    (ipcarg_t) packet_get_id(packet));
+	    (sysarg_t) packet_get_id(packet));
 	return EOK;
 }
@@ -104,6 +104,6 @@
 int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t *packet)
 {
-	async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (ipcarg_t) code,
-	    (ipcarg_t) packet_get_id(packet));
+	async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (sysarg_t) code,
+	    (sysarg_t) packet_get_id(packet));
 	return EOK;
 }
@@ -126,6 +126,6 @@
     icmp_param_t pointer, packet_t *packet)
 {
-	async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (ipcarg_t) code,
-	    (ipcarg_t) packet_get_id(packet), (ipcarg_t) pointer);
+	async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (sysarg_t) code,
+	    (sysarg_t) packet_get_id(packet), (sysarg_t) pointer);
 	return EOK;
 }
Index: uspace/lib/packet/generic/packet_server.c
===================================================================
--- uspace/lib/packet/generic/packet_server.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/packet/generic/packet_server.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -327,5 +327,5 @@
 
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_PHONE_HUNGUP:
 		return EOK;
@@ -337,6 +337,6 @@
 			return ENOMEM;
 		*answer_count = 2;
-		IPC_SET_ARG1(*answer, (ipcarg_t) packet->packet_id);
-		IPC_SET_ARG2(*answer, (ipcarg_t) packet->length);
+		IPC_SET_ARG1(*answer, (sysarg_t) packet->packet_id);
+		IPC_SET_ARG2(*answer, (sysarg_t) packet->length);
 		return EOK;
 	
@@ -351,6 +351,6 @@
 			return ENOMEM;
 		*answer_count = 2;
-		IPC_SET_ARG1(*answer, (ipcarg_t) packet->packet_id);
-		IPC_SET_ARG2(*answer, (ipcarg_t) packet->length);
+		IPC_SET_ARG1(*answer, (sysarg_t) packet->packet_id);
+		IPC_SET_ARG2(*answer, (sysarg_t) packet->length);
 		return EOK;
 	
@@ -365,5 +365,5 @@
 		if (!packet_is_valid(packet))
 			return ENOENT;
-		IPC_SET_ARG1(*answer, (ipcarg_t) packet->length);
+		IPC_SET_ARG1(*answer, (sysarg_t) packet->length);
 		*answer_count = 1;
 		return EOK;
Index: uspace/lib/usb/Makefile
===================================================================
--- uspace/lib/usb/Makefile	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/usb/Makefile	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -34,4 +34,5 @@
 SOURCES = \
 	src/addrkeep.c \
+	src/class.c \
 	src/debug.c \
 	src/drvpsync.c \
@@ -40,4 +41,5 @@
 	src/hidparser.c \
 	src/localdrv.c \
+	src/recognise.c \
 	src/remotedrv.c \
 	src/usb.c \
Index: uspace/lib/usb/include/usb/classes/classes.h
===================================================================
--- uspace/lib/usb/include/usb/classes/classes.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/usb/include/usb/classes/classes.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -60,4 +60,5 @@
 } usb_class_t;
 
+const char *usb_str_class(usb_class_t);
 
 #endif
Index: uspace/lib/usb/include/usb/classes/hid.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hid.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/usb/include/usb/classes/hid.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -127,5 +127,5 @@
 	usb_hid_configuration_t *conf;
 	usb_address_t address;
-	usb_endpoint_t default_ep;
+	usb_endpoint_t poll_endpoint;
 	usb_hid_report_parser_t *parser;
 } usb_hid_dev_kbd_t;
Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/usb/include/usb/usb.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -101,5 +101,5 @@
  * Used by various USB functions as opaque handle.
  */
-typedef ipcarg_t usb_handle_t;
+typedef sysarg_t usb_handle_t;
 
 /** USB packet identifier. */
Index: uspace/lib/usb/include/usb/usbdrv.h
===================================================================
--- uspace/lib/usb/include/usb/usbdrv.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/usb/include/usb/usbdrv.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -94,4 +94,8 @@
 int usb_drv_async_wait_for(usb_handle_t);
 
+int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t);
+int usb_drv_register_child_in_devman(int, device_t *, usb_address_t,
+    devman_handle_t *);
+
 
 #endif
Index: uspace/lib/usb/src/addrkeep.c
===================================================================
--- uspace/lib/usb/src/addrkeep.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/usb/src/addrkeep.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -199,5 +199,5 @@
 			usb_address_keeping_used_t *last
 			    = used_address_get_instance(addresses->used_addresses.next);
-			free_address = last->address;
+			free_address = last->address + 1;
 		}
 	}
Index: uspace/lib/usb/src/class.c
===================================================================
--- uspace/lib/usb/src/class.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usb/src/class.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusb usb
+ * @{
+ */
+/** @file
+ * @brief Class related functions.
+ */
+#include <usb/classes/classes.h>
+#include <errno.h>
+
+/** Tell string representation of USB class.
+ *
+ * @param cls Class code.
+ * @return String representation.
+ */
+const char *usb_str_class(usb_class_t cls)
+{
+	switch (cls) {
+		case USB_CLASS_USE_INTERFACE:
+			return "use-interface";
+		case USB_CLASS_AUDIO:
+			return "audio";
+		case USB_CLASS_COMMUNICATIONS_CDC_CONTROL:
+			return "communications";
+		case USB_CLASS_HID:
+			return "HID";
+		case USB_CLASS_PHYSICAL:
+			return "physical";
+		case USB_CLASS_IMAGE:
+			return "image";
+		case USB_CLASS_PRINTER:
+			return "printer";
+		case USB_CLASS_MASS_STORAGE:
+			return "mass-storage";
+		case USB_CLASS_HUB:
+			return "hub";
+		case USB_CLASS_CDC_DATA:
+			return "CDC";
+		case USB_CLASS_SMART_CARD:
+			return "smart-card";
+		case USB_CLASS_CONTENT_SECURITY:
+			return "security";
+		case USB_CLASS_VIDEO:
+			return "video";
+		case USB_CLASS_PERSONAL_HEALTHCARE:
+			return "healthcare";
+		case USB_CLASS_DIAGNOSTIC:
+			return "diagnostic";
+		case USB_CLASS_WIRELESS_CONTROLLER:
+			return "wireless";
+		case USB_CLASS_MISCELLANEOUS:
+			return "misc";
+		case USB_CLASS_APPLICATION_SPECIFIC:
+			return "application";
+		case USB_CLASS_VENDOR_SPECIFIC:
+			return "vendor";
+		default:
+			return "unknown";
+	}
+}
+
+
+/**
+ * @}
+ */
Index: uspace/lib/usb/src/recognise.c
===================================================================
--- uspace/lib/usb/src/recognise.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usb/src/recognise.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,322 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusb usb
+ * @{
+ */
+/** @file
+ * @brief Functions for recognising kind of attached devices.
+ */
+#include <usb/usbdrv.h>
+#include <usb/classes/classes.h>
+#include <stdio.h>
+#include <errno.h>
+
+
+#define BCD_INT(a) (((unsigned int)(a)) / 256)
+#define BCD_FRAC(a) (((unsigned int)(a)) % 256)
+
+#define BCD_FMT "%x.%x"
+#define BCD_ARGS(a) BCD_INT((a)), BCD_FRAC((a))
+
+/* FIXME: make this dynamic */
+#define MATCH_STRING_MAX 256
+
+/** Add formatted match id.
+ *
+ * @param matches List of match ids where to add to.
+ * @param score Score of the match.
+ * @param format Printf-like format
+ * @return Error code.
+ */
+static int usb_add_match_id(match_id_list_t *matches, int score,
+    const char *format, ...)
+{
+	char *match_str = NULL;
+	match_id_t *match_id = NULL;
+	int rc;
+	
+	match_str = malloc(MATCH_STRING_MAX + 1);
+	if (match_str == NULL) {
+		rc = ENOMEM;
+		goto failure;
+	}
+
+	/*
+	 * FIXME: replace with dynamic allocation of exact size
+	 */
+	va_list args;
+	va_start(args, format	);
+	vsnprintf(match_str, MATCH_STRING_MAX, format, args);
+	match_str[MATCH_STRING_MAX] = 0;
+	va_end(args);
+
+	match_id = create_match_id();
+	if (match_id == NULL) {
+		rc = ENOMEM;
+		goto failure;
+	}
+
+	match_id->id = match_str;
+	match_id->score = score;
+	add_match_id(matches, match_id);
+
+	return EOK;
+	
+failure:
+	if (match_str != NULL) {
+		free(match_str);
+	}
+	if (match_id != NULL) {
+		match_id->id = NULL;
+		delete_match_id(match_id);
+	}
+	
+	return rc;
+}
+
+/** Add match ids based on configuration descriptor.
+ *
+ * @param hc Open phone to host controller.
+ * @param matches Match ids list to add matches to.
+ * @param address USB address of the attached device.
+ * @return Error code.
+ */
+static int usb_add_config_descriptor_match_ids(int hc,
+    match_id_list_t *matches, usb_address_t address,
+    int config_count)
+{
+	int final_rc = EOK;
+	
+	int config_index;
+	for (config_index = 0; config_index < config_count; config_index++) {
+		int rc;
+		usb_standard_configuration_descriptor_t config_descriptor;
+		rc = usb_drv_req_get_bare_configuration_descriptor(hc,
+		    address,  config_index, &config_descriptor);
+		if (rc != EOK) {
+			final_rc = rc;
+			continue;
+		}
+
+		size_t full_config_descriptor_size;
+		void *full_config_descriptor
+		    = malloc(config_descriptor.total_length);
+		rc = usb_drv_req_get_full_configuration_descriptor(hc,
+		    address, config_index,
+		    full_config_descriptor, config_descriptor.total_length,
+		    &full_config_descriptor_size);
+		if (rc != EOK) {
+			final_rc = rc;
+			continue;
+		}
+		if (full_config_descriptor_size
+		    != config_descriptor.total_length) {
+			final_rc = ERANGE;
+			continue;
+		}
+
+		/*
+		 * Iterate through config descriptor to find the interface
+		 * descriptors.
+		 */
+		size_t position = sizeof(config_descriptor);
+		while (position + 1 < full_config_descriptor_size) {
+			uint8_t *current_descriptor
+			    = ((uint8_t *) full_config_descriptor) + position;
+			uint8_t cur_descr_len = current_descriptor[0];
+			uint8_t cur_descr_type = current_descriptor[1];
+			
+			position += cur_descr_len;
+			
+			if (cur_descr_type != USB_DESCTYPE_INTERFACE) {
+				continue;
+			}
+			/*
+			 * Finally, we found an interface descriptor.
+			 */
+			usb_standard_interface_descriptor_t *interface
+			    = (usb_standard_interface_descriptor_t *)
+			    current_descriptor;
+			
+			rc = usb_add_match_id(matches, 50,
+			    "usb&interface&class=%s",
+			    usb_str_class(interface->interface_class));
+			if (rc != EOK) {
+				final_rc = rc;
+				break;
+			}
+		}
+	}
+	
+	return final_rc;
+}
+
+/** Create match ids describing attached device.
+ *
+ * @warning The list of match ids @p matches may change even when
+ * function exits with error.
+ *
+ * @param hc Open phone to host controller.
+ * @param matches Initialized list of match ids.
+ * @param address USB address of the attached device.
+ * @return Error code.
+ */
+int usb_drv_create_device_match_ids(int hc, match_id_list_t *matches,
+    usb_address_t address)
+{
+	int rc;
+	usb_standard_device_descriptor_t device_descriptor;
+
+	rc = usb_drv_req_get_device_descriptor(hc, address,
+	    &device_descriptor);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	/*
+	 * Unless the vendor id is 0, the pair idVendor-idProduct
+	 * quite uniquely describes the device.
+	 */
+	if (device_descriptor.vendor_id != 0) {
+		/* First, with release number. */
+		rc = usb_add_match_id(matches, 100,
+		    "usb&vendor=%d&product=%d&release=" BCD_FMT,
+		    (int) device_descriptor.vendor_id,
+		    (int) device_descriptor.product_id,
+		    BCD_ARGS(device_descriptor.device_version));
+		if (rc != EOK) {
+			return rc;
+		}
+		
+		/* Next, without release number. */
+		rc = usb_add_match_id(matches, 90, "usb&vendor=%d&product=%d",
+		    (int) device_descriptor.vendor_id,
+		    (int) device_descriptor.product_id);
+		if (rc != EOK) {
+			return rc;
+		}
+
+	}	
+
+	/*
+	 * If the device class points to interface we skip adding
+	 * class directly.
+	 */
+	if (device_descriptor.device_class != USB_CLASS_USE_INTERFACE) {
+		rc = usb_add_match_id(matches, 50, "usb&class=%s",
+		    usb_str_class(device_descriptor.device_class));
+		if (rc != EOK) {
+			return rc;
+		}
+	}
+	/*
+	 * Go through all configurations and add matches
+	 * based on interface class.
+	 */
+	rc = usb_add_config_descriptor_match_ids(hc, matches,
+	    address, device_descriptor.configuration_count);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	/*
+	 * As a fallback, provide the simplest match id possible.
+	 */
+	rc = usb_add_match_id(matches, 1, "usb&fallback");
+	if (rc != EOK) {
+		return rc;
+	}
+
+	return EOK;
+}
+
+
+/** Probe for device kind and register it in devman.
+ *
+ * @param hc Open phone to the host controller.
+ * @param parent Parent device.
+ * @param address Address of the (unknown) attached device.
+ * @return Error code.
+ */
+int usb_drv_register_child_in_devman(int hc, device_t *parent,
+    usb_address_t address, devman_handle_t *child_handle)
+{
+	device_t *child = NULL;
+	char *child_name = NULL;
+	int rc;
+
+	child = create_device();
+	if (child == NULL) {
+		rc = ENOMEM;
+		goto failure;
+	}
+
+	/*
+	 * TODO: some better child naming
+	 */
+	rc = asprintf(&child_name, "usb%p", child);
+	if (rc < 0) {
+		goto failure;
+	}
+	child->name = child_name;
+	
+	rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	rc = child_device_register(child, parent);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	if (child_handle != NULL) {
+		*child_handle = child->handle;
+	}
+	
+	return EOK;
+
+failure:
+	if (child != NULL) {
+		child->name = NULL;
+		/* This takes care of match_id deallocation as well. */
+		delete_device(child);
+	}
+	if (child_name != NULL) {
+		free(child_name);
+	}
+
+	return rc;
+
+}
+
+
+/**
+ * @}
+ */
Index: uspace/lib/usb/src/usbdrv.c
===================================================================
--- uspace/lib/usb/src/usbdrv.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/usb/src/usbdrv.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -72,10 +72,10 @@
 	devman_handle_t handle;
 
-	rc = devman_device_get_handle("/virt/usbhc", &handle, 0);
+	rc = devman_device_get_handle("/virt/usbhc", &handle, flags);
 	if (rc != EOK) {
 		return rc;
 	}
 	
-	int phone = devman_device_connect(handle, 0);
+	int phone = devman_device_connect(handle, flags);
 
 	return phone;
@@ -90,5 +90,5 @@
 usb_address_t usb_drv_get_my_address(int phone, device_t *dev)
 {
-	ipcarg_t address;
+	sysarg_t address;
 	int rc = async_req_2_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
 	    IPC_M_USBHC_GET_ADDRESS,
@@ -132,5 +132,5 @@
 usb_address_t usb_drv_request_address(int phone)
 {
-	ipcarg_t address;
+	sysarg_t address;
 	int rc = async_req_1_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
 	    IPC_M_USBHC_REQUEST_ADDRESS, &address);
@@ -298,9 +298,9 @@
  * @return Error status.
  */
-static int read_buffer_in(int phone, ipcarg_t hash,
+static int read_buffer_in(int phone, sysarg_t hash,
     void *buffer, size_t size, size_t *actual_size)
 {
 	ipc_call_t answer_data;
-	ipcarg_t answer_rc;
+	sysarg_t answer_rc;
 	aid_t req;
 	int rc;
@@ -350,5 +350,5 @@
 	transfer_info_t *transfer = (transfer_info_t *) handle;
 
-	ipcarg_t answer_rc;
+	sysarg_t answer_rc;
 	async_wait_for(transfer->request, &answer_rc);
 
@@ -367,5 +367,5 @@
 		 * We will use it when actually reading-in the data.
 		 */
-		ipcarg_t buffer_hash = IPC_GET_ARG1(transfer->reply);
+		sysarg_t buffer_hash = IPC_GET_ARG1(transfer->reply);
 		if (buffer_hash == 0) {
 			rc = ENOENT;
Index: uspace/lib/usbvirt/Makefile
===================================================================
--- uspace/lib/usbvirt/Makefile	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/lib/usbvirt/Makefile	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -31,13 +31,13 @@
 
 LIBS = $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include
+EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -Iinclude
 
 SOURCES = \
-	callback.c \
-	ctrlpipe.c \
-	debug.c \
-	main.c \
-	stdreq.c \
-	transaction.c
+	src/callback.c \
+	src/ctrlpipe.c \
+	src/debug.c \
+	src/main.c \
+	src/stdreq.c \
+	src/transaction.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: pace/lib/usbvirt/callback.c
===================================================================
--- uspace/lib/usbvirt/callback.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,236 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Callback connection handling.
- */
-#include <devmap.h>
-#include <fcntl.h>
-#include <vfs/vfs.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <mem.h>
-
-#include "hub.h"
-#include "device.h"
-#include "private.h"
-
-#define NAMESPACE "usb"
-#define USB_MAX_PAYLOAD_SIZE 1020
-
-/** Wrapper for SETUP transaction over telephone. */
-static void handle_setup_transaction(usbvirt_device_t *device,
-    ipc_callid_t iid, ipc_call_t icall)
-{
-	usb_address_t address = IPC_GET_ARG1(icall);
-	usb_endpoint_t endpoint = IPC_GET_ARG2(icall);
-	size_t expected_len = IPC_GET_ARG3(icall);
-	
-	if (address != device->address) {
-		ipc_answer_0(iid, EADDRNOTAVAIL);
-		return;
-	}
-	
-	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	if (expected_len == 0) {
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	size_t len = 0;
-	void * buffer = NULL;
-	int rc = async_data_write_accept(&buffer, false,
-	    1, USB_MAX_PAYLOAD_SIZE, 0, &len);
-		
-	if (rc != EOK) {
-		ipc_answer_0(iid, rc);
-		return;
-	}
-	
-	rc = device->transaction_setup(device, endpoint, buffer, len);
-	
-	ipc_answer_0(iid, rc);
-}
-
-/** Wrapper for OUT transaction over telephone. */
-static void handle_out_transaction(usbvirt_device_t *device,
-    ipc_callid_t iid, ipc_call_t icall)
-{
-	usb_address_t address = IPC_GET_ARG1(icall);
-	usb_endpoint_t endpoint = IPC_GET_ARG2(icall);
-	size_t expected_len = IPC_GET_ARG3(icall);
-	
-	if (address != device->address) {
-		ipc_answer_0(iid, EADDRNOTAVAIL);
-		return;
-	}
-	
-	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	int rc = EOK;
-	
-	size_t len = 0;
-	void *buffer = NULL;
-	
-	if (expected_len > 0) {
-		rc = async_data_write_accept(&buffer, false,
-		    1, USB_MAX_PAYLOAD_SIZE, 0, &len);
-			
-		if (rc != EOK) {
-			ipc_answer_0(iid, rc);
-			return;
-		}
-	}
-	
-	rc = device->transaction_out(device, endpoint, buffer, len);
-	
-	if (buffer != NULL) {
-		free(buffer);
-	}
-	
-	ipc_answer_0(iid, rc);
-}
-
-
-/** Wrapper for IN transaction over telephone. */
-static void handle_in_transaction(usbvirt_device_t *device,
-    ipc_callid_t iid, ipc_call_t icall)
-{
-	usb_address_t address = IPC_GET_ARG1(icall);
-	usb_endpoint_t endpoint = IPC_GET_ARG2(icall);
-	size_t expected_len = IPC_GET_ARG3(icall);
-	
-	if (address != device->address) {
-		ipc_answer_0(iid, EADDRNOTAVAIL);
-		return;
-	}
-	
-	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	int rc = EOK;
-	
-	void *buffer = expected_len > 0 ? malloc(expected_len) : NULL;
-	size_t len;
-	
-	rc = device->transaction_in(device, endpoint, buffer, expected_len, &len);
-	/*
-	 * If the request was processed, we will send data back.
-	 */
-	if (rc == EOK) {
-		size_t receive_len;
-		ipc_callid_t callid;
-		if (!async_data_read_receive(&callid, &receive_len)) {
-			ipc_answer_0(iid, EINVAL);
-			return;
-		}
-		async_data_read_finalize(callid, buffer, receive_len);
-	}
-	
-	ipc_answer_0(iid, rc);
-}
-
-/** Wrapper for getting device name. */
-static void handle_get_name(usbvirt_device_t *device,
-    ipc_callid_t iid, ipc_call_t icall)
-{
-	if (device->name == NULL) {
-		ipc_answer_0(iid, ENOENT);
-	}
-	
-	size_t size = str_size(device->name);
-	
-	ipc_callid_t callid;
-	size_t accepted_size;
-	if (!async_data_read_receive(&callid, &accepted_size)) {
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	if (accepted_size > size) {
-		accepted_size = size;
-	}
-	async_data_read_finalize(callid, device->name, accepted_size);
-	
-	ipc_answer_1(iid, EOK, accepted_size);
-}
-
-/** Callback connection for a given device. */
-void device_callback_connection(usbvirt_device_t *device, ipc_callid_t iid, ipc_call_t *icall)
-{
-	ipc_answer_0(iid, EOK);
-	
-	while (true) {
-		ipc_callid_t callid; 
-		ipc_call_t call; 
-		
-		callid = async_get_call(&call);
-		switch (IPC_GET_METHOD(call)) {
-			case IPC_M_PHONE_HUNGUP:
-				ipc_answer_0(callid, EOK);
-				return;
-			
-			case IPC_M_USBVIRT_GET_NAME:
-				handle_get_name(device, callid, call);
-				break;
-			
-			case IPC_M_USBVIRT_TRANSACTION_SETUP:
-				handle_setup_transaction(device, callid, call);
-				break;
-			
-			case IPC_M_USBVIRT_TRANSACTION_OUT:
-				handle_out_transaction(device, callid, call);
-				break;
-				
-			case IPC_M_USBVIRT_TRANSACTION_IN:
-				handle_in_transaction(device, callid, call);
-				break;
-			
-			default:
-				ipc_answer_0(callid, EINVAL);
-				break;
-		}
-	}
-}
-
-
-/**
- * @}
- */
Index: pace/lib/usbvirt/ctrlpipe.c
===================================================================
--- uspace/lib/usbvirt/ctrlpipe.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,127 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Device control pipe.
- */
-#include <errno.h>
-
-#include "private.h"
-
-#define REQUEST_TYPE_STANDARD 0 
-#define REQUEST_TYPE_CLASS 1
-
-#define GET_MIDBITS_MASK(size, shift) \
-	(((1 << size) - 1) << shift)
-#define GET_MIDBITS(value, size, shift) \
-	((value & GET_MIDBITS_MASK(size, shift)) >> shift)
-
-
-static const char *str_request_type(int type)
-{
-	switch (type) {
-		case REQUEST_TYPE_STANDARD:
-			return "standard";
-		case REQUEST_TYPE_CLASS:
-			return "class";
-		default:
-			return "unknown";
-	}
-}
-
-/** Tell request type.
- * By type is meant either standard, class, vendor or other.
- */
-static int request_get_type(uint8_t request_type)
-{
-	return GET_MIDBITS(request_type, 2, 5);
-}
-
-/** Handle communication over control pipe zero.
- */
-int control_pipe(usbvirt_device_t *device, usbvirt_control_transfer_t *transfer)
-{
-	device->lib_debug(device, 1, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO,
-	    "op on control pipe zero (request_size=%u)", transfer->request_size);
-	
-	if (transfer->request_size < sizeof(usb_device_request_setup_packet_t)) {
-		return ENOMEM;
-	}
-	
-	usb_device_request_setup_packet_t *request = (usb_device_request_setup_packet_t *) transfer->request;
-	uint8_t *remaining_data = transfer->data;
-	
-	int type = request_get_type(request->request_type);
-	
-	int rc = EOK;
-	
-	device->lib_debug(device, 2, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO,
-	    "request type: %s", str_request_type(type));
-	
-	switch (type) {
-		case REQUEST_TYPE_STANDARD:
-			rc = handle_std_request(device, request, remaining_data);
-			break;
-		case REQUEST_TYPE_CLASS:
-			if (DEVICE_HAS_OP(device, on_class_device_request)) {
-				rc = device->ops->on_class_device_request(device,
-				    request, remaining_data);
-			}
-			break;
-		default:
-			break;
-	}
-	
-	if (device->new_address != -1) {
-		/*
-		 * TODO: handle when this request is invalid (e.g.
-		 * setting address when in configured state).
-		 */
-		if (device->new_address == 0) {
-			device->state = USBVIRT_STATE_DEFAULT;
-		} else {
-			device->state = USBVIRT_STATE_ADDRESS;
-		}
-		device->address = device->new_address;
-		
-		device->new_address = -1;
-		
-		device->lib_debug(device, 2, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO,
-		    "device address changed to %d (state %s)",
-		    device->address, str_device_state(device->state));
-	}
-	
-	return rc;
-}
-
-/**
- * @}
- */
Index: pace/lib/usbvirt/debug.c
===================================================================
--- uspace/lib/usbvirt/debug.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Debugging support.
- */
-#include <stdio.h>
-#include <bool.h>
-
-#include "device.h"
-#include "private.h"
-
-
-static void debug_print(int level, uint8_t tag,
-    int current_level, uint8_t enabled_tags,
-    const char *format, va_list args)
-{
-	if (level > current_level) {
-		return;
-	}
-	
-	if ((tag & enabled_tags) == 0) {
-		return;
-	}
-	
-	bool print_prefix = true;
-	
-	if ((format[0] == '%') && (format[1] == 'M')) {
-		format += 2;
-		print_prefix = false;
-	}
-	
-	if (print_prefix) {
-		printf("[vusb]: ");
-		while (--level > 0) {
-			printf(" ");
-		}
-	}
-	
-	vprintf(format, args);
-	
-	if (print_prefix) {
-		printf("\n");
-	}
-}
-
-
-void user_debug(usbvirt_device_t *device, int level, uint8_t tag,
-    const char *format, ...)
-{
-	va_list args;
-	va_start(args, format);
-	
-	debug_print(level, tag,
-	    device->debug_level, device->debug_enabled_tags,
-	    format, args);
-	
-	va_end(args);
-}
-
-void lib_debug(usbvirt_device_t *device, int level, uint8_t tag,
-    const char *format, ...)
-{
-	va_list args;
-	va_start(args, format);
-	
-	debug_print(level, tag,
-	    device->lib_debug_level, device->lib_debug_enabled_tags,
-	    format, args);
-	
-	va_end(args);
-}
-
-/**
- * @}
- */
Index: pace/lib/usbvirt/device.h
===================================================================
--- uspace/lib/usbvirt/device.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,224 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Virtual USB device.
- */
-#ifndef LIBUSBVIRT_DEVICE_H_
-#define LIBUSBVIRT_DEVICE_H_
-
-#include <usb/usb.h>
-#include <usb/descriptor.h>
-#include <usb/devreq.h>
-
-typedef struct usbvirt_device usbvirt_device_t;
-struct usbvirt_control_transfer;
-
-typedef int (*usbvirt_on_device_request_t)(usbvirt_device_t *dev,
-	usb_device_request_setup_packet_t *request,
-	uint8_t *data);
-
-/** Callbacks for standard device requests.
- * When these functions are NULL or return EFORWARD, this
- * framework will try to satisfy the request by itself.
- */
-typedef struct {
-	usbvirt_on_device_request_t on_get_status;
-	usbvirt_on_device_request_t on_clear_feature;
-	usbvirt_on_device_request_t on_set_feature;
-	usbvirt_on_device_request_t on_set_address;
-	usbvirt_on_device_request_t on_get_descriptor;
-	usbvirt_on_device_request_t on_set_descriptor;
-	usbvirt_on_device_request_t on_get_configuration;
-	usbvirt_on_device_request_t on_set_configuration;
-	usbvirt_on_device_request_t on_get_interface;
-	usbvirt_on_device_request_t on_set_interface;
-	usbvirt_on_device_request_t on_synch_frame;
-} usbvirt_standard_device_request_ops_t;
-
-/** Device operations. */
-typedef struct {
-	/** Callbacks for standard deivce requests. */
-	usbvirt_standard_device_request_ops_t *standard_request_ops;
-	/** Callback for class-specific USB request. */
-	usbvirt_on_device_request_t on_class_device_request;
-	
-	int (*on_control_transfer)(usbvirt_device_t *dev,
-	    usb_endpoint_t endpoint, struct usbvirt_control_transfer *transfer);
-	
-	/** Callback for all other incoming data. */
-	int (*on_data)(usbvirt_device_t *dev,
-	    usb_endpoint_t endpoint, void *buffer, size_t size);
-	
-	/** Callback for host request for data. */
-	int (*on_data_request)(usbvirt_device_t *dev,
-	    usb_endpoint_t endpoint, void *buffer, size_t size, size_t *actual_size);
-	
-	/** Decides direction of control transfer. */
-	usb_direction_t (*decide_control_transfer_direction)(
-	    usb_endpoint_t endpoint, void *buffer, size_t size);
-} usbvirt_device_ops_t;
-
-/** Extra configuration data for GET_CONFIGURATION request. */
-typedef struct {
-	/** Actual data. */
-	uint8_t *data;
-	/** Data length. */
-	size_t length;
-} usbvirt_device_configuration_extras_t;
-
-/** Single device configuration. */
-typedef struct {
-	/** Standard configuration descriptor. */
-	usb_standard_configuration_descriptor_t *descriptor;
-	/** Array of extra data. */
-	usbvirt_device_configuration_extras_t *extra;
-	/** Length of @c extra array. */
-	size_t extra_count;
-} usbvirt_device_configuration_t;
-
-/** Standard USB descriptors. */
-typedef struct {
-	/** Standard device descriptor.
-	 * There is always only one such descriptor for the device.
-	 */
-	usb_standard_device_descriptor_t *device;
-	
-	/** Configurations. */
-	usbvirt_device_configuration_t *configuration;
-	/** Number of configurations. */
-	size_t configuration_count;
-	/** Index of currently selected configuration. */
-	uint8_t current_configuration;
-} usbvirt_descriptors_t;
-
-/** Possible states of virtual USB device.
- * Notice that these are not 1:1 mappings to those in USB specification.
- */
-typedef enum {
-	USBVIRT_STATE_DEFAULT,
-	USBVIRT_STATE_ADDRESS,
-	USBVIRT_STATE_CONFIGURED
-} usbvirt_device_state_t;
-
-/** Information about on-going control transfer.
- */
-typedef struct usbvirt_control_transfer {
-	/** Transfer direction (read/write control transfer). */
-	usb_direction_t direction;
-	/** Request data. */
-	void *request;
-	/** Size of request data. */
-	size_t request_size;
-	/** Payload. */
-	void *data;
-	/** Size of payload. */
-	size_t data_size;
-} usbvirt_control_transfer_t;
-
-typedef enum {
-	USBVIRT_DEBUGTAG_BASE = 1,
-	USBVIRT_DEBUGTAG_TRANSACTION = 2,
-	USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO = 4,
-	USBVIRT_DEBUGTAG_ALL = 255
-} usbvirt_debug_tags_t;
-
-/** Virtual USB device. */
-struct usbvirt_device {
-	/** Callback device operations. */
-	usbvirt_device_ops_t *ops;
-	
-	/** Reply onto control transfer.
-	 */
-	int (*control_transfer_reply)(usbvirt_device_t *dev,
-	    usb_endpoint_t endpoint, void *buffer, size_t size);
-	
-	/** Device name.
-	 * Used in debug prints and sent to virtual host controller.
-	 */
-	const char *name;
-	
-	/** Standard descriptors. */
-	usbvirt_descriptors_t *descriptors;
-	
-	/** Current device state. */
-	usbvirt_device_state_t state;
-	
-	/** Device address. */
-	usb_address_t address;
-	/** New device address.
-	 * This field is used during SET_ADDRESS request.
-	 * On all other occasions, it holds invalid address (e.g. -1).
-	 */
-	usb_address_t new_address;
-	
-	/** Process OUT transaction. */
-	int (*transaction_out)(usbvirt_device_t *dev,
-	    usb_endpoint_t endpoint, void *buffer, size_t size);
-	/** Process SETUP transaction. */
-	int (*transaction_setup)(usbvirt_device_t *dev,
-	    usb_endpoint_t endpoint, void *buffer, size_t size);
-	/** Process IN transaction. */
-	int (*transaction_in)(usbvirt_device_t *dev,
-	    usb_endpoint_t endpoint, void *buffer, size_t size, size_t *data_size);
-	
-	/** State information on control-transfer endpoints. */
-	usbvirt_control_transfer_t current_control_transfers[USB11_ENDPOINT_MAX];
-	
-	/* User debugging. */
-	
-	/** Debug print. */
-	void (*debug)(usbvirt_device_t *dev, int level, uint8_t tag,
-	    const char *format, ...);
-	
-	/** Current debug level. */
-	int debug_level;
-	
-	/** Bitmap of currently enabled tags. */
-	uint8_t debug_enabled_tags;
-	
-	/* Library debugging. */
-	
-	/** Debug print. */
-	void (*lib_debug)(usbvirt_device_t *dev, int level, uint8_t tag,
-	    const char *format, ...);
-	
-	/** Current debug level. */
-	int lib_debug_level;
-	
-	/** Bitmap of currently enabled tags. */
-	uint8_t lib_debug_enabled_tags;
-};
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usbvirt/hub.h
===================================================================
--- uspace/lib/usbvirt/hub.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Virtual USB device.
- */
-#ifndef LIBUSBVIRT_HUB_H_
-#define LIBUSBVIRT_HUB_H_
-
-#include "device.h"
-
-/** USB transaction type.
- * This types does not correspond directly to types in USB specification,
- * as actually DATA transactions are marked with these types to identify
- * their direction (and tag).
- */
-typedef enum {
-	USBVIRT_TRANSACTION_SETUP,
-	USBVIRT_TRANSACTION_IN,
-	USBVIRT_TRANSACTION_OUT
-} usbvirt_transaction_type_t;
-
-const char *usbvirt_str_transaction_type(usbvirt_transaction_type_t type);
-
-/** Telephony methods of virtual devices. */
-typedef enum {
-	IPC_M_USBVIRT_GET_NAME = IPC_FIRST_USER_METHOD,
-	IPC_M_USBVIRT_TRANSACTION_SETUP,
-	IPC_M_USBVIRT_TRANSACTION_OUT,
-	IPC_M_USBVIRT_TRANSACTION_IN,
-} usbvirt_device_method_t;
-
-int usbvirt_connect(usbvirt_device_t *);
-int usbvirt_connect_local(usbvirt_device_t *);
-int usbvirt_disconnect(usbvirt_device_t *dev);
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usbvirt/include/usbvirt/device.h
===================================================================
--- uspace/lib/usbvirt/include/usbvirt/device.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/include/usbvirt/device.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,285 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Virtual USB device.
+ */
+#ifndef LIBUSBVIRT_DEVICE_H_
+#define LIBUSBVIRT_DEVICE_H_
+
+#include <usb/usb.h>
+#include <usb/descriptor.h>
+#include <usb/devreq.h>
+
+/** Request type of a control transfer. */
+typedef enum {
+	/** Standard USB request. */
+	USBVIRT_REQUEST_TYPE_STANDARD = 0,
+	/** Standard class USB request. */
+	USBVIRT_REQUEST_TYPE_CLASS = 1
+} usbvirt_request_type_t;
+
+/** Recipient of control request. */
+typedef enum {
+	/** Device is the recipient of the control request. */
+	USBVIRT_REQUEST_RECIPIENT_DEVICE = 0,
+	/** Interface is the recipient of the control request. */
+	USBVIRT_REQUEST_RECIPIENT_INTERFACE = 1,
+	/** Endpoint is the recipient of the control request. */
+	USBVIRT_REQUEST_RECIPIENT_ENDPOINT = 2,
+	/** Other part of the device is the recipient of the control request. */
+	USBVIRT_REQUEST_RECIPIENT_OTHER = 3
+} usbvirt_request_recipient_t;
+
+/** Possible states of virtual USB device.
+ * Notice that these are not 1:1 mappings to those in USB specification.
+ */
+typedef enum {
+	/** Default state, device listens at default address. */
+	USBVIRT_STATE_DEFAULT,
+	/** Device has non-default address assigned. */
+	USBVIRT_STATE_ADDRESS,
+	/** Device is configured. */
+	USBVIRT_STATE_CONFIGURED
+} usbvirt_device_state_t;
+
+typedef struct usbvirt_device usbvirt_device_t;
+struct usbvirt_control_transfer;
+
+typedef int (*usbvirt_on_device_request_t)(usbvirt_device_t *dev,
+	usb_device_request_setup_packet_t *request,
+	uint8_t *data);
+
+/** Callback for control request over pipe zero.
+ *
+ * @param dev Virtual device answering the call.
+ * @param request Request setup packet.
+ * @param data Data when DATA stage is present.
+ * @return Error code.
+ */
+typedef int (*usbvirt_control_request_callback_t)(usbvirt_device_t *dev,
+	usb_device_request_setup_packet_t *request,
+	uint8_t *data);
+
+/** Handler for control transfer on endpoint zero. */
+typedef struct {
+	/** Request type bitmap.
+	 * Use USBVIRT_MAKE_CONTROL_REQUEST_TYPE for creating the bitmap.
+	 */
+	uint8_t request_type;
+	/** Request code. */
+	uint8_t request;
+	/** Request name for debugging. */
+	const char *name;
+	/** Callback for the request.
+	 * NULL value here announces end of a list.
+	 */
+	usbvirt_control_request_callback_t callback;
+} usbvirt_control_transfer_handler_t;
+
+/** Create control request type bitmap.
+ *
+ * @param direction Transfer direction (use usb_direction_t).
+ * @param type Request type (use usbvirt_request_type_t).
+ * @param recipient Recipient of the request (use usbvirt_request_recipient_t).
+ * @return Request type bitmap.
+ */
+#define USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, type, recipient) \
+	((((direction) == USB_DIRECTION_IN) ? 1 : 0) << 7) \
+	| (((type) & 3) << 5) \
+	| (((recipient) & 31))
+
+/** Create last item in an array of control request handlers. */
+#define USBVIRT_CONTROL_TRANSFER_HANDLER_LAST { 0, 0, NULL, NULL }
+
+/** Device operations. */
+typedef struct {
+	/** Callbacks for transfers over control pipe zero. */
+	usbvirt_control_transfer_handler_t *control_transfer_handlers;
+
+	int (*on_control_transfer)(usbvirt_device_t *dev,
+	    usb_endpoint_t endpoint, struct usbvirt_control_transfer *transfer);
+	
+	/** Callback for all other incoming data. */
+	int (*on_data)(usbvirt_device_t *dev,
+	    usb_endpoint_t endpoint, void *buffer, size_t size);
+	
+	/** Callback for host request for data. */
+	int (*on_data_request)(usbvirt_device_t *dev,
+	    usb_endpoint_t endpoint, void *buffer, size_t size, size_t *actual_size);
+	
+	/** Decides direction of control transfer. */
+	usb_direction_t (*decide_control_transfer_direction)(
+	    usb_endpoint_t endpoint, void *buffer, size_t size);
+
+	/** Callback when device changes its state.
+	 *
+	 * It is correct that this function is called when both states
+	 * are equal (e.g. this function is called during SET_CONFIGURATION
+	 * request done on already configured device).
+	 *
+	 * @warning The value of <code>dev->state</code> before calling
+	 * this function is not specified (i.e. can be @p old_state or
+	 * @p new_state).
+	 */
+	void (*on_state_change)(usbvirt_device_t *dev,
+	    usbvirt_device_state_t old_state, usbvirt_device_state_t new_state);
+} usbvirt_device_ops_t;
+
+/** Extra configuration data for GET_CONFIGURATION request. */
+typedef struct {
+	/** Actual data. */
+	uint8_t *data;
+	/** Data length. */
+	size_t length;
+} usbvirt_device_configuration_extras_t;
+
+/** Single device configuration. */
+typedef struct {
+	/** Standard configuration descriptor. */
+	usb_standard_configuration_descriptor_t *descriptor;
+	/** Array of extra data. */
+	usbvirt_device_configuration_extras_t *extra;
+	/** Length of @c extra array. */
+	size_t extra_count;
+} usbvirt_device_configuration_t;
+
+/** Standard USB descriptors. */
+typedef struct {
+	/** Standard device descriptor.
+	 * There is always only one such descriptor for the device.
+	 */
+	usb_standard_device_descriptor_t *device;
+	
+	/** Configurations. */
+	usbvirt_device_configuration_t *configuration;
+	/** Number of configurations. */
+	size_t configuration_count;
+	/** Index of currently selected configuration. */
+	uint8_t current_configuration;
+} usbvirt_descriptors_t;
+
+/** Information about on-going control transfer.
+ */
+typedef struct usbvirt_control_transfer {
+	/** Transfer direction (read/write control transfer). */
+	usb_direction_t direction;
+	/** Request data. */
+	void *request;
+	/** Size of request data. */
+	size_t request_size;
+	/** Payload. */
+	void *data;
+	/** Size of payload. */
+	size_t data_size;
+} usbvirt_control_transfer_t;
+
+typedef enum {
+	USBVIRT_DEBUGTAG_BASE = 1,
+	USBVIRT_DEBUGTAG_TRANSACTION = 2,
+	USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO = 4,
+	USBVIRT_DEBUGTAG_ALL = 255
+} usbvirt_debug_tags_t;
+
+/** Virtual USB device. */
+struct usbvirt_device {
+	/** Callback device operations. */
+	usbvirt_device_ops_t *ops;
+	
+	/** Custom device data. */
+	void *device_data;
+
+	/** Reply onto control transfer.
+	 */
+	int (*control_transfer_reply)(usbvirt_device_t *dev,
+	    usb_endpoint_t endpoint, void *buffer, size_t size);
+	
+	/** Device name.
+	 * Used in debug prints and sent to virtual host controller.
+	 */
+	const char *name;
+	
+	/** Standard descriptors. */
+	usbvirt_descriptors_t *descriptors;
+	
+	/** Current device state. */
+	usbvirt_device_state_t state;
+	
+	/** Device address. */
+	usb_address_t address;
+	/** New device address.
+	 * This field is used during SET_ADDRESS request.
+	 * On all other occasions, it holds invalid address (e.g. -1).
+	 */
+	usb_address_t new_address;
+	
+	/** Process OUT transaction. */
+	int (*transaction_out)(usbvirt_device_t *dev,
+	    usb_endpoint_t endpoint, void *buffer, size_t size);
+	/** Process SETUP transaction. */
+	int (*transaction_setup)(usbvirt_device_t *dev,
+	    usb_endpoint_t endpoint, void *buffer, size_t size);
+	/** Process IN transaction. */
+	int (*transaction_in)(usbvirt_device_t *dev,
+	    usb_endpoint_t endpoint, void *buffer, size_t size, size_t *data_size);
+	
+	/** State information on control-transfer endpoints. */
+	usbvirt_control_transfer_t current_control_transfers[USB11_ENDPOINT_MAX];
+	
+	/* User debugging. */
+	
+	/** Debug print. */
+	void (*debug)(usbvirt_device_t *dev, int level, uint8_t tag,
+	    const char *format, ...);
+	
+	/** Current debug level. */
+	int debug_level;
+	
+	/** Bitmap of currently enabled tags. */
+	uint8_t debug_enabled_tags;
+	
+	/* Library debugging. */
+	
+	/** Debug print. */
+	void (*lib_debug)(usbvirt_device_t *dev, int level, uint8_t tag,
+	    const char *format, ...);
+	
+	/** Current debug level. */
+	int lib_debug_level;
+	
+	/** Bitmap of currently enabled tags. */
+	uint8_t lib_debug_enabled_tags;
+};
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbvirt/include/usbvirt/hub.h
===================================================================
--- uspace/lib/usbvirt/include/usbvirt/hub.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/include/usbvirt/hub.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Virtual USB device.
+ */
+#ifndef LIBUSBVIRT_HUB_H_
+#define LIBUSBVIRT_HUB_H_
+
+#include "device.h"
+
+/** USB transaction type.
+ * This types does not correspond directly to types in USB specification,
+ * as actually DATA transactions are marked with these types to identify
+ * their direction (and tag).
+ */
+typedef enum {
+	USBVIRT_TRANSACTION_SETUP,
+	USBVIRT_TRANSACTION_IN,
+	USBVIRT_TRANSACTION_OUT
+} usbvirt_transaction_type_t;
+
+const char *usbvirt_str_transaction_type(usbvirt_transaction_type_t type);
+
+/** Telephony methods of virtual devices. */
+typedef enum {
+	IPC_M_USBVIRT_GET_NAME = IPC_FIRST_USER_METHOD,
+	IPC_M_USBVIRT_TRANSACTION_SETUP,
+	IPC_M_USBVIRT_TRANSACTION_OUT,
+	IPC_M_USBVIRT_TRANSACTION_IN,
+} usbvirt_device_method_t;
+
+int usbvirt_connect(usbvirt_device_t *);
+int usbvirt_connect_local(usbvirt_device_t *);
+int usbvirt_disconnect(usbvirt_device_t *dev);
+
+#endif
+/**
+ * @}
+ */
Index: pace/lib/usbvirt/main.c
===================================================================
--- uspace/lib/usbvirt/main.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,289 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Device registration with virtual USB framework.
- */
-#include <devman.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <mem.h>
-#include <assert.h>
-
-#include "hub.h"
-#include "device.h"
-#include "private.h"
-
-#define NAMESPACE "usb"
-
-/** Virtual device wrapper. */
-typedef struct {
-	/** Actual device. */
-	usbvirt_device_t *device;
-	/** Phone to host controller. */
-	int vhcd_phone;
-	/** Device id. */
-	ipcarg_t id;
-	/** Linked-list member. */
-	link_t link;
-} virtual_device_t;
-
-/*** List of known device. */
-static LIST_INITIALIZE(device_list);
-
-/** Find virtual device wrapper based on the contents. */
-static virtual_device_t *find_device(usbvirt_device_t *device)
-{
-	if (list_empty(&device_list)) {
-		return NULL;
-	}
-	
-	link_t *pos;
-	for (pos = device_list.next; pos != &device_list; pos = pos->next) {
-		virtual_device_t *dev
-		    = list_get_instance(pos, virtual_device_t, link);
-		if (dev->device == device) {
-			return dev;
-		}
-	}
-	
-	return NULL;
-}
-
-/** Find virtual device wrapper by its id. */
-static virtual_device_t *find_device_by_id(ipcarg_t id)
-{
-	if (list_empty(&device_list)) {
-		return NULL;
-	}
-	
-	link_t *pos;
-	for (pos = device_list.next; pos != &device_list; pos = pos->next) {
-		virtual_device_t *dev
-		    = list_get_instance(pos, virtual_device_t, link);
-		if (dev->id == id) {
-			return dev;
-		}
-	}
-	
-	return NULL;
-}
-
-/** Reply to a control transfer. */
-static int control_transfer_reply(usbvirt_device_t *device,
-	    usb_endpoint_t endpoint, void *buffer, size_t size)
-{
-	usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint];
-	if (transfer->data != NULL) {
-		free(transfer->data);
-	}
-	transfer->data = malloc(size);
-	memcpy(transfer->data, buffer, size);
-	transfer->data_size = size;
-	
-	return EOK;
-}
-
-/** Initialize virtual device. */
-static void device_init(usbvirt_device_t *dev)
-{
-	dev->transaction_out = transaction_out;
-	dev->transaction_setup = transaction_setup;
-	dev->transaction_in = transaction_in;
-	
-	dev->control_transfer_reply = control_transfer_reply;
-	
-	dev->debug = user_debug;
-	dev->lib_debug = lib_debug;
-	
-	dev->state = USBVIRT_STATE_DEFAULT;
-	dev->address = 0;
-	dev->new_address = -1;
-	
-	size_t i;
-	for (i = 0; i < USB11_ENDPOINT_MAX; i++) {
-		usbvirt_control_transfer_t *transfer = &dev->current_control_transfers[i];
-		transfer->direction = 0;
-		transfer->request = NULL;
-		transfer->request_size = 0;
-		transfer->data = NULL;
-		transfer->data_size = 0;
-	}
-}
-
-/** Add a virtual device.
- * The returned device (if not NULL) shall be destroy via destroy_device().
- */
-static virtual_device_t *add_device(usbvirt_device_t *dev)
-{
-	assert(find_device(dev) == NULL);
-	virtual_device_t *new_device
-	    = (virtual_device_t *) malloc(sizeof(virtual_device_t));
-	
-	new_device->device = dev;
-	link_initialize(&new_device->link);
-	
-	list_append(&new_device->link, &device_list);
-	
-	return new_device;
-}
-
-/** Destroy virtual device. */
-static void destroy_device(virtual_device_t *dev)
-{
-	if (dev->vhcd_phone > 0) {
-		ipc_hangup(dev->vhcd_phone);
-	}
-	
-	list_remove(&dev->link);
-	
-	free(dev);
-}
-
-/** Callback connection handler. */
-static void callback_connection(ipc_callid_t iid, ipc_call_t *icall)
-{
-	// FIXME - determine which device just called back
-	virtual_device_t *dev = find_device_by_id(0);
-	if (dev == NULL) {
-		ipc_answer_0(iid, EINVAL);
-		printf("Ooops\n");
-		return;
-	}
-
-	device_callback_connection(dev->device, iid, icall);
-}
-
-/** Create necessary phones for communication with virtual HCD.
- * This function wraps following calls:
- * -# open <code>/dev/devices/\\virt\\usbhc for reading
- * -# access phone of file opened in previous step
- * -# create callback through just opened phone
- * -# create handler for calling on data from host to function
- * -# return the (outgoing) phone
- *
- * @warning This function is wrapper for several actions and therefore
- * it is not possible - in case of error - to determine at which point
- * error occurred.
- *
- * @param dev Device to connect.
- * @return EOK on success or error code from errno.h.
- */
-int usbvirt_connect(usbvirt_device_t *dev)
-{
-	virtual_device_t *virtual_device = find_device(dev);
-	if (virtual_device != NULL) {
-		return EEXISTS;
-	}
-	
-	const char *vhc_path = "/virt/usbhc";
-	int rc;
-	devman_handle_t handle;
-
-	rc = devman_device_get_handle(vhc_path, &handle, 0);
-	if (rc != EOK) {
-		printf("devman_device_get_handle() failed\n");
-		return rc;
-	}
-	
-	int hcd_phone = devman_device_connect(handle, 0);
-	
-	if (hcd_phone < 0) {
-		printf("devman_device_connect() failed\n");
-		return hcd_phone;
-	}
-	
-	ipcarg_t phonehash;
-	rc = ipc_connect_to_me(hcd_phone, 0, 0, 0, &phonehash);
-	if (rc != EOK) {
-		printf("ipc_connect_to_me() failed\n");
-		return rc;
-	}
-	
-	device_init(dev);
-	
-	virtual_device = add_device(dev);
-	virtual_device->vhcd_phone = hcd_phone;
-	virtual_device->id = 0;
-	
-	async_new_connection(phonehash, 0, NULL, callback_connection);
-	
-	return EOK;
-}
-
-/** Prepares device as local.
- * This is useful if you want to have a virtual device in the same task
- * as HCD.
- *
- * @param dev Device to connect.
- * @return Error code.
- * @retval EOK Device connected.
- * @retval EEXISTS This device is already connected.
- */
-int usbvirt_connect_local(usbvirt_device_t *dev)
-{
-	virtual_device_t *virtual_device = find_device(dev);
-	if (virtual_device != NULL) {
-		return EEXISTS;
-	}
-	
-	device_init(dev);
-	
-	virtual_device = add_device(dev);
-	virtual_device->vhcd_phone = -1;
-	virtual_device->id = 0;
-	
-	return EOK;
-}
-
-/** Disconnects device from HCD.
- *
- * @param dev Device to be disconnected.
- * @return Error code.
- * @retval EOK Device connected.
- * @retval ENOENT This device is not connected.
- */
-int usbvirt_disconnect(usbvirt_device_t *dev)
-{
-	virtual_device_t *virtual_device = find_device(dev);
-	if (virtual_device == NULL) {
-		return ENOENT;
-	}
-	
-	destroy_device(virtual_device);
-	
-	return EOK;
-}
-
-
-/**
- * @}
- */
Index: pace/lib/usbvirt/private.h
===================================================================
--- uspace/lib/usbvirt/private.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,91 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Virtual USB private header.
- */
-#ifndef LIBUSBVIRT_PRIVATE_H_
-#define LIBUSBVIRT_PRIVATE_H_
-
-#include "device.h"
-#include "hub.h"
-
-
-#define DEVICE_HAS_OP(dev, op) \
-	( \
-		(  ((dev)->ops) != NULL  ) \
-		&& \
-		(  ((dev)->ops->op) != NULL  ) \
-	)
-
-int usbvirt_data_to_host(struct usbvirt_device *dev,
-    usb_endpoint_t endpoint, void *buffer, size_t size);
-
-int handle_incoming_data(struct usbvirt_device *dev,
-    usb_endpoint_t endpoint, void *buffer, size_t size);
-
-int control_pipe(usbvirt_device_t *device, usbvirt_control_transfer_t *transfer);
-
-int handle_std_request(usbvirt_device_t *device, usb_device_request_setup_packet_t *request, uint8_t *data);
-
-void device_callback_connection(usbvirt_device_t *device, ipc_callid_t iid, ipc_call_t *icall);
-
-int transaction_setup(usbvirt_device_t *device, usb_endpoint_t endpoint,
-    void *buffer, size_t size);
-int transaction_out(usbvirt_device_t *device, usb_endpoint_t endpoint,
-    void *buffer, size_t size);
-int transaction_in(usbvirt_device_t *device, usb_endpoint_t endpoint,
-    void *buffer, size_t size, size_t *data_size);
-
-
-void user_debug(usbvirt_device_t *device, int level, uint8_t tag,
-    const char *format, ...);
-void lib_debug(usbvirt_device_t *device, int level, uint8_t tag,
-    const char *format, ...);
-    
-static inline const char *str_device_state(usbvirt_device_state_t state)
-{
-	switch (state) {
-		case USBVIRT_STATE_DEFAULT:
-			return "default";
-		case USBVIRT_STATE_ADDRESS:
-			return "address";
-		case USBVIRT_STATE_CONFIGURED:
-			return "configured";
-		default:
-			return "unknown";
-	}
-}
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usbvirt/src/callback.c
===================================================================
--- uspace/lib/usbvirt/src/callback.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/src/callback.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Callback connection handling.
+ */
+#include <devmap.h>
+#include <fcntl.h>
+#include <vfs/vfs.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <mem.h>
+
+#include "private.h"
+
+#define NAMESPACE "usb"
+#define USB_MAX_PAYLOAD_SIZE 1020
+
+/** Wrapper for SETUP transaction over telephone. */
+static void handle_setup_transaction(usbvirt_device_t *device,
+    ipc_callid_t iid, ipc_call_t icall)
+{
+	usb_address_t address = IPC_GET_ARG1(icall);
+	usb_endpoint_t endpoint = IPC_GET_ARG2(icall);
+	size_t expected_len = IPC_GET_ARG3(icall);
+	
+	if (address != device->address) {
+		ipc_answer_0(iid, EADDRNOTAVAIL);
+		return;
+	}
+	
+	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
+		ipc_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	if (expected_len == 0) {
+		ipc_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	size_t len = 0;
+	void * buffer = NULL;
+	int rc = async_data_write_accept(&buffer, false,
+	    1, USB_MAX_PAYLOAD_SIZE, 0, &len);
+		
+	if (rc != EOK) {
+		ipc_answer_0(iid, rc);
+		return;
+	}
+	
+	rc = device->transaction_setup(device, endpoint, buffer, len);
+	
+	ipc_answer_0(iid, rc);
+}
+
+/** Wrapper for OUT transaction over telephone. */
+static void handle_out_transaction(usbvirt_device_t *device,
+    ipc_callid_t iid, ipc_call_t icall)
+{
+	usb_address_t address = IPC_GET_ARG1(icall);
+	usb_endpoint_t endpoint = IPC_GET_ARG2(icall);
+	size_t expected_len = IPC_GET_ARG3(icall);
+	
+	if (address != device->address) {
+		ipc_answer_0(iid, EADDRNOTAVAIL);
+		return;
+	}
+	
+	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
+		ipc_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	int rc = EOK;
+	
+	size_t len = 0;
+	void *buffer = NULL;
+	
+	if (expected_len > 0) {
+		rc = async_data_write_accept(&buffer, false,
+		    1, USB_MAX_PAYLOAD_SIZE, 0, &len);
+			
+		if (rc != EOK) {
+			ipc_answer_0(iid, rc);
+			return;
+		}
+	}
+	
+	rc = device->transaction_out(device, endpoint, buffer, len);
+	
+	if (buffer != NULL) {
+		free(buffer);
+	}
+	
+	ipc_answer_0(iid, rc);
+}
+
+
+/** Wrapper for IN transaction over telephone. */
+static void handle_in_transaction(usbvirt_device_t *device,
+    ipc_callid_t iid, ipc_call_t icall)
+{
+	usb_address_t address = IPC_GET_ARG1(icall);
+	usb_endpoint_t endpoint = IPC_GET_ARG2(icall);
+	size_t expected_len = IPC_GET_ARG3(icall);
+	
+	if (address != device->address) {
+		ipc_answer_0(iid, EADDRNOTAVAIL);
+		return;
+	}
+	
+	if ((endpoint < 0) || (endpoint >= USB11_ENDPOINT_MAX)) {
+		ipc_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	int rc = EOK;
+	
+	void *buffer = expected_len > 0 ? malloc(expected_len) : NULL;
+	size_t len;
+	
+	rc = device->transaction_in(device, endpoint, buffer, expected_len, &len);
+	/*
+	 * If the request was processed, we will send data back.
+	 */
+	if ((rc == EOK) && (expected_len > 0)) {
+		size_t receive_len;
+		ipc_callid_t callid;
+		if (!async_data_read_receive(&callid, &receive_len)) {
+			ipc_answer_0(iid, EINVAL);
+			return;
+		}
+		async_data_read_finalize(callid, buffer, receive_len);
+	}
+	
+	ipc_answer_0(iid, rc);
+}
+
+/** Wrapper for getting device name. */
+static void handle_get_name(usbvirt_device_t *device,
+    ipc_callid_t iid, ipc_call_t icall)
+{
+	if (device->name == NULL) {
+		ipc_answer_0(iid, ENOENT);
+	}
+	
+	size_t size = str_size(device->name);
+	
+	ipc_callid_t callid;
+	size_t accepted_size;
+	if (!async_data_read_receive(&callid, &accepted_size)) {
+		ipc_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	if (accepted_size > size) {
+		accepted_size = size;
+	}
+	async_data_read_finalize(callid, device->name, accepted_size);
+	
+	ipc_answer_1(iid, EOK, accepted_size);
+}
+
+/** Callback connection for a given device. */
+void device_callback_connection(usbvirt_device_t *device, ipc_callid_t iid, ipc_call_t *icall)
+{
+	ipc_answer_0(iid, EOK);
+	
+	while (true) {
+		ipc_callid_t callid; 
+		ipc_call_t call; 
+		
+		callid = async_get_call(&call);
+		switch (IPC_GET_IMETHOD(call)) {
+			case IPC_M_PHONE_HUNGUP:
+				ipc_answer_0(callid, EOK);
+				return;
+			
+			case IPC_M_USBVIRT_GET_NAME:
+				handle_get_name(device, callid, call);
+				break;
+			
+			case IPC_M_USBVIRT_TRANSACTION_SETUP:
+				handle_setup_transaction(device, callid, call);
+				break;
+			
+			case IPC_M_USBVIRT_TRANSACTION_OUT:
+				handle_out_transaction(device, callid, call);
+				break;
+				
+			case IPC_M_USBVIRT_TRANSACTION_IN:
+				handle_in_transaction(device, callid, call);
+				break;
+			
+			default:
+				ipc_answer_0(callid, EINVAL);
+				break;
+		}
+	}
+}
+
+
+/**
+ * @}
+ */
Index: uspace/lib/usbvirt/src/ctrlpipe.c
===================================================================
--- uspace/lib/usbvirt/src/ctrlpipe.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/src/ctrlpipe.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Device control pipe.
+ */
+#include <errno.h>
+
+#include "private.h"
+
+/** Compares handler type with request packet type.
+ *
+ * @param handler Handler.
+ * @param request_packet Request packet.
+ * @return Whether handler can serve this packet.
+ */
+static bool is_suitable_handler(usbvirt_control_transfer_handler_t *handler,
+    usb_device_request_setup_packet_t *request_packet)
+{
+	return (
+	    (handler->request_type == request_packet->request_type)
+	    && (handler->request == request_packet->request));
+
+}
+
+/** Find suitable transfer handler for given request packet.
+ *
+ * @param handlers Array of available handlers.
+ * @param request_packet Request SETUP packet.
+ * @return Handler or NULL.
+ */
+static usbvirt_control_transfer_handler_t *find_handler(
+    usbvirt_control_transfer_handler_t *handlers,
+    usb_device_request_setup_packet_t *request_packet)
+{
+	if (handlers == NULL) {
+		return NULL;
+	}
+
+	while (handlers->callback != NULL) {
+		if (is_suitable_handler(handlers, request_packet)) {
+			return handlers;
+		}
+		handlers++;
+	}
+
+	return NULL;
+}
+
+#define _GET_BIT(byte, bit) \
+	(((byte) & (1 << (bit))) ? '1' : '0')
+#define _GET_BITS(byte) \
+	_GET_BIT(byte, 7), _GET_BIT(byte, 6), _GET_BIT(byte, 5), \
+	_GET_BIT(byte, 4), _GET_BIT(byte, 3), _GET_BIT(byte, 2), \
+	_GET_BIT(byte, 1), _GET_BIT(byte, 0)
+
+static int find_and_run_handler(usbvirt_device_t *device,
+    usbvirt_control_transfer_handler_t *handlers,
+    usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data)
+{
+	int rc = EFORWARD;
+	usbvirt_control_transfer_handler_t *suitable_handler
+	    = find_handler(handlers, setup_packet);
+	if (suitable_handler != NULL) {
+		const char *callback_name = "user handler";
+		if (suitable_handler->name != NULL) {
+			callback_name = suitable_handler->name;
+		}
+		device->lib_debug(device, 1, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO,
+		    "pipe #0 - calling %s " \
+		        "[%c.%c%c.%c%c%c%c%c, R%d, V%d, I%d, L%d]",
+		    callback_name,
+		    _GET_BITS(setup_packet->request_type),
+		    setup_packet->request, setup_packet->value,
+		    setup_packet->index, setup_packet->length);
+		rc = suitable_handler->callback(device, setup_packet, data);
+	}
+
+	return rc;
+}
+#undef _GET_BITS
+#undef _GET_BIT
+
+
+/** Handle communication over control pipe zero.
+ */
+int control_pipe(usbvirt_device_t *device, usbvirt_control_transfer_t *transfer)
+{
+	device->lib_debug(device, 2, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO,
+	    "op on control pipe zero (request_size=%u)", transfer->request_size);
+	
+	if (transfer->request_size < sizeof(usb_device_request_setup_packet_t)) {
+		return ENOMEM;
+	}
+	
+	usb_device_request_setup_packet_t *request
+	    = (usb_device_request_setup_packet_t *) transfer->request;
+
+	/*
+	 * First, see whether user provided its own callback.
+	 */
+	int rc = EFORWARD;
+	if (device->ops) {
+		rc = find_and_run_handler(device,
+		    device->ops->control_transfer_handlers,
+		    request, transfer->data);
+	}
+
+	/*
+	 * If there was no user callback or the callback returned EFORWARD,
+	 * we need to run a local handler.
+	 */
+	if (rc == EFORWARD) {
+		rc = find_and_run_handler(device,
+		    control_pipe_zero_local_handlers,
+		    request, transfer->data);
+	}
+	
+	/*
+	 * Check for SET_ADDRESS finalization.
+	 */
+	if (device->new_address != -1) {
+		/*
+		 * TODO: handle when this request is invalid (e.g.
+		 * setting address when in configured state).
+		 */
+		usbvirt_device_state_t new_state;
+		if (device->new_address == 0) {
+			new_state = USBVIRT_STATE_DEFAULT;
+		} else {
+			new_state = USBVIRT_STATE_ADDRESS;
+		}
+		device->address = device->new_address;
+		
+		device->new_address = -1;
+		
+		if (DEVICE_HAS_OP(device, on_state_change)) {
+			device->ops->on_state_change(device, device->state,
+			    new_state);
+		}
+		device->state = new_state;
+
+		device->lib_debug(device, 2, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO,
+		    "device address changed to %d (state %s)",
+		    device->address, str_device_state(device->state));
+	}
+	
+	return rc;
+}
+
+/**
+ * @}
+ */
Index: uspace/lib/usbvirt/src/debug.c
===================================================================
--- uspace/lib/usbvirt/src/debug.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/src/debug.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Debugging support.
+ */
+#include <stdio.h>
+#include <bool.h>
+
+#include "private.h"
+
+
+static void debug_print(int level, uint8_t tag,
+    int current_level, uint8_t enabled_tags,
+    const char *format, va_list args)
+{
+	if (level > current_level) {
+		return;
+	}
+	
+	if ((tag & enabled_tags) == 0) {
+		return;
+	}
+	
+	bool print_prefix = true;
+	
+	if ((format[0] == '%') && (format[1] == 'M')) {
+		format += 2;
+		print_prefix = false;
+	}
+	
+	if (print_prefix) {
+		printf("[vusb]: ");
+		while (--level > 0) {
+			printf(" ");
+		}
+	}
+	
+	vprintf(format, args);
+	
+	if (print_prefix) {
+		printf("\n");
+	}
+}
+
+
+void user_debug(usbvirt_device_t *device, int level, uint8_t tag,
+    const char *format, ...)
+{
+	va_list args;
+	va_start(args, format);
+	
+	debug_print(level, tag,
+	    device->debug_level, device->debug_enabled_tags,
+	    format, args);
+	
+	va_end(args);
+}
+
+void lib_debug(usbvirt_device_t *device, int level, uint8_t tag,
+    const char *format, ...)
+{
+	va_list args;
+	va_start(args, format);
+	
+	debug_print(level, tag,
+	    device->lib_debug_level, device->lib_debug_enabled_tags,
+	    format, args);
+	
+	va_end(args);
+}
+
+/**
+ * @}
+ */
Index: uspace/lib/usbvirt/src/main.c
===================================================================
--- uspace/lib/usbvirt/src/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/src/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Device registration with virtual USB framework.
+ */
+#include <devman.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <mem.h>
+#include <assert.h>
+
+#include "private.h"
+
+#define NAMESPACE "usb"
+
+/** Virtual device wrapper. */
+typedef struct {
+	/** Actual device. */
+	usbvirt_device_t *device;
+	/** Phone to host controller. */
+	int vhcd_phone;
+	/** Device id. */
+	sysarg_t id;
+	/** Linked-list member. */
+	link_t link;
+} virtual_device_t;
+
+/*** List of known device. */
+static LIST_INITIALIZE(device_list);
+
+/** Find virtual device wrapper based on the contents. */
+static virtual_device_t *find_device(usbvirt_device_t *device)
+{
+	if (list_empty(&device_list)) {
+		return NULL;
+	}
+	
+	link_t *pos;
+	for (pos = device_list.next; pos != &device_list; pos = pos->next) {
+		virtual_device_t *dev
+		    = list_get_instance(pos, virtual_device_t, link);
+		if (dev->device == device) {
+			return dev;
+		}
+	}
+	
+	return NULL;
+}
+
+/** Find virtual device wrapper by its id. */
+static virtual_device_t *find_device_by_id(sysarg_t id)
+{
+	if (list_empty(&device_list)) {
+		return NULL;
+	}
+	
+	link_t *pos;
+	for (pos = device_list.next; pos != &device_list; pos = pos->next) {
+		virtual_device_t *dev
+		    = list_get_instance(pos, virtual_device_t, link);
+		if (dev->id == id) {
+			return dev;
+		}
+	}
+	
+	return NULL;
+}
+
+/** Reply to a control transfer. */
+static int control_transfer_reply(usbvirt_device_t *device,
+	    usb_endpoint_t endpoint, void *buffer, size_t size)
+{
+	usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint];
+	if (transfer->data != NULL) {
+		free(transfer->data);
+	}
+	transfer->data = malloc(size);
+	memcpy(transfer->data, buffer, size);
+	transfer->data_size = size;
+	
+	return EOK;
+}
+
+/** Initialize virtual device. */
+static void device_init(usbvirt_device_t *dev)
+{
+	dev->transaction_out = transaction_out;
+	dev->transaction_setup = transaction_setup;
+	dev->transaction_in = transaction_in;
+	
+	dev->control_transfer_reply = control_transfer_reply;
+	
+	dev->debug = user_debug;
+	dev->lib_debug = lib_debug;
+	
+	dev->state = USBVIRT_STATE_DEFAULT;
+	dev->address = 0;
+	dev->new_address = -1;
+	
+	size_t i;
+	for (i = 0; i < USB11_ENDPOINT_MAX; i++) {
+		usbvirt_control_transfer_t *transfer = &dev->current_control_transfers[i];
+		transfer->direction = 0;
+		transfer->request = NULL;
+		transfer->request_size = 0;
+		transfer->data = NULL;
+		transfer->data_size = 0;
+	}
+}
+
+/** Add a virtual device.
+ * The returned device (if not NULL) shall be destroy via destroy_device().
+ */
+static virtual_device_t *add_device(usbvirt_device_t *dev)
+{
+	assert(find_device(dev) == NULL);
+	virtual_device_t *new_device
+	    = (virtual_device_t *) malloc(sizeof(virtual_device_t));
+	
+	new_device->device = dev;
+	link_initialize(&new_device->link);
+	
+	list_append(&new_device->link, &device_list);
+	
+	return new_device;
+}
+
+/** Destroy virtual device. */
+static void destroy_device(virtual_device_t *dev)
+{
+	if (dev->vhcd_phone > 0) {
+		ipc_hangup(dev->vhcd_phone);
+	}
+	
+	list_remove(&dev->link);
+	
+	free(dev);
+}
+
+/** Callback connection handler. */
+static void callback_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	// FIXME - determine which device just called back
+	virtual_device_t *dev = find_device_by_id(0);
+	if (dev == NULL) {
+		ipc_answer_0(iid, EINVAL);
+		printf("Ooops\n");
+		return;
+	}
+
+	device_callback_connection(dev->device, iid, icall);
+}
+
+/** Create necessary phones for communication with virtual HCD.
+ * This function wraps following calls:
+ * -# open <code>/dev/devices/\\virt\\usbhc for reading
+ * -# access phone of file opened in previous step
+ * -# create callback through just opened phone
+ * -# create handler for calling on data from host to function
+ * -# return the (outgoing) phone
+ *
+ * @warning This function is wrapper for several actions and therefore
+ * it is not possible - in case of error - to determine at which point
+ * error occurred.
+ *
+ * @param dev Device to connect.
+ * @return EOK on success or error code from errno.h.
+ */
+int usbvirt_connect(usbvirt_device_t *dev)
+{
+	virtual_device_t *virtual_device = find_device(dev);
+	if (virtual_device != NULL) {
+		return EEXISTS;
+	}
+	
+	const char *vhc_path = "/virt/usbhc";
+	int rc;
+	devman_handle_t handle;
+
+	rc = devman_device_get_handle(vhc_path, &handle, 0);
+	if (rc != EOK) {
+		printf("devman_device_get_handle() failed\n");
+		return rc;
+	}
+	
+	int hcd_phone = devman_device_connect(handle, 0);
+	
+	if (hcd_phone < 0) {
+		printf("devman_device_connect() failed\n");
+		return hcd_phone;
+	}
+	
+	sysarg_t phonehash;
+	rc = ipc_connect_to_me(hcd_phone, 0, 0, 0, &phonehash);
+	if (rc != EOK) {
+		printf("ipc_connect_to_me() failed\n");
+		return rc;
+	}
+	
+	device_init(dev);
+	
+	virtual_device = add_device(dev);
+	virtual_device->vhcd_phone = hcd_phone;
+	virtual_device->id = 0;
+	
+	async_new_connection(phonehash, 0, NULL, callback_connection);
+	
+	return EOK;
+}
+
+/** Prepares device as local.
+ * This is useful if you want to have a virtual device in the same task
+ * as HCD.
+ *
+ * @param dev Device to connect.
+ * @return Error code.
+ * @retval EOK Device connected.
+ * @retval EEXISTS This device is already connected.
+ */
+int usbvirt_connect_local(usbvirt_device_t *dev)
+{
+	virtual_device_t *virtual_device = find_device(dev);
+	if (virtual_device != NULL) {
+		return EEXISTS;
+	}
+	
+	device_init(dev);
+	
+	virtual_device = add_device(dev);
+	virtual_device->vhcd_phone = -1;
+	virtual_device->id = 0;
+	
+	return EOK;
+}
+
+/** Disconnects device from HCD.
+ *
+ * @param dev Device to be disconnected.
+ * @return Error code.
+ * @retval EOK Device connected.
+ * @retval ENOENT This device is not connected.
+ */
+int usbvirt_disconnect(usbvirt_device_t *dev)
+{
+	virtual_device_t *virtual_device = find_device(dev);
+	if (virtual_device == NULL) {
+		return ENOENT;
+	}
+	
+	destroy_device(virtual_device);
+	
+	return EOK;
+}
+
+
+/**
+ * @}
+ */
Index: uspace/lib/usbvirt/src/private.h
===================================================================
--- uspace/lib/usbvirt/src/private.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/src/private.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Virtual USB private header.
+ */
+#ifndef LIBUSBVIRT_PRIVATE_H_
+#define LIBUSBVIRT_PRIVATE_H_
+
+#include <usbvirt/device.h>
+#include <usbvirt/hub.h>
+#include <assert.h>
+
+
+#define DEVICE_HAS_OP(dev, op) \
+	( \
+		(  ((dev)->ops) != NULL  ) \
+		&& \
+		(  ((dev)->ops->op) != NULL  ) \
+	)
+
+int usbvirt_data_to_host(struct usbvirt_device *dev,
+    usb_endpoint_t endpoint, void *buffer, size_t size);
+
+int handle_incoming_data(struct usbvirt_device *dev,
+    usb_endpoint_t endpoint, void *buffer, size_t size);
+
+int control_pipe(usbvirt_device_t *device, usbvirt_control_transfer_t *transfer);
+
+int handle_std_request(usbvirt_device_t *device, usb_device_request_setup_packet_t *request, uint8_t *data);
+
+void device_callback_connection(usbvirt_device_t *device, ipc_callid_t iid, ipc_call_t *icall);
+
+int transaction_setup(usbvirt_device_t *device, usb_endpoint_t endpoint,
+    void *buffer, size_t size);
+int transaction_out(usbvirt_device_t *device, usb_endpoint_t endpoint,
+    void *buffer, size_t size);
+int transaction_in(usbvirt_device_t *device, usb_endpoint_t endpoint,
+    void *buffer, size_t size, size_t *data_size);
+
+
+void user_debug(usbvirt_device_t *device, int level, uint8_t tag,
+    const char *format, ...);
+void lib_debug(usbvirt_device_t *device, int level, uint8_t tag,
+    const char *format, ...);
+    
+static inline const char *str_device_state(usbvirt_device_state_t state)
+{
+	switch (state) {
+		case USBVIRT_STATE_DEFAULT:
+			return "default";
+		case USBVIRT_STATE_ADDRESS:
+			return "address";
+		case USBVIRT_STATE_CONFIGURED:
+			return "configured";
+		default:
+			return "unknown";
+	}
+}
+
+extern usbvirt_control_transfer_handler_t control_pipe_zero_local_handlers[];
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usbvirt/src/stdreq.c
===================================================================
--- uspace/lib/usbvirt/src/stdreq.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/src/stdreq.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Preprocessing of standard device requests.
+ */
+#include <errno.h>
+#include <stdlib.h>
+#include <mem.h>
+#include <usb/devreq.h>
+
+#include "private.h"
+
+/*
+ * All sub handlers must return EFORWARD to inform the caller that
+ * they were not able to process the request (yes, it is abuse of
+ * this error code but such error code shall not collide with anything
+ * else in this context).
+ */
+ 
+/** GET_DESCRIPTOR handler. */
+static int handle_get_descriptor(usbvirt_device_t *device,
+    usb_device_request_setup_packet_t *setup_packet, uint8_t *extra_data)
+{
+	uint8_t type = setup_packet->value_high;
+	uint8_t index = setup_packet->value_low;
+
+	/* 
+	 * Standard device descriptor.
+	 */
+	if ((type == USB_DESCTYPE_DEVICE) && (index == 0)) {
+		if (device->descriptors && device->descriptors->device) {
+			return device->control_transfer_reply(device, 0,
+			    device->descriptors->device,
+			    device->descriptors->device->length);
+		} else {
+			return EFORWARD;
+		}
+	}
+	
+	/*
+	 * Configuration descriptor together with interface, endpoint and
+	 * class-specific descriptors.
+	 */
+	if (type == USB_DESCTYPE_CONFIGURATION) {
+		if (!device->descriptors) {
+			return EFORWARD;
+		}
+		if (index >= device->descriptors->configuration_count) {
+			return EFORWARD;
+		}
+		/* Copy the data. */
+		usbvirt_device_configuration_t *config = &device->descriptors
+		    ->configuration[index];
+		uint8_t *all_data = malloc(config->descriptor->total_length);
+		if (all_data == NULL) {
+			return ENOMEM;
+		}
+		
+		uint8_t *ptr = all_data;
+		memcpy(ptr, config->descriptor, config->descriptor->length);
+		ptr += config->descriptor->length;
+		size_t i;
+		for (i = 0; i < config->extra_count; i++) {
+			usbvirt_device_configuration_extras_t *extra
+			    = &config->extra[i];
+			memcpy(ptr, extra->data, extra->length);
+			ptr += extra->length;
+		}
+		
+		int rc = device->control_transfer_reply(device, 0,
+		    all_data, config->descriptor->total_length);
+		
+		free(all_data);
+		
+		return rc;
+	}
+	
+	return EFORWARD;
+}
+
+/** SET_ADDRESS handler. */
+static int handle_set_address(usbvirt_device_t *device,
+    usb_device_request_setup_packet_t *setup_packet, uint8_t *extra_data)
+{
+	uint16_t new_address = setup_packet->value;
+	uint16_t zero1 = setup_packet->index;
+	uint16_t zero2 = setup_packet->length;
+
+	if ((zero1 != 0) || (zero2 != 0)) {
+		return EINVAL;
+	}
+	
+	if (new_address > 127) {
+		return EINVAL;
+	}
+	
+	device->new_address = new_address;
+	
+	return EOK;
+}
+
+/** SET_CONFIGURATION handler. */
+static int handle_set_configuration(usbvirt_device_t *device,
+    usb_device_request_setup_packet_t *setup_packet, uint8_t *extra_data)
+{
+	uint16_t configuration_value = setup_packet->value;
+	uint16_t zero1 = setup_packet->index;
+	uint16_t zero2 = setup_packet->length;
+
+	if ((zero1 != 0) || (zero2 != 0)) {
+		return EINVAL;
+	}
+	
+	/*
+	 * Configuration value is 1 byte information.
+	 */
+	if (configuration_value > 255) {
+		return EINVAL;
+	}
+	
+	/*
+	 * Do nothing when in default state. According to specification,
+	 * this is not specified.
+	 */
+	if (device->state == USBVIRT_STATE_DEFAULT) {
+		return EOK;
+	}
+	
+	if (configuration_value == 0) {
+		if (DEVICE_HAS_OP(device, on_state_change)) {
+			device->ops->on_state_change(device, device->state,
+			    USBVIRT_STATE_ADDRESS);
+		}
+		device->state = USBVIRT_STATE_ADDRESS;
+	} else {
+		/*
+		* TODO: browse provided configurations and verify that
+		* user selected existing configuration.
+		*/
+		if (DEVICE_HAS_OP(device, on_state_change)) {
+			device->ops->on_state_change(device, device->state,
+			    USBVIRT_STATE_CONFIGURED);
+		}
+		device->state = USBVIRT_STATE_CONFIGURED;
+		if (device->descriptors) {
+			device->descriptors->current_configuration
+			    = configuration_value;
+		}
+	}
+		
+	return EOK;
+}
+
+
+#define MAKE_BM_REQUEST(direction, recipient) \
+	USBVIRT_MAKE_CONTROL_REQUEST_TYPE(direction, \
+	    USBVIRT_REQUEST_TYPE_STANDARD, recipient)
+#define MAKE_BM_REQUEST_DEV(direction) \
+	MAKE_BM_REQUEST(direction, USBVIRT_REQUEST_RECIPIENT_DEVICE)
+
+usbvirt_control_transfer_handler_t control_pipe_zero_local_handlers[] = {
+	{
+		.request_type = MAKE_BM_REQUEST_DEV(USB_DIRECTION_IN),
+		.request = USB_DEVREQ_GET_DESCRIPTOR,
+		.name = "GetDescriptor()",
+		.callback = handle_get_descriptor
+	},
+	{
+		.request_type = MAKE_BM_REQUEST_DEV(USB_DIRECTION_OUT),
+		.request = USB_DEVREQ_SET_ADDRESS,
+		.name = "SetAddress()",
+		.callback = handle_set_address
+	},
+	{
+		.request_type = MAKE_BM_REQUEST_DEV(USB_DIRECTION_OUT),
+		.request = USB_DEVREQ_SET_CONFIGURATION,
+		.name = "SetConfiguration()",
+		.callback = handle_set_configuration
+	},
+	USBVIRT_CONTROL_TRANSFER_HANDLER_LAST
+};
+
+/**
+ * @}
+ */
Index: uspace/lib/usbvirt/src/transaction.c
===================================================================
--- uspace/lib/usbvirt/src/transaction.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
+++ uspace/lib/usbvirt/src/transaction.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libusbvirt usb
+ * @{
+ */
+/** @file
+ * @brief Transaction processing.
+ */
+#include <errno.h>
+#include <stdlib.h>
+#include <mem.h>
+
+#include "private.h"
+
+static usb_direction_t setup_transaction_direction(usbvirt_device_t *,
+    usb_endpoint_t, void *, size_t);
+static void process_control_transfer(usbvirt_device_t *,
+    usb_endpoint_t, usbvirt_control_transfer_t *);
+
+/** Convert virtual USB transaction type to string.
+ */
+const char *usbvirt_str_transaction_type(usbvirt_transaction_type_t type)
+{
+	switch (type) {
+		case USBVIRT_TRANSACTION_SETUP:
+			return "setup";
+		case USBVIRT_TRANSACTION_IN:
+			return "in";
+		case USBVIRT_TRANSACTION_OUT:
+			return "out";
+		default:
+			return "unknown";
+	}
+}
+
+/** SETUP transaction handling.
+ * The setup transaction only prepares control transfer on given endpoint.
+ */
+int transaction_setup(usbvirt_device_t *device, usb_endpoint_t endpoint,
+    void *buffer, size_t size)
+{
+	device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
+	    "setup transaction: endpoint=%d, size=%u", endpoint, size);
+	
+	usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint];
+	
+	if (transfer->request != NULL) {
+		free(transfer->request);
+	}
+	if (transfer->data != NULL) {
+		free(transfer->data);
+	}
+	
+	transfer->direction = setup_transaction_direction(device, endpoint,
+	    buffer, size);
+	transfer->request = malloc(size);
+	memcpy(transfer->request, buffer, size);
+	transfer->request_size = size;
+	transfer->data = NULL;
+	transfer->data_size = 0;
+	
+	if (transfer->direction == USB_DIRECTION_IN) {
+		process_control_transfer(device, endpoint, transfer);
+	}
+	
+	return EOK;
+}
+
+/** OUT transaction handling.
+ * The OUT transaction can trigger processing of a control transfer.
+ */
+int transaction_out(usbvirt_device_t *device, usb_endpoint_t endpoint,
+    void *buffer, size_t size)
+{
+	device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
+	    "out transaction: endpoint=%d, size=%u", endpoint, size);
+	
+	/*
+	 * First check whether it is a transaction over control pipe.
+	 */
+	usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint];
+	if (transfer->request != NULL) {
+		if (transfer->direction == USB_DIRECTION_OUT) {
+			/*
+			 * For out transactions, append the data to the buffer.
+			 */
+			uint8_t *new_buffer = (uint8_t *) malloc(transfer->data_size + size);
+			if (transfer->data) {
+				memcpy(new_buffer, transfer->data, transfer->data_size);
+			}
+			memcpy(new_buffer + transfer->data_size, buffer, size);
+			
+			if (transfer->data) {
+				free(transfer->data);
+			}
+			transfer->data = new_buffer;
+			transfer->data_size += size;
+		} else {
+			/*
+			 * For in transactions, this means end of the
+			 * transaction.
+			 */
+			free(transfer->request);
+			if (transfer->data) {
+				free(transfer->data);
+			}
+			transfer->request = NULL;
+			transfer->request_size = 0;
+			transfer->data = NULL;
+			transfer->data_size = 0;
+		}
+		
+		return EOK;
+	}
+	
+	/*
+	 * Otherwise, announce that some data has come.
+	 */
+	if (device->ops && device->ops->on_data) {
+		return device->ops->on_data(device, endpoint, buffer, size);
+	} else {
+		return ENOTSUP;
+	}
+}
+
+/** IN transaction handling.
+ * The IN transaction can trigger processing of a control transfer.
+ */
+int transaction_in(usbvirt_device_t *device, usb_endpoint_t endpoint,
+    void *buffer, size_t size, size_t *data_size)
+{
+	device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
+	    "in transaction: endpoint=%d, size=%u", endpoint, size);
+	
+	/*
+	 * First check whether it is a transaction over control pipe.
+	 */
+	usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint];
+	if (transfer->request != NULL) {
+		if (transfer->direction == USB_DIRECTION_OUT) {
+			/*
+			 * This means end of input data.
+			 */
+			process_control_transfer(device, endpoint, transfer);
+		} else {
+			/*
+			 * For in transactions, this means sending next part
+			 * of the buffer.
+			 */
+			// FIXME: handle when the HC wants the data back
+			// in more chunks
+			size_t actual_size = 0;
+			if (transfer->data) {
+				actual_size = transfer->data_size;
+			}
+			if (actual_size > size) {
+				actual_size = size;
+			}
+			device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
+			    "in transaction: will copy %zu bytes", actual_size);
+			if (actual_size > 0) {
+				memcpy(buffer, transfer->data, actual_size);
+				if (data_size) {
+					*data_size = actual_size;
+				}
+			}
+		}
+		
+		return EOK;
+	}
+	
+	if (size == 0) {
+		return EINVAL;
+	}
+	
+	int rc = 1;
+	
+	if (device->ops && device->ops->on_data_request) {
+		rc = device->ops->on_data_request(device, endpoint, buffer, size, data_size);
+	}
+	
+	return rc;
+}
+
+/** Determine direction of control transfer.
+ * First, try the user provided callback, otherwise guess, believing that
+ * it uses the same format as control pipe 0.
+ */
+static usb_direction_t setup_transaction_direction(usbvirt_device_t *device,
+    usb_endpoint_t endpoint,
+    void *data, size_t size)
+{
+	int direction = -1;
+	if (device->ops && device->ops->decide_control_transfer_direction) {
+		direction = device->ops->decide_control_transfer_direction(endpoint,
+		    data, size);
+	}
+	
+	/*
+	 * If the user-supplied routine have not handled the direction
+	 * (or simply was not provided) we will guess, hoping that it 
+	 * uses same format as standard request on control pipe zero.
+	 */
+	if (direction < 0) {
+		if (size > 0) {
+			uint8_t *ptr = (uint8_t *) data;
+			if ((ptr[0] & 128) == 128) {
+				direction = USB_DIRECTION_IN;
+			} else {
+				direction = USB_DIRECTION_OUT;
+			}
+		} else {
+			/* This shall not happen anyway. */
+			direction = USB_DIRECTION_OUT;
+		}
+	}
+	
+	return (usb_direction_t) direction;
+}
+
+/** Process control transfer.
+ */
+static void process_control_transfer(usbvirt_device_t *device,
+    usb_endpoint_t endpoint,
+    usbvirt_control_transfer_t *transfer)
+{
+	int rc = EFORWARD;
+	
+	if (device->ops && device->ops->on_control_transfer) {
+		rc = device->ops->on_control_transfer(device, endpoint, transfer);
+	}
+	
+	if (rc == EFORWARD) {
+		if (endpoint == 0) {
+			rc = control_pipe(device, transfer);
+		}
+	}
+}
+
+/**
+ * @}
+ */
Index: pace/lib/usbvirt/stdreq.c
===================================================================
--- uspace/lib/usbvirt/stdreq.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,212 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Preprocessing of standard device requests.
- */
-#include <errno.h>
-#include <stdlib.h>
-#include <mem.h>
-#include <usb/devreq.h>
-
-#include "private.h"
-
-
-
-/*
- * All sub handlers must return EFORWARD to inform the caller that
- * they were not able to process the request (yes, it is abuse of
- * this error code but such error code shall not collide with anything
- * else in this context).
- */
- 
-/** GET_DESCRIPTOR handler. */
-static int handle_get_descriptor(usbvirt_device_t *device,
-    uint8_t type, uint8_t index, uint16_t language,
-    uint16_t length)
-{
-	/* 
-	 * Standard device descriptor.
-	 */
-	if ((type == USB_DESCTYPE_DEVICE) && (index == 0)) {
-		if (device->descriptors && device->descriptors->device) {
-			return device->control_transfer_reply(device, 0,
-			    device->descriptors->device,
-			    device->descriptors->device->length);
-		} else {
-			return EFORWARD;
-		}
-	}
-	
-	/*
-	 * Configuration descriptor together with interface, endpoint and
-	 * class-specific descriptors.
-	 */
-	if (type == USB_DESCTYPE_CONFIGURATION) {
-		if (!device->descriptors) {
-			return EFORWARD;
-		}
-		if (index >= device->descriptors->configuration_count) {
-			return EFORWARD;
-		}
-		/* Copy the data. */
-		usbvirt_device_configuration_t *config = &device->descriptors
-		    ->configuration[index];
-		uint8_t *all_data = malloc(config->descriptor->total_length);
-		if (all_data == NULL) {
-			return ENOMEM;
-		}
-		
-		uint8_t *ptr = all_data;
-		memcpy(ptr, config->descriptor, config->descriptor->length);
-		ptr += config->descriptor->length;
-		size_t i;
-		for (i = 0; i < config->extra_count; i++) {
-			usbvirt_device_configuration_extras_t *extra
-			    = &config->extra[i];
-			memcpy(ptr, extra->data, extra->length);
-			ptr += extra->length;
-		}
-		
-		int rc = device->control_transfer_reply(device, 0,
-		    all_data, config->descriptor->total_length);
-		
-		free(all_data);
-		
-		return rc;
-	}
-	
-	return EFORWARD;
-}
-
-/** SET_ADDRESS handler. */
-static int handle_set_address(usbvirt_device_t *device,
-    uint16_t new_address,
-    uint16_t zero1, uint16_t zero2)
-{
-	if ((zero1 != 0) || (zero2 != 0)) {
-		return EINVAL;
-	}
-	
-	if (new_address > 127) {
-		return EINVAL;
-	}
-	
-	device->new_address = new_address;
-	
-	return EOK;
-}
-
-/** SET_CONFIGURATION handler. */
-static int handle_set_configuration(usbvirt_device_t *device,
-    uint16_t configuration_value,
-    uint16_t zero1, uint16_t zero2)
-{
-	if ((zero1 != 0) || (zero2 != 0)) {
-		return EINVAL;
-	}
-	
-	/*
-	 * Configuration value is 1 byte information.
-	 */
-	if (configuration_value > 255) {
-		return EINVAL;
-	}
-	
-	/*
-	 * Do nothing when in default state. According to specification,
-	 * this is not specified.
-	 */
-	if (device->state == USBVIRT_STATE_DEFAULT) {
-		return EOK;
-	}
-	
-	if (configuration_value == 0) {
-		device->state = USBVIRT_STATE_ADDRESS;
-	} else {
-		/*
-		* TODO: browse provided configurations and verify that
-		* user selected existing configuration.
-		*/
-		device->state = USBVIRT_STATE_CONFIGURED;
-		if (device->descriptors) {
-			device->descriptors->current_configuration
-			    = configuration_value;
-		}
-	}
-		
-	return EOK;
-}
-
-#define HANDLE_REQUEST(request, data, type, dev, user_callback, default_handler) \
-	do { \
-		if ((request)->request == (type)) { \
-			int _rc = EFORWARD; \
-			if (((dev)->ops) && ((dev)->ops->standard_request_ops) \
-			    && ((dev)->ops->standard_request_ops->user_callback)) { \
-				_rc = (dev)->ops->standard_request_ops->\
-				    user_callback(dev, request, data); \
-			} \
-			if (_rc == EFORWARD) { \
-				default_handler; \
-			} \
-			return _rc; \
-		} \
-	} while (false)
-
-/** Handle standard device request. */
-int handle_std_request(usbvirt_device_t *device,
-    usb_device_request_setup_packet_t *request, uint8_t *data)
-{
-	device->lib_debug(device, 3, USBVIRT_DEBUGTAG_CONTROL_PIPE_ZERO,
-	    "handling standard request %d", request->request);
-	
-	HANDLE_REQUEST(request, data, USB_DEVREQ_GET_DESCRIPTOR,
-	    device, on_get_descriptor,
-	    handle_get_descriptor(device, request->value_high, request->value_low,
-	        request->index, request->length));
-	
-	HANDLE_REQUEST(request, data, USB_DEVREQ_SET_ADDRESS,
-	    device, on_set_address,
-	    handle_set_address(device, request->value,
-	        request->index, request->length));
-	
-	HANDLE_REQUEST(request, data, USB_DEVREQ_SET_CONFIGURATION,
-	    device, on_set_configuration,
-	    handle_set_configuration(device, request->value,
-	        request->index, request->length));
-	
-	return ENOTSUP;
-}
-
-/**
- * @}
- */
Index: pace/lib/usbvirt/transaction.c
===================================================================
--- uspace/lib/usbvirt/transaction.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ 	(revision )
@@ -1,269 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libusbvirt usb
- * @{
- */
-/** @file
- * @brief Transaction processing.
- */
-#include <errno.h>
-#include <stdlib.h>
-#include <mem.h>
-
-#include "hub.h"
-#include "private.h"
-
-static usb_direction_t setup_transaction_direction(usbvirt_device_t *,
-    usb_endpoint_t, void *, size_t);
-static void process_control_transfer(usbvirt_device_t *,
-    usb_endpoint_t, usbvirt_control_transfer_t *);
-
-/** Convert virtual USB transaction type to string.
- */
-const char *usbvirt_str_transaction_type(usbvirt_transaction_type_t type)
-{
-	switch (type) {
-		case USBVIRT_TRANSACTION_SETUP:
-			return "setup";
-		case USBVIRT_TRANSACTION_IN:
-			return "in";
-		case USBVIRT_TRANSACTION_OUT:
-			return "out";
-		default:
-			return "unknown";
-	}
-}
-
-/** SETUP transaction handling.
- * The setup transaction only prepares control transfer on given endpoint.
- */
-int transaction_setup(usbvirt_device_t *device, usb_endpoint_t endpoint,
-    void *buffer, size_t size)
-{
-	device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
-	    "setup transaction: endpoint=%d, size=%u", endpoint, size);
-	
-	usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint];
-	
-	if (transfer->request != NULL) {
-		free(transfer->request);
-	}
-	if (transfer->data != NULL) {
-		free(transfer->data);
-	}
-	
-	transfer->direction = setup_transaction_direction(device, endpoint,
-	    buffer, size);
-	transfer->request = malloc(size);
-	memcpy(transfer->request, buffer, size);
-	transfer->request_size = size;
-	transfer->data = NULL;
-	transfer->data_size = 0;
-	
-	if (transfer->direction == USB_DIRECTION_IN) {
-		process_control_transfer(device, endpoint, transfer);
-	}
-	
-	return EOK;
-}
-
-/** OUT transaction handling.
- * The OUT transaction can trigger processing of a control transfer.
- */
-int transaction_out(usbvirt_device_t *device, usb_endpoint_t endpoint,
-    void *buffer, size_t size)
-{
-	device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
-	    "out transaction: endpoint=%d, size=%u", endpoint, size);
-	
-	/*
-	 * First check whether it is a transaction over control pipe.
-	 */
-	usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint];
-	if (transfer->request != NULL) {
-		if (transfer->direction == USB_DIRECTION_OUT) {
-			/*
-			 * For out transactions, append the data to the buffer.
-			 */
-			uint8_t *new_buffer = (uint8_t *) malloc(transfer->data_size + size);
-			if (transfer->data) {
-				memcpy(new_buffer, transfer->data, transfer->data_size);
-			}
-			memcpy(new_buffer + transfer->data_size, buffer, size);
-			
-			if (transfer->data) {
-				free(transfer->data);
-			}
-			transfer->data = new_buffer;
-			transfer->data_size += size;
-		} else {
-			/*
-			 * For in transactions, this means end of the
-			 * transaction.
-			 */
-			free(transfer->request);
-			if (transfer->data) {
-				free(transfer->data);
-			}
-			transfer->request = NULL;
-			transfer->request_size = 0;
-			transfer->data = NULL;
-			transfer->data_size = 0;
-		}
-		
-		return EOK;
-	}
-	
-	/*
-	 * Otherwise, announce that some data has come.
-	 */
-	if (device->ops && device->ops->on_data) {
-		return device->ops->on_data(device, endpoint, buffer, size);
-	} else {
-		return ENOTSUP;
-	}
-}
-
-/** IN transaction handling.
- * The IN transaction can trigger processing of a control transfer.
- */
-int transaction_in(usbvirt_device_t *device, usb_endpoint_t endpoint,
-    void *buffer, size_t size, size_t *data_size)
-{
-	device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
-	    "in transaction: endpoint=%d, size=%u", endpoint, size);
-	
-	/*
-	 * First check whether it is a transaction over control pipe.
-	 */
-	usbvirt_control_transfer_t *transfer = &device->current_control_transfers[endpoint];
-	if (transfer->request != NULL) {
-		if (transfer->direction == USB_DIRECTION_OUT) {
-			/*
-			 * This means end of input data.
-			 */
-			process_control_transfer(device, endpoint, transfer);
-		} else {
-			/*
-			 * For in transactions, this means sending next part
-			 * of the buffer.
-			 */
-			// FIXME: handle when the HC wants the data back
-			// in more chunks
-			size_t actual_size = 0;
-			if (transfer->data) {
-				actual_size = transfer->data_size;
-			}
-			if (actual_size > size) {
-				actual_size = size;
-			}
-			device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
-			    "in transaction: will copy %zu bytes", actual_size);
-			if (actual_size > 0) {
-				memcpy(buffer, transfer->data, actual_size);
-				if (data_size) {
-					*data_size = actual_size;
-				}
-			}
-		}
-		
-		return EOK;
-	}
-	
-	if (size == 0) {
-		return EINVAL;
-	}
-	
-	int rc = 1;
-	
-	if (device->ops && device->ops->on_data_request) {
-		rc = device->ops->on_data_request(device, endpoint, buffer, size, data_size);
-	}
-	
-	return rc;
-}
-
-/** Determine direction of control transfer.
- * First, try the user provided callback, otherwise guess, believing that
- * it uses the same format as control pipe 0.
- */
-static usb_direction_t setup_transaction_direction(usbvirt_device_t *device,
-    usb_endpoint_t endpoint,
-    void *data, size_t size)
-{
-	int direction = -1;
-	if (device->ops && device->ops->decide_control_transfer_direction) {
-		direction = device->ops->decide_control_transfer_direction(endpoint,
-		    data, size);
-	}
-	
-	/*
-	 * If the user-supplied routine have not handled the direction
-	 * (or simply was not provided) we will guess, hoping that it 
-	 * uses same format as standard request on control pipe zero.
-	 */
-	if (direction < 0) {
-		if (size > 0) {
-			uint8_t *ptr = (uint8_t *) data;
-			if ((ptr[0] & 128) == 128) {
-				direction = USB_DIRECTION_IN;
-			} else {
-				direction = USB_DIRECTION_OUT;
-			}
-		} else {
-			/* This shall not happen anyway. */
-			direction = USB_DIRECTION_OUT;
-		}
-	}
-	
-	return (usb_direction_t) direction;
-}
-
-/** Process control transfer.
- */
-static void process_control_transfer(usbvirt_device_t *device,
-    usb_endpoint_t endpoint,
-    usbvirt_control_transfer_t *transfer)
-{
-	int rc = EFORWARD;
-	
-	if (device->ops && device->ops->on_control_transfer) {
-		rc = device->ops->on_control_transfer(device, endpoint, transfer);
-	}
-	
-	if (rc == EFORWARD) {
-		if (endpoint == 0) {
-			rc = control_pipe(device, transfer);
-		}
-	}
-}
-
-/**
- * @}
- */
Index: uspace/srv/bd/ata_bd/ata_bd.c
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/bd/ata_bd/ata_bd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -229,5 +229,5 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t method;
+	sysarg_t method;
 	devmap_handle_t dh;
 	int flags;
@@ -269,5 +269,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		method = IPC_GET_METHOD(call);
+		method = IPC_GET_IMETHOD(call);
 		switch (method) {
 		case IPC_M_PHONE_HUNGUP:
Index: uspace/srv/bd/file_bd/file_bd.c
===================================================================
--- uspace/srv/bd/file_bd/file_bd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/bd/file_bd/file_bd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -177,5 +177,5 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t method;
+	sysarg_t method;
 	size_t comm_size;
 	int flags;
@@ -202,5 +202,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		method = IPC_GET_METHOD(call);
+		method = IPC_GET_IMETHOD(call);
 		switch (method) {
 		case IPC_M_PHONE_HUNGUP:
Index: uspace/srv/bd/gxe_bd/gxe_bd.c
===================================================================
--- uspace/srv/bd/gxe_bd/gxe_bd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/bd/gxe_bd/gxe_bd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -160,5 +160,5 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t method;
+	sysarg_t method;
 	devmap_handle_t dh;
 	int flags;
@@ -205,5 +205,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		method = IPC_GET_METHOD(call);
+		method = IPC_GET_IMETHOD(call);
 		switch (method) {
 		case IPC_M_PHONE_HUNGUP:
Index: uspace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/bd/part/guid_part/guid_part.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -315,5 +315,5 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t method;
+	sysarg_t method;
 	devmap_handle_t dh;
 	int flags;
@@ -360,5 +360,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		method = IPC_GET_METHOD(call);
+		method = IPC_GET_IMETHOD(call);
 		switch (method) {
 		case IPC_M_PHONE_HUNGUP:
Index: uspace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/bd/part/mbr_part/mbr_part.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -393,5 +393,5 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t method;
+	sysarg_t method;
 	devmap_handle_t dh;
 	int flags;
@@ -438,5 +438,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		method = IPC_GET_METHOD(call);
+		method = IPC_GET_IMETHOD(call);
 		switch (method) {
 		case IPC_M_PHONE_HUNGUP:
Index: uspace/srv/bd/rd/rd.c
===================================================================
--- uspace/srv/bd/rd/rd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/bd/rd/rd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -124,5 +124,5 @@
 	while (true) {
 		callid = async_get_call(&call);
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			/*
Index: uspace/srv/clip/clip.c
===================================================================
--- uspace/srv/clip/clip.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/clip/clip.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -118,5 +118,5 @@
 		}
 		
-		ipcarg_t retval = async_data_read_finalize(callid, clip_data, size);
+		sysarg_t retval = async_data_read_finalize(callid, clip_data, size);
 		if (retval != EOK) {
 			ipc_answer_0(rid, retval);
@@ -145,5 +145,5 @@
 	
 	fibril_mutex_unlock(&clip_mtx);
-	ipc_answer_2(rid, EOK, (ipcarg_t) size, (ipcarg_t) tag);
+	ipc_answer_2(rid, EOK, (sysarg_t) size, (sysarg_t) tag);
 }
 
@@ -158,5 +158,5 @@
 		ipc_callid_t callid = async_get_call(&call);
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			cont = false;
@@ -183,5 +183,5 @@
 	async_set_client_connection(clip_connection);
 	
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	if (ipc_connect_to_me(PHONE_NS, SERVICE_CLIPBOARD, 0, 0, &phonead) != 0) 
 		return -1;
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/devman/devman.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -506,5 +506,5 @@
  * @param phone		The phone to the driver.
  */
-void set_driver_phone(driver_t *driver, ipcarg_t phone)
+void set_driver_phone(driver_t *driver, sysarg_t phone)
 {
 	fibril_mutex_lock(&driver->driver_mutex);
@@ -700,5 +700,5 @@
 	    node->name);
 	
-	ipcarg_t rc;
+	sysarg_t rc;
 	ipc_call_t answer;
 	
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/devman/devman.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -86,5 +86,5 @@
 	
 	/** Phone asociated with this driver. */
-	ipcarg_t phone;
+	sysarg_t phone;
 	/** Name of the device driver. */
 	char *name;
@@ -302,5 +302,5 @@
 
 extern driver_t *find_driver(driver_list_t *, const char *);
-extern void set_driver_phone(driver_t *, ipcarg_t);
+extern void set_driver_phone(driver_t *, sysarg_t);
 extern void initialize_running_driver(driver_t *, dev_tree_t *);
 
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/devman/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -74,5 +74,5 @@
 	
 	iid = async_get_call(&icall);
-	if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) {
+	if (IPC_GET_IMETHOD(icall) != DEVMAN_DRIVER_REGISTER) {
 		ipc_answer_0(iid, EREFUSED);
 		return NULL;
@@ -109,5 +109,5 @@
 	ipc_call_t call;
 	ipc_callid_t callid = async_get_call(&call);
-	if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
+	if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
 		ipc_answer_0(callid, ENOTSUP);
 		ipc_answer_0(iid, ENOTSUP);
@@ -141,5 +141,5 @@
 	
 	callid = async_get_call(&call);
-	if (DEVMAN_ADD_MATCH_ID != IPC_GET_METHOD(call)) {
+	if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
 		printf(NAME ": ERROR: devman_receive_match_id - invalid "
 		    "protocol.\n");
@@ -184,5 +184,5 @@
  * @return		Zero on success, negative error code otherwise.
  */
-static int devman_receive_match_ids(ipcarg_t match_count,
+static int devman_receive_match_ids(sysarg_t match_count,
     match_id_list_t *match_ids)
 {
@@ -211,5 +211,5 @@
 {
 	devman_handle_t parent_handle = IPC_GET_ARG1(*call);
-	ipcarg_t match_count = IPC_GET_ARG2(*call);
+	sysarg_t match_count = IPC_GET_ARG2(*call);
 	dev_tree_t *tree = &device_tree;
 	
@@ -367,5 +367,5 @@
 		callid = async_get_call(&call);
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			cont = false;
@@ -420,5 +420,5 @@
 		ipc_callid_t callid = async_get_call(&call);
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			cont = false;
@@ -486,5 +486,5 @@
 static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
 {
-	devmap_handle_t devmap_handle = IPC_GET_METHOD(*icall);
+	devmap_handle_t devmap_handle = IPC_GET_IMETHOD(*icall);
 	node_t *dev;
 
@@ -521,5 +521,5 @@
 	 * passes device handle to the driver as an ipc method.)
 	 */
-	if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)
+	if (IPC_GET_IMETHOD(*icall) != IPC_M_CONNECT_ME_TO)
 		devman_connection_devmapper(iid, icall);
 
@@ -531,5 +531,5 @@
 	
 	/* Select interface. */
-	switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
+	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
 	case DEVMAN_DRIVER:
 		devman_connection_driver(iid, icall);
@@ -599,5 +599,5 @@
 
 	/* Register device manager at naming service. */
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, &phonead) != 0)
 		return -1;
Index: uspace/srv/devmap/devmap.c
===================================================================
--- uspace/srv/devmap/devmap.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/devmap/devmap.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -61,5 +61,5 @@
 	link_t devices;
 	/** Phone asociated with this driver */
-	ipcarg_t phone;
+	sysarg_t phone;
 	/** Device driver name */
 	char *name;
@@ -387,5 +387,5 @@
 	ipc_callid_t iid = async_get_call(&icall);
 	
-	if (IPC_GET_METHOD(icall) != DEVMAP_DRIVER_REGISTER) {
+	if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) {
 		ipc_answer_0(iid, EREFUSED);
 		return NULL;
@@ -416,5 +416,5 @@
 	ipc_callid_t callid = async_get_call(&call);
 	
-	if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
+	if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
 		free(driver->name);
 		free(driver);
@@ -823,5 +823,5 @@
 	}
 	
-	ipcarg_t retval = async_data_read_finalize(callid, desc, size);
+	sysarg_t retval = async_data_read_finalize(callid, desc, size);
 	
 	free(desc);
@@ -890,5 +890,5 @@
 	}
 	
-	ipcarg_t retval = async_data_read_finalize(callid, desc, size);
+	sysarg_t retval = async_data_read_finalize(callid, desc, size);
 	
 	free(desc);
@@ -964,10 +964,10 @@
 	fibril_mutex_unlock(&null_devices_mutex);
 	
-	ipc_answer_1(iid, EOK, (ipcarg_t) i);
+	ipc_answer_1(iid, EOK, (sysarg_t) i);
 }
 
 static void devmap_null_destroy(ipc_callid_t iid, ipc_call_t *icall)
 {
-	ipcarg_t i = IPC_GET_ARG1(*icall);
+	sysarg_t i = IPC_GET_ARG1(*icall);
 	if (i >= NULL_DEVICES) {
 		ipc_answer_0(iid, ELIMIT);
@@ -1027,5 +1027,5 @@
 		ipc_callid_t callid = async_get_call(&call);
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			cont = false;
@@ -1078,5 +1078,5 @@
 		ipc_callid_t callid = async_get_call(&call);
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			cont = false;
@@ -1121,5 +1121,5 @@
 {
 	/* Select interface */
-	switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
+	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
 	case DEVMAP_DRIVER:
 		devmap_connection_driver(iid, icall);
@@ -1154,5 +1154,5 @@
 	
 	/* Register device mapper at naming service */
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0) 
 		return -1;
Index: uspace/srv/fs/devfs/devfs.c
===================================================================
--- uspace/srv/fs/devfs/devfs.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/fs/devfs/devfs.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -68,5 +68,5 @@
 		ipc_callid_t callid = async_get_call(&call);
 		
-		switch  (IPC_GET_METHOD(call)) {
+		switch  (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			return;
Index: uspace/srv/fs/devfs/devfs_ops.c
===================================================================
--- uspace/srv/fs/devfs/devfs_ops.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/fs/devfs/devfs_ops.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -420,5 +420,5 @@
 	
 	/* Accept the mount options */
-	ipcarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0,
+	sysarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0,
 	    0, NULL);
 	if (retval != EOK) {
@@ -575,5 +575,5 @@
 		/* Make a request at the driver */
 		ipc_call_t answer;
-		aid_t msg = async_send_3(dev->phone, IPC_GET_METHOD(*request),
+		aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request),
 		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
 		    IPC_GET_ARG3(*request), &answer);
@@ -584,5 +584,5 @@
 		
 		/* Wait for reply from the driver. */
-		ipcarg_t rc;
+		sysarg_t rc;
 		async_wait_for(msg, &rc);
 		size_t bytes = IPC_GET_ARG1(answer);
@@ -638,5 +638,5 @@
 		/* Make a request at the driver */
 		ipc_call_t answer;
-		aid_t msg = async_send_3(dev->phone, IPC_GET_METHOD(*request),
+		aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request),
 		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
 		    IPC_GET_ARG3(*request), &answer);
@@ -648,5 +648,5 @@
 		
 		/* Wait for reply from the driver. */
-		ipcarg_t rc;
+		sysarg_t rc;
 		async_wait_for(msg, &rc);
 		size_t bytes = IPC_GET_ARG1(answer);
@@ -746,5 +746,5 @@
 		/* Make a request at the driver */
 		ipc_call_t answer;
-		aid_t msg = async_send_2(dev->phone, IPC_GET_METHOD(*request),
+		aid_t msg = async_send_2(dev->phone, IPC_GET_IMETHOD(*request),
 		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);
 		
@@ -752,5 +752,5 @@
 		
 		/* Wait for reply from the driver */
-		ipcarg_t rc;
+		sysarg_t rc;
 		async_wait_for(msg, &rc);
 		
Index: uspace/srv/fs/fat/fat.c
===================================================================
--- uspace/srv/fs/fat/fat.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/fs/fat/fat.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -93,5 +93,5 @@
 	
 		callid = async_get_call(&call);
-		switch  (IPC_GET_METHOD(call)) {
+		switch  (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			return;
Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/fs/fat/fat_ops.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -1257,5 +1257,5 @@
 
 	rc = fat_node_put(fn);
-	ipc_answer_1(rid, rc, (ipcarg_t)bytes);
+	ipc_answer_1(rid, rc, (sysarg_t)bytes);
 }
 
Index: uspace/srv/fs/tmpfs/tmpfs.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/fs/tmpfs/tmpfs.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -99,5 +99,5 @@
 	
 		callid = async_get_call(&call);
-		switch  (IPC_GET_METHOD(call)) {
+		switch  (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			return;
Index: uspace/srv/hid/adb_mouse/adb_dev.c
===================================================================
--- uspace/srv/hid/adb_mouse/adb_dev.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/adb_mouse/adb_dev.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -68,5 +68,5 @@
 
 	/* NB: The callback connection is slotted for removal */
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
 		printf(NAME ": Failed to create callback from device\n");
@@ -89,5 +89,5 @@
 		int retval;
 
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			/* TODO: Handle hangup */
Index: uspace/srv/hid/adb_mouse/adb_mouse.c
===================================================================
--- uspace/srv/hid/adb_mouse/adb_mouse.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/adb_mouse/adb_mouse.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -102,5 +102,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			if (client_phone != -1) {
Index: uspace/srv/hid/char_mouse/char_mouse.c
===================================================================
--- uspace/srv/hid/char_mouse/char_mouse.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/char_mouse/char_mouse.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -87,5 +87,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			if (client_phone != -1) {
Index: uspace/srv/hid/char_mouse/chardev.c
===================================================================
--- uspace/srv/hid/char_mouse/chardev.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/char_mouse/chardev.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -70,5 +70,5 @@
 
 	/* NB: The callback connection is slotted for removal */
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
 		printf(NAME ": Failed to create callback from device\n");
@@ -104,5 +104,5 @@
 		int retval;
 
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			/* TODO: Handle hangup */
Index: uspace/srv/hid/console/console.c
===================================================================
--- uspace/srv/hid/console/console.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/console/console.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -74,7 +74,7 @@
 struct {
 	int phone;           /**< Framebuffer phone */
-	ipcarg_t cols;       /**< Framebuffer columns */
-	ipcarg_t rows;       /**< Framebuffer rows */
-	ipcarg_t color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
+	sysarg_t cols;       /**< Framebuffer columns */
+	sysarg_t rows;       /**< Framebuffer rows */
+	sysarg_t color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
 } fb_info;
 
@@ -101,7 +101,7 @@
 /** Information on row-span yet unsent to FB driver. */
 struct {
-	ipcarg_t col;  /**< Leftmost column of the span. */
-	ipcarg_t row;  /**< Row where the span lies. */
-	ipcarg_t cnt;  /**< Width of the span. */
+	sysarg_t col;  /**< Leftmost column of the span. */
+	sysarg_t row;  /**< Row where the span lies. */
+	sysarg_t cnt;  /**< Width of the span. */
 } fb_pending;
 
@@ -119,5 +119,5 @@
 }
 
-static void curs_goto(ipcarg_t x, ipcarg_t y)
+static void curs_goto(sysarg_t x, sysarg_t y)
 {
 	async_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y);
@@ -180,5 +180,5 @@
 }
 
-static int ccap_fb_to_con(ipcarg_t ccap_fb, ipcarg_t *ccap_con)
+static int ccap_fb_to_con(sysarg_t ccap_fb, sysarg_t *ccap_con)
 {
 	switch (ccap_fb) {
@@ -203,9 +203,9 @@
 
 /** Send an area of screenbuffer to the FB driver. */
-static void fb_update_area(console_t *cons, ipcarg_t x0, ipcarg_t y0, ipcarg_t width, ipcarg_t height)
+static void fb_update_area(console_t *cons, sysarg_t x0, sysarg_t y0, sysarg_t width, sysarg_t height)
 {
 	if (interbuffer) {
-		ipcarg_t x;
-		ipcarg_t y;
+		sysarg_t x;
+		sysarg_t y;
 		
 		for (y = 0; y < height; y++) {
@@ -237,5 +237,5 @@
  *
  */
-static void cell_mark_changed(ipcarg_t col, ipcarg_t row)
+static void cell_mark_changed(sysarg_t col, sysarg_t row)
 {
 	if (fb_pending.cnt != 0) {
@@ -255,5 +255,5 @@
 
 /** Print a character to the active VC with buffering. */
-static void fb_putchar(wchar_t c, ipcarg_t col, ipcarg_t row)
+static void fb_putchar(wchar_t c, sysarg_t col, sysarg_t row)
 {
 	async_msg_3(fb_info.phone, FB_PUTCHAR, c, col, row);
@@ -352,6 +352,6 @@
 		curs_visibility(false);
 		
-		ipcarg_t x;
-		ipcarg_t y;
+		sysarg_t x;
+		sysarg_t y;
 		int rc = 0;
 		
@@ -408,5 +408,5 @@
 		console_event_t ev;
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			/* TODO: Handle hangup */
@@ -451,5 +451,5 @@
 		int retval;
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			/* TODO: Handle hangup */
@@ -584,7 +584,7 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t arg1;
-	ipcarg_t arg2;
-	ipcarg_t arg3;
+	sysarg_t arg1;
+	sysarg_t arg2;
+	sysarg_t arg3;
 	
 	int rc;
@@ -608,5 +608,5 @@
 		arg3 = 0;
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			cons->refcount--;
@@ -726,5 +726,5 @@
 	
 	/* NB: The callback connection is slotted for removal */
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
 		printf(NAME ": Failed to create callback from input device\n");
Index: uspace/srv/hid/console/gcons.c
===================================================================
--- uspace/srv/hid/console/gcons.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/console/gcons.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -82,6 +82,6 @@
 
 static bool use_gcons = false;
-static ipcarg_t xres;
-static ipcarg_t yres;
+static sysarg_t xres;
+static sysarg_t yres;
 
 enum butstate {
@@ -107,10 +107,10 @@
 static size_t active_console = 0;
 
-static ipcarg_t mouse_x = 0;
-static ipcarg_t mouse_y= 0;
+static sysarg_t mouse_x = 0;
+static sysarg_t mouse_y= 0;
 
 static bool btn_pressed = false;
-static ipcarg_t btn_x = 0;
-static ipcarg_t btn_y = 0;
+static sysarg_t btn_x = 0;
+static sysarg_t btn_y = 0;
 
 static void vp_switch(int vp)
@@ -120,5 +120,5 @@
 
 /** Create view port */
-static int vp_create(ipcarg_t x, ipcarg_t y, ipcarg_t width, ipcarg_t height)
+static int vp_create(sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
 {
 	return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
@@ -137,5 +137,5 @@
 
 /** Transparent putchar */
-static void tran_putch(wchar_t ch, ipcarg_t col, ipcarg_t row)
+static void tran_putch(wchar_t ch, sysarg_t col, sysarg_t row)
 {
 	async_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
@@ -297,7 +297,7 @@
 }
 
-static int gcons_find_conbut(ipcarg_t x, ipcarg_t y)
-{
-	ipcarg_t status_start = STATUS_START + (xres - 800) / 2;
+static int gcons_find_conbut(sysarg_t x, sysarg_t y)
+{
+	sysarg_t status_start = STATUS_START + (xres - 800) / 2;
 	
 	if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT))
@@ -313,5 +313,5 @@
 		return -1;
 	
-	ipcarg_t btn = (x - status_start) / (STATUS_WIDTH + STATUS_SPACE);
+	sysarg_t btn = (x - status_start) / (STATUS_WIDTH + STATUS_SPACE);
 	
 	if (btn < CONSOLE_COUNT)
@@ -363,5 +363,5 @@
  *
  */
-static void draw_pixmap(char *logo, size_t size, ipcarg_t x, ipcarg_t y)
+static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y)
 {
 	/* Create area */
@@ -374,5 +374,5 @@
 	
 	/* Send area */
-	int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
+	int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
 	if (rc)
 		goto exit;
@@ -436,5 +436,5 @@
 	
 	/* Send area */
-	int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
+	int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
 	if (rc)
 		goto exit;
@@ -513,5 +513,5 @@
 	
 	/* Create status buttons */
-	ipcarg_t status_start = STATUS_START + (xres - 800) / 2;
+	sysarg_t status_start = STATUS_START + (xres - 800) / 2;
 	size_t i;
 	for (i = 0; i < CONSOLE_COUNT; i++) {
Index: uspace/srv/hid/fb/ega.c
===================================================================
--- uspace/srv/hid/fb/ega.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/fb/ega.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -230,5 +230,5 @@
 static int save_screen(void)
 {
-	ipcarg_t i;
+	sysarg_t i;
 	
 	/* Find empty screen */
@@ -245,5 +245,5 @@
 }
 
-static int print_screen(ipcarg_t i)
+static int print_screen(sysarg_t i)
 {
 	if ((i >= MAX_SAVED_SCREENS) || (saved_screens[i].data))
@@ -276,8 +276,8 @@
 		wchar_t c;
 		
-		ipcarg_t col;
-		ipcarg_t row;
-		ipcarg_t w;
-		ipcarg_t h;
+		sysarg_t col;
+		sysarg_t row;
+		sysarg_t w;
+		sysarg_t h;
 		
 		ssize_t rows;
@@ -290,8 +290,8 @@
 		uint32_t bg_rgb;
 		
-		ipcarg_t scr;
+		sysarg_t scr;
 		int retval;
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			client_connected = 0;
@@ -370,10 +370,10 @@
 			
 			if (rows >= 0) {
-				if ((ipcarg_t) rows > scr_height) {
+				if ((sysarg_t) rows > scr_height) {
 					retval = EINVAL;
 					break;
 				}
 			} else {
-				if ((ipcarg_t) (-rows) > scr_height) {
+				if ((sysarg_t) (-rows) > scr_height) {
 					retval = EINVAL;
 					break;
Index: uspace/srv/hid/fb/fb.c
===================================================================
--- uspace/srv/hid/fb/fb.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/fb/fb.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -199,9 +199,9 @@
 static int rgb_from_attr(attr_rgb_t *rgb, const attrs_t *a);
 static int rgb_from_style(attr_rgb_t *rgb, int style);
-static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color,
-    ipcarg_t bg_color, ipcarg_t flags);
-
-static int fb_set_color(viewport_t *vport, ipcarg_t fg_color,
-    ipcarg_t bg_color, ipcarg_t attr);
+static int rgb_from_idx(attr_rgb_t *rgb, sysarg_t fg_color,
+    sysarg_t bg_color, sysarg_t flags);
+
+static int fb_set_color(viewport_t *vport, sysarg_t fg_color,
+    sysarg_t bg_color, sysarg_t attr);
 
 static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor,
@@ -1072,5 +1072,5 @@
 	
 	static unsigned char *shm = NULL;
-	static ipcarg_t shm_id = 0;
+	static sysarg_t shm_id = 0;
 	static size_t shm_size;
 	
@@ -1083,5 +1083,5 @@
 	unsigned int h;
 	
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_SHARE_OUT:
 		/* We accept one area for data interchange */
@@ -1360,5 +1360,5 @@
 	int newval;
 	
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case FB_ANIM_CREATE:
 		nvp = IPC_GET_ARG1(*call);
@@ -1435,5 +1435,5 @@
 			break;
 		}
-		newval = (IPC_GET_METHOD(*call) == FB_ANIM_START);
+		newval = (IPC_GET_IMETHOD(*call) == FB_ANIM_START);
 		if (newval ^ animations[i].enabled) {
 			animations[i].enabled = newval;
@@ -1459,5 +1459,5 @@
 	int i, nvp;
 	
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case FB_VP_DRAW_PIXMAP:
 		nvp = IPC_GET_ARG1(*call);
@@ -1529,6 +1529,6 @@
 }
 
-static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color,
-    ipcarg_t bg_color, ipcarg_t flags)
+static int rgb_from_idx(attr_rgb_t *rgb, sysarg_t fg_color,
+    sysarg_t bg_color, sysarg_t flags)
 {
 	fg_color = (fg_color & 7) | ((flags & CATTR_BRIGHT) ? 8 : 0);
@@ -1562,11 +1562,11 @@
 }
 
-static int fb_set_style(viewport_t *vport, ipcarg_t style)
+static int fb_set_style(viewport_t *vport, sysarg_t style)
 {
 	return rgb_from_style(&vport->attr, (int) style);
 }
 
-static int fb_set_color(viewport_t *vport, ipcarg_t fg_color,
-    ipcarg_t bg_color, ipcarg_t flags)
+static int fb_set_color(viewport_t *vport, sysarg_t fg_color,
+    sysarg_t bg_color, sysarg_t flags)
 {
 	return rgb_from_idx(&vport->attr, fg_color, bg_color, flags);
@@ -1621,5 +1621,5 @@
 			continue;
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			client_connected = false;
Index: uspace/srv/hid/fb/main.c
===================================================================
--- uspace/srv/hid/fb/main.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/fb/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -114,5 +114,5 @@
 		return -1;
 	
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, &phonead) != 0) 
 		return -1;
Index: uspace/srv/hid/fb/serial_console.c
===================================================================
--- uspace/srv/hid/fb/serial_console.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/fb/serial_console.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -55,12 +55,12 @@
 #define MAX_CONTROL 20
 
-static ipcarg_t scr_width;
-static ipcarg_t scr_height;
+static sysarg_t scr_width;
+static sysarg_t scr_height;
 static bool color = true;    /**< True if producing color output. */
 static bool utf8 = false;    /**< True if producing UTF8 output. */
 static putc_function_t putc_function;
 
-static ipcarg_t lastcol = 0;
-static ipcarg_t lastrow = 0;
+static sysarg_t lastcol = 0;
+static sysarg_t lastrow = 0;
 static attrs_t cur_attr = {
 	.t = at_style,
@@ -130,5 +130,5 @@
 }
 
-void serial_goto(const ipcarg_t col, const ipcarg_t row)
+void serial_goto(const sysarg_t col, const sysarg_t row)
 {
 	if ((col > scr_width) || (row > scr_height))
@@ -252,5 +252,5 @@
 
 /** Set scrolling region. */
-void serial_set_scroll_region(ipcarg_t last_row)
+void serial_set_scroll_region(sysarg_t last_row)
 {
 	char control[MAX_CONTROL];
@@ -269,5 +269,5 @@
 }
 
-void serial_console_init(putc_function_t putc_fn, ipcarg_t w, ipcarg_t h)
+void serial_console_init(putc_function_t putc_fn, sysarg_t w, sysarg_t h)
 {
 	scr_width = w;
@@ -286,15 +286,15 @@
  *
  */
-static void draw_text_data(keyfield_t *data, ipcarg_t x0, ipcarg_t y0,
-    ipcarg_t width, ipcarg_t height)
+static void draw_text_data(keyfield_t *data, sysarg_t x0, sysarg_t y0,
+    sysarg_t width, sysarg_t height)
 {
 	attrs_t *a0 = &data[0].attrs;
 	serial_set_attrs(a0);
 	
-	ipcarg_t y;
+	sysarg_t y;
 	for (y = 0; y < height; y++) {
 		serial_goto(x0, y0 + y);
 		
-		ipcarg_t x;
+		sysarg_t x;
 		for (x = 0; x < width; x++) {
 			attrs_t *attr = &data[y * width + x].attrs;
@@ -337,13 +337,13 @@
 		
 		wchar_t c;
-		ipcarg_t col;
-		ipcarg_t row;
-		ipcarg_t w;
-		ipcarg_t h;
+		sysarg_t col;
+		sysarg_t row;
+		sysarg_t w;
+		sysarg_t h;
 		ssize_t rows;
 		
 		int retval;
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			client_connected = 0;
@@ -442,10 +442,10 @@
 			
 			if (rows >= 0) {
-				if ((ipcarg_t) rows > scr_height) {
+				if ((sysarg_t) rows > scr_height) {
 					retval = EINVAL;
 					break;
 				}
 			} else {
-				if ((ipcarg_t) (-rows) > scr_height) {
+				if ((sysarg_t) (-rows) > scr_height) {
 					retval = EINVAL;
 					break;
Index: uspace/srv/hid/fb/serial_console.h
===================================================================
--- uspace/srv/hid/fb/serial_console.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/fb/serial_console.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -44,11 +44,11 @@
 
 extern void serial_puts(const char *);
-extern void serial_goto(const ipcarg_t, const ipcarg_t);
+extern void serial_goto(const sysarg_t, const sysarg_t);
 extern void serial_clrscr(void);
 extern void serial_scroll(ssize_t);
 extern void serial_cursor_disable(void);
 extern void serial_cursor_enable(void);
-extern void serial_set_scroll_region(ipcarg_t);
-extern void serial_console_init(putc_function_t, ipcarg_t, ipcarg_t);
+extern void serial_set_scroll_region(sysarg_t);
+extern void serial_console_init(putc_function_t, sysarg_t, sysarg_t);
 extern void serial_client_connection(ipc_callid_t, ipc_call_t *);
 
Index: uspace/srv/hid/kbd/generic/kbd.c
===================================================================
--- uspace/srv/hid/kbd/generic/kbd.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/kbd/generic/kbd.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -177,5 +177,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			if (client_phone != -1) {
Index: uspace/srv/hid/kbd/port/adb.c
===================================================================
--- uspace/srv/hid/kbd/port/adb.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/kbd/port/adb.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -71,5 +71,5 @@
 
 	/* NB: The callback connection is slotted for removal */
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
 		printf(NAME ": Failed to create callback from device\n");
@@ -105,5 +105,5 @@
 		int retval;
 
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			/* TODO: Handle hangup */
Index: uspace/srv/hid/kbd/port/chardev.c
===================================================================
--- uspace/srv/hid/kbd/port/chardev.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/kbd/port/chardev.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -91,5 +91,5 @@
 
 	/* NB: The callback connection is slotted for removal */
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	if (ipc_connect_to_me(dev_phone, 0, 0, 0, &phonehash) != 0) {
 		printf(NAME ": Failed to create callback from device\n");
@@ -125,5 +125,5 @@
 		int retval;
 
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			/* TODO: Handle hangup */
Index: uspace/srv/hid/kbd/port/ns16550.c
===================================================================
--- uspace/srv/hid/kbd/port/ns16550.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/kbd/port/ns16550.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -123,5 +123,5 @@
 	if (cir_service)
 		async_msg_1(cir_phone, BUS_CLEAR_INTERRUPT,
-		    IPC_GET_METHOD(*call));
+		    IPC_GET_IMETHOD(*call));
 }
 
Index: uspace/srv/hid/kbd/port/z8530.c
===================================================================
--- uspace/srv/hid/kbd/port/z8530.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/kbd/port/z8530.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -111,5 +111,5 @@
 	if (cir_service)
 		async_msg_1(cir_phone, BUS_CLEAR_INTERRUPT,
-		    IPC_GET_METHOD(*call));
+		    IPC_GET_IMETHOD(*call));
 }
 
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -382,5 +382,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			if (ts->client_phone != -1) {
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -195,5 +195,5 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t method;
+	sysarg_t method;
 	devmap_handle_t dh;
 	int retval;
@@ -220,5 +220,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		method = IPC_GET_METHOD(call);
+		method = IPC_GET_IMETHOD(call);
 		switch (method) {
 		case IPC_M_PHONE_HUNGUP:
Index: uspace/srv/hw/char/i8042/i8042.c
===================================================================
--- uspace/srv/hw/char/i8042/i8042.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hw/char/i8042/i8042.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -219,5 +219,5 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t method;
+	sysarg_t method;
 	devmap_handle_t dh;
 	int retval;
@@ -248,5 +248,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		method = IPC_GET_METHOD(call);
+		method = IPC_GET_IMETHOD(call);
 		switch (method) {
 		case IPC_M_PHONE_HUNGUP:
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -116,5 +116,5 @@
 	ipc_callid_t callid;
 	ipc_call_t call;
-	ipcarg_t method;
+	sysarg_t method;
 	int retval;
 
@@ -124,5 +124,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-		method = IPC_GET_METHOD(call);
+		method = IPC_GET_IMETHOD(call);
 		switch (method) {
 		case IPC_M_PHONE_HUNGUP:
Index: uspace/srv/hw/cir/fhc/fhc.c
===================================================================
--- uspace/srv/hw/cir/fhc/fhc.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hw/cir/fhc/fhc.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -82,5 +82,5 @@
 	
 		callid = async_get_call(&call);
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case BUS_CLEAR_INTERRUPT:
 			inr = IPC_GET_ARG1(call);
@@ -133,5 +133,5 @@
 	
 	async_set_client_connection(fhc_connection);
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, &phonead);
 	
Index: uspace/srv/hw/cir/obio/obio.c
===================================================================
--- uspace/srv/hw/cir/obio/obio.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hw/cir/obio/obio.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -92,5 +92,5 @@
 	
 		callid = async_get_call(&call);
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case BUS_CLEAR_INTERRUPT:
 			inr = IPC_GET_ARG1(call);
@@ -134,5 +134,5 @@
 	
 	async_set_client_connection(obio_connection);
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, &phonead);
 	
Index: uspace/srv/hw/netif/dp8390/dp8390_module.c
===================================================================
--- uspace/srv/hw/netif/dp8390/dp8390_module.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/hw/netif/dp8390/dp8390_module.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -63,5 +63,5 @@
  *  @param[in] call The interrupt call.
  */
-#define IRQ_GET_DEVICE(call)			(device_id_t) IPC_GET_METHOD(*call)
+#define IRQ_GET_DEVICE(call)			(device_id_t) IPC_GET_IMETHOD(*call)
 
 /** Returns the interrupt status register from the interrupt call.
@@ -306,5 +306,5 @@
 
 int netif_initialize(void){
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 
 	async_set_interrupt_received(irq_handler);
@@ -343,5 +343,5 @@
 		
 		/* End if said to either by the message or the processing result */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
 			return;
 		
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/loader/main.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -383,5 +383,5 @@
 		callid = async_get_call(&call);
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			exit(0);
@@ -411,7 +411,7 @@
 			break;
 		}
-		if (IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) {
+		if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) {
 			DPRINTF("Responding EINVAL to method %d.\n",
-			    IPC_GET_METHOD(call));
+			    IPC_GET_IMETHOD(call));
 			ipc_answer_0(callid, EINVAL);
 		}
@@ -423,5 +423,5 @@
 int main(int argc, char *argv[])
 {
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	task_id_t id;
 	int rc;
Index: uspace/srv/net/il/arp/arp.c
===================================================================
--- uspace/srv/net/il/arp/arp.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/il/arp/arp.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -320,5 +320,5 @@
 		/* Bind the new one */
 		device->phone = nil_bind_service(device->service,
-		    (ipcarg_t) device->device_id, SERVICE_ARP,
+		    (sysarg_t) device->device_id, SERVICE_ARP,
 		    arp_globals.client_connection);
 		if (device->phone < 0) {
@@ -695,5 +695,5 @@
 	
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_PHONE_HUNGUP:
 		return EOK;
@@ -815,5 +815,5 @@
 		 * result.
 		 */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
 		    (res == EHANGUP))
 			return;
Index: uspace/srv/net/il/arp/arp_module.c
===================================================================
--- uspace/srv/net/il/arp/arp_module.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/il/arp/arp_module.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -65,5 +65,5 @@
 int il_module_start_standalone(async_client_conn_t client_connection)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	int rc;
 	
Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/il/ip/ip.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -430,5 +430,5 @@
 	// binds the netif service which also initializes the device
 	ip_netif->phone = nil_bind_service(ip_netif->service,
-	    (ipcarg_t) ip_netif->device_id, SERVICE_IP,
+	    (sysarg_t) ip_netif->device_id, SERVICE_IP,
 	    ip_globals.client_connection);
 	if (ip_netif->phone < 0) {
@@ -1902,5 +1902,5 @@
 	
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_PHONE_HUNGUP:
 		return EOK;
@@ -2025,5 +2025,5 @@
 		 * result.
 		 */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
 		    (res == EHANGUP)) {
 			return;
Index: uspace/srv/net/il/ip/ip_module.c
===================================================================
--- uspace/srv/net/il/ip/ip_module.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/il/ip/ip_module.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -66,5 +66,5 @@
 int il_module_start_standalone(async_client_conn_t client_connection)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	int rc;
 	
Index: uspace/srv/net/net/net.c
===================================================================
--- uspace/srv/net/net/net.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/net/net.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -322,5 +322,5 @@
 static int net_module_start(async_client_conn_t client_connection)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	int rc;
 	
@@ -632,5 +632,5 @@
 	
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_PHONE_HUNGUP:
 		return EOK;
@@ -697,5 +697,5 @@
 		
 		/* End if told to either by the message or the processing result */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
 			return;
 		
Index: uspace/srv/net/netif/lo/lo.c
===================================================================
--- uspace/srv/net/netif/lo/lo.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/netif/lo/lo.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -164,5 +164,5 @@
 int netif_initialize(void)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 
 	return REGISTER_ME(SERVICE_LO, &phonehash);
@@ -262,5 +262,5 @@
 		 * result.
 		 */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
 		    (res == EHANGUP))
 			return;
Index: uspace/srv/net/nil/eth/eth.c
===================================================================
--- uspace/srv/net/nil/eth/eth.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/nil/eth/eth.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -238,5 +238,5 @@
 
 	while (true) {
-		switch (IPC_GET_METHOD(*icall)) {
+		switch (IPC_GET_IMETHOD(*icall)) {
 		case NET_NIL_DEVICE_STATE:
 			nil_device_state_msg_local(0, IPC_GET_DEVICE(icall),
@@ -251,8 +251,8 @@
 				    IPC_GET_DEVICE(icall), packet, 0);
 			}
-			ipc_answer_0(iid, (ipcarg_t) rc);
+			ipc_answer_0(iid, (sysarg_t) rc);
 			break;
 		default:
-			ipc_answer_0(iid, (ipcarg_t) ENOTSUP);
+			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
@@ -849,5 +849,5 @@
 	
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_PHONE_HUNGUP:
 		return EOK;
@@ -926,5 +926,5 @@
 		 * result.
 		 */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
 		    (res == EHANGUP))
 			return;
Index: uspace/srv/net/nil/eth/eth_module.c
===================================================================
--- uspace/srv/net/nil/eth/eth_module.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/nil/eth/eth_module.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -52,5 +52,5 @@
 int nil_module_start_standalone(async_client_conn_t client_connection)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	int rc;
 	
Index: uspace/srv/net/nil/nildummy/nildummy.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/nil/nildummy/nildummy.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -110,9 +110,9 @@
 
 	while (true) {
-		switch (IPC_GET_METHOD(*icall)) {
+		switch (IPC_GET_IMETHOD(*icall)) {
 		case NET_NIL_DEVICE_STATE:
 			rc = nil_device_state_msg_local(0,
 			    IPC_GET_DEVICE(icall), IPC_GET_STATE(icall));
-			ipc_answer_0(iid, (ipcarg_t) rc);
+			ipc_answer_0(iid, (sysarg_t) rc);
 			break;
 		
@@ -124,9 +124,9 @@
 				    IPC_GET_DEVICE(icall), packet, 0);
 			}
-			ipc_answer_0(iid, (ipcarg_t) rc);
+			ipc_answer_0(iid, (sysarg_t) rc);
 			break;
 		
 		default:
-			ipc_answer_0(iid, (ipcarg_t) ENOTSUP);
+			ipc_answer_0(iid, (sysarg_t) ENOTSUP);
 		}
 		
@@ -386,5 +386,5 @@
 	
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case IPC_M_PHONE_HUNGUP:
 		return EOK;
@@ -466,5 +466,5 @@
 		 * result.
 		 */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
 		    (res == EHANGUP))
 			return;
Index: uspace/srv/net/nil/nildummy/nildummy_module.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy_module.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/nil/nildummy/nildummy_module.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -52,5 +52,5 @@
 int nil_module_start_standalone(async_client_conn_t client_connection)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	int rc;
 	
Index: uspace/srv/net/tl/icmp/icmp.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/tl/icmp/icmp.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -693,5 +693,5 @@
 	int rc;
 
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case NET_ICMP_DEST_UNREACH:
 		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
@@ -824,5 +824,5 @@
 
 		/* Process the call */
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			keep_on_going = false;
@@ -900,5 +900,5 @@
 
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case NET_TL_RECEIVED:
 		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
@@ -953,5 +953,5 @@
 		 * result.
 		 */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
 		    (res == EHANGUP))
 			return;
Index: uspace/srv/net/tl/icmp/icmp_module.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_module.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/tl/icmp/icmp_module.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -58,5 +58,5 @@
 int tl_module_start_standalone(async_client_conn_t client_connection)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	int rc;
 
Index: uspace/srv/net/tl/tcp/tcp.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/tl/tcp/tcp.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -829,8 +829,8 @@
 	/* Notify the destination socket */
 	async_msg_5(socket->phone, NET_SOCKET_RECEIVED,
-	    (ipcarg_t) socket->socket_id,
+	    (sysarg_t) socket->socket_id,
 	    ((packet_dimension->content < socket_data->data_fragment_size) ?
 	    packet_dimension->content : socket_data->data_fragment_size), 0, 0,
-	    (ipcarg_t) fragments);
+	    (sysarg_t) fragments);
 
 	return EOK;
@@ -1090,7 +1090,7 @@
 			/* Notify the destination socket */
 			async_msg_5(socket->phone, NET_SOCKET_ACCEPTED,
-			    (ipcarg_t) listening_socket->socket_id,
+			    (sysarg_t) listening_socket->socket_id,
 			    socket_data->data_fragment_size, TCP_HEADER_SIZE,
-			    0, (ipcarg_t) socket->socket_id);
+			    0, (sysarg_t) socket->socket_id);
 
 			fibril_rwlock_write_unlock(socket_data->local_lock);
@@ -1240,5 +1240,5 @@
 
 	*answer_count = 0;
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case NET_TL_RECEIVED:
 //		fibril_rwlock_read_lock(&tcp_globals.lock);
@@ -1323,5 +1323,5 @@
 
 		/* Process the call */
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			keep_on_going = false;
@@ -2481,5 +2481,5 @@
 		 * result.
 		 */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
 		    (res == EHANGUP))
 			return;
Index: uspace/srv/net/tl/tcp/tcp_module.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp_module.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/tl/tcp/tcp_module.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -61,5 +61,5 @@
 int tl_module_start_standalone(async_client_conn_t client_connection)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	int rc;
 
Index: uspace/srv/net/tl/udp/udp.c
===================================================================
--- uspace/srv/net/tl/udp/udp.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/tl/udp/udp.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -393,6 +393,6 @@
 	fibril_rwlock_write_unlock(&udp_globals.lock);
 	async_msg_5(socket->phone, NET_SOCKET_RECEIVED,
-	    (ipcarg_t) socket->socket_id, packet_dimension->content, 0, 0,
-	    (ipcarg_t) fragments);
+	    (sysarg_t) socket->socket_id, packet_dimension->content, 0, 0,
+	    (sysarg_t) fragments);
 
 	return EOK;
@@ -742,5 +742,5 @@
 
 		/* Process the call */
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			keep_on_going = false;
@@ -866,5 +866,5 @@
 	*answer_count = 0;
 
-	switch (IPC_GET_METHOD(*call)) {
+	switch (IPC_GET_IMETHOD(*call)) {
 	case NET_TL_RECEIVED:
 		rc = packet_translate_remote(udp_globals.net_phone, &packet,
@@ -913,5 +913,5 @@
 		 * result.
 		 */
-		if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
 		    (res == EHANGUP))
 			return;
Index: uspace/srv/net/tl/udp/udp_module.c
===================================================================
--- uspace/srv/net/tl/udp/udp_module.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/net/tl/udp/udp_module.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -59,5 +59,5 @@
 int tl_module_start_standalone(async_client_conn_t client_connection)
 {
-	ipcarg_t phonehash;
+	sysarg_t phonehash;
 	int rc;
 
Index: uspace/srv/ns/clonable.c
===================================================================
--- uspace/srv/ns/clonable.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/ns/clonable.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -46,5 +46,5 @@
 typedef struct {
 	link_t link;
-	ipcarg_t service;
+	sysarg_t service;
 	ipc_call_t call;
 	ipc_callid_t callid;
@@ -73,5 +73,5 @@
  *
  */
-void register_clonable(ipcarg_t service, ipcarg_t phone, ipc_call_t *call,
+void register_clonable(sysarg_t service, sysarg_t phone, ipc_call_t *call,
     ipc_callid_t callid)
 {
@@ -107,5 +107,5 @@
  *
  */
-void connect_to_clonable(ipcarg_t service, ipc_call_t *call,
+void connect_to_clonable(sysarg_t service, ipc_call_t *call,
     ipc_callid_t callid)
 {
Index: uspace/srv/ns/clonable.h
===================================================================
--- uspace/srv/ns/clonable.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/ns/clonable.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -40,7 +40,7 @@
 
 extern bool service_clonable(int service);
-extern void register_clonable(ipcarg_t service, ipcarg_t phone,
+extern void register_clonable(sysarg_t service, sysarg_t phone,
     ipc_call_t *call, ipc_callid_t callid);
-extern void connect_to_clonable(ipcarg_t service, ipc_call_t *call,
+extern void connect_to_clonable(sysarg_t service, ipc_call_t *call,
     ipc_callid_t callid);
 
Index: uspace/srv/ns/ns.c
===================================================================
--- uspace/srv/ns/ns.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/ns/ns.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -78,5 +78,5 @@
 	}
 	
-	ipc_answer_2(callid, EOK, (ipcarg_t) *addr, AS_AREA_READ);
+	ipc_answer_2(callid, EOK, (sysarg_t) *addr, AS_AREA_READ);
 }
 
@@ -135,7 +135,7 @@
 		
 		task_id_t id;
-		ipcarg_t retval;
-		
-		switch (IPC_GET_METHOD(call)) {
+		sysarg_t retval;
+		
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_SHARE_IN:
 			switch (IPC_GET_ARG3(call)) {
Index: uspace/srv/ns/service.c
===================================================================
--- uspace/srv/ns/service.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/ns/service.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -43,7 +43,7 @@
 typedef struct {
 	link_t link;
-	ipcarg_t service;        /**< Number of the service. */
-	ipcarg_t phone;          /**< Phone registered with the service. */
-	ipcarg_t in_phone_hash;  /**< Incoming phone hash. */
+	sysarg_t service;        /**< Number of the service. */
+	sysarg_t phone;          /**< Phone registered with the service. */
+	sysarg_t in_phone_hash;  /**< Incoming phone hash. */
 } hashed_service_t;
 
@@ -115,8 +115,8 @@
 typedef struct {
 	link_t link;
-	ipcarg_t service;        /**< Number of the service. */
+	sysarg_t service;        /**< Number of the service. */
 	ipc_callid_t callid;     /**< Call ID waiting for the connection */
-	ipcarg_t arg2;           /**< Second argument */
-	ipcarg_t arg3;           /**< Third argument */
+	sysarg_t arg2;           /**< Second argument */
+	sysarg_t arg3;           /**< Third argument */
 } pending_conn_t;
 
@@ -174,5 +174,5 @@
  *
  */
-int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call)
+int register_service(sysarg_t service, sysarg_t phone, ipc_call_t *call)
 {
 	unsigned long keys[3] = {
@@ -207,7 +207,7 @@
  *
  */
-void connect_to_service(ipcarg_t service, ipc_call_t *call, ipc_callid_t callid)
-{
-	ipcarg_t retval;
+void connect_to_service(sysarg_t service, ipc_call_t *call, ipc_callid_t callid)
+{
+	sysarg_t retval;
 	unsigned long keys[3] = {
 		service,
Index: uspace/srv/ns/service.h
===================================================================
--- uspace/srv/ns/service.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/ns/service.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -39,6 +39,6 @@
 extern void process_pending_conn(void);
 
-extern int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call);
-extern void connect_to_service(ipcarg_t service, ipc_call_t *call,
+extern int register_service(sysarg_t service, sysarg_t phone, ipc_call_t *call);
+extern void connect_to_service(sysarg_t service, ipc_call_t *call,
      ipc_callid_t callid);
 
Index: uspace/srv/ns/task.c
===================================================================
--- uspace/srv/ns/task.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/ns/task.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -45,5 +45,5 @@
 #define P2I_HASH_TABLE_CHAINS  256
 
-static int get_id_by_phone(ipcarg_t phone_hash, task_id_t *id);
+static int get_id_by_phone(sysarg_t phone_hash, task_id_t *id);
 
 /* TODO:
@@ -124,5 +124,5 @@
 typedef struct {
 	link_t link;
-	ipcarg_t phash;    /**< Task ID. */
+	sysarg_t phash;    /**< Task ID. */
 	task_id_t id;    /**< Task ID. */
 } p2i_entry_t;
@@ -248,5 +248,5 @@
 void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid)
 {
-	ipcarg_t retval;
+	sysarg_t retval;
 	task_exit_t texit;
 
@@ -393,5 +393,5 @@
 }
 
-static int get_id_by_phone(ipcarg_t phone_hash, task_id_t *id)
+static int get_id_by_phone(sysarg_t phone_hash, task_id_t *id)
 {
 	unsigned long keys[1];
Index: uspace/srv/vfs/vfs.c
===================================================================
--- uspace/srv/vfs/vfs.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/vfs/vfs.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -73,5 +73,5 @@
 		ipc_callid_t callid = async_get_call(&call);
 		
-		switch (IPC_GET_METHOD(call)) {
+		switch (IPC_GET_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
 			keep_on_going = false;
@@ -173,5 +173,5 @@
 	 * Register at the naming service.
 	 */
-	ipcarg_t phonead;
+	sysarg_t phonead;
 	ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, &phonead);
 	
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/vfs/vfs.h	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -54,5 +54,5 @@
 	fs_handle_t fs_handle;
 	fibril_mutex_t phone_lock;
-	ipcarg_t phone;
+	sysarg_t phone;
 } fs_info_t;
 
Index: uspace/srv/vfs/vfs_lookup.c
===================================================================
--- uspace/srv/vfs/vfs_lookup.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/vfs/vfs_lookup.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -161,10 +161,10 @@
 	ipc_call_t answer;
 	int phone = vfs_grab_phone(root->fs_handle);
-	aid_t req = async_send_5(phone, VFS_OUT_LOOKUP, (ipcarg_t) first,
-	    (ipcarg_t) (first + len - 1) % PLB_SIZE,
-	    (ipcarg_t) root->devmap_handle, (ipcarg_t) lflag, (ipcarg_t) index,
+	aid_t req = async_send_5(phone, VFS_OUT_LOOKUP, (sysarg_t) first,
+	    (sysarg_t) (first + len - 1) % PLB_SIZE,
+	    (sysarg_t) root->devmap_handle, (sysarg_t) lflag, (sysarg_t) index,
 	    &answer);
 	
-	ipcarg_t rc;
+	sysarg_t rc;
 	async_wait_for(req, &rc);
 	vfs_release_phone(root->fs_handle, phone);
@@ -210,8 +210,8 @@
 	ipc_call_t answer;
 	aid_t req = async_send_2(phone, VFS_OUT_OPEN_NODE,
-	    (ipcarg_t) result->triplet.devmap_handle,
-	    (ipcarg_t) result->triplet.index, &answer);
-	
-	ipcarg_t rc;
+	    (sysarg_t) result->triplet.devmap_handle,
+	    (sysarg_t) result->triplet.index, &answer);
+	
+	sysarg_t rc;
 	async_wait_for(req, &rc);
 	vfs_release_phone(result->triplet.fs_handle, phone);
Index: uspace/srv/vfs/vfs_node.c
===================================================================
--- uspace/srv/vfs/vfs_node.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/vfs/vfs_node.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -129,7 +129,7 @@
 		 */
 		int phone = vfs_grab_phone(node->fs_handle);
-		ipcarg_t rc;
+		sysarg_t rc;
 		rc = async_req_2_0(phone, VFS_OUT_DESTROY,
-		    (ipcarg_t)node->devmap_handle, (ipcarg_t)node->index);
+		    (sysarg_t)node->devmap_handle, (sysarg_t)node->index);
 		assert(rc == EOK);
 		vfs_release_phone(node->fs_handle, phone);
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/vfs/vfs_ops.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -79,5 +79,5 @@
 	size_t rsize;
 	unsigned rlnkcnt;
-	ipcarg_t rc;
+	sysarg_t rc;
 	int phone;
 	aid_t msg;
@@ -126,5 +126,5 @@
 			phone = vfs_grab_phone(fs_handle);
 			msg = async_send_1(phone, VFS_OUT_MOUNTED,
-			    (ipcarg_t) devmap_handle, &answer);
+			    (sysarg_t) devmap_handle, &answer);
 			/* send the mount options */
 			rc = async_data_write_start(phone, (void *)opts,
@@ -188,8 +188,8 @@
 	phone = vfs_grab_phone(mp_res.triplet.fs_handle);
 	msg = async_send_4(phone, VFS_OUT_MOUNT,
-	    (ipcarg_t) mp_res.triplet.devmap_handle,
-	    (ipcarg_t) mp_res.triplet.index,
-	    (ipcarg_t) fs_handle,
-	    (ipcarg_t) devmap_handle, &answer);
+	    (sysarg_t) mp_res.triplet.devmap_handle,
+	    (sysarg_t) mp_res.triplet.index,
+	    (sysarg_t) fs_handle,
+	    (sysarg_t) devmap_handle, &answer);
 	
 	/* send connection */
@@ -309,5 +309,5 @@
 	ipc_call_t data;
 	ipc_callid_t callid = async_get_call(&data);
-	if (IPC_GET_METHOD(data) != IPC_M_PING) {
+	if (IPC_GET_IMETHOD(data) != IPC_M_PING) {
 		ipc_answer_0(callid, ENOTSUP);
 		ipc_answer_0(rid, ENOTSUP);
@@ -716,5 +716,5 @@
 
 	/* Wait for reply from the FS server. */
-	ipcarg_t rc;
+	sysarg_t rc;
 	async_wait_for(msg, &rc);
 	
@@ -747,5 +747,5 @@
 		
 		/* Wait for reply from the FS server. */
-		ipcarg_t rc;
+		sysarg_t rc;
 		async_wait_for(msg, &rc);
 		
@@ -839,5 +839,5 @@
 	 * don't have to bother.
 	 */
-	ipcarg_t rc;
+	sysarg_t rc;
 	ipc_call_t answer;
 	if (read) {
@@ -973,10 +973,10 @@
     fs_index_t index, aoff64_t size)
 {
-	ipcarg_t rc;
+	sysarg_t rc;
 	int fs_phone;
 	
 	fs_phone = vfs_grab_phone(fs_handle);
-	rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t) devmap_handle,
-	    (ipcarg_t) index, LOWER32(size), UPPER32(size));
+	rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (sysarg_t) devmap_handle,
+	    (sysarg_t) index, LOWER32(size), UPPER32(size));
 	vfs_release_phone(fs_handle, fs_phone);
 	return (int)rc;
@@ -1005,5 +1005,5 @@
 
 	fibril_mutex_unlock(&file->lock);
-	ipc_answer_0(rid, (ipcarg_t)rc);
+	ipc_answer_0(rid, (sysarg_t)rc);
 }
 
@@ -1011,5 +1011,5 @@
 {
 	int fd = IPC_GET_ARG1(*request);
-	ipcarg_t rc;
+	sysarg_t rc;
 
 	vfs_file_t *file = vfs_file_get(fd);
@@ -1084,5 +1084,5 @@
 	ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
 	
-	ipcarg_t rv;
+	sysarg_t rv;
 	async_wait_for(msg, &rv);
 	vfs_release_phone(node->fs_handle, fs_phone);
Index: uspace/srv/vfs/vfs_register.c
===================================================================
--- uspace/srv/vfs/vfs_register.c	(revision 692f13e4f75dab05af609f6220c92abfd06ba037)
+++ uspace/srv/vfs/vfs_register.c	(revision 82122f3318b0329d89c50e24444e185cd1fe9adb)
@@ -177,6 +177,6 @@
 	ipc_call_t call;
 	ipc_callid_t callid = async_get_call(&call);
-	if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
-		dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
+	if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
+		dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call));
 		list_remove(&fs_info->fs_link);
 		fibril_mutex_unlock(&fs_head_lock);
@@ -197,5 +197,5 @@
 	size_t size;
 	if (!async_share_in_receive(&callid, &size)) {
-		dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
+		dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call));
 		list_remove(&fs_info->fs_link);
 		fibril_mutex_unlock(&fs_head_lock);
@@ -235,5 +235,5 @@
 	 */
 	fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next);
-	ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle);
+	ipc_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle);
 	
 	fibril_condvar_broadcast(&fs_head_cv);
