Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision ae7f6fb75347ada51aca1b40d5c46352dda49257)
+++ kernel/generic/src/mm/as.c	(revision 67455927fbc8c97908cd6c30a3647ae692112544)
@@ -112,9 +112,8 @@
 as_t *AS_KERNEL = NULL;
 
-static int area_flags_to_page_flags(int aflags);
-static as_area_t *find_area_and_lock(as_t *as, uintptr_t va);
-static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
-    as_area_t *avoid_area);
-static void sh_info_remove_reference(share_info_t *sh_info);
+static int area_flags_to_page_flags(int);
+static as_area_t *find_area_and_lock(as_t *, uintptr_t);
+static bool check_area_conflicts(as_t *, uintptr_t, size_t, as_area_t *);
+static void sh_info_remove_reference(share_info_t *);
 
 static int as_constructor(void *obj, int flags)
@@ -154,5 +153,6 @@
 /** Create address space.
  *
- * @param flags Flags that influence way in wich the address space is created.
+ * @param flags		Flags that influence the way in wich the address space
+ * 			is created.
  */
 as_t *as_create(int flags)
@@ -187,4 +187,6 @@
  *
  * We know that we don't hold any spinlock.
+ *
+ * @param as		Address space to be destroyed.
  */
 void as_destroy(as_t *as)
@@ -258,17 +260,17 @@
  * The created address space area is added to the target address space.
  *
- * @param as Target address space.
- * @param flags Flags of the area memory.
- * @param size Size of area.
- * @param base Base address of area.
- * @param attrs Attributes of the area.
- * @param backend Address space area backend. NULL if no backend is used.
- * @param backend_data NULL or a pointer to an array holding two void *.
- *
- * @return Address space area on success or NULL on failure.
+ * @param as		Target address space.
+ * @param flags		Flags of the area memory.
+ * @param size		Size of area.
+ * @param base		Base address of area.
+ * @param attrs		Attributes of the area.
+ * @param backend	Address space area backend. NULL if no backend is used.
+ * @param backend_data	NULL or a pointer to an array holding two void *.
+ *
+ * @return		Address space area on success or NULL on failure.
  */
 as_area_t *
 as_area_create(as_t *as, int flags, size_t size, uintptr_t base, int attrs,
-	       mem_backend_t *backend, mem_backend_data_t *backend_data)
+    mem_backend_t *backend, mem_backend_data_t *backend_data)
 {
 	ipl_t ipl;
@@ -322,11 +324,12 @@
 /** Find address space area and change it.
  *
- * @param as Address space.
- * @param address Virtual address belonging to the area to be changed. Must be
- *     page-aligned.
- * @param size New size of the virtual memory block starting at address. 
- * @param flags Flags influencing the remap operation. Currently unused.
- *
- * @return Zero on success or a value from @ref errno.h otherwise.
+ * @param as		Address space.
+ * @param address	Virtual address belonging to the area to be changed.
+ * 			Must be page-aligned.
+ * @param size		New size of the virtual memory block starting at
+ * 			address. 
+ * @param flags		Flags influencing the remap operation. Currently unused.
+ *
+ * @return		Zero on success or a value from @ref errno.h otherwise.
  */ 
 int as_area_resize(as_t *as, uintptr_t address, size_t size, int flags)
@@ -436,6 +439,8 @@
 					cond = false;	/* we are almost done */
 					i = (start_free - b) >> PAGE_WIDTH;
-					if (!used_space_remove(area, start_free, c - i))
-						panic("Could not remove used space.\n");
+					if (!used_space_remove(area, start_free,
+					    c - i))
+						panic("Could not remove used "
+						    "space.\n");
 				} else {
 					/*
@@ -444,5 +449,6 @@
 					 */
 					if (!used_space_remove(area, b, c))
-						panic("Could not remove used space.\n");
+						panic("Could not remove used "
+						    "space.\n");
 				}
 			
@@ -506,8 +512,8 @@
 /** Destroy address space area.
  *
- * @param as Address space.
- * @param address Address withing the area to be deleted.
- *
- * @return Zero on success or a value from @ref errno.h on failure. 
+ * @param as		Address space.
+ * @param address	Address within the area to be deleted.
+ *
+ * @return		Zero on success or a value from @ref errno.h on failure.
  */
 int as_area_destroy(as_t *as, uintptr_t address)
@@ -606,16 +612,17 @@
  * mapping is done through the backend share function.
  * 
- * @param src_as Pointer to source address space.
- * @param src_base Base address of the source address space area.
- * @param acc_size Expected size of the source area.
- * @param dst_as Pointer to destination address space.
- * @param dst_base Target base address.
+ * @param src_as	Pointer to source address space.
+ * @param src_base	Base address of the source address space area.
+ * @param acc_size	Expected size of the source area.
+ * @param dst_as	Pointer to destination address space.
+ * @param dst_base	Target base address.
  * @param dst_flags_mask Destination address space area flags mask.
  *
