Skip to content

Commit 7bf73cd

Browse files
committed
chore(rust): upgrade rust to edition 2024
1 parent f132d23 commit 7bf73cd

File tree

29 files changed

+110
-67
lines changed

29 files changed

+110
-67
lines changed

docs/labs/0x04/tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ entry!(main);
9393
#[macro_export]
9494
macro_rules! entry {
9595
($fn:ident) => {
96-
#[export_name = "_start"]
96+
#[unsafe(export_name = "_start")]
9797
pub extern "C" fn __impl_start() {
9898
let ret = $fn();
9999
// FIXME: after syscall, add lib::sys_exit(ret);

docs/labs/0x07/tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,8 @@ pub fn init(boot_info: &'static BootInfo) {
696696
info!("Stack grow test done.");
697697
}
698698

699-
#[no_mangle]
700699
#[inline(never)]
700+
#[unsafe(no_mangle)]
701701
pub fn grow_stack() {
702702
const STACK_SIZE: usize = 1024 * 4;
703703
const STEP: usize = 64;

docs/wiki/linux.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,20 @@ wsl --install -d Ubuntu
8282

8383
!!! tip "如果遇到了网络问题,请参考 [rsproxy.cn](https://rsproxy.cn/) 进行配置。"
8484

85+
4. 按照仓库中的 `rust-toolchain` 文件,安装对应的 Rust 工具链。
86+
87+
!!! tip 第一次在拥有 `rust-toolchain.toml` 文件的目录下运行 `cargo` 命令时,Rustup 会自动安装对应的工具链。
88+
8589
在安装完成后,请使用如下命令,确保你的相关软件包**不低于**如下标准:
8690

8791
对于 Ubuntu 24.04:
8892

8993
```bash
9094
$ rustc --version
91-
rustc 1.84.1 (e71f9a9a9 2025-01-27)
95+
rustc 1.85.0 (4d91de4e4 2025-02-17)
9296
9397
$ rustc +nightly --version
94-
rustc 1.86.0-nightly (124cc9219 2025-02-09)
98+
rustc 1.87.0-nightly (f04bbc60f 2025-02-20)
9599
96100
$ qemu-system-x86_64 --version
97101
QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.4)
@@ -107,10 +111,10 @@ GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
107111

108112
```bash
109113
$ rustc --version
110-
rustc 1.84.1 (e71f9a9a9 2025-01-27)
114+
rustc 1.85.0 (4d91de4e4 2025-02-17)
111115
112116
$ rustc +nightly --version
113-
rustc 1.86.0-nightly (124cc9219 2025-02-09)
117+
rustc 1.87.0-nightly (f04bbc60f 2025-02-20)
114118
115119
$ qemu-system-x86_64 --version
116120
QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.15)

docs/wiki/rust.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Rust 语言的基础语法可以参考 [Rust圣经](https://course.rs/) 或者 [
88

99
当熟悉 Rust 的语法与特性后,可以尝试去完成 [Rustlings](https://github.com/rust-lang/rustlings) 的练习,这些练习可以帮助你更好的理解 Rust 语言的特性。
1010

11+
本实验中使用的语言版本为 2024 版本,发布于 2025 年 2 月 20 日。
12+
1113
其他可参考的学习资料:
1214

1315
- [Rust 之旅(交互式课程)](https://tourofrust.com/00_zh-cn.html)

src/0x00/pkg/boot/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "ysos_boot"
33
version = "0.0.1"
4-
edition = "2021"
4+
edition = "2024"
55
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
66

77
[dependencies]

src/0x01/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ members = [
77
]
88
exclude = ["pkg/app/config", "pkg/app/.cargo"]
99

10+
[workspace.package]
11+
version = "0.1.0"
12+
edition = "2024"
13+
1014
[profile.release-with-debug]
1115
inherits = "release"
1216
debug = true

src/0x01/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ $(ESP)/KERNEL.ELF: target/x86_64-unknown-none/$(PROFILE)/ysos_kernel
7575
@mkdir -p $(@D)
7676
cp $< $@
7777

78+
7879
target/x86_64-unknown-uefi/$(MODE)/ysos_boot.efi: pkg/boot
7980
cd pkg/boot && cargo build $(BUILD_ARGS)
8081

src/0x01/pkg/boot/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "ysos_boot"
3-
version = "0.1.0"
4-
edition = "2021"
3+
version.workspace = true
4+
edition.workspace = true
55
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
66

77
[dependencies]

src/0x01/pkg/boot/src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use core::ptr::NonNull;
2+
use uefi::boot::*;
23
use uefi::proto::media::file::*;
34
use uefi::proto::media::fs::SimpleFileSystem;
4-
use uefi::boot::*;
55
use xmas_elf::ElfFile;
66

77
/// Open root directory

src/0x01/pkg/boot/src/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#![no_std]
22
use core::arch::asm;
33

4+
pub use uefi::boot::{MemoryAttribute, MemoryDescriptor, MemoryType};
45
pub use uefi::data_types::chars::*;
56
pub use uefi::data_types::*;
67
pub use uefi::proto::console::gop::{GraphicsOutput, ModeInfo};
7-
pub use uefi::boot::{MemoryAttribute, MemoryDescriptor, MemoryType};
88
pub use uefi::Status;
99

1010
use arrayvec::ArrayVec;
@@ -53,8 +53,10 @@ static mut ENTRY: usize = 0;
5353
///
5454
/// This function is unsafe because the caller must ensure that the kernel entry point is valid.
5555
pub unsafe fn jump_to_entry(bootinfo: *const BootInfo, stacktop: u64) -> ! {
56-
assert!(ENTRY != 0, "ENTRY is not set");
57-
asm!("mov rsp, {}; call {}", in(reg) stacktop, in(reg) ENTRY, in("rdi") bootinfo);
56+
unsafe {
57+
assert!(ENTRY != 0, "ENTRY is not set");
58+
asm!("mov rsp, {}; call {}", in(reg) stacktop, in(reg) ENTRY, in("rdi") bootinfo);
59+
}
5860
unreachable!()
5961
}
6062

@@ -65,7 +67,9 @@ pub unsafe fn jump_to_entry(bootinfo: *const BootInfo, stacktop: u64) -> ! {
6567
/// This function is unsafe because the caller must ensure that the kernel entry point is valid.
6668
#[inline(always)]
6769
pub unsafe fn set_entry(entry: usize) {
68-
ENTRY = entry;
70+
unsafe {
71+
ENTRY = entry;
72+
}
6973
}
7074

7175
/// This is copied from https://docs.rs/bootloader/0.10.12/src/bootloader/lib.rs.html
@@ -79,7 +83,7 @@ pub unsafe fn set_entry(entry: usize) {
7983
#[macro_export]
8084
macro_rules! entry_point {
8185
($path:path) => {
82-
#[export_name = "_start"]
86+
#[unsafe(export_name = "_start")]
8387
pub extern "C" fn __impl_start(boot_info: &'static $crate::BootInfo) -> ! {
8488
// validate the signature of the program entry point
8589
let f: fn(&'static $crate::BootInfo) -> ! = $path;

0 commit comments

Comments
 (0)