Skip to content

Commit caf6666

Browse files
committed
chore: prepare ch1-ch8 for crates.io publishing with metadata and versioned deps
1 parent 6c9d1b2 commit caf6666

12 files changed

Lines changed: 176 additions & 87 deletions

File tree

ch1-lab/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ nobios = [
1111
]
1212

1313
[dependencies]
14-
tg-sbi = { path = "../tg-sbi" }
15-
tg-console = { path = "../tg-console" }
14+
tg-sbi = { path = "../tg-sbi", version = "0.1.0-preview.1" }
15+
tg-console = { path = "../tg-console", version = "0.1.0-preview.2" }

ch1/Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
[package]
22
name = "tg-ch1"
3-
version = "0.0.1"
3+
description = "Chapter 1 of rCore Tutorial: A minimal bare-metal application running in RISC-V S-mode."
4+
version = "0.1.0-preview.1"
45
edition = "2021"
56
authors = ["YdrMaster <ydrml@hotmail.com>"]
7+
repository = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
8+
homepage = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
9+
documentation = "https://docs.rs/tg-ch1"
10+
license = "MIT OR Apache-2.0"
11+
readme = "README.md"
12+
keywords = ["rcore", "tutorial", "no-std", "riscv", "bare-metal"]
13+
categories = ["no-std", "embedded"]
614

715
[features]
816
default = []
@@ -11,4 +19,4 @@ nobios = [
1119
]
1220

1321
[dependencies]
14-
tg-sbi = { path = "../tg-sbi" }
22+
tg-sbi = { path = "../tg-sbi", version = "0.1.0-preview.1" }

ch2/Cargo.toml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
[package]
22
name = "tg-ch2"
3-
version = "0.0.1"
3+
description = "Chapter 2 of rCore Tutorial: Batch processing system with privilege levels and trap handling."
4+
version = "0.1.0-preview.1"
45
edition = "2021"
56
authors = ["YdrMaster <ydrml@hotmail.com>"]
7+
repository = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
8+
homepage = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
9+
documentation = "https://docs.rs/tg-ch2"
10+
license = "MIT OR Apache-2.0"
11+
readme = "README.md"
12+
keywords = ["rcore", "tutorial", "no-std", "riscv", "batch-system"]
13+
categories = ["no-std", "embedded"]
614

715
[features]
816
default = []
@@ -13,11 +21,11 @@ nobios = [
1321
[dependencies]
1422
riscv = "0.10.1"
1523

16-
tg-sbi = { path = "../tg-sbi" }
17-
tg-linker = { path = "../tg-linker" }
18-
tg-console = { path = "../tg-console" }
19-
tg-kernel-context = { path = "../tg-kernel-context" }
20-
tg-syscall = { path = "../tg-syscall", features = ["kernel"] }
24+
tg-sbi = { path = "../tg-sbi", version = "0.1.0-preview.1" }
25+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }
26+
tg-console = { path = "../tg-console", version = "0.1.0-preview.2" }
27+
tg-kernel-context = { path = "../tg-kernel-context", version = "0.1.0-preview.1" }
28+
tg-syscall = { path = "../tg-syscall", version = "0.1.0-preview.2", features = ["kernel"] }
2129

2230
[build-dependencies]
23-
tg-linker = { path = "../tg-linker" }
31+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }

ch3/Cargo.toml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
[package]
22
name = "tg-ch3"
3-
version = "0.0.1"
3+
description = "Chapter 3 of rCore Tutorial: Multiprogramming and time-sharing multitasking."
4+
version = "0.1.0-preview.1"
45
edition = "2021"
56
authors = ["YdrMaster <ydrml@hotmail.com>"]
7+
repository = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
8+
homepage = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
9+
documentation = "https://docs.rs/tg-ch3"
10+
license = "MIT OR Apache-2.0"
11+
readme = "README.md"
12+
keywords = ["rcore", "tutorial", "no-std", "riscv", "multitasking"]
13+
categories = ["no-std", "embedded"]
614

715
[features]
816
default = []
@@ -14,11 +22,11 @@ nobios = [
1422
[dependencies]
1523
riscv = "0.10.1"
1624

17-
tg-sbi = { path = "../tg-sbi" }
18-
tg-linker = { path = "../tg-linker" }
19-
tg-console = { path = "../tg-console" }
20-
tg-kernel-context = { path = "../tg-kernel-context" }
21-
tg-syscall = { path = "../tg-syscall", features = ["kernel"] }
25+
tg-sbi = { path = "../tg-sbi", version = "0.1.0-preview.1" }
26+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }
27+
tg-console = { path = "../tg-console", version = "0.1.0-preview.2" }
28+
tg-kernel-context = { path = "../tg-kernel-context", version = "0.1.0-preview.1" }
29+
tg-syscall = { path = "../tg-syscall", version = "0.1.0-preview.2", features = ["kernel"] }
2230

