Merge branch 'master' of git://www.b-labs.co.uk/amit/git/codezero into amit

Conflicts:
	conts/posix/mm0/mm/task.c
This commit is contained in:
Bahadir Balban
2009-11-20 00:20:52 +02:00
52 changed files with 424 additions and 318 deletions

View File

@@ -41,12 +41,13 @@ env = Environment(CC = config.kernel_toolchain + 'gcc',
PROGSUFFIX = '.elf',
ENV = {'PATH' : os.environ['PATH']},
LIBS = ['gcc', 'elf', 'libdev-baremetal', 'c-baremetal', 'gcc'],
LIBPATH = [join('build', LIBELF_PATH), join('build', LIBDEV_PATH), join('build', LIBC_PATH)],
LIBPATH = [join(join('build', LIBDEV_PATH), 'sys-' + variant), \
join('build', LIBELF_PATH), join('build', LIBC_PATH)],
CPPPATH = ['#include', LIBDEV_INCPATH, LIBC_INCPATH, LIBELF_INCPATH])
libdev = SConscript('conts/libdev/SConscript', \
exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : variant}, \
duplicate = 0, variant_dir = 'build/conts/libdev')
duplicate = 0, variant_dir = 'build/conts/libdev/sys-' + variant)
libc = SConscript('loader/libs/c/SConscript', \
exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : variant}, \
duplicate = 0, variant_dir = 'build/loader/libs/c')

View File

@@ -34,10 +34,11 @@ libl4 = SConscript('conts/libl4/SConscript', \
e = env.Clone()
e.Replace(CPPFLAGS = '')
type = 'userspace'
libdev = SConscript('conts/libdev/SConscript', \
exports = { 'env' : e, 'arch' : arch, 'platform' : platform, 'type' : 'userspace' }, \
duplicate = 0, variant_dir = \
join(BUILDDIR, os.path.relpath('conts/libdev', PROJROOT)))
join(join(BUILDDIR, os.path.relpath('conts/libdev', PROJROOT)), 'sys-' + type))
libc = SConscript('conts/libc/SConscript', \
exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : 'userspace' }, \

View File

