From 825e900afe31b55688d9dc8cc7af3797d183b8ec Mon Sep 17 00:00:00 2001 From: chyyuu Date: Sat, 26 Mar 2022 15:01:38 +0000 Subject: [PATCH] deploy: fd0efaa03da51973d2a043a3465457df0cc33ac1 --- ch4/os/all.html | 2 +- ch4/os/config/constant.KERNEL_HEAP_SIZE.html | 2 +- ch4/os/config/constant.KERNEL_STACK_SIZE.html | 2 +- ch4/os/config/constant.MEMORY_END.html | 2 +- ch4/os/config/constant.PAGE_SIZE.html | 2 +- ch4/os/config/constant.PAGE_SIZE_BITS.html | 2 +- ch4/os/config/constant.TRAMPOLINE.html | 2 +- ch4/os/config/constant.TRAP_CONTEXT.html | 2 +- ch4/os/config/constant.USER_STACK_SIZE.html | 2 +- ch4/os/config/fn.kernel_stack_position.html | 2 +- ch4/os/config/index.html | 5 +- ch4/os/console/fn.print.html | 2 +- ch4/os/console/index.html | 5 +- ch4/os/console/struct.Stdout.html | 2 +- ch4/os/fn.clear_bss.html | 5 +- ch4/os/fn.rust_main.html | 7 +- ch4/os/index.html | 39 +++++++- ch4/os/lang_items/fn.panic.html | 5 +- ch4/os/lang_items/index.html | 8 +- ch4/os/lang_items/sidebar-items.js | 2 +- ch4/os/loader/fn.get_app_data.html | 5 +- ch4/os/loader/fn.get_num_app.html | 5 +- ch4/os/loader/index.html | 9 +- ch4/os/loader/sidebar-items.js | 2 +- ch4/os/macro.print.html | 7 +- ch4/os/macro.println.html | 7 +- ch4/os/mm/address/constant.PA_WIDTH_SV39.html | 5 +- .../mm/address/constant.PPN_WIDTH_SV39.html | 2 +- ch4/os/mm/address/constant.VA_WIDTH_SV39.html | 2 +- .../mm/address/constant.VPN_WIDTH_SV39.html | 2 +- ch4/os/mm/address/index.html | 18 +++- ch4/os/mm/address/sidebar-items.js | 2 +- ch4/os/mm/address/struct.PhysAddr.html | 26 ++--- ch4/os/mm/address/struct.PhysPageNum.html | 25 ++--- ch4/os/mm/address/struct.SimpleRange.html | 13 +-- .../address/struct.SimpleRangeIterator.html | 9 +- ch4/os/mm/address/struct.VirtAddr.html | 27 ++--- ch4/os/mm/address/struct.VirtPageNum.html | 25 ++--- ch4/os/mm/address/trait.StepByOne.html | 4 +- ch4/os/mm/address/type.VPNRange.html | 5 +- ch4/os/mm/fn.init.html | 5 +- ch4/os/mm/frame_allocator/fn.frame_alloc.html | 5 +- .../fn.frame_allocator_test.html | 5 +- .../mm/frame_allocator/fn.frame_dealloc.html | 5 +- .../fn.init_frame_allocator.html | 5 +- ch4/os/mm/frame_allocator/index.html | 17 +++- ch4/os/mm/frame_allocator/sidebar-items.js | 2 +- .../struct.FRAME_ALLOCATOR.html | 13 +-- .../frame_allocator/struct.FrameTracker.html | 9 +- .../struct.StackFrameAllocator.html | 7 +- .../frame_allocator/trait.FrameAllocator.html | 4 +- .../type.FrameAllocatorImpl.html | 2 +- .../heap_allocator/fn.handle_alloc_error.html | 5 +- ch4/os/mm/heap_allocator/fn.heap_test.html | 2 +- ch4/os/mm/heap_allocator/fn.init_heap.html | 5 +- ch4/os/mm/heap_allocator/index.html | 13 ++- ch4/os/mm/heap_allocator/sidebar-items.js | 2 +- .../heap_allocator/static.HEAP_ALLOCATOR.html | 5 +- .../mm/heap_allocator/static.HEAP_SPACE.html | 5 +- ch4/os/mm/index.html | 20 +++- ch4/os/mm/memory_set/enum.MapType.html | 13 +-- ch4/os/mm/memory_set/fn.ebss.html | 2 +- ch4/os/mm/memory_set/fn.edata.html | 2 +- ch4/os/mm/memory_set/fn.ekernel.html | 2 +- ch4/os/mm/memory_set/fn.erodata.html | 2 +- ch4/os/mm/memory_set/fn.etext.html | 2 +- ch4/os/mm/memory_set/fn.remap_test.html | 2 +- ch4/os/mm/memory_set/fn.sbss_with_stack.html | 2 +- ch4/os/mm/memory_set/fn.sdata.html | 2 +- ch4/os/mm/memory_set/fn.srodata.html | 2 +- ch4/os/mm/memory_set/fn.stext.html | 2 +- ch4/os/mm/memory_set/fn.strampoline.html | 2 +- ch4/os/mm/memory_set/index.html | 14 ++- ch4/os/mm/memory_set/sidebar-items.js | 2 +- ch4/os/mm/memory_set/struct.KERNEL_SPACE.html | 11 ++- ch4/os/mm/memory_set/struct.MapArea.html | 7 +- .../mm/memory_set/struct.MapPermission.html | 89 ++++++++--------- ch4/os/mm/memory_set/struct.MemorySet.html | 15 +-- .../page_table/fn.translated_byte_buffer.html | 5 +- ch4/os/mm/page_table/index.html | 13 ++- ch4/os/mm/page_table/sidebar-items.js | 2 +- ch4/os/mm/page_table/struct.PTEFlags.html | 89 ++++++++--------- ch4/os/mm/page_table/struct.PageTable.html | 11 ++- .../mm/page_table/struct.PageTableEntry.html | 9 +- ch4/os/mm/sidebar-items.js | 2 +- ch4/os/sbi/constant.SBI_CLEAR_IPI.html | 6 -- ch4/os/sbi/constant.SBI_CONSOLE_GETCHAR.html | 6 -- ch4/os/sbi/constant.SBI_REMOTE_FENCE_I.html | 6 -- .../sbi/constant.SBI_REMOTE_SFENCE_VMA.html | 6 -- .../constant.SBI_REMOTE_SFENCE_VMA_ASID.html | 6 -- ch4/os/sbi/constant.SBI_SEND_IPI.html | 6 -- ch4/os/sbi/fn.console_getchar.html | 6 -- ch4/os/sbi/fn.console_putchar.html | 5 +- ch4/os/sbi/fn.sbi_call.html | 5 +- ch4/os/sbi/fn.set_timer.html | 5 +- ch4/os/sbi/fn.shutdown.html | 6 +- ch4/os/sbi/index.html | 14 ++- ch4/os/sbi/sidebar-items.js | 2 +- ch4/os/sidebar-items.js | 2 +- ch4/os/sync/index.html | 8 +- ch4/os/sync/sidebar-items.js | 2 +- ch4/os/sync/up/index.html | 5 +- ch4/os/sync/up/struct.UPSafeCell.html | 8 +- ch4/os/syscall/constant.SYSCALL_EXIT.html | 2 +- ch4/os/syscall/constant.SYSCALL_GET_TIME.html | 2 +- ch4/os/syscall/constant.SYSCALL_WRITE.html | 2 +- ch4/os/syscall/constant.SYSCALL_YIELD.html | 2 +- ch4/os/syscall/fn.syscall.html | 5 +- ch4/os/syscall/fs/constant.FD_STDOUT.html | 2 +- ch4/os/syscall/fs/fn.sys_write.html | 5 +- ch4/os/syscall/fs/index.html | 8 +- ch4/os/syscall/fs/sidebar-items.js | 2 +- ch4/os/syscall/index.html | 20 +++- ch4/os/syscall/process/fn.sys_exit.html | 5 +- ch4/os/syscall/process/fn.sys_get_time.html | 5 +- ch4/os/syscall/process/fn.sys_yield.html | 5 +- ch4/os/syscall/process/index.html | 10 +- ch4/os/syscall/process/sidebar-items.js | 2 +- ch4/os/syscall/sidebar-items.js | 2 +- ch4/os/task/context/index.html | 8 +- ch4/os/task/context/sidebar-items.js | 2 +- ch4/os/task/context/struct.TaskContext.html | 12 ++- ch4/os/task/fn.current_trap_cx.html | 5 +- ch4/os/task/fn.current_user_token.html | 5 +- ch4/os/task/fn.exit_current_and_run_next.html | 5 +- ch4/os/task/fn.mark_current_exited.html | 5 +- ch4/os/task/fn.mark_current_suspended.html | 5 +- ch4/os/task/fn.run_first_task.html | 5 +- ch4/os/task/fn.run_next_task.html | 6 +- .../task/fn.suspend_current_and_run_next.html | 5 +- ch4/os/task/index.html | 34 +++++-- ch4/os/task/sidebar-items.js | 2 +- ch4/os/task/struct.TASK_MANAGER.html | 22 ++++- ch4/os/task/struct.TaskContext.html | 25 +++++ ch4/os/task/struct.TaskManager.html | 26 ++++- ch4/os/task/struct.TaskManagerInner.html | 9 +- ch4/os/task/switch/fn.__switch.html | 6 +- ch4/os/task/switch/index.html | 13 ++- ch4/os/task/switch/sidebar-items.js | 2 +- ch4/os/task/task/enum.TaskStatus.html | 11 ++- ch4/os/task/task/index.html | 11 ++- ch4/os/task/task/sidebar-items.js | 2 +- ch4/os/task/task/struct.TaskControlBlock.html | 7 +- ch4/os/timer/constant.MSEC_PER_SEC.html | 2 +- ch4/os/timer/constant.TICKS_PER_SEC.html | 2 +- ch4/os/timer/fn.get_time.html | 2 +- ch4/os/timer/fn.get_time_ms.html | 5 +- ch4/os/timer/fn.set_next_trigger.html | 5 +- ch4/os/timer/index.html | 9 +- ch4/os/timer/sidebar-items.js | 2 +- ch4/os/trap/context/index.html | 8 +- ch4/os/trap/context/sidebar-items.js | 2 +- ch4/os/trap/context/struct.TrapContext.html | 15 ++- ch4/os/trap/fn.enable_timer_interrupt.html | 5 +- ch4/os/trap/fn.init.html | 5 +- ch4/os/trap/fn.set_kernel_trap_entry.html | 2 +- ch4/os/trap/fn.set_user_trap_entry.html | 2 +- ch4/os/trap/fn.trap_from_kernel.html | 8 +- ch4/os/trap/fn.trap_handler.html | 7 +- ch4/os/trap/fn.trap_return.html | 9 +- ch4/os/trap/index.html | 32 ++++-- ch4/os/trap/sidebar-items.js | 2 +- ch4/os/trap/struct.TrapContext.html | 31 ++++++ ch4/search-index.js | 2 +- ch4/src/os/config.rs.html | 6 +- ch4/src/os/console.rs.html | 10 +- ch4/src/os/lang_items.rs.html | 8 +- ch4/src/os/loader.rs.html | 10 +- ch4/src/os/main.rs.html | 54 ++++++++-- ch4/src/os/mm/address.rs.html | 22 ++++- ch4/src/os/mm/frame_allocator.rs.html | 22 ++++- ch4/src/os/mm/heap_allocator.rs.html | 14 ++- ch4/src/os/mm/memory_set.rs.html | 16 ++- ch4/src/os/mm/mod.rs.html | 22 ++++- ch4/src/os/mm/page_table.rs.html | 14 ++- ch4/src/os/sbi.rs.html | 30 ++++-- ch4/src/os/sync/mod.rs.html | 6 +- ch4/src/os/sync/up.rs.html | 8 +- ch4/src/os/syscall/fs.rs.html | 8 +- ch4/src/os/syscall/mod.rs.html | 28 +++++- ch4/src/os/syscall/process.rs.html | 12 ++- ch4/src/os/task/context.rs.html | 16 ++- ch4/src/os/task/mod.rs.html | 98 ++++++++++++++++++- ch4/src/os/task/switch.rs.html | 36 ++++--- ch4/src/os/task/task.rs.html | 8 +- ch4/src/os/timer.rs.html | 10 +- ch4/src/os/trap/context.rs.html | 40 ++++++-- ch4/src/os/trap/mod.rs.html | 50 +++++++++- 188 files changed, 1292 insertions(+), 569 deletions(-) delete mode 100644 ch4/os/sbi/constant.SBI_CLEAR_IPI.html delete mode 100644 ch4/os/sbi/constant.SBI_CONSOLE_GETCHAR.html delete mode 100644 ch4/os/sbi/constant.SBI_REMOTE_FENCE_I.html delete mode 100644 ch4/os/sbi/constant.SBI_REMOTE_SFENCE_VMA.html delete mode 100644 ch4/os/sbi/constant.SBI_REMOTE_SFENCE_VMA_ASID.html delete mode 100644 ch4/os/sbi/constant.SBI_SEND_IPI.html delete mode 100644 ch4/os/sbi/fn.console_getchar.html create mode 100644 ch4/os/task/struct.TaskContext.html create mode 100644 ch4/os/trap/struct.TrapContext.html diff --git a/ch4/os/all.html b/ch4/os/all.html index ad91e678..53d5b3ca 100644 --- a/ch4/os/all.html +++ b/ch4/os/all.html @@ -1,5 +1,5 @@ List of all items in this crate

List of all items

Structs

Enums

Traits

Macros

Functions

Typedefs

Statics

Constants

+ Change settings

List of all items

Structs

Enums

Traits

Macros

Functions

Typedefs

Statics

Constants

\ No newline at end of file diff --git a/ch4/os/config/constant.KERNEL_HEAP_SIZE.html b/ch4/os/config/constant.KERNEL_HEAP_SIZE.html index 943c5bf5..d670f534 100644 --- a/ch4/os/config/constant.KERNEL_HEAP_SIZE.html +++ b/ch4/os/config/constant.KERNEL_HEAP_SIZE.html @@ -2,5 +2,5 @@
pub const KERNEL_HEAP_SIZE: usize = 0x30_0000;
+

Constant os::config::KERNEL_HEAP_SIZE

source · []
pub const KERNEL_HEAP_SIZE: usize = 0x30_0000;
\ No newline at end of file diff --git a/ch4/os/config/constant.KERNEL_STACK_SIZE.html b/ch4/os/config/constant.KERNEL_STACK_SIZE.html index 0501d039..0870895a 100644 --- a/ch4/os/config/constant.KERNEL_STACK_SIZE.html +++ b/ch4/os/config/constant.KERNEL_STACK_SIZE.html @@ -2,5 +2,5 @@
pub const KERNEL_STACK_SIZE: usize = 4096 * 2; // 0x0000_0000_0000_2000usize
+

Constant os::config::KERNEL_STACK_SIZE

source · []
pub const KERNEL_STACK_SIZE: usize = 4096 * 2; // 0x0000_0000_0000_2000usize
\ No newline at end of file diff --git a/ch4/os/config/constant.MEMORY_END.html b/ch4/os/config/constant.MEMORY_END.html index 35f46bbb..50a51128 100644 --- a/ch4/os/config/constant.MEMORY_END.html +++ b/ch4/os/config/constant.MEMORY_END.html @@ -2,5 +2,5 @@
-

Constant os::config::MEMORY_END

source · []
pub const MEMORY_END: usize = 0x80800000;
+

Constant os::config::MEMORY_END

source · []
pub const MEMORY_END: usize = 0x80800000;
\ No newline at end of file diff --git a/ch4/os/config/constant.PAGE_SIZE.html b/ch4/os/config/constant.PAGE_SIZE.html index 1264f308..6a65de1f 100644 --- a/ch4/os/config/constant.PAGE_SIZE.html +++ b/ch4/os/config/constant.PAGE_SIZE.html @@ -2,5 +2,5 @@
-

Constant os::config::PAGE_SIZE

source · []
pub const PAGE_SIZE: usize = 0x1000;
+

Constant os::config::PAGE_SIZE

source · []
pub const PAGE_SIZE: usize = 0x1000;
\ No newline at end of file diff --git a/ch4/os/config/constant.PAGE_SIZE_BITS.html b/ch4/os/config/constant.PAGE_SIZE_BITS.html index 437e6ceb..5356ad2d 100644 --- a/ch4/os/config/constant.PAGE_SIZE_BITS.html +++ b/ch4/os/config/constant.PAGE_SIZE_BITS.html @@ -2,5 +2,5 @@
pub const PAGE_SIZE_BITS: usize = 0xc;
+

Constant os::config::PAGE_SIZE_BITS

source · []
pub const PAGE_SIZE_BITS: usize = 0xc;
\ No newline at end of file diff --git a/ch4/os/config/constant.TRAMPOLINE.html b/ch4/os/config/constant.TRAMPOLINE.html index a1707eb0..306d3252 100644 --- a/ch4/os/config/constant.TRAMPOLINE.html +++ b/ch4/os/config/constant.TRAMPOLINE.html @@ -2,5 +2,5 @@
-

Constant os::config::TRAMPOLINE

source · []
pub const TRAMPOLINE: usize = usize::MAX - PAGE_SIZE + 1; // 0xffff_ffff_ffff_f000usize
+

Constant os::config::TRAMPOLINE

source · []
pub const TRAMPOLINE: usize = usize::MAX - PAGE_SIZE + 1; // 0xffff_ffff_ffff_f000usize
\ No newline at end of file diff --git a/ch4/os/config/constant.TRAP_CONTEXT.html b/ch4/os/config/constant.TRAP_CONTEXT.html index f909cfea..54c8d95e 100644 --- a/ch4/os/config/constant.TRAP_CONTEXT.html +++ b/ch4/os/config/constant.TRAP_CONTEXT.html @@ -2,5 +2,5 @@
pub const TRAP_CONTEXT: usize = TRAMPOLINE - PAGE_SIZE; // 0xffff_ffff_ffff_e000usize
+

Constant os::config::TRAP_CONTEXT

source · []
pub const TRAP_CONTEXT: usize = TRAMPOLINE - PAGE_SIZE; // 0xffff_ffff_ffff_e000usize
\ No newline at end of file diff --git a/ch4/os/config/constant.USER_STACK_SIZE.html b/ch4/os/config/constant.USER_STACK_SIZE.html index 0d920560..7b13b4aa 100644 --- a/ch4/os/config/constant.USER_STACK_SIZE.html +++ b/ch4/os/config/constant.USER_STACK_SIZE.html @@ -2,5 +2,5 @@
pub const USER_STACK_SIZE: usize = 4096 * 2; // 0x0000_0000_0000_2000usize
+

Constant os::config::USER_STACK_SIZE

source · []
pub const USER_STACK_SIZE: usize = 4096 * 2; // 0x0000_0000_0000_2000usize
\ No newline at end of file diff --git a/ch4/os/config/fn.kernel_stack_position.html b/ch4/os/config/fn.kernel_stack_position.html index a368e2e7..3754af75 100644 --- a/ch4/os/config/fn.kernel_stack_position.html +++ b/ch4/os/config/fn.kernel_stack_position.html @@ -2,6 +2,6 @@
pub fn kernel_stack_position(app_id: usize) -> (usize, usize)
Expand description

Return (bottom, top) of a kernel stack in kernel space.

+

Function os::config::kernel_stack_position

source · []
pub fn kernel_stack_position(app_id: usize) -> (usize, usize)
Expand description

Return (bottom, top) of a kernel stack in kernel space.

\ No newline at end of file diff --git a/ch4/os/config/index.html b/ch4/os/config/index.html index abd8fb84..56888588 100644 --- a/ch4/os/config/index.html +++ b/ch4/os/config/index.html @@ -1,8 +1,9 @@ -os::config - Rust +os::config - Rust
-

Module os::config

source · []

Re-exports

+

Module os::config

source · []
Expand description

Constants used in rCore

+

Re-exports

pub use crate::board::CLOCK_FREQ;

Constants

Functions

Return (bottom, top) of a kernel stack in kernel space.

diff --git a/ch4/os/console/fn.print.html b/ch4/os/console/fn.print.html index 11eb46a6..cfcc29ed 100644 --- a/ch4/os/console/fn.print.html +++ b/ch4/os/console/fn.print.html @@ -2,5 +2,5 @@
-

Function os::console::print

source · []
pub fn print(args: Arguments<'_>)
+

Function os::console::print

source · []
pub fn print(args: Arguments<'_>)
\ No newline at end of file diff --git a/ch4/os/console/index.html b/ch4/os/console/index.html index 20aa4929..d3626af6 100644 --- a/ch4/os/console/index.html +++ b/ch4/os/console/index.html @@ -1,8 +1,9 @@ -os::console - Rust +os::console - Rust
-

Module os::console

source · []

Structs

+

Module os::console

source · []
Expand description

SBI console driver, for text output

+

Structs

Functions

\ No newline at end of file diff --git a/ch4/os/console/struct.Stdout.html b/ch4/os/console/struct.Stdout.html index aacab1d0..38dd2dcd 100644 --- a/ch4/os/console/struct.Stdout.html +++ b/ch4/os/console/struct.Stdout.html @@ -2,7 +2,7 @@
-

Struct os::console::Stdout

source · []
struct Stdout;

Trait Implementations

Writes a string slice into this writer, returning whether the write +

Struct os::console::Stdout

source · []
struct Stdout;

Trait Implementations

Writes a string slice into this writer, returning whether the write succeeded. Read more

Writes a char into this writer, returning whether the write succeeded. Read more

Glue for usage of the write! macro with implementors of this trait. Read more

diff --git a/ch4/os/fn.clear_bss.html b/ch4/os/fn.clear_bss.html index 7f6b047a..2dbff164 100644 --- a/ch4/os/fn.clear_bss.html +++ b/ch4/os/fn.clear_bss.html @@ -1,6 +1,7 @@ -clear_bss in os - Rust +clear_bss in os - Rust
-

Function os::clear_bss

source · []
pub(crate) fn clear_bss()
+

Function os::clear_bss

source · []
pub(crate) fn clear_bss()
Expand description

clear BSS segment

+
\ No newline at end of file diff --git a/ch4/os/fn.rust_main.html b/ch4/os/fn.rust_main.html index d912d8eb..a96f0b8b 100644 --- a/ch4/os/fn.rust_main.html +++ b/ch4/os/fn.rust_main.html @@ -1,7 +1,8 @@ -rust_main in os - Rust +rust_main in os - Rust
-

Function os::rust_main

source · []
#[no_mangle]
-pub fn rust_main() -> !
+

Function os::rust_main

source · []
#[no_mangle]
+pub fn rust_main() -> !
Expand description

the rust entry-point of os

+
\ No newline at end of file diff --git a/ch4/os/index.html b/ch4/os/index.html index d9f1eca1..cce08000 100644 --- a/ch4/os/index.html +++ b/ch4/os/index.html @@ -1,9 +1,38 @@ -os - Rust +os - Rust
+

Crate os

source · []
Expand description

The main module and entrypoint

+

Various facilities of the kernels are implemented as submodules. The most +important ones are:

+
    +
  • trap: Handles all cases of switching from userspace to the kernel
  • +
  • task: Task management
  • +
  • syscall: System call handling and implementation
  • +
+

The operating system also starts in this module. Kernel code starts +executing from entry.asm, after which rust_main() is called to +initialize various pieces of functionality. (See its source code for +details.)

+

We then call task::run_first_task() and for the first time go to +userspace.

+

Modules

+

Constants used in rCore

+

SBI console driver, for text output

+

The panic handler

+

Loading user applications into memory

+

Memory management implementation

+

SBI call wrappers

+

Synchronization and interior mutability primitives

+

Implementation of syscalls

+

Task management implementation

+

RISC-V timer-related functionality

+

Trap handling functionality

+

Macros

+

print string macro

+

println string macro

+

Functions

+

clear BSS segment

+

the rust entry-point of os

+
\ No newline at end of file diff --git a/ch4/os/lang_items/fn.panic.html b/ch4/os/lang_items/fn.panic.html index 4109a3bb..94ea66bd 100644 --- a/ch4/os/lang_items/fn.panic.html +++ b/ch4/os/lang_items/fn.panic.html @@ -1,6 +1,7 @@ -panic in os::lang_items - Rust +panic in os::lang_items - Rust
-

Function os::lang_items::panic

source · []
fn panic(info: &PanicInfo<'_>) -> !
+

Function os::lang_items::panic

source · []
fn panic(info: &PanicInfo<'_>) -> !
Expand description

panic handler

+
\ No newline at end of file diff --git a/ch4/os/lang_items/index.html b/ch4/os/lang_items/index.html index c333ed12..d194b684 100644 --- a/ch4/os/lang_items/index.html +++ b/ch4/os/lang_items/index.html @@ -1,7 +1,9 @@ -os::lang_items - Rust +os::lang_items - Rust
+

Module os::lang_items

source · []
Expand description

The panic handler

+

Functions

+

panic handler

+
\ No newline at end of file diff --git a/ch4/os/lang_items/sidebar-items.js b/ch4/os/lang_items/sidebar-items.js index 8ea0dd88..b06753b5 100644 --- a/ch4/os/lang_items/sidebar-items.js +++ b/ch4/os/lang_items/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["panic",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["panic","panic handler"]]}); \ No newline at end of file diff --git a/ch4/os/loader/fn.get_app_data.html b/ch4/os/loader/fn.get_app_data.html index 0dbd63c8..9a862678 100644 --- a/ch4/os/loader/fn.get_app_data.html +++ b/ch4/os/loader/fn.get_app_data.html @@ -1,6 +1,7 @@ -get_app_data in os::loader - Rust +get_app_data in os::loader - Rust
pub fn get_app_data(app_id: usize) -> &'static [u8]
+

Function os::loader::get_app_data

source · []
pub fn get_app_data(app_id: usize) -> &'static [u8]
Expand description

get applications data

+
\ No newline at end of file diff --git a/ch4/os/loader/fn.get_num_app.html b/ch4/os/loader/fn.get_num_app.html index cac8e7dc..e0af389b 100644 --- a/ch4/os/loader/fn.get_num_app.html +++ b/ch4/os/loader/fn.get_num_app.html @@ -1,6 +1,7 @@ -get_num_app in os::loader - Rust +get_num_app in os::loader - Rust
-

Function os::loader::get_num_app

source · []
pub fn get_num_app() -> usize
+

Function os::loader::get_num_app

source · []
pub fn get_num_app() -> usize
Expand description

Get the total number of applications.

+
\ No newline at end of file diff --git a/ch4/os/loader/index.html b/ch4/os/loader/index.html index 439fc3dd..ef2f97f1 100644 --- a/ch4/os/loader/index.html +++ b/ch4/os/loader/index.html @@ -1,7 +1,10 @@ -os::loader - Rust +os::loader - Rust
+

Module os::loader

source · []
Expand description

Loading user applications into memory

+

Functions

+

get applications data

+

Get the total number of applications.

+
\ No newline at end of file diff --git a/ch4/os/loader/sidebar-items.js b/ch4/os/loader/sidebar-items.js index 5a032a54..45183026 100644 --- a/ch4/os/loader/sidebar-items.js +++ b/ch4/os/loader/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["get_app_data",""],["get_num_app",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["get_app_data","get applications data"],["get_num_app","Get the total number of applications."]]}); \ No newline at end of file diff --git a/ch4/os/macro.print.html b/ch4/os/macro.print.html index 17d519f7..bb6aceda 100644 --- a/ch4/os/macro.print.html +++ b/ch4/os/macro.print.html @@ -1,9 +1,10 @@ -print in os - Rust +print in os - Rust
-

Macro os::print

