-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pw_interrupt_cortex_a: Add pw_interrupt backend for A-profile processors
Change-Id: I53b570aab788eb0cde8e14c2342a31b9218938e3 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/261396 Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com> Reviewed-by: Dave Roth <davidroth@google.com> Commit-Queue: Randy Zhang <randyzhg@google.com>
- Loading branch information
Randy Zhang
authored and
CQ Bot Account
committed
Jan 21, 2025
1 parent
eb1926a
commit e61919c
Showing
12 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2025 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("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") | ||
load("//pw_build:compatibility.bzl", "incompatible_with_mcu") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
licenses(["notice"]) | ||
|
||
constraint_value( | ||
name = "backend", | ||
constraint_setting = "//pw_interrupt:backend_constraint_setting", | ||
) | ||
|
||
cc_library( | ||
name = "context", | ||
hdrs = [ | ||
"public_overrides/pw_interrupt_backend/context_inline.h", | ||
], | ||
strip_include_prefix = "public_overrides", | ||
target_compatible_with = [":backend"], | ||
deps = [ | ||
":context_implementation", | ||
"//pw_interrupt:context.facade", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "context_implementation", | ||
hdrs = [ | ||
"public/pw_interrupt_cortex_a/context_inline.h", | ||
], | ||
strip_include_prefix = "public", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
sphinx_docs_library( | ||
name = "docs", | ||
srcs = [ | ||
"docs.rst", | ||
], | ||
prefix = "pw_interrupt_cortex_a/", | ||
target_compatible_with = incompatible_with_mcu(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright 2025 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") | ||
|
||
config("public_include_path") { | ||
include_dirs = [ "public" ] | ||
visibility = [ ":*" ] | ||
} | ||
|
||
config("backend_config") { | ||
include_dirs = [ "public_overrides" ] | ||
visibility = [ ":*" ] | ||
} | ||
|
||
pw_source_set("context") { | ||
public_deps = [ "$dir_pw_interrupt:context.facade" ] | ||
public_configs = [ | ||
":public_include_path", | ||
":backend_config", | ||
] | ||
public = [ | ||
"public/pw_interrupt_cortex_a/context_inline.h", | ||
"public_overrides/pw_interrupt_backend/context_inline.h", | ||
] | ||
} | ||
|
||
pw_doc_group("docs") { | ||
sources = [ "docs.rst" ] | ||
} | ||
|
||
pw_test_group("tests") { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2025 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($ENV{PW_ROOT}/pw_build/pigweed.cmake) | ||
|
||
pw_add_library(pw_interrupt_cortex_a.context INTERFACE | ||
HEADERS | ||
public/pw_interrupt_cortex_a/context_inline.h | ||
public_overrides/pw_interrupt_backend/context_inline.h | ||
PUBLIC_INCLUDES | ||
public | ||
public_overrides | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
davidroth@google.com | ||
randyzhg@google.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.. _module-pw_interrupt_cortex_a: | ||
|
||
--------------------- | ||
pw_interrupt_cortex_a | ||
--------------------- | ||
.. pigweed-module:: | ||
:name: pw_interrupt_cortex_a | ||
|
||
Pigweed's interrupt Cortex-A module provides a set of architecture specific | ||
backends for ``pw_interrupt``. Currently this module only supports processors | ||
that implement the Aarch64 execution state. |
42 changes: 42 additions & 0 deletions
42
pw_interrupt_cortex_a/public/pw_interrupt_cortex_a/context_inline.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2025 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. | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace pw::interrupt { | ||
|
||
// This module is not preprocessor protected like pw_interrupt_cortex_m because | ||
// pw_preprocessor/arch.h does not have macros for Arm A-profile architectures. | ||
// And it is not straightforward to add them because of the "cortex_m" | ||
// cc_library. A more ground up refactor of pw_preprocessor is needed. For now, | ||
// leave the responsibility to the user this backend only for Arm A-profile | ||
// architectures. | ||
|
||
#if ((__ARM_ARCH_PROFILE == 'A') && (__ARM_ARCH == 8) && \ | ||
(__ARM_ARCH_ISA_A64 == 1)) | ||
inline bool InInterruptContext() { | ||
// Arm A-profile Architecture Registers describes if the Interrupt Status | ||
// Register (ISR_EL1) is zero if there is no exception (interrupt) being | ||
// processed. | ||
uint32_t isr_el1; | ||
asm volatile("MRS %0, ISR_EL1" : "=r"(isr_el1)); | ||
return isr_el1 != 0; | ||
} | ||
#else | ||
#error "This module is only intended for 64-bit ARMv8-A processors." | ||
#endif // ((__ARM_ARCH_PROFILE == 'A') && (__ARM_ARCH == 8) && | ||
// (__ARM_ARCH_ISA_A64 == 1)) | ||
|
||
} // namespace pw::interrupt |
19 changes: 19 additions & 0 deletions
19
pw_interrupt_cortex_a/public_overrides/pw_interrupt_backend/context_inline.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2025 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. | ||
|
||
// This override header includes the main tokenized logging header and defines | ||
// the PW_LOG macro as the tokenized logging macro. | ||
#pragma once | ||
|
||
#include "pw_interrupt_cortex_a/context_inline.h" |