@@ -1,9 +1,10 @@
symbols
CONT%(cn)d_TYPE_LINUX 'Linux Container'
CONT%(cn)d_TYPE_EXAMPLES 'Examples Container'
CONT%(cn)d_TYPE_POSIX 'Codezero POSIX Services'
CONT%(cn)d_TYPE_TEST 'Test Container'
CONT%(cn)d_OPT_NAME 'Container Name'
CONT%(cn)d_TYPE_LINUX 'Linux Container'
CONT%(cn)d_TYPE_BAREMETAL 'Barebones Container'
CONT%(cn)d_TYPE_POSIX 'POSIX Container'
CONT%(cn)d_TYPE_CUSTOM 'Add New Customized Container'
CONT%(cn)d_OPT_NAME 'Container Name'
CONT%(cn)d_SOURCE_PATH 'Container Source Path'
CONT%(cn)d_PHYSMEM_REGIONS 'Container %(cn)d Number of Physical Regions'
CONT%(cn)d_PHYS0_START 'Container %(cn)d Physical Region 0 Start Address'
@@ -139,12 +140,16 @@ default CONT%(cn)d_VIRT4_END from 0xe0000000
default CONT%(cn)d_VIRT5_START from 0xe0000000
default CONT%(cn)d_VIRT5_END from 0xf0000000
default CONT%(cn)d_OPT_NAME from (CONT%(cn)d_TYPE_LINUX==y) ? "linux%(cn)d" : ((CONT%(cn)d_TYPE_EXAMPLES==y) ? "example%(cn)d" : ((CONT%(cn)d_TYPE_TEST==y) ? "test%(cn)d" : "posix%(cn)d"))
default CONT%(cn)d_OPT_NAME from (CONT%(cn)d_TYPE_LINUX==y) ? "linux%(cn)d" : ((CONT%(cn)d_TYPE_BAREMETAL==y) ? "baremetal%(cn)d" : ((CONT%(cn)d_TYPE_CUSTOM==y) ? "custom%(cn)d" :"posix%(cn)d"))
when CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_default_pager_params cont%(cn)d_posix_pager_params cont%(cn)d_examples_params
when CONT%(cn)d_TYPE_EXAMPLES==y suppress cont%(cn)d_linux_pager_params cont%(cn)d_posix_pager_params
when CONT%(cn)d_TYPE_TEST==y suppress cont%(cn)d_linux_pager_params cont%(cn)d_posix_pager_params cont%(cn)d_examples_params
when CONT%(cn)d_TYPE_POSIX==y suppress cont%(cn)d_linux_pager_params cont%(cn)d_examples_params
default CONT%(cn)d_SOURCE_PATH from "conts/timer"
when CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_default_pager_params cont%(cn)d_posix_pager_params
when CONT%(cn)d_TYPE_BAREMETAL==y suppress cont%(cn)d_linux_pager_params cont%(cn)d_posix_pager_params
when CONT%(cn)d_TYPE_POSIX==y suppress cont%(cn)d_linux_pager_params
when CONT%(cn)d_TYPE_CUSTOM==y suppress cont%(cn)d_linux_pager_params cont%(cn)d_posix_pager_params
unless CONT%(cn)d_TYPE_BAREMETAL==y suppress cont%(cn)d_baremetal_params
unless CONT%(cn)d_TYPE_CUSTOM==y suppress CONT%(cn)d_SOURCE_PATH
symbols
cont%(cn)d_menu 'Container %(cn)d Parameters'
@@ -157,17 +162,18 @@ cont%(cn)d_linux_pager_params 'Container %(cn)d Linux Pager Parameters'
cont%(cn)d_default_pager_params 'Container %(cn)d Default Pager Parameters'
cont%(cn)d_posix_pager_params 'Container %(cn)d POSIX Pager Parameters'
cont%(cn)d_examples_params 'Example Applications List'
CONT%(cn)d_EXAMPLE_APP0 'Empty Application'
CONT%(cn)d_EXAMPLE_APP1 'Hello World'
CONT%(cn)d_EXAMPLE_APP2 'Thread Library Demo'
cont%(cn)d_baremetal_params 'Baremetal Applications List'
CONT%(cn)d_BAREMETAL_APP0 'Empty Application'
CONT%(cn)d_BAREMETAL_APP1 'Hello World'
CONT%(cn)d_BAREMETAL_APP2 'Thread Library Demo'
CONT%(cn)d_BAREMETAL_APP3 'Test Application'
choices cont%(cn)d_examples_params
CONT%(cn)d_EXAMPLE_APP0
CONT%(cn)d_EXAMPLE_APP1
CONT%(cn)d_EXAMPLE_APP2
default CONT%(cn)d_EXAMPLE_APP0
choices cont%(cn)d_baremetal_params
CONT%(cn)d_BAREMETAL_APP0
CONT%(cn)d_BAREMETAL_APP1
CONT%(cn)d_BAREMETAL_APP2
CONT%(cn)d_BAREMETAL_APP3
default CONT%(cn)d_BAREMETAL_APP0
menu cont%(cn)d_default_pager_params
CONT%(cn)d_PAGER_LMA@
@@ -637,7 +643,8 @@ menu cont%(cn)d_capability_list
menu container%(cn)d_options
CONT%(cn)d_OPT_NAME$
cont%(cn)d_examples_params
CONT%(cn)d_SOURCE_PATH$
cont%(cn)d_baremetal_params
cont%(cn)d_linux_pager_params
cont%(cn)d_default_pager_params
cont%(cn)d_posix_pager_params
@@ -646,11 +653,11 @@ menu container%(cn)d_options
cont%(cn)d_capability_list
choices container%(cn)d_type
CONT%(cn)d_TYPE_EXAMPLES
CONT%(cn)d_TYPE_LINUX
CONT%(cn)d_TYPE_BAREMETAL
CONT%(cn)d_TYPE_POSIX
CONT%(cn)d_TYPE_TEST
default CONT%(cn)d_TYPE_EXAMPLES
CONT%(cn)d_TYPE_CUSTOM
CONT%(cn)d_TYPE_LINUX
default CONT%(cn)d_TYPE_BAREMETAL
menu cont%(cn)d_menu
container%(cn)d_type

View File

