From 6ac064257919fafeaca61cf7b2dbfc6644615b09 Mon Sep 17 00:00:00 2001 From: clabby Date: Thu, 14 Nov 2024 11:02:53 -0500 Subject: [PATCH] chore(common): Rename IO modules (#812) * reorg common * lint * lint --- crates/common/src/io.rs | 7 +++---- crates/common/src/lib.rs | 4 ++-- crates/common/src/malloc.rs | 4 ++-- crates/common/src/{cannon => mips32}/io.rs | 8 ++++---- crates/common/src/{cannon => mips32}/mod.rs | 0 crates/common/src/{cannon => mips32}/syscall.rs | 0 crates/common/src/{asterisc => riscv64}/io.rs | 8 ++++---- crates/common/src/{asterisc => riscv64}/mod.rs | 2 +- crates/common/src/{asterisc => riscv64}/syscall.rs | 0 crates/common/src/traits/basic.rs | 9 +++++---- crates/common/src/traits/mod.rs | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) rename crates/common/src/{cannon => mips32}/io.rs (91%) rename crates/common/src/{cannon => mips32}/mod.rs (100%) rename crates/common/src/{cannon => mips32}/syscall.rs (100%) rename crates/common/src/{asterisc => riscv64}/io.rs (89%) rename crates/common/src/{asterisc => riscv64}/mod.rs (84%) rename crates/common/src/{asterisc => riscv64}/syscall.rs (100%) diff --git a/crates/common/src/io.rs b/crates/common/src/io.rs index a07f7fc34..5c576106e 100644 --- a/crates/common/src/io.rs +++ b/crates/common/src/io.rs @@ -1,5 +1,4 @@ -//! This module contains the `ClientIO` struct, which is used to perform various IO operations -//! inside of the FPVM kernel within a `client` program. +//! This module contains the `ClientIO` struct, which is a system call interface for the kernel. use crate::{errors::IOResult, BasicKernelInterface, FileDescriptor}; use cfg_if::cfg_if; @@ -7,10 +6,10 @@ use cfg_if::cfg_if; cfg_if! { if #[cfg(target_arch = "mips")] { #[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `MIPS32rel1` target architecture."] - pub(crate) type ClientIO = crate::cannon::io::CannonIO; + pub(crate) type ClientIO = crate::mips32::io::Mips32IO; } else if #[cfg(target_arch = "riscv64")] { #[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `riscv64` target architecture."] - pub(crate) type ClientIO = crate::asterisc::io::AsteriscIO; + pub(crate) type ClientIO = crate::riscv64::io::RiscV64IO; } else if #[cfg(target_os = "zkvm")] { #[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `SP1` target architecture."] pub(crate) type ClientIO = crate::zkvm::io::ZkvmIO; diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 3b0345a83..884f6137c 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -27,10 +27,10 @@ pub use executor::block_on; pub(crate) mod linux; #[cfg(target_arch = "mips")] -pub(crate) mod cannon; +pub(crate) mod mips32; #[cfg(target_arch = "riscv64")] -pub(crate) mod asterisc; +pub(crate) mod riscv64; #[cfg(target_os = "zkvm")] pub(crate) mod zkvm; diff --git a/crates/common/src/malloc.rs b/crates/common/src/malloc.rs index afe63df28..109bc1d72 100644 --- a/crates/common/src/malloc.rs +++ b/crates/common/src/malloc.rs @@ -1,10 +1,10 @@ //! This module contains an implementation of a basic memory allocator for client programs in -//! running on top of various FPVMs. +//! running on an embedded device. //! //! The allocator is a linked list allocator based on the `dlmalloc` algorithm, which is a //! well-known and widely used allocator software such as OS Kernels. -/// The global allocator for the program in FPVM environments. +/// The global allocator for the program in embedded environments. #[cfg(any(target_arch = "mips", target_arch = "riscv64"))] pub mod global_allocator { use linked_list_allocator::LockedHeap; diff --git a/crates/common/src/cannon/io.rs b/crates/common/src/mips32/io.rs similarity index 91% rename from crates/common/src/cannon/io.rs rename to crates/common/src/mips32/io.rs index 3468d0b55..fc8f1beba 100644 --- a/crates/common/src/cannon/io.rs +++ b/crates/common/src/mips32/io.rs @@ -1,9 +1,9 @@ -use crate::{cannon::syscall, errors::IOResult, BasicKernelInterface, FileDescriptor}; +use crate::{errors::IOResult, mips32::syscall, BasicKernelInterface, FileDescriptor}; /// Concrete implementation of the [BasicKernelInterface] trait for the `MIPS32rel1` target -/// architecture. Exposes a safe interface for performing IO operations within the FPVM kernel. +/// architecture. Exposes a safe interface for performing IO operations within the kernel. #[derive(Debug)] -pub(crate) struct CannonIO; +pub(crate) struct Mips32IO; /// Relevant system call numbers for the `MIPS32rel1` target architecture. /// @@ -23,7 +23,7 @@ pub(crate) enum SyscallNumber { Write = 4004, } -impl BasicKernelInterface for CannonIO { +impl BasicKernelInterface for Mips32IO { fn write(fd: FileDescriptor, buf: &[u8]) -> IOResult { unsafe { crate::linux::from_ret(syscall::syscall3( diff --git a/crates/common/src/cannon/mod.rs b/crates/common/src/mips32/mod.rs similarity index 100% rename from crates/common/src/cannon/mod.rs rename to crates/common/src/mips32/mod.rs diff --git a/crates/common/src/cannon/syscall.rs b/crates/common/src/mips32/syscall.rs similarity index 100% rename from crates/common/src/cannon/syscall.rs rename to crates/common/src/mips32/syscall.rs diff --git a/crates/common/src/asterisc/io.rs b/crates/common/src/riscv64/io.rs similarity index 89% rename from crates/common/src/asterisc/io.rs rename to crates/common/src/riscv64/io.rs index 433ac67ad..e40a29de8 100644 --- a/crates/common/src/asterisc/io.rs +++ b/crates/common/src/riscv64/io.rs @@ -1,8 +1,8 @@ -use crate::{asterisc::syscall, errors::IOResult, BasicKernelInterface, FileDescriptor}; +use crate::{errors::IOResult, riscv64::syscall, BasicKernelInterface, FileDescriptor}; /// Concrete implementation of the [`KernelIO`] trait for the `riscv64` target architecture. #[derive(Debug)] -pub(crate) struct AsteriscIO; +pub(crate) struct RiscV64IO; /// Relevant system call numbers for the `riscv64` target architecture. /// @@ -10,7 +10,7 @@ pub(crate) struct AsteriscIO; /// /// **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 +/// trait for the [BasicKernelInterface] trait is created for the linux kernel, this list /// should be extended accordingly. #[repr(usize)] pub(crate) enum SyscallNumber { @@ -22,7 +22,7 @@ pub(crate) enum SyscallNumber { Write = 64, } -impl BasicKernelInterface for AsteriscIO { +impl BasicKernelInterface for RiscV64IO { fn write(fd: FileDescriptor, buf: &[u8]) -> IOResult { unsafe { crate::linux::from_ret(syscall::syscall3( diff --git a/crates/common/src/asterisc/mod.rs b/crates/common/src/riscv64/mod.rs similarity index 84% rename from crates/common/src/asterisc/mod.rs rename to crates/common/src/riscv64/mod.rs index 841a85dd7..dd28a94b7 100644 --- a/crates/common/src/asterisc/mod.rs +++ b/crates/common/src/riscv64/mod.rs @@ -1,5 +1,5 @@ //! This module contains raw syscall bindings for the `riscv64gc` target architecture, as well as a -//! high-level implementation of the [crate::BasicKernelInterface] trait for the `asterisc` kernel. +//! high-level implementation of the [crate::BasicKernelInterface] trait for the kernel. pub(crate) mod io; mod syscall; diff --git a/crates/common/src/asterisc/syscall.rs b/crates/common/src/riscv64/syscall.rs similarity index 100% rename from crates/common/src/asterisc/syscall.rs rename to crates/common/src/riscv64/syscall.rs diff --git a/crates/common/src/traits/basic.rs b/crates/common/src/traits/basic.rs index eccf4f07a..457176715 100644 --- a/crates/common/src/traits/basic.rs +++ b/crates/common/src/traits/basic.rs @@ -1,13 +1,14 @@ //! Defines the [BasicKernelInterface] trait, which describes the functionality of several system -//! calls inside of the FPVM kernel. +//! calls inside of the kernel. use crate::{errors::IOResult, FileDescriptor}; /// The [BasicKernelInterface] trait describes the functionality of several core system calls inside -/// of the FPVM kernel. +/// of the kernel. /// -/// Commonly, FPVMs delegate IO operations to custom file descriptors in the `client` program. It is -/// a safe wrapper around the raw system calls available to the `client` program. +/// Commonly, embedded proving environments delegate IO operations to custom file descriptors. +/// This trait is a safe wrapper around the raw system calls available to the `client` program +/// for host<->client communication. /// /// In cases where the set of system calls defined in this trait need to be extended, an additional /// trait should be created that extends this trait. diff --git a/crates/common/src/traits/mod.rs b/crates/common/src/traits/mod.rs index 16f8d5100..96f9699ae 100644 --- a/crates/common/src/traits/mod.rs +++ b/crates/common/src/traits/mod.rs @@ -4,7 +4,7 @@ //! architecture-specific type that provides the concrete implementation of the //! kernel interfaces. The `client` program then uses these traits to perform operations //! without needing to know the underlying implementation, which allows the same `client` -//! program to be compiled and ran on different target FPVM architectures. +//! program to be compiled and ran on different target architectures. mod basic; pub use basic::BasicKernelInterface;