source · []
macro_rules! print {
+    

Macro os::print

source · []
macro_rules! print {
     ($fmt: literal $(, $($arg: tt)+)?) => { ... };
 }
-
+
Expand description

print string macro

+
\ No newline at end of file diff --git a/ch4/os/macro.println.html b/ch4/os/macro.println.html index 6f58012d..229b7103 100644 --- a/ch4/os/macro.println.html +++ b/ch4/os/macro.println.html @@ -1,9 +1,10 @@ -println in os - Rust +println in os - Rust
-

Macro os::println

source · []
macro_rules! println {
+    

Macro os::println

source · []
macro_rules! println {
     ($fmt: literal $(, $($arg: tt)+)?) => { ... };
 }
-
+
Expand description

println string macro

+
\ No newline at end of file diff --git a/ch4/os/mm/address/constant.PA_WIDTH_SV39.html b/ch4/os/mm/address/constant.PA_WIDTH_SV39.html index d7ded0db..6504b57c 100644 --- a/ch4/os/mm/address/constant.PA_WIDTH_SV39.html +++ b/ch4/os/mm/address/constant.PA_WIDTH_SV39.html @@ -1,6 +1,7 @@ -PA_WIDTH_SV39 in os::mm::address - Rust +PA_WIDTH_SV39 in os::mm::address - Rust
const PA_WIDTH_SV39: usize = 56;
+

Constant os::mm::address::PA_WIDTH_SV39

source · []
const PA_WIDTH_SV39: usize = 56;
Expand description

physical address

+
\ No newline at end of file diff --git a/ch4/os/mm/address/constant.PPN_WIDTH_SV39.html b/ch4/os/mm/address/constant.PPN_WIDTH_SV39.html index 07bf60dc..943c0537 100644 --- a/ch4/os/mm/address/constant.PPN_WIDTH_SV39.html +++ b/ch4/os/mm/address/constant.PPN_WIDTH_SV39.html @@ -2,5 +2,5 @@
const PPN_WIDTH_SV39: usize = PA_WIDTH_SV39 - PAGE_SIZE_BITS; // 0x0000_0000_0000_002cusize
+

Constant os::mm::address::PPN_WIDTH_SV39

source · []
const PPN_WIDTH_SV39: usize = PA_WIDTH_SV39 - PAGE_SIZE_BITS; // 0x0000_0000_0000_002cusize
\ No newline at end of file diff --git a/ch4/os/mm/address/constant.VA_WIDTH_SV39.html b/ch4/os/mm/address/constant.VA_WIDTH_SV39.html index 1f0e06d1..590044d6 100644 --- a/ch4/os/mm/address/constant.VA_WIDTH_SV39.html +++ b/ch4/os/mm/address/constant.VA_WIDTH_SV39.html @@ -2,5 +2,5 @@
const VA_WIDTH_SV39: usize = 39;
+

Constant os::mm::address::VA_WIDTH_SV39

source · []
const VA_WIDTH_SV39: usize = 39;
\ No newline at end of file diff --git a/ch4/os/mm/address/constant.VPN_WIDTH_SV39.html b/ch4/os/mm/address/constant.VPN_WIDTH_SV39.html index 124aa845..cc0f9ac3 100644 --- a/ch4/os/mm/address/constant.VPN_WIDTH_SV39.html +++ b/ch4/os/mm/address/constant.VPN_WIDTH_SV39.html @@ -2,5 +2,5 @@
const VPN_WIDTH_SV39: usize = VA_WIDTH_SV39 - PAGE_SIZE_BITS; // 0x0000_0000_0000_001busize
+

Constant os::mm::address::VPN_WIDTH_SV39

source · []
const VPN_WIDTH_SV39: usize = VA_WIDTH_SV39 - PAGE_SIZE_BITS; // 0x0000_0000_0000_001busize
\ No newline at end of file diff --git a/ch4/os/mm/address/index.html b/ch4/os/mm/address/index.html index 57869066..9f845a86 100644 --- a/ch4/os/mm/address/index.html +++ b/ch4/os/mm/address/index.html @@ -1,11 +1,19 @@ -os::mm::address - Rust +os::mm::address - Rust
-

Module os::mm::address

source · []

Structs

+

Module os::mm::address

source · []
Expand description

Implementation of physical and virtual address and page number.

+

Structs

Constants

-

Traits

+

physical page number

+

a simple range structure for type T

+

iterator for the simple range structure

+

virtual address

+

virtual page number

+

Constants

+

Traits

Type Definitions

-
+

a simple range structure for virtual page number

+
\ No newline at end of file diff --git a/ch4/os/mm/address/sidebar-items.js b/ch4/os/mm/address/sidebar-items.js index 354c1cc1..26da70c7 100644 --- a/ch4/os/mm/address/sidebar-items.js +++ b/ch4/os/mm/address/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"constant":[["PA_WIDTH_SV39",""],["PPN_WIDTH_SV39",""],["VA_WIDTH_SV39",""],["VPN_WIDTH_SV39",""]],"struct":[["PhysAddr","Definitions"],["PhysPageNum",""],["SimpleRange",""],["SimpleRangeIterator",""],["VirtAddr",""],["VirtPageNum",""]],"trait":[["StepByOne",""]],"type":[["VPNRange",""]]}); \ No newline at end of file +initSidebarItems({"constant":[["PA_WIDTH_SV39","physical address"],["PPN_WIDTH_SV39",""],["VA_WIDTH_SV39",""],["VPN_WIDTH_SV39",""]],"struct":[["PhysAddr","Definitions"],["PhysPageNum","physical page number"],["SimpleRange","a simple range structure for type T"],["SimpleRangeIterator","iterator for the simple range structure"],["VirtAddr","virtual address"],["VirtPageNum","virtual page number"]],"trait":[["StepByOne",""]],"type":[["VPNRange","a simple range structure for virtual page number"]]}); \ No newline at end of file diff --git a/ch4/os/mm/address/struct.PhysAddr.html b/ch4/os/mm/address/struct.PhysAddr.html index 838b1238..f4514f14 100644 --- a/ch4/os/mm/address/struct.PhysAddr.html +++ b/ch4/os/mm/address/struct.PhysAddr.html @@ -2,32 +2,32 @@
-

Struct os::mm::address::PhysAddr

source · []
pub struct PhysAddr(pub usize);
Expand description

Definitions

-

Tuple Fields

0: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

+

Struct os::mm::address::PhysAddr

source · []
pub struct PhysAddr(pub usize);
Expand description

Definitions

+

Tuple Fields

0: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

Performs the conversion.

-

Performs the conversion.

-

Performs the conversion.

-

T: {PhysAddr, VirtAddr, PhysPageNum, VirtPageNum} +

Formats the value using the given formatter. Read more

+

Performs the conversion.

+

Performs the conversion.

+

Performs the conversion.

+

T: {PhysAddr, VirtAddr, PhysPageNum, VirtPageNum} T -> usize: T.0 usize -> T: usize.into()

-

Performs the conversion.

-

This method returns an Ordering between self and other. Read more

+

Performs the conversion.

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

-

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method tests for !=.

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/address/struct.PhysPageNum.html b/ch4/os/mm/address/struct.PhysPageNum.html index 978ea08b..0430a19c 100644 --- a/ch4/os/mm/address/struct.PhysPageNum.html +++ b/ch4/os/mm/address/struct.PhysPageNum.html @@ -1,29 +1,30 @@ -PhysPageNum in os::mm::address - Rust +PhysPageNum in os::mm::address - Rust
pub struct PhysPageNum(pub usize);

Tuple Fields

0: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

+

Struct os::mm::address::PhysPageNum

source · []
pub struct PhysPageNum(pub usize);
Expand description

physical page number

+

Tuple Fields

0: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

Performs the conversion.

-

Performs the conversion.

-

Performs the conversion.

-

Performs the conversion.

-

This method returns an Ordering between self and other. Read more

+

Formats the value using the given formatter. Read more

+

Performs the conversion.

+

Performs the conversion.

+

Performs the conversion.

+

Performs the conversion.

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

-

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method tests for !=.

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/address/struct.SimpleRange.html b/ch4/os/mm/address/struct.SimpleRange.html index af5a7d11..85bef5eb 100644 --- a/ch4/os/mm/address/struct.SimpleRange.html +++ b/ch4/os/mm/address/struct.SimpleRange.html @@ -1,16 +1,17 @@ -SimpleRange in os::mm::address - Rust +SimpleRange in os::mm::address - Rust
pub struct SimpleRange<T> where
    T: StepByOne + Copy + PartialEq + PartialOrd + Debug
{ +

Struct os::mm::address::SimpleRange

source · []
pub struct SimpleRange<T> where
    T: StepByOne + Copy + PartialEq + PartialOrd + Debug
{ l: T, r: T, -}

Fields

l: Tr: T

Implementations

Trait Implementations

Returns a copy of the value. Read more

+}
Expand description

a simple range structure for type T

+

Fields

l: Tr: T

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

The type of the elements being iterated over.

+

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

-

Creates an iterator from a value. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Creates an iterator from a value. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/address/struct.SimpleRangeIterator.html b/ch4/os/mm/address/struct.SimpleRangeIterator.html index 837bdaa2..c3f0475b 100644 --- a/ch4/os/mm/address/struct.SimpleRangeIterator.html +++ b/ch4/os/mm/address/struct.SimpleRangeIterator.html @@ -1,12 +1,13 @@ -SimpleRangeIterator in os::mm::address - Rust +SimpleRangeIterator in os::mm::address - Rust
pub struct SimpleRangeIterator<T> where
    T: StepByOne + Copy + PartialEq + PartialOrd + Debug
{ +

Struct os::mm::address::SimpleRangeIterator

source · []
pub struct SimpleRangeIterator<T> where
    T: StepByOne + Copy + PartialEq + PartialOrd + Debug
{ current: T, end: T, -}

Fields

current: Tend: T

Implementations

Trait Implementations

The type of the elements being iterated over.

-

Advances the iterator and returns the next value. Read more

+}
Expand description

iterator for the simple range structure

+

Fields

current: Tend: T

Implementations

Trait Implementations

The type of the elements being iterated over.

+

Advances the iterator and returns the next value. Read more

Returns the bounds on the remaining length of the iterator. Read more

Consumes the iterator, counting the number of iterations and returning it. Read more

Consumes the iterator, returning the last element. Read more

diff --git a/ch4/os/mm/address/struct.VirtAddr.html b/ch4/os/mm/address/struct.VirtAddr.html index 20e708c6..2b073ca8 100644 --- a/ch4/os/mm/address/struct.VirtAddr.html +++ b/ch4/os/mm/address/struct.VirtAddr.html @@ -1,30 +1,31 @@ -VirtAddr in os::mm::address - Rust +VirtAddr in os::mm::address - Rust
-

Struct os::mm::address::VirtAddr

source · []
pub struct VirtAddr(pub usize);

Tuple Fields

0: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

+

Struct os::mm::address::VirtAddr

source · []
pub struct VirtAddr(pub usize);
Expand description

virtual address

+

Tuple Fields

0: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Debugging

-

Formats the value using the given formatter. Read more

-

Performs the conversion.

-

Performs the conversion.

-

Performs the conversion.

-

Performs the conversion.

-

This method returns an Ordering between self and other. Read more

+

Debugging

+

Formats the value using the given formatter. Read more

+

Performs the conversion.

+

Performs the conversion.

+

Performs the conversion.

+

Performs the conversion.

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

-

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method tests for !=.

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/address/struct.VirtPageNum.html b/ch4/os/mm/address/struct.VirtPageNum.html index e7746617..f06481db 100644 --- a/ch4/os/mm/address/struct.VirtPageNum.html +++ b/ch4/os/mm/address/struct.VirtPageNum.html @@ -1,29 +1,30 @@ -VirtPageNum in os::mm::address - Rust +VirtPageNum in os::mm::address - Rust
pub struct VirtPageNum(pub usize);

Tuple Fields

0: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

+

Struct os::mm::address::VirtPageNum

source · []
pub struct VirtPageNum(pub usize);
Expand description

virtual page number

+

Tuple Fields

0: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

Performs the conversion.

-

Performs the conversion.

-

Performs the conversion.

-

Performs the conversion.

-

This method returns an Ordering between self and other. Read more

+

Formats the value using the given formatter. Read more

+

Performs the conversion.

+

Performs the conversion.

+

Performs the conversion.

+

Performs the conversion.

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

-

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method tests for !=.

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/address/trait.StepByOne.html b/ch4/os/mm/address/trait.StepByOne.html index 6cfac32b..4ab7e1bf 100644 --- a/ch4/os/mm/address/trait.StepByOne.html +++ b/ch4/os/mm/address/trait.StepByOne.html @@ -2,7 +2,7 @@
pub trait StepByOne {
+    

Trait os::mm::address::StepByOne

source · []
pub trait StepByOne {
     fn step(&mut self);
-}

Required methods

Implementors

+}

Required methods

Implementors

\ No newline at end of file diff --git a/ch4/os/mm/address/type.VPNRange.html b/ch4/os/mm/address/type.VPNRange.html index d685bcd0..566386d3 100644 --- a/ch4/os/mm/address/type.VPNRange.html +++ b/ch4/os/mm/address/type.VPNRange.html @@ -1,6 +1,7 @@ -VPNRange in os::mm::address - Rust +VPNRange in os::mm::address - Rust
-

Type Definition os::mm::address::VPNRange

source · []
pub type VPNRange = SimpleRange<VirtPageNum>;
+

Type Definition os::mm::address::VPNRange

source · []
pub type VPNRange = SimpleRange<VirtPageNum>;
Expand description

a simple range structure for virtual page number

+
\ No newline at end of file diff --git a/ch4/os/mm/fn.init.html b/ch4/os/mm/fn.init.html index c0af5bee..359d8c09 100644 --- a/ch4/os/mm/fn.init.html +++ b/ch4/os/mm/fn.init.html @@ -1,6 +1,7 @@ -init in os::mm - Rust +init in os::mm - Rust
-

Function os::mm::init

source · []
pub fn init()
+

Function os::mm::init

source · []
pub fn init()
Expand description

initiate heap allocator, frame allocator and kernel space

+
\ No newline at end of file diff --git a/ch4/os/mm/frame_allocator/fn.frame_alloc.html b/ch4/os/mm/frame_allocator/fn.frame_alloc.html index 62c59a99..5ecbcb00 100644 --- a/ch4/os/mm/frame_allocator/fn.frame_alloc.html +++ b/ch4/os/mm/frame_allocator/fn.frame_alloc.html @@ -1,6 +1,7 @@ -frame_alloc in os::mm::frame_allocator - Rust +frame_alloc in os::mm::frame_allocator - Rust
pub fn frame_alloc() -> Option<FrameTracker>
+

Function os::mm::frame_allocator::frame_alloc

source · []
pub fn frame_alloc() -> Option<FrameTracker>
Expand description

allocate a frame

+
\ No newline at end of file diff --git a/ch4/os/mm/frame_allocator/fn.frame_allocator_test.html b/ch4/os/mm/frame_allocator/fn.frame_allocator_test.html index f9aa04aa..41a5e33f 100644 --- a/ch4/os/mm/frame_allocator/fn.frame_allocator_test.html +++ b/ch4/os/mm/frame_allocator/fn.frame_allocator_test.html @@ -1,6 +1,7 @@ -frame_allocator_test in os::mm::frame_allocator - Rust +frame_allocator_test in os::mm::frame_allocator - Rust
pub fn frame_allocator_test()
+

Function os::mm::frame_allocator::frame_allocator_test

source · []
pub fn frame_allocator_test()
Expand description

a simple test for frame allocator

+
\ No newline at end of file diff --git a/ch4/os/mm/frame_allocator/fn.frame_dealloc.html b/ch4/os/mm/frame_allocator/fn.frame_dealloc.html index 272e2280..d8aa0382 100644 --- a/ch4/os/mm/frame_allocator/fn.frame_dealloc.html +++ b/ch4/os/mm/frame_allocator/fn.frame_dealloc.html @@ -1,6 +1,7 @@ -frame_dealloc in os::mm::frame_allocator - Rust +frame_dealloc in os::mm::frame_allocator - Rust
fn frame_dealloc(ppn: PhysPageNum)
+

Function os::mm::frame_allocator::frame_dealloc

source · []
fn frame_dealloc(ppn: PhysPageNum)
Expand description

deallocate a frame

+
\ No newline at end of file diff --git a/ch4/os/mm/frame_allocator/fn.init_frame_allocator.html b/ch4/os/mm/frame_allocator/fn.init_frame_allocator.html index e6d3b941..87c2d8ec 100644 --- a/ch4/os/mm/frame_allocator/fn.init_frame_allocator.html +++ b/ch4/os/mm/frame_allocator/fn.init_frame_allocator.html @@ -1,6 +1,7 @@ -init_frame_allocator in os::mm::frame_allocator - Rust +init_frame_allocator in os::mm::frame_allocator - Rust
pub fn init_frame_allocator()
+

Function os::mm::frame_allocator::init_frame_allocator

source · []
pub fn init_frame_allocator()
Expand description

initiate the frame allocator using ekernel and MEMORY_END

+
\ No newline at end of file diff --git a/ch4/os/mm/frame_allocator/index.html b/ch4/os/mm/frame_allocator/index.html index 4539a3ff..66230177 100644 --- a/ch4/os/mm/frame_allocator/index.html +++ b/ch4/os/mm/frame_allocator/index.html @@ -1,10 +1,19 @@ -os::mm::frame_allocator - Rust +os::mm::frame_allocator - Rust
Expand description

Implementation of FrameAllocator which +controls all the frames in the operating system.

+

Structs

+

frame allocator instance through lazy_static!

+

manage a frame which has the same lifecycle as the tracker

+

an implementation for frame allocator

+

Traits

Functions

-

Type Definitions

+

allocate a frame

+

a simple test for frame allocator

+

deallocate a frame

+

initiate the frame allocator using ekernel and MEMORY_END

+

Type Definitions

\ No newline at end of file diff --git a/ch4/os/mm/frame_allocator/sidebar-items.js b/ch4/os/mm/frame_allocator/sidebar-items.js index d63ca944..91a50bd8 100644 --- a/ch4/os/mm/frame_allocator/sidebar-items.js +++ b/ch4/os/mm/frame_allocator/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["frame_alloc",""],["frame_allocator_test",""],["frame_dealloc",""],["init_frame_allocator",""]],"struct":[["FRAME_ALLOCATOR",""],["FrameTracker",""],["StackFrameAllocator",""]],"trait":[["FrameAllocator",""]],"type":[["FrameAllocatorImpl",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["frame_alloc","allocate a frame"],["frame_allocator_test","a simple test for frame allocator"],["frame_dealloc","deallocate a frame"],["init_frame_allocator","initiate the frame allocator using `ekernel` and `MEMORY_END`"]],"struct":[["FRAME_ALLOCATOR","frame allocator instance through lazy_static!"],["FrameTracker","manage a frame which has the same lifecycle as the tracker"],["StackFrameAllocator","an implementation for frame allocator"]],"trait":[["FrameAllocator",""]],"type":[["FrameAllocatorImpl",""]]}); \ No newline at end of file diff --git a/ch4/os/mm/frame_allocator/struct.FRAME_ALLOCATOR.html b/ch4/os/mm/frame_allocator/struct.FRAME_ALLOCATOR.html index 42ee0a7b..f58d15d9 100644 --- a/ch4/os/mm/frame_allocator/struct.FRAME_ALLOCATOR.html +++ b/ch4/os/mm/frame_allocator/struct.FRAME_ALLOCATOR.html @@ -1,13 +1,14 @@ -FRAME_ALLOCATOR in os::mm::frame_allocator - Rust +FRAME_ALLOCATOR in os::mm::frame_allocator - Rust
pub struct FRAME_ALLOCATOR {
+    

Struct os::mm::frame_allocator::FRAME_ALLOCATOR

source · []
pub struct FRAME_ALLOCATOR {
     __private_field: (),
-}

Fields

__private_field: ()

Methods from Deref<Target = UPSafeCell<StackFrameAllocator>>

Panic if the data has been borrowed.

-

Trait Implementations

The resulting type after dereferencing.

-

Dereferences the value.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

frame allocator instance through lazy_static!

+

Fields

__private_field: ()

Methods from Deref<Target = UPSafeCell<StackFrameAllocator>>

Exclusive access inner data in UPSafeCell. Panic if the data has been borrowed.

+

Trait Implementations

The resulting type after dereferencing.

+

Dereferences the value.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/frame_allocator/struct.FrameTracker.html b/ch4/os/mm/frame_allocator/struct.FrameTracker.html index dfc45fe7..cb0a35e1 100644 --- a/ch4/os/mm/frame_allocator/struct.FrameTracker.html +++ b/ch4/os/mm/frame_allocator/struct.FrameTracker.html @@ -1,11 +1,12 @@ -FrameTracker in os::mm::frame_allocator - Rust +FrameTracker in os::mm::frame_allocator - Rust
pub struct FrameTracker {
+    

Struct os::mm::frame_allocator::FrameTracker

source · []
pub struct FrameTracker {
     pub ppn: PhysPageNum,
-}

Fields

ppn: PhysPageNum

Implementations

Trait Implementations

Formats the value using the given formatter. Read more

-

Executes the destructor for this type. Read more

+}
Expand description

manage a frame which has the same lifecycle as the tracker

+

Fields

ppn: PhysPageNum

Implementations

Trait Implementations

Formats the value using the given formatter. Read more

+

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

diff --git a/ch4/os/mm/frame_allocator/struct.StackFrameAllocator.html b/ch4/os/mm/frame_allocator/struct.StackFrameAllocator.html index 6f3a98a9..2d7534de 100644 --- a/ch4/os/mm/frame_allocator/struct.StackFrameAllocator.html +++ b/ch4/os/mm/frame_allocator/struct.StackFrameAllocator.html @@ -1,12 +1,13 @@ -StackFrameAllocator in os::mm::frame_allocator - Rust +StackFrameAllocator in os::mm::frame_allocator - Rust
pub struct StackFrameAllocator {
+    

Struct os::mm::frame_allocator::StackFrameAllocator

source · []
pub struct StackFrameAllocator {
     current: usize,
     end: usize,
     recycled: Vec<usize>,
-}

Fields

current: usizeend: usizerecycled: Vec<usize>

Implementations

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

an implementation for frame allocator

+

Fields

current: usizeend: usizerecycled: Vec<usize>

Implementations

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/frame_allocator/trait.FrameAllocator.html b/ch4/os/mm/frame_allocator/trait.FrameAllocator.html index 7724aa46..d7123fca 100644 --- a/ch4/os/mm/frame_allocator/trait.FrameAllocator.html +++ b/ch4/os/mm/frame_allocator/trait.FrameAllocator.html @@ -2,9 +2,9 @@
trait FrameAllocator {
+    

Trait os::mm::frame_allocator::FrameAllocator

source · []
trait FrameAllocator {
     fn new() -> Self;
 
fn alloc(&mut self) -> Option<PhysPageNum>;
fn dealloc(&mut self, ppn: PhysPageNum); -}

Required methods

Implementors

+}

Required methods

Implementors

\ No newline at end of file diff --git a/ch4/os/mm/frame_allocator/type.FrameAllocatorImpl.html b/ch4/os/mm/frame_allocator/type.FrameAllocatorImpl.html index 1ae3bf56..cfd60085 100644 --- a/ch4/os/mm/frame_allocator/type.FrameAllocatorImpl.html +++ b/ch4/os/mm/frame_allocator/type.FrameAllocatorImpl.html @@ -2,5 +2,5 @@
type FrameAllocatorImpl = StackFrameAllocator;
+

Type Definition os::mm::frame_allocator::FrameAllocatorImpl

source · []
type FrameAllocatorImpl = StackFrameAllocator;
\ No newline at end of file diff --git a/ch4/os/mm/heap_allocator/fn.handle_alloc_error.html b/ch4/os/mm/heap_allocator/fn.handle_alloc_error.html index f85900a1..407ad3d7 100644 --- a/ch4/os/mm/heap_allocator/fn.handle_alloc_error.html +++ b/ch4/os/mm/heap_allocator/fn.handle_alloc_error.html @@ -1,6 +1,7 @@ -handle_alloc_error in os::mm::heap_allocator - Rust +handle_alloc_error in os::mm::heap_allocator - Rust
pub fn handle_alloc_error(layout: Layout) -> !
+

Function os::mm::heap_allocator::handle_alloc_error

source · []
pub fn handle_alloc_error(layout: Layout) -> !
Expand description

panic when heap allocation error occurs

+
\ No newline at end of file diff --git a/ch4/os/mm/heap_allocator/fn.heap_test.html b/ch4/os/mm/heap_allocator/fn.heap_test.html index 60341633..95985613 100644 --- a/ch4/os/mm/heap_allocator/fn.heap_test.html +++ b/ch4/os/mm/heap_allocator/fn.heap_test.html @@ -2,5 +2,5 @@
pub fn heap_test()
+

Function os::mm::heap_allocator::heap_test

source · []
pub fn heap_test()
\ No newline at end of file diff --git a/ch4/os/mm/heap_allocator/fn.init_heap.html b/ch4/os/mm/heap_allocator/fn.init_heap.html index 043c81db..d3d6421a 100644 --- a/ch4/os/mm/heap_allocator/fn.init_heap.html +++ b/ch4/os/mm/heap_allocator/fn.init_heap.html @@ -1,6 +1,7 @@ -init_heap in os::mm::heap_allocator - Rust +init_heap in os::mm::heap_allocator - Rust
pub fn init_heap()
+

Function os::mm::heap_allocator::init_heap

source · []
pub fn init_heap()
Expand description

initiate heap allocator

+
\ No newline at end of file diff --git a/ch4/os/mm/heap_allocator/index.html b/ch4/os/mm/heap_allocator/index.html index 1c78df9a..eb694526 100644 --- a/ch4/os/mm/heap_allocator/index.html +++ b/ch4/os/mm/heap_allocator/index.html @@ -1,8 +1,13 @@ -os::mm::heap_allocator - Rust +os::mm::heap_allocator - Rust
+

Module os::mm::heap_allocator

source · []
Expand description

The global allocator

+

Statics

+

heap allocator instance

+

heap space ([u8; KERNEL_HEAP_SIZE])

+

Functions

+

panic when heap allocation error occurs

+

initiate heap allocator

+
\ No newline at end of file diff --git a/ch4/os/mm/heap_allocator/sidebar-items.js b/ch4/os/mm/heap_allocator/sidebar-items.js index d1f423dc..a400d729 100644 --- a/ch4/os/mm/heap_allocator/sidebar-items.js +++ b/ch4/os/mm/heap_allocator/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["handle_alloc_error",""],["heap_test",""],["init_heap",""]],"static":[["HEAP_ALLOCATOR",""],["HEAP_SPACE",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["handle_alloc_error","panic when heap allocation error occurs"],["heap_test",""],["init_heap","initiate heap allocator"]],"static":[["HEAP_ALLOCATOR","heap allocator instance"],["HEAP_SPACE","heap space ([u8; KERNEL_HEAP_SIZE])"]]}); \ No newline at end of file diff --git a/ch4/os/mm/heap_allocator/static.HEAP_ALLOCATOR.html b/ch4/os/mm/heap_allocator/static.HEAP_ALLOCATOR.html index 80e8d72a..f5ec0139 100644 --- a/ch4/os/mm/heap_allocator/static.HEAP_ALLOCATOR.html +++ b/ch4/os/mm/heap_allocator/static.HEAP_ALLOCATOR.html @@ -1,6 +1,7 @@ -HEAP_ALLOCATOR in os::mm::heap_allocator - Rust +HEAP_ALLOCATOR in os::mm::heap_allocator - Rust
static HEAP_ALLOCATOR: LockedHeap
+

Static os::mm::heap_allocator::HEAP_ALLOCATOR

source · []
static HEAP_ALLOCATOR: LockedHeap
Expand description

heap allocator instance

+
\ No newline at end of file diff --git a/ch4/os/mm/heap_allocator/static.HEAP_SPACE.html b/ch4/os/mm/heap_allocator/static.HEAP_SPACE.html index 5bba1873..111d8709 100644 --- a/ch4/os/mm/heap_allocator/static.HEAP_SPACE.html +++ b/ch4/os/mm/heap_allocator/static.HEAP_SPACE.html @@ -1,6 +1,7 @@ -HEAP_SPACE in os::mm::heap_allocator - Rust +HEAP_SPACE in os::mm::heap_allocator - Rust
static mut HEAP_SPACE: [u8; 3145728]
+

Static os::mm::heap_allocator::HEAP_SPACE

source · []
static mut HEAP_SPACE: [u8; 3145728]
Expand description

heap space ([u8; KERNEL_HEAP_SIZE])

+
\ No newline at end of file diff --git a/ch4/os/mm/index.html b/ch4/os/mm/index.html index 32853888..5635071a 100644 --- a/ch4/os/mm/index.html +++ b/ch4/os/mm/index.html @@ -1,9 +1,21 @@ -os::mm - Rust +os::mm - Rust
-

