| # Copyright 2021 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//python:proto.bzl", "py_proto_library") |
| load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") |
| load("//pw_build:compatibility.bzl", "incompatible_with_mcu") |
| load("//pw_build:pw_facade.bzl", "pw_facade") |
| load("//pw_protobuf_compiler:pw_proto_library.bzl", "pwpb_proto_library") |
| load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| licenses(["notice"]) |
| |
| # The crash facade provides architecture-independent APIs that may be helpful |
| # for analysing the CPU state delegating the reporting and crashing to the |
| # backend. |
| constraint_setting( |
| name = "crash_constraint_setting", |
| ) |
| |
| constraint_value( |
| name = "entry_backend", |
| constraint_setting = "//pw_cpu_exception:entry_constraint_setting", |
| ) |
| |
| constraint_value( |
| name = "support_backend", |
| constraint_setting = "//pw_cpu_exception:support_constraint_setting", |
| ) |
| |
| cc_library( |
| name = "config", |
| hdrs = ["pw_cpu_exception_cortex_m_private/config.h"], |
| deps = [":config_override"], |
| ) |
| |
| label_flag( |
| name = "config_override", |
| build_setting_default = "//pw_build:default_module_config", |
| ) |
| |
| # Override-able flag for each facade backend. |
| label_flag( |
| name = "crash_backend", |
| build_setting_default = "//pw_build:unspecified_backend", |
| ) |
| |
| pw_facade( |
| name = "crash", |
| srcs = ["crash.cc"], |
| hdrs = ["public/pw_cpu_exception_cortex_m/crash.h"], |
| backend = ":crash_backend", |
| strip_include_prefix = "public", |
| # TODO: https://pwbug.dev/350758633 - add v6m support |
| target_compatible_with = select({ |
| "@platforms//cpu:armv7-m": [], |
| "@platforms//cpu:armv7e-m": [], |
| "@platforms//cpu:armv7e-mf": [], |
| "@platforms//cpu:armv8-m": [], |
| "//conditions:default": ["@platforms//:incompatible"], |
| }), |
| deps = [ |
| ":config", |
| ":cortex_m_constants", |
| ":cpu_state", |
| "//pw_preprocessor:cortex_m", |
| ], |
| ) |
| |
| cc_library( |
| name = "cpu_state", |
| hdrs = ["public/pw_cpu_exception_cortex_m/cpu_state.h"], |
| strip_include_prefix = "public", |
| deps = [ |
| "//pw_preprocessor", |
| "//pw_preprocessor:cortex_m", |
| ], |
| ) |
| |
| cc_library( |
| name = "util", |
| srcs = ["util.cc"], |
| hdrs = ["public/pw_cpu_exception_cortex_m/util.h"], |
| strip_include_prefix = "public", |
| target_compatible_with = select({ |
| "@platforms//cpu:armv6-m": [], |
| "@platforms//cpu:armv7-m": [], |
| "@platforms//cpu:armv7e-m": [], |
| "@platforms//cpu:armv7e-mf": [], |
| "@platforms//cpu:armv8-m": [], |
| "//conditions:default": ["@platforms//:incompatible"], |
| }), |
| deps = [ |
| ":config", |
| ":cortex_m_constants", |
| ":cpu_state", |
| "//pw_log", |
| "//pw_preprocessor:cortex_m", |
| ], |
| ) |
| |
| cc_library( |
| name = "support", |
| srcs = ["support.cc"], |
| deps = [ |
| ":config", |
| ":cortex_m_constants", |
| ":cpu_state", |
| ":util", |
| "//pw_cpu_exception:support.facade", |
| "//pw_log", |
| "//pw_preprocessor", |
| "//pw_preprocessor:cortex_m", |
| "//pw_string", |
| ], |
| ) |
| |
| cc_library( |
| name = "proto_dump", |
| srcs = ["proto_dump.cc"], |
| hdrs = ["public/pw_cpu_exception_cortex_m/proto_dump.h"], |
| strip_include_prefix = "public", |
| target_compatible_with = select({ |
| "@platforms//cpu:armv6-m": [], |
| "@platforms//cpu:armv7-m": [], |
| "@platforms//cpu:armv7e-m": [], |
| "@platforms//cpu:armv7e-mf": [], |
| "@platforms//cpu:armv8-m": [], |
| "//conditions:default": ["@platforms//:incompatible"], |
| }), |
| deps = [ |
| ":config", |
| ":cpu_state", |
| ":cpu_state_protos_pwpb", |
| ":support", |
| "//pw_protobuf", |
| "//pw_status", |
| "//pw_stream", |
| ], |
| ) |
| |
| proto_library( |
| name = "cpu_state_protos", |
| srcs = ["pw_cpu_exception_cortex_m_protos/cpu_state.proto"], |
| import_prefix = "pw_cpu_exception_cortex_m_protos", |
| strip_import_prefix = "/pw_cpu_exception_cortex_m/pw_cpu_exception_cortex_m_protos", |
| ) |
| |
| py_proto_library( |
| name = "cpu_state_protos_pb2", |
| deps = [":cpu_state_protos"], |
| ) |
| |
| pwpb_proto_library( |
| name = "cpu_state_protos_pwpb", |
| deps = [":cpu_state_protos"], |
| ) |
| |
| cc_library( |
| name = "cpu_exception", |
| hdrs = [ |
| "public_overrides/pw_cpu_exception_backend/state.h", |
| ], |
| includes = [ |
| "public_overrides", |
| ], |
| deps = [ |
| ":cpu_state", |
| "//pw_cpu_exception:entry.facade", |
| "//pw_preprocessor", |
| "//pw_preprocessor:cortex_m", |
| ], |
| ) |
| |
| cc_library( |
| name = "cpu_exception_impl", |
| srcs = select({ |
| "@platforms//cpu:armv6-m": ["entry_armv6m.cc"], |
| "//conditions:default": ["entry.cc"], |
| }), |
| target_compatible_with = select({ |
| "@platforms//cpu:armv6-m": [], |
| "@platforms//cpu:armv7-m": [], |
| "@platforms//cpu:armv7e-m": [], |
| "@platforms//cpu:armv7e-mf": [], |
| "@platforms//cpu:armv8-m": [], |
| "//conditions:default": ["@platforms//:incompatible"], |
| }), |
| deps = [ |
| ":config", |
| ":cortex_m_constants", |
| ":cpu_state", |
| ":util", |
| # Depend on the full backends in the impl target. |
| "//pw_cpu_exception:entry", |
| "//pw_cpu_exception:handler", |
| ], |
| ) |
| |
| cc_library( |
| name = "snapshot", |
| srcs = ["snapshot.cc"], |
| hdrs = ["public/pw_cpu_exception_cortex_m/snapshot.h"], |
| strip_include_prefix = "public", |
| deps = [ |
| ":config", |
| ":cortex_m_constants", |
| ":cpu_state", |
| ":cpu_state_protos_pwpb", |
| ":proto_dump", |
| ":util", |
| "//pw_log", |
| "//pw_protobuf", |
| "//pw_status", |
| "//pw_thread:snapshot", |
| "//pw_thread:thread_pwpb", |
| ], |
| ) |
| |
| cc_library( |
| name = "cortex_m_constants", |
| hdrs = ["pw_cpu_exception_cortex_m_private/cortex_m_constants.h"], |
| visibility = ["//visibility:private"], |
| deps = ["//pw_preprocessor:cortex_m"], |
| ) |
| |
| cc_library( |
| name = "cpu_exception_entry_test_util", |
| srcs = ["exception_entry_test_util.cc"], |
| hdrs = ["public/pw_cpu_exception_cortex_m/exception_entry_test_util.h"], |
| strip_include_prefix = "public", |
| target_compatible_with = select({ |
| "@platforms//cpu:armv6-m": [], |
| "@platforms//cpu:armv7-m": [], |
| "@platforms//cpu:armv7e-m": [], |
| "@platforms//cpu:armv7e-mf": [], |
| "@platforms//cpu:armv8-m": [], |
| "//conditions:default": ["@platforms//:incompatible"], |
| }), |
| deps = [ |
| ":cortex_m_constants", |
| ":cpu_state", |
| ], |
| ) |
| |
| pw_cc_test( |
| name = "cpu_exception_entry_test", |
| srcs = select({ |
| "@platforms//cpu:armv6-m": ["exception_entry_test_armv6m.cc"], |
| "//conditions:default": ["exception_entry_test.cc"], |
| }), |
| deps = [ |
| ":config", |
| ":cpu_exception", |
| ":cpu_exception_entry_test_util", |
| ":cpu_exception_impl", |
| ":cpu_state", |
| "//pw_cpu_exception:handler", |
| "//pw_cpu_exception:support", |
| ], |
| ) |
| |
| pw_cc_test( |
| name = "util_test", |
| srcs = [ |
| "util_test.cc", |
| ], |
| deps = [ |
| ":cpu_state", |
| ":util", |
| ], |
| ) |
| |
| pw_cc_test( |
| name = "crash_test", |
| srcs = [ |
| "crash.cc", |
| "crash_test.cc", |
| "private/pw_cpu_exception_cortex_m_backend/crash.h", |
| "public/pw_cpu_exception_cortex_m/crash.h", |
| ], |
| includes = ["private"], |
| # TODO: https://pwbug.dev/350758633 - Add v6m support. |
| # TODO: https://pwbug.dev/353533678 - Failing on Cortex-M33 right now. |
| target_compatible_with = select({ |
| "@platforms//cpu:armv7-m": [], |
| "@platforms//cpu:armv7e-m": [], |
| "@platforms//cpu:armv7e-mf": [], |
| "//conditions:default": ["@platforms//:incompatible"], |
| }), |
| deps = [ |
| ":config", |
| ":cortex_m_constants", |
| ":cpu_state", |
| ":util", |
| "//pw_cpu_exception:entry", |
| "//pw_preprocessor", |
| "//pw_preprocessor:cortex_m", |
| "//pw_status", |
| "//pw_string:builder", |
| "//pw_sync:lock_annotations", |
| "//pw_sync:mutex", |
| ], |
| ) |
| |
| sphinx_docs_library( |
| name = "docs", |
| srcs = [ |
| "docs.rst", |
| ], |
| prefix = "pw_cpu_exception_cortex_m/", |
| target_compatible_with = incompatible_with_mcu(), |
| ) |