1- //! ABI definitions for symbols exported by risc0-zkvm-platform.
2-
3- // Included here so we don't have to depend on risc0-zkvm-platform.
4- //
5- // FIXME: Should we move this to the "libc" crate? It seems like other
6- // architectures put a lot of this kind of stuff there. But there's
7- // currently no risc0 fork of the libc crate, so we'd either have to
8- // fork it or upstream it.
9-
10- #![ allow( dead_code) ]
11- pub const DIGEST_WORDS : usize = 8 ;
12-
13- /// Standard IO file descriptors for use with sys_read and sys_write.
14- pub mod fileno {
15- pub const STDIN : u32 = 0 ;
16- pub const STDOUT : u32 = 1 ;
17- pub const STDERR : u32 = 2 ;
18- pub const JOURNAL : u32 = 3 ;
19- }
20-
211unsafe extern "C" {
22- // Wrappers around syscalls provided by risc0-zkvm-platform:
23- pub fn sys_halt ( ) ;
24- pub fn sys_output ( output_id : u32 , output_value : u32 ) ;
25- pub fn sys_sha_compress (
26- out_state : * mut [ u32 ; DIGEST_WORDS ] ,
27- in_state : * const [ u32 ; DIGEST_WORDS ] ,
28- block1_ptr : * const [ u32 ; DIGEST_WORDS ] ,
29- block2_ptr : * const [ u32 ; DIGEST_WORDS ] ,
30- ) ;
31- pub fn sys_sha_buffer (
32- out_state : * mut [ u32 ; DIGEST_WORDS ] ,
33- in_state : * const [ u32 ; DIGEST_WORDS ] ,
34- buf : * const u8 ,
35- count : u32 ,
36- ) ;
37- pub fn sys_rand ( recv_buf : * mut u32 , words : usize ) ;
38- pub fn sys_panic ( msg_ptr : * const u8 , len : usize ) -> !;
39- pub fn sys_log ( msg_ptr : * const u8 , len : usize ) ;
40- pub fn sys_cycle_count ( ) -> usize ;
41- pub fn sys_read ( fd : u32 , recv_buf : * mut u8 , nrequested : usize ) -> usize ;
42- pub fn sys_write ( fd : u32 , write_buf : * const u8 , nbytes : usize ) ;
43- pub fn sys_getenv (
44- recv_buf : * mut u32 ,
45- words : usize ,
46- varname : * const u8 ,
47- varname_len : usize ,
48- ) -> usize ;
49- pub fn sys_argc ( ) -> usize ;
50- pub fn sys_argv ( out_words : * mut u32 , out_nwords : usize , arg_index : usize ) -> usize ;
51-
52- // Allocate memory from global HEAP.
53- pub fn sys_alloc_words ( nwords : usize ) -> * mut u32 ;
54- pub fn sys_alloc_aligned ( nwords : usize , align : usize ) -> * mut u8 ;
55- }
2+ pub fn sys_rand ( dest : * mut u8 , words : usize ) ;
3+ pub fn sys_alloc ( size : usize , align : usize ) -> * mut u8 ;
4+ }
0 commit comments