From afaa1d03a85a8ad20579bc17971ae6639a46e200 Mon Sep 17 00:00:00 2001 From: Bora Sahin Date: Thu, 1 Oct 2009 15:43:46 +0300 Subject: [PATCH] A few changes to allow development on conts/test directory. Now, bare containers get their files from conts/bare_src instead of conts/test. test directory will be used for the next generation test programs. Also bare_src is tracked by git now with a minor mod to .gitignore. --- .gitignore | 2 +- conts/bare_src/SConstruct | 55 +++++++++++++++++++++++++++++++ conts/bare_src/container.c | 21 ++++++++++++ conts/bare_src/hello.c | 13 ++++++++ conts/bare_src/include/linker.lds | 34 +++++++++++++++++++ conts/bare_src/include/test.h | 0 conts/bare_src/main.c | 16 +++++++++ conts/bare_src/src/test.c | 0 scripts/bare/bare_generator.py | 2 +- 9 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 conts/bare_src/SConstruct create mode 100644 conts/bare_src/container.c create mode 100644 conts/bare_src/hello.c create mode 100644 conts/bare_src/include/linker.lds create mode 100644 conts/bare_src/include/test.h create mode 100644 conts/bare_src/main.c create mode 100644 conts/bare_src/src/test.c diff --git a/.gitignore b/.gitignore index f50577b..c8f3437 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ cscope*out loader/images.S loader/ksyms.S tags -conts/bare* +conts/bare[0-9] conts/linux src/generic/cinfo.c .gdbinit diff --git a/conts/bare_src/SConstruct b/conts/bare_src/SConstruct new file mode 100644 index 0000000..23e059c --- /dev/null +++ b/conts/bare_src/SConstruct @@ -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') diff --git a/conts/bare_src/container.c b/conts/bare_src/container.c new file mode 100644 index 0000000..7bcbf9e --- /dev/null +++ b/conts/bare_src/container.c @@ -0,0 +1,21 @@ +/* + * Container entry point for pager + * + * Copyright (C) 2007-2009 B Labs Ltd. + */ + +#include +#include + + +void main(void); + +void __container_init(void) +{ + /* Generic L4 initialisation */ + __l4_init(); + + /* Entry to main */ + main(); +} + diff --git a/conts/bare_src/hello.c b/conts/bare_src/hello.c new file mode 100644 index 0000000..054adc9 --- /dev/null +++ b/conts/bare_src/hello.c @@ -0,0 +1,13 @@ +/* + * Autogenerated hello world print function + */ + +#include +#include + +int print_hello_world(void) +{ + printf("%s: Hello world from %s!\n", __CONTAINER__, __CONTAINER_NAME__); + return 0; +} + diff --git a/conts/bare_src/include/linker.lds b/conts/bare_src/include/linker.lds new file mode 100644 index 0000000..abb38b5 --- /dev/null +++ b/conts/bare_src/include/linker.lds @@ -0,0 +1,34 @@ +/* + * Example working linker script for this container. + * + * Copyright (C) 2009 B Labs Ltd. + */ + +vma_start = 0x0; +lma_start = 0x1000000; +offset = vma_start - lma_start; + +ENTRY(_start) + +SECTIONS +{ + . = vma_start; + .text : AT (ADDR(.text) - offset) { + /* + * NOTE: + * crt0.S must be in .text.head. This is necessary because + * the kernel does not know any _start address, it assumes + * the start address of pager region as the start address. + */ + *(.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/conts/bare_src/include/test.h b/conts/bare_src/include/test.h new file mode 100644 index 0000000..e69de29 diff --git a/conts/bare_src/main.c b/conts/bare_src/main.c new file mode 100644 index 0000000..d2d8ed6 --- /dev/null +++ b/conts/bare_src/main.c @@ -0,0 +1,16 @@ +/* + * Main function for this container + */ +#include +#include +#include + +extern int print_hello_world(void); + +int main(void) +{ + print_hello_world(); + + return 0; +} + diff --git a/conts/bare_src/src/test.c b/conts/bare_src/src/test.c new file mode 100644 index 0000000..e69de29 diff --git a/scripts/bare/bare_generator.py b/scripts/bare/bare_generator.py index 5a848e8..e9ace5d 100755 --- a/scripts/bare/bare_generator.py +++ b/scripts/bare/bare_generator.py @@ -23,7 +23,7 @@ class BareContGenerator: 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/test') + self.EXAMPLE_PROJ_SRC_DIR = join(PROJROOT, 'conts/bare_src') self.main_builder_name = 'build.py' self.main_configurator_name = 'configure.py'