Skip to content

Commit

Permalink
docs: upgrade versions
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Oct 29, 2024
1 parent c80fe46 commit 12935dc
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 29 deletions.
4 changes: 2 additions & 2 deletions docs/labs/0x03/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -91,7 +91,7 @@ macro_rules! as_handler {
// ...
pop rbp
iretq",
sym $fn, options(noreturn));
sym $fn);
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions docs/labs/0x05/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion docs/labs/0x07/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ assert!(ret == heap_end, "Failed to allocate heap");
+ default = ["brk_alloc"]
```

在后续的实验中,如果你想要自行实现内存管理算法,可以参考上述过程,通过添加 `feature` 对代码进行隔离,以便于测试和调试。
在后续的实验中,如果你想要自行实现内存管理算法,可以参考上述过程,通过添加 `feature` 对代码进行隔离,以便于测试和调试。

如果想要自主测试其他内存管理操作,可以修改自定义的用户程序,或者直接将其实现为接受用户输入的 Shell 命令,进一步测试并记录你的 `brk` 系统调用的行为。

Expand Down
2 changes: 0 additions & 2 deletions docs/wiki/fs.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# 文件系统概述

<!-- 文件系统的层次结构一篇(磁盘、块设备、分区、文件系统) -->

## 导读

文件系统(File System)为操作系统提供了持久存储设备上高效管理信息的能力:其为上层应用抽象出统一的设备访问接口,屏蔽不同底层块设备的操作细节。文件系统强大而复杂,横跨计算机不同存储体系,涵盖了逻辑设计与物理实现的解耦与联系。因此,本章 Wiki 将从概念出发,逐步介绍文件系统的前世今生。
Expand Down
12 changes: 9 additions & 3 deletions docs/wiki/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/0x00/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/esp
/.idea
/.vscode
**/target
**/.gdb_history
Expand Down
2 changes: 1 addition & 1 deletion src/0x00/pkg/boot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/0x01/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/esp
/.idea
/.vscode
**/target
**/.gdb_history
Expand Down
3 changes: 1 addition & 2 deletions src/0x01/pkg/boot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -15,4 +15,3 @@ elf = { package = "ysos_elf", path = "../elf" }
[features]
boot = ["uefi/alloc", "uefi/logger", "uefi/panic_handler", "uefi/global_allocator"]
default = ["boot"]

2 changes: 1 addition & 1 deletion src/0x01/pkg/boot/src/fs.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/0x01/pkg/boot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/0x01/pkg/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/0x02/pkg/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions src/0x02/pkg/kernel/src/memory/allocator.rs
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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!(
Expand Down
3 changes: 2 additions & 1 deletion src/0x02/pkg/kernel/src/memory/gdt.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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}",
Expand Down
2 changes: 1 addition & 1 deletion src/0x03/pkg/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/0x03/pkg/kernel/src/utils/regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -82,7 +82,7 @@ macro_rules! as_handler {
pop rax
pop rbp
iretq",
sym $fn, options(noreturn));
sym $fn);
}
}
}
Expand Down

0 comments on commit 12935dc

Please sign in to comment.