Skip to content

Commit

Permalink
temp: add define to toggle the use of fw RAM
Browse files Browse the repository at this point in the history
  • Loading branch information
dehanj committed Nov 19, 2024
1 parent cd62ace commit b7ba452
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hw/application_fpga/fw/tk1/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

#include <stdint.h>

#define USE_FW_RAM_IN_SYSCALL

void inner_syscall(volatile syscall_t *ctx);

void syscall(syscall_t *ctx)
{

#ifdef USE_FW_RAM_IN_SYSCALL
asm volatile("addi x5, sp, 0;" // Save current SP value in x5
"li sp, 0xd0000800;" // Change SP to top of FW_RAM
"addi sp, sp, -4;" // Adjust SP to make space
Expand All @@ -23,16 +26,19 @@ void syscall(syscall_t *ctx)
: // No outputs
: // No inputs
: "x5", "memory"); // Clobbers
#endif //USE_FW_RAM_IN_SYSCALL

inner_syscall(ctx);

#ifdef USE_FW_RAM_IN_SYSCALL
asm volatile("lui t0, 0xd0000;" // Load the upper 20 bits
"addi t0, t0, 0x7fc;" // Add the lower 12 bits for full
"lw t1, 0(t0);" // Load the word at address in t0 to t1
"addi sp,t1, 0;" // Copy the value from t1 to sp
: // No outputs
: // No inputs
: "t0", "t1", "memory"); // Clobbers
#endif //USE_FW_RAM_IN_SYSCALL

return;
}
Expand Down

0 comments on commit b7ba452

Please sign in to comment.