Files
riscv64-kernel/user/test_pic/src/main.rs

31 lines
920 B
Rust

#![no_std]
#![no_main]
use core::time::Duration;
use os_std::syscall;
os_std::custom_std_setup! {}
fn main() {
// let mut input = String::new();
// let mut file = syscall::open("/dev/fb0");
// syscall::seek(&mut file, SeekFrom::End(-3));
// syscall::write(&mut file, &[255; 6400 * 50]);
syscall::sleep(Duration::from_secs_f64(2.0));
let mut stdin = syscall::open("/dev/tty0");
let mut file = syscall::open("/dev/tty0");
loop {
let mut test = [0; 2];
syscall::read(&mut stdin, &mut test);
let len = *test.iter().find(|x| **x == 0).unwrap_or(&1) + 1;
syscall::write(
&mut file,
str::from_utf8(&test[..len as usize]).unwrap().as_bytes(),
);
}
// println!(
// "Hello from PIC program loaded dynamically with custom std and a better justfile, and syscalls ! {:?}",
// str::from_utf8(&test)
// );
}