-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing callbacks in sail-riscv for state-changing events
1. Added callback functions for XRegs, FRegs, VRegs, PC, CSR, memory writes and CSR, memory reads. 2. Added implementation of callbacks for RVFI records in riscv_rvfi_callbacks.c. 3. Added default callback OCaml-implementations in the file platform.ml.
- Loading branch information
1 parent
87f8bb3
commit e385f56
Showing
21 changed files
with
372 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* The model assumes that these functions do not change the state of the model. | ||
*/ | ||
int mem_write_callback(uint64_t addr, uint64_t width, lbits value) { } | ||
int mem_read_callback(uint64_t addr, uint64_t width, lbits value) { } | ||
int mem_exception_callback(uint64_t addr, uint64_t num_of_exception) { } | ||
int xreg_write_callback(unsigned reg, uint64_t value) { } | ||
int freg_write_callback(unsigned reg, uint64_t value) { } | ||
int csr_write_callback(unsigned reg, uint64_t value) { } | ||
int csr_read_callback(unsigned reg, uint64_t value) { } | ||
int vreg_write_callback(unsigned reg, lbits value) { } | ||
int pc_write_callback(uint64_t value) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "riscv_config.h" | ||
|
||
int zrvfi_write(uint64_t addr, int64_t width, lbits value); | ||
int zrvfi_read(uint64_t addr, sail_int width, lbits value); | ||
int zrvfi_mem_exception(uint64_t addr); | ||
int zrvfi_wX(int64_t reg, uint64_t value); | ||
|
||
int mem_write_callback(uint64_t addr, uint64_t width, lbits value) | ||
{ | ||
if (rv_enable_callbacks) | ||
zrvfi_write(addr, width, value); | ||
} | ||
int mem_read_callback(uint64_t addr, uint64_t width, lbits value) | ||
{ | ||
if (rv_enable_callbacks) { | ||
sail_int len; | ||
CREATE(sail_int)(&len); | ||
CONVERT_OF(sail_int, mach_int)(&len, width); | ||
zrvfi_read(addr, len, value); | ||
KILL(sail_int)(&len); | ||
} | ||
} | ||
int mem_exception_callback(uint64_t addr, uint64_t num_of_exception) | ||
{ | ||
if (rv_enable_callbacks) | ||
zrvfi_mem_exception(addr); | ||
} | ||
int xreg_write_callback(unsigned reg, uint64_t value) | ||
{ | ||
if (rv_enable_callbacks) | ||
zrvfi_wX(reg, value); | ||
} | ||
int freg_write_callback(unsigned reg, uint64_t value) { } | ||
int csr_write_callback(unsigned reg, uint64_t value) { } | ||
int csr_read_callback(unsigned reg, uint64_t value) { } | ||
int vreg_write_callback(unsigned reg, lbits value) { } | ||
int pc_write_callback(uint64_t value) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.