Index: contrib/arch/kernel/kernel.adl
===================================================================
--- contrib/arch/kernel/kernel.adl	(revision 07fdf2039be8c557cff859a000458feabc41d241)
+++ contrib/arch/kernel/kernel.adl	(revision 07fdf2039be8c557cff859a000458feabc41d241)
@@ -0,0 +1,270 @@
+/*****************************
+ * Kernel syscall interfaces *
+ *****************************/
+
+interface kernel_klog {
+		/* Print using kernel facility */
+		unative_t sys_klog(int fd, const void *buf, size_t size);
+	protocol:
+		sys_klog*
+};
+
+interface kernel_console {
+		/* Enable kernel console */
+		uintptr_t sys_debug_enable_console(void);
+		
+		/* Disable kernel console */
+		uintptr_t sys_debug_disable_console(void);
+	protocol:
+		(sys_debug_enable_console + sys_debug_disable_console)*
+};
+
+interface kernel_tls {
+		/* Set thread-local storage pointer (on architectures where kernel mode is required) */
+		unative_t sys_tls_set(unative_t addr);
+	protocol:
+		sys_tls_set*
+};
+
+interface kernel_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);
+		
+		/* Terminate current thread */
+		unative_t sys_thread_exit(int uspace_status);
+		
+		/* Get current thread id */
+		unative_t sys_thread_get_id(thread_id_t *uspace_thread_id);
+	protocol:
+		(sys_thread_create + sys_thread_get_id)* ; sys_thread_exit
+};
+
+interface kernel_task {
+		/* Set name fo the current task */
+		unative_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);
+	protocol:
+		(sys_task_set_name + sys_task_get_id)*
+};
+
+interface kernel_program {
+		/* Spawn a new instance of clonable loader service */
+		unative_t sys_program_spawn_loader(char *uspace_name, size_t name_len);
+	protocol:
+		sys_program_spawn_loader*
+};
+
+interface kernel_futex {
+		/* Sleep in a futex wait queue */
+		unative_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);
+	protocol:
+		(sys_futex_sleep_timeout + sys_futex_wakeup)*
+};
+
+interface kernel_smc {
+		/* Enforce self-modifying code cache coherency */
+		unative_t sys_smc_coherence(uintptr_t va, size_t size);
+	protocol:
+		sys_smc_coherence*
+};
+
+interface kernel_as {
+		/* Create new address space area */
+		unative_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);
+		
+		/* Change flags of an address space area */
+		unative_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);
+	protocol:
+		(sys_as_area_create + sys_as_area_resize + sys_as_area_change_flags + sys_as_area_destroy)*
+};
+
+interface kernel_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);
+		
+		/* Slow synchronous IPC call */
+		unative_t sys_ipc_call_sync_slow(unative_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);
+		
+		/* Slow asynchronous IPC call */
+		unative_t sys_ipc_call_async_slow(unative_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);
+		
+		/* 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);
+		
+		/* 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);
+		
+		/* Slow answer an IPC call */
+		unative_t sys_ipc_answer_slow(unative_t callid, ipc_data_t *data);
+		
+		/* Hang up a phone */
+		unative_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);
+		
+		/* Interrupt one thread of the current task from waiting on IPC call */
+		unative_t sys_ipc_poke(void);
+	protocol:
+		(sys_ipc_call_sync_fast + sys_ipc_call_sync_slow + sys_ipc_call_async_fast + sys_ipc_call_async_slow + sys_ipc_forward_fast + sys_ipc_forward_slow + sys_ipc_answer_fast + sys_ipc_answer_slow + sys_ipc_hangup + sys_ipc_wait_for_call + sys_ipc_poke)*
+};
+
+interface kernel_event {
+		/* Subscribe to kernel event notifications */
+		unative_t sys_event_subscribe(unative_t evno, unative_t method);
+	protocol:
+		sys_event_subscribe*
+};
+
+interface kernel_cap {
+		/* Grant capabilities to a task */
+		unative_t sys_cap_grant(sysarg64_t *uspace_taskid_arg, cap_t caps);
+		
+		/* Revoke capabilities from a task */
+		unative_t sys_cap_revoke(sysarg64_t *uspace_taskid_arg, cap_t caps);
+	protocol:
+		(sys_cap_grant + sys_cap_rewoke)*
+};
+
+interface kernel_ddi {
+		/* Enable access I/O address space for the current task */
+		unative_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);
+		
+		/* Enable or disable preemption */
+		unative_t sys_preempt_control(int enable);
+		
+		/* Assign unique device number */
+		unative_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);
+		
+		/* Disconnect an IRQ handler from the current task */
+		unative_t sys_ipc_unregister_irq(inr_t inr, devno_t devno);
+	protocol:
+		(sys_enable_iospace + sys_physmem_map + sys_device_assign_devno + sys_preempt_control + sys_ipc_register_irq + sys_ipc_unregister_irq)*
+};
+
+interface kernel_sysinfo {
+		/* Check for sysinfo key validity */
+		unative_t sys_sysinfo_valid(unative_t ptr, unative_t len);
+		
+		/* Get sysinfo key value */
+		unative_t sys_sysinfo_value(unatice_t ptr, unative_t len);
+	protocol:
+		(sys_sysinfo_valid + sys_sysinfo_value)*
+};
+
+interface kernel_debug {
+		/* Connect to the kernel debugging answerbox of a given task */
+		unative_t sys_ipc_connect_kbox(sysarg64_t *uspace_taskid_arg);
+	protocol:
+		sys_ipc_connect_kbox*
+};
+
+
+/*****************************************************
+ * Primitive kernel components (exported subsystems) *
+ *****************************************************/
+
+frame kernel_console {
+	provides:
+		kernel_klog kernel_klog;
+		kernel_console kernel_console;
+};
+
+frame kernel_proc {
+	provides:
+		kernel_tls kernel_tls;
+		kernel_thread kernel_thread;
+		kernel_task kernel_task;
+		kernel_program kernel_program;
+};
+
+frame kernel_synch {
+	provides:
+		kernel_futex kernel_futex;
+		kernel_smc kernel_smc;
+};
+
+frame kernel_mm {
+	provides:
+		kernel_as kernel_as;
+};
+
+frame kernel_ipc {
+	provides:
+		kernel_ipc kernel_ipc;
+		kernel_event kernel_event;
+};
+
+frame kernel_security {
+	provides:
+		kernel_cap kernel_cap;
+};
+
+frame kernel_ddi {
+	provides:
+		kernel_ddi kernel_ddi;
+};
+
+frame kernel_sysinfo {
+	provides:
+		kernel_sysinfo kernel_sysinfo;
+};
+
+frame kernel_debug {
+	provides:
+		kernel_debug kernel_debug;
+};
+
+
+/******************************
+ * Composite kernel component *
+ ******************************/
+
+architecture kernel {
+	inst kernel_console kernel_console;
+	inst kernel_proc kernel_proc;
+	inst kernel_synch kernel_synch;
+	inst kernel_mm kernel_mm;
+	inst kernel_ipc kernel_ipc;
+	inst kernel_security kernel_security;
+	inst kernel_ddi kernel_ddi;
+	inst kernel_sysinfo kernel_sysinfo;
+	inst kernel_debug kernel_debug;
+	
+	delegate kernel_klog to kernel_console:kernel_klog;
+	delegate kernel_console to kernel_console:kernel_console;
+	delegate kernel_tls to kernel_proc:kernel_tls;
+	delegate kernel_thread to kernel_proc:kernel_thread;
+	delegate kernel_task to kernel_proc:kernel_task;
+	delegate kernel_program to kernel_proc:kernel_program;
+	delegate kernel_as to kernel_mm:kernel_as;
+	delegate kernel_ipc to kernel_ipc:kernel_sys;
+	delegate kernel_event to kernel_ipc:kernel_event;
+	delegate kernel_cap to kernel_security:kernel_cap;
+	delegate kernel_ddi to kernel_ddi:kernel_ddi;
+	delegate kernel_sysinfo to kernel_sysinfo:kernel_sysinfo;
+	delegate kernel_debug to kernel_debug:kernel_debug;
+};
