List of all items
Structs
Traits
Macros
Functions
- board::exit_code_encode
- clear_bss
- console::print
- lang_items::panic
- logging::init
- rust_main
- sbi::console_getchar
- sbi::console_putchar
- sbi::sbi_call
- sbi::shutdown
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 @@ -
pub struct RISCV64 {
- addr: u64,
-}
RISCV64 configuration
-addr: u64
Address of the sifive_test mapped device.
-Mutably borrows from an owned value. Read more
-pub trait QEMUExit {
- fn exit(&self, code: u32) -> !;
- fn exit_success(&self) -> !;
- fn exit_failure(&self) -> !;
-}
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
.
pub fn clear_bss()
clear BSS segment
+#[no_mangle]
+rust_main in os - Rust
\ 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 Expand description
The main module and entrypoint
+os - Rust 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
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
\ 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
\ 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
\ 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
\ 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 Function os::sbi::console_getchar
source · [−]pub fn console_getchar() -> usize
Expand description
use sbi call to getchar from console (qemu uart handler)
+console_getchar in os::sbi - Rust
\ 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 Function os::sbi::console_putchar
source · [−]pub fn console_putchar(c: usize)
Expand description
use sbi call to putchar in console (qemu uart handler)
+console_putchar in os::sbi - Rust
\ 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
\ 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 pub fn shutdown() -> !
Expand description
use sbi call to shutdown the kernel
+shutdown in os::sbi - Rust
\ 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 Constants
Functions
use sbi call to getchar from console (qemu uart handler)
+os::sbi - Rust
\ 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