Index: boot/arch/sparc64/loader/Makefile
===================================================================
--- boot/arch/sparc64/loader/Makefile	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ boot/arch/sparc64/loader/Makefile	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -52,4 +52,5 @@
 	main.c \
 	../../../generic/printf.c \
+	../../../generic/string.c \
 	../../../genarch/ofw.c \
 	ofwarch.c \
Index: boot/arch/sparc64/loader/main.c
===================================================================
--- boot/arch/sparc64/loader/main.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ boot/arch/sparc64/loader/main.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -67,5 +67,9 @@
 		printf("Error: unable to get keyboard properties\n");
 
+	if (!ofw_cpu(&bootinfo.cpu))
+		printf("Error: unable to get cpu properties\n");
+
 	printf("\nDevice statistics\n");
+	printf(" cpu: %dMHz\n", bootinfo.cpu.clock_frequency/1000000);
 	printf(" memory: %dM\n", bootinfo.memmap.total>>20);
 	printf(" screen at %P, resolution %dx%d, %d bpp (scanline %d bytes)\n", (uintptr_t) bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
Index: boot/arch/sparc64/loader/main.h
===================================================================
--- boot/arch/sparc64/loader/main.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ boot/arch/sparc64/loader/main.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -46,8 +46,13 @@
 
 typedef struct {
+	uint32_t clock_frequency;
+} cpu_t;
+
+typedef struct {
 	taskmap_t taskmap;
 	memmap_t memmap;
 	screen_t screen;
 	keyboard_t keyboard;
+	cpu_t cpu;
 } bootinfo_t;
 
Index: boot/arch/sparc64/loader/ofwarch.c
===================================================================
--- boot/arch/sparc64/loader/ofwarch.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ boot/arch/sparc64/loader/ofwarch.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -35,4 +35,6 @@
 #include <ofw.h>
 #include <printf.h>
+#include <string.h>
+#include "main.h"
 
 int bpp2align[] = {
@@ -80,2 +82,30 @@
 	return true;
 }
+
+int ofw_cpu(cpu_t *cpu)
+{
+	char type_name[BUF_SIZE];
+
+	phandle node;
+	node = ofw_get_child_node(ofw_root);
+	if (node == 0 || node == -1) {
+		printf("Could not find any child nodes of the root node.\n");
+		return;
+	}
+	
+	for (; node != 0 && node != -1; node = ofw_get_peer_node(node)) {
+		if (ofw_get_property(node, "device_type", type_name, sizeof(type_name)) > 0) {
+			if (strncmp(type_name, "cpu", 3) == 0) {
+				uint32_t mhz;
+				
+				if (ofw_get_property(node, "clock-frequency", &mhz, sizeof(mhz)) <= 0)
+					continue;
+					
+				cpu->clock_frequency = mhz;
+				return 1;
+			}
+		}
+	};
+
+	return 0;
+}
Index: boot/arch/sparc64/loader/ofwarch.h
===================================================================
--- boot/arch/sparc64/loader/ofwarch.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ boot/arch/sparc64/loader/ofwarch.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -30,4 +30,6 @@
 #define BOOT_sparc64_OFWARCH_H_
 
+#include "main.h"
+
 #define OFW_ADDRESS_CELLS	2
 #define OFW_SIZE_CELLS		2
@@ -35,3 +37,5 @@
 extern int bpp2align[];
 
+extern int ofw_cpu(cpu_t *cpu);
+
 #endif
Index: boot/genarch/ofw.c
===================================================================
--- boot/genarch/ofw.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ boot/genarch/ofw.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -146,4 +146,13 @@
 }
 
+phandle ofw_get_child_node(const phandle node)
+{
+	return ofw_call("child", 1, 1, NULL, node);
+}
+
+phandle ofw_get_peer_node(const phandle node)
+{
+	return ofw_call("peer", 1, 1, NULL, node);
+}
 
 static ihandle ofw_open(const char *name)
Index: boot/genarch/ofw.h
===================================================================
--- boot/genarch/ofw.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ boot/genarch/ofw.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -91,10 +91,20 @@
 extern uintptr_t ofw_cif;
 
+
+extern phandle ofw_chosen;
+extern ihandle ofw_stdout;
+extern phandle ofw_root;
+extern ihandle ofw_mmu;
+extern phandle ofw_memory;
 extern phandle ofw_aliases;
 
 extern void ofw_init(void);
+
 extern void ofw_write(const char *str, const int len);
 
 extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen);
+
+extern phandle ofw_get_child_node(const phandle node);
+extern phandle ofw_get_peer_node(const phandle node);
 extern phandle ofw_find_device(const char *name);
 
Index: boot/generic/gentypes.h
===================================================================
--- boot/generic/gentypes.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ boot/generic/gentypes.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -34,3 +34,5 @@
 #define true 1
 
+typedef unsigned long size_t;
+
 #endif
Index: boot/generic/string.c
===================================================================
--- boot/generic/string.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
+++ boot/generic/string.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup generic	
+ * @{
+ */
+
+#include <string.h>
+
+/**
+ * @file
+ * @brief	String manipulation functions.
+ */
+
+/** Return number of characters in a string.
+ *
+ * @param str NULL terminated string.
+ *
+ * @return Number of characters in str.
+ */
+size_t strlen(const char *str)
+{
+	int i;
+	
+	for (i = 0; str[i]; i++)
+		;
+	
+	return i;
+}
+
+/** Compare two NULL terminated strings
+ *
+ * Do a char-by-char comparison of two NULL terminated strings.
+ * The strings are considered equal iff they consist of the same
+ * characters on the minimum of their lengths and specified maximal
+ * length.
+ *
+ * @param src First string to compare.
+ * @param dst Second string to compare.
+ * @param len Maximal length for comparison.
+ *
+ * @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller.
+ *
+ */
+int strncmp(const char *src, const char *dst, size_t len)
+{
+	int i;
+	
+	i = 0;
+	for (;*src && *dst && i < len;src++,dst++,i++) {
+		if (*src < *dst)
+			return -1;
+		if (*src > *dst)
+			return 1;
+	}
+	if (i == len || *src == *dst)
+		return 0;
+	if (!*src)
+		return -1;
+	return 1;
+}
+
+/** Copy NULL terminated string.
+ *
+ * Copy at most 'len' characters from string 'src' to 'dest'.
+ * If 'src' is shorter than 'len', '\0' is inserted behind the
+ * last copied character.
+ *
+ * @param src Source string.
+ * @param dest Destination buffer.
+ * @param len Size of destination buffer.
+ */
+void strncpy(char *dest, const char *src, size_t len)
+{
+	int i;
+	for (i = 0; i < len; i++) {
+		if (!(dest[i] = src[i]))
+			return;
+	}
+	dest[i-1] = '\0';
+}
+
+/** Convert ascii representation to unative_t
+ *
+ * Supports 0x for hexa & 0 for octal notation.
+ * Does not check for overflows, does not support negative numbers
+ *
+ * @param text Textual representation of number
+ * @return Converted number or 0 if no valid number ofund 
+ */
+unative_t atoi(const char *text)
+{
+	int base = 10;
+	unative_t result = 0;
+
+	if (text[0] == '0' && text[1] == 'x') {
+		base = 16;
+		text += 2;
+	} else if (text[0] == '0')
+		base = 8;
+
+	while (*text) {
+		if (base != 16 && \
+		    ((*text >= 'A' && *text <= 'F' )
+		     || (*text >='a' && *text <='f')))
+			break;
+		if (base == 8 && *text >='8')
+			break;
+
+		if (*text >= '0' && *text <= '9') {
+			result *= base;
+			result += *text - '0';
+		} else if (*text >= 'A' && *text <= 'F') {
+			result *= base;
+			result += *text - 'A' + 10;
+		} else if (*text >= 'a' && *text <= 'f') {
+			result *= base;
+			result += *text - 'a' + 10;
+		} else
+			break;
+		text++;
+	}
+
+	return result;
+}
+
+/** @}
+ */
Index: boot/generic/string.h
===================================================================
--- boot/generic/string.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
+++ boot/generic/string.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup generic	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef BOOT_STRING_H_
+#define BOOT_STRING_H_
+
+#include <types.h>
+
+extern size_t strlen(const char *str);
+extern int strncmp(const char *src, const char *dst, size_t len);
+extern void strncpy(char *dest, const char *src, size_t len);
+extern unative_t atoi(const char *text);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/ia64/src/drivers/it.c
===================================================================
--- kernel/arch/ia64/src/drivers/it.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/ia64/src/drivers/it.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -27,5 +27,5 @@
  */
 
- /** @addtogroup ia64	
+/** @addtogroup ia64	
  * @{
  */
@@ -77,18 +77,15 @@
 	eoi_write(EOI);
 	
-	m=itm_read();
+	m = itm_read();
 	
-	while(1)
-	{
-	
-		c=itc_read();
-		c+=IT_SERVICE_CLOCKS;
+	while (1) {
+		c = itc_read();
+		c += IT_SERVICE_CLOCKS;
 
-		m+=IT_DELTA;
-		if(m-c<0)
-		{
+		m += IT_DELTA;
+		if (m-c<0)
 			CPU->missed_clock_ticks++;
-		}
-		else break;
+		else
+			break;
 	}
 	
@@ -96,11 +93,8 @@
 	srlz_d();				/* propagate changes */
 	
-	
-	
 	clock();
 	poll_keyboard();
 }
 
- /** @}
+/** @}
  */
-
Index: kernel/arch/mips32/include/asm.h
===================================================================
--- kernel/arch/mips32/include/asm.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/mips32/include/asm.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -67,4 +67,9 @@
 			  uintptr_t entry);
 