Module os::mm

source · []

Re-exports

+

Module os::mm

source · []
Expand description

Memory management implementation

+

SV39 page-based virtual-memory architecture for RV64 systems, and +everything about memory management, like frame allocator, page table, +map area and memory set, is implemented here.

+

Every task or process has a memory_set to control its virtual memory.

+

Re-exports

pub use address::PhysAddr;
pub use address::PhysPageNum;
pub use address::VirtAddr;
pub use address::VirtPageNum;
pub use frame_allocator::frame_alloc;
pub use frame_allocator::FrameTracker;
pub use memory_set::remap_test;
pub use memory_set::MapPermission;
pub use memory_set::MemorySet;
pub use memory_set::KERNEL_SPACE;
pub use memory_set::KERNEL_SPACE;
pub use page_table::translated_byte_buffer;
pub use page_table::PageTableEntry;

Modules

-

Functions

-
+

Implementation of physical and virtual address and page number.

+

Implementation of FrameAllocator which +controls all the frames in the operating system.

+

The global allocator

+

Implementation of MapArea and MemorySet.

+

Implementation of PageTableEntry and PageTable.

+

Functions

+

initiate heap allocator, frame allocator and kernel space

+
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/enum.MapType.html b/ch4/os/mm/memory_set/enum.MapType.html index 88675cce..c9d0b5c5 100644 --- a/ch4/os/mm/memory_set/enum.MapType.html +++ b/ch4/os/mm/memory_set/enum.MapType.html @@ -1,17 +1,18 @@ -MapType in os::mm::memory_set - Rust +MapType in os::mm::memory_set - Rust
pub enum MapType {
+    

Enum os::mm::memory_set::MapType

source · []
pub enum MapType {
     Identical,
     Framed,
-}

Variants

Identical

Framed

Trait Implementations

Returns a copy of the value. Read more

+}
Expand description

map type for memory set: identical or framed

+

Variants

Identical

Framed

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

This method tests for self and other values to be equal, and is used +

Formats the value using the given formatter. Read more

+

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/memory_set/fn.ebss.html b/ch4/os/mm/memory_set/fn.ebss.html index 3bd8584f..11f33595 100644 --- a/ch4/os/mm/memory_set/fn.ebss.html +++ b/ch4/os/mm/memory_set/fn.ebss.html @@ -2,5 +2,5 @@
-

Function os::mm::memory_set::ebss

source · []
unsafe extern "C" fn ebss()
+

Function os::mm::memory_set::ebss

source · []
unsafe extern "C" fn ebss()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.edata.html b/ch4/os/mm/memory_set/fn.edata.html index b9f4cc53..b4eec0d9 100644 --- a/ch4/os/mm/memory_set/fn.edata.html +++ b/ch4/os/mm/memory_set/fn.edata.html @@ -2,5 +2,5 @@
-

Function os::mm::memory_set::edata

source · []
unsafe extern "C" fn edata()
+

Function os::mm::memory_set::edata

source · []
unsafe extern "C" fn edata()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.ekernel.html b/ch4/os/mm/memory_set/fn.ekernel.html index a68105d6..ec06c973 100644 --- a/ch4/os/mm/memory_set/fn.ekernel.html +++ b/ch4/os/mm/memory_set/fn.ekernel.html @@ -2,5 +2,5 @@
-

Function os::mm::memory_set::ekernel

source · []
unsafe extern "C" fn ekernel()
+

Function os::mm::memory_set::ekernel

source · []
unsafe extern "C" fn ekernel()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.erodata.html b/ch4/os/mm/memory_set/fn.erodata.html index 7a42fc8f..a4c1c77a 100644 --- a/ch4/os/mm/memory_set/fn.erodata.html +++ b/ch4/os/mm/memory_set/fn.erodata.html @@ -2,5 +2,5 @@
-

Function os::mm::memory_set::erodata

source · []
unsafe extern "C" fn erodata()
+

Function os::mm::memory_set::erodata

source · []
unsafe extern "C" fn erodata()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.etext.html b/ch4/os/mm/memory_set/fn.etext.html index dfa43cfd..1ecbf9d3 100644 --- a/ch4/os/mm/memory_set/fn.etext.html +++ b/ch4/os/mm/memory_set/fn.etext.html @@ -2,5 +2,5 @@
-

Function os::mm::memory_set::etext

source · []
unsafe extern "C" fn etext()
+

Function os::mm::memory_set::etext

source · []
unsafe extern "C" fn etext()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.remap_test.html b/ch4/os/mm/memory_set/fn.remap_test.html index 56dcc149..764366b9 100644 --- a/ch4/os/mm/memory_set/fn.remap_test.html +++ b/ch4/os/mm/memory_set/fn.remap_test.html @@ -2,5 +2,5 @@
pub fn remap_test()
+

Function os::mm::memory_set::remap_test

source · []
pub fn remap_test()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.sbss_with_stack.html b/ch4/os/mm/memory_set/fn.sbss_with_stack.html index ecbf7b8a..84a2931b 100644 --- a/ch4/os/mm/memory_set/fn.sbss_with_stack.html +++ b/ch4/os/mm/memory_set/fn.sbss_with_stack.html @@ -2,5 +2,5 @@
unsafe extern "C" fn sbss_with_stack()
+

Function os::mm::memory_set::sbss_with_stack

source · []
unsafe extern "C" fn sbss_with_stack()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.sdata.html b/ch4/os/mm/memory_set/fn.sdata.html index 21790d43..d79948a9 100644 --- a/ch4/os/mm/memory_set/fn.sdata.html +++ b/ch4/os/mm/memory_set/fn.sdata.html @@ -2,5 +2,5 @@
-

Function os::mm::memory_set::sdata

source · []
unsafe extern "C" fn sdata()
+

Function os::mm::memory_set::sdata

source · []
unsafe extern "C" fn sdata()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.srodata.html b/ch4/os/mm/memory_set/fn.srodata.html index 12becf5b..ce2598a4 100644 --- a/ch4/os/mm/memory_set/fn.srodata.html +++ b/ch4/os/mm/memory_set/fn.srodata.html @@ -2,5 +2,5 @@
-

Function os::mm::memory_set::srodata

source · []
unsafe extern "C" fn srodata()
+

Function os::mm::memory_set::srodata

source · []
unsafe extern "C" fn srodata()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.stext.html b/ch4/os/mm/memory_set/fn.stext.html index f462b9fc..d950b37d 100644 --- a/ch4/os/mm/memory_set/fn.stext.html +++ b/ch4/os/mm/memory_set/fn.stext.html @@ -2,5 +2,5 @@
-

Function os::mm::memory_set::stext

source · []
unsafe extern "C" fn stext()
+

Function os::mm::memory_set::stext

source · []
unsafe extern "C" fn stext()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/fn.strampoline.html b/ch4/os/mm/memory_set/fn.strampoline.html index 6dd5b9da..ad7ef39d 100644 --- a/ch4/os/mm/memory_set/fn.strampoline.html +++ b/ch4/os/mm/memory_set/fn.strampoline.html @@ -2,5 +2,5 @@
unsafe extern "C" fn strampoline()
+

Function os::mm::memory_set::strampoline

source · []
unsafe extern "C" fn strampoline()
\ No newline at end of file diff --git a/ch4/os/mm/memory_set/index.html b/ch4/os/mm/memory_set/index.html index 0c31325f..a3611f0f 100644 --- a/ch4/os/mm/memory_set/index.html +++ b/ch4/os/mm/memory_set/index.html @@ -1,9 +1,15 @@ -os::mm::memory_set - Rust +os::mm::memory_set - Rust
Expand description

Implementation of MapArea and MemorySet.

+

Structs

+

a memory set instance through lazy_static! managing kernel space

+

map area structure, controls a contiguous piece of virtual memory

+

map permission corresponding to that in pte: R W X U

+

memory set structure, controls virtual-memory space

+

Enums

+

map type for memory set: identical or framed

+

Functions

\ No newline at end of file diff --git a/ch4/os/mm/memory_set/sidebar-items.js b/ch4/os/mm/memory_set/sidebar-items.js index 04cf13e9..8445e938 100644 --- a/ch4/os/mm/memory_set/sidebar-items.js +++ b/ch4/os/mm/memory_set/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"enum":[["MapType",""]],"fn":[["ebss",""],["edata",""],["ekernel",""],["erodata",""],["etext",""],["remap_test",""],["sbss_with_stack",""],["sdata",""],["srodata",""],["stext",""],["strampoline",""]],"struct":[["KERNEL_SPACE",""],["MapArea",""],["MapPermission",""],["MemorySet",""]]}); \ No newline at end of file +initSidebarItems({"enum":[["MapType","map type for memory set: identical or framed"]],"fn":[["ebss",""],["edata",""],["ekernel",""],["erodata",""],["etext",""],["remap_test",""],["sbss_with_stack",""],["sdata",""],["srodata",""],["stext",""],["strampoline",""]],"struct":[["KERNEL_SPACE","a memory set instance through lazy_static! managing kernel space"],["MapArea","map area structure, controls a contiguous piece of virtual memory"],["MapPermission","map permission corresponding to that in pte: `R W X U`"],["MemorySet","memory set structure, controls virtual-memory space"]]}); \ No newline at end of file diff --git a/ch4/os/mm/memory_set/struct.KERNEL_SPACE.html b/ch4/os/mm/memory_set/struct.KERNEL_SPACE.html index ff47bab0..b59b0b8d 100644 --- a/ch4/os/mm/memory_set/struct.KERNEL_SPACE.html +++ b/ch4/os/mm/memory_set/struct.KERNEL_SPACE.html @@ -1,12 +1,13 @@ -KERNEL_SPACE in os::mm::memory_set - Rust +KERNEL_SPACE in os::mm::memory_set - Rust
pub struct KERNEL_SPACE {
+    

Struct os::mm::memory_set::KERNEL_SPACE

source · []
pub struct KERNEL_SPACE {
     __private_field: (),
-}

Fields

__private_field: ()

Trait Implementations

The resulting type after dereferencing.

-

Dereferences the value.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

a memory set instance through lazy_static! managing kernel space

+

Fields

__private_field: ()

Trait Implementations

The resulting type after dereferencing.

+

Dereferences the value.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/memory_set/struct.MapArea.html b/ch4/os/mm/memory_set/struct.MapArea.html index 52907c98..532cf3e4 100644 --- a/ch4/os/mm/memory_set/struct.MapArea.html +++ b/ch4/os/mm/memory_set/struct.MapArea.html @@ -1,13 +1,14 @@ -MapArea in os::mm::memory_set - Rust +MapArea in os::mm::memory_set - Rust
pub struct MapArea {
+    

Struct os::mm::memory_set::MapArea

source · []
pub struct MapArea {
     vpn_range: SimpleRange<VirtPageNum>,
     data_frames: BTreeMap<VirtPageNum, FrameTracker>,
     map_type: MapType,
     map_perm: MapPermission,
-}

Fields

vpn_range: SimpleRange<VirtPageNum>data_frames: BTreeMap<VirtPageNum, FrameTracker>map_type: MapTypemap_perm: MapPermission

Implementations

data: start-aligned but maybe with shorter length +}

Expand description

map area structure, controls a contiguous piece of virtual memory

+

Fields

vpn_range: SimpleRange<VirtPageNum>data_frames: BTreeMap<VirtPageNum, FrameTracker>map_type: MapTypemap_perm: MapPermission

Implementations

data: start-aligned but maybe with shorter length assume that all frames were cleared before

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

diff --git a/ch4/os/mm/memory_set/struct.MapPermission.html b/ch4/os/mm/memory_set/struct.MapPermission.html index 8fa4b5c3..19d5ed0c 100644 --- a/ch4/os/mm/memory_set/struct.MapPermission.html +++ b/ch4/os/mm/memory_set/struct.MapPermission.html @@ -1,17 +1,18 @@ -MapPermission in os::mm::memory_set - Rust +MapPermission in os::mm::memory_set - Rust
pub struct MapPermission {
+    

Struct os::mm::memory_set::MapPermission

source · []
pub struct MapPermission {
     bits: u8,
-}

Fields

bits: u8

Implementations

Returns an empty set of flags.

-

Returns the set containing all flags.

-

Returns the raw value of the flags currently stored.

-

Convert from underlying bit representation, unless that +}

Expand description

map permission corresponding to that in pte: R W X U

+

Fields

bits: u8

Implementations

Returns an empty set of flags.

+

Returns the set containing all flags.

+

Returns the raw value of the flags currently stored.

+

Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.

-

Convert from underlying bit representation, dropping any bits +

Convert from underlying bit representation, dropping any bits that do not correspond to flags.

-

Convert from underlying bit representation, preserving all +

Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).

Safety

The caller of the bitflags! macro can chose to allow or @@ -19,35 +20,35 @@ disallow extra bits for their bitflags type.

The caller of from_bits_unchecked() has to ensure that all bits correspond to a defined flag or that extra bits are valid for this bitflags type.

-

Returns true if no flags are currently stored.

-

Returns true if all flags are currently set.

-

Returns true if there are flags common to both self and other.

-

Returns true if all of the flags in other are contained within self.

-

Inserts the specified flags in-place.

-

Removes the specified flags in-place.

-

Toggles the specified flags in-place.

-

Inserts or removes the specified flags depending on the passed value.

-

Returns the intersection between the flags in self and +

Returns true if no flags are currently stored.

+

Returns true if all flags are currently set.

+

Returns true if there are flags common to both self and other.

+

Returns true if all of the flags in other are contained within self.

+

Inserts the specified flags in-place.

+

Removes the specified flags in-place.

+

Toggles the specified flags in-place.

+

Inserts or removes the specified flags depending on the passed value.

+

Returns the intersection between the flags in self and other.

Specifically, the returned set contains only the flags which are present in both self and other.

This is equivalent to using the & operator (e.g. ops::BitAnd), as in flags & other.

-

Returns the union of between the flags in self and other.

+

Returns the union of between the flags in self and other.

Specifically, the returned set contains all flags which are present in either self or other, including any which are present in both (see Self::symmetric_difference if that is undesirable).

This is equivalent to using the | operator (e.g. ops::BitOr), as in flags | other.

-

Returns the difference between the flags in self and other.

+

Returns the difference between the flags in self and other.

Specifically, the returned set contains all flags present in self, except for the ones present in other.

It is also conceptually equivalent to the “bit-clear” operation: flags & !other (and this syntax is also supported).

This is equivalent to using the - operator (e.g. ops::Sub), as in flags - other.

-

Returns the symmetric difference between the flags +

Returns the symmetric difference between the flags in self and other.

Specifically, the returned set contains the flags present which are present in self or other, but that are not present in @@ -55,55 +56,55 @@ both. Equivalently, it contains the flags present in exactly one of the sets self and other.

This is equivalent to using the ^ operator (e.g. ops::BitXor), as in flags ^ other.

-

Returns the complement of this set of flags.

+

Returns the complement of this set of flags.

Specifically, the returned set contains all the flags which are not set in self, but which are allowed for this type.

Alternatively, it can be thought of as the set difference between Self::all() and self (e.g. Self::all() - self)

This is equivalent to using the ! operator (e.g. ops::Not), as in !flags.

-

Trait Implementations

Formats the value using the given formatter.

-

Returns the intersection between the two sets of flags.

+

Trait Implementations

Formats the value using the given formatter.

+

Returns the intersection between the two sets of flags.

The resulting type after applying the & operator.

-

Disables all flags disabled in the set.

-

Returns the union of the two sets of flags.

+

Disables all flags disabled in the set.

+

Returns the union of the two sets of flags.

The resulting type after applying the | operator.

-

Adds the set of flags.

-

Returns the left flags, but with all the right flags toggled.

+

Adds the set of flags.

+

Returns the left flags, but with all the right flags toggled.

The resulting type after applying the ^ operator.

-

Toggles the set of flags.

-

Returns a copy of the value. Read more

+

Toggles the set of flags.

+

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

Extends a collection with the contents of an iterator. Read more

+

Formats the value using the given formatter. Read more

+

Extends a collection with the contents of an iterator. Read more

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

-

Creates a value from an iterator. Read more

-

Feeds this value into the given Hasher. Read more

+

Creates a value from an iterator. Read more

+

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

-

Formats the value using the given formatter.

-

Returns the complement of this set of flags.

+

Formats the value using the given formatter.

+

Returns the complement of this set of flags.

The resulting type after applying the ! operator.

-

Formats the value using the given formatter.

-

This method returns an Ordering between self and other. Read more

+

Formats the value using the given formatter.

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

-

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method tests for !=.

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Returns the set difference of the two sets of flags.

+

Returns the set difference of the two sets of flags.

The resulting type after applying the - operator.

-

Disables all flags enabled in the set.

-

Formats the value using the given formatter.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Disables all flags enabled in the set.

+

Formats the value using the given formatter.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/memory_set/struct.MemorySet.html b/ch4/os/mm/memory_set/struct.MemorySet.html index 177c1aa6..446d4590 100644 --- a/ch4/os/mm/memory_set/struct.MemorySet.html +++ b/ch4/os/mm/memory_set/struct.MemorySet.html @@ -1,16 +1,17 @@ -MemorySet in os::mm::memory_set - Rust +MemorySet in os::mm::memory_set - Rust
pub struct MemorySet {
+    

Struct os::mm::memory_set::MemorySet

source · []
pub struct MemorySet {
     page_table: PageTable,
     areas: Vec<MapArea>,
-}

Fields

page_table: PageTableareas: Vec<MapArea>

Implementations

Assume that no conflicts.

-

Mention that trampoline is not collected by areas.

-

Without kernel stacks.

-

Include sections in elf and trampoline and TrapContext and user stack, +}

Expand description

memory set structure, controls virtual-memory space

+

Fields

page_table: PageTableareas: Vec<MapArea>

Implementations

Assume that no conflicts.

+

Mention that trampoline is not collected by areas.

+

Without kernel stacks.

+

Include sections in elf and trampoline and TrapContext and user stack, also returns user_sp and entry point.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/page_table/fn.translated_byte_buffer.html b/ch4/os/mm/page_table/fn.translated_byte_buffer.html index b4bb4c63..9e2bd9e5 100644 --- a/ch4/os/mm/page_table/fn.translated_byte_buffer.html +++ b/ch4/os/mm/page_table/fn.translated_byte_buffer.html @@ -1,6 +1,7 @@ -translated_byte_buffer in os::mm::page_table - Rust +translated_byte_buffer in os::mm::page_table - Rust
pub fn translated_byte_buffer(
    token: usize,
    ptr: *const u8,
    len: usize
) -> Vec<&'static mut [u8]>
+

Function os::mm::page_table::translated_byte_buffer

source · []
pub fn translated_byte_buffer(
    token: usize,
    ptr: *const u8,
    len: usize
) -> Vec<&'static mut [u8]>
Expand description

translate a pointer to a mutable u8 Vec through page table

+
\ No newline at end of file diff --git a/ch4/os/mm/page_table/index.html b/ch4/os/mm/page_table/index.html index cf418b36..61684637 100644 --- a/ch4/os/mm/page_table/index.html +++ b/ch4/os/mm/page_table/index.html @@ -1,8 +1,13 @@ -os::mm::page_table - Rust +os::mm::page_table - Rust
+

Module os::mm::page_table

source · []
Expand description

Implementation of PageTableEntry and PageTable.

+

Structs

+

page table entry flags

+

page table structure

+

page table entry structure

+

Functions

+

translate a pointer to a mutable u8 Vec through page table

+
\ No newline at end of file diff --git a/ch4/os/mm/page_table/sidebar-items.js b/ch4/os/mm/page_table/sidebar-items.js index 587b1852..d66f2651 100644 --- a/ch4/os/mm/page_table/sidebar-items.js +++ b/ch4/os/mm/page_table/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["translated_byte_buffer",""]],"struct":[["PTEFlags",""],["PageTable",""],["PageTableEntry",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["translated_byte_buffer","translate a pointer to a mutable u8 Vec through page table"]],"struct":[["PTEFlags","page table entry flags"],["PageTable","page table structure"],["PageTableEntry","page table entry structure"]]}); \ No newline at end of file diff --git a/ch4/os/mm/page_table/struct.PTEFlags.html b/ch4/os/mm/page_table/struct.PTEFlags.html index d01689cb..193c30c7 100644 --- a/ch4/os/mm/page_table/struct.PTEFlags.html +++ b/ch4/os/mm/page_table/struct.PTEFlags.html @@ -1,17 +1,18 @@ -PTEFlags in os::mm::page_table - Rust +PTEFlags in os::mm::page_table - Rust
pub struct PTEFlags {
+    

Struct os::mm::page_table::PTEFlags

source · []
pub struct PTEFlags {
     bits: u8,
-}

Fields

bits: u8

Implementations

Returns an empty set of flags.

-

Returns the set containing all flags.

-

Returns the raw value of the flags currently stored.

-

Convert from underlying bit representation, unless that +}

Expand description

page table entry flags

+

Fields

bits: u8

Implementations

Returns an empty set of flags.

+

Returns the set containing all flags.

+

Returns the raw value of the flags currently stored.

+

Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.

-

Convert from underlying bit representation, dropping any bits +

Convert from underlying bit representation, dropping any bits that do not correspond to flags.

-

Convert from underlying bit representation, preserving all +

Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).

Safety

The caller of the bitflags! macro can chose to allow or @@ -19,35 +20,35 @@ disallow extra bits for their bitflags type.

The caller of from_bits_unchecked() has to ensure that all bits correspond to a defined flag or that extra bits are valid for this bitflags type.

-

Returns true if no flags are currently stored.

-

Returns true if all flags are currently set.

-

Returns true if there are flags common to both self and other.

-

Returns true if all of the flags in other are contained within self.

-

Inserts the specified flags in-place.

-

Removes the specified flags in-place.

-

Toggles the specified flags in-place.

-

Inserts or removes the specified flags depending on the passed value.

-

Returns the intersection between the flags in self and +

Returns true if no flags are currently stored.

+

Returns true if all flags are currently set.

+

Returns true if there are flags common to both self and other.

+

Returns true if all of the flags in other are contained within self.

+

Inserts the specified flags in-place.

+

Removes the specified flags in-place.

+

Toggles the specified flags in-place.

+

Inserts or removes the specified flags depending on the passed value.

+

Returns the intersection between the flags in self and other.

Specifically, the returned set contains only the flags which are present in both self and other.

This is equivalent to using the & operator (e.g. ops::BitAnd), as in flags & other.

-

Returns the union of between the flags in self and other.

+

Returns the union of between the flags in self and other.

Specifically, the returned set contains all flags which are present in either self or other, including any which are present in both (see Self::symmetric_difference if that is undesirable).

This is equivalent to using the | operator (e.g. ops::BitOr), as in flags | other.

-

Returns the difference between the flags in self and other.

+

Returns the difference between the flags in self and other.

Specifically, the returned set contains all flags present in self, except for the ones present in other.

It is also conceptually equivalent to the “bit-clear” operation: flags & !other (and this syntax is also supported).

This is equivalent to using the - operator (e.g. ops::Sub), as in flags - other.

-

Returns the symmetric difference between the flags +

Returns the symmetric difference between the flags in self and other.

Specifically, the returned set contains the flags present which are present in self or other, but that are not present in @@ -55,55 +56,55 @@ both. Equivalently, it contains the flags present in exactly one of the sets self and other.

This is equivalent to using the ^ operator (e.g. ops::BitXor), as in flags ^ other.

-

Returns the complement of this set of flags.

+

Returns the complement of this set of flags.

Specifically, the returned set contains all the flags which are not set in self, but which are allowed for this type.

Alternatively, it can be thought of as the set difference between Self::all() and self (e.g. Self::all() - self)

This is equivalent to using the ! operator (e.g. ops::Not), as in !flags.

-

Trait Implementations

Formats the value using the given formatter.

-

Returns the intersection between the two sets of flags.

+

Trait Implementations

Formats the value using the given formatter.

+

Returns the intersection between the two sets of flags.

The resulting type after applying the & operator.

-

Disables all flags disabled in the set.

-

Returns the union of the two sets of flags.

+

Disables all flags disabled in the set.

+

Returns the union of the two sets of flags.

The resulting type after applying the | operator.

-

Adds the set of flags.

-

Returns the left flags, but with all the right flags toggled.

+

Adds the set of flags.

+

Returns the left flags, but with all the right flags toggled.

The resulting type after applying the ^ operator.

-

Toggles the set of flags.

-

Returns a copy of the value. Read more

+

Toggles the set of flags.

+

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

Extends a collection with the contents of an iterator. Read more

+

Formats the value using the given formatter. Read more

+

Extends a collection with the contents of an iterator. Read more

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

-

Creates a value from an iterator. Read more

-

Feeds this value into the given Hasher. Read more

+

Creates a value from an iterator. Read more

+

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

-

Formats the value using the given formatter.

-

Returns the complement of this set of flags.

+

Formats the value using the given formatter.

+

Returns the complement of this set of flags.

The resulting type after applying the ! operator.

-

Formats the value using the given formatter.

-

This method returns an Ordering between self and other. Read more

+

Formats the value using the given formatter.

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

-

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method tests for !=.

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Returns the set difference of the two sets of flags.

+

Returns the set difference of the two sets of flags.

The resulting type after applying the - operator.

-

Disables all flags enabled in the set.

-

Formats the value using the given formatter.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Disables all flags enabled in the set.

+

Formats the value using the given formatter.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/page_table/struct.PageTable.html b/ch4/os/mm/page_table/struct.PageTable.html index 1634c31e..898d7ac4 100644 --- a/ch4/os/mm/page_table/struct.PageTable.html +++ b/ch4/os/mm/page_table/struct.PageTable.html @@ -1,13 +1,14 @@ -PageTable in os::mm::page_table - Rust +PageTable in os::mm::page_table - Rust
pub struct PageTable {
+    

Struct os::mm::page_table::PageTable

source · []
pub struct PageTable {
     root_ppn: PhysPageNum,
     frames: Vec<FrameTracker>,
-}

Fields

root_ppn: PhysPageNumframes: Vec<FrameTracker>

Implementations

Assume that it won’t oom when creating/mapping.

-

Temporarily used to get arguments from user space.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

page table structure

+

Fields

root_ppn: PhysPageNumframes: Vec<FrameTracker>

Implementations

Assume that it won’t oom when creating/mapping.

+

Temporarily used to get arguments from user space.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/page_table/struct.PageTableEntry.html b/ch4/os/mm/page_table/struct.PageTableEntry.html index a67f9883..2de5d907 100644 --- a/ch4/os/mm/page_table/struct.PageTableEntry.html +++ b/ch4/os/mm/page_table/struct.PageTableEntry.html @@ -1,12 +1,13 @@ -PageTableEntry in os::mm::page_table - Rust +PageTableEntry in os::mm::page_table - Rust
#[repr(C)]
pub struct PageTableEntry { +

Struct os::mm::page_table::PageTableEntry

source · []
#[repr(C)]
pub struct PageTableEntry { pub bits: usize, -}

Fields

bits: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

+}
Expand description

page table entry structure

+

Fields

bits: usize

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/mm/sidebar-items.js b/ch4/os/mm/sidebar-items.js index 5e2f1aaa..b6d4156f 100644 --- a/ch4/os/mm/sidebar-items.js +++ b/ch4/os/mm/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["init",""]],"mod":[["address",""],["frame_allocator",""],["heap_allocator",""],["memory_set",""],["page_table",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["init","initiate heap allocator, frame allocator and kernel space"]],"mod":[["address","Implementation of physical and virtual address and page number."],["frame_allocator","Implementation of [`FrameAllocator`] which controls all the frames in the operating system."],["heap_allocator","The global allocator"],["memory_set","Implementation of [`MapArea`] and [`MemorySet`]."],["page_table","Implementation of [`PageTableEntry`] and [`PageTable`]."]]}); \ No newline at end of file diff --git a/ch4/os/sbi/constant.SBI_CLEAR_IPI.html b/ch4/os/sbi/constant.SBI_CLEAR_IPI.html deleted file mode 100644 index c191974c..00000000 --- a/ch4/os/sbi/constant.SBI_CLEAR_IPI.html +++ /dev/null @@ -1,6 +0,0 @@ -SBI_CLEAR_IPI in os::sbi - Rust -
-

Constant os::sbi::SBI_CLEAR_IPI

