mirror of
https://github.com/drasko/codezero.git
synced 2026-01-15 20:33:16 +01:00
Test container type is added.
Test container is planned to test codezero microkernel extensively. With these changes, everything is there to develop a full-featured test suite. It also exemplifies how a new container type can be added to the system. (cherry picked from commit f21fa53df421bfc8eeeaa096c89b98beed436c60)
This commit is contained in:
committed by
Bahadir Balban
parent
89d49ef495
commit
2a47e425c4
44
conts/test/SConscript
Normal file
44
conts/test/SConscript
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
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]')]
|
||||
|
||||
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)
|
||||
|
||||
56
conts/test/SConstruct
Normal file
56
conts/test/SConstruct
Normal file
@@ -0,0 +1,56 @@
|
||||
# -*- 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'))
|
||||
|
||||
21
conts/test/container.c
Normal file
21
conts/test/container.c
Normal 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>
|
||||
|
||||
|
||||
void main(void);
|
||||
|
||||
void __container_init(void)
|
||||
{
|
||||
/* Generic L4 initialisation */
|
||||
__l4_init();
|
||||
|
||||
/* Entry to main */
|
||||
main();
|
||||
}
|
||||
|
||||
13
conts/test/hello.c
Normal file
13
conts/test/hello.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Autogenerated hello world print function
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <container.h>
|
||||
|
||||
int print_hello_world(void)
|
||||
{
|
||||
printf("%s: Hello world from %s!\n", __CONTAINER__, __CONTAINER_NAME__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
13
conts/test/include/container.h.in
Normal file
13
conts/test/include/container.h.in
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* 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__ */
|
||||
26
conts/test/include/linker.lds.in
Normal file
26
conts/test/include/linker.lds.in
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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 = .;
|
||||
}
|
||||
16
conts/test/main.c
Normal file
16
conts/test/main.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Main function for this container
|
||||
*/
|
||||
#include <l4lib/arch/syslib.h>
|
||||
#include <l4lib/arch/syscalls.h>
|
||||
#include <l4/api/space.h>
|
||||
|
||||
extern int print_hello_world(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
print_hello_world();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user