Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/syscalls/stub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub fn load_cell_code(
) -> Result<usize, SysError> {
let result = get().load_cell_code(buf_ptr, len, content_offset, content_size, index, source);
match result {
Ok(()) => Ok(len),
Ok(_) => Ok(len),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this style of API, you should iterate based on the result of load_cell_code, and then fill in the actual data for each MemoryPageResult structure.

Err(e) => Err(e.into()),
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/syscalls/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub trait SyscallImpls {
content_size: usize,
index: usize,
source: Source,
) -> Result<(), Error> {
) -> Result<Vec<MemoryPageResult>, Error> {
build_result(self.syscall(
buf_ptr as u64,
len as u64,
Expand All @@ -132,6 +132,7 @@ pub trait SyscallImpls {
source as u64,
consts::SYS_LOAD_CELL_DATA_AS_CODE,
))
.and_then(|_| Ok(Vec::new()))
}
fn load_cell_data(
&self,
Expand Down Expand Up @@ -429,7 +430,7 @@ pub fn syscall_to_impls<S: SyscallImpls + ?Sized>(
a4 as usize,
source,
) {
Ok(()) => 0,
Ok(_) => 0,
Err(e) => e.into(),
}
}
Expand Down Expand Up @@ -737,3 +738,11 @@ impl From<Error> for SysError {
}
}
}

/// MemoryPageResult captures response from load cell code.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct MemoryPageResult {
pub page_start: u64,
pub data: [u8; 4096],
pub flag: u8,
}