Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision b886b60583e374eb7225d5360734542d3ff3085c)
+++ HelenOS.config	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -39,4 +39,5 @@
 @ "mips64" MIPS 64-bit
 @ "ppc32" PowerPC 32-bit (iMac G4)
+@ "sparc32" SPARC v8 (32-bit)
 @ "sparc64" Sun UltraSPARC 64-bit
 ! PLATFORM (choice)
@@ -60,4 +61,8 @@
 @ "generic" Generic Sun workstation or server
 ! [PLATFORM=sparc64] MACHINE (choice)
+
+% Machine type
+@ "leon3" Gaisler Aeroflex LEON3
+! [PLATFORM=sarc32] MACHINE (choice)
 
 % Machine type
@@ -88,4 +93,8 @@
 
 % CPU type
+@ "leon3" Gaisler Aeroflex LEON3
+! [PLATFORM=sparc32&MACHINE=leon3] PROCESSOR (choice)
+
+% CPU type
 @ "cortex_a8" ARM Cortex A-8
 ! [PLATFORM=arm32&(MACHINE=beagleboardxm|MACHINE=beaglebone)] PROCESSOR (choice)
@@ -176,4 +185,7 @@
 ! [PLATFORM=sparc64] KARCH (choice)
 
+% Kernel architecture
+@ "sparc32"
+! [PLATFORM=sparc32] KARCH (choice)
 
 ## Mapping between platform and user space architecture
@@ -223,4 +235,7 @@
 ! [PLATFORM=sparc64] UARCH (choice)
 
+% User space architecture
+@ "sparc32"
+! [PLATFORM=sparc32] UARCH (choice)
 
 ## Mapping between platform and boot architecture
@@ -270,4 +285,7 @@
 ! [PLATFORM=sparc64] BARCH (choice)
 
+% Boot architecture
+@ "sparc32"
+! [PLATFORM=sparc32] BARCH (choice)
 
 ## Mapping between platform and image format
@@ -284,5 +302,4 @@
 @ "binary"
 ! [PLATFORM=mips64] IMAGE (choice)
-
 
 ## Compiler options
@@ -310,5 +327,5 @@
 @ "gcc_native" GNU C Compiler (native)
 @ "clang" Clang
-! [PLATFORM=abs32le|PLATFORM=arm32|PLATFORM=sparc64] COMPILER (choice)
+! [PLATFORM=abs32le|PLATFORM=arm32|PLATFORM=sparc64|PLATFORM=sparc32] COMPILER (choice)
 
 
@@ -337,5 +354,5 @@
 
 % Hierarchical page tables support
-! [PLATFORM=abs32le|PLATFORM=ia32|PLATFORM=amd64|PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32] CONFIG_PAGE_PT (y)
+! [PLATFORM=abs32le|PLATFORM=ia32|PLATFORM=amd64|PLATFORM=arm32|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc32] CONFIG_PAGE_PT (y)
 
 % Page hash table support
@@ -343,5 +360,5 @@
 
 % Software integer division support
-! [PLATFORM=abs32le|PLATFORM=ia32|PLATFORM=arm32|PLATFORM=ia64|PLATFORM=mips32|PLATFORM=mips64|PLATFORM=ppc32] CONFIG_SOFTINT (y)
+! [PLATFORM=abs32le|PLATFORM=ia32|PLATFORM=arm32|PLATFORM=ia64|PLATFORM=mips32|PLATFORM=mips64|PLATFORM=ppc32|PLATFORM=sparc32] CONFIG_SOFTINT (y)
 
 % ASID support
