forked from syswonder/ruxos
-
Notifications
You must be signed in to change notification settings - Fork 0
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 syswonder#21 from ken4647/dev
Add module `ax9p` for 9pfs.
- Loading branch information
Showing
40 changed files
with
2,325 additions
and
53 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
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ net | |
pipe | ||
epoll | ||
poll | ||
virtio-9p |
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,6 @@ | ||
bind 0.0.0.0 | ||
port 5555 | ||
protected-mode no | ||
save "" | ||
appendonly no | ||
ignore-warnings ARM64-COW-BUG |
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,18 @@ | ||
[package] | ||
name = "driver_9p" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Zheng Wu <[email protected]>"] | ||
description = "Common traits and types for block storage drivers" | ||
license = "GPL-3.0-or-later OR Apache-2.0" | ||
homepage = "https://github.com/rcore-os/arceos" | ||
repository = "https://github.com/rcore-os/arceos/tree/main/crates/driver_common" | ||
documentation = "https://rcore-os.github.io/arceos/driver_common/index.html" | ||
|
||
[features] | ||
default = [] | ||
|
||
[dependencies] | ||
log = "0.4" | ||
spin = "0.9" | ||
driver_common = { path = "../driver_common" } |
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,26 @@ | ||
/* Copyright (c) [2023] [Syswonder Community] | ||
* [Rukos] is licensed under Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
* See the Mulan PSL v2 for more details. | ||
*/ | ||
|
||
//! Common traits and types for 9P device drivers (i.e. 9P2000.L, 9P2000.U). | ||
#![no_std] | ||
#![feature(doc_auto_cfg)] | ||
#![feature(const_trait_impl)] | ||
|
||
#[doc(no_inline)] | ||
pub use driver_common::BaseDriverOps; | ||
|
||
/// Operations that require a 9p driver to implement. | ||
pub trait _9pDriverOps: BaseDriverOps { | ||
/// initialize self(e.g. setup TCP connection) | ||
fn init(&self) -> Result<(), u8>; | ||
|
||
/// send bytes of inputs as request and receive get answer in outputs | ||
fn send_with_recv(&mut self, inputs: &[u8], outputs: &mut [u8]) -> Result<u32, u8>; // Ok(length)/Err() | ||
} |
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
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,52 @@ | ||
/* Copyright (c) [2023] [Syswonder Community] | ||
* [Rukos] is licensed under Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
* See the Mulan PSL v2 for more details. | ||
*/ | ||
|
||
use driver_9p::_9pDriverOps; | ||
use driver_common::{BaseDriverOps, DevResult, DeviceType}; | ||
use virtio_drivers::{device::v9p::VirtIO9p as InnerDev, transport::Transport, Hal}; | ||
|
||
/// The VirtIO 9p device driver. | ||
pub struct VirtIo9pDev<H: Hal, T: Transport> { | ||
inner: InnerDev<H, T>, | ||
} | ||
|
||
unsafe impl<H: Hal, T: Transport> Send for VirtIo9pDev<H, T> {} | ||
unsafe impl<H: Hal, T: Transport> Sync for VirtIo9pDev<H, T> {} | ||
|
||
impl<H: Hal, T: Transport> VirtIo9pDev<H, T> { | ||
/// Creates a new driver instance and initializes the device, or returns | ||
/// an error if any step fails. | ||
pub fn try_new(transport: T) -> DevResult<Self> { | ||
Ok(Self { | ||
inner: InnerDev::new(transport).unwrap(), | ||
}) | ||
} | ||
} | ||
|
||
impl<H: Hal, T: Transport> const BaseDriverOps for VirtIo9pDev<H, T> { | ||
fn device_name(&self) -> &str { | ||
"virtio-9p" | ||
} | ||
|
||
fn device_type(&self) -> DeviceType { | ||
DeviceType::_9P | ||
} | ||
} | ||
|
||
impl<H: Hal, T: Transport> _9pDriverOps for VirtIo9pDev<H, T> { | ||
// initialize self(e.g. setup TCP connection) | ||
fn init(&self) -> Result<(), u8> { | ||
Ok(()) | ||
} | ||
|
||
// send bytes of inputs as request and receive get answer in outputs | ||
fn send_with_recv(&mut self, inputs: &[u8], outputs: &mut [u8]) -> Result<u32, u8> { | ||
self.inner.request(inputs, outputs) | ||
} | ||
} |
Oops, something went wrong.