2021-01-16 15:45:10 +00:00
|
|
|
/* SPDX-License-Identifier: MIT */
|
|
|
|
|
|
|
|
#ifndef __EXCEPTION_H__
|
|
|
|
#define __EXCEPTION_H__
|
|
|
|
|
2021-09-21 11:29:19 +00:00
|
|
|
#define SIZEOF_EXC_INFO (64 * 8)
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
|
|
|
|
#include <assert.h>
|
2021-02-24 12:46:33 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2021-05-04 10:34:08 +00:00
|
|
|
#include "types.h"
|
|
|
|
|
2021-02-10 15:55:24 +00:00
|
|
|
enum exc_guard_t {
|
|
|
|
GUARD_OFF = 0,
|
|
|
|
GUARD_SKIP,
|
|
|
|
GUARD_MARK,
|
|
|
|
GUARD_RETURN,
|
|
|
|
GUARD_TYPE_MASK = 0xff,
|
|
|
|
GUARD_SILENT = 0x100,
|
|
|
|
};
|
2021-01-30 06:14:38 +00:00
|
|
|
|
2021-09-21 11:29:19 +00:00
|
|
|
struct exc_info {
|
|
|
|
u64 regs[32];
|
|
|
|
u64 spsr;
|
|
|
|
u64 elr;
|
|
|
|
u64 esr;
|
|
|
|
u64 far;
|
|
|
|
u64 afsr1;
|
|
|
|
u64 sp[3];
|
|
|
|
u64 cpu_id;
|
|
|
|
u64 mpidr;
|
|
|
|
u64 elr_phys;
|
|
|
|
u64 far_phys;
|
|
|
|
u64 sp_phys;
|
|
|
|
void *extra;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(struct exc_info) <= SIZEOF_EXC_INFO, "Please increase SIZEOF_EXC_INFO");
|
|
|
|
static_assert((sizeof(struct exc_info) & 15) == 0, "SIZEOF_EXC_INFO must be a multiple of 16");
|
|
|
|
|
2021-01-30 06:14:38 +00:00
|
|
|
extern volatile enum exc_guard_t exc_guard;
|
|
|
|
extern volatile int exc_count;
|
|
|
|
|
2021-01-16 15:45:10 +00:00
|
|
|
void exception_initialize(void);
|
2021-01-30 08:02:51 +00:00
|
|
|
void exception_shutdown(void);
|
2021-01-16 15:45:10 +00:00
|
|
|
|
2021-05-04 10:36:23 +00:00
|
|
|
void print_regs(u64 *regs, int el12);
|
|
|
|
|
2021-02-24 12:46:33 +00:00
|
|
|
uint64_t el0_call(void *func, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
|
2021-03-04 12:28:07 +00:00
|
|
|
uint64_t el1_call(void *func, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
|
2021-02-24 12:46:33 +00:00
|
|
|
|
2021-01-16 15:45:10 +00:00
|
|
|
#endif
|
2021-09-21 11:29:19 +00:00
|
|
|
|
|
|
|
#endif
|