Skip to content

Commit 5b846fc

Browse files
committed
Bump Rust version to nightly-2025-02-18(2024 Edition)
1 parent 1235956 commit 5b846fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+118
-105
lines changed

.github/workflows/doc-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push]
44

55
env:
66
CARGO_TERM_COLOR: always
7-
rust_toolchain: nightly-2024-01-18
7+
rust_toolchain: nightly-2025-02-18
88

99
jobs:
1010
build-doc:

os/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "os"
33
version = "0.1.0"
44
authors = ["Yifan Wu <[email protected]>"]
5-
edition = "2021"
5+
edition = "2024"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

os/src/drivers/block/virtio_blk.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::BlockDevice;
22
use crate::mm::{
3-
frame_alloc, frame_dealloc, kernel_token, FrameTracker, PageTable, PhysAddr, PhysPageNum,
4-
StepByOne, VirtAddr,
3+
FrameTracker, PageTable, PhysAddr, PhysPageNum, StepByOne, VirtAddr, frame_alloc,
4+
frame_dealloc, kernel_token,
55
};
66
use crate::sync::UPSafeCell;
77
use alloc::vec::Vec;

os/src/fs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ pub trait File: Send + Sync {
1515
fn write(&self, buf: UserBuffer) -> usize;
1616
}
1717

18-
pub use inode::{list_apps, open_file, OSInode, OpenFlags};
18+
pub use inode::{OSInode, OpenFlags, list_apps, open_file};
1919
pub use stdio::{Stdin, Stdout};

os/src/lang_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ fn panic(info: &PanicInfo) -> ! {
1010
"[kernel] Panicked at {}:{} {}",
1111
location.file(),
1212
location.line(),
13-
info.message().unwrap()
13+
info.message()
1414
);
1515
} else {
16-
error!("[kernel] Panicked: {}", info.message().unwrap());
16+
error!("[kernel] Panicked: {}", info.message());
1717
}
1818
shutdown(true)
1919
}

os/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#![allow(unused_imports)]
2424
#![no_std]
2525
#![no_main]
26-
#![feature(panic_info_message)]
2726
#![feature(alloc_error_handler)]
2827

