-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hint IO in the SDK #631
Open
matthiasgoergens
wants to merge
41
commits into
master
Choose a base branch
from
matthias/ceno_host
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hint IO in the SDK #631
Changes from 35 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
53db5a5
Hints in linker
matthiasgoergens 612befb
Snapshot
matthiasgoergens efde5b3
Clean up
matthiasgoergens d7949a6
Snapshot
matthiasgoergens e002be2
Clean up
matthiasgoergens 8a4906f
Clean up
matthiasgoergens b789f43
Clean up
matthiasgoergens d0af9d8
Clean up
matthiasgoergens 8333331
Remove commented out code
matthiasgoergens 8597909
Clarify comment
matthiasgoergens 1b14291
taplo fmt
matthiasgoergens 7f67dae
Merge remote-tracking branch 'origin/master' into matthias/ceno_host
matthiasgoergens 9280a9f
Clean up
matthiasgoergens 1ac5c7c
Fix
matthiasgoergens c00a5cb
Expect
matthiasgoergens 2b2a48c
Simpler
matthiasgoergens 1ba9692
Simpler
matthiasgoergens 35bacc3
Explain
matthiasgoergens c27881f
Explain
matthiasgoergens ef10c0a
Minimise diff
matthiasgoergens fecac1a
Minimise diff
matthiasgoergens 42da8da
Doc
matthiasgoergens 8fdb803
Don't hardcode the size of the region
matthiasgoergens 1e16d24
Simpler
matthiasgoergens 2f78d46
Deduplicate
matthiasgoergens 39280bf
Done TODO
matthiasgoergens 31805f6
Strings
matthiasgoergens 5091d3d
Just for fun
matthiasgoergens 10de0da
Simpler
matthiasgoergens bc3dba4
Merge remote-tracking branch 'origin/master' into matthias/ceno_host
matthiasgoergens ea77dbd
Show hint example
matthiasgoergens c438b43
Formatting
matthiasgoergens 9a746bc
Remove pedantic
matthiasgoergens 9d76268
Use bool as test case
matthiasgoergens 863f3ad
Suggestion
matthiasgoergens 4d8f924
Reshuffle crates
matthiasgoergens 0d2e317
Merge remote-tracking branch 'origin/master' into matthias/flat-struc…
matthiasgoergens 8b6c167
Merge remote-tracking branch 'origin/master' into matthias/ceno_host
matthiasgoergens 5a95f70
Fix
matthiasgoergens 77df864
Merge branch 'matthias/flat-structure-again' into matthias/ceno_host
matthiasgoergens 4d43dca
Merge remote-tracking branch 'origin/master' into matthias/ceno_host
matthiasgoergens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use std::iter::from_fn; | ||
|
||
use crate::{ByteAddr, EmuContext, VMState, WordAddr}; | ||
|
||
const WORD_SIZE: usize = 4; | ||
const INFO_OUT_ADDR: WordAddr = ByteAddr(0xC000_0000).waddr(); | ||
|
||
pub fn read_all_messages(state: &VMState) -> Vec<String> { | ||
let mut offset: WordAddr = WordAddr::from(0); | ||
from_fn(move || match read_message(state, offset) { | ||
out if out.is_empty() => None, | ||
out => { | ||
offset += out.len().div_ceil(WORD_SIZE) as u32 + 1; | ||
Some(out) | ||
} | ||
}) | ||
.collect() | ||
} | ||
|
||
fn read_message(state: &VMState, offset: WordAddr) -> String { | ||
let out_addr = INFO_OUT_ADDR + offset; | ||
let byte_len = state.peek_memory(out_addr) as usize; | ||
|
||
String::from_utf8_lossy( | ||
&(out_addr + 1_usize..) | ||
.map(|memory| state.peek_memory(memory)) | ||
.flat_map(u32::to_le_bytes) | ||
.take(byte_len) | ||
.collect::<Vec<_>>(), | ||
) | ||
.to_string() | ||
} |
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,20 @@ | ||
[package] | ||
categories.workspace = true | ||
description = "Support for the host port of a Ceno application" | ||
edition.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
name = "ceno_host" | ||
readme.workspace = true | ||
repository.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
ceno_emul = { path = "../ceno_emul" } | ||
itertools.workspace = true | ||
rkyv = { version = "0.8.9", default-features = false, features = ["alloc", "bytecheck"] } | ||
|
||
[dev-dependencies] | ||
ceno-examples = { path = "../examples-builder" } | ||
rand.workspace = true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a placeholder for now until we have the public IO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a placeholder of sorts, but for debug output, not for public IO.
We have an open issue to improve debug output.
I just moved the existing functionality around in this PR, because I want to make it accessible to other crates, instead of just using it in the internal tests. But I didn't actually change how it works here.