diff --git a/Cargo.lock b/Cargo.lock index a4dd7079f..538d9726e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "acpi" -version = "4.1.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55237649c6e747ea67e5ed45125af5e6a35ea1250c5e44995eb6049a955bd004" +checksum = "654f48ab3178632ea535be1765073b990895cb62f70a7e5671975d7150c26d15" dependencies = [ "bit_field", "log", @@ -175,9 +175,9 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" +checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" dependencies = [ "proc-macro2", "quote", @@ -355,9 +355,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.15" +version = "3.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bbe24bbd31a185bc2c4f7c2abe80bea13a20d57ee4e55be70ac512bdc76417" +checksum = "a3dbbb6653e7c55cc8595ad3e1f7be8f32aba4eb7ff7f0fd1163d4f3d137c0a9" dependencies = [ "atty", "bitflags", @@ -402,9 +402,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "1.2.2" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" dependencies = [ "cache-padded", ] @@ -509,9 +509,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" +checksum = "cdffe87e1d521a10f9696f833fe502293ea446d7f256c06128293a4119bdf4cb" dependencies = [ "quote", "syn", @@ -535,9 +535,9 @@ source = "git+https://github.com/rcore-os/device_tree-rs?rev=2f2e55f#2f2e55fb523 [[package]] name = "dircpy" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a87a3a434508804f6ad42f676c5be8910c35649a50d6ecf67a043a6424c543a1" +checksum = "d16e8f15af1ed7189d2bf43c7ae5d6fe0a840cd3b1e9c7bf7c08a384a5df441f" dependencies = [ "jwalk", "log", @@ -610,9 +610,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "executor" @@ -1510,7 +1510,7 @@ dependencies = [ "rcore-fs-sefs", "rcore-fs-sfs", "structopt", - "time 0.3.11", + "time 0.3.12", ] [[package]] @@ -1708,18 +1708,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.140" +version = "1.0.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" +checksum = "7af873f2c95b99fcb0bd0fe622a43e29514658873c8ceba88c4cb88833a22500" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.140" +version = "1.0.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da" +checksum = "75743a150d003dd863b51dc809bcad0d73f2102c53632f1e954e738192a3413f" dependencies = [ "proc-macro2", "quote", @@ -1927,10 +1927,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c91f41dcb2f096c05f0873d667dceec1087ce5bcf984ec8ffb19acddbb3217" +checksum = "74b7cc93fc23ba97fde84f7eea56c55d1ba183f495c6715defdfc7b9cb8c870f" dependencies = [ + "js-sys", "libc", "num_threads", ] @@ -2426,7 +2427,7 @@ dependencies = [ name = "xtask" version = "0.1.0" dependencies = [ - "clap 3.2.15", + "clap 3.2.16", "command-ext", "dircpy", "lazy_static", diff --git a/README.md b/README.md index e65f80644..7c2f6bacf 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ![stars](https://img.shields.io/github/stars/rcore-os/zCore) ![license](https://img.shields.io/github/license/rcore-os/zCore) -基于 zircon 并提供 Linux 兼容操作系统内核。 +基于 zircon 并提供 Linux 兼容性的操作系统内核。 - [An English README](docs/README_EN.md) - [原版 README](docs/README_LEGACY.md) @@ -16,6 +16,19 @@ - [构建系统更新日志](xtask/CHANGELOG.md) - [开发者注意事项(草案)](docs/for-developers.md) +## 目录 + +- [构建项目](#构建项目) +- [命令参考](#命令参考) + - [常用功能](#常用功能) + - [项目构建和管理](#项目构建和管理) + - [开发和调试](#开发和调试) + - [管理 linux rootfs](#管理-linux-rootfs) + - [libos 模式](#libos-模式) +- [平台支持](#平台支持) + - [Qemu/virt](#qemuvirt) + - [全志/哪吒](#全志哪吒) + ## 构建项目 项目构建采用 [xtask 模式](https://github.com/matklad/cargo-xtask),常用操作被封装成 cargo 命令,再通过 [Makefile](Makefile) 提供 make 调用,以兼容一些旧脚本。 @@ -56,7 +69,7 @@ cargo xtask ``` -## 命令参考指南 +## 命令参考 如果下面的命令描述与行为不符,或怀疑此文档更新不及时,亦可直接查看[内联文档](xtask/src/main.rs#L48)。 如果发现 `error: no such subcommand: ...`,查看[命令简写](.cargo/config.toml)为哪些命令设置了别名。 @@ -208,3 +221,19 @@ cargo image --arch riscv64 ```bash cargo linux-libos --args /bin/busybox ``` + +## 平台支持 + +### Qemu/virt + +参见[命令参考/开发和调试/**qemu**](#开发和调试)。 + +### 全志/哪吒 + +使用以下命令构造系统镜像: + +```bash +cargo bin --arch riscv64 --features "linux board-d1 link-user-img" --output z.bin +``` + +然后使用 [rustsbi-d1](https://github.com/rustsbi/rustsbi-d1) 将镜像部署到 Flash 或 DRAM。 diff --git a/docs/README_EN.md b/docs/README_EN.md index 15bfbc4a3..0ea24e06e 100644 --- a/docs/README_EN.md +++ b/docs/README_EN.md @@ -14,6 +14,19 @@ An OS kernel based on zircon, provides Linux compatible mode. - [legacy README](README_LEGACY.md) > you may want to check the legacy for setting up docker, running graphical applications, etc. But many of these scripts are deprecated +## Table of contents + +- [Build the project](#build-the-project) +- [Command reference](#command-reference) + - [Common functions](#common-functions) + - [Project and local repo](#project-and-local-repo) + - [Develop and debug](#develop-and-debug) + - [Linux rootfs management](#linux-rootfs-management) + - [Libos mode](#libos-mode) +- [Platform support](#platform-support) + - [Qemu/virt](#qemuvirt) + - [Allwinner/nezha](#allwinnernezha) + ## Build the project The project should be built with [xtask](https://github.com/matklad/cargo-xtask). The common operations are provided as cargo commands. An extra [Makefile](../Makefile) provides make calls for compatibility with some legacy scripts. @@ -97,7 +110,7 @@ Checks code without running. Try to compile the project with various different f cargo check-style ``` -### Develop and Debug +### Develop and debug - **asm** @@ -139,7 +152,7 @@ Launches gdb and connects to a port. cargo gdb --arch riscv64 --port 1234 ``` -### manage linux rootfs +### Linux rootfs management - **rootfs** @@ -211,3 +224,19 @@ Runs zCore in linux libos mode and runs an executable at the specified path. ```bash cargo linux-libos --args /bin/busybox ``` + +## Platform support + +### Qemu/virt + +See [Command reference/Develop and debug/**qemu**](#develop-and-debug). + +### Allwinner/nezha + +Build kernel binary with the following command: + +```bash +cargo bin --arch riscv64 --features "linux board-d1 link-user-img" --output z.bin +``` + +Then deploy the binary to Flash or DRAM with [rustsbi-d1](https://github.com/rustsbi/rustsbi-d1). diff --git a/xtask/src/commands.rs b/xtask/src/commands.rs index 030d57eb0..966e04b84 100644 --- a/xtask/src/commands.rs +++ b/xtask/src/commands.rs @@ -40,23 +40,10 @@ pub(crate) fn wget(url: impl AsRef, dst: impl AsRef) { return; } + println!("wget {} from {:?}", dst.display(), url.as_ref()); fetch_online!(dst, |tmp| { let mut wget = Ext::new("wget"); wget.arg(&url).arg("-O").arg(tmp); wget }); } - -// pub(crate) fn git_clone(repo: impl AsRef, dst: impl AsRef, pull: bool) { -// let dst = dst.as_ref(); -// if dst.is_dir() { -// if pull { -// let _ = Git::pull().current_dir(dst).status(); -// } else { -// println!("{dst:?} already exist. You can delete it manually to re-clone."); -// } -// return; -// } - -// fetch_online!(dst, |tmp| Git::clone(repo, Some(tmp))); -// } diff --git a/zCore/src/platform/riscv/boot_page_table.rs b/zCore/src/platform/riscv/boot_page_table.rs index cc3737162..2bbcb8b6f 100644 --- a/zCore/src/platform/riscv/boot_page_table.rs +++ b/zCore/src/platform/riscv/boot_page_table.rs @@ -2,18 +2,18 @@ use core::arch::asm; use page_table::{MmuFlags, PageTable, Sv39, OFFSET_BITS, PPN}; -/// 启动页表。 -pub(super) struct BootPageTable { - root: PageTable, - sub: PageTable, -} - /// 内核页属性 const KERNEL_PAGE: MmuFlags = MmuFlags::new(0xef); // DAG_'XWRV /// 子页表属性 const SUBTABLE: MmuFlags = MmuFlags::new(0x21); // __G_'___V +/// 启动页表。 +pub(super) struct BootPageTable { + root: PageTable, + sub: PageTable, +} + impl BootPageTable { /// 初始化为全零的启动页表。 pub const ZERO: Self = Self {