Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = [
"crates/ui",
"crates/x2apic",
"crates/heapless",
"crates/images",
]

[workspace.dependencies]
Expand All @@ -36,6 +37,7 @@ ui.path = "./crates/ui"
embedded-graphics = "0.8.1"
x2apic.path = "./crates/x2apic"
heapless.path = "./crates/heapless"
images.path = "./crates/images"

[profile.dev]
panic = "abort"
Expand Down
6 changes: 6 additions & 0 deletions crates/images/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "images"
version = "0.1.0"
edition = "2024"

[dependencies]
5 changes: 5 additions & 0 deletions crates/images/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![no_std]

use core::include_bytes;

pub static LOGO_CONTENT: &[u8] = include_bytes!("../static/logo.tga");
Binary file added crates/images/static/logo.tga
Binary file not shown.
2 changes: 2 additions & 0 deletions crates/ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ embedded-graphics.workspace = true
fb.workspace = true
heapless.workspace = true
arch.workspace = true
tinytga = "0.5.0"
images.workspace = true
45 changes: 45 additions & 0 deletions crates/ui/src/components/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use embedded_graphics::{
Drawable,
image::Image,
pixelcolor::Rgb888,
prelude::{DrawTarget, OriginDimensions, Point, RgbColor},
primitives::Rectangle,
};
use tinytga::Tga;

use crate::components::Component;

pub struct UiImage {
pub content: &'static [u8],
pub pos: Point,
}

impl UiImage {
pub fn new(content: &'static [u8], pos: Point) -> Self {
let tga: Tga<Rgb888> = Tga::from_slice(content).unwrap();
let size = tga.size();

Self {
content,
pos: Point::new(pos.x - size.width as i32, pos.y - size.height as i32),
}
}
}

impl Component for UiImage {
fn render(&mut self, screen: &mut fb::display::FbDisplay, space: Point) {
let tga: Tga<Rgb888> = Tga::from_slice(self.content).unwrap();

let image = Image::new(&tga, self.pos + space);

image.draw(screen).unwrap();
}
fn clear(&self, screen: &mut fb::display::FbDisplay, space: Point) {
let tga: Tga<Rgb888> = Tga::from_slice(self.content).unwrap();
let size = tga.size();

screen
.fill_solid(&Rectangle::new(self.pos + space, size), Rgb888::BLACK)
.unwrap();
}
}
1 change: 1 addition & 0 deletions crates/ui/src/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use embedded_graphics::prelude::Point;
use fb::display::FbDisplay;

pub mod image;
pub mod placeholder;
pub mod text;
pub mod textarea;
Expand Down
35 changes: 35 additions & 0 deletions crates/ui/src/sections/loading.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use embedded_graphics::prelude::{OriginDimensions, Point};
use fb::get_ui_writer;
use images::LOGO_CONTENT;

use crate::{
Section,
components::{Component, image::UiImage},
};

pub struct LoadingSection {
pub pos: Point,
logo: UiImage,
}

impl LoadingSection {
pub fn new(pos: Point) -> Self {
let mut logo = UiImage::new(
LOGO_CONTENT,
Point::new(
get_ui_writer().size().width as i32,
get_ui_writer().size().height as i32,
),
);
logo.pos.x /= 2;
logo.pos.y /= 2;

Self { pos, logo }
}
}

impl Section for LoadingSection {
fn render(&mut self, screen: &mut fb::display::FbDisplay) {
self.logo.render(screen, self.pos);
}
}
1 change: 1 addition & 0 deletions crates/ui/src/sections/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod cpu_info;
pub mod loading;
pub mod test_info;
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
...
}:
(craneLib target).devShell {
packages = with pkgs; [qemu just libisoburn];
packages = with pkgs; [qemu just libisoburn imagemagick gdb];
buildInputs = hook.enabledPackages;
shellHook = ''
echo "DevShell for ${name} (${target})"
Expand Down
17 changes: 12 additions & 5 deletions kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ use core::f32;
use core::fmt::Write;
use core::time::Duration;
use embedded_graphics::Drawable;
use embedded_graphics::image::Image;
use embedded_graphics::mono_font::MonoTextStyle;
use embedded_graphics::mono_font::iso_8859_9::FONT_6X10;
use embedded_graphics::pixelcolor::Rgb888;
use embedded_graphics::prelude::{DrawTarget, Point, RgbColor};
use embedded_graphics::prelude::{DrawTarget, OriginDimensions, Point, RgbColor};
use embedded_graphics::primitives::{PrimitiveStyle, StyledDrawable};
use embedded_graphics::text::Text;
use fb::{color_print, get_fb_writer, get_ui_writer, init_ui, println};
Expand All @@ -31,8 +32,12 @@ use march_c::MarchC;
use mem::allocator::Allocator;
use modulo_n::ModuloN;
use sync::Once;
use ui::sections::loading::LoadingSection;

use ui::sections::test_info::TestInfoSection;
use ui::{RenderSection, UiState, get_ui_state, init_ui_state, render_section, render_ui_state};
use ui::{
RenderSection, Section, UiState, get_ui_state, init_ui_state, render_section, render_ui_state,
};

use x86_64::VirtAddr;

Expand Down Expand Up @@ -77,6 +82,8 @@ extern "C" fn kmain() -> ! {

HIGHER_HALF_OFFSET.call_once(|| hhdm);

get_ui_writer().clear(Rgb888::new(11, 11, 10)).unwrap();

let mem_map = &boot::requests::MEMORY_MAP_REQUEST;
let entries = mem_map.get_response().unwrap().entries();

Expand All @@ -85,8 +92,9 @@ extern "C" fn kmain() -> ! {

init_idt();

println!("Starting memsos");
println!("Calibrating tsc...");
let mut loading = LoadingSection::new(Point::zero());
loading.render(get_ui_writer());

calibrate_tsc();
restore_rtc();
init_mem_module(entries);
Expand All @@ -110,7 +118,6 @@ extern "C" fn kmain() -> ! {
beep();

color_print!(Rgb888::CYAN, "It works! {}", reports.is_empty());
println!("asd");

hcf();
}
Expand Down
6 changes: 6 additions & 0 deletions tga.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

for tga in crates/images/static/*; do
echo $tga
magick $tga -alpha off -depth 8 $tga
done
Loading