- * @return Zero on success or ENOENT if there is no such task or if there is no
- * such address space area, EPERM if there was a problem in accepting the area
- * or ENOMEM if there was a problem in allocating destination address space
- * area. ENOTSUP is returned if the address space area backend does not support
- * sharing.
+ * @return		Zero on success or ENOENT if there is no such task or if
+ * 			there is no such address space area, EPERM if there was
+ * 			a problem in accepting the area or ENOMEM if there was a
+ * 			problem in allocating destination address space area.
+ * 			ENOTSUP is returned if the address space area backend
+ * 			does not support sharing.
  */
 int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
@@ -736,8 +743,9 @@
  * The address space area must be locked prior to this call.
  *
- * @param area Address space area.
- * @param access Access mode.
- *
- * @return False if access violates area's permissions, true otherwise.
+ * @param area		Address space area.
+ * @param access	Access mode.
+ *
+ * @return		False if access violates area's permissions, true
+ * 			otherwise.
  */
 bool as_area_check_access(as_area_t *area, pf_access_t access)
@@ -755,5 +763,5 @@
 }
 
-/** Change adress area flags.
+/** Change adress space area flags.
  *
  * The idea is to have the same data, but with a different access mode.
@@ -762,9 +770,9 @@
  * into private anonymous memory (unless it's already there).
  *
- * @param as Address space.
- * @param flags Flags of the area memory.
- * @param address Address withing the area to be changed.
- *
- * @return Zero on success or a value from @ref errno.h on failure. 
+ * @param as		Address space.
+ * @param flags		Flags of the area memory.
+ * @param address	Address withing the area to be changed.
+ *
+ * @return		Zero on success or a value from @ref errno.h on failure.
  */
 int as_area_change_flags(as_t *as, int flags, uintptr_t address)
@@ -877,6 +885,6 @@
 	/*
 	 * Map pages back in with new flags. This step is kept separate
-	 * so that there's no instant when the memory area could be
-	 * accesed with both the old and the new flags at once.
+	 * so that the memory area could not be accesed with both the old and
+	 * the new flags at once.
 	 */
 	frame_idx = 0;
@@ -916,17 +924,18 @@
 /** Handle page fault within the current address space.
  *
- * This is the high-level page fault handler. It decides
- * whether the page fault can be resolved by any backend
- * and if so, it invokes the backend to resolve the page
- * fault.
+ * This is the high-level page fault handler. It decides whether the page fault
+ * can be resolved by any backend and if so, it invokes the backend to resolve
+ * the page fault.
  *
  * Interrupts are assumed disabled.
  *
- * @param page Faulting page.
- * @param access Access mode that caused the fault (i.e. read/write/exec).
- * @param istate Pointer to interrupted state.
- *
- * @return AS_PF_FAULT on page fault, AS_PF_OK on success or AS_PF_DEFER if the
- * 	   fault was caused by copy_to_uspace() or copy_from_uspace().
+ * @param page		Faulting page.
+ * @param access	Access mode that caused the page fault (i.e.
+ * 			read/write/exec).
+ * @param istate	Pointer to the interrupted state.
+ *
+ * @return		AS_PF_FAULT on page fault, AS_PF_OK on success or
+ * 			AS_PF_DEFER if the fault was caused by copy_to_uspace()
+ * 			or copy_from_uspace().
  */
 int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate)
