Index: kernel/generic/include/sysinfo/abi.h
===================================================================
--- kernel/generic/include/sysinfo/abi.h	(revision fce3536ed6e901725440a6a9403d237da8f0e39a)
+++ kernel/generic/include/sysinfo/abi.h	(revision 80bfb601d828951693b11892603e3161b6736ea0)
@@ -31,4 +31,5 @@
  */
 /** @file
+ * Data structures passed between kernel sysinfo and user space.
  */
 
@@ -36,39 +37,57 @@
 #define KERN_ABI_H_
 
+/** Number of load components */
 #define LOAD_STEPS        3
+
+/** Maximum task name size */
 #define TASK_NAME_BUFLEN  20
 
+/** Statistics about a single CPU
+ *
+ */
 typedef struct {
-	unsigned int id;
-	uint16_t frequency_mhz;
-	uint64_t idle_ticks;
-	uint64_t busy_ticks;
+	unsigned int id;         /**< CPU ID as stored by kernel */
+	uint16_t frequency_mhz;  /**< Frequency in MHz */
+	uint64_t idle_ticks;     /**< Number of idle kernel quanta */
+	uint64_t busy_ticks;     /**< Number of busy kernel quanta */
 } stats_cpu_t;
 
+/** Physical memory statistics
+ *
+ */
 typedef struct {
-	uint64_t total;
-	uint64_t unavail;
-	uint64_t used;
-	uint64_t free;
+	uint64_t total;    /**< Total physical memory (bytes) */
+	uint64_t unavail;  /**< Unavailable (reserved, firmware) bytes */
+	uint64_t used;     /**< Allocated physical memory (bytes) */
+	uint64_t free;     /**< Free physical memory (bytes) */
 } stats_physmem_t;
 
+/** IPC statistics
+ *
+ * Associated with a task.
+ *
+ */
 typedef struct {
-	uint64_t call_sent;
-	uint64_t call_recieved;
-	uint64_t answer_sent;
-	uint64_t answer_recieved;
-	uint64_t irq_notif_recieved;
-	uint64_t forwarded;
+	uint64_t call_sent;           /**< IPC calls sent */
+	uint64_t call_recieved;       /**< IPC calls received */
+	uint64_t answer_sent;         /**< IPC answers sent */
+	uint64_t answer_recieved;     /**< IPC answers received */
+	uint64_t irq_notif_recieved;  /**< IPC IRQ notifications */
+	uint64_t forwarded;           /**< IPC messages forwarded */
 } stats_ipc_t;
 
+/** Statistics about a single task
+ *
+ */
 typedef struct {
-	char name[TASK_NAME_BUFLEN];
-	size_t virtmem;
-	size_t threads;
-	uint64_t ucycles;
-	uint64_t kcycles;
-	stats_ipc_t ipc_info;
+	char name[TASK_NAME_BUFLEN];  /**< Task name (in kernel) */
+	size_t virtmem;               /**< Size of VAS (bytes) */
+	size_t threads;               /**< Number of threads */
+	uint64_t ucycles;             /**< Number of CPU cycles in user space */
+	uint64_t kcycles;             /**< Number of CPU cycles in kernel */
+	stats_ipc_t ipc_info;         /**< IPC statistics */
 } stats_task_t;
 
+/** Load fixed-point value */
 typedef uint32_t load_t;
 
Index: kernel/generic/include/sysinfo/sysinfo.h
===================================================================
--- kernel/generic/include/sysinfo/sysinfo.h	(revision fce3536ed6e901725440a6a9403d237da8f0e39a)
+++ kernel/generic/include/sysinfo/sysinfo.h	(revision 80bfb601d828951693b11892603e3161b6736ea0)
@@ -39,62 +39,93 @@
 #include <str.h>
 
+/** Framebuffer info exported flags */
 extern bool fb_exported;
 
+/** Item value type
+ *
+ */
 typedef enum {
-	SYSINFO_VAL_UNDEFINED = 0,
-	SYSINFO_VAL_VAL = 1,
-	SYSINFO_VAL_DATA = 2,
-	SYSINFO_VAL_FUNCTION_VAL = 3,
-	SYSINFO_VAL_FUNCTION_DATA = 4
+	SYSINFO_VAL_UNDEFINED = 0,     /**< Undefined value */
+	SYSINFO_VAL_VAL = 1,           /**< Constant numeric value */
+	SYSINFO_VAL_DATA = 2,          /**< Constant binary data */
+	SYSINFO_VAL_FUNCTION_VAL = 3,  /**< Generated numeric value */
+	SYSINFO_VAL_FUNCTION_DATA = 4  /**< Generated binary data */
 } sysinfo_item_val_type_t;
 
