initial commit of lk (little kernel) project
diff --git a/include/arch.h b/include/arch.h
new file mode 100644
index 0000000..b9f93b6
--- /dev/null
+++ b/include/arch.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __ARCH_H
+#define __ARCH_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+void arch_early_init(void);
+void arch_init(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/arch/ops.h b/include/arch/ops.h
new file mode 100644
index 0000000..d5bafd0
--- /dev/null
+++ b/include/arch/ops.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __ARCH_OPS_H
+#define __ARCH_OPS_H
+
+#ifndef ASSEMBLY
+
+#include <sys/types.h>
+#include <compiler.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+void arch_enable_ints(void);
+void arch_disable_ints(void);
+
+int atomic_swap(volatile int *ptr, int val);
+int atomic_add(volatile int *ptr, int val);
+int atomic_and(volatile int *ptr, int val);
+int atomic_or(volatile int *ptr, int val);
+
+#endif // !ASSEMBLY
+#define ICACHE 1
+#define DCACHE 2
+#define UCACHE (ICACHE|DCACHE)
+#ifndef ASSEMBLY
+
+void arch_disable_cache(uint flags);
+void arch_enable_cache(uint flags);
+
+void arch_clean_cache_range(addr_t start, size_t len);
+void arch_clean_invalidate_cache_range(addr_t start, size_t len);
+	
+void arch_idle(void);
+
+void arch_disable_mmu(void);
+
+void arch_switch_stacks_and_call(addr_t call, addr_t stack) __NO_RETURN;
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // !ASSEMBLY
+
+#if ARCH_ARM
+#include <arch/arm/ops.h>
+#endif
+
+#endif
diff --git a/include/arch/thread.h b/include/arch/thread.h
new file mode 100644
index 0000000..06de51d
--- /dev/null
+++ b/include/arch/thread.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __ARCH_THREAD_H
+#define __ARCH_THREAD_H
+
+// give the arch code a chance to declare the arch_thread struct
+#include <arch/arch_thread.h>
+
+struct thread;
+
+void arch_thread_initialize(struct thread *);
+void arch_context_switch(struct thread *oldthread, struct thread *newthread);
+
+#endif
diff --git a/include/asm.h b/include/asm.h
new file mode 100644
index 0000000..dadf2c4
--- /dev/null
+++ b/include/asm.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __ASM_H
+#define __ASM_H
+
+//#define FUNCTION(x) .global x; .type x,@function; x:
+#define FUNCTION(x) .global x; x:
+
+#endif
+
diff --git a/include/assert.h b/include/assert.h
new file mode 100644
index 0000000..db58611
--- /dev/null
+++ b/include/assert.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __ASSERT_H
+#define __ASSERT_H
+
+#include <compiler.h>
+#include <platform/debug.h>
+
+#define ASSERT(x) \
+	do { if (unlikely(!(x))) { dprintf("ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); debug_halt(); } } while (0)
+
+#if DEBUG
+#define DEBUG_ASSERT(x) \
+	do { if (unlikely(!(x))) { dprintf("DEBUG ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); debug_halt(); } } while (0)
+#else
+#define DEBUG_ASSERT(x) \
+	do { } while(0)
+#endif
+
+#endif
diff --git a/include/bits.h b/include/bits.h
new file mode 100644
index 0000000..8643253
--- /dev/null
+++ b/include/bits.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __BITS_H
+#define __BITS_H
+
+#define clz(x) __builtin_clz(x)
+
+#define BIT(x, bit) ((x) & (1 << (bit)))
+#define BIT_SHIFT(x, bit) (((x) >> (bit)) & 1)
+#define BITS(x, high, low) ((x) & (((1<<((high)+1))-1) & ~((1<<(low))-1)))
+#define BITS_SHIFT(x, high, low) (((x) >> (low)) & ((1<<((high)-(low)+1))-1))
+#define BIT_SET(x, bit) (((x) & (1 << (bit))) ? 1 : 0)
+
+#endif
diff --git a/include/compiler.h b/include/compiler.h
new file mode 100644
index 0000000..cd4b243
--- /dev/null
+++ b/include/compiler.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __COMPILER_H
+#define __COMPILER_H
+
+#ifndef __ASSEMBLY__
+
+#if __GNUC__
+#define likely(x)       __builtin_expect(!!(x), 1)
+#define unlikely(x)     __builtin_expect(!!(x), 0)
+#define __UNUSED __attribute__((__unused__))
+#define __PACKED __attribute__((packed))
+#define __ALIGNED(x) __attribute__((aligned(x)))
+#define __PRINTFLIKE(__fmt,__varargs) __attribute__((__format__ (__printf__, __fmt, __varargs)))
+#define __SCANFLIKE(__fmt,__varargs) __attribute__((__format__ (__scanf__, __fmt, __varargs)))
+#define __SECTION(x) __attribute((section(x)))
+#define __PURE __attribute((pure))
+#define __CONST __attribute((const))
+#define __NO_RETURN __attribute__((noreturn)) 
+#define __MALLOC __attribute__((malloc))
+#define __WEAK __attribute__((weak))
+#define __GNU_INLINE __attribute__((gnu_inline))
+#define __GET_CALLER(x) __builtin_return_address(0)
+
+/* look for gcc 3.0 and above */
+#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 0)
+#define __ALWAYS_INLINE __attribute__((always_inline))
+#else
+#define __ALWAYS_INLINE
+#endif
+
+/* look for gcc 3.1 and above */
+#if !defined(__DEPRECATED) // seems to be built in in some versions of the compiler
+#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#define __DEPRECATED __attribute((deprecated))
+#else
+#define __DEPRECATED
+#endif
+#endif
+
+/* look for gcc 3.3 and above */
+#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
+/* the may_alias attribute was introduced in gcc 3.3; before that, there
+ * was no way to specify aliasiang rules on a type-by-type basis */
+#define __MAY_ALIAS __attribute__((may_alias)) 
+
+/* nonnull was added in gcc 3.3 as well */
+#define __NONNULL(x) __attribute((nonnull x))
+#else
+#define __MAY_ALIAS
+#define __NONNULL(x)
+#endif
+
+/* look for gcc 3.4 and above */
+#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#define __WARN_UNUSED_RESULT __attribute((warn_unused_result))
+#else
+#define __WARN_UNUSED_RESULT
+#endif
+
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
+#define __EXTERNALLY_VISIBLE __attribute__((externally_visible))
+#else
+#define __EXTERNALLY_VISIBLE
+#endif
+
+#else
+
+#define likely(x)       (x)
+#define unlikely(x)     (x)
+#define __UNUSED 
+#define __PACKED 
+#define __ALIGNED(x)
+#define __PRINTFLIKE(__fmt,__varargs)
+#define __SCANFLIKE(__fmt,__varargs)
+#define __SECTION(x)
+#define __PURE
+#define __CONST
+#define __NONNULL(x)
+#define __DEPRECATED
+#define __WARN_UNUSED_RESULT
+#define __ALWAYS_INLINE
+#define __MAY_ALIAS
+#define __NO_RETURN
+#endif
+
+#endif
+
+#endif
diff --git a/include/ctype.h b/include/ctype.h
new file mode 100644
index 0000000..7f9982e
--- /dev/null
+++ b/include/ctype.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __CTYPE_H
+#define __CTYPE_H
+
+int isalnum(int c);
+int isalpha(int c);
+int isblank(int c);
+int iscntrl(int c);
+int isdigit(int c);
+int isgraph(int c);
+int islower(int c);
+int isprint(int c);
+int ispunct(int c);
+int isspace(int c);
+int isupper(int c);
+int isxdigit(int c);
+
+int tolower(int c);
+int toupper(int c);
+
+#endif
+
diff --git a/include/debug.h b/include/debug.h
new file mode 100644
index 0000000..1013e87
--- /dev/null
+++ b/include/debug.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEBUG_H
+#define __DEBUG_H
+
+#include <assert.h>
+#include <platform/debug.h>
+#include <printf.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#if defined(DEBUG)
+#define DEBUGLEVEL DEBUG
+#else
+#define DEBUGLEVEL 2
+#endif
+
+/* systemwide halts */
+void halt(void) __NO_RETURN;
+
+void _panic(void *caller, const char *fmt, ...) __PRINTFLIKE(2, 3) __NO_RETURN;
+#define panic(x...) _panic(__GET_CALLER(), x)
+
+#define PANIC_UNIMPLEMENTED panic("%s unimplemented\n", __PRETTY_FUNCTION__)
+
+/* spin the cpu for a period of (short) time */
+void spin(uint32_t usecs);
+
+/* dump memory */
+void hexdump(const void *ptr, size_t len);
+void hexdump8(const void *ptr, size_t len);
+
+/* trace routines */
+#define TRACE_ENTRY printf("%s: entry\n", __PRETTY_FUNCTION__)
+#define TRACE_EXIT printf("%s: exit\n", __PRETTY_FUNCTION__)
+#define TRACE_ENTRY_OBJ printf("%s: entry obj %p\n", __PRETTY_FUNCTION__, this)
+#define TRACE_EXIT_OBJ printf("%s: exit obj %p\n", __PRETTY_FUNCTION__, this)
+#define TRACE printf("%s:%d\n", __PRETTY_FUNCTION__, __LINE__)
+#define TRACEF(x...) do { printf("%s:%d: ", __PRETTY_FUNCTION__, __LINE__); printf(x); } while (0)
+
+/* trace routines that work if LOCAL_TRACE is set */
+#define LTRACE_ENTRY do { if (LOCAL_TRACE) { TRACE_ENTRY; } } while (0)
+#define LTRACE_EXIT do { if (LOCAL_TRACE) { TRACE_EXIT; } } while (0)
+#define LTRACE do { if (LOCAL_TRACE) { TRACE; } } while (0)
+#define LTRACEF(x...) do { if (LOCAL_TRACE) { TRACEF(x); } } while (0)
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/dev/ethernet.h b/include/dev/ethernet.h
new file mode 100644
index 0000000..afb103e
--- /dev/null
+++ b/include/dev/ethernet.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEV_ETHERNET_H
+#define __DEV_ETHERNET_H
+
+/* Queue an ethernet frame for send.
+**
+** CRC and minimum length padding are handled by the driver.
+**
+** Data is malloc()'d and ownership is transfered to the ethernet
+** device which will free() it once the packet is transmitted.
+**
+*/
+int ethernet_send(void *data, unsigned length);
+
+status_t ethernet_init(void); /* initialize the ethernet device */
+
+#endif
diff --git a/include/dev/uart.h b/include/dev/uart.h
new file mode 100644
index 0000000..e3439dd
--- /dev/null
+++ b/include/dev/uart.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __DEV_UART_H
+#define __DEV_UART_H
+
+#include <sys/types.h>
+
+void uart_init(void);
+void uart_init_early(void);
+
+int uart_putc(int port, char c);
+int uart_getc(int port, bool wait);
+void uart_flush_tx(int port);
+void uart_flush_rx(int port);
+void uart_init_port(int port, uint baud);
+
+#endif
+
diff --git a/include/endian.h b/include/endian.h
new file mode 100644
index 0000000..30623b2
--- /dev/null
+++ b/include/endian.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __ENDIAN_H
+#define __ENDIAN_H
+
+#include <sys/types.h>
+
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 1234
+#endif
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN 4321
+#endif
+
+#if __POWERPC__
+#include <ppc_intrinsics.h>
+#endif
+
+#if defined(ARCH_ARM)
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+#ifndef BYTE_ORDER
+#error "need to get the BYTE_ORDER define from somewhere"
+#endif
+
+// define a macro that unconditionally swaps
+#define SWAP_32(x) \
+	(((uint32_t)(x) << 24) | (((uint32_t)(x) & 0xff00) << 8) |(((uint32_t)(x) & 0x00ff0000) >> 8) | ((uint32_t)(x) >> 24))
+#define SWAP_16(x) \
+	((((uint16_t)(x) & 0xff) << 8) | ((uint16_t)(x) >> 8))
+
+// standard swap macros
+#if BYTE_ORDER == BIG_ENDIAN
+#define LE32(val) SWAP_32(val)
+#define LE16(val) SWAP_16(val)
+#define BE32(val) (val)
+#define BE16(val) (val)
+#else
+#define LE32(val) (val)
+#define LE16(val) (val)
+#define BE32(val) SWAP_32(val)
+#define BE16(val) SWAP_16(val)
+#endif
+
+#define LE32SWAP(var) (var) = LE32(var);
+#define LE16SWAP(var) (var) = LE16(var);
+#define BE32SWAP(var) (var) = BE32(var);
+#define BE16SWAP(var) (var) = BE16(var);
+
+/* classic network byte swap stuff */
+#define ntohs(n) BE16(n)
+#define htons(h) BE16(h)
+#define ntohl(n) BE32(n)
+#define htonl(h) BE32(h)
+
+// some memory access macros
+#if __POWERPC__
+#define READ_MEM_WORD(ptr) 		__lwbrx((word *)(ptr), 0)
+#define READ_MEM_HALFWORD(ptr) 	__lhbrx((halfword *)(ptr), 0)
+#define READ_MEM_BYTE(ptr) 		(*(byte *)(ptr))
+#define WRITE_MEM_WORD(ptr, data) 	__stwbrx(data, (word *)(ptr), 0)
+#define WRITE_MEM_HALFWORD(ptr, data)	__sthbrx(data, (halfword *)(ptr), 0)
+#define WRITE_MEM_BYTE(ptr, data) 	(*(byte *)(ptr) = (data))
+#else
+#define READ_MEM_WORD(ptr) 		SWAPIT_32(*(word *)(ptr))
+#define READ_MEM_HALFWORD(ptr) 	SWAPIT_16(*(halfword *)(ptr))
+#define READ_MEM_BYTE(ptr) 		(*(byte *)(ptr))
+#define WRITE_MEM_WORD(ptr, data) 	(*(word *)(ptr) = SWAPIT_32(data))
+#define WRITE_MEM_HALFWORD(ptr, data)	(*(halfword *)(ptr) = SWAPIT_16(data))
+#define WRITE_MEM_BYTE(ptr, data) 	(*(byte *)(ptr) = (data))
+#endif
+
+
+#endif
diff --git a/include/err.h b/include/err.h
new file mode 100644
index 0000000..3b8b401
--- /dev/null
+++ b/include/err.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __ERR_H
+#define __ERR_H
+
+#define NO_ERROR 0
+#define ERROR -1
+#define ERR_NOT_FOUND -2
+#define ERR_NOT_READY -3
+#define ERR_NO_MSG -4
+#define ERR_NO_MEMORY -5
+#define ERR_ALREADY_STARTED -6
+#define ERR_NOT_VALID -7
+#define ERR_INVALID_ARGS -8
+#define ERR_NOT_ENOUGH_BUFFER -9
+#define ERR_NOT_SUSPENDED -10
+#define ERR_OBJECT_DESTROYED -11
+#define ERR_NOT_BLOCKED -12
+#define ERR_TIMED_OUT -13
+
+#endif
diff --git a/include/hw/mii.h b/include/hw/mii.h
new file mode 100644
index 0000000..0ff8979
--- /dev/null
+++ b/include/hw/mii.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2006 Brian Swetland
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __HW_MII_H
+#define __HW_MII_H
+
+#define MII_REG_BCR           0x00
+#define MII_REG_BSR           0x01
+#define MII_REG_PHY_ID1       0x02
+#define MII_REG_PHY_ID2       0x03
+#define MII_REG_AUTO_ADV      0x04
+#define MII_REG_AUTO_LINK     0x05
+#define MII_REG_AUTO_EXPN     0x06
+#define MII_REG_AUTO_NEXT     0x07
+#define MII_REG_LINK_NEXT     0x08
+#define MII_REG_RXER_CNT      0x15
+#define MII_REG_ICSR          0x1b
+#define MII_REG_100TX_PHY     0x1f
+
+#define MII_BCR_RESET         0x8000
+#define MII_BCR_LOOPBACK      0x4000
+#define MII_BCR_100MBPS       0x2000
+#define MII_BCR_AUTO_ENABLE   0x1000
+#define MII_BCR_PWR_DOWN      0x0800
+#define MII_BCR_ISOLATE       0x0400
+#define MII_BCR_AUTO_RESTART  0x0200
+#define MII_BCR_FULL_DUPLEX   0x0100
+#define MII_BCR_COL_TEST      0x0080
+#define MII_BCR_TX_DISABLE    0x0001
+
+#define MII_BSR_T4            0x8000
+#define MII_BSR_100TX_FULL    0x4000
+#define MII_BSR_100TX_HALF    0x2000
+#define MII_BSR_10T_FULL      0x1000
+#define MII_BSR_10T_HALF      0x0800
+#define MII_BSR_NO_PREAMBLE   0x0040
+#define MII_BSR_AUTO_COMPLETE 0x0020
+#define MII_BSR_REMOTE_FAULT  0x0010
+#define MII_BSR_AUTO_ABLE     0x0008
+#define MII_BSR_LINK_UP       0x0004
+#define MII_BSR_JABBER        0x0002
+#define MII_BSR_EXTEND        0x0001
+
+#define MII_100TX_PHY_ISOLATE  0x0040
+#define MII_100TX_MODE_MASK    0x001C
+#define MII_100TX_MODE_AUTO    0x0000
+#define MII_100TX_MODE_10T_H   0x0004
+#define MII_100TX_MODE_100TX_H 0x0008
+#define MII_100TX_MODE_10T_F   0x0014
+#define MII_100TX_MODE_100TX_F 0x0018
+#define MII_100TX_MODE_ISOLATE 0x001C
+#define MII_100TX_SQE_TEST     0x0002
+#define MII_100TX_NO_SCRAMBLE  0x0001
+
+#endif
diff --git a/include/inttypes.h b/include/inttypes.h
new file mode 100644
index 0000000..f6681e3
--- /dev/null
+++ b/include/inttypes.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __INTTYPES_H
+#define __INTTYPES_H
+
+#include <stdint.h>
+
+#endif
+
diff --git a/include/kernel/dpc.h b/include/kernel/dpc.h
new file mode 100644
index 0000000..9059e25
--- /dev/null
+++ b/include/kernel/dpc.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __KERNEL_DPC_H
+#define __KERNEL_DPC_H
+
+#include <list.h>
+#include <sys/types.h>
+
+void dpc_init(void);
+
+typedef void (*dpc_callback)(void *arg);
+
+#define DPC_FLAG_NORESCHED 0x1
+
+status_t dpc_queue(dpc_callback, void *arg, uint flags);
+
+#endif
+
diff --git a/include/kernel/event.h b/include/kernel/event.h
new file mode 100644
index 0000000..8a7fd1f
--- /dev/null
+++ b/include/kernel/event.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __KERNEL_EVENT_H
+#define __KERNEL_EVENT_H
+
+#include <kernel/thread.h>
+
+#define EVENT_MAGIC 'evnt'
+
+typedef struct event {
+	int magic;
+	bool signalled;
+	uint flags;
+	wait_queue_t wait;
+} event_t;
+
+#define EVENT_FLAG_AUTOUNSIGNAL 1
+
+void event_init(event_t *, bool initial, uint flags);
+void event_destroy(event_t *);
+status_t event_wait(event_t *);
+status_t event_wait_timeout(event_t *, time_t); /* wait on the event with a timeout */
+status_t event_signal(event_t *, bool reschedule);
+status_t event_unsignal(event_t *);
+
+#endif
+
diff --git a/include/kernel/mutex.h b/include/kernel/mutex.h
new file mode 100644
index 0000000..2bdf8f4
--- /dev/null
+++ b/include/kernel/mutex.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __KERNEL_MUTEX_H
+#define __KERNEL_MUTEX_H
+
+#include <kernel/thread.h>
+
+#define MUTEX_MAGIC 'mutx'
+
+typedef struct mutex {
+	int magic;
+	int count;
+	thread_t *holder;
+	wait_queue_t wait;
+} mutex_t;
+
+void mutex_init(mutex_t *);
+void mutex_destroy(mutex_t *);
+status_t mutex_acquire(mutex_t *);
+status_t mutex_acquire_timeout(mutex_t *, time_t); /* try to acquire the mutex with a timeout value */
+status_t mutex_release(mutex_t *);
+
+#endif
+
diff --git a/include/kernel/thread.h b/include/kernel/thread.h
new file mode 100644
index 0000000..7753ad4
--- /dev/null
+++ b/include/kernel/thread.h
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __KERNEL_THREAD_H
+#define __KERNEL_THREAD_H
+
+#include <sys/types.h>
+#include <list.h>
+#include <compiler.h>
+#include <arch/ops.h>
+#include <arch/thread.h>
+
+enum thread_state {
+	THREAD_SUSPENDED = 0,
+	THREAD_READY,
+	THREAD_RUNNING,
+	THREAD_BLOCKED,
+	THREAD_SLEEPING,
+	THREAD_DEATH,
+};
+
+typedef int (*thread_start_routine)(void *arg);
+
+#define THREAD_MAGIC 'thrd'
+
+typedef struct thread {
+	int magic;
+	struct list_node thread_list_node;
+
+	/* active bits */
+	struct list_node queue_node;
+	int priority;
+	enum thread_state state;	
+	int saved_critical_section_count;
+	int remaining_quantum;
+	
+	/* if blocked, a pointer to the wait queue */
+	struct wait_queue *blocking_wait_queue;
+	status_t wait_queue_block_ret;
+
+	/* architecture stuff */
+	struct arch_thread arch;
+
+	/* stack stuff */
+	void *stack;
+	size_t stack_size;
+
+	/* entry point */
+	thread_start_routine entry;
+	void *arg;
+
+	/* return code */
+	int retcode;
+
+	char name[32];
+} thread_t;
+
+/* thread priority */
+#define NUM_PRIORITIES 32
+#define LOWEST_PRIORITY 0
+#define HIGHEST_PRIORITY (NUM_PRIORITIES - 1)
+#define DPC_PRIORITY (NUM_PRIORITIES - 2)
+#define IDLE_PRIORITY LOWEST_PRIORITY
+#define LOW_PRIORITY (NUM_PRIORITIES / 4)
+#define DEFAULT_PRIORITY (NUM_PRIORITIES / 2)
+#define HIGH_PRIORITY ((NUM_PRIORITIES / 4) * 3)
+
+/* stack size */
+#define DEFAULT_STACK_SIZE 8192
+
+/* functions */
+void thread_init(void);
+void thread_become_idle(void) __NO_RETURN;
+void thread_set_name(const char *name);
+void thread_set_priority(int priority);
+thread_t *thread_create(const char *name, thread_start_routine entry, void *arg, int priority, size_t stack_size);
+status_t thread_resume(thread_t *);
+void thread_exit(int retcode) __NO_RETURN;
+void thread_sleep(time_t delay);
+
+void dump_thread(thread_t *t);
+void dump_all_threads(void);
+
+/* scheduler routines */
+void thread_yield(void); /* give up the cpu voluntarily */
+void thread_preempt(void); /* get preempted (inserted into head of run queue) */
+void thread_block(void); /* block on something and reschedule */
+
+/* called on every timer tick for the scheduler to do quantum expiration */
+enum handler_return thread_timer_tick(void);
+
+/* the current thread */
+extern thread_t *current_thread;
+
+/* the idle thread */
+extern thread_t *idle_thread;
+
+/* critical sections */
+extern int critical_section_count;
+
+static inline void enter_critical_section(void)
+{
+	critical_section_count++;
+	if (critical_section_count == 1)
+		arch_disable_ints();
+}
+
+static inline void exit_critical_section(void)
+{
+	critical_section_count--;
+	if (critical_section_count == 0)
+		arch_enable_ints();
+}
+
+static inline bool in_critical_section(void)
+{
+	return critical_section_count > 0;
+}
+
+/* only used by interrupt glue */
+static inline void inc_critical_section(void) { critical_section_count++; }
+static inline void dec_critical_section(void) { critical_section_count--; }
+
+/* wait queue stuff */
+#define WAIT_QUEUE_MAGIC 'wait'
+
+typedef struct wait_queue {
+	int magic;
+	struct list_node list;
+	int count;
+} wait_queue_t;
+
+/* wait queue primitive */
+/* NOTE: must be inside critical section when using these */
+void wait_queue_init(wait_queue_t *);
+
+/* 
+ * release all the threads on this wait queue with a return code of ERR_OBJECT_DESTROYED.
+ * the caller must assure that no other threads are operating on the wait queue during or
+ * after the call.
+ */
+void wait_queue_destroy(wait_queue_t *, bool reschedule);
+
+/*
+ * block on a wait queue.
+ * return status is whatever the caller of wait_queue_wake_*() specifies.
+ * a timeout other than INFINITE_TIME will set abort after the specified time
+ * and return ERR_TIMED_OUT. a timeout of 0 will immediately return.
+ */
+status_t wait_queue_block(wait_queue_t *, time_t timeout);
+
+/* 
+ * release one or more threads from the wait queue.
+ * reschedule = should the system reschedule if any is released.
+ * wait_queue_error = what wait_queue_block() should return for the blocking thread.
+ */
+int wait_queue_wake_one(wait_queue_t *, bool reschedule, status_t wait_queue_error);
+int wait_queue_wake_all(wait_queue_t *, bool reschedule, status_t wait_queue_error);
+
+/* 
+ * remove the thread from whatever wait queue it's in.
+ * return an error if the thread is not currently blocked (or is the current thread) 
+ */
+status_t thread_unblock_from_wait_queue(thread_t *t, bool reschedule, status_t wait_queue_error);
+
+/* thread level statistics */
+#define THREAD_STATS 0
+#if THREAD_STATS
+struct thread_stats {
+	bigtime_t idle_time;
+	bigtime_t last_idle_timestamp;
+	int reschedules;
+	int context_switches;
+	int preempts;
+	int yields;
+	int interrupts; /* platform code increment this */
+	int timer_ints; /* timer code increment this */
+	int timers; /* timer code increment this */
+};
+
+extern struct thread_stats thread_stats;
+
+#endif
+
+#endif
+
diff --git a/include/kernel/timer.h b/include/kernel/timer.h
new file mode 100644
index 0000000..f13ee5d
--- /dev/null
+++ b/include/kernel/timer.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __KERNEL_TIMER_H
+#define __KERNEL_TIMER_H
+
+#include <list.h>
+#include <sys/types.h>
+
+void timer_init(void);
+
+struct timer;
+typedef enum handler_return (*timer_callback)(struct timer *, time_t now, void *arg);
+
+#define TIMER_MAGIC 'timr'
+
+typedef struct timer {
+	int magic;
+	struct list_node node;
+
+	time_t scheduled_time;
+	time_t periodic_time;
+
+	timer_callback callback;
+	void *arg;
+} timer_t;
+
+void timer_initialize(timer_t *);
+void timer_set_oneshot(timer_t *, time_t delay, timer_callback, void *arg);
+void timer_set_periodic(timer_t *, time_t period, timer_callback, void *arg);
+void timer_cancel(timer_t *);
+
+#endif
+
diff --git a/include/lib/heap.h b/include/lib/heap.h
new file mode 100644
index 0000000..54ea73b
--- /dev/null
+++ b/include/lib/heap.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __LIB_HEAP_H
+#define __LIB_HEAP_H
+
+#include <sys/types.h>
+
+void *heap_alloc(size_t, unsigned int alignment);
+void heap_free(void *);
+
+void heap_init(void);
+
+
+
+#endif
diff --git a/include/list.h b/include/list.h
new file mode 100644
index 0000000..96cd0d4
--- /dev/null
+++ b/include/list.h
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __LIST_H
+#define __LIST_H
+
+#include <sys/types.h>
+
+#define containerof(ptr, type, member) \
+	((type *)((addr_t)(ptr) - offsetof(type, member)))
+
+struct list_node {
+	struct list_node *prev;
+	struct list_node *next;
+};
+
+#define LIST_INITIAL_VALUE(list) { &(list), &(list) }
+
+static inline void list_initialize(struct list_node *list)
+{
+	list->prev = list->next = list;
+}
+
+static inline void list_clear_node(struct list_node *item)
+{
+	item->prev = item->next = 0;
+}
+
+static inline bool list_in_list(struct list_node *item)
+{
+	if (item->prev == 0 && item->next == 0)
+		return false;
+	else
+		return true;
+}
+
+static inline void list_add_head(struct list_node *list, struct list_node *item)
+{
+	item->next = list->next;
+	item->prev = list;
+	list->next->prev = item;
+	list->next = item;
+}
+
+#define list_add_after(entry, new_entry) list_add_head(entry, new_entry)
+
+static inline void list_add_tail(struct list_node *list, struct list_node *item)
+{
+	item->prev = list->prev;
+	item->next = list;
+	list->prev->next = item;
+	list->prev = item;
+}
+
+#define list_add_before(entry, new_entry) list_add_tail(entry, new_entry)
+
+static inline void list_delete(struct list_node *item)
+{
+	item->next->prev = item->prev;
+	item->prev->next = item->next;
+	item->prev = item->next = 0;
+}
+
+static inline struct list_node* list_remove_head(struct list_node *list)
+{
+	if(list->next != list) {
+		struct list_node *item = list->next;
+		list_delete(item);
+		return item;
+	} else {
+		return NULL;
+	}
+}
+
+#define list_remove_head_type(list, type, element) ({\
+    struct list_node *__nod = list_remove_head(list);\
+    type *__t;\
+    if(__nod)\
+        __t = containerof(__nod, type, element);\
+    else\
+        __t = (type *)0;\
+    __t;\
+})
+
+static inline struct list_node* list_remove_tail(struct list_node *list)
+{
+	if(list->prev != list) {
+		struct list_node *item = list->prev;
+		list_delete(item);
+		return item;
+	} else {
+		return NULL;
+	}
+}
+
+#define list_remove_tail_type(list, type, element) ({\
+    struct list_node *__nod = list_remove_tail(list);\
+    type *__t;\
+    if(__nod)\
+        __t = containerof(__nod, type, element);\
+    else\
+        __t = (type *)0;\
+    __t;\
+})
+
+static inline struct list_node* list_peek_head(struct list_node *list)
+{
+	if(list->next != list) {
+		return list->next;
+	} else {
+		return NULL;
+	}	
+}
+
+#define list_peek_head_type(list, type, element) ({\
+    struct list_node *__nod = list_peek_head(list);\
+    type *__t;\
+    if(__nod)\
+        __t = containerof(__nod, type, element);\
+    else\
+        __t = (type *)0;\
+    __t;\
+})
+
+static inline struct list_node* list_peek_tail(struct list_node *list)
+{
+	if(list->prev != list) {
+		return list->prev;
+	} else {
+		return NULL;
+	}	
+}
+
+#define list_peek_tail_type(list, type, element) ({\
+    struct list_node *__nod = list_peek_tail(list);\
+    type *__t;\
+    if(__nod)\
+        __t = containerof(__nod, type, element);\
+    else\
+        __t = (type *)0;\
+    __t;\
+})
+
+static inline struct list_node* list_prev(struct list_node *list, struct list_node *item)
+{
+	if(item->prev != list)
+		return item->prev;
+	else
+		return NULL;
+}
+
+#define list_prev_type(list, item, type, element) ({\
+    struct list_node *__nod = list_prev(list, item);\
+    type *__t;\
+    if(__nod)\
+        __t = containerof(__nod, type, element);\
+    else\
+        __t = (type *)0;\
+    __t;\
+})
+
+static inline struct list_node* list_prev_wrap(struct list_node *list, struct list_node *item)
+{
+	if(item->prev != list)
+		return item->prev;
+	else if(item->prev->prev != list)
+		return item->prev->prev;
+	else
+		return NULL;
+}
+
+#define list_prev_wrap_type(list, item, type, element) ({\
+    struct list_node *__nod = list_prev_wrap(list, item);\
+    type *__t;\
+    if(__nod)\
+        __t = containerof(__nod, type, element);\
+    else\
+        __t = (type *)0;\
+    __t;\
+})
+
+static inline struct list_node* list_next(struct list_node *list, struct list_node *item)
+{
+	if(item->next != list)
+		return item->next;
+	else
+		return NULL;
+}
+
+#define list_next_type(list, item, type, element) ({\
+    struct list_node *__nod = list_next(list, item);\
+    type *__t;\
+    if(__nod)\
+        __t = containerof(__nod, type, element);\
+    else\
+        __t = (type *)0;\
+    __t;\
+})
+
+static inline struct list_node* list_next_wrap(struct list_node *list, struct list_node *item)
+{
+	if(item->next != list)
+		return item->next;
+	else if(item->next->next != list)
+		return item->next->next;
+	else
+		return NULL;
+}
+
+#define list_next_wrap_type(list, item, type, element) ({\
+    struct list_node *__nod = list_next_wrap(list, item);\
+    type *__t;\
+    if(__nod)\
+        __t = containerof(__nod, type, element);\
+    else\
+        __t = (type *)0;\
+    __t;\
+})
+
+// iterates over the list, node should be struct list_node*
+#define list_for_every(list, node) \
+	for(node = (list)->next; node != (list); node = node->next)
+
+// iterates over the list in a safe way for deletion of current node
+// node and temp_node should be struct list_node*
+#define list_for_every_safe(list, node, temp_node) \
+	for(node = (list)->next, temp_node = (node)->next;\
+	node != (list);\
+	node = temp_node, temp_node = (node)->next)
+
+// iterates over the list, entry should be the container structure type *
+#define list_for_every_entry(list, entry, type, member) \
+	for((entry) = containerof((list)->next, type, member);\
+		&(entry)->member != (list);\
+		(entry) = containerof((entry)->member.next, type, member))
+
+// iterates over the list in a safe way for deletion of current node
+// entry and temp_entry should be the container structure type *
+#define list_for_every_entry_safe(list, entry, temp_entry, type, member) \
+	for(entry = containerof((list)->next, type, member),\
+		temp_entry = containerof((entry)->member.next, type, member);\
+		&(entry)->member != (list);\
+		entry = temp_entry, temp_entry = containerof((temp_entry)->member.next, type, member))
+
+static inline bool list_is_empty(struct list_node *list)
+{
+	return (list->next == list) ? true : false;
+}
+
+#endif
diff --git a/include/malloc.h b/include/malloc.h
new file mode 100644
index 0000000..d48f6d2
--- /dev/null
+++ b/include/malloc.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __MALLOC_H
+#define __MALLOC_H
+
+#include <sys/types.h>
+#include <compiler.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+void *malloc(size_t size) __MALLOC;
+void *memalign(size_t boundary, size_t size) __MALLOC;
+void *calloc(size_t count, size_t size) __MALLOC;
+void free(void *ptr);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
+
diff --git a/include/new.h b/include/new.h
new file mode 100644
index 0000000..d150c18
--- /dev/null
+++ b/include/new.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __NEW_H
+#define __NEW_H
+
+#include <sys/types.h>
+
+void *operator new(size_t);
+void *operator new(size_t, void *ptr);
+void *operator new[](size_t);
+void *operator new[](size_t, void *ptr);
+void operator delete(void *p);
+void operator delete[](void *p);
+
+#endif
diff --git a/include/platform.h b/include/platform.h
new file mode 100644
index 0000000..5f7e303
--- /dev/null
+++ b/include/platform.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __PLATFORM_H
+#define __PLATFORM_H
+
+time_t current_time(void);
+bigtime_t current_time_hires(void);
+
+/* super early platform initialization, before almost everything */
+void platform_early_init(void);
+
+/* later init, after the kernel has come up */
+void platform_init(void);
+
+/* called by the arch init code to get the platform to set up any mmu mappings it may need */
+void platform_init_mmu_mappings(void);
+
+#endif
diff --git a/include/platform/debug.h b/include/platform/debug.h
new file mode 100644
index 0000000..2a48006
--- /dev/null
+++ b/include/platform/debug.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __PLATFORM_DEBUG_H
+#define __PLATFORM_DEBUG_H
+
+#include <sys/types.h>
+#include <stdarg.h>
+#include <compiler.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+void dputc(char c);
+int dgetc(char *c);
+int dputs(const char *str);
+int dprintf(const char *fmt, ...) __PRINTFLIKE(1, 2);
+int dvprintf(const char *fmt, va_list ap);
+void debug_dump_regs(void);
+uint32_t debug_cycle_count(void);
+
+void debug_dump_memory_bytes(void *mem, int len);
+void debug_dump_memory_halfwords(void *mem, int len);
+void debug_dump_memory_words(void *mem, int len);
+
+void debug_set_trace_level(int trace_type, int level);
+
+void debug_halt(void) __NO_RETURN;
+
+#if defined(__cplusplus)
+}
+#endif
+
+
+#endif
+
diff --git a/include/platform/interrupts.h b/include/platform/interrupts.h
new file mode 100644
index 0000000..7f563a5
--- /dev/null
+++ b/include/platform/interrupts.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __PLATFORM_INTERRUPTS_H
+#define __PLATFORM_INTERRUPTS_H
+
+#include <sys/types.h>
+
+status_t mask_interrupt(unsigned int vector, bool *oldstate);
+status_t unmask_interrupt(unsigned int vector, bool *oldstate);
+
+typedef enum handler_return (*int_handler)(void *arg);
+
+void register_int_handler(unsigned int vector, int_handler handler, void *arg);
+
+#endif
diff --git a/include/platform/timer.h b/include/platform/timer.h
new file mode 100644
index 0000000..2a6e617
--- /dev/null
+++ b/include/platform/timer.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __PLATFORM_TIMER_H
+#define __PLATFORM_TIMER_H
+
+typedef enum handler_return (*platform_timer_callback)(void *arg, time_t now);
+
+status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, time_t interval);
+
+#endif
+
diff --git a/include/printf.h b/include/printf.h
new file mode 100644
index 0000000..5006530
--- /dev/null
+++ b/include/printf.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __LIB_PRINTF_H
+#define __LIB_PRINTF_H
+
+#include <stdarg.h>
+#include <compiler.h>
+#include <debug.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int printf(const char *fmt, ...);
+int sprintf(char *str, const char *fmt, ...) __PRINTFLIKE(2, 3);
+int vsprintf(char *str, const char *fmt, va_list ap);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/include/project.h b/include/project.h
new file mode 100644
index 0000000..a25ffd6
--- /dev/null
+++ b/include/project.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __PROJECT_H
+#define __PROJECT_H
+
+void project_init(void);
+
+#endif
+
diff --git a/include/rand.h b/include/rand.h
new file mode 100644
index 0000000..907cf20
--- /dev/null
+++ b/include/rand.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __RAND_H
+#define __RAND_H
+
+int rand(void);
+
+#endif
+
diff --git a/include/reg.h b/include/reg.h
new file mode 100644
index 0000000..4b880dd
--- /dev/null
+++ b/include/reg.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __REG_H
+#define __REG_H
+
+#include <sys/types.h>
+
+/* low level macros for accessing memory mapped hardware registers */
+#define REG64(addr) ((volatile uint64_t *)(addr))
+#define REG32(addr) ((volatile uint32_t *)(addr))
+#define REG16(addr) ((volatile uint16_t *)(addr))
+#define REG8(addr) ((volatile uint8_t *)(addr))
+
+#endif
diff --git a/include/stdint.h b/include/stdint.h
new file mode 100644
index 0000000..0ea9e8a
--- /dev/null
+++ b/include/stdint.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __STDINT_H
+#define __STDINT_H
+
+typedef unsigned char      uint8_t;
+typedef unsigned short     uint16_t;
+typedef unsigned int       uint32_t;
+typedef unsigned long long uint64_t;
+typedef signed char int8_t;
+typedef short     int16_t;
+typedef int       int32_t;
+typedef long long int64_t;
+
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
+
+typedef int8_t int_fast8_t;
+typedef int16_t int_fast16_t;
+typedef int32_t int_fast32_t;
+typedef int64_t int_fast64_t;
+typedef uint8_t uint_fast8_t;
+typedef uint16_t uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+typedef uint64_t uint_fast64_t;
+
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+
+typedef long long intmax_t;
+typedef unsigned long long uintmax_t;
+
+#endif
+
diff --git a/include/stdlib.h b/include/stdlib.h
new file mode 100644
index 0000000..fb1e1de
--- /dev/null
+++ b/include/stdlib.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __STDLIB_H
+#define __STDLIB_H
+
+#include <sys/types.h>
+#include <stddef.h>
+#include <malloc.h>
+#include <printf.h>
+#include <endian.h>
+#include <arch/defines.h>
+
+int atoi(const char *num);
+unsigned int atoui(const char *num);
+long atol(const char *num);
+unsigned long atoul(const char *num);
+
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+
+#define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
+#define ROUNDDOWN(a, b) ((a) & ~((b)-1))
+
+/* allocate a buffer on the stack aligned and padded to the cpu's cache line size */
+#define STACKBUF_DMA_ALIGN(var, size) \
+	uint8_t __##var[(size) + CACHE_LINE]; uint8_t *var = (uint8_t *)(ROUNDUP((addr_t)__##var, CACHE_LINE))
+
+#endif
+
diff --git a/include/string.h b/include/string.h
new file mode 100644
index 0000000..3dccd92
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __LIB_STRING_H
+#define __LIB_STRING_H
+
+#include <sys/types.h>
+#include <compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *memchr (void const *, int, size_t) __PURE;
+int   memcmp (void const *, const void *, size_t) __PURE;
+void *memcpy (void *, void const *, size_t);
+void *memmove(void *, void const *, size_t);
+void *memset (void *, int, size_t);
+
+char       *strcat(char *, char const *);
+char       *strchr(char const *, int) __PURE;
+int         strcmp(char const *, char const *) __PURE;
+char       *strcpy(char *, char const *);
+char const *strerror(int) __CONST;
+size_t      strlen(char const *) __PURE;
+char       *strncat(char *, char const *, size_t);
+int         strncmp(char const *, char const *, size_t) __PURE;
+char       *strncpy(char *, char const *, size_t);
+char       *strpbrk(char const *, char const *) __PURE;
+char       *strrchr(char const *, int) __PURE;
+size_t      strspn(char const *, char const *) __PURE;
+size_t      strcspn(const char *s, const char *) __PURE;
+char       *strstr(char const *, char const *) __PURE;
+char       *strtok(char *, char const *);
+int         strcoll(const char *s1, const char *s2) __PURE;
+size_t      strxfrm(char *dest, const char *src, size_t n) __PURE;
+char       *strdup(const char *str) __MALLOC;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* non standard */
+void  *bcopy(void const *, void *, size_t);
+void   bzero(void *, size_t);
+size_t strlcat(char *, char const *, size_t);
+size_t strlcpy(char *, char const *, size_t);
+int    strncasecmp(char const *, char const *, size_t)  __PURE;
+int    strnicmp(char const *, char const *, size_t) __PURE;
+size_t strnlen(char const *s, size_t count) __PURE;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/types.h b/include/sys/types.h
new file mode 100644
index 0000000..12103a9
--- /dev/null
+++ b/include/sys/types.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __SYS_TYPES_H
+#define __SYS_TYPES_H
+
+#ifndef __cplusplus
+#define false 0
+#define true 1
+typedef int bool;
+#endif
+
+#include <stddef.h>
+#include <limits.h>
+#include <stdint.h>
+
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+
+typedef unsigned long size_t;
+typedef long          ssize_t;
+typedef long long     off_t;
+
+typedef int status_t;
+
+typedef uintptr_t addr_t;
+typedef uintptr_t vaddr_t;
+typedef uintptr_t paddr_t;
+
+typedef int kobj_id;
+
+typedef unsigned long time_t;
+typedef unsigned long long bigtime_t;
+#define INFINITE_TIME ULONG_MAX
+
+enum handler_return {
+	INT_NO_RESCHEDULE = 0,
+	INT_RESCHEDULE,
+};
+
+#endif
diff --git a/include/target.h b/include/target.h
new file mode 100644
index 0000000..0464d90
--- /dev/null
+++ b/include/target.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __TARGET_H
+#define __TARGET_H
+
+/* super early platform initialization, before almost everything */
+void target_early_init(void);
+
+/* later init, after the kernel has come up */
+void target_init(void);
+
+#endif