From 5e41b6709a90d29ae1e31eb60a82dd2e30d6d2b6 Mon Sep 17 00:00:00 2001 From: Nils Bosbach Date: Wed, 19 Jun 2024 16:29:23 +0200 Subject: [PATCH] Restructure * Remove config files (shift to avp64_sw) * Add cpu class to bundle cores (multicore debug support) * Add nightly CI flow * Add avp64 library & runner Signed-off-by: Nils Bosbach --- .clang-format | 2 +- .clang-tidy | 2 +- .github/workflows/cmake.yml | 16 +- .github/workflows/lint.yml | 14 +- .github/workflows/nightly.yml | 60 ++++ .github/workflows/style.yml | 2 +- .gitignore | 2 + .gitmodules | 9 +- CMakeLists.txt | 101 ++++--- README.md | 83 ++---- cmake | 1 + config/arm64_coremark.cfg | 82 ----- config/arm64_dhrystone.cfg | 82 ----- config/arm64_linux_4_19_4-x1.cfg | 13 - config/arm64_linux_4_19_4-x2.cfg | 13 - config/arm64_linux_4_19_4-x4.cfg | 13 - config/arm64_linux_4_19_4-x8.cfg | 13 - config/arm64_linux_4_19_4.cfg | 88 ------ config/arm64_stream.cfg | 82 ----- config/arm64_whetstone.cfg | 82 ----- config/arm64_xen.cfg | 96 ------ config/arm64x2_xen.cfg | 95 ------ deps/ocx-qemu-arm | 1 - deps/vcml | 1 - include/avp64.h | 21 ++ include/avp64/config.h | 92 ------ include/avp64/{arm64_cpu.h => core.h} | 60 ++-- include/avp64/cpu.h | 87 ++++++ patches/unicorn-fix-breakpoint.patch | 26 -- setup.sh | 164 ---------- src/{arm64_cpu.cpp => avp64/core.cpp} | 280 +++++++++++------- src/avp64/cpu.cpp | 142 +++++++++ src/{ => avp64}/main.cpp | 4 +- src/avp64/system.cpp | 177 +++++++++++ {include => src}/avp64/system.h | 80 +++-- src/avp64/version.h.in | 25 ++ src/system.cpp | 272 ----------------- sw/.gitignore | 2 + tests/CMakeLists.txt | 57 ++-- ...arm64_cpu_test.cpp => arm64_core_test.cpp} | 12 +- tests/linux_boot.py.in | 17 +- utils/format | 38 +++ {vscode => vscode-tutorial}/README.md | 18 +- .../assets/control_panel.png | Bin .../avp64.code-profile | 0 {vscode => vscode-tutorial}/launch.json | 14 +- {vscode => vscode-tutorial}/settings.json | 0 {vscode => vscode-tutorial}/setup.bash | 25 +- 48 files changed, 1003 insertions(+), 1563 deletions(-) create mode 100644 .github/workflows/nightly.yml create mode 160000 cmake delete mode 100644 config/arm64_coremark.cfg delete mode 100644 config/arm64_dhrystone.cfg delete mode 100644 config/arm64_linux_4_19_4-x1.cfg delete mode 100644 config/arm64_linux_4_19_4-x2.cfg delete mode 100644 config/arm64_linux_4_19_4-x4.cfg delete mode 100644 config/arm64_linux_4_19_4-x8.cfg delete mode 100644 config/arm64_linux_4_19_4.cfg delete mode 100644 config/arm64_stream.cfg delete mode 100644 config/arm64_whetstone.cfg delete mode 100644 config/arm64_xen.cfg delete mode 100644 config/arm64x2_xen.cfg delete mode 160000 deps/ocx-qemu-arm delete mode 160000 deps/vcml create mode 100644 include/avp64.h delete mode 100644 include/avp64/config.h rename include/avp64/{arm64_cpu.h => core.h} (76%) create mode 100644 include/avp64/cpu.h delete mode 100644 patches/unicorn-fix-breakpoint.patch delete mode 100755 setup.sh rename src/{arm64_cpu.cpp => avp64/core.cpp} (58%) create mode 100644 src/avp64/cpu.cpp rename src/{ => avp64}/main.cpp (91%) create mode 100644 src/avp64/system.cpp rename {include => src}/avp64/system.h (63%) create mode 100644 src/avp64/version.h.in delete mode 100644 src/system.cpp create mode 100644 sw/.gitignore rename tests/{arm64_cpu_test.cpp => arm64_core_test.cpp} (88%) create mode 100755 utils/format rename {vscode => vscode-tutorial}/README.md (81%) rename {vscode => vscode-tutorial}/assets/control_panel.png (100%) rename {vscode => vscode-tutorial}/avp64.code-profile (100%) rename {vscode => vscode-tutorial}/launch.json (60%) rename {vscode => vscode-tutorial}/settings.json (100%) rename {vscode => vscode-tutorial}/setup.bash (72%) diff --git a/.clang-format b/.clang-format index 5a6eada..badfb61 120000 --- a/.clang-format +++ b/.clang-format @@ -1 +1 @@ -deps/vcml/cmake/clang-format \ No newline at end of file +cmake/clang-format \ No newline at end of file diff --git a/.clang-tidy b/.clang-tidy index 2efc7ef..caac78b 120000 --- a/.clang-tidy +++ b/.clang-tidy @@ -1 +1 @@ -deps/vcml/cmake/clang-tidy \ No newline at end of file +cmake/clang-tidy \ No newline at end of file diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 7243dbb..27138d1 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -26,21 +26,17 @@ jobs: submodules: 'recursive' - name: Download software + working-directory: ./sw run: | - wget https://github.com/aut0/avp64_sw/releases/latest/download/linux.tar.gz - tar -xvf linux.tar.gz - rm linux.tar.gz + wget https://github.com/aut0/avp64_sw/releases/download/v2024.07.30/buildroot_6_5_6.tar.gz + tar -xvf buildroot_6_5_6.tar.gz + rm buildroot_6_5_6.tar.gz - name: Setup Dependencies run: | sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" sudo apt-get update -y -qq - sudo apt-get install libelf-dev libsdl2-dev libvncserver-dev libslirp-dev - - - name: Patch unicorn - run: | - git apply ${{github.workspace}}/patches/unicorn-*.patch - working-directory: ${{github.workspace}}/deps/ocx-qemu-arm/unicorn + sudo apt-get install build-essential libelf-dev libsdl2-dev libvncserver-dev libslirp-dev - name: Configure run: | @@ -48,7 +44,7 @@ jobs: -B ${{github.workspace}}/build \ -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} \ -DAVP64_BUILD_TESTS=ON \ - -DOCX_QEMU_ARM_BUILD_TESTS=OFF + -DAVP64_BUILD_RUNNER=ON - name: Build run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}} -j $(nproc) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index edd7c0a..bf9ed99 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,22 +28,16 @@ jobs: run: | sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" sudo apt-get update -y -qq - sudo apt-get install libelf-dev libsdl2-dev libvncserver-dev libslirp-dev clang-tidy - - - name: Patch unicorn - run: | - git apply ${{github.workspace}}/patches/unicorn-*.patch - working-directory: ${{github.workspace}}/deps/ocx-qemu-arm/unicorn + sudo apt-get install build-essential libelf-dev libsdl2-dev libvncserver-dev libslirp-dev clang-tidy - name: Configure run: | cmake \ -B ${{github.workspace}}/build \ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DAVP64_BUILD_TESTS=ON \ - -DOCX_QEMU_ARM_BUILD_TESTS=OFF \ - -DAVP64_LINTER="clang-tidy" \ - -DCMAKE_CXX_STANDARD=17 + -DAVP64_BUILD_TESTS=OFF \ + -DAVP64_BUILD_RUNNER=ON \ + -DAVP64_LINTER="clang-tidy" - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j $(nproc) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..fd72086 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,60 @@ +name: cmake + +on: + schedule: + - cron: '0 1 * * *' + +env: + TARGET_ARCH: linux64 + BUILD_TYPE: Release + +jobs: + build: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + + name: Build AVP64 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Download software + working-directory: ./sw + run: | + wget https://github.com/aut0/avp64_sw/releases/download/v2024.07.30/buildroot_6_5_6.tar.gz + tar -xvf buildroot_6_5_6.tar.gz + rm buildroot_6_5_6.tar.gz + + - name: Setup Dependencies + run: | + sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" + sudo apt-get update -y -qq + sudo apt-get install build-essential libelf-dev libsdl2-dev libvncserver-dev libslirp-dev + + - name: Configure + run: | + cmake \ + -B ${{github.workspace}}/build \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DAVP64_BUILD_TESTS=ON \ + -DAVP64_BUILD_RUNNER=ON + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j $(nproc) + + - name: Test + env: + LD_LIBRARY_PATH: ${{github.workspace}}/build/ocx-qemu-arm + working-directory: ${{github.workspace}}/build + run: | + ctest -C ${{env.BUILD_TYPE}} --output-on-failure --output-junit testreport.xml + + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: always() + with: + report_paths: ${{github.workspace}}/build/testreport.xml diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 92252d0..fd1f34d 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -16,4 +16,4 @@ jobs: submodules: 'recursive' - name: Check code style - run: deps/vcml/utils/format -n + run: ./utils/format -n diff --git a/.gitignore b/.gitignore index ed006f9..fb2e992 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ gdbscript* .vscode .cache compile_commands.json +linux-src/ + diff --git a/.gitmodules b/.gitmodules index b81660a..76f28dc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "deps/ocx-qemu-arm"] - path = deps/ocx-qemu-arm - url = https://github.com/snps-virtualprototyping/ocx-qemu-arm -[submodule "deps/vcml"] - path = deps/vcml - url = https://github.com/machineware-gmbh/vcml +[submodule "cmake"] + path = cmake + url = https://github.com/machineware-gmbh/cmake.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 646e0e6..351e55d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,66 +1,91 @@ ############################################################################## # # -# Copyright 2020 Lukas Jünger # +# Copyright 2024 Lukas Jünger, Nils Bosbach # # # # This software is licensed under the MIT license. # # A copy of the license can be found in the LICENSE file at the root # # of the source tree. # # # -############################################################################# - -cmake_minimum_required(VERSION 3.6) -project(avp64) -option(AVP64_BUILD_TESTS "Build unit tests" OFF) +############################################################################## -include(ExternalProject) +cmake_minimum_required(VERSION 3.12) +project(avp64 VERSION 2024.07.30 LANGUAGES C CXX) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +option(AVP64_BUILD_TESTS "Build unit tests" OFF) +option(AVP64_BUILD_RUNNER "Build avp64 runner" ON) set(AVP64_LINTER "" CACHE STRING "Code linter to use") -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) - -set(CMAKE_EXE_LINKER_FLAGS -rdynamic) - -set(OCX_QEMU_ARM_HOME $ENV{OCX_QEMU_HOME}) -if(NOT EXISTS ${OCX_QEMU_ARM_HOME}) - set(OCX_QEMU_ARM_HOME ${CMAKE_CURRENT_SOURCE_DIR}/deps/ocx-qemu-arm) -endif() - -set(VCML_HOME $ENV{VCML_HOME}) -if(NOT EXISTS ${VCML_HOME}) - set(VCML_HOME ${CMAKE_CURRENT_SOURCE_DIR}/deps/vcml) -endif() - -message(STATUS "Found OCX-QEMU-ARM at " ${OCX_QEMU_ARM_HOME}) -message(STATUS "Found VCML at " ${VCML_HOME}) +include(cmake/common.cmake) +find_github_repo(vcml "machineware-gmbh/vcml") -add_subdirectory(${OCX_QEMU_ARM_HOME} ocx-qemu-arm) -add_subdirectory(${VCML_HOME} vcml) +set(OCX_QEMU_ARM_BUILD_TESTS OFF CACHE BOOL "disable ocx tests") +find_github_repo(ocx-qemu-arm "nbosb/ocx-qemu-arm" "fix-namespace") set(src "${CMAKE_CURRENT_SOURCE_DIR}/src") -set(inc "${CMAKE_CURRENT_SOURCE_DIR}/include" - "${CMAKE_CURRENT_SOURCE_DIR}/deps/ocx-qemu-arm/ocx/include") +set(inc "${CMAKE_CURRENT_SOURCE_DIR}/include") +set(gen ${CMAKE_CURRENT_BINARY_DIR}/gen) + +configure_file(${src}/avp64/version.h.in + ${gen}/avp64/version.h @ONLY) set(sources - ${src}/arm64_cpu.cpp - ${src}/system.cpp - ${src}/main.cpp) + ${src}/avp64/core.cpp + ${src}/avp64/cpu.cpp +) -add_executable(avp64 ${sources}) +add_library(avp64 STATIC ${sources}) -set_target_properties(avp64 PROPERTIES CXX_CLANG_TIDY "${AVP64_LINTER}") target_compile_options(avp64 PRIVATE ${MWR_COMPILER_WARN_FLAGS}) +target_include_directories(avp64 PUBLIC ${inc}) +target_include_directories(avp64 PUBLIC ${gen}) +target_include_directories(avp64 PUBLIC ${OCX_QEMU_ARM_HOME}/ocx/include) +target_link_libraries(avp64 PUBLIC ${CMAKE_DL_LIBS}) +target_link_libraries(avp64 PUBLIC vcml) +set_target_properties(avp64 PROPERTIES CXX_STANDARD 17) +set_target_properties(avp64 PROPERTIES CXX_CLANG_TIDY "${AVP64_LINTER}") +set_target_properties(avp64 PROPERTIES VERSION "${AVP64_VERSION}") +set_target_properties(avp64 PROPERTIES SOVERSION "${AVP64_VERSION_MAJOR}") -target_include_directories(avp64 PRIVATE ${inc}) +if(NOT ${AVP64_LINTER} STREQUAL "") + # -std=c++17 is not passed to the compiler if it is the comiler's default + # this caused problems with clang-tidy + set_target_properties(avp64 PROPERTIES CXX_STANDARD_REQUIRED ON) +endif() -target_link_libraries(avp64 ${CMAKE_DL_LIBS}) -target_link_whole_archives(avp64 vcml) +set_target_properties(ocx-qemu-arm PROPERTIES EXCLUDE_FROM_ALL FALSE) -install(TARGETS avp64 DESTINATION bin) -install(DIRECTORY config/ DESTINATION config) +install(TARGETS avp64) +install(TARGETS ocx-qemu-arm DESTINATION lib) +install(DIRECTORY sw/ DESTINATION sw) +install(DIRECTORY ${inc}/ DESTINATION include) +install(DIRECTORY ${gen}/ DESTINATION include) if(AVP64_BUILD_TESTS) message(STATUS "Building AVP64 tests") enable_testing() add_subdirectory(tests) endif() + +if(AVP64_BUILD_RUNNER) + add_executable(avp64-runner + ${src}/avp64/system.cpp + ${src}/avp64/main.cpp + ) + + target_compile_options(avp64-runner PRIVATE ${MWR_COMPILER_WARN_FLAGS}) + target_include_directories(avp64-runner PRIVATE ${src}) + set_target_properties(avp64-runner PROPERTIES CXX_STANDARD 17) + set_target_properties(avp64-runner PROPERTIES CXX_CLANG_TIDY "${AVP64_LINTER}") + set_target_properties(avp64-runner PROPERTIES VERSION "${AVP64_VERSION}") + set_target_properties(avp64-runner PROPERTIES SOVERSION "${AVP64_VERSION_MAJOR}") + target_link_whole_archives(avp64-runner avp64) + target_link_whole_archives(avp64-runner vcml) + + if(NOT ${AVP64_LINTER} STREQUAL "") + # -std=c++17 is not passed to the compiler if it is the comiler's default + # this caused problems with clang-tidy + set_target_properties(avp64-runner PROPERTIES CXX_STANDARD_REQUIRED ON) + endif() + + install(TARGETS avp64-runner) +endif() diff --git a/README.md b/README.md index 07c30c3..f69de40 100644 --- a/README.md +++ b/README.md @@ -1,114 +1,84 @@ # An ARMv8 Virtual Platform (AVP64) [![Build Status](https://github.com/aut0/avp64/workflows/cmake/badge.svg?event=push)](https://github.com/aut0/avp64/actions/workflows/cmake.yml) +[![Nightly](https://github.com/aut0/avp64/workflows/nightly/badge.svg?event=push)](https://github.com/aut0/avp64/actions/workflows/nightly.yml) [![Lint Status](https://github.com/aut0/avp64/workflows/lint/badge.svg?event=push)](https://github.com/aut0/avp64/actions/workflows/lint.yml) [![Code Style](https://github.com/aut0/avp64/workflows/style/badge.svg?event=push)](https://github.com/aut0/avp64/actions/workflows/style.yml) This repository contains an ARMv8 multicore virtual platform. -It was built at the Institute for Communication Technologies and Embedded Systems at RTWH Aachen University. -The following target software configurations were tested (see [config](config/)): +It was built at the [Institute for Communication Technologies and Embedded Systems at RTWH Aachen University](https://www.ice.rwth-aachen.de/). +The following target software configurations were tested (see [avp64-sw](https://github.com/aut0/avp64_sw)): - CoreMark - Dhrystone - Whetstone - STREAM -- Linux single- and dual-core +- Linux single-, dual-, quad-, octa-core - Xen single- and dual-core ---- ## Build & Installation -In order to build `avp64`, you need a working installation of `vcml` and its components. -For that please follow the installation guideline of `vcml` which can be found [here](https://github.com/machineware-gmbh/vcml). - 1. Clone git repository including submodules: ```bash - git clone --recurse-submodules https://github.com/aut0/avp64 + git clone --recursive https://github.com/aut0/avp64 ``` -2. Chose directories for building and deployment: +1. Chose directories for building and deployment: - ```bash + ```text location of your repo copy, e.g. /home/lukas/avp64 location to store object files, e.g. /home/lukas/avp64/BUILD output directory for binaries, e.g. /opt/avp64 ``` -3. Patch submodules: A patch can be applied to patch the `unicorn` submodule. - - - [unicorn-fix-breakpoint.patch](./patches/unicorn-fix-breakpoint.patch): This patch fixes the breakpoint behavior of the VP. - Without this patch, the VP executes the instruction on a breakpoint hit and stops after the execution. - The patch stops the VP before the instruction is executed. - To apply the patch, execute: - - ```bash - (cd /deps/ocx-qemu-arm/unicorn && git apply /patches/unicorn-fix-breakpoint.patch) - ``` - -4. Configure and build the project using `cmake`. During configuration you must - state whether or not to build the unit tests: +1. Configure and build the project using `cmake`. During configuration you must + state whether or not to build the runner (vp executable) and the unit tests: + - `-DAVP64_BUILD_RUNNET=[ON|OFF]`: build runner (default: `ON`) - `-DAVP64_BUILD_TESTS=[ON|OFF]`: build unit tests (default: `OFF`) - Ensure that the environment variable `SYSTEMC_HOME` is correctly set. - Release and debug build configurations are controlled via the regular - parameters: + Release and debug build configurations are controlled via the regular cmake parameters: ```bash mkdir -p cd cmake -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=RELEASE - make -j 4 + make -j `nproc` sudo make install ``` - If building with `-DAVP64_BUILD_TESTS=ON` you can run all unit tests using - `make test` within ``. + If building with `-DAVP64_BUILD_TESTS=ON` you can run all unit tests using `make test` within ``. -5. After installation, the following new files should be present: +1. After installation, the following new files should be present: ```bash - /bin/avp64 # executable program - /config/ # configuration files - /lib/libocx-qemu-arm.so + /bin/avp64-runner # executable program + /lib/libocx-qemu-arm.so ``` -6. If the library `libocx-qemu-arm.so` cannot be found, add the lib folder to `LD_LIBRARY_PATH`: +1. If the library `libocx-qemu-arm.so` cannot be found, add the lib folder to `LD_LIBRARY_PATH`: ```bash - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/avp64/lib/ + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib/ ``` ---- ## Run -Run the platform using a [config](config/) file: +Run the platform using a config file from the [sw](sw/) folder: ```bash -/bin/avp64 -f /config/ +/bin/avp64-runner -f /sw/ ``` For more details on run parameters please look [here](https://github.com/machineware-gmbh/vcml). - To stop the platform, press Ctrl + a + x . -To install tested software that belongs to the provided [configuration files](config/), follow the installation guide of [avp64_sw](https://github.com/aut0/avp64_sw). -After the installation, set the environment variable `AVP64_SW` to the path of the `avp64_sw` repository: - -```bash -export AVP64_SW= -``` - -Execute the setup script, which is in `avp64/`, to copy and integrate the installed software: - -```bash -./setup.sh -``` - ---- ## Maintaining Multiple Builds @@ -118,7 +88,6 @@ that like to make changes on `avp64` and want to track down bugs. Note that these builds operate significantly slower than optimized release builds and should therefore not be used for VPs that are used productively, e.g. for target software development. -Ensure that the environment variable `SYSTEMC_HOME` is correctly set. To maintain both builds from a single source repository, try the following: ```bash @@ -143,16 +112,18 @@ Afterward, you can find the builds in: ---- -## Documentation +## Tutorial -The VCML documentation can be found -[here](https://github.com/machineware-gmbh/vcml). +A baisc tutorial that shows how to debug the executed target software using [Visual Studio Code](https://code.visualstudio.com/) can be found in the [vscode-tutorial](./vscode-tutorial/) folder. +Run the [vscode-tutorial/setup.bash](./vscode-tutorial/setup.bash) script to download the Linux image and Linux Kernel Source files and setup Visual Studio Code. +See the corresponding [Readme](./vscode-tutorial/README.md) for further details. ---- -## Target-Software-Debugging Tutorial +## Documentation -You can find a tutorial that shows how to debug the executed target software using Visual Studio Code [here](vscode/). +The VCML documentation can be found +[here](https://github.com/machineware-gmbh/vcml). ---- diff --git a/cmake b/cmake new file mode 160000 index 0000000..d502e7b --- /dev/null +++ b/cmake @@ -0,0 +1 @@ +Subproject commit d502e7bfa4ec1b0042d707277a4f781139a21f5d diff --git a/config/arm64_coremark.cfg b/config/arm64_coremark.cfg deleted file mode 100644 index cf5657c..0000000 --- a/config/arm64_coremark.cfg +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################## -# # -# Copyright 2022 Nils Bosbach, Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -### Simulation TCP port summary ############################################## - -# system.term0 -> 51010 (raw binary) -# system.term1 -> 51011 (raw binary) -# system.term2 -> 51012 (raw binary) -# system.term3 -> 51013 (raw binary) -# system.arm0 -> 51111 (GDB RSP) - -### General configuration #################################################### -system.name = avp64 -system.desc = Runs the coremark benchmark on a single-core aarch64 CPU -system.config = ${cfg} - -# Specify the number of processors to instantiate in the simulation. Maximum -# allowed is 32. Override this on command line using -c system.nrcpus=X. -system.nrcpu = 1 - -# Specify simulation duration. Simulation will stop automatically once this -# time-stamp is reached. Use integer values with suffixes s, ms, us or ns. If -# you want to simulate infinitely, leave this commented out. -# system.duration = 2s - -# TLM global quantum, a higher value improves performance but reduces timing -# accuracy. Use integer values with suffixes s, ms, us or ns. -system.quantum = 10us - -# Clock frequency -system.clock.hz = 1000000000 # 1 GHz - -### CPU configuration ######################################################## - -system.arm0.gdb_port = 52100 -system.arm0.gdb_wait = 0 # (0) start core immediately; (1) wait for gdb - -### Physical Address Map ##################################################### - -system.addr_ram = 0x00000000..0x0fffffff -system.addr_hwrng = 0x10007000..0x10007fff -system.addr_simdev = 0x10008000..0x10008fff -system.addr_uart0 = 0x10009000..0x10009fff -system.addr_uart1 = 0x1000a000..0x1000afff -system.addr_uart2 = 0x1000b000..0x1000bfff -system.addr_uart3 = 0x1000c000..0x1000cfff -system.addr_ethoc = 0x1000d000..0x1000efff -system.addr_sdhci = 0x1000f000..0x1000ffff -system.addr_gic_distif = 0x10140000..0x10140fff -system.addr_gic_cpuif = 0x10141000..0x10142fff -system.addr_gic_vifctrl= 0x10143000..0x10144fff -system.addr_gic_vcpuif = 0x10145000..0x10146fff - -### Interrupt Map ############################################################ - -system.irq_uart0 = 12 -system.irq_uart1 = 13 -system.irq_uart2 = 14 -system.irq_uart3 = 15 - -### Memory and IO peripherals configuration ################################## - -# Memory configuration -system.ram.size = 0x10000000 # 256MB -system.ram.images = ${dir}/../sw/arm64/benchmark/coremark/coremark.bin@0x00000000 - -# UART configuration -system.term0.backends = term tcp:51010 # stdout|file|tap|null -system.term1.backends = stdout tcp:51011 # term|file|tap|null -system.term2.backends = stdout tcp:51012 # term|file|tap|null -system.term3.backends = stdout tcp:51013 # term|file|tap|null - -# ETHOC configuration -system.ethoc.mac = 3a:44:1d:55:11:5a -system.bridge.backends = slirp:0 diff --git a/config/arm64_dhrystone.cfg b/config/arm64_dhrystone.cfg deleted file mode 100644 index 511a86a..0000000 --- a/config/arm64_dhrystone.cfg +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################## -# # -# Copyright 2022 Nils Bosbach, Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -### Simulation TCP port summary ############################################## - -# system.term0 -> 51010 (raw binary) -# system.term1 -> 51011 (raw binary) -# system.term2 -> 51012 (raw binary) -# system.term3 -> 51013 (raw binary) -# system.arm0 -> 51111 (GDB RSP) - -### General configuration #################################################### -system.name = avp64 -system.desc = Runs the dhrystone benchmark on a single-core aarch64 CPU -system.config = ${cfg} - -# Specify the number of processors to instantiate in the simulation. Maximum -# allowed is 32. Override this on command line using -c system.nrcpus=X. -system.nrcpu = 1 - -# Specify simulation duration. Simulation will stop automatically once this -# time-stamp is reached. Use integer values with suffixes s, ms, us or ns. If -# you want to simulate infinitely, leave this commented out. -# system.duration = 2s - -# TLM global quantum, a higher value improves performance but reduces timing -# accuracy. Use integer values with suffixes s, ms, us or ns. -system.quantum = 10us - -# Clock frequency -system.clock.hz = 1000000000 # 1 GHz - -### CPU configuration ######################################################## - -system.arm0.gdb_port = 52100 -system.arm0.gdb_wait = 0 # (0) start core immediately; (1) wait for gdb - -### Physical Address Map ##################################################### - -system.addr_ram = 0x00000000..0x0fffffff -system.addr_hwrng = 0x10007000..0x10007fff -system.addr_simdev = 0x10008000..0x10008fff -system.addr_uart0 = 0x10009000..0x10009fff -system.addr_uart1 = 0x1000a000..0x1000afff -system.addr_uart2 = 0x1000b000..0x1000bfff -system.addr_uart3 = 0x1000c000..0x1000cfff -system.addr_ethoc = 0x1000d000..0x1000efff -system.addr_sdhci = 0x1000f000..0x1000ffff -system.addr_gic_distif = 0x10140000..0x10140fff -system.addr_gic_cpuif = 0x10141000..0x10142fff -system.addr_gic_vifctrl= 0x10143000..0x10144fff -system.addr_gic_vcpuif = 0x10145000..0x10146fff - -### Interrupt Map ############################################################ - -system.irq_uart0 = 12 -system.irq_uart1 = 13 -system.irq_uart2 = 14 -system.irq_uart3 = 15 - -### Memory and IO peripherals configuration ################################## - -# Memory configuration -system.ram.size = 0x10000000 # 256MB -system.ram.images = ${dir}/../sw/arm64/benchmark/dhrystone/dhrystone.bin@0x00000000 - -# UART configuration -system.term0.backends = term tcp:51010 # stdout|file|tap|null -system.term1.backends = stdout tcp:51011 # term|file|tap|null -system.term2.backends = stdout tcp:51012 # term|file|tap|null -system.term3.backends = stdout tcp:51013 # term|file|tap|null - -# ETHOC configuration -system.ethoc.mac = 3a:44:1d:55:11:5a -system.bridge.backends = slirp:0 diff --git a/config/arm64_linux_4_19_4-x1.cfg b/config/arm64_linux_4_19_4-x1.cfg deleted file mode 100644 index 774b4a9..0000000 --- a/config/arm64_linux_4_19_4-x1.cfg +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################## -# # -# Copyright 2023 Nils Bosbach, Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -system.desc = Boots Linux on a single-core aarch64 CPU -system.nrcpu = 1 -%include ${dir}/arm64_linux_4_19_4.cfg diff --git a/config/arm64_linux_4_19_4-x2.cfg b/config/arm64_linux_4_19_4-x2.cfg deleted file mode 100644 index 2e2b65f..0000000 --- a/config/arm64_linux_4_19_4-x2.cfg +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################## -# # -# Copyright 2023 Nils Bosbach, Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -system.desc = Boots Linux on a dual-core aarch64 CPU -system.nrcpu = 2 -%include ${dir}/arm64_linux_4_19_4.cfg diff --git a/config/arm64_linux_4_19_4-x4.cfg b/config/arm64_linux_4_19_4-x4.cfg deleted file mode 100644 index 74f4dfc..0000000 --- a/config/arm64_linux_4_19_4-x4.cfg +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################## -# # -# Copyright 2023 Nils Bosbach, Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -system.desc = Boots Linux on a quad-core aarch64 CPU -system.nrcpu = 4 -%include ${dir}/arm64_linux_4_19_4.cfg diff --git a/config/arm64_linux_4_19_4-x8.cfg b/config/arm64_linux_4_19_4-x8.cfg deleted file mode 100644 index f46f85e..0000000 --- a/config/arm64_linux_4_19_4-x8.cfg +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################## -# # -# Copyright 2023 Nils Bosbach, Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -system.desc = Boots Linux on a octa-core aarch64 CPU -system.nrcpu = 8 -%include ${dir}/arm64_linux_4_19_4.cfg diff --git a/config/arm64_linux_4_19_4.cfg b/config/arm64_linux_4_19_4.cfg deleted file mode 100644 index 3eefad7..0000000 --- a/config/arm64_linux_4_19_4.cfg +++ /dev/null @@ -1,88 +0,0 @@ -############################################################################## -# # -# Copyright 2023 Lukas Jünger, Nils Bosbach # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -### General configuration #################################################### -system.name = avp64 -system.config = ${cfg} - -# Specify simulation duration. Simulation will stop automatically once this -# time-stamp is reached. Use integer values with suffixes s, ms, us or ns. If -# you want to simulate infinitely, leave this commented out. -# system.duration = 2s - -# TLM global quantum, a higher value improves performance but reduces timing -# accuracy. Use integer values with suffixes s, ms, us or ns. -system.quantum = 100us - -# Clock frequency -system.clock.hz = 1000000000 # 1 GHz - -### CPU configuration ######################################################## -system.arm.gdb_wait = false - -for i : ${system.nrcpu} do - system.arm${i}.gdb_port = 5210${i} - system.arm${i}.gdb_wait = ${system.arm.gdb_wait} - system.arm${i}.symbols = ${dir}/../sw/arm64/linux/vmlinux-4.19.4 -done - -### Physical Address Map ##################################################### - -system.addr_ram = 0x00000000..0x0fffffff -system.addr_hwrng = 0x10007000..0x10007fff -system.addr_simdev = 0x10008000..0x10008fff -system.addr_uart0 = 0x10009000..0x10009fff -system.addr_uart1 = 0x1000a000..0x1000afff -system.addr_uart2 = 0x1000b000..0x1000bfff -system.addr_uart3 = 0x1000c000..0x1000cfff -system.addr_ethoc = 0x1000d000..0x1000efff -system.addr_sdhci = 0x1000f000..0x1000ffff -system.addr_gic_distif = 0x10140000..0x10140fff -system.addr_gic_cpuif = 0x10141000..0x10142fff -system.addr_gic_vifctrl= 0x10143000..0x10144fff -system.addr_gic_vcpuif = 0x10145000..0x10146fff -system.addr_spi = 0x10147000..0x10148fff -system.addr_gpio = 0x10149000..0x10149fff - -### Interrupt Map ############################################################ - -system.irq_uart0 = 5 -system.irq_uart1 = 6 -system.irq_uart2 = 7 -system.irq_uart3 = 8 -system.irq_ethoc = 9 -system.irq_sdhci = 10 -system.irq_gt_hyp = 26 -system.irq_gt_virt= 27 -system.irq_gt_ns = 30 -system.irq_gt_s = 29 -system.irq_spi = 11 - -### Memory and IO peripherals configuration ################################## - -# Memory configuration -system.ram.size = 0x10000000 # 256MB -system.ram.images = ${dir}/../sw/arm64/linux/boot.bin@0x00000000 \ - ${dir}/../sw/arm64/linux/Image-4.19.4@0x00080000 \ - ${dir}/../sw/arm64/linux/avp64x${system.nrcpu}.dtb@0x07f00000 - -# SD Card configuration -system.sdcard.readonly = true -system.sdcard.image = ${dir}/../sw/arm64/linux/sdcard.img - -# Terminal configuration -system.term0.backends = term tcp:52010 # stdout|file|tap|null -system.term1.backends = tcp:52011 # term|file|tap|null -system.term2.backends = tcp:52012 # term|file|tap|null -system.term3.backends = tcp:52013 # term|file|tap|null - -# ETHOC configuration -system.ethoc.mac = 3a:44:1d:55:11:5a -system.bridge.backends = slirp:0 diff --git a/config/arm64_stream.cfg b/config/arm64_stream.cfg deleted file mode 100644 index 665eb8c..0000000 --- a/config/arm64_stream.cfg +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################## -# # -# Copyright 2022 Nils Bosbach, Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -### Simulation TCP port summary ############################################## - -# system.term0 -> 51010 (raw binary) -# system.term1 -> 51011 (raw binary) -# system.term2 -> 51012 (raw binary) -# system.term3 -> 51013 (raw binary) -# system.arm0 -> 51111 (GDB RSP) - -### General configuration #################################################### -system.name = avp64 -system.desc = Runs the stream benchmark on a single-core aarch64 CPU -system.config = ${cfg} - -# Specify the number of processors to instantiate in the simulation. Maximum -# allowed is 32. Override this on command line using -c system.nrcpus=X. -system.nrcpu = 1 - -# Specify simulation duration. Simulation will stop automatically once this -# time-stamp is reached. Use integer values with suffixes s, ms, us or ns. If -# you want to simulate infinitely, leave this commented out. -# system.duration = 2s - -# TLM global quantum, a higher value improves performance but reduces timing -# accuracy. Use integer values with suffixes s, ms, us or ns. -system.quantum = 10us - -# Clock frequency -system.clock.hz = 1000000000 # 1 GHz - -### CPU configuration ######################################################## - -system.arm0.gdb_port = 52100 -system.arm0.gdb_wait = 0 # (0) start core immediately; (1) wait for gdb - -### Physical Address Map ##################################################### - -system.addr_ram = 0x00000000..0x0fffffff -system.addr_hwrng = 0x10007000..0x10007fff -system.addr_simdev = 0x10008000..0x10008fff -system.addr_uart0 = 0x10009000..0x10009fff -system.addr_uart1 = 0x1000a000..0x1000afff -system.addr_uart2 = 0x1000b000..0x1000bfff -system.addr_uart3 = 0x1000c000..0x1000cfff -system.addr_ethoc = 0x1000d000..0x1000efff -system.addr_sdhci = 0x1000f000..0x1000ffff -system.addr_gic_distif = 0x10140000..0x10140fff -system.addr_gic_cpuif = 0x10141000..0x10142fff -system.addr_gic_vifctrl= 0x10143000..0x10144fff -system.addr_gic_vcpuif = 0x10145000..0x10146fff - -### Interrupt Map ############################################################ - -system.irq_uart0 = 12 -system.irq_uart1 = 13 -system.irq_uart2 = 14 -system.irq_uart3 = 15 - -### Memory and IO peripherals configuration ################################## - -# Memory configuration -system.ram.size = 0x10000000 # 256MB -system.ram.images = ${dir}/../sw/arm64/benchmark/stream/stream.bin@0x00000000 - -# UART configuration -system.term0.backends = term tcp:51010 # stdout|file|tap|null -system.term1.backends = stdout tcp:51011 # term|file|tap|null -system.term2.backends = stdout tcp:51012 # term|file|tap|null -system.term3.backends = stdout tcp:51013 # term|file|tap|null - -# ETHOC configuration -system.ethoc.mac = 3a:44:1d:55:11:5a -system.bridge.backends = slirp:0 diff --git a/config/arm64_whetstone.cfg b/config/arm64_whetstone.cfg deleted file mode 100644 index f9fb923..0000000 --- a/config/arm64_whetstone.cfg +++ /dev/null @@ -1,82 +0,0 @@ -############################################################################## -# # -# Copyright 2022 Nils Bosbach, Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -### Simulation TCP port summary ############################################## - -# system.term0 -> 51010 (raw binary) -# system.term1 -> 51011 (raw binary) -# system.term2 -> 51012 (raw binary) -# system.term3 -> 51013 (raw binary) -# system.arm0 -> 51111 (GDB RSP) - -### General configuration #################################################### -system.name = avp64 -system.desc = Runs the whetstone benchmark on a single-core aarch64 CPU -system.config = ${cfg} - -# Specify the number of processors to instantiate in the simulation. Maximum -# allowed is 32. Override this on command line using -c system.nrcpus=X. -system.nrcpu = 1 - -# Specify simulation duration. Simulation will stop automatically once this -# time-stamp is reached. Use integer values with suffixes s, ms, us or ns. If -# you want to simulate infinitely, leave this commented out. -# system.duration = 2s - -# TLM global quantum, a higher value improves performance but reduces timing -# accuracy. Use integer values with suffixes s, ms, us or ns. -system.quantum = 10us - -# Clock frequency -system.clock.hz = 1000000000 # 1 GHz - -### CPU configuration ######################################################## - -system.arm0.gdb_port = 52100 -system.arm0.gdb_wait = 0 # (0) start core immediately; (1) wait for gdb - -### Physical Address Map ##################################################### - -system.addr_ram = 0x00000000..0x0fffffff -system.addr_hwrng = 0x10007000..0x10007fff -system.addr_simdev = 0x10008000..0x10008fff -system.addr_uart0 = 0x10009000..0x10009fff -system.addr_uart1 = 0x1000a000..0x1000afff -system.addr_uart2 = 0x1000b000..0x1000bfff -system.addr_uart3 = 0x1000c000..0x1000cfff -system.addr_ethoc = 0x1000d000..0x1000efff -system.addr_sdhci = 0x1000f000..0x1000ffff -system.addr_gic_distif = 0x10140000..0x10140fff -system.addr_gic_cpuif = 0x10141000..0x10142fff -system.addr_gic_vifctrl= 0x10143000..0x10144fff -system.addr_gic_vcpuif = 0x10145000..0x10146fff - -### Interrupt Map ############################################################ - -system.irq_uart0 = 12 -system.irq_uart1 = 13 -system.irq_uart2 = 14 -system.irq_uart3 = 15 - -### Memory and IO peripherals configuration ################################## - -# Memory configuration -system.ram.size = 0x10000000 # 256MB -system.ram.images = ${dir}/../sw/arm64/benchmark/whetstone/whetstone.bin@0x00000000 - -# UART configuration -system.term0.backends = term tcp:51010 # stdout|file|tap|null -system.term1.backends = stdout tcp:51011 # term|file|tap|null -system.term2.backends = stdout tcp:51012 # term|file|tap|null -system.term3.backends = stdout tcp:51013 # term|file|tap|null - -# ETHOC configuration -system.ethoc.mac = 3a:44:1d:55:11:5a -system.bridge.backends = slirp:0 diff --git a/config/arm64_xen.cfg b/config/arm64_xen.cfg deleted file mode 100644 index 67ed914..0000000 --- a/config/arm64_xen.cfg +++ /dev/null @@ -1,96 +0,0 @@ -############################################################################## -# # -# Copyright 2020 Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -### Simulation TCP port summary ############################################## - -# system.term0 -> 52010 (raw binary) -# system.term1 -> 52011 (raw binary) -# system.term2 -> 52012 (raw binary) -# system.term3 -> 52013 (raw binary) -# system.arm0 -> 52100 (GDB RSP) - -### General configuration #################################################### -system.name = avp64 -system.desc = Boots XEN on a single-core aarch64 CPU -system.config = ${cfg} - -# Specify the number of processors to instantiate in the simulation. -system.nrcpu = 1 - -# Specify simulation duration. Simulation will stop automatically once this -# time-stamp is reached. Use integer values with suffixes s, ms, us or ns. If -# you want to simulate infinitely, leave this commented out. -# system.duration = 2s - -# TLM global quantum, a higher value improves performance but reduces timing -# accuracy. Use integer values with suffixes s, ms, us or ns. -system.quantum = 10us - -# Clock frequency -system.clock.hz = 1000000000 # 1 GHz - -### CPU configuration ######################################################## - -system.arm0.gdb_port = 52100 -system.arm0.gdb_wait = 0 # (0) start core immediately; (1) wait for gdb - -### Physical Address Map ##################################################### - -system.addr_ram = 0x00000000..0x7fffffff -system.addr_gic_distif = 0x90140000..0x90140fff -system.addr_gic_cpuif = 0x90141000..0x90142fff -system.addr_gic_vifctrl= 0x90143000..0x90144fff -system.addr_gic_vcpuif = 0x90145000..0x90146fff -system.addr_ethoc = 0x90004000..0x90005fff -system.addr_sdhci = 0x9000d000..0x9000dfff -system.addr_simdev = 0x90007000..0x90007fff -system.addr_uart0 = 0x90009000..0x90009fff -system.addr_uart1 = 0x9000a000..0x9000afff -system.addr_uart2 = 0x9000b000..0x9000bfff -system.addr_uart3 = 0x9000c000..0x9000cfff -system.addr_hwrng = 0x9000e000..0x9000efff -system.addr_spi = 0x100147000..0x100148fff -system.addr_gpio = 0x100149000..0x100149fff -### Interrupt Map ############################################################ - -system.irq_uart0 = 5 -system.irq_uart1 = 6 -system.irq_uart2 = 7 -system.irq_uart3 = 8 -system.irq_ethoc = 9 -system.irq_sdhci = 10 -system.irq_gt_hyp = 26 -system.irq_gt_virt= 27 -system.irq_gt_ns = 30 -system.irq_gt_s = 29 - -### Memory and IO peripherals configuration ################################## - -# Memory configuration -system.ram.size = 0x80000000 # 2GB -# Note that Xen expects a gzip'ed Image -system.ram.images = ${dir}/../sw/arm64/xen/boot.bin@0x00000000 \ - ${dir}/../sw/arm64/xen/Image-4.19.4.gz@0x7f600000 \ - ${dir}/../sw/arm64/xen/xen.dtb@0x7ec00000 \ - ${dir}/../sw/arm64/xen/xen@0x7ea00000 - -# SD Card configuration -system.sdcard.readonly = true -system.sdcard.image = ${dir}/../sw/arm64/xen/sdcard.img - -# UART configuration -system.term0.backends = term tcp:52010 # stdout|file|tap|null -system.term1.backends = tcp:52011 # term|file|tap|null -system.term2.backends = tcp:52012 # term|file|tap|null -system.term3.backends = tcp:52013 # term|file|tap|null - -# ETHOC configuration -system.ethoc.mac = 3a:44:1d:55:11:5a -system.bridge.backends = slirp:0 diff --git a/config/arm64x2_xen.cfg b/config/arm64x2_xen.cfg deleted file mode 100644 index 1adddb6..0000000 --- a/config/arm64x2_xen.cfg +++ /dev/null @@ -1,95 +0,0 @@ -############################################################################## -# # -# Copyright 2020 Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################## - -### Simulation TCP port summary ############################################## - -# system.term0 -> 52010 (raw binary) -# system.term1 -> 52011 (raw binary) -# system.term2 -> 52012 (raw binary) -# system.term3 -> 52013 (raw binary) -# system.arm0 -> 52100 (GDB RSP) - -### General configuration #################################################### -system.name = avp64 -system.desc = Boots XEN on a dual-core aarch64 CPU -system.config = ${cfg} - -# Specify the number of processors to instantiate in the simulation. -system.nrcpu = 2 - -# Specify simulation duration. Simulation will stop automatically once this -# time-stamp is reached. Use integer values with suffixes s, ms, us or ns. If -# you want to simulate infinitely, leave this commented out. -# system.duration = 2s - -# TLM global quantum, a higher value improves performance but reduces timing -# accuracy. Use integer values with suffixes s, ms, us or ns. -system.quantum = 10us - -### CPU configuration ######################################################## - -for i : ${system.nrcpu} do - system.arm${i}.gdb_port = 5210${i} - system.arm${i}.gdb_wait = 0 # (0) start core immediately; (1) wait for gdb -done - -### Physical Address Map ##################################################### - -system.addr_ram = 0x00000000..0x7fffffff -system.addr_gic_distif = 0x90140000..0x90140fff -system.addr_gic_cpuif = 0x90141000..0x90142fff -system.addr_gic_vifctrl= 0x90143000..0x90144fff -system.addr_gic_vcpuif = 0x90145000..0x90146fff -system.addr_ethoc = 0x90004000..0x90005fff -system.addr_sdhci = 0x9000d000..0x9000dfff -system.addr_simdev = 0x90007000..0x90007fff -system.addr_uart0 = 0x90009000..0x90009fff -system.addr_uart1 = 0x9000a000..0x9000afff -system.addr_uart2 = 0x9000b000..0x9000bfff -system.addr_uart3 = 0x9000c000..0x9000cfff -system.addr_hwrng = 0x9000e000..0x9000efff -system.addr_spi = 0x100147000..0x100148fff -system.addr_gpio = 0x100149000..0x100149fff -### Interrupt Map ############################################################ - -system.irq_uart0 = 5 -system.irq_uart1 = 6 -system.irq_uart2 = 7 -system.irq_uart3 = 8 -system.irq_ethoc = 9 -system.irq_sdhci = 10 -system.irq_gt_hyp = 26 -system.irq_gt_virt= 27 -system.irq_gt_ns = 30 -system.irq_gt_s = 29 - -### Memory and IO peripherals configuration ################################## - -# Memory configuration -system.ram.size = 0x80000000 # 2GB -# Note that Xen expects a gzip'ed Image -system.ram.images = ${dir}/../sw/arm64x2/xen/boot.bin@0x00000000 \ - ${dir}/../sw/arm64x2/xen/Image-4.19.4.gz@0x7f600000 \ - ${dir}/../sw/arm64x2/xen/xen_dualcore.dtb@0x7ec00000 \ - ${dir}/../sw/arm64x2/xen/xen@0x7ea00000 - -# SD Card configuration -system.sdcard.readonly = true -system.sdcard.image = ${dir}/../sw/arm64x2/xen/sdcard.img - -# UART configuration -system.term0.backends = term tcp:52010 # stdout|file|tap|null -system.term1.backends = tcp:52011 # term|file|tap|null -system.term2.backends = tcp:52012 # term|file|tap|null -system.term3.backends = tcp:52013 # term|file|tap|null - -# ETHOC configuration -system.ethoc.mac = 3a:44:1d:55:11:5a -system.bridge.backends = slirp:0 diff --git a/deps/ocx-qemu-arm b/deps/ocx-qemu-arm deleted file mode 160000 index 7ecddec..0000000 --- a/deps/ocx-qemu-arm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7ecddec27bd58ccf95871ac45733efeca5f04399 diff --git a/deps/vcml b/deps/vcml deleted file mode 160000 index 17eff7a..0000000 --- a/deps/vcml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 17eff7af6bf0270fda317b5470beba9f79c56fb7 diff --git a/include/avp64.h b/include/avp64.h new file mode 100644 index 0000000..68e12b9 --- /dev/null +++ b/include/avp64.h @@ -0,0 +1,21 @@ +/****************************************************************************** + * * + * Copyright 2024 Lukas Jünger, Nils Bosbach * + * * + * This software is licensed under the MIT license found in the * + * LICENSE file at the root directory of this source tree. * + * * + ******************************************************************************/ + +#ifndef AVP64_H +#define AVP64_H + +#include "avp64/core.h" +#include "avp64/cpu.h" +#include "avp64/version.h" + +#include + +MWR_DECLARE_MODULE(AVP64, "avp64", "MIT"); + +#endif diff --git a/include/avp64/config.h b/include/avp64/config.h deleted file mode 100644 index 941f6aa..0000000 --- a/include/avp64/config.h +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * * - * Copyright 2020 Lukas Jünger * - * * - * This software is licensed under the MIT license found in the * - * LICENSE file at the root directory of this source tree. * - * * - ******************************************************************************/ - -#ifndef AVP64_CONFIG_H -#define AVP64_CONFIG_H - -// memory map -#define AVP64_RAM_ADDR (0x00000000ull) -#define AVP64_RAM_SIZE (0x10000000ull) -#define AVP64_RAM_HIGH (AVP64_RAM_ADDR + AVP64_RAM_SIZE - 1) - -#define AVP64_GIC_DISTIF_ADDR (0x10140000ull) -#define AVP64_GIC_DISTIF_SIZE (0x00001000ull) -#define AVP64_GIC_DISTIF_HIGH \ - (AVP64_GIC_DISTIF_ADDR + AVP64_GIC_DISTIF_SIZE - 1) - -#define AVP64_GIC_CPUIF_ADDR (0x10141000ull) -#define AVP64_GIC_CPUIF_SIZE (0x00002000ull) -#define AVP64_GIC_CPUIF_HIGH (AVP64_GIC_CPUIF_ADDR + AVP64_GIC_CPUIF_SIZE - 1) - -#define AVP64_GIC_VIFCTRL_ADDR (0x10143000ull) -#define AVP64_GIC_VIFCTRL_SIZE (0x00002000ull) -#define AVP64_GIC_VIFCTRL_HIGH \ - (AVP64_GIC_VIFCTRL_ADDR + AVP64_GIC_VIFCTRL_SIZE - 1) - -#define AVP64_GIC_VCPUIF_ADDR (0x10145000ull) -#define AVP64_GIC_VCPUIF_SIZE (0x00002000ull) -#define AVP64_GIC_VCPUIF_HIGH \ - (AVP64_GIC_VCPUIF_ADDR + AVP64_GIC_VCPUIF_SIZE - 1) - -#define AVP64_HWRNG_ADDR (0x10007000ull) -#define AVP64_HWRNG_SIZE (0x00001000ull) -#define AVP64_HWRNG_HIGH (AVP64_HWRNG_ADDR + AVP64_HWRNG_SIZE - 1) - -#define AVP64_SIMDEV_ADDR (0x10008000ull) -#define AVP64_SIMDEV_SIZE (0x00001000ull) -#define AVP64_SIMDEV_HIGH (AVP64_SIMDEV_ADDR + AVP64_SIMDEV_SIZE - 1) - -#define AVP64_UART0_ADDR (0x10009000ull) -#define AVP64_UART0_SIZE (0x00001000ull) -#define AVP64_UART0_HIGH (AVP64_UART0_ADDR + AVP64_UART0_SIZE - 1) - -#define AVP64_UART1_ADDR (0x1000a000ull) -#define AVP64_UART1_SIZE (0x00001000ull) -#define AVP64_UART1_HIGH (AVP64_UART1_ADDR + AVP64_UART1_SIZE - 1) - -#define AVP64_UART2_ADDR (0x1000b000ull) -#define AVP64_UART2_SIZE (0x00001000ull) -#define AVP64_UART2_HIGH (AVP64_UART2_ADDR + AVP64_UART2_SIZE - 1) - -#define AVP64_UART3_ADDR (0x1000c000ull) -#define AVP64_UART3_SIZE (0x00001000ull) -#define AVP64_UART3_HIGH (AVP64_UART3_ADDR + AVP64_UART3_SIZE - 1) - -#define AVP64_ETHOC_ADDR (0x1000d000ull) -#define AVP64_ETHOC_SIZE (0x00002000ull) -#define AVP64_ETHOC_HIGH (AVP64_ETHOC_ADDR + AVP64_ETHOC_SIZE - 1) - -#define AVP64_SDHCI_ADDR (0x1000f000ull) -#define AVP64_SDHCI_SIZE (0x00001000ull) -#define AVP64_SDHCI_HIGH (AVP64_SDHCI_ADDR + AVP64_SDHCI_SIZE - 1) - -#define AVP64_SPI_ADDR (0x10147000ull) -#define AVP64_SPI_SIZE (0x00002000ull) -#define AVP64_SPI_HIGH (AVP64_SPI_ADDR + AVP64_SPI_SIZE - 1) - -#define AVP64_GPIO_ADDR (0x10149000ull) -#define AVP64_GPIO_SIZE (0x00001000ull) -#define AVP64_GPIO_HIGH (AVP64_GPIO_ADDR + AVP64_GPIO_SIZE - 1) - -// interrupt map -#define AVP64_IRQ_UART0 (5) -#define AVP64_IRQ_UART1 (6) -#define AVP64_IRQ_UART2 (7) -#define AVP64_IRQ_UART3 (8) -#define AVP64_IRQ_ETHOC (9) -#define AVP64_IRQ_SDHCI (10) -#define AVP64_IRQ_GT_NS (30) -#define AVP64_IRQ_GT_S (29) -#define AVP64_IRQ_GT_VIRT (27) -#define AVP64_IRQ_GT_HYP (26) -#define AVP64_IRQ_SPI (11) - -#define AVP64_CPU_DEFCLK (100 * vcml::MHz) - -#endif // AVP64_CONFIG_H diff --git a/include/avp64/arm64_cpu.h b/include/avp64/core.h similarity index 76% rename from include/avp64/arm64_cpu.h rename to include/avp64/core.h index ac9bf09..dba14b3 100644 --- a/include/avp64/arm64_cpu.h +++ b/include/avp64/core.h @@ -1,28 +1,38 @@ /****************************************************************************** * * - * Copyright 2020 Lukas Jünger * + * Copyright 2024 Lukas Jünger, Nils Bosbach * * * * This software is licensed under the MIT license found in the * * LICENSE file at the root directory of this source tree. * * * ******************************************************************************/ -#ifndef AVP_ARM64_CPU_H -#define AVP_ARM64_CPU_H +#ifndef AVP64_CORE_H +#define AVP64_CORE_H #include "vcml.h" #include "ocx/ocx.h" + #include namespace avp64 { -class arm64_cpu; +class core; class memory_protector { private: + struct page_data { + core* c; + vcml::u64 page_addr; + vcml::u64 page_size; + bool locked; + }; + std::map m_protected_pages; + struct sigaction m_sa_orig; + memory_protector(); - std::map> m_protected_pages; + void segfault_handler_int(int sig, siginfo_t* si, void*); public: static memory_protector& get_instance() { @@ -30,11 +40,20 @@ class memory_protector return inst; } - static void segfault_handler(int sig, siginfo_t* si, void*); - void register_page(arm64_cpu* cpu, vcml::u64 page_addr, void* host_addr); - void notify_page(void* access_addr); memory_protector(const memory_protector&) = delete; void operator=(memory_protector const&) = delete; + virtual ~memory_protector(); + + static void segfault_handler(int sig, siginfo_t* si, void*); + void register_page(core* cpu, vcml::u64 page_addr, void* host_addr); + bool notify_page(void* access_addr); +}; + +enum : size_t { + INTERRUPT_IRQ = 0, + INTERRUPT_FIQ = 1, + INTERRUPT_VIRQ = 2, + INTERRUPT_VFIQ = 3, }; enum arm_generic_timer_type { @@ -46,7 +65,7 @@ enum arm_generic_timer_type { typedef ocx::core* (*create_instance_t)(ocx::u64, ocx::env&, const char*); -class arm64_cpu : public vcml::processor, public ocx::env +class core : public vcml::processor, private ocx::env { private: ocx::core* m_core; @@ -56,7 +75,9 @@ class arm64_cpu : public vcml::processor, public ocx::env vcml::u64 m_total_cycles; void* m_ocx_handle; create_instance_t m_create_instance_func; - std::vector> m_syscall_subscriber; + std::vector> m_syscall_subscriber; + std::unordered_set m_update_mem; + std::list>> m_syscalls; void timer_irq_trigger(int timer_id); static void segfault_handler(int sig, siginfo_t* si, void* unused); @@ -85,6 +106,8 @@ class arm64_cpu : public vcml::processor, public ocx::env vcml::gpio_initiator_array timer_irq_out; std::vector> timer_events; + void log_timing_info() const; + virtual ocx::u8* get_page_ptr_r(ocx::u64 page_paddr) override; virtual ocx::u8* get_page_ptr_w(ocx::u64 page_paddr) override; @@ -110,7 +133,7 @@ class arm64_cpu : public vcml::processor, public ocx::env virtual bool handle_watchpoint(ocx::u64 vaddr, ocx::u64 size, ocx::u64 data, bool iswr) override; - void inject_cpu(arm64_cpu* cpu); + void inject_cpu(core* cpu); virtual vcml::u64 cycle_count() const override; virtual void update_local_time(sc_core::sc_time& local_time, @@ -119,17 +142,18 @@ class arm64_cpu : public vcml::processor, public ocx::env std::string& code) override; virtual vcml::u64 program_counter() override; virtual vcml::u64 stack_pointer() override; - virtual vcml::u64 get_core_id(); + virtual vcml::u64 core_id() override; void handle_syscall(int callno, std::shared_ptr arg); - void add_syscall_subscriber(const std::shared_ptr& cpu); + void add_syscall_subscriber(const std::shared_ptr& cpu); vcml::u64 get_page_size(); - arm64_cpu() = delete; - arm64_cpu(const arm64_cpu&) = delete; - explicit arm64_cpu(const sc_core::sc_module_name& name, vcml::u64 procid, - vcml::u64 coreid); - virtual ~arm64_cpu(); + core() = delete; + core(const core&) = delete; + explicit core(const sc_core::sc_module_name& name, vcml::u64 procid, + vcml::u64 coreid); + virtual ~core() override; + virtual const char* kind() const override { return "avp64::core"; } }; } // namespace avp64 diff --git a/include/avp64/cpu.h b/include/avp64/cpu.h new file mode 100644 index 0000000..359ac7c --- /dev/null +++ b/include/avp64/cpu.h @@ -0,0 +1,87 @@ +/****************************************************************************** + * * + * Copyright 2024 Lukas Jünger, Nils Bosbach * + * * + * This software is licensed under the MIT license found in the * + * LICENSE file at the root directory of this source tree. * + * * + ******************************************************************************/ + +#ifndef AVP64_CPU_H +#define AVP64_CPU_H + +#include +#include "vcml.h" +#include "avp64/core.h" + +namespace avp64 { + +enum : mwr::u64 { + GIC_DISTIF_LO = 0x10140000, + GIC_DISTIF_HI = GIC_DISTIF_LO + 0x1000 - 1, + GIC_CPUIF_LO = 0x10141000, + GIC_CPUIF_HI = GIC_CPUIF_LO + 0x2000 - 1, + GIC_VIFCTRL_LO = 0x10143000, + GIC_VIFCTRL_HI = GIC_VIFCTRL_LO + 0x2000 - 1, + GIC_VCPUIF_LO = 0x10145000, + GIC_VCPUIF_HI = GIC_VCPUIF_LO + 0x2000 - 1, +}; + +enum : mwr::u64 { + PPI_GT_NS = 14, + PPI_GT_S = 13, + PPI_GT_VIRT = 11, + PPI_GT_HYP = 10, +}; + +class cpu : public vcml::component +{ +public: + vcml::property ncores; + vcml::property clusterid; + vcml::property symbols; + vcml::property async; + vcml::property async_rate; + + vcml::property gic_cpuif; + vcml::property gic_distif; + vcml::property gic_vifctrl; + vcml::property gic_vcpuif; + + vcml::property irq_gt_hyp; + vcml::property irq_gt_virt; + vcml::property irq_gt_ns; + vcml::property irq_gt_s; + + vcml::property gdb_wait; + vcml::property gdb_echo; + vcml::property gdb_port; + + tlm::tlm_initiator_socket<> bus; + vcml::gpio_target_array spi; + + cpu(const sc_core::sc_module_name& nm); + cpu() = delete; + cpu(const cpu&) = delete; + virtual ~cpu() = default; + virtual const char* kind() const override { return "avp64::cpu"; } + + vcml::u64 cycle_count() const; + + virtual const char* version() const override; + +protected: + virtual void end_of_elaboration() override; + virtual void before_end_of_elaboration() override; + virtual void end_of_simulation() override; + +private: + std::vector> m_cores; + + vcml::arm::gic400 m_gic; + vcml::generic::bus m_corebus; + + std::shared_ptr m_gdb; +}; +} // namespace avp64 +#endif diff --git a/patches/unicorn-fix-breakpoint.patch b/patches/unicorn-fix-breakpoint.patch deleted file mode 100644 index b482f34..0000000 --- a/patches/unicorn-fix-breakpoint.patch +++ /dev/null @@ -1,26 +0,0 @@ -dnuxiff --git a/qemu/target/arm/translate-a64.c b/qemu/target/arm/translate-a64.c -index 0c1cb192..27e5b1f5 100644 ---- a/qemu/target/arm/translate-a64.c -+++ b/qemu/target/arm/translate-a64.c -@@ -15121,7 +15121,7 @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, - if (bp->flags & BP_CALL) { // SNPS added - gen_a64_set_pc_im(dc, dc->base.pc_next); - gen_helper_call_breakpoints(tcg_ctx, tcg_ctx->cpu_env); -- dc->base.is_jmp = DISAS_TOO_MANY; -+ dc->base.is_jmp = DISAS_EXIT; - } else - if (bp->flags & BP_CPU) { - gen_a64_set_pc_im(dc, dc->base.pc_next); -diff --git a/qemu/target/arm/translate.c b/qemu/target/arm/translate.c -index 9caffdce..4ff13b0c 100644 ---- a/qemu/target/arm/translate.c -+++ b/qemu/target/arm/translate.c -@@ -9265,7 +9265,7 @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, - gen_set_condexec(dc); - gen_set_pc_im(dc, dc->base.pc_next); - gen_helper_call_breakpoints(tcg_ctx, tcg_ctx->cpu_env); -- dc->base.is_jmp = DISAS_TOO_MANY; -+ dc->base.is_jmp = DISAS_EXIT; - } else - if (bp->flags & BP_CPU) { - gen_set_condexec(dc); diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 86de1fb..0000000 --- a/setup.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/bash -############################################################################## -# # -# Copyright 2020 Lukas Jünger # -# # -# This software is licensed under the MIT license. # -# A copy of the license can be found in the LICENSE file at the root # -# of the source tree. # -# # -############################################################################# - -set -e -# Get directory of script itself -SOURCE="${BASH_SOURCE[0]}" -# resolve $SOURCE until the file is no longer a symlink -while [ -h "$SOURCE" ]; do - DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" - SOURCE="$(readlink "$SOURCE")" - # if $SOURCE was a relative symlink, we need to resolve it relative to the - # path where the symlink file was located - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" -done -DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" - - -# If AVP64_SW is set, overwrite files with local version -if [ -z "$AVP64_SW" ]; then - echo "Error, specify AVP64_SW environment variable" - exit 0 -fi - - -if [ -d $DIR/build/debug ] || [ -d $DIR/build/release ]; then - BUILD_DEBUG="$DIR/build/debug" - BUILD_RELEASE="$DIR/build/release" -else - BUILD_DEBUG="$DIR/BUILD/DEBUG" - BUILD_RELEASE="$DIR/BUILD/RELEASE" -fi - -rm -rf "$BUILD_DEBUG/sw" -rm -rf "$BUILD_RELEASE/sw" - -# Linux Kernel build -AVP64_LINUX_BUILD="$AVP64_SW/linux/BUILD" -AVP64_LINUX_KERNEL_IMAGE="$AVP64_LINUX_BUILD/buildroot/output/linux/images/Image" -AVP64_LINUX_KERNEL_ELF="$AVP64_LINUX_BUILD/buildroot/output/linux/build/linux-4.19.4/vmlinux" -AVP64_LINUX_DTB_DIR="$AVP64_LINUX_BUILD/buildroot/output/dt" -AVP64_LINUX_SDCARD="$AVP64_LINUX_BUILD/buildroot/output/linux/images/sdcard.img" -AVP64_LINUX_BOOT="$AVP64_LINUX_BUILD/linux_bootcode/el3/boot.bin" - -if [ -f "$AVP64_LINUX_KERNEL_IMAGE" ]; then - echo "Found Linux kernel build at $AVP64_LINUX_BUILD" - - mkdir -p "$BUILD_DEBUG/sw/arm64/linux" - mkdir -p "$BUILD_RELEASE/sw/arm64/linux" - cp -rv "$AVP64_LINUX_KERNEL_IMAGE" "$BUILD_DEBUG/sw/arm64/linux/Image-4.19.4" - ln -s -r "$BUILD_DEBUG/sw/arm64/linux/Image-4.19.4" "$BUILD_RELEASE/sw/arm64/linux/Image-4.19.4" - cp -rv "$AVP64_LINUX_KERNEL_ELF" "$BUILD_DEBUG/sw/arm64/linux/vmlinux-4.19.4" - ln -s -r "$BUILD_DEBUG/sw/arm64/linux/vmlinux-4.19.4" "$BUILD_RELEASE/sw/arm64/linux/vmlinux-4.19.4" - cp -rv "$AVP64_LINUX_SDCARD" "$BUILD_DEBUG/sw/arm64/linux/sdcard.img" - chmod -w "$BUILD_DEBUG/sw/arm64/linux/sdcard.img" - ln -s -r "$BUILD_DEBUG/sw/arm64/linux/sdcard.img" "$BUILD_RELEASE/sw/arm64/linux/sdcard.img" - cp -rv "$AVP64_LINUX_BOOT" "$BUILD_DEBUG/sw/arm64/linux/boot.bin" - ln -s -r "$BUILD_DEBUG/sw/arm64/linux/boot.bin" "$BUILD_RELEASE/sw/arm64/linux/boot.bin" - - cp -rv "$AVP64_LINUX_DTB_DIR/avp64x1.dtb" "$BUILD_DEBUG/sw/arm64/linux/" - ln -s -r "$BUILD_DEBUG/sw/arm64/linux/avp64x1.dtb" "$BUILD_RELEASE/sw/arm64/linux/avp64x1.dtb" - - cp -rv "$AVP64_LINUX_DTB_DIR/avp64x2.dtb" "$BUILD_DEBUG/sw/arm64/linux/" - ln -s -r "$BUILD_DEBUG/sw/arm64/linux/avp64x2.dtb" "$BUILD_RELEASE/sw/arm64/linux/avp64x2.dtb" - - cp -rv "$AVP64_LINUX_DTB_DIR/avp64x4.dtb" "$BUILD_DEBUG/sw/arm64/linux/" - ln -s -r "$BUILD_DEBUG/sw/arm64/linux/avp64x4.dtb" "$BUILD_RELEASE/sw/arm64/linux/avp64x4.dtb" - - cp -rv "$AVP64_LINUX_DTB_DIR/avp64x8.dtb" "$BUILD_DEBUG/sw/arm64/linux/" - ln -s -r "$BUILD_DEBUG/sw/arm64/linux/avp64x8.dtb" "$BUILD_RELEASE/sw/arm64/linux/avp64x8.dtb" - -else - echo "Linux kernel build not found at $AVP64_LINUX_BUILD" -fi - -# Xen build -AVP64_XEN_BUILD="$AVP64_SW/xen/BUILD" -AVP64_XEN_KERNEL_IMAGE="$AVP64_XEN_BUILD/buildroot/output/dom0/images/Image.gz" -AVP64_XEN_KERNEL_ELF="$AVP64_XEN_BUILD/buildroot/output/dom0/build/linux-4.19.4/vmlinux" -AVP64_XEN_DTB="$AVP64_XEN_BUILD/buildroot/output/dom0/images/avp64_xen.dtb" -AVP64_XEN_SDCARD="$AVP64_XEN_BUILD/sdcard_image/images/sdcard.img" -AVP64_XEN_BOOT="$AVP64_XEN_BUILD/xen_bootcode/boot.bin" -AVP64_XEN_IMAGE="$AVP64_XEN_BUILD/buildroot/output/dom0/images/xen" -AVP64_XEN_SYMS="$AVP64_XEN_BUILD/buildroot/output/dom0/build/xen-4.13.0/xen/xen-syms" - -if [ -f "$AVP64_XEN_IMAGE" ]; then - echo "Found Xen build at $AVP64_XEN_BUILD" - - mkdir -p "$BUILD_DEBUG/sw/arm64/xen" - mkdir -p "$BUILD_RELEASE/sw/arm64/xen" - cp -rv "$AVP64_XEN_KERNEL_IMAGE" "$BUILD_DEBUG/sw/arm64/xen/Image-4.19.4.gz" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/Image-4.19.4.gz" "$BUILD_RELEASE/sw/arm64/xen/Image-4.19.4.gz" - cp -rv "$AVP64_XEN_KERNEL_ELF" "$BUILD_DEBUG/sw/arm64/xen/vmlinux-4.19.4" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/vmlinux-4.19.4" "$BUILD_RELEASE/sw/arm64/xen/vmlinux-4.19.4" - cp -rv "$AVP64_XEN_DTB" "$BUILD_DEBUG/sw/arm64/xen/xen.dtb" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/xen.dtb" "$BUILD_RELEASE/sw/arm64/xen/xen.dtb" - cp -rv "$AVP64_XEN_SDCARD" "$BUILD_DEBUG/sw/arm64/xen/sdcard.img" - chmod -w "$BUILD_DEBUG/sw/arm64/xen/sdcard.img" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/sdcard.img" "$BUILD_RELEASE/sw/arm64/xen/sdcard.img" - cp -rv "$AVP64_XEN_BOOT" "$BUILD_DEBUG/sw/arm64/xen/boot.bin" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/boot.bin" "$BUILD_RELEASE/sw/arm64/xen/boot.bin" - cp -rv "$AVP64_XEN_IMAGE" "$BUILD_DEBUG/sw/arm64/xen/xen" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/xen" "$BUILD_RELEASE/sw/arm64/xen/xen" - cp -rv "$AVP64_XEN_SYMS" "$BUILD_DEBUG/sw/arm64/xen/xen-syms" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/xen-syms" "$BUILD_RELEASE/sw/arm64/xen/xen-syms" - - AVP64X2_XEN_DTB="$AVP64_XEN_BUILD/buildroot/output/dom0/images/avp64_xen_dualcore.dtb" - - mkdir -p "$BUILD_DEBUG/sw/arm64x2/xen" - mkdir -p "$BUILD_RELEASE/sw/arm64x2/xen" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/Image-4.19.4.gz" "$BUILD_RELEASE/sw/arm64x2/xen/Image-4.19.4.gz" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/Image-4.19.4.gz" "$BUILD_DEBUG/sw/arm64x2/xen/Image-4.19.4.gz" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/vmlinux-4.19.4" "$BUILD_RELEASE/sw/arm64x2/xen/vmlinux-4.19.4" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/vmlinux-4.19.4" "$BUILD_DEBUG/sw/arm64x2/xen/vmlinux-4.19.4" - cp -rv "$AVP64X2_XEN_DTB" "$BUILD_DEBUG/sw/arm64x2/xen/xen_dualcore.dtb" - ln -s -r "$BUILD_DEBUG/sw/arm64x2/xen/xen_dualcore.dtb" "$BUILD_RELEASE/sw/arm64x2/xen/xen_dualcore.dtb" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/sdcard.img" "$BUILD_RELEASE/sw/arm64x2/xen/sdcard.img" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/sdcard.img" "$BUILD_DEBUG/sw/arm64x2/xen/sdcard.img" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/boot.bin" "$BUILD_RELEASE/sw/arm64x2/xen/boot.bin" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/boot.bin" "$BUILD_DEBUG/sw/arm64x2/xen/boot.bin" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/xen" "$BUILD_RELEASE/sw/arm64x2/xen/xen" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/xen" "$BUILD_DEBUG/sw/arm64x2/xen/xen" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/xen-syms" "$BUILD_RELEASE/sw/arm64x2/xen/xen-syms" - ln -s -r "$BUILD_DEBUG/sw/arm64/xen/xen-syms" "$BUILD_DEBUG/sw/arm64x2/xen/xen-syms" -else - echo "Xen build not found at $AVP64_XEN_BUILD" -fi - -# benchmarks -AVP64_BENCH_BUILD="$AVP64_SW/benchmark/BUILD" - -function copy_benchmark { - BENCH_BUILD=$AVP64_BENCH_BUILD/$1 - BENCH_BIN=$BENCH_BUILD/$1.bin - BENCH_ELF=$BENCH_BUILD/$1.elf - - if [ -f $BENCH_BIN ]; then - echo "Found benchmark $1 at $BENCH_BUILD" - mkdir -p "$BUILD_DEBUG/sw/arm64/benchmark/$1" - mkdir -p "$BUILD_RELEASE/sw/arm64/benchmark/$1" - - cp -rv "$BENCH_BIN" "$BUILD_DEBUG/sw/arm64/benchmark/$1/$1.bin" - ln -s -r "$BUILD_DEBUG/sw/arm64/benchmark/$1/$1.bin" "$BUILD_RELEASE/sw/arm64/benchmark/$1/$1.bin" - - if [ -f $BENCH_ELF ]; then - cp -rv "$BENCH_ELF" "$BUILD_DEBUG/sw/arm64/benchmark/$1/$1.elf" - ln -s -r "$BUILD_DEBUG/sw/arm64/benchmark/$1/$1.elf" "$BUILD_RELEASE/sw/arm64/benchmark/$1/$1.elf" - fi - else - echo "Binary file of benchmark $1 not found" - fi -} - -copy_benchmark coremark -copy_benchmark dhrystone -copy_benchmark stream -copy_benchmark whetstone diff --git a/src/arm64_cpu.cpp b/src/avp64/core.cpp similarity index 58% rename from src/arm64_cpu.cpp rename to src/avp64/core.cpp index ad7638f..c34333b 100644 --- a/src/arm64_cpu.cpp +++ b/src/avp64/core.cpp @@ -1,13 +1,13 @@ /****************************************************************************** * * - * Copyright 2020 Lukas Jünger * + * Copyright 2024 Lukas Jünger, Nils Bosbach * * * * This software is licensed under the MIT license found in the * * LICENSE file at the root directory of this source tree. * * * ******************************************************************************/ -#include "avp64/arm64_cpu.h" +#include "avp64/core.h" #include #include @@ -22,94 +22,121 @@ memory_protector::memory_protector(): m_protected_pages() { sa.sa_flags = SA_SIGINFO; ::sigemptyset(&sa.sa_mask); sa.sa_sigaction = segfault_handler; - VCML_ERROR_ON(::sigaction(SIGSEGV, &sa, NULL) != 0, "sigaction: %s", + VCML_ERROR_ON(::sigaction(SIGSEGV, &sa, &m_sa_orig) != 0, "sigaction: %s", std::strerror(errno)); } -void memory_protector::segfault_handler(int sig, siginfo_t* si, void* unused) { +memory_protector::~memory_protector() { + VCML_ERROR_ON(::sigaction(SIGSEGV, &m_sa_orig, nullptr) != 0, + "sigaction: %s", std::strerror(errno)); +} + +void memory_protector::segfault_handler(int sig, siginfo_t* si, void* arg) { VCML_ERROR_ON(sig != SIGSEGV, "unexpected signal"); - memory_protector::get_instance().notify_page(si->si_addr); + get_instance().segfault_handler_int(sig, si, arg); +} + +void memory_protector::segfault_handler_int(int sig, siginfo_t* si, + void* arg) { + if (!memory_protector::get_instance().notify_page(si->si_addr)) { + m_sa_orig.sa_sigaction(sig, si, arg); + } } -void memory_protector::register_page(arm64_cpu* cpu, vcml::u64 page_addr, +void memory_protector::register_page(core* core, vcml::u64 page_addr, void* host_addr) { - VCML_ERROR_ON(::mprotect(host_addr, 4096, PROT_READ) != 0, "mprotect: %s", - std::strerror(errno)); - m_protected_pages.insert( - { reinterpret_cast(host_addr), { cpu, page_addr } }); + auto it = m_protected_pages.find(reinterpret_cast(host_addr)); + if (it != m_protected_pages.end()) { + if (it->second.locked) { + if (it->second.page_addr != page_addr) { + vcml::log_error("page_addr do not match! %llu vs. %llu", + it->second.page_addr, page_addr); + } + return; + } else { + it->second.locked = true; + } + } else { + struct page_data& + pd = m_protected_pages[reinterpret_cast(host_addr)]; + pd.c = core; + pd.page_addr = page_addr; + pd.page_size = core->get_page_size(); + pd.locked = true; + } + VCML_ERROR_ON(::mprotect(host_addr, core->get_page_size(), PROT_READ) != 0, + "mprotect: %s", std::strerror(errno)); } -void memory_protector::notify_page(void* access_addr) { +bool memory_protector::notify_page(void* access_addr) { vcml::u64 host_page_addr = reinterpret_cast(access_addr) & (~0xfffull); - ::mprotect(reinterpret_cast(host_page_addr), 4096, - PROT_READ | PROT_WRITE); - try { - auto p = m_protected_pages.at(host_page_addr); - p.first->memory_protector_update(p.second); - } catch (std::out_of_range& e) { - VCML_ERROR("Page to notify not found"); + auto it = m_protected_pages.find(host_page_addr); + if (it == m_protected_pages.end()) { // not a locked page + return false; } + it->second.c->memory_protector_update(it->second.page_addr); + it->second.locked = false; + return ::mprotect(reinterpret_cast(host_page_addr), + it->second.page_size, PROT_READ | PROT_WRITE) == 0; } -ocx::u8* arm64_cpu::get_page_ptr_r(ocx::u64 page_paddr) { +ocx::u8* core::get_page_ptr_r(ocx::u64 page_paddr) { tlm::tlm_dmi dmi; vcml::u64 page_size = get_page_size(); if (insn.dmi_cache().lookup(page_paddr, page_size, tlm::TLM_READ_COMMAND, dmi)) { return dmi.get_dmi_ptr() + page_paddr - dmi.get_start_address(); - } else { - tlm::tlm_generic_payload tx; - tx.set_address(page_paddr); - tx.set_streaming_width(page_size); - tx.set_data_length(page_size); - tx.set_read(); - if (insn->get_direct_mem_ptr(tx, dmi)) { - insn.map_dmi(dmi); - return dmi.get_dmi_ptr() + page_paddr - dmi.get_start_address(); - } else { - return nullptr; - } } + + tlm::tlm_generic_payload tx; + tx.set_address(page_paddr); + tx.set_streaming_width(page_size); + tx.set_data_length(page_size); + tx.set_read(); + if (insn->get_direct_mem_ptr(tx, dmi)) { + insn.map_dmi(dmi); + return dmi.get_dmi_ptr() + page_paddr - dmi.get_start_address(); + } + return nullptr; } -ocx::u8* arm64_cpu::get_page_ptr_w(ocx::u64 page_paddr) { +ocx::u8* core::get_page_ptr_w(ocx::u64 page_paddr) { tlm::tlm_dmi dmi; vcml::u64 page_size = get_page_size(); if (insn.dmi_cache().lookup(page_paddr, page_size, tlm::TLM_WRITE_COMMAND, dmi)) { return dmi.get_dmi_ptr() + page_paddr - dmi.get_start_address(); - } else { - tlm::tlm_generic_payload tx; - tx.set_address(page_paddr); - tx.set_streaming_width(page_size); - tx.set_data_length(page_size); - tx.set_write(); - if (insn->get_direct_mem_ptr(tx, dmi)) { - insn.map_dmi(dmi); - return dmi.get_dmi_ptr() + page_paddr - dmi.get_start_address(); - } else { - return nullptr; - } } + + tlm::tlm_generic_payload tx; + tx.set_address(page_paddr); + tx.set_streaming_width(page_size); + tx.set_data_length(page_size); + tx.set_write(); + if (insn->get_direct_mem_ptr(tx, dmi)) { + insn.map_dmi(dmi); + return dmi.get_dmi_ptr() + page_paddr - dmi.get_start_address(); + } + return nullptr; } -void arm64_cpu::protect_page(ocx::u8* page_ptr, ocx::u64 page_addr) { +void core::protect_page(ocx::u8* page_ptr, ocx::u64 page_addr) { memory_protector::get_instance().register_page(this, page_addr, page_ptr); } -ocx::response arm64_cpu::transport(const ocx::transaction& tx) { +ocx::response core::transport(const ocx::transaction& tx) { vcml::tlm_sbi info = vcml::SBI_NONE; if (tx.is_debug) info |= vcml::SBI_DEBUG; if (tx.is_excl) info |= vcml::SBI_EXCL; - info.cpuid = get_core_id(); + info.cpuid = core_id(); tlm::tlm_response_status resp = tlm::TLM_GENERIC_ERROR_RESPONSE; - if (tx.is_read) - resp = data.read(tx.addr, tx.data, tx.size, info); - else - resp = data.write(tx.addr, tx.data, tx.size, info); + + resp = tx.is_read ? data.read(tx.addr, tx.data, tx.size, info) + : data.write(tx.addr, tx.data, tx.size, info); + switch (resp) { case tlm::TLM_OK_RESPONSE: return ocx::RESP_OK; @@ -123,29 +150,53 @@ ocx::response arm64_cpu::transport(const ocx::transaction& tx) { case tlm::TLM_BURST_ERROR_RESPONSE: case tlm::TLM_BYTE_ENABLE_ERROR_RESPONSE: default: - vcml::log_info("Unexpected TLM transport response."); + log_info("Unexpected TLM transport response."); return ocx::RESP_FAILED; } } -void arm64_cpu::signal(ocx::u64 sigid, bool set) { - timer_irq_out[sigid] = set; +void core::log_timing_info() const { + vcml::log_info("core %llu", m_core_id); + vcml::log_info(" clock speed : %.1f MHz", clk.read() / 1e6); + vcml::log_info(" sim speed : %.1f MIPS", get_cps() / 1e6); + vcml::log_info(" run time : %.1fs", get_run_time()); + vcml::log_info(" cycles : %llu", cycle_count()); + + for (auto i : irq) { + vcml::irq_stats stats; + if (!get_irq_stats(i.first, stats) || stats.irq_count == 0) + continue; + + std::string s; + s += vcml::mkstr(" irq %lu status :", stats.irq); + s += vcml::mkstr(" %lu#", stats.irq_count); + s += vcml::mkstr(", avg %.1fus", stats.irq_uptime.to_seconds() / + stats.irq_count * 1e6); + s += vcml::mkstr(", max %.1fus", stats.irq_longest.to_seconds() * 1e6); + vcml::log_info("%s", s.c_str()); + } } -void arm64_cpu::broadcast_syscall(int callno, std::shared_ptr arg, - bool async) { +void core::signal(ocx::u64 sigid, bool set) { + if (timer_irq_out[sigid] != set) { + timer_irq_out[sigid] = set; + } +} + +void core::broadcast_syscall(int callno, std::shared_ptr arg, + bool async) { handle_syscall(callno, arg); for (auto const& cpu : m_syscall_subscriber) { cpu->handle_syscall(callno, arg); } } -ocx::u64 arm64_cpu::get_time_ps() { +ocx::u64 core::get_time_ps() { return sc_core::sc_time_stamp().value() / sc_core::sc_time(1, sc_core::SC_PS).value(); } -const char* arm64_cpu::get_param(const char* name) { +const char* core::get_param(const char* name) { if (strcmp("gicv3", name) == 0) return "false"; else if (strcmp("tbsize", name) == 0) @@ -154,17 +205,17 @@ const char* arm64_cpu::get_param(const char* name) { VCML_ERROR("Unimplemented parameter requested"); } -void arm64_cpu::notify(ocx::u64 eventid, ocx::u64 time_ps) { - sc_core::sc_time notify_time(time_ps, sc_core::SC_PS); +void core::notify(ocx::u64 eventid, ocx::u64 time_ps) { + sc_core::sc_time notify_time = vcml::time_from_value(time_ps); sc_core::sc_time delta = notify_time - sc_core::sc_time_stamp(); timer_events[eventid]->notify(delta); } -void arm64_cpu::cancel(ocx::u64 eventid) { +void core::cancel(ocx::u64 eventid) { timer_events[eventid]->cancel(); } -void arm64_cpu::hint(ocx::hint_kind kind) { +void core::hint(ocx::hint_kind kind) { switch (kind) { case ocx::HINT_WFI: { sync(); @@ -172,12 +223,13 @@ void arm64_cpu::hint(ocx::hint_kind kind) { for (auto it : irq) { list |= it.second->default_event(); // Treat WFI as NOP if IRQ is pending - if (it.second->read()) + if (it.second->read()) { return; + } } const sc_core::sc_time before_wait = sc_core::sc_time_stamp(); sc_core::wait(list); - VCML_ERROR_ON(local_time_stamp() != sc_core::sc_time_stamp(), + VCML_ERROR_ON(local_time() != sc_core::SC_ZERO_TIME, "core not synchronized"); const vcml::u64 cycles = (sc_core::sc_time_stamp() - before_wait) / clock_cycle(); @@ -191,17 +243,17 @@ void arm64_cpu::hint(ocx::hint_kind kind) { } } -void arm64_cpu::handle_begin_basic_block(ocx::u64 vaddr) { +void core::handle_begin_basic_block(ocx::u64 vaddr) { throw std::logic_error("Not implemented"); } -bool arm64_cpu::handle_breakpoint(ocx::u64 vaddr) { +bool core::handle_breakpoint(ocx::u64 vaddr) { notify_breakpoint_hit(vaddr); return true; } -bool arm64_cpu::handle_watchpoint(ocx::u64 vaddr, ocx::u64 size, ocx::u64 data, - bool iswr) { +bool core::handle_watchpoint(ocx::u64 vaddr, ocx::u64 size, ocx::u64 data, + bool iswr) { const vcml::range range(vaddr, vaddr + size); if (iswr) @@ -211,11 +263,11 @@ bool arm64_cpu::handle_watchpoint(ocx::u64 vaddr, ocx::u64 size, ocx::u64 data, return true; } -void arm64_cpu::add_syscall_subscriber(const std::shared_ptr& cpu) { +void core::add_syscall_subscriber(const std::shared_ptr& cpu) { m_syscall_subscriber.push_back(cpu); } -void arm64_cpu::memory_protector_update(vcml::u64 page_addr) { +void core::memory_protector_update(vcml::u64 page_addr) { m_core->tb_flush_page(page_addr, page_addr + 4095); m_core->invalidate_page_ptr(page_addr); for (auto const& cpu : m_syscall_subscriber) { @@ -224,52 +276,51 @@ void arm64_cpu::memory_protector_update(vcml::u64 page_addr) { } } -void arm64_cpu::timer_irq_trigger(int timer_id) { +void core::timer_irq_trigger(int timer_id) { m_core->notified(timer_id); } -void arm64_cpu::interrupt(size_t irq, bool set) { +void core::interrupt(size_t irq, bool set) { m_core->interrupt(irq, set); } -void arm64_cpu::simulate(size_t cycles) { - // insn_count() is only reset at the beginning of step(), but not at the - // end, so the number of cycles can only be summed up in the following - // quantum +void core::simulate(size_t cycles) { + // insn_count() is only reset at the beginning of step(), but not at + // the end, so the number of cycles can only be summed up in the + // following quantum m_run_cycles += m_core->insn_count(); m_core->step(cycles); } -bool arm64_cpu::read_reg_dbg(size_t regno, void* buf, size_t len) { +bool core::read_reg_dbg(size_t regno, void* buf, size_t len) { return m_core->read_reg(regno, buf); } -bool arm64_cpu::write_reg_dbg(size_t regno, const void* buf, size_t len) { +bool core::write_reg_dbg(size_t regno, const void* buf, size_t len) { return m_core->write_reg(regno, buf); } -bool arm64_cpu::page_size(vcml::u64& size) { +bool core::page_size(vcml::u64& size) { size = m_core->page_size(); return true; } -bool arm64_cpu::virt_to_phys(vcml::u64 vaddr, vcml::u64& paddr) { +bool core::virt_to_phys(vcml::u64 vaddr, vcml::u64& paddr) { ocx::u64 paddr_ocx = paddr; bool ret_val = m_core->virt_to_phys(vaddr, paddr_ocx); paddr = paddr_ocx; return ret_val; } -bool arm64_cpu::insert_breakpoint(vcml::u64 addr) { +bool core::insert_breakpoint(vcml::u64 addr) { return m_core->add_breakpoint(addr); } -bool arm64_cpu::remove_breakpoint(vcml::u64 addr) { +bool core::remove_breakpoint(vcml::u64 addr) { return m_core->remove_breakpoint(addr); } -bool arm64_cpu::insert_watchpoint(const vcml::range& mem, - vcml::vcml_access acs) { +bool core::insert_watchpoint(const vcml::range& mem, vcml::vcml_access acs) { switch (acs) { case vcml::vcml_access::VCML_ACCESS_READ: return m_core->add_watchpoint(mem.start, mem.length(), false); @@ -279,13 +330,12 @@ bool arm64_cpu::insert_watchpoint(const vcml::range& mem, return m_core->add_watchpoint(mem.start, mem.length(), true) && m_core->add_watchpoint(mem.start, mem.length(), false); default: - vcml::log_error("Unsupported watchpoint"); + log_error("Unsupported watchpoint"); return false; } } -bool arm64_cpu::remove_watchpoint(const vcml::range& mem, - vcml::vcml_access acs) { +bool core::remove_watchpoint(const vcml::range& mem, vcml::vcml_access acs) { switch (acs) { case vcml::vcml_access::VCML_ACCESS_READ: return m_core->remove_watchpoint(mem.start, mem.length(), false); @@ -295,17 +345,17 @@ bool arm64_cpu::remove_watchpoint(const vcml::range& mem, return m_core->remove_watchpoint(mem.start, mem.length(), true) && m_core->remove_watchpoint(mem.start, mem.length(), false); default: - vcml::log_error("Unsupported watchpoint"); + log_error("Unsupported watchpoint"); return false; } } -vcml::u64 arm64_cpu::cycle_count() const { +vcml::u64 core::cycle_count() const { return m_run_cycles + m_core->insn_count(); } -void arm64_cpu::update_local_time(sc_core::sc_time& local_time, - sc_core::sc_process_b* proc) { +void core::update_local_time(sc_core::sc_time& local_time, + sc_core::sc_process_b* proc) { if (is_local_process(proc)) { vcml::u64 cycles = cycle_count() + m_sleep_cycles; VCML_ERROR_ON(cycles < m_total_cycles, "cycle count goes down"); @@ -314,12 +364,12 @@ void arm64_cpu::update_local_time(sc_core::sc_time& local_time, } } -bool arm64_cpu::disassemble(vcml::u8* ibuf, vcml::u64& addr, - std::string& code) { +bool core::disassemble(vcml::u8* ibuf, vcml::u64& addr, std::string& code) { size_t bufsz = 100; char buf[bufsz]; + vcml::u64 len; + len = m_core->disassemble(addr, buf, bufsz); - vcml::u64 len = m_core->disassemble(addr, buf, bufsz); if (len == 0) { return false; } @@ -329,7 +379,7 @@ bool arm64_cpu::disassemble(vcml::u8* ibuf, vcml::u64& addr, return true; } -vcml::u64 arm64_cpu::program_counter() { +vcml::u64 core::program_counter() { ocx::u64 pc_regid = m_core->pc_regid(); vcml::u64 pc = 0; if (m_core->read_reg(pc_regid, &pc)) { @@ -339,7 +389,7 @@ vcml::u64 arm64_cpu::program_counter() { } } -vcml::u64 arm64_cpu::stack_pointer() { +vcml::u64 core::stack_pointer() { ocx::u64 sp_regid = m_core->sp_regid(); vcml::u64 sp = 0; if (m_core->read_reg(sp_regid, &sp)) { @@ -349,19 +399,19 @@ vcml::u64 arm64_cpu::stack_pointer() { } } -vcml::u64 arm64_cpu::get_core_id() { +vcml::u64 core::core_id() { return m_core_id; } -void arm64_cpu::handle_syscall(int callno, std::shared_ptr arg) { +void core::handle_syscall(int callno, std::shared_ptr arg) { m_core->handle_syscall(callno, std::move(arg)); } -vcml::u64 arm64_cpu::get_page_size() { +vcml::u64 core::get_page_size() { return m_core->page_size(); } -void arm64_cpu::end_of_elaboration() { +void core::end_of_elaboration() { for (auto it = timer_events.begin(); it != timer_events.end(); ++it) { std::unique_ptr opts( new sc_core::sc_spawn_options()); @@ -371,15 +421,15 @@ void arm64_cpu::end_of_elaboration() { std::stringstream ss; ss << (*it)->basename() << "_trigger"; int index = std::distance(timer_events.begin(), it); - sc_core::sc_spawn(sc_bind(&arm64_cpu::timer_irq_trigger, this, index), + sc_core::sc_spawn(sc_bind(&core::timer_irq_trigger, this, index), sc_core::sc_gen_unique_name(ss.str().c_str()), opts.get()); } vcml::processor::end_of_elaboration(); } -arm64_cpu::arm64_cpu(const sc_core::sc_module_name& nm, vcml::u64 procid, - vcml::u64 coreid): +core::core(const sc_core::sc_module_name& nm, vcml::u64 procid, + vcml::u64 coreid): vcml::processor(nm, CPU_ARCH), m_core(nullptr), m_core_id(coreid), @@ -387,8 +437,14 @@ arm64_cpu::arm64_cpu(const sc_core::sc_module_name& nm, vcml::u64 procid, m_sleep_cycles(0), m_total_cycles(0), m_syscall_subscriber(), + m_update_mem(), + m_syscalls(), timer_irq_out("TIMER_IRQ_OUT"), timer_events(4) { + symbols.inherit_default(); + async.inherit_default(); + async_rate.inherit_default(); + m_ocx_handle = dlopen("libocx-qemu-arm.so", RTLD_LAZY); if (!m_ocx_handle) VCML_ERROR("Could not load libocx-qemu-arm.so: %s", dlerror()); @@ -436,17 +492,17 @@ arm64_cpu::arm64_cpu(const sc_core::sc_module_name& nm, vcml::u64 procid, m_core->set_id(procid, coreid); data.set_cpuid(m_core_id); insn.set_cpuid(m_core_id); - timer_events[ARM_TIMER_PHYS] = std::shared_ptr( - new sc_core::sc_event("arm_timer_ns")); - timer_events[ARM_TIMER_VIRT] = std::shared_ptr( - new sc_core::sc_event("arm_timer_virt")); - timer_events[ARM_TIMER_HYP] = std::shared_ptr( - new sc_core::sc_event("arm_timer_hyp")); - timer_events[ARM_TIMER_SEC] = std::shared_ptr( - new sc_core::sc_event("arm_timer_s")); + timer_events[ARM_TIMER_PHYS] = std::make_shared( + "arm_timer_ns"); + timer_events[ARM_TIMER_VIRT] = std::make_shared( + "arm_timer_virt"); + timer_events[ARM_TIMER_HYP] = std::make_shared( + "arm_timer_hyp"); + timer_events[ARM_TIMER_SEC] = std::make_shared( + "arm_timer_s"); } -arm64_cpu::~arm64_cpu() { +core::~core() { dlclose(m_ocx_handle); } diff --git a/src/avp64/cpu.cpp b/src/avp64/cpu.cpp new file mode 100644 index 0000000..4c8905a --- /dev/null +++ b/src/avp64/cpu.cpp @@ -0,0 +1,142 @@ +/****************************************************************************** + * * + * Copyright 2024 Lukas Jünger, Nils Bosbach * + * * + * This software is licensed under the MIT license found in the * + * LICENSE file at the root directory of this source tree. * + * * + ******************************************************************************/ + +#include "avp64/cpu.h" +#include "avp64/version.h" + +namespace avp64 { + +cpu::cpu(const sc_core::sc_module_name& nm): + vcml::component(nm), + ncores("ncores", 1), + clusterid("clusterid", 0), + symbols("symbols", ""), + async("async", false), + async_rate("async_rate", 10), + gic_cpuif("addr_gic_cpuif", { GIC_CPUIF_LO, GIC_CPUIF_HI }), + gic_distif("addr_gic_distif", { GIC_DISTIF_LO, GIC_DISTIF_HI }), + gic_vifctrl("addr_gic_vifctrl", { GIC_VIFCTRL_LO, GIC_VIFCTRL_HI }), + gic_vcpuif("addr_gic_vcpuif", { GIC_VCPUIF_LO, GIC_VCPUIF_HI }), + irq_gt_hyp("irq_gt_hyp", PPI_GT_HYP), + irq_gt_virt("irq_gt_virt", PPI_GT_VIRT), + irq_gt_ns("irq_gt_ns", PPI_GT_NS), + irq_gt_s("irq_gt_s", PPI_GT_S), + gdb_wait("gdb_wait", false), + gdb_echo("gdb_echo", false), + gdb_port("gdb_port", gdb_wait ? 0 : -1), + bus("bus"), + spi("spi"), + m_cores(), + m_gic("gic"), + m_corebus("corebus"), + m_gdb(nullptr) { + m_cores.resize(ncores); + + // initialize cores and bind interrupts + for (size_t id = 0; id < ncores; ++id) { + auto nm = vcml::mkstr("arm%zu", id); + m_cores[id] = std::make_shared(nm.c_str(), clusterid, id); + + m_cores[id]->irq[INTERRUPT_IRQ].bind(m_gic.irq_out[id]); + m_cores[id]->irq[INTERRUPT_FIQ].bind(m_gic.fiq_out[id]); + m_cores[id]->irq[INTERRUPT_VIRQ].bind(m_gic.virq_out[id]); + m_cores[id]->irq[INTERRUPT_VFIQ].bind(m_gic.vfiq_out[id]); + + m_cores[id]->timer_irq_out[ARM_TIMER_PHYS].bind( + m_gic.ppi(id, irq_gt_ns)); + m_cores[id]->timer_irq_out[ARM_TIMER_VIRT].bind( + m_gic.ppi(id, irq_gt_virt)); + m_cores[id]->timer_irq_out[ARM_TIMER_HYP].bind( + m_gic.ppi(id, irq_gt_hyp)); + m_cores[id]->timer_irq_out[ARM_TIMER_SEC].bind( + m_gic.ppi(id, irq_gt_s)); + + for (size_t core = 0; core < id; ++core) { + m_cores[core]->add_syscall_subscriber(m_cores[id]); + m_cores[id]->add_syscall_subscriber(m_cores[core]); + } + + m_corebus.bind(m_cores[id]->data); + m_corebus.bind(m_cores[id]->insn); + + clk.bind(m_cores[id]->clk); + rst.bind(m_cores[id]->rst); + } + + m_corebus.bind(m_gic.cpuif.in, gic_cpuif); + m_corebus.bind(m_gic.distif.in, gic_distif); + m_corebus.bind(m_gic.vifctrl.in, gic_vifctrl); + m_corebus.bind(m_gic.vcpuif.in, gic_vcpuif); + + m_corebus.bind_default(bus); + + clk.bind(m_corebus.clk); + clk.bind(m_gic.clk); + + rst.bind(m_corebus.rst); + rst.bind(m_gic.rst); +} + +void cpu::before_end_of_elaboration() { + vcml::component::before_end_of_elaboration(); + + for (auto [idx, port] : spi) { + log_debug("binding spi %zu to gic", idx); + port->bind(m_gic.spi_in[idx]); + } +} + +void cpu::end_of_elaboration() { + component::end_of_elaboration(); + + if (gdb_port >= 0) { + auto run = gdb_wait ? vcml::debugging::GDB_STOPPED + : vcml::debugging::GDB_RUNNING; + std::vector tgts; + + tgts.reserve(m_cores.size()); + for (const auto& c : m_cores) + tgts.push_back(c.get()); + + m_gdb = std::make_shared(gdb_port, tgts, + run); + m_gdb->echo(gdb_echo); + + if (gdb_port == 0) + gdb_port = m_gdb->port(); + + log_info("%s for GDB connection on port %hu", + gdb_wait ? "waiting" : "listening", m_gdb->port()); + } +} + +void cpu::end_of_simulation() { + for (const auto& c : m_cores) + c->log_timing_info(); + vcml::log_info("total - cluster %zu", clusterid.get()); + vcml::log_info(" instructions : %llu", cycle_count()); +} + +vcml::u64 cpu::cycle_count() const { + vcml::u64 total_insn = 0; + for (const auto& c : m_cores) { + total_insn += c->cycle_count(); + } + return total_insn; +} + +const char* cpu::version() const { + return AVP64_VERSION_STRING; +} + +VCML_EXPORT_MODEL(avp64::cpu, name, args) { + return new avp64::cpu(name); +} + +} // namespace avp64 diff --git a/src/main.cpp b/src/avp64/main.cpp similarity index 91% rename from src/main.cpp rename to src/avp64/main.cpp index 97cd901..e928e0a 100644 --- a/src/main.cpp +++ b/src/avp64/main.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * * - * Copyright 2020 Lukas Jünger * + * Copyright 2024 Lukas Jünger, Nils Bosbach * * * * This software is licensed under the MIT license found in the * * LICENSE file at the root directory of this source tree. * @@ -12,4 +12,4 @@ extern "C" int sc_main(int argc, char** argv) { avp64::system system("system"); return system.run(); -} \ No newline at end of file +} diff --git a/src/avp64/system.cpp b/src/avp64/system.cpp new file mode 100644 index 0000000..3eca162 --- /dev/null +++ b/src/avp64/system.cpp @@ -0,0 +1,177 @@ +/****************************************************************************** + * * + * Copyright 2024 Lukas Jünger, Nils Bosbach * + * * + * This software is licensed under the MIT license found in the * + * LICENSE file at the root directory of this source tree. * + * * + ******************************************************************************/ + +#include "avp64/system.h" +#include "avp64/version.h" + +namespace avp64 { + +void system::construct_system_arm64() { + clk_bind(m_clock_cpu, "clk", m_bus, "clk"); + clk_bind(m_clock_cpu, "clk", m_ram, "clk"); + clk_bind(m_clock_cpu, "clk", m_uart0, "clk"); + clk_bind(m_clock_cpu, "clk", m_uart1, "clk"); + clk_bind(m_clock_cpu, "clk", m_uart2, "clk"); + clk_bind(m_clock_cpu, "clk", m_uart3, "clk"); + clk_bind(m_clock_cpu, "clk", m_lan0, "clk"); + clk_bind(m_clock_cpu, "clk", m_sdhci, "clk"); + clk_bind(m_clock_cpu, "clk", m_sdcard, "clk"); + clk_bind(m_clock_cpu, "clk", m_simdev, "clk"); + clk_bind(m_clock_cpu, "clk", m_hwrng, "clk"); + clk_bind(m_clock_cpu, "clk", m_spi, "clk"); + clk_bind(m_clock_cpu, "clk", m_gpio, "clk"); + clk_bind(m_clock_cpu, "clk", m_rtc, "clk"); + clk_bind(m_clock_cpu, "clk", m_cpu, "clk"); + + gpio_bind(m_reset, "rst", m_bus, "rst"); + gpio_bind(m_reset, "rst", m_ram, "rst"); + gpio_bind(m_reset, "rst", m_uart0, "rst"); + gpio_bind(m_reset, "rst", m_uart1, "rst"); + gpio_bind(m_reset, "rst", m_uart2, "rst"); + gpio_bind(m_reset, "rst", m_uart3, "rst"); + gpio_bind(m_reset, "rst", m_lan0, "rst"); + gpio_bind(m_reset, "rst", m_sdhci, "rst"); + gpio_bind(m_reset, "rst", m_sdcard, "rst"); + gpio_bind(m_reset, "rst", m_simdev, "rst"); + gpio_bind(m_reset, "rst", m_hwrng, "rst"); + gpio_bind(m_reset, "rst", m_spi, "rst"); + gpio_bind(m_reset, "rst", m_gpio, "rst"); + gpio_bind(m_reset, "rst", m_rtc, "rst"); + gpio_bind(m_reset, "rst", m_cpu, "rst"); + + tlm_bind(m_bus, m_cpu, "bus"); + tlm_bind(m_bus, m_ram, "in", addr_ram); + tlm_bind(m_bus, m_uart0, "in", addr_uart0); + tlm_bind(m_bus, m_uart1, "in", addr_uart1); + tlm_bind(m_bus, m_uart2, "in", addr_uart2); + tlm_bind(m_bus, m_uart3, "in", addr_uart3); + tlm_bind(m_bus, m_lan0, "in", addr_lan0); + tlm_bind(m_bus, m_sdhci, "in", addr_sdhci); + tlm_bind(m_bus, m_sdhci, "out"); + tlm_bind(m_bus, m_simdev, "in", addr_simdev); + tlm_bind(m_bus, m_hwrng, "in", addr_hwrng); + tlm_bind(m_bus, m_spi, "in", addr_spi); + tlm_bind(m_bus, m_gpio, "in", addr_gpio); + tlm_bind(m_bus, m_rtc, "in", addr_rtc); + + // Connect network to eth + eth_bind(m_net, "eth_tx", 0, m_lan0, "eth_rx"); + eth_bind(m_net, "eth_rx", 0, m_lan0, "eth_tx"); + eth_bind(m_net, "eth_tx", 1, m_bridge, "eth_rx"); + eth_bind(m_net, "eth_rx", 1, m_bridge, "eth_tx"); + + // Connect terminals to uarts + serial_bind(m_term0, "serial_tx", m_uart0, "serial_rx"); + serial_bind(m_term0, "serial_rx", m_uart0, "serial_tx"); + serial_bind(m_term1, "serial_tx", m_uart1, "serial_rx"); + serial_bind(m_term1, "serial_rx", m_uart1, "serial_tx"); + serial_bind(m_term2, "serial_tx", m_uart2, "serial_rx"); + serial_bind(m_term2, "serial_rx", m_uart2, "serial_tx"); + serial_bind(m_term3, "serial_tx", m_uart3, "serial_rx"); + serial_bind(m_term3, "serial_rx", m_uart3, "serial_tx"); + + // Connect SD card to SDHCI + sd_bind(m_sdhci, "sd_out", m_sdcard, "sd_in"); + + // Connect SPI devices to SPI controller + spi_bind(m_spi, "spi_out", m_max31855, "spi_in"); + m_max31855.bind(m_gpio.gpio_out[0], + false); // active low CS forced by Linux kernel + + // IRQs + gpio_bind(m_uart0, "irq", m_cpu, "spi", irq_uart0); + gpio_bind(m_uart1, "irq", m_cpu, "spi", irq_uart1); + gpio_bind(m_uart2, "irq", m_cpu, "spi", irq_uart2); + gpio_bind(m_uart3, "irq", m_cpu, "spi", irq_uart3); + gpio_bind(m_lan0, "irq", m_cpu, "spi", irq_lan0); + gpio_bind(m_sdhci, "irq", m_cpu, "spi", irq_sdhci); + gpio_bind(m_spi, "irq", m_cpu, "spi", irq_spi); +} + +system::system(const sc_core::sc_module_name& nm): + vcml::system(nm), + addr_ram("addr_ram", { RAM_LO, RAM_HI }), + addr_uart0("addr_uart0", { UART0_LO, UART0_HI }), + addr_uart1("addr_uart1", { UART1_LO, UART1_HI }), + addr_uart2("addr_uart2", { UART2_LO, UART2_HI }), + addr_uart3("addr_uart3", { UART3_LO, UART3_HI }), + addr_rtc("addr_rtc", { RTC_LO, RTC_HI }), + addr_lan0("addr_lan0", { LAN0_LO, LAN0_HI }), + addr_sdhci("addr_sdhci", { SDHCI_LO, SDHCI_HI }), + addr_simdev("addr_simdev", { SIMDEV_LO, SIMDEV_HI }), + addr_hwrng("addr_hwrng", { HWRNG_LO, HWRNG_HI }), + addr_spi("addr_spi", { SPI_LO, SPI_HI }), + addr_gpio("addr_gpio", { GPIO_LO, GPIO_HI }), + irq_uart0("irq_uart0", SPI_UART0), + irq_uart1("irq_uart1", SPI_UART1), + irq_uart2("irq_uart2", SPI_UART2), + irq_uart3("irq_uart3", SPI_UART3), + irq_lan0("irq_lan0", SPI_LAN0), + irq_sdhci("irq_sdhci", SPI_SDHCI), + irq_spi("irq_spi", SPI_SPI), + m_clock_cpu("clock_cpu", 1 * mwr::GHz), + m_reset("reset"), + m_throttle("throttle"), + m_bus("bus"), + m_ram("ram", addr_ram.get().length()), + m_uart0("uart0"), + m_uart1("uart1"), + m_uart2("uart2"), + m_uart3("uart3"), + m_term0("term0"), + m_term1("term1"), + m_term2("term2"), + m_term3("term3"), + m_lan0("lan0"), + m_net("net"), + m_bridge("bridge"), + m_sdcard("sdcard"), + m_sdhci("sdhci"), + m_simdev("simdev"), + m_hwrng("hwrng"), + m_spi("spi"), + m_gpio("gpio"), + m_max31855("max31855"), + m_rtc("rtc"), + m_cpu("cpu") { + construct_system_arm64(); +} + +int system::run() { + double simstart = mwr::timestamp(); + int result = vcml::system::run(); + double realtime = mwr::timestamp() - simstart; + double duration = sc_core::sc_time_stamp().to_seconds(); + vcml::u64 ninsn = m_cpu.cycle_count(); + + double mips = realtime == 0.0 ? 0.0 : ninsn / realtime / 1e6; + vcml::log_info("total"); + vcml::log_info(" duration : %.9fs", duration); + vcml::log_info(" runtime : %.4fs", realtime); + vcml::log_info(" instructions : %llu", ninsn); + vcml::log_info(" sim speed : %.1f MIPS", mips); + vcml::log_info(" realtime ratio : %.2f / 1s", + realtime == 0.0 ? 0.0 : realtime / duration); + + return result; +} + +void system::end_of_elaboration() { + vcml::system::end_of_elaboration(); + + std::stringstream ss; + m_bus.execute("show", ss); + log_debug("%s", ss.str().c_str()); +} + +const char* system::version() const { + return AVP64_VERSION_STRING; +} + +} // namespace avp64 diff --git a/include/avp64/system.h b/src/avp64/system.h similarity index 63% rename from include/avp64/system.h rename to src/avp64/system.h index d9fc509..5317403 100644 --- a/include/avp64/system.h +++ b/src/avp64/system.h @@ -1,6 +1,6 @@ /****************************************************************************** * * - * Copyright 2020 Lukas Jünger * + * Copyright 2024 Lukas Jünger, Nils Bosbach * * * * This software is licensed under the MIT license found in the * * LICENSE file at the root directory of this source tree. * @@ -11,26 +11,69 @@ #define AVP64_SYSTEM_H #include "vcml.h" -#include "avp64/arm64_cpu.h" +#include "avp64.h" namespace avp64 { +enum : mwr::u64 { + RAM_LO = 0x00000000, + RAM_HI = RAM_LO + 0x10000000 - 1, + + HWRNG_LO = 0x10007000, + HWRNG_HI = HWRNG_LO + 0x1000 - 1, + + SIMDEV_LO = 0x10008000, + SIMDEV_HI = SIMDEV_LO + 0x1000 - 1, + + UART0_LO = 0x10009000, + UART0_HI = UART0_LO + 0x1000 - 1, + + UART1_LO = 0x1000a000, + UART1_HI = UART1_LO + 0x1000 - 1, + + UART2_LO = 0x1000b000, + UART2_HI = UART2_LO + 0x1000 - 1, + + UART3_LO = 0x1000c000, + UART3_HI = UART3_LO + 0x1000 - 1, + + SDHCI_LO = 0x1000d000, + SDHCI_HI = SDHCI_LO + 0x1000 - 1, + + RTC_LO = 0x1000e000, + RTC_HI = RTC_LO + 0x1000 - 1, + + GPIO_LO = 0x1000f000, + GPIO_HI = GPIO_LO + 0x1000 - 1, + + LAN0_LO = 0x10010000, + LAN0_HI = LAN0_LO + 0x10000 - 1, + + SPI_LO = 0x10020000, + SPI_HI = SPI_LO + 0x1000 - 1, +}; + +enum : mwr::u64 { + SPI_UART0 = 5, + SPI_UART1 = 6, + SPI_UART2 = 7, + SPI_UART3 = 8, + SPI_LAN0 = 9, + SPI_SDHCI = 10, + SPI_SPI = 11, +}; + class system : public vcml::system { public: // properties - vcml::property nrcpu; - vcml::property addr_ram; - vcml::property addr_gic_cpuif; - vcml::property addr_gic_distif; - vcml::property addr_gic_vifctrl; - vcml::property addr_gic_vcpuif; vcml::property addr_uart0; vcml::property addr_uart1; vcml::property addr_uart2; vcml::property addr_uart3; - vcml::property addr_ethoc; + vcml::property addr_rtc; + vcml::property addr_lan0; vcml::property addr_sdhci; vcml::property addr_simdev; vcml::property addr_hwrng; @@ -41,12 +84,8 @@ class system : public vcml::system vcml::property irq_uart1; vcml::property irq_uart2; vcml::property irq_uart3; - vcml::property irq_ethoc; + vcml::property irq_lan0; vcml::property irq_sdhci; - vcml::property irq_gt_hyp; - vcml::property irq_gt_virt; - vcml::property irq_gt_ns; - vcml::property irq_gt_s; vcml::property irq_spi; system(const sc_core::sc_module_name& name); @@ -58,15 +97,15 @@ class system : public vcml::system virtual void end_of_elaboration() override; -private: - std::vector> m_cpus; + const char* version() const override; - vcml::generic::clock m_clock; +private: + vcml::generic::clock m_clock_cpu; vcml::generic::reset m_reset; + vcml::meta::throttle m_throttle; vcml::generic::bus m_bus; vcml::generic::memory m_ram; - vcml::arm::gic400 m_gic; vcml::serial::pl011 m_uart0; vcml::serial::pl011 m_uart1; vcml::serial::pl011 m_uart2; @@ -75,7 +114,7 @@ class system : public vcml::system vcml::serial::terminal m_term1; vcml::serial::terminal m_term2; vcml::serial::terminal m_term3; - vcml::ethernet::ethoc m_ethoc; + vcml::ethernet::lan9118 m_lan0; vcml::ethernet::network m_net; vcml::ethernet::bridge m_bridge; vcml::sd::card m_sdcard; @@ -85,6 +124,9 @@ class system : public vcml::system vcml::spi::ocspi m_spi; vcml::generic::gpio m_gpio; vcml::spi::max31855 m_max31855; + vcml::timers::rtc1742 m_rtc; + + cpu m_cpu; void construct_system_arm64(); }; diff --git a/src/avp64/version.h.in b/src/avp64/version.h.in new file mode 100644 index 0000000..ed44d6c --- /dev/null +++ b/src/avp64/version.h.in @@ -0,0 +1,25 @@ +/****************************************************************************** + * * + * Copyright 2024 Lukas Jünger, Nils Bosbach * + * * + * This software is licensed under the MIT license found in the * + * LICENSE file at the root directory of this source tree. * + * * + ******************************************************************************/ + +#ifndef AVP64_VERSION_H +#define AVP64_VERSION_H + +#define AVP64_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define AVP64_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define AVP64_VERSION_PATCH @PROJECT_VERSION_PATCH@ + +#define AVP64_GIT_REV "@AVP64_GIT_REV@" +#define AVP64_GIT_REV_SHORT "@AVP64_GIT_REV_SHORT@" + +#define AVP64_VERSION @AVP64_VERSION_INT@ +#define AVP64_VERSION_STRING "@AVP64_VERSION_STRING@" + +#include + +#endif diff --git a/src/system.cpp b/src/system.cpp deleted file mode 100644 index aa0aeae..0000000 --- a/src/system.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/****************************************************************************** - * * - * Copyright 2020 Lukas Jünger * - * * - * This software is licensed under the MIT license found in the * - * LICENSE file at the root directory of this source tree. * - * * - ******************************************************************************/ - -#include -#include "avp64/system.h" -#include "avp64/config.h" -#include "mwr/core/utils.h" - -#define SAFE_DELETE(p) \ - do { \ - if (p) \ - delete (p); \ - (p) = NULL; \ - } while (0) - -#define AVP64_ARM64_CPU_IRQ (0) -#define AVP64_ARM64_CPU_FIQ (1) -#define AVP64_ARM64_CPU_VIRQ (2) -#define AVP64_ARM64_CPU_VFIQ (3) - -namespace avp64 { - -void system::construct_system_arm64() { - m_cpus.resize(nrcpu); - for (unsigned int cpu = 0; cpu < nrcpu; cpu++) { - std::stringstream ss; - ss << "arm" << cpu; - m_cpus[cpu] = std::make_shared(ss.str().c_str(), 0, cpu); - std::string irq_name("irq_" + ss.str()); - std::string fiq_name("fiq_" + ss.str()); - std::string virq_name("virq_" + ss.str()); - std::string vfiq_name("vfiq_" + ss.str()); - std::string irq_gt_hyp_name("irq_gt_hyp_" + ss.str()); - std::string irq_gt_virt_name("irq_gt_virt_" + ss.str()); - std::string irq_gt_ns_name("irq_gt_ns_" + ss.str()); - std::string irq_gt_s_name("irq_gt_s_" + ss.str()); - - m_cpus[cpu]->irq[AVP64_ARM64_CPU_IRQ].bind(m_gic.irq_out[cpu]); - m_cpus[cpu]->irq[AVP64_ARM64_CPU_FIQ].bind(m_gic.fiq_out[cpu]); - m_cpus[cpu]->irq[AVP64_ARM64_CPU_VIRQ].bind(m_gic.virq_out[cpu]); - m_cpus[cpu]->irq[AVP64_ARM64_CPU_VFIQ].bind(m_gic.vfiq_out[cpu]); - m_cpus[cpu]->timer_irq_out[avp64::ARM_TIMER_PHYS].bind( - m_gic.ppi_in[irq_gt_ns - 16 + (cpu * 16)]); - m_cpus[cpu]->timer_irq_out[avp64::ARM_TIMER_VIRT].bind( - m_gic.ppi_in[irq_gt_virt - 16 + (cpu * 16)]); - m_cpus[cpu]->timer_irq_out[avp64::ARM_TIMER_HYP].bind( - m_gic.ppi_in[irq_gt_hyp - 16 + (cpu * 16)]); - m_cpus[cpu]->timer_irq_out[avp64::ARM_TIMER_SEC].bind( - m_gic.ppi_in[irq_gt_s - 16 + (cpu * 16)]); - } - for (unsigned int cpu = 0; cpu < nrcpu; cpu++) { - for (unsigned int i = 0; i < nrcpu; i++) { - if (i == cpu) - continue; - else - m_cpus[i]->add_syscall_subscriber(m_cpus[cpu]); - } - } - - // Clock - for (const auto& cpu : m_cpus) { - m_clock.clk.bind(cpu->clk); - } - m_clock.clk.bind(m_bus.clk); - m_clock.clk.bind(m_ram.clk); - m_clock.clk.bind(m_gic.clk); - m_clock.clk.bind(m_uart0.clk); - m_clock.clk.bind(m_uart1.clk); - m_clock.clk.bind(m_uart2.clk); - m_clock.clk.bind(m_uart3.clk); - m_clock.clk.bind(m_ethoc.clk); - m_clock.clk.bind(m_sdcard.clk); - m_clock.clk.bind(m_sdhci.clk); - m_clock.clk.bind(m_simdev.clk); - m_clock.clk.bind(m_hwrng.clk); - m_clock.clk.bind(m_spi.clk); - m_clock.clk.bind(m_gpio.clk); - - // Reset - for (const auto& cpu : m_cpus) { - m_reset.rst.bind(cpu->rst); - } - m_reset.rst.bind(m_bus.rst); - m_reset.rst.bind(m_ram.rst); - m_reset.rst.bind(m_gic.rst); - m_reset.rst.bind(m_uart0.rst); - m_reset.rst.bind(m_uart1.rst); - m_reset.rst.bind(m_uart2.rst); - m_reset.rst.bind(m_uart3.rst); - m_reset.rst.bind(m_ethoc.rst); - m_reset.rst.bind(m_sdcard.rst); - m_reset.rst.bind(m_sdhci.rst); - m_reset.rst.bind(m_simdev.rst); - m_reset.rst.bind(m_hwrng.rst); - m_reset.rst.bind(m_spi.rst); - m_reset.rst.bind(m_gpio.rst); - - // Bus bindings - for (const auto& cpu : m_cpus) { - m_bus.bind(cpu->insn); - m_bus.bind(cpu->data); - } - m_bus.bind(m_ram.in, addr_ram); - m_bus.bind(m_uart0.in, addr_uart0); - m_bus.bind(m_uart1.in, addr_uart1); - m_bus.bind(m_uart2.in, addr_uart2); - m_bus.bind(m_uart3.in, addr_uart3); - m_bus.bind(m_ethoc.in, addr_ethoc.get()); - m_bus.bind(m_ethoc.out); - m_bus.bind(m_sdhci.in, addr_sdhci.get()); - m_bus.bind(m_sdhci.out); - m_bus.bind(m_gic.cpuif.in, addr_gic_cpuif); - m_bus.bind(m_gic.distif.in, addr_gic_distif); - m_bus.bind(m_gic.vifctrl.in, addr_gic_vifctrl); - m_bus.bind(m_gic.vcpuif.in, addr_gic_vcpuif); - m_bus.bind(m_simdev.in, addr_simdev); - m_bus.bind(m_hwrng.in, addr_hwrng); - m_bus.bind(m_spi.in, addr_spi); - m_bus.bind(m_gpio.in, addr_gpio); - - // Connect network to eth - m_net.connect(m_ethoc); - m_net.connect(m_bridge); - - // Connect terminals to uarts - m_term0.connect(m_uart0); - m_term1.connect(m_uart1); - m_term2.connect(m_uart2); - m_term3.connect(m_uart3); - - // Bind SDHCI and SDCARD - m_sdhci.sd_out.bind(m_sdcard.sd_in); - - m_spi.spi_out.bind(m_max31855.spi_in); - m_gpio.gpio_out[0].bind(m_max31855.cs); - - // IRQs - m_gic.spi_in[irq_uart0].bind(m_uart0.irq); - m_gic.spi_in[irq_uart1].bind(m_uart1.irq); - m_gic.spi_in[irq_uart2].bind(m_uart2.irq); - m_gic.spi_in[irq_uart3].bind(m_uart3.irq); - m_gic.spi_in[irq_ethoc].bind(m_ethoc.irq); - m_gic.spi_in[irq_sdhci].bind(m_sdhci.irq); - m_gic.spi_in[irq_spi].bind(m_spi.irq); -} - -system::system(const sc_core::sc_module_name& nm): - vcml::system(nm), - nrcpu("nrcpu", 1), - addr_ram("addr_ram", vcml::range(AVP64_RAM_ADDR, AVP64_RAM_HIGH)), - addr_gic_cpuif("addr_gic_cpuif", - vcml::range(AVP64_GIC_CPUIF_ADDR, AVP64_GIC_CPUIF_HIGH)), - addr_gic_distif("addr_gic_distif", - vcml::range(AVP64_GIC_DISTIF_ADDR, AVP64_GIC_DISTIF_HIGH)), - addr_gic_vifctrl("addr_gic_vifctrl", vcml::range(AVP64_GIC_VIFCTRL_ADDR, - AVP64_GIC_VIFCTRL_HIGH)), - addr_gic_vcpuif("addr_gic_vcpuif", - vcml::range(AVP64_GIC_VCPUIF_ADDR, AVP64_GIC_VCPUIF_HIGH)), - addr_uart0("addr_uart0", vcml::range(AVP64_UART0_ADDR, AVP64_UART0_HIGH)), - addr_uart1("addr_uart1", vcml::range(AVP64_UART1_ADDR, AVP64_UART1_HIGH)), - addr_uart2("addr_uart2", vcml::range(AVP64_UART2_ADDR, AVP64_UART2_HIGH)), - addr_uart3("addr_uart3", vcml::range(AVP64_UART3_ADDR, AVP64_UART3_HIGH)), - addr_ethoc("addr_ethoc", vcml::range(AVP64_ETHOC_ADDR, AVP64_ETHOC_HIGH)), - addr_sdhci("addr_sdhci", vcml::range(AVP64_SDHCI_ADDR, AVP64_SDHCI_HIGH)), - addr_simdev("addr_simdev", - vcml::range(AVP64_SIMDEV_ADDR, AVP64_SIMDEV_HIGH)), - addr_hwrng("addr_hwrng", vcml::range(AVP64_HWRNG_ADDR, AVP64_HWRNG_HIGH)), - addr_spi("addr_spi", vcml::range(AVP64_SPI_ADDR, AVP64_SPI_HIGH)), - addr_gpio("addr_gpio", vcml::range(AVP64_GPIO_ADDR, AVP64_GPIO_HIGH)), - irq_uart0("irq_uart0", AVP64_IRQ_UART0), - irq_uart1("irq_uart1", AVP64_IRQ_UART1), - irq_uart2("irq_uart2", AVP64_IRQ_UART2), - irq_uart3("irq_uart3", AVP64_IRQ_UART3), - irq_ethoc("irq_ethoc", AVP64_IRQ_ETHOC), - irq_sdhci("irq_sdhci", AVP64_IRQ_SDHCI), - irq_gt_hyp("irq_gt_hyp", AVP64_IRQ_GT_HYP), - irq_gt_virt("irq_gt_virt", AVP64_IRQ_GT_VIRT), - irq_gt_ns("irq_gt_ns", AVP64_IRQ_GT_NS), - irq_gt_s("irq_gt_s", AVP64_IRQ_GT_S), - irq_spi("irq_spi", AVP64_IRQ_SPI), - m_cpus(), - m_clock("clock", AVP64_CPU_DEFCLK), - m_reset("reset"), - m_bus("bus"), - m_ram("ram", addr_ram.get().length()), - m_gic("gic"), - m_uart0("uart0"), - m_uart1("uart1"), - m_uart2("uart2"), - m_uart3("uart3"), - m_term0("term0"), - m_term1("term1"), - m_term2("term2"), - m_term3("term3"), - m_ethoc("ethoc"), - m_net("net"), - m_bridge("bridge"), - m_sdcard("sdcard"), - m_sdhci("sdhci"), - m_simdev("simdev"), - m_hwrng("hwrng"), - m_spi("spi"), - m_gpio("gpio"), - m_max31855("max31855") { - construct_system_arm64(); -} - -int system::run() { - double simstart = mwr::timestamp(); - int result = vcml::system::run(); - double realtime = mwr::timestamp() - simstart; - double total_runtime = sc_core::sc_time_stamp().to_seconds(); - - uint64_t ninsn = 0; - for (unsigned int cpu = 0; cpu < nrcpu; cpu++) { - double mhz = m_cpus[cpu]->clk.read() * 1e-6; - double mips = m_cpus[cpu]->get_cps() * 1e-6; // approximated - double cpurt = m_cpus[cpu]->get_run_time(); - uint64_t cycles = m_cpus[cpu]->cycle_count(); - ninsn += cycles; - - vcml::log_info("core %d", cpu); - vcml::log_info(" clock speed : %.1f MHz", mhz); - vcml::log_info(" sim speed : %.1f MIPS", mips); - vcml::log_info(" run time : %.1fs", cpurt); - vcml::log_info(" cycles : %" PRId64, cycles); - - for (auto irq : m_cpus[cpu]->irq) { - vcml::irq_stats stats; - if (!m_cpus[cpu]->get_irq_stats(irq.first, stats) || - stats.irq_count == 0) - continue; - - std::string s; - s += vcml::mkstr(" irq %lu status :", stats.irq); - s += vcml::mkstr(" %lu#", stats.irq_count); - s += vcml::mkstr(", avg %.1fus", stats.irq_uptime.to_seconds() / - stats.irq_count * 1e6); - s += vcml::mkstr(", max %.1fus", - stats.irq_longest.to_seconds() * 1e6); - vcml::log_info("%s", s.c_str()); - } - } - - double mips = realtime == 0.0 ? 0.0 : ninsn / realtime / 1e6; - vcml::log_info("total"); - vcml::log_info(" duration : %.9fs", total_runtime); - vcml::log_info(" run time : %.4fs", realtime); - vcml::log_info(" instructions : %" PRId64, ninsn); - vcml::log_info(" sim speed : %.1f MIPS", mips); - - return result; -} - -void system::end_of_elaboration() { - std::stringstream ss; - m_bus.execute("show", ss); - log_debug("%s", ss.str().c_str()); - - ss.str(""); - ss.clear(); - - m_gic.execute("show", ss); - log_debug("%s", ss.str().c_str()); -} -} // namespace avp64 diff --git a/sw/.gitignore b/sw/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/sw/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7c4af74..956d974 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################## # # -# Copyright 2020 Lukas Jünger # +# Copyright 2024 Lukas Jünger, Nils Bosbach # # # # This software is licensed under the MIT license. # # A copy of the license can be found in the LICENSE file at the root # @@ -9,41 +9,44 @@ ############################################################################## set(CMAKE_EXE_LINKER_FLAGS -rdynamic) -find_package(PythonInterp "3.9" REQUIRED) +find_package(Python3 "3.9" REQUIRED) + +get_target_property(ld_library_path ocx-qemu-arm BINARY_DIR) add_library(test_main test_main.cpp) -target_link_libraries(test_main gtest) +target_link_libraries(test_main PUBLIC gtest) +target_link_libraries(test_main PUBLIC avp64) +target_link_libraries(test_main PUBLIC vcml) -macro(link_test test) +macro(new_test test) + add_executable(${test} ${test}.cpp) target_include_directories(${test} PRIVATE ${inc} ${SYSTEMC_INCLUDE_DIRS}) - target_link_libraries(${test} test_main gtest vcml ${SYSTEMC_LIBRARIES} ${LIBELF_LIBRARIES} ${CMAKE_DL_LIBS}) + target_link_libraries(${test} test_main) target_compile_options(${test} PRIVATE ${MWR_COMPILER_WARN_FLAGS}) - set_target_properties(${test} PROPERTIES CXX_CLANG_TIDY "${AVP64_LINTER}") add_test(NAME ${test} COMMAND ${test} ${CMAKE_CURRENT_SOURCE_DIR}) set_tests_properties(${test} PROPERTIES TIMEOUT 5) + set_tests_properties(${test} PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=${ld_library_path}:$ENV{LD_LIBRARY_PATH}) endmacro() -add_executable(arm64_cpu_test arm64_cpu_test.cpp - ${src}/arm64_cpu.cpp) -link_test(arm64_cpu_test) - -function(linux_boot nrcpu config timeout) - set(name "linux-boot-${nrcpu}-cpus") - set(config ${CMAKE_SOURCE_DIR}/config/${config}) - set(script ${CMAKE_CURRENT_BINARY_DIR}/${name}.py) - get_target_property(ld_library_path ocx-qemu-arm BINARY_DIR) - configure_file(linux_boot.py.in ${script}) - file(GENERATE OUTPUT ${script} INPUT ${script}) - add_test(NAME ${name} COMMAND ${PYTHON_EXECUTABLE} ${script}) - set_tests_properties(${name} PROPERTIES TIMEOUT ${timeout}) - set_tests_properties(${name} PROPERTIES ENVIRONMENT "${ENVVARS}") -endfunction() +new_test(arm64_core_test) +if (AVP64_BUILD_RUNNER) + function(linux_boot nrcpu config timeout) + set(name "linux-boot-${nrcpu}-cpus") + set(config ${CMAKE_SOURCE_DIR}/sw/${config}) + set(script ${CMAKE_CURRENT_BINARY_DIR}/${name}.py) + configure_file(linux_boot.py.in ${script}) + file(GENERATE OUTPUT ${script} INPUT ${script}) + add_test(NAME ${name} COMMAND ${Python3_EXECUTABLE} ${script}) + set_tests_properties(${name} PROPERTIES TIMEOUT ${timeout}) + set_tests_properties(${name} PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=${ld_library_path}:$ENV{LD_LIBRARY_PATH}) + endfunction() -linux_boot(1 arm64_linux_4_19_4-x1.cfg 600) + linux_boot(1 buildroot_6_5_6-x1.cfg 600) -string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER) -if(BUILD_TYPE_UPPER STREQUAL RELEASE) - linux_boot(2 arm64_linux_4_19_4-x2.cfg 600) - linux_boot(4 arm64_linux_4_19_4-x4.cfg 600) - linux_boot(8 arm64_linux_4_19_4-x8.cfg 600) + string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER) + if(BUILD_TYPE_UPPER STREQUAL RELEASE) + linux_boot(2 buildroot_6_5_6-x2.cfg 600) + linux_boot(4 buildroot_6_5_6-x4.cfg 600) + linux_boot(8 buildroot_6_5_6-x8.cfg 600) + endif() endif() diff --git a/tests/arm64_cpu_test.cpp b/tests/arm64_core_test.cpp similarity index 88% rename from tests/arm64_cpu_test.cpp rename to tests/arm64_core_test.cpp index 831d230..821b5a8 100644 --- a/tests/arm64_cpu_test.cpp +++ b/tests/arm64_core_test.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * * - * Copyright 2020 Lukas Jünger * + * Copyright 2024 Lukas Jünger, Nils Bosbach * * * * This software is licensed under the MIT license found in the * * LICENSE file at the root directory of this source tree. * @@ -8,12 +8,12 @@ ******************************************************************************/ #include -#include "avp64/arm64_cpu.h" +#include "avp64/core.h" -class arm64_cpu_test : public avp64::arm64_cpu +class arm64_core_test : public avp64::core { public: - arm64_cpu_test(): avp64::arm64_cpu("test_cpu", 0, 1){}; + arm64_core_test(): avp64::core("test_core", 0, 1){}; bool read_reg(id_t regno, void* buf, size_t len) { return read_reg_dbg(regno, buf, len); } @@ -23,13 +23,11 @@ class arm64_cpu_test : public avp64::arm64_cpu }; TEST(Arm64CpuTest, simple) { - arm64_cpu_test test_cpu; + arm64_core_test test_cpu; mwr::hz_t defclk = 1 * mwr::kHz; vcml::generic::clock clock("clk", defclk); vcml::generic::reset reset("rst"); - sc_core::sc_signal irq0("irq0"); - sc_core::sc_signal irq1("irq1"); vcml::generic::memory imem("imem", 0x1000); vcml::generic::memory dmem("dmem", 0x10000); diff --git a/tests/linux_boot.py.in b/tests/linux_boot.py.in index 39e713f..fc22899 100644 --- a/tests/linux_boot.py.in +++ b/tests/linux_boot.py.in @@ -2,7 +2,7 @@ ############################################################################## # # -# Copyright 2023 Nils Bosbach, Jan Henrik Weinstock # +# Copyright 2024 Nils Bosbach, Jan Henrik Weinstock # # # # This software is licensed under the MIT license. # # A copy of the license can be found in the LICENSE file at the root # @@ -14,14 +14,14 @@ import sys import pexpect import os -sim='$' +sim='$' cfg='@config@' -cmdline = f'{sim} -f {cfg}'; +cmdline = f'{sim} -f {cfg}' print(cmdline) -p = pexpect.spawn(cmdline, logfile=sys.stdout, timeout=None, encoding='utf-8', env=os.environ | {'LD_LIBRARY_PATH': '@ld_library_path@'}) +p = pexpect.spawn(cmdline, logfile=sys.stdout, timeout=None, encoding='utf-8') # did all secondary cpus boot? for cpu in range(1, @nrcpu@): @@ -33,13 +33,14 @@ p.expect('1000a000.uart: ttyAMA1 at MMIO 0x1000a000') p.expect('1000b000.uart: ttyAMA2 at MMIO 0x1000b000') p.expect('1000c000.uart: ttyAMA3 at MMIO 0x1000c000') p.expect('timeriomem_rng 10007000.rng: 32bits') -p.expect('spi_oc_tiny 10147000.spi') -p.expect('mmc0: SDHCI controller on f_sdh30') +p.expect('spi_oc_tiny 10020000.spi') +p.expect('smsc911x 10010000.lan9118 eth0') +p.expect('rtc-ds1742 1000e000.rtc: registered as rtc0') +p.expect('mmc0: SDHCI controller on 1000d000.mmc') p.expect('mmc0: new SDHC card at address 0000') -p.expect('ethoc 1000d000.ethernet eth0: Link is Up') # did we get a login prompt? -p.expect('avp64-dom0 login:') +p.expect('avp64 login:') p.sendline('root') # can we run commands? diff --git a/utils/format b/utils/format new file mode 100755 index 0000000..dd0233d --- /dev/null +++ b/utils/format @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +############################################################################## +# # +# Copyright (C) 2024 MachineWare GmbH # +# All Rights Reserved # +# # +# This is work is licensed under the terms described in the LICENSE file # +# found in the root directory of this source tree. # +# # +############################################################################## + +import os +import sys +import subprocess +import platform +import tempfile +from pathlib import Path + +home = Path(__file__).resolve().parents[1] +ext = '.exe' if platform.system() == 'Windows' else '' +arch = platform.machine().lower() +formatter = home / 'cmake' / 'Tools' / platform.system()\ + / f'clang-format-18.{arch}{ext}' +srcdirs = [home / 'src', home / 'include', home / 'test'] + +with tempfile.NamedTemporaryFile(mode='w+', delete=False) as temp: + temp_path = temp.name + for dir in srcdirs: + for ext in ('*.h', '*.cpp'): + for file in dir.rglob(ext): + if 'googletest' not in str(file): + temp.write(f"{str(file)}\n") + temp.close() + r = subprocess.run([formatter, '--Wno-error=unknown', '--Werror',\ + f'--files={temp_path}'] + sys.argv[1:]) + os.remove(temp_path) + sys.exit(r.returncode) diff --git a/vscode/README.md b/vscode-tutorial/README.md similarity index 81% rename from vscode/README.md rename to vscode-tutorial/README.md index f8a9bb2..884124c 100644 --- a/vscode/README.md +++ b/vscode-tutorial/README.md @@ -3,7 +3,7 @@ ## Setup 1. Install the needed tools - + Ubuntu: ```bash @@ -17,6 +17,7 @@ ```bash /vscode/setup.bash ``` + 1. Install the VSCode extensions * In the end of the setup script, VSCode opens @@ -36,7 +37,6 @@ * The project is configured to be installed at `/build/{debug|release}/`. (This setting can be changed in the [\/.vscode/settings.json](../.vscode/settings.json) file) * To install the project, press F1 and type _CMake: Install_ - ## Start AVP64 1. Open the Debug view (Ctrl+Shift+D) @@ -47,17 +47,19 @@ Sample output: ```text - SystemC 2.3.3-MachineWare GmbH --- Nov 10 2023 18:03:26 + SystemC 2.3.3-MachineWare GmbH --- Jul 26 2024 14:01:36 Copyright (c) 1996-2018 by all Contributors, ALL RIGHTS RESERVED [I 0.000000000] system.term0: listening on port 52010 [I 0.000000000] system.term1: listening on port 52011 [I 0.000000000] system.term2: listening on port 52012 [I 0.000000000] system.term3: listening on port 52013 - [D 0.001000000] created slirp ipv4 network 10.0.0.0/24 - [D 0.001000000] created slirp ipv6 network fec0:: - [I 0.132000000] system: starting infinite simulation using 100 us quantum - [I 0.138000000] system.arm0: waiting for GDB connection on port 52100 + [D 0.000000000] created slirp ipv4 network 10.0.0.0/24 + [D 0.000000000] created slirp ipv6 network fec0:: + [I 0.000000000] system: starting infinite simulation using 100 us quantum + [I 0.000000000] system.cpu: waiting for GDB connection on port 5555 + [I 0.000000000] system.cpu.arm0: listening for GDB connection on port 52100 + [I 0.000000000] system.cpu.arm1: listening for GDB connection on port 52101 ``` 1. Connect the debugger by going back to the Debug view (Ctrl+Shift+D) @@ -66,4 +68,4 @@ 1. You can control the target using the control panel at the top. You can use the dropdown menu to switch between debugging avp64 and the target software. - \ No newline at end of file + diff --git a/vscode/assets/control_panel.png b/vscode-tutorial/assets/control_panel.png similarity index 100% rename from vscode/assets/control_panel.png rename to vscode-tutorial/assets/control_panel.png diff --git a/vscode/avp64.code-profile b/vscode-tutorial/avp64.code-profile similarity index 100% rename from vscode/avp64.code-profile rename to vscode-tutorial/avp64.code-profile diff --git a/vscode/launch.json b/vscode-tutorial/launch.json similarity index 60% rename from vscode/launch.json rename to vscode-tutorial/launch.json index 18ca64e..9f18786 100644 --- a/vscode/launch.json +++ b/vscode-tutorial/launch.json @@ -5,10 +5,10 @@ "type": "lldb", "request": "launch", "name": "Debug AVP64", - "program": "${workspaceFolder}/build/debug/bin/avp64", + "program": "${workspaceFolder}/build/debug/bin/avp64-runner", "args": [ - "-f", "config/arm64_linux_4_19_4-x1.cfg", // the config file that should be used by avp64 - "-c", "system.arm.gdb_wait=true" // wait until the target software debugger is connected + "-f", "sw/buildroot_6_5_6-x2.cfg", // the config file that should be used by avp64 + "-c", "system.cpu.gdb_wait=true" // wait until the target software debugger is connected ], "cwd": "${workspaceFolder}/build/debug", "env": { @@ -23,14 +23,14 @@ "request": "attach", "name": "Debug Target SW", "gdbpath": "/usr/bin/gdb-multiarch", - "target": ":52100", // gdb port of avp64 that should be used (default value for cpu0) + "target": ":5555", // gdb port of avp64 that should be used (default value for cpu0) "remote": true, "printCalls": true, - "cwd": "${workspaceFolder}/build/debug/sw/arm64/linux/linux-4.19.4", + "cwd": "${workspaceFolder}/linux-src", "valuesFormatting": "parseText", - "executable": "${workspaceFolder}/build/debug/sw/arm64/linux/vmlinux-4.19.4", // elf file of the software that is executed + "executable": "${workspaceFolder}/build/debug/sw/buildroot_6_5_6/buildroot.elf", // elf file of the software that is executed "pathSubstitutions": { - "/app/build/buildroot/output/linux/build/linux-4.19.4": "${workspaceFolder}/build/debug/sw/arm64/linux/linux-4.19.4" + "/app/build/buildroot/output/linux/build/linux-6.5.6": "${workspaceFolder}/linux-src" }, "stopAtConnect": true } diff --git a/vscode/settings.json b/vscode-tutorial/settings.json similarity index 100% rename from vscode/settings.json rename to vscode-tutorial/settings.json diff --git a/vscode/setup.bash b/vscode-tutorial/setup.bash similarity index 72% rename from vscode/setup.bash rename to vscode-tutorial/setup.bash index 24b45d5..b272f58 100755 --- a/vscode/setup.bash +++ b/vscode-tutorial/setup.bash @@ -23,39 +23,30 @@ while [ -h "$SOURCE" ]; do done DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" -LINUX_SW=https://github.com/aut0/avp64_sw/releases/latest/download/linux.tar.gz -LINUX_SRC=https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.19.4.tar.gz +LINUX_SW=https://github.com/aut0/avp64_sw/releases/download/v2024.07.30/buildroot_6_5_6.tar.gz +LINUX_SRC=https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-6.5.6.tar.gz LINUX_ARCHIVE="${LINUX_SRC##*/}" LINUX_DIRNAME="${LINUX_ARCHIVE%.tar.gz}" ROOT_DIR=${DIR}/.. VSCODE_DIR=${ROOT_DIR}/.vscode EXTENSIONS=(llvm-vs-code-extensions.vscode-clangd twxs.cmake ms-vscode.cmake-tools vadimcn.vscode-lldb webfreak.debug) -# fetch linux +# fetch sw wget ${LINUX_SW} tar -xvf linux.tar.gz rm linux.tar.gz - -# copy sw folder -mkdir -p ${ROOT_DIR}/build/{debug,release} -mv sw ${ROOT_DIR}/build/debug -ln -s -r ${ROOT_DIR}/build/debug/sw ${ROOT_DIR}/build/release/sw +mv sw "${ROOT_DIR}/" # get linux sources wget ${LINUX_SRC} tar -xf ${LINUX_ARCHIVE} rm ${LINUX_ARCHIVE} -mv ${LINUX_DIRNAME} ${ROOT_DIR}/build/release/sw/arm64/linux/ +mv ${LINUX_DIRNAME} "${ROOT_DIR}/linux-src/" # setup .vscode folder -mkdir ${ROOT_DIR}/.vscode -cp ${DIR}/settings.json ${VSCODE_DIR}/ -cp ${DIR}/launch.json ${VSCODE_DIR}/ - -# apply patches -pushd ${ROOT_DIR}/deps/ocx-qemu-arm/unicorn > /dev/null -git apply ${ROOT_DIR}/patches/unicorn-*.patch -popd > /dev/null +mkdir "${ROOT_DIR}/.vscode" +cp "${DIR}/settings.json" "${VSCODE_DIR}/" +cp "${DIR}/launch.json" "${VSCODE_DIR}/" # open VS Code code ${ROOT_DIR}