+/** Subtree type
+ *
+ */
 typedef enum {
-	SYSINFO_SUBTREE_NONE = 0,
-	SYSINFO_SUBTREE_TABLE = 1,
-	SYSINFO_SUBTREE_FUNCTION = 2
+	SYSINFO_SUBTREE_NONE = 0,     /**< No subtree (leaf item) */
+	SYSINFO_SUBTREE_TABLE = 1,    /**< Fixed subtree */
+	SYSINFO_SUBTREE_FUNCTION = 2  /**< Generated subtree */
 } sysinfo_subtree_type_t;
 
 struct sysinfo_item;
 
+/** Gerated numeric value function */
 typedef unative_t (*sysinfo_fn_val_t)(struct sysinfo_item *);
+
+/** Generated binary data function */
 typedef void *(*sysinfo_fn_data_t)(struct sysinfo_item *, size_t *);
 
+/** Sysinfo item binary data
+ *
+ */
 typedef struct {
-	void *data;
-	size_t size;
+	void *data;   /**< Data */
+	size_t size;  /**< Size (bytes) */
 } sysinfo_data_t;
 
+/** Sysinfo item value (union)
+ *
+ */
 typedef union {
-	unative_t val;
-	sysinfo_fn_val_t fn_val;
-	sysinfo_fn_data_t fn_data;
-	sysinfo_data_t data;
+	unative_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 */
+	sysinfo_data_t data;        /**< Constant binary data */
 } sysinfo_item_val_t;
 
+/** Sysinfo return holder
+ *
+ * This structure is generated from the constant
+ * items or by the generating functions. Note that
+ * the validity of the data is limited by the scope
+ * of single sysinfo invocation guarded by sysinfo_lock.
+ *
+ */
 typedef struct {
-	sysinfo_item_val_type_t tag;
+	sysinfo_item_val_type_t tag;  /**< Return value type */
 	union {
-		unative_t val;
-		sysinfo_data_t data;
+		unative_t val;            /**< Numberic value */
+		sysinfo_data_t data;      /**< Binary data */
 	};
 } sysinfo_return_t;
 
+/** Generated subtree function */
 typedef sysinfo_return_t (*sysinfo_fn_subtree_t)(const char *);
 
+/** Sysinfo subtree (union)
+ *
+ */
 typedef union {
-	struct sysinfo_item *table;
-	sysinfo_fn_subtree_t get_data;
+	struct sysinfo_item *table;     /**< Fixed subtree (list of subitems) */
+	sysinfo_fn_subtree_t get_data;  /**< Generated subtree function */
 } sysinfo_subtree_t;
 
+/** Sysinfo item
+ *
+ */
 typedef struct sysinfo_item {
-	char *name;
+	char *name;                           /**< Item name */
 	
-	sysinfo_item_val_type_t val_type;
-	sysinfo_item_val_t val;
+	sysinfo_item_val_type_t val_type;     /**< Item value type */
+	sysinfo_item_val_t val;               /**< Item value */
 	
-	sysinfo_subtree_type_t subtree_type;
-	sysinfo_subtree_t subtree;
+	sysinfo_subtree_type_t subtree_type;  /**< Subtree type */
+	sysinfo_subtree_t subtree;            /**< Subtree */
 	
-	struct sysinfo_item *next;
+	struct sysinfo_item *next;            /**< Sibling item */
 } sysinfo_item_t;
 
@@ -114,8 +145,8 @@
 extern void sysinfo_dump(sysinfo_item_t *);
 
-unative_t sys_sysinfo_get_tag(void *, size_t);
-unative_t sys_sysinfo_get_value(void *, size_t, void *);
-unative_t sys_sysinfo_get_data_size(void *, size_t, void *);
-unative_t sys_sysinfo_get_data(void *, size_t, void *, size_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);
 
 #endif
Index: kernel/generic/src/sysinfo/stats.c
===================================================================
--- kernel/generic/src/sysinfo/stats.c	(revision fce3536ed6e901725440a6a9403d237da8f0e39a)
+++ kernel/generic/src/sysinfo/stats.c	(revision 80bfb601d828951693b11892603e3161b6736ea0)
@@ -55,6 +55,5 @@
 #define LOAD_INTERVAL  5
 
-/**
- * Fixed-point representation of:
+/** Fixed-point representation of
  *
  * 1 / exp(5 sec / 1 min)
@@ -64,7 +63,18 @@
  */
 static load_t load_exp[LOAD_STEPS] = {1884, 2014, 2037};
+
+/** Running average of the number of ready threads */
 static load_t avenrdy[LOAD_STEPS] = {0, 0, 0};
+
+/** Load calculation spinlock */
 SPINLOCK_STATIC_INITIALIZE_NAME(load_lock, "load_lock");
 
+/** Get system uptime
+ *
+ * @param item Sysinfo item (unused).
+ *
+ * @return System uptime (in secords).
+ *
+ */
 static unative_t get_stats_uptime(struct sysinfo_item *item)
 {
@@ -73,6 +83,16 @@
 }
 
+/** Get statistics of all CPUs
+ *
+ * @param item Sysinfo item (unused).
+ * @param size Size of the returned data.
+ *
+ * @return Data containing several stats_cpu_t structures.
+ *         If the return value is not NULL, it should be freed
+ *         in the context of the sysinfo request.
+ */
 static void *get_stats_cpus(struct sysinfo_item *item, size_t *size)
 {
+	/* Assumption: config.cpu_count is constant */
 	stats_cpu_t *stats_cpus =
 	    (stats_cpu_t *) malloc(sizeof(stats_cpu_t) * config.cpu_count,
@@ -83,4 +103,5 @@
 	}
 	
+	/* Each CPU structure is locked separatelly */
 	ipl_t ipl = interrupts_disable();
 	
@@ -103,4 +124,14 @@
 }
 
+/** Count number of tasks
+ *
+ * AVL task tree walker for counting tasks.
+ *
+ * @param node AVL task tree node (unused).
+ * @param arg  Pointer to the counter.
+ *
+ * @param Always true (continue the walk).
+ *
+ */
 static bool task_count_walker(avltree_node_t *node, void *arg)
 {
@@ -111,4 +142,15 @@
 }
 
+/** Gather tasks
+ *
+ * AVL task tree walker for gathering task IDs. Interrupts should
+ * be already disabled while walking the tree.
+ *
+ * @param node AVL task tree node.
+ * @param arg  Pointer to the iterator into the array of task IDs.
+ *
+ * @param Always true (continue the walk).
+ *
+ */
 static bool task_serialize_walker(avltree_node_t *node, void *arg)
 {
@@ -116,6 +158,8 @@
 	task_t *task = avltree_get_instance(node, task_t, tasks_tree_node);
 	
+	/* Interrupts are already disabled */
 	spinlock_lock(&(task->lock));
 	
+	/* Record the ID and increment the iterator */
 	**ids = task->taskid;
 	(*ids)++;
@@ -126,4 +170,13 @@
 }
 
+/** Get task IDs
+ *
+ * @param item Sysinfo item (unused).
+ * @param size Size of the returned data.
+ *
+ * @return Data containing task IDs of all tasks.
+ *         If the return value is not NULL, it should be freed
+ *         in the context of the sysinfo request.
+ */
 static void *get_stats_tasks(struct sysinfo_item *item, size_t *size)
 {
@@ -132,8 +185,10 @@
 	spinlock_lock(&tasks_lock);
 	
+	/* First walk the task tree to count the tasks */
 	size_t count = 0;
 	avltree_walk(&tasks_tree, task_count_walker, (void *) &count);
 	
 	if (count == 0) {
+		/* No tasks found (strange) */
 		spinlock_unlock(&tasks_lock);
 		interrupts_restore(ipl);
@@ -146,4 +201,5 @@
 	    (task_id_t *) malloc(sizeof(task_id_t) * count, FRAME_ATOMIC);
 	if (task_ids == NULL) {
+		/* No free space for allocation */
 		spinlock_unlock(&tasks_lock);
 		interrupts_restore(ipl);
@@ -153,4 +209,5 @@
 	}
 	
+	/* Walk tha task tree again to gather the IDs */
 	task_id_t *iterator = task_ids;
 	avltree_walk(&tasks_tree, task_serialize_walker, (void *) &iterator);
@@ -163,4 +220,11 @@
 }
 
+/** Get the size of a virtual address space
+ *
+ * @param as Address space.
+ *
+ * @return Size of the mapped virtual address space (bytes).
+ *
+ */
 static size_t get_task_virtmem(as_t *as)
 {
@@ -169,4 +233,5 @@
 	size_t result = 0;
 	
+	/* Walk the B+ tree and count pages */
 	link_t *cur;
 	for (cur = as->as_area_btree.leaf_head.next;
@@ -190,14 +255,32 @@
 }
 
+/** Get task statistics
+ *
+ * Get statistics of a given task. The task ID is passed
+ * as a string (current limitation of the sysinfo interface,
+ * but it is still reasonable for the given purpose).
+ *
+ * @param name Task ID (string-encoded number).
+ *
+ * @return Sysinfo return holder. The type of the returned
+ *         data is either SYSINFO_VAL_UNDEFINED (unknown
+ *         task ID or memory allocation error) or
+ *         SYSINFO_VAL_FUNCTION_DATA (in that case the
+ *         generated data should be freed within the
+ *         sysinfo request context).
+ *
+ */
 static sysinfo_return_t get_stats_task(const char *name)
 {
-	
+	/* Initially no return value */
 	sysinfo_return_t ret;
 	ret.tag = SYSINFO_VAL_UNDEFINED;
 	
+	/* Parse the task ID */
 	task_id_t task_id;
 	if (str_uint64(name, NULL, 0, true, &task_id) != EOK)
 		return ret;
 	
+	/* Allocate stats_task_t structure */
 	stats_task_t *stats_task =
 	    (stats_task_t *) malloc(sizeof(stats_task_t), FRAME_ATOMIC);
@@ -205,4 +288,5 @@
 		return ret;
 	
+	/* Messing with task structures, avoid deadlock */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&tasks_lock);
@@ -210,4 +294,5 @@
 	task_t *task = task_find_by_id(task_id);
 	if (task == NULL) {
+		/* No task with this ID */
 		spinlock_unlock(&tasks_lock);
 		interrupts_restore(ipl);
@@ -216,7 +301,9 @@
 	}
 	
+	/* Hand-over-hand locking */
 	spinlock_lock(&task->lock);
 	spinlock_unlock(&tasks_lock);
 	
+	/* Copy task's statistics */
 	str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name);
 	stats_task->virtmem = get_task_virtmem(task->as);
@@ -229,4 +316,5 @@
 	interrupts_restore(ipl);
 	
+	/* Correct return value */
 	ret.tag = SYSINFO_VAL_FUNCTION_DATA;
 	ret.data.data = (void *) stats_task;
@@ -236,4 +324,13 @@
 }
 