source · []
const SBI_CLEAR_IPI: usize = 3;
- \ No newline at end of file diff --git a/ch4/os/sbi/constant.SBI_CONSOLE_GETCHAR.html b/ch4/os/sbi/constant.SBI_CONSOLE_GETCHAR.html deleted file mode 100644 index 12640c16..00000000 --- a/ch4/os/sbi/constant.SBI_CONSOLE_GETCHAR.html +++ /dev/null @@ -1,6 +0,0 @@ -SBI_CONSOLE_GETCHAR in os::sbi - Rust -
const SBI_CONSOLE_GETCHAR: usize = 2;
- \ No newline at end of file diff --git a/ch4/os/sbi/constant.SBI_REMOTE_FENCE_I.html b/ch4/os/sbi/constant.SBI_REMOTE_FENCE_I.html deleted file mode 100644 index 35e0c19e..00000000 --- a/ch4/os/sbi/constant.SBI_REMOTE_FENCE_I.html +++ /dev/null @@ -1,6 +0,0 @@ -SBI_REMOTE_FENCE_I in os::sbi - Rust -
const SBI_REMOTE_FENCE_I: usize = 5;
- \ No newline at end of file diff --git a/ch4/os/sbi/constant.SBI_REMOTE_SFENCE_VMA.html b/ch4/os/sbi/constant.SBI_REMOTE_SFENCE_VMA.html deleted file mode 100644 index 4bedd2b5..00000000 --- a/ch4/os/sbi/constant.SBI_REMOTE_SFENCE_VMA.html +++ /dev/null @@ -1,6 +0,0 @@ -SBI_REMOTE_SFENCE_VMA in os::sbi - Rust -
const SBI_REMOTE_SFENCE_VMA: usize = 6;
- \ No newline at end of file diff --git a/ch4/os/sbi/constant.SBI_REMOTE_SFENCE_VMA_ASID.html b/ch4/os/sbi/constant.SBI_REMOTE_SFENCE_VMA_ASID.html deleted file mode 100644 index 06c69ce2..00000000 --- a/ch4/os/sbi/constant.SBI_REMOTE_SFENCE_VMA_ASID.html +++ /dev/null @@ -1,6 +0,0 @@ -SBI_REMOTE_SFENCE_VMA_ASID in os::sbi - Rust -
const SBI_REMOTE_SFENCE_VMA_ASID: usize = 7;
- \ No newline at end of file diff --git a/ch4/os/sbi/constant.SBI_SEND_IPI.html b/ch4/os/sbi/constant.SBI_SEND_IPI.html deleted file mode 100644 index a3da3df2..00000000 --- a/ch4/os/sbi/constant.SBI_SEND_IPI.html +++ /dev/null @@ -1,6 +0,0 @@ -SBI_SEND_IPI in os::sbi - Rust -
-

Constant os::sbi::SBI_SEND_IPI

source · []
const SBI_SEND_IPI: usize = 4;
- \ No newline at end of file diff --git a/ch4/os/sbi/fn.console_getchar.html b/ch4/os/sbi/fn.console_getchar.html deleted file mode 100644 index 877c7578..00000000 --- a/ch4/os/sbi/fn.console_getchar.html +++ /dev/null @@ -1,6 +0,0 @@ -console_getchar in os::sbi - Rust -
pub fn console_getchar() -> usize
- \ No newline at end of file diff --git a/ch4/os/sbi/fn.console_putchar.html b/ch4/os/sbi/fn.console_putchar.html index d1f365ff..5eadeec8 100644 --- a/ch4/os/sbi/fn.console_putchar.html +++ b/ch4/os/sbi/fn.console_putchar.html @@ -1,6 +1,7 @@ -console_putchar in os::sbi - Rust +console_putchar in os::sbi - Rust
pub fn console_putchar(c: usize)
+

Function os::sbi::console_putchar

source · []
pub fn console_putchar(c: usize)
Expand description

use sbi call to putchar in console (qemu uart handler)

+
\ No newline at end of file diff --git a/ch4/os/sbi/fn.sbi_call.html b/ch4/os/sbi/fn.sbi_call.html index 00731305..ba4d5230 100644 --- a/ch4/os/sbi/fn.sbi_call.html +++ b/ch4/os/sbi/fn.sbi_call.html @@ -1,6 +1,7 @@ -sbi_call in os::sbi - Rust +sbi_call in os::sbi - Rust
-

Function os::sbi::sbi_call

source · []
fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize
+

Function os::sbi::sbi_call

source · []
fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize
Expand description

general sbi call

+
\ No newline at end of file diff --git a/ch4/os/sbi/fn.set_timer.html b/ch4/os/sbi/fn.set_timer.html index baa87c5b..c7761375 100644 --- a/ch4/os/sbi/fn.set_timer.html +++ b/ch4/os/sbi/fn.set_timer.html @@ -1,6 +1,7 @@ -set_timer in os::sbi - Rust +set_timer in os::sbi - Rust
-

Function os::sbi::set_timer

source · []
pub fn set_timer(timer: usize)
+

Function os::sbi::set_timer

source · []
pub fn set_timer(timer: usize)
Expand description

use sbi call to set timer

+
\ No newline at end of file diff --git a/ch4/os/sbi/fn.shutdown.html b/ch4/os/sbi/fn.shutdown.html index 14b7a2d8..e8324d4d 100644 --- a/ch4/os/sbi/fn.shutdown.html +++ b/ch4/os/sbi/fn.shutdown.html @@ -1,6 +1,8 @@ -shutdown in os::sbi - Rust +shutdown in os::sbi - Rust
-

Function os::sbi::shutdown

source · []
pub fn shutdown() -> !
+

Function os::sbi::shutdown

source · []
pub fn shutdown() -> !
Expand description

use sbi call to getchar from console (qemu uart handler) +use sbi call to shutdown the kernel

+
\ No newline at end of file diff --git a/ch4/os/sbi/index.html b/ch4/os/sbi/index.html index 8c090e8c..6923bbd7 100644 --- a/ch4/os/sbi/index.html +++ b/ch4/os/sbi/index.html @@ -1,8 +1,14 @@ -os::sbi - Rust +os::sbi - Rust
+

Module os::sbi

source · []
Expand description

SBI call wrappers

+

Constants

+

Functions

+

use sbi call to putchar in console (qemu uart handler)

+

general sbi call

+

use sbi call to set timer

+

use sbi call to getchar from console (qemu uart handler) +use sbi call to shutdown the kernel

+
\ No newline at end of file diff --git a/ch4/os/sbi/sidebar-items.js b/ch4/os/sbi/sidebar-items.js index 025cc5ad..feec67bb 100644 --- a/ch4/os/sbi/sidebar-items.js +++ b/ch4/os/sbi/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"constant":[["SBI_CLEAR_IPI",""],["SBI_CONSOLE_GETCHAR",""],["SBI_CONSOLE_PUTCHAR",""],["SBI_REMOTE_FENCE_I",""],["SBI_REMOTE_SFENCE_VMA",""],["SBI_REMOTE_SFENCE_VMA_ASID",""],["SBI_SEND_IPI",""],["SBI_SET_TIMER",""],["SBI_SHUTDOWN",""]],"fn":[["console_getchar",""],["console_putchar",""],["sbi_call",""],["set_timer",""],["shutdown",""]]}); \ No newline at end of file +initSidebarItems({"constant":[["SBI_CONSOLE_PUTCHAR",""],["SBI_SET_TIMER",""],["SBI_SHUTDOWN",""]],"fn":[["console_putchar","use sbi call to putchar in console (qemu uart handler)"],["sbi_call","general sbi call"],["set_timer","use sbi call to set timer"],["shutdown","use sbi call to getchar from console (qemu uart handler) use sbi call to shutdown the kernel"]]}); \ No newline at end of file diff --git a/ch4/os/sidebar-items.js b/ch4/os/sidebar-items.js index bf6c5eff..4666d920 100644 --- a/ch4/os/sidebar-items.js +++ b/ch4/os/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["clear_bss",""],["rust_main",""]],"macro":[["print",""],["println",""]],"mod":[["board",""],["config",""],["console",""],["lang_items",""],["loader",""],["mm",""],["sbi",""],["sync",""],["syscall",""],["task",""],["timer",""],["trap",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["clear_bss","clear BSS segment"],["rust_main","the rust entry-point of os"]],"macro":[["print","print string macro"],["println","println string macro"]],"mod":[["board",""],["config","Constants used in rCore"],["console","SBI console driver, for text output"],["lang_items","The panic handler"],["loader","Loading user applications into memory"],["mm","Memory management implementation"],["sbi","SBI call wrappers"],["sync","Synchronization and interior mutability primitives"],["syscall","Implementation of syscalls"],["task","Task management implementation"],["timer","RISC-V timer-related functionality"],["trap","Trap handling functionality"]]}); \ No newline at end of file diff --git a/ch4/os/sync/index.html b/ch4/os/sync/index.html index 26fd3968..effcc859 100644 --- a/ch4/os/sync/index.html +++ b/ch4/os/sync/index.html @@ -1,8 +1,10 @@ -os::sync - Rust +os::sync - Rust
-

Module os::sync

source · []

Re-exports

+

Module os::sync

source · []
Expand description

Synchronization and interior mutability primitives

+

Re-exports

pub use up::UPSafeCell;

Modules

-
+

Uniprocessor interior mutability primitives

+
\ No newline at end of file diff --git a/ch4/os/sync/sidebar-items.js b/ch4/os/sync/sidebar-items.js index 440fc425..09d6027e 100644 --- a/ch4/os/sync/sidebar-items.js +++ b/ch4/os/sync/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"mod":[["up",""]]}); \ No newline at end of file +initSidebarItems({"mod":[["up","Uniprocessor interior mutability primitives"]]}); \ No newline at end of file diff --git a/ch4/os/sync/up/index.html b/ch4/os/sync/up/index.html index 26f07349..4faef20d 100644 --- a/ch4/os/sync/up/index.html +++ b/ch4/os/sync/up/index.html @@ -1,8 +1,9 @@ -os::sync::up - Rust +os::sync::up - Rust
-

Module os::sync::up

source · []

Structs

+

Module os::sync::up

source · []
Expand description

Uniprocessor interior mutability primitives

+

Structs

Wrap a static data structure inside it so that we are able to access it without any unsafe.

diff --git a/ch4/os/sync/up/struct.UPSafeCell.html b/ch4/os/sync/up/struct.UPSafeCell.html index d29e93de..006b5c1b 100644 --- a/ch4/os/sync/up/struct.UPSafeCell.html +++ b/ch4/os/sync/up/struct.UPSafeCell.html @@ -2,7 +2,7 @@
-

Struct os::sync::up::UPSafeCell

source · []
pub struct UPSafeCell<T> {
+    

Struct os::sync::up::UPSafeCell

source · []
pub struct UPSafeCell<T> {
     inner: RefCell<T>,
 }
Expand description

Wrap a static data structure inside it so that we are able to access it without any unsafe.

@@ -10,10 +10,10 @@ able to access it without any unsafe.

In order to get mutable reference of inner data, call exclusive_access.

Fields

inner: RefCell<T>

inner data

-

Implementations

User is responsible to guarantee that inner struct is only used in +

Implementations

User is responsible to guarantee that inner struct is only used in uniprocessor.

-

Panic if the data has been borrowed.

-

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Exclusive access inner data in UPSafeCell. Panic if the data has been borrowed.

+

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/syscall/constant.SYSCALL_EXIT.html b/ch4/os/syscall/constant.SYSCALL_EXIT.html index 53cf68dc..a7ac151b 100644 --- a/ch4/os/syscall/constant.SYSCALL_EXIT.html +++ b/ch4/os/syscall/constant.SYSCALL_EXIT.html @@ -2,5 +2,5 @@
const SYSCALL_EXIT: usize = 93;
+

Constant os::syscall::SYSCALL_EXIT

source · []
const SYSCALL_EXIT: usize = 93;
\ No newline at end of file diff --git a/ch4/os/syscall/constant.SYSCALL_GET_TIME.html b/ch4/os/syscall/constant.SYSCALL_GET_TIME.html index 8214ed51..f068b52f 100644 --- a/ch4/os/syscall/constant.SYSCALL_GET_TIME.html +++ b/ch4/os/syscall/constant.SYSCALL_GET_TIME.html @@ -2,5 +2,5 @@
const SYSCALL_GET_TIME: usize = 169;
+

Constant os::syscall::SYSCALL_GET_TIME

source · []
const SYSCALL_GET_TIME: usize = 169;
\ No newline at end of file diff --git a/ch4/os/syscall/constant.SYSCALL_WRITE.html b/ch4/os/syscall/constant.SYSCALL_WRITE.html index a37aec89..608006c0 100644 --- a/ch4/os/syscall/constant.SYSCALL_WRITE.html +++ b/ch4/os/syscall/constant.SYSCALL_WRITE.html @@ -2,5 +2,5 @@
const SYSCALL_WRITE: usize = 64;
+

Constant os::syscall::SYSCALL_WRITE

source · []
const SYSCALL_WRITE: usize = 64;
\ No newline at end of file diff --git a/ch4/os/syscall/constant.SYSCALL_YIELD.html b/ch4/os/syscall/constant.SYSCALL_YIELD.html index 126073c7..4bfc058a 100644 --- a/ch4/os/syscall/constant.SYSCALL_YIELD.html +++ b/ch4/os/syscall/constant.SYSCALL_YIELD.html @@ -2,5 +2,5 @@
const SYSCALL_YIELD: usize = 124;
+

Constant os::syscall::SYSCALL_YIELD

source · []
const SYSCALL_YIELD: usize = 124;
\ No newline at end of file diff --git a/ch4/os/syscall/fn.syscall.html b/ch4/os/syscall/fn.syscall.html index fa81af61..42310bad 100644 --- a/ch4/os/syscall/fn.syscall.html +++ b/ch4/os/syscall/fn.syscall.html @@ -1,6 +1,7 @@ -syscall in os::syscall - Rust +syscall in os::syscall - Rust
-

Function os::syscall::syscall

source · []
pub fn syscall(syscall_id: usize, args: [usize; 3]) -> isize
+

Function os::syscall::syscall

source · []
pub fn syscall(syscall_id: usize, args: [usize; 3]) -> isize
Expand description

handle syscall exception with syscall_id and other arguments

+
\ No newline at end of file diff --git a/ch4/os/syscall/fs/constant.FD_STDOUT.html b/ch4/os/syscall/fs/constant.FD_STDOUT.html index 145553ff..acbdf2fc 100644 --- a/ch4/os/syscall/fs/constant.FD_STDOUT.html +++ b/ch4/os/syscall/fs/constant.FD_STDOUT.html @@ -2,5 +2,5 @@
-

Constant os::syscall::fs::FD_STDOUT

source · []
const FD_STDOUT: usize = 1;
+

Constant os::syscall::fs::FD_STDOUT

source · []
const FD_STDOUT: usize = 1;
\ No newline at end of file diff --git a/ch4/os/syscall/fs/fn.sys_write.html b/ch4/os/syscall/fs/fn.sys_write.html index 4be481c8..426a98a1 100644 --- a/ch4/os/syscall/fs/fn.sys_write.html +++ b/ch4/os/syscall/fs/fn.sys_write.html @@ -1,6 +1,7 @@ -sys_write in os::syscall::fs - Rust +sys_write in os::syscall::fs - Rust
-

Function os::syscall::fs::sys_write

source · []
pub fn sys_write(fd: usize, buf: *const u8, len: usize) -> isize
+

Function os::syscall::fs::sys_write

source · []
pub fn sys_write(fd: usize, buf: *const u8, len: usize) -> isize
Expand description

write buf of length len to a file with fd

+
\ No newline at end of file diff --git a/ch4/os/syscall/fs/index.html b/ch4/os/syscall/fs/index.html index bb59af00..5d281ce8 100644 --- a/ch4/os/syscall/fs/index.html +++ b/ch4/os/syscall/fs/index.html @@ -1,8 +1,10 @@ -os::syscall::fs - Rust +os::syscall::fs - Rust
-

Module os::syscall::fs

source · []

Constants

+

Module os::syscall::fs

source · []
Expand description

File and filesystem-related syscalls

+

Constants

Functions

-
+

write buf of length len to a file with fd

+
\ No newline at end of file diff --git a/ch4/os/syscall/fs/sidebar-items.js b/ch4/os/syscall/fs/sidebar-items.js index 002a1085..99a1dcdc 100644 --- a/ch4/os/syscall/fs/sidebar-items.js +++ b/ch4/os/syscall/fs/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"constant":[["FD_STDOUT",""]],"fn":[["sys_write",""]]}); \ No newline at end of file +initSidebarItems({"constant":[["FD_STDOUT",""]],"fn":[["sys_write","write buf of length `len` to a file with `fd`"]]}); \ No newline at end of file diff --git a/ch4/os/syscall/index.html b/ch4/os/syscall/index.html index 6c1090c8..34f1cf37 100644 --- a/ch4/os/syscall/index.html +++ b/ch4/os/syscall/index.html @@ -1,9 +1,21 @@ -os::syscall - Rust +os::syscall - Rust
Expand description

Implementation of syscalls

+

The single entry point to all system calls, syscall(), is called +whenever userspace wishes to perform a system call using the ecall +instruction. In this case, the processor raises an ‘Environment call from +U-mode’ exception, which is handled as one of the cases in +crate::trap::trap_handler.

+

For clarity, each single syscall is implemented as its own function, named +sys_ then the name of the syscall. You can find functions like this in +submodules, and you should also implement syscalls this way.

+

Modules

+

File and filesystem-related syscalls

+

Process management syscalls

+

Constants

Functions

-
+

handle syscall exception with syscall_id and other arguments

+
\ No newline at end of file diff --git a/ch4/os/syscall/process/fn.sys_exit.html b/ch4/os/syscall/process/fn.sys_exit.html index 91b19d4b..b84b4814 100644 --- a/ch4/os/syscall/process/fn.sys_exit.html +++ b/ch4/os/syscall/process/fn.sys_exit.html @@ -1,6 +1,7 @@ -sys_exit in os::syscall::process - Rust +sys_exit in os::syscall::process - Rust
pub fn sys_exit(exit_code: i32) -> !
+

Function os::syscall::process::sys_exit

source · []
pub fn sys_exit(exit_code: i32) -> !
Expand description

task exits and submit an exit code

+
\ No newline at end of file diff --git a/ch4/os/syscall/process/fn.sys_get_time.html b/ch4/os/syscall/process/fn.sys_get_time.html index 9f214279..d50c06bf 100644 --- a/ch4/os/syscall/process/fn.sys_get_time.html +++ b/ch4/os/syscall/process/fn.sys_get_time.html @@ -1,6 +1,7 @@ -sys_get_time in os::syscall::process - Rust +sys_get_time in os::syscall::process - Rust
pub fn sys_get_time() -> isize
+

Function os::syscall::process::sys_get_time

source · []
pub fn sys_get_time() -> isize
Expand description

get current time

+
\ No newline at end of file diff --git a/ch4/os/syscall/process/fn.sys_yield.html b/ch4/os/syscall/process/fn.sys_yield.html index ec29290a..f883a279 100644 --- a/ch4/os/syscall/process/fn.sys_yield.html +++ b/ch4/os/syscall/process/fn.sys_yield.html @@ -1,6 +1,7 @@ -sys_yield in os::syscall::process - Rust +sys_yield in os::syscall::process - Rust
pub fn sys_yield() -> isize
+

Function os::syscall::process::sys_yield

source · []
pub fn sys_yield() -> isize
Expand description

current task gives up resources for other tasks

+
\ No newline at end of file diff --git a/ch4/os/syscall/process/index.html b/ch4/os/syscall/process/index.html index dd2ddfda..c0b387a7 100644 --- a/ch4/os/syscall/process/index.html +++ b/ch4/os/syscall/process/index.html @@ -1,7 +1,11 @@ -os::syscall::process - Rust +os::syscall::process - Rust
+

Module os::syscall::process

source · []
Expand description

Process management syscalls

+

Functions

+

task exits and submit an exit code

+

get current time

+

current task gives up resources for other tasks

+
\ No newline at end of file diff --git a/ch4/os/syscall/process/sidebar-items.js b/ch4/os/syscall/process/sidebar-items.js index 66dd7d01..cb1e6ecd 100644 --- a/ch4/os/syscall/process/sidebar-items.js +++ b/ch4/os/syscall/process/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["sys_exit",""],["sys_get_time",""],["sys_yield",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["sys_exit","task exits and submit an exit code"],["sys_get_time","get current time "],["sys_yield","current task gives up resources for other tasks"]]}); \ No newline at end of file diff --git a/ch4/os/syscall/sidebar-items.js b/ch4/os/syscall/sidebar-items.js index 7341fda9..31dc0ea8 100644 --- a/ch4/os/syscall/sidebar-items.js +++ b/ch4/os/syscall/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"constant":[["SYSCALL_EXIT",""],["SYSCALL_GET_TIME",""],["SYSCALL_WRITE",""],["SYSCALL_YIELD",""]],"fn":[["syscall",""]],"mod":[["fs",""],["process",""]]}); \ No newline at end of file +initSidebarItems({"constant":[["SYSCALL_EXIT",""],["SYSCALL_GET_TIME",""],["SYSCALL_WRITE",""],["SYSCALL_YIELD",""]],"fn":[["syscall","handle syscall exception with `syscall_id` and other arguments"]],"mod":[["fs","File and filesystem-related syscalls"],["process","Process management syscalls"]]}); \ No newline at end of file diff --git a/ch4/os/task/context/index.html b/ch4/os/task/context/index.html index d9baf036..777a2e56 100644 --- a/ch4/os/task/context/index.html +++ b/ch4/os/task/context/index.html @@ -1,7 +1,9 @@ -os::task::context - Rust +os::task::context - Rust
+

Module os::task::context

source · []
Expand description

Implementation of TaskContext

+

Structs

+

task context structure containing some registers

