Compare commits

..

39 Commits

Author SHA1 Message Date
David Brown
f67ff24ff0 cmake: rust: Comment typo fix
Fix a mispelled word "al" -> "all".

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
646ee215c7 cmake: rust: Remove redundant call
Remove a redundant call that does exactly what the previous function
call accomplishes.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
f7fed4da0f doc: develop: rust: Various cleanups to docs
Minor fixes to the documentation from review feedback.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
71619deaee cmake: rust: Add header dependencies to cargo
With bindgen needing to read the headers, make sure CMake knows about
this.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
389c78d573 .gitignore: Ignore Rust 'target' directories
Although the Cmake rules to build Rust applications keeps the target
directory inside of the build directory, some IDE tools may generate a
target directory while editing the code.  Ignore these so they never get
checked in.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
60fde89b38 rust: zephyr-sys: Fixup clang targets for RISCV
Rustc for RISCV encodes optional features on the CPU available as part
of the target tuple.  Clang, on the other hand does not.  In order to be
able to use libclang with bindgen on RISCV, we need to simplify the
target tuples a bit.  Do this by just matching 'riscv32' or 'riscv64'
and then passing in a generic tuple.  We aren't generating any code, and
the structs should always match between the targets.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
0332ce8554 rust: Workaround gcc/clang differences with soft fp
GCC automatically defines a `__SOFTFP__` define on targets that are
using software floating point.  The clang compiler does not do this by
default, so check this, and define it.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
a57ceb78ed Revert "include: Add dummy field for Rust as well as CPP"
This reverts commit 2046760e71.

Put these back so we get the zero element structures when using just
rust and not CPP.  A subsequent patch will suppress the warning.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
c93d7a5ee6 rust: Suppress warning about improper C types
Zephyr takes advantage of a gcc/clang extension that allows structs that
have no elements.  Rust is perfectly happy with this (it is quite common
in Rust code), but generates a warning when a struct containing no
elements is passed to C code.

For now, suppress this warning on the generated bindings.  This has the
disadvantage of suppressing it entirely, which might possibly detect
other cases of invalid structs.  However, the bindings are
auto-generated from C structs so should always be valid.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
a40ddef8d9 cmake: rust: Fix typo on variable name
Fix `WRAPPER_FiLE` to `WRAPPER_FILE`.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
0756a9cfbb rust: Export zephyr-sys as zephyr::raw
Re-export all of the bindgen generated bindings in the zephyr-sys crate
into `zephyr::raw`.  This keeps things easier, as users of `zephyr` only
need to worry about the single `zephyr` crate.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
fc8d858ce8 doc: rust: Add docs on bindings
Add documentation on the bindings between Rust and C, and the bindgen
tool used to generate them.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
d98eae8ca9 rust: zephyr-sys: Use absolute path for wrapper
Change the header passed into bindgen to be an absolute path.  This will
cause the generated wrapper to refer to this file also using an absolute
path.  As such, remove the explicit include path added as part of the
build.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
c440acd3a9 cmake: rust: Compile the bindgen wrapper
When compiling Rust programs, the bindgen utility generates a wrapper file
to expand inline functions, as these otherwise cannot be accessed from
rust.  Pass a consistent name to the cargo build, and add it to our source
build so that this wrapper get compiled.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
8dc77158ff include: Add dummy field for Rust as well as CPP
For CPP builds, a few structs that end up empty in some configurations will
generate compile errors.  With the Rust tools, bindgen ends up producing
empty structsw for these as well.  Although the code compiles, it generates
warnings.  For now, add CONFIG_RUST to the ifdef checks so that these
structs don't end up empty with Rust either.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
acac09ec6d rust: Convert k_str_out to bindgen one
Remove the manual k_str_out wrapper, and use the one generated by bindgen.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
542d65fcd4 rust: Use zephyr-sys to get bindings
Instead of trying to manually generate the bindings, use those generated by
bindgen in the zephyr-sys crate.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
f806a3f9e5 rust: Create zephyr-sys for low-level bindings
With a lot of work done by Mario Jaun <mario.jaun@zuehlke.com>.

Use the rust-bindgen tool to extract bindings from the Zephyr header files.
The tool is run with the exact configuration of the current build, and
therefore the bindings will match the current target.  The ifdefs and such
are not translated into the Rust code, and this must be generated live for
each build.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-09-06 09:15:47 -06:00
David Brown
4dd43cafbd samples: rust: Include rust samples in docs
Include the Sample Rust applications in the doc generation.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
be6c708901 doc: languages: rust: typo fixes
Fix various minor typos in the Rust documentation.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
efd15c89d1 doc: languagues: rust: Reformat
Refill the text to 100 columns instead of 72 to match the rest of the
project.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
63097dfac5 samples: rust: Rename hello world
Rename the sample to just hello world.  As long as the actual sample
name is different, there won't be index conflicts in the documentation.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
21a58bebed samples: rust: Add README for rust hello world
Create a Readme for this sample, explaining how to build and what it
does.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
42b25ccef0 rust: Move ignores to top .gitignore
Apply the rules to ignore some cargo generated or used files to the
whole tree, not just the samples.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
9daf9a6238 samples: rust: Tag the rust sample as rust
Add the 'rust' tag so that CI will invoke this test when rust support
files have changed.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
5249c82425 ci: tags: Add rust tag
The rust tag associates rust tests and samples with code that adds rust
support to Zephyr.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
24a71d59b4 cmake: rust: Add Cortex M7 support
The Cortex-M7 is build the same as M4.  Catch it in the same rules.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
6c8b63cee6 rust: Ignore unknown cfgs in the zephyr crate
We use the `#[cfg(...)]` directive in rust to pass Kconfig values through.
Because it is possible for the code to depend on a Kconfig value that isn't
present in a given build, there isn't a way for us to tell the Rust
toolchain about all possible config values.

For now, just disable this warning entirely.  This functionality could be
supported by the patch validation scripts, which seems like a better place
than trying to gather a list of all possible configs at build time.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
15556acd18 doc: languages: Add Rust documentation
Add initial docs for Rust language support.  Explains the support
currently present, how to install the toolchain needed, and explains
what is in the current sample.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
6b436713f1 MAINTAINERS: Add Rust to maintainers file
Indicate the new code is maintained.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
3f8ebadde7 rust: Simple rust hello_world application
Create the Rust equivalent of the hello_world application.  This shows
the use of printk from Rust as well as accessing a string value from
Kconfig.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
68e2023837 lib: rust: Add simple printk support to Rust
When `CONFIG_PRINTK` is enabled, provide macros `printk` and `printkln`
within the `zephyr` crate that applications can use to print.  This
currently sends messages, with a small amount of buffering, using
`k_str_out`.

Until C functions are made generally available from the Rust side,
we use a small wrapper function to call `k_str_out`, as it is
implemented as an inline syscall.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
1ed0aeab6b rust: Add cmake support for building rust apps
This provides the function `rust_cargo_application()` within Cmake to
give applications written in Rust a simple way to start.

This implements the basic functionality needed to build a rust
application on Arm, including target mapping, and invoking cargo during
the build.

Most of the functionality is about passing the appropriate flags to
`cargo`, which is used to perform the actual build of the rust code.
Cargo generates `librustapp.a` which is added to the link dependencies
for the application.

The cargo rule is written such that cargo will always be built (provided
`app` is being built), as there will be complex dependencies on the
cargo side.  Cargo will not modify the `librustapp.a` file if nothing
needs to be build, so this will generally be fast if there are no
changes to files that affect the Rust build.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
5230bb462e rust: Basic zephyr crates
This is the initial Zephyr-specific crates that provide support for Rust
on Zephyr.  Currently, what they do is fairly minimal, but important.

`zephyr-build` is a build time crate (linked against the `zephyr`
crate's build.rs) that processes the current build's Kconfig settings,
and does three things with them:

  - Boolean Kconfig values given given to the Rust toolchain so that
    conditional compilation can be based off of them.
  - Numeric Kconfig settings end up as constants in `zephyr::kconfig`.
  - String valued Kconfig settings end up as constants in
    `zephyr::kconfig`.

None of these cause code or data to be generated or allocated (but note
that if there is a reference to a string, that string will be placed in
read-only memory).

The `zephyr` crate is built for the target, and intended to be
referenced by the application.  It provides minimal support needed for a
"bare" Rust build, notably a panic handler.  At this point, the panic
handler is not implemented as we need better support for calling into
Zephyr's C code, so it just stops in an infinite loop.

It also ensures that `CONFIG_RUST` is set as a sanity check, and
includes the generated kconfig.rs file with the kconfig definitions for
the current build.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
148e135137 rust: Simple main wrapper
Until further variants are needed, this provides a `main()` function
that simply calls into the `rust_main()` function.  This is adequate for
applications where main can be directly written in Rust.

The reason that this is written here, rather than just writing `main`
directly in Rust is that `kernel/main_weak.c` provides a weak default
implementation that will be brought in before the Rust application's
`main` is linked in.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
3496844d37 rust: Initial config option
Add the `CONFIG_RUST` Kconfig.  This can be set to indicate that an
application wishes to use Rust support.

Adds `CONFIG_RUST_SUPPORTED` to indicate what platforms Rust is known to
work on.  This is set to the targets that are supported by subsequent
commits.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-27 08:47:59 -06:00
David Brown
5cbb204210 github: workflows: Update other docker image reference
The twister workflow contains two references to the docker image to use.
The earlier change only updated one of these.  Update the other to
match.  This should allow rust code to be built in the whole twister
workflow.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-24 07:58:26 -04:00
David Brown
45c96c74e2 github: workflows: Add cargo support to twister
Add cargo's bin to the path, and print out the versioning of the tool to
make it easy to ensure the right version has been installed.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-08-23 09:13:35 -06:00
David Brown
8c4b1635ba github: workflows: Update docker image
Use the v0.24.14 docker image, which adds rust target support.

Signed-off-by: David Brown <david.brown@linaro.org>

fix
2024-08-23 09:13:35 -06:00
6413 changed files with 49150 additions and 162680 deletions

View File

@@ -79,8 +79,6 @@ ForEachMacros:
- 'HTTP_SERVER_CONTENT_TYPE_FOREACH'
- 'HTTP_SERVICE_FOREACH'
- 'HTTP_SERVICE_FOREACH_RESOURCE'
- 'I3C_BUS_FOR_EACH_I3CDEV'
- 'I3C_BUS_FOR_EACH_I2CDEV'
IfMacros:
- 'CHECKIF'
# Disabled for now, see bug https://github.com/zephyrproject-rtos/zephyr/issues/48520
@@ -103,10 +101,5 @@ SpaceBeforeParens: ControlStatementsExceptControlMacros
SortIncludes: Never
UseTab: ForContinuationAndIndentation
WhitespaceSensitiveMacros:
- COND_CODE_0
- COND_CODE_1
- IF_DISABLED
- IF_ENABLED
- LISTIFY
- STRINGIFY
- Z_STRINGIFY

View File

@@ -1,21 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (c) 2024, Basalte bv
analyzer:
# Start by disabling all
- --disable-all
# Enable the sensitive profile
- --enable=sensitive
# Disable unused cases
- --disable=boost
- --disable=mpi
# Many identifiers in zephyr start with _
- --disable=clang-diagnostic-reserved-identifier
- --disable=clang-diagnostic-reserved-macro-identifier
# Cleanup
- --clean

View File

@@ -2,20 +2,12 @@ name: Backport Issue Check
on:
pull_request_target:
types:
- edited
- opened
- reopened
- synchronize
branches:
- v*-branch
jobs:
backport:
name: Backport Issue Check
concurrency:
group: backport-issue-check-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-22.04
if: github.repository == 'zephyrproject-rtos/zephyr'

View File

@@ -13,7 +13,7 @@ jobs:
steps:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v3
with:
run_id: ${{ github.event.workflow_run.id }}

View File

@@ -8,8 +8,6 @@ on:
- "west.yml"
- "subsys/bluetooth/**"
- "tests/bsim/**"
- "boards/nordic/nrf5*/*dt*"
- "dts/*/nordic/**"
- "tests/bluetooth/common/testlib/**"
- "samples/bluetooth/**"
- "boards/posix/**"
@@ -36,7 +34,7 @@ jobs:
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container:
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.14.20240823
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.13.20240601
options: '--entrypoint /bin/bash'
env:
ZEPHYR_TOOLCHAIN_VARIANT: zephyr
@@ -77,7 +75,6 @@ jobs:
git config --global user.name "Zephyr Bot"
rm -fr ".git/rebase-apply"
git rebase origin/${BASE_REF}
git clean -f -d
git log --pretty=oneline | head -n 10
west init -l . || true
west config manifest.group-filter -- +ci
@@ -88,7 +85,7 @@ jobs:
echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
- name: Check common triggering files
uses: tj-actions/changed-files@v45
uses: tj-actions/changed-files@v44
id: check-common-files
with:
files: |
@@ -101,11 +98,9 @@ jobs:
include/zephyr/arch/posix/
scripts/native_simulator/
tests/bsim/*
boards/nordic/nrf5*/*dt*
dts/*/nordic/
- name: Check if Bluethooth files changed
uses: tj-actions/changed-files@v45
uses: tj-actions/changed-files@v44
id: check-bluetooth-files
with:
files: |
@@ -114,7 +109,7 @@ jobs:
subsys/bluetooth/
- name: Check if Networking files changed
uses: tj-actions/changed-files@v45
uses: tj-actions/changed-files@v44
id: check-networking-files
with:
files: |
@@ -127,7 +122,7 @@ jobs:
include/zephyr/net/ieee802154*
- name: Check if UART files changed
uses: tj-actions/changed-files@v45
uses: tj-actions/changed-files@v44
id: check-uart-files
with:
files: |
@@ -137,10 +132,10 @@ jobs:
- name: Update BabbleSim to manifest revision
if: >
steps.check-bluetooth-files.outputs.any_modified == 'true'
|| steps.check-networking-files.outputs.any_modified == 'true'
|| steps.check-uart-files.outputs.any_modified == 'true'
|| steps.check-common-files.outputs.any_modified == 'true'
steps.check-bluetooth-files.outputs.any_changed == 'true'
|| steps.check-networking-files.outputs.any_changed == 'true'
|| steps.check-uart-files.outputs.any_changed == 'true'
|| steps.check-common-files.outputs.any_changed == 'true'
run: |
export BSIM_VERSION=$( west list bsim -f {revision} )
echo "Manifest points to bsim sha $BSIM_VERSION"
@@ -151,17 +146,17 @@ jobs:
make everything -s -j 8
- name: Run Bluetooth Tests with BSIM
if: steps.check-bluetooth-files.outputs.any_modified == 'true' || steps.check-common-files.outputs.any_modified == 'true'
if: steps.check-bluetooth-files.outputs.any_changed == 'true' || steps.check-common-files.outputs.any_changed == 'true'
run: |
tests/bsim/ci.bt.sh
- name: Run Networking Tests with BSIM
if: steps.check-networking-files.outputs.any_modified == 'true' || steps.check-common-files.outputs.any_modified == 'true'
if: steps.check-networking-files.outputs.any_changed == 'true' || steps.check-common-files.outputs.any_changed == 'true'
run: |
tests/bsim/ci.net.sh
- name: Run UART Tests with BSIM
if: steps.check-uart-files.outputs.any_modified == 'true' || steps.check-common-files.outputs.any_modified == 'true'
if: steps.check-uart-files.outputs.any_changed == 'true' || steps.check-common-files.outputs.any_changed == 'true'
run: |
tests/bsim/ci.uart.sh

View File

@@ -12,7 +12,7 @@ jobs:
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container:
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.14.20240823
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.13.20240601
options: '--entrypoint /bin/bash'
strategy:
fail-fast: false
@@ -62,7 +62,6 @@ jobs:
git config --global user.name "Zephyr Bot"
rm -fr ".git/rebase-apply"
git rebase origin/${BASE_REF}
git clean -f -d
git log --pretty=oneline | head -n 10
west init -l . || true
west config --global update.narrow true

View File

@@ -14,7 +14,7 @@ jobs:
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container:
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.14.20240823
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.13.20240601
options: '--entrypoint /bin/bash'
strategy:
fail-fast: false

View File

@@ -41,7 +41,6 @@ jobs:
git config --global user.name "Github Actions"
git remote -v
git rebase origin/${BASE_REF}
git clean -f -d
source zephyr-env.sh
# debug
ls -la

View File

@@ -38,7 +38,7 @@ jobs:
run: |
pip3 install setuptools
pip3 install wheel
pip3 install python-magic lxml junitparser gitlint pylint pykwalify yamllint clang-format unidiff sphinx-lint
pip3 install python-magic lxml junitparser gitlint pylint pykwalify yamllint clang-format unidiff
pip3 install west
- name: west setup
@@ -52,7 +52,6 @@ jobs:
[[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \
(echo "::error ::Merge commits not allowed, rebase instead";false)
git rebase origin/${BASE_REF}
git clean -f -d
# debug
git log --pretty=oneline | head -n 10
west init -l . || true

View File

@@ -28,6 +28,11 @@ jobs:
matrix:
python-version: ['3.10', '3.11', '3.12']
os: [ubuntu-22.04, macos-14, windows-2022]
exclude:
- os: macos-14
python-version: 3.6
- os: windows-2022
python-version: 3.6
steps:
- name: checkout
uses: actions/checkout@v4

View File

@@ -29,7 +29,7 @@ jobs:
if: >
github.repository_owner == 'zephyrproject-rtos'
outputs:
file_check: ${{ steps.check-doc-files.outputs.any_modified }}
file_check: ${{ steps.check-doc-files.outputs.any_changed }}
steps:
- name: checkout
uses: actions/checkout@v4
@@ -37,7 +37,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Check if Documentation related files changed
uses: tj-actions/changed-files@v45
uses: tj-actions/changed-files@v44
id: check-doc-files
with:
files: |
@@ -62,13 +62,20 @@ jobs:
if: >
github.repository_owner == 'zephyrproject-rtos' &&
( needs.doc-file-check.outputs.file_check == 'true' || github.event_name != 'pull_request' )
runs-on: ubuntu-22.04
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
timeout-minutes: 90
concurrency:
group: doc-build-html-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: install-pkgs
run: |
sudo apt-get update
@@ -94,7 +101,6 @@ jobs:
git config --global user.email "actions@zephyrproject.org"
git config --global user.name "Github Actions"
git rebase origin/${BASE_REF}
git clean -f -d
git log --graph --oneline HEAD...${PR_HEAD}
- name: cache-pip
@@ -110,22 +116,11 @@ jobs:
pip3 install west==${WEST_VERSION}
pip3 install cmake==${CMAKE_VERSION}
pip3 install coverxygen
pip3 install mlx.traceability strictdoc
- name: west setup
run: |
west init -l .
- name: prcoess requirements
run: |
west update reqmgmt
pushd ../tools/reqmgmt
strictdoc export . --formats json
popd
cp ../tools/reqmgmt/output/json/index.json doc/requirements/requirements.json
python3 doc/requirements/create_req.py --json doc/requirements/requirements.json --output doc/requirements/requirements.dox
- name: build-docs
shell: bash
run: |
@@ -146,10 +141,17 @@ jobs:
SPHINXOPTS_EXTRA="-q -t publish" \
make -C doc ${DOC_TARGET}
# API documentation coverage
python3 -m coverxygen --xml-dir doc/_build/html/doxygen/xml/ --src-dir include/ --output doc-coverage.info
# deprecated page causing issues
lcov --remove doc-coverage.info \*/deprecated > new.info
genhtml --no-function-coverage --no-branch-coverage new.info -o coverage-report
- name: compress-docs
run: |
tar --use-compress-program="xz -T0" -cf html-output.tar.xz --directory=doc/_build html
tar --use-compress-program="xz -T0" -cf api-output.tar.xz --directory=doc/_build html/doxygen/html
tar --use-compress-program="xz -T0" -cf api-coverage.tar.xz coverage-report
- name: upload-build
uses: actions/upload-artifact@v4
@@ -157,6 +159,12 @@ jobs:
name: html-output
path: html-output.tar.xz
- name: upload-api-coverage
uses: actions/upload-artifact@v4
with:
name: api-coverage
path: api-coverage.tar.xz
- name: process-pr
if: github.event_name == 'pull_request'
run: |
@@ -184,7 +192,8 @@ jobs:
if: |
github.event_name != 'pull_request' &&
github.repository_owner == 'zephyrproject-rtos'
runs-on: ubuntu-22.04
runs-on:
group: zephyr-runner-v2-linux-x64-4xlarge
container: texlive/texlive:latest
timeout-minutes: 120
concurrency:
@@ -196,6 +205,12 @@ jobs:
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Print cloud service information
run: |
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
- name: checkout
uses: actions/checkout@v4

View File

@@ -21,7 +21,7 @@ jobs:
steps:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v3
with:
workflow: doc-build.yml
run_id: ${{ github.event.workflow_run.id }}

View File

@@ -24,7 +24,7 @@ jobs:
steps:
- name: Download artifacts
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v3
with:
workflow: doc-build.yml
run_id: ${{ github.event.workflow_run.id }}

View File

@@ -26,7 +26,7 @@ jobs:
group: zephyr-runner-v2-linux-x64-4xlarge
if: github.repository_owner == 'zephyrproject-rtos'
container:
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.14.20240823
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.26.13.20240601
options: '--entrypoint /bin/bash'
strategy:
fail-fast: false

View File

@@ -46,7 +46,6 @@ jobs:
git config --global user.email "actions@zephyrproject.org"
git config --global user.name "Github Actions"
git rebase origin/${BASE_REF}
git clean -f -d
git log --graph --oneline HEAD...${PR_HEAD}
- name: Set up Python

View File

@@ -21,7 +21,7 @@ jobs:
echo "TRIMMED_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v4
uses: fsfe/reuse-action@v1
with:
args: spdx -o zephyr-${{ steps.get_version.outputs.VERSION }}.spdx

View File

@@ -43,7 +43,6 @@ jobs:
git config --global user.email "actions@zephyrproject.org"
git config --global user.name "Github Actions"
git rebase origin/${BASE_REF}
git clean -f -d
git log --graph --oneline HEAD...${PR_HEAD}
- name: Set up Python ${{ matrix.python-version }}

View File

@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-22.04
if: github.repository == 'zephyrproject-rtos/zephyr'
steps:
- uses: actions/stale@v9
- uses: actions/stale@v8
with:
stale-pr-message: 'This pull request has been marked as stale because it has been open (more
than) 60 days with no activity. Remove the stale label or add a comment saying that you

