├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md └── workflows │ ├── camkes-vm-deploy.yml │ ├── pr.yml │ ├── push.yml │ ├── test-hw.yml │ └── test.yml ├── .licenseignore ├── .reuse └── dep5 ├── .stylefilter ├── CMakeLists.txt ├── LICENSE.md ├── LICENSES ├── BSD-2-Clause.txt ├── BSD-3-Clause.txt ├── CC-BY-SA-4.0.txt ├── GPL-2.0-only.txt ├── GPL-2.0-or-later.txt ├── LGPL-3.0-or-later.txt └── MIT.txt ├── README.md ├── apps ├── Arm │ ├── odroid_vm │ │ ├── CMakeLists.txt │ │ ├── components │ │ │ ├── can │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── can.camkes │ │ │ │ ├── include │ │ │ │ │ ├── can_inf.h │ │ │ │ │ ├── common.h │ │ │ │ │ ├── mcp2515.h │ │ │ │ │ ├── queue.h │ │ │ │ │ └── spi_inf.h │ │ │ │ └── src │ │ │ │ │ ├── controller.c │ │ │ │ │ ├── dev.c │ │ │ │ │ ├── irq.c │ │ │ │ │ ├── queue.c │ │ │ │ │ ├── spi_cmd.c │ │ │ │ │ └── test.c │ │ │ ├── clk │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── clk.camkes │ │ │ │ ├── include │ │ │ │ │ ├── common.h │ │ │ │ │ └── utils.h │ │ │ │ └── src │ │ │ │ │ └── clk.c │ │ │ ├── gpio │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── gpio.camkes │ │ │ │ ├── include │ │ │ │ │ └── periph.h │ │ │ │ └── src │ │ │ │ │ └── gpio.c │ │ │ ├── pilot │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── pilot.camkes │ │ │ │ └── src │ │ │ │ │ ├── aeslib │ │ │ │ │ ├── aes.h │ │ │ │ │ ├── aescrypt.c │ │ │ │ │ ├── aeskey.c │ │ │ │ │ ├── aesopt.h │ │ │ │ │ ├── aestab.c │ │ │ │ │ ├── aestab.h │ │ │ │ │ ├── brg_endian.h │ │ │ │ │ ├── brg_types.h │ │ │ │ │ ├── commsec.c │ │ │ │ │ ├── commsec.h │ │ │ │ │ ├── gcm.c │ │ │ │ │ ├── gcm.h │ │ │ │ │ ├── gf128mul.c │ │ │ │ │ ├── gf128mul.h │ │ │ │ │ ├── gf_convert.c │ │ │ │ │ ├── gf_mul_lo.h │ │ │ │ │ └── mode_hdr.h │ │ │ │ │ └── pilot.c │ │ │ ├── pwm │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── pwm.camkes │ │ │ │ └── src │ │ │ │ │ └── pwm.c │ │ │ ├── spi │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── common.h │ │ │ │ │ ├── spi_inf.h │ │ │ │ │ └── utils.h │ │ │ │ ├── spi.camkes │ │ │ │ └── src │ │ │ │ │ └── spi.c │ │ │ ├── timer │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── src │ │ │ │ │ ├── pwm.c │ │ │ │ │ └── timer.c │ │ │ │ └── timer.camkes │ │ │ └── uart │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── src │ │ │ │ └── driver.c │ │ │ │ └── uart.camkes │ │ ├── include │ │ │ ├── can_inf.h │ │ │ ├── common.h │ │ │ ├── spi_inf.h │ │ │ └── utils.h │ │ ├── interfaces │ │ │ ├── can.idl4 │ │ │ ├── clk.idl4 │ │ │ ├── gpio.idl4 │ │ │ ├── pilot.idl4 │ │ │ ├── pwm.idl4 │ │ │ ├── spi.idl4 │ │ │ ├── timer.idl4 │ │ │ └── uart.idl4 │ │ ├── settings.cmake │ │ └── vm_odroid.camkes │ ├── vm_cross_connector │ │ ├── CMakeLists.txt │ │ ├── components │ │ │ └── CrossvmInit │ │ │ │ └── crossvm_init.c │ │ ├── exynos5422 │ │ │ └── devices.camkes │ │ ├── overlay_files │ │ │ └── init_scripts │ │ │ │ ├── cross_vm_module_init │ │ │ │ └── cross_vm_test │ │ ├── qemu-arm-virt │ │ │ └── devices.camkes │ │ ├── settings.cmake │ │ ├── src │ │ │ └── cross_vm_connections.c │ │ └── vm_cross_connector.camkes │ ├── vm_introspect │ │ ├── CMakeLists.txt │ │ ├── component │ │ │ └── introspect_component.c │ │ ├── exynos5422 │ │ │ └── devices.camkes │ │ ├── overlay_files │ │ │ └── init_scripts │ │ │ │ ├── introspect_dataport_init │ │ │ │ └── introspect_vm_test │ │ ├── qemu-arm-virt │ │ │ └── devices.camkes │ │ ├── settings.cmake │ │ ├── src │ │ │ ├── cross_vm_connection.c │ │ │ └── init_dataport_ram.c │ │ └── vm_introspect.camkes │ ├── vm_minimal │ │ ├── CMakeLists.txt │ │ ├── exynos5422 │ │ │ └── devices.camkes │ │ ├── odroidc2 │ │ │ └── devices.camkes │ │ ├── qemu-arm-virt │ │ │ └── devices.camkes │ │ ├── settings.cmake │ │ ├── tk1 │ │ │ └── devices.camkes │ │ ├── tx1 │ │ │ └── devices.camkes │ │ ├── tx2 │ │ │ └── devices.camkes │ │ ├── vm_minimal.camkes │ │ └── zcu102 │ │ │ ├── 2018_3 │ │ │ └── devices.camkes │ │ │ ├── 2021_1 │ │ │ └── devices.camkes │ │ │ └── 2022_1 │ │ │ └── devices.camkes │ ├── vm_multi │ │ ├── CMakeLists.txt │ │ ├── exynos5422 │ │ │ └── devices.camkes │ │ ├── overlay_files │ │ │ ├── inittab_hvc0 │ │ │ ├── vm0_bridge_setup.sh │ │ │ └── vm_client_net_setup.sh │ │ ├── qemu-arm-virt │ │ │ └── devices.camkes │ │ ├── settings.cmake │ │ └── vm_multi.camkes │ ├── vm_serial_server │ │ ├── CMakeLists.txt │ │ ├── exynos5422 │ │ │ └── devices.camkes │ │ ├── overlay_files │ │ │ └── init_scripts │ │ │ │ └── inittab_hvc0 │ │ ├── settings.cmake │ │ └── vm_serial_server.camkes │ └── vm_virtio_net │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── components │ │ └── PingClient │ │ │ └── ping_client.c │ │ ├── exynos5422 │ │ └── devices.camkes │ │ ├── overlay_files │ │ ├── init_scripts │ │ │ ├── arping_test │ │ │ ├── ping_test │ │ │ └── zynqmp │ │ │ │ ├── arping_test │ │ │ │ └── ping_test │ │ └── network_interfaces │ │ │ └── interfaces │ │ ├── settings.cmake │ │ ├── tx2 │ │ └── devices.camkes │ │ ├── vm_echo_ping.camkes │ │ ├── vm_virtio_net.camkes │ │ └── zcu102 │ │ └── 2022_1 │ │ └── devices.camkes └── x86 │ ├── cma34cr_centos │ ├── CMakeLists.txt │ ├── README.md │ ├── app_settings.cmake │ ├── centos_linux │ │ ├── bzimage │ │ ├── centos-kernel-config │ │ └── rootfs.cpio │ ├── cma34cr_centos.camkes │ ├── configurations │ │ └── cma34cr_centos.h │ ├── lwip_include │ │ └── lwipopts.h │ └── src │ │ └── cross_vm_connections.c │ ├── cma34cr_ubuntu │ ├── CMakeLists.txt │ ├── README.md │ ├── app_settings.cmake │ ├── cma34cr_ubuntu.camkes │ └── ubuntu_linux │ │ └── rootfs.cpio │ ├── minimal │ ├── CMakeLists.txt │ ├── app_settings.cmake │ └── minimal.camkes │ ├── minimal_64 │ ├── CMakeLists.txt │ ├── app_settings.cmake │ └── minimal.camkes │ ├── optiplex9020 │ ├── CMakeLists.txt │ ├── app_settings.cmake │ ├── optiplex9020.camkes │ └── src │ │ └── cross_vm_connections.c │ ├── virtio_blk_sample │ ├── CMakeLists.txt │ ├── app_settings.cmake │ └── virtio_blk_sample.camkes │ └── zmq_samples │ ├── CMakeLists.txt │ ├── README.md │ ├── app_settings.cmake │ ├── components │ └── cakeml-filter │ │ ├── componentScript.sml │ │ └── global_endpoint.c │ ├── libs │ ├── cakeml_helpers.cmake │ └── virtqueueScript.sml │ ├── scripts │ ├── network_interface_0 │ ├── network_interface_1 │ └── network_interface_2 │ ├── src │ └── user │ │ ├── CMakeLists.txt │ │ ├── clientserver │ │ ├── client.c │ │ └── server.c │ │ ├── pipeline │ │ ├── sink.c │ │ ├── source.c │ │ └── worker.c │ │ ├── pubsub │ │ ├── pub.c │ │ └── sub.c │ │ ├── zmq_bench_0.sh │ │ ├── zmq_bench_1.sh │ │ └── zmq_bench_2.sh │ ├── zmq_cakeml.camkes │ └── zmq_samples.camkes ├── easy-settings.cmake ├── linux ├── Makefile ├── buildroot_tk1_emmc_defconfig ├── buildroot_tk1_initrd_defconfig ├── linux ├── linux-secure-dtb ├── linux-secure-vusb-dtb ├── linux-tk1-debian ├── linux-tk1-initrd ├── linux-tk1-nonsecured.dts ├── linux-tk1-secure.dts └── rootfs-tk1.cpio └── settings.cmake /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Code of Conduct 8 | 9 | This repository and interactions with it fall under the [seL4 Code of Conduct][1] available from the [seL4 website][2]. 10 | 11 | [1]: https://docs.sel4.systems/processes/conduct.html 12 | [2]: https://sel4.systems 13 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Contributions Welcome 8 | 9 | Please see the [seL4 contributing guidelines][1] on the [seL4 website][2] for 10 | details. 11 | 12 | [1]: https://docs.sel4.systems/processes/contributing.html 13 | [2]: https://sel4.systems 14 | 15 | 16 | ## Contact 17 | 18 | If you have larger changes or additions, it is a good idea to get in contact 19 | with us as , so we can help you get started. 20 | 21 | The people responsible for the technical direction, procedures, and quality 22 | control are the [Technical Steering Committee][3] (TSC) of the seL4 23 | foundation. You can contact them either on the developer mailing list or on 24 | directly via email available from their profile pages. 25 | 26 | [3]: https://sel4.systems/Foundation/TSC 27 | 28 | 29 | ## Developer Certificate of Origin (DCO) 30 | 31 | This repository uses the same sign-off process as the Linux kernel. For every 32 | commit, use 33 | 34 | git commit -s 35 | 36 | to add a sign-off line to your commit message, which will come out as: 37 | 38 | Signed-off-by: name 39 | 40 | By adding this line, you make the declaration that you have the right to make 41 | this contribution under the open source license the files use that you changed 42 | or contributed. 43 | 44 | The full text of the declaration is at . 45 | -------------------------------------------------------------------------------- /.github/workflows/camkes-vm-deploy.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021, Proofcraft Pty Ltd 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | # CAmkES VM regression tests 6 | 7 | name: Deploy 8 | 9 | on: 10 | push: 11 | branches: [master] 12 | paths-ignore: 13 | - '**.md' 14 | 15 | # allow manual trigger 16 | workflow_dispatch: 17 | 18 | # allow explict trigger from other repos when dependencies have changed 19 | repository_dispatch: 20 | types: [deps-update] 21 | 22 | jobs: 23 | code: 24 | name: Freeze Code 25 | runs-on: ubuntu-latest 26 | outputs: 27 | xml: ${{ steps.repo.outputs.xml }} 28 | steps: 29 | - id: repo 30 | uses: seL4/ci-actions/repo-checkout@master 31 | with: 32 | manifest_repo: camkes-vm-examples-manifest 33 | manifest: master.xml 34 | 35 | build: 36 | name: Build 37 | needs: code 38 | runs-on: ubuntu-latest 39 | strategy: 40 | fail-fast: false 41 | matrix: 42 | march: [nehalem, armv7a, armv8a] 43 | steps: 44 | - uses: seL4/ci-actions/camkes-vm@master 45 | with: 46 | xml: ${{ needs.code.outputs.xml }} 47 | march: ${{ matrix.march }} 48 | - name: Upload images 49 | uses: actions/upload-artifact@v4 50 | with: 51 | name: images-${{ matrix.march }} 52 | path: '*-images.tar.gz' 53 | 54 | hw-run: 55 | name: Hardware 56 | runs-on: ubuntu-latest 57 | needs: [build] 58 | if: ${{ github.repository_owner == 'seL4' }} 59 | strategy: 60 | fail-fast: false 61 | matrix: 62 | march: [nehalem, armv7a, armv8a] 63 | # do not run concurrently with other workflows, but do run concurrently in the build matrix 64 | concurrency: camkes-hw-${{ strategy.job-index }} 65 | steps: 66 | - name: Get machine queue 67 | uses: actions/checkout@v4 68 | with: 69 | repository: seL4/machine_queue 70 | path: machine_queue 71 | - name: Download image 72 | uses: actions/download-artifact@v4 73 | with: 74 | name: images-${{ matrix.march }} 75 | - name: Run 76 | uses: seL4/ci-actions/camkes-vm-hw@master 77 | with: 78 | march: ${{ matrix.march }} 79 | index: $${{ strategy.job-index }} 80 | env: 81 | HW_SSH: ${{ secrets.HW_SSH }} 82 | 83 | deploy: 84 | name: Deploy manifest 85 | runs-on: ubuntu-22.04 86 | needs: [code, hw-run] 87 | if: ${{ github.repository_owner == 'seL4' }} 88 | steps: 89 | - name: Deploy 90 | uses: seL4/ci-actions/manifest-deploy@master 91 | with: 92 | xml: ${{ needs.code.outputs.xml }} 93 | manifest_repo: camkes-vm-examples-manifest 94 | env: 95 | GH_SSH: ${{ secrets.CI_SSH }} 96 | -------------------------------------------------------------------------------- /.github/workflows/pr.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2025, Proofcraft Pty Ltd 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | # Actions to run on pull requests 6 | 7 | name: PR 8 | 9 | on: [pull_request, workflow_dispatch] 10 | 11 | jobs: 12 | pr-checks: 13 | name: Checks 14 | uses: seL4/ci-actions/.github/workflows/pr.yml@master 15 | -------------------------------------------------------------------------------- /.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | # Actions to run on Push and Pull Request 6 | name: CI 7 | 8 | on: 9 | push: 10 | branches: 11 | - master 12 | pull_request: 13 | workflow_dispatch: 14 | 15 | jobs: 16 | checks: 17 | name: Checks 18 | uses: seL4/ci-actions/.github/workflows/push.yml@master 19 | -------------------------------------------------------------------------------- /.github/workflows/test-hw.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021, Proofcraft Pty Ltd 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | # camkes-vm-examples hardware builds and runs 6 | # 7 | # See camkes-vm-hw/builds.yml in the repo seL4/ci-actions for configs. 8 | 9 | name: HW 10 | 11 | on: 12 | # needs PR target for secrets access; guard by requiring label 13 | pull_request_target: 14 | types: [opened, reopened, synchronize, labeled] 15 | 16 | # downgrade permissions to read-only as you would have in a standard PR action 17 | permissions: 18 | contents: read 19 | 20 | # To reduce the load (especiually on the machine queue) we cancel any older runs 21 | # of this workflow for the current PR. Such runs exist, if there were new pushes 22 | # to the PR's branch without waiting for the workflow to finish. As a side 23 | # effect, pushing new commits now becomes a convenient way to cancel all the 24 | # older runs, e.g. if they are stuck and would only be stopped by the timeout 25 | # eventually. 26 | # Note that we could do the concurrency handling at a finer level, and only wrap 27 | # the actual run on the hardware. But there seems not much gain in letting the 28 | # older builds run, as these are usually obsolete with new pushes also. 29 | concurrency: 30 | group: ${{ github.workflow }}-pr-${{ github.event.number }} 31 | cancel-in-progress: true 32 | 33 | jobs: 34 | code: 35 | name: Freeze Code 36 | runs-on: ubuntu-latest 37 | if: ${{ github.event_name == 'push' || 38 | github.event_name == 'pull_request_target' && 39 | github.event.action != 'labeled' && 40 | (contains(github.event.pull_request.labels.*.name, 'hw-build') || 41 | contains(github.event.pull_request.labels.*.name, 'hw-test')) || 42 | github.event_name == 'pull_request_target' && 43 | github.event.action == 'labeled' && 44 | (github.event.label.name == 'hw-build' || 45 | github.event.label.name == 'hw-test') }} 46 | outputs: 47 | xml: ${{ steps.repo.outputs.xml }} 48 | steps: 49 | - id: repo 50 | uses: seL4/ci-actions/repo-checkout@master 51 | with: 52 | manifest_repo: camkes-vm-examples-manifest 53 | manifest: master.xml 54 | sha: ${{ github.event.pull_request.head.sha }} 55 | 56 | build: 57 | name: Build 58 | needs: code 59 | runs-on: ubuntu-latest 60 | strategy: 61 | fail-fast: true 62 | matrix: 63 | march: [nehalem, armv7a, armv8a] 64 | steps: 65 | - uses: seL4/ci-actions/camkes-vm@master 66 | with: 67 | xml: ${{ needs.code.outputs.xml }} 68 | march: ${{ matrix.march }} 69 | - name: Upload images 70 | uses: actions/upload-artifact@v4 71 | with: 72 | name: images-${{ matrix.march }} 73 | path: '*-images.tar.gz' 74 | 75 | run: 76 | name: Hardware 77 | runs-on: ubuntu-latest 78 | needs: [build] 79 | if: ${{ github.repository_owner == 'seL4' && 80 | (github.event_name == 'push' || 81 | github.event_name == 'pull_request_target' && 82 | github.event.action != 'labeled' && 83 | contains(github.event.pull_request.labels.*.name, 'hw-test') || 84 | github.event_name == 'pull_request_target' && 85 | github.event.action == 'labeled' && 86 | github.event.label.name == 'hw-test') }} 87 | strategy: 88 | fail-fast: true 89 | matrix: 90 | march: [nehalem, armv7a, armv8a] 91 | steps: 92 | - name: Get machine queue 93 | uses: actions/checkout@v4 94 | with: 95 | repository: seL4/machine_queue 96 | path: machine_queue 97 | - name: Download image 98 | uses: actions/download-artifact@v4 99 | with: 100 | name: images-${{ matrix.march }} 101 | - name: Run 102 | uses: seL4/ci-actions/camkes-vm-hw@master 103 | with: 104 | march: ${{ matrix.march }} 105 | index: $${{ strategy.job-index }} 106 | env: 107 | HW_SSH: ${{ secrets.HW_SSH }} 108 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021, Proofcraft Pty Ltd 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | # Actions to run on pull requests 6 | 7 | name: Camkes VM 8 | 9 | on: 10 | pull_request: 11 | 12 | jobs: 13 | test: 14 | name: Test 15 | runs-on: ubuntu-latest 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | march: [nehalem, armv7a, armv8a] 20 | steps: 21 | - uses: seL4/ci-actions/camkes-vm@master 22 | with: 23 | march: ${{ matrix.march }} 24 | -------------------------------------------------------------------------------- /.licenseignore: -------------------------------------------------------------------------------- 1 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | .reuse/dep5 6 | apps/x86/cma34cr_centos/centos_linux/* 7 | apps/x86/cma34cr_centos/lwip_include/lwipopts.h 8 | apps/x86/cma34cr_ubuntu/ubuntu_linux/* 9 | linux/* 10 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: seL4 3 | Upstream-Contact: seL4 team 4 | Source: http://sel4.systems 5 | 6 | Files: 7 | linux/* 8 | apps/x86/cma34cr_centos/* 9 | apps/x86/cma34cr_ubuntu/ubuntu_linux/rootfs.cpio 10 | Copyright: Linux 11 | License: GPL-2.0-only 12 | -------------------------------------------------------------------------------- /.stylefilter: -------------------------------------------------------------------------------- 1 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | cma34cr_centos/lwip_include/lwipopts.h 6 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | include(settings.cmake) 9 | project(camkes-vm C CXX ASM) 10 | 11 | if(AppArch STREQUAL "Arm") 12 | find_package(camkes-arm-vm REQUIRED) 13 | camkes_arm_vm_setup_arm_vm_environment() 14 | elseif(AppArch STREQUAL "x86") 15 | camkes_x86_vm_setup_x86_vm_environment() 16 | else() 17 | message(FATAL_ERROR "Unsupported") 18 | endif() 19 | # Add VM application 20 | add_subdirectory("apps/${AppArch}/${CAMKES_VM_APP}") 21 | # Should be done adding targets, can now generate the root server and the global configuration 22 | GenerateCAmkESRootserver() 23 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # License 8 | 9 | The files in this repository are released under standard open source licenses, 10 | identified by [SPDX license tags][1]. See the individual file headers for 11 | details, or use one of the publicly available SPDX tools to generate a bill of 12 | materials. The directory [`LICENSES`][2] contains the text for all licenses 13 | that are mentioned by files in this repository. 14 | 15 | Please see the individual library directories and source files for the licenses 16 | that apply to each library. 17 | 18 | For licensing an application, you must check each library that you link against. 19 | 20 | [1]: https://spdx.org 21 | [2]: LICENSES/ 22 | -------------------------------------------------------------------------------- /LICENSES/BSD-2-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | -------------------------------------------------------------------------------- /LICENSES/BSD-3-Clause.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) . All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(camkes-arm-odroid-vm C) 10 | 11 | include(${CAMKES_ARM_VM_HELPERS_PATH}) 12 | 13 | # Common build definitions 14 | CAmkESAddImportPath(components) 15 | CAmkESAddImportPath(interfaces) 16 | 17 | # Create interface include library 18 | add_library(app_include INTERFACE) 19 | target_include_directories(app_include INTERFACE include) 20 | 21 | # Create our CPP Flags based on ARM VM config variables 22 | set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5410") 23 | AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB Tk1DeviceFwd Tk1Insecure) 24 | 25 | # Add VM components 26 | add_subdirectory(components/pilot) 27 | add_subdirectory(components/uart) 28 | add_subdirectory(components/gpio) 29 | add_subdirectory(components/pwm) 30 | add_subdirectory(components/can) 31 | add_subdirectory(components/spi) 32 | add_subdirectory(components/clk) 33 | add_subdirectory(components/timer) 34 | 35 | set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux") 36 | 37 | # Different device tree if compiling with VmVUSB 38 | if(VmVUSB) 39 | set(device_tree_src "linux-secure-vusb-dtb") 40 | else() 41 | set(device_tree_src "linux-secure-dtb") 42 | endif() 43 | # Sed the device tree updating the rootfs name 44 | add_custom_command( 45 | OUTPUT linux/linux-dtb 46 | COMMAND 47 | bash -c 48 | "sed \"s/root=\\/dev\\/mmcblk1p2/root=\\/dev\\/${VmRootfs}/g\" ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} > linux/linux-dtb" 49 | VERBATIM 50 | ) 51 | # Create custom target for setting the dtb 52 | add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb") 53 | 54 | # Add Linux VM images into file server 55 | AddToFileServer("linux" "${linux_binary_name}") 56 | AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb) 57 | DefineCAmkESVMFileServer() 58 | 59 | # Declare odroid root server 60 | DeclareCAmkESRootserver( 61 | vm_odroid.camkes 62 | CPP_FLAGS 63 | ${cpp_flags} 64 | CPP_INCLUDES 65 | ${CAMKES_VM_DIR}/components/VM_Arm 66 | ) 67 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(can C) 10 | 11 | file(GLOB sources src/*.c) 12 | 13 | DeclareCAmkESComponent(can 14 | SOURCES ${sources} 15 | INCLUDES include 16 | LIBS app_include) 17 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/can.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | import "../../interfaces/spi.idl4"; 7 | import "../../interfaces/can.idl4"; 8 | 9 | component can { 10 | control; 11 | has mutex m_test; 12 | 13 | provides can_inf can; 14 | // maybe dataport Buf can_buf; 15 | 16 | uses spi_inf spi; 17 | dataport Buf spi_can; 18 | 19 | consumes IntEvent Int; 20 | emits IntEventAck IntAck; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/include/can_inf.h: -------------------------------------------------------------------------------- 1 | ../../../include/can_inf.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/include/common.h: -------------------------------------------------------------------------------- 1 | ../../../include/common.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/include/queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | /* TX/RX Massage Queue Functions */ 7 | #ifndef QUEUE_H 8 | #define QUEUE_H 9 | 10 | #include 11 | 12 | void mq_init(int size); 13 | int tx_queue_push(struct can_frame *frame); 14 | struct can_frame *tx_queue_pop(struct can_frame *frame); 15 | int rx_queue_push(struct can_frame *frame); 16 | struct can_frame *rx_queue_pop(struct can_frame *frame); 17 | 18 | #endif /*QUEUE_H*/ 19 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/include/spi_inf.h: -------------------------------------------------------------------------------- 1 | ../../../include/spi_inf.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/src/dev.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #define MSG_QUEUE_SIZE 128 15 | 16 | void spi__init(void); 17 | 18 | void can__init(void) 19 | { 20 | printf("CAN device started...\n"); 21 | mq_init(MSG_QUEUE_SIZE); 22 | } 23 | 24 | int can_setup(int baudrate) 25 | { 26 | spi__init(); 27 | mcp2515_reset(); 28 | 29 | /* Wait until reset finishes. */ 30 | int count = 100; 31 | while (1) { 32 | if (get_mode() == REQOP_CONFIG) { 33 | break; 34 | } 35 | else { 36 | udelay(1); 37 | count--; 38 | } 39 | if (count <= 0) { 40 | printf("CAN controller not responding. Check daughter board connection!\n"); 41 | return -1; 42 | } 43 | } 44 | 45 | set_baudrate(baudrate); 46 | enable_intrrupt(); 47 | 48 | set_mode(REQOP_NORMAL); 49 | 50 | return 0; 51 | } 52 | 53 | void can_send(struct can_frame frame) 54 | { 55 | int ret; 56 | 57 | do { 58 | ret = tx_queue_push(&frame); 59 | start_xmit(); 60 | } while (ret < 0); 61 | } 62 | 63 | void can_recv(struct can_frame *frame) 64 | { 65 | while (rx_queue_pop(frame) == NULL); 66 | } 67 | 68 | int can_try_recv(struct can_frame *frame) 69 | { 70 | if (rx_queue_pop(frame) == NULL) { 71 | return -1; 72 | }; 73 | 74 | return 0; 75 | } 76 | 77 | int can_set_filter(struct can_id id, unsigned int mask) 78 | { 79 | int ret; 80 | 81 | set_mode(REQOP_CONFIG); 82 | 83 | ret = set_rx_filter(id, mask); 84 | 85 | set_mode(REQOP_NORMAL); 86 | 87 | return ret; 88 | } 89 | 90 | void can_clear_filter(int filter_id) 91 | { 92 | set_mode(REQOP_CONFIG); 93 | 94 | clear_rx_filter(filter_id); 95 | 96 | set_mode(REQOP_NORMAL); 97 | } 98 | 99 | void can_disable_filtering(void) 100 | { 101 | set_mode(REQOP_CONFIG); 102 | 103 | clear_filter_mask(2); 104 | 105 | set_mode(REQOP_NORMAL); 106 | } 107 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/src/queue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | /* TX/RX message queue, using circular buffer. */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | struct mq_cb { 16 | struct can_frame *frames; 17 | int head; 18 | int tail; 19 | int size; 20 | sync_spinlock_t lock; 21 | }; 22 | 23 | static struct mq_cb *txq, *rxq; 24 | 25 | /* Check if the queue is full. */ 26 | static int mq_is_full(struct mq_cb *cb) 27 | { 28 | return (cb->tail + 1) % cb->size == cb->head; 29 | } 30 | 31 | /* Check if the queue is empty. */ 32 | static int mq_is_empty(struct mq_cb *cb) 33 | { 34 | return cb->tail == cb->head; 35 | } 36 | 37 | /* Add message to the end of the queue. */ 38 | static void mq_append_msg(struct mq_cb *cb, struct can_frame *frame) 39 | { 40 | memcpy(&cb->frames[cb->tail], frame, sizeof(struct can_frame)); 41 | cb->tail = (cb->tail + 1) % cb->size; 42 | } 43 | 44 | /* Retrieve message from the start of the queue. */ 45 | static void mq_remove_msg(struct mq_cb *cb, struct can_frame *frame) 46 | { 47 | memcpy(frame, &cb->frames[cb->head], sizeof(struct can_frame)); 48 | cb->head = (cb->head + 1) % cb->size; 49 | } 50 | 51 | /** 52 | * Initialize TX and RX message queues. 53 | * 54 | * @size: Size of the queue, applies to both TX and RX. 55 | */ 56 | void mq_init(int size) 57 | { 58 | /* Allocate memory for both TX and RX queues at once. */ 59 | txq = malloc(sizeof(struct mq_cb) * 2); 60 | if (!txq) { 61 | printf("Not enough memory!\n"); 62 | return; 63 | } 64 | rxq = txq + 1; 65 | 66 | txq->frames = malloc(sizeof(struct can_frame) * size * 2); 67 | if (!txq->frames) { 68 | printf("Not enough memory!\n"); 69 | free(txq); 70 | return; 71 | } 72 | rxq->frames = txq->frames + size; 73 | 74 | /* Initialize queues. */ 75 | txq->head = 0; 76 | txq->tail = 0; 77 | txq->size = size; 78 | sync_spinlock_init(&txq->lock); 79 | 80 | rxq->head = 0; 81 | rxq->tail = 0; 82 | rxq->size = size; 83 | sync_spinlock_init(&rxq->lock); 84 | } 85 | 86 | /** 87 | * Add CAN message to TX queue. 88 | * 89 | * @frame: CAN message about to add. 90 | * 91 | * @return: On success, return 0, -1 otherwise. 92 | * 93 | * NOTE: Popping from the queue will block this function. 94 | */ 95 | int tx_queue_push(struct can_frame *frame) 96 | { 97 | int ret = -1; 98 | 99 | if (!mq_is_full(txq)) { 100 | sync_spinlock_lock(&txq->lock); 101 | mq_append_msg(txq, frame); 102 | sync_spinlock_unlock(&txq->lock); 103 | ret = 0; 104 | } 105 | 106 | return ret; 107 | } 108 | 109 | /** 110 | * Retrieve CAN message from TX queue. 111 | * 112 | * @frame: CAN message about to fill-in . 113 | * 114 | * @return: On success, return frame address. 115 | * Return NULL if the queue is empty. 116 | * 117 | * NOTE: Pushing to the queue will block this function. 118 | * This function may block the IRQ handler. 119 | */ 120 | struct can_frame *tx_queue_pop(struct can_frame *frame) 121 | { 122 | struct can_frame *frm = NULL; 123 | 124 | if (!mq_is_empty(txq)) { 125 | sync_spinlock_lock(&txq->lock); 126 | mq_remove_msg(txq, frame); 127 | sync_spinlock_unlock(&txq->lock); 128 | frm = frame; 129 | } 130 | 131 | return frm; 132 | } 133 | 134 | /** 135 | * Add CAN message to RX queue. 136 | * 137 | * @frame: CAN message about to add. 138 | * 139 | * @return: On success, return 0, -1 otherwise. 140 | * 141 | * NOTE: Popping from the queue will block this function. 142 | * This function may block the IRQ handler. 143 | */ 144 | int rx_queue_push(struct can_frame *frame) 145 | { 146 | int ret = -1; 147 | 148 | if (!mq_is_full(rxq)) { 149 | sync_spinlock_lock(&rxq->lock); 150 | mq_append_msg(rxq, frame); 151 | sync_spinlock_unlock(&rxq->lock); 152 | ret = 0; 153 | } 154 | 155 | return ret; 156 | } 157 | 158 | /** 159 | * Retrieve CAN message from RX queue. 160 | * 161 | * @frame: CAN message about to fill-in . 162 | * 163 | * @return: On success, return frame address. 164 | * Return NULL if the queue is empty. 165 | * 166 | * NOTE: Pushing to the queue will block this function. 167 | */ 168 | struct can_frame *rx_queue_pop(struct can_frame *frame) 169 | { 170 | struct can_frame *frm = NULL; 171 | 172 | if (!mq_is_empty(rxq)) { 173 | sync_spinlock_lock(&rxq->lock); 174 | mq_remove_msg(rxq, frame); 175 | sync_spinlock_unlock(&rxq->lock); 176 | frm = frame; 177 | } 178 | 179 | return frm; 180 | } 181 | 182 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/can/src/test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | /* standard */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /* application common */ 13 | #include "can_inf.h" 14 | #include "spi_inf.h" 15 | #include "common.h" 16 | 17 | 18 | int run(void) 19 | { 20 | int error = 0; 21 | struct can_frame tx, rx; 22 | 23 | /* Initialize CAN controller. */ 24 | printf("Start CAN Test\n"); 25 | error = can_setup(125000); 26 | if (error < 0) { 27 | printf("Stop CAN Test.\n"); 28 | return -1; 29 | } 30 | 31 | /* Prepare CAN frame. */ 32 | tx.ident.id = 0x123; 33 | tx.ident.exide = 0; 34 | tx.ident.rtr = 0; 35 | tx.dlc = 8; 36 | tx.data[0] = 0x08; 37 | tx.data[1] = 0x07; 38 | tx.data[2] = 0x06; 39 | tx.data[3] = 0x05; 40 | tx.data[4] = 0x04; 41 | tx.data[5] = 0x03; 42 | tx.data[6] = 0x02; 43 | tx.data[7] = 0x01; 44 | 45 | while (1) { 46 | m_test_lock(); 47 | /* Send message */ 48 | can_send(tx); 49 | printf("Send: error(%d), id(%x), data(%x, %x, %x, %x, %x, %x, %x, %x)\n", 50 | error, tx.ident.id, 51 | tx.data[0], tx.data[1], tx.data[2], tx.data[3], 52 | tx.data[4], tx.data[5], tx.data[6], tx.data[7]); 53 | 54 | tx.ident.id++; 55 | 56 | /* Receive message */ 57 | error = can_try_recv(&rx); 58 | if (!error) { 59 | printf("Recv: error(%d), id(%x), data(%x, %x, %x, %x, %x, %x, %x, %x)\n", 60 | error, rx.ident.id, 61 | rx.data[0], rx.data[1], rx.data[2], rx.data[3], 62 | rx.data[4], rx.data[5], rx.data[6], rx.data[7]); 63 | } 64 | } 65 | 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/clk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(clk C) 10 | 11 | file(GLOB sources src/*.c) 12 | 13 | DeclareCAmkESComponent(clk 14 | SOURCES ${sources} 15 | INCLUDES include) 16 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/clk/clk.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | import "../../interfaces/clk.idl4"; 7 | 8 | 9 | component clk { 10 | provides clk_inf clktree; 11 | dataport Buf cmu_cpu_clk; 12 | dataport Buf cmu_top_clk; 13 | dataport Buf cmu_core_clk; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/clk/include/common.h: -------------------------------------------------------------------------------- 1 | ../../../include/common.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/clk/include/utils.h: -------------------------------------------------------------------------------- 1 | ../../../include/utils.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/clk/src/clk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | clock_sys_t clock_sys; 12 | 13 | unsigned int clktree_get_spi1_freq(void){ 14 | clk_t* clk; 15 | clk = clk_get_clock(&clock_sys, CLK_SPI1); 16 | return clk_get_freq(clk); 17 | } 18 | 19 | 20 | unsigned int clktree_set_spi1_freq(unsigned int rate){ 21 | clk_t* clk; 22 | clk = clk_get_clock(&clock_sys, CLK_SPI1); 23 | return clk_set_freq(clk, rate); 24 | } 25 | 26 | 27 | void clktree__init(void){ 28 | int err; 29 | err = exynos5_clock_sys_init(cmu_cpu_clk, 30 | cmu_core_clk, 31 | NULL, 32 | NULL, 33 | cmu_top_clk, 34 | NULL, 35 | NULL, 36 | NULL, 37 | NULL, 38 | NULL, 39 | &clock_sys); 40 | assert(!err); 41 | if(err){ 42 | printf("Failed to initialise clock tree\n"); 43 | } 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/gpio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(gpio C) 10 | 11 | file(GLOB sources src/*.c) 12 | 13 | DeclareCAmkESComponent(gpio 14 | SOURCES ${sources} 15 | INCLUDES include 16 | LIBS app_include) 17 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/gpio/gpio.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | import "../../interfaces/gpio.idl4"; 7 | 8 | component gpio { 9 | // control; 10 | provides gpio_inf gpio; 11 | // uses can_inf can; 12 | dataport Buf gpio1base; 13 | dataport Buf gpio2base; 14 | dataport Buf irqcbase; 15 | dataport Buf clk_tree; 16 | maybe consumes DataAvailable EINT14; 17 | emits IntEvent CANInt; 18 | consumes IntEventAck CANIntAck; 19 | 20 | consumes IRQGroup26 irq_grp26_int; 21 | consumes IRQGroup28 irq_grp28_int; 22 | consumes IRQGroup31 irq_grp31_int; 23 | consumes EXINT16_31 xint16_31_int; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/gpio/include/periph.h: -------------------------------------------------------------------------------- 1 | ../../../include/periph.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/pilot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(pilot C) 10 | 11 | file(GLOB sources src/*.c src/aeslib/*.c) 12 | 13 | DeclareCAmkESComponent(pilot 14 | SOURCES ${sources} 15 | INCLUDES src/aeslib) 16 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/pilot/pilot.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | import "../../interfaces/uart.idl4"; 7 | import "../../interfaces/pwm.idl4"; 8 | 9 | component pilot { 10 | uses uart_inf uart_gcs; 11 | dataport Buf gcs_buf; 12 | 13 | uses uart_inf uart_px4; 14 | dataport Buf px4_buf; 15 | 16 | uses pwm_inf pwm; 17 | emits pwm_signal signal; 18 | 19 | provides pilot_inf mavlink; 20 | 21 | emits restart restart_vm; 22 | } 23 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/pilot/src/aeslib/aes.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause */ 2 | 3 | /* 4 | --------------------------------------------------------------------------- 5 | Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved. 6 | 7 | The redistribution and use of this software (with or without changes) 8 | is allowed without the payment of fees or royalties provided that: 9 | 10 | source code distributions include the above copyright notice, this 11 | list of conditions and the following disclaimer; 12 | 13 | binary distributions include the above copyright notice, this list 14 | of conditions and the following disclaimer in their documentation. 15 | 16 | This software is provided 'as is' with no explicit or implied warranties 17 | in respect of its operation, including, but not limited to, correctness 18 | and fitness for purpose. 19 | --------------------------------------------------------------------------- 20 | Issue Date: 20/12/2007 21 | 22 | This file contains the definitions required to use AES in C. See aesopt.h 23 | for optimisation details. 24 | */ 25 | 26 | #ifndef _AES_H 27 | #define _AES_H 28 | 29 | // #include 30 | 31 | /* This include is used to find 8 & 32 bit unsigned integer types */ 32 | #include "brg_types.h" 33 | 34 | #if defined(__cplusplus) 35 | extern "C" 36 | { 37 | #endif 38 | 39 | #define AES_128 /* if a fast 128 bit key scheduler is needed */ 40 | 41 | /* The following must also be set in assembler files if being used */ 42 | 43 | #define AES_ENCRYPT /* if support for encryption is needed */ 44 | #define AES_DECRYPT /* if support for decryption is needed */ 45 | #define AES_REV_DKS /* define to reverse decryption key schedule */ 46 | 47 | #define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ 48 | #define N_COLS 4 /* the number of columns in the state */ 49 | 50 | /* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */ 51 | /* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */ 52 | /* or 44, 52 or 60 32-bit words. */ 53 | 54 | #if defined( AES_VAR ) || defined( AES_256 ) 55 | #define KS_LENGTH 60 56 | #elif defined( AES_192 ) 57 | #define KS_LENGTH 52 58 | #else 59 | #define KS_LENGTH 44 60 | #endif 61 | 62 | #define AES_RETURN INT_RETURN 63 | 64 | /* the character array 'inf' in the following structures is used */ 65 | /* to hold AES context information. This AES code uses cx->inf.b[0] */ 66 | /* to hold the number of rounds multiplied by 16. The other three */ 67 | /* elements can be used by code that implements additional modes */ 68 | 69 | typedef union 70 | { uint_32t l; 71 | uint_8t b[4]; 72 | } aes_inf; 73 | 74 | typedef struct 75 | { uint_32t ks[KS_LENGTH]; 76 | aes_inf inf; 77 | } aes_encrypt_ctx; 78 | 79 | typedef struct 80 | { uint_32t ks[KS_LENGTH]; 81 | aes_inf inf; 82 | } aes_decrypt_ctx; 83 | 84 | /* This routine must be called before first use if non-static */ 85 | /* tables are being used */ 86 | 87 | AES_RETURN aes_init(void); 88 | 89 | /* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */ 90 | /* those in the range 128 <= key_len <= 256 are given in bits */ 91 | 92 | #if defined( AES_ENCRYPT ) 93 | 94 | AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); 95 | AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); 96 | 97 | #endif 98 | 99 | #if defined( AES_DECRYPT ) 100 | 101 | AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); 102 | AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); 103 | 104 | #endif 105 | 106 | #if defined(__cplusplus) 107 | } 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/pilot/src/aeslib/commsec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #ifndef __COMMSEC_FOR_MAVLINK_H 7 | #define __COMMSEC_FOR_MAVLINK_H 8 | 9 | #define COMMSEC_SUCCEED 0 10 | #define COMMSEC_FAIL_BAD_BASE_STATION 1 11 | #define COMMSEC_FAIL_DUP_CTR 2 12 | #define COMMSEC_FAIL_CTR_ROLLOVER 3 13 | #define COMMSEC_FAIL_BAD_INPUT 4 14 | #define COMMSEC_FAIL_MSG_LENGTH_VIOLATES_ASSUMPTIONS 5 15 | #define COMMSEC_FAIL_GCM 6 16 | 17 | #include 18 | #include "gcm.h" 19 | 20 | #ifndef MAX_BASE_STATIONS 21 | // Adjust this freely. 22 | // It costs 4 bytes on the heap per additonal station. 23 | #define MAX_BASE_STATIONS 16 24 | #endif 25 | 26 | // GCM auth tag length in bytes 27 | // (do not adjust unless you are crypto savy) 28 | #define TAG_LEN 8 29 | 30 | // IV length in bytes. The IV is [ Salt | StationId | Counter] 31 | #define IV_LEN 12 32 | 33 | // Transmitted header len (the [ StationId | Counter ] portion of the IV) 34 | #define HEADER_LEN 8 35 | 36 | // This is tied to TAG_LEN - do not adjust unless you are GCM savy 37 | #define MAX_MESSAGE_LEN 512 38 | 39 | typedef struct { 40 | gcm_ctx encCtx; 41 | uint32_t encSalt; 42 | uint32_t myId; 43 | uint32_t myCounter; 44 | 45 | gcm_ctx decCtx; 46 | uint32_t decSalt; 47 | uint32_t mostRecentCounter[MAX_BASE_STATIONS]; 48 | } commsec_ctx; 49 | 50 | uint32_t securePkg_init( commsec_ctx *ctx, uint32_t myID 51 | , uint32_t decSalt, const uint8_t *rawDecKey 52 | , uint32_t encSalt, const uint8_t *rawEncKey); 53 | uint32_t securePkg_enc_in_place(commsec_ctx *ctx, uint8_t *msg, uint32_t msgStartIdx, uint32_t msgLength); 54 | uint32_t securePkg_enc( commsec_ctx *ctx, uint8_t *msg, uint32_t msgLen 55 | , uint8_t *ivStorage, uint8_t *tag); // Tag must be 64 bits 56 | uint32_t securePkg_dec(commsec_ctx *ctx, uint8_t *msg, uint32_t msgLen); 57 | void securePkg_zero(commsec_ctx *ctx); 58 | 59 | int securePkg_size_of_message(int pkgLen); 60 | int securePkg_size_of_package(int msgLen); 61 | 62 | #endif /* __COMMSEC_FOR_MAVLINK_H */ 63 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/pilot/src/aeslib/gf_convert.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-2-Clause */ 2 | 3 | /* 4 | --------------------------------------------------------------------------- 5 | Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved. 6 | 7 | The redistribution and use of this software (with or without changes) 8 | is allowed without the payment of fees or royalties provided that: 9 | 10 | source code distributions include the above copyright notice, this 11 | list of conditions and the following disclaimer; 12 | 13 | binary distributions include the above copyright notice, this list 14 | of conditions and the following disclaimer in their documentation. 15 | 16 | This software is provided 'as is' with no explicit or implied warranties 17 | in respect of its operation, including, but not limited to, correctness 18 | and fitness for purpose. 19 | --------------------------------------------------------------------------- 20 | Issue Date: 20/12/2007 21 | 22 | This file provides for conversion between different Galois Field 23 | representations. 24 | */ 25 | 26 | #include "mode_hdr.h" 27 | #include "gf128mul.h" 28 | 29 | #define DATA_256(q) {\ 30 | q(0x00), q(0x01), q(0x02), q(0x03), q(0x04), q(0x05), q(0x06), q(0x07),\ 31 | q(0x08), q(0x09), q(0x0a), q(0x0b), q(0x0c), q(0x0d), q(0x0e), q(0x0f),\ 32 | q(0x10), q(0x11), q(0x12), q(0x13), q(0x14), q(0x15), q(0x16), q(0x17),\ 33 | q(0x18), q(0x19), q(0x1a), q(0x1b), q(0x1c), q(0x1d), q(0x1e), q(0x1f),\ 34 | q(0x20), q(0x21), q(0x22), q(0x23), q(0x24), q(0x25), q(0x26), q(0x27),\ 35 | q(0x28), q(0x29), q(0x2a), q(0x2b), q(0x2c), q(0x2d), q(0x2e), q(0x2f),\ 36 | q(0x30), q(0x31), q(0x32), q(0x33), q(0x34), q(0x35), q(0x36), q(0x37),\ 37 | q(0x38), q(0x39), q(0x3a), q(0x3b), q(0x3c), q(0x3d), q(0x3e), q(0x3f),\ 38 | q(0x40), q(0x41), q(0x42), q(0x43), q(0x44), q(0x45), q(0x46), q(0x47),\ 39 | q(0x48), q(0x49), q(0x4a), q(0x4b), q(0x4c), q(0x4d), q(0x4e), q(0x4f),\ 40 | q(0x50), q(0x51), q(0x52), q(0x53), q(0x54), q(0x55), q(0x56), q(0x57),\ 41 | q(0x58), q(0x59), q(0x5a), q(0x5b), q(0x5c), q(0x5d), q(0x5e), q(0x5f),\ 42 | q(0x60), q(0x61), q(0x62), q(0x63), q(0x64), q(0x65), q(0x66), q(0x67),\ 43 | q(0x68), q(0x69), q(0x6a), q(0x6b), q(0x6c), q(0x6d), q(0x6e), q(0x6f),\ 44 | q(0x70), q(0x71), q(0x72), q(0x73), q(0x74), q(0x75), q(0x76), q(0x77),\ 45 | q(0x78), q(0x79), q(0x7a), q(0x7b), q(0x7c), q(0x7d), q(0x7e), q(0x7f),\ 46 | q(0x80), q(0x81), q(0x82), q(0x83), q(0x84), q(0x85), q(0x86), q(0x87),\ 47 | q(0x88), q(0x89), q(0x8a), q(0x8b), q(0x8c), q(0x8d), q(0x8e), q(0x8f),\ 48 | q(0x90), q(0x91), q(0x92), q(0x93), q(0x94), q(0x95), q(0x96), q(0x97),\ 49 | q(0x98), q(0x99), q(0x9a), q(0x9b), q(0x9c), q(0x9d), q(0x9e), q(0x9f),\ 50 | q(0xa0), q(0xa1), q(0xa2), q(0xa3), q(0xa4), q(0xa5), q(0xa6), q(0xa7),\ 51 | q(0xa8), q(0xa9), q(0xaa), q(0xab), q(0xac), q(0xad), q(0xae), q(0xaf),\ 52 | q(0xb0), q(0xb1), q(0xb2), q(0xb3), q(0xb4), q(0xb5), q(0xb6), q(0xb7),\ 53 | q(0xb8), q(0xb9), q(0xba), q(0xbb), q(0xbc), q(0xbd), q(0xbe), q(0xbf),\ 54 | q(0xc0), q(0xc1), q(0xc2), q(0xc3), q(0xc4), q(0xc5), q(0xc6), q(0xc7),\ 55 | q(0xc8), q(0xc9), q(0xca), q(0xcb), q(0xcc), q(0xcd), q(0xce), q(0xcf),\ 56 | q(0xd0), q(0xd1), q(0xd2), q(0xd3), q(0xd4), q(0xd5), q(0xd6), q(0xd7),\ 57 | q(0xd8), q(0xd9), q(0xda), q(0xdb), q(0xdc), q(0xdd), q(0xde), q(0xdf),\ 58 | q(0xe0), q(0xe1), q(0xe2), q(0xe3), q(0xe4), q(0xe5), q(0xe6), q(0xe7),\ 59 | q(0xe8), q(0xe9), q(0xea), q(0xeb), q(0xec), q(0xed), q(0xee), q(0xef),\ 60 | q(0xf0), q(0xf1), q(0xf2), q(0xf3), q(0xf4), q(0xf5), q(0xf6), q(0xf7),\ 61 | q(0xf8), q(0xf9), q(0xfa), q(0xfb), q(0xfc), q(0xfd), q(0xfe), q(0xff) } 62 | 63 | #define reverse_byte(i) ( \ 64 | (i & 0x80 ? 0x01 : 0) | (i & 0x40 ? 0x02 : 0) | \ 65 | (i & 0x20 ? 0x04 : 0) | (i & 0x10 ? 0x08 : 0) | \ 66 | (i & 0x08 ? 0x10 : 0) | (i & 0x04 ? 0x20 : 0) | \ 67 | (i & 0x02 ? 0x40 : 0) | (i & 0x01 ? 0x80 : 0) ) 68 | 69 | static const uint_8t rb_tab[256] = DATA_256(reverse_byte); 70 | 71 | static void reverse_bits(gf_t d, const gf_t s) 72 | { int j; 73 | for(j = 0 ; j < 16; ++j) 74 | { 75 | ((uint_8t*)d)[j] = rb_tab[((uint_8t*)s)[j]]; 76 | } 77 | } 78 | 79 | void convert_representation(gf_t dest, const gf_t source, transform rev) 80 | { 81 | if(rev & REVERSE_BITS) 82 | { 83 | reverse_bits(dest, source); 84 | if(rev & REVERSE_BYTES) 85 | bswap128_block(dest, dest); 86 | } 87 | else if(rev & REVERSE_BYTES) 88 | bswap128_block(dest, source); 89 | else if(dest != source) 90 | memcpy(dest, source, GF_BYTE_LEN); 91 | } 92 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/pilot/src/pilot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "commsec.h" 12 | 13 | /* the raw payload is 80 byte mavlink packets, these are wrapped 14 | * around the commsec protocal */ 15 | #define MAVLINK_LEN 80 16 | #define COMMSEC_PAYLOAD_LEN (securePkg_size_of_package(80)) 17 | 18 | /* our encryption keys. We only actually decrypt in one direction (RX) 19 | * so the key for transmit can be a dummy */ 20 | static uint8_t base_to_uav_key[16] = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}; //RX 21 | static uint8_t uav_to_base_key[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; //TX 22 | static uint32_t b2uSalt = 9219834; 23 | static uint32_t u2bSalt = 284920; 24 | /* state for decryption */ 25 | static commsec_ctx decrypt_state; 26 | 27 | static void init_decrypt() { 28 | /* just need to init the state with the keys and salts */ 29 | securePkg_init(&decrypt_state, 0, b2uSalt, base_to_uav_key, 30 | u2bSalt, uav_to_base_key); 31 | } 32 | 33 | /* returns 1 (true) if packet was decrypted successfully, 0 on failure */ 34 | static int try_decrypt(char *buf, int msgsize) { 35 | /* our messages contain a commsec payload around a 2 byte frame, ensure we have this much */ 36 | if (msgsize < 2 + COMMSEC_PAYLOAD_LEN) { 37 | return 0; 38 | } 39 | /* expect frame header of 0x7e first */ 40 | if (buf[0] != 0x7e) { 41 | return 0; 42 | } 43 | /* tag after frame header should be 0 for air-data messages */ 44 | if (buf[1] != 0) { 45 | return 0; 46 | } 47 | /* attempt to decrypt the actual frame to a temporary buffer */ 48 | uint8_t temp[COMMSEC_PAYLOAD_LEN]; 49 | /* skip the first two bytes that make up the frame header */ 50 | memcpy(temp, buf + 2, COMMSEC_PAYLOAD_LEN); 51 | uint32_t ret; 52 | ret = securePkg_dec(&decrypt_state, temp, COMMSEC_PAYLOAD_LEN); 53 | if (ret != 0) { 54 | return 0; 55 | } 56 | /* success */ 57 | return 1; 58 | } 59 | 60 | struct packet { 61 | char *data; 62 | uint32_t len; 63 | }; 64 | 65 | static struct packet pkt_gcs; //packet to be sent to GCS 66 | static struct packet pkt_px4; //packet to be sent to UAV 67 | static struct packet check_buf; //CMD received from GCS 68 | 69 | /* Max number of errors */ 70 | #define MAX_ERR 20 71 | static uint32_t err_cnt = 0; //Error counter 72 | 73 | /* CAmkES initialization */ 74 | #define CHK_BUF_SIZE 256 75 | void pre_init(void) 76 | { 77 | pkt_gcs.data = (char*)gcs_buf; 78 | pkt_gcs.len = 0; 79 | 80 | pkt_px4.data = (char*)px4_buf; 81 | pkt_px4.len = 0; 82 | 83 | check_buf.data = malloc(CHK_BUF_SIZE); 84 | assert(check_buf.data); 85 | check_buf.len = 0; 86 | 87 | init_decrypt(); 88 | } 89 | 90 | /* For debug */ 91 | static void UNUSED print_pkt(struct packet *pkt, int uart) 92 | { 93 | printf("From %d: ", uart); 94 | for (int i = 0; i < pkt->len; i++) { 95 | if (i % 16 == 0) { 96 | printf("\n"); 97 | } 98 | printf("%02X ", pkt->data[i]); 99 | } 100 | printf("\n"); 101 | } 102 | 103 | /* Decrypt packet */ 104 | static int UNUSED check_packet(struct packet *pkt, char c) 105 | { 106 | int ret; 107 | 108 | pkt->data[pkt->len++] = c; 109 | 110 | /* The packet is complete. */ 111 | if (c == 0x7e && pkt->len > 1) { 112 | //print_pkt(pkt, 1); 113 | ret = try_decrypt(pkt->data, pkt->len); 114 | if (ret) { 115 | printf("True...\n"); 116 | } else { 117 | printf("Fail...\n"); 118 | err_cnt++; 119 | } 120 | pkt->len = 0; 121 | } 122 | return 0; 123 | } 124 | 125 | #define TRIGGER_LVL 20 //The GCS is expecting a very low latency. 126 | void mavlink_recv(int uart_num, int c) 127 | { 128 | struct packet *pkt = NULL; 129 | int(*func)(int,int) = NULL; 130 | 131 | switch (uart_num) { 132 | case 1: 133 | pkt = &pkt_px4; 134 | func = uart_px4_write; 135 | 136 | /* Put data from GCS into the buffer for checking. */ 137 | // check_packet(&check_buf, c); 138 | break; 139 | case 3: 140 | pkt = &pkt_gcs; 141 | func = uart_gcs_write; 142 | break; 143 | default: 144 | pkt = NULL; 145 | break; 146 | } 147 | 148 | pkt->data[pkt->len++] = c; 149 | if (pkt->len == TRIGGER_LVL) { 150 | func(0, pkt->len); 151 | pkt->len = 0; 152 | signal_emit(); 153 | } 154 | 155 | /* XXX: Borrow the unused error counter to trigger the VM restart. */ 156 | err_cnt++; 157 | if (err_cnt > MAX_ERR) { 158 | printf("We are under attack!!!\n"); 159 | restart_vm_emit(); 160 | err_cnt = 0; 161 | } 162 | } 163 | 164 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/pwm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(pwm C) 10 | 11 | file(GLOB sources src/*.c) 12 | 13 | DeclareCAmkESComponent(pwm 14 | SOURCES ${sources}) 15 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/pwm/pwm.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | /* 7 | * This PPM driver only outputs PPM values received to the screen 8 | */ 9 | 10 | component pwm { 11 | control; 12 | provides pwm_inf pwm; 13 | consumes pwm_signal signal; 14 | consumes timer_evt timer_update; 15 | 16 | dataport Buf i2c0; 17 | consumes DataAvailable i2c0_int; 18 | 19 | has semaphore bus_sem; 20 | has mutex set_motors; 21 | 22 | has mutex sig; 23 | } 24 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/spi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(spi C) 10 | 11 | file(GLOB sources src/*.c) 12 | 13 | DeclareCAmkESComponent(spi 14 | SOURCES ${sources} 15 | INCLUDES include) 16 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/spi/include/common.h: -------------------------------------------------------------------------------- 1 | ../../../include/common.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/spi/include/spi_inf.h: -------------------------------------------------------------------------------- 1 | ../../../include/spi_inf.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/spi/include/utils.h: -------------------------------------------------------------------------------- 1 | ../../../include/utils.h -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/spi/spi.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | import "../../interfaces/clk.idl4"; 7 | import "../../interfaces/spi.idl4"; 8 | import "../../interfaces/gpio.idl4"; 9 | 10 | component spi { 11 | uses gpio_inf gpio; 12 | uses clk_inf clktree; 13 | provides spi_inf spi; 14 | dataport Buf spi1_reg; 15 | dataport Buf spi1_can; 16 | consumes DataAvailable spi1_int; 17 | 18 | has semaphore bus_sem; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(timer C) 10 | 11 | file(GLOB sources src/*.c) 12 | 13 | DeclareCAmkESComponent(timer 14 | SOURCES ${sources}) 15 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/timer/src/pwm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | pwm_t pwm; 14 | pwm_t *timer_drv = NULL; 15 | static ps_io_ops_t io_ops; 16 | 17 | void timer_handle_event(void *token, ltimer_event_t event) 18 | { 19 | 20 | /* Signal other components. */ 21 | timer_update_emit(); 22 | 23 | } 24 | 25 | void pre_init() 26 | { 27 | int error = camkes_io_ops(&io_ops); 28 | ZF_LOGF_IF(error, "Failed to get camkes_io_ops"); 29 | 30 | error = pwm_init(&pwm, io_ops, PWM_TIMER_PATH, timer_handle_event, NULL); 31 | if (error) { 32 | printf("PWM timer does not exist.\n"); 33 | } 34 | timer_drv = &pwm; 35 | 36 | /* Run in periodic mode and start the timer. */ 37 | pwm_set_timeout(timer_drv, NS_IN_S, true); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/timer/src/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | /* 7 | * Timer interface implementation. 8 | */ 9 | 10 | #include 11 | 12 | #include 13 | 14 | extern pwm_t *timer_drv; 15 | 16 | /* 17 | * Get current time. 18 | * 19 | * TODO: platsupport returns a 64-bit time. 20 | */ 21 | int tm_get_time() 22 | { 23 | return pwm_get_time(timer_drv); 24 | } 25 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/timer/timer.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | import "../../interfaces/timer.idl4"; 7 | 8 | 9 | component timer { 10 | emits Dummy dummy_source; 11 | consumes Dummy pmu; 12 | provides timer_inf tm; 13 | emits timer_evt timer_update; 14 | 15 | composition { 16 | connection seL4DTBHardware pmu_conn(from dummy_source, to pmu); 17 | } 18 | configuration { 19 | pmu.dtb = dtb({ "path" : "/soc/pwm@12dd0000" }); 20 | pmu.generate_interrupts = 1; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/uart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(uart C) 10 | 11 | file(GLOB sources src/*.c) 12 | 13 | DeclareCAmkESComponent(uart 14 | SOURCES ${sources}) 15 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/components/uart/uart.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | import "../../interfaces/uart.idl4"; 7 | import "../../interfaces/pilot.idl4"; 8 | 9 | component uart { 10 | control; 11 | 12 | provides uart_inf uart; 13 | dataport Buf uart0base; 14 | dataport Buf client_buf; 15 | consumes DataAvailable interrupt; 16 | has semaphore read_sem; 17 | has semaphore write_sem; 18 | attribute int ID; 19 | 20 | uses pilot_inf pilot; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/include/can_inf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #ifndef CAN_INF_H_ 7 | #define CAN_INF_H_ 8 | 9 | #include 10 | 11 | #define CAN_SID_BITS 11 12 | #define CAN_EID_BITS 18 13 | #define CAN_EID_MASK 0x3FFFFU 14 | 15 | #define CAN_MAX_DLC 8 16 | 17 | /** 18 | * Transmission Priority 19 | */ 20 | enum can_frame_priority { 21 | LOW = 0, 22 | MED_LOW, 23 | MED_HIGH, 24 | HIGH 25 | }; 26 | 27 | /** CAN Arbitration Field 28 | * 29 | * @id: CAN id(11 bits for standard frame, 29 bits if extended frame). 30 | * @exide: Extended frame flag. 31 | * @rtr: Remote Transmission Request. 32 | * @err: Error frame flag. 33 | */ 34 | struct can_id { 35 | uint32_t id:29; 36 | uint32_t exide:1; 37 | uint32_t rtr:1; 38 | uint32_t err:1; 39 | }; 40 | typedef struct can_id can_id_t; 41 | 42 | /** 43 | * Basic CAN frame structure. 44 | * 45 | * @ident: Identifier. 46 | * @prio: Transmit priority. 47 | * @dlc: Data Length Code(0 ~ 8). 48 | * @data: frame payload(8 bytes maximum). 49 | * 50 | * NOTE: The priority is MCP2515 only, it is not related to any prioritization 51 | * implicit in the CAN protocol. 52 | */ 53 | struct can_frame { 54 | struct can_id ident; 55 | uint8_t prio:2; 56 | uint8_t dlc:4; 57 | uint8_t data[CAN_MAX_DLC] __attribute__((aligned(8))); 58 | }; 59 | typedef struct can_frame can_frame_t; 60 | 61 | /** 62 | * CAN RX buffer filter. 63 | * 64 | * @id: CAN frame identifier bits which are accepted. 65 | * @mask: CAN mask. 66 | */ 67 | struct can_filter { 68 | uint32_t id; 69 | uint32_t mask; 70 | }; 71 | typedef struct can_filter can_filter_t; 72 | 73 | #endif /* CAN_INF_H_ */ 74 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/include/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | #ifndef COMMON_H 7 | #define COMMON_H 8 | 9 | /* Application IDs*/ 10 | #define CLIENT_APP_ID 0 11 | #define CAN_APP_ID 1 12 | #define NUM_APPS 2 13 | 14 | /* Generic Constants */ 15 | #define TRUE 1 16 | #define FALSE 0 17 | 18 | typedef enum{ 19 | CLEAR = 2, 20 | ENABLE = 1, 21 | DISABLE = 0 22 | }OPTION; 23 | 24 | #define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1)) 25 | #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/include/spi_inf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | /* 7 | * spi external interfaces 8 | */ 9 | 10 | #ifndef SPI_INF_H 11 | #define SPI_INF_H 12 | 13 | #include 14 | #include 15 | 16 | #define SPI_TRANS_MAX_SIZE 255 17 | 18 | typedef struct spi_buf_t{ 19 | uint8_t txbuf[SPI_TRANS_MAX_SIZE]; 20 | uint8_t rxbuf[SPI_TRANS_MAX_SIZE]; 21 | volatile bool lock; //shared buffer lock 22 | }spi_dev_port, *spi_dev_port_p; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/include/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | /* 7 | * utils.h 8 | * 9 | * Created on: Aug 6, 2013 10 | * Author: jxie 11 | */ 12 | 13 | #ifndef UTILS_H_ 14 | #define UTILS_H_ 15 | 16 | 17 | /** 18 | * Frequently used helper functions. 19 | */ 20 | #include 21 | #include 22 | #include 23 | 24 | /** 25 | * Read from 32-bit register. 26 | */ 27 | inline uint32_t readl(const void *address) 28 | { 29 | //printf("reading @ %x\n", address); 30 | return *((volatile uint32_t *)(address)); 31 | } 32 | 33 | /** 34 | * Write to 32-bit register. 35 | */ 36 | inline void writel(uint32_t value, const void *address) 37 | { 38 | //printf("writing %x @ %x\n", value, address); 39 | *((volatile uint32_t *)(address)) = value; 40 | } 41 | 42 | inline void spinlock_lock(int *lock) 43 | { 44 | while (!__sync_bool_compare_and_swap(lock, 0, 1)); 45 | } 46 | 47 | inline void spinlock_unlock(int *lock) 48 | { 49 | while (!__sync_bool_compare_and_swap(lock, 1, 0)); 50 | } 51 | 52 | inline void barrier(void) 53 | { 54 | __sync_synchronize(); 55 | } 56 | 57 | static inline uint32_t 58 | __be32_to_cpu(uint32_t x){ 59 | int i; 60 | uint32_t ret; 61 | char* a = (char*)&x; 62 | char* b = (char*)&ret; 63 | for(i = 0; i < sizeof(x); i++){ 64 | b[i] = a[sizeof(x) - i - 1]; 65 | } 66 | return ret; 67 | } 68 | 69 | /* A guess based on a 800MHz memory clock */ 70 | static __inline__ void udelay(uint64_t usec) 71 | { 72 | volatile static int x; 73 | while (usec--) { 74 | for (x = 0; x < 4000; x++) 75 | ; 76 | } 77 | } 78 | 79 | static __inline__ int min(int a, int b) 80 | { 81 | return a > b ? b : a; 82 | } 83 | 84 | static __inline__ void _acquire_spin_lock(volatile bool* lock){ 85 | while(!__sync_bool_compare_and_swap(lock,0,1)){ 86 | //seL4_Yield(); 87 | } 88 | } 89 | 90 | static __inline__ void _release_spin_lock(volatile bool* lock){ 91 | //release lock 92 | //*lock = 0; 93 | __sync_bool_compare_and_swap(lock,1,0); 94 | } 95 | 96 | static __inline__ void clrbits_le32(uint32_t * reg, uint32_t mask){ 97 | *reg = *reg & (~mask); 98 | } 99 | 100 | static __inline__ void setbits_le32(uint32_t * reg, uint32_t mask){ 101 | *reg = *reg | mask; 102 | } 103 | 104 | static __inline__ void clrsetbits_le32(uint32_t *reg, uint32_t clrm, uint32_t setm){ 105 | *reg = ((*reg) & (~clrm)) | (setm); 106 | } 107 | 108 | 109 | /* 110 | * General Purpose Utilities 111 | */ 112 | #define min(X, Y) \ 113 | ({ typeof(X) __x = (X); \ 114 | typeof(Y) __y = (Y); \ 115 | (__x < __y) ? __x : __y; }) 116 | 117 | #define max(X, Y) \ 118 | ({ typeof(X) __x = (X); \ 119 | typeof(Y) __y = (Y); \ 120 | (__x > __y) ? __x : __y; }) 121 | 122 | #define min3(X, Y, Z) \ 123 | ({ typeof(X) __x = (X); \ 124 | typeof(Y) __y = (Y); \ 125 | typeof(Z) __z = (Z); \ 126 | __x < __y ? (__x < __z ? __x : __z) : \ 127 | (__y < __z ? __y : __z); }) 128 | 129 | #define max3(X, Y, Z) \ 130 | ({ typeof(X) __x = (X); \ 131 | typeof(Y) __y = (Y); \ 132 | typeof(Z) __z = (Z); \ 133 | __x > __y ? (__x > __z ? __x : __z) : \ 134 | (__y > __z ? __y : __z); }) 135 | 136 | #define MIN3(x, y, z) min3(x, y, z) 137 | #define MAX3(x, y, z) max3(x, y, z) 138 | 139 | /* 140 | * Return the absolute value of a number. 141 | * 142 | * This handles unsigned and signed longs, ints, shorts and chars. For all 143 | * input types abs() returns a signed long. 144 | * 145 | */ 146 | #define abs(x) ({ \ 147 | long ret; \ 148 | if (sizeof(x) == sizeof(long)) { \ 149 | long __x = (x); \ 150 | ret = (__x < 0) ? -__x : __x; \ 151 | } else { \ 152 | int __x = (x); \ 153 | ret = (__x < 0) ? -__x : __x; \ 154 | } \ 155 | ret; \ 156 | }) 157 | 158 | #endif /* UTILS_H_ */ 159 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/interfaces/can.idl4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | procedure can_inf { 7 | include "can_inf.h"; 8 | int setup(in int baudrate); 9 | void send(in can_frame_t frame); 10 | void recv(out can_frame_t frame); 11 | int try_recv(out can_frame_t frame); 12 | int set_filter(in can_id_t ident, in unsigned int mask); 13 | void clear_filter(in int filter_id); 14 | void disable_filtering(void); 15 | }; 16 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/interfaces/clk.idl4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | procedure clk_inf { 7 | unsigned int set_spi1_freq(in unsigned int hz); 8 | unsigned int get_spi1_freq(void); 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/interfaces/gpio.idl4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | procedure gpio_inf{ 7 | // SPI chip select control 8 | void spi_can_nss(in int state); 9 | void spi_mpu_nss(in int state); 10 | void spi_acc_mag_nss(in int state); 11 | void spi_gyro_nss(in int state); 12 | void spi_baro_nss(in int state); 13 | void spi_ext_nss(in int state); 14 | }; 15 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/interfaces/pilot.idl4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | procedure pilot_inf { 7 | void recv(in int uart_num, in int c); 8 | }; 9 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/interfaces/pwm.idl4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | procedure pwm_inf { 7 | void set_motors(in double fl, in double fr, in double bl, in double br); 8 | 9 | /* led->[0,16), level->[0->4096] */ 10 | void set_led(in int led, in int level); 11 | 12 | /* Sent from the VMM when the VM writes /data/ to address 0x30000000 */ 13 | void vmsig(in int data); 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/interfaces/spi.idl4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | procedure spi_inf { 8 | int transfer(in int id, in unsigned int wcount, in unsigned int rcount); 9 | int transfer_byte(in int id, in char byte); 10 | }; 11 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/interfaces/timer.idl4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | procedure timer_inf { 7 | int get_time(); 8 | }; 9 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/interfaces/uart.idl4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | procedure uart_inf { 7 | // int read(in int uart_num, in int rsize); 8 | int write(in int uart_num, in int wsize); 9 | }; 10 | -------------------------------------------------------------------------------- /apps/Arm/odroid_vm/settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | set(PLATFORM "exynos5410" CACHE STRING "" FORCE) 8 | set(VmDtbFile ON CACHE BOOL "provide dtb" FORCE) 9 | -------------------------------------------------------------------------------- /apps/Arm/vm_cross_connector/components/CrossvmInit/crossvm_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | int run(void) 11 | { 12 | memset(dest, '\0', 4096); 13 | strcpy(dest, "This is a crossvm dataport test string\n"); 14 | 15 | while (1) { 16 | ready_wait(); 17 | printf("Got an event\n"); 18 | done_emit_underlying(); 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /apps/Arm/vm_cross_connector/overlay_files/init_scripts/cross_vm_module_init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | insmod /lib/modules/4.14.87/kernel/drivers/vmm/connection.ko 9 | -------------------------------------------------------------------------------- /apps/Arm/vm_cross_connector/overlay_files/init_scripts/cross_vm_test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | set -e 9 | 10 | dataport_read /dev/uio0 4096 11 | echo -ne "This is a test user string\n\0" | dataport_write /dev/uio0 4096 12 | dataport_read /dev/uio0 4096 13 | consumes_event_wait /dev/uio0 & 14 | sleep 1 15 | emits_event_emit /dev/uio0 16 | wait 17 | echo "Finished crossvm test script" 18 | -------------------------------------------------------------------------------- /apps/Arm/vm_cross_connector/qemu-arm-virt/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 10 | #define VM_RAM_BASE 0x40000000 11 | #define VM_RAM_SIZE 0x20000000 12 | #define VM_RAM_OFFSET 0x00000000 13 | #define VM_DTB_ADDR 0x4F000000 14 | #define VM_INITRD_ADDR 0x4D700000 15 | 16 | assembly { 17 | composition {} 18 | configuration { 19 | 20 | vm0.linux_address_config = { 21 | "linux_ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 22 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 23 | "linux_ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 24 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 25 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 26 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR) 28 | }; 29 | vm0.linux_image_config = { 30 | "linux_bootcmdline" : "pci=nomsi,realloc=off,bios initcall_blacklist=clk_disable_unused", 31 | "linux_stdout" : "/pl011@9000000", 32 | }; 33 | 34 | vm0.dtb = dtb([ 35 | {"path": "/pl011@9000000"}, 36 | ]); 37 | 38 | vm0.untyped_mmios = [ 39 | "0x8040000:12", // Interrupt Controller Virtual CPU interface (Virtual Machine view) 40 | "0x40000000:29", // Linux kernel memory regions 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /apps/Arm/vm_cross_connector/settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | set(supported "exynos5422;qemu-arm-virt") 8 | if(NOT "${PLATFORM}" IN_LIST supported) 9 | message(FATAL_ERROR "PLATFORM: ${PLATFORM} not supported. 10 | Supported: ${supported}") 11 | endif() 12 | set(VmPCISupport ON CACHE BOOL "" FORCE) 13 | set(LibUSB OFF CACHE BOOL "" FORCE) 14 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 15 | if(${PLATFORM} STREQUAL "qemu-arm-virt") 16 | # force cpu 17 | set(QEMU_MEMORY "2048") 18 | set(KernelArmCPU cortex-a53 CACHE STRING "" FORCE) 19 | endif() 20 | -------------------------------------------------------------------------------- /apps/Arm/vm_cross_connector/src/cross_vm_connections.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef CONFIG_PLAT_QEMU_ARM_VIRT 16 | #define CONNECTION_BASE_ADDRESS 0xDF000000 17 | #else 18 | #define CONNECTION_BASE_ADDRESS 0x3F000000 19 | #endif 20 | 21 | // these are defined in the dataport's glue code 22 | extern dataport_caps_handle_t crossvm_dp_0_handle; 23 | extern dataport_caps_handle_t crossvm_dp_1_handle; 24 | 25 | static struct camkes_crossvm_connection connections[] = { 26 | {&crossvm_dp_0_handle, ready_emit, -1, "conn_0"}, 27 | {&crossvm_dp_1_handle, NULL, -1, "conn_1"} 28 | }; 29 | 30 | static int consume_callback(vm_t *vm, void *cookie) 31 | { 32 | consume_connection_event(vm, connections[0].consume_badge, true); 33 | return 0; 34 | } 35 | 36 | extern seL4_Word done_notification_badge(void); 37 | void init_cross_vm_connections(vm_t *vm, void *cookie) 38 | { 39 | connections[0].consume_badge = done_notification_badge(); 40 | int err = register_async_event_handler(connections[0].consume_badge, consume_callback, NULL); 41 | ZF_LOGF_IF(err, "Failed to register_async_event_handler for init_cross_vm_connections."); 42 | 43 | cross_vm_connections_init(vm, CONNECTION_BASE_ADDRESS, connections, ARRAY_SIZE(connections)); 44 | } 45 | 46 | DEFINE_MODULE(cross_vm_connections, NULL, init_cross_vm_connections) 47 | -------------------------------------------------------------------------------- /apps/Arm/vm_cross_connector/vm_cross_connector.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | import ; 10 | import ; 11 | import ; 12 | import ; 13 | import ; 14 | import ; 15 | import ; 16 | import ; 17 | import ; 18 | 19 | #define FIRST_CROSS_VM_BADGE (1 << 3) 20 | 21 | component CrossvmInit { 22 | control; 23 | consumes Ready ready; 24 | emits Done done; 25 | dataport Buf(4096) dest; 26 | dataport Buf(4096) src; 27 | } 28 | 29 | component VM { 30 | VM_INIT_DEF() 31 | dataport Buf(4096) crossvm_dp_0; 32 | dataport Buf(4096) crossvm_dp_1; 33 | emits Ready ready; 34 | consumes Done done; 35 | } 36 | 37 | assembly { 38 | composition { 39 | VM_GENERAL_COMPOSITION_DEF() 40 | VM_COMPOSITION_DEF(0) 41 | component CrossvmInit crossvm_init; 42 | 43 | connection seL4Notification event_conn_0(from vm0.ready, 44 | to crossvm_init.ready); 45 | connection seL4GlobalAsynch event_conn_1(from crossvm_init.done, 46 | to vm0.done); 47 | connection seL4SharedDataWithCaps cross_vm_conn_0(from crossvm_init.dest, 48 | to vm0.crossvm_dp_0); 49 | connection seL4SharedDataWithCaps cross_vm_conn_1(from crossvm_init.src, 50 | to vm0.crossvm_dp_1); 51 | connection seL4VMDTBPassthrough vm_dtb(from vm0.dtb_self, to vm0.dtb); 52 | } 53 | configuration { 54 | VM_GENERAL_CONFIGURATION_DEF() 55 | VM_CONFIGURATION_DEF(0) 56 | 57 | vm0.num_extra_frame_caps = 0; 58 | vm0.extra_frame_map_address = 0; 59 | vm0.cnode_size_bits = 23; 60 | vm0.simple_untyped24_pool = 12; 61 | 62 | vm0.crossvm_dp_0_id = 0; 63 | vm0.crossvm_dp_0_size = 4096; 64 | vm0.crossvm_dp_1_id = 0; 65 | vm0.crossvm_dp_1_size = 4096; 66 | 67 | 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(camkes-vm-introspect C) 10 | 11 | include(${CAMKES_ARM_VM_HELPERS_PATH}) 12 | find_package(camkes-vm-linux REQUIRED) 13 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 14 | include(${CAMKES_VM_LINUX_MODULE_HELPERS_PATH}) 15 | include(${CAMKES_VM_LINUX_SOURCE_HELPERS_PATH}) 16 | include(${CAMKES_VM_LINUX_MODULE_HELPERS_PATH}) 17 | include(ExternalProject) 18 | include(external-project-helpers) 19 | 20 | if("${KernelARMPlatform}" STREQUAL "exynos5422") 21 | set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422") 22 | set(linux_repo "https://github.com/hardkernel/linux.git") 23 | set(linux_tag "4.14.87-153") 24 | set(linux_arch "arm") 25 | set(linux_cross_compile "arm-linux-gnueabi-") 26 | 27 | find_package(camkes-vm-linux REQUIRED) 28 | 29 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 30 | 31 | set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422") 32 | 33 | # Generate overlayed rootfs 34 | set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/exynos5422/rootfs.cpio.gz") 35 | 36 | elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt") 37 | set(cpp_flags "-DKERNELARMPLATFORM_QEMU-ARM-VIRT") 38 | set(linux_repo "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git") 39 | set(linux_tag "v4.9.189") 40 | set(linux_arch "arm64") 41 | set(linux_cross_compile "aarch64-linux-gnu-") 42 | 43 | find_package(camkes-vm-linux REQUIRED) 44 | 45 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 46 | 47 | include(simulation) 48 | 49 | set(SIMULATION ON CACHE BOOL "Generate simulation script to run qemu with the proper arguments") 50 | 51 | if(SIMULATION) 52 | GenerateSimulateScript() 53 | endif() 54 | 55 | endif() 56 | 57 | AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux") 58 | 59 | set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/rootfs_crossvm.cpio.gz") 60 | 61 | ExternalProject_Add( 62 | introspect-app 63 | URL 64 | file:///${CAMKES_VM_LINUX_DIR}/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/pkgs/introspect 65 | BINARY_DIR 66 | ${CMAKE_CURRENT_BINARY_DIR}/introspect-app 67 | INSTALL_COMMAND 68 | "" 69 | BUILD_ALWAYS 70 | ON 71 | EXCLUDE_FROM_ALL 72 | CMAKE_ARGS 73 | -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} 74 | ) 75 | 76 | AddExternalProjFilesToOverlay( 77 | introspect-app 78 | ${CMAKE_CURRENT_BINARY_DIR}/introspect-app 79 | overlay 80 | "usr/bin" 81 | FILES 82 | introspect 83 | ) 84 | 85 | # Add script to initialise dataport module 86 | AddFileToOverlayDir( 87 | "S90crossvm_module_init" 88 | ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/init_scripts/introspect_dataport_init 89 | "etc/init.d" 90 | overlay 91 | ) 92 | 93 | AddFileToOverlayDir( 94 | "S91crossvm_test" 95 | ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/init_scripts/introspect_vm_test 96 | "etc/init.d" 97 | overlay 98 | ) 99 | 100 | # Construct new rootfs 101 | AddOverlayDirToRootfs( 102 | overlay 103 | ${rootfs_file} 104 | "buildroot" 105 | "rootfs_install" 106 | output_overlayed_rootfs_location 107 | rootfs_target 108 | GZIP 109 | ) 110 | 111 | AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target) 112 | 113 | AddCamkesCPPFlag( 114 | cpp_flags 115 | CONFIG_VARS 116 | VmEmmc2NoDMA 117 | VmVUSB 118 | VmVchan 119 | Tk1DeviceFwd 120 | Tk1Insecure 121 | VmVirtioNetVirtqueue 122 | ) 123 | 124 | DefineCAmkESVMFileServer() 125 | 126 | CAmkESAddImportPath(${KernelARMPlatform}) 127 | 128 | # Define our VM Component with out cross vm dataports glue code 129 | DeclareCAmkESComponent(VM SOURCES src/cross_vm_connection.c src/init_dataport_ram.c) 130 | 131 | DeclareCAmkESComponent(introspect_memdev SOURCES component/introspect_component.c) 132 | 133 | # Declare root server 134 | DeclareCAmkESRootserver( 135 | vm_introspect.camkes 136 | CPP_FLAGS 137 | ${cpp_flags} 138 | CPP_INCLUDES 139 | ${CAMKES_VM_DIR}/components/VM_Arm 140 | ) 141 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/component/introspect_component.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define RAM_BASE 0x40000000 11 | #define N 10 12 | 13 | uint32_t fib_buf[N]; 14 | 15 | int run(void) 16 | { 17 | while (1) { 18 | ready_wait(); 19 | printf("introspect: Got an event\n"); 20 | 21 | seL4_Word paddr = *(seL4_Word *)introspect_data; 22 | printf("paddr in component 0x%x\n", paddr); 23 | 24 | seL4_Word offset = paddr - RAM_BASE; 25 | 26 | printf("offset in component 0x%x\n", offset); 27 | 28 | memcpy(fib_buf, ((char *)memdev + offset), sizeof(uint32_t) * N); 29 | 30 | //print data from inside linux process 31 | for (int i = 0; i < 10; i++) { 32 | printf("camkes_fib[%d]@%p = %d, ", i, (fib_buf + i), fib_buf[i]); 33 | } 34 | 35 | printf("\n"); 36 | done_emit(); 37 | } 38 | 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/overlay_files/init_scripts/introspect_dataport_init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | insmod /lib/modules/4.14.87/kernel/drivers/vmm/connection.ko 9 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/overlay_files/init_scripts/introspect_vm_test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | set -e 9 | 10 | /usr/bin/introspect 11 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/qemu-arm-virt/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_INITRD_MAX_SIZE 0xc80000 10 | #define VM_RAM_BASE 0x40000000 11 | #define VM_RAM_SIZE 0x8001000 12 | #define VM_RAM_OFFSET 0x00000000 13 | #define VM_DTB_ADDR 0x47381000 14 | #define VM_INITRD_ADDR 0x46701000 15 | 16 | assembly { 17 | composition {} 18 | configuration { 19 | 20 | vm_memdev.paddr = VM_RAM_BASE; 21 | vm_memdev.size = VM_RAM_SIZE; 22 | 23 | vm0.linux_address_config = { 24 | "linux_ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 25 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 26 | "linux_ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 27 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 28 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 29 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 30 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR) 31 | }; 32 | 33 | vm0.linux_image_config = { 34 | "linux_bootcmdline" : "", 35 | "linux_stdout" : "/pl011@9000000", 36 | }; 37 | vm0.num_vcpus = 2; 38 | 39 | vm0.dtb = dtb([ 40 | {"path": "/pl011@9000000"}, 41 | ]); 42 | 43 | vm0.untyped_mmios = [ 44 | "0x8040000:12" // Interrupt Controller Virtual CPU interface (Virtual Machine view) 45 | ]; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | set(supported "exynos5422;qemu-arm-virt") 8 | if(NOT "${PLATFORM}" IN_LIST supported) 9 | message(FATAL_ERROR "PLATFORM: ${PLATFORM} not supported. 10 | Supported: ${supported}") 11 | endif() 12 | set(VmPCISupport ON CACHE BOOL "" FORCE) 13 | set(LibUSB OFF CACHE BOOL "" FORCE) 14 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 15 | if(${PLATFORM} STREQUAL "qemu-arm-virt") 16 | # force cpu 17 | set(QEMU_MEMORY "2048") 18 | set(KernelArmCPU cortex-a53 CACHE STRING "" FORCE) 19 | endif() 20 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/src/cross_vm_connection.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef CONFIG_PLAT_QEMU_ARM_VIRT 16 | #define CONNECTION_BASE_ADDRESS 0xDF000000 17 | #else 18 | #define CONNECTION_BASE_ADDRESS 0x3F000000 19 | #endif 20 | 21 | //example going from linux to native component 22 | static void sys_ipa_to_pa(void) 23 | { 24 | printf("address from linux is %x\n", *(seL4_Word *)introspect_data); 25 | 26 | ready_emit(); 27 | } 28 | 29 | // these are defined in the dataport's glue code 30 | extern dataport_caps_handle_t introspect_data_handle; 31 | 32 | static struct camkes_crossvm_connection connections[] = { 33 | {&introspect_data_handle, sys_ipa_to_pa, -1, "introspect_vm"} 34 | }; 35 | 36 | static int consume_callback(vm_t *vm, void *cookie) 37 | { 38 | consume_connection_event(vm, connections[0].consume_badge, true); 39 | return 0; 40 | } 41 | 42 | extern seL4_Word done_notification_badge(void); 43 | 44 | void init_cross_vm_connections(vm_t *vm, void *cookie) 45 | { 46 | connections[0].consume_badge = done_notification_badge(); 47 | int err = register_async_event_handler(connections[0].consume_badge, consume_callback, NULL); 48 | ZF_LOGF_IF(err, "Failed to register_async_event_handler for init_cross_vm_connections."); 49 | 50 | cross_vm_connections_init(vm, CONNECTION_BASE_ADDRESS, connections, ARRAY_SIZE(connections)); 51 | } 52 | 53 | DEFINE_MODULE(cross_vm_connections, NULL, init_cross_vm_connections) 54 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/src/init_dataport_ram.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | extern dataport_caps_handle_t memdev_handle; 16 | 17 | static vm_frame_t dataport_memory_iterator(uintptr_t addr, void *cookie) 18 | { 19 | cspacepath_t return_frame; 20 | vm_frame_t frame_result = { seL4_CapNull, seL4_NoRights, 0, 0 }; 21 | const vm_config_t *vm_config = (const vm_config_t *)cookie; 22 | 23 | uintptr_t frame_start = ROUND_DOWN(addr, BIT(seL4_PageBits)); 24 | if (frame_start < vm_config->ram.base || frame_start > vm_config->ram.base + vm_config->ram.size) { 25 | ZF_LOGE("Error: Not dataport ram region"); 26 | return frame_result; 27 | } 28 | 29 | int page_idx = (frame_start - vm_config->ram.base) / BIT(seL4_PageBits); 30 | frame_result.cptr = dataport_get_nth_frame_cap(&memdev_handle, page_idx); 31 | frame_result.rights = seL4_AllRights; 32 | frame_result.vaddr = frame_start; 33 | frame_result.size_bits = seL4_PageBits; 34 | return frame_result; 35 | } 36 | 37 | /* This overwrites the weak function in the VMM module init_ram */ 38 | void init_ram_module(vm_t *vm, void *cookie) 39 | { 40 | int err; 41 | 42 | void *reg_cookie = (void *)&vm_config; 43 | err = vm_ram_register_at_custom_iterator(vm, vm_config.ram.base, 44 | vm_config.ram.size, 45 | dataport_memory_iterator, 46 | reg_cookie); 47 | assert(!err); 48 | } 49 | -------------------------------------------------------------------------------- /apps/Arm/vm_introspect/vm_introspect.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | import ; 10 | import ; 11 | import ; 12 | import ; 13 | import ; 14 | import ; 15 | import ; 16 | import ; 17 | import ; 18 | 19 | component introspect_memdev { 20 | control; 21 | //guest memory connection 22 | dataport Buf memdev; 23 | 24 | //data to introspect 25 | dataport Buf introspect_data; 26 | 27 | //signals 28 | consumes Ready ready; 29 | emits Done done; 30 | } 31 | 32 | component VM { 33 | VM_INIT_DEF() 34 | 35 | //guest memory region 36 | dataport Buf memdev; 37 | 38 | //data to pass through to memdev to look at 39 | dataport Buf introspect_data; 40 | 41 | //communication signals 42 | emits Ready ready; 43 | consumes Done done; 44 | } 45 | 46 | assembly { 47 | composition { 48 | VM_GENERAL_COMPOSITION_DEF() 49 | VM_COMPOSITION_DEF(0) 50 | component introspect_memdev md; 51 | 52 | 53 | connection seL4Notification event_conn_0(from vm0.ready, 54 | to md.ready); 55 | connection seL4GlobalAsynch event_conn_1(from md.done, 56 | to vm0.done); 57 | 58 | connection seL4SharedDataWithCaps conn_introspect_data(from md.introspect_data, 59 | to vm0.introspect_data); 60 | 61 | connection seL4SharedDataWithCaps vm_memdev(from md.memdev, to vm0.memdev); 62 | 63 | connection seL4VMDTBPassthrough vm_dtb(from vm0.dtb_self, to vm0.dtb); 64 | } 65 | configuration { 66 | VM_GENERAL_CONFIGURATION_DEF() 67 | VM_CONFIGURATION_DEF(0) 68 | 69 | vm0.num_extra_frame_caps = 0; 70 | vm0.extra_frame_map_address = 0; 71 | vm0.cnode_size_bits = 23; 72 | vm0.simple_untyped24_pool = 12; 73 | 74 | vm0.introspect_data_id = 0; 75 | vm0.introspect_data_size = 4096; 76 | 77 | md.memdev_hardware_cached = false; 78 | vm0.memdev_hardware_cached = false; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/odroidc2/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_RAM_OFFSET 0 10 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 11 | 12 | #define VM_RAM_BASE 0x20000000 13 | #define VM_RAM_SIZE 0x10000000 14 | #define VM_DTB_ADDR 0x2F000000 15 | #define VM_INITRD_ADDR 0x2D700000 16 | 17 | assembly { 18 | composition {} 19 | configuration { 20 | vm0.linux_address_config = { 21 | "linux_ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 22 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 23 | "linux_ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 24 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 25 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 26 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR) 28 | }; 29 | 30 | vm0.linux_image_config = {}; 31 | 32 | vm0.dtb = dtb([ 33 | {"path": "/serial@c81004c0"}, 34 | {"path": "/ethernet@c9410000"}, 35 | ]); 36 | 37 | vm0.untyped_mmios = [ 38 | "0xc4306000:12", // VCPU 39 | "0x20000000:28", // RAM 40 | ]; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/qemu-arm-virt/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 10 | #define VM_RAM_BASE 0x40000000 11 | #define VM_RAM_SIZE 0x20000000 12 | #define VM_RAM_OFFSET 0x00000000 13 | #define VM_DTB_ADDR 0x4F000000 14 | #define VM_INITRD_ADDR 0x4D700000 15 | 16 | assembly { 17 | composition {} 18 | configuration { 19 | 20 | vm0.linux_address_config = { 21 | "linux_ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 22 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 23 | "linux_ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 24 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 25 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 26 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR) 28 | }; 29 | 30 | vm0.linux_image_config = { 31 | "linux_bootcmdline" : "", 32 | "linux_stdout" : "/pl011@9000000", 33 | }; 34 | vm0.num_vcpus = 2; 35 | 36 | vm0.dtb = dtb([ 37 | {"path": "/pl011@9000000"}, 38 | ]); 39 | 40 | vm0.untyped_mmios = [ 41 | "0x8040000:12", // Interrupt Controller Virtual CPU interface (Virtual Machine view) 42 | "0x40000000:29", // Linux kernel memory regions 43 | ]; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | set(supported "tk1;tx1;tx2;exynos5422;qemu-arm-virt;odroidc2;zcu102") 8 | if(NOT "${PLATFORM}" IN_LIST supported) 9 | message(FATAL_ERROR "PLATFORM: ${PLATFORM} not supported. 10 | Supported: ${supported}") 11 | endif() 12 | if(${PLATFORM} STREQUAL "tk1") 13 | set(KernelTk1SMMU ON CACHE BOOL "" FORCE) 14 | set(KernelTk1SMMUInterruptEnable ON CACHE BOOL "" FORCE) 15 | endif() 16 | 17 | set(LibUSB OFF CACHE BOOL "" FORCE) 18 | if(${PLATFORM} STREQUAL "exynos5422") 19 | set(VmPCISupport ON CACHE BOOL "" FORCE) 20 | set(VmVirtioNet ON CACHE BOOL "" FORCE) 21 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 22 | endif() 23 | if(${PLATFORM} STREQUAL "tx2") 24 | set(VmPCISupport ON CACHE BOOL "" FORCE) 25 | set(VmVirtioNet ON CACHE BOOL "" FORCE) 26 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 27 | set(VmDtbFile ON CACHE BOOL "" FORCE) 28 | endif() 29 | if(${PLATFORM} STREQUAL "odroidc2") 30 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 31 | set(VmDtbFile ON CACHE BOOL "" FORCE) 32 | endif() 33 | if(${PLATFORM} STREQUAL "qemu-arm-virt") 34 | # force cpu 35 | set(QEMU_MEMORY "2048") 36 | set(KernelArmCPU cortex-a53 CACHE STRING "" FORCE) 37 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 38 | endif() 39 | if(${PLATFORM} STREQUAL "zcu102") 40 | set(AARCH64 ON CACHE BOOL "" FORCE) 41 | set(KernelAllowSMCCalls ON CACHE BOOL "" FORCE) 42 | endif() 43 | -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/tk1/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 10 | #define VM_PADDR_RAM_BASE 0xB0000000 11 | #define VM_RAM_BASE 0x80000000 12 | #define VM_RAM_SIZE 0x40000000 13 | #define VM_RAM_OFFSET 0x30000000 14 | #define VM_DTB_ADDR 0x82000000 15 | #define VM_INITRD_ADDR 0x80700000 16 | 17 | assembly { 18 | composition {} 19 | configuration { 20 | 21 | vm0.linux_address_config = { 22 | "linux_ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 23 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM_PADDR_RAM_BASE), 24 | "linux_ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 25 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 26 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 27 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 28 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR) 29 | }; 30 | 31 | vm0.linux_image_config = { 32 | "linux_bootcmdline" : "console=ttyS0,115200n8 otf_key=c75e5bb91eb3bd947560357b64422f85 usbcore.old_scheme_first=1 tegraid=40.1.1.0.0 modem_id=0 android.kerneltype=normal commchip_id=0 usb_port_owner_info=2 lane_owner_info=1 touch_id=0@0 board_info=0x0177:0x0000:0x02:0x43:0x00 init=/sbin/init root=/dev/mmcblk0p2 rw rootwait gpt earlyprint", 33 | "linux_stdout" : "/pl011@9000000", 34 | }; 35 | 36 | vm0.dtb = dtb([{"path": "/interrupt-controller@60004000"}, 37 | {"path": "/sdhci@700b0000"}, 38 | {"path": "/usb@7d000000"}, 39 | {"path": "/usb@7d004000"}, 40 | {"path": "/usb@7d008000"}, 41 | #if TK1DEVICEFWD == 0 42 | {"path": "/clock@60006000"}, 43 | {"path": "/serial@70006000"}, 44 | #endif 45 | #if TK1INSECURE 46 | {"path": "/pcie@1003000"}, 47 | {"path": "/host1x@50000000"}, 48 | {"path": "/host1x@50000000/dc@54200000"}, 49 | {"path": "/host1x@50000000/dc@54240000"}, 50 | {"path": "/timer@60005000"}, 51 | {"path": "/actmon@6000c800"}, 52 | {"path": "/gpio@6000d000"}, 53 | {"path": "/dma@60020000"}, 54 | {"path": "/pinmux@70000868"}, 55 | {"path": "/i2c@7000c000"}, 56 | {"path": "/i2c@7000d000"}, 57 | {"path": "/rtc@7000e000"}, 58 | {"path": "/fuse@7000f800"}, 59 | {"path": "/clock@70110000"}, 60 | {"path": "/emc@7001b000"}, 61 | {"path": "/sata@70020000"}, 62 | {"path": "/hda@70030000"}, 63 | {"path": "/padctl@7009f000"}, 64 | {"path": "/ahub@70300000"}, 65 | {"path": "/ahub@70300000/i2s@70301000"}, 66 | #endif 67 | ]); 68 | 69 | vm0.untyped_mmios = [ 70 | "0x50046000:12", // Interrupt Controller Virtual CPU interface (Virtual Machine view) 71 | "0xb0000000:28", // Linux kernel memory regions 72 | "0xc0000000:29", // Linux kernel memory regions 73 | "0xe0000000:28", // Linux kernel memory regions 74 | #if TK1INSECURE 75 | "0x01000000:12", // PCIe Controller 0 config registers 76 | "0x01001000:12", // PCIe Controller 1 config registers 77 | #endif 78 | ]; 79 | vm0.irqs = [ 80 | 63, // INTERRUPT_SDMMC4 81 | 122, // INTERRUPT_UARTD 82 | ]; 83 | 84 | #if TK1INSECURE 85 | /* See 86 | * .../kernel/include/plat/tk1/plat/machine/smmu.h 87 | * ASID IDs, minus one 88 | * Each additional ASID here represents an entire page table; 89 | * make sure you have enough RAM. 90 | */ 91 | vm0.smmu = [0,5,6,10,11,12,15,16,21,23,24,25,26,27]; 92 | #else 93 | vm0.smmu = [10, 23]; 94 | #endif 95 | 96 | } 97 | } -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/tx1/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 10 | #define VM_RAM_BASE 0x80000000 11 | #define VM_RAM_SIZE 0x8000000 12 | #define VM_RAM_OFFSET 0 13 | #define VM_DTB_ADDR 0x82000000 14 | #define VM_INITRD_ADDR 0x80700000 15 | 16 | assembly { 17 | composition {} 18 | configuration { 19 | 20 | vm0.linux_address_config = { 21 | "linux_ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 22 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 23 | "linux_ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 24 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 25 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 26 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR), 28 | }; 29 | vm0.num_vcpus = 4; 30 | 31 | vm0.linux_image_config = { 32 | "linux_bootcmdline" : "console=ttyS0,115200n8 earlycon=uart8250,mmio32,0x70006000 debug mem=100m initcall_debug user_debug=31", 33 | "linux_stdout" : "serial0:115200n8", 34 | }; 35 | 36 | vm0.dtb = dtb([{"path": "/serial@70006000"}, 37 | {"path": "/interrupt-controller@60004000"}, 38 | {"path": "/clock@60006000"}, 39 | {"path": "/rtc@7000e000"}, 40 | {"path": "/gpio@6000d000"}, 41 | {"path": "/memory-controller@70019000"}, 42 | {"path": "/pinmux@700008d4"}, 43 | {"path": "/fuse@7000f800"}]); 44 | 45 | vm0.untyped_mmios = ["0x50046000:12"]; // Interrupt Controller Virtual CPU interface (Virtual Machine view) 46 | } 47 | } -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/tx2/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 10 | #define VM_RAM_BASE 0xF1000000 11 | #define VM_RAM_SIZE 0x8000000 12 | #define VM_RAM_OFFSET 0 13 | #define VM_DTB_ADDR 0xF2000000 14 | #define VM_INITRD_ADDR 0xF7000000 15 | 16 | assembly { 17 | composition {} 18 | configuration { 19 | 20 | vm0.linux_address_config = { 21 | "linux_ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 22 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 23 | "linux_ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 24 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 25 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 26 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR) 28 | }; 29 | 30 | vm0.linux_image_config = { 31 | "linux_bootcmdline" : "console=ttyS0,115200n1 no_console_suspend=1 earlycon=uart8250,mmio32,0x03100000 debug init=/sbin/init", 32 | "linux_stdout" : "/serial@3100000", 33 | }; 34 | vm0.num_vcpus = 4; 35 | 36 | vm0.dtb = dtb([ 37 | {"path": "/chipid@100000"}, 38 | {"path": "/gpio@2200000"}, 39 | {"path": "/pinmux@2430000"}, 40 | {"path": "/mc_sid@2c00000"}, 41 | {"path": "/mc"}, 42 | {"path": "/timer@3020000"}, 43 | {"path": "/efuse@3820000"}, 44 | {"path": "/serial@3100000"}, 45 | {"path": "/serial@3110000"}, 46 | {"path": "/serial@3130000"}, 47 | {"path": "/serial@3140000"}, 48 | {"path": "/serial@3150000"}, 49 | {"path": "/tachometer@39c0000"}, 50 | {"path": "/tegra-hsp@3c00000"}, 51 | {"path": "/clock@5000000"}, 52 | {"path": "/funnel_major@8010000"}, 53 | {"path": "/etf@8030000"}, 54 | {"path": "/etr@8050000"}, 55 | {"path": "/tpiu@8060000"}, 56 | {"path": "/stm@8070000"}, 57 | {"path": "/funnel_minor@8820000"}, 58 | {"path": "/ptm_bpmp@8a1c000"}, 59 | {"path": "/funnel_bccplex@9010000"}, 60 | {"path": "/ptm@9840000"}, 61 | {"path": "/ptm@9940000"}, 62 | {"path": "/ptm@9a40000"}, 63 | {"path": "/ptm@9b40000"}, 64 | {"path": "/tegra-hsp@b150000"}, 65 | {"path": "/tegra-hsp@c150000"}, 66 | {"path": "/gpio@c2f0000"}, 67 | {"path": "/pmc@c360000"}, 68 | {"path": "/pmc@c370000"}, 69 | /* bpmp node */ 70 | {"properties" : {"compatible[0]" : "nvidia,tegra186-bpmp"}}]); 71 | 72 | vm0.untyped_mmios = [ 73 | "0x3886000:12", // GICV Iface. 74 | /* The purpose of these untyped regions is to force the untyped 75 | * allocator to treat this memory region as reserved so that when we 76 | * try to ensure that the VMM is placed into this region in RAM, it 77 | * will definitely be available for placement. 78 | * 79 | * This address pertains to guest-vm@f1000000 in the overlay DTS 80 | */ 81 | "0xF1000000:24", 82 | "0xF2000000:25", 83 | "0xF4000000:26", 84 | "0xF8000000:24", 85 | ]; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/vm_minimal.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | import ; 10 | import ; 11 | import ; 12 | import ; 13 | import ; 14 | 15 | assembly { 16 | composition { 17 | VM_GENERAL_COMPOSITION_DEF() 18 | VM_COMPOSITION_DEF(0) 19 | connection seL4VMDTBPassthrough vm_dtb(from vm0.dtb_self, to vm0.dtb); 20 | } 21 | configuration { 22 | VM_GENERAL_CONFIGURATION_DEF() 23 | VM_CONFIGURATION_DEF(0) 24 | 25 | vm0.num_extra_frame_caps = 0; 26 | vm0.extra_frame_map_address = 0; 27 | vm0.cnode_size_bits = 23; 28 | vm0.simple_untyped24_pool = 12; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/zcu102/2018_3/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023, DornerWorks 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 11 | #define VM_RAM_BASE 0x10000000 12 | #define VM_RAM_SIZE 0x10000000 13 | #define VM_ENTRY_ADDR 0x10080000 14 | #define VM_RAM_OFFSET 0 15 | #define VM_DTB_ADDR 0x12000000 16 | #define VM_INITRD_ADDR 0x13000000 17 | 18 | assembly { 19 | composition {} 20 | configuration { 21 | 22 | vm0.vm_address_config = { 23 | "ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 24 | "ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 25 | "ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 26 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR), 28 | "kernel_entry_addr" : VAR_STRINGIZE(VM_ENTRY_ADDR), 29 | }; 30 | vm0.num_vcpus = 4; 31 | 32 | /* Extra untyped pool to allow for 256MB of RAM */ 33 | vm0.simple_untyped28_pool = 1; 34 | 35 | vm0.vm_image_config = { 36 | "kernel_name" : "linux", 37 | "initrd_name" : "linux-initrd", 38 | "dtb_base_name" : "linux-dtb", 39 | "kernel_bootcmdline" : "console=ttyPS0,115200 root=/dev/ram rw earlycon clk_ignore_unused", 40 | "kernel_stdout" : "serial0:115200n8", 41 | "generate_dtb" : true, 42 | "provide_dtb" : false, 43 | "map_one_to_one" : false, 44 | "provide_initrd": true, 45 | "clean_cache" : false, 46 | }; 47 | 48 | vm0.dtb = dtb([{"path": "/amba/serial@ff000000"} ]); 49 | 50 | vm0.untyped_mmios = ["0xf9060000:12"]; // Interrupt Controller Virtual CPU interface (Virtual Machine view) 51 | 52 | vm0.plat_keep_devices = [ 53 | "/pss_ref_clk", 54 | "/gt_crx_ref_clk", 55 | "/pss_alt_ref_clk", 56 | "/aux_ref_clk", 57 | "/video_clk", 58 | "/pmu", 59 | "/psci", 60 | "/timer", 61 | "/aliases", 62 | ]; 63 | 64 | vm0.plat_keep_devices_and_subtree = [ 65 | "/firmware", 66 | "/amba/pinctrl@ff180000", 67 | ]; 68 | 69 | vm0.allow_smc = true; 70 | vm0.allowed_smc_functions = [ 71 | SMC_PM_GET_API_VERSION, 72 | SMC_PM_REQUEST_NODE, 73 | SMC_PM_SET_REQUIREMENT, 74 | SMC_PM_INIT_FINALIZE, 75 | SMC_PM_PINCTRL_REQUEST, 76 | SMC_PM_PINCTRL_RELEASE, 77 | SMC_PM_PINCTRL_SET_FUNCTION, 78 | SMC_PM_PINCTRL_CONFIG_PARAM_SET, 79 | SMC_PM_IOCTL, 80 | SMC_PM_QUERY_DATA, 81 | SMC_PM_CLOCK_ENABLE, 82 | SMC_PM_CLOCK_GETSTATE, 83 | SMC_PM_CLOCK_GETDIVIDER, 84 | SMC_PM_CLOCK_GETPARENT, 85 | SMC_PM_GET_TRUSTZONE_VERSION, 86 | ]; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/zcu102/2021_1/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023, DornerWorks 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 11 | #define VM_RAM_BASE 0x10000000 12 | #define VM_RAM_SIZE 0x10000000 13 | #define VM_ENTRY_ADDR 0x10080000 14 | #define VM_RAM_OFFSET 0 15 | #define VM_DTB_ADDR 0x12000000 16 | #define VM_INITRD_ADDR 0x13000000 17 | 18 | assembly { 19 | composition {} 20 | configuration { 21 | 22 | vm0.vm_address_config = { 23 | "ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 24 | "ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 25 | "ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 26 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR), 28 | "kernel_entry_addr" : VAR_STRINGIZE(VM_ENTRY_ADDR), 29 | }; 30 | vm0.num_vcpus = 4; 31 | 32 | /* Extra untyped pool to allow for 256MB of RAM */ 33 | vm0.simple_untyped28_pool = 1; 34 | 35 | vm0.vm_image_config = { 36 | "kernel_name" : "linux", 37 | "initrd_name" : "linux-initrd", 38 | "dtb_base_name" : "linux-dtb", 39 | "kernel_bootcmdline" : "console=ttyPS0,115200 root=/dev/ram rw earlycon clk_ignore_unused", 40 | "kernel_stdout" : "serial0:115200n8", 41 | "generate_dtb" : true, 42 | "provide_dtb" : false, 43 | "map_one_to_one" : false, 44 | "provide_initrd": true, 45 | "clean_cache" : false, 46 | }; 47 | 48 | vm0.dtb = dtb([{"path": "/amba/serial@ff000000"} ]); 49 | 50 | vm0.untyped_mmios = ["0xf9060000:12"]; // Interrupt Controller Virtual CPU interface (Virtual Machine view) 51 | 52 | /* The ZCU102 can run different Xilinx releases of Petalinux 53 | * During one release, the PS devices were moved from the "amba" to 54 | * the "axi" bus. The seL4 kernel only needs the device tree to 55 | * allocate untyped resources, so the device tree was never updated. 56 | * However, it's a good idea to match the device tree with the version 57 | * of Petalinux that is running. 58 | * 59 | * This file configures a Petalinux 2021.1 guest VM, meaning a different 60 | * device tree than the seL4 kernel device tree is used as the base for 61 | * guest dtb generation. This version uses the axi bus. Therefore, 62 | * any passthrough or emulated devices on that bus must be listed here 63 | * with the plat_keep_devices, as the VMM will attempt to keep the amba 64 | * bus versions, which do not exist in the 2021.1 base. 65 | * 66 | * The VMM will complain about the /amba/serial device not existing: 67 | * "Non-existing node /amba/serial@ff000000 specified to be kept" 68 | */ 69 | vm0.plat_keep_devices = [ 70 | "/pss_ref_clk", 71 | "/gt_crx_ref_clk", 72 | "/pss_alt_ref_clk", 73 | "/aux_ref_clk", 74 | "/video_clk", 75 | "/pmu", 76 | "/psci", 77 | "/timer", 78 | "/aliases", 79 | "/axi/interrupt-controller@f9010000", 80 | "/axi/serial@ff000000", 81 | ]; 82 | 83 | vm0.plat_keep_devices_and_subtree = [ 84 | "/firmware", 85 | ]; 86 | 87 | vm0.allow_smc = true; 88 | vm0.allowed_smc_functions = [ 89 | SMC_PM_GET_API_VERSION, 90 | SMC_PM_REQUEST_NODE, 91 | SMC_PM_SET_REQUIREMENT, 92 | SMC_PM_INIT_FINALIZE, 93 | SMC_PM_FPGA_GET_STATUS, 94 | SMC_PM_PINCTRL_REQUEST, 95 | SMC_PM_PINCTRL_SET_FUNCTION, 96 | SMC_PM_PINCTRL_CONFIG_PARAM_GET, 97 | SMC_PM_PINCTRL_CONFIG_PARAM_SET, 98 | SMC_PM_IOCTL, 99 | SMC_PM_QUERY_DATA, 100 | SMC_PM_CLOCK_ENABLE, 101 | SMC_PM_CLOCK_GETSTATE, 102 | SMC_PM_CLOCK_GETDIVIDER, 103 | SMC_PM_CLOCK_GETPARENT, 104 | SMC_PM_GET_TRUSTZONE_VERSION, 105 | ]; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /apps/Arm/vm_minimal/zcu102/2022_1/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023, DornerWorks 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 11 | #define VM_RAM_BASE 0x10000000 12 | #define VM_RAM_SIZE 0x10000000 13 | #define VM_ENTRY_ADDR 0x10080000 14 | #define VM_RAM_OFFSET 0 15 | #define VM_DTB_ADDR 0x12000000 16 | #define VM_INITRD_ADDR 0x13000000 17 | 18 | assembly { 19 | composition {} 20 | configuration { 21 | 22 | vm0.vm_address_config = { 23 | "ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 24 | "ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 25 | "ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 26 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR), 28 | "kernel_entry_addr" : VAR_STRINGIZE(VM_ENTRY_ADDR), 29 | }; 30 | vm0.num_vcpus = 4; 31 | 32 | /* Extra untyped pool to allow for 256MB of RAM */ 33 | vm0.simple_untyped28_pool = 1; 34 | 35 | vm0.vm_image_config = { 36 | "kernel_name" : "linux", 37 | "initrd_name" : "linux-initrd", 38 | "dtb_base_name" : "linux-dtb", 39 | "kernel_bootcmdline" : "console=ttyPS0,115200 root=/dev/ram rw earlycon clk_ignore_unused", 40 | "kernel_stdout" : "serial0:115200n8", 41 | "generate_dtb" : true, 42 | "provide_dtb" : false, 43 | "map_one_to_one" : false, 44 | "provide_initrd": true, 45 | "clean_cache" : false, 46 | }; 47 | 48 | vm0.dtb = dtb([{"path": "/amba/serial@ff000000"} ]); 49 | 50 | vm0.untyped_mmios = ["0xf9060000:12"]; // Interrupt Controller Virtual CPU interface (Virtual Machine view) 51 | 52 | vm0.plat_keep_devices = [ 53 | "/pss_ref_clk", 54 | "/gt_crx_ref_clk", 55 | "/pss_alt_ref_clk", 56 | "/aux_ref_clk", 57 | "/video_clk", 58 | "/pmu", 59 | "/psci", 60 | "/timer", 61 | "/aliases", 62 | "/axi/interrupt-controller@f9010000", 63 | "/axi/serial@ff000000", 64 | ]; 65 | 66 | vm0.plat_keep_devices_and_subtree = [ 67 | "/firmware", 68 | ]; 69 | 70 | vm0.allow_smc = true; 71 | vm0.allowed_smc_functions = [ 72 | SMC_PM_GET_API_VERSION, 73 | SMC_PM_REQUEST_NODE, 74 | SMC_PM_SET_REQUIREMENT, 75 | SMC_PM_INIT_FINALIZE, 76 | SMC_PM_FPGA_GET_STATUS, 77 | SMC_PM_PINCTRL_REQUEST, 78 | SMC_PM_PINCTRL_SET_FUNCTION, 79 | SMC_PM_PINCTRL_CONFIG_PARAM_GET, 80 | SMC_PM_PINCTRL_CONFIG_PARAM_SET, 81 | SMC_PM_IOCTL, 82 | SMC_PM_QUERY_DATA, 83 | SMC_PM_CLOCK_ENABLE, 84 | SMC_PM_CLOCK_GETSTATE, 85 | SMC_PM_CLOCK_GETDIVIDER, 86 | SMC_PM_CLOCK_GETPARENT, 87 | SMC_PM_GET_TRUSTZONE_VERSION, 88 | SMC_PM_ADD_SUBSYSTEM, 89 | SMC_PM_FEATURE_CHECK, 90 | ]; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /apps/Arm/vm_multi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(vm-multi C) 10 | 11 | include(${CAMKES_ARM_VM_HELPERS_PATH}) 12 | find_package(camkes-vm-linux REQUIRED) 13 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 14 | 15 | if("${PLATFORM}" STREQUAL "exynos5422") 16 | # Create our CPP Flags based on ARM VM config variables 17 | set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422") 18 | elseif("${PLATFORM}" STREQUAL "qemu-arm-virt") 19 | set(cpp_flags "-DKERNELARMPLATFORM_QEMU-ARM-VIRT") 20 | set(SIMULATION ON CACHE BOOL "Generate simulation script to run qemu with the proper arguments") 21 | include(simulation) 22 | if(SIMULATION) 23 | GenerateSimulateScript() 24 | endif() 25 | endif() 26 | 27 | # Generate our overlayed rootfs images 28 | set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/rootfs.cpio.gz") 29 | 30 | # Setup our passthrough vm overlay 31 | AddFileToOverlayDir( 32 | "inittab" 33 | ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/inittab_hvc0 34 | "etc" 35 | overlay_vm0 36 | ) 37 | AddFileToOverlayDir( 38 | "S90bridge_setup" 39 | ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/vm0_bridge_setup.sh 40 | "etc/init.d" 41 | overlay_vm0 42 | ) 43 | AddOverlayDirToRootfs( 44 | overlay_vm0 45 | ${rootfs_file} 46 | "buildroot" 47 | "rootfs_install" 48 | vm0_output_overlayed_rootfs_location 49 | rootfs_target_vm0 50 | GZIP 51 | ) 52 | 53 | # Setup our client vm overlays 54 | AddFileToOverlayDir( 55 | "inittab" 56 | ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/inittab_hvc0 57 | "etc" 58 | overlay_client_vm 59 | ) 60 | AddFileToOverlayDir( 61 | "S90client_net_vm" 62 | ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/vm_client_net_setup.sh 63 | "etc/init.d" 64 | overlay_client_vm 65 | ) 66 | AddOverlayDirToRootfs( 67 | overlay_client_vm 68 | ${rootfs_file} 69 | "buildroot" 70 | "rootfs_install" 71 | client_output_overlayed_rootfs_location 72 | rootfs_target_client_vm 73 | GZIP 74 | ) 75 | 76 | AddToFileServer( 77 | "linux-initrd-vm0" 78 | "${vm0_output_overlayed_rootfs_location}" 79 | DEPENDS 80 | rootfs_target_vm0 81 | ) 82 | AddToFileServer( 83 | "linux-initrd-vm-client" 84 | "${client_output_overlayed_rootfs_location}" 85 | DEPENDS 86 | rootfs_target_client_vm 87 | ) 88 | 89 | AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux") 90 | 91 | AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB VmVchan Tk1DeviceFwd Tk1Insecure) 92 | 93 | DefineCAmkESVMFileServer() 94 | 95 | CAmkESAddImportPath(${KernelARMPlatform}) 96 | 97 | # Declare root server 98 | DeclareCAmkESRootserver( 99 | vm_multi.camkes 100 | CPP_FLAGS 101 | ${cpp_flags} 102 | CPP_INCLUDES 103 | ${CAMKES_VM_DIR}/components/VM_Arm 104 | ) 105 | -------------------------------------------------------------------------------- /apps/Arm/vm_multi/overlay_files/inittab_hvc0: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0-only 2 | 3 | # /etc/inittab 4 | # 5 | # Copyright (C) 2001 Erik Andersen 6 | # 7 | # Note: BusyBox init doesn't support runlevels. The runlevels field is 8 | # completely ignored by BusyBox init. If you want runlevels, use 9 | # sysvinit. 10 | # 11 | # Format for each entry: ::: 12 | # 13 | # id == tty to run on, or empty for /dev/console 14 | # runlevels == ignored 15 | # action == one of sysinit, respawn, askfirst, wait, and once 16 | # process == program to run 17 | 18 | # Startup the system 19 | ::sysinit:/bin/mount -t proc proc /proc 20 | ::sysinit:/bin/mount -o remount,rw / 21 | ::sysinit:/bin/mkdir -p /dev/pts /dev/shm 22 | ::sysinit:/bin/mount -a 23 | ::sysinit:/sbin/swapon -a 24 | null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd 25 | null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin 26 | null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout 27 | null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr 28 | ::sysinit:/bin/hostname -F /etc/hostname 29 | # now run any rc scripts 30 | ::sysinit:/etc/init.d/rcS 31 | 32 | # Put a getty on the serial port 33 | hvc0:2345:respawn:/sbin/getty -L 9600 hvc0 34 | 35 | # Stuff to do for the 3-finger salute 36 | #::ctrlaltdel:/sbin/reboot 37 | 38 | # Stuff to do before rebooting 39 | ::shutdown:/etc/init.d/rcK 40 | ::shutdown:/sbin/swapoff -a 41 | ::shutdown:/bin/umount -a -r 42 | -------------------------------------------------------------------------------- /apps/Arm/vm_multi/overlay_files/vm0_bridge_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | set -e 9 | 10 | ifconfig eth0 up 11 | ifconfig eth1 up 12 | brctl addbr br0 13 | brctl addif br0 eth0 14 | brctl addif br0 eth1 15 | udhcpc -i br0 16 | -------------------------------------------------------------------------------- /apps/Arm/vm_multi/overlay_files/vm_client_net_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | set -e 9 | 10 | ifconfig eth0 up 11 | udhcpc -i eth0 12 | -------------------------------------------------------------------------------- /apps/Arm/vm_multi/qemu-arm-virt/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_RAM_OFFSET 0x00000000 10 | #define VM_INITRD_MAX_SIZE 0x3200000 //50 MB 11 | 12 | #define VM0_RAM_BASE 0x40000000 13 | #define VM0_RAM_SIZE 0x8000000 14 | #define VM0_DTB_ADDR 0x47000000 //VM0_RAM_BASE + 0x7000000 15 | #define VM0_INITRD_ADDR 0x43e00000 //VM0_DTB_ADDR - VM_INITRD_MAX_SIZE 16 | 17 | #define VM1_RAM_BASE 0x48000000 18 | #define VM1_RAM_SIZE 0x8000000 19 | #define VM1_DTB_ADDR 0x4f000000 //VM1_RAM_BASE + 0x7000000 20 | #define VM1_INITRD_ADDR 0x4be00000 //VM1_DTB_ADDR - VM_INITRD_MAX_SIZE 21 | 22 | #define VM2_RAM_BASE 0x50000000 23 | #define VM2_RAM_SIZE 0x8000000 24 | #define VM2_DTB_ADDR 0x57000000 //VM2_RAM_BASE + 0x7000000 25 | #define VM2_INITRD_ADDR 0x53e00000 //VM2_DTB_ADDR - VM_INITRD_MAX_SIZE 26 | 27 | assembly { 28 | composition {} 29 | configuration { 30 | 31 | vm0.linux_address_config = { 32 | "linux_ram_base" : VAR_STRINGIZE(VM0_RAM_BASE), 33 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM0_RAM_BASE), 34 | "linux_ram_size" : VAR_STRINGIZE(VM0_RAM_SIZE), 35 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 36 | "dtb_addr" : VAR_STRINGIZE(VM0_DTB_ADDR), 37 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 38 | "initrd_addr" : VAR_STRINGIZE(VM0_INITRD_ADDR), 39 | }; 40 | vm0.linux_image_config = { 41 | "linux_bootcmdline" : "console=hvc0 nosmp rw debug loglevel=8 pci=nomsi,realloc=off,bios initcall_blacklist=clk_disable_unused", 42 | "linux_stdout" : "hvc0", 43 | "dtb_name" : "", 44 | "initrd_name" : "linux-initrd-vm0", 45 | }; 46 | vm0.dtb = dtb([ 47 | {"path": "/pcie@10000000"}, 48 | ]); 49 | vm0.mmios = [ 50 | "0x8040000:0x1000:12", // Interrupt Controller Virtual CPU interface (Virtual Machine view) 51 | ]; 52 | vm0.untyped_mmios = [ 53 | /* TODO: QEMU PCI addresses could change - ideally need to decode from pcie node */ 54 | "0x10040000:17", // QEMU PCI MMIO 55 | "0x3eff0000:16", // QEMU PCI IO ports 56 | "0x40000000:27", // Linux kernel memory regions 57 | ]; 58 | vm0.dtb_irqs = [35, 36, 37, 38]; 59 | 60 | vm1.linux_address_config = { 61 | "linux_ram_base" : VAR_STRINGIZE(VM1_RAM_BASE), 62 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM1_RAM_BASE), 63 | "linux_ram_size" : VAR_STRINGIZE(VM1_RAM_SIZE), 64 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 65 | "dtb_addr" : VAR_STRINGIZE(VM1_DTB_ADDR), 66 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 67 | "initrd_addr" : VAR_STRINGIZE(VM1_INITRD_ADDR), 68 | }; 69 | vm1.linux_image_config = { 70 | "linux_bootcmdline" : "console=hvc0 nosmp rw debug loglevel=8 pci=nomsi,realloc=off,bios initcall_blacklist=clk_disable_unused", 71 | "linux_stdout" : "hvc0", 72 | "dtb_name" : "", 73 | "initrd_name" : "linux-initrd-vm-client", 74 | }; 75 | vm1.mmios = [ 76 | "0x8040000:0x1000:12", // Interrupt Controller Virtual CPU interface (Virtual Machine view) 77 | ]; 78 | vm1.untyped_mmios = [ 79 | "0x48000000:27", // Linux kernel memory regions 80 | ]; 81 | vm1.dtb = dtb([{}]); 82 | 83 | vm2.linux_address_config = { 84 | "linux_ram_base" : VAR_STRINGIZE(VM2_RAM_BASE), 85 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM2_RAM_BASE), 86 | "linux_ram_size" : VAR_STRINGIZE(VM2_RAM_SIZE), 87 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 88 | "dtb_addr" : VAR_STRINGIZE(VM2_DTB_ADDR), 89 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 90 | "initrd_addr" : VAR_STRINGIZE(VM2_INITRD_ADDR), 91 | }; 92 | vm2.linux_image_config = { 93 | "linux_bootcmdline" : "console=hvc0 nosmp rw debug loglevel=8 pci=nomsi,realloc=off,bios initcall_blacklist=clk_disable_unused", 94 | "linux_stdout" : "hvc0", 95 | "dtb_name" : "", 96 | "initrd_name" : "linux-initrd-vm-client", 97 | }; 98 | vm2.mmios = [ 99 | "0x8040000:0x1000:12", // Interrupt Controller Virtual CPU interface (Virtual Machine view) 100 | ]; 101 | vm2.untyped_mmios = [ 102 | "0x50000000:27", // Linux kernel memory regions 103 | ]; 104 | vm2.dtb = dtb([{}]); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /apps/Arm/vm_multi/settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | set(supported "exynos5422;qemu-arm-virt") 8 | if(NOT "${PLATFORM}" IN_LIST supported) 9 | message(FATAL_ERROR "PLATFORM: ${PLATFORM} not supported. 10 | Supported: ${supported}") 11 | endif() 12 | set(LibUSB OFF CACHE BOOL "" FORCE) 13 | set(VmPCISupport ON CACHE BOOL "" FORCE) 14 | set(VmVirtioConsole ON CACHE BOOL "" FORCE) 15 | set(VmVirtioNetArping OFF CACHE BOOL "" FORCE) 16 | set(VmVirtioNetVirtqueue ON CACHE BOOL "" FORCE) 17 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 18 | if("${PLATFORM}" STREQUAL "qemu-arm-virt") 19 | set(QEMU_MEMORY "2048") 20 | set(KernelArmCPU cortex-a53 CACHE STRING "" FORCE) 21 | set(qemu_sim_extra_args "-netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no -device virtio-net,netdev=mynet0,mac=52:55:00:d1:55:01") 22 | set(KernelArmExportPCNTUser ON CACHE BOOL "" FORCE) 23 | set(KernelArmExportPTMRUser ON CACHE BOOL "" FORCE) 24 | endif() 25 | -------------------------------------------------------------------------------- /apps/Arm/vm_multi/vm_multi.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | import ; 10 | import ; 11 | import ; 12 | import ; 13 | import ; 14 | import ; 15 | import ; 16 | import ; 17 | import ; 18 | 19 | struct vswitch_mapping { 20 | string mac_addr; 21 | int send_id; 22 | int recv_id; 23 | }; 24 | 25 | component VM { 26 | VM_INIT_DEF() 27 | maybe uses VirtQueueDev recv1; 28 | maybe uses VirtQueueDrv send1; 29 | maybe uses VirtQueueDev recv2; 30 | maybe uses VirtQueueDrv send2; 31 | attribute vswitch_mapping vswitch_layout[] = []; 32 | attribute string vswitch_mac_address = ""; 33 | } 34 | 35 | assembly { 36 | composition { 37 | /* Boilerplate composition settings */ 38 | VM_GENERAL_COMPOSITION_DEF() 39 | 40 | /* Other standard VM defintions (vm0, vm1, vm1) */ 41 | VM_COMPOSITION_DEF(0) 42 | VM_COMPOSITION_DEF(1) 43 | VM_COMPOSITION_DEF(2) 44 | /* vm0,vm1 & vm2 serial connections */ 45 | VM_VIRTUAL_SERIAL_COMPOSITION_DEF(0,1,2) 46 | 47 | /* vm0-[vm1,vm2] connection */ 48 | component VirtQueueInit vm1_vm0; 49 | component VirtQueueInit vm2_vm0; 50 | connection seL4VirtQueues vm1_vm0_conn(to vm1_vm0.init, from vm0.send1, from vm0.recv1, from vm1.send1, from vm1.recv1); 51 | connection seL4VirtQueues vm2_vm0_conn(to vm2_vm0.init, from vm0.recv2, from vm0.send2, from vm2.recv1, from vm2.send1); 52 | 53 | /* DTB Passthrough */ 54 | connection seL4VMDTBPassthrough vm0_dtb(from vm0.dtb_self, to vm0.dtb); 55 | connection seL4VMDTBPassthrough vm1_dtb(from vm1.dtb_self, to vm1.dtb); 56 | connection seL4VMDTBPassthrough vm2_dtb(from vm2.dtb_self, to vm2.dtb); 57 | } 58 | configuration { 59 | VM_GENERAL_CONFIGURATION_DEF() 60 | VM_CONFIGURATION_DEF(0) 61 | VM_CONFIGURATION_DEF(1) 62 | VM_CONFIGURATION_DEF(2) 63 | VM_VIRTUAL_SERIAL_CONFIGURATION_DEF(0,1,2) 64 | 65 | vm0.num_extra_frame_caps = 0; 66 | vm0.extra_frame_map_address = 0; 67 | vm0.cnode_size_bits = 18; 68 | vm0.simple_untyped21_pool = 12; 69 | vm0.simple_untyped12_pool = 12; 70 | vm0.vswitch_mac_address = "02:00:00:00:AA:01"; 71 | vm0.vswitch_layout = [{"mac_addr": "02:00:00:00:AA:02", "recv_id": 0, "send_id":1}, 72 | {"mac_addr": "02:00:00:00:AA:03", "recv_id": 2, "send_id":3}]; 73 | 74 | vm1.num_extra_frame_caps = 0; 75 | vm1.extra_frame_map_address = 0; 76 | vm1.cnode_size_bits = 18; 77 | vm1.simple_untyped21_pool = 12; 78 | vm1.simple_untyped12_pool = 12; 79 | vm1.vswitch_mac_address = "02:00:00:00:AA:02"; 80 | vm1.vswitch_layout = [{"mac_addr": "02:00:00:00:AA:01", "recv_id": 0, "send_id":1}]; 81 | 82 | vm2.num_extra_frame_caps = 0; 83 | vm2.extra_frame_map_address = 0; 84 | vm2.cnode_size_bits = 18; 85 | vm2.simple_untyped21_pool = 12; 86 | vm2.simple_untyped12_pool = 12; 87 | vm2.vswitch_mac_address = "02:00:00:00:AA:03"; 88 | vm2.vswitch_layout = [{"mac_addr": "02:00:00:00:AA:01", "recv_id": 0, "send_id":1}]; 89 | 90 | /* VM0-VM1 virtqueue configurations */ 91 | vm0.recv1_id = 0; 92 | vm0.recv1_shmem_size = 8192; 93 | vm0.send1_id = 1; 94 | vm0.send1_shmem_size = 8192; 95 | /* VM0-VM2 virtqueue configurations */ 96 | vm0.recv2_id = 2; 97 | vm0.recv2_shmem_size = 8192; 98 | vm0.send2_id = 3; 99 | vm0.send2_shmem_size = 8192; 100 | 101 | /* VM1 virtqueue configurations */ 102 | vm1.recv1_id = 0; 103 | vm1.recv1_shmem_size = 8192; 104 | vm1.send1_id = 1; 105 | vm1.send1_shmem_size = 8192; 106 | 107 | /* VM2 virtqueue configurations */ 108 | vm2.recv1_id = 0; 109 | vm2.recv1_shmem_size = 8192; 110 | vm2.send1_id = 1; 111 | vm2.send1_shmem_size = 8192; 112 | 113 | /* Virtqueue Topology */ 114 | vm1_vm0.init_topology = [{ "drv" : "vm0.send1", "dev" : "vm1.recv1"}, 115 | { "drv" : "vm1.send1", "dev" : "vm0.recv1"}]; 116 | 117 | vm2_vm0.init_topology = [{ "drv" : "vm0.send2", "dev" : "vm2.recv1"}, 118 | { "drv" : "vm2.send1", "dev" : "vm0.recv2"}]; 119 | 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /apps/Arm/vm_serial_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(camkes-vm-virtio-net C) 10 | 11 | include(${CAMKES_ARM_VM_HELPERS_PATH}) 12 | 13 | find_package(camkes-vm-linux REQUIRED) 14 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 15 | 16 | # Create our CPP Flags based on ARM VM config variables 17 | set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422") 18 | 19 | AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux") 20 | # Generate overlayed rootfs 21 | set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/exynos5422/rootfs.cpio.gz") 22 | AddFileToOverlayDir( 23 | "inittab" 24 | ${CMAKE_CURRENT_SOURCE_DIR}/overlay_files/init_scripts/inittab_hvc0 25 | "etc" 26 | overlay 27 | ) 28 | 29 | AddOverlayDirToRootfs( 30 | overlay 31 | ${rootfs_file} 32 | "buildroot" 33 | "rootfs_install" 34 | output_overlayed_rootfs_location 35 | rootfs_target 36 | GZIP 37 | ) 38 | AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target) 39 | # Updated dtb based on generated initrd 40 | UpdateDtbFromInitrd( 41 | "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux-dtb-virtcon" 42 | ${output_overlayed_rootfs_location} 43 | "0x4d700000" 44 | dtb_gen_target 45 | output_dtb_location 46 | DEPENDS 47 | rootfs_target 48 | ) 49 | AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target) 50 | 51 | AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB Tk1DeviceFwd Tk1Insecure) 52 | 53 | DefineCAmkESVMFileServer() 54 | 55 | CAmkESAddImportPath(exynos5422) 56 | 57 | # Declare root server 58 | DeclareCAmkESRootserver( 59 | vm_serial_server.camkes 60 | CPP_FLAGS 61 | ${cpp_flags} 62 | CPP_INCLUDES 63 | ${CAMKES_VM_DIR}/components/VM_Arm 64 | ) 65 | -------------------------------------------------------------------------------- /apps/Arm/vm_serial_server/overlay_files/init_scripts/inittab_hvc0: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0-only 2 | 3 | # /etc/inittab 4 | # 5 | # Copyright (C) 2001 Erik Andersen 6 | # 7 | # Note: BusyBox init doesn't support runlevels. The runlevels field is 8 | # completely ignored by BusyBox init. If you want runlevels, use 9 | # sysvinit. 10 | # 11 | # Format for each entry: ::: 12 | # 13 | # id == tty to run on, or empty for /dev/console 14 | # runlevels == ignored 15 | # action == one of sysinit, respawn, askfirst, wait, and once 16 | # process == program to run 17 | 18 | # Startup the system 19 | ::sysinit:/bin/mount -t proc proc /proc 20 | ::sysinit:/bin/mount -o remount,rw / 21 | ::sysinit:/bin/mkdir -p /dev/pts /dev/shm 22 | ::sysinit:/bin/mount -a 23 | ::sysinit:/sbin/swapon -a 24 | null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd 25 | null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin 26 | null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout 27 | null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr 28 | ::sysinit:/bin/hostname -F /etc/hostname 29 | # now run any rc scripts 30 | ::sysinit:/etc/init.d/rcS 31 | 32 | # Put a getty on the serial port 33 | hvc0:2345:respawn:/sbin/getty -L 9600 hvc0 34 | 35 | # Stuff to do for the 3-finger salute 36 | #::ctrlaltdel:/sbin/reboot 37 | 38 | # Stuff to do before rebooting 39 | ::shutdown:/etc/init.d/rcK 40 | ::shutdown:/sbin/swapoff -a 41 | ::shutdown:/bin/umount -a -r 42 | -------------------------------------------------------------------------------- /apps/Arm/vm_serial_server/settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | set(supported "exynos5422") 8 | if(NOT "${PLATFORM}" IN_LIST supported) 9 | message(FATAL_ERROR "PLATFORM: ${PLATFORM} not supported. 10 | Supported: ${supported}") 11 | endif() 12 | set(KernelARMPlatform "${PLATFORM}" CACHE STRING "" FORCE) 13 | set(LibUSB OFF CACHE BOOL "" FORCE) 14 | set(VmPCISupport ON CACHE BOOL "" FORCE) 15 | set(VmVirtioConsole ON CACHE BOOL "" FORCE) 16 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 17 | set(VmDtbFile ON CACHE BOOL "provide dtb" FORCE) 18 | -------------------------------------------------------------------------------- /apps/Arm/vm_serial_server/vm_serial_server.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | import ; 8 | import ; 9 | import ; 10 | import ; 11 | 12 | assembly { 13 | composition { 14 | /* Connect all the components to use the serial server */ 15 | component SerialServer serial; 16 | component TimeServer time_server; 17 | connection seL4SerialServer serial_vm(from vm.batch, to serial.processed_batch); 18 | connection seL4SerialServer serial_input(from vm.serial_getchar, to serial.getchar); 19 | connection seL4TimeServer serialserver_timer(from serial.timeout, to time_server.the_timer); 20 | connection seL4VMDTBPassthrough vm_dtb(from vm.dtb_self, to vm.dtb); 21 | } 22 | configuration { 23 | vm.num_extra_frame_caps = 0; 24 | vm.extra_frame_map_address = 0; 25 | 26 | time_server.timers_per_client = 1; 27 | /* Put the entire time server at the highest priority */ 28 | time_server.priority = 255; 29 | time_server.simple = true; 30 | 31 | vm.serial_getchar_shmem_size = 0x1000; 32 | vm.batch_shmem_size = 0x1000; 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/overlay_files/init_scripts/arping_test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | echo "Testing arping on virtual interface:" 9 | arping 192.168.1.2 -c 5 -w 2 10 | # Success code for arping: 0 (arping returns non-zero value if packet count and timeout is not met) 11 | if [ $? -eq 0 ] 12 | then 13 | echo "arping test was successful" 14 | else 15 | echo "arping test failed" 16 | fi 17 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/overlay_files/init_scripts/ping_test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | echo "Testing ping on virtual interface:" 9 | ping 192.168.1.2 -v -c 5 -W 2 10 | # Success code for Ping: 0 (Ping returns non-zero value if packet count and timeout is not met) 11 | if [ $? -eq 0 ] 12 | then 13 | echo "Ping test was successful" 14 | else 15 | echo "Ping test failed" 16 | fi 17 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/overlay_files/init_scripts/zynqmp/arping_test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: arping_test 4 | # Required-Start: $networking 5 | # Required-Stop: 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 1 8 | # Short-Description: Configure virtio-net device 9 | ### END INIT INFO 10 | 11 | # 12 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 13 | # Copyright 2024, DornerWorks 14 | # 15 | # SPDX-License-Identifier: BSD-2-Clause 16 | # 17 | 18 | echo "Testing arping on virtual interface:" > /dev/console 19 | 20 | # Petalinux 2022.1 doesn't seem to like the /etc/network/interfaces file 21 | eth0_ip="192.168.1.1" 22 | ifconfig eth0 $eth0_ip 23 | 24 | arping 192.168.1.2 -c 5 -w 2 25 | # Success code for arping: 0 (arping returns non-zero value if packet count and timeout is not met) 26 | if [ $? -eq 0 ] 27 | then 28 | echo "arping test was successful" > /dev/console 29 | else 30 | echo "arping test failed" > /dev/console 31 | fi 32 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/overlay_files/init_scripts/zynqmp/ping_test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: ping_test 4 | # Required-Start: $networking 5 | # Required-Stop: 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 1 8 | # Short-Description: Configure virtio-net device 9 | ### END INIT INFO 10 | 11 | # 12 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 13 | # Copyright 2024, DornerWorks 14 | # 15 | # SPDX-License-Identifier: BSD-2-Clause 16 | # 17 | 18 | echo "Testing ping on virtual interface:" > /dev/console 19 | 20 | # Petalinux 2022.1 doesn't seem to like the /etc/network/interfaces file 21 | eth0_ip="192.168.1.1" 22 | ifconfig eth0 $eth0_ip 23 | 24 | ping 192.168.1.2 -v -c 5 -W 2 25 | # Success code for Ping: 0 (Ping returns non-zero value if packet count and timeout is not met) 26 | if [ $? -eq 0 ] 27 | then 28 | echo "Ping test was successful" > /dev/console 29 | else 30 | echo "Ping test failed" > /dev/console 31 | fi 32 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/overlay_files/network_interfaces/interfaces: -------------------------------------------------------------------------------- 1 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | auto lo 6 | iface lo inet loopback 7 | 8 | auto eth0 9 | iface eth0 inet static 10 | address 192.168.1.1 11 | netmask 255.255.255.0 12 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | set(supported "exynos5422;tx2;zcu102") 8 | if(NOT "${PLATFORM}" IN_LIST supported) 9 | message(FATAL_ERROR "PLATFORM: ${PLATFORM} not supported. 10 | Supported: ${supported}") 11 | endif() 12 | set(LibUSB OFF CACHE BOOL "" FORCE) 13 | set(VmPCISupport ON CACHE BOOL "" FORCE) 14 | if(VIRTIO_NET_PING) 15 | set(VmVirtioNetVirtqueue ON CACHE BOOL "" FORCE) 16 | else() 17 | set(VmVirtioNetArping ON CACHE BOOL "" FORCE) 18 | endif() 19 | set(VmInitRdFile ON CACHE BOOL "" FORCE) 20 | set(VmDtbFile ON CACHE BOOL "provide dtb" FORCE) 21 | 22 | if(${PLATFORM} STREQUAL "zcu102") 23 | set(AARCH64 ON CACHE BOOL "" FORCE) 24 | set(KernelAllowSMCCalls ON CACHE BOOL "" FORCE) 25 | set(VmZynqmpPetalinuxVersion 2022_1 CACHE STRING "" FORCE) 26 | endif() 27 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/tx2/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 10 | #define VM_RAM_BASE 0xF1000000 11 | #define VM_RAM_SIZE 0x8000000 12 | #define VM_RAM_OFFSET 0 13 | #define VM_DTB_ADDR 0xF2000000 14 | #define VM_INITRD_ADDR 0xF7000000 15 | 16 | assembly { 17 | composition {} 18 | configuration { 19 | 20 | vm0.linux_address_config = { 21 | "linux_ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 22 | "linux_ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 23 | "linux_ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 24 | "linux_ram_offset" : VAR_STRINGIZE(VM_RAM_OFFSET), 25 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 26 | "initrd_max_size" : VAR_STRINGIZE(VM_INITRD_MAX_SIZE), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR) 28 | }; 29 | 30 | vm0.linux_image_config = { 31 | "linux_bootcmdline" : "console=ttyS0,115200n1 no_console_suspend=1 earlycon=uart8250,mmio32,0x03100000 debug nosmp init=/sbin/init", 32 | "linux_stdout" : "/serial@3100000", 33 | }; 34 | 35 | vm0.dtb = dtb([ 36 | {"path": "/chipid@100000"}, 37 | {"path": "/gpio@2200000"}, 38 | {"path": "/pinmux@2430000"}, 39 | {"path": "/mc_sid@2c00000"}, 40 | {"path": "/mc"}, 41 | {"path": "/timer@3020000"}, 42 | {"path": "/efuse@3820000"}, 43 | {"path": "/serial@3100000"}, 44 | {"path": "/serial@3110000"}, 45 | {"path": "/serial@3130000"}, 46 | {"path": "/serial@3140000"}, 47 | {"path": "/serial@3150000"}, 48 | {"path": "/tachometer@39c0000"}, 49 | {"path": "/tegra-hsp@3c00000"}, 50 | {"path": "/clock@5000000"}, 51 | {"path": "/funnel_major@8010000"}, 52 | {"path": "/etf@8030000"}, 53 | {"path": "/etr@8050000"}, 54 | {"path": "/tpiu@8060000"}, 55 | {"path": "/stm@8070000"}, 56 | {"path": "/funnel_minor@8820000"}, 57 | {"path": "/ptm_bpmp@8a1c000"}, 58 | {"path": "/funnel_bccplex@9010000"}, 59 | {"path": "/ptm@9840000"}, 60 | {"path": "/ptm@9940000"}, 61 | {"path": "/ptm@9a40000"}, 62 | {"path": "/ptm@9b40000"}, 63 | {"path": "/tegra-hsp@b150000"}, 64 | {"path": "/tegra-hsp@c150000"}, 65 | {"path": "/gpio@c2f0000"}, 66 | {"path": "/pmc@c360000"}, 67 | {"path": "/pmc@c370000"}, 68 | /* bpmp node */ 69 | {"properties" : {"compatible[0]" : "nvidia,tegra186-bpmp"}}]); 70 | 71 | vm0.untyped_mmios = [ 72 | "0x3886000:12", // GICV Iface. 73 | /* The purpose of these untyped regions is to force the untyped 74 | * allocator to treat this memory region as reserved so that when we 75 | * try to ensure that the VMM is placed into this region in RAM, it 76 | * will definitely be available for placement. 77 | * 78 | * This address pertains to guest-vm@f1000000 in the overlay DTS 79 | */ 80 | "0xF1000000:24", 81 | "0xF2000000:25", 82 | "0xF4000000:26", 83 | "0xF8000000:24", 84 | ]; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/vm_echo_ping.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | import ; 10 | import ; 11 | import ; 12 | import ; 13 | import ; 14 | import ; 15 | import ; 16 | import ; 17 | import ; 18 | 19 | struct vswitch_mapping { 20 | string mac_addr; 21 | int send_id; 22 | int recv_id; 23 | }; 24 | 25 | component VM { 26 | VM_INIT_DEF() 27 | attribute vswitch_mapping vswitch_layout[] = []; 28 | attribute string vswitch_mac_address = ""; 29 | } 30 | 31 | component PingClient { 32 | control; 33 | /* Virtqueue connection for send and recv */ 34 | uses VirtQueueDev recv; 35 | uses VirtQueueDrv send; 36 | emits Callback self; 37 | consumes Callback ping_wait; 38 | } 39 | 40 | assembly { 41 | composition { 42 | VM_GENERAL_COMPOSITION_DEF() 43 | VM_COMPOSITION_DEF(0) 44 | 45 | component PingClient ping_client; 46 | component VirtQueueInit ping_vqinit0; 47 | component VirtQueueInit ping_vqinit1; 48 | 49 | connection seL4VirtQueues ping_virtq_conn0(to ping_vqinit0.init, from ping_client.send, from vm0.recv); 50 | connection seL4VirtQueues ping_virtq_conn1(to ping_vqinit1.init, from ping_client.recv, from vm0.send); 51 | connection seL4GlobalAsynchCallback ping_global_callback(from ping_client.self, to ping_client.ping_wait); 52 | connection seL4VMDTBPassthrough vm_dtb(from vm0.dtb_self, to vm0.dtb); 53 | } 54 | configuration { 55 | VM_GENERAL_CONFIGURATION_DEF() 56 | VM_CONFIGURATION_DEF(0) 57 | 58 | vm0.num_extra_frame_caps = 0; 59 | vm0.extra_frame_map_address = 0; 60 | vm0.cnode_size_bits = 23; 61 | vm0.simple_untyped24_pool = 12; 62 | 63 | vm0.recv_id = 0; 64 | vm0.recv_shmem_size = 32768; 65 | vm0.send_id = 1; 66 | vm0.send_shmem_size = 32768; 67 | vm0.vswitch_mac_address = "02:00:00:00:AA:01"; 68 | vm0.vswitch_layout = [{"mac_addr": "02:00:00:00:AA:02", "recv_id": 0, "send_id":1}]; 69 | 70 | ping_client.recv_id = 0; 71 | ping_client.recv_shmem_size = 32768; 72 | ping_client.send_id = 1; 73 | ping_client.send_shmem_size = 32768; 74 | ping_client.vswitch_mac_address = "02:00:00:00:AA:02"; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/vm_virtio_net.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | 9 | import ; 10 | import ; 11 | import ; 12 | import ; 13 | import ; 14 | import ; 15 | import ; 16 | import ; 17 | import ; 18 | 19 | component VM { 20 | VM_INIT_DEF() 21 | attribute string vswitch_mac_address = ""; 22 | } 23 | 24 | assembly { 25 | composition { 26 | VM_GENERAL_COMPOSITION_DEF() 27 | VM_COMPOSITION_DEF(0) 28 | connection seL4VMDTBPassthrough vm_dtb(from vm0.dtb_self, to vm0.dtb); 29 | } 30 | configuration { 31 | VM_GENERAL_CONFIGURATION_DEF() 32 | VM_CONFIGURATION_DEF(0) 33 | vm0.num_extra_frame_caps = 0; 34 | vm0.extra_frame_map_address = 0; 35 | vm0.cnode_size_bits = 23; 36 | vm0.simple_untyped24_pool = 12; 37 | vm0.vswitch_mac_address = "02:00:00:00:AA:01"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /apps/Arm/vm_virtio_net/zcu102/2022_1/devices.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023, DornerWorks 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #define VM_INITRD_MAX_SIZE 0x1900000 //25 MB 11 | #define VM_RAM_BASE 0x10000000 12 | #define VM_RAM_SIZE 0x10000000 13 | #define VM_ENTRY_ADDR 0x10080000 14 | #define VM_RAM_OFFSET 0 15 | #define VM_DTB_ADDR 0x12000000 16 | #define VM_INITRD_ADDR 0x13000000 17 | 18 | assembly { 19 | composition {} 20 | configuration { 21 | 22 | vm0.vm_address_config = { 23 | "ram_base" : VAR_STRINGIZE(VM_RAM_BASE), 24 | "ram_paddr_base" : VAR_STRINGIZE(VM_RAM_BASE), 25 | "ram_size" : VAR_STRINGIZE(VM_RAM_SIZE), 26 | "dtb_addr" : VAR_STRINGIZE(VM_DTB_ADDR), 27 | "initrd_addr" : VAR_STRINGIZE(VM_INITRD_ADDR), 28 | "kernel_entry_addr" : VAR_STRINGIZE(VM_ENTRY_ADDR), 29 | }; 30 | vm0.num_vcpus = 4; 31 | 32 | /* Extra untyped pool to allow for 256MB of RAM */ 33 | vm0.simple_untyped28_pool = 1; 34 | 35 | vm0.vm_image_config = { 36 | "kernel_name" : "linux", 37 | "initrd_name" : "linux-initrd", 38 | "dtb_base_name" : "linux-dtb", 39 | "kernel_bootcmdline" : "console=ttyPS0,115200 root=/dev/ram rw earlycon clk_ignore_unused net.ifnames=0", 40 | "kernel_stdout" : "serial0:115200n8", 41 | "generate_dtb" : true, 42 | "provide_dtb" : false, 43 | "map_one_to_one" : false, 44 | "provide_initrd": true, 45 | "clean_cache" : false, 46 | }; 47 | 48 | vm0.dtb = dtb([{"path": "/amba/serial@ff000000"} ]); 49 | 50 | vm0.untyped_mmios = ["0xf9060000:12"]; // Interrupt Controller Virtual CPU interface (Virtual Machine view) 51 | 52 | vm0.plat_keep_devices = [ 53 | "/pss_ref_clk", 54 | "/gt_crx_ref_clk", 55 | "/pss_alt_ref_clk", 56 | "/aux_ref_clk", 57 | "/video_clk", 58 | "/pmu", 59 | "/psci", 60 | "/timer", 61 | "/aliases", 62 | "/axi/interrupt-controller@f9010000", 63 | "/axi/serial@ff000000", 64 | ]; 65 | 66 | vm0.plat_keep_devices_and_subtree = [ 67 | "/firmware", 68 | ]; 69 | 70 | vm0.allow_smc = true; 71 | vm0.allowed_smc_functions = [ 72 | SMC_PM_GET_API_VERSION, 73 | SMC_PM_REQUEST_NODE, 74 | SMC_PM_RELEASE_NODE, 75 | SMC_PM_SET_REQUIREMENT, 76 | SMC_PM_INIT_FINALIZE, 77 | SMC_PM_FPGA_GET_STATUS, 78 | SMC_PM_RESET_ASSERT, 79 | SMC_PM_RESET_GET_STATUS, 80 | SMC_PM_MMIO_WRITE, 81 | SMC_PM_MMIO_READ, 82 | SMC_PM_GET_CHIPID, 83 | SMC_PM_PINCTRL_REQUEST, 84 | SMC_PM_PINCTRL_RELEASE, 85 | SMC_PM_PINCTRL_SET_FUNCTION, 86 | SMC_PM_PINCTRL_CONFIG_PARAM_GET, 87 | SMC_PM_PINCTRL_CONFIG_PARAM_SET, 88 | SMC_PM_IOCTL, 89 | SMC_PM_QUERY_DATA, 90 | SMC_PM_CLOCK_ENABLE, 91 | SMC_PM_CLOCK_DISABLE, 92 | SMC_PM_CLOCK_GETSTATE, 93 | SMC_PM_CLOCK_SETDIVIDER, 94 | SMC_PM_CLOCK_GETDIVIDER, 95 | SMC_PM_CLOCK_GETPARENT, 96 | SMC_PM_GET_TRUSTZONE_VERSION, 97 | SMC_PM_ADD_SUBSYSTEM, 98 | SMC_PM_FEATURE_CHECK, 99 | SMC_IPI_MAILBOX_OPEN, 100 | SMC_IPI_MAILBOX_RELEASE, 101 | SMC_IPI_MAILBOX_ENABLE_IRQ 102 | ]; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_centos/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(cma34cr_centos) 10 | 11 | # Include CAmkES VM helper functions 12 | include(${CAMKES_VM_HELPERS_PATH}) 13 | 14 | # Retrieve Init0 extra src files 15 | file(GLOB init0_extra src/*.c) 16 | # Declare VM component: Init0 17 | DeclareCAmkESVM(Init0 EXTRA_SOURCES ${init0_extra} EXTRA_LIBS ethdrivers) 18 | 19 | # Declare C162 Kernel 20 | DecompressLinuxKernel( 21 | decompress_linux decompressed_kernel ${CMAKE_CURRENT_SOURCE_DIR}/centos_linux/bzimage 22 | ) 23 | AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS decompress_linux) 24 | 25 | # Declare C162 Rootfs 26 | AddToFileServer("rootfs.cpio" ${CMAKE_CURRENT_SOURCE_DIR}/centos_linux/rootfs.cpio) 27 | 28 | # Provided by find_package(util_libs) 29 | include(${LWIP_HELPERS}) 30 | # Declare lwipopts.h include 31 | AddLWIPConfiguration(${CMAKE_CURRENT_SOURCE_DIR}/lwip_include) 32 | 33 | # Initialise CAmkES Root Server with addition CPP includes 34 | DeclareCAmkESVMRootServer( 35 | cma34cr_centos.camkes 36 | CPP_INCLUDES 37 | ${CAMKES_VM_DIR}/components/StringReverse/include 38 | ${CAMKES_VM_DIR}/components/Ethdriver/include 39 | configurations 40 | ) 41 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_centos/README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # CentOS Guest 8 | 9 | ## Installation 10 | 11 | CentOS should be installed on the 32GiB flash drive of the cma34cr using the entire drive, 12 | i.e. no dual booting etc. It must be an i386 CentOS 7 installation, images of which can be 13 | found at http://mirror.centos.org/altarch/7/isos/i386/ 14 | 15 | ## Kernel Image 16 | 17 | The bzimage and roofs.cpio in this directory are from altarch CentOS-7. They are the 18 | /boot/initramfs-3.10.0-693.5.2.el7.centos.plus.i686.img 19 | /boot/vmlinuz-3.10.0-693.5.2.el7.centos.plus.i686 20 | From an i386 CentOS-7 installation. You should be able to replace these with the 21 | equivalent files from any i386 CentOS-7 installation, regardless of the precise version, 22 | although you should not need to do this as this kernel/initramfs should be compatible with 23 | any installation. 24 | 25 | ## Kernel Command Line 26 | 27 | Assuming a default installation of CentOS the command line passed to the Linux kernel. 28 | In the case where you provided a custom name for your root partitions, or if 29 | something changes in later CentOS versions, then this needs to be updated from the 30 | command line in the grub configuration of your actual installation 31 | 32 | ## Booting the VMM 33 | 34 | After building you will have two files in the images/ directory, a kernel- and a capdl-. 35 | These need to be booted with a multiboot compatible loader, with the capdl- image passed 36 | as a boot module. This can be done with with a PXE based network loader, or by adding to 37 | the grub menu of the installed CentOS. 38 | 39 | ## Hardware Configuration 40 | 41 | The component specification assumes that the cma34cr is close to its default configuration, 42 | with the exception that the SATA controller has been placed into legacy IDE mode instead of 43 | its default AHCI mode. 44 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_centos/app_settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | # Define kernel config options 10 | set(KernelSel4Arch x86_64 CACHE STRING "" FORCE) 11 | set(KernelMaxNumNodes 2 CACHE STRING "" FORCE) 12 | set(KernelMultibootGFXMode linear CACHE STRING "" FORCE) 13 | set(KernelMultibootGFXModeWidth 0 CACHE STRING "" FORCE) 14 | set(KernelMultibootGFXModeDepth 0 CACHE STRING "" FORCE) 15 | set(KernelMultibootGFXModeHeight 0 CACHE STRING "" FORCE) 16 | 17 | # cma34cr platform doesn't support HugePage or PCID 18 | set(KernelHugePage OFF CACHE BOOL "" FORCE) 19 | set(KernelSupportPCID OFF CACHE BOOL "" FORCE) 20 | 21 | # Define VMM configurations 22 | set(LibSel4VMMPlatsupportVESAFrameBuffer ON CACHE BOOL "" FORCE) 23 | 24 | # Enable LWIP 25 | set(LibLwip ON CACHE BOOL "" FORCE) 26 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_centos/centos_linux/bzimage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/apps/x86/cma34cr_centos/centos_linux/bzimage -------------------------------------------------------------------------------- /apps/x86/cma34cr_centos/centos_linux/rootfs.cpio: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/apps/x86/cma34cr_centos/centos_linux/rootfs.cpio -------------------------------------------------------------------------------- /apps/x86/cma34cr_centos/configurations/cma34cr_centos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | 7 | #define PASSTHROUGH_SATA 8 | /*#define PASSTHROUGH_ETHERNET*/ 9 | 10 | /* Kernel cmdline for guests */ 11 | #define VM_GUEST_CMDLINE "earlyprintk=ttyS0,115200 console=ttyS0,115200 i8042.nokbd=y i8042.nomux=y i8042.noaux=y io_delay=udelay noisapnp pci=nomsi debug root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rdinit=/init 5" 12 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_centos/lwip_include/lwipopts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Simon Goldschmidt 30 | */ 31 | 32 | // SPDX-License-Identifier: BSD-3-Clause 33 | 34 | #ifndef __LWIPOPTS_H__ 35 | #define __LWIPOPTS_H__ 36 | 37 | /* Prevent having to link sys_arch.c (we don't test the API layers in unit tests) */ 38 | #define NO_SYS 1 39 | #define NO_SYS_NO_TIMERS 1 40 | #define LWIP_NETCONN 0 41 | #define LWIP_SOCKET 0 42 | #define LWIP_IGMP 1 43 | #define LWIP_RAND rand 44 | 45 | #define MEM_ALIGNMENT 4 46 | #define MEM_SIZE 16000 47 | 48 | #define ETHARP_SUPPORT_STATIC_ENTRIES 1 49 | #define SYS_LIGHTWEIGHT_PROT 0 50 | 51 | /* Get lwip to queue any packets whilst waiting for ARP response. Otherwise lwip will 52 | * only hold the latest packet until the ARP is resolved. */ 53 | #define ARP_QUEUEING 1 54 | 55 | #endif /* __LWIPOPTS_H__ */ 56 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_centos/src/cross_vm_connections.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /* these are defined in the dataport's glue code */ 16 | extern dataport_caps_handle_t dp1_handle; 17 | extern dataport_caps_handle_t dp2_handle; 18 | 19 | static struct camkes_crossvm_connection connections[] = { 20 | {&dp1_handle, ready_emit, {.id = -1, .reg_callback = NULL}}, 21 | {&dp2_handle, NULL, { .id = 1, .reg_callback = done_reg_callback }} 22 | }; 23 | 24 | int camkes_cross_vm_connections_init(vm_t *vm, vmm_pci_space_t *pci, seL4_CPtr irq_notification, 25 | uintptr_t connection_base_address) 26 | { 27 | return cross_vm_connections_init(vm, connection_base_address, connections, ARRAY_SIZE(connections), pci, 28 | irq_notification); 29 | } 30 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_ubuntu/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(cma34cr_ubuntu) 10 | 11 | CAmkESAddImportPath(components) 12 | 13 | # Include CAmkES VM helper functions 14 | include(${CAMKES_VM_HELPERS_PATH}) 15 | find_package(camkes-vm-linux REQUIRED) 16 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 17 | 18 | # Declare VM component: Init0 19 | DeclareCAmkESVM(Init0) 20 | 21 | # Declare C162 Kernel 22 | GetArchSpecificLinuxKernelFile("32" kernel_file) 23 | DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) 24 | AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) 25 | 26 | # Declare C162 Rootfs 27 | AddToFileServer("rootfs.cpio" ${CMAKE_CURRENT_SOURCE_DIR}/ubuntu_linux/rootfs.cpio) 28 | 29 | # Initialise CAmkES Root Server with addition CPP includes 30 | DeclareCAmkESVMRootServer(cma34cr_ubuntu.camkes) 31 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_ubuntu/README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # UbuntuOS Guest 8 | 9 | ## Installation 10 | 11 | This example has been tested by booting Ubuntu 18.04 LTS from a USB flash drive connected to the 12 | cma34cr. Ubuntu can also be booted from the flash drive of the cma34cr by using the entire drive, 13 | i.e. no dual booting etc. See the centos example for the appropriate hardware passthrough configuration. 14 | 15 | ## Kernel Image 16 | 17 | The roofs.cpio in this directory is built from a Ubuntu 18.04 installation. This was generated as per 18 | the instructions found [here](https://docs.sel4.systems/projects/camkes-vm/#booting-from-hard-drive) 19 | 20 | ## Kernel Command Line 21 | 22 | Assuming a default installation of Ubuntu the command line passed to the Linux kernel. 23 | In the case where you provided a custom name for your root partitions, or if 24 | something changes in later Ubuntu versions, then this needs to be updated from the 25 | command line in the grub configuration of your actual installation 26 | 27 | ## Booting the VMM 28 | 29 | After building you will have two files in the images/ directory, a kernel- and a capdl-. 30 | These need to be booted with a multiboot compatible loader, with the capdl- image passed 31 | as a boot module. This can be done with with a PXE based network loader, or by adding to 32 | the grub menu of the installed Ubuntu distro. 33 | 34 | ## Hardware Configuration 35 | 36 | The hardware configuration for this example is minimal. This includes the passing of 37 | cma34cr USB hardware. For details on passing through ethernet and SATA hardware see the 38 | centos example. 39 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_ubuntu/app_settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | # Define kernel config options 10 | set(KernelSel4Arch x86_64 CACHE STRING "" FORCE) 11 | set(KernelMaxNumNodes 2 CACHE STRING "" FORCE) 12 | set(KernelHugePage OFF CACHE BOOL "" FORCE) 13 | set(KernelSupportPCID OFF CACHE BOOL "" FORCE) 14 | 15 | set(KernelMultibootGFXMode linear CACHE STRING "" FORCE) 16 | set(KernelMultibootGFXModeWidth 0 CACHE STRING "" FORCE) 17 | set(KernelMultibootGFXModeDepth 0 CACHE STRING "" FORCE) 18 | set(KernelMultibootGFXModeHeight 0 CACHE STRING "" FORCE) 19 | 20 | # Define VMM configurations 21 | set(LibSel4VMMPlatsupportVESAFrameBuffer ON CACHE BOOL "" FORCE) 22 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_ubuntu/cma34cr_ubuntu.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | 7 | import ; 8 | 9 | #include 10 | 11 | #define VM_GUEST_CMDLINE "earlyprintk=ttyS0,115200 console=ttyS0,115200 i8042.nokbd=y i8042.nomux=y i8042.noaux=y \ 12 | io_delay=udelay noisapnp pci=nomsi debug root=/dev/sda1" 13 | 14 | component Init0 { 15 | VM_INIT_DEF() 16 | } 17 | 18 | assembly { 19 | composition { 20 | VM_COMPOSITION_DEF() 21 | VM_PER_VM_COMP_DEF(0) 22 | 23 | } 24 | configuration { 25 | VM_CONFIGURATION_DEF() 26 | VM_PER_VM_CONFIG_DEF(0) 27 | vm0.simple_untyped24_pool = 48; 28 | vm0.heap_size = 0x10000; 29 | vm0.guest_ram_mb = 512; 30 | vm0.kernel_cmdline = VM_GUEST_CMDLINE; 31 | vm0.kernel_image = "bzimage"; 32 | vm0.kernel_relocs = "bzimage"; 33 | vm0.initrd_image = "rootfs.cpio"; 34 | vm0.iospace_domain = 0x0f; 35 | vm0.pci_devices_iospace = 1; 36 | 37 | // For VESA vframebuffer 38 | vm0.untyped_mmios = ["0xb0000000:28"]; 39 | vm0.simple_extra_bootinfo = ["SEL4_BOOTINFO_HEADER_X86_VBE"]; 40 | vm0.cnode_size_bits = 24; 41 | 42 | vm0.pci_devices = [ 43 | #ifdef USB1 44 | { 45 | "name":"USB1", 46 | "bus":0, "dev":0x14, "fun":0, 47 | "irq":"USB1", 48 | "memory":[ 49 | {"paddr":0xc0700000, "size":0x400, "page_bits":12}, 50 | ], 51 | }, 52 | #endif 53 | { 54 | "name":"USB2", 55 | "bus":0, "dev":0x1a, "fun":0, 56 | "irq":"USB2", 57 | "memory":[ 58 | {"paddr":0xc0714000, "size":0x400, "page_bits":12}, 59 | ], 60 | }, 61 | { 62 | "name":"USB3", 63 | "bus":0, "dev":0x1d, "fun":0, 64 | "irq":"USB3", 65 | "memory":[ 66 | {"paddr":0xc0713000, "size":0x400, "page_bits":12}, 67 | ], 68 | }, 69 | ]; 70 | vm0.vm_irqs = [ 71 | #ifdef USB1 72 | {"name":"USB1", "source":0x1c, "level_trig":1, "active_low":1, "dest":16}, 73 | #endif 74 | {"name":"USB2", "source":0x10, "level_trig":1, "active_low":1, "dest":14}, 75 | {"name":"USB3", "source":0x17, "level_trig":1, "active_low":1, "dest":15}, 76 | ]; 77 | 78 | // These ranges are RMRR for the IOMMU and so we must exclude the from the guest 79 | // physical address space as we cannot overwrite the mappings that will already exist 80 | // in the iommu for them 81 | vm0.exclude_paddr = [ [0xaae84000, 0x20000], [0xab800000, 0x4200000]]; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /apps/x86/cma34cr_ubuntu/ubuntu_linux/rootfs.cpio: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/apps/x86/cma34cr_ubuntu/ubuntu_linux/rootfs.cpio -------------------------------------------------------------------------------- /apps/x86/minimal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(minimal) 10 | 11 | # Include CAmkES VM helper functions 12 | include(${CAMKES_VM_HELPERS_PATH}) 13 | find_package(camkes-vm-linux REQUIRED) 14 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 15 | # message(WARNING "${CAMKES_VM_HELPERS_PATH}") 16 | 17 | # message(FATAL_ERROR "${CAMKES_VM_LINUX_HELPERS_PATH}") 18 | 19 | # Declare VM component: Init0 20 | DeclareCAmkESVM(Init0) 21 | 22 | # Get Default Linux VM files 23 | GetDefaultLinuxKernelFile(kernel_file) 24 | GetDefaultLinuxRootfsFile(rootfs_file) 25 | 26 | # Decompress Linux Kernel image and add to file server 27 | DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) 28 | AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) 29 | 30 | # Add rootfs images into file server 31 | AddToFileServer("rootfs.cpio" ${rootfs_file}) 32 | 33 | # Initialise CAmkES Root Server with addition CPP includes 34 | DeclareCAmkESVMRootServer(minimal.camkes) 35 | 36 | if(SIMULATION) 37 | include(simulation) 38 | GenerateSimulateScript() 39 | endif() -------------------------------------------------------------------------------- /apps/x86/minimal/app_settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | # Define kernel config options 10 | set(KernelSel4Arch ia32 CACHE STRING "" FORCE) 11 | set(KernelMaxNumNodes 1 CACHE STRING "" FORCE) 12 | -------------------------------------------------------------------------------- /apps/x86/minimal/minimal.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | 7 | import ; 8 | 9 | #include 10 | 11 | #define VM_GUEST_CMDLINE "earlyprintk=ttyS0,115200 console=ttyS0,115200 i8042.nokbd=y i8042.nomux=y \ 12 | i8042.noaux=y io_delay=udelay noisapnp pci=nomsi debug root=/dev/mem" 13 | 14 | component Init0 { 15 | VM_INIT_DEF() 16 | } 17 | 18 | assembly { 19 | composition { 20 | VM_COMPOSITION_DEF() 21 | VM_PER_VM_COMP_DEF(0) 22 | } 23 | 24 | configuration { 25 | VM_CONFIGURATION_DEF() 26 | VM_PER_VM_CONFIG_DEF(0) 27 | 28 | vm0.simple_untyped23_pool = 20; 29 | vm0.heap_size = 0x2000000; 30 | vm0.guest_ram_mb = 128; 31 | vm0.kernel_cmdline = VM_GUEST_CMDLINE; 32 | vm0.kernel_image = "bzimage"; 33 | vm0.kernel_relocs = "bzimage"; 34 | vm0.initrd_image = "rootfs.cpio"; 35 | vm0.iospace_domain = 0x0f; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /apps/x86/minimal_64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023, DornerWorks 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(minimal_64) 10 | 11 | # Include CAmkES VM helper functions 12 | include(${CAMKES_VM_HELPERS_PATH}) 13 | find_package(camkes-vm-linux REQUIRED) 14 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 15 | 16 | # Declare VM component: Init0 17 | DeclareCAmkESVM(Init0) 18 | 19 | # Get Default Linux VM files 20 | GetDefaultLinuxKernelFile(kernel_file) 21 | GetDefaultLinuxRootfsFile(rootfs_file) 22 | 23 | # Decompress Linux Kernel image and add to file server 24 | DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) 25 | AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) 26 | 27 | # Add rootfs images into file server 28 | AddToFileServer("rootfs.cpio" ${rootfs_file}) 29 | 30 | # Initialise CAmkES Root Server with addition CPP includes 31 | DeclareCAmkESVMRootServer(minimal.camkes) 32 | 33 | if(SIMULATION) 34 | include(simulation) 35 | GenerateSimulateScript() 36 | endif() 37 | -------------------------------------------------------------------------------- /apps/x86/minimal_64/app_settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023, DornerWorks 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | # Define kernel config options 10 | set(KernelSel4Arch x86_64 CACHE STRING "" FORCE) 11 | set(KernelX86_64VTX64BitGuests ON CACHE BOOL "" FORCE) 12 | set(KernelMaxNumNodes 1 CACHE STRING "" FORCE) 13 | set(LibSel4VMMUseHPET ON CACHE BOOL "" FORCE) 14 | -------------------------------------------------------------------------------- /apps/x86/minimal_64/minimal.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023, DornerWorks 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | import ; 8 | 9 | #include 10 | 11 | #define VM_GUEST_CMDLINE "earlyprintk=ttyS0,115200 console=ttyS0,115200 i8042.nokbd=y i8042.nomux=y \ 12 | i8042.noaux=y io_delay=udelay noisapnp pci=nomsi debug root=/dev/mem" 13 | 14 | component Init0 { 15 | VM_INIT_DEF() 16 | } 17 | 18 | assembly { 19 | composition { 20 | VM_COMPOSITION_DEF() 21 | VM_PER_VM_COMP_DEF(0) 22 | } 23 | 24 | configuration { 25 | VM_CONFIGURATION_DEF() 26 | VM_PER_VM_CONFIG_DEF(0) 27 | 28 | vm0.simple_untyped23_pool = 20; 29 | vm0.heap_size = 0x2000000; 30 | vm0.guest_ram_mb = 128; 31 | vm0.kernel_cmdline = VM_GUEST_CMDLINE; 32 | vm0.kernel_image = "bzimage"; 33 | vm0.kernel_relocs = ""; 34 | vm0.initrd_image = "rootfs.cpio"; 35 | vm0.iospace_domain = 0x0f; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /apps/x86/optiplex9020/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(optiplex9020) 10 | 11 | # Include CAmkES VM helper 12 | include(${CAMKES_VM_HELPERS_PATH}) 13 | find_package(camkes-vm-linux REQUIRED) 14 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 15 | 16 | # Retrieve Init0 extra src files 17 | file(GLOB init0_extra src/*.c) 18 | # Declare VM component: Init0 19 | DeclareCAmkESVM(Init0 EXTRA_SOURCES ${init0_extra} EXTRA_LIBS ethdrivers) 20 | # Declare VM component: Init1 21 | DeclareCAmkESVM(Init1) 22 | 23 | # Get 32-bit Linux VM files 24 | GetArchDefaultLinuxKernelFile("32" kernel_file) 25 | GetArchDefaultLinuxRootfsFile("32" rootfs_file) 26 | 27 | # Decompress Linux Kernel image 28 | DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) 29 | 30 | # Add Linux VM images into file server 31 | AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) 32 | AddToFileServer("rootfs.cpio" ${rootfs_file}) 33 | 34 | # Initialise CAmkES Root Server with additional CPP includes 35 | DeclareCAmkESVMRootServer( 36 | optiplex9020.camkes CPP_INCLUDES ${CAMKES_VM_DIR}/components/StringReverse/include 37 | ) 38 | -------------------------------------------------------------------------------- /apps/x86/optiplex9020/app_settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | # Define kernel config options 10 | set(KernelSel4Arch x86_64 CACHE STRING "" FORCE) 11 | set(KernelMaxNumNodes 1 CACHE STRING "" FORCE) 12 | -------------------------------------------------------------------------------- /apps/x86/optiplex9020/optiplex9020.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | 7 | import ; 8 | 9 | #include 10 | #include 11 | 12 | #define VM_GUEST_CMDLINE "earlyprintk=ttyS0,115200 console=ttyS0,115200 root=/dev/mem i8042.nokbd=iy \ 13 | i8042.nomux=y i8042.noaux=y io_delay=udelay noisapnp pci=nomsi" 14 | 15 | component Init0 { 16 | dataport Buf(STRING_REVERSE_BUFSIZE) dp1; 17 | dataport Buf(STRING_REVERSE_BUFSIZE) dp2; 18 | 19 | emits Ready ready; 20 | consumes Done done; 21 | 22 | has mutex cross_vm_event_mutex; 23 | 24 | VM_INIT_DEF() 25 | } 26 | 27 | component Init1 { 28 | VM_INIT_DEF() 29 | } 30 | 31 | import ; 32 | 33 | assembly { 34 | composition { 35 | VM_COMPOSITION_DEF() 36 | VM_PER_VM_COMP_DEF(0) 37 | VM_PER_VM_COMP_DEF(1) 38 | 39 | component StringReverse string_reverse; 40 | 41 | connection seL4SharedDataWithCaps cross_vm_conn(from string_reverse.src_dp, 42 | to vm0.dp1); 43 | 44 | connection seL4SharedDataWithCaps cross_vm_large_conn(from string_reverse.dest_dp, 45 | to vm0.dp2); 46 | 47 | connection seL4Notification ev2_conn(from vm0.ready, 48 | to string_reverse.ready); 49 | 50 | connection seL4Notification ev1_conn(from string_reverse.done, 51 | to vm0.done); 52 | 53 | connection seL4RPCCall cross_vm_putchar(from string_reverse.putchar, 54 | to serial.processed_putchar); 55 | } 56 | configuration { 57 | VM_CONFIGURATION_DEF() 58 | VM_PER_VM_CONFIG_DEF(0) 59 | vm0.simple_untyped23_pool = 21; 60 | vm0.simple_untyped22_pool = 1; 61 | vm0.heap_size = 0x10000; 62 | vm0.guest_ram_mb = 128; 63 | vm0.kernel_cmdline = VM_GUEST_CMDLINE; 64 | vm0.kernel_image = "bzimage"; 65 | vm0.kernel_relocs = "bzimage"; 66 | vm0.initrd_image = "rootfs.cpio"; 67 | vm0.iospace_domain = 0x0f; 68 | vm0.pci_devices_iospace = 1; 69 | 70 | vm0.dp1_id = 1; 71 | vm0.dp1_size = STRING_REVERSE_BUFSIZE; 72 | 73 | vm0.dp2_id = 2; 74 | vm0.dp2_size = STRING_REVERSE_BUFSIZE; 75 | 76 | VM_PER_VM_CONFIG_DEF(1) 77 | vm1.simple_untyped23_pool = 21; 78 | vm1.simple_untyped22_pool = 1; 79 | vm1.heap_size = 0x10000; 80 | vm1.guest_ram_mb = 128; 81 | vm1.kernel_cmdline = VM_GUEST_CMDLINE; 82 | vm1.kernel_image = "bzimage"; 83 | vm1.kernel_relocs = "bzimage"; 84 | vm1.initrd_image = "rootfs.cpio"; 85 | vm1.iospace_domain = 0x10; 86 | vm1.pci_devices_iospace = 2; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /apps/x86/optiplex9020/src/cross_vm_connections.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /* these are defined in the dataport's glue code */ 16 | extern dataport_caps_handle_t dp1_handle; 17 | extern dataport_caps_handle_t dp2_handle; 18 | 19 | static struct camkes_crossvm_connection connections[] = { 20 | {&dp1_handle, ready_emit, {.id = -1, .reg_callback = NULL}}, 21 | {&dp2_handle, NULL, { .id = 1, .reg_callback = done_reg_callback }} 22 | }; 23 | 24 | int camkes_cross_vm_connections_init(vm_t *vm, vmm_pci_space_t *pci, seL4_CPtr irq_notification, 25 | uintptr_t connection_base_address) 26 | { 27 | return cross_vm_connections_init(vm, connection_base_address, connections, ARRAY_SIZE(connections), pci, 28 | irq_notification); 29 | } 30 | -------------------------------------------------------------------------------- /apps/x86/virtio_blk_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020, DornerWorks 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(virtio_blk_sample) 10 | 11 | # Include CAmkES VM helper functions 12 | include(${CAMKES_VM_HELPERS_PATH}) 13 | find_package(camkes-vm-linux REQUIRED) 14 | include(${CAMKES_VM_LINUX_HELPERS_PATH}) 15 | 16 | # Declare VM components: Init0 17 | DeclareCAmkESVM(Init0) 18 | 19 | # Get Default Linux VM files 20 | GetDefaultLinuxKernelFile(kernel_file) 21 | GetDefaultLinuxRootfsFile(rootfs_file) 22 | 23 | # Decompress Linux Kernel image and add to file server 24 | DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file}) 25 | AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel) 26 | 27 | AddToFileServer("rootfs.cpio" ${rootfs_file}) 28 | 29 | DeclareCAmkESVMRootServer(virtio_blk_sample.camkes) 30 | 31 | if(SIMULATION) 32 | include(simulation) 33 | GenerateSimulateScript() 34 | endif() 35 | -------------------------------------------------------------------------------- /apps/x86/virtio_blk_sample/app_settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019, DornerWorks 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | # Define kernel config options 10 | set(KernelSel4Arch ia32 CACHE STRING "") 11 | 12 | set(KernelMaxNumNodes 1 CACHE STRING "" FORCE) 13 | set(KernelHugePage OFF CACHE BOOL "" FORCE) 14 | 15 | ApplyCommonSimulationSettings(${KernelArch}) 16 | set(KernelIOMMU ON CACHE BOOL "" FORCE) 17 | 18 | # Use AHCI by default 19 | set(SataserverUseAHCI ON CACHE STRING "") 20 | 21 | set(CAmkESVMDestHardware "optiplex" CACHE STRING "" FORCE) 22 | -------------------------------------------------------------------------------- /apps/x86/virtio_blk_sample/virtio_blk_sample.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020, DornerWorks 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | /* 8 | * Sample QEMU invocation to test this on QEMU: 9 | * qemu-system-i386 -machine q35,accel=kvm,kernel-irqchip=split \ 10 | * -cpu Nehalem,+vme,-pdpe1gb,+xsave,+xsaveopt,-xsavec,-fsgsbase,-invpcid,-syscall,-lm,enforce,+vmx \ 11 | * -nographic -serial mon:stdio -m size=4G -enable-kvm \ 12 | * -kernel images/kernel-ia32-pc99 \ 13 | * -initrd images/capdl-loader-image-ia32-pc99 \ 14 | * -device intel-iommu,intremap=off \ 15 | * -drive id=disk,file=/path/to/file.img,if=none -device ahci,id=ahci -device ide-hd,drive=disk,bus=ide.0 16 | * 17 | * This requires nested virtualisation to be turned on. 18 | * https://www.linux-kvm.org/page/Nested_Guests 19 | * 20 | * Your file.img should have an MSDOS partition table; partition 1 will be 21 | * made available to the VM. 22 | * 23 | * A suitable file can be created thus: 24 | * dd if=/dev/zero of=file1.img bs=1024k count=1024 25 | * mke2fs -L 'part1' file1.img 26 | * dd if=/dev/zero of=file2.img bs=1024k count=1024 27 | * mke2fs -L 'part2' file2.img 28 | * dd if=/dev/zero of=file.img bs=1024k count=1 29 | * cat file1.img file2.img >> file.img 30 | * rm file[12].img 31 | * parted file.img mklabel msdos 32 | * parted file.img mkpart primary 1MiB 1025MiB 33 | * parted file.img mkpart primary 1025MiB '100%' 34 | * 35 | */ 36 | 37 | import ; 38 | 39 | #include 40 | #include 41 | 42 | #define VM_GUEST_CMDLINE "earlyprintk=ttyS0,115200 console=ttyS0,115200 i8042.nokbd=y i8042.nomux=y \ 43 | i8042.noaux=y noisapnp pci=nomsi,noacpi nolapic_timer" 44 | 45 | component Init0 { 46 | VM_INIT_DEF() 47 | VM_INIT_SATA() 48 | } 49 | 50 | assembly { 51 | composition { 52 | VM_COMPOSITION_DEF() 53 | SATA_COMPOSITION_DEF() 54 | 55 | VM_PER_VM_COMP_DEF(0) 56 | VM_SATA_CONNECTIONS(0) 57 | } 58 | 59 | configuration { 60 | VM_CONFIGURATION_DEF() 61 | VM_PER_VM_CONFIG_DEF(0) 62 | 63 | VM_SATA_CONFIG() 64 | 65 | sataserver.ioports = "0xf090:0xf097,0xf080:0xf083,0xf070:0xf077,0xf060:0xf063,0xf020:0xf03f"; 66 | sataserver.iospaces = "0x12:0x0:0x1f:2"; 67 | sataserver.pci_bdfs = "0x0:0x1f.2"; 68 | sataserver.iospace_id = 0x12; 69 | sataserver.num_bdfs = 1; 70 | sataserver.drive = 0; 71 | 72 | vm0.simple_untyped23_pool = 20; 73 | vm0.heap_size = 0x2000000; 74 | vm0.dma_pool = 0x20000; 75 | vm0.guest_ram_mb = 128; 76 | vm0.kernel_cmdline = VM_GUEST_CMDLINE; 77 | vm0.kernel_image = "bzimage"; 78 | vm0.kernel_relocs = "bzimage"; 79 | vm0.initrd_image = "rootfs.cpio"; 80 | vm0.iospace_domain = 0x0f; 81 | vm0.cnode_size_bits = 21; 82 | 83 | vm0.sched_ctrl = [0, 1, 2, 3, 4, 5]; 84 | 85 | vm0.sataserver_iface_attributes = "0"; 86 | vm0.sataserver_iface_partitions = [1]; /* Physical Partition assigned to VM0 */ 87 | 88 | vm0.init_cons = [ 89 | {"init":"make_virtio_blk"}, 90 | ]; 91 | 92 | vm0.pci_devices_iospace = 1; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/app_settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | # Define kernel config options 10 | set(KernelSel4Arch x86_64 CACHE STRING "" FORCE) 11 | set(KernelMaxNumNodes 1 CACHE STRING "" FORCE) 12 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/components/cakeml-filter/global_endpoint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: BSD-2-Clause 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define FFI_SUCCESS 0 12 | #define FFI_FAILURE 1 13 | 14 | seL4_CPtr virtqueue_wait_notification(void); 15 | 16 | // Return the global endpoint for our CakeML filter component 17 | void ffiget_global_endpoint(char * c, unsigned long clen, char * a, unsigned long alen) { 18 | assert(alen >= 1 + sizeof(seL4_CPtr)); 19 | seL4_CPtr src = virtqueue_wait_notification(); 20 | memcpy(a + 1, &src, sizeof(seL4_CPtr)); 21 | a[0] = FFI_SUCCESS; 22 | } 23 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/libs/cakeml_helpers.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | # Build a linear chain of CakeML/HOL scripts from a list of libraries 10 | # Each library should contain @DEPENDENCY_PATH@ wherever it refers to its parent, 11 | # e.g. in the list of `open`ed modules, and as an argument to `translation_extends`. 12 | # This allows us to depend on a subset of available libraries, stitched together 13 | # in the appropriate order. Output files are placed in `dest_dir`. 14 | # 15 | # Usage: CakeMLPP(dest_dir source_files...) 16 | # CakeMLPP(some/dest_dir dir1/firstDepScript.sml dir2/secondDepScript.sml ...) 17 | function(CakeMLPP dest_dir) 18 | # First library should depend on camkesStart 19 | set(DEPENDENCY_PATH "camkesStart") 20 | foreach(source_file ${ARGN}) 21 | get_filename_component(filename ${source_file} NAME) 22 | set(dest_file ${dest_dir}/${filename}) 23 | configure_file(${source_file} ${dest_file} @ONLY) 24 | set_property( 25 | DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 26 | APPEND 27 | PROPERTY CMAKE_CONFIGURE_DEPENDS "${source_file}" 28 | ) 29 | string( 30 | REGEX 31 | REPLACE 32 | "Script.sml" 33 | "" 34 | theory_name 35 | ${filename} 36 | ) 37 | set(DEPENDENCY_PATH ${theory_name}) 38 | endforeach() 39 | endfunction() 40 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/scripts/network_interface_0: -------------------------------------------------------------------------------- 1 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | auto lo 6 | iface lo inet loopback 7 | 8 | auto eth0 9 | iface eth0 inet static 10 | address 192.168.1.1 11 | netmask 255.255.255.0 12 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/scripts/network_interface_1: -------------------------------------------------------------------------------- 1 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | auto lo 6 | iface lo inet loopback 7 | 8 | auto eth0 9 | iface eth0 inet static 10 | address 192.168.1.2 11 | netmask 255.255.255.0 12 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/scripts/network_interface_2: -------------------------------------------------------------------------------- 1 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 2 | # 3 | # SPDX-License-Identifier: BSD-2-Clause 4 | 5 | auto lo 6 | iface lo inet loopback 7 | 8 | auto eth0 9 | iface eth0 inet static 10 | address 192.168.1.3 11 | netmask 255.255.255.0 12 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.8.2) 8 | 9 | project(demoapps) 10 | 11 | # This finds and imports the ZMQ library that is built by another project 12 | find_package(ZeroMQ "4.2.5" EXACT) 13 | 14 | macro(create_bin name file) 15 | add_executable(${name} ${file}) 16 | target_link_libraries(${name} -static libzmq-static) 17 | install(TARGETS ${name} DESTINATION bin/) 18 | endmacro() 19 | 20 | 21 | create_bin(client clientserver/client.c) 22 | create_bin(server clientserver/server.c) 23 | 24 | create_bin(pub pubsub/pub.c) 25 | create_bin(sub pubsub/sub.c) 26 | 27 | create_bin(sink pipeline/sink.c) 28 | create_bin(source pipeline/source.c) 29 | create_bin(worker pipeline/worker.c) 30 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/clientserver/client.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: LGPL-3.0-or-later */ 2 | 3 | /* 4 | Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file 5 | 6 | This file is part of libzmq, the ZeroMQ core engine in C++. 7 | 8 | libzmq is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License (LGPL) as published 10 | by the Free Software Foundation; either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | As a special exception, the Contributors give you permission to link 14 | this library with independent modules to produce an executable, 15 | regardless of the license terms of these independent modules, and to 16 | copy and distribute the resulting executable under terms of your choice, 17 | provided that you also meet, for each linked independent module, the 18 | terms and conditions of the license of that module. An independent 19 | module is a module which is not derived from or based on this library. 20 | If you modify this library, you must extend this exception to your 21 | version of the library. 22 | 23 | libzmq is distributed in the hope that it will be useful, but WITHOUT 24 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 26 | License for more details. 27 | 28 | You should have received a copy of the GNU Lesser General Public License 29 | along with this program. If not, see . 30 | */ 31 | 32 | /* Sourced from libzmq */ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | int main (int argc, char *argv[]) 40 | { 41 | const char *connect_to; 42 | int roundtrip_count; 43 | size_t message_size; 44 | void *ctx; 45 | void *s; 46 | int rc; 47 | int i; 48 | zmq_msg_t msg; 49 | void *watch; 50 | unsigned long elapsed; 51 | double latency; 52 | 53 | if (argc != 4) { 54 | printf ("usage: %s " 55 | "\n", argv[0]); 56 | return 1; 57 | } 58 | connect_to = argv[1]; 59 | message_size = atoi (argv[2]); 60 | roundtrip_count = atoi (argv[3]); 61 | 62 | ctx = zmq_init (1); 63 | if (!ctx) { 64 | printf ("error in zmq_init: %s\n", zmq_strerror (errno)); 65 | return -1; 66 | } 67 | 68 | s = zmq_socket (ctx, ZMQ_REQ); 69 | if (!s) { 70 | printf ("error in zmq_socket: %s\n", zmq_strerror (errno)); 71 | return -1; 72 | } 73 | 74 | rc = zmq_connect (s, connect_to); 75 | if (rc != 0) { 76 | printf ("error in zmq_connect: %s\n", zmq_strerror (errno)); 77 | return -1; 78 | } 79 | 80 | rc = zmq_msg_init_size (&msg, message_size); 81 | if (rc != 0) { 82 | printf ("error in zmq_msg_init_size: %s\n", zmq_strerror (errno)); 83 | return -1; 84 | } 85 | memset (zmq_msg_data (&msg), 0, message_size); 86 | 87 | watch = zmq_stopwatch_start (); 88 | 89 | for (i = 0; i != roundtrip_count; i++) { 90 | rc = zmq_sendmsg (s, &msg, 0); 91 | if (rc < 0) { 92 | printf ("error in zmq_sendmsg: %s\n", zmq_strerror (errno)); 93 | return -1; 94 | } 95 | rc = zmq_recvmsg (s, &msg, 0); 96 | if (rc < 0) { 97 | printf ("error in zmq_recvmsg: %s\n", zmq_strerror (errno)); 98 | return -1; 99 | } 100 | if (zmq_msg_size (&msg) != message_size) { 101 | printf ("message of incorrect size received\n"); 102 | return -1; 103 | } 104 | } 105 | 106 | elapsed = zmq_stopwatch_stop (watch); 107 | 108 | rc = zmq_msg_close (&msg); 109 | if (rc != 0) { 110 | printf ("error in zmq_msg_close: %s\n", zmq_strerror (errno)); 111 | return -1; 112 | } 113 | 114 | latency = (double) elapsed / (roundtrip_count * 2); 115 | 116 | printf ("message size: %d [B]\n", (int) message_size); 117 | printf ("roundtrip count: %d\n", (int) roundtrip_count); 118 | printf ("average latency: %.3f [us]\n", (double) latency); 119 | 120 | rc = zmq_close (s); 121 | if (rc != 0) { 122 | printf ("error in zmq_close: %s\n", zmq_strerror (errno)); 123 | return -1; 124 | } 125 | 126 | rc = zmq_ctx_term (ctx); 127 | if (rc != 0) { 128 | printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno)); 129 | return -1; 130 | } 131 | 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/clientserver/server.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: LGPL-3.0-or-later */ 2 | 3 | /* 4 | Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file 5 | 6 | This file is part of libzmq, the ZeroMQ core engine in C++. 7 | 8 | libzmq is free software; you can redistribute it and/or modify it under 9 | the terms of the GNU Lesser General Public License (LGPL) as published 10 | by the Free Software Foundation; either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | As a special exception, the Contributors give you permission to link 14 | this library with independent modules to produce an executable, 15 | regardless of the license terms of these independent modules, and to 16 | copy and distribute the resulting executable under terms of your choice, 17 | provided that you also meet, for each linked independent module, the 18 | terms and conditions of the license of that module. An independent 19 | module is a module which is not derived from or based on this library. 20 | If you modify this library, you must extend this exception to your 21 | version of the library. 22 | 23 | libzmq is distributed in the hope that it will be useful, but WITHOUT 24 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 26 | License for more details. 27 | 28 | You should have received a copy of the GNU Lesser General Public License 29 | along with this program. If not, see . 30 | */ 31 | 32 | /* Sourced from libzmq */ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | int main (int argc, char *argv[]) 39 | { 40 | const char *bind_to; 41 | int roundtrip_count; 42 | size_t message_size; 43 | void *ctx; 44 | void *s; 45 | int rc; 46 | int i; 47 | zmq_msg_t msg; 48 | 49 | if (argc != 4) { 50 | printf ("usage: %s " 51 | "\n", argv[0]); 52 | return 1; 53 | } 54 | bind_to = argv[1]; 55 | message_size = atoi (argv[2]); 56 | roundtrip_count = atoi (argv[3]); 57 | 58 | ctx = zmq_init (1); 59 | if (!ctx) { 60 | printf ("error in zmq_init: %s\n", zmq_strerror (errno)); 61 | return -1; 62 | } 63 | 64 | s = zmq_socket (ctx, ZMQ_REP); 65 | if (!s) { 66 | printf ("error in zmq_socket: %s\n", zmq_strerror (errno)); 67 | return -1; 68 | } 69 | 70 | rc = zmq_bind (s, bind_to); 71 | if (rc != 0) { 72 | printf ("error in zmq_bind: %s\n", zmq_strerror (errno)); 73 | return -1; 74 | } 75 | 76 | rc = zmq_msg_init (&msg); 77 | if (rc != 0) { 78 | printf ("error in zmq_msg_init: %s\n", zmq_strerror (errno)); 79 | return -1; 80 | } 81 | 82 | for (i = 0; i != roundtrip_count; i++) { 83 | rc = zmq_recvmsg (s, &msg, 0); 84 | if (rc < 0) { 85 | printf ("error in zmq_recvmsg: %s\n", zmq_strerror (errno)); 86 | return -1; 87 | } 88 | if (zmq_msg_size (&msg) != message_size) { 89 | printf ("message of incorrect size received\n"); 90 | return -1; 91 | } 92 | rc = zmq_sendmsg (s, &msg, 0); 93 | if (rc < 0) { 94 | printf ("error in zmq_sendmsg: %s\n", zmq_strerror (errno)); 95 | return -1; 96 | } 97 | } 98 | 99 | rc = zmq_msg_close (&msg); 100 | if (rc != 0) { 101 | printf ("error in zmq_msg_close: %s\n", zmq_strerror (errno)); 102 | return -1; 103 | } 104 | 105 | zmq_sleep (1); 106 | 107 | rc = zmq_close (s); 108 | if (rc != 0) { 109 | printf ("error in zmq_close: %s\n", zmq_strerror (errno)); 110 | return -1; 111 | } 112 | 113 | rc = zmq_ctx_term (ctx); 114 | if (rc != 0) { 115 | printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno)); 116 | return -1; 117 | } 118 | 119 | return 0; 120 | } 121 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/pipeline/sink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 iMatix Corporation and Contributors 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | // Originally sourced from https://github.com/booksbyus/zguide 6 | 7 | // Task sink 8 | // Binds PULL socket to tcp://localhost:5558 9 | // Collects results from workers via that socket 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int main (int argc, char *argv[]) 17 | { 18 | 19 | const char *bind_to; 20 | int roundtrip_count; 21 | if (argc != 3) { 22 | printf ("usage: %s " 23 | "\n", argv[0]); 24 | return -1; 25 | } 26 | bind_to = argv[1]; 27 | roundtrip_count = atoi (argv[2]); 28 | 29 | // Prepare our context and socket 30 | void *context = zmq_ctx_new (); 31 | void *receiver = zmq_socket (context, ZMQ_PULL); 32 | zmq_bind (receiver, bind_to); 33 | 34 | // Wait for start of batch 35 | char buffer [256]; 36 | int size = zmq_recv (receiver, buffer, 255, 0); 37 | if (size == -1) { 38 | printf("Got eof"); 39 | return -1; 40 | } 41 | // Start our clock now 42 | struct timeval tv; 43 | gettimeofday (&tv, NULL); 44 | int64_t start_time = (int64_t) (tv.tv_sec * 1000 + tv.tv_usec / 1000); 45 | 46 | // Process 100 confirmations 47 | int task_nbr; 48 | for (task_nbr = 0; task_nbr < roundtrip_count; task_nbr++) { 49 | char buffer [256]; 50 | int size = zmq_recv (receiver, buffer, 255, 0); 51 | if (size == -1) { 52 | printf("Got eof"); 53 | return -1; 54 | } 55 | buffer[size] = '\0'; 56 | char *string = buffer; 57 | if ((task_nbr / 10) * 10 == task_nbr) 58 | printf (":"); 59 | else 60 | printf ("."); 61 | fflush (stdout); 62 | } 63 | // Calculate and report duration of batch 64 | gettimeofday (&tv, NULL); 65 | int64_t end_time = (int64_t) (tv.tv_sec * 1000 + tv.tv_usec / 1000); 66 | 67 | printf ("Total elapsed time: %d msec\n", 68 | (int) (end_time - start_time)); 69 | 70 | zmq_close (receiver); 71 | zmq_ctx_destroy (context); 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/pipeline/source.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 iMatix Corporation and Contributors 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | // Originally sourced from https://github.com/booksbyus/zguide 6 | // Task ventilator 7 | // Binds PUSH socket to tcp://localhost:5557 8 | // Sends batch of tasks to workers via that socket 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define randof(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0)) 16 | 17 | int main (int argc, char *argv[]) 18 | { 19 | const char *bind_to1; 20 | const char *bind_to2; 21 | 22 | int roundtrip_count; 23 | if (argc != 4) { 24 | printf ("usage: %s " 25 | "\n", argv[0]); 26 | return -1; 27 | } 28 | bind_to1 = argv[1]; 29 | bind_to2 = argv[2]; 30 | roundtrip_count = atoi (argv[3]); 31 | 32 | void *context = zmq_ctx_new (); 33 | 34 | // Socket to send messages on 35 | void *sender = zmq_socket (context, ZMQ_PUSH); 36 | zmq_bind (sender, bind_to1); 37 | 38 | // Socket to send start of batch message on 39 | void *sink = zmq_socket (context, ZMQ_PUSH); 40 | zmq_connect (sink, bind_to2); 41 | 42 | // printf ("Press Enter when the workers are ready: "); 43 | // getchar (); 44 | printf ("Sending tasks to workers…\n"); 45 | 46 | // The first message is "0" and signals start of batch 47 | zmq_send (sink, "0", 2, 0); 48 | 49 | // Initialize random number generator 50 | srandom ((unsigned) time (NULL)); 51 | 52 | // Send 100 tasks 53 | int task_nbr; 54 | int total_msec = 0; // Total expected cost in msecs 55 | for (task_nbr = 0; task_nbr < roundtrip_count; task_nbr++) { 56 | int workload; 57 | // Random workload from 1 to 100msecs 58 | workload = randof (100) + 1; 59 | total_msec += workload; 60 | char string [10]; 61 | sprintf (string, "%d", workload); 62 | zmq_send (sender, string, strlen(string), 0); 63 | } 64 | printf ("Total expected cost: %d msec\n", total_msec); 65 | 66 | zmq_close (sink); 67 | zmq_close (sender); 68 | zmq_ctx_destroy (context); 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/pipeline/worker.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 iMatix Corporation and Contributors 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | // Originally sourced from https://github.com/booksbyus/zguide 6 | 7 | // Task worker 8 | // Connects PULL socket to tcp://localhost:5557 9 | // Collects workloads from ventilator via that socket 10 | // Connects PUSH socket to tcp://localhost:5558 11 | // Sends results to sink via that socket 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | int main (int argc, char *argv[]) 19 | { 20 | const char *bind_to1; 21 | const char *bind_to2; 22 | 23 | int roundtrip_count; 24 | if (argc != 3) { 25 | printf ("usage: %s \n", argv[0]); 26 | return -1; 27 | } 28 | bind_to1 = argv[1]; 29 | bind_to2 = argv[2]; 30 | 31 | // Socket to receive messages on 32 | void *context = zmq_ctx_new (); 33 | void *receiver = zmq_socket (context, ZMQ_PULL); 34 | zmq_connect (receiver, bind_to1); 35 | 36 | // Socket to send messages to 37 | void *sender = zmq_socket (context, ZMQ_PUSH); 38 | zmq_connect (sender, bind_to2); 39 | 40 | // Process tasks forever 41 | while (1) { 42 | char buffer [256]; 43 | int size = zmq_recv (receiver, buffer, 255, 0); 44 | if (size == -1) { 45 | printf("Got eof"); 46 | return -1; 47 | } 48 | buffer[size] = '\0'; 49 | char *string = buffer; 50 | printf ("%s.", string); // Show progress 51 | fflush (stdout); 52 | struct timespec t; 53 | t.tv_sec = atoi (string) / 1000; 54 | t.tv_nsec = (atoi (string) % 1000) * 1000000; 55 | nanosleep (&t, NULL); 56 | 57 | zmq_send (sender, "", 1, 0); // Send results to sink 58 | } 59 | zmq_close (receiver); 60 | zmq_close (sender); 61 | zmq_ctx_destroy (context); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/pubsub/pub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 iMatix Corporation and Contributors 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | // Originally sourced from https://github.com/booksbyus/zguide 6 | // Weather update server 7 | // Binds PUB socket to tcp://*:5556 8 | // Publishes random weather updates 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #define randof(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0)) 16 | 17 | int main (int argc, char *argv[]) 18 | { 19 | const char *bind_to; 20 | int roundtrip_count; 21 | size_t message_size; 22 | void *ctx; 23 | void *s; 24 | int rc; 25 | int i; 26 | zmq_msg_t msg; 27 | 28 | if (argc != 4) { 29 | printf ("usage: %s " 30 | "\n", argv[0]); 31 | return -1; 32 | } 33 | bind_to = argv[1]; 34 | message_size = atoi (argv[2]); 35 | roundtrip_count = atoi (argv[3]); 36 | 37 | ctx = zmq_init (1); 38 | if (!ctx) { 39 | printf ("error in zmq_init: %s\n", zmq_strerror (errno)); 40 | return -1; 41 | } 42 | 43 | s = zmq_socket (ctx, ZMQ_PUB); 44 | if (!s) { 45 | printf ("error in zmq_socket: %s\n", zmq_strerror (errno)); 46 | return -1; 47 | } 48 | rc = zmq_bind (s, bind_to); 49 | if (rc != 0) { 50 | printf ("error in zmq_bind: %s\n", zmq_strerror (errno)); 51 | return -1; 52 | } 53 | 54 | 55 | srandom ((unsigned) time (NULL)); 56 | printf("%d\n", roundtrip_count); 57 | for (int i=0; i < roundtrip_count; i++) { 58 | // Get values that will fool the boss 59 | //printf("Sending\n"); 60 | int zipcode, temperature, relhumidity; 61 | zipcode = randof (100000); 62 | temperature = randof (215) - 80; 63 | relhumidity = randof (50) + 10; 64 | 65 | // Send message to all subscribers 66 | char update [20]; 67 | sprintf (update, "%05d %d %d %d", zipcode, temperature, relhumidity, i); 68 | int len = zmq_send (s, update, strnlen(update, 20), 0); 69 | //printf("%d\n", len); 70 | sleep(1); 71 | } 72 | 73 | 74 | rc = zmq_close (s); 75 | if (rc != 0) { 76 | printf ("error in zmq_close: %s\n", zmq_strerror (errno)); 77 | return -1; 78 | } 79 | 80 | rc = zmq_ctx_term (ctx); 81 | if (rc != 0) { 82 | printf ("error in zmq_ctx_term: %s\n", zmq_strerror (errno)); 83 | return -1; 84 | } 85 | 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/pubsub/sub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2013 iMatix Corporation and Contributors 3 | * SPDX-License-Identifier: MIT 4 | */ 5 | // Originally sourced from https://github.com/booksbyus/zguide 6 | // Weather update client 7 | // Connects SUB socket to tcp://localhost:5556 8 | // Collects weather updates and finds avg temp in zipcode 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | int main (int argc, char *argv []) 16 | { 17 | // Socket to talk to server 18 | printf ("Collecting updates from weather server…\n"); 19 | const char *bind_to; 20 | int roundtrip_count; 21 | 22 | if (argc != 3) { 23 | printf ("usage: %s " 24 | "\n", argv[0]); 25 | return -1; 26 | } 27 | bind_to = argv[1]; 28 | roundtrip_count = atoi (argv[2]); 29 | 30 | 31 | void *context = zmq_ctx_new (); 32 | void *subscriber = zmq_socket (context, ZMQ_SUB); 33 | int rc = zmq_connect (subscriber, bind_to); 34 | if (rc) { 35 | printf ("error in zmq_connect: %s\n", zmq_strerror (errno)); 36 | return -1; 37 | } 38 | 39 | rc = zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, 40 | NULL, 0); 41 | if (rc) { 42 | printf ("error in zmq_setsockopt: %s\n", zmq_strerror (errno)); 43 | return -1; 44 | } 45 | 46 | // Process 100 updates 47 | int update_nbr; 48 | long total_temp = 0; 49 | for (update_nbr = 0; update_nbr < roundtrip_count; update_nbr++) { 50 | char buffer [256]; 51 | int size = zmq_recv (subscriber, buffer, 255, 0); 52 | if (size == -1) { 53 | printf("Got eof"); 54 | return -1; 55 | } 56 | buffer[size] = '\0'; 57 | char *string = buffer; 58 | 59 | int zipcode, temperature, relhumidity; 60 | sscanf (string, "%d %d %d", 61 | &zipcode, &temperature, &relhumidity); 62 | total_temp += temperature; 63 | printf("temp: %s\n", string); 64 | } 65 | printf ("Average temperature for zipcode was %dF\n", 66 | (int) (total_temp / update_nbr)); 67 | 68 | zmq_close (subscriber); 69 | zmq_ctx_destroy (context); 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/zmq_bench_0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | set -e 9 | 10 | # Print an error message to capture error condition 11 | trap "if [ \$? -ne 0 ]; then echo 'Exited with error'; fi" 0; 12 | 13 | echo "Running 3 scenarios on one vm" 14 | echo "Running client server scenario" 15 | server tcp://lo:5555 1 10000 & 16 | client tcp://127.0.0.1:5555 1 10000 17 | wait 18 | 19 | echo "Running pub/sub scenario" 20 | sub tcp://127.0.0.1:5555 5 & 21 | pub tcp://lo:5555 1 6 22 | wait 23 | 24 | echo "Running pipeline scenario" 25 | sink tcp://127.0.0.1:5556 100 & 26 | worker tcp://127.0.0.1:5555 tcp://127.0.0.1:5556 & 27 | worker tcp://127.0.0.1:5555 tcp://127.0.0.1:5556 & 28 | # source is a built in command, so we need to use its actual path 29 | /bin/source tcp://127.0.0.1:5555 tcp://127.0.0.1:5556 100 30 | wait %1 31 | kill %2 32 | kill %3 33 | 34 | echo "Running 3 scenarios accross 3 vms" 35 | echo "Running client server scenario" 36 | client tcp://192.168.1.2:5555 1 10000 37 | 38 | # Sleep to allow subscriber to start 39 | sleep 1 40 | 41 | echo "Running pub/sub scenario" 42 | pub tcp://192.168.1.1:5555 1 6 43 | 44 | echo "Running pipeline scenario" 45 | 46 | # Sleep to allow workers to start 47 | sleep 1 48 | /bin/source tcp://192.168.1.1:5556 tcp://192.168.1.3:5556 100 49 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/zmq_bench_1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | set -e 9 | 10 | # Print an error message to capture error condition 11 | trap "if [ \$? -ne 0 ]; then echo 'Exited with error'; fi" 0; 12 | 13 | 14 | server tcp://eth0:5555 1 10000 15 | 16 | 17 | sub tcp://192.168.1.1:5555 5 18 | 19 | 20 | worker tcp://192.168.1.1:5556 tcp://192.168.1.3:5556 & 21 | work1=$! 22 | worker tcp://192.168.1.1:5556 tcp://192.168.1.3:5556 & 23 | work2=$! 24 | 25 | (sleep 15 && kill $work1 && kill $work2) & 26 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/src/user/zmq_bench_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) 4 | # 5 | # SPDX-License-Identifier: BSD-2-Clause 6 | # 7 | 8 | set -e 9 | 10 | # Print an error message to capture error condition 11 | trap "if [ \$? -ne 0 ]; then echo 'Exited with error'; fi" 0; 12 | 13 | sink tcp://192.168.1.3:5556 100 14 | 15 | echo "Finished running all scenarios" 16 | -------------------------------------------------------------------------------- /apps/x86/zmq_samples/zmq_samples.camkes: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | * 4 | * SPDX-License-Identifier: GPL-2.0-only 5 | */ 6 | 7 | import ; 8 | import ; 9 | 10 | #include 11 | #include 12 | 13 | #define VM_GUEST_CMDLINE "earlyprintk=ttyS0,115200 console=ttyS0,115200 root=/dev/mem i8042.nokbd=iy \ 14 | i8042.nomux=y i8042.noaux=y io_delay=udelay noisapnp pci=nomsi" 15 | 16 | 17 | 18 | #define VM0_topology_def(f) f(0,1,2) 19 | #define VM1_topology_def(f) f(1,0,2) 20 | #define VM2_topology_def(f) f(2,0,1) 21 | 22 | #define topology_def(f) \ 23 | VM0_topology_def(f) \ 24 | VM1_topology_def(f) \ 25 | VM2_topology_def(f) 26 | 27 | #define VM0_MACADDRESS "02:00:00:00:AA:01" 28 | #define VM1_MACADDRESS "02:00:00:00:AA:02" 29 | #define VM2_MACADDRESS "02:00:00:00:AA:03" 30 | 31 | 32 | component Init0 { 33 | VM_INIT_DEF() 34 | VM_CONNECTION_COMPONENT_DEF(0,topology_def) 35 | } 36 | 37 | component Init1 { 38 | VM_INIT_DEF() 39 | VM_CONNECTION_COMPONENT_DEF(1,topology_def) 40 | } 41 | 42 | component Init2 { 43 | VM_INIT_DEF() 44 | VM_CONNECTION_COMPONENT_DEF(2,topology_def) 45 | } 46 | 47 | assembly { 48 | composition { 49 | VM_COMPOSITION_DEF() 50 | VM_PER_VM_COMP_DEF(0) 51 | VM_PER_VM_COMP_DEF(1) 52 | VM_PER_VM_COMP_DEF(2) 53 | 54 | component VirtQueueInit init; 55 | VM_CONNECTION_CONNECT_VMS(init.init, topology_def) 56 | 57 | } 58 | 59 | configuration { 60 | 61 | VM_CONNECTION_CONFIG(init.init, topology_def) 62 | 63 | /* Initialise vmm devices */ 64 | vm0.init_cons = [ 65 | VM_CONNECTION_INIT_HANDLER(0,topology_def), 66 | ]; 67 | vm1.init_cons = [ 68 | VM_CONNECTION_INIT_HANDLER(1,topology_def), 69 | ]; 70 | vm2.init_cons = [ 71 | VM_CONNECTION_INIT_HANDLER(2,topology_def), 72 | ]; 73 | 74 | VM_CONFIGURATION_DEF() 75 | VM_PER_VM_CONFIG_DEF(0) 76 | vm0.simple_untyped23_pool = 21; 77 | vm0.simple_untyped22_pool = 1; 78 | vm0.heap_size = 0x10000; 79 | vm0.guest_ram_mb = 128; 80 | vm0.kernel_cmdline = VM_GUEST_CMDLINE; 81 | vm0.kernel_image = "bzimage"; 82 | vm0.kernel_relocs = "bzimage"; 83 | vm0.initrd_image = "vm0_rootfs.cpio"; 84 | vm0.iospace_domain = 0x0f; 85 | vm0.pci_devices_iospace = 1; 86 | 87 | VM_PER_VM_CONFIG_DEF(1) 88 | vm1.simple_untyped23_pool = 21; 89 | vm1.simple_untyped22_pool = 1; 90 | vm1.heap_size = 0x10000; 91 | vm1.guest_ram_mb = 128; 92 | vm1.kernel_cmdline = VM_GUEST_CMDLINE; 93 | vm1.kernel_image = "bzimage"; 94 | vm1.kernel_relocs = "bzimage"; 95 | vm1.initrd_image = "vm1_rootfs.cpio"; 96 | vm1.iospace_domain = 0x10; 97 | vm1.pci_devices_iospace = 2; 98 | 99 | VM_PER_VM_CONFIG_DEF(2) 100 | vm2.simple_untyped23_pool = 21; 101 | vm2.simple_untyped22_pool = 1; 102 | vm2.heap_size = 0x10000; 103 | vm2.guest_ram_mb = 128; 104 | vm2.kernel_cmdline = VM_GUEST_CMDLINE; 105 | vm2.kernel_image = "bzimage"; 106 | vm2.kernel_relocs = "bzimage"; 107 | vm2.initrd_image = "vm2_rootfs.cpio"; 108 | vm2.iospace_domain = 0x11; 109 | vm2.pci_devices_iospace = 3; 110 | 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /easy-settings.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | # set(PLATFORM "tx1" CACHE STRING "Platform to use") 8 | set(RELEASE OFF CACHE BOOL "Performance optimized build") 9 | # set(CAMKES_VM_APP "vm_minimal" CACHE STRING "CAmkES VM application to build") 10 | -------------------------------------------------------------------------------- /linux/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 | # 4 | # SPDX-License-Identifier: BSD-2-Clause 5 | # 6 | 7 | supported= false 8 | 9 | ifeq ($(LINUX_FILE), linux-tk1-debian) 10 | supported:=true 11 | SRC_FILE := $(BUILDROOT_DIR)/output/build/linux-custom/arch/arm/boot/Image 12 | DEST_FILE := linux-tk1-debian 13 | endif 14 | ifeq ($(LINUX_FILE), linux-tk1-initrd) 15 | supported:=true 16 | SRC_FILE := $(BUILDROOT_DIR)/output/build/linux-custom/arch/arm/boot/Image 17 | DEST_FILE := linux-tk1-initrd 18 | endif 19 | 20 | 21 | .PHONY: copy_buildroot 22 | copy_buildroot: 23 | @if [ ! -e "${BUILDROOT_DIR}" ] || [ "${supported}" == "false" ]; then \ 24 | echo "Specify a BUILDROOT_DIR to ${BUILDROOT_DIR} buildroot"; \ 25 | echo "Specify LINUX_FILE. Only supported files are: linux-tk1-debian, \ 26 | linux-tk1-initrd";\ 27 | exit 1; \ 28 | else \ 29 | echo "cp ${SRC_FILE} ${DEST_FILE}"; \ 30 | cp ${SRC_FILE} ${DEST_FILE}; \ 31 | fi 32 | -------------------------------------------------------------------------------- /linux/linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/linux/linux -------------------------------------------------------------------------------- /linux/linux-secure-dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/linux/linux-secure-dtb -------------------------------------------------------------------------------- /linux/linux-secure-vusb-dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/linux/linux-secure-vusb-dtb -------------------------------------------------------------------------------- /linux/linux-tk1-debian: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/linux/linux-tk1-debian -------------------------------------------------------------------------------- /linux/linux-tk1-initrd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/linux/linux-tk1-initrd -------------------------------------------------------------------------------- /linux/rootfs-tk1.cpio: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seL4/camkes-vm-examples/351d417392936d02457307610bcdf12190d54282/linux/rootfs-tk1.cpio --------------------------------------------------------------------------------