OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [examples/] [isrdemo/] [src/] [isr_example.S] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
 
2
#include "encoding.h"
3
 
4
  .text
5
  .align 8
6
 
7
  .globl init_mtvec
8
init_mtvec:
9
  ##! init mtvec register (see https://github.com/riscv/riscv-test-env/blob/master/p/riscv_test.h)
10
  la t0, trap_entry
11
  csrw mtvec, t0
12
  li t0, 0x00000800
13
  csrs mie, t0       # Enable External irq (ftom PLIC) for M mode
14
  ret
15
 
16
 
17
trap_entry:
18
  ##! module CSRFile rises io_fatc signal that is cause of the 'ptw.invalidate'.
19
  fence
20
  csrw mscratch, a0;
21
 
22
  _save_context(tp)
23
 
24
  ## @brief Call function :
25
  ##       long handle_trap(long cause, long epc, long long regs[32])
26
  ##             a0 = argument 1: cause
27
  ##             a1 = argument 2: mepc
28
  ##             a2 = argument 3: pointer on stack
29
  ## @return     a0 New instruction pointer offset
30
  csrr a0, mcause
31
  csrr a1, mepc
32
  sd a1,COOP_REG_TP(tp)
33
  mv a2, sp
34
  # !!! Cannot reset external pending bits only via IrqController (page 28)
35
  li t0, 0x00000800
36
  csrc mip, t0      #csrc pseudo asm instruction clear CSR bit.
37
                    #[11] MEIP: machine pending external interrupt
38
  jal isr_example_c
39
 
40
  # tp-offset in the context array is used to save mepc value. An it may be
41
  # modified by isr handler during preemtive task switching.
42
  ld a1,COOP_REG_TP(tp)
43
  csrw mepc,a1
44
  _restore_context(tp)
45
  mret
46
 
47
.section ".tdata.begin"
48
.globl _tdata_begin
49
_tdata_begin:
50
 
51
.section ".tdata.end"
52
.globl _tdata_end
53
_tdata_end:
54
 
55
.section ".tbss.end"
56
.globl _tbss_end
57
_tbss_end:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.