From da4e1feaa5c8818e43a6b1e25ab32eab92307c1f Mon Sep 17 00:00:00 2001 From: Genode Labs Date: Thu, 22 Dec 2011 16:19:25 +0100 Subject: [PATCH] Imported Genode release 11.11 --- LICENSE | 280 + README | 182 +- base-codezero/Makefile | 44 + base-codezero/README | 3 + base-codezero/config/vpb926.cml | 240 + base-codezero/doc/codezero.txt | 274 + base-codezero/etc/specs.conf | 1 + base-codezero/include/arm/cpu/atomic.h | 33 + base-codezero/include/base/ipc_msgbuf.h | 63 + base-codezero/include/base/ipc_pager.h | 169 + base-codezero/include/base/native_types.h | 143 + .../include/codezero/dummies/stdio.h | 0 .../include/codezero/dummies/string.h | 0 base-codezero/include/codezero/syscalls.h | 76 + base-codezero/lib/mk/arm/startup.mk | 9 + base-codezero/lib/mk/arm_v5/l4.mk | 3 + base-codezero/lib/mk/arm_v5/l4_arm_v5.mk | 9 + base-codezero/lib/mk/codezero_cml.inc | 3 + base-codezero/lib/mk/cxx.mk | 13 + base-codezero/lib/mk/ipc.mk | 4 + base-codezero/lib/mk/l4.inc | 43 + base-codezero/lib/mk/lock.mk | 7 + base-codezero/lib/mk/pager.mk | 4 + base-codezero/lib/mk/pl011/core_printf.mk | 6 + base-codezero/lib/mk/platform.mk | 33 + base-codezero/lib/mk/thread.mk | 5 + base-codezero/mk/spec-codezero.mk | 56 + base-codezero/mk/spec-codezero_arm.mk | 13 + base-codezero/mk/spec-codezero_arm_v5.mk | 9 + .../mk/spec-codezero_platform_vpb926.mk | 6 + base-codezero/patches/README | 67 + base-codezero/patches/binutils-2.21.patch | 33 + base-codezero/patches/gcc_4_6_1_fixes.patch | 182 + .../patches/gcc_shared_enabled.patch | 10 + base-codezero/patches/libc_search_dir.patch | 21 + base-codezero/patches/scons-2.0.1.patch | 97 + base-codezero/patches/set_fixed_pager.patch | 13 + base-codezero/run/env | 88 + .../src/base/console/pl011/core_console.h | 78 + base-codezero/src/base/cxx/exception.cc | 53 + base-codezero/src/base/cxx/memcmp.cc | 24 + base-codezero/src/base/ipc/ipc.cc | 175 + base-codezero/src/base/ipc/pager.cc | 175 + base-codezero/src/base/lock/cmpxchg.cc | 48 + base-codezero/src/base/lock/lock.cc | 63 + base-codezero/src/base/lock/lock_helper.h | 112 + base-codezero/src/base/pager/pager.cc | 101 + base-codezero/src/base/thread/thread_start.cc | 79 + base-codezero/src/core/core_rm_session.cc | 67 + .../src/core/include/core_rm_session.h | 52 + .../src/core/include/irq_session_component.h | 71 + base-codezero/src/core/include/map_local.h | 66 + base-codezero/src/core/include/platform.h | 72 + base-codezero/src/core/include/platform_pd.h | 74 + .../src/core/include/platform_thread.h | 135 + base-codezero/src/core/include/util.h | 46 + .../src/core/io_mem_session_support.cc | 27 + .../src/core/io_port_session_component.cc | 58 + .../src/core/irq_session_component.cc | 72 + base-codezero/src/core/platform.cc | 293 + base-codezero/src/core/platform_pd.cc | 124 + base-codezero/src/core/platform_thread.cc | 104 + base-codezero/src/core/ram_session_support.cc | 65 + base-codezero/src/core/rm_session_support.cc | 28 + base-codezero/src/core/target.inc | 55 + base-codezero/src/core/target.mk | 4 + base-codezero/src/core/thread_start.cc | 121 + base-codezero/src/kernel/target.mk | 74 + base-codezero/src/platform/_main_helper.h | 67 + base-codezero/src/platform/genode.ld | 131 + base-codezero/tool/gen_romfs | 202 + base-fiasco/Makefile | 44 + base-fiasco/README | 4 + base-fiasco/config/kernel-config.x86 | 95 + base-fiasco/config/l4env-config.x86 | 83 + base-fiasco/doc/fiasco.txt | 130 + base-fiasco/etc/fiasco.conf | 11 + base-fiasco/etc/specs.conf | 15 + base-fiasco/etc/tools.conf | 8 + base-fiasco/include/arm/cpu/atomic.h | 39 + base-fiasco/include/base/cancelable_lock.h | 57 + base-fiasco/include/base/ipc_msgbuf.h | 65 + base-fiasco/include/base/ipc_pager.h | 173 + base-fiasco/include/base/native_types.h | 115 + base-fiasco/include/fiasco/thread_helper.h | 40 + base-fiasco/lib/mk/arm/startup.mk | 8 + base-fiasco/lib/mk/core_printf.mk | 5 + base-fiasco/lib/mk/ipc.mk | 3 + base-fiasco/lib/mk/l4v2_support.mk | 19 + base-fiasco/lib/mk/lock.mk | 3 + base-fiasco/lib/mk/pager.mk | 3 + base-fiasco/lib/mk/platform.inc | 56 + base-fiasco/lib/mk/x86/platform.mk | 6 + base-fiasco/lib/mk/x86/startup.mk | 8 + base-fiasco/mk/l4_pkg.mk | 69 + base-fiasco/mk/spec-fiasco.mk | 32 + base-fiasco/mk/spec-fiasco_arm.mk | 50 + base-fiasco/mk/spec-fiasco_x86.mk | 25 + base-fiasco/mk/spec-platform_imx.mk | 16 + base-fiasco/mk/spec-platform_integrator.mk | 14 + base-fiasco/mk/spec-platform_mmsp2.mk | 14 + base-fiasco/run/env | 127 + base-fiasco/src/base/console/core_console.h | 30 + base-fiasco/src/base/ipc/ipc.cc | 259 + base-fiasco/src/base/ipc/pager.cc | 69 + base-fiasco/src/base/lock/lock.cc | 50 + base-fiasco/src/base/pager/pager.cc | 117 + base-fiasco/src/bootstrap/target.mk | 5 + base-fiasco/src/core/arm/platform_arm.cc | 24 + base-fiasco/src/core/arm/target.mk | 7 + base-fiasco/src/core/include/map_local.h | 76 + base-fiasco/src/core/include/platform.h | 157 + base-fiasco/src/core/include/platform_pd.h | 182 + .../src/core/include/platform_thread.h | 142 + base-fiasco/src/core/include/util.h | 121 + .../src/core/io_mem_session_support.cc | 95 + base-fiasco/src/core/irq_session_component.cc | 122 + base-fiasco/src/core/platform.cc | 509 + base-fiasco/src/core/platform_pd.cc | 290 + base-fiasco/src/core/platform_thread.cc | 153 + base-fiasco/src/core/ram_session_support.cc | 27 + base-fiasco/src/core/rm_session_support.cc | 48 + base-fiasco/src/core/target.inc | 51 + base-fiasco/src/core/thread_start.cc | 62 + base-fiasco/src/core/x86/platform_x86.cc | 52 + base-fiasco/src/core/x86/target.mk | 7 + base-fiasco/src/kernel/target.inc | 23 + base-fiasco/src/kernel/x86/target.mk | 4 + base-fiasco/src/platform/_main_helper.h | 19 + base-fiasco/src/platform/arm/Makefile | 25 + base-fiasco/src/platform/arm/_main.cc | 124 + base-fiasco/src/platform/arm/crt0.s | 37 + base-fiasco/src/sigma0/target.mk | 5 + base-foc/Makefile | 98 + base-foc/README | 9 + base-foc/config/pbxa9.kernel | 83 + base-foc/config/rva9.user | 64 + base-foc/config/vea9x4.kernel | 85 + base-foc/config/x86_32.kernel | 87 + base-foc/config/x86_64.kernel | 73 + base-foc/doc/foc.txt | 142 + base-foc/etc/foc.conf | 20 + base-foc/etc/specs.conf | 8 + base-foc/include/arm/cpu/atomic.h | 54 + base-foc/include/base/cap_sel_alloc.h | 68 + base-foc/include/base/ipc.h | 56 + base-foc/include/base/ipc_msgbuf.h | 152 + base-foc/include/base/ipc_pager.h | 200 + base-foc/include/base/native_types.h | 87 + base-foc/include/base/thread_state.h | 40 + base-foc/include/foc_cpu_session/client.h | 79 + base-foc/include/foc_cpu_session/connection.h | 41 + .../include/foc_cpu_session/foc_cpu_session.h | 46 + base-foc/include/foc_pd_session/client.h | 38 + base-foc/include/foc_pd_session/connection.h | 40 + .../include/foc_pd_session/foc_pd_session.h | 40 + base-foc/include/signal_session/foc_source.h | 35 + .../include/signal_session/source_client.h | 91 + .../signal_session/source_rpc_object.h | 39 + base-foc/lib/mk/arm/ipc.mk | 4 + base-foc/lib/mk/arm/platform.inc | 8 + base-foc/lib/mk/arm/startup.mk | 8 + base-foc/lib/mk/arm/syscalls.mk | 5 + base-foc/lib/mk/cap_alloc.mk | 3 + base-foc/lib/mk/core_printf.mk | 5 + base-foc/lib/mk/env.mk | 6 + base-foc/lib/mk/ipc.inc | 5 + base-foc/lib/mk/l4re_support.mk | 14 + base-foc/lib/mk/lock.mk | 5 + base-foc/lib/mk/pager.mk | 3 + base-foc/lib/mk/platform.inc | 69 + base-foc/lib/mk/platform_pbxa9/platform.mk | 6 + base-foc/lib/mk/platform_vea9x4/platform.mk | 6 + base-foc/lib/mk/raw_server.mk | 4 + base-foc/lib/mk/server.mk | 3 + base-foc/lib/mk/thread.mk | 3 + base-foc/lib/mk/x86/syscalls.mk | 5 + base-foc/lib/mk/x86_32/ipc.mk | 3 + base-foc/lib/mk/x86_32/platform.mk | 13 + base-foc/lib/mk/x86_32/startup.mk | 8 + base-foc/lib/mk/x86_64/ipc.mk | 3 + base-foc/lib/mk/x86_64/platform.mk | 13 + base-foc/lib/mk/x86_64/startup.mk | 8 + base-foc/mk/l4_pkg.mk | 60 + base-foc/mk/spec-foc.mk | 52 + base-foc/mk/spec-foc_arm.mk | 37 + base-foc/mk/spec-foc_pbxa9.mk | 4 + base-foc/mk/spec-foc_vea9x4.mk | 4 + base-foc/mk/spec-foc_x86_32.mk | 25 + base-foc/mk/spec-foc_x86_64.mk | 30 + base-foc/patches/README | 14 + .../patches/crtn_arm_binutils_2.21.1.patch | 21 + base-foc/patches/fix_exception_ip.patch | 15 + base-foc/patches/foc_single_step_x86.patch | 241 + base-foc/patches/timer_arm.patch | 20 + base-foc/patches/vexpress_detection.patch | 13 + base-foc/run/env | 203 + base-foc/src/base/console/core_console.h | 30 + base-foc/src/base/env/cap_sel_alloc.cc | 107 + base-foc/src/base/ipc/arm/pager.cc | 27 + base-foc/src/base/ipc/arm/pager_exception.cc | 29 + base-foc/src/base/ipc/ipc.cc | 317 + base-foc/src/base/ipc/pager.cc | 110 + base-foc/src/base/ipc/x86/pager_exception.cc | 29 + base-foc/src/base/ipc/x86_32/pager.cc | 35 + base-foc/src/base/ipc/x86_64/pager.cc | 42 + base-foc/src/base/lock/lock_helper.h | 108 + base-foc/src/base/pager/pager.cc | 183 + base-foc/src/base/server/server.cc | 39 + base-foc/src/base/thread/thread.cc | 200 + base-foc/src/base/thread/thread_bootstrap.cc | 51 + base-foc/src/base/thread/thread_start.cc | 67 + base-foc/src/bootstrap/target.mk | 5 + base-foc/src/core/arm/platform_arm.cc | 16 + base-foc/src/core/arm/platform_thread.cc | 25 + base-foc/src/core/arm/target.mk | 7 + base-foc/src/core/cap_session_component.cc | 230 + base-foc/src/core/cpu_session_extension.cc | 87 + .../src/core/include/cap_session_component.h | 118 + .../src/core/include/cpu_session_component.h | 155 + .../src/core/include/irq_session_component.h | 113 + base-foc/src/core/include/map_local.h | 66 + .../src/core/include/pd_session_component.h | 57 + base-foc/src/core/include/platform.h | 157 + base-foc/src/core/include/platform_pd.h | 116 + base-foc/src/core/include/platform_thread.h | 164 + base-foc/src/core/include/util.h | 117 + base-foc/src/core/io_mem_session_support.cc | 92 + base-foc/src/core/irq_session_component.cc | 150 + base-foc/src/core/pd_session_extension.cc | 23 + base-foc/src/core/platform.cc | 500 + base-foc/src/core/platform_pd.cc | 174 + base-foc/src/core/platform_thread.cc | 307 + base-foc/src/core/ram_session_support.cc | 27 + base-foc/src/core/rm_session_support.cc | 35 + base-foc/src/core/signal_source_component.cc | 77 + base-foc/src/core/target.inc | 57 + base-foc/src/core/thread_start.cc | 68 + base-foc/src/core/x86/platform_thread.cc | 27 + base-foc/src/core/x86/platform_x86.cc | 44 + base-foc/src/core/x86/target.mk | 8 + base-foc/src/kernel/pbxa9/target.mk | 4 + base-foc/src/kernel/target.inc | 21 + base-foc/src/kernel/vea9x4/target.mk | 4 + base-foc/src/kernel/x86_32/target.mk | 4 + base-foc/src/kernel/x86_64/target.mk | 4 + base-foc/src/platform/_main_helper.h | 29 + base-foc/src/platform/_main_parent_cap.h | 36 + base-foc/src/sigma0/target.mk | 5 + base-host/README | 7 + base-host/etc/specs.conf | 13 + base-host/etc/tools.conf | 4 + base-host/include/base/ipc_msgbuf.h | 39 + base-host/include/base/ipc_pager.h | 139 + base-host/include/base/native_types.h | 45 + base-host/lib/mk/core_printf.mk | 1 + base-host/lib/mk/env.mk | 6 + base-host/lib/mk/ipc.mk | 3 + base-host/lib/mk/lock.mk | 4 + base-host/lib/mk/pager.mk | 3 + base-host/lib/mk/printf_stdio.mk | 3 + base-host/src/base/env/parent.cc | 24 + base-host/src/base/ipc/ipc.cc | 77 + base-host/src/base/lock/lock_helper.h | 52 + base-host/src/base/pager/pager.cc | 57 + base-host/src/core/context_area.cc | 90 + base-host/src/core/core_rm_session.cc | 30 + base-host/src/core/include/core_rm_session.h | 48 + base-host/src/core/include/platform.h | 50 + base-host/src/core/include/platform_pd.h | 59 + base-host/src/core/include/platform_thread.h | 106 + base-host/src/core/include/util.h | 60 + base-host/src/core/io_mem_session_support.cc | 27 + .../src/core/io_port_session_component.cc | 58 + base-host/src/core/irq_session_component.cc | 54 + base-host/src/core/platform.cc | 41 + base-host/src/core/platform_pd.cc | 55 + base-host/src/core/platform_thread.cc | 77 + base-host/src/core/ram_session_support.cc | 29 + base-host/src/core/rm_session_support.cc | 26 + base-host/src/core/target.inc | 49 + base-host/src/core/target.mk | 1 + base-host/src/core/thread_host.cc | 23 + .../src/lib/printf_stdio/printf_stdio.cc | 35 + base-linux/README | 1 + base-linux/etc/specs.conf | 22 + base-linux/include/base/ipc_msgbuf.h | 64 + base-linux/include/base/local_interface.h | 89 + base-linux/include/base/native_types.h | 135 + base-linux/include/base/pager.h | 43 + base-linux/include/base/platform_env.h | 379 + base-linux/include/linux_dataspace/client.h | 47 + .../include/linux_dataspace/linux_dataspace.h | 47 + base-linux/include/rm_session/client.h | 59 + base-linux/lib/import/import-lx_hybrid.mk | 92 + base-linux/lib/import/import-syscall.mk | 6 + base-linux/lib/mk/core_printf.mk | 5 + base-linux/lib/mk/env.mk | 6 + base-linux/lib/mk/ipc.mk | 5 + base-linux/lib/mk/lock.mk | 5 + base-linux/lib/mk/lx_hybrid.mk | 7 + base-linux/lib/mk/process.mk | 13 + base-linux/lib/mk/rpath.mk | 6 + base-linux/lib/mk/thread.mk | 6 + base-linux/lib/mk/x86_32/startup.mk | 8 + base-linux/lib/mk/x86_32/syscall.mk | 5 + base-linux/lib/mk/x86_64/startup.mk | 8 + base-linux/lib/mk/x86_64/syscall.mk | 7 + base-linux/mk/spec-linux.mk | 18 + base-linux/mk/spec-linux_x86_32.mk | 21 + base-linux/mk/spec-linux_x86_64.mk | 22 + base-linux/run/env | 43 + base-linux/run/lx_hybrid_ctors.run | 77 + base-linux/run/lx_hybrid_exception.run | 60 + base-linux/src/base/console/core_console.h | 31 + base-linux/src/base/env/debug.cc | 57 + base-linux/src/base/env/platform_env.cc | 97 + base-linux/src/base/env/rm_session_mmap.cc | 283 + base-linux/src/base/ipc/ipc.cc | 358 + base-linux/src/base/lock/lock_helper.h | 80 + base-linux/src/base/process/process.cc | 203 + base-linux/src/base/thread/thread_linux.cc | 115 + base-linux/src/core/context_area.cc | 112 + .../src/core/include/cap_session_component.h | 47 + .../src/core/include/dataspace_component.h | 91 + .../core/include/io_mem_session_component.h | 64 + .../src/core/include/irq_session_component.h | 60 + .../src/core/include/pd_session_component.h | 61 + base-linux/src/core/include/platform.h | 62 + base-linux/src/core/include/platform_pd.h | 25 + base-linux/src/core/include/platform_thread.h | 65 + .../src/core/include/rm_session_component.h | 64 + .../src/core/io_mem_session_component.cc | 27 + .../src/core/io_port_session_component.cc | 59 + base-linux/src/core/pd_session_component.cc | 51 + base-linux/src/core/platform.cc | 62 + base-linux/src/core/platform_thread.cc | 86 + base-linux/src/core/ram_session_support.cc | 59 + base-linux/src/core/rom_session_component.cc | 71 + base-linux/src/core/target.mk | 36 + base-linux/src/core/thread_linux.cc | 55 + base-linux/src/platform/_main_helper.h | 40 + .../src/platform/context_area.nostdlib.ld | 25 + .../src/platform/context_area.stdlib.ld | 20 + base-linux/src/platform/linux_rpath.cc | 39 + base-linux/src/platform/linux_rpath.h | 25 + base-linux/src/platform/linux_syscalls.h | 501 + base-linux/src/platform/lx_hybrid.cc | 47 + base-linux/src/platform/x86_32/crt0.s | 70 + base-linux/src/platform/x86_32/lx_clone.S | 109 + base-linux/src/platform/x86_32/lx_syscall.S | 77 + base-linux/src/platform/x86_64/crt0.s | 74 + base-linux/src/platform/x86_64/lx_clone.S | 71 + .../src/platform/x86_64/lx_restore_rt.S | 16 + base-linux/src/platform/x86_64/lx_syscall.S | 29 + base-linux/src/test/lx_hybrid_ctors/main.cc | 39 + base-linux/src/test/lx_hybrid_ctors/target.mk | 22 + .../src/test/lx_hybrid_ctors/testlib.cc | 24 + .../src/test/lx_hybrid_exception/main.cc | 37 + .../src/test/lx_hybrid_exception/target.mk | 3 + base-linux/src/test/sub_rm/config.h | 22 + base-mb/README | 11 + base-mb/doc/getting_started.txt | 249 + base-mb/doc/microblaze.txt | 124 + base-mb/etc/specs.conf | 1 + base-mb/etc/tools.conf | 14 + base-mb/include/base/ipc_msgbuf.h | 62 + base-mb/include/base/ipc_pager.h | 207 + base-mb/include/base/native_types.h | 62 + base-mb/include/cpu/atomic.h | 71 + base-mb/include/cpu/config.h | 116 + base-mb/include/kernel/config.h | 79 + base-mb/include/kernel/syscalls.h | 568 + base-mb/include/kernel/types.h | 329 + base-mb/include/xilinx/xps_intc.h | 226 + base-mb/include/xilinx/xps_timer.h | 399 + base-mb/include/xilinx/xps_uartl.h | 111 + base-mb/lib/mk/cxx.mk | 87 + base-mb/lib/mk/ipc.mk | 6 + base-mb/lib/mk/kernel.inc | 41 + base-mb/lib/mk/kernel_core.mk | 13 + base-mb/lib/mk/kernel_test.inc | 7 + base-mb/lib/mk/lock.mk | 6 + base-mb/lib/mk/pager.mk | 4 + ...logix_s3adsp1800_mmu__atomic_operations.mk | 6 + ...talogix_s3adsp1800_mmu__kernel_support.inc | 29 + base-mb/lib/mk/printf_microblaze.mk | 5 + base-mb/lib/mk/startup.mk | 13 + base-mb/lib/mk/test_env.mk | 6 + base-mb/lib/mk/thread.mk | 8 + base-mb/lib/mk/thread_context.mk | 5 + base-mb/mk/spec-mb_ml507.mk | 7 + base-mb/mk/spec-mb_s3a_starter_kit.mk | 7 + base-mb/platform/mb_s3a_starter_kit/Makefile | 22 + .../platform/mb_s3a_starter_kit/system.bit | Bin 0 -> 341653 bytes base-mb/platform/mk/microblaze.mk | 19 + base-mb/platform/mk/ml507.mk | 19 + base-mb/platform/mk/s3a_starter_kit.mk | 22 + base-mb/platform/mk/xilinx.mk | 24 + base-mb/run/env | 211 + base-mb/run/hello.run | 15 + base-mb/run/nested_init.run | 34 + .../src/base/console/microblaze_console.cc | 64 + base-mb/src/base/cxx/atexit.cc | 19 + base-mb/src/base/ipc/ipc.cc | 201 + base-mb/src/base/ipc/pager.cc | 74 + base-mb/src/base/lock/lock_helper.h | 57 + base-mb/src/base/pager/pager.cc | 115 + base-mb/src/base/thread/thread.cc | 207 + base-mb/src/base/thread/thread_bootstrap.cc | 22 + base-mb/src/base/thread/thread_context.cc | 57 + base-mb/src/base/thread/thread_start.cc | 73 + base-mb/src/core/context_area.cc | 148 + base-mb/src/core/core_rm_session.cc | 36 + base-mb/src/core/include/core_rm_session.h | 52 + base-mb/src/core/include/cpu/prints.h | 67 + .../src/core/include/irq_session_component.h | 73 + base-mb/src/core/include/kernel/print.h | 98 + base-mb/src/core/include/map_local.h | 49 + base-mb/src/core/include/platform.h | 118 + base-mb/src/core/include/platform_pd.h | 253 + base-mb/src/core/include/platform_thread.h | 162 + base-mb/src/core/include/util.h | 55 + base-mb/src/core/include/util/array.h | 21 + base-mb/src/core/include/util/debug.h | 62 + base-mb/src/core/include/util/id_allocator.h | 122 + base-mb/src/core/include/util/math.h | 40 + base-mb/src/core/include/util/queue.h | 145 + base-mb/src/core/include/xilinx/microblaze.h | 403 + base-mb/src/core/io_mem_session_support.cc | 28 + base-mb/src/core/io_port_session_component.cc | 41 + base-mb/src/core/irq_session_component.cc | 68 + base-mb/src/core/platform.cc | 312 + base-mb/src/core/platform_thread.cc | 183 + base-mb/src/core/ram_session_support.cc | 45 + base-mb/src/core/rm_session_support.cc | 38 + base-mb/src/core/target.inc | 52 + base-mb/src/core/target.mk | 10 + base-mb/src/core/thread_roottask.cc | 110 + base-mb/src/kernel/generic/blocking.cc | 268 + .../src/kernel/generic/include/exception.h | 82 + .../src/kernel/generic/include/interrupt.h | 50 + base-mb/src/kernel/generic/include/thread.h | 360 + base-mb/src/kernel/generic/kernel.cc | 189 + base-mb/src/kernel/generic/scheduler.cc | 130 + base-mb/src/kernel/generic/syscall_events.cc | 187 + base-mb/src/kernel/generic/thread.cc | 117 + base-mb/src/kernel/include/generic/blocking.h | 417 + base-mb/src/kernel/include/generic/event.h | 103 + base-mb/src/kernel/include/generic/ipc.h | 323 + .../kernel/include/generic/irq_controller.h | 153 + base-mb/src/kernel/include/generic/printf.h | 21 + .../src/kernel/include/generic/scheduler.h | 372 + .../kernel/include/generic/syscall_events.h | 190 + base-mb/src/kernel/include/generic/timer.h | 197 + base-mb/src/kernel/include/generic/tlb.h | 152 + base-mb/src/kernel/include/generic/verbose.h | 107 + .../platform/platform.h | 729 + .../petalogix_s3adsp1800_mmu/atomic.s | 92 + .../platforms/petalogix_s3adsp1800_mmu/crt0.s | 45 + .../petalogix_s3adsp1800_mmu/crt0_kernel.s | 93 + .../petalogix_s3adsp1800_mmu/include/errors.s | 23 + .../include/exec_context.s | 527 + .../include/linker_commands.s | 34 + .../include/special_registers.s | 59 + .../petalogix_s3adsp1800_mmu/kernel_entry.s | 209 + .../petalogix_s3adsp1800_mmu/platform.cc | 205 + .../petalogix_s3adsp1800_mmu/userland_entry.s | 223 + base-mb/src/platform/_main_helper.h | 54 + base-mb/src/platform/genode.ld | 115 + base-mb/src/test/hello/main.cc | 23 + base-mb/src/test/hello/target.mk | 3 + base-nova/Makefile | 47 + base-nova/README | 10 + base-nova/doc/nova.txt | 254 + base-nova/etc/specs.conf | 5 + base-nova/include/base/cap_sel_alloc.h | 72 + base-nova/include/base/ipc.h | 36 + base-nova/include/base/ipc_msgbuf.h | 186 + base-nova/include/base/ipc_pager.h | 137 + base-nova/include/base/native_types.h | 88 + base-nova/include/base/pager.h | 154 + base-nova/include/base/sleep.h | 34 + base-nova/include/nova/stdint.h | 28 + base-nova/include/nova/syscalls.h | 673 + .../include/signal_session/nova_source.h | 34 + .../include/signal_session/source_client.h | 82 + .../signal_session/source_rpc_object.h | 39 + base-nova/lib/mk/core_printf.mk | 5 + base-nova/lib/mk/env.mk | 7 + base-nova/lib/mk/ipc.mk | 6 + base-nova/lib/mk/lock.mk | 5 + base-nova/lib/mk/pager.mk | 3 + base-nova/lib/mk/printf_stdio.mk | 3 + base-nova/lib/mk/raw_server.mk | 4 + base-nova/lib/mk/server.mk | 3 + base-nova/lib/mk/test_env.mk | 11 + base-nova/lib/mk/thread.mk | 6 + base-nova/lib/mk/thread_context.mk | 3 + base-nova/lib/mk/x86_32/startup.mk | 8 + base-nova/mk/spec-nova.mk | 16 + base-nova/patches/README | 21 + base-nova/patches/utcb.patch | 18 + base-nova/run/env | 82 + base-nova/src/base/console/core_console.h | 129 + base-nova/src/base/env/cap_sel_alloc.cc | 121 + base-nova/src/base/env/main_thread.cc | 43 + base-nova/src/base/ipc/ipc.cc | 200 + base-nova/src/base/ipc/pager.cc | 67 + base-nova/src/base/lock/lock_helper.h | 88 + base-nova/src/base/pager/pager.cc | 177 + base-nova/src/base/server/server.cc | 187 + base-nova/src/base/thread/thread_context.cc | 38 + base-nova/src/base/thread/thread_nova.cc | 141 + base-nova/src/core/core_rm_session.cc | 53 + base-nova/src/core/echo.cc | 62 + .../src/core/include/cap_session_component.h | 48 + base-nova/src/core/include/core_rm_session.h | 52 + base-nova/src/core/include/echo.h | 54 + .../src/core/include/irq_session_component.h | 74 + base-nova/src/core/include/map_local.h | 45 + base-nova/src/core/include/nova_util.h | 141 + base-nova/src/core/include/platform.h | 81 + base-nova/src/core/include/platform_pd.h | 79 + base-nova/src/core/include/platform_thread.h | 125 + base-nova/src/core/include/util.h | 74 + base-nova/src/core/io_mem_session_support.cc | 59 + base-nova/src/core/irq_session_component.cc | 74 + base-nova/src/core/platform.cc | 352 + base-nova/src/core/platform_pd.cc | 57 + base-nova/src/core/platform_thread.cc | 143 + base-nova/src/core/ram_session_support.cc | 77 + base-nova/src/core/rm_session_support.cc | 55 + base-nova/src/core/signal_source_component.cc | 73 + base-nova/src/core/target.inc | 56 + base-nova/src/core/target.mk | 4 + base-nova/src/core/thread_start.cc | 63 + base-nova/src/kernel/target.mk | 35 + .../src/lib/printf_stdio/printf_stdio.cc | 35 + base-nova/src/platform/_main_helper.h | 58 + base-nova/src/platform/_main_parent_cap.h | 46 + base-nova/src/platform/roottask.ld | 104 + base-okl4/Makefile | 49 + base-okl4/README | 10 + base-okl4/contrib/generated/README | 8 + base-okl4/contrib/generated/x86/asmsyms.h | 69 + .../contrib/generated/x86/kdb_class_helper.h | 119 + base-okl4/contrib/generated/x86/ktcb_layout.h | 71 + base-okl4/contrib/generated/x86/linker.ld | 148 + base-okl4/contrib/generated/x86/macro_sets.cc | 401 + base-okl4/contrib/generated/x86/tcb_layout.h | 105 + base-okl4/doc/notes.txt | 863 ++ base-okl4/doc/okl4.txt | 131 + base-okl4/etc/specs.conf | 1 + base-okl4/include/base/ipc_msgbuf.h | 68 + base-okl4/include/base/ipc_pager.h | 180 + base-okl4/include/base/native_types.h | 127 + base-okl4/include/base/thread_state.h | 33 + base-okl4/include/okl4_pd_session/client.h | 41 + .../include/okl4_pd_session/connection.h | 41 + .../include/okl4_pd_session/okl4_pd_session.h | 62 + base-okl4/lib/mk/bootinfo.mk | 5 + base-okl4/lib/mk/core_printf.mk | 5 + base-okl4/lib/mk/ipc.mk | 3 + base-okl4/lib/mk/kernel.inc | 97 + base-okl4/lib/mk/lock.mk | 4 + base-okl4/lib/mk/pager.mk | 3 + base-okl4/lib/mk/platform.inc | 57 + base-okl4/lib/mk/thread.mk | 5 + base-okl4/lib/mk/x86/kernel.mk | 112 + base-okl4/lib/mk/x86/platform.mk | 16 + base-okl4/lib/mk/x86/startup.mk | 8 + base-okl4/mk/spec-okl4.mk | 50 + base-okl4/mk/spec-okl4_x86.mk | 17 + base-okl4/patches/README | 71 + base-okl4/patches/char_bit.patch | 25 + base-okl4/patches/eabi_build.patch | 232 + base-okl4/patches/elfweaver.patch | 11 + base-okl4/patches/gcc_4.4.5.patch | 54 + base-okl4/patches/gdt_init.patch | 12 + base-okl4/patches/kdb_reboot.patch | 54 + base-okl4/patches/reply_tid.patch | 21 + base-okl4/patches/suspend_resume.patch | 28 + base-okl4/patches/syscall_pic.patch | 411 + base-okl4/run/env | 200 + base-okl4/run/priority.run | 42 + base-okl4/src/base/bootinfo/README | 2 + base-okl4/src/base/bootinfo/stdint.h | 20 + base-okl4/src/base/bootinfo/stdio.h | 12 + base-okl4/src/base/console/core_console.h | 31 + base-okl4/src/base/ipc/ipc.cc | 287 + base-okl4/src/base/ipc/pager.cc | 143 + base-okl4/src/base/lock/lock_helper.h | 102 + base-okl4/src/base/pager/pager.cc | 120 + base-okl4/src/base/thread/thread_bootstrap.cc | 29 + base-okl4/src/core/core_rm_session.cc | 62 + base-okl4/src/core/include/core_rm_session.h | 57 + base-okl4/src/core/include/map_local.h | 126 + .../src/core/include/pd_session_component.h | 59 + base-okl4/src/core/include/platform.h | 134 + base-okl4/src/core/include/platform_pd.h | 191 + base-okl4/src/core/include/platform_thread.h | 150 + base-okl4/src/core/include/stdint.h | 22 + base-okl4/src/core/include/util.h | 131 + base-okl4/src/core/io_mem_session_support.cc | 27 + base-okl4/src/core/irq_session_component.cc | 316 + .../src/core/okl4_pd_session_component.cc | 28 + base-okl4/src/core/platform.cc | 318 + base-okl4/src/core/platform_pd.cc | 315 + base-okl4/src/core/platform_thread.cc | 197 + base-okl4/src/core/ram_session_support.cc | 66 + base-okl4/src/core/rm_session_support.cc | 90 + base-okl4/src/core/target.inc | 55 + base-okl4/src/core/thread_start.cc | 59 + base-okl4/src/core/x86/platform_thread_x86.cc | 57 + base-okl4/src/core/x86/target.mk | 8 + base-okl4/src/kernel/target.inc | 67 + base-okl4/src/kernel/x86/target.mk | 56 + base-okl4/src/platform/_main_helper.h | 50 + base-okl4/src/test/create_thread.h | 144 + base-okl4/src/test/io_port.h | 36 + base-okl4/src/test/mini_env.h | 83 + base-okl4/src/test/okl4_01_hello_raw/Makefile | 27 + base-okl4/src/test/okl4_01_hello_raw/crt0.s | 54 + .../src/test/okl4_01_hello_raw/genode.ld | 89 + base-okl4/src/test/okl4_01_hello_raw/hello.cc | 76 + .../src/test/okl4_01_hello_raw/weaver.xml | 61 + base-okl4/src/test/okl4_02_hello/hello.cc | 37 + base-okl4/src/test/okl4_02_hello/target.mk | 4 + base-okl4/src/test/okl4_03_thread/main.cc | 76 + base-okl4/src/test/okl4_03_thread/target.mk | 4 + .../src/test/okl4_04_ipc_send_wait/main.cc | 79 + .../src/test/okl4_04_ipc_send_wait/target.mk | 4 + base-okl4/src/test/okl4_05_ipc_call/main.cc | 90 + base-okl4/src/test/okl4_05_ipc_call/target.mk | 4 + base-okl4/src/test/okl4_06_pager/main.cc | 142 + base-okl4/src/test/okl4_06_pager/target.mk | 4 + base-okl4/src/test/okl4_07_boot_info/main.cc | 103 + base-okl4/src/test/okl4_07_boot_info/stdint.h | 22 + .../src/test/okl4_07_boot_info/target.mk | 5 + base-okl4/src/test/okl4_08_timer_pit/main.cc | 135 + .../src/test/okl4_08_timer_pit/target.mk | 4 + base-okl4/tool/README | 3 + base-okl4/tool/weaver_x86.xml | 76 + base-pistachio/Makefile | 40 + base-pistachio/README | 3 + base-pistachio/config/kernel | 153 + base-pistachio/doc/pistachio.txt | 78 + base-pistachio/etc/specs.conf | 1 + base-pistachio/include/base/clock.h | 37 + base-pistachio/include/base/ipc_msgbuf.h | 65 + base-pistachio/include/base/ipc_pager.h | 195 + base-pistachio/include/base/native_types.h | 111 + base-pistachio/include/pistachio/kip.h | 56 + .../include/pistachio/thread_helper.h | 45 + base-pistachio/include/util/hexdump.h | 39 + base-pistachio/include/x86/cpu/rdtsc.h | 30 + base-pistachio/include/x86/util/smath.h | 54 + base-pistachio/lib/mk/core_printf.mk | 5 + base-pistachio/lib/mk/hexdump.mk | 3 + base-pistachio/lib/mk/ipc.mk | 3 + base-pistachio/lib/mk/kip.mk | 5 + base-pistachio/lib/mk/l4.mk | 11 + base-pistachio/lib/mk/lock.mk | 4 + base-pistachio/lib/mk/pager.mk | 3 + base-pistachio/lib/mk/platform.mk | 25 + base-pistachio/lib/mk/x86/startup.mk | 8 + base-pistachio/mk/spec-pistachio.mk | 41 + base-pistachio/mk/spec-pistachio_x86.mk | 14 + base-pistachio/patches/README | 20 + base-pistachio/patches/syscalls_ia32.patch | 280 + base-pistachio/run/env | 108 + .../src/base/console/core_console.h | 31 + base-pistachio/src/base/ipc/ipc.cc | 355 + base-pistachio/src/base/ipc/pager.cc | 139 + base-pistachio/src/base/kip/kip.cc | 57 + base-pistachio/src/base/lock/lock_helper.h | 102 + base-pistachio/src/base/pager/pager.cc | 118 + .../src/core/cpu_session_platform.cc | 15 + base-pistachio/src/core/include/map_local.h | 82 + base-pistachio/src/core/include/platform.h | 156 + base-pistachio/src/core/include/platform_pd.h | 214 + .../src/core/include/platform_thread.h | 151 + base-pistachio/src/core/include/util.h | 126 + .../src/core/io_mem_session_support.cc | 123 + .../src/core/irq_session_component.cc | 134 + base-pistachio/src/core/multiboot_info.cc | 162 + base-pistachio/src/core/platform.cc | 648 + base-pistachio/src/core/platform_pd.cc | 387 + base-pistachio/src/core/platform_thread.cc | 235 + .../src/core/ram_session_support.cc | 27 + base-pistachio/src/core/rm_session_support.cc | 50 + base-pistachio/src/core/target.inc | 52 + base-pistachio/src/core/thread_start.cc | 62 + base-pistachio/src/core/x86/platform_x86.cc | 32 + base-pistachio/src/core/x86/target.mk | 7 + base-pistachio/src/kernel/target.mk | 61 + base-pistachio/src/platform/_main_helper.h | 26 + base-pistachio/src/util/hexdump/hexdump.cc | 55 + base/README | 12 + base/etc/README | 16 + base/etc/tools.conf | 57 + base/include/32bit/base/fixed_stdint.h | 60 + base/include/64bit/base/fixed_stdint.h | 50 + base/include/README | 3 + base/include/arm/cpu/cpu_state.h | 32 + base/include/base/allocator.h | 205 + base/include/base/allocator_avl.h | 325 + base/include/base/allocator_guard.h | 93 + base/include/base/blocking.h | 28 + base/include/base/cancelable_lock.h | 94 + base/include/base/capability.h | 291 + base/include/base/child.h | 583 + base/include/base/connection.h | 98 + base/include/base/console.h | 60 + base/include/base/cpu_state.h | 35 + base/include/base/crt0.h | 45 + base/include/base/elf.h | 157 + base/include/base/env.h | 88 + base/include/base/errno.h | 22 + base/include/base/exception.h | 19 + base/include/base/heap.h | 182 + base/include/base/ipc.h | 41 + base/include/base/ipc_generic.h | 624 + base/include/base/lock.h | 47 + base/include/base/lock_guard.h | 46 + base/include/base/object_pool.h | 130 + base/include/base/pager.h | 199 + base/include/base/platform_env.h | 150 + base/include/base/printf.h | 105 + base/include/base/process.h | 92 + base/include/base/rpc.h | 287 + base/include/base/rpc_args.h | 121 + base/include/base/rpc_client.h | 135 + base/include/base/rpc_server.h | 394 + base/include/base/semaphore.h | 173 + base/include/base/service.h | 414 + base/include/base/signal.h | 284 + base/include/base/slab.h | 255 + base/include/base/sleep.h | 29 + base/include/base/snprintf.h | 82 + base/include/base/stdint.h | 43 + base/include/base/sync_allocator.h | 168 + base/include/base/thread.h | 367 + base/include/base/thread_state.h | 26 + base/include/base/tslab.h | 35 + base/include/cap_session/cap_session.h | 59 + base/include/cap_session/capability.h | 22 + base/include/cap_session/client.h | 35 + base/include/cap_session/connection.h | 32 + base/include/cpu_session/capability.h | 22 + base/include/cpu_session/client.h | 65 + base/include/cpu_session/connection.h | 42 + base/include/cpu_session/cpu_session.h | 230 + base/include/dataspace/capability.h | 22 + base/include/dataspace/client.h | 33 + base/include/dataspace/dataspace.h | 54 + base/include/io_mem_session/capability.h | 22 + base/include/io_mem_session/client.h | 31 + base/include/io_mem_session/connection.h | 42 + base/include/io_mem_session/io_mem_session.h | 51 + base/include/io_port_session/capability.h | 22 + base/include/io_port_session/client.h | 47 + base/include/io_port_session/connection.h | 42 + .../include/io_port_session/io_port_session.h | 116 + base/include/irq_session/capability.h | 22 + base/include/irq_session/client.h | 31 + base/include/irq_session/connection.h | 39 + base/include/irq_session/irq_session.h | 47 + base/include/log_session/capability.h | 22 + base/include/log_session/client.h | 32 + base/include/log_session/connection.h | 32 + base/include/log_session/log_session.h | 49 + base/include/pager/capability.h | 30 + base/include/parent/capability.h | 22 + base/include/parent/client.h | 43 + base/include/parent/parent.h | 152 + base/include/pd_session/capability.h | 22 + base/include/pd_session/client.h | 35 + base/include/pd_session/connection.h | 41 + base/include/pd_session/pd_session.h | 63 + base/include/ram_session/capability.h | 29 + base/include/ram_session/client.h | 45 + base/include/ram_session/connection.h | 40 + base/include/ram_session/ram_session.h | 127 + base/include/rm_session/capability.h | 22 + base/include/rm_session/client.h | 51 + base/include/rm_session/connection.h | 40 + base/include/rm_session/rm_session.h | 196 + base/include/rom_session/capability.h | 22 + base/include/rom_session/client.h | 32 + base/include/rom_session/connection.h | 60 + base/include/rom_session/rom_session.h | 55 + base/include/root/capability.h | 22 + base/include/root/client.h | 38 + base/include/root/component.h | 250 + base/include/root/root.h | 93 + base/include/session/capability.h | 22 + base/include/session/session.h | 38 + base/include/signal_session/capability.h | 25 + base/include/signal_session/client.h | 43 + base/include/signal_session/connection.h | 32 + base/include/signal_session/signal_session.h | 96 + base/include/signal_session/source.h | 75 + base/include/signal_session/source_client.h | 33 + .../signal_session/source_rpc_object.h | 28 + base/include/thread/capability.h | 29 + base/include/util/arg_string.h | 325 + base/include/util/avl_string.h | 77 + base/include/util/avl_tree.h | 203 + base/include/util/fifo.h | 108 + base/include/util/list.h | 126 + base/include/util/meta.h | 636 + base/include/util/misc_math.h | 72 + base/include/util/string.h | 417 + base/include/util/token.h | 210 + base/include/util/touch.h | 35 + base/include/x86/cpu/atomic.h | 53 + base/include/x86/cpu/consts.h | 35 + base/include/x86_32/cpu/cpu_state.h | 48 + base/include/x86_64/cpu/cpu_state.h | 54 + base/lib/README | 1 + base/lib/import/import-stdcxx.mk | 21 + base/lib/mk/README | 24 + base/lib/mk/allocator_avl.mk | 4 + base/lib/mk/avl_tree.mk | 3 + base/lib/mk/console.mk | 3 + base/lib/mk/cxx.mk | 68 + base/lib/mk/elf.mk | 3 + base/lib/mk/env.mk | 5 + base/lib/mk/heap.mk | 4 + base/lib/mk/host/cxx.mk | 3 + base/lib/mk/log_console.mk | 4 + base/lib/mk/platform.mk | 0 base/lib/mk/process.mk | 4 + base/lib/mk/raw_server.mk | 3 + base/lib/mk/raw_signal.mk | 3 + base/lib/mk/server.mk | 3 + base/lib/mk/signal.mk | 3 + base/lib/mk/slab.mk | 3 + base/lib/mk/stdcxx.mk | 7 + base/lib/mk/thread.mk | 3 + base/mk/README | 14 + base/mk/base-libs.mk | 14 + base/mk/dep_lib.mk | 146 + base/mk/dep_prg.mk | 71 + base/mk/generic.mk | 85 + base/mk/global.mk | 175 + base/mk/lib.mk | 178 + base/mk/prg.mk | 183 + base/mk/spec-32bit.mk | 4 + base/mk/spec-64bit.mk | 4 + base/mk/spec-arm.mk | 14 + base/mk/spec-arm_v5.mk | 8 + base/mk/spec-arm_v7a.mk | 8 + base/mk/spec-experimental.mk | 1 + base/mk/spec-host.mk | 8 + base/mk/spec-platform_pbxa9.mk | 16 + base/mk/spec-platform_vea9x4.mk | 16 + base/mk/spec-platform_vpb926.mk | 18 + base/mk/spec-release.mk | 1 + base/mk/spec-x86_32.mk | 19 + base/mk/spec-x86_64.mk | 12 + base/run/rm_fault.run | 35 + base/run/sub_rm.run | 63 + base/src/README | 1 + base/src/base/README | 7 + base/src/base/allocator/README | 5 + base/src/base/allocator/allocator_avl.cc | 357 + base/src/base/allocator/slab.cc | 296 + base/src/base/avl_tree/avl_tree.cc | 164 + base/src/base/console/console.cc | 335 + base/src/base/console/core_printf.cc | 73 + base/src/base/console/log_console.cc | 127 + base/src/base/cxx/exception.cc | 38 + base/src/base/cxx/guard.cc | 72 + base/src/base/cxx/malloc_free.cc | 92 + base/src/base/cxx/misc.cc | 202 + base/src/base/cxx/new_delete.cc | 35 + base/src/base/cxx/unwind.cc | 45 + base/src/base/elf/elf.h | 254 + base/src/base/elf/elf_binary.cc | 159 + base/src/base/env/context_area.cc | 47 + base/src/base/env/env.cc | 31 + base/src/base/heap/heap.cc | 150 + base/src/base/heap/sliced_heap.cc | 114 + base/src/base/lock/lock.cc | 214 + base/src/base/process/process.cc | 279 + base/src/base/server/common.cc | 151 + base/src/base/server/server.cc | 39 + base/src/base/signal/signal.cc | 299 + base/src/base/thread/thread.cc | 208 + base/src/base/thread/thread_bootstrap.cc | 18 + base/src/base/thread/thread_start.cc | 71 + .../src/core/arm/io_port_session_component.cc | 63 + base/src/core/context_area.cc | 153 + base/src/core/core_mem_alloc.cc | 63 + base/src/core/cpu_session_component.cc | 196 + base/src/core/dataspace_component.cc | 52 + base/src/core/dump_alloc.cc | 58 + base/src/core/include/cap_root.h | 47 + base/src/core/include/cap_session_component.h | 47 + base/src/core/include/core_env.h | 179 + base/src/core/include/core_mem_alloc.h | 172 + base/src/core/include/core_parent.h | 61 + base/src/core/include/core_rm_session.h | 63 + base/src/core/include/cpu_root.h | 59 + base/src/core/include/cpu_session_component.h | 144 + base/src/core/include/dataspace_component.h | 139 + base/src/core/include/io_mem_root.h | 63 + .../core/include/io_mem_session_component.h | 139 + base/src/core/include/io_port_root.h | 71 + .../core/include/io_port_session_component.h | 77 + base/src/core/include/irq_root.h | 113 + base/src/core/include/irq_session_component.h | 140 + base/src/core/include/log_root.h | 54 + base/src/core/include/log_session_component.h | 85 + base/src/core/include/multiboot.h | 69 + base/src/core/include/pd_root.h | 54 + base/src/core/include/pd_session_component.h | 49 + base/src/core/include/platform_generic.h | 109 + base/src/core/include/ram_root.h | 65 + base/src/core/include/ram_session_component.h | 163 + base/src/core/include/rm_root.h | 97 + base/src/core/include/rm_session_component.h | 354 + base/src/core/include/rom_fs.h | 100 + base/src/core/include/rom_root.h | 55 + base/src/core/include/rom_session_component.h | 72 + base/src/core/include/signal_root.h | 75 + .../core/include/signal_session_component.h | 166 + base/src/core/io_mem_session_component.cc | 114 + base/src/core/main.cc | 245 + base/src/core/mb_info.h | 175 + base/src/core/multiboot_info.cc | 143 + base/src/core/pd_session_component.cc | 50 + base/src/core/ram_session_component.cc | 275 + base/src/core/rm_session_component.cc | 725 + base/src/core/rom_session_component.cc | 42 + base/src/core/signal_session_component.cc | 101 + base/src/core/signal_source_component.cc | 84 + .../src/core/x86/io_port_session_component.cc | 138 + base/src/platform/_main.cc | 259 + base/src/platform/_main_parent_cap.h | 33 + base/src/platform/arm/crt0.s | 37 + base/src/platform/genode.ld | 117 + base/src/platform/x86_32/crt0.s | 61 + base/src/platform/x86_64/crt0.s | 65 + base/src/test/rm_fault/main.cc | 213 + base/src/test/rm_fault/target.mk | 3 + base/src/test/rm_nested/main.cc | 123 + base/src/test/rm_nested/target.mk | 4 + base/src/test/sub_rm/config.h | 15 + base/src/test/sub_rm/main.cc | 191 + base/src/test/sub_rm/target.mk | 6 + dde_ipxe/Makefile | 54 + dde_ipxe/README | 18 + dde_ipxe/include/dde_ipxe/nic.h | 67 + dde_ipxe/lib/mk/dde_ipxe_nic.mk | 49 + dde_ipxe/lib/mk/dde_ipxe_support.mk | 5 + dde_ipxe/patches/dde_ipxe.patch | 42 + dde_ipxe/src/drivers/nic/main.cc | 136 + dde_ipxe/src/drivers/nic/target.mk | 3 + dde_ipxe/src/lib/dde_ipxe/dde.c | 350 + dde_ipxe/src/lib/dde_ipxe/dde_support.cc | 86 + dde_ipxe/src/lib/dde_ipxe/dummies.c | 30 + .../src/lib/dde_ipxe/include/bits/byteswap.h | 1 + .../src/lib/dde_ipxe/include/bits/compiler.h | 1 + dde_ipxe/src/lib/dde_ipxe/include/bits/cpu.h | 0 .../src/lib/dde_ipxe/include/bits/eltorito.h | 0 .../src/lib/dde_ipxe/include/bits/endian.h | 1 + .../src/lib/dde_ipxe/include/bits/errfile.h | 1 + dde_ipxe/src/lib/dde_ipxe/include/bits/io.h | 1 + dde_ipxe/src/lib/dde_ipxe/include/bits/nap.h | 0 .../src/lib/dde_ipxe/include/bits/pci_io.h | 3 + .../src/lib/dde_ipxe/include/bits/smbios.h | 0 .../src/lib/dde_ipxe/include/bits/stdint.h | 1 + .../src/lib/dde_ipxe/include/bits/string.h | 1 + .../src/lib/dde_ipxe/include/bits/timer.h | 6 + .../src/lib/dde_ipxe/include/bits/uaccess.h | 1 + .../src/lib/dde_ipxe/include/bits/umalloc.h | 0 .../dde_ipxe/include/config/local/console.h | 0 .../dde_ipxe/include/config/local/general.h | 0 .../lib/dde_ipxe/include/config/local/ioapi.h | 0 .../lib/dde_ipxe/include/config/local/nap.h | 0 .../dde_ipxe/include/config/local/serial.h | 0 .../lib/dde_ipxe/include/config/local/timer.h | 0 .../dde_ipxe/include/config/local/umalloc.h | 0 .../src/lib/dde_ipxe/include/env_dde_kit.h | 68 + dde_ipxe/src/lib/dde_ipxe/local.h | 28 + dde_ipxe/src/lib/dde_ipxe/nic.c | 337 + demo/doc/demo.txt | 216 + demo/doc/img/genode_logo.png | Bin 0 -> 17091 bytes demo/doc/img/launchpad.png | Bin 0 -> 58017 bytes demo/doc/img/liquid_fb.png | Bin 0 -> 240040 bytes demo/doc/img/liquid_fb_small.png | Bin 0 -> 288612 bytes demo/doc/img/setup.png | Bin 0 -> 82437 bytes demo/doc/img/x-ray.png | Bin 0 -> 99749 bytes demo/doc/img/x-ray_small.png | Bin 0 -> 225817 bytes demo/include/launchpad/launchpad.h | 231 + demo/include/libpng_static/png.h | 3481 +++++ demo/include/libpng_static/pngconf.h | 1472 ++ demo/include/libpng_static/pngusr.h | 19 + demo/include/libz_static/zconf.h | 332 + demo/include/libz_static/zlib.h | 1357 ++ demo/include/mini_c/errno.h | 21 + demo/include/mini_c/limits.h | 14 + demo/include/mini_c/stdio.h | 41 + demo/include/mini_c/stdlib.h | 30 + demo/include/mini_c/string.h | 31 + demo/include/mini_c/sys/types.h | 14 + demo/lib/import/import-libpng_static.mk | 1 + demo/lib/import/import-libz_static.mk | 1 + demo/lib/import/import-mini_c.mk | 1 + demo/lib/mk/launchpad.mk | 4 + demo/lib/mk/libpng_static.mk | 12 + demo/lib/mk/libz_static.mk | 9 + demo/lib/mk/mini_c.mk | 10 + demo/lib/mk/scout_widgets.mk | 42 + demo/src/app/backdrop/README | 19 + demo/src/app/backdrop/main.cc | 264 + demo/src/app/backdrop/target.mk | 4 + demo/src/app/launchpad/README | 34 + demo/src/app/launchpad/child_entry.h | 146 + demo/src/app/launchpad/launch_entry.h | 90 + demo/src/app/launchpad/launcher.cc | 28 + demo/src/app/launchpad/launchpad_window.cc | 173 + demo/src/app/launchpad/launchpad_window.h | 171 + demo/src/app/launchpad/loadbar.h | 254 + demo/src/app/launchpad/main.cc | 250 + demo/src/app/launchpad/section.h | 73 + demo/src/app/launchpad/status_entry.h | 71 + demo/src/app/launchpad/target.mk | 11 + demo/src/app/scout/common/about.cc | 191 + demo/src/app/scout/common/browser_window.cc | 460 + demo/src/app/scout/common/doc.cc | 456 + demo/src/app/scout/common/elements.cc | 453 + demo/src/app/scout/common/main.cc | 158 + demo/src/app/scout/common/navbar.cc | 200 + demo/src/app/scout/common/png_image.cc | 148 + demo/src/app/scout/common/refracted_icon.cc | 184 + demo/src/app/scout/common/scrollbar.cc | 327 + demo/src/app/scout/common/sky_texture.cc | 363 + demo/src/app/scout/common/test.txt | 11 + demo/src/app/scout/common/tick.cc | 125 + demo/src/app/scout/common/widgets.cc | 474 + demo/src/app/scout/data/about.rgba | Bin 0 -> 16384 bytes demo/src/app/scout/data/backward.rgba | Bin 0 -> 16384 bytes demo/src/app/scout/data/closed_icon.rgba | Bin 0 -> 1024 bytes demo/src/app/scout/data/cover.rgba | 1 + demo/src/app/scout/data/downarrow.rgba | Bin 0 -> 4096 bytes demo/src/app/scout/data/forward.rgba | Bin 0 -> 16384 bytes demo/src/app/scout/data/home.rgba | Bin 0 -> 16384 bytes demo/src/app/scout/data/index.rgba | Bin 0 -> 16384 bytes demo/src/app/scout/data/ior.map | Bin 0 -> 32768 bytes demo/src/app/scout/data/kill_icon.rgba | Bin 0 -> 1024 bytes demo/src/app/scout/data/loadbar.rgba | Bin 0 -> 1024 bytes demo/src/app/scout/data/mono16.tff | Bin 0 -> 45832 bytes demo/src/app/scout/data/nav_next.rgba | Bin 0 -> 16384 bytes demo/src/app/scout/data/nav_prev.rgba | Bin 0 -> 16384 bytes demo/src/app/scout/data/opened_icon.rgba | Bin 0 -> 1024 bytes demo/src/app/scout/data/pointer.rgba | Bin 0 -> 4096 bytes demo/src/app/scout/data/redbar.rgba | Bin 0 -> 1024 bytes demo/src/app/scout/data/sizer.rgba | Bin 0 -> 4096 bytes demo/src/app/scout/data/slider.rgba | Bin 0 -> 4096 bytes demo/src/app/scout/data/test.png | Bin 0 -> 45070 bytes demo/src/app/scout/data/titlebar.rgba | Bin 0 -> 4096 bytes demo/src/app/scout/data/uparrow.rgba | Bin 0 -> 4096 bytes demo/src/app/scout/data/vera16.tff | Bin 0 -> 52036 bytes demo/src/app/scout/data/vera18.tff | Bin 0 -> 63612 bytes demo/src/app/scout/data/vera20.tff | Bin 0 -> 80131 bytes demo/src/app/scout/data/vera22.tff | Bin 0 -> 96920 bytes demo/src/app/scout/data/vera24.tff | Bin 0 -> 112576 bytes demo/src/app/scout/data/verabi10.tff | Bin 0 -> 26458 bytes demo/src/app/scout/data/verai16.tff | Bin 0 -> 52656 bytes demo/src/app/scout/data/whitebar.rgba | Bin 0 -> 1024 bytes demo/src/app/scout/genode/launcher.cc | 29 + demo/src/app/scout/genode/platform_genode.cc | 382 + demo/src/app/scout/genode/startup.cc | 17 + demo/src/app/scout/genode/target.mk | 35 + demo/src/app/scout/include/browser.h | 162 + demo/src/app/scout/include/browser_window.h | 159 + demo/src/app/scout/include/canvas.h | 325 + demo/src/app/scout/include/canvas_rgb565.h | 236 + demo/src/app/scout/include/color.h | 52 + demo/src/app/scout/include/config.h | 26 + demo/src/app/scout/include/elements.h | 810 ++ demo/src/app/scout/include/event.h | 82 + demo/src/app/scout/include/fade_icon.h | 95 + demo/src/app/scout/include/fader.h | 78 + demo/src/app/scout/include/font.h | 62 + demo/src/app/scout/include/genode/alloc.h | 30 + .../scout/include/genode/launcher_config.h | 38 + demo/src/app/scout/include/genode/printf.h | 30 + demo/src/app/scout/include/genode/string.h | 28 + demo/src/app/scout/include/history.h | 112 + demo/src/app/scout/include/miscmath.h | 35 + demo/src/app/scout/include/platform.h | 161 + demo/src/app/scout/include/redraw_manager.h | 150 + demo/src/app/scout/include/refracted_icon.h | 76 + demo/src/app/scout/include/scout_types.h | 21 + demo/src/app/scout/include/scrollbar.h | 106 + demo/src/app/scout/include/sky_texture.h | 43 + demo/src/app/scout/include/styles.h | 53 + demo/src/app/scout/include/tick.h | 87 + demo/src/app/scout/include/titlebar.h | 91 + demo/src/app/scout/include/user_state.h | 164 + demo/src/app/scout/include/widgets.h | 165 + demo/src/app/scout/include/window.h | 222 + demo/src/lib/launchpad/launchpad.cc | 370 + demo/src/lib/libpng/contrib/png.c | 847 ++ demo/src/lib/libpng/contrib/pngerror.c | 313 + demo/src/lib/libpng/contrib/pngget.c | 937 ++ demo/src/lib/libpng/contrib/pngmem.c | 598 + demo/src/lib/libpng/contrib/pngpread.c | 1578 +++ demo/src/lib/libpng/contrib/pngread.c | 1461 ++ demo/src/lib/libpng/contrib/pngrio.c | 164 + demo/src/lib/libpng/contrib/pngrtran.c | 4219 ++++++ demo/src/lib/libpng/contrib/pngrutil.c | 3123 +++++ demo/src/lib/libpng/contrib/pngset.c | 1265 ++ demo/src/lib/libpng/contrib/pngtrans.c | 652 + demo/src/lib/libpng/contrib/pngwio.c | 228 + demo/src/lib/libpng/contrib/pngwrite.c | 1513 ++ demo/src/lib/libpng/contrib/pngwtran.c | 572 + demo/src/lib/libpng/contrib/pngwutil.c | 2750 ++++ demo/src/lib/libpng/main.cc | 63 + demo/src/lib/libpng/stdio.h | 0 demo/src/lib/libpng/target.mk | 7 + demo/src/lib/libz/contrib/adler32.c | 149 + demo/src/lib/libz/contrib/compress.c | 79 + demo/src/lib/libz/contrib/crc32.c | 423 + demo/src/lib/libz/contrib/crc32.h | 441 + demo/src/lib/libz/contrib/deflate.c | 1736 +++ demo/src/lib/libz/contrib/deflate.h | 331 + demo/src/lib/libz/contrib/gzio.c | 1026 ++ demo/src/lib/libz/contrib/infback.c | 623 + demo/src/lib/libz/contrib/inffast.c | 318 + demo/src/lib/libz/contrib/inffast.h | 11 + demo/src/lib/libz/contrib/inffixed.h | 94 + demo/src/lib/libz/contrib/inflate.c | 1368 ++ demo/src/lib/libz/contrib/inflate.h | 115 + demo/src/lib/libz/contrib/inftrees.c | 329 + demo/src/lib/libz/contrib/inftrees.h | 55 + demo/src/lib/libz/contrib/trees.c | 1219 ++ demo/src/lib/libz/contrib/trees.h | 128 + demo/src/lib/libz/contrib/uncompr.c | 61 + demo/src/lib/libz/contrib/zutil.c | 318 + demo/src/lib/libz/contrib/zutil.h | 269 + demo/src/lib/mini_c/README | 10 + demo/src/lib/mini_c/abort.cc | 22 + demo/src/lib/mini_c/atol.cc | 21 + demo/src/lib/mini_c/malloc_free.cc | 50 + demo/src/lib/mini_c/memcmp.cc | 19 + demo/src/lib/mini_c/memset.cc | 19 + demo/src/lib/mini_c/mini_c.c | 84 + demo/src/lib/mini_c/printf.cc | 24 + demo/src/lib/mini_c/snprintf.cc | 27 + demo/src/lib/mini_c/strlen.cc | 19 + demo/src/lib/mini_c/strtod.cc | 27 + demo/src/lib/mini_c/strtol.cc | 31 + demo/src/lib/mini_c/vsnprintf.cc | 21 + demo/src/server/liquid_framebuffer/README | 31 + .../liquid_framebuffer/framebuffer_window.h | 108 + demo/src/server/liquid_framebuffer/main.cc | 214 + .../src/server/liquid_framebuffer/services.cc | 256 + demo/src/server/liquid_framebuffer/services.h | 23 + demo/src/server/liquid_framebuffer/target.mk | 9 + demo/src/server/nitlog/main.cc | 412 + demo/src/server/nitlog/mono.tff | Bin 0 -> 20488 bytes demo/src/server/nitlog/target.mk | 5 + doc/Makefile | 38 + doc/build_system.txt | 466 + doc/coding_style.txt | 267 + doc/components.txt | 357 + doc/conventions.txt | 78 + doc/future_optimizations.txt | 68 + doc/getting_started.txt | 116 + doc/release_notes-08-11.txt | 830 ++ doc/release_notes-09-02.txt | 460 + doc/release_notes-09-05.txt | 585 + doc/release_notes-09-08.txt | 573 + doc/release_notes-09-11.txt | 1017 ++ doc/release_notes-10-02.txt | 1224 ++ doc/release_notes-10-05.txt | 1211 ++ doc/release_notes-10-08.txt | 618 + doc/release_notes-10-11.txt | 871 ++ doc/release_notes-11-02.txt | 876 ++ doc/release_notes-11-05.txt | 1289 ++ doc/release_notes-11-08.txt | 703 + doc/release_notes-11-11.txt | 1008 ++ gems/README | 6 + gems/include/terminal/character_screen.h | 219 + .../terminal/character_screen_tracer.h | 80 + gems/include/terminal/decoder.h | 421 + gems/include/terminal/types.h | 127 + gems/run/tcp_terminal.run | 122 + gems/run/terminal_decoder.run | 25 + gems/run/terminal_echo.run | 104 + gems/src/server/http_block/README | 26 + gems/src/server/http_block/http.cc | 305 + gems/src/server/http_block/http.h | 122 + gems/src/server/http_block/main.cc | 289 + gems/src/server/http_block/target.mk | 5 + gems/src/server/tcp_terminal/README | 12 + gems/src/server/tcp_terminal/main.cc | 514 + gems/src/server/tcp_terminal/target.mk | 3 + gems/src/server/terminal/main.cc | 1367 ++ gems/src/server/terminal/mono.tff | Bin 0 -> 34824 bytes gems/src/server/terminal/target.mk | 4 + gems/src/test/terminal_decoder/main.cc | 275 + gems/src/test/terminal_decoder/target.mk | 4 + gems/src/test/terminal_decoder/vim.vt | 1 + hello_tutorial/README | 2 + hello_tutorial/config/config | 12 + hello_tutorial/doc/hello_tutorial.txt | 406 + hello_tutorial/include/hello_session/client.h | 41 + .../include/hello_session/connection.h | 34 + .../include/hello_session/hello_session.h | 41 + hello_tutorial/run/hello.run | 48 + hello_tutorial/src/hello/client/main.cc | 38 + hello_tutorial/src/hello/client/target.mk | 3 + hello_tutorial/src/hello/server/main.cc | 93 + hello_tutorial/src/hello/server/target.mk | 3 + libports/Makefile | 69 + libports/README | 45 + libports/doc/libc.txt | 72 + libports/include/EGL/eglplatform.h | 34 + libports/include/freetype-genode/ftconfig.h | 500 + libports/include/freetype-genode/ftmodule.h | 32 + libports/include/gcc/README | 2 + libports/include/gcc/longlong.h | 1525 ++ libports/include/gmp/config.h | 522 + libports/include/gmp/x86_32/fac_ui.h | 19 + libports/include/gmp/x86_32/fib_table.h | 8 + libports/include/gmp/x86_32/gmp.h | 2230 +++ libports/include/gmp/x86_32/mp_bases.h | 11 + libports/include/gmp/x86_32/perfsqr.h | 50 + libports/include/jpeg/jconfig.h | 46 + libports/include/libc-genode/mntent.h | 13 + libports/include/libc-genode/sys/syscall.h | 4 + libports/include/libc-genode/timeconv.h | 0 libports/include/libc-plugin/fd_alloc.h | 69 + libports/include/libc-plugin/plugin.h | 124 + .../include/libc-plugin/plugin_registry.h | 46 + libports/include/lwip/arch/cc.h | 61 + libports/include/lwip/arch/perf.h | 20 + libports/include/lwip/arch/sys_arch.h | 30 + libports/include/lwip/genode.h | 52 + libports/include/lwip/lwipopts.h | 77 + libports/include/ncurses/ncurses_cfg.h | 201 + libports/include/python/osreldate.h | 3 + libports/include/python/pyconfig.h | 1092 ++ libports/include/python/x86_32/genode_defs.h | 20 + libports/include/python/x86_64/genode_defs.h | 20 + libports/include/readline/config.h | 269 + libports/lib/import/import-gmp.mk | 14 + libports/lib/import/import-jpeg.mk | 3 + libports/lib/import/import-libc.mk | 51 + libports/lib/import/import-libpng.mk | 1 + libports/lib/import/import-lwip.mk | 1 + libports/lib/import/import-mpfr.mk | 1 + libports/lib/import/import-ncurses.mk | 1 + libports/lib/import/import-python.mk | 13 + libports/lib/import/import-zlib.mk | 1 + libports/lib/mk/arm/libc-gen.mk | 18 + libports/lib/mk/arm/libm.mk | 19 + libports/lib/mk/ffat.mk | 12 + libports/lib/mk/ffat_block.mk | 13 + libports/lib/mk/freetype.mk | 51 + libports/lib/mk/gallium-aux.mk | 52 + libports/lib/mk/gallium-egl.mk | 44 + libports/lib/mk/gallium-failover.mk | 5 + libports/lib/mk/gallium-i915.mk | 30 + libports/lib/mk/gallium-identity.mk | 5 + libports/lib/mk/gallium-softpipe.mk | 5 + libports/lib/mk/gallium-trace.mk | 5 + libports/lib/mk/gallium.inc | 28 + libports/lib/mk/gallium.mk | 8 + libports/lib/mk/gmp-mpf.mk | 5 + libports/lib/mk/gmp-mpq.mk | 5 + libports/lib/mk/gmp-mpz.mk | 5 + libports/lib/mk/gmp.inc | 13 + libports/lib/mk/gmp.mk | 25 + libports/lib/mk/history.mk | 24 + libports/lib/mk/jpeg.mk | 27 + libports/lib/mk/libc-common.inc | 26 + libports/lib/mk/libc-gdtoa.mk | 13 + libports/lib/mk/libc-gen.inc | 13 + libports/lib/mk/libc-inet.mk | 9 + libports/lib/mk/libc-locale.mk | 7 + libports/lib/mk/libc-stdio.mk | 7 + libports/lib/mk/libc-stdlib.mk | 9 + libports/lib/mk/libc-stdtime.mk | 7 + libports/lib/mk/libc-string.mk | 18 + libports/lib/mk/libc.mk | 32 + libports/lib/mk/libc_ffat.mk | 6 + libports/lib/mk/libc_lock_pipe.mk | 6 + libports/lib/mk/libc_log.mk | 6 + libports/lib/mk/libc_lwip.mk | 5 + libports/lib/mk/libc_lwip_loopback.mk | 5 + libports/lib/mk/libc_lwip_nic_dhcp.mk | 5 + libports/lib/mk/libc_terminal.mk | 6 + libports/lib/mk/libdrm.mk | 11 + libports/lib/mk/libm.mk | 79 + libports/lib/mk/libpng.mk | 16 + libports/lib/mk/lwip.mk | 45 + libports/lib/mk/mesa-egl.mk | 13 + libports/lib/mk/mesa.inc | 21 + libports/lib/mk/mesa.mk | 65 + libports/lib/mk/mpfr.mk | 20 + libports/lib/mk/ncurses.mk | 34 + libports/lib/mk/python.inc | 143 + libports/lib/mk/readline.mk | 30 + libports/lib/mk/sdl.mk | 131 + libports/lib/mk/test-ldso.mk | 7 + libports/lib/mk/test-ldso2.mk | 5 + libports/lib/mk/x86_32/gmp-mpn.mk | 54 + libports/lib/mk/x86_32/libc-gen.mk | 23 + libports/lib/mk/x86_32/python.mk | 3 + libports/lib/mk/x86_64/libc-gen.mk | 18 + libports/lib/mk/x86_64/python.mk | 3 + libports/lib/mk/zlib.mk | 12 + libports/ports/ffat.mk | 43 + libports/ports/freetype.mk | 32 + libports/ports/gmp.mk | 39 + libports/ports/jpeg.mk | 24 + libports/ports/libc.mk | 468 + libports/ports/libdrm.mk | 27 + libports/ports/libpng.mk | 32 + libports/ports/lwip.mk | 37 + libports/ports/mesa.mk | 48 + libports/ports/mpfr.mk | 35 + libports/ports/ncurses.mk | 185 + libports/ports/python.mk | 33 + libports/ports/readline.mk | 30 + libports/ports/sdl.mk | 41 + libports/ports/zlib.mk | 32 + libports/run/eglgears.run | 130 + libports/run/libc_ffat.run | 126 + libports/run/lwip.run | 136 + libports/run/lwip_lx.run | 68 + libports/run/python.run | 92 + libports/run/test-libc.run | 36 + libports/src/app/eglgears/eglgears.c | 422 + libports/src/app/eglgears/target.mk | 3 + libports/src/lib/egl/driver.cc | 790 ++ libports/src/lib/egl/select_driver.cc | 122 + libports/src/lib/egl/select_driver.h | 25 + libports/src/lib/egl/st_opengl.c | 20 + libports/src/lib/ffat/config.patch | 30 + libports/src/lib/ffat/diskio.c | 146 + libports/src/lib/ffat/diskio_block.cc | 176 + libports/src/lib/gallium/README | 7 + libports/src/lib/gallium/dummy_trace.c | 26 + .../src/lib/gallium/i915/query_device_id.cc | 98 + libports/src/lib/gallium/i915/target.mk | 6 + libports/src/lib/gallium/main.cc | 14 + libports/src/lib/gallium/p_state_config.patch | 20 + libports/src/lib/gmp/config.m4 | 39 + libports/src/lib/gmp/mpn/x86/add_n.asm | 145 + libports/src/lib/gmp/mpn/x86/dummy.c | 21 + libports/src/lib/gmp/mpn/x86/fib_table.c | 61 + libports/src/lib/gmp/mpn/x86/mp_bases.c | 269 + libports/src/lib/libc/Version.def | 9 + libports/src/lib/libc/atexit.cc | 24 + libports/src/lib/libc/clock_gettime.cc | 32 + libports/src/lib/libc/dummies.cc | 143 + libports/src/lib/libc/environ.cc | 20 + libports/src/lib/libc/errno.cc | 21 + libports/src/lib/libc/exit.cc | 39 + libports/src/lib/libc/fd_alloc.cc | 80 + libports/src/lib/libc/file_operations.cc | 389 + libports/src/lib/libc/gai_strerror.cc | 21 + libports/src/lib/libc/gettimeofday.cc | 28 + libports/src/lib/libc/ioctl.cc | 20 + libports/src/lib/libc/issetugid.cc | 20 + libports/src/lib/libc/libc_debug.h | 35 + libports/src/lib/libc/malloc.cc | 93 + libports/src/lib/libc/munmap.cc | 22 + libports/src/lib/libc/patches/README | 19 + libports/src/lib/libc/patches/malloc_c.patch | 11 + .../src/lib/libc/patches/math_private.patch | 18 + .../src/lib/libc/patches/pthread_cancel.patch | 11 + .../lib/libc/patches/vfwprintf_c_warn.patch | 32 + libports/src/lib/libc/plugin.cc | 174 + libports/src/lib/libc/plugin_registry.cc | 80 + libports/src/lib/libc/progname.cc | 14 + libports/src/lib/libc/readlink.cc | 33 + libports/src/lib/libc/rlimit.cc | 36 + libports/src/lib/libc/select.cc | 274 + libports/src/lib/libc/sysctl.cc | 68 + libports/src/lib/libc_ffat/plugin.cc | 724 + libports/src/lib/libc_lock_pipe/plugin.cc | 336 + libports/src/lib/libc_log/plugin.cc | 108 + libports/src/lib/libc_lwip/init.cc | 23 + libports/src/lib/libc_lwip/plugin.cc | 598 + libports/src/lib/libc_lwip_loopback/init.cc | 29 + libports/src/lib/libc_lwip_nic_dhcp/init.cc | 34 + libports/src/lib/libc_terminal/README | 6 + libports/src/lib/libc_terminal/plugin.cc | 268 + libports/src/lib/libdrm/ioctl.cc | 198 + libports/src/lib/libpng/config.h | 87 + libports/src/lib/lwip/errno.patch | 16 + libports/src/lib/lwip/include/nic.h | 24 + libports/src/lib/lwip/include/ring_buffer.h | 119 + libports/src/lib/lwip/include/thread.h | 43 + libports/src/lib/lwip/include/timer.h | 55 + .../src/lib/lwip/libc_select_notify.patch | 40 + libports/src/lib/lwip/platform/nic.cc | 277 + libports/src/lib/lwip/platform/printf.cc | 36 + libports/src/lib/lwip/platform/sys_arch.cc | 572 + libports/src/lib/python/config.c | 87 + libports/src/lib/python/dup.c | 20 + libports/src/lib/python/libc_plugin.cc | 109 + libports/src/lib/python/libc_plugin_init.cc | 18 + libports/src/lib/python/posixmodule.patch | 23 + libports/src/lib/readline/genode.cc | 81 + libports/src/lib/sdl/SDL_config.h | 37 + libports/src/lib/sdl/SDL_config_genode.h | 83 + libports/src/lib/sdl/SDL_video.patch | 35 + .../src/lib/sdl/video/SDL_genode_fb_events.cc | 486 + .../src/lib/sdl/video/SDL_genode_fb_events.h | 37 + .../src/lib/sdl/video/SDL_genode_fb_video.cc | 327 + .../src/lib/sdl/video/SDL_genode_fb_video.h | 68 + libports/src/test/ldso/include/test-ldso.h | 24 + libports/src/test/ldso/lib/test-rtld.cc | 81 + libports/src/test/ldso/lib/test_lib.cc | 16 + libports/src/test/ldso/main.cc | 87 + libports/src/test/ldso/target.mk | 4 + libports/src/test/libc/main.cc | 40 + libports/src/test/libc/target.mk | 3 + libports/src/test/libc_ffat/main.cc | 96 + libports/src/test/libc_ffat/target.mk | 3 + libports/src/test/libports/freetype/target.mk | 5 + libports/src/test/libports/gmp/target.mk | 8 + libports/src/test/libports/jpeg/target.mk | 5 + libports/src/test/libports/libpng/target.mk | 5 + libports/src/test/libports/main.cc | 14 + libports/src/test/libports/mesa/target.mk | 6 + libports/src/test/libports/mpfr/target.mk | 9 + libports/src/test/libports/ncurses/target.mk | 5 + libports/src/test/libports/readline/target.mk | 5 + libports/src/test/libports/zlib/target.mk | 5 + libports/src/test/lwip/http_srv/main.cc | 126 + libports/src/test/lwip/http_srv/target.mk | 5 + libports/src/test/lwip/loopback/main.cc | 198 + libports/src/test/lwip/loopback/target.mk | 3 + libports/src/test/python/README | 20 + libports/src/test/python/hello.py | 13 + libports/src/test/python/main.cc | 77 + libports/src/test/python/target.mk | 6 + libports/src/test/sdl/main.cc | 82 + libports/src/test/sdl/target.mk | 3 + libports/tool/mesa/Makefile | 18 + os/README | 20 + os/config/bomb | 26 + os/config/demo | 40 + os/config/gta01 | 35 + os/config/linux_demo | 43 + os/config/mixer | 67 + os/config/nested_config | 79 + os/config/priority | 88 + os/doc/init.txt | 287 + .../audio_out_session/audio_out_session.h | 98 + os/include/audio_out_session/capability.h | 30 + os/include/audio_out_session/client.h | 74 + os/include/audio_out_session/connection.h | 49 + os/include/audio_out_session/rpc_object.h | 57 + os/include/blit/blit.h | 35 + os/include/block/component.h | 207 + os/include/block/driver.h | 114 + os/include/block_session/block_session.h | 151 + os/include/block_session/capability.h | 22 + os/include/block_session/client.h | 69 + os/include/block_session/connection.h | 43 + os/include/block_session/rpc_object.h | 54 + os/include/dde_kit/assert.h | 37 + os/include/dde_kit/dde_kit.h | 24 + os/include/dde_kit/initcall.h | 33 + os/include/dde_kit/interrupt.h | 60 + os/include/dde_kit/lock.h | 65 + os/include/dde_kit/memory.h | 134 + os/include/dde_kit/panic.h | 33 + os/include/dde_kit/pci.h | 144 + os/include/dde_kit/pgtab.h | 72 + os/include/dde_kit/printf.h | 56 + os/include/dde_kit/resources.h | 113 + os/include/dde_kit/semaphore.h | 73 + os/include/dde_kit/thread.h | 138 + os/include/dde_kit/timer.h | 75 + os/include/dde_kit/types.h | 41 + os/include/framebuffer_session/capability.h | 22 + os/include/framebuffer_session/client.h | 38 + os/include/framebuffer_session/connection.h | 75 + .../framebuffer_session/framebuffer_session.h | 72 + os/include/gpu/driver.h | 67 + os/include/init/child.h | 571 + os/include/init/child_config.h | 134 + os/include/init/child_policy.h | 302 + os/include/input/component.h | 116 + os/include/input/event.h | 59 + os/include/input/keycodes.h | 455 + os/include/input_session/capability.h | 22 + os/include/input_session/client.h | 38 + os/include/input_session/connection.h | 32 + os/include/input_session/input_session.h | 61 + os/include/ldso/arch.h | 24 + os/include/loader_session/capability.h | 22 + os/include/loader_session/client.h | 56 + os/include/loader_session/connection.h | 38 + os/include/loader_session/loader_session.h | 74 + os/include/net/arp.h | 294 + os/include/net/dhcp.h | 280 + os/include/net/ethernet.h | 181 + os/include/net/ipv4.h | 171 + os/include/net/netaddress.h | 73 + os/include/net/udp.h | 156 + os/include/nic/component.h | 239 + os/include/nic/driver.h | 90 + os/include/nic_session/capability.h | 22 + os/include/nic_session/client.h | 61 + os/include/nic_session/connection.h | 46 + os/include/nic_session/nic_session.h | 103 + os/include/nic_session/rpc_object.h | 55 + os/include/nitpicker_gfx/README | 3 + os/include/nitpicker_gfx/canvas.h | 119 + os/include/nitpicker_gfx/chunky_canvas.h | 203 + os/include/nitpicker_gfx/color.h | 36 + os/include/nitpicker_gfx/font.h | 61 + os/include/nitpicker_gfx/geometry.h | 161 + os/include/nitpicker_gfx/miscmath.h | 23 + os/include/nitpicker_gfx/nitpicker_types.h | 21 + os/include/nitpicker_gfx/pixel_rgb.h | 73 + os/include/nitpicker_gfx/pixel_rgb565.h | 56 + os/include/nitpicker_session/capability.h | 26 + os/include/nitpicker_session/client.h | 44 + os/include/nitpicker_session/connection.h | 126 + .../nitpicker_session/nitpicker_session.h | 75 + os/include/nitpicker_view/capability.h | 25 + os/include/nitpicker_view/client.h | 39 + os/include/nitpicker_view/nitpicker_view.h | 77 + os/include/os/alarm.h | 137 + os/include/os/attached_io_mem_dataspace.h | 83 + os/include/os/attached_ram_dataspace.h | 91 + os/include/os/config.h | 74 + os/include/os/irq_activation.h | 83 + os/include/os/packet_stream.h | 783 ++ os/include/os/ring_buffer.h | 94 + os/include/os/session_policy.h | 105 + os/include/os/timed_semaphore.h | 243 + os/include/packet_stream_rx/client.h | 66 + .../packet_stream_rx/packet_stream_rx.h | 61 + os/include/packet_stream_rx/rpc_object.h | 80 + os/include/packet_stream_tx/client.h | 73 + .../packet_stream_tx/packet_stream_tx.h | 65 + os/include/packet_stream_tx/rpc_object.h | 77 + os/include/pci_device/capability.h | 22 + os/include/pci_device/client.h | 51 + os/include/pci_device/pci_device.h | 206 + os/include/pci_session/capability.h | 22 + os/include/pci_session/client.h | 38 + os/include/pci_session/connection.h | 32 + os/include/pci_session/pci_session.h | 65 + os/include/platform/pbxa9/lan9118_defs.h | 38 + os/include/platform/pbxa9/pl011_defs.h | 63 + os/include/platform/pbxa9/pl050_defs.h | 28 + os/include/platform/pbxa9/pl11x_defs.h | 34 + os/include/platform/pbxa9/pl180_defs.h | 27 + os/include/platform/pbxa9/sp810_defs.h | 27 + os/include/platform/vea9x4/bus.h | 31 + os/include/platform/vea9x4/lan9118_defs.h | 41 + os/include/platform/vea9x4/pl011_defs.h | 66 + os/include/platform/vea9x4/pl050_defs.h | 31 + os/include/platform/vea9x4/pl11x_defs.h | 38 + os/include/platform/vea9x4/pl180_defs.h | 30 + os/include/platform/vea9x4/sp810_defs.h | 30 + os/include/platform/vpb926/pl011_defs.h | 67 + os/include/platform/vpb926/pl050_defs.h | 32 + os/include/platform/vpb926/pl11x_defs.h | 34 + os/include/platform/vpb926/sp810_defs.h | 28 + os/include/terminal_session/client.h | 120 + os/include/terminal_session/connection.h | 52 + .../terminal_session/terminal_session.h | 104 + os/include/timer_session/capability.h | 22 + os/include/timer_session/client.h | 31 + os/include/timer_session/connection.h | 38 + os/include/timer_session/server.h | 25 + os/include/timer_session/timer_session.h | 43 + os/include/util/endian.h | 30 + os/include/util/xml_node.h | 677 + os/include/xev_track/xev_track.h | 75 + os/lib/mk/alarm.mk | 3 + os/lib/mk/arm/ld.mk | 12 + os/lib/mk/arm/ldso-startup.mk | 5 + os/lib/mk/arm/ldso_crt0.mk | 3 + os/lib/mk/blit.mk | 3 + os/lib/mk/codezero/ldso-arch.mk | 7 + os/lib/mk/dde_kit.mk | 6 + os/lib/mk/ldso-arch.mk | 5 + os/lib/mk/ldso-startup.mk | 3 + os/lib/mk/linux/ldso-arch.mk | 6 + os/lib/mk/net.mk | 3 + os/lib/mk/pistachio/ldso-arch.mk | 5 + os/lib/mk/timed_semaphore.mk | 4 + os/lib/mk/x86_32/blit.mk | 5 + os/lib/mk/x86_32/ld.mk | 12 + os/lib/mk/x86_32/ldso_crt0.mk | 3 + os/lib/mk/x86_32/ldso_crt0_lx.mk | 3 + os/lib/mk/x86_64/blit.mk | 5 + os/lib/mk/x86_64/ld.mk | 14 + os/lib/mk/x86_64/ldso_crt0.mk | 3 + os/lib/mk/x86_64/ldso_crt0_lx.mk | 3 + os/lib/mk/xev_track.mk | 6 + os/run/ahci.run | 133 + os/run/demo.run | 111 + os/run/ldso.run | 55 + os/run/part_blk.run | 145 + os/run/rom_blk.run | 42 + os/run/sd_card.run | 80 + os/run/signal.run | 38 + os/run/tar_rom.run | 75 + os/run/timed_semaphore.run | 61 + os/run/uart.run | 90 + os/src/app/xvfb/README | 48 + os/src/app/xvfb/inject_input.cc | 99 + os/src/app/xvfb/inject_input.h | 38 + os/src/app/xvfb/main.cc | 340 + os/src/app/xvfb/target.mk | 9 + os/src/drivers/ahci/README | 19 + os/src/drivers/ahci/main.cc | 771 + os/src/drivers/ahci/target.mk | 4 + os/src/drivers/atapi/README | 24 + os/src/drivers/atapi/ata_bus_master.cc | 140 + os/src/drivers/atapi/ata_bus_master.h | 75 + os/src/drivers/atapi/ata_device.cc | 225 + os/src/drivers/atapi/ata_device.h | 160 + os/src/drivers/atapi/atapi_device.cc | 143 + .../drivers/atapi/contrib/mindrvr-guide.txt | 387 + os/src/drivers/atapi/contrib/mindrvr.c | 2831 ++++ os/src/drivers/atapi/contrib/mindrvr.h | 450 + os/src/drivers/atapi/endian.h | 29 + os/src/drivers/atapi/io.cc | 256 + os/src/drivers/atapi/io.h | 78 + os/src/drivers/atapi/main.cc | 265 + os/src/drivers/atapi/pio.h | 43 + os/src/drivers/atapi/target.mk | 9 + os/src/drivers/audio_out/linux/alsa.c | 88 + os/src/drivers/audio_out/linux/alsa.h | 32 + os/src/drivers/audio_out/linux/main.cc | 270 + os/src/drivers/audio_out/linux/target.mk | 6 + .../framebuffer/fiasco_ux/framebuffer.cc | 129 + .../framebuffer/fiasco_ux/framebuffer.h | 32 + os/src/drivers/framebuffer/fiasco_ux/main.cc | 125 + .../drivers/framebuffer/fiasco_ux/target.mk | 4 + os/src/drivers/framebuffer/pl11x/main.cc | 236 + .../drivers/framebuffer/pl11x/pbxa9/target.mk | 7 + os/src/drivers/framebuffer/pl11x/target.mk | 0 .../framebuffer/pl11x/vea9x4/target.mk | 7 + .../framebuffer/pl11x/vea9x4/video_memory.cc | 27 + .../drivers/framebuffer/pl11x/video_memory.cc | 22 + .../drivers/framebuffer/pl11x/video_memory.h | 26 + .../framebuffer/pl11x/vpb926/target.mk | 7 + os/src/drivers/framebuffer/sdl/fb_sdl.cc | 181 + os/src/drivers/framebuffer/sdl/input.cc | 204 + os/src/drivers/framebuffer/sdl/target.mk | 6 + os/src/drivers/framebuffer/vesa/README | 79 + .../drivers/framebuffer/vesa/contrib/LICENSE | 17 + .../framebuffer/vesa/contrib/Makefile.old | 19 + .../drivers/framebuffer/vesa/contrib/debug.c | 432 + .../drivers/framebuffer/vesa/contrib/decode.c | 1092 ++ .../drivers/framebuffer/vesa/contrib/fgets.c | 56 + os/src/drivers/framebuffer/vesa/contrib/fpu.c | 965 ++ os/src/drivers/framebuffer/vesa/contrib/ops.c | 11697 ++++++++++++++++ .../drivers/framebuffer/vesa/contrib/ops2.c | 2805 ++++ .../framebuffer/vesa/contrib/prim_ops.c | 2655 ++++ .../drivers/framebuffer/vesa/contrib/printk.c | 12 + os/src/drivers/framebuffer/vesa/contrib/sys.c | 661 + .../framebuffer/vesa/contrib/x86emu/debug.h | 210 + .../framebuffer/vesa/contrib/x86emu/decode.h | 88 + .../framebuffer/vesa/contrib/x86emu/fpu.h | 61 + .../vesa/contrib/x86emu/fpu_regs.h | 119 + .../framebuffer/vesa/contrib/x86emu/ops.h | 45 + .../vesa/contrib/x86emu/prim_asm.h | 970 ++ .../vesa/contrib/x86emu/prim_ops.h | 141 + .../framebuffer/vesa/contrib/x86emu/x86emui.h | 103 + .../drivers/framebuffer/vesa/framebuffer.cc | 253 + os/src/drivers/framebuffer/vesa/hw_emul.cc | 311 + os/src/drivers/framebuffer/vesa/ifx86emu.cc | 522 + .../framebuffer/vesa/include/framebuffer.h | 53 + .../framebuffer/vesa/include/hw_emul.h | 34 + .../framebuffer/vesa/include/ifx86emu.h | 90 + os/src/drivers/framebuffer/vesa/include/vbe.h | 103 + .../drivers/framebuffer/vesa/include/vesa.h | 105 + .../framebuffer/vesa/include/x86emu/regs.h | 339 + .../framebuffer/vesa/include/x86emu/types.h | 108 + .../framebuffer/vesa/include/x86emu/x86emu.h | 198 + os/src/drivers/framebuffer/vesa/main.cc | 258 + os/src/drivers/framebuffer/vesa/target.mk | 10 + os/src/drivers/input/dummy/README | 1 + os/src/drivers/input/dummy/main.cc | 95 + os/src/drivers/input/dummy/target.mk | 3 + os/src/drivers/input/fiasco_ux/input.cc | 224 + os/src/drivers/input/fiasco_ux/input.h | 37 + os/src/drivers/input/fiasco_ux/main.cc | 113 + os/src/drivers/input/fiasco_ux/target.mk | 4 + os/src/drivers/input/fiasco_ux/test.cc | 560 + os/src/drivers/input/ps2/event_queue.h | 69 + os/src/drivers/input/ps2/input_driver.h | 28 + os/src/drivers/input/ps2/irq_handler.h | 49 + os/src/drivers/input/ps2/pl050/irq_handler.h | 66 + os/src/drivers/input/ps2/pl050/main.cc | 76 + os/src/drivers/input/ps2/pl050/pl050.h | 159 + os/src/drivers/input/ps2/pl050/stdio.h | 1 + os/src/drivers/input/ps2/pl050/string.h | 1 + os/src/drivers/input/ps2/pl050/target.mk | 6 + os/src/drivers/input/ps2/ps2_keyboard.h | 459 + os/src/drivers/input/ps2/ps2_mouse.h | 267 + os/src/drivers/input/ps2/scan_code_set_1.h | 191 + os/src/drivers/input/ps2/scan_code_set_2.h | 321 + os/src/drivers/input/ps2/serial_interface.h | 33 + os/src/drivers/input/ps2/x86/i8042.h | 291 + os/src/drivers/input/ps2/x86/main.cc | 76 + os/src/drivers/input/ps2/x86/target.mk | 6 + os/src/drivers/nic/lan9118/lan9118.h | 369 + os/src/drivers/nic/lan9118/main.cc | 62 + os/src/drivers/nic/lan9118/target.mk | 5 + os/src/drivers/nic/linux/main.cc | 188 + os/src/drivers/nic/linux/target.mk | 4 + os/src/drivers/pci/main.cc | 51 + os/src/drivers/pci/pci_config_access.h | 134 + os/src/drivers/pci/pci_device_component.h | 94 + os/src/drivers/pci/pci_device_config.h | 189 + os/src/drivers/pci/pci_session_component.h | 255 + os/src/drivers/pci/x86/target.mk | 8 + os/src/drivers/platform/gta01/main.cc | 306 + os/src/drivers/platform/gta01/target.mk | 4 + os/src/drivers/rtc/x86/main.cc | 153 + os/src/drivers/rtc/x86/target.mk | 4 + os/src/drivers/sd_card/host_driver.h | 86 + os/src/drivers/sd_card/pl180/main.cc | 66 + os/src/drivers/sd_card/pl180/pl180.h | 290 + os/src/drivers/sd_card/pl180/target.mk | 6 + os/src/drivers/sd_card/sd_card.h | 135 + .../drivers/timer/codezero/platform_timer.cc | 41 + os/src/drivers/timer/codezero/target.mk | 14 + os/src/drivers/timer/fiasco/platform_timer.cc | 72 + os/src/drivers/timer/fiasco/target.mk | 8 + os/src/drivers/timer/foc/target.mk | 8 + os/src/drivers/timer/foc/timer_root.h | 95 + .../timer/foc/timer_session_component.h | 115 + os/src/drivers/timer/include/timer_root.h | 70 + .../timer/include/timer_session_component.h | 252 + .../timer/include_periodic/platform_timer.h | 94 + .../timer/include_pit/platform_timer.h | 183 + os/src/drivers/timer/linux/platform_timer.cc | 53 + os/src/drivers/timer/linux/target.mk | 7 + os/src/drivers/timer/main.cc | 54 + os/src/drivers/timer/nova/target.mk | 8 + os/src/drivers/timer/nova/timer_root.h | 106 + .../timer/nova/timer_session_component.h | 198 + .../drivers/timer/okl4_arm/platform_timer.cc | 40 + os/src/drivers/timer/okl4_arm/target.mk | 8 + os/src/drivers/timer/okl4_x86/target.mk | 8 + .../drivers/timer/pistachio/platform_timer.cc | 57 + os/src/drivers/timer/pistachio/target.mk | 8 + os/src/drivers/uart/README | 22 + os/src/drivers/uart/i8250/i8250.h | 142 + os/src/drivers/uart/i8250/main.cc | 104 + os/src/drivers/uart/i8250/target.mk | 6 + os/src/drivers/uart/pl011/calc_brd_values.py | 16 + os/src/drivers/uart/pl011/main.cc | 87 + os/src/drivers/uart/pl011/pl011.h | 168 + os/src/drivers/uart/pl011/target.mk | 6 + os/src/drivers/uart/terminal_component.h | 177 + os/src/drivers/uart/terminal_driver.h | 75 + os/src/init/config.explicit_routing | 91 + os/src/init/config.wildcard | 69 + os/src/init/main.cc | 177 + os/src/init/target.mk | 3 + os/src/lib/alarm/alarm.cc | 211 + os/src/lib/blit/blit.cc | 26 + os/src/lib/blit/x86/blit.cc | 116 + os/src/lib/blit/x86/x86_32/mmx.h | 47 + os/src/lib/blit/x86/x86_64/mmx.h | 46 + os/src/lib/dde_kit/dde_kit.cc | 20 + os/src/lib/dde_kit/interrupt.cc | 193 + os/src/lib/dde_kit/lock.cc | 67 + os/src/lib/dde_kit/memory.cc | 301 + os/src/lib/dde_kit/panic.cc | 45 + os/src/lib/dde_kit/pci.cc | 151 + os/src/lib/dde_kit/pci_tree.cc | 74 + os/src/lib/dde_kit/pci_tree.h | 247 + os/src/lib/dde_kit/pgtab.cc | 194 + os/src/lib/dde_kit/printf.cc | 40 + os/src/lib/dde_kit/resources.cc | 339 + os/src/lib/dde_kit/semaphore.cc | 66 + os/src/lib/dde_kit/thread.cc | 308 + os/src/lib/dde_kit/thread.h | 69 + os/src/lib/dde_kit/timer.cc | 207 + os/src/lib/ldso/README | 38 + os/src/lib/ldso/arch/binary_name.cc | 22 + os/src/lib/ldso/arch/codezero/dummy.c | 22 + os/src/lib/ldso/arch/linux/binary_name.cc | 25 + os/src/lib/ldso/arch/linux/parent_cap.cc | 18 + os/src/lib/ldso/arch/parent_cap.cc | 24 + os/src/lib/ldso/arm/crt0.s | 25 + os/src/lib/ldso/arm/platform.c | 125 + os/src/lib/ldso/contrib/amd64/reloc.c | 407 + os/src/lib/ldso/contrib/amd64/rtld_machdep.h | 78 + os/src/lib/ldso/contrib/amd64/rtld_start.S | 114 + os/src/lib/ldso/contrib/arm/reloc.c | 398 + os/src/lib/ldso/contrib/arm/rtld_machdep.h | 74 + os/src/lib/ldso/contrib/arm/rtld_start.S | 101 + os/src/lib/ldso/contrib/debug.c | 143 + os/src/lib/ldso/contrib/debug.h | 66 + os/src/lib/ldso/contrib/i386/reloc.c | 387 + os/src/lib/ldso/contrib/i386/rtld_machdep.h | 79 + os/src/lib/ldso/contrib/i386/rtld_start.S | 91 + os/src/lib/ldso/contrib/libmap.c | 369 + os/src/lib/ldso/contrib/libmap.h | 10 + os/src/lib/ldso/contrib/malloc.c | 518 + os/src/lib/ldso/contrib/map_object.c | 283 + os/src/lib/ldso/contrib/rtld.c | 3477 +++++ os/src/lib/ldso/contrib/rtld.h | 285 + os/src/lib/ldso/contrib/rtld_lock.c | 334 + os/src/lib/ldso/contrib/rtld_lock.h | 73 + os/src/lib/ldso/contrib/rtld_tls.h | 69 + os/src/lib/ldso/contrib/xmalloc.c | 59 + os/src/lib/ldso/dl_extensions.h | 30 + os/src/lib/ldso/environ.cc | 22 + os/src/lib/ldso/err.cc | 28 + os/src/lib/ldso/file.cc | 366 + os/src/lib/ldso/file.h | 39 + os/src/lib/ldso/include/arm/call_main.h | 24 + os/src/lib/ldso/include/libc/dlfcn.h | 139 + os/src/lib/ldso/include/libc/elf-hints.h | 50 + .../include/libc/libc-amd64/machine/elf.h | 123 + .../ldso/include/libc/libc-arm/machine/asm.h | 174 + .../ldso/include/libc/libc-arm/machine/elf.h | 103 + .../ldso/include/libc/libc-i386/machine/elf.h | 122 + os/src/lib/ldso/include/libc/sys/cdefs.h | 564 + os/src/lib/ldso/include/libc/sys/elf.h | 41 + os/src/lib/ldso/include/libc/sys/elf32.h | 245 + os/src/lib/ldso/include/libc/sys/elf64.h | 248 + os/src/lib/ldso/include/libc/sys/elf_common.h | 865 ++ .../lib/ldso/include/libc/sys/elf_generic.h | 88 + os/src/lib/ldso/include/libc/sys/link_elf.h | 99 + os/src/lib/ldso/include/libc/sys/queue.h | 627 + os/src/lib/ldso/include/libc_emu/err.h | 29 + os/src/lib/ldso/include/libc_emu/errno.h | 12 + os/src/lib/ldso/include/libc_emu/fcntl.h | 23 + os/src/lib/ldso/include/libc_emu/ldso_types.h | 63 + os/src/lib/ldso/include/libc_emu/link.h | 14 + .../ldso/include/libc_emu/machine/atomic.h | 13 + .../ldso/include/libc_emu/machine/segments.h | 12 + .../ldso/include/libc_emu/machine/sysarch.h | 23 + os/src/lib/ldso/include/libc_emu/stdio.h | 44 + os/src/lib/ldso/include/libc_emu/stdlib.h | 43 + os/src/lib/ldso/include/libc_emu/string.h | 142 + os/src/lib/ldso/include/libc_emu/sys/_types.h | 25 + os/src/lib/ldso/include/libc_emu/sys/ktrace.h | 20 + os/src/lib/ldso/include/libc_emu/sys/mman.h | 53 + os/src/lib/ldso/include/libc_emu/sys/mount.h | 12 + os/src/lib/ldso/include/libc_emu/sys/param.h | 35 + os/src/lib/ldso/include/libc_emu/sys/queue.h | 12 + os/src/lib/ldso/include/libc_emu/sys/stat.h | 6 + os/src/lib/ldso/include/libc_emu/sys/types.h | 13 + os/src/lib/ldso/include/libc_emu/sys/uio.h | 12 + os/src/lib/ldso/include/libc_emu/unistd.h | 67 + os/src/lib/ldso/include/x86_32/call_main.h | 32 + os/src/lib/ldso/include/x86_64/call_main.h | 32 + os/src/lib/ldso/ldso.ld | 18 + os/src/lib/ldso/ldso_types.c | 17 + os/src/lib/ldso/lock.cc | 82 + os/src/lib/ldso/main.c | 107 + os/src/lib/ldso/platform.c | 13 + os/src/lib/ldso/rtld_dummies.c | 54 + os/src/lib/ldso/startup/startup.cc | 31 + os/src/lib/ldso/startup/unwind_exidx.cc | 48 + os/src/lib/ldso/stdio.cc | 63 + os/src/lib/ldso/stdlib.cc | 71 + os/src/lib/ldso/string.cc | 57 + os/src/lib/ldso/symbol.map | 85 + os/src/lib/ldso/target.inc | 62 + os/src/lib/ldso/test.cc | 18 + os/src/lib/ldso/x86_32/crt0.s | 50 + os/src/lib/ldso/x86_32/linux/crt0.s | 54 + os/src/lib/ldso/x86_64/crt0.s | 43 + os/src/lib/ldso/x86_64/linux/crt0.s | 52 + os/src/lib/net/ethernet.cc | 16 + os/src/lib/net/ipv4.cc | 17 + os/src/lib/timed_semaphore/timed_semaphore.cc | 33 + os/src/lib/xev_track/xev_track.cc | 529 + os/src/platform/genode_dyn.ld | 276 + os/src/platform/genode_rel.ld | 256 + os/src/server/iso9660/README | 27 + os/src/server/iso9660/backing_store.h | 257 + os/src/server/iso9660/iso9660.cc | 496 + os/src/server/iso9660/iso9660.h | 81 + os/src/server/iso9660/main.cc | 321 + os/src/server/iso9660/target.mk | 3 + os/src/server/loader/README | 9 + os/src/server/loader/input_root.h | 70 + .../server/loader/input_session_component.cc | 91 + .../server/loader/input_session_component.h | 59 + os/src/server/loader/loader_child.h | 250 + os/src/server/loader/loader_root.h | 51 + .../server/loader/loader_session_component.cc | 165 + .../server/loader/loader_session_component.h | 86 + os/src/server/loader/loader_view_component.h | 87 + os/src/server/loader/main.cc | 33 + os/src/server/loader/nitpicker_root.h | 82 + .../loader/nitpicker_session_component.cc | 152 + .../loader/nitpicker_session_component.h | 107 + .../server/loader/nitpicker_view_component.h | 99 + os/src/server/loader/rom_root.h | 60 + os/src/server/loader/rom_session_component.cc | 70 + os/src/server/loader/rom_session_component.h | 60 + os/src/server/loader/tar_server_child.h | 171 + os/src/server/loader/target.mk | 8 + os/src/server/mixer/mixer.cc | 692 + os/src/server/mixer/target.mk | 3 + os/src/server/nic_bridge/address_node.cc | 54 + os/src/server/nic_bridge/address_node.h | 111 + os/src/server/nic_bridge/avl_safe.h | 47 + os/src/server/nic_bridge/component.cc | 146 + os/src/server/nic_bridge/component.h | 235 + os/src/server/nic_bridge/list_safe.h | 45 + os/src/server/nic_bridge/mac.cc | 21 + os/src/server/nic_bridge/mac.h | 80 + os/src/server/nic_bridge/main.cc | 53 + os/src/server/nic_bridge/packet_handler.cc | 235 + os/src/server/nic_bridge/packet_handler.h | 168 + os/src/server/nic_bridge/target.mk | 6 + os/src/server/nic_bridge/vlan.cc | 20 + os/src/server/nic_bridge/vlan.h | 56 + os/src/server/nic_loopback/main.cc | 210 + os/src/server/nic_loopback/target.mk | 3 + os/src/server/nit_fb/README | 11 + os/src/server/nit_fb/main.cc | 232 + os/src/server/nit_fb/target.mk | 3 + os/src/server/nitpicker/README | 26 + os/src/server/nitpicker/TODO | 7 + os/src/server/nitpicker/common/user_state.cc | 208 + os/src/server/nitpicker/common/view.cc | 121 + os/src/server/nitpicker/common/view_stack.cc | 319 + os/src/server/nitpicker/data/big_mouse.h | 36 + os/src/server/nitpicker/data/default.tff | Bin 0 -> 20568 bytes os/src/server/nitpicker/genode/main.cc | 914 ++ os/src/server/nitpicker/genode/target.mk | 14 + os/src/server/nitpicker/include/background.h | 48 + .../server/nitpicker/include/chunky_menubar.h | 52 + os/src/server/nitpicker/include/clip_guard.h | 50 + os/src/server/nitpicker/include/draw_label.h | 70 + os/src/server/nitpicker/include/list.h | 109 + os/src/server/nitpicker/include/menubar.h | 67 + os/src/server/nitpicker/include/mode.h | 61 + .../server/nitpicker/include/mouse_cursor.h | 68 + os/src/server/nitpicker/include/session.h | 109 + os/src/server/nitpicker/include/string.h | 34 + os/src/server/nitpicker/include/user_state.h | 81 + os/src/server/nitpicker/include/view.h | 141 + os/src/server/nitpicker/include/view_stack.h | 201 + os/src/server/part_blk/README | 65 + os/src/server/part_blk/back_end.cc | 232 + os/src/server/part_blk/main.cc | 234 + os/src/server/part_blk/part_blk.h | 75 + os/src/server/part_blk/target.mk | 3 + os/src/server/rom_loopdev/README | 6 + os/src/server/rom_loopdev/main.cc | 273 + os/src/server/rom_loopdev/target.mk | 3 + os/src/server/rom_prefetcher/main.cc | 122 + os/src/server/rom_prefetcher/target.mk | 3 + os/src/server/tar_rom/README | 13 + os/src/server/tar_rom/main.cc | 249 + os/src/server/tar_rom/target.mk | 3 + os/src/test/ahci/main.cc | 183 + os/src/test/ahci/target.mk | 3 + os/src/test/alarm/main.cc | 117 + os/src/test/alarm/target.mk | 3 + os/src/test/audio_out/README | 14 + os/src/test/audio_out/main.cc | 219 + os/src/test/audio_out/target.mk | 3 + os/src/test/block/main.cc | 119 + os/src/test/block/target.mk | 3 + os/src/test/bomb/main.cc | 266 + os/src/test/bomb/target.mk | 3 + os/src/test/dde_kit/i8042.h | 186 + os/src/test/dde_kit/target.mk | 3 + os/src/test/dde_kit/test.cc | 699 + os/src/test/fb_block_adapter/main.cc | 251 + os/src/test/fb_block_adapter/target.mk | 3 + os/src/test/input/key_strings.h | 514 + os/src/test/input/target.mk | 3 + os/src/test/input/test.cc | 61 + os/src/test/iso/main.cc | 155 + os/src/test/iso/target.mk | 3 + os/src/test/iso/test.txt | 1 + os/src/test/loader/main.cc | 67 + os/src/test/loader/target.mk | 3 + os/src/test/nic_loopback/main.cc | 186 + os/src/test/nic_loopback/target.mk | 3 + os/src/test/nitpicker/target.mk | 3 + os/src/test/nitpicker/test.cc | 191 + os/src/test/packet_stream/main.cc | 331 + os/src/test/packet_stream/target.mk | 3 + os/src/test/part_blk/main.cc | 115 + os/src/test/part_blk/target.mk | 3 + os/src/test/pci/target.mk | 3 + os/src/test/pci/test.cc | 86 + os/src/test/rom_blk/main.cc | 121 + os/src/test/rom_blk/target.mk | 3 + os/src/test/signal/main.cc | 529 + os/src/test/signal/target.mk | 3 + os/src/test/terminal_echo/main.cc | 46 + os/src/test/terminal_echo/target.mk | 3 + os/src/test/timed_semaphore/main.cc | 102 + os/src/test/timed_semaphore/target.mk | 3 + os/src/test/timer/main.cc | 120 + os/src/test/timer/target.mk | 3 + os/src/test/timer_accuracy/main.cc | 57 + os/src/test/timer_accuracy/target.mk | 4 + os/src/test/uart/main.cc | 38 + os/src/test/uart/target.mk | 3 + os/src/test/xev_track/main.cc | 97 + os/src/test/xev_track/target.mk | 6 + os/tool/dde_kit_adapt_sources | 9 + os/tool/dde_kit_find_initcalls | 24 + ports-foc/Makefile | 89 + ports-foc/README | 221 + ports-foc/config/android_config.arm | 1241 ++ ports-foc/config/android_config.x86_32 | 1322 ++ ports-foc/config/linux_config.arm | 1143 ++ ports-foc/config/linux_config.x86_32 | 1327 ++ ports-foc/include/32-bit/l4/util/l4_macros.h | 21 + ports-foc/include/64-bit/l4/util/l4_macros.h | 21 + ports-foc/include/genode/block.h | 52 + ports-foc/include/genode/framebuffer.h | 97 + ports-foc/include/genode/input.h | 50 + ports-foc/include/genode/linkage.h | 23 + ports-foc/include/genode/net.h | 40 + ports-foc/include/genode/terminal.h | 35 + ports-foc/include/l4/io/io.h | 103 + ports-foc/include/l4/log/log.h | 32 + ports-foc/include/l4/re/c/dataspace.h | 52 + ports-foc/include/l4/re/c/debug.h | 29 + ports-foc/include/l4/re/c/mem_alloc.h | 41 + ports-foc/include/l4/re/c/namespace.h | 32 + ports-foc/include/l4/re/c/rm.h | 50 + ports-foc/include/l4/re/c/util/cap.h | 29 + ports-foc/include/l4/re/c/util/cap_alloc.h | 30 + ports-foc/include/l4/re/consts.h | 23 + ports-foc/include/l4/re/env.h | 57 + ports-foc/include/l4/util/atomic.h | 17 + ports-foc/include/l4/util/cpu.h | 29 + ports-foc/include/l4/util/kip.h | 31 + ports-foc/include/l4/util/kprintf.h | 17 + ports-foc/include/l4/util/util.h | 53 + ports-foc/lib/mk/l4lx.mk | 35 + ports-foc/lib/mk/l4sys.mk | 3 + ports-foc/mk/l4lx.mk | 53 + ports-foc/patches/l4android_genode.patch | 924 ++ ports-foc/patches/l4lx_genode.patch | 938 ++ ports-foc/run/l4android.run | 200 + ports-foc/run/l4linux.run | 144 + ports-foc/src/drivers/Makefile | 5 + ports-foc/src/drivers/genode_block.c | 295 + ports-foc/src/drivers/genode_fb.c | 525 + ports-foc/src/drivers/genode_net.c | 191 + ports-foc/src/drivers/genode_rtc.c | 147 + ports-foc/src/drivers/genode_serial.c | 340 + ports-foc/src/l4android/arm/target.mk | 7 + ports-foc/src/l4android/x86_32/target.mk | 6 + ports-foc/src/l4linux/arm/target.mk | 7 + ports-foc/src/l4linux/x86_32/target.mk | 6 + ports-foc/src/lib/l4lx/dataspace.cc | 30 + ports-foc/src/lib/l4lx/env.cc | 51 + ports-foc/src/lib/l4lx/genode_block.cc | 312 + ports-foc/src/lib/l4lx/genode_framebuffer.cc | 87 + ports-foc/src/lib/l4lx/genode_input.cc | 158 + ports-foc/src/lib/l4lx/genode_net.cc | 226 + ports-foc/src/lib/l4lx/genode_terminal.cc | 112 + ports-foc/src/lib/l4lx/include/dataspace.h | 95 + ports-foc/src/lib/l4lx/include/env.h | 49 + ports-foc/src/lib/l4lx/include/l4lx_irq.h | 80 + ports-foc/src/lib/l4lx/include/l4lx_memory.h | 32 + ports-foc/src/lib/l4lx/include/l4lx_task.h | 46 + ports-foc/src/lib/l4lx/include/l4lx_thread.h | 54 + ports-foc/src/lib/l4lx/include/linux.h | 57 + ports-foc/src/lib/l4lx/include/rm.h | 165 + ports-foc/src/lib/l4lx/include/task.h | 86 + ports-foc/src/lib/l4lx/include/vcpu.h | 125 + ports-foc/src/lib/l4lx/l4_io.cc | 123 + ports-foc/src/lib/l4lx/l4_log.cc | 42 + ports-foc/src/lib/l4lx/l4_re_c_dataspace.cc | 135 + ports-foc/src/lib/l4lx/l4_re_c_debug.cc | 30 + ports-foc/src/lib/l4lx/l4_re_c_mem_alloc.cc | 54 + ports-foc/src/lib/l4lx/l4_re_c_namespace.cc | 33 + ports-foc/src/lib/l4lx/l4_re_c_rm.cc | 161 + ports-foc/src/lib/l4lx/l4_re_c_util_cap.cc | 53 + ports-foc/src/lib/l4lx/l4_re_env.cc | 79 + ports-foc/src/lib/l4lx/l4_util_cpu.cc | 30 + ports-foc/src/lib/l4lx/l4_util_kip.cc | 59 + ports-foc/src/lib/l4lx/l4_util_util.cc | 36 + ports-foc/src/lib/l4lx/l4lx_irq.cc | 279 + ports-foc/src/lib/l4lx/l4lx_memory.cc | 86 + ports-foc/src/lib/l4lx/l4lx_task.cc | 172 + ports-foc/src/lib/l4lx/l4lx_thread.cc | 176 + ports-foc/src/lib/l4lx/rm.cc | 254 + ports-foc/src/lib/l4lx/startup.cc | 149 + ports-okl4/Makefile | 74 + ports-okl4/README | 121 + ports-okl4/config/elfweaver_config | 72 + ports-okl4/config/init_config | 76 + ports-okl4/config/linux_config | 607 + ports-okl4/include/oklx_kernel/oklx/ioctl.h | 47 + ports-okl4/include/oklx_lib/genode/audio.h | 37 + ports-okl4/include/oklx_lib/genode/block.h | 30 + ports-okl4/include/oklx_lib/genode/config.h | 42 + ports-okl4/include/oklx_lib/genode/exit.h | 23 + .../include/oklx_lib/genode/framebuffer.h | 85 + ports-okl4/include/oklx_lib/genode/input.h | 32 + ports-okl4/include/oklx_lib/genode/lock.h | 45 + ports-okl4/include/oklx_lib/genode/memory.h | 40 + ports-okl4/include/oklx_lib/genode/net.h | 26 + ports-okl4/include/oklx_lib/genode/open.h | 26 + ports-okl4/include/oklx_lib/genode/printf.h | 22 + ports-okl4/include/oklx_lib/genode/sleep.h | 29 + ports-okl4/include/oklx_lib/iguana/eas.h | 66 + ports-okl4/include/oklx_lib/iguana/hardware.h | 39 + .../include/oklx_lib/iguana/memsection.h | 110 + ports-okl4/include/oklx_lib/iguana/pd.h | 47 + ports-okl4/include/oklx_lib/iguana/stdint.h | 20 + ports-okl4/include/oklx_lib/iguana/thread.h | 56 + ports-okl4/include/oklx_lib/iguana/tls.h | 24 + ports-okl4/include/oklx_lib/iguana/types.h | 25 + ports-okl4/lib/mk/oklx.mk | 32 + ports-okl4/patches/oklx_genode.patch | 3350 +++++ ports-okl4/patches/unionfs.patch | 11419 +++++++++++++++ ports-okl4/run/lx_block.run | 104 + ports-okl4/src/app/xev_track/bounding_box.h | 60 + ports-okl4/src/app/xev_track/main.cc | 187 + ports-okl4/src/app/xev_track/target.mk | 6 + .../src/lib/oklx/genode/genode_audio.cc | 303 + .../src/lib/oklx/genode/genode_block.cc | 179 + .../src/lib/oklx/genode/genode_config.cc | 145 + ports-okl4/src/lib/oklx/genode/genode_exit.cc | 29 + .../src/lib/oklx/genode/genode_framebuffer.cc | 173 + .../src/lib/oklx/genode/genode_input.cc | 153 + ports-okl4/src/lib/oklx/genode/genode_lock.cc | 53 + .../src/lib/oklx/genode/genode_memory.cc | 71 + ports-okl4/src/lib/oklx/genode/genode_net.cc | 176 + ports-okl4/src/lib/oklx/genode/genode_open.cc | 56 + .../src/lib/oklx/genode/genode_printf.cc | 29 + .../src/lib/oklx/genode/genode_sleep.cc | 34 + .../src/lib/oklx/genode/genode_threads.cc | 191 + ports-okl4/src/lib/oklx/iguana/iguana_eas.cc | 159 + .../src/lib/oklx/iguana/iguana_hardware.cc | 35 + .../src/lib/oklx/iguana/iguana_memsection.cc | 132 + ports-okl4/src/lib/oklx/iguana/iguana_pd.cc | 41 + .../src/lib/oklx/iguana/iguana_thread.cc | 54 + ports-okl4/src/lib/oklx/iguana/iguana_tls.cc | 34 + .../src/lib/oklx/include/oklx_memory_maps.h | 76 + .../src/lib/oklx/include/oklx_screens.h | 146 + .../src/lib/oklx/include/oklx_threads.h | 169 + ports-okl4/src/oklinux/main.cc | 1 + ports-okl4/src/oklinux/target.mk | 53 + ports/Makefile | 73 + ports/README | 15 + ports/doc/gdb.txt | 503 + ports/include/noux_session/capability.h | 22 + ports/include/noux_session/client.h | 47 + ports/include/noux_session/connection.h | 31 + ports/include/noux_session/noux_session.h | 99 + ports/include/noux_session/sysio.h | 256 + ports/lib/mk/fiasco_x86/gdbserver_platform.mk | 3 + ports/lib/mk/foc_arm/gdbserver_platform.mk | 7 + ports/lib/mk/foc_x86_32/gdbserver_platform.mk | 3 + ports/lib/mk/gdbserver_libc_support.mk | 7 + ports/lib/mk/gdbserver_platform.inc | 25 + ports/lib/mk/libc_noux.mk | 7 + .../lib/mk/linux_x86_32/gdbserver_platform.mk | 3 + ports/lib/mk/okl4_x86/gdbserver_platform.mk | 3 + .../mk/pistachio_x86/gdbserver_platform.mk | 3 + .../mk/x86_32/gdbserver_platform_x86_32.inc | 7 + ports/mk/noux.mk | 192 + ports/ports/arora.mk | 27 + ports/ports/bash.mk | 21 + ports/ports/binutils.mk | 21 + ports/ports/coreutils.mk | 20 + ports/ports/dash.mk | 21 + ports/ports/findutils.mk | 20 + ports/ports/gcc.mk | 28 + ports/ports/gdb.mk | 80 + ports/ports/make.mk | 20 + ports/ports/vancouver.mk | 21 + ports/ports/vim.mk | 32 + ports/run/debug_nitpicker.run | 147 + ports/run/gdb_monitor.run | 101 + ports/run/noux.run | 77 + ports/run/noux_vim.run | 148 + ports/run/vancouver.run | 126 + ports/src/app/arora/arora.pro | 1 + ports/src/app/arora/arora_bookmarks.patch | 29 + .../src/app/arora/arora_disable_adblock.patch | 42 + .../arora/arora_disable_program_exit.patch | 13 + ports/src/app/arora/arora_genode.patch | 401 + ports/src/app/arora/arora_move_window.patch | 14 + .../app/arora/arora_nitpicker_plugin.patch | 28 + ports/src/app/arora/arora_startpage.patch | 24 + ports/src/app/arora/demo/bg.png | Bin 0 -> 521 bytes ports/src/app/arora/demo/bg_content.png | Bin 0 -> 676 bytes ports/src/app/arora/demo/bg_top.png | Bin 0 -> 3022 bytes ports/src/app/arora/demo/busybox.html | 70 + ports/src/app/arora/demo/demo.html | 7 + ports/src/app/arora/demo/http_block.png | Bin 0 -> 76084 bytes ports/src/app/arora/demo/intro.html | 81 + ports/src/app/arora/demo/nitpicker.html | 142 + ports/src/app/arora/demo/nitpicker_plugin.png | Bin 0 -> 96674 bytes ports/src/app/arora/demo/tetrix.html | 15 + ports/src/app/arora/demo/tinycore.html | 120 + ports/src/app/arora/demo/title_bg.png | Bin 0 -> 785 bytes ports/src/app/arora/demo_html.qrc | 14 + .../arora/qwebplugins/nitpicker/nitpicker.pri | 13 + .../qwebplugins/nitpicker/nitpickerplugin.cpp | 78 + .../qwebplugins/nitpicker/nitpickerplugin.h | 27 + .../nitpicker/nitpickerpluginwidget.cpp | 80 + .../nitpicker/nitpickerpluginwidget.h | 39 + ports/src/app/arora/target.mk | 251 + ports/src/app/gdb_monitor/app_child.h | 311 + ports/src/app/gdb_monitor/append_list.h | 110 + ports/src/app/gdb_monitor/cpu_root.h | 63 + .../app/gdb_monitor/cpu_session_component.cc | 191 + .../app/gdb_monitor/cpu_session_component.h | 73 + ports/src/app/gdb_monitor/dataspace_object.h | 43 + ports/src/app/gdb_monitor/gdb_stub_thread.cc | 40 + ports/src/app/gdb_monitor/gdb_stub_thread.h | 61 + ports/src/app/gdb_monitor/gdbserver/config.h | 31 + .../app/gdb_monitor/gdbserver/genode-low.cc | 345 + .../app/gdb_monitor/gdbserver/genode-low.h | 41 + .../app/gdb_monitor/gdbserver_genode.patch | 938 ++ ports/src/app/gdb_monitor/main.cc | 106 + ports/src/app/gdb_monitor/ram_root.h | 48 + .../app/gdb_monitor/ram_session_component.cc | 67 + .../app/gdb_monitor/ram_session_component.h | 54 + ports/src/app/gdb_monitor/rm_root.h | 65 + .../app/gdb_monitor/rm_session_component.cc | 157 + .../app/gdb_monitor/rm_session_component.h | 106 + ports/src/app/gdb_monitor/rom.h | 122 + .../app/gdb_monitor/signal_handler_thread.cc | 61 + .../app/gdb_monitor/signal_handler_thread.h | 40 + ports/src/app/gdb_monitor/target.mk | 42 + ports/src/app/gdb_monitor/thread_info.h | 43 + .../lib/gdbserver_libc_support/elf/common.h | 20 + .../gdbserver_libc_support.c | 43 + .../gdbserver_libc_support.h | 36 + .../lib/gdbserver_libc_support/sys/procfs.h | 25 + .../lib/gdbserver_libc_support/sys/ptrace.h | 40 + .../src/lib/gdbserver_libc_support/sys/vfs.h | 19 + .../lib/gdbserver_platform/fiasco_x86_low.cc | 75 + .../src/lib/gdbserver_platform/foc_arm_low.cc | 122 + .../lib/gdbserver_platform/foc_x86_32_low.cc | 111 + .../gdbserver_platform_helper.cc | 40 + .../gdbserver_platform_helper.h | 19 + ports/src/lib/gdbserver_platform/i386.h | 37 + .../gdbserver_platform/linux_x86_32_low.cc | 56 + .../lib/gdbserver_platform/okl4_x86_low.cc | 75 + .../gdbserver_platform/pistachio_x86_low.cc | 77 + ports/src/lib/gdbserver_platform/reg-arm.h | 47 + ports/src/lib/libc_noux/plugin.cc | 731 + ports/src/lib/libc_noux/target.mk | 2 + ports/src/noux-pkg/bash/build.patch | 40 + ports/src/noux-pkg/bash/target.mk | 11 + ports/src/noux-pkg/binutils/build.patch | 11 + ports/src/noux-pkg/binutils/target.mk | 15 + ports/src/noux-pkg/coreutils/target.mk | 10 + ports/src/noux-pkg/dash/build.patch | 18 + ports/src/noux-pkg/dash/target.mk | 8 + ports/src/noux-pkg/findutils/target.mk | 1 + ports/src/noux-pkg/gcc/build.patch | 129 + ports/src/noux-pkg/gcc/target.mk | 207 + ports/src/noux-pkg/make/target.mk | 6 + ports/src/noux-pkg/vim/target.mk | 56 + ports/src/noux/args.h | 116 + ports/src/noux/child.h | 302 + ports/src/noux/directory_service.h | 43 + ports/src/noux/dummy_input_io_channel.h | 28 + ports/src/noux/environment.h | 90 + ports/src/noux/file_descriptor_registry.h | 116 + ports/src/noux/file_io_service.h | 32 + ports/src/noux/file_system.h | 96 + ports/src/noux/io_channel.h | 111 + ports/src/noux/main.cc | 451 + ports/src/noux/path.h | 303 + ports/src/noux/pwd.h | 42 + ports/src/noux/range_checked_index.h | 46 + ports/src/noux/root_file_system.h | 93 + ports/src/noux/shared_pointer.h | 142 + ports/src/noux/signal_dispatcher.h | 28 + ports/src/noux/tar_file_system.h | 408 + ports/src/noux/target.mk | 4 + ports/src/noux/terminal_io_channel.h | 128 + ports/src/noux/vfs.h | 87 + ports/src/noux/vfs_handle.h | 98 + ports/src/noux/vfs_io_channel.h | 102 + ports/src/noux/wake_up_notifier.h | 37 + ports/src/test/gdb_monitor/main.cc | 79 + ports/src/test/gdb_monitor/target.mk | 3 + ports/src/vancouver/README | 9 + ports/src/vancouver/boot_module_provider.h | 199 + ports/src/vancouver/device_model_registry.cc | 88 + ports/src/vancouver/device_model_registry.h | 66 + ports/src/vancouver/main.cc | 992 ++ ports/src/vancouver/nova_user_env.cc | 133 + ports/src/vancouver/service/profile.h | 22 + ports/src/vancouver/target.mk | 41 + qt4/Makefile | 77 + qt4/README | 27 + qt4/include/genode/thread_qt.h | 116 + .../qnitpickerviewwidget.h | 53 + qt4/include/qpluginwidget/qpluginwidget.h | 107 + .../private/qeventdispatcher_genode_p.h | 208 + qt4/include/qt4/QtCore/qconfig-genode.h | 585 + qt4/include/qt4/QtCore/qconfig.h | 369 + .../private/qwindowsurface_nitpicker_qws_p.h | 80 + qt4/include/qt4/QtGui/qinputnitpicker_qws.h | 52 + qt4/include/qt4/QtGui/qkbdnitpicker_qws.h | 69 + qt4/include/qt4/QtGui/qkbdpc101_qws.h | 95 + qt4/include/qt4/QtGui/qmousenitpicker_qws.h | 71 + qt4/include/qt4/QtGui/qscreennitpicker_qws.h | 83 + qt4/lib/import/import-qt4.mk | 143 + qt4/lib/import/import-qt_core.mk | 3 + qt4/lib/import/import-qt_gui.mk | 3 + qt4/lib/import/import-qt_javascriptcore.mk | 3 + qt4/lib/import/import-qt_jscore.mk | 3 + qt4/lib/import/import-qt_network.mk | 3 + qt4/lib/import/import-qt_script.mk | 3 + qt4/lib/import/import-qt_scriptclassic.mk | 3 + qt4/lib/import/import-qt_scripttools.mk | 3 + qt4/lib/import/import-qt_svg.mk | 3 + qt4/lib/import/import-qt_ui_tools.mk | 3 + qt4/lib/import/import-qt_webcore.mk | 3 + qt4/lib/import/import-qt_xml.mk | 3 + qt4/lib/mk/dejavusans.mk | 7 + qt4/lib/mk/qgif.mk | 10 + qt4/lib/mk/qjpeg.mk | 10 + qt4/lib/mk/qnitpickerviewwidget.mk | 10 + qt4/lib/mk/qpluginwidget.mk | 10 + qt4/lib/mk/qt_core.mk | 312 + qt4/lib/mk/qt_gui.mk | 767 + qt4/lib/mk/qt_jscore.mk | 284 + qt4/lib/mk/qt_network.mk | 150 + qt4/lib/mk/qt_script.mk | 1 + qt4/lib/mk/qt_script46.mk | 346 + qt4/lib/mk/qt_scriptclassic.mk | 94 + qt4/lib/mk/qt_scripttools.mk | 160 + qt4/lib/mk/qt_svg.mk | 66 + qt4/lib/mk/qt_ui_tools.mk | 66 + qt4/lib/mk/qt_webcore.mk | 1870 +++ qt4/lib/mk/qt_xml.mk | 50 + qt4/run/qt4.run | 132 + .../calculatorform/calculatorform.cpp | 57 + .../examples/calculatorform/calculatorform.h | 59 + .../calculatorform/calculatorform.pro | 8 + .../examples/calculatorform/calculatorform.ui | 284 + qt4/src/app/examples/calculatorform/font.qrc | 6 + qt4/src/app/examples/calculatorform/main.cpp | 50 + qt4/src/app/examples/calculatorform/target.mk | 77 + qt4/src/app/examples/previewer/target.mk | 99 + qt4/src/app/examples/tetrix/font.qrc | 6 + qt4/src/app/examples/tetrix/main.cpp | 117 + qt4/src/app/examples/tetrix/target.mk | 77 + qt4/src/app/examples/tetrix/tetrix.pro | 11 + qt4/src/app/examples/tetrix/tetrix.qrc | 8 + qt4/src/app/examples/tetrix/tetrixboard.cpp | 127 + qt4/src/app/examples/tetrix/tetrixboard.h | 96 + qt4/src/app/examples/tetrix/tetrixboard.js | 249 + qt4/src/app/examples/tetrix/tetrixpiece.js | 131 + qt4/src/app/examples/tetrix/tetrixwindow.js | 16 + qt4/src/app/examples/tetrix/tetrixwindow.ui | 164 + qt4/src/app/examples/textedit/target.mk | 98 + qt4/src/app/qt_launchpad/child_entry.cpp | 29 + qt4/src/app/qt_launchpad/child_entry.h | 43 + qt4/src/app/qt_launchpad/child_entry.ui | 148 + qt4/src/app/qt_launchpad/font.qrc | 6 + qt4/src/app/qt_launchpad/kbyte_loadbar.cpp | 24 + qt4/src/app/qt_launchpad/kbyte_loadbar.h | 33 + qt4/src/app/qt_launchpad/launch_entry.cpp | 31 + qt4/src/app/qt_launchpad/launch_entry.h | 43 + qt4/src/app/qt_launchpad/launch_entry.ui | 133 + qt4/src/app/qt_launchpad/main.cpp | 47 + qt4/src/app/qt_launchpad/qt_launchpad.cpp | 113 + qt4/src/app/qt_launchpad/qt_launchpad.h | 46 + qt4/src/app/qt_launchpad/qt_launchpad.pro | 11 + qt4/src/app/qt_launchpad/qt_launchpad.ui | 152 + qt4/src/app/qt_launchpad/target.mk | 83 + qt4/src/app/tmpl/target.mk.example | 85 + qt4/src/lib/dejavusans/dejavusans.qrc | 6 + .../qnitpickerviewwidget.cpp | 277 + qt4/src/lib/qpluginwidget/qpluginwidget.cpp | 313 + qt4/src/lib/qt4/mkspecs/genode-g++/qmake.conf | 14 + .../qt4/mkspecs/genode-g++/qplatformdefs.h | 100 + .../qt4/mkspecs/qws/genode-x86-g++/qmake.conf | 9 + .../qws/genode-x86-g++/qplatformdefs.h | 42 + qt4/src/lib/qt4/previewer_example.patch | 23 + qt4/src/lib/qt4/qt4_genode.patch | 1644 +++ qt4/src/lib/qt4/qt4_include_time_h.patch | 38 + .../qt4_lwip_connect_semantics_adaption.patch | 26 + .../lib/qt4/qt4_no_exit_on_window_close.patch | 30 + .../qt4/qt4_no_search_for_resolv_lib.patch | 19 + .../qt4_no_separate_host_lookup_threads.patch | 72 + qt4/src/lib/qt4/qt4_nonblocking_sockets.patch | 21 + qt4/src/lib/qt4/qt4_renderwidget.patch | 17 + qt4/src/lib/qt4/qt4_virtual_deletelater.patch | 12 + .../lib/qt4/src/corelib/global/qconfig.cpp | 32 + .../qt4/src/corelib/io/qprocess_genode.cpp | 275 + .../kernel/qeventdispatcher_genode.cpp | 990 ++ .../qt4/src/corelib/thread/qmutex_genode.cpp | 88 + .../qt4/src/corelib/thread/qthread_genode.cpp | 431 + .../corelib/thread/qwaitcondition_genode.cpp | 264 + .../src/gui/embedded/qinputnitpicker_qws.cpp | 106 + .../src/gui/embedded/qkbdnitpicker_qws.cpp | 73 + .../qt4/src/gui/embedded/qkbdpc101_qws.cpp | 493 + .../src/gui/embedded/qmousenitpicker_qws.cpp | 126 + .../src/gui/embedded/qscreennitpicker_qws.cpp | 293 + .../painting/qwindowsurface_nitpicker_qws.cpp | 169 + qt4/src/lib/qt4/textedit_example.patch | 32 + qt4/src/lib/qt_main/qt_main.cc | 77 + qt4/tool/Makefile | 76 + qt4/tool/qmake/Makefile | 150 + tool/README | 50 + tool/autopilot | 360 + tool/beautify | 1770 +++ tool/boot/chain.c32 | Bin 0 -> 20192 bytes tool/boot/isolinux.bin | Bin 0 -> 24576 bytes tool/boot/isolinux.cfg | 5 + tool/boot/stage2_eltorito | Bin 0 -> 165928 bytes tool/builddir/build.mk | 280 + tool/builddir/etc/README | 2 + tool/builddir/etc/build.conf.codezero_vpb926 | 1 + tool/builddir/etc/build.conf.drivers_x86 | 12 + tool/builddir/etc/build.conf.fiasco_x86 | 1 + tool/builddir/etc/build.conf.foc_pbxa9 | 1 + tool/builddir/etc/build.conf.foc_vea9x4 | 1 + tool/builddir/etc/build.conf.foc_x86_32 | 1 + tool/builddir/etc/build.conf.foc_x86_64 | 1 + tool/builddir/etc/build.conf.generic | 42 + tool/builddir/etc/build.conf.linux_x86 | 1 + tool/builddir/etc/build.conf.mb_ml507 | 2 + .../etc/build.conf.mb_s3a_starter_kit | 2 + tool/builddir/etc/build.conf.nova_x86 | 6 + tool/builddir/etc/build.conf.okl4_x86 | 1 + tool/builddir/etc/build.conf.pistachio_x86 | 1 + tool/builddir/etc/build.conf.ports-foc | 5 + tool/builddir/etc/build.conf.ports-okl4 | 5 + tool/builddir/etc/build.conf.qemu_no_kvm | 10 + tool/create_builddir | 145 + tool/create_iso | 70 + tool/fix_include_ifndef | 119 + tool/libgcc_libc_stub.h | 641 + tool/parse_cxx | 906 ++ tool/run | 484 + tool/tool_chain | 579 + 2462 files changed, 320115 insertions(+), 3 deletions(-) create mode 100644 LICENSE create mode 100644 base-codezero/Makefile create mode 100644 base-codezero/README create mode 100644 base-codezero/config/vpb926.cml create mode 100644 base-codezero/doc/codezero.txt create mode 100644 base-codezero/etc/specs.conf create mode 100644 base-codezero/include/arm/cpu/atomic.h create mode 100644 base-codezero/include/base/ipc_msgbuf.h create mode 100644 base-codezero/include/base/ipc_pager.h create mode 100644 base-codezero/include/base/native_types.h create mode 100644 base-codezero/include/codezero/dummies/stdio.h create mode 100644 base-codezero/include/codezero/dummies/string.h create mode 100644 base-codezero/include/codezero/syscalls.h create mode 100644 base-codezero/lib/mk/arm/startup.mk create mode 100644 base-codezero/lib/mk/arm_v5/l4.mk create mode 100644 base-codezero/lib/mk/arm_v5/l4_arm_v5.mk create mode 100644 base-codezero/lib/mk/codezero_cml.inc create mode 100644 base-codezero/lib/mk/cxx.mk create mode 100644 base-codezero/lib/mk/ipc.mk create mode 100644 base-codezero/lib/mk/l4.inc create mode 100644 base-codezero/lib/mk/lock.mk create mode 100644 base-codezero/lib/mk/pager.mk create mode 100644 base-codezero/lib/mk/pl011/core_printf.mk create mode 100644 base-codezero/lib/mk/platform.mk create mode 100644 base-codezero/lib/mk/thread.mk create mode 100644 base-codezero/mk/spec-codezero.mk create mode 100644 base-codezero/mk/spec-codezero_arm.mk create mode 100644 base-codezero/mk/spec-codezero_arm_v5.mk create mode 100644 base-codezero/mk/spec-codezero_platform_vpb926.mk create mode 100644 base-codezero/patches/README create mode 100644 base-codezero/patches/binutils-2.21.patch create mode 100644 base-codezero/patches/gcc_4_6_1_fixes.patch create mode 100644 base-codezero/patches/gcc_shared_enabled.patch create mode 100644 base-codezero/patches/libc_search_dir.patch create mode 100644 base-codezero/patches/scons-2.0.1.patch create mode 100644 base-codezero/patches/set_fixed_pager.patch create mode 100644 base-codezero/run/env create mode 100644 base-codezero/src/base/console/pl011/core_console.h create mode 100644 base-codezero/src/base/cxx/exception.cc create mode 100644 base-codezero/src/base/cxx/memcmp.cc create mode 100644 base-codezero/src/base/ipc/ipc.cc create mode 100644 base-codezero/src/base/ipc/pager.cc create mode 100644 base-codezero/src/base/lock/cmpxchg.cc create mode 100644 base-codezero/src/base/lock/lock.cc create mode 100644 base-codezero/src/base/lock/lock_helper.h create mode 100644 base-codezero/src/base/pager/pager.cc create mode 100644 base-codezero/src/base/thread/thread_start.cc create mode 100644 base-codezero/src/core/core_rm_session.cc create mode 100644 base-codezero/src/core/include/core_rm_session.h create mode 100644 base-codezero/src/core/include/irq_session_component.h create mode 100644 base-codezero/src/core/include/map_local.h create mode 100644 base-codezero/src/core/include/platform.h create mode 100644 base-codezero/src/core/include/platform_pd.h create mode 100644 base-codezero/src/core/include/platform_thread.h create mode 100644 base-codezero/src/core/include/util.h create mode 100644 base-codezero/src/core/io_mem_session_support.cc create mode 100644 base-codezero/src/core/io_port_session_component.cc create mode 100644 base-codezero/src/core/irq_session_component.cc create mode 100644 base-codezero/src/core/platform.cc create mode 100644 base-codezero/src/core/platform_pd.cc create mode 100644 base-codezero/src/core/platform_thread.cc create mode 100644 base-codezero/src/core/ram_session_support.cc create mode 100644 base-codezero/src/core/rm_session_support.cc create mode 100644 base-codezero/src/core/target.inc create mode 100644 base-codezero/src/core/target.mk create mode 100644 base-codezero/src/core/thread_start.cc create mode 100644 base-codezero/src/kernel/target.mk create mode 100644 base-codezero/src/platform/_main_helper.h create mode 100644 base-codezero/src/platform/genode.ld create mode 100755 base-codezero/tool/gen_romfs create mode 100644 base-fiasco/Makefile create mode 100644 base-fiasco/README create mode 100644 base-fiasco/config/kernel-config.x86 create mode 100644 base-fiasco/config/l4env-config.x86 create mode 100644 base-fiasco/doc/fiasco.txt create mode 100644 base-fiasco/etc/fiasco.conf create mode 100644 base-fiasco/etc/specs.conf create mode 100644 base-fiasco/etc/tools.conf create mode 100644 base-fiasco/include/arm/cpu/atomic.h create mode 100644 base-fiasco/include/base/cancelable_lock.h create mode 100644 base-fiasco/include/base/ipc_msgbuf.h create mode 100644 base-fiasco/include/base/ipc_pager.h create mode 100644 base-fiasco/include/base/native_types.h create mode 100644 base-fiasco/include/fiasco/thread_helper.h create mode 100644 base-fiasco/lib/mk/arm/startup.mk create mode 100644 base-fiasco/lib/mk/core_printf.mk create mode 100644 base-fiasco/lib/mk/ipc.mk create mode 100644 base-fiasco/lib/mk/l4v2_support.mk create mode 100644 base-fiasco/lib/mk/lock.mk create mode 100644 base-fiasco/lib/mk/pager.mk create mode 100644 base-fiasco/lib/mk/platform.inc create mode 100644 base-fiasco/lib/mk/x86/platform.mk create mode 100644 base-fiasco/lib/mk/x86/startup.mk create mode 100644 base-fiasco/mk/l4_pkg.mk create mode 100644 base-fiasco/mk/spec-fiasco.mk create mode 100644 base-fiasco/mk/spec-fiasco_arm.mk create mode 100644 base-fiasco/mk/spec-fiasco_x86.mk create mode 100644 base-fiasco/mk/spec-platform_imx.mk create mode 100644 base-fiasco/mk/spec-platform_integrator.mk create mode 100644 base-fiasco/mk/spec-platform_mmsp2.mk create mode 100644 base-fiasco/run/env create mode 100644 base-fiasco/src/base/console/core_console.h create mode 100644 base-fiasco/src/base/ipc/ipc.cc create mode 100644 base-fiasco/src/base/ipc/pager.cc create mode 100644 base-fiasco/src/base/lock/lock.cc create mode 100644 base-fiasco/src/base/pager/pager.cc create mode 100644 base-fiasco/src/bootstrap/target.mk create mode 100644 base-fiasco/src/core/arm/platform_arm.cc create mode 100644 base-fiasco/src/core/arm/target.mk create mode 100644 base-fiasco/src/core/include/map_local.h create mode 100644 base-fiasco/src/core/include/platform.h create mode 100644 base-fiasco/src/core/include/platform_pd.h create mode 100644 base-fiasco/src/core/include/platform_thread.h create mode 100644 base-fiasco/src/core/include/util.h create mode 100644 base-fiasco/src/core/io_mem_session_support.cc create mode 100644 base-fiasco/src/core/irq_session_component.cc create mode 100644 base-fiasco/src/core/platform.cc create mode 100644 base-fiasco/src/core/platform_pd.cc create mode 100644 base-fiasco/src/core/platform_thread.cc create mode 100644 base-fiasco/src/core/ram_session_support.cc create mode 100644 base-fiasco/src/core/rm_session_support.cc create mode 100644 base-fiasco/src/core/target.inc create mode 100644 base-fiasco/src/core/thread_start.cc create mode 100644 base-fiasco/src/core/x86/platform_x86.cc create mode 100644 base-fiasco/src/core/x86/target.mk create mode 100644 base-fiasco/src/kernel/target.inc create mode 100644 base-fiasco/src/kernel/x86/target.mk create mode 100644 base-fiasco/src/platform/_main_helper.h create mode 100644 base-fiasco/src/platform/arm/Makefile create mode 100644 base-fiasco/src/platform/arm/_main.cc create mode 100644 base-fiasco/src/platform/arm/crt0.s create mode 100644 base-fiasco/src/sigma0/target.mk create mode 100644 base-foc/Makefile create mode 100644 base-foc/README create mode 100644 base-foc/config/pbxa9.kernel create mode 100644 base-foc/config/rva9.user create mode 100644 base-foc/config/vea9x4.kernel create mode 100644 base-foc/config/x86_32.kernel create mode 100644 base-foc/config/x86_64.kernel create mode 100644 base-foc/doc/foc.txt create mode 100644 base-foc/etc/foc.conf create mode 100644 base-foc/etc/specs.conf create mode 100644 base-foc/include/arm/cpu/atomic.h create mode 100644 base-foc/include/base/cap_sel_alloc.h create mode 100644 base-foc/include/base/ipc.h create mode 100644 base-foc/include/base/ipc_msgbuf.h create mode 100644 base-foc/include/base/ipc_pager.h create mode 100644 base-foc/include/base/native_types.h create mode 100644 base-foc/include/base/thread_state.h create mode 100644 base-foc/include/foc_cpu_session/client.h create mode 100644 base-foc/include/foc_cpu_session/connection.h create mode 100644 base-foc/include/foc_cpu_session/foc_cpu_session.h create mode 100644 base-foc/include/foc_pd_session/client.h create mode 100644 base-foc/include/foc_pd_session/connection.h create mode 100644 base-foc/include/foc_pd_session/foc_pd_session.h create mode 100644 base-foc/include/signal_session/foc_source.h create mode 100644 base-foc/include/signal_session/source_client.h create mode 100644 base-foc/include/signal_session/source_rpc_object.h create mode 100644 base-foc/lib/mk/arm/ipc.mk create mode 100644 base-foc/lib/mk/arm/platform.inc create mode 100644 base-foc/lib/mk/arm/startup.mk create mode 100644 base-foc/lib/mk/arm/syscalls.mk create mode 100644 base-foc/lib/mk/cap_alloc.mk create mode 100644 base-foc/lib/mk/core_printf.mk create mode 100644 base-foc/lib/mk/env.mk create mode 100644 base-foc/lib/mk/ipc.inc create mode 100644 base-foc/lib/mk/l4re_support.mk create mode 100644 base-foc/lib/mk/lock.mk create mode 100644 base-foc/lib/mk/pager.mk create mode 100644 base-foc/lib/mk/platform.inc create mode 100644 base-foc/lib/mk/platform_pbxa9/platform.mk create mode 100644 base-foc/lib/mk/platform_vea9x4/platform.mk create mode 100644 base-foc/lib/mk/raw_server.mk create mode 100644 base-foc/lib/mk/server.mk create mode 100644 base-foc/lib/mk/thread.mk create mode 100644 base-foc/lib/mk/x86/syscalls.mk create mode 100644 base-foc/lib/mk/x86_32/ipc.mk create mode 100644 base-foc/lib/mk/x86_32/platform.mk create mode 100644 base-foc/lib/mk/x86_32/startup.mk create mode 100644 base-foc/lib/mk/x86_64/ipc.mk create mode 100644 base-foc/lib/mk/x86_64/platform.mk create mode 100644 base-foc/lib/mk/x86_64/startup.mk create mode 100644 base-foc/mk/l4_pkg.mk create mode 100644 base-foc/mk/spec-foc.mk create mode 100644 base-foc/mk/spec-foc_arm.mk create mode 100644 base-foc/mk/spec-foc_pbxa9.mk create mode 100644 base-foc/mk/spec-foc_vea9x4.mk create mode 100644 base-foc/mk/spec-foc_x86_32.mk create mode 100644 base-foc/mk/spec-foc_x86_64.mk create mode 100644 base-foc/patches/README create mode 100644 base-foc/patches/crtn_arm_binutils_2.21.1.patch create mode 100644 base-foc/patches/fix_exception_ip.patch create mode 100644 base-foc/patches/foc_single_step_x86.patch create mode 100644 base-foc/patches/timer_arm.patch create mode 100644 base-foc/patches/vexpress_detection.patch create mode 100644 base-foc/run/env create mode 100644 base-foc/src/base/console/core_console.h create mode 100644 base-foc/src/base/env/cap_sel_alloc.cc create mode 100644 base-foc/src/base/ipc/arm/pager.cc create mode 100644 base-foc/src/base/ipc/arm/pager_exception.cc create mode 100644 base-foc/src/base/ipc/ipc.cc create mode 100644 base-foc/src/base/ipc/pager.cc create mode 100644 base-foc/src/base/ipc/x86/pager_exception.cc create mode 100644 base-foc/src/base/ipc/x86_32/pager.cc create mode 100644 base-foc/src/base/ipc/x86_64/pager.cc create mode 100644 base-foc/src/base/lock/lock_helper.h create mode 100644 base-foc/src/base/pager/pager.cc create mode 100644 base-foc/src/base/server/server.cc create mode 100644 base-foc/src/base/thread/thread.cc create mode 100644 base-foc/src/base/thread/thread_bootstrap.cc create mode 100644 base-foc/src/base/thread/thread_start.cc create mode 100644 base-foc/src/bootstrap/target.mk create mode 100644 base-foc/src/core/arm/platform_arm.cc create mode 100644 base-foc/src/core/arm/platform_thread.cc create mode 100644 base-foc/src/core/arm/target.mk create mode 100644 base-foc/src/core/cap_session_component.cc create mode 100644 base-foc/src/core/cpu_session_extension.cc create mode 100644 base-foc/src/core/include/cap_session_component.h create mode 100644 base-foc/src/core/include/cpu_session_component.h create mode 100644 base-foc/src/core/include/irq_session_component.h create mode 100644 base-foc/src/core/include/map_local.h create mode 100644 base-foc/src/core/include/pd_session_component.h create mode 100644 base-foc/src/core/include/platform.h create mode 100644 base-foc/src/core/include/platform_pd.h create mode 100644 base-foc/src/core/include/platform_thread.h create mode 100644 base-foc/src/core/include/util.h create mode 100644 base-foc/src/core/io_mem_session_support.cc create mode 100644 base-foc/src/core/irq_session_component.cc create mode 100644 base-foc/src/core/pd_session_extension.cc create mode 100644 base-foc/src/core/platform.cc create mode 100644 base-foc/src/core/platform_pd.cc create mode 100644 base-foc/src/core/platform_thread.cc create mode 100644 base-foc/src/core/ram_session_support.cc create mode 100644 base-foc/src/core/rm_session_support.cc create mode 100644 base-foc/src/core/signal_source_component.cc create mode 100644 base-foc/src/core/target.inc create mode 100644 base-foc/src/core/thread_start.cc create mode 100644 base-foc/src/core/x86/platform_thread.cc create mode 100644 base-foc/src/core/x86/platform_x86.cc create mode 100644 base-foc/src/core/x86/target.mk create mode 100644 base-foc/src/kernel/pbxa9/target.mk create mode 100644 base-foc/src/kernel/target.inc create mode 100644 base-foc/src/kernel/vea9x4/target.mk create mode 100644 base-foc/src/kernel/x86_32/target.mk create mode 100644 base-foc/src/kernel/x86_64/target.mk create mode 100644 base-foc/src/platform/_main_helper.h create mode 100644 base-foc/src/platform/_main_parent_cap.h create mode 100644 base-foc/src/sigma0/target.mk create mode 100644 base-host/README create mode 100644 base-host/etc/specs.conf create mode 100644 base-host/etc/tools.conf create mode 100644 base-host/include/base/ipc_msgbuf.h create mode 100644 base-host/include/base/ipc_pager.h create mode 100644 base-host/include/base/native_types.h create mode 100644 base-host/lib/mk/core_printf.mk create mode 100644 base-host/lib/mk/env.mk create mode 100644 base-host/lib/mk/ipc.mk create mode 100644 base-host/lib/mk/lock.mk create mode 100644 base-host/lib/mk/pager.mk create mode 100644 base-host/lib/mk/printf_stdio.mk create mode 100644 base-host/src/base/env/parent.cc create mode 100644 base-host/src/base/ipc/ipc.cc create mode 100644 base-host/src/base/lock/lock_helper.h create mode 100644 base-host/src/base/pager/pager.cc create mode 100644 base-host/src/core/context_area.cc create mode 100644 base-host/src/core/core_rm_session.cc create mode 100644 base-host/src/core/include/core_rm_session.h create mode 100644 base-host/src/core/include/platform.h create mode 100644 base-host/src/core/include/platform_pd.h create mode 100644 base-host/src/core/include/platform_thread.h create mode 100644 base-host/src/core/include/util.h create mode 100644 base-host/src/core/io_mem_session_support.cc create mode 100644 base-host/src/core/io_port_session_component.cc create mode 100644 base-host/src/core/irq_session_component.cc create mode 100644 base-host/src/core/platform.cc create mode 100644 base-host/src/core/platform_pd.cc create mode 100644 base-host/src/core/platform_thread.cc create mode 100644 base-host/src/core/ram_session_support.cc create mode 100644 base-host/src/core/rm_session_support.cc create mode 100644 base-host/src/core/target.inc create mode 100644 base-host/src/core/target.mk create mode 100644 base-host/src/core/thread_host.cc create mode 100644 base-host/src/lib/printf_stdio/printf_stdio.cc create mode 100644 base-linux/README create mode 100644 base-linux/etc/specs.conf create mode 100644 base-linux/include/base/ipc_msgbuf.h create mode 100644 base-linux/include/base/local_interface.h create mode 100644 base-linux/include/base/native_types.h create mode 100644 base-linux/include/base/pager.h create mode 100644 base-linux/include/base/platform_env.h create mode 100644 base-linux/include/linux_dataspace/client.h create mode 100644 base-linux/include/linux_dataspace/linux_dataspace.h create mode 100644 base-linux/include/rm_session/client.h create mode 100644 base-linux/lib/import/import-lx_hybrid.mk create mode 100644 base-linux/lib/import/import-syscall.mk create mode 100644 base-linux/lib/mk/core_printf.mk create mode 100644 base-linux/lib/mk/env.mk create mode 100644 base-linux/lib/mk/ipc.mk create mode 100644 base-linux/lib/mk/lock.mk create mode 100644 base-linux/lib/mk/lx_hybrid.mk create mode 100644 base-linux/lib/mk/process.mk create mode 100644 base-linux/lib/mk/rpath.mk create mode 100644 base-linux/lib/mk/thread.mk create mode 100644 base-linux/lib/mk/x86_32/startup.mk create mode 100644 base-linux/lib/mk/x86_32/syscall.mk create mode 100644 base-linux/lib/mk/x86_64/startup.mk create mode 100644 base-linux/lib/mk/x86_64/syscall.mk create mode 100644 base-linux/mk/spec-linux.mk create mode 100644 base-linux/mk/spec-linux_x86_32.mk create mode 100644 base-linux/mk/spec-linux_x86_64.mk create mode 100644 base-linux/run/env create mode 100644 base-linux/run/lx_hybrid_ctors.run create mode 100644 base-linux/run/lx_hybrid_exception.run create mode 100644 base-linux/src/base/console/core_console.h create mode 100644 base-linux/src/base/env/debug.cc create mode 100644 base-linux/src/base/env/platform_env.cc create mode 100644 base-linux/src/base/env/rm_session_mmap.cc create mode 100644 base-linux/src/base/ipc/ipc.cc create mode 100644 base-linux/src/base/lock/lock_helper.h create mode 100644 base-linux/src/base/process/process.cc create mode 100644 base-linux/src/base/thread/thread_linux.cc create mode 100644 base-linux/src/core/context_area.cc create mode 100644 base-linux/src/core/include/cap_session_component.h create mode 100644 base-linux/src/core/include/dataspace_component.h create mode 100644 base-linux/src/core/include/io_mem_session_component.h create mode 100644 base-linux/src/core/include/irq_session_component.h create mode 100644 base-linux/src/core/include/pd_session_component.h create mode 100644 base-linux/src/core/include/platform.h create mode 100644 base-linux/src/core/include/platform_pd.h create mode 100644 base-linux/src/core/include/platform_thread.h create mode 100644 base-linux/src/core/include/rm_session_component.h create mode 100644 base-linux/src/core/io_mem_session_component.cc create mode 100644 base-linux/src/core/io_port_session_component.cc create mode 100644 base-linux/src/core/pd_session_component.cc create mode 100644 base-linux/src/core/platform.cc create mode 100644 base-linux/src/core/platform_thread.cc create mode 100644 base-linux/src/core/ram_session_support.cc create mode 100644 base-linux/src/core/rom_session_component.cc create mode 100644 base-linux/src/core/target.mk create mode 100644 base-linux/src/core/thread_linux.cc create mode 100644 base-linux/src/platform/_main_helper.h create mode 100644 base-linux/src/platform/context_area.nostdlib.ld create mode 100644 base-linux/src/platform/context_area.stdlib.ld create mode 100644 base-linux/src/platform/linux_rpath.cc create mode 100644 base-linux/src/platform/linux_rpath.h create mode 100644 base-linux/src/platform/linux_syscalls.h create mode 100644 base-linux/src/platform/lx_hybrid.cc create mode 100644 base-linux/src/platform/x86_32/crt0.s create mode 100644 base-linux/src/platform/x86_32/lx_clone.S create mode 100644 base-linux/src/platform/x86_32/lx_syscall.S create mode 100644 base-linux/src/platform/x86_64/crt0.s create mode 100644 base-linux/src/platform/x86_64/lx_clone.S create mode 100644 base-linux/src/platform/x86_64/lx_restore_rt.S create mode 100644 base-linux/src/platform/x86_64/lx_syscall.S create mode 100644 base-linux/src/test/lx_hybrid_ctors/main.cc create mode 100644 base-linux/src/test/lx_hybrid_ctors/target.mk create mode 100644 base-linux/src/test/lx_hybrid_ctors/testlib.cc create mode 100644 base-linux/src/test/lx_hybrid_exception/main.cc create mode 100644 base-linux/src/test/lx_hybrid_exception/target.mk create mode 100644 base-linux/src/test/sub_rm/config.h create mode 100644 base-mb/README create mode 100644 base-mb/doc/getting_started.txt create mode 100644 base-mb/doc/microblaze.txt create mode 100755 base-mb/etc/specs.conf create mode 100755 base-mb/etc/tools.conf create mode 100755 base-mb/include/base/ipc_msgbuf.h create mode 100755 base-mb/include/base/ipc_pager.h create mode 100755 base-mb/include/base/native_types.h create mode 100755 base-mb/include/cpu/atomic.h create mode 100755 base-mb/include/cpu/config.h create mode 100755 base-mb/include/kernel/config.h create mode 100755 base-mb/include/kernel/syscalls.h create mode 100755 base-mb/include/kernel/types.h create mode 100644 base-mb/include/xilinx/xps_intc.h create mode 100644 base-mb/include/xilinx/xps_timer.h create mode 100644 base-mb/include/xilinx/xps_uartl.h create mode 100755 base-mb/lib/mk/cxx.mk create mode 100755 base-mb/lib/mk/ipc.mk create mode 100755 base-mb/lib/mk/kernel.inc create mode 100755 base-mb/lib/mk/kernel_core.mk create mode 100755 base-mb/lib/mk/kernel_test.inc create mode 100755 base-mb/lib/mk/lock.mk create mode 100755 base-mb/lib/mk/pager.mk create mode 100644 base-mb/lib/mk/petalogix_s3adsp1800_mmu__atomic_operations.mk create mode 100755 base-mb/lib/mk/petalogix_s3adsp1800_mmu__kernel_support.inc create mode 100755 base-mb/lib/mk/printf_microblaze.mk create mode 100755 base-mb/lib/mk/startup.mk create mode 100755 base-mb/lib/mk/test_env.mk create mode 100644 base-mb/lib/mk/thread.mk create mode 100755 base-mb/lib/mk/thread_context.mk create mode 100644 base-mb/mk/spec-mb_ml507.mk create mode 100644 base-mb/mk/spec-mb_s3a_starter_kit.mk create mode 100644 base-mb/platform/mb_s3a_starter_kit/Makefile create mode 100644 base-mb/platform/mb_s3a_starter_kit/system.bit create mode 100644 base-mb/platform/mk/microblaze.mk create mode 100644 base-mb/platform/mk/ml507.mk create mode 100644 base-mb/platform/mk/s3a_starter_kit.mk create mode 100644 base-mb/platform/mk/xilinx.mk create mode 100755 base-mb/run/env create mode 100755 base-mb/run/hello.run create mode 100755 base-mb/run/nested_init.run create mode 100755 base-mb/src/base/console/microblaze_console.cc create mode 100755 base-mb/src/base/cxx/atexit.cc create mode 100755 base-mb/src/base/ipc/ipc.cc create mode 100755 base-mb/src/base/ipc/pager.cc create mode 100755 base-mb/src/base/lock/lock_helper.h create mode 100644 base-mb/src/base/pager/pager.cc create mode 100644 base-mb/src/base/thread/thread.cc create mode 100755 base-mb/src/base/thread/thread_bootstrap.cc create mode 100755 base-mb/src/base/thread/thread_context.cc create mode 100644 base-mb/src/base/thread/thread_start.cc create mode 100644 base-mb/src/core/context_area.cc create mode 100644 base-mb/src/core/core_rm_session.cc create mode 100644 base-mb/src/core/include/core_rm_session.h create mode 100644 base-mb/src/core/include/cpu/prints.h create mode 100644 base-mb/src/core/include/irq_session_component.h create mode 100644 base-mb/src/core/include/kernel/print.h create mode 100755 base-mb/src/core/include/map_local.h create mode 100755 base-mb/src/core/include/platform.h create mode 100755 base-mb/src/core/include/platform_pd.h create mode 100755 base-mb/src/core/include/platform_thread.h create mode 100755 base-mb/src/core/include/util.h create mode 100644 base-mb/src/core/include/util/array.h create mode 100644 base-mb/src/core/include/util/debug.h create mode 100644 base-mb/src/core/include/util/id_allocator.h create mode 100644 base-mb/src/core/include/util/math.h create mode 100644 base-mb/src/core/include/util/queue.h create mode 100644 base-mb/src/core/include/xilinx/microblaze.h create mode 100755 base-mb/src/core/io_mem_session_support.cc create mode 100755 base-mb/src/core/io_port_session_component.cc create mode 100644 base-mb/src/core/irq_session_component.cc create mode 100644 base-mb/src/core/platform.cc create mode 100755 base-mb/src/core/platform_thread.cc create mode 100755 base-mb/src/core/ram_session_support.cc create mode 100755 base-mb/src/core/rm_session_support.cc create mode 100755 base-mb/src/core/target.inc create mode 100755 base-mb/src/core/target.mk create mode 100755 base-mb/src/core/thread_roottask.cc create mode 100755 base-mb/src/kernel/generic/blocking.cc create mode 100755 base-mb/src/kernel/generic/include/exception.h create mode 100755 base-mb/src/kernel/generic/include/interrupt.h create mode 100755 base-mb/src/kernel/generic/include/thread.h create mode 100755 base-mb/src/kernel/generic/kernel.cc create mode 100755 base-mb/src/kernel/generic/scheduler.cc create mode 100755 base-mb/src/kernel/generic/syscall_events.cc create mode 100755 base-mb/src/kernel/generic/thread.cc create mode 100755 base-mb/src/kernel/include/generic/blocking.h create mode 100755 base-mb/src/kernel/include/generic/event.h create mode 100755 base-mb/src/kernel/include/generic/ipc.h create mode 100755 base-mb/src/kernel/include/generic/irq_controller.h create mode 100755 base-mb/src/kernel/include/generic/printf.h create mode 100755 base-mb/src/kernel/include/generic/scheduler.h create mode 100755 base-mb/src/kernel/include/generic/syscall_events.h create mode 100755 base-mb/src/kernel/include/generic/timer.h create mode 100755 base-mb/src/kernel/include/generic/tlb.h create mode 100755 base-mb/src/kernel/include/generic/verbose.h create mode 100755 base-mb/src/kernel/include/petalogix_s3adsp1800_mmu/platform/platform.h create mode 100755 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/atomic.s create mode 100755 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/crt0.s create mode 100755 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/crt0_kernel.s create mode 100755 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/include/errors.s create mode 100755 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/include/exec_context.s create mode 100644 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/include/linker_commands.s create mode 100755 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/include/special_registers.s create mode 100755 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/kernel_entry.s create mode 100644 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/platform.cc create mode 100755 base-mb/src/kernel/platforms/petalogix_s3adsp1800_mmu/userland_entry.s create mode 100644 base-mb/src/platform/_main_helper.h create mode 100755 base-mb/src/platform/genode.ld create mode 100644 base-mb/src/test/hello/main.cc create mode 100644 base-mb/src/test/hello/target.mk create mode 100644 base-nova/Makefile create mode 100644 base-nova/README create mode 100644 base-nova/doc/nova.txt create mode 100644 base-nova/etc/specs.conf create mode 100644 base-nova/include/base/cap_sel_alloc.h create mode 100644 base-nova/include/base/ipc.h create mode 100644 base-nova/include/base/ipc_msgbuf.h create mode 100644 base-nova/include/base/ipc_pager.h create mode 100644 base-nova/include/base/native_types.h create mode 100644 base-nova/include/base/pager.h create mode 100644 base-nova/include/base/sleep.h create mode 100644 base-nova/include/nova/stdint.h create mode 100644 base-nova/include/nova/syscalls.h create mode 100644 base-nova/include/signal_session/nova_source.h create mode 100644 base-nova/include/signal_session/source_client.h create mode 100644 base-nova/include/signal_session/source_rpc_object.h create mode 100644 base-nova/lib/mk/core_printf.mk create mode 100644 base-nova/lib/mk/env.mk create mode 100644 base-nova/lib/mk/ipc.mk create mode 100644 base-nova/lib/mk/lock.mk create mode 100644 base-nova/lib/mk/pager.mk create mode 100644 base-nova/lib/mk/printf_stdio.mk create mode 100644 base-nova/lib/mk/raw_server.mk create mode 100644 base-nova/lib/mk/server.mk create mode 100644 base-nova/lib/mk/test_env.mk create mode 100644 base-nova/lib/mk/thread.mk create mode 100644 base-nova/lib/mk/thread_context.mk create mode 100644 base-nova/lib/mk/x86_32/startup.mk create mode 100644 base-nova/mk/spec-nova.mk create mode 100644 base-nova/patches/README create mode 100644 base-nova/patches/utcb.patch create mode 100644 base-nova/run/env create mode 100644 base-nova/src/base/console/core_console.h create mode 100644 base-nova/src/base/env/cap_sel_alloc.cc create mode 100644 base-nova/src/base/env/main_thread.cc create mode 100644 base-nova/src/base/ipc/ipc.cc create mode 100644 base-nova/src/base/ipc/pager.cc create mode 100644 base-nova/src/base/lock/lock_helper.h create mode 100644 base-nova/src/base/pager/pager.cc create mode 100644 base-nova/src/base/server/server.cc create mode 100644 base-nova/src/base/thread/thread_context.cc create mode 100644 base-nova/src/base/thread/thread_nova.cc create mode 100644 base-nova/src/core/core_rm_session.cc create mode 100644 base-nova/src/core/echo.cc create mode 100644 base-nova/src/core/include/cap_session_component.h create mode 100644 base-nova/src/core/include/core_rm_session.h create mode 100644 base-nova/src/core/include/echo.h create mode 100644 base-nova/src/core/include/irq_session_component.h create mode 100644 base-nova/src/core/include/map_local.h create mode 100644 base-nova/src/core/include/nova_util.h create mode 100644 base-nova/src/core/include/platform.h create mode 100644 base-nova/src/core/include/platform_pd.h create mode 100644 base-nova/src/core/include/platform_thread.h create mode 100644 base-nova/src/core/include/util.h create mode 100644 base-nova/src/core/io_mem_session_support.cc create mode 100644 base-nova/src/core/irq_session_component.cc create mode 100644 base-nova/src/core/platform.cc create mode 100644 base-nova/src/core/platform_pd.cc create mode 100644 base-nova/src/core/platform_thread.cc create mode 100644 base-nova/src/core/ram_session_support.cc create mode 100644 base-nova/src/core/rm_session_support.cc create mode 100644 base-nova/src/core/signal_source_component.cc create mode 100644 base-nova/src/core/target.inc create mode 100644 base-nova/src/core/target.mk create mode 100644 base-nova/src/core/thread_start.cc create mode 100644 base-nova/src/kernel/target.mk create mode 100644 base-nova/src/lib/printf_stdio/printf_stdio.cc create mode 100644 base-nova/src/platform/_main_helper.h create mode 100644 base-nova/src/platform/_main_parent_cap.h create mode 100644 base-nova/src/platform/roottask.ld create mode 100644 base-okl4/Makefile create mode 100644 base-okl4/README create mode 100644 base-okl4/contrib/generated/README create mode 100644 base-okl4/contrib/generated/x86/asmsyms.h create mode 100644 base-okl4/contrib/generated/x86/kdb_class_helper.h create mode 100644 base-okl4/contrib/generated/x86/ktcb_layout.h create mode 100644 base-okl4/contrib/generated/x86/linker.ld create mode 100644 base-okl4/contrib/generated/x86/macro_sets.cc create mode 100644 base-okl4/contrib/generated/x86/tcb_layout.h create mode 100644 base-okl4/doc/notes.txt create mode 100644 base-okl4/doc/okl4.txt create mode 100644 base-okl4/etc/specs.conf create mode 100644 base-okl4/include/base/ipc_msgbuf.h create mode 100644 base-okl4/include/base/ipc_pager.h create mode 100644 base-okl4/include/base/native_types.h create mode 100644 base-okl4/include/base/thread_state.h create mode 100644 base-okl4/include/okl4_pd_session/client.h create mode 100644 base-okl4/include/okl4_pd_session/connection.h create mode 100644 base-okl4/include/okl4_pd_session/okl4_pd_session.h create mode 100644 base-okl4/lib/mk/bootinfo.mk create mode 100644 base-okl4/lib/mk/core_printf.mk create mode 100644 base-okl4/lib/mk/ipc.mk create mode 100644 base-okl4/lib/mk/kernel.inc create mode 100644 base-okl4/lib/mk/lock.mk create mode 100644 base-okl4/lib/mk/pager.mk create mode 100644 base-okl4/lib/mk/platform.inc create mode 100644 base-okl4/lib/mk/thread.mk create mode 100644 base-okl4/lib/mk/x86/kernel.mk create mode 100644 base-okl4/lib/mk/x86/platform.mk create mode 100644 base-okl4/lib/mk/x86/startup.mk create mode 100644 base-okl4/mk/spec-okl4.mk create mode 100644 base-okl4/mk/spec-okl4_x86.mk create mode 100644 base-okl4/patches/README create mode 100644 base-okl4/patches/char_bit.patch create mode 100644 base-okl4/patches/eabi_build.patch create mode 100644 base-okl4/patches/elfweaver.patch create mode 100644 base-okl4/patches/gcc_4.4.5.patch create mode 100644 base-okl4/patches/gdt_init.patch create mode 100644 base-okl4/patches/kdb_reboot.patch create mode 100644 base-okl4/patches/reply_tid.patch create mode 100644 base-okl4/patches/suspend_resume.patch create mode 100644 base-okl4/patches/syscall_pic.patch create mode 100644 base-okl4/run/env create mode 100644 base-okl4/run/priority.run create mode 100644 base-okl4/src/base/bootinfo/README create mode 100644 base-okl4/src/base/bootinfo/stdint.h create mode 100644 base-okl4/src/base/bootinfo/stdio.h create mode 100644 base-okl4/src/base/console/core_console.h create mode 100644 base-okl4/src/base/ipc/ipc.cc create mode 100644 base-okl4/src/base/ipc/pager.cc create mode 100644 base-okl4/src/base/lock/lock_helper.h create mode 100644 base-okl4/src/base/pager/pager.cc create mode 100644 base-okl4/src/base/thread/thread_bootstrap.cc create mode 100644 base-okl4/src/core/core_rm_session.cc create mode 100644 base-okl4/src/core/include/core_rm_session.h create mode 100644 base-okl4/src/core/include/map_local.h create mode 100644 base-okl4/src/core/include/pd_session_component.h create mode 100644 base-okl4/src/core/include/platform.h create mode 100644 base-okl4/src/core/include/platform_pd.h create mode 100644 base-okl4/src/core/include/platform_thread.h create mode 100644 base-okl4/src/core/include/stdint.h create mode 100644 base-okl4/src/core/include/util.h create mode 100644 base-okl4/src/core/io_mem_session_support.cc create mode 100644 base-okl4/src/core/irq_session_component.cc create mode 100644 base-okl4/src/core/okl4_pd_session_component.cc create mode 100644 base-okl4/src/core/platform.cc create mode 100644 base-okl4/src/core/platform_pd.cc create mode 100644 base-okl4/src/core/platform_thread.cc create mode 100644 base-okl4/src/core/ram_session_support.cc create mode 100644 base-okl4/src/core/rm_session_support.cc create mode 100644 base-okl4/src/core/target.inc create mode 100644 base-okl4/src/core/thread_start.cc create mode 100644 base-okl4/src/core/x86/platform_thread_x86.cc create mode 100644 base-okl4/src/core/x86/target.mk create mode 100644 base-okl4/src/kernel/target.inc create mode 100644 base-okl4/src/kernel/x86/target.mk create mode 100644 base-okl4/src/platform/_main_helper.h create mode 100644 base-okl4/src/test/create_thread.h create mode 100644 base-okl4/src/test/io_port.h create mode 100644 base-okl4/src/test/mini_env.h create mode 100644 base-okl4/src/test/okl4_01_hello_raw/Makefile create mode 100644 base-okl4/src/test/okl4_01_hello_raw/crt0.s create mode 100644 base-okl4/src/test/okl4_01_hello_raw/genode.ld create mode 100644 base-okl4/src/test/okl4_01_hello_raw/hello.cc create mode 100644 base-okl4/src/test/okl4_01_hello_raw/weaver.xml create mode 100644 base-okl4/src/test/okl4_02_hello/hello.cc create mode 100644 base-okl4/src/test/okl4_02_hello/target.mk create mode 100644 base-okl4/src/test/okl4_03_thread/main.cc create mode 100644 base-okl4/src/test/okl4_03_thread/target.mk create mode 100644 base-okl4/src/test/okl4_04_ipc_send_wait/main.cc create mode 100644 base-okl4/src/test/okl4_04_ipc_send_wait/target.mk create mode 100644 base-okl4/src/test/okl4_05_ipc_call/main.cc create mode 100644 base-okl4/src/test/okl4_05_ipc_call/target.mk create mode 100644 base-okl4/src/test/okl4_06_pager/main.cc create mode 100644 base-okl4/src/test/okl4_06_pager/target.mk create mode 100644 base-okl4/src/test/okl4_07_boot_info/main.cc create mode 100644 base-okl4/src/test/okl4_07_boot_info/stdint.h create mode 100644 base-okl4/src/test/okl4_07_boot_info/target.mk create mode 100644 base-okl4/src/test/okl4_08_timer_pit/main.cc create mode 100644 base-okl4/src/test/okl4_08_timer_pit/target.mk create mode 100644 base-okl4/tool/README create mode 100644 base-okl4/tool/weaver_x86.xml create mode 100644 base-pistachio/Makefile create mode 100644 base-pistachio/README create mode 100644 base-pistachio/config/kernel create mode 100644 base-pistachio/doc/pistachio.txt create mode 100644 base-pistachio/etc/specs.conf create mode 100644 base-pistachio/include/base/clock.h create mode 100644 base-pistachio/include/base/ipc_msgbuf.h create mode 100644 base-pistachio/include/base/ipc_pager.h create mode 100644 base-pistachio/include/base/native_types.h create mode 100644 base-pistachio/include/pistachio/kip.h create mode 100644 base-pistachio/include/pistachio/thread_helper.h create mode 100644 base-pistachio/include/util/hexdump.h create mode 100644 base-pistachio/include/x86/cpu/rdtsc.h create mode 100644 base-pistachio/include/x86/util/smath.h create mode 100644 base-pistachio/lib/mk/core_printf.mk create mode 100644 base-pistachio/lib/mk/hexdump.mk create mode 100644 base-pistachio/lib/mk/ipc.mk create mode 100644 base-pistachio/lib/mk/kip.mk create mode 100644 base-pistachio/lib/mk/l4.mk create mode 100644 base-pistachio/lib/mk/lock.mk create mode 100644 base-pistachio/lib/mk/pager.mk create mode 100644 base-pistachio/lib/mk/platform.mk create mode 100644 base-pistachio/lib/mk/x86/startup.mk create mode 100644 base-pistachio/mk/spec-pistachio.mk create mode 100644 base-pistachio/mk/spec-pistachio_x86.mk create mode 100644 base-pistachio/patches/README create mode 100644 base-pistachio/patches/syscalls_ia32.patch create mode 100644 base-pistachio/run/env create mode 100644 base-pistachio/src/base/console/core_console.h create mode 100644 base-pistachio/src/base/ipc/ipc.cc create mode 100644 base-pistachio/src/base/ipc/pager.cc create mode 100644 base-pistachio/src/base/kip/kip.cc create mode 100644 base-pistachio/src/base/lock/lock_helper.h create mode 100644 base-pistachio/src/base/pager/pager.cc create mode 100644 base-pistachio/src/core/cpu_session_platform.cc create mode 100644 base-pistachio/src/core/include/map_local.h create mode 100644 base-pistachio/src/core/include/platform.h create mode 100644 base-pistachio/src/core/include/platform_pd.h create mode 100644 base-pistachio/src/core/include/platform_thread.h create mode 100644 base-pistachio/src/core/include/util.h create mode 100644 base-pistachio/src/core/io_mem_session_support.cc create mode 100644 base-pistachio/src/core/irq_session_component.cc create mode 100644 base-pistachio/src/core/multiboot_info.cc create mode 100644 base-pistachio/src/core/platform.cc create mode 100644 base-pistachio/src/core/platform_pd.cc create mode 100644 base-pistachio/src/core/platform_thread.cc create mode 100644 base-pistachio/src/core/ram_session_support.cc create mode 100644 base-pistachio/src/core/rm_session_support.cc create mode 100644 base-pistachio/src/core/target.inc create mode 100644 base-pistachio/src/core/thread_start.cc create mode 100644 base-pistachio/src/core/x86/platform_x86.cc create mode 100644 base-pistachio/src/core/x86/target.mk create mode 100644 base-pistachio/src/kernel/target.mk create mode 100644 base-pistachio/src/platform/_main_helper.h create mode 100644 base-pistachio/src/util/hexdump/hexdump.cc create mode 100644 base/README create mode 100644 base/etc/README create mode 100644 base/etc/tools.conf create mode 100644 base/include/32bit/base/fixed_stdint.h create mode 100644 base/include/64bit/base/fixed_stdint.h create mode 100644 base/include/README create mode 100644 base/include/arm/cpu/cpu_state.h create mode 100644 base/include/base/allocator.h create mode 100644 base/include/base/allocator_avl.h create mode 100644 base/include/base/allocator_guard.h create mode 100644 base/include/base/blocking.h create mode 100644 base/include/base/cancelable_lock.h create mode 100644 base/include/base/capability.h create mode 100644 base/include/base/child.h create mode 100644 base/include/base/connection.h create mode 100644 base/include/base/console.h create mode 100644 base/include/base/cpu_state.h create mode 100644 base/include/base/crt0.h create mode 100644 base/include/base/elf.h create mode 100644 base/include/base/env.h create mode 100644 base/include/base/errno.h create mode 100644 base/include/base/exception.h create mode 100644 base/include/base/heap.h create mode 100644 base/include/base/ipc.h create mode 100644 base/include/base/ipc_generic.h create mode 100644 base/include/base/lock.h create mode 100644 base/include/base/lock_guard.h create mode 100644 base/include/base/object_pool.h create mode 100644 base/include/base/pager.h create mode 100644 base/include/base/platform_env.h create mode 100644 base/include/base/printf.h create mode 100644 base/include/base/process.h create mode 100644 base/include/base/rpc.h create mode 100644 base/include/base/rpc_args.h create mode 100644 base/include/base/rpc_client.h create mode 100644 base/include/base/rpc_server.h create mode 100644 base/include/base/semaphore.h create mode 100644 base/include/base/service.h create mode 100644 base/include/base/signal.h create mode 100644 base/include/base/slab.h create mode 100644 base/include/base/sleep.h create mode 100644 base/include/base/snprintf.h create mode 100644 base/include/base/stdint.h create mode 100644 base/include/base/sync_allocator.h create mode 100644 base/include/base/thread.h create mode 100644 base/include/base/thread_state.h create mode 100644 base/include/base/tslab.h create mode 100644 base/include/cap_session/cap_session.h create mode 100644 base/include/cap_session/capability.h create mode 100644 base/include/cap_session/client.h create mode 100644 base/include/cap_session/connection.h create mode 100644 base/include/cpu_session/capability.h create mode 100644 base/include/cpu_session/client.h create mode 100644 base/include/cpu_session/connection.h create mode 100644 base/include/cpu_session/cpu_session.h create mode 100644 base/include/dataspace/capability.h create mode 100644 base/include/dataspace/client.h create mode 100644 base/include/dataspace/dataspace.h create mode 100644 base/include/io_mem_session/capability.h create mode 100644 base/include/io_mem_session/client.h create mode 100644 base/include/io_mem_session/connection.h create mode 100644 base/include/io_mem_session/io_mem_session.h create mode 100644 base/include/io_port_session/capability.h create mode 100644 base/include/io_port_session/client.h create mode 100644 base/include/io_port_session/connection.h create mode 100644 base/include/io_port_session/io_port_session.h create mode 100644 base/include/irq_session/capability.h create mode 100644 base/include/irq_session/client.h create mode 100644 base/include/irq_session/connection.h create mode 100644 base/include/irq_session/irq_session.h create mode 100644 base/include/log_session/capability.h create mode 100644 base/include/log_session/client.h create mode 100644 base/include/log_session/connection.h create mode 100644 base/include/log_session/log_session.h create mode 100644 base/include/pager/capability.h create mode 100644 base/include/parent/capability.h create mode 100644 base/include/parent/client.h create mode 100644 base/include/parent/parent.h create mode 100644 base/include/pd_session/capability.h create mode 100644 base/include/pd_session/client.h create mode 100644 base/include/pd_session/connection.h create mode 100644 base/include/pd_session/pd_session.h create mode 100644 base/include/ram_session/capability.h create mode 100644 base/include/ram_session/client.h create mode 100644 base/include/ram_session/connection.h create mode 100644 base/include/ram_session/ram_session.h create mode 100644 base/include/rm_session/capability.h create mode 100644 base/include/rm_session/client.h create mode 100644 base/include/rm_session/connection.h create mode 100644 base/include/rm_session/rm_session.h create mode 100644 base/include/rom_session/capability.h create mode 100644 base/include/rom_session/client.h create mode 100644 base/include/rom_session/connection.h create mode 100644 base/include/rom_session/rom_session.h create mode 100644 base/include/root/capability.h create mode 100644 base/include/root/client.h create mode 100644 base/include/root/component.h create mode 100644 base/include/root/root.h create mode 100644 base/include/session/capability.h create mode 100644 base/include/session/session.h create mode 100644 base/include/signal_session/capability.h create mode 100644 base/include/signal_session/client.h create mode 100644 base/include/signal_session/connection.h create mode 100644 base/include/signal_session/signal_session.h create mode 100644 base/include/signal_session/source.h create mode 100644 base/include/signal_session/source_client.h create mode 100644 base/include/signal_session/source_rpc_object.h create mode 100644 base/include/thread/capability.h create mode 100644 base/include/util/arg_string.h create mode 100644 base/include/util/avl_string.h create mode 100644 base/include/util/avl_tree.h create mode 100644 base/include/util/fifo.h create mode 100644 base/include/util/list.h create mode 100644 base/include/util/meta.h create mode 100644 base/include/util/misc_math.h create mode 100644 base/include/util/string.h create mode 100644 base/include/util/token.h create mode 100644 base/include/util/touch.h create mode 100644 base/include/x86/cpu/atomic.h create mode 100644 base/include/x86/cpu/consts.h create mode 100644 base/include/x86_32/cpu/cpu_state.h create mode 100644 base/include/x86_64/cpu/cpu_state.h create mode 100644 base/lib/README create mode 100644 base/lib/import/import-stdcxx.mk create mode 100644 base/lib/mk/README create mode 100644 base/lib/mk/allocator_avl.mk create mode 100644 base/lib/mk/avl_tree.mk create mode 100644 base/lib/mk/console.mk create mode 100644 base/lib/mk/cxx.mk create mode 100644 base/lib/mk/elf.mk create mode 100644 base/lib/mk/env.mk create mode 100644 base/lib/mk/heap.mk create mode 100644 base/lib/mk/host/cxx.mk create mode 100644 base/lib/mk/log_console.mk create mode 100644 base/lib/mk/platform.mk create mode 100644 base/lib/mk/process.mk create mode 100644 base/lib/mk/raw_server.mk create mode 100644 base/lib/mk/raw_signal.mk create mode 100644 base/lib/mk/server.mk create mode 100644 base/lib/mk/signal.mk create mode 100644 base/lib/mk/slab.mk create mode 100644 base/lib/mk/stdcxx.mk create mode 100644 base/lib/mk/thread.mk create mode 100644 base/mk/README create mode 100644 base/mk/base-libs.mk create mode 100644 base/mk/dep_lib.mk create mode 100644 base/mk/dep_prg.mk create mode 100644 base/mk/generic.mk create mode 100644 base/mk/global.mk create mode 100644 base/mk/lib.mk create mode 100644 base/mk/prg.mk create mode 100644 base/mk/spec-32bit.mk create mode 100644 base/mk/spec-64bit.mk create mode 100644 base/mk/spec-arm.mk create mode 100644 base/mk/spec-arm_v5.mk create mode 100644 base/mk/spec-arm_v7a.mk create mode 100644 base/mk/spec-experimental.mk create mode 100644 base/mk/spec-host.mk create mode 100644 base/mk/spec-platform_pbxa9.mk create mode 100644 base/mk/spec-platform_vea9x4.mk create mode 100644 base/mk/spec-platform_vpb926.mk create mode 100644 base/mk/spec-release.mk create mode 100644 base/mk/spec-x86_32.mk create mode 100644 base/mk/spec-x86_64.mk create mode 100644 base/run/rm_fault.run create mode 100644 base/run/sub_rm.run create mode 100644 base/src/README create mode 100644 base/src/base/README create mode 100644 base/src/base/allocator/README create mode 100644 base/src/base/allocator/allocator_avl.cc create mode 100644 base/src/base/allocator/slab.cc create mode 100644 base/src/base/avl_tree/avl_tree.cc create mode 100644 base/src/base/console/console.cc create mode 100644 base/src/base/console/core_printf.cc create mode 100644 base/src/base/console/log_console.cc create mode 100644 base/src/base/cxx/exception.cc create mode 100644 base/src/base/cxx/guard.cc create mode 100644 base/src/base/cxx/malloc_free.cc create mode 100644 base/src/base/cxx/misc.cc create mode 100644 base/src/base/cxx/new_delete.cc create mode 100644 base/src/base/cxx/unwind.cc create mode 100644 base/src/base/elf/elf.h create mode 100644 base/src/base/elf/elf_binary.cc create mode 100644 base/src/base/env/context_area.cc create mode 100644 base/src/base/env/env.cc create mode 100644 base/src/base/heap/heap.cc create mode 100644 base/src/base/heap/sliced_heap.cc create mode 100644 base/src/base/lock/lock.cc create mode 100644 base/src/base/process/process.cc create mode 100644 base/src/base/server/common.cc create mode 100644 base/src/base/server/server.cc create mode 100644 base/src/base/signal/signal.cc create mode 100644 base/src/base/thread/thread.cc create mode 100644 base/src/base/thread/thread_bootstrap.cc create mode 100644 base/src/base/thread/thread_start.cc create mode 100644 base/src/core/arm/io_port_session_component.cc create mode 100644 base/src/core/context_area.cc create mode 100644 base/src/core/core_mem_alloc.cc create mode 100644 base/src/core/cpu_session_component.cc create mode 100644 base/src/core/dataspace_component.cc create mode 100644 base/src/core/dump_alloc.cc create mode 100644 base/src/core/include/cap_root.h create mode 100644 base/src/core/include/cap_session_component.h create mode 100644 base/src/core/include/core_env.h create mode 100644 base/src/core/include/core_mem_alloc.h create mode 100644 base/src/core/include/core_parent.h create mode 100644 base/src/core/include/core_rm_session.h create mode 100644 base/src/core/include/cpu_root.h create mode 100644 base/src/core/include/cpu_session_component.h create mode 100644 base/src/core/include/dataspace_component.h create mode 100644 base/src/core/include/io_mem_root.h create mode 100644 base/src/core/include/io_mem_session_component.h create mode 100644 base/src/core/include/io_port_root.h create mode 100644 base/src/core/include/io_port_session_component.h create mode 100644 base/src/core/include/irq_root.h create mode 100644 base/src/core/include/irq_session_component.h create mode 100644 base/src/core/include/log_root.h create mode 100644 base/src/core/include/log_session_component.h create mode 100644 base/src/core/include/multiboot.h create mode 100644 base/src/core/include/pd_root.h create mode 100644 base/src/core/include/pd_session_component.h create mode 100644 base/src/core/include/platform_generic.h create mode 100644 base/src/core/include/ram_root.h create mode 100644 base/src/core/include/ram_session_component.h create mode 100644 base/src/core/include/rm_root.h create mode 100644 base/src/core/include/rm_session_component.h create mode 100644 base/src/core/include/rom_fs.h create mode 100644 base/src/core/include/rom_root.h create mode 100644 base/src/core/include/rom_session_component.h create mode 100644 base/src/core/include/signal_root.h create mode 100644 base/src/core/include/signal_session_component.h create mode 100644 base/src/core/io_mem_session_component.cc create mode 100644 base/src/core/main.cc create mode 100644 base/src/core/mb_info.h create mode 100644 base/src/core/multiboot_info.cc create mode 100644 base/src/core/pd_session_component.cc create mode 100644 base/src/core/ram_session_component.cc create mode 100644 base/src/core/rm_session_component.cc create mode 100644 base/src/core/rom_session_component.cc create mode 100644 base/src/core/signal_session_component.cc create mode 100644 base/src/core/signal_source_component.cc create mode 100644 base/src/core/x86/io_port_session_component.cc create mode 100644 base/src/platform/_main.cc create mode 100644 base/src/platform/_main_parent_cap.h create mode 100644 base/src/platform/arm/crt0.s create mode 100644 base/src/platform/genode.ld create mode 100644 base/src/platform/x86_32/crt0.s create mode 100644 base/src/platform/x86_64/crt0.s create mode 100644 base/src/test/rm_fault/main.cc create mode 100644 base/src/test/rm_fault/target.mk create mode 100644 base/src/test/rm_nested/main.cc create mode 100644 base/src/test/rm_nested/target.mk create mode 100644 base/src/test/sub_rm/config.h create mode 100644 base/src/test/sub_rm/main.cc create mode 100644 base/src/test/sub_rm/target.mk create mode 100644 dde_ipxe/Makefile create mode 100644 dde_ipxe/README create mode 100644 dde_ipxe/include/dde_ipxe/nic.h create mode 100644 dde_ipxe/lib/mk/dde_ipxe_nic.mk create mode 100644 dde_ipxe/lib/mk/dde_ipxe_support.mk create mode 100644 dde_ipxe/patches/dde_ipxe.patch create mode 100644 dde_ipxe/src/drivers/nic/main.cc create mode 100644 dde_ipxe/src/drivers/nic/target.mk create mode 100644 dde_ipxe/src/lib/dde_ipxe/dde.c create mode 100644 dde_ipxe/src/lib/dde_ipxe/dde_support.cc create mode 100644 dde_ipxe/src/lib/dde_ipxe/dummies.c create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/byteswap.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/compiler.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/cpu.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/eltorito.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/endian.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/errfile.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/io.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/nap.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/pci_io.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/smbios.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/stdint.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/string.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/timer.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/uaccess.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/bits/umalloc.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/config/local/console.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/config/local/general.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/config/local/ioapi.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/config/local/nap.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/config/local/serial.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/config/local/timer.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/config/local/umalloc.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/include/env_dde_kit.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/local.h create mode 100644 dde_ipxe/src/lib/dde_ipxe/nic.c create mode 100644 demo/doc/demo.txt create mode 100644 demo/doc/img/genode_logo.png create mode 100644 demo/doc/img/launchpad.png create mode 100644 demo/doc/img/liquid_fb.png create mode 100644 demo/doc/img/liquid_fb_small.png create mode 100644 demo/doc/img/setup.png create mode 100644 demo/doc/img/x-ray.png create mode 100644 demo/doc/img/x-ray_small.png create mode 100644 demo/include/launchpad/launchpad.h create mode 100644 demo/include/libpng_static/png.h create mode 100644 demo/include/libpng_static/pngconf.h create mode 100644 demo/include/libpng_static/pngusr.h create mode 100644 demo/include/libz_static/zconf.h create mode 100644 demo/include/libz_static/zlib.h create mode 100644 demo/include/mini_c/errno.h create mode 100644 demo/include/mini_c/limits.h create mode 100644 demo/include/mini_c/stdio.h create mode 100644 demo/include/mini_c/stdlib.h create mode 100644 demo/include/mini_c/string.h create mode 100644 demo/include/mini_c/sys/types.h create mode 100644 demo/lib/import/import-libpng_static.mk create mode 100644 demo/lib/import/import-libz_static.mk create mode 100644 demo/lib/import/import-mini_c.mk create mode 100644 demo/lib/mk/launchpad.mk create mode 100644 demo/lib/mk/libpng_static.mk create mode 100644 demo/lib/mk/libz_static.mk create mode 100644 demo/lib/mk/mini_c.mk create mode 100644 demo/lib/mk/scout_widgets.mk create mode 100644 demo/src/app/backdrop/README create mode 100644 demo/src/app/backdrop/main.cc create mode 100644 demo/src/app/backdrop/target.mk create mode 100644 demo/src/app/launchpad/README create mode 100644 demo/src/app/launchpad/child_entry.h create mode 100644 demo/src/app/launchpad/launch_entry.h create mode 100644 demo/src/app/launchpad/launcher.cc create mode 100644 demo/src/app/launchpad/launchpad_window.cc create mode 100644 demo/src/app/launchpad/launchpad_window.h create mode 100644 demo/src/app/launchpad/loadbar.h create mode 100644 demo/src/app/launchpad/main.cc create mode 100644 demo/src/app/launchpad/section.h create mode 100644 demo/src/app/launchpad/status_entry.h create mode 100644 demo/src/app/launchpad/target.mk create mode 100644 demo/src/app/scout/common/about.cc create mode 100644 demo/src/app/scout/common/browser_window.cc create mode 100644 demo/src/app/scout/common/doc.cc create mode 100644 demo/src/app/scout/common/elements.cc create mode 100644 demo/src/app/scout/common/main.cc create mode 100644 demo/src/app/scout/common/navbar.cc create mode 100644 demo/src/app/scout/common/png_image.cc create mode 100644 demo/src/app/scout/common/refracted_icon.cc create mode 100644 demo/src/app/scout/common/scrollbar.cc create mode 100644 demo/src/app/scout/common/sky_texture.cc create mode 100644 demo/src/app/scout/common/test.txt create mode 100644 demo/src/app/scout/common/tick.cc create mode 100644 demo/src/app/scout/common/widgets.cc create mode 100644 demo/src/app/scout/data/about.rgba create mode 100644 demo/src/app/scout/data/backward.rgba create mode 100644 demo/src/app/scout/data/closed_icon.rgba create mode 100644 demo/src/app/scout/data/cover.rgba create mode 100644 demo/src/app/scout/data/downarrow.rgba create mode 100644 demo/src/app/scout/data/forward.rgba create mode 100644 demo/src/app/scout/data/home.rgba create mode 100644 demo/src/app/scout/data/index.rgba create mode 100644 demo/src/app/scout/data/ior.map create mode 100644 demo/src/app/scout/data/kill_icon.rgba create mode 100644 demo/src/app/scout/data/loadbar.rgba create mode 100644 demo/src/app/scout/data/mono16.tff create mode 100644 demo/src/app/scout/data/nav_next.rgba create mode 100644 demo/src/app/scout/data/nav_prev.rgba create mode 100644 demo/src/app/scout/data/opened_icon.rgba create mode 100644 demo/src/app/scout/data/pointer.rgba create mode 100644 demo/src/app/scout/data/redbar.rgba create mode 100644 demo/src/app/scout/data/sizer.rgba create mode 100644 demo/src/app/scout/data/slider.rgba create mode 100644 demo/src/app/scout/data/test.png create mode 100644 demo/src/app/scout/data/titlebar.rgba create mode 100644 demo/src/app/scout/data/uparrow.rgba create mode 100644 demo/src/app/scout/data/vera16.tff create mode 100644 demo/src/app/scout/data/vera18.tff create mode 100644 demo/src/app/scout/data/vera20.tff create mode 100644 demo/src/app/scout/data/vera22.tff create mode 100644 demo/src/app/scout/data/vera24.tff create mode 100644 demo/src/app/scout/data/verabi10.tff create mode 100644 demo/src/app/scout/data/verai16.tff create mode 100644 demo/src/app/scout/data/whitebar.rgba create mode 100644 demo/src/app/scout/genode/launcher.cc create mode 100644 demo/src/app/scout/genode/platform_genode.cc create mode 100644 demo/src/app/scout/genode/startup.cc create mode 100644 demo/src/app/scout/genode/target.mk create mode 100644 demo/src/app/scout/include/browser.h create mode 100644 demo/src/app/scout/include/browser_window.h create mode 100644 demo/src/app/scout/include/canvas.h create mode 100644 demo/src/app/scout/include/canvas_rgb565.h create mode 100644 demo/src/app/scout/include/color.h create mode 100644 demo/src/app/scout/include/config.h create mode 100644 demo/src/app/scout/include/elements.h create mode 100644 demo/src/app/scout/include/event.h create mode 100644 demo/src/app/scout/include/fade_icon.h create mode 100644 demo/src/app/scout/include/fader.h create mode 100644 demo/src/app/scout/include/font.h create mode 100644 demo/src/app/scout/include/genode/alloc.h create mode 100644 demo/src/app/scout/include/genode/launcher_config.h create mode 100644 demo/src/app/scout/include/genode/printf.h create mode 100644 demo/src/app/scout/include/genode/string.h create mode 100644 demo/src/app/scout/include/history.h create mode 100644 demo/src/app/scout/include/miscmath.h create mode 100644 demo/src/app/scout/include/platform.h create mode 100644 demo/src/app/scout/include/redraw_manager.h create mode 100644 demo/src/app/scout/include/refracted_icon.h create mode 100644 demo/src/app/scout/include/scout_types.h create mode 100644 demo/src/app/scout/include/scrollbar.h create mode 100644 demo/src/app/scout/include/sky_texture.h create mode 100644 demo/src/app/scout/include/styles.h create mode 100644 demo/src/app/scout/include/tick.h create mode 100644 demo/src/app/scout/include/titlebar.h create mode 100644 demo/src/app/scout/include/user_state.h create mode 100644 demo/src/app/scout/include/widgets.h create mode 100644 demo/src/app/scout/include/window.h create mode 100644 demo/src/lib/launchpad/launchpad.cc create mode 100644 demo/src/lib/libpng/contrib/png.c create mode 100644 demo/src/lib/libpng/contrib/pngerror.c create mode 100644 demo/src/lib/libpng/contrib/pngget.c create mode 100644 demo/src/lib/libpng/contrib/pngmem.c create mode 100644 demo/src/lib/libpng/contrib/pngpread.c create mode 100644 demo/src/lib/libpng/contrib/pngread.c create mode 100644 demo/src/lib/libpng/contrib/pngrio.c create mode 100644 demo/src/lib/libpng/contrib/pngrtran.c create mode 100644 demo/src/lib/libpng/contrib/pngrutil.c create mode 100644 demo/src/lib/libpng/contrib/pngset.c create mode 100644 demo/src/lib/libpng/contrib/pngtrans.c create mode 100644 demo/src/lib/libpng/contrib/pngwio.c create mode 100644 demo/src/lib/libpng/contrib/pngwrite.c create mode 100644 demo/src/lib/libpng/contrib/pngwtran.c create mode 100644 demo/src/lib/libpng/contrib/pngwutil.c create mode 100644 demo/src/lib/libpng/main.cc create mode 100644 demo/src/lib/libpng/stdio.h create mode 100644 demo/src/lib/libpng/target.mk create mode 100644 demo/src/lib/libz/contrib/adler32.c create mode 100644 demo/src/lib/libz/contrib/compress.c create mode 100644 demo/src/lib/libz/contrib/crc32.c create mode 100644 demo/src/lib/libz/contrib/crc32.h create mode 100644 demo/src/lib/libz/contrib/deflate.c create mode 100644 demo/src/lib/libz/contrib/deflate.h create mode 100644 demo/src/lib/libz/contrib/gzio.c create mode 100644 demo/src/lib/libz/contrib/infback.c create mode 100644 demo/src/lib/libz/contrib/inffast.c create mode 100644 demo/src/lib/libz/contrib/inffast.h create mode 100644 demo/src/lib/libz/contrib/inffixed.h create mode 100644 demo/src/lib/libz/contrib/inflate.c create mode 100644 demo/src/lib/libz/contrib/inflate.h create mode 100644 demo/src/lib/libz/contrib/inftrees.c create mode 100644 demo/src/lib/libz/contrib/inftrees.h create mode 100644 demo/src/lib/libz/contrib/trees.c create mode 100644 demo/src/lib/libz/contrib/trees.h create mode 100644 demo/src/lib/libz/contrib/uncompr.c create mode 100644 demo/src/lib/libz/contrib/zutil.c create mode 100644 demo/src/lib/libz/contrib/zutil.h create mode 100644 demo/src/lib/mini_c/README create mode 100644 demo/src/lib/mini_c/abort.cc create mode 100644 demo/src/lib/mini_c/atol.cc create mode 100644 demo/src/lib/mini_c/malloc_free.cc create mode 100644 demo/src/lib/mini_c/memcmp.cc create mode 100644 demo/src/lib/mini_c/memset.cc create mode 100644 demo/src/lib/mini_c/mini_c.c create mode 100644 demo/src/lib/mini_c/printf.cc create mode 100644 demo/src/lib/mini_c/snprintf.cc create mode 100644 demo/src/lib/mini_c/strlen.cc create mode 100644 demo/src/lib/mini_c/strtod.cc create mode 100644 demo/src/lib/mini_c/strtol.cc create mode 100644 demo/src/lib/mini_c/vsnprintf.cc create mode 100644 demo/src/server/liquid_framebuffer/README create mode 100644 demo/src/server/liquid_framebuffer/framebuffer_window.h create mode 100644 demo/src/server/liquid_framebuffer/main.cc create mode 100644 demo/src/server/liquid_framebuffer/services.cc create mode 100644 demo/src/server/liquid_framebuffer/services.h create mode 100644 demo/src/server/liquid_framebuffer/target.mk create mode 100644 demo/src/server/nitlog/main.cc create mode 100644 demo/src/server/nitlog/mono.tff create mode 100644 demo/src/server/nitlog/target.mk create mode 100644 doc/Makefile create mode 100644 doc/build_system.txt create mode 100644 doc/coding_style.txt create mode 100644 doc/components.txt create mode 100644 doc/conventions.txt create mode 100644 doc/future_optimizations.txt create mode 100644 doc/getting_started.txt create mode 100644 doc/release_notes-08-11.txt create mode 100644 doc/release_notes-09-02.txt create mode 100644 doc/release_notes-09-05.txt create mode 100644 doc/release_notes-09-08.txt create mode 100644 doc/release_notes-09-11.txt create mode 100644 doc/release_notes-10-02.txt create mode 100644 doc/release_notes-10-05.txt create mode 100644 doc/release_notes-10-08.txt create mode 100644 doc/release_notes-10-11.txt create mode 100644 doc/release_notes-11-02.txt create mode 100644 doc/release_notes-11-05.txt create mode 100644 doc/release_notes-11-08.txt create mode 100644 doc/release_notes-11-11.txt create mode 100644 gems/README create mode 100644 gems/include/terminal/character_screen.h create mode 100644 gems/include/terminal/character_screen_tracer.h create mode 100644 gems/include/terminal/decoder.h create mode 100644 gems/include/terminal/types.h create mode 100644 gems/run/tcp_terminal.run create mode 100644 gems/run/terminal_decoder.run create mode 100644 gems/run/terminal_echo.run create mode 100644 gems/src/server/http_block/README create mode 100644 gems/src/server/http_block/http.cc create mode 100644 gems/src/server/http_block/http.h create mode 100644 gems/src/server/http_block/main.cc create mode 100644 gems/src/server/http_block/target.mk create mode 100644 gems/src/server/tcp_terminal/README create mode 100644 gems/src/server/tcp_terminal/main.cc create mode 100644 gems/src/server/tcp_terminal/target.mk create mode 100644 gems/src/server/terminal/main.cc create mode 100644 gems/src/server/terminal/mono.tff create mode 100644 gems/src/server/terminal/target.mk create mode 100644 gems/src/test/terminal_decoder/main.cc create mode 100644 gems/src/test/terminal_decoder/target.mk create mode 100644 gems/src/test/terminal_decoder/vim.vt create mode 100644 hello_tutorial/README create mode 100644 hello_tutorial/config/config create mode 100644 hello_tutorial/doc/hello_tutorial.txt create mode 100644 hello_tutorial/include/hello_session/client.h create mode 100644 hello_tutorial/include/hello_session/connection.h create mode 100644 hello_tutorial/include/hello_session/hello_session.h create mode 100644 hello_tutorial/run/hello.run create mode 100644 hello_tutorial/src/hello/client/main.cc create mode 100644 hello_tutorial/src/hello/client/target.mk create mode 100644 hello_tutorial/src/hello/server/main.cc create mode 100644 hello_tutorial/src/hello/server/target.mk create mode 100644 libports/Makefile create mode 100644 libports/README create mode 100644 libports/doc/libc.txt create mode 100644 libports/include/EGL/eglplatform.h create mode 100644 libports/include/freetype-genode/ftconfig.h create mode 100644 libports/include/freetype-genode/ftmodule.h create mode 100644 libports/include/gcc/README create mode 100644 libports/include/gcc/longlong.h create mode 100644 libports/include/gmp/config.h create mode 100644 libports/include/gmp/x86_32/fac_ui.h create mode 100644 libports/include/gmp/x86_32/fib_table.h create mode 100644 libports/include/gmp/x86_32/gmp.h create mode 100644 libports/include/gmp/x86_32/mp_bases.h create mode 100644 libports/include/gmp/x86_32/perfsqr.h create mode 100644 libports/include/jpeg/jconfig.h create mode 100644 libports/include/libc-genode/mntent.h create mode 100644 libports/include/libc-genode/sys/syscall.h create mode 100644 libports/include/libc-genode/timeconv.h create mode 100644 libports/include/libc-plugin/fd_alloc.h create mode 100644 libports/include/libc-plugin/plugin.h create mode 100644 libports/include/libc-plugin/plugin_registry.h create mode 100644 libports/include/lwip/arch/cc.h create mode 100644 libports/include/lwip/arch/perf.h create mode 100644 libports/include/lwip/arch/sys_arch.h create mode 100644 libports/include/lwip/genode.h create mode 100644 libports/include/lwip/lwipopts.h create mode 100644 libports/include/ncurses/ncurses_cfg.h create mode 100644 libports/include/python/osreldate.h create mode 100644 libports/include/python/pyconfig.h create mode 100644 libports/include/python/x86_32/genode_defs.h create mode 100644 libports/include/python/x86_64/genode_defs.h create mode 100644 libports/include/readline/config.h create mode 100644 libports/lib/import/import-gmp.mk create mode 100644 libports/lib/import/import-jpeg.mk create mode 100644 libports/lib/import/import-libc.mk create mode 100644 libports/lib/import/import-libpng.mk create mode 100644 libports/lib/import/import-lwip.mk create mode 100644 libports/lib/import/import-mpfr.mk create mode 100644 libports/lib/import/import-ncurses.mk create mode 100644 libports/lib/import/import-python.mk create mode 100644 libports/lib/import/import-zlib.mk create mode 100644 libports/lib/mk/arm/libc-gen.mk create mode 100644 libports/lib/mk/arm/libm.mk create mode 100644 libports/lib/mk/ffat.mk create mode 100644 libports/lib/mk/ffat_block.mk create mode 100644 libports/lib/mk/freetype.mk create mode 100644 libports/lib/mk/gallium-aux.mk create mode 100644 libports/lib/mk/gallium-egl.mk create mode 100644 libports/lib/mk/gallium-failover.mk create mode 100644 libports/lib/mk/gallium-i915.mk create mode 100644 libports/lib/mk/gallium-identity.mk create mode 100644 libports/lib/mk/gallium-softpipe.mk create mode 100644 libports/lib/mk/gallium-trace.mk create mode 100644 libports/lib/mk/gallium.inc create mode 100644 libports/lib/mk/gallium.mk create mode 100644 libports/lib/mk/gmp-mpf.mk create mode 100644 libports/lib/mk/gmp-mpq.mk create mode 100644 libports/lib/mk/gmp-mpz.mk create mode 100644 libports/lib/mk/gmp.inc create mode 100644 libports/lib/mk/gmp.mk create mode 100644 libports/lib/mk/history.mk create mode 100644 libports/lib/mk/jpeg.mk create mode 100644 libports/lib/mk/libc-common.inc create mode 100644 libports/lib/mk/libc-gdtoa.mk create mode 100644 libports/lib/mk/libc-gen.inc create mode 100644 libports/lib/mk/libc-inet.mk create mode 100644 libports/lib/mk/libc-locale.mk create mode 100644 libports/lib/mk/libc-stdio.mk create mode 100644 libports/lib/mk/libc-stdlib.mk create mode 100644 libports/lib/mk/libc-stdtime.mk create mode 100644 libports/lib/mk/libc-string.mk create mode 100644 libports/lib/mk/libc.mk create mode 100644 libports/lib/mk/libc_ffat.mk create mode 100644 libports/lib/mk/libc_lock_pipe.mk create mode 100644 libports/lib/mk/libc_log.mk create mode 100644 libports/lib/mk/libc_lwip.mk create mode 100644 libports/lib/mk/libc_lwip_loopback.mk create mode 100644 libports/lib/mk/libc_lwip_nic_dhcp.mk create mode 100644 libports/lib/mk/libc_terminal.mk create mode 100644 libports/lib/mk/libdrm.mk create mode 100644 libports/lib/mk/libm.mk create mode 100644 libports/lib/mk/libpng.mk create mode 100644 libports/lib/mk/lwip.mk create mode 100644 libports/lib/mk/mesa-egl.mk create mode 100644 libports/lib/mk/mesa.inc create mode 100644 libports/lib/mk/mesa.mk create mode 100644 libports/lib/mk/mpfr.mk create mode 100644 libports/lib/mk/ncurses.mk create mode 100644 libports/lib/mk/python.inc create mode 100644 libports/lib/mk/readline.mk create mode 100644 libports/lib/mk/sdl.mk create mode 100644 libports/lib/mk/test-ldso.mk create mode 100644 libports/lib/mk/test-ldso2.mk create mode 100644 libports/lib/mk/x86_32/gmp-mpn.mk create mode 100644 libports/lib/mk/x86_32/libc-gen.mk create mode 100644 libports/lib/mk/x86_32/python.mk create mode 100644 libports/lib/mk/x86_64/libc-gen.mk create mode 100644 libports/lib/mk/x86_64/python.mk create mode 100644 libports/lib/mk/zlib.mk create mode 100644 libports/ports/ffat.mk create mode 100644 libports/ports/freetype.mk create mode 100644 libports/ports/gmp.mk create mode 100644 libports/ports/jpeg.mk create mode 100644 libports/ports/libc.mk create mode 100644 libports/ports/libdrm.mk create mode 100644 libports/ports/libpng.mk create mode 100644 libports/ports/lwip.mk create mode 100644 libports/ports/mesa.mk create mode 100644 libports/ports/mpfr.mk create mode 100644 libports/ports/ncurses.mk create mode 100644 libports/ports/python.mk create mode 100644 libports/ports/readline.mk create mode 100644 libports/ports/sdl.mk create mode 100644 libports/ports/zlib.mk create mode 100644 libports/run/eglgears.run create mode 100644 libports/run/libc_ffat.run create mode 100644 libports/run/lwip.run create mode 100644 libports/run/lwip_lx.run create mode 100644 libports/run/python.run create mode 100644 libports/run/test-libc.run create mode 100644 libports/src/app/eglgears/eglgears.c create mode 100644 libports/src/app/eglgears/target.mk create mode 100644 libports/src/lib/egl/driver.cc create mode 100644 libports/src/lib/egl/select_driver.cc create mode 100644 libports/src/lib/egl/select_driver.h create mode 100644 libports/src/lib/egl/st_opengl.c create mode 100644 libports/src/lib/ffat/config.patch create mode 100644 libports/src/lib/ffat/diskio.c create mode 100644 libports/src/lib/ffat/diskio_block.cc create mode 100644 libports/src/lib/gallium/README create mode 100644 libports/src/lib/gallium/dummy_trace.c create mode 100644 libports/src/lib/gallium/i915/query_device_id.cc create mode 100644 libports/src/lib/gallium/i915/target.mk create mode 100644 libports/src/lib/gallium/main.cc create mode 100644 libports/src/lib/gallium/p_state_config.patch create mode 100644 libports/src/lib/gmp/config.m4 create mode 100644 libports/src/lib/gmp/mpn/x86/add_n.asm create mode 100644 libports/src/lib/gmp/mpn/x86/dummy.c create mode 100644 libports/src/lib/gmp/mpn/x86/fib_table.c create mode 100644 libports/src/lib/gmp/mpn/x86/mp_bases.c create mode 100644 libports/src/lib/libc/Version.def create mode 100644 libports/src/lib/libc/atexit.cc create mode 100644 libports/src/lib/libc/clock_gettime.cc create mode 100644 libports/src/lib/libc/dummies.cc create mode 100644 libports/src/lib/libc/environ.cc create mode 100644 libports/src/lib/libc/errno.cc create mode 100644 libports/src/lib/libc/exit.cc create mode 100644 libports/src/lib/libc/fd_alloc.cc create mode 100644 libports/src/lib/libc/file_operations.cc create mode 100644 libports/src/lib/libc/gai_strerror.cc create mode 100644 libports/src/lib/libc/gettimeofday.cc create mode 100644 libports/src/lib/libc/ioctl.cc create mode 100644 libports/src/lib/libc/issetugid.cc create mode 100644 libports/src/lib/libc/libc_debug.h create mode 100644 libports/src/lib/libc/malloc.cc create mode 100644 libports/src/lib/libc/munmap.cc create mode 100644 libports/src/lib/libc/patches/README create mode 100644 libports/src/lib/libc/patches/malloc_c.patch create mode 100644 libports/src/lib/libc/patches/math_private.patch create mode 100644 libports/src/lib/libc/patches/pthread_cancel.patch create mode 100644 libports/src/lib/libc/patches/vfwprintf_c_warn.patch create mode 100644 libports/src/lib/libc/plugin.cc create mode 100644 libports/src/lib/libc/plugin_registry.cc create mode 100644 libports/src/lib/libc/progname.cc create mode 100644 libports/src/lib/libc/readlink.cc create mode 100644 libports/src/lib/libc/rlimit.cc create mode 100644 libports/src/lib/libc/select.cc create mode 100644 libports/src/lib/libc/sysctl.cc create mode 100644 libports/src/lib/libc_ffat/plugin.cc create mode 100644 libports/src/lib/libc_lock_pipe/plugin.cc create mode 100644 libports/src/lib/libc_log/plugin.cc create mode 100644 libports/src/lib/libc_lwip/init.cc create mode 100644 libports/src/lib/libc_lwip/plugin.cc create mode 100644 libports/src/lib/libc_lwip_loopback/init.cc create mode 100644 libports/src/lib/libc_lwip_nic_dhcp/init.cc create mode 100644 libports/src/lib/libc_terminal/README create mode 100644 libports/src/lib/libc_terminal/plugin.cc create mode 100644 libports/src/lib/libdrm/ioctl.cc create mode 100644 libports/src/lib/libpng/config.h create mode 100644 libports/src/lib/lwip/errno.patch create mode 100644 libports/src/lib/lwip/include/nic.h create mode 100644 libports/src/lib/lwip/include/ring_buffer.h create mode 100644 libports/src/lib/lwip/include/thread.h create mode 100644 libports/src/lib/lwip/include/timer.h create mode 100644 libports/src/lib/lwip/libc_select_notify.patch create mode 100644 libports/src/lib/lwip/platform/nic.cc create mode 100644 libports/src/lib/lwip/platform/printf.cc create mode 100644 libports/src/lib/lwip/platform/sys_arch.cc create mode 100644 libports/src/lib/python/config.c create mode 100644 libports/src/lib/python/dup.c create mode 100644 libports/src/lib/python/libc_plugin.cc create mode 100644 libports/src/lib/python/libc_plugin_init.cc create mode 100644 libports/src/lib/python/posixmodule.patch create mode 100644 libports/src/lib/readline/genode.cc create mode 100644 libports/src/lib/sdl/SDL_config.h create mode 100644 libports/src/lib/sdl/SDL_config_genode.h create mode 100644 libports/src/lib/sdl/SDL_video.patch create mode 100644 libports/src/lib/sdl/video/SDL_genode_fb_events.cc create mode 100644 libports/src/lib/sdl/video/SDL_genode_fb_events.h create mode 100644 libports/src/lib/sdl/video/SDL_genode_fb_video.cc create mode 100644 libports/src/lib/sdl/video/SDL_genode_fb_video.h create mode 100644 libports/src/test/ldso/include/test-ldso.h create mode 100644 libports/src/test/ldso/lib/test-rtld.cc create mode 100644 libports/src/test/ldso/lib/test_lib.cc create mode 100644 libports/src/test/ldso/main.cc create mode 100644 libports/src/test/ldso/target.mk create mode 100644 libports/src/test/libc/main.cc create mode 100644 libports/src/test/libc/target.mk create mode 100644 libports/src/test/libc_ffat/main.cc create mode 100644 libports/src/test/libc_ffat/target.mk create mode 100644 libports/src/test/libports/freetype/target.mk create mode 100644 libports/src/test/libports/gmp/target.mk create mode 100644 libports/src/test/libports/jpeg/target.mk create mode 100644 libports/src/test/libports/libpng/target.mk create mode 100644 libports/src/test/libports/main.cc create mode 100644 libports/src/test/libports/mesa/target.mk create mode 100644 libports/src/test/libports/mpfr/target.mk create mode 100644 libports/src/test/libports/ncurses/target.mk create mode 100644 libports/src/test/libports/readline/target.mk create mode 100644 libports/src/test/libports/zlib/target.mk create mode 100644 libports/src/test/lwip/http_srv/main.cc create mode 100644 libports/src/test/lwip/http_srv/target.mk create mode 100644 libports/src/test/lwip/loopback/main.cc create mode 100644 libports/src/test/lwip/loopback/target.mk create mode 100644 libports/src/test/python/README create mode 100644 libports/src/test/python/hello.py create mode 100644 libports/src/test/python/main.cc create mode 100644 libports/src/test/python/target.mk create mode 100644 libports/src/test/sdl/main.cc create mode 100644 libports/src/test/sdl/target.mk create mode 100644 libports/tool/mesa/Makefile create mode 100644 os/README create mode 100644 os/config/bomb create mode 100644 os/config/demo create mode 100644 os/config/gta01 create mode 100644 os/config/linux_demo create mode 100644 os/config/mixer create mode 100644 os/config/nested_config create mode 100644 os/config/priority create mode 100644 os/doc/init.txt create mode 100644 os/include/audio_out_session/audio_out_session.h create mode 100644 os/include/audio_out_session/capability.h create mode 100644 os/include/audio_out_session/client.h create mode 100644 os/include/audio_out_session/connection.h create mode 100644 os/include/audio_out_session/rpc_object.h create mode 100644 os/include/blit/blit.h create mode 100644 os/include/block/component.h create mode 100644 os/include/block/driver.h create mode 100644 os/include/block_session/block_session.h create mode 100644 os/include/block_session/capability.h create mode 100644 os/include/block_session/client.h create mode 100644 os/include/block_session/connection.h create mode 100644 os/include/block_session/rpc_object.h create mode 100644 os/include/dde_kit/assert.h create mode 100644 os/include/dde_kit/dde_kit.h create mode 100644 os/include/dde_kit/initcall.h create mode 100644 os/include/dde_kit/interrupt.h create mode 100644 os/include/dde_kit/lock.h create mode 100644 os/include/dde_kit/memory.h create mode 100644 os/include/dde_kit/panic.h create mode 100644 os/include/dde_kit/pci.h create mode 100644 os/include/dde_kit/pgtab.h create mode 100644 os/include/dde_kit/printf.h create mode 100644 os/include/dde_kit/resources.h create mode 100644 os/include/dde_kit/semaphore.h create mode 100644 os/include/dde_kit/thread.h create mode 100644 os/include/dde_kit/timer.h create mode 100644 os/include/dde_kit/types.h create mode 100644 os/include/framebuffer_session/capability.h create mode 100644 os/include/framebuffer_session/client.h create mode 100644 os/include/framebuffer_session/connection.h create mode 100644 os/include/framebuffer_session/framebuffer_session.h create mode 100644 os/include/gpu/driver.h create mode 100644 os/include/init/child.h create mode 100644 os/include/init/child_config.h create mode 100644 os/include/init/child_policy.h create mode 100644 os/include/input/component.h create mode 100644 os/include/input/event.h create mode 100644 os/include/input/keycodes.h create mode 100644 os/include/input_session/capability.h create mode 100644 os/include/input_session/client.h create mode 100644 os/include/input_session/connection.h create mode 100644 os/include/input_session/input_session.h create mode 100644 os/include/ldso/arch.h create mode 100644 os/include/loader_session/capability.h create mode 100644 os/include/loader_session/client.h create mode 100644 os/include/loader_session/connection.h create mode 100644 os/include/loader_session/loader_session.h create mode 100644 os/include/net/arp.h create mode 100644 os/include/net/dhcp.h create mode 100644 os/include/net/ethernet.h create mode 100644 os/include/net/ipv4.h create mode 100644 os/include/net/netaddress.h create mode 100644 os/include/net/udp.h create mode 100644 os/include/nic/component.h create mode 100644 os/include/nic/driver.h create mode 100644 os/include/nic_session/capability.h create mode 100644 os/include/nic_session/client.h create mode 100644 os/include/nic_session/connection.h create mode 100644 os/include/nic_session/nic_session.h create mode 100644 os/include/nic_session/rpc_object.h create mode 100644 os/include/nitpicker_gfx/README create mode 100644 os/include/nitpicker_gfx/canvas.h create mode 100644 os/include/nitpicker_gfx/chunky_canvas.h create mode 100644 os/include/nitpicker_gfx/color.h create mode 100644 os/include/nitpicker_gfx/font.h create mode 100644 os/include/nitpicker_gfx/geometry.h create mode 100644 os/include/nitpicker_gfx/miscmath.h create mode 100644 os/include/nitpicker_gfx/nitpicker_types.h create mode 100644 os/include/nitpicker_gfx/pixel_rgb.h create mode 100644 os/include/nitpicker_gfx/pixel_rgb565.h create mode 100644 os/include/nitpicker_session/capability.h create mode 100644 os/include/nitpicker_session/client.h create mode 100644 os/include/nitpicker_session/connection.h create mode 100644 os/include/nitpicker_session/nitpicker_session.h create mode 100644 os/include/nitpicker_view/capability.h create mode 100644 os/include/nitpicker_view/client.h create mode 100644 os/include/nitpicker_view/nitpicker_view.h create mode 100644 os/include/os/alarm.h create mode 100644 os/include/os/attached_io_mem_dataspace.h create mode 100644 os/include/os/attached_ram_dataspace.h create mode 100644 os/include/os/config.h create mode 100644 os/include/os/irq_activation.h create mode 100644 os/include/os/packet_stream.h create mode 100644 os/include/os/ring_buffer.h create mode 100644 os/include/os/session_policy.h create mode 100644 os/include/os/timed_semaphore.h create mode 100644 os/include/packet_stream_rx/client.h create mode 100644 os/include/packet_stream_rx/packet_stream_rx.h create mode 100644 os/include/packet_stream_rx/rpc_object.h create mode 100644 os/include/packet_stream_tx/client.h create mode 100644 os/include/packet_stream_tx/packet_stream_tx.h create mode 100644 os/include/packet_stream_tx/rpc_object.h create mode 100644 os/include/pci_device/capability.h create mode 100644 os/include/pci_device/client.h create mode 100644 os/include/pci_device/pci_device.h create mode 100644 os/include/pci_session/capability.h create mode 100644 os/include/pci_session/client.h create mode 100644 os/include/pci_session/connection.h create mode 100644 os/include/pci_session/pci_session.h create mode 100644 os/include/platform/pbxa9/lan9118_defs.h create mode 100644 os/include/platform/pbxa9/pl011_defs.h create mode 100644 os/include/platform/pbxa9/pl050_defs.h create mode 100644 os/include/platform/pbxa9/pl11x_defs.h create mode 100644 os/include/platform/pbxa9/pl180_defs.h create mode 100644 os/include/platform/pbxa9/sp810_defs.h create mode 100644 os/include/platform/vea9x4/bus.h create mode 100644 os/include/platform/vea9x4/lan9118_defs.h create mode 100644 os/include/platform/vea9x4/pl011_defs.h create mode 100644 os/include/platform/vea9x4/pl050_defs.h create mode 100644 os/include/platform/vea9x4/pl11x_defs.h create mode 100644 os/include/platform/vea9x4/pl180_defs.h create mode 100644 os/include/platform/vea9x4/sp810_defs.h create mode 100644 os/include/platform/vpb926/pl011_defs.h create mode 100644 os/include/platform/vpb926/pl050_defs.h create mode 100644 os/include/platform/vpb926/pl11x_defs.h create mode 100644 os/include/platform/vpb926/sp810_defs.h create mode 100644 os/include/terminal_session/client.h create mode 100644 os/include/terminal_session/connection.h create mode 100644 os/include/terminal_session/terminal_session.h create mode 100644 os/include/timer_session/capability.h create mode 100644 os/include/timer_session/client.h create mode 100644 os/include/timer_session/connection.h create mode 100644 os/include/timer_session/server.h create mode 100644 os/include/timer_session/timer_session.h create mode 100644 os/include/util/endian.h create mode 100644 os/include/util/xml_node.h create mode 100644 os/include/xev_track/xev_track.h create mode 100644 os/lib/mk/alarm.mk create mode 100644 os/lib/mk/arm/ld.mk create mode 100644 os/lib/mk/arm/ldso-startup.mk create mode 100644 os/lib/mk/arm/ldso_crt0.mk create mode 100644 os/lib/mk/blit.mk create mode 100644 os/lib/mk/codezero/ldso-arch.mk create mode 100644 os/lib/mk/dde_kit.mk create mode 100644 os/lib/mk/ldso-arch.mk create mode 100644 os/lib/mk/ldso-startup.mk create mode 100644 os/lib/mk/linux/ldso-arch.mk create mode 100644 os/lib/mk/net.mk create mode 100644 os/lib/mk/pistachio/ldso-arch.mk create mode 100644 os/lib/mk/timed_semaphore.mk create mode 100644 os/lib/mk/x86_32/blit.mk create mode 100644 os/lib/mk/x86_32/ld.mk create mode 100644 os/lib/mk/x86_32/ldso_crt0.mk create mode 100644 os/lib/mk/x86_32/ldso_crt0_lx.mk create mode 100644 os/lib/mk/x86_64/blit.mk create mode 100644 os/lib/mk/x86_64/ld.mk create mode 100644 os/lib/mk/x86_64/ldso_crt0.mk create mode 100644 os/lib/mk/x86_64/ldso_crt0_lx.mk create mode 100644 os/lib/mk/xev_track.mk create mode 100644 os/run/ahci.run create mode 100644 os/run/demo.run create mode 100644 os/run/ldso.run create mode 100644 os/run/part_blk.run create mode 100644 os/run/rom_blk.run create mode 100644 os/run/sd_card.run create mode 100644 os/run/signal.run create mode 100644 os/run/tar_rom.run create mode 100644 os/run/timed_semaphore.run create mode 100644 os/run/uart.run create mode 100644 os/src/app/xvfb/README create mode 100644 os/src/app/xvfb/inject_input.cc create mode 100644 os/src/app/xvfb/inject_input.h create mode 100644 os/src/app/xvfb/main.cc create mode 100644 os/src/app/xvfb/target.mk create mode 100644 os/src/drivers/ahci/README create mode 100644 os/src/drivers/ahci/main.cc create mode 100644 os/src/drivers/ahci/target.mk create mode 100644 os/src/drivers/atapi/README create mode 100644 os/src/drivers/atapi/ata_bus_master.cc create mode 100644 os/src/drivers/atapi/ata_bus_master.h create mode 100644 os/src/drivers/atapi/ata_device.cc create mode 100644 os/src/drivers/atapi/ata_device.h create mode 100644 os/src/drivers/atapi/atapi_device.cc create mode 100644 os/src/drivers/atapi/contrib/mindrvr-guide.txt create mode 100644 os/src/drivers/atapi/contrib/mindrvr.c create mode 100644 os/src/drivers/atapi/contrib/mindrvr.h create mode 100644 os/src/drivers/atapi/endian.h create mode 100644 os/src/drivers/atapi/io.cc create mode 100644 os/src/drivers/atapi/io.h create mode 100644 os/src/drivers/atapi/main.cc create mode 100644 os/src/drivers/atapi/pio.h create mode 100644 os/src/drivers/atapi/target.mk create mode 100644 os/src/drivers/audio_out/linux/alsa.c create mode 100644 os/src/drivers/audio_out/linux/alsa.h create mode 100644 os/src/drivers/audio_out/linux/main.cc create mode 100644 os/src/drivers/audio_out/linux/target.mk create mode 100644 os/src/drivers/framebuffer/fiasco_ux/framebuffer.cc create mode 100644 os/src/drivers/framebuffer/fiasco_ux/framebuffer.h create mode 100644 os/src/drivers/framebuffer/fiasco_ux/main.cc create mode 100644 os/src/drivers/framebuffer/fiasco_ux/target.mk create mode 100644 os/src/drivers/framebuffer/pl11x/main.cc create mode 100644 os/src/drivers/framebuffer/pl11x/pbxa9/target.mk create mode 100644 os/src/drivers/framebuffer/pl11x/target.mk create mode 100644 os/src/drivers/framebuffer/pl11x/vea9x4/target.mk create mode 100644 os/src/drivers/framebuffer/pl11x/vea9x4/video_memory.cc create mode 100644 os/src/drivers/framebuffer/pl11x/video_memory.cc create mode 100644 os/src/drivers/framebuffer/pl11x/video_memory.h create mode 100644 os/src/drivers/framebuffer/pl11x/vpb926/target.mk create mode 100644 os/src/drivers/framebuffer/sdl/fb_sdl.cc create mode 100644 os/src/drivers/framebuffer/sdl/input.cc create mode 100644 os/src/drivers/framebuffer/sdl/target.mk create mode 100644 os/src/drivers/framebuffer/vesa/README create mode 100644 os/src/drivers/framebuffer/vesa/contrib/LICENSE create mode 100644 os/src/drivers/framebuffer/vesa/contrib/Makefile.old create mode 100644 os/src/drivers/framebuffer/vesa/contrib/debug.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/decode.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/fgets.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/fpu.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/ops.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/ops2.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/prim_ops.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/printk.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/sys.c create mode 100644 os/src/drivers/framebuffer/vesa/contrib/x86emu/debug.h create mode 100644 os/src/drivers/framebuffer/vesa/contrib/x86emu/decode.h create mode 100644 os/src/drivers/framebuffer/vesa/contrib/x86emu/fpu.h create mode 100644 os/src/drivers/framebuffer/vesa/contrib/x86emu/fpu_regs.h create mode 100644 os/src/drivers/framebuffer/vesa/contrib/x86emu/ops.h create mode 100644 os/src/drivers/framebuffer/vesa/contrib/x86emu/prim_asm.h create mode 100644 os/src/drivers/framebuffer/vesa/contrib/x86emu/prim_ops.h create mode 100644 os/src/drivers/framebuffer/vesa/contrib/x86emu/x86emui.h create mode 100644 os/src/drivers/framebuffer/vesa/framebuffer.cc create mode 100644 os/src/drivers/framebuffer/vesa/hw_emul.cc create mode 100644 os/src/drivers/framebuffer/vesa/ifx86emu.cc create mode 100644 os/src/drivers/framebuffer/vesa/include/framebuffer.h create mode 100644 os/src/drivers/framebuffer/vesa/include/hw_emul.h create mode 100644 os/src/drivers/framebuffer/vesa/include/ifx86emu.h create mode 100644 os/src/drivers/framebuffer/vesa/include/vbe.h create mode 100644 os/src/drivers/framebuffer/vesa/include/vesa.h create mode 100644 os/src/drivers/framebuffer/vesa/include/x86emu/regs.h create mode 100644 os/src/drivers/framebuffer/vesa/include/x86emu/types.h create mode 100644 os/src/drivers/framebuffer/vesa/include/x86emu/x86emu.h create mode 100644 os/src/drivers/framebuffer/vesa/main.cc create mode 100644 os/src/drivers/framebuffer/vesa/target.mk create mode 100644 os/src/drivers/input/dummy/README create mode 100644 os/src/drivers/input/dummy/main.cc create mode 100644 os/src/drivers/input/dummy/target.mk create mode 100644 os/src/drivers/input/fiasco_ux/input.cc create mode 100644 os/src/drivers/input/fiasco_ux/input.h create mode 100644 os/src/drivers/input/fiasco_ux/main.cc create mode 100644 os/src/drivers/input/fiasco_ux/target.mk create mode 100644 os/src/drivers/input/fiasco_ux/test.cc create mode 100644 os/src/drivers/input/ps2/event_queue.h create mode 100644 os/src/drivers/input/ps2/input_driver.h create mode 100644 os/src/drivers/input/ps2/irq_handler.h create mode 100644 os/src/drivers/input/ps2/pl050/irq_handler.h create mode 100644 os/src/drivers/input/ps2/pl050/main.cc create mode 100644 os/src/drivers/input/ps2/pl050/pl050.h create mode 100644 os/src/drivers/input/ps2/pl050/stdio.h create mode 100644 os/src/drivers/input/ps2/pl050/string.h create mode 100644 os/src/drivers/input/ps2/pl050/target.mk create mode 100644 os/src/drivers/input/ps2/ps2_keyboard.h create mode 100644 os/src/drivers/input/ps2/ps2_mouse.h create mode 100644 os/src/drivers/input/ps2/scan_code_set_1.h create mode 100644 os/src/drivers/input/ps2/scan_code_set_2.h create mode 100644 os/src/drivers/input/ps2/serial_interface.h create mode 100644 os/src/drivers/input/ps2/x86/i8042.h create mode 100644 os/src/drivers/input/ps2/x86/main.cc create mode 100644 os/src/drivers/input/ps2/x86/target.mk create mode 100644 os/src/drivers/nic/lan9118/lan9118.h create mode 100644 os/src/drivers/nic/lan9118/main.cc create mode 100644 os/src/drivers/nic/lan9118/target.mk create mode 100644 os/src/drivers/nic/linux/main.cc create mode 100644 os/src/drivers/nic/linux/target.mk create mode 100644 os/src/drivers/pci/main.cc create mode 100644 os/src/drivers/pci/pci_config_access.h create mode 100644 os/src/drivers/pci/pci_device_component.h create mode 100644 os/src/drivers/pci/pci_device_config.h create mode 100644 os/src/drivers/pci/pci_session_component.h create mode 100644 os/src/drivers/pci/x86/target.mk create mode 100644 os/src/drivers/platform/gta01/main.cc create mode 100644 os/src/drivers/platform/gta01/target.mk create mode 100644 os/src/drivers/rtc/x86/main.cc create mode 100644 os/src/drivers/rtc/x86/target.mk create mode 100644 os/src/drivers/sd_card/host_driver.h create mode 100644 os/src/drivers/sd_card/pl180/main.cc create mode 100644 os/src/drivers/sd_card/pl180/pl180.h create mode 100644 os/src/drivers/sd_card/pl180/target.mk create mode 100644 os/src/drivers/sd_card/sd_card.h create mode 100644 os/src/drivers/timer/codezero/platform_timer.cc create mode 100644 os/src/drivers/timer/codezero/target.mk create mode 100644 os/src/drivers/timer/fiasco/platform_timer.cc create mode 100644 os/src/drivers/timer/fiasco/target.mk create mode 100644 os/src/drivers/timer/foc/target.mk create mode 100644 os/src/drivers/timer/foc/timer_root.h create mode 100644 os/src/drivers/timer/foc/timer_session_component.h create mode 100644 os/src/drivers/timer/include/timer_root.h create mode 100644 os/src/drivers/timer/include/timer_session_component.h create mode 100644 os/src/drivers/timer/include_periodic/platform_timer.h create mode 100644 os/src/drivers/timer/include_pit/platform_timer.h create mode 100644 os/src/drivers/timer/linux/platform_timer.cc create mode 100644 os/src/drivers/timer/linux/target.mk create mode 100644 os/src/drivers/timer/main.cc create mode 100644 os/src/drivers/timer/nova/target.mk create mode 100644 os/src/drivers/timer/nova/timer_root.h create mode 100644 os/src/drivers/timer/nova/timer_session_component.h create mode 100644 os/src/drivers/timer/okl4_arm/platform_timer.cc create mode 100644 os/src/drivers/timer/okl4_arm/target.mk create mode 100644 os/src/drivers/timer/okl4_x86/target.mk create mode 100644 os/src/drivers/timer/pistachio/platform_timer.cc create mode 100644 os/src/drivers/timer/pistachio/target.mk create mode 100644 os/src/drivers/uart/README create mode 100644 os/src/drivers/uart/i8250/i8250.h create mode 100644 os/src/drivers/uart/i8250/main.cc create mode 100644 os/src/drivers/uart/i8250/target.mk create mode 100755 os/src/drivers/uart/pl011/calc_brd_values.py create mode 100644 os/src/drivers/uart/pl011/main.cc create mode 100644 os/src/drivers/uart/pl011/pl011.h create mode 100644 os/src/drivers/uart/pl011/target.mk create mode 100644 os/src/drivers/uart/terminal_component.h create mode 100644 os/src/drivers/uart/terminal_driver.h create mode 100644 os/src/init/config.explicit_routing create mode 100644 os/src/init/config.wildcard create mode 100644 os/src/init/main.cc create mode 100644 os/src/init/target.mk create mode 100644 os/src/lib/alarm/alarm.cc create mode 100644 os/src/lib/blit/blit.cc create mode 100644 os/src/lib/blit/x86/blit.cc create mode 100644 os/src/lib/blit/x86/x86_32/mmx.h create mode 100644 os/src/lib/blit/x86/x86_64/mmx.h create mode 100644 os/src/lib/dde_kit/dde_kit.cc create mode 100644 os/src/lib/dde_kit/interrupt.cc create mode 100644 os/src/lib/dde_kit/lock.cc create mode 100644 os/src/lib/dde_kit/memory.cc create mode 100644 os/src/lib/dde_kit/panic.cc create mode 100644 os/src/lib/dde_kit/pci.cc create mode 100644 os/src/lib/dde_kit/pci_tree.cc create mode 100644 os/src/lib/dde_kit/pci_tree.h create mode 100644 os/src/lib/dde_kit/pgtab.cc create mode 100644 os/src/lib/dde_kit/printf.cc create mode 100644 os/src/lib/dde_kit/resources.cc create mode 100644 os/src/lib/dde_kit/semaphore.cc create mode 100644 os/src/lib/dde_kit/thread.cc create mode 100644 os/src/lib/dde_kit/thread.h create mode 100644 os/src/lib/dde_kit/timer.cc create mode 100644 os/src/lib/ldso/README create mode 100644 os/src/lib/ldso/arch/binary_name.cc create mode 100644 os/src/lib/ldso/arch/codezero/dummy.c create mode 100644 os/src/lib/ldso/arch/linux/binary_name.cc create mode 100644 os/src/lib/ldso/arch/linux/parent_cap.cc create mode 100644 os/src/lib/ldso/arch/parent_cap.cc create mode 100644 os/src/lib/ldso/arm/crt0.s create mode 100644 os/src/lib/ldso/arm/platform.c create mode 100644 os/src/lib/ldso/contrib/amd64/reloc.c create mode 100644 os/src/lib/ldso/contrib/amd64/rtld_machdep.h create mode 100644 os/src/lib/ldso/contrib/amd64/rtld_start.S create mode 100644 os/src/lib/ldso/contrib/arm/reloc.c create mode 100644 os/src/lib/ldso/contrib/arm/rtld_machdep.h create mode 100644 os/src/lib/ldso/contrib/arm/rtld_start.S create mode 100644 os/src/lib/ldso/contrib/debug.c create mode 100644 os/src/lib/ldso/contrib/debug.h create mode 100644 os/src/lib/ldso/contrib/i386/reloc.c create mode 100644 os/src/lib/ldso/contrib/i386/rtld_machdep.h create mode 100644 os/src/lib/ldso/contrib/i386/rtld_start.S create mode 100644 os/src/lib/ldso/contrib/libmap.c create mode 100644 os/src/lib/ldso/contrib/libmap.h create mode 100644 os/src/lib/ldso/contrib/malloc.c create mode 100644 os/src/lib/ldso/contrib/map_object.c create mode 100644 os/src/lib/ldso/contrib/rtld.c create mode 100644 os/src/lib/ldso/contrib/rtld.h create mode 100644 os/src/lib/ldso/contrib/rtld_lock.c create mode 100644 os/src/lib/ldso/contrib/rtld_lock.h create mode 100644 os/src/lib/ldso/contrib/rtld_tls.h create mode 100644 os/src/lib/ldso/contrib/xmalloc.c create mode 100644 os/src/lib/ldso/dl_extensions.h create mode 100644 os/src/lib/ldso/environ.cc create mode 100644 os/src/lib/ldso/err.cc create mode 100644 os/src/lib/ldso/file.cc create mode 100644 os/src/lib/ldso/file.h create mode 100644 os/src/lib/ldso/include/arm/call_main.h create mode 100644 os/src/lib/ldso/include/libc/dlfcn.h create mode 100644 os/src/lib/ldso/include/libc/elf-hints.h create mode 100644 os/src/lib/ldso/include/libc/libc-amd64/machine/elf.h create mode 100644 os/src/lib/ldso/include/libc/libc-arm/machine/asm.h create mode 100644 os/src/lib/ldso/include/libc/libc-arm/machine/elf.h create mode 100644 os/src/lib/ldso/include/libc/libc-i386/machine/elf.h create mode 100644 os/src/lib/ldso/include/libc/sys/cdefs.h create mode 100644 os/src/lib/ldso/include/libc/sys/elf.h create mode 100644 os/src/lib/ldso/include/libc/sys/elf32.h create mode 100644 os/src/lib/ldso/include/libc/sys/elf64.h create mode 100644 os/src/lib/ldso/include/libc/sys/elf_common.h create mode 100644 os/src/lib/ldso/include/libc/sys/elf_generic.h create mode 100644 os/src/lib/ldso/include/libc/sys/link_elf.h create mode 100644 os/src/lib/ldso/include/libc/sys/queue.h create mode 100644 os/src/lib/ldso/include/libc_emu/err.h create mode 100644 os/src/lib/ldso/include/libc_emu/errno.h create mode 100644 os/src/lib/ldso/include/libc_emu/fcntl.h create mode 100644 os/src/lib/ldso/include/libc_emu/ldso_types.h create mode 100644 os/src/lib/ldso/include/libc_emu/link.h create mode 100644 os/src/lib/ldso/include/libc_emu/machine/atomic.h create mode 100644 os/src/lib/ldso/include/libc_emu/machine/segments.h create mode 100644 os/src/lib/ldso/include/libc_emu/machine/sysarch.h create mode 100644 os/src/lib/ldso/include/libc_emu/stdio.h create mode 100644 os/src/lib/ldso/include/libc_emu/stdlib.h create mode 100644 os/src/lib/ldso/include/libc_emu/string.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/_types.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/ktrace.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/mman.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/mount.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/param.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/queue.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/stat.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/types.h create mode 100644 os/src/lib/ldso/include/libc_emu/sys/uio.h create mode 100644 os/src/lib/ldso/include/libc_emu/unistd.h create mode 100644 os/src/lib/ldso/include/x86_32/call_main.h create mode 100644 os/src/lib/ldso/include/x86_64/call_main.h create mode 100644 os/src/lib/ldso/ldso.ld create mode 100644 os/src/lib/ldso/ldso_types.c create mode 100644 os/src/lib/ldso/lock.cc create mode 100644 os/src/lib/ldso/main.c create mode 100644 os/src/lib/ldso/platform.c create mode 100644 os/src/lib/ldso/rtld_dummies.c create mode 100644 os/src/lib/ldso/startup/startup.cc create mode 100644 os/src/lib/ldso/startup/unwind_exidx.cc create mode 100644 os/src/lib/ldso/stdio.cc create mode 100644 os/src/lib/ldso/stdlib.cc create mode 100644 os/src/lib/ldso/string.cc create mode 100644 os/src/lib/ldso/symbol.map create mode 100644 os/src/lib/ldso/target.inc create mode 100644 os/src/lib/ldso/test.cc create mode 100644 os/src/lib/ldso/x86_32/crt0.s create mode 100644 os/src/lib/ldso/x86_32/linux/crt0.s create mode 100644 os/src/lib/ldso/x86_64/crt0.s create mode 100644 os/src/lib/ldso/x86_64/linux/crt0.s create mode 100644 os/src/lib/net/ethernet.cc create mode 100644 os/src/lib/net/ipv4.cc create mode 100644 os/src/lib/timed_semaphore/timed_semaphore.cc create mode 100644 os/src/lib/xev_track/xev_track.cc create mode 100644 os/src/platform/genode_dyn.ld create mode 100644 os/src/platform/genode_rel.ld create mode 100644 os/src/server/iso9660/README create mode 100644 os/src/server/iso9660/backing_store.h create mode 100644 os/src/server/iso9660/iso9660.cc create mode 100644 os/src/server/iso9660/iso9660.h create mode 100644 os/src/server/iso9660/main.cc create mode 100644 os/src/server/iso9660/target.mk create mode 100644 os/src/server/loader/README create mode 100644 os/src/server/loader/input_root.h create mode 100644 os/src/server/loader/input_session_component.cc create mode 100644 os/src/server/loader/input_session_component.h create mode 100644 os/src/server/loader/loader_child.h create mode 100644 os/src/server/loader/loader_root.h create mode 100644 os/src/server/loader/loader_session_component.cc create mode 100644 os/src/server/loader/loader_session_component.h create mode 100644 os/src/server/loader/loader_view_component.h create mode 100644 os/src/server/loader/main.cc create mode 100644 os/src/server/loader/nitpicker_root.h create mode 100644 os/src/server/loader/nitpicker_session_component.cc create mode 100644 os/src/server/loader/nitpicker_session_component.h create mode 100644 os/src/server/loader/nitpicker_view_component.h create mode 100644 os/src/server/loader/rom_root.h create mode 100644 os/src/server/loader/rom_session_component.cc create mode 100644 os/src/server/loader/rom_session_component.h create mode 100644 os/src/server/loader/tar_server_child.h create mode 100644 os/src/server/loader/target.mk create mode 100644 os/src/server/mixer/mixer.cc create mode 100644 os/src/server/mixer/target.mk create mode 100644 os/src/server/nic_bridge/address_node.cc create mode 100644 os/src/server/nic_bridge/address_node.h create mode 100644 os/src/server/nic_bridge/avl_safe.h create mode 100644 os/src/server/nic_bridge/component.cc create mode 100644 os/src/server/nic_bridge/component.h create mode 100644 os/src/server/nic_bridge/list_safe.h create mode 100644 os/src/server/nic_bridge/mac.cc create mode 100644 os/src/server/nic_bridge/mac.h create mode 100644 os/src/server/nic_bridge/main.cc create mode 100644 os/src/server/nic_bridge/packet_handler.cc create mode 100644 os/src/server/nic_bridge/packet_handler.h create mode 100644 os/src/server/nic_bridge/target.mk create mode 100644 os/src/server/nic_bridge/vlan.cc create mode 100644 os/src/server/nic_bridge/vlan.h create mode 100644 os/src/server/nic_loopback/main.cc create mode 100644 os/src/server/nic_loopback/target.mk create mode 100644 os/src/server/nit_fb/README create mode 100644 os/src/server/nit_fb/main.cc create mode 100644 os/src/server/nit_fb/target.mk create mode 100644 os/src/server/nitpicker/README create mode 100644 os/src/server/nitpicker/TODO create mode 100644 os/src/server/nitpicker/common/user_state.cc create mode 100644 os/src/server/nitpicker/common/view.cc create mode 100644 os/src/server/nitpicker/common/view_stack.cc create mode 100644 os/src/server/nitpicker/data/big_mouse.h create mode 100755 os/src/server/nitpicker/data/default.tff create mode 100644 os/src/server/nitpicker/genode/main.cc create mode 100644 os/src/server/nitpicker/genode/target.mk create mode 100644 os/src/server/nitpicker/include/background.h create mode 100644 os/src/server/nitpicker/include/chunky_menubar.h create mode 100644 os/src/server/nitpicker/include/clip_guard.h create mode 100644 os/src/server/nitpicker/include/draw_label.h create mode 100644 os/src/server/nitpicker/include/list.h create mode 100644 os/src/server/nitpicker/include/menubar.h create mode 100644 os/src/server/nitpicker/include/mode.h create mode 100644 os/src/server/nitpicker/include/mouse_cursor.h create mode 100644 os/src/server/nitpicker/include/session.h create mode 100644 os/src/server/nitpicker/include/string.h create mode 100644 os/src/server/nitpicker/include/user_state.h create mode 100644 os/src/server/nitpicker/include/view.h create mode 100644 os/src/server/nitpicker/include/view_stack.h create mode 100644 os/src/server/part_blk/README create mode 100644 os/src/server/part_blk/back_end.cc create mode 100644 os/src/server/part_blk/main.cc create mode 100644 os/src/server/part_blk/part_blk.h create mode 100644 os/src/server/part_blk/target.mk create mode 100644 os/src/server/rom_loopdev/README create mode 100644 os/src/server/rom_loopdev/main.cc create mode 100644 os/src/server/rom_loopdev/target.mk create mode 100644 os/src/server/rom_prefetcher/main.cc create mode 100644 os/src/server/rom_prefetcher/target.mk create mode 100644 os/src/server/tar_rom/README create mode 100755 os/src/server/tar_rom/main.cc create mode 100755 os/src/server/tar_rom/target.mk create mode 100644 os/src/test/ahci/main.cc create mode 100644 os/src/test/ahci/target.mk create mode 100644 os/src/test/alarm/main.cc create mode 100644 os/src/test/alarm/target.mk create mode 100644 os/src/test/audio_out/README create mode 100644 os/src/test/audio_out/main.cc create mode 100644 os/src/test/audio_out/target.mk create mode 100644 os/src/test/block/main.cc create mode 100644 os/src/test/block/target.mk create mode 100644 os/src/test/bomb/main.cc create mode 100644 os/src/test/bomb/target.mk create mode 100644 os/src/test/dde_kit/i8042.h create mode 100644 os/src/test/dde_kit/target.mk create mode 100644 os/src/test/dde_kit/test.cc create mode 100644 os/src/test/fb_block_adapter/main.cc create mode 100644 os/src/test/fb_block_adapter/target.mk create mode 100644 os/src/test/input/key_strings.h create mode 100644 os/src/test/input/target.mk create mode 100644 os/src/test/input/test.cc create mode 100644 os/src/test/iso/main.cc create mode 100644 os/src/test/iso/target.mk create mode 100644 os/src/test/iso/test.txt create mode 100644 os/src/test/loader/main.cc create mode 100644 os/src/test/loader/target.mk create mode 100644 os/src/test/nic_loopback/main.cc create mode 100644 os/src/test/nic_loopback/target.mk create mode 100644 os/src/test/nitpicker/target.mk create mode 100644 os/src/test/nitpicker/test.cc create mode 100644 os/src/test/packet_stream/main.cc create mode 100644 os/src/test/packet_stream/target.mk create mode 100644 os/src/test/part_blk/main.cc create mode 100644 os/src/test/part_blk/target.mk create mode 100644 os/src/test/pci/target.mk create mode 100644 os/src/test/pci/test.cc create mode 100644 os/src/test/rom_blk/main.cc create mode 100644 os/src/test/rom_blk/target.mk create mode 100644 os/src/test/signal/main.cc create mode 100644 os/src/test/signal/target.mk create mode 100644 os/src/test/terminal_echo/main.cc create mode 100644 os/src/test/terminal_echo/target.mk create mode 100644 os/src/test/timed_semaphore/main.cc create mode 100644 os/src/test/timed_semaphore/target.mk create mode 100644 os/src/test/timer/main.cc create mode 100644 os/src/test/timer/target.mk create mode 100644 os/src/test/timer_accuracy/main.cc create mode 100644 os/src/test/timer_accuracy/target.mk create mode 100644 os/src/test/uart/main.cc create mode 100644 os/src/test/uart/target.mk create mode 100644 os/src/test/xev_track/main.cc create mode 100644 os/src/test/xev_track/target.mk create mode 100755 os/tool/dde_kit_adapt_sources create mode 100755 os/tool/dde_kit_find_initcalls create mode 100644 ports-foc/Makefile create mode 100644 ports-foc/README create mode 100644 ports-foc/config/android_config.arm create mode 100644 ports-foc/config/android_config.x86_32 create mode 100644 ports-foc/config/linux_config.arm create mode 100644 ports-foc/config/linux_config.x86_32 create mode 100644 ports-foc/include/32-bit/l4/util/l4_macros.h create mode 100644 ports-foc/include/64-bit/l4/util/l4_macros.h create mode 100644 ports-foc/include/genode/block.h create mode 100644 ports-foc/include/genode/framebuffer.h create mode 100644 ports-foc/include/genode/input.h create mode 100644 ports-foc/include/genode/linkage.h create mode 100644 ports-foc/include/genode/net.h create mode 100644 ports-foc/include/genode/terminal.h create mode 100644 ports-foc/include/l4/io/io.h create mode 100644 ports-foc/include/l4/log/log.h create mode 100644 ports-foc/include/l4/re/c/dataspace.h create mode 100644 ports-foc/include/l4/re/c/debug.h create mode 100644 ports-foc/include/l4/re/c/mem_alloc.h create mode 100644 ports-foc/include/l4/re/c/namespace.h create mode 100644 ports-foc/include/l4/re/c/rm.h create mode 100644 ports-foc/include/l4/re/c/util/cap.h create mode 100644 ports-foc/include/l4/re/c/util/cap_alloc.h create mode 100644 ports-foc/include/l4/re/consts.h create mode 100644 ports-foc/include/l4/re/env.h create mode 100644 ports-foc/include/l4/util/atomic.h create mode 100644 ports-foc/include/l4/util/cpu.h create mode 100644 ports-foc/include/l4/util/kip.h create mode 100644 ports-foc/include/l4/util/kprintf.h create mode 100644 ports-foc/include/l4/util/util.h create mode 100644 ports-foc/lib/mk/l4lx.mk create mode 100644 ports-foc/lib/mk/l4sys.mk create mode 100644 ports-foc/mk/l4lx.mk create mode 100644 ports-foc/patches/l4android_genode.patch create mode 100644 ports-foc/patches/l4lx_genode.patch create mode 100644 ports-foc/run/l4android.run create mode 100644 ports-foc/run/l4linux.run create mode 100644 ports-foc/src/drivers/Makefile create mode 100644 ports-foc/src/drivers/genode_block.c create mode 100644 ports-foc/src/drivers/genode_fb.c create mode 100644 ports-foc/src/drivers/genode_net.c create mode 100644 ports-foc/src/drivers/genode_rtc.c create mode 100644 ports-foc/src/drivers/genode_serial.c create mode 100644 ports-foc/src/l4android/arm/target.mk create mode 100644 ports-foc/src/l4android/x86_32/target.mk create mode 100644 ports-foc/src/l4linux/arm/target.mk create mode 100644 ports-foc/src/l4linux/x86_32/target.mk create mode 100644 ports-foc/src/lib/l4lx/dataspace.cc create mode 100644 ports-foc/src/lib/l4lx/env.cc create mode 100644 ports-foc/src/lib/l4lx/genode_block.cc create mode 100644 ports-foc/src/lib/l4lx/genode_framebuffer.cc create mode 100644 ports-foc/src/lib/l4lx/genode_input.cc create mode 100644 ports-foc/src/lib/l4lx/genode_net.cc create mode 100644 ports-foc/src/lib/l4lx/genode_terminal.cc create mode 100644 ports-foc/src/lib/l4lx/include/dataspace.h create mode 100644 ports-foc/src/lib/l4lx/include/env.h create mode 100644 ports-foc/src/lib/l4lx/include/l4lx_irq.h create mode 100644 ports-foc/src/lib/l4lx/include/l4lx_memory.h create mode 100644 ports-foc/src/lib/l4lx/include/l4lx_task.h create mode 100644 ports-foc/src/lib/l4lx/include/l4lx_thread.h create mode 100644 ports-foc/src/lib/l4lx/include/linux.h create mode 100644 ports-foc/src/lib/l4lx/include/rm.h create mode 100644 ports-foc/src/lib/l4lx/include/task.h create mode 100644 ports-foc/src/lib/l4lx/include/vcpu.h create mode 100644 ports-foc/src/lib/l4lx/l4_io.cc create mode 100644 ports-foc/src/lib/l4lx/l4_log.cc create mode 100644 ports-foc/src/lib/l4lx/l4_re_c_dataspace.cc create mode 100644 ports-foc/src/lib/l4lx/l4_re_c_debug.cc create mode 100644 ports-foc/src/lib/l4lx/l4_re_c_mem_alloc.cc create mode 100644 ports-foc/src/lib/l4lx/l4_re_c_namespace.cc create mode 100644 ports-foc/src/lib/l4lx/l4_re_c_rm.cc create mode 100644 ports-foc/src/lib/l4lx/l4_re_c_util_cap.cc create mode 100644 ports-foc/src/lib/l4lx/l4_re_env.cc create mode 100644 ports-foc/src/lib/l4lx/l4_util_cpu.cc create mode 100644 ports-foc/src/lib/l4lx/l4_util_kip.cc create mode 100644 ports-foc/src/lib/l4lx/l4_util_util.cc create mode 100644 ports-foc/src/lib/l4lx/l4lx_irq.cc create mode 100644 ports-foc/src/lib/l4lx/l4lx_memory.cc create mode 100644 ports-foc/src/lib/l4lx/l4lx_task.cc create mode 100644 ports-foc/src/lib/l4lx/l4lx_thread.cc create mode 100644 ports-foc/src/lib/l4lx/rm.cc create mode 100644 ports-foc/src/lib/l4lx/startup.cc create mode 100644 ports-okl4/Makefile create mode 100644 ports-okl4/README create mode 100644 ports-okl4/config/elfweaver_config create mode 100644 ports-okl4/config/init_config create mode 100644 ports-okl4/config/linux_config create mode 100644 ports-okl4/include/oklx_kernel/oklx/ioctl.h create mode 100644 ports-okl4/include/oklx_lib/genode/audio.h create mode 100644 ports-okl4/include/oklx_lib/genode/block.h create mode 100644 ports-okl4/include/oklx_lib/genode/config.h create mode 100644 ports-okl4/include/oklx_lib/genode/exit.h create mode 100644 ports-okl4/include/oklx_lib/genode/framebuffer.h create mode 100644 ports-okl4/include/oklx_lib/genode/input.h create mode 100644 ports-okl4/include/oklx_lib/genode/lock.h create mode 100644 ports-okl4/include/oklx_lib/genode/memory.h create mode 100644 ports-okl4/include/oklx_lib/genode/net.h create mode 100644 ports-okl4/include/oklx_lib/genode/open.h create mode 100644 ports-okl4/include/oklx_lib/genode/printf.h create mode 100644 ports-okl4/include/oklx_lib/genode/sleep.h create mode 100644 ports-okl4/include/oklx_lib/iguana/eas.h create mode 100644 ports-okl4/include/oklx_lib/iguana/hardware.h create mode 100644 ports-okl4/include/oklx_lib/iguana/memsection.h create mode 100644 ports-okl4/include/oklx_lib/iguana/pd.h create mode 100644 ports-okl4/include/oklx_lib/iguana/stdint.h create mode 100644 ports-okl4/include/oklx_lib/iguana/thread.h create mode 100644 ports-okl4/include/oklx_lib/iguana/tls.h create mode 100644 ports-okl4/include/oklx_lib/iguana/types.h create mode 100644 ports-okl4/lib/mk/oklx.mk create mode 100644 ports-okl4/patches/oklx_genode.patch create mode 100644 ports-okl4/patches/unionfs.patch create mode 100644 ports-okl4/run/lx_block.run create mode 100644 ports-okl4/src/app/xev_track/bounding_box.h create mode 100644 ports-okl4/src/app/xev_track/main.cc create mode 100644 ports-okl4/src/app/xev_track/target.mk create mode 100644 ports-okl4/src/lib/oklx/genode/genode_audio.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_block.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_config.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_exit.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_framebuffer.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_input.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_lock.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_memory.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_net.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_open.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_printf.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_sleep.cc create mode 100644 ports-okl4/src/lib/oklx/genode/genode_threads.cc create mode 100644 ports-okl4/src/lib/oklx/iguana/iguana_eas.cc create mode 100644 ports-okl4/src/lib/oklx/iguana/iguana_hardware.cc create mode 100644 ports-okl4/src/lib/oklx/iguana/iguana_memsection.cc create mode 100644 ports-okl4/src/lib/oklx/iguana/iguana_pd.cc create mode 100644 ports-okl4/src/lib/oklx/iguana/iguana_thread.cc create mode 100644 ports-okl4/src/lib/oklx/iguana/iguana_tls.cc create mode 100644 ports-okl4/src/lib/oklx/include/oklx_memory_maps.h create mode 100644 ports-okl4/src/lib/oklx/include/oklx_screens.h create mode 100644 ports-okl4/src/lib/oklx/include/oklx_threads.h create mode 100644 ports-okl4/src/oklinux/main.cc create mode 100644 ports-okl4/src/oklinux/target.mk create mode 100644 ports/Makefile create mode 100644 ports/README create mode 100644 ports/doc/gdb.txt create mode 100644 ports/include/noux_session/capability.h create mode 100644 ports/include/noux_session/client.h create mode 100644 ports/include/noux_session/connection.h create mode 100644 ports/include/noux_session/noux_session.h create mode 100644 ports/include/noux_session/sysio.h create mode 100644 ports/lib/mk/fiasco_x86/gdbserver_platform.mk create mode 100644 ports/lib/mk/foc_arm/gdbserver_platform.mk create mode 100644 ports/lib/mk/foc_x86_32/gdbserver_platform.mk create mode 100644 ports/lib/mk/gdbserver_libc_support.mk create mode 100644 ports/lib/mk/gdbserver_platform.inc create mode 100644 ports/lib/mk/libc_noux.mk create mode 100644 ports/lib/mk/linux_x86_32/gdbserver_platform.mk create mode 100644 ports/lib/mk/okl4_x86/gdbserver_platform.mk create mode 100644 ports/lib/mk/pistachio_x86/gdbserver_platform.mk create mode 100644 ports/lib/mk/x86_32/gdbserver_platform_x86_32.inc create mode 100644 ports/mk/noux.mk create mode 100644 ports/ports/arora.mk create mode 100644 ports/ports/bash.mk create mode 100644 ports/ports/binutils.mk create mode 100644 ports/ports/coreutils.mk create mode 100644 ports/ports/dash.mk create mode 100644 ports/ports/findutils.mk create mode 100644 ports/ports/gcc.mk create mode 100644 ports/ports/gdb.mk create mode 100644 ports/ports/make.mk create mode 100644 ports/ports/vancouver.mk create mode 100644 ports/ports/vim.mk create mode 100644 ports/run/debug_nitpicker.run create mode 100644 ports/run/gdb_monitor.run create mode 100644 ports/run/noux.run create mode 100644 ports/run/noux_vim.run create mode 100644 ports/run/vancouver.run create mode 100644 ports/src/app/arora/arora.pro create mode 100644 ports/src/app/arora/arora_bookmarks.patch create mode 100644 ports/src/app/arora/arora_disable_adblock.patch create mode 100644 ports/src/app/arora/arora_disable_program_exit.patch create mode 100644 ports/src/app/arora/arora_genode.patch create mode 100644 ports/src/app/arora/arora_move_window.patch create mode 100644 ports/src/app/arora/arora_nitpicker_plugin.patch create mode 100644 ports/src/app/arora/arora_startpage.patch create mode 100644 ports/src/app/arora/demo/bg.png create mode 100644 ports/src/app/arora/demo/bg_content.png create mode 100644 ports/src/app/arora/demo/bg_top.png create mode 100644 ports/src/app/arora/demo/busybox.html create mode 100644 ports/src/app/arora/demo/demo.html create mode 100644 ports/src/app/arora/demo/http_block.png create mode 100644 ports/src/app/arora/demo/intro.html create mode 100644 ports/src/app/arora/demo/nitpicker.html create mode 100644 ports/src/app/arora/demo/nitpicker_plugin.png create mode 100644 ports/src/app/arora/demo/tetrix.html create mode 100644 ports/src/app/arora/demo/tinycore.html create mode 100644 ports/src/app/arora/demo/title_bg.png create mode 100644 ports/src/app/arora/demo_html.qrc create mode 100644 ports/src/app/arora/qwebplugins/nitpicker/nitpicker.pri create mode 100644 ports/src/app/arora/qwebplugins/nitpicker/nitpickerplugin.cpp create mode 100644 ports/src/app/arora/qwebplugins/nitpicker/nitpickerplugin.h create mode 100644 ports/src/app/arora/qwebplugins/nitpicker/nitpickerpluginwidget.cpp create mode 100644 ports/src/app/arora/qwebplugins/nitpicker/nitpickerpluginwidget.h create mode 100644 ports/src/app/arora/target.mk create mode 100644 ports/src/app/gdb_monitor/app_child.h create mode 100644 ports/src/app/gdb_monitor/append_list.h create mode 100644 ports/src/app/gdb_monitor/cpu_root.h create mode 100644 ports/src/app/gdb_monitor/cpu_session_component.cc create mode 100644 ports/src/app/gdb_monitor/cpu_session_component.h create mode 100644 ports/src/app/gdb_monitor/dataspace_object.h create mode 100644 ports/src/app/gdb_monitor/gdb_stub_thread.cc create mode 100644 ports/src/app/gdb_monitor/gdb_stub_thread.h create mode 100644 ports/src/app/gdb_monitor/gdbserver/config.h create mode 100644 ports/src/app/gdb_monitor/gdbserver/genode-low.cc create mode 100644 ports/src/app/gdb_monitor/gdbserver/genode-low.h create mode 100644 ports/src/app/gdb_monitor/gdbserver_genode.patch create mode 100644 ports/src/app/gdb_monitor/main.cc create mode 100644 ports/src/app/gdb_monitor/ram_root.h create mode 100644 ports/src/app/gdb_monitor/ram_session_component.cc create mode 100644 ports/src/app/gdb_monitor/ram_session_component.h create mode 100644 ports/src/app/gdb_monitor/rm_root.h create mode 100644 ports/src/app/gdb_monitor/rm_session_component.cc create mode 100644 ports/src/app/gdb_monitor/rm_session_component.h create mode 100644 ports/src/app/gdb_monitor/rom.h create mode 100644 ports/src/app/gdb_monitor/signal_handler_thread.cc create mode 100644 ports/src/app/gdb_monitor/signal_handler_thread.h create mode 100644 ports/src/app/gdb_monitor/target.mk create mode 100644 ports/src/app/gdb_monitor/thread_info.h create mode 100644 ports/src/lib/gdbserver_libc_support/elf/common.h create mode 100644 ports/src/lib/gdbserver_libc_support/gdbserver_libc_support.c create mode 100644 ports/src/lib/gdbserver_libc_support/gdbserver_libc_support.h create mode 100644 ports/src/lib/gdbserver_libc_support/sys/procfs.h create mode 100644 ports/src/lib/gdbserver_libc_support/sys/ptrace.h create mode 100644 ports/src/lib/gdbserver_libc_support/sys/vfs.h create mode 100644 ports/src/lib/gdbserver_platform/fiasco_x86_low.cc create mode 100644 ports/src/lib/gdbserver_platform/foc_arm_low.cc create mode 100644 ports/src/lib/gdbserver_platform/foc_x86_32_low.cc create mode 100644 ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc create mode 100644 ports/src/lib/gdbserver_platform/gdbserver_platform_helper.h create mode 100644 ports/src/lib/gdbserver_platform/i386.h create mode 100644 ports/src/lib/gdbserver_platform/linux_x86_32_low.cc create mode 100644 ports/src/lib/gdbserver_platform/okl4_x86_low.cc create mode 100644 ports/src/lib/gdbserver_platform/pistachio_x86_low.cc create mode 100644 ports/src/lib/gdbserver_platform/reg-arm.h create mode 100644 ports/src/lib/libc_noux/plugin.cc create mode 100644 ports/src/lib/libc_noux/target.mk create mode 100644 ports/src/noux-pkg/bash/build.patch create mode 100644 ports/src/noux-pkg/bash/target.mk create mode 100644 ports/src/noux-pkg/binutils/build.patch create mode 100644 ports/src/noux-pkg/binutils/target.mk create mode 100644 ports/src/noux-pkg/coreutils/target.mk create mode 100644 ports/src/noux-pkg/dash/build.patch create mode 100644 ports/src/noux-pkg/dash/target.mk create mode 100644 ports/src/noux-pkg/findutils/target.mk create mode 100644 ports/src/noux-pkg/gcc/build.patch create mode 100644 ports/src/noux-pkg/gcc/target.mk create mode 100644 ports/src/noux-pkg/make/target.mk create mode 100644 ports/src/noux-pkg/vim/target.mk create mode 100644 ports/src/noux/args.h create mode 100644 ports/src/noux/child.h create mode 100644 ports/src/noux/directory_service.h create mode 100644 ports/src/noux/dummy_input_io_channel.h create mode 100644 ports/src/noux/environment.h create mode 100644 ports/src/noux/file_descriptor_registry.h create mode 100644 ports/src/noux/file_io_service.h create mode 100644 ports/src/noux/file_system.h create mode 100644 ports/src/noux/io_channel.h create mode 100644 ports/src/noux/main.cc create mode 100644 ports/src/noux/path.h create mode 100644 ports/src/noux/pwd.h create mode 100644 ports/src/noux/range_checked_index.h create mode 100644 ports/src/noux/root_file_system.h create mode 100644 ports/src/noux/shared_pointer.h create mode 100644 ports/src/noux/signal_dispatcher.h create mode 100644 ports/src/noux/tar_file_system.h create mode 100644 ports/src/noux/target.mk create mode 100644 ports/src/noux/terminal_io_channel.h create mode 100644 ports/src/noux/vfs.h create mode 100644 ports/src/noux/vfs_handle.h create mode 100644 ports/src/noux/vfs_io_channel.h create mode 100644 ports/src/noux/wake_up_notifier.h create mode 100644 ports/src/test/gdb_monitor/main.cc create mode 100644 ports/src/test/gdb_monitor/target.mk create mode 100644 ports/src/vancouver/README create mode 100644 ports/src/vancouver/boot_module_provider.h create mode 100644 ports/src/vancouver/device_model_registry.cc create mode 100644 ports/src/vancouver/device_model_registry.h create mode 100644 ports/src/vancouver/main.cc create mode 100644 ports/src/vancouver/nova_user_env.cc create mode 100644 ports/src/vancouver/service/profile.h create mode 100644 ports/src/vancouver/target.mk create mode 100644 qt4/Makefile create mode 100644 qt4/README create mode 100644 qt4/include/genode/thread_qt.h create mode 100644 qt4/include/qnitpickerviewwidget/qnitpickerviewwidget.h create mode 100644 qt4/include/qpluginwidget/qpluginwidget.h create mode 100644 qt4/include/qt4/QtCore/private/qeventdispatcher_genode_p.h create mode 100644 qt4/include/qt4/QtCore/qconfig-genode.h create mode 100644 qt4/include/qt4/QtCore/qconfig.h create mode 100644 qt4/include/qt4/QtGui/private/qwindowsurface_nitpicker_qws_p.h create mode 100644 qt4/include/qt4/QtGui/qinputnitpicker_qws.h create mode 100644 qt4/include/qt4/QtGui/qkbdnitpicker_qws.h create mode 100644 qt4/include/qt4/QtGui/qkbdpc101_qws.h create mode 100644 qt4/include/qt4/QtGui/qmousenitpicker_qws.h create mode 100644 qt4/include/qt4/QtGui/qscreennitpicker_qws.h create mode 100644 qt4/lib/import/import-qt4.mk create mode 100644 qt4/lib/import/import-qt_core.mk create mode 100644 qt4/lib/import/import-qt_gui.mk create mode 100644 qt4/lib/import/import-qt_javascriptcore.mk create mode 100644 qt4/lib/import/import-qt_jscore.mk create mode 100644 qt4/lib/import/import-qt_network.mk create mode 100644 qt4/lib/import/import-qt_script.mk create mode 100644 qt4/lib/import/import-qt_scriptclassic.mk create mode 100644 qt4/lib/import/import-qt_scripttools.mk create mode 100644 qt4/lib/import/import-qt_svg.mk create mode 100644 qt4/lib/import/import-qt_ui_tools.mk create mode 100644 qt4/lib/import/import-qt_webcore.mk create mode 100644 qt4/lib/import/import-qt_xml.mk create mode 100644 qt4/lib/mk/dejavusans.mk create mode 100644 qt4/lib/mk/qgif.mk create mode 100644 qt4/lib/mk/qjpeg.mk create mode 100644 qt4/lib/mk/qnitpickerviewwidget.mk create mode 100644 qt4/lib/mk/qpluginwidget.mk create mode 100644 qt4/lib/mk/qt_core.mk create mode 100644 qt4/lib/mk/qt_gui.mk create mode 100644 qt4/lib/mk/qt_jscore.mk create mode 100644 qt4/lib/mk/qt_network.mk create mode 100644 qt4/lib/mk/qt_script.mk create mode 100644 qt4/lib/mk/qt_script46.mk create mode 100644 qt4/lib/mk/qt_scriptclassic.mk create mode 100644 qt4/lib/mk/qt_scripttools.mk create mode 100644 qt4/lib/mk/qt_svg.mk create mode 100644 qt4/lib/mk/qt_ui_tools.mk create mode 100644 qt4/lib/mk/qt_webcore.mk create mode 100644 qt4/lib/mk/qt_xml.mk create mode 100644 qt4/run/qt4.run create mode 100644 qt4/src/app/examples/calculatorform/calculatorform.cpp create mode 100644 qt4/src/app/examples/calculatorform/calculatorform.h create mode 100644 qt4/src/app/examples/calculatorform/calculatorform.pro create mode 100644 qt4/src/app/examples/calculatorform/calculatorform.ui create mode 100644 qt4/src/app/examples/calculatorform/font.qrc create mode 100644 qt4/src/app/examples/calculatorform/main.cpp create mode 100644 qt4/src/app/examples/calculatorform/target.mk create mode 100644 qt4/src/app/examples/previewer/target.mk create mode 100644 qt4/src/app/examples/tetrix/font.qrc create mode 100644 qt4/src/app/examples/tetrix/main.cpp create mode 100644 qt4/src/app/examples/tetrix/target.mk create mode 100644 qt4/src/app/examples/tetrix/tetrix.pro create mode 100644 qt4/src/app/examples/tetrix/tetrix.qrc create mode 100644 qt4/src/app/examples/tetrix/tetrixboard.cpp create mode 100644 qt4/src/app/examples/tetrix/tetrixboard.h create mode 100644 qt4/src/app/examples/tetrix/tetrixboard.js create mode 100644 qt4/src/app/examples/tetrix/tetrixpiece.js create mode 100644 qt4/src/app/examples/tetrix/tetrixwindow.js create mode 100644 qt4/src/app/examples/tetrix/tetrixwindow.ui create mode 100644 qt4/src/app/examples/textedit/target.mk create mode 100644 qt4/src/app/qt_launchpad/child_entry.cpp create mode 100644 qt4/src/app/qt_launchpad/child_entry.h create mode 100644 qt4/src/app/qt_launchpad/child_entry.ui create mode 100644 qt4/src/app/qt_launchpad/font.qrc create mode 100644 qt4/src/app/qt_launchpad/kbyte_loadbar.cpp create mode 100644 qt4/src/app/qt_launchpad/kbyte_loadbar.h create mode 100644 qt4/src/app/qt_launchpad/launch_entry.cpp create mode 100644 qt4/src/app/qt_launchpad/launch_entry.h create mode 100644 qt4/src/app/qt_launchpad/launch_entry.ui create mode 100644 qt4/src/app/qt_launchpad/main.cpp create mode 100644 qt4/src/app/qt_launchpad/qt_launchpad.cpp create mode 100644 qt4/src/app/qt_launchpad/qt_launchpad.h create mode 100644 qt4/src/app/qt_launchpad/qt_launchpad.pro create mode 100644 qt4/src/app/qt_launchpad/qt_launchpad.ui create mode 100644 qt4/src/app/qt_launchpad/target.mk create mode 100644 qt4/src/app/tmpl/target.mk.example create mode 100644 qt4/src/lib/dejavusans/dejavusans.qrc create mode 100644 qt4/src/lib/qnitpickerviewwidget/qnitpickerviewwidget.cpp create mode 100644 qt4/src/lib/qpluginwidget/qpluginwidget.cpp create mode 100644 qt4/src/lib/qt4/mkspecs/genode-g++/qmake.conf create mode 100644 qt4/src/lib/qt4/mkspecs/genode-g++/qplatformdefs.h create mode 100644 qt4/src/lib/qt4/mkspecs/qws/genode-x86-g++/qmake.conf create mode 100644 qt4/src/lib/qt4/mkspecs/qws/genode-x86-g++/qplatformdefs.h create mode 100644 qt4/src/lib/qt4/previewer_example.patch create mode 100644 qt4/src/lib/qt4/qt4_genode.patch create mode 100644 qt4/src/lib/qt4/qt4_include_time_h.patch create mode 100644 qt4/src/lib/qt4/qt4_lwip_connect_semantics_adaption.patch create mode 100644 qt4/src/lib/qt4/qt4_no_exit_on_window_close.patch create mode 100644 qt4/src/lib/qt4/qt4_no_search_for_resolv_lib.patch create mode 100644 qt4/src/lib/qt4/qt4_no_separate_host_lookup_threads.patch create mode 100644 qt4/src/lib/qt4/qt4_nonblocking_sockets.patch create mode 100644 qt4/src/lib/qt4/qt4_renderwidget.patch create mode 100644 qt4/src/lib/qt4/qt4_virtual_deletelater.patch create mode 100644 qt4/src/lib/qt4/src/corelib/global/qconfig.cpp create mode 100644 qt4/src/lib/qt4/src/corelib/io/qprocess_genode.cpp create mode 100644 qt4/src/lib/qt4/src/corelib/kernel/qeventdispatcher_genode.cpp create mode 100644 qt4/src/lib/qt4/src/corelib/thread/qmutex_genode.cpp create mode 100644 qt4/src/lib/qt4/src/corelib/thread/qthread_genode.cpp create mode 100644 qt4/src/lib/qt4/src/corelib/thread/qwaitcondition_genode.cpp create mode 100644 qt4/src/lib/qt4/src/gui/embedded/qinputnitpicker_qws.cpp create mode 100644 qt4/src/lib/qt4/src/gui/embedded/qkbdnitpicker_qws.cpp create mode 100644 qt4/src/lib/qt4/src/gui/embedded/qkbdpc101_qws.cpp create mode 100644 qt4/src/lib/qt4/src/gui/embedded/qmousenitpicker_qws.cpp create mode 100644 qt4/src/lib/qt4/src/gui/embedded/qscreennitpicker_qws.cpp create mode 100644 qt4/src/lib/qt4/src/gui/painting/qwindowsurface_nitpicker_qws.cpp create mode 100644 qt4/src/lib/qt4/textedit_example.patch create mode 100644 qt4/src/lib/qt_main/qt_main.cc create mode 100644 qt4/tool/Makefile create mode 100644 qt4/tool/qmake/Makefile create mode 100644 tool/README create mode 100755 tool/autopilot create mode 100755 tool/beautify create mode 100644 tool/boot/chain.c32 create mode 100644 tool/boot/isolinux.bin create mode 100644 tool/boot/isolinux.cfg create mode 100644 tool/boot/stage2_eltorito create mode 100644 tool/builddir/build.mk create mode 100644 tool/builddir/etc/README create mode 100644 tool/builddir/etc/build.conf.codezero_vpb926 create mode 100644 tool/builddir/etc/build.conf.drivers_x86 create mode 100644 tool/builddir/etc/build.conf.fiasco_x86 create mode 100644 tool/builddir/etc/build.conf.foc_pbxa9 create mode 100644 tool/builddir/etc/build.conf.foc_vea9x4 create mode 100644 tool/builddir/etc/build.conf.foc_x86_32 create mode 100644 tool/builddir/etc/build.conf.foc_x86_64 create mode 100644 tool/builddir/etc/build.conf.generic create mode 100644 tool/builddir/etc/build.conf.linux_x86 create mode 100644 tool/builddir/etc/build.conf.mb_ml507 create mode 100644 tool/builddir/etc/build.conf.mb_s3a_starter_kit create mode 100644 tool/builddir/etc/build.conf.nova_x86 create mode 100644 tool/builddir/etc/build.conf.okl4_x86 create mode 100644 tool/builddir/etc/build.conf.pistachio_x86 create mode 100644 tool/builddir/etc/build.conf.ports-foc create mode 100644 tool/builddir/etc/build.conf.ports-okl4 create mode 100644 tool/builddir/etc/build.conf.qemu_no_kvm create mode 100755 tool/create_builddir create mode 100755 tool/create_iso create mode 100755 tool/fix_include_ifndef create mode 100644 tool/libgcc_libc_stub.h create mode 100755 tool/parse_cxx create mode 100755 tool/run create mode 100755 tool/tool_chain diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..d8cf7d463 --- /dev/null +++ b/LICENSE @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/README b/README index 042bbace8..a0d913f21 100644 --- a/README +++ b/README @@ -1,4 +1,180 @@ -Genode OS Framework -This is just the initial version without any code yet. We're on the -way to migrate the current released version into Git. + ================================= + Genode Operating System Framework + ================================= + + +This is the source tree of the reference implementation of the Genode OS +architecture. For a general overview about the architecture, please refer to +the project's official website: + +:Official project website for the Genode OS Framework: + + [http://genode.org/documentation/general-overview] + +The current implementation can be compiled for 8 different kernels: Linux, +L4ka::Pistachio, L4/Fiasco, OKL4, NOVA, Fiasco.OC, Codezero, and a custom +kernel for the MicroBlaze architecture. Whereas the Linux version serves us as +development vehicle and enables us to rapidly develop the generic parts of the +system, the actual target platforms of the framework are microkernels. There +is no "perfect" microkernel - and neither should there be one. If a microkernel +pretended to be fit for all use cases, it wouldn't be "micro". Hence, all +microkernels differ in terms of their respective features, complexity, and +supported hardware architectures. + +Genode allows the use of each of the kernels listed above with a rich set of +device drivers, protocol stacks, libraries, and applications in a uniform way. +For developers, the framework provides an easy way to target multiple different +kernels instead of tying the development to a particular kernel technology. For +kernel developers, Genode contributes advanced workloads, stress-testing their +kernel, and enabling a variety of application use cases that would not be +possible otherwise. For users and system integrators, it enables the choice of +the kernel that fits best with the requirements at hand for the particular +usage scenario. + + +Directory overview +################## + +The Genode source tree is composed of the following subdirectories: + +:'doc': + + This directory contains general documentation. Please consider the following + document for a quick guide to get started with the framework: + + ! doc/getting_started.txt + + If you are curious about the ready-to-use components that come with the + framework, please review the components overview: + + ! doc/components.txt + +:'base': + + This directory contains the source-code repository of the fundamental + frameworks and interfaces of Genode. Furthermore, it contains the generic + parts of core. + +:'os': + + This directory contains the non-base OS components such as the init process, + device drivers, and basic system services. + +:'demo': + + This directory contains the source-code repository of various services and + applications that we use for demonstration purposes. For example, a graphical + application launcher called Launchpad and the Scout tutorial browser. + +:'base-': + These directories contain platform-specific source-code repositories + complementing the 'base' repository. The following platforms are supported: + + :'linux': + Linux kernel (both x86_32 and x86_64) + + :'pistachio': + L4ka::Pistachio kernel developed at University of Karlsruhe. + See [http://genode.org/community/wiki/GenodeOnL4kaPistachio] + + :'fiasco': + L4/Fiasco kernel developed at University of Technology Dresden. + See [http://genode.org/community/wiki/GenodeOnL4Fiasco] + + :'foc': + Fiasco.OC is a modernized version of the Fiasco microkernel with a + completely revised kernel interface fostering capability-based + security. It is not compatible with L4/Fiasco. + See [http://genode.org/community/wiki/GenodeOnFiascoOC] + + :'okl4': + OKL4 kernel (x86_32 and ARM) developed at Open-Kernel-Labs. + See [http://genode.org/community/wiki/GenodeOnOKL4] + + :'nova': + NOVA hypervisor developed at University of Technology Dresden + See [http://genode.org/community/wiki/GenodeOnNOVA] + + :'codezero': + Codezero microkernel developed by B-Labs + See [http://genode.org/community/wiki/GenodeOnCodezero] + + :'mb': + Support for running Genode natively on the MicroBlaze softcore CPU. + See [http://genode.org/community/wiki/GenodeOnMicroBlaze] + + :'host': + Pseudo platform documenting the interface between the generic and + platform-specific parts of the base framework. This is not a functional + base platform. + +:'tool': + + Source-code management tools and scripts. Please refer to the README file + contained in the directory. + +:'hello_tutorial': + + Tutorial for creating a simple client-server scenario with Genode. This + repository includes documentation and the complete source code. + +:'libports': + + This source-code repository contains ports of popular open-source libraries + to Genode, most importantly the C library. The repository contains no + upstream source code but means to download the code and adapt it to Genode. + For instructions about how to use this mechanism, please consult the README + file at the top level of the repository. + +:'linux_drivers': + + This source-code repository contains the device driver environment for + executing Linux device drivers natively on Genode. + +:'dde_ipxe': + + This source-code repository contains the device driver environment for + executing drivers of the iPXE project. + +:'qt4': + + This source-code repository contains the Genode version of Qt4 framework. + Please find more information about using Qt4 with Genode in the repository's + 'README' file. + +:'ports': + + This source-code repository hosts ports of 3rd-party applications to + Genode. The repository does not contain upstream source code but provides + a mechanism for downloading the official source distributions and adapt + them to the Genode environment. The used mechanism is roughly the same + as used for the 'libports' repository. Please consult 'libports/README' + for further information. + +:'ports-': + + These platform-specific source-code repositories contain software that + capitalizes special features of the respective kernel platform. I.e., + for the OKL4 base platform, a port of OKLinux is provided in 'ports-okl4'. + For the Fiasco.OC platform, 'ports-foc' hosts a port of the L4Linux + kernel. For further information, please refer to the README file at the + top level of the respective repository. + +:'gems': + + This source-code repository contains Genode applications that use + both native Genode interfaces as well as features of other high-level + repositories, in particular shared libraries provided by 'libports'. + + +Contact +####### + +The best way to get in touch with Genode developers and users is the project's +mailing list. Please feel welcome to join in! + +:Genode Mailing Lists: + + [http://genode.org/community/mailing-lists] + diff --git a/base-codezero/Makefile b/base-codezero/Makefile new file mode 100644 index 000000000..f04ea5e7d --- /dev/null +++ b/base-codezero/Makefile @@ -0,0 +1,44 @@ +# +# \brief Download and prepare the Codezero kernel +# \author Norman Feske +# \date 2011-08-05 +# + +VERBOSE ?= @ +ECHO = @echo +GIT_URL = git://git.l4dev.org/codezero.git +GIT_REV = 6fa4884a5a1cf6207372f69ae01e5faa6d5a39c8 +CONTRIB_DIR = contrib +PATCHES = $(shell find patches -name *.patch) + +# +# Print help information by default +# +help:: + +prepare: $(CONTRIB_DIR) + +help:: + $(ECHO) + $(ECHO) "Check out upstream source code of the Codezero kernel" + $(ECHO) + $(ECHO) "The source code will be located at the '$(CONTRIB_DIR)/' directory." + $(ECHO) + $(ECHO) "--- available commands ---" + $(ECHO) "prepare - checkout upstream source codes" + $(ECHO) "clean - remove upstream source codes" + $(ECHO) + +$(CONTRIB_DIR)/.git: + $(VERBOSE)git clone $(GIT_URL) $(CONTRIB_DIR) + +$(CONTRIB_DIR): $(CONTRIB_DIR)/.git + $(VERBOSE)cd $(CONTRIB_DIR); git reset --hard $(GIT_REV) + $(ECHO) "applying patches to '$(CONTRIB_DIR)/'" + $(VERBOSE)for i in $(PATCHES); do patch -d $@ -p1 < $$i; done + +.PHONY: $(CONTRIB_DIR) + +clean:: + $(VERBOSE)rm -rf $(CONTRIB_DIR) + diff --git a/base-codezero/README b/base-codezero/README new file mode 100644 index 000000000..c2d8da087 --- /dev/null +++ b/base-codezero/README @@ -0,0 +1,3 @@ +This repository contains the port of Genode to the Codezero microkernel +For instructions about using Genode with Codezero, please refer to +'doc/codezero.txt'. diff --git a/base-codezero/config/vpb926.cml b/base-codezero/config/vpb926.cml new file mode 100644 index 000000000..2629c72d0 --- /dev/null +++ b/base-codezero/config/vpb926.cml @@ -0,0 +1,240 @@ +# +# Automatically generated, don't edit +# +# Generated on: furnace +# At: Fri, 05 Aug 2011 21:48:00 +0000 +# Linux version 2.6.32-33-generic (buildd@rothera) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #70-Ubuntu SMP Thu Jul 7 21:09:46 UTC 2011 + +# +# 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=n +CONFIG_CONTAINERS=1 + +# +# Container 0 Parameters +# + +# +# Container 0 Type +# +CONFIG_CONT0_TYPE_BAREMETAL=y +CONFIG_CONT0_TYPE_POSIX=n +CONFIG_CONT0_TYPE_LINUX=n + + +# +# Container 0 Options +# +CONFIG_CONT0_OPT_NAME="empty0" + +# +# Baremetal Project Type +# +CONFIG_CONT0_BAREMETAL_PROJ_EMPTY=y +CONFIG_CONT0_BAREMETAL_PROJ_HELLO_WORLD=n +CONFIG_CONT0_BAREMETAL_PROJ_THREADS_DEMO=n +CONFIG_CONT0_BAREMETAL_PROJ_TEST_SUITE=n +CONFIG_CONT0_BAREMETAL_PROJ_UART_SERVICE=n +CONFIG_CONT0_BAREMETAL_PROJ_TIMER_SERVICE=n +CONFIG_CONT0_BAREMETAL_PROJ_KMI_SERVICE=n +CONFIG_CONT0_BAREMETAL_PROJ_MUTEX_DEMO=n +CONFIG_CONT0_BAREMETAL_PROJ_IPC_DEMO=n + + +# +# Container 0 Pager Linker Parameters +# +CONFIG_CONT0_PAGER_LMA=0x40000 +CONFIG_CONT0_PAGER_VMA=0x100000 + + +# +# Container 0 Pager Physical Memory Regions (Capabilities) +# +CONFIG_CONT0_PAGER_PHYSMEM_REGIONS=1 +CONFIG_CONT0_PAGER_PHYS0_START=0x40000 +CONFIG_CONT0_PAGER_PHYS0_END=0x4000000 + + +# +# Container 0 Pager Virtual Memory Regions (Capabilities) +# +CONFIG_CONT0_PAGER_VIRTMEM_REGIONS=1 +CONFIG_CONT0_PAGER_VIRT0_START=0x0 +CONFIG_CONT0_PAGER_VIRT0_END=0x50000000 + + +# +# 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=y +CONFIG_SUBARCH_V7=n +CONFIG_SUBARCH_V6=n +CONFIG_CONT0_PAGER_LOAD_ADDR=0x40000 +CONFIG_CONT0_PAGER_VIRT_ADDR=0x100000 +CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000 +CONFIG_CONT0_START_PC_ADDR=0x100000 +CONFIG_CONT1_START_PC_ADDR=0xb0000000 +# +# That's all, folks! diff --git a/base-codezero/doc/codezero.txt b/base-codezero/doc/codezero.txt new file mode 100644 index 000000000..30bd482a6 --- /dev/null +++ b/base-codezero/doc/codezero.txt @@ -0,0 +1,274 @@ + + ================================== + Genode on the Codezero microkernel + ================================== + + + Norman Feske + + +Codezero is a microkernel primarily targeted at ARM-based embedded systems. +It is developed by the British company B-Labs. + +:B-Labs website: + + [http://b-labs.co.uk] + +The Codezero kernel was first made publicly available in summer 2009. The +latest version, documentation, and community resources are available at the +project website: + +:Codezero project website: + + [http://l4dev.org] + +As highlighted by the name of the project website, the design of the kernel is +closely related to the family of L4 microkernels. In short, the kernel provides +a minimalistic set of functionality for managing address spaces, threads, and +communication between threads, but leaves complicated policy and device access +to user-level components. + + +Using Genode with Codezero +########################## + +For using Codezero, please ensure to have Git, SCons, and Python installed as +these tools are required for downloading and building the kernel. Furthermore, +you will need to install the tool chain for ARM. For instructions on how to +download and install the tool chain, please refer to: + +:[http://genode.org/download/tool-chain]: + Genode tool-chain + +To download the Codezero kernel and integrate it with Genode, issue + +! make prepare + +from the 'base-codezero/' directory. The Codezero kernel is fully supported by +Genode's run mechanism. Therefore, you can run Genode scenarios using Qemu +directly from the build directory. For a quick test, let's create a build +directory for Codezero on the VersatilePB926 platform using Genode's +'create_builddir' tool: + +! /tool/create_builddir codezero_vpb926 BUILD_DIR= + +To execute the graphical Genode demo, change to the new created build directory +and issue: + +! make run/demo + + +Characteristics of the kernel +############################# + +To put Codezero in relation to other L4 kernels, here is a quick summary on the +most important design aspects as implemented with the version 0.3, and on how +our port of Genode relates to them: + +* In the line of the original L4 interface, the kernel uses global name spaces + for kernel objects such as threads and address spaces. + +* For the interaction between a user thread and the kernel, the concept of + user-level thread-control blocks (UTCB) is used. A UTCB is a small + thread-specific region in the thread's virtual address space, which is + always mapped. Hence the access to the UTCB can never raise a page fault, + which makes it perfect for the kernel to access system-call arguments, + in particular IPC payload copied from/to user threads. In contrast to other + L4 kernels, the location of UTCBs within the virtual address space is managed + by the user land. + + On Genode, core keeps track of the UTCB locations for all user threads. + This way, the physical backing store for the UTCB can be properly accounted + to the corresponding protection domain. + +* The kernel provides three kinds of synchronous inter-process communication + (IPC): Short IPC carries payload in CPU registers only. Full IPC copies + message payload via the UTCBs of the communicating parties. Extended IPC + transfers a variable-sized message from/to arbitrary locations of the + sender/receiver address spaces. During an extended IPC, page fault may + occur. + + Genode solely relies on extended IPC, leaving the other IPC mechanisms to + future optimizations. + +* The scheduling of threads is based on hard priorities. Threads with the + same priority are executed in a round-robin fashion. The kernel supports + time-slice-based preemption. + + Genode does not support Codezero priorities yet. + +* The original L4 interface leaves open the question on how to manage + and account kernel resources such as the memory used for page tables. + Codezero makes the accounting of such resources explicit, enables the + user-land to manage them in a responsible way, and prevent kernel-resource + denial-of-service problems. + +* In contrast to the original L4.v2 and L4.x0 interfaces, the kernel provides + no time source in the form of IPC timeouts to the user land. A time source + must be provided by a user-space timer driver. Genode employs such a timer + services on all platforms so that it is not effected by this limitation. + +In several ways, Codezero goes beyond the known L4 interfaces. The most +noticeable addition is the support for so-called containers. A container is +similar to a virtual machine. It is an execution environment that holds a set +of physical resources such as RAM and devices. The number of containers and the +physical resources assigned to them is static and is to be defined at build +time. The code executed inside a container can be roughly classified into two +cases. First, there are static programs that require strong isolation from the +rest of the system but no classical operating-system infrastructure, for +example special-purpose telecommunication stacks or cryptographic functionality +of an embedded device. Second, there a kernel-like workload, which use the L4 +interface to substructure the container into address spaces, for example a +paravirtualized Linux kernel that uses Codezero address spaces to protect Linux +processes. Genode runs inside a container and facilitates Codezero's L4 +interface to implement its multi-server architecture. + + +Behind the scenes +################# + +The 'make prepare' mechanism checks out the kernel source code from the +upstream Git repository to 'base-codezero/contrib'. When building the kernel +from within a Genode build directory via 'make kernel', this directory won't be +touched by the Genode build system. Instead, a snapshot of the 'contrib' +directory is taken to '/kernel/codezero'. This is the place where +the Codezero configuration and build processes are executed. By working with a +build-directory-local snapshot, we ensure that the source tree remains +untouched at all times. After having taken the snapshot, the Codezero kernel is +configured using a configuration template specific for the hardware platform. +The configuration comes in the form of a CML file located at +'base-codezero/config/'. There is one CML file per supported platform named +'.cml'. The configured Codezero build directory will reside at +'/kernel/codezero/build/'. Finally, the Codezero build system is +invoked to build the kernel. + +The two stages of building Codezero +=================================== + +The Codezero build system always performs the compilation of the kernel and the +so-called containers as well as the integration of all these components into a +final ELF image as one operation. When building just the kernel via 'make +kernel', the final image will contain the default container0 that comes with +the Codezero distribution. For integrating Genode into the final image, the +content of the container0 must be replaced by the Genode binaries followed by +another execution of 'kernel/codezero/build.py'. Now, the single-image will be +re-created, including the Genode binaries. When using Genode's run mechanism, +these steps are automated for you. For reference, please review the Codezero +run environment at 'base-codezero/run/env'. + +By first building the kernel with Codezero's default container ('make kernel') +and later replacing the container's content with Genode binaries, we +optimize the work flow for building Genode components. The kernel is compiled +only once, but the (quick) re-linking of the final image is done every time a +run script is executed. + +In the run environment, you will see that we forcefully remove a file called +'cinfo.c' from the build-directory-local snapshot of the Codezero source tree. +This file is generated automatically by the Codezero build system and linked +against the kernel. It contains the parameters of the containers executed on +the kernel. Because we change the content of container0 each time when +executing a run script, those parameter change. So we have to enforce to +re-generation of the 'cinfo.c' file. + +How Genode ROM modules are passed into the final image +====================================================== + +The Codezero build system picks up any ELF files residing the container's +directory wheres the file called 'main.elf' is considered to be the roottask +(in Codezero speak called pager) of the container. For Genode, 'main.elf' +corresponds to the core executable. All other boot modules are merged into an +ELF file, which we merely use as a container for these binary data. This ELF +file is linked such that it gets loaded directly after the core image (this is +how core finds the boot modules). The process of archiving all boot modules +into the single ELF file is automated via the 'base-codezero/tool/gen_romfs' +tool. In the container's directory, the merged file is called 'modules.elf'. + +Adapting the source code of the kernel +====================================== + +For debugging and development you might desire to change the kernel code +at times. You can safely do so within the 'base-codezero/contrib/' directory. +When issuing the next 'make kernel' from the Genode build directory, your +changes will be picked up. However, when working with run scripts, the kernel +is not revisited each time. The kernel gets built only once if the +'/kernel' directory does not exist, yet. If you work on the kernel +source tree and wish to conveniently test the kernel with a run script, use + +! make kernel run/ + +This way, you make sure to rebuild the kernel prior executing the steps +described in the run script. + +Tweaking the kernel configuration +================================= + +The kernel configuration can be tweaked within '/kernel/codezero'. +Just change to this directory and issue './build.py -C'. The next time you +build the kernel via 'make kernel' your configuration will be applied. +If you want to conserve your custom configuration, just copy the file +'/kernel/codezero/build/config.cml'. + +Parameters of 'vpb926.cml' explained +==================================== + +The default configuration for the VersatilePB926 platform as found at +'base-codzero/config/vpb926.cml' is paramaterized as follows: + +:Default pager parameters: +! 0x40000 Pager LMA +! 0x100000 Pager VMA +These values are important because they are currently hard-wired in the +linker script used by Genode. If you need to adopt these values, make +sure to also update the Genode linker script located at +'base-codezero/src/platform/genode.ld'. + +:Physical Memory Regions: +! 1 Number of Physical Regions +! 0x40000 Physical Region 0 Start Address +! 0x4000000 Physical Region 0 End Address +We only use 64MB of memory. The physical memory between 0 and 0x40000 is +used by the kernel. + +:Virtual Memory Regions: +! 1 Number of Virtual Regions +! 0x0 Virtual Region 0 Start Address +! 0x50000000 Virtual Region 0 End Address +It is important to choose the end address such that the virtual memory +covers the thread context area. The context area is defined at +'base/include/base/thread.h'. + + +Limitations +########### + +At the current stage, the Genode version for Codezero is primarily geared +towards the developers of Codezero as a workload to stress their kernel. It +still has a number of limitations that would affect the real-world use: + +* Because the only platform supported out of the box by the official Codezero + source tree is the ARM-based Versatilebp board, Genode is currently tied to + this hardware platform. + +* The current timer driver at 'os/src/drivers/timer/codezero/' is a dummy + driver that just yields the CPU time instead of blocking. Is is not + suitable as time source. + +* The PL110 framebuffer driver at 'os/src/drivers/framebuffer/pl110/' + does only support the LCD display as provided by Qemu but it is not tested on + real hardware. + +* Even though Codezero provides priority-based scheduling, Genode does not + allow assigning priorities to Codezero processes, yet. + +As always, these limitations will be addressed as needed. + + +Thanks +###### + +We want to thank the main developer of Codezero Bahadir Balban for his great +responsiveness to our feature requests and questions. Without his help, the +porting effort would have taken much more effort. We hope that our framework +will be of value to the Codezero community. + + diff --git a/base-codezero/etc/specs.conf b/base-codezero/etc/specs.conf new file mode 100644 index 000000000..500de1149 --- /dev/null +++ b/base-codezero/etc/specs.conf @@ -0,0 +1 @@ +SPECS = genode diff --git a/base-codezero/include/arm/cpu/atomic.h b/base-codezero/include/arm/cpu/atomic.h new file mode 100644 index 000000000..8a73cb8a9 --- /dev/null +++ b/base-codezero/include/arm/cpu/atomic.h @@ -0,0 +1,33 @@ +/* + * \brief Atomic operations for ARM on codezero + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__ARM__CPU__ATOMIC_H_ +#define _INCLUDE__ARM__CPU__ATOMIC_H_ + +namespace Genode { + + /** + * Atomic compare and exchange + * + * This function compares the value at dest with cmp_val. + * If both values are equal, dest is set to new_val. If + * both values are different, the value at dest remains + * unchanged. + * + * \return 1 if the value was successfully changed to new_val, + * 0 if cmp_val and the value at dest differ. + */ + int cmpxchg(volatile int *dest, int cmp_val, int new_val); +} + +#endif /* _INCLUDE__ARM__CPU__ATOMIC_H_ */ diff --git a/base-codezero/include/base/ipc_msgbuf.h b/base-codezero/include/base/ipc_msgbuf.h new file mode 100644 index 000000000..cb5beae44 --- /dev/null +++ b/base-codezero/include/base/ipc_msgbuf.h @@ -0,0 +1,63 @@ +/* + * \brief IPC message buffer + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_ +#define _INCLUDE__BASE__IPC_MSGBUF_H_ + +namespace Genode { + + /** + * IPC message buffer layout + */ + class Msgbuf_base + { + protected: + + size_t _size; + char _msg_start[]; /* symbol marks start of message */ + + public: + + /* + * Begin of actual message buffer + */ + char buf[]; + + /** + * Return size of message buffer + */ + inline size_t size() const { return _size; }; + + /** + * Return address of message buffer + */ + inline void *addr() { return &_msg_start[0]; }; + + } __attribute__((aligned(4))); + + /** + * Instance of IPC message buffer with specified buffer size + */ + template + class Msgbuf : public Msgbuf_base + { + public: + + char buf[BUF_SIZE]; + + Msgbuf() { _size = BUF_SIZE; } + + } __attribute__((aligned(4))); +} + +#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */ diff --git a/base-codezero/include/base/ipc_pager.h b/base-codezero/include/base/ipc_pager.h new file mode 100644 index 000000000..d1fcbf603 --- /dev/null +++ b/base-codezero/include/base/ipc_pager.h @@ -0,0 +1,169 @@ +/* + * \brief Dummy pager support for Genode + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_PAGER_H_ +#define _INCLUDE__BASE__IPC_PAGER_H_ + +#include +#include +#include + +namespace Genode { + + class Mapping + { + private: + + addr_t _from_phys_addr; + addr_t _to_virt_addr; + size_t _num_pages; + bool _writeable; + + enum { PAGE_SIZE_LOG2 = 12 }; + + public: + + /** + * Constructor + */ + Mapping(addr_t dst_addr, addr_t src_addr, + bool write_combined, unsigned l2size = PAGE_SIZE_LOG2, + bool rw = true) + : + _from_phys_addr(src_addr), + _to_virt_addr(dst_addr), + _num_pages(1 << (l2size - PAGE_SIZE_LOG2)), + _writeable(rw) + { } + + /** + * Construct invalid mapping + */ + Mapping() : _num_pages(0) { } + + /** + * Prepare map operation + * + * No preparations are needed on Codezero because all mapping + * originate from the physical address space. + */ + void prepare_map_operation() { } + + addr_t from_phys() const { return _from_phys_addr; } + addr_t to_virt() const { return _to_virt_addr; } + size_t num_pages() const { return _num_pages; } + bool writeable() const { return _writeable; } + }; + + + /** + * Special paging server class + */ + class Ipc_pager : public Native_capability + { + private: + + Native_thread_id _last; /* faulted thread */ + addr_t _pf_addr; /* page-fault address */ + addr_t _pf_ip; /* instruction pointer of faulter */ + bool _pf_write; /* true on write fault */ + + Mapping _reply_mapping; + +// protected: +// +// /** +// * Wait for pagefault +// */ +// void _wait(); +// +// /** +// * Send page-fault reply and wait for next page fault +// */ +// void _reply_and_wait(); + + public: + + /** + * Constructor + */ + Ipc_pager(); + + /** + * Wait for a new page fault received as short message IPC + */ + void wait_for_fault(); + + /** + * Reply current page-fault and wait for a new one + */ + void reply_and_wait_for_fault(); + + /** + * Request instruction pointer of current page fault + */ + addr_t fault_ip() { return _pf_ip; } + + /** + * Request fault address of current page fault + */ + addr_t fault_addr() { return _pf_addr; } + + /** + * Set parameters for next reply + */ + void set_reply_mapping(Mapping m) { _reply_mapping = m; } + + /** + * Set destination for next reply + */ + void set_reply_dst(Native_capability pager_object) { + _last = pager_object.local_name(); } + + /** + * Answer call without sending a mapping + * + * This function is used to acknowledge local calls from one of + * core's region-manager sessions. + */ + void acknowledge_wakeup(); + + /** + * Return thread ID of last faulter + */ + Native_thread_id last() const { return _last; } + + /** + * Return badge for faulting thread + */ + unsigned long badge() const { return _last.tid; } + + /** + * Return true if page fault was a write fault + */ + bool is_write_fault() const { return _pf_write; } + + /** + * Return true if last fault was an exception + */ + bool is_exception() const + { + /* + * Reflection of exceptions is not supported on this platform. + */ + return false; + } + }; +} + +#endif /* _INCLUDE__BASE__IPC_PAGER_H_ */ diff --git a/base-codezero/include/base/native_types.h b/base-codezero/include/base/native_types.h new file mode 100644 index 000000000..abe7190b5 --- /dev/null +++ b/base-codezero/include/base/native_types.h @@ -0,0 +1,143 @@ +/* + * \brief Dummy definitions for native types used for compiling unit tests + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ +#define _INCLUDE__BASE__NATIVE_TYPES_H_ + +namespace Codezero { + + struct l4_mutex; + + enum { NILTHREAD = -1 }; +} + +namespace Genode { + + class Platform_thread; + + struct Native_thread_id + { + int tid; + + /** + * Pointer to thread's running lock + * + * Once initialized (see 'lock_helper.h'), it will point to the + * '_running_lock' field of the thread's 'Native_thread' structure, + * which is part of the thread context. This member variable is + * used by the lock implementation only. + */ + struct Codezero::l4_mutex *running_lock; + + Native_thread_id() { } + + /** + * Constructor (used as implicit constructor) + */ + Native_thread_id(int l4id) : tid(l4id), running_lock(0) { } + + Native_thread_id(int l4id, Codezero::l4_mutex *rl) : tid(l4id), running_lock(rl) { } + }; + + struct Native_thread + { + Native_thread_id l4id; + + /** + * Only used in core + * + * For 'Thread' objects created within core, 'pt' points to the + * physical thread object, which is going to be destroyed on + * destruction of the 'Thread'. + */ + Platform_thread *pt; + }; + + /** + * Empty UTCB type expected by the thread library + * + * On this kernel, UTCBs are not placed within the the context area. Each + * thread can request its own UTCB pointer using the kernel interface. + * However, we use the 'Native_utcb' member of the thread context to + * hold thread-specific data, i.e. the running lock used by the lock + * implementation. + */ + struct Native_utcb + { + private: + + /** + * Prevent construction + * + * A UTCB is never constructed, it is backed by zero-initialized memory. + */ + Native_utcb(); + + /** + * Backing store for per-thread running lock + * + * The size of this member must equal 'sizeof(Codezero::l4_mutex)'. + * Unfortunately, we cannot include the Codezero headers here. + */ + int _running_lock; + + public: + + Codezero::l4_mutex *running_lock() { + return (Codezero::l4_mutex *)&_running_lock; } + }; + + inline bool operator == (Native_thread_id t1, Native_thread_id t2) { return t1.tid == t2.tid; } + inline bool operator != (Native_thread_id t1, Native_thread_id t2) { return t1.tid != t2.tid; } + + /* + * Because Codezero does not support local names for capabilities, a Genode + * capability consists of the global thread ID and a global object ID, not + * protected by the kernel when transmitted as IPC payloads. + */ + class Native_capability + { + private: + + Native_thread_id _tid; /* global thread ID */ + int _local_name; /* global unique object ID */ + + public: + + /** + * Default constructor creates invalid capability + */ + Native_capability() + : _local_name(0) { _tid.tid = Codezero::NILTHREAD; } + + /** + * Constructor for hand-crafting capabilities + * + * This constructor is only used internally be the framework. + */ + Native_capability(Native_thread_id tid, int local_name) + : _tid(tid), _local_name(local_name) { } + + bool valid() const { return _tid.tid != Codezero::NILTHREAD; } + + int local_name() const { return _local_name; } + int dst() const { return _tid.tid; } + + Native_thread_id tid() const { return _tid; } + }; + + typedef int Native_connection_state; +} + + +#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */ diff --git a/base-codezero/include/codezero/dummies/stdio.h b/base-codezero/include/codezero/dummies/stdio.h new file mode 100644 index 000000000..e69de29bb diff --git a/base-codezero/include/codezero/dummies/string.h b/base-codezero/include/codezero/dummies/string.h new file mode 100644 index 000000000..e69de29bb diff --git a/base-codezero/include/codezero/syscalls.h b/base-codezero/include/codezero/syscalls.h new file mode 100644 index 000000000..e289825df --- /dev/null +++ b/base-codezero/include/codezero/syscalls.h @@ -0,0 +1,76 @@ +/* + * \brief Aggregate Codezero syscall bindings + * \author Norman Feske + * \date 2010-02-16 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__CODEZERO__SYSCALLS_H_ +#define _INCLUDE__CODEZERO__SYSCALLS_H_ + +/* + * Codezero headers happen to include the compiler's 'stdarg.h'. If this + * happened within the 'Codezero' namespace below, we would not be able to + * include 'stdarg.h' later on into the root namespace (stdarg's include guards + * would prevent this. Therefore, we make sure to include the file into the + * root namespace prior processing any Codezero headers. + */ +#include + +namespace Codezero { extern "C" { + +/* make Codezero includes happy */ +extern char *strncpy(char *dest, const char *src, __SIZE_TYPE__); +extern void *memcpy(void *dest, const void *src, __SIZE_TYPE__); + +/* + * Work around the problem of C++ keywords being used as + * argument names in the Codezero API headers. + */ +#define new _new_ +#define virtual _virtual_ +#define printf(A, ...) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* needed for capability.h */ +#include +#include +#include +#include + +#undef new +#undef virtual +#ifdef max +#undef max +#endif +#undef printf +} } + +namespace Codezero { + + /** + * Return thread ID of the calling thread + */ + inline int thread_myself() + { + struct task_ids ids = { 0, 0, 0 }; + l4_getid(&ids); + return ids.tid; + } +} + +#endif /* _INCLUDE__CODEZERO__SYSCALLS_H_ */ diff --git a/base-codezero/lib/mk/arm/startup.mk b/base-codezero/lib/mk/arm/startup.mk new file mode 100644 index 000000000..66f13e018 --- /dev/null +++ b/base-codezero/lib/mk/arm/startup.mk @@ -0,0 +1,9 @@ +LIBS = cxx lock l4 +SRC_S = crt0.s +SRC_CC = _main.cc +INC_DIR += $(REP_DIR)/src/platform +INC_DIR += $(BASE_DIR)/src/platform +INC_DIR += $(REP_DIR)/include/codezero/dummies + +vpath crt0.s $(BASE_DIR)/src/platform/arm +vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc)) diff --git a/base-codezero/lib/mk/arm_v5/l4.mk b/base-codezero/lib/mk/arm_v5/l4.mk new file mode 100644 index 000000000..8779d0b68 --- /dev/null +++ b/base-codezero/lib/mk/arm_v5/l4.mk @@ -0,0 +1,3 @@ +LIBS += l4_arm_v5 + +include $(REP_DIR)/lib/mk/l4.inc diff --git a/base-codezero/lib/mk/arm_v5/l4_arm_v5.mk b/base-codezero/lib/mk/arm_v5/l4_arm_v5.mk new file mode 100644 index 000000000..4ba824957 --- /dev/null +++ b/base-codezero/lib/mk/arm_v5/l4_arm_v5.mk @@ -0,0 +1,9 @@ +LIBL4_DIR = $(CODEZERO_DIR)/conts/userlibs/libl4 + +INC_DIR += $(CODEZERO_DIR)/conts/userlibs/libc/include + +SRC_C += $(notdir $(wildcard $(LIBL4_DIR)/src/arch/arm/v5/*.c)) +SRC_S += $(notdir $(wildcard $(LIBL4_DIR)/src/arch/arm/v5/*.S)) + +vpath %.c $(LIBL4_DIR)/src/arch/arm/v5 +vpath %.S $(LIBL4_DIR)/src/arch/arm/v5 diff --git a/base-codezero/lib/mk/codezero_cml.inc b/base-codezero/lib/mk/codezero_cml.inc new file mode 100644 index 000000000..93cb2386f --- /dev/null +++ b/base-codezero/lib/mk/codezero_cml.inc @@ -0,0 +1,3 @@ +ifeq ($(filter-out $(SPECS),platform_vpb926),) +CODEZERO_CML = $(REP_DIR)/config/vpb926.cml +endif diff --git a/base-codezero/lib/mk/cxx.mk b/base-codezero/lib/mk/cxx.mk new file mode 100644 index 000000000..b77ed0d06 --- /dev/null +++ b/base-codezero/lib/mk/cxx.mk @@ -0,0 +1,13 @@ +# +# Additional symbols we need to keep when using the arm-none-linux-gnueabi +# tool chain +# +KEEP_SYMBOLS += __aeabi_ldivmod __aeabi_uldivmod __dynamic_cast +KEEP_SYMBOLS += _ZN10__cxxabiv121__vmi_class_type_infoD0Ev + +# +# Override sources of the base repository with our changed version +# +vpath exception.cc $(REP_DIR)/src/base/cxx + +include $(BASE_DIR)/lib/mk/cxx.mk diff --git a/base-codezero/lib/mk/ipc.mk b/base-codezero/lib/mk/ipc.mk new file mode 100644 index 000000000..9e662a419 --- /dev/null +++ b/base-codezero/lib/mk/ipc.mk @@ -0,0 +1,4 @@ +SRC_CC = ipc.cc pager.cc +INC_DIR += $(REP_DIR)/include/codezero/dummies + +vpath %.cc $(REP_DIR)/src/base/ipc diff --git a/base-codezero/lib/mk/l4.inc b/base-codezero/lib/mk/l4.inc new file mode 100644 index 000000000..521519fe5 --- /dev/null +++ b/base-codezero/lib/mk/l4.inc @@ -0,0 +1,43 @@ +LIBL4_DIR = $(CODEZERO_DIR)/conts/userlibs/libl4 + +SRC_C += init.c irq.c mutex.c +SRC_C += arch/arm/exregs.c +SRC_S += $(addprefix arch/arm/,syscalls.S new_thread.S) +SRC_C += $(addprefix lib/,addr.c bit.c idpool.c) +SRC_C += $(addprefix lib/thread/,init.c thread.c) +SRC_C += $(addprefix lib/cap/,cap.c read.c) + +INC_DIR += $(CODEZERO_DIR)/conts/userlibs/libc/include +INC_DIR += $(CODEZERO_DIR)/conts/userlibs/libmem/include +INC_DIR += $(CODEZERO_DIR)/conts/userlibs/libmem + +vpath % $(LIBL4_DIR)/src + +# +# The libl4 source files uses macros defined in macros.h but do not +# explicitly include the 'macros.h' header file. +# +CC_OPT += -include $(LIBL4_DIR)/include/l4lib/macros.h + +# +# Resolve conflicts with built-in functions +# +CC_OPT += -fno-builtin-pow + +# +# During the compilation of the libl4 file 'thread.c', the 'l4id_t' type +# is used without prior inclusion of 'types.h'. Furthermore, 'types.h' +# has a wrong include guard, so we take care of this problem using a +# wrapper. +# +CC_OPT_lib_thread_thread += -include fix_include_types.h +CC_OPT_arch_arm_exregs += -include fix_include_types.h + +lib/thread/thread.o arch/arm/exregs.o: fix_include_types.h + +fix_include_types.h: + @echo "#include " > $@ + @echo "#define __L4LIB_ARM_TYPES_H___" >> $@ + +CC_OPT += -std=gnu99 + diff --git a/base-codezero/lib/mk/lock.mk b/base-codezero/lib/mk/lock.mk new file mode 100644 index 000000000..be1457625 --- /dev/null +++ b/base-codezero/lib/mk/lock.mk @@ -0,0 +1,7 @@ +SRC_CC = lock.cc cmpxchg.cc + +INC_DIR += $(REP_DIR)/include/codezero/dummies +INC_DIR += $(REP_DIR)/src/base/lock + +vpath lock.cc $(BASE_DIR)/src/base/lock +vpath cmpxchg.cc $(REP_DIR)/src/base/lock diff --git a/base-codezero/lib/mk/pager.mk b/base-codezero/lib/mk/pager.mk new file mode 100644 index 000000000..24f25bcf8 --- /dev/null +++ b/base-codezero/lib/mk/pager.mk @@ -0,0 +1,4 @@ +SRC_CC = pager.cc +INC_DIR += $(REP_DIR)/include/codezero/dummies + +vpath pager.cc $(REP_DIR)/src/base/pager diff --git a/base-codezero/lib/mk/pl011/core_printf.mk b/base-codezero/lib/mk/pl011/core_printf.mk new file mode 100644 index 000000000..7b10977e1 --- /dev/null +++ b/base-codezero/lib/mk/pl011/core_printf.mk @@ -0,0 +1,6 @@ +SRC_CC = core_printf.cc +LIBS = cxx console +INC_DIR += $(REP_DIR)/src/base/console/pl011 +INC_DIR += $(REP_DIR)/include/codezero/dummies + +vpath core_printf.cc $(BASE_DIR)/src/base/console diff --git a/base-codezero/lib/mk/platform.mk b/base-codezero/lib/mk/platform.mk new file mode 100644 index 000000000..a68192448 --- /dev/null +++ b/base-codezero/lib/mk/platform.mk @@ -0,0 +1,33 @@ +# +# Create prerequisites for building Genode for Codezero +# + +# +# Execute the rules in this file only at the second build stage when we know +# about the complete build settings, e.g., the 'CROSS_DEV_PREFIX'. +# +ifeq ($(called_from_lib_mk),yes) + +include $(REP_DIR)/lib/mk/codezero_cml.inc + +all: $(BUILD_BASE_DIR)/include/l4/config.h + +$(BUILD_BASE_DIR)/include/l4/config.h: $(CODEZERO_CML) + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)$(CODEZERO_DIR)/tools/cml2header.py -i $^ -o $@ + +# +# Codezero's 'macros.h' includes the file "config.h", expected to be located in +# the same directory (using #include "config.h"). However, 'config.h' is +# generated into the source tree by the Codezero configuration system. Since we +# do not want to pollute the source tree, we create a shadow copy of 'macros.h' +# in the same directory as our generated 'config.h'. +# +all: $(BUILD_BASE_DIR)/include/l4/macros.h + +$(BUILD_BASE_DIR)/include/l4/macros.h: $(CODEZERO_DIR)/include/l4/macros.h + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)ln -s $^ $@ + +endif + diff --git a/base-codezero/lib/mk/thread.mk b/base-codezero/lib/mk/thread.mk new file mode 100644 index 000000000..a0741ed3b --- /dev/null +++ b/base-codezero/lib/mk/thread.mk @@ -0,0 +1,5 @@ +SRC_CC = thread.cc thread_start.cc thread_bootstrap.cc +INC_DIR += $(REP_DIR)/include/codezero/dummies + +vpath thread_start.cc $(REP_DIR)/src/base/thread +vpath %.cc $(BASE_DIR)/src/base/thread diff --git a/base-codezero/mk/spec-codezero.mk b/base-codezero/mk/spec-codezero.mk new file mode 100644 index 000000000..3ad6ea616 --- /dev/null +++ b/base-codezero/mk/spec-codezero.mk @@ -0,0 +1,56 @@ +# +# Specifics for the Codezero kernel API +# + +# +# Read default and builddir-specific config files +# +# In these config files, we expect to find the definition of CODEZERO_DIR +# +-include $(call select_from_repositories,etc/codezero.conf) +-include $(BUILD_BASE_DIR)/etc/codezero.conf + +ifeq ($(CODEZERO_DIR),) +$(error Could not find the definition of CODEZERO_DIR in etc/codezero.conf) +endif + +# +# Convert path to absolute directory +# +absdir = $(shell readlink -f $(1)) + +# +# Headers generated within the build directory +# (see 'lib/mk/platform.mk') +# +INC_DIR += $(BUILD_BASE_DIR)/include + +# +# Codezero headers +# +CODEZERO_ABS_DIR = $(call absdir,$(CODEZERO_DIR)) + +INC_DIR += $(CODEZERO_ABS_DIR)/include +INC_DIR += $(CODEZERO_ABS_DIR)/conts/userlibs/libl4/include +INC_DIR += $(CODEZERO_ABS_DIR)/conts/userlibs/libdev/uart/include + +# +# Codezero-specific startup code +# +PRG_LIBS += startup + +# +# Allow programs to test for the Codezero kernel +# +# This is needed by the 'pl050/irq_handler.h' to handle the interrupt semantics +# of Codezero. +# +CC_OPT += -D__CODEZERO__ + +# +# Clean rules for removing the side effects of building the platform +# +clean_includes: + $(VERBOSE)rm -rf $(BUILD_BASE_DIR)/include + +cleanall: clean_includes diff --git a/base-codezero/mk/spec-codezero_arm.mk b/base-codezero/mk/spec-codezero_arm.mk new file mode 100644 index 000000000..adca798ff --- /dev/null +++ b/base-codezero/mk/spec-codezero_arm.mk @@ -0,0 +1,13 @@ +# +# Specifics for Codezero on ARM +# +SPECS += codezero + +# +# Linker options specific for ARM +# +LD_TEXT_ADDR ?= 0x02000000 + +CC_OPT += -D__ARCH__=arm + +include $(call select_from_repositories,mk/spec-codezero.mk) diff --git a/base-codezero/mk/spec-codezero_arm_v5.mk b/base-codezero/mk/spec-codezero_arm_v5.mk new file mode 100644 index 000000000..7fd40ca72 --- /dev/null +++ b/base-codezero/mk/spec-codezero_arm_v5.mk @@ -0,0 +1,9 @@ +# +# Specifics for Codezero on ARMv5 +# + +SPECS += codezero_arm + +CC_OPT += -D__SUBARCH__=v5 + +include $(call select_from_repositories,mk/spec-codezero_arm.mk) diff --git a/base-codezero/mk/spec-codezero_platform_vpb926.mk b/base-codezero/mk/spec-codezero_platform_vpb926.mk new file mode 100644 index 000000000..5145a5743 --- /dev/null +++ b/base-codezero/mk/spec-codezero_platform_vpb926.mk @@ -0,0 +1,6 @@ +SPECS += codezero_arm_v5 platform_vpb926 + +CC_OPT += -D__PLATFORM__=pb926 + +include $(call select_from_repositories,mk/spec-codezero_arm_v5.mk) +include $(call select_from_repositories,mk/spec-platform_vpb926.mk) diff --git a/base-codezero/patches/README b/base-codezero/patches/README new file mode 100644 index 000000000..4dc411106 --- /dev/null +++ b/base-codezero/patches/README @@ -0,0 +1,67 @@ +This directory contains patches of the Codezero kernel that are needed for the +integration with Genode. Furthermore, some patches address issues with recent +tool chains not yet supported by the official Codezero verison. + +:binutils-2.21.patch: + + The GNU assembler of binutils-2.21 complains with an error that was ignored + by previous binutils versions: + + "Error: .size expression for ... does not evaluate to a constant" + + This error seems to occur if the argument of 'BEGIN_PROC' does not match + the argument of 'END_PROC'. The patch fixes such inconsistencies in the + code. + +:gcc_shared_enabled.patch: + + Codezero expect the tool chain to be used for the kernel to not support + shared libraries. This is the case for Codesourcery's arm-non-eabi + tool chain. Such tool chains use to incorporate both libgcc and libgcc_eh + into the single libgcc.a library. In contrast, for tool chains built with + '--enable-shared', libgcc does not contain the functions of libgcc_eh. Hence, + one symbol called '__aeabi_unwind_cpp_pr0' referenced by libgcc and normally + provided by libgcc_eh remains unresolved. There are two possible solutions + for this problem: We could link libgcc_eh to the 'final.elf' image as + expected by libgcc. However, this way, we will need to implement the + the environment expected by libgcc_eh. For Codezero, this is pointless + because no C++ is used. The second option is to provide a dummy symbol + for '__aeabi_unwind_cpp_pr0' just to make the linker happy. This patch + adds such a dummy symbol to 'loader/main.c'. + +:libc_search_dir.patch: + + The userlibs are build with w/o '-nostdinc'. Consequently, the standard + search paths of the tool chain are used. Because the user land is + normally build with the Codesourcery tool chain 'arm-none-linux-gnueabi', + the complete glibc headers (that come with the tool chain) end up in + the default search path. Coincidentally, the userlibs SConstruct file + misses to supply the Codezero libc headers, which goes undetected because + headers such as 'stdio.h' are silently taken from the tool chain's libc. + This patch supplies Codezero's libc include-search path for building + the userlibs. This enables the userlibs to be built with tool chains + that do not come with a complete libc. + +:scons-2.0.1.patch: + + SCons 2.0.1 complains about the 'build_dir' argument being renamed to + 'variant_dir'. This patch renames the argument where needed for building + the kernel and the default container. + +:set_fixed_pager.patch: + + At some point, Codezero abandoned the facility to define the pager for a + given thread via the exregs system call. Instead, the kernel hard-wires the + creator of the thread as the thread's pager. This is conflicting with + Genode's way of creating and paging threads. On the current version of Genode + for Codezero, all threads are paged by one thread (thread 3 happens to be the + global pager) within core. As a work-around to Codezero's current limitation, + we define thread 3 to be the pager of all threads. + +:gcc_4_6_1_fixes.patch: + + Version 4.6.1 of GCC is more picky about dead code than previous versions and + warns about unused variables. Because Codezero is build with the '-Werror' + flag, these warnings cause the kernel build to fail. The patch fixes those + warnings by removing the variables in question. + diff --git a/base-codezero/patches/binutils-2.21.patch b/base-codezero/patches/binutils-2.21.patch new file mode 100644 index 000000000..dd34a1037 --- /dev/null +++ b/base-codezero/patches/binutils-2.21.patch @@ -0,0 +1,33 @@ +diff --git a/src/arch/arm/vectors.S b/src/arch/arm/vectors.S +index 0475389..62f3c38 100644 +--- a/src/arch/arm/vectors.S ++++ b/src/arch/arm/vectors.S +@@ -503,7 +503,7 @@ BEGIN_PROC(arm_irq_exception_basic) + mov lr, pc + ldr pc, =do_irq + ldmfd sp!, {r0-r3, pc}^ +-END_PROC(arm_irq_exception) ++END_PROC(arm_irq_exception_basic) + + /* Minimal IRQ state saved on irq stack right after irq vector enters: */ + #define IRQ_R0 0 +diff --git a/conts/userlibs/libc/src/arch-arm/memcpy.S b/conts/userlibs/libc/src/arch-arm/memcpy.S +index 383f5d2..b4df27f 100644 +--- a/conts/userlibs/libc/src/arch-arm/memcpy.S ++++ b/conts/userlibs/libc/src/arch-arm/memcpy.S +@@ -57,4 +57,4 @@ BEGIN_PROC(memcpy) + bne last + 1: + pop {r0, r4 - r11, pc} +-END_PROC(_memcpy) ++END_PROC(memcpy) +diff --git a/conts/userlibs/libc/src/arch-arm/memset.S b/conts/userlibs/libc/src/arch-arm/memset.S +index ce9b06c..3746955 100644 +--- a/conts/userlibs/libc/src/arch-arm/memset.S ++++ b/conts/userlibs/libc/src/arch-arm/memset.S +@@ -65,4 +65,4 @@ BEGIN_PROC(memset) + bne end + + ldmfd sp!, {r4 - r11, pc} +-END_PROC(_memset) ++END_PROC(memset) diff --git a/base-codezero/patches/gcc_4_6_1_fixes.patch b/base-codezero/patches/gcc_4_6_1_fixes.patch new file mode 100644 index 000000000..9404db70f --- /dev/null +++ b/base-codezero/patches/gcc_4_6_1_fixes.patch @@ -0,0 +1,182 @@ +diff --git a/src/api/map.c b/src/api/map.c +index 1d15086..6139b4c 100644 +--- a/src/api/map.c ++++ b/src/api/map.c +@@ -78,6 +78,6 @@ int sys_unmap(unsigned long virtual, unsigned long npages, unsigned int tid) + retval = ret; + } + +- return ret; ++ return retval; + } + +diff --git a/src/api/thread.c b/src/api/thread.c +index 985c425..579e4fb 100644 +--- a/src/api/thread.c ++++ b/src/api/thread.c +@@ -497,7 +497,7 @@ out_err: + */ + int sys_thread_control(unsigned int flags, struct task_ids *ids) + { +- struct ktcb *task = 0, *pager = 0; ++ struct ktcb *task = 0; + int err, ret = 0; + + if ((err = check_access((unsigned long)ids, sizeof(*ids), +@@ -508,8 +508,6 @@ int sys_thread_control(unsigned int flags, struct task_ids *ids) + if (!(task = tcb_find(ids->tid))) + return -ESRCH; + +- pager = task->pager; +- + /* + * Caller may operate on a thread if it shares + * the same address space with that thread's pager +diff --git a/src/arch/arm/mapping-common.c b/src/arch/arm/mapping-common.c +index 385f7c2..55b4bea 100644 +--- a/src/arch/arm/mapping-common.c ++++ b/src/arch/arm/mapping-common.c +@@ -313,12 +313,11 @@ int check_mapping(unsigned long vaddr, unsigned long size, + int remove_mapping_space(struct address_space *space, unsigned long vaddr) + { + pmd_table_t *pmd_table; +- int pgd_i, pmd_i; ++ int pmd_i; + pmd_t *pmd; + unsigned int pmd_type, pte_type; + + vaddr = page_align(vaddr); +- pgd_i = PGD_INDEX(vaddr); + pmd_i = PMD_INDEX(vaddr); + + /* +diff --git a/src/glue/arm/init.c b/src/glue/arm/init.c +index 2373c66..43c6fda 100644 +--- a/src/glue/arm/init.c ++++ b/src/glue/arm/init.c +@@ -68,8 +68,6 @@ void print_sections(void) + /* The kip is non-standard, using 0xBB to indicate mine for now ;-) */ + void kip_init() + { +- struct utcb **utcb_ref; +- + /* + * TODO: Adding utcb size might be useful + */ +@@ -86,9 +84,6 @@ void kip_init() + + kip_init_syscalls(); + +- /* KIP + 0xFF0 is pointer to UTCB segment start address */ +- utcb_ref = (struct utcb **)((unsigned long)&kip + UTCB_KIP_OFFSET); +- + add_boot_mapping(virt_to_phys(&kip), USER_KIP_PAGE, PAGE_SIZE, + MAP_USR_RO); + printk("%s: Kernel built on %s, %s\n", __KERNELNAME__, +diff --git a/loader/libs/elf/src/elf.c b/loader/libs/elf/src/elf.c +index 4a1b5e0..f97273b 100644 +--- a/loader/libs/elf/src/elf.c ++++ b/loader/libs/elf/src/elf.c +@@ -339,16 +339,12 @@ elf_loadFile(void *elfFile, bool phys) + { + int i; + int num_pheaders; +- int pheader_offset; +- int pheader_type; + if (elf_checkFile(elfFile) != 0) { + return false; + } + + num_pheaders = elf_getNumProgramHeaders(elfFile); +- pheader_offset = elf_getProgramHeaderOffset(elfFile, 0); + //printf("Number of program headers: %d\n", num_pheaders); +- //printf("Program header offset of first header from file beginning: 0x%p\n",pheader_offset); + + /* + * FIXME: +@@ -373,8 +369,6 @@ elf_loadFile(void *elfFile, bool phys) + // printf("This section's size in file: %p\n", len); + src = (uint64_t) (uintptr_t) elfFile + elf_getProgramHeaderOffset(elfFile, i); + // printf("Elf program header offset: %p\n", src); +- 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); + memcpy((void*) (uintptr_t) dest, (void*) (uintptr_t) src, len); +diff --git a/loader/libs/elf/src/elf32.c b/loader/libs/elf/src/elf32.c +index 2d13798..78bbf33 100644 +--- a/loader/libs/elf/src/elf32.c ++++ b/loader/libs/elf/src/elf32.c +@@ -248,7 +248,6 @@ elf32_fprintf(FILE *f, struct Elf32_Header *file, int size, const char *name, in + struct Elf32_Shdr *sections; + unsigned numSections; + int i, r; +- char *str_table; + + fprintf(f, "Found an elf32 file called \"%s\" located " + "at address 0x%p\n", name, file); +@@ -307,7 +306,6 @@ elf32_fprintf(FILE *f, struct Elf32_Header *file, int size, const char *name, in + } + } + if (flags & ELF_PRINT_SECTIONS) { +- str_table = elf32_getSegmentStringTable(file); + + printf("Section Headers:\n"); + printf(" [Nr] Name Type Addr Off\n"); +diff --git a/src/generic/capability.c b/src/generic/capability.c +index 0860ea5..ef44445 100644 +--- a/src/generic/capability.c ++++ b/src/generic/capability.c +@@ -403,7 +403,7 @@ struct capability *cap_match_mem(struct capability *cap, + { + struct sys_map_args *args = args_ptr; + struct ktcb *target = args->task; +- unsigned long long start, end, pfn_point; ++ unsigned long long start, pfn_point; + unsigned long pfn; + unsigned int perms; + +@@ -415,7 +415,6 @@ struct capability *cap_match_mem(struct capability *cap, + + /* Long long range check to avoid overflow */ + start = cap->start; +- end = cap->end; + pfn_point = pfn; + if (start > pfn_point || cap->end < pfn_point + args->npages) + return 0; +diff --git a/loader/main.c b/loader/main.c +index 7d21a4c..8d7d6db 100644 +--- a/loader/main.c ++++ b/loader/main.c +@@ -26,7 +26,6 @@ int load_elf_image(unsigned long **entry, void *filebuf); + int load_container_image(void *cont_section) + { + struct Elf32_Header *elf_header = (struct Elf32_Header *)cont_section; +- struct Elf32_Shdr *sect_header; + int nsect; + int nimgs = 0; + unsigned long *image_entry; +@@ -36,7 +35,6 @@ int load_container_image(void *cont_section) + return -1; + } + +- sect_header = elf32_getSectionTable(elf_header); + nsect = elf32_getNumSections(elf_header); + + for (int i = 0; i < nsect; i++) { +@@ -59,7 +57,6 @@ int load_container_image(void *cont_section) + int load_container_images(unsigned long start, unsigned long end) + { + struct Elf32_Header *elf_header = (struct Elf32_Header *)start; +- struct Elf32_Shdr *sect_header; + int nsect = 0; + int nconts = 0; + +@@ -68,7 +65,6 @@ int load_container_images(unsigned long start, unsigned long end) + return -1; + } + +- sect_header = elf32_getSectionTable(elf_header); + nsect = elf32_getNumSections(elf_header); + + for (int i = 0; i < nsect; i++) { diff --git a/base-codezero/patches/gcc_shared_enabled.patch b/base-codezero/patches/gcc_shared_enabled.patch new file mode 100644 index 000000000..a5a8be439 --- /dev/null +++ b/base-codezero/patches/gcc_shared_enabled.patch @@ -0,0 +1,10 @@ +diff --git a/loader/main.c b/loader/main.c +index 7d21a4c..ee03918 100644 +--- a/loader/main.c ++++ b/loader/main.c +@@ -135,3 +135,5 @@ int main(void) + return -1; + } + ++ ++asm(".global __aeabi_unwind_cpp_pr0; __aeabi_unwind_cpp_pr0:"); diff --git a/base-codezero/patches/libc_search_dir.patch b/base-codezero/patches/libc_search_dir.patch new file mode 100644 index 000000000..90931cc19 --- /dev/null +++ b/base-codezero/patches/libc_search_dir.patch @@ -0,0 +1,21 @@ +diff --git a/conts/userlibs/SConstruct b/conts/userlibs/SConstruct +index 41c7913..421b563 100644 +--- a/conts/userlibs/SConstruct ++++ b/conts/userlibs/SConstruct +@@ -11,6 +11,7 @@ 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 +@@ -28,7 +29,7 @@ env = Environment(CC = config.toolchain_userspace + 'gcc', + ASFLAGS = ['-D__ASSEMBLY__', '-march=' + gcc_arch_flag], + ENV = {'PATH' : os.environ['PATH']}, + LIBS = 'gcc', # libgcc.a - Required for division routines. +- CPPPATH = KERNEL_HEADERS, ++ CPPPATH = [KERNEL_HEADERS, LIBC_INCLUDE], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + + # Set the build directory for this source tree diff --git a/base-codezero/patches/scons-2.0.1.patch b/base-codezero/patches/scons-2.0.1.patch new file mode 100644 index 000000000..cbab04464 --- /dev/null +++ b/base-codezero/patches/scons-2.0.1.patch @@ -0,0 +1,97 @@ +diff --git a/src/drivers/SConscript b/src/drivers/SConscript +index eedb59f..8f5cd5d 100644 +--- a/src/drivers/SConscript ++++ b/src/drivers/SConscript +@@ -8,24 +8,24 @@ src_local = [] + objs = [] + + objs += SConscript("uart/pl011/SConscript", exports = { 'env' : env }, +- duplicate=0, build_dir = join(bdir, 'pl011')) ++ duplicate=0, variant_dir = join(bdir, 'pl011')) + + objs += SConscript("timer/sp804/SConscript", exports = { 'env' : env }, +- duplicate=0, build_dir = join(bdir, 'timer')) ++ duplicate=0, variant_dir = join(bdir, 'timer')) + + objs += SConscript("irq/pl190/SConscript", exports = { 'env' : env }, +- duplicate=0, build_dir = join(bdir, 'vic')) ++ duplicate=0, variant_dir = join(bdir, 'vic')) + + objs += SConscript("irq/gic/SConscript", exports = { 'env' : env }, +- duplicate=0, build_dir = join(bdir, 'gic')) ++ duplicate=0, variant_dir = join(bdir, 'gic')) + + objs += SConscript("irq/omap3/SConscript", exports = { 'env' : env }, +- duplicate=0, build_dir = join(bdir, 'omap/intc')) ++ duplicate=0, variant_dir = join(bdir, 'omap/intc')) + + objs += SConscript("uart/omap/SConscript", exports = { 'env' : env }, +- duplicate=0, build_dir = join(bdir, 'omap/uart')) ++ duplicate=0, variant_dir = join(bdir, 'omap/uart')) + + objs += SConscript("timer/omap/SConscript", exports = { 'env' : env }, +- duplicate=0, build_dir = join(bdir, 'omap/timer')) ++ duplicate=0, variant_dir = join(bdir, 'omap/timer')) + + Return('objs') +diff --git a/conts/baremetal/empty/SConstruct b/conts/baremetal/empty/SConstruct +index b70d69a..4889d8e 100644 +--- a/conts/baremetal/empty/SConstruct ++++ b/conts/baremetal/empty/SConstruct +@@ -48,7 +48,7 @@ env = Environment(CC = config.toolchain_userspace + 'gcc', + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + + objs = SConscript('SConscript', exports = { 'env' : env }, +- duplicate=0, build_dir = builddir) ++ duplicate=0, variant_dir = builddir) + + Depends(objs, join(PROJROOT, CONFIG_H)) + prog = env.Program(join(builddir, 'main.elf'), objs) +diff --git a/SConstruct b/SConstruct +index 2abc190..58c983d 100644 +--- a/SConstruct ++++ b/SConstruct +@@ -71,35 +71,35 @@ env = Environment(CC = config.toolchain_kernel + 'gcc', + objects = [] + objects += SConscript('src/generic/SConscript', + exports = { 'env' : env }, duplicate = 0, +- build_dir = join(builddir, 'generic')) ++ variant_dir = join(builddir, 'generic')) + + objects += SConscript(join(join('src/glue', arch), 'SConscript'), + exports = { 'env' : env }, duplicate = 0, +- build_dir = join(builddir, join('glue',arch))) ++ variant_dir = join(builddir, join('glue',arch))) + + objects += SConscript(join(join('src/arch', arch), 'SConscript'), + exports = { 'env' : env }, duplicate = 0, +- build_dir = join(builddir, join('arch', arch))) ++ variant_dir = join(builddir, join('arch', arch))) + + objects += SConscript(join(join('src/arch', arch), join(subarch, 'SConscript')), + exports = { 'env' : env }, duplicate = 0, +- build_dir = join(builddir, join(join('arch',arch), subarch))) ++ variant_dir = join(builddir, join(join('arch',arch), subarch))) + + objects += SConscript('src/lib/SConscript', + exports = { 'env' : env }, duplicate = 0, +- build_dir = join(builddir, 'lib')) ++ variant_dir = join(builddir, 'lib')) + + objects += SConscript('src/api/SConscript', + exports = { 'env' : env }, duplicate = 0, +- build_dir = join(builddir, 'api')) ++ variant_dir = join(builddir, 'api')) + + objects += SConscript('src/drivers/SConscript', + exports = { 'env' : env, 'bdir' : 'driver/'}, duplicate = 0, +- build_dir = join(builddir, 'driver')) ++ variant_dir = join(builddir, 'driver')) + + objects += SConscript(join(join('src/platform', platform), 'SConscript'), + exports = { 'env' : env }, duplicate = 0, +- build_dir = join(builddir, join('platform', platform))) ++ variant_dir = join(builddir, join('platform', platform))) + + + # Add builders for generating kernel linker scripts diff --git a/base-codezero/patches/set_fixed_pager.patch b/base-codezero/patches/set_fixed_pager.patch new file mode 100644 index 000000000..dc0818584 --- /dev/null +++ b/base-codezero/patches/set_fixed_pager.patch @@ -0,0 +1,13 @@ +diff --git a/include/l4/generic/tcb.h b/include/l4/generic/tcb.h +index 7b315b8..ace38d8 100644 +--- a/include/l4/generic/tcb.h ++++ b/include/l4/generic/tcb.h +@@ -70,7 +70,7 @@ struct task_ids { + + struct container; + +-#define tcb_pagerid(tcb) ((tcb)->pager->tid) ++#define tcb_pagerid(tcb) 3 + + #define space_is_pager(tcb) \ + ((tcb)->space->spid == (tcb)->pager->space->spid) diff --git a/base-codezero/run/env b/base-codezero/run/env new file mode 100644 index 000000000..bfdaec3ab --- /dev/null +++ b/base-codezero/run/env @@ -0,0 +1,88 @@ +# +# \brief Codezero-specific test-environment supplements +# \author Norman Feske +# \date 2011-08-05 +# +# This file is meant to be used as '--include' argument for 'tool/run'. +# + + +## +# Return location of prebuilt mirror of codezero source tree +# +proc kernel_dir { } { return [pwd]/kernel/codezero } + + +## +# Return container directory where the Genode binaries should be copied to +# +proc container_dir { } { return [kernel_dir]/build/cont0/empty0 } + + +## +# Return location of 'gen_romfs' tool +# +proc gen_romfs { } { return "[genode_dir]/base-codezero/tool/gen_romfs" } + + +## +# Print and execute shell command +# +proc exec_sh { command } { + puts "$command" + exec sh -c $command +} + + +################################## +## Test framework API functions ## +################################## + +proc create_boot_directory { } { + + # create only intermediate directries hosting the run directory + exec mkdir -p [run_dir] + exec rm -rf [run_dir] + + exec mkdir -p [run_dir]/genode +} + + +proc build_boot_image {binaries} { + + if {![file exists kernel]} { build kernel } + + copy_and_strip_genode_binaries_to_run_dir $binaries + + # the codezero build system expects that the pager binary is named 'main.elf' + exec cp [run_dir]/genode/core [container_dir]/main.elf + + # obtain list of modules + set modules [glob [run_dir]/genode/*] + + # remove core from list of modules + set core_idx [lsearch -exact $modules [run_dir]/genode/core] + set modules [lreplace $modules $core_idx $core_idx] + + # generate elf image containing the boot modules + exec_sh "[gen_romfs] -p [cross_dev_prefix] -c [run_dir]/genode/core -o [container_dir]/modules.elf $modules" + + set tool_chain_dir [file dirname [cross_dev_prefix]] + set prepend_path "" + if {[file isdirectory $tool_chain_dir]} { + set prepend_path $tool_chain_dir } + + # force re-generation of 'cinfo.c', which depends on the container content + exec_sh "rm -f [kernel_dir]/src/generic/cinfo.c" + + # rebuild codezero, linking the new container content + exec_sh "cd [kernel_dir]; PATH=$prepend_path:\$PATH ./build.py" + + # copy result to [run_dir]/image.elf (to be picked up by spawn_qemu) + exec_sh "cp [kernel_dir]/build/final.elf [run_dir]/image.elf" +} + + +proc run_genode_until {{wait_for_re forever} {timeout_value 0}} { + spawn_qemu $wait_for_re $timeout_value } + diff --git a/base-codezero/src/base/console/pl011/core_console.h b/base-codezero/src/base/console/pl011/core_console.h new file mode 100644 index 000000000..d0e6f4ff7 --- /dev/null +++ b/base-codezero/src/base/console/pl011/core_console.h @@ -0,0 +1,78 @@ +/* + * \brief Console backend for PL011 UART on Codezero + * \author Norman Feske + * \date 2009-10-03 + * + * This code assumes a PL011 UART as provided by 'qemu -M versatilepb'. Prior + * executing this code, the kernel already initialized the UART to print some + * startup message. So we can skip the UART initialization here. The kernel + * maps the UART registers to the magic address PL011_BASE when starting mm0. + * So we can just start using the device without any precautions. + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* codezero includes */ +#include + +typedef unsigned char uint8_t; + +/** + * Base address of default-mapped UART device + * + * defined in 'l4/arch/arm/io.h' + */ +enum { PL011_BASE = USERSPACE_CONSOLE_VBASE }; + +/** + * UART registers + */ +enum { PL011_REG_UARTDR = PL011_BASE + 0x00 }; +enum { PL011_REG_UARTFR = PL011_BASE + 0x18 }; + + +/** + * Returns true if UART is ready to transmit a character + */ +static bool pl011_tx_ready() +{ + enum { PL011_TX_FIFO_FULL = 1 << 5 }; + return !(*((volatile unsigned *)PL011_REG_UARTFR) & PL011_TX_FIFO_FULL); +} + + +/** + * Output character to serial port + */ +static void pl011_out_char(uint8_t c) +{ + /* wait until serial port is ready */ + while (!pl011_tx_ready()); + + /* output character */ + *((volatile unsigned int *)PL011_REG_UARTDR) = c; +} + + +namespace Genode +{ + class Core_console : public Console + { + protected: + + void _out_char(char c) { + if(c == '\n') + pl011_out_char('\r'); + pl011_out_char(c); + } + }; +} + diff --git a/base-codezero/src/base/cxx/exception.cc b/base-codezero/src/base/cxx/exception.cc new file mode 100644 index 000000000..612ddd24f --- /dev/null +++ b/base-codezero/src/base/cxx/exception.cc @@ -0,0 +1,53 @@ +/* + * \brief Support for exceptions libsupc++ + * \author Norman Feske + * \author Sebastian Sumpf + * \date 2006-07-21 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +extern "C" char __eh_frame_start__[]; /* from linker script */ +extern "C" void __register_frame (const void *begin); /* from libgcc_eh */ + +/* + * This symbol is set by Genode's dynamic linker (ldso) during binary setup. + * After setup, the symbol will point to the actual implementation of + * 'dl_iterate_phdr', which is located within the linker. 'dl_iterate_phdr' + * iterates through all (linker loaded) binaries and shared libraries. This + * function has to be implemented in order to support C++ exceptions within + * shared libraries. + * Return values of dl_iterate_phdr (gcc 4.2.4): + * < 0 = error + * 0 = continue program header iteration + * > 0 = stop iteration (no errors occured) + * + * See also: man dl_iterate_phdr + */ +int (*genode__dl_iterate_phdr) (int (*callback) (void *info, unsigned long size, void *data), void *data) = 0; + +extern "C" int dl_iterate_phdr(int (*callback) (void *info, unsigned long size, void *data), void *data) __attribute__((weak)); +extern "C" int dl_iterate_phdr(int (*callback) (void *info, unsigned long size, void *data), void *data) +{ + if (!genode__dl_iterate_phdr) + return -1; + + return genode__dl_iterate_phdr(callback, data); +} + +extern "C" void raise() +{ + PDBG("raise called - not implemented\n"); +} + +void init_exception_handling() +{ +// __register_frame(__eh_frame_start__); +} diff --git a/base-codezero/src/base/cxx/memcmp.cc b/base-codezero/src/base/cxx/memcmp.cc new file mode 100644 index 000000000..330b63165 --- /dev/null +++ b/base-codezero/src/base/cxx/memcmp.cc @@ -0,0 +1,24 @@ +/* + * \brief Functions required for using the arm-none-linux-gnueabi tool chain + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include + +using namespace Genode; + + +extern "C" int raise(int sig) +{ + PWRN("raise - not yet implemented"); + return 0; +} diff --git a/base-codezero/src/base/ipc/ipc.cc b/base-codezero/src/base/ipc/ipc.cc new file mode 100644 index 000000000..48a242972 --- /dev/null +++ b/base-codezero/src/base/ipc/ipc.cc @@ -0,0 +1,175 @@ +/* + * \brief Codezero implementation of the IPC API + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Codezero includes */ +#include + +/* Genode includes */ +#include +#include +#include +#include + +using namespace Genode; +using namespace Codezero; + +enum { verbose_ipc = false }; + + +/***************** + ** Ipc_ostream ** + *****************/ + +void Ipc_ostream::_send() +{ + if (verbose_ipc) + PDBG("thread %d sends IPC to %d, write_offset=%d", + thread_myself(), _dst.tid().tid, _write_offset); + + umword_t snd_size = min(_write_offset, (unsigned)L4_IPC_EXTENDED_MAX_SIZE); + + *(umword_t *)_snd_msg->addr() = _dst.local_name(); + + int ret = l4_send_extended(_dst.tid().tid, L4_IPC_TAG_SYNC_EXTENDED, + snd_size, _snd_msg->addr()); + if (ret < 0) + PERR("l4_send_extended (to thread %d) returned ret=%d", + _dst.tid().tid, ret); + + _write_offset = sizeof(umword_t); +} + + + +Ipc_ostream::Ipc_ostream(Native_capability dst, Msgbuf_base *snd_msg) +: + Ipc_marshaller((char *)snd_msg->addr(), snd_msg->size()), + _snd_msg(snd_msg), _dst(dst) +{ + _write_offset = sizeof(umword_t); +} + + +/***************** + ** Ipc_istream ** + *****************/ + +void Ipc_istream::_wait() +{ + umword_t *rcv_buf = (umword_t *)_rcv_msg->addr(); + umword_t rcv_size = min(_rcv_msg->size(), (unsigned)L4_IPC_EXTENDED_MAX_SIZE); + + if (verbose_ipc) + PDBG("thread %d waits for IPC from %d, rcv_buf at %p, rcv_size=%d", + tid().tid, _rcv_cs, rcv_buf, (int)rcv_size); + + int ret = l4_receive_extended(_rcv_cs, rcv_size, rcv_buf); + if (ret < 0) + PERR("l4_receive_extended (from any) returned ret=%d", ret); + + if (verbose_ipc) + PDBG("thread %d received IPC from %d", + tid().tid, l4_get_sender()); + + _read_offset = sizeof(umword_t); +} + + +Ipc_istream::Ipc_istream(Msgbuf_base *rcv_msg) +: + Ipc_unmarshaller((char *)rcv_msg->addr(), rcv_msg->size()), + Native_capability(thread_myself(), 0), + _rcv_msg(rcv_msg) +{ + _rcv_cs = L4_ANYTHREAD; + _read_offset = sizeof(umword_t); +} + + +Ipc_istream::~Ipc_istream() { } + + +/**************** + ** Ipc_client ** + ****************/ + +void Ipc_client::_call() +{ +#warning l4_sendrecv_extended is not yet implemented in l4lib/arch/syslib.h + _send(); + _rcv_cs = _dst.tid().tid; + _wait(); + _rcv_cs = L4_ANYTHREAD; + + _write_offset = _read_offset = sizeof(umword_t); +} + + +Ipc_client::Ipc_client(Native_capability const &srv, + Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg) +: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0) +{ } + + +/**************** + ** Ipc_server ** + ****************/ + +void Ipc_server::_prepare_next_reply_wait() +{ + /* now we have a request to reply */ + _reply_needed = true; + + /* leave space for return value at the beginning of the msgbuf */ + _write_offset = 2*sizeof(umword_t); + + /* receive buffer offset */ + _read_offset = sizeof(umword_t); +} + + +void Ipc_server::_wait() +{ + /* wait for new server request */ + try { Ipc_istream::_wait(); } catch (Blocking_canceled) { } + + /* define destination of next reply */ + _dst = Native_capability(l4_get_sender(), badge()); + + _prepare_next_reply_wait(); +} + + +void Ipc_server::_reply() +{ + try { _send(); } catch (Ipc_error) { } + + _prepare_next_reply_wait(); +} + + +void Ipc_server::_reply_wait() +{ + if (_reply_needed) + _reply(); + + _wait(); +} + + +Ipc_server::Ipc_server(Msgbuf_base *snd_msg, + Msgbuf_base *rcv_msg) +: + Ipc_istream(rcv_msg), Ipc_ostream(Native_capability(), snd_msg), + _reply_needed(false) +{ } diff --git a/base-codezero/src/base/ipc/pager.cc b/base-codezero/src/base/ipc/pager.cc new file mode 100644 index 000000000..a3e8c3470 --- /dev/null +++ b/base-codezero/src/base/ipc/pager.cc @@ -0,0 +1,175 @@ +/* + * \brief Pager support for Codezero + * \author Norman Feske + * \date 2010-02-16 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* Codezero includes */ +#include + + +using namespace Genode; +using namespace Codezero; + +enum { verbose_page_faults = false }; + + +/************************ + ** Page-fault utility ** + ************************/ + +class Fault +{ + public: + + enum Type { READ, WRITE, EXEC, UNKNOWN }; + + private: + + /** + * Translate Codezero page-fault information to generic fault type + * + * \param sr status + * \param pte page-table entry + */ + static Type _fault_type(umword_t sr, umword_t pte) + { + if (is_prefetch_abort(sr)) + return EXEC; + + if ((pte & PTE_PROT_MASK) == (__MAP_USR_RO & PTE_PROT_MASK)) + return WRITE; + + return READ; + } + + Type _type; + umword_t _addr; + umword_t _ip; + + public: + + /** + * Constructor + * + * \param kdata Codezero-specific page-fault information + */ + Fault(struct fault_kdata const &kdata) + : + _type(_fault_type(kdata.fsr, kdata.pte)), + _addr(_type == EXEC ? kdata.faulty_pc : kdata.far), + _ip(kdata.faulty_pc) + { } + + Type type() const { return _type; } + umword_t addr() const { return _addr; } + umword_t ip() const { return _ip; } +}; + + +/** + * Print page-fault information in a human-readable form + */ +inline void print_page_fault(Fault &fault, int from) +{ + printf("page (%s%s%s) fault from %d at pf_addr=%lx, pf_ip=%lx\n", + fault.type() == Fault::READ ? "r" : "-", + fault.type() == Fault::WRITE ? "w" : "-", + fault.type() == Fault::EXEC ? "x" : "-", + from, fault.addr(), fault.ip()); +} + + +/*************** + ** IPC pager ** + ***************/ + +void Ipc_pager::wait_for_fault() +{ + for (;;) { + int ret = l4_receive(L4_ANYTHREAD); + + if (ret < 0) { + PERR("pager: l4_received returned ret=%d", ret); + continue; + } + + umword_t tag = l4_get_tag(); + int faulter_tid = l4_get_sender(); + + if (tag != L4_IPC_TAG_PFAULT) { + PWRN("got an unexpected IPC from %d", faulter_tid); + continue; + } + + /* copy fault information from message registers */ + struct fault_kdata fault_kdata; + for (unsigned i = 0; i < sizeof(fault_kdata_t)/sizeof(umword_t); i++) + ((umword_t *)&fault_kdata)[i] = read_mr(MR_UNUSED_START + i); + + Fault fault(fault_kdata); + + if (verbose_page_faults) + print_page_fault(fault, faulter_tid); + + /* determine corresponding page in our own address space */ + _pf_addr = fault.addr(); + _pf_write = fault.type() == Fault::WRITE; + _pf_ip = fault.ip(); + _last = faulter_tid; + + return; + } +} + + +void Ipc_pager::reply_and_wait_for_fault() +{ + /* install mapping */ + umword_t flags = _reply_mapping.writeable() ? MAP_USR_RW + : MAP_USR_RO; + + /* + * XXX: remove heuristics for mapping device registers. + */ + if (_reply_mapping.from_phys() == 0x10120000 /* LCD */ + || _reply_mapping.from_phys() == 0x10006000 /* keyboard */ + || _reply_mapping.from_phys() == 0x10007000) /* mouse */ + flags = MAP_USR_IO; + + int ret = l4_map((void *)_reply_mapping.from_phys(), + (void *)_reply_mapping.to_virt(), + _reply_mapping.num_pages(), flags, _last.tid); + + /* wake up faulter if mapping succeeded */ + if (ret < 0) + PERR("l4_map returned %d, putting thread %d to sleep", ret, _last.tid); + else + acknowledge_wakeup(); + + /* wait for next page fault */ + wait_for_fault(); +} + + +void Ipc_pager::acknowledge_wakeup() +{ + enum { SUCCESS = 0 }; + l4_set_sender(_last.tid); + l4_ipc_return(SUCCESS); +} + + +Ipc_pager::Ipc_pager() : Native_capability(thread_myself(), 0) { } + diff --git a/base-codezero/src/base/lock/cmpxchg.cc b/base-codezero/src/base/lock/cmpxchg.cc new file mode 100644 index 000000000..6bda6e2ce --- /dev/null +++ b/base-codezero/src/base/lock/cmpxchg.cc @@ -0,0 +1,48 @@ +/* + * \brief Codezero-specific implementation of cmpxchg + * \author Norman Feske + * \date 2009-10-12 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include + +/* Codezero includes */ +#include + + +static bool mutex_initialized; +static Codezero::l4_mutex mutex; + +int Genode::cmpxchg(volatile int *dest, int cmp_val, int new_val) +{ + if (!mutex_initialized) { + Codezero::l4_mutex_init(&mutex); + mutex_initialized = true; + } + + int ret = Codezero::l4_mutex_lock(&mutex); + if (ret < 0) + mutex_initialized = false; + + bool result = false; + if (*dest == cmp_val) { + *dest = new_val; + result = true; + } + + ret = Codezero::l4_mutex_unlock(&mutex); + if (ret < 0) + mutex_initialized = false; + + return result; +} diff --git a/base-codezero/src/base/lock/lock.cc b/base-codezero/src/base/lock/lock.cc new file mode 100644 index 000000000..8ebe5b7d4 --- /dev/null +++ b/base-codezero/src/base/lock/lock.cc @@ -0,0 +1,63 @@ +/* + * \brief Lock implementation + * \author Norman Feske + * \date 2007-10-15 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include + +/* Codezero includes */ +#include + +using namespace Genode; + + +Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial) +: + _native_lock(UNLOCKED) +{ + if (initial == LOCKED) + lock(); +} + + +void Cancelable_lock::lock() +{ + while (!cmpxchg(&_native_lock, UNLOCKED, LOCKED)) + Codezero::l4_thread_switch(-1); +} + + +void Cancelable_lock::unlock() +{ + _native_lock = UNLOCKED; +} + + +/* + * Printf implementation to make Codezero's syscall bindings happy. + * + * We need a better place for this function - actually, the best would be not + * to need this function at all. As of now, 'printf' is referenced by + * Codezero's libl4, in particular by the mutex implementation. + */ +extern "C" void printf(const char *format, ...) __attribute__((weak)); +extern "C" void printf(const char *format, ...) +{ + va_list list; + va_start(list, format); + + vprintf(format, list); + + va_end(list); +} diff --git a/base-codezero/src/base/lock/lock_helper.h b/base-codezero/src/base/lock/lock_helper.h new file mode 100644 index 000000000..fb8dbc6a6 --- /dev/null +++ b/base-codezero/src/base/lock/lock_helper.h @@ -0,0 +1,112 @@ +/* + * \brief Helper functions for the Lock implementation + * \author Norman Feske + * \date 2010-04-20 + * + * For documentation about the interface, please revisit the 'base-pistachio' + * implementation. + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* Codezero includes */ +#include + + +/** + * Resolve 'Thread_base::myself' when not linking the thread library + * + * This weak symbol is primarily used by test cases. Most other Genode programs + * use the thread library. If the thread library is not used, 'myself' can only + * be called by the main thread, for which 'myself' is defined as zero. + */ +Genode::Thread_base * __attribute__((weak)) Genode::Thread_base::myself() { return 0; } + + +Genode::Native_utcb *Genode::Thread_base::utcb() +{ + /* + * If 'utcb' is called on the object returned by 'myself', + * the 'this' pointer may be NULL (if the calling thread is + * the main thread). Therefore we handle this special case + * here. + */ + if (this == 0) return 0; + + return &_context->utcb; +} + + +static Codezero::l4_mutex main_running_lock = { -1 }; + + +static inline void thread_yield() +{ + Codezero::l4_thread_switch(-1); +} + + +static inline bool thread_id_valid(Genode::Native_thread_id tid) +{ + return tid.tid != Codezero::NILTHREAD; +} + + +static bool thread_check_stopped_and_restart(Genode::Native_thread_id tid) +{ + if (!thread_id_valid(tid)) + return false; + + Codezero::l4_mutex_unlock(tid.running_lock); + return true; +} + + +static inline Genode::Native_thread_id thread_get_my_native_id() +{ + using namespace Genode; + + Codezero::l4_mutex *running_lock = 0; + + /* obtain pointer to running lock of calling thread */ + if (Thread_base::myself()) + running_lock = Thread_base::myself()->utcb()->running_lock(); + else { + running_lock = &main_running_lock; + if (running_lock->lock == -1) { + Codezero::l4_mutex_init(running_lock); + Codezero::l4_mutex_lock(running_lock); /* block on first mutex lock */ + } + } + + return Genode::Native_thread_id(Codezero::thread_myself(), running_lock); +} + + +static inline Genode::Native_thread_id thread_invalid_id() +{ + return Genode::Native_thread_id(Codezero::NILTHREAD, 0); +} + + +static inline void thread_switch_to(Genode::Native_thread_id tid) +{ + if (thread_id_valid(tid)) + Codezero::l4_thread_switch(tid.tid); +} + + +static inline void thread_stop_myself() +{ + Genode::Native_thread_id myself = thread_get_my_native_id(); + Codezero::l4_mutex_lock(myself.running_lock); +} diff --git a/base-codezero/src/base/pager/pager.cc b/base-codezero/src/base/pager/pager.cc new file mode 100644 index 000000000..e0c9d2be3 --- /dev/null +++ b/base-codezero/src/base/pager/pager.cc @@ -0,0 +1,101 @@ +/* + * \brief Dummy pager framework + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +using namespace Genode; + + +/********************** + ** Pager activation ** + **********************/ + +void Pager_activation_base::entry() +{ + Ipc_pager pager; + _cap = pager; + _cap_valid.unlock(); + + pager.wait_for_fault(); + while (1) { + + /* lookup referenced object */ + Pager_object *obj = _ep ? _ep->obj_by_id(pager.badge()) : 0; + + /* handle request */ + if (obj) { + if (obj->pager(pager)) + /* something strange occured - leave thread in pagefault */ + pager.wait_for_fault(); + else + pager.reply_and_wait_for_fault(); + } else { + + /* + * We got a request from one of cores region-manager sessions + * to answer the pending page fault of a resolved region-manager + * client. Hence, we have to send the page-fault reply to the + * specified thread and answer the call of the region-manager + * session. + * + * When called from a region-manager session, we receive the + * core-local address of the targeted pager object via the + * first message word, which corresponds to the 'fault_ip' + * argument of normal page-fault messages. + */ + obj = reinterpret_cast(pager.fault_ip()); + + /* send reply to the calling region-manager session */ + pager.acknowledge_wakeup(); + + /* answer page fault of resolved pager object */ + pager.set_reply_dst(obj->cap()); + pager.acknowledge_wakeup(); + pager.wait_for_fault(); + } + } +} + + +/********************** + ** Pager entrypoint ** + **********************/ + +Pager_entrypoint::Pager_entrypoint(Cap_session *, Pager_activation_base *a) +: _activation(a) +{ _activation->ep(this); } + + +void Pager_entrypoint::dissolve(Pager_object *obj) +{ + remove(obj); +} + + +Pager_capability Pager_entrypoint::manage(Pager_object *obj) +{ + /* return invalid capability if no activation is present */ + if (!_activation) return Pager_capability(); + + _activation->cap(); + + Untyped_capability cap = Native_capability(_activation->cap().tid(), obj->badge()); + + /* add server object to object pool */ + obj->cap(cap); + insert(obj); + + /* return capability that uses the object id as badge */ + return reinterpret_cap_cast(cap); +} diff --git a/base-codezero/src/base/thread/thread_start.cc b/base-codezero/src/base/thread/thread_start.cc new file mode 100644 index 000000000..2204d85d0 --- /dev/null +++ b/base-codezero/src/base/thread/thread_start.cc @@ -0,0 +1,79 @@ +/* + * \brief NOVA-specific implementation of the Thread API + * \author Norman Feske + * \date 2010-01-19 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include + +/* Codezero includes */ +#include + +using namespace Genode; + + +/** + * Entry point entered by new threads + */ +void Thread_base::_thread_start() +{ + Thread_base::myself()->_thread_bootstrap(); + Thread_base::myself()->entry(); + Genode::sleep_forever(); +} + + +/***************** + ** Thread base ** + *****************/ + +void Thread_base::_init_platform_thread() +{ + Codezero::l4_mutex_init(utcb()->running_lock()); + Codezero::l4_mutex_lock(utcb()->running_lock()); /* block on first mutex lock */ +} + + +void Thread_base::_deinit_platform_thread() +{ + env()->cpu_session()->kill_thread(_thread_cap); +} + + +void Thread_base::start() +{ + /* create thread at core */ + char buf[48]; + name(buf, sizeof(buf)); + _thread_cap = env()->cpu_session()->create_thread(buf); + + /* assign thread to protection domain */ + env()->pd_session()->bind_thread(_thread_cap); + + /* create new pager object and assign it to the new thread */ + Pager_capability pager_cap = env()->rm_session()->add_client(_thread_cap); + env()->cpu_session()->set_pager(_thread_cap, pager_cap); + + /* register initial IP and SP at core */ + addr_t thread_sp = (addr_t)&_context->stack[-4]; + thread_sp &= ~0xf; /* align initial stack to 16 byte boundary */ + env()->cpu_session()->start(_thread_cap, (addr_t)_thread_start, thread_sp); +} + + +void Thread_base::cancel_blocking() +{ + Codezero::l4_mutex_unlock(utcb()->running_lock()); + env()->cpu_session()->cancel_blocking(_thread_cap); +} diff --git a/base-codezero/src/core/core_rm_session.cc b/base-codezero/src/core/core_rm_session.cc new file mode 100644 index 000000000..7458fc354 --- /dev/null +++ b/base-codezero/src/core/core_rm_session.cc @@ -0,0 +1,67 @@ +/* + * \brief Core-local RM session + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include +#include +#include + +using namespace Genode; + + +Rm_session::Local_addr +Core_rm_session::attach(Dataspace_capability ds_cap, size_t size, + off_t offset, bool use_local_addr, + Rm_session::Local_addr local_addr) +{ + using namespace Codezero; + + Dataspace_component *ds = static_cast(_ds_ep->obj_by_cap(ds_cap)); + if (!ds) + throw Invalid_dataspace(); + + if (size == 0) + size = ds->size(); + + size_t page_rounded_size = (size + get_page_size() - 1) & get_page_mask(); + size_t num_pages = page_rounded_size >> get_page_size_log2(); + + if (use_local_addr) { + PERR("Parameter 'use_local_addr' not supported within core"); + return 0; + } + + if (offset) { + PERR("Parameter 'offset' not supported within core"); + return 0; + } + + /* allocate range in core's virtual address space */ + void *virt_addr; + if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) { + PERR("Could not allocate virtual address range in core of size %zd\n", + page_rounded_size); + return false; + } + + if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) { + PERR("core-local memory mapping failed virt=%lx, phys=%lx\n", + (addr_t)virt_addr, ds->phys_addr()); + return 0; + } + + return virt_addr; +} diff --git a/base-codezero/src/core/include/core_rm_session.h b/base-codezero/src/core/include/core_rm_session.h new file mode 100644 index 000000000..064115d70 --- /dev/null +++ b/base-codezero/src/core/include/core_rm_session.h @@ -0,0 +1,52 @@ +/* + * \brief Core-local region manager session + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__CORE_RM_SESSION_H_ +#define _CORE__INCLUDE__CORE_RM_SESSION_H_ + +/* Genode includes */ +#include + +/* core includes */ +#include + +namespace Genode { + + class Core_rm_session : public Rm_session + { + private: + + Rpc_entrypoint *_ds_ep; + + public: + + Core_rm_session(Rpc_entrypoint *ds_ep) : _ds_ep(ds_ep) { } + + Local_addr attach(Dataspace_capability ds_cap, size_t size = 0, + off_t offset = 0, bool use_local_addr = false, + Local_addr local_addr = 0); + + void detach(Local_addr) { } + + Pager_capability add_client(Thread_capability) { + return Pager_capability(); } + + void fault_handler(Signal_context_capability) { } + + State state() { return State(); } + + Dataspace_capability dataspace() { return Dataspace_capability(); } + }; +} + +#endif /* _CORE__INCLUDE__CORE_RM_SESSION_H_ */ diff --git a/base-codezero/src/core/include/irq_session_component.h b/base-codezero/src/core/include/irq_session_component.h new file mode 100644 index 000000000..7d51690bc --- /dev/null +++ b/base-codezero/src/core/include/irq_session_component.h @@ -0,0 +1,71 @@ +/* + * \brief IRQ session interface for NOVA + * \author Norman Feske + * \date 2010-01-30 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ + +#include +#include + +#include + +namespace Genode { + + class Irq_session_component : public Rpc_object, + public List::Element + { + private: + + enum { STACK_SIZE = 4096 }; + + unsigned _irq_number; + Range_allocator *_irq_alloc; + Rpc_entrypoint _entrypoint; + Irq_session_capability _cap; + bool _attached; + + public: + + /** + * Constructor + * + * \param cap_session capability session to use + * \param irq_alloc platform-dependent IRQ allocator + * \param args session construction arguments + */ + Irq_session_component(Cap_session *cap_session, + Range_allocator *irq_alloc, + const char *args); + + /** + * Destructor + */ + ~Irq_session_component(); + + /** + * Return capability to this session + * + * If an initialization error occurs, returned capability is invalid. + */ + Irq_session_capability cap() const { return _cap; } + + + /*************************** + ** Irq session interface ** + ***************************/ + + void wait_for_irq(); + }; +} + +#endif /* _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ */ diff --git a/base-codezero/src/core/include/map_local.h b/base-codezero/src/core/include/map_local.h new file mode 100644 index 000000000..a9822721e --- /dev/null +++ b/base-codezero/src/core/include/map_local.h @@ -0,0 +1,66 @@ +/* + * \brief Core-local mapping + * \author Norman Feske + * \date 2010-02-15 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__MAP_LOCAL_H_ +#define _CORE__INCLUDE__MAP_LOCAL_H_ + +/* Genode includes */ +#include + +/* core includes */ +#include + + +namespace Genode { + + /** + * Map physical pages to core-local virtual address range + * + * On Codezero, mappings originate from the physical address space. + * + * \param from_phys physical source address + * \param to_virt core-local destination address + * \param num_pages number of pages to map + * + * \return true on success + */ + inline bool map_local(addr_t from_phys, addr_t to_virt, size_t num_pages) + { + using namespace Codezero; + + int res = l4_map((void *)from_phys, (void *)to_virt, + num_pages, MAP_USR_RW, thread_myself()); + if (res < 0) { + PERR("l4_map phys 0x%lx -> 0x%lx returned %d", from_phys, to_virt, res); + return false; + } + + return true; + } + + + inline bool unmap_local(addr_t virt_addr, size_t num_pages) + { + using namespace Codezero; + + int res = l4_unmap((void *)virt_addr, num_pages, thread_myself()); + if (res < 0) { + PERR("l4_unmap returned %d", res); + return false; + } + + return true; + } +} + +#endif /* _CORE__INCLUDE__MAP_LOCAL_H_ */ diff --git a/base-codezero/src/core/include/platform.h b/base-codezero/src/core/include/platform.h new file mode 100644 index 000000000..dcb456e01 --- /dev/null +++ b/base-codezero/src/core/include/platform.h @@ -0,0 +1,72 @@ +/* + * \brief Platform interface + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_H_ +#define _CORE__INCLUDE__PLATFORM_H_ + +/* Genode includes */ +#include + +/* local includes */ +#include +#include + +namespace Genode { + + class Platform : public Platform_generic + { + private: + + typedef Core_mem_allocator::Phys_allocator Phys_allocator; + + Core_mem_allocator _core_mem_alloc; /* core-accessible memory */ + Phys_allocator _io_mem_alloc; /* MMIO allocator */ + Phys_allocator _io_port_alloc; /* I/O port allocator */ + Phys_allocator _irq_alloc; /* IRQ allocator */ + Rom_fs _rom_fs; /* ROM file system */ + + /** + * Virtual address range usable by non-core processes + */ + addr_t _vm_base; + size_t _vm_size; + + int _init_rom_fs(); + + public: + + /** + * Constructor + */ + Platform(); + + + /******************************** + ** Generic platform interface ** + ********************************/ + + Range_allocator *ram_alloc() { return _core_mem_alloc.phys_alloc(); } + Range_allocator *io_mem_alloc() { return &_io_mem_alloc; } + Range_allocator *io_port_alloc() { return &_io_port_alloc; } + Range_allocator *irq_alloc() { return &_irq_alloc; } + Range_allocator *region_alloc() { return _core_mem_alloc.virt_alloc(); } + Allocator *core_mem_alloc() { return &_core_mem_alloc; } + addr_t vm_start() const { return _vm_base; } + size_t vm_size() const { return _vm_size; } + Rom_fs *rom_fs() { return &_rom_fs; } + + void wait_for_exit(); + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_H_ */ diff --git a/base-codezero/src/core/include/platform_pd.h b/base-codezero/src/core/include/platform_pd.h new file mode 100644 index 000000000..eb6a7e42d --- /dev/null +++ b/base-codezero/src/core/include/platform_pd.h @@ -0,0 +1,74 @@ +/* + * \brief Protection-domain facility + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_PD_H_ +#define _CORE__INCLUDE__PLATFORM_PD_H_ + +/* core includes */ +#include + +/* Codezero includes */ +#include + +namespace Genode { + + class Platform_thread; + class Platform_pd + { + private: + + enum { MAX_THREADS_PER_PD = 32 }; + enum { UTCB_VIRT_BASE = 0x30000000 }; + enum { UTCB_AREA_SIZE = MAX_THREADS_PER_PD*sizeof(struct Codezero::utcb) }; + + int _space_id; + + bool utcb_in_use[MAX_THREADS_PER_PD]; + + public: + + + /** + * Constructors + */ + Platform_pd(bool core); + Platform_pd(signed pd_id = -1, bool create = true); + + /** + * Destructor + */ + ~Platform_pd(); + + /** + * Bind thread to protection domain + * + * \return 0 on success or + * -1 if thread ID allocation failed. + */ + int bind_thread(Platform_thread *thread); + + /** + * Unbind thread from protection domain + * + * Free the thread's slot and update thread object. + */ + void unbind_thread(Platform_thread *thread); + + /** + * Assign parent interface to protection domain + */ + int assign_parent(Native_capability parent) { return 0; } + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */ diff --git a/base-codezero/src/core/include/platform_thread.h b/base-codezero/src/core/include/platform_thread.h new file mode 100644 index 000000000..1895715e4 --- /dev/null +++ b/base-codezero/src/core/include/platform_thread.h @@ -0,0 +1,135 @@ +/* + * \brief Thread facility + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_THREAD_H_ +#define _CORE__INCLUDE__PLATFORM_THREAD_H_ + +/* Genode includes */ +#include +#include +#include + +namespace Genode { + + class Platform_pd; + class Platform_thread + { + private: + + friend class Platform_pd; + + enum { PD_NAME_MAX_LEN = 64 }; + + int _tid; /* global codezero thread ID */ + int _space_id; + addr_t _utcb; + char _name[PD_NAME_MAX_LEN]; + Pager_object *_pager; + + /** + * Assign physical thread ID and UTCB address to thread + * + * This function is called from 'Platform_pd::bind_thread'. + */ + void _assign_physical_thread(int tid, int space_id, addr_t utcb) { + _tid = tid; _space_id = space_id; _utcb = utcb; } + + public: + + enum { THREAD_INVALID = -1 }; /* invalid thread number */ + + /** + * Constructor + */ + Platform_thread(const char *name = 0, unsigned priority = 0, + int thread_id = THREAD_INVALID); + + /** + * Destructor + */ + ~Platform_thread(); + + /** + * Start thread + * + * \param ip instruction pointer to start at + * \param sp stack pointer to use + * \param cpu_no target cpu + * + * \retval 0 successful + * \retval -1 thread could not be started + */ + int start(void *ip, void *sp, unsigned int cpu_no = 0); + + /** + * Pause this thread + */ + void pause(); + + /** + * Resume this thread + */ + void resume(); + + /** + * Cancel currently blocking operation + */ + void cancel_blocking(); + + /** + * Request thread state + * + * \param state_dst destination state buffer + * + * \retval 0 successful + * \retval -1 thread state not accessible + */ + int state(Genode::Thread_state *state_dst); + + + /************************ + ** Accessor functions ** + ************************/ + + /** + * Set pager capability + */ + Pager_object *pager(Pager_object *pager) const { return _pager; } + void pager(Pager_object *pager) { _pager = pager; } + Pager_object *pager() { return _pager; } + + /** + * Return identification of thread when faulting + */ + unsigned long pager_object_badge() const { return _tid; } + + /** + * Set the executing CPU for this thread. + */ + void set_cpu(unsigned int cpu_no); + + /** + * Get thread name + */ + const char *name() const { return "noname"; } + + + /*********************** + ** Codezero specific ** + ***********************/ + + addr_t utcb() const { return _utcb; } + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */ diff --git a/base-codezero/src/core/include/util.h b/base-codezero/src/core/include/util.h new file mode 100644 index 000000000..3524d02c2 --- /dev/null +++ b/base-codezero/src/core/include/util.h @@ -0,0 +1,46 @@ +/* + * \brief Core-internal utilities + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__UTIL_H_ +#define _CORE__INCLUDE__UTIL_H_ + +/* Genode includes */ +#include +#include + +/* Codezero includes */ +#include + +namespace Genode { + + inline size_t get_page_size_log2() { return 12; } + inline size_t get_page_size() { return 1 << get_page_size_log2(); } + inline addr_t get_page_mask() { return ~(get_page_size() - 1); } + inline addr_t trunc_page(addr_t addr) { return addr & get_page_mask(); } + inline addr_t round_page(addr_t addr) { return trunc_page(addr + get_page_size() - 1); } + + inline addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; } + inline size_t constrain_map_size_log2(size_t size_log2) { return get_page_size_log2(); } + + inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, + Rm_session::Fault_type pf_type, + unsigned long faulter_badge) + { + printf("%s (%s pf_addr=%p pf_ip=%p from %02lx)\n", msg, + pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ", + (void *)pf_addr, (void *)pf_ip, + faulter_badge); + } +} + +#endif /* _CORE__INCLUDE__UTIL_H_ */ diff --git a/base-codezero/src/core/io_mem_session_support.cc b/base-codezero/src/core/io_mem_session_support.cc new file mode 100644 index 000000000..6b1f5715e --- /dev/null +++ b/base-codezero/src/core/io_mem_session_support.cc @@ -0,0 +1,27 @@ +/* + * \brief Implementation of the IO_MEM session interface + * \author Norman Feske + * \date 2009-03-29 + * + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + + +using namespace Genode; + + +void Io_mem_session_component::_unmap_local(addr_t base, size_t size) +{ } + + +addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) +{ return 0; } diff --git a/base-codezero/src/core/io_port_session_component.cc b/base-codezero/src/core/io_port_session_component.cc new file mode 100644 index 000000000..c90a87b7e --- /dev/null +++ b/base-codezero/src/core/io_port_session_component.cc @@ -0,0 +1,58 @@ +/* + * \brief Implementation of the IO_PORT session interface + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include "io_port_session_component.h" + +using namespace Genode; + + +/************** + ** Port API ** + **************/ + +unsigned char Io_port_session_component::inb(unsigned short address) { + return 0; } + + +unsigned short Io_port_session_component::inw(unsigned short address) { + return 0; } + + +unsigned Io_port_session_component::inl(unsigned short address) { + return 0; } + + +void Io_port_session_component::outb(unsigned short address, unsigned char value) +{ } + + +void Io_port_session_component::outw(unsigned short address, unsigned short value) +{ } + + +void Io_port_session_component::outl(unsigned short address, unsigned value) +{ } + + +/****************************** + ** Constructor / destructor ** + ******************************/ + +Io_port_session_component::Io_port_session_component(Range_allocator *io_port_alloc, + const char *args) +: _io_port_alloc(io_port_alloc) +{ } + + +Io_port_session_component::~Io_port_session_component() +{ } diff --git a/base-codezero/src/core/irq_session_component.cc b/base-codezero/src/core/irq_session_component.cc new file mode 100644 index 000000000..4975c1a3c --- /dev/null +++ b/base-codezero/src/core/irq_session_component.cc @@ -0,0 +1,72 @@ +/* + * \brief Implementation of IRQ session component + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include + +/* Codezero includes */ +#include + + +using namespace Genode; + + +void Irq_session_component::wait_for_irq() +{ + using namespace Codezero; + + /* attach thread to IRQ when first called */ + if (!_attached) { + int ret = l4_irq_control(IRQ_CONTROL_REGISTER, 0, _irq_number); + if (ret < 0) { + PERR("l4_irq_control(IRQ_CONTROL_REGISTER) returned %d", ret); + sleep_forever(); + } + _attached = true; + } + + /* block for IRQ */ + int ret = l4_irq_control(IRQ_CONTROL_WAIT, 0, _irq_number); + if (ret < 0) + PWRN("l4_irq_control(IRQ_CONTROL_WAIT) returned %d", ret); +} + + +Irq_session_component::Irq_session_component(Cap_session *cap_session, + Range_allocator *irq_alloc, + const char *args) +: + _irq_alloc(irq_alloc), + _entrypoint(cap_session, STACK_SIZE, "irq"), + _attached(false) +{ + long irq_number = Arg_string::find_arg(args, "irq_number").long_value(-1); + if (!irq_alloc || (irq_number == -1)|| + irq_alloc->alloc_addr(1, irq_number) != Range_allocator::ALLOC_OK) { + PERR("unavailable IRQ %lx requested", irq_number); + return; + } + _irq_number = irq_number; + _cap = Irq_session_capability(_entrypoint.manage(this)); +} + + +Irq_session_component::~Irq_session_component() +{ + PERR("not yet implemented"); +} + diff --git a/base-codezero/src/core/platform.cc b/base-codezero/src/core/platform.cc new file mode 100644 index 000000000..b7c2551a9 --- /dev/null +++ b/base-codezero/src/core/platform.cc @@ -0,0 +1,293 @@ +/* + * \brief Platform interface implementation + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include + +/* core includes */ +#include +#include +#include + +/* Codezero includes */ +#include + +using namespace Genode; + +enum { verbose_boot_info = true }; + +/* + * Memory-layout information provided by the linker script + */ + +/* virtual address range consumed by core's program image */ +extern unsigned _prog_img_beg, _prog_img_end; + +/* physical address range occupied by core */ +extern addr_t _vma_start, _lma_start; + + +/************************** + ** Boot-module handling ** + **************************/ + +/** + * Scan ROM module image for boot modules + * + * By convention, the boot modules start at the page after core's BSS segment. + */ +int Platform::_init_rom_fs() +{ + /** + * Format of module meta-data as found in the ROM module image + */ + struct Module + { + long name; /* physical address of null-terminated string */ + long base; /* physical address of module data */ + long size; /* size of module data in bytes */ + }; + + /* find base address of ROM module image */ + addr_t phys_base = round_page((addr_t)&_prog_img_end); + + /* map the first page of the image containing the module meta data */ + class Out_of_virtual_memory_during_rom_fs_init { }; + void *virt_base = 0; + if (!_core_mem_alloc.virt_alloc()->alloc(get_page_size(), &virt_base)) + throw Out_of_virtual_memory_during_rom_fs_init(); + + if (!map_local(phys_base, (addr_t)virt_base, 1)) { + PERR("map_local failed"); + return -1; + } + + /* remove page containing module infos from physical memory allocator */ + _core_mem_alloc.phys_alloc()->remove_range(phys_base, get_page_size()); + + /* validate the presence of a ROM image by checking the magic cookie */ + const char cookie[4] = {'G', 'R', 'O', 'M'}; + for (size_t i = 0; i < sizeof(cookie); i++) + if (cookie[i] != ((char *)virt_base)[i]) { + PERR("could not detect ROM modules"); + return -2; + } + + printf("detected ROM module image at 0x%p\n", (void *)phys_base); + + /* detect overly large meta data, we only support 4K */ + addr_t end_of_header = ((long *)virt_base)[1]; + size_t header_size = end_of_header - (long)phys_base; + if (header_size > get_page_size()) { + PERR("ROM fs module header exceeds %d bytes", get_page_size()); + return -3; + } + + /* start of module list */ + Module *module = (Module *)((addr_t)virt_base + 2*sizeof(long)); + + /* + * Interate over module list and populate core's ROM file system with + * 'Rom_module' objects. + */ + for (; module->name; module++) { + + /* convert physical address of module name to core-local address */ + char *name = (char *)(module->name - phys_base + (addr_t)virt_base); + + printf("ROM module \"%s\" at physical address 0x%p, size=%zd\n", + name, (void *)module->base, (size_t)module->size); + + Rom_module *rom_module = new (core_mem_alloc()) + Rom_module(module->base, module->size, name); + + _rom_fs.insert(rom_module); + + /* remove module from physical memory allocator */ + _core_mem_alloc.phys_alloc()->remove_range(module->base, round_page(module->size)); + } + return 0; +} + + +/**************************************** + ** Support for core memory management ** + ****************************************/ + +bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, unsigned size_log2) +{ + return map_local(phys_addr, virt_addr, 1 << (size_log2 - get_page_size_log2())); +} + + +/************************ + ** Platform interface ** + ************************/ + +Platform::Platform() : + _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), + _irq_alloc(core_mem_alloc()), _vm_base(0), _vm_size(0) +{ + using namespace Codezero; + + /* init core UTCB */ + static char main_utcb[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + static struct exregs_data exregs; + exregs_set_utcb(&exregs, (unsigned long)&main_utcb[0]); + l4_exchange_registers(&exregs, thread_myself()); + + /* error handling is futile at this point */ + + /* read number of capabilities */ + int num_caps; + int ret; + if ((ret = l4_capability_control(CAP_CONTROL_NCAPS, + 0, &num_caps)) < 0) { + PERR("l4_capability_control(CAP_CONTROL_NCAPS) returned %d", ret); + class Could_not_obtain_num_of_capabilities { }; + throw Could_not_obtain_num_of_capabilities(); + } + + struct capability cap_array[num_caps]; + + if (verbose_boot_info) + printf("allocated cap array[%d] of size %d on stack\n", + num_caps, sizeof(cap_array)); + + /* read all capabilities */ + if ((ret = l4_capability_control(CAP_CONTROL_READ, + 0, cap_array)) < 0) { + PERR("l4_capability_control(CAP_CONTROL_READ) returned %d", ret); + class Read_caps_failed { }; + throw Read_caps_failed(); + } + + /* initialize core allocators */ + bool phys_mem_defined = false; + addr_t dev_mem_base = 0; + for (int i = 0; i < num_caps; i++) { + struct capability *cap = &cap_array[i]; + + addr_t base = cap->start << get_page_size_log2(), + size = cap->size << get_page_size_log2(); + + if (verbose_boot_info) + printf("cap type=%x, rtype=%x, base=%lx, size=%lx\n", + cap_type(cap), cap_rtype(cap), base, size); + + switch (cap_type(cap)) { + + case CAP_TYPE_MAP_VIRTMEM: + + /* + * Use first non-UTCB virtual address range as default + * virtual memory range usable for all processes. + */ + if (_vm_size == 0) { + + /* exclude page at virtual address 0 */ + if (base == 0 && size >= get_page_size()) { + base += get_page_size(); + size -= get_page_size(); + } + + _vm_base = base; + _vm_size = size; + + /* add range as free range to core's virtual address allocator */ + _core_mem_alloc.virt_alloc()->add_range(base, size); + break; + } + + PWRN("ignoring additional virtual address range [%lx,%lx)", + base, base + size); + break; + + case CAP_TYPE_MAP_PHYSMEM: + + /* + * We interpret the first physical memory resource that is bigger + * than typical device resources as RAM. + */ + enum { RAM_SIZE_MIN = 16*1024*1024 }; + if (!phys_mem_defined && size > RAM_SIZE_MIN) { + _core_mem_alloc.phys_alloc()->add_range(base, size); + phys_mem_defined = true; + dev_mem_base = base + size; + } + break; + + case CAP_TYPE_IPC: + case CAP_TYPE_UMUTEX: + case CAP_TYPE_IRQCTRL: + case CAP_TYPE_QUANTITY: + break; + } + } + + addr_t core_virt_beg = trunc_page((addr_t)&_prog_img_beg), + core_virt_end = round_page((addr_t)&_prog_img_end); + size_t core_size = core_virt_end - core_virt_beg; + + printf("core image:\n"); + printf(" virtual address range [%08lx,%08lx) size=0x%zx\n", + core_virt_beg, core_virt_end, core_size); + printf(" physically located at 0x%08lx\n", _lma_start); + + /* remove core image from core's virtual address allocator */ + _core_mem_alloc.virt_alloc()->remove_range(core_virt_beg, core_size); + + /* preserve context area in core's virtual address space */ + _core_mem_alloc.virt_alloc()->raw()->remove_range(Thread_base::CONTEXT_AREA_VIRTUAL_BASE, + Thread_base::CONTEXT_AREA_VIRTUAL_SIZE); + + /* remove used core memory from physical memory allocator */ + _core_mem_alloc.phys_alloc()->remove_range(_lma_start, core_size); + + /* remove magically mapped UART from core virtual memory */ + _core_mem_alloc.virt_alloc()->remove_range(USERSPACE_CONSOLE_VBASE, get_page_size()); + + /* add boot modules to ROM fs */ + if (_init_rom_fs() < 0) { + PERR("initialization of romfs failed - halt."); + while(1); + } + + /* initialize interrupt allocator */ + _irq_alloc.add_range(0, 255); + + /* regard physical addresses higher than memory area as MMIO */ + _io_mem_alloc.add_range(dev_mem_base, 0x80000000 - dev_mem_base); + + /* + * Print statistics about allocator initialization + */ + printf("VM area at [%08lx,%08lx)\n", _vm_base, _vm_base + _vm_size); + + if (verbose_boot_info) { + printf(":phys_alloc: "); _core_mem_alloc.phys_alloc()->raw()->dump_addr_tree(); + printf(":virt_alloc: "); _core_mem_alloc.virt_alloc()->raw()->dump_addr_tree(); + printf(":io_mem_alloc: "); _io_mem_alloc.raw()->dump_addr_tree(); + } +} + + +void Platform::wait_for_exit() +{ + sleep_forever(); +} + + +void Core_parent::exit(int exit_value) { } diff --git a/base-codezero/src/core/platform_pd.cc b/base-codezero/src/core/platform_pd.cc new file mode 100644 index 000000000..2dbd758a3 --- /dev/null +++ b/base-codezero/src/core/platform_pd.cc @@ -0,0 +1,124 @@ +/* + * \brief Protection-domain facility + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include +#include +#include + +using namespace Genode; +using namespace Codezero; + + +/*************************** + ** Public object members ** + ***************************/ + +int Platform_pd::bind_thread(Platform_thread *thread) +{ + /* allocate new thread at the kernel */ + struct task_ids ids = { 1, _space_id, TASK_ID_INVALID }; + int ret = l4_thread_control(THREAD_CREATE | TC_SHARE_SPACE, &ids); + if (ret < 0) { + PERR("l4_thread_control returned %d, tid=%d\n", ret, ids.tid); + return -1; + } + + /* allocate UTCB for new thread */ + int utcb_idx; + for (utcb_idx = 0; utcb_idx < MAX_THREADS_PER_PD; utcb_idx++) + if (!utcb_in_use[utcb_idx]) break; + + if (utcb_idx == MAX_THREADS_PER_PD) { + PERR("UTCB allocation failed"); + return -2; + } + + /* mark UTCB as being in use */ + utcb_in_use[utcb_idx] = true; + + /* map UTCB area for the first thread of a new PD */ + if (utcb_idx == 0) { + void *utcb_phys = 0; + if (!platform()->ram_alloc()->alloc(UTCB_AREA_SIZE, &utcb_phys)) { + PERR("could not allocate physical pages for UTCB"); + return -3; + } + + ret = l4_map(utcb_phys, (void *)UTCB_VIRT_BASE, + UTCB_AREA_SIZE/get_page_size(), MAP_USR_RW, ids.tid); + if (ret < 0) { + PERR("UTCB mapping into new PD failed, ret=%d", ret); + return -4; + } + } + + addr_t utcb_addr = UTCB_VIRT_BASE + utcb_idx*sizeof(struct utcb); + thread->_assign_physical_thread(ids.tid, _space_id, utcb_addr); + return 0; +} + + +void Platform_pd::unbind_thread(Platform_thread *thread) +{ + /* find UTCB index of thread */ + unsigned utcb_idx; + for (utcb_idx = 0; utcb_idx < MAX_THREADS_PER_PD; utcb_idx++) + if (thread->utcb() == UTCB_VIRT_BASE + utcb_idx*sizeof(struct utcb)) + break; + + if (utcb_idx == MAX_THREADS_PER_PD) { + PWRN("could not find UTCB index of thread"); + return; + } + + utcb_in_use[utcb_idx] = false; + + PWRN("not fully implemented"); +} + + +Platform_pd::Platform_pd(bool core) +{ + PWRN("not yet implemented"); +} + + +Platform_pd::Platform_pd(signed pd_id, bool create) : _space_id(-1) +{ + _space_id = -1; + + /* mark all UTCBs of the new PD as free */ + for (int i = 0; i < MAX_THREADS_PER_PD; i++) + utcb_in_use[i] = false; + + struct task_ids ids = { -1, -1, -1 }; + + int ret = l4_thread_control(THREAD_CREATE | TC_NEW_SPACE, &ids); + if (ret < 0) { + PERR("l4_thread_control(THREAD_CREATE | TC_NEW_SPACE) returned %d", ret); + return; + } + + /* set space ID to valid value to indicate success */ + _space_id = ids.spid; +} + + +Platform_pd::~Platform_pd() +{ + PWRN("not yet implemented"); +} diff --git a/base-codezero/src/core/platform_thread.cc b/base-codezero/src/core/platform_thread.cc new file mode 100644 index 000000000..bead355a1 --- /dev/null +++ b/base-codezero/src/core/platform_thread.cc @@ -0,0 +1,104 @@ +/* + * \brief Thread facility + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include + +/* Codezero includes */ +#include + +enum { verbose_thread_start = true }; + +using namespace Genode; +using namespace Codezero; + + +void Platform_thread::set_cpu(unsigned int cpu_no) +{ + PDBG("not yet implemented"); +} + + +int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no) +{ + Native_thread_id pager = _pager ? _pager->cap().tid() : -1; + + /* setup thread context */ + struct exregs_data exregs; + exregs.flags = 0; + exregs_set_stack(&exregs, (unsigned long)sp); + exregs_set_pc (&exregs, (unsigned long)ip); + exregs_set_pager(&exregs, pager.tid); + exregs_set_utcb (&exregs, _utcb); + + int ret = l4_exchange_registers(&exregs, _tid); + if (ret < 0) { + printf("l4_exchange_registers returned ret=%d\n", ret); + return -2; + } + + /* start execution */ + struct task_ids ids = { _tid, _space_id, _tid }; + ret = l4_thread_control(THREAD_RUN, &ids); + if (ret < 0) { + printf("Error: l4_thread_control(THREAD_RUN) returned %d\n", ret); + return -3; + } + + if (verbose_thread_start) + printf("core started thread \"%s\" with ID %d inside space ID %d\n", + _name, _tid, _space_id); + return 0; +} + + +void Platform_thread::pause() +{ + PDBG("not implemented"); +} + + +void Platform_thread::resume() +{ + PDBG("not implemented"); +} + + +int Platform_thread::state(Thread_state *state_dst) +{ + PDBG("not implemented"); + return -1; +} + + +void Platform_thread::cancel_blocking() +{ + PDBG("not implemented"); +} + + +Platform_thread::Platform_thread(const char *name, unsigned, int thread_id) +: _tid(-1) +{ + strncpy(_name, name, sizeof(_name)); +} + + +Platform_thread::~Platform_thread() +{ + PDBG("not implemented"); +} diff --git a/base-codezero/src/core/ram_session_support.cc b/base-codezero/src/core/ram_session_support.cc new file mode 100644 index 000000000..6e57322f1 --- /dev/null +++ b/base-codezero/src/core/ram_session_support.cc @@ -0,0 +1,65 @@ +/* + * \brief Export RAM dataspace as shared memory object (dummy) + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include +#include +#include + + +using namespace Genode; + +void Ram_session_component::_export_ram_ds(Dataspace_component *ds) { } +void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds) { } + +void Ram_session_component::_clear_ds (Dataspace_component *ds) +{ + using namespace Codezero; + + /* + * Map dataspace core-locally, memset, unmap dataspace + */ + + size_t page_rounded_size = (ds->size() + get_page_size() - 1) & get_page_mask(); + size_t num_pages = page_rounded_size >> get_page_size_log2(); + + /* allocate range in core's virtual address space */ + void *virt_addr; + if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) { + PERR("Could not allocate virtual address range in core of size %zd\n", + page_rounded_size); + return; + } + + /* map the dataspace's physical pages to corresponding virtual addresses */ + if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) { + PERR("core-local memory mapping failed\n"); + return; + } + + memset(virt_addr, 0, ds->size()); + + /* unmap dataspace from core */ + if (!unmap_local((addr_t)virt_addr, num_pages)) { + PERR("could not unmap %zd pages from virtual address range at %p", + num_pages, virt_addr); + return; + } + + /* free core's virtual address space */ + platform()->region_alloc()->free(virt_addr, page_rounded_size); +} diff --git a/base-codezero/src/core/rm_session_support.cc b/base-codezero/src/core/rm_session_support.cc new file mode 100644 index 000000000..cae0eed70 --- /dev/null +++ b/base-codezero/src/core/rm_session_support.cc @@ -0,0 +1,28 @@ +/* + * \brief RM-session implementation + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include +#include + +/* Codezero includes */ +#include + +using namespace Genode; +using namespace Codezero; + + +void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size) +{ + l4_unmap((void *)virt_base, size >> get_page_size_log2(), badge()); +} diff --git a/base-codezero/src/core/target.inc b/base-codezero/src/core/target.inc new file mode 100644 index 000000000..3557657a2 --- /dev/null +++ b/base-codezero/src/core/target.inc @@ -0,0 +1,55 @@ +TARGET = core +LIBS = cxx ipc heap core_printf process pager lock \ + raw_signal raw_server + +GEN_CORE_DIR = $(BASE_DIR)/src/core + +SRC_CC = \ + main.cc \ + ram_session_component.cc \ + ram_session_support.cc \ + rom_session_component.cc \ + cpu_session_component.cc \ + pd_session_component.cc \ + io_mem_session_component.cc \ + io_mem_session_support.cc \ + thread.cc \ + thread_start.cc \ + thread_bootstrap.cc \ + platform_thread.cc \ + platform_pd.cc \ + platform.cc \ + dataspace_component.cc \ + rm_session_component.cc \ + rm_session_support.cc \ + io_port_session_component.cc \ + irq_session_component.cc \ + signal_session_component.cc \ + signal_source_component.cc \ + core_rm_session.cc \ + core_mem_alloc.cc \ + dump_alloc.cc \ + context_area.cc + +INC_DIR = $(REP_DIR)/src/core/include \ + $(GEN_CORE_DIR)/include \ + $(REP_DIR)/include/codezero/dummies + +vpath main.cc $(GEN_CORE_DIR) +vpath ram_session_component.cc $(GEN_CORE_DIR) +vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath cpu_session_component.cc $(GEN_CORE_DIR) +vpath pd_session_component.cc $(GEN_CORE_DIR) +vpath rm_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_support.cc $(GEN_CORE_DIR) +vpath signal_session_component.cc $(GEN_CORE_DIR) +vpath signal_source_component.cc $(GEN_CORE_DIR) +vpath dataspace_component.cc $(GEN_CORE_DIR) +vpath core_mem_alloc.cc $(GEN_CORE_DIR) +vpath dump_alloc.cc $(GEN_CORE_DIR) +vpath context_area.cc $(GEN_CORE_DIR) +vpath %.cc $(REP_DIR)/src/core +vpath thread_bootstrap.cc $(BASE_DIR)/src/base/thread +vpath thread.cc $(BASE_DIR)/src/base/thread + diff --git a/base-codezero/src/core/target.mk b/base-codezero/src/core/target.mk new file mode 100644 index 000000000..b1aacf1a0 --- /dev/null +++ b/base-codezero/src/core/target.mk @@ -0,0 +1,4 @@ +include $(PRG_DIR)/target.inc + +LD_TEXT_ADDR = 0x100000 + diff --git a/base-codezero/src/core/thread_start.cc b/base-codezero/src/core/thread_start.cc new file mode 100644 index 000000000..b642a276c --- /dev/null +++ b/base-codezero/src/core/thread_start.cc @@ -0,0 +1,121 @@ +/* + * \brief Implementation of Thread API interface for core + * \author Norman Feske + * \date 2006-05-03 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Codezero includes */ +#include + +/* Genode includes */ +#include +#include +#include + +/* core includes */ +#include +#include + +enum { verbose_thread_start = true }; + +using namespace Genode; + + +void Thread_base::_init_platform_thread() { } + + +void Thread_base::_deinit_platform_thread() { } + + +/** + * Create and start new thread + * + * \param space_no space ID in which the new thread will be executed + * \param sp initial stack pointer + * \param ip initial instruction pointer + * \return new thread ID, or + * negative error code + */ +inline int create_thread(int space_no, + void *sp, void *ip, + int pager_tid = 1) +{ + using namespace Codezero; + + struct task_ids ids = { 1, space_no, TASK_ID_INVALID }; + + /* allocate new thread at the kernel */ + unsigned long flags = THREAD_CREATE | TC_SHARE_SPACE | TC_SHARE_GROUP; + int ret = l4_thread_control(flags, &ids); + if (ret < 0) { + PERR("l4_thread_control returned %d, spid=%d\n", + ret, ids.spid); + return -1; + } + + unsigned long utcb_base_addr = (unsigned long)l4_get_utcb(); + + /* calculate utcb address of new thread */ + unsigned long new_utcb = utcb_base_addr + ids.tid*sizeof(struct utcb); + + /* setup thread context */ + struct exregs_data exregs; + exregs_set_stack(&exregs, (unsigned long)sp); + exregs_set_pc (&exregs, (unsigned long)ip); + exregs_set_pager(&exregs, pager_tid); + exregs_set_utcb (&exregs, new_utcb); + + ret = l4_exchange_registers(&exregs, ids.tid); + if (ret < 0) { + printf("l4_exchange_registers returned ret=%d\n", ret); + return -2; + } + + /* start execution */ + ret = l4_thread_control(THREAD_RUN, &ids); + if (ret < 0) { + printf("Error: l4_thread_control(THREAD_RUN) returned %d\n", ret); + return -3; + } + + /* return new thread ID allocated by the kernel */ + return ids.tid; +} + + +void Thread_base::_thread_start() +{ + Thread_base::myself()->_thread_bootstrap(); + Thread_base::myself()->entry(); + sleep_forever(); +} + + +void Thread_base::start() +{ + /* create and start platform thread */ + _tid.pt = new(platform()->core_mem_alloc()) Platform_thread(_context->name); + + _tid.l4id = create_thread(1, &_context->stack[-4], (void *)&_thread_start); + if (_tid.l4id.tid < 0) + PERR("create_thread returned %d", _tid.l4id.tid); + + if (verbose_thread_start) + printf("core started local thread \"%s\" with ID %d\n", + _context->name, _tid.l4id.tid); +} + + +void Thread_base::cancel_blocking() +{ + PWRN("not implemented"); +} + + diff --git a/base-codezero/src/kernel/target.mk b/base-codezero/src/kernel/target.mk new file mode 100644 index 000000000..a96dbcbef --- /dev/null +++ b/base-codezero/src/kernel/target.mk @@ -0,0 +1,74 @@ +TARGET = codezero + +-include $(BUILD_BASE_DIR)/etc/codezero.conf +ifeq ($(wildcard $(CODEZERO_DIR)),) +$(error No valid kernel configured in 'etc/codezero.conf') +endif + +include $(REP_DIR)/lib/mk/codezero_cml.inc + +TOOL_CHAIN_DIR = $(dir $(CROSS_DEV_PREFIX)) +CODEZERO_DST_DIR = $(BUILD_BASE_DIR)/kernel/codezero +CODEZERO_BUILD_DIR = $(CODEZERO_DST_DIR)/build + +.PHONY: $(TARGET) + +MIRROR_COPY := conts/baremetal/empty conts/userlibs \ + build.py include SConstruct src loader + +MIRROR_SYMLINK := scripts tools + +update_copy = $(VERBOSE)tar c -C $(CODEZERO_DIR) $(MIRROR_COPY) | tar x -C $(CODEZERO_DST_DIR) + +ifneq ($(VERBOSE),) +CODEZERO_STDOUT := > /dev/null +endif + +# +# Environment variables passed to the Codezero build system +# +BUILD_ENV = PATH=$(dir $(CROSS_DEV_PREFIX)):$$PATH + +# +# Local copy of the CML file used for supplying the configuration +# to the Codezero build system. +# +LOCAL_CONFIG_CML := $(shell pwd)/config.cml + +$(TARGET): $(CODEZERO_BUILD_DIR) + $(MSG_BUILD)kernel + $(update_copy) + $(VERBOSE)cd $(CODEZERO_DST_DIR); $(BUILD_ENV) ./build.py $(CODEZERO_STDOUT) + +# +# Mirror the parts of the Codezero source tree that are relevant for building +# the kernel +# +$(CODEZERO_DST_DIR): $(CODEZERO_DIR) + $(VERBOSE)test -d $@ || mkdir -p $@ + $(VERBOSE)for d in $(MIRROR_SYMLINK); do ln -sf $(realpath $^)/$$d $@/$$d; done + +$(CODEZERO_BUILD_DIR): $(CODEZERO_DST_DIR) $(CODEZERO_CML) + $(update_copy) + $(VERBOSE)cp $(CODEZERO_CML) $(LOCAL_CONFIG_CML) + @# + @# Create copy of the CML config in the local build directory to update + @# the tool chain parameters according to the CROSS_DEV_PREFIX configured + @# for Genode. + @# + $(VERBOSE)sed -i "/TOOLCHAIN_USERSPACE/s/\".*\"/\"$(notdir $(CROSS_DEV_PREFIX))\"/" $(LOCAL_CONFIG_CML) + $(VERBOSE)sed -i "/TOOLCHAIN_KERNEL/s/\".*\"/\"$(notdir $(CROSS_DEV_PREFIX))\"/" $(LOCAL_CONFIG_CML) + $(VERBOSE)cd $(CODEZERO_DST_DIR); $(BUILD_ENV) ./build.py -C -b -f $(LOCAL_CONFIG_CML) $(CODEZERO_STDOUT) + +clean cleanall: clean_codezero + +# +# Make sure to execute the 'clean_codezero' rule prior the generic clean +# rule in 'prg.mk' because the generic rule will attempt to remove $(TARGET) +# file, which is a directory in our case. +# +clean_prg_objects: clean_codezero + +clean_codezero: + $(VERBOSE)rm -f $(LOCAL_CONFIG_CML) + $(VERBOSE)rm -rf $(CODEZERO_DST_DIR) diff --git a/base-codezero/src/platform/_main_helper.h b/base-codezero/src/platform/_main_helper.h new file mode 100644 index 000000000..80a04f02f --- /dev/null +++ b/base-codezero/src/platform/_main_helper.h @@ -0,0 +1,67 @@ +/* + * \brief Platform-specific helper functions for the _main() function + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _PLATFORM___MAIN_HELPER_H_ +#define _PLATFORM___MAIN_HELPER_H_ + +#include + +/* make Codezero includes happy */ +extern "C" char *strncpy(char *dest, const char *src, Genode::size_t n); +extern "C" void *memcpy(void *dest, const void *src, Genode::size_t n); + +/* Codezero includes */ +#include + + +/**************************** + ** Codezero libl4 support ** + ****************************/ + +/* + * Unfortunately, the function 'exregs_print_registers' in 'exregs.c' refers to + * 'memset'. Because we do not want to link core against a C library, we have to + * resolve this function here. + */ +extern "C" void *memset(void *s, int c, Genode::size_t n) __attribute__((weak)); +extern "C" void *memset(void *s, int c, Genode::size_t n) +{ + return Genode::memset(s, c, n); +} + + +/* + * Same problem as for 'memset'. The 'printf' symbol is referenced from + * 'mutex.c' and 'exregs.c' of Codezero's libl4. + */ +extern "C" int printf(const char *format, ...) __attribute__((weak)); +extern "C" int printf(const char *format, ...) +{ + va_list list; + va_start(list, format); + Genode::vprintf(format, list); + va_end(list); + return 0; +} + + +/************************** + ** Startup-code helpers ** + **************************/ + +static void main_thread_bootstrap() +{ + Codezero::__l4_init(); +} + +#endif /* _PLATFORM___MAIN_HELPER_H_ */ diff --git a/base-codezero/src/platform/genode.ld b/base-codezero/src/platform/genode.ld new file mode 100644 index 000000000..064ccf6c0 --- /dev/null +++ b/base-codezero/src/platform/genode.ld @@ -0,0 +1,131 @@ +/* + * \brief Linker script for Genode programs + * \author Christian Helmuth + * \date 2006-04-12 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* values taken from Codezero's mm0 linker script */ +/*physical_base = 0x00208000;*/ +/*virtual_base = 0xe0000000;*/ +/*offset = virtual_base - physical_base;*/ + +/* + * Addresses correspond to the linker script generated by + * the Codezero build system. + */ +vma_start = 0x100000; +lma_start = 0x40000; +offset = vma_start - lma_start; + + +ENTRY(_start) + +PHDRS +{ + ro PT_LOAD; + rw PT_LOAD; +} + +SECTIONS +{ + . = vma_start; + + .text : AT (ADDR(.text) - offset) { + /* begin of program image (link address) */ + _prog_img_beg = .; + + *(.text.crt0) + *(.init) + *(.text .text.* .gnu.linkonce.t.*) + *(.fini) + *(.rodata .rodata.* .gnu.linkonce.r.*) + + . = ALIGN(0x08); + + _ctors_start = .; + KEEP (*(.ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.init_array)) /* list of constructors specific for ARM eabi */ + _ctors_end = .; + _dtors_start = .; + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + _dtors_end = .; + } : ro = 0x90909090 + + /* Linux: exception section for uaccess mechanism */ + __ex_table : { *(__ex_table) } + + .eh_frame_hdr : { *(.eh_frame_hdr) } + + . = ALIGN(0x1000); + + _prog_img_data = .; + + .data : AT (ADDR(.data) - offset) { + /* + * Leave space for parent capability parameters at start of data + * section. The protection domain creator is reponsible for storing + * sane values here. + */ + _parent_cap = .; + LONG(0xffffffff); + LONG(0xffffffff); + _vma_start = .; + LONG(vma_start); + _lma_start = .; + LONG(lma_start); + + *(.data .data.* .gnu.linkonce.d.*) + } : rw + + /* exception frames for C++ */ + .eh_frame : { + __eh_frame_start__ = .; + KEEP (*(.eh_frame)) + LONG(0) + } : rw + + .init_array : { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + + .gcc_except_table : { KEEP(*(.gcc_except_table)) } + .dynamic : { *(.dynamic) } + + /* .ARM.exidx is sorted, so has to go in its own output section */ + __exidx_start = .; + .ARM.exidx : { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } + __exidx_end = .; + + .ARM.extab : { + *(.ARM.extab*) + } : rw + + . = ALIGN(4); + + .bss : AT (ADDR(.bss) - offset) { + *(.bss .bss.* .gnu.linkonce.b.* COMMON) + } + + /* end of program image -- must be after last section */ + _prog_img_end = .; + + /DISCARD/ : { + *(.note) + *(.note.ABI-tag) + *(.comment) + } +} diff --git a/base-codezero/tool/gen_romfs b/base-codezero/tool/gen_romfs new file mode 100755 index 000000000..eca46b04d --- /dev/null +++ b/base-codezero/tool/gen_romfs @@ -0,0 +1,202 @@ +#!/usr/bin/python + +import os, re, getopt, sys +from stat import ST_SIZE +from subprocess import PIPE, Popen + +verbose = 0 + + +# return address of 4K page following the spefified address +def round_page(addr): + page_size = 0x1000 + return (addr + page_size) & ~(page_size - 1) + + +def first_free_addr_after_program(elf, cross_prefix = ""): + try: + objdump = cross_prefix + "objdump" + objdump_output = Popen([objdump, "-p", elf], + stdout=PIPE).communicate()[0] + except OSError: + print "Error: execution of " + objdump + " failed, invalid cross-tool prefix?" + exit(3) + + # + # The output of 'objdump -p' contains the list of program segments. Each + # segment has two lines of text, the first containing the 'vaddr' value and + # the latter containing the 'memsz' value. For each line, we match for both + # 'vaddr' and 'memsz' fields. When observing a line with a 'memsz' field, + # we know that the previous line contained the corresponding 'vaddr' and + # that the end address of the segment is the sum of the current 'vaddr' + # and 'memsz' values. + # + max_end_addr = 0 + for line in objdump_output.splitlines(): + match_vaddr = re.compile(".*vaddr (0x[0-9a-f]*).*").match(line) + match_memsz = re.compile(".*memsz (0x[0-9a-f]*).*").match(line) + if (match_vaddr): + vaddr = int(match_vaddr.group(1), 0) + if (match_memsz): + memsz = int(match_memsz.group(1), 0) + max_end_addr = max(max_end_addr, vaddr + memsz) + + # align the first free address at the next page boundary + return round_page(max_end_addr) + + +def generate_modules_asm(modules): + """ + Generate assembly code aggregating boot-module data from specified files. + The generated assembly code looks as follows: + + /* + * The ELF image consists only of a data section. At file offset 0, there + * is a magic cookie that core validates when accessing the ROM fs. It is + * followed by the end address of the meta data. + */ + .section .data + .string "GROM" /* magic cookie used by core to identify a ROM fs image*/ + .long header_end /* end of ROM fs meta data */ + + /* + * Each module is represented by a struct of 3 long values. The first + * value is pointer to the module name. A null-pointer marks the end of + * the module list. + */ + .long mod1_name /* pointer to the null-terminated module name */ + .long mod1_start /* pointer to the module data */ + .long mod1_end - mod1_start /* size of the module data */ + + .long 0 + + /* + * For each module, there exists a null-terminated string labeled with + * 'mod_name' referenced by the module list above. + */ + mod1_name: + .string "name of data module" + .byte 0 + + header_end: + + /* + * The data of each module must be aligned at a page boundary to enable + * the mapping of individual modules to different address spaces. + */ + .align 4096 + mod1_start: .incbin "data" + mod1_end: + """ + + asm_src = "" + + # header + asm_src += ".section .data\nmodule_list:\n" + asm_src += ".ascii \"GROM\"\n" + asm_src += ".long header_end\n" + + # module list + i = 1 + for module in modules: + asm_src += ".long mod" + str(i) + "_name\n" + asm_src += ".long mod" + str(i) + "_start\n" + asm_src += ".long mod" + str(i) + "_end - mod" + str(i) + "_start\n" + i = i + 1 + asm_src += ".long 0\n" + + # module names + i = 1 + for module in modules: + asm_src += "mod" + str(i) + "_name: .string \"" + os.path.split(module)[1] + "\"; .byte 0\n" + i = i + 1 + + asm_src += "header_end:\n" + + # module data + i = 1 + for module in modules: + asm_src += ".p2align 12,0\n" + asm_src += "mod" + str(i) + "_start: .incbin \"" + module + "\"; " + asm_src += "mod" + str(i) + "_end:\n" + i = i + 1 + + return asm_src + +instructions = """ +usage: gen_romfs [-v] [-p ] -c -o [modules ...] + +Generates Genode ROM file system as ELF file loadable into a Codezero container + + -c|--core ELF binary of Genode's core + -o|--output name of ELF image to generate + -p|--prefix cross toolchain prefix + -v|--verbose print details about generated ROM file systemn +""" + +def usage(): + print instructions + +def user_error(message): + print "Error: " + message + usage + sys.exit(2) + +# default values for command-line arguments +cross_prefix = "" +core_elf = "" +dst_elf = "" + +# parse command line arguments +try: + opts, modules = getopt.getopt(sys.argv[1:], + "c:o:p:v", + ["core=", "output=", "prefix=", "verbose"]) +except getopt.GetoptError: + usage() + sys.exit(2) +for opt, arg in opts: + if opt in ("-c", "--core"): + core_elf = arg + elif opt in ("-o", "--output"): + dst_elf = arg + elif opt in ("-p", "--prefix"): + cross_prefix = arg + elif opt in ("-v", "--verbose"): + verbose = 1 + else: + user_error("invalid argument \"" + arg + "\"") + +# validate arguments +if (core_elf == ""): user_error("no core binary specified") +if (len(modules) == 0): user_error("no modules specified") +if (dst_elf == ""): user_error("no output file spefied") + +# determine destination address of the modules ELF image +modules_start_addr = first_free_addr_after_program(core_elf, cross_prefix) + +if (verbose): + print "module address: " + hex(modules_start_addr) + +# generate assembly code aggregating the module data +asm_src = generate_modules_asm(modules) + +if (verbose): + print "generated assember code:" + for line in asm_src.splitlines(): + print " " + line + +# invoke assembler and linker through the gcc front end +gcc_cmd = [cross_prefix + "gcc", + "-nostdlib", + "-x", "assembler", + "-Wl,--entry=0", + "-Wl,--section-start=.data=" + hex(modules_start_addr), + "-o", dst_elf, + "-"] + +if (verbose): + print "gcc command line:" + print " " + ' '.join(gcc_cmd) + +Popen(gcc_cmd, stdin=PIPE).communicate(asm_src)[0] diff --git a/base-fiasco/Makefile b/base-fiasco/Makefile new file mode 100644 index 000000000..633ec3156 --- /dev/null +++ b/base-fiasco/Makefile @@ -0,0 +1,44 @@ +# +# \brief Download, and unpack Fiasco and addtional needed tools (sigma0, bootstrap) +# \author Stefan Kalkowski +# \date 2011-07-18 +# + +VERBOSE ?= @ +ECHO = @echo +DOWNLOAD_DIR = download +CONTRIB_DIR = contrib +FIASCO_ARCHIVE = 3rd_fiasco.tar.bz2 +FIASCO_URI = http://downloads.sourceforge.net/project/genode/3rd/$(FIASCO_ARCHIVE) + +# +# Print help information by default +# +help: + $(ECHO) + $(ECHO) "Prepare the Fiasco base repository" + $(ECHO) + $(ECHO) "--- available commands ---" + $(ECHO) "prepare - download and extract the Fiasco source code" + $(ECHO) "clean - clean everything except downloaded archives" + $(ECHO) "cleanall - clean everything including downloaded archives" + $(ECHO) + +$(DOWNLOAD_DIR)/$(FIASCO_ARCHIVE): + $(ECHO) "downloading source code to '$(DOWNLOAD_DIR)/'" + $(VERBOSE)mkdir -p $(DOWNLOAD_DIR) + $(VERBOSE)wget -c $(FIASCO_URI) -O $@ + +$(CONTRIB_DIR): $(DOWNLOAD_DIR)/$(FIASCO_ARCHIVE) + $(ECHO) "unpacking source code to '$(CONTRIB_DIR)/'" + $(VERBOSE)tar xjf $< + $(VERBOSE)mv 3rd $@ + $(VERBOSE)touch $@ + +prepare: $(CONTRIB_DIR) + +clean: + $(VERBOSE)rm -rf $(CONTRIB_DIR) + +cleanall: clean + $(VERBOSE)rm -rf $(DOWNLOAD_DIR) diff --git a/base-fiasco/README b/base-fiasco/README new file mode 100644 index 000000000..8129cac57 --- /dev/null +++ b/base-fiasco/README @@ -0,0 +1,4 @@ +This repository contains the L4/Fiasco-specific implementation of Genode. + +For instructions to build and start the Fiasco version of Genode, please +consult the documentation located at 'base-fiasco/doc/fiasco.txt'. diff --git a/base-fiasco/config/kernel-config.x86 b/base-fiasco/config/kernel-config.x86 new file mode 100644 index 000000000..19d0f4013 --- /dev/null +++ b/base-fiasco/config/kernel-config.x86 @@ -0,0 +1,95 @@ +# +# Automatically generated make config: don't edit +# Fiasco kernel version: SVN +# Thu Jul 21 16:51:09 2011 +# + +# +# Target configuration +# +CONFIG_IA32=y +# CONFIG_AMD64 is not set +# CONFIG_ARM is not set +CONFIG_PF_PC=y +# CONFIG_PF_UX is not set +# CONFIG_PF_REALVIEW is not set +# CONFIG_PF_INTEGRATOR is not set +# CONFIG_PF_XSCALE is not set +# CONFIG_PF_SA1100 is not set +CONFIG_ABI_V2=y +# CONFIG_ARM_PXA is not set +# CONFIG_ARM_SA is not set +# CONFIG_ARM_920T is not set +# CONFIG_ARM_926 is not set +# CONFIG_ARM_1176 is not set +# CONFIG_ARM_MPCORE is not set +# CONFIG_ARM_CORTEX_A8 is not set +# CONFIG_IA32_486 is not set +CONFIG_IA32_586=y +# CONFIG_IA32_686 is not set +# CONFIG_IA32_P2 is not set +# CONFIG_IA32_P3 is not set +# CONFIG_IA32_P4 is not set +# CONFIG_IA32_PM is not set +# CONFIG_IA32_K6 is not set +# CONFIG_IA32_K7 is not set +# CONFIG_IA32_K8 is not set +# CONFIG_AMD64_K8 is not set +CONFIG_SCHED_PIT=y +# CONFIG_SCHED_RTC is not set +# CONFIG_SCHED_APIC is not set +# CONFIG_WORKAROUND_AMD_FPU_LEAK is not set +CONFIG_REGPARM3=y + +# +# Kernel options +# +CONFIG_HANDLE_SEGMENTS=y +# CONFIG_PL0_HACK is not set +CONFIG_TASK_CAPS=y +# CONFIG_USER_LOCKS is not set +CONFIG_CONTEXT_4K=y +CONFIG_IO_PROT=y +# CONFIG_IO_PROT_IOPL_3 is not set +CONFIG_SYNC_TSC=y +CONFIG_FINE_GRAINED_CPUTIME=y + +# +# Debugging +# +CONFIG_INLINE=y +# CONFIG_NDEBUG is not set +# CONFIG_NO_FRAME_PTR is not set +# CONFIG_STACK_DEPTH is not set +# CONFIG_LIST_ALLOC_SANITY is not set +# CONFIG_BEFORE_IRET_SANITY is not set +CONFIG_GSTABS=y +# CONFIG_WATCHDOG is not set +CONFIG_SERIAL=y +CONFIG_JDB=y +# CONFIG_JDB_LOGGING is not set +# CONFIG_JDB_ACCOUNTING is not set +# CONFIG_JDB_MISC is not set +CONFIG_POWERSAVE_GETCHAR=y +# CONFIG_WARN_NONE is not set +# CONFIG_WARN_WARNING is not set +CONFIG_WARN_ANY=y + +# +# Compiling +# +CONFIG_CC="gcc" +CONFIG_CXX="g++" +CONFIG_HOST_CC="gcc" +CONFIG_HOST_CXX="g++" +# CONFIG_VERBOSE is not set +# CONFIG_MAINTAINER_MODE is not set +CONFIG_LABEL="" +CONFIG_EXPERIMENTAL=y +CONFIG_PERF_CNT=y +CONFIG_BIT32=y +CONFIG_WARN_LEVEL=2 +CONFIG_XARCH="ia32" +CONFIG_IA32_TARGET="Intel Pentium" +CONFIG_ABI="v2" +CONFIG_DECEIT_BIT_DISABLES_SWITCH=y diff --git a/base-fiasco/config/l4env-config.x86 b/base-fiasco/config/l4env-config.x86 new file mode 100644 index 000000000..826fc5bc4 --- /dev/null +++ b/base-fiasco/config/l4env-config.x86 @@ -0,0 +1,83 @@ +# +# Automatically generated by configuration tool: don't edit +# + +# +# Target Architecture +# +BUILD_ARCH_x86=y +BUILD_ARCH_arm=n +BUILD_ARCH_amd64=n +BUILD_ARCH='x86' +CPU='586' +BUILD_ABI_l4v2=y +BUILD_ABI_linux=n +BUILD_ABI='l4v2' + +# +# Paths and Directories +# +DROPS_INSTDIR='$(DROPS_STDDIR)' + +# +# Verboseness and Messages +# +DEPEND_VERBOSE_SWITCH=n +DEPEND_VERBOSE='@' +VERBOSE_SWITCH=n +SHOWMESSAGES=y +BID_COLORED_PHASES=y + +# +# Compilers and Tools +# +BIDc_USE_SPECIAL_CC=y +HOST_CC="gcc -m32" +HOST_CXX="g++ -m32" +CC="$(SYSTEM_TARGET)gcc -m32" +CXX="$(SYSTEM_TARGET)g++ -m32" + +# +# Tools +# +YACC='byacc' +LEX='flex' +CTAGS='ctags' +ETAGS='etags' + +# +# Options +# +HAVE_LDSO=n +INT_CPP_NAME_SWITCH=y +INT_LD_NAME_SWITCH=y +BID_STRIP_PROGS=n +BID_GSTAB_SW=y +BID_CFLAGS_GSTAB='-gstabs+' +BID_GCC_OMIT_FP=n +BID_GENERATE_MAPFILE=n +BID_BUILD_DOC=y + +# +# Advanced +# +USE_UCLIBC=y +USE_DIETLIBC=n +BUILD_LOADER=n +BUILD_LOADER_PICS='libl4util.a libl4util_root.a libsigma0.a libnames.a libloaderif.a libcon.a libl4rm.a libbootmod.a libcon.a libconstream-server.a libdm_generic.a libdm_mem.a libgeneric_ts.a liblogserver.a liblogserver_capsule.a libsemaphore.a libthread.a libslab.a libgeneric_fprov.a libl4env_err.a libl4env.a libroot.a libc_be_l4env_start_stop.a libc_be_minimal_log_io.a libc_be_simple_mem.a libc_be_mmap.a libc_be_mmap_util.a libuclibc_support.a librtc.a libl4env-l4lx.a' +L4_CALL_SYSCALLS=y +L4_ABS_SYSCALLS=y +BID_CPPFLAGS_SYSCALLS='-DCONFIG_L4_CALL_SYSCALLS -DCONFIG_L4_ABS_SYSCALLS' +USE_TASKLIB=n +RELEASE_MODE=n +BID_BUILD_L4DIR_ONLY=n +CONFIG_LABEL='__none__' + +# +# Paths +# +LINUX24_INCDIR='$(OBJ_BASE)/include/linux-24 $(DROPS_STDDIR)/include/linux-24' +LINUX26_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/linux-26-headers $(DROPS_STDDIR)/include/$(ARCH)/l4/linux-26-headers $(OBJ_BASE)/include/l4/linux-26-headers $(DROPS_STDDIR)/include/l4/linux-26-headers' +DDE_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/dde_linux $(DROPS_STDDIR)/include/$(ARCH)/l4/dde_linux' +DDE26_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/dde_linux26 $(DROPS_STDDIR)/include/$(ARCH)/l4/dde_linux26 $(OBJ_BASE)/include/l4/dde_linux26 $(DROPS_STDDIR)/include/l4/dde_linux26' +SDL_INCDIR='$(OBJ_BASE)/include/l4/sdl $(DROPS_STDDIR)/include/l4/sdl' diff --git a/base-fiasco/doc/fiasco.txt b/base-fiasco/doc/fiasco.txt new file mode 100644 index 000000000..cfd604a2a --- /dev/null +++ b/base-fiasco/doc/fiasco.txt @@ -0,0 +1,130 @@ + + ============================================= + How to use Genode with the Fiasco microkernel + ============================================= + + + Norman Feske, Christian Helmuth + +Abstract +######## + +This documentation describes the process of building and booting the L4/Fiasco +version of Genode. It assumes that you are familiar with basic concepts +described in the introductory documentation of Genode, namely the "How to start +exploring Genode" document. + + +Preconditions +############# + +The Fiasco version of Genode relies on the following components from +the source tree of the Fiasco microkernel and the L4 environment (which also +need additional tools). + + +Tools +===== + +* Gawk +* Bison +* Python + + +The Fiasco microkernel +====================== + +Information about Fiasco are provided at its official website: + +! http://os.inf.tu-dresden.de/fiasco/prev/ + +To download the kernel and integrate it with Genode, issue the following +command from within the 'base-fiasco' directory: + +! make prepare + +This command will download a prepackaged version of the kernel tested +with Genode. The build process of the kernel is integrated with Genode's +build system. After creating a build directory using 'create_builddir' +with 'fiasco_x86' as argument: + +! /tool/create_builddir fiasco_x86 \ +! BUILD_DIR= + +From within the new , the kernel can be compiled via + +! make kernel + +When using Genode's run mechanism, there is no need to explicitly +build the kernel. The run environment (see 'base-fiasco/run/env') +takes care of it. So you can simple execute run scripts from within +the build directory, for example: + +! make run/demo + + +Behind the scenes +================= + +For using the L4/Fiasco kernel, some basic user-level components and libraries +are needed. These are subsumed under the name L4 environment an are organized +as a number of packages. These packages provide two types of components. There +are low-level components for booting up and interfacing to Fiasco and there are +higher-level components that compose a basic OS infrastructure. For Genode, we +only rely on the low-level packages. + +Previous versions of Genode included all necessary sources from the L4 +environment in the '3rd/fiasco/snapshot' subdirectory. From release 10.02, the +'3rd' directory is no longer part of the release archive and also removed from +the subversion repository. Please download the '3rd_fiasco.tar.bz2' archive. +The source are organized as follows + +:'tool': contains the tools that are used by the build processes of + the L4 environment and Fiasco. For example, the build process of Fiasco + relies on the 'preprocess' tool. + +:'kernel': contains the Fiasco microkernel. + +:'l4': contains the L4-environment source tree. The single packages + are located at 'l4/pkg'. + +From all the packages of the L4 environment, the following three are of +interest for using Genode: + +:'pkg/l4sys': contains the Fiasco system-call bindings. + + The system-call bindings are a set of C-header files that define the + application-programming interface for invoking the system calls of + Fiasco. + +:'pkg/sigma0': + + Sigma0 is the initial memory manager required to use Fiasco. + +:'pkg/bootstrap': + + Bootstrap is the program that is started by the boot loader. + After being started, Bootstrap prepares the bare machine to + accommodate Fiasco. On many embedded architectures, bootstrap + is used to create a single binary image containing all boot-time + OS components. + +To build all components under '3rd/fiasco' after extracting the +archive, issue the following commands: + +! mkdir +! make -C 3rd/fiasco BUILD_DIR=/3rd build + +The specified '' must be the absolute path to the +directory, which will contain the build directories for the third party +software and the Genode build directory. After the build, your compound +build directory contains the following subdirectories: + +:'fiasco_x86': + + All generated files and the final binary of Fiasco reside here. + +:'l4env': + + L4 environment binaries and header files. + diff --git a/base-fiasco/etc/fiasco.conf b/base-fiasco/etc/fiasco.conf new file mode 100644 index 000000000..589873dca --- /dev/null +++ b/base-fiasco/etc/fiasco.conf @@ -0,0 +1,11 @@ +# +# Fiasco-specific default configuration options +# + +# +# Directory, where to search for L4 headers +# +# When using this file as template for a customized +# '/etc/fiasco.conf'. +# +#L4_DIR = $(HOME)/src/l4build.x86 diff --git a/base-fiasco/etc/specs.conf b/base-fiasco/etc/specs.conf new file mode 100644 index 000000000..91f1b0335 --- /dev/null +++ b/base-fiasco/etc/specs.conf @@ -0,0 +1,15 @@ +# +# Description of build platform +# + +# +# To build the Fiasco-specific Genode binaries, +# use one of the the following config options. +# +SPECS = genode fiasco_x86 + +# +# To build for the ARM integrator platform, +# use the following SPECS value. +# +#SPECS = genode platform_integrator fiasco_arm diff --git a/base-fiasco/etc/tools.conf b/base-fiasco/etc/tools.conf new file mode 100644 index 000000000..a1cada69b --- /dev/null +++ b/base-fiasco/etc/tools.conf @@ -0,0 +1,8 @@ +# +# The following options let you define your cross-compile tool chain +# + +include $(BASE_DIR)/etc/tools.conf + +#CROSS_DEV_PREFIX = arm-softfloat-linux-gnu- + diff --git a/base-fiasco/include/arm/cpu/atomic.h b/base-fiasco/include/arm/cpu/atomic.h new file mode 100644 index 000000000..60e6e0ea8 --- /dev/null +++ b/base-fiasco/include/arm/cpu/atomic.h @@ -0,0 +1,39 @@ +/* + * \brief Atomic operations for ARM + * \author Norman Feske + * \date 2007-04-28 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__ARM__CPU__ATOMIC_H_ +#define _INCLUDE__ARM__CPU__ATOMIC_H_ + +namespace Genode { + + extern "C" long int + l4_atomic_cmpxchg(volatile long int*, long int, long int); + + /** + * Atomic compare and exchange + * + * This function compares the value at dest with cmp_val. + * If both values are equal, dest is set to new_val. If + * both values are different, the value at dest remains + * unchanged. + * + * \return 1 if the value was successfully changed to new_val, + * 0 if cmp_val and the value at dest differ. + */ + inline int cmpxchg(volatile int *dest, int cmp_val, int new_val) + { + return l4_atomic_cmpxchg((volatile long int *)dest, cmp_val, new_val); + } +} + +#endif /* _INCLUDE__ARM__CPU__ATOMIC_H_ */ diff --git a/base-fiasco/include/base/cancelable_lock.h b/base-fiasco/include/base/cancelable_lock.h new file mode 100644 index 000000000..7ca90e6fd --- /dev/null +++ b/base-fiasco/include/base/cancelable_lock.h @@ -0,0 +1,57 @@ +/* + * \brief Basic locking primitive + * \author Norman Feske + * \date 2006-07-26 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__CANCELABLE_LOCK_H_ +#define _INCLUDE__BASE__CANCELABLE_LOCK_H_ + +#include +#include +#include + +namespace Genode { + + class Cancelable_lock + { + private: + + Native_lock _native_lock; + + public: + + enum State { LOCKED, UNLOCKED }; + + /** + * Constructor + */ + Cancelable_lock(State initial = UNLOCKED); + + /** + * Try to aquire lock an block while lock is not free + * + * This function may throw a Genode::Blocking_canceled exception. + */ + void lock(); + + /** + * Release lock + */ + void unlock(); + + /** + * Lock guard + */ + typedef Genode::Lock_guard Guard; + }; +} + +#endif /* _INCLUDE__BASE__CANCELABLE_LOCK_H_ */ diff --git a/base-fiasco/include/base/ipc_msgbuf.h b/base-fiasco/include/base/ipc_msgbuf.h new file mode 100644 index 000000000..1cb3909b8 --- /dev/null +++ b/base-fiasco/include/base/ipc_msgbuf.h @@ -0,0 +1,65 @@ +/* + * \brief Fiasco-specific layout of IPC message buffer + * \author Norman Feske + * \date 2006-06-14 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_ +#define _INCLUDE__BASE__IPC_MSGBUF_H_ + +namespace Genode { + + /** + * IPC message buffer layout + */ + class Msgbuf_base + { + protected: + + Genode::size_t _size; + + public: + + /* + * Begin of message buffer layout + */ + + Fiasco::l4_fpage_t rcv_fpage; + Fiasco::l4_msgdope_t size_dope; + Fiasco::l4_msgdope_t send_dope; + char buf[]; + + /** + * Return size of message buffer + */ + inline size_t size() const { return _size; }; + + /** + * Return address of message buffer + */ + inline void *addr() { return &rcv_fpage; }; + }; + + + /** + * Instance of IPC message buffer with specified buffer size + */ + template + class Msgbuf : public Msgbuf_base + { + public: + + char buf[BUF_SIZE]; + + Msgbuf() { _size = BUF_SIZE; } + }; +} + +#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */ diff --git a/base-fiasco/include/base/ipc_pager.h b/base-fiasco/include/base/ipc_pager.h new file mode 100644 index 000000000..aef9569ff --- /dev/null +++ b/base-fiasco/include/base/ipc_pager.h @@ -0,0 +1,173 @@ +/* + * \brief Fiasco pager support + * \author Christian Helmuth + * \date 2006-06-14 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_PAGER_H_ +#define _INCLUDE__BASE__IPC_PAGER_H_ + +/* Genode includes */ +#include +#include +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +namespace Genode { + + class Mapping + { + private: + + addr_t _dst_addr; + Fiasco::l4_fpage_t _fpage; + + public: + + /** + * Constructor + */ + Mapping(addr_t dst_addr, addr_t src_addr, + bool write_combined, unsigned l2size = L4_LOG2_PAGESIZE, + bool rw = true, bool grant = false) + : + _dst_addr(dst_addr), + _fpage(Fiasco::l4_fpage(src_addr, l2size, rw, grant)) + { + if (write_combined) + _fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE; + } + + /** + * Construct invalid flexpage + */ + Mapping() : _dst_addr(0), _fpage(Fiasco::l4_fpage(0, 0, 0, 0)) { } + + Fiasco::l4_umword_t dst_addr() const { return _dst_addr; } + Fiasco::l4_fpage_t fpage() const { return _fpage; } + + /** + * Prepare map operation + * + * On Fiasco, we need to map a page locally to be able to map it to + * another address space. + */ + void prepare_map_operation() + { + addr_t core_local_addr = _fpage.fp.page << 12; + size_t mapping_size = 1 << _fpage.fp.size; + + for (addr_t i = 0; i < mapping_size; i += L4_PAGESIZE) { + if (_fpage.fp.write) + touch_read_write((unsigned char volatile *)(core_local_addr + i)); + else + touch_read((unsigned char const volatile *)(core_local_addr + i)); + } + } + }; + + + /** + * Special paging server class + */ + class Ipc_pager : public Native_capability + { + private: + + Native_thread_id _last; /* origin of last fault message */ + addr_t _pf_addr; /* page-fault address */ + addr_t _pf_ip; /* instruction pointer of faulter */ + Mapping _reply_mapping; /* page-fault answer */ + + public: + + /** + * Constructor + */ + Ipc_pager(); + + /** + * Wait for a new page fault received as short message IPC + */ + void wait_for_fault(); + + /** + * Reply current page-fault and wait for a new one + * + * Send short flex page and wait for next short-message (register) + * IPC -- pagefault + */ + void reply_and_wait_for_fault(); + + /** + * Request instruction pointer of current page fault + */ + addr_t fault_ip() { return _pf_ip; } + + /** + * Request fault address of current page fault + */ + addr_t fault_addr() { return _pf_addr & ~3; } + + /** + * Set parameters for next reply + */ + void set_reply_mapping(Mapping m) { _reply_mapping = m; } + + /** + * Set destination for next reply + */ + void set_reply_dst(Native_capability pager_object) { + _last.raw = pager_object.local_name(); } + + /** + * Answer call without sending a flex-page mapping + * + * This function is used to acknowledge local calls from one of + * core's region-manager sessions. + */ + void acknowledge_wakeup(); + + /** + * Return thread ID of last faulter + */ + Native_thread_id last() const { return _last; } + + /** + * Return badge for faulting thread + * + * As Fiasco has no server-defined badges for page-fault messages, we + * interpret the sender ID as badge. + */ + unsigned long badge() const { + return convert_native_thread_id_to_badge(_last); } + + bool is_write_fault() const { return (_pf_addr & 2); } + + /** + * Return true if last fault was an exception + */ + bool is_exception() const + { + /* + * Reflection of exceptions is not supported on this platform. + */ + return false; + } + }; +} + +#endif /* _INCLUDE__BASE__IPC_PAGER_H_ */ diff --git a/base-fiasco/include/base/native_types.h b/base-fiasco/include/base/native_types.h new file mode 100644 index 000000000..7e0485667 --- /dev/null +++ b/base-fiasco/include/base/native_types.h @@ -0,0 +1,115 @@ +/* + * \brief Native types on L4/Fiasco + * \author Norman Feske + * \date 2008-07-26 + */ + +/* + * Copyright (C) 2008-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ +#define _INCLUDE__BASE__NATIVE_TYPES_H_ + +namespace Fiasco { +#include + + /** + * Return invalid L4 thread ID + */ + inline l4_threadid_t invalid_l4_threadid_t() { return L4_INVALID_ID; } +} + +namespace Genode { + + typedef volatile int Native_lock; + + class Platform_thread; + + typedef Fiasco::l4_threadid_t Native_thread_id; + + struct Native_thread + { + Native_thread_id l4id; + + /** + * Only used in core + * + * For 'Thread' objects created within core, 'pt' points to + * the physical thread object, which is going to be destroyed + * on destruction of the 'Thread'. + */ + Platform_thread *pt; + }; + + inline unsigned long convert_native_thread_id_to_badge(Native_thread_id tid) + { + /* + * Fiasco has no server-defined badges for page-fault messages. + * Therefore, we have to interpret the sender ID as badge. + */ + return tid.raw; + } + + /** + * Empty UTCB type expected by the thread library + * + * On this kernel, UTCBs are not placed within the the context area. Each + * thread can request its own UTCB pointer using the kernel interface. + */ + typedef struct { } Native_utcb; + + /* + * On Fiasco, the local_name member of a capability is global + * to the whole system. Therefore, capabilities are to be + * created at a central place that prevents id clashes. + */ + class Native_capability + { + protected: + + Fiasco::l4_threadid_t _tid; + long _local_name; + + public: + + /** + * Default constructor + */ + Native_capability() + : _tid(Fiasco::invalid_l4_threadid_t()), _local_name(0) { } + + long local_name() const { return _local_name; } + Fiasco::l4_threadid_t dst() const { return _tid; } + + bool valid() const { return l4_is_invalid_id(_tid) == 0; } + + + /***************************************************** + ** Functions to be used by the Fiasco backend only ** + *****************************************************/ + + /** + * Constructor + * + * This constructor can be called to create a Fiasco + * capability by hand. It must never be used from + * generic code! + */ + Native_capability(Fiasco::l4_threadid_t tid, + Fiasco::l4_umword_t local_name) + : _tid(tid), _local_name(local_name) { } + + /** + * Access raw capability data + */ + Fiasco::l4_threadid_t tid() const { return _tid; } + }; + + typedef Fiasco::l4_threadid_t Native_connection_state; +} + +#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */ diff --git a/base-fiasco/include/fiasco/thread_helper.h b/base-fiasco/include/fiasco/thread_helper.h new file mode 100644 index 000000000..411c44c02 --- /dev/null +++ b/base-fiasco/include/fiasco/thread_helper.h @@ -0,0 +1,40 @@ +/* + * \brief Fiasco-specific thread helper functions + * \author Norman Feske + * \date 2007-05-03 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__FIASCO__THREAD_HELPER_H_ +#define _INCLUDE__FIASCO__THREAD_HELPER_H_ + +#include + +namespace Fiasco { +#include + + inline void print_l4_threadid(l4_threadid_t t) + { + Genode::printf("THREAD %x.%02x\n", t.id.task, t.id.lthread); + Genode::printf(" unsigned version_low:10 = %x\n", t.id.version_low); + Genode::printf(" unsigned lthread:7 = %x\n", t.id.lthread); + Genode::printf(" unsigned task:11 = %x\n", t.id.task); + } + + + /** + * Sigma0 thread ID + * + * We must use a raw hex value initializer since we're using C++ and + * l4_threadid_t is an union. + */ + const l4_threadid_t sigma0_threadid = { 0x00040000 }; +} + +#endif /* _INCLUDE__FIASCO__THREAD_HELPER_H_ */ diff --git a/base-fiasco/lib/mk/arm/startup.mk b/base-fiasco/lib/mk/arm/startup.mk new file mode 100644 index 000000000..9dda379a2 --- /dev/null +++ b/base-fiasco/lib/mk/arm/startup.mk @@ -0,0 +1,8 @@ +REQUIRES = fiasco arm +LIBS = cxx lock +SRC_S = crt0.s +SRC_CC = _main.cc +INC_DIR += $(REP_DIR)/src/platform + +vpath crt0.s $(REP_DIR)/src/platform/arm +vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc)) diff --git a/base-fiasco/lib/mk/core_printf.mk b/base-fiasco/lib/mk/core_printf.mk new file mode 100644 index 000000000..663cf64b9 --- /dev/null +++ b/base-fiasco/lib/mk/core_printf.mk @@ -0,0 +1,5 @@ +SRC_CC = core_printf.cc +LIBS = cxx console +INC_DIR += $(REP_DIR)/src/base/console + +vpath core_printf.cc $(BASE_DIR)/src/base/console diff --git a/base-fiasco/lib/mk/ipc.mk b/base-fiasco/lib/mk/ipc.mk new file mode 100644 index 000000000..6e6443bb9 --- /dev/null +++ b/base-fiasco/lib/mk/ipc.mk @@ -0,0 +1,3 @@ +SRC_CC = ipc.cc pager.cc + +vpath %.cc $(REP_DIR)/src/base/ipc diff --git a/base-fiasco/lib/mk/l4v2_support.mk b/base-fiasco/lib/mk/l4v2_support.mk new file mode 100644 index 000000000..8bda913f9 --- /dev/null +++ b/base-fiasco/lib/mk/l4v2_support.mk @@ -0,0 +1,19 @@ +# +# Build L4env base libraries, needed by sigma0 and bootstrap + + +# ignore stage one, visit the L4 build system at second build stage +ifeq ($(called_from_lib_mk),yes) + +# packages in 'l4/pkg/' +PKGS = l4sys/lib \ + uclibc/lib/uclibc \ + uclibc/lib/include \ + crtx \ + l4util/lib \ + cxx + +include $(REP_DIR)/mk/l4_pkg.mk +all: $(PKG_TAGS) + +endif diff --git a/base-fiasco/lib/mk/lock.mk b/base-fiasco/lib/mk/lock.mk new file mode 100644 index 000000000..75eddeef1 --- /dev/null +++ b/base-fiasco/lib/mk/lock.mk @@ -0,0 +1,3 @@ +SRC_CC = lock.cc + +vpath lock.cc $(REP_DIR)/src/base/lock diff --git a/base-fiasco/lib/mk/pager.mk b/base-fiasco/lib/mk/pager.mk new file mode 100644 index 000000000..c22e66d22 --- /dev/null +++ b/base-fiasco/lib/mk/pager.mk @@ -0,0 +1,3 @@ +SRC_CC = pager.cc + +vpath pager.cc $(REP_DIR)/src/base/pager diff --git a/base-fiasco/lib/mk/platform.inc b/base-fiasco/lib/mk/platform.inc new file mode 100644 index 000000000..cf5ab378e --- /dev/null +++ b/base-fiasco/lib/mk/platform.inc @@ -0,0 +1,56 @@ +# +# Create prerequisites for building Genode for Fiasco +# +# Prior building Genode programs for Fiasco, the kernel bindings must be +# generated. This is done by building a minimalistic subset of the original +# userland that comes with Fiasco. +# + +# +# Execute the rules in this file only at the second build stage when we know +# about the complete build settings, e.g., the 'CROSS_DEV_PREFIX'. +# +ifeq ($(called_from_lib_mk),yes) + +# +# Sanity checks +# +ifeq ($(L4_BUILD_DIR),$(BUILD_BASE_DIR)/l4) +all: $(L4_SRC_DIR) + +$(L4_SRC_DIR): + $(VERBOSE)$(ECHO) "--> Please, execute 'make prepare' in $(REP_DIR)" + $(VERBOSE)$(ECHO) "--> before compiling Genode apps for Fiasco." + $(VERBOSE)exit 1 +endif + +# +# Create L4 build directory +# +$(BUILD_BASE_DIR)/l4/.Makeconf.bid.old: + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)cp $(L4_CONFIG) $(@:.old=) + $(VERBOSE_MK) MAKEFLAGS= make $(VERBOSE_DIR) -C $(L4_SRC_DIR)/l4 \ + O=$(BUILD_BASE_DIR)/l4 SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" oldconfig + +$(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc: + $(VERBOSE)mkdir -p $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc + $(VERBOSE)tar cf - --exclude .svn -C $(L4_SRC_DIR)/../uclibc ARCH-all ARCH-x86 \ + | tar xf - -C $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc + +PKGS = input/include \ + drivers/uart/include \ + l4sys/include \ + l4util/include \ + libc_support/include \ + libsigma0/include + +include $(REP_DIR)/mk/l4_pkg.mk + +all: $(PKG_TAGS) + +$(PKG_TAGS): $(BUILD_BASE_DIR)/l4/.Makeconf.bid.old +$(PKG_TAGS): $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc + +endif + diff --git a/base-fiasco/lib/mk/x86/platform.mk b/base-fiasco/lib/mk/x86/platform.mk new file mode 100644 index 000000000..e53cdd8d1 --- /dev/null +++ b/base-fiasco/lib/mk/x86/platform.mk @@ -0,0 +1,6 @@ +# +# Configuration for L4 build system (for kernel-bindings, sigma0, bootstrap). +# +L4_CONFIG = $(REP_DIR)/config/l4env-config.x86 + +include $(REP_DIR)/lib/mk/platform.inc diff --git a/base-fiasco/lib/mk/x86/startup.mk b/base-fiasco/lib/mk/x86/startup.mk new file mode 100644 index 000000000..a3b2d14bd --- /dev/null +++ b/base-fiasco/lib/mk/x86/startup.mk @@ -0,0 +1,8 @@ +REQUIRES = fiasco x86 +LIBS = cxx lock +SRC_S = crt0.s +SRC_CC = _main.cc +INC_DIR += $(BASE_DIR)/src/platform $(REP_DIR)/src/platform + +vpath crt0.s $(dir $(call select_from_repositories,src/platform/x86_32/crt0.s)) +vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc)) diff --git a/base-fiasco/mk/l4_pkg.mk b/base-fiasco/mk/l4_pkg.mk new file mode 100644 index 000000000..d01a25794 --- /dev/null +++ b/base-fiasco/mk/l4_pkg.mk @@ -0,0 +1,69 @@ +# +# Utility for building L4 contrib packages +# +# Variables that steer the behaviour of this makefile: +# +# TARGET - name of target +# PKGS - list of L4 packages to visit in order to create +# the target +# + +LIBS += platform + +ifeq ($(filter-out $(SPECS),x86_32),) + L4_BUILD_ARCH := x86 +endif + +ifeq ($(filter-out $(SPECS),arm),) + L4_BUILD_ARCH := arm +endif + +ifeq ($(L4_BUILD_ARCH),) +all: l4_build_arch_undefined + $(VERBOSE)$(ECHO) "Error: L4_BUILD_ARCH undefined, architecture not supported" + $(VERBOSE)false +endif + +L4_PKG_DIR = $(L4_SRC_DIR)/l4/pkg +STARTUP_LIB = +PKG_TAGS = $(addsuffix .tag,$(PKGS)) + +ifeq ($(VERBOSE),) +L4_VERBOSE = V=1 +endif + +$(TARGET): $(PKG_TAGS) + +# +# We preserve the order of processing 'l4/pkg/' directories because of +# inter-package dependencies. However, within each directory, make is working +# in parallel. +# +.NOTPARALLEL: $(PKG_TAGS) + +# +# The '_GNU_SOURCE' definition is needed to convince uClibc to define the +# 'off64_t' type, which is used by bootstrap. +# +%.tag: + $(VERBOSE_MK) MAKEFLAGS= CPPFLAGS="$(CC_MARCH)" \ + CFLAGS="$(CC_MARCH)" CXXFLAGS="$(CC_MARCH) -D_GNU_SOURCE" \ + ASFLAGS="$(CC_MARCH)" LDFLAGS="$(LD_MARCH)" \ + $(MAKE) $(VERBOSE_DIR) O=$(L4_BUILD_DIR) $(L4_VERBOSE) \ + -C $(L4_PKG_DIR)/$* \ + CC="$(CROSS_DEV_PREFIX)gcc" \ + CXX="$(CROSS_DEV_PREFIX)g++" \ + LD="$(CROSS_DEV_PREFIX)ld" + $(VERBOSE)mkdir -p $(dir $@) && touch $@ + +clean cleanall: clean_tags + +# if (pseudo) target is named after a directory, remove the whole subtree +clean_prg_objects: clean_dir_named_as_target + +clean_dir_named_as_target: + $(VERBOSE)(test -d $(TARGET) && rm -rf $(TARGET)) || true + +clean_tags: + $(VERBOSE)rm -f $(PKG_TAGS) + diff --git a/base-fiasco/mk/spec-fiasco.mk b/base-fiasco/mk/spec-fiasco.mk new file mode 100644 index 000000000..3b9253af3 --- /dev/null +++ b/base-fiasco/mk/spec-fiasco.mk @@ -0,0 +1,32 @@ +# +# Specifics for the l4v2 kernel API +# + +# +# Read default and builddir-specific config files +# +# In these config files, we find the definition of L4_DIR +# +-include $(call select_from_repositories,etc/fiasco.conf) +-include $(BUILD_BASE_DIR)/etc/fiasco.conf + +L4_BUILD_DIR ?= $(BUILD_BASE_DIR)/l4 +L4_SRC_DIR ?= $(REP_DIR)/contrib/fiasco/snapshot + + +# +# L4/sys headers +# +L4_INC_DIR += $(L4_BUILD_DIR)/include \ + $(L4_BUILD_DIR)/include/l4v2 + +# +# Startup code to be used when building a program +# +STARTUP_LIB ?= startup +PRG_LIBS += $(STARTUP_LIB) + +clean_contrib: + $(VERBOSE)rm -rf $(BUILD_BASE_DIR)/l4 + +cleanall: clean_contrib diff --git a/base-fiasco/mk/spec-fiasco_arm.mk b/base-fiasco/mk/spec-fiasco_arm.mk new file mode 100644 index 000000000..8c34daad2 --- /dev/null +++ b/base-fiasco/mk/spec-fiasco_arm.mk @@ -0,0 +1,50 @@ +# +# Specifics for Fiasco on ARM +# +# The following variables must be defined by a platform spec file: +# +# L4SYS_ARM_CPU - Platform identifiert used for constructing l4sys path +# names corresponding to the ARM platform. For example, +# specify 'arm_int' for the ARM integrator board. +# RAM_BASE - Start address of physical memory. If not specified, +# the start adress 0x0 is used. +# + +SPECS += arm fiasco 32bit + +# +# ARM-specific L4/sys headers +# +L4_INC_DIR += $(L4_BUILD_DIR)/include/arm/l4v2 \ + $(L4_BUILD_DIR)/include/arm + +# +# Support for Fiasco's ARM-specific extensions of L4 +# and ARM-specific utility functions. +# +REP_INC_DIR += include/arm + +# +# Defines for L4/sys headers +# +CC_OPT += -DSYSTEM_$(L4SYS_ARM_CPU)_l4v2 +CC_OPT += -DCONFIG_L4_CALL_SYSCALLS -DL4API_l4v2 -DARCH_arm +CC_OPT += -msoft-float -fomit-frame-pointer +AS_OPT += -mfpu=softfpa + +# +# Linker options that are specific for L4 on ARM +# +RAM_BASE ?= 0x0 +LD_TEXT_ADDR ?= $(shell printf "0x%x" $$(($(RAM_BASE) + 0x00078000))) +CXX_LINK_OPT += -Wl,-Ttext=$(LINK_TEXT_ADDR) +CXX_LINK_OPT += -L$(L4_BUILD_DIR)/lib/$(L4SYS_ARM_CPU)/l4v2 +EXT_OBJECTS += -ll4sys + +# +# Also include less-specific configuration last +# +include $(call select_from_repositories,mk/spec-32bit.mk) +include $(call select_from_repositories,mk/spec-fiasco.mk) + +INC_DIR += $(L4_INC_DIR) diff --git a/base-fiasco/mk/spec-fiasco_x86.mk b/base-fiasco/mk/spec-fiasco_x86.mk new file mode 100644 index 000000000..41b1d98f3 --- /dev/null +++ b/base-fiasco/mk/spec-fiasco_x86.mk @@ -0,0 +1,25 @@ +# +# Specifics for Fiasco L4v2 on x86 +# + +SPECS += x86_32 fiasco +SPECS += pci ps2 vesa + +# +# x86-specific L4v2/sys headers +# +L4_INC_DIR += $(L4_BUILD_DIR)/include/x86/l4v2 \ + $(L4_BUILD_DIR)/include/x86 + +# +# Linker options that are specific for x86 +# +LD_TEXT_ADDR ?= 0x01000000 + +# +# Also include less-specific configuration last +# +include $(call select_from_repositories,mk/spec-x86_32.mk) +include $(call select_from_repositories,mk/spec-fiasco.mk) + +INC_DIR += $(L4_INC_DIR) diff --git a/base-fiasco/mk/spec-platform_imx.mk b/base-fiasco/mk/spec-platform_imx.mk new file mode 100644 index 000000000..61e45889d --- /dev/null +++ b/base-fiasco/mk/spec-platform_imx.mk @@ -0,0 +1,16 @@ +# +# Specifics for Freescale i.MX21 platform +# + +RAM_BASE = 0xc0000000 + +# +# Configure target CPU for gcc +# +CC_OPT += -march=armv5 + +# +# Defines for L4/sys headers +# +CC_OPT += -DCPUTYPE_imx +L4SYS_ARM_CPU = arm_imx diff --git a/base-fiasco/mk/spec-platform_integrator.mk b/base-fiasco/mk/spec-platform_integrator.mk new file mode 100644 index 000000000..a6bb3dba0 --- /dev/null +++ b/base-fiasco/mk/spec-platform_integrator.mk @@ -0,0 +1,14 @@ +# +# Specifics for ARM integrator platform +# + +# +# Configure target CPU for gcc +# +CC_OPT += -march=armv5 + +# +# Defines for L4/sys headers +# +CC_OPT += -DCPUTYPE_int +L4SYS_ARM_CPU = arm_int diff --git a/base-fiasco/mk/spec-platform_mmsp2.mk b/base-fiasco/mk/spec-platform_mmsp2.mk new file mode 100644 index 000000000..0cba20187 --- /dev/null +++ b/base-fiasco/mk/spec-platform_mmsp2.mk @@ -0,0 +1,14 @@ +# +# Specifics for MagicEyes Digital’s Multimedia Signal Processor +# + +# +# Configure target CPU for gcc +# +CC_OPT += -march=armv4t + +# +# Defines for L4/sys headers +# +CC_OPT += -DCPUTYPE_mmsp2 +L4SYS_ARM_CPU = arm_mmsp2 diff --git a/base-fiasco/run/env b/base-fiasco/run/env new file mode 100644 index 000000000..d5fe1ad29 --- /dev/null +++ b/base-fiasco/run/env @@ -0,0 +1,127 @@ +# +# \brief Fiasco-specific test-environment supplements +# \author Norman Feske +# \author Christian Helmuth +# \date 2010-08-26 +# +# This file is meant to be used as '--include' argument for 'tool/run'. +# + + +## +# Read the location of the Fiasco user directory from 'etc/fiasco.conf' +# +proc l4_dir { } { + global _l4_dir + + if {![info exists _l4_dir]} { + if {[file exists etc/fiasco.conf]} { + set _l4_dir [exec sed -n "/^L4_BUILD_DIR/s/^.*=\\s*//p" etc/fiasco.conf] + if {[file exists $_l4_dir]} { return $_l4_dir } + } + + set _l4_dir "[pwd]/l4" + if {![file exists $_l4_dir]} { + puts -nonewline stderr "Error: Could neither find the L4 build directory " + puts -nonewline stderr "within '/l4' nor at a location " + puts -nonewline stderr "specified via 'L4_BUILD_DIR = ' " + puts stderr "in /etc/fiasco.conf'." + exit 1 + } + } + return $_l4_dir +} + + +## +# Return whether the l4-buid-directory is provided from the outside +# +proc l4_dir_external { } { + if {[l4_dir] == "[pwd]/l4"} { return 0 } + return 1 +} + + +## +# Return the location of the Fiasco kernel +# +proc fiasco { } { + return [kernel_location_from_config_file etc/fiasco.conf [pwd]/kernel/fiasco/fiasco] +} + + +## +# Return whether fiasco kernel is provided from the outside +# +proc fiasco_external { } { + if {[fiasco] == "[pwd]/kernel/fiasco/fiasco"} { return 0 } + return 1 +} + + +################################## +## Test framework API functions ## +################################## + +proc create_boot_directory { } { + exec rm -rf [run_dir] + exec mkdir -p [run_dir]/genode + exec mkdir -p [run_dir]/fiasco +} + +proc bin_dir { } { + if {[have_spec x86_32]} { return "[l4_dir]/bin/x86_586" } + + puts stderr "Error: Cannot determine bin directory" + exit 1 +} + +proc build_boot_image {binaries} { + + # + # Collect contents of the ISO image + # + copy_and_strip_genode_binaries_to_run_dir $binaries + + if {![fiasco_external]} { build { kernel } } + if {![l4_dir_external]} { build { bootstrap sigma0 } } + + # assert existence of the L4 build directory + l4_dir + + puts "using fiasco kernel [fiasco]" + exec cp [fiasco] [run_dir]/fiasco/fiasco + puts "using sigma0/bootstrap at [l4_dir]" + exec cp [bin_dir]/l4v2/sigma0 [run_dir]/fiasco + exec cp [bin_dir]/bootstrap [run_dir]/fiasco + + install_iso_bootloader_to_run_dir + + # + # Generate grub config file + # + # The core binary is part of the 'binaries' list but it must + # appear right after 'sigma0' as boot module. Hence the special case. + # + set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"] + puts $fh "timeout 0" + puts $fh "default 0" + puts $fh "\ntitle Genode on L4/Fiasco" + puts $fh " kernel /fiasco/bootstrap -serial -modaddr=0x02000000" + puts $fh " module /fiasco/fiasco -serial -serial_esc -jdb_cmd=JH" + puts $fh " module /fiasco/sigma0" + puts $fh " module /genode/core" + puts $fh " module /genode/config" + foreach binary $binaries { + if {$binary != "core"} { + puts $fh " module /genode/$binary" } } + puts $fh " vbeset 0x117 506070" + close $fh + + create_iso_image_from_run_dir +} + + +proc run_genode_until {{wait_for_re forever} {timeout_value 0}} { + spawn_qemu $wait_for_re $timeout_value } + diff --git a/base-fiasco/src/base/console/core_console.h b/base-fiasco/src/base/console/core_console.h new file mode 100644 index 000000000..e5e50de5a --- /dev/null +++ b/base-fiasco/src/base/console/core_console.h @@ -0,0 +1,30 @@ +/* + * \brief Console backend using the Fiasco kernel debugger + * \author Norman Feske + * \date 2006-04-08 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +/* Genode includes */ +#include + +namespace Genode { + + class Core_console : public Console + { + protected: + + void _out_char(char c) { Fiasco::outchar(c); } + }; +} diff --git a/base-fiasco/src/base/ipc/ipc.cc b/base-fiasco/src/base/ipc/ipc.cc new file mode 100644 index 000000000..e23fcb443 --- /dev/null +++ b/base-fiasco/src/base/ipc/ipc.cc @@ -0,0 +1,259 @@ +/* + * \brief IPC implementation for Fiasco + * \author Norman Feske + * \date 2006-06-13 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include +#include + +namespace Fiasco { +#include +#include +#include +} + +using namespace Genode; + + +/***************** + ** Ipc_ostream ** + *****************/ + +void Ipc_ostream::_send() +{ + using namespace Fiasco; + + _snd_msg->send_dope = L4_IPC_DOPE((_write_offset + sizeof(umword_t) - 1)>>2, 0); + + l4_msgdope_t result; + l4_ipc_send(_dst.tid(), _snd_msg->addr(), _dst.local_name(), + *reinterpret_cast(&_snd_msg->buf[sizeof(umword_t)]), + L4_IPC_NEVER, &result); + + if (L4_IPC_IS_ERROR(result)) { + PERR("Ipc error %lx", L4_IPC_ERROR(result)); + throw Genode::Ipc_error(); + } + + _write_offset = sizeof(umword_t); +} + + +Ipc_ostream::Ipc_ostream(Native_capability dst, Msgbuf_base *snd_msg) : + Ipc_marshaller(&snd_msg->buf[0], snd_msg->size()), + _snd_msg(snd_msg), _dst(dst) +{ + _write_offset = sizeof(umword_t); +} + + +/***************** + ** Ipc_istream ** + *****************/ + +void Ipc_istream::_wait() +{ + using namespace Fiasco; + + l4_msgdope_t result; + + /* + * Wait until we get a proper message and thereby + * ignore receive message cuts on the server-side. + * This error condition should be handled by the + * client. The server does not bother. + */ + do { + _rcv_msg->size_dope = L4_IPC_DOPE(_rcv_msg->size()>>2, 0); + + l4_ipc_wait(&_rcv_cs, _rcv_msg->addr(), + reinterpret_cast(&_rcv_msg->buf[0]), + reinterpret_cast(&_rcv_msg->buf[sizeof(umword_t)]), + L4_IPC_NEVER, &result); + + if (L4_IPC_IS_ERROR(result)) + PERR("Ipc error %lx", L4_IPC_ERROR(result)); + + } while (L4_IPC_IS_ERROR(result)); + + /* reset buffer read offset */ + _read_offset = sizeof(umword_t); +} + + +Ipc_istream::Ipc_istream(Msgbuf_base *rcv_msg): + Ipc_unmarshaller(&rcv_msg->buf[0], rcv_msg->size()), + Native_capability(Fiasco::l4_myself(), 0), + _rcv_msg(rcv_msg) +{ + using namespace Fiasco; + + _rcv_cs = L4_INVALID_ID; + + _read_offset = sizeof(umword_t); +} + + +Ipc_istream::~Ipc_istream() { } + + +/**************** + ** Ipc_client ** + ****************/ + +void Ipc_client::_call() +{ + using namespace Fiasco; + + l4_msgdope_t ipc_result; + long rec_badge; + + _snd_msg->send_dope = L4_IPC_DOPE((_write_offset + 2*sizeof(umword_t) - 1)>>2, 0); + _rcv_msg->size_dope = L4_IPC_DOPE(_rcv_msg->size()>>2, 0); + + l4_ipc_call(_dst.tid(), + _write_offset <= 2*sizeof(umword_t) ? L4_IPC_SHORT_MSG : _snd_msg->addr(), + _dst.local_name(), + *reinterpret_cast(&_snd_msg->buf[sizeof(umword_t)]), + _rcv_msg->addr(), + reinterpret_cast(&rec_badge), + reinterpret_cast(&_rcv_msg->buf[sizeof(umword_t)]), + L4_IPC_NEVER, &ipc_result); + + if (L4_IPC_IS_ERROR(ipc_result)) { + + if (L4_IPC_ERROR(ipc_result) == L4_IPC_RECANCELED) + throw Genode::Blocking_canceled(); + + PERR("Ipc error %lx", L4_IPC_ERROR(ipc_result)); + throw Genode::Ipc_error(); + } + + /* + * Reset buffer read and write offsets. We shadow the first mword of the + * send message buffer (filled via '_write_offset') with the local name of + * the invoked remote object. We shadow the first mword of the receive + * buffer (retrieved via '_read_offset') with the local name of the reply + * capability ('rec_badge'), which is bogus in the L4/Fiasco case. In both + * cases, we skip the shadowed message mword when reading/writing the + * message payload. + */ + _write_offset = _read_offset = sizeof(umword_t); +} + + +Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg, + Msgbuf_base *rcv_msg): + Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0) +{ } + + +/**************** + ** Ipc_server ** + ****************/ + +void Ipc_server::_prepare_next_reply_wait() +{ + /* now we have a request to reply */ + _reply_needed = true; + + /* leave space for return value at the beginning of the msgbuf */ + _write_offset = 2*sizeof(umword_t); + + /* receive buffer offset */ + _read_offset = sizeof(umword_t); +} + + +void Ipc_server::_wait() +{ + /* wait for new server request */ + try { Ipc_istream::_wait(); } catch (Blocking_canceled) { } + + /* define destination of next reply */ + _dst = Native_capability(_rcv_cs, badge()); + + _prepare_next_reply_wait(); +} + + +void Ipc_server::_reply() +{ + using namespace Fiasco; + + _snd_msg->send_dope = L4_IPC_DOPE((_write_offset + sizeof(umword_t) - 1)>>2, 0); + + l4_msgdope_t result; + l4_ipc_send(_dst.tid(), _snd_msg->addr(), _dst.local_name(), + *reinterpret_cast(&_snd_msg->buf[sizeof(umword_t)]), + L4_IPC_SEND_TIMEOUT_0, &result); + + if (L4_IPC_IS_ERROR(result)) + PERR("Ipc error %lx, ignored", L4_IPC_ERROR(result)); + + _prepare_next_reply_wait(); +} + + +void Ipc_server::_reply_wait() +{ + using namespace Fiasco; + + if (_reply_needed) { + + l4_msgdope_t ipc_result; + + _snd_msg->send_dope = L4_IPC_DOPE((_write_offset + sizeof(umword_t) - 1)>>2, 0); + _rcv_msg->size_dope = L4_IPC_DOPE(_rcv_msg->size()>>2, 0); + + /* + * Use short IPC for reply if possible. + * This is the common case of returning + * an integer as RPC result. + */ + l4_ipc_reply_and_wait( + _dst.tid(), + _write_offset <= 2*sizeof(umword_t) ? L4_IPC_SHORT_MSG : _snd_msg->addr(), + _dst.local_name(), + *reinterpret_cast(&_snd_msg->buf[sizeof(umword_t)]), + &_rcv_cs, _rcv_msg->addr(), + reinterpret_cast(&_rcv_msg->buf[0]), + reinterpret_cast(&_rcv_msg->buf[sizeof(umword_t)]), + L4_IPC_SEND_TIMEOUT_0, &ipc_result); + + if (L4_IPC_IS_ERROR(ipc_result)) { + PERR("Ipc error %lx", L4_IPC_ERROR(ipc_result)); + + /* + * The error conditions could be a message cut (which + * we want to ignore on the server side) or a reply failure + * (for example, if the caller went dead during the call. + * In both cases, we do not reflect the error condition to + * the user but want to wait for the next proper incoming + * message. So let's just wait now. + */ + _wait(); + } + + } else _wait(); + + /* define destination of next reply */ + _dst = Native_capability(_rcv_cs, badge()); + + _prepare_next_reply_wait(); +} + + +Ipc_server::Ipc_server(Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg): + Ipc_istream(rcv_msg), + Ipc_ostream(Native_capability(), snd_msg), _reply_needed(false) +{ } diff --git a/base-fiasco/src/base/ipc/pager.cc b/base-fiasco/src/base/ipc/pager.cc new file mode 100644 index 000000000..4216d85a7 --- /dev/null +++ b/base-fiasco/src/base/ipc/pager.cc @@ -0,0 +1,69 @@ +/* + * \brief Pager support for Fiasco + * \author Christian Helmuth + * \date 2006-06-14 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include + +namespace Fiasco { +#include +#include +} + +using namespace Genode; +using namespace Fiasco; + + +void Ipc_pager::wait_for_fault() +{ + l4_msgdope_t result; + + do { + l4_ipc_wait(&_last, + L4_IPC_SHORT_MSG, &_pf_addr, &_pf_ip, + L4_IPC_NEVER, &result); + + if (L4_IPC_IS_ERROR(result)) + PERR("Ipc error %lx", L4_IPC_ERROR(result)); + + } while (L4_IPC_IS_ERROR(result)); +} + + +void Ipc_pager::reply_and_wait_for_fault() +{ + l4_msgdope_t result; + + l4_ipc_reply_and_wait(_last, + L4_IPC_SHORT_FPAGE, _reply_mapping.dst_addr(), + _reply_mapping.fpage().fpage, &_last, + L4_IPC_SHORT_MSG, &_pf_addr, &_pf_ip, + L4_IPC_SEND_TIMEOUT_0, &result); + + if (L4_IPC_IS_ERROR(result)) { + PERR("Ipc error %lx", L4_IPC_ERROR(result)); + + /* ignore all errors and wait for next proper message */ + wait_for_fault(); + } +} + + +void Ipc_pager::acknowledge_wakeup() +{ + /* answer wakeup call from one of core's region-manager sessions */ + l4_msgdope_t result; + l4_ipc_send(_last, L4_IPC_SHORT_MSG, 0, 0, L4_IPC_SEND_TIMEOUT_0, &result); +} + + +Ipc_pager::Ipc_pager() : Native_capability(Fiasco::l4_myself(), 0) { } diff --git a/base-fiasco/src/base/lock/lock.cc b/base-fiasco/src/base/lock/lock.cc new file mode 100644 index 000000000..773d7d855 --- /dev/null +++ b/base-fiasco/src/base/lock/lock.cc @@ -0,0 +1,50 @@ +/* + * \brief Lock implementation + * \author Norman Feske + * \date 2007-10-15 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include + +/* L4/Fiasco includes */ +namespace Fiasco { +#include +} + +using namespace Genode; + + +Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial) +: _native_lock(UNLOCKED) +{ + if (initial == LOCKED) + lock(); +} + + +void Cancelable_lock::lock() +{ + /* + * XXX: How to notice cancel-blocking signals issued when being outside the + * 'l4_ipc_sleep' system call? + */ + while (!Genode::cmpxchg(&_native_lock, UNLOCKED, LOCKED)) + if (Fiasco::l4_ipc_sleep(Fiasco::l4_ipc_timeout(0, 0, 500, 0)) != L4_IPC_RETIMEOUT) + throw Genode::Blocking_canceled(); +} + + +void Cancelable_lock::unlock() +{ + _native_lock = UNLOCKED; +} diff --git a/base-fiasco/src/base/pager/pager.cc b/base-fiasco/src/base/pager/pager.cc new file mode 100644 index 000000000..91fd42bd7 --- /dev/null +++ b/base-fiasco/src/base/pager/pager.cc @@ -0,0 +1,117 @@ +/* + * \brief Fiasco pager framework + * \author Norman Feske + * \author Christian Helmuth + * \date 2006-07-14 + * + * FIXME Isn't this file generic? + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +namespace Fiasco { +#include +#include +} + +using namespace Genode; + + +/********************** + ** Pager activation ** + **********************/ + +void Pager_activation_base::entry() +{ + Ipc_pager pager; + _cap = pager; + _cap_valid.unlock(); + + pager.wait_for_fault(); + while (1) { + + /* lookup referenced object */ + Pager_object *obj = _ep ? _ep->obj_by_id(pager.badge()) : 0; + + /* handle request */ + if (obj) { + if (obj->pager(pager)) + /* something strange occured - leave thread in pagefault */ + pager.wait_for_fault(); + else + pager.reply_and_wait_for_fault(); + } else { + + /* prevent threads outside of core to mess with our wake-up interface */ + enum { CORE_TASK_ID = 4 }; + if (pager.last().id.task != CORE_TASK_ID) { + + PWRN("page fault from unknown partner %x.%02x", + (int)pager.last().id.task, (int)pager.last().id.lthread); + + } else { + + /* + * We got a request from one of cores region-manager sessions + * to answer the pending page fault of a resolved region-manager + * client. Hence, we have to send the page-fault reply to the + * specified thread and answer the call of the region-manager + * session. + * + * When called from a region-manager session, we receive the + * core-local address of the targeted pager object via the + * first message word, which corresponds to the 'fault_ip' + * argument of normal page-fault messages. + */ + obj = reinterpret_cast(pager.fault_ip()); + + /* send reply to the calling region-manager session */ + pager.acknowledge_wakeup(); + + /* answer page fault of resolved pager object */ + pager.set_reply_dst(obj->cap()); + pager.acknowledge_wakeup(); + } + pager.wait_for_fault(); + } + }; +} + + +/********************** + ** Pager entrypoint ** + **********************/ + +Pager_entrypoint::Pager_entrypoint(Cap_session *, Pager_activation_base *a) +: _activation(a) +{ _activation->ep(this); } + + +void Pager_entrypoint::dissolve(Pager_object *obj) +{ + remove(obj); +} + + +Pager_capability Pager_entrypoint::manage(Pager_object *obj) +{ + /* return invalid capability if no activation is present */ + if (!_activation) return Pager_capability(); + + Native_thread_id tid = _activation->cap().tid(); + Native_capability cap(_activation->cap().tid(), obj->badge()); + + /* add server object to object pool */ + obj->cap(cap); + insert(obj); + + /* return capability that uses the object id as badge */ + return reinterpret_cap_cast(cap); +} diff --git a/base-fiasco/src/bootstrap/target.mk b/base-fiasco/src/bootstrap/target.mk new file mode 100644 index 000000000..e2a41b44f --- /dev/null +++ b/base-fiasco/src/bootstrap/target.mk @@ -0,0 +1,5 @@ +TARGET = bootstrap +PKGS = bootstrap +LIBS = l4v2_support + +include $(REP_DIR)/mk/l4_pkg.mk diff --git a/base-fiasco/src/core/arm/platform_arm.cc b/base-fiasco/src/core/arm/platform_arm.cc new file mode 100644 index 000000000..81c895a68 --- /dev/null +++ b/base-fiasco/src/core/arm/platform_arm.cc @@ -0,0 +1,24 @@ +/* + * \brief Platform support specific to ARM + * \author Norman Feske + * \date 2007-10-13 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include "platform.h" + +using namespace Genode; + +void Platform::_setup_io_port_alloc() +{ + /* + * This is just a dummy init function for the I/O port allocator. + * ARM does not I/O port support. + */ +} diff --git a/base-fiasco/src/core/arm/target.mk b/base-fiasco/src/core/arm/target.mk new file mode 100644 index 000000000..1be0ccfdb --- /dev/null +++ b/base-fiasco/src/core/arm/target.mk @@ -0,0 +1,7 @@ +include $(PRG_DIR)/../target.inc + +REQUIRES += arm +SRC_CC += platform_arm.cc + +vpath io_port_session_component.cc $(GEN_CORE_DIR)/arm + diff --git a/base-fiasco/src/core/include/map_local.h b/base-fiasco/src/core/include/map_local.h new file mode 100644 index 000000000..f4fd7c148 --- /dev/null +++ b/base-fiasco/src/core/include/map_local.h @@ -0,0 +1,76 @@ +/* + * \brief Core-local mapping + * \author Norman Feske + * \date 2010-02-15 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__MAP_LOCAL_H_ +#define _CORE__INCLUDE__MAP_LOCAL_H_ + +/* core includes */ +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +} + +namespace Genode { + + /** + * Map page locally within core + * + * On Fiasco, all mapping originate from virtual addresses. At startup, + * core obtains the whole memory sigma0 in a one-to-one fashion. Hence, + * core-local addresses normally correspond to physical addresses. + * + * \param from_addr core-virtual source address + * \param to_addr core-virtual destination address + * \param num_pages number of pages to remap + */ + inline bool map_local(addr_t from_addr, addr_t to_addr, size_t num_pages) + { + Native_thread_id core_pager = platform_specific()->core_pager()->native_thread_id(); + + addr_t offset = 0; + size_t page_size = get_page_size(); + size_t page_size_log2 = get_page_size_log2(); + for (unsigned i = 0; i < num_pages; i++, offset += page_size) { + + using namespace Fiasco; + + /* perform echo request to the core pager */ + l4_umword_t dummy = 0; + l4_msgdope_t ipc_result; + l4_fpage_t from_fpage = l4_fpage(from_addr + offset, + page_size_log2, true, false); + enum { ECHO_LOCAL_MAP_REQUEST = 0 }; + l4_ipc_call(core_pager, L4_IPC_SHORT_MSG, + from_fpage.raw, /* normally page-fault addr */ + ECHO_LOCAL_MAP_REQUEST, /* normally page-fault IP */ + L4_IPC_MAPMSG(to_addr + offset, page_size_log2), + &dummy, &dummy, + L4_IPC_NEVER, &ipc_result); + + if (L4_IPC_IS_ERROR(ipc_result)) { + PWRN("could not locally remap 0x%lx to 0x%lx, error code is %ld", + from_addr, to_addr, L4_IPC_ERROR(ipc_result)); + return false; + } + } + return true; + } +} + +#endif /* _CORE__INCLUDE__MAP_LOCAL_H_ */ + diff --git a/base-fiasco/src/core/include/platform.h b/base-fiasco/src/core/include/platform.h new file mode 100644 index 000000000..7052fb68a --- /dev/null +++ b/base-fiasco/src/core/include/platform.h @@ -0,0 +1,157 @@ +/* + * \brief Fiasco platform + * \author Christian Helmuth + * \author Norman Feske + * \date 2007-09-10 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_H_ +#define _CORE__INCLUDE__PLATFORM_H_ + +#include +#include + +#include "platform_generic.h" +#include "platform_thread.h" +#include "platform_pd.h" +#include "multiboot.h" + + +namespace Genode { + + class Platform : public Platform_generic + { + private: + + /* + * Shortcut for the type of allocator instances for physical resources + */ + typedef Synchronized_range_allocator Phys_allocator; + + Platform_pd *_core_pd; /* core protection domain object */ + Phys_allocator _ram_alloc; /* RAM allocator */ + Phys_allocator _io_mem_alloc; /* MMIO allocator */ + Phys_allocator _io_port_alloc; /* I/O port allocator */ + Phys_allocator _irq_alloc; /* IRQ allocator */ + Phys_allocator _region_alloc; /* virtual memory allocator for core */ + Multiboot_info _mb_info; /* multiboot information */ + Rom_fs _rom_fs; /* ROM file system */ + Rom_module _kip_rom; /* ROM module for Fiasco KIP */ + + addr_t _vm_start; /* begin of virtual memory */ + size_t _vm_size; /* size of virtual memory */ + + /* + * We do not export any boot module loaded before FIRST_ROM. + */ + enum { FIRST_ROM = 3 }; + + /** + * Setup base resources + * + * - Map and provide KIP as ROM module + * - Initializes region allocator + * - Initializes multiboot info structure + */ + void _setup_basics(); + + /** + * Setup RAM, IO_MEM, and region allocators + */ + void _setup_mem_alloc(); + + /** + * Setup I/O port space allocator + */ + void _setup_io_port_alloc(); + + /** + * Setup IRQ allocator + */ + void _setup_irq_alloc(); + + /** + * Parse multi-boot information and update ROM database + */ + void _setup_rom(); + + /** + * Setup pager for core-internal threads + */ + void _setup_core_pager(); + + public: + + /** + * Pager object representing the pager of core namely sigma0 + */ + struct Sigma0 : public Pager_object + { + /** + * Constructor + */ + Sigma0(); + + int pager(Ipc_pager &ps) { /* never called */ return -1; } + }; + + /** + * Return singleton instance of Sigma0 pager object + */ + static Sigma0 *sigma0(); + + /** + * Core pager thread that handles core-internal page-faults + */ + struct Core_pager : public Platform_thread, public Pager_object + { + /** + * Constructor + */ + Core_pager(Platform_pd *core_pd); + + int pager(Ipc_pager &ps) { /* never called */ return -1; } + }; + + /** + * Return singleton instance of core pager object + */ + Core_pager *core_pager(); + + /** + * Constructor + */ + Platform(); + + /** + * Accessor for core pd object + */ + Platform_pd *core_pd() { return _core_pd; } + + + /******************************** + ** Generic platform interface ** + ********************************/ + + Allocator *core_mem_alloc() { return &_ram_alloc; } + Range_allocator *ram_alloc() { return &_ram_alloc; } + Range_allocator *io_mem_alloc() { return &_io_mem_alloc; } + Range_allocator *io_port_alloc() { return &_io_port_alloc; } + Range_allocator *irq_alloc() { return &_irq_alloc; } + Range_allocator *region_alloc() { return &_region_alloc; } + addr_t vm_start() const { return _vm_start; } + size_t vm_size() const { return _vm_size; } + Rom_fs *rom_fs() { return &_rom_fs; } + + void wait_for_exit(); + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_H_ */ diff --git a/base-fiasco/src/core/include/platform_pd.h b/base-fiasco/src/core/include/platform_pd.h new file mode 100644 index 000000000..55c486041 --- /dev/null +++ b/base-fiasco/src/core/include/platform_pd.h @@ -0,0 +1,182 @@ +/* + * \brief L4/Fiasco protection domain facility + * \author Christian Helmuth + * \date 2006-04-11 + * + * Protection domains are L4 tasks under Fiasco and serve as base + * container for the platform. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_PD_H_ +#define _CORE__INCLUDE__PLATFORM_PD_H_ + +#include + +namespace Fiasco { +#include +} + +namespace Genode { + + class Platform_thread; + class Platform_pd + { + private: + + enum { + VERSION_BITS = 10, + PD_FIRST = 0x10, + PD_MAX = (1 << 11) - 1, /* leave 0x7ff free for L4_INVALID_ID */ + PD_VERSION_MAX = (1 << 10) - 1, + PD_INVALID = -1, + THREAD_MAX = (1 << 7), + }; + + unsigned _pd_id; /* plain pd number */ + unsigned _version; /* version number */ + + Fiasco::l4_taskid_t _l4_task_id; /* L4 task ID */ + + + /********************************************** + ** Threads of this protection domain object ** + **********************************************/ + + Platform_thread *_threads[THREAD_MAX]; + + /** + * Initialize thread allocator + */ + void _init_threads(); + + /** + * Thread iteration for one task + */ + Platform_thread *_next_thread(); + + /** + * Thread allocation + * + * Again a special case for Core thread0. + */ + int _alloc_thread(int thread_id, Platform_thread *thread); + + /** + * Thread deallocation + * + * No special case for Core thread0 here - we just never call it. + */ + void _free_thread(int thread_id); + + + /****************** + ** PD allocator ** + ******************/ + + struct Pd_alloc + { + unsigned reserved : 1; + unsigned free : 1; + unsigned version : VERSION_BITS; + + Pd_alloc(bool r, bool f, unsigned v) + : reserved(r), free(f), version(v) { } + + Pd_alloc() : reserved(0), free(0), version(0) { } + }; + + static Pd_alloc *_pds() + { + static Pd_alloc static_pds[PD_MAX]; + return static_pds; + } + + /** + * Protection-domain creation + * + * The syscall parameter propagates if any L4 kernel function + * should be used. We need the special case for the Core startup. + */ + void _create_pd(bool syscall); + + /** + * Protection domain destruction + * + * No special case for Core here - we just never call it. + */ + void _destroy_pd(); + + /** + * Protection domain allocation + * + * Find free L4 task and use it. We need the special case for Core + * startup. + */ + int _alloc_pd(signed pd_id); + + /** + * Protection domain deallocation + * + * No special case for Core here - we just never call it. + */ + void _free_pd(); + + + /*************** + ** Debugging ** + ***************/ + + void _debug_log_pds(void); + void _debug_log_threads(void); + + public: + + /** + * Constructor + */ + Platform_pd(signed pd_id = PD_INVALID, bool create = true); + + /** + * Destructor + */ + ~Platform_pd(); + + /** + * Initialize L4 task facility + */ + static void init(); + + /** + * Bind thread to protection domain + * + * \return 0 on success or + * -1 if thread ID allocation failed. + * + * This function allocates the physical L4 thread ID. + */ + int bind_thread(Platform_thread *thread); + + /** + * Unbind thread from protection domain + * + * Free the thread's slot and update thread object. + */ + void unbind_thread(Platform_thread *thread); + + /** + * Assign parent interface to protection domain + */ + int assign_parent(Native_capability parent) { return 0; } + + int pd_id() const { return _pd_id; } + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */ diff --git a/base-fiasco/src/core/include/platform_thread.h b/base-fiasco/src/core/include/platform_thread.h new file mode 100644 index 000000000..41d9215d1 --- /dev/null +++ b/base-fiasco/src/core/include/platform_thread.h @@ -0,0 +1,142 @@ +/* + * \brief Fiasco thread facility + * \author Christian Helmuth + * \date 2006-04-11 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_THREAD_H_ +#define _CORE__INCLUDE__PLATFORM_THREAD_H_ + +/* Genode includes */ +#include +#include +#include + +/* core includes */ +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +namespace Genode { + + class Platform_pd; + class Platform_thread + { + private: + + int _thread_id; /* plain thread number */ + Native_thread_id _l4_thread_id; /* L4 thread ID */ + char _name[32]; /* thread name that will be + registered at the kernel + debugger */ + Platform_pd *_platform_pd; /* protection domain thread + is bound to */ + Pager_object *_pager; + + public: + + enum { + THREAD_INVALID = -1, /* invalid thread number */ + }; + + /** + * Constructor + */ + Platform_thread(const char *name = 0, unsigned priority = 0, + int thread_id = THREAD_INVALID); + + /** + * Destructor + */ + ~Platform_thread(); + + /** + * Start thread + * + * \param ip instruction pointer to start at + * \param sp stack pointer to use + * + * \retval 0 successful + * \retval -1 thread could not be started + */ + int start(void *ip, void *sp); + + /** + * Pause this thread + */ + void pause(); + + /** + * Resume this thread + */ + void resume(); + + /** + * Cancel currently blocking operation + */ + void cancel_blocking(); + + /** + * This thread is about to be bound + * + * \param thread_id local thread ID + * \param l4_thread_id final L4 thread ID + * \param pd platform pd, thread is bound to + */ + void bind(int thread_id, Native_thread_id l4_thread_id, + Platform_pd *pd); + + /** + * Unbind this thread + */ + void unbind(); + + /** + * Request thread state + * + * \param state_dst destination state buffer + * + * \retval 0 successful + * \retval -1 thread state not accessible + */ + int state(Genode::Thread_state *state_dst); + + + /************************ + ** Accessor functions ** + ************************/ + + /** + * Return/set pager + */ + Pager_object *pager() const { return _pager; } + void pager(Pager_object *pager) { _pager = pager; } + + /** + * Return identification of thread when faulting + */ + unsigned long pager_object_badge() const { + return convert_native_thread_id_to_badge(_l4_thread_id); } + + + /******************************* + ** Fiasco-specific Accessors ** + *******************************/ + + int thread_id() const { return _thread_id; } + Native_thread_id native_thread_id() const { return _l4_thread_id; } + const char *name() const { return _name; } + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */ diff --git a/base-fiasco/src/core/include/util.h b/base-fiasco/src/core/include/util.h new file mode 100644 index 000000000..cda2f5641 --- /dev/null +++ b/base-fiasco/src/core/include/util.h @@ -0,0 +1,121 @@ +/* + * \brief Fiasco utilities + * \author Christian Helmuth + * \date 2006-04-11 + * + * Is very practical now, but please keep the errors of the l4util pkg in mind. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__UTIL_H_ +#define _CORE__INCLUDE__UTIL_H_ + +/* Genode includes */ +#include +#include +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +#include +} + +namespace Genode { + + inline void log_event(const char *s) + { + Fiasco::fiasco_tbuf_log(s); + } + + inline void log_event(const char *s, unsigned v1, unsigned v2, unsigned v3) + { + Fiasco::fiasco_tbuf_log_3val(s, v1, v2, v3); + } + + inline void panic(const char *s) + { + using namespace Fiasco; + outstring(s); + enter_kdebug("> panic <"); + } + + inline void touch_ro(const void *addr, unsigned size) + { + using namespace Fiasco; + unsigned char const volatile *bptr; + unsigned char const *eptr; + + bptr = (unsigned char const volatile *)(((unsigned)addr) & L4_PAGEMASK); + eptr = (unsigned char const *)(((unsigned)addr + size - 1) & L4_PAGEMASK); + for ( ; bptr <= eptr; bptr += L4_PAGESIZE) + touch_read(bptr); + } + + inline void touch_rw(const void *addr, unsigned size) + { + using namespace Fiasco; + unsigned char volatile *bptr; + unsigned char const *eptr; + + bptr = (unsigned char volatile *)(((unsigned)addr) & L4_PAGEMASK); + eptr = (unsigned char const *)(((unsigned)addr + size - 1) & L4_PAGEMASK); + for (; bptr <= eptr; bptr += L4_PAGESIZE) + touch_read_write(bptr); + } + + inline addr_t trunc_page(addr_t addr) + { + using namespace Fiasco; + return l4_trunc_page(addr); + } + + inline addr_t round_page(addr_t addr) + { + using namespace Fiasco; + return l4_round_page(addr); + } + + inline addr_t round_superpage(addr_t addr) + { + using namespace Fiasco; + return l4_round_superpage(addr); + } + + inline size_t get_page_size() { return L4_PAGESIZE; } + + inline size_t get_page_size_log2() { return L4_LOG2_PAGESIZE; } + + inline size_t get_super_page_size() { return L4_SUPERPAGESIZE; } + + inline size_t get_super_page_size_log2() { return L4_LOG2_SUPERPAGESIZE; } + + inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, + Rm_session::Fault_type pf_type, + unsigned long badge) + { + Native_thread_id tid; + tid.raw = badge; + printf("%s (%s pf_addr=%p pf_ip=%p from %x.%02x)\n", msg, + pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ", + (void *)pf_addr, (void *)pf_ip, + (int)tid.id.task, (int)tid.id.lthread); + } + + inline addr_t map_src_addr(addr_t core_local_addr, addr_t phys_addr) { + return core_local_addr; } + + inline size_t constrain_map_size_log2(size_t size_log2) { return size_log2; } +} + +#endif /* _CORE__INCLUDE__UTIL_H_ */ diff --git a/base-fiasco/src/core/io_mem_session_support.cc b/base-fiasco/src/core/io_mem_session_support.cc new file mode 100644 index 000000000..14ea9b13b --- /dev/null +++ b/base-fiasco/src/core/io_mem_session_support.cc @@ -0,0 +1,95 @@ +/* + * \brief Fiasco-specific implementation of the IO_MEM session interface + * \author Christian Helmuth + * \date 2006-08-28 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +} + +using namespace Genode; + + +void Io_mem_session_component::_unmap_local(addr_t base, size_t size) +{ + platform()->region_alloc()->free(reinterpret_cast(base)); +} + + +static inline bool can_use_super_page(addr_t base, size_t size) { + return (base & (get_super_page_size() - 1)) == 0 + && (size >= get_super_page_size()); } + + +addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) +{ + using namespace Fiasco; + + /* align large I/O dataspaces on a super-page boundary within core */ + size_t alignment = (size >= get_super_page_size()) ? get_super_page_size_log2() + : get_page_size_log2(); + + /* find appropriate region for mapping */ + void *local_base = 0; + if (!platform()->region_alloc()->alloc_aligned(size, &local_base, alignment)) + return 0; + + /* call sigma0 for I/O region */ + int err; + l4_umword_t request; + l4_umword_t dw0, dw1; + l4_msgdope_t result; + l4_msgtag_t tag; + + l4_threadid_t sigma0 = sigma0_threadid; + + unsigned offset = 0; + while (size) { + /* FIXME what about caching demands? */ + /* FIXME what about read / write? */ + + /* special case for page0, which is RAM in sigma0/x86 */ + if (base + offset == 0) + request = SIGMA0_REQ_FPAGE_RAM; + else + request = SIGMA0_REQ_FPAGE_IOMEM; + + size_t page_size_log2 = get_page_size_log2(); + if (can_use_super_page(base + offset, size)) + page_size_log2 = get_super_page_size_log2(); + + err = l4_ipc_call_tag(sigma0, + L4_IPC_SHORT_MSG, + request, + l4_fpage(base + offset, page_size_log2, 0, 0).fpage, + l4_msgtag(L4_MSGTAG_SIGMA0, 0, 0, 0), + L4_IPC_MAPMSG((addr_t)local_base + offset, page_size_log2), + &dw0, &dw1, + L4_IPC_NEVER, &result, &tag); + + if (err || !l4_ipc_fpage_received(result)) { + PERR("%d %d", err, l4_ipc_fpage_received(result)); + return 0; + } + + offset += 1 << page_size_log2; + size -= 1 << page_size_log2; + } + + return (addr_t)local_base; +} diff --git a/base-fiasco/src/core/irq_session_component.cc b/base-fiasco/src/core/irq_session_component.cc new file mode 100644 index 000000000..89e726f53 --- /dev/null +++ b/base-fiasco/src/core/irq_session_component.cc @@ -0,0 +1,122 @@ +/* + * \brief Core implementation of IRQ sessions + * \author Christian Helmuth + * \date 2007-09-13 + * + * FIXME ram quota missing + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +} + +using namespace Genode; + + +bool Irq_session_component::Irq_control_component::associate_to_irq(unsigned irq_number) +{ + using namespace Fiasco; + + int err; + l4_threadid_t irq_tid; + l4_umword_t dw0, dw1; + l4_msgdope_t result; + + l4_make_taskid_from_irq(irq_number, &irq_tid); + + /* boost thread to IRQ priority */ + enum { IRQ_PRIORITY = 0xC0 }; + + l4_sched_param_t param = {sp:{prio:IRQ_PRIORITY, small:0, state:0, time_exp:0, time_man:0}}; + l4_threadid_t ext_preempter = L4_INVALID_ID; + l4_threadid_t partner = L4_INVALID_ID; + l4_sched_param_t old_param; + l4_thread_schedule(l4_myself(), param, &ext_preempter, &partner, &old_param); + + err = l4_ipc_receive(irq_tid, + L4_IPC_SHORT_MSG, &dw0, &dw1, + L4_IPC_BOTH_TIMEOUT_0, &result); + + if (err != L4_IPC_RETIMEOUT) PERR("IRQ association failed"); + + return (err == L4_IPC_RETIMEOUT); +} + + +void Irq_session_component::wait_for_irq() +{ + using namespace Fiasco; + + l4_threadid_t irq_tid; + l4_umword_t dw0=0, dw1=0; + l4_msgdope_t result; + + l4_make_taskid_from_irq(_irq_number, &irq_tid); + + do { + l4_ipc_call(irq_tid, + L4_IPC_SHORT_MSG, 0, 0, + L4_IPC_SHORT_MSG, &dw0, &dw1, + L4_IPC_NEVER, &result); + + if (L4_IPC_IS_ERROR(result)) PERR("Ipc error %lx", L4_IPC_ERROR(result)); + } while (L4_IPC_IS_ERROR(result)); +} + + +Irq_session_component::Irq_session_component(Cap_session *cap_session, + Range_allocator *irq_alloc, + const char *args) +: + _irq_alloc(irq_alloc), + _ep(cap_session, STACK_SIZE, "irqctrl"), + _control_cap(_ep.manage(&_control_component)), + _control_client(_control_cap) +{ + bool shared = Arg_string::find_arg(args, "irq_shared").bool_value(false); + if (shared) { + PWRN("IRQ sharing not supported"); + throw Root::Invalid_args(); + } + + long irq_number = Arg_string::find_arg(args, "irq_number").long_value(-1); + if (irq_number == -1 || !irq_alloc || + irq_alloc->alloc_addr(1, irq_number) != Range_allocator::ALLOC_OK) { + PERR("Unavailable IRQ %lx requested", irq_number); + throw Root::Invalid_args(); + } + _irq_number = irq_number; + + if (!_control_client.associate_to_irq(irq_number)) { + PWRN("IRQ association failed"); + throw Root::Invalid_args(); + } + + /* initialize capability */ + _irq_cap = Irq_session_capability(_ep.manage(this)); +} + + +Irq_session_component::~Irq_session_component() +{ + PERR("Implement me, immediately!"); +} + diff --git a/base-fiasco/src/core/platform.cc b/base-fiasco/src/core/platform.cc new file mode 100644 index 000000000..f9782720c --- /dev/null +++ b/base-fiasco/src/core/platform.cc @@ -0,0 +1,509 @@ +/* + * \brief Fiasco platform interface implementation + * \author Christian Helmuth + * \date 2006-04-11 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include +#include +#include + +/* core includes */ +#include +#include +#include +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +#include +#include +#include +} + +using namespace Genode; + + +static const bool verbose = true; +static const bool verbose_core_pf = false; +static const bool verbose_region_alloc = false; + + +/*********************************** + ** Core address space management ** + ***********************************/ + +static Synchronized_range_allocator &_core_address_ranges() +{ + static Synchronized_range_allocator _core_address_ranges(0); + return _core_address_ranges; +} + +enum { PAGER_STACK_ELEMENTS = 1024 }; +static unsigned long _core_pager_stack[PAGER_STACK_ELEMENTS]; +static unsigned _core_pager_arg; + + +/** + * Core pager "service loop" + */ +static void _core_pager_loop() +{ + unsigned pd_id = _core_pager_arg; + + using namespace Fiasco; + + l4_threadid_t t; + l4_umword_t dw0, dw1; + l4_msgdope_t r; + + bool send_reply = false; + + while (1) { + + if (send_reply) + /* unblock faulter and wait for next pagefault */ + l4_ipc_reply_and_wait(t, L4_IPC_SHORT_MSG, 0, 0, + &t, L4_IPC_SHORT_MSG, &dw0, &dw1, + L4_IPC_NEVER, &r); + else + l4_ipc_wait(&t, L4_IPC_SHORT_MSG, &dw0, &dw1, L4_IPC_NEVER, &r); + + /* ignore messages from non-core pds */ + if (t.id.task != pd_id) break; + + /* detect local map request */ + if (dw1 == 0) { + l4_msgdope_t ipc_result; + l4_ipc_send(t, L4_IPC_SHORT_FPAGE, 0, dw0, + L4_IPC_SEND_TIMEOUT_0, &ipc_result); + send_reply = false; + continue; + } + + bool rw = dw0 & 2; + addr_t pfa = dw0 & ~2; + + if (pfa < L4_PAGESIZE) { + + /* NULL pointer access */ + PERR("Possible null pointer %s in %x.%02x at %lx IP %lx", + rw ? "WRITE" : "READ", (int)t.id.task, (int)t.id.lthread, pfa, dw1); + /* do not unblock faulter */ + send_reply = false; + continue; + } else if (!_core_address_ranges().valid_addr(pfa)) { + + /* page-fault address is not in RAM */ + PERR("%s access outside of RAM in %x.%02x at %lx IP %lx", + rw ? "WRITE" : "READ", (int)t.id.task, (int)t.id.lthread, pfa, dw1); + /* do not unblock faulter */ + send_reply = false; + continue; + } else if (verbose_core_pf) + PDBG("pfa=%lx ip=%lx thread %x.%02x", pfa, dw1, (int)t.id.task, (int)t.id.lthread); + + /* my pf handler is sigma0 - just touch the appropriate page */ + if (rw) + touch_rw((void *)pfa, 1); + else + touch_ro((void *)pfa, 1); + + send_reply = true; + } +} + + +Platform::Sigma0::Sigma0() : Pager_object(0) +{ + cap(reinterpret_cap_cast(Native_capability(Fiasco::sigma0_threadid, 0))); +} + + +Platform::Sigma0 *Platform::sigma0() +{ + static Sigma0 _sigma0; + return &_sigma0; +} + + +Platform::Core_pager::Core_pager(Platform_pd *core_pd) +: + Platform_thread("core.pager"), Pager_object(0) +{ + Platform_thread::pager(sigma0()); + + core_pd->bind_thread(this); + cap(Native_capability(native_thread_id(), 0)); + + /* pager needs to know core's pd ID */ + _core_pager_arg = core_pd->pd_id(); + + /* stack begins at the top end of the '_core_pager_stack' array */ + void *sp = (void *)&_core_pager_stack[PAGER_STACK_ELEMENTS - 1]; + start((void *)_core_pager_loop, sp); + + using namespace Fiasco; + + /* pager0 receives pagefaults from me - for NULL pointer detection */ + l4_umword_t d; + l4_threadid_t preempter = L4_INVALID_ID; + l4_threadid_t pager = native_thread_id(); + l4_thread_ex_regs(l4_myself(), ~0UL, ~0UL, &preempter, &pager, &d, &d, &d); +} + + +Platform::Core_pager *Platform::core_pager() +{ + static Core_pager _core_pager(core_pd()); + return &_core_pager; +} + + +/*********************************** + ** Helper for L4 region handling ** + ***********************************/ + +struct Region +{ + addr_t start; + addr_t end; + + Region() : start(0), end(0) { } + Region(addr_t s, addr_t e) : start(s), end(e) { } +}; + + +/** + * Log region + */ +static inline void print_region(Region r) +{ + printf("[%08lx,%08lx) %08lx", r.start, r.end, r.end - r.start); +} + + +/** + * Add region to allocator + */ +static inline void add_region(Region r, Range_allocator &alloc) +{ + if (verbose_region_alloc) { + printf("%p add: ", &alloc); print_region(r); printf("\n"); + } + + /* adjust region */ + addr_t start = trunc_page(r.start); + addr_t end = round_page(r.end); + + alloc.add_range(start, end - start); +} + + +/** + * Remove region from allocator + */ +static inline void remove_region(Region r, Range_allocator &alloc) +{ + if (verbose_region_alloc) { + printf("%p remove: ", &alloc); print_region(r); printf("\n"); + } + + /* adjust region */ + addr_t start = trunc_page(r.start); + addr_t end = round_page(r.end); + + alloc.remove_range(start, end - start); +} + + +/** + * Request any RAM page from Sigma0 + */ +static inline int sigma0_req_region(addr_t *addr, unsigned log2size) +{ + using namespace Fiasco; + + /* XXX sigma0 always maps pages RW */ + l4_umword_t req_fpage = l4_fpage(0, log2size, 0, 0).fpage; + void* rcv_window = L4_IPC_MAPMSG(0, L4_WHOLE_ADDRESS_SPACE); + addr_t base; + l4_fpage_t rcv_fpage; + l4_msgdope_t result; + l4_msgtag_t tag; + + int err = l4_ipc_call_tag(Fiasco::sigma0_threadid, + L4_IPC_SHORT_MSG, SIGMA0_REQ_FPAGE_ANY, req_fpage, + l4_msgtag(L4_MSGTAG_SIGMA0, 0, 0, 0), + rcv_window, &base, (l4_umword_t *)&rcv_fpage, + L4_IPC_NEVER, &result, &tag); + int ret = (err || !l4_ipc_fpage_received(result)); + + if (!ret) touch_rw((void *)addr, 1); + + *addr = base; + return ret; +} + + +void Platform::_setup_mem_alloc() +{ + /* + * Completely map program image by touching all pages read-only to + * prevent sigma0 from handing out those page as anonymous memory. + */ + volatile const char *beg, *end; + beg = (const char *)(((unsigned)&_prog_img_beg) & L4_PAGEMASK); + end = (const char *)&_prog_img_end; + for ( ; beg < end; beg += L4_PAGESIZE) (void)(*beg); + + /* request pages of known page size starting with largest */ + size_t log2_sizes[] = { L4_LOG2_SUPERPAGESIZE, L4_LOG2_PAGESIZE }; + + for (unsigned i = 0; i < sizeof(log2_sizes)/sizeof(*log2_sizes); ++i) { + size_t log2_size = log2_sizes[i]; + size_t size = 1 << log2_size; + + int err = 0; + addr_t addr; + Region region; + + /* request any page of current size from sigma0 */ + do { + err = sigma0_req_region(&addr, log2_size); + if (!err) { + /* XXX do not allocate page0 */ + if (addr == 0) { + Fiasco::l4_fpage_unmap(Fiasco::l4_fpage(0, log2_size, 0, 0), + L4_FP_FLUSH_PAGE | L4_FP_ALL_SPACES); + continue; + } + + region.start = addr; region.end = addr + size; + add_region(region, _ram_alloc); + add_region(region, _core_address_ranges()); + remove_region(region, _io_mem_alloc); + remove_region(region, _region_alloc); + } + } while (!err); + } +} + + +void Platform::_setup_irq_alloc() { + _irq_alloc.add_range(0, 0x10); } + + +void Platform::_setup_basics() +{ + using namespace Fiasco; + + int err; + + /* region allocator is not setup yet */ + + /* map KIP one-to-one */ + void *fpage = L4_IPC_MAPMSG(0, L4_WHOLE_ADDRESS_SPACE); + l4_umword_t dw0, dw1; + l4_msgdope_t r; + l4_msgtag_t tag; + + err = l4_ipc_call_tag(Fiasco::sigma0_threadid, + L4_IPC_SHORT_MSG, SIGMA0_REQ_KIP, 0, + l4_msgtag(L4_MSGTAG_SIGMA0, 0, 0, 0), + fpage, &dw0, &dw1, + L4_IPC_NEVER, &r, &tag); + + bool amok = false; + if (err) { + printf("IPC error %d\n", err); + amok = true; + } + if (!l4_ipc_fpage_received(r)) { + printf("No fpage received\n"); + amok = true; + } + + if (amok) + panic("kip mapping failed"); + + /* store mapping base from received mapping */ + l4_kernel_info_t *kip = (l4_kernel_info_t *)dw0; + + if (kip->magic != L4_KERNEL_INFO_MAGIC) + panic("Sigma0 mapped something but not the KIP"); + + if (verbose) { + printf("\n"); + printf("KIP @ %p\n", kip); + printf(" magic: %08x\n", kip->magic); + printf(" version: %08x\n", kip->version); + printf(" sigma0 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma0_esp, kip->sigma0_eip); + printf(" sigma1 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma1_esp, kip->sigma1_eip); + printf(" root "); printf(" esp: %08lx eip: %08lx\n", kip->root_esp, kip->root_eip); + } + + /* add KIP as ROM module */ + _kip_rom = Rom_module((addr_t)kip, L4_PAGESIZE, "l4v2_kip"); + _rom_fs.insert(&_kip_rom); + + /* update multi-boot info pointer from KIP */ + void *mb_info_ptr = (void *)kip->user_ptr; + _mb_info = Multiboot_info(mb_info_ptr); + if (verbose) printf("MBI @ %p\n", mb_info_ptr); + + /* parse memory descriptors - look for virtual memory configuration */ + /* XXX we support only one VM region (here and also inside RM) */ + using L4::Kip::Mem_desc; + + _vm_start = 0; _vm_size = 0; + Mem_desc *desc = Mem_desc::first(kip); + + for (unsigned i = 0; i < Mem_desc::count(kip); ++i) + if (desc[i].is_virtual()) { + _vm_start = round_page(desc[i].start()); + _vm_size = trunc_page(desc[i].end() - _vm_start + 1); + + break; + } + if (_vm_size == 0) + panic("Virtual memory configuration not found"); + + /* configure applicable address space but never use page0 */ + _vm_size = _vm_start == 0 ? _vm_size - L4_PAGESIZE : _vm_size; + _vm_start = _vm_start == 0 ? L4_PAGESIZE : _vm_start; + _region_alloc.add_range(_vm_start, _vm_size); + + /* preserve context area in core's virtual address space */ + _region_alloc.remove_range(Thread_base::CONTEXT_AREA_VIRTUAL_BASE, + Thread_base::CONTEXT_AREA_VIRTUAL_SIZE); + + /* I/O memory could be the whole user address space */ + /* FIXME if the kernel helps to find out max address - use info here */ + _io_mem_alloc.add_range(0, ~0); + + /* remove KIP and MBI area from region and IO_MEM allocator */ + remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _region_alloc); + remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _io_mem_alloc); + remove_region(Region((addr_t)mb_info_ptr, (addr_t)mb_info_ptr + _mb_info.size()), _region_alloc); + remove_region(Region((addr_t)mb_info_ptr, (addr_t)mb_info_ptr + _mb_info.size()), _io_mem_alloc); + + /* remove core program image memory from region and IO_MEM allocator */ + addr_t img_start = (addr_t) &_prog_img_beg; + addr_t img_end = (addr_t) &_prog_img_end; + remove_region(Region(img_start, img_end), _region_alloc); + remove_region(Region(img_start, img_end), _io_mem_alloc); + + /* image is accessible by core */ + add_region(Region(img_start, img_end), _core_address_ranges()); +} + + +void Platform::_setup_rom() +{ + Rom_module rom; + + for (unsigned i = FIRST_ROM; i < _mb_info.num_modules(); i++) { + if (!(rom = _mb_info.get_module(i)).valid()) continue; + + Rom_module *new_rom = new(core_mem_alloc()) Rom_module(rom); + _rom_fs.insert(new_rom); + + if (verbose) + printf(" mod[%d] [%p,%p) %s\n", i, + (void *)new_rom->addr(), ((char *)new_rom->addr()) + new_rom->size(), + new_rom->name()); + + /* zero remainder of last ROM page */ + size_t count = L4_PAGESIZE - rom.size() % L4_PAGESIZE; + if (count != L4_PAGESIZE) + memset(reinterpret_cast(rom.addr() + rom.size()), 0, count); + + /* remove ROM area from region and IO_MEM allocator */ + remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _region_alloc); + remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _io_mem_alloc); + + /* add area to core-accessible ranges */ + add_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _core_address_ranges()); + } +} + + +Platform::Platform() : + _ram_alloc(0), _io_mem_alloc(core_mem_alloc()), + _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), + _region_alloc(core_mem_alloc()) +{ + /* + * We must be single-threaded at this stage and so this is safe. + */ + static bool initialized = 0; + if (initialized) panic("Platform constructed twice!"); + initialized = true; + + _setup_basics(); + _setup_mem_alloc(); + _setup_io_port_alloc(); + _setup_irq_alloc(); + _setup_rom(); + + if (verbose) { + printf(":ram_alloc: "); _ram_alloc.raw()->dump_addr_tree(); + printf(":region_alloc: "); _region_alloc.raw()->dump_addr_tree(); + printf(":io_mem: "); _io_mem_alloc.raw()->dump_addr_tree(); + printf(":io_port: "); _io_port_alloc.raw()->dump_addr_tree(); + printf(":irq: "); _irq_alloc.raw()->dump_addr_tree(); + printf(":rom_fs: "); _rom_fs.print_fs(); + printf(":core ranges: "); _core_address_ranges().raw()->dump_addr_tree(); + } + + Fiasco::l4_threadid_t myself = Fiasco::l4_myself(); + + Platform_pd::init(); + + /* setup pd object for core pd */ + _core_pd = new(core_mem_alloc()) Platform_pd(myself.id.task, false); + + /* + * We setup the thread object for thread0 in core pd using a special + * interface that allows us to specify the lthread number. + */ + Platform_thread *core_thread = new(core_mem_alloc()) Platform_thread("core.main", myself.id.lthread); + core_thread->pager(sigma0()); + _core_pd->bind_thread(core_thread); + + /* we never call _core_thread.start(), so set name directly */ + Fiasco::fiasco_register_thread_name(core_thread->native_thread_id(), core_thread->name()); +} + + +/******************************** + ** Generic platform interface ** + ********************************/ + +void Platform::wait_for_exit() +{ + /* + * On Fiasco, Core never exits. So let us sleep forever. + */ + sleep_forever(); +} + + +void Core_parent::exit(int exit_value) { } diff --git a/base-fiasco/src/core/platform_pd.cc b/base-fiasco/src/core/platform_pd.cc new file mode 100644 index 000000000..329ad3d22 --- /dev/null +++ b/base-fiasco/src/core/platform_pd.cc @@ -0,0 +1,290 @@ +/* + * \brief Fiasco protection domain facility + * \author Christian Helmuth + * \date 2006-04-11 + * + * On Fiasco, the pd class has several duties: + * + * - It is an allocator for L4 tasks and cares for versioning and recycling. We + * do this with "static class members". + * - L4 threads are tied to L4 tasks and there are only 128 per L4 task. So + * each pd object is an allocator for its threads. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +using namespace Fiasco; +using namespace Genode; + + +static const bool verbose = false; + + +/************************** + ** Static class members ** + **************************/ + +static bool _init = false; + + +void Platform_pd::init() +{ + if (_init) return; + + unsigned i; + Pd_alloc reserved(true, true, 0); + Pd_alloc free(false, true, 0); + + /* mark reserved protection domains */ + for (i = 0; i < PD_FIRST; ++i) _pds()[i] = reserved; + /* init remainder */ + for ( ; i < PD_MAX; ++i) _pds()[i] = free; + + _init = true; +} + + +/**************************** + ** Private object members ** + ****************************/ + +void Platform_pd::_create_pd(bool syscall) +{ + l4_threadid_t l4t = l4_myself(); + l4t.id.task = _pd_id; + l4t.id.lthread = 0; + l4t.id.version_low = _version; + + l4_taskid_t nt; + if (syscall) + nt = l4_task_new(l4t, 0, 0, 0, l4t); + else + nt = l4t; + + if (l4_is_nil_id(nt)) + panic("pd creation failed"); + + _l4_task_id = nt; +} + + +void Platform_pd::_destroy_pd() +{ + l4_threadid_t l4t = _l4_task_id; + + /* L4 task deletion is: make inactive with myself as chief in 2nd parameter */ + l4_taskid_t nt = l4_task_new(l4t, convert_native_thread_id_to_badge(l4_myself()), + 0, 0, L4_NIL_ID); + + if (l4_is_nil_id(nt)) + panic("pd destruction failed"); + + _l4_task_id = L4_INVALID_ID; +} + + +int Platform_pd::_alloc_pd(signed pd_id) +{ + if (pd_id == PD_INVALID) { + unsigned i; + + for (i = PD_FIRST; i < PD_MAX; i++) + if (_pds()[i].free) break; + + /* no free protection domains available */ + if (i == PD_MAX) return -1; + + pd_id = i; + } else { + if (!_pds()[pd_id].reserved || !_pds()[pd_id].free) + return -1; + } + + _pds()[pd_id].free = 0; + + _pd_id = pd_id; + _version = _pds()[pd_id].version; + + return pd_id; +} + + +void Platform_pd::_free_pd() +{ + unsigned t = _pd_id; + + /* XXX check and log double-free? */ + if (_pds()[t].free) return; + + /* maximum reuse count reached leave non-free */ + if (_pds()[t].version == PD_VERSION_MAX) return; + + _pds()[t].free = 1; + ++_pds()[t].version; +} + + +void Platform_pd::_init_threads() +{ + unsigned i; + + for (i = 0; i < THREAD_MAX; ++i) + _threads[i] = 0; +} + + +Platform_thread* Platform_pd::_next_thread() +{ + unsigned i; + + /* look for bound thread */ + for (i = 0; i < THREAD_MAX; ++i) + if (_threads[i]) break; + + /* no bound threads */ + if (i == THREAD_MAX) return 0; + + return _threads[i]; +} + + +int Platform_pd::_alloc_thread(int thread_id, Platform_thread *thread) +{ + int i = thread_id; + + /* look for free thread */ + if (thread_id == Platform_thread::THREAD_INVALID) { + for (i = 0; i < THREAD_MAX; ++i) + if (!_threads[i]) break; + + /* no free threads available */ + if (i == THREAD_MAX) return -1; + } else { + if (_threads[i]) return -2; + } + + _threads[i] = thread; + + return i; +} + + +void Platform_pd::_free_thread(int thread_id) +{ + if (!_threads[thread_id]) + PWRN("double-free of thread %x.%x detected", _pd_id, thread_id); + + _threads[thread_id] = 0; +} + + +/*************************** + ** Public object members ** + ***************************/ + +int Platform_pd::bind_thread(Platform_thread *thread) +{ + /* thread_id is THREAD_INVALID by default - only core is the special case */ + int thread_id = thread->thread_id(); + l4_threadid_t l4_thread_id; + + int t = _alloc_thread(thread_id, thread); + if (t < 0) { + PERR("Thread alloc failed"); + return -1; + } + thread_id = t; + + l4_thread_id = _l4_task_id; + l4_thread_id.id.lthread = thread_id; + + /* finally inform thread about binding */ + thread->bind(thread_id, l4_thread_id, this); + + if (verbose) _debug_log_threads(); + return 0; +} + + +void Platform_pd::unbind_thread(Platform_thread *thread) +{ + int thread_id = thread->thread_id(); + + /* unbind thread before proceeding */ + thread->unbind(); + + _free_thread(thread_id); + + if (verbose) _debug_log_threads(); +} + + +Platform_pd::Platform_pd(signed pd_id, bool create) +{ + /* check correct init */ + if (!_init) + panic("init pd facility via Platform_pd::init() before using it!"); + + /* init threads */ + _init_threads(); + + int ret = _alloc_pd(pd_id); + if (ret < 0) { + _debug_log_pds(); + panic("pd alloc failed"); + } + + _create_pd(create); +} + + +Platform_pd::~Platform_pd() +{ + /* unbind all threads */ + while (Platform_thread *t = _next_thread()) unbind_thread(t); + + _destroy_pd(); + _free_pd(); +} + + +/*********************** + ** Debugging support ** + ***********************/ + +void Platform_pd::_debug_log_threads() +{ + int i; + printf("[%02x] ", _pd_id); + for (i = 0; i < THREAD_MAX; ++i) { + printf("%c", !_threads[i] ? '.' : 'X'); + if (i == 63) printf("\n "); + } + printf("\n"); +} + + +void Platform_pd::_debug_log_pds() +{ + int i; + for (i = 0; i < PD_MAX; ++i) + printf("[%02x] %d %d %d\n", i, _pds()[i].reserved, _pds()[i].free, + _pds()[i].version); +} diff --git a/base-fiasco/src/core/platform_thread.cc b/base-fiasco/src/core/platform_thread.cc new file mode 100644 index 000000000..fbd632197 --- /dev/null +++ b/base-fiasco/src/core/platform_thread.cc @@ -0,0 +1,153 @@ +/* + * \brief Fiasco thread facility + * \author Christian Helmuth + * \date 2006-04-11 + * + * This provides a thread object and uses l4_inter_task_ex_regs() for L4 thread + * manipulation. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +#include +} + +using namespace Genode; +using namespace Fiasco; + + +int Platform_thread::start(void *ip, void *sp) +{ + l4_umword_t dummy, old_eflags; + l4_threadid_t thread = _l4_thread_id; + l4_threadid_t pager = _pager ? _pager->cap().tid() : L4_INVALID_ID; + l4_threadid_t preempter = L4_INVALID_ID; + l4_threadid_t cap_handler = L4_INVALID_ID; + + l4_inter_task_ex_regs(thread, (l4_umword_t)ip, (l4_umword_t)sp, + &preempter, &pager, &cap_handler, + &old_eflags, &dummy, &dummy, + 0, l4_utcb_get()); + if (old_eflags == ~0UL) + PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread); + + fiasco_register_thread_name(thread, _name); + return 0; +} + + +void Platform_thread::pause() +{ + PDBG("not implemented"); +} + + +void Platform_thread::resume() +{ + PDBG("not implemented"); +} + + +void Platform_thread::bind(int thread_id, l4_threadid_t l4_thread_id, Platform_pd *pd) +{ + _thread_id = thread_id; + _l4_thread_id = l4_thread_id; + _platform_pd = pd; +} + + +void Platform_thread::unbind() +{ + l4_umword_t dummy, old_eflags; + l4_threadid_t thread = _l4_thread_id; + l4_threadid_t pager = thread; + l4_threadid_t preempter = L4_INVALID_ID; + l4_threadid_t cap_handler = L4_INVALID_ID; + + fiasco_register_thread_name(thread, ""); + + /* + * The Fiasco thread is halted by setting itself as pager and forcing + * pagefault at 0, where Genode never maps a page. The bottom line is the + * thread blocks in IPC to itself. + */ + l4_inter_task_ex_regs(thread, 0, 0, + &preempter, &pager, &cap_handler, + &old_eflags, &dummy, &dummy, + 0, l4_utcb_get()); + if (old_eflags == ~0UL) + PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread); + + _thread_id = THREAD_INVALID; + _l4_thread_id = L4_INVALID_ID; + _platform_pd = 0; +} + + +int Platform_thread::state(Thread_state *state_dst) +{ + l4_umword_t old_eflags, ip, sp; + l4_threadid_t thread = _l4_thread_id; + l4_threadid_t pager = L4_INVALID_ID; + l4_threadid_t preempter = L4_INVALID_ID; + l4_threadid_t cap_handler = L4_INVALID_ID; + + l4_inter_task_ex_regs(thread, ~0UL, ~0UL, + &preempter, &pager, &cap_handler, + &old_eflags, &ip, &sp, + L4_THREAD_EX_REGS_NO_CANCEL, l4_utcb_get()); + if (old_eflags == ~0UL) + PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread); + + /* fill thread state structure */ + state_dst->ip = ip; + state_dst->sp = sp; + + return 0; +} + + +void Platform_thread::cancel_blocking() +{ + l4_umword_t dummy; + l4_threadid_t invalid = L4_INVALID_ID; + + l4_inter_task_ex_regs(_l4_thread_id, ~0UL, ~0UL, + &invalid, &invalid, &invalid, + &dummy, &dummy, &dummy, 0, l4_utcb_get()); +} + + +Platform_thread::Platform_thread(const char *name, unsigned, int thread_id) +: _thread_id(thread_id), _l4_thread_id(L4_INVALID_ID), _pager(0) +{ + strncpy(_name, name, sizeof(_name)); +} + + +Platform_thread::~Platform_thread() +{ + /* + * We inform our protection domain about thread destruction, which will end up in + * Thread::unbind() + */ + if (_platform_pd) + _platform_pd->unbind_thread(this); +} diff --git a/base-fiasco/src/core/ram_session_support.cc b/base-fiasco/src/core/ram_session_support.cc new file mode 100644 index 000000000..9fe8d2c55 --- /dev/null +++ b/base-fiasco/src/core/ram_session_support.cc @@ -0,0 +1,27 @@ +/* + * \brief Export RAM dataspace as shared memory object (dummy) + * \author Norman Feske + * \date 2006-07-03 + * + * On L4, each dataspace _is_ a shared memory object. + * Therefore, these functions are empty. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include "ram_session_component.h" + +using namespace Genode; + +void Ram_session_component::_export_ram_ds(Dataspace_component *ds) { } +void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds) { } + +void Ram_session_component::_clear_ds(Dataspace_component *ds) +{ + memset((void *)ds->phys_addr(), 0, ds->size()); +} diff --git a/base-fiasco/src/core/rm_session_support.cc b/base-fiasco/src/core/rm_session_support.cc new file mode 100644 index 000000000..c2aa7f603 --- /dev/null +++ b/base-fiasco/src/core/rm_session_support.cc @@ -0,0 +1,48 @@ +/* + * \brief Fiasco-specific part of RM-session implementation + * \author Norman Feske + * \date 2009-04-10 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +} + +using namespace Genode; + +static const bool verbose_unmap = false; + + +void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size) +{ + /* + * Fiasco's 'unmap' syscall unmaps the specified flexpage from all address + * spaces to which we mapped the pages. We cannot target this operation to + * a specific L4 task. Hence, we unmap the dataspace from all tasks, not + * only for this RM client. + */ + if (verbose_unmap) { + Fiasco::l4_threadid_t tid; tid.raw = badge(); + printf("RM client %p (%x.%x) unmap core-local [%lx,%lx)\n", + this, tid.id.task, tid.id.lthread, core_local_base, core_local_base + size); + } + + using namespace Fiasco; + + addr_t addr = core_local_base; + for (; addr < core_local_base + size; addr += L4_PAGESIZE) + l4_fpage_unmap(l4_fpage(addr, L4_LOG2_PAGESIZE, 0, 0), + L4_FP_FLUSH_PAGE); +} diff --git a/base-fiasco/src/core/target.inc b/base-fiasco/src/core/target.inc new file mode 100644 index 000000000..16505825c --- /dev/null +++ b/base-fiasco/src/core/target.inc @@ -0,0 +1,51 @@ +TARGET = core +REQUIRES = fiasco +LIBS = cxx ipc heap core_printf process pager lock raw_signal raw_server + +GEN_CORE_DIR = $(BASE_DIR)/src/core + +SRC_CC = main.cc \ + multiboot_info.cc \ + ram_session_component.cc \ + ram_session_support.cc \ + rom_session_component.cc \ + cpu_session_component.cc \ + pd_session_component.cc \ + io_mem_session_component.cc \ + io_mem_session_support.cc \ + thread.cc \ + thread_start.cc \ + thread_bootstrap.cc \ + platform_thread.cc \ + platform_pd.cc \ + platform.cc \ + dataspace_component.cc \ + rm_session_component.cc \ + rm_session_support.cc \ + io_port_session_component.cc \ + irq_session_component.cc \ + signal_session_component.cc \ + signal_source_component.cc \ + dump_alloc.cc \ + context_area.cc + +INC_DIR += $(REP_DIR)/src/core/include \ + $(GEN_CORE_DIR)/include + +vpath main.cc $(GEN_CORE_DIR) +vpath multiboot_info.cc $(GEN_CORE_DIR) +vpath ram_session_component.cc $(GEN_CORE_DIR) +vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath cpu_session_component.cc $(GEN_CORE_DIR) +vpath pd_session_component.cc $(GEN_CORE_DIR) +vpath rm_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_support.cc $(GEN_CORE_DIR) +vpath signal_session_component.cc $(GEN_CORE_DIR) +vpath signal_source_component.cc $(GEN_CORE_DIR) +vpath dataspace_component.cc $(GEN_CORE_DIR) +vpath dump_alloc.cc $(GEN_CORE_DIR) +vpath context_area.cc $(GEN_CORE_DIR) +vpath thread_bootstrap.cc $(BASE_DIR)/src/base/thread +vpath thread.cc $(BASE_DIR)/src/base/thread +vpath %.cc $(REP_DIR)/src/core diff --git a/base-fiasco/src/core/thread_start.cc b/base-fiasco/src/core/thread_start.cc new file mode 100644 index 000000000..1041e5ecc --- /dev/null +++ b/base-fiasco/src/core/thread_start.cc @@ -0,0 +1,62 @@ +/* + * \brief Implementation of Thread API interface on top of Platform_thread + * \author Norman Feske + * \date 2006-05-03 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include +#include + +using namespace Genode; + + +void Thread_base::_thread_start() +{ + Thread_base::myself()->_thread_bootstrap(); + Thread_base::myself()->entry(); + sleep_forever(); +} + + +void Thread_base::start() +{ + /* create and start platform thread */ + _tid.pt = new(platform()->core_mem_alloc()) Platform_thread(_context->name); + + platform_specific()->core_pd()->bind_thread(_tid.pt); + + _tid.pt->pager(platform_specific()->core_pager()); + _tid.l4id = _tid.pt->native_thread_id(); + + _tid.pt->start((void *)_thread_start, _context->stack); +} + + +void Thread_base::cancel_blocking() +{ + /* + * Within core, we never need to unblock threads + */ +} + + +void Thread_base::_init_platform_thread() { } + + +void Thread_base::_deinit_platform_thread() +{ + /* destruct platform thread */ + destroy(platform()->core_mem_alloc(), _tid.pt); +} diff --git a/base-fiasco/src/core/x86/platform_x86.cc b/base-fiasco/src/core/x86/platform_x86.cc new file mode 100644 index 000000000..4b79db17b --- /dev/null +++ b/base-fiasco/src/core/x86/platform_x86.cc @@ -0,0 +1,52 @@ +/* + * \brief Platform support specific to x86 + * \author Christian Helmuth + * \date 2006-04-11 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +#include "platform.h" +#include "util.h" + +namespace Fiasco { +#include +} + +using namespace Genode; +using namespace Fiasco; + +void Platform::_setup_io_port_alloc() +{ + l4_fpage_t fp; + l4_umword_t dummy; + l4_msgdope_t result; + l4_msgtag_t tag; + + /* get all I/O ports at once */ + int error = l4_ipc_call_tag(Fiasco::sigma0_threadid, + L4_IPC_SHORT_MSG, + l4_iofpage(0, L4_WHOLE_IOADDRESS_SPACE, 0).fpage, 0, + l4_msgtag(L4_MSGTAG_IO_PAGE_FAULT, 0, 0, 0), + L4_IPC_IOMAPMSG(0, L4_WHOLE_IOADDRESS_SPACE), + &dummy, &fp.fpage, + L4_IPC_NEVER, &result, &tag); + + if (error || + !(l4_ipc_fpage_received(result) /* got something */ + && fp.iofp.f == 0xf /* got IO ports */ + && fp.iofp.iosize == L4_WHOLE_IOADDRESS_SPACE + && fp.iofp.iopage == 0)) /* got whole IO space */ + + panic("Received no I/O ports from sigma0"); + + /* setup allocator */ + _io_port_alloc.add_range(0, 0x10000); +} diff --git a/base-fiasco/src/core/x86/target.mk b/base-fiasco/src/core/x86/target.mk new file mode 100644 index 000000000..719b8306e --- /dev/null +++ b/base-fiasco/src/core/x86/target.mk @@ -0,0 +1,7 @@ +include $(PRG_DIR)/../target.inc + +REQUIRES += x86 +SRC_CC += platform_x86.cc + +vpath io_port_session_component.cc $(GEN_CORE_DIR)/x86 + diff --git a/base-fiasco/src/kernel/target.inc b/base-fiasco/src/kernel/target.inc new file mode 100644 index 000000000..b736792ff --- /dev/null +++ b/base-fiasco/src/kernel/target.inc @@ -0,0 +1,23 @@ +TARGET = fiasco +REQUIRES += fiasco +FIASCO_BUILD_DIR = $(BUILD_BASE_DIR)/kernel/$(TARGET) +FIASCO = $(FIASCO_BUILD_DIR)/fiasco +FIASCO_SRC = $(REP_DIR)/contrib/fiasco/snapshot/kernel/fiasco +STARTUP_LIB = + +$(TARGET): $(FIASCO) + +$(FIASCO_BUILD_DIR): + $(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \ + $(VERBOSE_DIR) -C $(FIASCO_SRC) BUILDDIR=$@ + $(VERBOSE)cp $(KERNEL_CONFIG) $@/globalconfig.out + $(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \ + $(VERBOSE_DIR) -C $@ oldconfig + +$(FIASCO): $(FIASCO_BUILD_DIR) + $(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \ + $(VERBOSE_DIR) -C $(FIASCO_BUILD_DIR) + $(VERBOSE)ln -sf $@ $(BUILD_BASE_DIR)/bin/$(TARGET) + +clean cleanall: + $(VERBOSE)rm -rf $(FIASCO_BUILD_DIR) diff --git a/base-fiasco/src/kernel/x86/target.mk b/base-fiasco/src/kernel/x86/target.mk new file mode 100644 index 000000000..8bf4175e6 --- /dev/null +++ b/base-fiasco/src/kernel/x86/target.mk @@ -0,0 +1,4 @@ +REQUIRES = x86 32bit +KERNEL_CONFIG = $(REP_DIR)/config/kernel-config.x86 + +-include $(PRG_DIR)/../target.inc diff --git a/base-fiasco/src/platform/_main_helper.h b/base-fiasco/src/platform/_main_helper.h new file mode 100644 index 000000000..6cfa9d232 --- /dev/null +++ b/base-fiasco/src/platform/_main_helper.h @@ -0,0 +1,19 @@ +/* + * \brief Platform-specific helper functions for the _main() function + * \author Christian Prochaska + * \date 2009-08-05 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _PLATFORM___MAIN_HELPER_H_ +#define _PLATFORM___MAIN_HELPER_H_ + +static void main_thread_bootstrap() { } + +#endif /* _PLATFORM___MAIN_HELPER_H_ */ diff --git a/base-fiasco/src/platform/arm/Makefile b/base-fiasco/src/platform/arm/Makefile new file mode 100644 index 000000000..adf975841 --- /dev/null +++ b/base-fiasco/src/platform/arm/Makefile @@ -0,0 +1,25 @@ +SRC = ../x86/genode.ld +TARGET = genode.ld + +all: + @echo "--- available targets ---" + @echo " genode.ld - generate $(TARGET) from $(SRC)" + @echo " cleanall - remove generated file" + +# +# NOTE: We change the start address to 0x60000, which +# is the same address as used by the original +# roottask. +# +# On L4x0, the thread ID type is only 32bit instead of 64bit +# for L4v2. Therefore, we have to adapt the place holder for +# thread ID part of the parent capability. +# +genode.ld: + cp $(SRC) $@ + sed -i "s/= 0x[0-9]\+;/= 0x00060000;/" $@ + sed -i "54s/^.*$$/\t\tLONG(0xffffffff);/" $@ + +clean cleanall: + rm -f $(TARGET) + diff --git a/base-fiasco/src/platform/arm/_main.cc b/base-fiasco/src/platform/arm/_main.cc new file mode 100644 index 000000000..8a9babe9e --- /dev/null +++ b/base-fiasco/src/platform/arm/_main.cc @@ -0,0 +1,124 @@ +/** + * \brief Startup code for Fiasco/ARM + * \author Norman Feske + * \date 2007-04-30 + * + * Call constructors for static objects before calling main(). + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +namespace Fiasco { +#include +} + +/* Genode */ +#include +#include +#include +#include + +namespace Genode { + + /** + * Return constructed parent capability + */ + Parent_capability parent_cap() + { + Fiasco::l4_threadid_t tid = *(Fiasco::l4_threadid_t *)&_parent_cap_thread_id; + return Parent_capability(Native_capability(tid, _parent_cap_local_name)); + } +} + +using namespace Genode; + + +/*************** + ** C++ stuff ** + ***************/ + +/* + * This symbol must be defined when exception + * headers are defined in the linker script. + */ +extern "C" __attribute__((weak)) void *__gxx_personality_v0(void) +{ + Fiasco::outstring("What a surprise! This function is really used? Sorry - not implemented\n"); + return 0; +} + + +/** + * Resolve symbols needed by libsupc++ to make + * the linker happy. + * + * FIXME: implement us! + */ +extern "C" __attribute__((weak)) int atexit(void) { + Fiasco::outstring("atexit() called - not implemented!\n"); + return 0; +}; +extern "C" __attribute__((weak)) int memcmp(void) { + Fiasco::outstring("memcmp() called - not implemented!\n"); + return 0; +}; +extern "C" __attribute__((weak)) int strncmp(void) { + Fiasco::outstring("strncmp() called - not implemented!\n"); + return 0; +}; + + +extern int main(int argc, char **argv); + +extern void init_exception_handling(); /* implemented in base/cxx */ + + +/* FIXME no support for commandline + * ask parent for argc and argv */ +static char argv0[] = { '_', 'm', 'a', 'i', 'n'}; +static char *argv[1] = { argv0 }; + + +/* + * Define 'environ' pointer that is supposed to be exported by + * the startup code and relied on by any libC. Because we have no + * UNIX environment, however, we set this pointer to NULL. + */ +__attribute__((weak)) char **environ = (char **)0; + + +/** + * C entry function called by the crt0 startup code + */ +extern "C" int _main() +{ + /* call constructors for static objects */ + void (**func)(); + for (func = &_ctors_end; func != &_ctors_start; (*--func)()); + + /* initialize exception handling */ + init_exception_handling(); + + /* completely map program image by touching all pages read-only */ + volatile const char *beg, *end; + beg = (const char *)(((unsigned)&_prog_img_beg) & L4_PAGEMASK); + end = (const char *)&_prog_img_end; + for ( ; beg < end; beg += L4_PAGESIZE) (void)(*beg); + + /* call real main function */ + /* XXX no support for commandline */ + int ret = main(1, argv); + + /* inform parent about program exit */ + env()->parent()->exit(ret); + + PDBG("main() returned %d", ret); + sleep_forever(); + + return ret; +} diff --git a/base-fiasco/src/platform/arm/crt0.s b/base-fiasco/src/platform/arm/crt0.s new file mode 100644 index 000000000..14b23c62a --- /dev/null +++ b/base-fiasco/src/platform/arm/crt0.s @@ -0,0 +1,37 @@ +/** + * \brief Startup code for Genode applications on ARM + * \author Norman Feske + * \date 2007-04-28 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/*--- .text (program code) -------------------------*/ + .text + + .globl _start +_start: + + ldr sp, .initial_sp + b _main + +.initial_sp: .word _stack_high + + .globl __dso_handle +__dso_handle: + .long 0 + +/*--- .bss (non-initialized data) ------------------*/ +.section ".bss" + + .globl _stack_low +_stack_low: + .space 64*1024 + .globl _stack_high +_stack_high: + diff --git a/base-fiasco/src/sigma0/target.mk b/base-fiasco/src/sigma0/target.mk new file mode 100644 index 000000000..b9c6271d9 --- /dev/null +++ b/base-fiasco/src/sigma0/target.mk @@ -0,0 +1,5 @@ +TARGET = sigma0 +PKGS = sigma0/server +LIBS = l4v2_support + +include $(REP_DIR)/mk/l4_pkg.mk diff --git a/base-foc/Makefile b/base-foc/Makefile new file mode 100644 index 000000000..24bdd778c --- /dev/null +++ b/base-foc/Makefile @@ -0,0 +1,98 @@ +# +# \brief Checkout Fiasco.OC and addtional needed tools (sigma0, bootstrap) +# \author Stefan Kalkowski +# \date 2011-03-31 +# + +VERBOSE ?= @ +ECHO = @echo +SVN_URI = http://svn.tudos.org/repos/oc/tudos/trunk +SVN_REV = 38 +CONTRIB_DIR = contrib +PATCHES = $(shell find patches -name *.patch) + +SVN_TARGETS = tools/preprocess \ + kernel/fiasco \ + l4/conf \ + l4/doc \ + l4/mk \ + l4/tool \ + l4/pkg/bootstrap \ + l4/pkg/cxx \ + l4/pkg/drivers-frst \ + l4/pkg/l4sys \ + l4/pkg/l4util \ + l4/pkg/ldscripts \ + l4/pkg/libsigma0 \ + l4/pkg/sigma0 \ + l4/pkg/uclibc-headers \ + l4/pkg/uclibc-minimal \ + l4/pkg/uclibc \ + l4/pkg/libvcpu + +# +# Print help information by default +# +help:: + +# realpath is there to follow symlink; if contrib dir does not exists yet, +# create new directory +REAL_CONTRIB_DIR := $(realpath $(CONTRIB_DIR)) +ifeq ($(REAL_CONTRIB_DIR),) +REAL_CONTRIB_DIR := $(CONTRIB_DIR) +endif + +prepare: $(REAL_CONTRIB_DIR)/.svn update_contrib_subdirs apply_patches + +help:: + $(ECHO) + $(ECHO) "Check out upstream source code of Fiasco.OC" + $(ECHO) + $(ECHO) "The source code will be located at the '$(CONTRIB_DIR)/' directory." + $(ECHO) + $(ECHO) "--- available commands ---" + $(ECHO) "prepare - checkout upstream source codes" + $(ECHO) "clean - remove upstream source codes" + $(ECHO) + +$(CONTRIB_DIR): + $(VERBOSE)mkdir -p $@ + +# use '.svn' subdirectory as rule to enable the use of a symbolic link as +# contrib directory +$(REAL_CONTRIB_DIR)/.svn: $(CONTRIB_DIR) + $(VERBOSE)svn co -r $(SVN_REV) --depth immediates $(SVN_URI) $(dir $@) + $(VERBOSE)svn co -r $(SVN_REV) --depth files $(SVN_URI)/l4 $(dir $@)/l4 + $(VERBOSE)svn co -r $(SVN_REV) --depth files $(SVN_URI)/l4/pkg $(dir $@)/l4/pkg + +# used phony to always update the SVN on 'make prepare' +# (before updating, we need to revert our custom patches) +update_contrib_subdirs: $(addprefix $(REAL_CONTRIB_DIR)/,$(SVN_TARGETS)) + $(ECHO) "updating . to revision $(SVN_REV)" + $(VERBOSE)svn revert $(REAL_CONTRIB_DIR) + $(VERBOSE)svn up -r $(SVN_REV) -N $(REAL_CONTRIB_DIR)/ + $(ECHO) "updating l4 to revision $(SVN_REV)" + $(VERBOSE)svn revert $(REAL_CONTRIB_DIR)/l4 + $(VERBOSE)svn up -r $(SVN_REV) -N $(REAL_CONTRIB_DIR)/l4 + $(ECHO) "updating l4/pkg to revision $(SVN_REV)" + $(VERBOSE)svn revert $(REAL_CONTRIB_DIR)/l4/pkg + $(VERBOSE)svn up -r $(SVN_REV) -N $(REAL_CONTRIB_DIR)/l4/pkg + $(VERBOSE)for i in $(SVN_TARGETS); do \ + echo "updating $$i to revision $(SVN_REV)"; \ + svn revert -R $(REAL_CONTRIB_DIR)/$$i; \ + svn up -r $(SVN_REV) $(REAL_CONTRIB_DIR)/$$i; done + +# for resolving the dependencies of 'update_contrib_subdirs' +$(REAL_CONTRIB_DIR)/%: + $(VERBOSE)svn up -r $(SVN_REV) $(SVN_URI)/$* $@ + +apply_patches: + $(ECHO) "applying patches to '$(REAL_CONTRIB_DIR)/'" + $(VERBOSE)for i in $(PATCHES); do \ + patch -N -d $(REAL_CONTRIB_DIR) -p0 < $$i; done + +# if $(CONTRIB_DIR) is a symlink, leave $(REAL_CONTRIB_DIR) alone +clean:: + $(VERBOSE)rm -rf $(CONTRIB_DIR) + +.NOTPARALLEL: diff --git a/base-foc/README b/base-foc/README new file mode 100644 index 000000000..53d39fd57 --- /dev/null +++ b/base-foc/README @@ -0,0 +1,9 @@ +This repository contains the port of Genode to the Fiasco.OC microkernel. +For further information, please refer to the following documents: + +:[http://genode.org/community/wiki/GenodeOnFiascoOC - Genode on Fiasco.OC Wiki page]: + This Wiki page contains the information on how to build and use + Genode with Fiasco.OC. + +:[http://os.inf.tu-dresden.de/fiasco]: + Official website for the Fiasco.OC microkernel. diff --git a/base-foc/config/pbxa9.kernel b/base-foc/config/pbxa9.kernel new file mode 100644 index 000000000..7568ff534 --- /dev/null +++ b/base-foc/config/pbxa9.kernel @@ -0,0 +1,83 @@ +# +# Automatically generated make config: don't edit +# Fiasco configuration +# + +# +# Target configuration +# +# CONFIG_IA32 is not set +# CONFIG_AMD64 is not set +CONFIG_ARM=y +CONFIG_PF_REALVIEW=y +# CONFIG_PF_IMX is not set +# CONFIG_PF_S3C2410 is not set +# CONFIG_PF_TEGRA2 is not set +# CONFIG_PF_OMAP is not set +# CONFIG_PF_SA1100 is not set +# CONFIG_PF_XSCALE is not set +# CONFIG_PF_KIRKWOOD is not set +# CONFIG_PF_INTEGRATOR is not set +CONFIG_BSP_NAME="realview" +# CONFIG_PF_REALVIEW_EB is not set +# CONFIG_PF_REALVIEW_PB11MP is not set +CONFIG_PF_REALVIEW_PBX=y +# CONFIG_PF_REALVIEW_VEXPRESS is not set +CONFIG_PF_REALVIEW_RAM_PHYS_BASE_0x0=y +# CONFIG_PF_REALVIEW_RAM_PHYS_BASE_0x2 is not set +# CONFIG_PF_REALVIEW_RAM_PHYS_BASE_0x7 is not set +CONFIG_PF_REALVIEW_RAM_PHYS_BASE=0x0 +CONFIG_ABI_VF=y +CONFIG_PF_ARM_MP_CAPABLE=y +CONFIG_CAN_ARM_CPU_CORTEX_A9=y +CONFIG_CAN_ARM_CACHE_L2CXX0=y +CONFIG_ARM_CORTEX_A9=y +# CONFIG_ARM_ALIGNMENT_CHECK is not set +# CONFIG_ARM_CA9_ENABLE_SWP is not set +CONFIG_ARM_CACHE_L2CXX0=y +CONFIG_FPU=y + +# +# Kernel options +# +CONFIG_CONTEXT_4K=y +# CONFIG_FINE_GRAINED_CPUTIME is not set +CONFIG_SCHED_FIXED_PRIO=y + +# +# Debugging +# +# CONFIG_INLINE is not set +# CONFIG_NDEBUG is not set +CONFIG_NO_FRAME_PTR=y +# CONFIG_STACK_DEPTH is not set +# CONFIG_LIST_ALLOC_SANITY is not set +CONFIG_SERIAL=y +CONFIG_JDB=y +CONFIG_JDB_LOGGING=y +CONFIG_JDB_DISASM=y +# CONFIG_JDB_GZIP is not set +# CONFIG_VMEM_ALLOC_TEST is not set +# CONFIG_DEBUG_KERNEL_PAGE_FAULTS is not set +# CONFIG_WARN_NONE is not set +CONFIG_WARN_WARNING=y +# CONFIG_WARN_ANY is not set + +# +# Compiling +# +CONFIG_CC="gcc" +CONFIG_CXX="g++" +CONFIG_HOST_CC="gcc" +CONFIG_HOST_CXX="g++" +# CONFIG_VERBOSE is not set +# CONFIG_MAINTAINER_MODE is not set +CONFIG_LABEL="" +# CONFIG_EXPERIMENTAL is not set +CONFIG_PERF_CNT=y +CONFIG_BIT32=y +CONFIG_ARM_V7=y +CONFIG_ARM_V6PLUS=y +CONFIG_WARN_LEVEL=1 +CONFIG_XARCH="arm" +CONFIG_ABI="vf" diff --git a/base-foc/config/rva9.user b/base-foc/config/rva9.user new file mode 100644 index 000000000..73704f9b2 --- /dev/null +++ b/base-foc/config/rva9.user @@ -0,0 +1,64 @@ +# +# Automatically generated make config: don't edit +# L4Re Configuration +# Thu Jul 14 16:26:37 2011 +# +# CONFIG_BUILD_ARCH_x86 is not set +# CONFIG_BUILD_ARCH_amd64 is not set +CONFIG_BUILD_ARCH_arm=y +# CONFIG_BUILD_ARCH_ppc32 is not set +# CONFIG_BUILD_ARCH_sparc is not set +CONFIG_BUILD_ARCH="arm" +CONFIG_BUILD_ABI_l4f=y +CONFIG_BUILD_ABI="l4f" +CONFIG_CPU="armv7a" +# CONFIG_CPU_ARM_ARMV4 is not set +# CONFIG_CPU_ARM_ARMV4T is not set +# CONFIG_CPU_ARM_ARMV5 is not set +# CONFIG_CPU_ARM_ARMV5T is not set +# CONFIG_CPU_ARM_ARMV5TE is not set +# CONFIG_CPU_ARM_ARMV6 is not set +# CONFIG_CPU_ARM_ARMV6T2 is not set +# CONFIG_CPU_ARM_ARMV6ZK is not set +CONFIG_CPU_ARM_ARMV7A=y +# CONFIG_CPU_ARM_ARMV7R is not set +CONFIG_CPU_ARMV6KPLUS=y +CONFIG_CPU_ARMV6PLUS=y + +# +# Platform +# +# CONFIG_PLATFORM_ARM_integrator is not set +CONFIG_PLATFORM_ARM_rv=y +# CONFIG_PLATFORM_ARM_imx21 is not set +# CONFIG_PLATFORM_ARM_imx51 is not set +# CONFIG_PLATFORM_ARM_omap3evm is not set +# CONFIG_PLATFORM_ARM_beagleboard is not set +# CONFIG_PLATFORM_ARM_pandaboard is not set +# CONFIG_PLATFORM_ARM_tegra2 is not set +# CONFIG_PLATFORM_ARM_custom is not set +CONFIG_ARM_PLATFORM_TYPE="rv" +CONFIG_RAM_BASE=0x0 +CONFIG_RAM_SIZE_MB=256 +# CONFIG_USE_DROPS_STDDIR is not set +# CONFIG_USE_DICE is not set +CONFIG_DROPS_STDDIR="/path/to/l4re" +CONFIG_DROPS_INSTDIR="/path/to/l4re" +CONFIG_BID_COLORED_PHASES=y + +# +# Building +# +CONFIG_YACC="yacc" +CONFIG_LEX="flex" +CONFIG_CTAGS="ctags" +CONFIG_ETAGS="etags" +CONFIG_HAVE_LDSO=y +CONFIG_INT_CPP_NAME_SWITCH=y +CONFIG_INT_LD_NAME_SWITCH=y +# CONFIG_BID_STRIP_PROGS is not set +# CONFIG_BID_GCC_OMIT_FP is not set +# CONFIG_BID_GENERATE_MAPFILE is not set +# CONFIG_BID_BUILD_DOC is not set +# CONFIG_RELEASE_MODE is not set +CONFIG_LABEL="" diff --git a/base-foc/config/vea9x4.kernel b/base-foc/config/vea9x4.kernel new file mode 100644 index 000000000..630a9ab8b --- /dev/null +++ b/base-foc/config/vea9x4.kernel @@ -0,0 +1,85 @@ +# +# Automatically generated make config: don't edit +# Fiasco configuration +# + +# +# Target configuration +# +# CONFIG_IA32 is not set +# CONFIG_AMD64 is not set +CONFIG_ARM=y +CONFIG_PF_REALVIEW=y +# CONFIG_PF_IMX is not set +# CONFIG_PF_S3C2410 is not set +# CONFIG_PF_TEGRA2 is not set +# CONFIG_PF_OMAP is not set +# CONFIG_PF_SA1100 is not set +# CONFIG_PF_XSCALE is not set +# CONFIG_PF_KIRKWOOD is not set +# CONFIG_PF_INTEGRATOR is not set +CONFIG_BSP_NAME="realview" +# CONFIG_PF_REALVIEW_EB is not set +# CONFIG_PF_REALVIEW_PB11MP is not set +# CONFIG_PF_REALVIEW_PBX is not set +CONFIG_PF_REALVIEW_VEXPRESS=y +CONFIG_PF_REALVIEW_RAM_PHYS_BASE_0x0=y +# CONFIG_PF_REALVIEW_RAM_PHYS_BASE_0x6 is not set +CONFIG_PF_REALVIEW_RAM_PHYS_BASE=0x0 +CONFIG_ABI_VF=y +CONFIG_PF_ARM_MP_CAPABLE=y +CONFIG_CAN_ARM_CPU_CORTEX_A9=y +CONFIG_ARM_CORTEX_A9=y +# CONFIG_ARM_ALIGNMENT_CHECK is not set +# CONFIG_ARM_TZ is not set +# CONFIG_ARM_CA9_ENABLE_SWP is not set +CONFIG_FPU=y + +# +# Kernel options +# +# CONFIG_MP is not set +CONFIG_CONTEXT_4K=y +# CONFIG_FINE_GRAINED_CPUTIME is not set +CONFIG_SCHED_FIXED_PRIO=y +# CONFIG_SCHED_WFQ is not set +# CONFIG_SCHED_FP_WFQ is not set +# CONFIG_DISABLE_VIRT_OBJ_SPACE is not set + +# +# Debugging +# +# CONFIG_INLINE is not set +# CONFIG_NDEBUG is not set +CONFIG_NO_FRAME_PTR=y +# CONFIG_STACK_DEPTH is not set +# CONFIG_LIST_ALLOC_SANITY is not set +CONFIG_SERIAL=y +CONFIG_JDB=y +CONFIG_JDB_LOGGING=y +CONFIG_JDB_DISASM=y +# CONFIG_JDB_GZIP is not set +# CONFIG_VMEM_ALLOC_TEST is not set +# CONFIG_DEBUG_KERNEL_PAGE_FAULTS is not set +# CONFIG_WARN_NONE is not set +CONFIG_WARN_WARNING=y +# CONFIG_WARN_ANY is not set + +# +# Compiling +# +CONFIG_CC="gcc" +CONFIG_CXX="g++" +CONFIG_HOST_CC="gcc" +CONFIG_HOST_CXX="g++" +# CONFIG_VERBOSE is not set +# CONFIG_MAINTAINER_MODE is not set +CONFIG_LABEL="" +CONFIG_EXPERIMENTAL=y +CONFIG_PERF_CNT=y +CONFIG_BIT32=y +CONFIG_ARM_V7=y +CONFIG_ARM_V6PLUS=y +CONFIG_WARN_LEVEL=1 +CONFIG_XARCH="arm" +CONFIG_ABI="vf" diff --git a/base-foc/config/x86_32.kernel b/base-foc/config/x86_32.kernel new file mode 100644 index 000000000..36f9c530e --- /dev/null +++ b/base-foc/config/x86_32.kernel @@ -0,0 +1,87 @@ +# +# Automatically generated make config: don't edit +# Fiasco configuration +# Wed Sep 14 14:33:24 2011 +# + +# +# Target configuration +# +CONFIG_IA32=y +# CONFIG_AMD64 is not set +# CONFIG_ARM is not set +CONFIG_PF_PC=y +# CONFIG_PF_UX is not set +CONFIG_ABI_VF=y +# CONFIG_IA32_486 is not set +CONFIG_IA32_586=y +# CONFIG_IA32_686 is not set +# CONFIG_IA32_P2 is not set +# CONFIG_IA32_P3 is not set +# CONFIG_IA32_P4 is not set +# CONFIG_IA32_PM is not set +# CONFIG_IA32_CORE2 is not set +# CONFIG_IA32_ATOM is not set +# CONFIG_IA32_K6 is not set +# CONFIG_IA32_K7 is not set +# CONFIG_IA32_K8 is not set +# CONFIG_IA32_K10 is not set +# CONFIG_CPU_VIRT is not set +CONFIG_SCHED_PIT=y +# CONFIG_SCHED_RTC is not set +# CONFIG_SCHED_APIC is not set +# CONFIG_WORKAROUND_AMD_FPU_LEAK is not set +CONFIG_REGPARM3=y + +# +# Kernel options +# +CONFIG_CONTEXT_4K=y +CONFIG_IO_PROT=y +# CONFIG_IO_PROT_IOPL_3 is not set +# CONFIG_SYNC_TSC is not set +# CONFIG_FINE_GRAINED_CPUTIME is not set +CONFIG_SCHED_FIXED_PRIO=y + +# +# Debugging +# +CONFIG_INLINE=y +# CONFIG_NDEBUG is not set +# CONFIG_NO_FRAME_PTR is not set +# CONFIG_STACK_DEPTH is not set +# CONFIG_ALLOW_RO_TEXT is not set +# CONFIG_LIST_ALLOC_SANITY is not set +# CONFIG_BEFORE_IRET_SANITY is not set +# CONFIG_IRQ_SPINNER is not set +CONFIG_WATCHDOG=y +CONFIG_SERIAL=y +CONFIG_JDB=y +# CONFIG_JDB_LOGGING is not set +CONFIG_JDB_DISASM=y +CONFIG_JDB_GZIP=y +# CONFIG_JDB_ACCOUNTING is not set +# CONFIG_JDB_MISC is not set +CONFIG_POWERSAVE_GETCHAR=y +CONFIG_USER_SINGLE_STEP=y +# CONFIG_WARN_NONE is not set +CONFIG_WARN_WARNING=y +# CONFIG_WARN_ANY is not set + +# +# Compiling +# +CONFIG_CC="gcc" +CONFIG_CXX="g++" +CONFIG_HOST_CC="gcc" +CONFIG_HOST_CXX="g++" +# CONFIG_VERBOSE is not set +# CONFIG_MAINTAINER_MODE is not set +CONFIG_LABEL="" +# CONFIG_EXPERIMENTAL is not set +CONFIG_PERF_CNT=y +CONFIG_BIT32=y +CONFIG_WARN_LEVEL=1 +CONFIG_XARCH="ia32" +CONFIG_IA32_TARGET="Intel Pentium" +CONFIG_ABI="vf" diff --git a/base-foc/config/x86_64.kernel b/base-foc/config/x86_64.kernel new file mode 100644 index 000000000..76a2390fc --- /dev/null +++ b/base-foc/config/x86_64.kernel @@ -0,0 +1,73 @@ +# +# Automatically generated make config: don't edit +# Fiasco configuration +# + +# +# Target configuration +# +# CONFIG_IA32 is not set +CONFIG_AMD64=y +# CONFIG_ARM is not set +CONFIG_PF_PC=y +CONFIG_ABI_VF=y +CONFIG_AMD64_K8=y +# CONFIG_AMD64_CORE2 is not set +# CONFIG_AMD64_ATOM is not set +# CONFIG_AMD64_K10 is not set +# CONFIG_CPU_VIRT is not set +# CONFIG_SCHED_PIT is not set +# CONFIG_SCHED_RTC is not set +CONFIG_SCHED_APIC=y +# CONFIG_SCHED_HPET is not set +# CONFIG_WORKAROUND_AMD_FPU_LEAK is not set + +# +# Kernel options +# +CONFIG_CONTEXT_4K=y +CONFIG_IO_PROT=y +# CONFIG_IO_PROT_IOPL_3 is not set +# CONFIG_FINE_GRAINED_CPUTIME is not set +CONFIG_SCHED_FIXED_PRIO=y + +# +# Debugging +# +CONFIG_INLINE=y +# CONFIG_NDEBUG is not set +CONFIG_NO_FRAME_PTR=y +CONFIG_STACK_DEPTH=y +# CONFIG_ALLOW_RO_TEXT is not set +# CONFIG_LIST_ALLOC_SANITY is not set +# CONFIG_BEFORE_IRET_SANITY is not set +# CONFIG_IRQ_SPINNER is not set +CONFIG_WATCHDOG=y +CONFIG_SERIAL=y +CONFIG_JDB=y +CONFIG_JDB_LOGGING=y +CONFIG_JDB_DISASM=y +CONFIG_JDB_GZIP=y +CONFIG_JDB_MISC=y +CONFIG_POWERSAVE_GETCHAR=y +# CONFIG_WARN_NONE is not set +CONFIG_WARN_WARNING=y +# CONFIG_WARN_ANY is not set + +# +# Compiling +# +CONFIG_CC="gcc" +CONFIG_CXX="g++" +CONFIG_HOST_CC="gcc" +CONFIG_HOST_CXX="g++" +# CONFIG_VERBOSE is not set +# CONFIG_MAINTAINER_MODE is not set +CONFIG_LABEL="" +# CONFIG_EXPERIMENTAL is not set +CONFIG_PERF_CNT=y +CONFIG_BIT64=y +CONFIG_WARN_LEVEL=1 +CONFIG_XARCH="amd64" +CONFIG_IA32_TARGET="AMD Opteron" +CONFIG_ABI="vf" diff --git a/base-foc/doc/foc.txt b/base-foc/doc/foc.txt new file mode 100644 index 000000000..3771f3cef --- /dev/null +++ b/base-foc/doc/foc.txt @@ -0,0 +1,142 @@ + + =================================== + Genode on the Fiasco.OC microkernel + =================================== + + + Stefan Kalkowski + + +Fiasco.OC is a microkernel developed by the OS group of the TU-Dresden. It's +an object-oriented capability-based system for x86, ARM and PowerPC platforms. + +This document provides brief instructions about downloading, building and +booting the Fiasco.OC version of Genode. + + +Prerequisites +############# + +You need certain tools to use the Fiasco.OC build system. On Debian/Ubuntu +systems you have to install the following packages: + +! apt-get install make gawk pkg-config subversion patch + +Moreover, you need to download and install the tool-chain used by Genode. Have +a look at this page: + +:[http://genode.org/download/tool-chain]: + Genode tool-chain + +If you want to use the so called run-scripts in Genode, a mechanism that +automates building, integration and testing of components, you have to install +the following, additional package: + +! apt-get install expect + + +Building the Fiasco.OC version of Genode +######################################## + +The current version of Genode is available at the public subversion repository: + +:http://genode.org/download/subversion-repository: + Information about accessing the Genode public subversion repository + +After you've fetched the Genode source tree from the subversion repository, or +downloaded the latest release tar archive, you need the Fiasco.OC source code, +its kernel-bindings, additional bootstrap tools etc. To simplify that step, +you can use a Makefile in the 'base-foc' directory of the Genode source tree, +just do: + +! cd base-foc +! make prepare + +This will install all necessary third-party source code in the 'contrib' folder. + +Now, go to a directory where you want the Genode/Fiasco.OC build directory to +remain. Use the helper script in the 'tool' directory of the Genode +source tree to create the initial build environment. You need to state the +build directory you want to create, and the hardware architecture to run +Fiasco.OC/Genode on. Choose 'foc_x86_32', 'foc_x86_64', or 'foc_pbxa9' +depending on whether you want to build for the 32-bit or 64-bit X86 +architecture, or for ARMs Cortex-A9. + +! /tool/create_builddir foc_x86_32 \ +! BUILD_DIR= + +Now, go to the newly created build directory and type make: + +! cd +! make + +This will build the Fiasco.OC kernel, its bootstrap code, and every Genode component, +that runs on top of Fiasco.OC. + +If you just want to give Genode/Fiasco.OC a try, you can call e.g.: the demo run-script +instead of building everything: + +! cd +! make run/demo + + +Running L4Linux on top of Genode +################################ + +To get the L4Linux running on top of Genode, you have to change to the +'ports-foc' repository within your Genode source tree and do a 'make prepare': + +! cd ports-foc +! make prepare + +This will fetch the currently supported version from the L4Linux subversion +repository, and apply a patch to it, that is needed to execute it on top of +Genode. + +Before compiling L4Linux for Genode/Fiasco.OC you have to integrate the 'ports-foc' +repository into your build environment. Therefore edit the 'etc/build.conf' file +in your build directory, and uncomment the following line: + +! REPOSITORIES += $(GENODE_DIR)/ports-foc + +After that you can build and run L4Linux by issuing: + +! make run/l4linux + +in your build directory. This run-script boots a single L4Linux instance into +a minimal console environment. The script depends on an 'initrd.gz' archive, +which has to reside in 'bin' in your build directory. You can find an example +initramfs here: + +:[http://genode.org/files/release-11.05/l4lx/x86/initrd.gz]: + Initramfs archive for X86 + +:[http://genode.org/files/release-11.05/l4lx/arm/initrd.gz]: + Initramfs archive for ARM + + +Integration of Fiasco.OC with Genode +#################################### + +If you don't want the Genode build system to build the Fiasco.OC kernel for +you, but you want to provide your own version, you have to state in the +'etc/foc.conf' file within your build directory, where to find it: + +! L4_BUILD_DIR = +! KERNEL = + +The first variable states where to find the kernel bindings (the L4RE build +directory), the second one states where your kernel binary can be found. +After adding these variable to the file, you have to do a full cleanup +in your build directory to ensure, that the right bindings are used: + +! make cleanall + +From now on, run-scripts will use your provided kernel. + + +Further Information +################### + +:[http://os.inf.tu-dresden.de/fiasco]: + Official website for the Fiasco.OC microkernel. diff --git a/base-foc/etc/foc.conf b/base-foc/etc/foc.conf new file mode 100644 index 000000000..46c90d33e --- /dev/null +++ b/base-foc/etc/foc.conf @@ -0,0 +1,20 @@ +# +# Fiasco.OC-specific default configuration options +# + +# +# Directory, where to search for L4 headers +# +# When using this file as template for a customized +# '/etc/kernel.conf'. +# +#L4_BUILD_DIR = $(HOME)/src/l4build.x86 + +# +# Path to the Fiasco.OC kernel +# +# When using this file as template for a customized +# '/etc/kernel.conf'. +# +#KERNEL = $(HOME)/src/fiasco-build.x86/fiasco + diff --git a/base-foc/etc/specs.conf b/base-foc/etc/specs.conf new file mode 100644 index 000000000..81779dc15 --- /dev/null +++ b/base-foc/etc/specs.conf @@ -0,0 +1,8 @@ +# +# Description of build platform +# + +# +# By default, build Fiasco.OC binaries for ia32. +# +SPECS ?= genode foc_x86_32 diff --git a/base-foc/include/arm/cpu/atomic.h b/base-foc/include/arm/cpu/atomic.h new file mode 100644 index 000000000..c87c79575 --- /dev/null +++ b/base-foc/include/arm/cpu/atomic.h @@ -0,0 +1,54 @@ +/* + * \brief Atomic operations for ARM + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2007-04-28 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__ARM__CPU__ATOMIC_H_ +#define _INCLUDE__ARM__CPU__ATOMIC_H_ + +namespace Genode { + + /** + * Atomic compare and exchange + * + * This function compares the value at dest with cmp_val. + * If both values are equal, dest is set to new_val. If + * both values are different, the value at dest remains + * unchanged. + * + * \return 1 if the value was successfully changed to new_val, + * 0 if cmp_val and the value at dest differ. + */ + inline int cmpxchg(volatile int *dest, int cmp_val, int new_val) + { + unsigned long equal, not_exclusive; + + __asm__ __volatile__( + "@ cmpxchg\n" + " 1: \n" + " ldrex %0, [%2] \n" + " cmp %0, %3 \n" + " bne 2f \n" + " strexeq %0, %4, [%2]\n" + " teqeq %0, #0 \n" + " bne 1b \n" + " moveq %1, #1 \n" + " 2: \n" + " movne %1, #0 \n" + : "=&r" (not_exclusive), "=&r" (equal) + : "r" (dest), "r" (cmp_val), "r" (new_val) + : "cc"); + return equal && !not_exclusive; + } +} + +#endif /* _INCLUDE__ARM__CPU__ATOMIC_H_ */ diff --git a/base-foc/include/base/cap_sel_alloc.h b/base-foc/include/base/cap_sel_alloc.h new file mode 100644 index 000000000..a39ea2157 --- /dev/null +++ b/base-foc/include/base/cap_sel_alloc.h @@ -0,0 +1,68 @@ +/* + * \brief Interface for process-local capability-selector allocation + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2010-01-19 + * + * This interface is Fiasco-specific and not part of the Genode API. It should + * only be used internally by the framework or by Fiasco-specific code. The + * implementation of the interface is part of the environment library. + * + * This implementation is borrowed by the nova-platform equivalent. + * (TODO: merge it) + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__CAP_SEL_ALLOC_H_ +#define _INCLUDE__BASE__CAP_SEL_ALLOC_H_ + +#include + +namespace Genode +{ + class Capability_allocator + { + private: + + addr_t _cap_idx; + + /** + * Constructor + */ + Capability_allocator(); + + public: + + /** + * Return singleton instance of 'Capability_allocator' + */ + static Capability_allocator* allocator(); + + /** + * Allocate range of capability selectors + * + * \param num_caps_log2 number of capability selectors. By default, + * the function returns a single capability selector. + * \return first capability selector of allocated range, + * or 0 if allocation failed + */ + addr_t alloc(size_t num_caps = 1); + + /** + * Release range of capability selectors + * + * \param cap first capability selector of range + * \param num_caps_log2 number of capability selectors to free. + */ + void free(addr_t cap, size_t num_caps = 1); + }; +} + +#endif /* _INCLUDE__BASE__CAP_SEL_ALLOC_H_ */ + diff --git a/base-foc/include/base/ipc.h b/base-foc/include/base/ipc.h new file mode 100644 index 000000000..938eb00c5 --- /dev/null +++ b/base-foc/include/base/ipc.h @@ -0,0 +1,56 @@ +/* + * \brief Fiasco.OC-specific supplements to the IPC framework + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2010-01-27 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_H_ +#define _INCLUDE__BASE__IPC_H_ + +#include + +namespace Fiasco { +#include +#include +#include +} + +inline void Genode::Ipc_ostream::_marshal_capability(Genode::Native_capability const &cap) +{ + long unique_id = cap.local_name(); + _write_to_buf(unique_id); + if (unique_id) + _snd_msg->snd_append_cap_sel(cap.dst()); +} + + +inline void Genode::Ipc_istream::_unmarshal_capability(Genode::Native_capability &cap) +{ + using namespace Fiasco; + + /* extract Genode internal capability label from message buffer */ + long unique_id = 0; + _read_from_buf(unique_id); + + if (!unique_id) { + cap = Native_capability(); + return; + } + + /* allocate new cap slot and grant cap to it out of receive window */ + Genode::addr_t cap_sel = Capability_allocator::allocator()->alloc(); + l4_task_map(L4_BASE_TASK_CAP, L4_BASE_TASK_CAP, + l4_obj_fpage(_rcv_msg->rcv_cap_sel(), 0, L4_FPAGE_RWX), + cap_sel | L4_ITEM_MAP | L4_MAP_ITEM_GRANT); + cap = Native_capability(cap_sel, unique_id); +} + +#endif /* _INCLUDE__BASE__IPC_H_ */ diff --git a/base-foc/include/base/ipc_msgbuf.h b/base-foc/include/base/ipc_msgbuf.h new file mode 100644 index 000000000..4a2d00055 --- /dev/null +++ b/base-foc/include/base/ipc_msgbuf.h @@ -0,0 +1,152 @@ +/* + * \brief IPC message buffer layout for Fiasco.OC + * \author Stefan Kalkowski + * \date 2010-11-30 + * + * On Fiasco.OC, IPC is used to transmit plain data and capabilities. + * Therefore the message buffer contains both categories of payload. + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_ +#define _INCLUDE__BASE__IPC_MSGBUF_H_ + +/* Genode includes */ +#include + +/* Fiasco.OC includes */ +namespace Fiasco { +#include +#include +} + +namespace Genode { + + class Msgbuf_base + { + public: + + enum { MAX_CAP_ARGS_LOG2 = 2, MAX_CAP_ARGS = 1 << MAX_CAP_ARGS_LOG2 }; + + protected: + + size_t _size; + + /** + * Number of capability selectors to send. + */ + size_t _snd_cap_sel_cnt; + + /** + * Capability selectors to delegate. + */ + addr_t _snd_cap_sel[MAX_CAP_ARGS]; + + /** + * Base of capability receive window. + */ + addr_t _rcv_cap_sel_base; + + /** + * Read counter for unmarshalling portal capability selectors + */ + addr_t _rcv_cap_sel_cnt; + + char _msg_start[]; /* symbol marks start of message */ + + public: + + /** + * Constructor + */ + Msgbuf_base() + : _rcv_cap_sel_base(Capability_allocator::allocator()->alloc(MAX_CAP_ARGS)) + { + rcv_reset(); + snd_reset(); + } + + /* + * Begin of actual message buffer + */ + char buf[]; + + /** + * Return size of message buffer + */ + inline size_t size() const { return _size; }; + + /** + * Return address of message buffer + */ + inline void *addr() { return &_msg_start[0]; }; + + /** + * Reset portal capability selector payload + */ + inline void snd_reset() { _snd_cap_sel_cnt = 0; } + + /** + * Append capability selector to message buffer + */ + inline bool snd_append_cap_sel(addr_t cap_sel) + { + if (_snd_cap_sel_cnt >= MAX_CAP_ARGS) + return false; + + _snd_cap_sel[_snd_cap_sel_cnt++] = cap_sel; + return true; + } + + /** + * Return number of marshalled capability selectors + */ + inline size_t snd_cap_sel_cnt() { return _snd_cap_sel_cnt; } + + /** + * Return capability selector to send. + * + * \param i index (0 ... 'snd_cap_sel_cnt()' - 1) + * \return capability selector, or 0 if index is invalid + */ + addr_t snd_cap_sel(unsigned i) { + return i < _snd_cap_sel_cnt ? _snd_cap_sel[i] : 0; } + + /** + * Return address of capability receive window. + */ + addr_t rcv_cap_sel_base() { return _rcv_cap_sel_base; } + + /** + * Reset capability receive window + */ + void rcv_reset() { _rcv_cap_sel_cnt = 0; } + + /** + * Return next received capability selector. + * + * \return capability selector, or 0 if index is invalid + */ + addr_t rcv_cap_sel() { + return _rcv_cap_sel_base + _rcv_cap_sel_cnt++ * Fiasco::L4_CAP_SIZE; } + }; + + + template + class Msgbuf : public Msgbuf_base + { + public: + + char buf[BUF_SIZE]; + + Msgbuf() { _size = BUF_SIZE; } + }; +} + +#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */ diff --git a/base-foc/include/base/ipc_pager.h b/base-foc/include/base/ipc_pager.h new file mode 100644 index 000000000..a5084d85d --- /dev/null +++ b/base-foc/include/base/ipc_pager.h @@ -0,0 +1,200 @@ +/* + * \brief Fiasco.OC pager support + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-06-14 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_PAGER_H_ +#define _INCLUDE__BASE__IPC_PAGER_H_ + +/* Genode includes */ +#include +#include +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +namespace Genode { + + class Mapping + { + private: + + addr_t _dst_addr; + addr_t _src_addr; + bool _write_combined; + unsigned _log2size; + bool _rw; + bool _grant; + + public: + + /** + * Constructor + */ + Mapping(addr_t dst_addr, addr_t src_addr, + bool write_combined, unsigned l2size = L4_LOG2_PAGESIZE, + bool rw = true, bool grant = false) + : _dst_addr(dst_addr), _src_addr(src_addr), + _write_combined(write_combined), _log2size(l2size), + _rw(rw), _grant(grant) { } + + /** + * Construct invalid flexpage + */ + Mapping() : _dst_addr(0), _src_addr(0), _write_combined(false), + _log2size(0), _rw(false), _grant(false) { } + + Fiasco::l4_umword_t dst_addr() const { return _dst_addr; } + bool grant() const { return _grant; } + + Fiasco::l4_fpage_t fpage() const + { + // TODO: write combined + //if (write_combined) + // _fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE; + + unsigned char rights = _rw ? Fiasco::L4_FPAGE_RW : Fiasco::L4_FPAGE_RO; + return Fiasco::l4_fpage(_src_addr, _log2size, rights); + } + + /** + * Prepare map operation + * + * On Fiasco, we need to map a page locally to be able to map it to + * another address space. + */ + void prepare_map_operation() + { + size_t mapping_size = 1 << _log2size; + for (addr_t i = 0; i < mapping_size; i += L4_PAGESIZE) { + if (_rw) + touch_read_write((unsigned char volatile *)(_src_addr + i)); + else + touch_read((unsigned char const volatile *)(_src_addr + i)); + } + } + }; + + + /** + * Special paging server class + */ + class Ipc_pager : public Native_capability + { + public: + + enum Msg_type { PAGEFAULT, WAKE_UP, PAUSE, EXCEPTION }; + + private: + + Native_thread _last; /* origin of last fault */ + addr_t _pf_addr; /* page-fault address */ + addr_t _pf_ip; /* ip of faulter */ + Mapping _reply_mapping; /* page-fault answer */ + unsigned long _badge; /* badge of faulting thread */ + Fiasco::l4_msgtag_t _tag; /* receive message tag */ + Fiasco::l4_exc_regs_t _regs; /* exception registers */ + Msg_type _type; + + void _parse_msg_type(void); + void _parse_exception(void); + void _parse_pagefault(void); + void _parse(unsigned long label); + + public: + + /** + * Constructor + */ + Ipc_pager(); + + /** + * Wait for a new page fault received as short message IPC + */ + void wait_for_fault(); + + /** + * Reply current page-fault and wait for a new one + * + * Send short flex page and wait for next short-message (register) + * IPC -- pagefault + */ + void reply_and_wait_for_fault(); + + /** + * Request instruction pointer of current page fault + */ + addr_t fault_ip() { return _pf_ip; } + + /** + * Request fault address of current page fault + */ + addr_t fault_addr() { return _pf_addr & ~3; } + + /** + * Set parameters for next reply + */ + void set_reply_mapping(Mapping m) { _reply_mapping = m; } + + /** + * Set destination for next reply + */ + void set_reply_dst(Native_capability pager_object) { + _last = pager_object.dst(); } + + /** + * Answer call without sending a flex-page mapping + * + * This function is used to acknowledge local calls from one of + * core's region-manager sessions. + */ + void acknowledge_wakeup(); + + /** + * Return thread ID of last faulter + */ + Native_thread last() const { return _last; } + + /** + * Return badge for faulting thread + */ + unsigned long badge() { return _badge; } + + bool is_write_fault() const { return (_pf_addr & 2); } + + /** + * Return true if last fault was an exception + */ + bool is_exception() const + { + return _type == Ipc_pager::EXCEPTION; + } + + /** + * Return the type of ipc we received at last. + */ + Msg_type msg_type() { return _type; }; + + /** + * Copy the exception registers from the last exception + * to the given thread_state object. + */ + void copy_regs(Thread_state *state); + }; +} + +#endif /* _INCLUDE__BASE__IPC_PAGER_H_ */ diff --git a/base-foc/include/base/native_types.h b/base-foc/include/base/native_types.h new file mode 100644 index 000000000..fcfe1d33d --- /dev/null +++ b/base-foc/include/base/native_types.h @@ -0,0 +1,87 @@ +#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ +#define _INCLUDE__BASE__NATIVE_TYPES_H_ + +namespace Fiasco { +#include +#include +#include + + class Fiasco_capability + { + private: + + l4_cap_idx_t _cap_idx; + + public: + + enum Cap_selectors { + INVALID_CAP = L4_INVALID_CAP, + TASK_CAP = L4_BASE_TASK_CAP, + PARENT_CAP = 0x8UL << L4_CAP_SHIFT, + THREADS_BASE_CAP = 0x9UL << L4_CAP_SHIFT, + USER_BASE_CAP = 0x200UL << L4_CAP_SHIFT, + THREAD_GATE_CAP = 0, + THREAD_PAGER_CAP = 0x1UL << L4_CAP_SHIFT, + THREAD_IRQ_CAP = 0x2UL << L4_CAP_SHIFT, + THREAD_CAP_SLOT = THREAD_IRQ_CAP + L4_CAP_SIZE, + MAIN_THREAD_CAP = THREADS_BASE_CAP + THREAD_GATE_CAP + }; + + Fiasco_capability(l4_cap_idx_t cap = L4_INVALID_CAP) + : _cap_idx(cap) { } + + Fiasco_capability(void* cap) + : _cap_idx((l4_cap_idx_t)cap) { } + + bool valid() const { return !(_cap_idx & Fiasco::L4_INVALID_CAP_BIT) + && _cap_idx != 0; } + + operator l4_cap_idx_t () { return _cap_idx; } + }; + + enum Utcb_regs { + UTCB_TCR_BADGE = 1, + UTCB_TCR_THREAD_OBJ = 2 + }; +} + +namespace Genode { + + typedef volatile int Native_lock; + typedef Fiasco::Fiasco_capability Native_thread_id; + typedef Fiasco::Fiasco_capability Native_thread; + typedef Fiasco::Fiasco_capability Native_task; + typedef Fiasco::l4_utcb_t* Native_utcb; + + class Native_capability + { + private: + + Native_thread _cap_sel; + int _unique_id; + + public: + + /** + * Default constructor creates an invalid capability + */ + Native_capability() : _unique_id(0) { } + + /** + * Construct capability manually + */ + Native_capability(Native_thread cap_sel, int unique_id) + : _cap_sel(cap_sel), _unique_id(unique_id) { } + + int local_name() const { return _unique_id; } + Native_thread dst() const { return _cap_sel; } + Native_thread_id tid() const { return _cap_sel; } + + bool valid() const { return _cap_sel.valid() && _unique_id != 0; } + + }; + + typedef int Native_connection_state; +} + +#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */ diff --git a/base-foc/include/base/thread_state.h b/base-foc/include/base/thread_state.h new file mode 100644 index 000000000..b88ffd5c7 --- /dev/null +++ b/base-foc/include/base/thread_state.h @@ -0,0 +1,40 @@ +/* + * \brief Thread state + * \author Stefan Kalkowski + * \date 2010-01-20 + * + * This file contains the Fiasco.OC specific part of the thread state. + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__THREAD_STATE_H_ +#define _INCLUDE__BASE__THREAD_STATE_H_ + +#include +#include +#include + +namespace Genode { + + struct Thread_state : public Cpu_state + { + Native_capability cap; /* capability selector with thread cap */ + unsigned exceptions; /* counts exceptions raised by the thread */ + bool paused; /* indicates whether thread is stopped */ + bool in_exception; /* true if thread is currently in exception */ + Lock lock; + + /** + * Constructor + */ + Thread_state() : cap(), exceptions(0), paused(false) { } + }; +} + +#endif /* _INCLUDE__BASE__THREAD_STATE_H_ */ diff --git a/base-foc/include/foc_cpu_session/client.h b/base-foc/include/foc_cpu_session/client.h new file mode 100644 index 000000000..92bb43149 --- /dev/null +++ b/base-foc/include/foc_cpu_session/client.h @@ -0,0 +1,79 @@ +/* + * \brief Client-side cpu session Fiasco.OC extension + * \author Stefan Kalkowski + * \date 2011-04-04 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__FOC_CPU_SESSION__CLIENT_H_ +#define _INCLUDE__FOC_CPU_SESSION__CLIENT_H_ + +#include +#include +#include + +namespace Genode { + + struct Foc_cpu_session_client : Rpc_client + { + explicit Foc_cpu_session_client(Cpu_session_capability session) + : Rpc_client(static_cap_cast(session)) { } + + Thread_capability create_thread(Name const &name) { + return call(name); } + + void kill_thread(Thread_capability thread) { + call(thread); } + + Thread_capability first() { + return call(); } + + Thread_capability next(Thread_capability curr) { + return call(curr); } + + int set_pager(Thread_capability thread, Pager_capability pager) { + return call(thread, pager); } + + int start(Thread_capability thread, addr_t ip, addr_t sp) { + return call(thread, ip, sp); } + + void pause(Thread_capability thread) { + call(thread); } + + void resume(Thread_capability thread) { + call(thread); } + + void cancel_blocking(Thread_capability thread) { + call(thread); } + + int name(Thread_capability thread, char *name_dst, size_t name_len) + { + PWRN("name called, this function is deprecated"); + return -1; + } + + int state(Thread_capability thread, Thread_state *dst_state) { + return call(thread, dst_state); } + + void exception_handler(Thread_capability thread, Signal_context_capability handler) { + call(thread, handler); } + + void enable_vcpu(Thread_capability cap, addr_t vcpu_state) { + call(cap, vcpu_state); } + + Native_capability native_cap(Thread_capability cap) { + return call(cap); } + + Native_capability alloc_irq() { + return call(); } + }; + +} + +#endif /* _INCLUDE__FOC_CPU_SESSION__CLIENT_H_ */ diff --git a/base-foc/include/foc_cpu_session/connection.h b/base-foc/include/foc_cpu_session/connection.h new file mode 100644 index 000000000..118db4ad7 --- /dev/null +++ b/base-foc/include/foc_cpu_session/connection.h @@ -0,0 +1,41 @@ +/* + * \brief Connection to Fiasco.OC specific cpu service + * \author Stefan Kalkowski + * \date 2011-04-04 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__FOC_CPU_SESSION__CONNECTION_H_ +#define _INCLUDE__FOC_CPU_SESSION__CONNECTION_H_ + +#include +#include + +namespace Genode { + + struct Foc_cpu_connection : Connection, Foc_cpu_session_client + { + /** + * Constructor + * + * \param label initial session label + * \param priority designated priority of all threads created + * with this CPU session + */ + Foc_cpu_connection(const char *label = "", + long priority = DEFAULT_PRIORITY) + : + Connection( + session("priority=0x%lx, ram_quota=32K, label=\"%s\"", + priority, label)), + Foc_cpu_session_client(cap()) { } + }; +} + +#endif /* _INCLUDE__FOC_CPU_SESSION__CONNECTION_H_ */ diff --git a/base-foc/include/foc_cpu_session/foc_cpu_session.h b/base-foc/include/foc_cpu_session/foc_cpu_session.h new file mode 100644 index 000000000..fd7b66b7b --- /dev/null +++ b/base-foc/include/foc_cpu_session/foc_cpu_session.h @@ -0,0 +1,46 @@ +/* + * \brief Cpu session interface extension for Fiasco.OC + * \author Stefan Kalkowski + * \date 2011-04-04 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__FOC_CPU_SESSION__FOC_CPU_SESSION_H_ +#define _INCLUDE__FOC_CPU_SESSION__FOC_CPU_SESSION_H_ + +#include +#include + +namespace Genode { + + struct Foc_cpu_session : Cpu_session + { + virtual ~Foc_cpu_session() { } + + virtual void enable_vcpu(Thread_capability cap, addr_t vcpu_state) = 0; + + virtual Native_capability native_cap(Thread_capability cap) = 0; + + virtual Native_capability alloc_irq() = 0; + + + /********************* + ** RPC declaration ** + *********************/ + + GENODE_RPC(Rpc_enable_vcpu, void, enable_vcpu, Thread_capability, addr_t); + GENODE_RPC(Rpc_native_cap, Native_capability, native_cap, Thread_capability); + GENODE_RPC(Rpc_alloc_irq, Native_capability, alloc_irq); + + GENODE_RPC_INTERFACE_INHERIT(Cpu_session, + Rpc_enable_vcpu, Rpc_native_cap, Rpc_alloc_irq); + }; +} + +#endif /* _INCLUDE__FOC_CPU_SESSION__FOC_CPU_SESSION_H_ */ diff --git a/base-foc/include/foc_pd_session/client.h b/base-foc/include/foc_pd_session/client.h new file mode 100644 index 000000000..fcc3390a2 --- /dev/null +++ b/base-foc/include/foc_pd_session/client.h @@ -0,0 +1,38 @@ +/* + * \brief Client-side Fiasco.OC specific PD session interface + * \author Stefan Kalkowski + * \date 2011-04-14 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__FOC_PD_SESSION__CLIENT_H_ +#define _INCLUDE__FOC_PD_SESSION__CLIENT_H_ + +#include +#include + +namespace Genode { + + struct Foc_pd_session_client : Rpc_client + { + explicit Foc_pd_session_client(Capability session) + : Rpc_client(session) { } + + int bind_thread(Thread_capability thread) { + return call(thread); } + + int assign_parent(Parent_capability parent) { + return call(parent); } + + Native_capability task_cap() { return call(); } + }; + +} + +#endif /* _INCLUDE__FOC_PD_SESSION__CLIENT_H_ */ diff --git a/base-foc/include/foc_pd_session/connection.h b/base-foc/include/foc_pd_session/connection.h new file mode 100644 index 000000000..f7d2bc145 --- /dev/null +++ b/base-foc/include/foc_pd_session/connection.h @@ -0,0 +1,40 @@ +/* + * \brief Connection to Fiasco.OC specific PD service + * \author Stefan Kalkowski + * \date 2011-04-14 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__FOC_PD_SESSION__CONNECTION_H_ +#define _INCLUDE__FOC_PD_SESSION__CONNECTION_H_ + +#include +#include + +namespace Genode { + + struct Foc_pd_connection : Connection, Foc_pd_session_client + { + /** + * Constructor + * + * \param args additional session arguments + */ + Foc_pd_connection(const char *args = 0) + : + Connection( + session("ram_quota=4K%s%s", + args ? ", " : "", + args ? args : "")), + Foc_pd_session_client(cap()) + { } + }; +} + +#endif /* _INCLUDE__FOC_PD_SESSION__CONNECTION_H_ */ diff --git a/base-foc/include/foc_pd_session/foc_pd_session.h b/base-foc/include/foc_pd_session/foc_pd_session.h new file mode 100644 index 000000000..56ce644f2 --- /dev/null +++ b/base-foc/include/foc_pd_session/foc_pd_session.h @@ -0,0 +1,40 @@ +/* + * \brief Fiasco.OC specific PD session extension + * \author Stefan Kalkowski + * \date 2011-04-14 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__FOC_PD_SESSION__FOC_PD_SESSION_H_ +#define _INCLUDE__FOC_PD_SESSION__FOC_PD_SESSION_H_ + +#include +#include +#include + +namespace Genode { + + struct Foc_pd_session : Pd_session + { + virtual ~Foc_pd_session() { } + + virtual Native_capability task_cap() = 0; + + + /********************* + ** RPC declaration ** + *********************/ + + GENODE_RPC(Rpc_task_cap, Native_capability, task_cap); + + GENODE_RPC_INTERFACE_INHERIT(Pd_session, Rpc_task_cap); + }; +} + +#endif /* _INCLUDE__FOC_PD_SESSION__FOC_PD_SESSION_H_ */ diff --git a/base-foc/include/signal_session/foc_source.h b/base-foc/include/signal_session/foc_source.h new file mode 100644 index 000000000..b27b4da75 --- /dev/null +++ b/base-foc/include/signal_session/foc_source.h @@ -0,0 +1,35 @@ +/* + * \brief Fiasco.OC-specific signal source RPC interface + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2011-04-12 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__SIGNAL_SESSION__FOC_SOURCE_H_ +#define _INCLUDE__SIGNAL_SESSION__FOC_SOURCE_H_ + +#include +#include + +namespace Genode { + + struct Foc_signal_source : Signal_source + { + /********************* + ** RPC declaration ** + *********************/ + + GENODE_RPC(Rpc_request_semaphore, Native_capability, _request_semaphore); + + GENODE_RPC_INTERFACE_INHERIT(Signal_source, Rpc_request_semaphore); + }; +} + +#endif /* _INCLUDE__SIGNAL_SESSION__FOC_SOURCE_H_ */ diff --git a/base-foc/include/signal_session/source_client.h b/base-foc/include/signal_session/source_client.h new file mode 100644 index 000000000..540e6431c --- /dev/null +++ b/base-foc/include/signal_session/source_client.h @@ -0,0 +1,91 @@ +/* + * \brief Fiasco.OC-specific signal-source client interface + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2010-02-03 + * + * On Fiasco.OC, the signal source server does not provide a blocking + * 'wait_for_signal' function because this kernel does no support + * out-of-order IPC replies. Instead, we use an IRQ kernel-object + * to let the client block until a signal is present at the + * server. The IRQ object gets initialized with the first + * call of 'wait_for_signal()'. + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__SIGNAL_SESSION__SOURCE_CLIENT_H_ +#define _INCLUDE__SIGNAL_SESSION__SOURCE_CLIENT_H_ + +#include +#include +#include + +namespace Fiasco { +#include +} + +namespace Genode { + + class Signal_source_client : public Rpc_client + { + private: + + /** + * Capability with 'dst' referring to a Fiasco.OC IRQ object + */ + Native_capability _sem; + + /** + * Request Fiasco.OC IRQ object from signal-source server + */ + void _init_sem() + { + using namespace Fiasco; + + /* request mapping of semaphore capability selector */ + _sem = call(); + + l4_msgtag_t tag = l4_irq_attach(_sem.dst(), 0, + Thread_base::myself()->tid()); + if (l4_error(tag)) + PERR("l4_irq_attach failed with %ld!", l4_error(tag)); + } + + public: + + /** + * Constructor + */ + Signal_source_client(Signal_source_capability cap) + : Rpc_client(static_cap_cast(cap)) + { _init_sem(); } + + + /***************************** + ** Signal source interface ** + *****************************/ + + Signal wait_for_signal() + { + using namespace Fiasco; + + /* block on semaphore, will be unblocked if signal is available */ + l4_irq_receive(_sem.dst(), L4_IPC_NEVER); + + /* + * Now that the server has unblocked the semaphore, we are sure + * that there is a signal pending. The following 'wait_for_signal' + * request will be immediately answered. + */ + return call(); + } + }; +} + +#endif /* _INCLUDE__SIGNAL_SESSION__SOURCE_CLIENT_H_ */ diff --git a/base-foc/include/signal_session/source_rpc_object.h b/base-foc/include/signal_session/source_rpc_object.h new file mode 100644 index 000000000..96d1cd776 --- /dev/null +++ b/base-foc/include/signal_session/source_rpc_object.h @@ -0,0 +1,39 @@ +/* + * \brief Signal-source server interface + * \author Norman Feske + * \date 2010-02-03 + * + * This file is only included by 'signal_session/server.h' and relies on the + * headers included there. No include guards are needed. It is a separate + * header file to make it easily replaceable by a platform-specific + * implementation. + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__SIGNAL_SESSION__SOURCE_SERVER_H_ +#define _INCLUDE__SIGNAL_SESSION__SOURCE_SERVER_H_ + +#include +#include + +namespace Genode { + + struct Signal_source_rpc_object : Rpc_object + { + protected: + + Native_capability _blocking_semaphore; + + public: + + Native_capability _request_semaphore() { return _blocking_semaphore; } + }; +} + +#endif /* _INCLUDE__SIGNAL_SESSION__SOURCE_SERVER_H_ */ diff --git a/base-foc/lib/mk/arm/ipc.mk b/base-foc/lib/mk/arm/ipc.mk new file mode 100644 index 000000000..33f3e6cfd --- /dev/null +++ b/base-foc/lib/mk/arm/ipc.mk @@ -0,0 +1,4 @@ +SRC_CC = arm/pager_exception.cc arm/pager.cc + +include $(REP_DIR)/lib/mk/ipc.inc + diff --git a/base-foc/lib/mk/arm/platform.inc b/base-foc/lib/mk/arm/platform.inc new file mode 100644 index 000000000..d0bb4139f --- /dev/null +++ b/base-foc/lib/mk/arm/platform.inc @@ -0,0 +1,8 @@ +# +# Create mirror for architecture-specific L4sys header files +# +L4_INC_TARGETS = arm/l4/sys \ + arm/l4f/l4/sys \ + arm/l4/vcpu + +include $(REP_DIR)/lib/mk/platform.inc diff --git a/base-foc/lib/mk/arm/startup.mk b/base-foc/lib/mk/arm/startup.mk new file mode 100644 index 000000000..14b52c669 --- /dev/null +++ b/base-foc/lib/mk/arm/startup.mk @@ -0,0 +1,8 @@ +SRC_S = crt0.s +SRC_CC = _main.cc +LIBS += cxx lock + +INC_DIR += $(REP_DIR)/src/platform $(BASE_DIR)/src/platform + +vpath crt0.s $(BASE_DIR)/src/platform/arm +vpath _main.cc $(BASE_DIR)/src/platform diff --git a/base-foc/lib/mk/arm/syscalls.mk b/base-foc/lib/mk/arm/syscalls.mk new file mode 100644 index 000000000..ff94d707d --- /dev/null +++ b/base-foc/lib/mk/arm/syscalls.mk @@ -0,0 +1,5 @@ +SRC_C += utcb.c +SRC_S += atomic_ops_s.S + +vpath atomic_ops_s.S $(L4_BUILD_DIR)/source/pkg/l4sys/lib/src/ARCH-arm +vpath utcb.c $(L4_BUILD_DIR)/source/pkg/l4sys/lib/src diff --git a/base-foc/lib/mk/cap_alloc.mk b/base-foc/lib/mk/cap_alloc.mk new file mode 100644 index 000000000..33f7d67d9 --- /dev/null +++ b/base-foc/lib/mk/cap_alloc.mk @@ -0,0 +1,3 @@ +SRC_CC = cap_sel_alloc.cc + +vpath cap_sel_alloc.cc $(REP_DIR)/src/base/env diff --git a/base-foc/lib/mk/core_printf.mk b/base-foc/lib/mk/core_printf.mk new file mode 100644 index 000000000..663cf64b9 --- /dev/null +++ b/base-foc/lib/mk/core_printf.mk @@ -0,0 +1,5 @@ +SRC_CC = core_printf.cc +LIBS = cxx console +INC_DIR += $(REP_DIR)/src/base/console + +vpath core_printf.cc $(BASE_DIR)/src/base/console diff --git a/base-foc/lib/mk/env.mk b/base-foc/lib/mk/env.mk new file mode 100644 index 000000000..fc7176970 --- /dev/null +++ b/base-foc/lib/mk/env.mk @@ -0,0 +1,6 @@ +SRC_CC = env.cc context_area.cc cap_sel_alloc.cc +LIBS = ipc heap log_console lock + +vpath env.cc $(BASE_DIR)/src/base/env +vpath context_area.cc $(BASE_DIR)/src/base/env +vpath cap_sel_alloc.cc $(REP_DIR)/src/base/env diff --git a/base-foc/lib/mk/ipc.inc b/base-foc/lib/mk/ipc.inc new file mode 100644 index 000000000..9a9abfc51 --- /dev/null +++ b/base-foc/lib/mk/ipc.inc @@ -0,0 +1,5 @@ +LIBS = syscalls +SRC_CC += ipc.cc pager.cc +INC_DIR += $(REP_DIR)/src/base/lock + +vpath %.cc $(REP_DIR)/src/base/ipc diff --git a/base-foc/lib/mk/l4re_support.mk b/base-foc/lib/mk/l4re_support.mk new file mode 100644 index 000000000..805809386 --- /dev/null +++ b/base-foc/lib/mk/l4re_support.mk @@ -0,0 +1,14 @@ +# +# Build L4re base libraries, needed by sigma0 and bootstrap + + +# ignore stage one, visit the L4 build system at second build stage +ifeq ($(called_from_lib_mk),yes) + +# packages in 'l4/pkg/' +PKGS = uclibc-headers uclibc-minimal l4util cxx + +include $(REP_DIR)/mk/l4_pkg.mk +all: $(PKG_TAGS) + +endif diff --git a/base-foc/lib/mk/lock.mk b/base-foc/lib/mk/lock.mk new file mode 100644 index 000000000..83ab108db --- /dev/null +++ b/base-foc/lib/mk/lock.mk @@ -0,0 +1,5 @@ +SRC_CC = lock.cc +INC_DIR += $(REP_DIR)/src/base/lock +#INC_DIR += $(REP_DIR)/src/platform + +vpath lock.cc $(BASE_DIR)/src/base/lock diff --git a/base-foc/lib/mk/pager.mk b/base-foc/lib/mk/pager.mk new file mode 100644 index 000000000..eb4f42e1e --- /dev/null +++ b/base-foc/lib/mk/pager.mk @@ -0,0 +1,3 @@ +SRC_CC = pager.cc + +vpath pager.cc $(REP_DIR)/src/base/pager diff --git a/base-foc/lib/mk/platform.inc b/base-foc/lib/mk/platform.inc new file mode 100644 index 000000000..c2309db08 --- /dev/null +++ b/base-foc/lib/mk/platform.inc @@ -0,0 +1,69 @@ +# +# Create prerequisites for building Genode for Fiasco.OC +# +# Prior building Genode programs for Fiasco.OC, the kernel bindings must be +# generated. This is done by building a minimalistic subset of the original +# userland (L4re) that comes with Fiasco.OC. +# + +# +# Execute the rules in this file only at the second build stage when we know +# about the complete build settings, e.g., the 'CROSS_DEV_PREFIX'. +# +ifeq ($(called_from_lib_mk),yes) + +# +# Create mirror for architecture-specific L4sys header files +# +L4_INC_TARGETS += l4/sys \ + l4f/l4/sys \ + l4/sigma0 \ + l4/vcpu + +all: $(addprefix $(BUILD_BASE_DIR)/include/,$(L4_INC_TARGETS)) + +$(BUILD_BASE_DIR)/include/%: + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)ln -sf $(L4_BUILD_DIR)/include/$* $@ + +# +# Sanity checks +# +ifeq ($(L4_BUILD_DIR),$(BUILD_BASE_DIR)/l4) +ifeq ($(L4_CONFIG),) +all: $(REP_DIR)/contrib l4_config_not_defined +l4_config_not_defined: + $(VERBOSE)$(ECHO) "Error: L4_CONFIG is not defined, platform not supported" + @false +endif +endif + +$(REP_DIR)/contrib: + $(VERBOSE)$(ECHO) "--> Please, execute 'make prepare' in $(REP_DIR)" + $(VERBOSE)$(ECHO) "--> before compiling Genode apps for Fiasco.OC." + $(VERBOSE)$(ECHO) "--> Run 'make cleanall' before next compilation." + $(VERBOSE)exit 1 + +# +# Create L4 build directory +# +# Resetting the 'MAKEFLAGS' is important because otherwise, the L4 +# build system will stuble over predefined variables, i.e., 'LIB' +# +$(BUILD_BASE_DIR)/l4/.kconfig: $(REP_DIR)/contrib + $(VERBOSE_MK) MAKEFLAGS= $(MAKE) $(VERBOSE_DIR) -C $(REP_DIR)/contrib/l4 B=$(dir $@) \ + DROPSCONF_DEFCONFIG="$(L4_CONFIG)" \ + VERBOSE="$(VERBOSE)" SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" + +PKGS = ldscripts \ + l4sys \ + libsigma0 \ + libvcpu/include + +include $(REP_DIR)/mk/l4_pkg.mk +all: $(PKG_TAGS) + +$(PKG_TAGS): $(BUILD_BASE_DIR)/l4/.kconfig + +endif + diff --git a/base-foc/lib/mk/platform_pbxa9/platform.mk b/base-foc/lib/mk/platform_pbxa9/platform.mk new file mode 100644 index 000000000..067f34694 --- /dev/null +++ b/base-foc/lib/mk/platform_pbxa9/platform.mk @@ -0,0 +1,6 @@ +# +# Configuration for L4 build system (for kernel-bindings, sigma0, bootstrap). +# +L4_CONFIG = $(call select_from_repositories,config/rva9.user) + +include $(REP_DIR)/lib/mk/arm/platform.inc diff --git a/base-foc/lib/mk/platform_vea9x4/platform.mk b/base-foc/lib/mk/platform_vea9x4/platform.mk new file mode 100644 index 000000000..067f34694 --- /dev/null +++ b/base-foc/lib/mk/platform_vea9x4/platform.mk @@ -0,0 +1,6 @@ +# +# Configuration for L4 build system (for kernel-bindings, sigma0, bootstrap). +# +L4_CONFIG = $(call select_from_repositories,config/rva9.user) + +include $(REP_DIR)/lib/mk/arm/platform.inc diff --git a/base-foc/lib/mk/raw_server.mk b/base-foc/lib/mk/raw_server.mk new file mode 100644 index 000000000..3487331b9 --- /dev/null +++ b/base-foc/lib/mk/raw_server.mk @@ -0,0 +1,4 @@ +SRC_CC = server.cc common.cc + +vpath server.cc $(REP_DIR)/src/base/server +vpath common.cc $(BASE_DIR)/src/base/server diff --git a/base-foc/lib/mk/server.mk b/base-foc/lib/mk/server.mk new file mode 100644 index 000000000..de155386e --- /dev/null +++ b/base-foc/lib/mk/server.mk @@ -0,0 +1,3 @@ +LIBS = thread + +include $(REP_DIR)/lib/mk/raw_server.mk diff --git a/base-foc/lib/mk/thread.mk b/base-foc/lib/mk/thread.mk new file mode 100644 index 000000000..74ce01970 --- /dev/null +++ b/base-foc/lib/mk/thread.mk @@ -0,0 +1,3 @@ +SRC_CC = thread.cc thread_start.cc thread_bootstrap.cc + +vpath %.cc $(REP_DIR)/src/base/thread diff --git a/base-foc/lib/mk/x86/syscalls.mk b/base-foc/lib/mk/x86/syscalls.mk new file mode 100644 index 000000000..80154535d --- /dev/null +++ b/base-foc/lib/mk/x86/syscalls.mk @@ -0,0 +1,5 @@ +SRC_C += utcb.c +SRC_S += syscalls_direct.S + +vpath syscalls_direct.S $(L4_BUILD_DIR)/source/pkg/l4sys/lib/src/ARCH-x86 +vpath utcb.c $(L4_BUILD_DIR)/source/pkg/l4sys/lib/src diff --git a/base-foc/lib/mk/x86_32/ipc.mk b/base-foc/lib/mk/x86_32/ipc.mk new file mode 100644 index 000000000..010cede4f --- /dev/null +++ b/base-foc/lib/mk/x86_32/ipc.mk @@ -0,0 +1,3 @@ +SRC_CC = x86/pager_exception.cc x86_32/pager.cc + +include $(REP_DIR)/lib/mk/ipc.inc diff --git a/base-foc/lib/mk/x86_32/platform.mk b/base-foc/lib/mk/x86_32/platform.mk new file mode 100644 index 000000000..fedc7acf3 --- /dev/null +++ b/base-foc/lib/mk/x86_32/platform.mk @@ -0,0 +1,13 @@ +# +# Configuration for L4 build system (for kernel-bindings, sigma0, bootstrap). +# +L4_CONFIG = $(call select_from_repositories,contrib/l4/mk/defconfig/config.x86) + +# +# Create mirror for architecture-specific L4sys header files +# +L4_INC_TARGETS = x86/l4/sys \ + x86/l4f/l4/sys \ + x86/l4/vcpu + +include $(REP_DIR)/lib/mk/platform.inc diff --git a/base-foc/lib/mk/x86_32/startup.mk b/base-foc/lib/mk/x86_32/startup.mk new file mode 100644 index 000000000..8c2ef8fe0 --- /dev/null +++ b/base-foc/lib/mk/x86_32/startup.mk @@ -0,0 +1,8 @@ +SRC_S = crt0.s +SRC_CC = _main.cc +LIBS += cxx lock + +INC_DIR += $(REP_DIR)/src/platform $(BASE_DIR)/src/platform + +vpath crt0.s $(BASE_DIR)/src/platform/x86_32 +vpath _main.cc $(BASE_DIR)/src/platform diff --git a/base-foc/lib/mk/x86_64/ipc.mk b/base-foc/lib/mk/x86_64/ipc.mk new file mode 100644 index 000000000..9586dd77b --- /dev/null +++ b/base-foc/lib/mk/x86_64/ipc.mk @@ -0,0 +1,3 @@ +SRC_CC = x86/pager_exception.cc x86_64/pager.cc + +include $(REP_DIR)/lib/mk/ipc.inc diff --git a/base-foc/lib/mk/x86_64/platform.mk b/base-foc/lib/mk/x86_64/platform.mk new file mode 100644 index 000000000..5a12904c7 --- /dev/null +++ b/base-foc/lib/mk/x86_64/platform.mk @@ -0,0 +1,13 @@ +# +# Configuration for L4 build system (for kernel-bindings, sigma0, bootstrap). +# +L4_CONFIG = $(call select_from_repositories,contrib/l4/mk/defconfig/config.amd64) + +# +# Create mirror for architecture-specific L4sys header files +# +L4_INC_TARGETS = amd64/l4/sys \ + amd64/l4f/l4/sys \ + amd64/l4/vcpu + +include $(REP_DIR)/lib/mk/platform.inc diff --git a/base-foc/lib/mk/x86_64/startup.mk b/base-foc/lib/mk/x86_64/startup.mk new file mode 100644 index 000000000..cc3c00505 --- /dev/null +++ b/base-foc/lib/mk/x86_64/startup.mk @@ -0,0 +1,8 @@ +SRC_S = crt0.s +SRC_CC = _main.cc +LIBS += cxx lock + +INC_DIR += $(REP_DIR)/src/platform $(BASE_DIR)/src/platform + +vpath crt0.s $(BASE_DIR)/src/platform/x86_64 +vpath _main.cc $(BASE_DIR)/src/platform diff --git a/base-foc/mk/l4_pkg.mk b/base-foc/mk/l4_pkg.mk new file mode 100644 index 000000000..07e4d55da --- /dev/null +++ b/base-foc/mk/l4_pkg.mk @@ -0,0 +1,60 @@ +# +# Utility for building L4 contrib packages +# +# Variables that steer the behaviour of this makefile: +# +# TARGET - name of target +# PKGS - list of L4 packages to visit in order to create +# the target +# + +LIBS += platform + +ifeq ($(filter-out $(SPECS),x86_32),) + L4_BUILD_ARCH := x86_586 +endif + +ifeq ($(filter-out $(SPECS),x86_64),) + L4_BUILD_ARCH := amd_k9 +endif + +ifeq ($(filter-out $(SPECS),arm_v7a),) + L4_BUILD_ARCH := arm_armv7a +endif + +ifeq ($(L4_BUILD_ARCH),) +all: l4_build_arch_undefined + $(VERBOSE)$(ECHO) "Error: L4_BUILD_ARCH undefined, architecture not supported" + $(VERBOSE)false +endif + +L4_BUILD_DIR = $(BUILD_BASE_DIR)/l4 +L4_BUILD_OPT = SYSTEM_TARGET=$(CROSS_DEV_PREFIX) +L4_PKG_DIR = $(REP_DIR)/contrib/l4/pkg +STARTUP_LIB = +PKG_TAGS = $(addsuffix .tag,$(PKGS)) + +$(TARGET): $(PKG_TAGS) + +# +# We preserve the order of processing 'l4/pkg/' directories because of +# inter-package dependencies. However, within each directory, make is working +# in parallel. +# +.NOTPARALLEL: $(PKG_TAGS) + +%.tag: + $(VERBOSE_MK) $(MAKE) $(VERBOSE_DIR) O=$(L4_BUILD_DIR) -C $(L4_PKG_DIR)/$* "$(L4_BUILD_OPT)" + $(VERBOSE)mkdir -p $(dir $@) && touch $@ + +clean cleanall: clean_tags + +# if (pseudo) target is named after a directory, remove the whole subtree +clean_prg_objects: clean_dir_named_as_target + +clean_dir_named_as_target: + $(VERBOSE)(test -d $(TARGET) && rm -rf $(TARGET)) || true + +clean_tags: + $(VERBOSE)rm -f $(PKG_TAGS) + diff --git a/base-foc/mk/spec-foc.mk b/base-foc/mk/spec-foc.mk new file mode 100644 index 000000000..4a383fec8 --- /dev/null +++ b/base-foc/mk/spec-foc.mk @@ -0,0 +1,52 @@ +# +# Specifics for the Fiasco.OC kernel API +# + +-include $(call select_from_repositories,etc/foc.conf) +-include $(BUILD_BASE_DIR)/etc/foc.conf + +# +# L4/sys headers +# +L4_INC_DIR += $(BUILD_BASE_DIR)/include/ +L4F_INC_DIR += $(BUILD_BASE_DIR)/include/l4f + +# +# L4 build directory, if not defined by 'foc.conf', use directory local +# to the Genode build directory. +# +L4_BUILD_DIR ?= $(BUILD_BASE_DIR)/l4 + +# +# Build everything with -fPIC because the Fiasco.OC syscall bindings +# rely on 'ebx' (on x86) being handled with care. Without -fPIC enabled, +# the syscall bindings break. +# +CC_OPT += -fPIC + +# +# Use 'regparm=0' call instead of an inline function, when accessing +# the utcb. This is needed to stay compatible with L4linux +# +CC_OPT += -DL4SYS_USE_UTCB_WRAP=1 + +# +# Startup code to be used when building a program +# +STARTUP_LIB ?= startup +PRG_LIBS += $(STARTUP_LIB) + +all: + +# +# Clean rules for removing the side effects of building the platform +# library +# +clean_includes: + $(VERBOSE)rm -rf $(BUILD_BASE_DIR)/include + +clean_contrib: + $(VERBOSE)rm -rf $(BUILD_BASE_DIR)/l4 + +cleanall: clean_contrib clean_includes + diff --git a/base-foc/mk/spec-foc_arm.mk b/base-foc/mk/spec-foc_arm.mk new file mode 100644 index 000000000..312e8aa01 --- /dev/null +++ b/base-foc/mk/spec-foc_arm.mk @@ -0,0 +1,37 @@ +# +# Specifics for Fiasco.OC on ARM +# + +SPECS += foc + +# +# Linker options that are specific for arm +# +LD_TEXT_ADDR ?= 0x01000000 + +# +# ARM-specific L4/sys headers +# +L4_INC_DIR = $(BUILD_BASE_DIR)/include/arm +L4F_INC_DIR = $(BUILD_BASE_DIR)/include/arm/l4f + +# +# Support for Fiasco.OC's ARM-specific atomic functions +# +REP_INC_DIR += include/arm + +# +# Defines for L4/sys headers +# +CC_OPT += -DCONFIG_L4_CALL_SYSCALLS -DARCH_arm + +# +# Architecture-specific L4sys header files +# +L4_INC_TARGETS = arm/l4/sys \ + arm/l4f/l4/sys \ + arm/l4/vcpu + +include $(call select_from_repositories,mk/spec-foc.mk) + +INC_DIR += $(L4F_INC_DIR) $(L4_INC_DIR) diff --git a/base-foc/mk/spec-foc_pbxa9.mk b/base-foc/mk/spec-foc_pbxa9.mk new file mode 100644 index 000000000..eec6e570e --- /dev/null +++ b/base-foc/mk/spec-foc_pbxa9.mk @@ -0,0 +1,4 @@ +SPECS += foc_arm platform_pbxa9 + +include $(call select_from_repositories,mk/spec-platform_pbxa9.mk) +include $(call select_from_repositories,mk/spec-foc_arm.mk) diff --git a/base-foc/mk/spec-foc_vea9x4.mk b/base-foc/mk/spec-foc_vea9x4.mk new file mode 100644 index 000000000..031fa605c --- /dev/null +++ b/base-foc/mk/spec-foc_vea9x4.mk @@ -0,0 +1,4 @@ +SPECS += foc_arm platform_vea9x4 + +include $(call select_from_repositories,mk/spec-platform_vea9x4.mk) +include $(call select_from_repositories,mk/spec-foc_arm.mk) diff --git a/base-foc/mk/spec-foc_x86_32.mk b/base-foc/mk/spec-foc_x86_32.mk new file mode 100644 index 000000000..341693d41 --- /dev/null +++ b/base-foc/mk/spec-foc_x86_32.mk @@ -0,0 +1,25 @@ +# +# Specifics for Fiasco.OC on x86 +# + +SPECS += x86_32 foc +SPECS += pci ps2 vesa + +# +# Linker options that are specific for x86 +# +LD_TEXT_ADDR ?= 0x01000000 + +# +# L4/sys headers +# +L4_INC_DIR = $(BUILD_BASE_DIR)/include/x86 +L4F_INC_DIR = $(BUILD_BASE_DIR)/include/x86/l4f + +# +# Also include less-specific configuration last +# +include $(call select_from_repositories,mk/spec-x86_32.mk) +include $(call select_from_repositories,mk/spec-foc.mk) + +INC_DIR += $(L4F_INC_DIR) $(L4_INC_DIR) diff --git a/base-foc/mk/spec-foc_x86_64.mk b/base-foc/mk/spec-foc_x86_64.mk new file mode 100644 index 000000000..fe126d344 --- /dev/null +++ b/base-foc/mk/spec-foc_x86_64.mk @@ -0,0 +1,30 @@ +# +# Specifics for Fiasco.OC on x86 64-bit +# + +SPECS += x86_64 foc +SPECS += pci ps2 vesa + +# +# Linker options that are specific for x86 +# +LD_TEXT_ADDR ?= 0x01000000 + +# +# L4/sys headers +# +L4_INC_DIR = $(BUILD_BASE_DIR)/include/amd64 +L4F_INC_DIR = $(BUILD_BASE_DIR)/include/amd64/l4f + +# +# Compile for 64-bit +# +CC_OPT += -m64 + +# +# Also include less-specific configuration last +# +include $(call select_from_repositories,mk/spec-x86_64.mk) +include $(call select_from_repositories,mk/spec-foc.mk) + +INC_DIR += $(L4F_INC_DIR) $(L4_INC_DIR) diff --git a/base-foc/patches/README b/base-foc/patches/README new file mode 100644 index 000000000..543e94196 --- /dev/null +++ b/base-foc/patches/README @@ -0,0 +1,14 @@ +The patches in this directory are modifications of the Fiasco.OC kernel +required for using this kernel with Genode. + +:'foc_single_step_x86.patch': + + This patch enables the user land to use the CPU's single stepping mode on + x86_32 platforms. It is needed to enable the use of GDB monitor for + user-level debugging. + +:'fix_exception_ip.patch': + + On the occurrence of undefined-instruction exceptions on ARM, Fiasco.OC + reports a wrong program-counter value to the exception handler. The patch + fixes the problem. diff --git a/base-foc/patches/crtn_arm_binutils_2.21.1.patch b/base-foc/patches/crtn_arm_binutils_2.21.1.patch new file mode 100644 index 000000000..a32d341c7 --- /dev/null +++ b/base-foc/patches/crtn_arm_binutils_2.21.1.patch @@ -0,0 +1,21 @@ +Index: uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/crtn.S +=================================================================== +--- l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/crtn.S (revision 36) ++++ l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/crtn.S (working copy) +@@ -16,6 +16,7 @@ + #else + .align 2 + .arm ++ .L1: + ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc} + #endif + .size .L1, .-.L1 +@@ -32,6 +33,7 @@ + #else + .align 2 + .arm ++ .L2: + ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc} + #endif + .size .L2,.-.L2 + diff --git a/base-foc/patches/fix_exception_ip.patch b/base-foc/patches/fix_exception_ip.patch new file mode 100644 index 000000000..2b866bda8 --- /dev/null +++ b/base-foc/patches/fix_exception_ip.patch @@ -0,0 +1,15 @@ +Index: kernel/fiasco/src/kern/arm/thread-arm.cpp +=================================================================== +--- kernel/fiasco/src/kern/arm/thread-arm.cpp (revision 38) ++++ kernel/fiasco/src/kern/arm/thread-arm.cpp (working copy) +@@ -258,6 +258,10 @@ + && handle_copro_fault[copro](opcode, ts)) + return; + } ++ ++ /* check for ARM default GDB breakpoint */ ++ if (!(ts->psr & Proc::Status_thumb) && opcode == 0xe7ffdefe) ++ ts->pc -= 4; + } + + undef_insn: diff --git a/base-foc/patches/foc_single_step_x86.patch b/base-foc/patches/foc_single_step_x86.patch new file mode 100644 index 000000000..5bc8f16f9 --- /dev/null +++ b/base-foc/patches/foc_single_step_x86.patch @@ -0,0 +1,241 @@ +Index: kernel/fiasco/src/Kconfig +=================================================================== +--- kernel/fiasco/src/Kconfig (revision 38) ++++ kernel/fiasco/src/Kconfig (working copy) +@@ -694,6 +694,14 @@ + prevent some P4 processors from being overheated. This option + requires a working timer IRQ to wakeup getchar periodically. + ++config USER_SINGLE_STEP ++ bool "Enable user level single stepping support" ++ depends on IA32 ++ default n ++ help ++ This option enables single stepping of user level applications outside of ++ JDB. ++ + choice + prompt "Warn levels" + default WARN_WARNING +Index: kernel/fiasco/src/kern/ia32/config-ia32.cpp +=================================================================== +--- kernel/fiasco/src/kern/ia32/config-ia32.cpp (revision 38) ++++ kernel/fiasco/src/kern/ia32/config-ia32.cpp (working copy) +@@ -98,6 +98,12 @@ + static const bool kinfo_timer_uses_rdtsc = false; + #endif + ++#ifdef CONFIG_USER_SINGLE_STEP ++ static const bool user_single_step = true; ++#else ++ static const bool user_single_step = false; ++#endif ++ + static const bool old_sigma0_adapter_hack = false; + + // the default uart to use for serial console +Index: kernel/fiasco/src/kern/ia32/32/entry-native.S +=================================================================== +--- kernel/fiasco/src/kern/ia32/32/entry-native.S (revision 38) ++++ kernel/fiasco/src/kern/ia32/32/entry-native.S (working copy) +@@ -46,6 +46,30 @@ + jmp slowtraps + .endm + ++#ifdef CONFIG_USER_SINGLE_STEP ++.macro HANDLE_USER_TRAP1 ++ /* Save EFLAGS, this may trap if user task had single stepping activated ++ * test for single stepping ++ */ ++ pushf ++ addl $4, %esp ++ testl $EFLAGS_TF, -4(%esp) ++.endm ++ ++.macro RESTORE_USER_TRAP1 ++ /* Restore single stepping if it has been set */ ++ je 1f ++ orl $EFLAGS_TF, (%esp) ++1: ++.endm ++#else ++.macro HANDLE_USER_TRAP1 ++.endm ++ ++.macro RESTORE_USER_TRAP1 ++.endm ++#endif ++ + .p2align 4 + .globl entry_vec01_debug + entry_vec01_debug: +@@ -55,6 +79,15 @@ + cmpl $VAL__MEM_LAYOUT__TCBS_END, %esp + jbe 2f + #endif ++ ++ /* test if trap was raised within kernel */ ++ testl $3, 4(%esp) ++ jne 1f ++ ++ /* turn of EFLAGS.TF */ ++ btrl $7, 8(%esp) ++ iret ++ + 1: pushl $0 + pushl $1 + pusha +@@ -214,11 +247,17 @@ + .p2align(4) + .global entry_sys_fast_ipc_c + entry_sys_fast_ipc_c: ++ ++ HANDLE_USER_TRAP1 ++ + pop %esp + pushl $(GDT_DATA_USER|SEL_PL_U) /* user ss */ + pushl %ebp // push user SP (get in ebp) + // Fake user eflags, set IOPL to 3 + pushl $(EFLAGS_IOPL_U | EFLAGS_IF) ++ ++ RESTORE_USER_TRAP1 ++ + cld + // Fake user cs. This cs value is never used with exception + // that the thread is ex_regs'd before we leave with sysexit. +Index: kernel/fiasco/src/kern/ia32/thread-ia32.cpp +=================================================================== +--- kernel/fiasco/src/kern/ia32/thread-ia32.cpp (revision 38) ++++ kernel/fiasco/src/kern/ia32/thread-ia32.cpp (working copy) +@@ -196,12 +196,19 @@ + Address ip; + int from_user = ts->cs() & 3; + ++ //if (ts->_trapno != 3) ++ // LOG_MSG_3VAL(this, "trap", ts->_trapno, from_user, ts->ip()); ++ + if (EXPECT_FALSE(ts->_trapno == 0xee)) //debug IPI + { + Ipi::eoi(Ipi::Debug); + goto generic_debug; + } + ++ if (Config::user_single_step && ts->_trapno == 1 && from_user) ++ if (send_exception(ts)) ++ goto success; ++ + if (from_user && _space.user_mode()) + { + if (ts->_trapno == 14 && Kmem::is_io_bitmap_page_fault(ts->_cr2)) +@@ -521,7 +528,8 @@ + // thread (not alien) and it's a debug trap, + // debug traps for aliens are always reflected as exception IPCs + if (!(state() & Thread_alien) +- && (ts->_trapno == 1 || ts->_trapno == 3)) ++ && ((ts->_trapno == 1 && !Config::user_single_step) ++ || ts->_trapno == 3)) + return 0; // we do not handle this + + if (ts->_trapno == 3) +@@ -574,6 +582,11 @@ + } + } + ++IMPLEMENT inline ++void ++Thread::user_single_step(bool) ++{} ++ + //---------------------------------------------------------------------------- + IMPLEMENTATION [ia32]: + +@@ -586,6 +599,16 @@ + _gs = _fs = Utcb_init::utcb_segment(); + } + ++IMPLEMENT inline ++void ++Thread::user_single_step(bool enable) ++{ ++ if (!Config::user_single_step) ++ return; ++ ++ regs()->flags(enable ? user_flags() | EFLAGS_TF : user_flags() & ~EFLAGS_TF); ++} ++ + //---------------------------------------------------------------------------- + IMPLEMENTATION [amd64]: + +Index: kernel/fiasco/src/kern/thread_object.cpp +=================================================================== +--- kernel/fiasco/src/kern/thread_object.cpp (revision 38) ++++ kernel/fiasco/src/kern/thread_object.cpp (working copy) +@@ -524,6 +524,8 @@ + if (o_ip) *o_ip = user_ip(); + if (o_flags) *o_flags = user_flags(); + ++ (ops & Exr_single_step) ? user_single_step(true) : user_single_step(false); ++ + // Changing the run state is only possible when the thread is not in + // an exception. + if (!(ops & Exr_cancel) && (state() & Thread_in_exception)) +Index: kernel/fiasco/src/kern/thread.cpp +=================================================================== +--- kernel/fiasco/src/kern/thread.cpp (revision 38) ++++ kernel/fiasco/src/kern/thread.cpp (working copy) +@@ -70,6 +70,7 @@ + { + Exr_cancel = 0x10000, + Exr_trigger_exception = 0x20000, ++ Exr_single_step = 0x40000, + }; + + enum Vcpu_ctl_flags +@@ -137,6 +138,8 @@ + + inline Mword user_flags() const; + ++ inline void user_single_step(bool); ++ + /** nesting level in debugger (always critical) if >1 */ + static Per_cpu nested_trap_recover; + static void handle_remote_requests_irq() asm ("handle_remote_cpu_requests"); +Index: kernel/fiasco/src/kern/arm/thread-arm.cpp +=================================================================== +--- kernel/fiasco/src/kern/arm/thread-arm.cpp (revision 38) ++++ kernel/fiasco/src/kern/arm/thread-arm.cpp (working copy) +@@ -361,7 +361,7 @@ + IMPLEMENT inline + Mword + Thread::user_flags() const +-{ return 0; } ++{ return state() & Thread_ready; } + + IMPLEMENT inline NEEDS[Thread::exception_triggered] + void +@@ -549,6 +549,10 @@ + return (v[insn >> 28] >> (psr >> 28)) & 1; + } + ++IMPLEMENT inline ++void Thread::user_single_step(bool) ++{} ++ + // ------------------------------------------------------------------------ + IMPLEMENTATION [arm && armv6plus]: + +Index: kernel/fiasco/src/kern/ppc32/thread-ppc32.cpp +=================================================================== +--- kernel/fiasco/src/kern/ppc32/thread-ppc32.cpp (revision 38) ++++ kernel/fiasco/src/kern/ppc32/thread-ppc32.cpp (working copy) +@@ -307,6 +307,10 @@ + } + } + ++IMPLEMENT inline ++void Thread::user_single_step(bool) ++{} ++ + PUBLIC inline NEEDS ["trap_state.h"] + int + Thread::send_exception_arch(Trap_state * /*ts*/) diff --git a/base-foc/patches/timer_arm.patch b/base-foc/patches/timer_arm.patch new file mode 100644 index 000000000..d922d48b7 --- /dev/null +++ b/base-foc/patches/timer_arm.patch @@ -0,0 +1,20 @@ +Index: kernel/fiasco/src/kern/arm/bsp/realview/timer-arm-mptimer-realview.cpp +=================================================================== +--- kernel/fiasco/src/kern/arm/bsp/realview/timer-arm-mptimer-realview.cpp (revision 38) ++++ kernel/fiasco/src/kern/arm/bsp/realview/timer-arm-mptimer-realview.cpp (working copy) +@@ -4,7 +4,7 @@ + EXTENSION class Timer + { + private: +- enum { Interval = 104999, /* assumed 210MHz */}; ++ enum { Interval = 209999, /* assumed 210MHz */}; + }; + + // -------------------------------------------------------------------------- +@@ -13,5 +13,5 @@ + EXTENSION class Timer + { + private: +- enum { Interval = 49999, }; ++ enum { Interval = 99999, /* assumed 100MHz */}; + }; diff --git a/base-foc/patches/vexpress_detection.patch b/base-foc/patches/vexpress_detection.patch new file mode 100644 index 000000000..02c3af74d --- /dev/null +++ b/base-foc/patches/vexpress_detection.patch @@ -0,0 +1,13 @@ +Index: kernel/fiasco/src/kern/arm/bsp/realview/board_check-arm-realview.cpp +=================================================================== +--- kernel/fiasco/src/kern/arm/bsp/realview/board_check-arm-realview.cpp (revision 38) ++++ kernel/fiasco/src/kern/arm/bsp/realview/board_check-arm-realview.cpp (working copy) +@@ -46,7 +46,7 @@ + IMPLEMENTATION [arm && realview && realview_vexpress]: + + Board_check::id_pair Board_check::ids[] FIASCO_INITDATA = { +- { 0xffffff00, 0x1190f500 }, ++ { 0xcfffff00, 0x0190f500 }, + }; + + // ------------------------------------------------------------------------ diff --git a/base-foc/run/env b/base-foc/run/env new file mode 100644 index 000000000..f8bc4dbb7 --- /dev/null +++ b/base-foc/run/env @@ -0,0 +1,203 @@ +# +# \brief Fiasco.OC-specific test-environment supplements +# \author Stefan Kalkowski +# \date 2010-11-22 +# +# This file is meant to be used as '--include' argument for 'tool/run'. +# + +## +# Return the location of the Fiasco.OC user directory +# +proc l4_dir { } { + global _l4_dir + + if {![info exists _l4_dir]} { + if {[file exists etc/foc.conf]} { + set _l4_dir [exec sed -n "/^L4_BUILD_DIR/s/^.*=\\s*//p" etc/foc.conf] + if {[file exists $_l4_dir]} { return $_l4_dir } + } + + set _l4_dir "[pwd]/l4" + if {![file exists $_l4_dir]} { + puts -nonewline stderr "Error: Could neither find the L4 build directory " + puts -nonewline stderr "within '/l4' nor at a location " + puts -nonewline stderr "specified via 'L4_BUILD_DIR = ' " + puts stderr "in /etc/foc.conf'." + exit 1 + } + } + return $_l4_dir +} + +## +# Return whether the l4-buid-directory is provided from the outside +# +proc l4_dir_external { } { + if {[l4_dir] == "[pwd]/l4"} { return 0 } + return 1 +} + +## +# Return the location of the Fiasco.OC kernel directory +# +proc fiasco { } { + global _fiasco + + if {![info exists _fiasco]} { + if {[file exists etc/foc.conf]} { + set _fiasco [exec sed -n "/^KERNEL/s/^.*=\\s*//p" etc/foc.conf] + if {[file exists $_fiasco]} { return $_fiasco } + } + + # try to fall back to version hosted with the Genode build directory + set _fiasco "[pwd]/kernel/fiasco.oc/fiasco" + } + return $_fiasco +} + +## +# Return whether fiasco kernel is provided from the outside +# +proc fiasco_external { } { + if {[fiasco] == "[pwd]/kernel/fiasco.oc/fiasco"} { return 0 } + return 1 +} + +################################## +## Test framework API functions ## +################################## + +proc create_boot_directory { } { + exec rm -rf [run_dir] + exec mkdir -p [run_dir]/genode + + if {[have_spec x86]} { + exec mkdir -p [run_dir]/fiasco + exec mkdir -p [run_dir]/boot/grub + } +} + + +proc copy_and_strip_binaries {binaries} { + + # + # Collect contents of the boot image + # + foreach binary $binaries { + exec cp bin/$binary [run_dir]/genode + catch { + exec [cross_dev_prefix]strip [run_dir]/genode/$binary } + } + + # + # Generate config file for bootstrap + # +} + + +proc bin_dir { } { + if {[have_spec x86_32]} { return "[l4_dir]/bin/x86_586" } + if {[have_spec x86_64]} { return "[l4_dir]/bin/amd64_K8" } + if {[have_spec arm_v7a]} { return "[l4_dir]/bin/arm_armv7a" } + + puts stderr "Error: Cannot determine bin directory" + exit 1 +} + + +proc build_boot_image_x86 {binaries} { + + copy_and_strip_binaries $binaries + + set foc_targets { } + if {![fiasco_external] && ![file exists kernel]} { lappend foc_targets kernel } + if {![l4_dir_external]} { + if {![file exists bootstrap]} { lappend foc_targets bootstrap } + if {![file exists sigma0]} { lappend foc_targets sigma0 } + } + if {[llength $foc_targets] > 0} { build $foc_targets } + + # assert existence of the L4 build directory + l4_dir + + puts "using fiasco kernel [fiasco]" + exec cp [fiasco] [run_dir]/fiasco + puts "using sigma0/bootstrap at [l4_dir]" + exec cp [bin_dir]/l4f/sigma0 [run_dir]/fiasco + exec cp [bin_dir]/bootstrap [run_dir]/fiasco + + install_iso_bootloader_to_run_dir + + # + # Generate grub config file + # + # The core binary is part of the 'binaries' list but it must + # appear right after 'sigma0' as boot module. Hence the special case. + # + set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"] + puts $fh "timeout 0" + puts $fh "default 0" + puts $fh "\ntitle Genode on Fiasco.OC" + puts $fh " kernel /fiasco/bootstrap -modaddr=0x01100000" + puts $fh " module /fiasco/fiasco -serial_esc" + puts $fh " module /fiasco/sigma0" + puts $fh " module /genode/core" + puts $fh " module /genode/config" + foreach binary $binaries { + if {$binary != "core"} { + puts $fh " module /genode/$binary" } } + puts $fh " vbeset 0x117 506070" + close $fh + + create_iso_image_from_run_dir +} + + +proc build_boot_image_arm {binaries} { + + copy_and_strip_binaries $binaries + + build "kernel sigma0 bootstrap" + + # + # Generate bootstrap config + # + set fh [open "[run_dir]/modules.list" "WRONLY CREAT TRUNC"] + + puts $fh "modaddr 0x01100000\n" + puts $fh "entry genode" + puts $fh "kernel [fiasco] -serial_esc" + puts $fh "roottask genode/core" + puts $fh "module genode/config" + foreach binary $binaries { + if {$binary != "core"} { + puts $fh "module genode/$binary" } } + close $fh + + set gen_img_cmd "cd [l4_dir]/source/pkg/bootstrap/server/src && " + append gen_img_cmd "make O=[l4_dir] ENTRY=genode " + append gen_img_cmd "BOOTSTRAP_DO_UIMAGE= BOOTSTRAP_DO_RAW_IMAGE= " + append gen_img_cmd "BOOTSTRAP_MODULES_LIST=[pwd]/[run_dir]/modules.list " + append gen_img_cmd "BOOTSTRAP_SEARCH_PATH=[pwd]/[run_dir]:[file dirname [fiasco]]:[l4_dir] " + append gen_img_cmd "SYSTEM_TARGET=[cross_dev_prefix]" + + set pid [eval "spawn sh -c \"$gen_img_cmd\""] + expect { eof { } } + if {[lindex [wait $pid] end] != 0} { + puts "Error: Single-image creation failed" + exit -4 + } + + exec cp [bin_dir]/bootstrap.elf [run_dir]/image.elf +} + + +proc build_boot_image {binaries} { + if {[have_spec x86]} { return [build_boot_image_x86 $binaries] } + if {[have_spec arm]} { return [build_boot_image_arm $binaries] } +} + + +proc run_genode_until {{wait_for_re forever} {timeout_value 0}} { + spawn_qemu $wait_for_re $timeout_value } diff --git a/base-foc/src/base/console/core_console.h b/base-foc/src/base/console/core_console.h new file mode 100644 index 000000000..e5e50de5a --- /dev/null +++ b/base-foc/src/base/console/core_console.h @@ -0,0 +1,30 @@ +/* + * \brief Console backend using the Fiasco kernel debugger + * \author Norman Feske + * \date 2006-04-08 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +/* Genode includes */ +#include + +namespace Genode { + + class Core_console : public Console + { + protected: + + void _out_char(char c) { Fiasco::outchar(c); } + }; +} diff --git a/base-foc/src/base/env/cap_sel_alloc.cc b/base-foc/src/base/env/cap_sel_alloc.cc new file mode 100644 index 000000000..c4ccbae9a --- /dev/null +++ b/base-foc/src/base/env/cap_sel_alloc.cc @@ -0,0 +1,107 @@ +/* + * \brief Capability-selector allocator + * \author Stefan Kalkowski + * \date 2010-12-06 + * + * This is a Fiasco.OC-specific addition to the process enviroment. + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include + +/* Fiasco.OC includes */ +namespace Fiasco { +#include +#include +} + +using namespace Genode; + +/** + * First available capability selector for custom use + * + * Must be initialized by the startup code + */ +static unsigned long __first_free_cap_selector = + Fiasco::Fiasco_capability::USER_BASE_CAP; + +/** + * Low-level lock to protect the allocator + * + * We cannot use a normal Genode lock because this lock is used by code + * executed prior the initialization of Genode. + */ +class Alloc_lock +{ + private: + + int _state; + + public: + + enum State { LOCKED, UNLOCKED }; + + /** + * Constructor + */ + Alloc_lock() : _state(UNLOCKED) {} + + void lock() + { + while (!Genode::cmpxchg(&_state, UNLOCKED, LOCKED)) + Fiasco::l4_ipc_sleep(Fiasco::l4_ipc_timeout(0, 0, 500, 0)); + } + + void unlock() { _state = UNLOCKED; } +}; + + +/** + * Return lock used to protect capability selector allocations + */ +static Alloc_lock *alloc_lock() +{ + static Alloc_lock alloc_lock_inst; + return &alloc_lock_inst; +} + + +addr_t Capability_allocator::alloc(size_t num_caps) +{ + alloc_lock()->lock(); + int ret_base = _cap_idx; + _cap_idx += num_caps * Fiasco::L4_CAP_SIZE; + alloc_lock()->unlock(); + return ret_base; +} + + +void Capability_allocator::free(addr_t cap, size_t num_caps_log2) +{ +// PWRN("Not yet implemented!"); +} + + +Capability_allocator::Capability_allocator() +: _cap_idx(__first_free_cap_selector) +{ + /* initialize lock */ + alloc_lock(); +} + + +Capability_allocator* Capability_allocator::allocator() +{ + static Capability_allocator inst; + return &inst; +} diff --git a/base-foc/src/base/ipc/arm/pager.cc b/base-foc/src/base/ipc/arm/pager.cc new file mode 100644 index 000000000..71dc997f0 --- /dev/null +++ b/base-foc/src/base/ipc/arm/pager.cc @@ -0,0 +1,27 @@ +/* + * \brief Fiasco.OC pager framework + * \author Stefan Kalkowski + * \date 2011-09-08 + * + * ARM specific parts, when handling cpu-exceptions. + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + + +void Genode::Ipc_pager::copy_regs(Thread_state *state) +{ + state->ip = _regs.pc; + state->sp = _regs.sp; + Genode::memcpy(&state->r, &_regs.r, sizeof(state->r)); + state->lr = _regs.ulr; + state->cpsr = _regs.cpsr; +} diff --git a/base-foc/src/base/ipc/arm/pager_exception.cc b/base-foc/src/base/ipc/arm/pager_exception.cc new file mode 100644 index 000000000..248adfc71 --- /dev/null +++ b/base-foc/src/base/ipc/arm/pager_exception.cc @@ -0,0 +1,29 @@ +/* + * \brief ARM-specific pager support for Fiasco.OC + * \author Stefan Kalkowski + * \date 2011-08-24 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +namespace Fiasco { +#include +} + +enum Exceptions { EX_REGS = 0x500000 }; + + +void Genode::Ipc_pager::_parse_exception() +{ + if (Fiasco::l4_utcb_exc()->err == EX_REGS) + _type = PAUSE; + else + _type = EXCEPTION; +} diff --git a/base-foc/src/base/ipc/ipc.cc b/base-foc/src/base/ipc/ipc.cc new file mode 100644 index 000000000..731e29da2 --- /dev/null +++ b/base-foc/src/base/ipc/ipc.cc @@ -0,0 +1,317 @@ +/* + * \brief Implementation of the IPC API for Fiasco.OC + * \author Stefan Kalkowski + * \date 2009-12-03 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* + * l4_msgtag_t (size == 1 mword) format: + * + * -------------------------------------------------------------- + * | label | 4 Bit flags | 6 Bit items | 6 Bit word count | + * -------------------------------------------------------------- + */ + + +/* Genode includes */ +#include +#include +#include +#include + +/* base-foc/src/base/lock */ +#include /* for 'thread_get_my_native_id()' */ + +/* Fiasco.OC includes */ +namespace Fiasco { +#include +#include +#include +#include +#include +} + +using namespace Genode; +using namespace Fiasco; + + +/*************** + ** Utilities ** + ***************/ + +enum Debug { + DEBUG_MSG = 0, + HALT_ON_ERROR = 0 +}; + + +static bool ipc_error(l4_msgtag_t tag, bool print) +{ + int ipc_error = l4_ipc_error(tag, l4_utcb()); + if (ipc_error) { + if (print) { + outstring("Ipc error: "); + outhex32(ipc_error); + outstring(" occurred!\n"); + } + if (HALT_ON_ERROR) + enter_kdebug("Ipc error"); + return true; + } + return false; +} + + +/** + * Copy message registers from UTCB to destination message buffer + */ +static void copy_utcb_to_msgbuf(l4_msgtag_t tag, Msgbuf_base *rcv_msg) +{ + unsigned num_msg_words = l4_msgtag_words(tag); + unsigned num_cap_sel = l4_msgtag_items(tag); + if (num_msg_words == 0 && num_cap_sel == 0) + return; + + /* look up and validate destination message buffer to receive the payload */ + l4_mword_t *msg_buf = (l4_mword_t *)rcv_msg->buf; + if (num_msg_words*sizeof(l4_mword_t) > rcv_msg->size()) { + if (DEBUG_MSG) + outstring("receive message buffer too small"); + num_msg_words = rcv_msg->size()/sizeof(l4_mword_t); + } + + /* read message payload into destination message buffer */ + l4_mword_t *src = (l4_mword_t *)l4_utcb_mr(); + l4_mword_t *dst = (l4_mword_t *)&msg_buf[0]; + for (unsigned i = 0; i < num_msg_words; i++) + *dst++ = *src++; + + rcv_msg->rcv_reset(); +} + + +/** + * Copy message registers from message buffer to UTCB and create message tag. + */ +static l4_msgtag_t copy_msgbuf_to_utcb(Msgbuf_base *snd_msg, unsigned offset, + Native_capability dst) +{ + l4_mword_t *msg_buf = (l4_mword_t *)snd_msg->buf; + unsigned num_msg_words = offset/sizeof(l4_mword_t); + unsigned num_cap_sel = snd_msg->snd_cap_sel_cnt(); + + if (num_msg_words + 2 * num_cap_sel > L4_UTCB_GENERIC_DATA_SIZE) { + if (DEBUG_MSG) + outstring("receive message buffer too small"); + throw Ipc_error(); + } + + /* first copy target label to message buffer */ + msg_buf[0] = dst.local_name(); + + /* store message into UTCB message registers */ + for (unsigned i = 0; i < num_msg_words; i++) + l4_utcb_mr()->mr[i] = msg_buf[i]; + + /* setup flexpages of capabilities to send */ + for (unsigned i = 0; i < num_cap_sel; i++) { + unsigned idx = num_msg_words + 2*i; + l4_utcb_mr()->mr[idx] = L4_ITEM_MAP/* | L4_ITEM_CONT*/; + l4_utcb_mr()->mr[idx + 1] = l4_obj_fpage(snd_msg->snd_cap_sel(i), + 0, L4_FPAGE_RWX).raw; + } + + /* we have consumed capability selectors, reset message buffer */ + snd_msg->snd_reset(); + + return l4_msgtag(0, num_msg_words, num_cap_sel, 0); +} + + +/***************** + ** Ipc_ostream ** + *****************/ + +void Ipc_ostream::_send() +{ + l4_msgtag_t tag = copy_msgbuf_to_utcb(_snd_msg, _write_offset, _dst); + tag = l4_ipc_send(_dst.dst(), l4_utcb(), tag, L4_IPC_NEVER); + if (ipc_error(tag, DEBUG_MSG)) + throw Ipc_error(); + + _write_offset = sizeof(l4_mword_t); +} + + +Ipc_ostream::Ipc_ostream(Native_capability dst, Msgbuf_base *snd_msg) +: + Ipc_marshaller(&snd_msg->buf[0], snd_msg->size()), + _snd_msg(snd_msg), _dst(dst) +{ + _write_offset = sizeof(l4_mword_t); +} + + +/***************** + ** Ipc_istream ** + *****************/ + +void Ipc_istream::_wait() +{ + l4_umword_t label = 0; + addr_t rcv_cap_sel = _rcv_msg->rcv_cap_sel_base(); + for (int i = 0; i < Msgbuf_base::MAX_CAP_ARGS; i++) { + l4_utcb_br()->br[i] = rcv_cap_sel | L4_RCV_ITEM_SINGLE_CAP; + rcv_cap_sel += L4_CAP_SIZE; + } + l4_utcb_br()->bdr = 0; + + l4_msgtag_t tag; + do { + tag = l4_ipc_wait(l4_utcb(), &label, L4_IPC_NEVER); + } while (ipc_error(tag, DEBUG_MSG)); + + /* copy message from the UTCBs message registers to the receive buffer */ + copy_utcb_to_msgbuf(tag, _rcv_msg); + + /* reset unmarshaller */ + _read_offset = sizeof(l4_mword_t); +} + + +Ipc_istream::Ipc_istream(Msgbuf_base *rcv_msg) +: + Ipc_unmarshaller(&rcv_msg->buf[0], rcv_msg->size()), + Native_capability(thread_get_my_native_id(), + Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE]), + _rcv_msg(rcv_msg) +{ + _read_offset = sizeof(l4_mword_t); +} + + +Ipc_istream::~Ipc_istream() { } + + +/**************** + ** Ipc_client ** + ****************/ + +void Ipc_client::_call() +{ + /* copy call message to the UTCBs message registers */ + l4_msgtag_t tag = copy_msgbuf_to_utcb(_snd_msg, _write_offset, _dst); + + addr_t rcv_cap_sel = _rcv_msg->rcv_cap_sel_base(); + for (int i = 0; i < Msgbuf_base::MAX_CAP_ARGS; i++) { + l4_utcb_br()->br[i] = rcv_cap_sel | L4_RCV_ITEM_SINGLE_CAP; + rcv_cap_sel += L4_CAP_SIZE; + } + + tag = l4_ipc_call(_dst.dst(), l4_utcb(), tag, L4_IPC_NEVER); + if (l4_ipc_error(tag, l4_utcb()) == L4_IPC_RECANCELED) + throw Genode::Blocking_canceled(); + if (ipc_error(tag, DEBUG_MSG)) + throw Genode::Ipc_error(); + + /* copy request message from the UTCBs message registers */ + copy_utcb_to_msgbuf(tag, _rcv_msg); + + _write_offset = _read_offset = sizeof(umword_t); +} + + +Ipc_client::Ipc_client(Native_capability const &srv, + Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg) +: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0) { } + + +/**************** + ** Ipc_server ** + ****************/ + +void Ipc_server::_prepare_next_reply_wait() +{ + /* now we have a request to reply */ + _reply_needed = true; + + /* leave space for return value at the beginning of the msgbuf */ + _write_offset = 2*sizeof(umword_t); + + /* receive buffer offset */ + _read_offset = sizeof(umword_t); +} + + +void Ipc_server::_wait() +{ + /* wait for new server request */ + try { Ipc_istream::_wait(); } catch (Blocking_canceled) { } + + /* we only have an unknown implicit reply capability */ + /* _dst = ???; */ + + _prepare_next_reply_wait(); +} + + +void Ipc_server::_reply() +{ + l4_msgtag_t tag = copy_msgbuf_to_utcb(_snd_msg, _write_offset, _dst); + tag = l4_ipc_send(L4_SYSF_REPLY, l4_utcb(), tag, L4_IPC_SEND_TIMEOUT_0); + if (ipc_error(tag, DEBUG_MSG)) + throw Ipc_error(); +} + + +void Ipc_server::_reply_wait() +{ + if (_reply_needed) { + l4_umword_t label; + addr_t rcv_cap_sel = _rcv_msg->rcv_cap_sel_base(); + for (int i = 0; i < Msgbuf_base::MAX_CAP_ARGS; i++) { + l4_utcb_br()->br[i] = rcv_cap_sel | L4_RCV_ITEM_SINGLE_CAP; + rcv_cap_sel += L4_CAP_SIZE; + } + + l4_utcb_br()->bdr &= ~L4_BDR_OFFSET_MASK; + + l4_msgtag_t tag = copy_msgbuf_to_utcb(_snd_msg, _write_offset, _dst); + tag = l4_ipc_reply_and_wait(l4_utcb(), tag, &label, L4_IPC_SEND_TIMEOUT_0); + if (ipc_error(tag, false)) { + /* + * The error conditions could be a message cut (which + * we want to ignore on the server side) or a reply failure + * (for example, if the caller went dead during the call. + * In both cases, we do not reflect the error condition to + * the user but want to wait for the next proper incoming + * message. So let's just wait now. + */ + _wait(); + } else { + + /* copy request message from the UTCBs message registers */ + copy_utcb_to_msgbuf(tag, _rcv_msg); + } + } else + _wait(); + + /* reply capability is implicit in fiasco.oc and unknown to us */ + /* _dst = ???; */ + _prepare_next_reply_wait(); +} + + +Ipc_server::Ipc_server(Msgbuf_base *snd_msg, + Msgbuf_base *rcv_msg) +: Ipc_istream(rcv_msg), + Ipc_ostream(Native_capability(), snd_msg), + _reply_needed(false) +{ } diff --git a/base-foc/src/base/ipc/pager.cc b/base-foc/src/base/ipc/pager.cc new file mode 100644 index 000000000..65e4b69a8 --- /dev/null +++ b/base-foc/src/base/ipc/pager.cc @@ -0,0 +1,110 @@ +/* + * \brief Pager support for Fiasco.OC + * \author Stefan Kalkowski + * \date 2011-01-11 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include +#include + +namespace Fiasco { +#include +} + +using namespace Genode; +using namespace Fiasco; + +void Ipc_pager::_parse(unsigned long label) { + _badge = label & ~0x3; + _parse_msg_type(); + if (_type == PAGEFAULT || _type == EXCEPTION) + _parse_pagefault(); + if (_type == PAUSE || _type == EXCEPTION) + memcpy(&_regs, l4_utcb_exc(), sizeof(l4_exc_regs_t)); +} + + +void Ipc_pager::_parse_pagefault() +{ + if (_tag.is_exception()) { + _pf_addr = l4_utcb_exc_pfa(l4_utcb_exc()); + _pf_ip = l4_utcb_exc_pc(l4_utcb_exc()); + } else { + _pf_addr = l4_utcb_mr()->mr[0]; + _pf_ip = l4_utcb_mr()->mr[1]; + } +} + + +void Ipc_pager::_parse_msg_type() +{ + if (_tag.is_exception() && !l4_utcb_exc_is_pf(l4_utcb_exc())) { + _parse_exception(); + return; + } + + if (_tag.is_page_fault()) + _type = PAGEFAULT; + else { + _type = WAKE_UP; + _pf_ip = l4_utcb_mr()->mr[1]; + } +} + + +void Ipc_pager::wait_for_fault() +{ + l4_umword_t label; + + do { + _tag = l4_ipc_wait(l4_utcb(), &label, L4_IPC_NEVER); + int err = l4_ipc_error(_tag, l4_utcb()); + if (!err) { + _parse(label); + return; + } + PERR("Ipc error %d in pagefault from %lx", err, label & ~0x3); + } while (true); +} + + +void Ipc_pager::reply_and_wait_for_fault() +{ + l4_umword_t label; + l4_msgtag_t snd_tag = l4_msgtag(0, 0, 1, 0); + + l4_umword_t grant = _reply_mapping.grant() ? L4_MAP_ITEM_GRANT : 0; + l4_utcb_mr()->mr[0] = _reply_mapping.dst_addr() | L4_ITEM_MAP | grant; + l4_utcb_mr()->mr[1] = _reply_mapping.fpage().raw; + + _tag = l4_ipc_send_and_wait(_last, l4_utcb(), snd_tag, + &label, L4_IPC_SEND_TIMEOUT_0); + int err = l4_ipc_error(_tag, l4_utcb()); + if (err) { + PERR("Ipc error %d in pagefault from %lx", err, label & ~0x3); + wait_for_fault(); + } else + _parse(label); +} + + +void Ipc_pager::acknowledge_wakeup() +{ + l4_cap_idx_t dst = _last.valid() ? _last : L4_SYSF_REPLY; + + /* answer wakeup call from one of core's region-manager sessions */ + l4_ipc_send(dst, l4_utcb(), l4_msgtag(0, 0, 0, 0), L4_IPC_SEND_TIMEOUT_0); +} + + +Ipc_pager::Ipc_pager() +: Native_capability(Thread_base::myself()->tid(), 0), _badge(0) { } + diff --git a/base-foc/src/base/ipc/x86/pager_exception.cc b/base-foc/src/base/ipc/x86/pager_exception.cc new file mode 100644 index 000000000..2473e656f --- /dev/null +++ b/base-foc/src/base/ipc/x86/pager_exception.cc @@ -0,0 +1,29 @@ +/* + * \brief x86-specific pager support for Fiasco.OC + * \author Stefan Kalkowski + * \date 2011-08-24 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +namespace Fiasco { +#include +} + +enum Exceptions { EX_REGS = 0xff }; + + +void Genode::Ipc_pager::_parse_exception() +{ + if (Fiasco::l4_utcb_exc()->trapno == EX_REGS) + _type = PAUSE; + else + _type = EXCEPTION; +} diff --git a/base-foc/src/base/ipc/x86_32/pager.cc b/base-foc/src/base/ipc/x86_32/pager.cc new file mode 100644 index 000000000..cfed3982b --- /dev/null +++ b/base-foc/src/base/ipc/x86_32/pager.cc @@ -0,0 +1,35 @@ +/* + * \brief Fiasco.OC pager framework + * \author Stefan Kalkowski + * \date 2011-09-08 + * + * X86_32 specific parts, when handling cpu-exceptions. + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + + +void Genode::Ipc_pager::copy_regs(Thread_state *state) +{ + state->ip = _regs.ip; + state->sp = _regs.sp; + state->edi = _regs.edi; + state->esi = _regs.esi; + state->ebp = _regs.ebp; + state->ebx = _regs.ebx; + state->edx = _regs.edx; + state->ecx = _regs.ecx; + state->eax = _regs.eax; + state->gs = _regs.gs; + state->fs = _regs.fs; + state->eflags = _regs.flags; + state->trapno = _regs.trapno; +} diff --git a/base-foc/src/base/ipc/x86_64/pager.cc b/base-foc/src/base/ipc/x86_64/pager.cc new file mode 100644 index 000000000..6e0379754 --- /dev/null +++ b/base-foc/src/base/ipc/x86_64/pager.cc @@ -0,0 +1,42 @@ +/* + * \brief Fiasco.OC pager framework + * \author Stefan Kalkowski + * \date 2011-09-08 + * + * X86_64 specific parts, when handling cpu-exceptions. + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + + +void Genode::Ipc_pager::copy_regs(Thread_state *state) +{ + state->ip = _regs.ip; + state->sp = _regs.sp; + state->r8 = _regs.r8; + state->r9 = _regs.r9; + state->r10 = _regs.r10; + state->r11 = _regs.r11; + state->r12 = _regs.r12; + state->r13 = _regs.r13; + state->r14 = _regs.r14; + state->r15 = _regs.r15; + state->rax = _regs.rax; + state->rbx = _regs.rbx; + state->rcx = _regs.rcx; + state->rdx = _regs.rdx; + state->rdi = _regs.rdi; + state->rsi = _regs.rsi; + state->rbp = _regs.rbp; + state->ss = _regs.ss; + state->eflags = _regs.flags; + state->trapno = _regs.trapno; +} diff --git a/base-foc/src/base/lock/lock_helper.h b/base-foc/src/base/lock/lock_helper.h new file mode 100644 index 000000000..06bbd166d --- /dev/null +++ b/base-foc/src/base/lock/lock_helper.h @@ -0,0 +1,108 @@ +/* + * \brief Fiasco.OC-specific helper functions for the Lock implementation + * \author Stefan Kalkowski + * \author Norman Feske + * \date 2011-02-22 + * + * This file serves as adapter between the generic lock implementation + * in 'lock.cc' and the underlying kernel. + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* Fiasco.OC includes */ +namespace Fiasco { +#include +#include +#include +} + +/** + * Resolve 'Thread_base::myself' when not linking the thread library + * + * This weak symbol is primarily used by test cases. Most other Genode programs + * use the thread library. If the thread library is not used, 'myself' can only + * be called by the main thread, for which 'myself' is defined as zero. + */ +Genode::Thread_base * __attribute__((weak)) Genode::Thread_base::myself() { return 0; } + +/** + * Yield CPU time + */ +static inline void thread_yield() { Fiasco::l4_thread_yield(); } + + +/** + * Custom ExchangeRegisters wrapper for waking up a thread + * + * When waking up an lock applicant, we need to make sure that the thread was + * stopped beforehand. Therefore, we evaluate the previous thread state as + * returned by the 'L4_ExchangeRegisters' call. + * + * \return true if the thread was in blocking state + */ +static inline bool thread_check_stopped_and_restart(Genode::Native_thread_id tid) +{ + using namespace Fiasco; + + Genode::Native_thread_id irq = tid + Fiasco_capability::THREAD_IRQ_CAP; + l4_irq_trigger(irq); + return true; +} + + +static inline Genode::Native_thread_id thread_get_my_native_id() +{ + using namespace Fiasco; + + Genode::Thread_base *myself = Genode::Thread_base::myself(); + return myself ? myself->tid() : Fiasco_capability::MAIN_THREAD_CAP; +} + + +static inline Genode::Native_thread_id thread_invalid_id() +{ + return Genode::Native_thread(); +} + + +/** + * Check if a native thread ID is initialized + * + * \return true if ID is initialized + */ +static inline bool thread_id_valid(Genode::Native_thread_id tid) +{ + return tid.valid(); +} + + +/** + * Yield CPU time to the specified thread + */ +static inline void thread_switch_to(Genode::Native_thread_id tid) +{ + Fiasco::l4_thread_switch(tid); +} + + +/** + * Unconditionally block the calling thread + */ +static inline void thread_stop_myself() +{ + using namespace Fiasco; + + Genode::Native_thread_id irq = thread_get_my_native_id() + + Fiasco_capability::THREAD_IRQ_CAP; + l4_irq_receive(irq, L4_IPC_NEVER); +} diff --git a/base-foc/src/base/pager/pager.cc b/base-foc/src/base/pager/pager.cc new file mode 100644 index 000000000..fc4f7a12c --- /dev/null +++ b/base-foc/src/base/pager/pager.cc @@ -0,0 +1,183 @@ +/* + * \brief Fiasco pager framework + * \author Norman Feske + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-07-14 + * + * FIXME Isn't this file generic? + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include + +/* Fiasco.OC includes */ +namespace Fiasco { +#include +#include +} + +using namespace Genode; + + +/********************** + ** Pager activation ** + **********************/ + +void Pager_activation_base::entry() +{ + Ipc_pager pager; + _cap = Native_capability(Thread_base::_thread_cap); + _cap_valid.unlock(); + + bool reply_pending = false; + while (1) { + + if (reply_pending) + pager.reply_and_wait_for_fault(); + else + pager.wait_for_fault(); + + reply_pending = false; + + if (!_ep) { + PWRN("Pager entrypoint not yet defined"); + continue; + } + + switch (pager.msg_type()) { + + case Ipc_pager::PAGEFAULT: + case Ipc_pager::EXCEPTION: + { + /* lookup referenced object */ + Pager_object *obj = _ep->obj_by_id(pager.badge()); + + if (pager.is_exception()) { + Lock::Guard guard(obj->state.lock); + pager.copy_regs(&obj->state); + obj->state.exceptions++; + obj->state.in_exception = true; + obj->submit_exception_signal(); + continue; + } + + /* handle request */ + if (obj->pager(pager)) { + /* could not resolv - leave thread in pagefault */ + PDBG("Could not resolve pf=%p ip=%p", + (void*)pager.fault_addr(), (void*)pager.fault_ip()); + } else { + pager.set_reply_dst(Native_capability(obj->badge(),0)); + reply_pending = true; + continue; + } + break; + } + + case Ipc_pager::WAKE_UP: + { + /* + * We got a request from one of cores region-manager sessions + * to answer the pending page fault of a resolved region-manager + * client, or to resume a previously paused thread. Hence, we + * have to send a reply to the specified thread and answer the + * call. + */ + Pager_object *obj = _ep->obj_by_id(pager.badge()); + if (!obj) { + PWRN("Got illegal wake-up message from %lx", pager.badge()); + continue; + } + + /* send reply to the caller */ + pager.set_reply_dst(Native_capability()); + pager.acknowledge_wakeup(); + + /* revert exception flag */ + { + Lock::Guard guard(obj->state.lock); + obj->state.in_exception = false; + } + + /* send wake up message to requested thread */ + pager.set_reply_dst(Native_capability(obj->badge(),0)); + pager.acknowledge_wakeup(); + break; + } + + /* + * Handle exceptions that are artificially generated by the pause + * function of the CPU service. + */ + case Ipc_pager::PAUSE: + { + Pager_object *obj = _ep->obj_by_id(pager.badge()); + + Lock::Guard guard(obj->state.lock); + pager.copy_regs(&obj->state); + + obj->state.exceptions++; + obj->state.in_exception = true; + + /* + * It might occur, that the thread raises an exception, + * after it already got resumed by the cpu_session, in + * that case we unblock it immediately. + */ + if (!obj->state.paused) { + pager.set_reply_dst(Native_capability(obj->badge(),0)); + reply_pending = true; + } + break; + } + + default: + PERR("Got unknown message type %x!", pager.msg_type()); + } + }; +} + + +/********************** + ** Pager entrypoint ** + **********************/ + +Pager_entrypoint::Pager_entrypoint(Cap_session *cap_session, + Pager_activation_base *a) +: _activation(a), _cap_session(cap_session) +{ + _activation->ep(this); +} + + +void Pager_entrypoint::dissolve(Pager_object *obj) { remove(obj); } + + +Pager_capability Pager_entrypoint::manage(Pager_object *obj) +{ + using namespace Fiasco; + + /* return invalid capability if no activation is present */ + if (!_activation) return Pager_capability(); + + Native_capability c = _activation->cap(); + Native_capability cap(_cap_session->alloc(c)); + + /* add server object to object pool */ + obj->cap(cap); + insert(obj); + + /* return capability that uses the object id as badge */ + return reinterpret_cap_cast(cap); +} diff --git a/base-foc/src/base/server/server.cc b/base-foc/src/base/server/server.cc new file mode 100644 index 000000000..020bd4c6a --- /dev/null +++ b/base-foc/src/base/server/server.cc @@ -0,0 +1,39 @@ +/* + * \brief Default version of platform-specific part of server framework + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2006-05-12 + * + * This version is suitable for platforms similar to L4. Each platform + * for which this implementation is not suited contains a platform- + * specific version in its respective 'base-' repository. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +using namespace Genode; + + +/*********************** + ** Server entrypoint ** + ***********************/ + +Untyped_capability Rpc_entrypoint::_manage(Rpc_object_base *obj) +{ + Untyped_capability new_obj_cap = _cap_session->alloc(_cap); + + /* add server object to object pool */ + obj->cap(new_obj_cap); + insert(obj); + + /* return capability that uses the object id as badge */ + return new_obj_cap; +} diff --git a/base-foc/src/base/thread/thread.cc b/base-foc/src/base/thread/thread.cc new file mode 100644 index 000000000..a9ab1a7d4 --- /dev/null +++ b/base-foc/src/base/thread/thread.cc @@ -0,0 +1,200 @@ +/* + * \brief Implementation of the Thread API + * \author Norman Feske + * \date 2010-01-11 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include +#include +#include +#include + +namespace Fiasco { +#include +} + +using namespace Genode; + + +/** + * Return the managed dataspace holding the thread context area + * + * This function is provided by the process environment. + */ +namespace Genode { + Rm_session *env_context_area_rm_session(); + Ram_session *env_context_area_ram_session(); +} + + +/****************************** + ** Thread-context allocator ** + ******************************/ + +Thread_base::Context *Thread_base::Context_allocator::base_to_context(addr_t base) +{ + addr_t result = base + CONTEXT_VIRTUAL_SIZE - sizeof(Context); + return reinterpret_cast(result); +} + + +addr_t Thread_base::Context_allocator::addr_to_base(void *addr) +{ + return ((addr_t)addr) & CONTEXT_VIRTUAL_BASE_MASK; +} + + +bool Thread_base::Context_allocator::_is_in_use(addr_t base) +{ + List_element *le = _threads.first(); + for (; le; le = le->next()) + if (base_to_context(base) == le->object()->_context) + return true; + + return false; +} + + +Thread_base::Context *Thread_base::Context_allocator::alloc(Thread_base *thread_base) +{ + Lock::Guard _lock_guard(_threads_lock); + + /* + * Find slot in context area for the new context + */ + addr_t base = CONTEXT_AREA_VIRTUAL_BASE; + for (; _is_in_use(base); base += CONTEXT_VIRTUAL_SIZE) { + + /* check upper bound of context area */ + if (base >= CONTEXT_AREA_VIRTUAL_BASE + CONTEXT_AREA_VIRTUAL_SIZE) + return 0; + } + + _threads.insert(&thread_base->_list_element); + + return base_to_context(base); +} + + +void Thread_base::Context_allocator::free(Thread_base *thread_base) +{ + Lock::Guard _lock_guard(_threads_lock); + + _threads.remove(&thread_base->_list_element); +} + + +/***************** + ** Thread base ** + *****************/ + +Thread_base::Context_allocator *Thread_base::_context_allocator() +{ + static Context_allocator context_allocator_inst; + return &context_allocator_inst; +} + + +Thread_base::Context *Thread_base::_alloc_context(size_t stack_size) +{ + /* + * Synchronize context list when creating new threads from multiple threads + * + * XXX: remove interim fix + */ + static Lock alloc_lock; + Lock::Guard _lock_guard(alloc_lock); + + /* allocate thread context */ + Context *context = _context_allocator()->alloc(this); + if (!context) + throw Context_alloc_failed(); + + /* determine size of dataspace to allocate for context members and stack */ + enum { PAGE_SIZE_LOG2 = 12 }; + size_t ds_size = align_addr(stack_size, PAGE_SIZE_LOG2); + + if (stack_size >= CONTEXT_VIRTUAL_SIZE - sizeof(Native_utcb) - (1 << PAGE_SIZE_LOG2)) + throw Stack_too_large(); + + /* + * Calculate base address of the stack + * + * The stack is always located at the top of the context. + */ + addr_t ds_addr = Context_allocator::addr_to_base(context) + CONTEXT_VIRTUAL_SIZE + - ds_size; + + /* add padding for UTCB if defined for the platform */ + if (sizeof(Native_utcb) >= (1 << PAGE_SIZE_LOG2)) + ds_addr -= sizeof(Native_utcb); + + /* allocate and attach backing store for the stack */ + Ram_dataspace_capability ds_cap; + try { + ds_cap = env_context_area_ram_session()->alloc(ds_size); + addr_t attach_addr = ds_addr - CONTEXT_AREA_VIRTUAL_BASE; + env_context_area_rm_session()->attach_at(ds_cap, attach_addr, ds_size); + + } catch (Ram_session::Alloc_failed) { + throw Stack_alloc_failed(); + } + + /* + * Now the thread context is backed by memory, so it is safe to access its + * members. + */ + + context->thread_base = this; + context->stack_base = ds_addr; + context->ds_cap = ds_cap; + return context; +} + + +void Thread_base::_free_context() +{ + addr_t ds_addr = _context->stack_base - CONTEXT_AREA_VIRTUAL_BASE; + Ram_dataspace_capability ds_cap = _context->ds_cap; + Genode::env_context_area_rm_session()->detach((void *)ds_addr); + Genode::env_context_area_ram_session()->free(ds_cap); + _context_allocator()->free(this); +} + + +void Thread_base::name(char *dst, size_t dst_len) +{ + snprintf(dst, min(dst_len, (size_t)Context::NAME_LEN), _context->name); +} + + +Thread_base *Thread_base::myself() { + using namespace Fiasco; + + return reinterpret_cast(l4_utcb_tcr()->user[UTCB_TCR_THREAD_OBJ]); +} + + +Thread_base::Thread_base(const char *name, size_t stack_size) +: + _list_element(this), + _context(_alloc_context(stack_size)) +{ + strncpy(_context->name, name, sizeof(_context->name)); + _init_platform_thread(); +} + + +Thread_base::~Thread_base() +{ + _deinit_platform_thread(); + _free_context(); +} diff --git a/base-foc/src/base/thread/thread_bootstrap.cc b/base-foc/src/base/thread/thread_bootstrap.cc new file mode 100644 index 000000000..a664e3b37 --- /dev/null +++ b/base-foc/src/base/thread/thread_bootstrap.cc @@ -0,0 +1,51 @@ +/* + * \brief Fiasco.OC specific thread bootstrap code + * \author Stefan Kalkowski + * \date 2011-01-20 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include +#include +#include + +namespace Fiasco { +#include +} + +void Genode::Thread_base::_thread_bootstrap() +{ + using namespace Genode; + using namespace Fiasco; + + /* first, receive my own gate-capability and badge from starter thread */ + addr_t thread_base = 0; + unsigned long my_badge = 0; + Msgbuf<128> snd_msg, rcv_msg; + Ipc_server srv(&snd_msg, &rcv_msg); + srv >> IPC_WAIT >> thread_base >> my_badge << IPC_REPLY; + + /* store both values in user-defined section of the UTCB */ + l4_utcb_tcr()->user[UTCB_TCR_BADGE] = my_badge; + l4_utcb_tcr()->user[UTCB_TCR_THREAD_OBJ] = thread_base; +} + + +void Genode::Thread_base::_thread_start() +{ + using namespace Genode; + + Thread_base::myself()->_thread_bootstrap(); + Thread_base::myself()->entry(); + sleep_forever(); +} + + +void Genode::Thread_base::_init_platform_thread() { } diff --git a/base-foc/src/base/thread/thread_start.cc b/base-foc/src/base/thread/thread_start.cc new file mode 100644 index 000000000..d5c578cde --- /dev/null +++ b/base-foc/src/base/thread/thread_start.cc @@ -0,0 +1,67 @@ +/* + * \brief Fiasco-specific implementation of the non-core startup Thread API + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2010-01-19 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include + +using namespace Genode; + + +void Thread_base::_deinit_platform_thread() +{ + env()->cpu_session()->kill_thread(_thread_cap); +} + + +void Thread_base::start() +{ + /* create thread at core */ + char buf[48]; + name(buf, sizeof(buf)); + _thread_cap = env()->cpu_session()->create_thread(buf); + + /* assign thread to protection domain */ + env()->pd_session()->bind_thread(_thread_cap); + + /* create new pager object and assign it to the new thread */ + Pager_capability pager_cap = env()->rm_session()->add_client(_thread_cap); + env()->cpu_session()->set_pager(_thread_cap, pager_cap); + + /* register initial IP and SP at core */ + addr_t thread_sp = (addr_t)&_context->stack[-4]; + thread_sp &= ~0xf; /* align initial stack to 16 byte boundary */ + env()->cpu_session()->start(_thread_cap, (addr_t)_thread_start, thread_sp); + + /* get gate-capability and badge of new thread */ + Thread_state state; + env()->cpu_session()->state(_thread_cap, &state); + _tid = state.cap.dst(); + + /* + * send newly constructed thread, pointer to its Thread_base object, + * and its badge + */ + Msgbuf<128> snd_msg, rcv_msg; + Ipc_client cli(state.cap, &snd_msg, &rcv_msg); + cli << (addr_t)this << state.cap.local_name() << IPC_CALL; +} + + +void Thread_base::cancel_blocking() +{ + env()->cpu_session()->cancel_blocking(_thread_cap); +} diff --git a/base-foc/src/bootstrap/target.mk b/base-foc/src/bootstrap/target.mk new file mode 100644 index 000000000..de8e348be --- /dev/null +++ b/base-foc/src/bootstrap/target.mk @@ -0,0 +1,5 @@ +TARGET = bootstrap +PKGS = drivers-frst/of drivers-frst/uart bootstrap +LIBS = l4re_support + +include $(REP_DIR)/mk/l4_pkg.mk diff --git a/base-foc/src/core/arm/platform_arm.cc b/base-foc/src/core/arm/platform_arm.cc new file mode 100644 index 000000000..bb5f8dc08 --- /dev/null +++ b/base-foc/src/core/arm/platform_arm.cc @@ -0,0 +1,16 @@ +/* + * \brief Platform support specific to ARM + * \author Norman Feske + * \date 2011-05-02 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +void Genode::Platform::_setup_io_port_alloc() { } diff --git a/base-foc/src/core/arm/platform_thread.cc b/base-foc/src/core/arm/platform_thread.cc new file mode 100644 index 000000000..5959c5b94 --- /dev/null +++ b/base-foc/src/core/arm/platform_thread.cc @@ -0,0 +1,25 @@ +/* + * \brief Fiasco.OC thread facility (arm specifics) + * \author Stefan Kalkowski + * \date 2011-09-08 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include + + +bool Genode::Platform_thread::_in_syscall(Fiasco::l4_umword_t flags) +{ + return flags == 0; +} diff --git a/base-foc/src/core/arm/target.mk b/base-foc/src/core/arm/target.mk new file mode 100644 index 000000000..89dee1de3 --- /dev/null +++ b/base-foc/src/core/arm/target.mk @@ -0,0 +1,7 @@ +include $(PRG_DIR)/../target.inc + +REQUIRES += arm +SRC_CC += arm/platform_arm.cc arm/platform_thread.cc + +vpath io_port_session_component.cc $(GEN_CORE_DIR)/arm + diff --git a/base-foc/src/core/cap_session_component.cc b/base-foc/src/core/cap_session_component.cc new file mode 100644 index 000000000..2991411a7 --- /dev/null +++ b/base-foc/src/core/cap_session_component.cc @@ -0,0 +1,230 @@ +/* + * \brief Fiasco.oc platform-specific capability allocation + * \author Stefan Kalkowski + * \date 2011-01-13 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include +#include + +namespace Fiasco { +#include +#include +#include +#include +} + +using namespace Genode; + + +/***************************** + ** Cap_session_component ** + *****************************/ + +Native_capability Cap_session_component::alloc(Cap_session_component *session, + Native_capability ep) +{ + Native_capability cap; + + if (!ep.valid()) { + PWRN("Invalid cap!"); + return Native_capability(); + } + + /* + * maybe someone tries to fool us, proof whether cap exists in cap tree. + * + * Actually we should proof whether both capability selectors + * point to the same object, but this isn't possible in fiasco.oc. + */ + Capability_node *n = Capability_tree::tree()->find_by_badge(ep.local_name()); + if (!n) { + PWRN("Unknown capability!"); + return cap; + } + + + try { + using namespace Fiasco; + + /* + * Allocate new badge, and ipc-gate and set badge as gate-label + */ + unsigned long badge = Badge_allocator::allocator()->alloc(); + Native_thread gate = Capability_allocator::allocator()->alloc(); + l4_msgtag_t tag = l4_factory_create_gate(L4_BASE_FACTORY_CAP, + gate, + n->pt()->native_thread(), + badge); + if (l4_msgtag_has_error(tag)) { + PERR("l4_factory_create_gate failed!"); + Capability_allocator::allocator()->free(gate); + Badge_allocator::allocator()->free(badge); + return cap; + } else + /* set debugger-name of ipc-gate to thread's name */ + Fiasco::l4_debugger_set_object_name(gate, n->pt()->name()); + + /* + * Create new node in capability tree. + * + * TODO: don't use core_mem_alloc, but a session-specific allocator + */ + Capability_node *new_node = new (platform()->core_mem_alloc()) + Capability_node(badge, session, n->pt(), gate); + Capability_tree::tree()->insert(new_node); + cap = Native_capability(gate, badge); + + } catch (Badge_allocator::Out_of_badges) {} + + return cap; +} + + +Native_capability Cap_session_component::alloc(Native_capability ep) +{ + return Cap_session_component::alloc(this, ep); +} + + +void Cap_session_component::free(Native_capability cap) +{ + using namespace Fiasco; + + Capability_node *n = Capability_tree::tree()->find_by_badge(cap.local_name()); + if (!n) + return; + + /* + * check whether this cap_session has created the capability to delete. + * + * Actually we should proof whether both capability selectors + * point to the same object, but this isn't possible in fiasco.oc. + */ + if (n->cap_session() != this) + return; + + Capability_tree::tree()->remove(n); + Badge_allocator::allocator()->free(n->badge()); + l4_msgtag_t tag = l4_task_unmap(L4_BASE_TASK_CAP, + l4_obj_fpage(cap.dst(), 0, 0), + L4_FP_ALL_SPACES | L4_FP_DELETE_OBJ); + if (l4_msgtag_has_error(tag)) + PERR("destruction of ipc-gate %lx failed!", (unsigned long) cap.dst()); + + /* free explicilty allocated cap-selector */ + Capability_allocator::allocator()->free(n->gate()); + + destroy(platform_specific()->core_mem_alloc(), n); +} + + +/*********************** + ** Badge Allocator ** + ***********************/ + +Badge_allocator::Badge_allocator() +: _id_alloc(platform_specific()->core_mem_alloc()) +{ + _id_alloc.add_range(BADGE_OFFSET, BADGE_RANGE); +} + + +unsigned long Badge_allocator::alloc() +{ + Lock::Guard lock_guard(_lock); + + void *badge; + if (_id_alloc.alloc(BADGE_OFFSET, &badge)) + return (unsigned long) badge; + throw Out_of_badges(); +} + + +void Badge_allocator::free(unsigned long badge) +{ + Lock::Guard lock_guard(_lock); + + if (badge < BADGE_RANGE) + _id_alloc.free((void*)(badge & BADGE_MASK), BADGE_OFFSET); +} + + +Badge_allocator* Badge_allocator::allocator() +{ + static Badge_allocator alloc; + return &alloc; +} + + +/*********************** + ** Capability_node ** + ***********************/ + +Capability_node::Capability_node(unsigned long badge, + Cap_session_component *cap_session, + Platform_thread *pt, + Native_thread gate) +: _badge(badge), _cap_session(cap_session), _pt(pt), _gate(gate) {} + + +bool Capability_node::higher(Capability_node *n) +{ + return n->_badge > _badge; +} + + +Capability_node* Capability_node::find_by_badge(unsigned long badge) +{ + if (_badge == badge) return this; + + Capability_node *n = Avl_node::child(badge > _badge); + return n ? n->find_by_badge(badge) : 0; +} + + +/*********************** + ** Capability_tree ** + ***********************/ + +void Capability_tree::insert(Avl_node *node) +{ + Lock::Guard lock_guard(_lock); + + Avl_tree::insert(node); +} + + +void Capability_tree::remove(Avl_node *node) +{ + Lock::Guard lock_guard(_lock); + + Avl_tree::remove(node); +} + + +Capability_node* Capability_tree::find_by_badge(unsigned long badge) +{ + Lock::Guard lock_guard(_lock); + + return first()->find_by_badge(badge); +} + + +Capability_tree* Capability_tree::tree() +{ + static Capability_tree _tree; + return &_tree; +} diff --git a/base-foc/src/core/cpu_session_extension.cc b/base-foc/src/core/cpu_session_extension.cc new file mode 100644 index 000000000..466aa1310 --- /dev/null +++ b/base-foc/src/core/cpu_session_extension.cc @@ -0,0 +1,87 @@ +/** + * \brief Core implementation of the CPU session interface extension + * \author Stefan Kalkowski + * \date 2011-04-04 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Core includes */ +#include + +/* Fiasco.OC includes */ +namespace Fiasco { +#include +#include +} + + +void Genode::Cpu_session_component::enable_vcpu(Genode::Thread_capability thread_cap, + Genode::addr_t vcpu_state) +{ + using namespace Genode; + using namespace Fiasco; + + Lock::Guard lock_guard(_thread_list_lock); + + Cpu_thread_component *thread = _lookup_thread(thread_cap); + if (!thread) return; + + Native_thread tid = thread->platform_thread()->native_thread(); + + l4_msgtag_t tag = l4_thread_vcpu_control(tid, vcpu_state); + if (l4_msgtag_has_error(tag)) + PWRN("l4_thread_vcpu_control failed"); +} + + +Genode::Native_capability +Genode::Cpu_session_component::native_cap(Genode::Thread_capability cap) +{ + using namespace Genode; + + Lock::Guard lock_guard(_thread_list_lock); + + Cpu_thread_component *thread = _lookup_thread(cap); + if (!thread) return Native_capability(); + + return Native_capability(thread->platform_thread()->native_thread(), -1); +} + + +Genode::Native_capability Genode::Cpu_session_component::alloc_irq() +{ + using namespace Fiasco; + + Fiasco_capability irq_cap(Genode::Capability_allocator::allocator()->alloc()); + l4_msgtag_t res = l4_factory_create_irq(L4_BASE_FACTORY_CAP, irq_cap); + if (l4_error(res)) + PWRN("Allocation of irq object failed!"); + return Genode::Native_capability(irq_cap, -1); +} + + +void Genode::Cpu_session_component::single_step(Genode::Thread_capability thread_cap, bool enable) +{ + using namespace Genode; + + Lock::Guard lock_guard(_thread_list_lock); + + Cpu_thread_component *thread = _lookup_thread(thread_cap); + if (!thread) return; + + Native_thread tid = thread->platform_thread()->native_thread(); + + enum { THREAD_SINGLE_STEP = 0x40000 }; + int flags = enable ? THREAD_SINGLE_STEP : 0; + + Fiasco::l4_thread_ex_regs(tid, ~0UL, ~0UL, flags); +} diff --git a/base-foc/src/core/include/cap_session_component.h b/base-foc/src/core/include/cap_session_component.h new file mode 100644 index 000000000..995cf9d37 --- /dev/null +++ b/base-foc/src/core/include/cap_session_component.h @@ -0,0 +1,118 @@ +/* + * \brief Capability allocation service + * \author Stefan Kalkowski + * \date 2011-01-13 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__CAP_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__CAP_SESSION_COMPONENT_H_ + +/* Genode includes */ +#include +#include +#include +#include +#include + +namespace Genode { + + class Cap_session_component : public Rpc_object + { + private: + + static long _unique_id_cnt; /* TODO: remove this from generic core code */ + + public: + + Native_capability alloc(Native_capability ep); + + void free(Native_capability cap); + + static Native_capability alloc(Cap_session_component *session, + Native_capability ep); + }; + + + class Badge_allocator + { + private: + + enum { + BADGE_RANGE = ~0UL, + BADGE_MASK = ~3UL, + BADGE_NUM_MAX = BADGE_MASK >> 2, + BADGE_OFFSET = 1 << 2 + }; + + Synchronized_range_allocator _id_alloc; + Lock _lock; + + Badge_allocator(); + + public: + + class Out_of_badges : Exception {}; + + unsigned long alloc(); + void free(unsigned long badge); + + static Badge_allocator* allocator(); + }; + + + class Platform_thread; + class Capability_node : public Avl_node + { + private: + + unsigned long _badge; + Cap_session_component *_cap_session; + Platform_thread *_pt; + Native_thread _gate; + + public: + + Capability_node(unsigned long badge, + Cap_session_component *cap_session, + Platform_thread *pt, + Native_thread gate); + + bool higher(Capability_node *n); + + Capability_node *find_by_badge(unsigned long badge); + + unsigned long badge() { return _badge; } + Cap_session_component *cap_session() { return _cap_session; } + Platform_thread *pt() { return _pt; } + Native_thread gate() { return _gate; } + }; + + + class Capability_tree : public Avl_tree + { + private: + + Lock _lock; + + Capability_tree() {} + + public: + + void insert(Avl_node *node); + + void remove(Avl_node *node); + + Capability_node *find_by_badge(unsigned long badge); + + static Capability_tree* tree(); + }; +} + +#endif /* _CORE__INCLUDE__CAP_SESSION_COMPONENT_H_ */ diff --git a/base-foc/src/core/include/cpu_session_component.h b/base-foc/src/core/include/cpu_session_component.h new file mode 100644 index 000000000..7ed3cfff4 --- /dev/null +++ b/base-foc/src/core/include/cpu_session_component.h @@ -0,0 +1,155 @@ +/* + * \brief Core-specific instance of the CPU session/thread interfaces + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-07-17 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_ + +/* Genode includes */ +#include +#include +#include +#include +#include +#include +#include + +/* core includes */ +#include + +namespace Genode { + + /** + * RPC interface of CPU thread + * + * We make 'Cpu_thread' a RPC object only to be able to lookup CPU threads + * from thread capabilities supplied as arguments to CPU-session functions. + * A CPU thread does not provide an actual RPC interface. + */ + struct Cpu_thread + { + GENODE_RPC_INTERFACE(); + }; + + + class Cpu_thread_component : public Rpc_object, + public List::Element + { + private: + + Platform_thread _platform_thread; + + bool _bound; /* pd binding flag */ + + public: + + Cpu_thread_component(const char *name, unsigned priority) + : _platform_thread(name, priority), _bound(false) { } + + + /************************ + ** Accessor functions ** + ************************/ + + inline Platform_thread * platform_thread() { return &_platform_thread; } + inline bool bound() const { return _bound; } + inline void bound(bool b) { _bound = b; } + }; + + + class Cpu_session_component : public Rpc_object + { + private: + + /** + * Allocator used for managing the CPU threads associated with the + * CPU session + */ + typedef Tslab Cpu_thread_allocator; + + Rpc_entrypoint *_thread_ep; + Pager_entrypoint *_pager_ep; + Allocator_guard _md_alloc; /* guarded meta-data allocator */ + Cpu_thread_allocator _slab; /* meta-data allocator */ + Lock _slab_lock; /* protect slab access */ + List _thread_list; + Lock _thread_list_lock; /* protect thread list */ + unsigned _priority; /* priority of threads + created with this + session */ + + /** + * Lookup thread in CPU session by its capability + * + * \retval NULL thread capability is invalid or + * does not belong to the CPU session + */ + Cpu_thread_component *_lookup_thread(Thread_capability thread) { + return dynamic_cast + (_thread_ep->obj_by_cap(thread)); } + + /** + * Raw thread-killing functionality + * + * This function is called from the 'kill_thread' function and + * the destructor. Each these functions grab the list lock + * by themselves and call this function to perform the actual + * killing. + */ + void _unsynchronized_kill_thread(Cpu_thread_component *thread); + + public: + + /** + * Constructor + */ + Cpu_session_component(Rpc_entrypoint *thread_ep, + Pager_entrypoint *pager_ep, + Allocator *md_alloc, const char *args); + + /** + * Destructor + */ + ~Cpu_session_component(); + + + /*************************** + ** CPU session interface ** + ***************************/ + + Thread_capability create_thread(Name const &); + void kill_thread(Thread_capability); + Thread_capability first(); + Thread_capability next(Thread_capability); + int set_pager(Thread_capability, Pager_capability); + int start(Thread_capability, addr_t, addr_t); + void pause(Thread_capability thread_cap); + void resume(Thread_capability thread_cap); + void single_step(Thread_capability thread_cap, bool enable); + void cancel_blocking(Thread_capability); + int name(Thread_capability, char *, size_t); + int state(Thread_capability, Thread_state *); + void exception_handler(Thread_capability, Signal_context_capability); + + + /*********************************** + ** Fiasco.OC specific extensions ** + ***********************************/ + + void enable_vcpu(Thread_capability, addr_t); + Native_capability native_cap(Thread_capability); + Native_capability alloc_irq(); + }; +} + +#endif /* _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_ */ diff --git a/base-foc/src/core/include/irq_session_component.h b/base-foc/src/core/include/irq_session_component.h new file mode 100644 index 000000000..728d6eab9 --- /dev/null +++ b/base-foc/src/core/include/irq_session_component.h @@ -0,0 +1,113 @@ +/* + * \brief IRQ session interface for Fiasco.OC + * \author Stefan Kalkowski + * \date 2011-01-28 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ + +#include +#include +#include +#include + +#include + +namespace Genode { + + class Irq_session_component : public Rpc_object, + public List::Element + { + private: + + class Interrupt : public Avl_node + { + private: + + Native_thread _cap; + Semaphore _sem; + + public: + + unsigned number; + + Interrupt(); + + bool higher(Interrupt *n); + Interrupt* find_by_num(unsigned num); + + Native_thread capability() { return _cap; } + Semaphore* semaphore() { return &_sem; } + }; + + + class Interrupt_handler : public Thread<4096> + { + private: + + Interrupt_handler() { start(); } + + void entry(); + + public: + + static Native_thread handler_cap(); + }; + + + Interrupt _irq; + Range_allocator *_irq_alloc; + + /* + * Each IRQ session uses a dedicated server activation + */ + enum { STACK_SIZE = 2048 }; + Rpc_entrypoint _ep; + + Irq_session_capability _irq_cap; + + static Avl_tree* _irqs(); + + public: + + /** + * Constructor + * + * \param cap_session capability session to use + * \param irq_alloc platform-dependent IRQ allocator + * \param args session construction arguments + */ + Irq_session_component(Cap_session *cap_session, + Range_allocator *irq_alloc, + const char *args); + + /** + * Destructor + */ + ~Irq_session_component(); + + /** + * Return capability to this session + * + * If an initialization error occurs, returned capability is invalid. + */ + Irq_session_capability cap() const { return _irq_cap; } + + + /*************************** + ** Irq session interface ** + ***************************/ + + void wait_for_irq(); + }; +} + +#endif /* _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ */ diff --git a/base-foc/src/core/include/map_local.h b/base-foc/src/core/include/map_local.h new file mode 100644 index 000000000..73cee97fd --- /dev/null +++ b/base-foc/src/core/include/map_local.h @@ -0,0 +1,66 @@ +/* + * \brief Core-local mapping + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2010-02-15 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__MAP_LOCAL_H_ +#define _CORE__INCLUDE__MAP_LOCAL_H_ + +/* core includes */ +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +namespace Genode { + + /** + * Map page locally within core + * + * On Fiasco, all mapping originate from virtual addresses. At startup, + * core obtains the whole memory sigma0 in a one-to-one fashion. Hence, + * core-local addresses normally correspond to physical addresses. + * + * \param from_addr core-virtual source address + * \param to_addr core-virtual destination address + * \param num_pages number of pages to remap + */ + inline bool map_local(addr_t from_addr, addr_t to_addr, size_t num_pages) + { + addr_t offset = 0; + size_t page_size = get_page_size(); + size_t page_size_log2 = get_page_size_log2(); + for (unsigned i = 0; i < num_pages; i++, offset += page_size) { + + using namespace Fiasco; + + l4_fpage_t snd_fpage = l4_fpage(from_addr + offset, + page_size_log2, L4_FPAGE_RW); + + if (l4_msgtag_has_error(l4_task_map(L4_BASE_TASK_CAP, + L4_BASE_TASK_CAP, + snd_fpage, + to_addr + offset))) { + PWRN("could not locally remap 0x%lx to 0x%lx", from_addr, to_addr); + return false; + } + } + + return true; + } +} + +#endif /* _CORE__INCLUDE__MAP_LOCAL_H_ */ + diff --git a/base-foc/src/core/include/pd_session_component.h b/base-foc/src/core/include/pd_session_component.h new file mode 100644 index 000000000..2f0490b1f --- /dev/null +++ b/base-foc/src/core/include/pd_session_component.h @@ -0,0 +1,57 @@ +/* + * \brief Core-specific instance of the PD session interface + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-07-17 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PD_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__PD_SESSION_COMPONENT_H_ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include + +namespace Genode { + + class Pd_session_component : public Rpc_object + { + private: + + Platform_pd _pd; + Parent_capability _parent; + Rpc_entrypoint *_thread_ep; + + public: + + Pd_session_component(Rpc_entrypoint *thread_ep, const char *args) + : _thread_ep(thread_ep) { } + + + /************************** + ** PD session interface ** + **************************/ + + int bind_thread(Thread_capability); + int assign_parent(Parent_capability); + + + /********************************** + ** Fiasco.OC specific functions ** + **********************************/ + + Native_capability task_cap(); + }; +} + +#endif /* _CORE__INCLUDE__PD_SESSION_COMPONENT_H_ */ diff --git a/base-foc/src/core/include/platform.h b/base-foc/src/core/include/platform.h new file mode 100644 index 000000000..7052fb68a --- /dev/null +++ b/base-foc/src/core/include/platform.h @@ -0,0 +1,157 @@ +/* + * \brief Fiasco platform + * \author Christian Helmuth + * \author Norman Feske + * \date 2007-09-10 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_H_ +#define _CORE__INCLUDE__PLATFORM_H_ + +#include +#include + +#include "platform_generic.h" +#include "platform_thread.h" +#include "platform_pd.h" +#include "multiboot.h" + + +namespace Genode { + + class Platform : public Platform_generic + { + private: + + /* + * Shortcut for the type of allocator instances for physical resources + */ + typedef Synchronized_range_allocator Phys_allocator; + + Platform_pd *_core_pd; /* core protection domain object */ + Phys_allocator _ram_alloc; /* RAM allocator */ + Phys_allocator _io_mem_alloc; /* MMIO allocator */ + Phys_allocator _io_port_alloc; /* I/O port allocator */ + Phys_allocator _irq_alloc; /* IRQ allocator */ + Phys_allocator _region_alloc; /* virtual memory allocator for core */ + Multiboot_info _mb_info; /* multiboot information */ + Rom_fs _rom_fs; /* ROM file system */ + Rom_module _kip_rom; /* ROM module for Fiasco KIP */ + + addr_t _vm_start; /* begin of virtual memory */ + size_t _vm_size; /* size of virtual memory */ + + /* + * We do not export any boot module loaded before FIRST_ROM. + */ + enum { FIRST_ROM = 3 }; + + /** + * Setup base resources + * + * - Map and provide KIP as ROM module + * - Initializes region allocator + * - Initializes multiboot info structure + */ + void _setup_basics(); + + /** + * Setup RAM, IO_MEM, and region allocators + */ + void _setup_mem_alloc(); + + /** + * Setup I/O port space allocator + */ + void _setup_io_port_alloc(); + + /** + * Setup IRQ allocator + */ + void _setup_irq_alloc(); + + /** + * Parse multi-boot information and update ROM database + */ + void _setup_rom(); + + /** + * Setup pager for core-internal threads + */ + void _setup_core_pager(); + + public: + + /** + * Pager object representing the pager of core namely sigma0 + */ + struct Sigma0 : public Pager_object + { + /** + * Constructor + */ + Sigma0(); + + int pager(Ipc_pager &ps) { /* never called */ return -1; } + }; + + /** + * Return singleton instance of Sigma0 pager object + */ + static Sigma0 *sigma0(); + + /** + * Core pager thread that handles core-internal page-faults + */ + struct Core_pager : public Platform_thread, public Pager_object + { + /** + * Constructor + */ + Core_pager(Platform_pd *core_pd); + + int pager(Ipc_pager &ps) { /* never called */ return -1; } + }; + + /** + * Return singleton instance of core pager object + */ + Core_pager *core_pager(); + + /** + * Constructor + */ + Platform(); + + /** + * Accessor for core pd object + */ + Platform_pd *core_pd() { return _core_pd; } + + + /******************************** + ** Generic platform interface ** + ********************************/ + + Allocator *core_mem_alloc() { return &_ram_alloc; } + Range_allocator *ram_alloc() { return &_ram_alloc; } + Range_allocator *io_mem_alloc() { return &_io_mem_alloc; } + Range_allocator *io_port_alloc() { return &_io_port_alloc; } + Range_allocator *irq_alloc() { return &_irq_alloc; } + Range_allocator *region_alloc() { return &_region_alloc; } + addr_t vm_start() const { return _vm_start; } + size_t vm_size() const { return _vm_size; } + Rom_fs *rom_fs() { return &_rom_fs; } + + void wait_for_exit(); + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_H_ */ diff --git a/base-foc/src/core/include/platform_pd.h b/base-foc/src/core/include/platform_pd.h new file mode 100644 index 000000000..5ae2713b8 --- /dev/null +++ b/base-foc/src/core/include/platform_pd.h @@ -0,0 +1,116 @@ +/* + * \brief L4/Fiasco protection domain facility + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-04-11 + * + * Protection domains are L4 tasks under Fiasco.OC and serve as base + * container for the platform. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_PD_H_ +#define _CORE__INCLUDE__PLATFORM_PD_H_ + +#include +#include +#include +#include +#include + +namespace Fiasco { +#include +} + +namespace Genode { + + class Platform_thread; + class Platform_pd + { + private: + + enum { + THREAD_MAX = (1 << 6), + UTCB_AREA_SIZE = (THREAD_MAX * Fiasco::L4_UTCB_OFFSET), + UTCB_AREA_START = (Thread_base::CONTEXT_AREA_VIRTUAL_BASE + + THREAD_MAX * Thread_base::CONTEXT_VIRTUAL_SIZE) + }; + + Native_task _l4_task_cap; /* L4 task capability slot */ + Native_capability _parent; + bool _parent_cap_mapped; + bool _task_cap_mapped; + Platform_thread *_threads[THREAD_MAX]; + + /** + * Protection-domain creation + * + * The syscall parameter propagates if any L4 kernel function + * should be used. We need the special case for the Core startup. + */ + void _create_pd(bool syscall); + + /** + * Protection domain destruction + * + * No special case for Core here - we just never call it. + */ + void _destroy_pd(); + + public: + + class Threads_exhausted : Exception {}; + + + /** + * Constructor + */ + Platform_pd(bool create = true, + Native_task task_cap = Native_task()); + + /** + * Destructor + */ + ~Platform_pd(); + + /** + * Bind thread to protection domain + * + * \return 0 on success or + * -1 if thread ID allocation failed. + * + * This function allocates the physical L4 thread ID. + */ + int bind_thread(Platform_thread *thread); + + /** + * Unbind thread from protection domain + * + * Free the thread's slot and update thread object. + */ + void unbind_thread(Platform_thread *thread); + + /** + * Assign parent interface to protection domain + */ + int assign_parent(Native_capability parent); + + void map_task_cap(); + void map_parent_cap(); + + /******************************* + ** Fiasco-specific Accessors ** + *******************************/ + + Native_task native_task() { return _l4_task_cap; } + Native_thread parent_cap() { return _parent.dst(); } + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */ diff --git a/base-foc/src/core/include/platform_thread.h b/base-foc/src/core/include/platform_thread.h new file mode 100644 index 000000000..45a01a179 --- /dev/null +++ b/base-foc/src/core/include/platform_thread.h @@ -0,0 +1,164 @@ +/* + * \brief Fiasco thread facility + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-04-11 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_THREAD_H_ +#define _CORE__INCLUDE__PLATFORM_THREAD_H_ + +/* Genode includes */ +#include +#include +#include + +/* core includes */ +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +namespace Genode { + + class Platform_pd; + class Platform_thread + { + private: + + friend class Platform_pd; + + bool _core_thread; + Native_capability _thread_cap; + Native_capability _gate_cap; + Native_capability _remote_gate_cap; + Native_thread _remote_pager_cap; + Native_thread _irq_cap; + Native_thread _remote_irq_cap; + Capability_node _node; + Native_utcb _utcb; + char _name[32]; /* thread name that will be + registered at the kernel + debugger */ + Platform_pd *_platform_pd; /* protection domain thread + is bound to */ + Pager_object *_pager; + + void _create_thread(void); + void _finalize_construction(const char *name, unsigned prio); + bool _in_syscall(Fiasco::l4_umword_t flags); + + public: + + enum { DEFAULT_PRIORITY = 128 }; + + /** + * Constructor for non-core threads + */ + Platform_thread(const char *name, unsigned priority); + + /** + * Constructor for core main-thread + */ + Platform_thread(Native_thread cap, const char *name); + + /** + * Constructor for core threads + */ + Platform_thread(const char *name); + + /** + * Destructor + */ + ~Platform_thread(); + + /** + * Start thread + * + * \param ip instruction pointer to start at + * \param sp stack pointer to use + * + * \retval 0 successful + * \retval -1 thread could not be started + */ + int start(void *ip, void *sp); + + /** + * Pause this thread + */ + void pause(); + + /** + * Resume this thread + */ + void resume(); + + /** + * Cancel currently blocking operation + */ + void cancel_blocking(); + + /** + * This thread is about to be bound + * + * \param cap final capability index + * \param pd platform pd, thread is bound to + */ + void bind(/*Native_thread_id cap, */Platform_pd *pd); + + /** + * Unbind this thread + */ + void unbind(); + + /** + * Request thread state + * + * \param state_dst destination state buffer + * + * \retval 0 successful + * \retval -1 thread state not accessible + */ + int state(Genode::Thread_state *state_dst); + + + /************************ + ** Accessor functions ** + ************************/ + + /** + * Return/set pager + */ + Pager_object *pager() const { return _pager; } + void pager(Pager_object *pager); + + /** + * Return identification of thread when faulting + */ + unsigned long pager_object_badge() { + return (unsigned long) _thread_cap.dst(); } + + + /******************************* + ** Fiasco-specific Accessors ** + *******************************/ + + Native_thread native_thread() const { return _thread_cap.dst(); } + Native_capability thread_cap() const { return _thread_cap; } + Native_capability gate() const { return _remote_gate_cap; } + const char *name() const { return _name; } + bool core_thread() const { return _core_thread; } + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */ diff --git a/base-foc/src/core/include/util.h b/base-foc/src/core/include/util.h new file mode 100644 index 000000000..3a8366012 --- /dev/null +++ b/base-foc/src/core/include/util.h @@ -0,0 +1,117 @@ +/* + * \brief Fiasco.OC utilities + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-04-11 + * + * Is very practical now, but please keep the errors of the l4util pkg in mind. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__UTIL_H_ +#define _CORE__INCLUDE__UTIL_H_ + +/* Genode includes */ +#include +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +} + +namespace Genode { + + inline void log_event(const char *s) + { + Fiasco::fiasco_tbuf_log(s); + } + + inline void log_event(const char *s, unsigned v1, unsigned v2, unsigned v3) + { + Fiasco::fiasco_tbuf_log_3val(s, v1, v2, v3); + } + + inline void panic(const char *s) + { + using namespace Fiasco; + outstring(s); + enter_kdebug("> panic <"); + } + + inline void touch_ro(const void *addr, unsigned size) + { + using namespace Fiasco; + unsigned char const volatile *bptr; + unsigned char const *eptr; + + bptr = (unsigned char const volatile *)(((Genode::addr_t)addr) & L4_PAGEMASK); + eptr = (unsigned char const *)(((Genode::addr_t)addr + size - 1) & L4_PAGEMASK); + for ( ; bptr <= eptr; bptr += L4_PAGESIZE) + touch_read(bptr); + } + + inline void touch_rw(const void *addr, unsigned size) + { + using namespace Fiasco; + unsigned char volatile *bptr; + unsigned char const *eptr; + + bptr = (unsigned char volatile *)(((Genode::addr_t)addr) & L4_PAGEMASK); + eptr = (unsigned char const *)(((Genode::addr_t)addr + size - 1) & L4_PAGEMASK); + for (; bptr <= eptr; bptr += L4_PAGESIZE) + touch_read_write(bptr); + } + + inline addr_t trunc_page(addr_t addr) + { + using namespace Fiasco; + return l4_trunc_page(addr); + } + + inline addr_t round_page(addr_t addr) + { + using namespace Fiasco; + return l4_round_page(addr); + } + + inline addr_t round_superpage(addr_t addr) + { + using namespace Fiasco; + return (addr + L4_SUPERPAGESIZE-1) & L4_SUPERPAGEMASK; + } + + inline size_t get_page_size() { return L4_PAGESIZE; } + + inline size_t get_page_size_log2() { return L4_LOG2_PAGESIZE; } + + inline size_t get_super_page_size() { return L4_SUPERPAGESIZE; } + + inline size_t get_super_page_size_log2() { return L4_LOG2_SUPERPAGESIZE; } + + inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, + Rm_session::Fault_type pf_type, + unsigned long badge) + { + printf("%s (%s pf_addr=%p pf_ip=%p from %lx)\n", msg, + pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ", + (void *)pf_addr, (void *)pf_ip, badge); + } + + inline addr_t map_src_addr(addr_t core_local_addr, addr_t phys_addr) { + return core_local_addr; } + + inline size_t constrain_map_size_log2(size_t size_log2) { return size_log2; } +} + +#endif /* _CORE__INCLUDE__UTIL_H_ */ diff --git a/base-foc/src/core/io_mem_session_support.cc b/base-foc/src/core/io_mem_session_support.cc new file mode 100644 index 000000000..f75670556 --- /dev/null +++ b/base-foc/src/core/io_mem_session_support.cc @@ -0,0 +1,92 @@ +/* + * \brief Fiasco.OC-specific implementation of the IO_MEM session interface + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-08-28 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +} + +using namespace Genode; + + +void Io_mem_session_component::_unmap_local(addr_t base, size_t size) +{ + platform()->region_alloc()->free(reinterpret_cast(base)); +} + + +static inline bool can_use_super_page(addr_t base, size_t size) +{ + return (base & (get_super_page_size() - 1)) == 0 + && (size >= get_super_page_size()); +} + + +addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) +{ + using namespace Fiasco; + + /* align large I/O dataspaces on a super-page boundary within core */ + size_t alignment = (size >= get_super_page_size()) ? get_super_page_size_log2() + : get_page_size_log2(); + + /* find appropriate region for mapping */ + void *local_base = 0; + if (!platform()->region_alloc()->alloc_aligned(size, &local_base, alignment)) + return 0; + + /* call sigma0 for I/O region */ + unsigned offset = 0; + while (size) { + /* FIXME what about caching demands? */ + /* FIXME what about read / write? */ + + l4_utcb_mr()->mr[0] = SIGMA0_REQ_FPAGE_IOMEM; + + size_t page_size_log2 = get_page_size_log2(); + if (can_use_super_page(base + offset, size)) + page_size_log2 = get_super_page_size_log2(); + l4_utcb_mr()->mr[1] = l4_fpage(base + offset, + page_size_log2, L4_FPAGE_RWX).raw; + + /* open receive window for mapping */ + l4_utcb_br()->bdr = 0; + l4_utcb_br()->br[0] = L4_ITEM_MAP; + l4_utcb_br()->br[1] = l4_fpage((addr_t)local_base + offset, + page_size_log2, L4_FPAGE_RWX).raw; + + l4_msgtag_t tag = l4_msgtag(L4_PROTO_SIGMA0, 2, 0, 0); + tag = l4_ipc_call(L4_BASE_PAGER_CAP, l4_utcb(), tag, L4_IPC_NEVER); + if (l4_ipc_error(tag, l4_utcb())) { + PERR("Ipc error %ld", l4_ipc_error(tag, l4_utcb())); + return 0; + } + + if (l4_msgtag_items(tag) < 1) { + PERR("Got no mapping!"); + return 0; + } + + offset += 1 << page_size_log2; + size -= 1 << page_size_log2; + } + + return (addr_t)local_base; +} diff --git a/base-foc/src/core/irq_session_component.cc b/base-foc/src/core/irq_session_component.cc new file mode 100644 index 000000000..a75e3942f --- /dev/null +++ b/base-foc/src/core/irq_session_component.cc @@ -0,0 +1,150 @@ +/* + * \brief Core implementation of IRQ sessions + * \author Christian Helmuth + * \date 2007-09-13 + * + * FIXME ram quota missing + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +#include +} + +using namespace Genode; + + +Irq_session_component::Interrupt* +Irq_session_component::Interrupt::find_by_num(unsigned num) +{ + if (number == num) return this; + + Interrupt *n = Avl_node::child(num > number); + return n ? n->find_by_num(num) : 0; +} + + +bool Irq_session_component::Interrupt::higher(Irq_session_component::Interrupt *n) +{ + return n->number > number; +} + + +Irq_session_component::Interrupt::Interrupt() +: _cap(Capability_allocator::allocator()->alloc()), _sem(), number(0) {} + + +Native_thread Irq_session_component::Interrupt_handler::handler_cap() +{ + static Interrupt_handler handler; + return handler._thread_cap.dst(); +} + + +void Irq_session_component::Interrupt_handler::entry() +{ + using namespace Fiasco; + + int err; + l4_msgtag_t tag; + l4_umword_t label; + + while (true) { + tag = l4_ipc_wait(l4_utcb(), &label, L4_IPC_NEVER); + if ((err = l4_ipc_error(tag, l4_utcb()))) + PERR("IRQ receive: %d\n", err); + else { + Interrupt *intr = _irqs()->first(); + if (intr) { + intr = intr->find_by_num(label); + if (intr) + intr->semaphore()->up(); + } + } + } +} + + +Avl_tree* Irq_session_component::_irqs() +{ + static Avl_tree irqs; + return &irqs; +} + + +Irq_session_component::Irq_session_component(Cap_session *cap_session, + Range_allocator *irq_alloc, + const char *args) +: + _irq_alloc(irq_alloc), + _ep(cap_session, STACK_SIZE, "irqctrl") +{ + using namespace Fiasco; + + long irq_number = Arg_string::find_arg(args, "irq_number").long_value(-1); + if ((irq_number == -1) || _irq_alloc->alloc_addr(1, irq_number)) { + PERR("Unavailable IRQ %lx requested", irq_number); + throw Root::Invalid_args(); + } + + /* + * temorary hack for fiasco.oc using the local-apic, + * where old pic-line 0 maps to 2 + */ + if (irq_number == 0) + irq_number = 2; + + _irq.number = irq_number; + Irq_session_component::_irqs()->insert(&_irq); + + if (l4_error(l4_factory_create_irq(L4_BASE_FACTORY_CAP, _irq.capability()))) + PERR("l4_factory_create_irq failed!"); + + if (l4_error(l4_icu_bind(L4_BASE_ICU_CAP, irq_number, _irq.capability()))) + PERR("Binding IRQ%ld to the ICU failed", irq_number); + + if (l4_error(l4_irq_attach(_irq.capability(), irq_number, + Interrupt_handler::handler_cap()))) + PERR("Error attaching to IRQ %ld", irq_number); + + /* initialize capability */ + _irq_cap = _ep.manage(this); +} + + +void Irq_session_component::wait_for_irq() +{ + using namespace Fiasco; + + int err; + l4_msgtag_t tag = l4_irq_unmask(_irq.capability()); + if ((err = l4_ipc_error(tag, l4_utcb()))) + PERR("IRQ unmask: %d\n", err); + + _irq.semaphore()->down(); +} + + +Irq_session_component::~Irq_session_component() +{ + PERR("Implement me, immediately!"); +} diff --git a/base-foc/src/core/pd_session_extension.cc b/base-foc/src/core/pd_session_extension.cc new file mode 100644 index 000000000..fa08844a3 --- /dev/null +++ b/base-foc/src/core/pd_session_extension.cc @@ -0,0 +1,23 @@ +/* + * \brief Core implementation of the PD session extension + * \author Stefan Kalkowski + * \date 2011-04-14 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Core includes */ +#include + + +Genode::Native_capability Genode::Pd_session_component::task_cap() { + return Native_capability(_pd.native_task(), + Badge_allocator::allocator()->alloc()); } diff --git a/base-foc/src/core/platform.cc b/base-foc/src/core/platform.cc new file mode 100644 index 000000000..c202db06a --- /dev/null +++ b/base-foc/src/core/platform.cc @@ -0,0 +1,500 @@ +/* + * \brief Fiasco platform interface implementation + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-04-11 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include +#include + +/* core includes */ +#include +#include +#include +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +#include +#include +#include + +static l4_kernel_info_t *kip; +} + +using namespace Genode; + + +static const bool verbose = true; +static const bool verbose_core_pf = false; +static const bool verbose_region_alloc = false; + + +/*********************************** + ** Core address space management ** + ***********************************/ + +static Synchronized_range_allocator &_core_address_ranges() +{ + static Synchronized_range_allocator _core_address_ranges(0); + return _core_address_ranges; +} + +enum { PAGER_STACK_ELEMENTS = 1024 }; +static unsigned long _core_pager_stack[PAGER_STACK_ELEMENTS]; + +/** + * Core pager "service loop" + */ +static void _core_pager_loop() +{ + using namespace Fiasco; + + bool send_reply = false; + l4_umword_t label; + l4_utcb_t *utcb = l4_utcb(); + l4_msgtag_t snd_tag = l4_msgtag(0, 0, 0, 0); + l4_msgtag_t tag; + + while (true) { + + if (send_reply) + tag = l4_ipc_reply_and_wait(utcb, snd_tag, &label, L4_IPC_NEVER); + else + tag = l4_ipc_wait(utcb, &label, L4_IPC_NEVER); + + if (!tag.is_page_fault()) { + PWRN("Received something different than a pagefault, ignoring ..."); + continue; + } + + /* read fault information */ + l4_umword_t pfa = l4_trunc_page(l4_utcb_mr()->mr[0]); + l4_umword_t ip = l4_utcb_mr()->mr[1]; + bool rw = l4_utcb_mr()->mr[0] & 2; //TODO enum + + if (pfa < (l4_umword_t)L4_PAGESIZE) { + + /* NULL pointer access */ + PERR("Possible null pointer %s at %lx IP %lx", + rw ? "WRITE" : "READ", pfa, ip); + /* do not unblock faulter */ + send_reply = false; + continue; + } else if (!_core_address_ranges().valid_addr(pfa)) { + + /* page-fault address is not in RAM */ + PERR("%s access outside of RAM at %lx IP %lx", + rw ? "WRITE" : "READ", pfa, ip); + /* do not unblock faulter */ + send_reply = false; + continue; + } else if (verbose_core_pf) + PDBG("pfa=%lx ip=%lx", pfa, ip); + + /* my pf handler is sigma0 - just touch the appropriate page */ + if (rw) + touch_rw((void *)pfa, 1); + else + touch_ro((void *)pfa, 1); + + send_reply = true; + } +} + + +Platform::Sigma0::Sigma0() : Pager_object(0) +{ + /* + * We use the Pager_object here in a slightly different manner, + * just to tunnel the pager cap to the Platform_thread::start method. + */ + cap(reinterpret_cap_cast(Native_capability(Fiasco::L4_BASE_PAGER_CAP, 0))); +} + + +Platform::Sigma0 *Platform::sigma0() +{ + static Sigma0 _sigma0; + return &_sigma0; +} + + +Platform::Core_pager::Core_pager(Platform_pd *core_pd) +: Platform_thread("core.pager"), Pager_object(0) +{ + Platform_thread::pager(sigma0()); + + core_pd->bind_thread(this); + cap(Native_capability(native_thread(), 0)); + + /* stack begins at the top end of the '_core_pager_stack' array */ + void *sp = (void *)&_core_pager_stack[PAGER_STACK_ELEMENTS - 1]; + start((void *)_core_pager_loop, sp); + + using namespace Fiasco; + + l4_thread_control_start(); + l4_thread_control_pager(native_thread()); + l4_thread_control_exc_handler(native_thread()); + l4_msgtag_t tag = l4_thread_control_commit(L4_BASE_THREAD_CAP); + if (l4_msgtag_has_error(tag)) + PWRN("l4_thread_control_commit failed!"); +} + + +Platform::Core_pager *Platform::core_pager() +{ + static Core_pager _core_pager(core_pd()); + return &_core_pager; +} + + +/*********************************** + ** Helper for L4 region handling ** + ***********************************/ + +struct Region +{ + addr_t start; + addr_t end; + + Region() : start(0), end(0) { } + Region(addr_t s, addr_t e) : start(s), end(e) { } +}; + + +/** + * Log region + */ +static inline void print_region(Region r) +{ + printf("[%08lx,%08lx) %08lx", r.start, r.end, r.end - r.start); +} + + +/** + * Add region to allocator + */ +static inline void add_region(Region r, Range_allocator &alloc) +{ + if (verbose_region_alloc) { + printf("%p add: ", &alloc); print_region(r); printf("\n"); + } + + /* adjust region */ + addr_t start = trunc_page(r.start); + addr_t end = round_page(r.end); + + alloc.add_range(start, end - start); +} + + +/** + * Remove region from allocator + */ +static inline void remove_region(Region r, Range_allocator &alloc) +{ + if (verbose_region_alloc) { + printf("%p remove: ", &alloc); print_region(r); printf("\n"); + } + + /* adjust region */ + addr_t start = trunc_page(r.start); + addr_t end = round_page(r.end); + + alloc.remove_range(start, end - start); +} + + +/** + * Request any RAM page from Sigma0 + */ +static inline int sigma0_req_region(addr_t *addr, unsigned log2size) +{ + using namespace Fiasco; + + l4_utcb_mr()->mr[0] = SIGMA0_REQ_FPAGE_ANY; + l4_utcb_mr()->mr[1] = l4_fpage(0, log2size, 0).raw; + + /* open receive window for mapping */ + l4_utcb_br()->bdr &= ~L4_BDR_OFFSET_MASK; + l4_utcb_br()->br[0] = L4_ITEM_MAP; + l4_utcb_br()->br[1] = l4_fpage(0, L4_WHOLE_ADDRESS_SPACE, L4_FPAGE_RWX).raw; + + l4_msgtag_t tag = l4_msgtag(L4_PROTO_SIGMA0, 2, 0, 0); + tag = l4_ipc_call(L4_BASE_PAGER_CAP, l4_utcb(), tag, L4_IPC_NEVER); + if (l4_ipc_error(tag, l4_utcb())) + return -1; + + if (l4_msgtag_items(tag) != 1) + return -2; + + *addr = l4_utcb_mr()->mr[0] & (~0UL << L4_PAGESHIFT); + + touch_rw((void *)addr, 1); + + return 0; +} + + +static Fiasco::l4_kernel_info_t *sigma0_map_kip() +{ + using namespace Fiasco; + + /* signal we want to map the KIP */ + l4_utcb_mr()->mr[0] = SIGMA0_REQ_KIP; + + /* open receive window for KIP one-to-one */ + l4_utcb_br()->bdr &= ~L4_BDR_OFFSET_MASK; + l4_utcb_br()->br[0] = L4_ITEM_MAP; + l4_utcb_br()->br[1] = l4_fpage(0, L4_WHOLE_ADDRESS_SPACE, L4_FPAGE_RX).raw; + + /* call sigma0 */ + l4_msgtag_t tag = l4_ipc_call(L4_BASE_PAGER_CAP, + l4_utcb(), + l4_msgtag(L4_PROTO_SIGMA0, 1, 0, 0), + L4_IPC_NEVER); + if (l4_ipc_error(tag, l4_utcb())) + return 0; + + l4_addr_t ret = l4_trunc_page(l4_utcb_mr()->mr[0]); + return (l4_kernel_info_t*) ret; +} + + +void Platform::_setup_mem_alloc() +{ + /* + * Completely map program image by touching all pages read-only to + * prevent sigma0 from handing out those page as anonymous memory. + */ + volatile const char *beg, *end; + beg = (const char *)(((Genode::addr_t)&_prog_img_beg) & L4_PAGEMASK); + end = (const char *)&_prog_img_end; + for ( ; beg < end; beg += L4_PAGESIZE) (void)(*beg); + + /* request pages of known page size starting with largest */ + size_t log2_sizes[] = { L4_LOG2_SUPERPAGESIZE, L4_LOG2_PAGESIZE }; + + for (unsigned i = 0; i < sizeof(log2_sizes)/sizeof(*log2_sizes); ++i) { + size_t log2_size = log2_sizes[i]; + size_t size = 1 << log2_size; + int err = 0; + addr_t addr = 0; + Region region; + + /* request any page of current size from sigma0 */ + do { + err = sigma0_req_region(&addr, log2_size); + if (!err) { + /* XXX do not allocate page0 */ + if (addr == 0) { + Fiasco::l4_task_unmap(Fiasco::L4_BASE_TASK_CAP, + Fiasco::l4_fpage(0, log2_size, 0), + Fiasco::L4_FP_ALL_SPACES); + continue; + } + + region.start = addr; region.end = addr + size; + add_region(region, _ram_alloc); + add_region(region, _core_address_ranges()); + remove_region(region, _io_mem_alloc); + remove_region(region, _region_alloc); + } + } while (!err); + } +} + + +void Platform::_setup_irq_alloc() { _irq_alloc.add_range(0, 0x100); } + + +void Platform::_setup_basics() +{ + using namespace Fiasco; + + kip = sigma0_map_kip(); + if (!kip) + panic("kip mapping failed"); + + if (kip->magic != L4_KERNEL_INFO_MAGIC) + panic("Sigma0 mapped something but not the KIP"); + + if (verbose) { + printf("\n"); + printf("KIP @ %p\n", kip); + printf(" magic: %08zx\n", (size_t)kip->magic); + printf(" version: %08zx\n", (size_t)kip->version); + printf(" sigma0 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma0_esp, kip->sigma0_eip); + printf(" sigma1 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma1_esp, kip->sigma1_eip); + printf(" root "); printf(" esp: %08lx eip: %08lx\n", kip->root_esp, kip->root_eip); + } + + /* add KIP as ROM module */ + _kip_rom = Rom_module((addr_t)kip, L4_PAGESIZE, "l4v2_kip"); + _rom_fs.insert(&_kip_rom); + + /* update multi-boot info pointer from KIP */ + void *mb_info_ptr = (void *)kip->user_ptr; + _mb_info = Multiboot_info(mb_info_ptr); + if (verbose) printf("MBI @ %p\n", mb_info_ptr); + + /* parse memory descriptors - look for virtual memory configuration */ + /* XXX we support only one VM region (here and also inside RM) */ + using Fiasco::L4::Kip::Mem_desc; + + _vm_start = 0; _vm_size = 0; + Mem_desc *desc = Mem_desc::first(kip); + + for (unsigned i = 0; i < Mem_desc::count(kip); ++i) + if (desc[i].is_virtual()) { + _vm_start = round_page(desc[i].start()); + _vm_size = trunc_page(desc[i].end() - _vm_start + 1); + + break; + } + if (_vm_size == 0) + panic("Virtual memory configuration not found"); + + /* configure applicable address space but never use page0 */ + _vm_size = _vm_start == 0 ? _vm_size - L4_PAGESIZE : _vm_size; + _vm_start = _vm_start == 0 ? L4_PAGESIZE : _vm_start; + _region_alloc.add_range(_vm_start, _vm_size); + + /* preserve context area in core's virtual address space */ + _region_alloc.remove_range(Thread_base::CONTEXT_AREA_VIRTUAL_BASE, + Thread_base::CONTEXT_AREA_VIRTUAL_SIZE); + + /* preserve utcb- area in core's virtual address space */ + _region_alloc.remove_range((addr_t)l4_utcb(), L4_PAGESIZE); + + /* I/O memory could be the whole user address space */ + /* FIXME if the kernel helps to find out max address - use info here */ + _io_mem_alloc.add_range(0, ~0); + + /* remove KIP and MBI area from region and IO_MEM allocator */ + remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _region_alloc); + remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _io_mem_alloc); + remove_region(Region((addr_t)mb_info_ptr, (addr_t)mb_info_ptr + _mb_info.size()), _region_alloc); + remove_region(Region((addr_t)mb_info_ptr, (addr_t)mb_info_ptr + _mb_info.size()), _io_mem_alloc); + + /* remove core program image memory from region and IO_MEM allocator */ + addr_t img_start = (addr_t) &_prog_img_beg; + addr_t img_end = (addr_t) &_prog_img_end; + remove_region(Region(img_start, img_end), _region_alloc); + remove_region(Region(img_start, img_end), _io_mem_alloc); + + /* image is accessible by core */ + add_region(Region(img_start, img_end), _core_address_ranges()); +} + + +void Platform::_setup_rom() +{ + Rom_module rom; + + for (unsigned i = FIRST_ROM; i < _mb_info.num_modules(); i++) { + if (!(rom = _mb_info.get_module(i)).valid()) continue; + + Rom_module *new_rom = new(core_mem_alloc()) Rom_module(rom); + _rom_fs.insert(new_rom); + + if (verbose) + printf(" mod[%d] [%p,%p) %s\n", i, + (void *)new_rom->addr(), ((char *)new_rom->addr()) + new_rom->size(), + new_rom->name()); + + /* zero remainder of last ROM page */ + size_t count = L4_PAGESIZE - rom.size() % L4_PAGESIZE; + if (count != L4_PAGESIZE) + memset(reinterpret_cast(rom.addr() + rom.size()), 0, count); + + /* remove ROM area from region and IO_MEM allocator */ + remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _region_alloc); + remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _io_mem_alloc); + + /* add area to core-accessible ranges */ + add_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _core_address_ranges()); + } + + Rom_module *kip_rom = new(core_mem_alloc()) + Rom_module((addr_t)Fiasco::kip, L4_PAGESIZE, "kip"); + _rom_fs.insert(kip_rom); +} + + +Platform::Platform() : + _ram_alloc(0), _io_mem_alloc(core_mem_alloc()), + _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), + _region_alloc(core_mem_alloc()) +{ + /* + * We must be single-threaded at this stage and so this is safe. + */ + static bool initialized = 0; + if (initialized) panic("Platform constructed twice!"); + initialized = true; + + _setup_basics(); + _setup_mem_alloc(); + _setup_io_port_alloc(); + _setup_irq_alloc(); + _setup_rom(); + + if (verbose) { + printf(":ram_alloc: "); _ram_alloc.raw()->dump_addr_tree(); + printf(":region_alloc: "); _region_alloc.raw()->dump_addr_tree(); + printf(":io_mem: "); _io_mem_alloc.raw()->dump_addr_tree(); + printf(":io_port: "); _io_port_alloc.raw()->dump_addr_tree(); + printf(":irq: "); _irq_alloc.raw()->dump_addr_tree(); + printf(":rom_fs: "); _rom_fs.print_fs(); + printf(":core ranges: "); _core_address_ranges().raw()->dump_addr_tree(); + } + + /* setup pd object for core pd */ + _core_pd = new(core_mem_alloc()) Platform_pd(false, Fiasco::L4_BASE_TASK_CAP); + + /* + * We setup the thread object for thread0 in core pd using a special + * interface that allows us to specify the capability slot. + */ + Platform_thread *core_thread = new(core_mem_alloc()) + Platform_thread(Fiasco::L4_BASE_THREAD_CAP, "core.main"); + + core_thread->pager(sigma0()); + _core_pd->bind_thread(core_thread); +} + + +/******************************** + ** Generic platform interface ** + ********************************/ + +void Platform::wait_for_exit() +{ + /* + * On Fiasco, Core never exits. So let us sleep forever. + */ + sleep_forever(); +} + + +void Core_parent::exit(int exit_value) { } diff --git a/base-foc/src/core/platform_pd.cc b/base-foc/src/core/platform_pd.cc new file mode 100644 index 000000000..12ca769c9 --- /dev/null +++ b/base-foc/src/core/platform_pd.cc @@ -0,0 +1,174 @@ +/* + * \brief Fiasco protection domain facility + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-04-11 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +} + +using namespace Fiasco; +using namespace Genode; + + +static addr_t core_utcb_base() { + static addr_t base = (addr_t) l4_utcb(); + return base; +} + + +/**************************** + ** Private object members ** + ****************************/ + +void Platform_pd::_create_pd(bool syscall) +{ + if (!_l4_task_cap.valid()) + _l4_task_cap = Capability_allocator::allocator()->alloc(); + + if (syscall) { + if (!_l4_task_cap) + panic("no cap slot for pd creation available!"); + + l4_fpage_t utcb_area = l4_fpage(UTCB_AREA_START, + log2(UTCB_AREA_SIZE), 0); + l4_msgtag_t tag = l4_factory_create_task(L4_BASE_FACTORY_CAP, + _l4_task_cap, utcb_area); + + if (l4_msgtag_has_error(tag)) + panic("pd creation failed"); + } +} + + +void Platform_pd::_destroy_pd() +{ + l4_task_unmap(L4_BASE_TASK_CAP, + l4_obj_fpage(_l4_task_cap, 0, L4_FPAGE_RWX), + L4_FP_ALL_SPACES | L4_FP_DELETE_OBJ); +} + + +/*************************** + ** Public object members ** + ***************************/ + +int Platform_pd::bind_thread(Platform_thread *thread) +{ + using namespace Fiasco; + + for (unsigned i = 0; i < THREAD_MAX; i++) { + if (_threads[i]) + continue; + + _threads[i] = thread; + if (thread->core_thread()) + thread->_utcb = (l4_utcb_t*) (core_utcb_base() + i * L4_UTCB_OFFSET); + else + thread->_utcb = + reinterpret_cast(UTCB_AREA_START + i * L4_UTCB_OFFSET); + Native_thread cap_offset = Fiasco_capability::THREADS_BASE_CAP + + i * Fiasco_capability::THREAD_CAP_SLOT; + thread->_remote_gate_cap = Native_capability(cap_offset + Fiasco_capability::THREAD_GATE_CAP, + thread->_gate_cap.local_name()); + thread->_remote_pager_cap = cap_offset + Fiasco_capability::THREAD_PAGER_CAP; + thread->_remote_irq_cap = cap_offset + Fiasco_capability::THREAD_IRQ_CAP; + + /* inform thread about binding */ + thread->bind(this); + return 0; + } + + PERR("thread alloc failed"); + return -1; +} + + +void Platform_pd::unbind_thread(Platform_thread *thread) +{ + /* inform thread about unbinding */ + thread->unbind(); + + for (unsigned i = 0; i < THREAD_MAX; i++) + if (_threads[i] == thread) { + _threads[i] = (Platform_thread*) 0; + return; + } +} + + +int Platform_pd::assign_parent(Native_capability parent) +{ + if (_parent.valid()) return -1; + _parent = parent; + return 0; +} + + +void Platform_pd::map_parent_cap() +{ + if (!_parent_cap_mapped) { + l4_msgtag_t tag = l4_task_map(_l4_task_cap, L4_BASE_TASK_CAP, + l4_obj_fpage(_parent.dst(), 0, L4_FPAGE_RWX), + Fiasco_capability::PARENT_CAP | L4_ITEM_MAP); + if (l4_msgtag_has_error(tag)) + PWRN("mapping parent cap failed"); + + _parent_cap_mapped = true; + } +} + + +void Platform_pd::map_task_cap() +{ + if (!_task_cap_mapped) { + l4_msgtag_t tag = l4_task_map(_l4_task_cap, L4_BASE_TASK_CAP, + l4_obj_fpage(_l4_task_cap, 0, L4_FPAGE_RWX), + Fiasco_capability::TASK_CAP | L4_ITEM_MAP); + if (l4_msgtag_has_error(tag)) + PWRN("mapping task cap failed"); + _task_cap_mapped = true; + } +} + + +Platform_pd::Platform_pd(bool create, Native_task task_cap) +: _l4_task_cap(task_cap), + _parent_cap_mapped(false), + _task_cap_mapped(false) +{ + for (unsigned i = 0; i < THREAD_MAX; i++) + _threads[i] = (Platform_thread*) 0; + + _create_pd(create); +} + + +Platform_pd::~Platform_pd() +{ + for (unsigned i = 0; i < THREAD_MAX; i++) { + if (_threads[i]) + _threads[i]->unbind(); + } + _destroy_pd(); +} diff --git a/base-foc/src/core/platform_thread.cc b/base-foc/src/core/platform_thread.cc new file mode 100644 index 000000000..2288447b6 --- /dev/null +++ b/base-foc/src/core/platform_thread.cc @@ -0,0 +1,307 @@ +/* + * \brief Fiasco thread facility + * \author Stefan Kalkowski + * \date 2011-01-04 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include + +/* core includes */ +#include +#include +#include +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +#include +#include +#include +#include +#include +} + +using namespace Genode; +using namespace Fiasco; + + +int Platform_thread::start(void *ip, void *sp) +{ + if (_pager && _platform_pd) { + /* map pager cap */ + l4_msgtag_t tag = l4_task_map(_platform_pd->native_task(), L4_BASE_TASK_CAP, + l4_obj_fpage(_pager->cap().dst(), 0, L4_FPAGE_RWX), + _remote_pager_cap | L4_ITEM_MAP); + if (l4_msgtag_has_error(tag)) + PWRN("mapping pager cap failed"); + } + + /* reserve utcb area and associate thread with this task */ + l4_thread_control_start(); + l4_thread_control_pager(_remote_pager_cap); + l4_thread_control_exc_handler(_remote_pager_cap); + l4_thread_control_bind(_utcb, _platform_pd->native_task()); + + l4_msgtag_t tag = l4_thread_control_commit(_thread_cap.dst()); + if (l4_msgtag_has_error(tag)) { + PWRN("l4_thread_control_commit for %lx failed!", + (unsigned long) _thread_cap.dst()); + return -1; + } + + /* set ip and sp and run the thread */ + tag = l4_thread_ex_regs(_thread_cap.dst(), (l4_addr_t) ip, (l4_addr_t) sp, 0); + if (l4_msgtag_has_error(tag)) { + PWRN("l4_thread_ex_regs failed!"); + return -1; + } + + return 0; +} + + +void Platform_thread::pause() +{ + if (!_pager) + return; + + _pager->state.lock.lock(); + + if (_pager->state.paused == true) { + _pager->state.lock.unlock(); + return; + } + + unsigned exc = _pager->state.exceptions; + _pager->state.ip = ~0UL; + _pager->state.sp = ~0UL; + l4_umword_t flags = L4_THREAD_EX_REGS_TRIGGER_EXCEPTION; + + /* Mark thread to be stopped */ + _pager->state.paused = true; + + /* + * Force the thread to be paused to trigger an exception. + * The pager thread, which also acts as exception handler, will + * leave the thread in exception state until, it gets woken again + */ + l4_thread_ex_regs_ret(_thread_cap.dst(), &_pager->state.ip, + &_pager->state.sp, &flags); + bool in_syscall = _in_syscall(flags); + _pager->state.lock.unlock(); + + /** + * Check whether the thread was in ongoing ipc, if so it won't raise + * an exception before ipc is completed. + */ + if (!in_syscall) { + /* + * Wait until the pager thread got an exception from + * the requested thread, and stored its thread state + */ + while (exc == _pager->state.exceptions && !_pager->state.in_exception) + l4_thread_switch(_thread_cap.dst()); + } +} + + +void Platform_thread::resume() +{ + if (!_pager) + return; + + _pager->state.lock.lock(); + + /* Mark thread to be runable again */ + _pager->state.paused = false; + _pager->state.lock.unlock(); + + /* Send a message to the exception handler, to unblock the client */ + Msgbuf<16> snd, rcv; + Ipc_client ipc_client(_pager->cap(), &snd, &rcv); + ipc_client << _pager << IPC_CALL; +} + + +void Platform_thread::bind(Platform_pd *pd) +{ + l4_msgtag_t tag; + Native_task task = pd->native_task(); + + _platform_pd = pd; + + if (!_core_thread) { + /* map parent and task cap if it doesn't happen already */ + _platform_pd->map_task_cap(); + _platform_pd->map_parent_cap(); + } + + if (_gate_cap.valid()) { + /* map thread's gate cap */ + tag = l4_task_map(task, L4_BASE_TASK_CAP, + l4_obj_fpage(_gate_cap.dst(), 0, L4_FPAGE_RWX), + _remote_gate_cap.dst() | L4_ITEM_MAP); + if (l4_msgtag_has_error(tag)) + PWRN("mapping thread's gate cap failed"); + } + + /* map thread's irq cap */ + tag = l4_task_map(task, L4_BASE_TASK_CAP, + l4_obj_fpage(_irq_cap, 0, L4_FPAGE_RWX), + _remote_irq_cap | L4_ITEM_MAP); + if (l4_msgtag_has_error(tag)) + PWRN("mapping thread's irq cap failed"); +} + + +void Platform_thread::unbind() +{ + l4_thread_ex_regs(_thread_cap.dst(), 0, 0, 0); + l4_task_unmap(L4_BASE_TASK_CAP, + l4_obj_fpage(_gate_cap.dst(), 0, L4_FPAGE_RWX), + L4_FP_ALL_SPACES | L4_FP_DELETE_OBJ); + l4_task_unmap(L4_BASE_TASK_CAP, + l4_obj_fpage(_thread_cap.dst(), 0, L4_FPAGE_RWX), + L4_FP_ALL_SPACES | L4_FP_DELETE_OBJ); + _platform_pd = (Platform_pd*) 0; +} + + +void Platform_thread::pager(Pager_object *pager) +{ + _pager = pager; +} + + +int Platform_thread::state(Thread_state *state_dst) +{ + if (_pager) + *state_dst = _pager->state; + + state_dst->cap = _remote_gate_cap; + return 0; +} + + +void Platform_thread::cancel_blocking() +{ + l4_irq_trigger(_irq_cap); +} + + +void Platform_thread::_create_thread() +{ + l4_msgtag_t tag = l4_factory_create_thread(L4_BASE_FACTORY_CAP, + _thread_cap.dst()); + if (l4_msgtag_has_error(tag)) + PERR("cannot create more thread kernel-objects!"); +} + + +void Platform_thread::_finalize_construction(const char *name, unsigned prio) +{ + /* create irq for new thread */ + _irq_cap = Capability_allocator::allocator()->alloc(); + l4_msgtag_t tag = l4_factory_create_irq(L4_BASE_FACTORY_CAP, _irq_cap); + if (l4_msgtag_has_error(tag)) + PWRN("creating thread's irq failed"); + + /* attach thread to irq */ + tag = l4_irq_attach(_irq_cap, 0, _thread_cap.dst()); + if (l4_msgtag_has_error(tag)) + PWRN("attaching thread's irq failed"); + + /* set human readable name in kernel debugger */ + strncpy(_name, name, sizeof(_name)); + Fiasco::l4_debugger_set_object_name(_thread_cap.dst(), name); + + /* set priority of thread */ + prio = Cpu_session::scale_priority(DEFAULT_PRIORITY, prio); + l4_sched_param_t params = l4_sched_param(prio); + l4_scheduler_run_thread(L4_BASE_SCHEDULER_CAP, _thread_cap.dst(), ¶ms); +} + + +Platform_thread::Platform_thread(const char *name, + unsigned prio) +: _core_thread(false), + _thread_cap(Capability_allocator::allocator()->alloc(), + Badge_allocator::allocator()->alloc()), + _node(_thread_cap.local_name(), 0, this, _thread_cap.dst()), + _utcb(0), + _platform_pd(0), + _pager(0) +{ + /* register the thread capability */ + Capability_tree::tree()->insert(&_node); + + _create_thread(); + + /* create gate for new thread */ + _gate_cap = core_env()->cap_session()->alloc(_thread_cap); + + _finalize_construction(name, prio); +} + + +Platform_thread::Platform_thread(Native_thread cap, const char *name) +: _core_thread(true), + _thread_cap(cap, -1), + _node(_thread_cap.local_name(), 0, this, _thread_cap.dst()), + _utcb(0), + _platform_pd(0), + _pager(0) +{ + /* register the thread capability */ + Capability_tree::tree()->insert(&_node); + + _finalize_construction(name, 0); +} + + +Platform_thread::Platform_thread(const char *name) +: _core_thread(true), + _thread_cap(Capability_allocator::allocator()->alloc(), + Badge_allocator::allocator()->alloc()), + _node(_thread_cap.local_name(), 0, this, _thread_cap.dst()), + _utcb(0), + _platform_pd(0), + _pager(0) +{ + /* register the thread capability */ + Capability_tree::tree()->insert(&_node); + + _create_thread(); + + /* create gate for new thread */ + _gate_cap = Cap_session_component::alloc(0, _thread_cap); + + _finalize_construction(name, 0); +} + + +Platform_thread::~Platform_thread() +{ + /* + * We inform our protection domain about thread destruction, which will end up in + * Thread::unbind() + */ + if (_platform_pd) + _platform_pd->unbind_thread(this); + + /* remove the thread capability */ + Capability_tree::tree()->remove(&_node); + Badge_allocator::allocator()->free(_thread_cap.local_name()); + Capability_allocator::allocator()->free(_thread_cap.dst()); +} diff --git a/base-foc/src/core/ram_session_support.cc b/base-foc/src/core/ram_session_support.cc new file mode 100644 index 000000000..9fe8d2c55 --- /dev/null +++ b/base-foc/src/core/ram_session_support.cc @@ -0,0 +1,27 @@ +/* + * \brief Export RAM dataspace as shared memory object (dummy) + * \author Norman Feske + * \date 2006-07-03 + * + * On L4, each dataspace _is_ a shared memory object. + * Therefore, these functions are empty. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include "ram_session_component.h" + +using namespace Genode; + +void Ram_session_component::_export_ram_ds(Dataspace_component *ds) { } +void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds) { } + +void Ram_session_component::_clear_ds(Dataspace_component *ds) +{ + memset((void *)ds->phys_addr(), 0, ds->size()); +} diff --git a/base-foc/src/core/rm_session_support.cc b/base-foc/src/core/rm_session_support.cc new file mode 100644 index 000000000..2406690e6 --- /dev/null +++ b/base-foc/src/core/rm_session_support.cc @@ -0,0 +1,35 @@ +/* + * \brief Fiasco-specific part of RM-session implementation + * \author Stefan Kalkowski + * \date 2011-01-18 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +/* Fiasco includes */ +namespace Fiasco { +#include +} + +using namespace Genode; + + +void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size) +{ + using namespace Fiasco; + + // TODO unmap it only from target space + addr_t addr = core_local_base; + for (; addr < core_local_base + size; addr += L4_PAGESIZE) + l4_task_unmap(L4_BASE_TASK_CAP, + l4_fpage(addr, L4_LOG2_PAGESIZE, L4_FPAGE_RW), + L4_FP_OTHER_SPACES); +} diff --git a/base-foc/src/core/signal_source_component.cc b/base-foc/src/core/signal_source_component.cc new file mode 100644 index 000000000..e1f5fc8e0 --- /dev/null +++ b/base-foc/src/core/signal_source_component.cc @@ -0,0 +1,77 @@ +/* + * \brief Implementation of the SIGNAL interface + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2009-08-11 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include + +/* core includes */ +#include + +namespace Fiasco { +#include +#include +} + +using namespace Genode; + + +/***************************** + ** Signal-source component ** + *****************************/ + +void Signal_source_component::submit(Signal_context_component *context, + Ipc_ostream *ostream, + int cnt) +{ + /* enqueue signal to context */ + context->increment_signal_cnt(cnt); + + if (!context->is_enqueued()) { + _signal_queue.enqueue(context); + + /* wake up client */ + Fiasco::l4_irq_trigger(_blocking_semaphore.dst()); + } +} + + +Signal_source::Signal Signal_source_component::wait_for_signal() +{ + if (_signal_queue.empty()) { + PWRN("unexpected call of wait_for_signal"); + return Signal(0, 0); + } + + /* dequeue and return pending signal */ + Signal_context_component *context = _signal_queue.dequeue(); + Signal result(context->imprint(), context->cnt()); + context->reset_signal_cnt(); + return result; +} + + +Signal_source_component::Signal_source_component(Rpc_entrypoint *ep) +: _entrypoint(ep) +{ + using namespace Fiasco; + + Fiasco_capability irq = Capability_allocator::allocator()->alloc(); + l4_msgtag_t res = l4_factory_create_irq(L4_BASE_FACTORY_CAP, irq); + if (l4_error(res)) + PERR("Allocation of irq object failed!"); + + _blocking_semaphore = Native_capability(irq, -1); +} diff --git a/base-foc/src/core/target.inc b/base-foc/src/core/target.inc new file mode 100644 index 000000000..27530aff6 --- /dev/null +++ b/base-foc/src/core/target.inc @@ -0,0 +1,57 @@ +TARGET = core +REQUIRES = foc +LIBS = cxx ipc heap core_printf process pager lock raw_signal raw_server + +LD_TEXT_ADDR = 0x140000 + +GEN_CORE_DIR = $(BASE_DIR)/src/core + +SRC_CC = main.cc \ + multiboot_info.cc \ + ram_session_component.cc \ + ram_session_support.cc \ + rom_session_component.cc \ + cpu_session_component.cc \ + pd_session_component.cc \ + io_mem_session_component.cc \ + io_mem_session_support.cc \ + thread.cc \ + thread_bootstrap.cc \ + thread_start.cc \ + platform_thread.cc \ + platform_pd.cc \ + platform.cc \ + dataspace_component.cc \ + rm_session_component.cc \ + rm_session_support.cc \ + io_port_session_component.cc \ + irq_session_component.cc \ + signal_session_component.cc \ + signal_source_component.cc \ + cap_sel_alloc.cc \ + dump_alloc.cc \ + context_area.cc \ + cap_session_component.cc \ + cpu_session_extension.cc \ + pd_session_extension.cc + +INC_DIR += $(REP_DIR)/src/core/include \ + $(GEN_CORE_DIR)/include + +vpath main.cc $(GEN_CORE_DIR) +vpath multiboot_info.cc $(GEN_CORE_DIR) +vpath ram_session_component.cc $(GEN_CORE_DIR) +vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath cpu_session_component.cc $(GEN_CORE_DIR) +vpath pd_session_component.cc $(GEN_CORE_DIR) +vpath rm_session_component.cc $(GEN_CORE_DIR) +vpath signal_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_support.cc $(GEN_CORE_DIR) +vpath dataspace_component.cc $(GEN_CORE_DIR) +vpath dump_alloc.cc $(GEN_CORE_DIR) +vpath context_area.cc $(GEN_CORE_DIR) +vpath thread.cc $(REP_DIR)/src/base/thread +vpath thread_bootstrap.cc $(REP_DIR)/src/base/thread +vpath cap_sel_alloc.cc $(REP_DIR)/src/base/env +vpath %.cc $(REP_DIR)/src/core diff --git a/base-foc/src/core/thread_start.cc b/base-foc/src/core/thread_start.cc new file mode 100644 index 000000000..ec4e7632a --- /dev/null +++ b/base-foc/src/core/thread_start.cc @@ -0,0 +1,68 @@ +/* + * \brief Fiasco.OC-specific implementation of core's startup Thread API. + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2006-05-03 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include +#include +#include + +namespace Fiasco { +#include +#include +} + +using namespace Genode; + + +void Thread_base::_deinit_platform_thread() +{ + PWRN("%s: not implemented yet!", __func__); +} + + +void Thread_base::start() +{ + using namespace Fiasco; + + /* create and start platform thread */ + Platform_thread *pt = + new(platform()->core_mem_alloc()) Platform_thread(_context->name); + + platform_specific()->core_pd()->bind_thread(pt); + _tid = pt->gate().dst(); + _thread_cap = reinterpret_cap_cast(pt->thread_cap()); + + pt->pager(platform_specific()->core_pager()); + pt->start((void *)_thread_start, _context->stack); + + /* + * send newly constructed thread, pointer to its Thread_base object, + * and its badge + */ + Msgbuf<128> snd_msg, rcv_msg; + Ipc_client cli(_thread_cap, &snd_msg, &rcv_msg); + cli << (addr_t)this << pt->gate().local_name() << IPC_CALL; +} + + +void Thread_base::cancel_blocking() +{ + /* + * Within core, we never need to unblock threads + */ +} diff --git a/base-foc/src/core/x86/platform_thread.cc b/base-foc/src/core/x86/platform_thread.cc new file mode 100644 index 000000000..da360874a --- /dev/null +++ b/base-foc/src/core/x86/platform_thread.cc @@ -0,0 +1,27 @@ +/* + * \brief Fiasco.OC thread facility (x86 specifics) + * \author Stefan Kalkowski + * \date 2011-09-08 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include + + +bool Genode::Platform_thread::_in_syscall(Fiasco::l4_umword_t flags) +{ + using namespace Genode; + + return flags & X86::IOPL; +} diff --git a/base-foc/src/core/x86/platform_x86.cc b/base-foc/src/core/x86/platform_x86.cc new file mode 100644 index 000000000..a5829af40 --- /dev/null +++ b/base-foc/src/core/x86/platform_x86.cc @@ -0,0 +1,44 @@ +/* + * \brief Platform support specific to x86 + * \author Christian Helmuth + * \author Stefan Kalkowski + * \date 2006-04-11 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +#include "platform.h" +#include "util.h" + +/* Fiasco.OC includes */ +namespace Fiasco { +#include +} + +void Genode::Platform::_setup_io_port_alloc() +{ + using namespace Fiasco; + + l4_fpage_t fpage = l4_iofpage(0, L4_WHOLE_IOADDRESS_SPACE); + l4_utcb_mr()->mr[0] = fpage.raw; + l4_utcb_br()->bdr &= ~L4_BDR_OFFSET_MASK; + l4_utcb_br()->br[0] = L4_ITEM_MAP; + l4_utcb_br()->br[1] = fpage.raw; + l4_msgtag_t tag = l4_ipc_call(L4_BASE_PAGER_CAP, l4_utcb(), + l4_msgtag(L4_PROTO_IO_PAGE_FAULT, 1, 0, 0), + L4_IPC_NEVER); + + if (l4_ipc_error(tag, l4_utcb())) + panic("Received no I/O ports from sigma0"); + + /* setup allocator */ + _io_port_alloc.add_range(0, 0x10000); +} diff --git a/base-foc/src/core/x86/target.mk b/base-foc/src/core/x86/target.mk new file mode 100644 index 000000000..4a5ca470b --- /dev/null +++ b/base-foc/src/core/x86/target.mk @@ -0,0 +1,8 @@ +include $(PRG_DIR)/../target.inc + +REQUIRES += x86 +SRC_CC += x86/platform_x86.cc \ + x86/platform_thread.cc + +vpath io_port_session_component.cc $(GEN_CORE_DIR)/x86 + diff --git a/base-foc/src/kernel/pbxa9/target.mk b/base-foc/src/kernel/pbxa9/target.mk new file mode 100644 index 000000000..7efed8180 --- /dev/null +++ b/base-foc/src/kernel/pbxa9/target.mk @@ -0,0 +1,4 @@ +REQUIRES = platform_pbxa9 +KERNEL_CONFIG = $(REP_DIR)/config/pbxa9.kernel + +-include $(PRG_DIR)/../target.inc diff --git a/base-foc/src/kernel/target.inc b/base-foc/src/kernel/target.inc new file mode 100644 index 000000000..62dd563b3 --- /dev/null +++ b/base-foc/src/kernel/target.inc @@ -0,0 +1,21 @@ +TARGET = fiasco.oc +REQUIRES += foc +FOC_BUILD_DIR = $(BUILD_BASE_DIR)/kernel/$(TARGET) +FIASCO = $(FOC_BUILD_DIR)/fiasco +FIASCO_SRC = $(REP_DIR)/contrib/kernel/fiasco +STARTUP_LIB = + +$(TARGET): $(FIASCO) + +$(FOC_BUILD_DIR): + $(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \ + $(VERBOSE_DIR) -C $(FIASCO_SRC) BUILDDIR=$@ + $(VERBOSE)cp $(KERNEL_CONFIG) $@/globalconfig.out + +$(FIASCO): $(FOC_BUILD_DIR) + $(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \ + $(VERBOSE_DIR) -C $(FOC_BUILD_DIR) + $(VERBOSE)ln -sf $@ $(BUILD_BASE_DIR)/bin/$(TARGET) + +clean cleanall: + $(VERBOSE)rm -rf $(FOC_BUILD_DIR) diff --git a/base-foc/src/kernel/vea9x4/target.mk b/base-foc/src/kernel/vea9x4/target.mk new file mode 100644 index 000000000..b4b1ffa60 --- /dev/null +++ b/base-foc/src/kernel/vea9x4/target.mk @@ -0,0 +1,4 @@ +REQUIRES = platform_vea9x4 +KERNEL_CONFIG = $(REP_DIR)/config/vea9x4.kernel + +-include $(PRG_DIR)/../target.inc diff --git a/base-foc/src/kernel/x86_32/target.mk b/base-foc/src/kernel/x86_32/target.mk new file mode 100644 index 000000000..7324e497e --- /dev/null +++ b/base-foc/src/kernel/x86_32/target.mk @@ -0,0 +1,4 @@ +REQUIRES = x86 32bit +KERNEL_CONFIG = $(REP_DIR)/config/x86_32.kernel + +-include $(PRG_DIR)/../target.inc diff --git a/base-foc/src/kernel/x86_64/target.mk b/base-foc/src/kernel/x86_64/target.mk new file mode 100644 index 000000000..f01766c42 --- /dev/null +++ b/base-foc/src/kernel/x86_64/target.mk @@ -0,0 +1,4 @@ +REQUIRES = x86 64bit +KERNEL_CONFIG = $(REP_DIR)/config/x86_64.kernel + +-include $(PRG_DIR)/../target.inc diff --git a/base-foc/src/platform/_main_helper.h b/base-foc/src/platform/_main_helper.h new file mode 100644 index 000000000..05d69d205 --- /dev/null +++ b/base-foc/src/platform/_main_helper.h @@ -0,0 +1,29 @@ +/* + * \brief Platform-specific helper functions for the _main() function + * \author Christian Prochaska + * \date 2009-08-05 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _PLATFORM___MAIN_HELPER_H_ +#define _PLATFORM___MAIN_HELPER_H_ + +/* Genode includes */ +#include + +namespace Fiasco { +#include +} + + +static void main_thread_bootstrap() { + Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_THREAD_OBJ] = 0; } + + +#endif /* _PLATFORM___MAIN_HELPER_H_ */ diff --git a/base-foc/src/platform/_main_parent_cap.h b/base-foc/src/platform/_main_parent_cap.h new file mode 100644 index 000000000..570449a9d --- /dev/null +++ b/base-foc/src/platform/_main_parent_cap.h @@ -0,0 +1,36 @@ +/* + * \brief Obtain parent capability + * \author Norman Feske + * \date 2010-01-26 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _PLATFORM__MAIN_PARENT_CAP_H_ +#define _PLATFORM__MAIN_PARENT_CAP_H_ + +#include + +namespace Genode { + + /** + * Return constructed parent capability + */ + Parent_capability parent_cap() + { + Native_capability cap; + memcpy(&cap, (void *)&_parent_cap, sizeof(cap)); + + /* assemble parent capability from object ID and Fiasco cap */ + return reinterpret_cap_cast( + Native_capability(Fiasco::Fiasco_capability::PARENT_CAP, + cap.local_name())); + } +} + +#endif /* _PLATFORM__MAIN_PARENT_CAP_H_ */ diff --git a/base-foc/src/sigma0/target.mk b/base-foc/src/sigma0/target.mk new file mode 100644 index 000000000..81726b75a --- /dev/null +++ b/base-foc/src/sigma0/target.mk @@ -0,0 +1,5 @@ +TARGET = l4f/sigma0 +PKGS = sigma0 +LIBS = l4re_support + +include $(REP_DIR)/mk/l4_pkg.mk diff --git a/base-host/README b/base-host/README new file mode 100644 index 000000000..3e7487c66 --- /dev/null +++ b/base-host/README @@ -0,0 +1,7 @@ +This repository contains dummy implementations of platform-specific Genode APIs +to enable the compilation of Genode for the host platform. Because the +repository provides only dummy implementations, most of the generated binaries +will not work. However, the repository serves two important purposes. It +documents the platform- specific APIs that must be filled out when porting +Genode to another platform, and it is the build environment for unit tests +executed on the host platform. diff --git a/base-host/etc/specs.conf b/base-host/etc/specs.conf new file mode 100644 index 000000000..834b0f8f4 --- /dev/null +++ b/base-host/etc/specs.conf @@ -0,0 +1,13 @@ +# +# Description of build platform +# + +# +# If you want to build the host-specific Genode +# binaries, use this config option. +# +ifeq ($(shell uname -m),x86_64) +SPECS ?= host x86_64 +else +SPECS ?= host x86_32 +endif diff --git a/base-host/etc/tools.conf b/base-host/etc/tools.conf new file mode 100644 index 000000000..b051c01e2 --- /dev/null +++ b/base-host/etc/tools.conf @@ -0,0 +1,4 @@ +# +# Use the default host compiler instead of the Genode tool chain +# +CROSS_DEV_PREFIX = diff --git a/base-host/include/base/ipc_msgbuf.h b/base-host/include/base/ipc_msgbuf.h new file mode 100644 index 000000000..ac3bc03c2 --- /dev/null +++ b/base-host/include/base/ipc_msgbuf.h @@ -0,0 +1,39 @@ +/* + * \brief Dummy IPC message buffer + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_ +#define _INCLUDE__BASE__IPC_MSGBUF_H_ + +namespace Genode { + + class Msgbuf_base + { + private: + + size_t _size; + + public: + + char buf[]; + + /** + * Return size of message buffer + */ + inline size_t size() const { return _size; }; + }; + + template + class Msgbuf : public Msgbuf_base { }; +} + +#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */ diff --git a/base-host/include/base/ipc_pager.h b/base-host/include/base/ipc_pager.h new file mode 100644 index 000000000..9c8a9760a --- /dev/null +++ b/base-host/include/base/ipc_pager.h @@ -0,0 +1,139 @@ +/* + * \brief Dummy pager support for Genode + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_PAGER_H_ +#define _INCLUDE__BASE__IPC_PAGER_H_ + +#include +#include +#include + +namespace Genode { + + class Mapping + { + public: + + /** + * Constructor + */ + Mapping(addr_t dst_addr, addr_t src_addr, + bool write_combined, unsigned l2size = 12, bool rw = true) { } + + /** + * Construct invalid mapping + */ + Mapping() { } + + /** + * Prepare map operation + */ + void prepare_map_operation() { } + }; + + + /** + * Special paging server class + */ + class Ipc_pager : public Native_capability + { + protected: + + /** + * Wait for short-message (register) IPC -- pagefault + */ + void _wait() { } + + /** + * Send short flex page and + * wait for next short-message (register) IPC -- pagefault + */ + void _reply_and_wait() { } + + public: + + /** + * Constructor + */ + Ipc_pager() { } + + /** + * Wait for a new fault received as short message IPC + */ + void wait_for_fault() { } + + /** + * Reply current page-fault and wait for a new one + * + * Send short flex page and wait for next short-message (register) + * IPC -- fault + */ + void reply_and_wait_for_fault() { } + + /** + * Request instruction pointer of current page fault + */ + addr_t fault_ip() { return 0; } + + /** + * Request fault address of current page fault + */ + addr_t fault_addr() { return 0; } + + /** + * Set parameters for next reply + */ + void set_reply_mapping(Mapping m) { } + + /** + * Set destination for next reply + */ + void set_reply_dst(Native_capability pager_object) { } + + /** + * Answer call without sending a flex-page mapping + * + * This function is used to acknowledge local calls from one of + * core's region-manager sessions. + */ + void acknowledge_wakeup() { } + + /** + * Return thread ID of last faulter + */ + Native_thread_id last() const { return 0; } + + /** + * Return badge for faulting thread + */ + unsigned long badge() const { return 0; } + + /** + * Return true if last fault was a write fault + */ + bool is_write_fault() const { return false; } + + /** + * Return true if last fault was an exception + */ + bool is_exception() const + { + /* + * Reflection of exceptions is not supported on this platform. + */ + return false; + } + }; +} + +#endif /* _INCLUDE__BASE__IPC_PAGER_H_ */ diff --git a/base-host/include/base/native_types.h b/base-host/include/base/native_types.h new file mode 100644 index 000000000..57ecd778a --- /dev/null +++ b/base-host/include/base/native_types.h @@ -0,0 +1,45 @@ +/* + * \brief Dummy definitions for native types used for compiling unit tests + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ +#define _INCLUDE__BASE__NATIVE_TYPES_H_ + +namespace Genode { + + typedef volatile int Native_lock; + typedef int Native_thread; + typedef Native_thread Native_thread_id; + typedef struct { } Native_utcb; + + class Native_capability + { + private: + + long _local_name; + + public: + + Native_capability() : _local_name(0) { } + Native_capability(Native_thread_id, long local_name) + : _local_name(local_name) { } + + bool valid() const { return _local_name != 0; } + int local_name() const { return _local_name; } + int dst() const { return 0; } + Native_thread_id tid() const { return 0; } + }; + + typedef int Native_connection_state; +} + +#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */ diff --git a/base-host/lib/mk/core_printf.mk b/base-host/lib/mk/core_printf.mk new file mode 100644 index 000000000..a0fa6a56b --- /dev/null +++ b/base-host/lib/mk/core_printf.mk @@ -0,0 +1 @@ +LIBS = printf_stdio console diff --git a/base-host/lib/mk/env.mk b/base-host/lib/mk/env.mk new file mode 100644 index 000000000..915a0ccbe --- /dev/null +++ b/base-host/lib/mk/env.mk @@ -0,0 +1,6 @@ +SRC_CC = env.cc parent.cc context_area.cc +LIBS = ipc heap lock log_console + +vpath env.cc $(BASE_DIR)/src/base/env +vpath context_area.cc $(BASE_DIR)/src/base/env +vpath parent.cc $(REP_DIR)/src/base/env diff --git a/base-host/lib/mk/ipc.mk b/base-host/lib/mk/ipc.mk new file mode 100644 index 000000000..524cb1f03 --- /dev/null +++ b/base-host/lib/mk/ipc.mk @@ -0,0 +1,3 @@ +SRC_CC = ipc.cc + +vpath ipc.cc $(REP_DIR)/src/base/ipc diff --git a/base-host/lib/mk/lock.mk b/base-host/lib/mk/lock.mk new file mode 100644 index 000000000..a79c1d9a1 --- /dev/null +++ b/base-host/lib/mk/lock.mk @@ -0,0 +1,4 @@ +SRC_CC = lock.cc +INC_DIR += $(REP_DIR)/src/base/lock + +vpath lock.cc $(BASE_DIR)/src/base/lock diff --git a/base-host/lib/mk/pager.mk b/base-host/lib/mk/pager.mk new file mode 100644 index 000000000..c22e66d22 --- /dev/null +++ b/base-host/lib/mk/pager.mk @@ -0,0 +1,3 @@ +SRC_CC = pager.cc + +vpath pager.cc $(REP_DIR)/src/base/pager diff --git a/base-host/lib/mk/printf_stdio.mk b/base-host/lib/mk/printf_stdio.mk new file mode 100644 index 000000000..8f910d8e9 --- /dev/null +++ b/base-host/lib/mk/printf_stdio.mk @@ -0,0 +1,3 @@ +SRC_CC = printf_stdio.cc + +vpath printf_stdio.cc $(REP_DIR)/src/lib/printf_stdio diff --git a/base-host/src/base/env/parent.cc b/base-host/src/base/env/parent.cc new file mode 100644 index 000000000..efc9378a0 --- /dev/null +++ b/base-host/src/base/env/parent.cc @@ -0,0 +1,24 @@ +/* + * \brief Access to pseudo parent capability + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +namespace Genode { + + /** + * Return parent capability + * + * This function is normally provided by the 'startup' library. + */ + Native_capability parent_cap() { return Native_capability(); } +} diff --git a/base-host/src/base/ipc/ipc.cc b/base-host/src/base/ipc/ipc.cc new file mode 100644 index 000000000..3055926c5 --- /dev/null +++ b/base-host/src/base/ipc/ipc.cc @@ -0,0 +1,77 @@ +/* + * \brief Dummy implementation of the IPC API + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +using namespace Genode; + + +/***************** + ** Ipc_ostream ** + *****************/ + +Ipc_ostream::Ipc_ostream(Native_capability dst, Msgbuf_base *snd_msg) +: + Ipc_marshaller(&snd_msg->buf[0], snd_msg->size()), + _snd_msg(snd_msg), _dst(dst) +{ } + + +/***************** + ** Ipc_istream ** + *****************/ + +void Ipc_istream::_wait() +{ } + + +Ipc_istream::Ipc_istream(Msgbuf_base *rcv_msg) : + Ipc_unmarshaller(&rcv_msg->buf[0], rcv_msg->size()), + _rcv_msg(rcv_msg) +{ } + + +Ipc_istream::~Ipc_istream() { } + + +/**************** + ** Ipc_client ** + ****************/ + +void Ipc_client::_call() { } + + +Ipc_client::Ipc_client(Native_capability const &srv, + Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg) +: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0) +{ } + + +/**************** + ** Ipc_server ** + ****************/ + +void Ipc_server::_wait() { } + + +void Ipc_server::_reply() { } + + +void Ipc_server::_reply_wait() { } + + +Ipc_server::Ipc_server(Msgbuf_base *snd_msg, + Msgbuf_base *rcv_msg) +: Ipc_istream(rcv_msg), Ipc_ostream(Native_capability(), snd_msg) +{ } diff --git a/base-host/src/base/lock/lock_helper.h b/base-host/src/base/lock/lock_helper.h new file mode 100644 index 000000000..c3197875a --- /dev/null +++ b/base-host/src/base/lock/lock_helper.h @@ -0,0 +1,52 @@ +/* + * \brief Dummy helper functions for the Lock implementation + * \author Norman Feske + * \date 2009-10-02 + * + * For documentation about the interface, please revisit the 'base-pistachio' + * implementation. + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + + +static inline void thread_yield() { } + + +static bool thread_check_stopped_and_restart(Genode::Native_thread_id tid) +{ + return true; +} + + +static inline Genode::Native_thread_id thread_get_my_native_id() +{ + return -1; +} + + +static inline Genode::Native_thread_id thread_invalid_id() +{ + return -1; +} + + +static inline bool thread_id_valid(Genode::Native_thread_id tid) +{ + return false; +} + + +static inline void thread_switch_to(Genode::Native_thread_id tid) +{ } + + +static inline void thread_stop_myself() { while (true); } diff --git a/base-host/src/base/pager/pager.cc b/base-host/src/base/pager/pager.cc new file mode 100644 index 000000000..34c91e9f3 --- /dev/null +++ b/base-host/src/base/pager/pager.cc @@ -0,0 +1,57 @@ +/* + * \brief Dummy pager framework + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +using namespace Genode; + + +/********************** + ** Pager activation ** + **********************/ + +void Pager_activation_base::entry() +{ + while (1); +} + + +/********************** + ** Pager entrypoint ** + **********************/ + +Pager_entrypoint::Pager_entrypoint(Cap_session *, Pager_activation_base *a) +: _activation(a) +{ _activation->ep(this); } + + +void Pager_entrypoint::dissolve(Pager_object *obj) +{ + remove(obj); +} + + +Pager_capability Pager_entrypoint::manage(Pager_object *obj) +{ + /* return invalid capability if no activation is present */ + if (!_activation) return Pager_capability(); + + Native_capability cap = Native_capability(_activation->cap().tid(), obj->badge()); + + /* add server object to object pool */ + obj->cap(cap); + insert(obj); + + /* return capability that uses the object id as badge */ + return Pager_capability(cap); +} diff --git a/base-host/src/core/context_area.cc b/base-host/src/core/context_area.cc new file mode 100644 index 000000000..0cf455b06 --- /dev/null +++ b/base-host/src/core/context_area.cc @@ -0,0 +1,90 @@ +/* + * \brief Support code for the thread API + * \author Norman Feske + * \date 2010-01-13 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include + + +/** + * Region-manager session for allocating thread contexts + */ +class Context_area_rm_session : public Genode::Rm_session +{ + public: + + /** + * Attach backing store to thread-context area + */ + Local_addr attach(Genode::Dataspace_capability ds_cap, + Genode::size_t size, Genode::off_t offset, + bool use_local_addr, Local_addr local_addr) + { + PWRN("not implemented"); + return local_addr; + } + + void detach(Local_addr local_addr) { + PWRN("context area detach from 0x%p - not implemented", (void *)local_addr); } + + Genode::Pager_capability add_client(Genode::Thread_capability) { + return Genode::Pager_capability(); } + + void fault_handler(Genode::Signal_context_capability) { } + + State state() { return State(); } + + Genode::Dataspace_capability dataspace() { + return Genode::Dataspace_capability(); } +}; + + +class Context_area_ram_session : public Genode::Ram_session +{ + public: + + Genode::Ram_dataspace_capability alloc(Genode::size_t size) { + return Genode::Ram_dataspace_capability(); } + + void free(Genode::Ram_dataspace_capability) { } + + int ref_account(Genode::Ram_session_capability) { return 0; } + + int transfer_quota(Genode::Ram_session_capability, Genode::size_t) { return 0; } + + Genode::size_t quota() { return 0; } + + Genode::size_t used() { return 0; } +}; + + +/** + * Return single instance of the context-area RM and RAM session + */ +namespace Genode { + + Rm_session *env_context_area_rm_session() + { + static Context_area_rm_session inst; + return &inst; + } + + Ram_session *env_context_area_ram_session() + { + static Context_area_ram_session inst; + return &inst; + } +} + diff --git a/base-host/src/core/core_rm_session.cc b/base-host/src/core/core_rm_session.cc new file mode 100644 index 000000000..0c00829f2 --- /dev/null +++ b/base-host/src/core/core_rm_session.cc @@ -0,0 +1,30 @@ +/* + * \brief Core-local RM session + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include + +using namespace Genode; + + +Rm_session::Local_addr +Core_rm_session::attach(Dataspace_capability ds_cap, size_t size, + off_t offset, bool use_local_addr, + Rm_session::Local_addr local_addr) +{ + PWRN("not implemented"); + return 0; +} diff --git a/base-host/src/core/include/core_rm_session.h b/base-host/src/core/include/core_rm_session.h new file mode 100644 index 000000000..ac46b2640 --- /dev/null +++ b/base-host/src/core/include/core_rm_session.h @@ -0,0 +1,48 @@ +/* + * \brief Core-local region manager session + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__CORE_RM_SESSION_H_ +#define _CORE__INCLUDE__CORE_RM_SESSION_H_ + +/* Genode includes */ +#include + +/* core includes */ +#include + +namespace Genode { + + class Core_rm_session : public Rm_session + { + public: + + Core_rm_session(Rpc_entrypoint *ds_ep) { } + + Local_addr attach(Dataspace_capability ds_cap, size_t size=0, + off_t offset=0, bool use_local_addr = false, + Local_addr local_addr = 0); + + void detach(Local_addr local_addr) { } + + Pager_capability add_client(Thread_capability thread) { + return Pager_capability(); } + + void fault_handler(Signal_context_capability handler) { } + + State state() { return State(); } + + Dataspace_capability dataspace() { return Dataspace_capability(); } + }; +} + +#endif /* _CORE__INCLUDE__CORE_RM_SESSION_H_ */ diff --git a/base-host/src/core/include/platform.h b/base-host/src/core/include/platform.h new file mode 100644 index 000000000..0b467602e --- /dev/null +++ b/base-host/src/core/include/platform.h @@ -0,0 +1,50 @@ +/* + * \brief Platform interface + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_H_ +#define _CORE__INCLUDE__PLATFORM_H_ + +/* core includes */ +#include + +namespace Genode { + + class Platform : public Platform_generic + { + public: + + /** + * Constructor + */ + Platform(); + + + /******************************** + ** Generic platform interface ** + ********************************/ + + Range_allocator *ram_alloc() { return 0; } + Range_allocator *io_mem_alloc() { return 0; } + Range_allocator *io_port_alloc() { return 0; } + Range_allocator *irq_alloc() { return 0; } + Range_allocator *region_alloc() { return 0; } + Allocator *core_mem_alloc() { return 0; } + addr_t vm_start() const { return 0; } + size_t vm_size() const { return 0; } + Rom_fs *rom_fs() { return 0; } + + void wait_for_exit(); + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_H_ */ diff --git a/base-host/src/core/include/platform_pd.h b/base-host/src/core/include/platform_pd.h new file mode 100644 index 000000000..7c051aba3 --- /dev/null +++ b/base-host/src/core/include/platform_pd.h @@ -0,0 +1,59 @@ +/* + * \brief Protection-domain facility + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_PD_H_ +#define _CORE__INCLUDE__PLATFORM_PD_H_ + +#include + +namespace Genode { + + class Platform_thread; + class Platform_pd + { + public: + + /** + * Constructors + */ + Platform_pd(bool core); + Platform_pd(signed pd_id = -1, bool create = true); + + /** + * Destructor + */ + ~Platform_pd(); + + /** + * Bind thread to protection domain + * + * \return 0 on success or + * -1 if thread ID allocation failed. + */ + int bind_thread(Platform_thread *thread); + + /** + * Unbind thread from protection domain + * + * Free the thread's slot and update thread object. + */ + void unbind_thread(Platform_thread *thread); + + /** + * Assign parent interface to protection domain + */ + int assign_parent(Native_capability parent) { return 0; } + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */ diff --git a/base-host/src/core/include/platform_thread.h b/base-host/src/core/include/platform_thread.h new file mode 100644 index 000000000..e62719001 --- /dev/null +++ b/base-host/src/core/include/platform_thread.h @@ -0,0 +1,106 @@ +/* + * \brief Thread facility + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__PLATFORM_THREAD_H_ +#define _CORE__INCLUDE__PLATFORM_THREAD_H_ + +/* Genode includes */ +#include +#include +#include + +namespace Genode { + + class Platform_pd; + class Platform_thread + { + public: + + enum { THREAD_INVALID = -1 }; /* invalid thread number */ + + /** + * Constructor + */ + Platform_thread(const char *name = 0, unsigned priority = 0, + int thread_id = THREAD_INVALID); + + /** + * Destructor + */ + ~Platform_thread(); + + /** + * Start thread + * + * \param ip instruction pointer to start at + * \param sp stack pointer to use + * \param cpu_no target cpu + * + * \retval 0 successful + * \retval -1 thread could not be started + */ + int start(void *ip, void *sp, unsigned int cpu_no = 0); + + /** + * Pause this thread + */ + void pause(); + + /** + * Resume this thread + */ + void resume(); + + /** + * Cancel currently blocking operation + */ + void cancel_blocking(); + + /** + * Request thread state + * + * \param state_dst destination state buffer + * + * \retval 0 successful + * \retval -1 thread state not accessible + */ + int state(Genode::Thread_state *state_dst); + + + /************************ + ** Accessor functions ** + ************************/ + + /** + * Set pager + */ + void pager(Pager_object *pager) { } + + /** + * Return identification of thread when faulting + */ + unsigned long pager_object_badge() const; + + /** + * Set the executing CPU for this thread. + */ + void set_cpu(unsigned int cpu_no); + + /** + * Get thread name + */ + const char *name() const { return "noname"; } + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */ diff --git a/base-host/src/core/include/util.h b/base-host/src/core/include/util.h new file mode 100644 index 000000000..4f50f05f9 --- /dev/null +++ b/base-host/src/core/include/util.h @@ -0,0 +1,60 @@ +/* + * \brief Core-internal utilities + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__UTIL_H_ +#define _CORE__INCLUDE__UTIL_H_ + +/* Genode includes */ +#include +#include + +namespace Genode { + + inline size_t get_page_size_log2() { return 12; } + inline size_t get_page_size() { return 1 << get_page_size_log2(); } + inline addr_t get_page_mask() { return ~(get_page_size() - 1); } + inline addr_t trunc_page(addr_t addr) { return addr & get_page_mask(); } + inline addr_t round_page(addr_t addr) { return trunc_page(addr + get_page_size() - 1); } + + /** + * Select source used for map operations + */ + inline addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; } + + /** + * Return highest supported flexpage size for the given mapping size + * + * This function is called by the page-fault handler to determine the + * mapping granularity to be used for a page-fault answer. If a kernel + * supports flexible page sizes, this function can just return the + * argument. If a kernel only supports a certain set of map sizes such + * as 4K and 4M, this function should select one of those smaller or + * equal to the argument. + */ + inline size_t constrain_map_size_log2(size_t size_log2) + { + return get_page_size_log2(); + } + + inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip, + Rm_session::Fault_type pf_type, + unsigned long faulter_badge) + { + printf("%s (%s pf_addr=%p pf_ip=%p from %02lx)", msg, + pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ", + (void *)pf_addr, (void *)pf_ip, + faulter_badge); + } +} + +#endif /* _CORE__INCLUDE__UTIL_H_ */ diff --git a/base-host/src/core/io_mem_session_support.cc b/base-host/src/core/io_mem_session_support.cc new file mode 100644 index 000000000..6b1f5715e --- /dev/null +++ b/base-host/src/core/io_mem_session_support.cc @@ -0,0 +1,27 @@ +/* + * \brief Implementation of the IO_MEM session interface + * \author Norman Feske + * \date 2009-03-29 + * + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + + +using namespace Genode; + + +void Io_mem_session_component::_unmap_local(addr_t base, size_t size) +{ } + + +addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) +{ return 0; } diff --git a/base-host/src/core/io_port_session_component.cc b/base-host/src/core/io_port_session_component.cc new file mode 100644 index 000000000..c90a87b7e --- /dev/null +++ b/base-host/src/core/io_port_session_component.cc @@ -0,0 +1,58 @@ +/* + * \brief Implementation of the IO_PORT session interface + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include "io_port_session_component.h" + +using namespace Genode; + + +/************** + ** Port API ** + **************/ + +unsigned char Io_port_session_component::inb(unsigned short address) { + return 0; } + + +unsigned short Io_port_session_component::inw(unsigned short address) { + return 0; } + + +unsigned Io_port_session_component::inl(unsigned short address) { + return 0; } + + +void Io_port_session_component::outb(unsigned short address, unsigned char value) +{ } + + +void Io_port_session_component::outw(unsigned short address, unsigned short value) +{ } + + +void Io_port_session_component::outl(unsigned short address, unsigned value) +{ } + + +/****************************** + ** Constructor / destructor ** + ******************************/ + +Io_port_session_component::Io_port_session_component(Range_allocator *io_port_alloc, + const char *args) +: _io_port_alloc(io_port_alloc) +{ } + + +Io_port_session_component::~Io_port_session_component() +{ } diff --git a/base-host/src/core/irq_session_component.cc b/base-host/src/core/irq_session_component.cc new file mode 100644 index 000000000..4e5226958 --- /dev/null +++ b/base-host/src/core/irq_session_component.cc @@ -0,0 +1,54 @@ +/* + * \brief Implementation of IRQ session component + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include + + +using namespace Genode; + + +bool Irq_session_component::Irq_control_component::associate_to_irq(unsigned irq) +{ + PWRN("not implemented"); + return true; +} + + +void Irq_session_component::wait_for_irq() +{ + PWRN("not implemented"); +} + + +Irq_session_component::Irq_session_component(Cap_session *cap_session, + Range_allocator *irq_alloc, + const char *args) +: + _irq_alloc(irq_alloc), + _ep(cap_session, STACK_SIZE, "irqctrl"), + _irq_attached(false), + _control_client(Capability()) +{ + PWRN("not implemented"); +} + + +Irq_session_component::~Irq_session_component() +{ + PERR("not yet implemented"); +} + diff --git a/base-host/src/core/platform.cc b/base-host/src/core/platform.cc new file mode 100644 index 000000000..96beed570 --- /dev/null +++ b/base-host/src/core/platform.cc @@ -0,0 +1,41 @@ +/* + * \brief Platform interface implementation + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include +#include + +using namespace Genode; + + +Platform::Platform() +{ + PWRN("not implemented"); +} + + +/******************************** + ** Generic platform interface ** + ********************************/ + +void Platform::wait_for_exit() +{ + sleep_forever(); +} + + +void Core_parent::exit(int exit_value) { } diff --git a/base-host/src/core/platform_pd.cc b/base-host/src/core/platform_pd.cc new file mode 100644 index 000000000..4d4487073 --- /dev/null +++ b/base-host/src/core/platform_pd.cc @@ -0,0 +1,55 @@ +/* + * \brief Protection-domain facility + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include + +using namespace Genode; + + +/*************************** + ** Public object members ** + ***************************/ + +int Platform_pd::bind_thread(Platform_thread *thread) +{ + PWRN("not implemented"); + return -1; +} + + +void Platform_pd::unbind_thread(Platform_thread *thread) +{ + PWRN("not implemented"); +} + + +Platform_pd::Platform_pd(bool core) +{ + PWRN("not yet implemented"); +} + + +Platform_pd::Platform_pd(signed pd_id, bool create) +{ + PWRN("not yet implemented"); +} + + +Platform_pd::~Platform_pd() +{ + PWRN("not yet implemented"); +} diff --git a/base-host/src/core/platform_thread.cc b/base-host/src/core/platform_thread.cc new file mode 100644 index 000000000..6d9dfff82 --- /dev/null +++ b/base-host/src/core/platform_thread.cc @@ -0,0 +1,77 @@ +/* + * \brief Thread facility + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include + +using namespace Genode; + + +void Platform_thread::set_cpu(unsigned int cpu_no) +{ + PERR("not yet implemented"); +} + + +int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no) +{ + PWRN("not implemented"); + return -1; +} + + +void Platform_thread::pause() +{ + PWRN("not implemented"); +} + + +void Platform_thread::resume() +{ + PWRN("not implemented"); +} + + +int Platform_thread::state(Thread_state *state_dst) +{ + PWRN("not implemented"); + return -1; +} + + +void Platform_thread::cancel_blocking() +{ + PWRN("not implemented"); +} + + +unsigned long Platform_thread::pager_object_badge() const +{ + PWRN("not implemented"); + return -1; +} + + +Platform_thread::Platform_thread(const char *name, unsigned, int thread_id) +{ + PWRN("not implemented"); +} + + +Platform_thread::~Platform_thread() +{ + PWRN("not implemented"); +} diff --git a/base-host/src/core/ram_session_support.cc b/base-host/src/core/ram_session_support.cc new file mode 100644 index 000000000..ae7dabee8 --- /dev/null +++ b/base-host/src/core/ram_session_support.cc @@ -0,0 +1,29 @@ +/* + * \brief Export RAM dataspace as shared memory object (dummy) + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include + + +using namespace Genode; + +void Ram_session_component::_export_ram_ds(Dataspace_component *ds) { } +void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds) { } + +void Ram_session_component::_clear_ds (Dataspace_component *ds) +{ + PWRN("not implemented"); +} diff --git a/base-host/src/core/rm_session_support.cc b/base-host/src/core/rm_session_support.cc new file mode 100644 index 000000000..4e8e309a3 --- /dev/null +++ b/base-host/src/core/rm_session_support.cc @@ -0,0 +1,26 @@ +/* + * \brief RM-session implementation + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* core includes */ +#include + +using namespace Genode; + + +void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size) +{ + PWRN("not implemented"); +} diff --git a/base-host/src/core/target.inc b/base-host/src/core/target.inc new file mode 100644 index 000000000..94d609385 --- /dev/null +++ b/base-host/src/core/target.inc @@ -0,0 +1,49 @@ +TARGET = core +LIBS = cxx ipc heap core_printf process pager lock \ + raw_signal raw_server + +GEN_CORE_DIR = $(BASE_DIR)/src/core + +SRC_CC = \ + main.cc \ + ram_session_component.cc \ + ram_session_support.cc \ + rom_session_component.cc \ + cpu_session_component.cc \ + pd_session_component.cc \ + io_mem_session_component.cc \ + io_mem_session_support.cc \ + thread.cc \ + thread_host.cc \ + thread_bootstrap.cc \ + platform_thread.cc \ + platform_pd.cc \ + platform.cc \ + dataspace_component.cc \ + rm_session_component.cc \ + rm_session_support.cc \ + io_port_session_component.cc \ + irq_session_component.cc \ + signal_session_component.cc \ + signal_source_component.cc \ + core_rm_session.cc \ + context_area.cc + +INC_DIR = $(REP_DIR)/src/core/include \ + $(GEN_CORE_DIR)/include + +vpath main.cc $(GEN_CORE_DIR) +vpath ram_session_component.cc $(GEN_CORE_DIR) +vpath rom_session_component.cc $(GEN_CORE_DIR) +vpath cpu_session_component.cc $(GEN_CORE_DIR) +vpath pd_session_component.cc $(GEN_CORE_DIR) +vpath rm_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_component.cc $(GEN_CORE_DIR) +vpath io_mem_session_support.cc $(GEN_CORE_DIR) +vpath signal_session_component.cc $(GEN_CORE_DIR) +vpath signal_source_component.cc $(GEN_CORE_DIR) +vpath dataspace_component.cc $(GEN_CORE_DIR) +vpath %.cc $(REP_DIR)/src/core +vpath thread_bootstrap.cc $(BASE_DIR)/src/base/thread +vpath thread.cc $(BASE_DIR)/src/base/thread + diff --git a/base-host/src/core/target.mk b/base-host/src/core/target.mk new file mode 100644 index 000000000..310689bf0 --- /dev/null +++ b/base-host/src/core/target.mk @@ -0,0 +1 @@ +include $(PRG_DIR)/target.inc diff --git a/base-host/src/core/thread_host.cc b/base-host/src/core/thread_host.cc new file mode 100644 index 000000000..da171551c --- /dev/null +++ b/base-host/src/core/thread_host.cc @@ -0,0 +1,23 @@ +/* + * \brief Implementation of Thread API interface for core + * \author Norman Feske + * \date 2006-05-03 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +using namespace Genode; + +void Thread_base::_init_platform_thread() { } +void Thread_base::_deinit_platform_thread() { } +void Thread_base::start() { } +void Thread_base::cancel_blocking() { } diff --git a/base-host/src/lib/printf_stdio/printf_stdio.cc b/base-host/src/lib/printf_stdio/printf_stdio.cc new file mode 100644 index 000000000..a1981ee00 --- /dev/null +++ b/base-host/src/lib/printf_stdio/printf_stdio.cc @@ -0,0 +1,35 @@ +/* + * \brief Genode::printf back-end for stdio + * \author Norman Feske + * \date 2009-10-06 + * + * This library can be used by unit test executed on the host platform to + * direct output from the Genode framework to stdout. + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include + + +void Genode::printf(const char *format, ...) +{ + va_list list; + va_start(list, format); + + ::vprintf(format, list); + + va_end(list); +} + + +void Genode::vprintf(const char *format, va_list list) +{ + ::vprintf(format, list); +} diff --git a/base-linux/README b/base-linux/README new file mode 100644 index 000000000..5322ef84f --- /dev/null +++ b/base-linux/README @@ -0,0 +1 @@ +This repository contains the Linux-specific implementation of Genode. diff --git a/base-linux/etc/specs.conf b/base-linux/etc/specs.conf new file mode 100644 index 000000000..7574aad19 --- /dev/null +++ b/base-linux/etc/specs.conf @@ -0,0 +1,22 @@ +# +# Description of build platform +# + +# +# If you want to build the Linux-specific Genode +# binaries, use this config option. +# +ifeq ($(shell uname -m),x86_64) +SPECS ?= genode linux_x86_64 sdl +else +SPECS ?= genode linux_x86_32 sdl +endif + +# +# If you want to build for the host platform, +# use the following config option. +# You need to specify '32bit' additionally to 'host' +# to include the 32bit-specific Genode include path +# containing integer definitions. +# +#SPECS ?= host 32bit diff --git a/base-linux/include/base/ipc_msgbuf.h b/base-linux/include/base/ipc_msgbuf.h new file mode 100644 index 000000000..c0f554830 --- /dev/null +++ b/base-linux/include/base/ipc_msgbuf.h @@ -0,0 +1,64 @@ +/* + * \brief Linux-specific layout of IPC message buffer + * \author Norman Feske + * \date 2006-06-14 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_ +#define _INCLUDE__BASE__IPC_MSGBUF_H_ + +namespace Genode { + + /** + * IPC message buffer layout + */ + class Msgbuf_base + { + protected: + + Genode::size_t _size; + char _msg_start[]; /* symbol marks start of message buffer data */ + + /* + * No member variables are allowed beyond this point! + */ + + public: + + char buf[]; + + /** + * Return size of message buffer + */ + inline Genode::size_t size() const { return _size; }; + + /** + * Return address of message buffer + */ + inline void *addr() { return &_msg_start[0]; }; + }; + + + /** + * Pump up IPC message buffer to specified buffer size + */ + template + class Msgbuf : public Msgbuf_base + { + public: + + char buf[BUF_SIZE]; + + Msgbuf() { _size = BUF_SIZE; } + }; +} + + +#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */ diff --git a/base-linux/include/base/local_interface.h b/base-linux/include/base/local_interface.h new file mode 100644 index 000000000..e7f08096c --- /dev/null +++ b/base-linux/include/base/local_interface.h @@ -0,0 +1,89 @@ +/* + * \brief Support for process-local pseudo capabilities + * \author Norman Feske + * \date 2011-11-21 + * + * Pseudo capabilities have a zero 'tid' and a non-zero 'local_name'. The local + * name is a pointer to the local object implementing the interface. Pseudo + * capabilties are valid only as arguments for local services that are prepared + * for it. I.e., the locally implemented RM service accepts pseudo dataspace + * capabilities that refer to managed dataspaces. Or the Linux-specific + * 'Rm_session_client' takes a pseudo capability to target RM-session + * invokations to the local implementation. + * + * Please note that this header file is not part of the official Genode API. + * It exists on no other platform than Linux and is meant for Genode-internal + * use only. + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__LOCAL_INTERFACE_H_ +#define _INCLUDE__BASE__LOCAL_INTERFACE_H_ + +#include +#include + +namespace Genode { + + /** + * Common base class of local interface implementations + */ + struct Local_interface + { + virtual ~Local_interface() { } + + /** + * Exception type + */ + class Non_local_capability { }; + + /** + * Convert pseudo capability to pointer to locally implemented session + * + * \param IF interface type + * \param cap pseudo capability + * + * \throw Non_local_capability if the argument does not refer to a + * locally implemented interface + */ + template + static IF *deref(Capability cap) + { + /* check if this is a pseudo capability */ + if (cap.tid() != 0 || !cap.local_name()) + throw Non_local_capability(); + + /* + * For a pseudo capability, the 'local_name' points to the local + * session object of the correct type. + */ + IF *interface = dynamic_cast((Local_interface *)cap.local_name()); + if (!interface) + throw Non_local_capability(); + + return interface; + } + + /** + * Construct pseudo capability to process-local interface implementation + * + * \param IF interface type + * \param interface pointer to local interface implementation + * \return pseudo capability + * + */ + template + static Capability capability(IF *interface) + { + return reinterpret_cap_cast(Native_capability(0, (long)interface)); + }; + }; +} + +#endif /* _INCLUDE__BASE__LOCAL_INTERFACE_H_ */ diff --git a/base-linux/include/base/native_types.h b/base-linux/include/base/native_types.h new file mode 100644 index 000000000..033eb53b9 --- /dev/null +++ b/base-linux/include/base/native_types.h @@ -0,0 +1,135 @@ +/* + * \brief Native types + * \author Norman Feske + * \date 2007-10-15 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ +#define _INCLUDE__BASE__NATIVE_TYPES_H_ + +/* + * We cannot just include and here + * because this would impy the nested inclusion of a myriad + * of Linux types and would pollute the namespace for everyone + * who includes this header file. We want to cleanly separate + * Genode from POSIX. + */ + +namespace Genode { + + /** + * Native lock type + * + * We are using a sleeping spinlock as lock implementation on Linux. This + * is a temporary solution until we have implemented futex-based locking. + * In a previous version, we have relied on POSIX semaphores as provided by + * the glibc. However, relying on the glibc badly interferes with a custom + * libc implementation. The glibc semaphore implementation expects to find + * a valid pthread structure via the TLS pointer. We do not have such a + * structure because we create threads via the 'clone' system call rather + * than 'pthread_create'. Hence we have to keep the base framework clean + * from glibc usage altogether. + */ + typedef volatile int Native_lock; + + /** + * Thread ID used in lock implementation + * + * Unfortunately, both - PID and TID - are needed for lx_tgkill() in + * thread_check_stopped_and_restart(). + */ + struct Native_thread_id + { + unsigned int tid; /* Native thread ID type as returned by the + 'clone' system call */ + unsigned int pid; /* process ID (resp. thread-group ID) */ + + Native_thread_id() : tid(0), pid(0) { } + Native_thread_id(unsigned int tid, unsigned int pid) + : tid(tid), pid(pid) { } + }; + + /** + * Native thread contains more thread-local data than just the ID + * + * A thread needs two sockets as it may be a server that depends on another + * service during request processing. If the server socket would be used for + * the client call, the server thread may be unblocked by further requests + * from its clients. In other words, the additional client socket provides + * closed-receive semantics in calls. An even better solution is to use + * SCM_RIGHTS messages to send a client socket descriptor with the request. + */ + struct Native_thread : Native_thread_id + { + int client; /* socket used as IPC client */ + int server; /* socket used as IPC server */ + + Native_thread() : client(-1), server(-1) { } + }; + + inline bool operator == (Native_thread_id t1, Native_thread_id t2) { + return (t1.tid == t2.tid) && (t1.pid == t2.pid); } + + inline bool operator != (Native_thread_id t1, Native_thread_id t2) { + return (t1.tid != t2.tid) || (t1.pid != t2.pid); } + + /** + * Empty UTCB type expected by the thread library, unused on Linux + */ + typedef struct { } Native_utcb; + + /* + * On Linux, the local_name member of a capability is global + * to the whole system. Therefore, capabilities are to be + * created at a central place that prevents id clashes. + */ + class Native_capability + { + protected: + + long _tid; /* target thread */ + long _local_name; + + public: + + /** + * Default constructor + */ + Native_capability() : _tid(0), _local_name(0) { } + + long local_name() const { return _local_name; } + + bool valid() const { return _tid != 0; } + + + /**************************************************** + ** Functions to be used by the Linux backend only ** + ****************************************************/ + + /** + * Constructor + * + * This constructor can be called to create a Linux + * capability by hand. It must never be used from + * generic code! + */ + Native_capability(long tid, long local_name) + : _tid(tid), _local_name(local_name) { } + + /** + * Access raw capability data + */ + long tid() const { return _tid; } + }; + + typedef int Native_connection_state; /* socket descriptor */ +} + +#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */ diff --git a/base-linux/include/base/pager.h b/base-linux/include/base/pager.h new file mode 100644 index 000000000..bd4b61f00 --- /dev/null +++ b/base-linux/include/base/pager.h @@ -0,0 +1,43 @@ +/* + * \brief Paging-server framework + * \author Norman Feske + * \author Christian Helmuth + * \date 2006-04-28 + * + * Linux dummies + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__PAGER_H_ +#define _INCLUDE__BASE__PAGER_H_ + +#include +#include +#include + +namespace Genode { + + struct Pager_object + { + virtual ~Pager_object() { } + + void exception_handler(Signal_context_capability) { } + }; + + class Pager_activation_base { }; + struct Pager_entrypoint + { + Pager_entrypoint(Cap_session *, Pager_activation_base *) { } + + Pager_object *obj_by_cap(Pager_capability) { return 0; } + }; + template class Pager_activation : public Pager_activation_base { }; +} + +#endif /* _INCLUDE__BASE__PAGER_H_ */ diff --git a/base-linux/include/base/platform_env.h b/base-linux/include/base/platform_env.h new file mode 100644 index 000000000..d98332fc5 --- /dev/null +++ b/base-linux/include/base/platform_env.h @@ -0,0 +1,379 @@ +/* + * \brief Linux-specific environment + * \author Norman Feske + * \author Christian Helmuth + * \date 2006-07-28 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__PLATFORM_ENV_H_ +#define _INCLUDE__BASE__PLATFORM_ENV_H_ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Genode { + + class Platform_env : public Env + { + private: + + /************************** + ** Local region manager ** + **************************/ + + class Region + { + private: + + addr_t _start; + off_t _offset; + Dataspace_capability _ds; + size_t _size; + + /** + * Return offset of first byte after the region + */ + addr_t _end() const { return _start + _size; } + + public: + + Region() : _start(0), _offset(0), _size(0) { } + + Region(addr_t start, off_t offset, Dataspace_capability ds, size_t size) + : _start(start), _offset(offset), _ds(ds), _size(size) { } + + bool used() const { return _size > 0; } + addr_t start() const { return _start; } + off_t offset() const { return _offset; } + size_t size() const { return _size; } + Dataspace_capability dataspace() const { return _ds; } + + bool intersects(Region const &r) const + { + return (r.start() < _end()) && (_start < r._end()); + } + }; + + + /** + * Meta data about dataspaces attached to an RM session + */ + class Region_map + { + public: + + enum { MAX_REGIONS = 4096 }; + + private: + + Region _map[MAX_REGIONS]; + + bool _id_valid(int id) const { + return (id >= 0 && id < MAX_REGIONS); } + + public: + + /** + * Add region to region map + * + * \return region ID, or + * -1 if out of metadata, or + * -2 if region conflicts existing region + */ + int add_region(Region const ®ion) + { + /* + * Check for region conflicts + */ + for (int i = 0; i < MAX_REGIONS; i++) { + if (_map[i].intersects(region)) + return -2; + } + + /* + * Allocate new region metadata + */ + int i; + for (i = 0; i < MAX_REGIONS; i++) + if (!_map[i].used()) break; + + if (i == MAX_REGIONS) { + PERR("maximum number of %d regions reached", + MAX_REGIONS); + return -1; + } + + _map[i] = region; + return i; + } + + Region region(int id) const + { + return _id_valid(id) ? _map[id] : Region(); + } + + Region lookup(addr_t start) + { + for (int i = 0; i < MAX_REGIONS; i++) + if (_map[i].start() == start) + return _map[i]; + return Region(); + } + + void remove_region(addr_t start) + { + for (int i = 0; i < MAX_REGIONS; i++) + if (_map[i].start() == start) + _map[i] = Region(); + } + }; + + + /* + * On Linux, we use a local region manager session + * that attaches dataspaces via mmap to the local + * address space. + */ + class Rm_session_mmap : public Local_interface, + public Rm_session, + public Dataspace + { + private: + + Lock _lock; /* protect '_rmap' */ + Region_map _rmap; + bool const _sub_rm; /* false if RM session is root */ + size_t const _size; + + /** + * Base offset of the RM session + * + * For a normal RM session (the one that comes with the + * 'env()', this value is zero. If the RM session is + * used as nested dataspace, '_base' contains the address + * where the managed dataspace is attached in the root RM + * session. + * + * Note that a managed dataspace cannot be attached more + * than once. Furthermore, managed dataspace cannot be + * attached to another managed dataspace. The nested + * dataspace emulation is solely implemented to support + * the common use case of managed dataspaces as mechanism + * to reserve parts of the local address space from being + * populated by the 'env()->rm_session()'. (i.e., for the + * context area, or for the placement of consecutive + * shared-library segments) + */ + addr_t _base; + + bool _is_attached() const { return _base > 0; } + + void _add_to_rmap(Region const &); + + public: + + Rm_session_mmap(bool sub_rm, size_t size = ~0) + : _sub_rm(sub_rm), _size(size), _base(0) { } + + ~Rm_session_mmap() + { + /* detach sub RM session when destructed */ + if (_sub_rm && _is_attached()) + env()->rm_session()->detach((void *)_base); + } + + + /************************************** + ** Region manager session interface ** + **************************************/ + + Local_addr attach(Dataspace_capability ds, size_t size, + off_t, bool, Local_addr); + + void detach(Local_addr local_addr); + + Pager_capability add_client(Thread_capability thread) { + return Pager_capability(); } + + void fault_handler(Signal_context_capability handler) { } + + State state() { return State(); } + + + /************************* + ** Dataspace interface ** + *************************/ + + size_t size() { return _size; } + + addr_t phys_addr() { return 0; } + + bool writable() { return true; } + + /** + * Return pseudo dataspace capability of the RM session + * + * The capability returned by this function is only usable + * as argument to 'Rm_session_mmap::attach'. It is not a + * real capability. + */ + Dataspace_capability dataspace() + { + return Local_interface::capability(this); + } + }; + + + class Expanding_ram_session_client : public Ram_session_client + { + Ram_session_capability _cap; + + public: + + Expanding_ram_session_client(Ram_session_capability cap) + : Ram_session_client(cap), _cap(cap) { } + + Ram_dataspace_capability alloc(size_t size) { + bool try_again; + do { + try_again = false; + try { + return Ram_session_client::alloc(size); + + } catch (Ram_session::Out_of_metadata) { + + /* give up if the error occurred a second time */ + if (try_again) + break; + + PINF("upgrade quota donation for Env::RAM session"); + env()->parent()->upgrade(_cap, "ram_quota=8K"); + try_again = true; + } + } while (try_again); + + return Ram_dataspace_capability(); + } + }; + + + /** + * Local interceptor of parent requests + * + * On Linux, we need to intercept calls to the parent interface to + * implement the RM service locally. This particular service is + * used for creating managed dataspaces, which allow the + * reservation of parts of the local address space from being + * automatically managed by the 'env()->rm_session()'. + * + * All requests that do not refer to the RM service are passed + * through the real parent interface. + */ + class Local_parent : public Parent_client + { + public: + + /********************** + ** Parent interface ** + **********************/ + + Session_capability session(Service_name const &, + Session_args const &); + void close(Session_capability); + + /** + * Constructor + * + * \param parent_cap real parent capability used to + * promote requests to non-local + * services + */ + Local_parent(Parent_capability parent_cap); + }; + + + /************************************* + ** Linux-specific helper functions ** + *************************************/ + + /** + * Read Unix environment variable as long value + */ + static unsigned long _get_env_ulong(const char *key); + + + Parent_capability _parent_cap() + { + long tid = _get_env_ulong("parent_tid"); + long local_name = _get_env_ulong("parent_local_name"); + + /* produce typed capability manually */ + return reinterpret_cap_cast(Native_capability(tid, local_name)); + } + + + /******************************* + ** Platform-specific members ** + *******************************/ + + Local_parent _parent; + Ram_session_capability _ram_session_cap; + Expanding_ram_session_client _ram_session_client; + Cpu_session_client _cpu_session_client; + Rm_session_mmap _rm_session_mmap; + Heap _heap; + + public: + + /** + * Standard constructor + */ + Platform_env() + : + _parent(_parent_cap()), + _ram_session_cap(static_cap_cast(parent()->session("Env::ram_session", ""))), + _ram_session_client(_ram_session_cap), + _cpu_session_client(static_cap_cast(parent()->session("Env::cpu_session", ""))), + _rm_session_mmap(false), + _heap(&_ram_session_client, &_rm_session_mmap) + { } + + /** + * Destructor + */ + ~Platform_env() { parent()->exit(0); } + + + /******************* + ** Env interface ** + *******************/ + + Parent *parent() { return &_parent; } + Ram_session *ram_session() { return &_ram_session_client; } + Ram_session_capability ram_session_cap() { return _ram_session_cap; } + Rm_session *rm_session() { return &_rm_session_mmap; } + Heap *heap() { return &_heap; } + Cpu_session *cpu_session() { return &_cpu_session_client; } + Pd_session *pd_session() { return 0; } + }; +} + +#endif /* _INCLUDE__BASE__PLATFORM_ENV_H_ */ diff --git a/base-linux/include/linux_dataspace/client.h b/base-linux/include/linux_dataspace/client.h new file mode 100644 index 000000000..284bb27d0 --- /dev/null +++ b/base-linux/include/linux_dataspace/client.h @@ -0,0 +1,47 @@ +/* + * \brief Linux-specific dataspace client interface + * \author Norman Feske + * \date 2006-05-11 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__LINUX_DATASPACE__CLIENT_H_ +#define _INCLUDE__LINUX_DATASPACE__CLIENT_H_ + +#include +#include +#include +#include + +namespace Genode { + + struct Linux_dataspace_client : Rpc_client + { + explicit Linux_dataspace_client(Dataspace_capability ds) + : Rpc_client(static_cap_cast(ds)) { } + + + /********************************* + ** Generic dataspace interface ** + *********************************/ + + size_t size() { return call(); } + addr_t phys_addr() { return call(); } + bool writable() { return call(); } + + + /**************************************** + ** Linux-specific dataspace interface ** + ****************************************/ + + Filename fname() { return call(); } + }; +} + +#endif /* _INCLUDE__LINUX_DATASPACE__CLIENT_H_ */ diff --git a/base-linux/include/linux_dataspace/linux_dataspace.h b/base-linux/include/linux_dataspace/linux_dataspace.h new file mode 100644 index 000000000..432cadd0f --- /dev/null +++ b/base-linux/include/linux_dataspace/linux_dataspace.h @@ -0,0 +1,47 @@ +/* + * \brief Linux-specific dataspace interface + * \author Norman Feske + * \date 2006-07-05 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__LINUX_DATASPACE__LINUX_DATASPACE_H_ +#define _INCLUDE__LINUX_DATASPACE__LINUX_DATASPACE_H_ + +#include +#include +#include +#include + +namespace Genode { + + struct Linux_dataspace : Dataspace + { + enum { FNAME_LEN = 32 }; + + struct Filename { char buf[FNAME_LEN]; }; + + virtual ~Linux_dataspace() { } + + /** + * Request name of file that represents the dataspace on Linux + */ + virtual Filename fname() = 0; + + /********************* + ** RPC declaration ** + *********************/ + + + GENODE_RPC(Rpc_fname, Filename, fname); + GENODE_RPC_INTERFACE_INHERIT(Dataspace, Rpc_fname); + }; +} + +#endif /* _INCLUDE__LINUX_DATASPACE__LINUX_DATASPACE_H_ */ diff --git a/base-linux/include/rm_session/client.h b/base-linux/include/rm_session/client.h new file mode 100644 index 000000000..c06312ff3 --- /dev/null +++ b/base-linux/include/rm_session/client.h @@ -0,0 +1,59 @@ +/* + * \brief Pseudo RM-session client stub targeting the process-local RM service + * \author Norman Feske + * \date 2011-11-21 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__RM_SESSION__CLIENT_H_ +#define _INCLUDE__RM_SESSION__CLIENT_H_ + +#include +#include + +namespace Genode { + + struct Rm_session_client : Rm_session + { + Rm_session_capability const _cap; + + /** + * Return pointer to locally implemented RM session + * + * \throw Local_interface::Non_local_capability + */ + Rm_session *_local() const { return Local_interface::deref(_cap); } + + explicit Rm_session_client(Rm_session_capability session) + : _cap(session) { } + + Local_addr attach(Dataspace_capability ds, size_t size, off_t offset, + bool use_local_addr, Local_addr local_addr) + { + return _local()->attach(ds, size, offset, use_local_addr, local_addr); + } + + void detach(Local_addr local_addr) { + return _local()->detach(local_addr); } + + Pager_capability add_client(Thread_capability thread) { + return _local()->add_client(thread); } + + void fault_handler(Signal_context_capability handler) { + return _local()->fault_handler(handler); } + + State state() { + return _local()->state(); } + + Dataspace_capability dataspace() { + return _local()->dataspace(); } + }; +} + +#endif /* _INCLUDE__RM_SESSION__CLIENT_H_ */ diff --git a/base-linux/lib/import/import-lx_hybrid.mk b/base-linux/lib/import/import-lx_hybrid.mk new file mode 100644 index 000000000..4c61c5904 --- /dev/null +++ b/base-linux/lib/import/import-lx_hybrid.mk @@ -0,0 +1,92 @@ +# +# Make Linux headers of the host platform available to the program +# +include $(call select_from_repositories,lib/import/import-syscall.mk) + +# +# Manually supply all library search paths of the host compiler to our tool +# chain. +# +HOST_LIB_SEARCH_DIRS := $(shell cc -print-search-dirs | grep libraries |\ + sed "s/.*=//" | sed "s/:/ /g" |\ + sed "s/\/ / /g" | sed "s/\/\$$//") +# +# Add search path for 'limits.h' +# +INC_DIR += $(shell echo "int main() {return 0;}" |\ + LANG=C $(CXX) -x c++ -v -E - 2>&1 |\ + sed '/^\#include <\.\.\.> search starts here:/,/^End of search list/!d' |\ + grep "include-fixed") + +# +# Add search paths for normal libraries +# +CXX_LINK_OPT += $(addprefix -L,$(HOST_LIB_SEARCH_DIRS)) + +# +# Add search paths for shared-library lookup +# +# We add all locations of shared libraries present in the ld.cache to our +# library search path. +# +HOST_SO_SEARCH_DIRS := $(sort $(dir $(shell ldconfig -p | sed "s/^.* \//\//" | grep "^\/"))) +LINK_ARG_PREFIX := -Wl, +CXX_LINK_OPT += $(addprefix $(LINK_ARG_PREFIX)-rpath-link $(LINK_ARG_PREFIX),$(HOST_SO_SEARCH_DIRS)) + +# +# The '__libc_csu_init' function is normally provided by the C library. We +# override the libc's version in our 'lx_hybrid' library to have a hook for +# Genode-specific initializations. Unfortunately, this way, we get two symbols +# with the same name. So we have to tell the linker to be forgiving. The order +# of the libraries at the linker command line determines which symbol is used. +# Therefore it is important to have 'lx_hybrid.lib.so' listed before '-lc', +# which is always the case when supplying '-lc' via 'EXT_OBJECTS' (not +# 'CXX_LINK_OPT'). +# +CXX_LINK_OPT += -Wl,--allow-multiple-definition + +# +# Make exceptions work +# +CXX_LINK_OPT += -Wl,--eh-frame-hdr + +# +# Add all libraries and their dependencies specified at the 'LX_LIBS' +# variable to the linker command line +# +ifneq ($(LX_LIBS),) +EXT_OBJECTS = $(shell pkg-config --static --libs $(LX_LIBS)) +endif + +# +# Use the host's startup codes, linker script, and dynamic linker +# +EXT_OBJECTS += $(shell cc -print-file-name=crt1.o) +EXT_OBJECTS += $(shell cc -print-file-name=crti.o) +EXT_OBJECTS += $(shell cc -print-file-name=crtbegin.o) +EXT_OBJECTS += $(shell cc -print-file-name=crtend.o) +EXT_OBJECTS += $(shell cc -print-file-name=crtn.o) +EXT_OBJECTS += -lgcc -lgcc_s -lsupc++ -lc + +# +# Some header files installed on GNU/Linux test for the GNU compiler. For +# example, 'stdio.h' might complain with the following error otherwise: +# +# /usr/include/stdio.h:432:27: error: expected initializer before ‘throw’ +# /usr/include/stdio.h:488:6: error: expected initializer before ‘throw’ +# +# By manually defining '_GNU_SOURCE', the header files are processed as +# expected. +# +CC_OPT += -D_GNU_SOURCE + +USE_HOST_LD_SCRIPT = yes + +ifeq (x86_64,$(findstring x86_64,$(SPECS))) +CXX_LINK_OPT += -Wl,--dynamic-linker=/lib64/ld-linux-x86-64.so.2 +else +CXX_LINK_OPT += -Wl,--dynamic-linker=/lib/ld-linux.so.2 +endif + +# because we use the host compiler's libgcc, omit the Genode toolchain's version +LD_LIBGCC = diff --git a/base-linux/lib/import/import-syscall.mk b/base-linux/lib/import/import-syscall.mk new file mode 100644 index 000000000..6e66dc920 --- /dev/null +++ b/base-linux/lib/import/import-syscall.mk @@ -0,0 +1,6 @@ +INC_DIR += $(dir $(call select_from_repositories,src/platform/linux_syscalls.h)) +INC_DIR += /usr/include + +# needed for Ubuntu 11.04 +INC_DIR += /usr/include/i386-linux-gnu +INC_DIR += /usr/include/x86_64-linux-gnu diff --git a/base-linux/lib/mk/core_printf.mk b/base-linux/lib/mk/core_printf.mk new file mode 100644 index 000000000..32ba72675 --- /dev/null +++ b/base-linux/lib/mk/core_printf.mk @@ -0,0 +1,5 @@ +SRC_CC = core_printf.cc +LIBS = cxx console syscall +INC_DIR += $(REP_DIR)/src/base/console + +vpath core_printf.cc $(BASE_DIR)/src/base/console diff --git a/base-linux/lib/mk/env.mk b/base-linux/lib/mk/env.mk new file mode 100644 index 000000000..d07cccbae --- /dev/null +++ b/base-linux/lib/mk/env.mk @@ -0,0 +1,6 @@ +SRC_CC = env.cc rm_session_mmap.cc platform_env.cc debug.cc context_area.cc +LIBS = ipc heap log_console lock syscall + +vpath env.cc $(BASE_DIR)/src/base/env +vpath context_area.cc $(BASE_DIR)/src/base/env +vpath %.cc $(REP_DIR)/src/base/env diff --git a/base-linux/lib/mk/ipc.mk b/base-linux/lib/mk/ipc.mk new file mode 100644 index 000000000..f8b81bade --- /dev/null +++ b/base-linux/lib/mk/ipc.mk @@ -0,0 +1,5 @@ +REQUIRES = linux +SRC_CC = ipc.cc +LIBS = syscall rpath + +vpath ipc.cc $(REP_DIR)/src/base/ipc diff --git a/base-linux/lib/mk/lock.mk b/base-linux/lib/mk/lock.mk new file mode 100644 index 000000000..51b073080 --- /dev/null +++ b/base-linux/lib/mk/lock.mk @@ -0,0 +1,5 @@ +SRC_CC = lock.cc +LIBS = syscall +INC_DIR += $(REP_DIR)/src/base/lock + +vpath lock.cc $(BASE_DIR)/src/base/lock diff --git a/base-linux/lib/mk/lx_hybrid.mk b/base-linux/lib/mk/lx_hybrid.mk new file mode 100644 index 000000000..859754041 --- /dev/null +++ b/base-linux/lib/mk/lx_hybrid.mk @@ -0,0 +1,7 @@ +SRC_CC = lx_hybrid.cc new_delete.cc +LIBS += syscall env + +vpath new_delete.cc $(BASE_DIR)/src/base/cxx +vpath lx_hybrid.cc $(REP_DIR)/src/platform + +CUSTOM_CXX = g++ diff --git a/base-linux/lib/mk/process.mk b/base-linux/lib/mk/process.mk new file mode 100644 index 000000000..1e3d7795a --- /dev/null +++ b/base-linux/lib/mk/process.mk @@ -0,0 +1,13 @@ +SRC_CC = process.cc +LIBS = syscall + +# +# The Linux version of the process library does not use Genode's ELF loader for +# loading executables but the 'execve' system call. However, for supporting +# dynamically linked executables, we have to take the decision of whether to load +# the dynamic linker or a static executable based on information provided by +# the ELF program header. We use the ELF library to obtain this information. +# +LIBS += elf + +vpath process.cc $(REP_DIR)/src/base/process diff --git a/base-linux/lib/mk/rpath.mk b/base-linux/lib/mk/rpath.mk new file mode 100644 index 000000000..fc42a899a --- /dev/null +++ b/base-linux/lib/mk/rpath.mk @@ -0,0 +1,6 @@ +REQUIRES = linux +SRC_CC = linux_rpath.cc +LIBS = syscall + +vpath linux_rpath.cc $(REP_DIR)/src/platform + diff --git a/base-linux/lib/mk/thread.mk b/base-linux/lib/mk/thread.mk new file mode 100644 index 000000000..db22b1f6d --- /dev/null +++ b/base-linux/lib/mk/thread.mk @@ -0,0 +1,6 @@ +REQUIRES = linux +SRC_CC = thread.cc thread_linux.cc +LIBS = syscall + +vpath thread.cc $(BASE_DIR)/src/base/thread +vpath thread_linux.cc $(REP_DIR)/src/base/thread diff --git a/base-linux/lib/mk/x86_32/startup.mk b/base-linux/lib/mk/x86_32/startup.mk new file mode 100644 index 000000000..765f02b6d --- /dev/null +++ b/base-linux/lib/mk/x86_32/startup.mk @@ -0,0 +1,8 @@ +REQUIRES = linux x86 +LIBS = cxx lock syscall +SRC_S = crt0.s +SRC_CC = _main.cc +INC_DIR += $(BASE_DIR)/src/platform + +vpath crt0.s $(REP_DIR)/src/platform/x86_32 +vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc)) diff --git a/base-linux/lib/mk/x86_32/syscall.mk b/base-linux/lib/mk/x86_32/syscall.mk new file mode 100644 index 000000000..28371b0da --- /dev/null +++ b/base-linux/lib/mk/x86_32/syscall.mk @@ -0,0 +1,5 @@ +REQUIRES = linux x86 +SRC_S += lx_clone.S lx_syscall.S + +vpath lx_clone.S $(REP_DIR)/../base-linux/src/platform/x86_32 +vpath lx_syscall.S $(REP_DIR)/../base-linux/src/platform/x86_32 diff --git a/base-linux/lib/mk/x86_64/startup.mk b/base-linux/lib/mk/x86_64/startup.mk new file mode 100644 index 000000000..248c5902a --- /dev/null +++ b/base-linux/lib/mk/x86_64/startup.mk @@ -0,0 +1,8 @@ +REQUIRES = linux x86 +LIBS = cxx lock syscall +SRC_S = crt0.s +SRC_CC = _main.cc +INC_DIR += $(BASE_DIR)/src/platform + +vpath crt0.s $(REP_DIR)/src/platform/x86_64 +vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc)) diff --git a/base-linux/lib/mk/x86_64/syscall.mk b/base-linux/lib/mk/x86_64/syscall.mk new file mode 100644 index 000000000..f2d614497 --- /dev/null +++ b/base-linux/lib/mk/x86_64/syscall.mk @@ -0,0 +1,7 @@ +REQUIRES = linux x86 +SRC_S += lx_clone.S lx_restore_rt.S lx_syscall.S + +vpath lx_restore_rt.S $(REP_DIR)/../base-linux/src/platform/x86_64 +vpath lx_clone.S $(REP_DIR)/../base-linux/src/platform/x86_64 +vpath lx_syscall.S $(REP_DIR)/../base-linux/src/platform/x86_64 + diff --git a/base-linux/mk/spec-linux.mk b/base-linux/mk/spec-linux.mk new file mode 100644 index 000000000..a09531af7 --- /dev/null +++ b/base-linux/mk/spec-linux.mk @@ -0,0 +1,18 @@ +# +# Specifics for the Linux-specific Genode components +# + +# +# Startup code to be used when building a program and linker script that is +# specific for Linux. We also reserve the thread-context area via a segment in +# the program under Linux to prevent clashes with vdso. +# +ifneq ($(USE_HOST_LD_SCRIPT),yes) +PRG_LIBS += startup +LD_TEXT_ADDR ?= 0x01000000 +LD_SCRIPT_STATIC = $(call select_from_repositories,src/platform/genode.ld) \ + $(call select_from_repositories,src/platform/context_area.nostdlib.ld) +else +LD_SCRIPT_STATIC = $(LD_SCRIPT_DEFAULT) \ + $(call select_from_repositories,src/platform/context_area.stdlib.ld) +endif diff --git a/base-linux/mk/spec-linux_x86_32.mk b/base-linux/mk/spec-linux_x86_32.mk new file mode 100644 index 000000000..6bcd64715 --- /dev/null +++ b/base-linux/mk/spec-linux_x86_32.mk @@ -0,0 +1,21 @@ +# +# Specifics for Linux on 32-bit x86 +# +SPECS += linux x86_32 + +REP_INC_DIR += src/platform/x86_32 + +# +# We need to manually add the default linker script on the command line in case +# of standard library use. Otherwise, we were not able to extend it by the +# context area section. +# +ifeq ($(USE_HOST_LD_SCRIPT),yes) +LD_SCRIPT_DEFAULT = ldscripts/elf_i386.xc +endif + +# +# Include less-specific configuration +# +include $(call select_from_repositories,mk/spec-x86_32.mk) +include $(call select_from_repositories,mk/spec-linux.mk) diff --git a/base-linux/mk/spec-linux_x86_64.mk b/base-linux/mk/spec-linux_x86_64.mk new file mode 100644 index 000000000..9e14b2fec --- /dev/null +++ b/base-linux/mk/spec-linux_x86_64.mk @@ -0,0 +1,22 @@ +# +# Specifics for Linux on 64-bit x86 +# +SPECS += linux x86_64 + +REP_INC_DIR += src/platform/x86_64 + +# +# We need to manually add the default linker script on the command line in case +# of standard library use. Otherwise, we were not able to extend it by the +# context area section. +# +ifeq ($(USE_HOST_LD_SCRIPT),yes) +LD_SCRIPT_DEFAULT = ldscripts/elf_x86_64.xc +endif + +# +# Include less-specific configuration +# +include $(call select_from_repositories,mk/spec-x86_64.mk) +include $(call select_from_repositories,mk/spec-linux.mk) + diff --git a/base-linux/run/env b/base-linux/run/env new file mode 100644 index 000000000..ab4ca95af --- /dev/null +++ b/base-linux/run/env @@ -0,0 +1,43 @@ +# +# \brief Environment for executing Genode on Linux +# \author Norman Feske +# \date 2010-08-16 +# +# For the documentation of the implemented API functions, +# please refer to the comments in 'tool/run'. +# + +proc create_boot_directory { } { + exec rm -rf [run_dir] + exec mkdir -p [run_dir] +} + + +proc install_config {config} { + set fh [open "[run_dir]/config" "WRONLY CREAT TRUNC"] + puts $fh $config + close $fh +} + + +proc build_boot_image {binaries} { + foreach binary $binaries { + exec ln -sf ../../../bin/$binary [run_dir] } +} + + +proc run_genode_until {{wait_for_re forever} {timeout_value 0}} { + global output + set timeout $timeout_value + set orig_pwd [pwd] + cd [run_dir] + set pid [spawn ./core] + if {$wait_for_re == "forever"} { interact $pid } + expect { + -re $wait_for_re { } + timeout { puts stderr "Error: Test execution timed out"; exit -2 } + } + cd $orig_pwd + set output $expect_out(buffer) +} + diff --git a/base-linux/run/lx_hybrid_ctors.run b/base-linux/run/lx_hybrid_ctors.run new file mode 100644 index 000000000..7b52ad4d4 --- /dev/null +++ b/base-linux/run/lx_hybrid_ctors.run @@ -0,0 +1,77 @@ +# +# \brief Test if global static constructors in hybrid applications and +# host shared libs get called +# \author Christian Prochaska +# \date 2011-11-24 +# + +# +# Build +# + +build { + core init + test/lx_hybrid_ctors +} + +create_boot_directory + +# +# Generate config +# + +install_config { + + + + + + + + + + + + +} + +# +# Boot modules +# + +exec cp test/lx_hybrid_ctors/libtestlib.so bin/ + +# generic modules +set boot_modules { + core init + test-lx_hybrid_ctors + libtestlib.so +} + +build_boot_image $boot_modules + +# +# Execute test case +# + +# qemu config +append qemu_args "-nographic -m 64 " + +run_genode_until "child exited with exit value 0.*\n" 10 + +# +# Compare output +# + +grep_output {\[init -\> test-lx_hybrid_ctors\]} + +compare_output_to { + [init -> test-lx_hybrid_ctors] Global static constructor of host library called. + [init -> test-lx_hybrid_ctors] Global static constructor of Genode application called + [init -> test-lx_hybrid_ctors] --- lx_hybrid global static constructor test --- + [init -> test-lx_hybrid_ctors] --- returning from main --- +} + +exec rm bin/libtestlib.so + +# vi: set ft=tcl : diff --git a/base-linux/run/lx_hybrid_exception.run b/base-linux/run/lx_hybrid_exception.run new file mode 100644 index 000000000..32befb51c --- /dev/null +++ b/base-linux/run/lx_hybrid_exception.run @@ -0,0 +1,60 @@ +# +# \brief Test if the exception mechanism works in hybrid applications +# \author Christian Prochaska +# \date 2011-11-22 +# + +# +# Build +# + +build { + core init + test/lx_hybrid_exception +} + +create_boot_directory + +# +# Generate config +# + +install_config { + + + + + + + + + + + + +} + +# +# Boot modules +# + +# generic modules +set boot_modules { + core init + test-lx_hybrid_exception +} + +build_boot_image $boot_modules + +# +# Execute test case +# + +# qemu config +append qemu_args "-nographic -m 64 " + +run_genode_until "child exited with exit value 0.*\n" 10 + +puts "Test succeeded" + +# vi: set ft=tcl : diff --git a/base-linux/src/base/console/core_console.h b/base-linux/src/base/console/core_console.h new file mode 100644 index 000000000..2fecced9a --- /dev/null +++ b/base-linux/src/base/console/core_console.h @@ -0,0 +1,31 @@ +/* + * \brief Printf backend using Linux stdout + * \author Norman Feske + * \date 2006-04-08 + * + * This console back-end should only be used by core. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Linux syscall bindings */ +#include + +namespace Genode { + + class Core_console : public Console + { + protected: + + void _out_char(char c) { lx_write(1, &c, sizeof(c)); } + }; +} + diff --git a/base-linux/src/base/env/debug.cc b/base-linux/src/base/env/debug.cc new file mode 100644 index 000000000..d62b76976 --- /dev/null +++ b/base-linux/src/base/env/debug.cc @@ -0,0 +1,57 @@ +/* + * \brief Linux-specific debug utilities + * \author Norman Feske + * \date 2009-05-16 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* + * With the enabled 'DEBUG' flag, status information can be printed directly + * via a Linux system call by using the 'raw_write_str' function. This output + * bypasses the Genode 'LOG' mechanism, which is useful for debugging low-level + * code such as a libC back-end. + */ +#define DEBUG 1 + + +#if DEBUG +#include +#endif /* DEBUG */ + + +/** + * Write function targeting directly the Linux system call layer and bypassing + * any Genode code. + */ +extern "C" int raw_write_str(const char *str) +{ +#if DEBUG + unsigned len = 0; + for (; str[len] != 0; len++); + lx_syscall(SYS_write, (int)1, str, len); + return len; +#endif /* DEBUG */ +} + + +/** + * Debug function waiting until the user presses return + * + * This function is there to delay the execution of a back-end function such + * that we have time to attack the GNU debugger to the running process. Once + * attached, we can continue execution and use 'gdb' for debugging. In the + * normal mode of operation, this function is never used. + */ +extern "C" void wait_for_continue(void) +{ +#if DEBUG + char buf[16]; + lx_syscall(SYS_read, (int)0, buf, sizeof(buf)); +#endif /* DEBUG */ +} diff --git a/base-linux/src/base/env/platform_env.cc b/base-linux/src/base/env/platform_env.cc new file mode 100644 index 000000000..454e2cc92 --- /dev/null +++ b/base-linux/src/base/env/platform_env.cc @@ -0,0 +1,97 @@ +/* + * \brief Support for the Linux-specific environment + * \author Norman Feske + * \date 2008-12-12 + */ + +/* + * Copyright (C) 2008-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include + +using namespace Genode; + +/******************************** + ** Platform_env::Local_parent ** + ********************************/ + +Session_capability +Platform_env::Local_parent::session(Service_name const &service_name, + Session_args const &args) +{ + if (strcmp(service_name.string(), + Rm_session::service_name()) == 0) + { + size_t size = + Arg_string::find_arg(args.string(),"size") + .ulong_value(~0); + + if (size == 0) + return Parent_client::session(service_name, args); + + Rm_session_mmap *rm = new (env()->heap()) + Rm_session_mmap(true, size); + + return Local_interface::capability(rm); + } + + return Parent_client::session(service_name, args); +} + + +void Platform_env::Local_parent::close(Session_capability session) +{ + /* + * Handle non-local capabilities + */ + if (session.valid()) { + Parent_client::close(session); + return; + } + + /* + * Detect capability to local RM session + */ + try { + Capability rm = + static_cap_cast(session); + + destroy(env()->heap(), Local_interface::deref(rm)); + + } catch (Local_interface::Non_local_capability) { } +} + + +Platform_env::Local_parent::Local_parent(Parent_capability parent_cap) +: Parent_client(parent_cap) { } + + +/****************** + ** Platform_env ** + ******************/ + +/** + * List of Unix environment variables, initialized by the startup code + */ +extern char **lx_environ; + + +/** + * Read environment variable as long value + */ +unsigned long Platform_env::_get_env_ulong(const char *key) +{ + for (char **curr = lx_environ; curr && *curr; curr++) { + + Arg arg = Arg_string::find_arg(*curr, key); + if (arg.valid()) + return arg.ulong_value(0); + } + + return 0; +} diff --git a/base-linux/src/base/env/rm_session_mmap.cc b/base-linux/src/base/env/rm_session_mmap.cc new file mode 100644 index 000000000..4e1c2439d --- /dev/null +++ b/base-linux/src/base/env/rm_session_mmap.cc @@ -0,0 +1,283 @@ +/* + * \brief Implementation of Linux-specific local region manager + * \author Norman Feske + * \date 2008-10-22 + */ + +/* + * Copyright (C) 2008-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include +#include +#include + +using namespace Genode; + + +static size_t dataspace_size(Dataspace_capability ds) +{ + if (ds.valid()) + return Dataspace_client(ds).size(); + + return Local_interface::deref(ds)->size(); +} + + +static bool is_sub_rm_session(Dataspace_capability ds) +{ + if (ds.valid()) + return false; + + try { + Local_interface::deref(ds); } + catch (Local_interface::Non_local_capability) { + return false; } + + return true; +} + + +static void *map_local(Dataspace_capability ds, size_t size, addr_t offset, + bool use_local_addr, addr_t local_addr) +{ + Linux_dataspace::Filename fname = Linux_dataspace_client(ds).fname(); + fname.buf[sizeof(fname.buf) - 1] = 0; + + bool writable = Dataspace_client(ds).writable(); + int fd = lx_open(fname.buf, (writable ? O_RDWR : O_RDONLY) | LX_O_CLOEXEC); + if (fd < 0) { + PERR("map_local: Could not open file \"%s\"", fname.buf); + throw Rm_session::Invalid_dataspace(); + } + + int flags = MAP_SHARED | (use_local_addr ? MAP_FIXED : 0); + int prot = PROT_READ | PROT_EXEC | (writable ? PROT_WRITE : 0); + void *addr = lx_mmap(use_local_addr ? (void*)local_addr : 0, size, + prot, flags, fd, offset); + + lx_close(fd); + + if (((long)addr < 0) && ((long)addr > -4095)) { + PERR("map_local: return value of mmap is %ld", (long)addr); + throw Rm_session::Region_conflict(); + } + + return addr; +} + + +void Platform_env::Rm_session_mmap::_add_to_rmap(Region const ®ion) +{ + if (_rmap.add_region(region) < 0) { + PERR("_add_to_rmap: could not add region to sub RM session"); + throw Region_conflict(); + } +} + + +Rm_session::Local_addr +Platform_env::Rm_session_mmap::attach(Dataspace_capability ds, + size_t size, off_t offset, + bool use_local_addr, + Rm_session::Local_addr local_addr) +{ + Lock::Guard lock_guard(_lock); + + /* only support attach_at for sub RM sessions */ + if (_sub_rm && !use_local_addr) { + PERR("Rm_session_mmap::attach: attaching w/o local addr not supported\n"); + throw Out_of_metadata(); + } + + if (offset < 0) { + PERR("Rm_session_mmap::attach: negative offset not supported\n"); + throw Region_conflict(); + } + + size_t const remaining_ds_size = dataspace_size(ds) > (addr_t)offset + ? dataspace_size(ds) - (addr_t)offset : 0; + + /* determine size of virtual address region */ + size_t const region_size = size ? min(remaining_ds_size, size) + : remaining_ds_size; + if (region_size == 0) + throw Region_conflict(); + + /* + * We have to distinguish the following cases + * + * 1 we are a root RM session and ds is a plain dataspace + * 2 we are a root RM session and ds is a sub RM session + * 2.1 ds is already attached (base != 0) + * 2.2 ds is not yet attached + * 3 we are a sub RM session and ds is a plain dataspace + * 3.1 we are attached to a root RM session + * 3.2 we are not yet attached + * 4 we are a sub RM session and ds is a sub RM session (not supported) + */ + + if (_sub_rm) { + + /* + * Case 4 + */ + if (is_sub_rm_session(ds)) { + PERR("Rm_session_mmap::attach: nesting sub RM sessions is not supported"); + throw Invalid_dataspace(); + } + + /* + * Check for the dataspace to not exceed the boundaries of the + * sub RM session + */ + if (region_size + (addr_t)local_addr > _size) { + PERR("Rm_session_mmap::attach: dataspace does not fit in sub RM session"); + throw Region_conflict(); + } + + _add_to_rmap(Region(local_addr, offset, ds, region_size)); + + /* + * Case 3.1 + * + * This RM session is a sub RM session. If the sub RM session is + * attached (_base > 0), add its attachement offset to the local base + * and map it. + */ + if (_is_attached()) + map_local(ds, region_size, offset, true, _base + (addr_t)local_addr); + + return (void *)local_addr; + + } else { + + if (is_sub_rm_session(ds)) { + + Dataspace *ds_if = Local_interface::deref(ds); + + Rm_session_mmap *rm = dynamic_cast(ds_if); + + if (!rm) + throw Invalid_dataspace(); + + /* + * Case 2.1 + * + * Detect if sub RM session is already attached + */ + if (rm->_base) { + PERR("Rm_session_mmap::attach: mapping a sub RM session twice is not supported"); + throw Out_of_metadata(); + } + + _add_to_rmap(Region(local_addr, offset, ds, region_size)); + + /* + * Allocate local address range that can hold the entire sub RM + * session. + */ + rm->_base = lx_vm_reserve(use_local_addr ? (addr_t)local_addr : 0, + region_size); + + /* + * Cases 2.2, 3.2 + * + * The sub rm session was not attached until now but it may have + * been populated with dataspaces. Go through all regions an map + * each of them. + */ + for (int i = 0; i < Region_map::MAX_REGIONS; i++) { + Region region = rm->_rmap.region(i); + if (!region.used()) + continue; + + map_local(region.dataspace(), region.size(), region.offset(), + true, rm->_base + region.start() + region.offset()); + } + + return rm->_base; + + } else { + + /* + * Case 1 + * + * Boring, a plain dataspace is attached to a root RM session. + */ + void *addr = map_local(ds, region_size, offset, use_local_addr, local_addr); + + _add_to_rmap(Region((addr_t)addr, offset, ds, region_size)); + + return addr; + } + } +} + + +void Platform_env::Rm_session_mmap::detach(Rm_session::Local_addr local_addr) +{ + Lock::Guard lock_guard(_lock); + + /* + * Cases + * + * 1 we are root RM + * 2 we are sub RM (region must be normal dataspace) + * 2.1 we are not attached + * 2.2 we are attached to a root RM + */ + + Region region = _rmap.lookup(local_addr); + if (!region.used()) + return; + + /* + * Remove meta data from region map + */ + _rmap.remove_region(local_addr); + + if (_sub_rm) { + + /* + * Case 2.1, 2.2 + * + * By removing a region from an attached sub RM session we mark the + * corresponding local address range as reserved. A plain 'munmap' + * would mark this range as free to use for the root RM session, which + * we need to prevent. + * + * If we are not attached, no local address-space manipulation is + * needed. + */ + if (_is_attached()) + lx_vm_reserve((addr_t)local_addr + _base, region.size()); + + } else { + + /* + * Case 1 + * + * We need no distiction between detaching normal dataspaces and + * sub RM session. In both cases, we simply mark the local address + * range as free. + */ + lx_munmap(local_addr, region.size()); + } + + /* + * If the detached dataspace is sub RM session, mark it as detached + */ + if (is_sub_rm_session(region.dataspace())) { + + Dataspace *ds_if = Local_interface::deref(region.dataspace()); + Rm_session_mmap *rm = dynamic_cast(ds_if); + if (rm) + rm->_base = 0; + } + +} diff --git a/base-linux/src/base/ipc/ipc.cc b/base-linux/src/base/ipc/ipc.cc new file mode 100644 index 000000000..eb8c5aa3d --- /dev/null +++ b/base-linux/src/base/ipc/ipc.cc @@ -0,0 +1,358 @@ +/* + * \brief Socket-based IPC implementation for Linux + * \author Norman Feske + * \author Christian Helmuth + * \date 2011-10-11 + * + * We create two sockets under lx_rpath() for each thread: client and server + * role. The naming is 'ep--'. The socket descriptors are + * cached in Thread_base::_tid. + * + * Currently two socket files are needed, as the client does not send the reply + * socket access-rights in a combined message with the payload. In the future, + * only server sockets must be bound in lx_rpath(). + * + * The current request message layout is: + * + * long server_local_name; + * long client_thread_id; + * int opcode; + * ...payload... + * + * Response messages look like this: + * + * long scratch_word; + * int exc_code; + * ...payload... + * + * All fields are naturally aligned, i.e., aligend on 4 or 8 byte boundaries on + * 32-bit resp. 64-bit systems. + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include + +/* Linux includes */ +#include +#include +#include + +#include +#include + + +extern "C" void wait_for_continue(void); +extern "C" int raw_write_str(const char *str); + +#define PRAW(fmt, ...) \ + do { \ + char str[128]; \ + snprintf(str, sizeof(str), \ + ESC_ERR fmt ESC_END "\n", ##__VA_ARGS__); \ + raw_write_str(str); \ + } while (0) + + +using namespace Genode; + + +/** + * Utility: Create socket address for thread ID and role (client/server) + */ +static void lx_create_sockaddr(sockaddr_un *addr, long thread_id, char const *role) +{ + addr->sun_family = AF_UNIX; + Genode::snprintf(addr->sun_path, sizeof(addr->sun_path), "%s/ep-%ld-%s", + lx_rpath(), thread_id, role); +} + + +/** + * Utility: Create a socket descriptor and file for given thread and role + */ +static int create_socket(long thread_id, char const *role) +{ + int sd = lx_socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0); + if (sd < 0) return -1; + + sockaddr_un addr; + lx_create_sockaddr(&addr, thread_id, role); + + /* make sure bind succeeds */ + lx_unlink(addr.sun_path); + + if (lx_bind(sd, (sockaddr *)&addr, sizeof(addr)) < 0) + return -2; + + return sd; +} + + +/** + * Utility: Unlink socket file and close descriptor + * + * XXX Currently, socket destruction is missing. The client socket could be + * used from multiple Ipc_client objects. A safe destruction would need + * reference counting. + */ +//static void destroy_socket(int sd, long thread_id, char const *role) +//{ +// sockaddr_un addr; +// lx_create_sockaddr(&addr, thread_id, role); +// +// lx_unlink(addr.sun_path); +// lx_close(sd); +//} + + +/** + * Get client-socket descriptor for main thread + */ +static int main_client_socket() +{ + static int sd = create_socket(lx_gettid(), "client"); + + return sd; +} + + +/** + * Utility: Get server socket for given thread + */ +static int server_socket(Thread_base *thread) +{ + /* + * Main thread uses Ipc_server for sleep_forever() only. + */ + if (!thread) + return lx_socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0); + + if (thread->tid().server == -1) + thread->tid().server = create_socket(thread->tid().tid, "server"); + return thread->tid().server; +} + + +/** + * Utility: Get client socket for given thread + */ +static int client_socket(Thread_base *thread) +{ + if (!thread) return main_client_socket(); + + if (thread->tid().client == -1) + thread->tid().client = create_socket(thread->tid().tid, "client"); + return thread->tid().client; +} + + +/** + * Utility: Send message to thread via given socket descriptor + */ +static void send_to(int sd, long thread_id, char const *target_role, + void *msg, Genode::size_t msg_len) +{ + sockaddr_un addr; + lx_create_sockaddr(&addr, thread_id, target_role); + + int res = lx_sendto(sd, msg, msg_len, 0, (sockaddr *)&addr, sizeof(addr)); + if (res < 0) { + PRAW("Send error: %d with %s in %d", res, addr.sun_path, lx_gettid()); + wait_for_continue(); + throw Ipc_error(); + } +} + + +/** + * Utility: Receive message via given socket descriptor + */ +static void recv_from(int sd, void *buf, Genode::size_t buf_len) +{ + socklen_t fromlen; + int res = lx_recvfrom(sd, buf, buf_len, 0, 0, &fromlen); + if (res < 0) { + if ((-res) == EINTR) + throw Blocking_canceled(); + else { + PRAW("Recv error: %d in %d", res, lx_gettid()); + wait_for_continue(); + throw Ipc_error(); + } + } +} + + +/***************** + ** Ipc_ostream ** + *****************/ + +/* + * XXX This class will be removed soon. + */ + +void Ipc_ostream::_prepare_next_send() +{ + PRAW("unexpected call to %s (%p)", __PRETTY_FUNCTION__, this); +} + + +void Ipc_ostream::_send() +{ + PRAW("unexpected call to %s (%p)", __PRETTY_FUNCTION__, this); +} + + +Ipc_ostream::Ipc_ostream(Native_capability dst, Msgbuf_base *snd_msg): + Ipc_marshaller(snd_msg->buf, snd_msg->size()), _snd_msg(snd_msg), _dst(dst) +{ } + + +/***************** + ** Ipc_istream ** + *****************/ + +/* + * XXX This class will be removed soon. + */ + +void Ipc_istream::_prepare_next_receive() +{ + PRAW("unexpected call to %s (%p)", __PRETTY_FUNCTION__, this); +} + + +void Ipc_istream::_wait() +{ + PRAW("unexpected call to %s (%p)", __PRETTY_FUNCTION__, this); +} + + +Ipc_istream::Ipc_istream(Msgbuf_base *rcv_msg) +: Ipc_unmarshaller(rcv_msg->buf, rcv_msg->size()), + Native_capability(lx_gettid(), 0), + _rcv_msg(rcv_msg), _rcv_cs(-1) +{ } + + +Ipc_istream::~Ipc_istream() { } + + +/**************** + ** Ipc_client ** + ****************/ + +void Ipc_client::_prepare_next_call() +{ + /* prepare next request in buffer */ + long local_name = _dst.local_name(); + long tid = Native_capability::tid(); + + _write_offset = 0; + _write_to_buf(local_name); + _write_to_buf(tid); + + /* prepare response buffer */ + _read_offset = sizeof(long); +} + + +void Ipc_client::_call() +{ + if (_dst.valid()) { + send_to(_rcv_cs, _dst.tid(), "server", + _snd_msg->buf, _write_offset); + + recv_from(_rcv_cs, _rcv_msg->buf, _rcv_msg->size()); + } + _prepare_next_call(); +} + + +Ipc_client::Ipc_client(Native_capability const &srv, + Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg) +: Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0) +{ + _rcv_cs = client_socket(Thread_base::myself()); + + _prepare_next_call(); +} + + +/**************** + ** Ipc_server ** + ****************/ + +void Ipc_server::_prepare_next_reply_wait() +{ + /* skip server-local name */ + _read_offset = sizeof(long); + + /* read client thread id from request buffer */ + long tid; + if (_reply_needed) { + _read_from_buf(tid); + _dst = Native_capability(tid, 0); /* only _tid member is used */ + } + + /* prepare next reply */ + _write_offset = 0; + long local_name = _dst.local_name(); + _write_to_buf(local_name); /* XXX unused, needed by de/marshaller */ + + /* leave space for exc code at the beginning of the msgbuf */ + _write_offset += align_natural(sizeof(int)); +} + + +void Ipc_server::_wait() +{ + /* wait for new server request */ + try { + recv_from(_rcv_cs, _rcv_msg->buf, _rcv_msg->size()); + } catch (Blocking_canceled) { } + + /* now we have a request to reply, determine reply destination */ + _reply_needed = true; + _prepare_next_reply_wait(); +} + + +void Ipc_server::_reply() +{ + try { + send_to(_rcv_cs, _dst.tid(), "client", _snd_msg->buf, _write_offset); + } catch (Ipc_error) { } + + _prepare_next_reply_wait(); +} + + +void Ipc_server::_reply_wait() +{ + /* when first called, there was no request yet */ + if (_reply_needed) + send_to(_rcv_cs, _dst.tid(), "client", _snd_msg->buf, _write_offset); + + _wait(); +} + + +Ipc_server::Ipc_server(Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg) +: Ipc_istream(rcv_msg), + Ipc_ostream(Native_capability(), snd_msg), _reply_needed(false) +{ + _rcv_cs = server_socket(Thread_base::myself()); + + _prepare_next_reply_wait(); +} diff --git a/base-linux/src/base/lock/lock_helper.h b/base-linux/src/base/lock/lock_helper.h new file mode 100644 index 000000000..b6cca57f9 --- /dev/null +++ b/base-linux/src/base/lock/lock_helper.h @@ -0,0 +1,80 @@ +/* + * \brief Linux-specific helper functions for the Lock implementation + * \author Norman Feske + * \date 2009-07-20 + * + * This file serves as adapter between the generic lock implementation + * in 'lock.cc' and the underlying kernel. + * + * For documentation about the interface, please revisit the 'base-pistachio' + * implementation. + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* Linux includes */ +#include + + +/** + * Resolve 'Thread_base::myself' when not linking the thread library + * + * This weak symbol is primarily used by test cases. Most other Genode programs + * use the thread library. If the thread library is not used, 'myself' can only + * be called by the main thread, for which 'myself' is defined as zero. + */ +Genode::Thread_base * __attribute__((weak)) Genode::Thread_base::myself() { return 0; } + + +static inline void thread_yield() +{ + struct timespec ts = { 0, 1000 }; + lx_nanosleep(&ts, 0); +} + + +static bool thread_check_stopped_and_restart(Genode::Native_thread_id tid) +{ + lx_tgkill(tid.pid, tid.tid, LX_SIGUSR1); + return true; +} + + +static inline Genode::Native_thread_id thread_get_my_native_id() +{ + return Genode::Native_thread_id(lx_gettid(), lx_getpid()); +} + + +static inline Genode::Native_thread_id thread_invalid_id() +{ + return Genode::Native_thread_id(); +} + + +static inline bool thread_id_valid(Genode::Native_thread_id tid) +{ + return (tid.pid != 0); +} + + +static inline void thread_switch_to(Genode::Native_thread_id tid) +{ + thread_yield(); +} + + +static inline void thread_stop_myself() +{ + struct timespec ts = { 1000, 0 }; + while (lx_nanosleep(&ts, 0) == 0); +} diff --git a/base-linux/src/base/process/process.cc b/base-linux/src/base/process/process.cc new file mode 100644 index 000000000..768c48f8c --- /dev/null +++ b/base-linux/src/base/process/process.cc @@ -0,0 +1,203 @@ +/* + * \brief Implementation of process creation for Linux + * \author Norman Feske + * \date 2006-07-06 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include +#include +#include + +/* Framework-internal includes */ +#include + + +using namespace Genode; + +Dataspace_capability Process::_dynamic_linker_cap; + +/** + * Argument frame for passing 'execve' paremeters through 'clone' + */ +struct execve_args { + const char *filename; + char *const*argv; + char *const*envp; +}; + + +/** + * Startup code of the new child process + */ +static int _exec_child(struct execve_args *arg) +{ + return lx_execve(arg->filename, arg->argv, arg->envp); +} + + +/** + * List of Unix environment variables, initialized by the startup code + */ +extern char **lx_environ; + + +/** + * Read environment variable as string + * + * If no matching key exists, return an empty string. + */ +static const char *get_env(const char *key) +{ + Genode::size_t key_len = strlen(key); + for (char **curr = lx_environ; curr && *curr; curr++) + if ((Genode::strcmp(*curr, key, key_len) == 0) && (*curr)[key_len] == '=') + return (const char *)(*curr + key_len + 1); + + return ""; +} + +/** + * Check for dynamic ELF header + */ +static bool _check_dynamic_elf(Dataspace_capability elf_ds_cap) +{ + /* attach ELF locally */ + addr_t elf_addr; + + try { elf_addr = env()->rm_session()->attach(elf_ds_cap); } + catch (...) { return false; } + + /* + * If attach is called within core, it will return zero because + * Linux uses Core_rm_session. + */ + if (!elf_addr) return false; + + /* read program header and interpreter */ + Elf_binary elf((addr_t)elf_addr); + env()->rm_session()->detach((void *)elf_addr); + + return elf.is_dynamically_linked(); +} + + +const char *Process::_priv_pd_args(Parent_capability parent_cap, + Dataspace_capability elf_data_ds_cap, + const char *name, char *const argv[]) +{ + /* + * Serialize calls of this function because it uses the static 'envbuf' and + * 'stack' variables. + */ + static Lock _priv_pd_args_lock; + Lock::Guard _lock_guard(_priv_pd_args_lock); + + /* check for dynamic program header */ + if (_check_dynamic_elf(elf_data_ds_cap)) { + if (!_dynamic_linker_cap.valid()) { + PERR("Dynamically linked file found, but no dynamic linker binary present"); + return 0; + } + elf_data_ds_cap = _dynamic_linker_cap; + } + + /* pass parent capability as environment variable to the child */ + enum { ENV_STR_LEN = 256 }; + static char envbuf[5][ENV_STR_LEN]; + Genode::snprintf(envbuf[0], ENV_STR_LEN, "parent_tid=%ld", + parent_cap.tid()); + Genode::snprintf(envbuf[1], ENV_STR_LEN, "parent_local_name=%lu", + parent_cap.local_name()); + Genode::snprintf(envbuf[2], ENV_STR_LEN, "DISPLAY=%s", + get_env("DISPLAY")); + Genode::snprintf(envbuf[3], ENV_STR_LEN, "HOME=%s", + get_env("HOME")); + Genode::snprintf(envbuf[4], ENV_STR_LEN, "LD_LIBRARY_PATH=%s", + get_env("LD_LIBRARY_PATH")); + + char *env[] = { &envbuf[0][0], &envbuf[1][0], &envbuf[2][0], + &envbuf[3][0], &envbuf[4][0], 0 }; + + /* determine name of binary to start */ + Linux_dataspace_client elf_data_ds(elf_data_ds_cap); + Linux_dataspace::Filename fname = elf_data_ds.fname(); + fname.buf[sizeof(fname.buf) - 1] = 0; + + /* prefix name of Linux program (helps killing some zombies) */ + char pname_buf[9 + Linux_dataspace::FNAME_LEN]; + snprintf(pname_buf, sizeof(pname_buf), "[Genode] %s", name); + + /* it may happen, that argv is null */ + char *argv_buf[2]; + if (!argv) { + argv_buf[0] = pname_buf; + argv_buf[1] = 0; + argv = argv_buf; + } else + ((char **)argv)[0] = pname_buf; + + /* + * We cannot create the new process via 'fork()' because all our used + * memory including stack memory is backed by dataspaces, which had been + * mapped with the 'MAP_SHARED' flag. Therefore, after being created, the + * new process starts using the stack with the same physical memory pages + * as used by parent process. This would ultimately lead to stack + * corruption. To prevent both processes from concurrently accessing the + * same stack, we pause the execution of the parent until the child calls + * 'execve'. From then on, the child has its private memory layout. The + * desired behaviour is normally provided by 'vfork' but we use the more + * modern 'clone' call for this purpose. + */ + enum { STACK_SIZE = 4096 }; + static char stack[STACK_SIZE]; /* initial stack used by the child until + calling 'execve' */ + + /* + * Argument frame as passed to 'clone'. Because, we can only pass a single + * pointer, all arguments are embedded within the 'execve_args' struct. + */ + struct execve_args arg = { + fname.buf, + argv, + env + }; + + pid_t pid = lx_create_process((int (*)(void *))_exec_child, + stack + STACK_SIZE - sizeof(umword_t), &arg); + + /* + * We create a pseudo pd session with the new pd's pid as argument + * to enable Core to kill the process when the pd session gets closed. + */ + snprintf(_priv_pd_argbuf, sizeof(_priv_pd_argbuf), "PID=%d", pid); + + return _priv_pd_argbuf; +} + + +Process::Process(Dataspace_capability elf_data_ds_cap, + Ram_session_capability ram_session_cap, + Cpu_session_capability cpu_session_cap, + Rm_session_capability rm_session_cap, + Parent_capability parent_cap, + const char *name, + char *const argv[]) +: + _pd(_priv_pd_args(parent_cap, elf_data_ds_cap, name, argv)), + _cpu_session_client(Cpu_session_capability()), + _rm_session_client(Rm_session_capability()) +{ } + + +Process::~Process() { } diff --git a/base-linux/src/base/thread/thread_linux.cc b/base-linux/src/base/thread/thread_linux.cc new file mode 100644 index 000000000..e6dec1152 --- /dev/null +++ b/base-linux/src/base/thread/thread_linux.cc @@ -0,0 +1,115 @@ +/* + * \brief Implementation of the Thread API via Linux threads + * \author Norman Feske + * \date 2006-06-13 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include + +/* Linux syscall bindings */ +#include + +using namespace Genode; + + +static void empty_signal_handler(int) { } + + +/** + * Signal handler for killing the thread + */ +static void thread_exit_signal_handler(int) { lx_exit(0); } + + +static void thread_start(void *) +{ + /* + * Set signal handler such that canceled system calls get not + * transparently retried after a signal gets received. + */ + lx_sigaction(LX_SIGUSR1, empty_signal_handler); + + Thread_base::myself()->entry(); + sleep_forever(); +} + + +void Thread_base::_init_platform_thread() { } + + +void Thread_base::_deinit_platform_thread() +{ + /* + * Kill thread until it is really really dead + * + * We use the 'tgkill' system call to kill the thread. This system call + * returns immediately and just flags the corresponding signal at the + * targeted thread context. However, the thread still lives until the + * signal flags are evaluated. When leaving this function, however, we want + * to be sure that the thread is no more executing any code such that we + * an safely free and unmap the thread's stack. So we call 'tgkill' in a + * loop until we get an error indicating that the thread does not exists + * anymore. + */ + for (;;) { + + /* destroy thread locally */ + int ret = lx_tgkill(_tid.pid, _tid.tid, LX_SIGCANCEL); + + if (ret < 0) break; + + /* if thread still exists, wait a bit and try to kill it again */ + struct timespec ts = { 0, 500 }; + lx_nanosleep(&ts, 0); + } + + /* inform core about the killed thread */ + env()->cpu_session()->kill_thread(_thread_cap); +} + + +void Thread_base::start() +{ + /* + * The first time we enter this code path, the 'start' function is + * called by the main thread as there cannot exist other threads + * without executing this function. When first called, we initialize + * the thread lib here. + */ + static bool threadlib_initialized = false; + if (!threadlib_initialized) { + lx_sigaction(LX_SIGCANCEL, thread_exit_signal_handler); + threadlib_initialized = true; + } + + /* align initial stack to 16 byte boundary */ + void *thread_sp = (void *)((addr_t)(_context->stack) & ~0xf); + _tid.tid = lx_create_thread(thread_start, thread_sp, this); + _tid.pid = lx_getpid(); + + /* + * Inform core about the new thread by calling create_thread and encoding + * the thread's PID in the thread-name argument. + */ + char name_and_pid[Cpu_session::THREAD_NAME_LEN + 2*16]; + snprintf(name_and_pid, sizeof(name_and_pid), "%s:0x%x:0x%x", + _context->name, _tid.tid, _tid.pid); + _thread_cap = env()->cpu_session()->create_thread(name_and_pid); +} + + +void Thread_base::cancel_blocking() +{ + env()->cpu_session()->cancel_blocking(_thread_cap); +} diff --git a/base-linux/src/core/context_area.cc b/base-linux/src/core/context_area.cc new file mode 100644 index 000000000..3c7a83d35 --- /dev/null +++ b/base-linux/src/core/context_area.cc @@ -0,0 +1,112 @@ +/* + * \brief Linux-specific support code for the thread API + * \author Norman Feske + * \date 2010-01-13 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include + +/* Linux includes */ +#include +#include + + +/** + * Region-manager session for allocating thread contexts + * + * This class corresponds to the managed dataspace that is normally + * used for organizing thread contexts with the thread context area. + * It "emulates" the sub address space by adjusting the local address + * argument to 'attach' with the offset of the thread context area. + */ +class Context_area_rm_session : public Genode::Rm_session +{ + public: + + /** + * Attach backing store to thread-context area + */ + Local_addr attach(Genode::Dataspace_capability ds_cap, + Genode::size_t size, Genode::off_t offset, + bool use_local_addr, Local_addr local_addr) + { + using namespace Genode; + + /* convert context-area-relative to absolute virtual address */ + addr_t addr = local_addr; + addr += Thread_base::CONTEXT_AREA_VIRTUAL_BASE; + + /* use anonymous mmap for allocating stack backing store */ + int flags = MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE; + int prot = PROT_READ | PROT_WRITE; + void *res = lx_mmap((void*)addr, size, prot, flags, -1, 0); + + if ((addr_t)res != addr) + throw Region_conflict(); + + return local_addr; + } + + void detach(Local_addr local_addr) { + PWRN("context area detach from 0x%p - not implemented", (void *)local_addr); } + + Genode::Pager_capability add_client(Genode::Thread_capability) { + return Genode::Pager_capability(); } + + void fault_handler(Genode::Signal_context_capability) { } + + State state() { return State(); } + + Genode::Dataspace_capability dataspace() { + return Genode::Dataspace_capability(); } +}; + + +class Context_area_ram_session : public Genode::Ram_session +{ + public: + + Genode::Ram_dataspace_capability alloc(Genode::size_t size) { + return Genode::Ram_dataspace_capability(); } + + void free(Genode::Ram_dataspace_capability) { } + + int ref_account(Genode::Ram_session_capability) { return 0; } + + int transfer_quota(Genode::Ram_session_capability, Genode::size_t) { return 0; } + + size_t quota() { return 0; } + + size_t used() { return 0; } +}; + + +/** + * Return single instance of the context-area RM and RAM session + */ +namespace Genode { + + Rm_session *env_context_area_rm_session() + { + static Context_area_rm_session inst; + return &inst; + } + + Ram_session *env_context_area_ram_session() + { + static Context_area_ram_session inst; + return &inst; + } +} + diff --git a/base-linux/src/core/include/cap_session_component.h b/base-linux/src/core/include/cap_session_component.h new file mode 100644 index 000000000..f63d1d145 --- /dev/null +++ b/base-linux/src/core/include/cap_session_component.h @@ -0,0 +1,47 @@ +/* + * \brief Capability allocation service + * \author Norman Feske + * \date 2006-06-26 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__CAP_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__LINUX__CAP_SESSION_COMPONENT_H_ + +#include +#include +#include + +namespace Genode { + + class Cap_session_component : public Rpc_object + { + private: + + static long _unique_id_cnt; + static Lock &_lock() + { + static Lock static_lock; + return static_lock; + } + + public: + + Native_capability alloc(Native_capability ep) + { + Lock::Guard lock_guard(_lock()); + + return Native_capability(ep.tid(), ++_unique_id_cnt); + } + + void free(Native_capability cap) { } + }; +} + +#endif /* _CORE__INCLUDE__LINUX__CAP_SESSION_COMPONENT_H_ */ diff --git a/base-linux/src/core/include/dataspace_component.h b/base-linux/src/core/include/dataspace_component.h new file mode 100644 index 000000000..fa1b05ce3 --- /dev/null +++ b/base-linux/src/core/include/dataspace_component.h @@ -0,0 +1,91 @@ +/* + * \brief Core-internal dataspace representation on Linux + * \author Norman Feske + * \date 2006-05-19 + * + * On Linux userland, we do not deal with physical memory. Instead, + * we create a file for each dataspace that is to be mmapped. + * Therefore, the allocator is not really used for allocating + * memory but only as a container for quota. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__DATASPACE_COMPONENT_H_ +#define _CORE__INCLUDE__LINUX__DATASPACE_COMPONENT_H_ + +#include +#include +#include +#include +#include + +namespace Genode { + + class Dataspace_component : public Rpc_object + { + private: + + size_t _size; /* size of dataspace in bytes */ + addr_t _addr; /* meaningless on linux */ + Filename _fname; /* filename for mmap */ + bool _writable; /* false if read-only */ + + public: + + /** + * Constructor + */ + Dataspace_component(size_t size, addr_t addr, bool writable) + : _size(size), _addr(addr), _writable(writable) { } + + /** + * Default constructor returns invalid dataspace + */ + Dataspace_component() : _size(0), _addr(0), _writable(false) { } + + /** + * This constructor is only provided for compatibility + * reasons and should not be used. + */ + Dataspace_component(size_t size, addr_t core_local_addr, + addr_t phys_addr, bool write_combined, + bool writable) + : _size(size), _addr(phys_addr) + { + PWRN("Should only be used for IOMEM and not within Linux."); + } + + /** + * Define/request corresponding filename of dataspace + * + * To use dataspaces as shared memory objects on Linux, we have to + * assign a file to each dataspace. This way, multiple Linux process + * can mmap this file. + */ + void fname(const char *fname) { strncpy(_fname.buf, fname, sizeof(_fname.buf)); } + + + /************************* + ** Dataspace interface ** + *************************/ + + size_t size() { return _size; } + addr_t phys_addr() { return _addr; } + bool writable() { return _writable; } + + + /**************************************** + ** Linux-specific dataspace interface ** + ****************************************/ + + Filename fname() { return _fname; } + }; +} + +#endif /* _CORE__INCLUDE__LINUX__DATASPACE_COMPONENT_H_ */ diff --git a/base-linux/src/core/include/io_mem_session_component.h b/base-linux/src/core/include/io_mem_session_component.h new file mode 100644 index 000000000..61344c6d6 --- /dev/null +++ b/base-linux/src/core/include/io_mem_session_component.h @@ -0,0 +1,64 @@ +/* + * \brief Core-specific instance of the IO_MEM session interface (Linux) + * \author Christian Helmuth + * \date 2007-09-14 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__IO_MEM_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__LINUX__IO_MEM_SESSION_COMPONENT_H_ + +/* Genode includes */ +#include +#include +#include +#include + +/* core includes */ +#include + +namespace Genode { + + class Io_mem_session_component : public Rpc_object + { + public: + + /** + * Constructor + * + * \param io_mem_alloc MMIO region allocator + * \param ram_alloc RAM allocator that will be checked for + * region collisions + * \param ds_ep entry point to manage the dataspace + * corresponding the io_mem session + * \param args session construction arguments, in + * particular MMIO region base, size and + * caching demands + */ + Io_mem_session_component(Range_allocator *io_mem_alloc, + Range_allocator *ram_alloc, + Rpc_entrypoint *ds_ep, + const char *args); + + /** + * Destructor + */ + ~Io_mem_session_component() { } + + + /***************************** + ** Io-mem session interface ** + *****************************/ + + Io_mem_dataspace_capability dataspace() { + return Io_mem_dataspace_capability(); } + }; +} + +#endif /* _CORE__INCLUDE__LINUX__IO_MEM_SESSION_COMPONENT_H_ */ diff --git a/base-linux/src/core/include/irq_session_component.h b/base-linux/src/core/include/irq_session_component.h new file mode 100644 index 000000000..907b88d98 --- /dev/null +++ b/base-linux/src/core/include/irq_session_component.h @@ -0,0 +1,60 @@ +/* + * \brief Core-specific instance of the IRQ session interface for Linux + * \author Christian Helmuth + * \date 2007-09-13 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__IRQ_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__LINUX__IRQ_SESSION_COMPONENT_H_ + +#include +#include +#include +#include + +namespace Genode { + + class Irq_session_component : public List::Element + { + public: + + /** + * Constructor + * + * \param cap_session capability session to use + * \param irq_alloc platform-dependent IRQ allocator + * \param args session construction arguments + */ + Irq_session_component(Cap_session *cap_session, + Range_allocator *irq_alloc, + const char *args) { } + + /** + * Destructor + */ + ~Irq_session_component() { } + + /** + * Return capability to this session + * + * Capability is always invalid under Linux. + */ + Session_capability cap() const { return Session_capability(); } + + + /*************************** + ** Irq session interface ** + ***************************/ + + void wait_for_irq() { } + }; +} + +#endif /* _CORE__INCLUDE__LINUX__IRQ_SESSION_COMPONENT_H_ */ diff --git a/base-linux/src/core/include/pd_session_component.h b/base-linux/src/core/include/pd_session_component.h new file mode 100644 index 000000000..bc4866b5e --- /dev/null +++ b/base-linux/src/core/include/pd_session_component.h @@ -0,0 +1,61 @@ +/* + * \brief CORE-specific instance of the PD session interface for Linux + * \author Norman Feske + * \date 2006-08-14 + * + * On Linux, we use a pd session only for keeping the information about the + * existence of protection domains to enable us to destruct all pds of a whole + * subtree. A pd is killed by CORE when closing the corresponding pd session. + * The PID of the process is passed to CORE as an argument of the session + * construction. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__PD_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__LINUX__PD_SESSION_COMPONENT_H_ + +/* Genode includes */ +#include +#include +#include +#include + +/* local includes */ +#include "platform.h" + +namespace Genode { + + class Pd_session_component : public Rpc_object + { + private: + + unsigned long _pid; + + public: + + Pd_session_component(Rpc_entrypoint *thread_ep, + const char *args); + + ~Pd_session_component(); + + + /****************************/ + /** Pd session interface **/ + /****************************/ + + /* + * This interface is not functional on Linux. + */ + + int bind_thread(Thread_capability thread); + int assign_parent(Parent_capability); + }; +} + +#endif /* _CORE__INCLUDE__LINUX__PD_SESSION_COMPONENT_H_ */ diff --git a/base-linux/src/core/include/platform.h b/base-linux/src/core/include/platform.h new file mode 100644 index 000000000..1d3379b1d --- /dev/null +++ b/base-linux/src/core/include/platform.h @@ -0,0 +1,62 @@ +/* + * \brief Linux platform + * \author Christian Helmuth + * \author Norman Feske + * \date 2007-09-10 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__PLATFORM_H_ +#define _CORE__INCLUDE__LINUX__PLATFORM_H_ + +#include +#include +#include + +#include +#include +#include + +namespace Genode { + + using namespace Genode; + + class Platform : public Platform_generic + { + private: + + Synchronized_range_allocator _ram_alloc; /* RAM allocator */ + + public: + + /** + * Constructor + */ + Platform(); + + + /******************************** + ** Generic platform interface ** + ********************************/ + + Range_allocator *core_mem_alloc() { return &_ram_alloc; } + Range_allocator *ram_alloc() { return &_ram_alloc; } + Range_allocator *io_mem_alloc() { return 0; } + Range_allocator *io_port_alloc() { return 0; } + Range_allocator *irq_alloc() { return 0; } + Range_allocator *region_alloc() { return 0; } + addr_t vm_start() const { return 0; } + size_t vm_size() const { return 0; } + Rom_fs *rom_fs() { return 0; } + + void wait_for_exit(); + }; +} + +#endif /* _CORE__INCLUDE__PLATFORM_H_ */ diff --git a/base-linux/src/core/include/platform_pd.h b/base-linux/src/core/include/platform_pd.h new file mode 100644 index 000000000..cd9fa461a --- /dev/null +++ b/base-linux/src/core/include/platform_pd.h @@ -0,0 +1,25 @@ +/* + * \brief Linux protection domain facility + * \author Norman Feske + * \date 2006-06-13 + * + * Pretty dumb. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__PLATFORM_PD_H_ +#define _CORE__INCLUDE__LINUX__PLATFORM_PD_H_ + +namespace Genode { + + class Platform_pd + { }; +} + +#endif /* _CORE__INCLUDE__LINUX__PLATFORM_PD_H_ */ diff --git a/base-linux/src/core/include/platform_thread.h b/base-linux/src/core/include/platform_thread.h new file mode 100644 index 000000000..9fadda64d --- /dev/null +++ b/base-linux/src/core/include/platform_thread.h @@ -0,0 +1,65 @@ +/* + * \brief Linux thread facility + * \author Norman Feske + * \date 2006-06-13 + * + * Pretty dumb. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__PLATFORM_THREAD_H_ +#define _CORE__INCLUDE__LINUX__PLATFORM_THREAD_H_ + +#include +#include + +namespace Genode { + + class Platform_thread + { + private: + + unsigned long _tid; + unsigned long _pid; + char _name[32]; + + public: + + /** + * Constructor + */ + Platform_thread(const char *name, unsigned priority); + + /** + * Cancel currently blocking operation + */ + void cancel_blocking(); + + /** + * Pause this thread + */ + void pause(); + + /** + * Resume this thread + */ + void resume(); + + /** + * Dummy implementation of platform-thread interface + */ + Pager_object *pager() { return 0; } + void pager(Pager_object *) { } + int start(void *ip, void *sp) { return 0; } + int state(Thread_state *state_dst) { return 0; } + const char *name() { return _name; } + }; +} + +#endif /* _CORE__INCLUDE__LINUX__PLATFORM_THREAD_H_ */ diff --git a/base-linux/src/core/include/rm_session_component.h b/base-linux/src/core/include/rm_session_component.h new file mode 100644 index 000000000..aa2aa535c --- /dev/null +++ b/base-linux/src/core/include/rm_session_component.h @@ -0,0 +1,64 @@ +/* + * \brief Core-specific instance of the RM session interface + * \author Christian Helmuth + * \date 2006-07-17 + * + * Dummies for Linux platform + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _CORE__INCLUDE__LINUX__RM_SESSION_COMPONENT_H_ +#define _CORE__INCLUDE__LINUX__RM_SESSION_COMPONENT_H_ + +/* Genode */ +#include +#include +#include +#include + +namespace Genode { + + struct Rm_client; + + class Rm_session_component : public Rpc_object + { + public: + + Rm_session_component(Rpc_entrypoint *ds_ep, + Rpc_entrypoint *thread_ep, + Allocator *md_alloc, + size_t ram_quota, + Pager_entrypoint *pager_ep, + addr_t vm_start, + size_t vm_size) { } + + void upgrade_ram_quota(size_t ram_quota) { } + + Local_addr attach(Dataspace_capability, size_t, off_t, bool, Local_addr) { + return (addr_t)0; } + + void detach(Local_addr) { } + + Pager_capability add_client(Thread_capability) { + return Pager_capability(); } + + void fault_handler(Signal_context_capability) { } + + State state() { return State(); } + + Dataspace_capability dataspace() { return Dataspace_capability(); } + + void dissolve(Rm_client *cl) { } + }; + + struct Rm_member { Rm_session_component *member_rm_session() { return 0; } }; + struct Rm_client : Pager_object, Rm_member { }; +} + +#endif /* _CORE__INCLUDE__LINUX__RM_SESSION_COMPONENT_H_ */ diff --git a/base-linux/src/core/io_mem_session_component.cc b/base-linux/src/core/io_mem_session_component.cc new file mode 100644 index 000000000..cead86767 --- /dev/null +++ b/base-linux/src/core/io_mem_session_component.cc @@ -0,0 +1,27 @@ +/* + * \brief Linux-specific IO_MEM service + * \author Christian Helmuth + * \date 2006-09-01 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +#include + +using namespace Genode; + + +Io_mem_session_component::Io_mem_session_component(Range_allocator *io_mem_alloc, + Range_allocator *ram_alloc, + Rpc_entrypoint *ds_ep, + const char *args) +{ + PWRN("no io_mem support on Linux (args=\"%s\")", args); +} diff --git a/base-linux/src/core/io_port_session_component.cc b/base-linux/src/core/io_port_session_component.cc new file mode 100644 index 000000000..d5ef72473 --- /dev/null +++ b/base-linux/src/core/io_port_session_component.cc @@ -0,0 +1,59 @@ +/* + * \brief Linux-specific IO_PORT service + * \author Christian Helmuth + * \date 2007-04-18 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include + +#include "io_port_session_component.h" + +using namespace Genode; + + +unsigned char Io_port_session_component::inb(unsigned short address) { + return 0; } + + +unsigned short Io_port_session_component::inw(unsigned short address) { + return 0; } + + +unsigned Io_port_session_component::inl(unsigned short address) { + return 0; } + + +void Io_port_session_component::outb(unsigned short address, unsigned char value) { +} + + +void Io_port_session_component::outw(unsigned short address, unsigned short value) { +} + + +void Io_port_session_component::outl(unsigned short address, unsigned value) { +} + + +Io_port_session_component::Io_port_session_component(Range_allocator *io_port_alloc, + const char *args) +: _io_port_alloc(io_port_alloc) +{ + PWRN("no IO_PORT support under Linux (args=\"%s\")", args); + _size = 0; + throw Root::Invalid_args(); +} + + +Io_port_session_component::~Io_port_session_component() +{ + PERR("Implement me, immediately!"); +} diff --git a/base-linux/src/core/pd_session_component.cc b/base-linux/src/core/pd_session_component.cc new file mode 100644 index 000000000..5f809b68b --- /dev/null +++ b/base-linux/src/core/pd_session_component.cc @@ -0,0 +1,51 @@ +/** + * \brief Core implementation of the PD session interface + * \author Christian Helmuth + * \date 2006-07-17 + * + * FIXME arg_string and quota missing + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode */ +#include + +/* Core */ +#include + +/* Linux includes */ +#include + +using namespace Genode; + + +Pd_session_component::Pd_session_component(Rpc_entrypoint *thread_ep, + const char *args) +{ + _pid = Arg_string::find_arg(args, "PID").long_value(0); +} + + +Pd_session_component::~Pd_session_component() +{ + if (_pid) + lx_kill(_pid, 9); +} + + +int Pd_session_component::bind_thread(Thread_capability) +{ + return -1; +} + + +int Pd_session_component::assign_parent(Parent_capability) +{ + return -1; +} diff --git a/base-linux/src/core/platform.cc b/base-linux/src/core/platform.cc new file mode 100644 index 000000000..2946a870f --- /dev/null +++ b/base-linux/src/core/platform.cc @@ -0,0 +1,62 @@ +/* + * \brief Linux platform interface implementation + * \author Norman Feske + * \date 2006-06-13 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* local includes */ +#include "platform.h" +#include "core_env.h" + +/* Linux includes */ +#include +#include + + +using namespace Genode; + + +static char _some_mem[80*1024*1024]; +static Lock _wait_for_exit_lock(Lock::LOCKED); /* exit() sync */ + + +static void signal_handler(int signum) +{ + _wait_for_exit_lock.unlock(); +} + + +Platform::Platform() +: _ram_alloc(0) +{ + /* catch control-c */ + lx_sigaction(2, signal_handler); + + /* create resource directory under /tmp */ + lx_mkdir(lx_rpath(), S_IRWXU); + + _ram_alloc.add_range((addr_t)_some_mem, sizeof(_some_mem)); +} + + +void Platform::wait_for_exit() +{ + /* block until exit condition is satisfied */ + try { _wait_for_exit_lock.lock(); } + catch (Blocking_canceled) { }; +} + +void Core_parent::exit(int exit_value) +{ + lx_exit_group(exit_value); +} diff --git a/base-linux/src/core/platform_thread.cc b/base-linux/src/core/platform_thread.cc new file mode 100644 index 000000000..7f7761903 --- /dev/null +++ b/base-linux/src/core/platform_thread.cc @@ -0,0 +1,86 @@ +/* + * \brief Linux-specific platform thread implementation + * \author Norman Feske + * \date 2007-10-15 + */ + +/* + * Copyright (C) 2007-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include + +/* local includes */ +#include "platform_thread.h" + +/* Linux syscall helper */ +#include + +using namespace Genode; + + +typedef Token Tid_token; + + +Platform_thread::Platform_thread(const char *name, unsigned) +{ + /* search for thread-id portion of thread name */ + Tid_token tok(name); + while (tok.type() != Tid_token::END && tok[0] != ':') + tok = tok.next(); + + /* tok points at the colon separator, next token is the id */ + tok = tok.next(); + + if (tok.type() == Tid_token::END) { + PWRN("Invalid format of thread name."); + return; + } + + /* convert string to thread id */ + ascii_to(tok.start(), &_tid); + + /* search for process-id portion of thread name */ + while (tok.type() != Tid_token::END && tok[0] != ':') + tok = tok.next(); + + /* tok points at the colon separator, next token is the id */ + tok = tok.next(); + + if (tok.type() == Tid_token::END) { + PWRN("Invalid format of thread name."); + return; + } + + /* convert string to process id */ + ascii_to(tok.start(), &_pid); + + /* initialize private members */ + size_t name_len = tok.start() - name; + strncpy(_name, name, min(sizeof(_name), name_len)); +} + + +void Platform_thread::cancel_blocking() +{ + PDBG("send cancel-blocking signal to %ld\n", _tid); + lx_tgkill(_pid, _tid, LX_SIGUSR1); +} + + +void Platform_thread::pause() +{ + PDBG("not implemented"); +} + + +void Platform_thread::resume() +{ + PDBG("not implemented"); +} diff --git a/base-linux/src/core/ram_session_support.cc b/base-linux/src/core/ram_session_support.cc new file mode 100644 index 000000000..dc5815dba --- /dev/null +++ b/base-linux/src/core/ram_session_support.cc @@ -0,0 +1,59 @@ +/* + * \brief Make dataspace accessible to other Linux processes + * \author Norman Feske + * \date 2006-07-03 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* glibc includes */ +#include + +/* Genode includes */ +#include + +/* local includes */ +#include "ram_session_component.h" + +/* Linux syscall bindings */ +#include +#include + + +using namespace Genode; + + +static int ram_ds_cnt = 0; /* counter for creating unique dataspace IDs */ + +void Ram_session_component::_export_ram_ds(Dataspace_component *ds) +{ + char fname_buf[Linux_dataspace::FNAME_LEN]; + + /* assign filename to dataspace */ + snprintf(fname_buf, sizeof(fname_buf), "%s/ds-%d", lx_rpath(), ram_ds_cnt++); + + ds->fname(fname_buf); + + /* create new file representing the dataspace */ + lx_unlink(fname_buf); + int fd = lx_open(fname_buf, O_CREAT | O_RDWR | O_TRUNC | LX_O_CLOEXEC, S_IRWXU); + lx_ftruncate(fd, ds->size()); + lx_close(fd); +} + + +void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds) +{ + lx_unlink(ds->fname().buf); +} + + +void Ram_session_component::_clear_ds(Dataspace_component *ds) +{ + memset((void *)ds->phys_addr(), 0, ds->size()); +} diff --git a/base-linux/src/core/rom_session_component.cc b/base-linux/src/core/rom_session_component.cc new file mode 100644 index 000000000..9a5f39d25 --- /dev/null +++ b/base-linux/src/core/rom_session_component.cc @@ -0,0 +1,71 @@ +/* + * \brief Linux-specific core implementation of the ROM session interface + * \author Norman Feske + * \date 2006-07-06 + * + * The Linux version of ROM session component does not use the + * Rom_fs as provided as constructor argument. Instead, we map + * rom modules directly to files of the host file system. + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Linux includes */ +#include + +/* Genode includes */ +#include +#include +#include + +/* local includes */ +#include "rom_session_component.h" + +using namespace Genode; + + +static Genode::size_t file_size(const char *path) +{ + struct stat64 s; + if (lx_stat(path, &s) < 0) + return 0; + else + return s.st_size; +} + + +Rom_session_component::Rom_session_component(Rom_fs *rom_fs, + Rpc_entrypoint *ds_ep, + const char *args) +: _ds_ep(ds_ep) +{ + /* extract filename from session arguments */ + char fname_buf[Linux_dataspace::FNAME_LEN]; + Arg_string::find_arg(args, "filename").string(fname_buf, sizeof(fname_buf), ""); + + Genode::size_t fsize = file_size(fname_buf); + + /* use invalid capability as default value */ + _ds_cap = Rom_dataspace_capability(); + + /* ROM module not found */ + if (fsize == 0) + throw Root::Invalid_args(); + + _ds = Dataspace_component(fsize, 0, false); + _ds.fname(fname_buf); + + Dataspace_capability ds_cap = _ds_ep->manage(&_ds); + _ds_cap = static_cap_cast(ds_cap); +} + + +Rom_session_component::~Rom_session_component() +{ + _ds_ep->dissolve(&_ds); +} diff --git a/base-linux/src/core/target.mk b/base-linux/src/core/target.mk new file mode 100644 index 000000000..c2b11d79a --- /dev/null +++ b/base-linux/src/core/target.mk @@ -0,0 +1,36 @@ +TARGET = core +REQUIRES = linux +LIBS = cxx ipc heap core_printf process lock raw_server syscall rpath + +GEN_CORE_DIR = $(BASE_DIR)/src/core + +SRC_CC = main.cc \ + platform.cc \ + platform_thread.cc \ + ram_session_component.cc \ + ram_session_support.cc \ + rom_session_component.cc \ + cpu_session_component.cc \ + pd_session_component.cc \ + io_mem_session_component.cc \ + io_port_session_component.cc \ + signal_session_component.cc \ + signal_source_component.cc \ + thread.cc \ + thread_linux.cc \ + context_area.cc \ + debug.cc + +INC_DIR += $(REP_DIR)/src/core/include \ + $(GEN_CORE_DIR)/include \ + $(REP_DIR)/src/platform \ + /usr/include + +vpath main.cc $(GEN_CORE_DIR) +vpath thread.cc $(BASE_DIR)/src/base/thread +vpath ram_session_component.cc $(GEN_CORE_DIR) +vpath cpu_session_component.cc $(GEN_CORE_DIR) +vpath signal_session_component.cc $(GEN_CORE_DIR) +vpath signal_source_component.cc $(GEN_CORE_DIR) +vpath debug.cc $(REP_DIR)/src/base/env +vpath %.cc $(PRG_DIR) diff --git a/base-linux/src/core/thread_linux.cc b/base-linux/src/core/thread_linux.cc new file mode 100644 index 000000000..14f7c60a5 --- /dev/null +++ b/base-linux/src/core/thread_linux.cc @@ -0,0 +1,55 @@ +/* + * \brief Implementation of the core-internal Thread API via Linux threads + * \author Norman Feske + * \date 2006-06-13 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include + +/* Linux syscall bindings */ +#include + +using namespace Genode; + + +static void empty_signal_handler(int) { } + + +static void thread_start(void *) +{ + /* + * Set signal handler such that canceled system calls get not + * transparently retried after a signal gets received. + */ + lx_sigaction(LX_SIGUSR1, empty_signal_handler); + + Thread_base::myself()->entry(); + sleep_forever(); +} + + +void Thread_base::_init_platform_thread() { } + + +void Thread_base::_deinit_platform_thread() { } + + +void Thread_base::start() +{ + /* align initial stack to 16 byte boundary */ + void *thread_sp = (void *)((addr_t)(_context->stack) & ~0xf); + _tid.tid = lx_create_thread(thread_start, thread_sp, this); + _tid.pid = lx_getpid(); +} + + +void Thread_base::cancel_blocking() { } diff --git a/base-linux/src/platform/_main_helper.h b/base-linux/src/platform/_main_helper.h new file mode 100644 index 000000000..8aa049a03 --- /dev/null +++ b/base-linux/src/platform/_main_helper.h @@ -0,0 +1,40 @@ +/* + * \brief Platform-specific helper functions for the _main() function + * \author Christian Prochaska + * \date 2009-08-05 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _PLATFORM___MAIN_HELPER_H_ +#define _PLATFORM___MAIN_HELPER_H_ + +#include + +#include + +/* + * Define 'lx_environ' pointer that is supposed to be initialized by the + * startup code. + */ +__attribute__((weak)) char **lx_environ = (char **)0; + + +static void main_thread_bootstrap() +{ + using namespace Genode; + + /* reserve context area */ + Genode::addr_t base = Thread_base::CONTEXT_AREA_VIRTUAL_BASE; + Genode::size_t size = Thread_base::CONTEXT_AREA_VIRTUAL_SIZE; + if (lx_vm_reserve(base, size) != base) + PERR("reservation of context area [%lx,%lx) failed", + (unsigned long) base, (unsigned long) base + size); +} + +#endif /* _PLATFORM___MAIN_HELPER_H_ */ diff --git a/base-linux/src/platform/context_area.nostdlib.ld b/base-linux/src/platform/context_area.nostdlib.ld new file mode 100644 index 000000000..fa3e2f54a --- /dev/null +++ b/base-linux/src/platform/context_area.nostdlib.ld @@ -0,0 +1,25 @@ +/* + * \brief Linux-specific linker script additions (STDLIB = no) + * \author Christian Helmuth + * \date 2010-09-22 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +PHDRS +{ + context_area PT_LOAD FLAGS(0); +} + +SECTIONS +{ + . = 0x40000000; + _context_area_start = .; + .context_area : { . += 0x10000000; } : context_area + _context_area_end = .; +} diff --git a/base-linux/src/platform/context_area.stdlib.ld b/base-linux/src/platform/context_area.stdlib.ld new file mode 100644 index 000000000..1ef45a1c1 --- /dev/null +++ b/base-linux/src/platform/context_area.stdlib.ld @@ -0,0 +1,20 @@ +/* + * \brief Linux-specific linker script additions (STDLIB = yes) + * \author Christian Helmuth + * \date 2010-09-22 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +SECTIONS +{ + . = 0x40000000; + _context_area_start = .; + .context_area : { . += 0x10000000; } + _context_area_end = .; +} diff --git a/base-linux/src/platform/linux_rpath.cc b/base-linux/src/platform/linux_rpath.cc new file mode 100644 index 000000000..3432798c0 --- /dev/null +++ b/base-linux/src/platform/linux_rpath.cc @@ -0,0 +1,39 @@ +/* + * \brief Linux resource path + * \author Christian Helmuth + * \date 2011-09-25 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +#include +#include + + +namespace { + struct Rpath + { + char string[32]; + + Rpath() + { + Genode::snprintf(string, sizeof(string), "/tmp/genode-%d", lx_getuid()); + } + }; +} + + +char const * lx_rpath() +{ + static Rpath rpath; + + return rpath.string; +} diff --git a/base-linux/src/platform/linux_rpath.h b/base-linux/src/platform/linux_rpath.h new file mode 100644 index 000000000..34f52fe4f --- /dev/null +++ b/base-linux/src/platform/linux_rpath.h @@ -0,0 +1,25 @@ +/* + * \brief Linux resource path + * \author Christian Helmuth + * \date 2011-09-25 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _PLATFORM__LINUX_RPATH_H_ +#define _PLATFORM__LINUX_RPATH_H_ + + +/** + * Return resource path for Genode + * + * Genode creates files for dataspaces and endpoints under in this directory. + */ +char const * lx_rpath(); + +#endif /* _PLATFORM__LINUX_RPATH_H_ */ diff --git a/base-linux/src/platform/linux_syscalls.h b/base-linux/src/platform/linux_syscalls.h new file mode 100644 index 000000000..5433178fb --- /dev/null +++ b/base-linux/src/platform/linux_syscalls.h @@ -0,0 +1,501 @@ +/* + * \brief Linux system-call wrappers + * \author Norman Feske + * \date 2008-10-22 + * + * This file is meant to be internally used by the framework. It is not public + * interface. + * + * From within the framework libraries, we have to use the Linux syscall + * interface directly rather than relying on convenient libC functions to be + * able to link this part of the framework to a custom libC. Otherwise, we + * would end up with very nasty cyclic dependencies when using framework + * functions such as IPC from the libC back end. + * + * The Linux syscall interface looks different for 32bit and 64bit system, in + * particular regarding the socket interface. On 32bit systems, all socket + * operations are invoked via the 'socketcall' syscall. On 64bit systems, the + * different socket functions have distinct syscalls. + */ + +/* + * Copyright (C) 2008-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _PLATFORM__LINUX_SYSCALLS_H_ +#define _PLATFORM__LINUX_SYSCALLS_H_ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 /* needed to enable the definition of 'stat64' */ +#endif + +/* Linux includes */ +#include +#include +#include +#include +#include + +/* Genode includes */ +#include + + +/***************************************** + ** Functions used by the IPC framework ** + *****************************************/ + +#include + +extern "C" long lx_syscall(int number, ...); +extern "C" int lx_clone(int (*fn)(void *), void *child_stack, + int flags, void *arg); + + +inline Genode::uint16_t lx_bswap16(Genode::uint16_t x) +{ + char v[2] = { + (x & 0xff00) >> 8, + (x & 0x00ff) >> 0, + }; + return *(Genode::uint16_t *)v; +} + + +inline Genode::uint32_t lx_bswap32(Genode::uint32_t x) +{ + char v[4] = { + (x & 0xff000000) >> 24, + (x & 0x00ff0000) >> 16, + (x & 0x0000ff00) >> 8, + (x & 0x000000ff) >> 0, + }; + return *(Genode::uint32_t *)v; +} + +#define lx_htonl(x) lx_bswap32(x) +#define lx_htons(x) lx_bswap16(x) +#define lx_ntohs(x) lx_bswap16(x) + +#ifdef SYS_socketcall + +inline int lx_socketcall(int call, unsigned long *args) +{ + int res = lx_syscall(SYS_socketcall, call, args); + return res; +} + + +inline int lx_socket(int domain, int type, int protocol) +{ + unsigned long args[3] = { domain, type, protocol }; + return lx_socketcall(SYS_SOCKET, args); +} + + +inline int lx_connect(int sockfd, const struct sockaddr *serv_addr, + socklen_t addrlen) +{ + unsigned long args[3] = { sockfd, (unsigned long)serv_addr, addrlen }; + return lx_socketcall(SYS_CONNECT, args); +} + + +inline int lx_bind(int sockfd, const struct sockaddr *addr, + socklen_t addrlen) +{ + unsigned long args[3] = { sockfd, (unsigned long)addr, addrlen }; + return lx_socketcall(SYS_BIND, args); +} + + +inline int lx_getsockname(int s, struct sockaddr *name, socklen_t *namelen) +{ + unsigned long args[3] = { s, (unsigned long)name, (unsigned long)namelen }; + return lx_socketcall(SYS_GETSOCKNAME, args); +} + + +inline ssize_t lx_recvfrom(int s, void *buf, Genode::size_t len, int flags, + struct sockaddr *from, socklen_t *from_len) +{ + unsigned long args[6] = { s, (unsigned long)buf, len, flags, + (unsigned long)from, (unsigned long)from_len }; + return lx_socketcall(SYS_RECVFROM, args); +} + + +inline ssize_t lx_sendto(int s, void *buf, Genode::size_t len, int flags, + struct sockaddr *to, socklen_t to_len) +{ + unsigned long args[6] = { s, (unsigned long)buf, len, flags, + (unsigned long)to, (unsigned long)to_len }; + return lx_socketcall(SYS_SENDTO, args); +} + +#else + +inline int lx_socket(int domain, int type, int protocol) +{ + return lx_syscall(SYS_socket, domain, type, protocol); +} + + +inline int lx_connect(int sockfd, const struct sockaddr *serv_addr, + socklen_t addrlen) +{ + return lx_syscall(SYS_connect, sockfd, serv_addr, addrlen); +} + + +inline int lx_bind(int sockfd, const struct sockaddr *addr, + socklen_t addrlen) +{ + return lx_syscall(SYS_bind, sockfd, addr, addrlen); +} + + +inline int lx_getsockname(int s, struct sockaddr *name, socklen_t *namelen) +{ + return lx_syscall(SYS_getsockname, s, name, namelen); +} + + +inline ssize_t lx_recvfrom(int s, void *buf, Genode::size_t len, int flags, + struct sockaddr *from, socklen_t *from_len) +{ + return lx_syscall(SYS_recvfrom, s, buf, len, flags, from, from_len); +} + + +inline ssize_t lx_sendto(int s, void *buf, Genode::size_t len, int flags, + struct sockaddr *to, socklen_t to_len) +{ + return lx_syscall(SYS_sendto, s, buf, len, flags, to, to_len); +} + +#endif /* SYS_socketcall */ + + +inline int lx_write(int fd, const void *buf, Genode::size_t count) +{ + return lx_syscall(SYS_write, fd, buf, count); +} + + +inline int lx_close(int fd) +{ + return lx_syscall(SYS_close, fd); +} + + +/******************************************* + ** Functions used by the process library ** + *******************************************/ + +inline int lx_execve(const char *filename, char *const argv[], + char *const envp[]) +{ + return lx_syscall(SYS_execve, filename, argv, envp); +} + + +inline void lx_exit(int status) +{ + lx_syscall(SYS_exit, status); +} + + +inline void lx_exit_group(int status) +{ + lx_syscall(SYS_exit_group, status); +} + + +/************************************************************ + ** Functions used by the env library and local rm session ** + ************************************************************/ + +/* O_CLOEXEC is a GNU extension so we provide it here */ +enum { LX_O_CLOEXEC = 02000000 }; + +inline int lx_open(const char *pathname, int flags, mode_t mode = 0) +{ + return lx_syscall(SYS_open, pathname, flags, mode); +} + + +inline void *lx_mmap(void *start, Genode::size_t length, int prot, int flags, + int fd, off_t offset) +{ +#ifdef _LP64 + return (void *)lx_syscall(SYS_mmap, start, length, prot, flags, fd, offset); +#else + return (void *)lx_syscall(SYS_mmap2, start, length, prot, flags, fd, offset/4096); +#endif /* _LP64 */ +} + + +inline int lx_munmap(void *addr, size_t length) +{ + return lx_syscall(SYS_munmap, addr, length); +} + + +/** + * Exclude local virtual memory area from being used by mmap + * + * \param base base address of area to reserve + * \param size number of bytes to reserve + * + * \return start of allocated reserved area, or ~0 on failure + */ +inline Genode::addr_t lx_vm_reserve(Genode::addr_t base, Genode::size_t size) +{ + /* we cannot include sys/mman.h from here */ + enum { + LX_MAP_PRIVATE = 0x02, + LX_MAP_FIXED = 0x10, + LX_MAP_ANONYMOUS = 0x20, + LX_PROT_NONE = 0x0 + }; + + int const flags = LX_MAP_ANONYMOUS | LX_MAP_PRIVATE + | (base ? LX_MAP_FIXED : 0); + + void * const res = lx_mmap((void *)base, size, LX_PROT_NONE, flags, -1, 0); + + if (base) + return ((Genode::addr_t)res == base) ? base : ~0; + else + return (Genode::addr_t)res; +} + + +/******************************************************* + ** Functions used by core's ram-session support code ** + *******************************************************/ + +inline int lx_mkdir(char const *pathname, mode_t mode) +{ + return lx_syscall(SYS_mkdir, pathname, mode); +} + + +inline int lx_ftruncate(int fd, unsigned long length) +{ + return lx_syscall(SYS_ftruncate, fd, length); +} + + +inline int lx_unlink(const char *fname) +{ + return lx_syscall(SYS_unlink, fname); +} + +/******************************************************* + ** Functions used by core's rom-session support code ** + *******************************************************/ + +inline int lx_stat(const char *path, struct stat64 *buf) +{ +#ifdef _LP64 + return lx_syscall(SYS_stat, path, buf); +#else + return lx_syscall(SYS_stat64, path, buf); +#endif +} + +/*********************************************************************** + ** Functions used by thread lib and core's cancel-blocking mechanism ** + ***********************************************************************/ + +enum { + LX_SIGUSR1 = 10, /* used for cancel-blocking mechanism */ + LX_SIGCANCEL = 32, /* accoring to glibc, this equals SIGRTMIN, + used for killing threads */ +}; + + +struct kernel_sigaction +{ + void (*handler)(int); + unsigned long flags; + void (*restorer)(void); + sigset_t mask; +}; + + +inline int lx_sigemptyset(sigset_t *set) +{ + if (set == 0) + return -1; + Genode::memset(set, 0, sizeof(sigset_t)); + return 0; +} + + +#ifdef _LP64 +extern "C" void lx_restore_rt (void); +#endif + +/** + * Simplified binding for sigaction system call + */ +inline int lx_sigaction(int signum, void (*handler)(int)) +{ + struct kernel_sigaction act; + act.handler = handler; + +#ifdef _LP64 + /* + * The SA_RESTORER flag is not officially documented, but used internally + * by the glibc implementation of sigaction(). Without specifying this flag + * tgkill() does not work on x86_64. The restorer function gets called + * when leaving the signal handler and it should call the rt_sigreturn syscall. + */ + enum { SA_RESTORER = 0x04000000 }; + act.flags = SA_RESTORER; + act.restorer = lx_restore_rt;; +#else + act.flags = 0; + act.restorer = 0; +#endif + lx_sigemptyset(&act.mask); + + return lx_syscall(SYS_rt_sigaction, signum, &act, 0UL, _NSIG/8); +} + + +/** + * Send signal to process + * + * This function is used by core to kill processes. + */ +inline int lx_kill(int pid, int signal) +{ + return lx_syscall(SYS_kill, pid, signal); +} + + +/** + * Send signal to thread + * + * This function is used by core to cancel blocking operations of + * threads, and by the thread library to kill threads. + */ +inline int lx_tgkill(int pid, int tid, int signal) +{ + return lx_syscall(SYS_tgkill, pid, tid, signal); +} + + +inline int lx_create_thread(void (*entry)(void *), void *stack, void *arg) +{ + int flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND + | CLONE_THREAD | CLONE_SYSVSEM; + + /* + * The syscall binding for clone does not exist in the FreeBSD libc, which + * we are using as libc for Genode. In glibc, clone is implemented as a + * assembler binding without external libc references. Hence, we are safe + * to rely on the glibc version of 'clone' here. + */ + return lx_clone((int (*)(void *))entry, stack, flags, arg); +} + + +inline int lx_create_process(int (*entry)(void *), void *stack, void *arg) +{ + int flags = CLONE_VFORK | SIGCHLD; + return lx_clone((int (*)(void *))entry, stack, flags, arg); +} + + +inline pid_t lx_getpid() { return lx_syscall(SYS_getpid); } +inline pid_t lx_gettid() { return lx_syscall(SYS_gettid); } +inline uid_t lx_getuid() { return lx_syscall(SYS_getuid); } + + +/************************************ + ** Functions used by lock library ** + ************************************/ + +struct timespec; + +inline int lx_nanosleep(const struct timespec *req, struct timespec *rem) +{ + return lx_syscall(SYS_nanosleep, req, rem); +} + + +/** + * Signal set corrsponding to glibc's 'sigset_t' + */ +class Lx_sigset +{ + unsigned long int _value[_SIGSET_NWORDS]; + + public: + + /** + * Constructor + */ + Lx_sigset() { } + + /** + * Constructor + * + * \param signum set specified entry of sigset + */ + Lx_sigset(int signum) + { + + for (unsigned i = 0; i < _SIGSET_NWORDS; i++) + _value[i] = 0; + + /* + * Both '__sigword' and '__sigmask' are macros, defined in the + * glibc header file 'bits/sigset.h' and not external functions. + * Therefore we can use them here without getting into conflicts + * with the linkage of another libc. + */ + _value[__sigword(signum)] = __sigmask(signum); + } + + bool is_set(int signum) { + return _value[__sigword(signum)] && __sigmask(signum); } +}; + + +/** + * Check if signal is pending + * + * \return true if signal is pending + */ +inline bool lx_sigpending(int signum) +{ + Lx_sigset sigset; + lx_syscall(SYS_rt_sigpending, &sigset, _NSIG/8); + return sigset.is_set(signum); +} + + +/** + * Set signal mask state + * + * \param signum signal to mask or unmask + * \param state mask state for the signal, + * true enables the signal, + * false blocks the signal + */ +inline bool lx_sigsetmask(int signum, bool state) +{ + Lx_sigset old_sigmask, sigset(signum); + lx_syscall(SYS_rt_sigprocmask, state ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old_sigmask, _NSIG/8); + return old_sigmask.is_set(signum); +} + +#endif /* _PLATFORM__LINUX_SYSCALLS_H_ */ diff --git a/base-linux/src/platform/lx_hybrid.cc b/base-linux/src/platform/lx_hybrid.cc new file mode 100644 index 000000000..db8bf950c --- /dev/null +++ b/base-linux/src/platform/lx_hybrid.cc @@ -0,0 +1,47 @@ +/* + * \brief Supplemental code for hybrid Genode/Linux programs + * \author Norman Feske + * \date 2011-09-02 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include +#include +#include <_main_helper.h> + + +extern "C" int raw_write_str(const char *str); + + +/** + * Dummy for symbol that is normally provided by '_main.cc' + */ +int genode___cxa_atexit(void (*func)(void*), void *arg, void *dso) +{ + raw_write_str("genode___cxa_atexit called, not implemented\n"); + return 0; +} + + +/* + * Manually initialize the 'lx_environ' pointer. For non-hybrid programs, this + * pointer is initialized by the startup code. + */ +extern char **environ; +extern char **lx_environ; + +/* + * This function must be called before any other static constructor in the Genode + * application, so it gets the highest priority (lowest priority number >100) + */ +__attribute__((constructor(101))) void lx_hybrid_init() +{ + main_thread_bootstrap(); + lx_environ = environ; +} diff --git a/base-linux/src/platform/x86_32/crt0.s b/base-linux/src/platform/x86_32/crt0.s new file mode 100644 index 000000000..384207b8b --- /dev/null +++ b/base-linux/src/platform/x86_32/crt0.s @@ -0,0 +1,70 @@ +/* + * \brief Startup code for Genode applications + * \author Christian Helmuth + * \date 2006-07-06 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/*--- .text (program code) -------------------------*/ + .text + + .globl _start +_start: + + movl %esp, __initial_sp + /* + * environ = &argv[argc + 1] + * in Genode argc is always 1 + */ + popl %eax /* argc */ + popl %eax /* argv[0] */ + popl %eax /* NULL */ + movl %esp, lx_environ + + /* XXX Switch to our own stack. */ + movl $_stack_high,%esp + + /* Clear the base pointer so that stack backtraces will work. */ + xorl %ebp,%ebp + + /* Jump into init C code */ + call _main + + /* We should never get here since _main does not return */ +1: int $3 + jmp 2f + .ascii "_main() returned." +2: jmp 1b + + +/*--------------------------------------------------*/ + .data + .globl __dso_handle +__dso_handle: + .long 0 + + .globl __initial_sp +__initial_sp: + .long 0 + +/*--- .eh_frame (exception frames) -----------------*/ +/* + .section .eh_frame,"aw" + .globl __EH_FRAME_BEGIN__ +__EH_FRAME_BEGIN__: +*/ + +/*--- .bss (non-initialized data) ------------------*/ + .bss + .p2align 4 + .globl _stack_low +_stack_low: + .space 64*1024 + .globl _stack_high +_stack_high: diff --git a/base-linux/src/platform/x86_32/lx_clone.S b/base-linux/src/platform/x86_32/lx_clone.S new file mode 100644 index 000000000..cc290f656 --- /dev/null +++ b/base-linux/src/platform/x86_32/lx_clone.S @@ -0,0 +1,109 @@ +/* + * \brief Linux clone() binding + * \author Christian Prochaska + * \date 2009-07-14 + * + * based on glibc-2.9/sysdeps/unix/sysv/linux/i386/clone.S + */ + + +#define L(name) name + +#define ENTER_KERNEL int $0x80 +#define SYS_clone 120 +#define SYS_exit 1 + +#define LINKAGE 4 +#define PTR_SIZE 4 + +#define PARMS LINKAGE /* no space for saved regs */ +#define FUNC PARMS +#define STACK FUNC+4 +#define FLAGS STACK+PTR_SIZE +#define ARG FLAGS+4 +#define PTID ARG+PTR_SIZE +#define TLS PTID+PTR_SIZE +#define CTID TLS+PTR_SIZE + + .text + .globl lx_clone + .type lx_clone, @function +lx_clone: + .cfi_startproc + + /* Insert the argument onto the new stack. Make sure the new + thread is started with an alignment of (mod 16). */ + movl STACK(%esp),%ecx + andl $0xfffffff0, %ecx + subl $28,%ecx + movl ARG(%esp),%eax /* no negative argument counts */ + movl %eax,12(%ecx) + + /* Save the function pointer as the zeroth argument. + It will be popped off in the child in the ebx frobbing below. */ + movl FUNC(%esp),%eax + movl %eax,8(%ecx) + /* Don't leak any information. */ + movl $0,4(%ecx) + movl $0,(%ecx) + + /* Do the system call */ + pushl %ebx + .cfi_adjust_cfa_offset (4) + pushl %esi + .cfi_adjust_cfa_offset (4) + pushl %edi + .cfi_adjust_cfa_offset (4) + + movl TLS+12(%esp),%esi + .cfi_rel_offset %esi, 4 + movl PTID+12(%esp),%edx + movl FLAGS+12(%esp),%ebx + .cfi_rel_offset %ebx, 8 + movl CTID+12(%esp),%edi + .cfi_rel_offset %edi, 0 + movl $SYS_clone,%eax + + /* End FDE now, because in the child the unwind info will be + wrong. */ + .cfi_endproc + + ENTER_KERNEL + popl %edi + popl %esi + popl %ebx + + test %eax,%eax + jz L(thread_start) + +L(pseudo_end): + ret + +L(thread_start): + .cfi_startproc; + /* Clearing frame pointer is insufficient, use CFI. */ + .cfi_undefined %eip; + /* Note: %esi is zero. */ + movl %esi,%ebp /* terminate the stack frame */ + call *%ebx +#ifdef PIC + call L(here) +L(here): + popl %ebx + addl $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ebx +#endif + movl %eax, %ebx + movl $SYS_exit, %eax + ENTER_KERNEL + + .cfi_endproc; + + .cfi_startproc + .cfi_endproc + +/* + * Allow stacks to be mapped executable (needed because Genode does not + * offer an API to handle non-execute mappings yet). + */ +.section .note.GNU-stack, "", @progbits + diff --git a/base-linux/src/platform/x86_32/lx_syscall.S b/base-linux/src/platform/x86_32/lx_syscall.S new file mode 100644 index 000000000..fccc9c05a --- /dev/null +++ b/base-linux/src/platform/x86_32/lx_syscall.S @@ -0,0 +1,77 @@ +/* + * \brief Linux syscall() binding + * \author Christian Prochaska + * \date 2009-07-14 + * + * based on glibc-2.9/sysdeps/unix/sysv/linux/i386/syscall.S + * + * error case: + * glibc's syscall() function returns -1 and sets errno + * lx_syscall() returns -errno + */ + + +#define L(name) name + +#define ENTER_KERNEL int $0x80 + + .text + .globl lx_syscall + .type lx_syscall, @function +lx_syscall: + .cfi_startproc +/* PUSHARGS_6*/ /* Save register contents. */ +/* PUSHARGS_6 begin */ + pushl %ebp; + .cfi_adjust_cfa_offset 4; + .cfi_rel_offset %ebp, 0; +L(PUSHBP1): + pushl %edi; + .cfi_adjust_cfa_offset 4; + .cfi_rel_offset %edi, 0; +L(PUSHDI1): + pushl %esi; + .cfi_adjust_cfa_offset 4; + .cfi_rel_offset %esi, 0; +L(PUSHSI1): + pushl %ebx; + .cfi_adjust_cfa_offset 4; + .cfi_rel_offset %ebx, 0; +L(PUSHBX1): +/* PUSHARGS_6 end */ + + /*_DOARGS_6(44)*/ /* Load arguments. */ +/*_DOARGS_6(44) begin*/ + movl 44(%esp), %ebp; + movl 40(%esp), %edi; + movl 36(%esp), %esi; + movl 32(%esp), %edx; + movl 28(%esp), %ecx; + movl 24(%esp), %ebx; +/*_DOARGS_6(44) end*/ + movl 20(%esp), %eax /* Load syscall number into %eax. */ + ENTER_KERNEL /* Do the system call. */ +/* POPARGS_6*/ /* Restore register contents. */ +/* POPARGS_6 begin */ + popl %ebx; + .cfi_adjust_cfa_offset -4; + .cfi_restore %ebx; +L(POPBX1): + popl %esi; + .cfi_adjust_cfa_offset -4; + .cfi_restore %esi; +L(POPSI1): + popl %edi; + .cfi_adjust_cfa_offset -4; + .cfi_restore %edi; +L(POPDI1): + popl %ebp; + .cfi_adjust_cfa_offset -4; + .cfi_restore %ebp; +L(POPBP1): +/* POPARGS_6 end */ +L(pseudo_end): + ret /* Return to caller. */ + + .cfi_endproc + diff --git a/base-linux/src/platform/x86_64/crt0.s b/base-linux/src/platform/x86_64/crt0.s new file mode 100644 index 000000000..a51dd556e --- /dev/null +++ b/base-linux/src/platform/x86_64/crt0.s @@ -0,0 +1,74 @@ +/* + * \brief Startup code for Genode applications + * \author Christian Helmuth + * \date 2006-07-06 + */ + +/* + * Copyright (C) 2006-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/*--- .text (program code) -------------------------*/ + .text + + .globl _start +_start: + + movq __initial_sp@GOTPCREL(%rip), %rax + movq %rsp, (%rax) + /* + * environ = &argv[argc + 1] + * in Genode argc is always 1 + */ + popq %rax /* argc */ + popq %rax /* argv[0] */ + popq %rax /* NULL */ + movq lx_environ@GOTPCREL(%rip), %rax + movq %rsp, (%rax) + + /* XXX Switch to our own stack. */ + leaq _stack_high@GOTPCREL(%rip), %rax + movq (%rax), %rsp + + /* Clear the base pointer so that stack backtraces will work. */ + xorq %rbp,%rbp + + /* Jump into init C code */ + callq _main + + /* We should never get here since _main does not return */ +1: int $3 + jmp 2f + .ascii "_main() returned." +2: jmp 1b + + +/*--------------------------------------------------*/ + .data + .p2align 8 + .globl __dso_handle +__dso_handle: + .quad 0 + + .globl __initial_sp +__initial_sp: + .quad 0 + +/*--- .eh_frame (exception frames) -----------------*/ +/* + .section .eh_frame,"aw" + .globl __EH_FRAME_BEGIN__ +__EH_FRAME_BEGIN__: +*/ + +/*--- .bss (non-initialized data) ------------------*/ + .bss + .p2align 8 + .globl _stack_low +_stack_low: + .space 64*1024 + .globl _stack_high +_stack_high: diff --git a/base-linux/src/platform/x86_64/lx_clone.S b/base-linux/src/platform/x86_64/lx_clone.S new file mode 100644 index 000000000..8edeea931 --- /dev/null +++ b/base-linux/src/platform/x86_64/lx_clone.S @@ -0,0 +1,71 @@ +/* + * \brief Linux clone() binding + * \author Christian Prochaska + * \date 2009-07-14 + * + * based on glibc-2.9/sysdeps/unix/sysv/linux/x86_64/clone.S + */ + +#define L(name) name + +#define SYS_clone 56 +#define SYS_exit 60 + + .text + .globl lx_clone + .type lx_clone, @function +lx_clone: + .cfi_startproc + + /* Insert the argument onto the new stack. */ + subq $16,%rsi + movq %rcx,8(%rsi) + + /* Save the function pointer. It will be popped off in the + child in the ebx frobbing below. */ + movq %rdi,0(%rsi) + + /* Do the system call. */ + movq %rdx, %rdi + movq %r8, %rdx + movq %r9, %r8 + movq 8(%rsp), %r10 + movl $SYS_clone,%eax + + /* End FDE now, because in the child the unwind info will be + wrong. */ + .cfi_endproc + syscall + + testq %rax,%rax + jz L(thread_start) + +L(pseudo_end): + /* parent returns */ + ret + +L(thread_start): + .cfi_startproc + /* Clearing frame pointer is insufficient, use CFI. */ + .cfi_undefined (%rip); + + /* Clear the frame pointer. The ABI suggests this be done, to mark + the outermost frame obviously. */ + xorl %ebp, %ebp + + /* Set up arguments for the function call. */ + popq %rax /* Function to call. */ + popq %rdi /* Argument. */ + call *%rax + /* Call exit with return value from function call. */ + movq %rax, %rdi + movq $SYS_exit, %rax + syscall + .cfi_endproc + +/* + * Allow stacks to be mapped executable (needed because Genode does not + * offer an API to handle non-executable mappings yet). + */ +.section .note.GNU-stack, "", @progbits + diff --git a/base-linux/src/platform/x86_64/lx_restore_rt.S b/base-linux/src/platform/x86_64/lx_restore_rt.S new file mode 100644 index 000000000..9297c9435 --- /dev/null +++ b/base-linux/src/platform/x86_64/lx_restore_rt.S @@ -0,0 +1,16 @@ +/* + * \brief Linux signal handler restorer function + * \author Christian Prochaska + * \date 2009-07-14 + * + */ + + +#define SYS_rt_sigreturn 15 + + .text + .globl lx_restore_rt + .type lx_restore_rt, @function +lx_restore_rt: + movq $SYS_rt_sigreturn, %rax + syscall diff --git a/base-linux/src/platform/x86_64/lx_syscall.S b/base-linux/src/platform/x86_64/lx_syscall.S new file mode 100644 index 000000000..47b008a88 --- /dev/null +++ b/base-linux/src/platform/x86_64/lx_syscall.S @@ -0,0 +1,29 @@ +/* + * \brief Linux syscall() binding + * \author Christian Prochaska + * \date 2009-07-14 + * + * based on glibc-2.9/sysdeps/unix/sysv/linux/x86_64/syscall.S + * + * error case: + * glibc's syscall() function returns -1 and sets errno + * lx_syscall() returns -errno + */ + + +#define L(name) name + + .text + .globl lx_syscall + .type lx_syscall, @function +lx_syscall: + movq %rdi, %rax /* Syscall number -> rax. */ + movq %rsi, %rdi /* shift arg1 - arg5. */ + movq %rdx, %rsi + movq %rcx, %rdx + movq %r8, %r10 + movq %r9, %r8 + movq 8(%rsp),%r9 /* arg6 is on the stack. */ + syscall /* Do the system call. */ +L(pseudo_end): + ret /* Return to caller. */ diff --git a/base-linux/src/test/lx_hybrid_ctors/main.cc b/base-linux/src/test/lx_hybrid_ctors/main.cc new file mode 100644 index 000000000..a7f7b83ec --- /dev/null +++ b/base-linux/src/test/lx_hybrid_ctors/main.cc @@ -0,0 +1,39 @@ +/* + * \brief Test if global static constructors in hybrid applications get called + * \author Christian Prochaska + * \date 2011-11-24 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + + +#include + +using namespace Genode; + + +struct Testapp_testclass +{ + Testapp_testclass() + { + Genode::printf("Global static constructor of Genode application called\n"); + } +}; + + +Testapp_testclass testapp_testclass; + + +int main(int argc, char *argv[]) +{ + printf("--- lx_hybrid global static constructor test ---\n"); + + printf("--- returning from main ---\n"); + + return 0; +} diff --git a/base-linux/src/test/lx_hybrid_ctors/target.mk b/base-linux/src/test/lx_hybrid_ctors/target.mk new file mode 100644 index 000000000..3125dfea4 --- /dev/null +++ b/base-linux/src/test/lx_hybrid_ctors/target.mk @@ -0,0 +1,22 @@ +TARGET = test-lx_hybrid_ctors +SRC_CC = main.cc +LIBS = env lx_hybrid + +EXT_OBJECTS += $(BUILD_BASE_DIR)/test/lx_hybrid_ctors/libtestlib.so + +TESTLIB_SO = libtestlib.so +TESTLIB_SRC_CC = testlib.cc + +$(TARGET): libtestlib.so + +$(TESTLIB_SO): $(TESTLIB_SRC_CC) + $(MSG_BUILD)$(TESTLIB_SO) + $(VERBOSE)g++ -fPIC -c $^ + $(VERBOSE)g++ -shared -Wlsoname,$(TESTLIB_SO) -o $@ $(notdir $(^:.cc=.o)) + +clean_libtestlib: + $(VERBOSE)rm -f $(TESTLIB_SO) $(TESTLIB_SRC_CC:.cc=.o) + +clean: clean_libtestlib + +vpath testlib.cc $(PRG_DIR) diff --git a/base-linux/src/test/lx_hybrid_ctors/testlib.cc b/base-linux/src/test/lx_hybrid_ctors/testlib.cc new file mode 100644 index 000000000..827a457a5 --- /dev/null +++ b/base-linux/src/test/lx_hybrid_ctors/testlib.cc @@ -0,0 +1,24 @@ +/* + * \brief Test if global static constructors in host shared libs get called + * \author Christian Prochaska + * \date 2011-11-24 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +struct Testlib_testclass +{ + Testlib_testclass() + { + printf("[init -> test-lx_hybrid_ctors] Global static constructor of host library called.\n"); + } +}; + +Testlib_testclass testlib_testclass; diff --git a/base-linux/src/test/lx_hybrid_exception/main.cc b/base-linux/src/test/lx_hybrid_exception/main.cc new file mode 100644 index 000000000..a79f7e0b3 --- /dev/null +++ b/base-linux/src/test/lx_hybrid_exception/main.cc @@ -0,0 +1,37 @@ +/* + * \brief Test if the exception mechanism works in hybrid applications + * \author Christian Prochaska + * \date 2011-11-22 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#include + +using namespace Genode; + +class Test_exception { }; + +/** + * Main program + */ +int main(int, char **) +{ + printf("--- lx_hybrid exception test ---\n"); + + try { + printf("Throwing Test_exception\n"); + throw Test_exception(); + } catch(Test_exception) { + printf("Caught Test_exception\n"); + } + + printf("--- returning from main ---\n"); + + return 0; +} diff --git a/base-linux/src/test/lx_hybrid_exception/target.mk b/base-linux/src/test/lx_hybrid_exception/target.mk new file mode 100644 index 000000000..7a7242111 --- /dev/null +++ b/base-linux/src/test/lx_hybrid_exception/target.mk @@ -0,0 +1,3 @@ +TARGET = test-lx_hybrid_exception +SRC_CC = main.cc +LIBS = env lx_hybrid diff --git a/base-linux/src/test/sub_rm/config.h b/base-linux/src/test/sub_rm/config.h new file mode 100644 index 000000000..ec66d4fdb --- /dev/null +++ b/base-linux/src/test/sub_rm/config.h @@ -0,0 +1,22 @@ +/* + * \brief Linux-specific policy for sub_rm test + * \author Norman Feske + * \date 2011-11-22 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* + * The Linux implementation of the RM service does not support attaching + * the same sub RM session twice. This configuration enables the respective + * error-handling test. + */ +enum { attach_twice_forbidden = true }; + +enum { support_attach_sub_any = false }; + diff --git a/base-mb/README b/base-mb/README new file mode 100644 index 000000000..730ff1f63 --- /dev/null +++ b/base-mb/README @@ -0,0 +1,11 @@ +This repository contains the port of Genode for Xilinx MicroBlaze-based +platforms. It is based on an custom microkernel implementation, which is also +part of this repository. To get an overview on the this platform and the +underlying microkernel please refer to the introduction located at: + +! /base-mb/doc/microblaze.txt + +To get a quick overview about how to work with this platform, you may read the +getting-started guide located at: + +! /base-mb/doc/getting_started.txt diff --git a/base-mb/doc/getting_started.txt b/base-mb/doc/getting_started.txt new file mode 100644 index 000000000..efdac7643 --- /dev/null +++ b/base-mb/doc/getting_started.txt @@ -0,0 +1,249 @@ + + ========================================================= + Getting started with Genode on MicroBlaze based platforms + ========================================================= + + + Martin Stein + + +This file describes in a practical manner how to work with Genode on platforms +which are based on the Xilinx MicroBlaze. It approaches the following aspects: + +* Build Genode with an existing static scenario of programs which are interacting + on with each other and printing information about it to the serial port. +* Run this Genode scenario on Qemu and on the Xilinx Spartan 3A Starter Kit +* Implement basic support aspects for new MicroBlaze-based platforms + +If you're not familar with the Genode OS framework, you can read the online +documentation: + + [http://genode.org/documentation/] + +If you need further information about the Xilinx MicroBlaze, you can read an +introduction written by the Genode developers inside your Genode directory: + + 'base-mb/doc/microblaze.txt' + +It also covers general issues and limitations respecting the status quo of the +Genode porting for MicroBlaze-based platforms. To go in detail about the Xilinx +MicroBlaze, you may refer to the Xilinx documentation: + + [http://www.xilinx.com/tools/microblaze.htm] + +Prerequisites +============= + +The MicroBlaze tool chain +~~~~~~~~~~~~~~~~~~~~~~~~~ + +To build Genode for MicroBlaze, it is recommended to use the following +GCC/binutils-compliant tools: + +* mb-g++ (GCC) 4.1.1 20060524 (Xilinx 11.2 Build EDK_LS2.2 20 Apr 2009 Xilinx + 11.2 Build EDK_LS2.2 23 Apr 2009) +* GNU ld version 2.16 Xilinx 11.2 Build EDK_LS2.2 23 Apr 2009 +* GNU assembler 2.16 Xilinx 11.2 Build EDK_LS2.2 23 Apr 2009 + +These tools come with the Xilinx Embedded Development Kit (EDK). + +Expect +~~~~~~ + +To run the given test scenarios on Genode, you have to install the Tcl-based +testing-tool Expect, for example using 'apt-get' on Debian-based Linux +distributions: + +! sudo apt-get install expect + +Qemu +~~~~ + +To run Genode's MicroBlaze port on Qemu, the following Qemu-version is recommended: + + QEMU emulator version 0.14.50, Copyright (c) 2003-2008 Fabrice Bellard + +You can get the source code of the latest version via GIT as follows: + +! git clone git://git.qemu.org/qemu.git + +For the scenarios described in here, you have to compile qemu via: + +! configure --target-list=microblaze-softmmu +! make + +Hardware +~~~~~~~~ + +The tutorial that runs Genode on hardware uses the Xilinx Spartan 3A Starter Kit +Revision D board with the FPGA 'xc3s700a', package 'fg484' on speed grade '-4'. +It has to be connected to your machine via USB and a serial port RS-232. + +Tutorial: Build and run Genode's MicroBlaze port +================================================ + +Initially go to your Genode directory and ensure that the value of the 'QEMU' variable +within 'tool/builddir/etc/build.conf.mb-s3a_starter_kit' conforms to the path +of your 'qemu-system-microblaze' command. Now build a build directory with the +following shell commands: + +! ./tool/create_builddir mb-s3a_starter_kit \ +! BUILD_DIR=build.mb-s3a_starter_kit \ + +On Qemu +~~~~~~~ + +Change to '/build.mb-s3a_starter_kit'. In this directory, +build and run the Genode scenario 'nested_init' for Qemu as follows: + +! make run/nested_init + +This instructs the Genode build system to act according to the run-script +'/base-mb/run/nested_init.run'. This script initiates the build of +the Genode's core, the program 'init', and a configuration that describes the +scenario init start. Then it constructs a bootable image of these 3 files and +finally starts Qemu to boot the image virtually. Genode then starts 2 nested +'init' programs, each 'init' instance prints some information about its +capabilities. + + +On Hardware +~~~~~~~~~~~ + +Ensure that the Xilinx Spartan 3A Starter Kit jumpers are set as described for +the board-intern demo. Connect the board via USB to your machine and turn it +on. Wait till the LED next to the USB connector on board lights up, then list +all connected USB devices: + +! lsusb + +This should print, among others, one line like this 'Bus XXX Device XXX: ID XXXX:0008 +Xilinx, Inc.' (any X is a wildcard for a number 0-9). Now connect the Serial port that +is labeled on board with 'J27' with your computer, this allows us to track debugging +output from Genode later. Go to '/build.mb-s3a_starter_kit'. +First we have to configure the Spartan 3A with an appropriate MicroBlaze SoC as follows: + +! make -C ../base-mb/platform/mb-s3a_starter_kit + +If it has finished successfully, we can build and run the 'nested_init' scenario by +typing the following command from within the build directory: + +! RUN_OPT="--target jtag" make run/nested_init + +After this, the build chain leaves an XMD command prompt to you, which is connected +to the SoC on the FPGA via JTAG, so you can steer it as you wish. Genode isn't started +already, you can now run a program like 'gtkterm' which intercepts the serial port that +Genode will print to. The parameters of the serial port according to 'gtkterm' are: + +* Speed = 9600 +* Parity = none +* Bits = 8 +* Stopbits = 1 +* Flowcontrol = none + +To start the execution of the 'nested_init' scenario type + +! run + +to the open XMD prompt. The serial port interception should show output similar +to that of the Qemu-run. You should avoid uploading multiple times to a once +configured platform, it can lead to memory inconsistency. In contrast when +configuring the FPGA in between the RAM gets reset. + +Other scenarios +~~~~~~~~~~~~~~~ + +You can also find a simple hello-world program at 'base-mb/src/test/hello'. +An appropriate 'run' script also exists and can be build from within a build +directory via: + +! RUN_OPT="--target " make run/hello + +Hints: How to add support for other MicroBlaze-based platforms +============================================================== + +The steps described in here don't claim to be complete. They solely should +cover the basic of aspects to be considered when implementing support for new +platforms and reflect main conventions Genode's MicroBlaze port relies to. + +New MicroBlaze-based platforms have to fulfill several considerations for now +to be compliant to the Genode port. The core expects: + +* A MicroBlaze SoC with software-loaded MMU that has 64 entries, + RAM accessibility and no instruction- and data- caches +* The RAM address space to be mapped to 0x90000000 +* The CPUs IRQ controller to be an XPS interrupt controller, + mapped to 0x81800000 +* An XPS Timer mapped to 0x83c00000 with IRQ 0 +* An XPS UART Lite mapped to 0x84000000 + +Basics +~~~~~~ + +Add a file 'base-mb/mk/spec-.mk' with the content + +! SPECS += +! STARTUP_LIB ?= startup +! PRG_LIBS += $(STARTUP_LIB) + +This file contains aspects to be integrated if 'PLATFORM' occurs in the +make-variable 'SPECS' during the build process. It also can add 'SPECS' by +itself to provide further details to the build system. For example, +the word-width of the CPU like '32bit'. Any other program or library +can depend on 'PLATFORM' later by adding it to its 'SPECS'. The second and third +lines specify a library that all userland-programs on Genode use to start on +'PLATFORM'. The denoted one is the default '/base-mb/lib/mk/startup.mk' +used by the currently supported platforms. + +You can influence the build-process for 'PLATFORM' furthermore by adding additional +lines to this file, for according documentation please refer to: + + [http://genode.org/documentation/] + +FPGA Configuration and support by the tool 'run' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To automate testing via the 'run' tool, you have to create a Makefile +'/base-mb/platform//Makefile' that provides a target +'upload'. This target should upload an ELF-image, whose absolute path is +given by the make argument 'IMAGE', to the according hardware. +The above mentioned Makefile should also provide by convention a target +'configure' which prepares the according hardware for the upload of +boot images. Typically it configures the FPGA with an appropriate +SoC. Therefore, whose source should also be located within +'/base-mb/platform//'. + +Finally you have to edit '/base-mb/run/env' to hint 'run' to +your platform. Add inside the function definition 'proc hardware { } {' +an additional: + +! if { [have_spec {}] } { +! set _hardware +! return $_hardware +! } + +'run' then calls 'upload' on '/base-mb/platform//Makefile' +and gives the boot image when 'run_genode_until' is called by the according +'run'-script. But first you should create an according build directory as described +next. + +Support for the tool 'create_builddir' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Add a file 'tool/builddir/etc/build.conf.' with at least the content + +! REPOSITORIES = base-mb +! QEMU = + +Where 'QEMU' denotes your Qemu command to emulate 'PLATFORM' for Genode +Now add a make-target '::' to 'tool/create_builddir' that should +describe additional things to do for your build directory. A good point to +start is to overwrite the default specifications the build process should take +into account when selecting and build targets and libraries. + +! @echo "SPECS = genode " > $(BUILD_DIR)/etc/specs.conf + +This adds the specifics for basic Genode settings, libraries and programs as +well as to the contents of your previously created +'base-mb/mk/spec-.mk'. + diff --git a/base-mb/doc/microblaze.txt b/base-mb/doc/microblaze.txt new file mode 100644 index 000000000..9f38e7c2e --- /dev/null +++ b/base-mb/doc/microblaze.txt @@ -0,0 +1,124 @@ + + ========================================================== + Introduction into the Genode porting for Xilinx MicroBlaze + ========================================================== + + + Norman Feske + Martin Stein + +This file gives an overview to the Genode porting for MicroBlaze-based +platforms. To get a quick introduction in how to build and run Genode on +such platforms, please refer to: + +! + +Xilinx MicroBlaze is a so-called softcore CPU, which is commonly used as part +of FPGA-based System-on-Chip designs. At Genode Labs, we are regularly using +this IP core, in particular for our Genode FPGA Graphics Project, which is a +GUI software stack and a set of IP cores for implementing fully-fledged +windowed GUIs on FPGAs: + +:Website of the Genode FPGA Graphics Project: + + [http://genode-labs.com/products/fpga-graphics] + +Ever since we first released the Genode FPGA project, we envisioned to combine +it with the Genode OS Framework. In Spring 2010, Martin Stein joined our team +at Genode Labs and accepted the challenge to bring the Genode OS Framework to +the realms of FPGA-based SoCs. Technically, this implies porting the framework +to the MicroBlaze CPU architecture. In contrast to most softcore CPUs such as +the popular Lattice Mico32, the MicroBlaze features a MMU, which is a fundamental +requirement for implementing a microkernel-based system. Architecturally-wise +MicroBlaze is a RISC CPU similar to MIPS. Many system parameters of the CPU +(caches, certain arithmetic and shift instructions) can be parametrized at +synthesizing time of the SoC. We found that the relatively simple architecture +of this CPU provides a perfect playground for pursuing some of our ideas about +kernel design that go beyond the scope of current microkernels. So instead of +adding MicroBlaze support into one of the existing microkernels already +supported by Genode, we went for a new kernel design. Deviating from the typical +microkernel, which is a self-sufficient program running in kernel mode that +executes user-level processes on top, our design regards the kernel as a part of +Genode's core. It is not a separate program but a library that implements the +glue between user-level core and the raw CPU. Specifically, it provides the +entrypoint for hardware exceptions, a thread scheduler, an IPC mechanism, and +functions to manipulate virtual address spaces (loading and flushing entries +from the CPU's software-loaded TLB). It does not manage any physical memory +resources or the relationship between processes. This is the job of core. +From the kernel-developer's point of view, the kernel part can be summarized as +follows: + +* The kernel provides user-level threads that are scheduled in a round-robin + fashion. +* Threads can communicate via synchronous IPC. +* There is a mechanism for blocking and waking up threads. This mechanism + can be used by Genode to implement locking as well as asynchronous + inter-process communication. +* There is a single kernel thread, which never blocks in the kernel code paths. + So the kernel acts as a state machine. Naturally, there is no concurrency in the + execution paths traversed in kernel mode, vastly simplifying these code parts. + However, all code paths are extremely short and bounded with regard to + execution time. Hence, we expect the interference with interrupt latencies + to be low. +* The IPC operation transfers payload between UTCBs only. Each thread has a + so-called user-level thread control block which is mapped transparently by + the kernel. Because of this mapping, user-level page faults cannot occur + during IPC transfers. +* There is no mapping database. Virtual address spaces are manipulated by + loading and flushing physical TLB entries. There is no caching of mappings + done in the kernel. All higher-level information about the interrelationship + of memory and processes is managed by the user-level core. +* Core runs in user mode, mapped 1-to-1 from the physical address space + except for its virtual thread-context area. +* The kernel paths are executed in physical address space (MicroBlaze). + Because both kernel code and user-level core code are observing the same + address-space layout, both worlds appear to run within a single address + space. +* User processes can use the entire virtual address space (4G) except for a + helper page for invoking syscalls and a page containing atomic operations. + There is no reservation used for the kernel. +* The MicroBlaze architecture lacks an atomic compare-and-swap instruction. On + user-level, this functionality is emulated via delayed preemption. A kernel- + provided page holds the sequence of operations to be executed atomically and + prevents (actually delays) the preemption of a thread that is currently + executing instructions at that page. +* The MicroBlaze MMU supports several different page sizes (1K up to 16MB). + Genode fully supports this feature for page sizes >= 4K. This way, the TLB + footprint can be minimized by choosing sensible alignments of memory + objects. + +Current state +============= + +The MicroBlaze platform support resides in the 'base-mb' repository. At the +current stage, core is able to successfully start multiple nested instances of +the init process. Most of the critical kernel functionality is working. This +includes inter-process communication, address-space creation, multi-threading, +thread synchronization, page-fault handling, and TLB eviction. + +The nested init scenario runs on Qemu, emulating the Petalogix Spartan 3A +DSP1800 design, as well as on real hardware, tested with the Xilinx Spartan +3A Starter Kit configured with an appropriate Microblaze SoC. + +This simple scenario already illustrates the vast advantage of +using different page sizes supported by the MicroBlaze CPU. If using +4KB pages only, a scenario with three nested init processes produces more than +300.000 page faults. There is an extremely high pressure on the TLB, which +only contains 64 entries. Those entries are constantly evicted so that +threshing effects are likely to occur. By making use of flexible page +sizes (4K, 16K, 64K, 256K, 1M, 4M, 16M), the number of page faults gets +slashed to only 1.800, speeding up the boot time by factor 10. + +On hardware the capability remains to increase execution speed significantly +by turning on instruction- and data-caches. However this feature has not been +tested for now. + +The kernel provides, beyond the requirements of the nested init scenario, +allocation, handling and deallocation of IRQs to the userland to enable +core to offer IRQ and IO Memory session services. This allows +custom device-driver implementations within the userland. + +Currently, there is no restriction of IPC communication rights. Threads are +addressed using their global thread IDs (in fact, using their respective +indices in the KTCB array). For the future, we are planning to add +capabilty-based delegation of communication rights. diff --git a/base-mb/etc/specs.conf b/base-mb/etc/specs.conf new file mode 100755 index 000000000..a3b84ce6d --- /dev/null +++ b/base-mb/etc/specs.conf @@ -0,0 +1 @@ +SPECS ?= genode mb-s3a_starter_kit diff --git a/base-mb/etc/tools.conf b/base-mb/etc/tools.conf new file mode 100755 index 000000000..dc0d02af9 --- /dev/null +++ b/base-mb/etc/tools.conf @@ -0,0 +1,14 @@ + +# Microblaze toolchain command prefix +CROSS_DEV_PREFIX ?= mb- + +# GCC code optimization level +CC_OLEVEL = -O2 + +# Disable garbage collection of sections by LD because the MicroBlaze toolchain +# would produce corrupted code with this option enabled. +LD_OPT_GC_SECTIONS = + +# Microblaze toolchain doesn't support #pragma GCC diagnostic, +# so avoid correspondig warnings. +CC_WARN += -Wno-pragmas diff --git a/base-mb/include/base/ipc_msgbuf.h b/base-mb/include/base/ipc_msgbuf.h new file mode 100755 index 000000000..ce17cd31a --- /dev/null +++ b/base-mb/include/base/ipc_msgbuf.h @@ -0,0 +1,62 @@ +/* + * \brief Dummy IPC message buffer + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_ +#define _INCLUDE__BASE__IPC_MSGBUF_H_ + +namespace Genode { + + /** + * IPC message buffer layout + */ + class Msgbuf_base + { + protected: + + size_t _size; + char _msg_start[]; /* symbol marks start of message */ + + public: + + /* + * Begin of actual message buffer + */ + char buf[]; + + /** + * Return size of message buffer + */ + inline size_t size() const { return _size; } + + /** + * Return address of message buffer + */ + inline void *addr() { return &_msg_start[0]; } + }; + + + /** + * Instance of IPC message buffer with specified buffer size + */ + template + class Msgbuf : public Msgbuf_base + { + public: + + char buf[BUF_SIZE]; + + Msgbuf() { _size = BUF_SIZE; } + }; +} + +#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */ diff --git a/base-mb/include/base/ipc_pager.h b/base-mb/include/base/ipc_pager.h new file mode 100755 index 000000000..ebb4c6b42 --- /dev/null +++ b/base-mb/include/base/ipc_pager.h @@ -0,0 +1,207 @@ +/* + * \brief Dummy pager support for Genode + * \author Norman Feske, + * Martin Stein + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__IPC_PAGER_H_ +#define _INCLUDE__BASE__IPC_PAGER_H_ + +/* Genode includes */ +#include +#include +#include +#include + +/* Kernel includes */ +#include +#include + + +namespace Genode { + + namespace Paging { + + typedef Kernel::Paging::Resolution Native_resolution; + + /** + * Used by Genode's IPC Pager and RM Session Component + */ + class Resolution : public Native_resolution{ + + public: + + typedef Kernel::Paging::Physical_page Physical_page; + typedef Kernel::Paging::Virtual_page Virtual_page; + + private: + + enum { + INVALID_SIZE = Physical_page::INVALID_SIZE, + NO_PROTECTION_ID = 0, + DEFAULT_SIZE_LOG2 = Kernel::DEFAULT_PAGE_SIZE_LOG2, + DEFAULT_WRITEABLE = true, + DEFAULT_EXECUTABLE = true + }; + + bool _valid; + + public: + + ::Genode::Native_page_size _native_size(unsigned const size_log2) + { + using namespace Kernel; + using namespace Kernel::Paging; + + Physical_page::size_t s; + return Physical_page::size_by_size_log2(s, size_log2) ? + Physical_page::INVALID_SIZE : s; + } + + Native_page_permission _native_permission(bool const writeable, + bool const executable) + { + typedef Kernel::Paging::Physical_page Physical_page; + + if (writeable){ + if (executable) return Physical_page::RWX; + else return Physical_page::RW;} + else{ + if (executable) return Physical_page::RX; + else return Physical_page::R;} + } + + Resolution(addr_t virtual_page_address, + addr_t physical_page_address, + bool write_combined, + unsigned size_log2 = DEFAULT_SIZE_LOG2, + bool writeable = DEFAULT_WRITEABLE) + : _valid(true) + { + virtual_page = Virtual_page(virtual_page_address, + NO_PROTECTION_ID); + + physical_page = Physical_page(physical_page_address, + _native_size(size_log2), + _native_permission(writeable, + DEFAULT_EXECUTABLE)); + } + + Resolution() : _valid(false) { } + + void prepare_map_operation() { } + + inline bool valid() { return _valid; } + }; + } + + typedef Paging::Resolution Mapping; + + /** + * Special paging server class + */ + class Ipc_pager : public Native_capability + { + typedef Kernel::Paging::Request Request; + + Mapping _mapping; + Request _request; + + public: + + /** + * Constructor + */ + Ipc_pager() + : Native_capability(Genode::my_thread_id(), 0) + { + _request.source.tid = 0; + } + + /** + * Wait for a new fault received as short message IPC + */ + void wait_for_fault(); + + /** + * Reply current fault and wait for a new one + * + * Send short flex page and wait for next short-message (register) + * IPC -- pagefault + */ + void reply_and_wait_for_fault(); + + bool resolved(); + + /** + * Request instruction pointer of current fault + */ + addr_t fault_ip() { return _request.source.ip; } + + /** + * Request fault address of current page fault + */ + addr_t fault_addr() { return _request.virtual_page.address(); } + + /** + * Set parameters for next reply + */ + inline void set_reply_mapping(Mapping m) { _mapping=m; } + + /** + * Set destination for next reply + */ + inline void set_reply_dst(Native_capability pager_object) { } + + /** + * Answer call without sending a flex-page mapping + * + * This function is used to acknowledge local calls from one of + * core's region-manager sessions. + */ + inline void acknowledge_wakeup() + { + Kernel::thread_wake(_request.source.tid); + } + + /** + * Return thread ID of last faulter + */ + inline Native_thread_id last() const { return _request.source.tid; } + + /** + * Return badge for faulting thread + */ + inline unsigned long badge() const { return _request.source.tid; } + + /** + * Was last fault a write fault? + */ + bool is_write_fault() const + { + return _request.access==Kernel::Paging::Request::RW || + _request.access==Kernel::Paging::Request::RWX; + } + + /** + * Return true if last fault was an exception + */ + bool is_exception() const + { + /* + * Reflection of exceptions is not supported on this platform. + */ + return false; + } + }; +} + +#endif /* _INCLUDE__BASE__IPC_PAGER_H_ */ diff --git a/base-mb/include/base/native_types.h b/base-mb/include/base/native_types.h new file mode 100755 index 000000000..76c5a6180 --- /dev/null +++ b/base-mb/include/base/native_types.h @@ -0,0 +1,62 @@ +/* + * \brief Dummy definitions for native types used for compiling unit tests + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ +#define _INCLUDE__BASE__NATIVE_TYPES_H_ + +#include + +namespace Genode { + + typedef Kernel::Thread_id Native_thread_id; + typedef Native_thread_id Native_thread; + + typedef Kernel::Protection_id Native_process_id; + + typedef Kernel::Utcb_unaligned Native_utcb; + typedef Kernel::Paging::Physical_page::Permissions Native_page_permission; + typedef Kernel::Paging::Physical_page::size_t Native_page_size; + + Native_thread_id my_thread_id(); + + class Native_capability + { + private: + + Native_thread_id _tid; + long _local_name; + + public: + + Native_capability() : _tid(0), _local_name(0) { } + + Native_capability(Native_thread_id tid, long local_name) + : _tid(tid), _local_name(local_name) { } + + bool valid() const { return _tid!=0; } + + int local_name() const { return _local_name; } + + int dst() const { return (int)_tid; } + + Native_thread_id tid() const { return _tid; } + }; + + typedef int Native_connection_state; +} + +#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */ + + + + diff --git a/base-mb/include/cpu/atomic.h b/base-mb/include/cpu/atomic.h new file mode 100755 index 000000000..a13806546 --- /dev/null +++ b/base-mb/include/cpu/atomic.h @@ -0,0 +1,71 @@ +/* + * \brief Atomic Userland operations for Microblaze + * \author Norman Feske + * \date 2009-10-02 + */ + +/* + * Copyright (C) 2009-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__CPU__ATOMIC_H_ +#define _INCLUDE__CPU__ATOMIC_H_ + +#include + +namespace Genode { + + extern void* const _atomic_cmpxchg; + + + /** + * Executes compare and exchange as atomic operation + * + * This function compares the value at dest with cmp_val. + * If both values are equal, dest is set to new_val. If + * both values are different, the value at dest remains + * unchanged. + * + * \return 1 if the value was successfully changed to new_val, + * 0 if cmp_val and the value at dest differ. + */ + inline int cmpxchg(volatile int *dest, + unsigned int cmp_val, + unsigned int new_val) + { + int result = 0; + unsigned int r15_buf = 0; + + /** + * r27-r30 are arguments/return-values + * for _atomic_cmpxchg in r31 kernel denotes if + * interrupt has occured while executing atomic code + */ + asm volatile ("lwi r30, %[dest] \n" + "lwi r29, %[cmp_val] \n" + "lwi r28, %[new_val] \n" + "lwi r27, %[dest_val] \n" + "or r31, r0, r0 \n" + "swi r15, %[r15_buf] \n" + "bralid r15, _atomic_cmpxchg \n" + "or r0, r0, r0 \n" + "lwi r15, %[r15_buf] \n" + "swi r28, %[result] " + : + [result] "=m" (result), + [r15_buf] "+m" (r15_buf), + [dest] "+m" (dest), + [cmp_val] "+m" (cmp_val), + [new_val] "+m" (new_val), + [dest_val] "+m" (*dest) + :: "r31", "r30", "r29", "r28", "r27", "memory"); + + return result; + } +} + + +#endif /* _INCLUDE__CPU__ATOMIC_H_ */ diff --git a/base-mb/include/cpu/config.h b/base-mb/include/cpu/config.h new file mode 100755 index 000000000..13c8cb7bd --- /dev/null +++ b/base-mb/include/cpu/config.h @@ -0,0 +1,116 @@ +/* + * \brief Configuration of underlying hardware + * \author Martin stein + * \date 07-05-2010 + */ + +/* + * Copyright (C) 07-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__CPU__CONFIG_H_ +#define _INCLUDE__CPU__CONFIG_H_ + +#define ALWAYS_INLINE __attribute__((always_inline)) + +#define BITFIELD_ENUMS(name, bit_significancy_offset, bit_width) \ + name ## _LSH = bit_significancy_offset, \ + name ## _WID = bit_width, \ + name ## _MSK = ~((~0) << bit_width) << bit_significancy_offset, + +namespace Cpu { + + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; + + typedef uint8_t byte_t; + typedef uint32_t word_t; + + typedef unsigned long addr_t; + typedef __SIZE_TYPE__ size_t; + + enum { + BYTE_WIDTH_LOG2 = 3, + WORD_WIDTH_LOG2 = 5, + BYTE_WIDTH = 1 << BYTE_WIDTH_LOG2, + WORD_WIDTH = 1 << WORD_WIDTH_LOG2, + BYTE_SIZE = sizeof(byte_t), + WORD_SIZE = sizeof(word_t), + + _16B_SIZE_LOG2 = 1*WORD_SIZE, + _256B_SIZE_LOG2 = 2*WORD_SIZE, + _4KB_SIZE_LOG2 = 3*WORD_SIZE, + _64KB_SIZE_LOG2 = 4*WORD_SIZE, + _1MB_SIZE_LOG2 = 5*WORD_SIZE, + _16MB_SIZE_LOG2 = 6*WORD_SIZE, + _256MB_SIZE_LOG2 = 7*WORD_SIZE, + + _16B_SIZE = 1 << _16B_SIZE_LOG2, + _256B_SIZE = 1 << _256B_SIZE_LOG2, + _4KB_SIZE = 1 << _4KB_SIZE_LOG2, + _64KB_SIZE = 1 << _64KB_SIZE_LOG2, + _1MB_SIZE = 1 << _1MB_SIZE_LOG2, + _16MB_SIZE = 1 << _16MB_SIZE_LOG2, + _256MB_SIZE = 1 << _256MB_SIZE_LOG2, + }; + + enum { + RAM_BASE = 0x90000000, + RAM_SIZE = 0x06000000, + + XPS_INTC_BASE = 0x81800000, + + XPS_TIMER_0_BASE = 0x83c00000, + XPS_TIMER_0_IRQ = 0, + + XPS_ETHERNETLITE_BASE = 0x81000000, + XPS_ETHERNETLITE_IRQ = 1, + + XPS_UARTLITE_BASE = 0x84000000, + XPS_UARTLITE_IRQ = 3, + + XPS_TIMER_1_BASE = 0x70000000, + XPS_TIMER_1_IRQ = 4, + }; + + typedef uint8_t Irq_id; + typedef uint8_t Exception_id; + + enum { + FAST_SIMPLEX_LINK = 0, + UNALIGNED = 1, + ILLEGAL_OPCODE = 2, + INSTRUCTION_BUS = 3, + DATA_BUS = 4, + DIV_BY_ZERO_EXCEPTON = 5, + FPU = 6, + PRIVILEGED_INSTRUCTION = 7, + + INTERRUPT = 10, + EXTERNAL_NON_MASKABLE_BREAK = 11, + EXTERNAL_MASKABLE_BREAK = 12, + + DATA_STORAGE = 16, + INSTRUCTION_STORAGE = 17, + DATA_TLB_MISS = 18, + INSTRUCTION_TLB_MISS = 19, + + MIN_EXCEPTION_ID = 0, + MAX_EXCEPTION_ID = 19, + + INVALID_EXCEPTION_ID = 20 + }; + + enum { + MIN_IRQ_ID = 0, + MAX_IRQ_ID = 31, + + INVALID_IRQ_ID = 32, + }; +} + +#endif /* _INCLUDE__CPU__CONFIG_H_ */ diff --git a/base-mb/include/kernel/config.h b/base-mb/include/kernel/config.h new file mode 100755 index 000000000..25f04b243 --- /dev/null +++ b/base-mb/include/kernel/config.h @@ -0,0 +1,79 @@ +/* + * \brief Configuration of kernel features + * \author Martin stein + * \date 24-06-2010 + */ + +/* + * Copyright (C) 24-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__KERNEL__CONFIG_H_ +#define _INCLUDE__KERNEL__CONFIG_H_ + +#include + +namespace Kernel +{ + enum { + SCHEDULING_MS_INTERVAL = 10, + SCHEDULING_TIMER_BASE = Cpu::XPS_TIMER_0_BASE, + SCHEDULING_TIMER_IRQ = Cpu::XPS_TIMER_0_IRQ, + + DEFAULT_PAGE_SIZE_LOG2 = Cpu::_4KB_SIZE_LOG2, + }; + + typedef Cpu::uint8_t Thread_id; + typedef Cpu::uint8_t Protection_id; + + enum{ + MIN_THREAD_ID = 1, + MAX_THREAD_ID = 64, + + MIN_PROTECTION_ID = 1, + MAX_PROTECTION_ID = 64, + + INVALID_THREAD_ID = 0, + INVALID_PROTECTION_ID = 0 }; +} + +namespace Roottask +{ + enum { + MAIN_STACK_SIZE = 1024*1024*Cpu::WORD_SIZE, + MAIN_THREAD_ID = 2, + + PROTECTION_ID = 1, + }; +} + +namespace User +{ + enum { + UART_BASE = Cpu::XPS_UARTLITE_BASE, + UART_IRQ = Cpu::XPS_UARTLITE_IRQ, + + IO_MEM_BASE = 0x70000000, + IO_MEM_SIZE = 0x10000000, + + XPS_TIMER_0_BASE = 0x70000000, + XPS_TIMER_0_IRQ = 4, + + MIN_IRQ = 4, + MAX_IRQ = 31, + + MIN_PROTECTION_ID = Roottask::PROTECTION_ID+1, + MAX_PROTECTION_ID = Kernel::MAX_PROTECTION_ID, + + MIN_THREAD_ID = Roottask::MAIN_THREAD_ID+1, + MAX_THREAD_ID = Kernel::MAX_THREAD_ID, + + VADDR_BASE = 0 + 1*(1< +#include + +/** + * Inline assembly clobber lists for syscalls with no arguments + */ +#define SYSCALL_7_ASM_CLOBBER "r24", SYSCALL_6_ASM_CLOBBER +#define SYSCALL_6_ASM_CLOBBER "r25", SYSCALL_5_ASM_CLOBBER +#define SYSCALL_5_ASM_CLOBBER "r26", SYSCALL_4_ASM_CLOBBER +#define SYSCALL_4_ASM_CLOBBER "r27", SYSCALL_3_ASM_CLOBBER +#define SYSCALL_3_ASM_CLOBBER "r28", SYSCALL_2_ASM_CLOBBER +#define SYSCALL_2_ASM_CLOBBER "r29", SYSCALL_1_ASM_CLOBBER +#define SYSCALL_1_ASM_CLOBBER SYSCALL_0_ASM_CLOBBER +#define SYSCALL_0_ASM_CLOBBER "r31", "r30" + +/** + * Inline assembly list for write access during syscalls with no arguments + */ +#define SYSCALL_0_ASM_WRITE \ + [result] "=m" (result), \ + [r15_buf] "+m" (r15_buf), \ + [opcode] "+m" (opcode) + + +/** + * Inline assembly lists for write access during syscalls with arguments + */ +#define SYSCALL_1_ASM_WRITE [arg_0] "+m" (arg_0), SYSCALL_0_ASM_WRITE +#define SYSCALL_2_ASM_WRITE [arg_1] "+m" (arg_1), SYSCALL_1_ASM_WRITE +#define SYSCALL_3_ASM_WRITE [arg_2] "+m" (arg_2), SYSCALL_2_ASM_WRITE +#define SYSCALL_4_ASM_WRITE [arg_3] "+m" (arg_3), SYSCALL_3_ASM_WRITE +#define SYSCALL_5_ASM_WRITE [arg_4] "+m" (arg_4), SYSCALL_4_ASM_WRITE +#define SYSCALL_6_ASM_WRITE [arg_5] "+m" (arg_5), SYSCALL_5_ASM_WRITE +#define SYSCALL_7_ASM_WRITE [arg_6] "+m" (arg_6), SYSCALL_6_ASM_WRITE + +/** + * Inline assembly ops for syscalls with no arguments + * - r19-r31 are save when occuring in the clobber list + * r15 is a 'dedicated' register and so we have to save it manually + */ +#define SYSCALL_0_ASM_OPS \ + "lwi r31, %[opcode] \n" \ + "swi r15, %[r15_buf] \n" \ + "brki r15, 0x8 \n" \ + "or r0, r0, r0 \n" \ + "lwi r15, %[r15_buf] \n" \ + "swi r30, %[result] " + +/** + * Inline assembly ops for syscalls with arguments + */ +#define SYSCALL_1_ASM_OPS "lwi r30, %[arg_0]\n" SYSCALL_0_ASM_OPS +#define SYSCALL_2_ASM_OPS "lwi r29, %[arg_1]\n" SYSCALL_1_ASM_OPS +#define SYSCALL_3_ASM_OPS "lwi r28, %[arg_2]\n" SYSCALL_2_ASM_OPS +#define SYSCALL_4_ASM_OPS "lwi r27, %[arg_3]\n" SYSCALL_3_ASM_OPS +#define SYSCALL_5_ASM_OPS "lwi r26, %[arg_4]\n" SYSCALL_4_ASM_OPS +#define SYSCALL_6_ASM_OPS "lwi r25, %[arg_5]\n" SYSCALL_5_ASM_OPS +#define SYSCALL_7_ASM_OPS "lwi r24, %[arg_6]\n" SYSCALL_6_ASM_OPS + +/** + * Inline assembly lists for read access during syscalls with arguments + */ +#define SYSCALL_0_ASM_READ +#define SYSCALL_1_ASM_READ SYSCALL_0_ASM_READ +#define SYSCALL_2_ASM_READ SYSCALL_1_ASM_READ +#define SYSCALL_3_ASM_READ SYSCALL_2_ASM_READ +#define SYSCALL_4_ASM_READ SYSCALL_3_ASM_READ +#define SYSCALL_5_ASM_READ SYSCALL_4_ASM_READ +#define SYSCALL_6_ASM_READ SYSCALL_5_ASM_READ +#define SYSCALL_7_ASM_READ SYSCALL_6_ASM_READ + + +namespace Kernel { + + using namespace Cpu; + + typedef unsigned int Syscall_arg; + + /** + * Syscall with 1 Argument + */ + ALWAYS_INLINE inline int syscall(Syscall_id opcode); + + + /** + * Syscall with 2 Arguments + */ + ALWAYS_INLINE inline int syscall(Syscall_id opcode, + Syscall_arg arg_0); + + /** + * Syscall with 3 Arguments + */ + ALWAYS_INLINE inline int syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1); + + /** + * Syscall with 4 Arguments + */ + ALWAYS_INLINE inline int syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2); + + /** + * Syscall with 5 Arguments + */ + ALWAYS_INLINE inline int syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2, + Syscall_arg arg_3); + + /** + * Syscall with 6 Arguments + */ + ALWAYS_INLINE inline int syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2, + Syscall_arg arg_3, + Syscall_arg arg_4); + + /** + * Syscall with 7 Arguments + */ + ALWAYS_INLINE inline int syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2, + Syscall_arg arg_3, + Syscall_arg arg_4, + Syscall_arg arg_5); + + /** + * Syscall with 8 Arguments + */ + ALWAYS_INLINE inline int syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2, + Syscall_arg arg_3, + Syscall_arg arg_4, + Syscall_arg arg_5, + Syscall_arg arg_6); + + /** + * Yield thread execution and coninue with next + */ + inline void thread_yield(); + + /** + * Block thread that calls this + */ + inline void thread_sleep(); + + /** + * Create and start threads + * + * \param tid ident that thread should get + * \param pid threads protection domain + * \param pager_id threads page fault handler thread + * \param utcb_p virtual address of utcb + * \param vip initial virtual ip + * \param vsp initial virtual sp + * \param param scheduling parameters, not used by now + * \return 0 if new thread was created + * n > 0 if any error has occured (errorcodes planned) + */ + inline int thread_create(Thread_id tid, + Protection_id pid, + Thread_id pager_tid, + Utcb* utcb_p, + Cpu::addr_t vip, + Cpu::addr_t vsp, + unsigned int params); + + /** + * Kill thread - only with root rights + * + * \param tid ident of thread + * \return 0 if thread is awake after syscall + * n > 0 if any error has occured (errorcodes planned) + */ + inline int thread_kill(Thread_id tid); + + /** + * Unblock denoted thread + * + * \param tid ident of thread thats blocked + * \detail works only if destination has same protection + * domain or caller has rootrights + * \return 0 if thread is awake after syscall + * n > 0 if any error has occured (errorcodes planned) + */ + inline int thread_wake(Thread_id tid); + + /** + * Re-set pager of another thread + * + * \param dst_tid thread whose pager shall be changed + * \param pager_tid ident of pager thread + * \detail works only if caller has rootrights + * \return 0 if new pager of thread is successfully set + * n > 0 if any error has occured (errorcodes planned) + */ + inline int thread_pager(Thread_id dst_tid, + Thread_id pager_tid); + + /** + * Reply last and wait for new ipc request + * + * \param msg_length length of reply message + * \return length of received message + */ + inline int ipc_serve(unsigned int reply_size); + + /** + * Send ipc request denoted in utcb to specific thread + * + * \param dest_id ident of destination thread + * \param msg_length number of request-message words + * \return number of reply-message words, or + * zero if request was not successfull + */ + inline int ipc_request(Thread_id dest_tid, unsigned int msg_size); + + /** + * Load pageresolution to memory managment unit + * + * \param p_addr physical page address + * \param v_addr virtual page address + * \param pid protection domain ident + * \param size size of page + * \param permissions permission flags for page + * \return 0 if thread is awake after syscall + * n > 0 if any error has occured (errorcodes planned) + */ + inline int tlb_load(Cpu::addr_t p_address, + Cpu::addr_t v_address, + Protection_id pid, + Paging::Physical_page::size_t size, + Paging::Physical_page::Permissions permissions); + + /** + * Flush page resolution area from tlb + * + * \param pid protection domain id + * \param start startaddress of area + * \param size_kbyte size of area in 1KB units + * \return 0 if new thread was created + * n > 0 if any error has occured (errorcodes planned) + */ + inline int tlb_flush(Protection_id pid, + Cpu::addr_t start, + unsigned size); + + /** + * Print char to serial ouput + * + * \param c char to print + */ + inline void print_char(char c); + + /** + * Print various informations about a specific thread + * \param i Unique ID of the thread, if it remains 0 take our own ID + */ + inline void print_info(Thread_id const & i = 0); + + /** + * Allocate an IRQ to the calling thread if the IRQ is + * not allocated yet to another thread + * + * \param i Unique ID of the IRQ + * \return 0 If the IRQ is allocated to this thread now + * n != 0 If the IRQ is not allocated to this thread already + * (code of the error that has occured) + */ + inline int irq_allocate(Irq_id i); + + /** + * Free an IRQ from allocation if it is allocated by the + * calling thread + * + * \param i Unique ID of the IRQ + * \return 0 If the IRQ is free now + * n != 0 If the IRQ is allocated already + * (code of the error that has occured) + */ + inline int irq_free(Irq_id i); + + /** + * Sleep till the 'Irq_message'-queue of this thread is not + * empty. For any IRQ that is allocated by this thread and occures + * between the kernel-entrance inside 'irq_wait' and the next time this + * thread wakes up, an 'Irq_message' with metadata about the according + * IRQ is added to the threads 'Irq_message'-queue. + * When returning from 'irq_wait' the first message from the threads + * 'Irq_message'-queue is dequeued and written to the threads UTCB-base. + */ + inline void irq_wait(); +} + + +void Kernel::print_info(Thread_id const & i) +{ + syscall(PRINT_INFO, (Syscall_arg) i); +} + + +void Kernel::irq_wait() { syscall(IRQ_WAIT); } + + +int Kernel::irq_allocate(Irq_id i) +{ + return syscall(IRQ_ALLOCATE, (Syscall_arg) i); +} + + +int Kernel::irq_free(Irq_id i) { return syscall(IRQ_FREE, (Syscall_arg) i); } + + +void Kernel::thread_yield() { syscall(THREAD_YIELD); } + + +void Kernel::thread_sleep() { syscall(THREAD_SLEEP); } + + +int Kernel::thread_create(Thread_id tid, + Protection_id pid, + Thread_id pager_tid, + Utcb* utcb_p, + Cpu::addr_t vip, + Cpu::addr_t vsp, + unsigned int params) +{ + return syscall(THREAD_CREATE, + (Syscall_arg) tid, + (Syscall_arg) pid, + (Syscall_arg) pager_tid, + (Syscall_arg) utcb_p, + (Syscall_arg) vip, + (Syscall_arg) vsp, + (Syscall_arg) params); +} + + +int Kernel::thread_kill(Thread_id tid) +{ + return syscall(THREAD_KILL, (Syscall_arg) tid); +} + + +int Kernel::thread_wake(Thread_id tid) +{ + return syscall(THREAD_WAKE, (Syscall_arg) tid); +} + + +int Kernel::thread_pager(Thread_id dst_tid, + Thread_id pager_tid) +{ + return syscall( + THREAD_PAGER, + (Syscall_arg) dst_tid, + (Syscall_arg) pager_tid); +} + + +int Kernel::ipc_serve(unsigned int reply_size) +{ + return syscall(IPC_SERVE, (Syscall_arg) reply_size); +} + + +int Kernel::ipc_request(Thread_id dest_tid, + unsigned int msg_size) +{ + return syscall( + IPC_REQUEST, + (Syscall_arg) dest_tid, + (Syscall_arg) msg_size); +} + + +int Kernel::tlb_load(Cpu::addr_t p_address, + Cpu::addr_t v_address, + Protection_id pid, + Paging::Physical_page::size_t size, + Paging::Physical_page::Permissions permissions) +{ + return syscall( + TLB_LOAD, + (Syscall_arg) p_address, + (Syscall_arg) v_address, + (Syscall_arg) pid, + (Syscall_arg) size, + (Syscall_arg) permissions); +} + + +int Kernel::tlb_flush(Protection_id pid, + Cpu::addr_t start, + unsigned size) +{ + return syscall( + TLB_FLUSH, + (Syscall_arg) pid, + (Syscall_arg) start, + (Syscall_arg) size); +} + + +void Kernel::print_char(char c) { syscall(PRINT_CHAR, (Syscall_arg) c); } + + +int Kernel::syscall(Syscall_id opcode) +{ + int result; + unsigned int r15_buf; + + asm volatile(SYSCALL_0_ASM_OPS + : SYSCALL_0_ASM_WRITE + : SYSCALL_0_ASM_READ + : SYSCALL_0_ASM_CLOBBER); + + return result; +} + + +int Kernel::syscall(Syscall_id opcode, Syscall_arg arg_0) +{ + int result; + unsigned int r15_buf; + + asm volatile(SYSCALL_1_ASM_OPS + : SYSCALL_1_ASM_WRITE + : SYSCALL_1_ASM_READ + : SYSCALL_1_ASM_CLOBBER); + + return result; +} + + +int Kernel::syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1) +{ + int result; + unsigned int r15_buf; + + asm volatile(SYSCALL_2_ASM_OPS + : SYSCALL_2_ASM_WRITE + : SYSCALL_2_ASM_READ + : SYSCALL_2_ASM_CLOBBER); + + return result; +} + + +int Kernel::syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2) +{ + int result; + unsigned int r15_buf; + + asm volatile(SYSCALL_3_ASM_OPS + : SYSCALL_3_ASM_WRITE + : SYSCALL_3_ASM_READ + : SYSCALL_3_ASM_CLOBBER); + + return result; +} + + +int Kernel::syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2, + Syscall_arg arg_3) +{ + int result; + unsigned int r15_buf; + + asm volatile(SYSCALL_4_ASM_OPS + : SYSCALL_4_ASM_WRITE + : SYSCALL_4_ASM_READ + : SYSCALL_4_ASM_CLOBBER); + + return result; +} + + +int Kernel::syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2, + Syscall_arg arg_3, + Syscall_arg arg_4) +{ + int result; + unsigned int r15_buf; + + asm volatile(SYSCALL_5_ASM_OPS + : SYSCALL_5_ASM_WRITE + : SYSCALL_5_ASM_READ + : SYSCALL_5_ASM_CLOBBER); + + return result; +} + + +int Kernel::syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2, + Syscall_arg arg_3, + Syscall_arg arg_4, + Syscall_arg arg_5) +{ + int result; + unsigned int r15_buf; + + asm volatile(SYSCALL_6_ASM_OPS + : SYSCALL_6_ASM_WRITE + : SYSCALL_6_ASM_READ + : SYSCALL_6_ASM_CLOBBER); + + return result; +} + + +int Kernel::syscall(Syscall_id opcode, + Syscall_arg arg_0, + Syscall_arg arg_1, + Syscall_arg arg_2, + Syscall_arg arg_3, + Syscall_arg arg_4, + Syscall_arg arg_5, + Syscall_arg arg_6) +{ + int result; + unsigned int r15_buf; + + asm volatile(SYSCALL_7_ASM_OPS + : SYSCALL_7_ASM_WRITE + : SYSCALL_7_ASM_READ + : SYSCALL_7_ASM_CLOBBER); + + return result; +} + + +#endif /* _INCLUDE__KERNEL__SYSCALLS_H_ */ diff --git a/base-mb/include/kernel/types.h b/base-mb/include/kernel/types.h new file mode 100755 index 000000000..1dfaca10a --- /dev/null +++ b/base-mb/include/kernel/types.h @@ -0,0 +1,329 @@ +/* + * \brief Kernel specific data types + * \author Martin stein + * \date 2010-10-01 + */ + +/* + * Copyright (C) 2010-2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__KERNEL__TYPES_H_ +#define _INCLUDE__KERNEL__TYPES_H_ + +#include +#include +#include + +namespace Kernel { + + using namespace Cpu; + + enum {THREAD_CREATE_PARAMS_ROOTRIGHT_LSHIFT=0}; + + + struct Utcb_unaligned + { + enum { + ALIGNMENT_LOG2 = 0, + SIZE_LOG2 = Cpu::_4KB_SIZE_LOG2, + }; + + union + { + volatile Cpu::byte_t byte[1<= sizeof(size_by_size_log2) / sizeof(size_by_size_log2[0])) + return -2; + + if (size_by_size_log2[size_log2] == INVALID_SIZE) + return -3; + + s = size_by_size_log2[(unsigned)size_log2]; + return 0; +} + + +Cpu::size_t Kernel::Utcb_unaligned::size() +{ + return (Cpu::size_t)1< + +namespace Xilinx { + + /** + * Driver for the Xilinx LogiCORE IP XPS Interrupt Controller 2.01 + */ + class Xps_intc + { + public: + + typedef Cpu::uint32_t Register; + typedef Cpu::uint8_t Irq; + + enum { + REGISTER_WIDTH = sizeof(Register)*Cpu::BYTE_WIDTH, + MIN_IRQ = Cpu::MIN_IRQ_ID, + MAX_IRQ = Cpu::MAX_IRQ_ID, + INVALID_IRQ = Cpu::INVALID_IRQ_ID, + }; + + /** + * Constructor argument + */ + struct Constr_arg + { + Cpu::addr_t base; + + Constr_arg(Cpu::addr_t const & b) : base(b) { } + }; + + /** + * Probe if IRQ ID is valid at this controller + */ + inline bool valid(Irq const & i); + + /** + * Enable propagation of all IRQ inputs + */ + inline void unmask(); + + /** + * Enable propagation of all IRQ inputs + */ + inline void unmask(Irq const & i); + + /** + * Disable propagation of all IRQ inputs + * (anyhow the occurency of IRQ's gets noticed in ISR) + */ + inline void mask(); + + /** + * Disable propagation of an IRQ input + * (anyhow the occurency of the IRQ's gets noticed in ISR) + */ + inline void mask(Irq const & i); + + /** + * Constructor + * All IRQ's are masked initially + */ + inline Xps_intc(Constr_arg const & ca); + + /** + * Destructor + * All IRQ's are left masked + */ + inline ~Xps_intc(); + + /** + * Get the pending IRQ with + * the highest priority (that one with the lowest IRQ ID) + */ + inline Irq next_irq(); + + /** + * Release IRQ input so it can occure again + * (in general IRQ source gets acknowledged thereby) + */ + inline void release(Irq const & i); + + /** + * Probe if IRQ is pending (unmasked and active) + */ + inline bool pending(Irq const & i); + + private: + + /** + * Register mapping offsets relative to the device base address + */ + enum { + RISR_OFFSET = 0 * Cpu::WORD_SIZE, + RIPR_OFFSET = 1 * Cpu::WORD_SIZE, + RIER_OFFSET = 2 * Cpu::WORD_SIZE, + RIAR_OFFSET = 3 * Cpu::WORD_SIZE, + RSIE_OFFSET = 4 * Cpu::WORD_SIZE, + RCIE_OFFSET = 5 * Cpu::WORD_SIZE, + RIVR_OFFSET = 6 * Cpu::WORD_SIZE, + RMER_OFFSET = 7 * Cpu::WORD_SIZE, + RMAX_OFFSET = 8 * Cpu::WORD_SIZE, + + RMER_ME_LSHIFT = 0, + RMER_HIE_LSHIFT = 1 + }; + + /** + * Short register description (no optional registers) + * + * ISR IRQ status register, a bit in here is '1' as long as the + * according IRQ-input is '1', IRQ/bit correlation: [MAX_IRQ,...,1,0] + * IER IRQ unmask register, as long as a bit is '1' in IER the controller + * output equals the according bit in ISR as long as MER[ME] is '1' + * IAR IRQ acknowledge register, writing a '1' to a bit in IAR writes + * '0' to the according bit in ISR and '0' to bit in IAR + * SIE Set IRQ unmask register, writing a '1' to a bit in SIE sets the + * according bit in IER to '1' and writes '0' to the bit in SIE + * CIE Clear IRQ unmask register, writing a '1' to a bit in SIE sets the + * according bit in IER to '0' and writes '0' to the bit in CIE + * MER Master unmask register, structure: [0,...,0,HIE,ME], controller + * output is '0' as long as ME is '0', HIE is '0' initally so + * software IRQ mode is active writing '1' to HIE switches to + * hardware IRQ mode and masks writing to HIE + */ + volatile Register* const _risr; + volatile Register* const _rier; + volatile Register* const _riar; + volatile Register* const _rsie; + volatile Register* const _rcie; + volatile Register* const _rmer; + }; +} + + +void Xilinx::Xps_intc::unmask() { *_rsie = ~0; } + + +void Xilinx::Xps_intc::unmask(Irq const & i) +{ + if (!valid(i)) { return; } + *_rsie = 1 << i; +} + + +void Xilinx::Xps_intc::mask() { *_rcie = ~0; } + + +void Xilinx::Xps_intc::mask(Irq const & i) +{ + if (!valid(i)) { return; } + *_rcie = 1 << i; +} + + +bool Xilinx::Xps_intc::pending(Irq const & i) +{ + if (!valid(i)) { return false; } + Register const pending = *_risr & *_rier; + return pending & (1 << i); +} + + +bool Xilinx::Xps_intc::valid(Irq const & i) +{ + return !(i == INVALID_IRQ || i > MAX_IRQ); +} + + +Xilinx::Xps_intc::Xps_intc(Constr_arg const & ca) : + _risr((Register*)(ca.base + RISR_OFFSET)), + _rier((Register*)(ca.base + RIER_OFFSET)), + _riar((Register*)(ca.base + RIAR_OFFSET)), + _rsie((Register*)(ca.base + RSIE_OFFSET)), + _rcie((Register*)(ca.base + RCIE_OFFSET)), + _rmer((Register*)(ca.base + RMER_OFFSET)) +{ + *_rmer = 1 << RMER_HIE_LSHIFT | 1 << RMER_ME_LSHIFT; + mask(); +} + + +Xilinx::Xps_intc::~Xps_intc() +{ + mask(); +} + + +Xilinx::Xps_intc::Irq Xilinx::Xps_intc::next_irq() +{ + Register const pending = *_risr & *_rier; + Register bit_mask = 1; + + for (unsigned int i=0; i + +namespace Xilinx { + + /** + * Driver for the Xilinx LogiCORE XPS Timer/Counter IP 1.02 + */ + class Xps_timer + { + public: + + /** + * CPU dependencies + */ + typedef Cpu::word_t word_t; + typedef Cpu::addr_t addr_t; + typedef Cpu::size_t size_t; + typedef Cpu::uint32_t uint32_t; + + /** + * MMIO register + */ + typedef uint32_t Register; + + /** + * Constructor, resets timer, overwrites timer value with '0' + */ + inline Xps_timer(addr_t const &base); + + /** + * Destructor, resets timer, overwrites timer value with '0' + */ + inline ~Xps_timer(); + + /** + * Overwrite timer value with X>0, count downwards to '0', set the + * IRQ output to '1' for one cycle and simultaneously start counting + * downwards again from X, and so on ... + * + * \param value the value X + */ + inline void run_periodic(unsigned int const &value); + + /** + * Overwrite timer value with X>0, count downwards to '0', set the + * IRQ output to '1' for one cycle and simultaneously start counting + * downwards from max_value() to '0', and so on ... + * + * \param value the value X + */ + inline void run_circulating(unsigned int const &value); + + /** + * Overwrite timer value with X>0, count downwards to '0', set the + * IRQ output to '1' for one cycle, timer value remains '0' + * + * \param value the value X + */ + inline void run_oneshot(unsigned int const &value); + + /** + * Prepare a 'run_oneshot()'-like run that shall be triggered with + * simple means. Useful for starting the timer out of assembly-code. + * + * \param value native time-value used to assess the delay + * of the timer IRQ as of the triggering + * \param start_val at this address the start value gets deposited + * \param start_reg at this address an address X gets deposited + * writing the start value to X later starts the + * timer as prepared + */ + inline void prepare_oneshot(unsigned int const & value, + volatile Register * & start_reg, + Register & start_val); + + /** + * Current timer value + */ + inline unsigned int value(); + + /** + * Return the timers current value and determine if the timer has hit '0' + * before the returned value and after the last time we started it or called + * 'period_value' on it. Called during non-periodic runs 'rolled_over' + * becomes 'true' if value is '0' and 'false' otherwise + * + * Enable exclusive access only to this function to ensure correct behavior! + * This function delays the timer about the duration of a few cpu cycles! + */ + inline unsigned int period_value(bool * const & rolled_over); + + /** + * Size of the MMIO provided by the timer device + */ + static inline size_t size(); + + /** + * Maximum timer value + */ + static inline unsigned int max_value(); + + /** + * Converting a native time value to milliseconds + */ + static inline unsigned int native_to_msec(unsigned int const &v); + + /** + * Converting milliseconds to a native time value + */ + static inline unsigned int msec_to_native(unsigned int const &v); + + /** + * Converting a native time value to microseconds + */ + static inline unsigned int native_to_usec(unsigned int const &v); + + /** + * Converting microseconds to a native time value + */ + static inline unsigned int usec_to_native(unsigned int const &v); + + private: + + /** + * General constraints + */ + enum { + WORD_SIZE = sizeof(word_t), + BYTE_WIDTH = Cpu::BYTE_WIDTH, + FREQUENCY_PER_US = 62, + }; + + /** + * Registers + */ + enum { + /* Control/status register */ + RTCSR0_OFFSET = 0*WORD_SIZE, + + /* Load register, written to RTCR when RTCSR[LOAD]='1' */ + RTLR0_OFFSET = 1*WORD_SIZE, + + /* On timer/counter register the counting is done */ + RTCR0_OFFSET = 2*WORD_SIZE, + + /* Respectively for the second timer/counter module */ + RTCSR1_OFFSET = 4*WORD_SIZE, + RTLR1_OFFSET = 5*WORD_SIZE, + RTCR1_OFFSET = 6*WORD_SIZE, + + MMIO_SIZE = 8*WORD_SIZE, + + /* r/w '0': generate timer mode + * r/w '1': capture timer mode */ + RTCSR_MDT_LSHIFT = 0, + + /* r/w '0': count upward mode + * r/w '1': count downward mode */ + RTCSR_UDT_LSHIFT = 1, + + /* r/w '0': external generate signal disabled mode + * r/w '1': external generate signal enabled mode */ + RTCSR_GENT_LSHIFT = 2, + + /* r/w '0': external capture trigger disabled mode + * r/w '1': external capture trigger enabled mode */ + RTCSR_CAPT_LSHIFT = 3, + + /* r/w '0': hold values mode + * r/w '0': auto reload (generate timer) / overwrite (capture timer) mode */ + RTCSR_ARHT_LSHIFT = 4, + + /* w/r '0': disable loading mode + * w/r '1': loading timer mode (RTCR=RTLR) */ + RTCSR_LOAD_LSHIFT = 5, + + /* w/r '0': throw no IRQ mode (doesn't affect RTCSR[TINT]) + * w/r '1': throw IRQ on 0-1-edge at RTCSR[TINT] mode */ + RTCSR_ENIT_LSHIFT = 6, + + /* w/r '0': don't count (RTCR remains constant) + * w/r '1': count on RTCR */ + RTCSR_ENT_LSHIFT = 7, + + /* r '0': no IRQ has occured + * r '1': IRQ has occured + * w '0': no effect + * w '1': RTCSR[TINT]=0 */ + RTCSR_TINT_LSHIFT = 8, + + /* r/w '0': pulse width modulation disabled mode + * r/w '1': pulse width modulation enabled mode */ + RTCSR_PWM_LSHIFT = 9, + + /* w/r '0': nothing + * w/r '1': RTCSR[ENT]='1' for all timer/counter modules */ + RTCSR_ENALL_LSHIFT = 10, + }; + + /** + * Controls for RTCSR + */ + enum { + RUN_ONCE = 0 + | 0 << RTCSR_MDT_LSHIFT + | 1 << RTCSR_UDT_LSHIFT + | 0 << RTCSR_CAPT_LSHIFT + | 0 << RTCSR_GENT_LSHIFT + | 0 << RTCSR_ARHT_LSHIFT + | 0 << RTCSR_LOAD_LSHIFT + | 1 << RTCSR_ENIT_LSHIFT + | 1 << RTCSR_ENT_LSHIFT + | 1 << RTCSR_TINT_LSHIFT + | 0 << RTCSR_PWM_LSHIFT + | 0 << RTCSR_ENALL_LSHIFT + , + + STOP_N_LOAD = 0 + | 0 << RTCSR_MDT_LSHIFT + | 1 << RTCSR_UDT_LSHIFT + | 0 << RTCSR_CAPT_LSHIFT + | 0 << RTCSR_GENT_LSHIFT + | 0 << RTCSR_ARHT_LSHIFT + | 1 << RTCSR_LOAD_LSHIFT + | 0 << RTCSR_ENIT_LSHIFT + | 0 << RTCSR_ENT_LSHIFT + | 0 << RTCSR_TINT_LSHIFT + | 0 << RTCSR_PWM_LSHIFT + | 0 << RTCSR_ENALL_LSHIFT + , + + RUN_PERIODIC = RUN_ONCE + | 1 << RTCSR_ARHT_LSHIFT + , + + STOP_N_RESET = STOP_N_LOAD + | 1 << RTCSR_TINT_LSHIFT + , + }; + + /** + * Absolute register addresses + */ + volatile Register *const _rtcsr0; + volatile Register *const _rtlr0; + volatile Register *const _rtcr0; + volatile Register *const _rtcsr1; + volatile Register *const _rtlr1; + volatile Register *const _rtcr1; + }; +} + + +Xilinx::Xps_timer::Xps_timer(addr_t const &base) +: + _rtcsr0((Register *)(base + RTCSR0_OFFSET)), + _rtlr0((Register *)(base + RTLR0_OFFSET)), + _rtcr0((Register *)(base + RTCR0_OFFSET)), + _rtcsr1((Register *)(base + RTCSR1_OFFSET)), + _rtlr1((Register *)(base + RTLR1_OFFSET)), + _rtcr1((Register *)(base + RTCR1_OFFSET)) +{ + *_rtcsr0 = STOP_N_RESET; + *_rtcsr1 = STOP_N_RESET; + *_rtlr0 = 0; +} + + +Xilinx::Xps_timer::size_t Xilinx::Xps_timer::size() +{ + return (size_t)MMIO_SIZE; +} + + +unsigned int Xilinx::Xps_timer::max_value() { return ((unsigned int)~0); } + + +void Xilinx::Xps_timer::prepare_oneshot(unsigned int const & value, + volatile Register * & start_reg, + Register & start_val) +{ + *_rtcsr0 = STOP_N_LOAD; + *_rtlr0 = value; + + start_reg = _rtcsr0; + start_val = RUN_ONCE; +} + + +void Xilinx::Xps_timer::run_circulating(unsigned int const &value) +{ + *_rtcsr0 = STOP_N_LOAD; + *_rtlr0 = value; + *_rtcsr0 = RUN_PERIODIC; + *_rtlr0 = max_value(); +} + + +void Xilinx::Xps_timer::run_periodic(unsigned int const &value) +{ + *_rtcsr0 = STOP_N_LOAD; + *_rtlr0 = value; + *_rtcsr0 = RUN_PERIODIC; +} + + +void Xilinx::Xps_timer::run_oneshot(unsigned int const &value) +{ + *_rtcsr0 = STOP_N_LOAD; + *_rtlr0 = value; + *_rtcsr0 = RUN_ONCE; +} + + +unsigned int Xilinx::Xps_timer::value() { return *_rtcr0; } + + +unsigned int Xilinx::Xps_timer::period_value(bool * const &rolled_over) +{ + if(!(*_rtcsr0 & (1 << RTCSR_ARHT_LSHIFT))){ + /* this is no periodic run */ + unsigned int const v = *_rtcr0; + *rolled_over = !(v); + return value(); + } + + /* 2 measurements are necessary to ensure that + * 'rolled_over' and the returned value are fit together + * because we can not halt the timer or read both simulanously */ + unsigned int const v1 = *_rtcr0; + *rolled_over = (bool)(*_rtcsr0 & (1 << RTCSR_TINT_LSHIFT)); + unsigned int const v2 = *_rtcr0; + + if(*rolled_over) { + /* v2 must be a value the timer had after rolling over, so restart + * the timer with the current value but RTCSR[TINT] reset */ + unsigned int const initial_rtlr = *_rtlr0; + unsigned int const restart_n_reset = *_rtcsr0 | (1 << RTCSR_TINT_LSHIFT); + *_rtlr0 = *_rtcr0; // timer gets delayed about the + *_rtcsr0 = restart_n_reset; // duration of these two operations + *_rtlr0 = initial_rtlr; + return v2; + } + + /* v1 must be a value that the timer had before rolling + * over, so we don't have to reset the "rolled over" status even + * if the timer has rolled over till now */ + return v1; +} + + +Xilinx::Xps_timer::~Xps_timer() +{ + *_rtcsr0 = STOP_N_RESET; + *_rtcsr1 = STOP_N_RESET; +} + + +unsigned int Xilinx::Xps_timer::native_to_msec(unsigned int const &v) +{ + return 1000*native_to_usec(v); +} + + +unsigned int Xilinx::Xps_timer::msec_to_native(unsigned int const &v) +{ + return 1000*usec_to_native(v); +} + + +unsigned int Xilinx::Xps_timer::native_to_usec(unsigned int const &v) +{ + return v/FREQUENCY_PER_US; +} + + +unsigned int Xilinx::Xps_timer::usec_to_native(unsigned int const &v) +{ + return v*FREQUENCY_PER_US; +} + + +#endif /* _INCLUDE__DEVICES__XILINX_XPS_TIMER_H_ */ diff --git a/base-mb/include/xilinx/xps_uartl.h b/base-mb/include/xilinx/xps_uartl.h new file mode 100644 index 000000000..57e531ee0 --- /dev/null +++ b/base-mb/include/xilinx/xps_uartl.h @@ -0,0 +1,111 @@ +/* + * \brief Driver for the Xilinx LogiCORE IP XPS UART Lite 1.01a + * \author Martin stein + * \date 2011-05-06 + */ + +/* + * Copyright (C) 2011 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__DEVICES__XILINX_XPS_UARTL_H_ +#define _INCLUDE__DEVICES__XILINX_XPS_UARTL_H_ + +#include + +namespace Xilinx { + + /** + * Driver for the Xilinx LogiCORE IP XPS UART Lite 1.01a + */ + class Xps_uartl + { + public: + + /** + * Constructor + */ + Xps_uartl(Cpu::addr_t const & base); + + /** + * Send one ASCII char over the UART interface + */ + inline void send(char const & c); + + private: + + /** + * Relative MMIO structure + */ + + typedef Cpu::uint32_t Register; + + enum { + RX_FIFO_OFF = 0 * Cpu::WORD_SIZE, + TX_FIFO_OFF = 1 * Cpu::WORD_SIZE, + STAT_REG_OFF = 2 * Cpu::WORD_SIZE, + CTRL_REG_OFF = 3 * Cpu::WORD_SIZE, + }; + + struct Rx_fifo { + enum { + BITFIELD_ENUMS(RX_DATA, 0, 8) + }; + }; + + struct Tx_fifo { + enum { + BITFIELD_ENUMS(TX_DATA, 0, 8) + }; + }; + + struct Ctrl_reg { + enum { + BITFIELD_ENUMS(RST_TX_FIFO, 0, 1) + BITFIELD_ENUMS(RST_RX_FIFO, 1, 1) + BITFIELD_ENUMS(ENABLE_INTR, 4, 1) + }; + }; + + struct Stat_reg { + enum { + BITFIELD_ENUMS(RX_FIFO_VALID_DATA, 0, 1) + BITFIELD_ENUMS(RX_FIFO_FULL, 1, 1) + BITFIELD_ENUMS(TX_FIFO_EMPTY, 2, 1) + BITFIELD_ENUMS(TX_FIFO_FULL, 3, 1) + BITFIELD_ENUMS(INTR_ENABLED, 4, 1) + BITFIELD_ENUMS(OVERRUN_ERROR, 5, 1) + BITFIELD_ENUMS(FRAME_ERROR, 6, 1) + BITFIELD_ENUMS(PARITY_ERROR, 7, 1) + }; + }; + + /** + * Absolute register pointers + */ + volatile Register* const _rx_fifo; + volatile Register* const _tx_fifo; + volatile Register* const _stat_reg; + volatile Register* const _ctrl_reg; + }; +} + + +Xilinx::Xps_uartl::Xps_uartl(Cpu::addr_t const & base) : + _rx_fifo((Register*)(base + RX_FIFO_OFF)), + _tx_fifo((Register*)(base + TX_FIFO_OFF)), + _stat_reg((Register*)(base + STAT_REG_OFF)), + _ctrl_reg((Register*)(base + CTRL_REG_OFF)) +{} + + +void Xilinx::Xps_uartl::send(char const & c){ + while(*_stat_reg & Stat_reg::TX_FIFO_FULL_MSK); + *_tx_fifo = c; +} + + +#endif /* _INCLUDE__DEVICES__XILINX_XPS_UARTL_H_ */ diff --git a/base-mb/lib/mk/cxx.mk b/base-mb/lib/mk/cxx.mk new file mode 100755 index 000000000..5d176c384 --- /dev/null +++ b/base-mb/lib/mk/cxx.mk @@ -0,0 +1,87 @@ +LIBS = allocator_avl +CXX_SRC_CC += misc.cc new_delete.cc malloc_free.cc exception.cc guard.cc + +vpath %.cc $(BASE_DIR)/src/base/cxx + +# +# Microblaze-specific supplement +# +CXX_SRC_CC += atexit.cc + +vpath %.cc $(REP_DIR)/src/base/cxx + +# +# Here we define all symbols we want to hide in libsupc++ and libgcc_eh +# +LIBC_SYMBOLS += malloc free calloc realloc \ + abort fputc fputs fwrite \ + stderr strcat strcpy strlen up \ + memcmp strncmp strcmp sprintf + +# +# Take the right system libraries +# +# Normally, we never include build-system-internal files from library- +# description files. For building the 'cxx' library, however, we need the +# information about the used 'gcc' for resolving the location of the C++ +# support libraries. This definition is performed by 'mk/lib.mk' after +# including this library description file. Hence, we need to manually +# include 'global.mk' here. +# +include $(BASE_DIR)/mk/global.mk + +LIBCXX_GCC = $(shell $(CUSTOM_CXX_LIB) -print-file-name=libsupc++.a) \ + $(shell $(CUSTOM_CXX_LIB) -print-libgcc-file-name) + +# $(shell $(CUSTOM_CXX_LIB) -print-file-name=libgcc_eh.a) + +# +# Dummy target used by the build system +# +SRC_S = supc++.o +CXX_SRC = $(sort $(CXX_SRC_CC)) +CXX_OBJECTS = $(addsuffix .o,$(basename $(CXX_SRC))) +LOCAL_SYMBOLS = $(patsubst %,--localize-symbol=%,$(LIBC_SYMBOLS)) + +# +# Prevent symbols of the gcc support libs from being discarded during 'ld -r' +# +KEEP_SYMBOLS += __cxa_guard_acquire +KEEP_SYMBOLS += __moddi3 __divdi3 __umoddi3 __udivdi3 +KEEP_SYMBOLS += _ZTVN10__cxxabiv116__enum_type_infoE +KEEP_SYMBOLS += __fixunsdfdi +KEEP_SYMBOLS += __udivsi3 __divsi3 + +# +# Keep symbols additionally needed for linking the libc on ARM +# +KEEP_SYMBOLS += __muldi3 __eqdf2 __fixdfsi __ltdf2 __ltdf2 __nedf2 __ltdf2 \ + __gtdf2 __ltdf2 __ledf2 __fixdfsi __ltdf2 __ltdf2 __eqdf2 \ + __fixdfsi __ltdf2 __fixdfsi __eqdf2 __gtdf2 __ltdf2 __gtdf2 \ + __eqdf2 __muldi3 __muldi3 + +# +# Keep symbols needed for floating-point support on ARM +# +KEEP_SYMBOLS += __addsf3 __gtsf2 __ltsf2 + +# +# Additional symbols we need to keep when using the arm-none-linux-gnueabi +# tool chain +# +KEEP_SYMBOLS += __aeabi_ldivmod __aeabi_uldivmod __dynamic_cast +KEEP_SYMBOLS += _ZN10__cxxabiv121__vmi_class_type_infoD0Ev +KEEP_SYMBOLS += __aeabi_idiv __aeabi_ulcmp __aeabi_fmul __aeabi_dcmpun \ + __aeabi_d2lz __aeabi_f2lz __aeabi_d2f __aeabi_fcmpun \ + __aeabi_f2iz ctx_done sincos sincosf tgamma + +# +# Rule to link all libc definitions and libsupc++ libraries +# and to hide after that the exported libc symbols +# +$(SRC_S): $(CXX_OBJECTS) + $(MSG_MERGE)$@ + $(VERBOSE)$(LD) $(addprefix -u ,$(KEEP_SYMBOLS)) -r $(CXX_OBJECTS) $(LIBCXX_GCC) -o $@.tmp + $(MSG_CONVERT)$@ + $(VERBOSE)$(OBJCOPY) $(LOCAL_SYMBOLS) $@.tmp $@ + $(VERBOSE)$(RM) $@.tmp diff --git a/base-mb/lib/mk/ipc.mk b/base-mb/lib/mk/ipc.mk new file mode 100755 index 000000000..8c5d5d845 --- /dev/null +++ b/base-mb/lib/mk/ipc.mk @@ -0,0 +1,6 @@ +SRC_CC = ipc.cc +SRC_CC += pager.cc +LIBS += thread_context + +vpath ipc.cc $(REP_DIR)/src/base/ipc +vpath pager.cc $(REP_DIR)/src/base/ipc diff --git a/base-mb/lib/mk/kernel.inc b/base-mb/lib/mk/kernel.inc new file mode 100755 index 000000000..5d7fbe218 --- /dev/null +++ b/base-mb/lib/mk/kernel.inc @@ -0,0 +1,41 @@ +KERNEL_DIR = $(REP_DIR)/src/kernel + +INC_DIR += $(KERNEL_DIR)/include +INC_DIR += $(REP_DIR)/src/core/include + + +## +## Platform-specific kernel parts +## + +PLATFORM = petalogix_s3adsp1800_mmu + +# +# Basic platform support +# +include $(LIBINC_DIR)/$(PLATFORM)__kernel_support.inc + +# +# Enable atomic operations for this platform +# +LIBS += $(PLATFORM)__atomic_operations + + +## +## Generic kernel parts +## + +GENERIC_DIR = $(KERNEL_DIR)/generic + +SRC_CC += kernel.cc +SRC_CC += scheduler.cc +SRC_CC += thread.cc +SRC_CC += blocking.cc +SRC_CC += syscall_events.cc + +vpath kernel.cc $(GENERIC_DIR) +vpath scheduler.cc $(GENERIC_DIR) +vpath thread.cc $(GENERIC_DIR) +vpath blocking.cc $(GENERIC_DIR) +vpath syscall_events.cc $(GENERIC_DIR) + diff --git a/base-mb/lib/mk/kernel_core.mk b/base-mb/lib/mk/kernel_core.mk new file mode 100755 index 000000000..090e52136 --- /dev/null +++ b/base-mb/lib/mk/kernel_core.mk @@ -0,0 +1,13 @@ +LIBINC_DIR = $(REP_DIR)/lib/mk + +include $(LIBINC_DIR)/kernel.inc + +INC_DIR += $(REP_DIR)/src/platform +INC_DIR += $(REP_DIR)/src/core +INC_DIR += $(BASE_DIR)/src/platform + +include $(LIBINC_DIR)/kernel.inc +CC_OPT += -DROOTTASK_ENTRY=_main +SRC_CC += _main.cc + +vpath _main.cc $(BASE_DIR)/src/platform diff --git a/base-mb/lib/mk/kernel_test.inc b/base-mb/lib/mk/kernel_test.inc new file mode 100755 index 000000000..a35e00097 --- /dev/null +++ b/base-mb/lib/mk/kernel_test.inc @@ -0,0 +1,7 @@ +LIBINC_DIR = $(REP_DIR)/lib/mk + +include $(LIBINC_DIR)/kernel.inc + +INC_DIR += $(REP_DIR)/src/platform +INC_DIR += $(REP_DIR)/src/core +INC_DIR += $(BASE_DIR)/src/platform diff --git a/base-mb/lib/mk/lock.mk b/base-mb/lib/mk/lock.mk new file mode 100755 index 000000000..b34dacabd --- /dev/null +++ b/base-mb/lib/mk/lock.mk @@ -0,0 +1,6 @@ +PLATFORM = petalogix_s3adsp1800_mmu +LIBS = thread_context $(PLATFORM)__atomic_operations +SRC_CC = lock.cc +INC_DIR += $(REP_DIR)/src/base/lock + +vpath lock.cc $(BASE_DIR)/src/base/lock diff --git a/base-mb/lib/mk/pager.mk b/base-mb/lib/mk/pager.mk new file mode 100755 index 000000000..24f25bcf8 --- /dev/null +++ b/base-mb/lib/mk/pager.mk @@ -0,0 +1,4 @@ +SRC_CC = pager.cc +INC_DIR += $(REP_DIR)/include/codezero/dummies + +vpath pager.cc $(REP_DIR)/src/base/pager diff --git a/base-mb/lib/mk/petalogix_s3adsp1800_mmu__atomic_operations.mk b/base-mb/lib/mk/petalogix_s3adsp1800_mmu__atomic_operations.mk new file mode 100644 index 000000000..8ace07986 --- /dev/null +++ b/base-mb/lib/mk/petalogix_s3adsp1800_mmu__atomic_operations.mk @@ -0,0 +1,6 @@ +PLATFORM_DIR = $(REP_DIR)/src/kernel/platforms/petalogix_s3adsp1800_mmu + +INC_DIR += $(PLATFORM_DIR)/include + +SRC_S += atomic.s +vpath atomic.s $(PLATFORM_DIR) diff --git a/base-mb/lib/mk/petalogix_s3adsp1800_mmu__kernel_support.inc b/base-mb/lib/mk/petalogix_s3adsp1800_mmu__kernel_support.inc new file mode 100755 index 000000000..5c703ad10 --- /dev/null +++ b/base-mb/lib/mk/petalogix_s3adsp1800_mmu__kernel_support.inc @@ -0,0 +1,29 @@ +## +## Platform +## +PLATFORM = petalogix_s3adsp1800_mmu + +# +# Assembly include paths +# +INC_DIR += $(KERNEL_DIR)/platforms/$(PLATFORM)/include + +# +# C++ include paths +# +INC_DIR += $(KERNEL_DIR)/include/$(PLATFORM) + +# +# Sources +# +PLATFORM_DIR = $(KERNEL_DIR)/platforms/$(PLATFORM) + +SRC_CC += platform.cc +SRC_S += crt0_kernel.s +SRC_S += kernel_entry.s +SRC_S += userland_entry.s + +vpath platform.cc $(PLATFORM_DIR) +vpath crt0_kernel.s $(PLATFORM_DIR) +vpath kernel_entry.s $(PLATFORM_DIR) +vpath userland_entry.s $(PLATFORM_DIR) diff --git a/base-mb/lib/mk/printf_microblaze.mk b/base-mb/lib/mk/printf_microblaze.mk new file mode 100755 index 000000000..00c6c7588 --- /dev/null +++ b/base-mb/lib/mk/printf_microblaze.mk @@ -0,0 +1,5 @@ +SRC_CC = microblaze_console.cc +LIBS = cxx console +INC_DIR += $(REP_DIR)/src/platform + +vpath %.cc $(REP_DIR)/src/base/console diff --git a/base-mb/lib/mk/startup.mk b/base-mb/lib/mk/startup.mk new file mode 100755 index 000000000..9aec768c8 --- /dev/null +++ b/base-mb/lib/mk/startup.mk @@ -0,0 +1,13 @@ +PLATFORM = petalogix_s3adsp1800_mmu +KERNEL_DIR = $(REP_DIR)/src/kernel +PLATFORM_DIR = $(KERNEL_DIR)/platforms/$(PLATFORM) + +LIBS = cxx lock +SRC_S = crt0.s +SRC_CC += _main.cc +INC_DIR += $(REP_DIR)/src/platform +INC_DIR += $(BASE_DIR)/src/platform +INC_DIR += $(PLATFORM_DIR)/include + +vpath crt0.s $(PLATFORM_DIR) +vpath _main.cc $(dir $(call select_from_repositories,src/platform/_main.cc)) diff --git a/base-mb/lib/mk/test_env.mk b/base-mb/lib/mk/test_env.mk new file mode 100755 index 000000000..99adcd34f --- /dev/null +++ b/base-mb/lib/mk/test_env.mk @@ -0,0 +1,6 @@ +SRC_CC = context_area.cc thread_roottask.cc thread.cc +LIBS += lock thread_context + +vpath thread.cc $(BASE_DIR)/src/base/thread +vpath thread_roottask.cc $(REP_DIR)/src/test +vpath context_area.cc $(REP_DIR)/src/test diff --git a/base-mb/lib/mk/thread.mk b/base-mb/lib/mk/thread.mk new file mode 100644 index 000000000..265adc053 --- /dev/null +++ b/base-mb/lib/mk/thread.mk @@ -0,0 +1,8 @@ +SRC_CC = thread.cc thread_start.cc thread_bootstrap.cc +INC_DIR += $(REP_DIR)/include/codezero/dummies +INC_DIR += $(REP_DIR)/src/core/include + +vpath thread.cc $(REP_DIR)/src/base/thread +vpath thread_start.cc $(REP_DIR)/src/base/thread +vpath thread_bootstrap.cc $(REP_DIR)/src/base/thread +vpath %.cc $(BASE_DIR)/src/base/thread diff --git a/base-mb/lib/mk/thread_context.mk b/base-mb/lib/mk/thread_context.mk new file mode 100755 index 000000000..3693bce60 --- /dev/null +++ b/base-mb/lib/mk/thread_context.mk @@ -0,0 +1,5 @@ +SRC_CC = thread_context.cc + +INC_DIR += $(REP_DIR)/src/core/include + +vpath thread_context.cc $(REP_DIR)/src/base/thread diff --git a/base-mb/mk/spec-mb_ml507.mk b/base-mb/mk/spec-mb_ml507.mk new file mode 100644 index 000000000..e6199c897 --- /dev/null +++ b/base-mb/mk/spec-mb_ml507.mk @@ -0,0 +1,7 @@ +SPECS += 32bit mb_timer + +STARTUP_LIB ?= startup + +PRG_LIBS += $(STARTUP_LIB) + +include $(call select_from_repositories,mk/spec-32bit.mk) diff --git a/base-mb/mk/spec-mb_s3a_starter_kit.mk b/base-mb/mk/spec-mb_s3a_starter_kit.mk new file mode 100644 index 000000000..e6199c897 --- /dev/null +++ b/base-mb/mk/spec-mb_s3a_starter_kit.mk @@ -0,0 +1,7 @@ +SPECS += 32bit mb_timer + +STARTUP_LIB ?= startup + +PRG_LIBS += $(STARTUP_LIB) + +include $(call select_from_repositories,mk/spec-32bit.mk) diff --git a/base-mb/platform/mb_s3a_starter_kit/Makefile b/base-mb/platform/mb_s3a_starter_kit/Makefile new file mode 100644 index 000000000..5d215f2c9 --- /dev/null +++ b/base-mb/platform/mb_s3a_starter_kit/Makefile @@ -0,0 +1,22 @@ +# +# \brief Prepare the Xilinx Spartan 3A Starter Kit to run Genode on it +# \author Martin Stein +# \date 2011-05-23 +# + +HW = s3a_starter_kit +WORK_DIR = $(shell pwd) +BIT_FILE = $(WORK_DIR)/system.bit +VERBOSE ?= @ +REP_DIR = ../.. +MK_DIR = $(REP_DIR)/platform/mk/ + +all: configure + +clean: + $(VERBOSE) rm -f $(TMP_FILES) + +.PHONY: all clean + +include $(MK_DIR)/$(HW).mk +include $(MK_DIR)/microblaze.mk diff --git a/base-mb/platform/mb_s3a_starter_kit/system.bit b/base-mb/platform/mb_s3a_starter_kit/system.bit new file mode 100644 index 0000000000000000000000000000000000000000..13ca4c7f449374790dd6f3371249337f5c596cfb GIT binary patch literal 341653 zcmeFa4|FA0c_;W)y^>UtUw2n`%Z}^_b0sVA>}`|RZ9&>hhjY6TafkJ=3bBDNMPg1FvnMF84KHF1a>kw3pvjQPE3chQLM6V6)yyIETYTw#mRw z_BcuiNscjSf4}eETd&@ey4@Ia&g9S6{qFbwyMOA|tv_E?NrrcA_W@X{p(+P z_s{-sulV`5ze8@2<`uv6W9|0!@BCk<4^GS5<-7y!{ri8k{mLJ0Um@?1;r*|C^(zm& zy8UDFvoi3it2dtqj^ES1SB8x2zkc|cD<%#d*?+G*y#Mfzru!dEC*57`CpRB!pOA(9 z3;DuQ*>mv$TE=qhta2`IEs$Ae;A$l``imoEt&ZH+=G9(ZP#scF5RBuP&MEZ=I6S*Dl?8!}Zr6$Va_iWUD@vv=#L|{tgjG#NBZH z4F~dT4r_e+54=%6*c-oB51)?e;cpsCccwVJ#P-o2dLS{^Gd_BL!}WHgPha^{Pw49P zU{&cE