2928
extern crate alloc;
@@ -56,18 +55,18 @@ use core::arch::global_asm;
5655
global_asm!(include_str!("entry.asm"));
5756
/// clear BSS segment
5857
fn clear_bss() {
59-
extern "C" {
60-
fn sbss();
61-
fn ebss();
58+
unsafe extern "C" {
59+
safe fn sbss();
60+
safe fn ebss();
6261
}
6362
unsafe {
6463
core::slice::from_raw_parts_mut(sbss as usize as *mut u8, ebss as usize - sbss as usize)
6564
.fill(0);
6665
}
6766
}
6867

69-
#[no_mangle]
7068
/// the rust entry-point of os
69+
#[unsafe(no_mangle)]
7170
pub fn rust_main() -> ! {
7271
clear_bss();
7372
logging::init();

os/src/mm/frame_allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ lazy_static! {
9494
}
9595
/// initiate the frame allocator using `ekernel` and `MEMORY_END`
9696
pub fn init_frame_allocator() {
97-
extern "C" {
98-
fn ekernel();
97+
unsafe extern "C" {
98+
safe fn ekernel();
9999
}
100100
FRAME_ALLOCATOR.exclusive_access().init(
101101
PhysAddr::from(ekernel as usize).ceil(),

os/src/mm/heap_allocator.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! The global allocator
22
use crate::config::KERNEL_HEAP_SIZE;
33
use buddy_system_allocator::LockedHeap;
4+
use core::ptr::addr_of_mut;
45

56
#[global_allocator]
67
/// heap allocator instance
@@ -18,17 +19,17 @@ pub fn init_heap() {
1819
unsafe {
1920
HEAP_ALLOCATOR
2021
.lock()
21-
.init(HEAP_SPACE.as_ptr() as usize, KERNEL_HEAP_SIZE);
22+
.init(addr_of_mut!(HEAP_SPACE) as usize, KERNEL_HEAP_SIZE);
2223
}
2324
}
2425

2526
#[allow(unused)]
2627
pub fn heap_test() {
2728
use alloc::boxed::Box;
2829
use alloc::vec::Vec;
29-
extern "C" {
30-
fn sbss();
31-
fn ebss();
30+
unsafe extern "C" {
31+
safe fn sbss();
32+
safe fn ebss();
3233
}
3334
let bss_range = sbss as usize..ebss as usize;
3435
let a = Box::new(5);

os/src/mm/memory_set.rs

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Implementation of [`MapArea`] and [`MemorySet`].
2-
use super::{frame_alloc, FrameTracker};
2+
3+
use super::{FrameTracker, frame_alloc};
34
use super::{PTEFlags, PageTable, PageTableEntry};
45
use super::{PhysAddr, PhysPageNum, VirtAddr, VirtPageNum};
56
use super::{StepByOne, VPNRange};
@@ -12,17 +13,17 @@ use core::arch::asm;
1213
use lazy_static::*;
1314
use riscv::register::satp;
1415

15-
extern "C" {
16-
fn stext();
17-
fn etext();
18-
fn srodata();
19-
fn erodata();
20-
fn sdata();
21-
fn edata();
22-
fn sbss_with_stack();
23-
fn ebss();
24-
fn ekernel();
25-
fn strampoline();
16+
unsafe extern "C" {
17+
safe fn stext();
18+
safe fn etext();
19+
safe fn srodata();
20+
safe fn erodata();
21+
safe fn sdata();
22+
safe fn edata();
23+
safe fn sbss_with_stack();
24+
safe fn ebss();
25+
safe fn ekernel();
26+
safe fn strampoline();
2627
}
2728

2829
lazy_static! {
@@ -389,20 +390,26 @@ pub fn remap_test() {
389390
let mid_text: VirtAddr = ((stext as usize + etext as usize) / 2).into();
390391
let mid_rodata: VirtAddr = ((srodata as usize + erodata as usize) / 2).into();
391392
let mid_data: VirtAddr = ((sdata as usize + edata as usize) / 2).into();
392-
assert!(!kernel_space
393-
.page_table
394-
.translate(mid_text.floor())
395-
.unwrap()
396-
.writable(),);
397-
assert!(!kernel_space
398-
.page_table
399-
.translate(mid_rodata.floor())
400-
.unwrap()
401-
.writable(),);
402-
assert!(!kernel_space
403-
.page_table
404-
.translate(mid_data.floor())
405-
.unwrap()
406-
.executable(),);
393+
assert!(
394+
!kernel_space
395+
.page_table
396+
.translate(mid_text.floor())
397+
.unwrap()
398+
.writable(),
399+
);
400+
assert!(
401+
!kernel_space
402+
.page_table
403+
.translate(mid_rodata.floor())
404+
.unwrap()
405+
.writable(),
406+
);
407+
assert!(
408+
!kernel_space
409+
.page_table
410+
.translate(mid_data.floor())
411+
.unwrap()
412+
.executable(),
413+
);
407414
println!("remap_test passed!");
408415
}

os/src/mm/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ mod page_table;
1313

1414
use address::VPNRange;
1515
pub use address::{PhysAddr, PhysPageNum, StepByOne, VirtAddr, VirtPageNum};
16-
pub use frame_allocator::{frame_alloc, frame_dealloc, FrameTracker};
16+
pub use frame_allocator::{FrameTracker, frame_alloc, frame_dealloc};
1717
pub use memory_set::remap_test;
18-
pub use memory_set::{kernel_token, MapPermission, MemorySet, KERNEL_SPACE};
18+
pub use memory_set::{KERNEL_SPACE, MapPermission, MemorySet, kernel_token};
1919
use page_table::PTEFlags;
2020
pub use page_table::{
21-
translated_byte_buffer, translated_ref, translated_refmut, translated_str, PageTable,
22-
PageTableEntry, UserBuffer, UserBufferIterator,
21+
PageTable, PageTableEntry, UserBuffer, UserBufferIterator, translated_byte_buffer,
22+
translated_ref, translated_refmut, translated_str,
2323
};
2424
/// initiate heap allocator, frame allocator and kernel space
2525
pub fn init() {

0 commit comments

Comments
 (0)