Integrated Test Container inside Baremetal container.

This commit is contained in:
Amit Mahajan
2009-11-20 00:06:03 +05:30
parent 352d75f66c
commit 8a7b9dbcdf
21 changed files with 63 additions and 288 deletions

View File

@@ -2,7 +2,6 @@ symbols
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_TEST 'Test Container'
CONT%(cn)d_OPT_NAME 'Container Name'
CONT%(cn)d_PHYSMEM_REGIONS 'Container %(cn)d Number of Physical Regions'
@@ -139,11 +138,10 @@ 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_BAREMETAL==y) ? "baremetal%(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" : "posix%(cn)d")
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_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
unless CONT%(cn)d_TYPE_BAREMETAL==y suppress cont%(cn)d_baremetal_params
@@ -162,12 +160,13 @@ 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_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
@@ -650,7 +649,6 @@ choices container%(cn)d_type
CONT%(cn)d_TYPE_BAREMETAL
CONT%(cn)d_TYPE_POSIX
CONT%(cn)d_TYPE_LINUX
CONT%(cn)d_TYPE_TEST
default CONT%(cn)d_TYPE_BAREMETAL
menu cont%(cn)d_menu

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

@@ -188,8 +188,6 @@ class configuration:
self.containers[id].type = "posix"
elif param2 == "BAREMETAL":
self.containers[id].type = "baremetal"
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

@@ -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

@@ -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

@@ -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

@@ -1,13 +0,0 @@
/*
* Autogenerated definitions for this container.
*/
#ifndef __CONTAINER_H__
#define __CONTAINER_H__
#define __CONTAINER_NAME__ "%s"
#define __CONTAINER_ID__ %d
#define __CONTAINER__ "cont%d"
#endif /* __CONTAINER_H__ */

View File

@@ -1,29 +0,0 @@
/*
* Example working linker script for this container.
*
* Copyright (C) 2009 B Labs Ltd.
*/
vma_start = %s;
lma_start = %s;
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 = .;
}
}

View File

@@ -77,27 +77,6 @@ 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.
@@ -128,8 +107,6 @@ def build_all_containers():
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)