+/** Get physical memory statistics
+ *
+ * @param item Sysinfo item (unused).
+ * @param size Size of the returned data.
+ *
+ * @return Data containing stats_physmem_t.
+ *         If the return value is not NULL, it should be freed
+ *         in the context of the sysinfo request.
+ */
 static void *get_stats_physmem(struct sysinfo_item *item, size_t *size)
 {
@@ -252,4 +349,13 @@
 }
 
+/** Get system load
+ *
+ * @param item Sysinfo item (unused).
+ * @param size Size of the returned data.
+ *
+ * @return Data several load_t values.
+ *         If the return value is not NULL, it should be freed
+ *         in the context of the sysinfo request.
+ */
 static void *get_stats_load(struct sysinfo_item *item, size_t *size)
 {
@@ -261,4 +367,5 @@
 	}
 	
+	/* To always get consistent values acquire the spinlock */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&load_lock);
@@ -324,4 +431,5 @@
 	
 	while (true) {
+		/* Mutually exclude with get_stats_load() */
 		ipl_t ipl = interrupts_disable();
 		spinlock_lock(&load_lock);
@@ -340,4 +448,7 @@
 }
 
+/** Register sysinfo statistical items
+ *
+ */
 void stats_init(void)
 {
Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision fce3536ed6e901725440a6a9403d237da8f0e39a)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision 80bfb601d828951693b11892603e3161b6736ea0)
@@ -41,13 +41,21 @@
 #include <errno.h>
 
+/** Maximal sysinfo path length */
 #define SYSINFO_MAX_PATH  2048
 
 bool fb_exported = false;
 
+/** Global sysinfo tree root item */
 static sysinfo_item_t *global_root = NULL;
+
+/** Sysinfo SLAB cache */
 static slab_cache_t *sysinfo_item_slab;
 
+/** Sysinfo spinlock */
 SPINLOCK_STATIC_INITIALIZE_NAME(sysinfo_lock, "sysinfo_lock");
 
+/** Sysinfo item constructor
+ *
+ */
 static int sysinfo_item_constructor(void *obj, int kmflag)
 {
@@ -63,4 +71,11 @@
 }
 
+/** Sysinfo item destructor
+ *
+ * Note that the return value is not perfectly correct
+ * since more space might get actually freed thanks
+ * to the disposal of item->name
+ *
+ */
 static int sysinfo_item_destructor(void *obj)
 {
@@ -73,4 +88,9 @@
 }
 
+/** Initialize sysinfo subsystem
+ *
+ * Create SLAB cache for sysinfo items.
+ *
+ */
 void sysinfo_init(void)
 {
@@ -80,9 +100,20 @@
 }
 