@@ -1,113 +0,0 @@
#
# Automatically generated, don't edit
#
# Generated on: bahadir-laptop
# At: Fri, 23 Oct 2009 09:24:42 +0000
# Linux version 2.6.24-22-generic (buildd@vernadsky) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Mon Nov 24 18:32:42 UTC 2008
#
# Codezero Microkernel Configurator
#
#
# Main architecture
#
CONFIG_ARCH_ARM=y
#
# ARM Architecture Configuration
#
#
# ARM Architecture Family
#
CONFIG_SUBARCH_V5=y
CONFIG_SUBARCH_V6=n
CONFIG_SUBARCH_V7=n
#
# ARM CPU type
#
#
# ARM Processor Type
#
CONFIG_CPU_ARM926=y
#
# ARM Platform Type
#
#
# ARM Platform Type
#
CONFIG_PLATFORM_EB=n
CONFIG_PLATFORM_AB926=n
CONFIG_PLATFORM_PB926=y
#
# Platform Drivers
#
CONFIG_DRIVER_UART_PL011=y
CONFIG_DRIVER_TIMER_SP804=y
CONFIG_DRIVER_IRQ_PL190=y
CONFIG_CONTAINERS=1
#
# Container Setup
#
#
# Container 0 Parameters
#
#
# Container 0 Type
#
CONFIG_CONT0_TYPE_LINUX=n
CONFIG_CONT0_TYPE_BARE=n
CONFIG_CONT0_TYPE_POSIX=n
CONFIG_CONT0_TYPE_TEST=y
#
# Container 0 Options
#
CONFIG_CONT0_OPT_NAME="caps"
#
# Container 0 Default Pager Parameters
#
CONFIG_CONT0_PAGER_LMA=0x40000
CONFIG_CONT0_PAGER_VMA=0x10000000
#
# Container 0 Physical Memory Regions
#
CONFIG_CONT0_PHYSMEM_REGIONS=1
CONFIG_CONT0_PHYS0_START=0x40000
CONFIG_CONT0_PHYS0_END=0x200000
#
# Container 0 Virtual Memory Regions
#
CONFIG_CONT0_VIRTMEM_REGIONS=1
CONFIG_CONT0_VIRT0_START=0x10000000
CONFIG_CONT0_VIRT0_END=0x20000000
#
# That's all, folks!

View File

@@ -12,7 +12,8 @@ class Container:
self.name = None
self.type = None
self.id = id
self.example_id = 0
self.src_path = None
self.baremetal_id = 0
self.pager_lma = 0
self.pager_vma = 0
self.pager_size = 0
@@ -131,7 +132,10 @@ class configuration:
# TODO: Carry this over to Container() as static method???
def get_container_parameter(self, id, param, val):
if param[:len("PAGER_LMA")] == "PAGER_LMA":
if param[:len("SOURCE_PATH")] == "SOURCE_PATH":
parts = val.split("\"", 3)
self.containers[id].src_path = parts[1]
elif param[:len("PAGER_LMA")] == "PAGER_LMA":
self.containers[id].pager_lma = int(val, 0)
elif param[:len("PAGER_VMA")] == "PAGER_VMA":
self.containers[id].pager_vma = int(val, 0)
@@ -173,9 +177,9 @@ class configuration:
dirname = val[1:-1].lower()
self.containers[id].dirname = dirname
self.containers[id].name = dirname
elif param[:len("EXAMPLE_APP")] == "EXAMPLE_APP":
elif param[:len("BAREMETAL_APP")] == "BAREMETAL_APP":
param1 = param.split("_", 1)
self.containers[id].example_id = param1[1][-1:]
self.containers[id].baremetal_id = param1[1][-1:]
elif param[:len("CAP_")] == "CAP_":
prefix, param_rest = param.split('_', 1)
prepare_capability(self.containers[id], param_rest, val)
@@ -186,10 +190,10 @@ class configuration:
self.containers[id].type = "linux"
elif param2 == "POSIX":
self.containers[id].type = "posix"
elif param2 == "EXAMPLES":
self.containers[id].type = "examples"
elif param2 == "TEST":
self.containers[id].type = "test"
elif param2 == "BAREMETAL":
self.containers[id].type = "baremetal"
elif param2 == "CUSTOM":
self.containers[id].type = "custom"
# Extract parameters for containers
def get_container_parameters(self, name, val):
matchobj = re.match(r"(CONFIG_CONT){1}([0-9]){1}(\w+)", name)

View File

