Created
September 25, 2024 15:46
-
-
Save edubart/ca253b609f3b5b61d4e9540016fa027e to your computer and use it in GitHub Desktop.
Machine C API rust bindings
This file contains hidden or 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
/* automatically generated by rust-bindgen 0.70.1 */ | |
pub const CM_MARCHID: u32 = 18; | |
pub const CM_VERSION_MAJOR: u32 = 0; | |
pub const CM_VERSION_MINOR: u32 = 18; | |
pub const CM_VERSION_PATCH: u32 = 1; | |
pub const CM_VERSION_LABEL: &[u8; 1] = b"\0"; | |
pub const CM_MIMPID: u32 = 18; | |
pub const CM_HASH_SIZE: cm_constant = 32; | |
pub const CM_TREE_LOG2_WORD_SIZE: cm_constant = 5; | |
pub const CM_TREE_LOG2_PAGE_SIZE: cm_constant = 12; | |
pub const CM_TREE_LOG2_ROOT_SIZE: cm_constant = 64; | |
pub type cm_constant = u32; | |
pub const CM_ERROR_OK: cm_error = 0; | |
pub const CM_ERROR_INVALID_ARGUMENT: cm_error = 1; | |
pub const CM_ERROR_DOMAIN_ERROR: cm_error = 2; | |
pub const CM_ERROR_LENGTH_ERROR: cm_error = 3; | |
pub const CM_ERROR_OUT_OF_RANGE: cm_error = 4; | |
pub const CM_ERROR_LOGIC_ERROR: cm_error = 5; | |
pub const CM_ERROR_RUNTIME_ERROR: cm_error = 6; | |
pub const CM_ERROR_RANGE_ERROR: cm_error = 7; | |
pub const CM_ERROR_OVERFLOW_ERROR: cm_error = 8; | |
pub const CM_ERROR_UNDERFLOW_ERROR: cm_error = 9; | |
pub const CM_ERROR_REGEX_ERROR: cm_error = 10; | |
pub const CM_ERROR_SYSTEM_ERROR: cm_error = 11; | |
pub const CM_ERROR_BAD_TYPEID: cm_error = 12; | |
pub const CM_ERROR_BAD_CAST: cm_error = 13; | |
pub const CM_ERROR_BAD_ANY_CAST: cm_error = 14; | |
pub const CM_ERROR_BAD_OPTIONAL_ACCESS: cm_error = 15; | |
pub const CM_ERROR_BAD_WEAK_PTR: cm_error = 16; | |
pub const CM_ERROR_BAD_FUNCTION_CALL: cm_error = 17; | |
pub const CM_ERROR_BAD_ALLOC: cm_error = 18; | |
pub const CM_ERROR_BAD_ARRAY_NEW_LENGTH: cm_error = 19; | |
pub const CM_ERROR_BAD_EXCEPTION: cm_error = 20; | |
pub const CM_ERROR_BAD_VARIANT_ACCESS: cm_error = 21; | |
pub const CM_ERROR_EXCEPTION: cm_error = 22; | |
pub const CM_ERROR_UNKNOWN: cm_error = 23; | |
pub type cm_error = u32; | |
pub const CM_BREAK_REASON_FAILED: cm_break_reason = 0; | |
pub const CM_BREAK_REASON_HALTED: cm_break_reason = 1; | |
pub const CM_BREAK_REASON_YIELDED_MANUALLY: cm_break_reason = 2; | |
pub const CM_BREAK_REASON_YIELDED_AUTOMATICALLY: cm_break_reason = 3; | |
pub const CM_BREAK_REASON_YIELDED_SOFTLY: cm_break_reason = 4; | |
pub const CM_BREAK_REASON_REACHED_TARGET_MCYCLE: cm_break_reason = 5; | |
pub type cm_break_reason = u32; | |
pub const CM_UARCH_BREAK_REASON_REACHED_TARGET_CYCLE: cm_uarch_break_reason = 0; | |
pub const CM_UARCH_BREAK_REASON_UARCH_HALTED: cm_uarch_break_reason = 1; | |
pub type cm_uarch_break_reason = u32; | |
pub const CM_ACCESS_LOG_TYPE_PROOFS: cm_access_log_type = 1; | |
pub const CM_ACCESS_LOG_TYPE_ANNOTATIONS: cm_access_log_type = 2; | |
pub const CM_ACCESS_LOG_TYPE_LARGE_DATA: cm_access_log_type = 4; | |
pub type cm_access_log_type = u32; | |
pub const CM_CSR_X0: cm_csr = 0; | |
pub const CM_CSR_X1: cm_csr = 1; | |
pub const CM_CSR_X2: cm_csr = 2; | |
pub const CM_CSR_X3: cm_csr = 3; | |
pub const CM_CSR_X4: cm_csr = 4; | |
pub const CM_CSR_X5: cm_csr = 5; | |
pub const CM_CSR_X6: cm_csr = 6; | |
pub const CM_CSR_X7: cm_csr = 7; | |
pub const CM_CSR_X8: cm_csr = 8; | |
pub const CM_CSR_X9: cm_csr = 9; | |
pub const CM_CSR_X10: cm_csr = 10; | |
pub const CM_CSR_X11: cm_csr = 11; | |
pub const CM_CSR_X12: cm_csr = 12; | |
pub const CM_CSR_X13: cm_csr = 13; | |
pub const CM_CSR_X14: cm_csr = 14; | |
pub const CM_CSR_X15: cm_csr = 15; | |
pub const CM_CSR_X16: cm_csr = 16; | |
pub const CM_CSR_X17: cm_csr = 17; | |
pub const CM_CSR_X18: cm_csr = 18; | |
pub const CM_CSR_X19: cm_csr = 19; | |
pub const CM_CSR_X20: cm_csr = 20; | |
pub const CM_CSR_X21: cm_csr = 21; | |
pub const CM_CSR_X22: cm_csr = 22; | |
pub const CM_CSR_X23: cm_csr = 23; | |
pub const CM_CSR_X24: cm_csr = 24; | |
pub const CM_CSR_X25: cm_csr = 25; | |
pub const CM_CSR_X26: cm_csr = 26; | |
pub const CM_CSR_X27: cm_csr = 27; | |
pub const CM_CSR_X28: cm_csr = 28; | |
pub const CM_CSR_X29: cm_csr = 29; | |
pub const CM_CSR_X30: cm_csr = 30; | |
pub const CM_CSR_X31: cm_csr = 31; | |
pub const CM_CSR_F0: cm_csr = 32; | |
pub const CM_CSR_F1: cm_csr = 33; | |
pub const CM_CSR_F2: cm_csr = 34; | |
pub const CM_CSR_F3: cm_csr = 35; | |
pub const CM_CSR_F4: cm_csr = 36; | |
pub const CM_CSR_F5: cm_csr = 37; | |
pub const CM_CSR_F6: cm_csr = 38; | |
pub const CM_CSR_F7: cm_csr = 39; | |
pub const CM_CSR_F8: cm_csr = 40; | |
pub const CM_CSR_F9: cm_csr = 41; | |
pub const CM_CSR_F10: cm_csr = 42; | |
pub const CM_CSR_F11: cm_csr = 43; | |
pub const CM_CSR_F12: cm_csr = 44; | |
pub const CM_CSR_F13: cm_csr = 45; | |
pub const CM_CSR_F14: cm_csr = 46; | |
pub const CM_CSR_F15: cm_csr = 47; | |
pub const CM_CSR_F16: cm_csr = 48; | |
pub const CM_CSR_F17: cm_csr = 49; | |
pub const CM_CSR_F18: cm_csr = 50; | |
pub const CM_CSR_F19: cm_csr = 51; | |
pub const CM_CSR_F20: cm_csr = 52; | |
pub const CM_CSR_F21: cm_csr = 53; | |
pub const CM_CSR_F22: cm_csr = 54; | |
pub const CM_CSR_F23: cm_csr = 55; | |
pub const CM_CSR_F24: cm_csr = 56; | |
pub const CM_CSR_F25: cm_csr = 57; | |
pub const CM_CSR_F26: cm_csr = 58; | |
pub const CM_CSR_F27: cm_csr = 59; | |
pub const CM_CSR_F28: cm_csr = 60; | |
pub const CM_CSR_F29: cm_csr = 61; | |
pub const CM_CSR_F30: cm_csr = 62; | |
pub const CM_CSR_F31: cm_csr = 63; | |
pub const CM_CSR_PC: cm_csr = 64; | |
pub const CM_CSR_FCSR: cm_csr = 65; | |
pub const CM_CSR_MVENDORID: cm_csr = 66; | |
pub const CM_CSR_MARCHID: cm_csr = 67; | |
pub const CM_CSR_MIMPID: cm_csr = 68; | |
pub const CM_CSR_MCYCLE: cm_csr = 69; | |
pub const CM_CSR_ICYCLEINSTRET: cm_csr = 70; | |
pub const CM_CSR_MSTATUS: cm_csr = 71; | |
pub const CM_CSR_MTVEC: cm_csr = 72; | |
pub const CM_CSR_MSCRATCH: cm_csr = 73; | |
pub const CM_CSR_MEPC: cm_csr = 74; | |
pub const CM_CSR_MCAUSE: cm_csr = 75; | |
pub const CM_CSR_MTVAL: cm_csr = 76; | |
pub const CM_CSR_MISA: cm_csr = 77; | |
pub const CM_CSR_MIE: cm_csr = 78; | |
pub const CM_CSR_MIP: cm_csr = 79; | |
pub const CM_CSR_MEDELEG: cm_csr = 80; | |
pub const CM_CSR_MIDELEG: cm_csr = 81; | |
pub const CM_CSR_MCOUNTEREN: cm_csr = 82; | |
pub const CM_CSR_MENVCFG: cm_csr = 83; | |
pub const CM_CSR_STVEC: cm_csr = 84; | |
pub const CM_CSR_SSCRATCH: cm_csr = 85; | |
pub const CM_CSR_SEPC: cm_csr = 86; | |
pub const CM_CSR_SCAUSE: cm_csr = 87; | |
pub const CM_CSR_STVAL: cm_csr = 88; | |
pub const CM_CSR_SATP: cm_csr = 89; | |
pub const CM_CSR_SCOUNTEREN: cm_csr = 90; | |
pub const CM_CSR_SENVCFG: cm_csr = 91; | |
pub const CM_CSR_ILRSC: cm_csr = 92; | |
pub const CM_CSR_IFLAGS: cm_csr = 93; | |
pub const CM_CSR_IUNREP: cm_csr = 94; | |
pub const CM_CSR_CLINT_MTIMECMP: cm_csr = 95; | |
pub const CM_CSR_PLIC_GIRQPEND: cm_csr = 96; | |
pub const CM_CSR_PLIC_GIRQSRVD: cm_csr = 97; | |
pub const CM_CSR_HTIF_TOHOST: cm_csr = 98; | |
pub const CM_CSR_HTIF_FROMHOST: cm_csr = 99; | |
pub const CM_CSR_HTIF_IHALT: cm_csr = 100; | |
pub const CM_CSR_HTIF_ICONSOLE: cm_csr = 101; | |
pub const CM_CSR_HTIF_IYIELD: cm_csr = 102; | |
pub const CM_CSR_UARCH_X0: cm_csr = 103; | |
pub const CM_CSR_UARCH_X1: cm_csr = 104; | |
pub const CM_CSR_UARCH_X2: cm_csr = 105; | |
pub const CM_CSR_UARCH_X3: cm_csr = 106; | |
pub const CM_CSR_UARCH_X4: cm_csr = 107; | |
pub const CM_CSR_UARCH_X5: cm_csr = 108; | |
pub const CM_CSR_UARCH_X6: cm_csr = 109; | |
pub const CM_CSR_UARCH_X7: cm_csr = 110; | |
pub const CM_CSR_UARCH_X8: cm_csr = 111; | |
pub const CM_CSR_UARCH_X9: cm_csr = 112; | |
pub const CM_CSR_UARCH_X10: cm_csr = 113; | |
pub const CM_CSR_UARCH_X11: cm_csr = 114; | |
pub const CM_CSR_UARCH_X12: cm_csr = 115; | |
pub const CM_CSR_UARCH_X13: cm_csr = 116; | |
pub const CM_CSR_UARCH_X14: cm_csr = 117; | |
pub const CM_CSR_UARCH_X15: cm_csr = 118; | |
pub const CM_CSR_UARCH_X16: cm_csr = 119; | |
pub const CM_CSR_UARCH_X17: cm_csr = 120; | |
pub const CM_CSR_UARCH_X18: cm_csr = 121; | |
pub const CM_CSR_UARCH_X19: cm_csr = 122; | |
pub const CM_CSR_UARCH_X20: cm_csr = 123; | |
pub const CM_CSR_UARCH_X21: cm_csr = 124; | |
pub const CM_CSR_UARCH_X22: cm_csr = 125; | |
pub const CM_CSR_UARCH_X23: cm_csr = 126; | |
pub const CM_CSR_UARCH_X24: cm_csr = 127; | |
pub const CM_CSR_UARCH_X25: cm_csr = 128; | |
pub const CM_CSR_UARCH_X26: cm_csr = 129; | |
pub const CM_CSR_UARCH_X27: cm_csr = 130; | |
pub const CM_CSR_UARCH_X28: cm_csr = 131; | |
pub const CM_CSR_UARCH_X29: cm_csr = 132; | |
pub const CM_CSR_UARCH_X30: cm_csr = 133; | |
pub const CM_CSR_UARCH_X31: cm_csr = 134; | |
pub const CM_CSR_UARCH_PC: cm_csr = 135; | |
pub const CM_CSR_UARCH_CYCLE: cm_csr = 136; | |
pub const CM_CSR_UARCH_HALT_FLAG: cm_csr = 137; | |
pub const CM_CSR_COUNT: cm_csr = 138; | |
pub const CM_CSR_IFLAGS_PRV: cm_csr = 139; | |
pub const CM_CSR_IFLAGS_X: cm_csr = 140; | |
pub const CM_CSR_IFLAGS_Y: cm_csr = 141; | |
pub const CM_CSR_IFLAGS_H: cm_csr = 142; | |
pub const CM_CSR_HTIF_TOHOST_DEV: cm_csr = 143; | |
pub const CM_CSR_HTIF_TOHOST_CMD: cm_csr = 144; | |
pub const CM_CSR_HTIF_TOHOST_REASON: cm_csr = 145; | |
pub const CM_CSR_HTIF_TOHOST_DATA: cm_csr = 146; | |
pub const CM_CSR_HTIF_FROMHOST_DEV: cm_csr = 147; | |
pub const CM_CSR_HTIF_FROMHOST_CMD: cm_csr = 148; | |
pub const CM_CSR_HTIF_FROMHOST_REASON: cm_csr = 149; | |
pub const CM_CSR_HTIF_FROMHOST_DATA: cm_csr = 150; | |
pub const CM_CSR_UNKNOWN: cm_csr = 151; | |
pub type cm_csr = u32; | |
pub type cm_hash = [u8; 32usize]; | |
#[repr(C)] | |
#[derive(Debug, Copy, Clone)] | |
pub struct cm_machine { | |
_unused: [u8; 0], | |
} | |
extern "C" { | |
pub fn cm_get_last_error_message() -> *const ::std::os::raw::c_char; | |
pub fn cm_get_default_config() -> *const ::std::os::raw::c_char; | |
pub fn cm_get_csr_address(csr: cm_csr) -> u64; | |
pub fn cm_create( | |
config: *const ::std::os::raw::c_char, | |
runtime_config: *const ::std::os::raw::c_char, | |
new_machine: *mut *mut cm_machine, | |
) -> i32; | |
pub fn cm_destroy(m: *mut cm_machine) -> i32; | |
pub fn cm_delete(m: *mut cm_machine); | |
pub fn cm_load( | |
dir: *const ::std::os::raw::c_char, | |
runtime_config: *const ::std::os::raw::c_char, | |
new_machine: *mut *mut cm_machine, | |
) -> i32; | |
pub fn cm_store(m: *mut cm_machine, dir: *const ::std::os::raw::c_char) -> i32; | |
pub fn cm_replace_memory_range( | |
m: *mut cm_machine, | |
start: u64, | |
length: u64, | |
shared: bool, | |
image_filename: *const ::std::os::raw::c_char, | |
) -> i32; | |
pub fn cm_get_initial_config( | |
m: *const cm_machine, | |
config: *mut *const ::std::os::raw::c_char, | |
) -> i32; | |
pub fn cm_get_memory_ranges( | |
m: *const cm_machine, | |
ranges: *mut *const ::std::os::raw::c_char, | |
) -> i32; | |
pub fn cm_get_root_hash(m: *mut cm_machine, hash: *mut cm_hash) -> i32; | |
pub fn cm_get_proof( | |
m: *mut cm_machine, | |
address: u64, | |
log2_size: i32, | |
proof: *mut *const ::std::os::raw::c_char, | |
) -> i32; | |
pub fn cm_read_word(m: *const cm_machine, address: u64, val: *mut u64) -> i32; | |
pub fn cm_read_csr(m: *const cm_machine, csr: cm_csr, val: *mut u64) -> i32; | |
pub fn cm_write_csr(m: *mut cm_machine, csr: cm_csr, val: u64) -> i32; | |
pub fn cm_read_memory(m: *const cm_machine, address: u64, data: *mut u8, length: u64) -> i32; | |
pub fn cm_write_memory(m: *mut cm_machine, address: u64, data: *const u8, length: u64) -> i32; | |
pub fn cm_read_virtual_memory( | |
m: *const cm_machine, | |
address: u64, | |
data: *mut u8, | |
length: u64, | |
) -> i32; | |
pub fn cm_write_virtual_memory( | |
m: *mut cm_machine, | |
address: u64, | |
data: *const u8, | |
length: u64, | |
) -> i32; | |
pub fn cm_translate_virtual_address(m: *const cm_machine, vaddr: u64, paddr: *mut u64) -> i32; | |
pub fn cm_read_mcycle(m: *const cm_machine, val: *mut u64) -> i32; | |
pub fn cm_read_iflags_X(m: *const cm_machine, val: *mut bool) -> i32; | |
pub fn cm_read_iflags_Y(m: *const cm_machine, val: *mut bool) -> i32; | |
pub fn cm_reset_iflags_Y(m: *mut cm_machine) -> i32; | |
pub fn cm_set_iflags_Y(m: *mut cm_machine) -> i32; | |
pub fn cm_read_iflags_H(m: *const cm_machine, val: *mut bool) -> i32; | |
pub fn cm_read_uarch_cycle(m: *const cm_machine, val: *mut u64) -> i32; | |
pub fn cm_read_uarch_halt_flag(m: *const cm_machine, val: *mut bool) -> i32; | |
pub fn cm_set_uarch_halt_flag(m: *mut cm_machine) -> i32; | |
pub fn cm_snapshot(m: *mut cm_machine) -> i32; | |
pub fn cm_commit(m: *mut cm_machine) -> i32; | |
pub fn cm_rollback(m: *mut cm_machine) -> i32; | |
pub fn cm_run(m: *mut cm_machine, mcycle_end: u64, break_reason: *mut cm_break_reason) -> i32; | |
pub fn cm_run_uarch( | |
m: *mut cm_machine, | |
uarch_cycle_end: u64, | |
uarch_break_reason: *mut cm_uarch_break_reason, | |
) -> i32; | |
pub fn cm_reset_uarch(m: *mut cm_machine) -> i32; | |
pub fn cm_send_cmio_response( | |
m: *mut cm_machine, | |
reason: u16, | |
data: *const u8, | |
length: u64, | |
) -> i32; | |
pub fn cm_log_step_uarch( | |
m: *mut cm_machine, | |
log_type: i32, | |
one_based: bool, | |
access_log: *mut *const ::std::os::raw::c_char, | |
) -> i32; | |
pub fn cm_log_reset_uarch( | |
m: *mut cm_machine, | |
log_type: i32, | |
one_based: bool, | |
access_log: *mut *const ::std::os::raw::c_char, | |
) -> i32; | |
pub fn cm_log_send_cmio_response( | |
m: *mut cm_machine, | |
reason: u16, | |
data: *const u8, | |
length: u64, | |
log_type: i32, | |
one_based: bool, | |
access_log: *mut *const ::std::os::raw::c_char, | |
) -> i32; | |
pub fn cm_verify_step_uarch( | |
root_hash_before: *const cm_hash, | |
access_log: *const ::std::os::raw::c_char, | |
root_hash_after: *const cm_hash, | |
one_based: bool, | |
) -> i32; | |
pub fn cm_verify_reset_uarch( | |
root_hash_before: *const cm_hash, | |
access_log: *const ::std::os::raw::c_char, | |
root_hash_after: *const cm_hash, | |
one_based: bool, | |
) -> i32; | |
pub fn cm_verify_send_cmio_response( | |
reason: u16, | |
data: *const u8, | |
length: u64, | |
root_hash_before: *const cm_hash, | |
access_log: *const ::std::os::raw::c_char, | |
root_hash_after: *const cm_hash, | |
one_based: bool, | |
) -> i32; | |
pub fn cm_verify_merkle_tree(m: *mut cm_machine, result: *mut bool) -> i32; | |
pub fn cm_verify_dirty_page_maps(m: *mut cm_machine, result: *mut bool) -> i32; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment