From 75196ee7565a06ea894070c1b30f40ff56371f0a Mon Sep 17 00:00:00 2001 From: chyyuu Date: Fri, 25 Mar 2022 07:59:22 +0000 Subject: [PATCH] deploy: a71b02152ff2104e50fed675b701095ef49001cd --- ch1/os/console/fn.print.html | 2 +- ch1/os/console/index.html | 5 ++-- ch1/os/console/struct.Stdout.html | 2 +- ch1/os/fn.clear_bss.html | 5 ++-- ch1/os/fn.rust_main.html | 7 +++-- ch1/os/index.html | 22 ++++++++++---- ch1/os/lang_items/fn.panic.html | 2 +- ch1/os/lang_items/index.html | 5 ++-- ch1/os/macro.print.html | 7 +++-- ch1/os/macro.println.html | 7 +++-- ch1/os/sidebar-items.js | 2 +- ch1/search-index.js | 2 +- ch1/src/os/console.rs.html | 10 ++++++- ch1/src/os/lang_items.rs.html | 10 +++++-- ch1/src/os/main.rs.html | 50 +++++++++++++++++++++++-------- 15 files changed, 97 insertions(+), 41 deletions(-) diff --git a/ch1/os/console/fn.print.html b/ch1/os/console/fn.print.html index 11eb46a6..cfcc29ed 100644 --- a/ch1/os/console/fn.print.html +++ b/ch1/os/console/fn.print.html @@ -2,5 +2,5 @@
-

Function os::console::print

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

Function os::console::print

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

Module os::console

source · []

Structs

+

Module os::console

source · []
Expand description

SBI console driver, for text output

+

Structs

Functions

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

Struct os::console::Stdout

source · []
struct Stdout;

Trait Implementations

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

Struct os::console::Stdout

source · []
struct Stdout;

Trait Implementations

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

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

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

diff --git a/ch1/os/fn.clear_bss.html b/ch1/os/fn.clear_bss.html index a57de7ed..f103a9b3 100644 --- a/ch1/os/fn.clear_bss.html +++ b/ch1/os/fn.clear_bss.html @@ -1,6 +1,7 @@ -clear_bss in os - Rust +clear_bss in os - Rust
-

Function os::clear_bss

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

Function os::clear_bss

source · []
pub 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 e8e31292..a0b62e28 100644 --- a/ch1/os/fn.rust_main.html +++ b/ch1/os/fn.rust_main.html @@ -1,7 +1,8 @@ -rust_main in os - Rust +rust_main in os - Rust
-

Function os::rust_main

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

Function os::rust_main

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

the rust entry-point of os

+
\ No newline at end of file diff --git a/ch1/os/index.html b/ch1/os/index.html index 57f94903..1e648efc 100644 --- a/ch1/os/index.html +++ b/ch1/os/index.html @@ -1,9 +1,21 @@ -os - Rust +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

+

SBI console driver, for text output

+

The panic handler

+

Macros

+

print string macro

+

println string macro

+

Functions

+

clear BSS segment

+

the rust entry-point of os

+
\ No newline at end of file diff --git a/ch1/os/lang_items/fn.panic.html b/ch1/os/lang_items/fn.panic.html index 4109a3bb..6665430c 100644 --- a/ch1/os/lang_items/fn.panic.html +++ b/ch1/os/lang_items/fn.panic.html @@ -2,5 +2,5 @@
-

Function os::lang_items::panic

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

Function os::lang_items::panic

source · []
fn panic(info: &PanicInfo<'_>) -> !
\ No newline at end of file diff --git a/ch1/os/lang_items/index.html b/ch1/os/lang_items/index.html index c333ed12..752216ad 100644 --- a/ch1/os/lang_items/index.html +++ b/ch1/os/lang_items/index.html @@ -1,7 +1,8 @@ -os::lang_items - Rust +os::lang_items - Rust
Expand description

The panic handler

+

Functions

\ No newline at end of file diff --git a/ch1/os/macro.print.html b/ch1/os/macro.print.html index 17d519f7..bb6aceda 100644 --- a/ch1/os/macro.print.html +++ b/ch1/os/macro.print.html @@ -1,9 +1,10 @@ -print in os - Rust +print in os - Rust
-

Macro os::print

source · []
macro_rules! print {
+    

Macro os::print

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

print string macro

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

Macro os::println

source · []
macro_rules! println {
+    

Macro os::println

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

println string macro

+
\ No newline at end of file diff --git a/ch1/os/sidebar-items.js b/ch1/os/sidebar-items.js index d905173d..dd6f2db9 100644 --- a/ch1/os/sidebar-items.js +++ b/ch1/os/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"fn":[["clear_bss",""],["rust_main",""]],"macro":[["print",""],["println",""]],"mod":[["console",""],["lang_items",""],["sbi",""]]}); \ 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":[["console","SBI console driver, for text output"],["lang_items","The panic handler"],["sbi",""]]}); \ No newline at end of file diff --git a/ch1/search-index.js b/ch1/search-index.js index a30ab981..801e8cd3 100644 --- a/ch1/search-index.js +++ b/ch1/search-index.js @@ -1,4 +1,4 @@ var searchIndex = JSON.parse('{\ -"os":{"doc":"","t":[5,0,0,14,14,5,0,3,11,11,11,11,5,11,11,11,11,5,17,17,17,17,17,17,17,17,17,5,5,5,5],"n":["clear_bss","console","lang_items","print","println","rust_main","sbi","Stdout","borrow","borrow_mut","from","into","print","try_from","try_into","type_id","write_str","panic","SBI_CLEAR_IPI","SBI_CONSOLE_GETCHAR","SBI_CONSOLE_PUTCHAR","SBI_REMOTE_FENCE_I","SBI_REMOTE_SFENCE_VMA","SBI_REMOTE_SFENCE_VMA_ASID","SBI_SEND_IPI","SBI_SET_TIMER","SBI_SHUTDOWN","console_getchar","console_putchar","sbi_call","shutdown"],"q":["os","","","","","","","os::console","","","","","","","","","","os::lang_items","os::sbi","","","","","","","","","","","",""],"d":["","","","","","","","","","","","","","","","","","","","","","","","","","","","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,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"f":[[[]],null,null,null,null,[[],["never",15]],null,null,[[]],[[]],[[]],[[]],[[["arguments",3]]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[["str",15]],["result",6]],[[["panicinfo",3]],["never",15]],null,null,null,null,null,null,null,null,null,[[],["usize",15]],[[["usize",15]]],[[["usize",15],["usize",15],["usize",15],["usize",15]],["usize",15]],[[],["never",15]]],"p":[[3,"Stdout"]]}\ +"os":{"doc":"The main module and entrypoint","t":[5,0,0,14,14,5,0,3,11,11,11,11,5,11,11,11,11,5,17,17,17,17,17,17,17,17,17,5,5,5,5],"n":["clear_bss","console","lang_items","print","println","rust_main","sbi","Stdout","borrow","borrow_mut","from","into","print","try_from","try_into","type_id","write_str","panic","SBI_CLEAR_IPI","SBI_CONSOLE_GETCHAR","SBI_CONSOLE_PUTCHAR","SBI_REMOTE_FENCE_I","SBI_REMOTE_SFENCE_VMA","SBI_REMOTE_SFENCE_VMA_ASID","SBI_SEND_IPI","SBI_SET_TIMER","SBI_SHUTDOWN","console_getchar","console_putchar","sbi_call","shutdown"],"q":["os","","","","","","","os::console","","","","","","","","","","os::lang_items","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","","","","","","","","","","","","","","","","","","","","","","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,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"f":[[[]],null,null,null,null,[[],["never",15]],null,null,[[]],[[]],[[]],[[]],[[["arguments",3]]],[[],["result",4]],[[],["result",4]],[[],["typeid",3]],[[["str",15]],["result",6]],[[["panicinfo",3]],["never",15]],null,null,null,null,null,null,null,null,null,[[],["usize",15]],[[["usize",15]]],[[["usize",15],["usize",15],["usize",15],["usize",15]],["usize",15]],[[],["never",15]]],"p":[[3,"Stdout"]]}\ }'); if (window.initSearch) {window.initSearch(searchIndex)}; \ No newline at end of file diff --git a/ch1/src/os/console.rs.html b/ch1/src/os/console.rs.html index 18c55e28..c3774d09 100644 --- a/ch1/src/os/console.rs.html +++ b/ch1/src/os/console.rs.html @@ -32,7 +32,13 @@ 29 30 31 -
use crate::sbi::console_putchar;
+32
+33
+34
+35
+
//! SBI console driver, for text output
+
+use crate::sbi::console_putchar;
 use core::fmt::{self, Write};
 
 struct Stdout;
@@ -50,6 +56,7 @@
     Stdout.write_fmt(args).unwrap();
 }
 
+/// print string macro
 #[macro_export]
 macro_rules! print {
     ($fmt: literal $(, $($arg: tt)+)?) => {
@@ -57,6 +64,7 @@
     }
 }
 
+/// println string macro
 #[macro_export]
 macro_rules! println {
     ($fmt: literal $(, $($arg: tt)+)?) => {
diff --git a/ch1/src/os/lang_items.rs.html b/ch1/src/os/lang_items.rs.html
index 62e776c9..7685d650 100644
--- a/ch1/src/os/lang_items.rs.html
+++ b/ch1/src/os/lang_items.rs.html
@@ -18,20 +18,24 @@
 15
 16
 17
-
use crate::sbi::shutdown;
+18
+19
+
//! The panic handler
+
+use crate::sbi::shutdown;
 use core::panic::PanicInfo;
 
 #[panic_handler]
 fn panic(info: &PanicInfo) -> ! {
     if let Some(location) = info.location() {
         println!(
-            "Panicked at {}:{} {}",
+            "[kernel] Panicked at {}:{} {}",
             location.file(),
             location.line(),
             info.message().unwrap()
         );
     } else {
-        println!("Panicked: {}", info.message().unwrap());
+        println!("[kernel] Panicked: {}", info.message().unwrap());
     }
     shutdown()
 }
diff --git a/ch1/src/os/main.rs.html b/ch1/src/os/main.rs.html
index 176a155b..d261d083 100644
--- a/ch1/src/os/main.rs.html
+++ b/ch1/src/os/main.rs.html
@@ -48,7 +48,31 @@
 45
 46
 47
-
#![no_std]
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+
//! 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!`.
+
+#![deny(missing_docs)]
+#![deny(warnings)]
+#![no_std]
 #![no_main]
 #![feature(panic_info_message)]
 
@@ -61,7 +85,8 @@
 
 global_asm!(include_str!("entry.asm"));
 
-fn clear_bss() {
+/// clear BSS segment
+pub fn clear_bss() {
     extern "C" {
         fn sbss();
         fn ebss();
@@ -69,19 +94,20 @@
     (sbss as usize..ebss as usize).for_each(|a| unsafe { (a as *mut u8).write_volatile(0) });
 }
 
+/// the rust entry-point of os
 #[no_mangle]
 pub fn rust_main() -> ! {
     extern "C" {
-        fn stext();
-        fn etext();
-        fn srodata();
-        fn erodata();
-        fn sdata();
-        fn edata();
-        fn sbss();
-        fn ebss();
-        fn boot_stack();
-        fn boot_stack_top();
+        fn stext();               // begin addr of text segment
+        fn etext();               // end addr of text segment
+        fn srodata();             // start addr of Read-Only data segment
+        fn erodata();             // end addr of Read-Only data ssegment
+        fn sdata();               // start addr of data segment
+        fn edata();               // end addr of data segment
+        fn sbss();                // start addr of BSS segment
+        fn ebss();                // end addr of BSS segment
+        fn boot_stack();          // stack bottom
+        fn boot_stack_top();      // stack top
     }
     clear_bss();
     println!("Hello, world!");