-/** Recursively find item in sysinfo tree
+/** Recursively find an item in sysinfo tree
  *
  * Should be called with interrupts disabled
  * and sysinfo_lock held.
  *
+ * @param name    Current sysinfo path suffix.
+ * @param subtree Current sysinfo (sub)tree root item.
+ * @param ret     If the return value is NULL, this argument
+ *                can be either also NULL (i.e. no item was
+ *                found and no data was generated) or the
+ *                original pointer is used to store the value
+ *                generated by a generated subtree function.
+ *
+ * @return Found item or NULL if no item in the fixed tree
+ *         was found (N.B. ret).
+ *
  */
 static sysinfo_item_t *sysinfo_find_item(const char *name,
@@ -94,4 +125,5 @@
 	sysinfo_item_t *cur = subtree;
 	
+	/* Walk all siblings */
 	while (cur != NULL) {
 		size_t i = 0;
@@ -118,5 +150,5 @@
 				return NULL;
 			default:
-				/* Not found */
+				/* Not found, no data generated */
 				*ret = NULL;
 				return NULL;
@@ -127,4 +159,5 @@
 	}
 	
+	/* Not found, no data generated */
 	*ret = NULL;
 	return NULL;
@@ -135,4 +168,12 @@
  * Should be called with interrupts disabled
  * and sysinfo_lock held.
+ *
+ * @param name     Current sysinfo path suffix.
+ * @param psubtree Pointer to an already existing (sub)tree root
+ *                 item or where to store a new tree root item.
+ *
+ * @return Existing or newly allocated sysinfo item or NULL
+ *         if the current tree configuration does not allow to
+ *         create a new item.
  *
  */
@@ -172,4 +213,5 @@
 	sysinfo_item_t *cur = *psubtree;
 	
+	/* Walk all siblings */
 	while (cur != NULL) {
 		size_t i = 0;
@@ -199,5 +241,5 @@
 			default:
 				/* Subtree items handled by a function, this
-				 * cannot be overriden.
+				 * cannot be overriden by a constant item.
 				 */
 				return NULL;
@@ -235,5 +277,4 @@
 		}
 		
-		/* Get next sibling */
 		cur = cur->next;
 	}
@@ -244,7 +285,16 @@
 }
 
+/** Set sysinfo item with a constant numeric value
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param val  Value to store in the item.
+ *
+ */
 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root,
     unative_t val)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -263,7 +313,21 @@
 }
 
+/** Set sysinfo item with a constant binary data
+ *
+ * Note that sysinfo only stores the pointer to the
+ * binary data and does not touch it in any way. The
+ * data should be static and immortal.
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param data Binary data.
+ * @param size Size of the binary data.
+ *
+ */
 void sysinfo_set_item_data(const char *name, sysinfo_item_t **root,
     void *data, size_t size)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -283,7 +347,16 @@
 }
 
+/** Set sysinfo item with a generated numeric value
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param fn   Numeric value generator function.
+ *
+ */
 void sysinfo_set_item_fn_val(const char *name, sysinfo_item_t **root,
     sysinfo_fn_val_t fn)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -302,7 +375,21 @@
 }
 
+/** Set sysinfo item with a generated binary data
+ *
+ * Note that each time the generator function is called
+ * it is supposed to return a new dynamically allocated
+ * data. This data is then freed by sysinfo in the context
+ * of the current sysinfo request.
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param fn   Binary data generator function.
+ *
+ */
 void sysinfo_set_item_fn_data(const char *name, sysinfo_item_t **root,
     sysinfo_fn_data_t fn)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -321,6 +408,14 @@
 }
 
+/** Set sysinfo item with an undefined value
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ *
+ */
 void sysinfo_set_item_undefined(const char *name, sysinfo_item_t **root)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -337,7 +432,16 @@
 }
 
