forked from rcore-os/zCore
-
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.
Add linux_object::fs::rcore_fs_wrapper
And add directory zCore to cargo workspace
- Loading branch information
1 parent
26dd63f
commit 806c9d1
Showing
26 changed files
with
171 additions
and
89 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -11,8 +11,6 @@ jobs: | |
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
|
@@ -27,13 +25,9 @@ jobs: | |
- name: Clippy LibOS | ||
run: cargo clippy --all-features | ||
- name: Clippy x86_64 bare-metal | ||
run: | | ||
cd zCore | ||
make clippy ARCH=x86_64 | ||
run: cd zCore && make clippy ARCH=x86_64 | ||
- name: Clippy riscv64 bare-metal | ||
run: | | ||
cd zCore | ||
make clippy ARCH=riscv64 LINUX=1 | ||
run: cd zCore && make clippy ARCH=riscv64 LINUX=1 | ||
|
||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
@@ -48,13 +42,20 @@ jobs: | |
with: | ||
profile: minimal | ||
toolchain: nightly-2021-07-27 | ||
components: rust-src | ||
- name: Build | ||
run: cargo build | ||
- name: Build zCore | ||
run: | | ||
cd zCore | ||
make build ARCH=x86_64 | ||
components: rust-src, llvm-tools-preview | ||
- uses: actions-rs/[email protected] | ||
with: | ||
crate: cargo-binutils | ||
version: latest | ||
use-tool-cache: true | ||
- name: Build linux LibOS | ||
run: cargo build --features "linux libos" | ||
- name: Build zircon LibOS | ||
run: cargo build --features "zircon libos" | ||
- name: Build x86_64 bare-metal | ||
run: cd zCore && make build ARCH=x86_64 | ||
- name: Build riscv64 bare-metal | ||
run: cd zCore && make build ARCH=riscv64 LINUX=1 | ||
|
||
build-aarch64: | ||
runs-on: ubuntu-20.04 | ||
|
@@ -101,10 +102,6 @@ jobs: | |
run: make rootfs | ||
- name: Test | ||
run: cargo test --no-fail-fast | ||
# uses: actions-rs/cargo@v1 | ||
# with: | ||
# command: test | ||
# args: --all-features --no-fail-fast | ||
env: | ||
CARGO_INCREMENTAL: '0' | ||
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort' | ||
|
@@ -130,9 +127,6 @@ jobs: | |
- uses: actions/checkout@v2 | ||
- name: Run benchmarks | ||
run: cargo bench | ||
# uses: actions-rs/cargo@v1 | ||
# with: | ||
# command: bench | ||
|
||
core-test: | ||
runs-on: ubuntu-20.04 | ||
|
@@ -166,8 +160,6 @@ jobs: | |
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
- name: Pull prebuilt images | ||
run: git lfs pull -I prebuilt/zircon/x64/core-tests.zbi,prebuilt/zircon/x64/libzircon-libos.so,prebuilt/zircon/x64/userboot-libos.so | ||
- uses: actions-rs/toolchain@v1 | ||
|
@@ -185,8 +177,6 @@ jobs: | |
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
- name: Pull prebuilt images | ||
run: git lfs pull -I prebuilt/linux/libc-libos.so | ||
- name: Install musl toolchain | ||
|
@@ -262,13 +252,16 @@ jobs: | |
with: | ||
profile: minimal | ||
toolchain: nightly-2021-07-27 | ||
components: rust-src | ||
components: rust-src, llvm-tools-preview | ||
- uses: actions-rs/[email protected] | ||
with: | ||
crate: cargo-binutils | ||
version: latest | ||
use-tool-cache: true | ||
- name: Install cargo tools and qemu-system-riscv64 | ||
run: | | ||
sudo apt update | ||
sudo apt install qemu-utils | ||
cargo install cargo-binutils | ||
rustup component add llvm-tools-preview | ||
wget https://github.com/rcore-os/qemu-prebuilt/releases/download/5.2.0-riscv64/qemu-system-riscv64.tar.xz > /dev/null | ||
tar xJf qemu-system-riscv64.tar.xz && sudo cp qemu-system-riscv64 /usr/local/bin | ||
wget https://github.com/rcore-os/qemu-prebuilt/releases/download/qemu-share/qemu-share.tar.xz > /dev/null | ||
|
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
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,4 +1,5 @@ | ||
#![allow(dead_code)] | ||
#![allow(clippy::identity_op)] | ||
|
||
use trapframe::TrapFrame; | ||
|
||
|
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,15 @@ | ||
use std::env; | ||
use std::path::Path; | ||
|
||
#[async_std::main] | ||
async fn main() { | ||
env_logger::init(); | ||
kernel_hal::init(); | ||
let args = env::args().skip(1).collect(); | ||
let envs = vec!["PATH=/usr/sbin:/usr/bin:/sbin:/bin".into()]; | ||
let rootfs_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("../rootfs"); | ||
let hostfs = rcore_fs_hostfs::HostFS::new(rootfs_path); | ||
let proc = linux_loader::run(args, envs, hostfs); | ||
let code = proc.wait_for_exit().await; | ||
std::process::exit(code as i32); | ||
} |
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
File renamed without changes.
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,67 @@ | ||
//! Device wrappers that implement `rcore_fs::dev::Device`, which can loaded | ||
//! file systems on (e.g. `rcore_fs_sfs::SimpleFileSystem::open()`). | ||
use alloc::sync::Arc; | ||
|
||
extern crate rcore_fs; | ||
|
||
use kernel_hal::drivers::scheme::BlockScheme; | ||
use rcore_fs::dev::{BlockDevice, DevError, Device, Result}; | ||
use spin::RwLock; | ||
|
||
/// A naive LRU cache layer for `BlockDevice`, re-exported from `rcore-fs`. | ||
pub use rcore_fs::dev::block_cache::BlockCache; | ||
|
||
/// Memory buffer for device. | ||
pub struct MemBuf(RwLock<&'static mut [u8]>); | ||
|
||
impl MemBuf { | ||
/// create a [`MemBuf`] struct. | ||
pub fn new(buf: &'static mut [u8]) -> Self { | ||
MemBuf(RwLock::new(buf)) | ||
} | ||
} | ||
|
||
impl Device for MemBuf { | ||
fn read_at(&self, offset: usize, buf: &mut [u8]) -> Result<usize> { | ||
let slice = self.0.read(); | ||
let len = buf.len().min(slice.len() - offset); | ||
buf[..len].copy_from_slice(&slice[offset..offset + len]); | ||
Ok(len) | ||
} | ||
fn write_at(&self, offset: usize, buf: &[u8]) -> Result<usize> { | ||
let mut slice = self.0.write(); | ||
let len = buf.len().min(slice.len() - offset); | ||
slice[offset..offset + len].copy_from_slice(&buf[..len]); | ||
Ok(len) | ||
} | ||
fn sync(&self) -> Result<()> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
/// Block device implements [`BlockScheme`]. | ||
pub struct Block(Arc<dyn BlockScheme>); | ||
|
||
impl Block { | ||
/// create a [`Block`] struct. | ||
pub fn new(block: Arc<dyn BlockScheme>) -> Self { | ||
Self(block) | ||
} | ||
} | ||
|
||
impl BlockDevice for Block { | ||
const BLOCK_SIZE_LOG2: u8 = 9; // 512 | ||
|
||
fn read_at(&self, block_id: usize, buf: &mut [u8]) -> Result<()> { | ||
self.0.read_block(block_id, buf).map_err(|_| DevError) | ||
} | ||
|
||
fn write_at(&self, block_id: usize, buf: &[u8]) -> Result<()> { | ||
self.0.write_block(block_id, buf).map_err(|_| DevError) | ||
} | ||
|
||
fn sync(&self) -> Result<()> { | ||
self.0.flush().map_err(|_| DevError) | ||
} | ||
} |
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
Oops, something went wrong.