From d640294e5f3c3129d548a634ad70a2aacd437143 Mon Sep 17 00:00:00 2001 From: wyfcyx Date: Mon, 27 Mar 2023 16:07:29 +0000 Subject: [PATCH] deploy: 0b13333b90ab29357ae06135884c658d63e24555 --- ch1/implementors/core/marker/trait.Freeze.js | 2 +- ch1/implementors/core/marker/trait.Send.js | 2 +- ch1/implementors/core/marker/trait.Sync.js | 2 +- ch1/implementors/core/marker/trait.Unpin.js | 2 +- .../panic/unwind_safe/trait.RefUnwindSafe.js | 2 +- .../panic/unwind_safe/trait.UnwindSafe.js | 2 +- ch1/implementors/os/board/trait.QEMUExit.js | 3 - ch1/os/all.html | 2 +- ch1/os/board/constant.EXIT_FAILURE.html | 1 - ch1/os/board/constant.EXIT_FAILURE_FLAG.html | 1 - ch1/os/board/constant.EXIT_RESET.html | 1 - ch1/os/board/constant.EXIT_SUCCESS.html | 1 - ch1/os/board/constant.QEMU_EXIT_HANDLE.html | 1 - ch1/os/board/constant.VIRT_TEST.html | 1 - ch1/os/board/fn.exit_code_encode.html | 2 - ch1/os/board/index.html | 3 - ch1/os/board/sidebar-items.js | 1 - ch1/os/board/struct.RISCV64.html | 20 --- ch1/os/board/trait.QEMUExit.html | 10 -- ch1/os/fn.clear_bss.html | 2 +- ch1/os/fn.rust_main.html | 2 +- ch1/os/index.html | 4 +- ch1/os/sbi/constant.SBI_CONSOLE_GETCHAR.html | 1 - ch1/os/sbi/constant.SBI_CONSOLE_PUTCHAR.html | 1 - ch1/os/sbi/constant.SBI_SET_TIMER.html | 1 - ch1/os/sbi/constant.SBI_SHUTDOWN.html | 1 - ch1/os/sbi/fn.console_getchar.html | 2 +- ch1/os/sbi/fn.console_putchar.html | 2 +- ch1/os/sbi/fn.sbi_call.html | 1 - ch1/os/sbi/fn.shutdown.html | 2 +- ch1/os/sbi/index.html | 4 +- ch1/os/sbi/sidebar-items.js | 2 +- ch1/os/sidebar-items.js | 2 +- ch1/search-index.js | 2 +- ch1/source-files.js | 2 +- ch1/src/os/boards/qemu.rs.html | 160 ------------------ ch1/src/os/lang_items.rs.html | 2 +- ch1/src/os/main.rs.html | 12 +- ch1/src/os/sbi.rs.html | 60 ++----- 39 files changed, 36 insertions(+), 288 deletions(-) delete mode 100644 ch1/implementors/os/board/trait.QEMUExit.js delete mode 100644 ch1/os/board/constant.EXIT_FAILURE.html delete mode 100644 ch1/os/board/constant.EXIT_FAILURE_FLAG.html delete mode 100644 ch1/os/board/constant.EXIT_RESET.html delete mode 100644 ch1/os/board/constant.EXIT_SUCCESS.html delete mode 100644 ch1/os/board/constant.QEMU_EXIT_HANDLE.html delete mode 100644 ch1/os/board/constant.VIRT_TEST.html delete mode 100644 ch1/os/board/fn.exit_code_encode.html delete mode 100644 ch1/os/board/index.html delete mode 100644 ch1/os/board/sidebar-items.js delete mode 100644 ch1/os/board/struct.RISCV64.html delete mode 100644 ch1/os/board/trait.QEMUExit.html delete mode 100644 ch1/os/sbi/constant.SBI_CONSOLE_GETCHAR.html delete mode 100644 ch1/os/sbi/constant.SBI_CONSOLE_PUTCHAR.html delete mode 100644 ch1/os/sbi/constant.SBI_SET_TIMER.html delete mode 100644 ch1/os/sbi/constant.SBI_SHUTDOWN.html delete mode 100644 ch1/os/sbi/fn.sbi_call.html delete mode 100644 ch1/src/os/boards/qemu.rs.html diff --git a/ch1/implementors/core/marker/trait.Freeze.js b/ch1/implementors/core/marker/trait.Freeze.js index ec45eed4..991f1ddc 100644 --- a/ch1/implementors/core/marker/trait.Freeze.js +++ b/ch1/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 SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]},{"text":"impl Freeze for RISCV64","synthetic":true,"types":["os::board::RISCV64"]}]; +implementors["os"] = [{"text":"impl Freeze for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Freeze for SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch1/implementors/core/marker/trait.Send.js b/ch1/implementors/core/marker/trait.Send.js index 1c2ef31c..07032654 100644 --- a/ch1/implementors/core/marker/trait.Send.js +++ b/ch1/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 SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]},{"text":"impl Send for RISCV64","synthetic":true,"types":["os::board::RISCV64"]}]; +implementors["os"] = [{"text":"impl Send for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Send for SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch1/implementors/core/marker/trait.Sync.js b/ch1/implementors/core/marker/trait.Sync.js index 1de4414c..82d46aeb 100644 --- a/ch1/implementors/core/marker/trait.Sync.js +++ b/ch1/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 SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]},{"text":"impl Sync for RISCV64","synthetic":true,"types":["os::board::RISCV64"]}]; +implementors["os"] = [{"text":"impl Sync for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Sync for SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch1/implementors/core/marker/trait.Unpin.js b/ch1/implementors/core/marker/trait.Unpin.js index 032e7430..3d1bca7d 100644 --- a/ch1/implementors/core/marker/trait.Unpin.js +++ b/ch1/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 SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]},{"text":"impl Unpin for RISCV64","synthetic":true,"types":["os::board::RISCV64"]}]; +implementors["os"] = [{"text":"impl Unpin for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl Unpin for SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch1/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js b/ch1/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js index 64771d59..3df058fc 100644 --- a/ch1/implementors/core/panic/unwind_safe/trait.RefUnwindSafe.js +++ b/ch1/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 SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]},{"text":"impl RefUnwindSafe for RISCV64","synthetic":true,"types":["os::board::RISCV64"]}]; +implementors["os"] = [{"text":"impl RefUnwindSafe for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl RefUnwindSafe for SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch1/implementors/core/panic/unwind_safe/trait.UnwindSafe.js b/ch1/implementors/core/panic/unwind_safe/trait.UnwindSafe.js index 41f30f32..171f2862 100644 --- a/ch1/implementors/core/panic/unwind_safe/trait.UnwindSafe.js +++ b/ch1/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 SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]},{"text":"impl UnwindSafe for RISCV64","synthetic":true,"types":["os::board::RISCV64"]}]; +implementors["os"] = [{"text":"impl UnwindSafe for Stdout","synthetic":true,"types":["os::console::Stdout"]},{"text":"impl UnwindSafe for SimpleLogger","synthetic":true,"types":["os::logging::SimpleLogger"]}]; if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() \ No newline at end of file diff --git a/ch1/implementors/os/board/trait.QEMUExit.js b/ch1/implementors/os/board/trait.QEMUExit.js deleted file mode 100644 index 34fffcbd..00000000 --- a/ch1/implementors/os/board/trait.QEMUExit.js +++ /dev/null @@ -1,3 +0,0 @@ -(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/ch1/os/all.html b/ch1/os/all.html index 9a2c3641..9f831464 100644 --- a/ch1/os/all.html +++ b/ch1/os/all.html @@ -1 +1 @@ -List of all items in this crate
\ No newline at end of file +List of all items in this crate
\ No newline at end of file diff --git a/ch1/os/board/constant.EXIT_FAILURE.html b/ch1/os/board/constant.EXIT_FAILURE.html deleted file mode 100644 index ce980ff0..00000000 --- a/ch1/os/board/constant.EXIT_FAILURE.html +++ /dev/null @@ -1 +0,0 @@ -EXIT_FAILURE in os::board - Rust
const EXIT_FAILURE: u32 = _; // 78_643u32
\ No newline at end of file diff --git a/ch1/os/board/constant.EXIT_FAILURE_FLAG.html b/ch1/os/board/constant.EXIT_FAILURE_FLAG.html deleted file mode 100644 index 2e97e514..00000000 --- a/ch1/os/board/constant.EXIT_FAILURE_FLAG.html +++ /dev/null @@ -1 +0,0 @@ -EXIT_FAILURE_FLAG in os::board - Rust
const EXIT_FAILURE_FLAG: u32 = 0x3333;
\ No newline at end of file diff --git a/ch1/os/board/constant.EXIT_RESET.html b/ch1/os/board/constant.EXIT_RESET.html deleted file mode 100644 index b6711049..00000000 --- a/ch1/os/board/constant.EXIT_RESET.html +++ /dev/null @@ -1 +0,0 @@ -EXIT_RESET in os::board - Rust
const EXIT_RESET: u32 = 0x7777;
\ No newline at end of file diff --git a/ch1/os/board/constant.EXIT_SUCCESS.html b/ch1/os/board/constant.EXIT_SUCCESS.html deleted file mode 100644 index a539b563..00000000 --- a/ch1/os/board/constant.EXIT_SUCCESS.html +++ /dev/null @@ -1 +0,0 @@ -EXIT_SUCCESS in os::board - Rust
const EXIT_SUCCESS: u32 = 0x5555;
\ No newline at end of file diff --git a/ch1/os/board/constant.QEMU_EXIT_HANDLE.html b/ch1/os/board/constant.QEMU_EXIT_HANDLE.html deleted file mode 100644 index 7dbb59f3..00000000 --- a/ch1/os/board/constant.QEMU_EXIT_HANDLE.html +++ /dev/null @@ -1 +0,0 @@ -QEMU_EXIT_HANDLE in os::board - Rust
pub const QEMU_EXIT_HANDLE: RISCV64;
\ No newline at end of file diff --git a/ch1/os/board/constant.VIRT_TEST.html b/ch1/os/board/constant.VIRT_TEST.html deleted file mode 100644 index 2335c7e3..00000000 --- a/ch1/os/board/constant.VIRT_TEST.html +++ /dev/null @@ -1 +0,0 @@ -VIRT_TEST in os::board - Rust
const VIRT_TEST: u64 = 0x100000;
\ No newline at end of file diff --git a/ch1/os/board/fn.exit_code_encode.html b/ch1/os/board/fn.exit_code_encode.html deleted file mode 100644 index 8409dbc1..00000000 --- a/ch1/os/board/fn.exit_code_encode.html +++ /dev/null @@ -1,2 +0,0 @@ -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/ch1/os/board/index.html b/ch1/os/board/index.html deleted file mode 100644 index 096431a8..00000000 --- a/ch1/os/board/index.html +++ /dev/null @@ -1,3 +0,0 @@ -os::board - Rust

Module os::board

source · []

Structs

RISCV64 configuration

-

Constants

Traits

Functions

Encode the exit code using EXIT_FAILURE_FLAG.

-
\ No newline at end of file diff --git a/ch1/os/board/sidebar-items.js b/ch1/os/board/sidebar-items.js deleted file mode 100644 index 0e1f33a4..00000000 --- a/ch1/os/board/sidebar-items.js +++ /dev/null @@ -1 +0,0 @@ -window.SIDEBAR_ITEMS = {"constant":[["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/ch1/os/board/struct.RISCV64.html b/ch1/os/board/struct.RISCV64.html deleted file mode 100644 index 1d472127..00000000 --- a/ch1/os/board/struct.RISCV64.html +++ /dev/null @@ -1,20 +0,0 @@ -RISCV64 in os::board - Rust
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/ch1/os/board/trait.QEMUExit.html b/ch1/os/board/trait.QEMUExit.html deleted file mode 100644 index 5c224cb1..00000000 --- a/ch1/os/board/trait.QEMUExit.html +++ /dev/null @@ -1,10 +0,0 @@ -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/ch1/os/fn.clear_bss.html b/ch1/os/fn.clear_bss.html index ede9857f..7a914244 100644 --- a/ch1/os/fn.clear_bss.html +++ b/ch1/os/fn.clear_bss.html @@ -1,2 +1,2 @@ -clear_bss in os - Rust

Function os::clear_bss

source · []
pub fn clear_bss()
Expand description

clear BSS segment

+clear_bss in os - Rust

Function os::clear_bss

source · []
pub fn clear_bss()
Expand description

clear BSS segment

\ No newline at end of file diff --git a/ch1/os/fn.rust_main.html b/ch1/os/fn.rust_main.html index 129effbb..2a5c3d71 100644 --- a/ch1/os/fn.rust_main.html +++ b/ch1/os/fn.rust_main.html @@ -1,3 +1,3 @@ -rust_main in os - Rust

Function os::rust_main

source · []
#[no_mangle]
+rust_main in os - Rust

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/ch1/os/index.html b/ch1/os/index.html index 723168b2..24f6b697 100644 --- a/ch1/os/index.html +++ b/ch1/os/index.html @@ -1,10 +1,10 @@ -os - Rust

Crate os

source · []
Expand description

The main module and entrypoint

+os - Rust

Crate os

source · []
Expand description

The main module and entrypoint

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

We then call println! to display Hello, world!.

-

Modules

board 🔒
console 🔒

SBI console driver, for text output

+

Modules

console 🔒

SBI console driver, for text output

lang_items 🔒

The panic handler

logging 🔒
sbi 🔒

Macros

print string macro

println string macro

diff --git a/ch1/os/sbi/constant.SBI_CONSOLE_GETCHAR.html b/ch1/os/sbi/constant.SBI_CONSOLE_GETCHAR.html deleted file mode 100644 index 82709775..00000000 --- a/ch1/os/sbi/constant.SBI_CONSOLE_GETCHAR.html +++ /dev/null @@ -1 +0,0 @@ -SBI_CONSOLE_GETCHAR in os::sbi - Rust
const SBI_CONSOLE_GETCHAR: usize = 2;
\ No newline at end of file diff --git a/ch1/os/sbi/constant.SBI_CONSOLE_PUTCHAR.html b/ch1/os/sbi/constant.SBI_CONSOLE_PUTCHAR.html deleted file mode 100644 index 10915495..00000000 --- a/ch1/os/sbi/constant.SBI_CONSOLE_PUTCHAR.html +++ /dev/null @@ -1 +0,0 @@ -SBI_CONSOLE_PUTCHAR in os::sbi - Rust
const SBI_CONSOLE_PUTCHAR: usize = 1;
\ No newline at end of file diff --git a/ch1/os/sbi/constant.SBI_SET_TIMER.html b/ch1/os/sbi/constant.SBI_SET_TIMER.html deleted file mode 100644 index 0d9f9f56..00000000 --- a/ch1/os/sbi/constant.SBI_SET_TIMER.html +++ /dev/null @@ -1 +0,0 @@ -SBI_SET_TIMER in os::sbi - Rust
const SBI_SET_TIMER: usize = 0;
\ No newline at end of file diff --git a/ch1/os/sbi/constant.SBI_SHUTDOWN.html b/ch1/os/sbi/constant.SBI_SHUTDOWN.html deleted file mode 100644 index 7d6536c9..00000000 --- a/ch1/os/sbi/constant.SBI_SHUTDOWN.html +++ /dev/null @@ -1 +0,0 @@ -SBI_SHUTDOWN in os::sbi - Rust
const SBI_SHUTDOWN: usize = 8;
\ No newline at end of file diff --git a/ch1/os/sbi/fn.console_getchar.html b/ch1/os/sbi/fn.console_getchar.html index 05d6fe85..a86aadae 100644 --- a/ch1/os/sbi/fn.console_getchar.html +++ b/ch1/os/sbi/fn.console_getchar.html @@ -1,2 +1,2 @@ -console_getchar in os::sbi - Rust
pub fn console_getchar() -> usize
Expand description

use sbi call to getchar from console (qemu uart handler)

+console_getchar in os::sbi - Rust
pub fn console_getchar() -> usize
Expand description

use sbi call to getchar from console (qemu uart handler)

\ No newline at end of file diff --git a/ch1/os/sbi/fn.console_putchar.html b/ch1/os/sbi/fn.console_putchar.html index 39337ba8..d0471813 100644 --- a/ch1/os/sbi/fn.console_putchar.html +++ b/ch1/os/sbi/fn.console_putchar.html @@ -1,2 +1,2 @@ -console_putchar in os::sbi - Rust
pub fn console_putchar(c: usize)
Expand description

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

+console_putchar in os::sbi - Rust
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/ch1/os/sbi/fn.sbi_call.html b/ch1/os/sbi/fn.sbi_call.html deleted file mode 100644 index 3b16c63b..00000000 --- a/ch1/os/sbi/fn.sbi_call.html +++ /dev/null @@ -1 +0,0 @@ -sbi_call in os::sbi - Rust

Function os::sbi::sbi_call

source · []
fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize
\ No newline at end of file diff --git a/ch1/os/sbi/fn.shutdown.html b/ch1/os/sbi/fn.shutdown.html index 8bf42f48..f5d484ee 100644 --- a/ch1/os/sbi/fn.shutdown.html +++ b/ch1/os/sbi/fn.shutdown.html @@ -1,2 +1,2 @@ -shutdown in os::sbi - Rust

Function os::sbi::shutdown

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

use sbi call to shutdown the kernel

+shutdown in os::sbi - Rust

Function os::sbi::shutdown

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

use sbi call to shutdown the kernel

\ No newline at end of file diff --git a/ch1/os/sbi/index.html b/ch1/os/sbi/index.html index 8b1d1cf9..0fed43a0 100644 --- a/ch1/os/sbi/index.html +++ b/ch1/os/sbi/index.html @@ -1,4 +1,4 @@ -os::sbi - Rust

Module os::sbi

source · []

Constants

Functions

use sbi call to getchar from console (qemu uart handler)

+os::sbi - Rust

Module os::sbi

source · []

Functions

use sbi call to getchar from console (qemu uart handler)

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

-
sbi_call 🔒

use sbi call to shutdown the kernel

+

use sbi call to shutdown the kernel

\ No newline at end of file diff --git a/ch1/os/sbi/sidebar-items.js b/ch1/os/sbi/sidebar-items.js index 25833d7f..812e0a5d 100644 --- a/ch1/os/sbi/sidebar-items.js +++ b/ch1/os/sbi/sidebar-items.js @@ -1 +1 @@ -window.SIDEBAR_ITEMS = {"constant":[["SBI_CONSOLE_GETCHAR",""],["SBI_CONSOLE_PUTCHAR",""],["SBI_SET_TIMER",""],["SBI_SHUTDOWN",""]],"fn":[["console_getchar","use sbi call to getchar from console (qemu uart handler)"],["console_putchar","use sbi call to putchar in console (qemu uart handler)"],["sbi_call",""],["shutdown","use sbi call to shutdown the kernel"]]}; \ No newline at end of file +window.SIDEBAR_ITEMS = {"fn":[["console_getchar","use sbi call to getchar from console (qemu uart handler)"],["console_putchar","use sbi call to putchar in console (qemu uart handler)"],["shutdown","use sbi call to shutdown the kernel"]]}; \ No newline at end of file diff --git a/ch1/os/sidebar-items.js b/ch1/os/sidebar-items.js index 135edb8e..aac0d92c 100644 --- a/ch1/os/sidebar-items.js +++ b/ch1/os/sidebar-items.js @@ -1 +1 @@ -window.SIDEBAR_ITEMS = {"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",""],["console","SBI console driver, for text output"],["lang_items","The panic handler"],["logging",""],["sbi",""]]}; \ No newline at end of file +window.SIDEBAR_ITEMS = {"fn":[["clear_bss","clear BSS segment"],["rust_main","the rust entry-point of os"]],"macro":[["print","print string macro"],["println","println string macro"]],"mod":[["console","SBI console driver, for text output"],["lang_items","The panic handler"],["logging",""],["sbi",""]]}; \ No newline at end of file diff --git a/ch1/search-index.js b/ch1/search-index.js index ea0b1423..32deb147 100644 --- a/ch1/search-index.js +++ b/ch1/search-index.js @@ -1,5 +1,5 @@ var searchIndex = JSON.parse('{\ -"os":{"doc":"The main module and entrypoint","t":[0,5,0,0,0,14,14,5,0,17,17,17,17,8,17,3,17,12,11,11,10,11,5,10,11,10,11,11,11,11,11,11,11,3,11,11,11,11,5,11,11,11,11,5,3,11,11,11,11,11,5,11,11,11,11,11,17,17,17,17,5,5,5,5],"n":["board","clear_bss","console","lang_items","logging","print","println","rust_main","sbi","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","Stdout","borrow","borrow_mut","from","into","print","try_from","try_into","type_id","write_str","panic","SimpleLogger","borrow","borrow_mut","enabled","flush","from","init","into","log","try_from","try_into","type_id","SBI_CONSOLE_GETCHAR","SBI_CONSOLE_PUTCHAR","SBI_SET_TIMER","SBI_SHUTDOWN","console_getchar","console_putchar","sbi_call","shutdown"],"q":["os","","","","","","","","","os::board","","","","","","","","","","","","","","","","","","","","","","","","os::console","","","","","","","","","","os::lang_items","os::logging","","","","","","","","","","","","os::sbi","","","","","","",""],"d":["","clear BSS segment","SBI console driver, for text output","The panic handler","","print string macro","println string macro","the rust entry-point of os","","","","","","","","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.","","Calls U::from(self).","","","","","","","","","use sbi call to getchar from console (qemu uart handler)","use sbi call to putchar in console (qemu uart handler)","","use sbi call to shutdown the kernel"],"i":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,17,3,0,17,3,17,3,3,3,3,3,3,3,0,8,8,8,8,0,8,8,8,8,0,0,12,12,12,12,12,0,12,12,12,12,12,0,0,0,0,0,0,0,0],"f":[0,[[]],0,0,0,0,0,[[],1],0,0,0,0,0,0,0,0,0,0,[[]],[[]],[2,1],[[3,2],1],[2,2],[[],1],[3,1],[[],1],[3,1],[[]],[[]],[4,3],[[],5],[[],5],[[],6],0,[[]],[[]],[[]],[[]],[7],[[],5],[[],5],[[],6],[[8,9],10],[11,1],0,[[]],[[]],[[12,13],14],[12],[[]],[[]],[[]],[[12,15]],[[],5],[[],5],[[],6],0,0,0,0,[[],16],[16],[[16,16,16,16],16],[[],1]],"p":[[15,"never"],[15,"u32"],[3,"RISCV64"],[15,"u64"],[4,"Result"],[3,"TypeId"],[3,"Arguments"],[3,"Stdout"],[15,"str"],[6,"Result"],[3,"PanicInfo"],[3,"SimpleLogger"],[3,"Metadata"],[15,"bool"],[3,"Record"],[15,"usize"],[8,"QEMUExit"]]}\ +"os":{"doc":"The main module and entrypoint","t":[5,0,0,0,14,14,5,0,3,11,11,11,11,5,11,11,11,11,5,3,11,11,11,11,11,5,11,11,11,11,11,5,5,5],"n":["clear_bss","console","lang_items","logging","print","println","rust_main","sbi","Stdout","borrow","borrow_mut","from","into","print","try_from","try_into","type_id","write_str","panic","SimpleLogger","borrow","borrow_mut","enabled","flush","from","init","into","log","try_from","try_into","type_id","console_getchar","console_putchar","shutdown"],"q":["os","","","","","","","","os::console","","","","","","","","","","os::lang_items","os::logging","","","","","","","","","","","","os::sbi","",""],"d":["clear BSS segment","SBI console driver, for text output","The panic handler","","print string macro","println string macro","the rust entry-point of os","","","","","Returns the argument unchanged.","Calls U::from(self).","","","","","","","","","","","","Returns the argument unchanged.","","Calls U::from(self).","","","","","use sbi call to getchar from console (qemu uart handler)","use sbi call to putchar in console (qemu uart handler)","use sbi call to shutdown the kernel"],"i":[0,0,0,0,0,0,0,0,0,5,5,5,5,0,5,5,5,5,0,0,9,9,9,9,9,0,9,9,9,9,9,0,0,0],"f":[[[]],0,0,0,0,0,[[],1],0,0,[[]],[[]],[[]],[[]],[2],[[],3],[[],3],[[],4],[[5,6],7],[8,1],0,[[]],[[]],[[9,10],11],[9],[[]],[[]],[[]],[[9,12]],[[],3],[[],3],[[],4],[[],13],[13],[11,1]],"p":[[15,"never"],[3,"Arguments"],[4,"Result"],[3,"TypeId"],[3,"Stdout"],[15,"str"],[6,"Result"],[3,"PanicInfo"],[3,"SimpleLogger"],[3,"Metadata"],[15,"bool"],[3,"Record"],[15,"usize"]]}\ }'); if (typeof window !== 'undefined' && window.initSearch) {window.initSearch(searchIndex)}; if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex}; diff --git a/ch1/source-files.js b/ch1/source-files.js index c0d20547..2535a248 100644 --- a/ch1/source-files.js +++ b/ch1/source-files.js @@ -1,4 +1,4 @@ var sourcesIndex = JSON.parse('{\ -"os":["",[["boards",[],["qemu.rs"]]],["console.rs","lang_items.rs","logging.rs","main.rs","sbi.rs"]]\ +"os":["",[],["console.rs","lang_items.rs","logging.rs","main.rs","sbi.rs"]]\ }'); createSourceSidebar(); diff --git a/ch1/src/os/boards/qemu.rs.html b/ch1/src/os/boards/qemu.rs.html deleted file mode 100644 index 2f5825d1..00000000 --- a/ch1/src/os/boards/qemu.rs.html +++ /dev/null @@ -1,160 +0,0 @@ -qemu.rs - source
1
-2
-3
-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
-
//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/ch1/src/os/lang_items.rs.html b/ch1/src/os/lang_items.rs.html index 70d5d37b..7d6977bc 100644 --- a/ch1/src/os/lang_items.rs.html +++ b/ch1/src/os/lang_items.rs.html @@ -34,7 +34,7 @@ } else { println!("[kernel] Panicked: {}", info.message().unwrap()); } - shutdown() + shutdown(true) }
\ No newline at end of file diff --git a/ch1/src/os/main.rs.html b/ch1/src/os/main.rs.html index 45cb598f..555ba83d 100644 --- a/ch1/src/os/main.rs.html +++ b/ch1/src/os/main.rs.html @@ -74,9 +74,6 @@ 74 75 76 -77 -78 -79
//! The main module and entrypoint
 //!
 //! The operating system and app also starts in this module. Kernel code starts
@@ -101,9 +98,6 @@
 mod logging;
 mod sbi;
 
-#[path = "boards/qemu.rs"]
-mod board;
-
 global_asm!(include_str!("entry.asm"));
 
 /// clear BSS segment
@@ -152,9 +146,9 @@
     );
     error!("[kernel] .bss [{:#x}, {:#x})", sbss as usize, ebss as usize);
 
-    use crate::board::QEMUExit;
-    crate::board::QEMU_EXIT_HANDLE.exit_success(); // CI autotest success
-                                                   //crate::board::QEMU_EXIT_HANDLE.exit_failure(); // CI autoest failed
+    // CI autotest success: sbi::shutdown(false)
+    // CI autotest failed : sbi::shutdown(true)
+    sbi::shutdown(false)
 }
 
