-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
131af9c
commit bd5a9b4
Showing
53 changed files
with
1,406 additions
and
768 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "ggos_brk" | ||
version = "0.0.1" | ||
edition = "2021" | ||
authors = ["GZTime <[email protected]>"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
lib = { path="../../lib", package="gglib", default-features=false, features=["kernel_alloc"] } |
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,116 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
extern crate alloc; | ||
|
||
use alloc::vec::Vec; | ||
use lib::*; | ||
|
||
extern crate lib; | ||
|
||
fn main() -> isize { | ||
println!("Welcome to Brk Test!"); | ||
|
||
pre_test(); | ||
|
||
loop { | ||
print!("$ "); | ||
let command = stdin().read_line(); | ||
let line: Vec<&str> = command.trim().split(' ').collect(); | ||
|
||
match line[0] { | ||
"brk" => { | ||
if line.len() != 2 { | ||
println!("Usage: brk <addr>"); | ||
continue; | ||
} | ||
|
||
let addr = if line[1].starts_with("0x") { | ||
usize::from_str_radix(&line[1][2..], 16) | ||
} else { | ||
line[1].parse::<usize>() | ||
}; | ||
|
||
let addr = match addr { | ||
Ok(addr) => addr, | ||
Err(_) => { | ||
println!("Invalid address: {}", line[1]); | ||
continue; | ||
} | ||
}; | ||
|
||
match sys_brk(Some(addr)) { | ||
Some(new_brk) => { | ||
println!("Brk to {:#x} success, new brk addr: {:#x}", addr, new_brk) | ||
} | ||
None => println!("Brk to {:#x} failed", addr), | ||
} | ||
|
||
sys_stat(); | ||
} | ||
"cur" => match sys_brk(None) { | ||
Some(brk) => println!("Current brk addr: {:#x}", brk), | ||
None => println!("Failed to get current brk addr"), | ||
}, | ||
"exit" => { | ||
break; | ||
} | ||
_ => { | ||
println!("Unknown command: {}", line[0]); | ||
} | ||
} | ||
} | ||
|
||
0 | ||
} | ||
|
||
fn pre_test() { | ||
println!("Pre-test: Brk Test"); | ||
|
||
let brk = sys_brk(None); | ||
|
||
let brk = match brk { | ||
Some(brk) => { | ||
println!("Current brk addr: {:#x}", brk); | ||
brk | ||
} | ||
None => { | ||
println!("Failed to get current brk addr"); | ||
sys_exit(1); | ||
} | ||
}; | ||
|
||
let new_brk = sys_brk(Some(brk + 0x1000)); | ||
|
||
match new_brk { | ||
Some(new_brk) => { | ||
println!( | ||
"Brk to {:#x} success, new brk addr: {:#x}", | ||
brk + 0x1000, | ||
new_brk | ||
); | ||
sys_stat(); | ||
} | ||
None => { | ||
println!("Brk to {:#x} failed", brk + 0x1000); | ||
sys_exit(1); | ||
} | ||
} | ||
|
||
let new_brk = sys_brk(Some(brk)); | ||
|
||
match new_brk { | ||
Some(new_brk) => { | ||
println!("Brk to {:#x} success, new brk addr: {:#x}", brk, new_brk); | ||
sys_stat(); | ||
} | ||
None => { | ||
println!("Brk to {:#x} failed", brk); | ||
sys_exit(1); | ||
} | ||
} | ||
|
||
println!("Pre-test finished"); | ||
} | ||
|
||
entry!(main); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ggos_dining" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
authors = ["GZTime <[email protected]>"] | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ggos_fork" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
edition = "2021" | ||
authors = ["GZTime <[email protected]>"] | ||
|
||
|
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.