2331
[build-dependencies]
24-
tg-linker = { path = "../tg-linker" }
32+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }

ch4/Cargo.toml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
[package]
22
name = "tg-ch4"
3-
version = "0.0.1"
3+
description = "Chapter 4 of rCore Tutorial: Address space management with SV39 virtual memory."
4+
version = "0.1.0-preview.1"
45
edition = "2021"
56
authors = ["YdrMaster <ydrml@hotmail.com>"]
7+
repository = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
8+
homepage = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
9+
documentation = "https://docs.rs/tg-ch4"
10+
license = "MIT OR Apache-2.0"
11+
readme = "README.md"
12+
keywords = ["rcore", "tutorial", "no-std", "riscv", "virtual-memory"]
13+
categories = ["no-std", "embedded"]
614

715
[features]
816
default = []
@@ -14,13 +22,13 @@ nobios = [
1422
xmas-elf = "0.8.0"
1523
riscv = "0.10.1"
1624

17-
tg-sbi = { path = "../tg-sbi" }
18-
tg-linker = { path = "../tg-linker" }
19-
tg-console = { path = "../tg-console" }
20-
tg-kernel-context = { path = "../tg-kernel-context", features = ["foreign"] }
21-
tg-kernel-alloc = { path = "../tg-kernel-alloc" }
22-
tg-kernel-vm = { path = "../tg-kernel-vm" }
23-
tg-syscall = { path = "../tg-syscall", features = ["kernel"] }
25+
tg-sbi = { path = "../tg-sbi", version = "0.1.0-preview.1" }
26+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }
27+
tg-console = { path = "../tg-console", version = "0.1.0-preview.2" }
28+
tg-kernel-context = { path = "../tg-kernel-context", version = "0.1.0-preview.1", features = ["foreign"] }
29+
tg-kernel-alloc = { path = "../tg-kernel-alloc", version = "0.1.0-preview.2" }
30+
tg-kernel-vm = { path = "../tg-kernel-vm", version = "0.1.0-preview.2" }
31+
tg-syscall = { path = "../tg-syscall", version = "0.1.0-preview.2", features = ["kernel"] }
2432

2533
[build-dependencies]
26-
tg-linker = { path = "../tg-linker" }
34+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }

ch5/Cargo.toml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
[package]
22
name = "tg-ch5"
3-
version = "0.0.1"
3+
description = "Chapter 5 of rCore Tutorial: Process management with fork, exec and wait syscalls."
4+
version = "0.1.0-preview.1"
45
edition = "2021"
56
authors = ["zflcs <1491657576@qq.com>"]
7+
repository = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
8+
homepage = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
9+
documentation = "https://docs.rs/tg-ch5"
10+
license = "MIT OR Apache-2.0"
11+
readme = "README.md"
12+
keywords = ["rcore", "tutorial", "no-std", "riscv", "process"]
13+
categories = ["no-std", "embedded"]
614

715
[features]
816
default = []
@@ -15,14 +23,14 @@ xmas-elf = "0.8.0"
1523
riscv = "0.10.1"
1624
spin = "0.9"
1725

18-
tg-sbi = { path = "../tg-sbi" }
19-
tg-linker = { path = "../tg-linker" }
20-
tg-console = { path = "../tg-console" }
21-
tg-kernel-context = { path = "../tg-kernel-context", features = ["foreign"] }
22-
tg-kernel-alloc = { path = "../tg-kernel-alloc" }
23-
tg-kernel-vm = { path = "../tg-kernel-vm" }
24-
tg-syscall = { path = "../tg-syscall", features = ["kernel"] }
25-
tg-task-manage = { path = "../tg-task-manage", features = ["proc"] }
26+
tg-sbi = { path = "../tg-sbi", version = "0.1.0-preview.1" }
27+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }
28+
tg-console = { path = "../tg-console", version = "0.1.0-preview.2" }
29+
tg-kernel-context = { path = "../tg-kernel-context", version = "0.1.0-preview.1", features = ["foreign"] }
30+
tg-kernel-alloc = { path = "../tg-kernel-alloc", version = "0.1.0-preview.2" }
31+
tg-kernel-vm = { path = "../tg-kernel-vm", version = "0.1.0-preview.2" }
32+
tg-syscall = { path = "../tg-syscall", version = "0.1.0-preview.2", features = ["kernel"] }
33+
tg-task-manage = { path = "../tg-task-manage", version = "0.1.0-preview.1", features = ["proc"] }
2634

2735
[build-dependencies]
28-
tg-linker = { path = "../tg-linker" }
36+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }

ch6/Cargo.toml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
[package]
22
name = "tg-ch6"
3-
version = "0.0.1"
3+
description = "Chapter 6 of rCore Tutorial: File system with easy-fs and virtio block device."
4+
version = "0.1.0-preview.1"
45
edition = "2021"
56
authors = ["tkf2019 <kaifu6821@qq.com>"]
7+
repository = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
8+
homepage = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
9+
documentation = "https://docs.rs/tg-ch6"
10+
license = "MIT OR Apache-2.0"
11+
readme = "README.md"
12+
keywords = ["rcore", "tutorial", "no-std", "riscv", "filesystem"]
13+
categories = ["no-std", "embedded"]
614

715
[features]
816
default = []
@@ -11,20 +19,21 @@ nobios = [
1119
]
1220

1321
[dependencies]
14-
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers", rev = "4ee80e5" }
22+
#virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers", rev = "4ee80e5" }
23+
virtio-drivers = "0.1.0"
1524
xmas-elf = "0.8.0"
1625
riscv = "0.10.1"
1726
spin = "0.9"
1827

19-
tg-sbi = { path = "../tg-sbi" }
20-
tg-linker = { path = "../tg-linker" }
21-
tg-console = { path = "../tg-console" }
22-
tg-kernel-context = { path = "../tg-kernel-context", features = ["foreign"] }
23-
tg-kernel-alloc = { path = "../tg-kernel-alloc" }
24-
tg-kernel-vm = { path = "../tg-kernel-vm" }
25-
tg-syscall = { path = "../tg-syscall", features = ["kernel"] }
26-
tg-task-manage = { path = "../tg-task-manage", features = ["proc"] }
27-
tg-easy-fs = { path = "../tg-easy-fs" }
28+
tg-sbi = { path = "../tg-sbi", version = "0.1.0-preview.1" }
29+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }
30+
tg-console = { path = "../tg-console", version = "0.1.0-preview.2" }
31+
tg-kernel-context = { path = "../tg-kernel-context", version = "0.1.0-preview.1", features = ["foreign"] }
32+
tg-kernel-alloc = { path = "../tg-kernel-alloc", version = "0.1.0-preview.2" }
33+
tg-kernel-vm = { path = "../tg-kernel-vm", version = "0.1.0-preview.2" }
34+
tg-syscall = { path = "../tg-syscall", version = "0.1.0-preview.2", features = ["kernel"] }
35+
tg-task-manage = { path = "../tg-task-manage", version = "0.1.0-preview.1", features = ["proc"] }
36+
tg-easy-fs = { path = "../tg-easy-fs", version = "0.1.0-preview.2" }
2837

2938
[build-dependencies]
30-
tg-linker = { path = "../tg-linker" }
39+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }

ch6/src/virtio_block.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@ use core::{alloc::Layout, ptr::NonNull};
77
use spin::{Lazy, Mutex};
88
use tg_easy_fs::BlockDevice;
99
use tg_kernel_vm::page_table::{MmuMeta, Sv39, VAddr, VmFlags};
10-
use virtio_drivers::{Hal, VirtIOBlk, VirtIOHeader};
10+
use virtio_drivers::{Hal, MmioTransport, VirtIOBlk, VirtIOHeader};
1111

1212
const VIRTIO0: usize = 0x10001000;
1313

1414
pub static BLOCK_DEVICE: Lazy<Arc<dyn BlockDevice>> = Lazy::new(|| {
1515
Arc::new(unsafe {
1616
VirtIOBlock(Mutex::new(
17-
VirtIOBlk::new(&mut *(VIRTIO0 as *mut VirtIOHeader)).unwrap(),
17+
VirtIOBlk::new(
18+
MmioTransport::new(NonNull::new(VIRTIO0 as *mut VirtIOHeader).unwrap())
19+
.expect("Error when creating MmioTransport"),
20+
)
21+
.expect("Error when creating VirtIOBlk"),
1822
))
1923
})
2024
});
2125

