1 // Copyright 2016 The Fuchsia Authors
2 //
3 // Use of this source code is governed by a MIT-style
4 // license that can be found in the LICENSE file or at
5 // https://opensource.org/licenses/MIT
6 
7 #pragma once
8 
9 #include <sys/types.h>
10 #include <zircon/compiler.h>
11 #include <zircon/types.h>
12 
13 __BEGIN_CDECLS
14 
15 typedef struct arch_exception_context arch_exception_context_t;
16 typedef struct zx_exception_report zx_exception_report_t;
17 
18 // Called by arch code when it cannot handle an exception.
19 // |context| is architecture-specific, and can be dumped to the console
20 // using arch_dump_exception_context(). Implemented by non-arch code.
21 zx_status_t dispatch_user_exception(uint exception_type,
22                                     arch_exception_context_t* context);
23 
24 // Dispatches an exception that was raised by a syscall using
25 // thread_signal_policy_exception() (see <kernel/thread.h>), causing
26 // dispatch_user_exception() to be called with the current context.
27 // Implemented by arch code.
28 zx_status_t arch_dispatch_user_policy_exception(void);
29 
30 // Dumps architecture-specific state to the console. |context| typically comes
31 // from a call to dispatch_user_exception(). Implemented by arch code.
32 void arch_dump_exception_context(const arch_exception_context_t* context);
33 
34 // Sets |report| using architecture-specific information from |context|.
35 // Implemented by arch code.
36 void arch_fill_in_exception_context(
37     const arch_exception_context_t* context, zx_exception_report_t* report);
38 
39 __END_CDECLS
40