@@ -30,8 +30,6 @@ LINUX_ATAGSDIR = join(LINUXDIR, 'atags')
POSIXDIR = join(PROJROOT, 'conts/posix')
POSIX_BOOTDESCDIR = join(POSIXDIR, 'bootdesc')
TESTDIR = join(PROJROOT, 'conts/test')
projpaths = { \
'LINUX_ATAGSDIR' : LINUX_ATAGSDIR, \
'LINUX_ROOTFSDIR' : LINUX_ROOTFSDIR, \

View File

@@ -4,7 +4,8 @@ import os, sys, shelve, shutil
from os.path import join
from config.projpaths import *
from config.configuration import *
from scripts.examples.examples_generator import *
from scripts.baremetal.baremetal_generator import *
from scripts.custom.custom_generator import *
from scripts.kernel.generate_kernel_cinfo import *
from scripts.cml.generate_container_cml import *
from optparse import OptionParser
@@ -184,9 +185,13 @@ def configure_system(options, args):
configuration_save(config)
# Generate example container files if new ones defined
examples_cont_gen = ExamplesContGenerator()
examples_cont_gen.examples_container_generate(config)
# Generate baremetal container files if new ones defined
baremetal_cont_gen = BaremetalContGenerator()
baremetal_cont_gen.baremetal_container_generate(config)
# Generate custom container files if new ones defined
custom_cont_gen = CustomContGenerator()
custom_cont_gen.custom_container_generate(config)
# Print out the configuration if asked
if options.print_config:

View File

@@ -7,7 +7,7 @@
import os, shelve, sys
from os.path import *
PROJRELROOT = '../..'
PROJRELROOT = '../../..'
sys.path.append(PROJRELROOT)
@@ -32,6 +32,10 @@ LIBC_LIBPATH = join(BUILDDIR, LIBC_RELDIR)
LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \
join(LIBC_DIR, 'include/arch' + '/' + arch)]
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
env = Environment(CC = 'arm-none-linux-gnueabi-gcc',
# We don't use -nostdinc because sometimes we need standard headers,
@@ -42,9 +46,9 @@ env = Environment(CC = 'arm-none-linux-gnueabi-gcc',
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', 'c-userspace'], # libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBC_INCLUDE],
LIBPATH = [LIBL4_LIBPATH, LIBC_LIBPATH],
LIBS = ['gcc', 'libl4', 'c-userspace', 'libdev-userspace', 'gcc', 'c-userspace'], # libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, LIBC_INCLUDE],
LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH],
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
src = Glob('*.[cS]')

View File

@@ -7,7 +7,7 @@
import os, shelve, sys
from os.path import *
PROJRELROOT = '../..'
PROJRELROOT = '../../..'
sys.path.append(PROJRELROOT)
@@ -34,7 +34,7 @@ LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(BUILDDIR, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
LIBMEM_RELDIR = 'conts/libmem'

View File

@@ -7,7 +7,7 @@
import os, shelve, sys
from os.path import *
PROJRELROOT = '../..'
PROJRELROOT = '../../..'
sys.path.append(PROJRELROOT)

View File

@@ -0,0 +1,59 @@
# -*- mode: python; coding: utf-8; -*-
#
# Codezero -- Virtualization microkernel for embedded systems.
#
# Copyright © 2009 B Labs Ltd
#
import os, shelve, sys
from os.path import *
PROJRELROOT = '../../..'
sys.path.append(PROJRELROOT)
from config.projpaths import *
from config.configuration import *
from config.lib 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)
# 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)]
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
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", "-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', 'libdev-userspace', 'gcc', 'c-userspace'], # libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, LIBC_INCLUDE],
LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH],
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
src = Glob('*.[cS]')
src += Glob('src/*.[cS]')
objs = env.Object(src)
prog = env.Program('main.elf', objs)
Depends(prog, 'include/linker.lds')

View File

@@ -8,7 +8,7 @@
#include <l4lib/utcb.h>
void main(void);
extern void main(void);
void __container_init(void)
{

View File

@@ -25,7 +25,7 @@ LIBDEV_INCPATH = [LIBDEV_PATH + '/uart/include']
e = env.Clone()
e.Append(CPPPATH = ['include', 'include/sys-' + variant + '/arch-' + arch,
LIBDEV_INCPATH],
CCFLAGS = ['-nostdinc', '-DVARIANT_' + variant.upper()])
CCFLAGS = '-nostdinc')
source = \
Glob('src/*.c') + \

View File

@@ -34,8 +34,8 @@ LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(BUILDDIR, LIBDEV_RELDIR)
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = join(LIBDEV_DIR, 'uart/include')
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)

View File

