1#[cfg(target_arch = "riscv32")]
4pub fn read_word() -> u32 {
5 riscv_common::csr_read_word()
6}
7
8#[cfg(not(target_arch = "riscv32"))]
9pub fn read_word() -> u32 {
10 panic!("csr_read_word is only available on riscv32")
11}
12
13#[cfg(target_arch = "riscv32")]
14pub fn write_word(word: u32) {
15 riscv_common::csr_write_word(word as usize);
16}
17
18#[cfg(not(target_arch = "riscv32"))]
19pub fn write_word(_word: u32) {
20 panic!("csr_write_word is only available on riscv32")
21}
22
23#[cfg(target_arch = "riscv32")]
24pub fn emit_cycle_marker() {
25 unsafe {
26 core::arch::asm!(
28 "csrrw x0, 0x7ff, x0",
29 options(nomem, nostack, preserves_flags)
30 )
31 }
32}
33
34#[cfg(not(target_arch = "riscv32"))]
35pub fn emit_cycle_marker() {
36 }
38
39#[cfg(target_arch = "riscv32")]
40pub fn exit_success(words: &[u32; 8]) -> ! {
41 riscv_common::zksync_os_finish_success(words)
42}
43
44#[cfg(not(target_arch = "riscv32"))]
45pub fn exit_success(_words: &[u32; 8]) -> ! {
46 panic!("exit_success is only available on riscv32")
47}
48
49#[cfg(target_arch = "riscv32")]
50pub fn exit_error() -> ! {
51 riscv_common::zksync_os_finish_error()
52}
53
54#[cfg(not(target_arch = "riscv32"))]
55pub fn exit_error() -> ! {
56 panic!("exit_error is only available on riscv32")
57}