View File

@@ -77,7 +77,6 @@ jobs:
git config --global user.name "Zephyr Bot"
rm -fr ".git/rebase-apply"
git rebase origin/${BASE_REF}
git clean -f -d
git log --pretty=oneline | head -n 10
west init -l . || true
west config manifest.group-filter -- +ci,+optional
@@ -186,7 +185,6 @@ jobs:
git config --global user.name "Zephyr Builder"
rm -fr ".git/rebase-apply"
git rebase origin/${BASE_REF}
git clean -f -d
git log --pretty=oneline | head -n 10
fi
echo "$HOME/.local/bin" >> $GITHUB_PATH
@@ -315,7 +313,7 @@ jobs:
if: success() || failure()
steps:
# Needed for elasticearch and upload script
# Needed for opensearch and upload script
- if: github.event_name == 'push' || github.event_name == 'schedule'
name: Checkout
uses: actions/checkout@v4
@@ -329,7 +327,7 @@ jobs:
path: artifacts
- if: github.event_name == 'push' || github.event_name == 'schedule'
name: Upload to elasticsearch
name: Upload to opensearch
run: |
pip3 install elasticsearch
# set run date on upload to get consistent and unified data across the matrix.

View File

@@ -31,6 +31,11 @@ jobs:
matrix:
python-version: ['3.10', '3.11', '3.12']
os: [ubuntu-22.04, macos-14, windows-2022]
exclude:
- os: macos-14
python-version: 3.6
- os: windows-2022
python-version: 3.6
steps:
- name: checkout
uses: actions/checkout@v4

13
.gitignore vendored
View File

@@ -59,6 +59,18 @@ venv
.clangd
new.info
# Cargo drops lock files in projects to capture resolved dependencies.
# We don't want to record these.
Cargo.lock
# Cargo encourages a .cargo/config.toml file to symlink to a generated
# file. Don't save these.
.cargo/
# Normal west builds will place the Rust target directory under the build directory. However,
# sometimes IDEs and such will litter these target directories as well.
target/
# CI output
compliance.xml
_error.types
@@ -91,5 +103,4 @@ MaintainersFormat.txt
ModulesMaintainers.txt
Nits.txt
Pylint.txt
SphinxLint.txt
YAMLLint.txt

View File