@@ -1,44 +0,0 @@
Import('config', 'env', 'contid')
import os, sys
from config.projpaths import *
arch = config.arch
sys.path.append('../../')
from config.lib import *
container = next((c for c in config.containers if int(c.id) == int(contid)), None)
CONTAINER_INCLUDE = join(BUILDDIR, 'cont' + str(contid) + '/test' + '/include')
def generate_linker_script(target, source, env):
with open(source[0].path, 'r') as lds_in:
linker_script = lds_in.read()
with open(target[0].path, 'w+') as lds_out:
assert container.pager_vma != 0
assert container.pager_lma != 0
lds_out.write(linker_script % (conv_hex(container.pager_vma), conv_hex(container.pager_lma)))
def generate_container_h(target, source, env):
with open(source[0].path, 'r') as fin:
str = fin.read()
with open(target[0].path, 'w+') as fout:
# Make any manipulations here
fout.write(str % (container.name, container.id, container.id))
linker_lds = Command('include/linker.lds', 'include/linker.lds.in', generate_linker_script)
container_h = Command('include/container.h', 'include/container.h.in', generate_container_h)
src = [Glob('*.[cS]') + Glob('src/*.[cS]') + Glob('src/arch/*.[cS]')]
env.Append(LINKFLAGS = ['-T' + linker_lds[0].path, '-u_start'])
env.Append(CPPPATH = [CONTAINER_INCLUDE])
objs = env.Object(src)
prog = env.Program('main.elf', objs)
Depends(linker_lds, CML2_CONFIG_H)
Depends(prog, linker_lds)

View File

@@ -1,56 +0,0 @@
# -*- mode: python; coding: utf-8; -*-
#
# Codezero -- Virtualization microkernel for embedded systems.
#
# Copyright © 2009 B Labs Ltd
#
import os, shelve, sys
from os.path import *
PROJRELROOT = '../../'
sys.path.append(PROJRELROOT)
from config.projpaths import *
from config.configuration import *
from config.lib 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)
# 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)]
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'],
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', 'c-userspace'], # 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')
contid = ARGUMENTS.get('cont', '0')
SConscript('SConscript', \
exports = { 'config' : config, 'env' : env, 'contid' : contid }, duplicate = 0, \
variant_dir = join(BUILDDIR, 'cont' + str(contid) + '/test'))

View File

