Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify MMU translation APIs #533

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading