diff --git a/ch3/implementors/core/marker/trait.Freeze.js b/ch3/implementors/core/marker/trait.Freeze.js index 06cfc49c..f3e60d05 100644 --- a/ch3/implementors/core/marker/trait.Freeze.js +++ b/ch3/implementors/core/marker/trait.Freeze.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["os"] = [{"text":"impl Freeze for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Freeze for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl Freeze for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> !Freeze for UPSafeCell<T>","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl Freeze for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl Freeze for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl Freeze for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl !Freeze for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl Freeze for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl Freeze for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl Freeze for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; +implementors["os"] = [{"text":"impl Freeze for RISCV64","synthetic":true,"types":["os::board::RISCV64"]},{"text":"impl Freeze for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Freeze for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl Freeze for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> !Freeze for UPSafeCell<T>","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl Freeze for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl Freeze for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl Freeze for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl !Freeze for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl Freeze for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl Freeze for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl Freeze for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch3/implementors/core/marker/trait.Send.js b/ch3/implementors/core/marker/trait.Send.js index 477ead66..3bdeb42a 100644 --- a/ch3/implementors/core/marker/trait.Send.js +++ b/ch3/implementors/core/marker/trait.Send.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["os"] = [{"text":"impl Send for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Send for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl Send for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> Send for UPSafeCell<T> where
    T: Send
","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl Send for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl Send for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl Send for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl Send for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl Send for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl Send for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl Send for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; +implementors["os"] = [{"text":"impl Send for RISCV64","synthetic":true,"types":["os::board::RISCV64"]},{"text":"impl Send for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Send for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl Send for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> Send for UPSafeCell<T> where
    T: Send
","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl Send for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl Send for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl Send for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl Send for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl Send for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl Send for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl Send for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch3/implementors/core/marker/trait.Sync.js b/ch3/implementors/core/marker/trait.Sync.js index dac9ac10..fbe2855d 100644 --- a/ch3/implementors/core/marker/trait.Sync.js +++ b/ch3/implementors/core/marker/trait.Sync.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["os"] = [{"text":"impl Sync for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Sync for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl Sync for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl Sync for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl Sync for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl Sync for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl Sync for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl Sync for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl Sync for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl Sync for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]},{"text":"impl<T> Sync for UPSafeCell<T>","synthetic":false,"types":["os::sync::up::UPSafeCell"]}]; +implementors["os"] = [{"text":"impl Sync for RISCV64","synthetic":true,"types":["os::board::RISCV64"]},{"text":"impl Sync for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Sync for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl Sync for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl Sync for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl Sync for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl Sync for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl Sync for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl Sync for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl Sync for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl Sync for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]},{"text":"impl<T> Sync for UPSafeCell<T>","synthetic":false,"types":["os::sync::up::UPSafeCell"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch3/implementors/core/marker/trait.Unpin.js b/ch3/implementors/core/marker/trait.Unpin.js index eb193db4..f5152aa0 100644 --- a/ch3/implementors/core/marker/trait.Unpin.js +++ b/ch3/implementors/core/marker/trait.Unpin.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["os"] = [{"text":"impl Unpin for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Unpin for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl Unpin for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> Unpin for UPSafeCell<T> where
    T: Unpin
","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl Unpin for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl Unpin for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl Unpin for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl Unpin for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl Unpin for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl Unpin for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl Unpin for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; +implementors["os"] = [{"text":"impl Unpin for RISCV64","synthetic":true,"types":["os::board::RISCV64"]},{"text":"impl Unpin for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Unpin for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl Unpin for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> Unpin for UPSafeCell<T> where
    T: Unpin
","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl Unpin for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl Unpin for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl Unpin for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl Unpin for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl Unpin for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl Unpin for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl Unpin for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch3/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js b/ch3/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js index 563cd9a0..fef03468 100644 --- a/ch3/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js +++ b/ch3/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["os"] = [{"text":"impl RefUnwindSafe for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl RefUnwindSafe for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl RefUnwindSafe for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> !RefUnwindSafe for UPSafeCell<T>","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl RefUnwindSafe for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl RefUnwindSafe for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl RefUnwindSafe for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl !RefUnwindSafe for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl RefUnwindSafe for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl RefUnwindSafe for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl RefUnwindSafe for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; +implementors["os"] = [{"text":"impl RefUnwindSafe for RISCV64","synthetic":true,"types":["os::board::RISCV64"]},{"text":"impl RefUnwindSafe for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl RefUnwindSafe for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl RefUnwindSafe for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> !RefUnwindSafe for UPSafeCell<T>","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl RefUnwindSafe for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl RefUnwindSafe for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl RefUnwindSafe for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl !RefUnwindSafe for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl RefUnwindSafe for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl RefUnwindSafe for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl RefUnwindSafe for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch3/implementors/core/panic/unwind_safe/trait.UnwindSafe.js b/ch3/implementors/core/panic/unwind_safe/trait.UnwindSafe.js index f156d0d2..2a051a16 100644 --- a/ch3/implementors/core/panic/unwind_safe/trait.UnwindSafe.js +++ b/ch3/implementors/core/panic/unwind_safe/trait.UnwindSafe.js @@ -1,3 +1,3 @@ (function() {var implementors = {}; -implementors["os"] = [{"text":"impl UnwindSafe for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl UnwindSafe for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl UnwindSafe for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> UnwindSafe for UPSafeCell<T> where
    T: UnwindSafe
","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl UnwindSafe for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl UnwindSafe for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl UnwindSafe for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl UnwindSafe for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl UnwindSafe for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl UnwindSafe for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl UnwindSafe for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; +implementors["os"] = [{"text":"impl UnwindSafe for RISCV64","synthetic":true,"types":["os::board::RISCV64"]},{"text":"impl UnwindSafe for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl UnwindSafe for KernelStack","synthetic":true,"types":["os::loader::KernelStack"]},{"text":"impl UnwindSafe for UserStack","synthetic":true,"types":["os::loader::UserStack"]},{"text":"impl<T> UnwindSafe for UPSafeCell<T> where
    T: UnwindSafe
","synthetic":true,"types":["os::sync::up::UPSafeCell"]},{"text":"impl UnwindSafe for TaskContext","synthetic":true,"types":["os::task::context::TaskContext"]},{"text":"impl UnwindSafe for TaskControlBlock","synthetic":true,"types":["os::task::task::TaskControlBlock"]},{"text":"impl UnwindSafe for TaskStatus","synthetic":true,"types":["os::task::task::TaskStatus"]},{"text":"impl UnwindSafe for TaskManager","synthetic":true,"types":["os::task::TaskManager"]},{"text":"impl UnwindSafe for TaskManagerInner","synthetic":true,"types":["os::task::TaskManagerInner"]},{"text":"impl UnwindSafe for TASK_MANAGER","synthetic":true,"types":["os::task::TASK_MANAGER"]},{"text":"impl UnwindSafe for TrapContext","synthetic":true,"types":["os::trap::context::TrapContext"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch3/implementors/os/board/trait.QEMUExit.js b/ch3/implementors/os/board/trait.QEMUExit.js new file mode 100644 index 00000000..34fffcbd --- /dev/null +++ b/ch3/implementors/os/board/trait.QEMUExit.js @@ -0,0 +1,3 @@ +(function() {var implementors = {}; +implementors["os"] = []; +if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch3/os/all.html b/ch3/os/all.html index c9916611..354d1f9f 100644 --- a/ch3/os/all.html +++ b/ch3/os/all.html @@ -3,5 +3,5 @@

List of all items

Structs

Enums

Macros

Functions

Statics

Constants

+

Crate os

List of all items

Structs

Enums

Traits

Macros

Functions

Statics

Constants

\ No newline at end of file diff --git a/ch3/os/board/constant.EXIT_FAILURE.html b/ch3/os/board/constant.EXIT_FAILURE.html new file mode 100644 index 00000000..a9c07dec --- /dev/null +++ b/ch3/os/board/constant.EXIT_FAILURE.html @@ -0,0 +1,8 @@ +EXIT_FAILURE in os::board - Rust + +
+

Constant os::board::EXIT_FAILURE

source · []
const EXIT_FAILURE: u32 = exit_code_encode(1); // 78_643u32
+ \ No newline at end of file diff --git a/ch3/os/board/constant.EXIT_FAILURE_FLAG.html b/ch3/os/board/constant.EXIT_FAILURE_FLAG.html new file mode 100644 index 00000000..d87a6320 --- /dev/null +++ b/ch3/os/board/constant.EXIT_FAILURE_FLAG.html @@ -0,0 +1,8 @@ +EXIT_FAILURE_FLAG in os::board - Rust + +
const EXIT_FAILURE_FLAG: u32 = 0x3333;
+ \ No newline at end of file diff --git a/ch3/os/sbi/constant.SBI_SHUTDOWN.html b/ch3/os/board/constant.EXIT_RESET.html similarity index 52% rename from ch3/os/sbi/constant.SBI_SHUTDOWN.html rename to ch3/os/board/constant.EXIT_RESET.html index 52b49945..9550ab95 100644 --- a/ch3/os/sbi/constant.SBI_SHUTDOWN.html +++ b/ch3/os/board/constant.EXIT_RESET.html @@ -1,8 +1,8 @@ -SBI_SHUTDOWN in os::sbi - Rust +EXIT_RESET in os::board - Rust
-

Constant os::sbi::SBI_SHUTDOWN

source · []
const SBI_SHUTDOWN: usize = 8;
+
+

Constant os::board::EXIT_RESET

source · []
const EXIT_RESET: u32 = 0x7777;
\ No newline at end of file diff --git a/ch3/os/board/constant.EXIT_SUCCESS.html b/ch3/os/board/constant.EXIT_SUCCESS.html new file mode 100644 index 00000000..769c562c --- /dev/null +++ b/ch3/os/board/constant.EXIT_SUCCESS.html @@ -0,0 +1,8 @@ +EXIT_SUCCESS in os::board - Rust + +
+

Constant os::board::EXIT_SUCCESS

source · []
const EXIT_SUCCESS: u32 = 0x5555;
+ \ No newline at end of file diff --git a/ch3/os/board/constant.QEMU_EXIT_HANDLE.html b/ch3/os/board/constant.QEMU_EXIT_HANDLE.html new file mode 100644 index 00000000..1b1fd9e3 --- /dev/null +++ b/ch3/os/board/constant.QEMU_EXIT_HANDLE.html @@ -0,0 +1,8 @@ +QEMU_EXIT_HANDLE in os::board - Rust + +
pub const QEMU_EXIT_HANDLE: RISCV64;
+ \ No newline at end of file diff --git a/ch3/os/board/constant.VIRT_TEST.html b/ch3/os/board/constant.VIRT_TEST.html new file mode 100644 index 00000000..87f078f3 --- /dev/null +++ b/ch3/os/board/constant.VIRT_TEST.html @@ -0,0 +1,8 @@ +VIRT_TEST in os::board - Rust + +
+

Constant os::board::VIRT_TEST

source · []
const VIRT_TEST: u64 = 0x100000;
+ \ No newline at end of file diff --git a/ch3/os/board/fn.exit_code_encode.html b/ch3/os/board/fn.exit_code_encode.html new file mode 100644 index 00000000..f284354e --- /dev/null +++ b/ch3/os/board/fn.exit_code_encode.html @@ -0,0 +1,9 @@ +exit_code_encode in os::board - Rust + +
const fn exit_code_encode(code: u32) -> u32
Expand description

Encode the exit code using EXIT_FAILURE_FLAG.

+
+ \ No newline at end of file diff --git a/ch3/os/board/index.html b/ch3/os/board/index.html index 6e57a39d..fcc54881 100644 --- a/ch3/os/board/index.html +++ b/ch3/os/board/index.html @@ -1,10 +1,15 @@ -os::board - Rust +os::board - Rust
-

Module os::board

source · []
Expand description

Constants used in rCore for K210 devel board

-

Constants

-
+

Module board

+

Module os::board

source · []
Expand description

Constants used in rCore for qemu

+

Structs

+

RISCV64 configuration

+

Constants

+

Traits

+

Functions

+

Encode the exit code using EXIT_FAILURE_FLAG.

+
\ No newline at end of file diff --git a/ch3/os/board/sidebar-items.js b/ch3/os/board/sidebar-items.js index 3e4f2eb7..afb7e2db 100644 --- a/ch3/os/board/sidebar-items.js +++ b/ch3/os/board/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"constant":[["CLOCK_FREQ",""]]}); \ No newline at end of file +initSidebarItems({"constant":[["CLOCK_FREQ",""],["EXIT_FAILURE",""],["EXIT_FAILURE_FLAG",""],["EXIT_RESET",""],["EXIT_SUCCESS",""],["QEMU_EXIT_HANDLE",""],["VIRT_TEST",""]],"fn":[["exit_code_encode","Encode the exit code using EXIT_FAILURE_FLAG."]],"struct":[["RISCV64","RISCV64 configuration"]],"trait":[["QEMUExit",""]]}); \ No newline at end of file diff --git a/ch3/os/board/struct.RISCV64.html b/ch3/os/board/struct.RISCV64.html new file mode 100644 index 00000000..d7b05920 --- /dev/null +++ b/ch3/os/board/struct.RISCV64.html @@ -0,0 +1,27 @@ +RISCV64 in os::board - Rust + +
+

Struct os::board::RISCV64

source · []
pub struct RISCV64 {
+    addr: u64,
+}
Expand description

RISCV64 configuration

+

Fields

addr: u64

Address of the sifive_test mapped device.

+

Implementations

Create an instance.

+

Trait Implementations

Exit qemu with specified exit code.

+

Exit QEMU using EXIT_SUCCESS, aka 0, if possible. Read more

+

Exit QEMU using EXIT_FAILURE, aka 1.

+

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

+

Returns the argument unchanged.

+

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+

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/ch3/os/board/trait.QEMUExit.html b/ch3/os/board/trait.QEMUExit.html new file mode 100644 index 00000000..b50c8ad5 --- /dev/null +++ b/ch3/os/board/trait.QEMUExit.html @@ -0,0 +1,17 @@ +QEMUExit in os::board - Rust + +
pub trait QEMUExit {
+    fn exit(&self, code: u32) -> !;
+    fn exit_success(&self) -> !;
+    fn exit_failure(&self) -> !;
+}

Required methods

Exit with specified return code.

+

Note: For X86, code is binary-OR’ed with 0x1 inside QEMU.

+

Exit QEMU using EXIT_SUCCESS, aka 0, if possible.

+

Note: Not possible for X86.

+

Exit QEMU using EXIT_FAILURE, aka 1.

+

Implementors

+ \ No newline at end of file diff --git a/ch3/os/index.html b/ch3/os/index.html index abb9ced0..f94fc709 100644 --- a/ch3/os/index.html +++ b/ch3/os/index.html @@ -19,7 +19,7 @@ details.)

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

Modules

-
board 🔒

Constants used in rCore for K210 devel board

+
board 🔒

Constants used in rCore for qemu

config 🔒

Constants used in rCore

console 🔒

SBI console driver, for text output

lang_items 🔒

The panic handler

diff --git a/ch3/os/sbi/fn.console_putchar.html b/ch3/os/sbi/fn.console_putchar.html index 29dbf260..a12b56d9 100644 --- a/ch3/os/sbi/fn.console_putchar.html +++ b/ch3/os/sbi/fn.console_putchar.html @@ -4,6 +4,6 @@
pub fn console_putchar(c: usize)
Expand description

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

+

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/ch3/os/sbi/fn.sbi_call.html b/ch3/os/sbi/fn.sbi_call.html index 3a23d6f7..36f2a25f 100644 --- a/ch3/os/sbi/fn.sbi_call.html +++ b/ch3/os/sbi/fn.sbi_call.html @@ -4,6 +4,6 @@
-

Function os::sbi::sbi_call

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

handle SBI call with which SBI_id and other arguments

+

Function os::sbi::sbi_call

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

handle SBI call with which SBI_id and other arguments

\ No newline at end of file diff --git a/ch3/os/sbi/fn.set_timer.html b/ch3/os/sbi/fn.set_timer.html index afd1ed95..3045a210 100644 --- a/ch3/os/sbi/fn.set_timer.html +++ b/ch3/os/sbi/fn.set_timer.html @@ -4,6 +4,6 @@
-

Function os::sbi::set_timer

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

use sbi call to set timer

+

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/ch3/os/sbi/fn.shutdown.html b/ch3/os/sbi/fn.shutdown.html index c2a12377..bd570877 100644 --- a/ch3/os/sbi/fn.shutdown.html +++ b/ch3/os/sbi/fn.shutdown.html @@ -1,10 +1,9 @@ -shutdown in os::sbi - Rust +shutdown in os::sbi - Rust
-

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

+

Function os::sbi::shutdown

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

use sbi call to shutdown the kernel

\ No newline at end of file diff --git a/ch3/os/sbi/index.html b/ch3/os/sbi/index.html index 8a064ea7..7e0596d7 100644 --- a/ch3/os/sbi/index.html +++ b/ch3/os/sbi/index.html @@ -4,13 +4,12 @@
-

Module os::sbi

source · []
Expand description

SBI call wrappers

+

Module os::sbi

source · []
Expand description

SBI call wrappers

Constants

-

Functions

+

Functions

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

sbi_call 🔒

handle SBI call with which SBI_id and other arguments

use sbi call to set timer

-

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

+

use sbi call to shutdown the kernel

\ No newline at end of file diff --git a/ch3/os/sbi/sidebar-items.js b/ch3/os/sbi/sidebar-items.js index e7897b40..049cd83f 100644 --- a/ch3/os/sbi/sidebar-items.js +++ b/ch3/os/sbi/sidebar-items.js @@ -1 +1 @@ -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","handle SBI call with `which` SBI_id and other arguments"],["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 +initSidebarItems({"constant":[["SBI_CONSOLE_PUTCHAR",""],["SBI_SET_TIMER",""]],"fn":[["console_putchar","use sbi call to putchar in console (qemu uart handler)"],["sbi_call","handle SBI call with `which` SBI_id and other arguments"],["set_timer","use sbi call to set timer"],["shutdown","use sbi call to shutdown the kernel"]]}); \ No newline at end of file diff --git a/ch3/os/sidebar-items.js b/ch3/os/sidebar-items.js index 5033c832..812146ee 100644 --- a/ch3/os/sidebar-items.js +++ b/ch3/os/sidebar-items.js @@ -1 +1 @@ -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","Constants used in rCore for K210 devel board"],["config","Constants used in rCore"],["console","SBI console driver, for text output"],["lang_items","The panic handler"],["loader","Loading user applications into memory"],["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 +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","Constants used in rCore for qemu"],["config","Constants used in rCore"],["console","SBI console driver, for text output"],["lang_items","The panic handler"],["loader","Loading user applications into memory"],["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/ch3/os/task/fn.exit_current_and_run_next.html b/ch3/os/task/fn.exit_current_and_run_next.html index c5a29517..8452d373 100644 --- a/ch3/os/task/fn.exit_current_and_run_next.html +++ b/ch3/os/task/fn.exit_current_and_run_next.html @@ -4,6 +4,6 @@
pub fn exit_current_and_run_next()
Expand description

exit current task, then run next task

+

Function os::task::exit_current_and_run_next

source · []
pub fn exit_current_and_run_next()
Expand description

exit current task, then run next task

\ No newline at end of file diff --git a/ch3/os/task/fn.mark_current_exited.html b/ch3/os/task/fn.mark_current_exited.html index 5a7636b8..0a8b1d7b 100644 --- a/ch3/os/task/fn.mark_current_exited.html +++ b/ch3/os/task/fn.mark_current_exited.html @@ -4,6 +4,6 @@
fn mark_current_exited()
Expand description

exit current task

+

Function os::task::mark_current_exited

source · []
fn mark_current_exited()
Expand description

exit current task

\ No newline at end of file diff --git a/ch3/os/task/fn.mark_current_suspended.html b/ch3/os/task/fn.mark_current_suspended.html index b569fd29..e35a4aa6 100644 --- a/ch3/os/task/fn.mark_current_suspended.html +++ b/ch3/os/task/fn.mark_current_suspended.html @@ -4,6 +4,6 @@
fn mark_current_suspended()
Expand description

suspend current task

+

Function os::task::mark_current_suspended

source · []
fn mark_current_suspended()
Expand description

suspend current task

\ No newline at end of file diff --git a/ch3/os/task/fn.run_first_task.html b/ch3/os/task/fn.run_first_task.html index 0997f73e..1151964d 100644 --- a/ch3/os/task/fn.run_first_task.html +++ b/ch3/os/task/fn.run_first_task.html @@ -4,6 +4,6 @@
pub fn run_first_task()
Expand description

run first task

+

Function os::task::run_first_task

source · []
pub fn run_first_task()
Expand description

run first task

\ No newline at end of file diff --git a/ch3/os/task/fn.run_next_task.html b/ch3/os/task/fn.run_next_task.html index c338adeb..1e040fc9 100644 --- a/ch3/os/task/fn.run_next_task.html +++ b/ch3/os/task/fn.run_next_task.html @@ -4,6 +4,6 @@
-

Function os::task::run_next_task

source · []
fn run_next_task()
Expand description

rust next task

+

Function os::task::run_next_task

source · []
fn run_next_task()
Expand description

rust next task

\ No newline at end of file diff --git a/ch3/os/task/fn.suspend_current_and_run_next.html b/ch3/os/task/fn.suspend_current_and_run_next.html index eb65639f..5f163b16 100644 --- a/ch3/os/task/fn.suspend_current_and_run_next.html +++ b/ch3/os/task/fn.suspend_current_and_run_next.html @@ -4,6 +4,6 @@
pub fn suspend_current_and_run_next()
Expand description

suspend current task, then run next task

+

Function os::task::suspend_current_and_run_next

source · []
pub fn suspend_current_and_run_next()
Expand description

suspend current task, then run next task

\ No newline at end of file diff --git a/ch3/os/task/index.html b/ch3/os/task/index.html index ff39ad00..5c47cde1 100644 --- a/ch3/os/task/index.html +++ b/ch3/os/task/index.html @@ -4,7 +4,7 @@
-

Module os::task

source · []
Expand description

Task management implementation

+

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 diff --git a/ch3/os/task/struct.TASK_MANAGER.html b/ch3/os/task/struct.TASK_MANAGER.html index b263d87b..115bcfb3 100644 --- a/ch3/os/task/struct.TASK_MANAGER.html +++ b/ch3/os/task/struct.TASK_MANAGER.html @@ -14,7 +14,7 @@ But in ch3, we load apps statically, so the first task is a real app.

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.

-

Switch current Running task to the task we have found, +

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.

diff --git a/ch3/os/task/struct.TaskManager.html b/ch3/os/task/struct.TaskManager.html index 3bf3c62c..4fca9064 100644 --- a/ch3/os/task/struct.TaskManager.html +++ b/ch3/os/task/struct.TaskManager.html @@ -16,14 +16,14 @@ borrowing checks to runtime. You can see examples on how to use innerTaskManager.

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.

+

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 ch3, 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.

-

Switch current Running task to the task we have found, +

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

diff --git a/ch3/search-index.js b/ch3/search-index.js index 36a488f1..9cae1c2f 100644 --- a/ch3/search-index.js +++ b/ch3/search-index.js @@ -1,4 +1,4 @@ var searchIndex = JSON.parse('{\ -"os":{"doc":"The main module and entrypoint","t":[0,5,0,0,0,0,14,14,5,0,0,0,0,0,0,17,17,17,17,17,17,3,11,11,11,11,5,11,11,11,11,5,7,3,7,3,11,11,11,11,11,11,12,12,11,11,5,5,11,11,5,11,11,5,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,11,5,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,11,12,12,12,11,11,11,11,5,13,13,13,3,4,13,11,11,11,11,11,11,11,11,11,11,11,12,12,11,11,11,11,11,11,17,17,5,5,5,3,0,5,5,12,12,5,12,3,11,11,11,11,11,12,11,12,11,11,11,12],"n":["board","clear_bss","config","console","lang_items","loader","print","println","rust_main","sbi","sync","syscall","task","timer","trap","CLOCK_FREQ","APP_BASE_ADDRESS","APP_SIZE_LIMIT","KERNEL_STACK_SIZE","MAX_APP_NUM","USER_STACK_SIZE","Stdout","borrow","borrow_mut","from","into","print","try_from","try_into","type_id","write_str","panic","KERNEL_STACK","KernelStack","USER_STACK","UserStack","borrow","borrow","borrow_mut","borrow_mut","clone","clone","data","data","from","from","get_base_i","get_num_app","get_sp","get_sp","init_app_cx","into","into","load_apps","push_context","try_from","try_from","try_into","try_into","type_id","type_id","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","deref","exit_current_and_run_next","find_next_task","from","from","from","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","clone","from","goto_restore","into","ra","s","sp","try_from","try_into","type_id","zero_init","__switch","Exited","Ready","Running","TaskControlBlock","TaskStatus","UnInit","borrow","borrow","borrow_mut","borrow_mut","clone","clone","eq","from","from","into","into","task_cx","task_status","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","sepc","sstatus","trap_handler","x","TrapContext","app_init_context","borrow","borrow_mut","from","into","sepc","set_sp","sstatus","try_from","try_into","type_id","x"],"q":["os","","","","","","","","","","","","","","","os::board","os::config","","","","","os::console","","","","","","","","","","os::lang_items","os::loader","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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":["Constants used in rCore for K210 devel board","clear BSS segment","Constants used in rCore","SBI console driver, for text output","The panic handler","Loading user applications into memory","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","","","","","","","","","","Returns the argument unchanged.","Calls U::from(self).","","","","","","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Get base address of app i.","Get the total number of applications.","","","get app info with entry and sp and save TrapContext in …","Calls U::from(self).","Calls U::from(self).","Load nth user app at [APP_BASE_ADDRESS + n * …","","","","","","","","","","","use sbi call to putchar in console (qemu uart handler)","handle SBI call with which SBI_id and other arguments","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 …","Returns the argument unchanged.","inner data","Calls U::from(self).","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 time in milliseconds","current task gives up resources for other tasks","Global variable: TASK_MANAGER","Task Context","The task manager, where all the tasks are managed.","Inner of Task Manager","","","","","","","","Implementation of TaskContext","id of current Running task","","exit current task, then run next task","Find next task to run and return task id.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","use inner value to get mutable access","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","exit current task","Change the status of current Running task into Exited.","suspend current task","Change the status of current Running task into Ready.","total number of tasks","return address ( e.g. __restore ) of __switch ASM function","run first task","Run the first task in task list.","rust next task","Switch current Running task to the task we have found, or …","callee saved registers: s 0..11","kernel stack pointer of app","suspend current task, then run next task","Rust wrapper around __switch.","Types related to task management","task list","","","","","","","","","","Task Context","","","","Returns the argument unchanged.","set task context {__restore ASM funciton, kernel stack, …","Calls U::from(self).","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 …","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Calls U::from(self).","Calls U::from(self).","","","","","","","","","","","read the mtime register","get current time in milliseconds","set the next timer interrupt","Trap Context","","timer interrupt enabled","initialize CSR stvec as the entry of __alltraps","CSR sepc","CSR sstatus ","handle an interrupt, exception, or system call from user …","general regs[0..31]","Trap Context","init app context","","","Returns the argument unchanged.","Calls U::from(self).","CSR sepc","set stack pointer to x_2 reg (sp)","CSR sstatus ","","","","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,1,1,1,1,0,1,1,1,1,0,0,0,0,0,2,3,2,3,2,3,2,3,2,3,0,0,2,3,0,2,3,0,2,2,3,2,3,2,3,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,6,7,5,6,7,5,0,7,5,0,6,6,7,5,6,6,7,5,0,6,0,6,6,8,0,6,0,6,8,8,0,0,0,7,6,7,5,6,7,5,6,7,5,0,8,8,8,8,8,8,8,8,8,8,8,8,8,0,9,9,9,0,0,9,10,9,10,9,10,9,9,10,9,10,9,10,10,10,9,10,9,10,9,0,0,0,0,0,0,0,0,0,11,11,0,11,0,11,11,11,11,11,11,11,11,11,11,11,11],"f":[null,[[]],null,null,null,null,null,null,[[],["never",0]],null,null,null,null,null,null,null,null,null,null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[]],[[]],[[["arguments",3]]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0],["str",0]],["result",6]],[[["panicinfo",3]],["never",0]],null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["kernelstack",3]],[[["",0]],["userstack",3]],null,null,[[]],[[]],[[["usize",0]],["usize",0]],[[],["usize",0]],[[["",0]],["usize",0]],[[["",0]],["usize",0]],[[["usize",0]],["usize",0]],[[]],[[]],[[]],[[["",0],["trapcontext",3]],["usize",0]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],null,null,null,[[["usize",0]]],[[["usize",0],["usize",0],["usize",0],["usize",0]],["usize",0]],[[["usize",0]]],[[],["never",0]],null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["refmut",3]],[[]],null,[[]],[[]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],null,null,null,null,null,null,[[["usize",0]],["isize",0]],null,[[["usize",0],["usize",0]],["isize",0]],[[["i32",0]],["never",0]],[[],["isize",0]],[[],["isize",0]],null,null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],null,null,[[["",0]],["taskmanager",3]],[[]],[[["",0]],["option",4,[["usize",0]]]],[[]],[[]],[[]],null,[[]],[[]],[[]],[[]],[[["",0]]],[[]],[[["",0]]],null,null,[[]],[[["",0]],["never",0]],[[]],[[["",0]]],null,null,[[]],null,null,null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["taskcontext",3]],[[]],[[["usize",0]]],[[]],null,null,null,[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[]],null,null,null,null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["taskcontrolblock",3]],[[["",0]],["taskstatus",4]],[[["",0],["taskstatus",4]],["bool",0]],[[]],[[]],[[]],[[]],null,null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],null,null,[[],["usize",0]],[[],["usize",0]],[[]],null,null,[[]],[[]],null,null,[[["trapcontext",3]],["trapcontext",3]],null,null,[[["usize",0],["usize",0]]],[[["",0]],["",0]],[[["",0]],["",0]],[[]],[[]],null,[[["",0],["usize",0]]],null,[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],null],"p":[[3,"Stdout"],[3,"KernelStack"],[3,"UserStack"],[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,14,14,5,0,0,0,0,0,0,17,17,17,17,17,8,17,3,17,12,11,11,10,11,5,10,11,10,11,11,11,11,11,11,11,17,17,17,17,17,3,11,11,11,11,5,11,11,11,11,5,7,3,7,3,11,11,11,11,11,11,12,12,11,11,5,5,11,11,5,11,11,5,11,11,11,11,11,11,11,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,11,5,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,11,12,12,12,11,11,11,11,5,13,13,13,3,4,13,11,11,11,11,11,11,11,11,11,11,11,12,12,11,11,11,11,11,11,17,17,5,5,5,3,0,5,5,12,12,5,12,3,11,11,11,11,11,12,11,12,11,11,11,12],"n":["board","clear_bss","config","console","lang_items","loader","print","println","rust_main","sbi","sync","syscall","task","timer","trap","CLOCK_FREQ","EXIT_FAILURE","EXIT_FAILURE_FLAG","EXIT_RESET","EXIT_SUCCESS","QEMUExit","QEMU_EXIT_HANDLE","RISCV64","VIRT_TEST","addr","borrow","borrow_mut","exit","exit","exit_code_encode","exit_failure","exit_failure","exit_success","exit_success","from","into","new","try_from","try_into","type_id","APP_BASE_ADDRESS","APP_SIZE_LIMIT","KERNEL_STACK_SIZE","MAX_APP_NUM","USER_STACK_SIZE","Stdout","borrow","borrow_mut","from","into","print","try_from","try_into","type_id","write_str","panic","KERNEL_STACK","KernelStack","USER_STACK","UserStack","borrow","borrow","borrow_mut","borrow_mut","clone","clone","data","data","from","from","get_base_i","get_num_app","get_sp","get_sp","init_app_cx","into","into","load_apps","push_context","try_from","try_from","try_into","try_into","type_id","type_id","SBI_CONSOLE_PUTCHAR","SBI_SET_TIMER","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","deref","exit_current_and_run_next","find_next_task","from","from","from","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","clone","from","goto_restore","into","ra","s","sp","try_from","try_into","type_id","zero_init","__switch","Exited","Ready","Running","TaskControlBlock","TaskStatus","UnInit","borrow","borrow","borrow_mut","borrow_mut","clone","clone","eq","from","from","into","into","task_cx","task_status","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","sepc","sstatus","trap_handler","x","TrapContext","app_init_context","borrow","borrow_mut","from","into","sepc","set_sp","sstatus","try_from","try_into","type_id","x"],"q":["os","","","","","","","","","","","","","","","os::board","","","","","","","","","","","","","","","","","","","","","","","","","os::config","","","","","os::console","","","","","","","","","","os::lang_items","os::loader","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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":["Constants used in rCore for qemu","clear BSS segment","Constants used in rCore","SBI console driver, for text output","The panic handler","Loading user applications into memory","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","","","","","","","","RISCV64 configuration","","Address of the sifive_test mapped device.","","","Exit with specified return code.","Exit qemu with specified exit code.","Encode the exit code using EXIT_FAILURE_FLAG.","Exit QEMU using EXIT_FAILURE, aka 1.","","Exit QEMU using EXIT_SUCCESS, aka 0, if possible.","","Returns the argument unchanged.","Calls U::from(self).","Create an instance.","","","","","","","","","","","","Returns the argument unchanged.","Calls U::from(self).","","","","","","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Get base address of app i.","Get the total number of applications.","","","get app info with entry and sp and save TrapContext in …","Calls U::from(self).","Calls U::from(self).","Load nth user app at [APP_BASE_ADDRESS + n * …","","","","","","","","","","use sbi call to putchar in console (qemu uart handler)","handle SBI call with which SBI_id and other arguments","use sbi call to set timer","use sbi call to shutdown the kernel","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 …","Returns the argument unchanged.","inner data","Calls U::from(self).","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 time in milliseconds","current task gives up resources for other tasks","Global variable: TASK_MANAGER","Task Context","The task manager, where all the tasks are managed.","Inner of Task Manager","","","","","","","","Implementation of TaskContext","id of current Running task","","exit current task, then run next task","Find next task to run and return task id.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","use inner value to get mutable access","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","exit current task","Change the status of current Running task into Exited.","suspend current task","Change the status of current Running task into Ready.","total number of tasks","return address ( e.g. __restore ) of __switch ASM function","run first task","Run the first task in task list.","rust next task","Switch current Running task to the task we have found, or …","callee saved registers: s 0..11","kernel stack pointer of app","suspend current task, then run next task","Rust wrapper around __switch.","Types related to task management","task list","","","","","","","","","","Task Context","","","","Returns the argument unchanged.","set task context {__restore ASM funciton, kernel stack, …","Calls U::from(self).","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 …","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Calls U::from(self).","Calls U::from(self).","","","","","","","","","","","read the mtime register","get current time in milliseconds","set the next timer interrupt","Trap Context","","timer interrupt enabled","initialize CSR stvec as the entry of __alltraps","CSR sepc","CSR sstatus ","handle an interrupt, exception, or system call from user …","general regs[0..31]","Trap Context","init app context","","","Returns the argument unchanged.","Calls U::from(self).","CSR sepc","set stack pointer to x_2 reg (sp)","CSR sstatus ","","","","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,1,1,1,2,1,0,2,1,2,1,1,1,1,1,1,1,0,0,0,0,0,0,3,3,3,3,0,3,3,3,3,0,0,0,0,0,4,5,4,5,4,5,4,5,4,5,0,0,4,5,0,4,5,0,4,4,5,4,5,4,5,0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,8,9,7,8,9,7,0,9,7,0,8,8,9,7,8,8,9,7,0,8,0,8,8,10,0,8,0,8,10,10,0,0,0,9,8,9,7,8,9,7,8,9,7,0,10,10,10,10,10,10,10,10,10,10,10,10,10,0,11,11,11,0,0,11,12,11,12,11,12,11,11,12,11,12,11,12,12,12,11,12,11,12,11,0,0,0,0,0,0,0,0,0,13,13,0,13,0,13,13,13,13,13,13,13,13,13,13,13,13],"f":[null,[[]],null,null,null,null,null,null,[[],["never",0]],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0],["u32",0]],["never",0]],[[["",0],["u32",0]],["never",0]],[[["u32",0]],["u32",0]],[[["",0]],["never",0]],[[["",0]],["never",0]],[[["",0]],["never",0]],[[["",0]],["never",0]],[[]],[[]],[[["u64",0]]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],null,null,null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[]],[[]],[[["arguments",3]]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0],["str",0]],["result",6]],[[["panicinfo",3]],["never",0]],null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["kernelstack",3]],[[["",0]],["userstack",3]],null,null,[[]],[[]],[[["usize",0]],["usize",0]],[[],["usize",0]],[[["",0]],["usize",0]],[[["",0]],["usize",0]],[[["usize",0]],["usize",0]],[[]],[[]],[[]],[[["",0],["trapcontext",3]],["usize",0]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],null,null,[[["usize",0]]],[[["usize",0],["usize",0],["usize",0],["usize",0]],["usize",0]],[[["usize",0]]],[[],["never",0]],null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["refmut",3]],[[]],null,[[]],[[]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],null,null,null,null,null,null,[[["usize",0]],["isize",0]],null,[[["usize",0],["usize",0]],["isize",0]],[[["i32",0]],["never",0]],[[],["isize",0]],[[],["isize",0]],null,null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],null,null,[[["",0]],["taskmanager",3]],[[]],[[["",0]],["option",4,[["usize",0]]]],[[]],[[]],[[]],null,[[]],[[]],[[]],[[]],[[["",0]]],[[]],[[["",0]]],null,null,[[]],[[["",0]],["never",0]],[[]],[[["",0]]],null,null,[[]],null,null,null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["taskcontext",3]],[[]],[[["usize",0]]],[[]],null,null,null,[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[]],null,null,null,null,null,null,null,[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["",0]],[[["",0]],["taskcontrolblock",3]],[[["",0]],["taskstatus",4]],[[["",0],["taskstatus",4]],["bool",0]],[[]],[[]],[[]],[[]],null,null,[[],["result",4]],[[],["result",4]],[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],[[["",0]],["typeid",3]],null,null,[[],["usize",0]],[[],["usize",0]],[[]],null,null,[[]],[[]],null,null,[[["trapcontext",3]],["trapcontext",3]],null,null,[[["usize",0],["usize",0]]],[[["",0]],["",0]],[[["",0]],["",0]],[[]],[[]],null,[[["",0],["usize",0]]],null,[[],["result",4]],[[],["result",4]],[[["",0]],["typeid",3]],null],"p":[[3,"RISCV64"],[8,"QEMUExit"],[3,"Stdout"],[3,"KernelStack"],[3,"UserStack"],[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/ch3/src/os/boards/qemu.rs.html b/ch3/src/os/boards/qemu.rs.html index 8fcc206e..b4dcaaf5 100644 --- a/ch3/src/os/boards/qemu.rs.html +++ b/ch3/src/os/boards/qemu.rs.html @@ -6,9 +6,169 @@
1
 2
 3
-
//! Constants used in rCore for K210 devel board
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+
//! Constants used in rCore for qemu
 
 pub const CLOCK_FREQ: usize = 12500000;
+
+//ref:: https://github.com/andre-richter/qemu-exit
+use core::arch::asm;
+
+const EXIT_SUCCESS: u32 = 0x5555; // Equals `exit(0)`. qemu successful exit
+
+const EXIT_FAILURE_FLAG: u32 = 0x3333;
+const EXIT_FAILURE: u32 = exit_code_encode(1); // Equals `exit(1)`. qemu failed exit
+const EXIT_RESET: u32 = 0x7777; // qemu reset
+
+pub trait QEMUExit {
+    /// Exit with specified return code.
+    ///
+    /// Note: For `X86`, code is binary-OR'ed with `0x1` inside QEMU.
+    fn exit(&self, code: u32) -> !;
+
+    /// Exit QEMU using `EXIT_SUCCESS`, aka `0`, if possible.
+    ///
+    /// Note: Not possible for `X86`.
+    fn exit_success(&self) -> !;
+
+    /// Exit QEMU using `EXIT_FAILURE`, aka `1`.
+    fn exit_failure(&self) -> !;
+}
+
+/// RISCV64 configuration
+pub struct RISCV64 {
+    /// Address of the sifive_test mapped device.
+    addr: u64,
+}
+
+/// Encode the exit code using EXIT_FAILURE_FLAG.
+const fn exit_code_encode(code: u32) -> u32 {
+    (code << 16) | EXIT_FAILURE_FLAG
+}
+
+impl RISCV64 {
+    /// Create an instance.
+    pub const fn new(addr: u64) -> Self {
+        RISCV64 { addr }
+    }
+}
+
+impl QEMUExit for RISCV64 {
+    /// Exit qemu with specified exit code.
+    fn exit(&self, code: u32) -> ! {
+        // If code is not a special value, we need to encode it with EXIT_FAILURE_FLAG.
+        let code_new = match code {
+            EXIT_SUCCESS | EXIT_FAILURE | EXIT_RESET => code,
+            _ => exit_code_encode(code),
+        };
+
+        unsafe {
+            asm!(
+                "sw {0}, 0({1})",
+                in(reg)code_new, in(reg)self.addr
+            );
+
+            // For the case that the QEMU exit attempt did not work, transition into an infinite
+            // loop. Calling `panic!()` here is unfeasible, since there is a good chance
+            // this function here is the last expression in the `panic!()` handler
+            // itself. This prevents a possible infinite loop.
+            loop {
+                asm!("wfi", options(nomem, nostack));
+            }
+        }
+    }
+
+    fn exit_success(&self) -> ! {
+        self.exit(EXIT_SUCCESS);
+    }
+
+    fn exit_failure(&self) -> ! {
+        self.exit(EXIT_FAILURE);
+    }
+}
+
+const VIRT_TEST: u64 = 0x100000;
+
+pub const QEMU_EXIT_HANDLE: RISCV64 = RISCV64::new(VIRT_TEST);
 
\ No newline at end of file diff --git a/ch3/src/os/sbi.rs.html b/ch3/src/os/sbi.rs.html index 4d0991f7..f6669ab6 100644 --- a/ch3/src/os/sbi.rs.html +++ b/ch3/src/os/sbi.rs.html @@ -54,12 +54,24 @@ 49 50 51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61
//! SBI call wrappers
 
 use core::arch::asm;
 
 const SBI_SET_TIMER: usize = 0;
 const SBI_CONSOLE_PUTCHAR: usize = 1;
+
+#[cfg(feature = "board_k210")]
 const SBI_SHUTDOWN: usize = 8;
 // const SBI_CONSOLE_GETCHAR: usize = 2;
 // const SBI_CLEAR_IPI: usize = 3;
@@ -100,9 +112,17 @@
 //     sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0)
 // }
 
+#[cfg(feature = "board_qemu")]
+use crate::board::QEMUExit;
 /// use sbi call to shutdown the kernel
 pub fn shutdown() -> ! {
+    #[cfg(feature = "board_k210")]
     sbi_call(SBI_SHUTDOWN, 0, 0, 0);
+
+    #[cfg(feature = "board_qemu")]
+    crate::board::QEMU_EXIT_HANDLE.exit_failure();
+
+    #[cfg(feature = "board_k210")]
     panic!("It should shutdown!");
 }
 
diff --git a/ch3/src/os/task/mod.rs.html b/ch3/src/os/task/mod.rs.html index e8add938..f75c1dfa 100644 --- a/ch3/src/os/task/mod.rs.html +++ b/ch3/src/os/task/mod.rs.html @@ -174,6 +174,14 @@ 169 170 171 +172 +173 +174 +175 +176 +177 +178 +179
//! Task management implementation
 //!
 //! Everything about task management, like starting and switching tasks is
@@ -309,6 +317,14 @@
             }
             // go back to user mode
         } else {
+            println!("All applications completed!");
+
+            #[cfg(feature = "board_qemu")]
+            use crate::board::QEMUExit;
+            #[cfg(feature = "board_qemu")]
+            crate::board::QEMU_EXIT_HANDLE.exit_success();
+            
+            #[cfg(feature = "board_k210")]
             panic!("All applications completed!");
         }
     }