Index: libc/arch/ppc32/Makefile.inc
===================================================================
--- libc/arch/ppc32/Makefile.inc	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/Makefile.inc	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+## Toolchain configuration
+#
+
+TARGET = ppc-linux-gnu
+TOOLCHAIN_DIR = /usr/local/ppc/bin
+
+ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \
+		arch/$(ARCH)/src/psthread.S \
+		arch/$(ARCH)/src/thread.c
+
+LFLAGS += -N
Index: libc/arch/ppc32/_link.ld.in
===================================================================
--- libc/arch/ppc32/_link.ld.in	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/_link.ld.in	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,45 @@
+STARTUP(../libc/arch/ARCH/src/entry.o)
+ENTRY(__entry)
+
+PHDRS {
+	text PT_LOAD FLAGS(5);
+	data PT_LOAD FLAGS(6);
+}
+
+SECTIONS {
+	. = 0x1000;
+
+	.init ALIGN(0x1000) : SUBALIGN(0x1000) {
+		*(.init);
+	} :text
+	.text : {
+		*(.text);
+		*(.rodata*);
+	} :text
+	
+	.data ALIGN(0x1000) : SUBALIGN(0x1000) {
+		*(.data);
+	} :data
+	.tdata : {
+		_tdata_start = .;
+		*(.tdata);
+		_tdata_end = .;
+	} :data
+	.tbss : {
+		_tbss_start = .;
+		*(.tbss);
+		_tbss_end = .;
+	} :data
+	.bss : {
+		*(.sbss);
+		*(COMMON);
+		*(.bss);
+		_heap = .;
+		LONG(0xdeadbeef);
+	} :data
+	
+	/DISCARD/ : {
+		*(*);
+	}
+
+}
Index: libc/arch/ppc32/include/atomic.h
===================================================================
--- libc/arch/ppc32/include/atomic.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/include/atomic.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+#ifndef __ppc32_ATOMIC_H__
+#define __ppc32_ATOMIC_H__
+
+static inline void atomic_inc(atomic_t *val)
+{
+	long tmp;
+
+	asm __volatile__ (
+		"1:\n"
+		"lwarx %0, 0, %2\n"
+		"addic %0, %0, 1\n"
+		"stwcx. %0, 0, %2\n"
+		"bne- 1b"
+		: "=&r" (tmp), "=m" (val->count)
+		: "r" (&val->count), "m" (val->count)
+		: "cc");
+}
+
+static inline void atomic_dec(atomic_t *val)
+{
+	long tmp;
+
+	asm __volatile__(
+		"1:\n"
+		"lwarx %0, 0, %2\n"
+		"addic %0, %0, -1\n"
+		"stwcx.	%0, 0, %2\n"
+		"bne- 1b"
+		: "=&r" (tmp), "=m" (val->count)
+		: "r" (&val->count), "m" (val->count)
+		: "cc");
+}
+
+static inline long atomic_postinc(atomic_t *val)
+{
+	atomic_inc(val);
+	return val->count - 1;
+}
+
+static inline long atomic_postdec(atomic_t *val)
+{
+	atomic_dec(val);
+	return val->count + 1;
+}
+
+static inline long atomic_preinc(atomic_t *val)
+{
+	atomic_inc(val);
+	return val->count;
+}
+
+static inline long atomic_predec(atomic_t *val)
+{
+	atomic_dec(val);
+	return val->count;
+}
+
+#endif
Index: libc/arch/ppc32/include/psthread.h
===================================================================
--- libc/arch/ppc32/include/psthread.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/include/psthread.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+#ifndef __LIBC__ppc32__PSTHREAD_H__
+#define __LIBC__ppc32__PSTHREAD_H__
+
+#include <types.h>
+
+#define context_set(c, _pc, stack, size, ptls) 			\
+	(c)->pc = (sysarg_t) (_pc);				\
+	(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; 	\
+        (c)->tls = ((sysarg_t)(ptls)) + 0x7000 + sizeof(tcb_t);
+
+#define SP_DELTA	(8+16)
+
+typedef struct  {
+	uint32_t sp;
+	uint32_t pc;
+	
+	uint32_t tls;
+} context_t;
+
+#endif
Index: libc/arch/ppc32/include/stackarg.h
===================================================================
--- libc/arch/ppc32/include/stackarg.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/include/stackarg.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+
+/*
+ * Variable argument list manipulation macros
+ * for architectures using stack to pass arguments.
+ */
+ 
+#ifndef __LIBC_STACKARG_H__
+#define __LIBC_STACKARG_H__
+
+#include <types.h>
+
+/* dont allow to define it second time in stdarg.h */
+#define __VARARGS_DEFINED
+
+typedef struct va_list {
+	int pos;
+	uint8_t *last;
+} va_list;
+
+#define va_start(ap, lst) \
+	(ap).pos = sizeof(lst); \
+	(ap).last = (uint8_t *) &(lst)
+
+#define va_arg(ap, type) \
+	(*((type *)((ap).last + ((ap).pos += sizeof(type)) - sizeof(type))))
+
+#define va_end(ap)
+
+
+#endif
Index: libc/arch/ppc32/include/thread.h
===================================================================
--- libc/arch/ppc32/include/thread.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/include/thread.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#ifndef __LIBC__ppc32__THREAD_H__
+#define __LIBC__ppc32__THREAD_H__
+
+typedef struct {
+	void *pst_data;
+} tcb_t;
+
+static inline void __tcb_set(tcb_t *tcb)
+{
+}
+
+static inline tcb_t * __tcb_get(void)
+{
+}
+
+#endif
Index: libc/arch/ppc32/include/types.h
===================================================================
--- libc/arch/ppc32/include/types.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/include/types.h	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+#ifndef __LIBC__TYPES_H__
+#define __LIBC__TYPES_H__
+
+typedef unsigned int sysarg_t;
+typedef unsigned int size_t;
+typedef signed int ssize_t;
+
+typedef char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+typedef long long int int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long int uint64_t;
+
+#endif
Index: libc/arch/ppc32/src/entry.s
===================================================================
--- libc/arch/ppc32/src/entry.s	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/src/entry.s	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,43 @@
+#
+# 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
+#
+#
+__entry:
+	bl __main	
+	bl main
+	bl __exit
+	
+.end __entry
Index: libc/arch/ppc32/src/psthread.S
===================================================================
--- libc/arch/ppc32/src/psthread.S	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/src/psthread.S	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+.text
+
+.global context_save
+.global context_restore
+
+#include <libarch/context_offset.h>
+
+context_save:
+	blr
+
+
+context_restore:
+	blr
Index: libc/arch/ppc32/src/syscall.c
===================================================================
--- libc/arch/ppc32/src/syscall.c	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/src/syscall.c	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+#include <libc.h>
+
+sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2, const sysarg_t p3, const sysarg_t p4, const syscall_t id)
+{
+	register sysarg_t __ppc32_reg_r3 asm("3") = id;
+	register sysarg_t __ppc32_reg_r4 asm("4") = p1;
+	register sysarg_t __ppc32_reg_r5 asm("5") = p2;
+	register sysarg_t __ppc32_reg_r6 asm("6") = p3;
+	register sysarg_t __ppc32_reg_r7 asm("7") = p4;
+	
+	asm volatile (
+		"sc\n"
+		: "=r" (__ppc32_reg_r3)
+		: "r" (__ppc32_reg_r3),
+		  "r" (__ppc32_reg_r4),
+		  "r" (__ppc32_reg_r5),
+		  "r" (__ppc32_reg_r6),
+		  "r" (__ppc32_reg_r7)
+	);
+	
+	return __ppc32_reg_r3;
+}
Index: libc/arch/ppc32/src/thread.c
===================================================================
--- libc/arch/ppc32/src/thread.c	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/src/thread.c	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+#include <thread.h>
+#include <malloc.h>
+
+/** Allocate TLS & TCB for initial module threads
+ *
+ * @param data Start of data section
+ * @return pointer to tcb_t structure
+ */
+tcb_t * __alloc_tls(void **data, size_t size)
+{
+	tcb_t *tcb;
+	
+	*data = malloc(sizeof(tcb_t) + size);
+
+	tcb = (tcb_t *) (*data + size);
+
+	return tcb;
+}
+
+void __free_tls_arch(tcb_t *tcb, size_t size)
+{
+	void *start = ((void *) tcb) - size;
+	free(start);
+}
Index: libc/arch/ppc32/src/thread_entry.s
===================================================================
--- libc/arch/ppc32/src/thread_entry.s	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
+++ libc/arch/ppc32/src/thread_entry.s	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+.text
+	
+.globl __thread_entry
+
+## User-space thread entry point for all but the first threads.
+#
+#
+__thread_entry:
+	b __thread_main
+
+.end __thread_entry
Index: uspace.config
===================================================================
--- uspace.config	(revision 3d7774721d7e8fdbfa8fbcedd136237f7beabc24)
+++ uspace.config	(revision 34c4d691d69bded69c4c1d3527d7605c5c121433)
@@ -7,4 +7,5 @@
 @ "mips32" MIPS 32-bit Little Endian
 @ "mips32eb" MIPS 32-bit Big Endian
+@ "ppc32" PowerPC 32-bit
 ! ARCH (choice)
 