Index: boot/arch/sparc32/Makefile.inc
===================================================================
--- boot/arch/sparc32/Makefile.inc	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/Makefile.inc	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,58 @@
+#
+# Copyright (c) 2013 Jakub Klama
+# 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.
+#
+
+ifeq ($(MACHINE), leon3)
+	BOOT_OUTPUT = image.boot
+	POST_OUTPUT = $(ROOT_PATH)/uImage.bin
+	LADDR = 0x40000000
+	SADDR = 0x40000000
+	POSTBUILD = Makefile.uboot
+endif
+
+BFD_NAME = elf32-sparc
+BFD_OUTPUT = $(BFD_NAME)
+BFD_ARCH = sparc
+
+BITS = 32
+ENDIANESS = LE
+
+SOURCES = \
+	arch/$(BARCH)/src/asm.S \
+	arch/$(BARCH)/src/ambapp.c \
+	arch/$(BARCH)/src/main.c \
+	arch/$(BARCH)/src/mm.c \
+	arch/$(BARCH)/src/putchar.c \
+	$(COMPS_C) \
+	genarch/src/division.c \
+	generic/src/memstr.c \
+	generic/src/printf_core.c \
+	generic/src/vprintf.c \
+	generic/src/printf.c \
+	generic/src/str.c \
+	generic/src/version.c \
+	generic/src/inflate.c
Index: boot/arch/sparc32/_link.ld.in
===================================================================
--- boot/arch/sparc32/_link.ld.in	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/_link.ld.in	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,37 @@
+#include <arch/arch.h>
+
+ENTRY(start)
+
+SECTIONS {
+	. = BOOT_BASE;
+	.text : {
+		*(BOOTSTRAP);
+		*(.text);
+	}
+	. = BOOT_BASE + 0x8000;
+	.data : {
+		bdata_start = .;
+		*(BOOTPT);      /* bootstrap page table */
+		*(BOOTSTACK);   /* bootstrap stack */
+		*(.data);       /* initialized data */
+		*(.rodata);
+		*(.rodata.*);
+		*(.sdata);
+		*(.reginfo);
+		*(.sbss);
+		*(.scommon);
+		*(.bss);        /* uninitialized static variables */
+		*(COMMON);      /* global variables */
+[[COMPONENTS]]
+	}
+	bdata_end = .;
+
+	/DISCARD/ : {
+		*(.gnu.*);
+		*(.ARM.*);
+		*(.mdebug*);
+		*(.pdr);
+		*(.comment);
+		*(.note.*);
+	}
+}
Index: boot/arch/sparc32/include/ambapp.h
===================================================================
--- boot/arch/sparc32/include/ambapp.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/include/ambapp.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32boot
+ * @{
+ */
+/** @file
+ * @brief Definitions of structures and addresses of AMBA Plug&Play interface
+ */
+
+#ifndef BOOT_sparc32_AMBAPP_H
+#define BOOT_sparc32_AMBAPP_H
+
+#define	AMBAPP_MAX_DEVICES	64
+#define	AMBAPP_AHBMASTER_AREA	0xfffff000
+#define	AMBAPP_AHBSLAVE_AREA	0xfffff800
+#define	AMBAPP_CONF_AREA	0xff000
+
+typedef enum {
+	GAISLER			= 1,
+	ESA			= 4
+} amba_vendor_id_t;
+
+typedef enum {
+	GAISLER_LEON3    	= 0x003,
+	GAISLER_LEON3DSU 	= 0x004,
+	GAISLER_ETHAHB   	= 0x005,
+	GAISLER_APBMST   	= 0x006,
+	GAISLER_AHBUART  	= 0x007,
+	GAISLER_SRCTRL   	= 0x008,
+	GAISLER_SDCTRL   	= 0x009,
+	GAISLER_APBUART  	= 0x00C,
+	GAISLER_IRQMP    	= 0x00D,
+	GAISLER_AHBRAM   	= 0x00E,
+	GAISLER_GPTIMER  	= 0x011,
+	GAISLER_PCITRG   	= 0x012,
+	GAISLER_PCISBRG  	= 0x013,
+	GAISLER_PCIFBRG  	= 0x014,
+	GAISLER_PCITRACE 	= 0x015,
+	GAISLER_PCIDMA   	= 0x016,
+	GAISLER_AHBTRACE 	= 0x017,
+	GAISLER_ETHDSU   	= 0x018,
+	GAISLER_PIOPORT  	= 0x01A,
+	GAISLER_AHBJTAG  	= 0x01c,
+	GAISLER_SPW      	= 0x01f,
+	GAISLER_ATACTRL  	= 0x024,
+	GAISLER_VGA      	= 0x061,
+	GAISLER_KBD      	= 0x060,
+	GAISLER_ETHMAC   	= 0x01D,
+	GAISLER_DDRSPA   	= 0x025,
+	GAISLER_EHCI     	= 0x026,
+	GAISLER_UHCI     	= 0x027,
+	GAISLER_SPW2     	= 0x029,
+	GAISLER_DDR2SPA  	= 0x02E,
+	GAISLER_AHBSTAT  	= 0x052,
+	GAISLER_FTMCTRL  	= 0x054,
+	ESA_MCTRL		= 0x00F,
+} amba_device_id_t;
+
+typedef struct {
+	/* Primary serial port location */
+	uintptr_t uart_base;
+	size_t uart_size;
+	int uart_irq;
+	/* Timers location */
+	uintptr_t timer_base;
+	size_t timer_size;
+	int timer_irq;
+} amba_info_t;
+
+typedef struct {
+	amba_vendor_id_t vendor_id;
+	amba_device_id_t device_id;
+	int irq;
+	int version;
+	uint32_t args[3];
+	struct {
+		uintptr_t start;
+		uintptr_t size;
+		bool prefetchable;
+		bool cacheable;
+	} bars[4];
+} amba_device_t;
+
+typedef struct {
+	unsigned int addr: 12;
+	unsigned int reserved: 2;
+	unsigned int prefetchable: 1;
+	unsigned int cacheable: 1;
+	unsigned int mask: 12;
+	unsigned int type: 4;
+} __attribute__((packed)) ambapp_bar_t;
+
+typedef struct {
+	unsigned int vendor_id: 8;
+	unsigned int device_id: 24;
+	unsigned int reserved: 2;
+	unsigned int version: 5;
+	unsigned int irq: 5;
+	uint32_t user_defined[3];
+	ambapp_bar_t bar[4];
+} __attribute__((packed)) ambapp_entry_t;
+
+amba_device_t amba_devices[AMBAPP_MAX_DEVICES];
+int amba_devices_found;
+uintptr_t amba_uart_base;
+
+void ambapp_scan(void);
+void ambapp_qemu_fake_scan(void);
+void ambapp_print_devices(void);
+amba_device_t *ambapp_lookup_first(amba_vendor_id_t, amba_device_id_t);
+
+#endif
+
+/** @}
+ */
Index: boot/arch/sparc32/include/arch.h
===================================================================
--- boot/arch/sparc32/include/arch.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/include/arch.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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.
+ */
+
+#ifndef BOOT_sparc32_ARCH_H
+#define BOOT_sparc32_ARCH_H
+
+#define	PTL0_ENTRIES	256
+#define	PTL0_SHIFT	24
+#define	PTL0_SIZE	(1 << 24)
+#define	PTL0_ENTRY_SIZE	4
+
+/* ASI assignments: */
+#define	ASI_CACHEMISS	0x01
+#define	ASI_CACHECTRL	0x02
+#define	ASI_MMUREGS	0x19
+#define	ASI_MMUBYPASS	0x1c
+
+/*
+ * Address where the boot stage image starts (beginning of usable physical
+ * memory).
+ */
+#define BOOT_BASE	0x40000000
+#define BOOT_OFFSET	(BOOT_BASE + 0xa00000)
+
+#define PA_OFFSET 0x40000000
+
+#ifndef __ASM__
+	#define PA2KA(addr)  (((uintptr_t) (addr)) + PA_OFFSET)
+#else
+	#define PA2KA(addr)  ((addr) + PA_OFFSET)
+#endif
+
+
+#endif
+
+/** @}
+ */
Index: boot/arch/sparc32/include/asm.h
===================================================================
--- boot/arch/sparc32/include/asm.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/include/asm.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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.
+ */
+
+#ifndef BOOT_sparc32_ASM_H_
+#define BOOT_sparc32_ASM_H_
+
+#include <typedefs.h>
+
+static inline uint32_t asi_u32_read(int asi, uintptr_t va)
+{
+	uint32_t v;
+
+	asm volatile (
+		"lda [%[va]] %[asi], %[v]\n"
+		: [v] "=r" (v)
+		: [va] "r" (va),
+		  [asi] "i" ((unsigned int) asi)
+	);
+	
+	return v;
+}
+
+static inline void asi_u32_write(int asi, uintptr_t va, uint32_t v)
+{
+	asm volatile (
+		"sta %[v], [%[va]] %[asi]\n"
+		:: [v] "r" (v),
+		   [va] "r" (va),
+		   [asi] "i" ((unsigned int) asi)
+		: "memory"
+	);
+}
+
+extern void jump_to_kernel(void *entry);
+
+#endif
Index: boot/arch/sparc32/include/main.h
===================================================================
--- boot/arch/sparc32/include/main.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/include/main.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32boot
+ * @{
+ */
+/** @file
+ * @brief Boot related declarations.
+ */
+
+#ifndef BOOT_sparc32_MAIN_H
+#define BOOT_sparc2_MAIN_H
+
+/** Address where characters to be printed are expected. */
+#define	APBUART_SCONS_THR	0x80000100
+#define	APBUART_SCONS_THR_MMU	0xb0000100
+
+extern void bootstrap(void);
+
+#endif
+
+/** @}
+ */
Index: boot/arch/sparc32/include/mm.h
===================================================================
--- boot/arch/sparc32/include/mm.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/include/mm.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32boot
+ * @{
+ */
+/** @file
+ * @brief Memory management used while booting the kernel.
+ *
+ * So called "section" paging is used while booting the kernel. The term
+ * "section" comes from the ARM architecture specification and stands for the
+ * following: one-level paging, 1MB sized pages, 4096 entries in the page
+ * table.
+ */
+
+#ifndef BOOT_sparc32__MM_H
+#define BOOT_sparc32__MM_H
+
+#include <typedefs.h>
+
+#define	PAGE_SIZE	(1 << 12)
+
+typedef struct {
+	uint32_t pa;
+	uint32_t size;
+	uint32_t va;
+	uint32_t cacheable;
+} section_mapping_t;
+
+typedef struct {
+	unsigned int ppn: 24;
+	unsigned int cacheable: 1;
+	unsigned int modified: 1;
+	unsigned int referenced: 1;
+	unsigned int acc: 3;
+	unsigned int et: 2;
+} __attribute__((packed)) pte_t;
+
+extern pte_t boot_pt[PTL0_ENTRIES];
+
+void mmu_init(void);
+
+#define	PTE_ET_DESCRIPTOR	1
+#define	PTE_ET_ENTRY		2
+#define	PTE_ACC_RWX		3
+#define	MMU_CONTROL_EN		(1 << 0)
+
+#endif
+
+/** @}
+ */
Index: boot/arch/sparc32/include/types.h
===================================================================
--- boot/arch/sparc32/include/types.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/include/types.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2006 Martin Decky
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32boot
+ * @{
+ */
+/** @file
+ * @brief Definitions of basic types like #uintptr_t.
+ */
+
+#ifndef BOOT_sparc32_TYPES_H
+#define BOOT_sparc32_TYPES_H
+
+#define TASKMAP_MAX_RECORDS        32
+#define BOOTINFO_TASK_NAME_BUFLEN  32
+
+typedef uint32_t size_t;
+typedef uint32_t uintptr_t;
+
+typedef uint32_t pfn_t;
+
+typedef struct {
+	/** Address where the task was placed. */
+	void *addr;
+	/** Size of the task's binary. */
+	size_t size;
+	/** Task name. */
+	char name[BOOTINFO_TASK_NAME_BUFLEN];
+} task_t;
+
+typedef struct {
+	size_t cnt;
+	task_t tasks[TASKMAP_MAX_RECORDS];
+} bootinfo_t;
+
+#endif
+
+/** @}
+ */
Index: boot/arch/sparc32/src/ambapp.c
===================================================================
--- boot/arch/sparc32/src/ambapp.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/src/ambapp.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32boot
+ * @{
+ */
+/** @file
+ * @brief Bootstrap.
+ */
+
+#include <arch/asm.h>
+#include <arch/common.h>
+#include <arch/arch.h>
+#include <arch/ambapp.h>
+#include <arch/mm.h>
+#include <arch/main.h>
+#include <arch/_components.h>
+#include <halt.h>
+#include <printf.h>
+#include <memstr.h>
+#include <version.h>
+#include <macros.h>
+#include <align.h>
+#include <str.h>
+#include <errno.h>
+
+static void ambapp_scan_area(uintptr_t, int);
+
+void ambapp_scan()
+{
+	/* Scan for AHB masters & slaves */
+	ambapp_scan_area(AMBAPP_AHBMASTER_AREA, 64);
+	ambapp_scan_area(AMBAPP_AHBSLAVE_AREA, 63);
+
+	/* Scan for APB slaves on APBMST */
+	amba_device_t *apbmst = ambapp_lookup_first(GAISLER, GAISLER_APBMST);
+	if (apbmst != NULL)
+		ambapp_scan_area(apbmst->bars[0].start, 16);
+
+	/* If we found nothing, fake device entries */
+	ambapp_qemu_fake_scan();
+}
+
+static void ambapp_scan_area(uintptr_t master_bar, int max_entries)
+{
+	ambapp_entry_t *entry = (ambapp_entry_t *) (master_bar | AMBAPP_CONF_AREA);
+
+	for (int i = 0; i < max_entries; i++) {
+		if (amba_devices_found == AMBAPP_MAX_DEVICES)
+			return;
+
+		if (entry->vendor_id == 0xff)
+			continue;
+
+		amba_device_t *device = &amba_devices[amba_devices_found];
+		device->vendor_id = (amba_vendor_id_t)entry->vendor_id;
+		device->device_id = (amba_device_id_t)entry->device_id;
+		device->version = entry->version;
+		device->irq = entry->irq;
+	
+		for (int bar = 0; bar < 4; bar++) {
+			device->bars[bar].start = entry->bar[bar].addr << 20;
+			device->bars[bar].size = entry->bar[bar].mask;
+			device->bars[bar].prefetchable = (bool)entry->bar[bar].prefetchable;
+			device->bars[bar].cacheable = (bool)entry->bar[bar].cacheable;
+		}
+
+		amba_devices_found++;
+	}
+}
+
+void ambapp_qemu_fake_scan()
+{
+	/* UART */
+	amba_devices[0].vendor_id = GAISLER;
+	amba_devices[0].device_id = GAISLER_APBUART;
+	amba_devices[0].version = 1;
+	amba_devices[0].irq = 2;
+	amba_devices[0].bars[0].start = 0x80000100;
+	amba_devices[0].bars[0].size = 0x100;
+
+	/* IRQMP */
+	amba_devices[1].vendor_id = GAISLER;
+	amba_devices[1].device_id = GAISLER_IRQMP;
+	amba_devices[1].version = 1;
+	amba_devices[1].irq = -1;
+	amba_devices[1].bars[0].start = 0x80000200;
+	amba_devices[1].bars[0].size = 0x100;
+
+	/* GPTIMER */
+	amba_devices[2].vendor_id = GAISLER;
+	amba_devices[2].device_id = GAISLER_GPTIMER;
+	amba_devices[2].version = 1;
+	amba_devices[2].irq = 8;
+	amba_devices[2].bars[0].start = 0x80000300;
+	amba_devices[2].bars[0].size = 0x100;
+
+	amba_devices_found = 3;
+}
+
+void ambapp_print_devices()
+{
+	printf("ABMA devices:\n");
+
+	for (int i = 0; i < amba_devices_found; i++) {
+		amba_device_t *dev = &amba_devices[i];
+		printf("<%1x:%03x> at 0x%08x, irq %d\n", dev->vendor_id, dev->device_id, dev->bars[0].start, dev->irq);
+	}
+}
+
+amba_device_t *ambapp_lookup_first(amba_vendor_id_t vendor, amba_device_id_t device)
+{
+	for (int i = 0; i < amba_devices_found; i++) {
+		if (amba_devices[i].vendor_id == vendor &&
+		    amba_devices[i].device_id == device)
+			return &amba_devices[i];
+	}
+
+	return NULL;
+}
Index: boot/arch/sparc32/src/asm.S
===================================================================
--- boot/arch/sparc32/src/asm.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/src/asm.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,56 @@
+#
+# Copyright (c) 2007 Michal Kebrt
+# 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.
+#
+
+#include <arch/arch.h>
+
+.section BOOTSTRAP
+
+.global start
+.global boot_pt
+.global boot_ctx_table
+.global boot_stack
+.global jump_to_kernel
+
+start:
+	b bootstrap
+	nop
+
+.section BOOTPT
+.align 4096
+boot_pt:
+	.space PTL0_ENTRIES * PTL0_ENTRY_SIZE
+boot_ctx_table:
+	.space 4
+.section BOOTSTACK
+	.space 4096
+boot_stack:
+
+jump_to_kernel:
+	set 0x80a00000, %l0
+	jmp %l0
+	nop
Index: boot/arch/sparc32/src/main.c
===================================================================
--- boot/arch/sparc32/src/main.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/src/main.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32boot
+ * @{
+ */
+/** @file
+ * @brief Bootstrap.
+ */
+
+#include <arch/asm.h>
+#include <arch/common.h>
+#include <arch/arch.h>
+#include <arch/ambapp.h>
+#include <arch/mm.h>
+#include <arch/main.h>
+#include <arch/_components.h>
+#include <halt.h>
+#include <printf.h>
+#include <memstr.h>
+#include <version.h>
+#include <macros.h>
+#include <align.h>
+#include <str.h>
+#include <errno.h>
+#include <inflate.h>
+
+#define TOP2ADDR(top)  (((void *) PA2KA(BOOT_OFFSET)) + (top))
+static bootinfo_t bootinfo;
+
+void bootstrap(void)
+{
+	/* Initialize AMBA P&P device list */
+	ambapp_scan();
+
+	/* Look up for UART */
+	amba_device_t *uart = ambapp_lookup_first(GAISLER, GAISLER_APBUART);
+	amba_uart_base = uart->bars[0].start;
+
+	/* Standard output is now initialized */
+	version_print();
+
+	for (size_t i = 0; i < COMPONENTS; i++) {
+		printf(" %p|%p: %s image (%u/%u bytes)\n", components[i].start,
+		    components[i].start, components[i].name, components[i].inflated,
+		    components[i].size);
+	}
+
+	ambapp_print_devices();
+
+	mmu_init();
+
+	void *dest[COMPONENTS];
+	size_t top = 0;
+	size_t cnt = 0;
+	bootinfo.cnt = 0;
+	for (size_t i = 0; i < min(COMPONENTS, TASKMAP_MAX_RECORDS); i++) {
+		top = ALIGN_UP(top, PAGE_SIZE);
+		
+		if (i > 0) {
+			bootinfo.tasks[bootinfo.cnt].addr = TOP2ADDR(top);
+			bootinfo.tasks[bootinfo.cnt].size = components[i].inflated;
+			
+			str_cpy(bootinfo.tasks[bootinfo.cnt].name,
+			    BOOTINFO_TASK_NAME_BUFLEN, components[i].name);
+			
+			bootinfo.cnt++;
+		}
+		
+		dest[i] = TOP2ADDR(top);
+
+		top += components[i].inflated;
+		cnt++;
+	}
+	
+	printf("\nInflating components ... ");
+	
+	for (size_t i = cnt; i > 0; i--) {
+		void *tail = components[i - 1].start + components[i - 1].size;
+		if (tail >= dest[i - 1]) {
+			printf("\n%s: Image too large to fit (%p >= %p), halting.\n",
+			    components[i].name, tail, dest[i - 1]);
+			for (;;);
+		}
+		
+		printf("%s ", components[i - 1].name);
+		
+		int err = inflate(components[i - 1].start, components[i - 1].size,
+		    dest[i - 1], components[i - 1].inflated);
+		if (err != EOK) {
+			printf("\n%s: Inflating error %d\n", components[i - 1].name, err);
+			for (;;);
+		}
+	}
+
+	printf("Booting the kernel ... \n");
+	jump_to_kernel((void *) PA2KA(BOOT_OFFSET));
+}
+
+/** @}
+ */
Index: boot/arch/sparc32/src/mm.c
===================================================================
--- boot/arch/sparc32/src/mm.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/src/mm.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32boot
+ * @{
+ */
+/** @file
+ * @brief Bootstrap.
+ */
+
+#include <arch/asm.h>
+#include <arch/common.h>
+#include <arch/arch.h>
+#include <arch/mm.h>
+#include <arch/main.h>
+#include <arch/_components.h>
+#include <halt.h>
+#include <printf.h>
+#include <memstr.h>
+#include <version.h>
+#include <macros.h>
+#include <align.h>
+#include <str.h>
+#include <errno.h>
+#include <inflate.h>
+
+#define	OFF2SEC(_addr)	((_addr) >> PTL0_SHIFT)
+#define	SEC2OFF(_sec)	((_sec) << PTL0_SHIFT)
+
+static section_mapping_t mappings[] = {
+	{ 0x40000000, 0x3fffffff, 0x40000000, 1 },
+	{ 0x40000000, 0x2fffffff, 0x80000000, 1 },
+	{ 0x80000000, 0x0fffffff, 0xb0000000, 0 },
+	{ 0, 0, 0, 0 },
+};
+
+extern uintptr_t boot_ctx_table;
+
+static void mmu_enable()
+{
+	boot_ctx_table = ((uintptr_t)&boot_pt[0] >> 4) | PTE_ET_DESCRIPTOR;
+
+	/* Set Context Table Pointer register */
+	asi_u32_write(ASI_MMUREGS, 0x100, ((uint32_t)&boot_ctx_table) >> 4);
+
+	/* Select context 0 */
+	asi_u32_write(ASI_MMUREGS, 0x200, 0);
+
+	/* Enable MMU */
+	uint32_t cr = asi_u32_read(ASI_MMUREGS, 0x000);
+	cr |= 1;
+	asi_u32_write(ASI_MMUREGS, 0x000, cr);
+}
+
+static void mmu_disable()
+{
+	uint32_t cr = asi_u32_read(ASI_MMUREGS, 0x000);
+	cr &= ~1;
+	asi_u32_write(ASI_MMUREGS, 0x000, cr);
+}
+
+void mmu_init()
+{
+	mmu_disable();
+
+	for (int i = 0; mappings[i].size != 0; i++) {
+		int ptr = 0;
+		for (uint32_t sec = OFF2SEC(mappings[i].va); 
+		     sec < OFF2SEC(mappings[i].va + mappings[i].size);
+		     sec++) {
+			boot_pt[sec].ppn = ((mappings[i].pa + SEC2OFF(ptr++)) >> 12) & 0xffffff;
+			boot_pt[sec].cacheable = mappings[i].cacheable;
+			boot_pt[sec].acc = PTE_ACC_RWX;
+			boot_pt[sec].et = PTE_ET_ENTRY;
+		}
+	}
+
+	mmu_enable();
+}
Index: boot/arch/sparc32/src/putchar.c
===================================================================
--- boot/arch/sparc32/src/putchar.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ boot/arch/sparc32/src/putchar.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007 Michal Kebrt
+ * Copyright (c) 2009 Vineeth Pillai
+ * Copyright (c) 2010 Jiri Svoboda
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32boot
+ * @{
+ */
+/** @file
+ * @brief bootloader output logic
+ */
+
+#include <typedefs.h>
+#include <arch/asm.h>
+#include <arch/arch.h>
+#include <arch/main.h>
+#include <arch/mm.h>
+#include <putchar.h>
+#include <str.h>
+
+/** Send a byte to the LEON3 serial console.
+ *
+ * @param byte		Byte to send.
+ */
+static void scons_sendb(uint8_t byte)
+{
+	asi_u32_write(ASI_MMUBYPASS, APBUART_SCONS_THR, byte);
+}
+
+/** Display a character
+ *
+ * @param ch	Character to display
+ */
+void putchar(const wchar_t ch)
+{
+	if (ch == '\n')
+		scons_sendb('\r');
+
+	if (ascii_check(ch))
+		scons_sendb((uint8_t) ch);
+	else
+		scons_sendb(U_SPECIAL);
+}
+
+/** @}
+ */
Index: defaults/sparc32/Makefile.config
===================================================================
--- defaults/sparc32/Makefile.config	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ defaults/sparc32/Makefile.config	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,60 @@
+# Platform
+PLATFORM = sparc32
+
+# Ramdisk format
+RDFMT = ext4fs
+
+# Compiler
+COMPILER = gcc_cross
+
+# Support for SMP
+CONFIG_SMP = n
+
+# Debug build
+CONFIG_DEBUG = y
+
+# Deadlock detection support for spinlocks
+CONFIG_DEBUG_SPINLOCK = y
+
+# Lazy FPU context switching
+CONFIG_FPU_LAZY = y
+
+# Use TSB
+CONFIG_TSB = y
+
+# Virtually indexed D-cache support
+CONFIG_VIRT_IDX_DCACHE = y
+
+# Support for userspace debuggers
+CONFIG_UDEBUG = y
+
+# Kernel console support
+CONFIG_KCONSOLE = y
+
+# Kernel symbol information
+CONFIG_SYMTAB = y
+
+# Detailed kernel logging
+CONFIG_LOG = n
+
+# Kernel function tracing
+CONFIG_TRACE = n
+
+# Compile kernel tests
+CONFIG_TEST = y
+
+# Input device class
+CONFIG_HID_IN = generic
+
+# Output device class
+CONFIG_HID_OUT = generic
+
+# Start AP processors by the loader
+CONFIG_AP = y
+
+# Load disk drivers on startup
+CONFIG_START_BD = n
+
+# Mount /data on startup
+CONFIG_MOUNT_DATA = n
+
Index: defaults/sparc32/leon3/Makefile.config
===================================================================
--- defaults/sparc32/leon3/Makefile.config	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ defaults/sparc32/leon3/Makefile.config	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,8 @@
+# Machine type
+MACHINE = leon3
+
+# CPU type
+PROCESSOR = leon3
+
+# Barebone build with essential binaries only
+CONFIG_BAREBONE = y
Index: defaults/sparc32/output
===================================================================
--- defaults/sparc32/output	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ defaults/sparc32/output	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,1 @@
+image.boot
Index: kernel/arch/sparc32/Makefile.inc
===================================================================
--- kernel/arch/sparc32/Makefile.inc	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/Makefile.inc	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,63 @@
+#
+# 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.
+#
+
+BFD = binary
+
+ifeq ($(COMPILER),gcc_cross)
+	ifeq ($(CROSS_TARGET),arm32)
+		ATSIGN = %
+	endif
+	
+	ifeq ($(CROSS_TARGET),mips32)
+		GCC_CFLAGS += -mno-abicalls
+	endif
+endif
+
+BITS = 32
+ENDIANESS = LE
+
+ARCH_SOURCES = \
+	arch/$(KARCH)/src/start.S \
+	arch/$(KARCH)/src/trap_table.S \
+	arch/$(KARCH)/src/context.S \
+	arch/$(KARCH)/src/debug/stacktrace.c \
+	arch/$(KARCH)/src/proc/scheduler.c \
+	arch/$(KARCH)/src/proc/task.c \
+	arch/$(KARCH)/src/proc/thread.c \
+	arch/$(KARCH)/src/sparc32.c \
+	arch/$(KARCH)/src/userspace.c \
+	arch/$(KARCH)/src/exception.c \
+	arch/$(KARCH)/src/cpu/cpu.c \
+	arch/$(KARCH)/src/ddi/ddi.c \
+	arch/$(KARCH)/src/smp/smp.c \
+	arch/$(KARCH)/src/smp/ipi.c \
+	arch/$(KARCH)/src/mm/km.c \
+	arch/$(KARCH)/src/mm/as.c \
+	arch/$(KARCH)/src/mm/frame.c \
+	arch/$(KARCH)/src/mm/page.c \
+	arch/$(KARCH)/src/mm/tlb.c \
Index: kernel/arch/sparc32/_link.ld.in
===================================================================
--- kernel/arch/sparc32/_link.ld.in	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/_link.ld.in	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,45 @@
+#define	KERNEL_LOAD_ADDRESS 0x80a00000
+
+ENTRY(kernel_image_start)
+
+SECTIONS {
+	. = KERNEL_LOAD_ADDRESS;
+	.text : {
+		ktext_start = .;
+		*(.text);
+		ktext_end = .;
+	}
+	.data : {
+		kdata_start = .;
+		*(.data);                       /* initialized data */
+		. = ALIGN(8);
+		hardcoded_ktext_size = .;
+		LONG(ktext_end - ktext_start);
+		hardcoded_kdata_size = .;
+		LONG(kdata_end - kdata_start);
+		hardcoded_load_address = .;
+		LONG(KERNEL_LOAD_ADDRESS);
+		*(.bss);                        /* uninitialized static variables */
+		*(COMMON);                      /* global variables */
+		
+		*(.rodata*);
+		*(.sdata);
+		*(.reginfo);
+		. = ALIGN(8);
+		symbol_table = .;
+		*(symtab.*);
+	}
+	.sbss : {
+		*(.sbss);
+		*(.scommon);
+	}
+	
+	kdata_end = .;
+	
+	/DISCARD/ : {
+		*(.mdebug*);
+		*(.pdr);
+		*(.comment);
+		*(.note);
+	}
+}
Index: kernel/arch/sparc32/include/arch/ambapp.h
===================================================================
--- kernel/arch/sparc32/include/arch/ambapp.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/ambapp.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32_AMBAPP_H_
+#define KERN_sparc32_AMBAPP_H_
+
+typedef struct
+{
+	/* Primary serial port location */
+	uintptr_t uart_base;
+	size_t uart_size;
+	int uart_irq;
+	/* Timers location */
+	uintptr_t timer_base;
+	size_t timer_size;
+	int timer_irq;
+} ambapp_info_t;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/arch.h
===================================================================
--- kernel/arch/sparc32/include/arch/arch.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/arch.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup sparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32_ARCH_H_
+#define KERN_sparc32_ARCH_H_
+
+#ifndef __ASM__
+
+void arch_pre_main(void);
+
+#endif
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/asm.h
===================================================================
--- kernel/arch/sparc32/include/arch/asm.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/asm.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,216 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup sparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32_ASM_H_
+#define KERN_sparc32_ASM_H_
+
+#include <typedefs.h>
+#include <config.h>
+#include <trace.h>
+#include <arch/register.h>
+
+NO_TRACE static inline void asm_delay_loop(uint32_t usec)
+{
+}
+
+NO_TRACE static inline __attribute__((noreturn)) void cpu_halt(void)
+{
+	/* On real hardware this should stop processing further
+	   instructions on the CPU (and possibly putting it into
+	   low-power mode) without any possibility of exitting
+	   this function. */
+	
+	while (true);
+}
+
+NO_TRACE static inline void cpu_sleep(void)
+{
+	/* On real hardware this should put the CPU into low-power
+	   mode. However, the CPU is free to continue processing
+	   futher instructions any time. The CPU also wakes up
+	   upon an interrupt. */
+}
+
+NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t val)
+{
+}
+
+/** Word to port
+ *
+ * Output word to port
+ *
+ * @param port Port to write to
+ * @param val Value to write
+ *
+ */
+NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t val)
+{
+}
+
+/** Double word to port
+ *
+ * Output double word to port
+ *
+ * @param port Port to write to
+ * @param val Value to write
+ *
+ */
+NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t val)
+{
+}
+
+/** Byte from port
+ *
+ * Get byte from port
+ *
+ * @param port Port to read from
+ * @return Value read
+ *
+ */
+NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
+{
+	return 0;
+}
+
+/** Word from port
+ *
+ * Get word from port
+ *
+ * @param port Port to read from
+ * @return Value read
+ *
+ */
+NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
+{
+	return 0;
+}
+
+/** Double word from port
+ *
+ * Get double word from port
+ *
+ * @param port Port to read from
+ * @return Value read
+ *
+ */
+NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
+{
+	return 0;
+}
+
+NO_TRACE static inline uint32_t psr_read()
+{
+	uint32_t v;
+
+	asm volatile (
+		"mov %%psr, %[v]\n"
+		: [v] "=r" (v)
+	);
+
+	return v;
+}
+
+NO_TRACE static inline void psr_write(uint32_t psr)
+{
+	asm volatile (
+		"mov %[v], %%psr\n"
+		:: [v] "r" (psr)
+	);
+}
+
+NO_TRACE static inline ipl_t interrupts_enable(void)
+{
+	ipl_t pil;
+
+	psr_reg_t psr;
+	psr.value = psr_read();
+	pil = psr.pil;
+	psr.pil = 0xf;
+	psr_write(psr.value);
+
+	return pil;
+}
+
+NO_TRACE static inline ipl_t interrupts_disable(void)
+{
+	ipl_t pil;
+
+	psr_reg_t psr;
+	psr.value = psr_read();
+	pil = psr.pil;
+	psr.pil = 0;
+	psr_write(psr.value);
+
+	return pil;
+}
+
+NO_TRACE static inline void interrupts_restore(ipl_t ipl)
+{
+	psr_reg_t psr;
+	psr.value = psr_read();
+	psr.pil = ipl;
+	psr_write(psr.value);
+}
+
+NO_TRACE static inline ipl_t interrupts_read(void)
+{
+	psr_reg_t psr;
+	psr.value = psr_read();
+	return psr.pil;
+}
+
+NO_TRACE static inline bool interrupts_disabled(void)
+{
+	psr_reg_t psr;
+	psr.value = psr_read();
+	return psr.pil == 0;
+}
+
+NO_TRACE static inline uintptr_t get_stack_base(void)
+{
+	uintptr_t v;
+	
+	asm volatile (
+		"and %%sp, %[size], %[v]\n" 
+		: [v] "=r" (v)
+		: [size] "r" (~(STACK_SIZE - 1))
+	);
+	
+	return v;
+}
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/atomic.h
===================================================================
--- kernel/arch/sparc32/include/arch/atomic.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/atomic.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_ATOMIC_H_
+#define KERN_abs32le_ATOMIC_H_
+
+#include <typedefs.h>
+#include <arch/barrier.h>
+#include <preemption.h>
+#include <verify.h>
+#include <trace.h>
+
+NO_TRACE ATOMIC static inline void atomic_inc(atomic_t *val)
+    WRITES(&val->count)
+    REQUIRES_EXTENT_MUTABLE(val)
+    REQUIRES(val->count < ATOMIC_COUNT_MAX)
+{
+	/* On real hardware the increment has to be done
+	   as an atomic action. */
+	
+	val->count++;
+}
+
+NO_TRACE ATOMIC static inline void atomic_dec(atomic_t *val)
+    WRITES(&val->count)
+    REQUIRES_EXTENT_MUTABLE(val)
+    REQUIRES(val->count > ATOMIC_COUNT_MIN)
+{
+	/* On real hardware the decrement has to be done
+	   as an atomic action. */
+	
+	val->count--;
+}
+
+NO_TRACE ATOMIC static inline atomic_count_t atomic_postinc(atomic_t *val)
+    WRITES(&val->count)
+    REQUIRES_EXTENT_MUTABLE(val)
+    REQUIRES(val->count < ATOMIC_COUNT_MAX)
+{
+	/* On real hardware both the storing of the previous
+	   value and the increment have to be done as a single
+	   atomic action. */
+	
+	atomic_count_t prev = val->count;
+	
+	val->count++;
+	return prev;
+}
+
+NO_TRACE ATOMIC static inline atomic_count_t atomic_postdec(atomic_t *val)
+    WRITES(&val->count)
+    REQUIRES_EXTENT_MUTABLE(val)
+    REQUIRES(val->count > ATOMIC_COUNT_MIN)
+{
+	/* On real hardware both the storing of the previous
+	   value and the decrement have to be done as a single
+	   atomic action. */
+	
+	atomic_count_t prev = val->count;
+	
+	val->count--;
+	return prev;
+}
+
+#define atomic_preinc(val)  (atomic_postinc(val) + 1)
+#define atomic_predec(val)  (atomic_postdec(val) - 1)
+
+NO_TRACE ATOMIC static inline atomic_count_t test_and_set(atomic_t *val)
+    WRITES(&val->count)
+    REQUIRES_EXTENT_MUTABLE(val)
+{
+	/* On real hardware the retrieving of the original
+	   value and storing 1 have to be done as a single
+	   atomic action. */
+	
+	atomic_count_t prev = val->count;
+	val->count = 1;
+	return prev;
+}
+
+NO_TRACE static inline void atomic_lock_arch(atomic_t *val)
+    WRITES(&val->count)
+    REQUIRES_EXTENT_MUTABLE(val)
+{
+	do {
+		while (val->count);
+	} while (test_and_set(val));
+}
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/barrier.h
===================================================================
--- kernel/arch/sparc32/include/arch/barrier.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/barrier.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,55 @@
+/*
+ * 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 abs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_BARRIER_H_
+#define KERN_abs32le_BARRIER_H_
+
+/*
+ * Provisions are made to prevent compiler from reordering instructions itself.
+ */
+
+#define CS_ENTER_BARRIER()
+#define CS_LEAVE_BARRIER()
+
+#define memory_barrier()
+#define read_barrier()
+#define write_barrier()
+
+#define smc_coherence(addr)
+#define smc_coherence_block(addr, size)
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/context.h
===================================================================
--- kernel/arch/sparc32/include/arch/context.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/context.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2005 Jakub Jermar
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32_CONTEXT_H_
+#define KERN_sparc32_CONTEXT_H_
+
+#include <arch/stack.h>
+#include <typedefs.h>
+#include <align.h>
+
+#define SP_DELTA  (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
+
+#define context_set(c, _pc, stack, size) \
+	do { \
+		(c)->pc = ((uintptr_t) _pc) - 4; \
+		(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), \
+		    STACK_ALIGNMENT) - (SP_DELTA); \
+		(c)->fp = (c)->fp; \
+	} while (0)
+
+/*
+ * Save only registers that must be preserved across
+ * function calls.
+ */
+typedef struct {
+	uintptr_t sp;		/* %o6 */
+	uintptr_t pc;		/* %o7 */
+	uint32_t i0;
+	uint32_t i1;
+	uint32_t i2;
+	uint32_t i3;
+	uint32_t i4;
+	uint32_t i5;
+	uintptr_t fp;		/* %i6 */
+	uintptr_t i7;
+	uint32_t l0;
+	uint32_t l1;
+	uint32_t l2;
+	uint32_t l3;
+	uint32_t l4;
+	uint32_t l5;
+	uint32_t l6;
+	uint32_t l7;
+	ipl_t ipl;
+} context_t;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/context_offset.h
===================================================================
--- kernel/arch/sparc32/include/arch/context_offset.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/context_offset.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2005 Jakub Jermar
+ * Copyright (c) 2013 Jakub Klama
+ * 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.
+ */
+
+#ifndef KERN_sparc32_CONTEXT_OFFSET_H_
+#define KERN_sparc32_CONTEXT_OFFSET_H_
+
+#define OFFSET_SP       0
+#define OFFSET_PC       4
+#define OFFSET_I0       8
+#define OFFSET_I1       12
+#define OFFSET_I2       16
+#define OFFSET_I3       20
+#define OFFSET_I4       24
+#define OFFSET_I5	28
+#define OFFSET_FP       32
+#define OFFSET_I7       36
+#define OFFSET_L0       40
+#define OFFSET_L1       44
+#define OFFSET_L2       48
+#define OFFSET_L3       52
+#define OFFSET_L4       56
+#define OFFSET_L5       60
+#define OFFSET_L6       64
+#define OFFSET_L7       68
+
+#ifndef KERNEL
+# define OFFSET_TP      72
+#endif
+#ifdef __ASM__
+
+.macro CONTEXT_SAVE_ARCH_CORE ctx:req
+	st %sp, [\ctx + OFFSET_SP]
+	st %o7, [\ctx + OFFSET_PC]
+	st %i0, [\ctx + OFFSET_I0]
+	st %i1, [\ctx + OFFSET_I1]
+	st %i2, [\ctx + OFFSET_I2]
+	st %i3, [\ctx + OFFSET_I3]
+	st %i4, [\ctx + OFFSET_I4]
+	st %i5, [\ctx + OFFSET_I5]
+	st %fp, [\ctx + OFFSET_FP]
+	st %i7, [\ctx + OFFSET_I7]
+	st %l0, [\ctx + OFFSET_L0]
+	st %l1, [\ctx + OFFSET_L1]
+	st %l2, [\ctx + OFFSET_L2]
+	st %l3, [\ctx + OFFSET_L3]
+	st %l4, [\ctx + OFFSET_L4]
+	st %l5, [\ctx + OFFSET_L5]
+	st %l6, [\ctx + OFFSET_L6]
+	st %l7, [\ctx + OFFSET_L7]
+#ifndef KERNEL
+	st %g7, [\ctx + OFFSET_TP]
+#endif
+.endm
+
+.macro CONTEXT_RESTORE_ARCH_CORE ctx:req
+	ld [\ctx + OFFSET_SP], %sp
+	ld [\ctx + OFFSET_PC], %o7
+	ld [\ctx + OFFSET_I0], %i0
+	ld [\ctx + OFFSET_I1], %i1
+	ld [\ctx + OFFSET_I2], %i2
+	ld [\ctx + OFFSET_I3], %i3
+	ld [\ctx + OFFSET_I4], %i4
+	ld [\ctx + OFFSET_I5], %i5
+	ld [\ctx + OFFSET_FP], %fp
+	ld [\ctx + OFFSET_I7], %i7
+	ld [\ctx + OFFSET_L0], %l0
+	ld [\ctx + OFFSET_L1], %l1
+	ld [\ctx + OFFSET_L2], %l2
+	ld [\ctx + OFFSET_L3], %l3
+	ld [\ctx + OFFSET_L4], %l4
+	ld [\ctx + OFFSET_L5], %l5
+	ld [\ctx + OFFSET_L6], %l6
+	ld [\ctx + OFFSET_L7], %l7
+#ifndef KERNEL
+	ld [\ctx + OFFSET_TP], %g7
+#endif
+.endm
+
+#endif /* __ASM__ */
+
+#endif
Index: kernel/arch/sparc32/include/arch/cpu.h
===================================================================
--- kernel/arch/sparc32/include/arch/cpu.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/cpu.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_CPU_H_
+#define KERN_abs32le_CPU_H_
+
+/*
+ * On real hardware this structure stores
+ * information specific to the current
+ * CPU model.
+ */
+typedef struct {
+} cpu_arch_t;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/cycle.h
===================================================================
--- kernel/arch/sparc32/include/arch/cycle.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/cycle.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_CYCLE_H_
+#define KERN_abs32le_CYCLE_H_
+
+#include <trace.h>
+
+NO_TRACE static inline uint64_t get_cycle(void)
+{
+	return 0;
+}
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/elf.h
===================================================================
--- kernel/arch/sparc32/include/arch/elf.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/elf.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_ELF_H_
+#define KERN_abs32le_ELF_H_
+
+#define ELF_MACHINE        EM_NO
+#define ELF_DATA_ENCODING  ELFDATA2LSB
+#define ELF_CLASS          ELFCLASS32
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/exception.h
===================================================================
--- kernel/arch/sparc32/include/arch/exception.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/exception.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2005 Jakub Jermar
+ * Copyright (c) 2013 Jakub Klama
+ * 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
+ */
+
+#ifndef KERN_sparc32_EXCEPTION_H_
+#define KERN_sparc32_EXCEPTION_H_
+
+#define TT_INSTRUCTION_ACCESS_EXCEPTION		0x01
+#define TT_INSTRUCTION_ACCESS_MMU_MISS		0x3c
+#define TT_INSTRUCTION_ACCESS_ERROR		0x21
+#define TT_ILLEGAL_INSTRUCTION			0x02
+#define TT_PRIVILEGED_INSTRUCTION		0x03
+#define TT_FP_DISABLED				0x08
+#define TT_DIVISION_BY_ZERO			0x2a
+#define TT_DATA_ACCESS_EXCEPTION		0x09
+#define TT_DATA_ACCESS_MMU_MISS			0x2c
+#define TT_DATA_ACCESS_ERROR			0x29
+#define TT_MEM_ADDRESS_NOT_ALIGNED		0x07
+
+#ifndef __ASM__
+
+/*#include <arch/interrupt.h>*/
+
+extern void instruction_access_exception(int n, istate_t *istate);
+extern void instruction_access_error(int n, istate_t *istate);
+extern void illegal_instruction(int n, istate_t *istate);
+extern void privileged_instruction(int n, istate_t *istate);
+extern void fp_disabled(int n, istate_t *istate);
+extern void division_by_zero(int n, istate_t *istate);
+extern void data_access_exception(int n, istate_t *istate);
+extern void data_access_error(int n, istate_t *istate);
+extern void mem_address_not_aligned(int n, istate_t *istate);
+
+#endif /* !__ASM__ */
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/faddr.h
===================================================================
--- kernel/arch/sparc32/include/arch/faddr.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/faddr.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_FADDR_H_
+#define KERN_abs32le_FADDR_H_
+
+#include <typedefs.h>
+
+#define FADDR(fptr)  ((uintptr_t) (fptr))
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/fpu_context.h
===================================================================
--- kernel/arch/sparc32/include/arch/fpu_context.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/fpu_context.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_FPU_CONTEXT_H_
+#define KERN_abs32le_FPU_CONTEXT_H_
+
+#include <typedefs.h>
+
+#define FPU_CONTEXT_ALIGN  16
+
+/*
+ * On real hardware this stores the FPU registers
+ * which are part of the CPU context.
+ */
+typedef struct {
+} fpu_context_t;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/interrupt.h
===================================================================
--- kernel/arch/sparc32/include/arch/interrupt.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/interrupt.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32leinterrupt
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_INTERRUPT_H_
+#define KERN_abs32le_INTERRUPT_H_
+
+#include <typedefs.h>
+#include <arch/istate.h>
+
+#define IVT_ITEMS  0
+#define IVT_FIRST  0
+
+#define VECTOR_TLB_SHOOTDOWN_IPI  0
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/istate.h
===================================================================
--- kernel/arch/sparc32/include/arch/istate.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/istate.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32leinterrupt
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_ISTATE_H_
+#define KERN_abs32le_ISTATE_H_
+
+#include <trace.h>
+
+#ifdef KERNEL
+
+#include <verify.h>
+
+#else /* KERNEL */
+
+#define REQUIRES_EXTENT_MUTABLE(arg)
+#define WRITES(arg)
+
+#endif /* KERNEL */
+
+/*
+ * On real hardware this stores the registers which
+ * need to be preserved during interupts.
+ */
+typedef struct istate {
+	uintptr_t ip;
+	uintptr_t fp;
+	uint32_t stack[];
+} istate_t;
+
+NO_TRACE static inline int istate_from_uspace(istate_t *istate)
+    REQUIRES_EXTENT_MUTABLE(istate)
+{
+	/* On real hardware this checks whether the interrupted
+	   context originated from user space. */
+	
+	return !(istate->ip & UINT32_C(0x80000000));
+}
+
+NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
+    uintptr_t retaddr)
+    WRITES(&istate->ip)
+{
+	/* On real hardware this sets the instruction pointer. */
+	
+	istate->ip = retaddr;
+}
+
+NO_TRACE static inline uintptr_t istate_get_pc(istate_t *istate)
+    REQUIRES_EXTENT_MUTABLE(istate)
+{
+	/* On real hardware this returns the instruction pointer. */
+	
+	return istate->ip;
+}
+
+NO_TRACE static inline uintptr_t istate_get_fp(istate_t *istate)
+    REQUIRES_EXTENT_MUTABLE(istate)
+{
+	/* On real hardware this returns the frame pointer. */
+	
+	return istate->fp;
+}
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/mm/as.h
===================================================================
--- kernel/arch/sparc32/include/arch/mm/as.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/mm/as.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32lemm
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_AS_H_
+#define KERN_abs32le_AS_H_
+
+#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
+
+#define KERNEL_ADDRESS_SPACE_START_ARCH  UINT32_C(0x80000000)
+#define KERNEL_ADDRESS_SPACE_END_ARCH    UINT32_C(0xffffffff)
+#define USER_ADDRESS_SPACE_START_ARCH    UINT32_C(0x00000000)
+#define USER_ADDRESS_SPACE_END_ARCH      UINT32_C(0x7fffffff)
+
+typedef struct {
+} as_arch_t;
+
+#include <genarch/mm/as_pt.h>
+
+#define as_constructor_arch(as, flags)  (as != as)
+#define as_destructor_arch(as)          (as != as)
+#define as_create_arch(as, flags)       (as != as)
+#define as_install_arch(as)
+#define as_deinstall_arch(as)
+#define as_invalidate_translation_cache(as, page, cnt)
+
+extern void as_arch_init(void);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/mm/asid.h
===================================================================
--- kernel/arch/sparc32/include/arch/mm/asid.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/mm/asid.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abc32lemm
+ * @{
+ */
+
+#ifndef KERN_abs32le_ASID_H_
+#define KERN_abs32le_ASID_H_
+
+#include <typedefs.h>
+
+typedef uint32_t asid_t;
+
+#define ASID_MAX_ARCH  3
+
+#define asid_get()      (ASID_START + 1)
+#define asid_put(asid)
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/mm/frame.h
===================================================================
--- kernel/arch/sparc32/include/arch/mm/frame.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/mm/frame.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32lemm
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_FRAME_H_
+#define KERN_abs32le_FRAME_H_
+
+#define FRAME_WIDTH  12  /* 4K */
+#define FRAME_SIZE   (1 << FRAME_WIDTH)
+
+#include <typedefs.h>
+
+#define	BOOT_PT_ADDRESS		0x40008000
+#define	BOOT_PT_START_FRAME	(BOOT_PT_ADDRESS >> FRAME_WIDTH)
+#define	BOOT_PT_SIZE_FRAMES	1
+
+extern void frame_low_arch_init(void);
+extern void frame_high_arch_init(void);
+extern void physmem_print(void);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/mm/km.h
===================================================================
--- kernel/arch/sparc32/include/arch/mm/km.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/mm/km.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 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 sparc32mm
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32_KM_H_
+#define KERN_sparc32_KM_H_
+
+#include <typedefs.h>
+
+#define	KM_SPARC32_IDENTITY_START	UINT32_C(0x80000000)
+#define	KM_SPARC32_IDENTITY_SIZE	UINT32_C(0x70000000)
+
+#define	KM_SPARC32_NON_IDENTITY_START	UINT32_C(0xf0000000)
+#define	KM_SPARC32_NON_IDENTITY_SIZE	UINT32_C(0xff000000)
+
+extern void km_identity_arch_init(void);
+extern void km_non_identity_arch_init(void);
+extern bool km_is_non_identity_arch(uintptr_t);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/mm/page.h
===================================================================
--- kernel/arch/sparc32/include/arch/mm/page.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/mm/page.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,198 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32lemm
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_PAGE_H_
+#define KERN_abs32le_PAGE_H_
+
+#include <arch/mm/frame.h>
+#include <trace.h>
+
+#define PAGE_WIDTH  FRAME_WIDTH
+#define PAGE_SIZE   FRAME_SIZE
+
+#define KA2PA(x)  (((uintptr_t) (x)) - UINT32_C(0x40000000))
+#define PA2KA(x)  (((uintptr_t) (x)) + UINT32_C(0x40000000))
+
+/*
+ * This is an example of 2-level page tables (PTL1 and PTL2 are left out)
+ * on top of the generic 4-level page table interface.
+ */
+
+/* Number of entries in each level. */
+#define PTL0_ENTRIES_ARCH  1024
+#define PTL1_ENTRIES_ARCH  0
+#define PTL2_ENTRIES_ARCH  0
+#define PTL3_ENTRIES_ARCH  1024
+
+/* Page table sizes for each level. */
+#define PTL0_SIZE_ARCH  ONE_FRAME
+#define PTL1_SIZE_ARCH  0
+#define PTL2_SIZE_ARCH  0
+#define PTL3_SIZE_ARCH  ONE_FRAME
+
+/* Macros calculating indices for each level. */
+#define PTL0_INDEX_ARCH(vaddr)  (((vaddr) >> 22) & 0x3ffU)
+#define PTL1_INDEX_ARCH(vaddr)  0
+#define PTL2_INDEX_ARCH(vaddr)  0
+#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 12) & 0x3ffU)
+
+/* Get PTE address accessors for each level. */
+#define GET_PTL1_ADDRESS_ARCH(ptl0, i) \
+	((pte_t *) ((((pte_t *) (ptl0))[(i)].frame_address) << 12))
+#define GET_PTL2_ADDRESS_ARCH(ptl1, i) \
+	(ptl1)
+#define GET_PTL3_ADDRESS_ARCH(ptl2, i) \
+	(ptl2)
+#define GET_FRAME_ADDRESS_ARCH(ptl3, i) \
+	((uintptr_t) ((((pte_t *) (ptl3))[(i)].frame_address) << 12))
+
+/* Set PTE address accessors for each level. */
+#define SET_PTL0_ADDRESS_ARCH(ptl0)
+#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) \
+	(((pte_t *) (ptl0))[(i)].frame_address = (a) >> 12)
+#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
+#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
+#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) \
+	(((pte_t *) (ptl3))[(i)].frame_address = (a) >> 12)
+
+/* Get PTE flags accessors for each level. */
+#define GET_PTL1_FLAGS_ARCH(ptl0, i) \
+	get_pt_flags((pte_t *) (ptl0), (size_t) (i))
+#define GET_PTL2_FLAGS_ARCH(ptl1, i) \
+	PAGE_PRESENT
+#define GET_PTL3_FLAGS_ARCH(ptl2, i) \
+	PAGE_PRESENT
+#define GET_FRAME_FLAGS_ARCH(ptl3, i) \
+	get_pt_flags((pte_t *) (ptl3), (size_t) (i))
+
+/* Set PTE flags accessors for each level. */
+#define SET_PTL1_FLAGS_ARCH(ptl0, i, x)	\
+	set_pt_flags((pte_t *) (ptl0), (size_t) (i), (x))
+#define SET_PTL2_FLAGS_ARCH(ptl1, i, x)
+#define SET_PTL3_FLAGS_ARCH(ptl2, i, x)
+#define SET_FRAME_FLAGS_ARCH(ptl3, i, x) \
+	set_pt_flags((pte_t *) (ptl3), (size_t) (i), (x))
+
+/* Set PTE present bit accessors for each level. */
+#define SET_PTL1_PRESENT_ARCH(ptl0, i)	\
+	set_pt_present((pte_t *) (ptl0), (size_t) (i))
+#define SET_PTL2_PRESENT_ARCH(ptl1, i)
+#define SET_PTL3_PRESENT_ARCH(ptl2, i)
+#define SET_FRAME_PRESENT_ARCH(ptl3, i) \
+	set_pt_present((pte_t *) (ptl3), (size_t) (i))
+
+/* Macros for querying the last level entries. */
+#define PTE_VALID_ARCH(p) \
+	(*((uint32_t *) (p)) != 0)
+#define PTE_PRESENT_ARCH(p) \
+	((p)->present != 0)
+#define PTE_GET_FRAME_ARCH(p) \
+	((p)->frame_address << FRAME_WIDTH)
+#define PTE_WRITABLE_ARCH(p) \
+	((p)->writeable != 0)
+#define PTE_EXECUTABLE_ARCH(p)  1
+
+#include <mm/mm.h>
+#include <arch/interrupt.h>
+#include <typedefs.h>
+
+/** Page Table Entry. */
+typedef struct {
+	unsigned int present : 1;
+	unsigned int writeable : 1;
+	unsigned int uaccessible : 1;
+	unsigned int page_write_through : 1;
+	unsigned int page_cache_disable : 1;
+	unsigned int accessed : 1;
+	unsigned int dirty : 1;
+	unsigned int pat : 1;
+	unsigned int global : 1;
+	
+	/** Valid content even if the present bit is not set. */
+	unsigned int soft_valid : 1;
+	unsigned int avl : 2;
+	unsigned int frame_address : 20;
+} __attribute__((packed)) pte_t;
+
+NO_TRACE static inline unsigned int get_pt_flags(pte_t *pt, size_t i)
+    REQUIRES_ARRAY_MUTABLE(pt, PTL0_ENTRIES_ARCH)
+{
+	pte_t *p = &pt[i];
+	
+	return (
+	    ((unsigned int) (!p->page_cache_disable) << PAGE_CACHEABLE_SHIFT) |
+	    ((unsigned int) (!p->present) << PAGE_PRESENT_SHIFT) |
+	    ((unsigned int) p->uaccessible << PAGE_USER_SHIFT) |
+	    (1 << PAGE_READ_SHIFT) |
+	    ((unsigned int) p->writeable << PAGE_WRITE_SHIFT) |
+	    (1 << PAGE_EXEC_SHIFT) |
+	    ((unsigned int) p->global << PAGE_GLOBAL_SHIFT)
+	);
+}
+
+NO_TRACE static inline void set_pt_flags(pte_t *pt, size_t i, int flags)
+    WRITES(ARRAY_RANGE(pt, PTL0_ENTRIES_ARCH))
+    REQUIRES_ARRAY_MUTABLE(pt, PTL0_ENTRIES_ARCH)
+{
+	pte_t *p = &pt[i];
+	
+	p->page_cache_disable = !(flags & PAGE_CACHEABLE);
+	p->present = !(flags & PAGE_NOT_PRESENT);
+	p->uaccessible = (flags & PAGE_USER) != 0;
+	p->writeable = (flags & PAGE_WRITE) != 0;
+	p->global = (flags & PAGE_GLOBAL) != 0;
+	
+	/*
+	 * Ensure that there is at least one bit set even if the present bit is
+	 * cleared.
+	 */
+	p->soft_valid = true;
+}
+
+NO_TRACE static inline void set_pt_present(pte_t *pt, size_t i)
+    WRITES(ARRAY_RANGE(pt, PTL0_ENTRIES_ARCH))
+    REQUIRES_ARRAY_MUTABLE(pt, PTL0_ENTRIES_ARCH)
+{
+	pte_t *p = &pt[i];
+
+	p->present = 1;
+}
+
+extern void page_arch_init(void);
+extern void page_fault(unsigned int, istate_t *);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/mm/tlb.h
===================================================================
--- kernel/arch/sparc32/include/arch/mm/tlb.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/mm/tlb.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32lemm
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_TLB_H_
+#define KERN_abs32le_TLB_H_
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/proc/task.h
===================================================================
--- kernel/arch/sparc32/include/arch/proc/task.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/proc/task.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32leproc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_TASK_H_
+#define KERN_abs32le_TASK_H_
+
+#include <typedefs.h>
+#include <adt/bitmap.h>
+
+/*
+ * On real hardware this structure stores task information
+ * specific to the architecture.
+ */
+typedef struct {
+} task_arch_t;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/proc/thread.h
===================================================================
--- kernel/arch/sparc32/include/arch/proc/thread.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/proc/thread.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32leproc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_abs32le_THREAD_H_
+#define KERN_abs32le_THREAD_H_
+
+#include <typedefs.h>
+
+typedef struct {
+} thread_arch_t;
+
+#define thr_constructor_arch(thr)
+#define thr_destructor_arch(thr)
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/register.h
===================================================================
--- kernel/arch/sparc32/include/arch/register.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/register.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32_REGISTER_H_
+#define KERN_sparc32_REGISTER_H_
+
+#include <typedefs.h>
+
+/** Processor State Register. */
+typedef union {
+	uint32_t value;
+	struct {
+		unsigned int impl: 4;
+		unsigned int ver: 4;
+		unsigned int icc: 4;
+		unsigned int : 6;
+		unsigned int ec: 1;
+		unsigned int ef: 1;
+		unsigned int pil: 4;
+		unsigned int s: 1;
+		unsigned int ps: 1;
+		unsigned int et: 1;
+		unsigned int cwp: 5;
+	} __attribute__ ((packed));
+} psr_reg_t;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/stack.h
===================================================================
--- kernel/arch/sparc32/include/arch/stack.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/stack.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2005 Jakub Jermar
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32_STACK_H_
+#define KERN_sparc32_STACK_H_
+
+#include <config.h>
+
+#define MEM_STACK_SIZE	STACK_SIZE
+
+#define STACK_ITEM_SIZE			4
+
+/** According to SPARC Compliance Definition, every stack frame is 16-byte aligned. */
+#define STACK_ALIGNMENT			8
+
+/**
+ * 16-extended-word save area for %i[0-7] and %l[0-7] registers.
+ */
+#define STACK_WINDOW_SAVE_AREA_SIZE	(16 * STACK_ITEM_SIZE)
+
+/**
+ * Six extended words for first six arguments.
+ */
+#define STACK_ARG_SAVE_AREA_SIZE	(6 * STACK_ITEM_SIZE)
+
+/*
+ * Offsets of arguments on stack.
+ */
+#define STACK_ARG0			0
+#define STACK_ARG1			4
+#define STACK_ARG2			8
+#define STACK_ARG3			12
+#define STACK_ARG4			16
+#define STACK_ARG5			20
+#define STACK_ARG6			24
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/trap.h
===================================================================
--- kernel/arch/sparc32/include/arch/trap.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/trap.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32_TRAP_H_
+#define KERN_sparc32_TRAP_H_
+
+#define	TRAP_ENTRY_SIZE		16
+#define	TRAP_TABLE_COUNT	256
+#define	TRAP_TABLE_SIZE		(TRAP_ENTRY_SIZE * TRAP_TABLE_COUNT)
+
+#ifndef __ASM__
+extern void *trap_table;
+#endif
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/include/arch/types.h
===================================================================
--- kernel/arch/sparc32/include/arch/types.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/include/arch/types.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup sparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc32le_TYPES_H_
+#define KERN_sparc32le_TYPES_H_
+
+#define ATOMIC_COUNT_MIN  UINT32_MIN
+#define ATOMIC_COUNT_MAX  UINT32_MAX
+
+typedef uint32_t size_t;
+typedef int32_t ssize_t;
+
+typedef uint32_t uintptr_t;
+typedef uint32_t pfn_t;
+
+typedef uint32_t ipl_t;
+
+typedef uint32_t sysarg_t;
+typedef int32_t native_t;
+typedef uint32_t atomic_count_t;
+
+typedef struct {
+} fncptr_t;
+
+#define INTN_C(c)   INT32_C(c)
+#define UINTN_C(c)  UINT32_C(c)
+
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/context.S
===================================================================
--- kernel/arch/sparc32/src/context.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/context.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,91 @@
+#
+# Copyright (c) 2005 Jakub Jermar
+# Copyright (c) 2013 Jakub Klama
+# 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.
+#
+
+#include <arch/context_offset.h>
+#include <arch/arch.h>
+
+.text
+
+.global context_save_arch
+.global context_restore_arch
+
+/*
+ * context_save_arch() is required not to create its own stack frame. See the
+ * generic context.h for explanation.
+ */
+context_save_arch:
+	#
+	# Force all our active register windows to memory so that we can find
+	# them there even if e.g. the thread is migrated to another processor.
+	#
+	#flushw
+		mov 7, %g1
+1:	subcc %g1, 1, %g1
+ 	bg 1b
+	 save %sp, -64, %sp
+
+	mov 7, %g1
+1:	subcc %g1, 1, %g1
+ 	bg 1b
+	 restore
+
+	CONTEXT_SAVE_ARCH_CORE %o0
+	retl
+	mov 1, %o0		! context_save_arch returns 1
+
+context_restore_arch:
+	#
+	# Forget all previous windows, they are not going to be needed again.
+	# Enforce a window fill on the next RESTORE instruction by setting
+	# CANRESTORE to zero and other window configuration registers
+	# accordingly. Note that the same can be achieved by executing the
+	# FLUSHW instruction, but since we don't need to remember the previous
+	# windows, we do the former and save thus some unnecessary window
+	# spills.
+	#
+	#rdpr %pstate, %l0
+	#andn %l0, PSTATE_IE_BIT, %l1
+	#wrpr %l1, %pstate
+	#wrpr %g0, 0, %canrestore
+	#wrpr %g0, 0, %otherwin
+	#wrpr %g0, NWINDOWS - 2, %cansave
+	#wrpr %l0, %pstate
+	mov 7, %g1
+1:	subcc %g1, 1, %g1
+ 	bg 1b
+	 save %sp, -64, %sp
+
+	mov 7, %g1
+1:	subcc %g1, 1, %g1
+ 	bg 1b
+	 restore
+
+	CONTEXT_RESTORE_ARCH_CORE %o0
+	retl
+	xor %o0, %o0, %o0	! context_restore_arch returns 0
Index: kernel/arch/sparc32/src/cpu/cpu.c
===================================================================
--- kernel/arch/sparc32/src/cpu/cpu.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/cpu/cpu.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#include <arch/cpu.h>
+#include <arch.h>
+#include <typedefs.h>
+#include <print.h>
+#include <fpu_context.h>
+
+
+void fpu_disable(void)
+{
+}
+
+void fpu_enable(void)
+{
+}
+
+void cpu_arch_init(void)
+{
+}
+
+void cpu_identify(void)
+{
+}
+
+void cpu_print_report(cpu_t* cpu)
+{
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/ddi/ddi.c
===================================================================
--- kernel/arch/sparc32/src/ddi/ddi.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/ddi/ddi.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32leddi
+ * @{
+ */
+/** @file
+ *  @brief DDI.
+ */
+
+#include <ddi/ddi.h>
+#include <proc/task.h>
+#include <typedefs.h>
+
+/** Enable I/O space range for task.
+ *
+ */
+int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)
+{
+	return 0;
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/debug/stacktrace.c
===================================================================
--- kernel/arch/sparc32/src/debug/stacktrace.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/debug/stacktrace.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2010 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 abs32le
+ * @{
+ */
+/** @file
+ */
+
+#include <stacktrace.h>
+#include <syscall/copy.h>
+#include <typedefs.h>
+
+bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx)
+{
+	return true;
+}
+
+bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
+{
+	return true;
+}
+
+bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
+{
+	return true;
+}
+
+bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx)
+{
+	return true;
+}
+
+bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
+{
+	return true;
+}
+
+bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
+{
+	return true;
+}
+
+uintptr_t frame_pointer_get(void)
+{
+	return 0;
+}
+
+uintptr_t program_counter_get(void)
+{
+	return 0;
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/exception.c
===================================================================
--- kernel/arch/sparc32/src/exception.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/exception.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2005 Jakub Jermar
+ * Copyright (c) 2013 Jakub Klama
+ * 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.h>
+#include <typedefs.h>
+#include <arch/istate.h>
+#include <arch/exception.h>
+#include <interrupt.h>
+#include <arch/asm.h>
+#include <debug.h>
+#include <print.h>
+#include <symtab.h>
+
+/** Handle instruction_access_exception. (0x1) */
+void instruction_access_exception(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** Handle instruction_access_error. (0x21) */
+void instruction_access_error(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** Handle illegal_instruction. (0x2) */
+void illegal_instruction(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** Handle privileged_instruction. (0x3) */
+void privileged_instruction(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** Handle fp_disabled. (0x3) */
+void fp_disabled(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** Handle division_by_zero. (0x2a) */
+void division_by_zero(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** Handle data_access_exception. (0x9) */
+void data_access_exception(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** Handle data_access_error. (0x29) */
+void data_access_error(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** Handle mem_address_not_aligned. (0x7) */
+void mem_address_not_aligned(int n, istate_t *istate)
+{
+	fault_if_from_uspace(istate, "%s.", __func__);
+	panic_badtrap(istate, n, "%s.", __func__);
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/mm/as.c
===================================================================
--- kernel/arch/sparc32/src/mm/as.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/mm/as.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32lemm
+ * @{
+ */
+
+#include <mm/as.h>
+#include <arch/mm/as.h>
+#include <genarch/mm/page_pt.h>
+
+void as_arch_init(void)
+{
+	as_operations = &as_pt_operations;
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/mm/frame.c
===================================================================
--- kernel/arch/sparc32/src/mm/frame.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/mm/frame.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2007 Pavel Jancik, Michal Kebrt
+ * Copyright (c) 2013 Jakub Klama
+ * 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 sparc32mm
+ * @{
+ */
+/** @file
+ *  @brief Frame related functions.
+ */
+
+#include <mm/frame.h>
+#include <arch/mm/frame.h>
+#include <config.h>
+#include <align.h>
+#include <macros.h>
+
+static void frame_common_arch_init(bool low)
+{
+	uintptr_t base;
+	size_t size;
+
+	//machine_get_memory_extents(&base, &size);
+	base = 0x40000000;
+	size = 0x2000000;
+
+	base = ALIGN_UP(base, FRAME_SIZE);
+	size = ALIGN_DOWN(size, FRAME_SIZE);
+	
+	if (!frame_adjust_zone_bounds(low, &base, &size))
+		return;
+
+	if (low) {
+		zone_create(ADDR2PFN(base), SIZE2FRAMES(size),
+		    BOOT_PT_START_FRAME + BOOT_PT_SIZE_FRAMES,
+		    ZONE_AVAILABLE | ZONE_LOWMEM);
+	} else {
+		pfn_t conf = zone_external_conf_alloc(SIZE2FRAMES(size));
+		if (conf != 0)
+			zone_create(ADDR2PFN(base), SIZE2FRAMES(size), conf,
+			    ZONE_AVAILABLE | ZONE_HIGHMEM);
+	}
+	
+}
+
+void physmem_print(void)
+{
+
+}
+
+/** Create low memory zones. */
+void frame_low_arch_init(void)
+{
+	frame_common_arch_init(true);
+
+	/* blacklist boot page table */
+	frame_mark_unavailable(BOOT_PT_START_FRAME, BOOT_PT_SIZE_FRAMES);
+	//machine_frame_init();
+}
+
+/** Create high memory zones. */
+void frame_high_arch_init(void)
+{
+	frame_common_arch_init(false);
+}
+
+/** Frees the boot page table. */
+/*void boot_page_table_free(void)
+{
+	unsigned int i;
+	for (i = 0; i < BOOT_PT_SIZE_FRAMES; i++)
+		frame_free(i * FRAME_SIZE + BOOT_PT_ADDRESS);
+}*/
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/mm/km.c
===================================================================
--- kernel/arch/sparc32/src/mm/km.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/mm/km.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 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 sparc32mm
+ * @{
+ */
+
+#include <arch/mm/km.h>
+#include <mm/km.h>
+#include <typedefs.h>
+#include <macros.h>
+
+void km_identity_arch_init(void)
+{
+	config.identity_base = KM_SPARC32_IDENTITY_START;
+	config.identity_size = KM_SPARC32_IDENTITY_SIZE;
+}
+
+void km_non_identity_arch_init(void)
+{
+	km_non_identity_span_add(KM_SPARC32_NON_IDENTITY_START,
+	    KM_SPARC32_NON_IDENTITY_SIZE);
+}
+
+bool km_is_non_identity_arch(uintptr_t addr)
+{
+	return iswithin(KM_SPARC32_NON_IDENTITY_START,
+	    KM_SPARC32_NON_IDENTITY_SIZE, addr, 1);
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/mm/page.c
===================================================================
--- kernel/arch/sparc32/src/mm/page.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/mm/page.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32lemm
+ * @{
+ */
+/** @file
+ */
+
+#include <arch/mm/page.h>
+#include <genarch/mm/page_pt.h>
+#include <arch/mm/frame.h>
+#include <mm/frame.h>
+#include <mm/page.h>
+#include <mm/as.h>
+#include <typedefs.h>
+#include <align.h>
+#include <config.h>
+#include <func.h>
+#include <arch/interrupt.h>
+#include <arch/asm.h>
+#include <debug.h>
+#include <memstr.h>
+#include <print.h>
+#include <interrupt.h>
+
+void page_arch_init(void)
+{
+	if (config.cpu_active == 1)
+		page_mapping_operations = &pt_mapping_operations;
+}
+
+void page_fault(unsigned int n __attribute__((unused)), istate_t *istate)
+{
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/mm/tlb.c
===================================================================
--- kernel/arch/sparc32/src/mm/tlb.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/mm/tlb.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32lemm
+ * @{
+ */
+
+#include <mm/tlb.h>
+#include <arch/mm/asid.h>
+#include <arch/asm.h>
+#include <typedefs.h>
+
+void tlb_invalidate_all(void)
+{
+}
+
+void tlb_invalidate_asid(asid_t asid __attribute__((unused)))
+{
+	tlb_invalidate_all();
+}
+
+void tlb_invalidate_pages(asid_t asid __attribute__((unused)), uintptr_t page, size_t cnt)
+{
+	tlb_invalidate_all();
+}
+
+void tlb_arch_init(void)
+{
+}
+
+void tlb_print(void)
+{
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/proc/scheduler.c
===================================================================
--- kernel/arch/sparc32/src/proc/scheduler.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/proc/scheduler.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32leproc
+ * @{
+ */
+/** @file
+ */
+
+#include <proc/scheduler.h>
+
+void before_task_runs_arch(void)
+{
+}
+
+void before_thread_runs_arch(void)
+{
+}
+
+void after_thread_ran_arch(void)
+{
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/proc/task.c
===================================================================
--- kernel/arch/sparc32/src/proc/task.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/proc/task.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32leproc
+ * @{
+ */
+/** @file
+ */
+
+#include <proc/task.h>
+
+void task_create_arch(task_t *t)
+{
+}
+
+void task_destroy_arch(task_t *t)
+{
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/proc/thread.c
===================================================================
--- kernel/arch/sparc32/src/proc/thread.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/proc/thread.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32leproc
+ * @{
+ */
+/** @file
+ */
+
+#include <proc/thread.h>
+
+void thread_create_arch(thread_t *t)
+{
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/smp/ipi.c
===================================================================
--- kernel/arch/sparc32/src/smp/ipi.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/smp/ipi.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifdef CONFIG_SMP
+
+#include <smp/ipi.h>
+
+void ipi_broadcast_arch(int ipi)
+{
+}
+
+#endif /* CONFIG_SMP */
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/smp/smp.c
===================================================================
--- kernel/arch/sparc32/src/smp/smp.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/smp/smp.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#include <smp/smp.h>
+
+#if 0
+void smp_init(void)
+{
+}
+
+void kmp(void *arg)
+{
+}
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/sparc32.c
===================================================================
--- kernel/arch/sparc32/src/sparc32.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/sparc32.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#include <arch.h>
+#include <typedefs.h>
+#include <arch/interrupt.h>
+#include <arch/asm.h>
+
+#include <func.h>
+#include <config.h>
+#include <errno.h>
+#include <context.h>
+#include <fpu_context.h>
+#include <interrupt.h>
+#include <syscall/copy.h>
+#include <ddi/irq.h>
+#include <proc/thread.h>
+#include <syscall/syscall.h>
+#include <console/console.h>
+#include <memstr.h>
+
+char memcpy_from_uspace_failover_address;
+char memcpy_to_uspace_failover_address;
+
+void arch_pre_main(void)
+{
+}
+
+void arch_pre_mm_init(void)
+{
+}
+
+void arch_post_mm_init(void)
+{
+	if (config.cpu_active == 1) {
+		/* Initialize IRQ routing */
+		irq_init(0, 0);
+		
+		/* Merge all memory zones to 1 big zone */
+		zone_merge_all();
+	}
+}
+
+void arch_post_cpu_init()
+{
+}
+
+void arch_pre_smp_init(void)
+{
+}
+
+void arch_post_smp_init(void)
+{
+}
+
+void calibrate_delay_loop(void)
+{
+}
+
+sysarg_t sys_tls_set(uintptr_t addr)
+{
+	return EOK;
+}
+
+/** Construct function pointer
+ *
+ * @param fptr   function pointer structure
+ * @param addr   function address
+ * @param caller calling function address
+ *
+ * @return address of the function pointer
+ *
+ */
+void *arch_construct_function(fncptr_t *fptr, void *addr, void *caller)
+{
+	return addr;
+}
+
+void arch_reboot(void)
+{
+}
+
+void irq_initialize_arch(irq_t *irq)
+{
+	(void) irq;
+}
+
+void istate_decode(istate_t *istate)
+{
+	(void) istate;
+}
+
+void fpu_init(void)
+{
+}
+
+void fpu_context_save(fpu_context_t *ctx)
+{
+}
+
+void fpu_context_restore(fpu_context_t *ctx)
+{
+}
+
+int memcpy_from_uspace(void *dst, const void *uspace_src, size_t size)
+{
+	return EOK;
+}
+
+int memcpy_to_uspace(void *uspace_dst, const void *src, size_t size)
+{
+	return EOK;
+}
+
+/** @}
+ */
Index: kernel/arch/sparc32/src/start.S
===================================================================
--- kernel/arch/sparc32/src/start.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/start.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,71 @@
+#
+# Copyright (c) 2013 Jakub Klama
+# 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.
+#
+
+.text
+
+.global kernel_image_start
+.global early_putchar
+
+kernel_image_start:
+	# Install trap handlers
+	set trap_table, %g1
+	mov %g1, %tbr
+
+        mov	%psr, %g1         	! Initialize WIM
+	add	%g1, 1, %g2
+	and	%g2, 0x7, %g2
+	set	1, %g3
+	sll	%g3, %g2, %g3
+        mov     %g3, %wim
+
+	or	%g1, 0x20, %g1
+        wr      %g1, %psr
+
+	set	boot_stack, %sp
+	mov	%sp, %fp
+	sub	%sp, 96, %sp
+
+	call arch_pre_main
+	nop
+
+	call main_bsp
+	nop
+
+early_putchar:
+	set 0x80000100, %l0
+	cmp %o0, '\n'
+	bne skip
+	set '\r', %l1
+	sta %l1, [%l0] 0x1c
+skip:	sta %o0, [%l0] 0x1c
+	retl
+	nop
+
+.align 16
+.space 4096
+boot_stack:
Index: kernel/arch/sparc32/src/trap_table.S
===================================================================
--- kernel/arch/sparc32/src/trap_table.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/trap_table.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,235 @@
+#
+# Copyright (c) 2013 Jakub Klama
+# 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.
+#
+
+#include <arch/trap.h>
+
+.text
+
+.global trap_table
+.global reset_trap
+.global window_overflow_trap
+.global window_underflow_trap
+
+reset_trap:
+	set 0x80000100, %l0
+	set 'r', %l1
+	sta %l1, [%l0] 0x1c
+	rett
+
+window_overflow_trap:
+        /* rotate WIM on bit right, we have 8 windows */
+        mov %wim,%l3
+        sll %l3,7,%l4
+        srl %l3,1,%l3
+        or  %l3,%l4,%l3
+        and %l3,0xff,%l3
+
+        /* disable WIM traps */
+        mov %g0,%wim
+        nop; nop; nop
+
+        /* point to correct window */
+        save
+
+        /* dump registers to stack */
+        std %l0, [%sp +  0]
+        std %l2, [%sp +  8]
+        std %l4, [%sp + 16]
+        std %l6, [%sp + 24]
+        std %i0, [%sp + 32]
+        std %i2, [%sp + 40]
+        std %i4, [%sp + 48]
+        std %i6, [%sp + 56]
+
+        /* back to where we should be */
+        restore
+
+        /* set new value of window */
+        mov %l3,%wim
+        nop; nop; nop
+
+        /* go home */
+        jmp %l1
+        rett %l2
+
+window_underflow_trap:
+        /* rotate WIM on bit LEFT, we have 8 windows */ 
+        mov %wim,%l3
+        srl %l3,7,%l4
+        sll %l3,1,%l3
+        or  %l3,%l4,%l3
+        and %l3, 0xff,%l3
+
+        /* disable WIM traps */
+        mov %g0,%wim
+        nop; nop; nop
+
+        /* point to correct window */
+        restore
+        restore
+
+        /* dump registers to stack */
+        ldd [%sp +  0], %l0
+        ldd [%sp +  8], %l2
+        ldd [%sp + 16], %l4
+        ldd [%sp + 24], %l6
+        ldd [%sp + 32], %i0
+        ldd [%sp + 40], %i2
+        ldd [%sp + 48], %i4
+        ldd [%sp + 56], %i6
+
+        /* back to where we should be */
+        save
+        save
+
+        /* set new value of window */
+        mov %l3,%wim
+        nop; nop; nop
+
+        /* go home */
+        jmp %l1
+        rett %l2
+
+#define	TRAP(_vector, _handler) \
+	.org trap_table + _vector * TRAP_ENTRY_SIZE; \
+	mov   %psr, %l0 ; \
+	sethi %hi(_handler), %l4 ; \
+	jmp   %l4+%lo(_handler); \
+	mov   _vector, %l3 ;
+
+#define	BADTRAP(_vector) \
+	.org trap_table + _vector * TRAP_ENTRY_SIZE ; \
+	ta 0 ;
+
+.align TRAP_TABLE_SIZE
+trap_table:
+	TRAP(0, reset_trap)
+	BADTRAP(1)
+	TRAP(2, illegal_instruction)
+	TRAP(3, privileged_instruction)
+	TRAP(4, fp_disabled)
+	TRAP(5, window_overflow_trap)
+	TRAP(6, window_underflow_trap)
+	BADTRAP(7)
+	BADTRAP(8)
+	BADTRAP(9)
+	BADTRAP(10)
+	BADTRAP(11)
+	BADTRAP(12)
+	BADTRAP(13)
+	BADTRAP(14)
+	BADTRAP(15)
+	BADTRAP(16)
+        BADTRAP(17)
+        BADTRAP(18)
+        BADTRAP(19)
+        BADTRAP(20)
+        BADTRAP(21)
+        BADTRAP(22)
+        BADTRAP(23)
+        BADTRAP(24)
+        BADTRAP(25)
+        BADTRAP(26)
+        BADTRAP(27)
+        BADTRAP(28)
+        BADTRAP(29)
+        BADTRAP(30)
+        BADTRAP(31)
+        BADTRAP(32)
+        BADTRAP(33)
+        BADTRAP(34)
+        BADTRAP(35)
+        BADTRAP(36)
+        BADTRAP(37)
+        BADTRAP(38)
+        BADTRAP(39)
+        BADTRAP(40)
+        BADTRAP(41)
+        BADTRAP(42)
+        BADTRAP(43)
+        BADTRAP(44)
+        BADTRAP(45)
+        BADTRAP(46)
+        BADTRAP(47)
+        BADTRAP(48)
+        BADTRAP(49)
+        BADTRAP(50)
+        BADTRAP(51)
+        BADTRAP(52)
+        BADTRAP(53)
+        BADTRAP(54)
+        BADTRAP(55)
+        BADTRAP(56)
+        BADTRAP(57)
+        BADTRAP(58)
+        BADTRAP(59)
+        BADTRAP(60)
+        BADTRAP(61)
+        BADTRAP(62)
+        BADTRAP(63)
+        BADTRAP(64)
+        BADTRAP(65)
+        BADTRAP(66)
+        BADTRAP(67)
+        BADTRAP(68)
+        BADTRAP(69)
+        BADTRAP(70)
+        BADTRAP(71)
+        BADTRAP(72)
+        BADTRAP(73)
+        BADTRAP(74)
+        BADTRAP(75)
+        BADTRAP(76)
+        BADTRAP(77)
+        BADTRAP(78)
+        BADTRAP(79)
+        BADTRAP(80)
+        BADTRAP(81)
+        BADTRAP(82)
+        BADTRAP(83)
+        BADTRAP(84)
+        BADTRAP(85)
+        BADTRAP(86)
+        BADTRAP(87)
+        BADTRAP(88)
+        BADTRAP(89)
+        BADTRAP(90)
+        BADTRAP(91)
+        BADTRAP(92)
+        BADTRAP(93)
+        BADTRAP(94)
+        BADTRAP(95)
+        BADTRAP(96)
+        BADTRAP(97)
+        BADTRAP(98)
+        BADTRAP(99)
+        BADTRAP(100)
+        BADTRAP(101)
+        BADTRAP(102)
+        BADTRAP(103)
+
Index: kernel/arch/sparc32/src/userspace.c
===================================================================
--- kernel/arch/sparc32/src/userspace.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ kernel/arch/sparc32/src/userspace.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup abs32le
+ * @{
+ */
+/** @file
+ */
+
+#include <userspace.h>
+#include <typedefs.h>
+#include <arch.h>
+#include <abi/proc/uarg.h>
+#include <mm/as.h>
+
+void userspace(uspace_arg_t *kernel_uarg)
+{
+	/* On real hardware this switches the CPU to user
+	   space mode and jumps to kernel_uarg->uspace_entry. */
+	
+	while (true);
+}
+
+/** @}
+ */
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision b886b60583e374eb7225d5360734542d3ff3085c)
+++ kernel/generic/src/main/main.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -166,4 +166,8 @@
 	config.stack_base = config.base + config.kernel_size;
 	
+	printf("base = 0x%08x\n", config.base);
+	printf("kernel_size = 0x%08x\n", config.kernel_size);
+	printf("stack_base = 0x%08x\n", config.stack_base);
+
 	/* Avoid placing stack on top of init */
 	size_t i;
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision b886b60583e374eb7225d5360734542d3ff3085c)
+++ tools/autotool.py	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -256,4 +256,8 @@
 		gnu_target = "sparc64-linux-gnu"
 		clang_target = "sparc-unknown-linux"
+
+	if (config['PLATFORM'] == "sparc32"):
+		target = config['PLATFORM'];
+		gnu_target = "sparc-leon3-linux-gnu"
 	
 	return (target, cc_args, gnu_target, clang_target)
Index: uspace/lib/c/arch/sparc32/Makefile.common
===================================================================
--- uspace/lib/c/arch/sparc32/Makefile.common	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/Makefile.common	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2006 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.
+#
+
+#GCC_CFLAGS += -mcpu=ultrasparc -m64 -mcmodel=medlow
+LFLAGS = -no-check-sections
+
+ENDIANESS = BE
+
+BFD_NAME = elf32-sparc
+BFD_ARCH = sparc
+
Index: uspace/lib/c/arch/sparc32/Makefile.inc
===================================================================
--- uspace/lib/c/arch/sparc32/Makefile.inc	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/Makefile.inc	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2006 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.
+#
+
+ARCH_SOURCES = \
+	arch/$(UARCH)/src/entry.s \
+	arch/$(UARCH)/src/entryjmp.s \
+	arch/$(UARCH)/src/thread_entry.s \
+	arch/$(UARCH)/src/fibril.S \
+	arch/$(UARCH)/src/tls.c \
+	arch/$(UARCH)/src/stacktrace.c \
+	arch/$(UARCH)/src/stacktrace_asm.S
+
+.PRECIOUS: arch/$(UARCH)/src/entry.o
Index: uspace/lib/c/arch/sparc32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/sparc32/_link.ld.in	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/_link.ld.in	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,68 @@
+STARTUP(LIBC_PATH/arch/UARCH/src/entry.o)
+ENTRY(__entry)
+
+PHDRS {
+#ifdef LOADER
+	interp PT_INTERP;
+	text PT_LOAD FILEHDR PHDRS FLAGS(5);
+#else
+	text PT_LOAD FLAGS(5);
+#endif
+	data PT_LOAD FLAGS(6);
+}
+
+SECTIONS {
+#ifdef LOADER
+	. = 0x70004000 + SIZEOF_HEADERS;
+#else
+	. = 0x4000 + SIZEOF_HEADERS;
+#endif
+	
+	.init : {
+		*(.init);
+	} :text
+	
+	.text : {
+		*(.text .text.*);
+		*(.rodata .rodata.*);
+	} :text
+	
+#ifdef LOADER
+	.interp : {
+		*(.interp);
+	} :interp :text
+#endif
+	
+	. = . + 0x4000;
+	
+	.got : {
+		 _gp = .;
+		 *(.got*);
+	} :data
+	
+	.data : {
+		*(.data);
+		*(.sdata);
+	} :data
+	
+	.tdata : {
+		_tdata_start = .;
+		*(.tdata);
+		_tdata_end = .;
+		_tbss_start = .;
+		*(.tbss);
+		_tbss_end = .;
+	} :data
+	
+	_tls_alignment = ALIGNOF(.tdata);
+	
+	.bss : {
+		*(.sbss);
+		*(COMMON);
+		*(.bss);
+	} :data
+	
+	/DISCARD/ : {
+		*(*);
+	}
+}
Index: uspace/lib/c/arch/sparc32/include/libarch/atomic.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/atomic.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/atomic.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,108 @@
+/*
+ * 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 libcsparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc64_ATOMIC_H_
+#define LIBC_sparc64_ATOMIC_H_
+
+#define LIBC_ARCH_ATOMIC_H_
+
+#include <atomicdflt.h>
+#include <sys/types.h>
+
+/** Atomic add operation.
+ *
+ * Use atomic compare and swap operation to atomically add signed value.
+ *
+ * @param val Atomic variable.
+ * @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)
+{
+	atomic_count_t a;
+	atomic_count_t b;
+	
+	do {
+		volatile uintptr_t ptr = (uintptr_t) &val->count;
+		
+		a = *((atomic_count_t *) ptr);
+		b = a + i;
+		
+// XXX		asm volatile (
+//			"cas %0, %2, %1\n"
+//			: "+m" (*((atomic_count_t *) ptr)),
+//			  "+r" (b)
+//			: "r" (a)
+//		);
+	} while (a != b);
+	
+	return a;
+}
+
+static inline atomic_count_t atomic_preinc(atomic_t *val)
+{
+	return atomic_add(val, 1) + 1;
+}
+
+static inline atomic_count_t atomic_postinc(atomic_t *val)
+{
+	return atomic_add(val, 1);
+}
+
+static inline atomic_count_t atomic_predec(atomic_t *val)
+{
+	return atomic_add(val, -1) - 1;
+}
+
+static inline atomic_count_t atomic_postdec(atomic_t *val)
+{
+	return atomic_add(val, -1);
+}
+
+static inline void atomic_inc(atomic_t *val)
+{
+	(void) atomic_add(val, 1);
+}
+
+static inline void atomic_dec(atomic_t *val)
+{
+	(void) atomic_add(val, -1);
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/barrier.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/barrier.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/barrier.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/sparc64/include/arch/barrier.h
Index: uspace/lib/c/arch/sparc32/include/libarch/config.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/config.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/config.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,44 @@
+/*
+ * 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 libcsparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc32_CONFIG_H_
+#define LIBC_sparc32_CONFIG_H_
+
+#define PAGE_WIDTH	12
+#define PAGE_SIZE	(1 << PAGE_WIDTH)
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/context_offset.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/context_offset.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/context_offset.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/sparc64/include/arch/context_offset.h
Index: uspace/lib/c/arch/sparc32/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/ddi.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/ddi.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @file
+ * @ingroup libsparc64
+ */
+
+#ifndef LIBC_sparc64_DDI_H_
+#define LIBC_sparc64_DDI_H_
+
+#include <sys/types.h>
+#include <libarch/types.h>
+
+static inline void memory_barrier(void)
+{
+	asm volatile (
+		"stbar\n"
+		::: "memory"
+	);
+}
+
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+{
+	*port = v;
+	memory_barrier();
+}
+
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+{
+	*port = v;
+	memory_barrier();
+}
+
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+{
+	*port = v;
+	memory_barrier();
+}
+
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+{
+	uint8_t rv;
+
+	rv = *port;
+	memory_barrier();
+
+	return rv;
+}
+
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+{
+	uint16_t rv;
+
+	rv = *port;
+	memory_barrier();
+
+	return rv;
+}
+
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+{
+	uint32_t rv;
+
+	rv = *port;
+	memory_barrier();
+
+	return rv;
+}
+
+#endif
Index: uspace/lib/c/arch/sparc32/include/libarch/elf.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/elf.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/elf.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/sparc64/include/arch/elf.h
Index: uspace/lib/c/arch/sparc32/include/libarch/elf_linux.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/elf_linux.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/elf_linux.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Jiri Svoboda
+ * 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 libcsparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc64_ELF_LINUX_H_
+#define LBIC_sparc64_ELF_LINUX_H_
+
+#include <libarch/istate.h>
+#include <sys/types.h>
+
+typedef struct {
+	/* TODO */
+	uint64_t pad[16];
+} elf_regs_t;
+
+static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs)
+{
+	/* TODO */
+	(void) istate; (void) elf_regs;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/faddr.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/faddr.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/faddr.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2005 Ondrej Palkovsky
+ * 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 libcsparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc64_FADDR_H_
+#define LIBC_sparc64_FADDR_H_
+
+#include <libarch/types.h>
+
+#define FADDR(fptr)		((uintptr_t) (fptr))
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/fibril.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/fibril.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,87 @@
+/*
+ * 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 libcsparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc32_FIBRIL_H_
+#define LIBC_sparc32_FIBRIL_H_
+
+#include <libarch/stack.h>
+#include <sys/types.h>
+#include <align.h>
+
+#define SP_DELTA  (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
+
+#define context_set(c, _pc, stack, size, ptls) \
+	do { \
+		(c)->pc = ((uintptr_t) _pc) - 8; \
+		(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), \
+		    STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
+		(c)->fp = -STACK_BIAS; \
+		(c)->tp = (uint32_t) ptls; \
+	} while (0)
+
+/*
+ * Save only registers that must be preserved across
+ * function calls.
+ */
+typedef struct {
+	uintptr_t sp;		/* %o6 */
+	uintptr_t pc;		/* %o7 */
+	uint64_t i0;
+	uint64_t i1;
+	uint64_t i2;
+	uint64_t i3;
+	uint64_t i4;
+	uint64_t i5;
+	uintptr_t fp;		/* %i6 */
+	uintptr_t i7;
+	uint64_t l0;
+	uint64_t l1;
+	uint64_t l2;
+	uint64_t l3;
+	uint64_t l4;
+	uint64_t l5;
+	uint64_t l6;
+	uint64_t l7;
+	uint64_t tp;		/* %g7 */
+} context_t;
+
+static inline uintptr_t context_get_fp(context_t *ctx)
+{
+	return ctx->sp + STACK_BIAS;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/inttypes.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/inttypes.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/inttypes.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010 Jiri Svoboda
+ * 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 libcsparc32
+ * @{
+ */
+
+#ifndef LIBC_sparc32_INTTYPES_H_
+#define LIBC_sparc32_INTTYPES_H_
+
+#define PRIdn  PRId32  /**< Format for native_t. */
+#define PRIun  PRIu32  /**< Format for sysarg_t. */
+#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t. */
+#define PRIua  PRIu32  /**< Format for atomic_count_t. */
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/istate.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/istate.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/istate.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/sparc64/include/arch/istate.h
Index: uspace/lib/c/arch/sparc32/include/libarch/regdef.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/regdef.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/regdef.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/sparc64/include/arch/regdef.h
Index: uspace/lib/c/arch/sparc32/include/libarch/stack.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/stack.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/stack.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,61 @@
+/*
+ * 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 libcsparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc64_STACK_H_
+#define LIBC_sparc64_STACK_H_
+
+#define STACK_ITEM_SIZE			8
+
+/** According to SPARC Compliance Definition, every stack frame is 16-byte aligned. */
+#define STACK_ALIGNMENT			16
+
+/**
+ * 16-extended-word save area for %i[0-7] and %l[0-7] registers.
+ */
+#define STACK_WINDOW_SAVE_AREA_SIZE	(16 * STACK_ITEM_SIZE)
+
+/*
+ * Six extended words for first six arguments.
+ */
+#define STACK_ARG_SAVE_AREA_SIZE		(6 * STACK_ITEM_SIZE)
+
+/**
+ * By convention, the actual top of the stack is %sp + STACK_BIAS.
+ */
+#define STACK_BIAS            2047
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/stackarg.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/stackarg.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/stackarg.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * 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 libcsparc64	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc64_STACKARG_H_
+#define LIBC_sparc64_STACKARG_H_
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/syscall.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/syscall.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/syscall.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2005 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.
+ */
+
+/** @addtogroup libcsparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc64_SYSCALL_H_
+#define LIBC_sparc64_SYSCALL_H_
+
+#include <sys/types.h>
+#include <abi/syscall.h>
+
+#define __syscall0	__syscall
+#define __syscall1	__syscall
+#define __syscall2	__syscall
+#define __syscall3	__syscall
+#define __syscall4	__syscall
+#define __syscall5	__syscall
+#define __syscall6	__syscall
+
+static inline sysarg_t
+__syscall(const sysarg_t p1, const sysarg_t p2, const sysarg_t p3,
+    const sysarg_t p4, const sysarg_t p5, const sysarg_t p6, const syscall_t id)
+{
+	register uint32_t a1 asm("o0") = p1;
+	register uint32_t a2 asm("o1") = p2;
+	register uint32_t a3 asm("o2") = p3;
+	register uint32_t a4 asm("o3") = p4;
+	register uint32_t a5 asm("o4") = p5;
+	register uint32_t a6 asm("o5") = p6;
+
+	asm volatile (
+		"ta %7\n"
+		: "=r" (a1)
+		: "r" (a1), "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6),
+		  "i" (id)
+		: "memory"
+	);
+	
+	return a1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/thread.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/thread.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/thread.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * 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 libcsparc64
+ * @{
+ */
+
+#ifndef LIBC_sparc64_THREAD_H_
+#define LIBC_sparc64_THREAD_H_
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/tls.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/tls.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/tls.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * 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 libcsparc64
+ * @{
+ */
+/**
+ * @file
+ * @brief	sparc64 TLS functions.
+ */
+
+#ifndef LIBC_sparc64_TLS_H_
+#define LIBC_sparc64_TLS_H_
+
+#define CONFIG_TLS_VARIANT_2
+
+typedef struct {
+	void *self;
+	void *fibril_data;
+} tcb_t;
+
+static inline void __tcb_set(tcb_t *tcb)
+{
+	asm volatile ("mov %0, %%g7\n" : : "r" (tcb) : "g7");
+}
+
+static inline tcb_t * __tcb_get(void)
+{
+	void *retval;
+
+	asm volatile ("mov %%g7, %0\n" : "=r" (retval));
+
+	return retval;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/include/libarch/types.h
===================================================================
--- uspace/lib/c/arch/sparc32/include/libarch/types.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/include/libarch/types.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2005 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.
+ */
+
+/** @addtogroup libcsparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_sparc32_TYPES_H_
+#define LIBC_sparc32_TYPES_H_
+
+#define __32_BITS__
+
+#include <libarch/common.h>
+
+#define SIZE_MIN  UINT32_MIN
+#define SIZE_MAX  UINT32_MAX
+
+#define SSIZE_MIN  INT32_MIN
+#define SSIZE_MAX  INT32_MAX
+
+typedef uint32_t sysarg_t;
+typedef int32_t native_t;
+
+typedef int32_t ssize_t;
+typedef uint32_t size_t;
+
+typedef uint32_t uintptr_t;
+typedef int32_t intptr_t;
+typedef uint32_t atomic_count_t;
+typedef int32_t atomic_signed_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/src/entry.s
===================================================================
--- uspace/lib/c/arch/sparc32/src/entry.s	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/src/entry.s	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,52 @@
+#
+# Copyright (c) 2006 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.
+#
+
+.section .init, "ax"
+
+.org 0
+
+.globl __entry
+
+## User-space task entry point
+#
+# %o0 contains uarg
+# %o1 contains pcb_ptr
+#
+__entry:
+	#
+	# Create the first stack frame.
+	#
+	save %sp, -176, %sp
+# XXX	flushw
+	add %g0, -0x7ff, %fp
+	
+	# Pass pcb_ptr as the first argument to __main()
+	mov %i1, %o0
+	sethi %hi(_gp), %l7
+	call __main
+	or %l7, %lo(_gp), %l7
Index: uspace/lib/c/arch/sparc32/src/entryjmp.s
===================================================================
--- uspace/lib/c/arch/sparc32/src/entryjmp.s	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/src/entryjmp.s	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2008 Jiri Svoboda
+# 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.
+#
+
+.globl entry_point_jmp
+
+## void entry_point_jmp(void *entry_point, void *pcb);
+#
+# %o0	contains entry_point
+# %o1	contains pcb
+#
+# Jump to program entry point
+entry_point_jmp:
+	# Pass pcb pointer to entry point in %o1. As it is already
+	# there, no action is needed.
+	call %o0
+	nop
+	# fixme: use branch instead of call
Index: uspace/lib/c/arch/sparc32/src/fibril.S
===================================================================
--- uspace/lib/c/arch/sparc32/src/fibril.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/src/fibril.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,57 @@
+#
+# 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.
+#
+
+#include <libarch/context_offset.h>
+
+.text
+
+.global context_save
+.global context_restore
+
+context_save:
+	#
+	# We rely on the kernel to flush our active register windows to memory
+	# should a thread switch occur.
+	#
+# XXX	CONTEXT_SAVE_ARCH_CORE %o0
+	retl
+	mov 1, %o0		! context_save_arch returns 1
+
+context_restore:
+	#
+	# Flush all active windows.
+	# This is essential, because CONTEXT_RESTORE_ARCH_CORE overwrites %sp of
+	# CWP - 1 with the value written to %fp of CWP.  Flushing all active
+	# windows mitigates this problem as CWP - 1 becomes the overlap window.
+	#
+# XXX
+#	flushw
+	
+# XXX	CONTEXT_RESTORE_ARCH_CORE %o0
+	retl
+	xor %o0, %o0, %o0	! context_restore_arch returns 0
Index: uspace/lib/c/arch/sparc32/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/sparc32/src/stacktrace.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/src/stacktrace.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2010 Jakub Jermar
+ * Copyright (c) 2010 Jiri Svoboda
+ * 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 <sys/types.h>
+#include <stdbool.h>
+#include <libarch/stack.h>
+#include <errno.h>
+
+#include <stacktrace.h>
+
+#define FRAME_OFFSET_FP_PREV	(14 * 8)
+#define FRAME_OFFSET_RA		(15 * 8)
+
+bool stacktrace_fp_valid(stacktrace_t *st, uintptr_t fp)
+{
+	(void) st;
+	return fp != 0;
+}
+
+int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
+{
+	uintptr_t bprev;
+	int rc;
+
+	rc = (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, &bprev);
+	if (rc == EOK)
+		*prev = bprev + STACK_BIAS;
+	return rc;
+}
+
+int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
+{
+	return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
+}
+
+/** @}
+ */
Index: uspace/lib/c/arch/sparc32/src/stacktrace_asm.S
===================================================================
--- uspace/lib/c/arch/sparc32/src/stacktrace_asm.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/src/stacktrace_asm.S	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2009 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.
+#
+
+#include <libarch/stack.h>
+
+.text
+
+.global stacktrace_prepare
+.global stacktrace_fp_get
+.global stacktrace_pc_get
+
+stacktrace_prepare:
+	save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE+STACK_ARG_SAVE_AREA_SIZE), %sp
+	# Flush all other windows to memory so that we can read their contents.
+# XXX	flushw
+	ret
+	restore
+
+stacktrace_fp_get:
+	# Add the stack bias to %sp to get the actual address.
+	retl
+	add %sp, STACK_BIAS, %o0
+
+stacktrace_pc_get:
+	retl
+	mov %o7, %o0
Index: uspace/lib/c/arch/sparc32/src/thread_entry.s
===================================================================
--- uspace/lib/c/arch/sparc32/src/thread_entry.s	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/src/thread_entry.s	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,55 @@
+#
+# 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.
+#
+
+.text
+	
+.globl __thread_entry
+
+## User-space thread entry point for all but the first threads.
+#
+#
+__thread_entry:
+	#
+	# Create the first stack frame.
+	#
+	save %sp, -176, %sp
+# XXX	flushw
+	add %g0, -0x7ff, %fp
+
+	#
+	# Propagate the input arguments to the new window.
+	#
+	mov %i0, %o0
+
+	sethi %hi(_gp), %l7
+	call __thread_main		! %o0 contains address of uarg
+	or %l7, %lo(_gp), %l7
+	
+	! not reached
+	
+.end __thread_entry
Index: uspace/lib/c/arch/sparc32/src/tls.c
===================================================================
--- uspace/lib/c/arch/sparc32/src/tls.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
+++ uspace/lib/c/arch/sparc32/src/tls.c	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * 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 libcsparc64 sparc64
+ * @ingroup lc
+ * @{
+ */
+/** @file
+ *
+ */
+
+#include <tls.h>
+#include <sys/types.h>
+
+tcb_t *tls_alloc_arch(void **data, size_t size)
+{
+	return tls_alloc_variant_2(data, size);
+}
+
+void tls_free_arch(tcb_t *tcb, size_t size)
+{
+	tls_free_variant_2(tcb, size);
+}
+
+/** @}
+ */
Index: uspace/lib/c/include/atomicdflt.h
===================================================================
--- uspace/lib/c/include/atomicdflt.h	(revision b886b60583e374eb7225d5360734542d3ff3085c)
+++ uspace/lib/c/include/atomicdflt.h	(revision b6b02c0fa1670aace09bf1d3f51ce99017e6230e)
@@ -60,5 +60,6 @@
 static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv)
 {
-	return __sync_bool_compare_and_swap(&val->count, ov, nv);
+// XXX	return __sync_bool_compare_and_swap(&val->count, ov, nv);
+	return false;
 }
 #endif
