Skip to content

Commit

Permalink
risc-v: put trap vector at the start of kernel image
Browse files Browse the repository at this point in the history
Debugging improvements: 
- Mark the trap handler as a function, so it's not just an arbitrary
  symbol for the linker.
- Force trap entry to be at the start of the kernel runtime image, so
  the linker does not put it at arbitrary locations. Page alignment is
  not required on RISC-V for the vector base address, 4-byte alignment
  is enough.

Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
axel-h committed Aug 27, 2023
1 parent 5e21f21 commit df325dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/arch/riscv/common_riscv.lds
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ SECTIONS

.text . : AT(ADDR(.text) - KERNEL_OFFSET)
{
. = ALIGN(4K);


/* Standard kernel */
/* runtime kernel */
*(.vectors)
*(.text)
}

Expand Down
8 changes: 4 additions & 4 deletions src/arch/riscv/traps.S
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@

#define REGBYTES (CONFIG_WORD_SIZE / 8)

.section .text

.global trap_entry
.extern c_handle_syscall
.extern c_handle_fastpath_reply_recv
.extern c_handle_fastpath_call
.extern c_handle_interrupt
.extern c_handle_exception

trap_entry:
.section .vectors, "ax"
BEGIN_FUNC(trap_entry)

#ifdef ENABLE_SMP_SUPPORT
/* The sscratch contains the stack for the current core */
Expand Down Expand Up @@ -145,3 +143,5 @@ interrupt:
/* Save NextIP */
STORE x1, (34*REGBYTES)(t0)
j c_handle_interrupt

END_FUNC(trap_entry)

0 comments on commit df325dc

Please sign in to comment.