NoneTextDisplay and some other stuff

This commit is contained in:
Arthur Beck 2025-02-13 06:58:16 -06:00
parent bda3e93314
commit 296135901b
4 changed files with 33 additions and 5 deletions

View file

@ -5,8 +5,14 @@ set -e
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
if [[ $# -lt 1 ]]; then
echo "[INFO] Building all targets; no target argument provided"
fi
. $DIR/build $!
if [[ $# -ge 1 ]]; then
. $DIR/emulate $!
else
echo "[WARN] Not emulating; no target argument provided"
fi

View file

@ -37,9 +37,9 @@ impl MemoryType {
crate::arch::output::sdebugsnp("Hardware specific ");
crate::arch::output::sdebugbnp(&crate::u32_as_u8_slice(*val));
if *allocatable {
crate::arch::output::sdebugsnp(" allocatable");
crate::arch::output::sdebugsnp(", allocatable");
} else {
crate::arch::output::sdebugsnp(" unallocatable");
crate::arch::output::sdebugsnp(", unallocatable");
}
},

View file

@ -1,5 +1,7 @@
//! Types, constants and traits for displaying text. Mostly implemented in arch/.
use core::fmt::Write;
/// A type used for color in the functions of [TextDisplay].
///
/// Type alias for (u8, bool). Boolean argument is whether to
@ -68,3 +70,23 @@ impl dyn TextDisplay + '_ {
Ok((x, y))
}
}
pub struct NoneTextDisplay {}
impl TextDisplay for NoneTextDisplay {
fn get_size(&self) -> (u32, u32) {
(1,1)
}
fn write_char(&self, _: (u32, u32), _: u8, _: Color) -> Result<(), crate::Error<'static>> {
Ok(())
}
}
impl Write for NoneTextDisplay {
fn write_char(&mut self, _: char) -> core::fmt::Result {
Ok(())
}
fn write_str(&mut self, _: &str) -> core::fmt::Result {
Ok(())
}
}

View file

@ -5,7 +5,7 @@
use core::alloc::{Allocator, Layout};
use crate::{display::COLOR_DEFAULT, output::*};
use crate::{display::{NoneTextDisplay, COLOR_DEFAULT}, output::*};
use aphrodite_proc_macros::*;
@ -17,9 +17,9 @@ fn indep_boot_entry(
display: Option<&dyn crate::display::TextDisplay>,
#[allow(non_snake_case)] BI: &crate::boot::BootInfo,
) -> ! {
crate::arch::output::sdebugsln("Entrypoint called");
crate::arch::output::sdebugsln("IndepBootEntry called");
let display = display.unwrap();
let display = display.unwrap_or(&NoneTextDisplay {});
display.clear_screen(COLOR_DEFAULT);
sreset();