+/** Set sysinfo item with a generated subtree
+ *
+ * @param name Sysinfo path.
+ * @param root Pointer to the root item or where to store
+ *             a new root item (NULL for global sysinfo root).
+ * @param fn   Subtree generator function.
+ *
+ */
 void sysinfo_set_subtree_fn(const char *name, sysinfo_item_t **root,
     sysinfo_fn_subtree_t fn)
 {
+	/* Protect sysinfo tree consistency */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -347,4 +451,7 @@
 	
 	sysinfo_item_t *item = sysinfo_create_path(name, root);
+	
+	/* Change the type of the subtree only if it is not already
+	   a fixed subtree */
 	if ((item != NULL) && (item->subtree_type != SYSINFO_SUBTREE_TABLE)) {
 		item->subtree_type = SYSINFO_SUBTREE_FUNCTION;
@@ -357,4 +464,6 @@
 
 /** Sysinfo dump indentation helper routine
+ *
+ * @param depth Number of indentation characters to print.
  *
  */
@@ -374,4 +483,7 @@
  * there is no better simple solution.
  *
+ * @param root  Root item of the current (sub)tree.
+ * @param depth Current depth in the sysinfo tree.
+ *
  */
 static void sysinfo_dump_internal(sysinfo_item_t *root, unsigned int depth)
@@ -379,4 +491,5 @@
 	sysinfo_item_t *cur = root;
 	
+	/* Walk all siblings */
 	while (cur != NULL) {
 		sysinfo_indent(depth);
@@ -386,4 +499,5 @@
 		size_t size;
 		
+		/* Display node value and type */
 		switch (cur->val_type) {
 		case SYSINFO_VAL_UNDEFINED:
@@ -405,4 +519,6 @@
 		case SYSINFO_VAL_FUNCTION_DATA:
 			data = cur->val.fn_data(cur, &size);
+			
+			/* N.B.: The generated binary data should be freed */
 			if (data != NULL)
 				free(data);
@@ -415,4 +531,5 @@
 		}
 		
+		/* Recursivelly nest into the subtree */
 		switch (cur->subtree_type) {
 		case SYSINFO_SUBTREE_NONE:
@@ -434,6 +551,15 @@
 }
 
+/** Dump the structure of sysinfo tree
+ *
+ * @param root  Root item of the sysinfo (sub)tree.
+ *              If it is NULL then consider the global
+ *              sysinfo tree.
+ *
+ */
 void sysinfo_dump(sysinfo_item_t *root)
 {
+	/* Avoid other functions to mess with sysinfo
+	   while we are dumping it */
 	ipl_t ipl = interrupts_disable();
 	spinlock_lock(&sysinfo_lock);
@@ -448,9 +574,16 @@
 }
 
-/** Return sysinfo item determined by name
+/** Return sysinfo item value determined by name
  *
  * Should be called with interrupts disabled
  * and sysinfo_lock held.
  *
+ * @param name Sysinfo path.
+ * @param root Root item of the sysinfo (sub)tree.
+ *             If it is NULL then consider the global
+ *             sysinfo tree.
+ *
+ * @return Item value (constant or generated).
+ *
  */
 static sysinfo_return_t sysinfo_get_item(const char *name, sysinfo_item_t **root)
@@ -459,4 +592,5 @@
 		root = &global_root;
 	
+	/* Try to find the item or generate data */
 	sysinfo_return_t ret;
 	sysinfo_return_t *ret_ptr = &ret;
@@ -464,4 +598,6 @@
 	
 	if (item != NULL) {
+		/* Item found in the fixed sysinfo tree */
+		
 		ret.tag = item->val_type;
 		switch (item->val_type) {
@@ -482,6 +618,9 @@
 		}
 	} else {
-		if (ret_ptr == NULL)
+		/* No item in the fixed sysinfo tree */
+		if (ret_ptr == NULL) {
+			/* Even no data was generated */
 			ret.tag = SYSINFO_VAL_UNDEFINED;
+		}
 	}
 	
@@ -492,5 +631,10 @@
  *
  * Should be called with interrupts disabled
- * and sysinfo_lock held.
+ * and sysinfo_lock held. The path string passed from
+ * the user space has to be properly null-terminated
+ * (the last passed character must be null).
+ *
+ * @param ptr  Sysinfo path in the user address space.
+ * @param size Size of the path string.
  *
  */
@@ -514,14 +658,33 @@
 }
 
+/** Get the sysinfo value type (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * @param path_ptr  Sysinfo path in the user address space.
+ * @param path_size Size of the path string.
+ *
+ * @return Item value type.
+ *
+ */
 unative_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size)
 {
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&sysinfo_lock);
-	
+	/* Avoid other functions to mess with sysinfo
+	   while we are reading it */
+	ipl_t ipl = interrupts_disable();
+	spinlock_lock(&sysinfo_lock);
+	
+	/* Get the item */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
 	
+	/* N.B.: The generated binary data should be freed */
 	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
 		free(ret.data.data);
 	
+	/* Map generated value types to constant types
+	   (user space does not care whether the
+	   value is constant or generated) */
 	if (ret.tag == SYSINFO_VAL_FUNCTION_VAL)
 		ret.tag = SYSINFO_VAL_VAL;
@@ -535,13 +698,31 @@
 }
 
+/** Get the sysinfo numerical value (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * @param path_ptr  Sysinfo path in the user address space.
+ * @param path_size Size of the path string.
+ * @param value_ptr User space pointer where to store the
+ *                  numberical value.
+ *
+ * @return Error code (EOK in case of no error).
+ *
+ */
 unative_t sys_sysinfo_get_value(void *path_ptr, size_t path_size,
     void *value_ptr)
 {
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&sysinfo_lock);
-	
+	/* Avoid other functions to mess with sysinfo
+	   while we are reading it */
+	ipl_t ipl = interrupts_disable();
+	spinlock_lock(&sysinfo_lock);
+	
+	/* Get the item */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
 	int rc;
 	