+extern ipl_t interrupts_disable(void);
+extern ipl_t interrupts_enable(void);
+extern void interrupts_restore(ipl_t ipl);
+extern ipl_t interrupts_read(void);
+
 #endif
 
Index: kernel/arch/mips32/src/interrupt.c
===================================================================
--- kernel/arch/mips32/src/interrupt.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/mips32/src/interrupt.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -27,5 +27,5 @@
  */
 
- /** @addtogroup mips32interrupt
+/** @addtogroup mips32interrupt
  * @{
  */
@@ -142,5 +142,5 @@
 }
 
- /** @}
+/** @}
  */
 
Index: kernel/arch/sparc64/include/asm.h
===================================================================
--- kernel/arch/sparc64/include/asm.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/include/asm.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -36,8 +36,10 @@
 #define KERN_sparc64_ASM_H_
 
+#include <arch.h>
 #include <typedefs.h>
 #include <arch/types.h>
 #include <arch/register.h>
 #include <config.h>
+#include <time/clock.h>
 
 /** Read Processor State register.
@@ -336,5 +338,5 @@
 extern void cpu_halt(void);
 extern void cpu_sleep(void);
-extern void asm_delay_loop(uint32_t t);
+extern void asm_delay_loop(const uint32_t usec);
 
 extern uint64_t read_from_ag_g7(void);
Index: kernel/arch/sparc64/include/boot/boot.h
===================================================================
--- kernel/arch/sparc64/include/boot/boot.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/include/boot/boot.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -84,8 +84,13 @@
 
 typedef struct {
+	uint32_t clock_frequency;
+} processor_t;
+
+typedef struct {
 	taskmap_t taskmap;
 	memmap_t memmap;
 	screen_t screen;
 	keyboard_t keyboard;
+	processor_t processor;
 } bootinfo_t;
 
Index: kernel/arch/sparc64/include/cpu.h
===================================================================
--- kernel/arch/sparc64/include/cpu.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/include/cpu.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -53,4 +53,5 @@
 struct cpu_arch {
 	ver_reg_t ver;
+	uint32_t clock_frequency;
 };
 	
Index: kernel/arch/sparc64/include/drivers/tick.h
===================================================================
--- kernel/arch/sparc64/include/drivers/tick.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/include/drivers/tick.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -38,6 +38,4 @@
 #include <typedefs.h>
 
-#define TICK_DELTA        500000
-
 extern void tick_init(void);
 extern void tick_interrupt(int n, istate_t *istate);
Index: kernel/arch/sparc64/src/cpu/cpu.c
===================================================================
--- kernel/arch/sparc64/src/cpu/cpu.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/src/cpu/cpu.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -33,12 +33,14 @@
  */
 