@@ -19,11 +19,10 @@ from config.projpaths import *
from config.configuration import *
from config.lib import *
class ExamplesContGenerator:
class BaremetalContGenerator:
def __init__(self):
self.CONT_SRC_DIR = '' # Set when container is selected
self.EXAMPLES_SRC_BASEDIR = join(PROJROOT, 'conts')
self.EXAMPLES_PROJ_SRC_DIR = join(PROJROOT, 'conts/examples')
self.BAREMETAL_PROJ_SRC_DIR = join(PROJROOT, 'conts/baremetal')
self.main_builder_name = 'build.py'
self.main_configurator_name = 'configure.py'
@@ -47,12 +46,12 @@ class ExamplesContGenerator:
self.build_desc_out = None
self.src_main_out = None
def create_examples_srctree(self, config, cont):
def create_baremetal_srctree(self, config, cont):
# First, create the base project directory and sources
str = 'example' + cont.example_id
shutil.copytree(join(self.EXAMPLES_PROJ_SRC_DIR, str), self.CONT_SRC_DIR)
str = 'baremetal' + cont.baremetal_id
shutil.copytree(join(self.BAREMETAL_PROJ_SRC_DIR, str), self.CONT_SRC_DIR)
def copy_examples_build_desc(self, config, cont):
def copy_baremetal_build_desc(self, config, cont):
id_header = '[Container ID]\n'
type_header = '\n[Container Type]\n'
name_header = '\n[Container Name]\n'
@@ -79,7 +78,7 @@ class ExamplesContGenerator:
fout.write(pager_physmem_header % ireg)
fout.write('\t' + cont.physmem["START"][ireg] + ' - ' + cont.physmem["END"][ireg] + '\n')
def copy_examples_build_readme(self, config, cont):
def copy_baremetal_build_readme(self, config, cont):
with open(self.build_readme_in) as fin:
str = fin.read()
with open(self.build_readme_out, 'w+') as fout:
@@ -91,30 +90,30 @@ class ExamplesContGenerator:
self.main_configurator_name, \
self.main_configurator_name))
def copy_examples_container_h(self, config, cont):
def copy_baremetal_container_h(self, config, cont):
with open(self.container_h_in) as fin:
str = fin.read()
with open(self.container_h_out, 'w+') as fout:
# Make any manipulations here
fout.write(str % (cont.name, cont.id, cont.id))
def create_examples_sources(self, config, cont):
self.create_examples_srctree(config, cont)
self.copy_examples_build_readme(config, cont)
self.copy_examples_build_desc(config, cont)
def create_baremetal_sources(self, config, cont):
self.create_baremetal_srctree(config, cont)
self.copy_baremetal_build_readme(config, cont)
self.copy_baremetal_build_desc(config, cont)
self.generate_linker_script(config, cont)
self.copy_examples_container_h(config, cont)
self.copy_baremetal_container_h(config, cont)
def update_configuration(self, config, cont):
self.copy_examples_build_desc(config, cont)
self.copy_baremetal_build_desc(config, cont)
self.generate_linker_script(config, cont)
self.copy_examples_container_h(config, cont)
self.copy_baremetal_container_h(config, cont)
def check_create_examples_sources(self, config):
def check_create_baremetal_sources(self, config):
for cont in config.containers:
if cont.type == "examples":
if cont.type == "baremetal":
# Determine container directory name.
self.CONT_SRC_DIR = join(self.EXAMPLES_SRC_BASEDIR, cont.dirname.lower())
self.CONT_SRC_DIR = join(join(BUILDDIR, 'cont') + str(cont.id), cont.name)
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'), \
@@ -122,8 +121,8 @@ class ExamplesContGenerator:
self.container_h_out = join(join(self.CONT_SRC_DIR, 'include'), \
self.container_h_name)
if not os.path.exists(join(self.EXAMPLES_SRC_BASEDIR, cont.dirname)):
self.create_examples_sources(config, cont)
if not os.path.exists(self.CONT_SRC_DIR):
self.create_baremetal_sources(config, cont)
else:
# Don't create new sources but update configuration
self.update_configuration(config, cont)
@@ -135,12 +134,12 @@ class ExamplesContGenerator:
fout.write(str % (conv_hex(cont.pager_vma), \
conv_hex(cont.pager_lma)))
def examples_container_generate(self, config):
self.check_create_examples_sources(config)
def baremetal_container_generate(self, config):
self.check_create_baremetal_sources(config)
if __name__ == "__main__":
config = configuration_retrieve()
config.config_print()
examples_cont = ExamplesContGenerator()
examples_cont.examples_container_generate(config)
baremetal_cont = BaremetalContGenerator()
baremetal_cont.baremetal_container_generate(config)

View File

@@ -77,42 +77,22 @@ def build_posix_container(config, projpaths, container):
container_packer = DefaultContainerPacker(container, images)
return container_packer.pack_container(config)
# We simply use SCons to figure all this out from container.id
# Builds the test container.
def build_test_container(config, projpaths, container):
images = []
cwd = os.getcwd()
os.chdir(TESTDIR)
print '\nBuilding the Test Container...'
scons_cmd = 'scons ' + 'cont=' + str(container.id)
print "Issuing scons command: %s" % scons_cmd
os.system(scons_cmd)
builddir = source_to_builddir(TESTDIR, container.id)
os.path.walk(builddir, glob_by_walk, ['*.elf', images])
# Calculate and store size of pager
pager_binary = "cont" + str(container.id) + "/test/main.elf"
config.containers[container.id].pager_size = \
conv_hex(elf_binary_size(join(BUILDDIR, pager_binary)))
container_packer = DefaultContainerPacker(container, images)
return container_packer.pack_container(config)
# This simply calls SCons on a given container, and collects
# all images with .elf extension, instead of using whole classes
# for building and packing.
def build_default_container(config, projpaths, container):
images = []
cwd = os.getcwd()
projdir = join(join(PROJROOT, 'conts'), container.name)
projdir = join(join(BUILDDIR, 'cont') + str(container.id), \
container.name)
os.chdir(projdir)
os.system("scons")
os.path.walk(projdir, glob_by_walk, ['*.elf', images])
# Calculate and store size of pager
pager_binary = "conts/" + container.name + "/main.elf"
pager_binary = join("cont" + str(container.id), container.name) + "/main.elf"
config.containers[container.id].pager_size = \
conv_hex(elf_binary_size(join(PROJROOT, pager_binary)))
conv_hex(elf_binary_size(join(BUILDDIR, pager_binary)))
container_packer = DefaultContainerPacker(container, images)
return container_packer.pack_container(config)
@@ -124,12 +104,10 @@ def build_all_containers():
if container.type == 'linux':
pass
cont_images.append(build_linux_container(config, projpaths, container))
elif container.type == 'examples':
elif container.type == 'baremetal' or container.type == 'custom':
cont_images.append(build_default_container(config, projpaths, container))
elif container.type == 'posix':
cont_images.append(build_posix_container(config, projpaths, container))
elif container.type == 'test':
cont_images.append(build_test_container(config, projpaths, container))
else:
print "Error: Don't know how to build " + \
"container of type: %s" % (container.type)

