@@ -9,6 +9,7 @@
void do_trap(struct cpu_user_regs *cpu_regs);
void handle_trap(void);
+void trap_init(void);
#endif /* __ASSEMBLY__ */
@@ -8,6 +8,7 @@
#include <public/version.h>
#include <asm/early_printk.h>
+#include <asm/traps.h>
void arch_get_xen_caps(xen_capabilities_info_t *info)
{
@@ -23,6 +24,8 @@ void __init noreturn start_xen(unsigned long bootcpu_id,
{
remove_identity_mapping();
+ trap_init();
+
printk("All set up\n");
for ( ;; )
@@ -12,6 +12,18 @@
#include <asm/riscv_encoding.h>
#include <asm/traps.h>
+/*
+ * Initialize the trap handling.
+ *
+ * The function is called after MMU is enabled.
+ */
+void trap_init(void)
+{
+ unsigned long addr = (unsigned long)&handle_trap;
+
+ csr_write(CSR_STVEC, addr);
+}
+
static const char *decode_trap_cause(unsigned long cause)
{
static const char *const trap_causes[] = {