+	/* Only constant or generated numerical value is returned */
 	if ((ret.tag == SYSINFO_VAL_VAL) || (ret.tag == SYSINFO_VAL_FUNCTION_VAL))
 		rc = copy_to_uspace(value_ptr, &ret.val, sizeof(ret.val));
@@ -549,4 +730,5 @@
 		rc = EINVAL;
 	
+	/* N.B.: The generated binary data should be freed */
 	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
 		free(ret.data.data);
@@ -558,13 +740,31 @@
 }
 
+/** Get the sysinfo binary data size (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * @param path_ptr  Sysinfo path in the user address space.
+ * @param path_size Size of the path string.
+ * @param size_ptr  User space pointer where to store the
+ *                  binary data size.
+ *
+ * @return Error code (EOK in case of no error).
+ *
+ */
 unative_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size,
     void *size_ptr)
 {
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&sysinfo_lock);
-	
+	/* Avoid other functions to mess with sysinfo
+	   while we are reading it */
+	ipl_t ipl = interrupts_disable();
+	spinlock_lock(&sysinfo_lock);
+	
+	/* Get the item */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
 	int rc;
 	
+	/* Only the size of constant or generated binary data is considered */
 	if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA))
 		rc = copy_to_uspace(size_ptr, &ret.data.size,
@@ -573,4 +773,5 @@
 		rc = EINVAL;
 	
+	/* N.B.: The generated binary data should be freed */
 	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
 		free(ret.data.data);
@@ -582,14 +783,38 @@
 }
 
+/** Get the sysinfo binary data (syscall)
+ *
+ * The path string passed from the user space has
+ * to be properly null-terminated (the last passed
+ * character must be null).
+ *
+ * The user space buffer must be sized exactly according
+ * to the size of the binary data, otherwise the request
+ * fails.
+ *
+ * @param path_ptr    Sysinfo path in the user address space.
+ * @param path_size   Size of the path string.
+ * @param buffer_ptr  User space pointer to the buffer where
+ *                    to store the binary data.
+ * @param buffer_size User space buffer size.
+ *
+ * @return Error code (EOK in case of no error).
+ *
+ */
 unative_t sys_sysinfo_get_data(void *path_ptr, size_t path_size,
     void *buffer_ptr, size_t buffer_size)
 {
-	ipl_t ipl = interrupts_disable();
-	spinlock_lock(&sysinfo_lock);
-	
+	/* Avoid other functions to mess with sysinfo
+	   while we are reading it */
+	ipl_t ipl = interrupts_disable();
+	spinlock_lock(&sysinfo_lock);
+	
+	/* Get the item */
 	sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size);
 	int rc;
 	