+
\ No newline at end of file diff --git a/ch4/os/task/context/sidebar-items.js b/ch4/os/task/context/sidebar-items.js index 86a68385..c68c1891 100644 --- a/ch4/os/task/context/sidebar-items.js +++ b/ch4/os/task/context/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"struct":[["TaskContext",""]]}); \ No newline at end of file +initSidebarItems({"struct":[["TaskContext","task context structure containing some registers"]]}); \ No newline at end of file diff --git a/ch4/os/task/context/struct.TaskContext.html b/ch4/os/task/context/struct.TaskContext.html index 86c3149c..5a80dbdb 100644 --- a/ch4/os/task/context/struct.TaskContext.html +++ b/ch4/os/task/context/struct.TaskContext.html @@ -1,12 +1,18 @@ -TaskContext in os::task::context - Rust +TaskContext in os::task::context - Rust
#[repr(C)]
pub struct TaskContext { +

Struct os::task::context::TaskContext

source · []
#[repr(C)]
pub struct TaskContext { ra: usize, sp: usize, s: [usize; 12], -}

Fields

ra: usizesp: usizes: [usize; 12]

Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

task context structure containing some registers

+

Fields

ra: usize

return address ( e.g. __restore ) of __switch ASM function

+
sp: usize

kernel stack pointer of app

+
s: [usize; 12]

callee saved registers: s 0..11

+

Implementations

init task context

+

set Task Context{__restore ASM funciton: trap_return, sp: kstack_ptr, s: s_0..12}

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/task/fn.current_trap_cx.html b/ch4/os/task/fn.current_trap_cx.html index 541088f8..8f75802d 100644 --- a/ch4/os/task/fn.current_trap_cx.html +++ b/ch4/os/task/fn.current_trap_cx.html @@ -1,6 +1,7 @@ -current_trap_cx in os::task - Rust +current_trap_cx in os::task - Rust
pub fn current_trap_cx() -> &'static mut TrapContext
+

Function os::task::current_trap_cx

source · []
pub fn current_trap_cx() -> &'static mut TrapContext
Expand description

Get the current ‘Running’ task’s trap contexts.

+
\ No newline at end of file diff --git a/ch4/os/task/fn.current_user_token.html b/ch4/os/task/fn.current_user_token.html index d9162b2f..6d6d09f3 100644 --- a/ch4/os/task/fn.current_user_token.html +++ b/ch4/os/task/fn.current_user_token.html @@ -1,6 +1,7 @@ -current_user_token in os::task - Rust +current_user_token in os::task - Rust
pub fn current_user_token() -> usize
+

Function os::task::current_user_token

source · []
pub fn current_user_token() -> usize
Expand description

Get the current ‘Running’ task’s token.

+
\ No newline at end of file diff --git a/ch4/os/task/fn.exit_current_and_run_next.html b/ch4/os/task/fn.exit_current_and_run_next.html index f8c261ee..178ef6e9 100644 --- a/ch4/os/task/fn.exit_current_and_run_next.html +++ b/ch4/os/task/fn.exit_current_and_run_next.html @@ -1,6 +1,7 @@ -exit_current_and_run_next in os::task - Rust +exit_current_and_run_next in os::task - Rust
pub fn exit_current_and_run_next()
+

Function os::task::exit_current_and_run_next

source · []
pub fn exit_current_and_run_next()
Expand description

Exit the current ‘Running’ task and run the next task in task list.

+
\ No newline at end of file diff --git a/ch4/os/task/fn.mark_current_exited.html b/ch4/os/task/fn.mark_current_exited.html index ec059441..784d3445 100644 --- a/ch4/os/task/fn.mark_current_exited.html +++ b/ch4/os/task/fn.mark_current_exited.html @@ -1,6 +1,7 @@ -mark_current_exited in os::task - Rust +mark_current_exited in os::task - Rust
fn mark_current_exited()
+

Function os::task::mark_current_exited

source · []
fn mark_current_exited()
Expand description

Change the status of current Running task into Exited.

+
\ No newline at end of file diff --git a/ch4/os/task/fn.mark_current_suspended.html b/ch4/os/task/fn.mark_current_suspended.html index 5cb51ba8..eda6df26 100644 --- a/ch4/os/task/fn.mark_current_suspended.html +++ b/ch4/os/task/fn.mark_current_suspended.html @@ -1,6 +1,7 @@ -mark_current_suspended in os::task - Rust +mark_current_suspended in os::task - Rust
fn mark_current_suspended()
+

Function os::task::mark_current_suspended

source · []
fn mark_current_suspended()
Expand description

Change the status of current Running task into Ready.

+
\ No newline at end of file diff --git a/ch4/os/task/fn.run_first_task.html b/ch4/os/task/fn.run_first_task.html index cec4e4ef..6a642229 100644 --- a/ch4/os/task/fn.run_first_task.html +++ b/ch4/os/task/fn.run_first_task.html @@ -1,6 +1,7 @@ -run_first_task in os::task - Rust +run_first_task in os::task - Rust
pub fn run_first_task()
+

Function os::task::run_first_task

source · []
pub fn run_first_task()
Expand description

Run the first task in task list.

+
\ No newline at end of file diff --git a/ch4/os/task/fn.run_next_task.html b/ch4/os/task/fn.run_next_task.html index 9827dc72..bc4671ff 100644 --- a/ch4/os/task/fn.run_next_task.html +++ b/ch4/os/task/fn.run_next_task.html @@ -1,6 +1,8 @@ -run_next_task in os::task - Rust +run_next_task in os::task - Rust
-

Function os::task::run_next_task

source · []
fn run_next_task()
+

Function os::task::run_next_task

source · []
fn run_next_task()
Expand description

Switch current Running task to the task we have found, +or there is no Ready task and we can exit with all applications completed

+
\ No newline at end of file diff --git a/ch4/os/task/fn.suspend_current_and_run_next.html b/ch4/os/task/fn.suspend_current_and_run_next.html index 46c8386e..765bc8fd 100644 --- a/ch4/os/task/fn.suspend_current_and_run_next.html +++ b/ch4/os/task/fn.suspend_current_and_run_next.html @@ -1,6 +1,7 @@ -suspend_current_and_run_next in os::task - Rust +suspend_current_and_run_next in os::task - Rust
pub fn suspend_current_and_run_next()
+

Function os::task::suspend_current_and_run_next

source · []
pub fn suspend_current_and_run_next()
Expand description

Suspend the current ‘Running’ task and run the next task in task list.

+
\ No newline at end of file diff --git a/ch4/os/task/index.html b/ch4/os/task/index.html index 9893a06c..3f500aaa 100644 --- a/ch4/os/task/index.html +++ b/ch4/os/task/index.html @@ -1,10 +1,32 @@ -os::task - Rust +os::task - Rust
+

Module os::task

source · []
Expand description

Task management implementation

+

Everything about task management, like starting and switching tasks is +implemented here.

+

A single global instance of TaskManager called TASK_MANAGER controls +all the tasks in the operating system.

+

Be careful when you see __switch ASM function in switch.S. Control flow around this function +might not be what you expect.

+

Modules

+

Implementation of TaskContext

+

Rust wrapper around __switch.

+

Types related to task management

+

Structs

+

a TaskManager global instance through lazy_static!

+

task context structure containing some registers

+

The task manager, where all the tasks are managed.

+

The task manager inner in ‘UPSafeCell’

+

Functions

+

Get the current ‘Running’ task’s trap contexts.

+

Get the current ‘Running’ task’s token.

+

Exit the current ‘Running’ task and run the next task in task list.

+

Change the status of current Running task into Exited.

+

Change the status of current Running task into Ready.

+

Run the first task in task list.

+

Switch current Running task to the task we have found, +or there is no Ready task and we can exit with all applications completed

+

Suspend the current ‘Running’ task and run the next task in task list.

+
\ No newline at end of file diff --git a/ch4/os/task/sidebar-items.js b/ch4/os/task/sidebar-items.js index 4f7813ca..c6bcc072 100644 --- a/ch4/os/task/sidebar-items.js +++ b/ch4/os/task/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["current_trap_cx",""],["current_user_token",""],["exit_current_and_run_next",""],["mark_current_exited",""],["mark_current_suspended",""],["run_first_task",""],["run_next_task",""],["suspend_current_and_run_next",""]],"mod":[["context",""],["switch",""],["task",""]],"struct":[["TASK_MANAGER",""],["TaskManager",""],["TaskManagerInner",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["current_trap_cx","Get the current ‘Running’ task’s trap contexts."],["current_user_token","Get the current ‘Running’ task’s token."],["exit_current_and_run_next","Exit the current ‘Running’ task and run the next task in task list."],["mark_current_exited","Change the status of current `Running` task into `Exited`."],["mark_current_suspended","Change the status of current `Running` task into `Ready`."],["run_first_task","Run the first task in task list."],["run_next_task","Switch current `Running` task to the task we have found, or there is no `Ready` task and we can exit with all applications completed"],["suspend_current_and_run_next","Suspend the current ‘Running’ task and run the next task in task list."]],"mod":[["context","Implementation of [`TaskContext`]"],["switch","Rust wrapper around `__switch`."],["task","Types related to task management"]],"struct":[["TASK_MANAGER","a `TaskManager` global instance through lazy_static!"],["TaskContext","task context structure containing some registers"],["TaskManager","The task manager, where all the tasks are managed."],["TaskManagerInner","The task manager inner in ‘UPSafeCell’"]]}); \ No newline at end of file diff --git a/ch4/os/task/struct.TASK_MANAGER.html b/ch4/os/task/struct.TASK_MANAGER.html index 545b0179..c38ffd0e 100644 --- a/ch4/os/task/struct.TASK_MANAGER.html +++ b/ch4/os/task/struct.TASK_MANAGER.html @@ -1,12 +1,24 @@ -TASK_MANAGER in os::task - Rust +TASK_MANAGER in os::task - Rust
pub struct TASK_MANAGER {
+    

Struct os::task::TASK_MANAGER

source · []
pub struct TASK_MANAGER {
     __private_field: (),
-}

Fields

__private_field: ()

Methods from Deref<Target = TaskManager>

Trait Implementations

The resulting type after dereferencing.

-

Dereferences the value.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

a TaskManager global instance through lazy_static!

+

Fields

__private_field: ()

Methods from Deref<Target = TaskManager>

Run the first task in task list.

+

Generally, the first task in task list is an idle task (we call it zero process later). +But in ch4, we load apps statically, so the first task is a real app.

+

Change the status of current Running task into Ready.

+

Change the status of current Running task into Exited.

+

Find next task to run and return task id.

+

In this case, we only return the first Ready task in task list.

+

Get the current ‘Running’ task’s token.

+

Get the current ‘Running’ task’s trap contexts.

+

Switch current Running task to the task we have found, +or there is no Ready task and we can exit with all applications completed

+

Trait Implementations

The resulting type after dereferencing.

+

Dereferences the value.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/task/struct.TaskContext.html b/ch4/os/task/struct.TaskContext.html new file mode 100644 index 00000000..e9d772c1 --- /dev/null +++ b/ch4/os/task/struct.TaskContext.html @@ -0,0 +1,25 @@ +TaskContext in os::task - Rust +
#[repr(C)]
pub struct TaskContext { + ra: usize, + sp: usize, + s: [usize; 12], +}
Expand description

task context structure containing some registers

+

Fields

ra: usize

return address ( e.g. __restore ) of __switch ASM function

+
sp: usize

kernel stack pointer of app

+
s: [usize; 12]

callee saved registers: s 0..11

+

Implementations

init task context

+

set Task Context{__restore ASM funciton: trap_return, sp: kstack_ptr, s: s_0..12}

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Immutably borrows from an owned value. Read more

+

Mutably borrows from an owned value. Read more

+

Performs the conversion.

+

Performs the conversion.

+

The type returned in the event of a conversion error.

+

Performs the conversion.

+

The type returned in the event of a conversion error.

+

Performs the conversion.

+
+ \ No newline at end of file diff --git a/ch4/os/task/struct.TaskManager.html b/ch4/os/task/struct.TaskManager.html index e5c5d8f9..0d19927d 100644 --- a/ch4/os/task/struct.TaskManager.html +++ b/ch4/os/task/struct.TaskManager.html @@ -1,11 +1,31 @@ -TaskManager in os::task - Rust +TaskManager in os::task - Rust
pub struct TaskManager {
+    

Struct os::task::TaskManager

source · []
pub struct TaskManager {
     num_app: usize,
     inner: UPSafeCell<TaskManagerInner>,
-}

Fields

num_app: usizeinner: UPSafeCell<TaskManagerInner>

Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

The task manager, where all the tasks are managed.

+

Functions implemented on TaskManager deals with all task state transitions +and task context switching. For convenience, you can find wrappers around it +in the module level.

+

Most of TaskManager are hidden behind the field inner, to defer +borrowing checks to runtime. You can see examples on how to use inner in +existing functions on TaskManager.

+

Fields

num_app: usize

total number of tasks

+
inner: UPSafeCell<TaskManagerInner>

use inner value to get mutable access

+

Implementations

Run the first task in task list.

+

Generally, the first task in task list is an idle task (we call it zero process later). +But in ch4, we load apps statically, so the first task is a real app.

+

Change the status of current Running task into Ready.

+

Change the status of current Running task into Exited.

+

Find next task to run and return task id.

+

In this case, we only return the first Ready task in task list.

+

Get the current ‘Running’ task’s token.

+

Get the current ‘Running’ task’s trap contexts.

+

Switch current Running task to the task we have found, +or there is no Ready task and we can exit with all applications completed

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/task/struct.TaskManagerInner.html b/ch4/os/task/struct.TaskManagerInner.html index 3d3db42d..c9323243 100644 --- a/ch4/os/task/struct.TaskManagerInner.html +++ b/ch4/os/task/struct.TaskManagerInner.html @@ -1,11 +1,14 @@ -TaskManagerInner in os::task - Rust +TaskManagerInner in os::task - Rust
struct TaskManagerInner {
+    

Struct os::task::TaskManagerInner

source · []
struct TaskManagerInner {
     tasks: Vec<TaskControlBlock>,
     current_task: usize,
-}

Fields

tasks: Vec<TaskControlBlock>current_task: usize

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

The task manager inner in ‘UPSafeCell’

+

Fields

tasks: Vec<TaskControlBlock>

task list

+
current_task: usize

id of current Running task

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/task/switch/fn.__switch.html b/ch4/os/task/switch/fn.__switch.html index 7d5e620d..0ce4ae3a 100644 --- a/ch4/os/task/switch/fn.__switch.html +++ b/ch4/os/task/switch/fn.__switch.html @@ -1,6 +1,8 @@ -__switch in os::task::switch - Rust +__switch in os::task::switch - Rust
-

Function os::task::switch::__switch

source · []
pub unsafe extern "C" fn __switch(
    current_task_cx_ptr: *mut TaskContext,
    next_task_cx_ptr: *const TaskContext
)
+

Function os::task::switch::__switch

source · []
pub unsafe extern "C" fn __switch(
    current_task_cx_ptr: *mut TaskContext,
    next_task_cx_ptr: *const TaskContext
)
Expand description

Switch to the context of next_task_cx_ptr, saving the current context +in current_task_cx_ptr.

+
\ No newline at end of file diff --git a/ch4/os/task/switch/index.html b/ch4/os/task/switch/index.html index c7c3e27b..6f4109e5 100644 --- a/ch4/os/task/switch/index.html +++ b/ch4/os/task/switch/index.html @@ -1,7 +1,14 @@ -os::task::switch - Rust +os::task::switch - Rust
+

Module os::task::switch

source · []
Expand description

Rust wrapper around __switch.

+

Switching to a different task’s context happens here. The actual +implementation must not be in Rust and (essentially) has to be in assembly +language (Do you know why?), so this module really is just a wrapper around +switch.S.

+

Functions

+

Switch to the context of next_task_cx_ptr, saving the current context +in current_task_cx_ptr.

+
\ No newline at end of file diff --git a/ch4/os/task/switch/sidebar-items.js b/ch4/os/task/switch/sidebar-items.js index 59e64029..e12d73ff 100644 --- a/ch4/os/task/switch/sidebar-items.js +++ b/ch4/os/task/switch/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["__switch",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["__switch","Switch to the context of `next_task_cx_ptr`, saving the current context in `current_task_cx_ptr`."]]}); \ No newline at end of file diff --git a/ch4/os/task/task/enum.TaskStatus.html b/ch4/os/task/task/enum.TaskStatus.html index 4a8825f3..859cf9c7 100644 --- a/ch4/os/task/task/enum.TaskStatus.html +++ b/ch4/os/task/task/enum.TaskStatus.html @@ -1,17 +1,18 @@ -TaskStatus in os::task::task - Rust +TaskStatus in os::task::task - Rust
pub enum TaskStatus {
+    

Enum os::task::task::TaskStatus

source · []
pub enum TaskStatus {
     Ready,
     Running,
     Exited,
-}

Variants

Ready

Running

Exited

Trait Implementations

Returns a copy of the value. Read more

+}
Expand description

task status: UnInit, Ready, Running, Exited

+

Variants

Ready

Running

Exited

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/task/task/index.html b/ch4/os/task/task/index.html index b5128a44..b68dbf7b 100644 --- a/ch4/os/task/task/index.html +++ b/ch4/os/task/task/index.html @@ -1,8 +1,11 @@ -os::task::task - Rust +os::task::task - Rust
+

Module os::task::task

source · []
Expand description

Types related to task management

+

Structs

+

task control block structure

+

Enums

+

task status: UnInit, Ready, Running, Exited

+
\ No newline at end of file diff --git a/ch4/os/task/task/sidebar-items.js b/ch4/os/task/task/sidebar-items.js index ffc06192..369a3801 100644 --- a/ch4/os/task/task/sidebar-items.js +++ b/ch4/os/task/task/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"enum":[["TaskStatus",""]],"struct":[["TaskControlBlock",""]]}); \ No newline at end of file +initSidebarItems({"enum":[["TaskStatus","task status: UnInit, Ready, Running, Exited"]],"struct":[["TaskControlBlock","task control block structure"]]}); \ No newline at end of file diff --git a/ch4/os/task/task/struct.TaskControlBlock.html b/ch4/os/task/task/struct.TaskControlBlock.html index 0051029b..20d79d93 100644 --- a/ch4/os/task/task/struct.TaskControlBlock.html +++ b/ch4/os/task/task/struct.TaskControlBlock.html @@ -1,14 +1,15 @@ -TaskControlBlock in os::task::task - Rust +TaskControlBlock in os::task::task - Rust
pub struct TaskControlBlock {
+    

Struct os::task::task::TaskControlBlock

source · []
pub struct TaskControlBlock {
     pub task_status: TaskStatus,
     pub task_cx: TaskContext,
     pub memory_set: MemorySet,
     pub trap_cx_ppn: PhysPageNum,
     pub base_size: usize,
-}

Fields

task_status: TaskStatustask_cx: TaskContextmemory_set: MemorySettrap_cx_ppn: PhysPageNumbase_size: usize

Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

task control block structure

+

Fields

task_status: TaskStatustask_cx: TaskContextmemory_set: MemorySettrap_cx_ppn: PhysPageNumbase_size: usize

Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/timer/constant.MSEC_PER_SEC.html b/ch4/os/timer/constant.MSEC_PER_SEC.html index 0ac83405..af551c7d 100644 --- a/ch4/os/timer/constant.MSEC_PER_SEC.html +++ b/ch4/os/timer/constant.MSEC_PER_SEC.html @@ -2,5 +2,5 @@
-

Constant os::timer::MSEC_PER_SEC

source · []
const MSEC_PER_SEC: usize = 1000;
+

Constant os::timer::MSEC_PER_SEC

source · []
const MSEC_PER_SEC: usize = 1000;
\ No newline at end of file diff --git a/ch4/os/timer/constant.TICKS_PER_SEC.html b/ch4/os/timer/constant.TICKS_PER_SEC.html index 22a5816d..42b136ef 100644 --- a/ch4/os/timer/constant.TICKS_PER_SEC.html +++ b/ch4/os/timer/constant.TICKS_PER_SEC.html @@ -2,5 +2,5 @@
const TICKS_PER_SEC: usize = 100;
+

Constant os::timer::TICKS_PER_SEC

source · []
const TICKS_PER_SEC: usize = 100;
\ No newline at end of file diff --git a/ch4/os/timer/fn.get_time.html b/ch4/os/timer/fn.get_time.html index 2950e5cb..ef71dfd0 100644 --- a/ch4/os/timer/fn.get_time.html +++ b/ch4/os/timer/fn.get_time.html @@ -2,5 +2,5 @@
-

Function os::timer::get_time

source · []
pub fn get_time() -> usize
+

Function os::timer::get_time

source · []
pub fn get_time() -> usize
\ No newline at end of file diff --git a/ch4/os/timer/fn.get_time_ms.html b/ch4/os/timer/fn.get_time_ms.html index 8fa89c86..94f045cd 100644 --- a/ch4/os/timer/fn.get_time_ms.html +++ b/ch4/os/timer/fn.get_time_ms.html @@ -1,6 +1,7 @@ -get_time_ms in os::timer - Rust +get_time_ms in os::timer - Rust
-

Function os::timer::get_time_ms

source · []
pub fn get_time_ms() -> usize
+

Function os::timer::get_time_ms

source · []
pub fn get_time_ms() -> usize
Expand description

get current time in microseconds

+
\ No newline at end of file diff --git a/ch4/os/timer/fn.set_next_trigger.html b/ch4/os/timer/fn.set_next_trigger.html index 25cfe55f..8a80d195 100644 --- a/ch4/os/timer/fn.set_next_trigger.html +++ b/ch4/os/timer/fn.set_next_trigger.html @@ -1,6 +1,7 @@ -set_next_trigger in os::timer - Rust +set_next_trigger in os::timer - Rust
pub fn set_next_trigger()
+

Function os::timer::set_next_trigger

source · []
pub fn set_next_trigger()
Expand description

set the next timer interrupt

+
\ No newline at end of file diff --git a/ch4/os/timer/index.html b/ch4/os/timer/index.html index 80e7f056..a1b9b16b 100644 --- a/ch4/os/timer/index.html +++ b/ch4/os/timer/index.html @@ -1,8 +1,11 @@ -os::timer - Rust +os::timer - Rust
-

Module os::timer

source · []

Constants

+

Module os::timer

source · []
Expand description

RISC-V timer-related functionality

+

Constants

Functions

-
+

get current time in microseconds

+

set the next timer interrupt

+
\ No newline at end of file diff --git a/ch4/os/timer/sidebar-items.js b/ch4/os/timer/sidebar-items.js index afc78589..a66b0248 100644 --- a/ch4/os/timer/sidebar-items.js +++ b/ch4/os/timer/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"constant":[["MSEC_PER_SEC",""],["TICKS_PER_SEC",""]],"fn":[["get_time",""],["get_time_ms",""],["set_next_trigger",""]]}); \ No newline at end of file +initSidebarItems({"constant":[["MSEC_PER_SEC",""],["TICKS_PER_SEC",""]],"fn":[["get_time",""],["get_time_ms","get current time in microseconds"],["set_next_trigger","set the next timer interrupt"]]}); \ No newline at end of file diff --git a/ch4/os/trap/context/index.html b/ch4/os/trap/context/index.html index 75679a40..c5bd65b4 100644 --- a/ch4/os/trap/context/index.html +++ b/ch4/os/trap/context/index.html @@ -1,7 +1,9 @@ -os::trap::context - Rust +os::trap::context - Rust
+

Module os::trap::context

source · []
Expand description

Implementation of TrapContext

+

Structs

+

trap context structure containing sstatus, sepc and registers

+
\ No newline at end of file diff --git a/ch4/os/trap/context/sidebar-items.js b/ch4/os/trap/context/sidebar-items.js index d7c5bfe2..3f97d83e 100644 --- a/ch4/os/trap/context/sidebar-items.js +++ b/ch4/os/trap/context/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"struct":[["TrapContext",""]]}); \ No newline at end of file +initSidebarItems({"struct":[["TrapContext","trap context structure containing sstatus, sepc and registers"]]}); \ No newline at end of file diff --git a/ch4/os/trap/context/struct.TrapContext.html b/ch4/os/trap/context/struct.TrapContext.html index 19afbe81..1ac25746 100644 --- a/ch4/os/trap/context/struct.TrapContext.html +++ b/ch4/os/trap/context/struct.TrapContext.html @@ -1,15 +1,24 @@ -TrapContext in os::trap::context - Rust +TrapContext in os::trap::context - Rust
#[repr(C)]
pub struct TrapContext { +

Struct os::trap::context::TrapContext

source · []
#[repr(C)]
pub struct TrapContext { pub x: [usize; 32], pub sstatus: Sstatus, pub sepc: usize, pub kernel_satp: usize, pub kernel_sp: usize, pub trap_handler: usize, -}

Fields

x: [usize; 32]sstatus: Sstatussepc: usizekernel_satp: usizekernel_sp: usizetrap_handler: usize

Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+}
Expand description

trap context structure containing sstatus, sepc and registers

+

Fields

x: [usize; 32]

general regs[0..31]

+
sstatus: Sstatus

CSR sstatus

+
sepc: usize

CSR sepc

+
kernel_satp: usize

Addr of Page Table

+
kernel_sp: usize

kernel stack

+
trap_handler: usize

Addr of trap_handler function

+

Implementations

set stack pointer to x_2 reg (sp)

+

init app context

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/ch4/os/trap/fn.enable_timer_interrupt.html b/ch4/os/trap/fn.enable_timer_interrupt.html index 4483d3a4..2565e7a6 100644 --- a/ch4/os/trap/fn.enable_timer_interrupt.html +++ b/ch4/os/trap/fn.enable_timer_interrupt.html @@ -1,6 +1,7 @@ -enable_timer_interrupt in os::trap - Rust +enable_timer_interrupt in os::trap - Rust
pub fn enable_timer_interrupt()
+

Function os::trap::enable_timer_interrupt

source · []
pub fn enable_timer_interrupt()
Expand description

enable timer interrupt in sie CSR

+
\ No newline at end of file diff --git a/ch4/os/trap/fn.init.html b/ch4/os/trap/fn.init.html index 327eb15c..d6bf1957 100644 --- a/ch4/os/trap/fn.init.html +++ b/ch4/os/trap/fn.init.html @@ -1,6 +1,7 @@ -init in os::trap - Rust +init in os::trap - Rust
-

Function os::trap::init

source · []
pub fn init()
+

Function os::trap::init

source · []
pub fn init()
Expand description

initialize CSR stvec as the entry of __alltraps

+
\ No newline at end of file diff --git a/ch4/os/trap/fn.set_kernel_trap_entry.html b/ch4/os/trap/fn.set_kernel_trap_entry.html index 93082392..fda98ef4 100644 --- a/ch4/os/trap/fn.set_kernel_trap_entry.html +++ b/ch4/os/trap/fn.set_kernel_trap_entry.html @@ -2,5 +2,5 @@
fn set_kernel_trap_entry()
+

Function os::trap::set_kernel_trap_entry

source · []
fn set_kernel_trap_entry()
\ No newline at end of file diff --git a/ch4/os/trap/fn.set_user_trap_entry.html b/ch4/os/trap/fn.set_user_trap_entry.html index cd004a20..8f0c1ce7 100644 --- a/ch4/os/trap/fn.set_user_trap_entry.html +++ b/ch4/os/trap/fn.set_user_trap_entry.html @@ -2,5 +2,5 @@
fn set_user_trap_entry()
+

Function os::trap::set_user_trap_entry

source · []
fn set_user_trap_entry()
\ No newline at end of file diff --git a/ch4/os/trap/fn.trap_from_kernel.html b/ch4/os/trap/fn.trap_from_kernel.html index 045ba4bc..ef68cb6c 100644 --- a/ch4/os/trap/fn.trap_from_kernel.html +++ b/ch4/os/trap/fn.trap_from_kernel.html @@ -1,7 +1,9 @@ -trap_from_kernel in os::trap - Rust +trap_from_kernel in os::trap - Rust
#[no_mangle]
-pub fn trap_from_kernel() -> !
+

Function os::trap::trap_from_kernel

source · []
#[no_mangle]
+pub fn trap_from_kernel() -> !
Expand description

Unimplement: traps/interrupts/exceptions from kernel mode +Todo: Chapter 9: I/O device

+
\ No newline at end of file diff --git a/ch4/os/trap/fn.trap_handler.html b/ch4/os/trap/fn.trap_handler.html index 68a773f7..d55c09b6 100644 --- a/ch4/os/trap/fn.trap_handler.html +++ b/ch4/os/trap/fn.trap_handler.html @@ -1,7 +1,8 @@ -trap_handler in os::trap - Rust +trap_handler in os::trap - Rust
-

Function os::trap::trap_handler

source · []
#[no_mangle]
-pub fn trap_handler() -> !
+

Function os::trap::trap_handler

source · []
#[no_mangle]
+pub fn trap_handler() -> !
Expand description

handle an interrupt, exception, or system call from user space

+
\ No newline at end of file diff --git a/ch4/os/trap/fn.trap_return.html b/ch4/os/trap/fn.trap_return.html index 777ba42d..baf9f2a6 100644 --- a/ch4/os/trap/fn.trap_return.html +++ b/ch4/os/trap/fn.trap_return.html @@ -1,7 +1,10 @@ -trap_return in os::trap - Rust +trap_return in os::trap - Rust
-

Function os::trap::trap_return

source · []
#[no_mangle]
-pub fn trap_return() -> !
+

Function os::trap::trap_return

source · []
#[no_mangle]
+pub fn trap_return() -> !
Expand description

set the new addr of __restore asm function in TRAMPOLINE page, +set the reg a0 = trap_cx_ptr, reg a1 = phy addr of usr page table, +finally, jump to new addr of __restore asm function

+
\ No newline at end of file diff --git a/ch4/os/trap/index.html b/ch4/os/trap/index.html index 45624582..adbfe267 100644 --- a/ch4/os/trap/index.html +++ b/ch4/os/trap/index.html @@ -1,9 +1,29 @@ -os::trap - Rust +os::trap - Rust
Expand description

Trap handling functionality

+

For rCore, we have a single trap entry point, namely __alltraps. At +initialization in init(), we set the stvec CSR to point to it.

+

All traps go through __alltraps, which is defined in trap.S. The +assembly language code does just enough work restore the kernel space +context, ensuring that Rust code safely runs, and transfers control to +trap_handler().

+

It then calls different functionality based on what exactly the exception +was. For example, timer interrupts trigger task preemption, and syscalls go +to syscall().

+

Modules

+

Implementation of TrapContext

+

Structs

+

trap context structure containing sstatus, sepc and registers

+

Functions

+

enable timer interrupt in sie CSR

+

initialize CSR stvec as the entry of __alltraps

+

Unimplement: traps/interrupts/exceptions from kernel mode +Todo: Chapter 9: I/O device

+

handle an interrupt, exception, or system call from user space

+

set the new addr of __restore asm function in TRAMPOLINE page, +set the reg a0 = trap_cx_ptr, reg a1 = phy addr of usr page table, +finally, jump to new addr of __restore asm function

+
\ No newline at end of file diff --git a/ch4/os/trap/sidebar-items.js b/ch4/os/trap/sidebar-items.js index b976c179..a379917d 100644 --- a/ch4/os/trap/sidebar-items.js +++ b/ch4/os/trap/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["enable_timer_interrupt",""],["init",""],["set_kernel_trap_entry",""],["set_user_trap_entry",""],["trap_from_kernel",""],["trap_handler",""],["trap_return",""]],"mod":[["context",""]]}); \ No newline at end of file +initSidebarItems({"fn":[["enable_timer_interrupt","enable timer interrupt in sie CSR"],["init","initialize CSR `stvec` as the entry of `__alltraps`"],["set_kernel_trap_entry",""],["set_user_trap_entry",""],["trap_from_kernel","Unimplement: traps/interrupts/exceptions from kernel mode Todo: Chapter 9: I/O device "],["trap_handler","handle an interrupt, exception, or system call from user space"],["trap_return","set the new addr of __restore asm function in TRAMPOLINE page, set the reg a0 = trap_cx_ptr, reg a1 = phy addr of usr page table, finally, jump to new addr of __restore asm function"]],"mod":[["context","Implementation of [`TrapContext`]"]],"struct":[["TrapContext","trap context structure containing sstatus, sepc and registers"]]}); \ No newline at end of file diff --git a/ch4/os/trap/struct.TrapContext.html b/ch4/os/trap/struct.TrapContext.html new file mode 100644 index 00000000..f0f0b2b4 --- /dev/null +++ b/ch4/os/trap/struct.TrapContext.html @@ -0,0 +1,31 @@ +TrapContext in os::trap - Rust +
#[repr(C)]
pub struct TrapContext { + pub x: [usize; 32], + pub sstatus: Sstatus, + pub sepc: usize, + pub kernel_satp: usize, + pub kernel_sp: usize, + pub trap_handler: usize, +}
Expand description

trap context structure containing sstatus, sepc and registers

+

Fields

x: [usize; 32]

general regs[0..31]

+
sstatus: Sstatus

CSR sstatus

+
sepc: usize

CSR sepc

+
kernel_satp: usize

Addr of Page Table

+
kernel_sp: usize

kernel stack

+
trap_handler: usize

Addr of trap_handler function

+

Implementations

set stack pointer to x_2 reg (sp)

+

init app context

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Immutably borrows from an owned value. Read more

+

Mutably borrows from an owned value. Read more

+

Performs the conversion.

+

Performs the conversion.

+

The type returned in the event of a conversion error.

+

Performs the conversion.

+

The type returned in the event of a conversion error.

+

Performs the conversion.