22-
struct VirtIOBlock(Mutex<VirtIOBlk<'static, VirtioHal>>);
26+
struct VirtIOBlock(Mutex<VirtIOBlk<VirtioHal, MmioTransport>>);
27+
28+
// Safety: VirtIOBlock 内部使用 Mutex 保护,确保线程安全访问
29+
unsafe impl Send for VirtIOBlock {}
30+
unsafe impl Sync for VirtIOBlock {}
2331

2432
impl BlockDevice for VirtIOBlock {
2533
fn read_block(&self, block_id: usize, buf: &mut [u8]) {

ch7/Cargo.toml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
[package]
22
name = "tg-ch7"
3-
version = "0.0.1"
3+
description = "Chapter 7 of rCore Tutorial: Inter-process communication with pipe and signal handling."
4+
version = "0.1.0-preview.1"
45
edition = "2021"
56
authors = ["scPointer <jax01@foxmail.com>"]
7+
repository = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
8+
homepage = "https://github.com/rcore-os/rCore-Tutorial-in-single-workspace"
9+
documentation = "https://docs.rs/tg-ch7"
10+
license = "MIT OR Apache-2.0"
11+
readme = "README.md"
12+
keywords = ["rcore", "tutorial", "no-std", "riscv", "ipc"]
13+
categories = ["no-std", "embedded"]
614

715
[features]
816
default = []
@@ -11,22 +19,22 @@ nobios = [
1119
]
1220

1321
[dependencies]
14-
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers", rev = "4ee80e5" }
22+
virtio-drivers = "0.1.0"
1523
xmas-elf = "0.8.0"
1624
riscv = "0.10.1"
1725
spin = "0.9"
1826

19-
tg-sbi = { path = "../tg-sbi" }
20-
tg-linker = { path = "../tg-linker" }
21-
tg-console = { path = "../tg-console" }
22-
tg-kernel-context = { path = "../tg-kernel-context", features = ["foreign"] }
23-
tg-kernel-alloc = { path = "../tg-kernel-alloc" }
24-
tg-kernel-vm = { path = "../tg-kernel-vm" }
25-
tg-syscall = { path = "../tg-syscall", features = ["kernel"] }
26-
tg-task-manage = { path = "../tg-task-manage", features = ["proc"] }
27-
tg-easy-fs = { path = "../tg-easy-fs" }
28-
tg-signal = { path = "../tg-signal" }
29-
tg-signal-impl = { path = "../tg-signal-impl" }
27+
tg-sbi = { path = "../tg-sbi", version = "0.1.0-preview.1" }
28+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }
29+
tg-console = { path = "../tg-console", version = "0.1.0-preview.2" }
30+
tg-kernel-context = { path = "../tg-kernel-context", version = "0.1.0-preview.1", features = ["foreign"] }
31+
tg-kernel-alloc = { path = "../tg-kernel-alloc", version = "0.1.0-preview.2" }
32+
tg-kernel-vm = { path = "../tg-kernel-vm", version = "0.1.0-preview.2" }
33+
tg-syscall = { path = "../tg-syscall", version = "0.1.0-preview.2", features = ["kernel"] }
34+
tg-task-manage = { path = "../tg-task-manage", version = "0.1.0-preview.1", features = ["proc"] }
35+
tg-easy-fs = { path = "../tg-easy-fs", version = "0.1.0-preview.2" }
36+
tg-signal = { path = "../tg-signal", version = "0.1.0-preview.1" }
37+
tg-signal-impl = { path = "../tg-signal-impl", version = "0.1.0-preview.1" }
3038

3139
[build-dependencies]
32-
tg-linker = { path = "../tg-linker" }
40+
tg-linker = { path = "../tg-linker", version = "0.1.0-preview.2" }

ch7/src/virtio_block.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@ use core::{alloc::Layout, ptr::NonNull};
77
use spin::{Lazy, Mutex};
88
use tg_easy_fs::BlockDevice;
99
use tg_kernel_vm::page_table::{MmuMeta, Sv39, VAddr, VmFlags};
10-
use virtio_drivers::{Hal, VirtIOBlk, VirtIOHeader};
10+
use virtio_drivers::{Hal, MmioTransport, VirtIOBlk, VirtIOHeader};
1111

1212
const VIRTIO0: usize = 0x10001000;
1313

1414
pub static BLOCK_DEVICE: Lazy<Arc<dyn BlockDevice>> = Lazy::new(|| {
1515
Arc::new(unsafe {
1616
VirtIOBlock(Mutex::new(
17-
VirtIOBlk::new(&mut *(VIRTIO0 as *mut VirtIOHeader)).unwrap(),
17+
VirtIOBlk::new(
18+
MmioTransport::new(NonNull::new(VIRTIO0 as *mut VirtIOHeader).unwrap())
19+
.expect("Error when creating MmioTransport"),
20+
)
21+
.expect("Error when creating VirtIOBlk"),
1822
))
1923
})
2024
});
2125

22-
struct VirtIOBlock(Mutex<VirtIOBlk<'static, VirtioHal>>);
26+
struct VirtIOBlock(Mutex<VirtIOBlk<VirtioHal, MmioTransport>>);
27+
28+
// Safety: VirtIOBlock 内部使用 Mutex 保护,确保线程安全访问
29+
unsafe impl Send for VirtIOBlock {}
30+
unsafe impl Sync for VirtIOBlock {}
2331

2432
impl BlockDevice for VirtIOBlock {
2533
fn read_block(&self, block_id: usize, buf: &mut [u8]) {

0 commit comments

Comments
 (0)