diff --git a/docs/labs/0x03/tasks.md b/docs/labs/0x03/tasks.md index 32dbb82..03d5a19 100644 --- a/docs/labs/0x03/tasks.md +++ b/docs/labs/0x03/tasks.md @@ -82,7 +82,7 @@ macro_rules! as_handler { #[naked] pub extern "x86-interrupt" fn [<$fn _handler>](_sf: InterruptStackFrame) { unsafe { - core::arch::asm!(" + core::arch::naked_asm!(" push rbp // ... push r15 @@ -91,7 +91,7 @@ macro_rules! as_handler { // ... pop rbp iretq", - sym $fn, options(noreturn)); + sym $fn); } } } diff --git a/docs/labs/0x05/tasks.md b/docs/labs/0x05/tasks.md index 02278c8..dea0678 100644 --- a/docs/labs/0x05/tasks.md +++ b/docs/labs/0x05/tasks.md @@ -300,7 +300,10 @@ static mut M: u64 = 0xdeadbeef; fn main() -> isize { let mut c = 32; + let m_ptr = &raw mut M; + // do not alloc heap before `fork` + // which may cause unexpected behavior since we won't copy the heap in `fork` let pid = sys_fork(); if pid == 0 { @@ -309,9 +312,9 @@ fn main() -> isize { assert_eq!(c, 32); unsafe { - println!("child read value of M: {:#x}", M); - M = 0x2333; - println!("child changed the value of M: {:#x}", M); + println!("child read value of M: {:#x}", *m_ptr); + *m_ptr = 0x2333; + println!("child changed the value of M: {:#x}", *m_ptr); } c += 32; @@ -331,8 +334,8 @@ fn main() -> isize { assert_eq!(ret, 64); unsafe { - println!("parent read value of M: {:#x}", M); - assert_eq!(M, 0x2333); + println!("parent read value of M: {:#x}", *m_ptr); + assert_eq!(*m_ptr, 0x2333); } c += 1024; diff --git a/docs/labs/0x07/tasks.md b/docs/labs/0x07/tasks.md index 9e57048..acc293e 100644 --- a/docs/labs/0x07/tasks.md +++ b/docs/labs/0x07/tasks.md @@ -871,7 +871,7 @@ assert!(ret == heap_end, "Failed to allocate heap"); + default = ["brk_alloc"] ``` -在后续的实验中,如果你想要自行实现内存管理算法,可以参考上述过程,通过添加 `feature` 对代码进行隔离,以便于测试和调试。 +在后续的实验中,如果你想要自行实现内存管理算法,可以参考上述过程,通过添加 `feature` 对代码进行隔离,以便于测试和调试。 如果想要自主测试其他内存管理操作,可以修改自定义的用户程序,或者直接将其实现为接受用户输入的 Shell 命令,进一步测试并记录你的 `brk` 系统调用的行为。 diff --git a/docs/wiki/fs.md b/docs/wiki/fs.md index e259c0f..6a7fcac 100644 --- a/docs/wiki/fs.md +++ b/docs/wiki/fs.md @@ -1,7 +1,5 @@ # 文件系统概述 - - ## 导读 文件系统(File System)为操作系统提供了持久存储设备上高效管理信息的能力:其为上层应用抽象出统一的设备访问接口,屏蔽不同底层块设备的操作细节。文件系统强大而复杂,横跨计算机不同存储体系,涵盖了逻辑设计与物理实现的解耦与联系。因此,本章 Wiki 将从概念出发,逐步介绍文件系统的前世今生。 diff --git a/docs/wiki/linux.md b/docs/wiki/linux.md index 2345eb5..eeb8574 100644 --- a/docs/wiki/linux.md +++ b/docs/wiki/linux.md @@ -88,10 +88,13 @@ wsl --install -d Ubuntu ```bash $ rustc --version -rustc 1.80.1 (3f5fd8dd4 2024-08-06) +rustc 1.82.0 (f6e511eec 2024-10-15) + +$ rustc +nightly --version +rustc 1.84.0-nightly (3ed6e3cc6 2024-10-17) $ qemu-system-x86_64 --version -QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1) +QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.2) $ gcc --version gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 @@ -104,7 +107,10 @@ GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git ```bash $ rustc --version -rustc 1.80.1 (3f5fd8dd4 2024-08-06) +rustc 1.82.0 (f6e511eec 2024-10-15) + +$ rustc +nightly --version +rustc 1.84.0-nightly (3ed6e3cc6 2024-10-17) $ qemu-system-x86_64 --version QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.15) diff --git a/mkdocs.yml b/mkdocs.yml index 945686e..ebf1a1d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -120,12 +120,12 @@ plugins: type: iso_datetime extra_javascript: - - https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js - - https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js + - https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.js + - https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/auto-render.min.js - scripts/katex.js extra_css: - - https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css + - https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css - css/fonts.css - css/extra.css - css/inst.css diff --git a/src/0x00/.gitignore b/src/0x00/.gitignore index bc64b0a..6414b76 100644 --- a/src/0x00/.gitignore +++ b/src/0x00/.gitignore @@ -1,4 +1,5 @@ /esp +/.idea /.vscode **/target **/.gdb_history diff --git a/src/0x00/pkg/boot/Cargo.toml b/src/0x00/pkg/boot/Cargo.toml index d1677ab..1cb3cec 100644 --- a/src/0x00/pkg/boot/Cargo.toml +++ b/src/0x00/pkg/boot/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -uefi = { version = "0.32", default-features = false } +uefi = { version = "0.33", default-features = false } log = "0.4" [features] diff --git a/src/0x01/.gitignore b/src/0x01/.gitignore index bc64b0a..6414b76 100644 --- a/src/0x01/.gitignore +++ b/src/0x01/.gitignore @@ -1,4 +1,5 @@ /esp +/.idea /.vscode **/target **/.gdb_history diff --git a/src/0x01/pkg/boot/Cargo.toml b/src/0x01/pkg/boot/Cargo.toml index 1152b24..6858eed 100644 --- a/src/0x01/pkg/boot/Cargo.toml +++ b/src/0x01/pkg/boot/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] arrayvec = { version = "0.7", default-features = false } -uefi = { version = "0.32", default-features = false } +uefi = { version = "0.33", default-features = false } log = "0.4" x86_64 = "0.15" xmas-elf = "0.9" @@ -15,4 +15,3 @@ elf = { package = "ysos_elf", path = "../elf" } [features] boot = ["uefi/alloc", "uefi/logger", "uefi/panic_handler", "uefi/global_allocator"] default = ["boot"] - diff --git a/src/0x01/pkg/boot/src/fs.rs b/src/0x01/pkg/boot/src/fs.rs index 39217c7..cb7b508 100644 --- a/src/0x01/pkg/boot/src/fs.rs +++ b/src/0x01/pkg/boot/src/fs.rs @@ -1,6 +1,6 @@ use uefi::proto::media::file::*; use uefi::proto::media::fs::SimpleFileSystem; -use uefi::table::boot::*; +use uefi::boot::*; use xmas_elf::ElfFile; /// Open root directory diff --git a/src/0x01/pkg/boot/src/lib.rs b/src/0x01/pkg/boot/src/lib.rs index 2410c2a..1d20e0e 100644 --- a/src/0x01/pkg/boot/src/lib.rs +++ b/src/0x01/pkg/boot/src/lib.rs @@ -5,7 +5,7 @@ pub use uefi::data_types::chars::*; pub use uefi::data_types::*; pub use uefi::prelude::SystemTable; pub use uefi::proto::console::gop::{GraphicsOutput, ModeInfo}; -pub use uefi::table::boot::{MemoryAttribute, MemoryDescriptor, MemoryType}; +pub use uefi::boot::{MemoryAttribute, MemoryDescriptor, MemoryType}; pub use uefi::table::runtime::*; pub use uefi::table::Runtime; pub use uefi::Status as UefiStatus; diff --git a/src/0x01/pkg/kernel/Cargo.toml b/src/0x01/pkg/kernel/Cargo.toml index 189acf5..89e94fb 100644 --- a/src/0x01/pkg/kernel/Cargo.toml +++ b/src/0x01/pkg/kernel/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] boot = { package = "ysos_boot", path = "../boot", default-features = false } lazy_static = { version = "1.4", features = ["spin_no_std"] } -uefi = { version = "0.32", default-features = false } +uefi = { version = "0.33", default-features = false } paste = "1.0" spin = "0.9" x86 = "0.52" diff --git a/src/0x02/pkg/kernel/Cargo.toml b/src/0x02/pkg/kernel/Cargo.toml index 757b184..969ae81 100644 --- a/src/0x02/pkg/kernel/Cargo.toml +++ b/src/0x02/pkg/kernel/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] boot = { package = "ysos_boot", path = "../boot", default-features = false } lazy_static = { version = "1.4", features = ["spin_no_std"] } -uefi = { version = "0.32", default-features = false } +uefi = { version = "0.33", default-features = false } crossbeam-queue = { version = "0.3", default-features = false, features = ["alloc"] } paste = "1.0" spin = "0.9" diff --git a/src/0x02/pkg/kernel/src/memory/allocator.rs b/src/0x02/pkg/kernel/src/memory/allocator.rs index 5270e42..e5e540e 100644 --- a/src/0x02/pkg/kernel/src/memory/allocator.rs +++ b/src/0x02/pkg/kernel/src/memory/allocator.rs @@ -1,5 +1,6 @@ use linked_list_allocator::LockedHeap; use x86_64::VirtAddr; +use core::ptr::addr_of_mut; pub const HEAP_SIZE: usize = 8 * 1024 * 1024; // 8 MiB @@ -12,11 +13,11 @@ pub fn init() { // will be allocated on the bss section when the kernel is load static mut HEAP: [u8; HEAP_SIZE] = [0; HEAP_SIZE]; - let heap_start = VirtAddr::from_ptr(unsafe { HEAP.as_ptr() }); + let heap_start = VirtAddr::from_ptr(addr_of_mut!(HEAP)); let heap_end = heap_start + HEAP_SIZE as u64; unsafe { - ALLOCATOR.lock().init(HEAP.as_mut_ptr(), HEAP_SIZE); + ALLOCATOR.lock().init(addr_of_mut!(HEAP) as *mut u8, HEAP_SIZE); } debug!( diff --git a/src/0x02/pkg/kernel/src/memory/gdt.rs b/src/0x02/pkg/kernel/src/memory/gdt.rs index 9c9ffa9..5788331 100644 --- a/src/0x02/pkg/kernel/src/memory/gdt.rs +++ b/src/0x02/pkg/kernel/src/memory/gdt.rs @@ -1,3 +1,4 @@ +use core::ptr::addr_of_mut; use lazy_static::lazy_static; use x86_64::registers::segmentation::Segment; use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable, SegmentSelector}; @@ -20,7 +21,7 @@ lazy_static! { tss.privilege_stack_table[0] = { const STACK_SIZE: usize = IST_SIZES[0]; static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE]; - let stack_start = VirtAddr::from_ptr(unsafe { STACK.as_ptr() }); + let stack_start = VirtAddr::from_ptr(addr_of_mut!(STACK)); let stack_end = stack_start + STACK_SIZE as u64; info!( "Privilege Stack : 0x{:016x}-0x{:016x}", diff --git a/src/0x03/pkg/kernel/Cargo.toml b/src/0x03/pkg/kernel/Cargo.toml index bb08338..ee0edab 100644 --- a/src/0x03/pkg/kernel/Cargo.toml +++ b/src/0x03/pkg/kernel/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] boot = { package = "ysos_boot", path = "../boot", default-features = false } lazy_static = { version = "1.4", features = ["spin_no_std"] } -uefi = { version = "0.32", default-features = false } +uefi = { version = "0.33", default-features = false } crossbeam-queue = { version = "0.3", default-features = false, features = ["alloc"] } paste = "1.0" spin = "0.9" diff --git a/src/0x03/pkg/kernel/src/utils/regs.rs b/src/0x03/pkg/kernel/src/utils/regs.rs index 1a382d7..af64ce4 100644 --- a/src/0x03/pkg/kernel/src/utils/regs.rs +++ b/src/0x03/pkg/kernel/src/utils/regs.rs @@ -49,7 +49,7 @@ macro_rules! as_handler { #[naked] pub extern "x86-interrupt" fn [<$fn _handler>](_sf: InterruptStackFrame) { unsafe { - core::arch::asm!(" + core::arch::naked_asm!(" push rbp push rax push rbx @@ -82,7 +82,7 @@ macro_rules! as_handler { pop rax pop rbp iretq", - sym $fn, options(noreturn)); + sym $fn); } } }