Skip to content

Commit

Permalink
Merge pull request #149 from deater/riscv
Browse files Browse the repository at this point in the history
add initial riscv support
  • Loading branch information
adanalis authored Jan 12, 2024
2 parents 0b6a138 + b464420 commit 4f3cbc2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/linux-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ typedef ucontext_t hwd_ucontext_t;
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.pc
#elif defined(__hppa__)
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.sc_iaoq[0]
#elif defined(__riscv)
#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.__gregs[REG_PC]
#else
#error "OVERFLOW_ADDRESS() undefined!"
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/linux-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static inline long long get_cycles()
return retval;
}

#elif (defined(__arm__) || defined(__mips__) || defined(__hppa__))
#elif (defined(__arm__) || defined(__mips__) || defined(__hppa__)) || defined(__riscv)
static inline long long
get_cycles( void )
{
Expand Down
10 changes: 10 additions & 0 deletions src/mb.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
#define rmb() asm volatile("lfence":::"memory")
#endif


#elif defined (__riscv)
#define RISCV_FENCE(p, s) \
__asm__ __volatile__ ("fence " #p "," #s : : : "memory")

/* These barriers need to enforce ordering on both devices or memory. */
#define mb() RISCV_FENCE(iorw,iorw)
#define rmb() RISCV_FENCE(ir,ir)
#define wmb() RISCV_FENCE(ow,ow)

#else
#error Need to define rmb for this architecture!
#error See the kernel source directory: tools/perf/perf.h file
Expand Down

0 comments on commit 4f3cbc2

Please sign in to comment.