@@ -974,7 +983,6 @@
 	
 	/*
-	 * To avoid race condition between two page faults
-	 * on the same address, we need to make sure
-	 * the mapping has not been already inserted.
+	 * To avoid race condition between two page faults on the same address,
+	 * we need to make sure the mapping has not been already inserted.
 	 */
 	if ((pte = page_mapping_find(AS, page))) {
@@ -1030,6 +1038,6 @@
  * When this function is enetered, no spinlocks may be held.
  *
- * @param old Old address space or NULL.
- * @param new New address space.
+ * @param old		Old address space or NULL.
+ * @param new		New address space.
  */
 void as_switch(as_t *old_as, as_t *new_as)
@@ -1102,7 +1110,7 @@
 /** Convert address space area flags to page flags.
  *
- * @param aflags Flags of some address space area.
- *
- * @return Flags to be passed to page_mapping_insert().
+ * @param aflags	Flags of some address space area.
+ *
+ * @return		Flags to be passed to page_mapping_insert().
  */
 int area_flags_to_page_flags(int aflags)
@@ -1132,7 +1140,7 @@
  * Interrupts must be disabled.
  *
- * @param a Address space area.
- *
- * @return Flags to be used in page_mapping_insert().
+ * @param a		Address space area.
+ *
+ * @return		Flags to be used in page_mapping_insert().
  */
 int as_area_get_flags(as_area_t *a)
@@ -1143,10 +1151,11 @@
 /** Create page table.
  *
- * Depending on architecture, create either address space
- * private or global page table.
- *
- * @param flags Flags saying whether the page table is for kernel address space.
- *
- * @return First entry of the page table.
+ * Depending on architecture, create either address space private or global page
+ * table.
+ *
+ * @param flags		Flags saying whether the page table is for the kernel
+ * 			address space.
+ *
+ * @return		First entry of the page table.
  */
 pte_t *page_table_create(int flags)
@@ -1162,5 +1171,5 @@
  * Destroy page table in architecture specific way.
  *
- * @param page_table Physical address of PTL0.
+ * @param page_table	Physical address of PTL0.
  */
 void page_table_destroy(pte_t *page_table)
@@ -1181,6 +1190,6 @@
  * call in which case the lock argument is false.
  *
- * @param as Address space.
- * @param lock If false, do not attempt to lock as->lock.
+ * @param as		Address space.
+ * @param lock		If false, do not attempt to lock as->lock.
  */
 void page_table_lock(as_t *as, bool lock)
@@ -1194,6 +1203,6 @@
 /** Unlock page table.
  *
- * @param as Address space.
- * @param unlock If false, do not attempt to unlock as->lock.
+ * @param as		Address space.
+ * @param unlock	If false, do not attempt to unlock as->lock.
  */
 void page_table_unlock(as_t *as, bool unlock)
@@ -1210,9 +1219,9 @@
  * The address space must be locked and interrupts must be disabled.
  *
- * @param as Address space.
- * @param va Virtual address.
- *
- * @return Locked address space area containing va on success or NULL on
- *     failure.
+ * @param as		Address space.
+ * @param va		Virtual address.
+ *
+ * @return		Locked address space area containing va on success or
+ * 			NULL on failure.
  */
 as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
@@ -1266,13 +1275,13 @@
  * The address space must be locked and interrupts must be disabled.
  *
- * @param as Address space.
- * @param va Starting virtual address of the area being tested.
- * @param size Size of the area being tested.
- * @param avoid_area Do not touch this area. 
- *
- * @return True if there is no conflict, false otherwise.
- */
-bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
-			  as_area_t *avoid_area)
+ * @param as		Address space.
+ * @param va		Starting virtual address of the area being tested.
+ * @param size		Size of the area being tested.
+ * @param avoid_area	Do not touch this area. 
+ *
+ * @return		True if there is no conflict, false otherwise.
+ */
+bool
+check_area_conflicts(as_t *as, uintptr_t va, size_t size, as_area_t *avoid_area)
 {
 	as_area_t *a;
@@ -1363,5 +1372,5 @@
 	ipl = interrupts_disable();
 	src_area = find_area_and_lock(AS, base);
-	if (src_area){
+	if (src_area) {
 		size = src_area->pages * PAGE_SIZE;
 		mutex_unlock(&src_area->lock);
@@ -1377,9 +1386,9 @@
  * The address space area must be already locked.
  *
- * @param a Address space area.
- * @param page First page to be marked.
- * @param count Number of page to be marked.
- *
- * @return 0 on failure and 1 on success.
+ * @param a		Address space area.
+ * @param page		First page to be marked.
+ * @param count		Number of page to be marked.
+ *
+ * @return		Zero on failure and non-zero on success.
  */
 int used_space_insert(as_area_t *a, uintptr_t page, count_t count)
@@ -1651,6 +1660,6 @@
 	}
 
-	panic("Inconsistency detected while adding %" PRIc " pages of used space at "
-	    "%p.\n", count, page);
+	panic("Inconsistency detected while adding %" PRIc " pages of used "
+	    "space at %p.\n", count, page);
 }
 
@@ -1659,9 +1668,9 @@
  * The address space area must be already locked.
  *
- * @param a Address space area.
- * @param page First page to be marked.
- * @param count Number of page to be marked.
- *
- * @return 0 on failure and 1 on success.
+ * @param a		Address space area.
+ * @param page		First page to be marked.
+ * @param count		Number of page to be marked.
+ *
+ * @return		Zero on failure and non-zero on success.
  */
 int used_space_remove(as_area_t *a, uintptr_t page, count_t count)
@@ -1830,6 +1839,6 @@
 
 error:
-	panic("Inconsistency detected while removing %" PRIc " pages of used space "
-	    "from %p.\n", count, page);
+	panic("Inconsistency detected while removing %" PRIc " pages of used "
+	    "space from %p.\n", count, page);
 }
 
@@ -1838,5 +1847,5 @@
  * If the reference count drops to 0, the sh_info is deallocated.
  *
- * @param sh_info Pointer to address space area share info.
+ * @param sh_info	Pointer to address space area share info.
  */
 void sh_info_remove_reference(share_info_t *sh_info)
@@ -1907,5 +1916,5 @@
 /** Print out information about address space.
  *
- * @param as Address space.
+ * @param as		Address space.
  */
 void as_print(as_t *as)
@@ -1929,7 +1938,7 @@
 		
 			mutex_lock(&area->lock);
-			printf("as_area: %p, base=%p, pages=%" PRIc " (%p - %p)\n",
-			    area, area->base, area->pages, area->base,
-			    area->base + FRAMES2SIZE(area->pages));
+			printf("as_area: %p, base=%p, pages=%" PRIc
+			    " (%p - %p)\n", area, area->base, area->pages,
+			    area->base, area->base + FRAMES2SIZE(area->pages));
 			mutex_unlock(&area->lock);
 		}