+
+ \ No newline at end of file diff --git a/ch4/search-index.js b/ch4/search-index.js index fb4a57b8..5ccc4547 100644 --- a/ch4/search-index.js +++ b/ch4/search-index.js @@ -1,4 +1,4 @@ var searchIndex = JSON.parse('{\ -"os":{"doc":"","t":[0,5,0,0,0,0,0,14,14,5,0,0,0,0,0,0,17,17,17,17,17,17,17,17,17,5,3,11,11,11,11,5,11,11,11,11,5,5,5,0,0,0,5,0,0,12,12,12,12,17,17,3,3,3,3,8,17,6,17,3,3,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,11,11,11,11,11,11,11,11,11,11,11,11,12,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,3,8,6,3,3,12,10,11,11,11,11,11,11,11,12,10,11,11,11,12,11,5,5,5,11,11,11,11,5,11,11,11,10,11,11,12,12,11,11,11,11,11,11,11,11,11,7,7,5,5,5,13,13,3,3,3,4,3,18,18,18,18,12,11,11,12,11,11,11,11,11,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,11,5,5,5,11,11,11,5,5,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,12,11,11,11,11,11,12,11,11,5,11,5,5,11,5,5,5,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,18,18,18,3,3,3,18,18,18,18,18,11,11,11,11,11,11,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,11,11,11,11,11,11,11,11,5,11,11,11,11,11,11,11,11,11,11,11,11,17,17,17,17,17,17,17,17,17,5,5,5,5,5,0,3,11,11,11,11,12,11,11,11,11,11,17,17,17,17,0,0,5,17,5,5,5,5,3,3,3,12,11,11,11,11,11,11,0,12,5,5,11,5,11,11,11,11,11,11,12,11,11,11,5,11,5,11,12,5,11,5,11,5,0,0,12,11,11,11,11,11,11,11,11,11,3,11,11,11,11,11,12,12,12,11,11,11,11,5,13,13,13,3,4,12,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,12,12,11,12,11,11,11,11,11,11,17,17,5,5,5,0,5,5,5,5,5,5,5,3,11,11,11,11,11,12,12,12,11,12,12,11,11,11,12],"n":["board","clear_bss","config","console","lang_items","loader","mm","print","println","rust_main","sbi","sync","syscall","task","timer","trap","CLOCK_FREQ","KERNEL_HEAP_SIZE","KERNEL_STACK_SIZE","MEMORY_END","PAGE_SIZE","PAGE_SIZE_BITS","TRAMPOLINE","TRAP_CONTEXT","USER_STACK_SIZE","kernel_stack_position","Stdout","borrow","borrow_mut","from","into","print","try_from","try_into","type_id","write_str","panic","get_app_data","get_num_app","address","frame_allocator","heap_allocator","init","memory_set","page_table","0","0","0","0","PA_WIDTH_SV39","PPN_WIDTH_SV39","PhysAddr","PhysPageNum","SimpleRange","SimpleRangeIterator","StepByOne","VA_WIDTH_SV39","VPNRange","VPN_WIDTH_SV39","VirtAddr","VirtPageNum","aligned","aligned","borrow","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","ceil","ceil","clone","clone","clone","clone","clone","clone_into","clone_into","clone_into","clone_into","clone_into","cmp","cmp","cmp","cmp","current","end","eq","eq","eq","eq","floor","floor","fmt","fmt","fmt","fmt","from","from","from","from","from","from","from","from","from","from","from","from","from","from","get_bytes_array","get_end","get_mut","get_pte_array","get_start","indexes","into","into","into","into","into","into","into_iter","into_iter","l","ne","ne","ne","ne","new","new","next","page_offset","page_offset","partial_cmp","partial_cmp","partial_cmp","partial_cmp","r","step","step","to_owned","to_owned","to_owned","to_owned","to_owned","try_from","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","type_id","FRAME_ALLOCATOR","FrameAllocator","FrameAllocatorImpl","FrameTracker","StackFrameAllocator","__private_field","alloc","alloc","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","current","dealloc","dealloc","deref","drop","end","fmt","frame_alloc","frame_allocator_test","frame_dealloc","from","from","from","init","init_frame_allocator","into","into","into","new","new","new","ppn","recycled","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id","HEAP_ALLOCATOR","HEAP_SPACE","handle_alloc_error","heap_test","init_heap","Framed","Identical","KERNEL_SPACE","MapArea","MapPermission","MapType","MemorySet","R","U","W","X","__private_field","activate","all","areas","bitand","bitand_assign","bitor","bitor_assign","bits","bits","bitxor","bitxor_assign","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","clone","clone","clone_into","clone_into","cmp","complement","contains","copy_data","data_frames","deref","difference","ebss","edata","ekernel","empty","eq","eq","erodata","etext","extend","fmt","fmt","fmt","fmt","fmt","fmt","from","from","from","from","from","from_bits","from_bits_truncate","from_bits_unchecked","from_elf","from_iter","hash","insert","insert_framed_area","intersection","intersects","into","into","into","into","into","is_all","is_empty","map","map_one","map_perm","map_trampoline","map_type","ne","new","new_bare","new_kernel","not","page_table","partial_cmp","push","remap_test","remove","sbss_with_stack","sdata","set","srodata","stext","strampoline","sub","sub_assign","symmetric_difference","to_owned","to_owned","toggle","token","translate","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","union","unmap","unmap_one","vpn_range","A","D","G","PTEFlags","PageTable","PageTableEntry","R","U","V","W","X","all","bitand","bitand_assign","bitor","bitor_assign","bits","bits","bits","bitxor","bitxor_assign","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","clone","clone","clone_into","clone_into","cmp","complement","contains","difference","empty","empty","eq","executable","extend","find_pte","find_pte_create","flags","fmt","fmt","fmt","fmt","fmt","frames","from","from","from","from_bits","from_bits_truncate","from_bits_unchecked","from_iter","from_token","hash","insert","intersection","intersects","into","into","into","is_all","is_empty","is_valid","map","ne","new","new","not","partial_cmp","ppn","readable","remove","root_ppn","set","sub","sub_assign","symmetric_difference","to_owned","to_owned","toggle","token","translate","translated_byte_buffer","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id","union","unmap","writable","SBI_CLEAR_IPI","SBI_CONSOLE_GETCHAR","SBI_CONSOLE_PUTCHAR","SBI_REMOTE_FENCE_I","SBI_REMOTE_SFENCE_VMA","SBI_REMOTE_SFENCE_VMA_ASID","SBI_SEND_IPI","SBI_SET_TIMER","SBI_SHUTDOWN","console_getchar","console_putchar","sbi_call","set_timer","shutdown","up","UPSafeCell","borrow","borrow_mut","exclusive_access","from","inner","into","new","try_from","try_into","type_id","SYSCALL_EXIT","SYSCALL_GET_TIME","SYSCALL_WRITE","SYSCALL_YIELD","fs","process","syscall","FD_STDOUT","sys_write","sys_exit","sys_get_time","sys_yield","TASK_MANAGER","TaskManager","TaskManagerInner","__private_field","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","context","current_task","current_trap_cx","current_user_token","deref","exit_current_and_run_next","find_next_task","from","from","from","get_current_token","get_current_trap_cx","inner","into","into","into","mark_current_exited","mark_current_exited","mark_current_suspended","mark_current_suspended","num_app","run_first_task","run_first_task","run_next_task","run_next_task","suspend_current_and_run_next","switch","task","tasks","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id","TaskContext","borrow","borrow_mut","from","goto_trap_return","into","ra","s","sp","try_from","try_into","type_id","zero_init","__switch","Exited","Ready","Running","TaskControlBlock","TaskStatus","base_size","borrow","borrow","borrow_mut","borrow_mut","clone","clone_into","eq","from","from","get_trap_cx","get_user_token","into","into","memory_set","new","task_cx","task_status","to_owned","trap_cx_ppn","try_from","try_from","try_into","try_into","type_id","type_id","MSEC_PER_SEC","TICKS_PER_SEC","get_time","get_time_ms","set_next_trigger","context","enable_timer_interrupt","init","set_kernel_trap_entry","set_user_trap_entry","trap_from_kernel","trap_handler","trap_return","TrapContext","app_init_context","borrow","borrow_mut","from","into","kernel_satp","kernel_sp","sepc","set_sp","sstatus","trap_handler","try_from","try_into","type_id","x"],"q":["os","","","","","","","","","","","","","","","","os::board","os::config","","","","","","","","","os::console","","","","","","","","","","os::lang_items","os::loader","","os::mm","","","","","","os::mm::address","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::mm::frame_allocator","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::mm::heap_allocator","","","","","os::mm::memory_set","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::mm::page_table","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::sbi","","","","","","","","","","","","","","os::sync","os::sync::up","","","","","","","","","","","os::syscall","","","","","","","os::syscall::fs","","os::syscall::process","","","os::task","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::task::context","","","","","","","","","","","","","os::task::switch","os::task::task","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::timer","","","","","os::trap","","","","","","","","os::trap::context","","","","","","","","","","","","","","",""],"d":["","","","","","","","","","","","","","","","","","","","","","","","","","Return (bottom, top) of a kernel stack in kernel space.","","","","","","","","","","","","","","","","","","","","","","","","","","Definitions","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","Returns the set containing all flags.","","Returns the intersection between the two sets of flags.","Disables all flags disabled in the set.","Returns the union of the two sets of flags.","Adds the set of flags.","Returns the raw value of the flags currently stored.","","Returns the left flags, but with all the right flags …","Toggles the set of flags.","","","","","","","","","","","","","","","","Returns the complement of this set of flags.","Returns true if all of the flags in other are contained …","data: start-aligned but maybe with shorter length assume …","","","Returns the difference between the flags in self and other.","","","","Returns an empty set of flags.","","","","","","","","","","","","","","","","","Convert from underlying bit representation, unless that …","Convert from underlying bit representation, dropping any …","Convert from underlying bit representation, preserving all …","Include sections in elf and trampoline and TrapContext and …","","","Inserts the specified flags in-place.","Assume that no conflicts.","Returns the intersection between the flags in self and …","Returns true if there are flags common to both self and …","","","","","","Returns true if all flags are currently set.","Returns true if no flags are currently stored.","","","","Mention that trampoline is not collected by areas.","","","","","Without kernel stacks.","Returns the complement of this set of flags.","","","","","Removes the specified flags in-place.","","","Inserts or removes the specified flags depending on the …","","","","Returns the set difference of the two sets of flags.","Disables all flags enabled in the set.","Returns the symmetric difference between the flags in self …","","","Toggles the specified flags in-place.","","","","","","","","","","","","","","","","","","Returns the union of between the flags in self and other.","","","","","","","","","","","","","","","Returns the set containing all flags.","Returns the intersection between the two sets of flags.","Disables all flags disabled in the set.","Returns the union of the two sets of flags.","Adds the set of flags.","Returns the raw value of the flags currently stored.","","","Returns the left flags, but with all the right flags …","Toggles the set of flags.","","","","","","","","","","","","Returns the complement of this set of flags.","Returns true if all of the flags in other are contained …","Returns the difference between the flags in self and other.","Returns an empty set of flags.","","","","","","","","","","","","","","","","","Convert from underlying bit representation, unless that …","Convert from underlying bit representation, dropping any …","Convert from underlying bit representation, preserving all …","","Temporarily used to get arguments from user space.","","Inserts the specified flags in-place.","Returns the intersection between the flags in self and …","Returns true if there are flags common to both self and …","","","","Returns true if all flags are currently set.","Returns true if no flags are currently stored.","","","","","","Returns the complement of this set of flags.","","","","Removes the specified flags in-place.","","Inserts or removes the specified flags depending on the …","Returns the set difference of the two sets of flags.","Disables all flags enabled in the set.","Returns the symmetric difference between the flags in self …","","","Toggles the specified flags in-place.","","","","","","","","","","","","","Returns the union of between the flags in self and other.","","","","","","","","","","","","","","","","","","Wrap a static data structure inside it so that we are able …","","","Panic if the data has been borrowed.","","inner data","","User is responsible to guarantee that inner struct is only …","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,2,3,4,5,0,0,0,0,0,0,0,0,0,0,0,0,2,3,6,2,3,4,5,7,6,2,3,4,5,7,2,3,2,3,4,5,7,2,3,4,5,7,2,3,4,5,6,6,2,3,4,5,2,3,2,3,4,5,6,2,2,2,3,3,3,4,4,4,5,5,5,7,4,7,4,4,7,5,6,2,3,4,5,7,6,7,7,2,3,4,5,6,7,6,2,3,2,3,4,5,7,8,5,2,3,4,5,7,6,2,3,4,5,7,6,2,3,4,5,7,6,2,3,4,5,7,0,0,0,0,0,9,10,11,12,11,9,12,11,9,11,10,11,9,12,11,12,0,0,0,12,11,9,11,0,12,11,9,10,12,11,12,11,12,11,9,12,11,9,12,11,9,0,0,0,0,0,13,13,0,0,0,0,0,14,14,14,14,15,16,14,16,14,14,14,14,14,14,14,14,16,17,15,13,14,16,17,15,13,14,13,14,13,14,14,14,14,17,17,15,14,0,0,0,14,13,14,0,0,14,13,14,14,14,14,14,16,17,15,13,14,14,14,14,16,14,14,14,16,14,14,16,17,15,13,14,14,14,17,17,17,16,17,14,17,16,16,14,16,14,16,0,14,0,0,14,0,0,0,14,14,14,13,14,14,16,16,16,17,15,13,14,16,17,15,13,14,16,17,15,13,14,14,17,17,17,18,18,18,0,0,0,18,18,18,18,18,18,18,18,18,18,18,18,19,18,18,20,18,19,20,18,19,18,19,18,19,18,18,18,18,18,19,18,19,18,20,20,19,18,18,18,18,18,20,20,18,19,18,18,18,18,20,18,18,18,18,20,18,19,18,18,19,20,18,20,19,18,18,19,19,18,20,18,18,18,18,18,19,18,20,20,0,20,18,19,20,18,19,20,18,19,18,20,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,21,21,21,21,21,21,21,21,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,22,23,24,22,23,24,22,0,24,0,0,22,0,23,23,24,22,23,23,23,23,24,22,0,23,0,23,23,0,23,0,23,0,0,0,24,23,24,22,23,24,22,23,24,22,0,25,25,25,25,25,25,25,25,25,25,25,25,0,26,26,26,0,0,27,27,26,27,26,26,26,26,27,26,27,27,27,26,27,27,27,27,26,27,27,26,27,26,27,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],"f":[null,[[]],null,null,null,null,null,null,null,[[],["never",15]],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[[["usize",15]]],null,[[]],[[]],[[]],[[]],[[["arguments",3]]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[["str",15]],["result",6]],[[["panicinfo",3]],["never",15]],[[["usize",15]]],[[],["usize",15]],null,null,null,[[]],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[[],["bool",15]],[[],["bool",15]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["physpagenum",3]],[[],["virtpagenum",3]],[[],["physaddr",3]],[[],["virtaddr",3]],[[],["physpagenum",3]],[[],["virtpagenum",3]],[[],["simplerange",3]],[[]],[[]],[[]],[[]],[[]],[[["physaddr",3]],["ordering",4]],[[["virtaddr",3]],["ordering",4]],[[["physpagenum",3]],["ordering",4]],[[["virtpagenum",3]],["ordering",4]],null,null,[[["physaddr",3]],["bool",15]],[[["virtaddr",3]],["bool",15]],[[["physpagenum",3]],["bool",15]],[[["virtpagenum",3]],["bool",15]],[[],["physpagenum",3]],[[],["virtpagenum",3]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[]],[[["physpagenum",3]]],[[["usize",15]]],[[]],[[]],[[["virtpagenum",3]]],[[["usize",15]]],[[["physaddr",3]]],[[["usize",15]]],[[]],[[["virtaddr",3]]],[[["usize",15]]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],null,[[["physaddr",3]],["bool",15]],[[["virtaddr",3]],["bool",15]],[[["physpagenum",3]],["bool",15]],[[["virtpagenum",3]],["bool",15]],[[]],[[]],[[],["option",4]],[[],["usize",15]],[[],["usize",15]],[[["physaddr",3]],["option",4,[["ordering",4]]]],[[["virtaddr",3]],["option",4,[["ordering",4]]]],[[["physpagenum",3]],["option",4,[["ordering",4]]]],[[["virtpagenum",3]],["option",4,[["ordering",4]]]],null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],null,null,null,null,null,null,[[],["option",4,[["physpagenum",3]]]],[[],["option",4,[["physpagenum",3]]]],[[]],[[]],[[]],[[]],[[]],[[]],null,[[["physpagenum",3]]],[[["physpagenum",3]]],[[],["upsafecell",3]],[[]],null,[[["formatter",3]],["result",6]],[[],["option",4,[["frametracker",3]]]],[[]],[[["physpagenum",3]]],[[]],[[]],[[]],[[["physpagenum",3],["physpagenum",3]]],[[]],[[]],[[]],[[]],[[]],[[["physpagenum",3]]],[[]],null,null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],null,null,[[["layout",3]],["never",15]],[[]],[[]],null,null,null,null,null,null,null,null,null,null,null,null,[[]],[[]],null,[[]],[[]],[[["mappermission",3]]],[[]],[[],["u8",15]],null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["maptype",4]],[[],["mappermission",3]],[[]],[[]],[[["mappermission",3]],["ordering",4]],[[]],[[],["bool",15]],[[["pagetable",3]]],null,[[],["arc",3]],[[]],null,null,null,[[]],[[["maptype",4]],["bool",15]],[[["mappermission",3]],["bool",15]],null,null,[[["intoiterator",8]]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[]],[[]],[[]],[[]],[[]],[[["u8",15]],["option",4]],[[["u8",15]]],[[["u8",15]]],[[]],[[["intoiterator",8]]],[[]],[[]],[[["virtaddr",3],["virtaddr",3],["mappermission",3]]],[[]],[[],["bool",15]],[[]],[[]],[[]],[[]],[[]],[[],["bool",15]],[[],["bool",15]],[[["pagetable",3]]],[[["pagetable",3],["virtpagenum",3]]],null,[[]],null,[[["mappermission",3]],["bool",15]],[[["virtaddr",3],["virtaddr",3],["maptype",4],["mappermission",3]]],[[]],[[]],[[]],null,[[["mappermission",3]],["option",4,[["ordering",4]]]],[[["maparea",3],["option",4]]],[[]],[[]],null,null,[[["bool",15]]],null,null,null,[[]],[[]],[[]],[[]],[[]],[[]],[[],["usize",15]],[[["virtpagenum",3]],["option",4,[["pagetableentry",3]]]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[]],[[["pagetable",3]]],[[["pagetable",3],["virtpagenum",3]]],null,null,null,null,null,null,null,null,null,null,null,null,[[]],[[]],[[]],[[["pteflags",3]]],[[]],[[],["u8",15]],null,null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["pteflags",3]],[[],["pagetableentry",3]],[[]],[[]],[[["pteflags",3]],["ordering",4]],[[]],[[],["bool",15]],[[]],[[]],[[]],[[["pteflags",3]],["bool",15]],[[],["bool",15]],[[["intoiterator",8]]],[[["virtpagenum",3]],["option",4,[["pagetableentry",3]]]],[[["virtpagenum",3]],["option",4,[["pagetableentry",3]]]],[[],["pteflags",3]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],null,[[]],[[]],[[]],[[["u8",15]],["option",4]],[[["u8",15]]],[[["u8",15]]],[[["intoiterator",8]]],[[["usize",15]]],[[]],[[]],[[]],[[],["bool",15]],[[]],[[]],[[]],[[],["bool",15]],[[],["bool",15]],[[],["bool",15]],[[["virtpagenum",3],["physpagenum",3],["pteflags",3]]],[[["pteflags",3]],["bool",15]],[[]],[[["physpagenum",3],["pteflags",3]]],[[]],[[["pteflags",3]],["option",4,[["ordering",4]]]],[[],["physpagenum",3]],[[],["bool",15]],[[]],null,[[["bool",15]]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["usize",15]],[[["virtpagenum",3]],["option",4,[["pagetableentry",3]]]],[[["usize",15],["usize",15]],["vec",3]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[]],[[["virtpagenum",3]]],[[],["bool",15]],null,null,null,null,null,null,null,null,null,[[],["usize",15]],[[["usize",15]]],[[["usize",15],["usize",15],["usize",15],["usize",15]],["usize",15]],[[["usize",15]]],[[],["never",15]],null,null,[[]],[[]],[[],["refmut",3]],[[]],null,[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],null,null,null,null,null,null,[[["usize",15]],["isize",15]],null,[[["usize",15],["usize",15]],["isize",15]],[[["i32",15]],["never",15]],[[],["isize",15]],[[],["isize",15]],null,null,null,null,[[]],[[]],[[]],[[]],[[]],[[]],null,null,[[],["trapcontext",3]],[[],["usize",15]],[[],["taskmanager",3]],[[]],[[],["option",4,[["usize",15]]]],[[]],[[]],[[]],[[],["usize",15]],[[],["trapcontext",3]],null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],null,[[]],[[],["never",15]],[[]],[[]],[[]],null,null,null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],null,[[]],[[]],[[]],[[["usize",15]]],[[]],null,null,null,[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,null,null,null,null,null,null,[[]],[[]],[[]],[[]],[[],["taskstatus",4]],[[]],[[["taskstatus",4]],["bool",15]],[[]],[[]],[[],["trapcontext",3]],[[],["usize",15]],[[]],[[]],null,[[["usize",15]]],null,null,[[]],null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],null,null,[[],["usize",15]],[[],["usize",15]],[[]],null,[[]],[[]],[[]],[[]],[[],["never",15]],[[],["never",15]],[[],["never",15]],null,[[["usize",15],["usize",15],["usize",15],["usize",15],["usize",15]]],[[]],[[]],[[]],[[]],null,null,null,[[["usize",15]]],null,null,[[],["result",4]],[[],["result",4]],[[],["typeid",3]],null],"p":[[3,"Stdout"],[3,"PhysAddr"],[3,"VirtAddr"],[3,"PhysPageNum"],[3,"VirtPageNum"],[3,"SimpleRangeIterator"],[3,"SimpleRange"],[8,"StepByOne"],[3,"FRAME_ALLOCATOR"],[8,"FrameAllocator"],[3,"StackFrameAllocator"],[3,"FrameTracker"],[4,"MapType"],[3,"MapPermission"],[3,"KERNEL_SPACE"],[3,"MemorySet"],[3,"MapArea"],[3,"PTEFlags"],[3,"PageTableEntry"],[3,"PageTable"],[3,"UPSafeCell"],[3,"TASK_MANAGER"],[3,"TaskManager"],[3,"TaskManagerInner"],[3,"TaskContext"],[4,"TaskStatus"],[3,"TaskControlBlock"],[3,"TrapContext"]]}\ +"os":{"doc":"The main module and entrypoint","t":[0,5,0,0,0,0,0,14,14,5,0,0,0,0,0,0,17,17,17,17,17,17,17,17,17,5,3,11,11,11,11,5,11,11,11,11,5,5,5,0,0,0,5,0,0,12,12,12,12,17,17,3,3,3,3,8,17,6,17,3,3,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,11,11,11,11,11,11,11,11,11,11,11,11,12,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,3,8,6,3,3,12,10,11,11,11,11,11,11,11,12,10,11,11,11,12,11,5,5,5,11,11,11,11,5,11,11,11,10,11,11,12,12,11,11,11,11,11,11,11,11,11,7,7,5,5,5,13,13,3,3,3,4,3,18,18,18,18,12,11,11,12,11,11,11,11,11,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,11,5,5,5,11,11,11,5,5,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,12,11,11,11,11,11,12,11,11,5,11,5,5,11,5,5,5,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,18,18,18,3,3,3,18,18,18,18,18,11,11,11,11,11,11,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,11,11,11,11,11,11,11,11,5,11,11,11,11,11,11,11,11,11,11,11,11,17,17,17,5,5,5,5,0,3,11,11,11,11,12,11,11,11,11,11,17,17,17,17,0,0,5,17,5,5,5,5,3,3,3,3,12,11,11,11,11,11,11,0,12,5,5,11,5,11,11,11,11,11,11,12,11,11,11,5,11,5,11,12,12,5,11,5,11,12,12,5,0,0,12,11,11,11,11,11,11,11,11,11,3,11,11,11,11,11,12,12,12,11,11,11,11,5,13,13,13,3,4,12,11,11,11,11,11,11,11,11,11,11,11,11,11,12,11,12,12,11,12,11,11,11,11,11,11,17,17,5,5,5,3,0,5,5,12,12,12,5,5,12,5,5,12,5,12,3,11,11,11,11,11,12,12,12,11,12,12,11,11,11,12],"n":["board","clear_bss","config","console","lang_items","loader","mm","print","println","rust_main","sbi","sync","syscall","task","timer","trap","CLOCK_FREQ","KERNEL_HEAP_SIZE","KERNEL_STACK_SIZE","MEMORY_END","PAGE_SIZE","PAGE_SIZE_BITS","TRAMPOLINE","TRAP_CONTEXT","USER_STACK_SIZE","kernel_stack_position","Stdout","borrow","borrow_mut","from","into","print","try_from","try_into","type_id","write_str","panic","get_app_data","get_num_app","address","frame_allocator","heap_allocator","init","memory_set","page_table","0","0","0","0","PA_WIDTH_SV39","PPN_WIDTH_SV39","PhysAddr","PhysPageNum","SimpleRange","SimpleRangeIterator","StepByOne","VA_WIDTH_SV39","VPNRange","VPN_WIDTH_SV39","VirtAddr","VirtPageNum","aligned","aligned","borrow","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","ceil","ceil","clone","clone","clone","clone","clone","clone_into","clone_into","clone_into","clone_into","clone_into","cmp","cmp","cmp","cmp","current","end","eq","eq","eq","eq","floor","floor","fmt","fmt","fmt","fmt","from","from","from","from","from","from","from","from","from","from","from","from","from","from","get_bytes_array","get_end","get_mut","get_pte_array","get_start","indexes","into","into","into","into","into","into","into_iter","into_iter","l","ne","ne","ne","ne","new","new","next","page_offset","page_offset","partial_cmp","partial_cmp","partial_cmp","partial_cmp","r","step","step","to_owned","to_owned","to_owned","to_owned","to_owned","try_from","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","type_id","FRAME_ALLOCATOR","FrameAllocator","FrameAllocatorImpl","FrameTracker","StackFrameAllocator","__private_field","alloc","alloc","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","current","dealloc","dealloc","deref","drop","end","fmt","frame_alloc","frame_allocator_test","frame_dealloc","from","from","from","init","init_frame_allocator","into","into","into","new","new","new","ppn","recycled","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id","HEAP_ALLOCATOR","HEAP_SPACE","handle_alloc_error","heap_test","init_heap","Framed","Identical","KERNEL_SPACE","MapArea","MapPermission","MapType","MemorySet","R","U","W","X","__private_field","activate","all","areas","bitand","bitand_assign","bitor","bitor_assign","bits","bits","bitxor","bitxor_assign","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","clone","clone","clone_into","clone_into","cmp","complement","contains","copy_data","data_frames","deref","difference","ebss","edata","ekernel","empty","eq","eq","erodata","etext","extend","fmt","fmt","fmt","fmt","fmt","fmt","from","from","from","from","from","from_bits","from_bits_truncate","from_bits_unchecked","from_elf","from_iter","hash","insert","insert_framed_area","intersection","intersects","into","into","into","into","into","is_all","is_empty","map","map_one","map_perm","map_trampoline","map_type","ne","new","new_bare","new_kernel","not","page_table","partial_cmp","push","remap_test","remove","sbss_with_stack","sdata","set","srodata","stext","strampoline","sub","sub_assign","symmetric_difference","to_owned","to_owned","toggle","token","translate","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","union","unmap","unmap_one","vpn_range","A","D","G","PTEFlags","PageTable","PageTableEntry","R","U","V","W","X","all","bitand","bitand_assign","bitor","bitor_assign","bits","bits","bits","bitxor","bitxor_assign","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","clone","clone","clone_into","clone_into","cmp","complement","contains","difference","empty","empty","eq","executable","extend","find_pte","find_pte_create","flags","fmt","fmt","fmt","fmt","fmt","frames","from","from","from","from_bits","from_bits_truncate","from_bits_unchecked","from_iter","from_token","hash","insert","intersection","intersects","into","into","into","is_all","is_empty","is_valid","map","ne","new","new","not","partial_cmp","ppn","readable","remove","root_ppn","set","sub","sub_assign","symmetric_difference","to_owned","to_owned","toggle","token","translate","translated_byte_buffer","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id","union","unmap","writable","SBI_CONSOLE_PUTCHAR","SBI_SET_TIMER","SBI_SHUTDOWN","console_putchar","sbi_call","set_timer","shutdown","up","UPSafeCell","borrow","borrow_mut","exclusive_access","from","inner","into","new","try_from","try_into","type_id","SYSCALL_EXIT","SYSCALL_GET_TIME","SYSCALL_WRITE","SYSCALL_YIELD","fs","process","syscall","FD_STDOUT","sys_write","sys_exit","sys_get_time","sys_yield","TASK_MANAGER","TaskContext","TaskManager","TaskManagerInner","__private_field","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","context","current_task","current_trap_cx","current_user_token","deref","exit_current_and_run_next","find_next_task","from","from","from","get_current_token","get_current_trap_cx","inner","into","into","into","mark_current_exited","mark_current_exited","mark_current_suspended","mark_current_suspended","num_app","ra","run_first_task","run_first_task","run_next_task","run_next_task","s","sp","suspend_current_and_run_next","switch","task","tasks","try_from","try_from","try_from","try_into","try_into","try_into","type_id","type_id","type_id","TaskContext","borrow","borrow_mut","from","goto_trap_return","into","ra","s","sp","try_from","try_into","type_id","zero_init","__switch","Exited","Ready","Running","TaskControlBlock","TaskStatus","base_size","borrow","borrow","borrow_mut","borrow_mut","clone","clone_into","eq","from","from","get_trap_cx","get_user_token","into","into","memory_set","new","task_cx","task_status","to_owned","trap_cx_ppn","try_from","try_from","try_into","try_into","type_id","type_id","MSEC_PER_SEC","TICKS_PER_SEC","get_time","get_time_ms","set_next_trigger","TrapContext","context","enable_timer_interrupt","init","kernel_satp","kernel_sp","sepc","set_kernel_trap_entry","set_user_trap_entry","sstatus","trap_from_kernel","trap_handler","trap_handler","trap_return","x","TrapContext","app_init_context","borrow","borrow_mut","from","into","kernel_satp","kernel_sp","sepc","set_sp","sstatus","trap_handler","try_from","try_into","type_id","x"],"q":["os","","","","","","","","","","","","","","","","os::board","os::config","","","","","","","","","os::console","","","","","","","","","","os::lang_items","os::loader","","os::mm","","","","","","os::mm::address","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::mm::frame_allocator","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::mm::heap_allocator","","","","","os::mm::memory_set","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::mm::page_table","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::sbi","","","","","","","os::sync","os::sync::up","","","","","","","","","","","os::syscall","","","","","","","os::syscall::fs","","os::syscall::process","","","os::task","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::task::context","","","","","","","","","","","","","os::task::switch","os::task::task","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","os::timer","","","","","os::trap","","","","","","","","","","","","","","","os::trap::context","","","","","","","","","","","","","","",""],"d":["","clear BSS segment","Constants used in rCore","SBI console driver, for text output","The panic handler","Loading user applications into memory","Memory management implementation","print string macro","println string macro","the rust entry-point of os","SBI call wrappers","Synchronization and interior mutability primitives","Implementation of syscalls","Task management implementation","RISC-V timer-related functionality","Trap handling functionality","","","","","","","","","","Return (bottom, top) of a kernel stack in kernel space.","","","","","","","","","","","panic handler","get applications data","Get the total number of applications.","Implementation of physical and virtual address and page …","Implementation of FrameAllocator which controls all the …","The global allocator","initiate heap allocator, frame allocator and kernel space","Implementation of MapArea and MemorySet.","Implementation of PageTableEntry and PageTable.","","","","","physical address","","Definitions","physical page number","a simple range structure for type T","iterator for the simple range structure","","","a simple range structure for virtual page number","","virtual address","virtual page number","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","frame allocator instance through lazy_static!","","","manage a frame which has the same lifecycle as the tracker","an implementation for frame allocator","","","","","","","","","","","","","","","","","allocate a frame","a simple test for frame allocator","deallocate a frame","","","","","initiate the frame allocator using ekernel and MEMORY_END","","","","","","","","","","","","","","","","","","heap allocator instance","heap space ([u8; KERNEL_HEAP_SIZE])","panic when heap allocation error occurs","","initiate heap allocator","","","a memory set instance through lazy_static! managing kernel …","map area structure, controls a contiguous piece of virtual …","map permission corresponding to that in pte: R W X U","map type for memory set: identical or framed","memory set structure, controls virtual-memory space","","","","","","","Returns the set containing all flags.","","Returns the intersection between the two sets of flags.","Disables all flags disabled in the set.","Returns the union of the two sets of flags.","Adds the set of flags.","Returns the raw value of the flags currently stored.","","Returns the left flags, but with all the right flags …","Toggles the set of flags.","","","","","","","","","","","","","","","","Returns the complement of this set of flags.","Returns true if all of the flags in other are contained …","data: start-aligned but maybe with shorter length assume …","","","Returns the difference between the flags in self and other.","","","","Returns an empty set of flags.","","","","","","","","","","","","","","","","","Convert from underlying bit representation, unless that …","Convert from underlying bit representation, dropping any …","Convert from underlying bit representation, preserving all …","Include sections in elf and trampoline and TrapContext and …","","","Inserts the specified flags in-place.","Assume that no conflicts.","Returns the intersection between the flags in self and …","Returns true if there are flags common to both self and …","","","","","","Returns true if all flags are currently set.","Returns true if no flags are currently stored.","","","","Mention that trampoline is not collected by areas.","","","","","Without kernel stacks.","Returns the complement of this set of flags.","","","","","Removes the specified flags in-place.","","","Inserts or removes the specified flags depending on the …","","","","Returns the set difference of the two sets of flags.","Disables all flags enabled in the set.","Returns the symmetric difference between the flags in self …","","","Toggles the specified flags in-place.","","","","","","","","","","","","","","","","","","Returns the union of between the flags in self and other.","","","","","","","page table entry flags","page table structure","page table entry structure","","","","","","Returns the set containing all flags.","Returns the intersection between the two sets of flags.","Disables all flags disabled in the set.","Returns the union of the two sets of flags.","Adds the set of flags.","Returns the raw value of the flags currently stored.","","","Returns the left flags, but with all the right flags …","Toggles the set of flags.","","","","","","","","","","","","Returns the complement of this set of flags.","Returns true if all of the flags in other are contained …","Returns the difference between the flags in self and other.","Returns an empty set of flags.","","","","","","","","","","","","","","","","","Convert from underlying bit representation, unless that …","Convert from underlying bit representation, dropping any …","Convert from underlying bit representation, preserving all …","","Temporarily used to get arguments from user space.","","Inserts the specified flags in-place.","Returns the intersection between the flags in self and …","Returns true if there are flags common to both self and …","","","","Returns true if all flags are currently set.","Returns true if no flags are currently stored.","","","","","","Returns the complement of this set of flags.","","","","Removes the specified flags in-place.","","Inserts or removes the specified flags depending on the …","Returns the set difference of the two sets of flags.","Disables all flags enabled in the set.","Returns the symmetric difference between the flags in self …","","","Toggles the specified flags in-place.","","","translate a pointer to a mutable u8 Vec through page table","","","","","","","","","","Returns the union of between the flags in self and other.","","","","","","use sbi call to putchar in console (qemu uart handler)","general sbi call","use sbi call to set timer","use sbi call to getchar from console (qemu uart handler) …","Uniprocessor interior mutability primitives","Wrap a static data structure inside it so that we are able …","","","Exclusive access inner data in UPSafeCell. Panic if the …","","inner data","","User is responsible to guarantee that inner struct is only …","","","","","","","","File and filesystem-related syscalls","Process management syscalls","handle syscall exception with syscall_id and other …","","write buf of length len to a file with fd","task exits and submit an exit code","get current time ","current task gives up resources for other tasks","a TaskManager global instance through lazy_static!","task context structure containing some registers","The task manager, where all the tasks are managed.","The task manager inner in ‘UPSafeCell’","","","","","","","","Implementation of TaskContext","id of current Running task","Get the current ‘Running’ task’s trap contexts.","Get the current ‘Running’ task’s token.","","Exit the current ‘Running’ task and run the next task …","Find next task to run and return task id.","","","","Get the current ‘Running’ task’s token.","Get the current ‘Running’ task’s trap contexts.","use inner value to get mutable access","","","","Change the status of current Running task into Exited.","Change the status of current Running task into Exited.","Change the status of current Running task into Ready.","Change the status of current Running task into Ready.","total number of tasks","return address ( e.g. __restore ) of __switch ASM function","Run the first task in task list.","Run the first task in task list.","Switch current Running task to the task we have found, or …","Switch current Running task to the task we have found, or …","callee saved registers: s 0..11","kernel stack pointer of app","Suspend the current ‘Running’ task and run the next …","Rust wrapper around __switch.","Types related to task management","task list","","","","","","","","","","task context structure containing some registers","","","","set Task Context{__restore ASM funciton: trap_return, sp: …","","return address ( e.g. __restore ) of __switch ASM function","callee saved registers: s 0..11","kernel stack pointer of app","","","","init task context","Switch to the context of next_task_cx_ptr, saving the …","","","","task control block structure","task status: UnInit, Ready, Running, Exited","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","get current time in microseconds","set the next timer interrupt","trap context structure containing sstatus, sepc and …","Implementation of TrapContext","enable timer interrupt in sie CSR","initialize CSR stvec as the entry of __alltraps","Addr of Page Table","kernel stack","CSR sepc","","","CSR sstatus ","Unimplement: traps/interrupts/exceptions from kernel mode …","handle an interrupt, exception, or system call from user …","Addr of trap_handler function","set the new addr of __restore asm function in TRAMPOLINE …","general regs[0..31]","trap context structure containing sstatus, sepc and …","init app context","","","","","Addr of Page Table","kernel stack","CSR sepc","set stack pointer to x_2 reg (sp)","CSR sstatus ","Addr of trap_handler function","","","","general regs[0..31]"],"i":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,2,3,4,5,0,0,0,0,0,0,0,0,0,0,0,0,2,3,6,2,3,4,5,7,6,2,3,4,5,7,2,3,2,3,4,5,7,2,3,4,5,7,2,3,4,5,6,6,2,3,4,5,2,3,2,3,4,5,6,2,2,2,3,3,3,4,4,4,5,5,5,7,4,7,4,4,7,5,6,2,3,4,5,7,6,7,7,2,3,4,5,6,7,6,2,3,2,3,4,5,7,8,5,2,3,4,5,7,6,2,3,4,5,7,6,2,3,4,5,7,6,2,3,4,5,7,0,0,0,0,0,9,10,11,12,11,9,12,11,9,11,10,11,9,12,11,12,0,0,0,12,11,9,11,0,12,11,9,10,12,11,12,11,12,11,9,12,11,9,12,11,9,0,0,0,0,0,13,13,0,0,0,0,0,14,14,14,14,15,16,14,16,14,14,14,14,14,14,14,14,16,17,15,13,14,16,17,15,13,14,13,14,13,14,14,14,14,17,17,15,14,0,0,0,14,13,14,0,0,14,13,14,14,14,14,14,16,17,15,13,14,14,14,14,16,14,14,14,16,14,14,16,17,15,13,14,14,14,17,17,17,16,17,14,17,16,16,14,16,14,16,0,14,0,0,14,0,0,0,14,14,14,13,14,14,16,16,16,17,15,13,14,16,17,15,13,14,16,17,15,13,14,14,17,17,17,18,18,18,0,0,0,18,18,18,18,18,18,18,18,18,18,18,18,19,18,18,20,18,19,20,18,19,18,19,18,19,18,18,18,18,18,19,18,19,18,20,20,19,18,18,18,18,18,20,20,18,19,18,18,18,18,20,18,18,18,18,20,18,19,18,18,19,20,18,20,19,18,18,19,19,18,20,18,18,18,18,18,19,18,20,20,0,20,18,19,20,18,19,20,18,19,18,20,19,0,0,0,0,0,0,0,0,0,21,21,21,21,21,21,21,21,21,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,22,23,24,22,23,24,22,0,24,0,0,22,0,23,23,24,22,23,23,23,23,24,22,0,23,0,23,23,25,0,23,0,23,25,25,0,0,0,24,23,24,22,23,24,22,23,24,22,0,25,25,25,25,25,25,25,25,25,25,25,25,0,26,26,26,0,0,27,27,26,27,26,26,26,26,27,26,27,27,27,26,27,27,27,27,26,27,27,26,27,26,27,26,0,0,0,0,0,0,0,0,0,28,28,28,0,0,28,0,0,28,0,28,0,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],"f":[null,[[]],null,null,null,null,null,null,null,[[],["never",15]],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[[["usize",15]]],null,[[]],[[]],[[]],[[]],[[["arguments",3]]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[["str",15]],["result",6]],[[["panicinfo",3]],["never",15]],[[["usize",15]]],[[],["usize",15]],null,null,null,[[]],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[[],["bool",15]],[[],["bool",15]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["physpagenum",3]],[[],["virtpagenum",3]],[[],["physaddr",3]],[[],["virtaddr",3]],[[],["physpagenum",3]],[[],["virtpagenum",3]],[[],["simplerange",3]],[[]],[[]],[[]],[[]],[[]],[[["physaddr",3]],["ordering",4]],[[["virtaddr",3]],["ordering",4]],[[["physpagenum",3]],["ordering",4]],[[["virtpagenum",3]],["ordering",4]],null,null,[[["physaddr",3]],["bool",15]],[[["virtaddr",3]],["bool",15]],[[["physpagenum",3]],["bool",15]],[[["virtpagenum",3]],["bool",15]],[[],["physpagenum",3]],[[],["virtpagenum",3]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[]],[[["usize",15]]],[[]],[[["physpagenum",3]]],[[]],[[["usize",15]]],[[["virtpagenum",3]]],[[["usize",15]]],[[]],[[["physaddr",3]]],[[["virtaddr",3]]],[[]],[[["usize",15]]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],null,[[["physaddr",3]],["bool",15]],[[["virtaddr",3]],["bool",15]],[[["physpagenum",3]],["bool",15]],[[["virtpagenum",3]],["bool",15]],[[]],[[]],[[],["option",4]],[[],["usize",15]],[[],["usize",15]],[[["physaddr",3]],["option",4,[["ordering",4]]]],[[["virtaddr",3]],["option",4,[["ordering",4]]]],[[["physpagenum",3]],["option",4,[["ordering",4]]]],[[["virtpagenum",3]],["option",4,[["ordering",4]]]],null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],null,null,null,null,null,null,[[],["option",4,[["physpagenum",3]]]],[[],["option",4,[["physpagenum",3]]]],[[]],[[]],[[]],[[]],[[]],[[]],null,[[["physpagenum",3]]],[[["physpagenum",3]]],[[],["upsafecell",3]],[[]],null,[[["formatter",3]],["result",6]],[[],["option",4,[["frametracker",3]]]],[[]],[[["physpagenum",3]]],[[]],[[]],[[]],[[["physpagenum",3],["physpagenum",3]]],[[]],[[]],[[]],[[]],[[]],[[["physpagenum",3]]],[[]],null,null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],null,null,[[["layout",3]],["never",15]],[[]],[[]],null,null,null,null,null,null,null,null,null,null,null,null,[[]],[[]],null,[[]],[[]],[[["mappermission",3]]],[[]],[[],["u8",15]],null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["maptype",4]],[[],["mappermission",3]],[[]],[[]],[[["mappermission",3]],["ordering",4]],[[]],[[],["bool",15]],[[["pagetable",3]]],null,[[],["arc",3]],[[]],null,null,null,[[]],[[["maptype",4]],["bool",15]],[[["mappermission",3]],["bool",15]],null,null,[[["intoiterator",8]]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[]],[[]],[[]],[[]],[[]],[[["u8",15]],["option",4]],[[["u8",15]]],[[["u8",15]]],[[]],[[["intoiterator",8]]],[[]],[[]],[[["virtaddr",3],["virtaddr",3],["mappermission",3]]],[[]],[[],["bool",15]],[[]],[[]],[[]],[[]],[[]],[[],["bool",15]],[[],["bool",15]],[[["pagetable",3]]],[[["pagetable",3],["virtpagenum",3]]],null,[[]],null,[[["mappermission",3]],["bool",15]],[[["virtaddr",3],["virtaddr",3],["maptype",4],["mappermission",3]]],[[]],[[]],[[]],null,[[["mappermission",3]],["option",4,[["ordering",4]]]],[[["maparea",3],["option",4]]],[[]],[[]],null,null,[[["bool",15]]],null,null,null,[[]],[[]],[[]],[[]],[[]],[[]],[[],["usize",15]],[[["virtpagenum",3]],["option",4,[["pagetableentry",3]]]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[]],[[["pagetable",3]]],[[["pagetable",3],["virtpagenum",3]]],null,null,null,null,null,null,null,null,null,null,null,null,[[]],[[]],[[]],[[["pteflags",3]]],[[]],[[],["u8",15]],null,null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["pteflags",3]],[[],["pagetableentry",3]],[[]],[[]],[[["pteflags",3]],["ordering",4]],[[]],[[],["bool",15]],[[]],[[]],[[]],[[["pteflags",3]],["bool",15]],[[],["bool",15]],[[["intoiterator",8]]],[[["virtpagenum",3]],["option",4,[["pagetableentry",3]]]],[[["virtpagenum",3]],["option",4,[["pagetableentry",3]]]],[[],["pteflags",3]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],[[["formatter",3]],["result",6]],null,[[]],[[]],[[]],[[["u8",15]],["option",4]],[[["u8",15]]],[[["u8",15]]],[[["intoiterator",8]]],[[["usize",15]]],[[]],[[]],[[]],[[],["bool",15]],[[]],[[]],[[]],[[],["bool",15]],[[],["bool",15]],[[],["bool",15]],[[["virtpagenum",3],["physpagenum",3],["pteflags",3]]],[[["pteflags",3]],["bool",15]],[[]],[[["physpagenum",3],["pteflags",3]]],[[]],[[["pteflags",3]],["option",4,[["ordering",4]]]],[[],["physpagenum",3]],[[],["bool",15]],[[]],null,[[["bool",15]]],[[]],[[]],[[]],[[]],[[]],[[]],[[],["usize",15]],[[["virtpagenum",3]],["option",4,[["pagetableentry",3]]]],[[["usize",15],["usize",15]],["vec",3]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],[[]],[[["virtpagenum",3]]],[[],["bool",15]],null,null,null,[[["usize",15]]],[[["usize",15],["usize",15],["usize",15],["usize",15]],["usize",15]],[[["usize",15]]],[[],["never",15]],null,null,[[]],[[]],[[],["refmut",3]],[[]],null,[[]],[[]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],null,null,null,null,null,null,[[["usize",15]],["isize",15]],null,[[["usize",15],["usize",15]],["isize",15]],[[["i32",15]],["never",15]],[[],["isize",15]],[[],["isize",15]],null,null,null,null,null,[[]],[[]],[[]],[[]],[[]],[[]],null,null,[[],["trapcontext",3]],[[],["usize",15]],[[],["taskmanager",3]],[[]],[[],["option",4,[["usize",15]]]],[[]],[[]],[[]],[[],["usize",15]],[[],["trapcontext",3]],null,[[]],[[]],[[]],[[]],[[]],[[]],[[]],null,null,[[]],[[],["never",15]],[[]],[[]],null,null,[[]],null,null,null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],[[],["typeid",3]],null,[[]],[[]],[[]],[[["usize",15]]],[[]],null,null,null,[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[]],null,null,null,null,null,null,null,[[]],[[]],[[]],[[]],[[],["taskstatus",4]],[[]],[[["taskstatus",4]],["bool",15]],[[]],[[]],[[],["trapcontext",3]],[[],["usize",15]],[[]],[[]],null,[[["usize",15]]],null,null,[[]],null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[],["typeid",3]],null,null,[[],["usize",15]],[[],["usize",15]],[[]],null,null,[[]],[[]],null,null,null,[[]],[[]],null,[[],["never",15]],[[],["never",15]],null,[[],["never",15]],null,null,[[["usize",15],["usize",15],["usize",15],["usize",15],["usize",15]]],[[]],[[]],[[]],[[]],null,null,null,[[["usize",15]]],null,null,[[],["result",4]],[[],["result",4]],[[],["typeid",3]],null],"p":[[3,"Stdout"],[3,"PhysAddr"],[3,"VirtAddr"],[3,"PhysPageNum"],[3,"VirtPageNum"],[3,"SimpleRangeIterator"],[3,"SimpleRange"],[8,"StepByOne"],[3,"FRAME_ALLOCATOR"],[8,"FrameAllocator"],[3,"StackFrameAllocator"],[3,"FrameTracker"],[4,"MapType"],[3,"MapPermission"],[3,"KERNEL_SPACE"],[3,"MemorySet"],[3,"MapArea"],[3,"PTEFlags"],[3,"PageTableEntry"],[3,"PageTable"],[3,"UPSafeCell"],[3,"TASK_MANAGER"],[3,"TaskManager"],[3,"TaskManagerInner"],[3,"TaskContext"],[4,"TaskStatus"],[3,"TaskControlBlock"],[3,"TrapContext"]]}\ }'); if (window.initSearch) {window.initSearch(searchIndex)}; \ No newline at end of file diff --git a/ch4/src/os/config.rs.html b/ch4/src/os/config.rs.html index a476e6fb..14e65658 100644 --- a/ch4/src/os/config.rs.html +++ b/ch4/src/os/config.rs.html @@ -18,7 +18,11 @@ 15 16 17 -
pub const USER_STACK_SIZE: usize = 4096 * 2;
+18
+19
+
//! Constants used in rCore
+
+pub const USER_STACK_SIZE: usize = 4096 * 2;
 pub const KERNEL_STACK_SIZE: usize = 4096 * 2;
 pub const KERNEL_HEAP_SIZE: usize = 0x30_0000;
 pub const MEMORY_END: usize = 0x80800000;
