1# Copyright 2020 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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/facade.gni") 18import("$dir_pw_docgen/docs.gni") 19import("$dir_pw_unit_test/test.gni") 20import("backend.gni") 21 22config("public_include_path") { 23 include_dirs = [ "public" ] 24} 25 26group("pw_cpu_exception") { 27 public_deps = [ 28 ":entry", 29 ":handler", 30 ] 31} 32 33# This module has three facades, each of whose backends are set with a 34# different GN variable. 35# 36# - entry: This is the library that handles early exception entry and prepares 37# any CPU state that must be available to the exception handler via the 38# pw_cpu_exception_State object. The backend for this facade is 39# architecture-specific. 40# Set this facade's backend via `pw_cpu_exception_ENTRY_BACKEND` 41# 42# - handler: This facade is backed by an application-specific handler that 43# determines what to do when an exception is encountered. This may be 44# capturing a crash report before resetting the device, or in some cases 45# handling the exception to allow execution to continue. 46# Set this facade's backend via `pw_cpu_exception_HANDLER_BACKEND` 47# 48# - support: This facade provides architecture-independent functions that may be 49# helpful for dumping CPU state in various forms. This allows an application 50# to create an application-specific handler that is portable across multiple 51# architectures. 52# Set this facade's backend via `pw_cpu_exception_SUPPORT_BACKEND` 53 54pw_facade("entry") { 55 backend = pw_cpu_exception_ENTRY_BACKEND 56 public_configs = [ ":public_include_path" ] 57 public_deps = [ "$dir_pw_preprocessor" ] 58 public = [ 59 "public/pw_cpu_exception/entry.h", 60 "public/pw_cpu_exception/state.h", 61 ] 62} 63 64# The entry facade is hard tied to the definition of the pw_cpu_exception_State, 65# so spliting them into separate facades would require extra configurations 66# along with extra compatibility checks to ensure they are never mismatched. 67# 68# Instead, this ":entry_impl" target collects the entry implementation from the 69# backend that depends on the handler which in turn depends on ":entry" to avoid 70# circular deps. 71# 72# This group ("$dir_pw_cpu_exception:entry_impl") must listed in 73# pw_build_LINK_DEPS if pw_cpu_exception_ENTRY_BACKEND is set. 74# 75# Entry backends must provide their own "*.impl" target that collects their 76# entry implementation. 77group("entry_impl") { 78 public_deps = [] 79 80 if (pw_cpu_exception_ENTRY_BACKEND != "") { 81 public_deps += [ get_label_info(pw_cpu_exception_ENTRY_BACKEND, 82 "label_no_toolchain") + ".impl" ] 83 } 84} 85 86pw_facade("handler") { 87 backend = pw_cpu_exception_HANDLER_BACKEND 88 public_configs = [ ":public_include_path" ] 89 public_deps = [ 90 ":entry", 91 "$dir_pw_preprocessor", 92 ] 93 sources = [ "start_exception_handler.cc" ] 94 public = [ "public/pw_cpu_exception/handler.h" ] 95} 96 97# This library is technically optional. It is recommended to use `support` when 98# doing basic dumps of CPU state. As an alternative, projects may choose to 99# directly depend on the entry backend if they require direct access to 100# pw_cpu_exception_State members. 101pw_facade("support") { 102 backend = pw_cpu_exception_SUPPORT_BACKEND 103 public_configs = [ ":public_include_path" ] 104 public_deps = [ 105 ":entry", 106 dir_pw_span, 107 ] 108 public = [ "public/pw_cpu_exception/support.h" ] 109} 110 111pw_source_set("basic_handler") { 112 deps = [ 113 ":handler.facade", 114 dir_pw_log, 115 ] 116 sources = [ "basic_handler.cc" ] 117} 118 119pw_doc_group("docs") { 120 sources = [ 121 "backends.rst", 122 "docs.rst", 123 ] 124} 125 126pw_test_group("tests") { 127} 128