+#include <arch/asm.h>
 #include <cpu.h>
 #include <arch.h>
 #include <arch/register.h>
-#include <arch/asm.h>
 #include <print.h>
+#include <arch/boot/boot.h>
 
 void cpu_arch_init(void)
 {
+	CPU->arch.clock_frequency = bootinfo.processor.clock_frequency;
 }
 
@@ -94,5 +96,6 @@
 	}
 
-	printf("cpu%d: manuf=%s, impl=%s, mask=%d\n", CPU->id, manuf, impl, CPU->arch.ver.mask);
+	printf("cpu%d: manuf=%s, impl=%s, mask=%d (%dMHz)\n",
+		CPU->id, manuf, impl, CPU->arch.ver.mask, CPU->arch.clock_frequency/1000000);
 }
 
Index: kernel/arch/sparc64/src/drivers/tick.c
===================================================================
--- kernel/arch/sparc64/src/drivers/tick.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/src/drivers/tick.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -37,7 +37,12 @@
 #include <arch/asm.h>
 #include <arch/register.h>
+#include <typedefs.h>
+#include <arch/cpu.h>
+#include <arch/boot/boot.h>
+#include <time/clock.h>
+#include <arch.h>
 #include <debug.h>
-#include <time/clock.h>
-#include <typedefs.h>
+
+#define TICK_RESTART_TIME	50	/* Worst case estimate. */
 
 /** Initialize tick interrupt. */
@@ -48,5 +53,5 @@
 	interrupt_register(14, "tick_int", tick_interrupt);
 	compare.int_dis = false;
-	compare.tick_cmpr = TICK_DELTA;
+	compare.tick_cmpr = bootinfo.processor.clock_frequency/HZ;
 	tick_compare_write(compare.value);
 	tick_write(0);
@@ -61,4 +66,5 @@
 {
 	softint_reg_t softint, clear;
+	uint64_t next, compare, start, stop;
 	
 	softint.value = softint_read();
@@ -84,5 +90,13 @@
 	 * Restart counter.
 	 */
-	tick_write(0);
+	compare = CPU->arch.clock_frequency/HZ;
+	start = tick_read();
+	next = start - compare;
+	while (next >= compare - TICK_RESTART_TIME) {
+		next -= compare;
+		CPU->missed_clock_ticks++;
+	}
+	stop = tick_read();
+	tick_write(next + (stop - start));
 	
 	clock();
Index: kernel/arch/sparc64/src/dummy.s
===================================================================
--- kernel/arch/sparc64/src/dummy.s	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/src/dummy.s	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -29,5 +29,4 @@
 .text
 
-.global asm_delay_loop
 .global cpu_sleep
 .global fpu_context_restore
@@ -39,5 +38,4 @@
 .global dummy
 
-asm_delay_loop:
 cpu_sleep:
 fpu_context_restore:
Index: kernel/arch/sparc64/src/sparc64.c
===================================================================
--- kernel/arch/sparc64/src/sparc64.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/src/sparc64.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -43,4 +43,5 @@
 #include <arch/boot/boot.h>
 #include <arch/arch.h>
+#include <arch/asm.h>
 #include <arch/mm/page.h>
 #include <arch/stack.h>
@@ -90,6 +91,28 @@
 }
 
+/** Calibrate delay loop.
+ *
+ * On sparc64, we implement delay() by waiting for the TICK register to
+ * reach a pre-computed value, as opposed to performing some pre-computed
+ * amount of instructions of known duration. We set the delay_loop_const
+ * to 1 in order to neutralize the multiplication done by delay().
+ */
 void calibrate_delay_loop(void)
 {
+	CPU->delay_loop_const = 1;
+}
+
+/** Wait several microseconds.
+ *
+ * We assume that interrupts are already disabled.
+ *
+ * @param t Microseconds to wait.
+ */
+void asm_delay_loop(const uint32_t usec)
+{
+	uint64_t stop = tick_read() + (uint64_t) usec * (uint64_t) CPU->arch.clock_frequency / 1000000;
+
+	while (tick_read() < stop)
+		;
 }
 
