Skip to content

Commit

Permalink
Merge pull request #533 from ChinYikMing/unify-mmu-trans
Browse files Browse the repository at this point in the history
Unify MMU translation APIs
  • Loading branch information
jserv authored Jan 4, 2025
2 parents 5a04f3a + dfab12e commit 61f5882
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 189 deletions.
18 changes: 17 additions & 1 deletion src/riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,20 @@ typedef void (*riscv_mem_write_s)(riscv_t *rv,
typedef void (*riscv_mem_write_b)(riscv_t *rv,
riscv_word_t addr,
riscv_byte_t data);
#if RV32_HAS(SYSTEM)
/*
* VA2PA handler
* The MMU walkers and fault checkers are defined in system.c
* Thus, exporting this handler through function pointer
* preserves the encapsulation of MMU translation.
*
* ifetch do not leverage this translation because basic block
* might be retranslated and the corresponding PTE is NULL.
*/
typedef riscv_word_t (*riscv_mem_translate_t)(riscv_t *rv,
riscv_word_t vaddr,
bool rw);
#endif

/* system instruction handlers */
typedef void (*riscv_on_ecall)(riscv_t *rv);
Expand All @@ -424,7 +438,9 @@ typedef struct {
riscv_mem_write_s mem_write_s;
riscv_mem_write_b mem_write_b;

/* TODO: add peripheral I/O interfaces */
#if RV32_HAS(SYSTEM)
riscv_mem_translate_t mem_translate;
#endif

/* system */
riscv_on_ecall on_ecall;
Expand Down
Loading

0 comments on commit 61f5882

Please sign in to comment.