Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ HelenOS.config	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -344,7 +344,4 @@
 ! [PLATFORM=sparc64] CONFIG_VIRT_IDX_DCACHE (y/n)
 
-% Simics SMP Hack
-! [PROCESSOR=sun4v] CONFIG_SIMICS_SMP_HACK (y/n)
-
 % Support for userspace debuggers
 ! CONFIG_UDEBUG (y/n)
Index: ntrib/bazaar/bzreml/__init__.py
===================================================================
--- contrib/bazaar/bzreml/__init__.py	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,231 +1,0 @@
-#
-# Copyright (c) 2009 Martin Decky
-# 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.
-#
-
-"""Send emails for commits and repository changes."""
-
-#
-# Inspired by bzr-email plugin (copyright (c) 2005 - 2007 Canonical Ltd.,
-# distributed under GPL), but no code is shared with the original plugin.
-#
-# Configuration options:
-#  - post_commit_to (destination email address for the commit emails)
-#  - post_commit_sender (source email address for the commit emails)
-#
-
-import smtplib
-import time
-
-from StringIO import StringIO
-
-from email.utils import parseaddr
-from email.utils import formatdate
-from email.utils import make_msgid
-from email.Header import Header
-from email.Message import Message
-from email.mime.multipart import MIMEMultipart
-from email.mime.text import MIMEText
-
-from bzrlib import errors
-from bzrlib import revision
-from bzrlib import __version__ as bzrlib_version
-
-from bzrlib.branch import Branch
-from bzrlib.diff import DiffTree
-
-def send_smtp(server, sender, to, subject, body):
-	"""Send SMTP message"""
-	
-	connection = smtplib.SMTP()
-	
-	try:
-		connection.connect(server)
-	except socket.error, err:
-		raise errors.SocketConnectionError(host = server, msg = "Unable to connect to SMTP server", orig_error = err)
-	
-	sender_user, sender_email = parseaddr(sender)
-	payload = MIMEText(body.encode("utf-8"), "plain", "utf-8")
-	
-	msg = MIMEMultipart()
-	msg["From"] = "%s <%s>" % (Header(unicode(sender_user)), sender_email)
-	msg["User-Agent"] = "bzr/%s" % bzrlib_version
-	msg["Date"] = formatdate(None, True)
-	msg["Message-Id"] = make_msgid("bzr")
-	msg["To"] = to
-	msg["Subject"] = Header(subject)
-	msg.attach(payload)
-	
-	connection.sendmail(sender, [to], msg.as_string())
-
-def config_to(config):
-	"""Address the mail should go to"""
-	
-	return config.get_user_option("post_commit_to")
-
-def config_sender(config):
-	"""Address the email should be sent from"""
-	
-	result = config.get_user_option("post_commit_sender")
-	if (result is None):
-		result = config.username()
-	
-	return result
-
-def merge_marker(revision):
-	if (len(revision.parent_ids) > 1):
-		return " [merge]"
-	
-	return ""
-
-def revision_sequence(branch, revision_old_id, revision_new_id):
-	"""Calculate a sequence of revisions"""
-	
-	for revision_ac_id in branch.repository.iter_reverse_revision_history(revision_new_id):
-		if (revision_ac_id == revision_old_id):
-			break
-		yield revision_ac_id
-
-def send_email(branch, revision_old_id, revision_new_id, config):
-	"""Send the email"""
-	
-	if (config_to(config) is not None):
-		branch.lock_read()
-		branch.repository.lock_read()
-		try:
-			body = StringIO()
-			
-			for revision_ac_id in revision_sequence(branch, revision_old_id, revision_new_id):
-				revision_ac = branch.repository.get_revision(revision_ac_id)
-				revision_ac_no = branch.revision_id_to_revno(revision_ac_id)
-				
-				committer = revision_ac.committer
-				authors = revision_ac.get_apparent_authors()
-				date = time.strftime("%Y-%m-%d %H:%M:%S %Z (%a, %d %b %Y)", time.localtime(revision_ac.timestamp))
-				
-				if (authors != [committer]):
-					body.write("Author: %s\n" % ", ".join(authors))
-				
-				body.write("Committer: %s\n" % committer)
-				body.write("Date: %s\n" % date)
-				body.write("New Revision: %s%s\n" % (revision_ac_no, merge_marker(revision_ac)))
-				body.write("New Id: %s\n" % revision_ac_id)
-				
-				body.write("\n")
-				
-				for parent_id in revision_ac.parent_ids:
-					body.write("Parent: %s\n" % parent_id)
-					
-					tree_old = branch.repository.revision_tree(parent_id)
-					tree_ac = branch.repository.revision_tree(revision_ac_id)
-					
-					delta = tree_ac.changes_from(tree_old)
-					
-					if (len(delta.added) > 0):
-						body.write("Added:\n")
-						for item in delta.added:
-							body.write("    %s\n" % item[0])
-					
-					if (len(delta.removed) > 0):
-						body.write("Removed:\n")
-						for item in delta.removed:
-							body.write("    %s\n" % item[0])
-					
-					if (len(delta.renamed) > 0):
-						body.write("Renamed:\n")
-						for item in delta.renamed:
-							body.write("    %s -> %s\n" % (item[0], item[1]))
-					
-					if (len(delta.kind_changed) > 0):
-						body.write("Changed:\n")
-						for item in delta.kind_changed:
-							body.write("    %s\n" % item[0])
-						
-					if (len(delta.modified) > 0):
-						body.write("Modified:\n")
-						for item in delta.modified:
-							body.write("    %s\n" % item[0])
-					
-					body.write("\n")
-				
-				body.write("Log:\n")
-				if (not revision_ac.message):
-					body.write("(empty)\n")
-				else:
-					log = revision_ac.message.rstrip("\n\r")
-					for line in log.split("\n"):
-						body.write("%s\n" % line)
-				
-				body.write("\n")
-			
-			tree_old = branch.repository.revision_tree(revision_old_id)
-			tree_new = branch.repository.revision_tree(revision_new_id)
-			
-			tree_old.lock_read()
-			try:
-				tree_new.lock_read()
-				try:
-					diff = DiffTree.from_trees_options(tree_old, tree_new, body, "utf8", None, "", "", None)
-					diff.show_diff(None, None)
-				finally:
-					tree_new.unlock()
-			finally:
-				tree_old.unlock()
-			
-			revision_new_no = branch.revision_id_to_revno(revision_new_id)
-			
-			delta = tree_new.changes_from(tree_old)
-			files = []
-			
-			for item in delta.added:
-				files.append(item[0])
-			
-			for item in delta.removed:
-				files.append(item[0])
-			
-			for item in delta.renamed:
-				files.append(item[0])
-			
-			for item in delta.kind_changed:
-				files.append(item[0])
-			
-			for item in delta.modified:
-				files.append(item[0])
-			
-			subject = "r%d - %s" % (revision_new_no, " ".join(files))
-			
-			send_smtp("localhost", config_sender(config), config_to(config), subject, body.getvalue())
-		finally:
-			branch.repository.unlock()
-			branch.unlock()
-
-def branch_post_change_hook(params):
-	"""post_change_branch_tip hook"""
-	
-	send_email(params.branch, params.old_revid, params.new_revid, params.branch.get_config())
-
-install_named_hook = getattr(Branch.hooks, "install_named_hook", None)
-install_named_hook("post_change_branch_tip", branch_post_change_hook, "bzreml")
Index: contrib/bazaar/mbprotect/__init__.py
===================================================================
--- contrib/bazaar/mbprotect/__init__.py	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ contrib/bazaar/mbprotect/__init__.py	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -33,5 +33,5 @@
 # branch (a.k.a. linear history) of bzr repositories from unwanted change,
 # effectively making the main branch append-only.
-#
+# 
 # Specifically we verify that the new main branch contains the old tip.
 # This prevents a branch from inadvertently aquiring the tip of another branch.
@@ -46,26 +46,27 @@
 
 def pre_change_branch_tip(params):
-	repo = params.branch.repository
-	
-	# Check if the old repository was empty.
-	if params.old_revid == 'null:':
-		return
-	
-	# First permitted case is appending changesets to main branch.Look for
-	# old tip in new main branch.
-	for revision_id in repo.iter_reverse_revision_history(params.new_revid):
-		if revision_id == params.old_revid:
-			return	# Found old tip
-	
-	# Another permitted case is backing out changesets. Look for new tip
-	# in old branch.
-	for revision_id in repo.iter_reverse_revision_history(params.old_revid):
-		if revision_id == params.new_revid:
-			return	# Found new tip
-	
-	# Trying to do something else. Reject the change.
-	raise TipChangeRejected('Bad tip. Read http://trac.helenos.org/wiki/BazaarWorkflow')
+    repo = params.branch.repository
+
+    # Check if the old repository was empty.
+    if params.old_revid == 'null:':
+	return
+
+    # First permitted case is appending changesets to main branch.Look for
+    # old tip in new main branch.
+    for revision_id in repo.iter_reverse_revision_history(params.new_revid):
+	if revision_id == params.old_revid:
+	    return	# Found old tip
+
+    # Another permitted case is backing out changesets. Look for new tip
+    # in old branch.
+    for revision_id in repo.iter_reverse_revision_history(params.old_revid):
+	if revision_id == params.new_revid:
+	    return	# Found new tip
+
+    # Trying to do something else. Reject the change.
+    raise TipChangeRejected('Bad tip. Read http://trac.helenos.org/trac.fcgi/' +
+	'wiki/BazaarWorkflow')
 
 # Install hook.
 bzrlib.branch.Branch.hooks.install_named_hook('pre_change_branch_tip',
-	pre_change_branch_tip, 'MB-Protect tip check')
+    pre_change_branch_tip, 'MB-Protect tip check')
Index: defaults/sparc64/sun4v/Makefile.config
===================================================================
--- defaults/sparc64/sun4v/Makefile.config	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ defaults/sparc64/sun4v/Makefile.config	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -11,4 +11,6 @@
 CONFIG_SMP = n
 
+CONFIG_TSB = n
+
 CONFIG_FB = n
 
Index: kernel/Makefile.build
===================================================================
--- kernel/Makefile.build	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/Makefile.build	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -56,6 +56,5 @@
 	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
 	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-Werror -pipe
+	-Werror-implicit-function-declaration -Werror -pipe
 
 ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
@@ -70,7 +69,6 @@
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
 	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
-	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-pipe -arch $(CLANG_ARCH)
+	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -pipe \
+	-arch $(CLANG_ARCH)
 
 LFLAGS = -M
Index: kernel/arch/abs32le/Makefile.inc
===================================================================
--- kernel/arch/abs32le/Makefile.inc	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/abs32le/Makefile.inc	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -50,8 +50,4 @@
 endif
 
-ifeq ($(COMPILER),clang)
-	CLANG_ARCH = i386
-endif
-
 BITS = 32
 ENDIANESS = LE
Index: kernel/arch/abs32le/include/atomic.h
===================================================================
--- kernel/arch/abs32le/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/abs32le/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,5 +54,5 @@
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
 	/* On real hardware both the storing of the previous
@@ -60,5 +60,5 @@
 	   atomic action. */
 	
-	atomic_count_t prev = val->count;
+	long prev = val->count;
 	
 	val->count++;
@@ -66,5 +66,5 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
 	/* On real hardware both the storing of the previous
@@ -72,5 +72,5 @@
 	   atomic action. */
 	
-	atomic_count_t prev = val->count;
+	long prev = val->count;
 	
 	val->count--;
@@ -81,7 +81,7 @@
 #define atomic_predec(val)  (atomic_postdec(val) - 1)
 