diff --git a/ch4/src/os/console.rs.html b/ch4/src/os/console.rs.html
index 18c55e28..e4963bc7 100644
--- a/ch4/src/os/console.rs.html
+++ b/ch4/src/os/console.rs.html
@@ -32,7 +32,13 @@
 29
 30
 31
-
use crate::sbi::console_putchar;
+32
+33
+34
+35
+
//! SBI console driver, for text output
+
+use crate::sbi::console_putchar;
 use core::fmt::{self, Write};
 
 struct Stdout;
@@ -51,6 +57,7 @@
 }
 
 #[macro_export]
+/// print string macro
 macro_rules! print {
     ($fmt: literal $(, $($arg: tt)+)?) => {
         $crate::console::print(format_args!($fmt $(, $($arg)+)?));
@@ -58,6 +65,7 @@
 }
 
 #[macro_export]
+/// println string macro
 macro_rules! println {
     ($fmt: literal $(, $($arg: tt)+)?) => {
         $crate::console::print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
diff --git a/ch4/src/os/lang_items.rs.html b/ch4/src/os/lang_items.rs.html
index 696d616e..dfc6fe6f 100644
--- a/ch4/src/os/lang_items.rs.html
+++ b/ch4/src/os/lang_items.rs.html
@@ -18,10 +18,16 @@
 15
 16
 17
-
use crate::sbi::shutdown;
+18
+19
+20
+
//! The panic handler
+
+use crate::sbi::shutdown;
 use core::panic::PanicInfo;
 
 #[panic_handler]
+/// panic handler
 fn panic(info: &PanicInfo) -> ! {
     if let Some(location) = info.location() {
         println!(
diff --git a/ch4/src/os/loader.rs.html b/ch4/src/os/loader.rs.html
index c700c7cf..09b02e91 100644
--- a/ch4/src/os/loader.rs.html
+++ b/ch4/src/os/loader.rs.html
@@ -23,13 +23,21 @@
 20
 21
 22
-
pub fn get_num_app() -> usize {
+23
+24
+25
+26
+
//! Loading user applications into memory
+
+/// Get the total number of applications.
+pub fn get_num_app() -> usize {
     extern "C" {
         fn _num_app();
     }
     unsafe { (_num_app as usize as *const usize).read_volatile() }
 }
 
+/// get applications data
 pub fn get_app_data(app_id: usize) -> &'static [u8] {
     extern "C" {
         fn _num_app();
diff --git a/ch4/src/os/main.rs.html b/ch4/src/os/main.rs.html
index 93c66474..1d041f9a 100644
--- a/ch4/src/os/main.rs.html
+++ b/ch4/src/os/main.rs.html
@@ -61,7 +61,45 @@
 58
 59
 60
-
#![no_std]
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+
//! The main module and entrypoint
+//!
+//! Various facilities of the kernels are implemented as submodules. The most
+//! important ones are:
+//!
+//! - [`trap`]: Handles all cases of switching from userspace to the kernel
+//! - [`task`]: Task management
+//! - [`syscall`]: System call handling and implementation
+//!
+//! The operating system also starts in this module. Kernel code starts
+//! executing from `entry.asm`, after which [`rust_main()`] is called to
+//! initialize various pieces of functionality. (See its source code for
+//! details.)
+//!
+//! We then call [`task::run_first_task()`] and for the first time go to
+//! userspace.
+
+#![deny(missing_docs)]
+#![deny(warnings)]
+#![no_std]
 #![no_main]
 #![feature(panic_info_message)]
 #![feature(alloc_error_handler)]
@@ -86,16 +124,15 @@
 mod mm;
 mod sbi;
 mod sync;
-mod syscall;
-mod task;
+pub mod syscall;
+pub mod task;
 mod timer;
-mod trap;
-
-use core::arch::global_asm;
+pub mod trap;
 
-global_asm!(include_str!("entry.asm"));
-global_asm!(include_str!("link_app.S"));
+core::arch::global_asm!(include_str!("entry.asm"));
+core::arch::global_asm!(include_str!("link_app.S"));
 
+/// clear BSS segment
 fn clear_bss() {
     extern "C" {
         fn sbss();
@@ -108,6 +145,7 @@
 }
 
 #[no_mangle]
+/// the rust entry-point of os
 pub fn rust_main() -> ! {
     clear_bss();
     println!("[kernel] Hello, world!");
diff --git a/ch4/src/os/mm/address.rs.html b/ch4/src/os/mm/address.rs.html
index d9e151f0..f9dde337 100644
--- a/ch4/src/os/mm/address.rs.html
+++ b/ch4/src/os/mm/address.rs.html
@@ -242,10 +242,23 @@
 239
 240
 241
-
use super::PageTableEntry;
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+
//! Implementation of physical and virtual address and page number.
+
+use super::PageTableEntry;
 use crate::config::{PAGE_SIZE, PAGE_SIZE_BITS};
 use core::fmt::{self, Debug, Formatter};
 
+/// physical address
 const PA_WIDTH_SV39: usize = 56;
 const VA_WIDTH_SV39: usize = 39;
 const PPN_WIDTH_SV39: usize = PA_WIDTH_SV39 - PAGE_SIZE_BITS;
@@ -255,12 +268,15 @@
 #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
 pub struct PhysAddr(pub usize);
 
+/// virtual address
 #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
 pub struct VirtAddr(pub usize);
 
+/// physical page number
 #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
 pub struct PhysPageNum(pub usize);
 
+/// virtual page number
 #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
 pub struct VirtPageNum(pub usize);
 
@@ -420,6 +436,7 @@
 }
 
 #[derive(Copy, Clone)]
+/// a simple range structure for type T
 pub struct SimpleRange<T>
 where
     T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
@@ -452,6 +469,7 @@
         SimpleRangeIterator::new(self.l, self.r)
     }
 }
+/// iterator for the simple range structure
 pub struct SimpleRangeIterator<T>
 where
     T: StepByOne + Copy + PartialEq + PartialOrd + Debug,
@@ -482,6 +500,8 @@
         }
     }
 }
+
+/// a simple range structure for virtual page number
 pub type VPNRange = SimpleRange<VirtPageNum>;
 
diff --git a/ch4/src/os/mm/frame_allocator.rs.html b/ch4/src/os/mm/frame_allocator.rs.html index f3b68209..43e488a9 100644 --- a/ch4/src/os/mm/frame_allocator.rs.html +++ b/ch4/src/os/mm/frame_allocator.rs.html @@ -127,13 +127,27 @@ 124 125 126 -
use super::{PhysAddr, PhysPageNum};
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+
//! Implementation of [`FrameAllocator`] which 
+//! controls all the frames in the operating system.
+
+use super::{PhysAddr, PhysPageNum};
 use crate::config::MEMORY_END;
 use crate::sync::UPSafeCell;
 use alloc::vec::Vec;
 use core::fmt::{self, Debug, Formatter};
 use lazy_static::*;
 
+/// manage a frame which has the same lifecycle as the tracker
 pub struct FrameTracker {
     pub ppn: PhysPageNum,
 }
@@ -167,6 +181,7 @@
     fn dealloc(&mut self, ppn: PhysPageNum);
 }
 
+/// an implementation for frame allocator
 pub struct StackFrameAllocator {
     current: usize,
     end: usize,
@@ -211,10 +226,12 @@
 type FrameAllocatorImpl = StackFrameAllocator;
 
 lazy_static! {
+    /// frame allocator instance through lazy_static!
     pub static ref FRAME_ALLOCATOR: UPSafeCell<FrameAllocatorImpl> =
         unsafe { UPSafeCell::new(FrameAllocatorImpl::new()) };
 }
 
+/// initiate the frame allocator using `ekernel` and `MEMORY_END`
 pub fn init_frame_allocator() {
     extern "C" {
         fn ekernel();
@@ -225,6 +242,7 @@
     );
 }
 
+/// allocate a frame
 pub fn frame_alloc() -> Option<FrameTracker> {
     FRAME_ALLOCATOR
         .exclusive_access()
@@ -232,11 +250,13 @@
         .map(FrameTracker::new)
 }
 
+/// deallocate a frame
 fn frame_dealloc(ppn: PhysPageNum) {
     FRAME_ALLOCATOR.exclusive_access().dealloc(ppn);
 }
 
 #[allow(unused)]
+/// a simple test for frame allocator
 pub fn frame_allocator_test() {
     let mut v: Vec<FrameTracker> = Vec::new();
     for i in 0..5 {
diff --git a/ch4/src/os/mm/heap_allocator.rs.html b/ch4/src/os/mm/heap_allocator.rs.html
index d2313840..7a5fa29f 100644
--- a/ch4/src/os/mm/heap_allocator.rs.html
+++ b/ch4/src/os/mm/heap_allocator.rs.html
@@ -46,19 +46,31 @@
 43
 44
 45
-
use crate::config::KERNEL_HEAP_SIZE;
+46
+47
+48
+49
+50
+51
+
//! The global allocator
+
+use crate::config::KERNEL_HEAP_SIZE;
 use buddy_system_allocator::LockedHeap;
 
 #[global_allocator]
+/// heap allocator instance
 static HEAP_ALLOCATOR: LockedHeap = LockedHeap::empty();
 
 #[alloc_error_handler]
+/// panic when heap allocation error occurs
 pub fn handle_alloc_error(layout: core::alloc::Layout) -> ! {
     panic!("Heap allocation error, layout = {:?}", layout);
 }
 
+/// heap space ([u8; KERNEL_HEAP_SIZE])
 static mut HEAP_SPACE: [u8; KERNEL_HEAP_SIZE] = [0; KERNEL_HEAP_SIZE];
 
+/// initiate heap allocator
 pub fn init_heap() {
     unsafe {
         HEAP_ALLOCATOR
diff --git a/ch4/src/os/mm/memory_set.rs.html b/ch4/src/os/mm/memory_set.rs.html
index 5ebca1b9..8cf139d6 100644
--- a/ch4/src/os/mm/memory_set.rs.html
+++ b/ch4/src/os/mm/memory_set.rs.html
@@ -343,7 +343,16 @@
 340
 341
 342
-
use super::{frame_alloc, FrameTracker};
+343
+344
+345
+346
+347
+348
+349
+
//! Implementation of [`MapArea`] and [`MemorySet`].
+
+use super::{frame_alloc, FrameTracker};
 use super::{PTEFlags, PageTable, PageTableEntry};
 use super::{PhysAddr, PhysPageNum, VirtAddr, VirtPageNum};
 use super::{StepByOne, VPNRange};
@@ -370,10 +379,12 @@
 }
 
 lazy_static! {
+	/// a memory set instance through lazy_static! managing kernel space
     pub static ref KERNEL_SPACE: Arc<UPSafeCell<MemorySet>> =
         Arc::new(unsafe { UPSafeCell::new(MemorySet::new_kernel()) });
 }
 
+/// memory set structure, controls virtual-memory space
 pub struct MemorySet {
     page_table: PageTable,
     areas: Vec<MapArea>,
@@ -561,6 +572,7 @@
     }
 }
 
+/// map area structure, controls a contiguous piece of virtual memory
 pub struct MapArea {
     vpn_range: VPNRange,
     data_frames: BTreeMap<VirtPageNum, FrameTracker>,
@@ -642,12 +654,14 @@
 }
 
 #[derive(Copy, Clone, PartialEq, Debug)]
+/// map type for memory set: identical or framed
 pub enum MapType {
     Identical,
     Framed,
 }
 
 bitflags! {
+    /// map permission corresponding to that in pte: `R W X U`
     pub struct MapPermission: u8 {
         const R = 1 << 1;
         const W = 1 << 2;
diff --git a/ch4/src/os/mm/mod.rs.html b/ch4/src/os/mm/mod.rs.html
index b260ee5c..91f140ba 100644
--- a/ch4/src/os/mm/mod.rs.html
+++ b/ch4/src/os/mm/mod.rs.html
@@ -20,7 +20,26 @@
 17
 18
 19
-
mod address;
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+
//! Memory management implementation
+//! 
+//! SV39 page-based virtual-memory architecture for RV64 systems, and
+//! everything about memory management, like frame allocator, page table,
+//! map area and memory set, is implemented here.
+//! 
+//! Every task or process has a memory_set to control its virtual memory.
+
+
+mod address;
 mod frame_allocator;
 mod heap_allocator;
 mod memory_set;
@@ -34,6 +53,7 @@
 pub use page_table::{translated_byte_buffer, PageTableEntry};
 use page_table::{PTEFlags, PageTable};
 
+/// initiate heap allocator, frame allocator and kernel space
 pub fn init() {
     heap_allocator::init_heap();
     frame_allocator::init_frame_allocator();
diff --git a/ch4/src/os/mm/page_table.rs.html b/ch4/src/os/mm/page_table.rs.html
index cc3c0a56..328cb2fa 100644
--- a/ch4/src/os/mm/page_table.rs.html
+++ b/ch4/src/os/mm/page_table.rs.html
@@ -152,12 +152,21 @@
 149
 150
 151
-
use super::{frame_alloc, FrameTracker, PhysPageNum, StepByOne, VirtAddr, VirtPageNum};
+152
+153
+154
+155
+156
+157
+
//! Implementation of [`PageTableEntry`] and [`PageTable`].
+
+use super::{frame_alloc, FrameTracker, PhysPageNum, StepByOne, VirtAddr, VirtPageNum};
 use alloc::vec;
 use alloc::vec::Vec;
 use bitflags::*;
 
 bitflags! {
+    /// page table entry flags
     pub struct PTEFlags: u8 {
         const V = 1 << 0;
         const R = 1 << 1;
@@ -172,6 +181,7 @@
 
 #[derive(Copy, Clone)]
 #[repr(C)]
+/// page table entry structure
 pub struct PageTableEntry {
     pub bits: usize,
 }
@@ -205,6 +215,7 @@
     }
 }
 
+/// page table structure
 pub struct PageTable {
     root_ppn: PhysPageNum,
     frames: Vec<FrameTracker>,
@@ -282,6 +293,7 @@
     }
 }
 
+/// translate a pointer to a mutable u8 Vec through page table
 pub fn translated_byte_buffer(token: usize, ptr: *const u8, len: usize) -> Vec<&'static mut [u8]> {
     let page_table = PageTable::from_token(token);
     let mut start = ptr as usize;
diff --git a/ch4/src/os/sbi.rs.html b/ch4/src/os/sbi.rs.html
index 3d51abc8..c633ab77 100644
--- a/ch4/src/os/sbi.rs.html
+++ b/ch4/src/os/sbi.rs.html
@@ -46,21 +46,27 @@
 43
 44
 45
-
#![allow(unused)]
+46
+47
+48
+49
+50
+
//! SBI call wrappers
 
 use core::arch::asm;
 
 const SBI_SET_TIMER: usize = 0;
 const SBI_CONSOLE_PUTCHAR: usize = 1;
-const SBI_CONSOLE_GETCHAR: usize = 2;
-const SBI_CLEAR_IPI: usize = 3;
-const SBI_SEND_IPI: usize = 4;
-const SBI_REMOTE_FENCE_I: usize = 5;
-const SBI_REMOTE_SFENCE_VMA: usize = 6;
-const SBI_REMOTE_SFENCE_VMA_ASID: usize = 7;
+// const SBI_CONSOLE_GETCHAR: usize = 2;
+// const SBI_CLEAR_IPI: usize = 3;
+// const SBI_SEND_IPI: usize = 4;
+// const SBI_REMOTE_FENCE_I: usize = 5;
+// const SBI_REMOTE_SFENCE_VMA: usize = 6;
+// const SBI_REMOTE_SFENCE_VMA_ASID: usize = 7;
 const SBI_SHUTDOWN: usize = 8;
 
 #[inline(always)]
+/// general sbi call
 fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
     let mut ret;
     unsafe {
@@ -75,18 +81,22 @@
     ret
 }
 
+/// use sbi call to set timer
 pub fn set_timer(timer: usize) {
     sbi_call(SBI_SET_TIMER, timer, 0, 0);
 }
 
+/// use sbi call to putchar in console (qemu uart handler)
 pub fn console_putchar(c: usize) {
     sbi_call(SBI_CONSOLE_PUTCHAR, c, 0, 0);
 }
 
-pub fn console_getchar() -> usize {
-    sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0)
-}
+/// use sbi call to getchar from console (qemu uart handler)
+// pub fn console_getchar() -> usize {
+//     sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0)
+// }
 
+/// use sbi call to shutdown the kernel
 pub fn shutdown() -> ! {
     sbi_call(SBI_SHUTDOWN, 0, 0, 0);
     panic!("It should shutdown!");
diff --git a/ch4/src/os/sync/mod.rs.html b/ch4/src/os/sync/mod.rs.html
index 625d8d9d..4bd5e3b3 100644
--- a/ch4/src/os/sync/mod.rs.html
+++ b/ch4/src/os/sync/mod.rs.html
@@ -4,7 +4,11 @@
                                 Change settings
1
 2
 3
-
mod up;
+4
+5
+
//! Synchronization and interior mutability primitives
+
+mod up;
 
 pub use up::UPSafeCell;
 
diff --git a/ch4/src/os/sync/up.rs.html b/ch4/src/os/sync/up.rs.html index 8e982968..45704751 100644 --- a/ch4/src/os/sync/up.rs.html +++ b/ch4/src/os/sync/up.rs.html @@ -30,7 +30,11 @@ 27 28 29 -
use core::cell::{RefCell, RefMut};
+30
+31
+
//! Uniprocessor interior mutability primitives
+
+use core::cell::{RefCell, RefMut};
 
 /// Wrap a static data structure inside it so that we are
 /// able to access it without any `unsafe`.
@@ -54,7 +58,7 @@
             inner: RefCell::new(value),
         }
     }
-    /// Panic if the data has been borrowed.
+    /// Exclusive access inner data in UPSafeCell. Panic if the data has been borrowed.
     pub fn exclusive_access(&self) -> RefMut<'_, T> {
         self.inner.borrow_mut()
     }
diff --git a/ch4/src/os/syscall/fs.rs.html b/ch4/src/os/syscall/fs.rs.html
index dba0dfc2..6abfadd2 100644
--- a/ch4/src/os/syscall/fs.rs.html
+++ b/ch4/src/os/syscall/fs.rs.html
@@ -20,11 +20,17 @@
 17
 18
 19
-
use crate::mm::translated_byte_buffer;
+20
+21
+22
+
//! File and filesystem-related syscalls
+
+use crate::mm::translated_byte_buffer;
 use crate::task::current_user_token;
 
 const FD_STDOUT: usize = 1;
 
+/// write buf of length `len`  to a file with `fd`
 pub fn sys_write(fd: usize, buf: *const u8, len: usize) -> isize {
     match fd {
         FD_STDOUT => {
diff --git a/ch4/src/os/syscall/mod.rs.html b/ch4/src/os/syscall/mod.rs.html
index 2ef133f3..0e5502f5 100644
--- a/ch4/src/os/syscall/mod.rs.html
+++ b/ch4/src/os/syscall/mod.rs.html
@@ -21,7 +21,32 @@
 18
 19
 20
-
const SYSCALL_WRITE: usize = 64;
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+
//! Implementation of syscalls
+//!
+//! The single entry point to all system calls, [`syscall()`], is called
+//! whenever userspace wishes to perform a system call using the `ecall`
+//! instruction. In this case, the processor raises an 'Environment call from
+//! U-mode' exception, which is handled as one of the cases in
+//! [`crate::trap::trap_handler`].
+//!
+//! For clarity, each single syscall is implemented as its own function, named
+//! `sys_` then the name of the syscall. You can find functions like this in
+//! submodules, and you should also implement syscalls this way.
+
+const SYSCALL_WRITE: usize = 64;
 const SYSCALL_EXIT: usize = 93;
 const SYSCALL_YIELD: usize = 124;
 const SYSCALL_GET_TIME: usize = 169;
@@ -32,6 +57,7 @@
 use fs::*;
 use process::*;
 
+/// handle syscall exception with `syscall_id` and other arguments
 pub fn syscall(syscall_id: usize, args: [usize; 3]) -> isize {
     match syscall_id {
         SYSCALL_WRITE => sys_write(args[0], args[1] as *const u8, args[2]),
diff --git a/ch4/src/os/syscall/process.rs.html b/ch4/src/os/syscall/process.rs.html
index 6401ea98..b26c891a 100644
--- a/ch4/src/os/syscall/process.rs.html
+++ b/ch4/src/os/syscall/process.rs.html
@@ -18,20 +18,30 @@
 15
 16
 17
-
use crate::task::{exit_current_and_run_next, suspend_current_and_run_next};
+18
+19
+20
+21
+22
+
//! Process management syscalls
+
+use crate::task::{exit_current_and_run_next, suspend_current_and_run_next};
 use crate::timer::get_time_ms;
 
+/// task exits and submit an exit code
 pub fn sys_exit(exit_code: i32) -> ! {
     println!("[kernel] Application exited with code {}", exit_code);
     exit_current_and_run_next();
     panic!("Unreachable in sys_exit!");
 }
 
+/// current task gives up resources for other tasks
 pub fn sys_yield() -> isize {
     suspend_current_and_run_next();
     0
 }
 
+/// get current time 
 pub fn sys_get_time() -> isize {
     get_time_ms() as isize
 }
diff --git a/ch4/src/os/task/context.rs.html b/ch4/src/os/task/context.rs.html
index 61884b80..7d051ec5 100644
--- a/ch4/src/os/task/context.rs.html
+++ b/ch4/src/os/task/context.rs.html
@@ -26,16 +26,29 @@
 23
 24
 25
-
use crate::trap::trap_return;
+26
+27
+28
+29
+30
+31
+32
+
//! Implementation of [`TaskContext`]
+use crate::trap::trap_return;
 
 #[repr(C)]
+/// task context structure containing some registers
 pub struct TaskContext {
+    /// return address ( e.g. __restore ) of __switch ASM function
     ra: usize,
+    /// kernel stack pointer of app
     sp: usize,
+    /// callee saved registers:  s 0..11
     s: [usize; 12],
 }
 
 impl TaskContext {
+    /// init task context
     pub fn zero_init() -> Self {
         Self {
             ra: 0,
@@ -43,6 +56,7 @@
             s: [0; 12],
         }
     }
+    /// set Task Context{__restore ASM funciton: trap_return, sp: kstack_ptr, s: s_0..12}
     pub fn goto_trap_return(kstack_ptr: usize) -> Self {
         Self {
             ra: trap_return as usize,
diff --git a/ch4/src/os/task/mod.rs.html b/ch4/src/os/task/mod.rs.html
index 19cf5a14..1056993b 100644
--- a/ch4/src/os/task/mod.rs.html
+++ b/ch4/src/os/task/mod.rs.html
@@ -145,7 +145,66 @@
 142
 143
 144
-
mod context;
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+
//! Task management implementation
+//!
+//! Everything about task management, like starting and switching tasks is
+//! implemented here.
+//!
+//! A single global instance of [`TaskManager`] called `TASK_MANAGER` controls
+//! all the tasks in the operating system.
+//!
+//! Be careful when you see `__switch` ASM function in `switch.S`. Control flow around this function
+//! might not be what you expect.
+
+mod context;
 mod switch;
 #[allow(clippy::module_inception)]
 mod task;
@@ -160,17 +219,32 @@
 
 pub use context::TaskContext;
 
+/// The task manager, where all the tasks are managed.
+///
+/// Functions implemented on `TaskManager` deals with all task state transitions
+/// and task context switching. For convenience, you can find wrappers around it
+/// in the module level.
+///
+/// Most of `TaskManager` are hidden behind the field `inner`, to defer
+/// borrowing checks to runtime. You can see examples on how to use `inner` in
+/// existing functions on `TaskManager`.
 pub struct TaskManager {
+    /// total number of tasks
     num_app: usize,
+    /// use inner value to get mutable access
     inner: UPSafeCell<TaskManagerInner>,
 }
 
+/// The task manager inner in 'UPSafeCell'
 struct TaskManagerInner {
+    /// task list
     tasks: Vec<TaskControlBlock>,
+    /// id of current `Running` task
     current_task: usize,
 }
 
 lazy_static! {
+    /// a `TaskManager` global instance through lazy_static!
     pub static ref TASK_MANAGER: TaskManager = {
         println!("init TASK_MANAGER");
         let num_app = get_num_app();
@@ -192,6 +266,10 @@
 }
 
 impl TaskManager {
+    /// Run the first task in task list.
+    ///
+    /// Generally, the first task in task list is an idle task (we call it zero process later).
+    /// But in ch4, we load apps statically, so the first task is a real app.
     fn run_first_task(&self) -> ! {
         let mut inner = self.inner.exclusive_access();
         let next_task = &mut inner.tasks[0];
@@ -206,18 +284,23 @@
         panic!("unreachable in run_first_task!");
     }
 
+    /// Change the status of current `Running` task into `Ready`.
     fn mark_current_suspended(&self) {
         let mut inner = self.inner.exclusive_access();
         let cur = inner.current_task;
         inner.tasks[cur].task_status = TaskStatus::Ready;
     }
 
+    /// Change the status of current `Running` task into `Exited`.
     fn mark_current_exited(&self) {
         let mut inner = self.inner.exclusive_access();
         let cur = inner.current_task;
         inner.tasks[cur].task_status = TaskStatus::Exited;
     }
 
+    /// Find next task to run and return task id.
+    ///
+    /// In this case, we only return the first `Ready` task in task list.
     fn find_next_task(&self) -> Option<usize> {
         let inner = self.inner.exclusive_access();
         let current = inner.current_task;
@@ -226,16 +309,20 @@
             .find(|id| inner.tasks[*id].task_status == TaskStatus::Ready)
     }
 
+    /// Get the current 'Running' task's token.
     fn get_current_token(&self) -> usize {
         let inner = self.inner.exclusive_access();
         inner.tasks[inner.current_task].get_user_token()
     }
 
+    /// Get the current 'Running' task's trap contexts.
     fn get_current_trap_cx(&self) -> &'static mut TrapContext {
         let inner = self.inner.exclusive_access();
         inner.tasks[inner.current_task].get_trap_cx()
     }
 
+    /// Switch current `Running` task to the task we have found,
+    /// or there is no `Ready` task and we can exit with all applications completed
     fn run_next_task(&self) {
         if let Some(next) = self.find_next_task() {
             let mut inner = self.inner.exclusive_access();
@@ -256,36 +343,45 @@
     }
 }
 
+/// Run the first task in task list.
 pub fn run_first_task() {
     TASK_MANAGER.run_first_task();
 }
 
+/// Switch current `Running` task to the task we have found,
+/// or there is no `Ready` task and we can exit with all applications completed
 fn run_next_task() {
     TASK_MANAGER.run_next_task();
 }
 
+/// Change the status of current `Running` task into `Ready`.
 fn mark_current_suspended() {
     TASK_MANAGER.mark_current_suspended();
 }
 
+/// Change the status of current `Running` task into `Exited`.
 fn mark_current_exited() {
     TASK_MANAGER.mark_current_exited();
 }
 
+/// Suspend the current 'Running' task and run the next task in task list.
 pub fn suspend_current_and_run_next() {
     mark_current_suspended();
     run_next_task();
 }
 
+/// Exit the current 'Running' task and run the next task in task list.
 pub fn exit_current_and_run_next() {
     mark_current_exited();
     run_next_task();
 }
 
+/// Get the current 'Running' task's token.
 pub fn current_user_token() -> usize {
     TASK_MANAGER.get_current_token()
 }
 
+/// Get the current 'Running' task's trap contexts.
 pub fn current_trap_cx() -> &'static mut TrapContext {
     TASK_MANAGER.get_current_trap_cx()
 }
diff --git a/ch4/src/os/task/switch.rs.html b/ch4/src/os/task/switch.rs.html
index 416474a8..76d5419e 100644
--- a/ch4/src/os/task/switch.rs.html
+++ b/ch4/src/os/task/switch.rs.html
@@ -1,20 +1,34 @@
 switch.rs - source
     
1
-2
-3
-4
-5
-6
-7
-8
-
use super::TaskContext;
-use core::arch::global_asm;
+                                
Change settings
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+
//! Rust wrapper around `__switch`.
+//!
+//! Switching to a different task's context happens here. The actual
+//! implementation must not be in Rust and (essentially) has to be in assembly
+//! language (Do you know why?), so this module really is just a wrapper around
+//! `switch.S`.
 
-global_asm!(include_str!("switch.S"));
+core::arch::global_asm!(include_str!("switch.S"));
+use super::TaskContext;
 
 extern "C" {
+    /// Switch to the context of `next_task_cx_ptr`, saving the current context
+    /// in `current_task_cx_ptr`.
     pub fn __switch(current_task_cx_ptr: *mut TaskContext, next_task_cx_ptr: *const TaskContext);
 }
 
diff --git a/ch4/src/os/task/task.rs.html b/ch4/src/os/task/task.rs.html index 951f5ad0..a1705475 100644 --- a/ch4/src/os/task/task.rs.html +++ b/ch4/src/os/task/task.rs.html @@ -62,11 +62,16 @@ 59 60 61 -
use super::TaskContext;
+62
+63
+64
+
//! Types related to task management
+use super::TaskContext;
 use crate::config::{kernel_stack_position, TRAP_CONTEXT};
 use crate::mm::{MapPermission, MemorySet, PhysPageNum, VirtAddr, KERNEL_SPACE};
 use crate::trap::{trap_handler, TrapContext};
 
+/// task control block structure
 pub struct TaskControlBlock {
     pub task_status: TaskStatus,
     pub task_cx: TaskContext,
@@ -118,6 +123,7 @@
 }
 
 #[derive(Copy, Clone, PartialEq)]
+/// task status: UnInit, Ready, Running, Exited
 pub enum TaskStatus {
     Ready,
     Running,
diff --git a/ch4/src/os/timer.rs.html b/ch4/src/os/timer.rs.html
index 5244b163..14fcdf3e 100644
--- a/ch4/src/os/timer.rs.html
+++ b/ch4/src/os/timer.rs.html
@@ -19,7 +19,13 @@
 16
 17
 18
-
use crate::config::CLOCK_FREQ;
+19
+20
+21
+22
+
//! RISC-V timer-related functionality
+
+use crate::config::CLOCK_FREQ;
 use crate::sbi::set_timer;
 use riscv::register::time;
 
@@ -30,10 +36,12 @@
     time::read()
 }
 
+/// get current time in microseconds
 pub fn get_time_ms() -> usize {
     time::read() / (CLOCK_FREQ / MSEC_PER_SEC)
 }
 
+/// set the next timer interrupt
 pub fn set_next_trigger() {
     set_timer(get_time() + CLOCK_FREQ / TICKS_PER_SEC);
 }
diff --git a/ch4/src/os/trap/context.rs.html b/ch4/src/os/trap/context.rs.html
index f44ed68b..38e9692e 100644
--- a/ch4/src/os/trap/context.rs.html
+++ b/ch4/src/os/trap/context.rs.html
@@ -38,22 +38,44 @@
 35
 36
 37
-
use riscv::register::sstatus::{self, Sstatus, SPP};
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+
//! Implementation of [`TrapContext`]
+
+use riscv::register::sstatus::{self, Sstatus, SPP};
 
 #[repr(C)]
+/// trap context structure containing sstatus, sepc and registers
 pub struct TrapContext {
+    /// general regs[0..31]
     pub x: [usize; 32],
+    /// CSR sstatus      
     pub sstatus: Sstatus,
+    /// CSR sepc
     pub sepc: usize,
+    /// Addr of Page Table
     pub kernel_satp: usize,
+    /// kernel stack
     pub kernel_sp: usize,
+    /// Addr of trap_handler function
     pub trap_handler: usize,
 }
 
 impl TrapContext {
+    /// set stack pointer to x_2 reg (sp)
     pub fn set_sp(&mut self, sp: usize) {
         self.x[2] = sp;
     }
+    /// init app context
     pub fn app_init_context(
         entry: usize,
         sp: usize,
@@ -61,18 +83,18 @@
         kernel_sp: usize,
         trap_handler: usize,
     ) -> Self {
-        let mut sstatus = sstatus::read();
-        sstatus.set_spp(SPP::User);
+        let mut sstatus = sstatus::read(); // CSR sstatus
+        sstatus.set_spp(SPP::User); //previous privilege mode: user mode
         let mut cx = Self {
             x: [0; 32],
             sstatus,
-            sepc: entry,
-            kernel_satp,
-            kernel_sp,
-            trap_handler,
+            sepc: entry, // entry point of app
+            kernel_satp, // addr of page table
+            kernel_sp,   // kernel stack
+            trap_handler,// addr of trap_handler function
         };
-        cx.set_sp(sp);
-        cx
+        cx.set_sp(sp); // app's user stack pointer
+        cx // return initial Trap Context of app
     }
 }
 
diff --git a/ch4/src/os/trap/mod.rs.html b/ch4/src/os/trap/mod.rs.html index f8905a23..65415f1e 100644 --- a/ch4/src/os/trap/mod.rs.html +++ b/ch4/src/os/trap/mod.rs.html @@ -103,7 +103,41 @@ 100 101 102 -
mod context;
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+
//! Trap handling functionality
+//!
+//! For rCore, we have a single trap entry point, namely `__alltraps`. At
+//! initialization in [`init()`], we set the `stvec` CSR to point to it.
+//!
+//! All traps go through `__alltraps`, which is defined in `trap.S`. The
+//! assembly language code does just enough work restore the kernel space
+//! context, ensuring that Rust code safely runs, and transfers control to
+//! [`trap_handler()`].
+//!
+//! It then calls different functionality based on what exactly the exception
+//! was. For example, timer interrupts trigger task preemption, and syscalls go
+//! to [`syscall()`].
+mod context;
 
 use crate::config::{TRAMPOLINE, TRAP_CONTEXT};
 use crate::syscall::syscall;
@@ -120,6 +154,7 @@
 
 global_asm!(include_str!("trap.S"));
 
+/// initialize CSR `stvec` as the entry of `__alltraps`
 pub fn init() {
     set_kernel_trap_entry();
 }
@@ -136,6 +171,7 @@
     }
 }
 
+/// enable timer interrupt in sie CSR
 pub fn enable_timer_interrupt() {
     unsafe {
         sie::set_stimer();
@@ -143,6 +179,7 @@
 }
 
 #[no_mangle]
+/// handle an interrupt, exception, or system call from user space
 pub fn trap_handler() -> ! {
     set_kernel_trap_entry();
     let cx = current_trap_cx();
@@ -178,6 +215,9 @@
 }
 
 #[no_mangle]
+/// set the new addr of __restore asm function in TRAMPOLINE page,
+/// set the reg a0 = trap_cx_ptr, reg a1 = phy addr of usr page table,
+/// finally, jump to new addr of __restore asm function
 pub fn trap_return() -> ! {
     set_user_trap_entry();
     let trap_cx_ptr = TRAP_CONTEXT;
@@ -190,16 +230,18 @@
     unsafe {
         asm!(
             "fence.i",
-            "jr {restore_va}",
+            "jr {restore_va}",             // jump to new addr of __restore asm function
             restore_va = in(reg) restore_va,
-            in("a0") trap_cx_ptr,
-            in("a1") user_satp,
+            in("a0") trap_cx_ptr,      // a0 = virt addr of Trap Context
+            in("a1") user_satp,        // a1 = phy addr of usr page table
             options(noreturn)
         );
     }
 }
 
 #[no_mangle]
+/// Unimplement: traps/interrupts/exceptions from kernel mode
+/// Todo: Chapter 9: I/O device 
 pub fn trap_from_kernel() -> ! {
     panic!("a trap from kernel!");
 }