blob: 0ec0eea95342a5ef1a3c3bec6a8ec2fd006250cf [file] [log] [blame]
Furquan Shaikh2af76f42014-04-28 16:39:40 -07001/*
2 * This file is part of the libpayload project.
3 *
4 * Copyright 2013 Google Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _ARCH_EXCEPTION_H
31#define _ARCH_EXCEPTION_H
32
Aaron Durbin4f89d972014-09-16 22:23:57 -050033#include <arch/transition.h>
34
Aaron Durbincc175762014-08-27 16:45:12 -050035/* Initialize the exception handling on the current CPU. */
Furquan Shaikh2af76f42014-04-28 16:39:40 -070036void exception_init(void);
Furquan Shaikh2af76f42014-04-28 16:39:40 -070037
Julius Werner66a476a2015-10-12 16:45:21 -070038/* Initialize VBAR and SP_EL3. */
39void exception_init_asm(void *exception_stack_end);
40
Aaron Durbin4f89d972014-09-16 22:23:57 -050041/*
42 * Order matters for handling return values. The larger the value the higher
43 * the precedence.
44 */
45enum {
46 EXC_RET_IGNORED,
47 EXC_RET_ABORT,
48 EXC_RET_HANDLED,
49 EXC_RET_HANDLED_DUMP_STATE,
50};
51
52struct exception_handler {
53 int (*handler)(struct exc_state *state, uint64_t vector_id);
54 struct exception_handler *next;
55};
56
57
58/*
59 * Register a handler provided with the associated vector id. Returns 0 on
60 * sucess, < 0 on error. Note that registration is not thread/interrupt safe.
61 */
62int exception_handler_register(uint64_t vid, struct exception_handler *h);
63
64/*
65 * Unregister a handler from the vector id. Return 0 on success, < 0 on error.
66 * Note that the unregistration is not thread/interrupt safe.
67 */
68int exception_handler_unregister(uint64_t vid, struct exception_handler *h);
69
Furquan Shaikh2af76f42014-04-28 16:39:40 -070070#endif