-static inline atomic_count_t test_and_set(atomic_t *val)
+static inline uint32_t test_and_set(atomic_t *val)
 {
-	atomic_count_t prev = val->count;
+	uint32_t prev = val->count;
 	val->count = 1;
 	return prev;
Index: kernel/arch/abs32le/include/types.h
===================================================================
--- kernel/arch/abs32le/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/abs32le/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -55,5 +55,4 @@
 typedef uint32_t unative_t;
 typedef int32_t native_t;
-typedef uint32_t atomic_count_t;
 
 typedef struct {
Index: kernel/arch/abs32le/src/abs32le.c
===================================================================
--- kernel/arch/abs32le/src/abs32le.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/abs32le/src/abs32le.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -114,5 +114,5 @@
 }
 
-void panic_printf(const char *fmt, ...)
+void panic_printf(char *fmt, ...)
 {
 	va_list args;
Index: kernel/arch/amd64/include/atomic.h
===================================================================
--- kernel/arch/amd64/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/amd64/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,6 +40,5 @@
 #include <preemption.h>
 
-static inline void atomic_inc(atomic_t *val)
-{
+static inline void atomic_inc(atomic_t *val) {
 #ifdef CONFIG_SMP
 	asm volatile (
@@ -55,6 +54,5 @@
 }
 
-static inline void atomic_dec(atomic_t *val)
-{
+static inline void atomic_dec(atomic_t *val) {
 #ifdef CONFIG_SMP
 	asm volatile (
@@ -70,12 +68,11 @@
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val) 
 {
-	atomic_count_t r = 1;
+	long r = 1;
 	
 	asm volatile (
 		"lock xaddq %[r], %[count]\n"
-		: [count] "+m" (val->count),
-		  [r] "+r" (r)
+		: [count] "+m" (val->count), [r] "+r" (r)
 	);
 	
@@ -83,12 +80,11 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val) 
 {
-	atomic_count_t r = -1;
+	long r = -1;
 	
 	asm volatile (
 		"lock xaddq %[r], %[count]\n"
-		: [count] "+m" (val->count),
-		  [r] "+r" (r)
+		: [count] "+m" (val->count), [r] "+r" (r)
 	);
 	
@@ -99,12 +95,11 @@
 #define atomic_predec(val)  (atomic_postdec(val) - 1)
 
-static inline atomic_count_t test_and_set(atomic_t *val)
-{
-	atomic_count_t v = 1;
+static inline uint64_t test_and_set(atomic_t *val) {
+	uint64_t v;
 	
 	asm volatile (
+		"movq $1, %[v]\n"
 		"xchgq %[v], %[count]\n"
-		: [v] "+r" (v),
-		  [count] "+m" (val->count)
+		: [v] "=r" (v), [count] "+m" (val->count)
 	);
 	
@@ -112,8 +107,9 @@
 }
 
+
 /** amd64 specific fast spinlock */
 static inline void atomic_lock_arch(atomic_t *val)
 {
-	atomic_count_t tmp;
+	uint64_t tmp;
 	
 	preemption_disable();
@@ -129,8 +125,6 @@
 		"testq %[tmp], %[tmp]\n"
 		"jnz 0b\n"
-		: [count] "+m" (val->count),
-		  [tmp] "=&r" (tmp)
+		: [count] "+m" (val->count), [tmp] "=&r" (tmp)
 	);
-	
 	/*
 	 * Prevent critical section code from bleeding out this way up.
Index: kernel/arch/amd64/include/types.h
===================================================================
--- kernel/arch/amd64/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/amd64/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -55,5 +55,4 @@
 typedef uint64_t unative_t;
 typedef int64_t native_t;
-typedef uint64_t atomic_count_t;
 
 typedef struct {
Index: kernel/arch/amd64/src/cpu/cpu.c
===================================================================
--- kernel/arch/amd64/src/cpu/cpu.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/amd64/src/cpu/cpu.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -62,5 +62,5 @@
 };
 
-static const char *vendor_str[] = {
+static char *vendor_str[] = {
 	"Unknown Vendor",
 	"AuthenticAMD",
Index: kernel/arch/amd64/src/debugger.c
===================================================================
--- kernel/arch/amd64/src/debugger.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/amd64/src/debugger.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -339,4 +339,5 @@
 {
 	unsigned int i;
+	char *symbol;
 
 #ifdef __32_BITS__
@@ -352,5 +353,5 @@
 	for (i = 0; i < BKPOINTS_MAX; i++)
 		if (breakpoints[i].address) {
-			const char *symbol = symtab_fmt_name_lookup(
+			symbol = symtab_fmt_name_lookup(
 			    breakpoints[i].address);
 
Index: kernel/arch/amd64/src/interrupt.c
===================================================================
--- kernel/arch/amd64/src/interrupt.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/amd64/src/interrupt.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -65,6 +65,8 @@
 void decode_istate(int n, istate_t *istate)
 {
-	const char *symbol = symtab_fmt_name_lookup(istate->rip);
-	
+	char *symbol;
+
+	symbol = symtab_fmt_name_lookup(istate->rip);
+
 	printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n", n, __func__);
 	printf("%%rip: %#llx (%s)\n", istate->rip, symbol);
Index: kernel/arch/arm32/include/atomic.h
===================================================================
--- kernel/arch/arm32/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/arm32/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -47,6 +47,8 @@
  *
  */
-static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
+static inline long atomic_add(atomic_t *val, int i)
 {
+	long ret;
+
 	/*
 	 * This implementation is for UP pre-ARMv6 systems where we do not have
@@ -55,5 +57,5 @@
 	ipl_t ipl = interrupts_disable();
 	val->count += i;
-	atomic_count_t ret = val->count;
+	ret = val->count;
 	interrupts_restore(ipl);
 	
@@ -64,5 +66,4 @@
  *
  * @param val Variable to be incremented.
- *
  */
 static inline void atomic_inc(atomic_t *val)
@@ -74,5 +75,4 @@
  *
  * @param val Variable to be decremented.
- *
  */
 static inline void atomic_dec(atomic_t *val) {
@@ -84,7 +84,6 @@
  * @param val Variable to be incremented.
  * @return    Value after incrementation.
- *
  */
-static inline atomic_count_t atomic_preinc(atomic_t *val)
+static inline long atomic_preinc(atomic_t *val)
 {
 	return atomic_add(val, 1);
@@ -95,7 +94,6 @@
  * @param val Variable to be decremented.
  * @return    Value after decrementation.
- *
  */
-static inline atomic_count_t atomic_predec(atomic_t *val)
+static inline long atomic_predec(atomic_t *val)
 {
 	return atomic_add(val, -1);
@@ -106,7 +104,6 @@
  * @param val Variable to be incremented.
  * @return    Value before incrementation.
- *
  */
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
 	return atomic_add(val, 1) - 1;
@@ -117,7 +114,6 @@
  * @param val Variable to be decremented.
  * @return    Value before decrementation.
- *
  */
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
 	return atomic_add(val, -1) + 1;
Index: kernel/arch/arm32/include/types.h
===================================================================
--- kernel/arch/arm32/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/arm32/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup arm32
+/** @addtogroup arm32	
  * @{
  */
@@ -38,7 +38,7 @@
 
 #ifndef DOXYGEN
-	#define ATTRIBUTE_PACKED __attribute__((packed))
+#	define ATTRIBUTE_PACKED __attribute__ ((packed))
 #else
-	#define ATTRIBUTE_PACKED
+#	define ATTRIBUTE_PACKED
 #endif
 
@@ -62,5 +62,4 @@
 typedef uint32_t unative_t;
 typedef int32_t native_t;
-typedef uint32_t atomic_count_t;
 
 typedef struct {
Index: kernel/arch/arm32/src/cpu/cpu.c
===================================================================
--- kernel/arch/arm32/src/cpu/cpu.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/arm32/src/cpu/cpu.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -43,5 +43,5 @@
 
 /** Implementators (vendor) names */
-static const char *imp_data[] = {
+static char *imp_data[] = {
 	"?",					/* IMP_DATA_START_OFFSET */
 	"ARM Ltd",				/* 0x41 */
@@ -60,5 +60,5 @@
 
 /** Architecture names */
-static const char *arch_data[] = {
+static char *arch_data[] = {
 	"?",       /* 0x0 */
 	"4",       /* 0x1 */
@@ -108,6 +108,6 @@
 void cpu_print_report(cpu_t *m)
 {
-	const char *vendor = imp_data[0];
-	const char *architecture = arch_data[0];
+	char * vendor = imp_data[0];
+	char * architecture = arch_data[0];
 	cpu_arch_t * cpu_arch = &m->arch;
 
Index: kernel/arch/ia32/include/atomic.h
===================================================================
--- kernel/arch/ia32/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia32/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,6 +40,5 @@
 #include <preemption.h>
 
-static inline void atomic_inc(atomic_t *val)
-{
+static inline void atomic_inc(atomic_t *val) {
 #ifdef CONFIG_SMP
 	asm volatile (
@@ -55,6 +54,5 @@
 }
 
-static inline void atomic_dec(atomic_t *val)
-{
+static inline void atomic_dec(atomic_t *val) {
 #ifdef CONFIG_SMP
 	asm volatile (
@@ -70,12 +68,11 @@
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val) 
 {
-	atomic_count_t r = 1;
+	long r = 1;
 	
 	asm volatile (
 		"lock xaddl %[r], %[count]\n"
-		: [count] "+m" (val->count),
-		  [r] "+r" (r)
+		: [count] "+m" (val->count), [r] "+r" (r)
 	);
 	
@@ -83,12 +80,11 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val) 
 {
-	atomic_count_t r = -1;
+	long r = -1;
 	
 	asm volatile (
 		"lock xaddl %[r], %[count]\n"
-		: [count] "+m" (val->count),
-		  [r] "+r" (r)
+		: [count] "+m" (val->count), [r] "+r"(r)
 	);
 	
@@ -99,12 +95,11 @@
 #define atomic_predec(val)  (atomic_postdec(val) - 1)
 
-static inline atomic_count_t test_and_set(atomic_t *val)
-{
-	atomic_count_t v = 1;
+static inline uint32_t test_and_set(atomic_t *val) {
+	uint32_t v;
 	
 	asm volatile (
+		"movl $1, %[v]\n"
 		"xchgl %[v], %[count]\n"
-		: [v] "+r" (v),
-		  [count] "+m" (val->count)
+		: [v] "=r" (v), [count] "+m" (val->count)
 	);
 	
@@ -115,5 +110,5 @@
 static inline void atomic_lock_arch(atomic_t *val)
 {
-	atomic_count_t tmp;
+	uint32_t tmp;
 	
 	preemption_disable();
@@ -129,8 +124,6 @@
 		"testl %[tmp], %[tmp]\n"
 		"jnz 0b\n"
-		: [count] "+m" (val->count),
-		  [tmp] "=&r" (tmp)
+		: [count] "+m" (val->count), [tmp] "=&r" (tmp)
 	);
-	
 	/*
 	 * Prevent critical section code from bleeding out this way up.
Index: kernel/arch/ia32/include/types.h
===================================================================
--- kernel/arch/ia32/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia32/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -55,5 +55,4 @@
 typedef uint32_t unative_t;
 typedef int32_t native_t;
-typedef uint32_t atomic_count_t;
 
 typedef struct {
Index: kernel/arch/ia32/src/cpu/cpu.c
===================================================================
--- kernel/arch/ia32/src/cpu/cpu.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia32/src/cpu/cpu.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -64,5 +64,5 @@
 };
 
-static const char *vendor_str[] = {
+static char *vendor_str[] = {
 	"Unknown Vendor",
 	"AMD",
Index: kernel/arch/ia32/src/interrupt.c
===================================================================
--- kernel/arch/ia32/src/interrupt.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia32/src/interrupt.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -65,11 +65,13 @@
 void decode_istate(istate_t *istate)
 {
-	const char *symbol = symtab_fmt_name_lookup(istate->eip);
-	
+	char *symbol;
+
+	symbol = symtab_fmt_name_lookup(istate->eip);
+
 	if (CPU)
 		printf("----------------EXCEPTION OCCURED (cpu%u)----------------\n", CPU->id);
 	else
 		printf("----------------EXCEPTION OCCURED----------------\n");
-	
+		
 	printf("%%eip: %#lx (%s)\n", istate->eip, symbol);
 	printf("ERROR_WORD=%#lx\n", istate->error_word);
@@ -78,5 +80,5 @@
 	printf("stack: %#lx, %#lx, %#lx, %#lx\n", istate->stack[0], istate->stack[1], istate->stack[2], istate->stack[3]);
 	printf("       %#lx, %#lx, %#lx, %#lx\n", istate->stack[4], istate->stack[5], istate->stack[6], istate->stack[7]);
-	
+
 	stack_trace_istate(istate);
 }
Index: kernel/arch/ia32/src/mm/frame.c
===================================================================
--- kernel/arch/ia32/src/mm/frame.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia32/src/mm/frame.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia32mm
+/** @addtogroup ia32mm	
  * @{
  */
@@ -109,5 +109,5 @@
 }
 
-static const char *e820names[] = {
+static char *e820names[] = {
 	"invalid",
 	"available",
@@ -122,5 +122,5 @@
 {
 	unsigned int i;
-	const char *name;
+	char *name;
 	
 	printf("Base               Size               Name\n");
Index: kernel/arch/ia64/include/atomic.h
===================================================================
--- kernel/arch/ia64/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia64/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -36,8 +36,8 @@
 #define KERN_ia64_ATOMIC_H_
 
-static inline atomic_count_t test_and_set(atomic_t *val)
+static inline uint64_t test_and_set(atomic_t *val)
 {
-	atomic_count_t v;
-	
+	uint64_t v;
+		
 	asm volatile (
 		"movl %[v] = 0x1;;\n"
@@ -53,5 +53,6 @@
 {
 	do {
-		while (val->count);
+		while (val->count)
+			;
 	} while (test_and_set(val));
 }
@@ -59,5 +60,5 @@
 static inline void atomic_inc(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -70,5 +71,5 @@
 static inline void atomic_dec(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -79,7 +80,7 @@
 }
 
-static inline atomic_count_t atomic_preinc(atomic_t *val)
+static inline long atomic_preinc(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -92,7 +93,7 @@
 }
 
-static inline atomic_count_t atomic_predec(atomic_t *val)
+static inline long atomic_predec(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -105,7 +106,7 @@
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -118,7 +119,7 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
Index: kernel/arch/ia64/include/types.h
===================================================================
--- kernel/arch/ia64/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia64/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ia64
+/** @addtogroup ia64	
  * @{
  */
@@ -63,5 +63,4 @@
 typedef uint64_t unative_t;
 typedef int64_t native_t;
-typedef uint64_t atomic_count_t;
 
 typedef struct {
Index: kernel/arch/ia64/src/cpu/cpu.c
===================================================================
--- kernel/arch/ia64/src/cpu/cpu.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia64/src/cpu/cpu.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -52,5 +52,5 @@
 void cpu_print_report(cpu_t *m)
 {
-	const char *family_str;
+	char *family_str;
 	char vendor[2 * sizeof(uint64_t) + 1];
 	
Index: kernel/arch/ia64/src/interrupt.c
===================================================================
--- kernel/arch/ia64/src/interrupt.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ia64/src/interrupt.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -64,5 +64,5 @@
 #define BUNDLE_SIZE		16
 
-static const char *vector_names_64_bundle[VECTORS_64_BUNDLE] = {
+char *vector_names_64_bundle[VECTORS_64_BUNDLE] = {
 	"VHPT Translation vector",
 	"Instruction TLB vector",
@@ -87,5 +87,5 @@
 };
 
-static const char *vector_names_16_bundle[VECTORS_16_BUNDLE] = {
+char *vector_names_16_bundle[VECTORS_16_BUNDLE] = {
 	"Page Not Present vector",
 	"Key Permission vector",
@@ -121,5 +121,8 @@
 };
 
-static const char *vector_to_string(uint16_t vector)
+static char *vector_to_string(uint16_t vector);
+static void dump_interrupted_context(istate_t *istate);
+
+char *vector_to_string(uint16_t vector)
 {
 	ASSERT(vector <= VECTOR_MAX);
@@ -132,10 +135,12 @@
 }
 
-static void dump_interrupted_context(istate_t *istate)
-{
-	const char *ifa = symtab_fmt_name_lookup(istate->cr_ifa);
-	const char *iipa = symtab_fmt_name_lookup(istate->cr_iipa);
-	const char *iip = symtab_fmt_name_lookup(istate->cr_iip);
-	
+void dump_interrupted_context(istate_t *istate)
+{
+	char *ifa, *iipa, *iip;
+
+	ifa = symtab_fmt_name_lookup(istate->cr_ifa);
+	iipa = symtab_fmt_name_lookup(istate->cr_iipa);
+	iip = symtab_fmt_name_lookup(istate->cr_iip);
+
 	putchar('\n');
 	printf("Interrupted context dump:\n");
@@ -157,6 +162,6 @@
 void general_exception(uint64_t vector, istate_t *istate)
 {
-	const char *desc;
-	
+	char *desc = "";
+
 	switch (istate->cr_isr.ge_code) {
 	case GE_ILLEGALOP:
@@ -182,7 +187,7 @@
 		break;
 	}
-	
+
 	fault_if_from_uspace(istate, "General Exception (%s).", desc);
-	
+
 	dump_interrupted_context(istate);
 	panic("General Exception (%s).", desc);
Index: kernel/arch/mips32/include/atomic.h
===================================================================
--- kernel/arch/mips32/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/mips32/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup mips32
+/** @addtogroup mips32	
  * @{
  */
@@ -51,10 +51,8 @@
  *
  * @return Value after addition.
- *
  */
-static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
+static inline long atomic_add(atomic_t *val, int i)
 {
-	atomic_count_t tmp;
-	atomic_count_t v;
+	long tmp, v;
 	
 	asm volatile (
@@ -66,9 +64,6 @@
 		"	beq %0, %4, 1b\n"   /* if the atomic operation failed, try again */
 		"	nop\n"
-		: "=&r" (tmp),
-		  "+m" (val->count),
-		  "=&r" (v)
-		: "r" (i),
-		  "i" (0)
+		: "=&r" (tmp), "+m" (val->count), "=&r" (v)
+		: "r" (i), "i" (0)
 	);
 	
@@ -76,8 +71,6 @@
 }
 
-static inline atomic_count_t test_and_set(atomic_t *val)
-{
-	atomic_count_t tmp;
-	atomic_count_t v;
+static inline uint32_t test_and_set(atomic_t *val) {
+	uint32_t tmp, v;
 	
 	asm volatile (
@@ -89,7 +82,5 @@
 		"	beqz %0, 1b\n"
 		"2:\n"
-		: "=&r" (tmp),
-		  "+m" (val->count),
-		  "=&r" (v)
+		: "=&r" (tmp), "+m" (val->count), "=&r" (v)
 		: "i" (1)
 	);
@@ -98,8 +89,8 @@
 }
 
-static inline void atomic_lock_arch(atomic_t *val)
-{
+static inline void atomic_lock_arch(atomic_t *val) {
 	do {
-		while (val->count);
+		while (val->count)
+			;
 	} while (test_and_set(val));
 }
Index: kernel/arch/mips32/include/types.h
===================================================================
--- kernel/arch/mips32/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/mips32/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup mips32
+/** @addtogroup mips32	
  * @{
  */
@@ -55,5 +55,4 @@
 typedef uint32_t unative_t;
 typedef int32_t native_t;
-typedef uint32_t atomic_count_t;
 
 typedef struct {
Index: kernel/arch/mips32/src/cpu/cpu.c
===================================================================
--- kernel/arch/mips32/src/cpu/cpu.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/mips32/src/cpu/cpu.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,6 +40,6 @@
 
 struct data_t {
-	const char *vendor;
-	const char *model;
+	char *vendor;
+	char *model;
 };
 
Index: kernel/arch/mips32/src/debugger.c
===================================================================
--- kernel/arch/mips32/src/debugger.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/mips32/src/debugger.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -253,13 +253,14 @@
 {
 	unsigned int i;
+	char *symbol;
 	
 	printf("#  Count Address    INPROG ONESHOT FUNCCALL In symbol\n");
 	printf("-- ----- ---------- ------ ------- -------- ---------\n");
 	
-	for (i = 0; i < BKPOINTS_MAX; i++) {
+	for (i = 0; i < BKPOINTS_MAX; i++)
 		if (breakpoints[i].address) {
-			const char *symbol = symtab_fmt_name_lookup(
+			symbol = symtab_fmt_name_lookup(
 			    breakpoints[i].address);
-			
+
 			printf("%-2u %-5d %#10zx %-6s %-7s %-8s %s\n", i,
 			    breakpoints[i].counter, breakpoints[i].address,
@@ -269,6 +270,4 @@
 			    BKPOINT_FUNCCALL) ? "true" : "false"), symbol);
 		}
-	}
-	
 	return 1;
 }
Index: kernel/arch/mips32/src/exception.c
===================================================================
--- kernel/arch/mips32/src/exception.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/mips32/src/exception.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -49,5 +49,5 @@
 #include <symtab.h>
 
-static const char *exctable[] = {
+static char * exctable[] = {
 	"Interrupt",
 	"TLB Modified",
@@ -74,7 +74,9 @@
 static void print_regdump(istate_t *istate)
 {
-	const char *pcsymbol = symtab_fmt_name_lookup(istate->epc);
-	const char *rasymbol = symtab_fmt_name_lookup(istate->ra);
-	
+	char *pcsymbol, *rasymbol;
+
+	pcsymbol = symtab_fmt_name_lookup(istate->epc);
+	rasymbol = symtab_fmt_name_lookup(istate->ra);
+
 	printf("PC: %#x(%s) RA: %#x(%s), SP(%p)\n", istate->epc, pcsymbol,
 	    istate->ra, rasymbol, istate->sp);
@@ -91,9 +93,9 @@
 static void reserved_instr_exception(int n, istate_t *istate)
 {
-	if (*((uint32_t *) istate->epc) == 0x7c03e83b) {
+	if (*((uint32_t *)istate->epc) == 0x7c03e83b) {
 		ASSERT(THREAD);
 		istate->epc += 4;
 		istate->v1 = istate->k1;
-	} else
+	} else 
 		unhandled_exception(n, istate);
 }
Index: kernel/arch/mips32/src/mm/tlb.c
===================================================================
--- kernel/arch/mips32/src/mm/tlb.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/mips32/src/mm/tlb.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -321,6 +321,8 @@
 void tlb_refill_fail(istate_t *istate)
 {
-	const char *symbol = symtab_fmt_name_lookup(istate->epc);
-	const char *sym2 = symtab_fmt_name_lookup(istate->ra);
+	char *symbol, *sym2;
+
+	symbol = symtab_fmt_name_lookup(istate->epc);
+	sym2 = symtab_fmt_name_lookup(istate->ra);
 	
 	fault_if_from_uspace(istate, "TLB Refill Exception on %p.",
@@ -333,6 +335,8 @@
 void tlb_invalid_fail(istate_t *istate)
 {
-	const char *symbol = symtab_fmt_name_lookup(istate->epc);
-	
+	char *symbol;
+
+	symbol = symtab_fmt_name_lookup(istate->epc);
+
 	fault_if_from_uspace(istate, "TLB Invalid Exception on %p.",
 	    cp0_badvaddr_read());
@@ -343,6 +347,8 @@
 void tlb_modified_fail(istate_t *istate)
 {
-	const char *symbol = symtab_fmt_name_lookup(istate->epc);
-	
+	char *symbol;
+
+	symbol = symtab_fmt_name_lookup(istate->epc);
+
 	fault_if_from_uspace(istate, "TLB Modified Exception on %p.",
 	    cp0_badvaddr_read());
Index: kernel/arch/ppc32/include/atomic.h
===================================================================
--- kernel/arch/ppc32/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ppc32/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ppc32
+/** @addtogroup ppc32	
  * @{
  */
@@ -38,6 +38,6 @@
 static inline void atomic_inc(atomic_t *val)
 {
-	atomic_count_t tmp;
-	
+	long tmp;
+
 	asm volatile (
 		"1:\n"
@@ -46,8 +46,6 @@
 		"stwcx. %0, 0, %2\n"
 		"bne- 1b"
-		: "=&r" (tmp),
-		  "=m" (val->count)
-		: "r" (&val->count),
-		  "m" (val->count)
+		: "=&r" (tmp), "=m" (val->count)
+		: "r" (&val->count), "m" (val->count)
 		: "cc"
 	);
@@ -56,21 +54,19 @@
 static inline void atomic_dec(atomic_t *val)
 {
-	atomic_count_t tmp;
-	
+	long tmp;
+
 	asm volatile (
 		"1:\n"
 		"lwarx %0, 0, %2\n"
 		"addic %0, %0, -1\n"
-		"stwcx. %0, 0, %2\n"
+		"stwcx.	%0, 0, %2\n"
 		"bne- 1b"
-		: "=&r" (tmp),
-		  "=m" (val->count)
-		: "r" (&val->count),
-		  "m" (val->count)
+		: "=&r" (tmp), "=m" (val->count)
+		: "r" (&val->count), "m" (val->count)
 		: "cc"
 	);
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
 	atomic_inc(val);
@@ -78,5 +74,5 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
 	atomic_dec(val);
@@ -84,5 +80,5 @@
 }
 
-static inline atomic_count_t atomic_preinc(atomic_t *val)
+static inline long atomic_preinc(atomic_t *val)
 {
 	atomic_inc(val);
@@ -90,5 +86,5 @@
 }
 
-static inline atomic_count_t atomic_predec(atomic_t *val)
+static inline long atomic_predec(atomic_t *val)
 {
 	atomic_dec(val);
Index: kernel/arch/ppc32/include/types.h
===================================================================
--- kernel/arch/ppc32/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ppc32/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup ppc32
+/** @addtogroup ppc32	
  * @{
  */
@@ -55,5 +55,4 @@
 typedef uint32_t unative_t;
 typedef int32_t native_t;
-typedef uint32_t atomic_count_t;
 
 typedef struct {
Index: kernel/arch/ppc32/src/cpu/cpu.c
===================================================================
--- kernel/arch/ppc32/src/cpu/cpu.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ppc32/src/cpu/cpu.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,5 +54,5 @@
 void cpu_print_report(cpu_t *m)
 {
-	const char *name;
+	char *name;
 	
 	switch (m->arch.version) {
Index: kernel/arch/ppc32/src/mm/tlb.c
===================================================================
--- kernel/arch/ppc32/src/mm/tlb.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/ppc32/src/mm/tlb.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -114,7 +114,10 @@
 static void pht_refill_fail(uintptr_t badvaddr, istate_t *istate)
 {
-	const char *symbol = symtab_fmt_name_lookup(istate->pc);
-	const char *sym2 = symtab_fmt_name_lookup(istate->lr);
-	
+	char *symbol;
+	char *sym2;
+
+	symbol = symtab_fmt_name_lookup(istate->pc);
+	sym2 = symtab_fmt_name_lookup(istate->lr);
+
 	fault_if_from_uspace(istate,
 	    "PHT Refill Exception on %p.", badvaddr);
Index: kernel/arch/sparc64/Makefile.inc
===================================================================
--- kernel/arch/sparc64/Makefile.inc	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/Makefile.inc	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -75,4 +75,5 @@
 	arch/$(KARCH)/src/dummy.s \
 	arch/$(KARCH)/src/mm/$(USARCH)/as.c \
+	arch/$(KARCH)/src/mm/cache.S \
 	arch/$(KARCH)/src/mm/$(USARCH)/frame.c \
 	arch/$(KARCH)/src/mm/page.c \
@@ -92,11 +93,5 @@
 	arch/$(KARCH)/src/drivers/sgcn.c \
 	arch/$(KARCH)/src/drivers/pci.c \
-	arch/$(KARCH)/src/drivers/fhc.c \
-	arch/$(KARCH)/src/trap/$(USARCH)/interrupt.c
-
-ifeq ($(USARCH),sun4u)
-	ARCH_SOURCES += \
-	        arch/$(KARCH)/src/mm/cache.S
-endif
+	arch/$(KARCH)/src/drivers/fhc.c
 
 ifeq ($(USARCH),sun4v)
@@ -113,6 +108,6 @@
 ifeq ($(CONFIG_SMP),y)
 	ARCH_SOURCES += \
-		arch/$(KARCH)/src/smp/$(USARCH)/smp.c \
-		arch/$(KARCH)/src/smp/$(USARCH)/ipi.c
+		arch/$(KARCH)/src/smp/ipi.c \
+		arch/$(KARCH)/src/smp/smp.c
 endif
 
Index: kernel/arch/sparc64/include/atomic.h
===================================================================
--- kernel/arch/sparc64/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup sparc64
+/** @addtogroup sparc64	
  * @{
  */
@@ -45,47 +45,40 @@
  *
  * @param val Atomic variable.
- * @param i   Signed value to be added.
+ * @param i Signed value to be added.
  *
  * @return Value of the atomic variable as it existed before addition.
- *
  */
-static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
+static inline long atomic_add(atomic_t *val, int i)
 {
-	atomic_count_t a;
-	atomic_count_t b;
-	
+	uint64_t a, b;
+
 	do {
-		volatile uintptr_t ptr = (uintptr_t) &val->count;
-		
-		a = *((atomic_count_t *) ptr);
+		volatile uintptr_t x = (uint64_t) &val->count;
+
+		a = *((uint64_t *) x);
 		b = a + i;
-		
-		asm volatile (
-			"casx %0, %2, %1\n"
-			: "+m" (*((atomic_count_t *) ptr)),
-		      "+r" (b)
-		    : "r" (a)
-		);
+		asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)),
+		    "+r" (b) : "r" (a));
 	} while (a != b);
-	
+
 	return a;
 }
 
-static inline atomic_count_t atomic_preinc(atomic_t *val)
+static inline long atomic_preinc(atomic_t *val)
 {
 	return atomic_add(val, 1) + 1;
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
 	return atomic_add(val, 1);
 }
 
-static inline atomic_count_t atomic_predec(atomic_t *val)
+static inline long atomic_predec(atomic_t *val)
 {
 	return atomic_add(val, -1) - 1;
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
 	return atomic_add(val, -1);
@@ -102,16 +95,12 @@
 }
 
-static inline atomic_count_t test_and_set(atomic_t *val)
+static inline long test_and_set(atomic_t *val)
 {
-	atomic_count_t v = 1;
-	volatile uintptr_t ptr = (uintptr_t) &val->count;
-	
-	asm volatile (
-		"casx %0, %2, %1\n"
-		: "+m" (*((atomic_count_t *) ptr)),
-	      "+r" (v)
-	    : "r" (0)
-	);
-	
+	uint64_t v = 1;
+	volatile uintptr_t x = (uint64_t) &val->count;
+
+	asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *) x)),
+	    "+r" (v) : "r" (0));
+
 	return v;
 }
@@ -119,27 +108,24 @@
 static inline void atomic_lock_arch(atomic_t *val)
 {
-	atomic_count_t tmp1 = 1;
-	atomic_count_t tmp2 = 0;
-	
-	volatile uintptr_t ptr = (uintptr_t) &val->count;
-	
+	uint64_t tmp1 = 1;
+	uint64_t tmp2 = 0;
+
+	volatile uintptr_t x = (uint64_t) &val->count;
+
 	preemption_disable();
-	
+
 	asm volatile (
-		"0:\n"
-			"casx %0, %3, %1\n"
-			"brz %1, 2f\n"
-			"nop\n"
-		"1:\n"
-			"ldx %0, %2\n"
-			"brz %2, 0b\n"
-			"nop\n"
-			"ba %%xcc, 1b\n"
-			"nop\n"
-		"2:\n"
-		: "+m" (*((atomic_count_t *) ptr)),
-		  "+r" (tmp1),
-		  "+r" (tmp2)
-		: "r" (0)
+	"0:\n"
+		"casx %0, %3, %1\n"
+		"brz %1, 2f\n"
+		"nop\n"
+	"1:\n"
+		"ldx %0, %2\n"
+		"brz %2, 0b\n"
+		"nop\n"
+		"ba %%xcc, 1b\n"
+		"nop\n"
+	"2:\n"
+		: "+m" (*((uint64_t *) x)), "+r" (tmp1), "+r" (tmp2) : "r" (0)
 	);
 	
Index: kernel/arch/sparc64/include/mm/as.h
===================================================================
--- kernel/arch/sparc64/include/mm/as.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/as.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -36,9 +36,58 @@
 #define KERN_sparc64_AS_H_
 
-#if defined (SUN4U)
-#include <arch/mm/sun4u/as.h>
-#elif defined (SUN4V)
-#include <arch/mm/sun4v/as.h>
+#include <arch/mm/tte.h>
+
+#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH	1
+
+#define KERNEL_ADDRESS_SPACE_START_ARCH		(unsigned long) 0x0000000000000000
+#define KERNEL_ADDRESS_SPACE_END_ARCH		(unsigned long) 0xffffffffffffffff
+#define USER_ADDRESS_SPACE_START_ARCH		(unsigned long) 0x0000000000000000
+#define USER_ADDRESS_SPACE_END_ARCH		(unsigned long) 0xffffffffffffffff
+
+#define USTACK_ADDRESS_ARCH	(0xffffffffffffffffULL - (PAGE_SIZE - 1))
+
+#ifdef CONFIG_TSB
+
+/** TSB Tag Target register. */
+typedef union tsb_tag_target {
+	uint64_t value;
+	struct {
+		unsigned invalid : 1;	/**< Invalidated by software. */
+		unsigned : 2;
+		unsigned context : 13;	/**< Software ASID. */
+		unsigned : 6;
+		uint64_t va_tag : 42;	/**< Virtual address bits <63:22>. */
+	} __attribute__ ((packed));
+} tsb_tag_target_t;
+
+/** TSB entry. */
+typedef struct tsb_entry {
+	tsb_tag_target_t tag;
+	tte_data_t data;
+} __attribute__ ((packed)) tsb_entry_t;
+
+typedef struct {
+	tsb_entry_t *itsb;
+	tsb_entry_t *dtsb;
+} as_arch_t;
+
+#else
+
+typedef struct {
+} as_arch_t;
+
+#endif /* CONFIG_TSB */
+
+#include <genarch/mm/as_ht.h>
+
+#ifdef CONFIG_TSB
+#include <arch/mm/tsb.h>
+#define as_invalidate_translation_cache(as, page, cnt) \
+	tsb_invalidate((as), (page), (cnt))
+#else
+#define as_invalidate_translation_cache(as, page, cnt)
 #endif
+
+extern void as_arch_init(void);
 
 #endif
Index: rnel/arch/sparc64/include/mm/sun4u/as.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4u/as.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,96 +1,0 @@
-/*
- * Copyright (c) 2005 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 sparc64mm	
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_sparc64_sun4u_AS_H_
-#define KERN_sparc64_sun4u_AS_H_
-
-#include <arch/mm/tte.h>
-
-#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH	1
-
-#define KERNEL_ADDRESS_SPACE_START_ARCH		(unsigned long) 0x0000000000000000
-#define KERNEL_ADDRESS_SPACE_END_ARCH		(unsigned long) 0xffffffffffffffff
-#define USER_ADDRESS_SPACE_START_ARCH		(unsigned long) 0x0000000000000000
-#define USER_ADDRESS_SPACE_END_ARCH		(unsigned long) 0xffffffffffffffff
-
-#define USTACK_ADDRESS_ARCH	(0xffffffffffffffffULL - (PAGE_SIZE - 1))
-
-#ifdef CONFIG_TSB
-
-/** TSB Tag Target register. */
-typedef union tsb_tag_target {
-	uint64_t value;
-	struct {
-		unsigned invalid : 1;	/**< Invalidated by software. */
-		unsigned : 2;
-		unsigned context : 13;	/**< Software ASID. */
-		unsigned : 6;
-		uint64_t va_tag : 42;	/**< Virtual address bits <63:22>. */
-	} __attribute__ ((packed));
-} tsb_tag_target_t;
-
-/** TSB entry. */
-typedef struct tsb_entry {
-	tsb_tag_target_t tag;
-	tte_data_t data;
-} __attribute__ ((packed)) tsb_entry_t;
-
-typedef struct {
-	tsb_entry_t *itsb;
-	tsb_entry_t *dtsb;
-} as_arch_t;
-
-#else
-
-typedef struct {
-} as_arch_t;
-
-#endif /* CONFIG_TSB */
-
-#include <genarch/mm/as_ht.h>
-
-#ifdef CONFIG_TSB
-#include <arch/mm/tsb.h>
-#define as_invalidate_translation_cache(as, page, cnt) \
-	tsb_invalidate((as), (page), (cnt))
-#else
-#define as_invalidate_translation_cache(as, page, cnt)
-#endif
-
-extern void as_arch_init(void);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/sparc64/include/mm/sun4u/tlb.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4u/tlb.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/sun4u/tlb.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -684,5 +684,4 @@
 
 extern void dump_sfsr_and_sfar(void);
-extern void describe_dmmu_fault(void);
 
 #endif /* !def __ASM__ */
Index: rnel/arch/sparc64/include/mm/sun4u/tsb.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4u/tsb.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,172 +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 sparc64mm	
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_sparc64_sun4u_TSB_H_
-#define KERN_sparc64_sun4u_TSB_H_
-
-/*
- * ITSB abd DTSB will claim 64K of memory, which
- * is a nice number considered that it is one of
- * the page sizes supported by hardware, which,
- * again, is nice because TSBs need to be locked
- * in TLBs - only one TLB entry will do.
- */
-#define TSB_SIZE			2	/* when changing this, change
-						 * as.c as well */
-#define ITSB_ENTRY_COUNT		(512 * (1 << TSB_SIZE))
-#define DTSB_ENTRY_COUNT		(512 * (1 << TSB_SIZE))
-
-#define TSB_TAG_TARGET_CONTEXT_SHIFT	48
-
-#ifndef __ASM__
-
-#include <arch/mm/tte.h>
-#include <arch/mm/mmu.h>
-#include <arch/types.h>
-
-/** TSB Base register. */
-typedef union tsb_base_reg {
-	uint64_t value;
-	struct {
-		uint64_t base : 51;	/**< TSB base address, bits 63:13. */
-		unsigned split : 1;	/**< Split vs. common TSB for 8K and 64K
-					 * pages. HelenOS uses only 8K pages
-					 * for user mappings, so we always set
-					 * this to 0.
-					 */
-		unsigned : 9;
-		unsigned size : 3;	/**< TSB size. Number of entries is
-					 * 512 * 2^size. */
-	} __attribute__ ((packed));
-} tsb_base_reg_t;
-
-/** Read ITSB Base register.
- *
- * @return Content of the ITSB Base register.
- */
-static inline uint64_t itsb_base_read(void)
-{
-	return asi_u64_read(ASI_IMMU, VA_IMMU_TSB_BASE);
-}
-
-/** Read DTSB Base register.
- *
- * @return Content of the DTSB Base register.
- */
-static inline uint64_t dtsb_base_read(void)
-{
-	return asi_u64_read(ASI_DMMU, VA_DMMU_TSB_BASE);
-}
-
-/** Write ITSB Base register.
- *
- * @param v New content of the ITSB Base register.
- */
-static inline void itsb_base_write(uint64_t v)
-{
-	asi_u64_write(ASI_IMMU, VA_IMMU_TSB_BASE, v);
-}
-
-/** Write DTSB Base register.
- *
- * @param v New content of the DTSB Base register.
- */
-static inline void dtsb_base_write(uint64_t v)
-{
-	asi_u64_write(ASI_DMMU, VA_DMMU_TSB_BASE, v);
-}
-
-#if defined (US3)
-
-/** Write DTSB Primary Extension register.
- *
- * @param v New content of the DTSB Primary Extension register.
- */
-static inline void dtsb_primary_extension_write(uint64_t v)
-{
-	asi_u64_write(ASI_DMMU, VA_DMMU_PRIMARY_EXTENSION, v);
-}
-
-/** Write DTSB Secondary Extension register.
- *
- * @param v New content of the DTSB Secondary Extension register.
- */
-static inline void dtsb_secondary_extension_write(uint64_t v)
-{
-	asi_u64_write(ASI_DMMU, VA_DMMU_SECONDARY_EXTENSION, v);
-}
-
-/** Write DTSB Nucleus Extension register.
- *
- * @param v New content of the DTSB Nucleus Extension register.
- */
-static inline void dtsb_nucleus_extension_write(uint64_t v)
-{
-	asi_u64_write(ASI_DMMU, VA_DMMU_NUCLEUS_EXTENSION, v);
-}
-
-/** Write ITSB Primary Extension register.
- *
- * @param v New content of the ITSB Primary Extension register.
- */
-static inline void itsb_primary_extension_write(uint64_t v)
-{
-	asi_u64_write(ASI_IMMU, VA_IMMU_PRIMARY_EXTENSION, v);
-}
-
-/** Write ITSB Nucleus Extension register.
- *
- * @param v New content of the ITSB Nucleus Extension register.
- */
-static inline void itsb_nucleus_extension_write(uint64_t v)
-{
-	asi_u64_write(ASI_IMMU, VA_IMMU_NUCLEUS_EXTENSION, v);
-}
-
-#endif
-
-/* Forward declarations. */
-struct as;
-struct pte;
-
-extern void tsb_invalidate(struct as *as, uintptr_t page, size_t pages);
-extern void itsb_pte_copy(struct pte *t, size_t index);
-extern void dtsb_pte_copy(struct pte *t, size_t index, bool ro);
-
-#endif /* !def __ASM__ */
-
-#endif
-
-/** @}
- */
Index: kernel/arch/sparc64/include/mm/sun4v/frame.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4v/frame.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/sun4v/frame.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -33,7 +33,12 @@
  */
 
-#ifndef KERN_sparc64_sun4v_FRAME_H_
-#define KERN_sparc64_sun4v_FRAME_H_
+#ifndef KERN_sparc64_SUN4V_FRAME_H_
+#define KERN_sparc64_SUN4V_FRAME_H_
 
+/*
+ * Page size supported by the MMU.
+ * For 8K there is the nasty illegal virtual aliasing problem.
+ * Therefore, the kernel uses 8K only internally on the TLB and TSB levels.
+ */
 #define MMU_FRAME_WIDTH		13	/* 8K */
 #define MMU_FRAME_SIZE		(1 << MMU_FRAME_WIDTH)
@@ -47,5 +52,24 @@
 #include <arch/types.h>
 
+union frame_address {
+	uintptr_t address;
+	struct {
+#if defined (US)
+		unsigned : 23;
+		uint64_t pfn : 28;		/**< Physical Frame Number. */
+#elif defined (US3)
+		unsigned : 21;
+		uint64_t pfn : 30;		/**< Physical Frame Number. */
+#endif
+		unsigned offset : 13;		/**< Offset. */
+	} __attribute__ ((packed));
+};
+
+typedef union frame_address frame_address_t;
+
 extern uintptr_t last_frame;
+//MH
+//extern uintptr_t end_of_identity;
+
 extern void frame_arch_init(void);
 #define physmem_print()
Index: kernel/arch/sparc64/include/mm/sun4v/mmu.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4v/mmu.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/sun4v/mmu.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -28,5 +28,5 @@
  */
 
-/** @addtogroup sparc64mm
+/** @addtogroup sparc64mm	
  * @{
  */
@@ -45,4 +45,106 @@
 #define ASI_SECONDARY_CONTEXT_REG	0x21	/**< secondary context register ASI. */
 
+
+
+
+
+
+
+
+
+
+
+/* I-MMU ASIs. */
+#define ASI_IMMU			0x50
+#define ASI_IMMU_TSB_8KB_PTR_REG	0x51	
+#define ASI_IMMU_TSB_64KB_PTR_REG	0x52
+#define ASI_ITLB_DATA_IN_REG		0x54
+#define ASI_ITLB_DATA_ACCESS_REG	0x55
+#define ASI_ITLB_TAG_READ_REG		0x56
+#define ASI_IMMU_DEMAP			0x57
+
+/* Virtual Addresses within ASI_IMMU. */
+#define VA_IMMU_TSB_TAG_TARGET		0x0	/**< IMMU TSB tag target register. */
+#define VA_IMMU_SFSR			0x18	/**< IMMU sync fault status register. */
+#define VA_IMMU_TSB_BASE		0x28	/**< IMMU TSB base register. */
+#define VA_IMMU_TAG_ACCESS		0x30	/**< IMMU TLB tag access register. */
+#if defined (US3)
+#define VA_IMMU_PRIMARY_EXTENSION	0x48	/**< IMMU TSB primary extension register */
+#define VA_IMMU_NUCLEUS_EXTENSION	0x58	/**< IMMU TSB nucleus extension register */
+#endif
+
+
+/* D-MMU ASIs. */
+#define ASI_DMMU			0x58
+#define ASI_DMMU_TSB_8KB_PTR_REG	0x59	
+#define ASI_DMMU_TSB_64KB_PTR_REG	0x5a
+#define ASI_DMMU_TSB_DIRECT_PTR_REG	0x5b
+#define ASI_DTLB_DATA_IN_REG		0x5c
+#define ASI_DTLB_DATA_ACCESS_REG	0x5d
+#define ASI_DTLB_TAG_READ_REG		0x5e
+#define ASI_DMMU_DEMAP			0x5f
+
+/* Virtual Addresses within ASI_DMMU. */
+#define VA_DMMU_TSB_TAG_TARGET		0x0	/**< DMMU TSB tag target register. */
+#define VA_PRIMARY_CONTEXT_REG		0x8	/**< DMMU primary context register. */
+#define VA_SECONDARY_CONTEXT_REG	0x10	/**< DMMU secondary context register. */
+#define VA_DMMU_SFSR			0x18	/**< DMMU sync fault status register. */
+#define VA_DMMU_SFAR			0x20	/**< DMMU sync fault address register. */
+#define VA_DMMU_TSB_BASE		0x28	/**< DMMU TSB base register. */
+#define VA_DMMU_TAG_ACCESS		0x30	/**< DMMU TLB tag access register. */
+#define VA_DMMU_VA_WATCHPOINT_REG	0x38	/**< DMMU VA data watchpoint register. */
+#define VA_DMMU_PA_WATCHPOINT_REG	0x40	/**< DMMU PA data watchpoint register. */
+#if defined (US3)
+#define VA_DMMU_PRIMARY_EXTENSION	0x48	/**< DMMU TSB primary extension register */
+#define VA_DMMU_SECONDARY_EXTENSION	0x50	/**< DMMU TSB secondary extension register */
+#define VA_DMMU_NUCLEUS_EXTENSION	0x58	/**< DMMU TSB nucleus extension register */
+#endif
+
+#ifndef __ASM__
+
+#include <arch/asm.h>
+#include <arch/barrier.h>
+#include <arch/types.h>
+
+#if defined(US)
+/** LSU Control Register. */
+typedef union {
+	uint64_t value;
+	struct {
+		unsigned : 23;
+		unsigned pm : 8;
+		unsigned vm : 8;
+		unsigned pr : 1;
+		unsigned pw : 1;
+		unsigned vr : 1;
+		unsigned vw : 1;
+		unsigned : 1;
+		unsigned fm : 16;	
+		unsigned dm : 1;	/**< D-MMU enable. */
+		unsigned im : 1;	/**< I-MMU enable. */
+		unsigned dc : 1;	/**< D-Cache enable. */
+		unsigned ic : 1;	/**< I-Cache enable. */
+		
+	} __attribute__ ((packed));
+} lsu_cr_reg_t;
+#endif /* US */
+
+#endif /* !def __ASM__ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 #endif
 
Index: kernel/arch/sparc64/include/mm/sun4v/tlb.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4v/tlb.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/sun4v/tlb.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -28,5 +28,5 @@
  */
 
-/** @addtogroup sparc64mm
+/** @addtogroup sparc64mm	
  * @{
  */
Index: kernel/arch/sparc64/include/mm/sun4v/tsb.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4v/tsb.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/sun4v/tsb.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -28,5 +28,5 @@
  */
 
-/** @addtogroup sparc64mm
+/** @addtogroup sparc64mm	
  * @{
  */
@@ -71,5 +71,5 @@
 struct pte;
 
-extern void tsb_invalidate(struct as *as, uintptr_t page, uint64_t pages);
+extern void tsb_invalidate(struct as *as, uintptr_t page, count_t pages);
 extern void itsb_pte_copy(struct pte *t);
 extern void dtsb_pte_copy(struct pte *t, bool ro);
Index: kernel/arch/sparc64/include/mm/sun4v/tte.h
===================================================================
--- kernel/arch/sparc64/include/mm/sun4v/tte.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/sun4v/tte.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup sparc64mm
+/** @addtogroup sparc64mm	
  * @{
  */
Index: kernel/arch/sparc64/include/mm/tlb.h
===================================================================
--- kernel/arch/sparc64/include/mm/tlb.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/tlb.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -36,5 +36,4 @@
 #define KERN_sparc64_TLB_H_
 
-
 #if defined (SUN4U)
 #include <arch/mm/sun4u/tlb.h>
Index: kernel/arch/sparc64/include/mm/tsb.h
===================================================================
--- kernel/arch/sparc64/include/mm/tsb.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/mm/tsb.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -36,9 +36,134 @@
 #define KERN_sparc64_TSB_H_
 
-#if defined (SUN4U)
-#include <arch/mm/sun4u/tsb.h>
-#elif defined (SUN4V)
-#include <arch/mm/sun4v/tsb.h>
+/*
+ * ITSB abd DTSB will claim 64K of memory, which
+ * is a nice number considered that it is one of
+ * the page sizes supported by hardware, which,
+ * again, is nice because TSBs need to be locked
+ * in TLBs - only one TLB entry will do.
+ */
+#define TSB_SIZE			2	/* when changing this, change
+						 * as.c as well */
+#define ITSB_ENTRY_COUNT		(512 * (1 << TSB_SIZE))
+#define DTSB_ENTRY_COUNT		(512 * (1 << TSB_SIZE))
+
+#define TSB_TAG_TARGET_CONTEXT_SHIFT	48
+
+#ifndef __ASM__
+
+#include <arch/mm/tte.h>
+#include <arch/mm/mmu.h>
+#include <arch/types.h>
+
+/** TSB Base register. */
+typedef union tsb_base_reg {
+	uint64_t value;
+	struct {
+		uint64_t base : 51;	/**< TSB base address, bits 63:13. */
+		unsigned split : 1;	/**< Split vs. common TSB for 8K and 64K
+					 * pages. HelenOS uses only 8K pages
+					 * for user mappings, so we always set
+					 * this to 0.
+					 */
+		unsigned : 9;
+		unsigned size : 3;	/**< TSB size. Number of entries is
+					 * 512 * 2^size. */
+	} __attribute__ ((packed));
+} tsb_base_reg_t;
+
+/** Read ITSB Base register.
+ *
+ * @return Content of the ITSB Base register.
+ */
+static inline uint64_t itsb_base_read(void)
+{
+	return asi_u64_read(ASI_IMMU, VA_IMMU_TSB_BASE);
+}
+
+/** Read DTSB Base register.
+ *
+ * @return Content of the DTSB Base register.
+ */
+static inline uint64_t dtsb_base_read(void)
+{
+	return asi_u64_read(ASI_DMMU, VA_DMMU_TSB_BASE);
+}
+
+/** Write ITSB Base register.
+ *
+ * @param v New content of the ITSB Base register.
+ */
+static inline void itsb_base_write(uint64_t v)
+{
+	asi_u64_write(ASI_IMMU, VA_IMMU_TSB_BASE, v);
+}
+
+/** Write DTSB Base register.
+ *
+ * @param v New content of the DTSB Base register.
+ */
+static inline void dtsb_base_write(uint64_t v)
+{
+	asi_u64_write(ASI_DMMU, VA_DMMU_TSB_BASE, v);
+}
+
+#if defined (US3)
+
+/** Write DTSB Primary Extension register.
+ *
+ * @param v New content of the DTSB Primary Extension register.
+ */
+static inline void dtsb_primary_extension_write(uint64_t v)
+{
+	asi_u64_write(ASI_DMMU, VA_DMMU_PRIMARY_EXTENSION, v);
+}
+
+/** Write DTSB Secondary Extension register.
+ *
+ * @param v New content of the DTSB Secondary Extension register.
+ */
+static inline void dtsb_secondary_extension_write(uint64_t v)
+{
+	asi_u64_write(ASI_DMMU, VA_DMMU_SECONDARY_EXTENSION, v);
+}
+
+/** Write DTSB Nucleus Extension register.
+ *
+ * @param v New content of the DTSB Nucleus Extension register.
+ */
+static inline void dtsb_nucleus_extension_write(uint64_t v)
+{
+	asi_u64_write(ASI_DMMU, VA_DMMU_NUCLEUS_EXTENSION, v);
+}
+
+/** Write ITSB Primary Extension register.
+ *
+ * @param v New content of the ITSB Primary Extension register.
+ */
+static inline void itsb_primary_extension_write(uint64_t v)
+{
+	asi_u64_write(ASI_IMMU, VA_IMMU_PRIMARY_EXTENSION, v);
+}
+
+/** Write ITSB Nucleus Extension register.
+ *
+ * @param v New content of the ITSB Nucleus Extension register.
+ */
+static inline void itsb_nucleus_extension_write(uint64_t v)
+{
+	asi_u64_write(ASI_IMMU, VA_IMMU_NUCLEUS_EXTENSION, v);
+}
+
 #endif
+
+/* Forward declarations. */
+struct as;
+struct pte;
+
+extern void tsb_invalidate(struct as *as, uintptr_t page, size_t pages);
+extern void itsb_pte_copy(struct pte *t, size_t index);
+extern void dtsb_pte_copy(struct pte *t, size_t index, bool ro);
+
+#endif /* !def __ASM__ */
 
 #endif
Index: rnel/arch/sparc64/include/smp/sun4v/smp.h
===================================================================
--- kernel/arch/sparc64/include/smp/sun4v/smp.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2009 Pavel Rimsky
- * 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 sparc64	
- * @{
- */
-/**
- * @file
- * @brief	sun4v smp functions
- */
-
-#ifndef KERN_sparc64_sun4v_SMP_H_
-#define KERN_sparc64_sun4v_SMP_H_
-
-#include <typedefs.h>
-#include <arch/sun4v/cpu.h>
-
-extern bool calculate_optimal_nrdy(exec_unit_t *);
-
-#endif
-
-/** @}
- */
Index: kernel/arch/sparc64/include/sun4v/arch.h
===================================================================
--- kernel/arch/sparc64/include/sun4v/arch.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/sun4v/arch.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -58,4 +58,9 @@
 #define SCRATCHPAD_WBUF		0x18
 
+//MH - remove when cpu.h is forked
+#define ASI_NUCLEUS_QUAD_LDD	0x24	/** ASI for 16-byte atomic loads. */
+#define ASI_DCACHE_TAG		0x47	/** ASI D-Cache Tag. */
+#define ASI_ICBUS_CONFIG	0x4a	/** ASI of the UPA_CONFIG/FIREPLANE_CONFIG register. */
+
 #endif
 
Index: kernel/arch/sparc64/include/sun4v/cpu.h
===================================================================
--- kernel/arch/sparc64/include/sun4v/cpu.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/sun4v/cpu.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -44,9 +44,7 @@
 #ifndef __ASM__
 
-#include <atomic.h>
-#include <synch/spinlock.h>
-
 struct cpu;
 
+/*
 typedef struct {
 	uint64_t exec_unit_id;
@@ -57,4 +55,5 @@
 	SPINLOCK_DECLARE(proposed_nrdy_lock);
 } exec_unit_t;
+*/
 
 typedef struct cpu_arch {
@@ -64,7 +63,7 @@
 					     generated when the TICK register
 					     matches this value. */
-	exec_unit_t *exec_unit;		/**< Physical core. */
-	unsigned long proposed_nrdy;	/**< Proposed No. of ready threads
-					     so that cores are equally balanced. */
+	//exec_unit_t *exec_unit;		/**< Physical core. */
+	//unsigned long proposed_nrdy;	/**< Proposed No. of ready threads
+	//				     so that cores are equally balanced. */
 } cpu_arch_t;
 
Index: kernel/arch/sparc64/include/sun4v/hypercall.h
===================================================================
--- kernel/arch/sparc64/include/sun4v/hypercall.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/sun4v/hypercall.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -75,22 +75,22 @@
 
 /* return codes */
-#define HV_EOK			0	/**< Successful return */
-#define HV_ENOCPU		1	/**< Invalid CPU id */
-#define HV_ENORADDR		2	/**< Invalid real address */
-#define HV_ENOINTR		3	/**< Invalid interrupt id */
-#define HV_EBADPGSZ		4	/**< Invalid pagesize encoding */
-#define HV_EBADTSB		5	/**< Invalid TSB description */
-#define	HV_EINVAL		6	/**< Invalid argument */
-#define HV_EBADTRAP		7	/**< Invalid function number */
-#define HV_EBADALIGN		8	/**< Invalid address alignment */
-#define HV_EWOULDBLOCK		9	/**< Cannot complete operation without blocking */
-#define HV_ENOACCESS		10	/**< No access to specified resource */
-#define HV_EIO			11	/**< I/O Error */
-#define HV_ECPUERROR		12	/**< CPU is in error state */
-#define HV_ENOTSUPPORTED	13	/**< Function not supported */
-#define HV_ENOMAP		14	/**< No mapping found */
-#define HV_ETOOMANY		15	/**< Too many items specified / limit reached */
-#define HV_ECHANNEL		16	/**< Invalid LDC channel */
-#define HV_EBUSY		17	/**< Operation failed as resource is otherwise busy */
+#define EOK		0	/**< Successful return */
+#define ENOCPU		1	/**< Invalid CPU id */
+#define ENORADDR	2	/**< Invalid real address */
+#define ENOINTR		3	/**< Invalid interrupt id */
+#define EBADPGSZ	4	/**< Invalid pagesize encoding */
+#define EBADTSB		5	/**< Invalid TSB description */
+#define	EINVAL		6	/**< Invalid argument */
+#define EBADTRAP	7	/**< Invalid function number */
+#define EBADALIGN	8	/**< Invalid address alignment */
+#define EWOULDBLOCK	9	/**< Cannot complete operation without blocking */
+#define ENOACCESS	10	/**< No access to specified resource */
+#define EIO		11	/**< I/O Error */
+#define ECPUERROR	12	/**< CPU is in error state */
+#define ENOTSUPPORTED	13	/**< Function not supported */
+#define ENOMAP		14	/**< No mapping found */
+#define ETOOMANY	15	/**< Too many items specified / limit reached */
+#define ECHANNEL	16	/**< Invalid LDC channel */
+#define EBUSY		17	/**< Operation failed as resource is otherwise busy */
 
 
@@ -190,25 +190,11 @@
 __hypercall_fast_ret1(const uint64_t p1, const uint64_t p2, const uint64_t p3,
     const uint64_t p4, const uint64_t p5, const uint64_t function_number,
-    uint64_t *ret1)
+    uint64_t * const ret1)
 {
-	register uint64_t a6 asm("o5") = function_number;
-	register uint64_t a1 asm("o0") = p1;
-	register uint64_t a2 asm("o1") = p2;
-	register uint64_t a3 asm("o2") = p3;
-	register uint64_t a4 asm("o3") = p4;
-	register uint64_t a5 asm("o4") = p5;
-	
-	asm volatile (
-		"ta %8\n"
-		: "=r" (a1), "=r" (a2)
-		: "r" (a1), "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6),
-		  "i" (FAST_TRAP)
-		: "memory"
-	);
-
-	if (ret1)
-		*ret1 = a2;
-
-	return a1;
+	uint64_t errno = __hypercall_fast(p1, p2, p3, p4, p5, function_number);
+	if (ret1 != NULL) {
+		asm volatile ("mov %%o1, %0\n" : "=r" (*ret1));
+	}
+	return errno;
 }
 
Index: kernel/arch/sparc64/include/sun4v/ipi.h
===================================================================
--- kernel/arch/sparc64/include/sun4v/ipi.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/sun4v/ipi.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -38,8 +38,7 @@
 #define KERN_sparc64_sun4v_IPI_H_
 
-#include <arch/types.h>
-
-extern uint64_t ipi_brodcast_to(void (*)(void), uint16_t cpu_list[], uint64_t);
-extern uint64_t ipi_unicast_to(void (*)(void), uint16_t);
+uint64_t ipi_brodcast_to(void (*func)(void), uint16_t cpu_list[MAX_NUM_STRANDS],
+		uint64_t list_size);
+uint64_t ipi_unicast_to(void (*func)(void), uint16_t cpu_id);
 
 #endif
Index: kernel/arch/sparc64/include/trap/exception.h
===================================================================
--- kernel/arch/sparc64/include/trap/exception.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/trap/exception.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -38,16 +38,9 @@
 
 #define TT_INSTRUCTION_ACCESS_EXCEPTION		0x08
-#define TT_INSTRUCTION_ACCESS_MMU_MISS		0x09
 #define TT_INSTRUCTION_ACCESS_ERROR		0x0a
-#define	TT_IAE_UNAUTH_ACCESS			0x0b
-#define	TT_IAE_NFO_PAGE				0x0c
 #define TT_ILLEGAL_INSTRUCTION			0x10
 #define TT_PRIVILEGED_OPCODE			0x11
 #define TT_UNIMPLEMENTED_LDD			0x12
 #define TT_UNIMPLEMENTED_STD			0x13
-#define TT_DAE_INVALID_ASI			0x14
-#define TT_DAE_PRIVILEGE_VIOLATION		0x15
-#define TT_DAE_NC_PAGE				0x16
-#define TT_DAE_NFO_PAGE				0x17
 #define TT_FP_DISABLED				0x20
 #define TT_FP_EXCEPTION_IEEE_754		0x21
@@ -56,5 +49,4 @@
 #define TT_DIVISION_BY_ZERO			0x28
 #define TT_DATA_ACCESS_EXCEPTION		0x30
-#define TT_DATA_ACCESS_MMU_MISS			0x31
 #define TT_DATA_ACCESS_ERROR			0x32
 #define TT_MEM_ADDRESS_NOT_ALIGNED		0x34
Index: kernel/arch/sparc64/include/trap/interrupt.h
===================================================================
--- kernel/arch/sparc64/include/trap/interrupt.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/trap/interrupt.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -32,9 +32,66 @@
 /** 
  * @file
- * @brief This file contains level N interrupt and inter-processor interrupt
- * trap handler.
+ * @brief This file contains interrupt vector trap handler.
  */
-#ifndef KERN_sparc64_INTERRUPT_TRAP_H_
-#define KERN_sparc64_INTERRUPT_TRAP_H_
+
+#ifndef KERN_sparc64_TRAP_INTERRUPT_H_
+#define KERN_sparc64_TRAP_INTERRUPT_H_
+
+#include <arch/trap/trap_table.h>
+#include <arch/stack.h>
+
+/* IMAP register bits */
+#define IGN_MASK	0x7c0
+#define INO_MASK	0x1f
+#define IMAP_V_MASK	(1ULL << 31)
+
+#define IGN_SHIFT	6
+
+
+/* Interrupt ASI registers. */
+#define ASI_INTR_W			0x77
+#define ASI_INTR_DISPATCH_STATUS	0x48
+#define ASI_INTR_R			0x7f
+#define ASI_INTR_RECEIVE		0x49
+
+/* VA's used with ASI_INTR_W register. */
+#if defined (US)
+#define ASI_UDB_INTR_W_DATA_0	0x40
+#define ASI_UDB_INTR_W_DATA_1	0x50
+#define ASI_UDB_INTR_W_DATA_2	0x60
+#elif defined (US3)
+#define VA_INTR_W_DATA_0	0x40
+#define VA_INTR_W_DATA_1	0x48
+#define VA_INTR_W_DATA_2	0x50
+#define VA_INTR_W_DATA_3	0x58
+#define VA_INTR_W_DATA_4	0x60
+#define VA_INTR_W_DATA_5	0x68
+#define VA_INTR_W_DATA_6	0x80
+#define VA_INTR_W_DATA_7	0x88
+#endif
+#define VA_INTR_W_DISPATCH	0x70
+
+/* VA's used with ASI_INTR_R register. */
+#if defined(US)
+#define ASI_UDB_INTR_R_DATA_0	0x40
+#define ASI_UDB_INTR_R_DATA_1	0x50
+#define ASI_UDB_INTR_R_DATA_2	0x60
+#elif defined (US3)
+#define VA_INTR_R_DATA_0	0x40
+#define VA_INTR_R_DATA_1	0x48
+#define VA_INTR_R_DATA_2	0x50
+#define VA_INTR_R_DATA_3	0x58
+#define VA_INTR_R_DATA_4	0x60
+#define VA_INTR_R_DATA_5	0x68
+#define VA_INTR_R_DATA_6	0x80
+#define VA_INTR_R_DATA_7	0x88
+#endif
+
+/* Shifts in the Interrupt Vector Dispatch virtual address. */
+#define INTR_VEC_DISPATCH_MID_SHIFT	14
+
+/* Bits in the Interrupt Dispatch Status register. */
+#define INTR_DISPATCH_STATUS_NACK	0x2
+#define INTR_DISPATCH_STATUS_BUSY	0x1
 
 #define TT_INTERRUPT_LEVEL_1			0x41
@@ -54,13 +111,8 @@
 #define TT_INTERRUPT_LEVEL_15			0x4f
 
+#define TT_INTERRUPT_VECTOR_TRAP		0x60
+
 #define INTERRUPT_LEVEL_N_HANDLER_SIZE		TRAP_TABLE_ENTRY_SIZE
-
-/* IMAP register bits */
-#define IGN_MASK	0x7c0
-#define INO_MASK	0x1f
-#define IMAP_V_MASK	(1ULL << 31)
-
-#define IGN_SHIFT	6
-
+#define INTERRUPT_VECTOR_TRAP_HANDLER_SIZE	TRAP_TABLE_ENTRY_SIZE
 
 #ifdef __ASM__
@@ -69,5 +121,9 @@
 	PREEMPTIBLE_HANDLER exc_dispatch
 .endm
-#endif
+
+.macro INTERRUPT_VECTOR_TRAP_HANDLER
+	PREEMPTIBLE_HANDLER interrupt
+.endm
+#endif /* __ASM__ */
 
 #ifndef __ASM__
@@ -78,11 +134,4 @@
 #endif /* !def __ASM__ */
 
-
-#if defined (SUN4U)
-#include <arch/trap/sun4u/interrupt.h>
-#elif defined (SUN4V)
-#include <arch/trap/sun4v/interrupt.h>
-#endif
-
 #endif
 
Index: kernel/arch/sparc64/include/trap/regwin.h
===================================================================
--- kernel/arch/sparc64/include/trap/regwin.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/trap/regwin.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -183,5 +183,4 @@
 	add %l0, 1, %l0
 	wrpr %l0, 0, %cleanwin
-#if defined(SUN4U)
 	mov %r0, %l0
 	mov %r0, %l1
@@ -200,12 +199,11 @@
 	mov %r0, %o6
 	mov %r0, %o7
-#endif
 	retry
 .endm
 #endif /* __ASM__ */
 
-#if defined(SUN4U)
+#if defined (SUN4U)
 #include <arch/trap/sun4u/regwin.h>
-#elif defined(SUN4V)
+#elif defined (SUN4V)
 #include <arch/trap/sun4v/regwin.h>
 #endif
Index: rnel/arch/sparc64/include/trap/sun4u/interrupt.h
===================================================================
--- kernel/arch/sparc64/include/trap/sun4u/interrupt.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/*
- * Copyright (c) 2005 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 sparc64interrupt
- * @{
- */
-/** 
- * @file
- * @brief This file contains interrupt vector trap handler.
- */
-
-#ifndef KERN_sparc64_TRAP_SUN4U_INTERRUPT_H_
-#define KERN_sparc64_TRAP_SUN4U_INTERRUPT_H_
-
-#include <arch/trap/trap_table.h>
-#include <arch/stack.h>
-
-
-/* Interrupt ASI registers. */
-#define ASI_INTR_W			0x77
-#define ASI_INTR_DISPATCH_STATUS	0x48
-#define ASI_INTR_R			0x7f
-#define ASI_INTR_RECEIVE		0x49
-
-/* VA's used with ASI_INTR_W register. */
-#if defined (US)
-#define ASI_UDB_INTR_W_DATA_0	0x40
-#define ASI_UDB_INTR_W_DATA_1	0x50
-#define ASI_UDB_INTR_W_DATA_2	0x60
-#elif defined (US3)
-#define VA_INTR_W_DATA_0	0x40
-#define VA_INTR_W_DATA_1	0x48
-#define VA_INTR_W_DATA_2	0x50
-#define VA_INTR_W_DATA_3	0x58
-#define VA_INTR_W_DATA_4	0x60
-#define VA_INTR_W_DATA_5	0x68
-#define VA_INTR_W_DATA_6	0x80
-#define VA_INTR_W_DATA_7	0x88
-#endif
-#define VA_INTR_W_DISPATCH	0x70
-
-/* VA's used with ASI_INTR_R register. */
-#if defined(US)
-#define ASI_UDB_INTR_R_DATA_0	0x40
-#define ASI_UDB_INTR_R_DATA_1	0x50
-#define ASI_UDB_INTR_R_DATA_2	0x60
-#elif defined (US3)
-#define VA_INTR_R_DATA_0	0x40
-#define VA_INTR_R_DATA_1	0x48
-#define VA_INTR_R_DATA_2	0x50
-#define VA_INTR_R_DATA_3	0x58
-#define VA_INTR_R_DATA_4	0x60
-#define VA_INTR_R_DATA_5	0x68
-#define VA_INTR_R_DATA_6	0x80
-#define VA_INTR_R_DATA_7	0x88
-#endif
-
-/* Shifts in the Interrupt Vector Dispatch virtual address. */
-#define INTR_VEC_DISPATCH_MID_SHIFT	14
-
-/* Bits in the Interrupt Dispatch Status register. */
-#define INTR_DISPATCH_STATUS_NACK	0x2
-#define INTR_DISPATCH_STATUS_BUSY	0x1
-
-#define TT_INTERRUPT_VECTOR_TRAP		0x60
-
-#define INTERRUPT_VECTOR_TRAP_HANDLER_SIZE	TRAP_TABLE_ENTRY_SIZE
-
-#ifdef __ASM__
-.macro INTERRUPT_VECTOR_TRAP_HANDLER
-	PREEMPTIBLE_HANDLER interrupt
-.endm
-#endif /* __ASM__ */
-
-
-#endif
-
-/** @}
- */
Index: rnel/arch/sparc64/include/trap/sun4v/interrupt.h
===================================================================
--- kernel/arch/sparc64/include/trap/sun4v/interrupt.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Copyright (c) 2005 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 sparc64interrupt
- * @{
- */
-/** 
- * @file
- * @brief This file contains interrupt vector trap handler.
- */
-
-#ifndef KERN_sparc64_TRAP_SUN4V_INTERRUPT_H_
-#define KERN_sparc64_TRAP_SUN4V_INTERRUPT_H_
-
-#ifndef __ASM__
-
-extern void sun4v_ipi_init(void);
-extern void cpu_mondo(void);
-
-#endif
-
-#endif
-
-/** @}
- */
Index: kernel/arch/sparc64/include/trap/sun4v/mmu.h
===================================================================
--- kernel/arch/sparc64/include/trap/sun4v/mmu.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/trap/sun4v/mmu.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -36,6 +36,6 @@
  */
 
-#ifndef KERN_sparc64_sun4v_MMU_TRAP_H_
-#define KERN_sparc64_sun4v_MMU_TRAP_H_
+#ifndef KERN_sparc64_SUN4V_MMU_TRAP_H_
+#define KERN_sparc64_SUN4V_MMU_TRAP_H_
 
 #include <arch/stack.h>
@@ -121,7 +121,8 @@
 	 * but this time its handler accesse memory which IS mapped.
 	 */
-	.if (\tl > 0)
-		wrpr %g0, 1, %tl
-	.endif
+0:
+.if (\tl > 0)
+	wrpr %g0, 1, %tl
+.endif
 
 	/*
Index: kernel/arch/sparc64/include/trap/trap_table.h
===================================================================
--- kernel/arch/sparc64/include/trap/trap_table.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/trap/trap_table.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -101,5 +101,5 @@
 .macro PREEMPTIBLE_HANDLER f
 	sethi %hi(\f), %g1
-	b preemptible_handler
+	ba %xcc, preemptible_handler
 	or %g1, %lo(\f), %g1
 .endm
Index: kernel/arch/sparc64/include/types.h
===================================================================
--- kernel/arch/sparc64/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup sparc64
+/** @addtogroup sparc64	
  * @{
  */
@@ -55,5 +55,4 @@
 typedef uint64_t unative_t;
 typedef int64_t native_t;
-typedef uint64_t atomic_count_t;
 
 typedef struct {
Index: kernel/arch/sparc64/src/cpu/sun4u/cpu.c
===================================================================
--- kernel/arch/sparc64/src/cpu/sun4u/cpu.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/cpu/sun4u/cpu.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -129,6 +129,5 @@
 void cpu_print_report(cpu_t *m)
 {
-	const char *manuf;
-	const char *impl;
+	char *manuf, *impl;
 
 	switch (m->arch.ver.manuf) {
Index: kernel/arch/sparc64/src/cpu/sun4v/cpu.c
===================================================================
--- kernel/arch/sparc64/src/cpu/sun4v/cpu.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/cpu/sun4v/cpu.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -1,5 +1,4 @@
 /*
  * Copyright (c) 2005 Jakub Jermar
- * Copyright (c) 2009 Pavel Rimsky
  * All rights reserved.
  *
@@ -41,5 +40,6 @@
 #include <arch/sun4v/md.h>
 #include <arch/sun4v/hypercall.h>
-#include <arch/trap/sun4v/interrupt.h>
+
+//#include <arch/trap/sun4v/interrupt.h>
 
 /** Perform sparc64 specific initialization of the processor structure for the
@@ -51,5 +51,6 @@
 	__hypercall_fast_ret1(0, 0, 0, 0, 0, CPU_MYID, &myid);
 
-	CPU->arch.id = myid;
+	//MH
+	//CPU->arch.id = myid;
 
 	md_node_t node = md_get_root();
@@ -73,6 +74,6 @@
 		
 	tick_init();
-
-	sun4v_ipi_init();
+    	//MH - uncomment later
+	//sun4v_ipi_init();
 }
 
@@ -95,5 +96,5 @@
 {
 	printf("cpu%d: Niagara (%d MHz)\n", m->id,
-	    m->arch.clock_frequency / 1000000);
+		m->arch.clock_frequency / 1000000);
 }
 
Index: kernel/arch/sparc64/src/drivers/niagara.c
===================================================================
--- kernel/arch/sparc64/src/drivers/niagara.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/drivers/niagara.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -104,5 +104,5 @@
 static inline void do_putchar(const char c) {
 	/* repeat until the buffer is non-full */
-	while (__hypercall_fast1(CONS_PUTCHAR, c) == HV_EWOULDBLOCK)
+	while (__hypercall_fast1(CONS_PUTCHAR, c) == EWOULDBLOCK)
 		;
 }
@@ -111,7 +111,4 @@
 static void niagara_putchar(outdev_t *dev, const wchar_t ch, bool silent)
 {
-        if (silent)
-            return;
-
 	do_putchar(ch);
 	if (ch == '\n')
@@ -139,5 +136,5 @@
 
 	/* read character from keyboard, send it to upper layers of HelenOS */
-	if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == HV_EOK) {
+	if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) {
 		if (!silent) {
 			/* kconsole active, send the character to kernel */
Index: kernel/arch/sparc64/src/mm/sun4u/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4u/tlb.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/mm/sun4u/tlb.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -64,5 +64,5 @@
     tlb_tag_access_reg_t, const char *);
 
-const char *context_encoding[] = {
+char *context_encoding[] = {
 	"Primary",
 	"Secondary",
@@ -476,5 +476,5 @@
 }
 
-void describe_dmmu_fault(void)
+void dump_sfsr_and_sfar(void)
 {
 	tlb_sfsr_reg_t sfsr;
@@ -499,27 +499,4 @@
 }
 
-void dump_sfsr_and_sfar(void)
-{
-	tlb_sfsr_reg_t sfsr;
-	uintptr_t sfar;
-
-	sfsr.value = dtlb_sfsr_read();
-	sfar = dtlb_sfar_read();
-	
-#if defined (US)
-	printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, "
-	    "fv=%d\n", sfsr.asi, sfsr.ft, sfsr.e, sfsr.ct, sfsr.pr, sfsr.w,
-	    sfsr.ow, sfsr.fv);
-#elif defined (US3)
-	printf("DTLB SFSR: nf=%d, asi=%#x, tm=%d, ft=%#x, e=%d, ct=%d, pr=%d, "
-	    "w=%d, ow=%d, fv=%d\n", sfsr.nf, sfsr.asi, sfsr.tm, sfsr.ft,
-	    sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv);
-#endif
-	    
-	printf("DTLB SFAR: address=%p\n", sfar);
-	
-	dtlb_sfsr_write(0);
-}
-
 #if defined (US)
 /** Invalidate all unlocked ITLB and DTLB entries. */
Index: kernel/arch/sparc64/src/mm/sun4v/as.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4v/as.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/mm/sun4v/as.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -1,5 +1,4 @@
 /*
  * Copyright (c) 2006 Jakub Jermar
- * Copyright (c) 2009 Pavel Rimsky
  * All rights reserved.
  *
@@ -35,5 +34,4 @@
 
 #include <arch/mm/as.h>
-#include <arch/mm/pagesize.h>
 #include <arch/mm/tlb.h>
 #include <genarch/mm/page_ht.h>
@@ -41,5 +39,4 @@
 #include <debug.h>
 #include <config.h>
-#include <arch/sun4v/hypercall.h>
 
 #ifdef CONFIG_TSB
@@ -89,5 +86,5 @@
 {
 #ifdef CONFIG_TSB
-	size_t cnt = (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH;
+	count_t cnt = (TSB_ENTRY_COUNT * sizeof(tsb_entry_t)) >> FRAME_WIDTH;
 	frame_free((uintptr_t) as->arch.tsb_description.tsb_base);
 	return cnt;
@@ -115,23 +112,4 @@
 {
 	mmu_secondary_context_write(as->asid);
-#ifdef CONFIG_TSB	
-	uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
-
-	ASSERT(as->arch.tsb_description.tsb_base);
-	uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base);
-		
-	if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
-		/*
-		 * TSBs were allocated from memory not covered
-		 * by the locked 4M kernel DTLB entry. We need
-		 * to map both TSBs explicitly.
-		 */
-		mmu_demap_page(tsb, 0, MMU_FLAG_DTLB);
-		dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true);
-	}
-
-	__hypercall_fast2(MMU_TSB_CTXNON0, 1, KA2PA(&(as->arch.tsb_description)));
-	
-#endif
 }
 
@@ -156,7 +134,7 @@
 	uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH);
 
-	ASSERT(as->arch.tsb_description.tsb_base);
+	ASSERT(as->arch.itsb && as->arch.dtsb);
 
-	uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base);
+	uintptr_t tsb = (uintptr_t) as->arch.itsb;
 		
 	if (!overlaps(tsb, 8 * MMU_PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) {
@@ -166,5 +144,5 @@
 		 * to demap the entry installed by as_install_arch().
 		 */
-		__hypercall_fast3(MMU_UNMAP_PERM_ADDR, tsb, 0, MMU_FLAG_DTLB);
+		dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb);
 	}
 #endif
Index: kernel/arch/sparc64/src/mm/sun4v/frame.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4v/frame.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/mm/sun4v/frame.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -41,4 +41,6 @@
 #include <macros.h>
 
+uintptr_t last_frame = NULL;
+
 /** Create memory zones according to information stored in bootinfo.
  *
@@ -66,4 +68,6 @@
 			    SIZE2FRAMES(ALIGN_DOWN(size, FRAME_SIZE)),
 			    confdata, 0);
+			last_frame = max(last_frame, start + ALIGN_UP(size,
+			    FRAME_SIZE));
 		}
 
@@ -76,4 +80,7 @@
 		frame_mark_unavailable(ADDR2PFN(KA2PA(PFN2ADDR(0))), 1);
 	}
+
+//MH
+//	end_of_identity = PA2KA(last_frame);
 }
 
Index: kernel/arch/sparc64/src/mm/sun4v/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4v/tlb.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/mm/sun4v/tlb.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -89,5 +89,5 @@
  * field of the MMU fault status area is i.
  */
-static const char *fault_types[] = {
+char *fault_types[] = {
 	"unknown",
 	"fast miss",
@@ -107,4 +107,5 @@
 	"invalid page size"
 	};
+	
 
 /** Array of MMU fault status areas. */
@@ -405,5 +406,5 @@
 	uint64_t errno =  __hypercall_fast3(MMU_DEMAP_ALL, 0, 0,
 		MMU_FLAG_DTLB | MMU_FLAG_ITLB);
-	if (errno != HV_EOK) {
+	if (errno != EOK) {
 		panic("Error code = %d.\n", errno);
 	}
Index: kernel/arch/sparc64/src/mm/sun4v/tsb.c
===================================================================
--- kernel/arch/sparc64/src/mm/sun4v/tsb.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/mm/sun4v/tsb.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -1,5 +1,4 @@
 /*
  * Copyright (c) 2006 Jakub Jermar
- * Copyright (c) 2009 Pavel Rimsky
  * All rights reserved.
  *
@@ -35,5 +34,4 @@
 
 #include <arch/mm/tsb.h>
-#include <arch/mm/pagesize.h>
 #include <arch/mm/tlb.h>
 #include <arch/mm/page.h>
@@ -51,27 +49,30 @@
  * portions of both TSBs are invalidated at a time.
  *
- * @param as	Address space.
- * @param page 	First page to invalidate in TSB.
- * @param pages Number of pages to invalidate. Value of (count_t) -1 means the
- * 		whole TSB.
+ * @param as Address space.
+ * @param page First page to invalidate in TSB.
+ * @param pages Number of pages to invalidate. Value of (size_t) -1 means the
+ * 	whole TSB.
  */
 void tsb_invalidate(as_t *as, uintptr_t page, size_t pages)
 {
-	size_t i0, i;
+	size_t i0;
+	size_t i;
 	size_t cnt;
 	
-	ASSERT(as->arch.tsb_description.tsb_base);
+	ASSERT(as->arch.itsb && as->arch.dtsb);
 	
 	i0 = (page >> MMU_PAGE_WIDTH) & TSB_INDEX_MASK;
-	ASSERT(i0 < TSB_ENTRY_COUNT);
+	ASSERT(i0 < ITSB_ENTRY_COUNT && i0 < DTSB_ENTRY_COUNT);
 
-	if (pages == (size_t) - 1 || (pages) > TSB_ENTRY_COUNT)
-		cnt = TSB_ENTRY_COUNT;
+	if (pages == (size_t) -1 || (pages * 2) > ITSB_ENTRY_COUNT)
+		cnt = ITSB_ENTRY_COUNT;
 	else
-		cnt = pages;
+		cnt = pages * 2;
 	
 	for (i = 0; i < cnt; i++) {
-		((tsb_entry_t *) PA2KA(as->arch.tsb_description.tsb_base))[
-			(i0 + i) & (TSB_ENTRY_COUNT - 1)].data.v = false;
+		as->arch.itsb[(i0 + i) & (ITSB_ENTRY_COUNT - 1)].tag.invalid =
+		    true;
+		as->arch.dtsb[(i0 + i) & (DTSB_ENTRY_COUNT - 1)].tag.invalid =
+		    true;
 	}
 }
@@ -80,15 +81,19 @@
  *
  * @param t 	Software PTE.
+ * @param index	Zero if lower 8K-subpage, one if higher 8K subpage.
  */
-void itsb_pte_copy(pte_t *t)
+void itsb_pte_copy(pte_t *t, size_t index)
 {
+#if 0
 	as_t *as;
 	tsb_entry_t *tsb;
 	size_t entry;
 
+	ASSERT(index <= 1);
+	
 	as = t->as;
-	entry = (t->page >> MMU_PAGE_WIDTH) & TSB_INDEX_MASK; 
-	ASSERT(entry < TSB_ENTRY_COUNT);
-	tsb = &((tsb_entry_t *) PA2KA(as->arch.tsb_description.tsb_base))[entry];
+	entry = ((t->page >> MMU_PAGE_WIDTH) + index) & TSB_INDEX_MASK; 
+	ASSERT(entry < ITSB_ENTRY_COUNT);
+	tsb = &as->arch.itsb[entry];
 
 	/*
@@ -98,25 +103,24 @@
 	 */
 
-	tsb->data.v = false;
+	tsb->tag.invalid = true;	/* invalidate the entry
+					 * (tag target has this
+					 * set to 0) */
 
 	write_barrier();
 
+	tsb->tag.context = as->asid;
+	/* the shift is bigger than PAGE_WIDTH, do not bother with index  */
 	tsb->tag.va_tag = t->page >> VA_TAG_PAGE_SHIFT;
-
 	tsb->data.value = 0;
-	tsb->data.nfo = false;
-	tsb->data.ra = t->frame >> MMU_FRAME_WIDTH;
-	tsb->data.ie = false;
-	tsb->data.e = false;
+	tsb->data.size = PAGESIZE_8K;
+	tsb->data.pfn = (t->frame >> MMU_FRAME_WIDTH) + index;
 	tsb->data.cp = t->c;	/* cp as cache in phys.-idxed, c as cacheable */
-	tsb->data.cv = false;
 	tsb->data.p = t->k;	/* p as privileged, k as kernel */
-	tsb->data.x = true;
-	tsb->data.w = false;
-	tsb->data.size = PAGESIZE_8K;
+	tsb->data.v = t->p;	/* v as valid, p as present */
 	
 	write_barrier();
 	
-	tsb->data.v = t->p;	/* v as valid, p as present */
+	tsb->tag.invalid = false;	/* mark the entry as valid */
+#endif
 }
 
@@ -124,16 +128,20 @@
  *
  * @param t	Software PTE.
+ * @param index	Zero if lower 8K-subpage, one if higher 8K-subpage.
  * @param ro	If true, the mapping is copied read-only.
  */
-void dtsb_pte_copy(pte_t *t, bool ro)
+void dtsb_pte_copy(pte_t *t, size_t index, bool ro)
 {
+#if 0
 	as_t *as;
 	tsb_entry_t *tsb;
 	size_t entry;
+	
+	ASSERT(index <= 1);
 
 	as = t->as;
-	entry = (t->page >> MMU_PAGE_WIDTH) & TSB_INDEX_MASK; 
-	ASSERT(entry < TSB_ENTRY_COUNT);
-	tsb = &((tsb_entry_t *) PA2KA(as->arch.tsb_description.tsb_base))[entry];
+	entry = ((t->page >> MMU_PAGE_WIDTH) + index) & TSB_INDEX_MASK;
+	ASSERT(entry < DTSB_ENTRY_COUNT);
+	tsb = &as->arch.dtsb[entry];
 
 	/*
@@ -143,29 +151,31 @@
 	 */
 
-	tsb->data.v = false;
+	tsb->tag.invalid = true;	/* invalidate the entry
+					 * (tag target has this
+					 * set to 0) */
 
 	write_barrier();
 
+	tsb->tag.context = as->asid;
+	/* the shift is bigger than PAGE_WIDTH, do not bother with index */
 	tsb->tag.va_tag = t->page >> VA_TAG_PAGE_SHIFT;
-
 	tsb->data.value = 0;
-	tsb->data.nfo = false;
-	tsb->data.ra = t->frame >> MMU_FRAME_WIDTH;
-	tsb->data.ie = false;
-	tsb->data.e = false;
-	tsb->data.cp = t->c;	/* cp as cache in phys.-idxed, c as cacheable */
+	tsb->data.size = PAGESIZE_8K;
+	tsb->data.pfn = (t->frame >> MMU_FRAME_WIDTH) + index;
+	tsb->data.cp = t->c;
 #ifdef CONFIG_VIRT_IDX_DCACHE
 	tsb->data.cv = t->c;
 #endif /* CONFIG_VIRT_IDX_DCACHE */
-	tsb->data.p = t->k;	/* p as privileged, k as kernel */
-	tsb->data.x = true;
+	tsb->data.p = t->k;		/* p as privileged */
 	tsb->data.w = ro ? false : t->w;
-	tsb->data.size = PAGESIZE_8K;
+	tsb->data.v = t->p;
 	
 	write_barrier();
 	
-	tsb->data.v = t->p;	/* v as valid, p as present */
+	tsb->tag.invalid = false;	/* mark the entry as valid */
+#endif
 }
 
 /** @}
  */
+
Index: kernel/arch/sparc64/src/smp/ipi.c
===================================================================
--- kernel/arch/sparc64/src/smp/ipi.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
+++ kernel/arch/sparc64/src/smp/ipi.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -0,0 +1,174 @@
+/*
+ * 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 sparc64	
+ * @{
+ */
+/** @file
+ */
+
+#include <smp/ipi.h>
+#include <cpu.h>
+#include <arch.h>
+#include <arch/cpu.h>
+#include <arch/asm.h>
+#include <config.h>
+#include <mm/tlb.h>
+#include <arch/interrupt.h>
+#include <arch/trap/interrupt.h>
+#include <arch/barrier.h>
+#include <preemption.h>
+#include <time/delay.h>
+#include <panic.h>
+
+/** Set the contents of the outgoing interrupt vector data.
+ *
+ * The first data item (data 0) will be set to the value of func, the
+ * rest of the vector will contain zeros.
+ *
+ * This is a helper function used from within the cross_call function.
+ *
+ * @param func value the first data item of the vector will be set to
+ */
+static inline void set_intr_w_data(void (* func)(void))
+{
+#if defined (US)
+	asi_u64_write(ASI_INTR_W, ASI_UDB_INTR_W_DATA_0, (uintptr_t) func);
+	asi_u64_write(ASI_INTR_W, ASI_UDB_INTR_W_DATA_1, 0);
+	asi_u64_write(ASI_INTR_W, ASI_UDB_INTR_W_DATA_2, 0);
+#elif defined (US3)
+	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_0, (uintptr_t)	func);
+	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_1, 0);
+	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_2, 0);
+	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_3, 0);
+	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_4, 0);
+	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_5, 0);
+	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_6, 0);
+	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_7, 0);
+#endif
+}
+
+/** Invoke function on another processor.
+ *
+ * Currently, only functions without arguments are supported.
+ * Supporting more arguments in the future should be no big deal.
+ *
+ * Interrupts must be disabled prior to this call.
+ *
+ * @param mid MID of the target processor.
+ * @param func Function to be invoked.
+ */
+static void cross_call(int mid, void (* func)(void))
+{
+	uint64_t status;
+	bool done;
+
+	/*
+	 * This function might enable interrupts for a while.
+	 * In order to prevent migration to another processor,
+	 * we explicitly disable preemption.
+	 */
+	
+	preemption_disable();
+	
+	status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0);
+	if (status & INTR_DISPATCH_STATUS_BUSY)
+		panic("Interrupt Dispatch Status busy bit set.");
+	
+	ASSERT(!(pstate_read() & PSTATE_IE_BIT));
+	
+	do {
+		set_intr_w_data(func);
+		asi_u64_write(ASI_INTR_W,
+		    (mid << INTR_VEC_DISPATCH_MID_SHIFT) |
+		    VA_INTR_W_DISPATCH, 0);
+	
+		membar();
+		
+		do {
+			status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0);
+		} while (status & INTR_DISPATCH_STATUS_BUSY);
+		
+		done = !(status & INTR_DISPATCH_STATUS_NACK);
+		if (!done) {
+			/*
+			 * Prevent deadlock.
+			 */			
+			(void) interrupts_enable();
+			delay(20 + (tick_read() & 0xff));
+			(void) interrupts_disable();
+		}
+	} while (done);
+	
+	preemption_enable();
+}
+
+/*
+ * Deliver IPI to all processors except the current one.
+ *
+ * The sparc64 architecture does not support any group addressing
+ * which is found, for instance, on ia32 and amd64. Therefore we
+ * need to simulate the broadcast by sending the message to
+ * all target processors step by step.
+ *
+ * We assume that interrupts are disabled.
+ *
+ * @param ipi IPI number.
+ */
+void ipi_broadcast_arch(int ipi)
+{
+	unsigned int i;
+	
+	void (* func)(void);
+	
+	switch (ipi) {
+	case IPI_TLB_SHOOTDOWN:
+		func = tlb_shootdown_ipi_recv;
+		break;
+	default:
+		panic("Unknown IPI (%d).", ipi);
+		break;
+	}
+	
+	/*
+	 * As long as we don't support hot-plugging
+	 * or hot-unplugging of CPUs, we can walk
+	 * the cpus array and read processor's MID
+	 * without locking.
+	 */
+	
+	for (i = 0; i < config.cpu_active; i++) {
+		if (&cpus[i] == CPU)
+			continue;		/* skip the current CPU */
+
+		cross_call(cpus[i].arch.mid, func);
+	}
+}
+
+/** @}
+ */
Index: kernel/arch/sparc64/src/smp/smp.c
===================================================================
--- kernel/arch/sparc64/src/smp/smp.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
+++ kernel/arch/sparc64/src/smp/smp.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -0,0 +1,137 @@
+/*
+ * 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 sparc64	
+ * @{
+ */
+/** @file
+ */
+
+#include <smp/smp.h>
+#include <genarch/ofw/ofw_tree.h>
+#include <cpu.h>
+#include <arch/cpu_family.h>
+#include <arch/cpu.h>
+#include <arch.h>
+#include <config.h>
+#include <macros.h>
+#include <arch/types.h>
+#include <synch/synch.h>
+#include <synch/waitq.h>
+#include <print.h>
+#include <arch/cpu_node.h>
+
+/**
+ * This global variable is used to pick-up application processors
+ * from their active loop in start.S. When a processor looping in
+ * start.S sees that this variable contains its MID, it can
+ * proceed with its initialization.
+ *
+ * This variable is modified only by the bootstrap processor.
+ * Other processors access it read-only.
+ */
+volatile uint64_t waking_up_mid = (uint64_t) -1;
+
+/** Determine number of processors. */
+void smp_init(void)
+{
+	ofw_tree_node_t *node;
+	size_t cnt = 0;
+	
+	if (is_us() || is_us_iii()) {
+		node = ofw_tree_find_child_by_device_type(cpus_parent(), "cpu");
+		while (node) {
+			cnt++;
+			node = ofw_tree_find_peer_by_device_type(node, "cpu");
+		}
+	} else if (is_us_iv()) {
+		node = ofw_tree_find_child(cpus_parent(), "cmp");
+		while (node) {
+			cnt += 2;
+			node = ofw_tree_find_peer_by_name(node, "cmp");
+		}
+	}
+	
+	config.cpu_count = max(1, cnt);
+}
+
+/**
+ * Wakes up the CPU which is represented by the "node" OFW tree node.
+ * If "node" represents the current CPU, calling the function has
+ * no effect. 
+ */
+static void wakeup_cpu(ofw_tree_node_t *node)
+{
+	uint32_t mid;
+	ofw_tree_property_t *prop;
+		
+	/* 'upa-portid' for US, 'portid' for US-III, 'cpuid' for US-IV */
+	prop = ofw_tree_getprop(node, "upa-portid");
+	if ((!prop) || (!prop->value))
+		prop = ofw_tree_getprop(node, "portid");
+	if ((!prop) || (!prop->value))
+		prop = ofw_tree_getprop(node, "cpuid");
+		
+	if (!prop || prop->value == NULL)
+		return;
+		
+	mid = *((uint32_t *) prop->value);
+	if (CPU->arch.mid == mid)
+		return;
+
+	waking_up_mid = mid;
+		
+	if (waitq_sleep_timeout(&ap_completion_wq, 1000000, SYNCH_FLAGS_NONE) ==
+	    ESYNCH_TIMEOUT)
+		printf("%s: waiting for processor (mid = %" PRIu32
+		    ") timed out\n", __func__, mid);
+}
+
+/** Wake application processors up. */
+void kmp(void *arg)
+{
+	ofw_tree_node_t *node;
+	int i;
+	
+	if (is_us() || is_us_iii()) {
+		node = ofw_tree_find_child_by_device_type(cpus_parent(), "cpu");
+		for (i = 0; node;
+                     node = ofw_tree_find_peer_by_device_type(node, "cpu"), i++)
+			wakeup_cpu(node);
+	} else if (is_us_iv()) {
+		node = ofw_tree_find_child(cpus_parent(), "cmp");
+		while (node) {
+			wakeup_cpu(ofw_tree_find_child(node, "cpu@0"));
+			wakeup_cpu(ofw_tree_find_child(node, "cpu@1"));
+			node = ofw_tree_find_peer_by_name(node, "cmp");
+		}
+	}
+}
+
+/** @}
+ */
Index: rnel/arch/sparc64/src/smp/sun4u/ipi.c
===================================================================
--- kernel/arch/sparc64/src/smp/sun4u/ipi.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,174 +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 sparc64	
- * @{
- */
-/** @file
- */
-
-#include <smp/ipi.h>
-#include <cpu.h>
-#include <arch.h>
-#include <arch/cpu.h>
-#include <arch/asm.h>
-#include <config.h>
-#include <mm/tlb.h>
-#include <arch/interrupt.h>
-#include <arch/trap/interrupt.h>
-#include <arch/barrier.h>
-#include <preemption.h>
-#include <time/delay.h>
-#include <panic.h>
-
-/** Set the contents of the outgoing interrupt vector data.
- *
- * The first data item (data 0) will be set to the value of func, the
- * rest of the vector will contain zeros.
- *
- * This is a helper function used from within the cross_call function.
- *
- * @param func value the first data item of the vector will be set to
- */
-static inline void set_intr_w_data(void (* func)(void))
-{
-#if defined (US)
-	asi_u64_write(ASI_INTR_W, ASI_UDB_INTR_W_DATA_0, (uintptr_t) func);
-	asi_u64_write(ASI_INTR_W, ASI_UDB_INTR_W_DATA_1, 0);
-	asi_u64_write(ASI_INTR_W, ASI_UDB_INTR_W_DATA_2, 0);
-#elif defined (US3)
-	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_0, (uintptr_t)	func);
-	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_1, 0);
-	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_2, 0);
-	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_3, 0);
-	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_4, 0);
-	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_5, 0);
-	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_6, 0);
-	asi_u64_write(ASI_INTR_W, VA_INTR_W_DATA_7, 0);
-#endif
-}
-
-/** Invoke function on another processor.
- *
- * Currently, only functions without arguments are supported.
- * Supporting more arguments in the future should be no big deal.
- *
- * Interrupts must be disabled prior to this call.
- *
- * @param mid MID of the target processor.
- * @param func Function to be invoked.
- */
-static void cross_call(int mid, void (* func)(void))
-{
-	uint64_t status;
-	bool done;
-
-	/*
-	 * This function might enable interrupts for a while.
-	 * In order to prevent migration to another processor,
-	 * we explicitly disable preemption.
-	 */
-	
-	preemption_disable();
-	
-	status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0);
-	if (status & INTR_DISPATCH_STATUS_BUSY)
-		panic("Interrupt Dispatch Status busy bit set\n");
-	
-	ASSERT(!(pstate_read() & PSTATE_IE_BIT));
-	
-	do {
-		set_intr_w_data(func);
-		asi_u64_write(ASI_INTR_W,
-		    (mid << INTR_VEC_DISPATCH_MID_SHIFT) |
-		    VA_INTR_W_DISPATCH, 0);
-	
-		membar();
-		
-		do {
-			status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0);
-		} while (status & INTR_DISPATCH_STATUS_BUSY);
-		
-		done = !(status & INTR_DISPATCH_STATUS_NACK);
-		if (!done) {
-			/*
-			 * Prevent deadlock.
-			 */			
-			(void) interrupts_enable();
-			delay(20 + (tick_read() & 0xff));
-			(void) interrupts_disable();
-		}
-	} while (done);
-	
-	preemption_enable();
-}
-
-/*
- * Deliver IPI to all processors except the current one.
- *
- * The sparc64 architecture does not support any group addressing
- * which is found, for instance, on ia32 and amd64. Therefore we
- * need to simulate the broadcast by sending the message to
- * all target processors step by step.
- *
- * We assume that interrupts are disabled.
- *
- * @param ipi IPI number.
- */
-void ipi_broadcast_arch(int ipi)
-{
-	unsigned int i;
-	
-	void (* func)(void);
-	
-	switch (ipi) {
-	case IPI_TLB_SHOOTDOWN:
-		func = tlb_shootdown_ipi_recv;
-		break;
-	default:
-		panic("Unknown IPI (%d).\n", ipi);
-		break;
-	}
-	
-	/*
-	 * As long as we don't support hot-plugging
-	 * or hot-unplugging of CPUs, we can walk
-	 * the cpus array and read processor's MID
-	 * without locking.
-	 */
-	
-	for (i = 0; i < config.cpu_active; i++) {
-		if (&cpus[i] == CPU)
-			continue;		/* skip the current CPU */
-
-		cross_call(cpus[i].arch.mid, func);
-	}
-}
-
-/** @}
- */
Index: rnel/arch/sparc64/src/smp/sun4u/smp.c
===================================================================
--- kernel/arch/sparc64/src/smp/sun4u/smp.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,137 +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 sparc64	
- * @{
- */
-/** @file
- */
-
-#include <smp/smp.h>
-#include <genarch/ofw/ofw_tree.h>
-#include <cpu.h>
-#include <arch/cpu_family.h>
-#include <arch/cpu.h>
-#include <arch.h>
-#include <config.h>
-#include <macros.h>
-#include <arch/types.h>
-#include <synch/synch.h>
-#include <synch/waitq.h>
-#include <print.h>
-#include <arch/cpu_node.h>
-
-/**
- * This global variable is used to pick-up application processors
- * from their active loop in start.S. When a processor looping in
- * start.S sees that this variable contains its MID, it can
- * proceed with its initialization.
- *
- * This variable is modified only by the bootstrap processor.
- * Other processors access it read-only.
- */
-volatile uint64_t waking_up_mid = (uint64_t) -1;
-
-/** Determine number of processors. */
-void smp_init(void)
-{
-	ofw_tree_node_t *node;
-	unsigned int cnt = 0;
-	
-	if (is_us() || is_us_iii()) {
-		node = ofw_tree_find_child_by_device_type(cpus_parent(), "cpu");
-		while (node) {
-			cnt++;
-			node = ofw_tree_find_peer_by_device_type(node, "cpu");
-		}
-	} else if (is_us_iv()) {
-		node = ofw_tree_find_child(cpus_parent(), "cmp");
-		while (node) {
-			cnt += 2;
-			node = ofw_tree_find_peer_by_name(node, "cmp");
-		}
-	}
-	
-	config.cpu_count = max(1, cnt);
-}
-
-/**
- * Wakes up the CPU which is represented by the "node" OFW tree node.
- * If "node" represents the current CPU, calling the function has
- * no effect. 
- */
-static void wakeup_cpu(ofw_tree_node_t *node)
-{
-	uint32_t mid;
-	ofw_tree_property_t *prop;
-		
-	/* 'upa-portid' for US, 'portid' for US-III, 'cpuid' for US-IV */
-	prop = ofw_tree_getprop(node, "upa-portid");
-	if ((!prop) || (!prop->value))
-		prop = ofw_tree_getprop(node, "portid");
-	if ((!prop) || (!prop->value))
-		prop = ofw_tree_getprop(node, "cpuid");
-		
-	if (!prop || prop->value == NULL)
-		return;
-		
-	mid = *((uint32_t *) prop->value);
-	if (CPU->arch.mid == mid)
-		return;
-
-	waking_up_mid = mid;
-		
-	if (waitq_sleep_timeout(&ap_completion_wq, 1000000, SYNCH_FLAGS_NONE) ==
-	    ESYNCH_TIMEOUT)
-		printf("%s: waiting for processor (mid = %" PRIu32
-		    ") timed out\n", __func__, mid);
-}
-
-/** Wake application processors up. */
-void kmp(void *arg)
-{
-	ofw_tree_node_t *node;
-	int i;
-	
-	if (is_us() || is_us_iii()) {
-		node = ofw_tree_find_child_by_device_type(cpus_parent(), "cpu");
-		for (i = 0; node;
-                     node = ofw_tree_find_peer_by_device_type(node, "cpu"), i++)
-			wakeup_cpu(node);
-	} else if (is_us_iv()) {
-		node = ofw_tree_find_child(cpus_parent(), "cmp");
-		while (node) {
-			wakeup_cpu(ofw_tree_find_child(node, "cpu@0"));
-			wakeup_cpu(ofw_tree_find_child(node, "cpu@1"));
-			node = ofw_tree_find_peer_by_name(node, "cmp");
-		}
-	}
-}
-
-/** @}
- */
Index: rnel/arch/sparc64/src/smp/sun4v/ipi.c
===================================================================
--- kernel/arch/sparc64/src/smp/sun4v/ipi.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,123 +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 sparc64	
- * @{
- */
-/** @file
- */
-
-#include <smp/ipi.h>
-#include <cpu.h>
-#include <config.h>
-#include <interrupt.h>
-#include <arch/asm.h>
-#include <arch/cpu.h>
-#include <arch/sun4v/hypercall.h>
-#include <arch/sun4v/ipi.h>
-
-#define IPI_MESSAGE_SIZE	8
-
-static uint64_t data[MAX_NUM_STRANDS][IPI_MESSAGE_SIZE]
-	__attribute__ ((aligned (64)));
-
-static uint16_t ipi_cpu_list[MAX_NUM_STRANDS][MAX_NUM_STRANDS];
-
-/**
- * Sends an inter-processor interrupt to all virtual processors whose IDs are
- * listed in the list.
- *
- * @param func		address of the function to be invoked on the recipient
- * @param cpu_list	list of CPU IDs (16-bit identifiers) of the recipients
- * @param list_size	number of recipients (number of valid cpu_list entries)
- *
- * @return		error code returned by the CPU_MONDO_SEND hypercall
- */
-uint64_t ipi_brodcast_to(void (*func)(void), uint16_t cpu_list[MAX_NUM_STRANDS],
-		uint64_t list_size) {
-
-	data[CPU->arch.id][0] = (uint64_t) func;
-
-	unsigned int i;
-	for (i = 0; i < list_size; i++) {
-		ipi_cpu_list[CPU->arch.id][i] = cpu_list[i];
-	}
-
-	return __hypercall_fast3(CPU_MONDO_SEND, list_size,
-		KA2PA(ipi_cpu_list[CPU->arch.id]), KA2PA(data[CPU->arch.id]));
-}
-
-/**
- * Send an inter-processor interrupt to a particular CPU.
- *
- * @param func		address of the function to be invoked on the recipient
- * @param cpu_is	CPU ID (16-bit identifier) of the recipient
- *
- * @return		error code returned by the CPU_MONDO_SEND hypercall
- */
-uint64_t ipi_unicast_to(void (*func)(void), uint16_t cpu_id) {
-	ipi_cpu_list[CPU->arch.id][0] = cpu_id;
-	return ipi_brodcast_to(func, ipi_cpu_list[CPU->arch.id], 1);
-}
-
-/*
- * Deliver IPI to all processors except the current one.
- *
- * We assume that interrupts are disabled.
- *
- * @param ipi IPI number.
- */
-void ipi_broadcast_arch(int ipi)
-{
-	void (* func)(void);
-	
-	switch (ipi) {
-	case IPI_TLB_SHOOTDOWN:
-		func = tlb_shootdown_ipi_recv;
-		break;
-	default:
-		panic("Unknown IPI (%d).\n", ipi);
-		break;
-	}
-
-	unsigned int i;
-	unsigned idx = 0;
-	for (i = 0; i < config.cpu_active; i++) {
-		if (&cpus[i] == CPU) {
-			continue;
-		}
-
-		ipi_cpu_list[CPU->id][idx] = (uint16_t) cpus[i].id;
-		idx++;
-	}
-
-	ipi_brodcast_to(func, ipi_cpu_list[CPU->arch.id], idx);
-}
-
-/** @}
- */
Index: rnel/arch/sparc64/src/smp/sun4v/smp.c
===================================================================
--- kernel/arch/sparc64/src/smp/sun4v/smp.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,465 +1,0 @@
-/*
- * Copyright (c) 2006 Jakub Jermar
- * Copyright (c) 2009 Pavel Rimsky 
- * 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 sparc64	
- * @{
- */
-/** @file
- */
-
-#include <smp/smp.h>
-#include <smp/ipi.h>
-#include <genarch/ofw/ofw_tree.h>
-#include <cpu.h>
-#include <arch/cpu.h>
-#include <arch/boot/boot.h>
-#include <arch.h>
-#include <config.h>
-#include <macros.h>
-#include <func.h>
-#include <arch/types.h>
-#include <synch/synch.h>
-#include <synch/waitq.h>
-#include <print.h>
-#include <arch/sun4v/hypercall.h>
-#include <arch/sun4v/md.h>
-#include <arch/sun4v/ipi.h>
-#include <time/delay.h>
-#include <arch/smp/sun4v/smp.h>
-#include <string.h>
-
-/** hypervisor code of the "running" state of the CPU */
-#define CPU_STATE_RUNNING	2
-
-/** maximum possible number of processor cores */
-#define MAX_NUM_CORES		8
-
-/** needed in the CPU_START hypercall */
-extern void kernel_image_start(void);
-
-/** needed in the CPU_START hypercall */
-extern void *trap_table;
-
-/** number of execution units detected */
-uint8_t exec_unit_count = 0;
-
-/** execution units (processor cores) */
-exec_unit_t exec_units[MAX_NUM_CORES];
-
-/** CPU structures */
-extern cpu_t *cpus;
-
-/** maximum number of strands per a physical core detected */
-unsigned int max_core_strands = 0;
-
-#ifdef CONFIG_SIMICS_SMP_HACK
-/**
- * Copies a piece of HelenOS code to the place where OBP had its IPI handler.
- * By sending an IPI by the BSP to the AP the code will be executed.
- * The code will jump to the first instruction of the kernel. This is
- * a workaround how to make APs execute HelenOS code on Simics.
- */
-static void simics_smp_hack_init(void) {
-	asm volatile (
-		"setx temp_cpu_mondo_handler, %g4, %g6 \n"
-		"setx 0x80200f80, %g4, %g7 \n"
-
-		"ldx [%g6], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"add %g7, 0x8, %g7 \n"
-		"ldx [%g6 + 0x8], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"add %g7, 0x8, %g7 \n"
-		"ldx [%g6 + 0x10], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"add %g7, 0x8, %g7 \n"
-		"ldx [%g6 + 0x18], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"add %g7, 0x8, %g7 \n"
-		"ldx [%g6 + 0x20], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"add %g7, 0x8, %g7 \n"
-		"ldx [%g6 + 0x28], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"add %g7, 0x8, %g7 \n"
-		"ldx [%g6 + 0x30], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"add %g7, 0x8, %g7 \n"
-		"ldx [%g6 + 0x38], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"add %g7, 0x8, %g7 \n"
-		"ldx [%g6 + 0x40], %g4 \n"
-		"stxa %g4, [%g7] 0x14 \n"
-		"membar #Sync \n"
-
-		"flush %i7"
-
-		);
-}
-#endif
-
-#if 0
-/**
- * Proposes the optimal number of ready threads for each virtual processor
- * in the given processor core so that the processor core is as busy as the
- * average processor core. The proposed number of ready threads will be
- * stored to the proposed_nrdy variable of the cpu_arch_t struture.
- */
-bool calculate_optimal_nrdy(exec_unit_t *exec_unit) {
-
-	/* calculate the number of threads the core will steal */
-	int avg = atomic_get(&nrdy) / exec_unit_count;
-	int to_steal = avg - atomic_get(&(exec_units->nrdy));
-	if (to_steal < 0) {
-		return true;
-	} else if (to_steal == 0) {
-		return false;
-	}
-
-	/* initialize the proposals with the real numbers of ready threads */
-	unsigned int k;
-	for (k = 0; k < exec_unit->strand_count; k++) {
-		exec_units->cpus[k]->arch.proposed_nrdy =
-			atomic_get(&(exec_unit->cpus[k]->nrdy));
-	}
-
-	/* distribute the threads to be stolen to the core's CPUs */
-	int j;
-	for (j = to_steal; j > 0; j--) {
-		unsigned int k;
-		unsigned int least_busy = 0;
-		unsigned int least_busy_nrdy =
-			exec_unit->cpus[0]->arch.proposed_nrdy;
-
-		/* for each stolen thread, give it to the least busy CPU */
-		for (k = 0; k < exec_unit->strand_count; k++) {
-			if (exec_unit->cpus[k]->arch.proposed_nrdy
-					< least_busy_nrdy) {
-				least_busy = k;
-				least_busy_nrdy =
-					exec_unit->cpus[k]->arch.proposed_nrdy;
-			}
-		}
-		exec_unit->cpus[least_busy]->arch.proposed_nrdy++;
-	}
-
-	return false;
-}
-#endif
-
-/**
- * Finds out which execution units belong to particular CPUs. By execution unit
- * we mean the physical core the logical processor is backed by. Since each
- * Niagara physical core has just one integer execution unit and we will
- * ignore other execution units than the integer ones, we will use the terms
- * "integer execution unit", "execution unit" and "physical core"
- * interchangeably.
- *
- * The physical cores are detected by browsing the children of the CPU node
- * in the machine description and looking for a node representing an integer
- * execution unit. Once the integer execution unit of a particular CPU is
- * known, the ID of the CPU is added to the list of cpuids of the corresponding
- * execution unit structure (exec_unit_t). If an execution unit is encountered
- * for the first time, a new execution unit structure (exec_unit_t) must be
- * created first and added to the execution units array (exec_units).
- *
- * If the function fails to find an execution unit for a CPU (this may happen
- * on machines with older firmware or on Simics), it performs a fallback code
- * which pretends there exists just one execution unit and all CPUs belong to
- * it.
- *
- * Finally, the array of all execution units is reordered such that its element
- * which represents the physical core of the the bootstrap CPU is at index 0.
- * Moreover, the array of CPU IDs within the BSP's physical core structure is
- * reordered such that the element which represents the ID of the BSP is at
- * index 0. This is done because we would like the CPUs to be woken up
- * such that the 0-index CPU of the 0-index execution unit is
- * woken up first. And since the BSP is already woken up, we would like it to be
- * at 0-th position of the 0-th execution unit structure.
- *
- * Apart from that, the code also counts the total number of CPUs and stores
- * it to the global config.cpu_count variable.
- */
-static void detect_execution_units(void)
-{
-	/* ID of the bootstrap processor */
-	uint64_t myid;
-
-	/* total number of CPUs detected */
-	size_t cpu_count = 0;
-
-	/* will be set to 1 if detecting the physical cores fails */
-	bool exec_unit_assign_error = 0;
-
-	/* index of the bootstrap physical core in the array of cores */
-	unsigned int bsp_exec_unit_index = 0;
-
-	/* index of the BSP ID inside the array of bootstrap core's cpuids */
-	unsigned int bsp_core_strand_index = 0;
-
-	__hypercall_fast_ret1(0, 0, 0, 0, 0, CPU_MYID, &myid);
-	md_node_t node = md_get_root();
-
-	/* walk through all the CPU nodes in the MD*/
-	while (md_next_node(&node, "cpu")) {
-
-		uint64_t cpuid;
-		md_get_integer_property(node, "id", &cpuid);
-		cpu_count++;
-
-		/*
- 		 * if failed in previous CPUs, don't try
- 		 * to detect physical cores any more
- 		 */
-		if (exec_unit_assign_error)
-			continue;
-
-		/* detect exec. unit for the CPU represented by current node */
-		uint64_t exec_unit_id = 0;
-		md_child_iter_t it = md_get_child_iterator(node);
-
-		while (md_next_child(&it)) {
-			md_node_t child = md_get_child_node(it);
-			const char *exec_unit_type;
-			md_get_string_property(child, "type", &exec_unit_type);
-
-			/* each physical core has just 1 integer exec. unit */
-			if (str_cmp(exec_unit_type, "integer") == 0) {
-				exec_unit_id = child;
-				break;
-			}
-		}
-
-		/* execution unit detected successfully */
-		if (exec_unit_id != 0) {
-
-			/* find the exec. unit in array of existing units */
-			unsigned int i = 0;
-			for (i = 0; i < exec_unit_count; i++) {
-				if (exec_units[i].exec_unit_id == exec_unit_id)
-					break;
-			}
-
-			/*
-			 * execution unit just met has not been met before, so
-			 * create a new entry in array of all execution units
-			 */
-			if (i == exec_unit_count) {
-				exec_units[i].exec_unit_id = exec_unit_id;
-				exec_units[i].strand_count = 0;
-				atomic_set(&(exec_units[i].nrdy), 0);
-				spinlock_initialize(&(exec_units[i].proposed_nrdy_lock), "proposed nrdy lock");
-				exec_unit_count++;
-			}
-
-			/*
-			 * remember the exec. unit and strand of the BSP
-			 */
-			if (cpuid == myid) {
-				bsp_exec_unit_index = i;
-				bsp_core_strand_index = exec_units[i].strand_count;
-			}
-
-			/* add the CPU just met to the exec. unit's list */
-			exec_units[i].cpuids[exec_units[i].strand_count] = cpuid;
-			exec_units[i].strand_count++;
-			max_core_strands =
-				exec_units[i].strand_count > max_core_strands ?
-				exec_units[i].strand_count : max_core_strands;
-
-		/* detecting execution unit failed */
-		} else {
-			exec_unit_assign_error = 1;
-		}
-	}		
-
-	/* save the number of CPUs to a globally accessible variable */
-	config.cpu_count = cpu_count;
-
-	/*
- 	 * A fallback code which will be executed if finding out which
- 	 * execution units belong to particular CPUs fails. Pretend there
- 	 * exists just one execution unit and all CPUs belong to it.
- 	 */
-	if (exec_unit_assign_error) {
-		bsp_exec_unit_index = 0;
-		exec_unit_count = 1;
-		exec_units[0].strand_count = cpu_count;
-		exec_units[0].exec_unit_id = 1;
-		spinlock_initialize(&(exec_units[0].proposed_nrdy_lock), "proposed nrdy lock");
-		atomic_set(&(exec_units[0].nrdy), 0);
-		max_core_strands = cpu_count;
-
-		/* browse CPUs again, assign them the fictional exec. unit */
-		node = md_get_root();
-		unsigned int i = 0;
-
-		while (md_next_node(&node, "cpu")) {
-			uint64_t cpuid;
-			md_get_integer_property(node, "id", &cpuid);
-			if (cpuid == myid) {
-				bsp_core_strand_index = i;
-			}
-			exec_units[0].cpuids[i++] = cpuid;
-		}
-	}
-
-	/*
- 	 * Reorder the execution units array elements and the cpuid array
- 	 * elements so that the BSP will always be the very first CPU of
- 	 * the very first execution unit.
- 	 */
-	exec_unit_t temp_exec_unit = exec_units[0];
-	exec_units[0] = exec_units[bsp_exec_unit_index];
-	exec_units[bsp_exec_unit_index] = temp_exec_unit;
-
-	uint64_t temp_cpuid = exec_units[0].cpuids[0];
-	exec_units[0].cpuids[0] = exec_units[0].cpuids[bsp_exec_unit_index];
-	exec_units[0].cpuids[bsp_core_strand_index] = temp_cpuid;
-
-}
-
-/**
- * Determine number of processors and detect physical cores. On Simics
- * copy the code which will be executed by the AP when the BSP sends an
- * IPI to it in order to make it execute HelenOS code.
- */
-void smp_init(void)
-{
-	detect_execution_units();
-#ifdef CONFIG_SIMICS_SMP_HACK
-	simics_smp_hack_init();
-#endif
-}
-
-/**
- * For each CPU sets the value of cpus[i].arch.id, where i is the
- * index of the CPU in the cpus variable, to the cpuid of the i-th processor
- * to be run. The CPUs are run such that the CPU represented by cpus[0]
- * is run first, cpus[1] is run after it, and cpus[cpu_count - 1] is run as the
- * last one.
- *
- * The CPU IDs are set such that during waking the CPUs up the
- * processor cores will be alternated, i.e. first one CPU from the first core
- * will be run, after that one CPU from the second CPU core will be run,...
- * then one CPU from the last core will be run, after that another CPU
- * from the first core will be run, then another CPU from the second core
- * will be run,... then another CPU from the last core will be run, and so on.
- */
-static void init_cpuids(void)
-{
-	unsigned int cur_core_strand;
-	unsigned int cur_core;
-	unsigned int cur_cpu = 0;
-
-	for (cur_core_strand = 0; cur_core_strand < max_core_strands; cur_core_strand++) {
-		for (cur_core = 0; cur_core < exec_unit_count; cur_core++) {
-			if (cur_core_strand > exec_units[cur_core].strand_count)
-				continue;
-
-			cpus[cur_cpu].arch.exec_unit = &(exec_units[cur_core]);
-			atomic_add(&(exec_units[cur_core].nrdy), atomic_get(&(cpus[cur_cpu].nrdy)));
-			cpus[cur_cpu].arch.id = exec_units[cur_core].cpuids[cur_core_strand];
-			exec_units[cur_core].cpus[cur_core_strand] = &(cpus[cur_cpu]);
-			cur_cpu++;
-		}
-	}
-}
-
-/**
- * Wakes up a single CPU.
- *
- * @param cpuid	ID of the CPU to be woken up
- */
-static bool wake_cpu(uint64_t cpuid)
-{
-
-#ifdef CONFIG_SIMICS_SMP_HACK
-	ipi_unicast_to((void (*)(void)) 1234, cpuid);
-#else
-	/* stop the CPU before making it execute our code */
-	if (__hypercall_fast1(CPU_STOP, cpuid) != EOK)
-		return false;
-
-	/* wait for the CPU to stop */
-	uint64_t state;
-	__hypercall_fast_ret1(cpuid, 0, 0, 0, 0,
-		CPU_STATE, &state);
-	while (state == CPU_STATE_RUNNING) {
-		__hypercall_fast_ret1(cpuid, 0, 0, 0, 0,
-			CPU_STATE, &state);
-	}
-
-	/* make the CPU run again and execute HelenOS code */
-	if (__hypercall_fast4(
-		CPU_START, cpuid,
-		(uint64_t) KA2PA(kernel_image_start),
-		KA2PA(trap_table), bootinfo.physmem_start			
-		) != EOK)
-			return false;
-#endif
-
-	if (waitq_sleep_timeout(&ap_completion_wq, 10000000, SYNCH_FLAGS_NONE) ==
-			ESYNCH_TIMEOUT)
-		printf("%s: waiting for processor (cpuid = %" PRIu32
-		") timed out\n", __func__, cpuid);
-
-	return true;
-}
-
-/** Wake application processors up. */
-void kmp(void *arg)
-{
-	init_cpuids();
-
-	unsigned int i;
-
-	for (i = 1; i < config.cpu_count; i++) {
-		wake_cpu(cpus[i].arch.id);
-	}
-}
-
-/** @}
- */
Index: kernel/arch/sparc64/src/sun4v/md.c
===================================================================
--- kernel/arch/sparc64/src/sun4v/md.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/sun4v/md.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -104,6 +104,6 @@
 static md_element_t *get_element(element_idx_t idx)
 {
-	return (md_element_t *) (mach_desc +
-	    sizeof(md_header_t) + idx * sizeof(md_element_t));
+	return (md_element_t *) (
+		mach_desc + sizeof(md_header_t) + idx * sizeof(md_element_t));
 }
 
@@ -114,5 +114,5 @@
 	uintptr_t name_offset = get_element(idx)->name_offset;
 	return (char *) mach_desc + sizeof(md_header_t) +
-	    md_header->node_blk_sz + name_offset;
+		md_header->node_blk_sz + name_offset;
 }
 
@@ -137,5 +137,5 @@
 		md_element_t *element = get_element(idx);
 		if (element->tag == PROP_VAL &&
-		    str_cmp(key, get_element_name(idx)) == 0) {
+				str_cmp(key, get_element_name(idx)) == 0) {
 			*result = element->d.val;
 			return true;
@@ -161,8 +161,8 @@
 		md_element_t *element = get_element(idx);
 		if (element->tag == PROP_DATA &&
-		    str_cmp(key, get_element_name(idx)) == 0) {
+				str_cmp(key, get_element_name(idx)) == 0) {
 			*result = (char *) mach_desc + sizeof(md_header_t) +
-			    md_header->node_blk_sz + md_header->name_blk_sz +
-			    element->d.y.data_offset;
+				md_header->node_blk_sz + md_header->name_blk_sz +
+				element->d.y.data_offset;
 			return true;
 		}
@@ -186,5 +186,5 @@
 		md_element_t *element = get_element(*it);
 		if (element->tag == PROP_ARC &&
-		    str_cmp("fwd", get_element_name(*it)) == 0) {
+				str_cmp("fwd", get_element_name(*it)) == 0) {
 			return true;
 		}
@@ -289,5 +289,5 @@
 
 		if (element->tag == NODE &&
-		    str_cmp(name, get_element_name(*node)) == 0) {
+				str_cmp(name, get_element_name(*node)) == 0) {
 			return true;
 		}
@@ -306,10 +306,10 @@
 {
 	uint64_t retval = __hypercall_fast2(MACH_DESC, KA2PA(mach_desc),
-	    MD_MAX_SIZE);
+		MD_MAX_SIZE);
 
 	retval = retval;
-	if (retval != HV_EOK) {
+	if (retval != EOK) {
 		printf("Could not retrieve machine description, error = %d.\n",
-		    retval);
+			retval);
 	}
 }
Index: kernel/arch/sparc64/src/sun4v/sparc64.c
===================================================================
--- kernel/arch/sparc64/src/sun4v/sparc64.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/sun4v/sparc64.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -50,4 +50,6 @@
 #include <ddi/irq.h>
 #include <string.h>
+
+//MH
 #include <arch/drivers/niagara.h>
 
Index: kernel/arch/sparc64/src/trap/exception.c
===================================================================
--- kernel/arch/sparc64/src/trap/exception.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/trap/exception.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -46,7 +46,9 @@
 void dump_istate(istate_t *istate)
 {
-	const char *tpcs = symtab_fmt_name_lookup(istate->tpc);
-	const char *tnpcs = symtab_fmt_name_lookup(istate->tnpc);
-	
+	char *tpcs, *tnpcs;
+
+	tpcs = symtab_fmt_name_lookup(istate->tpc);
+	tnpcs = symtab_fmt_name_lookup(istate->tnpc);
+
 	printf("TSTATE=%#" PRIx64 "\n", istate->tstate);
 	printf("TPC=%#" PRIx64 " (%s)\n", istate->tpc, tpcs);
@@ -160,5 +162,6 @@
 	fault_if_from_uspace(istate, "%s.", __func__);
 	dump_istate(istate);
-	describe_dmmu_fault();
+//MH
+//	dump_sfsr_and_sfar();
 	panic("%s.", __func__);
 }
Index: kernel/arch/sparc64/src/trap/interrupt.c
===================================================================
--- kernel/arch/sparc64/src/trap/interrupt.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/trap/interrupt.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -1,5 +1,4 @@
 /*
  * Copyright (c) 2005 Jakub Jermar
- * Copyright (c) 2009 Pavel Rimsky
  * All rights reserved.
  *
@@ -35,6 +34,6 @@
 
 #include <arch/interrupt.h>
+#include <arch/sparc64.h>
 #include <arch/trap/interrupt.h>
-#include <arch/sparc64.h>
 #include <interrupt.h>
 #include <ddi/irq.h>
@@ -61,4 +60,65 @@
 	exc_register(n - 1, name, f);
 }
+
+/** Process hardware interrupt.
+ *
+ * @param n Ignored.
+ * @param istate Ignored.
+ */
+void interrupt(int n, istate_t *istate)
+{
+	uint64_t status;
+	uint64_t intrcv;
+	uint64_t data0;
+	status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0);
+	if (status & (!INTR_DISPATCH_STATUS_BUSY))
+		panic("Interrupt Dispatch Status busy bit not set.");
+
+	intrcv = asi_u64_read(ASI_INTR_RECEIVE, 0);
+#if defined (US)
+	data0 = asi_u64_read(ASI_INTR_R, ASI_UDB_INTR_R_DATA_0);
+#elif defined (US3)
+	data0 = asi_u64_read(ASI_INTR_R, VA_INTR_R_DATA_0);
+#endif
+
+	irq_t *irq = irq_dispatch_and_lock(data0);
+	if (irq) {
+		/*
+		 * The IRQ handler was found.
+		 */
+		irq->handler(irq);
+		/*
+		 * See if there is a clear-interrupt-routine and call it.
+		 */
+		if (irq->cir) {
+			irq->cir(irq->cir_arg, irq->inr);
+		}
+		spinlock_unlock(&irq->lock);
+	} else if (data0 > config.base) {
+		/*
+		 * This is a cross-call.
+		 * data0 contains address of the kernel function.
+		 * We call the function only after we verify
+		 * it is one of the supported ones.
+		 */
+#ifdef CONFIG_SMP
+		if (data0 == (uintptr_t) tlb_shootdown_ipi_recv) {
+			tlb_shootdown_ipi_recv();
+		}
+#endif
+	} else {
+		/*
+		 * Spurious interrupt.
+		 */
+#ifdef CONFIG_DEBUG
+		printf("cpu%u: spurious interrupt (intrcv=%#" PRIx64
+		    ", data0=%#" PRIx64 ")\n", CPU->id, intrcv, data0);
+#endif
+	}
+
+	membar();
+	asi_u64_write(ASI_INTR_RECEIVE, 0, 0);
+}
+
 /** @}
  */
Index: rnel/arch/sparc64/src/trap/sun4u/interrupt.c
===================================================================
--- kernel/arch/sparc64/src/trap/sun4u/interrupt.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,111 +1,0 @@
-/*
- * Copyright (c) 2005 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 sparc64interrupt
- * @{
- */
-/** @file
- */
-
-#include <arch/interrupt.h>
-#include <arch/sparc64.h>
-#include <arch/trap/interrupt.h>
-#include <interrupt.h>
-#include <ddi/irq.h>
-#include <arch/types.h>
-#include <debug.h>
-#include <arch/asm.h>
-#include <arch/barrier.h>
-#include <print.h>
-#include <arch.h>
-#include <mm/tlb.h>
-#include <config.h>
-#include <synch/spinlock.h>
-
-/** Process hardware interrupt.
- *
- * @param n Ignored.
- * @param istate Ignored.
- */
-void interrupt(int n, istate_t *istate)
-{
-	uint64_t status;
-	uint64_t intrcv;
-	uint64_t data0;
-	status = asi_u64_read(ASI_INTR_DISPATCH_STATUS, 0);
-	if (status & (!INTR_DISPATCH_STATUS_BUSY))
-		panic("Interrupt Dispatch Status busy bit not set\n");
-
-	intrcv = asi_u64_read(ASI_INTR_RECEIVE, 0);
-#if defined (US)
-	data0 = asi_u64_read(ASI_INTR_R, ASI_UDB_INTR_R_DATA_0);
-#elif defined (US3)
-	data0 = asi_u64_read(ASI_INTR_R, VA_INTR_R_DATA_0);
-#endif
-
-	irq_t *irq = irq_dispatch_and_lock(data0);
-	if (irq) {
-		/*
-		 * The IRQ handler was found.
-		 */
-		irq->handler(irq);
-		/*
-		 * See if there is a clear-interrupt-routine and call it.
-		 */
-		if (irq->cir) {
-			irq->cir(irq->cir_arg, irq->inr);
-		}
-		spinlock_unlock(&irq->lock);
-	} else if (data0 > config.base) {
-		/*
-		 * This is a cross-call.
-		 * data0 contains address of the kernel function.
-		 * We call the function only after we verify
-		 * it is one of the supported ones.
-		 */
-#ifdef CONFIG_SMP
-		if (data0 == (uintptr_t) tlb_shootdown_ipi_recv) {
-			tlb_shootdown_ipi_recv();
-		}
-#endif
-	} else {
-		/*
-		 * Spurious interrupt.
-		 */
-#ifdef CONFIG_DEBUG
-		printf("cpu%u: spurious interrupt (intrcv=%#" PRIx64
-		    ", data0=%#" PRIx64 ")\n", CPU->id, intrcv, data0);
-#endif
-	}
-
-	membar();
-	asi_u64_write(ASI_INTR_RECEIVE, 0, 0);
-}
-
-/** @}
- */
Index: rnel/arch/sparc64/src/trap/sun4v/interrupt.c
===================================================================
--- kernel/arch/sparc64/src/trap/sun4v/interrupt.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,121 +1,0 @@
-/*
- * Copyright (c) 2009 Pavel Rimsky
- * 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 sparc64interrupt
- * @{
- */
-/** @file
- */
-
-#include <arch/interrupt.h>
-#include <arch/trap/interrupt.h>
-#include <arch/sparc64.h>
-#include <interrupt.h>
-#include <ddi/irq.h>
-#include <arch/types.h>
-#include <debug.h>
-#include <arch/asm.h>
-#include <arch/barrier.h>
-#include <print.h>
-#include <arch.h>
-#include <mm/tlb.h>
-#include <config.h>
-#include <synch/spinlock.h>
-#include <arch/sun4v/hypercall.h>
-
-/** number of uint64_t-s in one CPU mondo message */
-#define CPU_MONDO_ENTRY_SIZE	8
-
-/** number of entries (messages) in the CPU mondo queue */
-#define CPU_MONDO_NENTRIES	8
-
-/** number of uint64_t-s in the CPU mondo queue */
-#define CPU_MONDO_QUEUE_SIZE	((CPU_MONDO_NENTRIES) * (CPU_MONDO_ENTRY_SIZE))
-
-/** used to identify CPU mondo queue in the hypercall */
-#define CPU_MONDO_QUEUE_ID	0x3c
-
-/** ASI for reading/writing CPU mondo head/tail registers */
-#define ASI_QUEUE		0x25
-
-/** VA for reading the CPU mondo tail */
-#define VA_CPU_MONDO_QUEUE_TAIL	0x3c8
-
-/** VA for reading/writing the CPU mondo head */
-#define VA_CPU_MONDO_QUEUE_HEAD	0x3c0
-
-/**
- * array which contains CPU mondo queue for every CPU
- */
-uint64_t cpu_mondo_queues[MAX_NUM_STRANDS][CPU_MONDO_QUEUE_SIZE]
-	__attribute__((aligned(
-	CPU_MONDO_QUEUE_SIZE * sizeof(uint64_t))));
-
-/**
- * Initializes CPU mondo queue for the current CPU.
- */
-void sun4v_ipi_init(void)
-{
-	if (__hypercall_fast3(
-		CPU_QCONF,
-		CPU_MONDO_QUEUE_ID,
-		KA2PA(cpu_mondo_queues[CPU->id]),
-		CPU_MONDO_NENTRIES) != HV_EOK)
-			panic("Initializing mondo queue failed on CPU %d.\n",
-			    CPU->arch.id);
-}
-
-/**
- * Handler of the CPU Mondo trap. Reads the message queue, updates the head
- * register and processes the message (invokes a function call).
- */
-void cpu_mondo(void)
-{
-#ifdef CONFIG_SMP
-	unsigned int tail = asi_u64_read(ASI_QUEUE, VA_CPU_MONDO_QUEUE_TAIL);
-	unsigned int head = asi_u64_read(ASI_QUEUE, VA_CPU_MONDO_QUEUE_HEAD);
-
-	while (head != tail) {
-		uint64_t data1 = cpu_mondo_queues[CPU->id][0];
-
-		head = (head + CPU_MONDO_ENTRY_SIZE * sizeof(uint64_t)) %
-		    (CPU_MONDO_QUEUE_SIZE * sizeof(uint64_t));
-		asi_u64_write(ASI_QUEUE, VA_CPU_MONDO_QUEUE_HEAD, head);
-
-		if (data1 == (uintptr_t) tlb_shootdown_ipi_recv) {
-			((void (*)(void)) data1)();
-		} else {
-			printf("Spurious interrupt on %d, data = %lx.\n",
-			    CPU->arch.id, data1);
-		}
-	}
-#endif
-}
-
-/** @}
- */
Index: kernel/arch/sparc64/src/trap/sun4v/trap_table.S
===================================================================
--- kernel/arch/sparc64/src/trap/sun4v/trap_table.S	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/arch/sparc64/src/trap/sun4v/trap_table.S	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -48,6 +48,4 @@
 #include <arch/stack.h>
 #include <arch/sun4v/regdef.h>
-#include <arch/sun4v/arch.h>
-#include <arch/sun4v/cpu.h>
 
 #define TABLE_SIZE	TRAP_TABLE_SIZE
@@ -62,15 +60,9 @@
 
 /* TT = 0x08, TL = 0, instruction_access_exception */
-/* TT = 0x08, TL = 0, IAE_privilege_violation on UltraSPARC T2 */
 .org trap_table + TT_INSTRUCTION_ACCESS_EXCEPTION*ENTRY_SIZE
 .global instruction_access_exception_tl0
 instruction_access_exception_tl0:
-	PREEMPTIBLE_HANDLER instruction_access_exception
-
-/* TT = 0x09, TL = 0, instruction_access_mmu_miss */
-.org trap_table + TT_INSTRUCTION_ACCESS_MMU_MISS*ENTRY_SIZE
-.global instruction_access_mmu_miss_handler_tl0
-	ba fast_instruction_access_mmu_miss_handler_tl0
-	nop
+	/*wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
+	PREEMPTIBLE_HANDLER instruction_access_exception*/
 
 /* TT = 0x0a, TL = 0, instruction_access_error */
@@ -80,16 +72,4 @@
 	PREEMPTIBLE_HANDLER instruction_access_error
 
-/* TT = 0x0b, TL = 0, IAE_unauth_access */
-.org trap_table + TT_IAE_UNAUTH_ACCESS*ENTRY_SIZE
-.global iae_unauth_access_tl0
-iae_unauth_access_tl0:
-	PREEMPTIBLE_HANDLER instruction_access_exception
-
-/* TT = 0x0c, TL = 0, IAE_nfo_page */
-.org trap_table + TT_IAE_NFO_PAGE*ENTRY_SIZE
-.global iae_nfo_page_tl0
-iae_nfo_page_tl0:
-	PREEMPTIBLE_HANDLER instruction_access_exception
-
 /* TT = 0x10, TL = 0, illegal_instruction */
 .org trap_table + TT_ILLEGAL_INSTRUCTION*ENTRY_SIZE
@@ -116,28 +96,4 @@
 	PREEMPTIBLE_HANDLER unimplemented_STD
 
-/* TT = 0x14, TL = 0, DAE_invalid_asi */
-.org trap_table + TT_DAE_INVALID_ASI*ENTRY_SIZE
-.global dae_invalid_asi_tl0
-dae_invalid_asi_tl0:
-	PREEMPTIBLE_HANDLER data_access_exception
-
-/* TT = 0x15, TL = 0, DAE_privilege_violation */
-.org trap_table + TT_DAE_PRIVILEGE_VIOLATION*ENTRY_SIZE
-.global dae_privilege_violation_tl0
-dae_privilege_violation_tl0:
-	PREEMPTIBLE_HANDLER data_access_exception
-
-/* TT = 0x16, TL = 0, DAE_nc_page */
-.org trap_table + TT_DAE_NC_PAGE*ENTRY_SIZE
-.global dae_nc_page_tl0
-dae_nc_page_tl0:
-	PREEMPTIBLE_HANDLER data_access_exception
-
-/* TT = 0x17, TL = 0, DAE_nfo_page */
-.org trap_table + TT_DAE_NFO_PAGE*ENTRY_SIZE
-.global dae_nfo_page_tl0
-dae_nfo_page_tl0:
-	PREEMPTIBLE_HANDLER data_access_exception
-
 /* TT = 0x20, TL = 0, fb_disabled handler */
 .org trap_table + TT_FP_DISABLED*ENTRY_SIZE
@@ -177,16 +133,9 @@
 
 /* TT = 0x30, TL = 0, data_access_exception */
-/* TT = 0x30, TL = 0, DAE_side_effect_page for UltraPSARC T2 */
 .org trap_table + TT_DATA_ACCESS_EXCEPTION*ENTRY_SIZE
 .global data_access_exception_tl0
 data_access_exception_tl0:
+	wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
 	PREEMPTIBLE_HANDLER data_access_exception
-
-/* TT = 0x31, TL = 0, data_access_mmu_miss */
-.org trap_table + TT_DATA_ACCESS_MMU_MISS*ENTRY_SIZE
-.global data_access_mmu_miss_tl0
-data_access_mmu_miss_tl0:
-	ba fast_data_access_mmu_miss_handler_tl0
-	nop
 
 /* TT = 0x32, TL = 0, data_access_error */
@@ -322,4 +271,10 @@
 	INTERRUPT_LEVEL_N_HANDLER 15
 
+/* TT = 0x60, TL = 0, interrupt_vector_trap handler */
+.org trap_table + TT_INTERRUPT_VECTOR_TRAP*ENTRY_SIZE
+.global interrupt_vector_trap_handler_tl0
+interrupt_vector_trap_handler_tl0:
+	INTERRUPT_VECTOR_TRAP_HANDLER
+
 /* TT = 0x64, TL = 0, fast_instruction_access_MMU_miss */
 .org trap_table + TT_FAST_INSTRUCTION_ACCESS_MMU_MISS*ENTRY_SIZE
@@ -339,10 +294,4 @@
 fast_data_access_protection_handler_tl0:
 	FAST_DATA_ACCESS_PROTECTION_HANDLER 0
-
-/* TT = 0x7c, TL = 0, cpu_mondo */
-.org trap_table + TT_CPU_MONDO*ENTRY_SIZE
-.global cpu_mondo_handler_tl0
-cpu_mondo_handler_tl0:
-PREEMPTIBLE_HANDLER cpu_mondo
 
 /* TT = 0x80, TL = 0, spill_0_normal handler */
@@ -403,17 +352,10 @@
 
 /* TT = 0x08, TL > 0, instruction_access_exception */
-/* TT = 0x08, TL > 0, IAE_privilege_violation on UltraSPARC T2 */
 .org trap_table + (TT_INSTRUCTION_ACCESS_EXCEPTION+512)*ENTRY_SIZE
 .global instruction_access_exception_tl1
 instruction_access_exception_tl1:
 	wrpr %g0, 1, %tl
+	wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
 	PREEMPTIBLE_HANDLER instruction_access_exception
-
-/* TT = 0x09, TL > 0, instruction_access_mmu_miss */
-.org trap_table + (TT_INSTRUCTION_ACCESS_MMU_MISS+512)*ENTRY_SIZE
-.global instruction_access_mmu_miss_handler_tl1
-	wrpr %g0, 1, %tl
-	ba fast_instruction_access_mmu_miss_handler_tl0
-	nop
 
 /* TT = 0x0a, TL > 0, instruction_access_error */
@@ -424,18 +366,4 @@
 	PREEMPTIBLE_HANDLER instruction_access_error
 
-/* TT = 0x0b, TL > 0, IAE_unauth_access */
-.org trap_table + (TT_IAE_UNAUTH_ACCESS+512)*ENTRY_SIZE
-.global iae_unauth_access_tl1
-iae_unauth_access_tl1:
-	wrpr %g0, 1, %tl
-	PREEMPTIBLE_HANDLER instruction_access_exception
-
-/* TT = 0x0c, TL > 0, IAE_nfo_page */
-.org trap_table + (TT_IAE_NFO_PAGE+512)*ENTRY_SIZE
-.global iae_nfo_page_tl1
-iae_nfo_page_tl1:
-	wrpr %g0, 1, %tl
-	PREEMPTIBLE_HANDLER instruction_access_exception
-
 /* TT = 0x10, TL > 0, illegal_instruction */
 .org trap_table + (TT_ILLEGAL_INSTRUCTION+512)*ENTRY_SIZE
@@ -445,32 +373,4 @@
 	PREEMPTIBLE_HANDLER illegal_instruction
 
-/* TT = 0x14, TL > 0, DAE_invalid_asi */
-.org trap_table + (TT_DAE_INVALID_ASI+512)*ENTRY_SIZE
-.global dae_invalid_asi_tl1
-dae_invalid_asi_tl1:
-	wrpr %g0, 1, %tl
-	PREEMPTIBLE_HANDLER data_access_exception
-
-/* TT = 0x15, TL > 0, DAE_privilege_violation */
-.org trap_table + (TT_DAE_PRIVILEGE_VIOLATION+512)*ENTRY_SIZE
-.global dae_privilege_violation_tl1
-dae_privilege_violation_tl1:
-	wrpr %g0, 1, %tl
-	PREEMPTIBLE_HANDLER data_access_exception
-
-/* TT = 0x16, TL > 0, DAE_nc_page */
-.org trap_table + (TT_DAE_NC_PAGE+512)*ENTRY_SIZE
-.global dae_nc_page_tl1
-dae_nc_page_tl1:
-	wrpr %g0, 1, %tl
-	PREEMPTIBLE_HANDLER data_access_exception
-
-/* TT = 0x17, TL > 0, DAE_nfo_page */
-.org trap_table + (TT_DAE_NFO_PAGE+512)*ENTRY_SIZE
-.global dae_nfo_page_tl1
-dae_nfo_page_tl1:
-	wrpr %g0, 1, %tl
-	PREEMPTIBLE_HANDLER data_access_exception
-
 /* TT = 0x24, TL > 0, clean_window handler */
 .org trap_table + (TT_CLEAN_WINDOW+512)*ENTRY_SIZE
@@ -490,15 +390,7 @@
 .global data_access_exception_tl1
 data_access_exception_tl1:
-	/*wrpr %g0, 1, %tl
+	wrpr %g0, 1, %tl
 	wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
-	PREEMPTIBLE_HANDLER data_access_exception*/
-
-/* TT = 0x31, TL > 0, data_access_mmu_miss */
-.org trap_table + (TT_DATA_ACCESS_MMU_MISS+512)*ENTRY_SIZE
-.global data_access_mmu_miss_tl1
-data_access_mmu_miss_tl1:
-	ba fast_data_access_mmu_miss_handler_tl1
-	nop
-
+	PREEMPTIBLE_HANDLER data_access_exception
 
 /* TT = 0x32, TL > 0, data_access_error */
@@ -527,11 +419,4 @@
 fast_data_access_protection_handler_tl1:
 	FAST_DATA_ACCESS_PROTECTION_HANDLER 1
-
-/* TT = 0x7c, TL > 0, cpu_mondo */
-.org trap_table + (TT_CPU_MONDO+512)*ENTRY_SIZE
-.global cpu_mondo_handler_tl1
-cpu_mondo_handler_tl1:
-	wrpr %g0, %tl
-	PREEMPTIBLE_HANDLER cpu_mondo
 
 /* TT = 0x80, TL > 0, spill_0_normal handler */
@@ -775,4 +660,6 @@
 .endm
 
+
+#if 0
 /*
  * Preemptible trap handler for handling traps from kernel.
@@ -790,4 +677,163 @@
 	nop					! it will be easy to find
 
+	/* prevent unnecessary CLEANWIN exceptions */
+	wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(0), %wstate
+1:
+	/*
+	 * Prevent SAVE instruction from causing a spill exception. If the
+	 * CANSAVE register is zero, explicitly spill register window
+	 * at CWP + 2.
+	 */
+
+	rdpr %cansave, %g3
+	brnz %g3, 2f
+	nop
+	INLINE_SPILL %g3, %g4
+
+2:
+	/* ask for new register window */
+	save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
+
+	/* copy higher level routine's address and its argument */
+	mov %g1, %l0
+	mov %g2, %o0
+
+	/*
+	 * Save TSTATE, TPC and TNPC aside.
+	 */
+	rdpr %tstate, %g1
+	rdpr %tpc, %g2
+	rdpr %tnpc, %g3
+
+	stx %g1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TSTATE]
+	stx %g2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TPC]
+	stx %g3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC]
+
+	/*
+	 * Save the Y register.
+	 * This register is deprecated according to SPARC V9 specification
+	 * and is only present for backward compatibility with previous
+	 * versions of the SPARC architecture.
+	 * Surprisingly, gcc makes use of this register without a notice.
+	 */
+	rd %y, %g4
+	stx %g4, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_Y]
+
+	/* switch to TL = 0, explicitly enable FPU */
+	wrpr %g0, 0, %tl
+	wrpr %g0, 0, %gl
+	wrpr %g0, PSTATE_PRIV_BIT | PSTATE_PEF_BIT, %pstate
+
+	/* g1 -> l1, ..., g7 -> l7 */
+	SAVE_GLOBALS
+
+	/* call higher-level service routine, pass istate as its 2nd parameter */
+	call %l0
+	add %sp, PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC, %o1
+
+	/* l1 -> g1, ..., l7 -> g7 */
+	RESTORE_GLOBALS
+
+	/* we must prserve the PEF bit */
+	rdpr %pstate, %l1
+
+	/* TL := 1, GL := 1 */
+	wrpr %g0, PSTATE_PRIV_BIT, %pstate
+	wrpr %g0, 1, %tl
+	wrpr %g0, 1, %gl
+
+	/* Read TSTATE, TPC and TNPC from saved copy. */
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TSTATE], %g1
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TPC], %g2
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC], %g3
+
+	/* Copy PSTATE.PEF to the in-register copy of TSTATE. */
+	and %l1, PSTATE_PEF_BIT, %l1
+	sllx %l1, TSTATE_PSTATE_SHIFT, %l1
+	sethi %hi(TSTATE_PEF_BIT), %g4		! reset the PEF bit to 0 ...
+	andn %g1, %g4, %g1
+	or %g1, %l1, %g1			! ... "or" it with saved PEF
+
+	/* Restore TSTATE, TPC and TNPC from saved copies. */
+	wrpr %g1, 0, %tstate
+	wrpr %g2, 0, %tpc
+	wrpr %g3, 0, %tnpc
+
+	/* Restore Y. */
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_Y], %g4
+	wr %g4, %y
+	
+	/* If TSTATE.CWP + 1 == CWP, then we do not have to fix CWP. */
+	and %g1, TSTATE_CWP_MASK, %l0
+	inc %l0
+	and %l0, NWINDOWS - 1, %l0	! %l0 mod NWINDOWS
+	rdpr %cwp, %l1
+	cmp %l0, %l1
+	bz 4f				! CWP is ok
+	nop
+
+3:
+	/*
+	 * Fix CWP.
+	 * In order to recapitulate, the input registers in the current
+	 * window are the output registers of the window to which we want
+	 * to restore. Because the fill trap fills only input and local
+	 * registers of a window, we need to preserve those output
+	 * registers manually.
+	 */
+	mov %sp, %g2
+	stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0]
+	stx %i1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1]
+	stx %i2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2]
+	stx %i3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3]
+	stx %i4, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I4]
+	stx %i5, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I5]
+	stx %i6, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6]
+	stx %i7, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7]
+	wrpr %l0, 0, %cwp
+	mov %g2, %sp
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0], %i0
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1], %i1
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2], %i2
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3], %i3
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I4], %i4
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I5], %i5
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6], %i6
+	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7], %i7
+
+4:
+	/*
+	 * Prevent RESTORE instruction from causing a fill exception. If the
+	 * CANRESTORE register is zero, explicitly fill register window
+	 * at CWP - 1.
+	 */
+	rdpr %canrestore, %g1
+	brnz %g1, 5f
+	nop
+	INLINE_FILL %g3, %g4
+
+5:
+	restore
+
+	retry
+.endm
+
+#endif
+
+/*
+ * Preemptible trap handler for handling traps from kernel.
+ */
+.macro PREEMPTIBLE_HANDLER_KERNEL
+
+	/*
+	 * ASSERT(%tl == 1)
+	 */
+	rdpr %tl, %g3
+	cmp %g3, 1
+	be 1f
+	nop
+0:	ba 0b					! this is for debugging, if we ever get here
+	nop					! it will be easy to find
+
 1:
 	/* prevent unnecessary CLEANWIN exceptions */
@@ -826,4 +872,6 @@
 	retry
 .endm
+
+
 
 /*
@@ -1044,5 +1092,5 @@
 	and %g1, NWINDOWS - 1, %g1
 	wrpr %g1, 0, %cwp			! CWP--
-	
+
 .if \is_syscall
 	done
@@ -1052,4 +1100,6 @@
 
 .endm
+
+
 
 /* Preemptible trap handler for TL=1.
@@ -1082,2 +1132,3 @@
 trap_instruction_handler:
 	PREEMPTIBLE_HANDLER_TEMPLATE 1
+
Index: kernel/genarch/include/acpi/acpi.h
===================================================================
--- kernel/genarch/include/acpi/acpi.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/genarch/include/acpi/acpi.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -67,5 +67,5 @@
 	uint8_t *signature;
 	struct acpi_sdt_header **sdt_ptr;
-	const char *description;
+	char *description;
 };
 
Index: kernel/genarch/src/acpi/madt.c
===================================================================
--- kernel/genarch/src/acpi/madt.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/genarch/src/acpi/madt.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -72,5 +72,5 @@
 unsigned int madt_entries_index_cnt = 0;
 
-const char *entry[] = {
+char *entry[] = {
 	"L_APIC",
 	"IO_APIC",
Index: kernel/genarch/src/drivers/i8042/i8042.c
===================================================================
--- kernel/genarch/src/drivers/i8042/i8042.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/genarch/src/drivers/i8042/i8042.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -67,6 +67,7 @@
 	i8042_instance_t *instance = irq->instance;
 	i8042_t *dev = instance->i8042;
+	uint8_t status;
 	
-	if (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) {
+	if (((status = pio_read_8(&dev->status)) & i8042_BUFFER_FULL_MASK)) {
 		uint8_t data = pio_read_8(&dev->data);
 		indev_push_character(instance->kbrdin, data);
Index: kernel/generic/include/atomic.h
===================================================================
--- kernel/generic/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup generic
+/** @addtogroup generic	
  * @{
  */
@@ -36,18 +36,16 @@
 #define KERN_ATOMIC_H_
 
-#include <arch/types.h>
-
 typedef struct atomic {
-	volatile atomic_count_t count;
+	volatile long count;
 } atomic_t;
 
 #include <arch/atomic.h>
 
-static inline void atomic_set(atomic_t *val, atomic_count_t i)
+static inline void atomic_set(atomic_t *val, long i)
 {
 	val->count = i;
 }
 
-static inline atomic_count_t atomic_get(atomic_t *val)
+static inline long atomic_get(atomic_t *val)
 {
 	return val->count;
Index: kernel/generic/include/bitops.h
===================================================================
--- kernel/generic/include/bitops.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/bitops.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -65,6 +65,8 @@
 	}
 	
-	if (arg >> 1)
+	if (arg >> 1) {
+		arg >>= 1;
 		n += 1;
+	}
 	
 	return n;
Index: kernel/generic/include/console/chardev.h
===================================================================
--- kernel/generic/include/console/chardev.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/console/chardev.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -53,5 +53,5 @@
 /** Character input device. */
 typedef struct indev {
-	const char *name;
+	char *name;
 	waitq_t wq;
 	
@@ -81,5 +81,5 @@
 /** Character output device. */
 typedef struct outdev {
-	const char *name;
+	char *name;
 	
 	/** Protects everything below. */
@@ -95,10 +95,10 @@
 } outdev_t;
 
-extern void indev_initialize(const char *name, indev_t *indev,
+extern void indev_initialize(char *name, indev_t *indev,
     indev_operations_t *op);
 extern void indev_push_character(indev_t *indev, wchar_t ch);
 extern wchar_t indev_pop_character(indev_t *indev);
 
-extern void outdev_initialize(const char *name, outdev_t *outdev,
+extern void outdev_initialize(char *name, outdev_t *outdev,
     outdev_operations_t *op);
 
Index: kernel/generic/include/console/kconsole.h
===================================================================
--- kernel/generic/include/console/kconsole.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/console/kconsole.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -94,5 +94,5 @@
 extern void kconsole_notify_init(void);
 extern bool kconsole_check_poll(void);
-extern void kconsole(const char *prompt, const char *msg, bool kcon);
+extern void kconsole(char *prompt, char *msg, bool kcon);
 extern void kconsole_thread(void *data);
 
Index: kernel/generic/include/cpu.h
===================================================================
--- kernel/generic/include/cpu.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/cpu.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -48,5 +48,5 @@
  * There is one structure like this for every processor.
  */
-typedef struct cpu {
+typedef struct {
 	SPINLOCK_DECLARE(lock);
 
Index: kernel/generic/include/errno.h
===================================================================
--- kernel/generic/include/errno.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/errno.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -57,6 +57,11 @@
 #define EADDRNOTAVAIL	-12	/* Address not available. */
 #define ETIMEOUT        -13     /* Timeout expired */
+//MH
+#ifndef EINVAL
 #define EINVAL          -14     /* Invalid value */
+#endif
+#ifndef EBUSY
 #define EBUSY           -15     /* Resource is busy */
+#endif
 #define EOVERFLOW	-16	/* The result does not fit its size. */
 #define EINTR		-17	/* Operation was interrupted. */
Index: kernel/generic/include/interrupt.h
===================================================================
--- kernel/generic/include/interrupt.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/interrupt.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -46,5 +46,5 @@
 typedef void (* iroutine)(int n, istate_t *istate);
 
-extern void fault_if_from_uspace(istate_t *istate, const char *fmt, ...);
+extern void fault_if_from_uspace(istate_t *istate, char *fmt, ...);
 extern iroutine exc_register(int n, const char *name, iroutine f);
 extern void exc_dispatch(int n, istate_t *t);
Index: kernel/generic/include/lib/elf.h
===================================================================
--- kernel/generic/include/lib/elf.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/lib/elf.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -338,5 +338,5 @@
 #endif
 
-extern const char *elf_error(unsigned int rc);
+extern char *elf_error(unsigned int rc);
 
 /* Interpreter string used to recognize the program loader */
Index: kernel/generic/include/mm/slab.h
===================================================================
--- kernel/generic/include/mm/slab.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/mm/slab.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -86,5 +86,5 @@
 
 typedef struct {
-	const char *name;
+	char *name;
 	
 	link_t link;
@@ -123,5 +123,5 @@
 } slab_cache_t;
 
-extern slab_cache_t *slab_cache_create(const char *, size_t, size_t,
+extern slab_cache_t *slab_cache_create(char *, size_t, size_t,
     int (*)(void *, int), int (*)(void *), int);
 extern void slab_cache_destroy(slab_cache_t *);
Index: kernel/generic/include/panic.h
===================================================================
--- kernel/generic/include/panic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/panic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -60,5 +60,5 @@
 extern bool silent;
 
-extern void panic_printf(const char *fmt, ...) __attribute__((noreturn));
+extern void panic_printf(char *fmt, ...) __attribute__((noreturn));
 
 #endif
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/proc/task.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -130,5 +130,5 @@
 extern void task_init(void);
 extern void task_done(void);
-extern task_t *task_create(as_t *as, const char *name);
+extern task_t *task_create(as_t *as, char *name);
 extern void task_destroy(task_t *t);
 extern task_t *task_find_by_id(task_id_t id);
Index: kernel/generic/include/proc/thread.h
===================================================================
--- kernel/generic/include/proc/thread.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/proc/thread.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -52,5 +52,5 @@
 #define THREAD_NAME_BUFLEN	20
 
-extern const char *thread_states[];
+extern char *thread_states[];
 
 /* Thread flags */
@@ -225,6 +225,6 @@
 
 extern void thread_init(void);
-extern thread_t *thread_create(void (*)(void *), void *, task_t *, int,
-    const char *, bool);
+extern thread_t *thread_create(void (*)(void *), void *, task_t *, int, char *,
+    bool);
 extern void thread_attach(thread_t *, task_t *);
 extern void thread_ready(thread_t *);
Index: kernel/generic/include/stacktrace.h
===================================================================
--- kernel/generic/include/stacktrace.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/stacktrace.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -46,5 +46,5 @@
 	bool (* frame_pointer_prev)(uintptr_t, uintptr_t *);
 	bool (* return_address_get)(uintptr_t, uintptr_t *);
-	bool (* symbol_resolve)(uintptr_t, const char **, uintptr_t *);
+	bool (* symbol_resolve)(uintptr_t, char **, uintptr_t *);
 } stack_trace_ops_t;
 
Index: kernel/generic/include/symtab.h
===================================================================
--- kernel/generic/include/symtab.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/symtab.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -45,6 +45,6 @@
 };
 
-extern int symtab_name_lookup(uintptr_t, const char **, uintptr_t *);
-extern const char *symtab_fmt_name_lookup(uintptr_t);
+extern int symtab_name_lookup(uintptr_t, char **, uintptr_t *);
+extern char *symtab_fmt_name_lookup(uintptr_t);
 extern int symtab_addr_lookup(const char *, uintptr_t *);
 extern void symtab_print_search(const char *);
Index: kernel/generic/include/synch/spinlock.h
===================================================================
--- kernel/generic/include/synch/spinlock.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/include/synch/spinlock.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -48,5 +48,5 @@
 	
 #ifdef CONFIG_DEBUG_SPINLOCK
-	const char *name;
+	char *name;
 #endif
 } spinlock_t;
@@ -101,5 +101,5 @@
 	SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, #lock_name)
 
-extern void spinlock_initialize(spinlock_t *lock, const char *name);
+extern void spinlock_initialize(spinlock_t *lock, char *name);
 extern int spinlock_trylock(spinlock_t *lock);
 extern void spinlock_lock_debug(spinlock_t *lock);
Index: kernel/generic/src/console/chardev.c
===================================================================
--- kernel/generic/src/console/chardev.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/console/chardev.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -47,5 +47,5 @@
  *
  */
-void indev_initialize(const char *name, indev_t *indev,
+void indev_initialize(char *name, indev_t *indev,
     indev_operations_t *op)
 {
@@ -130,5 +130,5 @@
  *
  */
-void outdev_initialize(const char *name, outdev_t *outdev,
+void outdev_initialize(char *name, outdev_t *outdev,
     outdev_operations_t *op)
 {
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/console/cmd.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -1033,5 +1033,5 @@
 	/* Execute the test */
 	test_quiet = false;
-	const char *ret = test->entry();
+	char *ret = test->entry();
 	
 	/* Update and read thread accounting */
@@ -1086,5 +1086,5 @@
 		/* Execute the test */
 		test_quiet = true;
-		const char *ret = test->entry();
+		char * ret = test->entry();
 		
 		/* Update and read thread accounting */
Index: kernel/generic/src/console/kconsole.c
===================================================================
--- kernel/generic/src/console/kconsole.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/console/kconsole.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -224,5 +224,5 @@
 		printf("\n");
 		pos = NULL;
-		while (cmdtab_search_one(name, &pos)) {
+		while ((hint = cmdtab_search_one(name, &pos))) {
 			cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link);
 			printf("%s (%s)\n", hlp->name, hlp->description);
@@ -643,5 +643,5 @@
  *
  */
-void kconsole(const char *prompt, const char *msg, bool kcon)
+void kconsole(char *prompt, char *msg, bool kcon)
 {
 	if (!stdin) {
Index: kernel/generic/src/debug/stacktrace.c
===================================================================
--- kernel/generic/src/debug/stacktrace.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/debug/stacktrace.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -44,7 +44,7 @@
 {
 	int cnt = 0;
-	const char *symbol;
+	char *symbol;
 	uintptr_t offset;
-	
+
 	while (cnt++ < STACK_FRAMES_MAX && ops->frame_pointer_validate(fp)) {
 		if (ops->symbol_resolve &&
@@ -85,5 +85,5 @@
 }
 
-static bool kernel_symbol_resolve(uintptr_t addr, const char **sp, uintptr_t *op)
+static bool kernel_symbol_resolve(uintptr_t addr, char **sp, uintptr_t *op)
 {
 	return (symtab_name_lookup(addr, sp, op) == 0);
Index: kernel/generic/src/debug/symtab.c
===================================================================
--- kernel/generic/src/debug/symtab.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/debug/symtab.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,5 +54,5 @@
  *
  */
-int symtab_name_lookup(uintptr_t addr, const char **name, uintptr_t *offset)
+int symtab_name_lookup(uintptr_t addr, char **name, uintptr_t *offset)
 {
 #ifdef CONFIG_SYMTAB
@@ -92,7 +92,7 @@
  *
  */
-const char *symtab_fmt_name_lookup(uintptr_t addr)
-{
-	const char *name;
+char *symtab_fmt_name_lookup(uintptr_t addr)
+{
+	char *name;
 	int rc = symtab_name_lookup(addr, &name, NULL);
 	
@@ -239,5 +239,5 @@
 		printf("\n");
 		pos = 0;
-		while (symtab_search_one(name, &pos)) {
+		while ((hint = symtab_search_one(name, &pos))) {
 			printf("%s\n", symbol_table[pos].symbol_name);
 			pos++;
Index: kernel/generic/src/interrupt/interrupt.c
===================================================================
--- kernel/generic/src/interrupt/interrupt.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/interrupt/interrupt.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -114,5 +114,5 @@
 
 /** Terminate thread and task if exception came from userspace. */
-void fault_if_from_uspace(istate_t *istate, const char *fmt, ...)
+void fault_if_from_uspace(istate_t *istate, char *fmt, ...)
 {
 	task_t *task = TASK;
@@ -162,4 +162,5 @@
 #if (IVT_ITEMS > 0)
 	unsigned int i;
+	char *symbol;
 
 	spinlock_lock(&exctbl_lock);
@@ -176,5 +177,5 @@
 	
 	for (i = 0; i < IVT_ITEMS; i++) {
-		const char *symbol = symtab_fmt_name_lookup((unative_t) exc_table[i].f);
+		symbol = symtab_fmt_name_lookup((unative_t) exc_table[i].f);
 
 #ifdef __32_BITS__
Index: kernel/generic/src/lib/elf.c
===================================================================
--- kernel/generic/src/lib/elf.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/lib/elf.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -48,5 +48,5 @@
 #include <arch.h>
 
-static const char *error_codes[] = {
+static char *error_codes[] = {
 	"no error",
 	"invalid image",
@@ -137,5 +137,5 @@
  * @return NULL terminated description of error.
  */
-const char *elf_error(unsigned int rc)
+char *elf_error(unsigned int rc)
 {
 	ASSERT(rc < sizeof(error_codes) / sizeof(char *));
@@ -155,4 +155,6 @@
     as_t *as, int flags)
 {
+	char *interp;
+
 	switch (entry->p_type) {
 	case PT_NULL:
@@ -163,11 +165,10 @@
 	case PT_DYNAMIC:
 	case PT_INTERP:
-		// FIXME
-		/*
-		char *interp = (char *) elf + entry->p_offset;
-		if (memcmp((uintptr_t) interp, (uintptr_t) ELF_INTERP_ZSTR,
+		interp = (char *)elf + entry->p_offset;
+		/* FIXME */
+		/*if (memcmp((uintptr_t)interp, (uintptr_t)ELF_INTERP_ZSTR,
 		    ELF_INTERP_ZLEN) != 0) {
 			return EE_UNSUPPORTED;
-		} */
+		}*/
 		if ((flags & ELD_F_LOADER) == 0) {
 			return EE_LOADER;
Index: kernel/generic/src/main/kinit.c
===================================================================
--- kernel/generic/src/main/kinit.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/main/kinit.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -183,6 +183,7 @@
 		
 		char namebuf[TASK_NAME_BUFLEN];
-		
-		const char *name = init.tasks[i].name;
+		char *name;
+		
+		name = init.tasks[i].name;
 		if (name[0] == 0)
 			name = "<unknown>";
Index: kernel/generic/src/main/version.c
===================================================================
--- kernel/generic/src/main/version.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/main/version.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -37,20 +37,20 @@
 #include <macros.h>
 
-static const char *project = "SPARTAN kernel";
-static const char *copyright = "Copyright (c) 2001-2010 HelenOS project";
-static const char *release = STRING(RELEASE);
-static const char *name = STRING(NAME);
-static const char *arch = STRING(KARCH);
+char *project = "SPARTAN kernel";
+char *copyright = "Copyright (c) 2001-2009 HelenOS project";
+char *release = STRING(RELEASE);
+char *name = STRING(NAME);
+char *arch = STRING(KARCH);
 
 #ifdef REVISION
-	static const char *revision = ", revision " STRING(REVISION);
+	char *revision = ", revision " STRING(REVISION);
 #else
-	static const char *revision = "";
+	char *revision = "";
 #endif
 
 #ifdef TIMESTAMP
-	static const char *timestamp = " on " STRING(TIMESTAMP);
+	char *timestamp = " on " STRING(TIMESTAMP);
 #else
-	static const char *timestamp = "";
+	char *timestamp = "";
 #endif
 
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/mm/as.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -784,4 +784,5 @@
 {
 	as_area_t *area;
+	uintptr_t base;
 	link_t *cur;
 	ipl_t ipl;
@@ -812,4 +813,6 @@
 		return ENOTSUP;
 	}
+
+	base = area->base;
 
 	/*
@@ -949,10 +952,9 @@
 	if (!THREAD)
 		return AS_PF_FAULT;
-	
-	if (!AS)
-		return AS_PF_FAULT;
-	
+		
+	ASSERT(AS);
+
 	mutex_lock(&AS->lock);
-	area = find_area_and_lock(AS, page);
+	area = find_area_and_lock(AS, page);	
 	if (!area) {
 		/*
Index: kernel/generic/src/mm/backend_elf.c
===================================================================
--- kernel/generic/src/mm/backend_elf.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/mm/backend_elf.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -232,9 +232,14 @@
 void elf_frame_free(as_area_t *area, uintptr_t page, uintptr_t frame)
 {
+	elf_header_t *elf = area->backend_data.elf;
 	elf_segment_header_t *entry = area->backend_data.segment;
-	uintptr_t start_anon;
+	uintptr_t base, start_anon;
+	size_t i;
 
 	ASSERT((page >= ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) &&
 	    (page < entry->p_vaddr + entry->p_memsz));
+	i = (page - ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE)) >> PAGE_WIDTH;
+	base = (uintptr_t) (((void *) elf) +
+	    ALIGN_DOWN(entry->p_offset, FRAME_SIZE));
 	start_anon = entry->p_vaddr + entry->p_filesz;
 
@@ -252,5 +257,5 @@
 		 * lower part is backed by the ELF image and the upper is
 		 * anonymous). In any case, a frame needs to be freed.
-		 */
+		 */ 
 		frame_free(frame);
 	}
Index: kernel/generic/src/mm/slab.c
===================================================================
--- kernel/generic/src/mm/slab.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/mm/slab.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -130,5 +130,5 @@
 /** Caches for malloc */
 static slab_cache_t *malloc_caches[SLAB_MAX_MALLOC_W - SLAB_MIN_MALLOC_W + 1];
-static const char *malloc_names[] =  {
+static char *malloc_names[] =  {
 	"malloc-16",
 	"malloc-32",
@@ -571,7 +571,8 @@
 
 /** Initialize allocated memory as a slab cache */
-static void _slab_cache_create(slab_cache_t *cache, const char *name,
-    size_t size, size_t align, int (*constructor)(void *obj, int kmflag),
-    int (*destructor)(void *obj), int flags)
+static void
+_slab_cache_create(slab_cache_t *cache, char *name, size_t size, size_t align,
+    int (*constructor)(void *obj, int kmflag), int (*destructor)(void *obj),
+    int flags)
 {
 	int pages;
@@ -630,5 +631,6 @@
 
 /** Create slab cache  */
-slab_cache_t *slab_cache_create(const char *name, size_t size, size_t align,
+slab_cache_t *
+slab_cache_create(char *name, size_t size, size_t align,
     int (*constructor)(void *obj, int kmflag), int (*destructor)(void *obj),
     int flags)
@@ -851,5 +853,5 @@
 		cache = list_get_instance(cur, slab_cache_t, link);
 
-		const char *name = cache->name;
+		char *name = cache->name;
 		uint8_t order = cache->order;
 		size_t size = cache->size;
@@ -894,5 +896,5 @@
 		    NULL, NULL, SLAB_CACHE_MAGDEFERRED);
 	}
-#ifdef CONFIG_DEBUG
+#ifdef CONFIG_DEBUG       
 	_slab_initialized = 1;
 #endif
Index: kernel/generic/src/proc/scheduler.c
===================================================================
--- kernel/generic/src/proc/scheduler.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/proc/scheduler.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -542,9 +542,6 @@
 {
 	thread_t *t;
-	int count;
-	atomic_count_t average;
+	int count, average, j, k = 0;
 	unsigned int i;
-	int j;
-	int k = 0;
 	ipl_t ipl;
 
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/proc/task.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -171,5 +171,5 @@
  *
  */
-task_t *task_create(as_t *as, const char *name)
+task_t *task_create(as_t *as, char *name)
 {
 	ipl_t ipl;
Index: kernel/generic/src/proc/thread.c
===================================================================
--- kernel/generic/src/proc/thread.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/proc/thread.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -76,5 +76,5 @@
 
 /** Thread states */
-const char *thread_states[] = {
+char *thread_states[] = {
 	"Invalid",
 	"Running",
@@ -264,5 +264,4 @@
 
 	atomic_inc(&nrdy);
-	// FIXME: Why is the avg value never read?
 	avg = atomic_get(&nrdy) / config.cpu_active;
 	atomic_inc(&cpu->nrdy);
@@ -289,5 +288,5 @@
  */
 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task,
-    int flags, const char *name, bool uncounted)
+    int flags, char *name, bool uncounted)
 {
 	thread_t *t;
Index: kernel/generic/src/synch/spinlock.c
===================================================================
--- kernel/generic/src/synch/spinlock.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/synch/spinlock.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -52,5 +52,5 @@
  *
  */
-void spinlock_initialize(spinlock_t *lock, const char *name)
+void spinlock_initialize(spinlock_t *lock, char *name)
 {
 	atomic_set(&lock->val, 0);
Index: kernel/generic/src/sysinfo/sysinfo.c
===================================================================
--- kernel/generic/src/sysinfo/sysinfo.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/sysinfo/sysinfo.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -46,5 +46,5 @@
 		return NULL;
 	
-	while (subtree != NULL) {
+	while (subtree != NULL)	{
 		int i = 0;
 		char *a = (char *) name;
@@ -68,4 +68,5 @@
 		/* No matches try next */
 		subtree = subtree->next;
+		i = 0;
 	}
 	return NULL;
@@ -158,6 +159,8 @@
 			item->subinfo_type = SYSINFO_SUBINFO_NONE;
 			return item;
-		} else
+		} else {
 			subtree = subtree->next;
+			i = 0;
+		}	
 	}
 
@@ -222,5 +225,5 @@
 		int i;
 		unative_t val = 0;
-		const char *vtype = NULL;
+		char *vtype = NULL;
 		
 		
Index: kernel/generic/src/udebug/udebug_ops.c
===================================================================
--- kernel/generic/src/udebug/udebug_ops.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/generic/src/udebug/udebug_ops.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -80,5 +80,8 @@
 static int _thread_op_begin(thread_t *t, bool being_go)
 {
+	task_id_t taskid;
 	ipl_t ipl;
+
+	taskid = TASK->taskid;
 
 	mutex_lock(&TASK->udebug.lock);
Index: kernel/test/atomic/atomic1.c
===================================================================
--- kernel/test/atomic/atomic1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/atomic/atomic1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -32,5 +32,5 @@
 #include <debug.h>
 
-const char *test_atomic1(void)
+char *test_atomic1(void)
 {
 	atomic_t a;
Index: kernel/test/avltree/avltree1.c
===================================================================
--- kernel/test/avltree/avltree1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/avltree/avltree1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -265,5 +265,5 @@
 }
 
-const char *test_avltree1(void)
+char *test_avltree1(void)
 {
 	alloc_avltree_node_prepare();
Index: kernel/test/btree/btree1.c
===================================================================
--- kernel/test/btree/btree1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/btree/btree1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -34,5 +34,5 @@
 static void *data = (void *) 0xdeadbeef;
 
-const char *test_btree1(void)
+char *test_btree1(void)
 {
 	btree_t t;
Index: kernel/test/debug/mips1.c
===================================================================
--- kernel/test/debug/mips1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/debug/mips1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -37,5 +37,5 @@
 #include <arch.h>
 
-const char *test_mips1(void)
+char *test_mips1(void)
 {
 	TPRINTF("If kconsole is compiled in, you should enter debug mode now.\n");
Index: kernel/test/debug/mips1_skip.c
===================================================================
--- kernel/test/debug/mips1_skip.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/debug/mips1_skip.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -29,5 +29,5 @@
 #include <test.h>
 
-const char *test_mips1(void)
+char *test_mips1(void)
 {
 	return NULL;
Index: kernel/test/fault/fault1.c
===================================================================
--- kernel/test/fault/fault1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/fault/fault1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -37,5 +37,5 @@
 #include <arch.h>
 
-const char *test_fault1(void)
+char *test_fault1(void)
 {
 	((int *)(0))[1] = 0;
Index: kernel/test/fpu/fpu1_ia64.c
===================================================================
--- kernel/test/fpu/fpu1_ia64.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/fpu/fpu1_ia64.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -126,8 +126,7 @@
 }
 
-const char *test_fpu1(void)
+char *test_fpu1(void)
 {
-	unsigned int i;
-	atomic_count_t total = 0;
+	unsigned int i, total = 0;
 	
 	waitq_initialize(&can_start);
@@ -160,5 +159,5 @@
 	waitq_wakeup(&can_start, WAKEUP_ALL);
 	
-	while (atomic_get(&threads_ok) != total) {
+	while (atomic_get(&threads_ok) != (long) total) {
 		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
 		thread_sleep(1);
Index: kernel/test/fpu/fpu1_skip.c
===================================================================
--- kernel/test/fpu/fpu1_skip.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/fpu/fpu1_skip.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -29,5 +29,5 @@
 #include <test.h>
 
-const char *test_fpu1(void)
+char *test_fpu1(void)
 {
 	return NULL;
Index: kernel/test/fpu/fpu1_x86.c
===================================================================
--- kernel/test/fpu/fpu1_x86.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/fpu/fpu1_x86.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -123,8 +123,7 @@
 }
 
-const char *test_fpu1(void)
+char *test_fpu1(void)
 {
-	unsigned int i;
-	atomic_count_t total = 0;
+	unsigned int i, total = 0;
 	
 	waitq_initialize(&can_start);
@@ -157,5 +156,5 @@
 	waitq_wakeup(&can_start, WAKEUP_ALL);
 	
-	while (atomic_get(&threads_ok) != total) {
+	while (atomic_get(&threads_ok) != (long) total) {
 		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
 		thread_sleep(1);
Index: kernel/test/fpu/mips2.c
===================================================================
--- kernel/test/fpu/mips2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/fpu/mips2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -109,8 +109,7 @@
 
 
-const char *test_mips2(void)
+char *test_mips2(void)
 {
-	unsigned int i;
-	atomic_count_t total = 0;
+	unsigned int i, total = 0;
 	
 	waitq_initialize(&can_start);
@@ -139,9 +138,9 @@
 	
 	TPRINTF("ok\n");
-	
+		
 	thread_sleep(1);
 	waitq_wakeup(&can_start, WAKEUP_ALL);
 	
-	while (atomic_get(&threads_ok) != total) {
+	while (atomic_get(&threads_ok) != (long) total) {
 		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
 		thread_sleep(1);
Index: kernel/test/fpu/mips2_skip.c
===================================================================
--- kernel/test/fpu/mips2_skip.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/fpu/mips2_skip.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -29,5 +29,5 @@
 #include <test.h>
 
-const char *test_mips2(void)
+char *test_mips2(void)
 {
 	return NULL;
Index: kernel/test/fpu/sse1.c
===================================================================
--- kernel/test/fpu/sse1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/fpu/sse1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -107,8 +107,7 @@
 }
 
-const char *test_sse1(void)
+char *test_sse1(void)
 {
-	unsigned int i;
-	atomic_count_t total = 0;
+	unsigned int i, total = 0;
 	
 	waitq_initialize(&can_start);
@@ -141,5 +140,5 @@
 	waitq_wakeup(&can_start, WAKEUP_ALL);
 	
-	while (atomic_get(&threads_ok) != total) {
+	while (atomic_get(&threads_ok) != (long) total) {
 		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
 		thread_sleep(1);
Index: kernel/test/fpu/sse1_skip.c
===================================================================
--- kernel/test/fpu/sse1_skip.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/fpu/sse1_skip.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -29,5 +29,5 @@
 #include <test.h>
 
-const char *test_sse1(void)
+char *test_sse1(void)
 {
 	return NULL;
Index: kernel/test/mm/falloc1.c
===================================================================
--- kernel/test/mm/falloc1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/mm/falloc1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -41,5 +41,5 @@
 #define TEST_RUNS   2
 
-const char *test_falloc1(void) {
+char *test_falloc1(void) {
 	uintptr_t *frames
 	    = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
Index: kernel/test/mm/falloc2.c
===================================================================
--- kernel/test/mm/falloc2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/mm/falloc2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -104,5 +104,5 @@
 }
 
-const char *test_falloc2(void)
+char *test_falloc2(void)
 {
 	unsigned int i;
Index: kernel/test/mm/mapping1.c
===================================================================
--- kernel/test/mm/mapping1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/mm/mapping1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -42,5 +42,5 @@
 #define VALUE1  0x89abcdef
 
-const char *test_mapping1(void)
+char *test_mapping1(void)
 {
 	uintptr_t frame0, frame1;
Index: kernel/test/mm/purge1.c
===================================================================
--- kernel/test/mm/purge1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/mm/purge1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,5 +40,5 @@
 extern void tlb_invalidate_pages(asid_t asid, uintptr_t va, size_t cnt);
 
-const char *test_purge1(void)
+char *test_purge1(void)
 {
 	tlb_entry_t entryi;
Index: kernel/test/mm/purge1_skip.c
===================================================================
--- kernel/test/mm/purge1_skip.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/mm/purge1_skip.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -29,5 +29,5 @@
 #include <test.h>
 
-const char *test_purge1(void)
+char *test_purge1(void)
 {
 	return NULL;
Index: kernel/test/mm/slab1.c
===================================================================
--- kernel/test/mm/slab1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/mm/slab1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -170,5 +170,5 @@
 }
 
-const char *test_slab1(void)
+char *test_slab1(void)
 {
 	testsimple();
Index: kernel/test/mm/slab2.c
===================================================================
--- kernel/test/mm/slab2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/mm/slab2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -226,5 +226,5 @@
 }
 
-const char *test_slab2(void)
+char *test_slab2(void)
 {
 	TPRINTF("Running reclaim single-thread test .. pass 1\n");
Index: kernel/test/print/print1.c
===================================================================
--- kernel/test/print/print1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/print/print1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -30,5 +30,5 @@
 #include <test.h>
 
-const char *test_print1(void)
+char *test_print1(void)
 {
 	TPRINTF("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n");
Index: kernel/test/print/print2.c
===================================================================
--- kernel/test/print/print2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/print/print2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -30,5 +30,5 @@
 #include <test.h>
 
-const char *test_print2(void)
+char *test_print2(void)
 {
 	TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n");
Index: kernel/test/print/print3.c
===================================================================
--- kernel/test/print/print3.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/print/print3.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -33,5 +33,5 @@
 #define BUFFER_SIZE  32
 
-const char *test_print3(void)
+char *test_print3(void)
 {
 	char buffer[BUFFER_SIZE];
Index: kernel/test/print/print4.c
===================================================================
--- kernel/test/print/print4.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/print/print4.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -30,5 +30,5 @@
 #include <test.h>
 
-const char *test_print4(void)
+char *test_print4(void)
 {
 	TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n");
Index: kernel/test/synch/rwlock1.c
===================================================================
--- kernel/test/synch/rwlock1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/synch/rwlock1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -41,5 +41,5 @@
 static rwlock_t rwlock;
 
-const char *test_rwlock1(void)
+char *test_rwlock1(void)
 {
 	rwlock_initialize(&rwlock);
Index: kernel/test/synch/rwlock2.c
===================================================================
--- kernel/test/synch/rwlock2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/synch/rwlock2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -53,5 +53,5 @@
 }
 
-const char *test_rwlock2(void)
+char *test_rwlock2(void)
 {
 	thread_t *thrd;
Index: kernel/test/synch/rwlock3.c
===================================================================
--- kernel/test/synch/rwlock3.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/synch/rwlock3.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -60,5 +60,5 @@
 }
 
-const char *test_rwlock3(void)
+char *test_rwlock3(void)
 {
 	int i;
Index: kernel/test/synch/rwlock4.c
===================================================================
--- kernel/test/synch/rwlock4.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/synch/rwlock4.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -132,5 +132,5 @@
 }
 
-const char *test_rwlock4(void)
+char *test_rwlock4(void)
 {
 	context_t ctx;
Index: kernel/test/synch/rwlock5.c
===================================================================
--- kernel/test/synch/rwlock5.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/synch/rwlock5.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -67,9 +67,8 @@
 }
 
-const char *test_rwlock5(void)
+char *test_rwlock5(void)
 {
 	int i, j, k;
-	atomic_count_t readers;
-	atomic_count_t writers;
+	long readers, writers;
 	
 	waitq_initialize(&can_start);
Index: kernel/test/synch/semaphore1.c
===================================================================
--- kernel/test/synch/semaphore1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/synch/semaphore1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -70,9 +70,8 @@
 }
 
-const char *test_semaphore1(void)
+char *test_semaphore1(void)
 {
 	int i, j, k;
-	atomic_count_t consumers;
-	atomic_count_t producers;
+	int consumers, producers;
 	
 	waitq_initialize(&can_start);
Index: kernel/test/synch/semaphore2.c
===================================================================
--- kernel/test/synch/semaphore2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/synch/semaphore2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -82,5 +82,5 @@
 }
 
-const char *test_semaphore2(void)
+char *test_semaphore2(void)
 {
 	uint32_t i, k;
Index: kernel/test/sysinfo/sysinfo1.c
===================================================================
--- kernel/test/sysinfo/sysinfo1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/sysinfo/sysinfo1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -33,5 +33,5 @@
 #include <sysinfo/sysinfo.h>
 
-const char *test_sysinfo1(void)
+char *test_sysinfo1(void)
 {
 	if (!test_quiet)
Index: kernel/test/test.h
===================================================================
--- kernel/test/test.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/test.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -48,40 +48,40 @@
 	}
 
-typedef const char *(*test_entry_t)(void);
+typedef char *(*test_entry_t)(void);
 
 typedef struct {
-	const char *name;
-	const char *desc;
+	char *name;
+	char *desc;
 	test_entry_t entry;
 	bool safe;
 } test_t;
 
-extern const char *test_atomic1(void);
-extern const char *test_avltree1(void);
-extern const char *test_btree1(void);
-extern const char *test_mips1(void);
-extern const char *test_fault1(void);
-extern const char *test_fpu1(void);
-extern const char *test_sse1(void);
-extern const char *test_mips2(void);
-extern const char *test_falloc1(void);
-extern const char *test_falloc2(void);
-extern const char *test_mapping1(void);
-extern const char *test_purge1(void);
-extern const char *test_slab1(void);
-extern const char *test_slab2(void);
-extern const char *test_rwlock1(void);
-extern const char *test_rwlock2(void);
-extern const char *test_rwlock3(void);
-extern const char *test_rwlock4(void);
-extern const char *test_rwlock5(void);
-extern const char *test_semaphore1(void);
-extern const char *test_semaphore2(void);
-extern const char *test_print1(void);
-extern const char *test_print2(void);
-extern const char *test_print3(void);
-extern const char *test_print4(void);
-extern const char *test_thread1(void);
-extern const char *test_sysinfo1(void);
+extern char *test_atomic1(void);
+extern char *test_avltree1(void);
+extern char *test_btree1(void);
+extern char *test_mips1(void);
+extern char *test_fault1(void);
+extern char *test_fpu1(void);
+extern char *test_sse1(void);
+extern char *test_mips2(void);
+extern char *test_falloc1(void);
+extern char *test_falloc2(void);
+extern char *test_mapping1(void);
+extern char *test_purge1(void);
+extern char *test_slab1(void);
+extern char *test_slab2(void);
+extern char *test_rwlock1(void);
+extern char *test_rwlock2(void);
+extern char *test_rwlock3(void);
+extern char *test_rwlock4(void);
+extern char *test_rwlock5(void);
+extern char *test_semaphore1(void);
+extern char *test_semaphore2(void);
+extern char *test_print1(void);
+extern char *test_print2(void);
+extern char *test_print3(void);
+extern char *test_print4(void);
+extern char *test_thread1(void);
+extern char *test_sysinfo1(void);
 
 extern test_t tests[];
Index: kernel/test/thread/thread1.c
===================================================================
--- kernel/test/thread/thread1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ kernel/test/thread/thread1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -53,13 +53,12 @@
 }
 
-const char *test_thread1(void)
+char *test_thread1(void)
 {
-	unsigned int i;
-	atomic_count_t total = 0;
+	unsigned int i, total = 0;
 	
 	atomic_set(&finish, 1);
 	atomic_set(&threads_finished, 0);
 	
-	for (i = 0; i < THREADS; i++) {
+	for (i = 0; i < THREADS; i++) {  
 		thread_t *t;
 		if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest", false))) {
@@ -75,5 +74,5 @@
 	
 	atomic_set(&finish, 0);
-	while (atomic_get(&threads_finished) < total) {
+	while (atomic_get(&threads_finished) < ((long) total)) {
 		TPRINTF("Threads left: %d\n", total - atomic_get(&threads_finished));
 		thread_sleep(1);
Index: ols/checkers/clang.py
===================================================================
--- tools/checkers/clang.py	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ 	(revision )
@@ -1,124 +1,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2010 Martin Decky
-# 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.
-#
-"""
-Wrapper for Clang static analyzer
-"""
-
-import sys
-import os
-import subprocess
-import jobfile
-
-jobs = [
-	"kernel/kernel.job"
-]
-
-def usage(prname):
-	"Print usage syntax"
-	print prname + " <ROOT>"
-
-def clang(root, job):
-	"Run Clang on a jobfile"
-	
-	inname = os.path.join(root, job)
-	
-	if (not os.path.isfile(inname)):
-		print "Unable to open %s" % inname
-		print "Did you run \"make precheck\" on the source tree?"
-		return False
-	
-	inf = file(inname, "r")
-	records = inf.read().splitlines()
-	inf.close()
-	
-	for record in records:
-		arg = jobfile.parse_arg(record)
-		if (not arg):
-			return False
-		
-		if (len(arg) < 6):
-			print "Not enought jobfile record arguments"
-			return False
-		
-		srcfname = arg[0]
-		tgtfname = arg[1]
-		tool = arg[2]
-		category = arg[3]
-		base = arg[4]
-		options = arg[5].split()
-		
-		srcfqname = os.path.join(base, srcfname)
-		if (not os.path.isfile(srcfqname)):
-			print "Source %s not found" % srcfqname
-			return False
-		
-		# Only C files are interesting for us
-		if (tool != "cc"):
-			continue
-		
-		args = ['clang', '-Qunused-arguments', '--analyze',
-			'-Xanalyzer', '-analyzer-opt-analyze-headers',
-			'-Xanalyzer', '-checker-cfref']
-		args.extend(options)
-		args.extend(['-o', tgtfname, srcfname])
-		
-		cwd = os.getcwd()
-		os.chdir(base)
-		retval = subprocess.Popen(args).wait()
-		os.chdir(cwd)
-		
-		if (retval != 0):
-			return False
-		
-	return True
-
-def main():
-	if (len(sys.argv) < 2):
-		usage(sys.argv[0])
-		return
-	
-	rootdir = os.path.abspath(sys.argv[1])
-	config = os.path.join(rootdir, "HelenOS.config")
-	
-	if (not os.path.isfile(config)):
-		print "%s not found." % config
-		print "Please specify the path to HelenOS build tree root as the first argument."
-		return
-	
-	for job in jobs:
-		if (not clang(rootdir, job)):
-			print
-			print "Failed job: %s" % job
-			return
-	
-	print
-	print "All jobs passed"
-
-if __name__ == '__main__':
-	main()
Index: tools/checkers/stanse.py
===================================================================
--- tools/checkers/stanse.py	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ tools/checkers/stanse.py	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -74,6 +74,4 @@
 		srcfname = arg[0]
 		tgtfname = arg[1]
-		tool = arg[2]
-		category = arg[3]
 		base = arg[4]
 		options = arg[5]
@@ -85,5 +83,5 @@
 		
 		# Only C files are interesting for us
-		if (tool != "cc"):
+		if (arg[2] != "cc"):
 			continue
 		
Index: tools/checkers/vcc.py
===================================================================
--- tools/checkers/vcc.py	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ tools/checkers/vcc.py	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -70,5 +70,5 @@
 		# Ignore preprocessor directives
 		if (line.startswith('#')):
-			continue
+			continue	
 		
 		tmpf.write("%s\n" % line)
@@ -107,6 +107,4 @@
 		srcfname = arg[0]
 		tgtfname = arg[1]
-		tool = arg[2]
-		category = arg[3]
 		base = arg[4]
 		options = arg[5]
@@ -121,5 +119,5 @@
 		
 		# Only C files are interesting for us
-		if (tool != "cc"):
+		if (arg[2] != "cc"):
 			continue
 		
Index: uspace/app/bdsh/cmds/builtins/cd/cd.c
===================================================================
--- uspace/app/bdsh/cmds/builtins/cd/cd.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/builtins/cd/cd.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -41,5 +41,5 @@
 #include "cd.h"
 
-static const char *cmdname = "cd";
+static char * cmdname = "cd";
 
 void help_cmd_cd(unsigned int level)
Index: uspace/app/bdsh/cmds/cmds.h
===================================================================
--- uspace/app/bdsh/cmds/cmds.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/cmds.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -33,6 +33,6 @@
 /* Module structure */
 typedef struct {
-	const char *name;   /* Name of the command */
-	const char *desc;   /* Description of the command */
+	char *name;         /* Name of the command */
+	char *desc;         /* Description of the command */
 	mod_entry_t entry;  /* Command (exec) entry function */
 	mod_help_t help;    /* Command (help) entry function */
@@ -41,6 +41,6 @@
 /* Builtin structure, same as modules except different types of entry points */
 typedef struct {
-	const char *name;
-	const char *desc;
+	char *name;
+	char *desc;
 	builtin_entry_t entry;
 	builtin_help_t help;
@@ -57,5 +57,5 @@
 extern int is_module(const char *);
 extern int is_module_alias(const char *);
-extern char *alias_for_module(const char *);
+extern char * alias_for_module(const char *);
 extern int help_module(int, unsigned int);
 extern int run_module(int, char *[]);
@@ -65,5 +65,5 @@
 extern int is_builtin(const char *);
 extern int is_builtin_alias(const char *);
-extern char *alias_for_builtin(const char *);
+extern char * alias_for_builtin(const char *);
 extern int help_builtin(int, unsigned int);
 extern int run_builtin(int, char *[], cliuser_t *);
Index: uspace/app/bdsh/cmds/modules/cat/cat.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/cat/cat.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -43,9 +43,9 @@
 #include "cmds.h"
 
-static const char *cmdname = "cat";
+static char *cmdname = "cat";
 #define CAT_VERSION "0.0.1"
 #define CAT_DEFAULT_BUFLEN 1024
 
-static const char *cat_oops = "That option is not yet supported\n";
+static char *cat_oops = "That option is not yet supported\n";
 
 static struct option const long_options[] = {
Index: uspace/app/bdsh/cmds/modules/help/help.c
===================================================================
--- uspace/app/bdsh/cmds/modules/help/help.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/help/help.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -42,5 +42,5 @@
 #include "util.h"
 
-static const char *cmdname = "help";
+static char *cmdname = "help";
 extern const char *progname;
 
Index: uspace/app/bdsh/cmds/modules/kcon/kcon.c
===================================================================
--- uspace/app/bdsh/cmds/modules/kcon/kcon.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/kcon/kcon.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,5 +40,5 @@
 #include "cmds.h"
 
-static const char *cmdname = "kcon";
+static char *cmdname = "kcon";
 
 /* Dispays help for kcon in various levels */
Index: uspace/app/bdsh/cmds/modules/ls/ls.c
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/ls/ls.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -49,5 +49,5 @@
 #include "cmds.h"
 
-static const char *cmdname = "ls";
+static char *cmdname = "ls";
 
 static void ls_scan_dir(const char *d, DIR *dirp)
Index: uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mkdir/mkdir.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/mkdir/mkdir.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -49,5 +49,5 @@
 #define MKDIR_VERSION "0.0.1"
 
-static const char *cmdname = "mkdir";
+static char *cmdname = "mkdir";
 
 static struct option const long_options[] = {
Index: uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mkfile/mkfile.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/mkfile/mkfile.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -51,5 +51,5 @@
 #define BUFFER_SIZE 16384
 
-static const char *cmdname = "mkfile";
+static char *cmdname = "mkfile";
 
 static struct option const long_options[] = {
Index: uspace/app/bdsh/cmds/modules/module_aliases.h
===================================================================
--- uspace/app/bdsh/cmds/modules/module_aliases.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/module_aliases.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -12,5 +12,5 @@
  * the entry point being reached. */
 
-const char *mod_aliases[] = {
+char *mod_aliases[] = {
 	"ren", "mv",
 	"umount", "unmount",
Index: uspace/app/bdsh/cmds/modules/mount/mount.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mount/mount.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/mount/mount.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -58,5 +58,5 @@
 {
 	unsigned int argc;
-	const char *mopts = "";
+	char *mopts = "";
 	int rc;
 
Index: uspace/app/bdsh/cmds/modules/pwd/pwd.c
===================================================================
--- uspace/app/bdsh/cmds/modules/pwd/pwd.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/pwd/pwd.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -39,5 +39,5 @@
 #include "pwd.h"
 
-static const char *cmdname = "pwd";
+static char * cmdname = "pwd";
 
 void help_cmd_pwd(unsigned int level)
Index: uspace/app/bdsh/cmds/modules/rm/rm.c
===================================================================
--- uspace/app/bdsh/cmds/modules/rm/rm.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/rm/rm.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -45,5 +45,5 @@
 #include "cmds.h"
 
-static const char *cmdname = "rm";
+static char *cmdname = "rm";
 #define RM_VERSION "0.0.1"
 
Index: uspace/app/bdsh/cmds/modules/sleep/sleep.c
===================================================================
--- uspace/app/bdsh/cmds/modules/sleep/sleep.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/sleep/sleep.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -38,5 +38,5 @@
 #include "cmds.h"
 
-static const char *cmdname = "sleep";
+static char *cmdname = "sleep";
 
 /* Dispays help for sleep in various levels */
Index: uspace/app/bdsh/cmds/modules/touch/touch.c
===================================================================
--- uspace/app/bdsh/cmds/modules/touch/touch.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/cmds/modules/touch/touch.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -47,5 +47,5 @@
 #include "cmds.h"
 
-static const char *cmdname = "touch";
+static char *cmdname = "touch";
 
 /* Dispays help for touch in various levels */
Index: uspace/app/bdsh/errors.c
===================================================================
--- uspace/app/bdsh/errors.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/errors.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -47,5 +47,5 @@
 /* Look up errno in cl_errors and return the corresponding string.
  * Return NULL if not found */
-static const char *err2str(int err)
+static char *err2str(int err)
 {
 
Index: uspace/app/bdsh/errstr.h
===================================================================
--- uspace/app/bdsh/errstr.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/errstr.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -4,5 +4,5 @@
 /* Simple array to translate error codes to meaningful strings */
 
-static const char *cl_errors[] = {
+static char *cl_errors[] = {
 	"Success",
 	"Failure",
@@ -18,5 +18,5 @@
 };
 
-static const char *err2str(int);
+static char *err2str(int);
 
 #endif
Index: uspace/app/bdsh/exec.c
===================================================================
--- uspace/app/bdsh/exec.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/exec.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -120,5 +120,5 @@
 	free(found);
 
-	tid = task_spawn(tmp, (const char **) argv);
+	tid = task_spawn((const char *)tmp, argv);
 	free(tmp);
 
Index: uspace/app/bdsh/exec.h
===================================================================
--- uspace/app/bdsh/exec.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/exec.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -5,4 +5,3 @@
 
 extern unsigned int try_exec(char *, char **);
-
 #endif
Index: uspace/app/bdsh/scli.h
===================================================================
--- uspace/app/bdsh/scli.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/bdsh/scli.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -6,5 +6,5 @@
 
 typedef struct {
-	const char *name;
+	char *name;
 	char *line;
 	char *cwd;
Index: uspace/app/edit/edit.c
===================================================================
--- uspace/app/edit/edit.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/edit/edit.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -475,7 +475,8 @@
 static void file_save_as(void)
 {
-	const char *old_fname = (doc.file_name != NULL) ? doc.file_name : "";
-	char *fname;
-	
+	char *old_fname, *fname;
+	int rc;
+
+	old_fname = (doc.file_name != NULL) ? doc.file_name : "";
 	fname = filename_prompt("Save As", old_fname);
 	if (fname == NULL) {
@@ -484,5 +485,5 @@
 	}
 
-	int rc = file_save(fname);
+	rc = file_save(fname);
 	if (rc != EOK)
 		return;
@@ -818,13 +819,15 @@
 	spt_t caret_pt;
 	coord_t coord;
+	char *fname;
+	int n;
 
 	tag_get_pt(&pane.caret_pos, &caret_pt);
 	spt_get_coord(&caret_pt, &coord);
 
-	const char *fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>";
+	fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>";
 
 	console_goto(con, 0, scr_rows - 1);
 	console_set_color(con, COLOR_WHITE, COLOR_BLACK, 0);
-	int n = printf(" %d, %d: File '%s'. Ctrl-Q Quit  Ctrl-S Save  "
+	n = printf(" %d, %d: File '%s'. Ctrl-Q Quit  Ctrl-S Save  "
 	    "Ctrl-E Save As", coord.row, coord.column, fname);
 	printf("%*s", scr_columns - 1 - n, "");
Index: uspace/app/getterm/getterm.c
===================================================================
--- uspace/app/getterm/getterm.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/getterm/getterm.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -69,7 +69,7 @@
 }
 
-static task_id_t spawn(const char *fname)
+static task_id_t spawn(char *fname)
 {
-	const char *args[2];
+	char *args[2];
 	
 	args[0] = fname;
Index: uspace/app/getterm/version.c
===================================================================
--- uspace/app/getterm/version.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/getterm/version.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,18 +40,18 @@
 #include "version.h"
 
-static const char *release = STRING(RELEASE);
-static const char *name = STRING(NAME);
-static const char *arch = STRING(UARCH);
+static char *release = STRING(RELEASE);
+static char *name = STRING(NAME);
+static char *arch = STRING(UARCH);
 
 #ifdef REVISION
-	static const char *revision = ", revision " STRING(REVISION);
+	static char *revision = ", revision " STRING(REVISION);
 #else
-	static const char *revision = "";
+	static char *revision = "";
 #endif
 
 #ifdef TIMESTAMP
-	static const char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
+	static char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
 #else
-	static const char *timestamp = "";
+	static char *timestamp = "";
 #endif
 
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/init/init.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -62,5 +62,5 @@
 static bool mount_root(const char *fstype)
 {
-	const char *opts = "";
+	char *opts = "";
 	const char *root_dev = "bd/initrd";
 	
@@ -117,7 +117,7 @@
 }
 
-static void spawn(const char *fname)
-{
-	const char *argv[2];
+static void spawn(char *fname)
+{
+	char *argv[2];
 	struct stat s;
 	
@@ -134,7 +134,7 @@
 }
 
-static void srv_start(const char *fname)
-{
-	const char *argv[2];
+static void srv_start(char *fname)
+{
+	char *argv[2];
 	task_id_t id;
 	task_exit_t texit;
@@ -168,7 +168,7 @@
 }
 
-static void console(const char *dev)
-{
-	const char *argv[3];
+static void console(char *dev)
+{
+	char *argv[3];
 	char hid_in[DEVMAP_NAME_MAXLEN];
 	int rc;
@@ -193,7 +193,7 @@
 }
 
-static void getterm(const char *dev, const char *app)
-{
-	const char *argv[4];
+static void getterm(char *dev, char *app)
+{
+	char *argv[4];
 	char term[DEVMAP_NAME_MAXLEN];
 	int rc;
Index: uspace/app/redir/redir.c
===================================================================
--- uspace/app/redir/redir.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/redir/redir.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -72,5 +72,5 @@
 static task_id_t spawn(int argc, char *argv[])
 {
-	const char **args = (const char **) calloc(argc + 1, sizeof(char *));
+	char **args = (char **) calloc(argc + 1, sizeof(char *));
 	if (!args) {
 		printf("No memory available\n");
Index: uspace/app/tester/console/console1.c
===================================================================
--- uspace/app/tester/console/console1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/console/console1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -36,5 +36,5 @@
 #include "../tester.h"
 
-static const char *color_name[] = {
+const char *color_name[] = {
 	[COLOR_BLACK] = "black",
 	[COLOR_BLUE] = "blue",
@@ -47,5 +47,5 @@
 };
 
-const char *test_console1(void)
+char *test_console1(void)
 {
 	if (!test_quiet) {
Index: uspace/app/tester/fault/fault1.c
===================================================================
--- uspace/app/tester/fault/fault1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/fault/fault1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -30,5 +30,5 @@
 #include "../tester.h"
 
-const char *test_fault1(void)
+char *test_fault1(void)
 {
 	((int *)(0))[1] = 0;
Index: uspace/app/tester/fault/fault2.c
===================================================================
--- uspace/app/tester/fault/fault2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/fault/fault2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -32,5 +32,5 @@
 typedef int __attribute__((may_alias)) aliasing_int;
 
-const char *test_fault2(void)
+char *test_fault2(void)
 {
 	volatile long long var;
Index: uspace/app/tester/fault/fault3.c
===================================================================
--- uspace/app/tester/fault/fault3.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/fault/fault3.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -30,5 +30,5 @@
 #include <stdlib.h>
 
-const char *test_fault3(void)
+char *test_fault3(void)
 {
 	abort();
Index: uspace/app/tester/fault/fault3.def
===================================================================
--- uspace/app/tester/fault/fault3.def	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/fault/fault3.def	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -3,4 +3,4 @@
 	"Abort",
 	&test_fault3,
-	false
+	true
 },
Index: uspace/app/tester/ipc/connect.c
===================================================================
--- uspace/app/tester/ipc/connect.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/ipc/connect.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -39,5 +39,5 @@
 }
 
-const char *test_connect(void)
+char *test_connect(void)
 {
 	TPRINTF("Connecting to %u...", IPC_TEST_SERVICE);
Index: uspace/app/tester/ipc/ping_pong.c
===================================================================
--- uspace/app/tester/ipc/ping_pong.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/ipc/ping_pong.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -38,5 +38,5 @@
 #define COUNT_GRANULARITY  100
 
-const char *test_ping_pong(void)
+char *test_ping_pong(void)
 {
 	TPRINTF("Pinging ns server for %d seconds...", DURATION_SECS);
Index: uspace/app/tester/ipc/register.c
===================================================================
--- uspace/app/tester/ipc/register.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/ipc/register.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -74,5 +74,5 @@
 }
 
-const char *test_register(void)
+char *test_register(void)
 {
 	async_set_client_connection(client_connection);
Index: uspace/app/tester/loop/loop1.c
===================================================================
--- uspace/app/tester/loop/loop1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/loop/loop1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -31,5 +31,5 @@
 #include "../tester.h"
 
-const char *test_loop1(void)
+char *test_loop1(void)
 {
 	TPRINTF("Looping...");
Index: uspace/app/tester/mm/malloc1.c
===================================================================
--- uspace/app/tester/mm/malloc1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/mm/malloc1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -73,5 +73,5 @@
 
 typedef struct {
-	const char *name;
+	char *name;
 	sp_term_cond_s cond;
 	sp_action_prob_s prob;
@@ -90,5 +90,5 @@
 
 typedef struct {
-	const char *name;
+	char *name;
 	ph_alloc_size_s alloc;
 	subphase_s *subphases;
@@ -628,5 +628,5 @@
 }
 
-const char *test_malloc1(void)
+char *test_malloc1(void)
 {
 	init_mem();
Index: uspace/app/tester/print/print1.c
===================================================================
--- uspace/app/tester/print/print1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/print/print1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -31,5 +31,5 @@
 #include "../tester.h"
 
-const char *test_print1(void)
+char *test_print1(void)
 {
 	TPRINTF("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n");
Index: uspace/app/tester/print/print2.c
===================================================================
--- uspace/app/tester/print/print2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/print/print2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -31,5 +31,5 @@
 #include "../tester.h"
 
-const char *test_print2(void)
+char *test_print2(void)
 {
 	TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n");
Index: uspace/app/tester/print/print3.c
===================================================================
--- uspace/app/tester/print/print3.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/print/print3.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -34,5 +34,5 @@
 #define BUFFER_SIZE  32
 
-const char *test_print3(void)
+char *test_print3(void)
 {
 	char buffer[BUFFER_SIZE];
Index: uspace/app/tester/print/print4.c
===================================================================
--- uspace/app/tester/print/print4.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/print/print4.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -31,5 +31,5 @@
 #include "../tester.h"
 
-const char *test_print4(void)
+char *test_print4(void)
 {
 	TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n");
Index: uspace/app/tester/stdio/stdio1.c
===================================================================
--- uspace/app/tester/stdio/stdio1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/stdio/stdio1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -36,8 +36,8 @@
 static char buf[BUF_SIZE + 1];
 
-const char *test_stdio1(void)
+char *test_stdio1(void)
 {
 	FILE *file;
-	const char *file_name = "/readme";
+	char *file_name = "/readme";
 	
 	TPRINTF("Open file \"%s\"...", file_name);
Index: uspace/app/tester/stdio/stdio2.c
===================================================================
--- uspace/app/tester/stdio/stdio2.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/stdio/stdio2.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -32,8 +32,8 @@
 #include "../tester.h"
 
-const char *test_stdio2(void)
+char *test_stdio2(void)
 {
 	FILE *file;
-	const char *file_name = "/test";
+	char *file_name = "/test";
 	
 	TPRINTF("Open file \"%s\" for writing...", file_name);
Index: uspace/app/tester/tester.c
===================================================================
--- uspace/app/tester/tester.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/tester.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -69,5 +69,5 @@
 {
 	/* Execute the test */
-	const char *ret = test->entry();
+	char *ret = test->entry();
 	
 	if (ret == NULL) {
Index: uspace/app/tester/tester.h
===================================================================
--- uspace/app/tester/tester.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/tester.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,30 +54,30 @@
 	}
 
-typedef const char *(*test_entry_t)(void);
+typedef char *(*test_entry_t)(void);
 
 typedef struct {
-	const char *name;
-	const char *desc;
+	char *name;
+	char *desc;
 	test_entry_t entry;
 	bool safe;
 } test_t;
 
-extern const char *test_thread1(void);
-extern const char *test_print1(void);
-extern const char *test_print2(void);
-extern const char *test_print3(void);
-extern const char *test_print4(void);
-extern const char *test_console1(void);
-extern const char *test_stdio1(void);
-extern const char *test_stdio2(void);
-extern const char *test_fault1(void);
-extern const char *test_fault2(void);
-extern const char *test_fault3(void);
-extern const char *test_vfs1(void);
-extern const char *test_ping_pong(void);
-extern const char *test_register(void);
-extern const char *test_connect(void);
-extern const char *test_loop1(void);
-extern const char *test_malloc1(void);
+extern char *test_thread1(void);
+extern char *test_print1(void);
+extern char *test_print2(void);
+extern char *test_print3(void);
+extern char *test_print4(void);
+extern char *test_console1(void);
+extern char *test_stdio1(void);
+extern char *test_stdio2(void);
+extern char *test_fault1(void);
+extern char *test_fault2(void);
+extern char *test_fault3(void);
+extern char *test_vfs1(void);
+extern char *test_ping_pong(void);
+extern char *test_register(void);
+extern char *test_connect(void);
+extern char *test_loop1(void);
+extern char *test_malloc1(void);
 
 extern test_t tests[];
Index: uspace/app/tester/thread/thread1.c
===================================================================
--- uspace/app/tester/thread/thread1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/thread/thread1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -50,8 +50,8 @@
 }
 
-const char *test_thread1(void)
+char *test_thread1(void)
 {
 	unsigned int i;
-	atomic_count_t total = 0;
+	int total = 0;
 	
 	atomic_set(&finish, 1);
Index: uspace/app/tester/vfs/vfs1.c
===================================================================
--- uspace/app/tester/vfs/vfs1.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tester/vfs/vfs1.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,5 +54,5 @@
 static char text[] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit";
 
-static const char *read_root(void)
+static char *read_root(void)
 {
 	TPRINTF("Opening the root directory...");
@@ -73,5 +73,5 @@
 }
 
-const char *test_vfs1(void)
+char *test_vfs1(void)
 {
 	if (mkdir(MOUNT_POINT, 0) != 0)
@@ -121,5 +121,5 @@
 	close(fd0);
 	
-	const char *rv = read_root();
+	char *rv = read_root();
 	if (rv != NULL)
 		return rv;
Index: uspace/app/tetris/screen.c
===================================================================
--- uspace/app/tetris/screen.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tetris/screen.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -72,5 +72,5 @@
  * simply literal strings);
  */
-static inline void putstr(const char *s)
+static inline void putstr(char *s)
 {
 	while (*s)
@@ -181,5 +181,5 @@
 }
 
-void stop(const char *why)
+void stop(char *why)
 {
 	if (isset)
Index: uspace/app/tetris/tetris.h
===================================================================
--- uspace/app/tetris/tetris.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/tetris/tetris.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -186,5 +186,5 @@
 extern int fits_in(const struct shape *, int);
 extern void place(const struct shape *, int, int);
-extern void stop(const char *);
+extern void stop(char *);
 
 /** @}
Index: uspace/app/trace/errors.h
===================================================================
--- uspace/app/trace/errors.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/trace/errors.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -37,6 +37,6 @@
 
 typedef struct {
-	const char *name;  /**< Error value name (Exx) */
-	const char *desc;  /**< Error description */
+	char *name;	/**< Error value name (Exx) */
+	char *desc;	/**< Error description */
 } err_desc_t;
 
Index: uspace/app/trace/ipc_desc.h
===================================================================
--- uspace/app/trace/ipc_desc.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/trace/ipc_desc.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -38,5 +38,5 @@
 typedef struct {
 	int number;
-	const char *name;
+	char *name;
 } ipc_m_desc_t;
 
Index: uspace/app/trace/proto.c
===================================================================
--- uspace/app/trace/proto.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/trace/proto.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -157,5 +157,5 @@
 }
 
-static void proto_struct_init(proto_t *proto, const char *name)
+static void proto_struct_init(proto_t *proto, char *name)
 {
 	proto->name = name;
@@ -164,5 +164,5 @@
 }
 
-proto_t *proto_new(const char *name)
+proto_t *proto_new(char *name)
 {
 	proto_t *p;
@@ -206,10 +206,10 @@
 }
 
-static void oper_struct_init(oper_t *oper, const char *name)
+static void oper_struct_init(oper_t *oper, char *name)
 {
 	oper->name = name;
 }
 
-oper_t *oper_new(const char *name, int argc, val_type_t *arg_types,
+oper_t *oper_new(char *name, int argc, val_type_t *arg_types,
     val_type_t rv_type, int respc, val_type_t *resp_types)
 {
Index: uspace/app/trace/proto.h
===================================================================
--- uspace/app/trace/proto.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/trace/proto.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -43,5 +43,5 @@
 
 typedef struct {
-	const char *name;
+	char *name;
 
 	int argc;
@@ -56,5 +56,5 @@
 typedef struct {
 	/** Protocol name */
-	const char *name;
+	char *name;
 
 	/** Maps method number to operation */
@@ -70,10 +70,10 @@
 void proto_register(int srv, proto_t *proto);
 proto_t *proto_get_by_srv(int srv);
-proto_t *proto_new(const char *name);
+proto_t *proto_new(char *name);
 void proto_delete(proto_t *proto);
 void proto_add_oper(proto_t *proto, int method, oper_t *oper);
 oper_t *proto_get_oper(proto_t *proto, int method);
 
-oper_t *oper_new(const char *name, int argc, val_type_t *arg_types,
+oper_t *oper_new(char *name, int argc, val_type_t *arg_types,
     val_type_t rv_type, int respc, val_type_t *resp_types);
 
Index: uspace/app/trace/syscalls.h
===================================================================
--- uspace/app/trace/syscalls.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/trace/syscalls.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -39,5 +39,5 @@
 
 typedef struct {
-	const char *name;
+	char *name;
 	int n_args;
 	val_type_t rv_type;
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/app/trace/trace.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -585,5 +585,5 @@
 }
 
-static loader_t *preload_task(const char *path, char **argv,
+static loader_t *preload_task(const char *path, char *const argv[],
     task_id_t *task_id)
 {
@@ -591,5 +591,5 @@
 	int rc;
 
-	/* Spawn a program loader */
+	/* Spawn a program loader */	
 	ldr = loader_connect();
 	if (ldr == NULL)
@@ -607,5 +607,5 @@
 
 	/* Send arguments */
-	rc = loader_set_args(ldr, (const char **) argv);
+	rc = loader_set_args(ldr, argv);
 	if (rc != EOK)
 		goto error;
@@ -870,31 +870,25 @@
 }
 
-static display_mask_t parse_display_mask(const char *text)
+static display_mask_t parse_display_mask(char *text)
 {
 	display_mask_t dm;
-	const char *c = text;
-	
+	char *c;
+
+	c = text;
+
 	while (*c) {
 		switch (*c) {
-		case 't':
-			dm = dm | DM_THREAD;
-			break;
-		case 's':
-			dm = dm | DM_SYSCALL;
-			break;
-		case 'i':
-			dm = dm | DM_IPC;
-			break;
-		case 'p':
-			dm = dm | DM_SYSTEM | DM_USER;
-			break;
+		case 't': dm = dm | DM_THREAD; break;
+		case 's': dm = dm | DM_SYSCALL; break;
+		case 'i': dm = dm | DM_IPC; break;
+		case 'p': dm = dm | DM_SYSTEM | DM_USER; break;
 		default:
 			printf("Unexpected event type '%c'.\n", *c);
 			exit(1);
 		}
-		
+
 		++c;
 	}
-	
+
 	return dm;
 }
@@ -902,13 +896,13 @@
 static int parse_args(int argc, char *argv[])
 {
+	char *arg;
 	char *err_p;
 
 	task_id = 0;
 
-	--argc;
-	++argv;
+	--argc; ++argv;
 
 	while (argc > 0) {
-		char *arg = *argv;
+		arg = *argv;
 		if (arg[0] == '+') {
 			display_mask = parse_display_mask(&arg[1]);
@@ -916,6 +910,5 @@
 			if (arg[1] == 't') {
 				/* Trace an already running task */
-				--argc;
-				++argv;
+				--argc; ++argv;
 				task_id = strtol(*argv, &err_p, 10);
 				task_ldr = NULL;
@@ -934,12 +927,10 @@
 			break;
 		}
-		
-		--argc;
-		++argv;
+
+		--argc; ++argv;
 	}
 
 	if (task_id != 0) {
-		if (argc == 0)
-			return 0;
+		if (argc == 0) return 0;
 		printf("Extra arguments\n");
 		print_syntax();
@@ -955,9 +946,8 @@
 	/* Preload the specified program file. */
 	printf("Spawning '%s' with arguments:\n", *argv);
-	
-	char **cp = argv;
-	while (*cp)
-		printf("'%s'\n", *cp++);
-	
+	{
+		char **cp = argv;
+		while (*cp) printf("'%s'\n", *cp++);
+	}
 	task_ldr = preload_task(*argv, argv, &task_id);
 	task_wait_for = true;
Index: uspace/lib/libc/Makefile.toolchain
===================================================================
--- uspace/lib/libc/Makefile.toolchain	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/Makefile.toolchain	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,26 +27,22 @@
 #
 
-OPTIMIZATION = 3
-
-GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(LIBC_PREFIX)/../../../config.h \
+GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
 	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
 	-Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-Werror -pipe -g -D__$(ENDIANESS)__
+	-Werror-implicit-function-declaration -Werror -pipe -g -D__$(ENDIANESS)__
 
-ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(LIBC_PREFIX)/../../../config.h \
-	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
-	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
-	-Wall -Wextra -Wno-clobbered -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-Werror -pipe -g -D__$(ENDIANESS)__
-
-CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O$(OPTIMIZATION) -imacros $(LIBC_PREFIX)/../../../config.h \
+ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
 	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
 	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-pipe -g -arch $(CLANG_ARCH) -D__$(ENDIANESS)__
+	-Werror-implicit-function-declaration -Werror -pipe -g -D__$(ENDIANESS)__
+
+CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
+	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
+	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
+	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
+	-Werror-implicit-function-declaration -pipe -g -arch $(CLANG_ARCH) \
+	-D__$(ENDIANESS)__
 
 LFLAGS = -M -N $(SOFTINT_PREFIX)/libsoftint.a
Index: uspace/lib/libc/arch/abs32le/Makefile.inc
===================================================================
--- uspace/lib/libc/arch/abs32le/Makefile.inc	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/abs32le/Makefile.inc	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -46,8 +46,4 @@
 endif
 
-ifeq ($(COMPILER),clang)
-	CLANG_ARCH = i386
-endif
-
 ARCH_SOURCES = \
 	arch/$(UARCH)/src/entry.c \
Index: uspace/lib/libc/arch/abs32le/include/atomic.h
===================================================================
--- uspace/lib/libc/arch/abs32le/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/abs32le/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -43,5 +43,5 @@
 #include <atomicdflt.h>
 
-static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv)
+static inline bool cas(atomic_t *val, long ov, long nv)
 {
 	if (val->count == ov) {
@@ -67,5 +67,5 @@
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
 	/* On real hardware both the storing of the previous
@@ -73,5 +73,5 @@
 	   atomic action. */
 	
-	atomic_count_t prev = val->count;
+	long prev = val->count;
 	
 	val->count++;
@@ -79,5 +79,5 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
 	/* On real hardware both the storing of the previous
@@ -85,5 +85,5 @@
 	   atomic action. */
 	
-	atomic_count_t prev = val->count;
+	long prev = val->count;
 	
 	val->count--;
Index: uspace/lib/libc/arch/abs32le/include/types.h
===================================================================
--- uspace/lib/libc/arch/abs32le/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/abs32le/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,6 +54,4 @@
 
 typedef uint32_t uintptr_t;
-typedef uint32_t atomic_count_t;
-typedef int32_t atomic_signed_t;
 
 #endif
Index: uspace/lib/libc/arch/amd64/include/atomic.h
===================================================================
--- uspace/lib/libc/arch/amd64/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/amd64/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -42,28 +42,33 @@
 #include <atomicdflt.h>
 
-static inline void atomic_inc(atomic_t *val)
-{
-	asm volatile (
-		"lock incq %[count]\n"
-		: [count] "+m" (val->count)
-	);
+static inline void atomic_inc(atomic_t *val) {
+	asm volatile ("lock incq %0\n" : "+m" (val->count));
 }
 
-static inline void atomic_dec(atomic_t *val)
-{
-	asm volatile (
-		"lock decq %[count]\n"
-		: [count] "+m" (val->count)
-	);
+static inline void atomic_dec(atomic_t *val) {
+	asm volatile ("lock decq %0\n" : "+m" (val->count));
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val) 
 {
-	atomic_count_t r = 1;
+	long r;
+
+	asm volatile (
+		"movq $1, %0\n"
+		"lock xaddq %0, %1\n"
+		: "=r" (r), "+m" (val->count)
+	);
+
+	return r;
+}
+
+static inline long atomic_postdec(atomic_t *val) 
+{
+	long r;
 	
 	asm volatile (
-		"lock xaddq %[r], %[count]\n"
-		: [count] "+m" (val->count),
-		  [r] "+r" (r)
+		"movq $-1, %0\n"
+		"lock xaddq %0, %1\n"
+		: "=r" (r), "+m" (val->count)
 	);
 	
@@ -71,19 +76,6 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
-{
-	atomic_count_t r = -1;
-	
-	asm volatile (
-		"lock xaddq %[r], %[count]\n"
-		: [count] "+m" (val->count),
-		  [r] "+r" (r)
-	);
-	
-	return r;
-}
-
-#define atomic_preinc(val)  (atomic_postinc(val) + 1)
-#define atomic_predec(val)  (atomic_postdec(val) - 1)
+#define atomic_preinc(val) (atomic_postinc(val) + 1)
+#define atomic_predec(val) (atomic_postdec(val) - 1)
 
 #endif
Index: uspace/lib/libc/arch/amd64/include/types.h
===================================================================
--- uspace/lib/libc/arch/amd64/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/amd64/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,6 +54,4 @@
 
 typedef uint64_t uintptr_t;
-typedef uint64_t atomic_count_t;
-typedef int64_t atomic_signed_t;
 
 #endif
Index: uspace/lib/libc/arch/arm32/include/atomic.h
===================================================================
--- uspace/lib/libc/arch/arm32/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/arm32/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libcarm32
+/** @addtogroup libcarm32	
  * @{
  */
@@ -38,5 +38,5 @@
 
 #define LIBC_ARCH_ATOMIC_H_
-#define CAS
+#define CAS 
 
 #include <atomicdflt.h>
@@ -46,8 +46,8 @@
 extern uintptr_t *ras_page;
 
-static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv)
+static inline bool cas(atomic_t *val, long ov, long nv)
 {
-	atomic_count_t ret = 0;
-	
+	long ret = 0;
+
 	/*
 	 * The following instructions between labels 1 and 2 constitute a
@@ -75,11 +75,9 @@
 		: "memory"
 	);
-	
+
 	ras_page[0] = 0;
-	asm volatile (
-		"" ::: "memory"
-	);
+	asm volatile ("" ::: "memory");	
 	ras_page[1] = 0xffffffff;
-	
+
 	return (bool) ret;
 }
@@ -91,10 +89,9 @@
  *
  * @return Value after addition.
- *
  */
-static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
+static inline long atomic_add(atomic_t *val, int i)
 {
-	atomic_count_t ret = 0;
-	
+	long ret = 0;
+
 	/*
 	 * The following instructions between labels 1 and 2 constitute a
@@ -118,11 +115,9 @@
 		: [imm] "r" (i)
 	);
-	
+
 	ras_page[0] = 0;
-	asm volatile (
-		"" ::: "memory"
-	);
+	asm volatile ("" ::: "memory");	
 	ras_page[1] = 0xffffffff;
-	
+
 	return ret;
 }
@@ -132,5 +127,4 @@
  *
  * @param val Variable to be incremented.
- *
  */
 static inline void atomic_inc(atomic_t *val)
@@ -143,5 +137,4 @@
  *
  * @param val Variable to be decremented.
- *
  */
 static inline void atomic_dec(atomic_t *val)
@@ -155,7 +148,6 @@
  * @param val Variable to be incremented.
  * @return    Value after incrementation.
- *
  */
-static inline atomic_count_t atomic_preinc(atomic_t *val)
+static inline long atomic_preinc(atomic_t *val)
 {
 	return atomic_add(val, 1);
@@ -167,7 +159,6 @@
  * @param val Variable to be decremented.
  * @return    Value after decrementation.
- *
  */
-static inline atomic_count_t atomic_predec(atomic_t *val)
+static inline long atomic_predec(atomic_t *val)
 {
 	return atomic_add(val, -1);
@@ -179,7 +170,6 @@
  * @param val Variable to be incremented.
  * @return    Value before incrementation.
- *
  */
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
 	return atomic_add(val, 1) - 1;
@@ -191,7 +181,6 @@
  * @param val Variable to be decremented.
  * @return    Value before decrementation.
- *
  */
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
 	return atomic_add(val, -1) + 1;
Index: uspace/lib/libc/arch/arm32/include/types.h
===================================================================
--- uspace/lib/libc/arch/arm32/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/arm32/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -55,6 +55,4 @@
 
 typedef uint32_t uintptr_t;
-typedef uint32_t atomic_count_t;
-typedef int32_t atomic_signed_t;
 
 #endif
Index: uspace/lib/libc/arch/ia32/include/atomic.h
===================================================================
--- uspace/lib/libc/arch/ia32/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/ia32/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,28 +40,33 @@
 #include <atomicdflt.h>
 
-static inline void atomic_inc(atomic_t *val)
-{
-	asm volatile (
-		"lock incl %[count]\n"
-		: [count] "+m" (val->count)
-	);
+static inline void atomic_inc(atomic_t *val) {
+	asm volatile ("lock incl %0\n" : "+m" (val->count));
 }
 
-static inline void atomic_dec(atomic_t *val)
-{
-	asm volatile (
-		"lock decl %[count]\n"
-		: [count] "+m" (val->count)
-	);
+static inline void atomic_dec(atomic_t *val) {
+	asm volatile ("lock decl %0\n" : "+m" (val->count));
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val) 
 {
-	atomic_count_t r = 1;
+	long r;
+
+	asm volatile (
+		"movl $1, %0\n"
+		"lock xaddl %0, %1\n"
+		: "=r" (r), "+m" (val->count)
+	);
+
+	return r;
+}
+
+static inline long atomic_postdec(atomic_t *val) 
+{
+	long r;
 	
 	asm volatile (
-		"lock xaddl %[r], %[count]\n"
-		: [count] "+m" (val->count),
-		  [r] "+r" (r)
+		"movl $-1, %0\n"
+		"lock xaddl %0, %1\n"
+		: "=r" (r), "+m" (val->count)
 	);
 	
@@ -69,19 +74,6 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
-{
-	atomic_count_t r = -1;
-	
-	asm volatile (
-		"lock xaddl %[r], %[count]\n"
-		: [count] "+m" (val->count),
-		  [r] "+r" (r)
-	);
-	
-	return r;
-}
-
-#define atomic_preinc(val)  (atomic_postinc(val) + 1)
-#define atomic_predec(val)  (atomic_postdec(val) - 1)
+#define atomic_preinc(val) (atomic_postinc(val) + 1)
+#define atomic_predec(val) (atomic_postdec(val) - 1)
 
 #endif
Index: uspace/lib/libc/arch/ia32/include/types.h
===================================================================
--- uspace/lib/libc/arch/ia32/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/ia32/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,6 +54,4 @@
 
 typedef uint32_t uintptr_t;
-typedef uint32_t atomic_count_t;
-typedef int32_t atomic_signed_t;
 
 #endif
Index: uspace/lib/libc/arch/ia64/include/atomic.h
===================================================================
--- uspace/lib/libc/arch/ia64/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/ia64/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -42,5 +42,5 @@
 static inline void atomic_inc(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -53,5 +53,5 @@
 static inline void atomic_dec(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -62,7 +62,7 @@
 }
 
-static inline atomic_count_t atomic_preinc(atomic_t *val)
+static inline long atomic_preinc(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -75,7 +75,7 @@
 }
 
-static inline atomic_count_t atomic_predec(atomic_t *val)
+static inline long atomic_predec(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -88,7 +88,7 @@
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
@@ -101,7 +101,7 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
-	atomic_count_t v;
+	long v;
 	
 	asm volatile (
Index: uspace/lib/libc/arch/ia64/include/types.h
===================================================================
--- uspace/lib/libc/arch/ia64/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/ia64/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -59,6 +59,4 @@
 
 typedef uint64_t uintptr_t;
-typedef uint64_t atomic_count_t;
-typedef int64_t atomic_signed_t;
 
 typedef struct {
Index: uspace/lib/libc/arch/mips32/include/atomic.h
===================================================================
--- uspace/lib/libc/arch/mips32/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/mips32/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,9 +27,9 @@
  */
 
-/** @addtogroup libcmips32
+/** @addtogroup libcmips32	
  * @{
  */
 /** @file
- * @ingroup libcmips32eb
+ * @ingroup libcmips32eb	
  */
 
@@ -41,26 +41,24 @@
 #include <atomicdflt.h>
 
-#define atomic_inc(x)  ((void) atomic_add(x, 1))
-#define atomic_dec(x)  ((void) atomic_add(x, -1))
+#define atomic_inc(x)	((void) atomic_add(x, 1))
+#define atomic_dec(x)	((void) atomic_add(x, -1))
 
-#define atomic_postinc(x)  (atomic_add(x, 1) - 1)
-#define atomic_postdec(x)  (atomic_add(x, -1) + 1)
+#define atomic_postinc(x) (atomic_add(x, 1) - 1)
+#define atomic_postdec(x) (atomic_add(x, -1) + 1)
 
-#define atomic_preinc(x)  atomic_add(x, 1)
-#define atomic_predec(x)  atomic_add(x, -1)
+#define atomic_preinc(x) atomic_add(x, 1)
+#define atomic_predec(x) atomic_add(x, -1)
 
 /* Atomic addition of immediate value.
  *
  * @param val Memory location to which will be the immediate value added.
- * @param i   Signed immediate that will be added to *val.
+ * @param i Signed immediate that will be added to *val.
  *
  * @return Value after addition.
- *
  */
-static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
+static inline long atomic_add(atomic_t *val, int i)
 {
-	atomic_count_t tmp;
-	atomic_count_t v;
-	
+	long tmp, v;
+
 	asm volatile (
 		"1:\n"
@@ -72,11 +70,8 @@
 		/*	nop	*/		/* nop is inserted automatically by compiler */
 		"	nop\n"
-		: "=&r" (tmp),
-		  "+m" (val->count),
-		  "=&r" (v)
-		: "r" (i),
-		  "i" (0)
-	);
-	
+		: "=&r" (tmp), "+m" (val->count), "=&r" (v)
+		: "r" (i), "i" (0)
+		);
+
 	return v;
 }
Index: uspace/lib/libc/arch/mips32/include/types.h
===================================================================
--- uspace/lib/libc/arch/mips32/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/mips32/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libcmips32
+/** @addtogroup libcmips32	
  * @{
  */
@@ -55,6 +55,4 @@
 
 typedef uint32_t uintptr_t;
-typedef uint32_t atomic_count_t;
-typedef int32_t atomic_signed_t;
 
 #endif
Index: uspace/lib/libc/arch/ppc32/include/atomic.h
===================================================================
--- uspace/lib/libc/arch/ppc32/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/ppc32/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libcppc32
+/** @addtogroup libcppc32	
  * @{
  */
@@ -42,6 +42,6 @@
 static inline void atomic_inc(atomic_t *val)
 {
-	atomic_count_t tmp;
-	
+	long tmp;
+
 	asm volatile (
 		"1:\n"
@@ -50,31 +50,25 @@
 		"stwcx. %0, 0, %2\n"
 		"bne- 1b"
-		: "=&r" (tmp),
-		  "=m" (val->count)
-		: "r" (&val->count),
-		  "m" (val->count)
-		: "cc"
-	);
+		: "=&r" (tmp), "=m" (val->count)
+		: "r" (&val->count), "m" (val->count)
+		: "cc");
 }
 
 static inline void atomic_dec(atomic_t *val)
 {
-	atomic_count_t tmp;
-	
+	long tmp;
+
 	asm volatile (
 		"1:\n"
 		"lwarx %0, 0, %2\n"
 		"addic %0, %0, -1\n"
-		"stwcx. %0, 0, %2\n"
+		"stwcx.	%0, 0, %2\n"
 		"bne- 1b"
-		: "=&r" (tmp),
-		  "=m" (val->count)
-		: "r" (&val->count),
-		  "m" (val->count)
-		: "cc"
-	);
+		: "=&r" (tmp), "=m" (val->count)
+		: "r" (&val->count), "m" (val->count)
+		: "cc");
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
 	atomic_inc(val);
@@ -82,5 +76,5 @@
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
 	atomic_dec(val);
@@ -88,5 +82,5 @@
 }
 
-static inline atomic_count_t atomic_preinc(atomic_t *val)
+static inline long atomic_preinc(atomic_t *val)
 {
 	atomic_inc(val);
@@ -94,5 +88,5 @@
 }
 
-static inline atomic_count_t atomic_predec(atomic_t *val)
+static inline long atomic_predec(atomic_t *val)
 {
 	atomic_dec(val);
Index: uspace/lib/libc/arch/ppc32/include/types.h
===================================================================
--- uspace/lib/libc/arch/ppc32/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/ppc32/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libcppc32
+/** @addtogroup libcppc32	
  * @{
  */
@@ -54,6 +54,4 @@
 
 typedef uint32_t uintptr_t;
-typedef uint32_t atomic_count_t;
-typedef int32_t atomic_signed_t;
 
 #endif
Index: uspace/lib/libc/arch/sparc64/include/atomic.h
===================================================================
--- uspace/lib/libc/arch/sparc64/include/atomic.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/sparc64/include/atomic.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -46,47 +46,39 @@
  *
  * @param val Atomic variable.
- * @param i   Signed value to be added.
+ * @param i Signed value to be added.
  *
  * @return Value of the atomic variable as it existed before addition.
- *
  */
-static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
+static inline long atomic_add(atomic_t *val, int i)
 {
-	atomic_count_t a;
-	atomic_count_t b;
-	
+	uint64_t a, b;
+
 	do {
-		volatile uintptr_t ptr = (uintptr_t) &val->count;
-		
-		a = *((atomic_count_t *) ptr);
+		volatile uintptr_t x = (uint64_t) &val->count;
+
+		a = *((uint64_t *) x);
 		b = a + i;
-		
-		asm volatile (
-			"casx %0, %2, %1\n"
-			: "+m" (*((atomic_count_t *) ptr)),
-			  "+r" (b)
-			: "r" (a)
-		);
+		asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)), "+r" (b) : "r" (a));
 	} while (a != b);
-	
+
 	return a;
 }
 
-static inline atomic_count_t atomic_preinc(atomic_t *val)
+static inline long atomic_preinc(atomic_t *val)
 {
 	return atomic_add(val, 1) + 1;
 }
 
-static inline atomic_count_t atomic_postinc(atomic_t *val)
+static inline long atomic_postinc(atomic_t *val)
 {
 	return atomic_add(val, 1);
 }
 
-static inline atomic_count_t atomic_predec(atomic_t *val)
+static inline long atomic_predec(atomic_t *val)
 {
 	return atomic_add(val, -1) - 1;
 }
 
-static inline atomic_count_t atomic_postdec(atomic_t *val)
+static inline long atomic_postdec(atomic_t *val)
 {
 	return atomic_add(val, -1);
Index: uspace/lib/libc/arch/sparc64/include/types.h
===================================================================
--- uspace/lib/libc/arch/sparc64/include/types.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/arch/sparc64/include/types.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -54,6 +54,4 @@
 
 typedef uint64_t uintptr_t;
-typedef uint64_t atomic_count_t;
-typedef int64_t atomic_signed_t;
 
 #endif
Index: uspace/lib/libc/generic/async.c
===================================================================
--- uspace/lib/libc/generic/async.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/generic/async.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -1101,58 +1101,4 @@
 }
 
-/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
- * 
- * Ask through phone for a new connection to some service.
- *
- * @param phoneid	Phone handle used for contacting the other side.
- * @param arg1		User defined argument.
- * @param arg2		User defined argument.
- * @param arg3		User defined argument.
- *
- * @return		New phone handle on success or a negative error code.
- */
-int
-async_connect_me_to(int phoneid, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3)
-{
-	int rc;
-	ipcarg_t newphid;
-
-	rc = async_req_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, NULL,
-	    NULL, NULL, NULL, &newphid);
-	
-	if (rc != EOK)	
-		return rc;
-
-	return newphid;
-}
-
-/** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework.
- * 
- * Ask through phone for a new connection to some service and block until
- * success.
- *
- * @param phoneid	Phone handle used for contacting the other side.
- * @param arg1		User defined argument.
- * @param arg2		User defined argument.
- * @param arg3		User defined argument.
- *
- * @return		New phone handle on success or a negative error code.
- */
-int
-async_connect_me_to_blocking(int phoneid, ipcarg_t arg1, ipcarg_t arg2,
-    ipcarg_t arg3)
-{
-	int rc;
-	ipcarg_t newphid;
-
-	rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3,
-	    IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid);
-	
-	if (rc != EOK)	
-		return rc;
-
-	return newphid;
-}
-
 /** Wrapper for making IPC_M_SHARE_IN calls using the async framework.
  *
Index: uspace/lib/libc/generic/futex.c
===================================================================
--- uspace/lib/libc/generic/futex.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/generic/futex.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -68,5 +68,5 @@
 int futex_down(futex_t *futex)
 {
-	if ((atomic_signed_t) atomic_predec(futex) < 0)
+	if (atomic_predec(futex) < 0)
 		return __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &futex->count);
 
@@ -82,5 +82,5 @@
 int futex_up(futex_t *futex)
 {
-	if ((atomic_signed_t) atomic_postinc(futex) < 0)
+	if (atomic_postinc(futex) < 0)
 		return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &futex->count);
 		
Index: uspace/lib/libc/generic/io/io.c
===================================================================
--- uspace/lib/libc/generic/io/io.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/generic/io/io.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -536,31 +536,4 @@
 }
 
-char *fgets(char *str, int size, FILE *stream)
-{
-	int c;
-	int idx;
-
-	idx = 0;
-	while (idx < size - 1) {
-		c = fgetc(stream);
-		if (c == EOF)
-			break;
-
-		str[idx++] = c;
-
-		if (c == '\n')
-			break;
-	}
-
-	if (ferror(stream))
-		return NULL;
-
-	if (idx == 0)
-		return NULL;
-
-	str[idx] = '\0';
-	return str;
-}
-
 int getchar(void)
 {
Index: uspace/lib/libc/generic/loader.c
===================================================================
--- uspace/lib/libc/generic/loader.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/generic/loader.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -183,5 +183,5 @@
  *
  */
-int loader_set_args(loader_t *ldr, const char *const argv[])
+int loader_set_args(loader_t *ldr, char *const argv[])
 {
 	/*
@@ -189,5 +189,5 @@
 	 * compute size of the buffer needed.
 	 */
-	const char *const *ap = argv;
+	char *const *ap = argv;
 	size_t buffer_size = 0;
 	while (*ap != NULL) {
Index: uspace/lib/libc/generic/sysinfo.c
===================================================================
--- uspace/lib/libc/generic/sysinfo.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/generic/sysinfo.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -37,7 +37,7 @@
 #include <string.h>
 
-sysarg_t sysinfo_value(const char *name)
+sysarg_t sysinfo_value(char *name)
 {
-	return __SYSCALL2(SYS_SYSINFO_VALUE, (sysarg_t) name,
+	return __SYSCALL2(SYS_SYSINFO_VALUE, (sysarg_t ) name,
 	    (sysarg_t) str_size(name));
 }
Index: uspace/lib/libc/generic/task.c
===================================================================
--- uspace/lib/libc/generic/task.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/generic/task.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -76,5 +76,5 @@
  *
  */
-task_id_t task_spawn(const char *path, const char *const args[])
+task_id_t task_spawn(const char *path, char *const args[])
 {
 	/* Connect to a program loader. */
Index: uspace/lib/libc/generic/thread.c
===================================================================
--- uspace/lib/libc/generic/thread.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/generic/thread.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -86,5 +86,5 @@
  * @return Zero on success or a code from @ref errno.h on failure.
  */
-int thread_create(void (* function)(void *), void *arg, const char *name,
+int thread_create(void (* function)(void *), void *arg, char *name,
     thread_id_t *tid)
 {
Index: uspace/lib/libc/include/async.h
===================================================================
--- uspace/lib/libc/include/async.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/include/async.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -259,7 +259,4 @@
 }
 
-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);
-
 /*
  * User-friendly wrappers for async_share_in_start().
Index: uspace/lib/libc/include/atomicdflt.h
===================================================================
--- uspace/lib/libc/include/atomicdflt.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/include/atomicdflt.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -37,26 +37,25 @@
 
 #ifndef LIBC_ARCH_ATOMIC_H_
-	#error This file cannot be included directly, include atomic.h instead.
+#error This file cannot be included directly, include atomic.h instead.
 #endif
 
-#include <stdint.h>
 #include <bool.h>
 
 typedef struct atomic {
-	volatile atomic_count_t count;
+	volatile long count;
 } atomic_t;
 
-static inline void atomic_set(atomic_t *val, atomic_count_t i)
+static inline void atomic_set(atomic_t *val, long i)
 {
-	val->count = i;
+        val->count = i;
 }
 
-static inline atomic_count_t atomic_get(atomic_t *val)
+static inline long atomic_get(atomic_t *val)
 {
-	return val->count;
+        return val->count;
 }
 
 #ifndef CAS
-static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv)
+static inline bool cas(atomic_t *val, long ov, long nv)
 {
 	return __sync_bool_compare_and_swap(&val->count, ov, nv);
Index: uspace/lib/libc/include/loader/loader.h
===================================================================
--- uspace/lib/libc/include/loader/loader.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/include/loader/loader.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -51,5 +51,5 @@
 extern int loader_set_cwd(loader_t *);
 extern int loader_set_pathname(loader_t *, const char *);
-extern int loader_set_args(loader_t *, const char *const[]);
+extern int loader_set_args(loader_t *, char *const[]);
 extern int loader_set_files(loader_t *, fdi_node_t *const[]);
 extern int loader_load_program(loader_t *);
Index: uspace/lib/libc/include/stdio.h
===================================================================
--- uspace/lib/libc/include/stdio.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/include/stdio.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -110,5 +110,5 @@
 /* Character and string input functions */
 extern int fgetc(FILE *);
-extern char *fgets(char *, int, FILE *);
+extern char *fgets(char *, size_t, FILE *);
 
 extern int getchar(void);
Index: uspace/lib/libc/include/sysinfo.h
===================================================================
--- uspace/lib/libc/include/sysinfo.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/include/sysinfo.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,5 +40,5 @@
 #include <string.h>
 
-sysarg_t sysinfo_value(const char *name);
+sysarg_t sysinfo_value(char *name);
 
 #endif
Index: uspace/lib/libc/include/task.h
===================================================================
--- uspace/lib/libc/include/task.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/include/task.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -47,5 +47,5 @@
 extern task_id_t task_get_id(void);
 extern int task_set_name(const char *name);
-extern task_id_t task_spawn(const char *path, const char *const argv[]);
+extern task_id_t task_spawn(const char *path, char *const argv[]);
 extern int task_wait(task_id_t id, task_exit_t *texit, int *retval);
 extern int task_retval(int val);
Index: uspace/lib/libc/include/thread.h
===================================================================
--- uspace/lib/libc/include/thread.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libc/include/thread.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -45,5 +45,5 @@
 extern void __thread_main(uspace_arg_t *);
 
-extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *);
+extern int thread_create(void (*)(void *), void *, char *, thread_id_t *);
 extern void thread_exit(int) __attribute__ ((noreturn));
 extern void thread_detach(thread_id_t);
Index: uspace/lib/libpci/access.c
===================================================================
--- uspace/lib/libpci/access.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libpci/access.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -51,5 +51,5 @@
 }
 
-static void pci_generic_error(const char *msg, ...)
+static void pci_generic_error(char *msg, ...)
 {
 	va_list args;
@@ -62,5 +62,5 @@
 }
 
-static void pci_generic_warn(const char *msg, ...)
+static void pci_generic_warn(char *msg, ...)
 {
 	va_list args;
@@ -72,5 +72,5 @@
 }
 
-static void pci_generic_debug(const char *msg, ...)
+static void pci_generic_debug(char *msg, ...)
 {
 	va_list args;
@@ -81,5 +81,5 @@
 }
 
-static void pci_null_debug(const char *msg UNUSED, ...)
+static void pci_null_debug(char *msg UNUSED, ...)
 {
 }
Index: uspace/lib/libpci/internal.h
===================================================================
--- uspace/lib/libpci/internal.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libpci/internal.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -13,5 +13,5 @@
 
 struct pci_methods {
-	const char *name;
+	char *name;
 	void (*config) (struct pci_access *);
 	int (*detect) (struct pci_access *);
Index: uspace/lib/libpci/names.c
===================================================================
--- uspace/lib/libpci/names.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libpci/names.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -299,5 +299,5 @@
 }
 
-const char *pci_lookup_name(struct pci_access *a, char *buf, int size, int flags,
+char *pci_lookup_name(struct pci_access *a, char *buf, int size, int flags,
 		      ...)
 {
Index: uspace/lib/libpci/pci.h
===================================================================
--- uspace/lib/libpci/pci.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libpci/pci.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -40,7 +40,7 @@
 
 	/* Functions you can override: */
-	void (*error) (const char *msg, ...);	/* Write error message and quit */
-	void (*warning) (const char *msg, ...);	/* Write a warning message */
-	void (*debug) (const char *msg, ...);	/* Write a debugging message */
+	void (*error) (char *msg, ...);	/* Write error message and quit */
+	void (*warning) (char *msg, ...);	/* Write a warning message */
+	void (*debug) (char *msg, ...);	/* Write a debugging message */
 
 	struct pci_dev *devices;	/* Devices found on this bus */
@@ -128,6 +128,6 @@
  */
 
-const char *pci_lookup_name(struct pci_access *a, char *buf, int size,
-    int flags, ...);
+char *pci_lookup_name(struct pci_access *a, char *buf, int size, int flags,
+		      ...);
 
 int pci_load_name_list(struct pci_access *a);	/* Called automatically by pci_lookup_*() when needed; returns success */
Index: uspace/lib/libpci/pci_ids.h
===================================================================
--- uspace/lib/libpci/pci_ids.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/lib/libpci/pci_ids.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -1,4 +1,4 @@
 /* DO NOT EDIT, THIS FILE IS AUTOMATICALLY GENERATED */
-const char *pci_ids[] = {
+char *pci_ids[] = {
 "0000  Gammagraphx, Inc.",
 "001a  Ascend Communications, Inc.",
Index: uspace/srv/hid/adb_mouse/adb_dev.c
===================================================================
--- uspace/srv/hid/adb_mouse/adb_dev.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/hid/adb_mouse/adb_dev.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -50,5 +50,5 @@
 int adb_dev_init(void)
 {
-	const char *input = "/dev/adb/mouse";
+	char *input = "/dev/adb/mouse";
 	int input_fd;
 
Index: uspace/srv/hid/char_mouse/chardev.c
===================================================================
--- uspace/srv/hid/char_mouse/chardev.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/hid/char_mouse/chardev.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -52,5 +52,5 @@
 int mouse_port_init(void)
 {
-	const char *input = "/dev/char/ps2b";
+	char *input = "/dev/char/ps2b";
 	int input_fd;
 
Index: uspace/srv/hid/fb/serial_console.c
===================================================================
--- uspace/srv/hid/fb/serial_console.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/hid/fb/serial_console.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -100,5 +100,5 @@
 };
 
-void serial_puts(const char *str)
+void serial_puts(char *str)
 {
 	while (*str)
Index: uspace/srv/hid/fb/serial_console.h
===================================================================
--- uspace/srv/hid/fb/serial_console.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/hid/fb/serial_console.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -43,5 +43,5 @@
 typedef void (*putc_function_t)(char);
 
-void serial_puts(const char *str);
+void serial_puts(char *str);
 void serial_goto(const unsigned int col, const unsigned int row);
 void serial_clrscr(void);
Index: uspace/srv/hid/kbd/port/adb.c
===================================================================
--- uspace/srv/hid/kbd/port/adb.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/hid/kbd/port/adb.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -53,5 +53,5 @@
 int kbd_port_init(void)
 {
-	const char *input = "/dev/adb/kbd";
+	char *input = "/dev/adb/kbd";
 	int input_fd;
 
Index: uspace/srv/hid/kbd/port/chardev.c
===================================================================
--- uspace/srv/hid/kbd/port/chardev.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/hid/kbd/port/chardev.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -52,5 +52,5 @@
 int kbd_port_init(void)
 {
-	const char *input = "/dev/char/ps2a";
+	char *input = "/dev/char/ps2a";
 	int input_fd;
 
Index: uspace/srv/loader/elf_load.c
===================================================================
--- uspace/srv/loader/elf_load.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/loader/elf_load.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -60,5 +60,5 @@
 #define DPRINTF(...)
 
-static const char *error_codes[] = {
+static char *error_codes[] = {
 	"no error",
 	"invalid image",
@@ -95,13 +95,12 @@
  * pointed to by @a info.
  *
- * @param file_name Path to the ELF file.
- * @param so_bias   Bias to use if the file is a shared object.
- * @param info      Pointer to a structure for storing information
- *                  extracted from the binary.
+ * @param file_name	Path to the ELF file.
+ * @param so_bias	Bias to use if the file is a shared object.
+ * @param info		Pointer to a structure for storing information
+ *			extracted from the binary.
  *
  * @return EOK on success or negative error code.
- *
- */
-int elf_load_file(const char *file_name, size_t so_bias, elf_info_t *info)
+ */
+int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info)
 {
 	elf_ld_t elf;
@@ -131,6 +130,5 @@
  * earlier with elf_load_file(). This function does not return.
  *
- * @param info Info structure filled earlier by elf_load_file()
- *
+ * @param info	Info structure filled earlier by elf_load_file()
  */
 void elf_run(elf_info_t *info, pcb_t *pcb)
@@ -282,5 +280,5 @@
  * @return NULL terminated description of error.
  */
-const char *elf_error(unsigned int rc)
+char *elf_error(unsigned int rc)
 {
 	assert(rc < sizeof(error_codes) / sizeof(char *));
Index: uspace/srv/loader/include/elf.h
===================================================================
--- uspace/srv/loader/include/elf.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/loader/include/elf.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -337,5 +337,5 @@
 #endif
 
-extern const char *elf_error(unsigned int rc);
+extern char *elf_error(unsigned int rc);
 
 #endif
Index: uspace/srv/loader/include/elf_load.h
===================================================================
--- uspace/srv/loader/include/elf_load.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/loader/include/elf_load.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup generic
+/** @addtogroup generic	
  * @{
  */
@@ -51,5 +51,5 @@
 
 	/** ELF interpreter name or NULL if statically-linked */
-	const char *interp;
+	char *interp;
 
 	/** Pointer to the dynamic section */
@@ -74,5 +74,5 @@
 } elf_ld_t;
 
-int elf_load_file(const char *file_name, size_t so_bias, elf_info_t *info);
+int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info);
 void elf_run(elf_info_t *info, pcb_t *pcb);
 void elf_create_pcb(elf_info_t *info, pcb_t *pcb);
Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/il/ip/ip.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -479,5 +479,5 @@
 	ERROR_DECLARE;
 
-	measured_string_t	names[] = {{ str_dup("IPV"), 3 }, { str_dup("IP_CONFIG"), 9 }, { str_dup("IP_ADDR"), 7 }, { str_dup("IP_NETMASK"), 10 }, { str_dup("IP_GATEWAY"), 10 }, { str_dup("IP_BROADCAST"), 12 }, { str_dup("ARP"), 3 }, { str_dup("IP_ROUTING"), 10 }};
+	measured_string_t	names[] = {{ "IPV", 3 }, { "IP_CONFIG", 9 }, { "IP_ADDR", 7 }, { "IP_NETMASK", 10 }, { "IP_GATEWAY", 10 }, { "IP_BROADCAST", 12 }, { "ARP", 3 }, { "IP_ROUTING", 10 }};
 	measured_string_ref	configuration;
 	size_t				count = sizeof( names ) / sizeof( measured_string_t );
Index: uspace/srv/net/modules.c
===================================================================
--- uspace/srv/net/modules.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/modules.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -55,17 +55,16 @@
 
 int connect_to_service_timeout( services_t need, suseconds_t timeout ){
-	if (timeout <= 0)
-		return async_connect_me_to_blocking( PHONE_NS, need, 0, 0);
-	
+	ipcarg_t phone;
+	int res;
+
 	while( true ){
-		int phone;
-
-		phone = async_connect_me_to( PHONE_NS, need, 0, 0);
-		if( (phone >= 0) || (phone != ENOENT) )
+		res = async_req_3_5( PHONE_NS, IPC_M_CONNECT_ME_TO, need, 0, 0, NULL, NULL, NULL, NULL, & phone );
+		if( res >= 0 ){
 			return phone;
-	
-		timeout -= MODULE_WAIT_TIME;
-		if( timeout <= 0 ) return ETIMEOUT;
-
+		}
+		if( timeout > 0 ){
+			timeout -= MODULE_WAIT_TIME;
+			if( timeout <= 0 ) return ETIMEOUT;
+		}
 		usleep( MODULE_WAIT_TIME );
 	}
@@ -85,5 +84,5 @@
 	if( phone >= 0 ){
 		if( ERROR_OCCURRED( ipc_connect_to_me( phone, arg1, arg2, arg3, & phonehash ))){
-			ipc_hangup( phone );
+			async_msg_0( phone, IPC_M_PHONE_HUNGUP );
 			return ERROR_CODE;
 		}
Index: uspace/srv/net/net/net.c
===================================================================
--- uspace/srv/net/net/net.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/net/net.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -154,5 +154,5 @@
  *  @returns Other error codes as defined for the add_configuration() function.
  */
-int	read_netif_configuration( const char * name, netif_ref netif );
+int	read_netif_configuration( char * name, netif_ref netif );
 
 /** Networking module global data.
@@ -413,5 +413,5 @@
 }
 
-int read_netif_configuration( const char * name, netif_ref netif ){
+int read_netif_configuration( char * name, netif_ref netif ){
 	// read the netif configuration file
 	return read_configuration_file( CONF_DIR, name, & netif->configuration );
@@ -485,7 +485,7 @@
 
 #ifdef CONFIG_NETIF_DP8390
-	const char *		conf_files[] = { "lo", "ne2k" };
+	char *		conf_files[] = { "lo", "ne2k" };
 #else
-	const char *		conf_files[] = { "lo" };
+	char *		conf_files[] = { "lo" };
 #endif
 
Index: uspace/srv/net/net/start/netstart.c
===================================================================
--- uspace/srv/net/net/start/netstart.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/net/start/netstart.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -69,5 +69,5 @@
  *  @returns Other error codes as defined for the task_spawn() function.
  */
-task_id_t	spawn( const char * fname );
+task_id_t	spawn( char * fname );
 
 int main( int argc, char * argv[] ){
@@ -97,12 +97,16 @@
 }
 
-task_id_t spawn( const char * fname ){
-	const char *	argv[ 2 ];
+task_id_t spawn( char * fname ){
+	char *	argv[ 2 ];
 	task_id_t	res;
 
+//	printf( "Spawning %s\n", fname );
 	argv[ 0 ] = fname;
 	argv[ 1 ] = NULL;
 	res = task_spawn( fname, argv );
-	
+	if( res != 0 ){
+		/* Success */
+		usleep( 50000 );
+	}
 	return res;
 }
Index: uspace/srv/net/netif/lo/lo.c
===================================================================
--- uspace/srv/net/netif/lo/lo.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/netif/lo/lo.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -102,5 +102,5 @@
 int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){
 	if( ! address ) return EBADMEM;
-	address->value = str_dup(DEFAULT_ADDR);
+	address->value = DEFAULT_ADDR;
 	address->length = DEFAULT_ADDR_LEN;
 	return EOK;
Index: uspace/srv/net/nil/eth/eth.c
===================================================================
--- uspace/srv/net/nil/eth/eth.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/nil/eth/eth.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -308,5 +308,5 @@
 	eth_device_ref	device;
 	int				index;
-	measured_string_t	names[ 2 ] = {{ str_dup("ETH_MODE"), 8 }, { str_dup("ETH_DUMMY"), 9 }};
+	measured_string_t	names[ 2 ] = {{ "ETH_MODE", 8 }, { "ETH_DUMMY", 9 }};
 	measured_string_ref	configuration;
 	size_t				count = sizeof( names ) / sizeof( measured_string_t );
Index: uspace/srv/net/structures/module_map.c
===================================================================
--- uspace/srv/net/structures/module_map.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/structures/module_map.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -49,5 +49,5 @@
 GENERIC_CHAR_MAP_IMPLEMENT( modules, module_t )
 
-int add_module( module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t connect_module ){
+int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id, connect_module_t connect_module ){
 	ERROR_DECLARE;
 
@@ -86,12 +86,23 @@
 }
 
-task_id_t spawn( const char * fname ){
-	const char * argv[ 2 ];
+task_id_t spawn( char * fname ){
+	char * argv[ 2 ];
+//	char * argv[ 4 ];
 	task_id_t	res;
 
+//	printf( "Spawning %s\n", fname );
 	argv[ 0 ] = fname;
 	argv[ 1 ] = NULL;
 	res = task_spawn( fname, argv );
-
+/*	argv[ 0 ] = "/app/trace";
+	argv[ 1 ] = "+ti";
+	argv[ 2 ] = fname;
+	argv[ 3 ] = NULL;
+	res = task_spawn( "/app/trace", argv );
+*/
+	if( res != 0 ){
+		/* Success */
+		usleep( 10000 );
+	}
 	return res;
 }
Index: uspace/srv/net/structures/module_map.h
===================================================================
--- uspace/srv/net/structures/module_map.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/structures/module_map.h	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -79,8 +79,8 @@
 	/** Module name.
 	 */
-	const char *		name;
+	char *		name;
 	/** Module full path filename.
 	 */
-	const char *		filename;
+	char *		filename;
 	/** Connecting function.
 	 */
@@ -99,5 +99,5 @@
  *  @returns ENOMEM if there is not enough memory left.
  */
-int	add_module( module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module );
+int	add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module );
 
 /** Searches and returns the specified module.
@@ -116,5 +116,5 @@
  *  @returns 0 if there is no such module.
  */
-task_id_t	spawn( const char * fname );
+task_id_t	spawn( char * fname );
 
 #endif
Index: uspace/srv/net/tl/icmp/icmp.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -464,5 +464,5 @@
 	ERROR_DECLARE;
 
-	measured_string_t	names[] = {{ str_dup("ICMP_ERROR_REPORTING"), 20 }, { str_dup("ICMP_ECHO_REPLYING"), 18 }};
+	measured_string_t	names[] = {{ "ICMP_ERROR_REPORTING", 20 }, { "ICMP_ECHO_REPLYING", 18 }};
 	measured_string_ref	configuration;
 	size_t				count = sizeof( names ) / sizeof( measured_string_t );
Index: uspace/srv/net/tl/udp/udp.c
===================================================================
--- uspace/srv/net/tl/udp/udp.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/udp/udp.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -192,5 +192,5 @@
 	ERROR_DECLARE;
 
-	measured_string_t	names[] = {{ str_dup("UDP_CHECKSUM_COMPUTING"), 22 }, { str_dup("UDP_AUTOBINDING"), 15 }};
+	measured_string_t	names[] = {{ "UDP_CHECKSUM_COMPUTING", 22 }, { "UDP_AUTOBINDING", 15 }};
 	measured_string_ref	configuration;
 	size_t				count = sizeof( names ) / sizeof( measured_string_t );
Index: uspace/srv/taskmon/taskmon.c
===================================================================
--- uspace/srv/taskmon/taskmon.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/taskmon/taskmon.c	(revision 2e992773e5f019775f8da23f506b24fe7ec905b0)
@@ -49,9 +49,9 @@
 static void fault_event(ipc_callid_t callid, ipc_call_t *call)
 {
-	const char *argv[6];
-	const char *fname;
+	char *argv[6];
+	char *fname;
 	char *dump_fname;
 	char *s_taskid;
-	const char **s;
+	char **s;
 
 	task_id_t taskid;
@@ -89,6 +89,5 @@
 
 	printf(NAME ": Executing");
-	
-	s = argv;
+        s = argv;
 	while (*s != NULL) {
 		printf(" %s", *s);