@@ -152,7 +152,6 @@ zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,
# Extra warnings options for twister run
if (CONFIG_COMPILER_WARNINGS_AS_ERRORS)
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:$<TARGET_PROPERTY:compiler,warnings_as_errors>>)
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler,warnings_as_errors>>)
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:$<TARGET_PROPERTY:asm,warnings_as_errors>>)
zephyr_link_libraries($<TARGET_PROPERTY:linker,warnings_as_errors>)
endif()
@@ -361,21 +360,8 @@ zephyr_compile_options(
$<$<COMPILE_LANGUAGE:ASM>:-D_ASMLANGUAGE>
)
find_package(Deprecated COMPONENTS toolchain_ld_base)
if(DEFINED TOOLCHAIN_LD_FLAGS)
zephyr_ld_options(${TOOLCHAIN_LD_FLAGS})
endif()
zephyr_link_libraries(PROPERTY base)
zephyr_link_libraries_ifndef(CONFIG_LINKER_USE_RELAX PROPERTY no_relax)
zephyr_link_libraries_ifdef(CONFIG_LINKER_USE_RELAX PROPERTY relax)
# Sort the common symbols and each input section by alignment
# in descending order to minimize padding between these symbols.
zephyr_link_libraries_ifdef(CONFIG_LINKER_SORT_BY_ALIGNMENT PROPERTY sort_alignment)
# @Intent: Set fundamental linker specific flags
toolchain_ld_base()
toolchain_ld_force_undefined_symbols(
_OffsetAbsSyms
@@ -383,37 +369,13 @@ toolchain_ld_force_undefined_symbols(
)
if(NOT CONFIG_NATIVE_BUILD)
find_package(Deprecated COMPONENTS toolchain_ld_baremetal)
zephyr_link_libraries(PROPERTY baremetal)
# Note that some architectures will skip this flag if set to error, even
# though the compiler flag check passes (e.g. ARC and Xtensa). So warning
# should be the default for now.
#
# Skip this for native application as Zephyr only provides
# additions to the host toolchain linker script. The relocation
# sections (.rel*) requires us to override those provided
# by host toolchain. As we can't account for all possible
# combination of compiler and linker on all machines used
# for development, it is better to turn this off.
#
# CONFIG_LINKER_ORPHAN_SECTION_PLACE is to place the orphan sections
# without any warnings or errors, which is the default behavior.
# So there is no need to explicitly set a linker flag.
if(CONFIG_LINKER_ORPHAN_SECTION_WARN)
zephyr_link_libraries(PROPERTY orphan_warning)
elseif(CONFIG_LINKER_ORPHAN_SECTION_ERROR)
zephyr_link_libraries(PROPERTY orphan_error)
endif()
# @Intent: Set linker specific flags for bare metal target
toolchain_ld_baremetal()
endif()
if(CONFIG_CPP)
if(NOT CONFIG_MINIMAL_LIBCPP AND NOT CONFIG_NATIVE_LIBRARY)
find_package(Deprecated COMPONENTS toolchain_ld_cpp)
endif()
zephyr_link_libraries(PROPERTY cpp_base)
if(CONFIG_CPP AND NOT CONFIG_MINIMAL_LIBCPP AND NOT CONFIG_NATIVE_LIBRARY)
# @Intent: Set linker specific flags for C++
toolchain_ld_cpp()
endif()
# @Intent: Add the basic toolchain warning flags

View File

@@ -210,8 +210,6 @@
/drivers/ethernet/*adin2111* @GeorgeCGV
/drivers/ethernet/*oa_tc6* @lmajewski
/drivers/ethernet/*lan865x* @lmajewski
/drivers/ethernet/dwc_xgmac @Smale-12048867
/drivers/ethernet/dwc_xgmac/dwc_xgmac @Smale-12048867
/drivers/ethernet/phy/ @rlubos @tbursztyka @arvinf @jukkar
/drivers/ethernet/phy/*adin2111* @GeorgeCGV
/drivers/mdio/*adin2111* @GeorgeCGV

View File

@@ -260,20 +260,6 @@ config LINKER_USE_PINNED_SECTION
Requires that pinned sections exist in the architecture, SoC,
board or custom linker script.
config LINKER_USE_ONDEMAND_SECTION
bool "Use Evictable Linker Section"
depends on DEMAND_MAPPING
depends on !LINKER_USE_PINNED_SECTION
depends on !ARCH_MAPS_ALL_RAM
help
If enabled, the symbols which may be evicted from memory
will be put into a linker section reserved for on-demand symbols.
During boot, the corresponding memory will be mapped as paged out.
This is conceptually the opposite of CONFIG_LINKER_USE_PINNED_SECTION.
Requires that on-demand sections exist in the architecture, SoC,
board or custom linker script.
config LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT
bool "Generic sections are present at boot" if DEMAND_PAGING && LINKER_USE_PINNED_SECTION
default y
@@ -289,7 +275,7 @@ config LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT
config LINKER_LAST_SECTION_ID
bool "Last section identifier"
default y if !ARM64
default y
depends on ARM || ARM64 || RISCV
help
If enabled, the last section will contain an identifier.

View File

@@ -305,9 +305,10 @@ Bluetooth HCI:
status: maintained
maintainers:
- jhedberg
- alwa-nordic
- jori-nordic
collaborators:
- hermabe
- alwa-nordic
- Thalley
- sjanc
- theob-pro
@@ -344,8 +345,13 @@ Bluetooth controller:
- subsys/bluetooth/common/
- subsys/bluetooth/controller/
- subsys/bluetooth/crypto/
- subsys/bluetooth/shell/ll.c
- subsys/bluetooth/shell/ll.h
- subsys/bluetooth/shell/ticker.c
- tests/bluetooth/controller/
- tests/bsim/bluetooth/ll/
- tests/bluetooth/ctrl*/
- tests/bluetooth/ll_settings/
labels:
- "area: Bluetooth Controller"
- "area: Bluetooth"
@@ -355,10 +361,11 @@ Bluetooth controller:
Bluetooth Host:
status: maintained
maintainers:
- jori-nordic
- jhedberg
- alwa-nordic
collaborators:
- hermabe
- alwa-nordic
- Thalley
- sjanc
- theob-pro
@@ -371,6 +378,7 @@ Bluetooth Host:
- subsys/bluetooth/host/
- subsys/bluetooth/lib/
- subsys/bluetooth/services/
- subsys/bluetooth/shell/
- subsys/bluetooth/CMakeLists.txt
- subsys/bluetooth/Kconfig*
- tests/bluetooth/
@@ -383,6 +391,7 @@ Bluetooth Host:
- include/zephyr/bluetooth/iso.h
- include/zephyr/bluetooth/controller.h
- include/zephyr/bluetooth/mesh.h
- include/zephyr/bluetooth/testing.h
- doc/connectivity/bluetooth/bluetooth-ctlr-arch.rst
- doc/connectivity/bluetooth/autopts/
- doc/connectivity/bluetooth/img/ctlr*
@@ -396,18 +405,21 @@ Bluetooth Host:
- samples/bluetooth/hci_*/
- samples/bluetooth/pbp*/
- samples/bluetooth/tmap*/
- samples/bluetooth/*_iso/
- samples/bluetooth/iso_*/
- samples/bluetooth/mesh*/
- subsys/bluetooth/shell/bredr.c
- subsys/bluetooth/shell/iso.c
- subsys/bluetooth/shell/ll.c
- subsys/bluetooth/shell/ll.h
- subsys/bluetooth/shell/ticker.c
- subsys/bluetooth/Kconfig.iso
- subsys/bluetooth/host/iso.c
- subsys/bluetooth/host/iso_internal.h
- subsys/bluetooth/host/shell/iso.c
- tests/bluetooth/audio/
- tests/bluetooth/controller/
- tests/bluetooth/ctrl*/
- tests/bluetooth/ll_settings/
- tests/bluetooth/mesh*/
- tests/bluetooth/qualification/
- tests/bluetooth/shell/audio.conf
- tests/bluetooth/shell/mesh.conf
- tests/bluetooth/tester/
- tests/bsim/bluetooth/audio/
- tests/bsim/bluetooth/audio_samples/
@@ -435,10 +447,10 @@ Bluetooth Mesh:
- doc/connectivity/bluetooth/api/mesh/
- include/zephyr/bluetooth/mesh/
- include/zephyr/bluetooth/mesh.h
- include/zephyr/bluetooth/testing.h
- samples/bluetooth/mesh*/
- subsys/bluetooth/mesh/
- tests/bluetooth/mesh*/
- tests/bluetooth/shell/mesh.conf
- tests/bsim/bluetooth/mesh/
labels:
- "area: Bluetooth Mesh"
@@ -493,6 +505,7 @@ Bluetooth Classic:
files:
- subsys/bluetooth/common/
- subsys/bluetooth/host/classic/
- subsys/bluetooth/shell/bredr.c
- include/zephyr/bluetooth/classic/
labels:
- "area: Bluetooth Classic"
@@ -506,15 +519,13 @@ Bluetooth ISO:
- Thalley
collaborators:
- jhedberg
- kruithofa
files:
- include/zephyr/bluetooth/iso.h
- doc/connectivity/bluetooth/api/shell/iso.rst
- samples/bluetooth/*_iso/
- samples/bluetooth/iso_*/
- subsys/bluetooth/shell/iso.c
- subsys/bluetooth/Kconfig.iso
- subsys/bluetooth/host/iso.c
- subsys/bluetooth/host/iso_internal.h
- subsys/bluetooth/host/shell/iso.c
labels:
- "area: Bluetooth ISO"
- "area: Bluetooth"
@@ -752,8 +763,8 @@ Coding Guidelines:
- "area: Coding Guidelines"
Common Architecture Interface:
status: maintained
maintainers:
status: odd fixes
collaborators:
- dcpleung
- nashif
files:
@@ -983,10 +994,10 @@ Documentation Infrastructure:
status: maintained
maintainers:
- gmarull
- kartben
collaborators:
- carlescufi
- nashif
- kartben
files:
- doc/_*/
- doc/CMakeLists.txt
@@ -1035,6 +1046,7 @@ Release Notes:
collaborators:
- lyakh
- lgirdwood
- marc-hb
- kv2019i
files:
- drivers/audio/
@@ -1728,7 +1740,7 @@ Release Notes:
- drivers/led/
- include/zephyr/drivers/led/
- include/zephyr/drivers/led.h
- samples/drivers/led/
- samples/drivers/led_*/
- tests/drivers/led/
- doc/hardware/peripherals/led.rst
- tests/drivers/build_all/led/
@@ -2044,21 +2056,6 @@ Release Notes:
tests:
- drivers.spi
"Drivers: Stepper":
status: maintained
maintainers:
- jilaypandya
files:
- drivers/stepper/
- include/zephyr/drivers/stepper.h
- dts/bindings/stepper/
- doc/hardware/peripherals/stepper.rst
- tests/drivers/build_all/stepper/
labels:
- "area: Stepper"
tests:
- drivers.stepper
"Drivers: System timer":
status: maintained
maintainers:
@@ -2077,8 +2074,6 @@ Release Notes:
status: odd fixes
collaborators:
- loicpoulain
- josuah
- ngphibang
files:
- drivers/video/
- include/zephyr/drivers/video.h
@@ -2086,7 +2081,6 @@ Release Notes:
- doc/hardware/peripherals/video.rst
- tests/drivers/*/video/
- dts/bindings/video/
- samples/drivers/video/
labels:
- "area: Video"
tests:
@@ -2160,8 +2154,6 @@ Release Notes:
maintainers:
- krish2718
- jukkar
collaborators:
- sachinthegreen
files:
- drivers/wifi/nrfwifi/
- dts/bindings/wifi/nordic,nrf70.yaml
@@ -2311,7 +2303,7 @@ Google Platforms:
- duda-patryk
files:
- boards/google/
- samples/boards/google/
- samples/boards/google_*/
Hash Utilities:
status: maintained
@@ -2710,6 +2702,8 @@ hawkBit:
status: maintained
maintainers:
- maass-hamburg
collaborators:
- ycsin
files:
- subsys/mgmt/hawkbit/
- include/zephyr/mgmt/hawkbit.h
@@ -2795,6 +2789,7 @@ Networking:
- samples/net/lwm2m_client/
- samples/net/wifi/
- samples/net/dhcpv4_client/
- subsys/net/buf*.c
- subsys/net/l2/ethernet/gptp/
- subsys/net/l2/ieee802154/
- subsys/net/l2/wifi/
@@ -2827,7 +2822,7 @@ Networking:
tests:
- net.socket
"Networking Buffers":
"Networking: Buffers":
status: maintained
maintainers:
- jhedberg
@@ -2836,15 +2831,13 @@ Networking:
- tbursztyka
- jukkar
files:
- doc/services/net_buf/
- include/zephyr/net/buf.h
- include/zephyr/net_buf.h
- lib/net_buf/
- tests/lib/net_buf/
- subsys/net/buf*.c
- tests/net/buf/
labels:
- "area: Networking Buffers"
tests:
- libraries.net_buf
- net.buf
"Networking: Connection Manager":
status: maintained
@@ -3179,6 +3172,17 @@ Retention:
labels:
- "area: Retention"
Rust:
status: maintained
maintainers:
- d3zd3z
files:
- cmake/modules/rust.cmake
- lib/rust/
- samples/rust/
labels:
- "area: Rust"
Samples:
status: maintained
maintainers:
@@ -3371,11 +3375,11 @@ Broadcom Platforms:
GD32 Platforms:
status: maintained
maintainers:
- cameled
- nandojve
collaborators:
- gmarull
- soburi
- cameled
files:
- boards/gd/
- drivers/*/*gd32*
@@ -3497,27 +3501,6 @@ Silabs Platforms:
labels:
- "platform: Silabs"
Silabs SiM3U Platforms:
status: maintained
maintainers:
- rettichschnidi
collaborators:
- M1cha
- asmellby
- jerome-pouiller
- jhedberg
files:
- boards/silabs/dev_kits/sim3u1xx_dk/
- drivers/*/*_si32*
- drivers/*/Kconfig.si32
- dts/arm/silabs/sim3u*
- dts/bindings/*/*silabs,si32*
- soc/silabs/silabs_sim3/
labels:
- "platform: Silabs SiM3U"
description: >-
SiM3U SoCs, dts files, and related drivers. Boards based on SiM3U SoCs.
Intel Platforms (X86):
status: maintained
maintainers:
@@ -3549,6 +3532,7 @@ Intel Platforms (Xtensa):
- andyross
- lyakh
- lgirdwood
- marc-hb
- kv2019i
- ceolin
- tmleman
@@ -3561,7 +3545,7 @@ Intel Platforms (Xtensa):
- soc/intel/intel_adsp/
- dts/xtensa/intel/
- tests/boards/intel_adsp/
- samples/boards/intel/adsp/
- samples/boards/intel_adsp/
- dts/bindings/*/intel,adsp*
- scripts/west_commands/runners/intel_adsp.py
labels:
@@ -3604,8 +3588,8 @@ NXP Drivers:
status: maintained
maintainers:
- dleach02
- mmahadevan108
collaborators:
- mmahadevan108
- danieldegrasse
- decsny
- manuargue
@@ -3641,8 +3625,8 @@ NXP Platforms (MCU):
status: maintained
maintainers:
- dleach02
- mmahadevan108
collaborators:
- mmahadevan108
- danieldegrasse
- DerekSnell
- yvanderv
@@ -3663,8 +3647,6 @@ NXP Platforms (MCU):
- soc/nxp/mcx/
- dts/arm/nxp/
- samples/boards/nxp*/
files-exclude:
- dts/arm/nxp/nxp_imx*
files-regex-exclude:
- .*s32.*
labels:
@@ -3689,7 +3671,7 @@ NXP Platforms (S32):
- drivers/misc/*nxp_s32*/
- dts/bindings/*/nxp,s32*
- dts/arm/nxp/*s32*
- samples/boards/nxp/s32/
- samples/boards/nxp_s32/
- include/zephyr/dt-bindings/*/nxp-s32*
- include/zephyr/dt-bindings/*/nxp_s32*
- include/zephyr/drivers/*/*nxp_s32*
@@ -3706,10 +3688,10 @@ NXP Platforms (MPU):
- dbaluta
- iuliana-prodan
- danieldegrasse
- decsny
- yvanderv
files:
- dts/arm64/nxp/
- dts/arm/nxp/nxp_imx*
- soc/nxp/imx/
- soc/nxp/layerscape/
files-regex:
@@ -3796,7 +3778,7 @@ nRF Platforms:
- drivers/*/*nrf*.c
- drivers/*/*nordic*/
- soc/nordic/
- samples/boards/nordic/
- samples/boards/nrf/
- dts/*/nordic/
- dts/bindings/*/nordic,*
- tests/drivers/*/*nrf*/
@@ -3921,7 +3903,7 @@ STM32 Platforms:
- dts/arm/st/
- dts/bindings/*/*stm32*
- soc/st/stm32/
- samples/boards/st/
- samples/boards/stm32/
labels:
- "platform: STM32"
description: >-
@@ -3936,8 +3918,6 @@ Espressif Platforms:
- LucasTambor
- marekmatej
- uLipe
- raffarost
- wmrsouza
files:
- drivers/*/*esp32*.c
- boards/espressif/
@@ -3945,8 +3925,8 @@ Espressif Platforms:
- dts/xtensa/espressif/
- dts/riscv/espressif/
- dts/bindings/*/*esp32*
- samples/boards/espressif/
- tests/boards/espressif/
- samples/boards/esp32*/
- tests/boards/espressif_esp32/
- drivers/*/*esp32*/
labels:
- "platform: ESP32"
@@ -4071,7 +4051,7 @@ LiteX Platforms:
- dts/bindings/*/litex*
- dts/riscv/riscv32-litex-vexriscv.dtsi
- include/zephyr/drivers/*/*litex*
- samples/boards/enjoydigital/litex/
- samples/boards/litex/
- samples/drivers/*litex/
- soc/litex/
labels:
@@ -4350,7 +4330,6 @@ West:
- mbolivar-ampere
- carlescufi
- swinslow
- pdgendt
files:
- scripts/west-commands.yml
- scripts/west_commands/
@@ -4359,15 +4338,6 @@ West:
labels:
- "area: West"
"West project: reqmgmt":
status: maintained
maintainers:
- nashif
- simhein
files: []
labels:
- "area: Requirements"
"West project: acpica":
status: maintained
maintainers:
@@ -4668,11 +4638,6 @@ West:
collaborators:
- hubertmis
- nordic-krch
- krish2718
- sachinthegreen
- udaynordic
- rajb9
- srkanordic
files:
- modules/hal_nordic/
labels:
@@ -4691,8 +4656,8 @@ West:
status: maintained
maintainers:
- dleach02
- mmahadevan108
collaborators:
- mmahadevan108
- danieldegrasse
- manuargue
- PetervdPerk-NXP
@@ -4757,7 +4722,6 @@ West:
- sateeshkotapati
- yonsch
- mnkp
- rettichschnidi
files:
- modules/Kconfig.silabs
labels:
@@ -5033,6 +4997,7 @@ West:
- nashif
- lyakh
- lgirdwood
- marc-hb
files:
- modules/Kconfig.sof
labels:
@@ -5313,7 +5278,6 @@ zbus:
- lyakh
- pillo79
files:
- cmake/llext-edk.cmake
- samples/subsys/llext/
- include/zephyr/llext/
- tests/subsys/llext/

View File

@@ -10,9 +10,15 @@
</p>
</a>
<a href="https://bestpractices.coreinfrastructure.org/projects/74"><img src="https://bestpractices.coreinfrastructure.org/projects/74/badge"></a>
<a href="https://scorecard.dev/viewer/?uri=github.com/zephyrproject-rtos/zephyr"><img src="https://api.securityscorecards.dev/projects/github.com/zephyrproject-rtos/zephyr/badge"></a>
<a href="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml?query=branch%3Amain"><img src="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml/badge.svg?event=push"></a>
<a href="https://bestpractices.coreinfrastructure.org/projects/74">
<img src="https://bestpractices.coreinfrastructure.org/projects/74/badge">
</a>
<a href="https://scorecard.dev/viewer/?uri=github.com/zephyrproject-rtos/zephyr">
<img src="https://api.securityscorecards.dev/projects/github.com/zephyrproject-rtos/zephyr/badge">
</a>
<a href="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml?query=branch%3Amain">
<img src="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml/badge.svg?event=push">
</a>
The Zephyr Project is a scalable real-time operating system (RTOS) supporting

View File

@@ -53,8 +53,6 @@ config ARM64
select IRQ_OFFLOAD_NESTED if IRQ_OFFLOAD
select BARRIER_OPERATIONS_ARCH
select ARCH_HAS_DIRECTED_IPIS
select ARCH_HAS_DEMAND_PAGING
select ARCH_HAS_DEMAND_MAPPING
help
ARM64 (AArch64) architecture
@@ -83,7 +81,6 @@ config X86
select ARCH_IS_SET
select ATOMIC_OPERATIONS_BUILTIN
select ARCH_SUPPORTS_COREDUMP
select ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
select ARCH_SUPPORTS_ROM_START if !X86_64
select CPU_HAS_MMU
select ARCH_MEM_DOMAIN_DATA if USERSPACE && !X86_COMMON_PAGE_TABLE
@@ -92,14 +89,12 @@ config X86
select ARCH_HAS_TIMING_FUNCTIONS
select ARCH_HAS_THREAD_LOCAL_STORAGE
select ARCH_HAS_DEMAND_PAGING if !X86_64
select ARCH_HAS_DEMAND_MAPPING if ARCH_HAS_DEMAND_PAGING
select IRQ_OFFLOAD_NESTED if IRQ_OFFLOAD
select NEED_LIBC_MEM_PARTITION if USERSPACE && TIMING_FUNCTIONS \
&& !BOARD_HAS_TIMING_FUNCTIONS \
&& !SOC_HAS_TIMING_FUNCTIONS
select ARCH_HAS_STACK_CANARIES_TLS
select ARCH_SUPPORTS_MEM_MAPPED_STACKS if X86_MMU && !DEMAND_PAGING
select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
help
x86 architecture
@@ -116,18 +111,17 @@ config RISCV
bool
select ARCH_IS_SET
select ARCH_SUPPORTS_COREDUMP
select ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
select ARCH_SUPPORTS_ROM_START if !SOC_FAMILY_ESPRESSIF_ESP32
select ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
select ARCH_HAS_CODE_DATA_RELOCATION
select ARCH_HAS_THREAD_LOCAL_STORAGE
select ARCH_HAS_STACKWALK
select IRQ_OFFLOAD_NESTED if IRQ_OFFLOAD
select USE_SWITCH_SUPPORTED
select USE_SWITCH
select SCHED_IPI_SUPPORTED if SMP
select ARCH_HAS_DIRECTED_IPIS
select BARRIER_OPERATIONS_BUILTIN
select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
imply XIP
help
RISCV architecture
@@ -142,7 +136,6 @@ config XTENSA
select ARCH_MEM_DOMAIN_DATA if USERSPACE
select ARCH_HAS_DIRECTED_IPIS
select THREAD_STACK_INFO
select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
help
Xtensa architecture
@@ -153,7 +146,6 @@ config ARCH_POSIX
select ARCH_HAS_CUSTOM_SWAP_TO_MAIN
select ARCH_HAS_CUSTOM_BUSY_WAIT
select ARCH_HAS_THREAD_ABORT
select ARCH_HAS_THREAD_NAME_HOOK
select NATIVE_BUILD
select HAS_COVERAGE_SUPPORT
select BARRIER_OPERATIONS_BUILTIN
@@ -189,9 +181,8 @@ config BIG_ENDIAN
Little-endian architecture is the default and should leave this option
unselected. This option is selected by arch/$ARCH/Kconfig,
soc/**/Kconfig, or boards/**/Kconfig and the user should generally avoid
modifying it. The option is used to select linker script OUTPUT_FORMAT,
the toolchain flags (TOOLCHAIN_C_FLAGS, TOOLCHAIN_LD_FLAGS), and command
line option for gen_isr_tables.py.
modifying it. The option is used to select linker script OUTPUT_FORMAT
and command line option for gen_isr_tables.py.
config LITTLE_ENDIAN
# Hidden Kconfig option representing the default little-endian architecture
@@ -423,17 +414,10 @@ config FRAME_POINTER
Select Y here to gain precise stack traces at the expense of slightly
increased size and decreased speed.
config ARCH_STACKWALK
bool "Compile the stack walking function"
default y
depends on ARCH_HAS_STACKWALK
help
Select Y here to compile the `arch_stack_walk()` function
config ARCH_STACKWALK_MAX_FRAMES
int "Max depth for stack walk function"
default 8
depends on ARCH_STACKWALK
depends on ARCH_HAS_STACKWALK
help
Depending on implementation, this can place a hard limit on the depths of the stack
for the stack walk function to examine.
@@ -615,14 +599,6 @@ config SIMPLIFIED_EXCEPTION_CODES
down to the generic K_ERR_CPU_EXCEPTION, which makes testing code
much more portable.
config EMPTY_IRQ_SPURIOUS
bool "Create empty spurious interrupt handler"
depends on ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
help
This option changes body of spurious interrupt handler. When enabled,
handler contains only an infinite while loop, when disabled, handler
contains the whole Zephyr fault handling procedure.
endmenu # Interrupt configuration
config INIT_ARCH_HW_AT_BOOT
@@ -682,24 +658,23 @@ config ARCH_SUPPORTS_COREDUMP
config ARCH_SUPPORTS_COREDUMP_THREADS
bool
config ARCH_SUPPORTS_COREDUMP_PRIV_STACKS
bool
config ARCH_SUPPORTS_ARCH_HW_INIT
bool
config ARCH_SUPPORTS_ROM_START
bool
config ARCH_SUPPORTS_EMPTY_IRQ_SPURIOUS
bool
config ARCH_HAS_EXTRA_EXCEPTION_INFO
bool
config ARCH_HAS_GDBSTUB
bool
config ARCH_HAS_STACKWALK
bool
help
This is selected when the architecture implemented the arch_stack_walk() API.
config ARCH_HAS_COHERENCE
bool
help
@@ -723,11 +698,6 @@ config ARCH_SUPPORTS_MEM_MAPPED_STACKS
help
Select when the architecture supports memory mapped stacks.
config ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET
bool
help
Select when the architecture implements arch_thread_priv_stack_space_get().
#
# Other architecture related options
#
@@ -793,13 +763,6 @@ config ARCH_HAS_DEMAND_PAGING
This hidden configuration should be selected by the architecture if
demand paging is supported.
config ARCH_HAS_DEMAND_MAPPING
bool
help
This hidden configuration should be selected by the architecture if
demand paging is supported and arch_mem_map() supports
K_MEM_MAP_UNPAGED.
config ARCH_HAS_RESERVED_PAGE_FRAMES
bool
help
@@ -825,7 +788,7 @@ config CPU_CACHE_INCOHERENT
help
This hidden configuration should be selected when the CPU has
incoherent cache. This applies to intra-CPU multiprocessing
incoherence and makes only sense when MP_MAX_NUM_CPUS > 1.
incoherence and makes only sense when MP_NUM_CPUS > 1.
config CPU_HAS_ICACHE
bool
@@ -1031,7 +994,7 @@ config CACHE_DOUBLEMAP
point to the same cached/uncached memory at different locations.
This applies to intra-CPU multiprocessing incoherence and makes only
sense when MP_MAX_NUM_CPUS > 1.
sense when MP_NUM_CPUS > 1.
config CACHE_MANAGEMENT
bool "Cache management features"

View File

@@ -374,9 +374,7 @@ config ARC_EXCEPTION_STACK_SIZE
endmenu
config ARC_EARLY_SOC_INIT
bool "Make early stage SoC-specific initialization [DEPRECATED]"
select SOC_RESET_HOOK
select DEPRECATED
bool "Make early stage SoC-specific initialization"
help
Call SoC per-core setup code on early stage initialization
(before C runtime initialization). Setup code is called in form of

View File

@@ -227,8 +227,4 @@ static int init_dcache(void)
return 0;
}
void arch_cache_init(void)
{
init_dcache();
}
SYS_INIT(init_dcache, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

View File

@@ -54,7 +54,7 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
}
/* need to be executed on every core in the system */
void arch_irq_offload_init(void)
int arc_irq_offload_init(void)
{
IRQ_CONNECT(IRQ_OFFLOAD_LINE, IRQ_OFFLOAD_PRIO, arc_irq_offload_handler, NULL, 0);
@@ -64,4 +64,8 @@ void arch_irq_offload_init(void)
* with generic irq_enable() but via z_arc_v2_irq_unit_int_enable().
*/
z_arc_v2_irq_unit_int_enable(IRQ_OFFLOAD_LINE);
return 0;
}
SYS_INIT(arc_irq_offload_init, POST_KERNEL, 0);

View File

