Update rustsbi-k210 to enable lagacy console_putchar. Adjust alignment of links apps. Run matrix on K210!
This commit is contained in:
parent
d0af7d26be
commit
63fe64ec0f
9 changed files with 88 additions and 108 deletions
Binary file not shown.
|
@ -47,6 +47,7 @@ _app_names:"#)?;
|
|||
.section .data
|
||||
.global app_{0}_start
|
||||
.global app_{0}_end
|
||||
.align 12
|
||||
app_{0}_start:
|
||||
.incbin "{2}{1}"
|
||||
app_{0}_end:"#, idx, app, TARGET_PATH)?;
|
||||
|
|
|
@ -43,6 +43,7 @@ pub fn rust_main() -> ! {
|
|||
mm::init();
|
||||
mm::remap_test();
|
||||
task::add_initproc();
|
||||
println!("after initproc!");
|
||||
trap::init();
|
||||
trap::enable_timer_interrupt();
|
||||
timer::set_next_trigger();
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[macro_use]
|
||||
extern crate user_lib;
|
||||
|
||||
const LEN: usize = 100;
|
||||
|
||||
static mut S: [u64; LEN] = [0u64; LEN];
|
||||
|
||||
#[no_mangle]
|
||||
unsafe fn main() -> i32 {
|
||||
let p = 3u64;
|
||||
let m = 998244353u64;
|
||||
let iter: usize = 300000;
|
||||
let mut cur = 0usize;
|
||||
S[cur] = 1;
|
||||
for i in 1..=iter {
|
||||
let next = if cur + 1 == LEN { 0 } else { cur + 1 };
|
||||
S[next] = S[cur] * p % m;
|
||||
cur = next;
|
||||
if i % 10000 == 0 {
|
||||
println!("power_3 [{}/{}]", i, iter);
|
||||
}
|
||||
}
|
||||
println!("{}^{} = {}(mod {})", p, iter, S[cur], m);
|
||||
println!("Test power_3 OK!");
|
||||
0
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[macro_use]
|
||||
extern crate user_lib;
|
||||
|
||||
const LEN: usize = 100;
|
||||
|
||||
static mut S: [u64; LEN] = [0u64; LEN];
|
||||
|
||||
#[no_mangle]
|
||||
unsafe fn main() -> i32 {
|
||||
let p = 5u64;
|
||||
let m = 998244353u64;
|
||||
let iter: usize = 210000;
|
||||
let mut cur = 0usize;
|
||||
S[cur] = 1;
|
||||
for i in 1..=iter {
|
||||
let next = if cur + 1 == LEN { 0 } else { cur + 1 };
|
||||
S[next] = S[cur] * p % m;
|
||||
cur = next;
|
||||
if i % 10000 == 0 {
|
||||
println!("power_5 [{}/{}]", i, iter);
|
||||
}
|
||||
}
|
||||
println!("{}^{} = {}(mod {})", p, iter, S[cur], m);
|
||||
println!("Test power_5 OK!");
|
||||
0
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[macro_use]
|
||||
extern crate user_lib;
|
||||
|
||||
const LEN: usize = 100;
|
||||
|
||||
static mut S: [u64; LEN] = [0u64; LEN];
|
||||
|
||||
#[no_mangle]
|
||||
unsafe fn main() -> i32 {
|
||||
let p = 7u64;
|
||||
let m = 998244353u64;
|
||||
let iter: usize = 240000;
|
||||
let mut cur = 0usize;
|
||||
S[cur] = 1;
|
||||
for i in 1..=iter {
|
||||
let next = if cur + 1 == LEN { 0 } else { cur + 1 };
|
||||
S[next] = S[cur] * p % m;
|
||||
cur = next;
|
||||
if i % 10000 == 0 {
|
||||
println!("power_7 [{}/{}]", i, iter);
|
||||
}
|
||||
}
|
||||
println!("{}^{} = {}(mod {})", p, iter, S[cur], m);
|
||||
println!("Test power_7 OK!");
|
||||
0
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[macro_use]
|
||||
extern crate user_lib;
|
||||
|
||||
use user_lib::{get_time, yield_};
|
||||
|
||||
#[no_mangle]
|
||||
fn main() -> i32 {
|
||||
let current_timer = get_time();
|
||||
let wait_for = current_timer + 10000000;
|
||||
while get_time() < wait_for {
|
||||
yield_();
|
||||
}
|
||||
println!("Test sleep OK!");
|
||||
0
|
||||
}
|
68
user/src/bin/matrix.rs
Normal file
68
user/src/bin/matrix.rs
Normal file
|
@ -0,0 +1,68 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[macro_use]
|
||||
extern crate user_lib;
|
||||
|
||||
use user_lib::{fork, wait, yield_, exit, getpid, get_time, wait_once};
|
||||
|
||||
static NUM: usize = 13;
|
||||
const N: usize = 10;
|
||||
static P: i32 = 10007;
|
||||
type Arr = [[i32; N]; N];
|
||||
|
||||
fn work(times: isize) {
|
||||
let mut a: Arr = Default::default();
|
||||
let mut b: Arr = Default::default();
|
||||
let mut c: Arr = Default::default();
|
||||
for i in 0..N {
|
||||
for j in 0..N {
|
||||
a[i][j] = 1;
|
||||
b[i][j] = 1;
|
||||
}
|
||||
}
|
||||
yield_();
|
||||
println!("pid {} is running ({} times)!.", getpid(), times);
|
||||
for _ in 0..times {
|
||||
for i in 0..N {
|
||||
for j in 0..N {
|
||||
c[i][j] = 0;
|
||||
for k in 0..N {
|
||||
c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % P;
|
||||
}
|
||||
}
|
||||
}
|
||||
for i in 0..N {
|
||||
for j in 0..N {
|
||||
a[i][j] = c[i][j];
|
||||
b[i][j] = c[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("pid {} done!.", getpid());
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn main() -> i32 {
|
||||
for _ in 0..NUM {
|
||||
let pid = fork();
|
||||
if pid == 0 {
|
||||
let current_time = get_time();
|
||||
let times = (current_time as i32 as isize) * (current_time as i32 as isize) % 1000;
|
||||
work(times * 40);
|
||||
}
|
||||
}
|
||||
|
||||
println!("fork ok.");
|
||||
|
||||
let mut xstate: i32 = 0;
|
||||
for _ in 0..NUM {
|
||||
if wait(&mut xstate) < 0 {
|
||||
panic!("wait failed.");
|
||||
}
|
||||
}
|
||||
assert!(wait_once(&mut xstate) < 0);
|
||||
println!("matrix passed.");
|
||||
0
|
||||
}
|
|
@ -48,7 +48,22 @@ pub fn get_time() -> isize { sys_get_time() }
|
|||
pub fn getpid() -> isize { sys_getpid() }
|
||||
pub fn fork() -> isize { sys_fork() }
|
||||
pub fn exec(path: &str) -> isize { sys_exec(path) }
|
||||
pub fn wait(xstate: &mut i32) -> isize { sys_waitpid(-1, xstate as *mut _) }
|
||||
pub fn waitpid(pid: usize, xstate: &mut i32) -> isize {
|
||||
sys_waitpid(pid as isize, xstate as *mut _)
|
||||
pub fn wait(exit_code: &mut i32) -> isize {
|
||||
loop {
|
||||
match sys_waitpid(-1, exit_code as *mut _) {
|
||||
-1 => { yield_(); }
|
||||
exit_pid => return exit_pid,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn wait_once(exit_code: &mut i32) -> isize {
|
||||
sys_waitpid(-1, exit_code as *mut _)
|
||||
}
|
||||
pub fn waitpid(pid: usize, exit_code: &mut i32) -> isize {
|
||||
loop {
|
||||
match sys_waitpid(pid as isize, exit_code as *mut _) {
|
||||
-1 => { yield_(); }
|
||||
exit_pid => return exit_pid,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue