From 8a7b9dbcdf770e030598e4bfbc88093a7d3adc36 Mon Sep 17 00:00:00 2001 From: Amit Mahajan Date: Fri, 20 Nov 2009 00:06:03 +0530 Subject: [PATCH] Integrated Test Container inside Baremetal container. --- config/cml/container_ruleset.template | 8 +- config/cml/examples/test/config.cml | 113 ------------------ config/configuration.py | 2 - config/projpaths.py | 2 - conts/baremetal/baremetal3/SConstruct | 59 +++++++++ .../baremetal3}/container.c | 2 +- .../baremetal3}/include/capability.h | 0 .../baremetal3}/include/tests.h | 0 .../baremetal3}/include/thread.h | 0 conts/{test => baremetal/baremetal3}/main.c | 0 conts/{test => baremetal/baremetal3}/src/arch | 0 .../baremetal3}/src/arch-arm/new_thread.S | 0 .../baremetal3}/src/capability.c | 0 .../baremetal3}/src/captest.c | 0 .../baremetal3}/src/example.c | 0 .../baremetal3}/src/thread.c | 0 conts/test/SConscript | 44 ------- conts/test/SConstruct | 56 --------- conts/test/include/container.h.in | 13 -- conts/test/include/linker.lds.in | 29 ----- scripts/conts/containers.py | 23 ---- 21 files changed, 63 insertions(+), 288 deletions(-) delete mode 100644 config/cml/examples/test/config.cml create mode 100644 conts/baremetal/baremetal3/SConstruct rename conts/{test => baremetal/baremetal3}/container.c (91%) rename conts/{test => baremetal/baremetal3}/include/capability.h (100%) rename conts/{test => baremetal/baremetal3}/include/tests.h (100%) rename conts/{test => baremetal/baremetal3}/include/thread.h (100%) rename conts/{test => baremetal/baremetal3}/main.c (100%) rename conts/{test => baremetal/baremetal3}/src/arch (100%) rename conts/{test => baremetal/baremetal3}/src/arch-arm/new_thread.S (100%) rename conts/{test => baremetal/baremetal3}/src/capability.c (100%) rename conts/{test => baremetal/baremetal3}/src/captest.c (100%) rename conts/{test => baremetal/baremetal3}/src/example.c (100%) rename conts/{test => baremetal/baremetal3}/src/thread.c (100%) delete mode 100644 conts/test/SConscript delete mode 100644 conts/test/SConstruct delete mode 100644 conts/test/include/container.h.in delete mode 100644 conts/test/include/linker.lds.in diff --git a/config/cml/container_ruleset.template b/config/cml/container_ruleset.template index 0f49a30..6ade069 100644 --- a/config/cml/container_ruleset.template +++ b/config/cml/container_ruleset.template @@ -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 diff --git a/config/cml/examples/test/config.cml b/config/cml/examples/test/config.cml deleted file mode 100644 index 83a7397..0000000 --- a/config/cml/examples/test/config.cml +++ /dev/null @@ -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! diff --git a/config/configuration.py b/config/configuration.py index 1e4b37e..f8c2fdc 100644 --- a/config/configuration.py +++ b/config/configuration.py @@ -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) diff --git a/config/projpaths.py b/config/projpaths.py index d2af30d..60cdd49 100644 --- a/config/projpaths.py +++ b/config/projpaths.py @@ -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, \ diff --git a/conts/baremetal/baremetal3/SConstruct b/conts/baremetal/baremetal3/SConstruct new file mode 100644 index 0000000..5e5a317 --- /dev/null +++ b/conts/baremetal/baremetal3/SConstruct @@ -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') diff --git a/conts/test/container.c b/conts/baremetal/baremetal3/container.c similarity index 91% rename from conts/test/container.c rename to conts/baremetal/baremetal3/container.c index 7bcbf9e..f570c3d 100644 --- a/conts/test/container.c +++ b/conts/baremetal/baremetal3/container.c @@ -8,7 +8,7 @@ #include -void main(void); +extern void main(void); void __container_init(void) { diff --git a/conts/test/include/capability.h b/conts/baremetal/baremetal3/include/capability.h similarity index 100% rename from conts/test/include/capability.h rename to conts/baremetal/baremetal3/include/capability.h diff --git a/conts/test/include/tests.h b/conts/baremetal/baremetal3/include/tests.h similarity index 100% rename from conts/test/include/tests.h rename to conts/baremetal/baremetal3/include/tests.h diff --git a/conts/test/include/thread.h b/conts/baremetal/baremetal3/include/thread.h similarity index 100% rename from conts/test/include/thread.h rename to conts/baremetal/baremetal3/include/thread.h diff --git a/conts/test/main.c b/conts/baremetal/baremetal3/main.c similarity index 100% rename from conts/test/main.c rename to conts/baremetal/baremetal3/main.c diff --git a/conts/test/src/arch b/conts/baremetal/baremetal3/src/arch similarity index 100% rename from conts/test/src/arch rename to conts/baremetal/baremetal3/src/arch diff --git a/conts/test/src/arch-arm/new_thread.S b/conts/baremetal/baremetal3/src/arch-arm/new_thread.S similarity index 100% rename from conts/test/src/arch-arm/new_thread.S rename to conts/baremetal/baremetal3/src/arch-arm/new_thread.S diff --git a/conts/test/src/capability.c b/conts/baremetal/baremetal3/src/capability.c similarity index 100% rename from conts/test/src/capability.c rename to conts/baremetal/baremetal3/src/capability.c diff --git a/conts/test/src/captest.c b/conts/baremetal/baremetal3/src/captest.c similarity index 100% rename from conts/test/src/captest.c rename to conts/baremetal/baremetal3/src/captest.c diff --git a/conts/test/src/example.c b/conts/baremetal/baremetal3/src/example.c similarity index 100% rename from conts/test/src/example.c rename to conts/baremetal/baremetal3/src/example.c diff --git a/conts/test/src/thread.c b/conts/baremetal/baremetal3/src/thread.c similarity index 100% rename from conts/test/src/thread.c rename to conts/baremetal/baremetal3/src/thread.c diff --git a/conts/test/SConscript b/conts/test/SConscript deleted file mode 100644 index 64c707d..0000000 --- a/conts/test/SConscript +++ /dev/null @@ -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) - diff --git a/conts/test/SConstruct b/conts/test/SConstruct deleted file mode 100644 index af97623..0000000 --- a/conts/test/SConstruct +++ /dev/null @@ -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')) - diff --git a/conts/test/include/container.h.in b/conts/test/include/container.h.in deleted file mode 100644 index 5015fd6..0000000 --- a/conts/test/include/container.h.in +++ /dev/null @@ -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__ */ diff --git a/conts/test/include/linker.lds.in b/conts/test/include/linker.lds.in deleted file mode 100644 index d9740ab..0000000 --- a/conts/test/include/linker.lds.in +++ /dev/null @@ -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 = .; - } -} diff --git a/scripts/conts/containers.py b/scripts/conts/containers.py index dc54a65..ae79ca0 100755 --- a/scripts/conts/containers.py +++ b/scripts/conts/containers.py @@ -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)