From ca1c695e328f1e15d845ff7f79c02a528730583a Mon Sep 17 00:00:00 2001 From: zxq5 Date: Mon, 24 Feb 2025 16:28:56 +0000 Subject: [PATCH] created stdio module, added hardware script --- kernel/src/lib.rs | 7 +++++-- libk/src/std/io/io.rs | 35 +++++++++++++++++++++++++++++++++++ scripts/hardware.sh | 2 ++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 scripts/hardware.sh diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index c1e18e8..7e60267 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -61,8 +61,11 @@ pub fn boot() -> Result<(), &'static str> { let memory_map = memmap::get_memory_map(); print_log!(" Initialising Serial... "); - libk::drivers::io::serial::init()?; - println_log!("[Success]"); + if libk::drivers::io::serial::init().is_err() { + println_log!("[Not Detected]") + } else { + println_log!("[Success]"); + } print_log!(" Setting Up Global Descriptor Table... "); gdt::init(); diff --git a/libk/src/std/io/io.rs b/libk/src/std/io/io.rs index dfb3dc0..d48d4ce 100644 --- a/libk/src/std/io/io.rs +++ b/libk/src/std/io/io.rs @@ -4,3 +4,38 @@ pub use crate::drivers::io::{ serial::_serial_write, serial_print, serial_println, }; + +pub mod stdin { + use alloc::string::String; + + /// Reads a line of input from standard input asynchronously, returning a `String` containing + /// the input line. Does not include the newline character at the end of the line. + /// + /// If the user presses the abort key (usually Ctrl+C), the returned string will be empty. + /// + /// This function is currently unimplemented. + pub async fn read_line() -> String { + todo!() + } + + /// Reads a character from standard input and blocks the current task until a character is + /// available. + /// + /// # Note + /// + /// This function is not yet implemented. + pub async fn read_char() -> char { + todo!() + } + + /// Attempt to read a character from standard input without blocking the current task. + /// + /// If no character is available, returns `None`. + /// + /// # Note + /// + /// This function is not yet implemented. + pub fn try_read_char() -> Option { + todo!() + } +} diff --git a/scripts/hardware.sh b/scripts/hardware.sh new file mode 100755 index 0000000..5070e47 --- /dev/null +++ b/scripts/hardware.sh @@ -0,0 +1,2 @@ +#!/bin/bash +sudo dd if=./build/image.iso of="$1"