Index: kernel/arch/sparc64/src/start.S
===================================================================
--- kernel/arch/sparc64/src/start.S	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/arch/sparc64/src/start.S	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -61,13 +61,11 @@
 	 */
 
-	flushw				! flush all but the active register window
-	wrpr %g0, 0, %tl		! TL = 0, primary context register is used
-
-	! Disable interrupts and disable 32-bit address masking.
-	rdpr %pstate, %g1
-	and %g1, ~(PSTATE_AM_BIT|PSTATE_IE_BIT), %g1
-	wrpr %g1, 0, %pstate
-
-	wrpr %g0, 0, %pil		! intialize %pil
+	flushw					! flush all but the active register window
+
+	wrpr %g0, 0, %tl			! TL = 0, primary context register is used
+
+	wrpr %g0, PSTATE_PRIV_BIT, %pstate	! Disable interrupts and disable 32-bit address masking.
+
+	wrpr %g0, 0, %pil			! intialize %pil
 
 	/*
Index: kernel/generic/include/arch.h
===================================================================
--- kernel/generic/include/arch.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/generic/include/arch.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -33,6 +33,6 @@
  */
 
-#ifndef __ARCH_H__
-#define __ARCH_H__
+#ifndef KERN_ARCH_H_
+#define KERN_ARCH_H_
 
 #include <arch/types.h>
@@ -80,9 +80,4 @@
 extern void calibrate_delay_loop(void);
 
-extern ipl_t interrupts_disable(void); 
-extern ipl_t interrupts_enable(void);
-extern void interrupts_restore(ipl_t ipl);
-extern ipl_t interrupts_read(void);
-
 #endif
 
Index: kernel/generic/include/cpu.h
===================================================================
--- kernel/generic/include/cpu.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/generic/include/cpu.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -33,6 +33,6 @@
  */
 
-#ifndef __CPU_H__
-#define __CPU_H__
+#ifndef KERN_CPU_H_
+#define KERN_CPU_H_
 
 #include <arch/cpu.h>
Index: kernel/generic/include/time/clock.h
===================================================================
--- kernel/generic/include/time/clock.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/generic/include/time/clock.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -33,6 +33,6 @@
  */
 
-#ifndef __CLOCK_H__
-#define __CLOCK_H__
+#ifndef KERN_CLOCK_H_
+#define KERN_CLOCK_H_
 
 #define HZ		100
Index: kernel/generic/include/time/delay.h
===================================================================
--- kernel/generic/include/time/delay.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/generic/include/time/delay.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -33,6 +33,6 @@
  */
 
-#ifndef __DELAY_H__
-#define __DELAY_H__
+#ifndef KERN_DELAY_H_
+#define KERN_DELAY_H_
 
 #include <arch/types.h>
Index: kernel/generic/include/time/timeout.h
===================================================================
--- kernel/generic/include/time/timeout.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/generic/include/time/timeout.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -33,6 +33,6 @@
  */
 
-#ifndef __TIMEOUT_H__
-#define __TIMEOUT_H__
+#ifndef KERN_TIMEOUT_H_
+#define KERN_TIMEOUT_H_
 
 #include <arch/types.h>
Index: kernel/generic/include/typedefs.h
===================================================================
--- kernel/generic/include/typedefs.h	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/generic/include/typedefs.h	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -33,6 +33,6 @@
  */
 
-#ifndef __TYPEDEFS_H__
-#define __TYPEDEFS_H__
+#ifndef KERN_TYPEDEFS_H_
+#define KERN_TYPEDEFS_H_
 
 #define false 0
Index: kernel/generic/src/cpu/cpu.c
===================================================================
--- kernel/generic/src/cpu/cpu.c	(revision 7bb6b065122bb8af8404a0355703e35ee8e56a37)
+++ kernel/generic/src/cpu/cpu.c	(revision 9a5b556abb26634c82cbd3954b0fdb4db62b828e)
@@ -110,5 +110,5 @@
 }
 
- /** @}
+/** @}
  */
 
