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
45 changes: 45 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[workspace]
resolver = "2"
members = [
"crates/console",
"crates/device-tree",
"crates/display-client",
"crates/display-proto",
"crates/display-server",
"crates/elf",
"crates/endian",
"crates/filesystem",
Expand Down
1 change: 1 addition & 0 deletions crates/console/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.elf
15 changes: 15 additions & 0 deletions crates/console/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "console"
version = "0.1.0"
edition = "2021"

[dependencies]
bytemuck = "1.21.0"
unicode-segmentation = "1.12"

display-client = { path = "../display-client" }
lz4 = { path = "../lz4" }
ulib = { path = "../ulib", features = ["heap-impl"] }

[dev-dependencies]
ulib = { path = "../ulib", features = ["test"] }
6 changes: 6 additions & 0 deletions crates/console/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
let crate_root = std::env::var("CARGO_MANIFEST_DIR").unwrap();
println!("cargo::rerun-if-changed=../ulib/script.ld");
println!("cargo::rustc-link-arg-bins=-T{crate_root}/../ulib/script.ld");
println!("cargo::rustc-link-arg-bins=-n");
}
19 changes: 19 additions & 0 deletions crates/console/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -ex

BIN="console"
TARGET=aarch64-unknown-none-softfloat
PROFILE=${PROFILE-"release"}

cargo rustc --profile="${PROFILE}" \
--target=${TARGET} -- \
-C relocation-model=static

if test "$PROFILE" = "dev" ; then
BINARY=../../target/${TARGET}/debug/${BIN}
else
BINARY=../../target/${TARGET}/${PROFILE}/${BIN}
fi

cp "${BINARY}" "${BIN}".elf
Binary file added crates/console/ctrld-fixed-10r.pcf.lz4
Binary file not shown.
23 changes: 23 additions & 0 deletions crates/console/src/color.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> u32 {
u32::from_be_bytes([a, r, g, b])
}

pub const fn de_rgba(color: u32) -> (u8, u8, u8, u8) {
let [a, r, g, b] = color.to_be_bytes();
(r, g, b, a)
}

pub fn blend(one: u32, two: u32) -> u32 {
let [a, r, g, b] = one.to_be_bytes().map(u32::from);
if a == 255 {
return one;
}
let [_bg_a, bg_r, bg_g, bg_b] = two.to_be_bytes().map(u32::from);
// TODO: blend in linear space?
let (r, g, b) = (
(r * a + bg_r * (255 - a)) / 255,
(g * a + bg_g * (255 - a)) / 255,
(b * a + bg_b * (255 - a)) / 255,
);
u32::from_be_bytes([a, r, g, b].map(|b| b as u8))
}
Loading