1 // Copyright 2019 The Pigweed Authors
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
7 // https://www.apache.org/licenses/LICENSE-2.0
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
16 // Platform-independent mechanism to catch hardware CPU faults in user code.
17 // This module encapsulates low level CPU exception handling assembly for the
18 // platform. By default, this module invokes the following user-defined function
19 // after early exception handling completes:
21 // pw_cpu_exception_DefaultHandler(pw_cpu_exception_State* state)
23 // If platform-dependent access to the CPU registers is needed, then
24 // applications can include the respective backend module directly; for example
25 // cpu_exception_armv7m.
27 // IMPORTANT: To use this module, you MUST implement
28 // pw_cpu_exception_DefaultHandler() in some part of your
31 #include "pw_preprocessor/compiler.h"
32 #include "pw_preprocessor/util.h"
34 // Low-level raw exception entry handler.
36 // Captures faulting CPU state into a platform-specific pw_cpu_exception_State
37 // object, then calls the user-provided fault handler.
39 // This function should be called immediately after a fault; typically by being
40 // in the interrupt vector table entries for the hard fault exceptions.
42 // Note: applications should almost never invoke this directly; if you do, make
43 // sure you know what you are doing.
44 PW_EXTERN_C PW_NO_PROLOGUE void pw_cpu_exception_Entry(void);