Outputting to the screen via the t(level) class of functions now works
This commit is contained in:
parent
bc19d1a69d
commit
2df6e24d05
7 changed files with 164 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
# config.aphro for aphrodite devel-461136c-out-of-tree
|
||||
CFG_VERSION=devel-461136c-out-of-tree
|
||||
# config.aphro for aphrodite devel-bc19d1a-out-of-tree
|
||||
CFG_VERSION=devel-bc19d1a-out-of-tree
|
||||
CONT_WITH_DIFFERENT_VERSION=false
|
||||
|
||||
# Begin metadata
|
||||
|
|
Binary file not shown.
|
@ -1,8 +1,8 @@
|
|||
set timeout=15
|
||||
set default=0
|
||||
|
||||
menuentry "Aphrodite" --class aphrodite --class kernel --class os $menuentry_id_option 'aphrodite-basic-devel-461136c-out-of-tree' {
|
||||
echo 'Loading Aphrodite aphrodite-devel-461136c-out-of-tree ...'
|
||||
menuentry "Aphrodite" --class aphrodite --class kernel --class os $menuentry_id_option 'aphrodite-basic-devel-bc19d1a-out-of-tree' {
|
||||
echo 'Loading Aphrodite aphrodite-devel-bc19d1a-out-of-tree ...'
|
||||
multiboot2 /boot/aphrodite.kernel
|
||||
boot
|
||||
}
|
Binary file not shown.
|
@ -56,16 +56,30 @@ impl FramebufferInfo {
|
|||
}
|
||||
|
||||
/// Writes a &str to the screen.
|
||||
pub fn write_str(self, pos: (u32, u32), str: &str, color: u8) -> Result<(), crate::Error<'static>> {
|
||||
pub fn write_str(self, pos: (u32, u32), str: &str, color: u8) -> Result<(u32, u32), crate::Error<'static>> {
|
||||
let (mut x, mut y) = pos;
|
||||
for char in str.as_bytes() {
|
||||
self.write_char((x, y), *char, color)?;
|
||||
x += 1;
|
||||
if x>self.width {
|
||||
while x>self.width {
|
||||
x -= self.width;
|
||||
y += 1;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
Ok((x, y))
|
||||
}
|
||||
|
||||
/// Writes a &\[u8] to the screen.
|
||||
pub fn write_bytes(self, pos: (u32, u32), str: &[u8], color: u8) -> Result<(u32, u32), crate::Error<'static>> {
|
||||
let (mut x, mut y) = pos;
|
||||
for char in str {
|
||||
self.write_char((x, y), *char, color)?;
|
||||
x += 1;
|
||||
while x>self.width {
|
||||
x -= self.width;
|
||||
y += 1;
|
||||
}
|
||||
}
|
||||
Ok((x, y))
|
||||
}
|
||||
}
|
|
@ -2,9 +2,12 @@
|
|||
#![cfg(any(target_arch = "x86"))]
|
||||
|
||||
use super::ports;
|
||||
use super::egatext::*;
|
||||
|
||||
use paste::paste;
|
||||
|
||||
static mut OUTPUT_TERM_POSITION: (u32, u32) = (0, 0);
|
||||
|
||||
macro_rules! message_funcs {
|
||||
($func_name:ident, $prefix:literal, $level:ident) => {
|
||||
paste! {
|
||||
|
@ -94,6 +97,138 @@ macro_rules! message_funcs {
|
|||
}
|
||||
ports::outb(super::DEBUG_PORT, s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/// Outputs a $func_name message &str to the terminal.
|
||||
pub fn [< t $func_name s >](s: &str, info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, $prefix, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
/// Outputs a $func_name message &str and a newline to the terminal.
|
||||
pub fn [< t $func_name sln >](s: &str, info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, $prefix, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION.1 += 1;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Outputs a $func_name message &\[u8] to the terminal.
|
||||
pub fn [< t $func_name b >](s: &[u8], info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, $prefix, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION = info.write_bytes(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
/// Outputs a $func_name message &\[u8] and a newline to the terminal.
|
||||
pub fn [< t $func_name bln >](s: &[u8], info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, $prefix, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION = info.write_bytes(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION.1 += 1;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Outputs a(n) $func_name message u8 to the terminal.
|
||||
pub fn [< t $func_name u >](s: u8, info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, $prefix, WHITE_ON_BLACK)?;
|
||||
info.write_char(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION.0 += 1;
|
||||
while OUTPUT_TERM_POSITION.0 > info.width {
|
||||
OUTPUT_TERM_POSITION.0 -= info.width;
|
||||
OUTPUT_TERM_POSITION.1 += 1;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
/// Outputs a $func_name message &str to the terminal without a prefix.
|
||||
pub fn [< t $func_name snp >](s: &str, info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
/// Outputs a $func_name message &str and a newline to the terminal without a prefix.
|
||||
pub fn [< t $func_name snpln >](s: &str, info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_str(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION.1 += 1;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Outputs a $func_name message &\[u8] to the terminal without a prefix.
|
||||
pub fn [< t $func_name bnp >](s: &[u8], info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_bytes(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
/// Outputs a $func_name message &\[u8] and a newline to the terminal without a prefix.
|
||||
pub fn [< t $func_name bnpln >](s: &[u8], info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
OUTPUT_TERM_POSITION = info.write_bytes(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION.1 += 1;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Outputs a(n) $func_name message u8 to the terminal without a prefix.
|
||||
pub fn [< t $func_name unp >](s: u8, info: FramebufferInfo) -> Result<(), crate::Error<'static>> {
|
||||
unsafe {
|
||||
if cfg!($level = "false") {
|
||||
return Ok(());
|
||||
}
|
||||
info.write_char(OUTPUT_TERM_POSITION, s, WHITE_ON_BLACK)?;
|
||||
OUTPUT_TERM_POSITION.0 += 1;
|
||||
while OUTPUT_TERM_POSITION.0 > info.width {
|
||||
OUTPUT_TERM_POSITION.0 -= info.width;
|
||||
OUTPUT_TERM_POSITION.1 += 1;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,9 +256,15 @@ extern "C" fn _start() -> ! {
|
|||
let ColorInfo::Palette{num_colors, palette: _} = color_info else { unreachable!() };
|
||||
sdebugs("Number of palette colors: ");
|
||||
sdebugbnpln(&aphrodite::u32_as_u8_slice(num_colors));
|
||||
|
||||
sfatalsln("Halting CPU; Indexed color unimplemented");
|
||||
asm!("hlt", options(noreturn));
|
||||
},
|
||||
1 => { // RGB
|
||||
sdebugsnpln("(RGB)");
|
||||
|
||||
sfatalsln("Halting CPU; RGB color unimplemented");
|
||||
asm!("hlt", options(noreturn));
|
||||
},
|
||||
2 => { // EGA Text
|
||||
sdebugsnpln("(EGA Text)");
|
||||
|
@ -272,10 +278,9 @@ extern "C" fn _start() -> ! {
|
|||
bpp: framebuffer_info.bpp
|
||||
};
|
||||
ega.clear_screen(BLACK_ON_BLACK);
|
||||
ega.write_str((0, 0), "Test", WHITE_ON_BLACK).unwrap();
|
||||
|
||||
tdebugsln("Testing EGA Text framebuffer...", ega).unwrap();
|
||||
for _ in 0..100000000 {
|
||||
asm!("nop")
|
||||
asm!("nop");
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
|
|
Loading…
Add table
Reference in a new issue