1*61c4878aSAndroid Build Coastguard Worker# Copyright 2019 The Pigweed Authors 2*61c4878aSAndroid Build Coastguard Worker# 3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of 5*61c4878aSAndroid Build Coastguard Worker# the License at 6*61c4878aSAndroid Build Coastguard Worker# 7*61c4878aSAndroid Build Coastguard Worker# https://www.apache.org/licenses/LICENSE-2.0 8*61c4878aSAndroid Build Coastguard Worker# 9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under 13*61c4878aSAndroid Build Coastguard Worker# the License. 14*61c4878aSAndroid Build Coastguard Worker 15*61c4878aSAndroid Build Coastguard Workerload("//pw_build:compatibility.bzl", "boolean_constraint_value") 16*61c4878aSAndroid Build Coastguard Workerload("//pw_build:pw_facade.bzl", "pw_facade") 17*61c4878aSAndroid Build Coastguard Worker 18*61c4878aSAndroid Build Coastguard Workerpackage(default_visibility = ["//visibility:public"]) 19*61c4878aSAndroid Build Coastguard Worker 20*61c4878aSAndroid Build Coastguard Workerlicenses(["notice"]) 21*61c4878aSAndroid Build Coastguard Worker 22*61c4878aSAndroid Build Coastguard Worker# This module has three facades, each of whose backends are set with a 23*61c4878aSAndroid Build Coastguard Worker# different constraint_setting. 24*61c4878aSAndroid Build Coastguard Worker# 25*61c4878aSAndroid Build Coastguard Worker# - entry: This is the library that handles early exception entry and prepares 26*61c4878aSAndroid Build Coastguard Worker# any CPU state that must be available to the exception handler via the 27*61c4878aSAndroid Build Coastguard Worker# pw_cpu_exception_State object. The backend for this facade is 28*61c4878aSAndroid Build Coastguard Worker# architecture-specific. 29*61c4878aSAndroid Build Coastguard Workerconstraint_setting( 30*61c4878aSAndroid Build Coastguard Worker name = "entry_constraint_setting", 31*61c4878aSAndroid Build Coastguard Worker) 32*61c4878aSAndroid Build Coastguard Worker 33*61c4878aSAndroid Build Coastguard Worker# - handler: This facade is backed by an application-specific handler that 34*61c4878aSAndroid Build Coastguard Worker# determines what to do when an exception is encountered. This may be 35*61c4878aSAndroid Build Coastguard Worker# capturing a crash report before resetting the device, or in some cases 36*61c4878aSAndroid Build Coastguard Worker# handling the exception to allow execution to continue. 37*61c4878aSAndroid Build Coastguard Workerconstraint_setting( 38*61c4878aSAndroid Build Coastguard Worker name = "handler_constraint_setting", 39*61c4878aSAndroid Build Coastguard Worker) 40*61c4878aSAndroid Build Coastguard Worker 41*61c4878aSAndroid Build Coastguard Worker# - support: This facade provides architecture-independent functions that may be 42*61c4878aSAndroid Build Coastguard Worker# helpful for dumping CPU state in various forms. This allows an application 43*61c4878aSAndroid Build Coastguard Worker# to create an application-specific handler that is portable across multiple 44*61c4878aSAndroid Build Coastguard Worker# architectures. 45*61c4878aSAndroid Build Coastguard Workerconstraint_setting( 46*61c4878aSAndroid Build Coastguard Worker name = "support_constraint_setting", 47*61c4878aSAndroid Build Coastguard Worker) 48*61c4878aSAndroid Build Coastguard Worker 49*61c4878aSAndroid Build Coastguard Workerpw_facade( 50*61c4878aSAndroid Build Coastguard Worker name = "entry", 51*61c4878aSAndroid Build Coastguard Worker hdrs = [ 52*61c4878aSAndroid Build Coastguard Worker "public/pw_cpu_exception/entry.h", 53*61c4878aSAndroid Build Coastguard Worker "public/pw_cpu_exception/state.h", 54*61c4878aSAndroid Build Coastguard Worker ], 55*61c4878aSAndroid Build Coastguard Worker backend = ":entry_backend", 56*61c4878aSAndroid Build Coastguard Worker strip_include_prefix = "public", 57*61c4878aSAndroid Build Coastguard Worker deps = [ 58*61c4878aSAndroid Build Coastguard Worker "//pw_preprocessor", 59*61c4878aSAndroid Build Coastguard Worker ], 60*61c4878aSAndroid Build Coastguard Worker) 61*61c4878aSAndroid Build Coastguard Worker 62*61c4878aSAndroid Build Coastguard Workerpw_facade( 63*61c4878aSAndroid Build Coastguard Worker name = "handler", 64*61c4878aSAndroid Build Coastguard Worker srcs = ["start_exception_handler.cc"], 65*61c4878aSAndroid Build Coastguard Worker hdrs = ["public/pw_cpu_exception/handler.h"], 66*61c4878aSAndroid Build Coastguard Worker backend = ":handler_backend", 67*61c4878aSAndroid Build Coastguard Worker implementation_deps = [ 68*61c4878aSAndroid Build Coastguard Worker "//pw_preprocessor", 69*61c4878aSAndroid Build Coastguard Worker ], 70*61c4878aSAndroid Build Coastguard Worker strip_include_prefix = "public", 71*61c4878aSAndroid Build Coastguard Worker deps = [":entry"], 72*61c4878aSAndroid Build Coastguard Worker) 73*61c4878aSAndroid Build Coastguard Worker 74*61c4878aSAndroid Build Coastguard Workerpw_facade( 75*61c4878aSAndroid Build Coastguard Worker name = "support", 76*61c4878aSAndroid Build Coastguard Worker hdrs = ["public/pw_cpu_exception/support.h"], 77*61c4878aSAndroid Build Coastguard Worker backend = ":support_backend", 78*61c4878aSAndroid Build Coastguard Worker strip_include_prefix = "public", 79*61c4878aSAndroid Build Coastguard Worker deps = [ 80*61c4878aSAndroid Build Coastguard Worker ":entry", 81*61c4878aSAndroid Build Coastguard Worker ], 82*61c4878aSAndroid Build Coastguard Worker) 83*61c4878aSAndroid Build Coastguard Worker 84*61c4878aSAndroid Build Coastguard Workerconstraint_value( 85*61c4878aSAndroid Build Coastguard Worker name = "basic_handler_backend", 86*61c4878aSAndroid Build Coastguard Worker constraint_setting = "//pw_cpu_exception:handler_constraint_setting", 87*61c4878aSAndroid Build Coastguard Worker) 88*61c4878aSAndroid Build Coastguard Worker 89*61c4878aSAndroid Build Coastguard Worker# TODO: https://github.com/bazelbuild/bazel/issues/23003 - this shouldn't be 90*61c4878aSAndroid Build Coastguard Worker# needed, as it should be possible to have a config_setting as to whether 91*61c4878aSAndroid Build Coastguard Worker# the entry_backend is "//pw_build:unspecified_backend" or not, but that doesn't 92*61c4878aSAndroid Build Coastguard Worker# work currently due to the referenced bug. 93*61c4878aSAndroid Build Coastguard Workerboolean_constraint_value( 94*61c4878aSAndroid Build Coastguard Worker name = "enabled", 95*61c4878aSAndroid Build Coastguard Worker) 96*61c4878aSAndroid Build Coastguard Worker 97*61c4878aSAndroid Build Coastguard Workercc_library( 98*61c4878aSAndroid Build Coastguard Worker name = "basic_handler", 99*61c4878aSAndroid Build Coastguard Worker srcs = ["basic_handler.cc"], 100*61c4878aSAndroid Build Coastguard Worker deps = [ 101*61c4878aSAndroid Build Coastguard Worker ":entry", 102*61c4878aSAndroid Build Coastguard Worker ":handler.facade", 103*61c4878aSAndroid Build Coastguard Worker "//pw_log", 104*61c4878aSAndroid Build Coastguard Worker ], 105*61c4878aSAndroid Build Coastguard Worker) 106*61c4878aSAndroid Build Coastguard Worker 107*61c4878aSAndroid Build Coastguard Worker# Override-able flags for each facade backend. 108*61c4878aSAndroid Build Coastguard Workerlabel_flag( 109*61c4878aSAndroid Build Coastguard Worker name = "entry_backend", 110*61c4878aSAndroid Build Coastguard Worker build_setting_default = "//pw_build:unspecified_backend", 111*61c4878aSAndroid Build Coastguard Worker) 112*61c4878aSAndroid Build Coastguard Worker 113*61c4878aSAndroid Build Coastguard Workerlabel_flag( 114*61c4878aSAndroid Build Coastguard Worker name = "entry_backend_impl", 115*61c4878aSAndroid Build Coastguard Worker build_setting_default = "//pw_build:unspecified_backend", 116*61c4878aSAndroid Build Coastguard Worker) 117*61c4878aSAndroid Build Coastguard Worker 118*61c4878aSAndroid Build Coastguard Workerlabel_flag( 119*61c4878aSAndroid Build Coastguard Worker name = "handler_backend", 120*61c4878aSAndroid Build Coastguard Worker build_setting_default = "//pw_build:unspecified_backend", 121*61c4878aSAndroid Build Coastguard Worker) 122*61c4878aSAndroid Build Coastguard Worker 123*61c4878aSAndroid Build Coastguard Workerlabel_flag( 124*61c4878aSAndroid Build Coastguard Worker name = "support_backend", 125*61c4878aSAndroid Build Coastguard Worker build_setting_default = "//pw_build:unspecified_backend", 126*61c4878aSAndroid Build Coastguard Worker) 127