Log on tty (serial and vga)

This commit is contained in:
2026-03-22 16:00:41 +01:00
parent 15ecefb5fb
commit f966a1239e
9 changed files with 129 additions and 96 deletions

View File

@@ -1,34 +1,23 @@
#![allow(unused)]
use core::sync::atomic::AtomicUsize;
use io::{Read as Readio, Write};
use shared::{fs::File, syscall};
use std::io::{Read, Stdin, stdin};
static FOO: AtomicUsize = AtomicUsize::new(0);
use std::io::{Read, Stdin, Write, stdin, stdout};
fn main() {
let mut input = String::new();
input.push('a');
// 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));
syscall::close(0);
let mut tty = unsafe { File::from_raw_fd(syscall::open("/dev/tty0")) };
syscall::close(1);
let _ = syscall::open("/dev/tty0");
println!("test from test_pic");
tty.write(input.as_bytes()).unwrap();
syscall::spawn("/usr/bin/shell");
// panic!("explicit panic");
// std::process::abort();
unsafe {core::arch::asm!("unimp")};
// unsafe {core::arch::asm!("unimp")};
loop {
let mut test = [0; 2];
// let len = stdin().read(&mut test);
let len = tty.read(&mut test).unwrap();
tty.write(str::from_utf8(&test[..len as usize]).unwrap().as_bytes())
.unwrap();
let mut test = [0; 4];
let len = stdin().read(&mut test).unwrap();
print!("{}", str::from_utf8(&test[..len as usize]).unwrap());
stdout().flush();
}
}