-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/feat-net' into feat…
…-net
- Loading branch information
Showing
44 changed files
with
469 additions
and
507 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "backtrace" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
arch = { path = "../../arch/" } | ||
early-print = { path = "../early-print/" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
use core::mem::size_of; | ||
|
||
use early_print::early_println; | ||
|
||
pub fn backtrace() { | ||
extern "C" { | ||
fn _stext(); | ||
fn _etext(); | ||
} | ||
unsafe { | ||
let mut current_pc = arch::register::ra(); | ||
let mut current_fp = arch::register::fp(); | ||
|
||
while current_pc >= _stext as usize && current_pc <= _etext as usize && current_fp != 0 { | ||
early_println!("{:#018x}", current_pc - size_of::<usize>()); | ||
current_fp = *(current_fp as *const usize).offset(-2); | ||
current_pc = *(current_fp as *const usize).offset(-1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "early-print" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
sbi-rt = { version = "0.0.3", features = ["legacy"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
use core::{fmt, fmt::Write}; | ||
|
||
pub struct EarlyStdout; | ||
|
||
impl fmt::Write for EarlyStdout { | ||
fn write_str(&mut self, s: &str) -> fmt::Result { | ||
for s in s.as_bytes() { | ||
sbi_rt::legacy::console_putchar(*s as usize); | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
pub fn early_print(args: fmt::Arguments<'_>) { | ||
EarlyStdout.write_fmt(args).unwrap(); | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! early_print { | ||
($($arg:tt)*) => {{ | ||
$crate::early_print(format_args!($($arg)*)); | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! early_println { | ||
() => ($crate::early_print!("\n")); | ||
($($arg:tt)*) => ($crate::early_print!("{}\n", format_args!($($arg)*))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.