diff --git a/SConstruct b/SConstruct
index 7b13608..b6a163a 100644
--- a/SConstruct
+++ b/SConstruct
@@ -27,7 +27,6 @@ arch = config_shelve["arch"]
subarch = config_shelve["subarch"]
platform = config_shelve["platform"]
all_syms = config_shelve["all_symbols"]
-print all_syms
objects = []
objects += SConscript('src/drivers/SConscript', exports = {'symbols' : all_syms, 'env' : env})
diff --git a/libs/c/src/ctype.c b/config/__init__.py
similarity index 100%
rename from libs/c/src/ctype.c
rename to config/__init__.py
diff --git a/configs/arm.cml b/config/cml/arm.cml
similarity index 100%
rename from configs/arm.cml
rename to config/cml/arm.cml
diff --git a/config/configuration.py b/config/configuration.py
new file mode 100644
index 0000000..d657b9a
--- /dev/null
+++ b/config/configuration.py
@@ -0,0 +1,47 @@
+#! /usr/bin/env python2.6
+# -*- mode: python; coding: utf-8; -*-
+
+import os, sys, shelve, shutil
+
+class config_symbols:
+ arch = None
+ subarch = None
+ platform = None
+ kbuild = []
+ all = []
+
+ # Get all name value symbols
+ def get_all(self, name, val):
+ self.all.append([name, val])
+
+ # Convert line to name value pair, if possible
+ def line_to_name_value(self, line):
+ parts = line.split()
+ if len(parts) > 0:
+ if parts[0] == "#define":
+ return parts[1], parts[2]
+ return None
+
+ # Extract architecture from a name value pair
+ def get_arch(self, name, val):
+ if name[:len("CONFIG_ARCH_")] == "CONFIG_ARCH_":
+ parts = name.split("_", 3)
+ self.arch = parts[2].lower()
+
+ # Extract subarch from a name value pair
+ def get_subarch(self, name, val):
+ if name[:len("CONFIG_SUBARCH_")] == "CONFIG_SUBARCH_":
+ parts = name.split("_", 3)
+ self.subarch = parts[2].lower()
+
+ # Extract platform from a name value pair
+ def get_platform(self, name, val):
+ if name[:len("CONFIG_PLATFORM_")] == "CONFIG_PLATFORM_":
+ parts = name.split("_", 3)
+ self.platform = parts[2].lower()
+
+ # Extract number of containers
+ def get_ncontainers(self, name, val):
+ if name[:len("CONFIG_CONTAINERS")] == "CONFIG_CONTAINERS":
+ self.ncontainers = val
+
diff --git a/config/projpaths.py b/config/projpaths.py
new file mode 100644
index 0000000..fc30496
--- /dev/null
+++ b/config/projpaths.py
@@ -0,0 +1,20 @@
+#! /usr/bin/env python2.6
+# -*- mode: python; coding: utf-8; -*-
+
+import os, sys, shelve, shutil
+from os.path import join
+
+# Way to get project root from any script importing this one :-)
+PROJROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+
+BUILDDIR = join(PROJROOT, "build")
+TOOLSDIR = join(PROJROOT, "tools")
+CML2_CONFIG_SRCDIR = join(PROJROOT, "config/cml")
+CML2TOOLSDIR = join(TOOLSDIR, "cml2-tools")
+CML2RULES = join(BUILDDIR, "cml2_rules.out")
+CML2_CONFIG_PROPERTIES = join(BUILDDIR, "cml2_config.out")
+CML2_CONFIG_H = join(BUILDDIR, "cml2_config.h")
+CONFIG_H = join("include/l4/config.h")
+CONFIG_SHELVE_DIR = join(BUILDDIR, "configdata")
+CONFIG_SHELVE_FILENAME = "configuration"
+CONFIG_SHELVE = join(CONFIG_SHELVE_DIR, CONFIG_SHELVE_FILENAME)
diff --git a/configure.py b/configure.py
index 00e9cf4..d063fbd 100755
--- a/configure.py
+++ b/configure.py
@@ -3,61 +3,8 @@
import os, sys, shelve, shutil
from os.path import join
-
-PROJROOT = os.getcwd()
-BUILDDIR = join(PROJROOT, "build")
-TOOLSDIR = join(PROJROOT, "tools")
-CML2TOOLSDIR = join(TOOLSDIR, "cml2-tools")
-CML2RULES = join(BUILDDIR, "cml2_rules.out")
-CML2_CONFIG_PROPERTIES = join(BUILDDIR, "cml2_config.out")
-CML2_CONFIG_H = join(BUILDDIR, "cml2_config.h")
-CONFIG_H = join("include/l4/config.h")
-CONFIG_SHELVE_DIR = join(BUILDDIR, "configdata")
-CONFIG_SHELVE_FILENAME = "configuration"
-CONFIG_SHELVE = join(CONFIG_SHELVE_DIR, CONFIG_SHELVE_FILENAME)
-configuration = {}
-
-class config_symbols:
- arch = None
- subarch = None
- platform = None
- kbuild = []
- all = []
-
- # Get all name value symbols
- def get_all(self, name, val):
- self.all.append([name, val])
-
- # Convert line to name value pair, if possible
- def line_to_name_value(self, line):
- parts = line.split()
- if len(parts) > 0:
- if parts[0] == "#define":
- return parts[1], parts[2]
- return None
-
- # Extract architecture from a name value pair
- def get_arch(self, name, val):
- if name[:len("CONFIG_ARCH_")] == "CONFIG_ARCH_":
- parts = name.split("_", 3)
- self.arch = parts[2].lower()
-
- # Extract subarch from a name value pair
- def get_subarch(self, name, val):
- if name[:len("CONFIG_SUBARCH_")] == "CONFIG_SUBARCH_":
- parts = name.split("_", 3)
- self.subarch = parts[2].lower()
-
- # Extract platform from a name value pair
- def get_platform(self, name, val):
- if name[:len("CONFIG_PLATFORM_")] == "CONFIG_PLATFORM_":
- parts = name.split("_", 3)
- self.platform = parts[2].lower()
-
- # Extract number of containers
- def get_ncontainers(self, name, val):
- if name[:len("CONFIG_CONTAINERS")] == "CONFIG_CONTAINERS":
- self.ncontainers = val
+from config.projpaths import *
+from config.configuration import *
symbols = config_symbols()
@@ -92,7 +39,7 @@ def save_configuration():
os.mkdir(CONFIG_SHELVE_DIR)
config_shelve = shelve.open(CONFIG_SHELVE)
- #config_shelve["config_symbols"] = symbols
+ config_shelve["config_symbols"] = symbols
config_shelve["arch"] = symbols.arch
config_shelve["subarch"] = symbols.subarch
config_shelve["platform"] = symbols.platform
@@ -109,4 +56,4 @@ def configure_kernel(cml_file):
save_configuration()
if __name__ == "__main__":
- configure_kernel("configs/arm.cml")
+ configure_kernel(join(CML2_CONFIG_SRCDIR, "arm.cml"))
diff --git a/conts/libl4/SConscript b/conts/libl4/SConscript
index 020dd9d..d0a213b 100644
--- a/conts/libl4/SConscript
+++ b/conts/libl4/SConscript
@@ -27,8 +27,6 @@ e.Append(CPPPATH = ['include'])
e['CCFLAGS'] = ['-g', '-nostdlib', '-Wall', '-ffreestanding', '-std=gnu99']
objects = e.StaticObject(Glob('src/*.c') + Glob('src/' + e['ARCH'] + '/*.[cS]'))
-Depends(objects, e['configFiles'])
library = e.StaticLibrary('l4', objects)
-Depends(library, e['configFiles'])
Return('library')
diff --git a/libs/c/SConscript b/libs/c/SConscript
deleted file mode 100644
index fa5bf9c..0000000
--- a/libs/c/SConscript
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- mode: python; coding: utf-8; -*-
-
-# Codezero -- a microkernel for embedded systems.
-#
-# Copyright © 2009 B Labs Ltd
-#
-# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
-# General Public License as published by the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-# License for more details.
-#
-# You should have received a copy of the GNU General Public License along with this program. If not, see
-# .
-#
-# Author: Russel Winder
-
-Import('environment', 'variant')
-
-e = environment.Clone()
-e.Append(CPPPATH = ['include', 'include/sys-' + variant + '/arch-' + environment['ARCH']])
-e.Append(CCFLAGS = '-nostdinc')
-
-source = \
- Glob('src/*.c') + \
- Glob('src/sys-' + variant + '/*.c') + \
- Glob('src/sys-' + variant + '/arch-' + e['ARCH'] + '/*.c') + \
- Glob('src/sys-' + variant + '/arch-' + e['ARCH'] + '/plat-' + e['PLATFORM'] + '/*.c') + \
- Glob('src/arch-' + e['ARCH'] + '/*.c') + \
- Glob('src/arch-' + e['ARCH'] + '/*.S')
-
-objects = e.StaticObject(source)
-Depends (objects, e['configFiles'])
-library = e.StaticLibrary('c-' + variant, objects)
-Depends (library, e['configFiles'])
-runTime = e.StaticObject('crt/sys-' + variant + '/arch-' + e['ARCH'] + '/crt0.S')
-Depends (runTime, e['configFiles'])
-
-result = (library, runTime)
-
-Return('result')
diff --git a/loader/SConscript b/loader/SConscript
deleted file mode 100644
index ebfc52d..0000000
--- a/loader/SConscript
+++ /dev/null
@@ -1,136 +0,0 @@
-# -*- mode: python; coding: utf-8; -*-
-
-# Codezero -- a microkernel for embedded systems.
-#
-# Copyright © 2009 B Labs Ltd
-#
-# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
-# General Public License as published by the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-# License for more details.
-#
-# You should have received a copy of the GNU General Public License along with this program. If not, see
-# .
-#
-# Author: Russel Winder
-
-import os.path
-import subprocess
-
-Import('environment', 'images', 'libsInOrder')
-
-e = environment.Clone()
-e.Append(LINKFLAGS = ['-T' + e['buildDirectory'] + '/loader/linker.lds'])
-e.Append(LIBS = libsInOrder)
-e.Append(CPPPATH = ['#libs/elf/include', '#' + e['buildDirectory'] + '/loader'])
-
-def convertAddress(address):
- '''Convert the string representation of the address given as parameter to a string representation of the
- address without the top four bits set. The issue here is that Python has a penchant for adding L to the
- end to create a Python literal. This is not wanted here.'''
- value = hex(int(address, 16) - 0xf0000000)
- if value[-1] in ['l', 'L']:
- value = value[:-1]
- return value
-
-def ksymToLds(target, source, env):
- symbols = ['break_virtual']
- with open(target[0].path, 'w') as asmFile:
- asmFile.write('''
-/*
- * %s autogenerated from %s.
- *
- * This file is included by the loader sources so that any
- * kernel symbol address can be known in advance and stopped
- * at by debuggers before virtual memory is enabled.
- */
-''' % (target[0].name, source[0].name))
- for symbol in symbols:
- process = subprocess.Popen('arm-none-eabi-objdump -d ' + source[0].path + ' | grep "<' + symbol + '>"', shell=True, stdout=subprocess.PIPE)
- assert process.wait() == 0
- address, name = process.stdout.read().split()
- assert '<' + symbol + '>:' == name
- asmFile.write( '''
-.section .text
-.align 4
-.global %s
-.type %s, function
-.equ %s, %s
-''' % (symbol, symbol, symbol, convertAddress(address)))
-
-
-container_assembler_start = \
-'''
-.align 4
-.section .kernel
-.incbin "%s"
-'''
-
-container_assembler_body = \
-'''
-.align 4
-.section .cont.%d
-.incbin "%s"
-'''
-
-container_lds_start = \
-'''/*
- * Autogenerated linker script that embeds each container image.
- *
- * Copyright (C) 2009 B Labs
- */
-
-SECTIONS
-{'''
-
-container_lds_body = \
-'''
- .cont.%d : { *(.cont.%d) }'''
-
-container_lds_end = \
-'''
-}
-'''
-
-def generate_container_assembler(source, target, env):
- with open(target[0].path, "w+") as f:
- file_body = container_assembler_start % (str(source[0]))
- img_i = 0
- for img in source[1:]:
- file_body += container_assembler_body % (img_i, img)
- img_i += 1
-
- f.write(file_body)
- f.close()
-
-def generate_container_lds(source, target, env):
- with open(target[0].path, "w+") as f:
- img_i = 0
- file_body = container_lds_start
- for img in source[1:]:
- file_body += container_lds_body % (img_i, img_i)
- img_i += 1
- file_body += container_lds_end
- f.write(file_body)
- f.close()
-
-startAxfS = Command('start.axf.S', images[0], ksymToLds)
-
-# In the following, it is crucially important that the order of the sources is as it is -- assumptions are
-# made in the functions doing the processing.
-
-kernelS = Command('containers.S', images, generate_container_assembler)
-linkerScript = Command('linker.lds', images, generate_container_lds)
-
-## TODO: deal with the situation where there are other .c and .S files in the directory.
-
-objects = e.Object(['arch.c' , 'main.c', kernelS, startAxfS])
-Depends(objects, e['configFiles'])
-Depends(objects, images)
-program = e.Program('final', objects + [e['baremetal_crt0']])
-Depends(program, linkerScript)
-
-Return('program')
diff --git a/loader/SConstruct b/loader/SConstruct
new file mode 100644
index 0000000..535aa67
--- /dev/null
+++ b/loader/SConstruct
@@ -0,0 +1,60 @@
+# -*- mode: python; coding: utf-8; -*-
+#
+# Codezero -- a microkernel for embedded systems.
+#
+# Copyright © 2009 B Labs Ltd
+
+import os, sys, shelve
+
+# Get global paths
+PROJRELROOT = '../'
+
+cwd = os.getcwd()
+os.chdir(PROJRELROOT)
+execfile("configdata.py")
+os.chdir(cwd)
+
+# Get configuration information
+config_shelve = shelve.open(CONFIG_SHELVE)
+
+#symbols = config_shelve["config_symbols"]
+arch = config_shelve["arch"]
+subarch = config_shelve["subarch"]
+platform = config_shelve["platform"]
+all_syms = config_shelve["all_symbols"]
+
+# Locally important paths are here
+LIBC_PATH = '../libs/c'
+LIBC_LIBPATH = LIBC_PATH
+LIBC_INCPATH = [join(LIBC_PATH, 'include'), \
+ join(LIBC_PATH, 'include/arch/' + arch)]
+LIBC_CRT_PATH = join(LIBC_PATH, "crt/sys-baremetal/arch-" + arch + "/crt0.o")
+LIBELF_PATH = '../libs/elf'
+LIBELF_LIBPATH = LIBELF_PATH
+LIBELF_INCPATH = join(LIBELF_PATH, 'include')
+
+env = Environment(CC = 'arm-none-eabi-gcc',
+ # We don't use -nostdinc because sometimes we need standard headers,
+ # such as stdarg.h e.g. for variable args, as in printk().
+ CCFLAGS = ['-g', '-mcpu=arm926ej-s', '-nostdlib', '-ffreestanding', \
+ '-std=gnu99', '-Wall', '-Werror'],
+ LINKFLAGS = ['-nostdlib', '-T' + "linker.lds"],
+ ASFLAGS = ['-D__ASSEMBLY__'],
+ PROGSUFFIX = '.elf',
+ ENV = {'PATH' : os.environ['PATH']},
+ LIBS = ['gcc', 'c-baremetal', 'gcc'],
+ LIBPATH = [LIBC_LIBPATH, LIBELF_LIBPATH],
+ CPPPATH = ['#include', LIBC_INCPATH, LIBELF_INCPATH])
+
+config_shelve = shelve.open(CONFIG_SHELVE)
+#symbols = config_shelve["config_symbols"]
+arch = config_shelve["arch"]
+subarch = config_shelve["subarch"]
+platform = config_shelve["platform"]
+all_syms = config_shelve["all_symbols"]
+
+src = Glob('*.[cS]')
+crt0 = Glob(LIBC_CRT_PATH)
+
+objs = env.Object(src)
+env.Program('final.elf', objs + crt0)
diff --git a/loader/libs/c/SConstruct b/loader/libs/c/SConstruct
new file mode 100644
index 0000000..6188362
--- /dev/null
+++ b/loader/libs/c/SConstruct
@@ -0,0 +1,51 @@
+# -*- mode: python; coding: utf-8; -*-
+#
+# Codezero -- a microkernel for embedded systems.
+#
+# Copyright © 2009 B Labs Ltd
+
+import os, sys, shelve
+
+PROJROOT="../../../"
+cwd = os.getcwd()
+os.chdir(PROJROOT)
+execfile("configure.py")
+os.chdir(cwd)
+
+env = Environment(CC = 'arm-none-eabi-gcc',
+ # We don't use -nostdinc because sometimes we need standard headers,
+ # such as stdarg.h e.g. for variable args, as in printk().
+ CCFLAGS = ['-g', '-mcpu=arm926ej-s', '-nostdlib', '-ffreestanding', \
+ '-std=gnu99', '-Wall', '-Werror'],
+ LINKFLAGS = ['-nostdlib', '-T' + "include/l4/arch/arm/linker.lds"],
+ ASFLAGS = ['-D__ASSEMBLY__'],
+ PROGSUFFIX = '.elf', # The suffix to use for final executable
+ ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path
+ LIBS = 'gcc', # libgcc.a - This is required for division routines.
+ CPPPATH = "#include")
+
+config_shelve = shelve.open(CONFIG_SHELVE)
+#symbols = config_shelve["config_symbols"]
+arch = config_shelve["arch"]
+subarch = config_shelve["subarch"]
+platform = config_shelve["platform"]
+all_syms = config_shelve["all_symbols"]
+
+variant = "baremetal"
+
+e = env.Clone()
+e.Append(CPPPATH = ['include/sys-' + variant + '/arch-' + arch])
+e.Append(CCFLAGS = '-nostdinc')
+
+source = \
+ Glob('src/*.c') + \
+ Glob('src/sys-' + variant + '/*.c') + \
+ Glob('src/sys-' + variant + '/arch-' + arch + '/*.c') + \
+ Glob('src/sys-' + variant + '/arch-' + arch + '/plat-' + platform + '/*.c') + \
+ Glob('src/arch-' + arch + '/*.c') + \
+ Glob('src/arch-' + arch + '/*.S') + \
+ Glob('crt/sys-' + variant + '/arch-' + arch + '/*.[cS]')
+
+objects = e.StaticObject(source)
+library = e.StaticLibrary('c-' + variant, objects)
+#runtime = e.StaticObject('crt/sys-' + variant + '/arch-' + arch + '/crt0.S')
diff --git a/loader/libs/c/crt/sys-baremetal/arch-arm/crt0.S b/loader/libs/c/crt/sys-baremetal/arch-arm/crt0.S
new file mode 100644
index 0000000..6b3c859
--- /dev/null
+++ b/loader/libs/c/crt/sys-baremetal/arch-arm/crt0.S
@@ -0,0 +1,93 @@
+/*
+ * Australian Public Licence B (OZPLB)
+ *
+ * Version 1-0
+ *
+ * Copyright (c) 2004 National ICT Australia
+ *
+ * All rights reserved.
+ *
+ * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
+ * National ICT Australia
+ * http://www.ertos.nicta.com.au
+ *
+ * Permission is granted by National ICT Australia, free of charge, to
+ * any person obtaining a copy of this software and any associated
+ * documentation files (the "Software") to deal with the Software without
+ * restriction, including (without limitation) the rights to use, copy,
+ * modify, adapt, merge, publish, distribute, communicate to the public,
+ * sublicense, and/or sell, lend or rent out copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimers.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of National ICT Australia, nor the names of its
+ * contributors, may be used to endorse or promote products derived
+ * from this Software without specific prior written permission.
+ *
+ * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
+ * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
+ * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
+ * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
+ * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
+ * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
+ * ERRORS, WHETHER OR NOT DISCOVERABLE.
+ *
+ * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
+ * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
+ * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
+ * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
+ * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
+ * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
+ * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
+ * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
+ * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
+ * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
+ * DAMAGES OR OTHER LIABILITY.
+ *
+ * If applicable legislation implies representations, warranties, or
+ * conditions, or imposes obligations or liability on National ICT
+ * Australia or one of its contributors in respect of the Software that
+ * cannot be wholly or partly excluded, restricted or modified, the
+ * liability of National ICT Australia or the contributor is limited, to
+ * the full extent permitted by the applicable legislation, at its
+ * option, to:
+ * a. in the case of goods, any one or more of the following:
+ * i. the replacement of the goods or the supply of equivalent goods;
+ * ii. the repair of the goods;
+ * iii. the payment of the cost of replacing the goods or of acquiring
+ * equivalent goods;
+ * iv. the payment of the cost of having the goods repaired; or
+ * b. in the case of services:
+ * i. the supplying of the services again; or
+ * ii. the payment of the cost of having the services supplied again.
+ *
+ * The construction, validity and performance of this licence is governed
+ * by the laws in force in New South Wales, Australia.
+ */
+ .section .text
+ .code 32
+ .global _start;
+ .align;
+_start:
+ ldr sp, 1f
+ bl platform_init
+ bl main
+1: .word _stack_top
+
+ .bss
+ .align
+_stack:
+ .space 1024
+_stack_top:
diff --git a/libs/c/crt/sys-userspace/arch-arm/crt0.S b/loader/libs/c/crt/sys-userspace/arch-arm/crt0.S
similarity index 100%
rename from libs/c/crt/sys-userspace/arch-arm/crt0.S
rename to loader/libs/c/crt/sys-userspace/arch-arm/crt0.S
diff --git a/libs/c/include/arch/arm/arch/inttypes.h b/loader/libs/c/include/arch/arm/arch/inttypes.h
similarity index 100%
rename from libs/c/include/arch/arm/arch/inttypes.h
rename to loader/libs/c/include/arch/arm/arch/inttypes.h
diff --git a/libs/c/include/arch/arm/arch/pl011_uart.h b/loader/libs/c/include/arch/arm/arch/pl011_uart.h
similarity index 100%
rename from libs/c/include/arch/arm/arch/pl011_uart.h
rename to loader/libs/c/include/arch/arm/arch/pl011_uart.h
diff --git a/libs/c/include/arch/arm/arch/setjmp.h b/loader/libs/c/include/arch/arm/arch/setjmp.h
similarity index 100%
rename from libs/c/include/arch/arm/arch/setjmp.h
rename to loader/libs/c/include/arch/arm/arch/setjmp.h
diff --git a/libs/c/include/arch/arm/arch/stdint.h b/loader/libs/c/include/arch/arm/arch/stdint.h
similarity index 100%
rename from libs/c/include/arch/arm/arch/stdint.h
rename to loader/libs/c/include/arch/arm/arch/stdint.h
diff --git a/libs/c/include/sys-baremetal/arch-arm/arch/inttypes.h b/loader/libs/c/include/arch/inttypes.h
similarity index 100%
rename from libs/c/include/sys-baremetal/arch-arm/arch/inttypes.h
rename to loader/libs/c/include/arch/inttypes.h
diff --git a/libs/c/include/sys-baremetal/arch-arm/arch/pl011_uart.h b/loader/libs/c/include/arch/pl011_uart.h
similarity index 100%
rename from libs/c/include/sys-baremetal/arch-arm/arch/pl011_uart.h
rename to loader/libs/c/include/arch/pl011_uart.h
diff --git a/libs/c/include/sys-baremetal/arch-arm/arch/setjmp.h b/loader/libs/c/include/arch/setjmp.h
similarity index 100%
rename from libs/c/include/sys-baremetal/arch-arm/arch/setjmp.h
rename to loader/libs/c/include/arch/setjmp.h
diff --git a/libs/c/include/sys-baremetal/arch-arm/arch/stdint.h b/loader/libs/c/include/arch/stdint.h
similarity index 100%
rename from libs/c/include/sys-baremetal/arch-arm/arch/stdint.h
rename to loader/libs/c/include/arch/stdint.h
diff --git a/libs/c/include/assert.h b/loader/libs/c/include/assert.h
similarity index 100%
rename from libs/c/include/assert.h
rename to loader/libs/c/include/assert.h
diff --git a/libs/c/include/complex.h b/loader/libs/c/include/complex.h
similarity index 100%
rename from libs/c/include/complex.h
rename to loader/libs/c/include/complex.h
diff --git a/libs/c/include/ctype.h b/loader/libs/c/include/ctype.h
similarity index 100%
rename from libs/c/include/ctype.h
rename to loader/libs/c/include/ctype.h
diff --git a/libs/c/include/errno.h b/loader/libs/c/include/errno.h
similarity index 100%
rename from libs/c/include/errno.h
rename to loader/libs/c/include/errno.h
diff --git a/libs/c/include/inttypes.h b/loader/libs/c/include/inttypes.h
similarity index 100%
rename from libs/c/include/inttypes.h
rename to loader/libs/c/include/inttypes.h
diff --git a/libs/c/include/iso646.h b/loader/libs/c/include/iso646.h
similarity index 100%
rename from libs/c/include/iso646.h
rename to loader/libs/c/include/iso646.h
diff --git a/libs/c/include/limits.h b/loader/libs/c/include/limits.h
similarity index 100%
rename from libs/c/include/limits.h
rename to loader/libs/c/include/limits.h
diff --git a/libs/c/include/locale.h b/loader/libs/c/include/locale.h
similarity index 100%
rename from libs/c/include/locale.h
rename to loader/libs/c/include/locale.h
diff --git a/libs/c/include/setjmp.h b/loader/libs/c/include/setjmp.h
similarity index 100%
rename from libs/c/include/setjmp.h
rename to loader/libs/c/include/setjmp.h
diff --git a/libs/c/include/stdarg.h b/loader/libs/c/include/stdarg.h
similarity index 100%
rename from libs/c/include/stdarg.h
rename to loader/libs/c/include/stdarg.h
diff --git a/libs/c/include/stdbool.h b/loader/libs/c/include/stdbool.h
similarity index 100%
rename from libs/c/include/stdbool.h
rename to loader/libs/c/include/stdbool.h
diff --git a/libs/c/include/stddef.h b/loader/libs/c/include/stddef.h
similarity index 100%
rename from libs/c/include/stddef.h
rename to loader/libs/c/include/stddef.h
diff --git a/libs/c/include/stdint.h b/loader/libs/c/include/stdint.h
similarity index 100%
rename from libs/c/include/stdint.h
rename to loader/libs/c/include/stdint.h
diff --git a/libs/c/include/stdio.h b/loader/libs/c/include/stdio.h
similarity index 100%
rename from libs/c/include/stdio.h
rename to loader/libs/c/include/stdio.h
diff --git a/libs/c/include/stdlib.h b/loader/libs/c/include/stdlib.h
similarity index 100%
rename from libs/c/include/stdlib.h
rename to loader/libs/c/include/stdlib.h
diff --git a/libs/c/include/string.h b/loader/libs/c/include/string.h
similarity index 100%
rename from libs/c/include/string.h
rename to loader/libs/c/include/string.h
diff --git a/libs/c/include/sys-baremetal/arch-arm/inttypes.h b/loader/libs/c/include/sys-baremetal/arch-arm/arch/inttypes.h
similarity index 100%
rename from libs/c/include/sys-baremetal/arch-arm/inttypes.h
rename to loader/libs/c/include/sys-baremetal/arch-arm/arch/inttypes.h
diff --git a/libs/c/include/sys-baremetal/arch-arm/pl011_uart.h b/loader/libs/c/include/sys-baremetal/arch-arm/arch/pl011_uart.h
similarity index 100%
rename from libs/c/include/sys-baremetal/arch-arm/pl011_uart.h
rename to loader/libs/c/include/sys-baremetal/arch-arm/arch/pl011_uart.h
diff --git a/libs/c/include/sys-baremetal/arch-arm/setjmp.h b/loader/libs/c/include/sys-baremetal/arch-arm/arch/setjmp.h
similarity index 100%
rename from libs/c/include/sys-baremetal/arch-arm/setjmp.h
rename to loader/libs/c/include/sys-baremetal/arch-arm/arch/setjmp.h
diff --git a/libs/c/include/sys-baremetal/arch-arm/stdint.h b/loader/libs/c/include/sys-baremetal/arch-arm/arch/stdint.h
similarity index 100%
rename from libs/c/include/sys-baremetal/arch-arm/stdint.h
rename to loader/libs/c/include/sys-baremetal/arch-arm/arch/stdint.h
diff --git a/libs/c/include/sys-userspace/arch-arm/arch/inttypes.h b/loader/libs/c/include/sys-baremetal/arch-arm/inttypes.h
similarity index 100%
rename from libs/c/include/sys-userspace/arch-arm/arch/inttypes.h
rename to loader/libs/c/include/sys-baremetal/arch-arm/inttypes.h
diff --git a/loader/libs/c/include/sys-baremetal/arch-arm/pl011_uart.h b/loader/libs/c/include/sys-baremetal/arch-arm/pl011_uart.h
new file mode 100644
index 0000000..cd2551f
--- /dev/null
+++ b/loader/libs/c/include/sys-baremetal/arch-arm/pl011_uart.h
@@ -0,0 +1,408 @@
+
+#ifndef __PL011__UART__H__
+#define __PL011__UART__H__
+
+/*
+ * PL011 UART Generic driver implementation.
+ * Copyright Bahadir Balban (C) 2006
+ *
+ * The particular intention of this code is that it has been carefully
+ * written as decoupled from os-specific code and in a verbose way such
+ * that it clearly demonstrates how the device operates, reducing the
+ * amount of time to be spent for understanding the operational model
+ * and implementing a driver from scratch. This is the very first to be
+ * such a driver so far, hopefully it will turn out to be useful.
+ */
+
+/* Default base address for this chip */
+#define PL011_DEFAULT_PHYSICAL_BASE 0x101F1000
+#define PL011_BASE PL011_DEFAULT_PHYSICAL_BASE
+
+/* Architecture specific memory access macros */
+#define read(val, address) val = *((volatile unsigned int *) address)
+#define write(val, address) *((volatile unsigned int *) address) = val
+
+/* Register offsets */
+#define PL011_UARTDR (PL011_BASE + 0x00)
+#define PL011_UARTRSR (PL011_BASE + 0x04)
+#define PL011_UARTECR (PL011_BASE + 0x04)
+#define PL011_UARTFR (PL011_BASE + 0x18)
+#define PL011_UARTILPR (PL011_BASE + 0x20)
+#define PL011_UARTIBRD (PL011_BASE + 0x24)
+#define PL011_UARTFBRD (PL011_BASE + 0x28)
+#define PL011_UARTLCR_H (PL011_BASE + 0x2C)
+#define PL011_UARTCR (PL011_BASE + 0x30)
+#define PL011_UARTIFLS (PL011_BASE + 0x34)
+#define PL011_UARTIMSC (PL011_BASE + 0x38)
+#define PL011_UARTRIS (PL011_BASE + 0x3C)
+#define PL011_UARTMIS (PL011_BASE + 0x40)
+#define PL011_UARTICR (PL011_BASE + 0x44)
+#define PL011_UARTDMACR (PL011_BASE + 0x48)
+
+/* IRQ bits for each uart irq event */
+#define PL011_RXIRQ (1 << 4)
+#define PL011_TXIRQ (1 << 5)
+#define PL011_RXTIMEOUTIRQ (1 << 6)
+#define PL011_FEIRQ (1 << 7)
+#define PL011_PEIRQ (1 << 8)
+#define PL011_BEIRQ (1 << 9)
+#define PL011_OEIRQ (1 << 10)
+
+struct pl011_uart;
+
+int pl011_initialise(struct pl011_uart *);
+int pl011_tx_char(char);
+int pl011_rx_char(char *);
+
+void pl011_set_baudrate(unsigned int, unsigned int);
+void pl011_set_irq_mask(unsigned int);
+void pl011_clr_irq_mask(unsigned int);
+
+void pl011_irq_handler(struct pl011_uart *);
+void pl011_tx_irq_handler(struct pl011_uart *, unsigned int);
+void pl011_rx_irq_handler(struct pl011_uart *, unsigned int);
+void pl011_error_irq_handler(struct pl011_uart *, unsigned int);
+
+static inline void pl011_uart_enable(void);
+static inline void pl011_uart_disable(void);
+static inline void pl011_tx_enable(void);
+static inline void pl011_tx_disable(void);
+static inline void pl011_rx_enable(void);
+static inline void pl011_rx_disable(void);
+static inline void pl011_irq_clear(unsigned int flags);
+static inline unsigned int pl011_read_irqstat(void);
+static inline unsigned int pl011_read_irqmask(void);
+static inline void pl011_rx_dma_disable(void);
+static inline void pl011_rx_dma_enable(void);
+static inline void pl011_tx_dma_enable(void);
+static inline void pl011_tx_dma_disable(void);
+static inline void pl011_set_irq_fifolevel(unsigned int xfer,
+ unsigned int level);
+static inline void pl011_set_word_width(int size);
+static inline void pl011_disable_fifos(void);
+static inline void pl011_set_parity_even(void);
+static inline void pl011_parity_enable(void);
+static inline void pl011_set_stopbits(int stopbits);
+
+static inline void pl011_set_parity_odd(void);
+static inline void pl011_enable_fifos(void);
+static inline void pl011_parity_disable(void);
+
+struct pl011_uart_ops {
+ int (*initialise)(struct pl011_uart *);
+
+ int (*tx_char)(char);
+ int (*rx_char)(char *);
+
+ void (*set_baudrate)(unsigned int, unsigned int);
+ void (*set_irq_mask)(unsigned int);
+ void (*clr_irq_mask)(unsigned int);
+
+ void (*irq_handler)(struct pl011_uart *);
+ void (*tx_irq_handler)(struct pl011_uart *, unsigned int);
+ void (*rx_irq_handler)(struct pl011_uart *, unsigned int);
+ void (*error_irq_handler)(struct pl011_uart *, unsigned int);
+};
+
+struct pl011_uart {
+ const unsigned int base;
+ struct pl011_uart_ops ops;
+ unsigned int frame_errors;
+ unsigned int parity_errors;
+ unsigned int break_errors;
+ unsigned int overrun_errors;
+ unsigned int rx_timeout_errors;
+};
+
+
+
+#define PL011_UARTEN (1 << 0)
+static inline void pl011_uart_enable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTCR);
+ val |= PL011_UARTEN;
+ write(val, PL011_UARTCR);
+
+ return;
+}
+
+static inline void pl011_uart_disable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTCR);
+ val &= ~PL011_UARTEN;
+ write(val, PL011_UARTCR);
+
+ return;
+}
+
+#define PL011_TXE (1 << 8)
+static inline void pl011_tx_enable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTCR);
+ val |= PL011_TXE;
+ write(val, PL011_UARTCR);
+ return;
+}
+
+static inline void pl011_tx_disable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTCR);
+ val &= ~PL011_TXE;
+ write(val, PL011_UARTCR);
+ return;
+}
+
+
+#define PL011_RXE (1 << 9)
+static inline void pl011_rx_enable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTCR);
+ val |= PL011_RXE;
+ write(val, PL011_UARTCR);
+ return;
+}
+
+static inline void pl011_rx_disable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTCR);
+ val &= ~PL011_RXE;
+ write(val, PL011_UARTCR);
+ return;
+}
+
+#define PL011_TWO_STOPBITS_SELECT (1 << 3)
+static inline void pl011_set_stopbits(int stopbits)
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTLCR_H);
+
+ if(stopbits == 2) { /* Set to two bits */
+ val |= PL011_TWO_STOPBITS_SELECT;
+ } else { /* Default is 1 */
+ val &= ~PL011_TWO_STOPBITS_SELECT;
+ }
+ write(val, PL011_UARTLCR_H);
+ return;
+}
+
+#define PL011_PARITY_ENABLE (1 << 1)
+static inline void pl011_parity_enable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTLCR_H);
+ val |= PL011_PARITY_ENABLE;
+ write(val, PL011_UARTLCR_H);
+ return;
+}
+
+static inline void pl011_parity_disable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTLCR_H);
+ val &= ~PL011_PARITY_ENABLE;
+ write(val, PL011_UARTLCR_H);
+ return;
+}
+
+#define PL011_PARITY_EVEN (1 << 2)
+static inline void pl011_set_parity_even()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTLCR_H);
+ val |= PL011_PARITY_EVEN;
+ write(val, PL011_UARTLCR_H);
+ return;
+}
+
+static inline void pl011_set_parity_odd()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTLCR_H);
+ val &= ~PL011_PARITY_EVEN;
+ write(val, PL011_UARTLCR_H);
+ return;
+}
+
+#define PL011_ENABLE_FIFOS (1 << 4)
+static inline void pl011_enable_fifos()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTLCR_H);
+ val |= PL011_ENABLE_FIFOS;
+ write(val, PL011_UARTLCR_H);
+ return;
+}
+
+static inline void pl011_disable_fifos()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTLCR_H);
+ val &= ~PL011_ENABLE_FIFOS;
+ write(val, PL011_UARTLCR_H);
+ return;
+}
+
+
+#define PL011_WORD_WIDTH_SHIFT (5)
+/* Sets the transfer word width for the data register. */
+static inline void pl011_set_word_width(int size)
+{
+ unsigned int val;
+ val = 0;
+
+ if(size < 5 || size > 8) /* Default is 8 */
+ size = 8;
+
+ /* Clear size field */
+ read(val, PL011_UARTLCR_H);
+ val &= ~(0x3 << PL011_WORD_WIDTH_SHIFT);
+ write(val, PL011_UARTLCR_H);
+
+ /* The formula is to write 5 less of size given:
+ * 11 = 8 bits
+ * 10 = 7 bits
+ * 01 = 6 bits
+ * 00 = 5 bits
+ */
+ read(val, PL011_UARTLCR_H);
+ val |= (size - 5) << PL011_WORD_WIDTH_SHIFT;
+ write(val, PL011_UARTLCR_H);
+
+ return;
+}
+
+/*
+ * Defines at which level of fifo fullness an irq will be generated.
+ * @xfer: tx fifo = 0, rx fifo = 1
+ * @level: Generate irq if:
+ * 0 rxfifo >= 1/8 full txfifo <= 1/8 full
+ * 1 rxfifo >= 1/4 full txfifo <= 1/4 full
+ * 2 rxfifo >= 1/2 full txfifo <= 1/2 full
+ * 3 rxfifo >= 3/4 full txfifo <= 3/4 full
+ * 4 rxfifo >= 7/8 full txfifo <= 7/8 full
+ * 5-7 reserved reserved
+ */
+static inline void pl011_set_irq_fifolevel(unsigned int xfer, unsigned int level)
+{
+ if(xfer != 1 && xfer != 0) /* Invalid fifo */
+ return;
+
+ if(level > 4) /* Invalid level */
+ return;
+
+ write(level << (xfer * 3), PL011_UARTIFLS);
+ return;
+}
+
+/* returns which irqs are masked */
+static inline unsigned int pl011_read_irqmask(void)
+{
+ unsigned int flags;
+ read(flags, PL011_UARTIMSC);
+ return flags;
+}
+
+/* returns masked irq status */
+static inline unsigned int pl011_read_irqstat(void)
+{
+ unsigned int irqstatus;
+ read(irqstatus, PL011_UARTMIS);
+ return irqstatus;
+}
+/* Clears the given asserted irqs */
+static inline void pl011_irq_clear(unsigned int flags)
+{
+ if(flags > 0x3FF) { /* Invalid irq clearing bitvector */
+ return;
+ }
+ /* Simply write the flags since it's a write-only register */
+ write(flags, PL011_UARTICR);
+ return;
+}
+
+#define PL011_TXDMAEN (1 << 1)
+#define PL011_RXDMAEN (1 << 0)
+
+/* Enables dma transfers for uart. The dma controller
+ * must be initialised, set-up and enabled separately.
+ */
+static inline void pl011_tx_dma_enable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTDMACR);
+ val |= PL011_TXDMAEN;
+ write(val, PL011_UARTDMACR);
+ return;
+}
+
+/* Disables dma transfers for uart */
+static inline void pl011_tx_dma_disable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTDMACR);
+ val &= ~PL011_TXDMAEN;
+ write(val, PL011_UARTDMACR);
+ return;
+}
+
+static inline void pl011_rx_dma_enable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTDMACR);
+ val |= PL011_RXDMAEN;
+ write(val, PL011_UARTDMACR);
+ return;
+}
+
+static inline void pl011_rx_dma_disable()
+{
+ unsigned int val;
+ val = 0;
+
+ read(val, PL011_UARTDMACR);
+ val &= ~PL011_RXDMAEN;
+ write(val, PL011_UARTDMACR);
+ return;
+}
+
+
+#endif /* __PL011__UART__ */
+
diff --git a/libs/c/include/sys-userspace/arch-arm/arch/setjmp.h b/loader/libs/c/include/sys-baremetal/arch-arm/setjmp.h
similarity index 100%
rename from libs/c/include/sys-userspace/arch-arm/arch/setjmp.h
rename to loader/libs/c/include/sys-baremetal/arch-arm/setjmp.h
diff --git a/libs/c/include/sys-userspace/arch-arm/arch/stdint.h b/loader/libs/c/include/sys-baremetal/arch-arm/stdint.h
similarity index 100%
rename from libs/c/include/sys-userspace/arch-arm/arch/stdint.h
rename to loader/libs/c/include/sys-baremetal/arch-arm/stdint.h
diff --git a/libs/c/include/sys-userspace/arch-arm/inttypes.h b/loader/libs/c/include/sys-userspace/arch-arm/arch/inttypes.h
similarity index 100%
rename from libs/c/include/sys-userspace/arch-arm/inttypes.h
rename to loader/libs/c/include/sys-userspace/arch-arm/arch/inttypes.h
diff --git a/libs/c/include/sys-userspace/arch-arm/arch/pl011_uart.h b/loader/libs/c/include/sys-userspace/arch-arm/arch/pl011_uart.h
similarity index 100%
rename from libs/c/include/sys-userspace/arch-arm/arch/pl011_uart.h
rename to loader/libs/c/include/sys-userspace/arch-arm/arch/pl011_uart.h
diff --git a/libs/c/include/sys-userspace/arch-arm/setjmp.h b/loader/libs/c/include/sys-userspace/arch-arm/arch/setjmp.h
similarity index 100%
rename from libs/c/include/sys-userspace/arch-arm/setjmp.h
rename to loader/libs/c/include/sys-userspace/arch-arm/arch/setjmp.h
diff --git a/libs/c/include/sys-userspace/arch-arm/stdint.h b/loader/libs/c/include/sys-userspace/arch-arm/arch/stdint.h
similarity index 100%
rename from libs/c/include/sys-userspace/arch-arm/stdint.h
rename to loader/libs/c/include/sys-userspace/arch-arm/arch/stdint.h
diff --git a/loader/libs/c/include/sys-userspace/arch-arm/inttypes.h b/loader/libs/c/include/sys-userspace/arch-arm/inttypes.h
new file mode 100644
index 0000000..329ca46
--- /dev/null
+++ b/loader/libs/c/include/sys-userspace/arch-arm/inttypes.h
@@ -0,0 +1,87 @@
+/*
+ * Australian Public Licence B (OZPLB)
+ *
+ * Version 1-0
+ *
+ * Copyright (c) 2004 National ICT Australia
+ *
+ * All rights reserved.
+ *
+ * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
+ * National ICT Australia
+ * http://www.ertos.nicta.com.au
+ *
+ * Permission is granted by National ICT Australia, free of charge, to
+ * any person obtaining a copy of this software and any associated
+ * documentation files (the "Software") to deal with the Software without
+ * restriction, including (without limitation) the rights to use, copy,
+ * modify, adapt, merge, publish, distribute, communicate to the public,
+ * sublicense, and/or sell, lend or rent out copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimers.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of National ICT Australia, nor the names of its
+ * contributors, may be used to endorse or promote products derived
+ * from this Software without specific prior written permission.
+ *
+ * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
+ * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
+ * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
+ * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
+ * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
+ * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
+ * ERRORS, WHETHER OR NOT DISCOVERABLE.
+ *
+ * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
+ * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
+ * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
+ * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
+ * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
+ * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
+ * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
+ * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
+ * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
+ * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
+ * DAMAGES OR OTHER LIABILITY.
+ *
+ * If applicable legislation implies representations, warranties, or
+ * conditions, or imposes obligations or liability on National ICT
+ * Australia or one of its contributors in respect of the Software that
+ * cannot be wholly or partly excluded, restricted or modified, the
+ * liability of National ICT Australia or the contributor is limited, to
+ * the full extent permitted by the applicable legislation, at its
+ * option, to:
+ * a. in the case of goods, any one or more of the following:
+ * i. the replacement of the goods or the supply of equivalent goods;
+ * ii. the repair of the goods;
+ * iii. the payment of the cost of replacing the goods or of acquiring
+ * equivalent goods;
+ * iv. the payment of the cost of having the goods repaired; or
+ * b. in the case of services:
+ * i. the supplying of the services again; or
+ * ii. the payment of the cost of having the services supplied again.
+ *
+ * The construction, validity and performance of this licence is governed
+ * by the laws in force in New South Wales, Australia.
+ */
+/*
+ Author: Ben Leslie
+*/
+#define __LENGTH_8_MOD "hh"
+#define __LENGTH_16_MOD "h"
+#define __LENGTH_32_MOD
+#define __LENGTH_64_MOD "ll"
+#define __LENGTH_MAX_MOD "ll"
+#define __LENGTH_PTR_MOD
diff --git a/libs/c/include/sys-userspace/arch-arm/pl011_uart.h b/loader/libs/c/include/sys-userspace/arch-arm/pl011_uart.h
similarity index 100%
rename from libs/c/include/sys-userspace/arch-arm/pl011_uart.h
rename to loader/libs/c/include/sys-userspace/arch-arm/pl011_uart.h
diff --git a/loader/libs/c/include/sys-userspace/arch-arm/setjmp.h b/loader/libs/c/include/sys-userspace/arch-arm/setjmp.h
new file mode 100644
index 0000000..22a17cd
--- /dev/null
+++ b/loader/libs/c/include/sys-userspace/arch-arm/setjmp.h
@@ -0,0 +1,83 @@
+/*
+ * Australian Public Licence B (OZPLB)
+ *
+ * Version 1-0
+ *
+ * Copyright (c) 2004 National ICT Australia
+ *
+ * All rights reserved.
+ *
+ * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
+ * National ICT Australia
+ * http://www.ertos.nicta.com.au
+ *
+ * Permission is granted by National ICT Australia, free of charge, to
+ * any person obtaining a copy of this software and any associated
+ * documentation files (the "Software") to deal with the Software without
+ * restriction, including (without limitation) the rights to use, copy,
+ * modify, adapt, merge, publish, distribute, communicate to the public,
+ * sublicense, and/or sell, lend or rent out copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimers.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of National ICT Australia, nor the names of its
+ * contributors, may be used to endorse or promote products derived
+ * from this Software without specific prior written permission.
+ *
+ * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
+ * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
+ * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
+ * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
+ * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
+ * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
+ * ERRORS, WHETHER OR NOT DISCOVERABLE.
+ *
+ * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
+ * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
+ * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
+ * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
+ * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
+ * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
+ * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
+ * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
+ * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
+ * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
+ * DAMAGES OR OTHER LIABILITY.
+ *
+ * If applicable legislation implies representations, warranties, or
+ * conditions, or imposes obligations or liability on National ICT
+ * Australia or one of its contributors in respect of the Software that
+ * cannot be wholly or partly excluded, restricted or modified, the
+ * liability of National ICT Australia or the contributor is limited, to
+ * the full extent permitted by the applicable legislation, at its
+ * option, to:
+ * a. in the case of goods, any one or more of the following:
+ * i. the replacement of the goods or the supply of equivalent goods;
+ * ii. the repair of the goods;
+ * iii. the payment of the cost of replacing the goods or of acquiring
+ * equivalent goods;
+ * iv. the payment of the cost of having the goods repaired; or
+ * b. in the case of services:
+ * i. the supplying of the services again; or
+ * ii. the payment of the cost of having the services supplied again.
+ *
+ * The construction, validity and performance of this licence is governed
+ * by the laws in force in New South Wales, Australia.
+ */
+/*
+ Author: Alex Webster
+*/
+
+typedef int jmp_buf[10];
diff --git a/loader/libs/c/include/sys-userspace/arch-arm/stdint.h b/loader/libs/c/include/sys-userspace/arch-arm/stdint.h
new file mode 100644
index 0000000..6078b0a
--- /dev/null
+++ b/loader/libs/c/include/sys-userspace/arch-arm/stdint.h
@@ -0,0 +1,92 @@
+/*
+ * Australian Public Licence B (OZPLB)
+ *
+ * Version 1-0
+ *
+ * Copyright (c) 2004 National ICT Australia
+ *
+ * All rights reserved.
+ *
+ * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
+ * National ICT Australia
+ * http://www.ertos.nicta.com.au
+ *
+ * Permission is granted by National ICT Australia, free of charge, to
+ * any person obtaining a copy of this software and any associated
+ * documentation files (the "Software") to deal with the Software without
+ * restriction, including (without limitation) the rights to use, copy,
+ * modify, adapt, merge, publish, distribute, communicate to the public,
+ * sublicense, and/or sell, lend or rent out copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimers.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimers in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of National ICT Australia, nor the names of its
+ * contributors, may be used to endorse or promote products derived
+ * from this Software without specific prior written permission.
+ *
+ * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
+ * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
+ * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
+ * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
+ * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
+ * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
+ * ERRORS, WHETHER OR NOT DISCOVERABLE.
+ *
+ * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
+ * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
+ * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
+ * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
+ * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
+ * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
+ * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
+ * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
+ * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
+ * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
+ * DAMAGES OR OTHER LIABILITY.
+ *
+ * If applicable legislation implies representations, warranties, or
+ * conditions, or imposes obligations or liability on National ICT
+ * Australia or one of its contributors in respect of the Software that
+ * cannot be wholly or partly excluded, restricted or modified, the
+ * liability of National ICT Australia or the contributor is limited, to
+ * the full extent permitted by the applicable legislation, at its
+ * option, to:
+ * a. in the case of goods, any one or more of the following:
+ * i. the replacement of the goods or the supply of equivalent goods;
+ * ii. the repair of the goods;
+ * iii. the payment of the cost of replacing the goods or of acquiring
+ * equivalent goods;
+ * iv. the payment of the cost of having the goods repaired; or
+ * b. in the case of services:
+ * i. the supplying of the services again; or
+ * ii. the payment of the cost of having the services supplied again.
+ *
+ * The construction, validity and performance of this licence is governed
+ * by the laws in force in New South Wales, Australia.
+ */
+/*
+ Author: Ben Leslie
+*/
+typedef signed char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+#define __PTR_SIZE 32
diff --git a/libs/c/include/time.h b/loader/libs/c/include/time.h
similarity index 100%
rename from libs/c/include/time.h
rename to loader/libs/c/include/time.h
diff --git a/libs/c/src/arch-arm/eabi.c b/loader/libs/c/src/arch-arm/eabi.c
similarity index 100%
rename from libs/c/src/arch-arm/eabi.c
rename to loader/libs/c/src/arch-arm/eabi.c
diff --git a/libs/c/src/arch-arm/jmp.S b/loader/libs/c/src/arch-arm/jmp.S
similarity index 100%
rename from libs/c/src/arch-arm/jmp.S
rename to loader/libs/c/src/arch-arm/jmp.S
diff --git a/libs/c/src/asctime.c b/loader/libs/c/src/asctime.c
similarity index 100%
rename from libs/c/src/asctime.c
rename to loader/libs/c/src/asctime.c
diff --git a/libs/c/src/assert.c b/loader/libs/c/src/assert.c
similarity index 100%
rename from libs/c/src/assert.c
rename to loader/libs/c/src/assert.c
diff --git a/libs/c/src/calloc.c b/loader/libs/c/src/calloc.c
similarity index 100%
rename from libs/c/src/calloc.c
rename to loader/libs/c/src/calloc.c
diff --git a/libs/c/src/clearerr.c b/loader/libs/c/src/clearerr.c
similarity index 100%
rename from libs/c/src/clearerr.c
rename to loader/libs/c/src/clearerr.c
diff --git a/libs/c/src/clock.c b/loader/libs/c/src/clock.c
similarity index 100%
rename from libs/c/src/clock.c
rename to loader/libs/c/src/clock.c
diff --git a/libs/c/crt/sys-baremetal/arch-arm/crt0.S b/loader/libs/c/src/crt0.S
similarity index 100%
rename from libs/c/crt/sys-baremetal/arch-arm/crt0.S
rename to loader/libs/c/src/crt0.S
diff --git a/loader/libs/c/src/ctype.c b/loader/libs/c/src/ctype.c
new file mode 100644
index 0000000..e69de29
diff --git a/libs/c/src/difftime.c b/loader/libs/c/src/difftime.c
similarity index 100%
rename from libs/c/src/difftime.c
rename to loader/libs/c/src/difftime.c
diff --git a/libs/c/src/errno.c b/loader/libs/c/src/errno.c
similarity index 100%
rename from libs/c/src/errno.c
rename to loader/libs/c/src/errno.c
diff --git a/libs/c/src/exit.c b/loader/libs/c/src/exit.c
similarity index 100%
rename from libs/c/src/exit.c
rename to loader/libs/c/src/exit.c
diff --git a/libs/c/src/fclose.c b/loader/libs/c/src/fclose.c
similarity index 100%
rename from libs/c/src/fclose.c
rename to loader/libs/c/src/fclose.c
diff --git a/libs/c/src/feof.c b/loader/libs/c/src/feof.c
similarity index 100%
rename from libs/c/src/feof.c
rename to loader/libs/c/src/feof.c
diff --git a/libs/c/src/ferror.c b/loader/libs/c/src/ferror.c
similarity index 100%
rename from libs/c/src/ferror.c
rename to loader/libs/c/src/ferror.c
diff --git a/libs/c/src/fflush.c b/loader/libs/c/src/fflush.c
similarity index 100%
rename from libs/c/src/fflush.c
rename to loader/libs/c/src/fflush.c
diff --git a/libs/c/src/fgetc.c b/loader/libs/c/src/fgetc.c
similarity index 100%
rename from libs/c/src/fgetc.c
rename to loader/libs/c/src/fgetc.c
diff --git a/libs/c/src/fgets.c b/loader/libs/c/src/fgets.c
similarity index 100%
rename from libs/c/src/fgets.c
rename to loader/libs/c/src/fgets.c
diff --git a/libs/c/src/format.c b/loader/libs/c/src/format.c
similarity index 100%
rename from libs/c/src/format.c
rename to loader/libs/c/src/format.c
diff --git a/libs/c/src/format.h b/loader/libs/c/src/format.h
similarity index 100%
rename from libs/c/src/format.h
rename to loader/libs/c/src/format.h
diff --git a/libs/c/src/fprintf.c b/loader/libs/c/src/fprintf.c
similarity index 100%
rename from libs/c/src/fprintf.c
rename to loader/libs/c/src/fprintf.c
diff --git a/libs/c/src/fputc.c b/loader/libs/c/src/fputc.c
similarity index 100%
rename from libs/c/src/fputc.c
rename to loader/libs/c/src/fputc.c
diff --git a/libs/c/src/fputs.c b/loader/libs/c/src/fputs.c
similarity index 100%
rename from libs/c/src/fputs.c
rename to loader/libs/c/src/fputs.c
diff --git a/libs/c/src/fread.c b/loader/libs/c/src/fread.c
similarity index 100%
rename from libs/c/src/fread.c
rename to loader/libs/c/src/fread.c
diff --git a/libs/c/src/fscanf.c b/loader/libs/c/src/fscanf.c
similarity index 100%
rename from libs/c/src/fscanf.c
rename to loader/libs/c/src/fscanf.c
diff --git a/libs/c/src/fseek.c b/loader/libs/c/src/fseek.c
similarity index 100%
rename from libs/c/src/fseek.c
rename to loader/libs/c/src/fseek.c
diff --git a/libs/c/src/ftell.c b/loader/libs/c/src/ftell.c
similarity index 100%
rename from libs/c/src/ftell.c
rename to loader/libs/c/src/ftell.c
diff --git a/libs/c/src/fwrite.c b/loader/libs/c/src/fwrite.c
similarity index 100%
rename from libs/c/src/fwrite.c
rename to loader/libs/c/src/fwrite.c
diff --git a/libs/c/src/getchar.c b/loader/libs/c/src/getchar.c
similarity index 100%
rename from libs/c/src/getchar.c
rename to loader/libs/c/src/getchar.c
diff --git a/libs/c/src/getenv.c b/loader/libs/c/src/getenv.c
similarity index 100%
rename from libs/c/src/getenv.c
rename to loader/libs/c/src/getenv.c
diff --git a/libs/c/src/gmtime.c b/loader/libs/c/src/gmtime.c
similarity index 100%
rename from libs/c/src/gmtime.c
rename to loader/libs/c/src/gmtime.c
diff --git a/libs/c/src/k_r_malloc.h b/loader/libs/c/src/k_r_malloc.h
similarity index 100%
rename from libs/c/src/k_r_malloc.h
rename to loader/libs/c/src/k_r_malloc.h
diff --git a/libs/c/src/locale.c b/loader/libs/c/src/locale.c
similarity index 100%
rename from libs/c/src/locale.c
rename to loader/libs/c/src/locale.c
diff --git a/libs/c/src/localtime.c b/loader/libs/c/src/localtime.c
similarity index 100%
rename from libs/c/src/localtime.c
rename to loader/libs/c/src/localtime.c
diff --git a/libs/c/src/malloc.c b/loader/libs/c/src/malloc.c
similarity index 100%
rename from libs/c/src/malloc.c
rename to loader/libs/c/src/malloc.c
diff --git a/libs/c/src/memchr.c b/loader/libs/c/src/memchr.c
similarity index 100%
rename from libs/c/src/memchr.c
rename to loader/libs/c/src/memchr.c
diff --git a/libs/c/src/memcmp.c b/loader/libs/c/src/memcmp.c
similarity index 100%
rename from libs/c/src/memcmp.c
rename to loader/libs/c/src/memcmp.c
diff --git a/libs/c/src/memcpy.c b/loader/libs/c/src/memcpy.c
similarity index 100%
rename from libs/c/src/memcpy.c
rename to loader/libs/c/src/memcpy.c
diff --git a/libs/c/src/memmove.c b/loader/libs/c/src/memmove.c
similarity index 100%
rename from libs/c/src/memmove.c
rename to loader/libs/c/src/memmove.c
diff --git a/libs/c/src/memset.c b/loader/libs/c/src/memset.c
similarity index 100%
rename from libs/c/src/memset.c
rename to loader/libs/c/src/memset.c
diff --git a/libs/c/src/mktime.c b/loader/libs/c/src/mktime.c
similarity index 100%
rename from libs/c/src/mktime.c
rename to loader/libs/c/src/mktime.c
diff --git a/libs/c/src/perror.c b/loader/libs/c/src/perror.c
similarity index 100%
rename from libs/c/src/perror.c
rename to loader/libs/c/src/perror.c
diff --git a/libs/c/src/printf.c b/loader/libs/c/src/printf.c
similarity index 100%
rename from libs/c/src/printf.c
rename to loader/libs/c/src/printf.c
diff --git a/libs/c/src/putchar.c b/loader/libs/c/src/putchar.c
similarity index 100%
rename from libs/c/src/putchar.c
rename to loader/libs/c/src/putchar.c
diff --git a/libs/c/src/puts.c b/loader/libs/c/src/puts.c
similarity index 100%
rename from libs/c/src/puts.c
rename to loader/libs/c/src/puts.c
diff --git a/libs/c/src/qsort.c b/loader/libs/c/src/qsort.c
similarity index 100%
rename from libs/c/src/qsort.c
rename to loader/libs/c/src/qsort.c
diff --git a/libs/c/src/rand.c b/loader/libs/c/src/rand.c
similarity index 100%
rename from libs/c/src/rand.c
rename to loader/libs/c/src/rand.c
diff --git a/libs/c/src/realloc.c b/loader/libs/c/src/realloc.c
similarity index 100%
rename from libs/c/src/realloc.c
rename to loader/libs/c/src/realloc.c
diff --git a/libs/c/src/remove.c b/loader/libs/c/src/remove.c
similarity index 100%
rename from libs/c/src/remove.c
rename to loader/libs/c/src/remove.c
diff --git a/libs/c/src/rename.c b/loader/libs/c/src/rename.c
similarity index 100%
rename from libs/c/src/rename.c
rename to loader/libs/c/src/rename.c
diff --git a/libs/c/src/rewind.c b/loader/libs/c/src/rewind.c
similarity index 100%
rename from libs/c/src/rewind.c
rename to loader/libs/c/src/rewind.c
diff --git a/libs/c/src/snprintf.c b/loader/libs/c/src/snprintf.c
similarity index 100%
rename from libs/c/src/snprintf.c
rename to loader/libs/c/src/snprintf.c
diff --git a/libs/c/src/sprintf.c b/loader/libs/c/src/sprintf.c
similarity index 100%
rename from libs/c/src/sprintf.c
rename to loader/libs/c/src/sprintf.c
diff --git a/libs/c/src/srand.c b/loader/libs/c/src/srand.c
similarity index 100%
rename from libs/c/src/srand.c
rename to loader/libs/c/src/srand.c
diff --git a/libs/c/src/strcat.c b/loader/libs/c/src/strcat.c
similarity index 100%
rename from libs/c/src/strcat.c
rename to loader/libs/c/src/strcat.c
diff --git a/libs/c/src/strchr.c b/loader/libs/c/src/strchr.c
similarity index 100%
rename from libs/c/src/strchr.c
rename to loader/libs/c/src/strchr.c
diff --git a/libs/c/src/strcmp.c b/loader/libs/c/src/strcmp.c
similarity index 100%
rename from libs/c/src/strcmp.c
rename to loader/libs/c/src/strcmp.c
diff --git a/libs/c/src/strcoll.c b/loader/libs/c/src/strcoll.c
similarity index 100%
rename from libs/c/src/strcoll.c
rename to loader/libs/c/src/strcoll.c
diff --git a/libs/c/src/strcpy.c b/loader/libs/c/src/strcpy.c
similarity index 100%
rename from libs/c/src/strcpy.c
rename to loader/libs/c/src/strcpy.c
diff --git a/libs/c/src/strcspn.c b/loader/libs/c/src/strcspn.c
similarity index 100%
rename from libs/c/src/strcspn.c
rename to loader/libs/c/src/strcspn.c
diff --git a/libs/c/src/strdup.c b/loader/libs/c/src/strdup.c
similarity index 100%
rename from libs/c/src/strdup.c
rename to loader/libs/c/src/strdup.c
diff --git a/libs/c/src/strerror.c b/loader/libs/c/src/strerror.c
similarity index 100%
rename from libs/c/src/strerror.c
rename to loader/libs/c/src/strerror.c
diff --git a/libs/c/src/strftime.c b/loader/libs/c/src/strftime.c
similarity index 100%
rename from libs/c/src/strftime.c
rename to loader/libs/c/src/strftime.c
diff --git a/libs/c/src/strlen.c b/loader/libs/c/src/strlen.c
similarity index 100%
rename from libs/c/src/strlen.c
rename to loader/libs/c/src/strlen.c
diff --git a/libs/c/src/strncat.c b/loader/libs/c/src/strncat.c
similarity index 100%
rename from libs/c/src/strncat.c
rename to loader/libs/c/src/strncat.c
diff --git a/libs/c/src/strncmp.c b/loader/libs/c/src/strncmp.c
similarity index 100%
rename from libs/c/src/strncmp.c
rename to loader/libs/c/src/strncmp.c
diff --git a/libs/c/src/strncpy.c b/loader/libs/c/src/strncpy.c
similarity index 100%
rename from libs/c/src/strncpy.c
rename to loader/libs/c/src/strncpy.c
diff --git a/libs/c/src/strpbrk.c b/loader/libs/c/src/strpbrk.c
similarity index 100%
rename from libs/c/src/strpbrk.c
rename to loader/libs/c/src/strpbrk.c
diff --git a/libs/c/src/strrchr.c b/loader/libs/c/src/strrchr.c
similarity index 100%
rename from libs/c/src/strrchr.c
rename to loader/libs/c/src/strrchr.c
diff --git a/libs/c/src/strspn.c b/loader/libs/c/src/strspn.c
similarity index 100%
rename from libs/c/src/strspn.c
rename to loader/libs/c/src/strspn.c
diff --git a/libs/c/src/strstr.c b/loader/libs/c/src/strstr.c
similarity index 100%
rename from libs/c/src/strstr.c
rename to loader/libs/c/src/strstr.c
diff --git a/libs/c/src/strtod.c b/loader/libs/c/src/strtod.c
similarity index 100%
rename from libs/c/src/strtod.c
rename to loader/libs/c/src/strtod.c
diff --git a/libs/c/src/strtok.c b/loader/libs/c/src/strtok.c
similarity index 100%
rename from libs/c/src/strtok.c
rename to loader/libs/c/src/strtok.c
diff --git a/libs/c/src/strtol.c b/loader/libs/c/src/strtol.c
similarity index 100%
rename from libs/c/src/strtol.c
rename to loader/libs/c/src/strtol.c
diff --git a/libs/c/src/strtoul.c b/loader/libs/c/src/strtoul.c
similarity index 100%
rename from libs/c/src/strtoul.c
rename to loader/libs/c/src/strtoul.c
diff --git a/libs/c/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c b/loader/libs/c/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c
similarity index 100%
rename from libs/c/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c
rename to loader/libs/c/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c
diff --git a/libs/c/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c b/loader/libs/c/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c
similarity index 100%
rename from libs/c/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c
rename to loader/libs/c/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c
diff --git a/libs/c/src/sys-baremetal/arch-arm/sys_stdio.c b/loader/libs/c/src/sys-baremetal/arch-arm/sys_stdio.c
similarity index 100%
rename from libs/c/src/sys-baremetal/arch-arm/sys_stdio.c
rename to loader/libs/c/src/sys-baremetal/arch-arm/sys_stdio.c
diff --git a/libs/c/src/sys-userspace/arch-arm/plat-pb926/platform_init.c b/loader/libs/c/src/sys-userspace/arch-arm/plat-pb926/platform_init.c
similarity index 100%
rename from libs/c/src/sys-userspace/arch-arm/plat-pb926/platform_init.c
rename to loader/libs/c/src/sys-userspace/arch-arm/plat-pb926/platform_init.c
diff --git a/libs/c/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c b/loader/libs/c/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c
similarity index 100%
rename from libs/c/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c
rename to loader/libs/c/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c
diff --git a/libs/c/src/sys-userspace/arch-arm/sys_stdio.c b/loader/libs/c/src/sys-userspace/arch-arm/sys_stdio.c
similarity index 100%
rename from libs/c/src/sys-userspace/arch-arm/sys_stdio.c
rename to loader/libs/c/src/sys-userspace/arch-arm/sys_stdio.c
diff --git a/libs/c/src/system.c b/loader/libs/c/src/system.c
similarity index 100%
rename from libs/c/src/system.c
rename to loader/libs/c/src/system.c
diff --git a/libs/c/src/time.c b/loader/libs/c/src/time.c
similarity index 100%
rename from libs/c/src/time.c
rename to loader/libs/c/src/time.c
diff --git a/libs/c/src/tmpfile.c b/loader/libs/c/src/tmpfile.c
similarity index 100%
rename from libs/c/src/tmpfile.c
rename to loader/libs/c/src/tmpfile.c
diff --git a/libs/c/src/ungetc.c b/loader/libs/c/src/ungetc.c
similarity index 100%
rename from libs/c/src/ungetc.c
rename to loader/libs/c/src/ungetc.c
diff --git a/libs/c/src/vfprintf.c b/loader/libs/c/src/vfprintf.c
similarity index 100%
rename from libs/c/src/vfprintf.c
rename to loader/libs/c/src/vfprintf.c
diff --git a/libs/c/src/vprintf.c b/loader/libs/c/src/vprintf.c
similarity index 100%
rename from libs/c/src/vprintf.c
rename to loader/libs/c/src/vprintf.c
diff --git a/libs/c/src/vsnprintf.c b/loader/libs/c/src/vsnprintf.c
similarity index 100%
rename from libs/c/src/vsnprintf.c
rename to loader/libs/c/src/vsnprintf.c
diff --git a/libs/elf/SConscript b/loader/libs/elf/SConscript
similarity index 100%
rename from libs/elf/SConscript
rename to loader/libs/elf/SConscript
diff --git a/loader/libs/elf/SConstruct b/loader/libs/elf/SConstruct
new file mode 100644
index 0000000..bdef6ad
--- /dev/null
+++ b/loader/libs/elf/SConstruct
@@ -0,0 +1,42 @@
+# -*- mode: python; coding: utf-8; -*-
+#
+# Codezero -- a microkernel for embedded systems.
+#
+# Copyright © 2009 B Labs Ltd
+
+import os, sys, shelve
+
+# Get global paths
+PROJRELROOT="../../../"
+cwd = os.getcwd()
+os.chdir(PROJRELROOT)
+execfile("configure.py")
+os.chdir(cwd)
+
+# Get configuration information
+config_shelve = shelve.open(CONFIG_SHELVE)
+#symbols = config_shelve["config_symbols"]
+arch = config_shelve["arch"]
+subarch = config_shelve["subarch"]
+platform = config_shelve["platform"]
+all_syms = config_shelve["all_symbols"]
+
+
+# Locally important paths are here
+LIBC_PATH = '../c'
+LIBC_LIBPATH = LIBC_PATH
+LIBC_INCPATH = [join(LIBC_PATH, 'include'), \
+ join(LIBC_PATH, 'include/arch/' + arch)]
+
+env = Environment(CC = 'arm-none-linux-gnueabi-gcc',
+ CCFLAGS = ['-g', '-nostdinc', '-nostdlib', '-ffreestanding'],
+ LINKFLAGS = ['-nostdlib'],
+ ENV = {'PATH' : os.environ['PATH']},
+ LIBS = ['gcc','c-baremetal'],
+ LIBPATH = LIBC_LIBPATH,
+ CPPPATH = ['#include', LIBC_INCPATH] )
+
+src = Glob("src/*.c")
+
+libelf = env.StaticLibrary('elf', src)
+
diff --git a/libs/elf/include/elf/elf.h b/loader/libs/elf/include/elf/elf.h
similarity index 100%
rename from libs/elf/include/elf/elf.h
rename to loader/libs/elf/include/elf/elf.h
diff --git a/libs/elf/include/elf/elf32.h b/loader/libs/elf/include/elf/elf32.h
similarity index 100%
rename from libs/elf/include/elf/elf32.h
rename to loader/libs/elf/include/elf/elf32.h
diff --git a/libs/elf/include/elf/elf64.h b/loader/libs/elf/include/elf/elf64.h
similarity index 100%
rename from libs/elf/include/elf/elf64.h
rename to loader/libs/elf/include/elf/elf64.h
diff --git a/libs/elf/src/elf.c b/loader/libs/elf/src/elf.c
similarity index 100%
rename from libs/elf/src/elf.c
rename to loader/libs/elf/src/elf.c
diff --git a/libs/elf/src/elf32.c b/loader/libs/elf/src/elf32.c
similarity index 100%
rename from libs/elf/src/elf32.c
rename to loader/libs/elf/src/elf32.c
diff --git a/libs/elf/src/elf64.c b/loader/libs/elf/src/elf64.c
similarity index 100%
rename from libs/elf/src/elf64.c
rename to loader/libs/elf/src/elf64.c
diff --git a/loader/linker.lds.in b/loader/linker.lds
similarity index 54%
rename from loader/linker.lds.in
rename to loader/linker.lds
index 5e6da93..c2b8a15 100644
--- a/loader/linker.lds.in
+++ b/loader/linker.lds
@@ -1,11 +1,3 @@
-/****
- **** Template for generating a linker.lds. Edit markers have replaced some items in the original file
- ****
- **** Copyright © 2009 B Labs Ltd
- ****
- **** Author: Russel Winder.
- ****/
-
/*
* Simple linker script for userspace or svc tasks.
*
@@ -21,7 +13,21 @@ SECTIONS
.rodata1 : { *(.rodata1) }
.data :
{
-__LINKER_ITEMS_EDIT_MARKER__
+ _start_kernel = .;
+ *(.kernel)
+ _end_kernel = .;
+ _start_bootdesc = .;
+ *(.bootdesc)
+ _end_bootdesc = .;
+ _start_mm0 = .;
+ *(.mm0)
+ _end_mm0 = .;
+ _start_fs0 = .;
+ *(.fs0)
+ _end_fs0 = .;
+ _start_test0 = .;
+ *(.test0)
+ _end_test0 = .;
*(.data)
}
.got : { *(.got) *(.got.plt) }
diff --git a/loader/pre-build.py b/loader/pre-build.py
new file mode 100755
index 0000000..27b167a
--- /dev/null
+++ b/loader/pre-build.py
@@ -0,0 +1,35 @@
+# -*- mode: python; coding: utf-8; -*-
+#
+# Codezero -- a microkernel for embedded systems.
+#
+# Copyright © 2009 B Labs Ltd
+
+import os, sys, shelve
+
+# Convert address from python literal to numeric value
+def address_remove_literal(address):
+ value = hex(int(address, 16) - 0xf0000000)
+ if value[-1] in ['l', 'L']:
+ value = value[:-1]
+ return value
+
+ksym_header = \
+'''
+/*
+ * %s autogenerated from %s.
+ *
+ * This file is included by the loader sources so that any
+ * kernel symbol address can be known in advance and stopped
+ * at by debuggers before virtual memory is enabled.
+ */
+'''
+
+symbol_section = \
+'''
+.section .text
+.align 4
+.global %s
+.type %s, function
+.equ %s, %s
+'''
+