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