+	/* Only constant or generated binary data is considered */
 	if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA)) {
+		/* Check destination buffer size */
 		if (ret.data.size == buffer_size)
 			rc = copy_to_uspace(buffer_ptr, ret.data.data,
@@ -600,4 +825,5 @@
 		rc = EINVAL;
 	
+	/* N.B.: The generated binary data should be freed */
 	if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
 		free(ret.data.data);
Index: uspace/lib/c/generic/stats.c
===================================================================
--- uspace/lib/c/generic/stats.c	(revision fce3536ed6e901725440a6a9403d237da8f0e39a)
+++ uspace/lib/c/generic/stats.c	(revision 80bfb601d828951693b11892603e3161b6736ea0)
@@ -43,4 +43,13 @@
 #define SYSINFO_STATS_MAX_PATH  64
 
+/** Get CPUs statistics
+ *
+ * @param count Number of records returned.
+ *
+ * @return Array of stats_cpu_t structures.
+ *         If non-NULL then it should be eventually freed
+ *         by free().
+ *
+ */
 stats_cpu_t *get_stats_cpus(size_t *count)
 {
@@ -55,4 +64,12 @@
 }
 
+/** Get physical memory statistics
+ *
+ *
+ * @return Pointer to the stats_physmem_t structure.
+ *         If non-NULL then it should be eventually freed
+ *         by free().
+ *
+ */
 stats_physmem_t *get_stats_physmem(void)
 {
@@ -66,4 +83,13 @@
 }
 
+/** Get task IDs
+ *
+ * @param count Number of IDs returned.
+ *
+ * @return Array of IDs (task_id_t).
+ *         If non-NULL then it should be eventually freed
+ *         by free().
+ *
+ */
 task_id_t *get_stats_tasks(size_t *count)
 {
@@ -78,4 +104,13 @@
 }
 
+/** Get single task statistics
+ *
+ * @param task_id Task ID we are interested in.
+ *
+ * @return Pointer to the stats_task_t structure.
+ *         If non-NULL then it should be eventually freed
+ *         by free().
+ *
+ */
 stats_task_t *get_stats_task(task_id_t task_id)
 {
@@ -92,4 +127,13 @@
 }
 
+/** Get system load
+ *
+ * @param count Number of load records returned.
+ *
+ * @return Array of load records (load_t).
+ *         If non-NULL then it should be eventually freed
+ *         by free().
+ *
+ */
 load_t *get_stats_load(size_t *count)
 {
@@ -104,4 +148,9 @@
 }
 
+/** Get system uptime
+ *
+ * @return System uptime (in seconds).
+ *
+ */
 sysarg_t get_stats_uptime(void)
 {
@@ -113,4 +162,13 @@
 }
 
+/** Print load fixed-point value
+ *
+ * Print the load record fixed-point value in decimal
+ * representation on stdout.
+ *
+ * @param upper      Load record.
+ * @param dec_length Number of decimal digits to print.
+ *
+ */
 void print_load_fragment(load_t upper, unsigned int dec_length)
 {
Index: uspace/lib/c/generic/sysinfo.c
===================================================================
--- uspace/lib/c/generic/sysinfo.c	(revision fce3536ed6e901725440a6a9403d237da8f0e39a)
+++ uspace/lib/c/generic/sysinfo.c	(revision 80bfb601d828951693b11892603e3161b6736ea0)
@@ -40,4 +40,11 @@
 #include <bool.h>
 
+/** Get sysinfo item type
+ *
+ * @param path Sysinfo path.
+ *
+ * @return Sysinfo item type.
+ *
+ */
 sysinfo_item_tag_t sysinfo_get_tag(const char *path)
 {
@@ -46,4 +53,13 @@
 }
 
+/** Get sysinfo numerical value
+ *
+ * @param path  Sysinfo path.
+ * @param value Pointer to store the numerical value to.
+ *
+ * @return EOK if the value was successfully read and
+ *         is of SYSINFO_VAL_VAL type.
+ *
+ */
 int sysinfo_get_value(const char *path, sysarg_t *value)
 {
@@ -52,4 +68,13 @@
 }
 
+/** Get sysinfo binary data size
+ *
+ * @param path  Sysinfo path.
+ * @param value Pointer to store the binary data size.
+ *
+ * @return EOK if the value was successfully read and
+ *         is of SYSINFO_VAL_DATA type.
+ *
+ */
 static int sysinfo_get_data_size(const char *path, size_t *size)
 {
@@ -58,10 +83,31 @@
 }
 
+/** Get sysinfo binary data
+ *
+ * @param path  Sysinfo path.
+ * @param value Pointer to store the binary data size.
+ *
+ * @return Binary data read from sysinfo or NULL if the
+ *         sysinfo item value type is not binary data.
+ *         The returned non-NULL pointer should be
+ *         freed by free().
+ *
+ */
 void *sysinfo_get_data(const char *path, size_t *size)
 {
+	/* The binary data size might change during time.
+	   Unfortunatelly we cannot allocate the buffer
+	   and transfer the data as a single atomic operation.
+	
+	   Let's hope that the number of iterations is bounded
+	   in common cases. */
+	
 	while (true) {
+		/* Get the binary data size */
 		int ret = sysinfo_get_data_size(path, size);
-		if (ret != EOK)
+		if (ret != EOK) {
+			/* Not binary data item */
 			return NULL;
+		}
 		
 		void *data = malloc(*size);
@@ -69,4 +115,5 @@
 			return NULL;
 		
+		/* Get the data */
 		ret = __SYSCALL4(SYS_SYSINFO_GET_DATA, (sysarg_t) path,
 		    (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size);
@@ -74,8 +121,12 @@
 			return data;
 		
+		/* Dispose the buffer */
 		free(data);
 		
-		if (ret != ENOMEM)
+		if (ret != ENOMEM) {
+			/* The failure to get the data was not caused
+			   by wrong buffer size */
 			return NULL;
+		}
 	}
 }
Index: uspace/lib/c/include/sysinfo.h
===================================================================
--- uspace/lib/c/include/sysinfo.h	(revision fce3536ed6e901725440a6a9403d237da8f0e39a)
+++ uspace/lib/c/include/sysinfo.h	(revision 80bfb601d828951693b11892603e3161b6736ea0)
@@ -38,4 +38,7 @@
 #include <libc.h>
 
+/** Sysinfo value types
+ *
+ */
 typedef enum {
 	SYSINFO_VAL_UNDEFINED = 0,