View File

View File

@@ -0,0 +1,143 @@
#! /usr/bin/env python2.6
# -*- mode: python; coding: utf-8; -*-
#
# Codezero -- Virtualization microkernel for embedded systems.
#
# Copyright © 2009 B Labs Ltd
#
import os, sys, shelve, glob
from os.path import join
PROJRELROOT = '../../'
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
sys.path.append(os.path.abspath("../"))
SCRIPTROOT = os.path.abspath(os.path.dirname(__file__))
from config.projpaths import *
from config.configuration import *
from config.lib import *
class CustomContGenerator:
def __init__(self):
self.CONT_SRC_DIR = '' # Set when container is selected
self.main_builder_name = 'build.py'
self.main_configurator_name = 'configure.py'
self.mailing_list_url = 'http://lists.l4dev.org/mailman/listinfo/codezero-devel'
self.build_script_in = join(SCRIPTROOT, 'files/SConstruct.in')
self.build_readme_in = join(SCRIPTROOT, 'files/build.readme.in')
self.build_desc_in = join(SCRIPTROOT, 'files/container.desc.in')
self.linker_lds_in = join(SCRIPTROOT, 'files/linker.lds.in')
self.container_h_in = join(SCRIPTROOT, 'files/container.h.in')
self.build_script_name = 'SConstruct'
self.build_readme_name = 'build.readme'
self.build_desc_name = '.container'
self.linker_lds_name = 'linker.lds'
self.container_h_name = 'container.h'
self.container_h_out = None
self.build_script_out = None
self.build_readme_out = None
self.build_desc_out = None
self.src_main_out = None
def create_custom_srctree(self, config, cont):
# First, create the base project directory and sources
shutil.copytree(join(PROJROOT, cont.src_path), self.CONT_SRC_DIR)
def copy_custom_build_desc(self, config, cont):
id_header = '[Container ID]\n'
type_header = '\n[Container Type]\n'
name_header = '\n[Container Name]\n'
pager_lma_header = '\n[Container Pager LMA]\n'
pager_vma_header = '\n[Container Pager VMA]\n'
pager_virtmem_header = '\n[Container Virtmem Region %s]\n'
pager_physmem_header = '\n[Container Physmem Region %s]\n'
with open(self.build_desc_out, 'w+') as fout:
fout.write(id_header)
fout.write('\t' + str(cont.id) + '\n')
fout.write(type_header)
fout.write('\t' + cont.type + '\n')
fout.write(name_header)
fout.write('\t' + cont.name + '\n')
fout.write(pager_lma_header)
fout.write('\t' + conv_hex(cont.pager_lma) + '\n')
fout.write(pager_vma_header)
fout.write('\t' + conv_hex(cont.pager_vma) + '\n')
for ireg in range(cont.virt_regions):
fout.write(pager_virtmem_header % ireg)
fout.write('\t' + cont.virtmem["START"][ireg] + ' - ' + cont.virtmem["END"][ireg] + '\n')
for ireg in range(cont.phys_regions):
fout.write(pager_physmem_header % ireg)
fout.write('\t' + cont.physmem["START"][ireg] + ' - ' + cont.physmem["END"][ireg] + '\n')
def copy_custom_build_readme(self, config, cont):
with open(self.build_readme_in) as fin:
str = fin.read()
with open(self.build_readme_out, 'w+') as fout:
# Make any manipulations here
fout.write(str % (self.mailing_list_url, \
cont.name, \
self.build_desc_name, \
self.main_builder_name, \
self.main_configurator_name, \
self.main_configurator_name))
def copy_custom_container_h(self, config, cont):
with open(self.container_h_in) as fin:
str = fin.read()
with open(self.container_h_out, 'w+') as fout:
# Make any manipulations here
fout.write(str % (cont.name, cont.id, cont.id))
def create_custom_sources(self, config, cont):
self.create_custom_srctree(config, cont)
self.copy_custom_build_readme(config, cont)
self.copy_custom_build_desc(config, cont)
self.generate_linker_script(config, cont)
self.copy_custom_container_h(config, cont)
def update_configuration(self, config, cont):
self.copy_custom_build_desc(config, cont)
self.generate_linker_script(config, cont)
self.copy_custom_container_h(config, cont)
def check_create_custom_sources(self, config):
for cont in config.containers:
if cont.type == "custom":
# Determine container directory name.
self.CONT_SRC_DIR = join(join(BUILDDIR, 'cont') + str(cont.id), cont.name)
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.container_h_out = join(join(self.CONT_SRC_DIR, 'include'), \
self.container_h_name)
if not os.path.exists(self.CONT_SRC_DIR):
self.create_custom_sources(config, cont)
else:
# Don't create new sources but update configuration
self.update_configuration(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 % (conv_hex(cont.pager_vma), \
conv_hex(cont.pager_lma)))
def custom_container_generate(self, config):
self.check_create_custom_sources(config)
if __name__ == "__main__":
config = configuration_retrieve()
config.config_print()
custom_cont = CustomContGenerator()
custom_cont.custom_container_generate(config)

