diff options
author | Austin Foxley <afoxley@google.com> | 2023-07-28 17:45:32 +0000 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-07-28 17:45:32 +0000 |
commit | 9ed69efeee1e4564b268ce83c3ba7dcd2ca24831 (patch) | |
tree | 0d0f4142d9f9cdb6025fa5374cd2a561bcdf251e /pw_interrupt_xtensa | |
parent | 50925b562f5fff38ba36a711e5e35b53326ecd5a (diff) | |
download | pigweed-9ed69efeee1e4564b268ce83c3ba7dcd2ca24831.tar.gz |
pw_interrupt: Add backend for xtensa processors
Change-Id: Ie883afce68738469fe88257468edd9ae43c18189
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/160031
Reviewed-by: Jonathon Reinhart <jrreinhart@google.com>
Commit-Queue: Austin Foxley <afoxley@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Diffstat (limited to 'pw_interrupt_xtensa')
-rw-r--r-- | pw_interrupt_xtensa/BUILD.bazel | 36 | ||||
-rw-r--r-- | pw_interrupt_xtensa/BUILD.gn | 31 | ||||
-rw-r--r-- | pw_interrupt_xtensa/context.cc | 34 | ||||
-rw-r--r-- | pw_interrupt_xtensa/docs.rst | 7 |
4 files changed, 108 insertions, 0 deletions
diff --git a/pw_interrupt_xtensa/BUILD.bazel b/pw_interrupt_xtensa/BUILD.bazel new file mode 100644 index 000000000..c3ab8e2aa --- /dev/null +++ b/pw_interrupt_xtensa/BUILD.bazel @@ -0,0 +1,36 @@ +# Copyright 2023 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +load( + "//pw_build:pigweed.bzl", + "pw_cc_library", +) + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +constraint_value( + name = "backend", + constraint_setting = "//pw_interrupt:backend_constraint_setting", +) + +pw_cc_library( + name = "context", + srcs = ["context.cc"], + target_compatible_with = [":backend"], + deps = [ + "//pw_interrupt:context_facade", + ], +) diff --git a/pw_interrupt_xtensa/BUILD.gn b/pw_interrupt_xtensa/BUILD.gn new file mode 100644 index 000000000..c822cb3cb --- /dev/null +++ b/pw_interrupt_xtensa/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright 2023 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +import("//build_overrides/pigweed.gni") + +import("$dir_pw_build/target_types.gni") +import("$dir_pw_docgen/docs.gni") +import("$dir_pw_unit_test/test.gni") + +pw_source_set("context") { + public_deps = [ "$dir_pw_interrupt:context.facade" ] + sources = [ "context.cc" ] +} + +pw_doc_group("docs") { + sources = [ "docs.rst" ] +} + +pw_test_group("tests") { +} diff --git a/pw_interrupt_xtensa/context.cc b/pw_interrupt_xtensa/context.cc new file mode 100644 index 000000000..9c16fcaf5 --- /dev/null +++ b/pw_interrupt_xtensa/context.cc @@ -0,0 +1,34 @@ +// Copyright 2023 The Pigweed Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +#include "pw_interrupt/context.h" + +#include <xtensa/config/core.h> +#include <xtensa/hal.h> + +#include <cstdint> + +namespace pw::interrupt { + +bool InInterruptContext() { + // xthal_intlevel_get returns the current interrupt level of the processor + // (value of PS.INTLEVEL register). C based handlers are always dispatched + // from an interrupt level below XCHAL_EXCM_LEVEL - handlers running above + // this level must be written in assembly. The interrupt level is set to zero + // when interrupts are enabled but the core isn't currently procesing one. + const uint32_t int_level = xthal_intlevel_get(); + return (int_level < XCHAL_EXCM_LEVEL) && (int_level > 0); +} + +} // namespace pw::interrupt diff --git a/pw_interrupt_xtensa/docs.rst b/pw_interrupt_xtensa/docs.rst new file mode 100644 index 000000000..182bdbd35 --- /dev/null +++ b/pw_interrupt_xtensa/docs.rst @@ -0,0 +1,7 @@ +.. _module-pw_interrupt_xtensa: + +------------------- +pw_interrupt_xtensa +------------------- +Pigweed's interrupt Xtensa module provides an architecture specific +backend for ``pw_interrupt``. |