From 6fa4884a5a1cf6207372f69ae01e5faa6d5a39c8 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Tue, 1 Jun 2010 15:08:13 +0300 Subject: [PATCH] Changes since April Clean up of build directories. Simplifications to capability model. --- SConstruct | 143 ++- SConstruct.loader | 64 - SConstruct.userlibs | 59 - build.py | 178 ++- config/caps.py | 273 ----- config/cml/arm.ruleset | 213 ---- config/cml/container_ruleset.template | 749 ------------ config/cml/examples/linux/config.cml | 271 ----- config/cml/examples/posix/single_posix.cml | 285 ----- config/cml/examples/posix/two_posix.cml | 479 -------- config/projpaths.py | 41 - conts/baremetal/empty/SConscript | 11 + conts/baremetal/empty/SConstruct | 81 +- conts/baremetal/hello_world/SConscript | 11 + conts/baremetal/hello_world/SConstruct | 84 +- conts/baremetal/ipc_demo/SConscript | 11 + conts/baremetal/ipc_demo/SConstruct | 57 + .../ipc_demo}/build.readme | 2 +- .../ipc_demo}/container.c | 9 +- .../ipc_demo}/include/container.h | 2 +- .../ipc_demo}/include/fault.h | 0 .../ipc_demo}/include/linker.h | 0 conts/baremetal/ipc_demo/include/linker.lds | 55 + .../ipc_demo}/include/memory.h | 0 conts/baremetal/ipc_demo/include/tests.h | 13 + conts/baremetal/ipc_demo/main.c | 29 + conts/baremetal/ipc_demo/src/ipc.c | 547 +++++++++ .../api => baremetal/ipc_demo/src}/memory.c | 0 conts/baremetal/ipc_demo/src/mm.c | 74 ++ conts/baremetal/kmi_service/SConscript | 12 + conts/baremetal/kmi_service/SConstruct | 87 +- conts/baremetal/kmi_service/container.c | 3 + .../baremetal/kmi_service/include/keyboard.h | 5 +- conts/baremetal/kmi_service/include/mouse.h | 3 +- conts/baremetal/kmi_service/main.c | 156 +-- conts/baremetal/mutex_demo/SConscript | 11 + conts/baremetal/mutex_demo/SConstruct | 57 + conts/baremetal/mutex_demo/container.c | 21 + conts/baremetal/mutex_demo/include/tests.h | 13 + conts/baremetal/mutex_demo/main.c | 18 + .../api => baremetal/mutex_demo/src}/mutex.c | 0 conts/baremetal/test_suite/SConscript | 23 + conts/baremetal/test_suite/SConstruct | 82 +- conts/baremetal/test_suite/TAGS | 257 ++++ .../test_suite}/TODO | 0 conts/baremetal/test_suite/container.c | 9 +- .../test_suite}/exit.ct | 0 .../test_suite}/include/api/api.h | 0 .../test_suite}/include/debug.h | 0 conts/baremetal/test_suite/include/fault.h | 44 + conts/baremetal/test_suite/include/linker.h | 16 + .../test_suite}/include/macros.h | 0 conts/baremetal/test_suite/include/memory.h | 12 + .../test_suite}/include/perf.h | 0 .../test_suite}/include/project_linker.lds | 0 conts/baremetal/test_suite/include/tests.h | 13 +- .../test_suite}/include/timer.h | 2 +- conts/baremetal/test_suite/main.c | 83 +- .../test_suite}/src/api/api.c | 0 .../test_suite}/src/api/cache.c | 0 .../test_suite}/src/api/cap.c | 0 .../test_suite}/src/api/exregs.c | 0 .../test_suite}/src/api/getid.c | 0 .../test_suite}/src/api/ipc.c | 0 .../test_suite}/src/api/irq.c | 0 .../test_suite}/src/api/map.c | 70 +- conts/baremetal/test_suite/src/api/memory.c | 198 +++ conts/baremetal/test_suite/src/api/mutex.c | 204 ++++ .../test_suite}/src/api/smp.c | 0 .../test_suite}/src/api/thread.c | 0 conts/baremetal/test_suite/src/arch | 1 - .../test_suite}/src/arch/arm/v5/mm.c | 9 +- .../test_suite}/src/arch/arm/v7/mm.c | 0 conts/baremetal/test_suite/src/capability.c | 6 +- conts/baremetal/test_suite/src/captest.c | 3 +- .../test_suite}/src/cli_serv/cli_serv.c | 0 .../test_suite}/src/mthread/mthread.c | 0 .../test_suite}/src/perf/cycles.c | 0 .../test_suite}/src/perf/exregs.c | 0 .../test_suite}/src/perf/getid.c | 8 +- .../test_suite}/src/perf/ipc.c | 0 .../test_suite}/src/perf/map.c | 0 .../test_suite}/src/perf/mutex.c | 1 + .../test_suite}/src/perf/perf.c | 1 + .../test_suite}/src/perf/simple.c | 0 .../test_suite}/src/perf/tctrl.c | 3 +- .../test_suite}/src/perf/timer.c | 1 - conts/baremetal/test_suite/src/perf/tswitch.c | 150 +++ .../test_suite}/tests_howto.txt | 0 conts/baremetal/threads_demo/SConscript | 11 + conts/baremetal/threads_demo/SConstruct | 80 +- conts/baremetal/threads_demo/thread.c | 108 ++ conts/baremetal/timer_service/SConscript | 12 + conts/baremetal/timer_service/SConstruct | 87 +- conts/baremetal/timer_service/container.c | 3 + conts/baremetal/timer_service/include/timer.h | 3 +- conts/baremetal/timer_service/main.c | 136 +-- conts/baremetal/uart_service/SConscript | 11 + conts/baremetal/uart_service/SConstruct | 82 +- conts/baremetal/uart_service/container.c | 8 +- conts/baremetal/uart_service/include/uart.h | 2 +- conts/baremetal/uart_service/main.c | 123 +- conts/libc/SConscript | 42 - conts/libc/SConstruct | 50 - conts/libdev/SConscript | 50 - conts/libdev/SConstruct | 59 - conts/libl4/SConstruct | 48 - conts/libmem/SConstruct | 75 -- conts/posix/SConstruct | 64 +- conts/posix/bootdesc/SConscript | 4 +- conts/posix/bootdesc/SConstruct | 6 +- conts/posix/libposix/SConstruct | 18 +- conts/posix/mm0/SConscript | 2 +- conts/posix/mm0/SConstruct | 42 +- conts/posix/mm0/fs/memfs/vnode.c | 2 +- conts/posix/mm0/fs/path.c | 2 +- conts/posix/mm0/include/linker.lds.in | 50 +- conts/posix/mm0/include/memfs/memfs.h | 2 +- conts/posix/mm0/include/vfs.h | 2 +- conts/posix/mm0/lib/idpool.c | 2 +- conts/posix/mm0/main.c | 2 + conts/posix/mm0/mm/capability.c | 40 +- conts/posix/mm0/mm/dev.c | 2 +- conts/posix/mm0/mm/execve.c | 2 +- conts/posix/mm0/mm/exit.c | 2 +- conts/posix/mm0/mm/fault.c | 4 +- conts/posix/mm0/mm/file.c | 5 +- conts/posix/mm0/mm/init.c | 4 +- conts/posix/mm0/mm/mmap.c | 53 +- conts/posix/mm0/mm/munmap.c | 2 +- conts/posix/mm0/mm/pagers.c | 4 +- conts/posix/mm0/mm/shm.c | 2 +- conts/posix/mm0/mm/task.c | 2 +- conts/posix/mm0/mm/user.c | 2 +- conts/posix/mm0/mm/utcb.c | 2 +- conts/posix/mm0/mm/vm_object.c | 2 +- conts/posix/mm0/tools/generate_bootdesc.py | 2 +- conts/posix/rootfs/SConscript | 4 +- conts/posix/test0/SConscript | 2 +- conts/posix/test0/SConstruct | 6 +- conts/posix/test0/include/linker.lds.in | 50 +- .../test0/include/test_exec_linker.lds.in | 27 +- conts/posix/test0/src/ipctest.c | 2 + conts/posix/test0/src/mutextest.c | 4 +- conts/test_suite0/SConstruct | 71 -- conts/test_suite0/include/capability.h | 6 - conts/test_suite0/include/linker.lds | 30 - conts/test_suite0/include/tests.h | 18 - conts/test_suite0/include/thread.h | 19 - conts/test_suite0/main.c | 47 - conts/test_suite0/src/capability.c | 106 -- conts/test_suite0/src/captest.c | 148 --- conts/test_suite0/src/example.c | 220 ---- conts/test_suite0/src/perf/tswitch.c | 0 conts/userlibs/SConscript | 39 + conts/userlibs/SConstruct | 39 + conts/userlibs/libc/SConscript | 37 + conts/userlibs/libc/SConstruct | 40 + .../libc/crt/sys-userspace/arch-arm/crt0.S | 0 conts/{ => userlibs}/libc/include/assert.h | 0 conts/{ => userlibs}/libc/include/limits.h | 0 conts/{ => userlibs}/libc/include/stdarg.h | 0 conts/{ => userlibs}/libc/include/stdbool.h | 0 conts/{ => userlibs}/libc/include/stddef.h | 0 conts/{ => userlibs}/libc/include/stdint.h | 0 conts/{ => userlibs}/libc/include/stdio.h | 0 conts/{ => userlibs}/libc/include/string.h | 0 .../sys-baremetal/arch-arm/arch/stdint.h | 0 .../sys-userspace/arch-arm/arch/stdint.h | 0 conts/{ => userlibs}/libc/src/arch-arm/eabi.c | 0 .../libc/src/arch-arm}/memcpy.S | 0 .../libc/src/arch-arm}/memset.S | 0 conts/{ => userlibs}/libc/src/format.c | 0 conts/{ => userlibs}/libc/src/format.h | 0 conts/{ => userlibs}/libc/src/fputc.c | 0 conts/{ => userlibs}/libc/src/memcmp.c | 0 conts/userlibs/libc/src/memcpy.c | 117 ++ conts/userlibs/libc/src/memset.c | 122 ++ conts/{ => userlibs}/libc/src/printf.c | 0 conts/{ => userlibs}/libc/src/sprintf.c | 0 conts/{ => userlibs}/libc/src/strcmp.c | 0 conts/{ => userlibs}/libc/src/strcpy.c | 0 conts/{ => userlibs}/libc/src/strlen.c | 0 conts/{ => userlibs}/libc/src/strncmp.c | 0 conts/{ => userlibs}/libc/src/strncpy.c | 0 .../src/sys-userspace/arch-arm/sys_fputc.c | 2 +- .../src/sys-userspace/arch-arm/sys_getc.c | 2 +- .../src/sys-userspace/arch-arm/sys_stdio.c | 0 conts/{ => userlibs}/libc/src/vfprintf.c | 0 conts/userlibs/libdev/SConscript | 40 + conts/userlibs/libdev/SConstruct | 56 + .../libdev/clcd/pl110/SConscript | 13 +- conts/{ => userlibs}/libdev/clcd/pl110/clcd.c | 0 conts/{ => userlibs}/libdev/clcd/pl110/clcd.h | 0 .../libdev/include/dev}/io.h | 0 .../libdev/include/dev}/kmi.h | 0 conts/userlibs/libdev/include/dev/platform.h | 17 + .../libdev/include/dev/platform/beagle/irq.h | 13 + .../include/dev/platform/beagle/platform.h | 13 + .../libdev/include/dev/platform/eb/irq.h | 22 + .../libdev/include/dev/platform/eb/platform.h | 14 + .../libdev/include/dev/platform/pb926/irq.h | 15 + .../include/dev/platform/pb926/platform.h | 15 + .../libdev/include/dev/platform/pba9/irq.h | 15 + .../include/dev/platform/pba9/platform.h | 14 + .../include/dev/platform/realview/platform.h | 17 + .../libdev/include/dev}/timer.h | 0 .../libdev/include/dev}/uart.h | 0 .../libdev/kmi/pl050/SConscript | 14 +- .../{ => userlibs}/libdev/kmi/pl050/keymap.h | 10 +- conts/{ => userlibs}/libdev/kmi/pl050/kmi.c | 2 +- conts/{ => userlibs}/libdev/kmi/pl050/kmi.h | 0 .../libdev/timer/omap/SConscript | 12 +- .../{ => userlibs}/libdev/timer/omap/timer.c | 2 +- .../{ => userlibs}/libdev/timer/omap/timer.h | 0 .../libdev/timer/sp804/SConscript | 14 +- .../{ => userlibs}/libdev/timer/sp804/timer.c | 0 .../{ => userlibs}/libdev/timer/sp804/timer.h | 2 +- .../libdev/uart/omap/SConscript | 12 +- conts/{ => userlibs}/libdev/uart/omap/uart.c | 4 +- conts/{ => userlibs}/libdev/uart/omap/uart.h | 0 .../libdev/uart/pl011/SConscript | 14 +- conts/{ => userlibs}/libdev/uart/pl011/uart.c | 4 +- conts/{ => userlibs}/libdev/uart/pl011/uart.h | 7 +- conts/{ => userlibs}/libl4/SConscript | 32 +- conts/userlibs/libl4/SConstruct | 31 + .../libl4/include/l4lib/arch/arm/asm.h | 0 .../libl4/include/l4lib/arch/arm/irq.h | 0 .../libl4/include/l4lib/arch/arm/syscalls.h | 0 .../libl4/include/l4lib/arch/arm/syslib.h | 0 .../libl4/include/l4lib/arch/arm/types.h | 0 .../libl4/include/l4lib/arch/arm/utcb.h | 0 .../libl4/include/l4lib/arch/arm/v5/perfmon.h | 0 .../libl4/include/l4lib/arch/arm/v5/utcb.h | 0 .../libl4/include/l4lib/arch/arm/v7/perfmon.h | 0 .../libl4/include/l4lib/arch/arm/v7/utcb.h | 0 .../libl4/include/l4lib/cache.h | 0 .../libl4/include/l4lib/exregs.h | 0 .../{ => userlibs}/libl4/include/l4lib/init.h | 0 .../libl4/include/l4lib/ipcdefs.h | 0 .../{ => userlibs}/libl4/include/l4lib/irq.h | 0 .../{ => userlibs}/libl4/include/l4lib/kip.h | 0 .../libl4/include/l4lib/lib/addr.h | 0 .../libl4/include/l4lib/lib/bit.h | 0 .../libl4/include/l4lib/lib/cap.h | 4 +- .../libl4/include/l4lib/lib/idpool.h | 0 .../libl4/include/l4lib/lib/thread.h | 0 .../libl4/include/l4lib/linux/api/cache.h | 17 + .../include/l4lib/linux/api/capability.h | 96 ++ .../libl4/include/l4lib/linux/api/errno.h | 148 +++ .../libl4/include/l4lib/linux/api/exregs.h | 50 + .../libl4/include/l4lib/linux/api/ipc.h | 27 + .../libl4/include/l4lib/linux/api/irq.h | 10 + .../libl4/include/l4lib/linux/api/kip.h | 82 ++ .../libl4/include/l4lib/linux/api/mutex.h | 60 + .../libl4/include/l4lib/linux/api/space.h | 5 + .../libl4/include/l4lib/linux/api/thread.h | 25 + .../include/l4lib/linux/arch/arm/exception.h | 73 ++ .../libl4/include/l4lib/linux/arch/arm/io.h | 25 + .../libl4/include/l4lib/linux/arch/arm/irq.h | 29 + .../include/l4lib/linux/arch/arm/mutex.h | 16 + .../include/l4lib/linux/arch/arm/v5/mm.h | 137 +++ .../l4lib/linux/arch/arm/v7/exception.h | 42 + .../include/l4lib/linux/arch/arm/v7/mm.h | 315 +++++ .../include/l4lib/linux/generic/cap-types.h | 148 +++ .../include/l4lib/linux/generic/preempt.h | 19 + .../libl4/include/l4lib/linux/generic/space.h | 30 + .../libl4/include/l4lib/linux/generic/tcb.h | 43 + .../include/l4lib/linux/glue/arm/cache.h | 26 + .../include/l4lib/linux/glue/arm/context.h | 53 + .../include/l4lib/linux/glue/arm/memlayout.h | 61 + .../include/l4lib/linux/glue/arm/memory.h | 85 ++ .../include/l4lib/linux/glue/arm/message.h | 95 ++ .../include/l4lib/linux/glue/arm/syscall.h | 78 ++ .../libl4/include/l4lib/linux/lib/list.h | 131 ++ .../libl4/include/l4lib/linux/lib/math.h | 44 + .../libl4/include/l4lib/linux/lib/mutex.h | 45 + .../libl4/include/l4lib/linux/lib/spinlock.h | 90 ++ .../libl4/include/l4lib/linux/lib/wait.h | 86 ++ .../libl4/include/l4lib/macros.h | 2 + .../libl4/include/l4lib/mutex.h | 0 .../libl4/include/l4lib/os/posix/kstat.h | 0 .../libl4/include/l4lib/os/posix/readdir.h | 0 .../libl4/include/l4lib/perfmon.h | 0 .../libl4/include/l4lib/types.h | 0 .../{ => userlibs}/libl4/include/l4lib/utcb.h | 0 .../libl4/src/arch/arm/exregs.c | 0 .../libl4/src/arch/arm/new_thread.S | 0 .../libl4/src/arch/arm/syscalls.S | 0 .../libl4/src/arch/arm/v5/atomic.S | 0 .../libl4/src/arch/arm/v5/mutex.S | 0 .../libl4/src/arch/arm/v6/mutex.c | 0 conts/userlibs/libl4/src/arch/arm/v7/atomic.S | 29 + .../libl4/src/arch/arm/v7/mutex.S | 0 .../libl4/src/arch/arm/v7/perfmon.c | 0 conts/{ => userlibs}/libl4/src/init.c | 0 conts/{ => userlibs}/libl4/src/irq.c | 0 conts/{ => userlibs}/libl4/src/lib/addr.c | 0 conts/{ => userlibs}/libl4/src/lib/bit.c | 0 conts/{ => userlibs}/libl4/src/lib/cap/cap.c | 35 +- conts/{ => userlibs}/libl4/src/lib/cap/read.c | 0 conts/{ => userlibs}/libl4/src/lib/idpool.c | 2 +- .../libl4/src/lib/thread/init.c | 2 +- .../libl4/src/lib/thread/thread.c | 2 +- conts/{ => userlibs}/libl4/src/mutex.c | 0 conts/{ => userlibs}/libmem/SConscript | 17 +- conts/userlibs/libmem/SConstruct | 68 ++ .../libmem/include/mem}/alloc_page.h | 2 +- .../libmem/include/mem}/clz.h | 0 .../libmem/include/mem}/debug.h | 4 +- .../libmem/include/mem}/libl4.h | 0 .../libmem/include/mem}/malloc.h | 0 .../libmem/include/mem}/memcache.h | 0 .../libmem/include/mem}/test_alloc_generic.h | 0 .../libmem/include/mem}/test_allocpage.h | 2 +- .../libmem/include/mem}/test_kmalloc.h | 2 +- .../libmem/include/mem}/test_memcache.h | 2 +- .../libmem/include/mem}/tests.h | 0 conts/{ => userlibs}/libmem/malloc/malloc.c | 0 .../{ => userlibs}/libmem/memcache/memcache.c | 2 +- conts/{ => userlibs}/libmem/mm/alloc_page.c | 2 +- conts/{ => userlibs}/libmem/run_tests.py | 0 conts/{ => userlibs}/libmem/tests/clz.c | 0 conts/{ => userlibs}/libmem/tests/debug.c | 0 conts/{ => userlibs}/libmem/tests/libl4.c | 0 conts/{ => userlibs}/libmem/tests/linker.c | 0 conts/{ => userlibs}/libmem/tests/main.c | 6 +- conts/{ => userlibs}/libmem/tests/memory.c | 0 .../libmem/tests/test_alloc_generic.c | 0 .../libmem/tests/test_allocpage.c | 0 .../libmem/tests/test_kmalloc.c | 0 .../libmem/tests/test_memcache.c | 2 +- docs/architecture.txt | 14 - include/l4/api/capability.h | 24 - include/l4/arch/arm/linker.lds.in | 1 + include/l4/generic/cap-types.h | 25 - include/l4/generic/capability.h | 12 +- include/l4/generic/container.h | 38 +- include/l4/generic/idle.h | 8 + include/l4/generic/platform.h | 21 +- include/l4/generic/resource.h | 39 +- include/l4/generic/scheduler.h | 6 +- include/l4/generic/space.h | 7 +- include/l4/generic/tcb.h | 15 +- include/l4/glue/arm/init.h | 5 +- include/l4/glue/arm/mapping.h | 28 +- include/l4/glue/arm/smp.h | 2 +- include/l4/lib/spinlock.h | 8 +- include/l4/macros.h | 7 +- include/l4/platform/eb/irq.h | 16 +- include/l4/platform/eb/offsets.h | 1 + include/l4/platform/pb926/irq.h | 4 + include/l4/platform/pb926/offsets.h | 2 +- include/l4/platform/pba9/irq.h | 5 +- include/l4/platform/pba9/offsets.h | 3 + include/l4/platform/pba9/platform.h | 9 + include/l4/platform/realview/offsets.h | 3 + loader/SConscript | 74 +- loader/SConstruct | 135 +++ loader/libs/c/SConscript | 11 +- loader/libs/c/SConstruct | 2 +- .../c/src/sys-baremetal/arch-arm/sys_fputc.c | 2 +- loader/libs/elf/SConstruct | 2 +- loader/libs/elf/src/elf.c | 6 +- loader/linker.lds.in | 2 + loader/main.c | 9 +- scripts/baremetal/baremetal_add_container.py | 2 +- scripts/baremetal/baremetal_generator.py | 44 +- scripts/baremetal/files/linker.lds.in | 35 +- scripts/cml/generate_container_cml.py | 46 +- {config => scripts/config}/__init__.py | 0 scripts/config/caps.py | 210 ++++ scripts/config/cml/arm.ruleset | 290 +++++ scripts/config/cml/container_ruleset.template | 1079 +++++++++++++++++ .../cml/examples/beagle/hello-world.cml | 0 .../cml/examples/helloworld/config.cml | 0 .../config}/cml/examples/kmi/kmi-pb926.cml | 0 .../cml/examples/linux/beagle/config.cml | 0 .../cml/examples/linux/pb926/config.cml | 0 .../cml/examples/linux/vexpress/config.cml | 230 ++++ .../cml/examples/posix/single_posix.cml | 243 ++++ .../config/cml/examples/posix/two_posix.cml | 397 ++++++ .../config}/cml/examples/vxa9/config.cml | 0 {config => scripts/config}/config_check.py | 0 .../config/config_invoke.py | 134 +- {config => scripts/config}/configuration.py | 109 +- {config => scripts/config}/lib.py | 0 scripts/config/projpaths.py | 75 ++ scripts/conts/containers.py | 119 +- scripts/conts/pack.py | 32 +- scripts/conts/packall.py | 19 +- scripts/kernel/check_kernel_limit.py | 40 + scripts/kernel/generate_kernel_cinfo.py | 100 +- scripts/linux/build_linux.py | 259 ++-- scripts/loader/generate_loader_asm.py | 12 +- scripts/qemu/qemu_cmdline.py | 43 +- src/api/SConscript | 6 +- src/api/cap.c | 655 ---------- src/api/exregs.c | 8 +- src/api/map.c | 10 +- src/api/mutex.c | 7 +- src/api/thread.c | 78 +- src/arch/arm/SConscript | 20 +- src/arch/arm/exception-common.c | 6 +- src/arch/arm/mapping-common.c | 118 +- src/arch/arm/v5/mapping.c | 36 +- src/arch/arm/v6/cpu_startup.c | 2 +- src/arch/arm/v6/mutex.c | 4 +- src/arch/arm/vectors.S | 2 +- src/drivers/SConscript | 45 +- src/drivers/irq/gic/SConscript | 30 +- src/drivers/irq/omap3/SConscript | 19 +- src/drivers/irq/pl190/SConscript | 20 +- src/drivers/timer/omap/SConscript | 19 +- src/drivers/timer/sp804/SConscript | 20 +- src/drivers/uart/omap/SConscript | 19 +- src/drivers/uart/pl011/SConscript | 20 +- src/generic/SConscript | 20 +- src/generic/bootmem.c | 9 +- src/generic/capability.c | 324 +---- src/generic/container.c | 142 +-- src/generic/idle.c | 72 ++ src/generic/resource.c | 740 ++++------- src/generic/scheduler.c | 106 +- src/generic/space.c | 24 +- src/generic/tcb.c | 138 ++- src/generic/time.c | 2 +- src/glue/arm/SConscript | 19 +- src/glue/arm/init.c | 61 +- src/glue/arm/smp.c | 15 +- src/lib/SConscript | 6 +- src/lib/string.c | 2 +- src/platform/beagle/SConscript | 1 - src/platform/eb/SConscript | 15 +- src/platform/eb/platform.c | 1 + src/platform/pb926/SConscript | 1 - src/platform/pb926/platform.c | 51 +- src/platform/pba9/SConscript | 14 +- src/platform/pba9/platform.c | 59 +- src/platform/realview/SConscript | 14 +- src/platform/realview/irq.c | 2 +- src/platform/realview/platform.c | 2 +- src/platform/realview/smp.c | 3 - tools/cml2-tools/cmlconfigure.py | 10 +- tools/pyelf/elf_section_info.py | 42 +- tools/pyelf/elfsize.py | 4 + tools/tagsgen/tagsgen_all | 1 + tools/tagsgen/tagsgen_kernel.py | 33 +- tools/tagsgen/tagsgen_linux.py | 79 ++ tools/tagsgen/tagsgen_loader | 13 +- 450 files changed, 10449 insertions(+), 7383 deletions(-) delete mode 100644 SConstruct.loader delete mode 100644 SConstruct.userlibs delete mode 100644 config/caps.py delete mode 100644 config/cml/arm.ruleset delete mode 100644 config/cml/container_ruleset.template delete mode 100644 config/cml/examples/linux/config.cml delete mode 100644 config/cml/examples/posix/single_posix.cml delete mode 100644 config/cml/examples/posix/two_posix.cml delete mode 100644 config/projpaths.py create mode 100644 conts/baremetal/empty/SConscript create mode 100644 conts/baremetal/hello_world/SConscript create mode 100644 conts/baremetal/ipc_demo/SConscript create mode 100644 conts/baremetal/ipc_demo/SConstruct rename conts/{test_suite0 => baremetal/ipc_demo}/build.readme (98%) rename conts/{test_suite0 => baremetal/ipc_demo}/container.c (59%) rename conts/{test_suite0 => baremetal/ipc_demo}/include/container.h (82%) rename conts/{test_suite0 => baremetal/ipc_demo}/include/fault.h (100%) rename conts/{test_suite0 => baremetal/ipc_demo}/include/linker.h (100%) create mode 100644 conts/baremetal/ipc_demo/include/linker.lds rename conts/{test_suite0 => baremetal/ipc_demo}/include/memory.h (100%) create mode 100644 conts/baremetal/ipc_demo/include/tests.h create mode 100644 conts/baremetal/ipc_demo/main.c create mode 100644 conts/baremetal/ipc_demo/src/ipc.c rename conts/{test_suite0/src/api => baremetal/ipc_demo/src}/memory.c (100%) create mode 100644 conts/baremetal/ipc_demo/src/mm.c create mode 100644 conts/baremetal/kmi_service/SConscript create mode 100644 conts/baremetal/mutex_demo/SConscript create mode 100644 conts/baremetal/mutex_demo/SConstruct create mode 100644 conts/baremetal/mutex_demo/container.c create mode 100644 conts/baremetal/mutex_demo/include/tests.h create mode 100644 conts/baremetal/mutex_demo/main.c rename conts/{test_suite0/src/api => baremetal/mutex_demo/src}/mutex.c (100%) create mode 100644 conts/baremetal/test_suite/SConscript create mode 100644 conts/baremetal/test_suite/TAGS rename conts/{test_suite0 => baremetal/test_suite}/TODO (100%) rename conts/{test_suite0 => baremetal/test_suite}/exit.ct (100%) rename conts/{test_suite0 => baremetal/test_suite}/include/api/api.h (100%) rename conts/{test_suite0 => baremetal/test_suite}/include/debug.h (100%) create mode 100644 conts/baremetal/test_suite/include/fault.h create mode 100644 conts/baremetal/test_suite/include/linker.h rename conts/{test_suite0 => baremetal/test_suite}/include/macros.h (100%) create mode 100644 conts/baremetal/test_suite/include/memory.h rename conts/{test_suite0 => baremetal/test_suite}/include/perf.h (100%) rename conts/{test_suite0 => baremetal/test_suite}/include/project_linker.lds (100%) rename conts/{test_suite0 => baremetal/test_suite}/include/timer.h (86%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/api.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/cache.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/cap.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/exregs.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/getid.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/ipc.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/irq.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/map.c (72%) create mode 100644 conts/baremetal/test_suite/src/api/memory.c create mode 100644 conts/baremetal/test_suite/src/api/mutex.c rename conts/{test_suite0 => baremetal/test_suite}/src/api/smp.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/api/thread.c (100%) delete mode 120000 conts/baremetal/test_suite/src/arch rename conts/{test_suite0 => baremetal/test_suite}/src/arch/arm/v5/mm.c (91%) rename conts/{test_suite0 => baremetal/test_suite}/src/arch/arm/v7/mm.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/cli_serv/cli_serv.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/mthread/mthread.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/cycles.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/exregs.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/getid.c (89%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/ipc.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/map.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/mutex.c (99%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/perf.c (95%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/simple.c (100%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/tctrl.c (94%) rename conts/{test_suite0 => baremetal/test_suite}/src/perf/timer.c (93%) create mode 100644 conts/baremetal/test_suite/src/perf/tswitch.c rename conts/{test_suite0 => baremetal/test_suite}/tests_howto.txt (100%) create mode 100644 conts/baremetal/threads_demo/SConscript create mode 100644 conts/baremetal/threads_demo/thread.c create mode 100644 conts/baremetal/timer_service/SConscript create mode 100644 conts/baremetal/uart_service/SConscript delete mode 100644 conts/libc/SConscript delete mode 100644 conts/libc/SConstruct delete mode 100644 conts/libdev/SConscript delete mode 100644 conts/libdev/SConstruct delete mode 100644 conts/libl4/SConstruct delete mode 100644 conts/libmem/SConstruct delete mode 100644 conts/test_suite0/SConstruct delete mode 100644 conts/test_suite0/include/capability.h delete mode 100644 conts/test_suite0/include/linker.lds delete mode 100644 conts/test_suite0/include/tests.h delete mode 100644 conts/test_suite0/include/thread.h delete mode 100644 conts/test_suite0/main.c delete mode 100644 conts/test_suite0/src/capability.c delete mode 100644 conts/test_suite0/src/captest.c delete mode 100644 conts/test_suite0/src/example.c delete mode 100644 conts/test_suite0/src/perf/tswitch.c create mode 100644 conts/userlibs/SConscript create mode 100644 conts/userlibs/SConstruct create mode 100644 conts/userlibs/libc/SConscript create mode 100644 conts/userlibs/libc/SConstruct rename conts/{ => userlibs}/libc/crt/sys-userspace/arch-arm/crt0.S (100%) rename conts/{ => userlibs}/libc/include/assert.h (100%) rename conts/{ => userlibs}/libc/include/limits.h (100%) rename conts/{ => userlibs}/libc/include/stdarg.h (100%) rename conts/{ => userlibs}/libc/include/stdbool.h (100%) rename conts/{ => userlibs}/libc/include/stddef.h (100%) rename conts/{ => userlibs}/libc/include/stdint.h (100%) rename conts/{ => userlibs}/libc/include/stdio.h (100%) rename conts/{ => userlibs}/libc/include/string.h (100%) rename conts/{ => userlibs}/libc/include/sys-baremetal/arch-arm/arch/stdint.h (100%) rename conts/{ => userlibs}/libc/include/sys-userspace/arch-arm/arch/stdint.h (100%) rename conts/{ => userlibs}/libc/src/arch-arm/eabi.c (100%) rename conts/{libc/src => userlibs/libc/src/arch-arm}/memcpy.S (100%) rename conts/{libc/src => userlibs/libc/src/arch-arm}/memset.S (100%) rename conts/{ => userlibs}/libc/src/format.c (100%) rename conts/{ => userlibs}/libc/src/format.h (100%) rename conts/{ => userlibs}/libc/src/fputc.c (100%) rename conts/{ => userlibs}/libc/src/memcmp.c (100%) create mode 100644 conts/userlibs/libc/src/memcpy.c create mode 100644 conts/userlibs/libc/src/memset.c rename conts/{ => userlibs}/libc/src/printf.c (100%) rename conts/{ => userlibs}/libc/src/sprintf.c (100%) rename conts/{ => userlibs}/libc/src/strcmp.c (100%) rename conts/{ => userlibs}/libc/src/strcpy.c (100%) rename conts/{ => userlibs}/libc/src/strlen.c (100%) rename conts/{ => userlibs}/libc/src/strncmp.c (100%) rename conts/{ => userlibs}/libc/src/strncpy.c (100%) rename conts/{ => userlibs}/libc/src/sys-userspace/arch-arm/sys_fputc.c (89%) rename conts/{ => userlibs}/libc/src/sys-userspace/arch-arm/sys_getc.c (95%) rename conts/{ => userlibs}/libc/src/sys-userspace/arch-arm/sys_stdio.c (100%) rename conts/{ => userlibs}/libc/src/vfprintf.c (100%) create mode 100644 conts/userlibs/libdev/SConscript create mode 100644 conts/userlibs/libdev/SConstruct rename conts/{ => userlibs}/libdev/clcd/pl110/SConscript (51%) rename conts/{ => userlibs}/libdev/clcd/pl110/clcd.c (100%) rename conts/{ => userlibs}/libdev/clcd/pl110/clcd.h (100%) rename conts/{libdev/include/libdev => userlibs/libdev/include/dev}/io.h (100%) rename conts/{libdev/include/libdev => userlibs/libdev/include/dev}/kmi.h (100%) create mode 100644 conts/userlibs/libdev/include/dev/platform.h create mode 100644 conts/userlibs/libdev/include/dev/platform/beagle/irq.h create mode 100644 conts/userlibs/libdev/include/dev/platform/beagle/platform.h create mode 100644 conts/userlibs/libdev/include/dev/platform/eb/irq.h create mode 100644 conts/userlibs/libdev/include/dev/platform/eb/platform.h create mode 100644 conts/userlibs/libdev/include/dev/platform/pb926/irq.h create mode 100644 conts/userlibs/libdev/include/dev/platform/pb926/platform.h create mode 100644 conts/userlibs/libdev/include/dev/platform/pba9/irq.h create mode 100644 conts/userlibs/libdev/include/dev/platform/pba9/platform.h create mode 100644 conts/userlibs/libdev/include/dev/platform/realview/platform.h rename conts/{libdev/include/libdev => userlibs/libdev/include/dev}/timer.h (100%) rename conts/{libdev/include/libdev => userlibs/libdev/include/dev}/uart.h (100%) rename conts/{ => userlibs}/libdev/kmi/pl050/SConscript (51%) rename conts/{ => userlibs}/libdev/kmi/pl050/keymap.h (98%) rename conts/{ => userlibs}/libdev/kmi/pl050/kmi.c (99%) rename conts/{ => userlibs}/libdev/kmi/pl050/kmi.h (100%) rename conts/{ => userlibs}/libdev/timer/omap/SConscript (59%) rename conts/{ => userlibs}/libdev/timer/omap/timer.c (99%) rename conts/{ => userlibs}/libdev/timer/omap/timer.h (100%) rename conts/{ => userlibs}/libdev/timer/sp804/SConscript (51%) rename conts/{ => userlibs}/libdev/timer/sp804/timer.c (100%) rename conts/{ => userlibs}/libdev/timer/sp804/timer.h (98%) rename conts/{ => userlibs}/libdev/uart/omap/SConscript (59%) rename conts/{ => userlibs}/libdev/uart/omap/uart.c (98%) rename conts/{ => userlibs}/libdev/uart/omap/uart.h (100%) rename conts/{ => userlibs}/libdev/uart/pl011/SConscript (51%) rename conts/{ => userlibs}/libdev/uart/pl011/uart.c (98%) rename conts/{ => userlibs}/libdev/uart/pl011/uart.h (95%) rename conts/{ => userlibs}/libl4/SConscript (67%) create mode 100644 conts/userlibs/libl4/SConstruct rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/asm.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/irq.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/syscalls.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/syslib.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/types.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/utcb.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/v5/perfmon.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/v5/utcb.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/v7/perfmon.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/arch/arm/v7/utcb.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/cache.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/exregs.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/init.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/ipcdefs.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/irq.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/kip.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/lib/addr.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/lib/bit.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/lib/cap.h (95%) rename conts/{ => userlibs}/libl4/include/l4lib/lib/idpool.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/lib/thread.h (100%) create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/cache.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/capability.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/errno.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/exregs.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/ipc.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/irq.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/kip.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/mutex.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/space.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/api/thread.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/arch/arm/exception.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/arch/arm/io.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/arch/arm/irq.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/arch/arm/mutex.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/arch/arm/v5/mm.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/arch/arm/v7/exception.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/arch/arm/v7/mm.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/generic/cap-types.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/generic/preempt.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/generic/space.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/generic/tcb.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/glue/arm/cache.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/glue/arm/context.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/glue/arm/memlayout.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/glue/arm/memory.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/glue/arm/message.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/glue/arm/syscall.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/lib/list.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/lib/math.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/lib/mutex.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/lib/spinlock.h create mode 100644 conts/userlibs/libl4/include/l4lib/linux/lib/wait.h rename conts/{ => userlibs}/libl4/include/l4lib/macros.h (93%) rename conts/{ => userlibs}/libl4/include/l4lib/mutex.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/os/posix/kstat.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/os/posix/readdir.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/perfmon.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/types.h (100%) rename conts/{ => userlibs}/libl4/include/l4lib/utcb.h (100%) rename conts/{ => userlibs}/libl4/src/arch/arm/exregs.c (100%) rename conts/{ => userlibs}/libl4/src/arch/arm/new_thread.S (100%) rename conts/{ => userlibs}/libl4/src/arch/arm/syscalls.S (100%) rename conts/{ => userlibs}/libl4/src/arch/arm/v5/atomic.S (100%) rename conts/{ => userlibs}/libl4/src/arch/arm/v5/mutex.S (100%) rename conts/{ => userlibs}/libl4/src/arch/arm/v6/mutex.c (100%) create mode 100644 conts/userlibs/libl4/src/arch/arm/v7/atomic.S rename conts/{ => userlibs}/libl4/src/arch/arm/v7/mutex.S (100%) rename conts/{ => userlibs}/libl4/src/arch/arm/v7/perfmon.c (100%) rename conts/{ => userlibs}/libl4/src/init.c (100%) rename conts/{ => userlibs}/libl4/src/irq.c (100%) rename conts/{ => userlibs}/libl4/src/lib/addr.c (100%) rename conts/{ => userlibs}/libl4/src/lib/bit.c (100%) rename conts/{ => userlibs}/libl4/src/lib/cap/cap.c (85%) rename conts/{ => userlibs}/libl4/src/lib/cap/read.c (100%) rename conts/{ => userlibs}/libl4/src/lib/idpool.c (98%) rename conts/{ => userlibs}/libl4/src/lib/thread/init.c (98%) rename conts/{ => userlibs}/libl4/src/lib/thread/thread.c (99%) rename conts/{ => userlibs}/libl4/src/mutex.c (100%) rename conts/{ => userlibs}/libmem/SConscript (55%) create mode 100644 conts/userlibs/libmem/SConstruct rename conts/{libmem/mm => userlibs/libmem/include/mem}/alloc_page.h (96%) rename conts/{libmem/tests => userlibs/libmem/include/mem}/clz.h (100%) rename conts/{libmem/tests => userlibs/libmem/include/mem}/debug.h (83%) rename conts/{libmem/tests => userlibs/libmem/include/mem}/libl4.h (100%) rename conts/{libmem/malloc => userlibs/libmem/include/mem}/malloc.h (100%) rename conts/{libmem/memcache => userlibs/libmem/include/mem}/memcache.h (100%) rename conts/{libmem/tests => userlibs/libmem/include/mem}/test_alloc_generic.h (100%) rename conts/{libmem/tests => userlibs/libmem/include/mem}/test_allocpage.h (93%) rename conts/{libmem/tests => userlibs/libmem/include/mem}/test_kmalloc.h (83%) rename conts/{libmem/tests => userlibs/libmem/include/mem}/test_memcache.h (86%) rename conts/{libmem/tests => userlibs/libmem/include/mem}/tests.h (100%) rename conts/{ => userlibs}/libmem/malloc/malloc.c (100%) rename conts/{ => userlibs}/libmem/memcache/memcache.c (99%) rename conts/{ => userlibs}/libmem/mm/alloc_page.c (99%) rename conts/{ => userlibs}/libmem/run_tests.py (100%) rename conts/{ => userlibs}/libmem/tests/clz.c (100%) rename conts/{ => userlibs}/libmem/tests/debug.c (100%) rename conts/{ => userlibs}/libmem/tests/libl4.c (100%) rename conts/{ => userlibs}/libmem/tests/linker.c (100%) rename conts/{ => userlibs}/libmem/tests/main.c (98%) rename conts/{ => userlibs}/libmem/tests/memory.c (100%) rename conts/{ => userlibs}/libmem/tests/test_alloc_generic.c (100%) rename conts/{ => userlibs}/libmem/tests/test_allocpage.c (100%) rename conts/{ => userlibs}/libmem/tests/test_kmalloc.c (100%) rename conts/{ => userlibs}/libmem/tests/test_memcache.c (99%) delete mode 100644 docs/architecture.txt create mode 100644 include/l4/generic/idle.h create mode 100644 loader/SConstruct rename {config => scripts/config}/__init__.py (100%) create mode 100644 scripts/config/caps.py create mode 100644 scripts/config/cml/arm.ruleset create mode 100644 scripts/config/cml/container_ruleset.template rename {config => scripts/config}/cml/examples/beagle/hello-world.cml (100%) rename {config => scripts/config}/cml/examples/helloworld/config.cml (100%) rename {config => scripts/config}/cml/examples/kmi/kmi-pb926.cml (100%) rename {config => scripts/config}/cml/examples/linux/beagle/config.cml (100%) rename {config => scripts/config}/cml/examples/linux/pb926/config.cml (100%) create mode 100644 scripts/config/cml/examples/linux/vexpress/config.cml create mode 100644 scripts/config/cml/examples/posix/single_posix.cml create mode 100644 scripts/config/cml/examples/posix/two_posix.cml rename {config => scripts/config}/cml/examples/vxa9/config.cml (100%) rename {config => scripts/config}/config_check.py (100%) rename configure.py => scripts/config/config_invoke.py (64%) rename {config => scripts/config}/configuration.py (74%) rename {config => scripts/config}/lib.py (100%) create mode 100644 scripts/config/projpaths.py create mode 100755 scripts/kernel/check_kernel_limit.py mode change 100755 => 100644 scripts/linux/build_linux.py create mode 100644 src/generic/idle.c create mode 100755 tools/tagsgen/tagsgen_linux.py diff --git a/SConstruct b/SConstruct index bb78220..2abc190 100644 --- a/SConstruct +++ b/SConstruct @@ -4,21 +4,23 @@ # # Copyright © 2009 B Labs Ltd # -import os, shelve -import configure -from configure import * +# This Script is mainly concerned with(in the same order): +# 1. Generating linker script for kernel. +# 2. Generating cinfo.c file based on generated containers. +# 3. Calling scons recursively over various kernel subdirectories. +# +import os from os.path import * +from scripts.config.config_invoke import * -config = configuration_retrieve() -arch = config.arch -subarch = config.subarch -platform = config.platform -gcc_arch_flag = config.gcc_arch_flag -all_syms = config.all -builddir='build/codezero/' +config = configuration_retrieve() +arch = config.arch +subarch = config.subarch +platform = config.platform +gcc_arch_flag = config.gcc_arch_flag +builddir = join(BUILDDIR, 'kernel') - -# Generate kernel linker script at runtime using template file. +# Generate kernel linker script at runtime using template file def generate_kernel_linker_script(target, source, env): linker_in = source[0] linker_out = target[0] @@ -28,86 +30,95 @@ def generate_kernel_linker_script(target, source, env): ('include', 'l4/platform/'+ platform + '/offsets.h', \ 'l4/glue/' + arch + '/memlayout.h', linker_in, linker_out) os.system(cmd) - -create_kernel_linker = Command(join(builddir, 'include/l4/arch/arm/linker.lds'), \ - join(PROJROOT, 'include/l4/arch/arm/linker.lds.in'), \ - generate_kernel_linker_script) + return None ''' -# Generate linker file with physical addresses, -# to be used for debug purpose only +# Generate kernel linker file with physical addresses +# (to be used for debug purpose only) def generate_kernel_phys_linker_script(target, source, env): phys_linker_in = source[0] phys_linker_out = target[0] - cmd = config.toolchain_kernel + "cpp -D__CPP__ " + \ + cmd = config.toolchain_kernel + "cpp -D__CPP__ -Dkernel_offset=0 " + \ "-I%s -imacros l4/macros.h -imacros %s -imacros %s -C -P %s -o %s" % \ ('include', 'l4/platform/'+ platform + '/offsets.h', \ 'l4/glue/' + arch + '/memlayout.h', phys_linker_in, phys_linker_out) os.system(cmd) - -create_kernel_phys_linker = Command(join(builddir, 'include/physlink.lds'), \ - join(PROJROOT, 'include/l4/arch/arm/linker.lds.in'), \ - generate_kernel_phys_linker_script) + return None ''' +# Kernel build environment env = Environment(CC = config.toolchain_kernel + 'gcc', - AR = config.toolchain_kernel + 'ar', - RANLIB = config.toolchain_kernel + 'ranlib', - # 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', '-march=' + gcc_arch_flag], - LINKFLAGS = ['-nostdlib', '-T' + join(builddir, 'include/l4/arch/arm/linker.lds')], - ASFLAGS = ['-D__ASSEMBLY__', '-march=' + gcc_arch_flag], - PROGSUFFIX = '.elf', # The suffix to use for final executable - ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path - LIBS = 'gcc', # libgcc.a - This is required for division routines. - CPPPATH = ["#include"], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__') + AR = config.toolchain_kernel + 'ar', + RANLIB = config.toolchain_kernel + 'ranlib', + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', + '-T' + join(builddir, 'include/l4/arch/arm/linker.lds')], + ASFLAGS = ['-D__ASSEMBLY__', '-march=' + gcc_arch_flag], + # The suffix to use for final executable + PROGSUFFIX = '.elf', + # Inherit shell path + ENV = {'PATH' : os.environ['PATH']}, + # libgcc.a - This is required for division routines. + LIBS = 'gcc', + CPPPATH = KERNEL_HEADERS, + CPPFLAGS = '-include l4/config.h -include l4/macros.h \ + -include l4/types.h -D__KERNEL__') objects = [] - objects += SConscript('src/generic/SConscript', - exports = {'symbols' : all_syms, 'env' : env}, - duplicate=0, build_dir=builddir + 'generic') + exports = { 'env' : env }, duplicate = 0, + build_dir = join(builddir, 'generic')) -objects += SConscript('src/glue/' + arch + '/SConscript', - exports = {'symbols' : all_syms, 'env' : env}, - duplicate=0, build_dir=builddir + 'glue' + '/' + arch) +objects += SConscript(join(join('src/glue', arch), 'SConscript'), + exports = { 'env' : env }, duplicate = 0, + build_dir = join(builddir, join('glue',arch))) -objects += SConscript('src/arch/' + arch + '/SConscript', - exports = {'symbols' : all_syms, 'env' : env}, - duplicate=0, build_dir=builddir + 'arch/' + arch) +objects += SConscript(join(join('src/arch', arch), 'SConscript'), + exports = { 'env' : env }, duplicate = 0, + build_dir = join(builddir, join('arch', arch))) -objects += SConscript('src/arch/' + arch + '/' + subarch + '/SConscript', - exports = {'symbols' : all_syms, 'env' : env}, - duplicate=0, build_dir=builddir + 'arch/' + arch + '/' + subarch) +objects += SConscript(join(join('src/arch', arch), join(subarch, 'SConscript')), + exports = { 'env' : env }, duplicate = 0, + build_dir = join(builddir, join(join('arch',arch), subarch))) objects += SConscript('src/lib/SConscript', - exports = {'symbols' : all_syms, 'env' : env}, - duplicate=0, build_dir=builddir + 'lib') + exports = { 'env' : env }, duplicate = 0, + build_dir = join(builddir, 'lib')) objects += SConscript('src/api/SConscript', - exports = {'symbols' : all_syms, 'env' : env}, - duplicate=0, build_dir=builddir + 'api') + exports = { 'env' : env }, duplicate = 0, + build_dir = join(builddir, 'api')) objects += SConscript('src/drivers/SConscript', - exports = {'symbols' : all_syms, 'env' : env, 'platform' : platform,'bdir' : 'driver/'}, - duplicate=0, build_dir=builddir) + exports = { 'env' : env, 'bdir' : 'driver/'}, duplicate = 0, + build_dir = join(builddir, 'driver')) -objects += SConscript('src/platform/' + platform + '/SConscript', - exports = {'symbols' : all_syms, 'env' : env,'platform' : platform}, duplicate=0, - build_dir=builddir + 'platform' + '/' +platform) +objects += SConscript(join(join('src/platform', platform), 'SConscript'), + exports = { 'env' : env }, duplicate = 0, + build_dir = join(builddir, join('platform', platform))) -kernel_elf = env.Program(BUILDDIR + '/kernel.elf', objects) -#env_phys = env.Clone() -#env_phys.Replace(LINKFLAGS = ['-nostdlib', '-T' + join(builddir, 'include/physlink.lds')]) -#env_phys.Program(BUILDDIR + '/kernel_phys.elf', objects) -Alias('kernel', kernel_elf) -Depends(kernel_elf, objects) -Depends(objects, create_kernel_linker) -#Depends(objects, create_kernel_phys_linker) -Depends(objects, 'include/l4/config.h') +# Add builders for generating kernel linker scripts +kernel_linker = Builder(action = generate_kernel_linker_script) +env.Append(BUILDERS = {'KERNEL_LINKER' : kernel_linker}) +env.KERNEL_LINKER(join(builddir, 'include/l4/arch/arm/linker.lds'), + [join(PROJROOT, 'include/l4/arch/arm/linker.lds.in'), CONFIG_H]) +''' +kernel_phys_linker = Builder(action = generate_kernel_phys_linker_script) +env_phys = env.Clone() +env_phys.Replace(LINKFLAGS = ['-nostdlib', '-T' + join(builddir, 'include/physlink.lds')]) +env_phys.Append(BUILDERS = {'KERNEL_LINKER' : kernel_phys_linker}) +env_phys.KERNEL_LINKER(join(builddir, 'include/physlink.lds'), + join(PROJROOT, 'include/l4/arch/arm/linker.lds.in'), CONFIG_H) + +kernel_phys_elf = env_phys.Program(join(BUILDDIR, 'kernel_phys.elf'), objects) +Depends(kernel_phys_elf, objects) +''' + +kernel_elf = env.Program(KERNEL_ELF, objects) +Depends(objects, CONFIG_H) diff --git a/SConstruct.loader b/SConstruct.loader deleted file mode 100644 index 6f4a7c4..0000000 --- a/SConstruct.loader +++ /dev/null @@ -1,64 +0,0 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- a microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd - -import os, sys, shelve -from os.path import join - -from config.configuration import * -from config.projpaths import * - -config = configuration_retrieve() -arch = config.arch -platform = config.platform -gcc_arch_flag = config.gcc_arch_flag - -variant = 'baremetal' - -# Locally important paths are here -LIBC_PATH = 'loader/libs/c' -LIBC_LIBPATH = LIBC_PATH -LIBC_INCPATH = ['#' + join(LIBC_PATH, 'include'), \ - '#' + join(LIBC_PATH, 'include/arch/' + arch)] - -LIBDEV_PATH = 'conts/libdev' -LIBDEV_INCPATH = ['#' + join(LIBDEV_PATH, 'include'),] - -LIBELF_PATH = 'loader/libs/elf' -LIBELF_LIBPATH = LIBELF_PATH -LIBELF_INCPATH = '#' + join(LIBELF_PATH, 'include') - -env = Environment(CC = config.toolchain_kernel + 'gcc', - AR = config.toolchain_kernel + 'ar', - RANLIB = config.toolchain_kernel + 'ranlib', - # 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', '-march=' + gcc_arch_flag], - LINKFLAGS = ['-nostdlib', '-T' + join(BUILDDIR, 'loader/linker.lds'), "-u_start"], - ASFLAGS = ['-D__ASSEMBLY__'], - PROGSUFFIX = '.elf', - ENV = {'PATH' : os.environ['PATH']}, - LIBS = ['gcc', 'elf', 'libdev-baremetal', 'c-baremetal', 'gcc'], - LIBPATH = [join(join('build', LIBDEV_PATH), 'sys-' + variant), \ - join('build', LIBELF_PATH), join('build', LIBC_PATH)], - CPPPATH = ['#include', LIBDEV_INCPATH, LIBC_INCPATH, LIBELF_INCPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__') - -libdev = SConscript('conts/libdev/SConscript', \ - exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : variant}, \ - duplicate = 0, variant_dir = 'build/conts/libdev/sys-' + variant) -libc = SConscript('loader/libs/c/SConscript', \ - exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : variant}, \ - duplicate = 0, variant_dir = 'build/loader/libs/c') -libelf = SConscript('loader/libs/elf/SConscript', exports = { 'env' : env }, \ - duplicate = 0, variant_dir = 'build/loader/libs/elf') - -loader_objs = SConscript('loader/SConscript', exports = { 'env' : env }, \ - duplicate = 0, variant_dir = 'build/loader') - -final_elf = env.Program('build/final.elf', [libelf + libc + loader_objs]) -Depends(loader_objs, libelf) -Depends(loader_objs, libc) diff --git a/SConstruct.userlibs b/SConstruct.userlibs deleted file mode 100644 index e224114..0000000 --- a/SConstruct.userlibs +++ /dev/null @@ -1,59 +0,0 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- Virtualization microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd -# -import os, shelve -import configure -from configure import * -from os.path import * - -config = configuration_retrieve() -arch = config.arch -subarch = config.subarch -platform = config.platform -gcc_arch_flag = config.gcc_arch_flag -all_syms = config.all - -env = Environment(CC = config.toolchain_userspace + 'gcc', - AR = config.toolchain_userspace + 'ar', - RANLIB = config.toolchain_userspace + 'ranlib', - # 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', '-march=' + gcc_arch_flag], - LINKFLAGS = ['-nostdlib'], - ASFLAGS = ['-D__ASSEMBLY__', '-march=' + gcc_arch_flag], - ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path - LIBS = 'gcc', # libgcc.a - This is required for division routines. - CPPPATH = "#include", - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') - -libl4 = SConscript('conts/libl4/SConscript', \ - exports = { 'env' : env, 'arch' : arch, 'subarch' : subarch }, duplicate = 0, \ - variant_dir = join(BUILDDIR, os.path.relpath('conts/libl4', PROJROOT))) - -e = env.Clone() -e.Replace(CPPFLAGS = '') -type = 'userspace' -libdev = SConscript('conts/libdev/SConscript', \ - exports = { 'env' : e, 'arch' : arch, 'platform' : platform, 'type' : 'userspace' }, \ - duplicate = 0, variant_dir = \ - join(join(BUILDDIR, os.path.relpath('conts/libdev', PROJROOT)), 'sys-' + type)) - -libc = SConscript('conts/libc/SConscript', \ - exports = { 'env' : env, 'arch' : arch, 'type' : 'userspace' }, \ - duplicate = 0, variant_dir = \ - join(BUILDDIR, os.path.relpath('conts/libc', PROJROOT))) - -libmm, libmc, libmalloc = SConscript('conts/libmem/SConscript', \ - exports = { 'env' : env, }, duplicate = 0, variant_dir = \ - join(BUILDDIR, os.path.relpath('conts/libmem', PROJROOT))) - -Alias('libl4', libl4) -Alias('libdev', libdev) -Alias('libc', libc) -Alias('libmm', libmm) -Alias('libmc', libmc) -Alias('libmalloc', libmalloc) diff --git a/build.py b/build.py index 54c3b3a..8bfce45 100755 --- a/build.py +++ b/build.py @@ -9,75 +9,127 @@ # import os, sys, shelve, shutil from os.path import join -from config.projpaths import * -from config.configuration import * -from config.config_check import * -from scripts.qemu import qemu_cmdline +from scripts.config.projpaths import * +from scripts.config.configuration import * +from scripts.config.config_check import * +from scripts.qemu.qemu_cmdline import * from scripts.conts import containers -from configure import * +from scripts.config.config_invoke import * +from scripts.kernel.check_kernel_limit import * + +def build_system(opts, args): + if opts.print_config: + config = configuration_retrieve() + if config: + config.config_print() + else: + print '\nNo configuration to print...\n' + return None + + # Configure + configure_system(opts, args) + + # Are we asked to configure only + if opts.config_only: + return None + + # Check for sanity of containers + sanity_check_conts() + + # Build userspace libraries + os.chdir(USERLIBS_DIR) + print "\nBuilding userspace libraries..." + ret = os.system("scons" + " -j " + opts.jobs) + if(ret): + print "Building userspace libraries failed...\n" + sys.exit(1) + + # Build containers + os.chdir(PROJROOT) + print "\nBuilding containers..." + containers.build_all_containers(opts) + + # Build the kernel + print "\nBuilding the kernel..." + os.chdir(PROJROOT) + ret = os.system("scons" + " -j " + opts.jobs) + if(ret): + print "Building kernel failed...\n" + sys.exit(1) + + # Check if kernel overlap with first container + if(check_kernel_container_overlap()): + print "Kernel overlaps with first continer." + print "Please shift the first container to some higher " + \ + "address after the kernel and build again...\n" + sys.exit(1) + + # Build the loader + os.chdir(PROJROOT) + print "\nBuilding the loader and packing..." + ret = os.system("scons -f " + join(LOADERDIR, 'SConstruct') + " -j " + opts.jobs) + if(ret): + print "Building loader failed...\n" + sys.exit(1) + + # Build qemu-insight-script + print "\nBuilding qemu-insight-script..." + build_qemu_cmdline_script() + + print "\nBuild complete..." + print "\nRun qemu with following command: ./tools/run-qemu-insight\n" + + renamed_cml = rename_config_cml(opts) + if(renamed_cml): + print 'CML configuration file saved as ' + renamed_cml + '\n' + + return None + +def clean_system(opts): + # Clean only if some config exists. + if not configuration_retrieve(): + print '\nNo configuration exists, nothing to clean..\n' + return None + + # Clean userspace libraries + os.chdir(USERLIBS_DIR) + print "\nCleaning userspace libraries..." + ret = os.system("scons -c") + + # Clean containers + os.chdir(PROJROOT) + print "\nCleaning containers..." + containers.clean_all_containers() + + # Clean the kernel + print "\nCleaning the kernel..." + os.chdir(PROJROOT) + ret = os.system("scons -c") + + # Clean the loader + os.chdir(PROJROOT) + print "\nCleaning the loader..." + ret = os.system("scons -c -f " + join(LOADERDIR, 'SConstruct')) + + # Remove qemu-insight-script + print "\nRemoving qemu-insight-script..." + clean_qemu_cmdline_script() + + if opts.clean_all: + cml_files_cleanup() + + print '\nCleaning Done...\n' + return None def main(): opts, args = build_parse_options() - # - # Configure - # - configure_system(opts, args) - # - # Check for sanity of containers - # - sanity_check_conts() + if opts.clean or opts.clean_all: + clean_system(opts) + else: + build_system(opts, args) - # - # Build userspace libraries - # - print "\nBuilding userspace libraries..." - ret = os.system('scons -f SConstruct.userlibs') - if(ret): - print "Build failed \n" - sys.exit(1) - - # - # Build containers - # - print "\nBuilding containers..." - containers.build_all_containers() - - # - # Generate cinfo - # - generate_cinfo() - - # - # Build the kernel - # - print "\nBuilding the kernel..." - os.chdir(PROJROOT) - ret = os.system("scons") - if(ret): - print "Build failed \n" - sys.exit(1) - - # - # Build libs and loader - # - os.chdir(PROJROOT) - print "\nBuilding the loader and packing..." - ret = os.system("scons -f SConstruct.loader") - if(ret): - print "Build failed \n" - sys.exit(1) - - # - # Build qemu-insight-script - # - print "\nBuilding qemu-insight-script.." - qemu_cmdline.build_qemu_cmdline_script() - #build_qemu_cmdline_script() - - print "\nBuild complete." - - print "\nRun qemu with following command: ./tools/run-qemu-insight\n" + return None if __name__ == "__main__": main() diff --git a/config/caps.py b/config/caps.py deleted file mode 100644 index d54532f..0000000 --- a/config/caps.py +++ /dev/null @@ -1,273 +0,0 @@ -#! /usr/bin/env python2.6 -# -*- mode: python; coding: utf-8; -*- -import os, sys, shelve, shutil, re -from projpaths import * -from lib import * -from caps import * -from string import Template - -cap_strings = { 'ipc' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_IPC | ${target_rtype}, -\t\t\t\t.access = CAP_IPC_SEND | CAP_IPC_RECV -\t\t\t\t | CAP_IPC_FULL | CAP_IPC_SHORT -\t\t\t\t | CAP_IPC_EXTENDED | CAP_CHANGEABLE -\t\t\t\t | CAP_REPLICABLE | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, .size = 0, -\t\t\t}, -''' -, 'tctrl' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_TCTRL | ${target_rtype}, -\t\t\t\t.access = CAP_TCTRL_CREATE | CAP_TCTRL_DESTROY -\t\t\t\t | CAP_TCTRL_SUSPEND | CAP_TCTRL_RUN -\t\t\t\t | CAP_TCTRL_RECYCLE | CAP_TCTRL_WAIT -\t\t\t\t | CAP_CHANGEABLE | CAP_REPLICABLE -\t\t\t\t | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, .size = 0, -\t\t\t}, -''' -, 'irqctrl' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_IRQCTRL | ${target_rtype}, -\t\t\t\t.access = CAP_IRQCTRL_REGISTER | CAP_IRQCTRL_WAIT -\t\t\t\t | CAP_CHANGEABLE | CAP_REPLICABLE -\t\t\t\t | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, .size = 0, -\t\t\t}, -''' -, 'exregs' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_EXREGS | ${target_rtype}, -\t\t\t\t.access = CAP_EXREGS_RW_PAGER -\t\t\t\t | CAP_EXREGS_RW_UTCB | CAP_EXREGS_RW_SP -\t\t\t\t | CAP_EXREGS_RW_PC | CAP_EXREGS_RW_REGS -\t\t\t\t | CAP_CHANGEABLE | CAP_REPLICABLE | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, .size = 0, -\t\t\t}, -''' -, 'capctrl' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_CAP | ${target_rtype}, -\t\t\t\t.access = CAP_CAP_GRANT | CAP_CAP_READ -\t\t\t\t | CAP_CAP_SHARE | CAP_CAP_REPLICATE -\t\t\t\t | CAP_CAP_MODIFY -\t\t\t\t| CAP_CAP_READ | CAP_CAP_SHARE, -\t\t\t\t.start = 0, .end = 0, .size = 0, -\t\t\t}, -''' -, 'umutex' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_UMUTEX | CAP_RTYPE_CONTAINER, -\t\t\t\t.access = CAP_UMUTEX_LOCK | CAP_UMUTEX_UNLOCK, -\t\t\t\t.start = 0, .end = 0, .size = 0, -\t\t\t}, -''' -, 'threadpool' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_QUANTITY -\t\t\t\t | CAP_RTYPE_THREADPOOL, -\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, -\t\t\t\t.size = ${size}, -\t\t\t}, -''' -, 'spacepool' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_QUANTITY | CAP_RTYPE_SPACEPOOL, -\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, -\t\t\t\t.size = ${size}, -\t\t\t}, -''' -, 'cpupool' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_QUANTITY | CAP_RTYPE_CPUPOOL, -\t\t\t\t.access = 0, .start = 0, .end = 0, -\t\t\t\t.size = ${size} /* Percentage */, -\t\t\t}, -''' -, 'mutexpool' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_QUANTITY | CAP_RTYPE_MUTEXPOOL, -\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, -\t\t\t\t.size = ${size}, -\t\t\t}, -''' -, 'mappool' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t/* For pmd accounting */ -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_QUANTITY | CAP_RTYPE_MAPPOOL, -\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, -\t\t\t\t/* Function of mem regions, nthreads etc. */ -\t\t\t\t.size = ${size}, -\t\t\t}, -''' -, 'cappool' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t/* For cap spliting, creating, etc. */ -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_QUANTITY | CAP_RTYPE_CAPPOOL, -\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, -\t\t\t\t.start = 0, .end = 0, -\t\t\t\t/* This may be existing caps X 2 etc. */ -\t\t\t\t.size = ${size}, -\t\t\t}, -''' -, 'device' : \ -''' -\t\t\t[${idx}] = { -\t\t\t\t/* For device selection */ -\t\t\t\t.target = ${cid}, -\t\t\t\t.type = CAP_TYPE_MAP_PHYSMEM | CAP_RTYPE_CONTAINER, -\t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE | CAP_MAP_EXEC | -\t\t\t\t\tCAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP | -\t\t\t\t\tCAP_IRQCTRL_REGISTER, -\t\t\t\t.start = __pfn(PLATFORM_${devname}_BASE), -\t\t\t\t.end = __pfn(PLATFORM_${devname}_BASE + PLATFORM_${devname}_SIZE), -\t\t\t\t.size = PLATFORM_${devname}_SIZE >> 12, -\t\t\t\t.attr = (CAP_DEVTYPE_${devtype} & CAP_DEVTYPE_MASK) -\t\t\t\t\t| ((${devnum} << CAP_DEVNUM_SHIFT) & CAP_DEVNUM_MASK), -\t\t\t\t.irq = IRQ_${devname}, -\t\t\t}, -''' -} - -# -# These are carefully crafted functions, touch with care. -# -def prepare_custom_capability(cont, param, val): - if 'TYPE' in param: - capkey, captype, rest = param.split('_', 2) - capkey = capkey.lower() - captype = captype.lower() - cont.caps[capkey] = cap_strings[captype] - elif 'TARGET' in param: - target_parts = param.split('_', 2) - if len(target_parts) == 2: - capkey = target_parts[0].lower() - templ = Template(cont.caps[capkey]) - cont.caps[capkey] = templ.safe_substitute(cid = val) - elif len(target_parts) == 3: - capkey = target_parts[0].lower() - ttype = target_parts[2] - templ = Template(cont.caps[capkey]) - - # On current container, provide correct rtype and current containerid. - # Else we leave container id to user-supplied value - if ttype == 'CURRENT_CONTAINER': - cont.caps[capkey] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_CONTAINER', - cid = cont.id) - elif ttype == 'CURRENT_PAGER_SPACE': - cont.caps[capkey] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_SPACE', - cid = cont.id) - elif ttype == 'ANOTHER_CONTAINER': - cont.caps[capkey] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_CONTAINER') - elif ttype == 'ANOTHER_PAGER': - cont.caps[capkey] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_THREAD') - elif 'DEVICE' in param: - # Extract all fields - unused, device_name, rest = param.split('_', 2) - capkey = device_name.lower() - cont.caps[capkey] = cap_strings['device'] - templ = Template(cont.caps[capkey]) - device_id = device_name[-1:] - device_type = device_name[:-1] - - # Fill in all blanks - cont.caps[capkey] = \ - templ.safe_substitute(cid = cont.id, - devname = device_name, - devnum = device_id, - devtype = device_type) - - else: # Ignore custom_use symbol - return - # print capkey - # print cont.caps[capkey] - -def prepare_typed_capability(cont, param, val): - captype, params = param.split('_', 1) - captype = captype.lower() - - # USE makes us assign the initial cap string with blank fields - if 'USE' in params: - cont.caps[captype] = cap_strings[captype] - - # Prepare string template from capability type - templ = Template(cont.caps[captype]) - - # If it is a pool, amend current container id as default - if captype[-len('pool'):] == 'pool': - cont.caps[captype] = templ.safe_substitute(cid = cont.id) - - # Fill in the blank size field - elif 'SIZE' in params: - # Get reference to capability string template - templ = Template(cont.caps[captype]) - cont.caps[captype] = templ.safe_substitute(size = val) - - # Fill in capability target type and target id fields - elif 'TARGET' in params: - # Get reference to capability string template - templ = Template(cont.caps[captype]) - - # Two types of strings are expected here: TARGET or TARGET_TARGETTYPE - # If TARGET, the corresponding value is in val - target_parts = params.split('_', 1) - - # Target type - if len(target_parts) == 2: - ttype = target_parts[1] - - # On current container, provide correct rtype and current containerid. - # Else we leave container id to user-supplied value - if ttype == 'CURRENT_CONTAINER': - cont.caps[captype] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_CONTAINER', - cid = cont.id) - elif ttype == 'CURRENT_PAGER_SPACE': - cont.caps[captype] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_SPACE', - cid = cont.id) - elif ttype == 'ANOTHER_CONTAINER': - cont.caps[captype] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_CONTAINER') - elif ttype == 'ANOTHER_PAGER': - cont.caps[captype] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_THREAD') - - # Get target value supplied by user in val - else: - cont.caps[captype] = templ.safe_substitute(cid = val) - - #print captype - #print cont.caps[captype] - -def prepare_capability(cont, param, val): - if 'CUSTOM' in param or 'DEVICE' in param: - prepare_custom_capability(cont, param, val) - else: - prepare_typed_capability(cont, param, val) - diff --git a/config/cml/arm.ruleset b/config/cml/arm.ruleset deleted file mode 100644 index 7bf4736..0000000 --- a/config/cml/arm.ruleset +++ /dev/null @@ -1,213 +0,0 @@ -start main_menu - -############# -# SYMBOLS # -############# -symbols - -ARCH_ARM 'ARM' - -arm_cpu_type 'ARM Processor Type' -CPU_ARM1136 'ARM1136 - Experimental' -CPU_ARM11MPCORE 'ARM11 MPCore - Experimental' -CPU_ARM926 'ARM926EJ-S' -CPU_CORTEXA8 'ARM Cortex-A8' -CPU_CORTEXA9 'ARM Cortex-A9' - -arm_platform_type 'ARM Platform Type' -PLATFORM_EB 'Realview EB Platform' -PLATFORM_PBA8 'Realview PB-A8 Platform, To be added' -PLATFORM_PB926 'Versatile PB926 Platform' -PLATFORM_PB11MPCORE 'Realview PB11MPCore Platform' -PLATFORM_BEAGLE 'OMAP3530/Cortex-A8 Beagle Board' -PLATFORM_PBA9 'Realview Express Cortex-A9' - -main_menu 'Codezero Microkernel Configurator' -arm_menu 'ARM Architecture Configuration' -arm_cpu_menu 'ARM CPU type' -arm_platform_menu 'ARM Platform Type' -processor_properties 'Generic Processor Properties' -kernel_generic_options 'Generic Kernel Properties' -toolchain_menu 'Toolchain Prefix' -containers_menu 'Container Setup' -arch_type 'Main architecture' - -SMP 'Enable SMP Support' -NCPU 'Number of SMP CPUs' -DEBUG_ACCOUNTING 'Enable system operations accounting' -DEBUG_PERFMON 'Enable performance monitoring' -DEBUG_PERFMON_USER 'Userspace access to perfmon registers (in-kernel measurements disabled)' -DEBUG_SPINLOCKS 'Debug spinlocks, e.g. detect recursive locks, double unlocks' -SCHED_TICKS 'Scheduler ticks per second' -ICACHE_DISABLE 'Disable the L1 instruction cache' -DCACHE_DISABLE 'Disable the L1 data cache' -PREEMPT_DISABLE 'Disable Kernel Preemption' -TOOLCHAIN_USERSPACE 'Toolchain prefix for userspace' -TOOLCHAIN_KERNEL 'Toolchain prefix for kernel' - -CAPABILITIES 'Enable capability checking' - -############# -# CHOICES # -############# - -choices arch_type - ARCH_ARM - default ARCH_ARM - -choices arm_platform_type - PLATFORM_EB - PLATFORM_PBA8 - PLATFORM_PB926 - PLATFORM_PB11MPCORE - PLATFORM_BEAGLE - PLATFORM_PBA9 - default PLATFORM_PB926 - -choices arm_cpu_type - CPU_ARM926 - CPU_ARM1136 - CPU_ARM11MPCORE - CPU_CORTEXA8 - CPU_CORTEXA9 - default CPU_ARM926 - -############# -# MENUS # -############# - -menu arm_cpu_menu - arm_cpu_type - -menu arm_platform_menu - arm_platform_type - -menu arm_menu - arm_platform_menu - arm_cpu_menu - -menu processor_properties - SMP - NCPU% - ICACHE_DISABLE - DCACHE_DISABLE - -menu kernel_generic_options - PREEMPT_DISABLE - DEBUG_ACCOUNTING - DEBUG_PERFMON - DEBUG_PERFMON_USER - DEBUG_SPINLOCKS - SCHED_TICKS% - -menu toolchain_menu - TOOLCHAIN_USERSPACE$ - TOOLCHAIN_KERNEL$ - -menu main_menu - arch_type - arm_menu - processor_properties - kernel_generic_options - toolchain_menu - containers_menu - -############# -# RULES # -############# -#Capability/Container rules: -default CAPABILITIES from y -default DEBUG_ACCOUNTING from n -default DEBUG_PERFMON from n -default DEBUG_PERFMON_USER from n -default DEBUG_SPINLOCKS from n -default SCHED_TICKS from 1000 -derive DEBUG_PERFMON_KERNEL from DEBUG_PERFMON == y and DEBUG_PERFMON_USER != y - -#Subarch Derivation Rules -derive SUBARCH_V5 from CPU_ARM926 - -derive SUBARCH_V6 from CPU_ARM1136 or - CPU_ARM11MPCORE - -derive SUBARCH_V7 from CPU_CORTEXA8 or - CPU_CORTEXA9 - -#CPU rules: -unless PLATFORM_PB926 suppress CPU_ARM926 -unless PLATFORM_PB11MPCORE or PLATFORM_EB suppress CPU_ARM11MPCORE -unless PLATFORM_EB suppress CPU_ARM1136 -unless PLATFORM_PBA9 or PLATFORM_EB suppress CPU_CORTEXA9 - -unless PLATFORM_BEAGLE or - PLATFORM_PBA8 or - PLATFORM_EB suppress CPU_CORTEXA8 - -#SMP support rules -unless CPU_CORTEXA9 or CPU_ARM11MPCORE suppress SMP -unless CPU_CORTEXA9 or CPU_ARM11MPCORE suppress NCPU -unless SMP suppress NCPU -unless DEBUG_ACCOUNTING suppress DEBUG_PERFMON - DEBUG_PERFMON_USER -unless DEBUG_PERFMON suppress DEBUG_PERFMON_USER - -# NOTE: Unlike menus, choices dont take { sym } model of visibility -# dependencies. Instead, a choice symbol is declared in a menu, and -# suppress statement is used to make sym visible, instead of a -# { sym } model under the choices. (See manual for { sym } usage). - -unless ARCH_ARM suppress arm_menu -derive DRIVER_UART_PL011 from PLATFORM_PB926 or - PLATFORM_PB11MPCORE or - PLATFORM_PBA9 or - PLATFORM_EB or - PLATFORM_PBA8 - -derive DRIVER_TIMER_SP804 from PLATFORM_PB926 or - PLATFORM_PB11MPCORE or - PLATFORM_PBA9 or - PLATFORM_EB or - PLATFORM_PBA8 - -derive DRIVER_IRQ_PL190 from PLATFORM_PB926 - -derive DRIVER_IRQ_GIC from PLATFORM_PB11MPCORE or - PLATFORM_PBA9 or - PLATFORM_EB or - PLATFORM_PBA8 - -derive DRIVER_UART_OMAP from PLATFORM_BEAGLE -derive DRIVER_TIMER_OMAP from PLATFORM_BEAGLE -derive DRIVER_INTC_OMAP from PLATFORM_BEAGLE - -#SMP default value -default SMP from y -default NCPU from 4 -default ICACHE_DISABLE from n -default DCACHE_DISABLE from n -default PREEMPT_DISABLE from n - -require NCPU <= 4 - -# Derive Ram base address depending on platform selected -# we use this in setting containers physical regions -# default values -# FIXME: Find a better solution -derive RAM_BASE_PLAT from PLATFORM_BEAGLE ? 0x80000000 : 0x00000000 - -# Toolchains: -default TOOLCHAIN_USERSPACE from 'arm-none-linux-gnueabi-' -default TOOLCHAIN_KERNEL from 'arm-none-eabi-' - -prefix CONFIG_ - -# Checklist for correct CML2 -# 1) Have you defined a prompt for each menu, choice_type? -# 2) Have you defined a default for each symbol? -# 3) Have you put 'symbols' keyword before each symbol, menu and choice? - - -# Important note on derived symbols -# DO NOT place any declaration for derived symbols like normal symbols, -# otherwise the derivation will be silently ignored, and you will be left -# wondering why. diff --git a/config/cml/container_ruleset.template b/config/cml/container_ruleset.template deleted file mode 100644 index 530b55e..0000000 --- a/config/cml/container_ruleset.template +++ /dev/null @@ -1,749 +0,0 @@ -symbols -CONT%(cn)d_TYPE_LINUX 'Linux Container' -CONT%(cn)d_TYPE_BAREMETAL 'Baremetal Container' -CONT%(cn)d_TYPE_POSIX 'POSIX Container' -CONT%(cn)d_OPT_NAME 'Container Name' - -CONTAINERS 'Number of containers' - -CONT%(cn)d_PHYSMEM_REGIONS 'Container %(cn)d Number of Physical Regions' -CONT%(cn)d_PHYS0_START 'Container %(cn)d Physical Region 0 Start Address' -CONT%(cn)d_PHYS0_END 'Container %(cn)d Physical Region 0 End Address' -CONT%(cn)d_PHYS1_START 'Container %(cn)d Physical Region 1 Start Address' -CONT%(cn)d_PHYS1_END 'Container %(cn)d Physical Region 1 End Address' -CONT%(cn)d_PHYS2_START 'Container %(cn)d Physical Region 2 Start Address' -CONT%(cn)d_PHYS2_END 'Container %(cn)d Physical Region 2 End Address' -CONT%(cn)d_PHYS3_START 'Container %(cn)d Physical Region 3 Start Address' -CONT%(cn)d_PHYS3_END 'Container %(cn)d Physical Region 3 End Address' - -symbols -CONT%(cn)d_VIRTMEM_REGIONS 'Container %(cn)d Number of Virtual Regions' -CONT%(cn)d_VIRT0_START 'Container %(cn)d Virtual Region 0 Start Address' -CONT%(cn)d_VIRT0_END 'Container %(cn)d Virtual Region 0 End Address' -CONT%(cn)d_VIRT1_START 'Container %(cn)d Virtual Region 1 Start Address' -CONT%(cn)d_VIRT1_END 'Container %(cn)d Virtual Region 1 End Address' -CONT%(cn)d_VIRT2_START 'Container %(cn)d Virtual Region 2 Start Address' -CONT%(cn)d_VIRT2_END 'Container %(cn)d Virtual Region 2 End Address' -CONT%(cn)d_VIRT3_START 'Container %(cn)d Virtual Region 3 Start Address' -CONT%(cn)d_VIRT3_END 'Container %(cn)d Virtual Region 3 End Address' -CONT%(cn)d_VIRT4_START 'Container %(cn)d Virtual Region 4 Start Address' -CONT%(cn)d_VIRT4_END 'Container %(cn)d Virtual Region 4 End Address' -CONT%(cn)d_VIRT5_START 'Container %(cn)d Virtual Region 5 Start Address' -CONT%(cn)d_VIRT5_END 'Container %(cn)d Virtual Region 5 End Address' - -# FIXME: We dont need to pass PAGER_LMA and PAGER_VMA to config.h now -# as we are using them just to derive other symbols, in this file only -CONT%(cn)d_PAGER_LMA 'Container %(cn)d Pager LMA' -CONT%(cn)d_PAGER_VMA 'Container %(cn)d Pager VMA' - -CONT%(cn)d_PAGER_SHM_START 'Container %(cn)d Shared Mappings Region Start' -CONT%(cn)d_PAGER_SHM_END 'Container %(cn)d Shared Mappings Region End' -CONT%(cn)d_PAGER_TASK_START 'Container %(cn)d Task Address Space Region Start' -CONT%(cn)d_PAGER_TASK_END 'Container %(cn)d Task Address Space Region End' -CONT%(cn)d_PAGER_UTCB_START 'Container %(cn)d UTCB Mappings Region Start' -CONT%(cn)d_PAGER_UTCB_END 'Container %(cn)d UTCB Mappings Region End' -CONT%(cn)d_LINUX_ZRELADDR 'Container %(cn)d Linux ZRELADDR Parameter' -CONT%(cn)d_LINUX_PAGE_OFFSET 'Container %(cn)d Linux PAGE_OFFSET Parameter' -CONT%(cn)d_LINUX_PHYS_OFFSET 'Container %(cn)d Linux PHYS_OFFSET Parameter' -CONT%(cn)d_LINUX_ROOTFS_ADDRESS 'Container %(cn)d Linux ROOTFS Address' - -default CONT%(cn)d_PAGER_LMA from CONT%(cn)d_PHYS0_START -default CONT%(cn)d_PAGER_VMA from CONT%(cn)d_VIRT0_START -default CONT%(cn)d_PAGER_SHM_START from CONT%(cn)d_VIRT1_START -default CONT%(cn)d_PAGER_SHM_END from CONT%(cn)d_VIRT1_END -default CONT%(cn)d_PAGER_TASK_START from CONT%(cn)d_VIRT2_START -default CONT%(cn)d_PAGER_TASK_END from CONT%(cn)d_VIRT2_END -default CONT%(cn)d_PAGER_UTCB_START from CONT%(cn)d_VIRT3_START -default CONT%(cn)d_PAGER_UTCB_END from CONT%(cn)d_VIRT3_END -default CONT%(cn)d_LINUX_ZRELADDR from (CONT%(cn)d_LINUX_PHYS_OFFSET + 0x8000) -default CONT%(cn)d_LINUX_PAGE_OFFSET from CONT%(cn)d_VIRT0_START -default CONT%(cn)d_LINUX_PHYS_OFFSET from CONT%(cn)d_PHYS0_START -default CONT%(cn)d_LINUX_ROOTFS_ADDRESS from (CONT%(cn)d_LINUX_PHYS_OFFSET + 0x500000) - -default CONT%(cn)d_VIRTMEM_REGIONS from (CONT%(cn)d_TYPE_POSIX==y ? 4 : 1) -default CONT%(cn)d_PHYSMEM_REGIONS from 1 - -# Define limits on virtual and physical memory regions of a _single_ container 0. Too much code! -when CONT%(cn)d_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_VIRT1_START CONT%(cn)d_VIRT1_END -when CONT%(cn)d_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_VIRT2_START CONT%(cn)d_VIRT2_END -when CONT%(cn)d_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_VIRT3_START CONT%(cn)d_VIRT3_END -when CONT%(cn)d_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_VIRT4_START CONT%(cn)d_VIRT4_END -when CONT%(cn)d_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_VIRT5_START CONT%(cn)d_VIRT5_END - -when CONT%(cn)d_VIRTMEM_REGIONS < 3 suppress CONT%(cn)d_VIRT2_START CONT%(cn)d_VIRT2_END -when CONT%(cn)d_VIRTMEM_REGIONS < 3 suppress CONT%(cn)d_VIRT3_START CONT%(cn)d_VIRT3_END -when CONT%(cn)d_VIRTMEM_REGIONS < 3 suppress CONT%(cn)d_VIRT4_START CONT%(cn)d_VIRT4_END -when CONT%(cn)d_VIRTMEM_REGIONS < 3 suppress CONT%(cn)d_VIRT5_START CONT%(cn)d_VIRT5_END - -when CONT%(cn)d_VIRTMEM_REGIONS < 4 suppress CONT%(cn)d_VIRT3_START CONT%(cn)d_VIRT3_END -when CONT%(cn)d_VIRTMEM_REGIONS < 4 suppress CONT%(cn)d_VIRT4_START CONT%(cn)d_VIRT4_END -when CONT%(cn)d_VIRTMEM_REGIONS < 4 suppress CONT%(cn)d_VIRT5_START CONT%(cn)d_VIRT5_END - -when CONT%(cn)d_VIRTMEM_REGIONS < 5 suppress CONT%(cn)d_VIRT4_START CONT%(cn)d_VIRT4_END -when CONT%(cn)d_VIRTMEM_REGIONS < 5 suppress CONT%(cn)d_VIRT5_START CONT%(cn)d_VIRT5_END - -when CONT%(cn)d_VIRTMEM_REGIONS < 6 suppress CONT%(cn)d_VIRT5_START CONT%(cn)d_VIRT5_END - - -when CONT%(cn)d_PHYSMEM_REGIONS < 2 suppress CONT%(cn)d_PHYS1_START CONT%(cn)d_PHYS1_END -when CONT%(cn)d_PHYSMEM_REGIONS < 2 suppress CONT%(cn)d_PHYS2_START CONT%(cn)d_PHYS2_END -when CONT%(cn)d_PHYSMEM_REGIONS < 2 suppress CONT%(cn)d_PHYS3_START CONT%(cn)d_PHYS3_END - -when CONT%(cn)d_PHYSMEM_REGIONS < 3 suppress CONT%(cn)d_PHYS2_START CONT%(cn)d_PHYS2_END -when CONT%(cn)d_PHYSMEM_REGIONS < 3 suppress CONT%(cn)d_PHYS3_START CONT%(cn)d_PHYS3_END - -when CONT%(cn)d_PHYSMEM_REGIONS < 4 suppress CONT%(cn)d_PHYS3_START CONT%(cn)d_PHYS3_END - -# We assume kernel uses 0x0 - 0x40000 physical RAM. -# Physical Regions for containers should start after kernel. -require CONT%(cn)d_PHYS0_START >= 0x40000 -require CONT%(cn)d_PHYS1_START >= 0x40000 -require CONT%(cn)d_PHYS2_START >= 0x40000 -require CONT%(cn)d_PHYS3_START >= 0x40000 - -# TODO: We can add check for end address of physical region to be -# less than RAM SIZE, need to find out RAM SIZE? - -# Rules for Linux kernel parameters -require CONT%(cn)d_LINUX_ZRELADDR > CONT%(cn)d_LINUX_PHYS_OFFSET + 0x8000 - -# TODO: Do we want to check if PAGER_LMA/VMA lies in allocated memory regions -default CONT%(cn)d_PHYS0_START from ((%(cn)d == 0 ? 0x100000 : (0x100000 + %(cn)d * 0x1000000)) + RAM_BASE_PLAT) -default CONT%(cn)d_PHYS0_END from (CONT%(cn)d_PHYS0_START + 0xD00000) -default CONT%(cn)d_PHYS1_START from CONT%(cn)d_PHYS0_END -default CONT%(cn)d_PHYS1_END from (CONT%(cn)d_PHYS1_START + 0x100000) -default CONT%(cn)d_PHYS2_START from CONT%(cn)d_PHYS1_END -default CONT%(cn)d_PHYS2_END from (CONT%(cn)d_PHYS2_START + 0x100000) -default CONT%(cn)d_PHYS3_START from CONT%(cn)d_PHYS2_END -default CONT%(cn)d_PHYS3_END from (CONT%(cn)d_PHYS3_START + 0x100000) - -default CONT%(cn)d_VIRT0_START from (%(cn)d == 0 ? 0xa0000000 : (0xa0000000 + %(cn)d * 0x10000000)) -default CONT%(cn)d_VIRT0_END from (CONT%(cn)d_VIRT0_START + 0x10000000) -default CONT%(cn)d_VIRT1_START from (%(cn)d == 0 ? 0x80000000 : (0x80000000 + %(cn)d * 0x8000000)) -default CONT%(cn)d_VIRT1_END from (CONT%(cn)d_VIRT1_START + 0x8000000) -default CONT%(cn)d_VIRT2_START from (%(cn)d == 0 ? 0x40000000 : (0x40000000 + %(cn)d * 0x10000000)) -default CONT%(cn)d_VIRT2_END from (CONT%(cn)d_VIRT2_START + 0x10000000) -default CONT%(cn)d_VIRT3_START from (%(cn)d == 0 ? 0xf8100000 : (0xf8100000 + %(cn)d * 0x100000)) -default CONT%(cn)d_VIRT3_END from (CONT%(cn)d_VIRT3_START + 0x100000) -default CONT%(cn)d_VIRT4_START from (%(cn)d == 0 ? 0x10000000 : (0x10000000 + %(cn)d * 0x10000000)) -default CONT%(cn)d_VIRT4_END from (CONT%(cn)d_VIRT4_START + 0x10000000) -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_POSIX==y) ? "posix%(cn)d" : -((CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD==y) ? "hello_world%(cn)d" : -((CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO==y) ? "thread_demo%(cn)d" : -((CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE==y) ? "test_suite%(cn)d" : -((CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE==y) ? "uart_service%(cn)d" : -((CONT%(cn)d_BAREMETAL_PROJ_KMI_SERVICE==y) ? "kmi_service%(cn)d" : -((CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE==y) ? "timer_service%(cn)d" : "empty%(cn)d"))))))) - -when CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_default_pager_params -unless CONT%(cn)d_TYPE_POSIX==y suppress cont%(cn)d_posix_pager_params -unless CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_linux_pager_params -unless CONT%(cn)d_TYPE_BAREMETAL==y suppress cont%(cn)d_baremetal_params - -# derive symbols, for cinfo.c, depending on the type of container selected -derive CONT%(cn)d_PAGER_LOAD_ADDR from (CONT%(cn)d_TYPE_LINUX==y) ? CONT%(cn)d_LINUX_PHYS_OFFSET : CONT%(cn)d_PAGER_LMA -derive CONT%(cn)d_PAGER_VIRT_ADDR from (CONT%(cn)d_TYPE_LINUX==y) ? CONT%(cn)d_LINUX_PAGE_OFFSET : CONT%(cn)d_PAGER_VMA -derive CONT%(cn)d_START_PC_ADDR from (CONT%(cn)d_TYPE_LINUX != y) ? CONT%(cn)d_PAGER_VMA : (CONT%(cn)d_LINUX_PAGE_OFFSET + CONT%(cn)d_LINUX_ZRELADDR - CONT%(cn)d_LINUX_PHYS_OFFSET) - -symbols -cont%(cn)d_menu 'Container %(cn)d Parameters' -cont%(cn)d_physmem_list 'Container %(cn)d Physical Memory Regions (Capabilities)' -cont%(cn)d_virtmem_list 'Container %(cn)d Virtual Memory Regions (Capabilities)' -cont%(cn)d_device_list 'Container %(cn)d Devices (Capabilities)' -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_default_pager_params 'Container %(cn)d Default Pager Parameters' -cont%(cn)d_posix_pager_params 'Container %(cn)d POSIX Pager Parameters' - -cont%(cn)d_baremetal_params 'Baremetal Project' -CONT%(cn)d_BAREMETAL_PROJ_EMPTY 'Empty Project' -CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD 'Hello World' -CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO 'Thread Library Demo' -CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE 'Microkernel Tests' -CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE 'UART Service' -CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE 'Timer Service' -CONT%(cn)d_BAREMETAL_PROJ_KMI_SERVICE 'Keyboard Mouse Service' - -choices cont%(cn)d_baremetal_params - CONT%(cn)d_BAREMETAL_PROJ_EMPTY - CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD - CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO - CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE - CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE - CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE - CONT%(cn)d_BAREMETAL_PROJ_KMI_SERVICE - default CONT%(cn)d_BAREMETAL_PROJ_EMPTY - -menu cont%(cn)d_default_pager_params - CONT%(cn)d_PAGER_LMA@ - CONT%(cn)d_PAGER_VMA@ - -menu cont%(cn)d_posix_pager_params - CONT%(cn)d_PAGER_SHM_START@ - CONT%(cn)d_PAGER_SHM_END@ - CONT%(cn)d_PAGER_TASK_START@ - CONT%(cn)d_PAGER_TASK_END@ - CONT%(cn)d_PAGER_UTCB_START@ - CONT%(cn)d_PAGER_UTCB_END@ - -menu cont%(cn)d_linux_pager_params - CONT%(cn)d_LINUX_PHYS_OFFSET@ - CONT%(cn)d_LINUX_ZRELADDR@ - CONT%(cn)d_LINUX_ROOTFS_ADDRESS@ - CONT%(cn)d_LINUX_PAGE_OFFSET@ - -menu cont%(cn)d_virtmem_list - CONT%(cn)d_VIRTMEM_REGIONS% - CONT%(cn)d_VIRT0_START@ - CONT%(cn)d_VIRT0_END@ - CONT%(cn)d_VIRT1_START@ - CONT%(cn)d_VIRT1_END@ - CONT%(cn)d_VIRT2_START@ - CONT%(cn)d_VIRT2_END@ - CONT%(cn)d_VIRT3_START@ - CONT%(cn)d_VIRT3_END@ - CONT%(cn)d_VIRT4_START@ - CONT%(cn)d_VIRT4_END@ - CONT%(cn)d_VIRT5_START@ - CONT%(cn)d_VIRT5_END@ - -menu cont%(cn)d_physmem_list - CONT%(cn)d_PHYSMEM_REGIONS% - CONT%(cn)d_PHYS0_START@ - CONT%(cn)d_PHYS0_END@ - CONT%(cn)d_PHYS1_START@ - CONT%(cn)d_PHYS1_END@ - CONT%(cn)d_PHYS2_START@ - CONT%(cn)d_PHYS2_END@ - CONT%(cn)d_PHYS3_START@ - CONT%(cn)d_PHYS3_END@ - -# -# Device menu and options per container -# -# FIXME: All this is to be moved to a per-platform description file. -# -symbols -cont%(cn)d_cap_device_uart1 'Container %(cn)d UART1 Menu' -cont%(cn)d_cap_device_uart2 'Container %(cn)d UART2 Menu' -cont%(cn)d_cap_device_uart3 'Container %(cn)d UART3 Menu' -cont%(cn)d_cap_device_timer1 'Container %(cn)d TIMER23 Menu' -cont%(cn)d_cap_device_keyboard0 'Container %(cn)d KEYBOARD0 Menu' -cont%(cn)d_cap_device_mouse0 'Container %(cn)d MOUSE0 Menu' -cont%(cn)d_cap_device_clcd0 'Container %(cn)d CLCD0 Menu' - -CONT%(cn)d_CAP_DEVICE_UART1_USE 'Container %(cn)d UART1 Enable' -CONT%(cn)d_CAP_DEVICE_UART2_USE 'Container %(cn)d UART2 Enable' -CONT%(cn)d_CAP_DEVICE_UART3_USE 'Container %(cn)d UART3 Enable' -CONT%(cn)d_CAP_DEVICE_TIMER1_USE 'Container %(cn)d TIMER23 Enable' -CONT%(cn)d_CAP_DEVICE_KEYBOARD0_USE 'Container %(cn)d KEYBOARD0 Enable' -CONT%(cn)d_CAP_DEVICE_MOUSE0_USE 'Container %(cn)d MOUSE0 Enable' -CONT%(cn)d_CAP_DEVICE_CLCD0_USE 'Container %(cn)d CLCD0 Enable' - -default CONT%(cn)d_CAP_DEVICE_UART1_USE from n -default CONT%(cn)d_CAP_DEVICE_UART2_USE from n -default CONT%(cn)d_CAP_DEVICE_UART3_USE from n -default CONT%(cn)d_CAP_DEVICE_TIMER1_USE from n -default CONT%(cn)d_CAP_DEVICE_KEYBOARD0_USE from n -default CONT%(cn)d_CAP_DEVICE_MOUSE0_USE from n -default CONT%(cn)d_CAP_DEVICE_CLCD0_USE from n - -menu cont%(cn)d_cap_device_uart1 - CONT%(cn)d_CAP_DEVICE_UART1_USE - -menu cont%(cn)d_cap_device_uart2 - CONT%(cn)d_CAP_DEVICE_UART2_USE - -menu cont%(cn)d_cap_device_uart3 - CONT%(cn)d_CAP_DEVICE_UART3_USE - -menu cont%(cn)d_cap_device_timer1 - CONT%(cn)d_CAP_DEVICE_TIMER1_USE - -menu cont%(cn)d_cap_device_keyboard0 - CONT%(cn)d_CAP_DEVICE_KEYBOARD0_USE - -menu cont%(cn)d_cap_device_mouse0 - CONT%(cn)d_CAP_DEVICE_MOUSE0_USE - -menu cont%(cn)d_cap_device_clcd0 - CONT%(cn)d_CAP_DEVICE_CLCD0_USE - -menu cont%(cn)d_device_list - cont%(cn)d_cap_device_uart1 - cont%(cn)d_cap_device_uart2 - cont%(cn)d_cap_device_uart3 - cont%(cn)d_cap_device_clcd0 - cont%(cn)d_cap_device_timer1 - cont%(cn)d_cap_device_keyboard0 - cont%(cn)d_cap_device_mouse0 - -# -# Settings for Custom Capabilities -# -choices cont%(cn)d_cap_custom0_type - CONT%(cn)d_CAP_CUSTOM0_IPC_TYPE - CONT%(cn)d_CAP_CUSTOM0_TCTRL_TYPE - CONT%(cn)d_CAP_CUSTOM0_EXREGS_TYPE - CONT%(cn)d_CAP_CUSTOM0_CAPCTRL_TYPE - default CONT%(cn)d_CAP_CUSTOM0_IPC_TYPE - -choices cont%(cn)d_cap_custom1_type - CONT%(cn)d_CAP_CUSTOM1_IPC_TYPE - CONT%(cn)d_CAP_CUSTOM1_TCTRL_TYPE - CONT%(cn)d_CAP_CUSTOM1_EXREGS_TYPE - CONT%(cn)d_CAP_CUSTOM1_CAPCTRL_TYPE - default CONT%(cn)d_CAP_CUSTOM1_IPC_TYPE - -choices cont%(cn)d_cap_custom2_type - CONT%(cn)d_CAP_CUSTOM2_IPC_TYPE - CONT%(cn)d_CAP_CUSTOM2_TCTRL_TYPE - CONT%(cn)d_CAP_CUSTOM2_EXREGS_TYPE - CONT%(cn)d_CAP_CUSTOM2_CAPCTRL_TYPE - default CONT%(cn)d_CAP_CUSTOM2_IPC_TYPE - -choices cont%(cn)d_cap_custom3_type - CONT%(cn)d_CAP_CUSTOM3_IPC_TYPE - CONT%(cn)d_CAP_CUSTOM3_TCTRL_TYPE - CONT%(cn)d_CAP_CUSTOM3_EXREGS_TYPE - CONT%(cn)d_CAP_CUSTOM3_CAPCTRL_TYPE - default CONT%(cn)d_CAP_CUSTOM3_IPC_TYPE - -default CONT%(cn)d_CAP_CUSTOM0_USE from n -default CONT%(cn)d_CAP_CUSTOM1_USE from n -default CONT%(cn)d_CAP_CUSTOM2_USE from n -default CONT%(cn)d_CAP_CUSTOM3_USE from n - -menu cont%(cn)d_cap_custom0 - CONT%(cn)d_CAP_CUSTOM0_USE - cont%(cn)d_cap_custom0_type - CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM0_TARGET% - -menu cont%(cn)d_cap_custom1 - CONT%(cn)d_CAP_CUSTOM1_USE - cont%(cn)d_cap_custom1_type - CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM1_TARGET% - -menu cont%(cn)d_cap_custom2 - CONT%(cn)d_CAP_CUSTOM2_USE - cont%(cn)d_cap_custom2_type - CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM2_TARGET% - -menu cont%(cn)d_cap_custom3 - CONT%(cn)d_CAP_CUSTOM3_USE - cont%(cn)d_cap_custom3_type - CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM3_TARGET% - -choicegroup CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_PAGER - default CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER from y - -choicegroup CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_PAGER - default CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER from y - -choicegroup CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_PAGER - default CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER from y - -choicegroup CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_PAGER - default CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER from y - -when CONT%(cn)d_CAP_CUSTOM0_USE == n - suppress cont%(cn)d_cap_custom0_type - CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM0_TARGET - -when CONT%(cn)d_CAP_CUSTOM1_USE == n - suppress cont%(cn)d_cap_custom1_type - CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM1_TARGET - -when CONT%(cn)d_CAP_CUSTOM2_USE == n - suppress cont%(cn)d_cap_custom2_type - CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM2_TARGET - -when CONT%(cn)d_CAP_CUSTOM3_USE == n - suppress cont%(cn)d_cap_custom3_type - CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM3_TARGET - -when CONT%(cn)d_CAP_CUSTOM0_IPC_TYPE == n - suppress CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM0_TARGET - -when CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER or - CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE - suppress CONT%(cn)d_CAP_CUSTOM0_TARGET - -when CONT%(cn)d_CAP_CUSTOM1_IPC_TYPE == n - suppress CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM1_TARGET - -when CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER or - CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE - suppress CONT%(cn)d_CAP_CUSTOM1_TARGET - -when CONT%(cn)d_CAP_CUSTOM2_IPC_TYPE == n - suppress CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM2_TARGET - -when CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER or - CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE - suppress CONT%(cn)d_CAP_CUSTOM2_TARGET - -when CONT%(cn)d_CAP_CUSTOM3_IPC_TYPE == n - suppress CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_CUSTOM3_TARGET - -when CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER or - CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE - suppress CONT%(cn)d_CAP_CUSTOM3_TARGET - -default CONT%(cn)d_CAP_CUSTOM0_TARGET from 0 -default CONT%(cn)d_CAP_CUSTOM1_TARGET from 0 -default CONT%(cn)d_CAP_CUSTOM2_TARGET from 0 -default CONT%(cn)d_CAP_CUSTOM3_TARGET from 0 - -# Symbols for Custom Capabilities -symbols -CONT%(cn)d_CAP_CUSTOM0_USE 'Enable this Capability' -cont%(cn)d_cap_custom0_type 'Capability Operation Type' -CONT%(cn)d_CAP_CUSTOM0_IPC_TYPE 'IPC Capability' -CONT%(cn)d_CAP_CUSTOM0_TCTRL_TYPE 'Thread Control Capability' -CONT%(cn)d_CAP_CUSTOM0_EXREGS_TYPE 'Exchange Registers Capability' -CONT%(cn)d_CAP_CUSTOM0_CAPCTRL_TYPE 'Capability Control Capability' -CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' -CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_CONTAINER 'Capability Targets Another Container' -CONT%(cn)d_CAP_CUSTOM0_TARGET_ANOTHER_PAGER 'Capability Targets Another Container`s Pager' -CONT%(cn)d_CAP_CUSTOM0_TARGET 'Enter Container ID' - -CONT%(cn)d_CAP_CUSTOM1_USE 'Enable this Capability' -cont%(cn)d_cap_custom1_type 'Capability Operation Type' -CONT%(cn)d_CAP_CUSTOM1_IPC_TYPE 'IPC Capability' -CONT%(cn)d_CAP_CUSTOM1_TCTRL_TYPE 'Thread Control Capability' -CONT%(cn)d_CAP_CUSTOM1_EXREGS_TYPE 'Exchange Registers Capability' -CONT%(cn)d_CAP_CUSTOM1_CAPCTRL_TYPE 'Capability Control Capability' -CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' -CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_CONTAINER 'Capability Targets Another Container' -CONT%(cn)d_CAP_CUSTOM1_TARGET_ANOTHER_PAGER 'Capability Targets Another Container`s Pager' -CONT%(cn)d_CAP_CUSTOM1_TARGET 'Enter Container ID' - -CONT%(cn)d_CAP_CUSTOM2_USE 'Enable this Capability' -cont%(cn)d_cap_custom2_type 'Capability Operation Type' -CONT%(cn)d_CAP_CUSTOM2_IPC_TYPE 'IPC Capability' -CONT%(cn)d_CAP_CUSTOM2_TCTRL_TYPE 'Thread Control Capability' -CONT%(cn)d_CAP_CUSTOM2_EXREGS_TYPE 'Exchange Registers Capability' -CONT%(cn)d_CAP_CUSTOM2_CAPCTRL_TYPE 'Capability Control Capability' -CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' -CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_CONTAINER 'Capability Targets Another Container' -CONT%(cn)d_CAP_CUSTOM2_TARGET_ANOTHER_PAGER 'Capability Targets Another Container`s Pager' -CONT%(cn)d_CAP_CUSTOM2_TARGET 'Enter Container ID' - -CONT%(cn)d_CAP_CUSTOM3_USE 'Enable this Capability' -cont%(cn)d_cap_custom3_type 'Capability Operation Type' -CONT%(cn)d_CAP_CUSTOM3_IPC_TYPE 'IPC Capability' -CONT%(cn)d_CAP_CUSTOM3_TCTRL_TYPE 'Thread Control Capability' -CONT%(cn)d_CAP_CUSTOM3_EXREGS_TYPE 'Exchange Registers Capability' -CONT%(cn)d_CAP_CUSTOM3_CAPCTRL_TYPE 'Capability Control Capability' -CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' -CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_CONTAINER 'Capability Targets Another Container' -CONT%(cn)d_CAP_CUSTOM3_TARGET_ANOTHER_PAGER 'Capability Targets Another Container`s Pager' -CONT%(cn)d_CAP_CUSTOM3_TARGET 'Enter Container ID' - - - -# Symbols for Generic Capabilities -symbols -CONT%(cn)d_CAP_TCTRL_USE 'Enable this Capability' -CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' - -CONT%(cn)d_CAP_EXREGS_USE 'Enable this Capability' -CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' - -CONT%(cn)d_CAP_IPC_USE 'Enable this Capability' -CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' -CONT%(cn)d_CAP_IPC_TARGET_ANOTHER_CONTAINER 'Capability Targets Another Container' -CONT%(cn)d_CAP_IPC_TARGET_ANOTHER_PAGER 'Capability Targets Another Container`s Pager' -CONT%(cn)d_CAP_IPC_TARGET 'Enter Container ID' - -CONT%(cn)d_CAP_CAPCTRL_USE 'Enable this Capability' -CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' - -CONT%(cn)d_CAP_IRQCTRL_USE 'Enable this Capability' -CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' - -CONT%(cn)d_CAP_UMUTEX_USE 'Enable this Capability' -CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' -CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' - - - -symbols -CONT%(cn)d_CAP_THREADPOOL_SIZE 'Number of Threads' -CONT%(cn)d_CAP_SPACEPOOL_SIZE 'Number of Address Spaces' -CONT%(cn)d_CAP_MAPPOOL_SIZE 'Number of PMD Mappings (E.g. Middle-level Page Tables)' -CONT%(cn)d_CAP_MUTEXPOOL_SIZE 'Number of Userspace Mutexes' -CONT%(cn)d_CAP_CAPPOOL_SIZE 'Number of Capabilities (Created at run-time via Split, Replicate)' -CONT%(cn)d_CAP_THREADPOOL_USE 'Enable this Capability' -CONT%(cn)d_CAP_SPACEPOOL_USE 'Enable this Capability' -CONT%(cn)d_CAP_MAPPOOL_USE 'Enable this Capability' -CONT%(cn)d_CAP_MUTEXPOOL_USE 'Enable this Capability' -CONT%(cn)d_CAP_CAPPOOL_USE 'Enable this Capability' - -cont%(cn)d_cap_threadpool 'Container %(cn)d Thread Pool Capability' -cont%(cn)d_cap_spacepool 'Container %(cn)d Space Pool Capability' -cont%(cn)d_cap_mutexpool 'Container %(cn)d Mutex Pool Capability' -cont%(cn)d_cap_mappool 'Container %(cn)d Map Pool Capability' -cont%(cn)d_cap_cappool 'Container %(cn)d Capability Pool Capability' -cont%(cn)d_cap_tctrl 'Container %(cn)d Thread Control Capability' -cont%(cn)d_cap_exregs 'Container %(cn)d Exchange Registers Capability' -cont%(cn)d_cap_ipc 'Container %(cn)d IPC Capability' -cont%(cn)d_cap_capctrl 'Container %(cn)d Capability Control Capability' -cont%(cn)d_cap_irqctrl 'Container %(cn)d IRQ Control Capability' -cont%(cn)d_cap_umutex 'Container %(cn)d Userspace Mutex Control Capability' -cont%(cn)d_cap_custom0 'Container %(cn)d Custom Capability 0 Parameters' -cont%(cn)d_cap_custom1 'Container %(cn)d Custom Capability 1 Parameters' -cont%(cn)d_cap_custom2 'Container %(cn)d Custom Capability 2 Parameters' -cont%(cn)d_cap_custom3 'Container %(cn)d Custom Capability 3 Parameters' - -cont%(cn)d_capability_list 'Container %(cn)d Capability List' - -default CONT%(cn)d_CAP_THREADPOOL_SIZE from 64 -default CONT%(cn)d_CAP_SPACEPOOL_SIZE from 64 -default CONT%(cn)d_CAP_MAPPOOL_SIZE from 800 -default CONT%(cn)d_CAP_MUTEXPOOL_SIZE from 100 -default CONT%(cn)d_CAP_CAPPOOL_SIZE from 32 - -default CONT%(cn)d_CAP_THREADPOOL_USE from y -default CONT%(cn)d_CAP_SPACEPOOL_USE from y -default CONT%(cn)d_CAP_MAPPOOL_USE from y -default CONT%(cn)d_CAP_MUTEXPOOL_USE from y -default CONT%(cn)d_CAP_CAPPOOL_USE from y - -# Use Rules for Generic Capabilities -when CONT%(cn)d_CAP_THREADPOOL_USE == n - suppress CONT%(cn)d_CAP_THREADPOOL_SIZE -when CONT%(cn)d_CAP_SPACEPOOL_USE == n - suppress CONT%(cn)d_CAP_SPACEPOOL_SIZE -when CONT%(cn)d_CAP_MAPPOOL_USE == n - suppress CONT%(cn)d_CAP_MAPPOOL_SIZE -when CONT%(cn)d_CAP_MUTEXPOOL_USE == n - suppress CONT%(cn)d_CAP_MUTEXPOOL_SIZE -when CONT%(cn)d_CAP_CAPPOOL_USE == n - suppress CONT%(cn)d_CAP_CAPPOOL_SIZE - -when CONT%(cn)d_CAP_IPC_USE == n - suppress CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_IPC_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_IPC_TARGET_ANOTHER_PAGER - -when CONT%(cn)d_CAP_EXREGS_USE == n - suppress CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE - -when CONT%(cn)d_CAP_TCTRL_USE == n - suppress CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE - -when CONT%(cn)d_CAP_CAPCTRL_USE == n - suppress CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE - -when CONT%(cn)d_CAP_IRQCTRL_USE == n - suppress CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE - -when CONT%(cn)d_CAP_UMUTEX_USE == n - suppress CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE - -when CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER or - CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE - suppress CONT%(cn)d_CAP_IPC_TARGET - -choicegroup CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_IPC_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_IPC_TARGET_ANOTHER_PAGER - default CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER from y - -choicegroup CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE - default CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_CONTAINER from y - -choicegroup CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE - default CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_CONTAINER from y - -choicegroup CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE - default CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER from y - -choicegroup CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE - default CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER from y - -choicegroup CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE - default CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER from y - -default CONT%(cn)d_CAP_TCTRL_USE from y -default CONT%(cn)d_CAP_EXREGS_USE from y -default CONT%(cn)d_CAP_IPC_USE from y -default CONT%(cn)d_CAP_CAPCTRL_USE from y -default CONT%(cn)d_CAP_IRQCTRL_USE from y -default CONT%(cn)d_CAP_UMUTEX_USE from y - -default CONT%(cn)d_CAP_IPC_TARGET from 0 - -# Capability Menus -menu cont%(cn)d_cap_tctrl - CONT%(cn)d_CAP_TCTRL_USE - CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE - -menu cont%(cn)d_cap_exregs - CONT%(cn)d_CAP_EXREGS_USE - CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE - -menu cont%(cn)d_cap_capctrl - CONT%(cn)d_CAP_CAPCTRL_USE - CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE - -menu cont%(cn)d_cap_umutex - CONT%(cn)d_CAP_UMUTEX_USE - CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE - -menu cont%(cn)d_cap_irqctrl - CONT%(cn)d_CAP_IRQCTRL_USE - CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE - -menu cont%(cn)d_cap_ipc - CONT%(cn)d_CAP_IPC_USE - CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER - CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE - CONT%(cn)d_CAP_IPC_TARGET_ANOTHER_CONTAINER - CONT%(cn)d_CAP_IPC_TARGET_ANOTHER_PAGER - CONT%(cn)d_CAP_IPC_TARGET% - -menu cont%(cn)d_cap_threadpool - CONT%(cn)d_CAP_THREADPOOL_USE - CONT%(cn)d_CAP_THREADPOOL_SIZE% - -menu cont%(cn)d_cap_spacepool - CONT%(cn)d_CAP_SPACEPOOL_USE - CONT%(cn)d_CAP_SPACEPOOL_SIZE% - -menu cont%(cn)d_cap_mappool - CONT%(cn)d_CAP_MAPPOOL_USE - CONT%(cn)d_CAP_MAPPOOL_SIZE% - -menu cont%(cn)d_cap_mutexpool - CONT%(cn)d_CAP_MUTEXPOOL_USE - CONT%(cn)d_CAP_MUTEXPOOL_SIZE% - -menu cont%(cn)d_cap_cappool - CONT%(cn)d_CAP_CAPPOOL_USE - CONT%(cn)d_CAP_CAPPOOL_SIZE% - -menu cont%(cn)d_capability_list - cont%(cn)d_cap_threadpool - cont%(cn)d_cap_spacepool - cont%(cn)d_cap_mutexpool - cont%(cn)d_cap_mappool - cont%(cn)d_cap_cappool - cont%(cn)d_cap_tctrl - cont%(cn)d_cap_exregs - cont%(cn)d_cap_ipc - cont%(cn)d_cap_capctrl - cont%(cn)d_cap_umutex - cont%(cn)d_cap_irqctrl - cont%(cn)d_cap_custom0 - cont%(cn)d_cap_custom1 - cont%(cn)d_cap_custom2 - cont%(cn)d_cap_custom3 - -menu container%(cn)d_options - CONT%(cn)d_OPT_NAME$ - cont%(cn)d_baremetal_params - cont%(cn)d_linux_pager_params - cont%(cn)d_default_pager_params - cont%(cn)d_posix_pager_params - cont%(cn)d_physmem_list - cont%(cn)d_virtmem_list - cont%(cn)d_capability_list - cont%(cn)d_device_list - -choices container%(cn)d_type - CONT%(cn)d_TYPE_BAREMETAL - CONT%(cn)d_TYPE_POSIX - CONT%(cn)d_TYPE_LINUX - default CONT%(cn)d_TYPE_BAREMETAL - -menu cont%(cn)d_menu - container%(cn)d_type - container%(cn)d_options diff --git a/config/cml/examples/linux/config.cml b/config/cml/examples/linux/config.cml deleted file mode 100644 index dc756db..0000000 --- a/config/cml/examples/linux/config.cml +++ /dev/null @@ -1,271 +0,0 @@ -# -# Automatically generated, don't edit -# -# Generated on: amit-laptop -# At: Fri, 04 Dec 2009 05:32:36 +0000 -# Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 - -# -# 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_PB926=y - - - - -# -# Toolchain Prefix -# -CONFIG_TOOLCHAIN_KERNEL="arm-none-eabi-" -CONFIG_TOOLCHAIN_USER="arm-none-linux-gnueabi-" - -CONFIG_CONTAINERS=1 - -# -# Container Setup -# -CONFIG_CAPABILITIES=y - -# -# Container 0 Parameters -# - -# -# Container 0 Type -# -CONFIG_CONT0_TYPE_BAREMETAL=n -CONFIG_CONT0_TYPE_POSIX=n -CONFIG_CONT0_TYPE_LINUX=y - - -# -# Container 0 Options -# -CONFIG_CONT0_OPT_NAME="linux0" - -# -# Container 0 Linux Pager Parameters -# -CONFIG_CONT0_LINUX_PHYS_OFFSET=0x100000 -CONFIG_CONT0_LINUX_ZRELADDR=0x108000 -CONFIG_CONT0_LINUX_ROOTFS_ADDRESS=0x600000 -CONFIG_CONT0_LINUX_PAGE_OFFSET=0xa0000000 - - -# -# Container 0 Physical Memory Regions (Capabilities) -# -CONFIG_CONT0_PHYSMEM_REGIONS=1 -CONFIG_CONT0_PHYS0_START=0x100000 -CONFIG_CONT0_PHYS0_END=0xe00000 - - -# -# Container 0 Virtual Memory Regions (Capabilities) -# -CONFIG_CONT0_VIRTMEM_REGIONS=1 -CONFIG_CONT0_VIRT0_START=0xa0000000 -CONFIG_CONT0_VIRT0_END=0xb0000000 - - -# -# Container 0 Capability List -# - -# -# Container 0 Thread Pool Capability -# -CONFIG_CONT0_CAP_THREADPOOL_USE=y -CONFIG_CONT0_CAP_THREADPOOL_SIZE=64 - - -# -# Container 0 Space Pool Capability -# -CONFIG_CONT0_CAP_SPACEPOOL_USE=y -CONFIG_CONT0_CAP_SPACEPOOL_SIZE=64 - - -# -# Container 0 Mutex Pool Capability -# -CONFIG_CONT0_CAP_MUTEXPOOL_USE=y -CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100 - - -# -# Container 0 Map Pool Capability -# -CONFIG_CONT0_CAP_MAPPOOL_USE=y -CONFIG_CONT0_CAP_MAPPOOL_SIZE=800 - - -# -# Container 0 Capability Pool Capability -# -CONFIG_CONT0_CAP_CAPPOOL_USE=y -CONFIG_CONT0_CAP_CAPPOOL_SIZE=32 - - -# -# Container 0 Thread Control Capability -# -CONFIG_CONT0_CAP_TCTRL_USE=y -CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Exchange Registers Capability -# -CONFIG_CONT0_CAP_EXREGS_USE=y -CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 IPC Capability -# -CONFIG_CONT0_CAP_IPC_USE=y -CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n -CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_CONTAINER=n -CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_PAGER=n - - -# -# Container 0 Capability Control Capability -# -CONFIG_CONT0_CAP_CAPCTRL_USE=y -CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Userspace Mutex Control Capability -# -CONFIG_CONT0_CAP_UMUTEX_USE=y -CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Custom Capability 0 Parameters -# -CONFIG_CONT0_CAP_CUSTOM0_USE=n - - -# -# Container 0 Custom Capability 1 Parameters -# -CONFIG_CONT0_CAP_CUSTOM1_USE=n - - -# -# Container 0 Custom Capability 2 Parameters -# -CONFIG_CONT0_CAP_CUSTOM2_USE=n - - -# -# Container 0 Custom Capability 3 Parameters -# -CONFIG_CONT0_CAP_CUSTOM3_USE=n - - - -# -# Container 0 Devices (Capabilities) -# - -# -# Container 0 UART1 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART1_USE=n - - -# -# Container 0 UART2 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART2_USE=n - - -# -# Container 0 UART3 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART3_USE=n - - -# -# Container 0 TIMER23 Menu -# -CONFIG_CONT0_CAP_DEVICE_TIMER1_USE=n - - - - - - -# -# Derived symbols -# -CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000 -CONFIG_DRIVER_IRQ_PL190=y -CONFIG_DRIVER_TIMER_SP804=y -CONFIG_CONT2_START_PC_ADDR=0xc0000000 -CONFIG_CONT3_START_PC_ADDR=0xd0000000 -CONFIG_DRIVER_IRQ_GIC=n -CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000 -CONFIG_baremetal2="baremetal_noname2" -CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000 -CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000 -CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000 -CONFIG_CONT0_PAGER_LOAD_ADDR=0x100000 -CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000 -CONFIG_baremetal1="baremetal_noname1" -CONFIG_baremetal0="empty0" -CONFIG_baremetal3="baremetal_noname3" -CONFIG_DRIVER_UART_PL011=y -CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000 -CONFIG_CONT0_START_PC_ADDR=0xa0008000 -CONFIG_CONT1_START_PC_ADDR=0xb0000000 -# -# That's all, folks! diff --git a/config/cml/examples/posix/single_posix.cml b/config/cml/examples/posix/single_posix.cml deleted file mode 100644 index 5e1e4fd..0000000 --- a/config/cml/examples/posix/single_posix.cml +++ /dev/null @@ -1,285 +0,0 @@ -# -# Automatically generated, don't edit -# -# Generated on: amit-laptop -# At: Fri, 04 Dec 2009 05:37:15 +0000 -# Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 - -# -# 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_PB926=y - - - - -# -# Toolchain Prefix -# -CONFIG_TOOLCHAIN="arm-none-eabi-" - -CONFIG_CONTAINERS=1 - -# -# Container Setup -# -CONFIG_CAPABILITIES=y - -# -# Container 0 Parameters -# - -# -# Container 0 Type -# -CONFIG_CONT0_TYPE_BAREMETAL=n -CONFIG_CONT0_TYPE_POSIX=y -CONFIG_CONT0_TYPE_LINUX=n - - -# -# Container 0 Options -# -CONFIG_CONT0_OPT_NAME="posix0" - -# -# Container 0 Default Pager Parameters -# -CONFIG_CONT0_PAGER_LMA=0x100000 -CONFIG_CONT0_PAGER_VMA=0xa0000000 - - -# -# Container 0 POSIX Pager Parameters -# -CONFIG_CONT0_PAGER_SHM_START=0x80000000 -CONFIG_CONT0_PAGER_SHM_END=0x88000000 -CONFIG_CONT0_PAGER_TASK_START=0x40000000 -CONFIG_CONT0_PAGER_TASK_END=0x50000000 -CONFIG_CONT0_PAGER_UTCB_START=0xf8100000 -CONFIG_CONT0_PAGER_UTCB_END=0xf8200000 - - -# -# Container 0 Physical Memory Regions (Capabilities) -# -CONFIG_CONT0_PHYSMEM_REGIONS=1 -CONFIG_CONT0_PHYS0_START=0x100000 -CONFIG_CONT0_PHYS0_END=0xe00000 - - -# -# Container 0 Virtual Memory Regions (Capabilities) -# -CONFIG_CONT0_VIRTMEM_REGIONS=4 -CONFIG_CONT0_VIRT0_START=0xa0000000 -CONFIG_CONT0_VIRT0_END=0xb0000000 -CONFIG_CONT0_VIRT1_START=0x80000000 -CONFIG_CONT0_VIRT1_END=0x88000000 -CONFIG_CONT0_VIRT2_START=0x40000000 -CONFIG_CONT0_VIRT2_END=0x50000000 -CONFIG_CONT0_VIRT3_START=0xf8100000 -CONFIG_CONT0_VIRT3_END=0xf8200000 - - -# -# Container 0 Capability List -# - -# -# Container 0 Thread Pool Capability -# -CONFIG_CONT0_CAP_THREADPOOL_USE=y -CONFIG_CONT0_CAP_THREADPOOL_SIZE=64 - - -# -# Container 0 Space Pool Capability -# -CONFIG_CONT0_CAP_SPACEPOOL_USE=y -CONFIG_CONT0_CAP_SPACEPOOL_SIZE=64 - - -# -# Container 0 Mutex Pool Capability -# -CONFIG_CONT0_CAP_MUTEXPOOL_USE=y -CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100 - - -# -# Container 0 Map Pool Capability -# -CONFIG_CONT0_CAP_MAPPOOL_USE=y -CONFIG_CONT0_CAP_MAPPOOL_SIZE=800 - - -# -# Container 0 Capability Pool Capability -# -CONFIG_CONT0_CAP_CAPPOOL_USE=y -CONFIG_CONT0_CAP_CAPPOOL_SIZE=32 - - -# -# Container 0 Thread Control Capability -# -CONFIG_CONT0_CAP_TCTRL_USE=y -CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Exchange Registers Capability -# -CONFIG_CONT0_CAP_EXREGS_USE=y -CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 IPC Capability -# -CONFIG_CONT0_CAP_IPC_USE=y -CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n -CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_CONTAINER=n -CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_PAGER=n - - -# -# Container 0 Capability Control Capability -# -CONFIG_CONT0_CAP_CAPCTRL_USE=y -CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Userspace Mutex Control Capability -# -CONFIG_CONT0_CAP_UMUTEX_USE=y -CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Custom Capability 0 Parameters -# -CONFIG_CONT0_CAP_CUSTOM0_USE=n - - -# -# Container 0 Custom Capability 1 Parameters -# -CONFIG_CONT0_CAP_CUSTOM1_USE=n - - -# -# Container 0 Custom Capability 2 Parameters -# -CONFIG_CONT0_CAP_CUSTOM2_USE=n - - -# -# Container 0 Custom Capability 3 Parameters -# -CONFIG_CONT0_CAP_CUSTOM3_USE=n - - - -# -# Container 0 Devices (Capabilities) -# - -# -# Container 0 UART1 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART1_USE=n - - -# -# Container 0 UART2 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART2_USE=n - - -# -# Container 0 UART3 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART3_USE=n - - -# -# Container 0 TIMER23 Menu -# -CONFIG_CONT0_CAP_DEVICE_TIMER1_USE=n - - - - - - -# -# Derived symbols -# -CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000 -CONFIG_DRIVER_IRQ_PL190=y -CONFIG_DRIVER_TIMER_SP804=y -CONFIG_CONT2_START_PC_ADDR=0xc0000000 -CONFIG_CONT3_START_PC_ADDR=0xd0000000 -CONFIG_DRIVER_IRQ_GIC=n -CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000 -CONFIG_baremetal2="baremetal_noname2" -CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000 -CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000 -CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000 -CONFIG_CONT0_PAGER_LOAD_ADDR=0x100000 -CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000 -CONFIG_baremetal1="baremetal_noname1" -CONFIG_baremetal0="empty0" -CONFIG_baremetal3="baremetal_noname3" -CONFIG_DRIVER_UART_PL011=y -CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000 -CONFIG_CONT0_START_PC_ADDR=0xa0000000 -CONFIG_CONT1_START_PC_ADDR=0xb0000000 -# -# That's all, folks! diff --git a/config/cml/examples/posix/two_posix.cml b/config/cml/examples/posix/two_posix.cml deleted file mode 100644 index a6c5bf4..0000000 --- a/config/cml/examples/posix/two_posix.cml +++ /dev/null @@ -1,479 +0,0 @@ -# -# Automatically generated, don't edit -# -# Generated on: amit-laptop -# At: Fri, 04 Dec 2009 05:19:22 +0000 -# Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 - -# -# 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_PB926=y - - - - -# -# Toolchain Prefix -# -CONFIG_TOOLCHAIN="arm-none-eabi-" - -CONFIG_CONTAINERS=2 - -# -# Container Setup -# -CONFIG_CAPABILITIES=y - -# -# Container 0 Parameters -# - -# -# Container 0 Type -# -CONFIG_CONT0_TYPE_BAREMETAL=n -CONFIG_CONT0_TYPE_POSIX=y -CONFIG_CONT0_TYPE_LINUX=n - - -# -# Container 0 Options -# -CONFIG_CONT0_OPT_NAME="posix0" - -# -# Container 0 Default Pager Parameters -# -CONFIG_CONT0_PAGER_LMA=0x100000 -CONFIG_CONT0_PAGER_VMA=0xa0000000 - - -# -# Container 0 POSIX Pager Parameters -# -CONFIG_CONT0_PAGER_SHM_START=0x80000000 -CONFIG_CONT0_PAGER_SHM_END=0x88000000 -CONFIG_CONT0_PAGER_TASK_START=0x40000000 -CONFIG_CONT0_PAGER_TASK_END=0x50000000 -CONFIG_CONT0_PAGER_UTCB_START=0xf8100000 -CONFIG_CONT0_PAGER_UTCB_END=0xf8200000 - - -# -# Container 0 Physical Memory Regions (Capabilities) -# -CONFIG_CONT0_PHYSMEM_REGIONS=1 -CONFIG_CONT0_PHYS0_START=0x100000 -CONFIG_CONT0_PHYS0_END=0xe00000 - - -# -# Container 0 Virtual Memory Regions (Capabilities) -# -CONFIG_CONT0_VIRTMEM_REGIONS=4 -CONFIG_CONT0_VIRT0_START=0xa0000000 -CONFIG_CONT0_VIRT0_END=0xb0000000 -CONFIG_CONT0_VIRT1_START=0x80000000 -CONFIG_CONT0_VIRT1_END=0x88000000 -CONFIG_CONT0_VIRT2_START=0x40000000 -CONFIG_CONT0_VIRT2_END=0x50000000 -CONFIG_CONT0_VIRT3_START=0xf8100000 -CONFIG_CONT0_VIRT3_END=0xf8200000 - - -# -# Container 0 Capability List -# - -# -# Container 0 Thread Pool Capability -# -CONFIG_CONT0_CAP_THREADPOOL_USE=y -CONFIG_CONT0_CAP_THREADPOOL_SIZE=64 - - -# -# Container 0 Space Pool Capability -# -CONFIG_CONT0_CAP_SPACEPOOL_USE=y -CONFIG_CONT0_CAP_SPACEPOOL_SIZE=64 - - -# -# Container 0 Mutex Pool Capability -# -CONFIG_CONT0_CAP_MUTEXPOOL_USE=y -CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100 - - -# -# Container 0 Map Pool Capability -# -CONFIG_CONT0_CAP_MAPPOOL_USE=y -CONFIG_CONT0_CAP_MAPPOOL_SIZE=800 - - -# -# Container 0 Capability Pool Capability -# -CONFIG_CONT0_CAP_CAPPOOL_USE=y -CONFIG_CONT0_CAP_CAPPOOL_SIZE=32 - - -# -# Container 0 Thread Control Capability -# -CONFIG_CONT0_CAP_TCTRL_USE=y -CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Exchange Registers Capability -# -CONFIG_CONT0_CAP_EXREGS_USE=y -CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 IPC Capability -# -CONFIG_CONT0_CAP_IPC_USE=y -CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n -CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_CONTAINER=n -CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_PAGER=n - - -# -# Container 0 Capability Control Capability -# -CONFIG_CONT0_CAP_CAPCTRL_USE=y -CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Userspace Mutex Control Capability -# -CONFIG_CONT0_CAP_UMUTEX_USE=y -CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 0 Custom Capability 0 Parameters -# -CONFIG_CONT0_CAP_CUSTOM0_USE=n - - -# -# Container 0 Custom Capability 1 Parameters -# -CONFIG_CONT0_CAP_CUSTOM1_USE=n - - -# -# Container 0 Custom Capability 2 Parameters -# -CONFIG_CONT0_CAP_CUSTOM2_USE=n - - -# -# Container 0 Custom Capability 3 Parameters -# -CONFIG_CONT0_CAP_CUSTOM3_USE=n - - - -# -# Container 0 Devices (Capabilities) -# - -# -# Container 0 UART1 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART1_USE=n - - -# -# Container 0 UART2 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART2_USE=n - - -# -# Container 0 UART3 Menu -# -CONFIG_CONT0_CAP_DEVICE_UART3_USE=n - - -# -# Container 0 TIMER23 Menu -# -CONFIG_CONT0_CAP_DEVICE_TIMER1_USE=n - - - - - -# -# Container 1 Parameters -# - -# -# Container 1 Type -# -CONFIG_CONT1_TYPE_BAREMETAL=n -CONFIG_CONT1_TYPE_POSIX=y -CONFIG_CONT1_TYPE_LINUX=n - - -# -# Container 1 Options -# -CONFIG_CONT1_OPT_NAME="posix1" - -# -# Container 1 Default Pager Parameters -# -CONFIG_CONT1_PAGER_LMA=0x1100000 -CONFIG_CONT1_PAGER_VMA=0xb0000000 - - -# -# Container 1 POSIX Pager Parameters -# -CONFIG_CONT1_PAGER_SHM_START=0x88000000 -CONFIG_CONT1_PAGER_SHM_END=0x90000000 -CONFIG_CONT1_PAGER_TASK_START=0x50000000 -CONFIG_CONT1_PAGER_TASK_END=0x60000000 -CONFIG_CONT1_PAGER_UTCB_START=0xf8200000 -CONFIG_CONT1_PAGER_UTCB_END=0xf8300000 - - -# -# Container 1 Physical Memory Regions (Capabilities) -# -CONFIG_CONT1_PHYSMEM_REGIONS=1 -CONFIG_CONT1_PHYS0_START=0x1100000 -CONFIG_CONT1_PHYS0_END=0x1e00000 - - -# -# Container 1 Virtual Memory Regions (Capabilities) -# -CONFIG_CONT1_VIRTMEM_REGIONS=4 -CONFIG_CONT1_VIRT0_START=0xb0000000 -CONFIG_CONT1_VIRT0_END=0xc0000000 -CONFIG_CONT1_VIRT1_START=0x88000000 -CONFIG_CONT1_VIRT1_END=0x90000000 -CONFIG_CONT1_VIRT2_START=0x50000000 -CONFIG_CONT1_VIRT2_END=0x60000000 -CONFIG_CONT1_VIRT3_START=0xf8200000 -CONFIG_CONT1_VIRT3_END=0xf8300000 - - -# -# Container 1 Capability List -# - -# -# Container 1 Thread Pool Capability -# -CONFIG_CONT1_CAP_THREADPOOL_USE=y -CONFIG_CONT1_CAP_THREADPOOL_SIZE=64 - - -# -# Container 1 Space Pool Capability -# -CONFIG_CONT1_CAP_SPACEPOOL_USE=y -CONFIG_CONT1_CAP_SPACEPOOL_SIZE=64 - - -# -# Container 1 Mutex Pool Capability -# -CONFIG_CONT1_CAP_MUTEXPOOL_USE=y -CONFIG_CONT1_CAP_MUTEXPOOL_SIZE=100 - - -# -# Container 1 Map Pool Capability -# -CONFIG_CONT1_CAP_MAPPOOL_USE=y -CONFIG_CONT1_CAP_MAPPOOL_SIZE=800 - - -# -# Container 1 Capability Pool Capability -# -CONFIG_CONT1_CAP_CAPPOOL_USE=y -CONFIG_CONT1_CAP_CAPPOOL_SIZE=32 - - -# -# Container 1 Thread Control Capability -# -CONFIG_CONT1_CAP_TCTRL_USE=y -CONFIG_CONT1_CAP_TCTRL_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT1_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 1 Exchange Registers Capability -# -CONFIG_CONT1_CAP_EXREGS_USE=y -CONFIG_CONT1_CAP_EXREGS_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT1_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 1 IPC Capability -# -CONFIG_CONT1_CAP_IPC_USE=y -CONFIG_CONT1_CAP_IPC_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT1_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n -CONFIG_CONT1_CAP_IPC_TARGET_ANOTHER_CONTAINER=n -CONFIG_CONT1_CAP_IPC_TARGET_ANOTHER_PAGER=n - - -# -# Container 1 Capability Control Capability -# -CONFIG_CONT1_CAP_CAPCTRL_USE=y -CONFIG_CONT1_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT1_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 1 Userspace Mutex Control Capability -# -CONFIG_CONT1_CAP_UMUTEX_USE=y -CONFIG_CONT1_CAP_UMUTEX_TARGET_CURRENT_CONTAINER=y -CONFIG_CONT1_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE=n - - -# -# Container 1 Custom Capability 0 Parameters -# -CONFIG_CONT1_CAP_CUSTOM0_USE=n - - -# -# Container 1 Custom Capability 1 Parameters -# -CONFIG_CONT1_CAP_CUSTOM1_USE=n - - -# -# Container 1 Custom Capability 2 Parameters -# -CONFIG_CONT1_CAP_CUSTOM2_USE=n - - -# -# Container 1 Custom Capability 3 Parameters -# -CONFIG_CONT1_CAP_CUSTOM3_USE=n - - - -# -# Container 1 Devices (Capabilities) -# - -# -# Container 1 UART1 Menu -# -CONFIG_CONT1_CAP_DEVICE_UART1_USE=n - - -# -# Container 1 UART2 Menu -# -CONFIG_CONT1_CAP_DEVICE_UART2_USE=n - - -# -# Container 1 UART3 Menu -# -CONFIG_CONT1_CAP_DEVICE_UART3_USE=n - - -# -# Container 1 TIMER23 Menu -# -CONFIG_CONT1_CAP_DEVICE_TIMER1_USE=n - - - - - - -# -# Derived symbols -# -CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000 -CONFIG_DRIVER_IRQ_PL190=y -CONFIG_DRIVER_TIMER_SP804=y -CONFIG_CONT2_START_PC_ADDR=0xc0000000 -CONFIG_CONT3_START_PC_ADDR=0xd0000000 -CONFIG_DRIVER_IRQ_GIC=n -CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000 -CONFIG_baremetal2="baremetal_noname2" -CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000 -CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000 -CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000 -CONFIG_CONT0_PAGER_LOAD_ADDR=0x100000 -CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000 -CONFIG_baremetal1="empty1" -CONFIG_baremetal0="empty0" -CONFIG_baremetal3="baremetal_noname3" -CONFIG_DRIVER_UART_PL011=y -CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000 -CONFIG_CONT0_START_PC_ADDR=0xa0000000 -CONFIG_CONT1_START_PC_ADDR=0xb0000000 -# -# That's all, folks! diff --git a/config/projpaths.py b/config/projpaths.py deleted file mode 100644 index dee7596..0000000 --- a/config/projpaths.py +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env python2.6 -# -*- mode: python; coding: utf-8; -*- - -import os, sys, shelve, shutil -from os.path import join - -# Way to get project root from any script importing this one :-) -PROJROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) - -BUILDDIR = join(PROJROOT, "build") -TOOLSDIR = join(PROJROOT, "tools") -CML2_CONFIG_SRCDIR = join(PROJROOT, "config/cml") -CML2_CONT_DEFFILE = join(PROJROOT, 'config/cml/container_ruleset.template') -CML2TOOLSDIR = join(TOOLSDIR, "cml2-tools") -CML2_COMPILED_RULES = join(BUILDDIR, "rules.compiled") -CML2_CONFIG_FILE = join(BUILDDIR, "config.cml") -CML2_CONFIG_FILE_SAVED = join(BUILDDIR, "config.cml.saved") -CML2_CONFIG_H = join(BUILDDIR, "config.h") -CML2_AUTOGEN_RULES = join(BUILDDIR, 'config.rules') -CONFIG_H = join("include/l4/config.h") -CONFIG_SHELVE_DIR = join(BUILDDIR, "configdata") -CONFIG_SHELVE_FILENAME = "configuration" -CONFIG_SHELVE = join(CONFIG_SHELVE_DIR, CONFIG_SHELVE_FILENAME) -KERNEL_CINFO_PATH = join(PROJROOT, "src/generic/cinfo.c") -LINUXDIR = join(PROJROOT, 'conts/linux') -LINUX_KERNELDIR = join(LINUXDIR, 'linux-2.6.33') -LINUX_ROOTFSDIR = join(LINUXDIR, 'rootfs') -LINUX_ATAGSDIR = join(LINUXDIR, 'atags') - -POSIXDIR = join(PROJROOT, 'conts/posix') -POSIX_BOOTDESCDIR = join(POSIXDIR, 'bootdesc') - -projpaths = { \ - 'LINUX_ATAGSDIR' : LINUX_ATAGSDIR, \ - 'LINUX_ROOTFSDIR' : LINUX_ROOTFSDIR, \ - 'LINUX_KERNELDIR' : LINUX_KERNELDIR, \ - 'LINUXDIR' : LINUXDIR, \ - 'BUILDDIR' : BUILDDIR, \ - 'POSIXDIR' : POSIXDIR, \ - 'POSIX_BOOTDESCDIR' : POSIX_BOOTDESCDIR -} diff --git a/conts/baremetal/empty/SConscript b/conts/baremetal/empty/SConscript new file mode 100644 index 0000000..062d7f2 --- /dev/null +++ b/conts/baremetal/empty/SConscript @@ -0,0 +1,11 @@ + +# Inherit global environment +Import('env') + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/empty/SConstruct b/conts/baremetal/empty/SConstruct index 6b408f3..b70d69a 100644 --- a/conts/baremetal/empty/SConstruct +++ b/conts/baremetal/empty/SConstruct @@ -7,60 +7,49 @@ import os, shelve, sys from os.path import * -PROJRELROOT = '../..' +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.conts.containers import * +from scripts.config.configuration import * config = configuration_retrieve() -platform = config.platform -arch = config.arch gcc_arch_flag = config.gcc_arch_flag -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) +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) -# 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)] +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) -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')] - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], - 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', \ - 'libmm', 'libmc', 'libmalloc','c-userspace'], # libgcc.a - This is required for division routines. - CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, \ - LIBC_INCLUDE, LIBMEM_INCLUDE], - LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + linker_lds, '-u_start'], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + # libgcc.a - This is required for division routines. + LIBS = ['gcc', 'libl4', 'c-userspace', 'libdev-userspace', 'gcc', + 'libmem', 'c-userspace'], + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') -src = Glob('*.[cS]') -src += Glob('src/*.[cS]') +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) -objs = env.Object(src) -prog = env.Program('main.elf', objs) -Depends(prog, 'include/linker.lds') +Depends(objs, join(PROJROOT, CONFIG_H)) +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/baremetal/hello_world/SConscript b/conts/baremetal/hello_world/SConscript new file mode 100644 index 0000000..062d7f2 --- /dev/null +++ b/conts/baremetal/hello_world/SConscript @@ -0,0 +1,11 @@ + +# Inherit global environment +Import('env') + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/hello_world/SConstruct b/conts/baremetal/hello_world/SConstruct index 4730433..83ebc21 100644 --- a/conts/baremetal/hello_world/SConstruct +++ b/conts/baremetal/hello_world/SConstruct @@ -4,64 +4,54 @@ # # Copyright © 2009 B Labs Ltd # -import os, shelve, sys +import os, sys from os.path import * -PROJRELROOT = '../..' +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.conts.containers import * +from scripts.config.configuration import * config = configuration_retrieve() -platform = config.platform -arch = config.arch gcc_arch_flag = config.gcc_arch_flag -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) +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) -# 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)] +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) -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')] - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], - 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', \ - 'libmm', 'libmc', 'libmalloc', 'gcc', 'c-userspace'], + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + 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', + 'libmem', 'gcc', 'c-userspace'], # libgcc.a - This is required for division routines. - CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, \ - LIBC_INCLUDE, LIBMEM_INCLUDE], - LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -include l4lib/macros.h') + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h \ + -include l4/types.h -include l4lib/macros.h') -src = Glob('*.[cS]') -src += Glob('src/*.[cS]') +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) -objs = env.Object(src) -prog = env.Program('main.elf', objs) -Depends(prog, 'include/linker.lds') +Depends(objs, join(PROJROOT, CONFIG_H)) + +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/baremetal/ipc_demo/SConscript b/conts/baremetal/ipc_demo/SConscript new file mode 100644 index 0000000..062d7f2 --- /dev/null +++ b/conts/baremetal/ipc_demo/SConscript @@ -0,0 +1,11 @@ + +# Inherit global environment +Import('env') + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/ipc_demo/SConstruct b/conts/baremetal/ipc_demo/SConstruct new file mode 100644 index 0000000..195425a --- /dev/null +++ b/conts/baremetal/ipc_demo/SConstruct @@ -0,0 +1,57 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, shelve, sys +from os.path import * + +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) + +from scripts.config.projpaths import * +from scripts.conts.containers import * +from scripts.config.configuration import * + +config = configuration_retrieve() +gcc_arch_flag = config.gcc_arch_flag + +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) + +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) + +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' + +env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + 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', + 'libmem', 'gcc', 'c-userspace'], + # libgcc.a - This is required for division routines. + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h \ + -include l4/types.h -include l4lib/macros.h') + +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) + +Depends(objs, join(PROJROOT, CONFIG_H)) + +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/test_suite0/build.readme b/conts/baremetal/ipc_demo/build.readme similarity index 98% rename from conts/test_suite0/build.readme rename to conts/baremetal/ipc_demo/build.readme index 7f2ecf4..4e9a73f 100644 --- a/conts/test_suite0/build.readme +++ b/conts/baremetal/ipc_demo/build.readme @@ -8,7 +8,7 @@ process. It is meant to be the most simple to get on with, therefore if you feel any complications, please reach us on our l4dev.org mailing list on http://lists.l4dev.org/mailman/listinfo/codezero-devel -You have created a new container called `test_suite0'. +You have created a new container called `ipc_demo0'. The parameters you have supplied are described in the ".container" file placed at the top-level directory. Note, that this is only an informative diff --git a/conts/test_suite0/container.c b/conts/baremetal/ipc_demo/container.c similarity index 59% rename from conts/test_suite0/container.c rename to conts/baremetal/ipc_demo/container.c index 4b97317..f570c3d 100644 --- a/conts/test_suite0/container.c +++ b/conts/baremetal/ipc_demo/container.c @@ -6,8 +6,7 @@ #include #include -#include -#include + extern void main(void); @@ -16,12 +15,6 @@ void __container_init(void) /* Generic L4 initialisation */ __l4_init(); - /* Thread library initialisation */ - __l4_threadlib_init(); - - /* Capability library initialization */ - __l4_capability_init(); - /* Entry to main */ main(); } diff --git a/conts/test_suite0/include/container.h b/conts/baremetal/ipc_demo/include/container.h similarity index 82% rename from conts/test_suite0/include/container.h rename to conts/baremetal/ipc_demo/include/container.h index ef93768..61184c0 100644 --- a/conts/test_suite0/include/container.h +++ b/conts/baremetal/ipc_demo/include/container.h @@ -5,7 +5,7 @@ #define __CONTAINER_H__ -#define __CONTAINER_NAME__ "test_suite0" +#define __CONTAINER_NAME__ "ipc_demo0" #define __CONTAINER_ID__ 0 #define __CONTAINER__ "cont0" diff --git a/conts/test_suite0/include/fault.h b/conts/baremetal/ipc_demo/include/fault.h similarity index 100% rename from conts/test_suite0/include/fault.h rename to conts/baremetal/ipc_demo/include/fault.h diff --git a/conts/test_suite0/include/linker.h b/conts/baremetal/ipc_demo/include/linker.h similarity index 100% rename from conts/test_suite0/include/linker.h rename to conts/baremetal/ipc_demo/include/linker.h diff --git a/conts/baremetal/ipc_demo/include/linker.lds b/conts/baremetal/ipc_demo/include/linker.lds new file mode 100644 index 0000000..2f25bd8 --- /dev/null +++ b/conts/baremetal/ipc_demo/include/linker.lds @@ -0,0 +1,55 @@ +/* + * Example working linker script for this container. + * + * Copyright (C) 2009 B Labs Ltd. + */ + +vma_start = 0xa0000000; +lma_start = 0x100000; +offset = vma_start - lma_start; + +OUTPUT_ARCH(arm) +ENTRY(_start) + +PHDRS +{ + rx PT_LOAD; + rw PT_LOAD; +} + +SECTIONS +{ + . = vma_start; + + /* Put all RX, RO sections here */ + .text : AT (ADDR(.text) - offset) + { + *(.text.head) *(.text) + } : rx = 0x90909090 + + .rodata : AT (ADDR(.rodata) - offset) + { + *(.rodata) + } : rx = 0x90909090 + + .rodata1 : AT (ADDR(.rodata1) - offset) + { + *(.rodata1) + } : rx = 0x90909090 + + . = ALIGN(4K); + + /* Put all RW sections here */ + .data : AT (ADDR(.data) - offset) + { + *(.data) + } : rw + .bss : AT (ADDR(.bss) - offset) + { + *(.bss) + . += 0x1000; + . = ALIGN(8); + __stack = .; + } : rw + __end = .; +} diff --git a/conts/test_suite0/include/memory.h b/conts/baremetal/ipc_demo/include/memory.h similarity index 100% rename from conts/test_suite0/include/memory.h rename to conts/baremetal/ipc_demo/include/memory.h diff --git a/conts/baremetal/ipc_demo/include/tests.h b/conts/baremetal/ipc_demo/include/tests.h new file mode 100644 index 0000000..696e0bb --- /dev/null +++ b/conts/baremetal/ipc_demo/include/tests.h @@ -0,0 +1,13 @@ + +#ifndef __TESTS_H__ +#define __TESTS_H__ + +//#define DEBUG + +#ifdef DEBUG +#define dgb_printf printf +#else +#define dbg_printf(fmt,...) +#endif + +#endif diff --git a/conts/baremetal/ipc_demo/main.c b/conts/baremetal/ipc_demo/main.c new file mode 100644 index 0000000..946aa07 --- /dev/null +++ b/conts/baremetal/ipc_demo/main.c @@ -0,0 +1,29 @@ +/* + * Main function for this container + */ + +#include +#include L4LIB_INC_ARCH(syslib.h) +#include L4LIB_INC_ARCH(syscalls.h) +#include +#include +#include + +#include + +extern int ipc_demo(void); + +int main(void) +{ + + __l4_threadlib_init(); + + __l4_capability_init(); + + page_pool_init(); + + ipc_demo(); + + return 0; +} + diff --git a/conts/baremetal/ipc_demo/src/ipc.c b/conts/baremetal/ipc_demo/src/ipc.c new file mode 100644 index 0000000..e290fb3 --- /dev/null +++ b/conts/baremetal/ipc_demo/src/ipc.c @@ -0,0 +1,547 @@ +/* + * Test ipc system call. + * + * Copyright (C) 2010 B Labs Ltd. + * + * Author: Bahadir Balban + */ +#include +#include L4LIB_INC_ARCH(syslib.h) +#include L4LIB_INC_ARCH(syscalls.h) +#include +#include +#include +//#include +#include +#include + +struct ipc_ext_data { + void *virtual; /* Virtual address to start ipc from */ + l4id_t partner; /* Partner to do extended ipc */ +}; + +int ipc_extended_sender(void *arg) +{ + struct ipc_ext_data *data = arg; + int err; + + if ((err = l4_send_extended(data->partner, 0, + SZ_2K, data->virtual)) < 0) { + printf("%s: Extended send failed. err=%d\n", + __FUNCTION__, err); + } + return 0; +} + +int ipc_extended_receiver(void *arg) +{ + struct ipc_ext_data *data = arg; + int err; + + if ((err = l4_receive_extended(data->partner, SZ_2K, + data->virtual)) < 0) { + printf("%s: Extended receive failed. err=%d\n", + __FUNCTION__, err); + } + + /* + * Test the data received + */ + for (int i = 0; i < SZ_2K; i++) { + if (((char *)data->virtual)[i] != 'A' + i) + printf("%s: Extended receive buffer has unexpected " + "data: Start %p, Offset: %d, " + "Data=%d, expected=%d\n", __FUNCTION__, + data->virtual, i, ((char *)data->virtual)[i], + 'A' + i); + return err; + } + + return 0; +} + +int ipc_ext_handle_pfault(struct ipc_ext_data *ipc_data, + void **virt, void **phys) +{ + u32 mr[MR_UNUSED_TOTAL]; + struct fault_data fault; + int err; + + /* Read mrs not used by syslib */ + for (int i = 0; i < MR_UNUSED_TOTAL; i++) + mr[i] = read_mr(MR_UNUSED_START + i); + + fault.kdata = (fault_kdata_t *)&mr[0]; + fault.sender = l4_get_sender(); + + /* Convert from arch-specific to generic fault data */ + set_generic_fault_params(&fault); + + /* + * Handle the fault using a basic logic - if a virtual index + * is faulted, map the corresponding page at same physical index. + */ + if (page_align(fault.address) == (unsigned long)virt[0]) { + if ((err = l4_map(phys[0], virt[0], 1, + MAP_USR_RW, fault.sender)) < 0) { + printf("%s: Error: l4_map failed. " + "phys=%p, virt=%p\n", __FUNCTION__, + phys[0], virt[0]); + return err; + } + } else if (page_align(fault.address) == (unsigned long)virt[1]) { + if ((err = l4_map(phys[1], virt[1], 1, + MAP_USR_RW, fault.sender)) < 0) { + printf("%s: Error: l4_map failed. " + "phys=%p, virt=%p\n", __FUNCTION__, + phys[1], virt[1]); + return err; + } + } else if (page_align(fault.address) == (unsigned long)virt[2]) { + if ((err = l4_map(phys[2], virt[2], 1, + MAP_USR_RW, fault.sender)) < 0) { + printf("%s: Error: l4_map failed. " + "phys=%p, virt=%p\n", __FUNCTION__, + phys[2], virt[2]); + return err; + } + } else if (page_align(fault.address) == (unsigned long)virt[3]) { + if ((err = l4_map(phys[3], virt[3], 1, + MAP_USR_RW, fault.sender)) < 0) { + printf("%s: Error: l4_map failed. " + "phys=%p, virt=%p\n", __FUNCTION__, + phys[3], virt[3]); + return err; + } + } else { + printf("%s: Error, page fault occured on an unexpected " + "address. adress=0x%x\n", __FUNCTION__, + fault.address); + return -1; + } + + /* Reply back to fault thread and return */ + return l4_ipc_return(0); +} + +/* + * Create two threads who will do page-faulting ipc to each other. + * Their parent waits and handles the page faults. + * + * This test allocates 4 virtual page and 4 physical page addresses. + * It fills a total of 2KB of payload starting from the 3rd quarter + * of the first page and until the 2nd quarter of the 2nd page to + * be sent by the sender thread. + * + * The payload is copied and the pages deliberately unmapped so that + * the sender thread will page fault during the send operation. + * + * The receive pages are also set up same as above, so the receiving + * thread also faults during the receive. + * + * The main thread starts both ipc threads, and starts waiting on + * page faults. It handles the faults and the test succeeds if the + * data is transfered safely to receiving end, despite all faults. + */ +int test_ipc_extended(void) +{ + struct task_ids self_ids; + struct ipc_ext_data ipc_data[2]; + struct l4_thread *thread[2]; + void *virt[4], *phys[4]; + int err, tag; + + l4_getid(&self_ids); + + /* Get 4 physical pages */ + for (int i = 0; i < 4; i++) + phys[i] = physical_page_new(1); + + /* Get 2 pairs of virtual pages */ + virt[0] = virtual_page_new(2); + virt[1] = virt[0] + PAGE_SIZE; + virt[2] = virtual_page_new(2); + virt[3] = virt[2] + PAGE_SIZE; + + /* Map sender pages to self */ + if ((err = l4_map(phys[0], virt[0], 1, + MAP_USR_RW, self_ids.tid)) < 0) { + printf("Error: Mapping Sender pages failed. phys: 0x%p," + " virt: 0x%p, tid=%d, err=%d\n", phys[0], virt[0], + self_ids.tid, err); + return err; + } + if ((err = l4_map(phys[1], virt[1], 1, + MAP_USR_RW, self_ids.tid)) < 0) { + printf("Error: Mapping Sender pages failed. phys: 0x%p," + " virt: 0x%p, tid=%d, err=%d\n", phys[0], virt[0], + self_ids.tid, err); + return err; + } + + /* + * Fill them with values to be sent + * Filling in 3rd KB of first page to 2nd KB of second page + */ + for (int i = 0; i < SZ_2K; i++) + ((char *)virt[0] + SZ_1K * 3)[i] = 'A' + i; + + /* Unmap the pages */ + l4_unmap(virt[0], 2, self_ids.tid); + + /* Create ipc threads but don't start. */ + if ((err = thread_create(ipc_extended_sender, + &ipc_data[0], + TC_SHARE_SPACE | TC_NOSTART, + &thread[0])) < 0) { + dbg_printf("Thread create failed. " + "err=%d\n", err); + return err; + } + + dbg_printf("Thread created successfully. " + "tid=%d\n", thread[0]->ids.tid); + + if ((err = thread_create(ipc_extended_receiver, + &ipc_data[1], + TC_SHARE_SPACE | TC_NOSTART, + &thread[1])) < 0) { + dbg_printf("Thread create failed. " + "err=%d\n", err); + return err; + } + + dbg_printf("Thread created successfully. " + "tid=%d\n", thread[1]->ids.tid); + + /* + * Set up arguments to sender, + * Send offset at 3rd quarter of first page. + */ + ipc_data[0].virtual = virt[0] + SZ_1K * 3; + ipc_data[0].partner = thread[1]->ids.tid; + + /* + * Set up arguments to receiver + * Receive offset at 3rd quarter of first page. + */ + ipc_data[1].virtual = virt[1] + SZ_1K * 3; + ipc_data[1].partner = thread[0]->ids.tid; + + /* Start the threads */ + l4_thread_control(THREAD_RUN, &thread[0]->ids); + l4_thread_control(THREAD_RUN, &thread[1]->ids); + + /* Expecting 4 faults on 4 pages */ + for (int i = 0; i < 4; i++) { + /* Wait on page fault */ + if ((err = l4_receive(L4_ANYTHREAD)) < 0) { + printf("Error: l4_receive() for page" + " fault has failed. err=%d\n", + err); + } + if ((tag = l4_get_tag()) != L4_IPC_TAG_PFAULT) { + printf("Error: Parent thread received " + "non-page fault ipc tag. tag=%d\n", + tag); + return -1; + } + + /* Handle fault */ + if ((err = ipc_ext_handle_pfault(ipc_data, virt, phys)) < 0) { + printf("Error: An error occured during ipc " + "page fault handling. err=%d\n", err); + return err; + } + } + + /* Wait for the ipc threads */ + for (int i = 0; i < 2; i ++) + if ((err = thread_wait(thread[i])) < 0) { + dbg_printf("THREAD_WAIT failed. " + "err=%d\n", err); + return err; + } + + /* Unmap and release pages */ + for (int i = 0; i < 4; i++) { + l4_unmap(virt[i], 1, self_ids.tid); + virtual_page_free(virt[i], 1); + physical_page_free(phys[i], 1); + } + + return 0; +} + +int ipc_full_thread(void *arg) +{ + l4id_t parent = *((l4id_t *)arg); + int err; + + /* Do two full send/receives */ + for (int i = 0; i < 2; i++) { + /* Full receive, return positive if error */ + if ((err = l4_receive_full(parent)) < 0) { + dbg_printf("Full receive failed on new " + "thread. err=%d", err); + return 1; + } + + /* Test full utcb received values */ + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) { + if (read_mr(i) != i) { + dbg_printf("IPC full receive on new thread: " + "Unexpected message register " + "values. MR%d = %d, should be %d\n", + i, read_mr(i), i); + return 1; /* Exit positive without reply */ + } + } + + /* + * Reset all message registers + */ + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) + write_mr(i, 0); + + /* Send full return reply */ + l4_send_full(parent, 0); + } + return 0; +} + +int ipc_short_thread(void *arg) +{ + l4id_t parent = *((l4id_t *)arg); + int err; + + /* Short receive, return positive if error */ + if ((err = l4_receive(parent)) < 0) { + dbg_printf("Short receive failed on new " + "thread. err=%d", err); + return 1; + } + + /* Test received registers */ + for (int i = MR_UNUSED_START; i < MR_TOTAL; i++) { + if (read_mr(i) != i) { + dbg_printf("IPC Receive on new thread: " + "Unexpected message register " + "values.\n" + "read = %d, expected = %d\n", + read_mr(i), i); + l4_print_mrs(); + return 1; /* Exit positive without reply */ + } + } + + /* + * Reset all message registers + */ + for (int i = MR_UNUSED_START; i < MR_TOTAL; i++) + write_mr(i, 0); + + /* + * Send return reply and exit + */ + return l4_send(parent, 0); +} + + +/* + * Create a thread and do a full ipc to it + */ +int test_ipc_full(void) +{ + struct task_ids self_ids; + struct l4_thread *thread; + int err; + + l4_getid(&self_ids); + + /* + * Create a thread in the same space + */ + if ((err = thread_create(ipc_full_thread, + &self_ids.tid, + TC_SHARE_SPACE, + &thread)) < 0) { + dbg_printf("Thread create failed. " + "err=%d\n", err); + return err; + } + + dbg_printf("Thread created successfully. " + "tid=%d\n", thread->ids.tid); + + /* + * Try one short and one full send/recv + * to test full send/recv occurs on both cases + */ + + /* + * Write data to full utcb registers + */ + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) + write_mr(i, i); + + /* + * First, do a full ipc send/recv + */ + if ((err = l4_sendrecv_full(thread->ids.tid, + thread->ids.tid, + 0)) < 0) { + dbg_printf("Full IPC send/recv failed. " + "err=%d\n", err); + return err; + } + + /* + * Check that payload registers are modified to 0 + */ + dbg_printf("%s: After send/recv:\n", __FUNCTION__); + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) { + if (read_mr(i) != 0) { + dbg_printf("Full IPC send/recv: " + "Received payload is not " + "as expected.\n " + "MR%d = %d, should be %d\n", + i, read_mr(i), 0); + return -1; + } + } + + /* + * Write data to full utcb registers + */ + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) + write_mr(i, i); + + /* + * Try a short ipc send/recv. This should still result + * in full ipc since the other side is doing full send/recv. + */ + if ((err = l4_sendrecv(thread->ids.tid, + thread->ids.tid, + 0)) < 0) { + dbg_printf("Full IPC send/recv failed. " + "err=%d\n", err); + return err; + } + + /* + * Check that payload registers are modified to 0 + */ + // dbg_printf("%s: After send/recv:\n", __FUNCTION__); + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) { + // dbg_printf("MR%d: %d\n", i, read_mr(i)); + if (read_mr(i) != 0) { + dbg_printf("Full IPC send/recv: " + "Received payload is not " + "as expected.\n " + "MR%d = %d, should be %d\n", + i, read_mr(i), 0); + return -1; + } + } + + /* Wait for the ipc thread to die */ + if ((err = thread_wait(thread)) < 0) { + dbg_printf("THREAD_WAIT failed. " + "err=%d\n", err); + return err; + } + + dbg_printf("Full IPC send/recv successful.\n"); + return 0; +} + +/* + * Create a thread and do a short ipc to it + */ +int test_ipc_short(void) +{ + struct task_ids self_ids; + struct l4_thread *thread; + int err; + + l4_getid(&self_ids); + + /* + * Create a thread in the same space + */ + if ((err = thread_create(ipc_short_thread, + &self_ids.tid, + TC_SHARE_SPACE, + &thread)) < 0) { + dbg_printf("Thread create failed. " + "err=%d\n", err); + return err; + } + + dbg_printf("Thread created successfully. " + "tid=%d\n", thread->ids.tid); + + /* + * Write data to short ipc registers + */ + for (int i = MR_UNUSED_START; i < MR_TOTAL; i++) + write_mr(i, i); + + /* + * Do short ipc send/recv and check data is reset + */ + if ((err = l4_sendrecv(thread->ids.tid, + thread->ids.tid, + 0)) < 0) { + dbg_printf("Short IPC send/recv failed. " + "err=%d\n", err); + return err; + } + + /* + * Check that payload registers are reset + */ + for (int i = MR_UNUSED_START; i < MR_TOTAL; i++) { + if (read_mr(i) != 0) { + dbg_printf("Short IPC send/recv: " + "Received payload is incorrect." + "read = %d, expected=%d\n", + read_mr(i), 0); + return -1; + } + } + + /* Wait for the ipc thread */ + if ((err = thread_wait(thread)) < 0) { + dbg_printf("THREAD_WAIT failed. " + "err=%d\n", err); + return err; + } + + dbg_printf("Short IPC send/recv successful.\n"); + return 0; +} + +int ipc_demo(void) +{ + int err; + + if ((err = test_ipc_extended()) < 0) + goto out_err; + + if ((err = test_ipc_short()) < 0) + goto out_err; + + if ((err = test_ipc_full()) < 0) + goto out_err; + + printf("IPC: -- PASSED --\n"); + return 0; + +out_err: + printf("IPC: -- FAILED --\n"); + return err; + +} + diff --git a/conts/test_suite0/src/api/memory.c b/conts/baremetal/ipc_demo/src/memory.c similarity index 100% rename from conts/test_suite0/src/api/memory.c rename to conts/baremetal/ipc_demo/src/memory.c diff --git a/conts/baremetal/ipc_demo/src/mm.c b/conts/baremetal/ipc_demo/src/mm.c new file mode 100644 index 0000000..1e63377 --- /dev/null +++ b/conts/baremetal/ipc_demo/src/mm.c @@ -0,0 +1,74 @@ +/* + * ARMv7 specific functions + * + * Copyright (C) 2008 - 2010 B Labs Ltd. + */ +#include +#include +#include INC_SUBARCH(mm.h) +#include INC_SUBARCH(exception.h) + +/* Get simplified access permissions */ +int pte_get_access_simple(pte_t pte) +{ + /* Place AP[2] and AP[1] in [1:0] positions and return */ + return (((pte >> PTE_AP2_BIT) & 1) << 1) + | ((pte >> PTE_AP1_BIT) & 1); +} + +int is_translation_fault(u32 fsr) +{ + return (fsr & FSR_FS_MASK) == ABORT_TRANSLATION_PAGE; +} + +unsigned int vm_prot_flags(pte_t pte, u32 fsr) +{ + unsigned int pte_prot_flags = 0; + + /* Translation fault means no permissions */ + if (is_translation_fault(fsr)) + return VM_NONE; + + /* Check simplified permission bits */ + switch (pte_get_access_simple(pte)) { + case AP_SIMPLE_USER_RW_KERN_RW: + pte_prot_flags |= VM_WRITE; + case AP_SIMPLE_USER_RO_KERN_RO: + pte_prot_flags |= VM_READ; + + /* Also, check exec never bit */ + if (!(pte & (1 << PTE_XN_BIT))) + pte_prot_flags |= VM_EXEC; + break; + case AP_SIMPLE_USER_NONE_KERN_RW: + case AP_SIMPLE_USER_NONE_KERN_RO: + default: + pte_prot_flags = VM_NONE; + break; + } + + return pte_prot_flags; +} + +void set_generic_fault_params(struct fault_data *fault) +{ + fault->pte_flags = vm_prot_flags(fault->kdata->pte, fault->kdata->fsr); + fault->reason = 0; + + /* + * Prefetch fault denotes exec fault. + */ + if (is_prefetch_abort(fault->kdata->fsr)) { + fault->reason |= VM_EXEC; + fault->address = fault->kdata->faulty_pc; + } else { + fault->address = fault->kdata->far; + + /* Write-not-read bit determines fault */ + if (fault->kdata->fsr & (1 << DFSR_WNR_BIT)) + fault->reason |= VM_WRITE; + else + fault->reason |= VM_READ; + } +} + diff --git a/conts/baremetal/kmi_service/SConscript b/conts/baremetal/kmi_service/SConscript new file mode 100644 index 0000000..23d3709 --- /dev/null +++ b/conts/baremetal/kmi_service/SConscript @@ -0,0 +1,12 @@ + +# Inherit global environment +Import('env') + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') +src_local += Glob('src/arch/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/kmi_service/SConstruct b/conts/baremetal/kmi_service/SConstruct index 7fed797..e379a6e 100755 --- a/conts/baremetal/kmi_service/SConstruct +++ b/conts/baremetal/kmi_service/SConstruct @@ -7,64 +7,51 @@ import os, shelve, sys from os.path import * -PROJRELROOT = '../..' +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.configuration import * +from scripts.conts.containers import * +from scripts.config.config_invoke import * config = configuration_retrieve() -arch = config.arch -platform = config.platform gcc_arch_flag = config.gcc_arch_flag -# Wrapper library for system calls -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) +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) -# Some user-space libraries -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)] +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) -LIBDEV_RELDIR = 'conts/libdev' -LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR) -LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace') -LIBDEV_INCLUDE = join(LIBDEV_DIR, 'include') - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], \ - 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', \ - 'libmm', 'libmc', 'libmalloc', 'gcc', 'c-userspace'], - # libgcc.a - This is required for division routines. - CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, \ - LIBC_INCLUDE, LIBMEM_INCLUDE], - LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + 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', + 'libmem', 'gcc', 'c-userspace'], + # libgcc.a - This is required for division routines. + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') -src = Glob('*.[cS]') -src += Glob('src/*.[cS]') -src += Glob('src/arch/*.[cS]') +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) -objs = env.Object(src) -prog = env.Program('main.elf', objs) -Depends(prog, 'include/linker.lds') +Depends(objs, join(PROJROOT, CONFIG_H)) + +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/baremetal/kmi_service/container.c b/conts/baremetal/kmi_service/container.c index e20006c..88da84e 100755 --- a/conts/baremetal/kmi_service/container.c +++ b/conts/baremetal/kmi_service/container.c @@ -7,6 +7,7 @@ #include #include #include +#include void main(void); @@ -18,6 +19,8 @@ void __container_init(void) /* Thread library initialisation */ __l4_threadlib_init(); + __l4_capability_init(); + /* Entry to main */ main(); } diff --git a/conts/baremetal/kmi_service/include/keyboard.h b/conts/baremetal/kmi_service/include/keyboard.h index 7c783b0..c24eab5 100755 --- a/conts/baremetal/kmi_service/include/keyboard.h +++ b/conts/baremetal/kmi_service/include/keyboard.h @@ -4,15 +4,16 @@ #ifndef __KEYBOARD_H__ #define __KEYBOARD_H__ -#include +#include /* * Keyboard structure */ struct keyboard { unsigned long base; /* Virtual base address */ - struct capability cap; /* Capability describing keyboard */ struct keyboard_state state; + unsigned long phys_base; /* Physical address of device */ + int irq_no; /* IRQ number of device */ }; #endif /* __KEYBOARD_H__ */ diff --git a/conts/baremetal/kmi_service/include/mouse.h b/conts/baremetal/kmi_service/include/mouse.h index d8eddbd..848462a 100755 --- a/conts/baremetal/kmi_service/include/mouse.h +++ b/conts/baremetal/kmi_service/include/mouse.h @@ -9,7 +9,8 @@ */ struct mouse { unsigned long base; /* Virtual base address */ - struct capability cap; /* Capability describing keyboard */ + unsigned long phys_base; /* Physical address of device */ + int irq_no; /* IRQ number of device */ }; #endif /* __MOUSE_H__ */ diff --git a/conts/baremetal/kmi_service/main.c b/conts/baremetal/kmi_service/main.c index 88a6bdf..1787d5e 100755 --- a/conts/baremetal/kmi_service/main.c +++ b/conts/baremetal/kmi_service/main.c @@ -3,6 +3,7 @@ */ #include #include +#include #include #include #include @@ -10,47 +11,22 @@ #include #include #include -#include +#include #include #include #include #include +#include #define KEYBOARDS_TOTAL 1 #define MOUSE_TOTAL 1 -static struct capability caparray[32]; +static struct capability *caparray; static int total_caps = 0; struct keyboard kbd[KEYBOARDS_TOTAL]; struct mouse mouse[MOUSE_TOTAL]; -int cap_read_all() -{ - int ncaps; - int err; - - /* Read number of capabilities */ - if ((err = l4_capability_control(CAP_CONTROL_NCAPS, - 0, &ncaps)) < 0) { - printf("l4_capability_control() reading # of" - " capabilities failed.\n Could not " - "complete CAP_CONTROL_NCAPS request.\n"); - BUG(); - } - total_caps = ncaps; - - /* Read all capabilities */ - if ((err = l4_capability_control(CAP_CONTROL_READ, - 0, caparray)) < 0) { - printf("l4_capability_control() reading of " - "capabilities failed.\n Could not " - "complete CAP_CONTROL_READ_CAPS request.\n"); - BUG(); - } - return 0; -} - int cap_share_all_with_space() { int err; @@ -68,47 +44,6 @@ int cap_share_all_with_space() return 0; } -/* - * Scans for up to KEYBOARDS_TOTAL - * keyboard devices and MOUSE_TOTAL mouse - * in capabilities. - */ -int kmi_probe_devices(void) -{ - int keyboards = 0, nmouse = 0; - - /* Scan for timer devices */ - for (int i = 0; i < total_caps; i++) { - /* Match device type */ - if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_KEYBOARD) { - /* Copy to correct device index */ - memcpy(&kbd[cap_devnum(&caparray[i])].cap, - &caparray[i], sizeof(kbd[0].cap)); - keyboards++; - } - if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_MOUSE) { - /* Copy to correct device index */ - memcpy(&mouse[cap_devnum(&caparray[i])].cap, - &caparray[i], sizeof(mouse[0].cap)); - nmouse++; - } - - } - - if (keyboards != KEYBOARDS_TOTAL) { - printf("%s: Error, not all keyboards could be found. " - "keyboards=%d\n", __CONTAINER_NAME__, keyboards); - return -ENODEV; - } - if (nmouse != MOUSE_TOTAL) { - printf("%s: Error, not all mouse could be found. " - "mouse=%d\n", __CONTAINER_NAME__, nmouse); - return -ENODEV; - } - - return 0; -} - int keyboard_irq_handler(void *arg) { int err; @@ -125,7 +60,7 @@ int keyboard_irq_handler(void *arg) /* Register self for timer irq, using notify slot 0 */ if ((err = l4_irq_control(IRQ_CONTROL_REGISTER, slot, - keyboard->cap.irq)) < 0) { + keyboard->irq_no)) < 0) { printf("%s: FATAL: Keyboard irq could not be registered. " "err=%d\n", __FUNCTION__, err); BUG(); @@ -136,7 +71,7 @@ int keyboard_irq_handler(void *arg) char c; /* Block on irq */ - int data = l4_irq_wait(slot, keyboard->cap.irq); + int data = l4_irq_wait(slot, keyboard->irq_no); while (data--) if ((c = kmi_keyboard_read(keyboard->base, &keyboard->state))) printf("%c", c); @@ -165,7 +100,7 @@ int mouse_irq_handler(void *arg) /* Register self for timer irq, using notify slot 0 */ if ((err = l4_irq_control(IRQ_CONTROL_REGISTER, slot, - mouse->cap.irq)) < 0) { + mouse->irq_no)) < 0) { printf("%s: FATAL: Mouse irq could not be registered. " "err=%d\n", __FUNCTION__, err); BUG(); @@ -176,7 +111,7 @@ int mouse_irq_handler(void *arg) int c; /* Block on irq */ - int data = l4_irq_wait(slot, mouse->cap.irq); + int data = l4_irq_wait(slot, mouse->irq_no); while (data--) if ((c = kmi_data_read(mouse->base))) printf("mouse data: %d\n", c); @@ -195,6 +130,9 @@ int kmi_setup_devices(void) struct l4_thread *tptr = &thread; int err; + kbd[0].phys_base = PLATFORM_KEYBOARD0_BASE; + kbd[0].irq_no = IRQ_KEYBOARD0; + for (int i = 0; i < KEYBOARDS_TOTAL; i++) { /* Get one page from address pool */ kbd[i].base = (unsigned long)l4_new_virtual(1); @@ -203,13 +141,12 @@ int kmi_setup_devices(void) kbd[i].state.keyup = 0; /* Map timer to a virtual address region */ - if (IS_ERR(l4_map((void *)__pfn_to_addr(kbd[i].cap.start), - (void *)kbd[i].base, kbd[i].cap.size, + if (IS_ERR(l4_map((void *)kbd[i].phys_base, + (void *)kbd[i].base, 1, MAP_USR_IO, self_tid()))) { printf("%s: FATAL: Failed to map Keyboard device " - "%d to a virtual address\n", - __CONTAINER_NAME__, - cap_devnum(&kbd[i].cap)); + "to a virtual address\n", + __CONTAINER_NAME__); BUG(); } @@ -229,17 +166,20 @@ int kmi_setup_devices(void) } } + mouse[0].phys_base = PLATFORM_MOUSE0_BASE; + mouse[0].irq_no = IRQ_MOUSE0; + for (int i = 0; i < MOUSE_TOTAL; i++) { /* Get one page from address pool */ mouse[i].base = (unsigned long)l4_new_virtual(1); /* Map timer to a virtual address region */ - if (IS_ERR(l4_map((void *)__pfn_to_addr(mouse[i].cap.start), - (void *)mouse[i].base, mouse[i].cap.size, + if (IS_ERR(l4_map((void *)mouse[i].phys_base, + (void *)mouse[i].base, 1, MAP_USR_IO, self_tid()))) { printf("%s: FATAL: Failed to map Mouse device " - "%d to a virtual address\n", - __CONTAINER_NAME__, cap_devnum(&mouse[i].cap)); + "to a virtual address\n", + __CONTAINER_NAME__); BUG(); } @@ -368,64 +308,20 @@ void handle_requests(void) } } -/* - * UTCB-size aligned utcb. - * - * BIG WARNING NOTE: This declaration is legal if we are - * running in a disjoint virtual address space, where the - * utcb declaration lies in a unique virtual address in - * the system. - */ -#define DECLARE_UTCB(name) \ - struct utcb name ALIGN(sizeof(struct utcb)) - -DECLARE_UTCB(utcb); - -/* Set up own utcb for ipc */ -int l4_utcb_setup(void *utcb_address) -{ - struct task_ids ids; - struct exregs_data exregs; - int err; - - l4_getid(&ids); - - /* Clear utcb */ - memset(utcb_address, 0, sizeof(struct utcb)); - - /* Setup exregs for utcb request */ - memset(&exregs, 0, sizeof(exregs)); - exregs_set_utcb(&exregs, (unsigned long)utcb_address); - - if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0) - return err; - - return 0; -} - void main(void) { - int err; - /* Read all capabilities */ - cap_read_all(); + caps_read_all(); + + total_caps = cap_get_count(); + caparray = cap_get_all(); /* Share all with space */ cap_share_all_with_space(); - /* Scan for keyboard devices in capabilities */ - kmi_probe_devices(); - /* Initialize virtual address pool for timers */ init_vaddr_pool(); - /* Setup own static utcb */ - if ((err = l4_utcb_setup(&utcb)) < 0) { - printf("FATAL: Could not set up own utcb. " - "err=%d\n", err); - BUG(); - } - /* Map and initialize keyboard devices */ kmi_setup_devices(); diff --git a/conts/baremetal/mutex_demo/SConscript b/conts/baremetal/mutex_demo/SConscript new file mode 100644 index 0000000..062d7f2 --- /dev/null +++ b/conts/baremetal/mutex_demo/SConscript @@ -0,0 +1,11 @@ + +# Inherit global environment +Import('env') + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/mutex_demo/SConstruct b/conts/baremetal/mutex_demo/SConstruct new file mode 100644 index 0000000..195425a --- /dev/null +++ b/conts/baremetal/mutex_demo/SConstruct @@ -0,0 +1,57 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, shelve, sys +from os.path import * + +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) + +from scripts.config.projpaths import * +from scripts.conts.containers import * +from scripts.config.configuration import * + +config = configuration_retrieve() +gcc_arch_flag = config.gcc_arch_flag + +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) + +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) + +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' + +env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + 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', + 'libmem', 'gcc', 'c-userspace'], + # libgcc.a - This is required for division routines. + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h \ + -include l4/types.h -include l4lib/macros.h') + +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) + +Depends(objs, join(PROJROOT, CONFIG_H)) + +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/baremetal/mutex_demo/container.c b/conts/baremetal/mutex_demo/container.c new file mode 100644 index 0000000..f570c3d --- /dev/null +++ b/conts/baremetal/mutex_demo/container.c @@ -0,0 +1,21 @@ +/* + * Container entry point for pager + * + * Copyright (C) 2007-2009 B Labs Ltd. + */ + +#include +#include + + +extern void main(void); + +void __container_init(void) +{ + /* Generic L4 initialisation */ + __l4_init(); + + /* Entry to main */ + main(); +} + diff --git a/conts/baremetal/mutex_demo/include/tests.h b/conts/baremetal/mutex_demo/include/tests.h new file mode 100644 index 0000000..696e0bb --- /dev/null +++ b/conts/baremetal/mutex_demo/include/tests.h @@ -0,0 +1,13 @@ + +#ifndef __TESTS_H__ +#define __TESTS_H__ + +//#define DEBUG + +#ifdef DEBUG +#define dgb_printf printf +#else +#define dbg_printf(fmt,...) +#endif + +#endif diff --git a/conts/baremetal/mutex_demo/main.c b/conts/baremetal/mutex_demo/main.c new file mode 100644 index 0000000..0f7142e --- /dev/null +++ b/conts/baremetal/mutex_demo/main.c @@ -0,0 +1,18 @@ +/* + * Main function for this container + */ + +#include +#include L4LIB_INC_ARCH(syslib.h) +#include L4LIB_INC_ARCH(syscalls.h) +#include + +extern int test_api_mutexctrl(void); + +int main(void) +{ + test_api_mutexctrl(); + + return 0; +} + diff --git a/conts/test_suite0/src/api/mutex.c b/conts/baremetal/mutex_demo/src/mutex.c similarity index 100% rename from conts/test_suite0/src/api/mutex.c rename to conts/baremetal/mutex_demo/src/mutex.c diff --git a/conts/baremetal/test_suite/SConscript b/conts/baremetal/test_suite/SConscript new file mode 100644 index 0000000..b098559 --- /dev/null +++ b/conts/baremetal/test_suite/SConscript @@ -0,0 +1,23 @@ + +# Inherit global environment +Import('env') + +from scripts.config.configuration import * + +config = configuration_retrieve() +arch = config.arch +subarch = config.subarch + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') +src_local += Glob('src/arch/' + arch + '/*.[cS]') +src_local += Glob('src/api/*.c'); +src_local += Glob('src/perf/*.c'); +src_local += Glob('src/cli_serv/*.c'); +src_local += Glob('src/mthread/*.c'); +src_local += Glob('src/arch/' + arch + '/' + subarch + '/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/test_suite/SConstruct b/conts/baremetal/test_suite/SConstruct index 556b3eb..c1e9c42 100644 --- a/conts/baremetal/test_suite/SConstruct +++ b/conts/baremetal/test_suite/SConstruct @@ -7,61 +7,49 @@ import os, shelve, sys from os.path import * -PROJRELROOT = '../..' +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * -from config.lib import * +from scripts.config.projpaths import * +from scripts.conts.containers import * +from scripts.config.configuration import * config = configuration_retrieve() -arch = config.arch -platform = config.platform gcc_arch_flag = config.gcc_arch_flag -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) +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) -# 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)] +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) -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')] - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], - 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', 'libmalloc', - 'c-userspace'], # libgcc.a - This is required for division routines. - CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, LIBC_INCLUDE, LIBMEM_INCLUDE], - LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + # 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', + '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + linker_lds, '-u_start'], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', + ENV = {'PATH' : os.environ['PATH']}, + LIBS = ['gcc', 'libl4', 'libmem', 'c-userspace', 'libdev-userspace', + 'gcc', 'c-userspace'], + # libgcc.a - This is required for division routines. + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') -src = Glob('*.[cS]') -src += Glob('src/*.[cS]') -src += Glob('src/arch/*.[cS]') +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) -objs = env.Object(src) -prog = env.Program('main.elf', objs) -Depends(prog, 'include/linker.lds') +Depends(objs, join(PROJROOT, CONFIG_H)) +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/baremetal/test_suite/TAGS b/conts/baremetal/test_suite/TAGS new file mode 100644 index 0000000..2f4ba7f --- /dev/null +++ b/conts/baremetal/test_suite/TAGS @@ -0,0 +1,257 @@ + +main.c,65 +void run_tests(void)run_tests16,287 +int main(void)main38,770 + +src/capability.c,0 + +src/example.c,0 + +src/cli_serv/cli_serv.c,45 +int test_cli_serv(void)test_cli_serv21,536 + +src/api/cap.c,192 +#define TOTAL_CAPS TOTAL_CAPS12,202 +struct capability cap_array[TOTAL_CAPS];cap_array14,228 +int test_cap_read(void)test_cap_read19,308 +int test_api_capctrl(void)test_api_capctrl47,968 + +src/api/exregs.c,113 +int test_exregs_read_write(void)test_exregs_read_write15,229 +int test_api_exregs(void)test_api_exregs76,1453 + +src/api/memory.c,771 +#define DECLARE_IDPOOL(DECLARE_IDPOOL23,461 +struct address_pool virtual_page_pool, physical_page_pool;virtual_page_pool26,558 +struct address_pool virtual_page_pool, physical_page_pool;physical_page_pool26,558 +#define PAGE_POOL_SIZE PAGE_POOL_SIZE28,618 +#define virt_to_phys(virt_to_phys33,750 +#define phys_to_virt(phys_to_virt34,833 +#define TEST_POOL_TOTAL TEST_POOL_TOTAL37,920 +void test_page_pool(void)test_page_pool41,972 +void page_pool_init(void)page_pool_init106,2602 +void *virtual_page_new(int npages)virtual_page_new177,4779 +void *physical_page_new(int npages)physical_page_new182,4879 +void virtual_page_free(void *address, int npages)virtual_page_free187,4981 +void physical_page_free(void *address, int npages)physical_page_free193,5104 + +src/api/cache.c,158 +int test_cctrl_basic(void)test_cctrl_basic18,348 +int test_cctrl_sync_caches()test_cctrl_sync_caches43,971 +int test_api_cctrl(void)test_api_cctrl64,1314 + +src/api/thread.c,517 +int new_thread_func(void *args)new_thread_func18,285 +int delayed_exit_func(void *args)delayed_exit_func32,614 +int imm_exit_func(void *args)imm_exit_func54,1031 +struct l4_thread *test_thread_create()test_thread_create62,1132 +int test_thread_actions(struct l4_thread *thread)test_thread_actions92,1698 +int test_thread_destroy(struct l4_thread *thread)test_thread_destroy126,2347 +int test_thread_invalid(struct l4_thread *thread)test_thread_invalid214,4305 +int test_api_tctrl(void)test_api_tctrl219,4371 + +src/api/api.c,35 +int test_api(void)test_api15,214 + +src/api/irq.c,50 +int test_api_irqctrl(void)test_api_irqctrl8,105 + +src/api/ipc.c,705 +struct ipc_ext_data {ipc_ext_data18,330 + void *virtual; /* Virtual address to start ipc from */virtual19,352 + l4id_t partner; /* Partner to do extended ipc */partner20,408 +int ipc_extended_sender(void *arg)ipc_extended_sender23,462 +int ipc_extended_receiver(void *arg)ipc_extended_receiver36,722 +int ipc_ext_handle_pfault(struct ipc_ext_data *ipc_data,ipc_ext_handle_pfault63,1348 +int test_ipc_extended(void)test_ipc_extended146,4092 +int ipc_full_thread(void *arg)ipc_full_thread276,7400 +int ipc_short_thread(void *arg)ipc_short_thread313,8275 +int test_ipc_full(void)test_ipc_full354,9106 +int test_ipc_short(void)test_ipc_short462,11483 +int test_api_ipc(void)test_api_ipc526,12763 + +src/api/map.c,305 +#define KERNEL_PAGE KERNEL_PAGE15,277 +#define KIP_PAGE KIP_PAGE16,311 +#define SYSCALL_PAGE SYSCALL_PAGE17,342 +#define VECTOR_PAGE VECTOR_PAGE18,377 +int test_api_map(void)test_api_map20,412 +int test_api_unmap(void)test_api_unmap259,6043 +int test_api_map_unmap(void)test_api_map_unmap347,8064 + +src/api/getid.c,167 +int thread_getid_nullptr(void *arg)thread_getid_nullptr15,250 +int test_getid_nullptr(void)test_getid_nullptr27,479 +int test_api_getid(void)test_api_getid84,1734 + +src/api/smp.c,299 +static int new_thread_func(void *args)new_thread_func14,232 +int test_smp_two_threads(void)test_smp_two_threads48,945 +int test_smp_two_spaces(void)test_smp_two_spaces113,2491 +int test_smp_ipc(void)test_smp_ipc118,2537 +int test_smp(void)test_smp124,2601 +int test_smp(void)test_smp141,2833 + +src/api/mutex.c,652 +#define MUTEX_NTHREADS MUTEX_NTHREADS16,283 +#define MUTEX_INCREMENTS MUTEX_INCREMENTS17,310 +#define MUTEX_VALUE_TOTAL MUTEX_VALUE_TOTAL18,340 +struct mutex_test_data {mutex_test_data20,404 + struct l4_mutex lock;lock21,429 + int val;val22,452 +static struct mutex_test_data tdata;tdata25,466 +static void init_test_data(struct mutex_test_data *tdata)init_test_data27,504 +int mutex_thread_non_contending(void *arg)mutex_thread_non_contending34,615 +int mutex_thread_contending(void *arg)mutex_thread_contending67,1270 +int test_mutex(int (*mutex_thread)(void *))test_mutex106,2054 +int test_api_mutexctrl(void)test_api_mutexctrl187,3891 + +src/captest.c,178 +int simple_pager_thread(void *arg)simple_pager_thread10,204 +int wait_check_test(struct task_ids *ids)wait_check_test57,1151 +int capability_test(void)capability_test74,1490 + +src/perf/tctrl.c,174 +struct perfmon_cycles tctrl_cycles;tctrl_cycles18,324 +#define PERFTEST_THREAD_CREATE PERFTEST_THREAD_CREATE20,361 +void perf_measure_tctrl(void)perf_measure_tctrl22,399 + +src/perf/exregs.c,181 +struct perfmon_cycles l4_exregs_cycles;l4_exregs_cycles19,372 +#define PERFTEST_EXREGS_COUNT PERFTEST_EXREGS_COUNT21,413 +int perf_measure_exregs(void)perf_measure_exregs23,449 + +src/perf/tswitch.c,472 +struct perfmon_cycles thread_switch_cycles;thread_switch_cycles18,324 +struct perfmon_cycles space_switch_cycles;space_switch_cycles19,368 +static int indicate_switch = 0;indicate_switch21,412 +void thread_switcher_thread(void *arg)thread_switcher_thread23,445 +void perf_measure_thread_switch(void)perf_measure_thread_switch39,799 +void perf_measure_space_switch(void)perf_measure_space_switch102,2328 +void perf_measure_tswitch(void)perf_measure_tswitch108,2372 + +src/perf/perf.c,51 +int test_performance(void)test_performance15,204 + +src/perf/simple.c,168 +struct perfmon_cycles simple_cycles;simple_cycles17,314 +#define PERFTEST_SIMPLE_LOOP PERFTEST_SIMPLE_LOOP19,352 +void perf_test_simple(void)perf_test_simple21,387 + +src/perf/ipc.c,51 +void perf_measure_ipc(void)perf_measure_ipc9,102 + +src/perf/map.c,107 +void perf_measure_map(void)perf_measure_map9,111 +void perf_measure_unmap(void)perf_measure_unmap14,145 + +src/perf/getid.c,245 +struct perfmon_cycles l4_getid_cycles;l4_getid_cycles18,333 +#define PERFTEST_GETID_COUNT PERFTEST_GETID_COUNT20,373 +void perf_measure_getid_ticks(void)perf_measure_getid_ticks25,450 +void perf_measure_getid(void)perf_measure_getid67,1461 + +src/perf/timer.c,150 +#define TIMER_PHYSICAL_BASE TIMER_PHYSICAL_BASE15,298 +unsigned long timer_base;timer_base17,339 +void perf_timer_init(void)perf_timer_init19,366 + +src/perf/mutex.c,55 +void perf_measure_mutex(void)perf_measure_mutex9,104 + +src/perf/cycles.c,70 +void platform_measure_cpu_cycles()platform_measure_cpu_cycles20,354 + +src/mthread/mthread.c,43 +int test_mthread(void)test_mthread22,547 + +src/arch/arm/v7/mm.c,285 +int pte_get_access_simple(pte_t pte)pte_get_access_simple13,246 +int is_translation_fault(u32 fsr)is_translation_fault20,427 +unsigned int vm_prot_flags(pte_t pte, u32 fsr)vm_prot_flags25,521 +void set_generic_fault_params(struct fault_data *fault)set_generic_fault_params54,1163 + +src/arch/arm/v5/mm.c,147 +unsigned int vm_prot_flags(pte_t pte)vm_prot_flags12,242 +void set_generic_fault_params(struct fault_data *fault)set_generic_fault_params42,960 + +container.c,52 +void __container_init(void)__container_init14,216 + +include/capability.h,47 +#define __CAPABILITY_H____CAPABILITY_H__2,25 + +include/thread.h,121 +#define __THREAD_H____THREAD_H__2,21 +#define STACK_SIZE STACK_SIZE15,318 +#define THREADS_TOTAL THREADS_TOTAL17,345 + +include/memory.h,59 +#define __TESTSUITE_MEMORY_H____TESTSUITE_MEMORY_H__2,31 + +include/fault.h,840 +#define __FAULT_H____FAULT_H__2,20 +#define VM_NONE VM_NONE10,169 +#define VM_READ VM_READ11,197 +#define VM_EXEC VM_EXEC12,225 +#define VM_WRITE VM_WRITE13,253 +#define VM_PROT_MASK VM_PROT_MASK14,281 +#define VMA_SHARED VMA_SHARED17,364 +#define VMA_ANONYMOUS VMA_ANONYMOUS19,459 +#define VMA_PRIVATE VMA_PRIVATE21,521 +#define VMA_FIXED VMA_FIXED23,574 +#define VMA_GROWSDOWN VMA_GROWSDOWN25,651 +#define VM_DIRTY VM_DIRTY28,751 +struct fault_data {fault_data31,842 + fault_kdata_t *kdata; /* Generic data forged by the kernel */kdata32,862 + unsigned int reason; /* Generic fault reason flags */reason33,926 + unsigned int address; /* Aborted address */address34,982 + unsigned int pte_flags; /* Generic protection flags on pte */pte_flags35,1028 + l4id_t sender; /* Inittask-related fault data */sender36,1092 + +include/macros.h,201 +#define __TEST_MACROS_H____TEST_MACROS_H__2,26 +#define __INC_ARCH(__INC_ARCH4,53 +#define __INC_SUBARCH(__INC_SUBARCH5,94 +#define __INC_PLAT(__INC_PLAT6,149 +#define __INC_GLUE(__INC_GLUE7,198 + +include/timer.h,59 +#define __PERF_TESTS_TIMER_H____PERF_TESTS_TIMER_H__2,31 + +include/perf.h,740 +#define __PERF_TESTS_H____PERF_TESTS_H__2,25 +struct perfmon_cycles {perfmon_cycles9,192 + u64 last; /* Last op cycles */last10,216 + u64 min; /* Minimum cycles */min11,248 + u64 max; /* Max cycles */max12,279 + u64 avg; /* Average cycles */avg13,306 + u64 total; /* Total cycles */total14,337 + u64 ops; /* Total ops */ops15,368 +#define CORTEXA9_400MHZ_USEC CORTEXA9_400MHZ_USEC26,614 +#define CORTEXA9_400MHZ_MSEC CORTEXA9_400MHZ_MSEC27,654 +#define USEC_MULTIPLIER USEC_MULTIPLIER28,697 +#define MSEC_MULTIPLIER MSEC_MULTIPLIER29,743 +#define perfmon_record_cycles(perfmon_record_cycles34,832 +#define perfmon_record_cycles(perfmon_record_cycles38,919 +#define perfmon_checkpoint_cycles(perfmon_checkpoint_cycles50,1261 + +include/api/api.h,55 +#define __TEST_SUITE_API_H____TEST_SUITE_API_H__2,29 + +include/debug.h,432 +#define __ARCH_DEBUG_H____ARCH_DEBUG_H__7,111 +static inline u32 perfmon_read_cyccnt() { return 0; }perfmon_read_cyccnt14,250 +static inline void perfmon_reset_start_cyccnt() { }perfmon_reset_start_cyccnt16,305 +static inline u32 perfmon_read_reset_start_cyccnt() { return 0; }perfmon_read_reset_start_cyccnt17,357 +#define debug_record_cycles(debug_record_cycles19,424 +#define debug_record_cycles(debug_record_cycles33,763 + +include/tests.h,149 +#define __TESTS_H____TESTS_H__2,20 +#define DEBUG_TESTS DEBUG_TESTS5,74 +#define dbg_printf(dbg_printf7,112 +#define dbg_printf(dbg_printf9,162 + +include/linker.h,61 +#define __TEST_SUITE_LINKER_H____TEST_SUITE_LINKER_H__2,32 diff --git a/conts/test_suite0/TODO b/conts/baremetal/test_suite/TODO similarity index 100% rename from conts/test_suite0/TODO rename to conts/baremetal/test_suite/TODO diff --git a/conts/baremetal/test_suite/container.c b/conts/baremetal/test_suite/container.c index f570c3d..4b97317 100644 --- a/conts/baremetal/test_suite/container.c +++ b/conts/baremetal/test_suite/container.c @@ -6,7 +6,8 @@ #include #include - +#include +#include extern void main(void); @@ -15,6 +16,12 @@ void __container_init(void) /* Generic L4 initialisation */ __l4_init(); + /* Thread library initialisation */ + __l4_threadlib_init(); + + /* Capability library initialization */ + __l4_capability_init(); + /* Entry to main */ main(); } diff --git a/conts/test_suite0/exit.ct b/conts/baremetal/test_suite/exit.ct similarity index 100% rename from conts/test_suite0/exit.ct rename to conts/baremetal/test_suite/exit.ct diff --git a/conts/test_suite0/include/api/api.h b/conts/baremetal/test_suite/include/api/api.h similarity index 100% rename from conts/test_suite0/include/api/api.h rename to conts/baremetal/test_suite/include/api/api.h diff --git a/conts/test_suite0/include/debug.h b/conts/baremetal/test_suite/include/debug.h similarity index 100% rename from conts/test_suite0/include/debug.h rename to conts/baremetal/test_suite/include/debug.h diff --git a/conts/baremetal/test_suite/include/fault.h b/conts/baremetal/test_suite/include/fault.h new file mode 100644 index 0000000..5b92fe4 --- /dev/null +++ b/conts/baremetal/test_suite/include/fault.h @@ -0,0 +1,44 @@ +#ifndef __FAULT_H__ +#define __FAULT_H__ + +#include +#include +#include INC_GLUE(memory.h) +#include INC_ARCH(exception.h) + +/* Protection flags */ +#define VM_NONE (1 << 0) +#define VM_READ (1 << 1) +#define VM_EXEC (1 << 2) +#define VM_WRITE (1 << 3) +#define VM_PROT_MASK (VM_READ | VM_WRITE | VM_EXEC) + +/* Shared copy of a file */ +#define VMA_SHARED (1 << 4) +/* VMA that's not file-backed, always maps devzero as VMA_COW */ +#define VMA_ANONYMOUS (1 << 5) +/* Private copy of a file */ +#define VMA_PRIVATE (1 << 6) +/* For wired pages */ +#define VMA_FIXED (1 << 7) +/* For stack, where mmap returns end address */ +#define VMA_GROWSDOWN (1 << 8) + +/* Set when the page is dirty in cache but not written to disk */ +#define VM_DIRTY (1 << 9) + +/* Fault data specific to this task + ptr to kernel's data */ +struct fault_data { + fault_kdata_t *kdata; /* Generic data forged by the kernel */ + unsigned int reason; /* Generic fault reason flags */ + unsigned int address; /* Aborted address */ + unsigned int pte_flags; /* Generic protection flags on pte */ + l4id_t sender; /* Inittask-related fault data */ +}; + + +void set_generic_fault_params(struct fault_data *fault); +void arch_print_fault_params(struct fault_data *fault); +void fault_handle_error(struct fault_data *fault); + +#endif /* __FAULT_H__ */ diff --git a/conts/baremetal/test_suite/include/linker.h b/conts/baremetal/test_suite/include/linker.h new file mode 100644 index 0000000..099195f --- /dev/null +++ b/conts/baremetal/test_suite/include/linker.h @@ -0,0 +1,16 @@ +#ifndef __TEST_SUITE_LINKER_H__ +#define __TEST_SUITE_LINKER_H__ + +extern unsigned char __stack[]; +extern unsigned char __end[]; +extern unsigned char vma_start[]; +extern unsigned char lma_start[]; +extern unsigned char offset[]; +extern unsigned char __data_start[]; +extern unsigned char __data_end[]; +extern unsigned char __bss_start[]; +extern unsigned char __bss_end[]; +extern unsigned char __stack_start[]; +extern unsigned char __stack_end[]; + +#endif /* __LINKER_H__ */ diff --git a/conts/test_suite0/include/macros.h b/conts/baremetal/test_suite/include/macros.h similarity index 100% rename from conts/test_suite0/include/macros.h rename to conts/baremetal/test_suite/include/macros.h diff --git a/conts/baremetal/test_suite/include/memory.h b/conts/baremetal/test_suite/include/memory.h new file mode 100644 index 0000000..f126dea --- /dev/null +++ b/conts/baremetal/test_suite/include/memory.h @@ -0,0 +1,12 @@ +#ifndef __TESTSUITE_MEMORY_H__ +#define __TESTSUITE_MEMORY_H__ + + + +void *virtual_page_new(int npages); +void *physical_page_new(int npages); +void virtual_page_free(void *address, int npages); +void physical_page_free(void *address, int npages); + +void page_pool_init(void); +#endif /* __TESTSUITE_MEMORY_H__ */ diff --git a/conts/test_suite0/include/perf.h b/conts/baremetal/test_suite/include/perf.h similarity index 100% rename from conts/test_suite0/include/perf.h rename to conts/baremetal/test_suite/include/perf.h diff --git a/conts/test_suite0/include/project_linker.lds b/conts/baremetal/test_suite/include/project_linker.lds similarity index 100% rename from conts/test_suite0/include/project_linker.lds rename to conts/baremetal/test_suite/include/project_linker.lds diff --git a/conts/baremetal/test_suite/include/tests.h b/conts/baremetal/test_suite/include/tests.h index 43283a1..e3e9b0d 100644 --- a/conts/baremetal/test_suite/include/tests.h +++ b/conts/baremetal/test_suite/include/tests.h @@ -1,7 +1,18 @@ #ifndef __TESTS_H__ #define __TESTS_H__ +/* Abort debugging conditions */ +#define DEBUG_TESTS 0 +#if DEBUG_TESTS +#define dbg_printf(...) printf(__VA_ARGS__) +#else +#define dbg_printf(...) +#endif -int capability_test(void); +int test_smp(); +int test_performance(); +int test_api(); +int test_cli_serv(); +int test_mthread(); #endif /* __TESTS_H__ */ diff --git a/conts/test_suite0/include/timer.h b/conts/baremetal/test_suite/include/timer.h similarity index 86% rename from conts/test_suite0/include/timer.h rename to conts/baremetal/test_suite/include/timer.h index 06db1f6..3aca0f9 100644 --- a/conts/test_suite0/include/timer.h +++ b/conts/baremetal/test_suite/include/timer.h @@ -1,7 +1,7 @@ #ifndef __PERF_TESTS_TIMER_H__ #define __PERF_TESTS_TIMER_H__ -#include +#include extern unsigned long timer_base; void perf_timer_init(void); diff --git a/conts/baremetal/test_suite/main.c b/conts/baremetal/test_suite/main.c index d2ea465..0f3b445 100644 --- a/conts/baremetal/test_suite/main.c +++ b/conts/baremetal/test_suite/main.c @@ -3,62 +3,41 @@ * * Copyright (C) 2009 B Labs Ltd. */ -#include -#include -#include -#include #include #include L4LIB_INC_ARCH(syslib.h) #include L4LIB_INC_ARCH(syscalls.h) +#include +#include +#include #include +#include -int exit_test_thread(void *arg) +void run_tests(void) { - while (1) - ; - //l4_thread_switch(0); - //l4_exit(5); - return 0; -} - -int exit_test(void) -{ - int ret; - struct task_ids ids; - - /* Create and run a new thread */ - if ((ret = thread_create(exit_test_thread, 0, - TC_SHARE_SPACE | TC_AS_PAGER, - &ids)) < 0) { - printf("Top-level simple_pager creation failed.\n"); - goto out_err; - } else - printf("Thread (%d) created successfully.\n", ids.tid); - - // l4_thread_switch(0); - - /* Kill it */ - printf("Killing Thread (%d).\n", ids.tid); - if ((ret = l4_thread_control(THREAD_DESTROY, &ids)) < 0) - printf("Error: Killing Thread (%d), err = %d\n", ids.tid, ret); - else - printf("Success: Killed Thread (%d)\n", ids.tid); - - #if 0 - /* Wait on it */ - printf("Waiting on Thread (%d) to exit.\n", ids.tid); - if ((ret = l4_thread_control(THREAD_WAIT, &ids)) >= 0) - printf("Success. Paged child returned %d\n", ret); - else - printf("Error. Wait on (%d) failed. err = %d\n", - ids.tid, ret); - + /* Performance tests */ + if (test_performance() < 0) + printf("Performance tests failed.\n"); #endif - return 0; -out_err: - BUG(); + if (test_smp() < 0) + printf("SMP tests failed.\n"); + + /* API Tests */ + if (test_api() < 0) + printf("API tests failed.\n"); + + /* Container client/server setup test */ + if (test_cli_serv() < 0) + printf("Client/server tests failed.\n"); + + /* Container multithreaded/standalone setup test */ + if (test_mthread() < 0) + printf("Multi-threaded tests failed.\n"); + + /* Parent quits */ + printf("Test parent thread exiting...\n"); + thread_exit(0); } int main(void) @@ -66,15 +45,7 @@ int main(void) printf("%s: Container %s started\n", __CONTAINER__, __CONTAINER_NAME__); - capability_test(); - - //exit_test(); - - /* Now quit to demo self-paging quit */ - //l4_exit(0); - - /* Now quit by null pointer */ - // *((int *)0) = 5; + run_tests(); return 0; } diff --git a/conts/test_suite0/src/api/api.c b/conts/baremetal/test_suite/src/api/api.c similarity index 100% rename from conts/test_suite0/src/api/api.c rename to conts/baremetal/test_suite/src/api/api.c diff --git a/conts/test_suite0/src/api/cache.c b/conts/baremetal/test_suite/src/api/cache.c similarity index 100% rename from conts/test_suite0/src/api/cache.c rename to conts/baremetal/test_suite/src/api/cache.c diff --git a/conts/test_suite0/src/api/cap.c b/conts/baremetal/test_suite/src/api/cap.c similarity index 100% rename from conts/test_suite0/src/api/cap.c rename to conts/baremetal/test_suite/src/api/cap.c diff --git a/conts/test_suite0/src/api/exregs.c b/conts/baremetal/test_suite/src/api/exregs.c similarity index 100% rename from conts/test_suite0/src/api/exregs.c rename to conts/baremetal/test_suite/src/api/exregs.c diff --git a/conts/test_suite0/src/api/getid.c b/conts/baremetal/test_suite/src/api/getid.c similarity index 100% rename from conts/test_suite0/src/api/getid.c rename to conts/baremetal/test_suite/src/api/getid.c diff --git a/conts/test_suite0/src/api/ipc.c b/conts/baremetal/test_suite/src/api/ipc.c similarity index 100% rename from conts/test_suite0/src/api/ipc.c rename to conts/baremetal/test_suite/src/api/ipc.c diff --git a/conts/test_suite0/src/api/irq.c b/conts/baremetal/test_suite/src/api/irq.c similarity index 100% rename from conts/test_suite0/src/api/irq.c rename to conts/baremetal/test_suite/src/api/irq.c diff --git a/conts/test_suite0/src/api/map.c b/conts/baremetal/test_suite/src/api/map.c similarity index 72% rename from conts/test_suite0/src/api/map.c rename to conts/baremetal/test_suite/src/api/map.c index d6f848e..d4d2a83 100644 --- a/conts/test_suite0/src/api/map.c +++ b/conts/baremetal/test_suite/src/api/map.c @@ -27,8 +27,8 @@ int test_api_map(void) * Make a valid mapping, a few pages below * the end of physical and virtual marks */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, MAP_USR_RW, self)) < 0) { @@ -40,8 +40,8 @@ int test_api_map(void) /* * Redo the same mapping. This should be valid. */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, MAP_USR_RW, self)) < 0) { @@ -53,8 +53,8 @@ int test_api_map(void) /* * Try mapping outside the virtual range */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END, 1, MAP_USR_RW, self)) == 0) { @@ -66,8 +66,8 @@ int test_api_map(void) /* * Try mapping outside the physical range */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, MAP_USR_RW, self)) == 0) { @@ -79,8 +79,8 @@ int test_api_map(void) /* * Try having them both out of range */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END, - (void *)CONFIG_CONT0_VIRT0_END, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END, + (void *)CONFIG_CONT0_PAGER_VIRT0_END, 1, MAP_USR_RW, self)) == 0) { @@ -93,8 +93,8 @@ int test_api_map(void) /* * Try out of range by off-by-one page size excess */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 6, MAP_USR_RW, self)) == 0) { @@ -108,8 +108,8 @@ int test_api_map(void) /* * Try invalid page size */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 0xFFFFFFFF, MAP_USR_RW, self)) == 0) { @@ -122,8 +122,8 @@ int test_api_map(void) * Try invalid flags */ flags = 0; - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, flags, self)) == 0) { @@ -132,8 +132,8 @@ int test_api_map(void) return -1; } flags = MAP_KERN_RWX; - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, 0, self)) == 0) { @@ -142,8 +142,8 @@ int test_api_map(void) return -1; } flags = MAP_KERN_IO; - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, 0, self)) == 0) { @@ -153,8 +153,8 @@ int test_api_map(void) } flags = MAP_KERN_RX; - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, 0, self)) == 0) { @@ -164,8 +164,8 @@ int test_api_map(void) } flags = 0xF0F0F01; - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, 0, self)) == 0) { @@ -178,7 +178,7 @@ int test_api_map(void) * Try passing wraparound values */ if ((err = l4_map((void *)0xFFFFFFFF, - (void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + (void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, MAP_USR_RW, self)) == 0) { @@ -190,7 +190,7 @@ int test_api_map(void) /* * Try passing wraparound values */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, (void *)0xFFFFF000, 2, MAP_USR_RW, @@ -203,7 +203,7 @@ int test_api_map(void) /* * Try mapping onto kernel */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, (void *)0xF0000000, 1, MAP_USR_RW, @@ -216,7 +216,7 @@ int test_api_map(void) /* * Try mapping to vector page */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, (void *)0xFFFF0000, 1, MAP_USR_RW, @@ -229,7 +229,7 @@ int test_api_map(void) /* * Try mapping to kip */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, (void *)0xFF000000, 1, MAP_USR_RW, @@ -242,7 +242,7 @@ int test_api_map(void) /* * Try mapping to syscall page */ - if ((err = l4_map((void *)CONFIG_CONT0_PHYS0_END - PAGE_SIZE * 5, + if ((err = l4_map((void *)CONFIG_CONT0_PAGER_PHYS0_END - PAGE_SIZE * 5, (void *)0xFFFFF000, 1, MAP_USR_RW, @@ -264,7 +264,7 @@ int test_api_unmap(void) /* * Try a valid unmap */ - if ((err = l4_unmap((void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_unmap((void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, self)) < 0) { dbg_printf("sys_unmap failed on valid request. err=%d\n", @@ -275,7 +275,7 @@ int test_api_unmap(void) /* * Try the same unmap, should return ENOMAP */ - if ((err = l4_unmap((void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_unmap((void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, self)) != -ENOMAP) { dbg_printf("sys_unmap did not return ENOMAP " @@ -314,7 +314,7 @@ int test_api_unmap(void) "unmap region. err=%d\n", err); return -1; } - if ((err = l4_unmap((void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_unmap((void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 0xFFFFFFFF, self)) == 0) { dbg_printf("sys_unmap succeeded on invalid " "unmap region. err=%d\n", err); @@ -324,7 +324,7 @@ int test_api_unmap(void) /* * Try unmapping zero pages */ - if ((err = l4_unmap((void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_unmap((void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 0, self)) == 0) { dbg_printf("sys_unmap succeeded on invalid " "unmap region. err=%d\n", err); @@ -334,7 +334,7 @@ int test_api_unmap(void) /* * Try unmapping with invalid id */ - if ((err = l4_unmap((void *)CONFIG_CONT0_VIRT0_END - PAGE_SIZE * 5, + if ((err = l4_unmap((void *)CONFIG_CONT0_PAGER_VIRT0_END - PAGE_SIZE * 5, 1, 0xFFFFFFFF)) == 0) { dbg_printf("sys_unmap succeeded on invalid " "unmap region. err=%d\n", err); diff --git a/conts/baremetal/test_suite/src/api/memory.c b/conts/baremetal/test_suite/src/api/memory.c new file mode 100644 index 0000000..82797e5 --- /dev/null +++ b/conts/baremetal/test_suite/src/api/memory.c @@ -0,0 +1,198 @@ +/* + * Empty virtual and physical pages for + * creating test scenarios + * + * Copyright (C) 2010 B Labs Ltd. + * + * Author: Bahadir Balban + */ +#include +#include INC_GLUE(memory.h) +#include +#include +#include +#include +#include +#include +#include + +/* + * Declare a statically allocated char buffer + * with enough bitmap size to cover given size + */ +#define DECLARE_IDPOOL(name, size) \ + char name[(sizeof(struct id_pool) + ((size >> 12) >> 3))] + +struct address_pool virtual_page_pool, physical_page_pool; + +#define PAGE_POOL_SIZE SZ_16MB + +DECLARE_IDPOOL(virtual_idpool, PAGE_POOL_SIZE); +DECLARE_IDPOOL(physical_idpool, PAGE_POOL_SIZE); + +#define virt_to_phys(virtual) ((unsigned long)(virtual) - (unsigned long)(offset)) +#define phys_to_virt(physical) ((unsigned long)(physical) + (unsigned long)(offset)) + + +#define TEST_POOL_TOTAL 5 +/* + * Test page pool + */ +void test_page_pool(void) +{ + void *p[TEST_POOL_TOTAL], *v[TEST_POOL_TOTAL]; + + /* Allocate test pages */ + for (int i = 0; i < TEST_POOL_TOTAL; i++) { + v[i] = virtual_page_new(1); + p[i] = physical_page_new(1); + dbg_printf("Test allocated: Virtual%d: 0x%p, " + "Physical%d, 0x%p\n", + i, v[i], i, p[i]); + } + + /* Free test pages */ + for (int i = 0; i < TEST_POOL_TOTAL; i++) { + virtual_page_free(v[i], 1); + physical_page_free(p[i], 1); + } + + /* Re-allocate test pages */ + for (int i = 0; i < TEST_POOL_TOTAL; i++) { + v[i] = virtual_page_new(1); + p[i] = physical_page_new(1); + dbg_printf("Test allocated: Virtual%d: 0x%p, " + "Physical%d, 0x%p\n", + i, v[i], i, p[i]); + } + + /* Free test pages */ + for (int i = 0; i < TEST_POOL_TOTAL; i++) { + virtual_page_free(v[i], 1); + physical_page_free(p[i], 1); + } + + /* Allocate in different lengths */ + for (int i = 0; i < TEST_POOL_TOTAL; i++) { + v[i] = virtual_page_new(i); + p[i] = physical_page_new(i); + dbg_printf("Test allocated: Virtual%d: 0x%p, " + "Physical%d, 0x%p\n", + i, v[i], i, p[i]); + } + + /* Free test pages in different order */ + for (int i = TEST_POOL_TOTAL - 1; i >= 0; i--) { + virtual_page_free(v[i], 1); + physical_page_free(p[i], 1); + } + + /* Allocate in different lengths */ + for (int i = 0; i < TEST_POOL_TOTAL; i++) { + v[i] = virtual_page_new(i); + p[i] = physical_page_new(i); + dbg_printf("Test allocated: Virtual%d: 0x%p, " + "Physical%d, 0x%p\n", + i, v[i], i, p[i]); + } + + /* Free test pages in normal order */ + for (int i = 0; i < TEST_POOL_TOTAL; i++) { + virtual_page_free(v[i], 1); + physical_page_free(p[i], 1); + } +} + +void page_pool_init(void) +{ + struct capability *physcap, *virtcap; + unsigned long phys_start, phys_end; + unsigned long virt_start, virt_end; + + /* + * Get physmem capability (Must be only one) + */ + if (!(physcap = cap_get_physmem(CAP_TYPE_MAP_PHYSMEM))) { + printf("FATAL: Could not find a physical memory" + "capability to use as a page pool.\n"); + BUG(); + } + + /* + * Get virtmem capability (Must be only one) + */ + if (!(virtcap = cap_get_by_type(CAP_TYPE_MAP_VIRTMEM))) { + printf("FATAL: Could not find a virtual memory" + "capability to use as a page pool.\n"); + BUG(); + } + + /* + * Now initialize physical and virtual page marks + * from unused pages. Linker script will help us + * on this. + */ + /* + printf("__data_start symbol: %lx\n", (unsigned long)__data_start); + printf("__data_end symbol: %lx\n", (unsigned long)__data_end); + printf("__bss_start symbol: %lx\n", (unsigned long)__bss_start); + printf("__bss_end symbol: %lx\n", (unsigned long)__bss_end); + printf("__stack_start symbol: %lx\n", (unsigned long)__stack_start); + printf("__stack_end symbol: %lx\n", (unsigned long)__stack_end); + printf("__end symbol: %lx\n", (unsigned long)__end); + */ + + phys_start = page_align_up(virt_to_phys(__end) + + (unsigned long)lma_start); + phys_end = __pfn_to_addr(physcap->end); + + dbg_printf("%s: Initializing physical range 0x%lx - 0x%lx\n", + __FUNCTION__, phys_start, phys_end); + + virt_start = page_align_up(__end) + (unsigned long)lma_start; + virt_end = __pfn_to_addr(virtcap->end); + + dbg_printf("%s: Initializing virtual range 0x%lx - 0x%lx\n", + __FUNCTION__, virt_start, virt_end); + + /* Initialize pools, maximum of PAGE_POOL_SIZE size */ + address_pool_init(&virtual_page_pool, + (struct id_pool *)&virtual_idpool, + virt_start, min(virt_end, + virt_start + PAGE_POOL_SIZE)); + address_pool_init(&physical_page_pool, + (struct id_pool *)&physical_idpool, + phys_start, min(phys_end, + phys_start + PAGE_POOL_SIZE)); + + // test_page_pool(); +} + +/* + * Some tests require page-faulting virtual addresses or + * differing virtual addresses that map onto the same + * physical page. These functions provide these pages. + */ + +void *virtual_page_new(int npages) +{ + return address_new(&virtual_page_pool, npages, PAGE_SIZE); +} + +void *physical_page_new(int npages) +{ + return address_new(&physical_page_pool, npages, PAGE_SIZE); +} + +void virtual_page_free(void *address, int npages) +{ + address_del(&virtual_page_pool, address, + npages, PAGE_SIZE); +} + +void physical_page_free(void *address, int npages) +{ + address_del(&physical_page_pool, address, + npages, PAGE_SIZE); +} + diff --git a/conts/baremetal/test_suite/src/api/mutex.c b/conts/baremetal/test_suite/src/api/mutex.c new file mode 100644 index 0000000..4d643cf --- /dev/null +++ b/conts/baremetal/test_suite/src/api/mutex.c @@ -0,0 +1,204 @@ +/* + * Test l4_mutex_control system call. + * + * Copyright (C) 2010 B Labs Ltd. + * + * Author: Bahadir Balban + */ + +#include +#include L4LIB_INC_ARCH(syslib.h) +#include L4LIB_INC_ARCH(syscalls.h) +#include +#include +#include + +#define MUTEX_NTHREADS 8 +#define MUTEX_INCREMENTS 200 +#define MUTEX_VALUE_TOTAL (MUTEX_NTHREADS * MUTEX_INCREMENTS) + +struct mutex_test_data { + struct l4_mutex lock; + int val; +}; + +static struct mutex_test_data tdata; + +static void init_test_data(struct mutex_test_data *tdata) +{ + l4_mutex_init(&tdata->lock); + tdata->val = 0; +} + + +int mutex_thread_non_contending(void *arg) +{ + struct mutex_test_data *data = + (struct mutex_test_data *)arg; + l4id_t tid = self_tid(); + int err = tid; + + for (int i = 0; i < MUTEX_INCREMENTS; i++) { + /* Lock the data structure */ + if ((err = l4_mutex_lock(&data->lock)) < 0) { + dbg_printf("Thread %d: Acquiring mutex failed. " + "err = %d\n", tid, err); + return -err; + } + + /* + * Increment and release lock + */ + data->val++; + + /* Unlock the data structure */ + if ((err = l4_mutex_unlock(&data->lock)) < 0) { + dbg_printf("Thread %d: Releasing the mutex failed. " + "err = %d\n", tid, err); + return -err; + } + } + + return 0; +} + + + +int mutex_thread_contending(void *arg) +{ + struct mutex_test_data *data = + (struct mutex_test_data *)arg; + l4id_t tid = self_tid(); + int err = tid; + + for (int i = 0; i < MUTEX_INCREMENTS; i++) { + /* Lock the data structure */ + if ((err = l4_mutex_lock(&data->lock)) < 0) { + dbg_printf("Thread %d: Acquiring mutex failed. " + "err = %d\n", tid, err); + return -err; + } + + /* + * Sleep some time to have some + * threads blocked on the mutex + */ + for (int j = 0; j < 3; j++) + l4_thread_switch(0); + + /* + * Increment and release lock + */ + data->val++; + + /* Unlock the data structure */ + if ((err = l4_mutex_unlock(&data->lock)) < 0) { + dbg_printf("Thread %d: Releasing the mutex failed. " + "err = %d\n", tid, err); + return -err; + } + } + + return 0; +} + + +int test_mutex(int (*mutex_thread)(void *)) +{ + struct l4_thread *thread[MUTEX_NTHREADS]; + int err; + + /* Init mutex data */ + init_test_data(&tdata); + + /* + * Lock the mutex so nobody starts working + */ + if ((err = l4_mutex_lock(&tdata.lock)) < 0) { + dbg_printf("Acquiring mutex failed. " + "err = %d\n", err); + return err; + } + + /* Create threads */ + for (int i = 0; i < MUTEX_NTHREADS; i++) { + if ((err = thread_create(mutex_thread, + &tdata, + TC_SHARE_SPACE, + &thread[i])) < 0) { + dbg_printf("Thread create failed. " + "err=%d\n", err); + return err; + } + } + + /* Unlock the mutex and initiate all workers */ + if ((err = l4_mutex_unlock(&tdata.lock)) < 0) { + dbg_printf("Releasing the mutex failed. " + "err = %d\n", err); + return -err; + } + + /* + * Wait for all threads to exit successfully + */ + for (int i = 0; i < MUTEX_NTHREADS; i++) { + if ((err = thread_wait(thread[i])) < 0) { + dbg_printf("THREAD_WAIT failed. " + "err=%d\n", err); + return err; + } + } + + /* + * Test that lock is in correct state + */ + if (tdata.lock.lock != L4_MUTEX_UNLOCKED) { + dbg_printf("MUTEX is not in unlocked condition " + "after tests. lockval = %d, expected = %d\n", + tdata.lock.lock, L4_MUTEX_UNLOCKED); + return -1; + } + + /* + * Test that increments have occured correctly + */ + if (tdata.val != MUTEX_VALUE_TOTAL) { + dbg_printf("Lock-protected value incremented incorrectly " + "after mutex worker threads.\n" + "val = %d, expected = %d\n", + tdata.val, + MUTEX_VALUE_TOTAL); + return -1; + } + if (tdata.val != MUTEX_VALUE_TOTAL) { + dbg_printf("Lock-protected value incremented incorrectly " + "after mutex worker threads.\n" + "val = %d, expected = %d\n", + tdata.val, + MUTEX_VALUE_TOTAL); + return -1; + } + + dbg_printf("Mutex test successful.\n"); + return 0; +} + +int test_api_mutexctrl(void) +{ + int err; + + if ((err = test_mutex(mutex_thread_contending)) < 0) + goto out_err; + + if ((err = test_mutex(mutex_thread_non_contending)) < 0) + goto out_err; + + printf("USERSPACE MUTEX: -- PASSED --\n"); + return 0; + +out_err: + printf("USERSPACE MUTEX: -- FAILED --\n"); + return err; +} + diff --git a/conts/test_suite0/src/api/smp.c b/conts/baremetal/test_suite/src/api/smp.c similarity index 100% rename from conts/test_suite0/src/api/smp.c rename to conts/baremetal/test_suite/src/api/smp.c diff --git a/conts/test_suite0/src/api/thread.c b/conts/baremetal/test_suite/src/api/thread.c similarity index 100% rename from conts/test_suite0/src/api/thread.c rename to conts/baremetal/test_suite/src/api/thread.c diff --git a/conts/baremetal/test_suite/src/arch b/conts/baremetal/test_suite/src/arch deleted file mode 120000 index 85405c2..0000000 --- a/conts/baremetal/test_suite/src/arch +++ /dev/null @@ -1 +0,0 @@ -arch-arm \ No newline at end of file diff --git a/conts/test_suite0/src/arch/arm/v5/mm.c b/conts/baremetal/test_suite/src/arch/arm/v5/mm.c similarity index 91% rename from conts/test_suite0/src/arch/arm/v5/mm.c rename to conts/baremetal/test_suite/src/arch/arm/v5/mm.c index c246aa3..c05bf60 100644 --- a/conts/test_suite0/src/arch/arm/v5/mm.c +++ b/conts/baremetal/test_suite/src/arch/arm/v5/mm.c @@ -3,10 +3,11 @@ * * Copyright (C) 2008 - 2010 B Labs Ltd. */ -#include -#include +#include #include -#include __INC_ARCH(mm.h) +#include +#include INC_SUBARCH(mm.h) +#include INC_SUBARCH(exception.h) /* Extracts generic protection flags from architecture-specific pte */ unsigned int vm_prot_flags(pte_t pte) @@ -60,6 +61,6 @@ void set_generic_fault_params(struct fault_data *fault) else BUG(); } - arch_print_fault_params(fault); + // arch_print_fault_params(fault); } diff --git a/conts/test_suite0/src/arch/arm/v7/mm.c b/conts/baremetal/test_suite/src/arch/arm/v7/mm.c similarity index 100% rename from conts/test_suite0/src/arch/arm/v7/mm.c rename to conts/baremetal/test_suite/src/arch/arm/v7/mm.c diff --git a/conts/baremetal/test_suite/src/capability.c b/conts/baremetal/test_suite/src/capability.c index 970e26a..95b96ff 100644 --- a/conts/baremetal/test_suite/src/capability.c +++ b/conts/baremetal/test_suite/src/capability.c @@ -4,13 +4,13 @@ * Copyright (C) 2009 B Labs Ltd. */ #include -#include +#include #include #include L4LIB_INC_ARCH(syscalls.h) +#if 0 static struct capability cap_array[30]; -#if 0 struct cap_group { struct cap_list virtmem; struct cap_list physmem; @@ -75,7 +75,6 @@ void cap_grant_single(struct capability *orig, struct capability *share, l4id_t { } -#endif int caps_read_all(void) { @@ -104,3 +103,4 @@ int caps_read_all(void) return 0; } +#endif diff --git a/conts/baremetal/test_suite/src/captest.c b/conts/baremetal/test_suite/src/captest.c index 27c50e0..94b9365 100644 --- a/conts/baremetal/test_suite/src/captest.c +++ b/conts/baremetal/test_suite/src/captest.c @@ -19,8 +19,7 @@ int simple_pager_thread(void *arg) printf("Thread spawned from pager, \ trying to create new thread.\n"); err = l4_thread_control(THREAD_CREATE | - TC_SHARE_SPACE | - TC_AS_PAGER, &ids); + TC_SHARE_SPACE, &ids); if (res == 0) if (err == -ENOCAP || diff --git a/conts/test_suite0/src/cli_serv/cli_serv.c b/conts/baremetal/test_suite/src/cli_serv/cli_serv.c similarity index 100% rename from conts/test_suite0/src/cli_serv/cli_serv.c rename to conts/baremetal/test_suite/src/cli_serv/cli_serv.c diff --git a/conts/test_suite0/src/mthread/mthread.c b/conts/baremetal/test_suite/src/mthread/mthread.c similarity index 100% rename from conts/test_suite0/src/mthread/mthread.c rename to conts/baremetal/test_suite/src/mthread/mthread.c diff --git a/conts/test_suite0/src/perf/cycles.c b/conts/baremetal/test_suite/src/perf/cycles.c similarity index 100% rename from conts/test_suite0/src/perf/cycles.c rename to conts/baremetal/test_suite/src/perf/cycles.c diff --git a/conts/test_suite0/src/perf/exregs.c b/conts/baremetal/test_suite/src/perf/exregs.c similarity index 100% rename from conts/test_suite0/src/perf/exregs.c rename to conts/baremetal/test_suite/src/perf/exregs.c diff --git a/conts/test_suite0/src/perf/getid.c b/conts/baremetal/test_suite/src/perf/getid.c similarity index 89% rename from conts/test_suite0/src/perf/getid.c rename to conts/baremetal/test_suite/src/perf/getid.c index 5aacd09..8cb0272 100644 --- a/conts/test_suite0/src/perf/getid.c +++ b/conts/baremetal/test_suite/src/perf/getid.c @@ -39,7 +39,6 @@ void perf_measure_getid_ticks(void) timer_load(timer_ldval, timer_base); /* Start the timer */ - printf("Starting the l4_getid timer tick test.\n"); timer_start(timer_base); /* Do the operation */ @@ -56,7 +55,7 @@ void perf_measure_getid_ticks(void) total += last; } - printf("TIMER: l4_getid took each %u min, %u max, %u avg,\n" + printf("L4_GETID(timer) took each %u min, %u max, %u avg, " "%u total microseconds, and %u total ops\n", min, max, total/ops, total, ops); } @@ -77,7 +76,6 @@ void perf_measure_getid(void) /* * Do the test */ - printf("Starting the l4_getid cycle counter test.\n"); for (int i = 0; i < PERFTEST_GETID_COUNT; i++) { perfmon_reset_start_cyccnt(); l4_getid(&ids); @@ -93,9 +91,9 @@ void perf_measure_getid(void) /* * Print results */ - printf("PERFMON: %s took %llu min, %llu max, %llu avg, " + printf("L4_GETID (cycle counter): took %llu cycles, %llu min, %llu max, %llu avg, " "%llu total microseconds in %llu ops.\n", - "l4_getid()", + l4_getid_cycles.min, l4_getid_cycles.min * USEC_MULTIPLIER, l4_getid_cycles.max * USEC_MULTIPLIER, l4_getid_cycles.avg * USEC_MULTIPLIER, diff --git a/conts/test_suite0/src/perf/ipc.c b/conts/baremetal/test_suite/src/perf/ipc.c similarity index 100% rename from conts/test_suite0/src/perf/ipc.c rename to conts/baremetal/test_suite/src/perf/ipc.c diff --git a/conts/test_suite0/src/perf/map.c b/conts/baremetal/test_suite/src/perf/map.c similarity index 100% rename from conts/test_suite0/src/perf/map.c rename to conts/baremetal/test_suite/src/perf/map.c diff --git a/conts/test_suite0/src/perf/mutex.c b/conts/baremetal/test_suite/src/perf/mutex.c similarity index 99% rename from conts/test_suite0/src/perf/mutex.c rename to conts/baremetal/test_suite/src/perf/mutex.c index f7a8140..0c1c6f3 100644 --- a/conts/test_suite0/src/perf/mutex.c +++ b/conts/baremetal/test_suite/src/perf/mutex.c @@ -8,4 +8,5 @@ void perf_measure_mutex(void) { + } diff --git a/conts/test_suite0/src/perf/perf.c b/conts/baremetal/test_suite/src/perf/perf.c similarity index 95% rename from conts/test_suite0/src/perf/perf.c rename to conts/baremetal/test_suite/src/perf/perf.c index aedd6c5..4513891 100644 --- a/conts/test_suite0/src/perf/perf.c +++ b/conts/baremetal/test_suite/src/perf/perf.c @@ -20,6 +20,7 @@ int test_performance(void) perf_measure_getid_ticks(); perf_measure_getid(); + perf_measure_tswitch(); perf_measure_tctrl(); perf_measure_exregs(); perf_measure_ipc(); diff --git a/conts/test_suite0/src/perf/simple.c b/conts/baremetal/test_suite/src/perf/simple.c similarity index 100% rename from conts/test_suite0/src/perf/simple.c rename to conts/baremetal/test_suite/src/perf/simple.c diff --git a/conts/test_suite0/src/perf/tctrl.c b/conts/baremetal/test_suite/src/perf/tctrl.c similarity index 94% rename from conts/test_suite0/src/perf/tctrl.c rename to conts/baremetal/test_suite/src/perf/tctrl.c index 9ab1e31..875c409 100644 --- a/conts/test_suite0/src/perf/tctrl.c +++ b/conts/baremetal/test_suite/src/perf/tctrl.c @@ -51,8 +51,9 @@ void perf_measure_tctrl(void) /* * Print results */ - printf("%s took %llu min, %llu max, %llu avg, in %llu ops.\n", + printf("%s took %llu cycles, %llu min, %llu max, %llu avg, in %llu ops.\n", "THREAD_CREATE", + tctrl_cycles.min, tctrl_cycles.min * USEC_MULTIPLIER, tctrl_cycles.max * USEC_MULTIPLIER, tctrl_cycles.avg * USEC_MULTIPLIER, diff --git a/conts/test_suite0/src/perf/timer.c b/conts/baremetal/test_suite/src/perf/timer.c similarity index 93% rename from conts/test_suite0/src/perf/timer.c rename to conts/baremetal/test_suite/src/perf/timer.c index 1c6eb14..f9c2edf 100644 --- a/conts/test_suite0/src/perf/timer.c +++ b/conts/baremetal/test_suite/src/perf/timer.c @@ -11,7 +11,6 @@ #include L4LIB_INC_ARCH(syslib.h) #include L4LIB_INC_ARCH(syscalls.h) -/* Note this must be obtained from the capability */ #define TIMER_PHYSICAL_BASE 0x10012000 unsigned long timer_base; diff --git a/conts/baremetal/test_suite/src/perf/tswitch.c b/conts/baremetal/test_suite/src/perf/tswitch.c new file mode 100644 index 0000000..037caa2 --- /dev/null +++ b/conts/baremetal/test_suite/src/perf/tswitch.c @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2010 B Labs Ltd. + * + * l4_thread_control performance tests + * + * Author: Bahadir Balban + */ + +#include +#include L4LIB_INC_ARCH(syslib.h) +#include L4LIB_INC_ARCH(syscalls.h) +#include +#include +#include +#include +#include + +struct perfmon_cycles thread_switch_cycles; +struct perfmon_cycles space_switch_cycles; + +static int indicate_switch = 0; + +void thread_switcher_thread(void *arg) +{ + l4id_t parent = ((struct task_ids *)arg)->tid; + + printf("%s: Running\n", __FUNCTION__); + /* Wait until parent signals us to switch */ + while (!indicate_switch) + l4_thread_switch(parent); + + /* + * Now do one last switch, which will + * be used in the actual switch measurement + */ + l4_thread_switch(parent); +} + +void perf_measure_thread_switch_simple(void) +{ + struct task_ids thread_switcher; + struct task_ids selfid; + l4_getid(&selfid); + + /* + * Initialize structures + */ + memset(&thread_switch_cycles, 0, sizeof (struct perfmon_cycles)); + thread_switch_cycles.min = ~0; /* Init as maximum possible */ + + /* Start the counter */ + perfmon_reset_start_cyccnt(); + + l4_thread_switch(0); + + perfmon_record_cycles(&thread_switch_cycles, "THREAD_SWITCH"); + + /* + * Calculate average + */ + thread_switch_cycles.avg = + thread_switch_cycles.total / thread_switch_cycles.ops; + + /* + * Print results + */ + printf("%s took %llu cycles, %llu min, %llu max, %llu avg, in %llu ops.\n", + "THREAD_SWITCH", + thread_switch_cycles.min, + thread_switch_cycles.min * USEC_MULTIPLIER, + thread_switch_cycles.max * USEC_MULTIPLIER, + thread_switch_cycles.avg * USEC_MULTIPLIER, + thread_switch_cycles.ops); +} + +void perf_measure_thread_switch(void) +{ + struct task_ids thread_switcher; + struct task_ids selfid; + l4_getid(&selfid); + + /* + * Initialize structures + */ + memset(&thread_switch_cycles, 0, sizeof (struct perfmon_cycles)); + thread_switch_cycles.min = ~0; /* Init as maximum possible */ + + /* Create switcher thread */ + l4_thread_control(THREAD_CREATE | TC_SHARE_SPACE, &selfid); + + /* Copy ids of created task */ + memcpy(&thread_switcher, &selfid, sizeof(struct task_ids)); + + /* Switch to the thread to ensure it runs at least once */ + l4_thread_switch(thread_switcher.tid); + + /* Start the counter */ + perfmon_reset_start_cyccnt(); + + /* Set the switch indicator */ + indicate_switch = 1; + + /* + * Switch to thread. + * + * We should be in full control here, because + * the thread must have run out of its time slices. + */ + l4_thread_switch(thread_switcher.tid); + + /* + * By this time, the switcher thread must have done a + * thread switch back to us + */ + perfmon_record_cycles(&thread_switch_cycles, "THREAD_SWITCH"); + + /* + * Calculate average + */ + thread_switch_cycles.avg = + thread_switch_cycles.total / thread_switch_cycles.ops; + + /* + * Print results + */ + printf("%s took %llu cycles, %llu min, %llu max, %llu avg, in %llu ops.\n", + "THREAD_SWITCH", + thread_switch_cycles.min, + thread_switch_cycles.min * USEC_MULTIPLIER, + thread_switch_cycles.max * USEC_MULTIPLIER, + thread_switch_cycles.avg * USEC_MULTIPLIER, + thread_switch_cycles.ops); + + + /* Destroy the thread */ + l4_thread_control(THREAD_DESTROY, &thread_switcher); +} + + +void perf_measure_space_switch(void) +{ + +} + + +void perf_measure_tswitch(void) +{ + perf_measure_thread_switch_simple(); + perf_measure_space_switch(); +} diff --git a/conts/test_suite0/tests_howto.txt b/conts/baremetal/test_suite/tests_howto.txt similarity index 100% rename from conts/test_suite0/tests_howto.txt rename to conts/baremetal/test_suite/tests_howto.txt diff --git a/conts/baremetal/threads_demo/SConscript b/conts/baremetal/threads_demo/SConscript new file mode 100644 index 0000000..062d7f2 --- /dev/null +++ b/conts/baremetal/threads_demo/SConscript @@ -0,0 +1,11 @@ + +# Inherit global environment +Import('env') + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/threads_demo/SConstruct b/conts/baremetal/threads_demo/SConstruct index 01d8caf..83ebc21 100644 --- a/conts/baremetal/threads_demo/SConstruct +++ b/conts/baremetal/threads_demo/SConstruct @@ -4,62 +4,54 @@ # # Copyright © 2009 B Labs Ltd # -import os, shelve, sys +import os, sys from os.path import * -PROJRELROOT = '../..' +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.conts.containers import * +from scripts.config.configuration import * config = configuration_retrieve() -platform = config.platform -arch = config.arch gcc_arch_flag = config.gcc_arch_flag -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) +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) -# 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)] +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) -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')] - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], - LINKFLAGS = ['-nostdlib', '-T' + "include/linker.lds", "-u_start"], - ASFLAGS = ['-D__ASSEMBLY__'], + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + 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 = ['libl4', 'libmalloc', '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, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + LIBS = ['gcc', 'libl4', 'c-userspace', 'libdev-userspace', + 'libmem', 'gcc', 'c-userspace'], + # libgcc.a - This is required for division routines. + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h \ + -include l4/types.h -include l4lib/macros.h') -src = Glob('*.[cS]') -src += Glob('src/*.[cS]') +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) -objs = env.Object(src) -prog = env.Program('main.elf', objs) -Depends(prog, 'include/linker.lds') +Depends(objs, join(PROJROOT, CONFIG_H)) + +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/baremetal/threads_demo/thread.c b/conts/baremetal/threads_demo/thread.c new file mode 100644 index 0000000..13c5ec9 --- /dev/null +++ b/conts/baremetal/threads_demo/thread.c @@ -0,0 +1,108 @@ +/* + * Test l4_mutex_control system call. + * + * Copyright (C) 2010 B Labs Ltd. + * + * Author: Bahadir Balban + */ + +#include +#include L4LIB_INC_ARCH(syslib.h) +#include L4LIB_INC_ARCH(syscalls.h) +#include + +#define NTHREADS 6 +#define dbg_printf printf + +int thread_test_func1(void *arg) +{ + l4id_t tid = self_tid(); + + printf("tid = %d is called.\n", tid); + + /* Wait for a while before exiting */ + int j = 0x400000; + while (j--) + ; + + return tid; +} + + + +int thread_test_func2(void *arg) +{ + l4id_t tid = self_tid(); + + printf("tid = %d is called.\n", tid); + + /* Wait for a while before exiting */ + int j = 0x400000; + while (j--) + ; + + thread_exit(0); + + return 0; +} + + +int thread_demo() +{ + struct l4_thread *thread[NTHREADS]; + int err; + + /* Create threads */ + for (int i = 0; i < NTHREADS; i++) { + if (i % 2 ) { + err = thread_create(thread_test_func1, 0, + TC_SHARE_SPACE, &thread[i]); + + if (err < 0) { + dbg_printf("Thread create failed. " + "err=%d i= %d\n", err, i); + return err; + } + } else { + err = thread_create(thread_test_func2, 0, + TC_SHARE_SPACE, &thread[i]); + if (err < 0) { + dbg_printf("Thread create failed. " + "err=%d i= %d\n", err, i); + return err; + } + } + } + + /* + * Wait for all threads to exit successfully + */ + for (int i = 0; i < NTHREADS; i++) { + if ((err = thread_wait(thread[i])) < 0) { + dbg_printf("THREAD_WAIT failed. " + "err=%d\n", err); + return err; + } + } + + dbg_printf("Thread test successful.\n"); + return 0; +} + +int main(void) +{ + int err; + + __l4_threadlib_init(); + + if ((err = thread_demo()) < 0) + goto out_err; + + printf("THREAD DEMO: -- PASSED --\n"); + return 0; + +out_err: + printf("THREAD DEMO: -- FAILED --\n"); + return err; +} + diff --git a/conts/baremetal/timer_service/SConscript b/conts/baremetal/timer_service/SConscript new file mode 100644 index 0000000..23d3709 --- /dev/null +++ b/conts/baremetal/timer_service/SConscript @@ -0,0 +1,12 @@ + +# Inherit global environment +Import('env') + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') +src_local += Glob('src/arch/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/timer_service/SConstruct b/conts/baremetal/timer_service/SConstruct index 7fed797..e379a6e 100644 --- a/conts/baremetal/timer_service/SConstruct +++ b/conts/baremetal/timer_service/SConstruct @@ -7,64 +7,51 @@ import os, shelve, sys from os.path import * -PROJRELROOT = '../..' +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.configuration import * +from scripts.conts.containers import * +from scripts.config.config_invoke import * config = configuration_retrieve() -arch = config.arch -platform = config.platform gcc_arch_flag = config.gcc_arch_flag -# Wrapper library for system calls -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) +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) -# Some user-space libraries -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)] +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) -LIBDEV_RELDIR = 'conts/libdev' -LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR) -LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace') -LIBDEV_INCLUDE = join(LIBDEV_DIR, 'include') - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], \ - 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', \ - 'libmm', 'libmc', 'libmalloc', 'gcc', 'c-userspace'], - # libgcc.a - This is required for division routines. - CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, \ - LIBC_INCLUDE, LIBMEM_INCLUDE], - LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + 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', + 'libmem', 'gcc', 'c-userspace'], + # libgcc.a - This is required for division routines. + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') -src = Glob('*.[cS]') -src += Glob('src/*.[cS]') -src += Glob('src/arch/*.[cS]') +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) -objs = env.Object(src) -prog = env.Program('main.elf', objs) -Depends(prog, 'include/linker.lds') +Depends(objs, join(PROJROOT, CONFIG_H)) + +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/baremetal/timer_service/container.c b/conts/baremetal/timer_service/container.c index e20006c..88da84e 100644 --- a/conts/baremetal/timer_service/container.c +++ b/conts/baremetal/timer_service/container.c @@ -7,6 +7,7 @@ #include #include #include +#include void main(void); @@ -18,6 +19,8 @@ void __container_init(void) /* Thread library initialisation */ __l4_threadlib_init(); + __l4_capability_init(); + /* Entry to main */ main(); } diff --git a/conts/baremetal/timer_service/include/timer.h b/conts/baremetal/timer_service/include/timer.h index 6b69efc..851fa84 100644 --- a/conts/baremetal/timer_service/include/timer.h +++ b/conts/baremetal/timer_service/include/timer.h @@ -78,7 +78,8 @@ struct timer { unsigned int count; /* Counter/jiffies */ struct sleeper_task_bucket task_list; /* List of sleeping tasks */ struct l4_mutex task_list_lock; /* Lock for sleeper_task_bucket */ - struct capability cap; /* Capability describing timer */ + unsigned long phys_base; /* Physical address of Device */ + int irq_no; /* IRQ number of device */ }; #endif /* __TIMER_H__ */ diff --git a/conts/baremetal/timer_service/main.c b/conts/baremetal/timer_service/main.c index b66362d..167d730 100644 --- a/conts/baremetal/timer_service/main.c +++ b/conts/baremetal/timer_service/main.c @@ -2,6 +2,7 @@ * Timer service for userspace */ #include +#include #include #include #include @@ -10,14 +11,15 @@ #include #include #include -#include +#include #include #include #include -#include +#include +#include /* Capabilities of this service */ -static struct capability caparray[32]; +static struct capability *caparray; static int total_caps = 0; /* Total number of timer chips being handled by us */ @@ -33,33 +35,6 @@ struct wake_task_list wake_tasks; /* tid of handle_request thread */ l4id_t tid_ipc_handler; -int cap_read_all() -{ - int ncaps; - int err; - - /* Read number of capabilities */ - if ((err = l4_capability_control(CAP_CONTROL_NCAPS, - 0, &ncaps)) < 0) { - printf("l4_capability_control() reading # of" - " capabilities failed.\n Could not " - "complete CAP_CONTROL_NCAPS request.\n"); - BUG(); - } - total_caps = ncaps; - - /* Read all capabilities */ - if ((err = l4_capability_control(CAP_CONTROL_READ, - 0, caparray)) < 0) { - printf("l4_capability_control() reading of " - "capabilities failed.\n Could not " - "complete CAP_CONTROL_READ_CAPS request.\n"); - BUG(); - } - - return 0; -} - int cap_share_all_with_space() { int err; @@ -160,32 +135,6 @@ struct link* find_bucket_list(unsigned long seconds) return vector; } -/* - * Scans for up to TIMERS_TOTAL timer devices in capabilities. - */ -int timer_probe_devices(void) -{ - int timers = 0; - - /* Scan for timer devices */ - for (int i = 0; i < total_caps; i++) { - /* Match device type */ - if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_TIMER) { - /* Copy to correct device index */ - memcpy(&global_timer[cap_devnum(&caparray[i]) - 1].cap, - &caparray[i], sizeof(global_timer[0].cap)); - timers++; - } - } - - if (timers != TIMERS_TOTAL) { - printf("%s: Error, not all timers could be found. " - "timers=%d\n", __CONTAINER_NAME__, timers); - return -ENODEV; - } - return 0; -} - /* * Irq handler for timer interrupts */ @@ -204,7 +153,7 @@ int timer_irq_handler(void *arg) /* Register self for timer irq, using notify slot 0 */ if ((err = l4_irq_control(IRQ_CONTROL_REGISTER, slot, - timer->cap.irq)) < 0) { + timer->irq_no)) < 0) { printf("%s: FATAL: Timer irq could not be registered. " "err=%d\n", __FUNCTION__, err); BUG(); @@ -219,7 +168,7 @@ int timer_irq_handler(void *arg) struct link *task_list; /* Block on irq */ - if((count = l4_irq_wait(slot, timer->cap.irq)) < 0) { + if((count = l4_irq_wait(slot, timer->irq_no)) < 0) { printf("l4_irq_wait() returned with negative value\n"); BUG(); } @@ -234,6 +183,7 @@ int timer_irq_handler(void *arg) /* find bucket list of taks to be woken for current count */ vector = find_bucket_list(timer->count); + l4_send(tid_ipc_handler,L4_IPC_TAG_TIMER_WAKE_THREADS); if (!list_empty(vector)) { /* Removing tasks from sleeper list */ @@ -300,19 +250,21 @@ int timer_setup_devices(void) struct l4_thread *tptr = &thread; int err; + global_timer[0].phys_base = PLATFORM_TIMER1_BASE; + global_timer[0].irq_no = IRQ_TIMER1; + for (int i = 0; i < TIMERS_TOTAL; i++) { /* initialize timer */ timer_struct_init(&global_timer[i],(unsigned long)l4_new_virtual(1) ); /* Map timer to a virtual address region */ - if (IS_ERR(l4_map((void *)__pfn_to_addr(global_timer[i].cap.start), - (void *)global_timer[i].base, global_timer[i].cap.size, - MAP_USR_IO, - self_tid()))) { - printf("%s: FATAL: Failed to map TIMER device " - "%d to a virtual address\n", - __CONTAINER_NAME__, - cap_devnum(&global_timer[i].cap)); + if (IS_ERR(l4_map((void *)global_timer[i].phys_base, + (void *)global_timer[i].base, 1, + MAP_USR_IO, self_tid()))) { + printf("%s: FATAL: Failed to map TIMER device from 0x%lx" + " to 0x%lx\n", __CONTAINER_NAME__, + global_timer[i].phys_base, + global_timer[i].base); BUG(); } @@ -502,64 +454,20 @@ void handle_requests(void) } } -/* - * UTCB-size aligned utcb. - * - * BIG WARNING NOTE: This declaration is legal if we are - * running in a disjoint virtual address space, where the - * utcb declaration lies in a unique virtual address in - * the system. - */ -#define DECLARE_UTCB(name) \ - struct utcb name ALIGN(sizeof(struct utcb)) - -DECLARE_UTCB(utcb); - -/* Set up own utcb for ipc */ -int l4_utcb_setup(void *utcb_address) -{ - struct task_ids ids; - struct exregs_data exregs; - int err; - - l4_getid(&ids); - - /* Clear utcb */ - memset(utcb_address, 0, sizeof(struct utcb)); - - /* Setup exregs for utcb request */ - memset(&exregs, 0, sizeof(exregs)); - exregs_set_utcb(&exregs, (unsigned long)utcb_address); - - if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0) - return err; - - return 0; -} - void main(void) { - int err; - /* Read all capabilities */ - cap_read_all(); + caps_read_all(); + + total_caps = cap_get_count(); + caparray = cap_get_all(); /* Share all with space */ cap_share_all_with_space(); - /* Scan for timer devices in capabilities */ - timer_probe_devices(); - /* Initialize virtual address pool for timers */ init_vaddr_pool(); - /* Setup own static utcb */ - if ((err = l4_utcb_setup(&utcb)) < 0) { - printf("FATAL: Could not set up own utcb. " - "err=%d\n", err); - BUG(); - } - /* initialise timed_out_task list */ wake_task_list_init(); diff --git a/conts/baremetal/uart_service/SConscript b/conts/baremetal/uart_service/SConscript new file mode 100644 index 0000000..062d7f2 --- /dev/null +++ b/conts/baremetal/uart_service/SConscript @@ -0,0 +1,11 @@ + +# Inherit global environment +Import('env') + +# The set of source files associated with this SConscript file. +src_local = Glob('*.[cS]') +src_local += Glob('src/*.[cS]') + +obj = env.Object(src_local) +Return('obj') + diff --git a/conts/baremetal/uart_service/SConstruct b/conts/baremetal/uart_service/SConstruct index 32cc880..5b27c25 100644 --- a/conts/baremetal/uart_service/SConstruct +++ b/conts/baremetal/uart_service/SConstruct @@ -7,60 +7,50 @@ import os, shelve, sys from os.path import * -PROJRELROOT = '../..' +CONTS_XXX = '../..' +BAREMETAL_CONTS_XXX = '../../..' +sys.path.append(CONTS_XXX) +sys.path.append(BAREMETAL_CONTS_XXX) -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.conts.containers import * +from scripts.config.configuration import * config = configuration_retrieve() -platform = config.platform -arch = config.arch gcc_arch_flag = config.gcc_arch_flag -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) +cid = int(ARGUMENTS.get('cid', 0)) +cont = find_container_from_cid(cid) -# 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)] +builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name) -LIBDEV_RELDIR = 'conts/libdev' -LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR) -LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace') -LIBDEV_INCLUDE = join(LIBDEV_DIR, 'include') - -# FIXME: Add these to autogenerated SConstruct !!! -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR +# linker.lds is generated either in conts/xxx or build/contx/include +if cont.duplicate == 0: + linker_lds = join(builddir, 'include/linker.lds') +else: + linker_lds = 'include/linker.lds' env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], - 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', 'libmalloc', '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, LIBMEM_INCLUDE], - LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + linker_lds, '-u_start'], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', + ENV = {'PATH' : os.environ['PATH']}, + LIBS = ['gcc', 'libl4', 'c-userspace', 'libdev-userspace', + 'libmem', 'gcc', 'c-userspace'], + # libgcc.a - This is required for division routines. + CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE, + LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')], + LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') -src = Glob('*.[cS]') -src += Glob('src/*.[cS]') +objs = SConscript('SConscript', exports = { 'env' : env }, + duplicate=0, build_dir = builddir) -objs = env.Object(src) -prog = env.Program('main.elf', objs) -Depends(prog, 'include/linker.lds') +Depends(objs, join(PROJROOT, CONFIG_H)) + +prog = env.Program(join(builddir, 'main.elf'), objs) +Depends(prog, linker_lds) diff --git a/conts/baremetal/uart_service/container.c b/conts/baremetal/uart_service/container.c index f570c3d..75a8a6b 100644 --- a/conts/baremetal/uart_service/container.c +++ b/conts/baremetal/uart_service/container.c @@ -6,7 +6,8 @@ #include #include - +#include +#include extern void main(void); @@ -15,6 +16,11 @@ void __container_init(void) /* Generic L4 initialisation */ __l4_init(); + /* Thread library initialisation */ + __l4_threadlib_init(); + + __l4_capability_init(); + /* Entry to main */ main(); } diff --git a/conts/baremetal/uart_service/include/uart.h b/conts/baremetal/uart_service/include/uart.h index fa21d7a..6d250f6 100644 --- a/conts/baremetal/uart_service/include/uart.h +++ b/conts/baremetal/uart_service/include/uart.h @@ -11,7 +11,7 @@ */ struct uart { unsigned long base; /* VMA where uart will be mapped */ - struct capability cap; /* Capability describing uart */ + unsigned long phys_base; }; #endif /* __UART_SERVICE_H__ */ diff --git a/conts/baremetal/uart_service/main.c b/conts/baremetal/uart_service/main.c index 4bed218..49f94b2 100644 --- a/conts/baremetal/uart_service/main.c +++ b/conts/baremetal/uart_service/main.c @@ -6,6 +6,7 @@ #include L4LIB_INC_ARCH(syscalls.h) #include #include +#include #include #include #include @@ -14,43 +15,17 @@ #include #include #include -#include +#include +#include /* Capabilities of this service */ -static struct capability caparray[32]; +static struct capability *caparray; static int total_caps = 0; /* Number of UARTS to be managed by this service */ #define UARTS_TOTAL 1 static struct uart uart[UARTS_TOTAL]; -int cap_read_all() -{ - int ncaps; - int err; - - /* Read number of capabilities */ - if ((err = l4_capability_control(CAP_CONTROL_NCAPS, - 0, &ncaps)) < 0) { - printf("l4_capability_control() reading # of" - " capabilities failed.\n Could not " - "complete CAP_CONTROL_NCAPS request.\n"); - BUG(); - } - total_caps = ncaps; - - /* Read all capabilities */ - if ((err = l4_capability_control(CAP_CONTROL_READ, - 0, caparray)) < 0) { - printf("l4_capability_control() reading of " - "capabilities failed.\n Could not " - "complete CAP_CONTROL_READ_CAPS request.\n"); - BUG(); - } - - return 0; -} - int cap_share_all_with_space() { int err; @@ -66,48 +41,23 @@ int cap_share_all_with_space() return 0; } -/* - * Scans for up to UARTS_TOTAL uart devices in capabilities. - */ -int uart_probe_devices(void) -{ - int uarts = 0; - - /* Scan for uart devices */ - for (int i = 0; i < total_caps; i++) { - /* Match device type */ - if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_UART) { - /* Copy to correct device index */ - memcpy(&uart[cap_devnum(&caparray[i]) - 1].cap, - &caparray[i], sizeof(uart[0].cap)); - uarts++; - } - } - - if (uarts != UARTS_TOTAL) { - printf("%s: Error, not all uarts could be found. " - "total uarts=%d\n", __CONTAINER_NAME__, uarts); - return -ENODEV; - } - return 0; -} - static struct uart uart[UARTS_TOTAL]; int uart_setup_devices(void) { + uart[0].phys_base = PLATFORM_UART1_BASE; + for (int i = 0; i < UARTS_TOTAL; i++) { /* Get one page from address pool */ uart[i].base = (unsigned long)l4_new_virtual(1); /* Map uart to a virtual address region */ - if (IS_ERR(l4_map((void *)__pfn_to_addr(uart[i].cap.start), - (void *)uart[i].base, uart[i].cap.size, + if (IS_ERR(l4_map((void *)uart[i].phys_base, + (void *)uart[i].base, 1, MAP_USR_IO, self_tid()))) { printf("%s: FATAL: Failed to map UART device " - "%d to a virtual address\n", - __CONTAINER_NAME__, - cap_devnum(&uart[i].cap)); + "to a virtual address\n", + __CONTAINER_NAME__); BUG(); } @@ -246,68 +196,23 @@ void handle_requests(void) } } -/* - * UTCB-size aligned utcb. - * - * BIG WARNING NOTE: - * This in-place declaration is legal if we are running - * in a disjoint virtual address space, where the utcb - * declaration lies in a unique virtual address in - * the system. - */ -#define DECLARE_UTCB(name) \ - struct utcb name ALIGN(sizeof(struct utcb)) - -DECLARE_UTCB(utcb); - -/* Set up own utcb for ipc */ -int l4_utcb_setup(void *utcb_address) -{ - struct task_ids ids; - struct exregs_data exregs; - int err; - - l4_getid(&ids); - - /* Clear utcb */ - memset(utcb_address, 0, sizeof(struct utcb)); - - /* Setup exregs for utcb request */ - memset(&exregs, 0, sizeof(exregs)); - exregs_set_utcb(&exregs, (unsigned long)utcb_address); - - if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0) - return err; - - return 0; -} - void main(void) { - int err; - /* Read all capabilities */ - cap_read_all(); + caps_read_all(); + + total_caps = cap_get_count(); + caparray = cap_get_all(); /* Share all with space */ cap_share_all_with_space(); - /* Scan for uart devices in capabilities */ - uart_probe_devices(); - /* Initialize virtual address pool for uarts */ init_vaddr_pool(); /* Map and initialize uart devices */ uart_setup_devices(); - /* Setup own utcb */ - if ((err = l4_utcb_setup(&utcb)) < 0) { - printf("FATAL: Could not set up own utcb. " - "err=%d\n", err); - BUG(); - } - /* Listen for uart requests */ while (1) handle_requests(); diff --git a/conts/libc/SConscript b/conts/libc/SConscript deleted file mode 100644 index a200276..0000000 --- a/conts/libc/SConscript +++ /dev/null @@ -1,42 +0,0 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- Virtualization microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd - -import os, sys, shelve -from os.path import join - -# Get global paths -PROJRELROOT = '../../../' - -sys.path.append(PROJRELROOT) - -from config.configuration import * -from config.projpaths import * - -Import('env', 'arch', 'type') -variant = type - -# Needed by fputc(), for declaration of uart_tx() -LIBDEV_RELDIR = 'conts/libdev' -LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR) -LIBDEV_INC = join(LIBDEV_DIR, 'include') - -e = env.Clone() -e.Append(CPPPATH = ['include', 'include/sys-' + variant + \ - '/arch-' + arch, LIBDEV_INC], - CCFLAGS = ['-nostdinc']) - -source = \ - Glob('src/*.[cS]') + \ - Glob('src/sys-' + variant + '/*.c') + \ - Glob('src/sys-' + variant + '/arch-' + arch + '/*.c') + \ - Glob('src/arch-' + arch + '/*.c') + \ - Glob('src/arch-' + arch + '/*.S') + \ - Glob('crt/sys-' + variant + '/arch-' + arch + '/*.[cS]') - -objects = e.StaticObject(source) -library = e.StaticLibrary('c-' + variant, objects) - -Return('library') diff --git a/conts/libc/SConstruct b/conts/libc/SConstruct deleted file mode 100644 index e1b8aa5..0000000 --- a/conts/libc/SConstruct +++ /dev/null @@ -1,50 +0,0 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- a microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd -# -import os, sys - -PROJRELROOT = '../..' - -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * - -config = configuration_retrieve() -gcc_arch_flag = config.gcc_arch_flag -arch = config.arch - -# We assume we are compiling for userspace. -# variant can be specified from cmdline using -# scons variant=xxx -variant = ARGUMENTS.get('variant', 'userspace') -print '\nCompiling for variant: ' + variant + '\n' - -# Needed by fputc(), for declaration of uart_tx() -LIBDEV_RELDIR = 'conts/libdev' -LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR) -LIBDEV_INC = join(LIBDEV_DIR, 'include') - -env = Environment(CC = config.toolchain_userspace + 'gcc', - CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', \ - '-nostdinc', '-Wall', '-Werror', '-march=' + gcc_arch_flag], - LINKFLAGS = ['-nostdlib'], - ASFLAGS = ['-D__ASSEMBLY__'], - ENV = {'PATH' : os.environ['PATH']}, - CPPPATH = ['include', LIBDEV_INC, join(PROJROOT,'include'), \ - 'include/sys-' + variant + '/arch-' + arch]) - -source = \ - Glob('src/*.[cS]') + \ - Glob('src/sys-' + variant + '/*.c') + \ - Glob('src/sys-' + variant + '/arch-' + arch + '/*.c') + \ - Glob('src/arch-' + arch + '/*.c') + \ - Glob('src/arch-' + arch + '/*.S') + \ - Glob('crt/sys-' + variant + '/arch-' + arch + '/*.[cS]') - -objects = env.StaticObject(source) -library = env.StaticLibrary('c-' + variant, objects) - diff --git a/conts/libdev/SConscript b/conts/libdev/SConscript deleted file mode 100644 index 3f62846..0000000 --- a/conts/libdev/SConscript +++ /dev/null @@ -1,50 +0,0 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- Virtualization microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd - -import os, sys, shelve -from os.path import join - -# Get global paths -PROJRELROOT = '../../../' - -sys.path.append(PROJRELROOT) - -from config.configuration import * -from config.projpaths import * - -Import('env', 'platform', 'type') -variant = type - -# To include setbit/clrbit functions -LIBL4_RELDIR = 'conts/libl4' -LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) -LIBL4_INC = join(LIBL4_DIR, 'include') - -LIBC_RELDIR = 'conts/libc' -LIBC_DIR = join(PROJROOT, LIBC_RELDIR) -LIBC_INC = join(LIBC_DIR, 'include') - -e = env.Clone() -e.Append(CPPPATH = ['#conts/libdev/include', LIBC_INC, LIBL4_INC], - CCFLAGS = ['-DVARIANT_' + variant.upper()]) - -objects = [] -objects += SConscript('uart/pl011/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : e}) -objects += SConscript('timer/sp804/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : e}) -objects += SConscript('kmi/pl050/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : e}) -objects += SConscript('clcd/pl110/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : e}) - -objects += SConscript('uart/omap/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : e}) -objects += SConscript('timer/omap/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : e}) - -library = e.StaticLibrary('libdev-' + variant, objects) -Return('library') diff --git a/conts/libdev/SConstruct b/conts/libdev/SConstruct deleted file mode 100644 index ea51650..0000000 --- a/conts/libdev/SConstruct +++ /dev/null @@ -1,59 +0,0 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- a microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd -# -import os, sys - -PROJRELROOT = '../..' - -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * - -config = configuration_retrieve() -gcc_arch_flag = config.gcc_arch_flag -platform = config.platform - -# We assume we are compiling for userspace. -# variant can be specified from cmdline using -# scons variant=xxx -variant = ARGUMENTS.get('variant', 'userspace') -print '\nCompiling for variant: ' + variant + '\n' - -# To include setbit/clrbit functions -LIBL4_RELDIR = 'conts/libl4' -LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) -LIBL4_INC = join(LIBL4_DIR, 'include') - -LIBC_RELDIR = 'conts/libc' -LIBC_DIR = join(PROJROOT, LIBC_RELDIR) -LIBC_INC = join(LIBC_DIR, 'include') - -env = Environment(CC = config.toolchain_userspace + 'gcc', - CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', \ - '-nostdinc', '-Wall', '-DVARIANT_' + variant.upper(), \ - '-march=' + gcc_arch_flag, '-Werror'], - LINKFLAGS = ['-nostdlib'], - ASFLAGS = ['-D__ASSEMBLY__'], - ENV = {'PATH' : os.environ['PATH']}, - CPPPATH = ['#include', LIBC_INC, LIBL4_INC, join(PROJROOT,'include')]) - -objects = [] -objects += SConscript('uart/pl011/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : env}) -objects += SConscript('timer/sp804/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : env}) -objects += SConscript('kmi/pl050/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : env}) -objects += SConscript('clcd/pl110/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : env}) - -objects += SConscript('uart/omap/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : env}) -objects += SConscript('timer/omap/SConscript', duplicate=0, \ - exports = {'platform' : platform, 'env' : env}) - -library = env.StaticLibrary('libdev-' + variant, objects) diff --git a/conts/libl4/SConstruct b/conts/libl4/SConstruct deleted file mode 100644 index a1ad865..0000000 --- a/conts/libl4/SConstruct +++ /dev/null @@ -1,48 +0,0 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- a microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd -# -import os, sys - -PROJRELROOT = '../..' - -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from config.configuration import * - -config = configuration_retrieve() -gcc_arch_flag = config.gcc_arch_flag -arch = config.arch -subarch = config.subarch - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) - -LIBC_RELDIR = 'conts/libc' -LIBC_DIR = join(PROJROOT, LIBC_RELDIR) -LIBC_INC = join(LIBC_DIR, 'include') - -env = Environment(CC = config.toolchain_userspace + 'gcc', - CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', \ - '-nostdinc', '-Wall', '-Werror', '-march=' + gcc_arch_flag], - LINKFLAGS = ['-nostdlib'], - ASFLAGS = ['-D__ASSEMBLY__'], - ENV = {'PATH' : os.environ['PATH']}, - CPPPATH = ['include', 'include/l4lib/arch', LIBC_INC, \ - join(PROJROOT,'include'), LIBMEM_DIR], - CPPFLAGS = ' -include l4lib/macros.h ') - -objects = env.StaticObject(Glob('src/*.c') + \ - Glob('src/lib/*.c') + \ - Glob('src/arch/' + arch + '/exregs.c') + \ - Glob('src/arch/' + arch + '/*.[cS]') + \ - Glob('src/arch/' + arch + '/' + subarch + '/*.[cS]') + \ - Glob('src/lib/cap/*.c')) + \ - Glob('src/lib/thread/*.c') - - -library = env.StaticLibrary('l4', objects) - diff --git a/conts/libmem/SConstruct b/conts/libmem/SConstruct deleted file mode 100644 index 2fadeff..0000000 --- a/conts/libmem/SConstruct +++ /dev/null @@ -1,75 +0,0 @@ -# -# Copyright (C) 2007 Bahadir Balban -# - -import os, glob, sys -from os.path import join -from string import split - -PROJRELROOT = '../..' -sys.path.append(PROJRELROOT) - -from configure import * -from config.projpaths import * -config = configuration_retrieve() -gcc_arch_flag = config.gcc_arch_flag - -headers_root = join(PROJRELROOT, "include/l4") -config_h = join(headers_root, "config.h") - -mm = "mm" -kmalloc = "kmalloc" -memcache = "memcache" -tests = "tests" - -mm_dir = mm -kmalloc_dir = kmalloc -memcache_dir = memcache -tests_dir = tests - -LIBL4_RELDIR = 'conts/libl4' -LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) -LIBL4_INCLUDE = join(LIBL4_DIR, 'include') - -# This does not work, need to check -test_env = Environment(CC = config.toolchain_userspace + 'gcc', - CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \ - '-nostdinc', '-Werror', '-march=' + gcc_arch_flag], - ENV = {'PATH' : os.environ['PATH']}, - LIBS = ['mm', 'km', 'mc'], - LIBPATH = ['#'], - CPPPATH = ['#include', join(PROJRELROOT, "include"), "#", LIBL4_INCLUDE]) - -env = Environment(CC = config.toolchain_userspace + 'gcc', - CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', \ - '-Wall', '-Werror', '-march=' + gcc_arch_flag], - LINKFLAGS = ['-nostdlib'], - ASFLAGS = ['-D__ASSEMBLY__'], - ENV = {'PATH' : os.environ['PATH']}, - LIBS = 'gcc', - CPPPATH = ['.', join(PROJROOT, 'include'), LIBL4_INCLUDE]) - -if os.path.exists(config_h) is False: - print "\nThis build requires a valid kernel configuration header." - print "Please run `scons configure' in the kernel root directory." - print "Choose the `tests' target to build memory allocator tests," - print "or any other target for real use.\n" - sys.exit() - -mm_src = glob.glob("%s/*.c" % mm_dir) -kmalloc_src = glob.glob("%s/*.c" % kmalloc_dir) -memcache_src = glob.glob("%s/*.c" % memcache_dir) -tests_src = glob.glob ("%s/*.c" % tests_dir) - -if "tests" in COMMAND_LINE_TARGETS: - print "WARNING!!! Did you configure the kernel with test target first???" - libmm = test_env.StaticLibrary(mm, mm_src) - libkmalloc = test_env.StaticLibrary("km", kmalloc_src) - libmemcache = test_env.StaticLibrary("mc", memcache_src) - test_prog = test_env.Program("test", tests_src) - env.Alias("tests", test_prog) -else: - libmm = env.StaticLibrary(mm, mm_src) - libkmalloc = env.StaticLibrary("km", kmalloc_src) - libmemcache = env.StaticLibrary("mc", memcache_src) - diff --git a/conts/posix/SConstruct b/conts/posix/SConstruct index 4869f32..1af35da 100644 --- a/conts/posix/SConstruct +++ b/conts/posix/SConstruct @@ -12,37 +12,13 @@ PROJRELROOT = '../../' sys.path.append(PROJRELROOT) sys.path.append('../../../../') -from config.projpaths import * -from config.configuration import * -from config.lib import * +from scripts.config.projpaths import * +from scripts.config.configuration import * +from scripts.config.lib import * config = configuration_retrieve() -arch = config.arch gcc_arch_flag = config.gcc_arch_flag -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') - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR - LIBPOSIX_RELDIR = 'conts/posix/libposix' LIBPOSIX_DIR = join(PROJROOT, LIBPOSIX_RELDIR) LIBPOSIX_INCLUDE_SERVER = join(LIBPOSIX_DIR, 'include') @@ -50,26 +26,26 @@ LIBPOSIX_INCLUDE_USERSPACE = join(LIBPOSIX_DIR, 'include/posix') LIBPOSIX_LIBPATH = join(BUILDDIR, LIBPOSIX_RELDIR) env = Environment(CC = config.toolchain_userspace + 'gcc', - AR = config.toolchain_userspace + 'ar', - RANLIB = config.toolchain_userspace + 'ranlib', - CCFLAGS = ['-g','-nostdinc', '-nostdlib', '-ffreestanding', - '-march=' + gcc_arch_flag, '-std=gnu99', '-Wall', '-Werror'], - LINKFLAGS = ['-nostdlib'], - ASFLAGS = ['-D__ASSEMBLY__'], - PROGSUFFIX = '.elf', - ENV = {'PATH' : os.environ['PATH']}, - LIBS = ['libl4', 'libdev-userspace', 'gcc', 'c-userspace', \ - 'gcc', 'libmm', 'libmc', 'libmalloc'], - CPPPATH = ['include', LIBDEV_INCLUDE, LIBC_INCLUDE, KERNEL_INCLUDE, - LIBL4_INCLUDE, LIBMEM_INCLUDE, LIBPOSIX_INCLUDE_USERSPACE], - LIBPATH = [LIBDEV_LIBPATH, LIBC_LIBPATH, LIBL4_LIBPATH, - LIBMEM_LIBPATH, LIBPOSIX_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + AR = config.toolchain_userspace + 'ar', + RANLIB = config.toolchain_userspace + 'ranlib', + CCFLAGS = ['-g','-nostdinc', '-nostdlib', '-ffreestanding', '-Wall', + '-march=' + gcc_arch_flag, '-std=gnu99', '-Werror'], + LINKFLAGS = ['-nostdlib'], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', + ENV = {'PATH' : os.environ['PATH']}, + LIBS = ['libl4', 'libdev-userspace', 'gcc', 'c-userspace', \ + 'gcc', 'libmem'], + CPPPATH = ['include', LIBDEV_INCLUDE, LIBC_INCLUDE, KERNEL_HEADERS, + LIBL4_INCLUDE, LIBMEM_INCLUDE, LIBPOSIX_INCLUDE_USERSPACE], + LIBPATH = [LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBL4_LIBPATH, + LIBMEM_LIBPATH, LIBPOSIX_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') contid = ARGUMENTS.get('cont', '0') libposix_env = env.Clone() -libposix_env.Replace(CPPPATH = [LIBPOSIX_INCLUDE_USERSPACE, 'include', KERNEL_INCLUDE, LIBL4_INCLUDE, LIBMEM_INCLUDE, LIBC_INCLUDE]) +libposix_env.Replace(CPPPATH = [LIBPOSIX_INCLUDE_USERSPACE, 'include', KERNEL_HEADERS, LIBL4_INCLUDE, LIBMEM_INCLUDE, LIBC_INCLUDE]) libposix = SConscript('libposix/SConscript', \ exports = { 'config' : config, 'env' : libposix_env, 'contid' : contid}, duplicate = 0, \ variant_dir = join(BUILDDIR, 'conts' + '/posix' + '/libposix')) @@ -86,7 +62,7 @@ rootfs = SConscript('rootfs/SConscript', \ # No libposix reference because it conflicts with the compiler C library + the cluncky libc we have. test0_env = env.Clone() -test0_env.Replace(CPPPATH = ['include', KERNEL_INCLUDE, LIBL4_INCLUDE, LIBMEM_INCLUDE, LIBC_INCLUDE, LIBPOSIX_INCLUDE_USERSPACE]) +test0_env.Replace(CPPPATH = ['include', KERNEL_HEADERS, LIBL4_INCLUDE, LIBMEM_INCLUDE, LIBC_INCLUDE, LIBPOSIX_INCLUDE_USERSPACE]) test0 = SConscript('test0/SConscript', \ exports = { 'config' : config, 'environment' : test0_env, 'contid' : contid, 'previmage' : rootfs }, duplicate = 0, \ variant_dir = join(BUILDDIR, 'cont' + str(contid) + '/posix' + '/test0')) diff --git a/conts/posix/bootdesc/SConscript b/conts/posix/bootdesc/SConscript index 7af88ed..f76ec0d 100644 --- a/conts/posix/bootdesc/SConscript +++ b/conts/posix/bootdesc/SConscript @@ -19,8 +19,8 @@ PROJRELROOT = '../../../../' sys.path.append(os.path.abspath(PROJRELROOT)) -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.config.configuration import * from tools.pyelf import elf config = configuration_retrieve() diff --git a/conts/posix/bootdesc/SConstruct b/conts/posix/bootdesc/SConstruct index bf505e5..fbdf371 100644 --- a/conts/posix/bootdesc/SConstruct +++ b/conts/posix/bootdesc/SConstruct @@ -3,11 +3,9 @@ # # Copyright (C) 2007 Bahadir Balban # -import os -import sys -import shutil +import os, sys, shutil from os.path import join -from configure import * +from scripts.config.config_invoke import * config = configuration_retrieve() builddir = ARGUMENTS.get('builddir', 'build/conts/posix') diff --git a/conts/posix/libposix/SConstruct b/conts/posix/libposix/SConstruct index 5c27f94..a1818b3 100644 --- a/conts/posix/libposix/SConstruct +++ b/conts/posix/libposix/SConstruct @@ -2,20 +2,14 @@ # Copyright (C) 2007 Bahadir Balban # -import os -import glob -import sys +import os, glob, sys from os.path import join from string import split -from configure import * +from scripts.config.config_invoke import * +from scripts.config.projpaths import * config = configuration_retrieve() -project_root = "../.." -kernel_headers = join(project_root, "include") -l4lib_headers = join(project_root, "tasks/libl4/include") -config_h = join(project_root, "include/l4/config.h") - env = Environment(CC = config.toolchain_userspace + 'gcc', CCFLAGS = ['-g', '-std=gnu99', '-nostdlib', '-ffreestanding'], LINKFLAGS = ['-nostdlib'], @@ -38,7 +32,7 @@ def extract_arch_subarch_plat(config_header): print "\n\nconfig.h does not exist. "\ "Please run: `scons configure' first\n\n" sys.exit() - f = open(config_h, "r") + f = open(CONFIG_H, "r") while True: line = f.readline() if line == "": @@ -64,9 +58,9 @@ def extract_arch_subarch_plat(config_header): sys.exit() return arch, subarch, plat -arch, subarch, plat = extract_arch_subarch_plat(config_h) +arch, subarch, plat = extract_arch_subarch_plat(CONFIG_H) -headers = ["#include/posix", l4lib_headers, kernel_headers] +headers = ["#include/posix", L4LIB_INCLUDE, KERNEL_HEADERS] env.Append(CPPPATH = headers) diff --git a/conts/posix/mm0/SConscript b/conts/posix/mm0/SConscript index 7c477c1..f6222e4 100644 --- a/conts/posix/mm0/SConscript +++ b/conts/posix/mm0/SConscript @@ -7,7 +7,7 @@ arch = config.arch subarch = config.subarch sys.path.append('../../../../') -from config.lib import * +from scripts.config.lib import * container = next((c for c in config.containers if int(c.id) == int(contid)), None) diff --git a/conts/posix/mm0/SConstruct b/conts/posix/mm0/SConstruct index d5fbd5b..5ded7f1 100644 --- a/conts/posix/mm0/SConstruct +++ b/conts/posix/mm0/SConstruct @@ -11,38 +11,26 @@ PROJRELROOT = '../../../' sys.path.append(PROJRELROOT) -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.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 = config.toolchain_userspace + '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'], - LINKFLAGS = ['-nostdlib', '-T' + "include/linker.lds", \ - LIBC_LIBPATH, LIBL4_LIBPATH, LIBMEM_LIBPATH], - ASFLAGS = ['-D__ASSEMBLY__'], - PROGSUFFIX = '.elf', # The suffix to use for final executable - ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path - LIBS = ['gcc', 'libl4', 'libc', 'libmm', 'libmc'], - CPPPATH = ["#include", LIBC_INCLUDE, KERNEL_INCLUDE, LIBL4_INCLUDE], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__') + # 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'], + LINKFLAGS = ['-nostdlib', '-T' + "include/linker.lds", + LIBC_LIBPATH, LIBL4_LIBPATH, LIBMEM_LIBPATH], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = ['gcc', 'libl4', 'libc', 'libmm', 'libmc'], + CPPPATH = ["#include", LIBC_INCLUDE, KERNEL_HEADERS, LIBL4_INCLUDE], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h \ + -D__KERNEL__') diff --git a/conts/posix/mm0/fs/memfs/vnode.c b/conts/posix/mm0/fs/memfs/vnode.c index f4c6e55..d507f8d 100644 --- a/conts/posix/mm0/fs/memfs/vnode.c +++ b/conts/posix/mm0/fs/memfs/vnode.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include diff --git a/conts/posix/mm0/fs/path.c b/conts/posix/mm0/fs/path.c index 11cd368..752728e 100644 --- a/conts/posix/mm0/fs/path.c +++ b/conts/posix/mm0/fs/path.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/conts/posix/mm0/include/linker.lds.in b/conts/posix/mm0/include/linker.lds.in index ccffea5..7f57d9b 100644 --- a/conts/posix/mm0/include/linker.lds.in +++ b/conts/posix/mm0/include/linker.lds.in @@ -9,54 +9,70 @@ physical_base = %s; pager_offset = virtual_base - physical_base; +OUTPUT_ARCH(arm) ENTRY(_start) +PHDRS +{ + rx PT_LOAD; + rw PT_LOAD; +} + SECTIONS { . = virtual_base; + /* Put all RX, RO sections here */ __start_text = .; - .text : AT (ADDR(.text) - pager_offset) { + .text : AT (ADDR(.text) - pager_offset) + { *(.text.head) *(.text) - } + } : rx = 0x90909090 __end_text = .; __start_rodata = .; - .rodata : AT (ADDR(.rodata) - pager_offset) { + .rodata : AT (ADDR(.rodata) - pager_offset) + { *(.rodata) - } - .rodata1 : AT (ADDR(.rodata1) - pager_offset) { + } : rx = 0x90909090 + .rodata1 : AT (ADDR(.rodata1) - pager_offset) + { *(.rodata1) - } + } : rx = 0x90909090 __end_rodata = .; + . = ALIGN(4K); + + /* Put all RW sections here */ __start_data = .; - .data : AT (ADDR(.data) - pager_offset) { + .data : AT (ADDR(.data) - pager_offset) + { *(.data) - } + } : rw __end_data = .; __start_bss = .; - .bss : AT (ADDR(.bss) - pager_offset) { + .bss : AT (ADDR(.bss) - pager_offset) + { *(.bss) - } - . = ALIGN(4K); + } : rw __end_bss = .; - . += 0x2000; /* BSS doesnt increment link counter??? */ __start_stack = .; - .stack : AT (ADDR(.stack) - pager_offset) { + .stack : AT (ADDR(.stack) - pager_offset) + { *(.stack) - } - . = ALIGN(4K); + } : rw __stack = .; /* This is the preallocated boot stack */ /* Below part is to be discarded after boot */ + . = ALIGN(4K); __start_init = .; - .init : AT (ADDR(.init) - pager_offset) { + .init : AT (ADDR(.init) - pager_offset) + { *(.init.data) *(.init.bootmem) - } + } : rw __end_init = .; __end = .; } diff --git a/conts/posix/mm0/include/memfs/memfs.h b/conts/posix/mm0/include/memfs/memfs.h index 64d3054..b878b7a 100644 --- a/conts/posix/mm0/include/memfs/memfs.h +++ b/conts/posix/mm0/include/memfs/memfs.h @@ -12,7 +12,7 @@ #include #include #include INC_GLUE(memory.h) -#include +#include #include /* diff --git a/conts/posix/mm0/include/vfs.h b/conts/posix/mm0/include/vfs.h index 0a56e2a..a937e0e 100644 --- a/conts/posix/mm0/include/vfs.h +++ b/conts/posix/mm0/include/vfs.h @@ -2,7 +2,7 @@ #define __VFS_H__ #include -#include +#include #include #include #include diff --git a/conts/posix/mm0/lib/idpool.c b/conts/posix/mm0/lib/idpool.c index db85f3f..3aaef58 100644 --- a/conts/posix/mm0/lib/idpool.c +++ b/conts/posix/mm0/lib/idpool.c @@ -4,7 +4,7 @@ * Copyright (C) 2007 Bahadir Balban */ #include -#include +#include #include #include INC_GLUE(memory.h) #include diff --git a/conts/posix/mm0/main.c b/conts/posix/mm0/main.c index b297503..874a150 100644 --- a/conts/posix/mm0/main.c +++ b/conts/posix/mm0/main.c @@ -94,10 +94,12 @@ void handle_requests(void) ret = 0; break; } +/* case L4_REQUEST_CAPABILITY: { ret = sys_request_cap(sender, (struct capability *)mr[0]); break; } +*/ case L4_IPC_TAG_SHMGET: { ret = sys_shmget((key_t)mr[0], (int)mr[1], (int)mr[2]); break; diff --git a/conts/posix/mm0/mm/capability.c b/conts/posix/mm0/mm/capability.c index d0ee46b..fe46efb 100644 --- a/conts/posix/mm0/mm/capability.c +++ b/conts/posix/mm0/mm/capability.c @@ -12,7 +12,7 @@ #include L4LIB_INC_ARCH(syscalls.h) #include /* TODO: Move this to API */ #include L4LIB_INC_ARCH(syslib.h) -#include +#include #include /* Capability descriptor list */ @@ -33,6 +33,7 @@ void cap_list_print(struct cap_list *cap_list) printf("\n"); } +#if 0 #define PAGER_TOTAL_MUTEX 5 int setup_children_mutex(int total_caps, struct cap_list *cap_list) { @@ -237,13 +238,16 @@ found: return 0; } +#endif +#if 0 int setup_children_caps(int total_caps, struct cap_list *cap_list) { setup_children_ipc(total_caps, cap_list); setup_children_mutex(total_caps, cap_list); return 0; } +#endif /* Copy all init-memory allocated capabilities */ void copy_boot_capabilities(int ncaps) @@ -283,6 +287,8 @@ int cap_read_all() } total_caps = ncaps; + printf("%s: Total of %d capabilities.\n", __FUNCTION__, total_caps); + /* Allocate array of caps from boot memory */ caparray = alloc_bootmem(sizeof(struct capability) * ncaps, 0); @@ -299,7 +305,7 @@ int cap_read_all() /* Copy them to real allocated structures */ copy_boot_capabilities(ncaps); - // cap_list_print(&capability_list); +// cap_list_print(&capability_list); memset(&cont_mem_regions, 0, sizeof(cont_mem_regions)); @@ -371,12 +377,29 @@ int cap_read_all() !cont_mem_regions.utcb || !cont_mem_regions.physmem || !cont_mem_regions.pager) { - printf("%s: Error, pager does not have one of the required" + printf("%s: Error, pager does not have one of the required " "mem capabilities defined. (TASK, SHM, PHYSMEM, UTCB, PAGER)\n", __TASKNAME__); - printf("%p, %p, %p, %p, %p\n", cont_mem_regions.task, - cont_mem_regions.shmem, cont_mem_regions.utcb, - cont_mem_regions.physmem, cont_mem_regions.pager); + if (cont_mem_regions.task) { + printf("task start: %lx\n", cont_mem_regions.task->start << 12); + printf("task end: %lx\n", cont_mem_regions.task->end << 12); + } + if (cont_mem_regions.shmem) { + printf("shmem start: %lx\n", cont_mem_regions.shmem->start << 12); + printf("shmem end: %lx\n", cont_mem_regions.shmem->end << 12); + } + if (cont_mem_regions.physmem) { + printf("physmem start: %lx\n", cont_mem_regions.physmem->start << 12); + printf("physmem end: %lx\n", cont_mem_regions.physmem->end << 12); + } + if (cont_mem_regions.utcb) { + printf("utcb start: %lx\n", cont_mem_regions.utcb->start << 12); + printf("utcb end: %lx\n", cont_mem_regions.utcb->end << 12); + } + if (cont_mem_regions.pager) { + printf("pager start: %lx\n", cont_mem_regions.pager->start << 12); + printf("pager end: %lx\n", cont_mem_regions.pager->end << 12); + } BUG(); } @@ -386,9 +409,10 @@ int cap_read_all() void setup_caps() { cap_read_all(); - setup_children_caps(total_caps, &capability_list); +// setup_children_caps(total_caps, &capability_list); } +#if 0 /* * Find our own, widened replicable capability of same type as given, * replicate, reduce and grant as described with given parameters. @@ -561,3 +585,5 @@ out: return ret; } +#endif + diff --git a/conts/posix/mm0/mm/dev.c b/conts/posix/mm0/mm/dev.c index 131a872..18972d6 100644 --- a/conts/posix/mm0/mm/dev.c +++ b/conts/posix/mm0/mm/dev.c @@ -3,7 +3,7 @@ */ #include #include -#include +#include #include /* diff --git a/conts/posix/mm0/mm/execve.c b/conts/posix/mm0/mm/execve.c index 656e1b7..90ec35e 100644 --- a/conts/posix/mm0/mm/execve.c +++ b/conts/posix/mm0/mm/execve.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/conts/posix/mm0/mm/exit.c b/conts/posix/mm0/mm/exit.c index 43ffd30..e0de747 100644 --- a/conts/posix/mm0/mm/exit.c +++ b/conts/posix/mm0/mm/exit.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include L4LIB_INC_ARCH(syslib.h) #include L4LIB_INC_ARCH(syscalls.h) diff --git a/conts/posix/mm0/mm/fault.c b/conts/posix/mm0/mm/fault.c index f1300cf..c8cc1c4 100644 --- a/conts/posix/mm0/mm/fault.c +++ b/conts/posix/mm0/mm/fault.c @@ -5,8 +5,8 @@ */ #include #include -#include -#include +#include +#include #include #include #include diff --git a/conts/posix/mm0/mm/file.c b/conts/posix/mm0/mm/file.c index 47f75bb..576864d 100644 --- a/conts/posix/mm0/mm/file.c +++ b/conts/posix/mm0/mm/file.c @@ -5,8 +5,8 @@ */ #include #include -#include -#include +#include +#include #include #include #include @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/conts/posix/mm0/mm/init.c b/conts/posix/mm0/mm/init.c index f0ace78..8c66faf 100644 --- a/conts/posix/mm0/mm/init.c +++ b/conts/posix/mm0/mm/init.c @@ -14,8 +14,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/conts/posix/mm0/mm/mmap.c b/conts/posix/mm0/mm/mmap.c index b46e78f..31109b2 100644 --- a/conts/posix/mm0/mm/mmap.c +++ b/conts/posix/mm0/mm/mmap.c @@ -5,7 +5,7 @@ */ #include #include -#include +#include #include INC_API(errno.h) #include #include L4LIB_INC_ARCH(syscalls.h) @@ -98,9 +98,59 @@ int task_insert_vma(struct vm_area *this, struct link *vma_list) BUG(); } +int vma_intersection(struct tcb *task, + unsigned long pfn_start, unsigned long pfn_end) +{ + struct vm_area *vma; + + list_foreach_struct(vma, &task->vm_area_head->list, list) { + if (set_intersection(pfn_start, pfn_end, + vma->pfn_start, vma->pfn_end)) + return 1; + } + return 0; +} + +/* + * Take first vma, place region after it. Traverse all vmas, if hit + * an intersection, take the next vma and retry until all are traversed + */ +unsigned long find_unmapped_area(unsigned long npages, struct tcb *task) +{ + unsigned long pfn_start = __pfn(task->map_start); + unsigned long pfn_end = pfn_start + npages; + struct vm_area *vma; + + if (npages > __pfn(task->map_end - task->map_start)) + return 0; + + /* If no vmas, first map slot is available. */ + if (list_empty(&task->vm_area_head->list)) + return task->map_start; + + list_foreach_struct(vma, &task->vm_area_head->list, list) { + /* Update region to after this vma */ + pfn_start = vma->pfn_end; + pfn_end = pfn_start + npages; + + /* If it doesn't intersect with any other vmas + * and is within boundaries, return it */ + if (pfn_end <= __pfn(task->map_end) && + !vma_intersection(task, pfn_start, pfn_end)) + return __pfn_to_addr(pfn_start); + } + return 0; +} + + +#if 0 /* * Search an empty space in the task's mmapable address region. * + * This works most of the time - but fails if an empty region is + * encountered that is used at a later vma that doesn't get checked. + * This may occur. + * * This does a less than O(n) algorithm by starting the estimated region * and vma comparison from the beginning, once a vma is not intersected * that means it is an available slot. However if vma's and estimated @@ -157,6 +207,7 @@ unsigned long find_unmapped_area(unsigned long npages, struct tcb *task) return 0; } +#endif /* Validate an address that is a possible candidate for an mmap() region */ int mmap_address_validate(struct tcb *task, unsigned long map_address, diff --git a/conts/posix/mm0/mm/munmap.c b/conts/posix/mm0/mm/munmap.c index 434ef69..e0d4479 100644 --- a/conts/posix/mm0/mm/munmap.c +++ b/conts/posix/mm0/mm/munmap.c @@ -9,7 +9,7 @@ #include #include L4LIB_INC_ARCH(syslib.h) #include -#include +#include /* This splits a vma, splitter region must be in the *middle* of original vma */ int vma_split(struct vm_area *vma, struct tcb *task, diff --git a/conts/posix/mm0/mm/pagers.c b/conts/posix/mm0/mm/pagers.c index 3990ff4..29c255d 100644 --- a/conts/posix/mm0/mm/pagers.c +++ b/conts/posix/mm0/mm/pagers.c @@ -5,8 +5,8 @@ #include #include L4LIB_INC_ARCH(syscalls.h) #include L4LIB_INC_ARCH(syslib.h) -#include -#include +#include +#include #include #include #include diff --git a/conts/posix/mm0/mm/shm.c b/conts/posix/mm0/mm/shm.c index cd3f778..60d7ec9 100644 --- a/conts/posix/mm0/mm/shm.c +++ b/conts/posix/mm0/mm/shm.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include L4LIB_INC_ARCH(syscalls.h) #include L4LIB_INC_ARCH(syslib.h) #include diff --git a/conts/posix/mm0/mm/task.c b/conts/posix/mm0/mm/task.c index 0bd1d89..90d4131 100644 --- a/conts/posix/mm0/mm/task.c +++ b/conts/posix/mm0/mm/task.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/conts/posix/mm0/mm/user.c b/conts/posix/mm0/mm/user.c index 6898390..2e3460e 100644 --- a/conts/posix/mm0/mm/user.c +++ b/conts/posix/mm0/mm/user.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include /* * Checks if the given user virtual address range is diff --git a/conts/posix/mm0/mm/utcb.c b/conts/posix/mm0/mm/utcb.c index 371a1f8..01f9f73 100644 --- a/conts/posix/mm0/mm/utcb.c +++ b/conts/posix/mm0/mm/utcb.c @@ -9,7 +9,7 @@ #include L4LIB_INC_ARCH(utcb.h) #include #include -#include +#include #include #include diff --git a/conts/posix/mm0/mm/vm_object.c b/conts/posix/mm0/mm/vm_object.c index b16307f..ffec04d 100644 --- a/conts/posix/mm0/mm/vm_object.c +++ b/conts/posix/mm0/mm/vm_object.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include /* Global list of all in-memory files on the system */ diff --git a/conts/posix/mm0/tools/generate_bootdesc.py b/conts/posix/mm0/tools/generate_bootdesc.py index 2028540..d14b90f 100755 --- a/conts/posix/mm0/tools/generate_bootdesc.py +++ b/conts/posix/mm0/tools/generate_bootdesc.py @@ -2,7 +2,7 @@ import os import sys -from configure import * +from config.config_invoke import * config = configuration_retrieve() objdump = "objdump" diff --git a/conts/posix/rootfs/SConscript b/conts/posix/rootfs/SConscript index fb03ba8..b60f00f 100644 --- a/conts/posix/rootfs/SConscript +++ b/conts/posix/rootfs/SConscript @@ -14,8 +14,8 @@ e = environment.Clone() sys.path.append('../../../') -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.config.configuration import * from tools.pyelf.lmanext import * rootfs_lds_in = \ diff --git a/conts/posix/test0/SConscript b/conts/posix/test0/SConscript index 34672e2..6889440 100644 --- a/conts/posix/test0/SConscript +++ b/conts/posix/test0/SConscript @@ -6,7 +6,7 @@ import os, sys arch = config.arch sys.path.append('../../../../') -from config.lib import * +from scripts.config.lib import * from tools.pyelf.lmanext import * src = [Glob('*.c') + Glob('test_exec.S') + Glob('src/*.[Sc]') + Glob('src/arch/arm/*.c')] diff --git a/conts/posix/test0/SConstruct b/conts/posix/test0/SConstruct index 076657c..750faea 100644 --- a/conts/posix/test0/SConstruct +++ b/conts/posix/test0/SConstruct @@ -3,12 +3,10 @@ # # Copyright (C) 2007 Bahadir Balban # -import os -import sys -import shutil +import os, sys, shutil from os.path import join from glob import glob -from configure import * +from scripts.config.config_invoke import * config = configuration_retrieve() diff --git a/conts/posix/test0/include/linker.lds.in b/conts/posix/test0/include/linker.lds.in index ff0689c..8cd7869 100644 --- a/conts/posix/test0/include/linker.lds.in +++ b/conts/posix/test0/include/linker.lds.in @@ -11,38 +11,60 @@ __stack = (virtual_base - 0x1000 - 8); /* First page before the env/args */ offset = virtual_base - physical_base; +OUTPUT_ARCH(arm) ENTRY(_start) +PHDRS +{ + rx PT_LOAD; + rw PT_LOAD; +} + SECTIONS { . = virtual_base; + + /* Put all RX, RO sections here */ _start_text = .; - .text : AT (ADDR(.text) - offset) { + .text : AT (ADDR(.text) - offset) + { *(.text.head) *(.text) - } - .rodata : AT (ADDR(.rodata) - offset) { + } : rx = 0x90909090 + + .rodata : AT (ADDR(.rodata) - offset) + { *(.rodata) - } - .rodata1 : AT (ADDR(.rodata1) - offset) { + } : rx = 0x90909090 + .rodata1 : AT (ADDR(.rodata1) - offset) + { *(.rodata1) - } + } : rx = 0x90909090 . = ALIGN(4K); - .data : AT (ADDR(.data) - offset) { + + /* Put all RW sections here */ + .data : AT (ADDR(.data) - offset) + { _start_test_exec = .; *(.testexec) _end_test_exec = .; *(.data) - } - .got : AT (ADDR(.got) - offset) { + } : rw + + .got : AT (ADDR(.got) - offset) + { *(.got) - } - .got.plt : AT (ADDR(.got.plt) - offset) { + } : rw + + .got.plt : AT (ADDR(.got.plt) - offset) + { *(.got.plt) - } - .bss : AT (ADDR(.bss) - offset) { + } : rw + + .bss : AT (ADDR(.bss) - offset) + { *(.bss) - } + } : rw _end = .; } diff --git a/conts/posix/test0/include/test_exec_linker.lds.in b/conts/posix/test0/include/test_exec_linker.lds.in index 001ce21..f8b38fe 100644 --- a/conts/posix/test0/include/test_exec_linker.lds.in +++ b/conts/posix/test0/include/test_exec_linker.lds.in @@ -8,18 +8,29 @@ virtual_base = %s; /* First page before the env/args */ - +OUTPUT_ARCH(arm) ENTRY(_start) +PHDRS +{ + rx PT_LOAD; + rw PT_LOAD; +} + SECTIONS { . = virtual_base; - .text : { *(.text.head) *(.text) } - .rodata : { *(.rodata) } - .rodata1 : { *(.rodata1) } + + /* RX, RO sections */ + .text : { *(.text.head) *(.text) } : rx =0x90909090 + .rodata : { *(.rodata) } : rx =0x90909090 + .rodata1 : { *(.rodata1) } : rx =0x90909090 + . = ALIGN(4K); - .data : { *(.data) } - .got : { *(.got) } - .got.plt : { *(.got.plt) } - .bss : { *(.bss) } + + /* RW sections */ + .data : { *(.data) } : rw + .got : { *(.got) } : rw + .got.plt : { *(.got.plt) } :rw + .bss : { *(.bss) } : rw } diff --git a/conts/posix/test0/src/ipctest.c b/conts/posix/test0/src/ipctest.c index d0daa36..fe464f5 100644 --- a/conts/posix/test0/src/ipctest.c +++ b/conts/posix/test0/src/ipctest.c @@ -74,6 +74,7 @@ void ipc_extended_test(void) /* This test makes this assumption */ BUG_ON(L4_IPC_EXTENDED_MAX_SIZE > PAGE_SIZE); +#if 0 /* * Request capability to ipc to each other from pager * (Actually only the sender needs it) @@ -92,6 +93,7 @@ void ipc_extended_test(void) "err = %d\n", err); goto out_err; } +#endif /* * Both child and parent gets 2 pages diff --git a/conts/posix/test0/src/mutextest.c b/conts/posix/test0/src/mutextest.c index 3b39908..2be2348 100644 --- a/conts/posix/test0/src/mutextest.c +++ b/conts/posix/test0/src/mutextest.c @@ -36,7 +36,6 @@ int user_mutex_test(void) { pid_t child, parent; int map_size = PAGE_SIZE; - struct capability cap; void *base; int err; @@ -74,7 +73,7 @@ int user_mutex_test(void) test_printf("%d: Created child with pid %d\n", getpid(), child); else test_printf("Child %d running.\n", getpid()); - +#if 0 /* * Request capability to ipc to each other from pager * (Actually only the sender needs it) @@ -95,6 +94,7 @@ int user_mutex_test(void) "err = %d\n", err); goto out_err; } +#endif /* Child locks and produces */ if (child == 0) { diff --git a/conts/test_suite0/SConstruct b/conts/test_suite0/SConstruct deleted file mode 100644 index 7abd41f..0000000 --- a/conts/test_suite0/SConstruct +++ /dev/null @@ -1,71 +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 -subarch = config.subarch -platform = config.platform -gcc_arch_flag = config.gcc_arch_flag - -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'), join(LIBDEV_DIR, 'include')] - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) -LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) -LIBMEM_INCLUDE = LIBMEM_DIR - -env = Environment(CC = config.toolchain_userspace + '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', '-march=' + gcc_arch_flag], - LINKFLAGS = ['-nostdlib', '-T' + "include/project_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', 'libmc', 'c-userspace', 'libdev-userspace', 'gcc', 'libmalloc', - 'c-userspace'], # libgcc.a - This is required for division routines. - CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, LIBC_INCLUDE, LIBMEM_INCLUDE], - LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH], - CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') - -src = Glob('*.[cS]') -src += Glob('src/*.[cS]') -src += Glob('src/arch/' + arch + '/*.[cS]') -src += Glob('src/api/*.c'); -src += Glob('src/perf/*.c'); -src += Glob('src/cli_serv/*.c'); -src += Glob('src/mthread/*.c'); -src += Glob('src/arch/' + arch + '/' + subarch + '/*.[cS]') -objs = env.Object(src) -prog = env.Program('main.elf', objs) -Depends(prog, 'include/linker.lds') diff --git a/conts/test_suite0/include/capability.h b/conts/test_suite0/include/capability.h deleted file mode 100644 index f30cb58..0000000 --- a/conts/test_suite0/include/capability.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __CAPABILITY_H__ -#define __CAPABILITY_H__ - -int caps_read_all(); - -#endif /* __CAPABILITY_H__ */ diff --git a/conts/test_suite0/include/linker.lds b/conts/test_suite0/include/linker.lds deleted file mode 100644 index 45a75c3..0000000 --- a/conts/test_suite0/include/linker.lds +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Example working linker script for this container. - * - * Copyright (C) 2009 B Labs Ltd. - */ - -vma_start = 0xa0000000; -lma_start = 0x100000; -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 = .; - } - __end = .; -} diff --git a/conts/test_suite0/include/tests.h b/conts/test_suite0/include/tests.h deleted file mode 100644 index e3e9b0d..0000000 --- a/conts/test_suite0/include/tests.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __TESTS_H__ -#define __TESTS_H__ - -/* Abort debugging conditions */ -#define DEBUG_TESTS 0 -#if DEBUG_TESTS -#define dbg_printf(...) printf(__VA_ARGS__) -#else -#define dbg_printf(...) -#endif - -int test_smp(); -int test_performance(); -int test_api(); -int test_cli_serv(); -int test_mthread(); - -#endif /* __TESTS_H__ */ diff --git a/conts/test_suite0/include/thread.h b/conts/test_suite0/include/thread.h deleted file mode 100644 index 1805d27..0000000 --- a/conts/test_suite0/include/thread.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __THREAD_H__ -#define __THREAD_H__ - -#include -#include L4LIB_INC_ARCH(syslib.h) -#include L4LIB_INC_ARCH(syscalls.h) -#include -#include - - -int thread_create(int (*func)(void *), void *args, unsigned int flags, - struct task_ids *new_ids); - -/* For same space */ -#define STACK_SIZE 0x1000 - -#define THREADS_TOTAL 10 - -#endif /* __THREAD_H__ */ diff --git a/conts/test_suite0/main.c b/conts/test_suite0/main.c deleted file mode 100644 index ad6537d..0000000 --- a/conts/test_suite0/main.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Main function for all tests - * - * Copyright (C) 2009 B Labs Ltd. - */ -#include -#include L4LIB_INC_ARCH(syslib.h) -#include L4LIB_INC_ARCH(syscalls.h) -#include -#include -#include -#include -#include - - -void run_tests(void) -{ - /* Performance tests */ - //if (test_performance() < 0) - // printf("Performance tests failed.\n"); - - if (test_smp() < 0) - printf("SMP tests failed.\n"); - - /* API Tests */ - if (test_api() < 0) - printf("API tests failed.\n"); - - /* Container client/server setup test */ - if (test_cli_serv() < 0) - printf("Client/server tests failed.\n"); - - /* Container multithreaded/standalone setup test */ - if (test_mthread() < 0) - printf("Multi-threaded tests failed.\n"); -} - -int main(void) -{ - printf("%s: Container %s started\n", - __CONTAINER__, __CONTAINER_NAME__); - - run_tests(); - - return 0; -} - diff --git a/conts/test_suite0/src/capability.c b/conts/test_suite0/src/capability.c deleted file mode 100644 index 95b96ff..0000000 --- a/conts/test_suite0/src/capability.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Capability-related userspace helpers - * - * Copyright (C) 2009 B Labs Ltd. - */ -#include -#include -#include -#include L4LIB_INC_ARCH(syscalls.h) - -#if 0 -static struct capability cap_array[30]; - -struct cap_group { - struct cap_list virtmem; - struct cap_list physmem; - struct cap_list threadpool; - struct cap_list tctrl; - struct cap_list exregs; - struct cap_list ipc; - struct cap_list mutex; - struct cap_list sched; - struct cap_list mutexpool; - struct cap_list spacepool; - struct cap_list cappool; -}; - -static inline struct capability *cap_get_thread() -{ - -} - -static inline struct capability *cap_get_space() -{ - -} - -static inline struct capability *cap_get_ipc() -{ - -} - -static inline struct capability *cap_get_virtmem() -{ - -} - -static inline struct capability *cap_get_physmem() -{ - -} - -static inline struct capability *cap_get_physmem(unsigned long phys) -{ - -} - -static inline struct capability *cap_get_virtmem(unsigned long virt) -{ - -} - -static inline struct capability *cap_get_byid(l4id_t id) -{ - -} - - -void cap_share_single(struct capability *orig, struct capability *share, l4id_t target, unsigned int flags) -{ - -} - -void cap_grant_single(struct capability *orig, struct capability *share, l4id_t target, unsigned int flags) -{ -} - - -int caps_read_all(void) -{ - int ncaps; - int err; - - /* Read number of capabilities */ - if ((err = l4_capability_control(CAP_CONTROL_NCAPS, - 0, &ncaps)) < 0) { - printf("l4_capability_control() reading # of" - " capabilities failed.\n Could not " - "complete CAP_CONTROL_NCAPS request.\n"); - BUG(); - } - - /* Read all capabilities */ - if ((err = l4_capability_control(CAP_CONTROL_READ, - 0, cap_array)) < 0) { - printf("l4_capability resource_control() reading of " - "capabilities failed.\n Could not " - "complete CAP_CONTROL_READ_CAPS request.\n"); - BUG(); - } - //cap_array_print(ncaps, caparray); - - return 0; -} - -#endif diff --git a/conts/test_suite0/src/captest.c b/conts/test_suite0/src/captest.c deleted file mode 100644 index 94b9365..0000000 --- a/conts/test_suite0/src/captest.c +++ /dev/null @@ -1,148 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include L4LIB_INC_ARCH(syslib.h) -#include - -int simple_pager_thread(void *arg) -{ - int err; - int res = *(int *)arg; - struct task_ids ids; - int testres = 0; - - l4_getid(&ids); - - printf("Thread spawned from pager, \ - trying to create new thread.\n"); - err = l4_thread_control(THREAD_CREATE | - TC_SHARE_SPACE, &ids); - - if (res == 0) - if (err == -ENOCAP || - err == -ENOMEM) { - printf("Creation failed with %d " - "as expected.\n", err); - testres = 0; - } else { - printf("Creation was supposed to fail " - "with %d or %d, but err = %d\n", - -ENOMEM, -ENOCAP, err); - testres = 1; - } - else - if (err == 0) { - // printf("Creation succeeded as expected.\n"); - testres = 0; - } else { - printf("Creation was supposed to succeed, " - "but err = %d\n", err); - testres = 1; - } - - /* Destroy thread we created */ - if (err == 0 && - res == 0) - l4_thread_control(THREAD_DESTROY, &ids); - - /* Destroy self */ - l4_exit(testres); - - return 0; -} - -int wait_check_test(struct task_ids *ids) -{ - int result; - - /* Wait for thread to finish */ - result = l4_thread_control(THREAD_WAIT, ids); - if (result < 0) { - printf("Waiting on (%d)'s exit failed.\n", ids->tid); - return -1; - } else if (result > 0) { - printf("Top-level test has failed\n"); - } - /* Else it is a success */ - - return 0; -} - -int capability_test(void) -{ - int err; - struct task_ids ids; - int TEST_MUST_FAIL = 0; - //int TEST_MUST_SUCCEED = 1; - - /* Read pager capabilities */ - caps_read_all(); - - /* - * Create new thread that will attempt - * a pager privileged operation - */ - if ((err = thread_create(simple_pager_thread, - &TEST_MUST_FAIL, - TC_SHARE_SPACE, &ids)) < 0) { - printf("Top-level simple_pager creation failed.\n"); - goto out_err; - } - - printf("waititng for result\n"); - /* Wait for test to finish and check result */ - if (wait_check_test(&ids) < 0) - goto out_err; -#if 0 - - /* Destroy test thread */ - if ((err = l4_thread_control(THREAD_DESTROY, &ids)) < 0) { - printf("Destruction of top-level simple_pager failed.\n"); - BUG(); - } - - /* - * Share operations with the same thread - * group - */ - if ((err = l4_capability_control(CAP_CONTROL_SHARE, - CAP_SHARE_CONTAINER, 0)) < 0) { - printf("Sharing capability with thread group failed.\n"); - goto out_err; - } - - /* - * Create new thread that will attempt a pager privileged - * operation. This should succeed as we shared caps with - * the thread group. - */ - if ((err = thread_create(simple_pager_thread, - &TEST_MUST_SUCCEED, - TC_SHARE_SPACE | - TC_SHARE_GROUP, &ids)) < 0) { - printf("Top-level simple_pager creation failed.\n"); - goto out_err; - } - - /* Wait for test to finish and check result */ - if (wait_check_test(&ids) < 0) - goto out_err; - - /* Destroy test thread */ - if ((err = l4_thread_control(THREAD_DESTROY, &ids)) < 0) { - printf("Destruction of top-level simple_pager failed.\n"); - BUG(); - } -#endif - - printf("Capability Sharing Test -- PASSED --\n"); - - return 0; - -out_err: - printf("Capability Sharing Test -- FAILED --\n"); - return 0; -} diff --git a/conts/test_suite0/src/example.c b/conts/test_suite0/src/example.c deleted file mode 100644 index 6321f2d..0000000 --- a/conts/test_suite0/src/example.c +++ /dev/null @@ -1,220 +0,0 @@ - -#if 0 - -int mutex_user_thread(void *arg) -{ - /* TODO: Create and access a mutex */ -} - -int independent_thread(void *arg) -{ - /* TODO: Do whatever syscall available */ -} - - -/* - * This example demonstrates how the capability-based - * security model can be bypassed and taken out of the - * way for the sake of implementing an application that - * doesn't worry too much about security. - * - * The benefit is that the user does neither worry about - * capabilities nor using its api to design correctly - * secure systems. The downside is that the system is - * less security-enforced, i.e. all parties must be - * trusted. - */ -int multi_threaded_nocaps_example(void) -{ - /* - * We are the first pager with capabilities to - * create new tasks, spaces, in its own container. - */ - pager_read_caps(); - - /* - * We have all our capabilities private to us. - * - * If we create a new task, it won't be able to - * any kernel operations that we can do, because - * we hold our capabilities privately. - * - * In order to settle all capability access issues - * once and for all threads we will create and manage, - * we share our capabilities with the most global - * collection possible. - */ - - /* - * Share all of our capabilities with all threads - * in the same container. - * - * From this point onwards, any thread we create and - * manage (i.e. whose container id is equal to our - * container id) will have the ability to leverage - * all of our capabilities as defined for us at - * configuration time. - */ - l4_cap_share(0, CAP_SHARE_CONTAINER | CAP_SHARE_ALL, self_tid()); - - - /* - * Lets try it. - * - * Create new thread that we don't have any hieararchical - * relationship, i.e. one that is a pager of itself, one - * that runs in a new address space, and in a new thread - * group. All we share is the container. - */ - if ((err = thread_create(independent_thread, 0, - TC_NO_SHARING, &ids)) < 0) { - printf("mutex_user_thread creation failed.\n"); - goto out_err; - } - - /* - * We can inspect the new thread by doing an ipc to it. - * NOTE: - * - * We are able to send to this thread from the start, - * as we had a container-wide ipc capability defined at - * config-time. - * - * But we would not be able to receive from it, if we - * did not share this capability with the container. It - * would have no rights to do a send to us. But because - * we're in the same container, and we shared our - * capability, it now can. - */ - if ((err = l4_recv(ids->tid, ids->tid, 0)) < 0) { - print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd); - goto out_err; - } - - /* - * From this point onwards we can create more threads - * without worrying about whether they have the caps - * to do certain ops, and the caps api. because we shared - * them all at the beginning. - */ - -out_err: - BUG(); -} - -/* - * This example demonstrates how a pager would - * share part of its capabilities on the system - * with its children. - * - * The example includes sharing of a mutex - * capability with a paged-child. - */ -int multi_threaded_capability_sharing_example(void) -{ - struct capability *mutex_cap; - int thread_retval; - - /* - * We are the first pager with capabilities to - * create new tasks, spaces, in its own container. - */ - pager_read_caps(); - - /* - * We have all our capabilities private to us. - * - * If we create a new task, it won't be able to - * create and use userspace mutexes, because we - * hold mutex capabilities privately. - * - * Lets try it. - */ - - /* - * Create new thread that will attempt - * a mutex operation, and die on us with a - * negative return code if it fails. - */ - if ((err = thread_create(mutex_user_thread, 0, - TC_SHARE_SPACE | - TC_AS_PAGER, &ids)) < 0) { - printf("mutex_user_thread creation failed.\n"); - goto out_err; - } - - /* Check on how the thread has done */ - if ((err = l4_thread_wait_on(ids, &thread_retval)) < 0) { - print("Waiting on thread %d failed. err = %d\n", - ids->tid, err); - goto out_err; - } - - if (thread_retval == 0) { - printf("Thread %d returned with success, where " - "we expected failure.\n", ids->tid); - goto out_err; - } - - /* - * Therefore, we share our capabilities with a - * collection so that our capabilities may be also - * used by them. - */ - - /* Get our private mutex cap */ - mutex_cap = cap_get(CAP_TYPE_MUTEX); - - /* We have ability to create and use this many mutexes */ - printf("%s: We have ability to create/use %d mutexes\n", - self_tid(), mutex_cap->size); - - /* Split it */ - cap_new = cap_split(mutex_cap, 10, CAP_SPLIT_SIZE); - - /* - * Share the split part with paged-children. - * - * From this point onwards, any thread we create and - * manage (i.e. whose pagerid == self_tid()) will have - * the ability to use mutexes, as defined by cap_new - * we created. - */ - l4_cap_share(cap_new, CAP_SHARE_PGGROUP, self_tid()); - - /* - * Create new thread that will attempt - * a mutex operation, and die on us with a - * negative return code if it fails. - */ - if ((err = thread_create(mutex_user_thread, 0, - TC_SHARE_SPACE | - TC_AS_PAGER, &ids)) < 0) { - printf("mutex_user_thread creation failed.\n"); - goto out_err; - } - - /* Check on how the thread has done */ - if ((err = l4_thread_wait_on(ids, &thread_retval)) < 0) { - printf("Waiting on thread %d failed. err = %d\n", - ids->tid, err); - goto out_err; - } - - if (thread_retval < 0) { - printf("Thread %d returned with failure, where " - "we expected success.\n", ids->tid); - goto out_err; - } - -out_err: - BUG(); -} - - - - - - -#endif - diff --git a/conts/test_suite0/src/perf/tswitch.c b/conts/test_suite0/src/perf/tswitch.c deleted file mode 100644 index e69de29..0000000 diff --git a/conts/userlibs/SConscript b/conts/userlibs/SConscript new file mode 100644 index 0000000..ba35a28 --- /dev/null +++ b/conts/userlibs/SConscript @@ -0,0 +1,39 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, sys +from os.path import * + +Import('env', 'build_dir') + +PROJRELROOT = '../..' +sys.path.append(PROJRELROOT) + +libl4 = SConscript('libl4/SConscript', duplicate = 0, + exports = { 'env' : env }, + variant_dir = join(build_dir, 'libl4')) + +e = env.Clone() +e.Replace(CPPFLAGS = '') +type = 'userspace' +libdev_builddir = join(join(build_dir, 'libdev'), 'sys-' + type) +libdev = SConscript('libdev/SConscript', duplicate = 0, + exports = { 'env' : e, 'type' : type, 'build_dir' : libdev_builddir }) + +libc = SConscript('libc/SConscript', duplicate = 0, + exports = { 'env' : env, 'type' : 'userspace' }, + variant_dir = join(build_dir, 'libc')) + +libmem = SConscript('libmem/SConscript', duplicate = 0, + exports = { 'env' : env, }, + variant_dir = join(build_dir, 'libmem')) + +Alias('libl4', libl4) +Alias('libdev', libdev) +Alias('libc', libc) +Alias('libmem', libmem) +#Alias('libmc', libmc) +#Alias('libmalloc',libmalloc) diff --git a/conts/userlibs/SConstruct b/conts/userlibs/SConstruct new file mode 100644 index 0000000..41c7913 --- /dev/null +++ b/conts/userlibs/SConstruct @@ -0,0 +1,39 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, sys +from os.path import * + +PROJRELROOT = '../..' +sys.path.append(PROJRELROOT) + +from scripts.config.config_invoke import * + +config = configuration_retrieve() +gcc_arch_flag = config.gcc_arch_flag + +builddir = join(BUILDDIR, USERLIBS_RELDIR) + +env = Environment(CC = config.toolchain_userspace + 'gcc', + AR = config.toolchain_userspace + 'ar', + RANLIB = config.toolchain_userspace + 'ranlib', + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib'], + ASFLAGS = ['-D__ASSEMBLY__', '-march=' + gcc_arch_flag], + ENV = {'PATH' : os.environ['PATH']}, + LIBS = 'gcc', # libgcc.a - Required for division routines. + CPPPATH = KERNEL_HEADERS, + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + +# Set the build directory for this source tree +VariantDir(builddir, os.getcwd()) + +SConscript('SConscript', duplicate = 0, + exports = { 'env' : env, 'build_dir' : builddir }) + diff --git a/conts/userlibs/libc/SConscript b/conts/userlibs/libc/SConscript new file mode 100644 index 0000000..b163693 --- /dev/null +++ b/conts/userlibs/libc/SConscript @@ -0,0 +1,37 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd + +import os, sys, shelve +from os.path import join + +# Get global paths +PROJRELROOT = '../../../' +sys.path.append(PROJRELROOT) + +from scripts.config.configuration import * +from scripts.config.projpaths import * + +config = configuration_retrieve() +arch = config.arch + +Import('env', 'type') + +e = env.Clone() +e.Append(CPPPATH = ['include', 'include/sys-' + type + '/arch-' + arch, LIBDEV_INCLUDE], + CCFLAGS = ['-nostdinc']) + +source = \ + Glob('src/*.[cS]') + \ + Glob('src/sys-' + type + '/*.c') + \ + Glob('src/sys-' + type + '/arch-' + arch + '/*.c') + \ + Glob('src/arch-' + arch + '/*.c') + \ + Glob('src/arch-' + arch + '/*.S') + \ + Glob('crt/sys-' + type + '/arch-' + arch + '/*.[cS]') + +objects = e.StaticObject(source) +library = e.StaticLibrary('c-' + type, objects) + +Return('library') diff --git a/conts/userlibs/libc/SConstruct b/conts/userlibs/libc/SConstruct new file mode 100644 index 0000000..dc164a7 --- /dev/null +++ b/conts/userlibs/libc/SConstruct @@ -0,0 +1,40 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- a microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, sys + +PROJRELROOT = '../../..' +sys.path.append(PROJRELROOT) + +from scripts.config.projpaths import * +from scripts.config.configuration import * + +config = configuration_retrieve() +gcc_arch_flag = config.gcc_arch_flag +arch = config.arch + +# We assume we are compiling for userspace. +# variant can be specified from cmdline using +# scons variant=xxx +variant = ARGUMENTS.get('variant', 'userspace') +print '\nCompiling for variant: ' + variant + '\n' + +builddir = join(BUILDDIR, LIBC_RELDIR) +VariantDir(builddir, os.getcwd(), 0) + +env = Environment(CC = config.toolchain_userspace + 'gcc', + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', + '-nostdinc', '-Wall', '-Werror', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib'], + ASFLAGS = ['-D__ASSEMBLY__'], + ENV = {'PATH' : os.environ['PATH']}, + CPPPATH = ['include', LIBDEV_INCLUDE, KERNEL_HEADERS, + 'include/sys-' + variant + '/arch-' + arch], + CPPFLAGS = '-include l4/macros.h') + +objects = SConscript('SConscript', exports = { 'env' : env, 'type' : variant }, + duplicate=0, build_dir = builddir) + diff --git a/conts/libc/crt/sys-userspace/arch-arm/crt0.S b/conts/userlibs/libc/crt/sys-userspace/arch-arm/crt0.S similarity index 100% rename from conts/libc/crt/sys-userspace/arch-arm/crt0.S rename to conts/userlibs/libc/crt/sys-userspace/arch-arm/crt0.S diff --git a/conts/libc/include/assert.h b/conts/userlibs/libc/include/assert.h similarity index 100% rename from conts/libc/include/assert.h rename to conts/userlibs/libc/include/assert.h diff --git a/conts/libc/include/limits.h b/conts/userlibs/libc/include/limits.h similarity index 100% rename from conts/libc/include/limits.h rename to conts/userlibs/libc/include/limits.h diff --git a/conts/libc/include/stdarg.h b/conts/userlibs/libc/include/stdarg.h similarity index 100% rename from conts/libc/include/stdarg.h rename to conts/userlibs/libc/include/stdarg.h diff --git a/conts/libc/include/stdbool.h b/conts/userlibs/libc/include/stdbool.h similarity index 100% rename from conts/libc/include/stdbool.h rename to conts/userlibs/libc/include/stdbool.h diff --git a/conts/libc/include/stddef.h b/conts/userlibs/libc/include/stddef.h similarity index 100% rename from conts/libc/include/stddef.h rename to conts/userlibs/libc/include/stddef.h diff --git a/conts/libc/include/stdint.h b/conts/userlibs/libc/include/stdint.h similarity index 100% rename from conts/libc/include/stdint.h rename to conts/userlibs/libc/include/stdint.h diff --git a/conts/libc/include/stdio.h b/conts/userlibs/libc/include/stdio.h similarity index 100% rename from conts/libc/include/stdio.h rename to conts/userlibs/libc/include/stdio.h diff --git a/conts/libc/include/string.h b/conts/userlibs/libc/include/string.h similarity index 100% rename from conts/libc/include/string.h rename to conts/userlibs/libc/include/string.h diff --git a/conts/libc/include/sys-baremetal/arch-arm/arch/stdint.h b/conts/userlibs/libc/include/sys-baremetal/arch-arm/arch/stdint.h similarity index 100% rename from conts/libc/include/sys-baremetal/arch-arm/arch/stdint.h rename to conts/userlibs/libc/include/sys-baremetal/arch-arm/arch/stdint.h diff --git a/conts/libc/include/sys-userspace/arch-arm/arch/stdint.h b/conts/userlibs/libc/include/sys-userspace/arch-arm/arch/stdint.h similarity index 100% rename from conts/libc/include/sys-userspace/arch-arm/arch/stdint.h rename to conts/userlibs/libc/include/sys-userspace/arch-arm/arch/stdint.h diff --git a/conts/libc/src/arch-arm/eabi.c b/conts/userlibs/libc/src/arch-arm/eabi.c similarity index 100% rename from conts/libc/src/arch-arm/eabi.c rename to conts/userlibs/libc/src/arch-arm/eabi.c diff --git a/conts/libc/src/memcpy.S b/conts/userlibs/libc/src/arch-arm/memcpy.S similarity index 100% rename from conts/libc/src/memcpy.S rename to conts/userlibs/libc/src/arch-arm/memcpy.S diff --git a/conts/libc/src/memset.S b/conts/userlibs/libc/src/arch-arm/memset.S similarity index 100% rename from conts/libc/src/memset.S rename to conts/userlibs/libc/src/arch-arm/memset.S diff --git a/conts/libc/src/format.c b/conts/userlibs/libc/src/format.c similarity index 100% rename from conts/libc/src/format.c rename to conts/userlibs/libc/src/format.c diff --git a/conts/libc/src/format.h b/conts/userlibs/libc/src/format.h similarity index 100% rename from conts/libc/src/format.h rename to conts/userlibs/libc/src/format.h diff --git a/conts/libc/src/fputc.c b/conts/userlibs/libc/src/fputc.c similarity index 100% rename from conts/libc/src/fputc.c rename to conts/userlibs/libc/src/fputc.c diff --git a/conts/libc/src/memcmp.c b/conts/userlibs/libc/src/memcmp.c similarity index 100% rename from conts/libc/src/memcmp.c rename to conts/userlibs/libc/src/memcmp.c diff --git a/conts/userlibs/libc/src/memcpy.c b/conts/userlibs/libc/src/memcpy.c new file mode 100644 index 0000000..1a045e8 --- /dev/null +++ b/conts/userlibs/libc/src/memcpy.c @@ -0,0 +1,117 @@ +/* + * Copyright B Labs(R) Ltd. + * Author: Prem Mallappa < prem.mallappa@b-labs.co.uk > + * Generic memcpy, fairly optimized + */ + +void +__attribute__ ((weak)) +*memcpy(void *dst, void *src, size_t len) +{ + unsigned char *s=src, *d=dst; + unsigned remain = 0; + unsigned align_mask = sizeof(unsigned long) - 1; + unsigned alignment = ((unsigned long)s & align_mask) | + ((unsigned long)d & align_mask); + + remain = len & align_mask; + + if (alignment == 0) { + unsigned long *sl = (unsigned long*)s, *dl = (unsigned long*)d; + while(len > remain) { + *dl++ = *sl++; + len -= sizeof(unsigned long); + } + s = (unsigned char *)sl; d = (unsigned char *)dl; + } + else if (alignment == 2) { + unsigned short *sh = (unsigned short *)s, *dh = (unsigned short *)d; + while (len > remain) { + *dh++ = *sh++; + len -= sizeof(unsigned short); + } + s = (unsigned char *)sh; d = (unsigned char *)dh; + } + else { + while (len--) + *d++ = *s++; + } + + switch(remain) { + case 3: + *d++ = *s++; + case 2: + *d++ = *s++; + case 1: + *d++ = *s++; + default: break; + } + + return dst; +} + +#if 0 +/* TEST */ + +int memcmp1(void *src, void *dst, size_t len) +{ + char *s = src, *d = dst; + int i; + for(i=0; i < len; i++) { + printf("%d %x %x\n", i, s[i], d[i]); + if(s[i] != d[i]) + break; + } + + if (i!=len) { + printf("diff at %d, src: %x, dst: %x\n", i, s[i], d[i]); + return 1; + } + return 0; +} + +int main(void) +{ + char s[100]__attribute__((aligned (8))), d[100]__attribute__((aligned (8))); + int i; +/* TEST 1 */ + for (i = 0; i < sizeof(s); i++) { + s[i] = i; + d[i] = 0; + } + + memcpy1(&s[0], &d[0], 3); + if(memcmp(&s[0], &d[0], 3)) + memcmp1(&s[0], &d[0], 3); + +/* TEST 2 */ + for (i = 0; i < sizeof(s); i++) { + s[i] = i; + d[i] = 0; + } + + memcpy1(&s[1], &d[0], 6); + if(memcmp(&s[1], &d[0], 6)) + memcmp1(&s[1], &d[0], 6); + +/* TEST 3 */ + for (i = 0; i < sizeof(s); i++) { + s[i] = i; + d[i] = 0; + } + memcpy1(&s[2], &d[1], 7); + if(memcmp(&s[2], &d[1], 7)) + memcmp1(&s[2], &d[1], 7); + +/* TEST 4 */ + for (i = 0; i < sizeof(s); i++) { + s[i] = i; + d[i] = 0; + } + memcpy1(&s[2], &d[3], 7); + if(memcmp(&s[2], &d[3], 7)) + memcmp1(&s[2], &d[3], 7); + + return 0; +} +#endif diff --git a/conts/userlibs/libc/src/memset.c b/conts/userlibs/libc/src/memset.c new file mode 100644 index 0000000..49d1115 --- /dev/null +++ b/conts/userlibs/libc/src/memset.c @@ -0,0 +1,122 @@ +/* + * Copyright B Labs(R) Ltd. + * Author: Prem Mallappa < prem.mallappa@b-labs.co.uk > + * Generic memset, still optimized + */ + +void +__attribute__ ((weak)) +*memset(void *dst, int c, size_t len) +{ + unsigned char *d=dst; + c &= 0xff; + unsigned short cs = (c << 8) | c; + unsigned long cl = (cs << 16) | cs; + unsigned align_mask = sizeof(unsigned long) - 1; + unsigned alignment = (len & align_mask) | + ((unsigned long)dst & (unsigned long)align_mask); + + + switch (alignment) { + case 3: + if (len--) { + *d++ = c; + alignment--; + } + case 2: + if (len--) { + *d++ = c; + alignment--; + } + case 1: + if (len--) { + *d++ = c; + alignment--; + } + default: break; + } + + unsigned remain = len & align_mask; + len -= remain; + + unsigned long *dl = (unsigned long*)d; + while (len > remain) { + *dl++ = cl; + len -= sizeof(unsigned long); + } + d = (unsigned char *)dl; + + switch(remain) { + case 3: + *d++ = c; + case 2: + *d++ = c; + case 1: + *d++ = c; + default: break; + } + + return dst; +} + + +#if 0 +/* TEST */ + +int memcmp1(void *dst, int c, size_t len) +{ + char *d = dst; + int i; + for(i=0; i < len; i++) { + printf(" %d: %x \n",i, d[i]); + if(d[i] != c & 0xff) + break; + } + + if (i < len) { + printf("diff at %d, dst: %x\n", i, d[i]); + + return 1; + } + return 0; +} + +int main(void) +{ + char d[100]; + int i; + for (i = 0; i < sizeof(d); i++) { + d[i] = 0; + } + + memset1(&d[0], 0x55, 4); + memcmp1(&d[0], 0x55, 4); + + memset(&d, 0x0, 100); + + memset1(&d[0], 0x55, 2); + memcmp1(&d[0], 0x55, 2); + + memset(&d, 0x0, 100); + + memset1(&d[0], 0x55, 1); + memcmp1(&d[0], 0x55, 1); + + memset(&d, 0x0, 100); + + memset1(&d[1], 0x55, 8); + memcmp1(&d[1], 0x55, 8); + + memset(&d, 0x0, 100); + + memset1(&d[1], 0x55, 1); + memcmp1(&d[1], 0x55, 1); + + memset(&d, 0x0, 100); + + memset1(&d[1], 0x55, 3); + memcmp1(&d[1], 0x55, 3); + + return 0; +} +#endif diff --git a/conts/libc/src/printf.c b/conts/userlibs/libc/src/printf.c similarity index 100% rename from conts/libc/src/printf.c rename to conts/userlibs/libc/src/printf.c diff --git a/conts/libc/src/sprintf.c b/conts/userlibs/libc/src/sprintf.c similarity index 100% rename from conts/libc/src/sprintf.c rename to conts/userlibs/libc/src/sprintf.c diff --git a/conts/libc/src/strcmp.c b/conts/userlibs/libc/src/strcmp.c similarity index 100% rename from conts/libc/src/strcmp.c rename to conts/userlibs/libc/src/strcmp.c diff --git a/conts/libc/src/strcpy.c b/conts/userlibs/libc/src/strcpy.c similarity index 100% rename from conts/libc/src/strcpy.c rename to conts/userlibs/libc/src/strcpy.c diff --git a/conts/libc/src/strlen.c b/conts/userlibs/libc/src/strlen.c similarity index 100% rename from conts/libc/src/strlen.c rename to conts/userlibs/libc/src/strlen.c diff --git a/conts/libc/src/strncmp.c b/conts/userlibs/libc/src/strncmp.c similarity index 100% rename from conts/libc/src/strncmp.c rename to conts/userlibs/libc/src/strncmp.c diff --git a/conts/libc/src/strncpy.c b/conts/userlibs/libc/src/strncpy.c similarity index 100% rename from conts/libc/src/strncpy.c rename to conts/userlibs/libc/src/strncpy.c diff --git a/conts/libc/src/sys-userspace/arch-arm/sys_fputc.c b/conts/userlibs/libc/src/sys-userspace/arch-arm/sys_fputc.c similarity index 89% rename from conts/libc/src/sys-userspace/arch-arm/sys_fputc.c rename to conts/userlibs/libc/src/sys-userspace/arch-arm/sys_fputc.c index 4ced173..9fb8271 100644 --- a/conts/libc/src/sys-userspace/arch-arm/sys_fputc.c +++ b/conts/userlibs/libc/src/sys-userspace/arch-arm/sys_fputc.c @@ -4,7 +4,7 @@ * Copyright (C) 2009 B Labs Ltd. */ #include -#include +#include int __fputc(int c, FILE *stream) { diff --git a/conts/libc/src/sys-userspace/arch-arm/sys_getc.c b/conts/userlibs/libc/src/sys-userspace/arch-arm/sys_getc.c similarity index 95% rename from conts/libc/src/sys-userspace/arch-arm/sys_getc.c rename to conts/userlibs/libc/src/sys-userspace/arch-arm/sys_getc.c index 2428f2f..475a6ff 100644 --- a/conts/libc/src/sys-userspace/arch-arm/sys_getc.c +++ b/conts/userlibs/libc/src/sys-userspace/arch-arm/sys_getc.c @@ -5,7 +5,7 @@ * */ #include -#include +#include char fgetc(FILE * file) { diff --git a/conts/libc/src/sys-userspace/arch-arm/sys_stdio.c b/conts/userlibs/libc/src/sys-userspace/arch-arm/sys_stdio.c similarity index 100% rename from conts/libc/src/sys-userspace/arch-arm/sys_stdio.c rename to conts/userlibs/libc/src/sys-userspace/arch-arm/sys_stdio.c diff --git a/conts/libc/src/vfprintf.c b/conts/userlibs/libc/src/vfprintf.c similarity index 100% rename from conts/libc/src/vfprintf.c rename to conts/userlibs/libc/src/vfprintf.c diff --git a/conts/userlibs/libdev/SConscript b/conts/userlibs/libdev/SConscript new file mode 100644 index 0000000..64dcfcb --- /dev/null +++ b/conts/userlibs/libdev/SConscript @@ -0,0 +1,40 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd + +import os, sys +from os.path import join + +# Get global paths +PROJRELROOT = '../../../' +sys.path.append(PROJRELROOT) + +from scripts.config.projpaths import * + +Import('env', 'type', 'build_dir') + +env.Append(CPPPATH = [LIBDEV_INCLUDE, LIBC_INCLUDE, LIBL4_INCLUDE], + CCFLAGS = ['-DVARIANT_' + type.upper()]) + +objects = SConscript('uart/pl011/SConscript', duplicate=0, exports = { 'env' : env }, + variant_dir = join(build_dir, 'uart/pl011')) + +objects += SConscript('timer/sp804/SConscript', duplicate=0, exports = { 'env' : env }, + variant_dir = join(build_dir, 'timer/sp804')) + +objects += SConscript('kmi/pl050/SConscript', duplicate=0, exports = { 'env' : env }, + variant_dir = join(build_dir, 'kmi/pl050')) + +objects += SConscript('clcd/pl110/SConscript', duplicate=0, exports = { 'env' : env }, + variant_dir = join(build_dir, 'clcd/pl110')) + +objects += SConscript('uart/omap/SConscript', duplicate=0, exports = { 'env' : env }, + variant_dir = join(build_dir, 'uart/omap')) + +objects += SConscript('timer/omap/SConscript', duplicate=0, exports = { 'env' : env }, + variant_dir = join(build_dir, 'timer/omap')) + +library = env.StaticLibrary(join(build_dir, 'libdev-' + type), objects) +Return('library') diff --git a/conts/userlibs/libdev/SConstruct b/conts/userlibs/libdev/SConstruct new file mode 100644 index 0000000..3da7ba0 --- /dev/null +++ b/conts/userlibs/libdev/SConstruct @@ -0,0 +1,56 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- a microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, sys + +PROJRELROOT = '../../..' +sys.path.append(PROJRELROOT) + +from scripts.config.projpaths import * +from scripts.config.configuration import * + +config = configuration_retrieve() +gcc_arch_flag = config.gcc_arch_flag + +# We assume we are compiling for userspace. +# variant can be specified from cmdline using +# scons variant=xxx +variant = ARGUMENTS.get('variant', 'userspace') +print '\nCompiling for variant: ' + variant + '\n' + +builddir = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-' + variant) +VariantDir(builddir, os.getcwd()) + +env = Environment(CC = config.toolchain_userspace + 'gcc', + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', + '-nostdinc', '-Wall', '-DVARIANT_' + variant.upper(), + '-march=' + gcc_arch_flag, '-Werror'], + LINKFLAGS = ['-nostdlib'], + ASFLAGS = ['-D__ASSEMBLY__'], + ENV = {'PATH' : os.environ['PATH']}, + CPPPATH = ['#include', LIBC_INCLUDE, LIBL4_INCLUDE, KERNEL_HEADERS]) + + +objects = SConscript('uart/pl011/SConscript', duplicate=0, + exports = { 'env' : env }, + variant_dir = join(builddir, 'uart/pl011')) +objects += SConscript('timer/sp804/SConscript', duplicate=0, + exports = { 'env' : env }, + variant_dir = join(builddir, 'timer/sp804')) +objects += SConscript('kmi/pl050/SConscript', duplicate=0, + exports = { 'env' : env }, + variant_dir = join(builddir, 'kmi/pl050')) +objects += SConscript('clcd/pl110/SConscript', duplicate=0, + exports = { 'env' : env }, + variant_dir = join(builddir, 'clcd/pl110')) +objects += SConscript('uart/omap/SConscript', duplicate=0, + exports = { 'env' : env }, + variant_dir = join(builddir, 'uart/omap')) +objects += SConscript('timer/omap/SConscript', duplicate=0, + exports = { 'env' : env }, + variant_dir = join(builddir, 'timer/omap')) + +library = env.StaticLibrary(join(builddir, 'libdev-' + variant), objects) diff --git a/conts/libdev/clcd/pl110/SConscript b/conts/userlibs/libdev/clcd/pl110/SConscript similarity index 51% rename from conts/libdev/clcd/pl110/SConscript rename to conts/userlibs/libdev/clcd/pl110/SConscript index e554dac..c11e3fa 100644 --- a/conts/libdev/clcd/pl110/SConscript +++ b/conts/userlibs/libdev/clcd/pl110/SConscript @@ -1,7 +1,16 @@ -Import('env', 'platform') +import sys +Import('env') + +# Get global paths +PROJRELROOT = '../../../' +sys.path.append(PROJRELROOT) + +from scripts.config.configuration import * +config = configuration_retrieve() +platform = config.platform #Platforms using pl110 -plat_list = ('eb', 'pba8', 'pba9', 'pb11mpcore', 'pb926') +plat_list = ('eb', 'pba9', 'pb926') # The set of source files associated with this SConscript file. src_local = [] diff --git a/conts/libdev/clcd/pl110/clcd.c b/conts/userlibs/libdev/clcd/pl110/clcd.c similarity index 100% rename from conts/libdev/clcd/pl110/clcd.c rename to conts/userlibs/libdev/clcd/pl110/clcd.c diff --git a/conts/libdev/clcd/pl110/clcd.h b/conts/userlibs/libdev/clcd/pl110/clcd.h similarity index 100% rename from conts/libdev/clcd/pl110/clcd.h rename to conts/userlibs/libdev/clcd/pl110/clcd.h diff --git a/conts/libdev/include/libdev/io.h b/conts/userlibs/libdev/include/dev/io.h similarity index 100% rename from conts/libdev/include/libdev/io.h rename to conts/userlibs/libdev/include/dev/io.h diff --git a/conts/libdev/include/libdev/kmi.h b/conts/userlibs/libdev/include/dev/kmi.h similarity index 100% rename from conts/libdev/include/libdev/kmi.h rename to conts/userlibs/libdev/include/dev/kmi.h diff --git a/conts/userlibs/libdev/include/dev/platform.h b/conts/userlibs/libdev/include/dev/platform.h new file mode 100644 index 0000000..d94be90 --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform.h @@ -0,0 +1,17 @@ +/* + * Generic platform file. + * + * Copyright (C) 2010 B Labs Ltd. + * + * Author: Bahadir Balban + */ +#ifndef __LIBDEV_PLATFORM_H__ +#define __LIBDEV_PLATFORM_H__ + +#define INC_LIBDEV_PLAT(x) + +/* paths realtive to conts/dev/ */ +#include INC_LIBDEV_PLAT(irq.h) +#include INC_LIBDEV_PLAT(platform.h) + +#endif /* __LIBDEV_PLATFORM_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/beagle/irq.h b/conts/userlibs/libdev/include/dev/platform/beagle/irq.h new file mode 100644 index 0000000..c11aa4b --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/beagle/irq.h @@ -0,0 +1,13 @@ +/* + * IRQ numbers for beagle board. + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_BEAGLE_IRQ_H__ +#define __LIBDEV_BEAGLE_IRQ_H__ + +#define IRQ_TIMER0 37 +#define IRQ_TIMER1 38 + +#endif /* __LIBDEV_BEAGLE_IRQ_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/beagle/platform.h b/conts/userlibs/libdev/include/dev/platform/beagle/platform.h new file mode 100644 index 0000000..552d80c --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/beagle/platform.h @@ -0,0 +1,13 @@ +/* + * Platform offsets for beagle board. + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_PLATFORM_BEAGLE_H__ +#define __LIBDEV_PLATFORM_BEAGLE_H__ + +#define PLATFORM_TIMER1_BASE 0x49032000 /* GPTIMER2 */ +#define PLATFORM_TIMER2_BASE 0x49034000 /* GPTIMER3 */ + +#endif /* __LIBDEV_PLATFORM_BEAGLE_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/eb/irq.h b/conts/userlibs/libdev/include/dev/platform/eb/irq.h new file mode 100644 index 0000000..91dd34e --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/eb/irq.h @@ -0,0 +1,22 @@ +/* + * IRQ numbers for eb. + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_EB_IRQ_H__ +#define __LIBDEV_EB_IRQ_H__ + +#if defined (CONFIG_CPU_ARM11MPCORE) || defined (CONFIG_CPU_CORTEXA9) +#define IRQ_TIMER1 34 +#define IRQ_KEYBOARD0 39 +#define IRQ_MOUSE0 40 +#define IRQ_CLCD0 55 +#else +#define IRQ_TIMER1 37 +#define IRQ_KEYBOARD0 52 +#define IRQ_MOUSE0 53 +#define IRQ_CLCD0 55 +#endif /* CONFIG_CPU_ARM11MPCORE || CONFIG_CPU_CORTEXA9 */ + +#endif /* __LIBDEV_EB_IRQ_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/eb/platform.h b/conts/userlibs/libdev/include/dev/platform/eb/platform.h new file mode 100644 index 0000000..c7419d5 --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/eb/platform.h @@ -0,0 +1,14 @@ +/* + * Platform offsets for eb. + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_PLATFORM_EB_H__ +#define __LIBDEV_PLATFORM_EB_H__ + +#include + +#define PLATFORM_CLCD0_BASE 0x10020000 /* CLCD0 */ + +#endif /* __LIBDEV_PLATFORM_EB_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/pb926/irq.h b/conts/userlibs/libdev/include/dev/platform/pb926/irq.h new file mode 100644 index 0000000..94db6b5 --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/pb926/irq.h @@ -0,0 +1,15 @@ +/* + * IRQ numbers for pb926. + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_PB926_IRQ_H__ +#define __LIBDEV_PB926_IRQ_H__ + +#define IRQ_TIMER1 5 +#define IRQ_CLCD0 16 +#define IRQ_KEYBOARD0 34 +#define IRQ_MOUSE0 35 + +#endif /* __LIBDEV_PB926_IRQ_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/pb926/platform.h b/conts/userlibs/libdev/include/dev/platform/pb926/platform.h new file mode 100644 index 0000000..3a43ff6 --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/pb926/platform.h @@ -0,0 +1,15 @@ +/* + * Platform offsets for pb926. + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_PLATFORM_PB926_H__ +#define __LIBDEV_PLATFORM_PB926_H__ + +#define PLATFORM_KEYBOARD0_BASE 0x10006000 /* Keyboard */ +#define PLATFORM_MOUSE0_BASE 0x10007000 /* Mouse */ +#define PLATFORM_TIMER1_BASE 0x101E3000 /* Timers 2 and 3 */ +#define PLATFORM_CLCD0_BASE 0x10120000 /* Color LCD */ + +#endif /* __LIBDEV_PLATFORM_PB926_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/pba9/irq.h b/conts/userlibs/libdev/include/dev/platform/pba9/irq.h new file mode 100644 index 0000000..725084c --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/pba9/irq.h @@ -0,0 +1,15 @@ +/* + * IRQ numbers for pba9. + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_PBA9_IRQ_H__ +#define __LIBDEV_PBA9_IRQ_H__ + +#define IRQ_TIMER1 35 +#define IRQ_KEYBOARD0 44 +#define IRQ_MOUSE0 45 +#define IRQ_CLCD0 46 + +#endif /* __LIBDEV_PBA9_IRQ_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/pba9/platform.h b/conts/userlibs/libdev/include/dev/platform/pba9/platform.h new file mode 100644 index 0000000..b000966 --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/pba9/platform.h @@ -0,0 +1,14 @@ +/* + * Platform offsets for versatile express. + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_PLATFORM_PBA9_H__ +#define __LIBDEV_PLATFORM_PBA9_H__ + +#include + +#define PLATFORM_CLCD0_BASE 0x1001F000 /* CLCD */ + +#endif /* __LIBDEV_PLATFORM_PBA9_H__ */ diff --git a/conts/userlibs/libdev/include/dev/platform/realview/platform.h b/conts/userlibs/libdev/include/dev/platform/realview/platform.h new file mode 100644 index 0000000..4a55e8a --- /dev/null +++ b/conts/userlibs/libdev/include/dev/platform/realview/platform.h @@ -0,0 +1,17 @@ +/* + * Common Platform offsets for realview platforms. + * It includes: + * a. pba9 + * b. eb + * + * Copyright (C) 2010 B Labs Ltd. + * + */ +#ifndef __LIBDEV_PLATFORM_REALVIEW_H__ +#define __LIBDEV_PLATFORM_REALVIEW_H__ + +#define PLATFORM_KEYBOARD0_BASE 0x10006000 /* Keyboard */ +#define PLATFORM_MOUSE0_BASE 0x10007000 /* Mouse */ +#define PLATFORM_TIMER1_BASE 0x10012000 /* Timers 2 and 3 */ + +#endif /* __LIBDEV_PLATFORM_REALVIEW_H__ */ diff --git a/conts/libdev/include/libdev/timer.h b/conts/userlibs/libdev/include/dev/timer.h similarity index 100% rename from conts/libdev/include/libdev/timer.h rename to conts/userlibs/libdev/include/dev/timer.h diff --git a/conts/libdev/include/libdev/uart.h b/conts/userlibs/libdev/include/dev/uart.h similarity index 100% rename from conts/libdev/include/libdev/uart.h rename to conts/userlibs/libdev/include/dev/uart.h diff --git a/conts/libdev/kmi/pl050/SConscript b/conts/userlibs/libdev/kmi/pl050/SConscript similarity index 51% rename from conts/libdev/kmi/pl050/SConscript rename to conts/userlibs/libdev/kmi/pl050/SConscript index 302f224..3129818 100644 --- a/conts/libdev/kmi/pl050/SConscript +++ b/conts/userlibs/libdev/kmi/pl050/SConscript @@ -1,7 +1,17 @@ -Import('env', 'platform') +import sys + +Import('env') + +# Get global paths +PROJRELROOT = '../../../' +sys.path.append(PROJRELROOT) + +from scripts.config.configuration import * +config = configuration_retrieve() +platform = config.platform #Platforms using pl050 -plat_list = ('eb', 'pba8', 'pba9', 'pb11mpcore', 'pb926') +plat_list = ('eb', 'pba9', 'pb926') # The set of source files associated with this SConscript file. src_local = [] diff --git a/conts/libdev/kmi/pl050/keymap.h b/conts/userlibs/libdev/kmi/pl050/keymap.h similarity index 98% rename from conts/libdev/kmi/pl050/keymap.h rename to conts/userlibs/libdev/kmi/pl050/keymap.h index 8ace0ae..679779a 100755 --- a/conts/libdev/kmi/pl050/keymap.h +++ b/conts/userlibs/libdev/kmi/pl050/keymap.h @@ -14,11 +14,17 @@ #define KEYCODE_SCRLK 0x202 #define KEYCODE_NUMLK 0x203 -#define KEYCODE_TAB 0x301 -#define KEYCODE_BACKSP 0x302 #define KEYCODE_RETURN 0x303 #define KEYCODE_ESCAPE 0x304 +#if 0 +#define KEYCODE_TAB 0x301 +#define KEYCODE_BACKSP 0x302 #define KEYCODE_ENTER 0x305 +#else +#define KEYCODE_TAB '\t' +#define KEYCODE_BACKSP '\b' +#define KEYCODE_ENTER '\n' +#endif #define KEYCODE_PRTSCR 0x401 #define KEYCODE_BREAK 0x402 diff --git a/conts/libdev/kmi/pl050/kmi.c b/conts/userlibs/libdev/kmi/pl050/kmi.c similarity index 99% rename from conts/libdev/kmi/pl050/kmi.c rename to conts/userlibs/libdev/kmi/pl050/kmi.c index 545f838..95569bf 100755 --- a/conts/libdev/kmi/pl050/kmi.c +++ b/conts/userlibs/libdev/kmi/pl050/kmi.c @@ -5,7 +5,7 @@ * Copyright (C) 2010 Amit Mahajan */ -#include +#include #include "kmi.h" #include "keymap.h" diff --git a/conts/libdev/kmi/pl050/kmi.h b/conts/userlibs/libdev/kmi/pl050/kmi.h similarity index 100% rename from conts/libdev/kmi/pl050/kmi.h rename to conts/userlibs/libdev/kmi/pl050/kmi.h diff --git a/conts/libdev/timer/omap/SConscript b/conts/userlibs/libdev/timer/omap/SConscript similarity index 59% rename from conts/libdev/timer/omap/SConscript rename to conts/userlibs/libdev/timer/omap/SConscript index 3c107f9..53d3fc0 100644 --- a/conts/libdev/timer/omap/SConscript +++ b/conts/userlibs/libdev/timer/omap/SConscript @@ -1,4 +1,14 @@ -Import('env', 'platform') +import sys + +Import('env') + +# Get global paths +PROJRELROOT = '../../../' +sys.path.append(PROJRELROOT) + +from scripts.config.configuration import * +config = configuration_retrieve() +platform = config.platform #Platforms using omap_uart plat_list = 'beagle' diff --git a/conts/libdev/timer/omap/timer.c b/conts/userlibs/libdev/timer/omap/timer.c similarity index 99% rename from conts/libdev/timer/omap/timer.c rename to conts/userlibs/libdev/timer/omap/timer.c index c051090..011c0cb 100644 --- a/conts/libdev/timer/omap/timer.c +++ b/conts/userlibs/libdev/timer/omap/timer.c @@ -7,7 +7,7 @@ * Author: Bahadir Balban */ -#include +#include #include #include "timer.h" diff --git a/conts/libdev/timer/omap/timer.h b/conts/userlibs/libdev/timer/omap/timer.h similarity index 100% rename from conts/libdev/timer/omap/timer.h rename to conts/userlibs/libdev/timer/omap/timer.h diff --git a/conts/libdev/timer/sp804/SConscript b/conts/userlibs/libdev/timer/sp804/SConscript similarity index 51% rename from conts/libdev/timer/sp804/SConscript rename to conts/userlibs/libdev/timer/sp804/SConscript index 38f5ee9..5621ef5 100644 --- a/conts/libdev/timer/sp804/SConscript +++ b/conts/userlibs/libdev/timer/sp804/SConscript @@ -1,7 +1,17 @@ -Import('env', 'platform') +import sys + +Import('env') + +# Get global paths +PROJRELROOT = '../../../' +sys.path.append(PROJRELROOT) + +from scripts.config.configuration import * +config = configuration_retrieve() +platform = config.platform #Platforms using sp804 -plat_list = ('eb', 'pba8', 'pba9', 'pb11mpcore', 'pb926') +plat_list = ('eb', 'pba9', 'pb926') # The set of source files associated with this SConscript file. src_local = [] diff --git a/conts/libdev/timer/sp804/timer.c b/conts/userlibs/libdev/timer/sp804/timer.c similarity index 100% rename from conts/libdev/timer/sp804/timer.c rename to conts/userlibs/libdev/timer/sp804/timer.c diff --git a/conts/libdev/timer/sp804/timer.h b/conts/userlibs/libdev/timer/sp804/timer.h similarity index 98% rename from conts/libdev/timer/sp804/timer.h rename to conts/userlibs/libdev/timer/sp804/timer.h index 904ca22..9994e71 100644 --- a/conts/libdev/timer/sp804/timer.h +++ b/conts/userlibs/libdev/timer/sp804/timer.h @@ -7,7 +7,7 @@ #ifndef __SP804_TIMER_H__ #define __SP804_TIMER_H__ -#include +#include /* Register offsets */ #define SP804_LOAD 0x0 diff --git a/conts/libdev/uart/omap/SConscript b/conts/userlibs/libdev/uart/omap/SConscript similarity index 59% rename from conts/libdev/uart/omap/SConscript rename to conts/userlibs/libdev/uart/omap/SConscript index 479c63e..ab0c621 100644 --- a/conts/libdev/uart/omap/SConscript +++ b/conts/userlibs/libdev/uart/omap/SConscript @@ -1,4 +1,14 @@ -Import('env', 'platform') +import sys + +Import('env') + +# Get global paths +PROJRELROOT = '../../../' +sys.path.append(PROJRELROOT) + +from scripts.config.configuration import * +config = configuration_retrieve() +platform = config.platform #Platforms using omap_uart plat_list = 'beagle' diff --git a/conts/libdev/uart/omap/uart.c b/conts/userlibs/libdev/uart/omap/uart.c similarity index 98% rename from conts/libdev/uart/omap/uart.c rename to conts/userlibs/libdev/uart/omap/uart.c index b8d86fe..51d3dc7 100644 --- a/conts/libdev/uart/omap/uart.c +++ b/conts/userlibs/libdev/uart/omap/uart.c @@ -4,8 +4,8 @@ * Copyright (C) 2007 Bahadir Balban */ -#include -#include +#include +#include #include "uart.h" #define OMAP_UART_TXFE 0x20 diff --git a/conts/libdev/uart/omap/uart.h b/conts/userlibs/libdev/uart/omap/uart.h similarity index 100% rename from conts/libdev/uart/omap/uart.h rename to conts/userlibs/libdev/uart/omap/uart.h diff --git a/conts/libdev/uart/pl011/SConscript b/conts/userlibs/libdev/uart/pl011/SConscript similarity index 51% rename from conts/libdev/uart/pl011/SConscript rename to conts/userlibs/libdev/uart/pl011/SConscript index ad9de61..7145c4d 100644 --- a/conts/libdev/uart/pl011/SConscript +++ b/conts/userlibs/libdev/uart/pl011/SConscript @@ -1,7 +1,17 @@ -Import('env', 'platform') +import sys + +Import('env') + +# Get global paths +PROJRELROOT = '../../../' +sys.path.append(PROJRELROOT) + +from scripts.config.configuration import * +config = configuration_retrieve() +platform = config.platform #Platforms using pl011 -plat_list = ('eb', 'pba8', 'pba9', 'pb11mpcore', 'pb926') +plat_list = ('eb', 'pba9', 'pb926') # The set of source files associated with this SConscript file. src_local = [] diff --git a/conts/libdev/uart/pl011/uart.c b/conts/userlibs/libdev/uart/pl011/uart.c similarity index 98% rename from conts/libdev/uart/pl011/uart.c rename to conts/userlibs/libdev/uart/pl011/uart.c index 01f6ac9..eac744f 100644 --- a/conts/libdev/uart/pl011/uart.c +++ b/conts/userlibs/libdev/uart/pl011/uart.c @@ -3,8 +3,8 @@ * * Copyright (C) 2009 B Labs Ltd. */ -#include -#include +#include +#include #include "uart.h" /* Error status bits in receive status register */ diff --git a/conts/libdev/uart/pl011/uart.h b/conts/userlibs/libdev/uart/pl011/uart.h similarity index 95% rename from conts/libdev/uart/pl011/uart.h rename to conts/userlibs/libdev/uart/pl011/uart.h index 077be0d..e15aabb 100644 --- a/conts/libdev/uart/pl011/uart.h +++ b/conts/userlibs/libdev/uart/pl011/uart.h @@ -6,10 +6,9 @@ #define __PL011_H__ #include /* To get PLATFORM */ -#include +#include #if defined(VARIANT_USERSPACE) -/* FIXME: Take this value in agreement from kernel, or from kernel only */ #include #include INC_ARCH(io.h) #define PL011_BASE USERSPACE_CONSOLE_VBASE @@ -18,9 +17,7 @@ #if defined(VARIANT_BAREMETAL) #if defined(CONFIG_PLATFORM_PB926) #define PL011_BASE 0x101F1000 -#elif defined(CONFIG_PLATFORM_EB) || defined(CONFIG_PLATFORM_PB11MPCORE) -#define PL011_BASE 0x10009000 -#elif defined(CONFIG_PLATFORM_PBA9) || defined(CONFIG_PLATFORM_PBA8) +#elif defined(CONFIG_PLATFORM_EB) || defined(CONFIG_PLATFORM_PBA9) #define PL011_BASE 0x10009000 #endif #endif diff --git a/conts/libl4/SConscript b/conts/userlibs/libl4/SConscript similarity index 67% rename from conts/libl4/SConscript rename to conts/userlibs/libl4/SConscript index 0adfb6b..f5c9f2c 100644 --- a/conts/libl4/SConscript +++ b/conts/userlibs/libl4/SConscript @@ -19,34 +19,21 @@ import os, sys -PROJRELROOT = '../..' +Import('env') +PROJRELROOT = '../../..' sys.path.append(PROJRELROOT) -from config.projpaths import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.configuration import * -Import('env', 'arch', 'subarch') - -config = configuration_retrieve() - -LIBMEM_RELDIR = 'conts/libmem' -LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) +config = configuration_retrieve() +arch = config.arch +subarch = config.subarch e = env.Clone() -e.Append(CPPPATH = ['include', 'include/l4lib/arch', - LIBMEM_DIR], - CPPFLAGS = ' -include l4lib/macros.h ') - -#Do we need to remove CPPFLAGS coming from top level env? - -# Use os.path.walk(dirname, glob_by_walk, ['*.[cS]', filelist]) -# To collect all files in the tree. - -def glob_by_walk(arg, dirname, names): - ext, imglist = arg - files = glob.glob(join(dirname, ext)) - imglist.extend(files) +e.Append(CPPPATH = ['include', 'include/l4lib/arch', LIBMEM_INCLUDE], + CPPFLAGS = ' -include l4lib/macros.h ') objects = e.StaticObject(Glob('src/*.c') + \ Glob('src/lib/*.c') + \ @@ -57,5 +44,4 @@ objects = e.StaticObject(Glob('src/*.c') + \ Glob('src/arch/' + arch + '/' + subarch + '/*.[cS]') library = e.StaticLibrary('l4', objects) - Return('library') diff --git a/conts/userlibs/libl4/SConstruct b/conts/userlibs/libl4/SConstruct new file mode 100644 index 0000000..f578ae3 --- /dev/null +++ b/conts/userlibs/libl4/SConstruct @@ -0,0 +1,31 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- a microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, sys + +PROJRELROOT = '../../..' +sys.path.append(PROJRELROOT) + +from scripts.config.projpaths import * +from scripts.config.configuration import * + +config = configuration_retrieve() +gcc_arch_flag = config.gcc_arch_flag + +builddir = join(BUILDDIR, LIBL4_RELDIR) +VariantDir(builddir, os.getcwd(), 0) + +env = Environment(CC = config.toolchain_userspace + 'gcc', + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', + '-nostdinc', '-Wall', '-Werror', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib'], + ASFLAGS = ['-D__ASSEMBLY__', '-march=' + gcc_arch_flag], + ENV = {'PATH' : os.environ['PATH']}, + CPPPATH = ['#include', LIBC_INCLUDE, KERNEL_HEADERS, LIBMEM_INCLUDE], + CPPFLAGS = ' -include l4lib/macros.h ') + +objects = SConscript('SConscript', exports = { 'env' : env }, duplicate=0, build_dir = builddir) + diff --git a/conts/libl4/include/l4lib/arch/arm/asm.h b/conts/userlibs/libl4/include/l4lib/arch/arm/asm.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/asm.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/asm.h diff --git a/conts/libl4/include/l4lib/arch/arm/irq.h b/conts/userlibs/libl4/include/l4lib/arch/arm/irq.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/irq.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/irq.h diff --git a/conts/libl4/include/l4lib/arch/arm/syscalls.h b/conts/userlibs/libl4/include/l4lib/arch/arm/syscalls.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/syscalls.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/syscalls.h diff --git a/conts/libl4/include/l4lib/arch/arm/syslib.h b/conts/userlibs/libl4/include/l4lib/arch/arm/syslib.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/syslib.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/syslib.h diff --git a/conts/libl4/include/l4lib/arch/arm/types.h b/conts/userlibs/libl4/include/l4lib/arch/arm/types.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/types.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/types.h diff --git a/conts/libl4/include/l4lib/arch/arm/utcb.h b/conts/userlibs/libl4/include/l4lib/arch/arm/utcb.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/utcb.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/utcb.h diff --git a/conts/libl4/include/l4lib/arch/arm/v5/perfmon.h b/conts/userlibs/libl4/include/l4lib/arch/arm/v5/perfmon.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/v5/perfmon.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/v5/perfmon.h diff --git a/conts/libl4/include/l4lib/arch/arm/v5/utcb.h b/conts/userlibs/libl4/include/l4lib/arch/arm/v5/utcb.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/v5/utcb.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/v5/utcb.h diff --git a/conts/libl4/include/l4lib/arch/arm/v7/perfmon.h b/conts/userlibs/libl4/include/l4lib/arch/arm/v7/perfmon.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/v7/perfmon.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/v7/perfmon.h diff --git a/conts/libl4/include/l4lib/arch/arm/v7/utcb.h b/conts/userlibs/libl4/include/l4lib/arch/arm/v7/utcb.h similarity index 100% rename from conts/libl4/include/l4lib/arch/arm/v7/utcb.h rename to conts/userlibs/libl4/include/l4lib/arch/arm/v7/utcb.h diff --git a/conts/libl4/include/l4lib/cache.h b/conts/userlibs/libl4/include/l4lib/cache.h similarity index 100% rename from conts/libl4/include/l4lib/cache.h rename to conts/userlibs/libl4/include/l4lib/cache.h diff --git a/conts/libl4/include/l4lib/exregs.h b/conts/userlibs/libl4/include/l4lib/exregs.h similarity index 100% rename from conts/libl4/include/l4lib/exregs.h rename to conts/userlibs/libl4/include/l4lib/exregs.h diff --git a/conts/libl4/include/l4lib/init.h b/conts/userlibs/libl4/include/l4lib/init.h similarity index 100% rename from conts/libl4/include/l4lib/init.h rename to conts/userlibs/libl4/include/l4lib/init.h diff --git a/conts/libl4/include/l4lib/ipcdefs.h b/conts/userlibs/libl4/include/l4lib/ipcdefs.h similarity index 100% rename from conts/libl4/include/l4lib/ipcdefs.h rename to conts/userlibs/libl4/include/l4lib/ipcdefs.h diff --git a/conts/libl4/include/l4lib/irq.h b/conts/userlibs/libl4/include/l4lib/irq.h similarity index 100% rename from conts/libl4/include/l4lib/irq.h rename to conts/userlibs/libl4/include/l4lib/irq.h diff --git a/conts/libl4/include/l4lib/kip.h b/conts/userlibs/libl4/include/l4lib/kip.h similarity index 100% rename from conts/libl4/include/l4lib/kip.h rename to conts/userlibs/libl4/include/l4lib/kip.h diff --git a/conts/libl4/include/l4lib/lib/addr.h b/conts/userlibs/libl4/include/l4lib/lib/addr.h similarity index 100% rename from conts/libl4/include/l4lib/lib/addr.h rename to conts/userlibs/libl4/include/l4lib/lib/addr.h diff --git a/conts/libl4/include/l4lib/lib/bit.h b/conts/userlibs/libl4/include/l4lib/lib/bit.h similarity index 100% rename from conts/libl4/include/l4lib/lib/bit.h rename to conts/userlibs/libl4/include/l4lib/lib/bit.h diff --git a/conts/libl4/include/l4lib/lib/cap.h b/conts/userlibs/libl4/include/l4lib/lib/cap.h similarity index 95% rename from conts/libl4/include/l4lib/lib/cap.h rename to conts/userlibs/libl4/include/l4lib/lib/cap.h index d343a0b..a7c6914 100644 --- a/conts/libl4/include/l4lib/lib/cap.h +++ b/conts/userlibs/libl4/include/l4lib/lib/cap.h @@ -70,6 +70,8 @@ static inline void cap_list_move(struct cap_list *to, void __l4_capability_init(void); struct capability *cap_get_by_type(unsigned int cap_type); struct capability *cap_get_physmem(unsigned int cap_type); - +int caps_read_all(void); +struct capability* cap_get_all(); +int cap_get_count(); #endif /* __LIBL4_CAPABILITY_H__ */ diff --git a/conts/libl4/include/l4lib/lib/idpool.h b/conts/userlibs/libl4/include/l4lib/lib/idpool.h similarity index 100% rename from conts/libl4/include/l4lib/lib/idpool.h rename to conts/userlibs/libl4/include/l4lib/lib/idpool.h diff --git a/conts/libl4/include/l4lib/lib/thread.h b/conts/userlibs/libl4/include/l4lib/lib/thread.h similarity index 100% rename from conts/libl4/include/l4lib/lib/thread.h rename to conts/userlibs/libl4/include/l4lib/lib/thread.h diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/cache.h b/conts/userlibs/libl4/include/l4lib/linux/api/cache.h new file mode 100644 index 0000000..90148cb --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/cache.h @@ -0,0 +1,17 @@ +/* + * Generic macros for cache operations + * + * Copyright (C) 2009 B Labs Ltd. + */ +#ifndef __CACHE_CONTROL_H__ +#define __CACHE_CONTROL_H__ + +#include L4LIB_INC_GLUE(cache.h) + +#define L4_INVALIDATE_ICACHE ARCH_INVALIDATE_ICACHE +#define L4_INVALIDATE_DCACHE ARCH_INVALIDATE_DCACHE +#define L4_CLEAN_DCACHE ARCH_CLEAN_DCACHE +#define L4_CLEAN_INVALIDATE_DCACHE ARCH_CLEAN_INVALIDATE_DCACHE +#define L4_INVALIDATE_TLB ARCH_INVALIDATE_TLB + +#endif /* __CACHE_CONTROL_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/capability.h b/conts/userlibs/libl4/include/l4lib/linux/api/capability.h new file mode 100644 index 0000000..babb62f --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/capability.h @@ -0,0 +1,96 @@ +/* + * Syscall API for capability manipulation + * + * Copyright (C) 2009 Bahadir Balban + */ +#ifndef __API_CAPABILITY_H__ +#define __API_CAPABILITY_H__ + +#include +#include L4LIB_INC_ARCH(types.h) + +/* Capability syscall request types */ +#define CAP_CONTROL_NCAPS 0x00000000 +#define CAP_CONTROL_READ 0x00000001 +#define CAP_CONTROL_SHARE 0x00000002 +#define CAP_CONTROL_GRANT 0x00000003 +#define CAP_CONTROL_REPLICATE 0x00000004 +#define CAP_CONTROL_SPLIT 0x00000005 +#define CAP_CONTROL_DEDUCE 0x00000006 +#define CAP_CONTROL_DESTROY 0x00000007 + +#define CAP_SHARE_MASK 0x0000000F +#define CAP_SHARE_SINGLE 0x00000001 +#define CAP_SHARE_ALL_CONTAINER 0x00000002 +#define CAP_SHARE_ALL_SPACE 0x00000003 + +#define CAP_GRANT_MASK 0x0000000F +#define CAP_GRANT_SINGLE 0x00000001 +#define CAP_GRANT_IMMUTABLE 0x00000004 + +#define CAP_SPLIT_MASK 0x0000000F +#define CAP_SPLIT_SIZE 0x00000001 +#define CAP_SPLIT_ACCESS 0x00000002 +#define CAP_SPLIT_RANGE 0x00000003 /* Returns -EPERM */ + +/* + * A capability is a unique representation of security + * qualifiers on a particular resource. + * + * In this structure: + * + * The capid denotes the unique capability ID. + * The resid denotes the unique ID of targeted resource. + * The owner denotes the unique ID of the one and only capability owner. This is + * almost always a thread ID. + * + * The type field contains two types: + * - The capability type, + * - The targeted resource type. + * + * The targeted resouce type denotes what type of resource the capability is + * allowed to operate on. For example a thread, a thread group, an address space + * or a memory can be of this type. + * + * The capability type defines the general set of operations allowed on a + * particular resource. For example a capability type may be thread_control, + * exchange_registers, ipc, or map operations. A resource type may be such as a + * thread, a thread group, a virtual or physical memory region. + * + * There are also quantitative capability types. While their names denote + * quantitative objects such as memory, threads, and address spaces, these + * types actually define the quantitative operations available on those + * resources such as creation and deletion of a thread, allocation and + * deallocation of a memory region etc. + * + * The access field denotes the fine-grain operations available on a particular + * resource. The meaning of each bitfield differs according to the type of the + * capability. For example, for a capability type thread_control, the bitfields + * may mean suspend, resume, create, delete etc. + */ +struct capability { + struct link list; + + /* Capability identifiers */ + l4id_t capid; /* Unique capability ID */ + l4id_t owner; /* Capability owner ID */ + l4id_t resid; /* Targeted resource ID */ + unsigned int type; /* Capability and target resource type */ + + /* Capability limits/permissions */ + u32 access; /* Permitted operations */ + + /* Limits on the resource (NOTE: must never have signed type) */ + unsigned long start; /* Resource start value */ + unsigned long end; /* Resource end value */ + unsigned long size; /* Resource size */ + + /* Use count of resource */ + unsigned long used; + + /* Device attributes, if this is a device. */ + unsigned int attr; + l4id_t irq; +}; + +#endif /* __API_CAPABILITY_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/errno.h b/conts/userlibs/libl4/include/l4lib/linux/api/errno.h new file mode 100644 index 0000000..ccc4712 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/errno.h @@ -0,0 +1,148 @@ +#ifndef __ERRNO_H__ +#define __ERRNO_H__ + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation Canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ + +/* Codezero specific error codes */ +#define EACTIVE 132 /* Task active */ +#define ENOIPC 133 /* General IPC error */ +#define ENOCAP 134 /* None or insufficient capability */ +#define ENOUTCB 135 /* Task has no utcb set up */ +#define ENOMAP 136 /* The memory area has unmapped regions */ +#define ENOIRQ 137 /* Irq cannot be registered */ +#define EABORT 138 /* Abort cannot be handled */ +#define ENOCHILD 139 /* Task is not paged by caller */ + +#endif /* __ERRNO_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/exregs.h b/conts/userlibs/libl4/include/l4lib/linux/api/exregs.h new file mode 100644 index 0000000..8fb9c8a --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/exregs.h @@ -0,0 +1,50 @@ +/* + * Exchange registers system call data. + * + * Copyright (C) 2008 Bahadir Balban + */ +#ifndef __EXREGS_H__ +#define __EXREGS_H__ + +#include L4LIB_INC_GLUE(syscall.h) +#include L4LIB_INC_GLUE(context.h) +#include + +#define EXREGS_SET_PAGER 1 +#define EXREGS_SET_UTCB 2 +#define EXREGS_READ 4 + +#define EXREGS_VALID_REGULAR_REGS \ + (FIELD_TO_BIT(exregs_context_t, r0) | \ + FIELD_TO_BIT(exregs_context_t, r1) | \ + FIELD_TO_BIT(exregs_context_t, r2) | \ + FIELD_TO_BIT(exregs_context_t, r3) | \ + FIELD_TO_BIT(exregs_context_t, r4) | \ + FIELD_TO_BIT(exregs_context_t, r5) | \ + FIELD_TO_BIT(exregs_context_t, r6) | \ + FIELD_TO_BIT(exregs_context_t, r7) | \ + FIELD_TO_BIT(exregs_context_t, r8) | \ + FIELD_TO_BIT(exregs_context_t, r9) | \ + FIELD_TO_BIT(exregs_context_t, r10) | \ + FIELD_TO_BIT(exregs_context_t, r11) | \ + FIELD_TO_BIT(exregs_context_t, r12) | \ + FIELD_TO_BIT(exregs_context_t, lr)) \ + +#define EXREGS_VALID_SP \ + FIELD_TO_BIT(exregs_context_t, sp) \ + +#define EXREGS_VALID_PC \ + FIELD_TO_BIT(exregs_context_t, pc) \ + +/* Structure passed by userspace pagers for exchanging registers */ +struct exregs_data { + exregs_context_t context; + u32 valid_vect; + u32 flags; + l4id_t pagerid; + unsigned long utcb_address; +}; + + + +#endif /* __EXREGS_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/ipc.h b/conts/userlibs/libl4/include/l4lib/linux/api/ipc.h new file mode 100644 index 0000000..8ec4a89 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/ipc.h @@ -0,0 +1,27 @@ +#ifndef __IPC_H__ +#define __IPC_H__ + +#define L4_NILTHREAD 0xFFFFFFFF +#define L4_ANYTHREAD 0xFFFFFFFE + +#define L4_IPC_TAG_MR_OFFSET 0 + +/* Pagefault */ +#define L4_IPC_TAG_PFAULT 0 +#define L4_IPC_TAG_UNDEF_FAULT 1 + +#define L4_IPC_FLAGS_TYPE_MASK 0x0000000F +#define L4_IPC_FLAGS_SHORT 0x00000000 /* Short IPC involves just primary message registers */ +#define L4_IPC_FLAGS_FULL 0x00000001 /* Full IPC involves full UTCB copy */ +#define L4_IPC_FLAGS_EXTENDED 0x00000002 /* Extended IPC can page-fault and copy up to 2KB */ + +/* Extended IPC extra fields */ +#define L4_IPC_FLAGS_MSG_INDEX_MASK 0x00000FF0 /* Index of message register with buffer pointer */ +#define L4_IPC_FLAGS_SIZE_MASK 0x0FFF0000 +#define L4_IPC_FLAGS_SIZE_SHIFT 16 +#define L4_IPC_FLAGS_MSG_INDEX_SHIFT 4 + + +#define L4_IPC_EXTENDED_MAX_SIZE (SZ_1K*2) + +#endif /* __IPC_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/irq.h b/conts/userlibs/libl4/include/l4lib/linux/api/irq.h new file mode 100644 index 0000000..f94a0ba --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/irq.h @@ -0,0 +1,10 @@ +#ifndef __API_IRQ_H__ +#define __API_IRQ_H__ + + +#define IRQ_CONTROL_REGISTER 0 +#define IRQ_CONTROL_RELEASE 1 +#define IRQ_CONTROL_WAIT 2 + + +#endif /* __API_IRQ_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/kip.h b/conts/userlibs/libl4/include/l4lib/linux/api/kip.h new file mode 100644 index 0000000..d18e846 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/kip.h @@ -0,0 +1,82 @@ +/* + * Kernel Interface Page + * + * Copyright (C) 2007 Bahadir Balban + */ + +#ifndef __KIP_H__ +#define __KIP_H__ +#include + +#define __YEAR__ ((((__DATE__ [7] - '0') * 10 + (__DATE__ [8] - '0')) * 10 \ + + (__DATE__ [9] - '0')) * 10 + (__DATE__ [10] - '0')) + +#define __MONTH__ (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 0 : 5) \ + : __DATE__ [2] == 'b' ? 1 \ + : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 2 : 3) \ + : __DATE__ [2] == 'y' ? 4 \ + : __DATE__ [2] == 'l' ? 6 \ + : __DATE__ [2] == 'g' ? 7 \ + : __DATE__ [2] == 'p' ? 8 \ + : __DATE__ [2] == 't' ? 9 \ + : __DATE__ [2] == 'v' ? 10 : 11) + +#define __DAY__ ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10 \ + + (__DATE__ [5] - '0')) + + +#define CODEZERO_VERSION 0 +#define CODEZERO_SUBVERSION 2 +#define KDESC_DATE_SIZE 12 +#define KDESC_TIME_SIZE 9 + +struct kernel_descriptor { + u32 version; + u32 subversion; + u32 magic; + char date[KDESC_DATE_SIZE]; + char time[KDESC_TIME_SIZE]; +} __attribute__((__packed__)); + +/* Experimental KIP with non-standard offsets */ +struct kip { + /* System descriptions */ + u32 magic; + u16 version_rsrv; + u8 api_subversion; + u8 api_version; + u32 api_flags; + + u32 container_control; + u32 time; + + u32 irq_control; + u32 thread_control; + u32 ipc_control; + u32 map; + u32 ipc; + u32 capability_control; + u32 unmap; + u32 exchange_registers; + u32 thread_switch; + u32 schedule; + u32 getid; + u32 mutex_control; + u32 cache_control; + + u32 arch_syscall0; + u32 arch_syscall1; + u32 arch_syscall2; + + u32 utcb; + + struct kernel_descriptor kdesc; +} __attribute__((__packed__)); + + +#if defined (__KERNEL__) +extern struct kip kip; +#endif /* __KERNEL__ */ + + +#endif /* __KIP_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/mutex.h b/conts/userlibs/libl4/include/l4lib/linux/api/mutex.h new file mode 100644 index 0000000..3248339 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/mutex.h @@ -0,0 +1,60 @@ +#ifndef __MUTEX_CONTROL_H__ +#define __MUTEX_CONTROL_H__ + +#if !defined(__LINUX_CONTAINER__) + +/* Request ids for mutex_control syscall */ + +#if defined (__KERNEL__) +#define MUTEX_CONTROL_LOCK L4_MUTEX_LOCK +#define MUTEX_CONTROL_UNLOCK L4_MUTEX_UNLOCK + +#define MUTEX_CONTROL_OPMASK L4_MUTEX_OPMASK + +#define mutex_operation(x) ((x) & MUTEX_CONTROL_OPMASK) +#define mutex_contenders(x) ((x) & ~MUTEX_CONTROL_OPMASK) + +#include +#include +#include + +/* + * Contender threashold is the total number of contenders + * who are expected to sleep on the mutex, and will be waited + * for a wakeup. + */ +struct mutex_queue { + int contenders; + unsigned long physical; + struct link list; + struct waitqueue_head wqh_contenders; + struct waitqueue_head wqh_holders; +}; + +/* + * Mutex queue head keeps the list of all userspace mutexes. + * + * Here, mutex_control_mutex is a single lock for: + * (1) Mutex_queue create/deletion + * (2) List add/removal. + * (3) Wait synchronization: + * - Both waitqueue spinlocks need to be acquired for + * rendezvous inspection to occur atomically. Currently + * it's not done since we rely on this mutex for that. + */ +struct mutex_queue_head { + struct link list; + struct mutex mutex_control_mutex; + int count; +}; + +void init_mutex_queue_head(struct mutex_queue_head *mqhead); + +#endif + +#define L4_MUTEX_OPMASK 0xF0000000 +#define L4_MUTEX_LOCK 0x10000000 +#define L4_MUTEX_UNLOCK 0x20000000 + +#endif /* __LINUX_CONTAINER__ */ +#endif /* __MUTEX_CONTROL_H__*/ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/space.h b/conts/userlibs/libl4/include/l4lib/linux/api/space.h new file mode 100644 index 0000000..2bdacf4 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/space.h @@ -0,0 +1,5 @@ +#ifndef __API_SPACE_H__ +#define __API_SPACE_H__ + + +#endif /* __API_SPACE_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/api/thread.h b/conts/userlibs/libl4/include/l4lib/linux/api/thread.h new file mode 100644 index 0000000..e800b2d --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/api/thread.h @@ -0,0 +1,25 @@ +#ifndef __API_THREAD_H__ +#define __API_THREAD_H__ + +#define THREAD_ACTION_MASK 0xF0000000 +#define THREAD_CREATE 0x00000000 +#define THREAD_RUN 0x10000000 +#define THREAD_SUSPEND 0x20000000 +#define THREAD_DESTROY 0x30000000 +#define THREAD_RECYCLE 0x40000000 +#define THREAD_WAIT 0x50000000 + +#define THREAD_SHARE_MASK 0x00F00000 +#define THREAD_SPACE_MASK 0x0F000000 +#define THREAD_CREATE_MASK (THREAD_SHARE_MASK | THREAD_SPACE_MASK) +#define TC_SHARE_CAPS 0x00100000 /* Share all thread capabilities */ +#define TC_SHARE_UTCB 0x00200000 /* Share utcb location (same space */ +#define TC_SHARE_GROUP 0x00400000 /* Share thread group id */ + +#define TC_SHARE_SPACE 0x01000000 /* New thread, use given space */ +#define TC_COPY_SPACE 0x02000000 /* New thread, copy given space */ +#define TC_NEW_SPACE 0x04000000 /* New thread, new space */ + +/* #define THREAD_USER_MASK 0x000F0000 Reserved for userspace */ +#define THREAD_EXIT_MASK 0x0000FFFF /* Thread exit code */ +#endif /* __API_THREAD_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/arch/arm/exception.h b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/exception.h new file mode 100644 index 0000000..df428b7 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/exception.h @@ -0,0 +1,73 @@ +/* + * Common definitions for exceptions + * across ARM sub-architectures. + * + * Copyright (C) 2010 B Labs Ltd. + */ + +#ifndef __EXCEPTION_H__ +#define __EXCEPTION_H__ + +//#include _INC_SUBARCH(exception.h) +#include L4LIB_INC_ARCH(asm.h) + +/* Abort debugging conditions */ +// #define DEBUG_ABORTS +#if defined (DEBUG_ABORTS) +#define dbg_abort(...) printk(__VA_ARGS__) +#else +#define dbg_abort(...) +#endif + +/* Codezero-specific abort type */ +#define ABORT_TYPE_PREFETCH 1 +#define ABORT_TYPE_DATA 0 + +/* If abort is handled and resolved in check_aborts */ +#define ABORT_HANDLED 1 + +/* Codezero makes use of bit 8 (Always Zero) of FSR to define which type of abort */ +#define set_abort_type(fsr, x) { fsr &= ~(1 << 8); fsr |= ((x & 1) << 8); } +#define is_prefetch_abort(fsr) ((fsr >> 8) & 0x1) +#define is_data_abort(fsr) (!is_prefetch_abort(fsr)) + +/* Kernel's data about the fault */ +typedef struct fault_kdata { + u32 faulty_pc; /* In DABT: Aborting PC, In PABT: Same as FAR */ + u32 fsr; /* In DABT: DFSR, In PABT: IFSR */ + u32 far; /* In DABT: DFAR, in PABT: IFAR */ + pte_t pte; /* Faulty page table entry */ +} __attribute__ ((__packed__)) fault_kdata_t; + + +/* This is filled on entry to irq handler, only if a process was interrupted.*/ +extern unsigned int preempted_psr; + +/* Implementing these as functions cause circular include dependency for tcb.h */ +#define TASK_IN_KERNEL(tcb) (((tcb)->context.spsr & ARM_MODE_MASK) == ARM_MODE_SVC) +#define TASK_IN_USER(tcb) (!TASK_IN_KERNEL(tcb)) + +static inline int is_user_mode(u32 spsr) +{ + return ((spsr & ARM_MODE_MASK) == ARM_MODE_USR); +} + +static inline int in_kernel() +{ + return (((preempted_psr & ARM_MODE_MASK) == ARM_MODE_SVC)) ? 1 : 0; +} + +static inline int in_user() +{ + return !in_kernel(); +} + +int pager_pagein_request(unsigned long vaddr, unsigned long size, + unsigned int flags); + +int fault_ipc_to_pager(u32 faulty_pc, u32 fsr, u32 far, u32 ipc_tag); + +int is_kernel_abort(u32 faulted_pc, u32 fsr, u32 far, u32 spsr); +int check_abort_type(u32 faulted_pc, u32 fsr, u32 far, u32 spsr); + +#endif /* __EXCEPTION_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/arch/arm/io.h b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/io.h new file mode 100644 index 0000000..07bc70c --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/io.h @@ -0,0 +1,25 @@ +#ifndef __ARM_IO_H__ +#define __ARM_IO_H__ +/* + * Arch-specific io functions/macros. + * + * Copyright (C) 2007 Bahadir Balban + */ + +#if defined (__KERNEL__) && !defined (__LINUX_CONTAINER__) + +#include INC_GLUE(memlayout.h) + +#define read(address) *((volatile unsigned int *) (address)) +#define write(val, address) *((volatile unsigned int *) (address)) = val + +#endif /* ends __KERNEL__ */ + +/* + * Generic uart virtual address until a file-based console access + * is available for userspace + */ +#define USERSPACE_CONSOLE_VBASE 0xF9800000 + + +#endif /* __ARM_IO_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/arch/arm/irq.h b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/irq.h new file mode 100644 index 0000000..db38692 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/irq.h @@ -0,0 +1,29 @@ +#ifndef __ARM_IRQ_H__ +#define __ARM_IRQ_H__ + +#include INC_SUBARCH(irq.h) + +void irq_local_restore(unsigned long state); +void irq_local_disable_save(unsigned long *state); +int irqs_enabled(); + +static inline void irq_local_enable() +{ + enable_irqs(); +} + +static inline void irq_local_disable() +{ + disable_irqs(); +} + + +/* + * Destructive atomic-read. + * + * Write 0 to byte at @location as its contents are read back. + */ +char l4_atomic_dest_readb(void *location); + + +#endif /* __ARM_IRQ_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/arch/arm/mutex.h b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/mutex.h new file mode 100644 index 0000000..37cdbe6 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/mutex.h @@ -0,0 +1,16 @@ +/* + * ARM specific low-level mutex interfaces + * + * Copyright (C) 2007 Bahadir Balban + */ + +#ifndef __ARCH_MUTEX_H__ +#define __ARCH_MUTEX_H__ + +/* TODO: The return types could be improved for debug checking */ +void __spin_lock(unsigned int *s); +void __spin_unlock(unsigned int *s); +unsigned int __mutex_lock(unsigned int *m); +void __mutex_unlock(unsigned int *m); + +#endif /* __ARCH_MUTEX_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v5/mm.h b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v5/mm.h new file mode 100644 index 0000000..9066267 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v5/mm.h @@ -0,0 +1,137 @@ +/* + * ARM v5-specific virtual memory details + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __V5_MM_H__ +#define __V5_MM_H__ + +/* ARM specific definitions */ +#define VIRT_MEM_START 0 +#define VIRT_MEM_END 0xFFFFFFFF +#if !defined(__LINUX_CONTAINER__) +#define SECTION_SIZE SZ_1MB +#define SECTION_MASK (SECTION_SIZE - 1) +#endif +#define SECTION_ALIGN_MASK (~SECTION_MASK) +#define SECTION_BITS 20 +#define ARM_PAGE_SIZE SZ_4K +#define ARM_PAGE_MASK 0xFFF +#define ARM_PAGE_BITS 12 + +#define PGD_SIZE SZ_4K * 4 +#define PGD_ENTRY_TOTAL SZ_4K + +#if !defined(__LINUX_CONTAINER__) +#define PMD_SIZE SZ_1K +#define PMD_TYPE_MASK 0x3 +#define PMD_TYPE_FAULT 0 + +#define PTE_TYPE_MASK 0x3 +#define PTE_TYPE_FAULT 0 +#define PTE_TYPE_LARGE 1 +#define PTE_TYPE_SMALL 2 +#endif + +#define PMD_ENTRY_TOTAL 256 +#define PMD_MAP_SIZE SZ_1MB +#define PMD_ALIGN_MASK (~(PMD_SIZE - 1)) +#define PMD_TYPE_PMD 1 +#define PMD_TYPE_SECTION 2 + +#define PTE_TYPE_TINY 3 + +/* Permission field offsets */ +#define SECTION_AP0 10 + +/* + * These are indices into arrays with pgd_t or pmd_t sized elements, + * therefore the index must be divided by appropriate element size + */ +#define PGD_INDEX(x) (((((unsigned long)(x)) >> 18) \ + & 0x3FFC) / sizeof(pmd_t)) + +/* + * Strip out the page offset in this + * megabyte from a total of 256 pages. + */ +#define PMD_INDEX(x) (((((unsigned long)(x)) >> 10) \ + & 0x3FC) / sizeof (pte_t)) + + +/* We need this as print-early.S is including this file */ +#ifndef __ASSEMBLY__ + +#if !defined(__LINUX_CONTAINER__) +/* Type-checkable page table elements */ +typedef u32 pmd_t; +typedef u32 pte_t; + +/* Page global directory made up of pgd_t entries */ +typedef struct pgd_table { + pmd_t entry[PGD_ENTRY_TOTAL]; +} pgd_table_t; + +/* Page middle directory made up of pmd_t entries */ +typedef struct pmd_table { + pte_t entry[PMD_ENTRY_TOTAL]; +} pmd_table_t; + +extern pgd_table_t init_pgd; + +#endif + +/* Applies for both small and large pages */ +#define PAGE_AP0 4 +#define PAGE_AP1 6 +#define PAGE_AP2 8 +#define PAGE_AP3 10 + +/* Permission values with rom and sys bits ignored */ +#define SVC_RW_USR_NONE 1 +#define SVC_RW_USR_RO 2 +#define SVC_RW_USR_RW 3 + +#define PTE_PROT_MASK (0xFF << 4) + +#define CACHEABILITY 3 +#define BUFFERABILITY 2 +#define cacheable (1 << CACHEABILITY) +#define bufferable (1 << BUFFERABILITY) +#define uncacheable 0 +#define unbufferable 0 + +/* Helper macros for common cases */ +#define __MAP_USR_RW (cacheable | bufferable | (SVC_RW_USR_RW << PAGE_AP0) \ + | (SVC_RW_USR_RW << PAGE_AP1) | (SVC_RW_USR_RW << PAGE_AP2) \ + | (SVC_RW_USR_RW << PAGE_AP3)) +#define __MAP_USR_RO (cacheable | bufferable | (SVC_RW_USR_RO << PAGE_AP0) \ + | (SVC_RW_USR_RO << PAGE_AP1) | (SVC_RW_USR_RO << PAGE_AP2) \ + | (SVC_RW_USR_RO << PAGE_AP3)) +#define __MAP_KERN_RW (cacheable | bufferable | (SVC_RW_USR_NONE << PAGE_AP0) \ + | (SVC_RW_USR_NONE << PAGE_AP1) | (SVC_RW_USR_NONE << PAGE_AP2) \ + | (SVC_RW_USR_NONE << PAGE_AP3)) +#define __MAP_KERN_IO (uncacheable | unbufferable | (SVC_RW_USR_NONE << PAGE_AP0) \ + | (SVC_RW_USR_NONE << PAGE_AP1) | (SVC_RW_USR_NONE << PAGE_AP2) \ + | (SVC_RW_USR_NONE << PAGE_AP3)) +#define __MAP_USR_IO (uncacheable | unbufferable | (SVC_RW_USR_RW << PAGE_AP0) \ + | (SVC_RW_USR_RW << PAGE_AP1) | (SVC_RW_USR_RW << PAGE_AP2) \ + | (SVC_RW_USR_RW << PAGE_AP3)) + +/* There is no execute bit in ARMv5, so we ignore it */ +#define __MAP_USR_RWX __MAP_USR_RW +#define __MAP_USR_RX __MAP_USR_RO +#define __MAP_KERN_RWX __MAP_KERN_RW +#define __MAP_KERN_RX __MAP_KERN_RW /* We always have kernel RW */ +#define __MAP_FAULT 0 + +void add_section_mapping_init(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags); + +void remove_section_mapping(unsigned long vaddr); + +void arch_update_utcb(unsigned long utcb_address); +void system_identify(void); + +#endif /* __ASSEMBLY__ */ +#endif /* __V5_MM_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v7/exception.h b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v7/exception.h new file mode 100644 index 0000000..2c912ba --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v7/exception.h @@ -0,0 +1,42 @@ +/* + * ARMv7 specific abort handling definitions + * + * Copyright (C) 2010 B Labs Ltd. + */ +#ifndef __V7_ARCH_EXCEPTION_H__ +#define __V7_ARCH_EXCEPTION_H__ + +/* Data and Prefetch abort encodings */ +#define ABORT_TTBW_SYNC_EXTERNAL_LEVEL1 0x0C +#define ABORT_TTBW_SYNC_EXTERNAL_LEVEL2 0x0E +#define ABORT_TTBW_SYNC_PARITY_LEVEL1 0x1C +#define ABORT_TTBW_SYNC_PARITY_LEVEL2 0x1E +#define ABORT_TRANSLATION_SECTION 0x05 +#define ABORT_TRANSLATION_PAGE 0x07 +#define ABORT_AFLAG_SECTION 0x03 +#define ABORT_AFLAG_PAGE 0x06 +#define ABORT_DOMAIN_SECTION 0x09 +#define ABORT_DOMAIN_PAGE 0x0B +#define ABORT_PERMISSION_SECTION 0x0D +#define ABORT_PERMISSION_PAGE 0x0F +#define ABORT_DEBUG_EVENT 0x02 +#define ABORT_SYNC_EXTERNAL 0x08 +#define ABORT_SYNC_PARITY 0x19 +#define ABORT_ASYNC_PARITY 0x18 /* Only on Data aborts */ +#define ABORT_ASYNC_EXTERNAL 0x16 /* Only on Data aborts */ +#define ABORT_ICACHE_MAINTENANCE 0x04 /* Only in Data aborts */ +#define ABORT_ALIGNMENT 0x01 /* Only in Data aborts */ + +/* IFSR/DFSR register bits */ +#define FSR_FS_BIT4 10 /* 4th bit of fault status */ +#define DFSR_WNR_BIT 11 /* Write-not-read bit */ +#define FSR_EXT_BIT 12 /* External abort type bit */ +#define FSR_FS_MASK 0xF + +static inline u32 fsr_get_status(u32 fsr) +{ + return (fsr & FSR_FS_MASK) | + (((fsr >> FSR_FS_BIT4) & 1) << 4); +} + +#endif /* __V7_ARCH_EXCEPTION_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v7/mm.h b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v7/mm.h new file mode 100644 index 0000000..9e7e207 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/arch/arm/v7/mm.h @@ -0,0 +1,315 @@ +/* + * v7 memory management definitions + * + * Copyright (C) 2010 B Labs Ltd. + * Written by Bahadir Balban + */ + +#ifndef __V7_MM_H__ +#define __V7_MM_H__ + +/* Generic definitions used across the kernel */ +#define VIRT_MEM_START 0 +#define VIRT_MEM_END 0xFFFFFFFF + +/* Non-global first level descriptor definitions */ +#define TASK_PGD_SIZE_MAP4GB SZ_16K +#define TASK_PGD_SIZE_MAP2GB SZ_8K +#define TASK_PGD_SIZE_MAP1GB SZ_4K +#define TASK_PGD_SIZE_MAP512MB (SZ_1K * 2) +#define TASK_PGD_SIZE_MAP256MB SZ_1K +#define TASK_PGD_SIZE_MAP128MB 512 +#define TASK_PGD_SIZE_MAP64MB 256 +#define TASK_PGD_SIZE_MAP32MB 128 + +/* Any virtual mapping above this value goes to the global table */ +#define PGD_GLOBAL_BOUNDARY 0x80000000 + +/* Task-specific page table, userspace private + shared memory mappings */ +#define PGD_ENTRY_TOTAL (TASK_PGD_SIZE_MAP2GB >> 2) +#define PGD_SIZE (TASK_PGD_SIZE_MAP2GB) + +/* Global page table size UTCB + kernel + device mappings */ +#define PGD_GLOBAL_SIZE SZ_16K +#define PGD_GLOBAL_ENTRY_TOTAL (PGD_GLOBAL_SIZE >> 2) + +#if !defined(__LINUX_CONTAINER__) +#define PMD_SIZE SZ_1K +#endif +#define PMD_ENTRY_TOTAL 256 +#define PMD_MAP_SIZE SZ_1MB + +/* FIXME: Check these shifts/masks are correct */ +#define PGD_INDEX_MASK 0x3FFC +#define PGD_INDEX_SHIFT 18 + +#define PMD_INDEX_MASK 0x3FC +#define PMD_INDEX_SHIFT 10 + +/* + * These are indices into arrays with pmd_t or pte_t sized elements, + * therefore the index must be divided by appropriate element size + */ +#define PGD_INDEX(x) (((((unsigned long)(x)) >> PGD_INDEX_SHIFT) \ + & PGD_INDEX_MASK) / sizeof(pmd_t)) + +/* Strip out the page offset in this megabyte from a total of 256 pages. */ +#define PMD_INDEX(x) (((((unsigned long)(x)) >> PMD_INDEX_SHIFT) \ + & PMD_INDEX_MASK) / sizeof (pte_t)) + +#if !defined (__ASSEMBLY__) && !defined (__LINUX_CONTAINER__) +/* Type-checkable page table elements */ +typedef u32 pmd_t; +typedef u32 pte_t; + +/* Page global directory made up of pmd_t entries */ +typedef struct page_table_directory { + pmd_t entry[PGD_GLOBAL_ENTRY_TOTAL]; +} pgd_global_table_t; + +/* Page non-global directory */ +typedef struct task_page_table_directory { + pmd_t entry[PGD_ENTRY_TOTAL]; +} pgd_table_t; + +/* Page middle directory made up of pte_t entries */ +typedef struct pmd_table { + pte_t entry[PMD_ENTRY_TOTAL]; +} pmd_table_t; + +extern pgd_table_t init_pgd; +extern pgd_global_table_t init_global_pgd; + +#endif /* !defined(__ASSEMBLY__) */ + +/* PMD definitions (2nd level page tables) */ +#define PMD_ALIGN_MASK (~(PMD_SIZE - 1)) +#define PMD_TYPE_FAULT 0x0 +#define PMD_TYPE_PMD 0x1 +#define PMD_TYPE_SECTION 0x2 +#define PMD_TYPE_MASK 0x3 +#define PMD_DOMAIN_SHIFT 5 /* Domain field on PGD entry */ +#define PMD_DOMAIN_MASK 0x000001E0 /* Domain mask on PGD entry */ +#define PMD_NS_BIT 3 /* Non-secure memory */ + +/* First level Section definitions */ +#define SECT_MAP_SIZE SZ_1MB /* Section base address alignment */ +#define SECT_NS_BIT 19 +#define SECT_SUPER_BIT 18 +#define SECT_NG_BIT 17 +#define SECT_SHAREABLE_BIT 16 +#define SECT_AP2_BIT 15 +#define SECT_TEX2_BIT 14 +#define SECT_TEX1_BIT 13 +#define SECT_TEX0_BIT 12 +#define SECT_AP1_BIT 11 +#define SECT_AP0_BIT 10 +#define SECT_DOMAIN_SHIFT 5 +#define SECT_XN_BIT 4 +#define SECT_CACHE_BIT 3 +#define SECT_BUFFER_BIT 2 + +#if !defined (__LINUX_CONTAINER__) +/* Second level entry (PTE) definitions */ +#define PTE_TYPE_MASK 0x2 +#define PTE_TYPE_FAULT 0 +#define PTE_TYPE_LARGE 1 +#define PTE_TYPE_SMALL 2 +#endif + +#define PTE_XN_BIT 0 +#define PTE_BUFFER_BIT 2 +#define PTE_CACHE_BIT 3 +#define PTE_AP0_BIT 4 +#define PTE_AP1_BIT 5 +#define PTE_TEX0_BIT 6 +#define PTE_TEX1_BIT 7 +#define PTE_TEX2_BIT 8 +#define PTE_AP2_BIT 9 +#define PTE_AP01_SHIFT PTE_AP0_BIT +#define PTE_AP01_MASK 0x30 + +#define PTE_SHARE_BIT 10 +#define PTE_NG_BIT 11 + +/* Domain access types */ +#define DOMAIN_ACCESS_NONE 0 +#define DOMAIN_ACCESS_CLIENT 1 +#define DOMAIN_ACCESS_MANAGER 3 + +/* Simplified permission model definitions */ +#define PTE_ACCESS_FLAG PTE_AP0_BIT + +/* Bits [1:0] map as AP[2], AP[1] */ +#define AP_SIMPLE_USER_NONE_KERN_RW 0 +#define AP_SIMPLE_USER_RW_KERN_RW 1 +#define AP_SIMPLE_USER_NONE_KERN_RO 2 +#define AP_SIMPLE_USER_RO_KERN_RO 3 + +/* + * Generic page table flag meanings for v7: + * + * Note these are not hardware-defined bits, + * they are defined by the kernel for + * convenience. + * + * [WXCDU] + * W = write, X = Exec, C = Cached, D = Device + * + * If !D it means Normal memory. + * If !U it means kernel-only. + * If !W it means read-only. + * + * These are actually meaningful but unused + * individually, rather the combination of them + * are directly converted into HW pte. + */ +#define PTE_MAP_USER (1 << 0) +#define PTE_MAP_DEVICE (1 << 1) +#define PTE_MAP_CACHED (1 << 2) +#define PTE_MAP_EXEC (1 << 3) +#define PTE_MAP_WRITE (1 << 4) + +/* 0 would mean normal, uncached, kernel mapping */ +#define PTE_MAP_FAULT (1 << 5) + +/* + * v7-specific conversion of map flags + */ + +/* In ARMv7 normal, wbwa, shareable, user-rw/kern-rw, xn=1 */ +#define __MAP_USR_RW (PTE_MAP_USER | PTE_MAP_WRITE | PTE_MAP_CACHED) + +/* Writeback cached. In ARMv7 normal, wbwa, shareable, user-ro/kern-ro, xn=1 */ +#define __MAP_USR_RO (PTE_MAP_USER | PTE_MAP_CACHED) + +/* Writeback cached. In ARMv7 normal, wbwa, shareable, user-none/kern-rw, xn=1 */ +#define __MAP_KERN_RW (PTE_MAP_CACHED | PTE_MAP_WRITE) + +/* Uncached. In ARMv7 device, uncached, shareable, user-rw/kern-rw, xn=1 */ +#define __MAP_USR_IO (PTE_MAP_USER | PTE_MAP_DEVICE | PTE_MAP_WRITE) + +/* Uncached. In ARMv7 device, uncached, shareable, user-none/kern-rw, xn=1 */ +#define __MAP_KERN_IO (PTE_MAP_DEVICE | PTE_MAP_WRITE) + +/* Writeback cached. In ARMv7 normal, wbwa, shareable, user-rw/kern-rw, xn=0 */ +#define __MAP_USR_RWX (PTE_MAP_USER | PTE_MAP_CACHED \ + | PTE_MAP_WRITE | PTE_MAP_EXEC) + +/* Writeback cached. In ARMv7 normal, wbwa, shareable, user-none/kern-rw, xn=0 */ +#define __MAP_KERN_RWX (PTE_MAP_CACHED | PTE_MAP_WRITE | PTE_MAP_EXEC) + +/* Writeback cached. In ARMv7 normal, wbwa, shareable, user-ro/kern-ro, xn=0 */ +#define __MAP_USR_RX (PTE_MAP_USER | PTE_MAP_CACHED | PTE_MAP_EXEC) + +/* Writeback cached. In ARMv7 normal, wbwa, shareable, user-none/kern-ro, xn=0 */ +#define __MAP_KERN_RX (PTE_MAP_CACHED | PTE_MAP_EXEC) + +/* Fault/unmapped entry */ +#define __MAP_FAULT PTE_MAP_FAULT + +/* + * Shareability bit remapping on tex remap + * + * As an example to below, when a normal region has its + * shareability bit set to 1, PRRR_NORMAL_S1_BIT remaps + * and determines the final shareability status. E.g. if + * PRRR_NORMAL_S1_BIT is set to 0, the region becomes + * not shareable, even though the pte S bit == 1. + * On Tex Remap, PRRR is the final decision point. + */ +#define PRRR_DEVICE_S0_BIT 16 /* Meaning of all device memory when S == 0 */ +#define PRRR_DEVICE_S1_BIT 17 /* Meaning of all device memory when S == 1 */ +#define PRRR_NORMAL_S0_BIT 18 /* Meaning of all normal memory when S == 0 */ +#define PRRR_NORMAL_S1_BIT 19 /* Meaning of all normal memory when S == 1 */ +#define PRRR_NOS_START_BIT 24 +#define NMRR_OUTER_START_BIT 16 +#define CACHEABLE_NONE 0 +#define CACHEABLE_WBWA 1 +#define CACHEABLE_WT_NOWA 2 +#define CACHEABLE_WB_NOWA 3 + +/* Memory type values for tex remap registers */ +#define MEMTYPE_ST_ORDERED 0 +#define MEMTYPE_DEVICE 1 +#define MEMTYPE_NORMAL 2 + +/* User-defined tex remap slots */ +#define TEX_SLOT_NORMAL_UNCACHED 0 +#define TEX_SLOT_NORMAL 1 +#define TEX_SLOT_DEVICE_UNCACHED 2 +#define TEX_SLOT_ST_ORDERED_UNCACHED 3 + +#define ASID_MASK 0xFF +#define ASID_GROUP_SHIFT 8 +#define PROCID_SHIFT 8 +#define PROCID_MASK 0xFFFFFF + +#define TASK_ASID(x) ((x)->space->spid & ASID_MASK) +#define SPACE_ASID(x) ((x)->spid & ASID_MASK) +#define TASK_PROCID(x) ((x)->tid & PROCID_MASK) + +#define PGD_GLOBAL_GET() (kernel_resources.pgd_global) + +/* + * + * Page table memory settings for translation table walk hardware: + * + * We assume write-back write-allocate, inner and outer + * cacheable, inner shareable, not outer-shareable, + * normal memory. + * + * ARMv7 VMSA (B3-114) says that the obscure IRGN[1:0] + * mapping ensures same bit values for SMP and v7 base architecture, + * however this is only partially true as seen by the WBWA bit + * mapping differences. + * + * RGN values: + * 00 Uncached + * 01 WBWA + * 10 WT + * 11 WB_NOWA + * + * On below definitions both inner and outer cacheability bits + * are assigned with the same cacheability values. + */ + /* I + * I R + * R R R G + * G N G G I N + * N O N N M 1 + * 0 S 1|0 P S C */ +#define PGD_MEMORY_NORMAL_WBWA_S_NOS 0x2B /* 00 1 0|1 0 1 1 */ +#define PGD_MEMORY_NORMAL_WBWA_S_NOS_SMP 0x6A /* 01 1 0|1 0 1 0 */ +#define PGD_MEMORY_NORMAL_WB_NOWA_S_NOS 0x3B /* 00 1 1|1 0 1 1 */ +#define PGD_MEMORY_NORMAL_WB_NOWA_S_NOS_SMP 0x7B /* 01 1 1|1 0 1 1 */ +#define PGD_MEMORY_NORMAL_WB_NOWA_S_OS 0x1B /* 00 0 1|1 0 1 1 */ +#define PGD_MEMORY_NORMAL_WB_NOWA_S_OS_SMP 0x5B /* 01 0 1|1 0 1 1 */ +#define PGD_MEMORY_NORMAL_UNCACHED_S_NOS 0x22 /* 00 1 0|0 0 1 0 */ +#define PGD_MEMORY_NORMAL_UNCACHED_S_NOS_SMP 0x22 /* 00 1 0|0 0 1 0 */ +#define PGD_MEMORY_NORMAL_WBWA_S_OS 0x0B /* 00 0 0|1 0 1 1 */ +#define PGD_MEMORY_NORMAL_WBWA_S_OS_SMP 0x4A /* 01 0 0|1 0 1 0 */ + +/* Returns page table memory settings for ttb walk fetches */ +unsigned int ttb_walk_mem_settings(void); + + +#if !defined (__ASSEMBLY__) + +void v7_flags_prepare_pte(pte_t *pte, unsigned long phys, + unsigned long virt, unsigned int v7_pte_flags); +void section_set_access_simple(pmd_t *pmd, unsigned int perms); +void section_set_tex_remap_slot(pmd_t *pmd, int slot); +void v7_write_section(unsigned long paddr, unsigned long vaddr, + unsigned int section_flags, unsigned int asid); +int pte_get_access_simple(pte_t pte); +void tex_remap_setup_all_slots(void); + +struct ktcb; +void arch_update_utcb(unsigned long utcb_address); +void arch_space_switch(struct ktcb *to); +void system_identify(void); + +#endif /* !defined(__ASSEMBLY__) */ + +#endif /* __V7_MM_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/generic/cap-types.h b/conts/userlibs/libl4/include/l4lib/linux/generic/cap-types.h new file mode 100644 index 0000000..7323378 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/generic/cap-types.h @@ -0,0 +1,148 @@ +/* + * Types of capabilities and their operations + * + * Copyright (C) 2009 Bahadir Balban + */ +#ifndef __CAP_TYPES_H__ +#define __CAP_TYPES_H__ + +/* + * Capability types + */ +#define CAP_TYPE_MASK 0x0000FFFF +#define CAP_TYPE_TCTRL (1 << 0) +#define CAP_TYPE_EXREGS (1 << 1) +#define CAP_TYPE_MAP_PHYSMEM (1 << 2) +#define CAP_TYPE_MAP_VIRTMEM (1 << 3) +#define CAP_TYPE_IPC (1 << 4) +#define CAP_TYPE_IRQCTRL (1 << 5) +#define CAP_TYPE_UMUTEX (1 << 6) +#define CAP_TYPE_QUANTITY (1 << 7) +#define CAP_TYPE_CAP (1 << 8) +#define cap_type(c) ((c)->type & CAP_TYPE_MASK) + +/* + * Resource types + */ +#define CAP_RTYPE_MASK 0xFFFF0000 +#define CAP_RTYPE_THREAD (1 << 16) +#define CAP_RTYPE_SPACE (1 << 17) +#define CAP_RTYPE_CONTAINER (1 << 18) +#define CAP_RTYPE_CPUPOOL (1 << 19) +#define CAP_RTYPE_THREADPOOL (1 << 20) +#define CAP_RTYPE_SPACEPOOL (1 << 21) +#define CAP_RTYPE_MUTEXPOOL (1 << 22) +#define CAP_RTYPE_MAPPOOL (1 << 23) /* For pmd spending */ +#define CAP_RTYPE_CAPPOOL (1 << 24) /* For new cap generation */ + +#define cap_rtype(c) ((c)->type & CAP_RTYPE_MASK) +#define cap_set_rtype(c, rtype) \ + {(c)->type &= ~CAP_RTYPE_MASK; \ + (c)->type |= CAP_RTYPE_MASK & rtype;} + +/* + * User-defined device-types + * (Kept in the user field) + */ +#define CAP_DEVTYPE_TIMER 1 +#define CAP_DEVTYPE_UART 2 +#define CAP_DEVTYPE_KEYBOARD 3 +#define CAP_DEVTYPE_MOUSE 4 +#define CAP_DEVTYPE_CLCD 5 +#define CAP_DEVTYPE_OTHER 0xF +#define CAP_DEVTYPE_MASK 0xFFFF +#define CAP_DEVNUM_MASK 0xFFFF0000 +#define CAP_DEVNUM_SHIFT 16 + +#define cap_is_devmem(c) ((c)->attr) +#define cap_set_devtype(c, devtype) \ + {(c)->attr &= ~CAP_DEVTYPE_MASK; \ + (c)->attr |= CAP_DEVTYPE_MASK & devtype;} +#define cap_set_devnum(c, devnum) \ + {(c)->attr &= ~CAP_DEVNUM_MASK; \ + (c)->attr |= CAP_DEVNUM_MASK & (devnum << CAP_DEVNUM_SHIFT);} +#define cap_devnum(c) \ + (((c)->attr & CAP_DEVNUM_MASK) >> CAP_DEVNUM_SHIFT) +#define cap_devtype(c) ((c)->attr & CAP_DEVTYPE_MASK) + +/* + * Access permissions + */ + +/* Generic permissions */ +#define CAP_CHANGEABLE (1 << 28) /* Can modify contents */ +#define CAP_TRANSFERABLE (1 << 29) /* Can grant or share it */ +#define CAP_REPLICABLE (1 << 30) /* Can create copies */ +#define CAP_GENERIC_MASK 0xF0000000 +#define CAP_IMMUTABLE 0 +#define cap_generic_perms(c) \ + ((c)->access & CAP_GENERIC_MASK) + +/* Thread control capability */ +#define CAP_TCTRL_CREATE (1 << 0) +#define CAP_TCTRL_DESTROY (1 << 1) +#define CAP_TCTRL_RUN (1 << 2) +#define CAP_TCTRL_SUSPEND (1 << 3) +#define CAP_TCTRL_RECYCLE (1 << 4) +#define CAP_TCTRL_WAIT (1 << 5) + +/* Exchange registers capability */ +#define CAP_EXREGS_RW_PAGER (1 << 0) +#define CAP_EXREGS_RW_UTCB (1 << 1) +#define CAP_EXREGS_RW_SP (1 << 2) +#define CAP_EXREGS_RW_PC (1 << 3) +#define CAP_EXREGS_RW_REGS (1 << 4) /* Other regular regs */ +#define CAP_EXREGS_RW_CPU (1 << 5) +#define CAP_EXREGS_RW_CPUTIME (1 << 6) + +/* Map capability */ +#define CAP_MAP_READ (1 << 0) +#define CAP_MAP_WRITE (1 << 1) +#define CAP_MAP_EXEC (1 << 2) +#define CAP_MAP_CACHED (1 << 3) +#define CAP_MAP_UNCACHED (1 << 4) +#define CAP_MAP_UNMAP (1 << 5) +#define CAP_MAP_UTCB (1 << 6) + +/* Cache operations, applicable to (virtual) memory regions */ +#define CAP_CACHE_INVALIDATE (1 << 7) +#define CAP_CACHE_CLEAN (1 << 8) + +/* + * IRQ Control capability + */ +#define CAP_IRQCTRL_WAIT (1 << 8) + +/* + * This is a common one and it applies to both + * CAP_TYPE_IRQCTRL and CAP_TYPE_MAP_PHYSMEM + */ +#define CAP_IRQCTRL_REGISTER (1 << 7) + + + +/* Ipc capability */ +#define CAP_IPC_SEND (1 << 0) +#define CAP_IPC_RECV (1 << 1) +#define CAP_IPC_SHORT (1 << 2) +#define CAP_IPC_FULL (1 << 3) +#define CAP_IPC_EXTENDED (1 << 4) +#define CAP_IPC_ASYNC (1 << 5) + +/* Userspace mutex capability */ +#define CAP_UMUTEX_LOCK (1 << 0) +#define CAP_UMUTEX_UNLOCK (1 << 1) + +/* Capability control capability */ +#define CAP_CAP_GRANT (1 << 0) +#define CAP_CAP_READ (1 << 1) +#define CAP_CAP_SHARE (1 << 2) +#define CAP_CAP_REPLICATE (1 << 3) +#define CAP_CAP_SPLIT (1 << 4) +#define CAP_CAP_DEDUCE (1 << 5) +#define CAP_CAP_DESTROY (1 << 6) +#define CAP_CAP_MODIFY (CAP_CAP_DEDUCE | CAP_CAP_SPLIT \ + | CAP_CAP_DESTROY) + + +#endif /* __CAP_TYPES_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/generic/preempt.h b/conts/userlibs/libl4/include/l4lib/linux/generic/preempt.h new file mode 100644 index 0000000..153d383 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/generic/preempt.h @@ -0,0 +1,19 @@ +/* + * Kernel preemption functions. + */ +#ifndef __PREEMPT_H__ +#define __PREEMPT_H__ + +#if !defined(__LINUX_CONTAINER__) + +void preempt_enable(void); +void preempt_disable(void); +int preemptive(void); +int preempt_count(void); + +int in_nested_irq_context(void); +int in_irq_context(void); +int in_task_context(void); + +#endif /* __LINUX_CONTAINER__ */ +#endif /* __PREEMPT_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/generic/space.h b/conts/userlibs/libl4/include/l4lib/linux/generic/space.h new file mode 100644 index 0000000..41c9d83 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/generic/space.h @@ -0,0 +1,30 @@ +/* + * Generic address space related information. + * + * Copyright (C) 2007-2010 Bahadir Balban + */ +#ifndef __SPACE_H__ +#define __SPACE_H__ + +/* + * Generic mapping flags. + */ +#define MAP_FAULT 0 +#define MAP_USR_RW 1 +#define MAP_USR_RO 2 +#define MAP_KERN_RW 3 +#define MAP_USR_IO 4 +#define MAP_KERN_IO 5 +#define MAP_USR_RWX 6 +#define MAP_KERN_RWX 7 +#define MAP_USR_RX 8 +#define MAP_KERN_RX 9 +#define MAP_UNMAP 10 /* For unmap syscall */ +#define MAP_INVALID_FLAGS (1 << 31) + +/* Some default aliases */ +#define MAP_USR_DEFAULT MAP_USR_RW +#define MAP_KERN_DEFAULT MAP_KERN_RW +#define MAP_IO_DEFAULT MAP_KERN_IO + +#endif /* __SPACE_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/generic/tcb.h b/conts/userlibs/libl4/include/l4lib/linux/generic/tcb.h new file mode 100644 index 0000000..6997e62 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/generic/tcb.h @@ -0,0 +1,43 @@ +/* + * Thread Control Block, kernel portion. + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ +#ifndef __TCB_H__ +#define __TCB_H__ + + +/* + * These are a mixture of flags that indicate the task is + * in a transitional state that could include one or more + * scheduling states. + */ +#define TASK_INTERRUPTED (1 << 0) +#define TASK_SUSPENDING (1 << 1) +#define TASK_RESUMING (1 << 2) +#define TASK_PENDING_SIGNAL (TASK_SUSPENDING) +#define TASK_REALTIME (1 << 5) + +/* + * This is to indicate a task (either current or one of + * its children) exit has occured and cleanup needs to be + * called + */ +#define TASK_EXITED (1 << 3) + +/* Task states */ +enum task_state { + TASK_INACTIVE = 0, + TASK_SLEEPING = 1, + TASK_RUNNABLE = 2, +}; + +#define TASK_CID_MASK 0xFF000000 +#define TASK_ID_MASK 0x00FFFFFF +#define TASK_CID_SHIFT 24 + +/* Values that rather have special meaning instead of an id value */ +#define TASK_ID_INVALID 0xFFFFFFFF + +#endif /* __TCB_H__ */ + diff --git a/conts/userlibs/libl4/include/l4lib/linux/glue/arm/cache.h b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/cache.h new file mode 100644 index 0000000..dee309f --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/cache.h @@ -0,0 +1,26 @@ +/* + * Generic cache api calls + * + * Copyright (C) 2010 B Labs Ltd. + * + * Author: Bahadir Balban + */ +#ifndef __GLUE_CACHE_H__ +#define __GLUE_CACHE_H__ + +//#include INC_SUBARCH(mmu_ops.h) + +/* Lowest byte is reserved for and used by capability permissions */ +#define ARCH_INVALIDATE_ICACHE 0x10 +#define ARCH_INVALIDATE_DCACHE 0x20 +#define ARCH_CLEAN_DCACHE 0x30 +#define ARCH_CLEAN_INVALIDATE_DCACHE 0x40 +#define ARCH_INVALIDATE_TLB 0x50 + +void arch_invalidate_dcache(unsigned long start, unsigned long end); +void arch_clean_invalidate_dcache(unsigned long start, unsigned long end); +void arch_invalidate_icache(unsigned long start, unsigned long end); +void arch_invalidate_tlb(unsigned long start, unsigned long end); +void arch_clean_dcache(unsigned long start, unsigned long end); + +#endif /* __GLUE_CACHE_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/glue/arm/context.h b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/context.h new file mode 100644 index 0000000..31ece62 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/context.h @@ -0,0 +1,53 @@ +#ifndef __ARM_CONTEXT_H__ +#define __ARM_CONTEXT_H__ + +#include + +/* + * This describes the register context of each task. Simply set + * them and they'll be copied onto real registers upon a context + * switch to that task. exchange_registers() system call is + * designed for this, whose input structure is defined further + * below. + */ +typedef struct arm_context { + u32 spsr; /* 0x0 */ + u32 r0; /* 0x4 */ + u32 r1; /* 0x8 */ + u32 r2; /* 0xC */ + u32 r3; /* 0x10 */ + u32 r4; /* 0x14 */ + u32 r5; /* 0x18 */ + u32 r6; /* 0x1C */ + u32 r7; /* 0x20 */ + u32 r8; /* 0x24 */ + u32 r9; /* 0x28 */ + u32 r10; /* 0x2C */ + u32 r11; /* 0x30 */ + u32 r12; /* 0x34 */ + u32 sp; /* 0x38 */ + u32 lr; /* 0x3C */ + u32 pc; /* 0x40 */ +} __attribute__((__packed__)) task_context_t; + + +typedef struct arm_exregs_context { + u32 r0; /* 0x4 */ + u32 r1; /* 0x8 */ + u32 r2; /* 0xC */ + u32 r3; /* 0x10 */ + u32 r4; /* 0x14 */ + u32 r5; /* 0x18 */ + u32 r6; /* 0x1C */ + u32 r7; /* 0x20 */ + u32 r8; /* 0x24 */ + u32 r9; /* 0x28 */ + u32 r10; /* 0x2C */ + u32 r11; /* 0x30 */ + u32 r12; /* 0x34 */ + u32 sp; /* 0x38 */ + u32 lr; /* 0x3C */ + u32 pc; /* 0x40 */ +} __attribute__((__packed__)) exregs_context_t; + +#endif /* __ARM_CONTEXT_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/glue/arm/memlayout.h b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/memlayout.h new file mode 100644 index 0000000..e71f7d8 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/memlayout.h @@ -0,0 +1,61 @@ +/* + * Virtual memory layout of ARM systems. + */ + +#ifndef __MEMLAYOUT_H__ +#define __MEMLAYOUT_H__ + +#ifndef __ASSEMBLY__ +#include L4LIB_INC_GLUE(memory.h) +#endif + +#define KERNEL_AREA_START 0xF0000000 +#define KERNEL_AREA_END 0xF8000000 /* 128 MB */ +#define KERNEL_AREA_SIZE (KERNEL_AREA_END - KERNEL_AREA_START) +#define KERNEL_AREA_SECTIONS (KERNEL_AREA_SIZE / ARM_SECTION_SIZE) + +#define UTCB_SIZE (sizeof(int) * 64) + +#define IO_AREA_START 0xF9000000 +#define IO_AREA_END 0xFF000000 +#define IO_AREA_SIZE (IO_AREA_END - IO_AREA_START) +#define IO_AREA_SECTIONS (IO_AREA_SIZE / ARM_SECTION_SIZE) + +#define USER_KIP_PAGE 0xFF000000 + +/* ARM-specific offset in KIP that tells the address of UTCB page */ +#define UTCB_KIP_OFFSET 0x50 + +#define IO_AREA0_VADDR IO_AREA_START +#define IO_AREA1_VADDR (IO_AREA_START + (SZ_1MB*1)) +#define IO_AREA2_VADDR (IO_AREA_START + (SZ_1MB*2)) +#define IO_AREA3_VADDR (IO_AREA_START + (SZ_1MB*3)) +#define IO_AREA4_VADDR (IO_AREA_START + (SZ_1MB*4)) +#define IO_AREA5_VADDR (IO_AREA_START + (SZ_1MB*5)) +#define IO_AREA6_VADDR (IO_AREA_START + (SZ_1MB*6)) +#define IO_AREA7_VADDR (IO_AREA_START + (SZ_1MB*7)) + +/* + * IO_AREA8_VADDR + * The beginning page in this slot is used for userspace uart mapping + */ + +#define ARM_HIGH_VECTOR 0xFFFF0000 +#define ARM_SYSCALL_VECTOR 0xFFFFFF00 + +#if !defined(__LINUX_CONTAINER__) +#define KERNEL_OFFSET (KERNEL_AREA_START - PLATFORM_PHYS_MEM_START) +#endif + +/* User tasks define them differently */ +#if defined (__KERNEL__) && !defined(__LINUX_CONTAINER__) +#define phys_to_virt(addr) ((unsigned int)(addr) + KERNEL_OFFSET) +#define virt_to_phys(addr) ((unsigned int)(addr) - KERNEL_OFFSET) +#endif + +#define KERN_ADDR(x) ((x >= KERNEL_AREA_START) && (x < KERNEL_AREA_END)) +#define UTCB_ADDR(x) ((x >= UTCB_AREA_START) && (x < UTCB_AREA_END)) +#define is_kernel_address(x) (KERN_ADDR(x) || (x >= ARM_HIGH_VECTOR) || \ + (x >= IO_AREA_START && x < IO_AREA_END)) + +#endif /* __MEMLAYOUT_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/glue/arm/memory.h b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/memory.h new file mode 100644 index 0000000..936faf3 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/memory.h @@ -0,0 +1,85 @@ +/* + * Includes memory-related architecture specific definitions and their + * corresponding generic wrappers. + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __GLUE_ARM_MEMORY_H__ +#define __GLUE_ARM_MEMORY_H__ + +#include L4LIB_INC_GLUE(memlayout.h) /* Important generic definitions */ +#include L4LIB_INC_SUBARCH(mm.h) + +/* Generic definitions */ +#define PFN_SHIFT 12 +#define PAGE_BITS PFN_SHIFT +#if !defined(__LINUX_CONTAINER__) +#define PAGE_SIZE SZ_4K +#define PAGE_MASK (PAGE_SIZE - 1) +#endif + +/* Aligns to the upper page (ceiling) FIXME: Must add a wraparound checker. */ +#define page_align_up(addr) ((((unsigned long)(addr)) + PAGE_MASK) & \ + (~PAGE_MASK)) + +/* Aligns to the lower page (floor) */ +#define page_align(addr) (((unsigned long)(addr)) & \ + (~PAGE_MASK)) + +#define is_aligned(val, size) (!(((unsigned long)(val)) & (((unsigned long)size) - 1))) +#define is_page_aligned(val) (!(((unsigned long)(val)) & PAGE_MASK)) +#define page_boundary(x) is_page_aligned(x) + +/* + * Align to given size. + * + * Note it must be an alignable size i.e. one that is a power of two. + * E.g. 0x1000 would work but 0x1010 would not. + */ +#define align(addr, size) (((unsigned int)(addr)) & (~((unsigned long)size-1))) +#define align_up(addr, size) ((((unsigned long)(addr)) + \ + ((size) - 1)) & (~(((unsigned long)size) - 1))) + +/* The bytes left until the end of the page that x is in */ +#define TILL_PAGE_ENDS(x) (PAGE_SIZE - ((unsigned long)(x) & PAGE_MASK)) + +/* Extract page frame number from address and vice versa. */ +#define __pfn(x) (((unsigned long)(x)) >> PAGE_BITS) +#define __pfn_to_addr(x) (((unsigned long)(x)) << PAGE_BITS) + +/* Extract physical address from page table entry (pte) */ +#define __pte_to_addr(x) (((unsigned long)(x)) & ~PAGE_MASK) + +/* Minimum excess needed for word alignment */ +#define SZ_WORD sizeof(unsigned int) +#define WORD_BITS 32 +#define WORD_BITS_LOG2 5 +#define BITWISE_GETWORD(x) ((x) >> WORD_BITS_LOG2) /* Divide by 32 */ +#define BITWISE_GETBIT(x) (1 << ((x) % WORD_BITS)) + +/* Minimum stack alignment restriction across functions, exceptions */ +#define STACK_ALIGNMENT 8 + +#if !defined(__LINUX_CONTAINER__) +/* Endianness conversion */ +static inline void be32_to_cpu(unsigned int x) +{ + char *p = (char *)&x; + char tmp; + + /* Swap bytes */ + tmp = p[0]; + p[0] = p[3]; + p[3] = tmp; + + tmp = p[1]; + p[1] = p[2]; + p[2] = tmp; +} + +struct ktcb; +void task_init_registers(struct ktcb *task, unsigned long pc); +#endif /* !_LINUX_CONTAINER__ */ + +#endif /* __GLUE_ARM_MEMORY_H__ */ + diff --git a/conts/userlibs/libl4/include/l4lib/linux/glue/arm/message.h b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/message.h new file mode 100644 index 0000000..7b63a7b --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/message.h @@ -0,0 +1,95 @@ +/* + * Userspace thread control block + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ +#ifndef __GLUE_ARM_MESSAGE_H__ +#define __GLUE_ARM_MESSAGE_H__ + +/* + * Here's a summary of how ARM registers are used during IPC: + * + * System registers: + * r0 - r2: Passed as arguments to ipc() call. They are the registers + * the microkernel will read and they have system-wide meaning. + * + * Primary message registers: + * r3 - r8: These 6 registers are the primary message registers MR0-MR6. + * Their format is application-specific, i.e. the microkernel imposes no + * format restrictions on them. + * + * TODO: The only exception is that, for ANYTHREAD receivers the predefined + * MR_SENDER is touched by the kernel to indicate the sender. This register + * is among the primary MRs and it may be better fit to put it into one of + * the system registers. + * + * l4lib registers: (MR_TAG, MR_SENDER, MR_RETURN) + * Some of the primary message registers are used by the l4lib convenience + * library for operations necessary on most or all common ipcs. For example + * every ipc has a tag that specifies the ipc reason. Also send/receive + * operations require a return value. Threads that are open to receive from + * all threads require the sender id. These values are passed in predefined + * primary message registers, but the microkernel has no knowledge about them. + * + * System call registers: L4SYS_ARG0 to ARG4.(See syslib.h for definitions) + * Finally the rest of the primary message registers are available for + * implementing system call arguments. For example the POSIX services use + * these arguments to pass posix system call information. + * + * Secondary Message Registers: + * These are non-real registers and are present in the UTCB memory region. + * Both real and non-real message registers have a location in the UTCB, but + * non-real ones are copied only if the FULL IPC flag is set. + * + * The big picture: + * + * r0 System register + * r1 System register + * r2 System register + * r3 Primary MR0 MR_RETURN, MR_TAG Present in UTCB, Short IPC + * r4 Primary MR1 MR_SENDER Present in UTCB, Short IPC + * r5 Primary MR2 L4SYS_ARG0 Present in UTCB, Short IPC + * r6 Primary MR3 L4SYS_ARG1 Present in UTCB, Short IPC + * r7 Primary MR4 L4SYS_ARG2 Present in UTCB, Short IPC + * r8 Primary MR5 L4SYS_ARG3 Present in UTCB, Short IPC + * x Secondary MR6 Present in UTCB, Full IPC only + * x Secondary MR64 Present in UTCB, Full IPC only + * + * Complicated for you? Suggest a simpler design and it shall be implemented! + */ + +#define MR_REST ((UTCB_SIZE >> 2) - MR_TOTAL - 4) /* -4 is for fields on utcb */ +#define MR_TOTAL 6 +#define MR_TAG 0 /* Contains the purpose of message */ +#define MR_SENDER 1 /* For anythread receivers to discover sender */ +#define MR_RETURN 0 /* Contains the posix return value. */ + +/* These define the mr start - end range that isn't used by userspace syslib */ +#define MR_UNUSED_START 2 /* The first mr that's not used by syslib.h */ +#define MR_UNUSED_TOTAL (MR_TOTAL - MR_UNUSED_START) +#define MR_USABLE_TOTAL MR_UNUSED_TOTAL + +/* These are defined so that we don't hard-code register names */ +#define MR0_REGISTER r3 +#define MR_RETURN_REGISTER r3 + +#define TASK_NOTIFY_SLOTS 8 +#define TASK_NOTIFY_MAXVALUE 255 + +/* Primaries aren't used for memcopy. Those ops use this as a parameter */ +#define L4_UTCB_FULL_BUFFER_SIZE (MR_REST * sizeof(int)) + +#include L4LIB_INC_GLUE(memlayout.h) + +#if !defined (__ASSEMBLY__) +struct utcb { + u32 mr[MR_TOTAL]; /* MRs that are mapped to real registers */ + u32 saved_tag; /* Saved tag field for stacked ipcs */ + u32 saved_sender; /* Saved sender field for stacked ipcs */ + u8 notify[TASK_NOTIFY_SLOTS]; /* Irq notification slots */ + u32 mr_rest[MR_REST]; /* Complete the utcb for up to 64 words */ +}; +#endif + + +#endif /* __GLUE_ARM_MESSAGE_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/glue/arm/syscall.h b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/syscall.h new file mode 100644 index 0000000..82e7e63 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/glue/arm/syscall.h @@ -0,0 +1,78 @@ +/* + * ARM-specific system call details. + * + * Copyright (C) 2007 Bahadir Balban + */ + +#ifndef __ARM_GLUE_SYSCALL_H__ +#define __ARM_GLUE_SYSCALL_H__ + +#include +#include L4LIB_INC_GLUE(message.h) + +/* Only specific call is the trap that gives back the kip address + * from which other system calls can be discovered. */ +#define L4_TRAP_KIP 0xB4 + +/* Used in the kernel to refer to virtual address of this page. + * User space discovers it from the KIP */ +#define ARM_SYSCALL_PAGE 0xFFFFF000 + +extern unsigned int __syscall_page_start; + +/* + * This structure is saved on the kernel stack + * just after entering a system call exception. + */ +typedef struct syscall_context { + u32 spsr; + u32 r0; + u32 r1; + u32 r2; + u32 r3; /* MR0 */ + u32 r4; /* MR1 */ + u32 r5; /* MR2 */ + u32 r6; /* MR3 */ + u32 r7; /* MR4 */ + u32 r8; /* MR5 */ + u32 r9; + u32 r10; + u32 r11; + u32 r12; + u32 sp_usr; + u32 lr_usr; +} __attribute__((__packed__)) syscall_context_t; + +typedef struct msg_regs { + u32 mr0; + u32 mr1; + u32 mr2; + u32 mr3; + u32 mr4; + u32 mr5; +} msg_regs_t; + +/* NOTE: + * These references are valid only when they have been explicitly set + * by a kernel entry point, e.g. a system call, a data abort handler + * that imitates a page fault ipc etc. + * + * Second note: + * _If_ these refer to real utcb's in the future, make sure to have + * utcb_map_lazily() check so that they're safe accesses. + */ +#define KTCB_REF_ARG0(ktcb) (&(ktcb)->syscall_regs->r0) +#define KTCB_REF_MR0(ktcb) (&(ktcb)->syscall_regs->MR0_REGISTER) + +/* Represents each syscall. We get argument registers + * from stack for now. This is slower but the simplest. */ +typedef int (*syscall_fn_t)(struct syscall_context *regs); + +/* Entry point for syscall dispatching. Called from asm */ +int syscall(struct syscall_context *regs, unsigned long); + +/* Syscall-related initialiser called during system init. */ +void syscall_init(void); +void kip_init_syscalls(void); + +#endif /* __ARM_GLUE_SYSCALL_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/lib/list.h b/conts/userlibs/libl4/include/l4lib/linux/lib/list.h new file mode 100644 index 0000000..15f981a --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/lib/list.h @@ -0,0 +1,131 @@ +#ifndef __LIST_H__ +#define __LIST_H__ + +#define L4_DEADWORD 0xDEADCCCC + +struct link { + struct link *next; + struct link *prev; +}; + +static inline void link_init(struct link *l) +{ + l->next = l; + l->prev = l; +} + +#define LINK_INIT(link) { &(link), &(link) } +#define LINK_DECLARE(l) \ + struct link l = LINK_INIT(l) + +#if !defined(__LINUX_CONTAINER__) +static inline void list_insert(struct link *new, struct link *list) +{ + struct link *next = list->next; + + /* + * The new link goes between the + * current and next links on the list e.g. + * list -> new -> next + */ + new->next = next; + next->prev = new; + list->next = new; + new->prev = list; + +} + +static inline void list_insert_tail(struct link *new, struct link *list) +{ + struct link *prev = list->prev; + + /* + * The new link goes between the + * current and prev links on the list, e.g. + * prev -> new -> list + */ + new->next = list; + list->prev = new; + new->prev = prev; + prev->next = new; +} + +static inline void list_remove(struct link *link) +{ + struct link *prev = link->prev; + struct link *next = link->next; + + prev->next = next; + next->prev = prev; + + link->next = (struct link *)L4_DEADWORD; + link->prev = (struct link *)L4_DEADWORD; +} + +static inline void list_remove_init(struct link *link) +{ + struct link *prev = link->prev; + struct link *next = link->next; + + //BUG_ON(prev == NULL || next == NULL || link == NULL); + prev->next = next; + next->prev = prev; + + link->next = link; + link->prev = link; +} + +/* Cuts the whole list from head and returns it */ +static inline struct link *list_detach(struct link *head) +{ + struct link *next = head->next; + + /* Detach head from rest of the list */ + list_remove_init(head); + + /* Return detached list */ + return next; +} + +/* append new_list to list given by head/end pair */ +static inline void list_attach(struct link *new_list, struct link *head, struct link *end) +{ + /* attach new list at the end of original list */ + end->next = new_list; + new_list->prev = end; + + /* go to the end of list to be attached */ + while (new_list->next != end->next) + new_list = new_list->next; + + /* set end nodes properly */ + new_list->next = head; + head->prev = new_list; + + /* set end to new end */ + end = new_list; +} + + +static inline int list_empty(struct link *list) +{ + return list->prev == list && list->next == list; +} + + +#define link_to_struct(link, struct_type, link_field) \ + container_of(link, struct_type, link_field) + +#define list_foreach_struct(struct_ptr, link_start, link_field) \ + for (struct_ptr = link_to_struct((link_start)->next, typeof(*struct_ptr), link_field); \ + &struct_ptr->link_field != (link_start); \ + struct_ptr = link_to_struct(struct_ptr->link_field.next, typeof(*struct_ptr), link_field)) + +#define list_foreach_removable_struct(struct_ptr, temp_ptr, link_start, link_field) \ + for (struct_ptr = link_to_struct((link_start)->next, typeof(*struct_ptr), link_field), \ + temp_ptr = link_to_struct((struct_ptr)->link_field.next, typeof(*struct_ptr), link_field);\ + &struct_ptr->link_field != (link_start); \ + struct_ptr = temp_ptr, temp_ptr = link_to_struct(temp_ptr->link_field.next, typeof(*temp_ptr), link_field)) + +#endif /* __LINUX_CONTAINER__ */ +#endif /* __LIST_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/lib/math.h b/conts/userlibs/libl4/include/l4lib/linux/lib/math.h new file mode 100644 index 0000000..0307f3c --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/lib/math.h @@ -0,0 +1,44 @@ +#ifndef __LIB_MATH_H__ +#define __LIB_MATH_H__ + +#if !defined (__LINUX_CONTAINER__) +#if !defined pow +static inline int pow(int val, int exp) +{ + int res = 1; + + for (int i = 0; i < exp; i++) + res *= val; + return res; +} +#endif + +#if !defined min +static inline int min(int x, int y) +{ + return x < y ? x : y; +} + +static inline int max(int x, int y) +{ + return x > y ? x : y; +} +#endif +#endif /* !__LINUX_CONTAINER__ */ + +/* Tests if ranges a-b intersect with range c-d */ +static inline int set_intersection(unsigned long a, unsigned long b, + unsigned long c, unsigned long d) +{ + /* + * Below is the complement set (') of the intersection + * of 2 ranges, much simpler ;-) + */ + if (b <= c || a >= d) + return 0; + + /* The rest is always intersecting */ + return 1; +} + +#endif /* __LIB_MATH_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/lib/mutex.h b/conts/userlibs/libl4/include/l4lib/linux/lib/mutex.h new file mode 100644 index 0000000..1e563bd --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/lib/mutex.h @@ -0,0 +1,45 @@ +/* + * The elementary concurrency constructs. + * + * Copyright (C) 2007 Bahadir Balban + */ + +#ifndef __LIB_MUTEX_H__ +#define __LIB_MUTEX_H__ + +#include +#include +#include +#include +#include +#include INC_ARCH(mutex.h) + +/* A mutex is a binary semaphore that can sleep. */ +struct mutex { + struct waitqueue_head wqh; + unsigned int lock; +}; + +static inline void mutex_init(struct mutex *mutex) +{ + memset(mutex, 0, sizeof(struct mutex)); + waitqueue_head_init(&mutex->wqh); +} + +int mutex_trylock(struct mutex *mutex); +int mutex_lock(struct mutex *mutex); +void mutex_unlock(struct mutex *mutex); +void mutex_unlock_async(struct mutex *mutex); + +/* NOTE: Since spinlocks guard mutex acquiring & sleeping, no locks needed */ +static inline int mutex_inc(unsigned int *cnt) +{ + return ++*cnt; +} + +static inline int mutex_dec(unsigned int *cnt) +{ + return --*cnt; +} + +#endif /* __LIB_MUTEX_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/lib/spinlock.h b/conts/userlibs/libl4/include/l4lib/linux/lib/spinlock.h new file mode 100644 index 0000000..38dceaa --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/lib/spinlock.h @@ -0,0 +1,90 @@ +#ifndef __LIB_SPINLOCK_H__ +#define __LIB_SPINLOCK_H__ + +#include +#include +#include L4LIB_INC_ARCH(irq.h) +#include L4LIB_INC_ARCH(mutex.h) + +#if !defined(__LINUX_CONTAINER__) +struct spinlock { + unsigned int lock; +}; + +#if !defined(__LINUX_CONTAINER__) +#define DECLARE_SPINLOCK(lockname) \ + struct spinlock lockname = { \ + .lock = 0, \ + } + +void spin_lock_record_check(void *lock_addr); +void spin_unlock_delete_check(void *lock_addr); + +static inline void spin_lock_init(struct spinlock *s) +{ + memset(s, 0, sizeof(struct spinlock)); +} + +/* + * - Guards from deadlock against local processes, but not local irqs. + * - To be used for synchronising against processes on *other* cpus. + */ +static inline void spin_lock(struct spinlock *s) +{ + preempt_disable(); /* This must disable local preempt */ +#if defined(CONFIG_SMP) + +#if defined (CONFIG_DEBUG_SPINLOCKS) + spin_lock_record_check(s); +#endif + __spin_lock(&s->lock); +#endif +} + +static inline void spin_unlock(struct spinlock *s) +{ +#if defined(CONFIG_SMP) + +#if defined (CONFIG_DEBUG_SPINLOCKS) + spin_unlock_delete_check(s); +#endif + __spin_unlock(&s->lock); +#endif + preempt_enable(); +} + +/* + * - Guards from deadlock against local processes *and* local irqs. + * - To be used for synchronising against processes and irqs + * on other cpus. + */ +static inline void spin_lock_irq(struct spinlock *s, + unsigned long *state) +{ + irq_local_disable_save(state); +#if defined(CONFIG_SMP) +#if defined (CONFIG_DEBUG_SPINLOCKS) + spin_lock_record_check(s); +#endif + + __spin_lock(&s->lock); +#endif +} + +static inline void spin_unlock_irq(struct spinlock *s, + unsigned long state) +{ +#if defined(CONFIG_SMP) + +#if defined (CONFIG_DEBUG_SPINLOCKS) + spin_unlock_delete_check(s); +#endif + + __spin_unlock(&s->lock); +#endif + irq_local_restore(state); +} +#endif + +#endif /* __LINUX_CONTAINER__ */ +#endif /* __LIB__SPINLOCK_H__ */ diff --git a/conts/userlibs/libl4/include/l4lib/linux/lib/wait.h b/conts/userlibs/libl4/include/l4lib/linux/lib/wait.h new file mode 100644 index 0000000..8195817 --- /dev/null +++ b/conts/userlibs/libl4/include/l4lib/linux/lib/wait.h @@ -0,0 +1,86 @@ +#ifndef __LIB_WAIT_H__ +#define __LIB_WAIT_H__ + +#include +#include + +struct ktcb; +struct waitqueue { + struct link task_list; + struct ktcb *task; +}; + +#define WAKEUP_ASYNC 0 + +enum wakeup_flags { + WAKEUP_INTERRUPT = (1 << 0), /* Set interrupt flag for task */ + WAKEUP_SYNC = (1 << 1), /* Wake it up synchronously */ +}; + +#define CREATE_WAITQUEUE_ON_STACK(wq, tsk) \ +struct waitqueue wq = { \ + .task_list = { &wq.task_list, &wq.task_list }, \ + .task = tsk, \ +}; + +struct waitqueue_head { + int sleepers; + struct spinlock slock; + struct link task_list; +}; + +static inline void waitqueue_head_init(struct waitqueue_head *head) +{ + memset(head, 0, sizeof(struct waitqueue_head)); + link_init(&head->task_list); +} + +void task_set_wqh(struct ktcb *task, struct waitqueue_head *wqh, + struct waitqueue *wq); + +void task_unset_wqh(struct ktcb *task); + + +/* + * Sleep if the given condition isn't true. + * ret will tell whether condition was met + * or we got interrupted. + */ +#define WAIT_EVENT(wqh, condition, ret) \ +do { \ + ret = 0; \ + for (;;) { \ + unsigned long irqsave; \ + spin_lock_irq(&(wqh)->slock, &irqsave); \ + if (condition) { \ + spin_unlock_irq(&(wqh)->slock, irqsave);\ + break; \ + } \ + CREATE_WAITQUEUE_ON_STACK(wq, current); \ + task_set_wqh(current, wqh, &wq); \ + (wqh)->sleepers++; \ + list_insert_tail(&wq.task_list, \ + &(wqh)->task_list); \ + /* printk("(%d) waiting...\n", current->tid); */\ + sched_prepare_sleep(); \ + spin_unlock_irq(&(wqh)->slock, irqsave); \ + schedule(); \ + /* Did we wake up normally or get interrupted */\ + if (current->flags & TASK_INTERRUPTED) { \ + current->flags &= ~TASK_INTERRUPTED; \ + ret = -EINTR; \ + break; \ + } \ + } \ +} while(0); + + +void wake_up(struct waitqueue_head *wqh, unsigned int flags); +int wake_up_task(struct ktcb *task, unsigned int flags); +void wake_up_all(struct waitqueue_head *wqh, unsigned int flags); + +int wait_on(struct waitqueue_head *wqh); +int wait_on_prepare(struct waitqueue_head *wqh, struct waitqueue *wq); +int wait_on_prepared_wait(void); +#endif /* __LIB_WAIT_H__ */ + diff --git a/conts/libl4/include/l4lib/macros.h b/conts/userlibs/libl4/include/l4lib/macros.h similarity index 93% rename from conts/libl4/include/l4lib/macros.h rename to conts/userlibs/libl4/include/l4lib/macros.h index 7a20d28..9f48511 100644 --- a/conts/libl4/include/l4lib/macros.h +++ b/conts/userlibs/libl4/include/l4lib/macros.h @@ -6,7 +6,9 @@ #ifndef __LIBL4_MACROS_H__ #define __LIBL4_MACROS_H__ +#if !defined (__LINUX_CONTAINER__) #include +#endif /* * These are for the userspace code to include diff --git a/conts/libl4/include/l4lib/mutex.h b/conts/userlibs/libl4/include/l4lib/mutex.h similarity index 100% rename from conts/libl4/include/l4lib/mutex.h rename to conts/userlibs/libl4/include/l4lib/mutex.h diff --git a/conts/libl4/include/l4lib/os/posix/kstat.h b/conts/userlibs/libl4/include/l4lib/os/posix/kstat.h similarity index 100% rename from conts/libl4/include/l4lib/os/posix/kstat.h rename to conts/userlibs/libl4/include/l4lib/os/posix/kstat.h diff --git a/conts/libl4/include/l4lib/os/posix/readdir.h b/conts/userlibs/libl4/include/l4lib/os/posix/readdir.h similarity index 100% rename from conts/libl4/include/l4lib/os/posix/readdir.h rename to conts/userlibs/libl4/include/l4lib/os/posix/readdir.h diff --git a/conts/libl4/include/l4lib/perfmon.h b/conts/userlibs/libl4/include/l4lib/perfmon.h similarity index 100% rename from conts/libl4/include/l4lib/perfmon.h rename to conts/userlibs/libl4/include/l4lib/perfmon.h diff --git a/conts/libl4/include/l4lib/types.h b/conts/userlibs/libl4/include/l4lib/types.h similarity index 100% rename from conts/libl4/include/l4lib/types.h rename to conts/userlibs/libl4/include/l4lib/types.h diff --git a/conts/libl4/include/l4lib/utcb.h b/conts/userlibs/libl4/include/l4lib/utcb.h similarity index 100% rename from conts/libl4/include/l4lib/utcb.h rename to conts/userlibs/libl4/include/l4lib/utcb.h diff --git a/conts/libl4/src/arch/arm/exregs.c b/conts/userlibs/libl4/src/arch/arm/exregs.c similarity index 100% rename from conts/libl4/src/arch/arm/exregs.c rename to conts/userlibs/libl4/src/arch/arm/exregs.c diff --git a/conts/libl4/src/arch/arm/new_thread.S b/conts/userlibs/libl4/src/arch/arm/new_thread.S similarity index 100% rename from conts/libl4/src/arch/arm/new_thread.S rename to conts/userlibs/libl4/src/arch/arm/new_thread.S diff --git a/conts/libl4/src/arch/arm/syscalls.S b/conts/userlibs/libl4/src/arch/arm/syscalls.S similarity index 100% rename from conts/libl4/src/arch/arm/syscalls.S rename to conts/userlibs/libl4/src/arch/arm/syscalls.S diff --git a/conts/libl4/src/arch/arm/v5/atomic.S b/conts/userlibs/libl4/src/arch/arm/v5/atomic.S similarity index 100% rename from conts/libl4/src/arch/arm/v5/atomic.S rename to conts/userlibs/libl4/src/arch/arm/v5/atomic.S diff --git a/conts/libl4/src/arch/arm/v5/mutex.S b/conts/userlibs/libl4/src/arch/arm/v5/mutex.S similarity index 100% rename from conts/libl4/src/arch/arm/v5/mutex.S rename to conts/userlibs/libl4/src/arch/arm/v5/mutex.S diff --git a/conts/libl4/src/arch/arm/v6/mutex.c b/conts/userlibs/libl4/src/arch/arm/v6/mutex.c similarity index 100% rename from conts/libl4/src/arch/arm/v6/mutex.c rename to conts/userlibs/libl4/src/arch/arm/v6/mutex.c diff --git a/conts/userlibs/libl4/src/arch/arm/v7/atomic.S b/conts/userlibs/libl4/src/arch/arm/v7/atomic.S new file mode 100644 index 0000000..40b3614 --- /dev/null +++ b/conts/userlibs/libl4/src/arch/arm/v7/atomic.S @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010 B Labs + * + * Author: Bahadir Balban + */ + +#include + +/* + * Atomically and destructively reads a byte. E.g. + * byte is read and zero is written back. This is + * useful on reading irq counts + * + * @r0 = byte address + */ +BEGIN_PROC(l4_atomic_dest_readb) + mov r2, #0 +1: + ldrexb r1, [r0] + strexb r3, r2, [r0] + cmp r3, #0 + bne 1b + mov r0, r1 + mov pc, lr +END_PROC(l4_atomic_dest_readb) + + + + diff --git a/conts/libl4/src/arch/arm/v7/mutex.S b/conts/userlibs/libl4/src/arch/arm/v7/mutex.S similarity index 100% rename from conts/libl4/src/arch/arm/v7/mutex.S rename to conts/userlibs/libl4/src/arch/arm/v7/mutex.S diff --git a/conts/libl4/src/arch/arm/v7/perfmon.c b/conts/userlibs/libl4/src/arch/arm/v7/perfmon.c similarity index 100% rename from conts/libl4/src/arch/arm/v7/perfmon.c rename to conts/userlibs/libl4/src/arch/arm/v7/perfmon.c diff --git a/conts/libl4/src/init.c b/conts/userlibs/libl4/src/init.c similarity index 100% rename from conts/libl4/src/init.c rename to conts/userlibs/libl4/src/init.c diff --git a/conts/libl4/src/irq.c b/conts/userlibs/libl4/src/irq.c similarity index 100% rename from conts/libl4/src/irq.c rename to conts/userlibs/libl4/src/irq.c diff --git a/conts/libl4/src/lib/addr.c b/conts/userlibs/libl4/src/lib/addr.c similarity index 100% rename from conts/libl4/src/lib/addr.c rename to conts/userlibs/libl4/src/lib/addr.c diff --git a/conts/libl4/src/lib/bit.c b/conts/userlibs/libl4/src/lib/bit.c similarity index 100% rename from conts/libl4/src/lib/bit.c rename to conts/userlibs/libl4/src/lib/bit.c diff --git a/conts/libl4/src/lib/cap/cap.c b/conts/userlibs/libl4/src/lib/cap/cap.c similarity index 85% rename from conts/libl4/src/lib/cap/cap.c rename to conts/userlibs/libl4/src/lib/cap/cap.c index 00269c7..771fab8 100644 --- a/conts/libl4/src/lib/cap/cap.c +++ b/conts/userlibs/libl4/src/lib/cap/cap.c @@ -26,13 +26,22 @@ struct capability *cap_get_by_type(unsigned int cap_type) struct capability *cap_get_physmem(unsigned int cap_type) { for (int i = 0; i < total_caps; i++) - if ((cap_type(&cap_array[i]) == CAP_TYPE_MAP_PHYSMEM) && - !cap_is_devmem(&cap_array[i])) { + if (cap_type(&cap_array[i]) == CAP_TYPE_MAP_PHYSMEM) { return &cap_array[i]; } return 0; } +struct capability* cap_get_all() +{ + return cap_array; +} + +int cap_get_count() +{ + return total_caps; +} + /* * Read all capabilities */ @@ -74,21 +83,6 @@ void __l4_capability_init(void) caps_read_all(); } -void cap_dev_print(struct capability *cap) -{ - switch (cap_devtype(cap)) { - case CAP_DEVTYPE_UART: - printf("Device type:\t\t\t%s%d\n", "UART", cap_devnum(cap)); - break; - case CAP_DEVTYPE_TIMER: - printf("Device type:\t\t\t%s%d\n", "Timer", cap_devnum(cap)); - break; - default: - return; - } - printf("Device Irq:\t\t%d\n", cap->irq); -} - void cap_print(struct capability *cap) { printf("Capability id:\t\t\t%d\n", cap->capid); @@ -103,12 +97,7 @@ void cap_print(struct capability *cap) printf("Capability type:\t\t%s\n", "Exchange Registers"); break; case CAP_TYPE_MAP_PHYSMEM: - if (!cap_is_devmem(cap)) { - printf("Capability type:\t\t%s\n", "Map/Physmem"); - } else { - printf("Capability type:\t\t%s\n", "Map/Physmem/Device"); - cap_dev_print(cap); - } + printf("Capability type:\t\t%s\n", "Map/Physmem"); break; case CAP_TYPE_MAP_VIRTMEM: printf("Capability type:\t\t%s\n", "Map/Virtmem"); diff --git a/conts/libl4/src/lib/cap/read.c b/conts/userlibs/libl4/src/lib/cap/read.c similarity index 100% rename from conts/libl4/src/lib/cap/read.c rename to conts/userlibs/libl4/src/lib/cap/read.c diff --git a/conts/libl4/src/lib/idpool.c b/conts/userlibs/libl4/src/lib/idpool.c similarity index 98% rename from conts/libl4/src/lib/idpool.c rename to conts/userlibs/libl4/src/lib/idpool.c index 71ca9b6..848089a 100644 --- a/conts/libl4/src/lib/idpool.c +++ b/conts/userlibs/libl4/src/lib/idpool.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include void id_pool_init(struct id_pool *pool, int totalbits) { diff --git a/conts/libl4/src/lib/thread/init.c b/conts/userlibs/libl4/src/lib/thread/init.c similarity index 98% rename from conts/libl4/src/lib/thread/init.c rename to conts/userlibs/libl4/src/lib/thread/init.c index 77ea75d..6e049dd 100644 --- a/conts/libl4/src/lib/thread/init.c +++ b/conts/userlibs/libl4/src/lib/thread/init.c @@ -1,7 +1,7 @@ #include #include -#include +#include /* * Static stack and utcb for same-space threads. diff --git a/conts/libl4/src/lib/thread/thread.c b/conts/userlibs/libl4/src/lib/thread/thread.c similarity index 99% rename from conts/libl4/src/lib/thread/thread.c rename to conts/userlibs/libl4/src/lib/thread/thread.c index 7de4391..91783d2 100644 --- a/conts/libl4/src/lib/thread/thread.c +++ b/conts/userlibs/libl4/src/lib/thread/thread.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include void *l4_utcb_alloc(void) { diff --git a/conts/libl4/src/mutex.c b/conts/userlibs/libl4/src/mutex.c similarity index 100% rename from conts/libl4/src/mutex.c rename to conts/userlibs/libl4/src/mutex.c diff --git a/conts/libmem/SConscript b/conts/userlibs/libmem/SConscript similarity index 55% rename from conts/libmem/SConscript rename to conts/userlibs/libmem/SConscript index d109462..5ae51ce 100644 --- a/conts/libmem/SConscript +++ b/conts/userlibs/libmem/SConscript @@ -6,26 +6,21 @@ import os, sys PROJRELROOT = '../..' - sys.path.append(PROJRELROOT) -from config.projpaths import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.config_invoke import * Import('env') -LIBL4_RELDIR = 'conts/libl4' -LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) -LIBL4_INCLUDE = join(LIBL4_DIR, 'include') - e = env.Clone() e.Append(CPPPATH = ['include', '.', LIBL4_INCLUDE]) objmm = e.StaticObject(Glob('mm/*.c')) objmc = e.StaticObject(Glob('memcache/*.[cS]')) objmalloc = e.StaticObject(Glob('malloc/*.[cS]')) -libmm = e.StaticLibrary('mm', objmm) -libmc = e.StaticLibrary('mc', objmc) -libmalloc = e.StaticLibrary('malloc', objmalloc) +libmem = e.StaticLibrary('mem', objmm + objmc + objmalloc) +#libmc = e.StaticLibrary('mc', objmc) +#libmalloc = e.StaticLibrary('malloc', objmalloc) -Return('libmm', 'libmc', 'libmalloc') +Return('libmem') diff --git a/conts/userlibs/libmem/SConstruct b/conts/userlibs/libmem/SConstruct new file mode 100644 index 0000000..23d7ffa --- /dev/null +++ b/conts/userlibs/libmem/SConstruct @@ -0,0 +1,68 @@ +# +# Copyright (C) 2007 Bahadir Balban +# + +import os, glob, sys +from os.path import join +from string import split + +PROJRELROOT = '../../..' +sys.path.append(PROJRELROOT) + +from scripts.config.config_invoke import * +from scripts.config.projpaths import * +config = configuration_retrieve() +gcc_arch_flag = config.gcc_arch_flag + +mm = "mm" +kmalloc = "kmalloc" +memcache = "memcache" +tests = "tests" + +mm_dir = mm +kmalloc_dir = kmalloc +memcache_dir = memcache +tests_dir = tests + +# This does not work, need to check +test_env = Environment(CC = config.toolchain_userspace + 'gcc', + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', + '-nostdinc', '-Werror', '-march=' + gcc_arch_flag], + ENV = {'PATH' : os.environ['PATH']}, + LIBS = ['mm', 'km', 'mc'], + LIBPATH = ['#'], + CPPPATH = ['#include', KERNEL_HEADERS, "#", LIBL4_INCLUDE]) + +env = Environment(CC = config.toolchain_userspace + 'gcc', + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', + '-Wall', '-Werror', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib'], + ASFLAGS = ['-D__ASSEMBLY__'], + ENV = {'PATH' : os.environ['PATH']}, + LIBS = 'gcc', + CPPPATH = ['.', KERNEL_HEADERS, LIBL4_INCLUDE]) + +if not os.path.exists(CONFIG_H): + print "\nThis build requires a valid kernel configuration header." + print "Please run `scons configure' in the kernel root directory." + print "Choose the `tests' target to build memory allocator tests," + print "or any other target for real use.\n" + sys.exit() + +mm_src = glob.glob("%s/*.c" % mm_dir) +kmalloc_src = glob.glob("%s/*.c" % kmalloc_dir) +memcache_src = glob.glob("%s/*.c" % memcache_dir) +tests_src = glob.glob ("%s/*.c" % tests_dir) + +if "tests" in COMMAND_LINE_TARGETS: + print "WARNING!!! Did you configure the kernel with test target first???" + libmem = test_env.StaticLibrary(mm, mm_src + kmalloc_src + memcache_src) + #libkmalloc = test_env.StaticLibrary("km", kmalloc_src) + #libmemcache = test_env.StaticLibrary("mc", memcache_src) + test_prog = test_env.Program("test", tests_src) + env.Alias("tests", test_prog) +else: + libmem = env.StaticLibrary(mm, mm_src + kmalloc_src + memcache_src) + #libkmalloc = env.StaticLibrary("km", kmalloc_src) + #libmemcache = env.StaticLibrary("mc", memcache_src) + diff --git a/conts/libmem/mm/alloc_page.h b/conts/userlibs/libmem/include/mem/alloc_page.h similarity index 96% rename from conts/libmem/mm/alloc_page.h rename to conts/userlibs/libmem/include/mem/alloc_page.h index 242cbd8..333387d 100644 --- a/conts/libmem/mm/alloc_page.h +++ b/conts/userlibs/libmem/include/mem/alloc_page.h @@ -1,7 +1,7 @@ #ifndef __ALLOC_PAGE_H__ #define __ALLOC_PAGE_H__ -#include +#include /* List member to keep track of free and unused physical pages. * Has PAGE_SIZE granularity */ diff --git a/conts/libmem/tests/clz.h b/conts/userlibs/libmem/include/mem/clz.h similarity index 100% rename from conts/libmem/tests/clz.h rename to conts/userlibs/libmem/include/mem/clz.h diff --git a/conts/libmem/tests/debug.h b/conts/userlibs/libmem/include/mem/debug.h similarity index 83% rename from conts/libmem/tests/debug.h rename to conts/userlibs/libmem/include/mem/debug.h index 3a9cda3..514f90a 100644 --- a/conts/libmem/tests/debug.h +++ b/conts/userlibs/libmem/include/mem/debug.h @@ -1,8 +1,8 @@ #ifndef __DEBUG_H__ #define __DEBUG_H__ -//#include -#include +//#include +#include #include #if defined(DEBUG) diff --git a/conts/libmem/tests/libl4.h b/conts/userlibs/libmem/include/mem/libl4.h similarity index 100% rename from conts/libmem/tests/libl4.h rename to conts/userlibs/libmem/include/mem/libl4.h diff --git a/conts/libmem/malloc/malloc.h b/conts/userlibs/libmem/include/mem/malloc.h similarity index 100% rename from conts/libmem/malloc/malloc.h rename to conts/userlibs/libmem/include/mem/malloc.h diff --git a/conts/libmem/memcache/memcache.h b/conts/userlibs/libmem/include/mem/memcache.h similarity index 100% rename from conts/libmem/memcache/memcache.h rename to conts/userlibs/libmem/include/mem/memcache.h diff --git a/conts/libmem/tests/test_alloc_generic.h b/conts/userlibs/libmem/include/mem/test_alloc_generic.h similarity index 100% rename from conts/libmem/tests/test_alloc_generic.h rename to conts/userlibs/libmem/include/mem/test_alloc_generic.h diff --git a/conts/libmem/tests/test_allocpage.h b/conts/userlibs/libmem/include/mem/test_allocpage.h similarity index 93% rename from conts/libmem/tests/test_allocpage.h rename to conts/userlibs/libmem/include/mem/test_allocpage.h index e9d181d..b78da18 100644 --- a/conts/libmem/tests/test_allocpage.h +++ b/conts/userlibs/libmem/include/mem/test_allocpage.h @@ -1,7 +1,7 @@ #ifndef __TEST_ALLOCPAGE_H__ #define __TEST_ALLOCPAGE_H__ -#include +#include #include "tests.h" void test_allocpage(int num_allocs, int alloc_max, FILE *init, FILE *exit); diff --git a/conts/libmem/tests/test_kmalloc.h b/conts/userlibs/libmem/include/mem/test_kmalloc.h similarity index 83% rename from conts/libmem/tests/test_kmalloc.h rename to conts/userlibs/libmem/include/mem/test_kmalloc.h index 9f3efea..f1f4c02 100644 --- a/conts/libmem/tests/test_kmalloc.h +++ b/conts/userlibs/libmem/include/mem/test_kmalloc.h @@ -1,7 +1,7 @@ #ifndef __TEST_KMALLOC_H__ #define __TEST_KMALLOC_H__ -#include +#include void test_kmalloc(int num_allocs, int allocs_max, FILE *initstate, FILE *exitstate); diff --git a/conts/libmem/tests/test_memcache.h b/conts/userlibs/libmem/include/mem/test_memcache.h similarity index 86% rename from conts/libmem/tests/test_memcache.h rename to conts/userlibs/libmem/include/mem/test_memcache.h index fad3ce2..aec8c96 100644 --- a/conts/libmem/tests/test_memcache.h +++ b/conts/userlibs/libmem/include/mem/test_memcache.h @@ -1,7 +1,7 @@ #ifndef __TEST_MEMCACHE_H__ #define __TEST_MEMCACHE_H__ -#include +#include int test_memcache(int num_alloc, int alloc_size_max, FILE *initstate, FILE *exitstate, int aligned); diff --git a/conts/libmem/tests/tests.h b/conts/userlibs/libmem/include/mem/tests.h similarity index 100% rename from conts/libmem/tests/tests.h rename to conts/userlibs/libmem/include/mem/tests.h diff --git a/conts/libmem/malloc/malloc.c b/conts/userlibs/libmem/malloc/malloc.c similarity index 100% rename from conts/libmem/malloc/malloc.c rename to conts/userlibs/libmem/malloc/malloc.c diff --git a/conts/libmem/memcache/memcache.c b/conts/userlibs/libmem/memcache/memcache.c similarity index 99% rename from conts/libmem/memcache/memcache.c rename to conts/userlibs/libmem/memcache/memcache.c index 57efa55..45aeb4a 100644 --- a/conts/libmem/memcache/memcache.c +++ b/conts/userlibs/libmem/memcache/memcache.c @@ -3,7 +3,7 @@ * * Copyright (C) 2007 Bahadir Balban */ -#include +#include #include #include diff --git a/conts/libmem/mm/alloc_page.c b/conts/userlibs/libmem/mm/alloc_page.c similarity index 99% rename from conts/libmem/mm/alloc_page.c rename to conts/userlibs/libmem/mm/alloc_page.c index 730213c..8efdccb 100644 --- a/conts/libmem/mm/alloc_page.c +++ b/conts/userlibs/libmem/mm/alloc_page.c @@ -9,7 +9,7 @@ #include #include #include -#include "alloc_page.h" +#include #include INC_GLUE(memory.h) #include INC_SUBARCH(mm.h) #include INC_GLUE(memlayout.h) diff --git a/conts/libmem/run_tests.py b/conts/userlibs/libmem/run_tests.py similarity index 100% rename from conts/libmem/run_tests.py rename to conts/userlibs/libmem/run_tests.py diff --git a/conts/libmem/tests/clz.c b/conts/userlibs/libmem/tests/clz.c similarity index 100% rename from conts/libmem/tests/clz.c rename to conts/userlibs/libmem/tests/clz.c diff --git a/conts/libmem/tests/debug.c b/conts/userlibs/libmem/tests/debug.c similarity index 100% rename from conts/libmem/tests/debug.c rename to conts/userlibs/libmem/tests/debug.c diff --git a/conts/libmem/tests/libl4.c b/conts/userlibs/libmem/tests/libl4.c similarity index 100% rename from conts/libmem/tests/libl4.c rename to conts/userlibs/libmem/tests/libl4.c diff --git a/conts/libmem/tests/linker.c b/conts/userlibs/libmem/tests/linker.c similarity index 100% rename from conts/libmem/tests/linker.c rename to conts/userlibs/libmem/tests/linker.c diff --git a/conts/libmem/tests/main.c b/conts/userlibs/libmem/tests/main.c similarity index 98% rename from conts/libmem/tests/main.c rename to conts/userlibs/libmem/tests/main.c index 0f3cecd..c916616 100644 --- a/conts/libmem/tests/main.c +++ b/conts/userlibs/libmem/tests/main.c @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include #include INC_SUBARCH(mm.h) #include INC_ARCH(linker.h) @@ -100,7 +100,7 @@ void print_options(struct cmdline_opts *opts) { dprintf("Running: %s\n", ((opts->run_allocator == 'p') ? "page allocator" : - ((opts->run_allocator == 'k') ? "kmalloc/kfree" : + ((opts->run_allocator == 'k') ? "kmem/kfree" : "memcache allocator"))); dprintf("Total allocations: %d\n", opts->allocations); dprintf("Maximum allocation size: %d, 0x%x(hex)\n\n", diff --git a/conts/libmem/tests/memory.c b/conts/userlibs/libmem/tests/memory.c similarity index 100% rename from conts/libmem/tests/memory.c rename to conts/userlibs/libmem/tests/memory.c diff --git a/conts/libmem/tests/test_alloc_generic.c b/conts/userlibs/libmem/tests/test_alloc_generic.c similarity index 100% rename from conts/libmem/tests/test_alloc_generic.c rename to conts/userlibs/libmem/tests/test_alloc_generic.c diff --git a/conts/libmem/tests/test_allocpage.c b/conts/userlibs/libmem/tests/test_allocpage.c similarity index 100% rename from conts/libmem/tests/test_allocpage.c rename to conts/userlibs/libmem/tests/test_allocpage.c diff --git a/conts/libmem/tests/test_kmalloc.c b/conts/userlibs/libmem/tests/test_kmalloc.c similarity index 100% rename from conts/libmem/tests/test_kmalloc.c rename to conts/userlibs/libmem/tests/test_kmalloc.c diff --git a/conts/libmem/tests/test_memcache.c b/conts/userlibs/libmem/tests/test_memcache.c similarity index 99% rename from conts/libmem/tests/test_memcache.c rename to conts/userlibs/libmem/tests/test_memcache.c index a373647..65e3bf0 100644 --- a/conts/libmem/tests/test_memcache.c +++ b/conts/userlibs/libmem/tests/test_memcache.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "test_memcache.h" #include "test_alloc_generic.h" #include "debug.h" diff --git a/docs/architecture.txt b/docs/architecture.txt deleted file mode 100644 index 50c4af3..0000000 --- a/docs/architecture.txt +++ /dev/null @@ -1,14 +0,0 @@ - -+-+ + + + + + + + + + + + + + + + + -|T| | | | | | | | | | | | | | | | | -|H| | | | | | | | | | | | | | | | | -|R| | | | | | | | | | | | | | | | | -|E| | | | | | | | | | | | | | | | | -|A| | | | | | | | | | | | | | | | | -|D| | | | | | | | | | | | | | | | | -+-------+-------+ +-------+-------+ -| Space | Space | | Space | Space | -+---------------+ +---------------+ -| Container | | Container | -+---------------+ +---------------+ - diff --git a/include/l4/api/capability.h b/include/l4/api/capability.h index 96347a7..749da5e 100644 --- a/include/l4/api/capability.h +++ b/include/l4/api/capability.h @@ -12,26 +12,6 @@ /* Capability syscall request types */ #define CAP_CONTROL_NCAPS 0x00000000 #define CAP_CONTROL_READ 0x00000001 -#define CAP_CONTROL_SHARE 0x00000002 -#define CAP_CONTROL_GRANT 0x00000003 -#define CAP_CONTROL_REPLICATE 0x00000004 -#define CAP_CONTROL_SPLIT 0x00000005 -#define CAP_CONTROL_DEDUCE 0x00000006 -#define CAP_CONTROL_DESTROY 0x00000007 - -#define CAP_SHARE_MASK 0x0000000F -#define CAP_SHARE_SINGLE 0x00000001 -#define CAP_SHARE_ALL_CONTAINER 0x00000002 -#define CAP_SHARE_ALL_SPACE 0x00000003 - -#define CAP_GRANT_MASK 0x0000000F -#define CAP_GRANT_SINGLE 0x00000001 -#define CAP_GRANT_IMMUTABLE 0x00000004 - -#define CAP_SPLIT_MASK 0x0000000F -#define CAP_SPLIT_SIZE 0x00000001 -#define CAP_SPLIT_ACCESS 0x00000002 -#define CAP_SPLIT_RANGE 0x00000003 /* Returns -EPERM */ /* * A capability is a unique representation of security @@ -87,10 +67,6 @@ struct capability { /* Use count of resource */ unsigned long used; - - /* Device attributes, if this is a device. */ - unsigned int attr; - l4id_t irq; }; #endif /* __API_CAPABILITY_H__ */ diff --git a/include/l4/arch/arm/linker.lds.in b/include/l4/arch/arm/linker.lds.in index 836e7c2..ef4f826 100644 --- a/include/l4/arch/arm/linker.lds.in +++ b/include/l4/arch/arm/linker.lds.in @@ -25,6 +25,7 @@ _bootstack_physical = _end_bootstack - kernel_offset; * virtual address. */ ENTRY(kernel_physical) +OUTPUT_ARCH(arm) SECTIONS { diff --git a/include/l4/generic/cap-types.h b/include/l4/generic/cap-types.h index 7323378..9c40b30 100644 --- a/include/l4/generic/cap-types.h +++ b/include/l4/generic/cap-types.h @@ -40,31 +40,6 @@ {(c)->type &= ~CAP_RTYPE_MASK; \ (c)->type |= CAP_RTYPE_MASK & rtype;} -/* - * User-defined device-types - * (Kept in the user field) - */ -#define CAP_DEVTYPE_TIMER 1 -#define CAP_DEVTYPE_UART 2 -#define CAP_DEVTYPE_KEYBOARD 3 -#define CAP_DEVTYPE_MOUSE 4 -#define CAP_DEVTYPE_CLCD 5 -#define CAP_DEVTYPE_OTHER 0xF -#define CAP_DEVTYPE_MASK 0xFFFF -#define CAP_DEVNUM_MASK 0xFFFF0000 -#define CAP_DEVNUM_SHIFT 16 - -#define cap_is_devmem(c) ((c)->attr) -#define cap_set_devtype(c, devtype) \ - {(c)->attr &= ~CAP_DEVTYPE_MASK; \ - (c)->attr |= CAP_DEVTYPE_MASK & devtype;} -#define cap_set_devnum(c, devnum) \ - {(c)->attr &= ~CAP_DEVNUM_MASK; \ - (c)->attr |= CAP_DEVNUM_MASK & (devnum << CAP_DEVNUM_SHIFT);} -#define cap_devnum(c) \ - (((c)->attr & CAP_DEVNUM_MASK) >> CAP_DEVNUM_SHIFT) -#define cap_devtype(c) ((c)->attr & CAP_DEVTYPE_MASK) - /* * Access permissions */ diff --git a/include/l4/generic/capability.h b/include/l4/generic/capability.h index 9f9bc41..6995168 100644 --- a/include/l4/generic/capability.h +++ b/include/l4/generic/capability.h @@ -8,6 +8,7 @@ #include #include +#include /* * Some resources that capabilities possess don't @@ -21,15 +22,11 @@ struct cap_list { - int ktcb_refs; int ncaps; struct link caps; }; void capability_init(struct capability *cap); -struct capability *capability_create(void); -struct capability *boot_capability_create(void); - static inline void cap_list_init(struct cap_list *clist) { @@ -94,14 +91,13 @@ struct task_ids; /* Capability checking for quantitative capabilities */ int capability_consume(struct capability *cap, int quantity); int capability_free(struct capability *cap, int quantity); -struct capability *capability_find_by_rtype(struct ktcb *task, - unsigned int rtype); +struct capability *cap_find_by_rtype(struct ktcb *task, + unsigned int rtype); int cap_count(struct ktcb *task); struct capability *cap_list_find_by_rtype(struct cap_list *clist, unsigned int rtype); -struct capability *cap_find_by_capid(l4id_t capid, struct cap_list **clist); -/* Capability checking on system calls */ +/* Capability checking on systm calls */ int cap_map_check(struct ktcb *task, unsigned long phys, unsigned long virt, unsigned long npages, unsigned int flags); int cap_unmap_check(struct ktcb *task, unsigned long virt, diff --git a/include/l4/generic/container.h b/include/l4/generic/container.h index 48f5b9a..4ec01db 100644 --- a/include/l4/generic/container.h +++ b/include/l4/generic/container.h @@ -19,7 +19,8 @@ #define curcont (current->container) #define CONFIG_CONTAINER_NAMESIZE 64 -#define CONFIG_MAX_CAPS_USED 16 +#define CONFIG_MAX_PAGER_CAPS 20 +#define CONFIG_MAX_CONT_CAPS 5 #define CONFIG_MAX_PAGERS_USED 1 /* Container macro. No locks needed! */ @@ -33,18 +34,13 @@ struct pager { unsigned long memsize; struct cap_list cap_list; - /* - * Section markings, - * We dont care for other types of sections, - * RO will be included inside RX. - */ - unsigned long rw_sections_start; - unsigned long rw_sections_end; - unsigned long rx_sections_start; - unsigned long rx_sections_end; + /* Program header markings of pager's elf */ + unsigned long rw_pheader_start; + unsigned long rw_pheader_end; + unsigned long rx_pheader_start; + unsigned long rx_pheader_end; }; - struct container { l4id_t cid; /* Unique container id */ int npagers; /* # of pagers */ @@ -82,15 +78,11 @@ struct pager_info { unsigned long start_address; unsigned long stack_address; - /* - * Section markings, - * We dont care for other types of sections, - * RO will be included inside RX. - */ - unsigned long rw_sections_start; - unsigned long rw_sections_end; - unsigned long rx_sections_start; - unsigned long rx_sections_end; + /* Program header markings of pager's elf */ + unsigned long rw_pheader_start; + unsigned long rw_pheader_end; + unsigned long rx_pheader_start; + unsigned long rx_pheader_end; /* Number of capabilities defined */ int ncaps; @@ -106,7 +98,7 @@ struct pager_info { * One or more virtmem caps, * Zero or more umutex caps, */ - struct cap_info caps[CONFIG_MAX_CAPS_USED]; + struct cap_info caps[CONFIG_MAX_PAGER_CAPS]; }; /* @@ -116,6 +108,8 @@ struct pager_info { struct container_info { char name[CONFIG_CONTAINER_NAMESIZE]; int npagers; + int ncaps; + struct cap_info caps[CONFIG_MAX_CONT_CAPS]; struct pager_info pager[CONFIG_MAX_PAGERS_USED]; }; @@ -128,8 +122,10 @@ struct container *container_create(void); int container_init_pagers(struct kernel_resources *kres); +struct container *container_alloc_init(void); int init_containers(struct kernel_resources *kres); struct container *container_find(struct kernel_resources *kres, l4id_t cid); +struct ktcb *container_find_tcb(struct container *c, l4id_t tid); #endif /* __CONTAINER_H__ */ diff --git a/include/l4/generic/idle.h b/include/l4/generic/idle.h new file mode 100644 index 0000000..206592e --- /dev/null +++ b/include/l4/generic/idle.h @@ -0,0 +1,8 @@ +#ifndef __IDLE_H__ +#define __IDLE_H__ + +void setup_idle_task(void); +void containers_setup_idle(void); + + +#endif diff --git a/include/l4/generic/platform.h b/include/l4/generic/platform.h index 51b00c7..3160451 100644 --- a/include/l4/generic/platform.h +++ b/include/l4/generic/platform.h @@ -26,8 +26,25 @@ void platform_irq_disable(int irq); void print_early(char *str); void printhex8(unsigned int); -int platform_setup_device_caps(struct kernel_resources *kres); - void platform_test_cpucycles(void); +enum mem_type { + MEM_TYPE_RAM = 0, + MEM_TYPE_DEV = 1, +}; + +struct platform_mem_range { + unsigned long start; + unsigned long end; + unsigned int type; +}; + +struct platform_mem_regions { + int nregions; + struct platform_mem_range mem_range[]; +}; + +/* Kernel uses this to initialize physmem capabilities */ +extern struct platform_mem_regions platform_mem_regions; + #endif /* __PLATFORM_H__ */ diff --git a/include/l4/generic/resource.h b/include/l4/generic/resource.h index ed23958..f9b2779 100644 --- a/include/l4/generic/resource.h +++ b/include/l4/generic/resource.h @@ -9,6 +9,7 @@ /* Number of containers defined at compile-time */ #include +#include #include #include #include @@ -21,11 +22,6 @@ struct boot_resources { int nspaces; int npmds; int nmutex; - - /* Kernel resource usage */ - int nkpmds; - int nkpgds; - int nkcaps; }; /* List of containers */ @@ -80,9 +76,6 @@ struct kernel_resources { struct cap_list devmem_used; struct cap_list devmem_free; - /* All other caps that belong to the kernel */ - struct cap_list non_memory_caps; - struct mem_cache *pgd_cache; struct mem_cache *pmd_cache; struct mem_cache *ktcb_cache; @@ -98,31 +91,25 @@ struct kernel_resources { /* Global page tables on split page tables */ pgd_global_table_t *pgd_global; #endif + struct address_space init_space; }; extern struct kernel_resources kernel_resources; -void free_pgd(void *addr); -void free_pmd(void *addr); -void free_space(void *addr, struct ktcb *task); -void free_ktcb(void *addr, struct ktcb *task); -void free_capability(void *addr); -void free_container(void *addr); -void free_user_mutex(void *addr); +void pgd_free(void *addr); +void pmd_cap_free(void *addr, struct cap_list *clist); +void space_cap_free(void *addr, struct cap_list *clist); +void ktcb_cap_free(void *addr, struct cap_list *clist); +void mutex_cap_free(void *addr); -pgd_table_t *alloc_pgd(void); -pmd_table_t *alloc_pmd(void); -struct address_space *alloc_space(void); -struct ktcb *alloc_ktcb(void); -struct ktcb *alloc_ktcb_use_capability(struct capability *cap); -struct capability *boot_alloc_capability(void); -struct capability *alloc_capability(void); -struct container *alloc_container(void); -struct mutex_queue *alloc_user_mutex(void); -int free_boot_memory(struct kernel_resources *kres); +pgd_table_t *pgd_alloc(void); +pmd_table_t *pmd_cap_alloc(struct cap_list *clist); +struct address_space *space_cap_alloc(struct cap_list *clist); +struct ktcb *ktcb_cap_alloc(struct cap_list *clist); +struct mutex_queue *mutex_cap_alloc(void); int init_system_resources(struct kernel_resources *kres); -void setup_idle_caps(); /*TODO: Delete this when done with it */ +void setup_idle_caps(struct kernel_resources *kres); #endif /* __RESOURCES_H__ */ diff --git a/include/l4/generic/scheduler.h b/include/l4/generic/scheduler.h index b1e1de4..29b2926 100644 --- a/include/l4/generic/scheduler.h +++ b/include/l4/generic/scheduler.h @@ -63,17 +63,13 @@ enum sched_flags { /* Contains per-container scheduling structures */ struct scheduler { unsigned int flags; - unsigned int task_select_ctr; + unsigned int task_select_counter; struct runqueue sched_rq[SCHED_RQ_TOTAL]; /* Regular runqueues */ struct runqueue *rq_runnable; struct runqueue *rq_expired; - /* Real-time runqueues */ - struct runqueue *rq_rt_runnable; - struct runqueue *rq_rt_expired; - struct ktcb *idle_task; /* Total priority of all tasks in container */ diff --git a/include/l4/generic/space.h b/include/l4/generic/space.h index 1ef4281..884f159 100644 --- a/include/l4/generic/space.h +++ b/include/l4/generic/space.h @@ -40,7 +40,7 @@ struct address_space { l4id_t spid; struct link list; - struct mutex lock; + struct spinlock lock; pgd_table_t *pgd; /* Capabilities shared by threads in same space */ @@ -50,13 +50,12 @@ struct address_space { struct address_space_list { struct link list; - struct mutex lock; + struct spinlock lock; int count; }; struct address_space *address_space_create(struct address_space *orig); -void address_space_delete(struct address_space *space, - struct ktcb *task_accounted); +void address_space_delete(struct address_space *space, struct cap_list *clist); void address_space_attach(struct ktcb *tcb, struct address_space *space); struct address_space *address_space_find(l4id_t spid); void address_space_add(struct address_space *space); diff --git a/include/l4/generic/tcb.h b/include/l4/generic/tcb.h index d187757..7b315b8 100644 --- a/include/l4/generic/tcb.h +++ b/include/l4/generic/tcb.h @@ -70,6 +70,12 @@ struct task_ids { struct container; +#define tcb_pagerid(tcb) ((tcb)->pager->tid) + +#define space_is_pager(tcb) \ + ((tcb)->space->spid == (tcb)->pager->space->spid) +#define thread_is_pager(tcb) ((tcb)->pager == (tcb)) + struct ktcb { /* User context */ task_context_t context; @@ -91,9 +97,6 @@ struct ktcb { /* CPU affinity */ int affinity; - /* Other related threads */ - l4id_t pagerid; - /* Flags to indicate various task status */ unsigned int flags; @@ -133,10 +136,10 @@ struct ktcb { /* Container */ struct container *container; - struct pager *pager; - /* Capability lists */ - struct cap_list cap_list; /* Own private capabilities */ + /* Other related threads */ + struct ktcb *pager; + int nchild; /* Fields for ipc rendezvous */ struct waitqueue_head wqh_recv; diff --git a/include/l4/glue/arm/init.h b/include/l4/glue/arm/init.h index 1aa1a30..ce3e0d5 100644 --- a/include/l4/glue/arm/init.h +++ b/include/l4/glue/arm/init.h @@ -12,15 +12,14 @@ void switch_to_user(struct ktcb *inittask); void timer_start(void); -extern struct address_space init_space; void init_kernel_mappings(void); void start_virtual_memory(void); void finalize_virtual_memory(void); void init_finalize(void); +void secondary_idle_task_init(void); void remove_section_mapping(unsigned long vaddr); void vectors_init(void); -void setup_idle_caps(void); -void setup_idle_task(void); + #endif /* __ARM_GLUE_INIT_H__ */ diff --git a/include/l4/glue/arm/mapping.h b/include/l4/glue/arm/mapping.h index 1142406..3826857 100644 --- a/include/l4/glue/arm/mapping.h +++ b/include/l4/glue/arm/mapping.h @@ -17,19 +17,27 @@ unsigned int space_flags_to_ptflags(unsigned int flags); -void add_mapping_pgd(unsigned long paddr, unsigned long vaddr, - unsigned int size, unsigned int flags, - pgd_table_t *pgd); +struct address_space; +struct cap_list; +int add_mapping_use_cap(unsigned long paddr, unsigned long vaddr, + unsigned int size, unsigned int flags, + struct address_space *space, + struct cap_list *clist); -void add_mapping(unsigned long paddr, unsigned long vaddr, +int add_mapping_space(unsigned long paddr, unsigned long vaddr, + unsigned int size, unsigned int flags, + struct address_space *space); + +int add_mapping(unsigned long paddr, unsigned long vaddr, unsigned int size, unsigned int flags); void add_boot_mapping(unsigned long paddr, unsigned long vaddr, unsigned int size, unsigned int flags); int remove_mapping(unsigned long vaddr); -int remove_mapping_pgd(pgd_table_t *pgd, unsigned long vaddr); -void remove_mapping_pgd_all_user(pgd_table_t *pgd); +int remove_mapping_space(struct address_space *space, unsigned long vaddr); +void remove_mapping_pgd_all_user(struct address_space *space, + struct cap_list *clist); int check_mapping_pgd(unsigned long vaddr, unsigned long size, unsigned int flags, pgd_table_t *pgd); @@ -40,7 +48,7 @@ int check_mapping(unsigned long vaddr, unsigned long size, void copy_pgd_kern_all(pgd_table_t *); struct address_space; -int delete_page_tables(struct address_space *space); +int delete_page_tables(struct address_space *space, struct cap_list *clist); int copy_user_tables(struct address_space *new, struct address_space *orig); void remap_as_pages(void *vstart, void *vend); @@ -62,14 +70,14 @@ unsigned long virt_to_phys_by_pgd(pgd_table_t *pgd, unsigned long vaddr); void arch_prepare_pte(u32 paddr, u32 vaddr, unsigned int flags, pte_t *ptep); -void arch_write_pte(pte_t *ptep, pte_t pte, u32 vaddr); +void arch_write_pte(pte_t *ptep, pte_t pte, u32 vaddr, u32 asid); -void arch_prepare_write_pte(u32 paddr, u32 vaddr, +void arch_prepare_write_pte(struct address_space *space, u32 paddr, u32 vaddr, unsigned int flags, pte_t *ptep); pmd_t *arch_pick_pmd(pgd_table_t *pgd, unsigned long vaddr); -void arch_write_pmd(pmd_t *pmd_entry, u32 pmd_phys, u32 vaddr); +void arch_write_pmd(pmd_t *pmd_entry, u32 pmd_phys, u32 vaddr, u32 asid); int arch_check_pte_access_perms(pte_t pte, unsigned int flags); diff --git a/include/l4/glue/arm/smp.h b/include/l4/glue/arm/smp.h index 686c7ca..19df82e 100644 --- a/include/l4/glue/arm/smp.h +++ b/include/l4/glue/arm/smp.h @@ -22,7 +22,7 @@ struct cpuinfo { extern struct cpuinfo cpuinfo; -#if defined(CONFIG_SMP) +#if defined(CONFIG_SMP_) void smp_attach(void); void smp_start_cores(void); diff --git a/include/l4/lib/spinlock.h b/include/l4/lib/spinlock.h index 46b2df9..afe8023 100644 --- a/include/l4/lib/spinlock.h +++ b/include/l4/lib/spinlock.h @@ -30,7 +30,7 @@ static inline void spin_lock_init(struct spinlock *s) static inline void spin_lock(struct spinlock *s) { preempt_disable(); /* This must disable local preempt */ -#if defined(CONFIG_SMP) +#if defined(CONFIG_SMP_) #if defined (CONFIG_DEBUG_SPINLOCKS) spin_lock_record_check(s); @@ -41,7 +41,7 @@ static inline void spin_lock(struct spinlock *s) static inline void spin_unlock(struct spinlock *s) { -#if defined(CONFIG_SMP) +#if defined(CONFIG_SMP_) #if defined (CONFIG_DEBUG_SPINLOCKS) spin_unlock_delete_check(s); @@ -60,7 +60,7 @@ static inline void spin_lock_irq(struct spinlock *s, unsigned long *state) { irq_local_disable_save(state); -#if defined(CONFIG_SMP) +#if defined(CONFIG_SMP_) #if defined (CONFIG_DEBUG_SPINLOCKS) spin_lock_record_check(s); #endif @@ -72,7 +72,7 @@ static inline void spin_lock_irq(struct spinlock *s, static inline void spin_unlock_irq(struct spinlock *s, unsigned long state) { -#if defined(CONFIG_SMP) +#if defined(CONFIG_SMP_) #if defined (CONFIG_DEBUG_SPINLOCKS) spin_unlock_delete_check(s); diff --git a/include/l4/macros.h b/include/l4/macros.h index 7d908f3..a064e33 100644 --- a/include/l4/macros.h +++ b/include/l4/macros.h @@ -48,6 +48,7 @@ #define SZ_1K 1024 #define SZ_2K 2048 #define SZ_4K 0x1000 +#define SZ_8K 0x2000 #define SZ_16K 0x4000 #define SZ_32K 0x8000 #define SZ_64K 0x10000 @@ -63,14 +64,14 @@ /* Per-cpu variables */ -#if defined CONFIG_SMP +#if defined CONFIG_SMP_ #define DECLARE_PERCPU(type, name) \ type name[CONFIG_NCPU] #define per_cpu(val) (val)[smp_get_cpuid()] #define per_cpu_byid(val, cpu) (val)[(cpu)] -#else /* Not CONFIG_SMP */ +#else /* Not CONFIG_SMP_ */ #define DECLARE_PERCPU(type, name) \ type name @@ -78,7 +79,7 @@ type name #define per_cpu(val) (val) #define per_cpu_byid(val, cpu) val -#endif /* End of Not CONFIG_SMP */ +#endif /* End of Not CONFIG_SMP_ */ #ifndef __ASSEMBLY__ #include /* offsetof macro, defined in the `standard' way. */ diff --git a/include/l4/platform/eb/irq.h b/include/l4/platform/eb/irq.h index e4889c6..72fe9f6 100644 --- a/include/l4/platform/eb/irq.h +++ b/include/l4/platform/eb/irq.h @@ -14,6 +14,10 @@ #define IRQS_MAX 96 #endif +/* Range of IRQ numbers used by this platform */ +#define IRQ_RANGE_START 0 +#define IRQ_RANGE_END IRQS_MAX + /* * Interrupt Distribution: * 0-31: Used as SI provided by distributed interrupt controller @@ -44,9 +48,14 @@ #define EB_IRQ_AACI (EB_GIC_IRQ_OFFSET + 19) /* Advanced Audio codec */ #define EB_IRQ_KMI0 (EB_GIC_IRQ_OFFSET + 20) /* Keyboard */ #define EB_IRQ_KMI1 (EB_GIC_IRQ_OFFSET + 21) /* Mouse */ -#define EB_IRQ_LCD (EB_GIC_IRQ_OFFSET + 20) /* Character LCD */ #define EB_IRQ_DMAC (EB_GIC_IRQ_OFFSET + 20) /* DMA Controller */ +/* + * We have 3 IRQs for CLCD + * 23 - clcd display + * 30, 31 for touch screen pen interrupt + */ +#define EB_IRQ_CLCD (EB_GIC_IRQ_OFFSET + 23) /* Interrupt Sources to ARM 11 MPCore or EB+A9 MPCore GIC */ #define MPCORE_GIC_IRQ_AACI (EB_GIC_IRQ_OFFSET + 0) @@ -59,6 +68,7 @@ #define MPCORE_GIC_IRQ_KMI0 (EB_GIC_IRQ_OFFSET + 7) #define MPCORE_GIC_IRQ_KMI1 (EB_GIC_IRQ_OFFSET + 8) #define MPCORE_GIC_IRQ_ETH (EB_GIC_IRQ_OFFSET + 9) +#define MPCORE_GIC_IRQ_CLCD (EB_GIC_IRQ_OFFSET + 23) /* Interrupt from GIC1 on Base board */ #define MPCORE_GIC_IRQ_EB_GIC1 (EB_GIC_IRQ_OFFSET + 10) @@ -69,13 +79,15 @@ #if defined (CONFIG_CPU_ARM11MPCORE) || defined (CONFIG_CPU_CORTEXA9) #define IRQ_TIMER0 MPCORE_GIC_IRQ_TIMER01 #define IRQ_TIMER1 MPCORE_GIC_IRQ_TIMER23 -#define IRQ_KEYBOARD0 MPCORE_GIC_IRQ_TIMER01 +#define IRQ_KEYBOARD0 MPCORE_GIC_IRQ_KMI0 #define IRQ_MOUSE0 MPCORE_GIC_IRQ_KMI1 +#define IRQ_CLCD0 MPCORE_GIC_IRQ_CLCD #else #define IRQ_TIMER0 EB_IRQ_TIMER01 #define IRQ_TIMER1 EB_IRQ_TIMER23 #define IRQ_KEYBOARD0 EB_IRQ_KMI0 #define IRQ_MOUSE0 EB_IRQ_KMI1 +#define IRQ_CLCD0 EB_IRQ_CLCD #endif #endif /* __PLATFORM_IRQ_H__ */ diff --git a/include/l4/platform/eb/offsets.h b/include/l4/platform/eb/offsets.h index e8be210..254d768 100644 --- a/include/l4/platform/eb/offsets.h +++ b/include/l4/platform/eb/offsets.h @@ -14,6 +14,7 @@ #include /* Device offsets in physical memory */ +#define PLATFORM_CLCD0_BASE 0x10020000 /* CLCD0 */ #define PLATFORM_GIC1_BASE 0x10040000 /* GIC 1 */ #define PLATFORM_GIC2_BASE 0x10050000 /* GIC 2 */ #define PLATFORM_GIC3_BASE 0x10060000 /* GIC 3 */ diff --git a/include/l4/platform/pb926/irq.h b/include/l4/platform/pb926/irq.h index 061542c..bdfff80 100644 --- a/include/l4/platform/pb926/irq.h +++ b/include/l4/platform/pb926/irq.h @@ -52,4 +52,8 @@ #define IRQ_KEYBOARD0 (SIC_IRQ_KEYBOARD + SIC_CHIP_OFFSET) #define IRQ_MOUSE0 (SIC_IRQ_MOUSE + SIC_CHIP_OFFSET) +/* Range of IRQ numbers used by this platform */ +#define IRQ_RANGE_START 0 +#define IRQ_RANGE_END 63 + #endif /* __PLATFORM_IRQ_H__ */ diff --git a/include/l4/platform/pb926/offsets.h b/include/l4/platform/pb926/offsets.h index a41e0ae..face775 100644 --- a/include/l4/platform/pb926/offsets.h +++ b/include/l4/platform/pb926/offsets.h @@ -31,7 +31,7 @@ #define PLATFORM_UART2_BASE 0x101F3000 /* Console port (UART2) */ #define PLATFORM_UART3_BASE 0x10009000 /* Console port (UART3) */ #define PLATFORM_CLCD0_BASE 0x10120000 /* Color LCD */ - +#define PLATFORM_SYSREGS_SIZE 0x01000000 /* Portion allocated for sysregs */ /* * Device offsets in virtual memory. They offset to some virtual * device base address. Each page on this virtual base is consecutively diff --git a/include/l4/platform/pba9/irq.h b/include/l4/platform/pba9/irq.h index 9a9dda5..6be0189 100644 --- a/include/l4/platform/pba9/irq.h +++ b/include/l4/platform/pba9/irq.h @@ -6,7 +6,6 @@ #ifndef __PLATFORM_IRQ_H__ #define __PLATFORM_IRQ_H__ - /* TODO: Not sure about this, need to check */ #define IRQ_CHIPS_MAX 1 #define IRQS_MAX 96 @@ -32,5 +31,9 @@ * 75- 81: Test chip interrupts */ +/* Range of IRQ numbers used by this platform */ +#define IRQ_RANGE_START 0 +#define IRQ_RANGE_END 95 + #endif /* __PLATFORM_IRQ_H__ */ diff --git a/include/l4/platform/pba9/offsets.h b/include/l4/platform/pba9/offsets.h index fb9dda5..05f59e4 100644 --- a/include/l4/platform/pba9/offsets.h +++ b/include/l4/platform/pba9/offsets.h @@ -13,6 +13,9 @@ #include +#define PLATFORM_DEVICES1_START 0x40000000 +#define PLATFORM_DEVICES1_END 0x60000000 + /* * Device offsets in physical memory * Naming of devices done starting with 0 subscript, diff --git a/include/l4/platform/pba9/platform.h b/include/l4/platform/pba9/platform.h index 3b027d4..42703b3 100644 --- a/include/l4/platform/pba9/platform.h +++ b/include/l4/platform/pba9/platform.h @@ -9,4 +9,13 @@ #include +#define CLCD_SELECT_BOARD 0 +#define CLCD_SELECT_TILE 1 + +void sri_set_mux(int offset); +void clcd_clock_write(u32 freq, int clcd_select); +u32 clcd_clock_read(int clcd_select); +void clcd_init(void); +void kmi_init(void); + #endif /* __PBA9_PLATFORM_H__ */ diff --git a/include/l4/platform/realview/offsets.h b/include/l4/platform/realview/offsets.h index 27204fe..2bf0109 100644 --- a/include/l4/platform/realview/offsets.h +++ b/include/l4/platform/realview/offsets.h @@ -15,6 +15,9 @@ #define PLATFORM_PHYS_MEM_START 0x00000000 /* inclusive */ #define PLATFORM_PHYS_MEM_END 0x10000000 /* 256 MB, exclusive */ +#define PLATFORM_DEVICES_START 0x10000000 /* System registers */ +#define PLATFORM_DEVICES_END 0x20000000 /* System regs end */ + /* * Device offsets in physical memory * Naming of devices done starting with 0 subscript, diff --git a/loader/SConscript b/loader/SConscript index 16a5acc..dc18f2b 100644 --- a/loader/SConscript +++ b/loader/SConscript @@ -1,79 +1,7 @@ -# -*- mode: python; coding: utf-8; -*- -# -# Codezero -- a microkernel for embedded systems. -# -# Copyright © 2009 B Labs Ltd - -import os, sys, shelve -from os.path import join Import('env') -### -### FIXME: We are missing the dependency on containers.elf -### -PROJRELROOT = '../../' - -from config.projpaths import * -from scripts.loader.generate_loader_asm import * -from config.lib import * - -# Function to determine the LMA for 'final.elf' -def find_loader_load_address(target, source, env): - # Start/end addresses of various physical memory regions defined - array_start = [] - array_end = [] - - with open(join(PROJROOT, CONFIG_H), 'r')as file: - for line in file: - begin = line.rfind(" ") - end = len(line) - if re.search("(PHYS)([0-9]){1,4}(_START)", line): - array_start.append(int(line[begin : end], 16)) - elif re.search("(PHYS)([0-9]){1,4}(_END)", line): - array_end.append(int(line[begin : end], 16)) - array_start.sort() - array_end.sort() - - # Size of physical memory hole we need for 'final.elf' say 16MB - mem_needed = 0x1000000 - # Default LMA = 32MB, if we have no container - loadaddr = 0x1000000 - for index,end in enumerate(array_end): - loadaddr = end - if (index+1) >= len(array_start): - # Reached end of start_array - break - else: - start = array_start[index+1] - if start-end >= mem_needed: - break - - # Create target file - with open(source[1].path, 'r') as input: - buffer = input.read() - #print 'Load address for final.elf: ' + str(conv_hex(loadaddr)) - with open(target[0].path, 'w+') as output: - output.write(buffer % str(conv_hex(loadaddr))) - -def ksym_to_loader(target, source, env): - generate_ksym_to_loader(target[0].path, source[0].path) - -def gen_loader_images_S(target, source, env): - generate_image_S(target[0].path, source) - -loader_ksyms = Command(join(PROJROOT, 'loader/ksyms.S'), join(BUILDDIR, 'kernel.elf'), ksym_to_loader) -loader_image_S = Command(join(PROJROOT, 'loader/images.S'), [join(BUILDDIR, 'kernel.elf'), join(BUILDDIR, 'conts/containers.elf')], \ - gen_loader_images_S) -lma_lds = Command(join(BUILDDIR, 'loader/linker.lds'), \ - [join(BUILDDIR, 'kernel.elf'), \ - join(PROJROOT, 'loader/linker.lds.in')], find_loader_load_address) src = Glob('*.[cS]') objs = env.Object(src) -Depends(src, lma_lds) -Depends(src, loader_ksyms) -Depends(src, loader_image_S) -Depends(objs, join(BUILDDIR, 'conts/containers.elf')) -Depends(objs, join(BUILDDIR, 'kernel.elf')) -Return('objs', 'loader_image_S') +Return('objs') diff --git a/loader/SConstruct b/loader/SConstruct new file mode 100644 index 0000000..4731585 --- /dev/null +++ b/loader/SConstruct @@ -0,0 +1,135 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- a microkernel for embedded systems. +# +# P.S : This file is called from PROJROOT directory, +# so all paths are given relative to PROJROOT. +# +# Copyright © 2009 B Labs Ltd + +import os, sys +from os.path import join + +sys.path.append(os.getcwd()) + +from scripts.config.configuration import * +from scripts.config.projpaths import * +from scripts.loader.generate_loader_asm import * + +config = configuration_retrieve() +arch = config.arch +gcc_arch_flag = config.gcc_arch_flag +symbols = config.all + +variant = 'baremetal' + +# Locally important paths are here +LIBC_PATH = 'loader/libs/c' +LIBC_LIBPATH = join(BUILDDIR, LIBC_PATH) +LIBC_INCPATH = ['#' + join(LIBC_PATH, 'include'), + '#' + join(LIBC_PATH, 'include/arch/' + arch)] + +LIBELF_PATH = 'loader/libs/elf' +LIBELF_LIBPATH = join(BUILDDIR, LIBELF_PATH) +LIBELF_INCPATH = '#' + join(LIBELF_PATH, 'include') + +env = Environment(CC = config.toolchain_kernel + 'gcc', + AR = config.toolchain_kernel + 'ar', + RANLIB = config.toolchain_kernel + 'ranlib', + # 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', '-march=' + gcc_arch_flag], + LINKFLAGS = ['-nostdlib', '-T' + join(BUILDDIR, 'loader/linker.lds'), + '-u_start'], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', + ENV = {'PATH' : os.environ['PATH']}, + LIBS = ['gcc', 'elf', 'libdev-baremetal', 'c-baremetal', 'gcc'], + LIBPATH = [LIBDEV_BAREMETAL_LIBPATH, LIBELF_LIBPATH, LIBC_LIBPATH], + CPPPATH = [KERNEL_HEADERS, LIBDEV_INCLUDE, LIBC_INCPATH, LIBELF_INCPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h \ + -include l4/types.h -D__KERNEL__') + +libdev_builddir = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-' + variant) +objs = SConscript(join(LIBDEV_RELDIR, 'SConscript'), duplicate = 0, + exports = { 'env' : env, 'type' : variant, 'build_dir' : libdev_builddir}, + variant_dir = join(BUILDDIR, LIBDEV_RELDIR)) + +objs += SConscript('loader/libs/c/SConscript', duplicate = 0, + exports = { 'env' : env, 'type' : variant}, + variant_dir = join(BUILDDIR, 'loader/libs/c')) + +objs += SConscript('loader/libs/elf/SConscript', duplicate = 0, + exports = { 'env' : env }, + variant_dir = join(BUILDDIR, 'loader/libs/elf')) + +objs += SConscript('loader/SConscript', duplicate = 0, + exports = { 'env' : env }, + variant_dir = join(BUILDDIR, 'loader')) + +# +# Find the LMA for FINAL_ELF +# Let size of physical memory hole needed for FINAL_ELF be 16MB +# and default LMA = 32MB, +# FIXME: default LMA = get_kernel_end_address() +# +def find_loader_load_address(target, source, env): + # Start/end addresses of various physical memory regions defined + array_start = [] + array_end = [] + + for sym, val in symbols: + if re.search("(PHYS)([0-9]){1,4}(_START)", sym): + array_start.append(int(val, 0)) + elif re.search("(PHYS)([0-9]){1,4}(_END)", sym): + array_end.append(int(val, 0)) + array_start.sort() + array_end.sort() + + mem_needed = 0x1000000 + loadaddr = 0x1000000 + for index, end in enumerate(array_end): + loadaddr = end + if (index+1) >= len(array_start): + # Reached end of start_array + break + else: + start = array_start[index+1] + if start - end >= mem_needed: + break + + # Create target file + with open(source[1].path, 'r') as input: + buffer = input.read() + #print '\nLoad address for FINAL_ELF: ' + str(conv_hex(loadaddr)) + with open(target[0].path, 'w+') as output: + output.write(buffer % str(loadaddr)) + return None + +def ksym_to_loader(target, source, env): + generate_ksym_to_loader(target[0].path, source[0].path) + +def gen_loader_images_S(target, source, env): + generate_image_S(target[0].path, source) + +# Builders +loader_image_S = Builder(action = gen_loader_images_S) +env.Append(BUILDERS = {'IMAGE_S' : loader_image_S}) +env.IMAGE_S(join(BUILDDIR, 'loader/images.S'), [KERNEL_ELF, join(BUILDDIR, 'conts/containers.elf')]) +objs += env.Object(join(BUILDDIR, 'loader/images.S')) + +loader_ksyms = Builder(action = ksym_to_loader) +env.Append(BUILDERS = {'LOADER_KSYSM' : loader_ksyms}) +env.LOADER_KSYSM(join(BUILDDIR, 'loader/ksyms.S'), [KERNEL_ELF]) +objs += env.Object(join(BUILDDIR, 'loader/ksyms.S')) + +lma_lds = Builder(action = find_loader_load_address) +env.Append(BUILDERS = {'LMA_LDS' : lma_lds}) +env.LMA_LDS(join(BUILDDIR, 'loader/linker.lds'), [KERNEL_ELF, 'loader/linker.lds.in']) + +final_elf = env.Program(FINAL_ELF, objs) + +Depends(objs,join(BUILDDIR, 'conts/containers.elf')) +Depends(objs,join(BUILDDIR, 'kernel.elf')) +Depends(final_elf, join(BUILDDIR, 'loader/linker.lds')) diff --git a/loader/libs/c/SConscript b/loader/libs/c/SConscript index 552c41d..e335ad9 100644 --- a/loader/libs/c/SConscript +++ b/loader/libs/c/SConscript @@ -9,13 +9,16 @@ from os.path import join # Get global paths PROJRELROOT = '../../../' - sys.path.append(PROJRELROOT) -from config.configuration import * -from config.projpaths import * +from scripts.config.configuration import * +from scripts.config.projpaths import * -Import('env', 'arch', 'platform', 'type') +config = configuration_retrieve() +arch = config.arch +platform = config.platform + +Import('env', 'type') variant = type e = env.Clone() diff --git a/loader/libs/c/SConstruct b/loader/libs/c/SConstruct index 79caa14..e640378 100644 --- a/loader/libs/c/SConstruct +++ b/loader/libs/c/SConstruct @@ -5,7 +5,7 @@ # Copyright © 2009 B Labs Ltd import os, sys, shelve -from configure import * +from scripts.config.config_invoke import * variant = "baremetal" config = configuration_retrieve() diff --git a/loader/libs/c/src/sys-baremetal/arch-arm/sys_fputc.c b/loader/libs/c/src/sys-baremetal/arch-arm/sys_fputc.c index 04d3c9a..a8a9d18 100644 --- a/loader/libs/c/src/sys-baremetal/arch-arm/sys_fputc.c +++ b/loader/libs/c/src/sys-baremetal/arch-arm/sys_fputc.c @@ -5,7 +5,7 @@ */ #include #include -#include +#include int __fputc(int c, FILE *stream) { diff --git a/loader/libs/elf/SConstruct b/loader/libs/elf/SConstruct index e464c5f..a9b30bd 100644 --- a/loader/libs/elf/SConstruct +++ b/loader/libs/elf/SConstruct @@ -6,7 +6,7 @@ import os, sys, shelve from os.path import join -from configure import * +from scripts.config.config_invoke import * config = configuration_retrieve() arch = config.arch diff --git a/loader/libs/elf/src/elf.c b/loader/libs/elf/src/elf.c index d9c810a..4a1b5e0 100644 --- a/loader/libs/elf/src/elf.c +++ b/loader/libs/elf/src/elf.c @@ -376,16 +376,16 @@ elf_loadFile(void *elfFile, bool phys) pheader_type = elf_getProgramHeaderType(elfFile, i); // printf("Elf program header type: %p\n", pheader_type); // Comment -//printf("Copying to range from 0x%x to 0x%x of size: 0x%x\n", (unsigned int)dest, (unsigned int)dest + (unsigned int)len, (unsigned int)len); +printf("Copying to range from 0x%x to 0x%x of size: 0x%x\n", (unsigned int)dest, (unsigned int)dest + (unsigned int)len, (unsigned int)len); memcpy((void*) (uintptr_t) dest, (void*) (uintptr_t) src, len); dest += len; clrsize = elf_getProgramHeaderMemorySize(elfFile, i) - len; -// printf("Clearing memory... starting from %x, size: %x\n", (unsigned int)dest, (unsigned int)clrsize); + printf("Clearing memory... starting from %x, size: %x\n", (unsigned int)dest, (unsigned int)clrsize); memset((void*) (uintptr_t) dest, 0, clrsize); // printf("Memory cleared.\n"); } // And this one -// printf("\n"); + printf("\n"); return true; } diff --git a/loader/linker.lds.in b/loader/linker.lds.in index 49d21f2..723ed51 100644 --- a/loader/linker.lds.in +++ b/loader/linker.lds.in @@ -10,6 +10,7 @@ ENTRY(_start) SECTIONS { . = load_address; + _start_loader = .; .text : { *(.text.head) *(.text) } .rodata : { *(.rodata) } .rodata1 : { *(.rodata1) } @@ -26,4 +27,5 @@ SECTIONS } .got : { *(.got) *(.got.plt) } .bss : { *(.bss) } + _end_loader = .; } diff --git a/loader/main.c b/loader/main.c index c1eb0e4..7d21a4c 100644 --- a/loader/main.c +++ b/loader/main.c @@ -10,6 +10,8 @@ extern char _start_kernel[]; extern char _end_kernel[]; extern char _start_containers[]; extern char _end_containers[]; +extern char _start_loader[]; +extern char _end_loader[]; /* This is a kernel symbol exported to loader's linker script from kernel build */ extern char bkpt_phys_to_virt[]; @@ -105,11 +107,16 @@ void arch_start_kernel(void *entry) func(0); } +#define __NAME__ "ELF Loader" int main(void) { unsigned long *kernel_entry; - printf("ELF Loader: Started.\n"); + printf("%s: Loader image size: %luKB, placed " + "at physical 0x%lx - 0x%lx\n", + __NAME__, (unsigned long)(_end_loader - _start_loader) / 1024, + (unsigned long)_start_loader, + (unsigned long)_end_loader); printf("Loading the kernel...\n"); load_elf_image(&kernel_entry, (void *)_start_kernel); diff --git a/scripts/baremetal/baremetal_add_container.py b/scripts/baremetal/baremetal_add_container.py index 0beb599..6b79b3b 100755 --- a/scripts/baremetal/baremetal_add_container.py +++ b/scripts/baremetal/baremetal_add_container.py @@ -14,7 +14,7 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELR from optparse import OptionParser from os.path import join from shutil import copytree -from config.projpaths import * +from scripts.config.projpaths import * def parse_cmdline_options(): usage = "usage: %prog [options] arg" diff --git a/scripts/baremetal/baremetal_generator.py b/scripts/baremetal/baremetal_generator.py index 4887e96..8993a39 100755 --- a/scripts/baremetal/baremetal_generator.py +++ b/scripts/baremetal/baremetal_generator.py @@ -15,9 +15,9 @@ sys.path.append(os.path.abspath("../")) SCRIPTROOT = os.path.abspath(os.path.dirname(__file__)) -from config.projpaths import * -from config.configuration import * -from config.lib import * +from scripts.config.projpaths import * +from scripts.config.configuration import * +from scripts.config.lib import * class BaremetalContGenerator: def __init__(self): @@ -71,12 +71,14 @@ class BaremetalContGenerator: fout.write('\t' + conv_hex(cont.pager_lma) + '\n') fout.write(pager_vma_header) fout.write('\t' + conv_hex(cont.pager_vma) + '\n') - for ireg in range(cont.virt_regions): + for ireg in range(cont.caplist["PAGER"].virt_regions): fout.write(pager_virtmem_header % ireg) - fout.write('\t' + cont.virtmem["START"][ireg] + ' - ' + cont.virtmem["END"][ireg] + '\n') - for ireg in range(cont.phys_regions): + fout.write('\t' + cont.caplist["PAGER"].virtmem["START"][ireg] + \ + ' - ' + cont.caplist["PAGER"].virtmem["END"][ireg] + '\n') + for ireg in range(cont.caplist["PAGER"].phys_regions): fout.write(pager_physmem_header % ireg) - fout.write('\t' + cont.physmem["START"][ireg] + ' - ' + cont.physmem["END"][ireg] + '\n') + fout.write('\t' + cont.caplist["PAGER"].physmem["START"][ireg] + \ + ' - ' + cont.caplist["PAGER"].physmem["END"][ireg] + '\n') def copy_baremetal_build_readme(self, config, cont): with open(self.build_readme_in) as fin: @@ -98,7 +100,10 @@ class BaremetalContGenerator: fout.write(str % (cont.name, cont.id, cont.id)) def create_baremetal_sources(self, config, cont): - self.create_baremetal_srctree(config, cont) + if cont.duplicate == 1: + self.create_baremetal_srctree(config, cont) + else: + os.makedirs(join(self.CONT_SRC_DIR, 'include')) self.copy_baremetal_build_readme(config, cont) self.copy_baremetal_build_desc(config, cont) self.generate_linker_script(config, cont) @@ -112,8 +117,13 @@ class BaremetalContGenerator: def check_create_baremetal_sources(self, config): for cont in config.containers: if cont.type == "baremetal": + # Determine container directory name. - self.CONT_SRC_DIR = join(self.BAREMETAL_SRC_BASEDIR, cont.name.lower()) + if cont.duplicate == 0: + self.CONT_SRC_DIR = join(join(BUILDDIR, 'cont' + str(cont.id)), cont.name) + else: + self.CONT_SRC_DIR = join(self.BAREMETAL_SRC_BASEDIR, cont.name) + 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,7 +131,7 @@ class BaremetalContGenerator: self.container_h_out = join(join(self.CONT_SRC_DIR, 'include'), \ self.container_h_name) - if not os.path.exists(join(self.BAREMETAL_SRC_BASEDIR, cont.name)): + if not os.path.exists(self.CONT_SRC_DIR): self.create_baremetal_sources(config, cont) else: # Don't create new sources but update configuration @@ -137,6 +147,20 @@ class BaremetalContGenerator: def baremetal_container_generate(self, config): self.check_create_baremetal_sources(config) + def baremetal_del_dynamic_files(self, cont): + self.CONT_SRC_DIR = join(join(BUILDDIR, 'cont' + str(cont.id)), cont.name) + 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'), self.linker_lds_name) + self.container_h_out = join(join(self.CONT_SRC_DIR, 'include'), self.container_h_name) + + if cont.duplicate == 0: + os.system('rm -f ' + self.build_readme_out) + os.system('rm -f ' + self.build_desc_out) + os.system('rm -f ' + self.linker_lds_out) + os.system('rm -f ' + self.container_h_out) + return None + if __name__ == "__main__": config = configuration_retrieve() config.config_print() diff --git a/scripts/baremetal/files/linker.lds.in b/scripts/baremetal/files/linker.lds.in index ce91000..12343df 100644 --- a/scripts/baremetal/files/linker.lds.in +++ b/scripts/baremetal/files/linker.lds.in @@ -8,23 +8,48 @@ vma_start = %s; lma_start = %s; offset = vma_start - lma_start; +OUTPUT_ARCH(arm) ENTRY(_start) +PHDRS +{ + rx PT_LOAD; + rw PT_LOAD; +} + SECTIONS { . = vma_start; - .text : AT (ADDR(.text) - offset) { *(.text.head) *(.text) } - .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } - .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } + + /* Put all RX, RO sections here */ + .text : AT (ADDR(.text) - offset) + { + *(.text.head) *(.text) + } : rx = 0x90909090 + + .rodata : AT (ADDR(.rodata) - offset) + { + *(.rodata) + } : rx = 0x90909090 + + .rodata1 : AT (ADDR(.rodata1) - offset) + { + *(.rodata1) + } : rx = 0x90909090 . = ALIGN(4K); - .data : AT (ADDR(.data) - offset) { *(.data) } + + /* Put all RW sections here */ + .data : AT (ADDR(.data) - offset) + { + *(.data) + } : rw .bss : AT (ADDR(.bss) - offset) { *(.bss) . += 0x1000; . = ALIGN(8); __stack = .; - } + } : rw __end = .; } diff --git a/scripts/cml/generate_container_cml.py b/scripts/cml/generate_container_cml.py index 1252737..9a9777b 100755 --- a/scripts/cml/generate_container_cml.py +++ b/scripts/cml/generate_container_cml.py @@ -10,12 +10,11 @@ from os.path import join from string import Template PROJRELROOT = '../../' - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) sys.path.append(os.path.abspath("../")) -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.config.configuration import * containers_menu = \ ''' @@ -41,44 +40,6 @@ def add_container_constraint(cid): cml_string = containers_constraint % (cid, cid) return cml_string -device_suppress_rule = \ -''' -when CONT${CONTID}_CAP_DEVICE_${DEVNAME}_USE == y suppress -''' - -device_suppress_sym = \ -'''\tcont${CONTID}_cap_device_${DEVNAME_LOWER} -''' - -devices = ['UART1', 'UART2', 'UART3', 'TIMER1', - 'KEYBOARD0', 'MOUSE0', 'CLCD0'] - -# -# When a symbol is used by a single container, sometimes it is -# necessary to hide it in other containers. This cannot be -# achieved statically but rather needs to be autogenerated -# depending on the number of containers used. -# -def generate_container_suppress_rules(ncont): - finalstr = '' - # For each device on the platform - for devname in devices: - # Generate rule for each container - for cont in range(ncont): - # Create string templates - rule_templ = Template(device_suppress_rule) - sym_templ = Template(device_suppress_sym) - - rulestr = rule_templ.substitute(CONTID = cont, DEVNAME = devname) - symstr = '' - # Fill for each container - for other_cont in range(ncont): - if other_cont == cont: - continue - symstr += sym_templ.substitute(CONTID = other_cont, DEVNAME_LOWER = devname.lower()) - finalstr += rulestr + symstr + "\n" - return finalstr - def generate_container_cml(arch, ncont): print "Autogenerating new rule file" fbody = "" @@ -96,9 +57,6 @@ def generate_container_cml(arch, ncont): fbody += default_number_of_containers - # Generate inter-container suppression rules for as many rules as containers - fbody += generate_container_suppress_rules(ncont) - # Write each container's rules for cont in range(ncont): with open(CML2_CONT_DEFFILE, "rU") as contdefs: diff --git a/config/__init__.py b/scripts/config/__init__.py similarity index 100% rename from config/__init__.py rename to scripts/config/__init__.py diff --git a/scripts/config/caps.py b/scripts/config/caps.py new file mode 100644 index 0000000..30b33b2 --- /dev/null +++ b/scripts/config/caps.py @@ -0,0 +1,210 @@ +#! /usr/bin/env python2.6 +# -*- mode: python; coding: utf-8; -*- +import os, sys, shelve, shutil, re +from projpaths import * +from lib import * +from caps import * +from string import Template + +cap_strings = { 'ipc' : \ +''' +\t\t\t[${idx}] = { +\t\t\t\t.target = ${cid}, +\t\t\t\t.type = CAP_TYPE_IPC | ${target_rtype}, +\t\t\t\t.access = CAP_IPC_SEND | CAP_IPC_RECV +\t\t\t\t | CAP_IPC_FULL | CAP_IPC_SHORT +\t\t\t\t | CAP_IPC_EXTENDED | CAP_CHANGEABLE +\t\t\t\t | CAP_REPLICABLE | CAP_TRANSFERABLE, +\t\t\t\t.start = 0, .end = 0, .size = 0, +\t\t\t}, +''' +, 'tctrl' : \ +''' +\t\t\t[${idx}] = { +\t\t\t\t.target = ${cid}, +\t\t\t\t.type = CAP_TYPE_TCTRL | CAP_RTYPE_CONTAINER, +\t\t\t\t.access = CAP_TCTRL_CREATE | CAP_TCTRL_DESTROY +\t\t\t\t | CAP_TCTRL_SUSPEND | CAP_TCTRL_RUN +\t\t\t\t | CAP_TCTRL_RECYCLE | CAP_TCTRL_WAIT +\t\t\t\t | CAP_CHANGEABLE | CAP_REPLICABLE +\t\t\t\t | CAP_TRANSFERABLE, +\t\t\t\t.start = 0, .end = 0, .size = 0, +\t\t\t}, +''' +, 'irqctrl' : \ +''' +\t\t\t[${idx}] = { +\t\t\t\t.target = ${cid}, +\t\t\t\t.type = CAP_TYPE_IRQCTRL | CAP_RTYPE_CONTAINER, +\t\t\t\t.access = CAP_IRQCTRL_REGISTER | CAP_IRQCTRL_WAIT +\t\t\t\t | CAP_CHANGEABLE | CAP_REPLICABLE +\t\t\t\t | CAP_TRANSFERABLE, +\t\t\t\t.start = IRQ_RANGE_START, .end = IRQ_RANGE_END, .size = 0, +\t\t\t}, +''' +, 'exregs' : \ +''' +\t\t\t[${idx}] = { +\t\t\t\t.target = ${cid}, +\t\t\t\t.type = CAP_TYPE_EXREGS | CAP_RTYPE_CONTAINER, +\t\t\t\t.access = CAP_EXREGS_RW_PAGER +\t\t\t\t | CAP_EXREGS_RW_UTCB | CAP_EXREGS_RW_SP +\t\t\t\t | CAP_EXREGS_RW_PC | CAP_EXREGS_RW_REGS +\t\t\t\t | CAP_CHANGEABLE | CAP_REPLICABLE | CAP_TRANSFERABLE, +\t\t\t\t.start = 0, .end = 0, .size = 0, +\t\t\t}, +''' +, 'threadpool' : \ +''' +\t\t\t[${idx}] = { +\t\t\t\t.target = ${cid}, +\t\t\t\t.type = CAP_TYPE_QUANTITY +\t\t\t\t | CAP_RTYPE_THREADPOOL, +\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, +\t\t\t\t.start = 0, .end = 0, +\t\t\t\t.size = ${size}, +\t\t\t}, +''' +, 'spacepool' : \ +''' +\t\t\t[${idx}] = { +\t\t\t\t.target = ${cid}, +\t\t\t\t.type = CAP_TYPE_QUANTITY | CAP_RTYPE_SPACEPOOL, +\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, +\t\t\t\t.start = 0, .end = 0, +\t\t\t\t.size = ${size}, +\t\t\t}, +''' +, 'mutexpool' : \ +''' +\t\t\t[${idx}] = { +\t\t\t\t.target = ${cid}, +\t\t\t\t.type = CAP_TYPE_QUANTITY | CAP_RTYPE_MUTEXPOOL, +\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, +\t\t\t\t.start = 0, .end = 0, +\t\t\t\t.size = ${size}, +\t\t\t}, +''' +, 'mappool' : \ +''' +\t\t\t[${idx}] = { +\t\t\t\t/* For pmd accounting */ +\t\t\t\t.target = ${cid}, +\t\t\t\t.type = CAP_TYPE_QUANTITY | CAP_RTYPE_MAPPOOL, +\t\t\t\t.access = CAP_CHANGEABLE | CAP_TRANSFERABLE, +\t\t\t\t.start = 0, .end = 0, +\t\t\t\t/* Function of mem regions, nthreads etc. */ +\t\t\t\t.size = ${size}, +\t\t\t}, +''' +} + +# +# These are carefully crafted functions, touch with care. +# +def prepare_custom_capability(cont, caplist, param, val): + if 'TYPE' in param: + capkey, captype, rest = param.split('_', 2) + capkey = capkey.lower() + captype = captype.lower() + caplist.caps[capkey] = cap_strings[captype] + elif 'TARGET' in param: + target_parts = param.split('_', 2) + if len(target_parts) == 2: + capkey = target_parts[0].lower() + templ = Template(caplist.caps[capkey]) + caplist.caps[capkey] = templ.safe_substitute(cid = val) + elif len(target_parts) == 3: + capkey = target_parts[0].lower() + ttype = target_parts[2] + templ = Template(caplist.caps[capkey]) + + # On current container, provide correct rtype and current containerid. + # Else we leave container id to user-supplied value + if ttype == 'CURRENT_CONTAINER': + caplist.caps[capkey] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_CONTAINER', + cid = cont.id) + elif ttype == 'CURRENT_PAGER_SPACE': + caplist.caps[capkey] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_SPACE', + cid = cont.id) + elif ttype == 'OTHER_CONTAINER': + caplist.caps[capkey] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_CONTAINER') + elif ttype == 'OTHER_PAGER': + caplist.caps[capkey] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_THREAD') + else: # Ignore custom_use symbol + return + # print capkey + # print caplist.caps[capkey] + +def prepare_typed_capability(cont, caplist, param, val): + captype, params = param.split('_', 1) + captype = captype.lower() + + # USE makes us assign the initial cap string with blank fields + if 'USE' in params: + caplist.caps[captype] = cap_strings[captype] + + # Prepare string template from capability type + templ = Template(caplist.caps[captype]) + + # If it is a pool, tctrl, exregs, irqctrl, amend current container id as default + if captype[-len('pool'):] == 'pool' or \ + captype[-len('irqctrl'):] == 'irqctrl': + caplist.caps[captype] = templ.safe_substitute(cid = cont.id) + + # Fill in the blank size field + elif 'SIZE' in params: + # Get reference to capability string template + templ = Template(caplist.caps[captype]) + caplist.caps[captype] = templ.safe_substitute(size = val) + + # Fill in capability target type and target id fields + elif 'TARGET' in params: + # Get reference to capability string template + templ = Template(caplist.caps[captype]) + + # Two types of strings are expected here: TARGET or TARGET_TARGETTYPE + # If TARGET, the corresponding value is in val + target_parts = params.split('_', 1) + + # Target type + if len(target_parts) == 2: + ttype = target_parts[1] + + # On current container, provide correct rtype and current containerid. + # Else we leave container id to user-supplied value + if ttype == 'CURRENT_CONTAINER': + caplist.caps[captype] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_CONTAINER', + cid = cont.id) + elif ttype == 'CURRENT_PAGER_SPACE': + caplist.caps[captype] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_SPACE', + cid = cont.id) + elif ttype == 'OTHER_CONTAINER': + caplist.caps[captype] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_CONTAINER') + elif ttype == 'OTHER_PAGER': + caplist.caps[captype] = templ.safe_substitute(target_rtype = 'CAP_RTYPE_THREAD') + + # Get target value supplied by user in val + else: + caplist.caps[captype] = templ.safe_substitute(cid = val) + + # print captype + # print caplist.caps[captype] + +def prepare_capability(cont, cap_owner, param, val): + caplist = cont.caplist[cap_owner] # Passing either pager or container caplist. + if 'CUSTOM' in param: + prepare_custom_capability(cont, caplist, param, val) + else: + prepare_typed_capability(cont, caplist, param, val) + # Add default capabilities exchange registers and thread control + +def create_default_capabilities(cont): + caplist = cont.caplist["PAGER"] + for captype in ['tctrl', 'exregs']: + # Set the string + caplist.caps[captype] = cap_strings[captype] + # Replace substitues with values + templ = Template(caplist.caps[captype]) + caplist.caps[captype] = templ.safe_substitute(cid = cont.id) + diff --git a/scripts/config/cml/arm.ruleset b/scripts/config/cml/arm.ruleset new file mode 100644 index 0000000..0dee5ee --- /dev/null +++ b/scripts/config/cml/arm.ruleset @@ -0,0 +1,290 @@ +start main_menu + +############# +# SYMBOLS # +############# +symbols + +ARCH_ARM 'ARM' text +ARM architecture. + +Support for armv5, armv6, armv7 available. +. + +arm_cpu_type 'ARM Processor Type' text +Select the type of arm cpu/processor to be used. +. + +CPU_ARM1136 'ARM1136 - Experimental' text +ARMv6/ARM11 series based uniprocessor cpu. +. + +CPU_ARM11MPCORE 'ARM11 MPCore - Experimental' text +ARMv6/ARM11 series based multiprocessor cpu. +. + +CPU_ARM926 'ARM926EJ-S' text +ARMv5/ARM9 series based uniprocessor cpu. +. + +CPU_CORTEXA8 'ARM Cortex-A8' text +ARMv7/Cortex series based uniprocessor cpu. +. + +CPU_CORTEXA9 'ARM Cortex-A9' text +ARMv7/Cortex series based multiprocessor cpu. +. + +arm_platform_type 'ARM Platform Type' text +Select the type of arm platform to be used. +. + +PLATFORM_PB926 'PB926-Versatile Platform' text +ARMv5 based versatile-pb platform. +. + +PLATFORM_EB 'Realview EB Platform' text +ARMv6 based realview-eb platform. +Supported cpus: + ARM1136 + ARM11MPCORE + Cortex-A8(Supported by qemu only) + Cortex-A9(Supported by RTSM/Models only) +. + +PLATFORM_BEAGLE 'OMAP3530/Cortex-A8 Beagle Board' text +Texas Instrument's OMAP3530 based beagle board(rev C) platform. + +OMAP3530 is derived from armv7 based cortex-a8 cpu. +. + +PLATFORM_PBA9 'Realview Express Cortex-A9' text +ARMv7 based realview-versatile-express quad-core platform. +. + +main_menu 'Codezero Microkernel Configurator' + +arm_menu 'ARM Architecture Configuration' text +Configure arm architecture. +. + +processor_properties 'Generic Processor Properties' text +Generic processor properties common to all types of processors supported. +. + +kernel_generic_options 'Generic Kernel Properties' text +Generic kernel properties. +. + +toolchain_menu 'Toolchain Prefix' text +Toolchains used for compiling kernel and user space. +. + +containers_menu 'Container Setup' text +Select the number of containers and configure each container. +. + +arch_type 'Main architecture' text +Select the type of architecture. +. + +SMP_ 'Enable SMP Support' text +Enable/Disable smp support. +. + +NCPU 'Number of SMP CPUs' text +Configure the number of cpus in case of multiprocessor cores. + +Available only when smp is enabled. +. + +DEBUG_ACCOUNTING 'Enable system operations accounting' text +Enable/Disable sytem operations accounting. + +By default operation accounting in kernel is enabled. +To enable operation accounting in userspace enable DEBUG_PERFMON_USER. +. + +DEBUG_PERFMON 'Enable performance monitoring' text +Enable/Disable system performance monitoring. +. + +DEBUG_PERFMON_USER 'Userspace access to perfmon registers' text +Enable/Disable userspace access to processor's performance registers. +Enabling this option will automatically disable in-kernel measurements. +. + +DEBUG_SPINLOCKS 'Debug spinlocks' text +Enable/Disable spinlock debugging by the kernel. +Eg: detect recursive locks, double unlocks etc. +. + +SCHED_TICKS 'Scheduler ticks per second' text +Configure the number of ticks generated per second +by the timer source of scheduler. +. + +ICACHE_DISABLE 'Disable the L1 instruction cache' text +Enable/Disable usage of L1 instruction cache by the processor. +. + +DCACHE_DISABLE 'Disable the L1 data cache' text +Enable/Disable usage of L1 data cache by the processor. +. + +PREEMPT_DISABLE 'Disable Kernel Preemption' text +Enable/Disable premption of kernel. +. + +TOOLCHAIN_USERSPACE 'Toolchain prefix for userspace' text +Toolchain used for compiling userspace libraries and container. + +Userspace is tested for an up-to-date codesourcery NONE-EABI-LINUX toolchain. + +To specify custom toolchain, use: + path/to/toolchain/toolchain-prefix +. + +TOOLCHAIN_KERNEL 'Toolchain prefix for kernel' text +Toolchain used for compiling kernel and loader. + +Kernel is tested for an up-to-date codesourcery EABI toolchain. +To specify custom toolchain, use: + path/to/toolchain/toolchain-prefix +. + +CAPABILITIES 'Enable capability checking' text +Enable/Disable capability checking by kernel. +. + +############# +# CHOICES # +############# + +choices arch_type + ARCH_ARM + default ARCH_ARM + +choices arm_platform_type + PLATFORM_PB926 + PLATFORM_PBA9 + PLATFORM_BEAGLE + PLATFORM_EB + default PLATFORM_PBA9 + +choices arm_cpu_type + CPU_ARM926 + CPU_ARM1136 + CPU_ARM11MPCORE + CPU_CORTEXA8 + CPU_CORTEXA9 + default CPU_CORTEXA9 + +############# +# MENUS # +############# + +menu arm_menu + arm_platform_type + arm_cpu_type + +menu processor_properties + SMP_ + NCPU% + ICACHE_DISABLE + DCACHE_DISABLE + +menu kernel_generic_options + PREEMPT_DISABLE + DEBUG_ACCOUNTING + DEBUG_PERFMON + DEBUG_PERFMON_USER + DEBUG_SPINLOCKS + SCHED_TICKS% + +menu toolchain_menu + TOOLCHAIN_USERSPACE$ + TOOLCHAIN_KERNEL$ + +menu main_menu + arch_type + arm_menu + processor_properties + kernel_generic_options + toolchain_menu + containers_menu + +############# +# RULES # +############# +#Capability/Container rules: +default CAPABILITIES from y +default DEBUG_ACCOUNTING from n +default DEBUG_PERFMON from n +default DEBUG_PERFMON_USER from n +default DEBUG_SPINLOCKS from n +default SCHED_TICKS from 1000 +derive DEBUG_PERFMON_KERNEL from DEBUG_PERFMON == y and DEBUG_PERFMON_USER != y + +#Subarch Derivation Rules +derive SUBARCH_V5 from CPU_ARM926 + +derive SUBARCH_V6 from CPU_ARM1136 or + CPU_ARM11MPCORE + +derive SUBARCH_V7 from CPU_CORTEXA8 or + CPU_CORTEXA9 + +#CPU rules: +unless PLATFORM_PB926 suppress CPU_ARM926 +unless PLATFORM_EB suppress CPU_ARM11MPCORE +unless PLATFORM_EB suppress CPU_ARM1136 +unless PLATFORM_PBA9 or PLATFORM_EB suppress CPU_CORTEXA9 +unless PLATFORM_BEAGLE or PLATFORM_EB suppress CPU_CORTEXA8 + +#SMP support rules +unless CPU_CORTEXA9 or CPU_ARM11MPCORE suppress SMP_ +unless CPU_CORTEXA9 or CPU_ARM11MPCORE suppress NCPU +unless SMP_ suppress NCPU +unless DEBUG_ACCOUNTING suppress DEBUG_PERFMON + DEBUG_PERFMON_USER +unless DEBUG_PERFMON suppress DEBUG_PERFMON_USER + +# NOTE: Unlike menus, choices dont take { sym } model of visibility +# dependencies. Instead, a choice symbol is declared in a menu, and +# suppress statement is used to make sym visible, instead of a +# { sym } model under the choices. (See manual for { sym } usage). + +unless ARCH_ARM suppress arm_menu + +#SMP default value +default SMP_ from y +default NCPU from 4 +default ICACHE_DISABLE from n +default DCACHE_DISABLE from n +default PREEMPT_DISABLE from n + +require NCPU <= 4 + +# Derive Ram base address depending on platform selected +# we use this in setting containers physical regions +# default values +# FIXME: Find a better solution +derive RAM_BASE_PLAT from PLATFORM_BEAGLE ? 0x80000000 : 0x00000000 + +# Toolchains: +default TOOLCHAIN_USERSPACE from 'arm-none-linux-gnueabi-' +default TOOLCHAIN_KERNEL from 'arm-none-eabi-' + +prefix CONFIG_ + +# Checklist for correct CML2 +# 1) Have you defined a prompt for each menu, choice_type? +# 2) Have you defined a default for each symbol? +# 3) Have you put 'symbols' keyword before each symbol, menu and choice? + + +# Important note on derived symbols +# DO NOT place any declaration for derived symbols like normal symbols, +# otherwise the derivation will be silently ignored, and you will be left +# wondering why. diff --git a/scripts/config/cml/container_ruleset.template b/scripts/config/cml/container_ruleset.template new file mode 100644 index 0000000..9f87c8a --- /dev/null +++ b/scripts/config/cml/container_ruleset.template @@ -0,0 +1,1079 @@ +symbols + +CONT%(cn)d_TYPE_LINUX 'Linux Container' text +Virtualized linux container. +. + +CONT%(cn)d_TYPE_BAREMETAL 'Baremetal Container' text +Baremetal containers. +These containers contain various demos describing the usage of various system calls, accessing devices etc. +. + +CONT%(cn)d_TYPE_POSIX 'POSIX Container' text +Posix container displaying a real posix system running over the hypervisor. +. + +CONT%(cn)d_OPT_NAME 'Project Name' text +Project name for container%(cn)d in this build. +. + +CONTAINERS 'Number of containers' text +Number of containers to be configured. + +The maximum number of containers that can be configured is set to 4. +. + + +CONT%(cn)d_PAGER_PHYSMEM_REGIONS 'Container %(cn)d Number of Physical Regions' text +Number of physical memory regions alloted to container%(cn)d. + +A maximum of 4 physical memory regions can be alloted to each container. +. + +CONT%(cn)d_PAGER_PHYS0_START 'Container %(cn)d Pager Physical Region 0 Start Address' text +Start address of physical memory region 0 for container%(cn)d. +. + +CONT%(cn)d_PAGER_PHYS0_END 'Container %(cn)d Pager Physical Region 0 End Address' text +End address of physical memory region 0 for container%(cn)d. +. + +CONT%(cn)d_PAGER_PHYS1_START 'Container %(cn)d Pager Physical Region 1 Start Address' text +Start address of physical memory region 1 for container%(cn)d. +. + +CONT%(cn)d_PAGER_PHYS1_END 'Container %(cn)d Pager Physical Region 1 End Address' text +End address of physical memory region 1 for container%(cn)d. +. + +CONT%(cn)d_PAGER_PHYS2_START 'Container %(cn)d Pager Physical Region 2 Start Address' text +Start address of physical memory region 2 for container%(cn)d. +. + +CONT%(cn)d_PAGER_PHYS2_END 'Container %(cn)d Pager Physical Region 2 End Address' text +End address of physical memory region 2 for container%(cn)d. +. + +CONT%(cn)d_PAGER_PHYS3_START 'Container %(cn)d Pager Physical Region 3 Start Address' text +Start address of physical memory region 3 for container%(cn)d. +. + +CONT%(cn)d_PAGER_PHYS3_END 'Container %(cn)d Pager Physical Region 3 End Address' text +End address of physical memory region 3 for container%(cn)d. +. + +symbols +CONT%(cn)d_PAGER_VIRTMEM_REGIONS 'Container %(cn)d Number of Virtual Regions' text +Number of virtual memory regions alloted to container%(cn)d. + +A maximum of 6 virtual memory regions can be alloted to each container. +. + +CONT%(cn)d_PAGER_VIRT0_START 'Container %(cn)d Pager Virtual Region 0 Start Address' text +Start address of virtual memory region 0 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT0_END 'Container %(cn)d Pager Virtual Region 0 End Address' text +End address of virtual memory region 0 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT1_START 'Container %(cn)d Pager Virtual Region 1 Start Address' text +Start address of virtual memory region 1 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT1_END 'Container %(cn)d Pager Virtual Region 1 End Address' text +End address of virtual memory region 1 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT2_START 'Container %(cn)d Pager Virtual Region 2 Start Address' text +Start address of virtual memory region 2 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT2_END 'Container %(cn)d Pager Virtual Region 2 End Address' text +End address of virtual memory region 2 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT3_START 'Container %(cn)d Pager Virtual Region 3 Start Address' text +Start address of virtual memory region 3 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT3_END 'Container %(cn)d Pager Virtual Region 3 End Address' text +End address of virtual memory region 3 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT4_START 'Container %(cn)d Pager Virtual Region 4 Start Address' text +Start address of virtual memory region 4 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT4_END 'Container %(cn)d Pager Virtual Region 4 End Address' text +End address of virtual memory region 4 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT5_START 'Container %(cn)d Pager Virtual Region 5 Start Address' text +Start address of virtual memory region 5 for container%(cn)d. +. + +CONT%(cn)d_PAGER_VIRT5_END 'Container %(cn)d Pager Virtual Region 5 End Address' text +End address of virtual memory region 5 for container%(cn)d. +. + +# FIXME: We dont need to pass PAGER_LMA and PAGER_VMA to config.h now +# as we are using them just to derive other symbols, in this file only +CONT%(cn)d_PAGER_LMA 'Container %(cn)d Pager LMA' text +Physical memory address for loading the pager of container%(cn)d. +. + +CONT%(cn)d_PAGER_VMA 'Container %(cn)d Pager VMA' text +Virtual memory address for loading the pager of container%(cn)d. +. + +CONT%(cn)d_PAGER_SHM_START 'Container %(cn)d Shared Mappings Region Start' text +Start of virtual memory region to be used for shared mappings for container%(cn)d. +. + +CONT%(cn)d_PAGER_SHM_END 'Container %(cn)d Shared Mappings Region End' text +End of virtual memory region to be used for shared mappings for container%(cn)d. +. + +CONT%(cn)d_PAGER_TASK_START 'Container %(cn)d Task Address Space Region Start' text +Start of virtual memory region to be used for address spaces generation +for the new tasks created in container%(cn)d. +. + +CONT%(cn)d_PAGER_TASK_END 'Container %(cn)d Task Address Space Region End' text +End of virtual memory region to be used for address spaces generation +for the new tasks created in container%(cn)d. +. + +CONT%(cn)d_PAGER_UTCB_START 'Container %(cn)d UTCB Mappings Region Start' text +Start of virtual memory region to be used for allocating utcbs of threads in container%(cn)d. +. + +CONT%(cn)d_PAGER_UTCB_END 'Container %(cn)d UTCB Mappings Region End' text +End of virtual memory region to be used for allocating utcbs of threads in container%(cn)d. +. + +CONT%(cn)d_LINUX_ZRELADDR 'Container %(cn)d Linux ZRELADDR Parameter' text +ZRELADDR parameter of linux kernel. + +This refers to the physical memory address where uncompressed linux kernel will be loaded. +This should be within the physical memory regions assigned to linux container. +. + +CONT%(cn)d_LINUX_PAGE_OFFSET 'Container %(cn)d Linux PAGE_OFFSET Parameter' text +PAGE_OFFSET parameter of linux kernel. + +This refers to the virtual memory address from where the virtual memory region +of linux kernel starts. +This should be within the virtual memory regions assigned to linux container. +. + +CONT%(cn)d_LINUX_PHYS_OFFSET 'Container %(cn)d Linux PHYS_OFFSET Parameter' text +PHYS_OFFSET parameter of linux kernel. + +This refers to the beginning address of physical memory region avaialable to linux container/kernel. +. + +CONT%(cn)d_LINUX_ROOTFS_ADDRESS 'Container %(cn)d Linux ROOTFS Address' text +Virtual memory address where root filesystem, to be used by linux kernel, will be located. + +This should be within the range of virtual memory regions assigned to linux container/kernel. +. + +default CONT%(cn)d_PAGER_LMA from CONT%(cn)d_PAGER_PHYS0_START +default CONT%(cn)d_PAGER_VMA from CONT%(cn)d_PAGER_VIRT0_START +default CONT%(cn)d_PAGER_SHM_START from CONT%(cn)d_PAGER_VIRT1_START +default CONT%(cn)d_PAGER_SHM_END from CONT%(cn)d_PAGER_VIRT1_END +default CONT%(cn)d_PAGER_TASK_START from CONT%(cn)d_PAGER_VIRT2_START +default CONT%(cn)d_PAGER_TASK_END from CONT%(cn)d_PAGER_VIRT2_END +default CONT%(cn)d_PAGER_UTCB_START from CONT%(cn)d_PAGER_VIRT3_START +default CONT%(cn)d_PAGER_UTCB_END from CONT%(cn)d_PAGER_VIRT3_END +default CONT%(cn)d_LINUX_ZRELADDR from (CONT%(cn)d_LINUX_PHYS_OFFSET + 0x8000) +default CONT%(cn)d_LINUX_PAGE_OFFSET from CONT%(cn)d_PAGER_VIRT0_START +default CONT%(cn)d_LINUX_PHYS_OFFSET from CONT%(cn)d_PAGER_PHYS0_START +default CONT%(cn)d_LINUX_ROOTFS_ADDRESS from (CONT%(cn)d_LINUX_PHYS_OFFSET + 0x500000) + +default CONT%(cn)d_PAGER_VIRTMEM_REGIONS from (CONT%(cn)d_TYPE_POSIX==y ? 4 : 1) +default CONT%(cn)d_PAGER_PHYSMEM_REGIONS from 1 + +# Define limits on virtual and physical memory regions of a _single_ container 0. Too much code! +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_PAGER_VIRT1_START CONT%(cn)d_PAGER_VIRT1_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_PAGER_VIRT2_START CONT%(cn)d_PAGER_VIRT2_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_PAGER_VIRT3_START CONT%(cn)d_PAGER_VIRT3_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_PAGER_VIRT4_START CONT%(cn)d_PAGER_VIRT4_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 2 suppress CONT%(cn)d_PAGER_VIRT5_START CONT%(cn)d_PAGER_VIRT5_END + +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 3 suppress CONT%(cn)d_PAGER_VIRT2_START CONT%(cn)d_PAGER_VIRT2_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 3 suppress CONT%(cn)d_PAGER_VIRT3_START CONT%(cn)d_PAGER_VIRT3_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 3 suppress CONT%(cn)d_PAGER_VIRT4_START CONT%(cn)d_PAGER_VIRT4_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 3 suppress CONT%(cn)d_PAGER_VIRT5_START CONT%(cn)d_PAGER_VIRT5_END + +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 4 suppress CONT%(cn)d_PAGER_VIRT3_START CONT%(cn)d_PAGER_VIRT3_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 4 suppress CONT%(cn)d_PAGER_VIRT4_START CONT%(cn)d_PAGER_VIRT4_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 4 suppress CONT%(cn)d_PAGER_VIRT5_START CONT%(cn)d_PAGER_VIRT5_END + +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 5 suppress CONT%(cn)d_PAGER_VIRT4_START CONT%(cn)d_PAGER_VIRT4_END +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 5 suppress CONT%(cn)d_PAGER_VIRT5_START CONT%(cn)d_PAGER_VIRT5_END + +when CONT%(cn)d_PAGER_VIRTMEM_REGIONS < 6 suppress CONT%(cn)d_PAGER_VIRT5_START CONT%(cn)d_PAGER_VIRT5_END + + +when CONT%(cn)d_PAGER_PHYSMEM_REGIONS < 2 suppress CONT%(cn)d_PAGER_PHYS1_START CONT%(cn)d_PAGER_PHYS1_END +when CONT%(cn)d_PAGER_PHYSMEM_REGIONS < 2 suppress CONT%(cn)d_PAGER_PHYS2_START CONT%(cn)d_PAGER_PHYS2_END +when CONT%(cn)d_PAGER_PHYSMEM_REGIONS < 2 suppress CONT%(cn)d_PAGER_PHYS3_START CONT%(cn)d_PAGER_PHYS3_END + +when CONT%(cn)d_PAGER_PHYSMEM_REGIONS < 3 suppress CONT%(cn)d_PAGER_PHYS2_START CONT%(cn)d_PAGER_PHYS2_END +when CONT%(cn)d_PAGER_PHYSMEM_REGIONS < 3 suppress CONT%(cn)d_PAGER_PHYS3_START CONT%(cn)d_PAGER_PHYS3_END + +when CONT%(cn)d_PAGER_PHYSMEM_REGIONS < 4 suppress CONT%(cn)d_PAGER_PHYS3_START CONT%(cn)d_PAGER_PHYS3_END + +# We assume kernel uses 0x0 - 0x40000 physical RAM. +# Physical Regions for containers should start after kernel. +require CONT%(cn)d_PAGER_PHYS0_START >= 0x40000 +require CONT%(cn)d_PAGER_PHYS1_START >= 0x40000 +require CONT%(cn)d_PAGER_PHYS2_START >= 0x40000 +require CONT%(cn)d_PAGER_PHYS3_START >= 0x40000 + +# TODO: We can add check for end address of physical region to be +# less than RAM SIZE, need to find out RAM SIZE? + +# Rules for Linux kernel parameters +require CONT%(cn)d_LINUX_ZRELADDR > CONT%(cn)d_LINUX_PHYS_OFFSET + 0x8000 + +# TODO: Do we want to check if PAGER_LMA/VMA lies in allocated memory regions +default CONT%(cn)d_PAGER_PHYS0_START from ((%(cn)d == 0 ? 0x100000 : (0x100000 + %(cn)d * 0x1000000)) + RAM_BASE_PLAT) +default CONT%(cn)d_PAGER_PHYS0_END from (CONT%(cn)d_PAGER_PHYS0_START + 0xD00000) +default CONT%(cn)d_PAGER_PHYS1_START from CONT%(cn)d_PAGER_PHYS0_END +default CONT%(cn)d_PAGER_PHYS1_END from (CONT%(cn)d_PAGER_PHYS1_START + 0x100000) +default CONT%(cn)d_PAGER_PHYS2_START from CONT%(cn)d_PAGER_PHYS1_END +default CONT%(cn)d_PAGER_PHYS2_END from (CONT%(cn)d_PAGER_PHYS2_START + 0x100000) +default CONT%(cn)d_PAGER_PHYS3_START from CONT%(cn)d_PAGER_PHYS2_END +default CONT%(cn)d_PAGER_PHYS3_END from (CONT%(cn)d_PAGER_PHYS3_START + 0x100000) + +default CONT%(cn)d_PAGER_VIRT0_START from (%(cn)d == 0 ? 0xa0000000 : (0xa0000000 + %(cn)d * 0x10000000)) +default CONT%(cn)d_PAGER_VIRT0_END from (CONT%(cn)d_PAGER_VIRT0_START + 0x10000000) +default CONT%(cn)d_PAGER_VIRT1_START from (%(cn)d == 0 ? 0x80000000 : (0x80000000 + %(cn)d * 0x8000000)) +default CONT%(cn)d_PAGER_VIRT1_END from (CONT%(cn)d_PAGER_VIRT1_START + 0x8000000) +default CONT%(cn)d_PAGER_VIRT2_START from (%(cn)d == 0 ? 0x40000000 : (0x40000000 + %(cn)d * 0x10000000)) +default CONT%(cn)d_PAGER_VIRT2_END from (CONT%(cn)d_PAGER_VIRT2_START + 0x10000000) +default CONT%(cn)d_PAGER_VIRT3_START from (%(cn)d == 0 ? 0xf8100000 : (0xf8100000 + %(cn)d * 0x100000)) +default CONT%(cn)d_PAGER_VIRT3_END from (CONT%(cn)d_PAGER_VIRT3_START + 0x100000) +default CONT%(cn)d_PAGER_VIRT4_START from (%(cn)d == 0 ? 0x10000000 : (0x10000000 + %(cn)d * 0x10000000)) +default CONT%(cn)d_PAGER_VIRT4_END from (CONT%(cn)d_PAGER_VIRT4_START + 0x10000000) +default CONT%(cn)d_PAGER_VIRT5_START from 0xe0000000 +default CONT%(cn)d_PAGER_VIRT5_END from 0xf0000000 + +default CONT%(cn)d_OPT_NAME from +(CONT%(cn)d_TYPE_LINUX==y) ? "linux%(cn)d" : +((CONT%(cn)d_TYPE_POSIX==y) ? "posix%(cn)d" : +((CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD==y) ? "hello_world%(cn)d" : +((CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO==y) ? "thread_demo%(cn)d" : +((CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE==y) ? "test_suite%(cn)d" : +((CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE==y) ? "uart_service%(cn)d" : +((CONT%(cn)d_BAREMETAL_PROJ_KMI_SERVICE==y) ? "kmi_service%(cn)d" : +((CONT%(cn)d_BAREMETAL_PROJ_MUTEX_DEMO==y) ? "mutex_demo%(cn)d" : +((CONT%(cn)d_BAREMETAL_PROJ_IPC_DEMO==y) ? "ipc_demo%(cn)d" : +((CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE==y) ? "timer_service%(cn)d" : "empty%(cn)d"))))))))) + +when CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_pager_linker_params +unless CONT%(cn)d_TYPE_POSIX==y suppress cont%(cn)d_posix_pager_params +unless CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_linux_pager_params +unless CONT%(cn)d_TYPE_BAREMETAL==y suppress cont%(cn)d_baremetal_params + +# derive symbols, for cinfo.c, depending on the type of container selected +derive CONT%(cn)d_PAGER_LOAD_ADDR from (CONT%(cn)d_TYPE_LINUX==y) ? CONT%(cn)d_LINUX_PHYS_OFFSET : CONT%(cn)d_PAGER_LMA +derive CONT%(cn)d_PAGER_VIRT_ADDR from (CONT%(cn)d_TYPE_LINUX==y) ? CONT%(cn)d_LINUX_PAGE_OFFSET : CONT%(cn)d_PAGER_VMA +derive CONT%(cn)d_START_PC_ADDR from (CONT%(cn)d_TYPE_LINUX != y) ? CONT%(cn)d_PAGER_VMA : (CONT%(cn)d_LINUX_PAGE_OFFSET + CONT%(cn)d_LINUX_ZRELADDR - CONT%(cn)d_LINUX_PHYS_OFFSET) + +symbols +cont%(cn)d_menu 'Container %(cn)d Parameters' text +List of parameters associated with container%(cn)d. + +All parameters are provided with default values, appropriate for defualt configurations of +various containers. +. + +cont%(cn)d_physmem_list 'Container %(cn)d Pager Physical Memory Regions (Capabilities)' text +List of physical memory regions to be used by container%(cn)d. +. + +cont%(cn)d_virtmem_list 'Container %(cn)d Pager Virtual Memory Regions (Capabilities)' text +List of virtual memory regions to be used by container%(cn)d. +. + +container%(cn)d_type 'Container %(cn)d Type' text +Container type. +. + +#cont%(cn)d_pager_params 'Container %(cn)d Pager Parameters' text +#Configuration parameters associated with container%(cn)d pager. +#. + +container%(cn)d_options 'Container %(cn)d Options' text +Configuration parameters associated with container%(cn)d. +. + +cont%(cn)d_linux_pager_params 'Container %(cn)d Linux Pager Parameters' text +Configuration parameters associated with pager of container%(cn)d. +. + +cont%(cn)d_pager_linker_params 'Container %(cn)d Pager Linker Parameters' text +Pager's linker parameters. These allow shifting the pager image in physical and virtual +address spaces. + +For correct functioning, the LMA parameter should match with one of the +defined physical memory capabilities. + +The VMA parameter should match with one of the defined virtual memory +capabilities. +. + +cont%(cn)d_posix_pager_params 'Container %(cn)d POSIX Pager Parameters' text +Configuration parameters associated with pager of container%(cn)d. +. + +cont%(cn)d_baremetal_params 'Baremetal Project Type' text +Select the type of sources to include in this baremetal container +. + +CONT%(cn)d_BAREMETAL_PROJ_EMPTY 'Empty Project' text +Empty container. + +This includes the bare minimum sources required to build a container. +. + +CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD 'Hello World' text +Hello world container + +This includes a main.c with a hello world message printed on the console. +. + +CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO 'Thread Library Demo' text +Baremetal container demonstrating usage of libl4 thread library and associated API. +. + +CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE 'Microkernel Tests' text +Baremetal container demonstrating some API usage cases and tests. +. + +CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE 'UART Service' text +Baremetal container demonstrating usage of uart devices. +. + +CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE 'Timer Service' text +Baremetal container displaying usage of timer devices. +. + +CONT%(cn)d_BAREMETAL_PROJ_KMI_SERVICE 'Keyboard Mouse Service' text +Baremetal container displaying usage of mouse and keyboard devices. +. + +CONT%(cn)d_BAREMETAL_PROJ_MUTEX_DEMO 'Mutex Demo' text +Baremetal container displaying usage of mutexes. +. + +CONT%(cn)d_BAREMETAL_PROJ_IPC_DEMO 'IPC Demo' text +Baremetal container displaying usage of ipc calls. +. + + +choices cont%(cn)d_baremetal_params + CONT%(cn)d_BAREMETAL_PROJ_EMPTY + CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD + CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO + CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE + CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE + CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE + CONT%(cn)d_BAREMETAL_PROJ_KMI_SERVICE + CONT%(cn)d_BAREMETAL_PROJ_MUTEX_DEMO + CONT%(cn)d_BAREMETAL_PROJ_IPC_DEMO + default CONT%(cn)d_BAREMETAL_PROJ_EMPTY + +menu cont%(cn)d_pager_linker_params + CONT%(cn)d_PAGER_LMA@ + CONT%(cn)d_PAGER_VMA@ + +menu cont%(cn)d_posix_pager_params + CONT%(cn)d_PAGER_SHM_START@ + CONT%(cn)d_PAGER_SHM_END@ + CONT%(cn)d_PAGER_TASK_START@ + CONT%(cn)d_PAGER_TASK_END@ + CONT%(cn)d_PAGER_UTCB_START@ + CONT%(cn)d_PAGER_UTCB_END@ + +menu cont%(cn)d_linux_pager_params + CONT%(cn)d_LINUX_PHYS_OFFSET@ + CONT%(cn)d_LINUX_ZRELADDR@ + CONT%(cn)d_LINUX_ROOTFS_ADDRESS@ + CONT%(cn)d_LINUX_PAGE_OFFSET@ + +menu cont%(cn)d_virtmem_list + CONT%(cn)d_PAGER_VIRTMEM_REGIONS% + CONT%(cn)d_PAGER_VIRT0_START@ + CONT%(cn)d_PAGER_VIRT0_END@ + CONT%(cn)d_PAGER_VIRT1_START@ + CONT%(cn)d_PAGER_VIRT1_END@ + CONT%(cn)d_PAGER_VIRT2_START@ + CONT%(cn)d_PAGER_VIRT2_END@ + CONT%(cn)d_PAGER_VIRT3_START@ + CONT%(cn)d_PAGER_VIRT3_END@ + CONT%(cn)d_PAGER_VIRT4_START@ + CONT%(cn)d_PAGER_VIRT4_END@ + CONT%(cn)d_PAGER_VIRT5_START@ + CONT%(cn)d_PAGER_VIRT5_END@ + +menu cont%(cn)d_physmem_list + CONT%(cn)d_PAGER_PHYSMEM_REGIONS% + CONT%(cn)d_PAGER_PHYS0_START@ + CONT%(cn)d_PAGER_PHYS0_END@ + CONT%(cn)d_PAGER_PHYS1_START@ + CONT%(cn)d_PAGER_PHYS1_END@ + CONT%(cn)d_PAGER_PHYS2_START@ + CONT%(cn)d_PAGER_PHYS2_END@ + CONT%(cn)d_PAGER_PHYS3_START@ + CONT%(cn)d_PAGER_PHYS3_END@ + +# +# Settings for Custom Capabilities +# +choices cont%(cn)d_pager_cap_custom0_type + CONT%(cn)d_PAGER_CAP_CUSTOM0_IPC_TYPE + default CONT%(cn)d_PAGER_CAP_CUSTOM0_IPC_TYPE +choices cont%(cn)d_pager_cap_custom1_type + CONT%(cn)d_PAGER_CAP_CUSTOM1_IPC_TYPE + default CONT%(cn)d_PAGER_CAP_CUSTOM1_IPC_TYPE +choices cont%(cn)d_pager_cap_custom2_type + CONT%(cn)d_PAGER_CAP_CUSTOM2_IPC_TYPE + default CONT%(cn)d_PAGER_CAP_CUSTOM2_IPC_TYPE +choices cont%(cn)d_pager_cap_custom3_type + CONT%(cn)d_PAGER_CAP_CUSTOM3_IPC_TYPE + default CONT%(cn)d_PAGER_CAP_CUSTOM3_IPC_TYPE + +default CONT%(cn)d_PAGER_CAP_CUSTOM0_USE from n +default CONT%(cn)d_PAGER_CAP_CUSTOM1_USE from n +default CONT%(cn)d_PAGER_CAP_CUSTOM2_USE from n +default CONT%(cn)d_PAGER_CAP_CUSTOM3_USE from n + +menu cont%(cn)d_pager_cap_custom0 + CONT%(cn)d_PAGER_CAP_CUSTOM0_USE + cont%(cn)d_pager_cap_custom0_type + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET% + +menu cont%(cn)d_pager_cap_custom1 + CONT%(cn)d_PAGER_CAP_CUSTOM1_USE + cont%(cn)d_pager_cap_custom1_type + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET% + +menu cont%(cn)d_pager_cap_custom2 + CONT%(cn)d_PAGER_CAP_CUSTOM2_USE + cont%(cn)d_pager_cap_custom2_type + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET% + +menu cont%(cn)d_pager_cap_custom3 + CONT%(cn)d_PAGER_CAP_CUSTOM3_USE + cont%(cn)d_pager_cap_custom3_type + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET% + +choicegroup CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_PAGER + default CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER from y + +choicegroup CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_PAGER + default CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER from y + +choicegroup CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_PAGER + default CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER from y + +choicegroup CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_PAGER + default CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER from y + +when CONT%(cn)d_PAGER_CAP_CUSTOM0_USE == n + suppress cont%(cn)d_pager_cap_custom0_type + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM1_USE == n + suppress cont%(cn)d_pager_cap_custom1_type + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM2_USE == n + suppress cont%(cn)d_pager_cap_custom2_type + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM3_USE == n + suppress cont%(cn)d_pager_cap_custom3_type + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM0_IPC_TYPE == n + suppress CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER or + CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE + suppress CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM1_IPC_TYPE == n + suppress CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER or + CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE + suppress CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM2_IPC_TYPE == n + suppress CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER or + CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE + suppress CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM3_IPC_TYPE == n + suppress CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET + +when CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER or + CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE + suppress CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET + +default CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET from 0 +default CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET from 0 +default CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET from 0 +default CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET from 0 + +# Symbols for Custom Capabilities +symbols + +# +# CUSTOM CAPABILITY 0 +# +CONT%(cn)d_PAGER_CAP_CUSTOM0_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +cont%(cn)d_pager_cap_custom0_type 'Capability Operation Type' text +Specify the type of custom capability. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM0_IPC_TYPE 'IPC Capability' text +Capability associated with inter-container and intra-container ipc properties. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_CONTAINER 'Capability targets any thread in this Container' text +Capability targets current container, meaning that the system call associated with this +capability can be used against any address space and thread present inside this container. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_CURRENT_PAGER_SPACE 'Capability targets any thread in pager`s address space' text +Capability targets the pager's address space, meaning that the system call associated +with this capability can be used for any thread inside the address space of pager. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_CONTAINER 'Capability Targets Another Container' text +Capability targets another container. This option may be used to allow system calls to work for +entities that exist in other container's. For example an IPC capability with this option would +allow ipc system calls to threads that reside in another container. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET_OTHER_PAGER 'Capability Targets Another Container`s Pager' text +Capability targets pager of another container. This option may be used to allow system calls to work for +the pager of other containers. For example an IPC capability with this option would +allow ipc system calls to go through to the pager of another container. This is a more +constrained version of targeting another container. + +. + +CONT%(cn)d_PAGER_CAP_CUSTOM0_TARGET 'Enter Container ID' text +Container ID of the container/pager targeted by this capability. +. + +# +# CUSTOM CAPABILITY 1 +# +CONT%(cn)d_PAGER_CAP_CUSTOM1_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +cont%(cn)d_pager_cap_custom1_type 'Capability Operation Type' text +Specify the type of custom capability. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM1_IPC_TYPE 'IPC Capability' text +Capability associated with inter-container and intra-container ipc properties. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_CONTAINER 'Capability targets any thread in this Container' text +Capability targets current container, meaning that the system call associated with this +capability can be used against any address space and thread present inside this container. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_CURRENT_PAGER_SPACE 'Capability targets any thread in pager`s address space' text +Capability targets the pager's address space, meaning that the system call associated +with this capability can be used for any thread inside the address space of pager. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_CONTAINER 'Capability Targets Another Container' text +Capability targets another container. This option may be used to allow system calls to work for +entities that exist in other container's. For example an IPC capability with this option would +allow ipc system calls to threads that reside in another container. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET_OTHER_PAGER 'Capability Targets Another Container`s Pager' text +Capability targets pager of another container. This option may be used to allow system calls to work for +the pager of other containers. For example an IPC capability with this option would +allow ipc system calls to go through to the pager of another container. This is a more +constrained version of targeting another container. + +. + +CONT%(cn)d_PAGER_CAP_CUSTOM1_TARGET 'Enter Container ID' text +Container ID of the container/pager targeted by this capability. +. + + +# +# CUSTOM CAPABILITY 2 +# +CONT%(cn)d_PAGER_CAP_CUSTOM2_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +cont%(cn)d_pager_cap_custom2_type 'Capability Operation Type' text +Specify the type of custom capability. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM2_IPC_TYPE 'IPC Capability' text +Capability associated with inter-container and intra-container ipc properties. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_CONTAINER 'Capability targets any thread in this Container' text +Capability targets current container, meaning that the system call associated with this +capability can be used against any address space and thread present inside this container. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_CURRENT_PAGER_SPACE 'Capability targets any thread in pager`s address space' text +Capability targets the pager's address space, meaning that the system call associated +with this capability can be used for any thread inside the address space of pager. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_CONTAINER 'Capability Targets Another Container' text +Capability targets another container. This option may be used to allow system calls to work for +entities that exist in other container's. For example an IPC capability with this option would +allow ipc system calls to threads that reside in another container. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET_OTHER_PAGER 'Capability Targets Another Container`s Pager' text +Capability targets pager of another container. This option may be used to allow system calls to work for +the pager of other containers. For example an IPC capability with this option would +allow ipc system calls to go through to the pager of another container. This is a more +constrained version of targeting another container. + +. + +CONT%(cn)d_PAGER_CAP_CUSTOM2_TARGET 'Enter Container ID' text +Container ID of the container/pager targeted by this capability. +. + +# +# CUSTOM CAPABILITY 3 +# +CONT%(cn)d_PAGER_CAP_CUSTOM3_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +cont%(cn)d_pager_cap_custom3_type 'Capability Operation Type' text +Specify the type of custom capability. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM3_IPC_TYPE 'IPC Capability' text +Capability associated with inter-container and intra-container ipc properties. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_CONTAINER 'Capability targets any thread in this Container' text +Capability targets current container, meaning that the system call associated with this +capability can be used against any address space and thread present inside this container. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_CURRENT_PAGER_SPACE 'Capability targets any thread in pager`s address space' text +Capability targets the pager's address space, meaning that the system call associated +with this capability can be used for any thread inside the address space of pager. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_CONTAINER 'Capability Targets Another Container' text +Capability targets another container. This option may be used to allow system calls to work for +entities that exist in other container's. For example an IPC capability with this option would +allow ipc system calls to threads that reside in another container. +. + +CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET_OTHER_PAGER 'Capability Targets Another Container`s Pager' text +Capability targets pager of another container. This option may be used to allow system calls to work for +the pager of other containers. For example an IPC capability with this option would +allow ipc system calls to go through to the pager of another container. This is a more +constrained version of targeting another container. + +. + +CONT%(cn)d_PAGER_CAP_CUSTOM3_TARGET 'Enter Container ID' text +Container ID of the container/pager targeted by this capability. +. + +# Symbols for Generic Capabilities +symbols +CONT%(cn)d_PAGER_CAP_IPC_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container' text +Capability targets current container, including all spaces and threads present inside this container. +. + +CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space' text +Capability targets space associated with pager of this container. +. + +CONT%(cn)d_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER 'Capability Targets Another Container' text +Capability targets pager of another container. +. + +CONT%(cn)d_PAGER_CAP_IPC_TARGET_OTHER_PAGER 'Capability Targets Another Container`s Pager' text +Capability targets pager of another container. +. + +CONT%(cn)d_PAGER_CAP_IPC_TARGET 'Enter Container ID' text +Container ID of the container/pager targeted by this capabilty. +. + +CONT%(cn)d_PAGER_CAP_IRQCTRL_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER 'Capability targets any thread in this Container' text +Capability targets current container, meaning that the system call associated with this +capability can be used against any address space and thread present inside this container. +. + +CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE 'Capability targets any thread in pager`s address space' text +Capability targets the pager's address space, meaning that the system call associated +with this capability can be used for any thread inside the address space of pager. +. + +CONT%(cn)d_CAP_IPC_TARGET_OTHER_CONTAINER 'Capability Targets Another Container' text +Capability targets another container. This option may be used to allow system calls to work for +entities that exist in other container's. For example an IPC capability with this option would +allow ipc system calls to threads that reside in another container. +. + +CONT%(cn)d_CAP_IPC_TARGET_OTHER_PAGER 'Capability Targets Another Container`s Pager' text +Capability targets pager of another container. This option may be used to allow system calls to work for +the pager of other containers. For example an IPC capability with this option would +allow ipc system calls to go through to the pager of another container. This is a more +constrained version of targeting another container. + +. + +CONT%(cn)d_CAP_IPC_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +CONT%(cn)d_CAP_IPC_TARGET 'Enter Container ID' text +Container ID of the container/pager targeted by this capabilty. +. + +symbols +CONT%(cn)d_PAGER_CAP_THREADPOOL_SIZE 'Number of Threads' text +Total number of threads in this pool. +. + +CONT%(cn)d_PAGER_CAP_SPACEPOOL_SIZE 'Number of Address Spaces' text +Total number of spaces in this pool. +. + +CONT%(cn)d_PAGER_CAP_MAPPOOL_SIZE 'Number of PMD Mappings' text +Total number of pmds(E.g. Middle-level Page Tables) in this pool. +. + +CONT%(cn)d_PAGER_CAP_MUTEXPOOL_SIZE 'Number of Userspace Mutexes' text +Total number of mutexes in this pool. +. + +CONT%(cn)d_CAP_MUTEXPOOL_SIZE 'Number of Userspace Mutexes' text +Total number of mutexes in this pool. +. + +CONT%(cn)d_PAGER_CAP_THREADPOOL_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +CONT%(cn)d_PAGER_CAP_SPACEPOOL_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +CONT%(cn)d_PAGER_CAP_MAPPOOL_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +CONT%(cn)d_PAGER_CAP_MUTEXPOOL_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +CONT%(cn)d_CAP_MUTEXPOOL_USE 'Enable this Capability' text +Enable/Disable this capability. +. + +cont%(cn)d_pager_cap_threadpool 'Container %(cn)d Thread Pool Capability' text +It controls the number of threads allowed to be created in the container. +. + +cont%(cn)d_pager_cap_spacepool 'Container %(cn)d Space Pool Capability' text +It controls the number of spaces allowed to be created in the container. +. + +cont%(cn)d_pager_cap_mutexpool 'Container %(cn)d Mutex Pool Capability' text +It controls the number of mutex allowed to be created and used in the container. +. + +cont%(cn)d_cap_mutexpool 'Container %(cn)d Mutex Pool Capability' text +It controls the number of mutex allowed to be created and used in the container. +. + +cont%(cn)d_pager_cap_mappool 'Container %(cn)d Map Pool Capability' text +It defines the mapping pools/caches for various kinds of structures used in the container. +. + + +cont%(cn)d_pager_cap_ipc 'Container %(cn)d IPC Capability' text +Capability associated with inter-container and intra-container ipc permissions. +. + +cont%(cn)d_cap_ipc 'Container %(cn)d IPC Capability' text +Capability associated with inter-container and intra-container ipc permissions. +. + +cont%(cn)d_pager_cap_irqctrl 'Container %(cn)d IRQ Control Capability' text +Capability associated with irq control features and permissions. +. + +cont%(cn)d_pager_cap_custom0 'Container %(cn)d Custom Capability 0 Parameters' text +Custom capability. +. + +cont%(cn)d_pager_cap_custom1 'Container %(cn)d Custom Capability 1 Parameters' text +Custom capability. +. + +cont%(cn)d_pager_cap_custom2 'Container %(cn)d Custom Capability 2 Parameters' text +Custom capability. +. + +cont%(cn)d_pager_cap_custom3 'Container %(cn)d Custom Capability 3 Parameters' text +Custom capability. +. + +cont%(cn)d_pager_capability_list 'Container %(cn)d Pager Capabilities' text +List of capabilities associated with Container%(cn)d's Pager task +. + +cont%(cn)d_capability_list 'Container %(cn)d Global Capabilities' text +List of capabilities globally associated with all tasks inside Container%(cn)d. + +These capabilities can be used by tasks inside Container%(cn)d. +. + + +default CONT%(cn)d_PAGER_CAP_THREADPOOL_SIZE from 64 +default CONT%(cn)d_PAGER_CAP_SPACEPOOL_SIZE from 64 +default CONT%(cn)d_PAGER_CAP_MAPPOOL_SIZE from 800 +default CONT%(cn)d_PAGER_CAP_MUTEXPOOL_SIZE from 100 +default CONT%(cn)d_CAP_MUTEXPOOL_SIZE from 100 + +default CONT%(cn)d_PAGER_CAP_THREADPOOL_USE from y +default CONT%(cn)d_PAGER_CAP_SPACEPOOL_USE from y +default CONT%(cn)d_PAGER_CAP_MAPPOOL_USE from y +default CONT%(cn)d_PAGER_CAP_MUTEXPOOL_USE from y +default CONT%(cn)d_CAP_MUTEXPOOL_USE from y + +# Use Rules for Generic Capabilities +when CONT%(cn)d_PAGER_CAP_THREADPOOL_USE == n + suppress CONT%(cn)d_PAGER_CAP_THREADPOOL_SIZE +when CONT%(cn)d_PAGER_CAP_SPACEPOOL_USE == n + suppress CONT%(cn)d_PAGER_CAP_SPACEPOOL_SIZE +when CONT%(cn)d_PAGER_CAP_MAPPOOL_USE == n + suppress CONT%(cn)d_PAGER_CAP_MAPPOOL_SIZE +when CONT%(cn)d_PAGER_CAP_MUTEXPOOL_USE == n + suppress CONT%(cn)d_PAGER_CAP_MUTEXPOOL_SIZE + +when CONT%(cn)d_CAP_MUTEXPOOL_USE == n + suppress CONT%(cn)d_CAP_MUTEXPOOL_SIZE + +when CONT%(cn)d_PAGER_CAP_IPC_USE == n + suppress CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_IPC_TARGET_OTHER_PAGER + +when CONT%(cn)d_CAP_IPC_USE == n + suppress CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER + CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_CAP_IPC_TARGET_OTHER_CONTAINER + CONT%(cn)d_CAP_IPC_TARGET_OTHER_PAGER + +when CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER or + CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE + suppress CONT%(cn)d_PAGER_CAP_IPC_TARGET + +when CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER or + CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE + suppress CONT%(cn)d_CAP_IPC_TARGET + +choicegroup CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_IPC_TARGET_OTHER_PAGER + default CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER from y + +choicegroup CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER + CONT%(cn)d_CAP_IPC_TARGET_OTHER_CONTAINER + CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_CAP_IPC_TARGET_OTHER_PAGER + default CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER from y + +default CONT%(cn)d_PAGER_CAP_IPC_USE from y +default CONT%(cn)d_PAGER_CAP_IRQCTRL_USE from y +default CONT%(cn)d_CAP_IPC_USE from y + +default CONT%(cn)d_PAGER_CAP_IPC_TARGET from 0 +default CONT%(cn)d_CAP_IPC_TARGET from 0 + +# Capability Menus +menu cont%(cn)d_pager_cap_irqctrl + CONT%(cn)d_PAGER_CAP_IRQCTRL_USE + +menu cont%(cn)d_pager_cap_ipc + CONT%(cn)d_PAGER_CAP_IPC_USE + CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER + CONT%(cn)d_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER + CONT%(cn)d_PAGER_CAP_IPC_TARGET_OTHER_PAGER + CONT%(cn)d_PAGER_CAP_IPC_TARGET% + +menu cont%(cn)d_pager_cap_threadpool + CONT%(cn)d_PAGER_CAP_THREADPOOL_USE + CONT%(cn)d_PAGER_CAP_THREADPOOL_SIZE% + +menu cont%(cn)d_pager_cap_spacepool + CONT%(cn)d_PAGER_CAP_SPACEPOOL_USE + CONT%(cn)d_PAGER_CAP_SPACEPOOL_SIZE% + +menu cont%(cn)d_pager_cap_mappool + CONT%(cn)d_PAGER_CAP_MAPPOOL_USE + CONT%(cn)d_PAGER_CAP_MAPPOOL_SIZE% + +menu cont%(cn)d_pager_cap_mutexpool + CONT%(cn)d_PAGER_CAP_MUTEXPOOL_USE + CONT%(cn)d_PAGER_CAP_MUTEXPOOL_SIZE% + +menu cont%(cn)d_pager_capability_list + cont%(cn)d_pager_cap_threadpool + cont%(cn)d_pager_cap_spacepool + cont%(cn)d_pager_cap_mutexpool + cont%(cn)d_pager_cap_mappool + cont%(cn)d_pager_cap_ipc + cont%(cn)d_pager_cap_irqctrl + cont%(cn)d_pager_cap_custom0 + cont%(cn)d_pager_cap_custom1 + cont%(cn)d_pager_cap_custom2 + cont%(cn)d_pager_cap_custom3 + +menu cont%(cn)d_cap_ipc + CONT%(cn)d_CAP_IPC_USE + CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER + CONT%(cn)d_CAP_IPC_TARGET_CURRENT_PAGER_SPACE + CONT%(cn)d_CAP_IPC_TARGET_OTHER_CONTAINER + CONT%(cn)d_CAP_IPC_TARGET_OTHER_PAGER + CONT%(cn)d_CAP_IPC_TARGET% + +menu cont%(cn)d_cap_mutexpool + CONT%(cn)d_CAP_MUTEXPOOL_USE + CONT%(cn)d_CAP_MUTEXPOOL_SIZE% + +menu cont%(cn)d_capability_list + cont%(cn)d_cap_ipc + cont%(cn)d_cap_mutexpool + +# menu cont%(cn)d_pager_params + +menu container%(cn)d_options + CONT%(cn)d_OPT_NAME$ + cont%(cn)d_baremetal_params +# cont%(cn)d_pager_params + cont%(cn)d_linux_pager_params + cont%(cn)d_pager_linker_params + cont%(cn)d_posix_pager_params + cont%(cn)d_physmem_list + cont%(cn)d_virtmem_list + cont%(cn)d_pager_capability_list + cont%(cn)d_capability_list + +choices container%(cn)d_type + CONT%(cn)d_TYPE_BAREMETAL + CONT%(cn)d_TYPE_POSIX + CONT%(cn)d_TYPE_LINUX + default CONT%(cn)d_TYPE_BAREMETAL + +menu cont%(cn)d_menu + container%(cn)d_type + container%(cn)d_options diff --git a/config/cml/examples/beagle/hello-world.cml b/scripts/config/cml/examples/beagle/hello-world.cml similarity index 100% rename from config/cml/examples/beagle/hello-world.cml rename to scripts/config/cml/examples/beagle/hello-world.cml diff --git a/config/cml/examples/helloworld/config.cml b/scripts/config/cml/examples/helloworld/config.cml similarity index 100% rename from config/cml/examples/helloworld/config.cml rename to scripts/config/cml/examples/helloworld/config.cml diff --git a/config/cml/examples/kmi/kmi-pb926.cml b/scripts/config/cml/examples/kmi/kmi-pb926.cml similarity index 100% rename from config/cml/examples/kmi/kmi-pb926.cml rename to scripts/config/cml/examples/kmi/kmi-pb926.cml diff --git a/config/cml/examples/linux/beagle/config.cml b/scripts/config/cml/examples/linux/beagle/config.cml similarity index 100% rename from config/cml/examples/linux/beagle/config.cml rename to scripts/config/cml/examples/linux/beagle/config.cml diff --git a/config/cml/examples/linux/pb926/config.cml b/scripts/config/cml/examples/linux/pb926/config.cml similarity index 100% rename from config/cml/examples/linux/pb926/config.cml rename to scripts/config/cml/examples/linux/pb926/config.cml diff --git a/scripts/config/cml/examples/linux/vexpress/config.cml b/scripts/config/cml/examples/linux/vexpress/config.cml new file mode 100644 index 0000000..1650fed --- /dev/null +++ b/scripts/config/cml/examples/linux/vexpress/config.cml @@ -0,0 +1,230 @@ +# +# Automatically generated, don't edit +# +# Generated on: bahadir-laptop +# At: Tue, 01 Jun 2010 11:36:41 +0000 +# Linux version 2.6.31-21-generic (buildd@rothera) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) ) #59-Ubuntu SMP Wed Mar 24 07:28:56 UTC 2010 + +# +# Codezero Microkernel Configurator +# + +# +# Main architecture +# +CONFIG_ARCH_ARM=y + + +# +# ARM Architecture Configuration +# + +# +# ARM Platform Type +# +CONFIG_PLATFORM_PB926=n +CONFIG_PLATFORM_PBA9=y +CONFIG_PLATFORM_BEAGLE=n +CONFIG_PLATFORM_EB=n + + +# +# ARM Processor Type +# +CONFIG_CPU_CORTEXA9=y + + + +# +# Generic Processor Properties +# +CONFIG_SMP_=y +CONFIG_NCPU=4 +CONFIG_ICACHE_DISABLE=n +CONFIG_DCACHE_DISABLE=n + + +# +# Generic Kernel Properties +# +CONFIG_PREEMPT_DISABLE=n +CONFIG_DEBUG_ACCOUNTING=n +CONFIG_DEBUG_SPINLOCKS=n +CONFIG_SCHED_TICKS=1000 + + +# +# Toolchain Prefix +# +CONFIG_TOOLCHAIN_USERSPACE="arm-none-linux-gnueabi-" +CONFIG_TOOLCHAIN_KERNEL="arm-none-eabi-" + + +# +# Container Setup +# +CONFIG_CAPABILITIES=y +CONFIG_CONTAINERS=1 + +# +# Container 0 Parameters +# + +# +# Container 0 Type +# +CONFIG_CONT0_TYPE_BAREMETAL=n +CONFIG_CONT0_TYPE_POSIX=n +CONFIG_CONT0_TYPE_LINUX=y + + +# +# Container 0 Options +# +CONFIG_CONT0_OPT_NAME="linux0" + +# +# Container 0 Linux Pager Parameters +# +CONFIG_CONT0_LINUX_PHYS_OFFSET=0x200000 +CONFIG_CONT0_LINUX_ZRELADDR=0x208000 +CONFIG_CONT0_LINUX_ROOTFS_ADDRESS=0x700000 +CONFIG_CONT0_LINUX_PAGE_OFFSET=0x60000000 + + +# +# Container 0 Pager Physical Memory Regions (Capabilities) +# +CONFIG_CONT0_PAGER_PHYSMEM_REGIONS=1 +CONFIG_CONT0_PAGER_PHYS0_START=0x100000 +CONFIG_CONT0_PAGER_PHYS0_END=0xe00000 + + +# +# Container 0 Pager Virtual Memory Regions (Capabilities) +# +CONFIG_CONT0_PAGER_VIRTMEM_REGIONS=1 +CONFIG_CONT0_PAGER_VIRT0_START=0xa0000000 +CONFIG_CONT0_PAGER_VIRT0_END=0xb0000000 + + +# +# Container 0 Pager Capabilities +# + +# +# Container 0 Thread Pool Capability +# +CONFIG_CONT0_PAGER_CAP_THREADPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_THREADPOOL_SIZE=64 + + +# +# Container 0 Space Pool Capability +# +CONFIG_CONT0_PAGER_CAP_SPACEPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_SPACEPOOL_SIZE=64 + + +# +# Container 0 Mutex Pool Capability +# +CONFIG_CONT0_PAGER_CAP_MUTEXPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_MUTEXPOOL_SIZE=100 + + +# +# Container 0 Map Pool Capability +# +CONFIG_CONT0_PAGER_CAP_MAPPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_MAPPOOL_SIZE=800 + + +# +# Container 0 IPC Capability +# +CONFIG_CONT0_PAGER_CAP_IPC_USE=y +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER=y +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER=n +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_OTHER_PAGER=n + + +# +# Container 0 IRQ Control Capability +# +CONFIG_CONT0_PAGER_CAP_IRQCTRL_USE=y + + +# +# Container 0 Custom Capability 0 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM0_USE=n + + +# +# Container 0 Custom Capability 1 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM1_USE=n + + +# +# Container 0 Custom Capability 2 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM2_USE=n + + +# +# Container 0 Custom Capability 3 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM3_USE=n + + + +# +# Container 0 Global Capabilities +# + +# +# Container 0 IPC Capability +# +CONFIG_CONT0_CAP_IPC_USE=y +CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y +CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n +CONFIG_CONT0_CAP_IPC_TARGET_OTHER_CONTAINER=n +CONFIG_CONT0_CAP_IPC_TARGET_OTHER_PAGER=n + + +# +# Container 0 Mutex Pool Capability +# +CONFIG_CONT0_CAP_MUTEXPOOL_USE=y +CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100 + + + + + + +# +# Derived symbols +# +CONFIG_CONT3_START_PC_ADDR=0xd0000000 +CONFIG_DEBUG_PERFMON_KERNEL=n +CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000 +CONFIG_CONT2_START_PC_ADDR=0xc0000000 +CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000 +CONFIG_RAM_BASE_PLAT=0 +CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000 +CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000 +CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000 +CONFIG_SUBARCH_V5=n +CONFIG_SUBARCH_V7=y +CONFIG_SUBARCH_V6=n +CONFIG_CONT0_PAGER_LOAD_ADDR=0x200000 +CONFIG_CONT0_PAGER_VIRT_ADDR=0x60000000 +CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000 +CONFIG_CONT0_START_PC_ADDR=0x60008000 +CONFIG_CONT1_START_PC_ADDR=0xb0000000 +# +# That's all, folks! diff --git a/scripts/config/cml/examples/posix/single_posix.cml b/scripts/config/cml/examples/posix/single_posix.cml new file mode 100644 index 0000000..fdaa507 --- /dev/null +++ b/scripts/config/cml/examples/posix/single_posix.cml @@ -0,0 +1,243 @@ +# +# Automatically generated, don't edit +# +# Generated on: bahadir-laptop +# At: Mon, 31 May 2010 17:06:37 +0000 +# Linux version 2.6.31-21-generic (buildd@rothera) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) ) #59-Ubuntu SMP Wed Mar 24 07:28:56 UTC 2010 + +# +# Codezero Microkernel Configurator +# + +# +# Main architecture +# +CONFIG_ARCH_ARM=y + + +# +# ARM Architecture Configuration +# + +# +# ARM Platform Type +# +CONFIG_PLATFORM_PB926=y +CONFIG_PLATFORM_PBA9=n +CONFIG_PLATFORM_BEAGLE=n +CONFIG_PLATFORM_EB=n + + +# +# ARM Processor Type +# +CONFIG_CPU_ARM926=y + + + +# +# Generic Processor Properties +# +CONFIG_ICACHE_DISABLE=n +CONFIG_DCACHE_DISABLE=n + + +# +# Generic Kernel Properties +# +CONFIG_PREEMPT_DISABLE=n +CONFIG_DEBUG_ACCOUNTING=n +CONFIG_DEBUG_SPINLOCKS=n +CONFIG_SCHED_TICKS=1000 + + +# +# Toolchain Prefix +# +CONFIG_TOOLCHAIN_USERSPACE="arm-none-linux-gnueabi-" +CONFIG_TOOLCHAIN_KERNEL="arm-none-eabi-" + + +# +# Container Setup +# +CONFIG_CAPABILITIES=y +CONFIG_CONTAINERS=1 + +# +# Container 0 Parameters +# + +# +# Container 0 Type +# +CONFIG_CONT0_TYPE_BAREMETAL=n +CONFIG_CONT0_TYPE_POSIX=y +CONFIG_CONT0_TYPE_LINUX=n + + +# +# Container 0 Options +# +CONFIG_CONT0_OPT_NAME="posix0" + +# +# Container 0 Pager Linker Parameters +# +CONFIG_CONT0_PAGER_LMA=0x100000 +CONFIG_CONT0_PAGER_VMA=0xa0000000 + + +# +# Container 0 POSIX Pager Parameters +# +CONFIG_CONT0_PAGER_SHM_START=0x80000000 +CONFIG_CONT0_PAGER_SHM_END=0x88000000 +CONFIG_CONT0_PAGER_TASK_START=0x40000000 +CONFIG_CONT0_PAGER_TASK_END=0x50000000 +CONFIG_CONT0_PAGER_UTCB_START=0xf8100000 +CONFIG_CONT0_PAGER_UTCB_END=0xf8200000 + + +# +# Container 0 Pager Physical Memory Regions (Capabilities) +# +CONFIG_CONT0_PAGER_PHYSMEM_REGIONS=1 +CONFIG_CONT0_PAGER_PHYS0_START=0x100000 +CONFIG_CONT0_PAGER_PHYS0_END=0xe00000 + + +# +# Container 0 Pager Virtual Memory Regions (Capabilities) +# +CONFIG_CONT0_PAGER_VIRTMEM_REGIONS=4 +CONFIG_CONT0_PAGER_VIRT0_START=0xa0000000 +CONFIG_CONT0_PAGER_VIRT0_END=0xb0000000 +CONFIG_CONT0_PAGER_VIRT1_START=0x80000000 +CONFIG_CONT0_PAGER_VIRT1_END=0x88000000 +CONFIG_CONT0_PAGER_VIRT2_START=0x40000000 +CONFIG_CONT0_PAGER_VIRT2_END=0x50000000 +CONFIG_CONT0_PAGER_VIRT3_START=0xf8100000 +CONFIG_CONT0_PAGER_VIRT3_END=0xf8200000 + + +# +# Container 0 Pager Capabilities +# + +# +# Container 0 Thread Pool Capability +# +CONFIG_CONT0_PAGER_CAP_THREADPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_THREADPOOL_SIZE=64 + + +# +# Container 0 Space Pool Capability +# +CONFIG_CONT0_PAGER_CAP_SPACEPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_SPACEPOOL_SIZE=64 + + +# +# Container 0 Mutex Pool Capability +# +CONFIG_CONT0_PAGER_CAP_MUTEXPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_MUTEXPOOL_SIZE=100 + + +# +# Container 0 Map Pool Capability +# +CONFIG_CONT0_PAGER_CAP_MAPPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_MAPPOOL_SIZE=800 + + +# +# Container 0 IPC Capability +# +CONFIG_CONT0_PAGER_CAP_IPC_USE=y +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER=y +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER=n +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_OTHER_PAGER=n + + +# +# Container 0 IRQ Control Capability +# +CONFIG_CONT0_PAGER_CAP_IRQCTRL_USE=y + + +# +# Container 0 Custom Capability 0 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM0_USE=n + + +# +# Container 0 Custom Capability 1 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM1_USE=n + + +# +# Container 0 Custom Capability 2 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM2_USE=n + + +# +# Container 0 Custom Capability 3 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM3_USE=n + + + +# +# Container 0 Global Capabilities +# + +# +# Container 0 IPC Capability +# +CONFIG_CONT0_CAP_IPC_USE=y +CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y +CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n +CONFIG_CONT0_CAP_IPC_TARGET_OTHER_CONTAINER=n +CONFIG_CONT0_CAP_IPC_TARGET_OTHER_PAGER=n + + +# +# Container 0 Mutex Pool Capability +# +CONFIG_CONT0_CAP_MUTEXPOOL_USE=y +CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100 + + + + + + +# +# Derived symbols +# +CONFIG_CONT3_START_PC_ADDR=0xd0000000 +CONFIG_DEBUG_PERFMON_KERNEL=n +CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000 +CONFIG_RAM_BASE_PLAT=0 +CONFIG_CONT2_START_PC_ADDR=0xc0000000 +CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000 +CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000 +CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000 +CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000 +CONFIG_SUBARCH_V5=y +CONFIG_SUBARCH_V7=n +CONFIG_SUBARCH_V6=n +CONFIG_CONT0_PAGER_LOAD_ADDR=0x100000 +CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000 +CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000 +CONFIG_CONT0_START_PC_ADDR=0xa0000000 +CONFIG_CONT1_START_PC_ADDR=0xb0000000 +# +# That's all, folks! diff --git a/scripts/config/cml/examples/posix/two_posix.cml b/scripts/config/cml/examples/posix/two_posix.cml new file mode 100644 index 0000000..9b98712 --- /dev/null +++ b/scripts/config/cml/examples/posix/two_posix.cml @@ -0,0 +1,397 @@ +# +# Automatically generated, don't edit +# +# Generated on: bahadir-laptop +# At: Mon, 31 May 2010 17:04:09 +0000 +# Linux version 2.6.31-21-generic (buildd@rothera) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) ) #59-Ubuntu SMP Wed Mar 24 07:28:56 UTC 2010 + +# +# Codezero Microkernel Configurator +# + +# +# Main architecture +# +CONFIG_ARCH_ARM=y + + +# +# ARM Architecture Configuration +# + +# +# ARM Platform Type +# +CONFIG_PLATFORM_PB926=y +CONFIG_PLATFORM_PBA9=n +CONFIG_PLATFORM_BEAGLE=n +CONFIG_PLATFORM_EB=n + + +# +# ARM Processor Type +# +CONFIG_CPU_ARM926=y + + + +# +# Generic Processor Properties +# +CONFIG_ICACHE_DISABLE=n +CONFIG_DCACHE_DISABLE=n + + +# +# Generic Kernel Properties +# +CONFIG_PREEMPT_DISABLE=n +CONFIG_DEBUG_ACCOUNTING=n +CONFIG_DEBUG_SPINLOCKS=n +CONFIG_SCHED_TICKS=1000 + + +# +# Toolchain Prefix +# +CONFIG_TOOLCHAIN_USERSPACE="arm-none-linux-gnueabi-" +CONFIG_TOOLCHAIN_KERNEL="arm-none-eabi-" + + +# +# Container Setup +# +CONFIG_CAPABILITIES=y +CONFIG_CONTAINERS=2 + +# +# Container 0 Parameters +# + +# +# Container 0 Type +# +CONFIG_CONT0_TYPE_BAREMETAL=n +CONFIG_CONT0_TYPE_POSIX=y +CONFIG_CONT0_TYPE_LINUX=n + + +# +# Container 0 Options +# +CONFIG_CONT0_OPT_NAME="posix0" + +# +# Container 0 Pager Linker Parameters +# +CONFIG_CONT0_PAGER_LMA=0x100000 +CONFIG_CONT0_PAGER_VMA=0xa0000000 + + +# +# Container 0 POSIX Pager Parameters +# +CONFIG_CONT0_PAGER_SHM_START=0x80000000 +CONFIG_CONT0_PAGER_SHM_END=0x88000000 +CONFIG_CONT0_PAGER_TASK_START=0x40000000 +CONFIG_CONT0_PAGER_TASK_END=0x50000000 +CONFIG_CONT0_PAGER_UTCB_START=0xf8100000 +CONFIG_CONT0_PAGER_UTCB_END=0xf8200000 + + +# +# Container 0 Pager Physical Memory Regions (Capabilities) +# +CONFIG_CONT0_PAGER_PHYSMEM_REGIONS=1 +CONFIG_CONT0_PAGER_PHYS0_START=0x100000 +CONFIG_CONT0_PAGER_PHYS0_END=0xe00000 + + +# +# Container 0 Pager Virtual Memory Regions (Capabilities) +# +CONFIG_CONT0_PAGER_VIRTMEM_REGIONS=4 +CONFIG_CONT0_PAGER_VIRT0_START=0xa0000000 +CONFIG_CONT0_PAGER_VIRT0_END=0xb0000000 +CONFIG_CONT0_PAGER_VIRT1_START=0x80000000 +CONFIG_CONT0_PAGER_VIRT1_END=0x88000000 +CONFIG_CONT0_PAGER_VIRT2_START=0x40000000 +CONFIG_CONT0_PAGER_VIRT2_END=0x50000000 +CONFIG_CONT0_PAGER_VIRT3_START=0xf8100000 +CONFIG_CONT0_PAGER_VIRT3_END=0xf8200000 + + +# +# Container 0 Pager Capabilities +# + +# +# Container 0 Thread Pool Capability +# +CONFIG_CONT0_PAGER_CAP_THREADPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_THREADPOOL_SIZE=64 + + +# +# Container 0 Space Pool Capability +# +CONFIG_CONT0_PAGER_CAP_SPACEPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_SPACEPOOL_SIZE=64 + + +# +# Container 0 Mutex Pool Capability +# +CONFIG_CONT0_PAGER_CAP_MUTEXPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_MUTEXPOOL_SIZE=100 + + +# +# Container 0 Map Pool Capability +# +CONFIG_CONT0_PAGER_CAP_MAPPOOL_USE=y +CONFIG_CONT0_PAGER_CAP_MAPPOOL_SIZE=800 + + +# +# Container 0 IPC Capability +# +CONFIG_CONT0_PAGER_CAP_IPC_USE=y +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER=y +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER=n +CONFIG_CONT0_PAGER_CAP_IPC_TARGET_OTHER_PAGER=n + + +# +# Container 0 IRQ Control Capability +# +CONFIG_CONT0_PAGER_CAP_IRQCTRL_USE=y + + +# +# Container 0 Custom Capability 0 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM0_USE=n + + +# +# Container 0 Custom Capability 1 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM1_USE=n + + +# +# Container 0 Custom Capability 2 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM2_USE=n + + +# +# Container 0 Custom Capability 3 Parameters +# +CONFIG_CONT0_PAGER_CAP_CUSTOM3_USE=n + + + +# +# Container 0 Global Capabilities +# + +# +# Container 0 IPC Capability +# +CONFIG_CONT0_CAP_IPC_USE=y +CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y +CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n +CONFIG_CONT0_CAP_IPC_TARGET_OTHER_CONTAINER=n +CONFIG_CONT0_CAP_IPC_TARGET_OTHER_PAGER=n + + +# +# Container 0 Mutex Pool Capability +# +CONFIG_CONT0_CAP_MUTEXPOOL_USE=y +CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100 + + + + + +# +# Container 1 Parameters +# + +# +# Container 1 Type +# +CONFIG_CONT1_TYPE_BAREMETAL=n +CONFIG_CONT1_TYPE_POSIX=y +CONFIG_CONT1_TYPE_LINUX=n + + +# +# Container 1 Options +# +CONFIG_CONT1_OPT_NAME="posix1" + +# +# Container 1 Pager Linker Parameters +# +CONFIG_CONT1_PAGER_LMA=0x1100000 +CONFIG_CONT1_PAGER_VMA=0xb0000000 + + +# +# Container 1 POSIX Pager Parameters +# +CONFIG_CONT1_PAGER_SHM_START=0x88000000 +CONFIG_CONT1_PAGER_SHM_END=0x90000000 +CONFIG_CONT1_PAGER_TASK_START=0x50000000 +CONFIG_CONT1_PAGER_TASK_END=0x60000000 +CONFIG_CONT1_PAGER_UTCB_START=0xf8200000 +CONFIG_CONT1_PAGER_UTCB_END=0xf8300000 + + +# +# Container 1 Pager Physical Memory Regions (Capabilities) +# +CONFIG_CONT1_PAGER_PHYSMEM_REGIONS=1 +CONFIG_CONT1_PAGER_PHYS0_START=0x1100000 +CONFIG_CONT1_PAGER_PHYS0_END=0x1e00000 + + +# +# Container 1 Pager Virtual Memory Regions (Capabilities) +# +CONFIG_CONT1_PAGER_VIRTMEM_REGIONS=4 +CONFIG_CONT1_PAGER_VIRT0_START=0xb0000000 +CONFIG_CONT1_PAGER_VIRT0_END=0xc0000000 +CONFIG_CONT1_PAGER_VIRT1_START=0x88000000 +CONFIG_CONT1_PAGER_VIRT1_END=0x90000000 +CONFIG_CONT1_PAGER_VIRT2_START=0x50000000 +CONFIG_CONT1_PAGER_VIRT2_END=0x60000000 +CONFIG_CONT1_PAGER_VIRT3_START=0xf8200000 +CONFIG_CONT1_PAGER_VIRT3_END=0xf8300000 + + +# +# Container 1 Pager Capabilities +# + +# +# Container 1 Thread Pool Capability +# +CONFIG_CONT1_PAGER_CAP_THREADPOOL_USE=y +CONFIG_CONT1_PAGER_CAP_THREADPOOL_SIZE=64 + + +# +# Container 1 Space Pool Capability +# +CONFIG_CONT1_PAGER_CAP_SPACEPOOL_USE=y +CONFIG_CONT1_PAGER_CAP_SPACEPOOL_SIZE=64 + + +# +# Container 1 Mutex Pool Capability +# +CONFIG_CONT1_PAGER_CAP_MUTEXPOOL_USE=y +CONFIG_CONT1_PAGER_CAP_MUTEXPOOL_SIZE=100 + + +# +# Container 1 Map Pool Capability +# +CONFIG_CONT1_PAGER_CAP_MAPPOOL_USE=y +CONFIG_CONT1_PAGER_CAP_MAPPOOL_SIZE=800 + + +# +# Container 1 IPC Capability +# +CONFIG_CONT1_PAGER_CAP_IPC_USE=y +CONFIG_CONT1_PAGER_CAP_IPC_TARGET_CURRENT_CONTAINER=y +CONFIG_CONT1_PAGER_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n +CONFIG_CONT1_PAGER_CAP_IPC_TARGET_OTHER_CONTAINER=n +CONFIG_CONT1_PAGER_CAP_IPC_TARGET_OTHER_PAGER=n + + +# +# Container 1 IRQ Control Capability +# +CONFIG_CONT1_PAGER_CAP_IRQCTRL_USE=y + + +# +# Container 1 Custom Capability 0 Parameters +# +CONFIG_CONT1_PAGER_CAP_CUSTOM0_USE=n + + +# +# Container 1 Custom Capability 1 Parameters +# +CONFIG_CONT1_PAGER_CAP_CUSTOM1_USE=n + + +# +# Container 1 Custom Capability 2 Parameters +# +CONFIG_CONT1_PAGER_CAP_CUSTOM2_USE=n + + +# +# Container 1 Custom Capability 3 Parameters +# +CONFIG_CONT1_PAGER_CAP_CUSTOM3_USE=n + + + +# +# Container 1 Global Capabilities +# + +# +# Container 1 IPC Capability +# +CONFIG_CONT1_CAP_IPC_USE=y +CONFIG_CONT1_CAP_IPC_TARGET_CURRENT_CONTAINER=y +CONFIG_CONT1_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n +CONFIG_CONT1_CAP_IPC_TARGET_OTHER_CONTAINER=n +CONFIG_CONT1_CAP_IPC_TARGET_OTHER_PAGER=n + + +# +# Container 1 Mutex Pool Capability +# +CONFIG_CONT1_CAP_MUTEXPOOL_USE=y +CONFIG_CONT1_CAP_MUTEXPOOL_SIZE=100 + + + + + + +# +# Derived symbols +# +CONFIG_CONT3_START_PC_ADDR=0xd0000000 +CONFIG_DEBUG_PERFMON_KERNEL=n +CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000 +CONFIG_RAM_BASE_PLAT=0 +CONFIG_CONT2_START_PC_ADDR=0xc0000000 +CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000 +CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000 +CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000 +CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000 +CONFIG_SUBARCH_V5=y +CONFIG_SUBARCH_V7=n +CONFIG_SUBARCH_V6=n +CONFIG_CONT0_PAGER_LOAD_ADDR=0x100000 +CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000 +CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000 +CONFIG_CONT0_START_PC_ADDR=0xa0000000 +CONFIG_CONT1_START_PC_ADDR=0xb0000000 +# +# That's all, folks! diff --git a/config/cml/examples/vxa9/config.cml b/scripts/config/cml/examples/vxa9/config.cml similarity index 100% rename from config/cml/examples/vxa9/config.cml rename to scripts/config/cml/examples/vxa9/config.cml diff --git a/config/config_check.py b/scripts/config/config_check.py similarity index 100% rename from config/config_check.py rename to scripts/config/config_check.py diff --git a/configure.py b/scripts/config/config_invoke.py similarity index 64% rename from configure.py rename to scripts/config/config_invoke.py index 0b0e0cb..597d28b 100755 --- a/configure.py +++ b/scripts/config/config_invoke.py @@ -1,9 +1,12 @@ #! /usr/bin/env python2.6 # -*- mode: python; coding: utf-8; -*- -import os, sys, shelve, shutil +import os, sys, shelve, shutil, time +from time import strftime, localtime from os.path import join -from config.projpaths import * -from config.configuration import * + +from projpaths import * +sys.path.append(PROJROOT) +from configuration import * from scripts.baremetal.baremetal_generator import * from scripts.kernel.generate_kernel_cinfo import * from scripts.cml.generate_container_cml import * @@ -45,6 +48,10 @@ def cml2_header_to_symbols(cml2_header, config): config.get_container_parameters(name, value) config.get_toolchain(name, value) +def cml2_add_default_caps(config): + for c in config.containers: + create_default_capabilities(c) + def cml2_update_config_h(config_h_path, config): with open(config_h_path, "a") as config_h: config_h.write("#define __ARCH__ " + config.arch + '\n') @@ -60,41 +67,45 @@ def configure_kernel(cml_file): cml2_configure(cml_file) - - # Parse options + autogenerate cml rule file if necessary. def build_parse_options(): autogen_true = 0 - usage = "usage: %prog [options] arg" - parser = OptionParser(usage) + usage = "\n\t%prog [options] arg\n\n\ + \r\t** : Override all other options provided" + parser = OptionParser(usage, version = "codezero 4.0") parser.add_option("-a", "--arch", type = "string", dest = "arch", - help = "Use configuration file for architecture") + help = "Specify architecture.") + parser.add_option("-n", "--num-containers", type = "int", dest = "ncont", - help = "Maximum number of containers that will be " - "made available in configuration") - parser.add_option("-c", "--configure-first", action = "store_true", dest = "config", - help = "Tells the build script to run configurator first") - parser.add_option("-f", "--use-file", dest = "cml_file", - help = "Supply user-defined cml file " - "(Use only if you want to override default)") + help = "Maximum number of containers supported in configuration.") + + parser.add_option("-f", "--file", dest = "cml_file", + help = "Specify user-defined configuration file.") + + parser.add_option("-C", "--configure", action = "store_true", dest = "config", + help = "Configure only.") + parser.add_option("-r", "--reset-config", action = "store_true", default = False, dest = "reset_config", - help = "Reset configuration file settings " - "(If you had configured before and changing the " - "rule file, this will reset existing values to default)") - parser.add_option("-s", "--save-old-config", action = "store_true", - default = False, dest = "backup_config", - help = "Backs up old configuration file settings to a .saved file" - "(Subsequent calls would overwrite. Only meaningful with -r)") + help = "Reset earlier configuration settings.") + + parser.add_option("-b", "--batch", action="store_true", dest="batch", default = False, + help = "Disable configuration screen, used with -f only.") + + parser.add_option("-j", "--jobs", type = "str", dest="jobs", default = "1", + help = "Enable parallel build with SCons and GNU/Make" + "try to launch more than one compilation at a time") + parser.add_option("-p", "--print-config", action = "store_true", default = False, dest = "print_config", - help = "Prints out configuration settings" - "(Symbol values and container parameters are printed)") - parser.add_option("-q", "--quite", action="store_true", dest="quite", default = False, - help = "Enable quite mode" - "(will not be presented with a configuration screen)") + help = "Print configuration**") + parser.add_option("-c", "--clean", action="store_true", dest="clean", default = False, + help = "Do cleanup excluding configuration files**") + + parser.add_option("-x", "--clean-all", action="store_true", dest="clean_all", default = False, + help = "Do cleanup including configuration files**") (options, args) = parser.parse_args() @@ -102,8 +113,12 @@ def build_parse_options(): parser.error("options -f and -r are mutually exclusive") exit() - # -f or -r or -n or -a implies -c - if options.cml_file or options.ncont or options.arch or options.reset_config \ + # if -C, configure only. + # -f or -r or -n or -a implies -C. + options.config_only = 0 + if options.config: + options.config_only = 1 + elif options.cml_file or options.ncont or options.arch or options.reset_config \ or not os.path.exists(BUILDDIR) or not os.path.exists(CONFIG_SHELVE_DIR): options.config = 1 @@ -145,14 +160,7 @@ def configure_system(options, args): os.system(CML2TOOLSDIR + '/cmlcompile.py -o ' + \ CML2_COMPILED_RULES + ' ' + rules_file) - # - # If there was an existing config file in default cml path - # and -s was supplied, save it. - # - if os.path.exists(CML2_CONFIG_FILE) and options.backup_config: - shutil.copy(CML2_CONFIG_FILE, CML2_CONFIG_FILE_SAVED) - - if options.quite: + if options.batch: # Create configuration from existing file os.system(CML2TOOLSDIR + '/cmlconfigure.py -b -o ' + \ CML2_CONFIG_FILE + ' -i ' + cml2_config_file + \ @@ -191,24 +199,59 @@ def configure_system(options, args): config = configuration() cml2_header_to_symbols(CML2_CONFIG_H, config) + cml2_add_default_caps(config) cml2_update_config_h(CONFIG_H, config) configuration_save(config) + # Initialise config dependent projpaths + define_config_dependent_projpaths(config) + # Generate baremetal container files if new ones defined baremetal_cont_gen = BaremetalContGenerator() baremetal_cont_gen.baremetal_container_generate(config) - # Print out the configuration if asked - if options.print_config: - config.config_print() - return config +# +# Rename config.cml to more human friendly name +# Name of new cml is based on paltform and +# containers configured in the system. +# +def rename_config_cml(options): + if not options.config: + return None -# Generate kernel cinfo structure for container definitions -def generate_cinfo(): config = configuration_retrieve() - generate_kernel_cinfo(config, KERNEL_CINFO_PATH) + new_cml_file = \ + join(BUILDDIR, strftime("%a-%d%b%Y-%H:%M:%S", localtime()) + \ + '-' + config.platform) + for cont in config.containers: + new_cml_file += '-' + cont.name + new_cml_file += '.cml' + + os.system("cp -f " + CML2_CONFIG_FILE + " " + new_cml_file) + return new_cml_file + +def cml_files_cleanup(): + ''' + config = configuration_retrieve() + new_cml_file = join(BUILDDIR, config.platform) + for cont in config.containers: + new_cml_file += '-' + cont.name + new_cml_file += '.cml' + + #os.system("rm -f " + CML2_CONFIG_FILE) + #os.system("rm -f " + new_cml_file) + #os.system("rm -f " + CML2_COMPILED_RULES) + #os.system("rm -f " + CML2_CONFIG_H) + #os.system("rm -f " + CML2_AUTOGEN_RULES) + os.system("rm -f " + CONFIG_H) + #os.system("rm -f " + CONFIG_SHELVE) + ''' + os.system("rm -f " + CONFIG_H) + os.system("rm -rf " + BUILDDIR) + + return None if __name__ == "__main__": opts, args = build_parse_options() @@ -218,3 +261,6 @@ if __name__ == "__main__": opts.config = 1 configure_system(opts, args) + ''' + print '\nPlease use build.py for configuration and building.\n' + ''' diff --git a/config/configuration.py b/scripts/config/configuration.py similarity index 74% rename from config/configuration.py rename to scripts/config/configuration.py index e995bf4..f2cea3f 100644 --- a/config/configuration.py +++ b/scripts/config/configuration.py @@ -5,20 +5,32 @@ from projpaths import * from lib import * from caps import * +class CapabilityList: + def __init__(self): + self.physmem = {} + self.physmem["START"] = {} + self.physmem["END"] = {} + self.virtmem = {} + self.virtmem["START"] = {} + self.virtmem["END"] = {} + self.caps = {} + self.virt_regions = 0 + self.phys_regions = 0 class Container: def __init__(self, id): self.dirname = None + self.duplicate = 0 self.name = None self.type = None self.id = id self.pager_lma = 0 self.pager_vma = 0 self.pager_size = 0 - self.pager_rw_section_start = 0 - self.pager_rw_section_end = 0 - self.pager_rx_section_start = 0 - self.pager_rx_section_end = 0 + self.pager_rw_pheader_start = 0 + self.pager_rw_pheader_end = 0 + self.pager_rx_pheader_start = 0 + self.pager_rx_pheader_end = 0 self.pager_task_region_start = 0 self.pager_task_region_end = 0 self.pager_shm_region_start = 0 @@ -29,31 +41,28 @@ class Container: self.linux_page_offset = 0 self.linux_phys_offset = 0 self.linux_rootfs_address = 0 - self.physmem = {} - self.physmem["START"] = {} - self.physmem["END"] = {} - self.virtmem = {} - self.virtmem["START"] = {} - self.virtmem["END"] = {} - self.caps = {} - self.virt_regions = 0 - self.phys_regions = 0 + self.caplist = {} + self.caplist["PAGER"] = CapabilityList() + self.caplist["CONTAINER"] = CapabilityList() def print_self(self): print '\nContainer %d' % self.id - print 'Container type: %s' % self.type - print 'Container Name: %s' % self.name - print 'Container Pager lma: %s' % conv_hex(self.pager_lma) - print 'Container Pager vma: %s' % conv_hex(self.pager_vma) - print 'Container Pager shm region start: %s' % conv_hex(self.pager_shm_region_start) - print 'Container Pager shm region end: %s' % conv_hex(self.pager_shm_region_end) - print 'Container Pager task region start: %s' % conv_hex(self.pager_task_region_start) - print 'Container Pager task region end: %s' % conv_hex(self.pager_task_region_end) - print 'Container Pager utcb region start: %s' % conv_hex(self.pager_utcb_region_start) - print 'Container Pager utcb region end: %s' % conv_hex(self.pager_utcb_region_end) - print 'Container Virtual regions: %s' % self.virt_regions - print 'Container Physical regions: %s' % self.phys_regions - print 'Container Capabilities: %s' % self.caps + print '------------' + print 'Container type: %s' % self.type + print 'Container Name: %s' % self.name + print 'Container Pager lma: %s' % conv_hex(self.pager_lma) + print 'Container Pager vma: %s' % conv_hex(self.pager_vma) + print 'Container Pager shm region start: %s' % conv_hex(self.pager_shm_region_start) + print 'Container Pager shm region end: %s' % conv_hex(self.pager_shm_region_end) + print 'Container Pager task region start: %s' % conv_hex(self.pager_task_region_start) + print 'Container Pager task region end: %s' % conv_hex(self.pager_task_region_end) + print 'Container Pager utcb region start: %s' % conv_hex(self.pager_utcb_region_start) + print 'Container Pager utcb region end: %s' % conv_hex(self.pager_utcb_region_end) + print 'Container Virtual regions: %s' % self.caps.virt_regions + print 'Container Physical regions: %s' % self.caps.phys_regions + print 'Container Pager Virtual regions: %s' % self.pager_caps.virt_regions + print 'Container Pager Physical regions: %s' % self.pager_caps.phys_regions + #print 'Container Capabilities: %s' % self.caps print '\n' class configuration: @@ -74,7 +83,7 @@ class configuration: self.cpu = None self.gcc_arch_flag = None self.toolchain_userspace = None - self.toolchain_kernel = None + self.toolchain_kernel = None self.all = [] self.smp = False self.ncpu = 0 @@ -175,18 +184,26 @@ class configuration: self.containers[id].linux_zreladdr = int(val, 0) elif param[:len("LINUX_ROOTFS_ADDRESS")] == "LINUX_ROOTFS_ADDRESS": self.containers[id].linux_rootfs_address += int(val, 0) - elif re.match(r"(VIRT|PHYS){1}([0-9]){1}(_){1}(START|END){1}", param): - matchobj = re.match(r"(VIRT|PHYS){1}([0-9]){1}(_){1}(START|END){1}", param) - virtphys, regionidstr, discard1, startend = matchobj.groups() + elif re.match(r"(PAGER_){0,1}(VIRT|PHYS){1}([0-9]){1}(_){1}(START|END){1}", param): + matchobj = re.match(r"(PAGER_){0,1}(VIRT|PHYS){1}([0-9]){1}(_){1}(START|END){1}", param) + pager, virtphys, regionidstr, discard1, startend = matchobj.groups() regionid = int(regionidstr) + if pager == "PAGER_": + owner = "PAGER" + elif pager == None: + owner = "CONTAINER" + else: + print "Pager is neither None nor PAGER_, it is: " + pager + if virtphys == "VIRT": - self.containers[id].virtmem[startend][regionid] = val - if regionid + 1 > self.containers[id].virt_regions: - self.containers[id].virt_regions = regionid + 1 + self.containers[id].caplist[owner].virtmem[startend][regionid] = val + if regionid + 1 > self.containers[id].caplist[owner].virt_regions: + self.containers[id].caplist[owner].virt_regions = regionid + 1 if virtphys == "PHYS": - self.containers[id].physmem[startend][regionid] = val - if regionid + 1 > self.containers[id].phys_regions: - self.containers[id].phys_regions = regionid + 1 + self.containers[id].caplist[owner].physmem[startend][regionid] = val + if regionid + 1 > self.containers[id].caplist[owner].phys_regions: + self.containers[id].caplist[owner].phys_regions = regionid + 1 + elif param[:len("OPT_NAME")] == "OPT_NAME": name = val[1:-1].lower() self.containers[id].name = name @@ -195,7 +212,10 @@ class configuration: self.containers[id].dirname = param1[2].lower() elif param[:len("CAP_")] == "CAP_": prefix, param_rest = param.split('_', 1) - prepare_capability(self.containers[id], param_rest, val) + prepare_capability(self.containers[id], "CONTAINER", param_rest, val) + elif param[:len("PAGER_CAP_")] == "PAGER_CAP_": + parts = param.split('_', 2) + prepare_capability(self.containers[id], "PAGER", parts[2], val) else: param1, param2 = param.split("_", 1) if param1 == "TYPE": @@ -205,6 +225,7 @@ class configuration: self.containers[id].type = "posix" elif param2 == "BAREMETAL": self.containers[id].type = "baremetal" + # Extract parameters for containers def get_container_parameters(self, name, val): matchobj = re.match(r"(CONFIG_CONT){1}([0-9]){1}(\w+)", name) @@ -256,12 +277,12 @@ class configuration: self.containers.sort(self.compare_containers) def config_print(self): - print 'Configuration\n' - print '-------------\n' - print 'Arch: %s, %s' % (self.arch, self.subarch) - print 'Platform: %s' % self.platform - print 'Symbols:\n %s' % self.all - print 'Containers: %d' % self.ncontainers + print '\nConfiguration' + print '-------------' + print 'Arch: %s, %s' % (self.arch, self.subarch) + print 'Platform: %s' % self.platform + #print 'Symbols: %s' % self.all + print 'Containers: %d' % self.ncontainers self.containers_print() def containers_print(self): @@ -284,6 +305,8 @@ def configuration_save(config): def configuration_retrieve(): # Get configuration information + if not os.path.exists(CONFIG_SHELVE): + return None config_shelve = shelve.open(CONFIG_SHELVE) config = config_shelve["configuration"] return config diff --git a/config/lib.py b/scripts/config/lib.py similarity index 100% rename from config/lib.py rename to scripts/config/lib.py diff --git a/scripts/config/projpaths.py b/scripts/config/projpaths.py new file mode 100644 index 0000000..63ee767 --- /dev/null +++ b/scripts/config/projpaths.py @@ -0,0 +1,75 @@ +#! /usr/bin/env python2.6 +# -*- mode: python; coding: utf-8; -*- + +import os, sys, shelve, shutil +from os.path import join + +# Way to get project root from any script importing this one :-) +PROJROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')) + +BUILDDIR = join(PROJROOT, 'build') +TOOLSDIR = join(PROJROOT, 'tools') +LOADERDIR = join(PROJROOT, 'loader') +KERNEL_HEADERS = join(PROJROOT, 'include') +SCRIPTS_DIR = join(PROJROOT, 'scripts') +KERNEL_ELF = join(BUILDDIR, 'kernel.elf') +FINAL_ELF = join(BUILDDIR, 'final.elf') + +USERLIBS_RELDIR = 'conts/userlibs' +USERLIBS_DIR = join(PROJROOT, USERLIBS_RELDIR) + +LIBL4_RELDIR = join(USERLIBS_RELDIR, 'libl4') +LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) +LIBL4_INCLUDE = join(LIBL4_DIR, 'include') +LIBL4_LIBPATH = join(BUILDDIR, LIBL4_RELDIR) + +LIBC_RELDIR = join(USERLIBS_RELDIR, 'libc') +LIBC_DIR = join(PROJROOT, LIBC_RELDIR) +LIBC_LIBPATH = join(BUILDDIR, LIBC_RELDIR) +LIBC_INCLUDE = [join(LIBC_DIR, 'include')] + +LIBDEV_RELDIR = join(USERLIBS_RELDIR, 'libdev') +LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR) +LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include'), join(LIBDEV_DIR, 'include')] +LIBDEV_USER_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace') +LIBDEV_BAREMETAL_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-baremetal') + +LIBMEM_RELDIR = join(USERLIBS_RELDIR, 'libmem') +LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) +LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) +LIBMEM_INCLUDE = join(LIBMEM_DIR, 'include') + +CML2_CONFIG_SRCDIR = join(SCRIPTS_DIR, 'config/cml') +CML2_CONT_DEFFILE = join(CML2_CONFIG_SRCDIR, 'container_ruleset.template') +CML2TOOLSDIR = join(TOOLSDIR, 'cml2-tools') +CML2_COMPILED_RULES = join(BUILDDIR, 'rules.compiled') +CML2_CONFIG_FILE = join(BUILDDIR, 'config.cml') +CML2_CONFIG_H = join(BUILDDIR, 'config.h') +CML2_AUTOGEN_RULES = join(BUILDDIR, 'config.rules') +CONFIG_H = join(PROJROOT, 'include/l4/config.h') +CONFIG_SHELVE_DIR = join(BUILDDIR, 'configdata') +CONFIG_SHELVE_FILENAME = 'configuration' +CONFIG_SHELVE = join(CONFIG_SHELVE_DIR, CONFIG_SHELVE_FILENAME) +KERNEL_CINFO_PATH = join(PROJROOT, "src/generic/cinfo.c") +LINUXDIR = join(PROJROOT, 'conts/linux') +LINUX_KERNELDIR = join(LINUXDIR, 'kernel-2.6.34') +LINUX_ROOTFSDIR = join(LINUXDIR, 'rootfs') +LINUX_ATAGSDIR = join(LINUXDIR, 'atags') + +POSIXDIR = join(PROJROOT, 'conts/posix') +POSIX_BOOTDESCDIR = join(POSIXDIR, 'bootdesc') + +projpaths = { + 'LINUX_ATAGSDIR' : LINUX_ATAGSDIR, + 'LINUX_ROOTFSDIR' : LINUX_ROOTFSDIR, + 'LINUX_KERNELDIR' : LINUX_KERNELDIR, + 'LINUXDIR' : LINUXDIR, + 'BUILDDIR' : BUILDDIR, + 'POSIXDIR' : POSIXDIR, + 'POSIX_BOOTDESCDIR' : POSIX_BOOTDESCDIR +} + +def define_config_dependent_projpaths(config): + LIBC_INCLUDE.append([join(LIBC_DIR, 'include/arch/' + config.arch)]) + return None + diff --git a/scripts/conts/containers.py b/scripts/conts/containers.py index 7207331..b15d394 100755 --- a/scripts/conts/containers.py +++ b/scripts/conts/containers.py @@ -11,44 +11,41 @@ from tools.pyelf.elfsize import * from tools.pyelf.elf_section_info import * PROJRELROOT = '../../' - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) sys.path.append(os.path.abspath("../")) -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.config.configuration import * from scripts.linux.build_linux import * -from scripts.linux.build_rootfs import * -from scripts.linux.build_atags import * from pack import * from packall import * +from scripts.baremetal.baremetal_generator import * def fill_pager_section_markers(cont, pager_binary): - cont.pager_rw_section_start, cont.pager_rw_section_end, \ - cont.pager_rx_section_start, cont.pager_rx_section_end = \ - elf_loadable_section_info(join(PROJROOT, pager_binary)) + cont.pager_rw_pheader_start, cont.pager_rw_pheader_end, \ + cont.pager_rx_pheader_start, cont.pager_rx_pheader_end = \ + elf_loadable_section_info(join(PROJROOT, pager_binary)) -def build_linux_container(config, projpaths, container): - linux_builder = LinuxBuilder(projpaths, container) - linux_builder.build_linux(config) +def build_linux_container(config, projpaths, container, opts): + linux_builder = LinuxBuilder(projpaths, container, opts) + linux_builder.build_linux(config, opts) - rootfs_builder = RootfsBuilder(projpaths, container) - rootfs_builder.build_rootfs(config) - atags_builder = AtagsBuilder(projpaths, container) - atags_builder.build_atags(config) + os.chdir(LINUX_ROOTFSDIR) + os.system('scons cid=' + str(container.id)) + + os.chdir(LINUX_ATAGSDIR) + os.system('scons cid=' + str(container.id)) # Calculate and store size of pager pager_binary = \ join(BUILDDIR, "cont" + str(container.id) + - "/linux/linux-2.6.33/linux.elf") + "/linux/kernel-2.6.34/linux.elf") config.containers[container.id].pager_size = \ conv_hex(elf_binary_size(pager_binary)) fill_pager_section_markers(config.containers[container.id], pager_binary) - linux_container_packer = \ - LinuxContainerPacker(container, linux_builder, \ - rootfs_builder, atags_builder) + linux_container_packer = LinuxContainerPacker(container, linux_builder) return linux_container_packer.pack_container(config) def glob_by_walk(arg, dirname, names): @@ -67,12 +64,12 @@ def source_to_builddir(srcdir, id): # 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): +def build_posix_container(config, projpaths, container, opts): images = [] cwd = os.getcwd() os.chdir(POSIXDIR) print '\nBuilding Posix Container %d...' % container.id - scons_cmd = 'scons ' + 'cont=' + str(container.id) + scons_cmd = 'scons ' + 'cont=' + str(container.id) + ' -j ' + opts.jobs #print "Issuing scons command: %s" % scons_cmd os.system(scons_cmd) builddir = source_to_builddir(POSIXDIR, container.id) @@ -93,16 +90,27 @@ def build_posix_container(config, projpaths, container): # This simply calls SCons on a given container, and collects # all images with .elf extension, instead of using whole classes # for building and packing. -def build_default_container(config, projpaths, container): +def build_default_container(config, projpaths, container, opts): images = [] cwd = os.getcwd() - projdir = join(join(PROJROOT, 'conts'), container.name) + + builddir = join(join(BUILDDIR, 'cont') + str(container.id), container.name) + if container.duplicate == 0: + projdir = join(join(PROJROOT, 'conts/baremetal'), container.dirname) + else: + projdir = join(join(PROJROOT, 'conts'), container.name) + + BaremetalContGenerator().baremetal_container_generate(config) + + if not os.path.exists(builddir): + os.mkdir(builddir) + os.chdir(projdir) - os.system("scons") - os.path.walk(projdir, glob_by_walk, ['*.elf', images]) + os.system("scons -j " + opts.jobs + " cid=" + str(container.id)) + os.path.walk(builddir, glob_by_walk, ['*.elf', images]) # Calculate and store size of pager - pager_binary = join(PROJROOT, "conts/" + container.name + "/main.elf") + pager_binary = join(builddir, "main.elf") config.containers[container.id].pager_size = \ conv_hex(elf_binary_size(pager_binary)) @@ -111,17 +119,16 @@ def build_default_container(config, projpaths, container): container_packer = DefaultContainerPacker(container, images) return container_packer.pack_container(config) -def build_all_containers(): +def build_all_containers(opts): config = configuration_retrieve() cont_images = [] for container in config.containers: if container.type == 'linux': - pass - cont_images.append(build_linux_container(config, projpaths, container)) + cont_images.append(build_linux_container(config, projpaths, container, opts)) elif container.type == 'baremetal': - cont_images.append(build_default_container(config, projpaths, container)) + cont_images.append(build_default_container(config, projpaths, container, opts)) elif container.type == 'posix': - cont_images.append(build_posix_container(config, projpaths, container)) + cont_images.append(build_posix_container(config, projpaths, container, opts)) else: print "Error: Don't know how to build " + \ "container of type: %s" % (container.type) @@ -131,6 +138,56 @@ def build_all_containers(): return all_cont_packer.pack_all(config) +# Clean containers +def clean_all_containers(): + config = configuration_retrieve() + for container in config.containers: + if container.type == 'linux': + linux_builder = LinuxBuilder(projpaths, container, None) + linux_builder.clean(config) + + os.chdir(LINUX_ROOTFSDIR) + os.system('scons -c cid=' + str(container.id)) + os.chdir(LINUX_ATAGSDIR) + os.system('scons -c cid=' + str(container.id)) + LinuxContainerPacker(container, linux_builder).clean() + + elif container.type == 'baremetal': + builddir = join(join(BUILDDIR, 'cont') + str(container.id), container.name) + if container.duplicate == 0: + projdir = join(join(PROJROOT, 'conts/baremetal'), container.dirname) + else: + projdir = join(join(PROJROOT, 'conts'), container.name) + + os.chdir(projdir) + os.system("scons -c cid=" + str(container.id)) + BaremetalContGenerator().baremetal_del_dynamic_files(container) + DefaultContainerPacker(container, None).clean() + + elif container.type == 'posix': + os.chdir(POSIXDIR) + scons_cmd = 'scons -c ' + 'cont=' + str(container.id) + os.system(scons_cmd) + DefaultContainerPacker(container, None).clean() + + else: + print "Error: Don't know how to build " + \ + "container of type: %s" % (container.type) + exit(1) + + # Clean packed containers elf + all_cont_packer = AllContainerPacker(None, None) + all_cont_packer.clean() + + return None + +def find_container_from_cid(cid): + config = configuration_retrieve() + for container in config.containers: + if cid == container.id: + return container + return None + if __name__ == "__main__": build_all_containers() diff --git a/scripts/conts/pack.py b/scripts/conts/pack.py index d4cae25..2f04d8f 100755 --- a/scripts/conts/pack.py +++ b/scripts/conts/pack.py @@ -9,12 +9,11 @@ import os, sys, shelve, glob from os.path import join PROJRELROOT = '../../' - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) sys.path.append(os.path.abspath('../')) -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.config.configuration import * container_assembler_body = \ ''' @@ -53,7 +52,7 @@ def source_to_builddir(srcdir, id): return join(BUILDDIR, cont_builddir) class LinuxContainerPacker: - def __init__(self, container, linux_builder, rootfs_builder, atags_builder): + def __init__(self, container, linux_builder): # Here, we simply attempt to get PROJROOT/conts as # PROJROOT/build/cont[0-9] @@ -65,9 +64,10 @@ class LinuxContainerPacker: self.container_S_out = join(self.CONTAINER_BUILDDIR_BASE, 'container.S') self.container_elf_out = join(self.CONTAINER_BUILDDIR_BASE, \ 'container' + str(container.id) + '.elf') + self.kernel_image_in = linux_builder.kernel_image - self.rootfs_elf_in = rootfs_builder.rootfs_elf_out - self.atags_elf_in = atags_builder.atags_elf_out + self.rootfs_elf_in = join(self.CONTAINER_BUILDDIR_BASE, 'linux/rootfs/rootfs.elf') + self.atags_elf_in = join(self.CONTAINER_BUILDDIR_BASE, 'linux/atags/atags.elf') def generate_container_assembler(self, source): with open(self.container_S_out, 'w+') as f: @@ -104,12 +104,9 @@ class LinuxContainerPacker: return self.container_elf_out def clean(self): - if os.path.exists(self.container_elf_out): - shutil.rmtree(self.container_elf_out) - if os.path.exists(self.container_lds_out): - shutil.rmtree(self.container_lds_out) - if os.path.exists(self.container_S_out): - shutil.rmtree(self.container_S_out) + os.system('rm -rf ' + self.container_elf_out) + os.system('rm -rf ' + self.container_lds_out) + os.system('rm -rf ' + self.container_S_out) class DefaultContainerPacker: @@ -118,7 +115,7 @@ class DefaultContainerPacker: # Here, we simply attempt to get PROJROOT/conts as # PROJROOT/build/cont[0-9] self.CONTAINER_BUILDDIR_BASE = \ - source_to_builddir(join(PROJROOT,'conts'), container.id) + join(source_to_builddir(join(PROJROOT,'conts'), container.id), 'packer') if not os.path.exists(self.CONTAINER_BUILDDIR_BASE): os.mkdir(self.CONTAINER_BUILDDIR_BASE) @@ -163,10 +160,7 @@ class DefaultContainerPacker: return self.container_elf_out def clean(self): - if os.path.exists(self.container_elf_out): - shutil.rmtree(self.container_elf_out) - if os.path.exists(self.container_lds_out): - shutil.rmtree(self.container_lds_out) - if os.path.exists(self.container_S_out): - shutil.rmtree(self.container_S_out) + os.system('rm -f ' + self.container_elf_out) + os.system('rm -f ' + self.container_lds_out) + os.system('rm -f ' + self.container_S_out) diff --git a/scripts/conts/packall.py b/scripts/conts/packall.py index 5cf6ed5..b955e53 100755 --- a/scripts/conts/packall.py +++ b/scripts/conts/packall.py @@ -9,12 +9,11 @@ import os, sys, shelve from os.path import join PROJRELROOT = '../../' - SCRIPTROOT = os.path.abspath(os.path.dirname(".")) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.config.configuration import * containers_assembler_body = \ ''' @@ -46,7 +45,10 @@ containers_lds_end = \ class AllContainerPacker: def __init__(self, image_list, container_list): self.cont_images_in = image_list - self.cont_images_in.sort() + + if self.cont_images_in: + self.cont_images_in.sort() + self.containers = container_list self.CONTAINERS_BUILDDIR = join(PROJROOT, 'build/conts') @@ -87,12 +89,9 @@ class AllContainerPacker: return self.containers_elf_out def clean(self): - if os.path.exists(self.containers_elf_out): - shutil.rmtree(self.containers_elf_out) - if os.path.exists(self.containers_lds_out): - shutil.rmtree(self.containers_lds_out) - if os.path.exists(self.containers_S_out): - shutil.rmtree(self.containers_S_out) + os.system('rm -f ' + self.containers_elf_out) + os.system('rm -f ' + self.containers_lds_out) + os.system('rm -f ' + self.containers_S_out) if __name__ == "__main__": all_cont_packer = AllContainerPacker([], []) diff --git a/scripts/kernel/check_kernel_limit.py b/scripts/kernel/check_kernel_limit.py new file mode 100755 index 0000000..7ece145 --- /dev/null +++ b/scripts/kernel/check_kernel_limit.py @@ -0,0 +1,40 @@ +#! /usr/bin/env python2.6 +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- a microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, sys +from tools.pyelf.elfsize import * + +from scripts.config.projpaths import * +from scripts.config.configuration import * + +def get_kernel_end_address(img): + kernel_size = elf_binary_size(img) + kernel_start = get_elf_load_address(img) + return (int(kernel_start.get()) + kernel_size) + +def get_container_start(): + start = 0xffffffff + with open(join(PROJROOT, CONFIG_H), 'r')as file: + for line in file: + begin = line.rfind(" ") + end = len(line) + if re.search("(PHYS)([0-9]){1,4}(_START)", line) and \ + start > int(line[begin : end], 16): + start = int(line[begin : end], 16) + return start + +def check_kernel_container_overlap(): + kernel_end = get_kernel_end_address(KERNEL_ELF) + cont_start = get_container_start() + if kernel_end > cont_start: + print '\nKernel end address = ' + str(hex(kernel_end)) + print 'Container start address = ' + str(hex(cont_start)) + '\n' + return 1 + return 0 + +if __name__ == "__main__": + check_kernel_container_overlap() diff --git a/scripts/kernel/generate_kernel_cinfo.py b/scripts/kernel/generate_kernel_cinfo.py index e3d59b9..e975b4a 100755 --- a/scripts/kernel/generate_kernel_cinfo.py +++ b/scripts/kernel/generate_kernel_cinfo.py @@ -10,12 +10,11 @@ from os.path import join from string import Template PROJRELROOT = '../..' - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) sys.path.append(os.path.abspath("../")) -from config.projpaths import * -from config.configuration import * +from scripts.config.projpaths import * +from scripts.config.configuration import * cinfo_file_start = \ @@ -34,10 +33,6 @@ cinfo_file_start = \ %s -/* - * FIXME: - * Add irqs, exceptions - */ __initdata struct container_info cinfo[] = { ''' @@ -46,12 +41,17 @@ cinfo_file_end = \ }; ''' -cinfo_start = \ +cinfo_head_start = \ ''' \t[%d] = { \t.name = "%s", \t.npagers = 1, -\t.pager = { +\t.ncaps = %d, +\t.caps = {''' + +cinfo_caps_end = \ +''' +\t}, ''' cinfo_end = \ @@ -62,15 +62,16 @@ cinfo_end = \ pager_start = \ ''' +\t.pager = { \t\t[0] = { \t\t\t.start_address = (CONFIG_CONT%(cn)d_START_PC_ADDR), \t\t\t.pager_lma = __pfn(CONFIG_CONT%(cn)d_PAGER_LOAD_ADDR), \t\t\t.pager_vma = __pfn(CONFIG_CONT%(cn)d_PAGER_VIRT_ADDR), \t\t\t.pager_size = __pfn(page_align_up(CONT%(cn)d_PAGER_MAPSIZE)), -\t\t\t.rw_sections_start = %(rw_sec_start)s, -\t\t\t.rw_sections_end = %(rw_sec_end)s, -\t\t\t.rx_sections_start = %(rx_sec_start)s, -\t\t\t.rx_sections_end = %(rx_sec_end)s, +\t\t\t.rw_pheader_start = %(rw_pheader_start)s, +\t\t\t.rw_pheader_end = %(rw_pheader_end)s, +\t\t\t.rx_pheader_start = %(rx_pheader_start)s, +\t\t\t.rx_pheader_end = %(rx_pheader_end)s, \t\t\t.ncaps = %(caps)d, \t\t\t.caps = { ''' @@ -80,6 +81,7 @@ pager_end = \ \t\t}, ''' +# These are pager-only. If for container, remove the PAGER part, indent down some tabs. cap_virtmem = \ ''' \t\t\t[%(capidx)d] = { @@ -88,9 +90,9 @@ cap_virtmem = \ \t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE | CAP_MAP_EXEC \t\t\t\t\t| CAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP | CAP_MAP_UTCB | \t\t\t\t\tCAP_CACHE_INVALIDATE | CAP_CACHE_CLEAN, -\t\t\t\t.start = __pfn(CONFIG_CONT%(cn)d_VIRT%(vn)d_START), -\t\t\t\t.end = __pfn(CONFIG_CONT%(cn)d_VIRT%(vn)d_END), -\t\t\t\t.size = __pfn(CONFIG_CONT%(cn)d_VIRT%(vn)d_END - CONFIG_CONT%(cn)d_VIRT%(vn)d_START), +\t\t\t\t.start = __pfn(CONFIG_CONT%(cn)d_PAGER_VIRT%(vn)d_START), +\t\t\t\t.end = __pfn(CONFIG_CONT%(cn)d_PAGER_VIRT%(vn)d_END), +\t\t\t\t.size = __pfn(CONFIG_CONT%(cn)d_PAGER_VIRT%(vn)d_END - CONFIG_CONT%(cn)d_PAGER_VIRT%(vn)d_START), \t\t\t}, ''' @@ -101,9 +103,9 @@ cap_physmem = \ \t\t\t\t.type = CAP_TYPE_MAP_PHYSMEM | CAP_RTYPE_CONTAINER, \t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE | CAP_MAP_EXEC | \t\t\t\t\tCAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP | CAP_MAP_UTCB, -\t\t\t\t.start = __pfn(CONFIG_CONT%(cn)d_PHYS%(pn)d_START), -\t\t\t\t.end = __pfn(CONFIG_CONT%(cn)d_PHYS%(pn)d_END), -\t\t\t\t.size = __pfn(CONFIG_CONT%(cn)d_PHYS%(pn)d_END - CONFIG_CONT%(cn)d_PHYS%(pn)d_START), +\t\t\t\t.start = __pfn(CONFIG_CONT%(cn)d_PAGER_PHYS%(pn)d_START), +\t\t\t\t.end = __pfn(CONFIG_CONT%(cn)d_PAGER_PHYS%(pn)d_END), +\t\t\t\t.size = __pfn(CONFIG_CONT%(cn)d_PAGER_PHYS%(pn)d_END - CONFIG_CONT%(cn)d_PAGER_PHYS%(pn)d_START), \t\t\t}, ''' @@ -136,6 +138,7 @@ pager_ifdefs = \ #define CONT%(cn)d_PAGER_MAPSIZE (CONT%(cn)d_PAGER_SIZE) #endif ''' + def generate_pager_memory_ifdefs(config, containers): pager_ifdef_string = "" linux = 0 @@ -149,7 +152,8 @@ def generate_pager_memory_ifdefs(config, containers): pager_ifdef_string += pager_ifdefs % { 'cn' : c.id } return pager_ifdef_string -def generate_kernel_cinfo(config, cinfo_path): +def generate_kernel_cinfo(cinfo_path): + config = configuration_retrieve() containers = config.containers containers.sort() @@ -158,40 +162,44 @@ def generate_kernel_cinfo(config, cinfo_path): pager_ifdefs = generate_pager_memory_ifdefs(config, containers) - with open(cinfo_path, 'w+') as cinfo_file: + with open(str(cinfo_path), 'w+') as cinfo_file: fbody = cinfo_file_start % pager_ifdefs for c in containers: - # Currently only these are considered as capabilities - total_caps = c.virt_regions + c.phys_regions + len(c.caps) - fbody += cinfo_start % (c.id, c.name) - fbody += pager_start % { 'cn' : c.id, 'caps' : total_caps, - 'rw_sec_start' : hex(c.pager_rw_section_start), - 'rw_sec_end' : hex(c.pager_rw_section_end), - 'rx_sec_start' : hex(c.pager_rx_section_start), - 'rx_sec_end' : hex(c.pager_rx_section_end), - } - cap_index = 0 - for mem_index in range(c.virt_regions): - fbody += cap_virtmem % { 'capidx' : cap_index, 'cn' : c.id, 'vn' : mem_index } - cap_index += 1 - for mem_index in range(c.phys_regions): - fbody += cap_physmem % { 'capidx' : cap_index, 'cn' : c.id, 'pn' : mem_index } - cap_index += 1 + for caplist in [c.caplist["CONTAINER"], c.caplist["PAGER"]]: + total_caps = caplist.virt_regions + caplist.phys_regions + len(caplist.caps) + if caplist == c.caplist["CONTAINER"]: + fbody += cinfo_head_start % (c.id, c.name, total_caps) + else: + fbody += pager_start % { 'cn' : c.id, 'caps' : total_caps, + 'rw_pheader_start' : hex(c.pager_rw_pheader_start), + 'rw_pheader_end' : hex(c.pager_rw_pheader_end), + 'rx_pheader_start' : hex(c.pager_rx_pheader_start), + 'rx_pheader_end' : hex(c.pager_rx_pheader_end), + } + cap_index = 0 + for mem_index in range(caplist.virt_regions): + fbody += cap_virtmem % { 'capidx' : cap_index, 'cn' : c.id, 'vn' : mem_index } + cap_index += 1 + for mem_index in range(caplist.phys_regions): + fbody += cap_physmem % { 'capidx' : cap_index, 'cn' : c.id, 'pn' : mem_index } + cap_index += 1 - for capkey, capstr in c.caps.items(): - templ = Template(capstr) - fbody += templ.safe_substitute(idx = cap_index) - cap_index += 1 + for capkey, capstr in caplist.caps.items(): + templ = Template(capstr) + fbody += templ.safe_substitute(idx = cap_index) + cap_index += 1 - fbody += pager_end - fbody += cinfo_end + if caplist == c.caplist["CONTAINER"]: + fbody += cinfo_caps_end + else: + fbody += pager_end + fbody += cinfo_end fbody += cinfo_file_end cinfo_file.write(fbody) if __name__ == "__main__": - config = configuration_retrieve() if len(sys.argv) > 1: - generate_kernel_cinfo(config, join(PROJROOT, sys.argv[1])) + generate_kernel_cinfo(join(PROJROOT, sys.argv[1])) else: - generate_kernel_cinfo(config, join(PROJROOT, 'src/generic/cinfo.c')) + generate_kernel_cinfo(KERNEL_CINFO_PATH) diff --git a/scripts/linux/build_linux.py b/scripts/linux/build_linux.py old mode 100755 new mode 100644 index d692398..03f036b --- a/scripts/linux/build_linux.py +++ b/scripts/linux/build_linux.py @@ -9,13 +9,12 @@ import os, sys, shelve, string from os.path import join PROJRELROOT = '../../' - -SCRIPTROOT = os.path.abspath(os.path.dirname(".")) +SCRIPTROOT = os.path.abspath(os.path.dirname('.')) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) -from config.projpaths import * -from config.configuration import * -from config.lib import * +from scripts.config.projpaths import * +from scripts.config.configuration import * +from scripts.config.lib import * LINUX_KERNEL_BUILDDIR = join(BUILDDIR, os.path.relpath(LINUX_KERNELDIR, PROJROOT)) @@ -23,105 +22,44 @@ LINUX_KERNEL_BUILDDIR = join(BUILDDIR, os.path.relpath(LINUX_KERNELDIR, PROJROOT # conts/linux -> build/cont[0-9]/linux def source_to_builddir(srcdir, id): cont_builddir = \ - os.path.relpath(srcdir, \ - PROJROOT).replace("conts", \ - "cont" + str(id)) + os.path.relpath(srcdir, PROJROOT).replace('conts', 'cont' + str(id)) return join(BUILDDIR, cont_builddir) class LinuxUpdateKernel: - def __init__(self, container): - # List for setting/unsetting .config params of linux - self.config_param_list = \ - (['PCI', 'SET'],['AEABI', 'SET'], - ['SCSI', 'SET'],['BLK_DEV_SD', 'SET'], - ['SYM53C8XX_2', 'SET'],['INPUT_EVDEV', 'SET'], - ['INOTIFY', 'SET'],['DEBUG_INFO', 'SET'], - ['USB_SUPPORT', 'UNSET'],['SOUND', 'UNSET'],) - # List of CPUIDs, to be used by linux based on codezero config - self.cpuid_list = (['ARM926', '0x41069265'], - ['CORTEXA8', '0x410fc080'], - ['ARM11MPCORE', '0x410fb022'], - ['CORTEXA9', '0x410fc090']) + self.cpuid_list = {'ARM926' : '0x41069265', + 'CORTEXA8' : '0x410fc080', + 'ARM11MPCORE': '0x410fb022', + 'CORTEXA9' : '0x410fc090'} + # List of ARCHIDs, to be used by linux based on codezero config - self.archid_list = (['PB926', '0x183'], - ['EB', '0x33B'], - ['PB11MPCORE', '0x3D4'], - ['BEAGLE', '0x60A'], - ['PBA9', '0x76D'], - ['PBA8', '0x769']) + self.archid_list = {'PB926' : '0x183', + 'EB' : '0x33B', + 'BEAGLE': '0x60A', + 'PBA9' : '0x76D'} # Path of system_macros header file - self.system_macros_h_out = \ - join(LINUX_KERNELDIR, - 'arch/codezero/include/virtualization/system_macros.h') - self.system_macros_h_in = \ - join(LINUX_KERNELDIR, - 'arch/codezero/include/virtualization/system_macros.h.in') + self.system_macros_h_out = join(LINUX_KERNELDIR, 'arch/arm/include/vmm/system_macros.h') + self.system_macros_h_in = join(LINUX_KERNELDIR, 'arch/arm/include/vmm/system_macros.h.in') - #Path for kernel_param file - self.kernel_param_out = \ - join(LINUX_KERNELDIR, 'arch/codezero/include/virtualization/kernel_param') - self.kernel_param_in = \ - join(LINUX_KERNELDIR, 'arch/codezero/include/virtualization/kernel_param.in') - - # Replace line(having input_pattern) in filename with new_data - def replace_line(self, filename, input_pattern, new_data, prev_line): - with open(filename, 'r+') as f: - flag = 0 - temp = 0 - x = re.compile(input_pattern) - for line in f: - if '' != prev_line: - if temp == prev_line and re.match(x, line): - flag = 1 - break - temp = line - else: - if re.match(x, line): - flag = 1 - break - - if flag == 0: - #print 'Warning: No match found for the parameter' - return - else: - # Prevent recompilation in case kernel parameter is same - if new_data != line: - f.seek(0) - l = f.read() - - # Need to truncate file because, size of contents to be - # written may be less than the size of original file. - f.seek(0) - f.truncate(0) - - # Write back to file - f.write(l.replace(line, new_data)) + self.kconfig_in = join(LINUX_KERNELDIR, 'arch/arm/Kconfig.in') + self.kconfig_out = join(LINUX_KERNELDIR, 'arch/arm/Kconfig') # Update kernel parameters def update_kernel_params(self, config, container): - # Update PAGE_OFFSET - # FIXME: Find a way to add this in system_macros.h or kernel_param - # issue is we have to update this in KCONFIG file which cannot - # have dependency on other files. - file = join(LINUX_KERNELDIR, 'arch/codezero/Kconfig') - param = str(conv_hex(container.linux_page_offset)) - new_data = ('\t' + 'default ' + param + '\n') - data_to_replace = "(\t)(default )" - prev_line = ('\t'+'default 0x80000000 if VMSPLIT_2G' + '\n') - self.replace_line(file, data_to_replace, new_data, prev_line) + with open(self.kconfig_out, 'w+') as output: + with open(self.kconfig_in, 'r') as input: + output.write(input.read() % \ + {'phys_offset' : str(conv_hex(container.linux_phys_offset)), \ + 'page_offset' : str(conv_hex(container.linux_page_offset)), \ + 'ztextaddr' : str(conv_hex(container.linux_phys_offset)), \ + 'zreladdr' : str(conv_hex(container.linux_zreladdr))}) - # Update ARCHID, CPUID and ATAGS ADDRESS - for cpu_type, cpu_id in self.cpuid_list: - if cpu_type == config.cpu.upper(): - cpuid = cpu_id - break - for arch_type, arch_id in self.archid_list: - if arch_type == config.platform.upper(): - archid = arch_id - break + + # Update ARCHID, CPUID and ATAGS ADDRESS + cpuid = self.cpuid_list[config.cpu.upper()] + archid = self.archid_list[config.platform.upper()] # Create system_macros header with open(self.system_macros_h_out, 'w+') as output: @@ -129,38 +67,15 @@ class LinuxUpdateKernel: output.write(input.read() % \ {'cpuid' : cpuid, \ 'archid' : archid, \ - 'atags' : str(conv_hex(container.linux_page_offset + 0x100)), \ - 'ztextaddr' : str(conv_hex(container.linux_phys_offset)), \ - 'phys_offset' : str(conv_hex(container.linux_phys_offset)), \ - 'page_offset' : str(conv_hex(container.linux_page_offset)), \ - 'zreladdr' : str(conv_hex(container.linux_zreladdr))}) + 'atags' : str(conv_hex(container.linux_page_offset + 0x100))}) - with open(self.kernel_param_out, 'w+') as output: - with open(self.kernel_param_in, 'r') as input: - output.write(input.read() % \ - {'ztextaddr' : str(conv_hex(container.linux_phys_offset)), \ - 'phys_offset' : str(conv_hex(container.linux_phys_offset)), \ - 'page_offset' : str(conv_hex(container.linux_page_offset)), \ - 'zreladdr' : str(conv_hex(container.linux_zreladdr))}) - - def modify_kernel_config(self, linux_builddir): - file = join(linux_builddir, '.config') - for param_name, param_value in self.config_param_list: - param = 'CONFIG_' + param_name - prev_line = '' - if param_value == 'SET': - data_to_replace = ('# ' + param) - new_data = (param + '=y' + '\n') - else: - data_to_replace = param - new_data = ('# ' + param + ' is not set' + '\n') - - self.replace_line(file, data_to_replace, new_data, prev_line) + def clean(self): + os.system('rm -f ' + self.system_macros_h_out) + os.system('rm -f ' + self.kconfig_out) class LinuxBuilder: - - def __init__(self, pathdict, container): - self.LINUX_KERNELDIR = pathdict["LINUX_KERNELDIR"] + def __init__(self, pathdict, container, opts): + self.LINUX_KERNELDIR = pathdict['LINUX_KERNELDIR'] # Calculate linux kernel build directory self.LINUX_KERNEL_BUILDDIR = \ @@ -169,57 +84,98 @@ class LinuxBuilder: self.container = container self.kernel_binary_image = \ join(os.path.relpath(self.LINUX_KERNEL_BUILDDIR, LINUX_KERNELDIR), \ - "vmlinux") - self.kernel_image = join(self.LINUX_KERNEL_BUILDDIR, "linux.elf") + 'vmlinux') + self.kernel_image = join(self.LINUX_KERNEL_BUILDDIR, 'linux.elf') self.kernel_updater = LinuxUpdateKernel(self.container) + self.build_config_file = join(self.LINUX_KERNEL_BUILDDIR, '.config') + self.platform_config_file = None # Default configuration file to use based on selected platform - self.platform_config_file = (['PB926', 'versatile_defconfig'], - ['BEAGLE', 'omap3_beagle_defconfig'], - ['PBA8', 'realview_defconfig'], - ['PBA9', 'realview-smp_defconfig'], - ['PB11MPCORE', 'realview-smp_defconfig'],) + self.platform_config_files = {'PB926' : 'versatile', + 'BEAGLE' : 'omap3_beagle', + 'PBA9' : 'vexpress_a9'} + # This one is for EB, EB can have 1136/1176/11MPCore/A8/A9 coretiles + self.cpu_config_file = {'CORTEXA8': 'eb-a8', + 'CORTEXA9': 'eb-a9', + 'ARM1136' : 'eb-1136', + 'ARM11MPCORE': 'eb-11mpcore'} - def build_linux(self, config): + def print_verbose(self, text): + print "########################################################" + print "########################################################" + print "# " + text + print "########################################################" + print "########################################################" + + def defconfig_to_config(self, config): + # First get the linux configuration file corresponding to chosen platform + self.platform_defconfig = '' + if config.platform.upper() == 'EB': + self.platform_defconfig = self.cpu_config_file[config.cpu.upper()] + else: + self.platform_defconfig = self.platform_config_files[config.platform.upper()] + + if not self.platform_defconfig: + print 'Platform detected as: ' + config.platform + print 'Could not find relevant linux config file please review configuration' + sys.exit(1) + + # Create a config file from the corresponding defconfig + os.system("make " + self.platform_defconfig + "_defconfig O=" + self.LINUX_KERNEL_BUILDDIR) + + def build_linux(self, config, opts): print '\nBuilding the linux kernel...' os.chdir(self.LINUX_KERNELDIR) if not os.path.exists(self.LINUX_KERNEL_BUILDDIR): os.makedirs(self.LINUX_KERNEL_BUILDDIR) - for platform, config_file in self.platform_config_file: - if platform == config.platform.upper(): - configuration_file = config_file - os.system("make ARCH=codezero CROSS_COMPILE=" + \ - config.toolchain_userspace + \ - " O=" + self.LINUX_KERNEL_BUILDDIR + " " + configuration_file) - - self.kernel_updater.modify_kernel_config(self.LINUX_KERNEL_BUILDDIR) + # Update linux configuration based on codezero config + # TODO: This may be changed from run-always to run-on-modification. self.kernel_updater.update_kernel_params(config, self.container) - os.system("make ARCH=codezero CROSS_COMPILE=" + \ - config.toolchain_userspace + \ - " O=" + self.LINUX_KERNEL_BUILDDIR + " menuconfig") - os.system("make ARCH=codezero " + \ - "CROSS_COMPILE=" + config.toolchain_userspace + \ - " O=" + self.LINUX_KERNEL_BUILDDIR) + # Is this the first time the kernel is to be configured? + if not os.path.exists(self.build_config_file): + self.print_verbose("Config file does not exist. Creating from defconfig") + self.defconfig_to_config(config) + + # Batch mode runs without invoking configure stage + if opts.batch: + # Build the kernel directly + os.system('make ARCH=arm CROSS_COMPILE=' + config.toolchain_kernel + \ + ' O=' + self.LINUX_KERNEL_BUILDDIR + ' ' + self.build_config_file) + else: + # Configure the kernel + os.system('make ARCH=arm CROSS_COMPILE=' + config.toolchain_kernel + \ + ' O=' + self.LINUX_KERNEL_BUILDDIR + ' menuconfig') + if not os.path.exists(self.build_config_file): + self.print_verbose("Config file doesnt exist after building: " + self.build_config_file) + sys.exit(1) + + # Build the kernel + os.system('make V=1 ARCH=arm ' + '-j ' + opts.jobs + \ + ' CROSS_COMPILE=' + config.toolchain_kernel + \ + ' O=' + self.LINUX_KERNEL_BUILDDIR + ' Image') # Generate kernel_image, elf to be used by codezero - linux_elf_gen_cmd = (config.toolchain_userspace + "objcopy -R .note \ - -R .note.gnu.build-id -R .comment -S --change-addresses " + \ + linux_elf_gen_cmd = (config.toolchain_userspace + 'objcopy -R .note \ + -R .note.gnu.build-id -R .comment -S --change-addresses ' + \ str(conv_hex(-self.container.linux_page_offset + self.container.linux_phys_offset)) + \ - " " + self.kernel_binary_image + " " + self.kernel_image) + ' ' + self.kernel_binary_image + ' ' + self.kernel_image) #print cmd os.system(linux_elf_gen_cmd) print 'Done...' - def clean(self): + def clean(self, config): print 'Cleaning linux kernel build...' - if os.path.exists(self.LINUX_KERNEL_BUILDDIR): - shutil.rmtree(self.LINUX_KERNEL_BUILDDIR) + self.kernel_updater.clean() + os.system('rm -f ' + self.kernel_image) + os.chdir(self.LINUX_KERNELDIR) + os.system('make ARCH=arm CROSS_COMPILE=' + config.toolchain_kernel + \ + ' O=' + self.LINUX_KERNEL_BUILDDIR + ' clean') print 'Done...' -if __name__ == "__main__": +if __name__ == '__main__': # This is only a default test case container = Container() container.id = 0 @@ -227,7 +183,8 @@ if __name__ == "__main__": if len(sys.argv) == 1: linux_builder.build_linux() - elif "clean" == sys.argv[1]: + elif 'clean' == sys.argv[1]: linux_builder.clean() else: - print " Usage: %s [clean]" % (sys.argv[0]) + print ' Usage: %s [clean]' % (sys.argv[0]) + diff --git a/scripts/loader/generate_loader_asm.py b/scripts/loader/generate_loader_asm.py index 4bb5acb..2576d54 100755 --- a/scripts/loader/generate_loader_asm.py +++ b/scripts/loader/generate_loader_asm.py @@ -7,15 +7,14 @@ # import os, sys, shelve, subprocess from os.path import join -from configure import * PROJRELROOT = '../../' - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) -from config.projpaths import * -from config.configuration import * -from config.lib import * +from scripts.config.projpaths import * +from scripts.config.configuration import * +from scripts.config.lib import * +from scripts.config.config_invoke import * config = configuration_retrieve() @@ -86,8 +85,7 @@ def generate_image_S(target_path, images): if __name__ == "__main__": if len(sys.argv) == 1: - generate_ksym_to_loader(join(PROJROOT, 'loader/ksyms.S'), \ - join(BUILDDIR, 'kernel.elf')) + generate_ksym_to_loader(join(PROJROOT, 'loader/ksyms.S'), KERNEL_ELF) elif len(sys.argv) == 3: generate_ksym_to_loader(sys.argv[1], sys.argv[1]) else: diff --git a/scripts/qemu/qemu_cmdline.py b/scripts/qemu/qemu_cmdline.py index 6232e29..6557abb 100644 --- a/scripts/qemu/qemu_cmdline.py +++ b/scripts/qemu/qemu_cmdline.py @@ -11,12 +11,8 @@ from os.path import join PROJRELROOT = "../.." sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) -from config.projpaths import * -from config.configuration import * - -#config = configuration_retrieve() -#cpu = config.cpu -#platform = config.platform +from scripts.config.projpaths import * +from scripts.config.configuration import * # Mapping between system configuration and qemu flags # Platform CPU qemu "-M" flag qemu "-cpu" flag @@ -26,13 +22,12 @@ map_list = (['EB', 'ARM1136', 'realview-eb', 'arm1136'], ['EB', 'CORTEXA9', 'realview-pbx-a9', 'cortex-a9'], ['PB926', 'ARM926', 'versatilepb', 'arm926'], ['BEAGLE', 'CORTEXA8', 'beagle', 'cortex-a8'], - ['PBA9', 'CORTEXA9', 'realview-pbx-a9', 'cortex-a9'], - ['PBA8', 'CORTEXA8', 'realview-pb-a8', 'cortex-a8']) + ['PBA9', 'CORTEXA9', 'realview-vx-a9', 'cortex-a9']) data_up = \ ''' cd build -qemu-system-arm -s -S -kernel final.elf -nographic -M %s -cpu %s & +qemu-system-arm -s -S -kernel final.elf -M %s -cpu %s %s & arm-none-insight ; pkill qemu-system-arm cd .. ''' @@ -40,15 +35,15 @@ cd .. data_smp = \ ''' cd build -qemu-system-arm -s -S -kernel final.elf -smp %d -nographic -M %s -cpu %s & +qemu-system-arm -s -S -kernel final.elf -smp %d -M %s -cpu %s %s & arm-none-insight ; pkill qemu-system-arm cd .. ''' -def build_qemu_cmdline_script(): - build_tools_folder = 'tools' - qemu_cmd_file = join(build_tools_folder, 'run-qemu-insight') +# File to be generated with qemu commandline +qemu_cmd_file = join(TOOLSDIR, 'run-qemu-insight') +def build_qemu_cmdline_script(): # Get system selected platform and cpu config = configuration_retrieve() cpu = config.cpu.upper() @@ -67,21 +62,33 @@ def build_qemu_cmdline_script(): print 'Qemu flags not found' sys.exit(1) - if os.path.exists(build_tools_folder) is False: - os.system("mkdir " + build_tools_folder) - # Special case for EB+A9(non-smp) if platform == 'EB' and cpu == 'CORTEXA9' and smp == False: mflag = 'realview-eb' + # Check if we CLCD is selected, otherwise use -nographic + clcd = None + for sym0, sym1 in config.all: + parts = sym0.split("_", ) + if len(parts) >= 5 and parts[3] == 'DEVICE' and \ + parts[4][:len("CLCD")] == "CLCD": + clcd = '-serial stdio' + if not clcd: + clcd = '-nographic' + # Write run-qemu-insight file with open(qemu_cmd_file, 'w+') as f: if smp == False: - f.write(data_up % (mflag, cpuflag)) + f.write(data_up % (mflag, cpuflag, clcd)) else: - f.write(data_smp % (ncpu, mflag, cpuflag)) + f.write(data_smp % (ncpu, mflag, cpuflag, clcd)) os.system("chmod +x " + qemu_cmd_file) + return None + +def clean_qemu_cmdline_script(): + os.system('rm -f ' + qemu_cmd_file) + return None if __name__ == "__main__": build_qemu_cmdline_script() diff --git a/src/api/SConscript b/src/api/SConscript index ae64648..1fa7f73 100644 --- a/src/api/SConscript +++ b/src/api/SConscript @@ -1,10 +1,10 @@ + # Inherit global environment Import('env') -Import('symbols') # The set of source files associated with this SConscript file. -src_local = ['kip.c', 'syscall.c', 'thread.c', 'ipc.c', 'map.c', 'mutex.c', 'cap.c', 'exregs.c', 'irq.c', 'cache.c'] +src_local = ['kip.c', 'syscall.c', 'thread.c', 'ipc.c', 'map.c', + 'mutex.c', 'cap.c', 'exregs.c', 'irq.c', 'cache.c'] obj = env.Object(src_local) - Return('obj') diff --git a/src/api/cap.c b/src/api/cap.c index bea6ee9..9ccaf98 100644 --- a/src/api/cap.c +++ b/src/api/cap.c @@ -25,12 +25,6 @@ int cap_read_all(struct capability *caparray) struct capability *cap; int capidx = 0; - /* Copy all capabilities from lists to buffer */ - list_foreach_struct(cap, ¤t->cap_list.caps, list) { - memcpy(&caparray[capidx], cap, sizeof(*cap)); - capidx++; - } - list_foreach_struct(cap, ¤t->space->cap_list.caps, list) { memcpy(&caparray[capidx], cap, sizeof(*cap)); capidx++; @@ -44,616 +38,6 @@ int cap_read_all(struct capability *caparray) return 0; } -/* - * Shares single cap. If you are sharing, there is - * only one target that makes sense, that is your - * own container. - */ -int cap_share_single(struct capability *user) -{ - struct capability *cap; - struct cap_list *clist; - - if (!(cap = cap_find_by_capid(user->capid, &clist))) - return -EEXIST; - - if (cap->owner != current->tid) - return -EPERM; - - /* First remove it from its list */ - cap_list_remove(cap, clist); - - /* Place it where it is shared */ - cap_list_insert(cap, &curcont->cap_list); - - return 0; -} - -/* - * Shares the whole capability list. - * - * FIXME: Make sure each and every capability has its - * share right set! - */ -int cap_share_all(unsigned int flags) -{ - if (flags == CAP_SHARE_ALL_CONTAINER) { - - /* Move all private caps to container */ - cap_list_move(&curcont->cap_list, - ¤t->cap_list); - - /* - * Move all space caps to container, also. - * - * FIXME: Make sure all space capabilities - * are owned by the sharer!!! - */ - cap_list_move(&curcont->cap_list, - ¤t->space->cap_list); - } else if (flags == CAP_SHARE_ALL_SPACE) { - - /* Move all private caps to space */ - cap_list_move(¤t->space->cap_list, - ¤t->cap_list); - } - return 0; -} - -int cap_share(struct capability *cap, unsigned int flags) -{ - if (flags == CAP_SHARE_SINGLE) - return cap_share_single(cap); - else - return cap_share_all(flags); -} - -#if 0 - -/* - * Currently unused. API hasn't settled. - */ -/* Grants all caps */ -int cap_grant_all(struct capability *req, unsigned int flags) -{ - struct ktcb *target; - struct capability *cap_head, *cap; - int err; - - /* Owners are always threads, for simplicity */ - if (!(target = tcb_find(req->owner))) - return -ESRCH; - - /* Detach all caps */ - cap_head = cap_list_detach(¤t->space->cap_list); - - list_foreach_struct(cap, &cap_head->list, list) { - /* Change ownership */ - cap->owner = target->tid; - BUG_ON(target->tid != req->owner); - - /* Make immutable if GRANT_IMMUTABLE given */ - if (flags & CAP_GRANT_IMMUTABLE) { - cap->access &= ~CAP_GENERIC_MASK; - cap->access |= CAP_IMMUTABLE; - } - - /* - * Sanity check: granted cap cannot have used - * quantity. Otherwise how else the original - * users of the cap free them? - */ - if (cap->used) { - err = -EPERM; - goto out_err; - } - } - - /* Attach all to target */ - cap_list_attach(cap_head, &target->space->cap_list); - return 0; - -out_err: - /* Attach it back to original */ - cap_list_attach(cap_head, ¤t->space->cap_list); - return err; -} - -#endif - -int cap_grant_single(struct capability *req, unsigned int flags) -{ - struct capability *cap; - struct cap_list *clist; - struct ktcb *target; - - if (!(cap = cap_find_by_capid(req->capid, &clist))) - return -EEXIST; - - if (!(target = tcb_find(req->owner))) - return -ESRCH; - - if (cap->owner != current->tid) - return -EPERM; - - /* Granted cap cannot have used quantity */ - if (cap->used) - return -EPERM; - - /* First remove it from its list */ - cap_list_remove(cap, clist); - - /* Change ownership */ - cap->owner = target->tid; - BUG_ON(cap->owner != req->owner); - - /* Make immutable if GRANT_IMMUTABLE given */ - if (flags & CAP_GRANT_IMMUTABLE) { - cap->access &= ~CAP_GENERIC_MASK; - cap->access |= CAP_IMMUTABLE; - } - - /* Place it where it is granted */ - cap_list_insert(cap, &target->space->cap_list); - - return 0; -} - -int cap_grant(struct capability *cap, unsigned int flags) -{ - if (flags & CAP_GRANT_SINGLE) - cap_grant_single(cap, flags); - else - return -EINVAL; - return 0; -} - -int cap_deduce_rtype(struct capability *orig, struct capability *new) -{ - struct ktcb *target; - struct address_space *sp; - - /* An rtype deduction can only be to a space or thread */ - switch (cap_rtype(new)) { - case CAP_RTYPE_SPACE: - /* Check containment right */ - if (cap_rtype(orig) != CAP_RTYPE_CONTAINER) - return -ENOCAP; - - /* - * Find out if this space exists in this - * container. - * - * Note address space search is local only. - * Only thread searches are global. - */ - if (!(sp = address_space_find(new->resid))) - return -ENOCAP; - - /* Success. Assign new type to original cap */ - cap_set_rtype(orig, cap_rtype(new)); - - /* Assign the space id to orig cap */ - orig->resid = sp->spid; - break; - case CAP_RTYPE_THREAD: - /* Find the thread */ - if (!(target = tcb_find(new->resid))) - return -ENOCAP; - - /* Check containment */ - if (cap_rtype(orig) == CAP_RTYPE_SPACE) { - if (orig->resid != target->space->spid) - return -ENOCAP; - } else if (cap_rtype(orig) == CAP_RTYPE_CONTAINER) { - if(orig->resid != target->container->cid) - return -ENOCAP; - } else - return -ENOCAP; - - /* Success. Assign new type to original cap */ - cap_set_rtype(orig, cap_rtype(new)); - - /* Assign the space id to orig cap */ - orig->resid = target->tid; - break; - default: - return -ENOCAP; - } - return 0; -} - -/* - * Deduction can be by access permissions, start, end, size - * fields, or the target resource type. Inter-container - * deduction is not allowed. - * - * Target resource deduction denotes reducing the applicable - * space of the target, e.g. from a container to a space in - * that container. - * - * NOTE: If there is no target deduction, you cannot change - * resid, as this is forbidden. - * - * Imagine a space cap, it cannot be deduced to become applicable - * to another space, i.e a space is in same privilege level. - * But a container-wide cap can be reduced to be applied on - * a space in that container (thus changing the resid to that - * space's id) - * - * capid: Id of original capability - * new: Userspace pointer to new state of capability - * that is desired. - * - * orig = deduced; - */ -int cap_deduce(struct capability *new) -{ - struct capability *orig; - struct cap_list *clist; - int ret; - - /* Find original capability */ - if (!(orig = cap_find_by_capid(new->capid, &clist))) - return -EEXIST; - - /* Check that caller is owner */ - if (orig->owner != current->tid) - return -ENOCAP; - - /* Check that it is deducable */ - if (!(orig->access & CAP_CHANGEABLE)) - return -ENOCAP; - - /* Check target resource deduction */ - if (cap_rtype(new) != cap_rtype(orig)) - if ((ret = cap_deduce_rtype(orig, new)) < 0) - return ret; - - /* Check owners are same for request validity */ - if (orig->owner != new->owner) - return -EINVAL; - - /* Check permissions for deduction */ - if (orig->access) { - /* New cannot have more bits than original */ - if ((orig->access & new->access) != new->access) - return -EINVAL; - /* New cannot make original redundant */ - if (new->access == 0) - return -EINVAL; - - /* Deduce bits of orig */ - orig->access &= new->access; - } else if (new->access) - return -EINVAL; - - /* Check size for deduction */ - if (orig->size) { - /* New can't have more, or make original redundant */ - if (new->size >= orig->size) - return -EINVAL; - - /* - * Can't make reduction on used ones, so there - * must be enough available ones - */ - if (new->size < orig->used) - return -EPERM; - orig->size = new->size; - } else if (new->size) - return -EINVAL; - - /* Range-like permissions can't be deduced */ - if (orig->start || orig->end) { - if (orig->start != new->start || - orig->end != new->end) - return -EPERM; - } else if (new->start || new->end) - return -EINVAL; - - /* Ensure orig and new are the same */ - BUG_ON(orig->capid != new->capid); - BUG_ON(orig->resid != new->resid); - BUG_ON(orig->owner != new->owner); - BUG_ON(orig->type != new->type); - BUG_ON(orig->access != new->access); - BUG_ON(orig->start != new->start); - BUG_ON(orig->end != new->end); - BUG_ON(orig->size != new->size); - BUG_ON(orig->used != new->used); - - return 0; -} - -/* - * Destroys a capability - */ -int cap_destroy(struct capability *cap) -{ - struct capability *orig; - struct cap_list *clist; - - /* Find original capability */ - if (!(orig = cap_find_by_capid(cap->capid, &clist))) - return -EEXIST; - - /* Check that caller is owner */ - if (orig->owner != current->tid) - return -ENOCAP; - - /* Check that it is destroyable */ - if (!(cap_generic_perms(orig) & CAP_CHANGEABLE)) - return -ENOCAP; - - /* - * Check that it is not a device. - * - * We don't allow devices for now. To do this - * correctly, we need to check if device irq - * is not currently registered. - */ - if (cap_is_devmem(orig)) - return -ENOCAP; - - cap_list_remove(orig, clist); - free_capability(orig); - return 0; -} - -static inline int cap_has_size(struct capability *c) -{ - return c->size; -} - -static inline int cap_has_range(struct capability *c) -{ - return c->start && c->end; -} - -/* - * Splits a capability - * - * Pools of typed memory objects can't be replicated, and - * deduced that way, as replication would temporarily double - * their size. So they are split in place. - * - * Splitting occurs by diff'ing resources possessed between - * capabilities. - * - * capid: Original capability that is valid. - * diff: New capability that we want to split out. - * - * orig = orig - diff; - * new = diff; - */ -int cap_split(struct capability *diff, unsigned int flags) -{ - struct capability *orig, *new; - struct cap_list *clist; - int ret; - - /* Find original capability */ - if (!(orig = cap_find_by_capid(diff->capid, &clist))) - return -EEXIST; - - /* Check target type/resid/owner is the same */ - if (orig->type != diff->type || - orig->resid != diff->resid || - orig->owner != diff->owner) - return -EINVAL; - - /* Check that caller is owner */ - if (orig->owner != current->tid) - return -ENOCAP; - - /* Check owners are same */ - if (orig->owner != diff->owner) - return -EINVAL; - - /* Check that it is splitable */ - if (!(orig->access & CAP_CHANGEABLE)) - return -ENOCAP; - - /* Create new */ - if (!(new = capability_create())) - return -ENOCAP; - - /* Check access bits usage and split */ - if (flags & CAP_SPLIT_ACCESS) { - /* Access bits must never be redundant */ - BUG_ON(!orig->access); - - /* Split one can't have more bits than original */ - if ((orig->access & diff->access) != diff->access) { - ret = -EINVAL; - goto out_err; - } - - /* Split one cannot make original redundant */ - if ((orig->access & ~diff->access) == 0) { - ret = -EINVAL; - goto out_err; - } - - /* Split one cannot be redundant itself */ - if (!diff->access) { - ret = -EINVAL; - goto out_err; - } - - /* Subtract given access permissions */ - orig->access &= ~diff->access; - - /* Assign given perms to new capability */ - new->access = diff->access; - } else { - /* Can't split only by access bits alone */ - if (!cap_has_size(orig) && - !cap_has_range(orig)) { - ret = -EINVAL; - goto out_err; - } - /* If no split, then they are identical */ - new->access = orig->access; - - /* Diff must also reflect orig by convention */ - if (diff->access != orig->access) { - ret = -EINVAL; - goto out_err; - } - } - - /* If cap has size, split by size is compulsory */ - if (cap_type(orig) == CAP_TYPE_QUANTITY) { - BUG_ON(!cap_has_size(orig)); - - /* - * Split one can't have more, - * or make original redundant - */ - if (diff->size >= orig->size) { - ret = -EINVAL; - goto out_err; - } - - /* Split one can't be redundant itself */ - if (!diff->size) { - ret = -EINVAL; - goto out_err; - } - - /* Split one must be clean i.e. all unused */ - if (orig->size - orig->used < diff->size) { - ret = -EPERM; - goto out_err; - } - - orig->size -= diff->size; - new->size = diff->size; - new->used = 0; - } else { - - /* Diff must also reflect orig by convention */ - if (diff->size != orig->size) { - ret = -EINVAL; - goto out_err; - } - - /* If no split, then they are identical */ - new->size = orig->size; - new->used = orig->used; - - } - - if (flags & CAP_SPLIT_RANGE) { - /* They must either be both one or both zero */ - BUG_ON(!!orig->start ^ !!orig->end); - - /* If orig doesn't have a range, return invalid */ - if (!orig->start && !orig->end) { - ret = -EINVAL; - goto out_err; - } else { - /* Orig has a range but diff doesn't */ - if (!diff->start || !diff->end) { - ret = -EINVAL; - goto out_err; - } - /* Both valid, but we don't permit range split */ - ret = -EPERM; - goto out_err; - } - /* If no split, then they are identical */ - } else { - new->start = orig->start; - new->end = orig->end; - } - - /* Copy other fields */ - new->type = orig->type; - new->resid = orig->resid; - new->owner = orig->owner; - - /* Add the new capability to the most private list */ - cap_list_insert(new, ¤t->space->cap_list); - - /* Check fields that must be identical */ - BUG_ON(new->resid != diff->resid); - BUG_ON(new->owner != diff->owner); - BUG_ON(new->type != diff->type); - BUG_ON(new->access != diff->access); - BUG_ON(new->start != diff->start); - BUG_ON(new->end != diff->end); - BUG_ON(new->size != diff->size); - - /* Copy capid, and used field that may not be the same */ - diff->capid = new->capid; - diff->used = new->used; - return 0; - -out_err: - free_capability(new); - return ret; -} - -/* - * Replicates an existing capability. This is for expanding - * capabilities to managed children. - * - * After replication, a duplicate capability exists in the - * system, but as it is not a quantity, this does not increase - * the capabilities of the caller in any way. - */ -int cap_replicate(struct capability *dupl) -{ - struct capability *new, *orig; - struct cap_list *clist; - - /* Find original capability */ - if (!(orig = cap_find_by_capid(dupl->capid, &clist))) - return -EEXIST; - - /* Check that caller is owner */ - if (orig->owner != current->tid) - return -ENOCAP; - - /* Check that it is replicable */ - if (!(orig->access & CAP_REPLICABLE)) - return -ENOCAP; - - /* Quantitative types must not be replicable */ - if (cap_type(orig) == CAP_TYPE_QUANTITY) { - printk("Cont %d: FATAL: Capability (%d) " - "is quantitative but also replicable\n", - curcont->cid, orig->capid); - /* FIXME: Should rule this out as a CML2 requirement */ - BUG(); - } - - /* Replicate it */ - if (!(new = capability_create())) - return -ENOCAP; - - /* Copy all except capid & listptrs */ - dupl->resid = new->resid = orig->resid; - dupl->owner = new->owner = orig->owner; - dupl->type = new->type = orig->type; - dupl->access = new->access = orig->access; - dupl->start = new->start = orig->start; - dupl->end = new->end = orig->end; - dupl->size = new->size = orig->size; - dupl->used = new->used = orig->used; - - /* Copy new fields */ - dupl->capid = new->capid; - - /* Add it to most private list */ - cap_list_insert(new, ¤t->space->cap_list); - - return 0; -} - /* * Read, manipulate capabilities. */ @@ -661,13 +45,6 @@ int sys_capability_control(unsigned int req, unsigned int flags, void *userbuf) { int err = 0; - /* - * Check capability to do a capability operation. - * Supported only on current's caps for time being. - */ - if ((err = cap_cap_check(current, req, flags)) < 0) - return err; - /* Check access for each request */ switch(req) { case CAP_CONTROL_NCAPS: @@ -683,20 +60,6 @@ int sys_capability_control(unsigned int req, unsigned int flags, void *userbuf) MAP_USR_RW, 1)) < 0) return err; break; - case CAP_CONTROL_SHARE: - if (flags == CAP_SHARE_ALL_CONTAINER || - flags == CAP_SHARE_ALL_SPACE) - break; - case CAP_CONTROL_GRANT: - case CAP_CONTROL_SPLIT: - case CAP_CONTROL_REPLICATE: - case CAP_CONTROL_DEDUCE: - case CAP_CONTROL_DESTROY: - if ((err = check_access((unsigned long)userbuf, - sizeof(struct capability), - MAP_USR_RW, 1)) < 0) - return err; - break; default: return -EINVAL; } @@ -709,24 +72,6 @@ int sys_capability_control(unsigned int req, unsigned int flags, void *userbuf) case CAP_CONTROL_READ: err = cap_read_all((struct capability *)userbuf); break; - case CAP_CONTROL_SHARE: - err = cap_share((struct capability *)userbuf, flags); - break; - case CAP_CONTROL_GRANT: - err = cap_grant((struct capability *)userbuf, flags); - break; - case CAP_CONTROL_SPLIT: - err = cap_split((struct capability *)userbuf, flags); - break; - case CAP_CONTROL_REPLICATE: - err = cap_replicate((struct capability *)userbuf); - break; - case CAP_CONTROL_DEDUCE: - err = cap_deduce((struct capability *)userbuf); - break; - case CAP_CONTROL_DESTROY: - err = cap_destroy((struct capability *)userbuf); - break; default: return -EINVAL; } diff --git a/src/api/exregs.c b/src/api/exregs.c index 2d1dde0..9496c84 100644 --- a/src/api/exregs.c +++ b/src/api/exregs.c @@ -61,10 +61,6 @@ void exregs_write_registers(struct ktcb *task, struct exregs_data *exregs) context->pc = exregs->context.pc; flags: - /* Set thread's pager if one is supplied */ - if (exregs->flags & EXREGS_SET_PAGER) - task->pagerid = exregs->pagerid; - /* Set thread's utcb if supplied */ if (exregs->flags & EXREGS_SET_UTCB) { task->utcb_address = exregs->utcb_address; @@ -122,7 +118,7 @@ void exregs_read_registers(struct ktcb *task, struct exregs_data *exregs) flags: /* Read thread's pager if pager flag supplied */ if (exregs->flags & EXREGS_SET_PAGER) - exregs->pagerid = task->pagerid; + exregs->pagerid = tcb_pagerid(task); /* Read thread's utcb if utcb flag supplied */ if (exregs->flags & EXREGS_SET_UTCB) @@ -183,7 +179,7 @@ int sys_exchange_registers(struct exregs_data *exregs, l4id_t tid) * be the pagers making the call on themselves. */ if (task->state != TASK_INACTIVE && exregs->valid_vect && - current != task && task->pagerid != current->tid) { + current != task && tcb_pagerid(task) != current->tid) { err = -EACTIVE; goto out; } diff --git a/src/api/map.c b/src/api/map.c index e9c04cd..1d15086 100644 --- a/src/api/map.c +++ b/src/api/map.c @@ -48,10 +48,8 @@ int sys_map(unsigned long phys, unsigned long virt, if ((err = cap_map_check(target, phys, virt, npages, flags)) < 0) return err; - add_mapping_pgd(phys, virt, npages << PAGE_BITS, - flags, TASK_PGD(target)); - - return 0; + return add_mapping_space(phys, virt, npages << PAGE_BITS, + flags, target->space); } /* @@ -74,8 +72,8 @@ int sys_unmap(unsigned long virtual, unsigned long npages, unsigned int tid) return ret; for (int i = 0; i < npages; i++) { - ret = remove_mapping_pgd(TASK_PGD(target), - virtual + i * PAGE_SIZE); + ret = remove_mapping_space(target->space, + virtual + i * PAGE_SIZE); if (ret) retval = ret; } diff --git a/src/api/mutex.c b/src/api/mutex.c index 357a851..deece51 100644 --- a/src/api/mutex.c +++ b/src/api/mutex.c @@ -79,7 +79,7 @@ struct mutex_queue *mutex_control_create(unsigned long mutex_physical) struct mutex_queue *mutex_queue; /* Allocate the mutex queue structure */ - if (!(mutex_queue = alloc_user_mutex())) + if (!(mutex_queue = mutex_cap_alloc())) return 0; /* Init and return */ @@ -98,7 +98,7 @@ void mutex_control_delete(struct mutex_queue *mq) BUG_ON(!list_empty(&mq->wqh_contenders.task_list)); BUG_ON(!list_empty(&mq->wqh_holders.task_list)); - free_user_mutex(mq); + mutex_cap_free(mq); } /* @@ -310,9 +310,6 @@ int sys_mutex_control(unsigned long mutex_address, int mutex_flags) mutex_op != MUTEX_CONTROL_UNLOCK) return -EPERM; - if ((ret = cap_mutex_check(mutex_address, mutex_op)) < 0) - return ret; - /* * Find and check physical address for virtual mutex address * diff --git a/src/api/thread.c b/src/api/thread.c index 4dbcd80..985c425 100644 --- a/src/api/thread.c +++ b/src/api/thread.c @@ -62,8 +62,7 @@ int thread_exit(struct ktcb *task) static inline int task_is_child(struct ktcb *task) { - return (((task) != current) && - ((task)->pagerid == current->tid)); + return ((task != current) && task->pager == current); } int thread_destroy_child(struct ktcb *task) @@ -91,9 +90,11 @@ int thread_destroy_child(struct ktcb *task) return 0; } +/* Must be called from pager thread only */ int thread_destroy_children(void) { struct ktcb *task, *n; + int ret; spin_lock(&curcont->ktcb_list.list_lock); list_foreach_removable_struct(task, n, @@ -106,17 +107,21 @@ int thread_destroy_children(void) } } spin_unlock(&curcont->ktcb_list.list_lock); - return 0; + /* Wait till all children are gone */ + WAIT_EVENT(¤t->wqh_pager, current->nchild == 0, ret); + + return ret; } void thread_destroy_self(unsigned int exit_code) { - /* Destroy all children first */ - thread_destroy_children(); - /* If self-paged, finish everything except deletion */ - if (current->tid == current->pagerid) { + if (thread_is_pager(current)) { + + /* Destroy all children first */ + BUG_ON(thread_destroy_children() < 0); + /* Remove self safe against ipc */ tcb_remove(current); @@ -124,9 +129,9 @@ void thread_destroy_self(unsigned int exit_code) wake_up_all(¤t->wqh_send, WAKEUP_INTERRUPT); wake_up_all(¤t->wqh_recv, WAKEUP_INTERRUPT); - /* Move capabilities to current cpu idle task */ - cap_list_move(&per_cpu(scheduler).idle_task->cap_list, - ¤t->cap_list); + /* Move capabilities to struct pager */ + cap_list_move(&curcont->pager->cap_list, + ¤t->space->cap_list); /* Place self on the per-cpu zombie queue */ ktcb_list_add(current, &per_cpu(kernel_resources.zombie_list)); @@ -219,7 +224,7 @@ int arch_clear_thread(struct ktcb *tcb) tcb->context.spsr = ARM_MODE_USR; /* Clear the page tables */ - remove_mapping_pgd_all_user(TASK_PGD(tcb)); + remove_mapping_pgd_all_user(tcb->space, ¤t->space->cap_list); /* Reinitialize all other fields */ tcb_init(tcb); @@ -358,36 +363,36 @@ int thread_setup_space(struct ktcb *tcb, struct task_ids *ids, unsigned int flag int ret = 0; if (flags & TC_SHARE_SPACE) { - mutex_lock(&curcont->space_list.lock); + spin_lock(&curcont->space_list.lock); if (!(space = address_space_find(ids->spid))) { - mutex_unlock(&curcont->space_list.lock); + spin_unlock(&curcont->space_list.lock); ret = -ESRCH; goto out; } - mutex_lock(&space->lock); - mutex_unlock(&curcont->space_list.lock); + spin_lock(&space->lock); + spin_unlock(&curcont->space_list.lock); address_space_attach(tcb, space); - mutex_unlock(&space->lock); + spin_unlock(&space->lock); } else if (flags & TC_COPY_SPACE) { - mutex_lock(&curcont->space_list.lock); + spin_lock(&curcont->space_list.lock); if (!(space = address_space_find(ids->spid))) { - mutex_unlock(&curcont->space_list.lock); + spin_unlock(&curcont->space_list.lock); ret = -ESRCH; goto out; } - mutex_lock(&space->lock); + spin_lock(&space->lock); if (IS_ERR(new = address_space_create(space))) { - mutex_unlock(&curcont->space_list.lock); - mutex_unlock(&space->lock); + spin_unlock(&curcont->space_list.lock); + spin_unlock(&space->lock); ret = (int)new; goto out; } - mutex_unlock(&space->lock); + spin_unlock(&space->lock); ids->spid = new->spid; /* Return newid to caller */ address_space_attach(tcb, new); address_space_add(new); - mutex_unlock(&curcont->space_list.lock); + spin_unlock(&curcont->space_list.lock); } else if (flags & TC_NEW_SPACE) { if (IS_ERR(new = address_space_create(0))) { @@ -397,9 +402,9 @@ int thread_setup_space(struct ktcb *tcb, struct task_ids *ids, unsigned int flag /* New space id to be returned back to caller */ ids->spid = new->spid; address_space_attach(tcb, new); - mutex_lock(&curcont->space_list.lock); + spin_lock(&curcont->space_list.lock); address_space_add(new); - mutex_unlock(&curcont->space_list.lock); + spin_unlock(&curcont->space_list.lock); } out: @@ -448,7 +453,12 @@ int thread_create(struct task_ids *ids, unsigned int flags) } /* Set creator as pager */ - new->pagerid = current->tid; + new->pager = current; + + /* Update pager child count */ + spin_lock(¤t->thread_lock); + current->nchild++; + spin_unlock(¤t->thread_lock); /* Setup container-generic fields from current task */ new->container = current->container; @@ -476,7 +486,7 @@ int thread_create(struct task_ids *ids, unsigned int flags) out_err: /* Pre-mature tcb needs freeing by free_ktcb */ - free_ktcb(new, current); + ktcb_cap_free(new, ¤t->space->cap_list); return err; } @@ -487,7 +497,7 @@ out_err: */ int sys_thread_control(unsigned int flags, struct task_ids *ids) { - struct ktcb *task = 0; + struct ktcb *task = 0, *pager = 0; int err, ret = 0; if ((err = check_access((unsigned long)ids, sizeof(*ids), @@ -498,15 +508,13 @@ int sys_thread_control(unsigned int flags, struct task_ids *ids) if (!(task = tcb_find(ids->tid))) return -ESRCH; + pager = task->pager; + /* - * Tasks may only operate on their children. They may - * also destroy themselves or any children. + * Caller may operate on a thread if it shares + * the same address space with that thread's pager */ - if ((flags & THREAD_ACTION_MASK) == THREAD_DESTROY && - !task_is_child(task) && task != current) - return -EPERM; - if ((flags & THREAD_ACTION_MASK) != THREAD_DESTROY - && !task_is_child(task)) + if (!space_is_pager(current)) return -EPERM; } diff --git a/src/arch/arm/SConscript b/src/arch/arm/SConscript index 8b6fa21..e37110d 100644 --- a/src/arch/arm/SConscript +++ b/src/arch/arm/SConscript @@ -1,23 +1,25 @@ + # Inherit global environment -import os, sys, glob +import os, sys PROJRELROOT = '../../' - sys.path.append(PROJRELROOT) -from config.projpaths import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.config_invoke import * -Import('env', 'symbols') +Import('env') +config = configuration_retrieve() +symbols = config.all # The set of source files associated with this SConscript file. -src_local = ['head.S', 'vectors.S', 'syscall.S', 'exception-common.c', 'mapping-common.c', 'memset.S', 'memcpy.S'] +src_local = ['head.S', 'vectors.S', 'syscall.S', 'exception-common.c', + 'mapping-common.c', 'memset.S', 'memcpy.S'] for name, val in symbols: - if 'CONFIG_SMP' == name: - src_local += ['head-smp.S'] + if 'CONFIG_SMP_' == name: + src_local += ['head-smp.S'] obj = env.Object(src_local) - Return('obj') diff --git a/src/arch/arm/exception-common.c b/src/arch/arm/exception-common.c index 7a934b7..9f2abc0 100644 --- a/src/arch/arm/exception-common.c +++ b/src/arch/arm/exception-common.c @@ -117,7 +117,7 @@ fault_ipc_to_pager(u32 faulty_pc, u32 fsr, u32 far, u32 ipc_tag) tcb_set_ipc_flags(current, IPC_FLAGS_SHORT); /* Detect if a pager is self-faulting */ - if (current->tid == current->pagerid) { + if (current == current->pager) { printk("Pager (%d) faulted on itself. " "FSR: 0x%x, FAR: 0x%x, PC: 0x%x pte: 0x%x CPU%d Exiting.\n", current->tid, fault->fsr, fault->far, @@ -126,8 +126,8 @@ fault_ipc_to_pager(u32 faulty_pc, u32 fsr, u32 far, u32 ipc_tag) } /* Send ipc to the task's pager */ - if ((err = ipc_sendrecv(current->pagerid, - current->pagerid, 0)) < 0) { + if ((err = ipc_sendrecv(tcb_pagerid(current), + tcb_pagerid(current), 0)) < 0) { BUG_ON(current->nlocks); /* Return on interrupt */ diff --git a/src/arch/arm/mapping-common.c b/src/arch/arm/mapping-common.c index 9816ead..385f7c2 100644 --- a/src/arch/arm/mapping-common.c +++ b/src/arch/arm/mapping-common.c @@ -96,7 +96,8 @@ virt_to_phys_by_task(struct ktcb *task, unsigned long vaddr) * Attaches a pmd to either a task or the global pgd * depending on the virtual address passed. */ -void attach_pmd(pgd_table_t *task_pgd, pmd_table_t *pmd_table, +void attach_pmd(struct address_space *space, + pmd_table_t *pmd_table, unsigned long vaddr) { u32 pmd_phys = virt_to_phys(pmd_table); @@ -108,15 +109,23 @@ void attach_pmd(pgd_table_t *task_pgd, pmd_table_t *pmd_table, * Pick the right pmd from the right pgd. * It makes a difference if split tables are used. */ - pmd = arch_pick_pmd(task_pgd, vaddr); + pmd = arch_pick_pmd(space->pgd, vaddr); /* Write the pmd into hardware pgd */ - arch_write_pmd(pmd, pmd_phys, vaddr); + arch_write_pmd(pmd, pmd_phys, vaddr, space->spid); } -void add_mapping_pgd(unsigned long physical, unsigned long virtual, - unsigned int sz_bytes, unsigned int flags, - pgd_table_t *task_pgd) +/* + * Maps a new address to given space, but charges another + * capability owner task for the pmd, if any used. + * + * This is useful for when irqs force mapping of UTCBs of + * other tasks to the preempted tasks for handling. + */ +int add_mapping_use_cap(unsigned long physical, unsigned long virtual, + unsigned int sz_bytes, unsigned int flags, + struct address_space *space, + struct cap_list *clist) { unsigned long npages = (sz_bytes >> PFN_SHIFT); pmd_table_t *pmd_table; @@ -136,27 +145,80 @@ void add_mapping_pgd(unsigned long physical, unsigned long virtual, /* Map all pages that cover given size */ for (int i = 0; i < npages; i++) { /* Check if a pmd was attached previously */ - if (!(pmd_table = pmd_exists(task_pgd, virtual))) { + if (!(pmd_table = pmd_exists(space->pgd, virtual))) { /* First mapping in pmd, allocate it */ - pmd_table = alloc_pmd(); + if (!(pmd_table = pmd_cap_alloc(clist))) + return -ENOMEM; /* Prepare the pte but don't sync */ arch_prepare_pte(physical, virtual, flags, &pmd_table->entry[PMD_INDEX(virtual)]); /* Attach pmd to its pgd and sync it */ - attach_pmd(task_pgd, pmd_table, virtual); + attach_pmd(space, pmd_table, virtual); } else { /* Prepare, write the pte and sync */ - arch_prepare_write_pte(physical, virtual, - flags, &pmd_table->entry[PMD_INDEX(virtual)]); + arch_prepare_write_pte(space, physical, virtual, + flags, + &pmd_table->entry[PMD_INDEX(virtual)]); } /* Move on to the next page */ physical += PAGE_SIZE; virtual += PAGE_SIZE; } + + return 0; +} + +int add_mapping_space(unsigned long physical, unsigned long virtual, + unsigned int sz_bytes, unsigned int flags, + struct address_space *space) +{ + unsigned long npages = (sz_bytes >> PFN_SHIFT); + pmd_table_t *pmd_table; + + if (sz_bytes < PAGE_SIZE) { + print_early("Error: Mapping size less than PAGE_SIZE. " + "Mapping size is in bytes not pages.\n"); + BUG(); + } + + if (sz_bytes & PAGE_MASK) + npages++; + + /* Convert generic map flags to arch specific flags */ + BUG_ON(!(flags = space_flags_to_ptflags(flags))); + + /* Map all pages that cover given size */ + for (int i = 0; i < npages; i++) { + /* Check if a pmd was attached previously */ + if (!(pmd_table = pmd_exists(space->pgd, virtual))) { + + /* First mapping in pmd, allocate it */ + if (!(pmd_table = pmd_cap_alloc(¤t->space->cap_list))) + return -ENOMEM; + + /* Prepare the pte but don't sync */ + arch_prepare_pte(physical, virtual, flags, + &pmd_table->entry[PMD_INDEX(virtual)]); + + /* Attach pmd to its pgd and sync it */ + attach_pmd(space, pmd_table, virtual); + } else { + /* Prepare, write the pte and sync */ + arch_prepare_write_pte(space, physical, virtual, + flags, + &pmd_table->entry[PMD_INDEX(virtual)]); + } + + /* Move on to the next page */ + physical += PAGE_SIZE; + virtual += PAGE_SIZE; + } + + return 0; } void add_boot_mapping(unsigned long physical, unsigned long virtual, @@ -191,11 +253,12 @@ void add_boot_mapping(unsigned long physical, unsigned long virtual, &pmd_table->entry[PMD_INDEX(virtual)]); /* Attach pmd to its pgd and sync it */ - attach_pmd(&init_pgd, pmd_table, virtual); + attach_pmd(current->space, pmd_table, virtual); } else { /* Prepare, write the pte and sync */ - arch_prepare_write_pte(physical, virtual, - flags, &pmd_table->entry[PMD_INDEX(virtual)]); + arch_prepare_write_pte(current->space, physical, + virtual, flags, + &pmd_table->entry[PMD_INDEX(virtual)]); } /* Move on to the next page */ @@ -204,10 +267,10 @@ void add_boot_mapping(unsigned long physical, unsigned long virtual, } } -void add_mapping(unsigned long paddr, unsigned long vaddr, - unsigned int size, unsigned int flags) +int add_mapping(unsigned long paddr, unsigned long vaddr, + unsigned int size, unsigned int flags) { - add_mapping_pgd(paddr, vaddr, size, flags, TASK_PGD(current)); + return add_mapping_space(paddr, vaddr, size, flags, current->space); } /* @@ -247,7 +310,7 @@ int check_mapping(unsigned long vaddr, unsigned long size, * This can be made common for v5/v7, keeping split/page table * and cache flush parts in arch-specific files. */ -int remove_mapping_pgd(pgd_table_t *task_pgd, unsigned long vaddr) +int remove_mapping_space(struct address_space *space, unsigned long vaddr) { pmd_table_t *pmd_table; int pgd_i, pmd_i; @@ -262,7 +325,7 @@ int remove_mapping_pgd(pgd_table_t *task_pgd, unsigned long vaddr) * Get the right pgd's pmd according to whether * the address is global or task-specific. */ - pmd = arch_pick_pmd(task_pgd, vaddr); + pmd = arch_pick_pmd(space->pgd, vaddr); pmd_type = *pmd & PMD_TYPE_MASK; @@ -288,7 +351,7 @@ int remove_mapping_pgd(pgd_table_t *task_pgd, unsigned long vaddr) BUG(); /* Write to pte, also syncing it as required by arch */ - arch_prepare_write_pte(0, vaddr, + arch_prepare_write_pte(space, 0, vaddr, space_flags_to_ptflags(MAP_FAULT), (pte_t *)&pmd_table->entry[pmd_i]); return 0; @@ -296,14 +359,14 @@ int remove_mapping_pgd(pgd_table_t *task_pgd, unsigned long vaddr) int remove_mapping(unsigned long vaddr) { - return remove_mapping_pgd(TASK_PGD(current), vaddr); + return remove_mapping_space(current->space, vaddr); } -int delete_page_tables(struct address_space *space) +int delete_page_tables(struct address_space *space, struct cap_list *clist) { - remove_mapping_pgd_all_user(space->pgd); - free_pgd(space->pgd); + remove_mapping_pgd_all_user(space, clist); + pgd_free(space->pgd); return 0; } @@ -325,7 +388,7 @@ int copy_user_tables(struct address_space *new, ((from->entry[i] & PMD_TYPE_MASK) == PMD_TYPE_PMD)) { /* Allocate new pmd */ - if (!(pmd = alloc_pmd())) + if (!(pmd = pmd_cap_alloc(¤t->space->cap_list))) goto out_error; /* Find original pmd */ @@ -359,7 +422,7 @@ out_error: phys_to_virt((to->entry[i] & PMD_ALIGN_MASK)); /* Free pmd */ - free_pmd(pmd); + pmd_cap_free(pmd, ¤t->space->cap_list); } } return -ENOMEM; @@ -385,7 +448,6 @@ void remap_as_pages(void *vstart, void *vend) unsigned long paddr = pstart; unsigned long vaddr = (unsigned long)vstart; int pmd_i = PMD_INDEX(vstart); - pgd_table_t *pgd = &init_pgd; pmd_table_t *pmd = alloc_boot_pmd(); int npages = __pfn(pend - pstart); int map_flags; @@ -408,7 +470,7 @@ void remap_as_pages(void *vstart, void *vend) vaddr += PAGE_SIZE; } - attach_pmd(pgd, pmd, (unsigned long)vstart); + attach_pmd(current->space, pmd, (unsigned long)vstart); printk("%s: Kernel area 0x%lx - 0x%lx " "remapped as %d pages\n", __KERNELNAME__, diff --git a/src/arch/arm/v5/mapping.c b/src/arch/arm/v5/mapping.c index 87f9224..c2a5d10 100644 --- a/src/arch/arm/v5/mapping.c +++ b/src/arch/arm/v5/mapping.c @@ -116,7 +116,7 @@ void arch_prepare_pte(u32 paddr, u32 vaddr, unsigned int flags, *ptep = paddr | flags | PTE_TYPE_SMALL; } -void arch_write_pte(pte_t *ptep, pte_t pte, u32 vaddr) +void arch_write_pte(pte_t *ptep, pte_t pte, u32 vaddr, u32 asid) { /* FIXME: * Clean the dcache and invalidate the icache @@ -143,7 +143,8 @@ void arch_write_pte(pte_t *ptep, pte_t pte, u32 vaddr) } -void arch_prepare_write_pte(u32 paddr, u32 vaddr, +void arch_prepare_write_pte(struct address_space *space, + u32 paddr, u32 vaddr, unsigned int flags, pte_t *ptep) { pte_t pte = 0; @@ -154,7 +155,7 @@ void arch_prepare_write_pte(u32 paddr, u32 vaddr, arch_prepare_pte(paddr, vaddr, flags, &pte); - arch_write_pte(ptep, pte, vaddr); + arch_write_pte(ptep, pte, vaddr, space->spid); } pmd_t * @@ -166,7 +167,7 @@ arch_pick_pmd(pgd_table_t *pgd, unsigned long vaddr) /* * v5 pmd writes */ -void arch_write_pmd(pmd_t *pmd_entry, u32 pmd_phys, u32 vaddr) +void arch_write_pmd(pmd_t *pmd_entry, u32 pmd_phys, u32 vaddr, u32 asid) { /* FIXME: Clean the dcache if there was a valid entry */ *pmd_entry = (pmd_t)(pmd_phys | PMD_TYPE_PMD); @@ -205,8 +206,10 @@ int is_global_pgdi(int i) extern pmd_table_t *pmd_array; -void remove_mapping_pgd_all_user(pgd_table_t *pgd) +void remove_mapping_pgd_all_user(struct address_space *space, + struct cap_list *clist) { + pgd_table_t *pgd = space->pgd; pmd_table_t *pmd; /* Traverse through all pgd entries. */ @@ -221,34 +224,22 @@ void remove_mapping_pgd_all_user(pgd_table_t *pgd) phys_to_virt((pgd->entry[i] & PMD_ALIGN_MASK)); /* Free it */ - free_pmd(pmd); + pmd_cap_free(pmd, clist); } /* Clear the pgd entry */ pgd->entry[i] = PMD_TYPE_FAULT; } } + /* FIXME: Flush tlbs here */ } - -int pgd_count_boot_pmds() -{ - int npmd = 0; - pgd_table_t *pgd = &init_pgd; - - for (int i = 0; i < PGD_ENTRY_TOTAL; i++) - if ((pgd->entry[i] & PMD_TYPE_MASK) == PMD_TYPE_PMD) - npmd++; - return npmd; -} - - /* * Jumps from boot pmd/pgd page tables to tables allocated from the cache. */ pgd_table_t *arch_realloc_page_tables(void) { - pgd_table_t *pgd_new = alloc_pgd(); + pgd_table_t *pgd_new = pgd_alloc(); pgd_table_t *pgd_old = &init_pgd; pmd_table_t *orig, *pmd; @@ -260,7 +251,7 @@ pgd_table_t *arch_realloc_page_tables(void) /* Detect a pmd entry */ if ((pgd_old->entry[i] & PMD_TYPE_MASK) == PMD_TYPE_PMD) { /* Allocate new pmd */ - if (!(pmd = alloc_pmd())) { + if (!(pmd = pmd_cap_alloc(¤t->space->cap_list))) { printk("FATAL: PMD allocation " "failed during system initialization\n"); BUG(); @@ -375,6 +366,9 @@ void idle_task(void) /* Do maintenance */ tcb_delete_zombies(); + /* Clear idle runnable flag */ + per_cpu(scheduler).flags &= ~SCHED_RUN_IDLE; + schedule(); } } diff --git a/src/arch/arm/v6/cpu_startup.c b/src/arch/arm/v6/cpu_startup.c index 3a4f980..c279bb6 100644 --- a/src/arch/arm/v6/cpu_startup.c +++ b/src/arch/arm/v6/cpu_startup.c @@ -28,7 +28,7 @@ void cpu_startup(void) //arm_set_cp15_cr(val); -#if defined (CONFIG_SMP) +#if defined (CONFIG_SMP_) /* Enable SCU*/ /* Enable SMP bit in CP15 */ #endif diff --git a/src/arch/arm/v6/mutex.c b/src/arch/arm/v6/mutex.c index 0a0b64f..ba096d9 100644 --- a/src/arch/arm/v6/mutex.c +++ b/src/arch/arm/v6/mutex.c @@ -26,7 +26,7 @@ void __spin_lock(unsigned int *s) "teq %0, #0\n" "strexeq %0, %1, [%2]\n" "teq %0, #0\n" -#ifdef CONFIG_SMP +#ifdef CONFIG_SMP_ "wfene\n" #endif "bne 1b\n" @@ -47,7 +47,7 @@ void __spin_unlock(unsigned int *s) : "memory" ); -#ifdef CONFIG_SMP +#ifdef CONFIG_SMP_ dsb(); __asm__ __volatile__ ("sev\n"); #endif diff --git a/src/arch/arm/vectors.S b/src/arch/arm/vectors.S index a5ac265..0475389 100644 --- a/src/arch/arm/vectors.S +++ b/src/arch/arm/vectors.S @@ -565,7 +565,7 @@ current_irq_nest_count: .word 0 .word 0 -#if defined (CONFIG_SMP) +#if defined (CONFIG_SMP_) @ Rx contains the address of per cpu variable .macro per_cpu adr, temp, varname get_cpuid \temp diff --git a/src/drivers/SConscript b/src/drivers/SConscript index 0ca81e6..eedb59f 100644 --- a/src/drivers/SConscript +++ b/src/drivers/SConscript @@ -1,32 +1,31 @@ -import os, sys, glob -PROJRELROOT = '../../' +import os +from os.path import join -sys.path.append(PROJRELROOT) - -from config.projpaths import * -from configure import * - -Import("env", "symbols", "platform", "bdir") +Import('env', 'bdir') src_local = [] objs = [] -for name, val in symbols: - if "CONFIG_DRIVER_UART_PL011" == name: - objs += SConscript("uart/pl011/SConscript", exports = {'env' : env}, duplicate=0, build_dir=bdir + 'pl011') - if "CONFIG_DRIVER_TIMER_SP804" == name: - objs += SConscript("timer/sp804/SConscript", exports = {'env' : env}, duplicate=0, build_dir=bdir + 'timer') - if "CONFIG_DRIVER_IRQ_PL190" == name: - objs += SConscript("irq/pl190/SConscript", exports = {'env' : env}, duplicate=0, build_dir=bdir + 'vic') - if "CONFIG_DRIVER_IRQ_GIC" == name: - objs += SConscript("irq/gic/SConscript", exports = {'env' : env}, duplicate=0, build_dir=bdir + 'gic') - if "CONFIG_DRIVER_INTC_OMAP" == name: - objs += SConscript("irq/omap3/SConscript", exports = {'env' : env}, duplicate=0, build_dir=bdir + '/omap/intc') - if "CONFIG_DRIVER_UART_OMAP" == name: - objs += SConscript("uart/omap/SConscript", exports = {'env' : env}, duplicate=0, build_dir=bdir + '/omap/uart') - if "CONFIG_DRIVER_TIMER_OMAP" == name: - objs += SConscript("timer/omap/SConscript", exports = {'env' : env}, duplicate=0, build_dir=bdir + '/omap/timer') +objs += SConscript("uart/pl011/SConscript", exports = { 'env' : env }, + duplicate=0, build_dir = join(bdir, 'pl011')) +objs += SConscript("timer/sp804/SConscript", exports = { 'env' : env }, + duplicate=0, build_dir = join(bdir, 'timer')) + +objs += SConscript("irq/pl190/SConscript", exports = { 'env' : env }, + duplicate=0, build_dir = join(bdir, 'vic')) + +objs += SConscript("irq/gic/SConscript", exports = { 'env' : env }, + duplicate=0, build_dir = join(bdir, 'gic')) + +objs += SConscript("irq/omap3/SConscript", exports = { 'env' : env }, + duplicate=0, build_dir = join(bdir, 'omap/intc')) + +objs += SConscript("uart/omap/SConscript", exports = { 'env' : env }, + duplicate=0, build_dir = join(bdir, 'omap/uart')) + +objs += SConscript("timer/omap/SConscript", exports = { 'env' : env }, + duplicate=0, build_dir = join(bdir, 'omap/timer')) Return('objs') diff --git a/src/drivers/irq/gic/SConscript b/src/drivers/irq/gic/SConscript index dac152b..623a871 100644 --- a/src/drivers/irq/gic/SConscript +++ b/src/drivers/irq/gic/SConscript @@ -1,17 +1,21 @@ -# Inherit global environment - -#import os, sys - -#PROJRELROOT = '../../../' - -#sys.path.append(PROJRELROOT) - -#from config.projpaths import * -#from configure import * Import('env') -# The set of source files associated with this SConscript file. -src_local = ['gic.c'] -obj = env.Object(src_local) +from scripts.config.projpaths import * +from scripts.config.config_invoke import * + +config = configuration_retrieve() +platform = config.platform + +# Platforms using GIC +plat_list = ('eb', 'pba9') + +# The set of source files associated with this SConscript file. +src_local = [] + +for plat_supported in plat_list: + if plat_supported == platform: + src_local += ['gic.c'] + +obj = env.Object(src_local) Return('obj') diff --git a/src/drivers/irq/omap3/SConscript b/src/drivers/irq/omap3/SConscript index ede27df..825401b 100644 --- a/src/drivers/irq/omap3/SConscript +++ b/src/drivers/irq/omap3/SConscript @@ -1,7 +1,20 @@ + Import('env') -# The set of source files associated with this SConscript file. -src_local = Glob('*.c') -obj = env.Object(src_local) +from scripts.config.projpaths import * +from scripts.config.config_invoke import * +config = configuration_retrieve() +platform = config.platform + +#Platforms using omap_intc +plat_list = 'beagle' + +# The set of source files associated with this SConscript file. +src_local = [] + +if plat_list == platform: + src_local += Glob('*.c') + +obj = env.Object(src_local) Return('obj') diff --git a/src/drivers/irq/pl190/SConscript b/src/drivers/irq/pl190/SConscript index a878bcc..2364e00 100644 --- a/src/drivers/irq/pl190/SConscript +++ b/src/drivers/irq/pl190/SConscript @@ -1,8 +1,20 @@ -# Inherit global environment Import('env') -# The set of source files associated with this SConscript file. -src_local = ['pl190_vic.c'] -obj = env.Object(src_local) +from scripts.config.projpaths import * +from scripts.config.config_invoke import * + +config = configuration_retrieve() +platform = config.platform + +# The set of source files associated with this SConscript file. +src_local = [] + +# Platforms using pl190 +plat_list = 'pb926' + +if plat_list == platform: + src_local += ['pl190_vic.c'] + +obj = env.Object(src_local) Return('obj') diff --git a/src/drivers/timer/omap/SConscript b/src/drivers/timer/omap/SConscript index c69a25c..4f67a40 100644 --- a/src/drivers/timer/omap/SConscript +++ b/src/drivers/timer/omap/SConscript @@ -1,7 +1,20 @@ + Import('env') -# The set of source files associated with this SConscript file. -src_local = ['timer.c'] -obj = env.Object(src_local) +from scripts.config.projpaths import * +from scripts.config.config_invoke import * +config = configuration_retrieve() +platform = config.platform + +# Platforms using omap_timer +plat_list = 'beagle' + +# The set of source files associated with this SConscript file. +src_local = [] + +if plat_list == platform: + src_local += ['timer.c'] + +obj = env.Object(src_local) Return('obj') diff --git a/src/drivers/timer/sp804/SConscript b/src/drivers/timer/sp804/SConscript index c69a25c..5da69da 100644 --- a/src/drivers/timer/sp804/SConscript +++ b/src/drivers/timer/sp804/SConscript @@ -1,7 +1,21 @@ + Import('env') -# The set of source files associated with this SConscript file. -src_local = ['timer.c'] -obj = env.Object(src_local) +from scripts.config.projpaths import * +from scripts.config.config_invoke import * +config = configuration_retrieve() +platform = config.platform + +# Platforms using sp804 timer +plat_list = ('eb', 'pba9', 'pb926') + +# The set of source files associated with this SConscript file. +src_local = [] + +for plat_supported in plat_list: + if plat_supported == platform: + src_local += ['timer.c'] + +obj = env.Object(src_local) Return('obj') diff --git a/src/drivers/uart/omap/SConscript b/src/drivers/uart/omap/SConscript index 84c1a71..751bd59 100644 --- a/src/drivers/uart/omap/SConscript +++ b/src/drivers/uart/omap/SConscript @@ -1,7 +1,20 @@ + Import('env') -# The set of source files associated with this SConscript file. -src_local = ['uart.c'] -obj = env.Object(src_local) +from scripts.config.projpaths import * +from scripts.config.config_invoke import * +config = configuration_retrieve() +platform = config.platform + +# Platforms using omap_uart +plat_list = 'beagle' + +# The set of source files associated with this SConscript file. +src_local = [] + +if plat_list == platform: + src_local += ['uart.c'] + +obj = env.Object(src_local) Return('obj') diff --git a/src/drivers/uart/pl011/SConscript b/src/drivers/uart/pl011/SConscript index 84c1a71..f1d1cde 100644 --- a/src/drivers/uart/pl011/SConscript +++ b/src/drivers/uart/pl011/SConscript @@ -1,7 +1,21 @@ + Import('env') -# The set of source files associated with this SConscript file. -src_local = ['uart.c'] -obj = env.Object(src_local) +from scripts.config.projpaths import * +from scripts.config.config_invoke import * +config = configuration_retrieve() +platform = config.platform + +# Platforms using pl011 uart +plat_list = ('eb', 'pba9', 'pb926') + +# The set of source files associated with this SConscript file. +src_local = [] + +for plat_supported in plat_list: + if plat_supported == platform: + src_local += ['uart.c'] + +obj = env.Object(src_local) Return('obj') diff --git a/src/generic/SConscript b/src/generic/SConscript index 3366d42..24e7fff 100644 --- a/src/generic/SConscript +++ b/src/generic/SConscript @@ -1,10 +1,28 @@ +import sys # Inherit global environment Import('env') +PROJROOT = '../..' +sys.path.append(PROJROOT) + +from scripts.kernel.generate_kernel_cinfo import* + # The set of source files associated with this SConscript file. -src_local = ['irq.c', 'scheduler.c', 'time.c', 'tcb.c', 'space.c', 'bootmem.c', 'resource.c', 'container.c', 'capability.c', 'cinfo.c', 'debug.c'] +src_local = ['irq.c', 'scheduler.c', 'time.c', 'tcb.c', 'space.c', + 'bootmem.c', 'resource.c', 'container.c', 'capability.c', + 'cinfo.c', 'debug.c', 'idle.c'] + +# Generate kernel cinfo structure for container definitions +def generate_cinfo(target, source, env): + generate_kernel_cinfo(target[0]) + return None + +cinfo_generator = Builder(action = generate_cinfo) +env.Append(BUILDERS = {'CINFO_GENERATOR' : cinfo_generator}) +env.CINFO_GENERATOR(KERNEL_CINFO_PATH, CONFIG_H) obj = env.Object(src_local) +Depends(obj, KERNEL_CINFO_PATH) Return('obj') diff --git a/src/generic/bootmem.c b/src/generic/bootmem.c index 85462fd..3e4b32a 100644 --- a/src/generic/bootmem.c +++ b/src/generic/bootmem.c @@ -16,15 +16,9 @@ */ #define BOOTMEM_SIZE (SZ_4K * 4) SECTION(".init.bootmem") char bootmem[BOOTMEM_SIZE]; -struct address_space init_space; static unsigned long cursor = (unsigned long)&bootmem; -unsigned long bootmem_free_pages(void) -{ - return BOOTMEM_SIZE - (page_align_up(cursor) - (unsigned long)&bootmem); -} - void *alloc_bootmem(int size, int alignment) { void *ptr; @@ -46,6 +40,9 @@ void *alloc_bootmem(int size, int alignment) /* Allocate from cursor */ ptr = (void *)cursor; + /* Zero initialize */ + memset(ptr, 0, size); + /* Update cursor */ cursor += size; diff --git a/src/generic/capability.c b/src/generic/capability.c index 6044015..0860ea5 100644 --- a/src/generic/capability.c +++ b/src/generic/capability.c @@ -19,6 +19,7 @@ #include #include INC_GLUE(message.h) #include INC_GLUE(ipc.h) +#include INC_PLAT(irq.h) void capability_init(struct capability *cap) { @@ -26,32 +27,13 @@ void capability_init(struct capability *cap) link_init(&cap->list); } -/* - * Boot-time function to create capability without - * capability checking - */ -struct capability *boot_capability_create(void) -{ - struct capability *cap = boot_alloc_capability(); - - capability_init(cap); - - return cap; -} - -struct capability *capability_create(void) -{ - struct capability *cap; - - if (!(cap = alloc_capability())) - return 0; - - capability_init(cap); - - return cap; -} #if defined(CONFIG_CAPABILITIES) + +/* + * FIXME: These need locking. A child can quit without + * pager's call. + */ int capability_consume(struct capability *cap, int quantity) { if (cap->size < cap->used + quantity) @@ -107,16 +89,11 @@ struct capability *cap_list_find_by_rtype(struct cap_list *cap_list, * In conclusion freeing of pool-type capabilities need to be done * in order of privacy. */ -struct capability *capability_find_by_rtype(struct ktcb *task, - unsigned int rtype) +struct capability *cap_find_by_rtype(struct ktcb *task, + unsigned int rtype) { struct capability *cap; - /* Search task's own list */ - list_foreach_struct(cap, &task->cap_list.caps, list) - if (cap_rtype(cap) == rtype) - return cap; - /* Search space list */ list_foreach_struct(cap, &task->space->cap_list.caps, list) if (cap_rtype(cap) == rtype) @@ -130,39 +107,9 @@ struct capability *capability_find_by_rtype(struct ktcb *task, return 0; } -struct capability *cap_find_by_capid(l4id_t capid, struct cap_list **cap_list) -{ - struct capability *cap; - struct ktcb *task = current; - - /* Search task's own list */ - list_foreach_struct(cap, &task->cap_list.caps, list) - if (cap->capid == capid) { - *cap_list = &task->cap_list; - return cap; - } - - /* Search space list */ - list_foreach_struct(cap, &task->space->cap_list.caps, list) - if (cap->capid == capid) { - *cap_list = &task->space->cap_list; - return cap; - } - - /* Search container list */ - list_foreach_struct(cap, &task->container->cap_list.caps, list) - if (cap->capid == capid) { - *cap_list = &task->container->cap_list; - return cap; - } - - return 0; -} - int cap_count(struct ktcb *task) { - return task->cap_list.ncaps + - task->space->cap_list.ncaps + + return task->space->cap_list.ncaps + task->container->cap_list.ncaps; } @@ -174,16 +121,10 @@ typedef struct capability *(*cap_match_func_t) \ * operation with a capability in a syscall-specific way. */ struct capability *cap_find(struct ktcb *task, cap_match_func_t cap_match_func, - void *match_args, unsigned int cap_type) + void *match_args, unsigned int cap_type) { struct capability *cap, *found; - /* Search task's own list */ - list_foreach_struct(cap, &task->cap_list.caps, list) - if (cap_type(cap) == cap_type && - ((found = cap_match_func(cap, match_args)))) - return found; - /* Search space list */ list_foreach_struct(cap, &task->space->cap_list.caps, list) if (cap_type(cap) == cap_type && @@ -199,129 +140,6 @@ struct capability *cap_find(struct ktcb *task, cap_match_func_t cap_match_func, return 0; } -struct sys_mutex_args { - unsigned long address; - unsigned int op; -}; - -/* - * Check broadly the ability to do mutex ops. Check it by - * the thread, space or container, (i.e. the group that can - * do this operation broadly) - * - * Note, that we check mutex_address elsewhere as a quick, - * per-task virt_to_phys translation that would not get - * easily/quickly satisfied by a memory capability checking. - * - * While this is not %100 right from a capability checking - * point-of-view, it is a shortcut that works and makes sense. - * - * For sake of completion, the right way to do it would be to - * add MUTEX_LOCKABLE, MUTEX_UNLOCKABLE attributes to both - * virtual and physical memory caps of a task, search those - * to validate the address. But we would have to translate - * from the page tables either ways. - */ -struct capability * -cap_match_mutex(struct capability *cap, void *args) -{ - /* Unconditionally expect these flags */ - unsigned int perms = CAP_UMUTEX_LOCK | CAP_UMUTEX_UNLOCK; - - if ((cap->access & perms) != perms) - return 0; - - /* Now check the usual restype/resid pair */ - switch (cap_rtype(cap)) { - case CAP_RTYPE_THREAD: - if (current->tid != cap->resid) - return 0; - break; - case CAP_RTYPE_SPACE: - if (current->space->spid != cap->resid) - return 0; - break; - case CAP_RTYPE_CONTAINER: - if (current->container->cid != cap->resid) - return 0; - break; - default: - BUG(); /* Unknown cap type is a bug */ - } - - return cap; -} - -struct sys_capctrl_args { - unsigned int req; - unsigned int flags; - struct ktcb *task; -}; - -struct capability * -cap_match_capctrl(struct capability *cap, void *args_ptr) -{ - struct sys_capctrl_args *args = args_ptr; - unsigned int req = args->req; - struct ktcb *target = args->task; - - /* Check operation privileges */ - switch (req) { - case CAP_CONTROL_NCAPS: - case CAP_CONTROL_READ: - if (!(cap->access & CAP_CAP_READ)) - return 0; - break; - case CAP_CONTROL_SHARE: - if (!(cap->access & CAP_CAP_SHARE)) - return 0; - break; - case CAP_CONTROL_GRANT: - if (!(cap->access & CAP_CAP_GRANT)) - return 0; - break; - case CAP_CONTROL_REPLICATE: - if (!(cap->access & CAP_CAP_REPLICATE)) - return 0; - break; - case CAP_CONTROL_SPLIT: - if (!(cap->access & CAP_CAP_SPLIT)) - return 0; - break; - case CAP_CONTROL_DEDUCE: - if (!(cap->access & CAP_CAP_DEDUCE)) - return 0; - break; - case CAP_CONTROL_DESTROY: - if (!(cap->access & CAP_CAP_DESTROY)) - return 0; - break; - default: - /* We refuse to accept anything else */ - return 0; - } - - /* Now check the usual restype/resid pair */ - switch (cap_rtype(cap)) { - case CAP_RTYPE_THREAD: - if (target->tid != cap->resid) - return 0; - break; - case CAP_RTYPE_SPACE: - if (target->space->spid != cap->resid) - return 0; - break; - case CAP_RTYPE_CONTAINER: - if (target->container->cid != cap->resid) - return 0; - break; - default: - BUG(); /* Unknown cap type is a bug */ - } - - return cap; -} - struct sys_ipc_args { struct ktcb *task; unsigned int ipc_type; @@ -664,73 +482,12 @@ struct capability *cap_match_mem(struct capability *cap, } struct sys_irqctrl_args { - struct ktcb *registrant; + struct ktcb *task; unsigned int req; unsigned int flags; l4id_t irq; }; -/* - * CAP_TYPE_MAP already matched upon entry. - * - * Match only device-specific details, e.g. irq registration - * capability - */ -struct capability *cap_match_devmem(struct capability *cap, - void *args_ptr) -{ - struct sys_irqctrl_args *args = args_ptr; - struct ktcb *target = args->registrant; - unsigned int perms; - - /* It must be a physmem type */ - if (cap_type(cap) != CAP_TYPE_MAP_PHYSMEM) - return 0; - - /* It must be a device */ - if (!cap_is_devmem(cap)) - return 0; - - /* Irq numbers should match */ - if (cap->irq != args->irq) - return 0; - - /* Check permissions, we only check irq specific */ - switch (args->req) { - case IRQ_CONTROL_REGISTER: - perms = CAP_IRQCTRL_REGISTER; - if ((cap->access & perms) != perms) - return 0; - break; - default: - /* Anything else is an invalid/unrecognised argument */ - return 0; - } - - /* - * Check that irq registration to target is covered - * by the capability containment rules. - */ - switch (cap_rtype(cap)) { - case CAP_RTYPE_THREAD: - if (target->tid != cap->resid) - return 0; - break; - case CAP_RTYPE_SPACE: - if (target->space->spid != cap->resid) - return 0; - break; - case CAP_RTYPE_CONTAINER: - if (target->container->cid != cap->resid) - return 0; - break; - default: - BUG(); /* Unknown cap type is a bug */ - } - - return cap; -} - /* * CAP_TYPE_IRQCTRL already matched */ @@ -738,7 +495,7 @@ struct capability *cap_match_irqctrl(struct capability *cap, void *args_ptr) { struct sys_irqctrl_args *args = args_ptr; - struct ktcb *target = args->registrant; + struct ktcb *target = args->task; /* Check operation privileges */ switch (args->req) { @@ -755,6 +512,11 @@ struct capability *cap_match_irqctrl(struct capability *cap, return 0; } + /* Irq number should match range */ + if (args->irq < cap->start && + args->irq > cap->end) + return 0; + /* * Target thread is the thread that is going to * handle the irqs. Check if capability matches @@ -828,35 +590,6 @@ struct capability *cap_match_cache(struct capability *cap, void *args_ptr) } #if defined(CONFIG_CAPABILITIES) -int cap_mutex_check(unsigned long mutex_address, int mutex_op) -{ - struct sys_mutex_args args = { - .address = mutex_address, - .op = mutex_op, - }; - - if (!(cap_find(current, cap_match_mutex, - &args, CAP_TYPE_UMUTEX))) - return -ENOCAP; - - return 0; -} - -int cap_cap_check(struct ktcb *task, unsigned int req, unsigned int flags) -{ - struct sys_capctrl_args args = { - .req = req, - .flags = flags, - .task = task, - }; - - if (!(cap_find(current, cap_match_capctrl, - &args, CAP_TYPE_CAP))) - return -ENOCAP; - - return 0; -} - int cap_map_check(struct ktcb *target, unsigned long phys, unsigned long virt, unsigned long npages, unsigned int flags) { @@ -967,11 +700,11 @@ int cap_thread_check(struct ktcb *task, } -int cap_irq_check(struct ktcb *registrant, unsigned int req, +int cap_irq_check(struct ktcb *task, unsigned int req, unsigned int flags, l4id_t irq) { struct sys_irqctrl_args args = { - .registrant = registrant, + .task = task, .req = req, .flags = flags, .irq = irq, @@ -981,15 +714,6 @@ int cap_irq_check(struct ktcb *registrant, unsigned int req, if (!(cap_find(current, cap_match_irqctrl, &args, CAP_TYPE_IRQCTRL))) return -ENOCAP; - - /* - * If it is an irq registration, find the device - * capability and check that it allows irq registration. - */ - if (req == IRQ_CONTROL_REGISTER) - if (!cap_find(current, cap_match_devmem, - &args, CAP_TYPE_MAP_PHYSMEM)) - return -ENOCAP; return 0; } @@ -1019,16 +743,6 @@ int cap_cache_check(unsigned long start, unsigned long end, unsigned int flags) } #else /* Meaning !CONFIG_CAPABILITIES */ -int cap_mutex_check(unsigned long mutex_address, int mutex_op) -{ - return 0; -} - -int cap_cap_check(struct ktcb *task, unsigned int req, unsigned int flags) -{ - return 0; -} - int cap_ipc_check(l4id_t to, l4id_t from, unsigned int flags, unsigned int ipc_type) { diff --git a/src/generic/container.c b/src/generic/container.c index 3b14658..a0d7ed0 100644 --- a/src/generic/container.c +++ b/src/generic/container.c @@ -15,8 +15,11 @@ #include INC_SUBARCH(mm.h) #include INC_ARCH(linker.h) -int container_init(struct container *c) +struct container *container_alloc_init() { + /* Allocate container */ + struct container *c = alloc_bootmem(sizeof(*c), 0); + /* Allocate new container id */ c->cid = id_new(&kernel_resources.container_ids); @@ -34,15 +37,6 @@ int container_init(struct container *c) cap_list_init(&c->pager[i].cap_list); - return 0; -} - -struct container *container_create(void) -{ - struct container *c = alloc_container(); - - container_init(c); - return c; } @@ -70,6 +64,63 @@ struct container *container_find(struct kernel_resources *kres, l4id_t cid) return 0; } +/* + * Map pagers based on section flags + */ +void map_pager_sections(struct pager *pager, struct container *cont, + struct ktcb *task) +{ + unsigned long size_rx = 0; + unsigned long size_rw = 0; + + if ((size_rx = page_align_up(pager->rx_pheader_end) - + pager->rx_pheader_start) >= PAGE_SIZE) { + printk("%s: Mapping 0x%lx bytes as RX " + "from 0x%lx physical to 0x%lx virtual for %s\n", + __KERNELNAME__, size_rx, + (pager->rx_pheader_start - + pager->start_vma + pager->start_lma), + pager->rx_pheader_start, cont->name); + + add_mapping_space((pager->rx_pheader_start - pager->start_vma + + pager->start_lma), + pager->rx_pheader_start, size_rx, + MAP_USR_RX, task->space); + } + + if ((size_rw = page_align_up(pager->rw_pheader_end) - + pager->rw_pheader_start) >= PAGE_SIZE) { + printk("%s: Mapping 0x%lx bytes as RW " + "from 0x%lx physical to 0x%lx virtual for %s\n", + __KERNELNAME__, size_rw, + (pager->rw_pheader_start - + pager->start_vma + pager->start_lma), + pager->rw_pheader_start, cont->name); + + add_mapping_space((pager->rw_pheader_start - pager->start_vma + + pager->start_lma), + pager->rw_pheader_start, size_rw, + MAP_USR_RW, task->space); + } + + /* + * If no RX, RW sections are there, map full image as RWX + * TODO: This doesnot look like the best way. + */ + if (!size_rx && !size_rw) { + printk("%s: Mapping 0x%lx bytes (%lu pages) " + "from 0x%lx to 0x%lx for %s\n", + __KERNELNAME__, pager->memsize, + __pfn(page_align_up(pager->memsize)), + pager->start_lma, pager->start_vma, cont->name); + + /* Map the task's space */ + add_mapping_space(pager->start_lma, pager->start_vma, + page_align_up(pager->memsize), + MAP_USR_RWX, task->space); + } +} + /* * TODO: * @@ -96,7 +147,7 @@ int init_pager(struct pager *pager, struct container *cont) * can be done to this pager. Note, that we're still on * idle task stack. */ - cap_list_move(¤t->cap_list, &pager->cap_list); + cap_list_move(¤t->space->cap_list, &pager->cap_list); /* Setup dummy container pointer so that curcont works */ current->container = cont; @@ -111,7 +162,7 @@ int init_pager(struct pager *pager, struct container *cont) task_init_registers(task, pager->start_address); /* Initialize container/pager relationships */ - task->pagerid = task->tid; + task->pager = task; task->tgid = task->tid; task->container = cont; @@ -121,72 +172,11 @@ int init_pager(struct pager *pager, struct container *cont) /* Add the address space to container space list */ address_space_add(task->space); -#if 0 - printk("%s: Mapping 0x%lx bytes (%lu pages) " - "from 0x%lx to 0x%lx for %s\n", - __KERNELNAME__, pager->memsize, - __pfn(page_align_up(pager->memsize)), - pager->start_lma, pager->start_vma, cont->name); - - /* Map the task's space */ - add_mapping_pgd(pager->start_lma, pager->start_vma, - page_align_up(pager->memsize), - MAP_USR_RWX, TASK_PGD(task)); -#else - /* - * Map pager with appropriate section flags - * We do page_align_down() to do a page alignment for - * various kinds of sections, this automatically - * takes care of the case where we have different kinds of - * data lying on same page, eg: RX, RO etc. - * Here one assumption made is, starting of first - * RW section will be already page aligned, if this is - * not true then we have to take special care of this. - */ - if(pager->rx_sections_end >= pager->rw_sections_start) { - pager->rx_sections_end = page_align(pager->rx_sections_end); - pager->rw_sections_start = page_align(pager->rw_sections_start); - } - - unsigned long size = 0; - if((size = page_align_up(pager->rx_sections_end) - - page_align_up(pager->rx_sections_start))) { - add_mapping_pgd(page_align_up(pager->rx_sections_start - - pager->start_vma + - pager->start_lma), - page_align_up(pager->rx_sections_start), - size, MAP_USR_RX, TASK_PGD(task)); - - printk("%s: Mapping 0x%lx bytes as RX " - "from 0x%lx to 0x%lx for %s\n", - __KERNELNAME__, size, - page_align_up(pager->rx_sections_start - - pager->start_vma + pager->start_lma), - page_align_up(pager->rx_sections_start), - cont->name); - } - - if((size = page_align_up(pager->rw_sections_end) - - page_align_up(pager->rw_sections_start))) { - add_mapping_pgd(page_align_up(pager->rw_sections_start - - pager->start_vma + - pager->start_lma), - page_align_up(pager->rw_sections_start), - size, MAP_USR_RW, TASK_PGD(task)); - - printk("%s: Mapping 0x%lx bytes as RW " - "from 0x%lx to 0x%lx for %s\n", - __KERNELNAME__, size, - page_align_up(pager->rw_sections_start - - pager->start_vma + pager->start_lma), - page_align_up(pager->rw_sections_start), - cont->name); - } - -#endif + /* Map various pager sections based on section flags */ + map_pager_sections(pager, cont, task); /* Move capability list from dummy to task's space cap list */ - cap_list_move(&task->space->cap_list, ¤t->cap_list); + cap_list_move(&task->space->cap_list, ¤t->space->cap_list); /* Initialize task scheduler parameters */ sched_init_task(task, TASK_PRIO_PAGER); diff --git a/src/generic/idle.c b/src/generic/idle.c new file mode 100644 index 0000000..f1cdd63 --- /dev/null +++ b/src/generic/idle.c @@ -0,0 +1,72 @@ +/* + * Idle task initialization and maintenance + * + * Copyright (C) 2010 B Labs Ltd. + * Author: Bahadir Balban + */ + +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(mapping.h) + +/* + * Set up current stack's beginning, and initial page tables + * as a valid task environment for idle task for current cpu + * + * Note, container pointer is initialized later when + * containers are in shape. + */ +void setup_idle_task() +{ + memset(current, 0, sizeof(struct ktcb)); + + current->space = &kernel_resources.init_space; + TASK_PGD(current) = &init_pgd; + + /* Initialize space caps list */ + cap_list_init(¤t->space->cap_list); + + /* Init scheduler structs */ + sched_init_task(current, TASK_PRIO_NORMAL); + + /* Set up never-to-be used fields as invalid for precaution */ + current->pager = 0; + current->tgid = -1; + + /* + * Set pointer to global kernel page tables. + * This is required early for early-stage pgd mappings + */ +#if defined(CONFIG_SUBARCH_V7) + kernel_resources.pgd_global = &init_global_pgd; +#endif + +} + +void secondary_idle_task_init(void) +{ + /* This also has its spid allocated by primary */ + current->space = &kernel_resources.init_space; + TASK_PGD(current) = &init_pgd; + + /* Need to assign a thread id */ + current->tid = id_new(&kernel_resources.ktcb_ids); + + /* Set affinity */ + current->affinity = smp_get_cpuid(); + + /* Set up never-to-be used fields as invalid for precaution */ + current->pager = 0; + current->tgid = -1; + + /* Init scheduler structs */ + sched_init_task(current, TASK_PRIO_NORMAL); + + sched_resume_async(current); +} + diff --git a/src/generic/resource.c b/src/generic/resource.c index b3cec20..76bffde 100644 --- a/src/generic/resource.c +++ b/src/generic/resource.c @@ -16,20 +16,21 @@ #include INC_ARCH(linker.h) #include INC_PLAT(platform.h) #include +#include struct kernel_resources kernel_resources; -pgd_table_t *alloc_pgd(void) +pgd_table_t *pgd_alloc(void) { return mem_cache_zalloc(kernel_resources.pgd_cache); } -pmd_table_t *alloc_pmd(void) +pmd_table_t *pmd_cap_alloc(struct cap_list *clist) { struct capability *cap; - if (!(cap = capability_find_by_rtype(current, - CAP_RTYPE_MAPPOOL))) + if (!(cap = cap_list_find_by_rtype(clist, + CAP_RTYPE_MAPPOOL))) return 0; if (capability_consume(cap, 1) < 0) @@ -38,12 +39,12 @@ pmd_table_t *alloc_pmd(void) return mem_cache_zalloc(kernel_resources.pmd_cache); } -struct address_space *alloc_space(void) +struct address_space *space_cap_alloc(struct cap_list *clist) { struct capability *cap; - if (!(cap = capability_find_by_rtype(current, - CAP_RTYPE_SPACEPOOL))) + if (!(cap = cap_list_find_by_rtype(clist, + CAP_RTYPE_SPACEPOOL))) return 0; if (capability_consume(cap, 1) < 0) @@ -52,20 +53,12 @@ struct address_space *alloc_space(void) return mem_cache_zalloc(kernel_resources.space_cache); } -struct ktcb *alloc_ktcb_use_capability(struct capability *cap) -{ - if (capability_consume(cap, 1) < 0) - return 0; - - return mem_cache_zalloc(kernel_resources.ktcb_cache); -} - -struct ktcb *alloc_ktcb(void) +struct ktcb *ktcb_cap_alloc(struct cap_list *clist) { struct capability *cap; - if (!(cap = capability_find_by_rtype(current, - CAP_RTYPE_THREADPOOL))) + if (!(cap = cap_list_find_by_rtype(clist, + CAP_RTYPE_THREADPOOL))) return 0; if (capability_consume(cap, 1) < 0) @@ -74,42 +67,12 @@ struct ktcb *alloc_ktcb(void) return mem_cache_zalloc(kernel_resources.ktcb_cache); } -/* - * This version is boot-time only and it has no - * capability checking. Imagine the case where the - * initial capabilities are created and there is no - * capability to check this allocation. - */ -struct capability *boot_alloc_capability(void) -{ - return mem_cache_zalloc(kernel_resources.cap_cache); -} - -struct capability *alloc_capability(void) +struct mutex_queue *mutex_cap_alloc() { struct capability *cap; - if (!(cap = capability_find_by_rtype(current, - CAP_RTYPE_CAPPOOL))) - return 0; - - if (capability_consume(cap, 1) < 0) - return 0; - - return mem_cache_zalloc(kernel_resources.cap_cache); -} - -struct container *alloc_container(void) -{ - return mem_cache_zalloc(kernel_resources.cont_cache); -} - -struct mutex_queue *alloc_user_mutex(void) -{ - struct capability *cap; - - if (!(cap = capability_find_by_rtype(current, - CAP_RTYPE_MUTEXPOOL))) + if (!(cap = cap_find_by_rtype(current, + CAP_RTYPE_MUTEXPOOL))) return 0; if (capability_consume(cap, 1) < 0) @@ -118,28 +81,28 @@ struct mutex_queue *alloc_user_mutex(void) return mem_cache_zalloc(kernel_resources.mutex_cache); } -void free_pgd(void *addr) +void pgd_free(void *addr) { BUG_ON(mem_cache_free(kernel_resources.pgd_cache, addr) < 0); } -void free_pmd(void *addr) +void pmd_cap_free(void *addr, struct cap_list *clist) { struct capability *cap; - BUG_ON(!(cap = capability_find_by_rtype(current, - CAP_RTYPE_MAPPOOL))); + BUG_ON(!(cap = cap_list_find_by_rtype(clist, + CAP_RTYPE_MAPPOOL))); capability_free(cap, 1); BUG_ON(mem_cache_free(kernel_resources.pmd_cache, addr) < 0); } -void free_space(void *addr, struct ktcb *task) +void space_cap_free(void *addr, struct cap_list *clist) { struct capability *cap; - BUG_ON(!(cap = capability_find_by_rtype(task, - CAP_RTYPE_SPACEPOOL))); + BUG_ON(!(cap = cap_list_find_by_rtype(clist, + CAP_RTYPE_SPACEPOOL))); capability_free(cap, 1); BUG_ON(mem_cache_free(kernel_resources.space_cache, addr) < 0); @@ -150,40 +113,24 @@ void free_space(void *addr, struct ktcb *task) * Account it to pager, but if it doesn't exist, * to current idle task */ -void free_ktcb(void *addr, struct ktcb *acc_task) +void ktcb_cap_free(void *addr, struct cap_list *clist) { struct capability *cap; /* Account it to task's pager if it exists */ - BUG_ON(!(cap = capability_find_by_rtype(acc_task, - CAP_RTYPE_THREADPOOL))); + BUG_ON(!(cap = cap_list_find_by_rtype(clist, + CAP_RTYPE_THREADPOOL))); capability_free(cap, 1); BUG_ON(mem_cache_free(kernel_resources.ktcb_cache, addr) < 0); } -void free_capability(void *addr) +void mutex_cap_free(void *addr) { struct capability *cap; - BUG_ON(!(cap = capability_find_by_rtype(current, - CAP_RTYPE_CAPPOOL))); - capability_free(cap, 1); - - BUG_ON(mem_cache_free(kernel_resources.cap_cache, addr) < 0); -} - -void free_container(void *addr) -{ - BUG_ON(mem_cache_free(kernel_resources.cont_cache, addr) < 0); -} - -void free_user_mutex(void *addr) -{ - struct capability *cap; - - BUG_ON(!(cap = capability_find_by_rtype(current, - CAP_RTYPE_MUTEXPOOL))); + BUG_ON(!(cap = cap_find_by_rtype(current, + CAP_RTYPE_MUTEXPOOL))); capability_free(cap, 1); BUG_ON(mem_cache_free(kernel_resources.mutex_cache, addr) < 0); @@ -307,7 +254,7 @@ int memcap_unmap(struct cap_list *used_list, return 0; } } - ret = -EEXIST; + return -EEXIST; out_err: if (ret == -ENOMEM) @@ -321,232 +268,48 @@ out_err: "Virtual" : "Physical", __pfn_to_addr(cap->start), __pfn_to_addr(cap->end)); - else if (ret == -EEXIST) - printk("%s: FATAL: %s memory capability range " - "does not match with any available free range. " - "start=0x%lx, end=0x%lx\n", __KERNELNAME__, - cap_type(cap) == CAP_TYPE_MAP_VIRTMEM ? - "Virtual" : "Physical", - __pfn_to_addr(cap->start), - __pfn_to_addr(cap->end)); BUG(); } /* - * Finds a device memory capability and deletes it from - * the available device capabilities list + * Copies cap_info structures to real capabilities in a list */ -int memcap_request_device(struct cap_list *cap_list, - struct cap_info *devcap) +void copy_cap_info(struct cap_list *clist, struct cap_info *cap_info, int ncaps) { - struct capability *cap, *n; + struct capability *cap; + struct cap_info *cinfo; - list_foreach_removable_struct(cap, n, &cap_list->caps, list) { - if (cap->start == devcap->start && - cap->end == devcap->end && - cap_is_devmem(cap)) { - /* Unlink only. This is boot memory */ - list_remove(&cap->list); - return 0; - } + for (int i = 0; i < ncaps; i++) { + cinfo = &cap_info[i]; + cap = alloc_bootmem(sizeof(*cap), 0); + + cap->resid = cinfo->target; + cap->type = cinfo->type; + cap->access = cinfo->access; + cap->start = cinfo->start; + cap->end = cinfo->end; + cap->size = cinfo->size; + + cap_list_insert(cap, clist); } - printk("%s: FATAL: Device memory requested " - "does not match any available device " - "capabilities start=0x%lx, end=0x%lx " - "attr=0x%x\n", __KERNELNAME__, - __pfn_to_addr(devcap->start), - __pfn_to_addr(devcap->end), devcap->attr); - BUG(); } -/* - * TODO: Evaluate if access bits are needed and add new cap ranges - * only if their access bits match. - * - * Maps a memory range as a capability to a list of capabilities either by - * merging the given range to an existing capability or creating a new one. - */ -int memcap_map(struct cap_list *cap_list, - const unsigned long map_start, - const unsigned long map_end) -{ - struct capability *cap, *n; - - list_foreach_removable_struct(cap, n, &cap_list->caps, list) { - if (cap->start == map_end) { - cap->start = map_start; - return 0; - } else if(cap->end == map_start) { - cap->end = map_end; - return 0; - } - } - - /* No capability could be extended, we create a new one */ - cap = alloc_capability(); - cap->start = map_start; - cap->end = map_end; - link_init(&cap->list); - cap_list_insert(cap, cap_list); - - return 0; -} - -/* Delete all boot memory and add it to physical memory pool. */ -int free_boot_memory(struct kernel_resources *kres) -{ - struct container *c; - unsigned long pfn_start = - __pfn(virt_to_phys(_start_init)); - unsigned long pfn_end = - __pfn(page_align_up(virt_to_phys(_end_init))); - unsigned long init_pfns = pfn_end - pfn_start; - - /* Trim kernel used memory cap */ - memcap_unmap(0, &kres->physmem_used, pfn_start, pfn_end); - - /* Add it to unused physical memory */ - memcap_map(&kres->physmem_free, pfn_start, pfn_end); - - /* Remove the init memory from the page tables */ - for (unsigned long i = pfn_start; i < pfn_end; i++) - remove_mapping(phys_to_virt(__pfn_to_addr(i))); - - /* Reset pointers that will remain in system as precaution */ - list_foreach_struct(c, &kres->containers.list, list) - c->pager = 0; - - printk("%s: Freed %lu KB init memory, " - "of which %lu KB was used.\n", - __KERNELNAME__, init_pfns * 4, - (init_pfns - - __pfn(page_align_up(bootmem_free_pages()))) * 4); - - return 0; -} - -/* - * Initializes kernel caplists, and sets up total of physical - * and virtual memory as single capabilities of the kernel. - * They will then get split into caps of different lengths - * during the traversal of container capabilities, and memcache - * allocations. - */ -void init_kernel_resources(struct kernel_resources *kres) -{ - struct capability *physmem, *virtmem, *kernel_area; - - /* Initialize system id pools */ - kres->space_ids.nwords = SYSTEM_IDS_MAX; - kres->ktcb_ids.nwords = SYSTEM_IDS_MAX; - kres->resource_ids.nwords = SYSTEM_IDS_MAX; - kres->container_ids.nwords = SYSTEM_IDS_MAX; - kres->mutex_ids.nwords = SYSTEM_IDS_MAX; - kres->capability_ids.nwords = SYSTEM_IDS_MAX; - - /* Initialize container head */ - container_head_init(&kres->containers); - - /* Initialize kernel capability lists */ - cap_list_init(&kres->physmem_used); - cap_list_init(&kres->physmem_free); - cap_list_init(&kres->virtmem_used); - cap_list_init(&kres->virtmem_free); - cap_list_init(&kres->devmem_used); - cap_list_init(&kres->devmem_free); - cap_list_init(&kres->non_memory_caps); - - /* Set up total physical memory as single capability */ - physmem = alloc_bootmem(sizeof(*physmem), 0); - physmem->start = __pfn(PLATFORM_PHYS_MEM_START); - physmem->end = __pfn(PLATFORM_PHYS_MEM_END); - link_init(&physmem->list); - cap_list_insert(physmem, &kres->physmem_free); - - /* Set up total virtual memory as single capability */ - virtmem = alloc_bootmem(sizeof(*virtmem), 0); - virtmem->start = __pfn(VIRT_MEM_START); - virtmem->end = __pfn(VIRT_MEM_END); - link_init(&virtmem->list); - cap_list_insert(virtmem, &kres->virtmem_free); - - /* Set up kernel used area as a single capability */ - kernel_area = alloc_bootmem(sizeof(*physmem), 0); - kernel_area->start = __pfn(virt_to_phys(_start_kernel)); - kernel_area->end = __pfn(virt_to_phys(_end_kernel)); - link_init(&kernel_area->list); - cap_list_insert(kernel_area, &kres->physmem_used); - - /* Unmap kernel used area from free physical memory capabilities */ - memcap_unmap(0, &kres->physmem_free, kernel_area->start, - kernel_area->end); - - /* Set up platform-specific device capabilities */ - platform_setup_device_caps(kres); - - /* TODO: - * Add all virtual memory areas used by the kernel - * e.g. kernel virtual area, syscall page, kip page, - * vectors page, timer, sysctl and uart device pages - */ -} - /* * Copies cinfo structures to real capabilities for each pager. */ int copy_pager_info(struct pager *pager, struct pager_info *pinfo) { - struct capability *cap; - struct cap_info *cap_info; pager->start_address = pinfo->start_address; pager->start_lma = __pfn_to_addr(pinfo->pager_lma); pager->start_vma = __pfn_to_addr(pinfo->pager_vma); pager->memsize = __pfn_to_addr(pinfo->pager_size); - pager->rw_sections_start = pinfo->rw_sections_start; - pager->rw_sections_end = pinfo->rw_sections_end; - pager->rx_sections_start = pinfo->rx_sections_start; - pager->rx_sections_end = pinfo->rx_sections_end; + pager->rw_pheader_start = pinfo->rw_pheader_start; + pager->rw_pheader_end = pinfo->rw_pheader_end; + pager->rx_pheader_start = pinfo->rx_pheader_start; + pager->rx_pheader_end = pinfo->rx_pheader_end; - /* Copy all cinfo structures into real capabilities */ - for (int i = 0; i < pinfo->ncaps; i++) { - cap = boot_capability_create(); - - cap_info = &pinfo->caps[i]; - - cap->resid = cap_info->target; - cap->type = cap_info->type; - cap->access = cap_info->access; - cap->start = cap_info->start; - cap->end = cap_info->end; - cap->size = cap_info->size; - cap->attr = cap_info->attr; - cap->irq = cap_info->irq; - - cap_list_insert(cap, &pager->cap_list); - } - - /* - * Check if pager has enough resources to create its caps: - * - * Find pager's capability capability, check its - * current use count and initialize it - */ - cap = cap_list_find_by_rtype(&pager->cap_list, - CAP_RTYPE_CAPPOOL); - - /* Verify that we did not excess allocated */ - if (!cap || cap->size < pinfo->ncaps) { - printk("FATAL: Pager needs more capabilities " - "than allocated for initialization.\n"); - BUG(); - } - - /* - * Initialize used count. The rest of the spending - * checks on this cap will be done in the cap syscall - */ - cap->used = pinfo->ncaps; + copy_cap_info(&pager->cap_list, pinfo->caps, pinfo->ncaps); return 0; } @@ -560,144 +323,16 @@ int copy_container_info(struct container *c, struct container_info *cinfo) strncpy(c->name, cinfo->name, CONFIG_CONTAINER_NAMESIZE); c->npagers = cinfo->npagers; - /* Copy capabilities */ + /* Copy container capabilities */ + copy_cap_info(&c->cap_list, cinfo->caps, cinfo->ncaps); + + /* Copy pager capabilities and boot info */ for (int i = 0; i < c->npagers; i++) copy_pager_info(&c->pager[i], &cinfo->pager[i]); return 0; } -/* - * Copy boot-time allocated kernel capabilities to ones that - * are allocated from the capability memcache - */ -void copy_boot_capabilities(struct cap_list *caplist) -{ - struct capability *bootcap, *n, *realcap; - - /* For every bootmem-allocated capability */ - list_foreach_removable_struct(bootcap, n, - &caplist->caps, - list) { - /* Create new one from capability cache */ - realcap = capability_create(); - - /* Copy all fields except id to real */ - realcap->owner = bootcap->owner; - realcap->resid = bootcap->resid; - realcap->type = bootcap->type; - realcap->access = bootcap->access; - realcap->start = bootcap->start; - realcap->end = bootcap->end; - realcap->size = bootcap->size; - realcap->attr = bootcap->attr; - realcap->irq = bootcap->irq; - - /* Unlink boot one */ - list_remove(&bootcap->list); - - /* Add real one to head */ - list_insert(&realcap->list, - &caplist->caps); - } -} - -/* - * Creates capabilities allocated with a real id, and from the - * capability cache, in place of ones allocated at boot-time. - */ -void setup_kernel_resources(struct boot_resources *bootres, - struct kernel_resources *kres) -{ - struct capability *cap; - struct container *container; - //pgd_table_t *current_pgd; - - /* First initialize the list of non-memory capabilities */ - cap = boot_capability_create(); - cap->type = CAP_TYPE_QUANTITY | CAP_RTYPE_MAPPOOL; - cap->size = bootres->nkpmds; - cap->owner = kres->cid; - cap_list_insert(cap, &kres->non_memory_caps); - - cap = boot_capability_create(); - cap->type = CAP_TYPE_QUANTITY | CAP_RTYPE_SPACEPOOL; - cap->size = bootres->nkpgds; - cap->owner = kres->cid; - cap_list_insert(cap, &kres->non_memory_caps); - - cap = boot_capability_create(); - cap->type = CAP_TYPE_QUANTITY | CAP_RTYPE_CAPPOOL; - cap->size = bootres->nkcaps; - cap->owner = kres->cid; - cap->used = 3; - cap_list_insert(cap, &kres->non_memory_caps); - - /* Set up dummy current cap-list for below functions to use */ - cap_list_move(¤t->cap_list, &kres->non_memory_caps); - - copy_boot_capabilities(&kres->physmem_used); - copy_boot_capabilities(&kres->physmem_free); - copy_boot_capabilities(&kres->virtmem_used); - copy_boot_capabilities(&kres->virtmem_free); - copy_boot_capabilities(&kres->devmem_used); - copy_boot_capabilities(&kres->devmem_free); - - /* - * Move to real page tables, accounted by - * pgds and pmds provided from the caches - * - * We do not want to delay this too much, - * since we want to avoid allocating an uncertain - * amount of memory from the boot allocators. - */ - // current_pgd = arch_realloc_page_tables(); - - /* Move it back */ - cap_list_move(&kres->non_memory_caps, ¤t->cap_list); - - - /* - * Setting up ids used internally. - * - * See how many containers we have. Assign next - * unused container id for kernel resources - */ - kres->cid = id_get(&kres->container_ids, bootres->nconts + 1); - // kres->cid = id_get(&kres->container_ids, 0); // Gets id 0 - - /* - * Assign thread and space ids to current which will later - * become the idle task - */ - current->tid = id_new(&kres->ktcb_ids); - current->space->spid = id_new(&kres->space_ids); - - /* - * Init per-cpu zombie lists - */ - for (int i = 0; i < CONFIG_NCPU; i++) - init_ktcb_list(&per_cpu_byid(kres->zombie_list, i)); - - /* - * Create real containers from compile-time created - * cinfo structures - */ - for (int i = 0; i < bootres->nconts; i++) { - /* Allocate & init container */ - container = container_create(); - - /* Fill in its information */ - copy_container_info(container, &cinfo[i]); - - /* Add it to kernel resources list */ - kres_insert_container(container, kres); - } - - /* Initialize pagers */ - container_init_pagers(kres); -} - /* * Given a structure size and numbers, it initializes a memory cache * using free memory available from free kernel memory capabilities. @@ -732,9 +367,9 @@ struct mem_cache *init_resource_cache(int nstruct, int struct_size, page_align_up(bufsize), MAP_KERN_RW); } else { - add_mapping_pgd(__pfn_to_addr(cap->start), - virtual, page_align_up(bufsize), - MAP_KERN_RW, &init_pgd); + add_mapping_space(__pfn_to_addr(cap->start), + virtual, page_align_up(bufsize), + MAP_KERN_RW, current->space); } /* Unmap area from memcap */ memcap_unmap_range(cap, &kres->physmem_free, @@ -761,19 +396,12 @@ struct mem_cache *init_resource_cache(int nstruct, int struct_size, void init_resource_allocators(struct boot_resources *bootres, struct kernel_resources *kres) { - /* - * An extra space reserved for kernel - * in case all containers quit - */ - bootres->nspaces++; - bootres->nkpgds++; - /* Initialise PGD cache */ kres->pgd_cache = init_resource_cache(bootres->nspaces, PGD_SIZE, kres, 1); - /* Initialise struct address_space cache */ + /* Initialise address space cache */ kres->space_cache = init_resource_cache(bootres->nspaces, sizeof(struct address_space), @@ -789,48 +417,6 @@ void init_resource_allocators(struct boot_resources *bootres, init_resource_cache(bootres->nmutex, sizeof(struct mutex_queue), kres, 0); - /* Initialise container cache */ - kres->cont_cache = - init_resource_cache(bootres->nconts, - sizeof(struct container), - kres, 0); - - /* - * Add all caps used by the kernel - * Two extra in case more memcaps get split after - * cap cache init below. Three extra for quantitative - * kernel caps for pmds, pgds, caps. - */ - bootres->nkcaps += kres->virtmem_used.ncaps + - kres->virtmem_free.ncaps + - kres->physmem_used.ncaps + - kres->physmem_free.ncaps + - kres->devmem_free.ncaps + - kres->devmem_used.ncaps + 2 + 3; - - /* Add that to all cap count */ - bootres->ncaps += bootres->nkcaps; - - /* Initialise capability cache */ - kres->cap_cache = - init_resource_cache(bootres->ncaps, - sizeof(struct capability), - kres, 0); - - /* Count boot pmds used so far and add them */ - bootres->nkpmds += pgd_count_boot_pmds(); - - /* - * Calculate maximum possible pmds that may be used - * during this pmd cache initialization and add them. - */ - bootres->nkpmds += ((bootres->npmds * PMD_SIZE) / PMD_MAP_SIZE); - if (!is_aligned(bootres->npmds * PMD_SIZE, - PMD_MAP_SIZE)) - bootres->nkpmds++; - - /* Add kernel pmds to all pmd count */ - bootres->npmds += bootres->nkpmds; /* Initialise PMD cache */ kres->pmd_cache = @@ -867,11 +453,6 @@ int process_cap_info(struct cap_info *cap, /* Speficies how many pmds can be mapped */ bootres->npmds += cap->size; break; - - case CAP_RTYPE_CAPPOOL: - /* Specifies how many new caps can be created */ - bootres->ncaps += cap->size; - break; } if (cap_type(cap) == CAP_TYPE_MAP_VIRTMEM) { @@ -879,50 +460,57 @@ int process_cap_info(struct cap_info *cap, &kres->virtmem_free, cap->start, cap->end); } else if (cap_type(cap) == CAP_TYPE_MAP_PHYSMEM) { - if (!cap_is_devmem(cap)) - memcap_unmap(&kres->physmem_used, - &kres->physmem_free, - cap->start, cap->end); - else /* Delete device from free list */ - memcap_request_device(&kres->devmem_free, cap); + /* Try physical ram ranges */ + if ((ret = memcap_unmap(&kres->physmem_used, + &kres->physmem_free, + cap->start, cap->end)) + == -EEXIST) { + /* Try physical device ranges */ + if ((ret = memcap_unmap(&kres->devmem_used, + &kres->devmem_free, + cap->start, cap->end)) + == -EEXIST) { + /* Neither is a match */ + printk("%s: FATAL: Physical memory " + "capability range does not match " + "with any available physmem or devmem " + "free range. start=0x%lx, end=0x%lx\n", + __KERNELNAME__, + __pfn_to_addr(cap->start), + __pfn_to_addr(cap->end)); + BUG(); + } + } } - return ret; } /* - * Initializes the kernel resources by describing both virtual - * and physical memory. Then traverses cap_info structures - * to figure out resource requirements of containers. + * Initialize kernel managed physical memory capabilities + * based on the multiple physical memory and device regions + * defined by the specific platform. */ -int setup_boot_resources(struct boot_resources *bootres, - struct kernel_resources *kres) +void kernel_setup_physmem(struct kernel_resources *kres, + struct platform_mem_regions *mem_regions) { - struct cap_info *cap; + struct capability *physmem; - init_kernel_resources(kres); + for (int i = 0; i < mem_regions->nregions; i++) { + /* Allocate new physical memory capability */ + physmem = alloc_bootmem(sizeof(*physmem), 0); - /* Number of containers known at compile-time */ - bootres->nconts = CONFIG_CONTAINERS; + /* Assign its range from platform range at this index */ + physmem->start = __pfn(mem_regions->mem_range[i].start); + physmem->end = __pfn(mem_regions->mem_range[i].end); - /* Traverse all containers */ - for (int i = 0; i < bootres->nconts; i++) { - /* Traverse all pagers */ - for (int j = 0; j < cinfo[i].npagers; j++) { - int ncaps = cinfo[i].pager[j].ncaps; - - /* Count all capabilities */ - bootres->ncaps += ncaps; - - /* Count all resources */ - for (int k = 0; k < ncaps; k++) { - cap = &cinfo[i].pager[j].caps[k]; - process_cap_info(cap, bootres, kres); - } - } + /* Init and insert the capability to keep permanently */ + link_init(&physmem->list); + if (mem_regions->mem_range[i].type == MEM_TYPE_RAM) + cap_list_insert(physmem, &kres->physmem_free); + else if (mem_regions->mem_range[i].type == MEM_TYPE_DEV) + cap_list_insert(physmem, &kres->devmem_free); + else BUG(); } - - return 0; } /* @@ -933,15 +521,145 @@ int setup_boot_resources(struct boot_resources *bootres, */ int init_system_resources(struct kernel_resources *kres) { + struct cap_info *cap_info; + // struct capability *cap; + struct container *container; + struct capability *virtmem, *kernel_area; struct boot_resources bootres; + /* Initialize system id pools */ + kres->space_ids.nwords = SYSTEM_IDS_MAX; + kres->ktcb_ids.nwords = SYSTEM_IDS_MAX; + kres->resource_ids.nwords = SYSTEM_IDS_MAX; + kres->container_ids.nwords = SYSTEM_IDS_MAX; + kres->mutex_ids.nwords = SYSTEM_IDS_MAX; + kres->capability_ids.nwords = SYSTEM_IDS_MAX; + + /* Initialize container head */ + container_head_init(&kres->containers); + + /* Initialize kernel capability lists */ + cap_list_init(&kres->physmem_used); + cap_list_init(&kres->physmem_free); + cap_list_init(&kres->devmem_used); + cap_list_init(&kres->devmem_free); + cap_list_init(&kres->virtmem_used); + cap_list_init(&kres->virtmem_free); + + /* Initialize kernel address space */ + link_init(&kres->init_space.list); + cap_list_init(&kres->init_space.cap_list); + spin_lock_init(&kres->init_space.lock); + + // Shall we have this? + // space->spid = id_new(&kernel_resources.space_ids); + + /* + * Set up total physical memory capabilities as many + * as the platform-defined physical memory regions + */ + kernel_setup_physmem(kres, &platform_mem_regions); + + /* Set up total virtual memory as single capability */ + virtmem = alloc_bootmem(sizeof(*virtmem), 0); + virtmem->start = __pfn(VIRT_MEM_START); + virtmem->end = __pfn(VIRT_MEM_END); + link_init(&virtmem->list); + cap_list_insert(virtmem, &kres->virtmem_free); + + /* Set up kernel used area as a single capability */ + kernel_area = alloc_bootmem(sizeof(*kernel_area), 0); + kernel_area->start = __pfn(virt_to_phys(_start_kernel)); + kernel_area->end = __pfn(virt_to_phys(_end_kernel)); + link_init(&kernel_area->list); + cap_list_insert(kernel_area, &kres->physmem_used); + + /* Unmap kernel used area from free physical memory capabilities */ + memcap_unmap(0, &kres->physmem_free, kernel_area->start, + kernel_area->end); + + /* TODO: + * Add all virtual memory areas used by the kernel + * e.g. kernel virtual area, syscall page, kip page, + */ + memset(&bootres, 0, sizeof(bootres)); - setup_boot_resources(&bootres, kres); + /* Number of containers known at compile-time */ + bootres.nconts = CONFIG_CONTAINERS; + + /* Traverse all containers */ + for (int i = 0; i < bootres.nconts; i++) { + + /* Process container-wide capabilities */ + bootres.ncaps += cinfo[i].ncaps; + for (int g = 0; g < cinfo[i].ncaps; g++) { + cap_info = &cinfo[i].caps[g]; + process_cap_info(cap_info, &bootres, kres); + } + + /* Traverse all pagers */ + for (int j = 0; j < cinfo[i].npagers; j++) { + int ncaps = cinfo[i].pager[j].ncaps; + + /* Count all capabilities */ + bootres.ncaps += ncaps; + + /* + * Count all resources, + * + * Remove all container memory resources + * from global. + */ + for (int k = 0; k < ncaps; k++) { + cap_info = &cinfo[i].pager[j].caps[k]; + process_cap_info(cap_info, &bootres, kres); + } + } + } init_resource_allocators(&bootres, kres); - setup_kernel_resources(&bootres, kres); + /* + * Setting up ids used internally. + * + * See how many containers we have. Assign next + * unused container id for kernel resources + */ + kres->cid = id_get(&kres->container_ids, bootres.nconts + 1); + // kres->cid = id_get(&kres->container_ids, 0); // Gets id 0 + + /* + * Assign thread and space ids to current which will later + * become the idle task + * TODO: Move this to idle task initialization? + */ + current->tid = id_new(&kres->ktcb_ids); + current->space->spid = id_new(&kres->space_ids); + + /* + * Init per-cpu zombie lists + */ + for (int i = 0; i < CONFIG_NCPU; i++) + init_ktcb_list(&per_cpu_byid(kres->zombie_list, i)); + + /* + * Create real containers from compile-time created + * cinfo structures + */ + for (int i = 0; i < bootres.nconts; i++) { + /* Allocate & init container */ + container = container_alloc_init(); + + /* Fill in its information */ + copy_container_info(container, &cinfo[i]); + + /* Add it to kernel resources list */ + kres_insert_container(container, kres); + } + + /* Initialize pagers */ + container_init_pagers(kres); return 0; } diff --git a/src/generic/scheduler.c b/src/generic/scheduler.c index 68ffe46..1f82308 100644 --- a/src/generic/scheduler.c +++ b/src/generic/scheduler.c @@ -27,6 +27,8 @@ #include INC_ARCH(exception.h) #include INC_SUBARCH(irq.h) +#define is_idle_task(task) (task == per_cpu(scheduler).idle_task) + DECLARE_PERCPU(struct scheduler, scheduler); /* This is incremented on each irq or voluntarily by preempt_disable() */ @@ -119,8 +121,6 @@ void sched_init() sched->rq_runnable = &sched->sched_rq[0]; sched->rq_expired = &sched->sched_rq[1]; - sched->rq_rt_runnable = &sched->sched_rq[2]; - sched->rq_rt_expired = &sched->sched_rq[3]; sched->prio_total = TASK_PRIO_TOTAL; sched->idle_task = current; } @@ -138,18 +138,6 @@ static void sched_rq_swap_queues(void) per_cpu(scheduler).rq_expired = temp; } -static void sched_rq_swap_rtqueues(void) -{ - struct runqueue *temp; - - BUG_ON(list_empty(&per_cpu(scheduler).rq_rt_expired->task_list)); - - /* Queues are swapped and expired list becomes runnable */ - temp = per_cpu(scheduler).rq_rt_runnable; - per_cpu(scheduler).rq_rt_runnable = per_cpu(scheduler).rq_rt_expired; - per_cpu(scheduler).rq_rt_expired = temp; -} - /* Set policy on where to add tasks in the runqueue */ #define RQ_ADD_BEHIND 0 #define RQ_ADD_FRONT 1 @@ -199,29 +187,6 @@ static inline void sched_rq_remove_task(struct ktcb *task) sched_unlock_runqueues(sched, irqflags); } -static inline void -sched_run_task(struct ktcb *task, struct scheduler *sched) -{ - if (task->flags & TASK_REALTIME) - sched_rq_add_task(task, sched->rq_rt_runnable, - RQ_ADD_BEHIND); - else - sched_rq_add_task(task, sched->rq_runnable, - RQ_ADD_BEHIND); -} - -static inline void -sched_expire_task(struct ktcb *task, struct scheduler *sched) -{ - - if (task->flags & TASK_REALTIME) - sched_rq_add_task(current, sched->rq_rt_expired, - RQ_ADD_BEHIND); - else - sched_rq_add_task(current, sched->rq_expired, - RQ_ADD_BEHIND); -} - void sched_init_task(struct ktcb *task, int prio) { link_init(&task->rq_list); @@ -237,7 +202,9 @@ void sched_resume_sync(struct ktcb *task) { BUG_ON(task == current); task->state = TASK_RUNNABLE; - sched_run_task(task, &per_cpu_byid(scheduler, task->affinity)); + sched_rq_add_task(task, per_cpu_byid(scheduler, + task->affinity).rq_runnable, + 1); schedule(); } @@ -250,7 +217,9 @@ void sched_resume_sync(struct ktcb *task) void sched_resume_async(struct ktcb *task) { task->state = TASK_RUNNABLE; - sched_run_task(task, &per_cpu_byid(scheduler, task->affinity)); + sched_rq_add_task(task, per_cpu_byid(scheduler, + task->affinity).rq_runnable, + 1); } /* @@ -279,7 +248,7 @@ void sched_suspend_sync(void) current->state = TASK_INACTIVE; current->flags &= ~TASK_SUSPENDING; - if (current->pagerid != current->tid) + if (current->pager != current) wake_up(¤t->wqh_pager, 0); preempt_enable(); @@ -293,7 +262,7 @@ void sched_suspend_async(void) current->state = TASK_INACTIVE; current->flags &= ~TASK_SUSPENDING; - if (current->pagerid != current->tid) + if (current->pager != current) wake_up(¤t->wqh_pager, 0); preempt_enable(); @@ -341,18 +310,6 @@ static inline int sched_recalc_ticks(struct ktcb *task, int prio_total) CONFIG_SCHED_TICKS * task->priority / prio_total; } -/* - * Select a real-time task 1/8th of any one selection - */ -static inline int sched_select_rt(struct scheduler *sched) -{ - int ctr = sched->task_select_ctr++ & 0xF; - - if (ctr == 0 || ctr == 8 || ctr == 15) - return 0; - else - return 1; -} /* * Selection happens as follows: @@ -370,28 +327,13 @@ static inline int sched_select_rt(struct scheduler *sched) struct ktcb *sched_select_next(void) { struct scheduler *sched = &per_cpu(scheduler); - int realtime = sched_select_rt(sched); - struct ktcb *next = 0; + struct ktcb *next = NULL; for (;;) { - /* Decision to run an RT task? */ - if (realtime && sched->rq_rt_runnable->total > 0) { - /* Get a real-time task, if available */ - next = link_to_struct(sched->rq_rt_runnable->task_list.next, - struct ktcb, rq_list); - break; - } else if (realtime && sched->rq_rt_expired->total > 0) { - /* Swap real-time queues */ - sched_rq_swap_rtqueues(); - /* Get a real-time task */ - next = link_to_struct(sched->rq_rt_runnable->task_list.next, - struct ktcb, rq_list); - break; /* Idle flagged for run? */ - } else if (sched->flags & SCHED_RUN_IDLE) { - /* Clear idle flag */ - sched->flags &= ~SCHED_RUN_IDLE; + if (sched->flags & SCHED_RUN_IDLE) { + /* Select and add to runqueue */ next = sched->idle_task; break; } else if (sched->rq_runnable->total > 0) { @@ -421,6 +363,7 @@ struct ktcb *sched_select_next(void) return next; } + /* Prepare next runnable task right before switching to it */ void sched_prepare_next(struct ktcb *next) { @@ -439,6 +382,10 @@ void sched_prepare_next(struct ktcb *next) next->ticks_left = next->ticks_assigned; } + /* Idle task needs adding to queue so its schedulable */ + if (is_idle_task(next)) + sched_rq_add_task(next, per_cpu(scheduler).rq_runnable, 1); + /* Reinitialise task's schedule granularity boundary */ next->sched_granule = SCHED_GRANULARITY; } @@ -491,13 +438,20 @@ void schedule() /* Reset schedule flag */ need_resched = 0; - /* Remove from runnable and put into appropriate runqueue */ + /* Remove runnable task from queue */ if (current->state == TASK_RUNNABLE) { sched_rq_remove_task(current); - if (current->ticks_left) - sched_run_task(current, &per_cpu(scheduler)); - else - sched_expire_task(current, &per_cpu(scheduler)); + /* Non-idle tasks go back to a runqueue */ + if (!is_idle_task(current)) { + if (current->ticks_left) + sched_rq_add_task(current, + per_cpu(scheduler).rq_runnable, + 0); + else + sched_rq_add_task(current, + per_cpu(scheduler).rq_expired, + 0); + } } /* diff --git a/src/generic/space.c b/src/generic/space.c index 9174894..06d8801 100644 --- a/src/generic/space.c +++ b/src/generic/space.c @@ -21,7 +21,7 @@ void init_address_space_list(struct address_space_list *space_list) memset(space_list, 0, sizeof(*space_list)); link_init(&space_list->list); - mutex_init(&space_list->lock); + spin_lock_init(&space_list->lock); } void address_space_attach(struct ktcb *tcb, struct address_space *space) @@ -54,20 +54,22 @@ void address_space_remove(struct address_space *space, struct container *cont) list_remove_init(&space->list); } + /* Assumes address space reflock is already held */ -void address_space_delete(struct address_space *space, - struct ktcb *task_accounted) +void address_space_delete(struct address_space *space, struct cap_list *clist) { BUG_ON(space->ktcb_refs); + BUG_ON(!list_empty(&space->cap_list.caps)); + BUG_ON(space->cap_list.ncaps); /* Traverse the page tables and delete private pmds */ - delete_page_tables(space); + delete_page_tables(space, clist); /* Return the space id */ id_del(&kernel_resources.space_ids, space->spid); /* Deallocate the space structure */ - free_space(space, task_accounted); + space_cap_free(space, clist); } struct address_space *address_space_create(struct address_space *orig) @@ -77,19 +79,19 @@ struct address_space *address_space_create(struct address_space *orig) int err; /* Allocate space structure */ - if (!(space = alloc_space())) + if (!(space = space_cap_alloc(¤t->space->cap_list))) return PTR_ERR(-ENOMEM); /* Allocate pgd */ - if (!(pgd = alloc_pgd())) { - free_space(space, current); + if (!(pgd = pgd_alloc())) { + space_cap_free(space, ¤t->space->cap_list); return PTR_ERR(-ENOMEM); } /* Initialize space structure */ link_init(&space->list); cap_list_init(&space->cap_list); - mutex_init(&space->lock); + spin_lock_init(&space->lock); space->pgd = pgd; /* Copy all kernel entries */ @@ -106,8 +108,8 @@ struct address_space *address_space_create(struct address_space *orig) if (orig) { /* Copy its user entries/tables */ if ((err = copy_user_tables(space, orig)) < 0) { - free_pgd(pgd); - free_space(space, current); + pgd_free(pgd); + space_cap_free(space, ¤t->space->cap_list); return PTR_ERR(err); } } diff --git a/src/generic/tcb.c b/src/generic/tcb.c index 9d2b755..cd15366 100644 --- a/src/generic/tcb.c +++ b/src/generic/tcb.c @@ -34,8 +34,6 @@ void tcb_init(struct ktcb *new) spin_lock_init(&new->thread_lock); - cap_list_init(&new->cap_list); - /* Initialise task's scheduling state and parameters. */ sched_init_task(new, TASK_PRIO_NORMAL); @@ -51,7 +49,7 @@ struct ktcb *tcb_alloc_init(l4id_t cid) struct ktcb *tcb; struct task_ids ids; - if (!(tcb = alloc_ktcb())) + if (!(tcb = ktcb_cap_alloc(¤t->space->cap_list))) return 0; ids.tid = id_new(&kernel_resources.ktcb_ids); @@ -66,9 +64,14 @@ struct ktcb *tcb_alloc_init(l4id_t cid) return tcb; } -void tcb_delete(struct ktcb *tcb) +/* + * Deletes tcb but moves capability list to struct pager + * Also the last child wakes up the pager which is absent here. + */ +void tcb_delete_pager(struct ktcb *tcb) { - struct ktcb *pager, *acc_task; + struct cap_list *pager_cap_list = + &tcb->container->pager->cap_list; /* Sanity checks first */ BUG_ON(!is_page_aligned(tcb)); @@ -83,15 +86,7 @@ void tcb_delete(struct ktcb *tcb) BUG_ON(tcb->nlocks); BUG_ON(tcb->waiting_on); BUG_ON(tcb->wq); - - /* Remove from zombie list */ - list_remove(&tcb->task_list); - - /* Determine task to account deletions */ - if (!(pager = tcb_find(tcb->pagerid))) - acc_task = current; - else - acc_task = pager; + BUG_ON(tcb->nchild); /* * NOTE: This protects single threaded space @@ -101,19 +96,69 @@ void tcb_delete(struct ktcb *tcb) * traversal would be needed to ensure list is * still there. */ - mutex_lock(&tcb->container->space_list.lock); - mutex_lock(&tcb->space->lock); + spin_lock(&tcb->container->space_list.lock); + spin_lock(&tcb->space->lock); + BUG_ON(--tcb->space->ktcb_refs != 0); + + address_space_remove(tcb->space, tcb->container); + + cap_list_move(pager_cap_list, &tcb->space->cap_list); + + spin_unlock(&tcb->space->lock); + spin_unlock(&tcb->container->space_list.lock); + + address_space_delete(tcb->space, pager_cap_list); + + /* Clear container id part */ + tcb->tid &= ~TASK_CID_MASK; + + /* Deallocate tcb ids */ + id_del(&kernel_resources.ktcb_ids, tcb->tid); + + /* Free the tcb */ + ktcb_cap_free(tcb, pager_cap_list); +} + +void tcb_delete(struct ktcb *tcb) +{ + struct ktcb *pager = tcb->pager; + + /* Sanity checks first */ + BUG_ON(!is_page_aligned(tcb)); + BUG_ON(tcb->wqh_pager.sleepers > 0); + BUG_ON(tcb->wqh_send.sleepers > 0); + BUG_ON(tcb->wqh_recv.sleepers > 0); + BUG_ON(tcb->affinity != current->affinity); + BUG_ON(tcb->state != TASK_INACTIVE); + BUG_ON(!list_empty(&tcb->rq_list)); + BUG_ON(tcb->rq); + BUG_ON(tcb == current); + BUG_ON(tcb->nlocks); + BUG_ON(tcb->waiting_on); + BUG_ON(tcb->wq); + BUG_ON(tcb->nchild); + + /* + * NOTE: This protects single threaded space + * deletion against space modification. + * + * If space deletion were multi-threaded, list + * traversal would be needed to ensure list is + * still there. + */ + spin_lock(&tcb->container->space_list.lock); + spin_lock(&tcb->space->lock); BUG_ON(--tcb->space->ktcb_refs < 0); /* No refs left for the space, delete it */ if (tcb->space->ktcb_refs == 0) { address_space_remove(tcb->space, tcb->container); - mutex_unlock(&tcb->space->lock); - address_space_delete(tcb->space, acc_task); - mutex_unlock(&tcb->container->space_list.lock); + spin_unlock(&tcb->space->lock); + spin_unlock(&tcb->container->space_list.lock); + address_space_delete(tcb->space, &tcb->pager->space->cap_list); } else { - mutex_unlock(&tcb->space->lock); - mutex_unlock(&tcb->container->space_list.lock); + spin_unlock(&tcb->space->lock); + spin_unlock(&tcb->container->space_list.lock); } /* Clear container id part */ @@ -123,7 +168,17 @@ void tcb_delete(struct ktcb *tcb) id_del(&kernel_resources.ktcb_ids, tcb->tid); /* Free the tcb */ - free_ktcb(tcb, acc_task); + ktcb_cap_free(tcb, &tcb->pager->space->cap_list); + + /* Reduce child count after freeing tcb, so that + * pager does not release capabilities until then */ + spin_lock(&pager->thread_lock); + BUG_ON(pager->nchild-- < 0); + spin_unlock(&pager->thread_lock); + + /* Wake up pager if this was the last child */ + if (pager->nchild == 0) + wake_up(&pager->wqh_pager, 0); } struct ktcb *tcb_find_by_space(l4id_t spid) @@ -248,13 +303,30 @@ void tcb_delete_zombies(void) struct ktcb_list *ktcb_list = &per_cpu(kernel_resources.zombie_list); - /* Traverse the per-cpu zombie list */ + /* Lock and traverse the per-cpu zombie list */ spin_lock(&ktcb_list->list_lock); list_foreach_removable_struct(zombie, n, &ktcb_list->list, - task_list) - /* Delete all zombies one by one */ - tcb_delete(zombie); + task_list) { + /* Lock zombie */ + spin_lock(&zombie->thread_lock); + + /* Remove from zombie list */ + list_remove(&zombie->task_list); + + /* Unlock all locks */ + spin_unlock(&zombie->thread_lock); + spin_unlock(&ktcb_list->list_lock); + + /* Delete zombie as lock-free */ + if (thread_is_pager(zombie)) + tcb_delete_pager(zombie); + else + tcb_delete(zombie); + + /* Lock back the list */ + spin_lock(&ktcb_list->list_lock); + } spin_unlock(&ktcb_list->list_lock); } @@ -367,10 +439,16 @@ int tcb_check_and_lazy_map_utcb(struct ktcb *task, int page_in) * Update it with privileged flags, * so that only kernel can access. */ - add_mapping_pgd(phys, page_align(task->utcb_address), - page_align_up(UTCB_SIZE), - MAP_KERN_RW, - TASK_PGD(current)); + if ((ret = add_mapping_use_cap(phys, + page_align(task->utcb_address), + page_align_up(UTCB_SIZE), + MAP_KERN_RW, + current->space, + &task->space->cap_list)) < 0) { + printk("Warning: Irq owner thread is " + "out of pmds. ret=%d\n", ret); + return ret; + } } BUG_ON(!phys); } diff --git a/src/generic/time.c b/src/generic/time.c index 466c7b0..8e56f3b 100644 --- a/src/generic/time.c +++ b/src/generic/time.c @@ -148,7 +148,7 @@ int do_timer_irq(void) update_process_times(); update_system_time(); -#if defined (CONFIG_SMP) +#if defined (CONFIG_SMP_) smp_send_ipi(cpu_mask_others(), IPI_TIMER_EVENT); #endif diff --git a/src/glue/arm/SConscript b/src/glue/arm/SConscript index da8cc4a..8891c6d 100644 --- a/src/glue/arm/SConscript +++ b/src/glue/arm/SConscript @@ -1,22 +1,25 @@ # Inherit global environment -import os, sys, glob +import os, sys PROJRELROOT = '../../' - sys.path.append(PROJRELROOT) -from config.projpaths import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.config_invoke import * -Import('env', 'symbols') +Import('env') + +config = configuration_retrieve() +symbols = config.all # The set of source files associated with this SConscript file. -src_local = ['init.c', 'memory.c', 'systable.c', 'irq.c', 'cache.c', 'debug.c'] +src_local = ['init.c', 'memory.c', 'systable.c', + 'irq.c', 'cache.c', 'debug.c'] for name, val in symbols: - if 'CONFIG_SMP' == name: - src_local += ['smp.c', 'ipi.c'] + if 'CONFIG_SMP_' == name: + src_local += ['smp.c', 'ipi.c'] obj = env.Object(src_local) Return('obj') diff --git a/src/glue/arm/init.c b/src/glue/arm/init.c index fcaba90..2373c66 100644 --- a/src/glue/arm/init.c +++ b/src/glue/arm/init.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -106,60 +107,6 @@ void vectors_init() } -#include -#include -#include - -/* This is what an idle task needs */ -static DECLARE_PERCPU(struct capability, pmd_cap); - -/* - * FIXME: Add this when initializing kernel resources - * This is a hack. - */ -void setup_idle_caps() -{ - struct capability *cap = &per_cpu(pmd_cap); - - cap_list_init(¤t->cap_list); - cap->type = CAP_RTYPE_MAPPOOL | CAP_TYPE_QUANTITY; - cap->size = 50; - - link_init(&cap->list); - cap_list_insert(cap, ¤t->cap_list); -} - -/* - * Set up current stack's beginning, and initial page tables - * as a valid task environment for idle task for current cpu - */ -void setup_idle_task() -{ - memset(current, 0, sizeof(struct ktcb)); - - current->space = &init_space; - TASK_PGD(current) = &init_pgd; - - /* Initialize space caps list */ - cap_list_init(¤t->space->cap_list); - - /* - * FIXME: This must go to kernel resources init. - */ - - /* Init scheduler structs */ - sched_init_task(current, TASK_PRIO_NORMAL); - - /* - * If using split page tables, kernel - * resources must point at the global pgd - * TODO: We may need this for V6, in the future - */ -#if defined(CONFIG_SUBARCH_V7) - kernel_resources.pgd_global = &init_global_pgd; -#endif -} - void remove_initial_mapping(void) { /* At this point, execution is on virtual addresses. */ @@ -168,17 +115,15 @@ void remove_initial_mapping(void) void init_finalize(void) { - /* Set up idle task capabilities */ - setup_idle_caps(); - platform_timer_start(); -#if defined (CONFIG_SMP) +#if defined (CONFIG_SMP_) /* Tell other cores to continue */ secondary_run_signal = 1; dmb(); #endif + sched_resume_async(current); idle_task(); } diff --git a/src/glue/arm/smp.c b/src/glue/arm/smp.c index 3b51d57..9ec8268 100644 --- a/src/glue/arm/smp.c +++ b/src/glue/arm/smp.c @@ -60,16 +60,6 @@ void init_smp(void) } } -void secondary_setup_idle_task(void) -{ - /* This also has its spid allocated by primary */ - current->space = &init_space; - TASK_PGD(current) = &init_pgd; - - /* We need a thread id */ - current->tid = id_new(&kernel_resources.ktcb_ids); -} - /* * Idle wait before any tasks become available for running. * @@ -85,16 +75,13 @@ void sched_secondary_start(void) while (!secondary_run_signal) dmb(); - secondary_setup_idle_task(); - - setup_idle_caps(); + secondary_idle_task_init(); idle_task(); BUG(); } - /* * this is where it jumps from secondary_start(), which is called from * board_smp_start() to align each core to start here diff --git a/src/lib/SConscript b/src/lib/SConscript index 728a769..f74a969 100644 --- a/src/lib/SConscript +++ b/src/lib/SConscript @@ -1,10 +1,10 @@ + # Inherit global environment Import('env') -Import('symbols') # The set of source files associated with this SConscript file. -src_local = ['printk.c', 'putc.c', 'string.c', 'bit.c', 'wait.c', 'mutex.c', 'idpool.c', 'memcache.c'] +src_local = ['printk.c', 'putc.c', 'string.c', 'bit.c', + 'wait.c', 'mutex.c', 'idpool.c', 'memcache.c'] obj = env.Object(src_local) - Return('obj') diff --git a/src/lib/string.c b/src/lib/string.c index b8e7dd6..234e377 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 B Labs Ltd. + * Copyright (C) 2008-2010 B Labs Ltd. */ void *_memset(void *p, int c, int size); diff --git a/src/platform/beagle/SConscript b/src/platform/beagle/SConscript index 6c87597..38f387d 100644 --- a/src/platform/beagle/SConscript +++ b/src/platform/beagle/SConscript @@ -7,5 +7,4 @@ Import('env') src_local = ['print-early.c', 'platform.c', 'perfmon.c', 'irq.c', 'cm.c'] obj = env.Object(src_local) - Return('obj') diff --git a/src/platform/eb/SConscript b/src/platform/eb/SConscript index ae7a53e..69cb53b 100644 --- a/src/platform/eb/SConscript +++ b/src/platform/eb/SConscript @@ -5,20 +5,23 @@ import os, sys PROJRELROOT = '../../../' - sys.path.append(PROJRELROOT) -from config.projpaths import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.config_invoke import * -Import('env', 'platform', 'symbols') +Import('env') + +config = configuration_retrieve() +platform = config.platform # The set of source files associated with this SConscript file. src_local = ['platform.c', 'irq.c'] obj = env.Object(src_local) # This is arealview platform, include corresponding files. -obj += SConscript(join(PROJROOT, 'src/platform/realview/SConscript'), exports = {'env' : env, 'symbols' : symbols}, - duplicate=0, build_dir='realview') +obj += SConscript(join(PROJROOT, 'src/platform/realview/SConscript'), + exports = { 'env' : env }, duplicate = 0, + build_dir = 'realview') Return('obj') diff --git a/src/platform/eb/platform.c b/src/platform/eb/platform.c index 0b8d39c..ec4ad66 100644 --- a/src/platform/eb/platform.c +++ b/src/platform/eb/platform.c @@ -49,6 +49,7 @@ int platform_setup_device_caps(struct kernel_resources *kres) device_cap_init(kres, CAP_DEVTYPE_TIMER, 1, PLATFORM_TIMER1_BASE); device_cap_init(kres, CAP_DEVTYPE_KEYBOARD, 0, PLATFORM_KEYBOARD0_BASE); device_cap_init(kres, CAP_DEVTYPE_MOUSE, 0, PLATFORM_MOUSE0_BASE); + device_cap_init(kres, CAP_DEVTYPE_CLCD, 0, PLATFORM_CLCD0_BASE); return 0; } diff --git a/src/platform/pb926/SConscript b/src/platform/pb926/SConscript index d16ecf3..57b1561 100644 --- a/src/platform/pb926/SConscript +++ b/src/platform/pb926/SConscript @@ -1,5 +1,4 @@ - # Inherit global environment Import('env') diff --git a/src/platform/pb926/platform.c b/src/platform/pb926/platform.c index 8f6a57a..ad1e2c8 100644 --- a/src/platform/pb926/platform.c +++ b/src/platform/pb926/platform.c @@ -23,42 +23,21 @@ #include #include -/* - * FIXME: This is not a platform specific - * call, we will move this out later - */ -void device_cap_init(struct kernel_resources *kres, int devtype, - int devnum, unsigned long base) -{ - struct capability *cap; - - cap = alloc_bootmem(sizeof(*cap), 0); - cap_set_devtype(cap, devtype); - cap_set_devnum(cap, devnum); - cap->start = __pfn(base); - cap->end = cap->start + 1; - cap->size = cap->end - cap->start; - link_init(&cap->list); - cap_list_insert(cap, &kres->devmem_free); -} - -/* - * The devices that are used by the kernel are mapped - * independent of these capabilities, but these provide a - * concise description of what is used by the kernel. - */ -int platform_setup_device_caps(struct kernel_resources *kres) -{ - device_cap_init(kres, CAP_DEVTYPE_UART, 1, PLATFORM_UART1_BASE); - device_cap_init(kres, CAP_DEVTYPE_UART, 2, PLATFORM_UART2_BASE); - device_cap_init(kres, CAP_DEVTYPE_UART, 3, PLATFORM_UART3_BASE); - device_cap_init(kres, CAP_DEVTYPE_TIMER, 1, PLATFORM_TIMER1_BASE); - device_cap_init(kres, CAP_DEVTYPE_KEYBOARD, 0, PLATFORM_KEYBOARD0_BASE); - device_cap_init(kres, CAP_DEVTYPE_MOUSE, 0, PLATFORM_MOUSE0_BASE); - device_cap_init(kres, CAP_DEVTYPE_CLCD, 0, PLATFORM_CLCD0_BASE); - - return 0; -} +struct platform_mem_regions platform_mem_regions = { + .nregions = 1, + .mem_range = { + [0] = { + .start = PLATFORM_PHYS_MEM_START, + .end = PLATFORM_PHYS_MEM_END, + .type = MEM_TYPE_RAM, + }, + [1] = { + .start = PLATFORM_SYSTEM_REGISTERS, + .end = PLATFORM_SYSTEM_REGISTERS + PLATFORM_SYSREGS_SIZE, + .type = MEM_TYPE_DEV, + }, + }, +}; /* * We will use UART0 for kernel as well as user tasks, diff --git a/src/platform/pba9/SConscript b/src/platform/pba9/SConscript index ae7a53e..eb8f188 100644 --- a/src/platform/pba9/SConscript +++ b/src/platform/pba9/SConscript @@ -1,24 +1,22 @@ - # Inherit global environment - import os, sys PROJRELROOT = '../../../' - sys.path.append(PROJRELROOT) -from config.projpaths import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.config_invoke import * -Import('env', 'platform', 'symbols') +Import('env') # The set of source files associated with this SConscript file. src_local = ['platform.c', 'irq.c'] obj = env.Object(src_local) # This is arealview platform, include corresponding files. -obj += SConscript(join(PROJROOT, 'src/platform/realview/SConscript'), exports = {'env' : env, 'symbols' : symbols}, - duplicate=0, build_dir='realview') +obj += SConscript(join(PROJROOT, 'src/platform/realview/SConscript'), + exports = {'env' : env }, duplicate = 0, + build_dir = 'realview') Return('obj') diff --git a/src/platform/pba9/platform.c b/src/platform/pba9/platform.c index 965beb1..3ba945a 100644 --- a/src/platform/pba9/platform.c +++ b/src/platform/pba9/platform.c @@ -19,42 +19,26 @@ #include #include -/* - * FIXME: This is not a platform specific - * call, we will move this out later - */ -void device_cap_init(struct kernel_resources *kres, int devtype, - int devnum, unsigned long base) -{ - struct capability *cap; - - cap = alloc_bootmem(sizeof(*cap), 0); - cap_set_devtype(cap, devtype); - cap_set_devnum(cap, devnum); - cap->start = __pfn(base); - cap->end = cap->start + 1; - cap->size = cap->end - cap->start; - link_init(&cap->list); - cap_list_insert(cap, &kres->devmem_free); -} - -/* - * The devices that are used by the kernel are mapped - * independent of these capabilities, but these provide a - * concise description of what is used by the kernel. - */ -int platform_setup_device_caps(struct kernel_resources *kres) -{ - device_cap_init(kres, CAP_DEVTYPE_UART, 1, PLATFORM_UART1_BASE); - device_cap_init(kres, CAP_DEVTYPE_UART, 2, PLATFORM_UART2_BASE); - device_cap_init(kres, CAP_DEVTYPE_UART, 3, PLATFORM_UART3_BASE); - device_cap_init(kres, CAP_DEVTYPE_TIMER, 1, PLATFORM_TIMER1_BASE); - device_cap_init(kres, CAP_DEVTYPE_KEYBOARD, 0, PLATFORM_KEYBOARD0_BASE); - device_cap_init(kres, CAP_DEVTYPE_MOUSE, 0, PLATFORM_MOUSE0_BASE); - device_cap_init(kres, CAP_DEVTYPE_CLCD, 0, PLATFORM_CLCD0_BASE); - - return 0; -} +struct platform_mem_regions platform_mem_regions = { + .nregions = 3, + .mem_range = { + [0] = { + .start = PLATFORM_PHYS_MEM_START, + .end = PLATFORM_PHYS_MEM_END, + .type = MEM_TYPE_RAM, + }, + [1] = { + .start = PLATFORM_DEVICES_START, + .end = PLATFORM_DEVICES_END, + .type = MEM_TYPE_DEV, + }, + [2] = { + .start = PLATFORM_DEVICES1_START, + .end = PLATFORM_DEVICES1_END, + .type = MEM_TYPE_DEV, + }, + }, +}; void init_platform_irq_controller() { @@ -85,5 +69,8 @@ void init_platform_devices() add_boot_mapping(PLATFORM_CLCD0_BASE, PLATFORM_CLCD0_VBASE, PAGE_SIZE, MAP_IO_DEFAULT); + /* System registers */ + add_boot_mapping(PLATFORM_SYSTEM_REGISTERS, PLATFORM_SYSREGS_VBASE, + PAGE_SIZE, MAP_IO_DEFAULT); } diff --git a/src/platform/realview/SConscript b/src/platform/realview/SConscript index 8be0e9d..d0c73a2 100644 --- a/src/platform/realview/SConscript +++ b/src/platform/realview/SConscript @@ -1,21 +1,23 @@ # Inherit global environment -import os, sys, glob +import os, sys PROJRELROOT = '../../' - sys.path.append(PROJRELROOT) -from config.projpaths import * -from configure import * +from scripts.config.projpaths import * +from scripts.config.config_invoke import * -Import('env', 'symbols') +Import('env') + +config = configuration_retrieve() +symbols = config.all # The set of source files associated with this SConscript file. src_local = ['irq.c', 'platform.c', 'print-early.c', 'perfmon.c', 'cpuperf.S'] for name, val in symbols: - if 'CONFIG_SMP' == name: + if 'CONFIG_SMP_' == name: src_local += ['smp.c'] obj = env.Object(src_local) diff --git a/src/platform/realview/irq.c b/src/platform/realview/irq.c index f8733b4..822f875 100644 --- a/src/platform/realview/irq.c +++ b/src/platform/realview/irq.c @@ -51,7 +51,7 @@ int platform_mouse_user_handler(struct irq_desc *desc) * Disable rx keyboard interrupt. * User will enable this */ - clrbit((unsigned int *)PLATFORM_KEYBOARD0_VBASE + PL050_KMICR, + clrbit((unsigned int *)PLATFORM_MOUSE0_VBASE + PL050_KMICR, PL050_KMI_RXINTR); irq_thread_notify(desc); diff --git a/src/platform/realview/platform.c b/src/platform/realview/platform.c index 2d57b65..71a2164 100644 --- a/src/platform/realview/platform.c +++ b/src/platform/realview/platform.c @@ -84,7 +84,7 @@ void platform_init(void) init_platform_irq_controller(); init_platform_devices(); -#if defined (CONFIG_SMP) +#if defined (CONFIG_SMP_) init_smp(); scu_init(); #endif diff --git a/src/platform/realview/smp.c b/src/platform/realview/smp.c index 33e6771..66490ec 100644 --- a/src/platform/realview/smp.c +++ b/src/platform/realview/smp.c @@ -55,9 +55,6 @@ void platform_smp_init(int ncpus) irq_desc_array[i].handler = &ipi_handler; } - add_boot_mapping(PLATFORM_SYSTEM_REGISTERS, PLATFORM_SYSREGS_VBASE, - PAGE_SIZE, MAP_IO_DEFAULT); - } int platform_smp_start(int cpu, void (*smp_start_func)(int)) diff --git a/tools/cml2-tools/cmlconfigure.py b/tools/cml2-tools/cmlconfigure.py index baf357b..b98daf3 100755 --- a/tools/cml2-tools/cmlconfigure.py +++ b/tools/cml2-tools/cmlconfigure.py @@ -75,7 +75,7 @@ _eng = { "GOBUTTON":"Go to...", "GOTOBYNAME":"Go to symbol by name: ", "GPROMPT":"Symbol to set or edit: ", - "HELPBANNER": "Press ? for help on current symbol, h for command help", + "HELPBANNER": "Press h for help on current symbol, c for command help", "HELPBUTTON":"Help", "HELPFOR":"Help for %s", "HSEARCHBUTTON":"Search help text...", @@ -207,7 +207,7 @@ Type `x' to save configuration and exit, `q' to exit without saving, `s' to save the configuration to a named file, and `i' to read in a configuration by filename. -I reads in a configuration and freezes the variables. -Type '?' to see any help text associated with the current symbol. Type 'h' +Type 'h' to see any help text associated with the current symbol. Type 'c' to see this command summary again. Some expert commands are documented in separate help; press TAB from this help screen to see it.\ """, @@ -297,7 +297,7 @@ using the `Go' command to visit a suppressed symbol, or by doing a Search. """, "CLIHELP":"""\ -Usage: clmlconfigure.py [-tcxqbs] [-[Dd] sym] [-[Ii] file] +Usage: cmlconfigure.py [-tcxqbs] [-[Dd] sym] [-[Ii] file] [-B banner] [-o output] [-v] -t force tty (line-oriented) mode @@ -1648,7 +1648,7 @@ class curses_style_menu: (self.lines, self.columns) = self.window.getmaxyx() self.menus.viewport_height = self.lines-1 recompute = 1 - elif cmd in (curses.ascii.TAB, ord('h')): + elif cmd in (curses.ascii.TAB, ord('c')): if self.in_menu(): self.menus.push(string.split(lang["CURSHELP"], "\n")) self.msgbuf = lang["WELCOME"] % (configuration.banner) \ @@ -1682,7 +1682,7 @@ class curses_style_menu: else: self.menus.push(entry.menu.items, entry) recompute = 1 - elif cmd == ord('?'): + elif cmd == ord('h'): if not self.in_menu(): self.help_popup("PRESSANY", (lang["NOSYMBOL"],)) else: diff --git a/tools/pyelf/elf_section_info.py b/tools/pyelf/elf_section_info.py index 5339488..b748269 100644 --- a/tools/pyelf/elf_section_info.py +++ b/tools/pyelf/elf_section_info.py @@ -2,40 +2,39 @@ import elf -# Define section markers for various sections in elf +# Define header markers for various program headers in elf def elf_loadable_section_info(img): elffile = elf.ElfFile.from_file(img) - # Sections markers for RW sections + # Markers rw_sections_start = 0 rw_sections_end = 0 - - # Section markers for RX and RO section combined rx_sections_start = 0 rx_sections_end = 0 # Flag encoding used by elf - sh_flag_write = 1 << 0 - sh_flag_load = 1 << 1 - sh_flag_execute = 1 << 2 + PF_X = 1 << 0 + PF_W = 1 << 1 + PF_R = 1 << 2 - for sheader in elffile.sheaders: - x = sheader.ai + loadable_header = 1 - # Check for loadable sections - if x.sh_flags.get() & sh_flag_load: - start = x.sh_addr.get() - end = start + x.sh_size.get() + for pheader in elffile.pheaders: + x = pheader.ai - # RW Section - if x.sh_flags.get() & sh_flag_write: - if (rw_sections_start == 0) or (rw_sections_start > start): - rw_sections_start = start - if (rw_sections_end == 0) or (rw_sections_end < end): - rw_sections_end = end + # Check for loadable headers + if x.p_type.get() >> loadable_header == 0: + start = x.p_vaddr.get() + end = start + x.p_memsz.get() - # RX, RO Section - else: + # RW header + if x.p_flags.get() & (~(PF_R | PF_W)) == 0: + if (rw_sections_start == 0) or (rw_sections_start > start): + rw_sections_start = start + if (rw_sections_end == 0) or (rw_sections_end < end): + rw_sections_end = end + # RX header + elif x.p_flags.get() & (~(PF_R | PF_X)) == 0: if (rx_sections_start == 0) or (rx_sections_start > start): rx_sections_start = start if (rx_sections_end == 0) or (rx_sections_end < end): @@ -43,4 +42,3 @@ def elf_loadable_section_info(img): return rw_sections_start, rw_sections_end, \ rx_sections_start, rx_sections_end - diff --git a/tools/pyelf/elfsize.py b/tools/pyelf/elfsize.py index 8e3827e..b40ce4a 100644 --- a/tools/pyelf/elfsize.py +++ b/tools/pyelf/elfsize.py @@ -21,3 +21,7 @@ def elf_binary_size(img): paddr_end = x.p_paddr + x.p_memsz return paddr_end - paddr_start +# Return load address of elf file +def get_elf_load_address(img): + elffile = elf.ElfFile.from_file(img) + return elffile.header.ai.e_entry diff --git a/tools/tagsgen/tagsgen_all b/tools/tagsgen/tagsgen_all index 0a8573b..053c473 100755 --- a/tools/tagsgen/tagsgen_all +++ b/tools/tagsgen/tagsgen_all @@ -16,5 +16,6 @@ ctags -e --languages=C,C++,Asm --recurse -Ltagfilelist # exuberant-ctags --languages=C,C++,Asm --recurse -Ltagfilelist cscope -q -k -R -i tagfilelist + # Remove file list. rm -f tagfilelist diff --git a/tools/tagsgen/tagsgen_kernel.py b/tools/tagsgen/tagsgen_kernel.py index 6e507bc..b94bee6 100755 --- a/tools/tagsgen/tagsgen_kernel.py +++ b/tools/tagsgen/tagsgen_kernel.py @@ -6,7 +6,7 @@ import os, sys PROJRELROOT = '../../' sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) -from config.configuration import * +from scripts.config.configuration import * config = configuration_retrieve() platform = config.platform @@ -25,32 +25,37 @@ def main(): include_dir_path = 'include/l4' search_folder = \ - ['api', 'arch/'+ arch, 'arch/'+ arch + '/' + subarch, 'drivers', \ - 'generic', 'glue/' + arch, 'lib', 'platform/' + platform] + ['api', + 'arch/'+ arch, + 'arch/'+ arch + '/' + subarch, + 'generic', + 'glue/' + arch, + 'lib', + 'platform/' + platform] # Check if we need realview directory based on platform selected - if platform == "eb" or \ - platform == "pba8" or \ - platform == "pba9" or \ - platform == "pb11mpcore": + if platform == 'eb' or platform == 'pba9': search_folder += ['platform/realview'] + # Driver selection based on platform selected + if platform == 'beagle': + search_folder += ['drivers/uart/omap', 'drivers/timer/omap', 'drivers/irq/omap3'] + elif platform == 'eb' or platform == 'pba9': + search_folder += ['drivers/uart/pl011', 'drivers/timer/sp804', 'drivers/irq/gic'] + elif platform == 'pb926': + search_folder += ['drivers/uart/pl011', 'drivers/timer/sp804', 'drivers/irq/pl190'] + # Put all sources into a file list. + depth = 1 for extn in file_extn: for dir in search_folder: - # Directory depth to be searched - if dir == 'drivers': - depth = 5 - else: - depth = 1 - os.system("find " + join(src_dir_path, dir) + \ " -maxdepth " + str(depth) + " -name '" + extn + "' >> tagfilelist") os.system("find " + join(include_dir_path, dir) + \ " -maxdepth " + str(depth) + " -name '" + extn + "' >> tagfilelist") # Use file list to include in tags. - os.system("ctags --languages=C,Asm --recurse -Ltagfilelist") + os.system("ctags --languages=C,Asm --recurse -Ltagfilelist --if0=yes") os.system("cscope -q -k -R -i tagfilelist") # Remove file list. diff --git a/tools/tagsgen/tagsgen_linux.py b/tools/tagsgen/tagsgen_linux.py new file mode 100755 index 0000000..b28a7e9 --- /dev/null +++ b/tools/tagsgen/tagsgen_linux.py @@ -0,0 +1,79 @@ +#! /usr/bin/env python2.6 +# -*- mode: python; coding: utf-8; -*- +# +# Call this script from codezero/conts/linux/kernel-2.6.34 +# + +import os, sys + +PROJRELROOT = '../..' +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) + +from scripts.config.configuration import * +config = configuration_retrieve() + +platform = config.platform + +def main(): + + # Type of files to be included + file_extn = ['*.c', '*.h', '*.s', '*.S', '*.lds', '*.in', 'Makefile', 'Kconfig'] + + # Kernel directories + src_dir_path = '.' #'kernel-2.6.34' + arch_dir_path = join(src_dir_path, 'arch/arm') + + # Add Makefiles etc present in base directories + search_folder = [[src_dir_path, 1], [arch_dir_path, 1]] + + # Add architecture files + search_folder += \ + [[join(arch_dir_path, 'boot'), 5], + [join(arch_dir_path, 'common'), 5], + [join(arch_dir_path, 'include'), 5], + [join(arch_dir_path, 'kernel'), 5], + [join(arch_dir_path, 'lib'), 5], + [join(arch_dir_path, 'mm'), 5]] + + # Check for platform files + if platform == 'pba9': + search_folder += [[join(arch_dir_path, 'mach-vexpress'), 5], + [join(arch_dir_path, 'mach-versatile'), 5], + [join(arch_dir_path, 'plat-versatile'), 5]] + elif platform == 'pb926': + search_folder += [[join(arch_dir_path, 'mach-versatile'), 5], + [join(arch_dir_path, 'plat-versatile'), 5]] + elif platform == 'eb': + search_folder += [join(arch_dir_path, 'mach-realview'), 5] + elif platform == 'beagle': + search_folder += [[join(arch_dir_path, 'mach-omap2'), 5], + [join(arch_dir_path, 'plat-omap'), 5]] + # We may need mach-omap1 also. + else: + print 'Please define platform files path...' + exit(1) + + + # Add generic kernel directories + search_folder += [[join(src_dir_path, 'mm'), 5], + [join(src_dir_path, 'lib'), 5], + [join(src_dir_path, 'kernel'), 5], + [join(src_dir_path, 'init'), 5], + [join(src_dir_path, 'include'), 5]] + + # Put all sources into a file list. + for extn in file_extn: + for dir, depth in search_folder: + os.system("find " + dir + " -maxdepth " + str(depth) + \ + " -name '" + extn + "' >> tagfilelist.linux") + + # Use file list to include in tags. + os.system("ctags --languages=C,Asm --recurse -Ltagfilelist.linux --if0=yes") + os.system("cscope -q -k -R -i tagfilelist.linux") + + # Delete generated files + os.system("rm -f tagfilelist.linux") + +if __name__ == "__main__": + main() + diff --git a/tools/tagsgen/tagsgen_loader b/tools/tagsgen/tagsgen_loader index fb263a5..73dff35 100755 --- a/tools/tagsgen/tagsgen_loader +++ b/tools/tagsgen/tagsgen_loader @@ -1,3 +1,5 @@ +rm -f cscope.* +rm -f tags # Put all sources into a file list. find ./loader -name '*.cc' > tagfilelist @@ -6,15 +8,10 @@ find ./loader -name '*.h' >> tagfilelist find ./loader -name '*.s' >> tagfilelist find ./loader -name '*.S' >> tagfilelist -find ./libs -name '*.cc'>> tagfilelist -find ./libs -name '*.c' >> tagfilelist -find ./libs -name '*.h' >> tagfilelist -find ./libs -name '*.s' >> tagfilelist -find ./libs -name '*.S' >> tagfilelist - # Use file list to include in tags. -exuberant-ctags --languages=C,Asm --recurse -Ltagfilelist +ctags --languages=C,Asm --recurse -Ltagfilelist cscope -q -k -R -i tagfilelist + # Remove file list. -#rm -f tagfilelist +rm -f tagfilelist