\ No newline at end of file diff --git a/ch1/src/os/sbi.rs.html b/ch1/src/os/sbi.rs.html index 3aa8aaf6..413b30e3 100644 --- a/ch1/src/os/sbi.rs.html +++ b/ch1/src/os/sbi.rs.html @@ -22,65 +22,29 @@ 22 23 24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42
#![allow(unused)]
 
-use core::arch::asm;
-
-const SBI_SET_TIMER: usize = 0;
-const SBI_CONSOLE_PUTCHAR: usize = 1;
-const SBI_CONSOLE_GETCHAR: usize = 2;
-const SBI_SHUTDOWN: usize = 8;
-
-#[inline(always)]
-fn sbi_call(which: usize, arg0: usize, arg1: usize, arg2: usize) -> usize {
-    let mut ret;
-    unsafe {
-        asm!(
-            "li x16, 0",
-            "ecall",
-            inlateout("x10") arg0 => ret,
-            in("x11") arg1,
-            in("x12") arg2,
-            in("x17") which,
-        );
-    }
-    ret
-}
-
 /// use sbi call to putchar in console (qemu uart handler)
 pub fn console_putchar(c: usize) {
-    sbi_call(SBI_CONSOLE_PUTCHAR, c, 0, 0);
+    #[allow(deprecated)]
+    sbi_rt::legacy::console_putchar(c);
 }
 
 /// use sbi call to getchar from console (qemu uart handler)
 pub fn console_getchar() -> usize {
-    sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0)
+    #[allow(deprecated)]
+    sbi_rt::legacy::console_getchar()
 }
 
-use crate::board::QEMUExit;
 /// use sbi call to shutdown the kernel
-pub fn shutdown() -> ! {
-    crate::board::QEMU_EXIT_HANDLE.exit_failure();
-
-    panic!("It should shutdown!");
+pub fn shutdown(failure: bool) -> ! {
+    use sbi_rt::{system_reset, NoReason, Shutdown, SystemFailure};
+    if !failure {
+        system_reset(Shutdown, NoReason);
+    } else {
+        system_reset(Shutdown, SystemFailure);
+    }
+    unreachable!()
 }
 
\ No newline at end of file