• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load(
16    "//pw_build:pigweed.bzl",
17    "pw_facade",
18)
19
20package(default_visibility = ["//visibility:public"])
21
22licenses(["notice"])
23
24# This module has three facades, each of whose backends are set with a
25# different constraint_setting.
26#
27# - entry: This is the library that handles early exception entry and prepares
28#   any CPU state that must be available to the exception handler via the
29#   pw_cpu_exception_State object. The backend for this facade is
30#   architecture-specific.
31constraint_setting(
32    name = "entry_constraint_setting",
33)
34
35# - handler: This facade is backed by an application-specific handler that
36#   determines what to do when an exception is encountered. This may be
37#   capturing a crash report before resetting the device, or in some cases
38#   handling the exception to allow execution to continue.
39constraint_setting(
40    name = "handler_constraint_setting",
41)
42
43# - support: This facade provides architecture-independent functions that may be
44#   helpful for dumping CPU state in various forms. This allows an application
45#   to create an application-specific handler that is portable across multiple
46#   architectures.
47constraint_setting(
48    name = "support_constraint_setting",
49)
50
51pw_facade(
52    name = "entry",
53    hdrs = [
54        "public/pw_cpu_exception/entry.h",
55        "public/pw_cpu_exception/state.h",
56    ],
57    backend = ":entry_backend",
58    includes = ["public"],
59    deps = [
60        "//pw_preprocessor",
61    ],
62)
63
64pw_facade(
65    name = "handler",
66    srcs = ["start_exception_handler.cc"],
67    hdrs = ["public/pw_cpu_exception/handler.h"],
68    backend = ":handler_backend",
69    implementation_deps = [
70        "//pw_preprocessor",
71    ],
72    includes = ["public"],
73    deps = [":entry"],
74)
75
76pw_facade(
77    name = "support",
78    hdrs = ["public/pw_cpu_exception/support.h"],
79    backend = ":support_backend",
80    includes = ["public"],
81    deps = [
82        ":entry",
83    ],
84)
85
86constraint_value(
87    name = "basic_handler_backend",
88    constraint_setting = "//pw_cpu_exception:handler_constraint_setting",
89)
90
91cc_library(
92    name = "basic_handler",
93    srcs = ["basic_handler.cc"],
94    deps = [
95        ":entry",
96        ":handler_facade",
97        "//pw_log",
98    ],
99)
100
101# Override-able flags for each facade backend.
102label_flag(
103    name = "entry_backend",
104    build_setting_default = ":entry_backend_multiplexer",
105)
106
107label_flag(
108    name = "entry_backend_impl",
109    build_setting_default = ":entry_backend_impl_multiplexer",
110)
111
112label_flag(
113    name = "handler_backend",
114    build_setting_default = ":handler_backend_multiplexer",
115)
116
117label_flag(
118    name = "support_backend",
119    build_setting_default = ":support_backend_multiplexer",
120)
121
122# Default facade backends.
123alias(
124    name = "entry_backend_multiplexer",
125    actual = select({
126        "//pw_cpu_exception_cortex_m:entry_backend": "@pigweed//pw_cpu_exception_cortex_m:cpu_exception",
127        "//conditions:default": "//pw_build:unspecified_backend",
128    }),
129)
130
131alias(
132    name = "entry_backend_impl_multiplexer",
133    actual = select({
134        "//pw_cpu_exception_cortex_m:entry_backend": "@pigweed//pw_cpu_exception_cortex_m:cpu_exception_impl",
135        "//conditions:default": "//pw_build:unspecified_backend",
136    }),
137)
138
139alias(
140    name = "handler_backend_multiplexer",
141    actual = select({
142        ":basic_handler_backend": ":basic_handler",
143        "//conditions:default": "//pw_build:unspecified_backend",
144    }),
145)
146
147alias(
148    name = "support_backend_multiplexer",
149    actual = select({
150        "//pw_cpu_exception_cortex_m:support_backend": "@pigweed//pw_cpu_exception_cortex_m:support",
151        "//conditions:default": "//pw_build:unspecified_backend",
152    }),
153)
154