Bare container type is converted to Examples container type.

Examples container type is designed to keep applications using codezero
userspace libraries, which is aiming to help newcomers who would like to
develop programs on top of the l4 microkernel.

Now bare bone application is one of the examples. In the near future, lots of
new programs will be introduced to show the various aspects of codezero
eco-system.
This commit is contained in:
Bora Sahin
2009-10-28 14:11:43 +02:00
parent b7e575817d
commit 050f537884
22 changed files with 162 additions and 66 deletions

View File

@@ -1,6 +1,6 @@
symbols
CONT%(cn)d_TYPE_LINUX 'Linux Container'
CONT%(cn)d_TYPE_BARE 'Bare 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'
@@ -113,12 +113,12 @@ default CONT%(cn)d_VIRT4_END from 0x0
default CONT%(cn)d_VIRT5_START from 0x0
default CONT%(cn)d_VIRT5_END from 0x0
default CONT%(cn)d_OPT_NAME from (CONT%(cn)d_TYPE_LINUX==y) ? "linux%(cn)d" : ((CONT%(cn)d_TYPE_BARE==y) ? "bare%(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_EXAMPLES==y) ? "example%(cn)d" : ((CONT%(cn)d_TYPE_TEST==y) ? "test%(cn)d" : "posix%(cn)d"))
when CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_bare_pager_params cont%(cn)d_posix_pager_params
when CONT%(cn)d_TYPE_BARE==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
when CONT%(cn)d_TYPE_POSIX==y suppress cont%(cn)d_linux_pager_params
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
symbols
cont%(cn)d_menu 'Container %(cn)d Parameters'
@@ -128,10 +128,20 @@ container%(cn)d_type 'Container %(cn)d Type'
container%(cn)d_options 'Container %(cn)d Options'
cont%(cn)d_linux_pager_params 'Container %(cn)d Linux Pager Parameters'
cont%(cn)d_bare_pager_params 'Container %(cn)d Default 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'
menu cont%(cn)d_bare_pager_params
cont%(cn)d_examples_params 'Example Applications List'
CONT%(cn)d_EXAMPLE_APP0 'Empty Application'
CONT%(cn)d_EXAMPLE_APP1 'Hello world'
choices cont%(cn)d_examples_params
CONT%(cn)d_EXAMPLE_APP0
CONT%(cn)d_EXAMPLE_APP1
default CONT%(cn)d_EXAMPLE_APP0
menu cont%(cn)d_default_pager_params
CONT%(cn)d_PAGER_LMA@
CONT%(cn)d_PAGER_VMA@
@@ -178,20 +188,20 @@ menu cont%(cn)d_physmem_list
menu container%(cn)d_options
CONT%(cn)d_OPT_NAME$
cont%(cn)d_examples_params
cont%(cn)d_linux_pager_params
cont%(cn)d_bare_pager_params
cont%(cn)d_default_pager_params
cont%(cn)d_posix_pager_params
cont%(cn)d_physmem_list
cont%(cn)d_virtmem_list
choices container%(cn)d_type
CONT%(cn)d_TYPE_LINUX
CONT%(cn)d_TYPE_BARE
CONT%(cn)d_TYPE_EXAMPLES
CONT%(cn)d_TYPE_POSIX
CONT%(cn)d_TYPE_TEST
default CONT%(cn)d_TYPE_BARE
default CONT%(cn)d_TYPE_EXAMPLES
menu cont%(cn)d_menu
container%(cn)d_type
container%(cn)d_options

View File

@@ -10,6 +10,7 @@ class Container:
self.name = None
self.type = None
self.id = id
self.example_id = 0
self.pager_lma = 0
self.pager_vma = 0
self.pager_size = 0
@@ -167,6 +168,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":
param1 = param.split("_", 1)
self.containers[id].example_id = param1[1][-1:]
else:
param1, param2 = param.split("_", 1)
if param1 == "TYPE":
@@ -174,11 +178,10 @@ class configuration:
self.containers[id].type = "linux"
elif param2 == "POSIX":
self.containers[id].type = "posix"
elif param2 == "BARE":
self.containers[id].type = "bare"
elif param2 == "EXAMPLES":
self.containers[id].type = "examples"
elif param2 == "TEST":
self.containers[id].type = "test"
# 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

@@ -4,7 +4,7 @@ import os, sys, shelve, shutil
from os.path import join
from config.projpaths import *
from config.configuration import *
from scripts.bare.bare_generator import *
from scripts.examples.examples_generator import *
from scripts.kernel.generate_kernel_cinfo import *
from scripts.cml.generate_container_cml import *
from optparse import OptionParser
@@ -185,9 +185,9 @@ def configure_system(options, args):
configuration_save(config)
# Generate bare container files if new ones defined
bare_cont_gen = BareContGenerator()
bare_cont_gen.bare_container_generate(config)
# Generate example container files if new ones defined
examples_cont_gen = ExamplesContGenerator()
examples_cont_gen.examples_container_generate(config)
# Print out the configuration if asked
if options.print_config:

View File

@@ -13,45 +13,39 @@ sys.path.append(PROJRELROOT)
from config.projpaths import *
from config.configuration import *
from configure import *
config = configuration_retrieve()
arch = config.arch
gcc_cpu_flag = config.gcc_cpu_flag
# Wrapper library for system calls
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)
# Some user-space libraries
# 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)]
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR)
LIBMEM_INCLUDE = LIBMEM_DIR
env = Environment(CC = config.user_toolchain + 'gcc',
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', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \
'-Werror', ('-mcpu=' + gcc_cpu_flag)], \
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', 'libmm', 'libmc', 'libmalloc', \
'gcc', 'c-userspace'], # libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBC_INCLUDE, LIBMEM_INCLUDE],
LIBPATH = [LIBL4_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH],
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
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')
src = Glob('*.[cS]')
src += Glob('src/*.[cS]')

View File

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

View File

@@ -0,0 +1,12 @@
/*
* Main function for this container
*/
#include <l4lib/arch/syslib.h>
#include <l4lib/arch/syscalls.h>
#include <l4/api/space.h>
int main(void)
{
return 0;
}

View File

@@ -0,0 +1,55 @@
# -*- 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 *
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', '-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', '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')
src = Glob('*.[cS]')
src += Glob('src/*.[cS]')
objs = env.Object(src)
prog = env.Program('main.elf', objs)
Depends(prog, 'include/linker.lds')

View File

@@ -0,0 +1,21 @@
/*
* Container entry point for pager
*
* Copyright (C) 2007-2009 B Labs Ltd.
*/
#include <l4lib/init.h>
#include <l4lib/utcb.h>
extern void main(void);
void __container_init(void)
{
/* Generic L4 initialisation */
__l4_init();
/* Entry to main */
main();
}

View File

@@ -55,7 +55,7 @@ def source_to_builddir(srcdir, id):
return join(BUILDDIR, cont_builddir)
# We simply use SCons to figure all this out from container.id
# This is very similar to default container builder:
# This is very similar to examples container builder:
# In fact this notion may become a standard convention for
# calling specific bare containers
def build_posix_container(config, projpaths, container):
@@ -110,7 +110,7 @@ def build_default_container(config, projpaths, container):
os.path.walk(projdir, glob_by_walk, ['*.elf', images])
# Calculate and store size of pager
pager_binary = "conts/bare" + str(container.id) + "/main.elf"
pager_binary = "conts/example" + str(container.id) + "/main.elf"
config.containers[container.id].pager_size = \
conv_hex(elf_binary_size(join(PROJROOT, pager_binary)))
@@ -124,7 +124,7 @@ def build_all_containers():
if container.type == 'linux':
pass
cont_images.append(build_linux_container(config, projpaths, container))
elif container.type == 'bare':
elif container.type == 'examples':
cont_images.append(build_default_container(config, projpaths, container))
elif container.type == 'posix':
cont_images.append(build_posix_container(config, projpaths, container))

View File

View File

@@ -19,11 +19,11 @@ from config.projpaths import *
from config.configuration import *
from config.lib import *
class BareContGenerator:
class ExamplesContGenerator:
def __init__(self):
self.CONT_SRC_DIR = '' # Set when container is selected
self.BARE_SRC_BASEDIR = join(PROJROOT, 'conts')
self.EXAMPLE_PROJ_SRC_DIR = join(PROJROOT, 'conts/bare_src')
self.EXAMPLES_SRC_BASEDIR = join(PROJROOT, 'conts')
self.EXAMPLES_PROJ_SRC_DIR = join(PROJROOT, 'conts/examples')
self.main_builder_name = 'build.py'
self.main_configurator_name = 'configure.py'
@@ -47,11 +47,12 @@ class BareContGenerator:
self.build_desc_out = None
self.src_main_out = None
def create_bare_srctree(self, config, cont):
def create_examples_srctree(self, config, cont):
# First, create the base project directory and sources
shutil.copytree(self.EXAMPLE_PROJ_SRC_DIR, self.CONT_SRC_DIR)
str = 'example' + cont.example_id
shutil.copytree(join(self.EXAMPLES_PROJ_SRC_DIR, str), self.CONT_SRC_DIR)
def copy_bare_build_desc(self, config, cont):
def copy_examples_build_desc(self, config, cont):
id_header = '[Container ID]\n'
type_header = '\n[Container Type]\n'
name_header = '\n[Container Name]\n'
@@ -78,7 +79,7 @@ class BareContGenerator:
fout.write(pager_physmem_header % ireg)
fout.write('\t' + cont.physmem["START"][ireg] + ' - ' + cont.physmem["END"][ireg] + '\n')
def copy_bare_build_readme(self, config, cont):
def copy_examples_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:
@@ -90,30 +91,30 @@ class BareContGenerator:
self.main_configurator_name, \
self.main_configurator_name))
def copy_bare_container_h(self, config, cont):
def copy_examples_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_bare_sources(self, config, cont):
self.create_bare_srctree(config, cont)
self.copy_bare_build_readme(config, cont)
self.copy_bare_build_desc(config, cont)
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)
self.generate_linker_script(config, cont)
self.copy_bare_container_h(config, cont)
self.copy_examples_container_h(config, cont)
def update_configuration(self, config, cont):
self.copy_bare_build_desc(config, cont)
self.copy_examples_build_desc(config, cont)
self.generate_linker_script(config, cont)
self.copy_bare_container_h(config, cont)
self.copy_examples_container_h(config, cont)
def check_create_bare_sources(self, config):
def check_create_examples_sources(self, config):
for cont in config.containers:
if cont.type == "bare":
if cont.type == "examples":
# Determine container directory name.
self.CONT_SRC_DIR = join(self.BARE_SRC_BASEDIR, cont.dirname.lower())
self.CONT_SRC_DIR = join(self.EXAMPLES_SRC_BASEDIR, cont.dirname.lower())
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'), \
@@ -121,8 +122,8 @@ class BareContGenerator:
self.container_h_out = join(join(self.CONT_SRC_DIR, 'include'), \
self.container_h_name)
if not os.path.exists(join(self.BARE_SRC_BASEDIR, cont.dirname)):
self.create_bare_sources(config, cont)
if not os.path.exists(join(self.EXAMPLES_SRC_BASEDIR, cont.dirname)):
self.create_examples_sources(config, cont)
else:
# Don't create new sources but update configuration
self.update_configuration(config, cont)
@@ -134,12 +135,12 @@ class BareContGenerator:
fout.write(str % (conv_hex(cont.pager_vma), \
conv_hex(cont.pager_lma)))
def bare_container_generate(self, config):
self.check_create_bare_sources(config)
def examples_container_generate(self, config):
self.check_create_examples_sources(config)
if __name__ == "__main__":
config = configuration_retrieve()
config.config_print()
bare_cont = BareContGenerator()
bare_cont.bare_container_generate(config)
examples_cont = ExamplesContGenerator()
examples_cont.examples_container_generate(config)

View File