root/kernel/kernelvec.S

/* [<][>][^][v][top][bottom][index][help] */
   1         #
   2         # interrupts and exceptions while in supervisor
   3         # mode come here.
   4         #
   5         # the current stack is a kernel stack.
   6         # push registers, call kerneltrap().
   7         # when kerneltrap() returns, restore registers, return.
   8         #
   9 .globl kerneltrap
  10 .globl kernelvec
  11 .align 4
  12 kernelvec:
  13         # make room to save registers.
  14         addi sp, sp, -256
  15 
  16         # save caller-saved registers.
  17         sd ra, 0(sp)
  18         sd sp, 8(sp)
  19         sd gp, 16(sp)
  20         sd tp, 24(sp)
  21         sd t0, 32(sp)
  22         sd t1, 40(sp)
  23         sd t2, 48(sp)
  24         sd a0, 72(sp)
  25         sd a1, 80(sp)
  26         sd a2, 88(sp)
  27         sd a3, 96(sp)
  28         sd a4, 104(sp)
  29         sd a5, 112(sp)
  30         sd a6, 120(sp)
  31         sd a7, 128(sp)
  32         sd t3, 216(sp)
  33         sd t4, 224(sp)
  34         sd t5, 232(sp)
  35         sd t6, 240(sp)
  36 
  37         # call the C trap handler in trap.c
  38         call kerneltrap
  39 
  40         # restore registers.
  41         ld ra, 0(sp)
  42         ld sp, 8(sp)
  43         ld gp, 16(sp)
  44         # not tp (contains hartid), in case we moved CPUs
  45         ld t0, 32(sp)
  46         ld t1, 40(sp)
  47         ld t2, 48(sp)
  48         ld a0, 72(sp)
  49         ld a1, 80(sp)
  50         ld a2, 88(sp)
  51         ld a3, 96(sp)
  52         ld a4, 104(sp)
  53         ld a5, 112(sp)
  54         ld a6, 120(sp)
  55         ld a7, 128(sp)
  56         ld t3, 216(sp)
  57         ld t4, 224(sp)
  58         ld t5, 232(sp)
  59         ld t6, 240(sp)
  60 
  61         addi sp, sp, 256
  62 
  63         # return to whatever we were doing in the kernel.
  64         sret

/* [<][>][^][v][top][bottom][index][help] */