cargo fmt/clippy

master
DeathWish5 5 years ago
commit 8329de6c11

@ -21,6 +21,8 @@ jobs:
run: |
cd code
cargo fmt --all -- --check
cd ch02-03
cargo fmt --all -- --check
# uses: actions-rs/cargo@v1
# with:
# command: fmt
@ -29,6 +31,8 @@ jobs:
run: |
cd code
cargo clippy
cd ch02-03
cargo clippy
# uses: actions-rs/cargo@v1
# with:
# command: clippy
@ -36,7 +40,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
os: [ubuntu-20.04]
# os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v2
with:
@ -50,15 +55,17 @@ jobs:
run: |
cd code
cargo build
cd ch02-03
cargo build
# uses: actions-rs/cargo@v1
# with:
# command: build
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
os: [ubuntu-20.04]
# os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v2
with:
@ -72,3 +79,27 @@ jobs:
run: |
cd code
cargo test
cd ch02-03
cargo test
doc:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
# os: [ubuntu-20.04, macos-latest]
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
components: rust-src
- name: Build docs
run: |
cd code
cargo doc --no-deps --all-features
cd ch02-03
cargo doc --no-deps --all-features

@ -1,9 +1,16 @@
# zCore Tutorial
[![CI](https://github.com/rcore-os/zCore-Tutorial/workflows/CI/badge.svg?branch=master)](https://github.com/rcore-os/zCore-Tutorial/actions)
[![Docs](https://img.shields.io/badge/docs-alpha-blue)](https://rcore-os.github.io/zCore-Tutorial/)
zCore Toturial 的目标是通过`step by step`地建立一个简化的zCore kernel的过程来学习和掌握zCore Kernel的核心概念和对应实现从而为进一步分析掌握zCore的完整内核打下基础。
zCore Toturial 的特点是所有的code都在用户态运行便于调试和分析。
## 仓库目录
* `docs/`: 教学实验指导
* `zcore`: 操作系统代码
* `code`: 操作系统代码
## 实验指导
@ -23,3 +30,20 @@ mdbook serve docs
```
rustc 1.56.0-nightly (08095fc1f 2021-07-26)
```
## 参考
- https://fuchsia.dev/
- https://fuchsia.dev/fuchsia-src/concepts/kernel
- https://fuchsia.dev/fuchsia-src/reference/kernel_objects/objects
- https://fuchsia.dev/fuchsia-src/reference/syscalls
- https://github.com/zhangpf/fuchsia-docs-zh-CN/tree/master/zircon
- [许中兴博士演讲Fuchsia OS 简介](https://xuzhongxing.github.io/201806fuchsia.pdf)
- 毕设论文
- [Rust语言操作系统的设计与实现,王润基本科毕设论文,2019](https://github.com/rcore-os/zCore/wiki/files/wrj-thesis.pdf)
- [zCore操作系统内核的设计与实现,潘庆霖本科毕设论文,2020](https://github.com/rcore-os/zCore/wiki/files/pql-thesis.pdf)
- 开发文档
- https://github.com/rcore-os/zCore/wiki/documents-of-zcore
- 更简单和基础的[rCore-Tutorial v3](https://rcore-os.github.io/rCore-Tutorial-Book-v3/):如果看不懂上面的内容,可以先看看这个教程。

@ -4,4 +4,6 @@ members = [
"ch01-02",
"ch01-03",
"ch02-02",
# "ch02-03",
# "ch03-02",
]

@ -127,6 +127,7 @@ impl_kobject!(DummyObject);
impl DummyObject {
/// 创建一个新 `DummyObject`
#[allow(dead_code)]
pub fn new() -> Arc<Self> {
Arc::new(DummyObject {
base: KObjectBase::default(),

@ -1,5 +1,5 @@
// ANCHOR: handle
use super::{DummyObject, KernelObject, Rights};
use super::{KernelObject, Rights};
use alloc::sync::Arc;
/// 内核对象句柄
@ -20,7 +20,7 @@ impl Handle {
#[cfg(test)]
mod tests {
use super::*;
use crate::object::DummyObject;
#[test]
fn new_obj_handle() {
let obj = DummyObject::new();

@ -60,7 +60,7 @@ impl Channel {
/// Read a packet from the channel if check is ok, otherwise the msg will keep.
pub fn read(&self) -> ZxResult<T> {
let mut recv_queue = self.recv_queue.lock();
if let Some(msg) = recv_queue.front() {
if let Some(_msg) = recv_queue.front() {
let msg = recv_queue.pop_front().unwrap();
return Ok(msg);
}

@ -1,5 +1,5 @@
// ANCHOR: handle
use super::{DummyObject, KernelObject, Rights};
use super::{KernelObject, Rights};
use alloc::sync::Arc;
/// 内核对象句柄
@ -20,7 +20,7 @@ impl Handle {
#[cfg(test)]
mod tests {
use super::*;
use crate::object::DummyObject;
#[test]
fn new_obj_handle() {
let obj = DummyObject::new();

@ -55,7 +55,7 @@ impl Channel {
/// Read a packet from the channel if check is ok, otherwise the msg will keep.
pub fn read(&self) -> ZxResult<T> {
let mut recv_queue = self.recv_queue.lock();
if let Some(_) = recv_queue.front() {
if recv_queue.front().is_some() {
let msg = recv_queue.pop_front().unwrap();
return Ok(msg);
}

@ -145,7 +145,7 @@ impl Process {
Ok(object)
}
pub fn start(&self) -> () {
pub fn start(&self) {
// unimplemented!()
}
@ -164,7 +164,7 @@ impl Process {
/// The process finally terminates.
fn terminate(&self) {
let mut inner = self.inner.lock();
let retcode = match inner.status {
let _retcode = match inner.status {
Status::Exited(retcode) => retcode,
_ => {
inner.status = Status::Exited(0);

@ -10,8 +10,8 @@ use {
pin::Pin,
task::{Context, Poll, Waker},
},
trapframe::{UserContext},
spin::Mutex,
trapframe::UserContext,
};
pub use self::thread_state::*;
@ -258,7 +258,6 @@ impl Task for Thread {
}
}
/// A handle to current thread.
///
/// This is a wrapper of [`Thread`] that provides additional methods for the thread runner.
@ -397,9 +396,9 @@ pub struct ThreadInfo {
mod tests {
use super::job::Job;
use super::*;
use core::time::Duration;
use kernel_hal::timer_now;
use kernel_hal::GeneralRegs;
use core::time::Duration;
#[test]
fn create() {
@ -469,7 +468,6 @@ mod tests {
assert_eq!(thread.state(), ThreadState::Dead);
}
#[test]
fn info() {
let root_job = Job::root();

@ -17,7 +17,7 @@ mod error;
mod ipc;
mod object;
mod task;
mod vm;
mod util;
mod vm;
pub use self::error::*;

@ -10,8 +10,8 @@ use {
pin::Pin,
task::{Context, Poll, Waker},
},
trapframe::{UserContext},
spin::Mutex,
trapframe::UserContext,
};
pub use self::thread_state::*;
@ -258,7 +258,6 @@ impl Task for Thread {
}
}
/// A handle to current thread.
///
/// This is a wrapper of [`Thread`] that provides additional methods for the thread runner.
@ -397,9 +396,9 @@ pub struct ThreadInfo {
mod tests {
use super::job::Job;
use super::*;
use core::time::Duration;
use kernel_hal::timer_now;
use kernel_hal::GeneralRegs;
use core::time::Duration;
#[test]
fn create() {
@ -469,7 +468,6 @@ mod tests {
assert_eq!(thread.state(), ThreadState::Dead);
}
#[test]
fn info() {
let root_job = Job::root();

Loading…
Cancel
Save