-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from anton-rs/cl/cannon
✨ Updates
- Loading branch information
Showing
25 changed files
with
479 additions
and
134 deletions.
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
Empty file.
Empty file.
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
Empty file.
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
all: cannon | ||
|
||
.PHONY: cannon | ||
# Build the `cannon` program builder image | ||
cannon: | ||
docker build -t cannon-pipeline:latest -f cannon/cannon.dockerfile ./cannon |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# `kona-common` | ||
# `kona-client` | ||
|
||
A suite of utilities for developing `host` programs and verifiable `client` executables. | ||
A suite of utilities for developing verifiable `client` executables that may run on top of FPVM targets. | ||
|
||
*TODO* |
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,54 @@ | ||
use crate::{asterisc::syscall, traits::BasicKernelInterface, types::RegisterSize}; | ||
use anyhow::Result; | ||
|
||
/// Concrete implementation of the [`KernelIO`] trait for the `riscv64` target architecture. | ||
pub struct AsteriscIO; | ||
|
||
/// Relevant system call numbers for the `riscv64` target architecture. | ||
/// | ||
/// See https://jborza.com/post/2021-05-11-riscv-linux-syscalls/ | ||
/// | ||
/// **Note**: This is not an exhaustive list of system calls available to the `client` program, | ||
/// only the ones necessary for the [BasicKernelInterface] trait implementation. If an extension trait for | ||
/// the [BasicKernelInterface] trait is created for the `asterisc` kernel, this list should be extended | ||
/// accordingly. | ||
#[repr(u32)] | ||
pub enum SyscallNumber { | ||
/// Sets the Exited and ExitCode states to true and $a0 respectively. | ||
Exit = 93, | ||
/// Similar behavior as Linux with support for unaligned reads. | ||
Read = 63, | ||
/// Similar behavior as Linux with support for unaligned writes. | ||
Write = 64, | ||
} | ||
|
||
impl BasicKernelInterface for AsteriscIO { | ||
fn write(fd: Self::FileDescriptor, buf: &[u8]) -> Result<RegisterSize> { | ||
unsafe { | ||
Ok(syscall::syscall3( | ||
SyscallNumber::Write as usize, | ||
fd as usize, | ||
buf.as_ptr() as usize, | ||
buf.len() as usize, | ||
) as RegisterSize) | ||
} | ||
} | ||
|
||
fn read(fd: Self::FileDescriptor, buf: &mut [u8]) -> Result<RegisterSize> { | ||
unsafe { | ||
Ok(syscall::syscall3( | ||
SyscallNumber::Read as usize, | ||
fd as usize, | ||
buf.as_ptr() as usize, | ||
buf.len() as usize, | ||
) as RegisterSize) | ||
} | ||
} | ||
|
||
fn exit(code: RegisterSize) -> ! { | ||
unsafe { | ||
syscall::syscall1(SyscallNumber::Exit as usize, code as usize); | ||
panic!() | ||
} | ||
} | ||
} |
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,4 @@ | ||
//! TODO | ||
pub mod io; | ||
mod syscall; |
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,44 @@ | ||
//! Unsafe system call interface for the `riscv64` target architecture. | ||
//! | ||
//! List of RISC-V system calls: https://jborza.com/post/2021-05-11-riscv-linux-syscalls/ | ||
//! | ||
//! **Registers used for system calls** | ||
//! | Register Number | Description | | ||
//! |=================|====================| | ||
//! | %a0 | arg1, return value | | ||
//! | %a1 | arg2 | | ||
//! | %a2 | arg3 | | ||
//! | %a3 | arg4 | | ||
//! | %a4 | arg5 | | ||
//! | %a5 | arg6 | | ||
//! | %a7 | syscall number | | ||
use core::arch::asm; | ||
|
||
/// Issues a raw system call with 1 argument. (e.g. exit) | ||
#[inline] | ||
pub unsafe fn syscall1(syscall_number: usize, arg1: usize) -> usize { | ||
let mut ret: usize; | ||
asm!( | ||
"ecall", | ||
in("a7") syscall_number, | ||
inlateout("a0") arg1 => ret, | ||
options(nostack, preserves_flags) | ||
); | ||
ret | ||
} | ||
|
||
/// Issues a raw system call with 3 arguments. (e.g. read, write) | ||
#[inline] | ||
pub unsafe fn syscall3(syscall_number: usize, arg1: usize, arg2: usize, arg3: usize) -> usize { | ||
let mut ret: usize; | ||
asm!( | ||
"ecall", | ||
in("a7") syscall_number, | ||
inlateout("a0") arg1 => ret, | ||
in("a1") arg2, | ||
in("a2") arg3, | ||
options(nostack, preserves_flags) | ||
); | ||
ret | ||
} |
Oops, something went wrong.