mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Test program for bare repos now links with libl4 and libc.
The userspace bare libc has been re-added to the repo.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
#
|
||||
# Codezero -- a microkernel for embedded systems.
|
||||
# Codezero -- Virtualization microkernel for embedded systems.
|
||||
#
|
||||
# Copyright © 2009 B Labs Ltd
|
||||
#
|
||||
@@ -40,10 +40,4 @@ objects += SConscript('src/lib/SConscript', exports = {'symbols' : all_syms, 'en
|
||||
objects += SConscript('src/api/SConscript', exports = {'symbols' : all_syms, 'env' : env})
|
||||
|
||||
kernel_elf = env.Program(BUILDDIR + '/kernel.elf', objects)
|
||||
|
||||
libl4 = SConscript('conts/libl4/SConscript', \
|
||||
exports = { 'arch' : arch }, duplicate = 0, \
|
||||
variant_dir = join(BUILDDIR, os.path.relpath('conts/libl4', PROJROOT)))
|
||||
|
||||
Alias('libl4', libl4)
|
||||
Alias('kernel', kernel_elf)
|
||||
|
||||
93
conts/libc/crt/sys-userspace/arch-arm/crt0.S
Normal file
93
conts/libc/crt/sys-userspace/arch-arm/crt0.S
Normal file
@@ -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.
|
||||
*/
|
||||
|
||||
#ifdef __thumb__
|
||||
#define bl blx
|
||||
#endif
|
||||
|
||||
.code 32
|
||||
.global _start;
|
||||
.align;
|
||||
_start:
|
||||
ldr sp, =__stack
|
||||
bl platform_init
|
||||
bl __container_init
|
||||
1:
|
||||
b 1b
|
||||
|
||||
@@ -14,28 +14,37 @@ sys.path.append(PROJRELROOT)
|
||||
from config.projpaths import *
|
||||
from config.configuration import *
|
||||
|
||||
|
||||
config = configuration_retrieve()
|
||||
|
||||
arch = config.arch
|
||||
|
||||
LIBL4_RELDIR = 'conts/libl4'
|
||||
KERNEL_INCLUDE = join(PROJROOT, 'include')
|
||||
LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR)
|
||||
LIBL4_INCLUDE = join(LIBL4_DIR, 'include')
|
||||
LIBL4_LIBPATH = join(BUILDDIR, LIBL4_RELDIR)
|
||||
|
||||
config = configuration_retrieve()
|
||||
# Locally important paths are here
|
||||
LIBC_RELDIR = 'conts/libc'
|
||||
LIBC_DIR = join(PROJROOT, LIBC_RELDIR)
|
||||
LIBC_LIBPATH = join(BUILDDIR, LIBC_RELDIR)
|
||||
LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \
|
||||
join(LIBC_DIR, 'include/arch' + '/' + arch)]
|
||||
|
||||
arch = config.arch
|
||||
|
||||
env = Environment(CC = 'arm-none-linux-gnueabi-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/linker.lds"],
|
||||
ASFLAGS = ['-D__ASSEMBLY__'],
|
||||
PROGSUFFIX = '.elf', # The suffix to use for final executable
|
||||
ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path
|
||||
LIBS = ['gcc', 'libl4'], # libgcc.a - This is required for division routines.
|
||||
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE],
|
||||
LIBPATH = LIBL4_LIBPATH,
|
||||
'-std=gnu99', '-Wall', '-Werror'], \
|
||||
LINKFLAGS = ['-nostdlib', '-T' + "include/linker.lds", "-u_start"],\
|
||||
ASFLAGS = ['-D__ASSEMBLY__'], \
|
||||
PROGSUFFIX = '.elf', # The suffix to use for final executable\
|
||||
ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path\
|
||||
LIBS = ['gcc', 'libl4', 'c-userspace', 'gcc'], # libgcc.a - This is required for division routines.
|
||||
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBC_INCLUDE],
|
||||
LIBPATH = [LIBL4_LIBPATH, LIBC_LIBPATH],
|
||||
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
|
||||
|
||||
src = Glob('*.[cS]')
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Example working linker script for this container.
|
||||
*
|
||||
* Copyright (C) 2009 B Labs Ltd.
|
||||
*/
|
||||
|
||||
vma_start = 0x0;
|
||||
lma_start = 0x1000000;
|
||||
offset = vma_start - lma_start;
|
||||
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = vma_start;
|
||||
.text : AT (ADDR(.text) - offset) { *(.text.head) *(.text) }
|
||||
.rodata : AT (ADDR(.rodata) - offset) { *(.rodata) }
|
||||
.rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) }
|
||||
|
||||
. = ALIGN(4K);
|
||||
.data : AT (ADDR(.data) - offset) { *(.data) }
|
||||
.bss : AT (ADDR(.bss) - offset) { *(.bss) }
|
||||
. += 0x1000;
|
||||
. = ALIGN(8);
|
||||
__stack = .;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
#
|
||||
# Codezero -- a microkernel for embedded systems.
|
||||
# Codezero -- Virtualization microkernel for embedded systems.
|
||||
#
|
||||
# Copyright © 2009 B Labs Ltd
|
||||
|
||||
|
||||
@@ -31,10 +31,12 @@ class BareContGenerator:
|
||||
self.build_script_in = join(SCRIPTROOT, 'SConstruct.in')
|
||||
self.build_readme_in = join(SCRIPTROOT, 'build.readme.in')
|
||||
self.build_desc_in = join(SCRIPTROOT, 'container.desc.in')
|
||||
self.linker_lds_in = join(SCRIPTROOT, 'linker.lds.in')
|
||||
|
||||
self.build_script_name = 'SConstruct'
|
||||
self.build_readme_name = 'build.readme'
|
||||
self.build_desc_name = '.container'
|
||||
self.linker_lds_name = 'linker.lds'
|
||||
|
||||
self.build_script_out = None
|
||||
self.build_readme_out = None
|
||||
@@ -82,10 +84,13 @@ class BareContGenerator:
|
||||
|
||||
self.build_readme_out = join(self.CONT_SRC_DIR, self.build_readme_name)
|
||||
self.build_desc_out = join(self.CONT_SRC_DIR, self.build_desc_name)
|
||||
self.linker_lds_out = join(join(self.CONT_SRC_DIR, 'include'), \
|
||||
self.linker_lds_name)
|
||||
|
||||
self.create_bare_srctree(config, cont)
|
||||
self.copy_bare_build_readme(config, cont)
|
||||
self.copy_bare_build_desc(config, cont)
|
||||
self.generate_linker_script(config, cont)
|
||||
|
||||
def check_create_bare_sources(self, config):
|
||||
for cont in config.containers:
|
||||
@@ -93,6 +98,13 @@ class BareContGenerator:
|
||||
if not os.path.exists(join(self.BARE_SRC_BASEDIR, cont.dirname)):
|
||||
self.create_bare_sources(config, cont)
|
||||
|
||||
def generate_linker_script(self, config, cont):
|
||||
with open(self.linker_lds_in) as fin:
|
||||
str = fin.read()
|
||||
with open(self.linker_lds_out, 'w+') as fout:
|
||||
fout.write(str % (cont.vma_start, \
|
||||
cont.lma_start))
|
||||
|
||||
def bare_container_generate(self, config):
|
||||
self.check_create_bare_sources(config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user