View File

View File

@@ -0,0 +1,112 @@
Codezero Buildsystem For This Container
Autogenerated by the Build system
This is an autogenerated file that is meant to walk you through the build
process. It is meant to be the most simple to get on with, therefore if
you feel any complications, please reach us on our l4dev.org mailing list
on %s
You have created a new container called `%s'.
The parameters you have supplied are described in the "%s" file
placed at the top-level directory. Note, that this is only an informative
file for your reference, and it can be optionally removed.
1. Directory Structure:
1.1) Directory tree:
.
|-- SConstruct
|-- build.readme
|-- .container
|-- include
| `-- linker.lds.example
|-- main.c
`-- src
|-- test.c
In the above directory tree:
1.2) |-- SConstruct
This is the top-level build file, that will build your project in its current
state. You may freely reorganize directories, but must reflect changes in this
file. For more, please see the SCons build tool at http://www.scons.org/
The build system will search for this file, and execute it by the:
`scons'
command at the root of the directory. You may issue the same command manually
for building and testing your build. If you choose to use another build tool
such as make, you may freely replace scons, and the build system will search
and call your custom build command.
1.3) |--include
`--src
These are the directories that include your header files and sources. You may
freely change and reorganize these, but make sure to have a valid build file
that reflects those changes at the top-level directory.
1.4) |-- include
| `-- linker.lds.example
This is an example linker script for your project. Using this as your default
linker script is often useful, since it has been autogenerated to contain all
the parameters you need for the memory regions of your application defined at
configuration time. You may freely replace it, but make sure to edit the
top-level build script accordingly.
2. Build Process
2.1) Build overview
The complete Codezero system will be built from a top-level `%s' script by
that resides in the top-level directory of Codezero sources.
The Codezero system build script will build this container at a certain stage
during the build, by referring to build script file named such as `SConstruct'
or `Makefile' that resides in this container's top-level directory.
Once the executables are built, it will search for all files with a .elf
extension in any of the subdirectories, and recognize those as loadable
executables. There may be more than one of these files present after the build.
In the future this behaviour may change such that the loadable executable files
are also specified in the configuration.
Finally, executables of all containers will be picked up and built into the
final.elf file, which is a self-loading elf executable.
3. Reconfiguring this container
If you want to reconfigure the container with new parameters, you may do so by
executing the `%s' script at the top-level Codezero directory by:
'./%s'
This will populate only brand new container directories with new files. It will
update it's existing internal configuration for existing containers (such as
container memory regions) but it won't touch any files that exist under an
already-defined container.
If you want to start from scratch, specify a new directory name, if you want
to reconfigure existing container parameters, run this on an existing directory,
and it will only update its internal records for this container, but not touch
the directory.
4. Example source files
Example source files populated by the configuration contain valid examples
of how the generic libl4 userspace library can be used. Each test contains a
valid example from the available API, and may be modified, changed and removed
freely.

View File

@@ -0,0 +1,8 @@
[Container Name]
[Container LMA]
[Container VMA]
[Container Type]