@@ -238,7 +238,7 @@ int arc_core_mpu_buffer_validate(const void *addr, size_t size, int write)
* This function provides the default configuration mechanism for the Memory
* Protection Unit (MPU).
*/
void arc_mpu_init(void)
static int arc_mpu_init(void)
{
uint32_t num_regions = get_num_regions();
@@ -246,6 +246,7 @@ void arc_mpu_init(void)
if (mpu_config.num_regions > num_regions) {
__ASSERT(0, "Request to configure: %u regions (supported: %u)\n",
mpu_config.num_regions, num_regions);
return -EINVAL;
}
/* Disable MPU */
@@ -277,7 +278,10 @@ void arc_mpu_init(void)
/* Enable MPU */
arc_core_mpu_enable();
return 0;
}
SYS_INIT(arc_mpu_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
#endif /* ZEPHYR_ARCH_ARC_CORE_MPU_ARC_MPU_COMMON_INTERNAL_H_ */

View File

@@ -814,7 +814,7 @@ int arc_core_mpu_buffer_validate(const void *addr, size_t size, int write)
* This function provides the default configuration mechanism for the Memory
* Protection Unit (MPU).
*/
void arc_mpu_init(void)
static int arc_mpu_init(void)
{
uint32_t num_regions;
uint32_t i;
@@ -826,7 +826,7 @@ void arc_mpu_init(void)
__ASSERT(0,
"Request to configure: %u regions (supported: %u)\n",
mpu_config.num_regions, num_regions);
return;
return -EINVAL;
}
static_regions_num = 0U;
@@ -851,7 +851,7 @@ void arc_mpu_init(void)
MPU_DYNAMIC_REGION_AREAS_NUM) {
LOG_ERR("not enough dynamic regions %d",
dynamic_regions_num);
return;
return -EINVAL;
}
dyn_reg_info[dynamic_regions_num].index = i;
@@ -886,8 +886,10 @@ void arc_mpu_init(void)
/* Enable MPU */
arc_core_mpu_enable();
return;
return 0;
}
SYS_INIT(arc_mpu_init, PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
#endif /* ZEPHYR_ARCH_ARC_CORE_MPU_ARC_MPU_V4_INTERNAL_H_ */

View File

@@ -23,8 +23,6 @@
#include <zephyr/arch/arc/cluster.h>
#include <zephyr/kernel_structs.h>
#include <kernel_internal.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
/* XXX - keep for future use in full-featured cache APIs */
#if 0
@@ -115,9 +113,6 @@ static void dev_state_zero(void)
#endif
extern FUNC_NORETURN void z_cstart(void);
extern void arc_mpu_init(void);
extern void arc_secureshield_init(void);
/**
* @brief Prepare to and run C code
*
@@ -126,10 +121,6 @@ extern void arc_secureshield_init(void);
void z_prep_c(void)
{
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
#ifdef CONFIG_ISA_ARCV3
arc_cluster_scm_enable();
#endif
@@ -139,15 +130,6 @@ void z_prep_c(void)
dev_state_zero();
#endif
z_data_copy();
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
#ifdef CONFIG_ARC_MPU
arc_mpu_init();
#endif
#ifdef CONFIG_ARC_SECURE_FIRMWARE
arc_secureshield_init();
#endif
z_cstart();
CODE_UNREACHABLE;
}

View File

@@ -16,9 +16,8 @@
#include <zephyr/arch/cpu.h>
#include <swap_macros.h>
#include <zephyr/arch/arc/asm-compat/assembler.h>
#if defined(CONFIG_SOC_RESET_HOOK)
GTEXT(soc_reset_hook)
#ifdef CONFIG_ARC_EARLY_SOC_INIT
#include <soc_ctrl.h>
#endif
GDATA(z_interrupt_stacks)
@@ -113,8 +112,8 @@ done_icache_invalidate:
done_dcache_invalidate:
#ifdef CONFIG_SOC_RESET_HOOK
bl soc_reset_hook
#ifdef CONFIG_ARC_EARLY_SOC_INIT
soc_early_asm_init_percpu
#endif
_dsp_extension_probe

View File

@@ -48,7 +48,7 @@ static void sjli_table_init(void)
/*
* @brief initialization of secureshield related functions.
*/
void arc_secureshield_init(void)
static int arc_secureshield_init(void)
{
sjli_table_init();
@@ -60,4 +60,9 @@ void arc_secureshield_init(void)
*
*/
__asm__ volatile("sflag 0x20");
return 0;
}
SYS_INIT(arc_secureshield_init, PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

View File

@@ -9,9 +9,11 @@
#ifdef CONFIG_IRQ_OFFLOAD
int arc_irq_offload_init(const struct device *unused);
static inline void arc_irq_offload_init_smp(void)
{
arch_irq_offload_init();
arc_irq_offload_init(NULL);
}
#else

View File

@@ -166,14 +166,11 @@ config RUNTIME_NMI
needed, enable this option and attach it via z_arm_nmi_set_handler().
config PLATFORM_SPECIFIC_INIT
bool "Platform (SOC) specific startup hook [DEPRECATED]"
select DEPRECATED
bool "Platform (SOC) specific startup hook"
help
The platform specific initialization code (z_arm_platform_init) is
executed at the beginning of the startup code (__start).
This option is deprecated, use SOC_RESET_HOOK instead.
config FAULT_DUMP
int "Fault dump level"
default 2

View File

@@ -217,7 +217,3 @@ int arch_icache_flush_and_invd_range(void *start_addr, size_t size)
}
#endif
void arch_cache_init(void)
{
}

View File

@@ -147,9 +147,8 @@ bool z_arm_fault_undef_instruction_fp(void)
* the FP was already enabled then this was an actual undefined
* instruction.
*/
if (__get_FPEXC() & FPEXC_EN) {
if (__get_FPEXC() & FPEXC_EN)
return true;
}
__set_FPEXC(FPEXC_EN);
@@ -163,9 +162,8 @@ bool z_arm_fault_undef_instruction_fp(void)
struct __fpu_sf *spill_esf =
(struct __fpu_sf *)_current_cpu->fp_ctx;
if (spill_esf == NULL) {
if (spill_esf == NULL)
return false;
}
_current_cpu->fp_ctx = NULL;

View File

@@ -21,8 +21,6 @@
#include <zephyr/linker/linker-defs.h>
#include <zephyr/sys/barrier.h>
#include <zephyr/arch/arm/cortex_a_r/lib_helpers.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
#if defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
#include <cortex_a_r/stack.h>
@@ -149,9 +147,6 @@ extern FUNC_NORETURN void z_cstart(void);
*/
void z_prep_c(void)
{
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
/* Initialize tpidruro with our struct _cpu instance address */
write_tpidruro((uintptr_t)&_kernel.cpus[0]);
@@ -165,9 +160,6 @@ void z_prep_c(void)
z_arm_init_stacks();
#endif
z_arm_interrupt_init();
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
#ifdef CONFIG_ARM_MPU
z_arm_mpu_init();
z_arm_configure_static_mpu_regions();

View File

@@ -30,8 +30,8 @@ GDATA(z_arm_sys_stack)
GDATA(z_arm_fiq_stack)
GDATA(z_arm_abort_stack)
GDATA(z_arm_undef_stack)
#if defined(CONFIG_SOC_RESET_HOOK)
GTEXT(soc_reset_hook)
#if defined(CONFIG_PLATFORM_SPECIFIC_INIT)
GTEXT(z_arm_platform_init)
#endif
/**
@@ -305,9 +305,9 @@ _primary_core:
msr CPSR_c, #(MODE_SYS | I_BIT | F_BIT)
mov sp, r10
#if defined(CONFIG_SOC_RESET_HOOK)
#if defined(CONFIG_PLATFORM_SPECIFIC_INIT)
/* Execute platform-specific initialisation if applicable */
bl soc_reset_hook
bl z_arm_platform_init
#endif
#if defined(CONFIG_WDOG_INIT)

View File

@@ -110,7 +110,3 @@ int arch_icache_flush_and_invd_range(void *start_addr, size_t size)
{
return -ENOTSUP;
}
void arch_cache_init(void)
{
}

View File

@@ -58,7 +58,7 @@ BUILD_ASSERT(!(CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE &
(CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1)),
"the size of the partition must be power of 2");
int z_arm_debug_enable_null_pointer_detection(void)
static int z_arm_debug_enable_null_pointer_detection(void)
{
z_arm_dwt_init();
@@ -118,4 +118,7 @@ int z_arm_debug_enable_null_pointer_detection(void)
return 0;
}
SYS_INIT(z_arm_debug_enable_null_pointer_detection, PRE_KERNEL_1,
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
#endif /* CONFIG_NULL_POINTER_EXCEPTION_DETECTION_DWT */

View File

@@ -27,11 +27,6 @@ SECTION_FUNC(TEXT, arch_pm_s2ram_suspend)
* r0: address of the system_off function
*/
push {r4-r12, lr}
/* Move system_off to protected register. */
mov r4, r0
/* Store CPU context */
ldr r1, =_cpu_context
mrs r2, msp
@@ -76,7 +71,7 @@ SECTION_FUNC(TEXT, arch_pm_s2ram_suspend)
* Call the system_off function passed as parameter. This should never
* return.
*/
blx r4
blx r0
/*
* The system_off function returns here only when the powering off was
@@ -86,10 +81,9 @@ SECTION_FUNC(TEXT, arch_pm_s2ram_suspend)
/*
* Reset the marking of suspend to RAM, return is ignored.
*/
push {r0}
bl pm_s2ram_mark_check_and_clear
/* Move system_off back to r0 as return value */
mov r0, r4
pop {r0}
pop {r4-r12, lr}
bx lr
@@ -99,14 +93,11 @@ GTEXT(arch_pm_s2ram_resume)
SECTION_FUNC(TEXT, arch_pm_s2ram_resume)
/*
* Check if reset occurred after suspending to RAM.
* Store LR to ensure we can continue boot when we are not suspended
* to RAM. In addition to LR, R0 is pushed too, to ensure "SP mod 8 = 0",
* as stated by ARM rule 6.2.1.2 for AAPCS32.
*/
push {r0, lr}
push {lr}
bl pm_s2ram_mark_check_and_clear
cmp r0, #0x1
pop {r0, lr}
pop {lr}
beq resume
bx lr

View File

@@ -20,8 +20,6 @@
#include <kernel_internal.h>
#include <zephyr/linker/linker-defs.h>
#include <zephyr/sys/barrier.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
#if defined(__GNUC__)
/*
@@ -183,10 +181,6 @@ extern FUNC_NORETURN void z_cstart(void);
*/
void z_prep_c(void)
{
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
relocate_vector_table();
#if defined(CONFIG_CPU_HAS_FPU)
z_arm_floating_point_init();
@@ -199,13 +193,6 @@ void z_prep_c(void)
#else
z_arm_interrupt_init();
#endif /* CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
#ifdef CONFIG_NULL_POINTER_EXCEPTION_DETECTION_DWT
z_arm_debug_enable_null_pointer_detection();
#endif
z_cstart();
CODE_UNREACHABLE;
}

View File

@@ -24,8 +24,8 @@ GDATA(z_interrupt_stacks)
#if defined(CONFIG_DEBUG_THREAD_INFO)
GDATA(z_sys_post_kernel)
#endif
#if defined(CONFIG_SOC_RESET_HOOK)
GTEXT(soc_reset_hook)
#if defined(CONFIG_PLATFORM_SPECIFIC_INIT)
GTEXT(z_arm_platform_init)
#endif
#if defined(CONFIG_INIT_ARCH_HW_AT_BOOT)
GTEXT(z_arm_init_arch_hw_at_boot)
@@ -93,8 +93,8 @@ SECTION_SUBSEC_FUNC(TEXT,_reset_section,__start)
bl arch_pm_s2ram_resume
#endif /* CONFIG_PM_S2RAM */
#if defined(CONFIG_SOC_RESET_HOOK)
bl soc_reset_hook
#if defined(CONFIG_PLATFORM_SPECIFIC_INIT)
bl z_arm_platform_init
#endif
#if defined(CONFIG_INIT_ARCH_HW_AT_BOOT)

View File

@@ -12,34 +12,6 @@
LOG_MODULE_REGISTER(elf, CONFIG_LLEXT_LOG_LEVEL);
#define R_ARM_NONE 0
#define R_ARM_PC24 1
#define R_ARM_ABS32 2
#define R_ARM_REL32 3
#define R_ARM_COPY 20
#define R_ARM_GLOB_DAT 21
#define R_ARM_JUMP_SLOT 22
#define R_ARM_RELATIVE 23
#define R_ARM_CALL 28
#define R_ARM_JUMP24 29
#define R_ARM_TARGET1 38
#define R_ARM_V4BX 40
#define R_ARM_PREL31 42
#define R_ARM_MOVW_ABS_NC 43
#define R_ARM_MOVT_ABS 44
#define R_ARM_MOVW_PREL_NC 45
#define R_ARM_MOVT_PREL 46
#define R_ARM_ALU_PC_G0_NC 57
#define R_ARM_ALU_PC_G1_NC 59
#define R_ARM_LDR_PC_G2 63
#define R_ARM_THM_CALL 10
#define R_ARM_THM_JUMP24 30
#define R_ARM_THM_MOVW_ABS_NC 47
#define R_ARM_THM_MOVT_ABS 48
#define R_ARM_THM_MOVW_PREL_NC 49
#define R_ARM_THM_MOVT_PREL 50
#define OPCODE2ARMMEM(x) ((uint32_t)(x))
#define OPCODE2THM16MEM(x) ((uint16_t)(x))
#define MEM2ARMOPCODE(x) OPCODE2ARMMEM(x)

View File

@@ -42,7 +42,3 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
offload_routine = NULL;
k_sched_unlock();
}
void arch_irq_offload_init(void)
{
}

View File

@@ -9,7 +9,6 @@ zephyr_library_sources(
irq_init.c
irq_manage.c
prep_c.c
reboot.c
reset.S
reset.c
switch.S
@@ -29,7 +28,6 @@ if(${SRAM_LENGTH} GREATER 11 OR ${KERNEL_VM_LENGTH} GREATER 11)
zephyr_cc_option(-mcmodel=large)
endif()
zephyr_library_sources_ifdef(CONFIG_LLEXT elf.c)
zephyr_library_sources_ifdef(CONFIG_FPU_SHARING fpu.c fpu.S)
zephyr_library_sources_ifdef(CONFIG_ARM_MMU mmu.c mmu.S)
zephyr_library_sources_ifdef(CONFIG_ARM_MPU cortex_r/arm_mpu.c)

View File

@@ -161,14 +161,6 @@ config ARM64_EXCEPTION_STACK_TRACE
help
Internal config to enable runtime stack traces on fatal exceptions.
config ARCH_HAS_STACKWALK
bool
default y
depends on FRAME_POINTER
help
Internal config to indicate that the arch_stack_walk() API is implemented
and it can be enabled.
config ARM64_SAFE_EXCEPTION_STACK_SIZE
int "The stack size of the safe exception stack"
default 4096

View File

@@ -1,515 +0,0 @@
/*
* Copyright (c) 2024 BayLibre SAS
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/llext/elf.h>
#include <zephyr/llext/llext.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/byteorder.h>
LOG_MODULE_REGISTER(elf, CONFIG_LLEXT_LOG_LEVEL);
#define R_ARM_NONE 0
#define R_AARCH64_NONE 256
/* Static data relocations */
#define R_AARCH64_ABS64 257
#define R_AARCH64_ABS32 258
#define R_AARCH64_ABS16 259
#define R_AARCH64_PREL64 260
#define R_AARCH64_PREL32 261
#define R_AARCH64_PREL16 262
/* Static relocations */
#define R_AARCH64_MOVW_UABS_G0 263
#define R_AARCH64_MOVW_UABS_G0_NC 264
#define R_AARCH64_MOVW_UABS_G1 265
#define R_AARCH64_MOVW_UABS_G1_NC 266
#define R_AARCH64_MOVW_UABS_G2 267
#define R_AARCH64_MOVW_UABS_G2_NC 268
#define R_AARCH64_MOVW_UABS_G3 269
#define R_AARCH64_MOVW_SABS_G0 270
#define R_AARCH64_MOVW_SABS_G1 271
#define R_AARCH64_MOVW_SABS_G2 272
#define R_AARCH64_MOVW_PREL_G0 287
#define R_AARCH64_MOVW_PREL_G0_NC 288
#define R_AARCH64_MOVW_PREL_G1 289
#define R_AARCH64_MOVW_PREL_G1_NC 290
#define R_AARCH64_MOVW_PREL_G2 291
#define R_AARCH64_MOVW_PREL_G2_NC 292
#define R_AARCH64_MOVW_PREL_G3 293
#define R_AARCH64_LD_PREL_LO19 273
#define R_AARCH64_ADR_PREL_LO21 274
#define R_AARCH64_ADR_PREL_PG_HI21 275
#define R_AARCH64_ADR_PREL_PG_HI21_NC 276
#define R_AARCH64_ADD_ABS_LO12_NC 277
#define R_AARCH64_LDST8_ABS_LO12_NC 278
#define R_AARCH64_TSTBR14 279
#define R_AARCH64_CONDBR19 280
#define R_AARCH64_JUMP26 282
#define R_AARCH64_CALL26 283
#define R_AARCH64_LDST16_ABS_LO12_NC 284
#define R_AARCH64_LDST32_ABS_LO12_NC 285
#define R_AARCH64_LDST64_ABS_LO12_NC 286
#define R_AARCH64_LDST128_ABS_LO12_NC 299
/* Masks for immediate values */
#define AARCH64_MASK_IMM12 BIT_MASK(12)
#define AARCH64_MASK_IMM14 BIT_MASK(14)
#define AARCH64_MASK_IMM16 BIT_MASK(16)
#define AARCH64_MASK_IMM19 BIT_MASK(19)
#define AARCH64_MASK_IMM26 BIT_MASK(26)
/* MOV instruction helper symbols */
#define AARCH64_MASK_MOV_OPCODE BIT_MASK(8)
#define AARCH64_SHIFT_MOV_OPCODE (23)
#define AARCH64_SHIFT_MOV_IMM16 (5)
#define AARCH64_OPCODE_MOVN (0b00100101)
#define AARCH64_OPCODE_MOVZ (0b10100101)
/* ADR instruction helper symbols */
#define AARCH64_MASK_ADR_IMMLO BIT_MASK(2)
#define AARCH64_MASK_ADR_IMMHI BIT_MASK(19)
#define AARCH64_SHIFT_ADR_IMMLO (29)
#define AARCH64_SHIFT_ADR_IMMHI (5)
#define AARCH64_ADR_IMMLO_BITS (2)
#define AARCH64_PAGE(expr) ((expr) & ~0xFFF)
enum aarch64_reloc_type {
AARCH64_RELOC_TYPE_NONE,
AARCH64_RELOC_TYPE_ABS,
AARCH64_RELOC_TYPE_PREL,
AARCH64_RELOC_TYPE_PAGE,
};
/**
* @brief Function computing a relocation (X in AArch64 ELF).
*
* @param[in] reloc_type Type of relocation operation.
* @param[in] loc Address of an opcode to rewrite (P in AArch64 ELF).
* @param[in] sym_base_addr Address of the symbol referenced by relocation (S in AArch64 ELF).
* @param[in] addend Addend from RELA relocation.
*
* @return Result of the relocation operation (X in AArch64 ELF)
*/
static uint64_t reloc(enum aarch64_reloc_type reloc_type, uintptr_t loc, uintptr_t sym_base_addr,
int64_t addend)
{
switch (reloc_type) {
case AARCH64_RELOC_TYPE_ABS:
return sym_base_addr + addend;
case AARCH64_RELOC_TYPE_PREL:
return sym_base_addr + addend - loc;
case AARCH64_RELOC_TYPE_PAGE:
return AARCH64_PAGE(sym_base_addr + addend) - AARCH64_PAGE(loc);
case AARCH64_RELOC_TYPE_NONE:
return 0;
}
CODE_UNREACHABLE;
}
/**
* @brief Handler for static data relocations.
*
* @param[in] rel Relocation data provided by ELF
* @param[in] reloc_type Type of relocation operation.
* @param[in] loc Address of an opcode to rewrite (P in AArch64 ELF).
* @param[in] sym_base_addr Address of the symbol referenced by relocation (S in AArch64 ELF).
*
* @retval -ERANGE Relocation value overflow
* @retval 0 Successful relocation
*/
static int data_reloc_handler(elf_rela_t *rel, elf_word reloc_type, uintptr_t loc,
uintptr_t sym_base_addr)
{
int64_t x;
switch (reloc_type) {
case R_AARCH64_ABS64:
*(int64_t *)loc = reloc(AARCH64_RELOC_TYPE_ABS, loc, sym_base_addr, rel->r_addend);
break;
case R_AARCH64_ABS32:
x = reloc(AARCH64_RELOC_TYPE_ABS, loc, sym_base_addr, rel->r_addend);
if (x < 0 || x > UINT32_MAX) {
return -ERANGE;
}
*(uint32_t *)loc = (uint32_t)x;
break;
case R_AARCH64_ABS16:
x = reloc(AARCH64_RELOC_TYPE_ABS, loc, sym_base_addr, rel->r_addend);
if (x < 0 || x > UINT16_MAX) {
return -ERANGE;
}
*(uint16_t *)loc = (uint16_t)x;
break;
case R_AARCH64_PREL64:
*(int64_t *)loc = reloc(AARCH64_RELOC_TYPE_PREL, loc, sym_base_addr, rel->r_addend);
break;
case R_AARCH64_PREL32:
x = reloc(AARCH64_RELOC_TYPE_PREL, loc, sym_base_addr, rel->r_addend);
if (x < INT32_MIN || x > INT32_MAX) {
return -ERANGE;
}
*(int32_t *)loc = (int32_t)x;
break;
case R_AARCH64_PREL16:
x = reloc(AARCH64_RELOC_TYPE_PREL, loc, sym_base_addr, rel->r_addend);
if (x < INT16_MIN || x > INT16_MAX) {
return -ERANGE;
}
*(int16_t *)loc = (int16_t)x;
break;
default:
CODE_UNREACHABLE;
}
return 0;
}
/**
* @brief Handler for relocations using MOV* instructions.
*
* @param[in] rel Relocation data provided by ELF
* @param[in] reloc_type Type of relocation operation.
* @param[in] loc Address of an opcode to rewrite (P in AArch64 ELF).
* @param[in] sym_base_addr Address of the symbol referenced by relocation (S in AArch64 ELF).
*
* @retval -ERANGE Relocation value overflow
* @retval 0 Successful relocation
*/
static int movw_reloc_handler(elf_rela_t *rel, elf_word reloc_type, uintptr_t loc,
uintptr_t sym_base_addr)
{
int64_t x;
uint32_t imm;
int lsb = 0; /* LSB of X to be used */
bool is_movnz = false;
enum aarch64_reloc_type type = AARCH64_RELOC_TYPE_ABS;
uint32_t opcode = sys_le32_to_cpu(*(uint32_t *)loc);
switch (reloc_type) {
case R_AARCH64_MOVW_SABS_G0:
is_movnz = true;
case R_AARCH64_MOVW_UABS_G0_NC:
case R_AARCH64_MOVW_UABS_G0:
break;
case R_AARCH64_MOVW_SABS_G1:
is_movnz = true;
case R_AARCH64_MOVW_UABS_G1_NC:
case R_AARCH64_MOVW_UABS_G1:
lsb = 16;
break;
case R_AARCH64_MOVW_SABS_G2:
is_movnz = true;
case R_AARCH64_MOVW_UABS_G2_NC:
case R_AARCH64_MOVW_UABS_G2:
lsb = 32;
break;
case R_AARCH64_MOVW_UABS_G3:
lsb = 48;
break;
case R_AARCH64_MOVW_PREL_G0:
is_movnz = true;
case R_AARCH64_MOVW_PREL_G0_NC:
type = AARCH64_RELOC_TYPE_PREL;
break;
case R_AARCH64_MOVW_PREL_G1:
is_movnz = true;
case R_AARCH64_MOVW_PREL_G1_NC:
type = AARCH64_RELOC_TYPE_PREL;
lsb = 16;
break;
case R_AARCH64_MOVW_PREL_G2:
is_movnz = true;
case R_AARCH64_MOVW_PREL_G2_NC:
type = AARCH64_RELOC_TYPE_PREL;
lsb = 32;
break;
case R_AARCH64_MOVW_PREL_G3:
is_movnz = true;
type = AARCH64_RELOC_TYPE_PREL;
lsb = 48;
break;
default:
CODE_UNREACHABLE;
}
x = reloc(type, loc, sym_base_addr, rel->r_addend);
imm = x >> lsb;
/* Manipulate opcode for signed relocations. Result depends on sign of immediate value. */
if (is_movnz) {
opcode &= ~(AARCH64_MASK_MOV_OPCODE << AARCH64_SHIFT_MOV_OPCODE);
if (x >= 0) {
opcode |= (AARCH64_OPCODE_MOVN << AARCH64_SHIFT_MOV_OPCODE);
} else {
opcode |= (AARCH64_OPCODE_MOVZ << AARCH64_SHIFT_MOV_OPCODE);
/* Need to invert immediate value for MOVZ. */
imm = ~imm;
}
}
opcode &= ~(AARCH64_MASK_IMM16 << AARCH64_SHIFT_MOV_IMM16);
opcode |= (imm & AARCH64_MASK_IMM16) << AARCH64_SHIFT_MOV_IMM16;
*(uint32_t *)loc = sys_cpu_to_le32(opcode);
if (imm > UINT16_MAX) {
return -ERANGE;
}
return 0;
}
/**
* @brief Handler for static relocations except these related to MOV* instructions.
*
* @param[in] rel Relocation data provided by ELF
* @param[in] reloc_type Type of relocation operation.
* @param[in] loc Address of an opcode to rewrite (P in AArch64 ELF).
* @param[in] sym_base_addr Address of the symbol referenced by relocation (S in AArch64 ELF).
*
* @retval -ERANGE Relocation value overflow
* @retval 0 Successful relocation
*/
static int imm_reloc_handler(elf_rela_t *rel, elf_word reloc_type, uintptr_t loc,
uintptr_t sym_base_addr)
{
int lsb = 2; /* LSB of X to be used */
int len; /* bit length of immediate value */
int shift = 10; /* shift of the immediate in instruction encoding */
uint64_t imm;
uint32_t bitmask = AARCH64_MASK_IMM12;
int64_t x;
bool is_adr = false;
enum aarch64_reloc_type type = AARCH64_RELOC_TYPE_ABS;
uint32_t opcode = sys_le32_to_cpu(*(uint32_t *)loc);
switch (reloc_type) {
case R_AARCH64_ADD_ABS_LO12_NC:
case R_AARCH64_LDST8_ABS_LO12_NC:
lsb = 0;
len = 12;
break;
case R_AARCH64_LDST16_ABS_LO12_NC:
lsb = 1;
len = 11;
break;
case R_AARCH64_LDST32_ABS_LO12_NC:
len = 10;
break;
case R_AARCH64_LDST64_ABS_LO12_NC:
lsb = 3;
len = 9;
break;
case R_AARCH64_LDST128_ABS_LO12_NC:
lsb = 4;
len = 8;
break;
case R_AARCH64_LD_PREL_LO19:
case R_AARCH64_CONDBR19:
type = AARCH64_RELOC_TYPE_PREL;
bitmask = AARCH64_MASK_IMM19;
shift = 5;
len = 19;
break;
case R_AARCH64_ADR_PREL_LO21:
type = AARCH64_RELOC_TYPE_PREL;
is_adr = true;
lsb = 0;
len = 21;
break;
case R_AARCH64_TSTBR14:
type = AARCH64_RELOC_TYPE_PREL;
bitmask = AARCH64_MASK_IMM14;
shift = 5;
len = 14;
break;
case R_AARCH64_ADR_PREL_PG_HI21_NC:
case R_AARCH64_ADR_PREL_PG_HI21:
type = AARCH64_RELOC_TYPE_PAGE;
is_adr = true;
lsb = 12;
len = 21;
break;
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
type = AARCH64_RELOC_TYPE_PREL;
bitmask = AARCH64_MASK_IMM26;
shift = 0;
len = 26;
break;
default:
CODE_UNREACHABLE;
}
x = reloc(type, loc, sym_base_addr, rel->r_addend);
x >>= lsb;
imm = x & BIT_MASK(len);
/* ADR instruction has immediate value split into two fields. */
if (is_adr) {
uint32_t immlo, immhi;
immlo = (imm & AARCH64_MASK_ADR_IMMLO) << AARCH64_SHIFT_ADR_IMMLO;
imm >>= AARCH64_ADR_IMMLO_BITS;
immhi = (imm & AARCH64_MASK_ADR_IMMHI) << AARCH64_SHIFT_ADR_IMMHI;
imm = immlo | immhi;
shift = 0;
bitmask = ((AARCH64_MASK_ADR_IMMLO << AARCH64_SHIFT_ADR_IMMLO) |
(AARCH64_MASK_ADR_IMMHI << AARCH64_SHIFT_ADR_IMMHI));
}
opcode &= ~(bitmask << shift);
opcode |= (imm & bitmask) << shift;
*(uint32_t *)loc = sys_cpu_to_le32(opcode);
/* Mask X sign bit and upper bits. */
x = (int64_t)(x & ~BIT_MASK(len - 1)) >> (len - 1);
/* Incrementing X will either overflow and set it to 0 or
* set it 1. Any other case indicates that there was an overflow in relocation.
*/
if ((int64_t)x++ > 1) {
return -ERANGE;
}
return 0;
}
/**
* @brief Architecture specific function for relocating partially linked (static) elf
*
* Elf files contain a series of relocations described in a section. These relocation
* instructions are architecture specific and each architecture supporting extensions
* must implement this.
*
* The relocation codes for arm64 are well documented
* https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#relocation
*
* @param[in] rel Relocation data provided by ELF
* @param[in] loc Address of an opcode to rewrite (P in AArch64 ELF)
* @param[in] sym_base_addr Address of the symbol referenced by relocation (S in AArch64 ELF)
* @param[in] sym_name Name of symbol referenced by relocation
* @param[in] load_bias `.text` load address
* @retval 0 Success
* @retval -ENOTSUP Unsupported relocation
* @retval -ENOEXEC Invalid relocation
*/
int arch_elf_relocate(elf_rela_t *rel, uintptr_t loc, uintptr_t sym_base_addr, const char *sym_name,
uintptr_t load_bias)
{
int ret = 0;
bool overflow_check = true;
elf_word reloc_type = ELF_R_TYPE(rel->r_info);
switch (reloc_type) {
case R_ARM_NONE:
case R_AARCH64_NONE:
overflow_check = false;
break;
case R_AARCH64_ABS64:
case R_AARCH64_PREL64:
overflow_check = false;
case R_AARCH64_ABS16:
case R_AARCH64_ABS32:
case R_AARCH64_PREL16:
case R_AARCH64_PREL32:
ret = data_reloc_handler(rel, reloc_type, loc, sym_base_addr);
break;
case R_AARCH64_MOVW_UABS_G0_NC:
case R_AARCH64_MOVW_UABS_G1_NC:
case R_AARCH64_MOVW_UABS_G2_NC:
case R_AARCH64_MOVW_UABS_G3:
case R_AARCH64_MOVW_PREL_G0_NC:
case R_AARCH64_MOVW_PREL_G1_NC:
case R_AARCH64_MOVW_PREL_G2_NC:
case R_AARCH64_MOVW_PREL_G3:
overflow_check = false;
case R_AARCH64_MOVW_UABS_G0:
case R_AARCH64_MOVW_UABS_G1:
case R_AARCH64_MOVW_UABS_G2:
case R_AARCH64_MOVW_SABS_G0:
case R_AARCH64_MOVW_SABS_G1:
case R_AARCH64_MOVW_SABS_G2:
case R_AARCH64_MOVW_PREL_G0:
case R_AARCH64_MOVW_PREL_G1:
case R_AARCH64_MOVW_PREL_G2:
ret = movw_reloc_handler(rel, reloc_type, loc, sym_base_addr);
break;
case R_AARCH64_ADD_ABS_LO12_NC:
case R_AARCH64_LDST8_ABS_LO12_NC:
case R_AARCH64_LDST16_ABS_LO12_NC:
case R_AARCH64_LDST32_ABS_LO12_NC:
case R_AARCH64_LDST64_ABS_LO12_NC:
case R_AARCH64_LDST128_ABS_LO12_NC:
overflow_check = false;
case R_AARCH64_LD_PREL_LO19:
case R_AARCH64_ADR_PREL_LO21:
case R_AARCH64_TSTBR14:
case R_AARCH64_CONDBR19:
ret = imm_reloc_handler(rel, reloc_type, loc, sym_base_addr);
break;
case R_AARCH64_ADR_PREL_PG_HI21_NC:
overflow_check = false;
case R_AARCH64_ADR_PREL_PG_HI21:
ret = imm_reloc_handler(rel, reloc_type, loc, sym_base_addr);
break;
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
ret = imm_reloc_handler(rel, reloc_type, loc, sym_base_addr);
/* TODO Handle case when address exceeds +/- 128MB */
break;
default:
LOG_ERR("unknown relocation: %llu\n", reloc_type);
return -ENOEXEC;
}
if (overflow_check && ret == -ERANGE) {
LOG_ERR("sym '%s': relocation out of range (%#lx -> %#lx)\n", sym_name, loc,
sym_base_addr);
return -ENOEXEC;
}
return 0;
}

View File

@@ -21,8 +21,6 @@
#include <zephyr/sys/poweroff.h>
#include <kernel_arch_func.h>
#include "paging.h"
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
#ifdef CONFIG_ARM64_SAFE_EXCEPTION_STACK
@@ -196,13 +194,9 @@ static void esf_dump(const struct arch_esf *esf)
LOG_ERR("x16: 0x%016llx x17: 0x%016llx", esf->x16, esf->x17);
LOG_ERR("x18: 0x%016llx lr: 0x%016llx", esf->x18, esf->lr);
}
#endif /* CONFIG_EXCEPTION_DEBUG */
#ifdef CONFIG_ARCH_STACKWALK
typedef bool (*arm64_stacktrace_cb)(void *cookie, unsigned long addr, void *fp);
static void walk_stackframe(arm64_stacktrace_cb cb, void *cookie, const struct arch_esf *esf,
int max_frames)
#ifdef CONFIG_EXCEPTION_STACK_TRACE
static void esf_unwind(const struct arch_esf *esf)
{
/*
* For GCC:
@@ -224,61 +218,30 @@ static void walk_stackframe(arm64_stacktrace_cb cb, void *cookie, const struct a
* + +-----------------+
*/
uint64_t *fp;
uint64_t *fp = (uint64_t *) esf->fp;
unsigned int count = 0;
uint64_t lr;
if (esf != NULL) {
fp = (uint64_t *) esf->fp;
} else {
return;
}
for (int i = 0; (fp != NULL) && (i < max_frames); i++) {
LOG_ERR("");
for (int i = 0; (fp != NULL) && (i < CONFIG_EXCEPTION_STACK_TRACE_MAX_FRAMES); i++) {
lr = fp[1];
if (!cb(cookie, lr, fp)) {
break;
}
#ifdef CONFIG_SYMTAB
uint32_t offset = 0;
const char *name = symtab_find_symbol_name(lr, &offset);
LOG_ERR("backtrace %2d: fp: 0x%016llx lr: 0x%016llx [%s+0x%x]",
count++, (uint64_t) fp, lr, name, offset);
#else
LOG_ERR("backtrace %2d: fp: 0x%016llx lr: 0x%016llx",
count++, (uint64_t) fp, lr);
#endif
fp = (uint64_t *) fp[0];
}
}
void arch_stack_walk(stack_trace_callback_fn callback_fn, void *cookie,
const struct k_thread *thread, const struct arch_esf *esf)
{
ARG_UNUSED(thread);
walk_stackframe((arm64_stacktrace_cb)callback_fn, cookie, esf,
CONFIG_ARCH_STACKWALK_MAX_FRAMES);
}
#endif /* CONFIG_ARCH_STACKWALK */
#ifdef CONFIG_EXCEPTION_STACK_TRACE
static bool print_trace_address(void *arg, unsigned long lr, void *fp)
{
int *i = arg;
#ifdef CONFIG_SYMTAB
uint32_t offset = 0;
const char *name = symtab_find_symbol_name(lr, &offset);
LOG_ERR(" %d: fp: 0x%016llx lr: 0x%016lx [%s+0x%x]", (*i)++, (uint64_t)fp, lr, name,
offset);
#else
LOG_ERR(" %d: fp: 0x%016llx lr: 0x%016lx", (*i)++, (uint64_t)fp, lr);
#endif /* CONFIG_SYMTAB */
return true;
}
static void esf_unwind(const struct arch_esf *esf)
{
int i = 0;
LOG_ERR("");
LOG_ERR("call trace:");
walk_stackframe(print_trace_address, &i, esf, CONFIG_ARCH_STACKWALK_MAX_FRAMES);
LOG_ERR("");
}
#endif /* CONFIG_EXCEPTION_STACK_TRACE */
#endif
#endif /* CONFIG_EXCEPTION_DEBUG */
#ifdef CONFIG_ARM64_STACK_PROTECTION
static bool z_arm64_stack_corruption_check(struct arch_esf *esf, uint64_t esr, uint64_t far)
@@ -324,9 +287,8 @@ static bool z_arm64_stack_corruption_check(struct arch_esf *esf, uint64_t esr, u
static bool is_recoverable(struct arch_esf *esf, uint64_t esr, uint64_t far,
uint64_t elr)
{
if (!esf) {
if (!esf)
return false;
}
#ifdef CONFIG_USERSPACE
for (int i = 0; i < ARRAY_SIZE(exceptions); i++) {
@@ -375,12 +337,6 @@ void z_arm64_fatal_error(unsigned int reason, struct arch_esf *esf)
}
#endif
if (IS_ENABLED(CONFIG_DEMAND_PAGING) &&
reason != K_ERR_STACK_CHK_FAIL &&
z_arm64_do_demand_paging(esf, esr, far)) {
return;
}
if (GET_EL(el) != MODE_EL0) {
#ifdef CONFIG_EXCEPTION_DEBUG
bool dump_far = false;
@@ -389,9 +345,8 @@ void z_arm64_fatal_error(unsigned int reason, struct arch_esf *esf)
dump_esr(esr, &dump_far);
if (dump_far) {
if (dump_far)
LOG_ERR("FAR_ELn: 0x%016llx", far);
}
LOG_ERR("TPIDRRO: 0x%016llx", read_tpidrro_el0());
#endif /* CONFIG_EXCEPTION_DEBUG */

View File

@@ -23,7 +23,3 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
: [svid] "i" (_SVC_CALL_IRQ_OFFLOAD),
"r" (x0), "r" (x1));
}
void arch_irq_offload_init(void)
{
}

View File

@@ -11,7 +11,6 @@
#include <zephyr/device.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/kernel/mm/demand_paging.h>
#include <kernel_arch_func.h>
#include <kernel_arch_interface.h>
#include <kernel_internal.h>
@@ -22,10 +21,8 @@
#include <zephyr/linker/linker-defs.h>
#include <zephyr/spinlock.h>
#include <zephyr/sys/util.h>
#include <mmu.h>
#include "mmu.h"
#include "paging.h"
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
@@ -142,12 +139,6 @@ int arm64_mmu_tables_total_usage(void)
static inline bool is_free_desc(uint64_t desc)
{
return desc == 0;
}
static inline bool is_inval_desc(uint64_t desc)
{
/* invalid descriptors aren't necessarily free */
return (desc & PTE_DESC_TYPE_MASK) == PTE_INVALID_DESC;
}
@@ -212,10 +203,8 @@ static void debug_show_pte(uint64_t *pte, unsigned int level)
if (is_block_desc(*pte)) {
MMU_DEBUG("[Block] ");
} else if (!is_inval_desc(*pte)) {
MMU_DEBUG("[Page] ");
} else {
MMU_DEBUG("[paged-out] ");
MMU_DEBUG("[Page] ");
}
uint8_t mem_type = (*pte >> 2) & MT_TYPE_MASK;
@@ -227,7 +216,6 @@ static void debug_show_pte(uint64_t *pte, unsigned int level)
MMU_DEBUG((*pte & PTE_BLOCK_DESC_AP_ELx) ? "-ELx" : "-ELh");
MMU_DEBUG((*pte & PTE_BLOCK_DESC_PXN) ? "-PXN" : "-PX");
MMU_DEBUG((*pte & PTE_BLOCK_DESC_UXN) ? "-UXN" : "-UX");
MMU_DEBUG((*pte & PTE_SW_WRITABLE) ? "-WRITABLE" : "");
MMU_DEBUG("\n");
}
#else
@@ -243,15 +231,8 @@ static void set_pte_table_desc(uint64_t *pte, uint64_t *table, unsigned int leve
static void set_pte_block_desc(uint64_t *pte, uint64_t desc, unsigned int level)
{
if (level != XLAT_LAST_LEVEL) {
desc |= PTE_BLOCK_DESC;
} else if (!IS_ENABLED(CONFIG_DEMAND_PAGING) || (desc & PTE_BLOCK_DESC_AF) != 0) {
desc |= PTE_PAGE_DESC;
} else {
/*
* Demand paging configured and AF unset: leave the descriptor
* type to "invalid" as in arch_mem_page_out().
*/
if (desc) {
desc |= (level == XLAT_LAST_LEVEL) ? PTE_PAGE_DESC : PTE_BLOCK_DESC;
}
*pte = desc;
debug_show_pte(pte, level);
@@ -392,11 +373,6 @@ static void del_mapping(uint64_t *table, uintptr_t virt, size_t size,
continue;
}
if (step != level_size && is_block_desc(*pte)) {
/* need to split this block mapping */
expand_to_table(pte, level);
}
if (is_table_desc(*pte, level)) {
subtable = pte_desc_table(*pte);
del_mapping(subtable, virt, step, level + 1);
@@ -404,6 +380,12 @@ static void del_mapping(uint64_t *table, uintptr_t virt, size_t size,
continue;
}
dec_table_ref(subtable);
} else {
/*
* We assume that block mappings will be unmapped
* as a whole and not partially.
*/
__ASSERT(step == level_size, "");
}
/* free this entry */
@@ -675,8 +657,6 @@ static uint64_t get_region_desc(uint32_t attrs)
/* AP bits for Data access permission */
desc |= (attrs & MT_RW) ? PTE_BLOCK_DESC_AP_RW : PTE_BLOCK_DESC_AP_RO;
desc |= (IS_ENABLED(CONFIG_DEMAND_PAGING) && (attrs & MT_RW)) ?
PTE_SW_WRITABLE : 0;
/* Mirror permissions to EL0 */
desc |= (attrs & MT_RW_AP_ELx) ?
@@ -684,11 +664,6 @@ static uint64_t get_region_desc(uint32_t attrs)
/* the access flag */
desc |= PTE_BLOCK_DESC_AF;
if (IS_ENABLED(CONFIG_DEMAND_PAGING) && (attrs & MT_PAGED_OUT) != 0) {
/* set it up for demand paging like arch_mem_page_out() */
desc &= ~PTE_BLOCK_DESC_AF;
desc |= PTE_BLOCK_DESC_AP_RO;
}
/* memory attribute index field */
mem_type = MT_TYPE(attrs);
@@ -711,20 +686,17 @@ static uint64_t get_region_desc(uint32_t attrs)
case MT_NORMAL_NC:
case MT_NORMAL:
/* Make Normal RW memory as execute never */
if ((attrs & MT_RW) || (attrs & MT_P_EXECUTE_NEVER)) {
if ((attrs & MT_RW) || (attrs & MT_P_EXECUTE_NEVER))
desc |= PTE_BLOCK_DESC_PXN;
}
if (((attrs & MT_RW) && (attrs & MT_RW_AP_ELx)) ||
(attrs & MT_U_EXECUTE_NEVER)) {
(attrs & MT_U_EXECUTE_NEVER))
desc |= PTE_BLOCK_DESC_UXN;
}
if (mem_type == MT_NORMAL) {
if (mem_type == MT_NORMAL)
desc |= PTE_BLOCK_DESC_INNER_SHARE;
} else {
else
desc |= PTE_BLOCK_DESC_OUTER_SHARE;
}
}
/* non-Global bit */
@@ -783,12 +755,6 @@ static void invalidate_tlb_all(void)
: : : "memory");
}
static inline void invalidate_tlb_page(uintptr_t virt)
{
/* to be refined */
invalidate_tlb_all();
}
/* zephyr execution regions with appropriate attributes */
struct arm_mmu_flat_range {
@@ -878,9 +844,8 @@ static void setup_page_tables(struct arm_mmu_ptables *ptables)
uintptr_t max_va = 0, max_pa = 0;
MMU_DEBUG("xlat tables:\n");
for (index = 0U; index < CONFIG_MAX_XLAT_TABLES; index++) {
for (index = 0U; index < CONFIG_MAX_XLAT_TABLES; index++)
MMU_DEBUG("%d: %p\n", index, xlat_tables + index * Ln_XLAT_NUM_ENTRIES);
}
for (index = 0U; index < mmu_config.num_regions; index++) {
region = &mmu_config.mmu_regions[index];
@@ -1102,10 +1067,6 @@ static int __arch_mem_map(void *virt, uintptr_t phys, size_t size, uint32_t flag
entry_flags |= MT_RW_AP_ELx;
}
if (IS_ENABLED(CONFIG_DEMAND_PAGING) && (flags & K_MEM_MAP_UNPAGED) != 0) {
entry_flags |= MT_PAGED_OUT;
}
return add_map(ptables, "generic", phys, (uintptr_t)virt, size, entry_flags);
}
@@ -1368,9 +1329,8 @@ void z_arm64_thread_mem_domains_init(struct k_thread *incoming)
{
struct arm_mmu_ptables *ptables;
if ((incoming->base.user_options & K_USER) == 0) {
if ((incoming->base.user_options & K_USER) == 0)
return;
}
ptables = incoming->arch.ptables;
@@ -1386,311 +1346,3 @@ void z_arm64_swap_mem_domains(struct k_thread *incoming)
}
#endif /* CONFIG_USERSPACE */
#ifdef CONFIG_DEMAND_PAGING
static uint64_t *get_pte_location(struct arm_mmu_ptables *ptables,
uintptr_t virt)
{
uint64_t *pte;
uint64_t *table = ptables->base_xlat_table;
unsigned int level = BASE_XLAT_LEVEL;
for (;;) {
pte = &table[XLAT_TABLE_VA_IDX(virt, level)];
if (level == XLAT_LAST_LEVEL) {
return pte;
}
if (is_table_desc(*pte, level)) {
level++;
table = pte_desc_table(*pte);
continue;
}
/* anything else is unexpected */
return NULL;
}
}
void arch_mem_page_out(void *addr, uintptr_t location)
{
uintptr_t virt = (uintptr_t)addr;
uint64_t *pte = get_pte_location(&kernel_ptables, virt);
uint64_t desc;
__ASSERT(pte != NULL, "");
desc = *pte;
/* mark the entry invalid to the hardware */
desc &= ~PTE_DESC_TYPE_MASK;
desc |= PTE_INVALID_DESC;
/* store the location token in place of the physical address */
__ASSERT((location & ~PTE_PHYSADDR_MASK) == 0, "");
desc &= ~PTE_PHYSADDR_MASK;
desc |= location;
/*
* The location token may be 0. Make sure the whole descriptor
* doesn't end up being zero as this would be seen as a free entry.
*/
desc |= PTE_BLOCK_DESC_AP_RO;
*pte = desc;
MMU_DEBUG("page_out: virt=%#lx location=%#lx\n", virt, location);
debug_show_pte(pte, XLAT_LAST_LEVEL);
sync_domains(virt, CONFIG_MMU_PAGE_SIZE, "page_out");
invalidate_tlb_page(virt);
}
void arch_mem_page_in(void *addr, uintptr_t phys)
{
uintptr_t virt = (uintptr_t)addr;
uint64_t *pte = get_pte_location(&kernel_ptables, virt);
uint64_t desc;
__ASSERT((phys & ~PTE_PHYSADDR_MASK) == 0, "");
__ASSERT(pte != NULL, "");
desc = *pte;
__ASSERT(!is_free_desc(desc), "");
/* mark the entry valid again to the hardware */
desc &= ~PTE_DESC_TYPE_MASK;
desc |= PTE_PAGE_DESC;
/* store the physical address */
desc &= ~PTE_PHYSADDR_MASK;
desc |= phys;
/* mark as clean */
desc |= PTE_BLOCK_DESC_AP_RO;
/* and make it initially unaccessible to track unaccessed pages */
desc &= ~PTE_BLOCK_DESC_AF;
*pte = desc;
MMU_DEBUG("page_in: virt=%#lx phys=%#lx\n", virt, phys);
debug_show_pte(pte, XLAT_LAST_LEVEL);
sync_domains(virt, CONFIG_MMU_PAGE_SIZE, "page_in");
invalidate_tlb_page(virt);
}
enum arch_page_location arch_page_location_get(void *addr, uintptr_t *location)
{
uintptr_t virt = (uintptr_t)addr;
uint64_t *pte = get_pte_location(&kernel_ptables, virt);
uint64_t desc;
enum arch_page_location status;
if (!pte) {
return ARCH_PAGE_LOCATION_BAD;
}
desc = *pte;
if (is_free_desc(desc)) {
return ARCH_PAGE_LOCATION_BAD;
}
switch (desc & PTE_DESC_TYPE_MASK) {
case PTE_PAGE_DESC:
status = ARCH_PAGE_LOCATION_PAGED_IN;
break;
case PTE_INVALID_DESC:
status = ARCH_PAGE_LOCATION_PAGED_OUT;
break;
default:
return ARCH_PAGE_LOCATION_BAD;
}
*location = desc & PTE_PHYSADDR_MASK;
return status;
}
uintptr_t arch_page_info_get(void *addr, uintptr_t *phys, bool clear_accessed)
{
uintptr_t virt = (uintptr_t)addr;
uint64_t *pte = get_pte_location(&kernel_ptables, virt);
uint64_t desc;
uintptr_t status = 0;
if (!pte) {
return ARCH_DATA_PAGE_NOT_MAPPED;
}
desc = *pte;
if (is_free_desc(desc)) {
return ARCH_DATA_PAGE_NOT_MAPPED;
}
switch (desc & PTE_DESC_TYPE_MASK) {
case PTE_PAGE_DESC:
status |= ARCH_DATA_PAGE_LOADED;
break;
case PTE_INVALID_DESC:
/* page not loaded */
break;
default:
return ARCH_DATA_PAGE_NOT_MAPPED;
}
if (phys) {
*phys = desc & PTE_PHYSADDR_MASK;
}
if ((status & ARCH_DATA_PAGE_LOADED) == 0) {
return status;
}
if ((desc & PTE_BLOCK_DESC_AF) != 0) {
status |= ARCH_DATA_PAGE_ACCESSED;
}
if ((desc & PTE_BLOCK_DESC_AP_RO) == 0) {
status |= ARCH_DATA_PAGE_DIRTY;
}
if (clear_accessed) {
desc &= ~PTE_BLOCK_DESC_AF;
*pte = desc;
MMU_DEBUG("page_info: virt=%#lx (clearing AF)\n", virt);
debug_show_pte(pte, XLAT_LAST_LEVEL);
sync_domains(virt, CONFIG_MMU_PAGE_SIZE, "unaccessible");
invalidate_tlb_page(virt);
}
return status;
}
#define MT_SCRATCH (MT_NORMAL | MT_P_RW_U_NA | MT_DEFAULT_SECURE_STATE)
void arch_mem_scratch(uintptr_t phys)
{
uintptr_t virt = (uintptr_t)K_MEM_SCRATCH_PAGE;
size_t size = CONFIG_MMU_PAGE_SIZE;
int ret = add_map(&kernel_ptables, "scratch", phys, virt, size, MT_SCRATCH);
if (ret) {
LOG_ERR("add_map() returned %d", ret);
} else {
sync_domains(virt, size, "scratch");
invalidate_tlb_page(virt);
}
}
static bool do_mem_page_fault(struct arch_esf *esf, uintptr_t virt)
{
/*
* The k_mem_page_fault() code expects to be called with IRQs enabled
* if the fault happened in a context where IRQs were enabled.
*/
if (arch_irq_unlocked(esf->spsr)) {
enable_irq();
}
bool ok = k_mem_page_fault((void *)virt);
disable_irq();
return ok;
}
/* Called from the fault handler. Returns true if the fault is resolved. */
bool z_arm64_do_demand_paging(struct arch_esf *esf, uint64_t esr, uint64_t far)
{
uintptr_t virt = far;
uint64_t *pte, desc;
uintptr_t phys;
/* filter relevant exceptions */
switch (GET_ESR_EC(esr)) {
case 0x21: /* insn abort from current EL */
case 0x25: /* data abort from current EL */
break;
default:
return false;
}
/* make sure the fault happened in the expected range */
if (!IN_RANGE(virt,
(uintptr_t)K_MEM_VIRT_RAM_START,
((uintptr_t)K_MEM_VIRT_RAM_END - 1))) {
return false;
}
virt = ROUND_DOWN(virt, CONFIG_MMU_PAGE_SIZE);
pte = get_pte_location(&kernel_ptables, virt);
if (!pte) {
/* page mapping doesn't exist, let the core code do its thing */
return do_mem_page_fault(esf, virt);
}
desc = *pte;
if ((desc & PTE_DESC_TYPE_MASK) != PTE_PAGE_DESC) {
/* page is not loaded/mapped */
return do_mem_page_fault(esf, virt);
}
/*
* From this point, we expect only 2 cases:
*
* 1) the Access Flag was not set so we set it marking the page
* as accessed;
*
* 2) the page was read-only and a write occurred so we clear the
* RO flag marking the page dirty.
*
* We bail out on anything else.
*
* Fault status codes for Data aborts (DFSC):
* 0b0010LL Access flag fault
* 0b0011LL Permission fault
*/
uint32_t dfsc = GET_ESR_ISS(esr) & GENMASK(5, 0);
bool write = (GET_ESR_ISS(esr) & BIT(6)) != 0; /* WnR */
if (dfsc == (0b001000 | XLAT_LAST_LEVEL) &&
(desc & PTE_BLOCK_DESC_AF) == 0) {
/* page is being accessed: set the access flag */
desc |= PTE_BLOCK_DESC_AF;
if (write) {
if ((desc & PTE_SW_WRITABLE) == 0) {
/* we don't actually have write permission */
return false;
}
/*
* Let's avoid another fault immediately after
* returning by making the page read-write right away
* effectively marking it "dirty" as well.
*/
desc &= ~PTE_BLOCK_DESC_AP_RO;
}
*pte = desc;
sync_domains(virt, CONFIG_MMU_PAGE_SIZE, "accessed");
/* no TLB inval needed after setting AF */
/* tell the eviction algorithm about it */
phys = desc & PTE_PHYSADDR_MASK;
k_mem_paging_eviction_accessed(phys);
return true;
}
if (dfsc == (0b001100 | XLAT_LAST_LEVEL) && write &&
(desc & PTE_BLOCK_DESC_AP_RO) != 0 &&
(desc & PTE_SW_WRITABLE) != 0) {
/* make it "dirty" i.e. read-write */
desc &= ~PTE_BLOCK_DESC_AP_RO;
*pte = desc;
sync_domains(virt, CONFIG_MMU_PAGE_SIZE, "dirtied");
invalidate_tlb_page(virt);
/* this also counts as an access refresh */
phys = desc & PTE_PHYSADDR_MASK;
k_mem_paging_eviction_accessed(phys);
return true;
}
return false;
}
#endif /* CONFIG_DEMAND_PAGING */

View File

@@ -126,14 +126,6 @@
*/
#define PTE_PHYSADDR_MASK GENMASK64(47, PAGE_SIZE_SHIFT)
/*
* Descriptor bits 58 to 55 are defined as "Reserved for Software Use".
*
* When using demand paging, RW memory is marked RO to trap the first write
* for dirty page tracking. Bit 55 indicates if memory is actually writable.
*/
#define PTE_SW_WRITABLE (1ULL << 55)
/*
* TCR definitions.
*/

View File

@@ -1,12 +0,0 @@
/*
* Copyright (c) 2024 BayLibre SAS
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef Z_ARM64_PAGING_H
#define Z_ARM64_PAGING_H
bool z_arm64_do_demand_paging(struct arch_esf *esf, uint64_t esr, uint64_t far);
#endif /* Z_ARM64_PAGING_H */

View File

@@ -16,8 +16,6 @@
#include <kernel_internal.h>
#include <zephyr/linker/linker-defs.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
extern void z_arm64_mm_init(bool is_primary_core);
@@ -32,10 +30,6 @@ __weak void z_arm64_mm_init(bool is_primary_core) { }
*/
void z_prep_c(void)
{
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
/* Initialize tpidrro_el0 with our struct _cpu instance address */
write_tpidrro_el0((uintptr_t)&_kernel.cpus[0]);
@@ -58,9 +52,6 @@ extern FUNC_NORETURN void arch_secondary_cpu_init(void);
void z_arm64_secondary_prep_c(void)
{
arch_secondary_cpu_init();
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
CODE_UNREACHABLE;
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/reboot.h>
#include <zephyr/drivers/pm_cpu_ops.h>
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
#ifdef CONFIG_PM_CPU_OPS_PSCI
void __weak sys_arch_reboot(int type)
{
unsigned char reset_type;
if (type == SYS_REBOOT_COLD) {
reset_type = SYS_COLD_RESET;
} else if (type == SYS_REBOOT_WARM) {
reset_type = SYS_WARM_RESET;
} else {
LOG_ERR("Invalid reboot type");
return;
}
pm_system_reset(reset_type);
}
#else
void __weak sys_arch_reboot(int type)
{
LOG_WRN("%s is not implemented", __func__);
ARG_UNUSED(type);
}
#endif

View File

@@ -4,5 +4,8 @@
# Needed to separate definitions in common Xen headers
zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:-D__ASSEMBLY__>)
# Xen interface version used in headers for correct definition
zephyr_compile_options(-D__XEN_INTERFACE_VERSION__=0x00040e00)
zephyr_library_sources(hypercall.S)
zephyr_library_sources(enlighten.c)

View File

@@ -25,11 +25,3 @@ config XEN_DOM0LESS
help
Configures Zephyr as DomU, that can be started on Dom0less
setup.
config XEN_INTERFACE_VERSION
hex "Xen interface version"
default 0x00040e00
depends on XEN
help
Xen interface version to use. This is the version of the
interface that Zephyr will use to communicate with the hypervisor.

View File

@@ -42,7 +42,7 @@ static int xen_map_shared_info(const shared_info_t *shared_page)
return HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp);
}
int xen_enlighten_init(void)
static int xen_enlighten_init(void)
{
int ret = 0;
shared_info_t *info = (shared_info_t *) shared_info_buf;
@@ -66,3 +66,5 @@ int xen_enlighten_init(void)
return 0;
}
SYS_INIT(xen_enlighten_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);

View File

@@ -28,13 +28,8 @@ extern "C" {
#ifndef _ASMLANGUAGE
extern void xen_enlighten_init(void);
static ALWAYS_INLINE void arch_kernel_init(void)
{
#ifdef CONFIG_XEN
xen_enlighten_init();
#endif
}
static inline void arch_switch(void *switch_to, void **switched_from)

View File

@@ -11,12 +11,9 @@
#include <zephyr/sys/__assert.h>
#include <zephyr/sys/util.h>
BUILD_ASSERT(CONFIG_MAX_IRQ_PER_AGGREGATOR < BIT(CONFIG_2ND_LEVEL_INTERRUPT_BITS),
BUILD_ASSERT((CONFIG_NUM_2ND_LEVEL_AGGREGATORS * CONFIG_MAX_IRQ_PER_AGGREGATOR) <=
BIT(CONFIG_2ND_LEVEL_INTERRUPT_BITS),
"L2 bits not enough to cover the number of L2 IRQs");
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
BUILD_ASSERT(CONFIG_MAX_IRQ_PER_AGGREGATOR < BIT(CONFIG_3RD_LEVEL_INTERRUPT_BITS),
"L3 bits not enough to cover the number of L3 IRQs");
#endif /* CONFIG_3RD_LEVEL_INTERRUPTS */
/**
* @brief Get the aggregator that's responsible for the given irq
@@ -88,8 +85,7 @@ unsigned int z_get_sw_isr_table_idx(unsigned int irq)
table_idx -= CONFIG_GEN_IRQ_START_VECTOR;
__ASSERT(table_idx < IRQ_TABLE_SIZE, "table_idx(%d) < IRQ_TABLE_SIZE(%d)", table_idx,
IRQ_TABLE_SIZE);
__ASSERT_NO_MSG(table_idx < IRQ_TABLE_SIZE);
return table_idx;
}

View File

@@ -7,12 +7,6 @@
/* Copied from linker.ld */
#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_nocache_ram), okay)
#define NOCACHE_REGION LINKER_DT_NODE_REGION_NAME_TOKEN(DT_CHOSEN(zephyr_nocache_ram))
#else
#define NOCACHE_REGION RAMABLE_REGION
#endif
/* Non-cached region of RAM */
SECTION_DATA_PROLOGUE(_NOCACHE_SECTION_NAME,(NOLOAD),)
{
@@ -33,5 +27,5 @@ SECTION_DATA_PROLOGUE(_NOCACHE_SECTION_NAME,(NOLOAD),)
MPU_ALIGN(_nocache_ram_size);
#endif
_nocache_ram_end = .;
} GROUP_DATA_LINK_IN(NOCACHE_REGION, NOCACHE_REGION)
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
_nocache_ram_size = _nocache_ram_end - _nocache_ram_start;

View File

@@ -92,8 +92,8 @@ void z_isr_install(unsigned int irq, void (*routine)(const void *),
for (i = 0; i < shared_entry->client_num; i++) {
client = &shared_entry->clients[i];
__ASSERT((client->isr == routine && client->arg == param) == false,
"ISR/arg combination is already registered");
__ASSERT(client->isr != routine && client->arg != param,
"trying to register duplicate ISR/arg pair");
}
shared_entry->clients[shared_entry->client_num].isr = routine;

View File

@@ -48,7 +48,3 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
irq_unlock(key);
}
void arch_irq_offload_init(void)
{
}

View File

@@ -11,8 +11,6 @@
#include <kernel_internal.h>
#include <zephyr/irq.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
static void interrupt_init(void)
{
@@ -46,15 +44,9 @@ static void interrupt_init(void)
void z_prep_c(void)
{
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
z_bss_zero();
interrupt_init();
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
z_cstart();
CODE_UNREACHABLE;

View File

@@ -41,7 +41,3 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
irq_unlock(key);
}
void arch_irq_offload_init(void)
{
}

View File

@@ -21,8 +21,6 @@
#include <zephyr/linker/linker-defs.h>
#include <zephyr/kernel_structs.h>
#include <kernel_internal.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
/**
* @brief Prepare to and run C code
@@ -32,10 +30,6 @@
void z_prep_c(void)
{
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
z_bss_zero();
z_data_copy();
/* In most XIP scenarios we copy the exception code into RAM, so need
@@ -50,9 +44,6 @@ void z_prep_c(void)
*/
z_nios2_dcache_flush_all();
#endif
#endif
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
z_cstart();
CODE_UNREACHABLE;

View File

@@ -14,10 +14,6 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
{
posix_irq_offload(routine, parameter);
}
void arch_irq_offload_init(void)
{
}
#endif
void arch_irq_enable(unsigned int irq)

View File

@@ -57,8 +57,3 @@ int posix_arch_get_unique_thread_id(int thread_idx)
{
return nct_get_unique_thread_id(te_state, thread_idx);
}
int posix_arch_thread_name_set(int thread_idx, const char *str)
{
return nct_thread_name_set(te_state, thread_idx, str);
}

View File

@@ -13,7 +13,6 @@
* architecture
*/
#include <stdio.h>
#include <zephyr/toolchain.h>
#include <zephyr/kernel_structs.h>
#include <ksched.h>
@@ -55,40 +54,6 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
thread_status->thread_idx = posix_new_thread((void *)thread_status);
}
int arch_thread_name_set(struct k_thread *thread, const char *str)
{
#define MAX_HOST_THREAD_NAME 16
int ret;
int thread_index;
posix_thread_status_t *thread_status;
char th_name[MAX_HOST_THREAD_NAME];
thread_status = thread->callee_saved.thread_status;
if (!thread_status) {
return -EAGAIN;
}
thread_index = thread_status->thread_idx;
if (!str) {
return -EAGAIN;
}
snprintf(th_name, MAX_HOST_THREAD_NAME,
#if (CONFIG_NATIVE_SIMULATOR_NUMBER_MCUS > 1)
STRINGIFY(CONFIG_NATIVE_SIMULATOR_MCU_N) ":"
#endif
"%s", str);
ret = posix_arch_thread_name_set(thread_index, th_name);
if (ret) {
return -EAGAIN;
}
return 0;
}
void posix_arch_thread_entry(void *pa_thread_status)
{
posix_thread_status_t *ptr = pa_thread_status;

View File

@@ -47,7 +47,6 @@ void posix_main_thread_start(int next_allowed_thread_nbr);
int posix_new_thread(void *payload);
void posix_abort_thread(int thread_idx);
int posix_arch_get_unique_thread_id(int thread_idx);
int posix_arch_thread_name_set(int thread_idx, const char *str);
#ifndef POSIX_ARCH_DEBUG_PRINTS
#define POSIX_ARCH_DEBUG_PRINTS 0

View File

@@ -37,6 +37,13 @@ config RISCV_ALWAYS_SWITCH_THROUGH_ECALL
and most people should say n here to minimize context switching
overhead.
config RISCV_EXCEPTION_STACK_TRACE
bool
default y
imply THREAD_STACK_INFO
help
Internal config to enable runtime stack traces on fatal exceptions.
menu "RISCV Processor Options"
config INCLUDE_RESET_VECTOR
@@ -238,14 +245,6 @@ config RISCV_HART_MASK
i.e. 128, 129, ..(0x80, 8x81, ..), this can be configured to 63 (0x7f)
such that we can extract the bits that start from 0.
config EXTRA_EXCEPTION_INFO
bool "Collect extra exception info"
depends on EXCEPTION_DEBUG
help
This option enables the collection of extra information, such as
register state, when a fault occurs. This information can be useful
to collect for post-mortem analysis and debug of issues.
config RISCV_PMP
bool "RISC-V PMP Support"
select THREAD_STACK_INFO
@@ -384,14 +383,6 @@ config GEN_IRQ_VECTOR_TABLE
config ARCH_HAS_SINGLE_THREAD_SUPPORT
default y if !SMP
config ARCH_HAS_STACKWALK
bool
default y
imply THREAD_STACK_INFO
help
Internal config to indicate that the arch_stack_walk() API is implemented
and it can be enabled.
rsource "Kconfig.isa"
endmenu

View File

@@ -25,5 +25,5 @@ zephyr_library_sources_ifdef(CONFIG_RISCV_PMP pmp.c pmp.S)
zephyr_library_sources_ifdef(CONFIG_THREAD_LOCAL_STORAGE tls.c)
zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S)
zephyr_library_sources_ifdef(CONFIG_SEMIHOST semihost.c)
zephyr_library_sources_ifdef(CONFIG_ARCH_STACKWALK stacktrace.c)
zephyr_library_sources_ifdef(CONFIG_EXCEPTION_STACK_TRACE stacktrace.c)
zephyr_linker_sources(ROM_START SORT_KEY 0x0vectors vector_table.ld)

View File

@@ -5,7 +5,6 @@
*/
#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/debug/coredump.h>
#ifndef CONFIG_64BIT
@@ -117,21 +116,3 @@ uint16_t arch_coredump_tgt_code_get(void)
{
return COREDUMP_TGT_RISC_V;
}
#if defined(CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK)
void arch_coredump_priv_stack_dump(struct k_thread *thread)
{
uintptr_t start_addr, end_addr;
/* See: zephyr/include/zephyr/arch/riscv/arch.h */
if (IS_ENABLED(CONFIG_PMP_POWER_OF_TWO_ALIGNMENT)) {
start_addr = thread->arch.priv_stack_start + Z_RISCV_STACK_GUARD_SIZE;
} else {
start_addr = thread->stack_info.start - CONFIG_PRIVILEGED_STACK_SIZE;
}
end_addr = Z_STACK_PTR_ALIGN(thread->arch.priv_stack_start + K_KERNEL_STACK_RESERVED +
CONFIG_PRIVILEGED_STACK_SIZE);
coredump_memory_dump(start_addr, end_addr);
}
#endif /* CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK */

View File

@@ -52,31 +52,6 @@ uintptr_t z_riscv_get_sp_before_exc(const struct arch_esf *esf)
return sp;
}
const char *z_riscv_mcause_str(unsigned long cause)
{
static const char *const mcause_str[17] = {
[0] = "Instruction address misaligned",
[1] = "Instruction Access fault",
[2] = "Illegal instruction",
[3] = "Breakpoint",
[4] = "Load address misaligned",
[5] = "Load access fault",
[6] = "Store/AMO address misaligned",
[7] = "Store/AMO access fault",
[8] = "Environment call from U-mode",
[9] = "Environment call from S-mode",
[10] = "unknown",
[11] = "Environment call from M-mode",
[12] = "Instruction page fault",
[13] = "Load page fault",
[14] = "unknown",
[15] = "Store/AMO page fault",
[16] = "unknown",
};
return mcause_str[MIN(cause, ARRAY_SIZE(mcause_str) - 1)];
}
FUNC_NORETURN void z_riscv_fatal_error(unsigned int reason,
const struct arch_esf *esf)
{
@@ -86,21 +61,6 @@ FUNC_NORETURN void z_riscv_fatal_error(unsigned int reason,
FUNC_NORETURN void z_riscv_fatal_error_csf(unsigned int reason, const struct arch_esf *esf,
const _callee_saved_t *csf)
{
unsigned long mcause;
__asm__ volatile("csrr %0, mcause" : "=r" (mcause));
mcause &= CONFIG_RISCV_MCAUSE_EXCEPTION_MASK;
LOG_ERR("");
LOG_ERR(" mcause: %ld, %s", mcause, z_riscv_mcause_str(mcause));
#ifndef CONFIG_SOC_OPENISA_RV32M1
unsigned long mtval;
__asm__ volatile("csrr %0, mtval" : "=r" (mtval));
LOG_ERR(" mtval: %lx", mtval);
#endif /* CONFIG_SOC_OPENISA_RV32M1 */
#ifdef CONFIG_EXCEPTION_DEBUG
if (esf != NULL) {
LOG_ERR(" a0: " PR_REG " t0: " PR_REG, esf->a0, esf->t0);
@@ -138,16 +98,52 @@ FUNC_NORETURN void z_riscv_fatal_error_csf(unsigned int reason, const struct arc
#endif /* CONFIG_RISCV_ISA_RV32E */
LOG_ERR("");
}
if (IS_ENABLED(CONFIG_EXCEPTION_STACK_TRACE)) {
z_riscv_unwind_stack(esf, csf);
}
#endif /* CONFIG_EXCEPTION_DEBUG */
#ifdef CONFIG_EXCEPTION_STACK_TRACE
z_riscv_unwind_stack(esf, csf);
#endif /* CONFIG_EXCEPTION_STACK_TRACE */
z_fatal_error(reason, esf);
CODE_UNREACHABLE;
}
static char *cause_str(unsigned long cause)
{
switch (cause) {
case 0:
return "Instruction address misaligned";
case 1:
return "Instruction Access fault";
case 2:
return "Illegal instruction";
case 3:
return "Breakpoint";
case 4:
return "Load address misaligned";
case 5:
return "Load access fault";
case 6:
return "Store/AMO address misaligned";
case 7:
return "Store/AMO access fault";
case 8:
return "Environment call from U-mode";
case 9:
return "Environment call from S-mode";
case 11:
return "Environment call from M-mode";
case 12:
return "Instruction page fault";
case 13:
return "Load page fault";
case 15:
return "Store/AMO page fault";
default:
return "unknown";
}
}
static bool bad_stack_pointer(struct arch_esf *esf)
{
#ifdef CONFIG_PMP_STACK_GUARD
@@ -211,6 +207,22 @@ void _Fault(struct arch_esf *esf)
}
#endif /* CONFIG_USERSPACE */
unsigned long mcause;
__asm__ volatile("csrr %0, mcause" : "=r" (mcause));
#ifndef CONFIG_SOC_OPENISA_RV32M1
unsigned long mtval;
__asm__ volatile("csrr %0, mtval" : "=r" (mtval));
#endif
mcause &= CONFIG_RISCV_MCAUSE_EXCEPTION_MASK;
LOG_ERR("");
LOG_ERR(" mcause: %ld, %s", mcause, cause_str(mcause));
#ifndef CONFIG_SOC_OPENISA_RV32M1
LOG_ERR(" mtval: %lx", mtval);
#endif
unsigned int reason = K_ERR_CPU_EXCEPTION;
if (bad_stack_pointer(esf)) {

View File

@@ -19,12 +19,6 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
FUNC_NORETURN void z_irq_spurious(const void *unused)
{
#ifdef CONFIG_EMPTY_IRQ_SPURIOUS
while (1) {
}
CODE_UNREACHABLE;
#else
unsigned long mcause;
ARG_UNUSED(unused);
@@ -43,7 +37,6 @@ FUNC_NORETURN void z_irq_spurious(const void *unused)
}
#endif
z_riscv_fatal_error(K_ERR_SPURIOUS_IRQ, NULL);
#endif /* CONFIG_EMPTY_IRQ_SPURIOUS */
}
#ifdef CONFIG_DYNAMIC_INTERRUPTS

View File

@@ -11,7 +11,3 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
{
arch_syscall_invoke2((uintptr_t)routine, (uintptr_t)parameter, RV_ECALL_IRQ_OFFLOAD);
}
void arch_irq_offload_init(void)
{
}

View File

@@ -450,15 +450,10 @@ do_fault:
STORE_CALLEE_SAVED() ;
mv a2, sp
#ifdef CONFIG_EXTRA_EXCEPTION_INFO
/* Store csf's addr into esf (a1 still holds the pointer to the esf at this point) */
sr a2 __struct_arch_esf_csf_OFFSET(a1)
#endif /* CONFIG_EXTRA_EXCEPTION_INFO */
tail z_riscv_fatal_error_csf
#else
tail z_riscv_fatal_error
#endif /* CONFIG_EXCEPTION_DEBUG */
#endif
#if defined(CONFIG_IRQ_OFFLOAD)
do_irq_offload:

View File

@@ -118,10 +118,6 @@ GEN_OFFSET_STRUCT(arch_esf, s0);
GEN_OFFSET_STRUCT(arch_esf, sp);
#endif
#ifdef CONFIG_EXTRA_EXCEPTION_INFO
GEN_OFFSET_STRUCT(arch_esf, csf);
#endif /* CONFIG_EXTRA_EXCEPTION_INFO */
#if defined(CONFIG_RISCV_SOC_CONTEXT_SAVE)
GEN_OFFSET_STRUCT(arch_esf, soc_context);
#endif

View File

@@ -19,8 +19,6 @@
#include <zephyr/toolchain.h>
#include <zephyr/kernel_structs.h>
#include <kernel_internal.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
#if defined(CONFIG_RISCV_SOC_INTERRUPT_INIT)
void soc_interrupt_init(void);
@@ -35,17 +33,10 @@ void soc_interrupt_init(void);
void z_prep_c(void)
{
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
z_bss_zero();
z_data_copy();
#if defined(CONFIG_RISCV_SOC_INTERRUPT_INIT)
soc_interrupt_init();
#endif
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
z_cstart();
CODE_UNREACHABLE;

View File

@@ -62,8 +62,7 @@ boot_first_core:
#ifdef CONFIG_INIT_STACKS
/* Pre-populate all bytes in z_interrupt_stacks with 0xAA */
la t0, z_interrupt_stacks
/* Total size of all cores' IRQ stack */
li t1, __z_interrupt_all_stacks_SIZEOF
li t1, __z_interrupt_stack_SIZEOF
add t1, t1, t0
/* Populate z_interrupt_stacks with 0xaaaaaaaa */
@@ -72,7 +71,7 @@ aa_loop:
sw t2, 0x00(t0)
addi t0, t0, 4
blt t0, t1, aa_loop
#endif /* CONFIG_INIT_STACKS */
#endif
/*
* Initially, setup stack pointer to

View File

@@ -14,9 +14,8 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
uintptr_t z_riscv_get_sp_before_exc(const struct arch_esf *esf);
typedef bool (*riscv_stacktrace_cb)(void *cookie, unsigned long addr, unsigned long sfp);
#define MAX_STACK_FRAMES CONFIG_ARCH_STACKWALK_MAX_FRAMES
#define MAX_STACK_FRAMES \
MAX(CONFIG_EXCEPTION_STACK_TRACE_MAX_FRAMES, CONFIG_ARCH_STACKWALK_MAX_FRAMES)
struct stackframe {
uintptr_t fp;
@@ -88,6 +87,26 @@ static bool in_stack_bound(uintptr_t addr, const struct k_thread *const thread,
return in_kernel_thread_stack_bound(addr, thread);
}
static bool in_fatal_stack_bound(uintptr_t addr, const struct k_thread *const thread,
const struct arch_esf *esf)
{
const uintptr_t align =
COND_CODE_1(CONFIG_FRAME_POINTER, (ARCH_STACK_PTR_ALIGN), (sizeof(uintptr_t)));
if (!IS_ALIGNED(addr, align)) {
return false;
}
if ((thread == NULL) || arch_is_in_isr()) {
/* We were servicing an interrupt */
uint8_t cpu_id = IS_ENABLED(CONFIG_SMP) ? arch_curr_cpu()->id : 0U;
return in_irq_stack_bound(addr, cpu_id);
}
return in_stack_bound(addr, thread, esf);
}
static inline bool in_text_region(uintptr_t addr)
{
extern uintptr_t __text_region_start, __text_region_end;
@@ -96,7 +115,7 @@ static inline bool in_text_region(uintptr_t addr)
}
#ifdef CONFIG_FRAME_POINTER
static void walk_stackframe(riscv_stacktrace_cb cb, void *cookie, const struct k_thread *thread,
static void walk_stackframe(stack_trace_callback_fn cb, void *cookie, const struct k_thread *thread,
const struct arch_esf *esf, stack_verify_fn vrfy,
const _callee_saved_t *csf)
{
@@ -119,7 +138,7 @@ static void walk_stackframe(riscv_stacktrace_cb cb, void *cookie, const struct k
}
for (int i = 0; (i < MAX_STACK_FRAMES) && vrfy(fp, thread, esf) && (fp > last_fp); i++) {
if (in_text_region(ra) && !cb(cookie, ra, fp)) {
if (in_text_region(ra) && !cb(cookie, ra)) {
break;
}
last_fp = fp;
@@ -129,7 +148,7 @@ static void walk_stackframe(riscv_stacktrace_cb cb, void *cookie, const struct k
if ((i == 0) && (esf != NULL)) {
/* Print `esf->ra` if we are at the top of the stack */
if (in_text_region(esf->ra) && !cb(cookie, esf->ra, fp)) {
if (in_text_region(esf->ra) && !cb(cookie, esf->ra)) {
break;
}
/**
@@ -169,7 +188,7 @@ static void walk_stackframe(riscv_stacktrace_cb cb, void *cookie, const struct k
}
#else /* !CONFIG_FRAME_POINTER */
register uintptr_t current_stack_pointer __asm__("sp");
static void walk_stackframe(riscv_stacktrace_cb cb, void *cookie, const struct k_thread *thread,
static void walk_stackframe(stack_trace_callback_fn cb, void *cookie, const struct k_thread *thread,
const struct arch_esf *esf, stack_verify_fn vrfy,
const _callee_saved_t *csf)
{
@@ -189,13 +208,14 @@ static void walk_stackframe(riscv_stacktrace_cb cb, void *cookie, const struct k
/* Unwind the provided thread */
sp = csf->sp;
ra = csf->ra;
}
ksp = (uintptr_t *)sp;
for (int i = 0; (i < MAX_STACK_FRAMES) && vrfy((uintptr_t)ksp, thread, esf) &&
((uintptr_t)ksp > last_ksp);) {
if (in_text_region(ra)) {
if (!cb(cookie, ra, POINTER_TO_UINT(ksp))) {
if (!cb(cookie, ra)) {
break;
}
/*
@@ -219,26 +239,7 @@ void arch_stack_walk(stack_trace_callback_fn callback_fn, void *cookie,
thread = _current;
}
walk_stackframe((riscv_stacktrace_cb)callback_fn, cookie, thread, esf, in_stack_bound,
&thread->callee_saved);
}
#ifdef CONFIG_EXCEPTION_STACK_TRACE
static bool in_fatal_stack_bound(uintptr_t addr, const struct k_thread *const thread,
const struct arch_esf *esf)
{
if (!IS_ALIGNED(addr, sizeof(uintptr_t))) {
return false;
}
if ((thread == NULL) || arch_is_in_isr()) {
/* We were servicing an interrupt */
uint8_t cpu_id = IS_ENABLED(CONFIG_SMP) ? arch_curr_cpu()->id : 0U;
return in_irq_stack_bound(addr, cpu_id);
}
return in_stack_bound(addr, thread, esf);
walk_stackframe(callback_fn, cookie, thread, esf, in_stack_bound, &thread->callee_saved);
}
#if __riscv_xlen == 32
@@ -247,30 +248,22 @@ static bool in_fatal_stack_bound(uintptr_t addr, const struct k_thread *const th
#define PR_REG "%016" PRIxPTR
#endif
#ifdef CONFIG_FRAME_POINTER
#define SFP "fp"
#ifdef CONFIG_EXCEPTION_STACK_TRACE_SYMTAB
#define LOG_STACK_TRACE(idx, ra, name, offset) \
LOG_ERR(" %2d: ra: " PR_REG " [%s+0x%x]", idx, ra, name, offset)
#else
#define SFP "sp"
#endif /* CONFIG_FRAME_POINTER */
#define LOG_STACK_TRACE(idx, ra, name, offset) LOG_ERR(" %2d: ra: " PR_REG, idx, ra)
#endif /* CONFIG_EXCEPTION_STACK_TRACE_SYMTAB */
#ifdef CONFIG_SYMTAB
#define LOG_STACK_TRACE(idx, sfp, ra, name, offset) \
LOG_ERR(" %2d: " SFP ": " PR_REG " ra: " PR_REG " [%s+0x%x]", idx, sfp, ra, name, \
offset)
#else
#define LOG_STACK_TRACE(idx, sfp, ra, name, offset) \
LOG_ERR(" %2d: " SFP ": " PR_REG " ra: " PR_REG, idx, sfp, ra)
#endif /* CONFIG_SYMTAB */
static bool print_trace_address(void *arg, unsigned long ra, unsigned long sfp)
static bool print_trace_address(void *arg, unsigned long ra)
{
int *i = arg;
#ifdef CONFIG_SYMTAB
#ifdef CONFIG_EXCEPTION_STACK_TRACE_SYMTAB
uint32_t offset = 0;
const char *name = symtab_find_symbol_name(ra, &offset);
#endif /* CONFIG_SYMTAB */
#endif
LOG_STACK_TRACE((*i)++, sfp, ra, name, offset);
LOG_STACK_TRACE((*i)++, ra, name, offset);
return true;
}
@@ -283,4 +276,3 @@ void z_riscv_unwind_stack(const struct arch_esf *esf, const _callee_saved_t *csf
walk_stackframe(print_trace_address, &i, _current, esf, in_fatal_stack_bound, csf);
LOG_ERR("");
}
#endif /* CONFIG_EXCEPTION_STACK_TRACE */

View File

@@ -15,7 +15,7 @@
/*
* Per-thread (TLS) variable indicating whether execution is in user mode.
*/
Z_THREAD_LOCAL uint8_t is_user_mode;
__thread uint8_t is_user_mode;
#endif
void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
@@ -144,12 +144,6 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
K_KERNEL_STACK_RESERVED +
CONFIG_PRIVILEGED_STACK_SIZE);
#ifdef CONFIG_INIT_STACKS
/* Initialize the privileged stack */
(void)memset((void *)_current->arch.priv_stack_start, 0xaa,
Z_STACK_PTR_ALIGN(K_KERNEL_STACK_RESERVED + CONFIG_PRIVILEGED_STACK_SIZE));
#endif /* CONFIG_INIT_STACKS */
top_of_user_stack = Z_STACK_PTR_ALIGN(
_current->stack_info.start +
_current->stack_info.size -
@@ -195,18 +189,6 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
CODE_UNREACHABLE;
}
int arch_thread_priv_stack_space_get(const struct k_thread *thread, size_t *stack_size,
size_t *unused_ptr)
{
if ((thread->base.user_options & K_USER) != K_USER) {
return -EINVAL;
}
*stack_size = Z_STACK_PTR_ALIGN(K_KERNEL_STACK_RESERVED + CONFIG_PRIVILEGED_STACK_SIZE);
return z_stack_space_get((void *)thread->arch.priv_stack_start, *stack_size, unused_ptr);
}
#endif /* CONFIG_USERSPACE */
#ifndef CONFIG_MULTITHREADING

View File

@@ -39,7 +39,3 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
irq_unlock(key);
}
void arch_irq_offload_init(void)
{
}

View File

@@ -10,8 +10,6 @@
*/
#include <kernel_internal.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
/**
* @brief Prepare to and run C code
@@ -21,13 +19,7 @@
void z_prep_c(void)
{
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
z_data_copy();
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
z_cstart();
CODE_UNREACHABLE;
}

View File

@@ -163,15 +163,14 @@ config X86_DYNAMIC_IRQ_STUBS
endmenu
config ARCH_HAS_STACKWALK
config X86_EXCEPTION_STACK_TRACE
bool
default y
select DEBUG_INFO
select THREAD_STACK_INFO
depends on !OMIT_FRAME_POINTER
help
Internal config to indicate that the arch_stack_walk() API is implemented
and it can be enabled.
Internal config to enable runtime stack traces on fatal exceptions.
config X86_USE_THREAD_LOCAL_STORAGE
bool

View File

@@ -29,7 +29,7 @@ config X86_EXCEPTION_STACK_SIZE
support limited call-tree depth and must fit into the low core,
so they are typically smaller than the ISR stacks.
config ARCH_HAS_STACKWALK
config X86_EXCEPTION_STACK_TRACE
bool
default y
select DEBUG_INFO
@@ -37,8 +37,7 @@ config ARCH_HAS_STACKWALK
depends on !OMIT_FRAME_POINTER
depends on NO_OPTIMIZATIONS
help
Internal config to indicate that the arch_stack_walk() API is implemented
and it can be enabled.
Internal config to enable runtime stack traces on fatal exceptions.
config SCHED_IPI_VECTOR
int "IDT vector to use for scheduler IPI"

View File

@@ -119,7 +119,3 @@ int arch_dcache_flush_and_invd_range(void *start_addr, size_t size)
{
return arch_dcache_flush_range(start_addr, size);
}
void arch_cache_init(void)
{
}

View File

@@ -22,35 +22,9 @@
*/
cmpl $MULTIBOOT_EAX_MAGIC, %eax
#ifndef CONFIG_DYNAMIC_BOOTARGS
je 1f
xorl %ebx, %ebx
1:
#else
movl $multiboot_cmdline, %edi
je setup_copy_cmdline
xorl %ebx, %ebx
jmp end_cmdline
setup_copy_cmdline:
testl $MULTIBOOT_INFO_FLAGS_CMDLINE, __multiboot_info_t_flags_OFFSET(%ebx)
jz end_cmdline
movl $multiboot_cmdline + CONFIG_BOOTARGS_ARGS_BUFFER_SIZE - 1, %edx
movl __multiboot_info_t_cmdline_OFFSET(%ebx), %esi
copy_cmdline:
cmpl %esi, %edx
je end_cmdline
cmpb $0, (%esi)
je end_cmdline
movsb
jmp copy_cmdline
end_cmdline:
movb $0, (%edi)
#endif
#endif
#ifdef CONFIG_PIC_DISABLE

View File

@@ -18,10 +18,6 @@ static uint64_t __aligned(64) efi_stack[1024];
struct efi_boot_arg *efi;
#ifdef CONFIG_DYNAMIC_BOOTARGS
__pinned_noinit char efi_bootargs[CONFIG_BOOTARGS_ARGS_BUFFER_SIZE];
#endif
void *efi_get_acpi_rsdp(void)
{
if (efi == NULL) {
@@ -173,10 +169,3 @@ int arch_printk_char_out(int c)
return efi_console_putchar(c);
}
#endif
#ifdef CONFIG_DYNAMIC_BOOTARGS
const char *get_bootargs(void)
{
return efi_bootargs;
}
#endif /* CONFIG_DYNAMIC_BOOTARGS */

View File

@@ -84,7 +84,7 @@ bool z_x86_check_stack_bounds(uintptr_t addr, size_t size, uint16_t cs)
return (addr <= start) || (addr + size > end);
}
#endif /* CONFIG_THREAD_STACK_INFO */
#endif
#ifdef CONFIG_THREAD_STACK_MEM_MAPPED
/**
@@ -120,37 +120,40 @@ bool z_x86_check_guard_page(uintptr_t addr)
}
#endif /* CONFIG_THREAD_STACK_MEM_MAPPED */
#if defined(CONFIG_ARCH_STACKWALK)
#ifdef CONFIG_EXCEPTION_DEBUG
static inline uintptr_t esf_get_code(const struct arch_esf *esf)
{
#ifdef CONFIG_X86_64
return esf->code;
#else
return esf->errorCode;
#endif
}
#if defined(CONFIG_EXCEPTION_STACK_TRACE)
struct stack_frame {
uintptr_t next;
uintptr_t ret_addr;
#ifndef CONFIG_X86_64
uintptr_t args;
#endif
};
__pinned_func static void walk_stackframe(stack_trace_callback_fn cb, void *cookie,
const struct arch_esf *esf, int max_frames)
#define MAX_STACK_FRAMES CONFIG_EXCEPTION_STACK_TRACE_MAX_FRAMES
__pinned_func
static void unwind_stack(uintptr_t base_ptr, uint16_t cs)
{
uintptr_t base_ptr;
uint16_t cs;
struct stack_frame *frame;
int i;
if (esf != NULL) {
#ifdef CONFIG_X86_64
base_ptr = esf->rbp;
#else /* x86 32-bit */
base_ptr = esf->ebp;
#endif /* CONFIG_X86_64 */
cs = esf->cs;
} else {
return;
}
if (base_ptr == 0U) {
LOG_ERR("NULL base ptr");
return;
}
for (i = 0; i < max_frames; i++) {
for (i = 0; i < MAX_STACK_FRAMES; i++) {
if (base_ptr % sizeof(base_ptr) != 0U) {
LOG_ERR("unaligned frame ptr");
return;
@@ -175,57 +178,16 @@ __pinned_func static void walk_stackframe(stack_trace_callback_fn cb, void *cook
if (frame->ret_addr == 0U) {
break;
}
if (!cb(cookie, frame->ret_addr)) {
break;
}
#ifdef CONFIG_X86_64
LOG_ERR(" 0x%016lx", frame->ret_addr);
#else
LOG_ERR(" 0x%08lx (0x%lx)", frame->ret_addr, frame->args);
#endif
base_ptr = frame->next;
}
}
void arch_stack_walk(stack_trace_callback_fn callback_fn, void *cookie,
const struct k_thread *thread, const struct arch_esf *esf)
{
ARG_UNUSED(thread);
walk_stackframe(callback_fn, cookie, esf,
CONFIG_ARCH_STACKWALK_MAX_FRAMES);
}
#endif /* CONFIG_ARCH_STACKWALK */
#if defined(CONFIG_EXCEPTION_STACK_TRACE)
static bool print_trace_address(void *arg, unsigned long addr)
{
int *i = arg;
#ifdef CONFIG_X86_64
LOG_ERR(" %d: 0x%016lx", (*i)++, addr);
#else
LOG_ERR(" %d: 0x%08lx", (*i)++, addr);
#endif
return true;
}
static ALWAYS_INLINE void unwind_stack(const struct arch_esf *esf)
{
int i = 0;
walk_stackframe(print_trace_address, &i, esf, CONFIG_ARCH_STACKWALK_MAX_FRAMES);
}
#endif /* CONFIG_EXCEPTION_STACK_TRACE */
#ifdef CONFIG_EXCEPTION_DEBUG
static inline uintptr_t esf_get_code(const struct arch_esf *esf)
{
#ifdef CONFIG_X86_64
return esf->code;
#else
return esf->errorCode;
#endif
}
static inline uintptr_t get_cr3(const struct arch_esf *esf)
{
#if defined(CONFIG_USERSPACE) && defined(CONFIG_X86_KPTI)
@@ -264,7 +226,13 @@ static void dump_regs(const struct arch_esf *esf)
LOG_ERR("RSP: 0x%016lx RFLAGS: 0x%016lx CS: 0x%04lx CR3: 0x%016lx",
esf->rsp, esf->rflags, esf->cs & 0xFFFFU, get_cr3(esf));
#ifdef CONFIG_EXCEPTION_STACK_TRACE
LOG_ERR("call trace:");
#endif
LOG_ERR("RIP: 0x%016lx", esf->rip);
#ifdef CONFIG_EXCEPTION_STACK_TRACE
unwind_stack(esf->rbp, esf->cs);
#endif
}
#else /* 32-bit */
__pinned_func
@@ -277,7 +245,13 @@ static void dump_regs(const struct arch_esf *esf)
LOG_ERR("EFLAGS: 0x%08x CS: 0x%04x CR3: 0x%08lx", esf->eflags,
esf->cs & 0xFFFFU, get_cr3(esf));
#ifdef CONFIG_EXCEPTION_STACK_TRACE
LOG_ERR("call trace:");
#endif
LOG_ERR("EIP: 0x%08x", esf->eip);
#ifdef CONFIG_EXCEPTION_STACK_TRACE
unwind_stack(esf->ebp, esf->cs);
#endif
}
#endif /* CONFIG_X86_64 */
@@ -394,10 +368,6 @@ FUNC_NORETURN void z_x86_fatal_error(unsigned int reason,
#ifdef CONFIG_EXCEPTION_DEBUG
dump_regs(esf);
#endif
#ifdef CONFIG_EXCEPTION_STACK_TRACE
LOG_ERR("call trace:");
unwind_stack(esf);
#endif /* CONFIG_EXCEPTION_STACK_TRACE */
#if defined(CONFIG_ASSERT) && defined(CONFIG_X86_64)
if (esf->rip == 0xb9) {
/* See implementation of __resume in locore.S. This is

View File

@@ -5,7 +5,6 @@
*/
#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/debug/coredump.h>
#define ARCH_HDR_VER 1
@@ -81,22 +80,3 @@ uint16_t arch_coredump_tgt_code_get(void)
{
return COREDUMP_TGT_X86;
}
#if defined(CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK)
void arch_coredump_priv_stack_dump(struct k_thread *thread)
{
struct z_x86_thread_stack_header *hdr_stack_obj;
uintptr_t start_addr, end_addr;
#if defined(CONFIG_THREAD_STACK_MEM_MAPPED)
hdr_stack_obj = (struct z_x86_thread_stack_header *)thread->stack_info.mapped.addr;
#else
hdr_stack_obj = (struct z_x86_thread_stack_header *)thread->stack_obj;
#endif /* CONFIG_THREAD_STACK_MEM_MAPPED) */
start_addr = (uintptr_t)&hdr_stack_obj->privilege_stack[0];
end_addr = start_addr + sizeof(hdr_stack_obj->privilege_stack);
coredump_memory_dump(start_addr, end_addr);
}
#endif /* CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK */

View File

@@ -47,7 +47,3 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
irq_unlock(key);
}
void arch_irq_offload_init(void)
{
}

View File

@@ -5,7 +5,6 @@
*/
#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/debug/coredump.h>
#define ARCH_HDR_VER 1
@@ -107,22 +106,3 @@ uint16_t arch_coredump_tgt_code_get(void)
{
return COREDUMP_TGT_X86_64;
}
#if defined(CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK)
void arch_coredump_priv_stack_dump(struct k_thread *thread)
{
struct z_x86_thread_stack_header *hdr_stack_obj;
uintptr_t start_addr, end_addr;
#if defined(CONFIG_THREAD_STACK_MEM_MAPPED)
hdr_stack_obj = (struct z_x86_thread_stack_header *)thread->stack_info.mapped.addr;
#else
hdr_stack_obj = (struct z_x86_thread_stack_header *)thread->stack_obj;
#endif /* CONFIG_THREAD_STACK_MEM_MAPPED) */
start_addr = (uintptr_t)&hdr_stack_obj->privilege_stack[0];
end_addr = start_addr + sizeof(hdr_stack_obj->privilege_stack);
coredump_memory_dump(start_addr, end_addr);
}
#endif /* CONFIG_DEBUG_COREDUMP_DUMP_THREAD_PRIV_STACK */

View File

@@ -18,8 +18,8 @@
extern void (*x86_irq_funcs[NR_IRQ_VECTORS])(const void *arg);
extern const void *x86_irq_args[NR_IRQ_VECTORS];
static void (*irq_offload_funcs[CONFIG_MP_MAX_NUM_CPUS])(const void *arg);
static const void *irq_offload_args[CONFIG_MP_MAX_NUM_CPUS];
static void (*irq_offload_funcs[CONFIG_MP_NUM_CPUS])(const void *arg);
static const void *irq_offload_args[CONFIG_MP_NUM_CPUS];
static void dispatcher(const void *arg)
{
@@ -44,7 +44,11 @@ void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
arch_irq_unlock(key);
}
void arch_irq_offload_init(void)
int irq_offload_init(void)
{
x86_irq_funcs[CONFIG_IRQ_OFFLOAD_VECTOR - IV_IRQS] = dispatcher;
return 0;
}
SYS_INIT(irq_offload_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

View File

@@ -11,15 +11,6 @@
struct multiboot_info multiboot_info;
#ifdef CONFIG_DYNAMIC_BOOTARGS
__pinned_noinit char multiboot_cmdline[CONFIG_BOOTARGS_ARGS_BUFFER_SIZE];
const char *get_bootargs(void)
{
return multiboot_cmdline;
}
#endif /* CONFIG_DYNAMIC_BOOTARGS */
/*
* called very early in the boot process to fetch data out of the multiboot
* info struct. we need to grab the relevant data before any dynamic memory

View File

@@ -14,18 +14,9 @@
#include "ia32_offsets.c"
#endif
#ifdef CONFIG_MULTIBOOT_INFO
#include <zephyr/arch/x86/multiboot_info.h>
#endif
GEN_OFFSET_SYM(x86_boot_arg_t, boot_type);
GEN_OFFSET_SYM(x86_boot_arg_t, arg);
GEN_OFFSET_SYM(_thread_arch_t, flags);
#ifdef CONFIG_MULTIBOOT_INFO
GEN_OFFSET_SYM(multiboot_info_t, flags);
GEN_OFFSET_SYM(multiboot_info_t, cmdline);
#endif
GEN_ABS_SYM_END

View File

@@ -9,8 +9,6 @@
#include <zephyr/arch/x86/multiboot.h>
#include <zephyr/arch/x86/efi.h>
#include <x86_mmu.h>
#include <zephyr/platform/hooks.h>
#include <zephyr/arch/cache.h>
extern FUNC_NORETURN void z_cstart(void);
extern void x86_64_irq_init(void);
@@ -19,10 +17,6 @@ extern void x86_64_irq_init(void);
__pinned_data x86_boot_arg_t x86_cpu_boot_arg;
#endif
extern int spec_ctrl_init(void);
/* Early global initialization functions, C domain. This runs only on the first
* CPU for SMP systems.
*/
@@ -31,9 +25,6 @@ FUNC_NORETURN void z_prep_c(void *arg)
{
x86_boot_arg_t *cpu_arg = arg;
#if defined(CONFIG_SOC_PREP_HOOK)
soc_prep_hook();
#endif
_kernel.cpus[0].nested = 0;
#ifdef CONFIG_MMU
@@ -81,12 +72,6 @@ FUNC_NORETURN void z_prep_c(void *arg)
z_x86_set_stack_guard(z_interrupt_stacks[i]);
}
#endif
#if CONFIG_ARCH_CACHE
arch_cache_init();
#endif
#if defined(CONFIG_X86_DISABLE_SSBD) || defined(CONFIG_X86_ENABLE_EXTENDED_IBRS)
spec_ctrl_init();
#endif
z_cstart();
CODE_UNREACHABLE;

Some files were not shown because too many files have changed in this diff Show More