From c674fcc6e62f2fce4f380da3cf413782b65e944f Mon Sep 17 00:00:00 2001 From: Elfein Landers Date: Wed, 26 Jan 2022 20:06:04 -0800 Subject: [PATCH 1/4] Did some shitty docs. --- ableos/.cargo/config.toml | 2 +- ableos/Cargo.lock | 2 +- ableos/Cargo.toml | 8 ++++---- ableos/rust-toolchain | 2 +- ableos/src/lib.rs | 5 ++++- ableos/src/vga_e.rs | 3 ++- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ableos/.cargo/config.toml b/ableos/.cargo/config.toml index ef48109..2cc8583 100644 --- a/ableos/.cargo/config.toml +++ b/ableos/.cargo/config.toml @@ -8,7 +8,7 @@ build-std-features = ["compiler-builtins-mem"] [target.'cfg(target_arch = "x86_64")'] # --quiet suppresses warning messages from the bootimage crate -runner = "bootimage runner --quiet" +runner = "bootimage runner" [target.riscv64gc-unknown-none-elf] rustflags = "-C link-arg=-T../ableos/src/arch/riscv/virt.lds" diff --git a/ableos/Cargo.lock b/ableos/Cargo.lock index 9cf3fa3..ff20fbf 100644 --- a/ableos/Cargo.lock +++ b/ableos/Cargo.lock @@ -167,7 +167,7 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "externc-libm" version = "0.1.0" -source = "git+ssh://root@git.ablecorp.us:20/able/externc-libm.git#0781df85c094bcd7e5ef7505e9c5cc6317eeda75" +source = "git+https://git.ablecorp.us/able/externc-libm.git#0781df85c094bcd7e5ef7505e9c5cc6317eeda75" dependencies = [ "libm", ] diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index ee3afed..dec2dae 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -36,7 +36,7 @@ lliw = "0.2.0" # qoi_rs = "*" spin = "0.5.2" vga = "*" -log= "*" +log = "*" pretty-hex = "0.2.1" unicode-width = "0.1.7" picorand = "*" @@ -57,10 +57,10 @@ version = "0.7.29" default-features = false features = ["size_64", "alloc"] -[dependencies.smoltcp] +[dependencies.smoltcp] version = "0.8.0" default-features = false -features = ["log", "proto-ipv4"] +features = ["log", "proto-ipv4"] [dependencies.y-compositor-protocol] git = "https://git.ablecorp.us:443/able/y-compositor-protocol.git" @@ -83,7 +83,7 @@ features = ["spin_no_std"] version = "1.0" [dependencies.externc-libm] -git = "ssh://root@git.ablecorp.us:20/able/externc-libm.git" +git = "https://git.ablecorp.us/able/externc-libm.git" [target.'cfg(target_arch = "x86_64")'.dependencies] bootloader = { version = "0.9.8", features = ["map_physical_memory"] } diff --git a/ableos/rust-toolchain b/ableos/rust-toolchain index bf867e0..c6d365e 100644 --- a/ableos/rust-toolchain +++ b/ableos/rust-toolchain @@ -1 +1 @@ -nightly +nightly-2022-01-04 diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index 47e4c6f..8b17140 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -1,5 +1,5 @@ //! hi - +#![deny(missing_docs)] #![no_std] #![feature( abi_x86_interrupt, @@ -14,14 +14,17 @@ )] #![feature(exclusive_range_pattern)] +/// Contains architecture specific code for aarch64. #[cfg(target_arch = "aarch64")] #[path = "arch/aarch64/mod.rs"] pub mod arch; +/// Contains architecture specific code for x86_64. #[cfg(target_arch = "x86_64")] #[path = "arch/x86_64/mod.rs"] pub mod arch; +/// Contains architecture specific code for riscv64. #[cfg(target_arch = "riscv64")] #[path = "arch/riscv/mod.rs"] pub mod arch; diff --git a/ableos/src/vga_e.rs b/ableos/src/vga_e.rs index 773193f..f2d6468 100644 --- a/ableos/src/vga_e.rs +++ b/ableos/src/vga_e.rs @@ -15,7 +15,7 @@ lazy_static::lazy_static! { pub static ref VGAE_BUFF_OFFSET_X: spin::Mutex = spin::Mutex::new(0); pub static ref VGAE_BUFF_OFFSET_Y: spin::Mutex = spin::Mutex::new(0); } - +/// pub fn draw_char(previous_character: Option, character: char, _offset: usize) { let mode = *VGAE.lock(); let mut offset_x = VGAE_BUFF_OFFSET_X.lock(); @@ -96,6 +96,7 @@ pub fn draw_char(previous_character: Option, character: char, _offset: usi } } } +/// Converts a number to ... i forgor 💀 pub fn num_to_vga16(num: u8) -> Color16 { use Color16::*; match num { From 3206cfd2bc7408db24eacca14c16c3a6e0dd7222 Mon Sep 17 00:00:00 2001 From: Elfein Landers Date: Wed, 26 Jan 2022 23:00:25 -0800 Subject: [PATCH 2/4] Simplify range check for font --- ableos/.cargo/config.toml | 4 ---- ableos/src/vga_e.rs | 40 ++++++++++++++++++----------------- shadeable/src/pixel_format.rs | 1 - 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/ableos/.cargo/config.toml b/ableos/.cargo/config.toml index f450ff4..06f0486 100644 --- a/ableos/.cargo/config.toml +++ b/ableos/.cargo/config.toml @@ -7,10 +7,6 @@ build-std-features = ["compiler-builtins-mem"] [target.'cfg(target_arch = "x86_64")'] -<<<<<<< HEAD -# --quiet suppresses warning messages from the bootimage crate -======= ->>>>>>> 9bba5ae0fa0b592727d97ff033f639e3e07b2a74 runner = "bootimage runner" [target.riscv64gc-unknown-none-elf] diff --git a/ableos/src/vga_e.rs b/ableos/src/vga_e.rs index 02ed149..8b39667 100644 --- a/ableos/src/vga_e.rs +++ b/ableos/src/vga_e.rs @@ -20,6 +20,8 @@ lazy_static::lazy_static! { pub static ref VGAE_BUFF_OFFSET_Y: spin::Mutex = spin::Mutex::new(0); } +const FONT_SCALE: f32 = 1.6; + /// Draw a glyph on the screen at the given position /// /// # Arguments @@ -31,41 +33,40 @@ pub fn draw_char(x: u8, y: u8, character: char, color: Rgba64) { // let mode = *VGAE.lock(); let mut mode = SCREEN_BUFFER.lock(); - let font = FontRef::try_from_slice(include_bytes!( + let basic_multingual_plane = FontRef::try_from_slice(include_bytes!( "../../ableos/assets/fonts/unifont-14.0.01.ttf" )) .unwrap(); - let font2 = FontRef::try_from_slice(include_bytes!( + let supplementary_multilingual_plane = FontRef::try_from_slice(include_bytes!( "../../ableos/assets/fonts/unifont_upper-14.0.01.ttf" )) .unwrap(); - let mut has_char = false; - for x in font.codepoint_ids() { - if x.1 == character { - has_char = true; - break; - } - } + // let mut has_char = false; + // for x in font.codepoint_ids() { + // if x.1 == character { + // has_char = true; + // break; + // } + // } - let used_font; - match has_char { - true => used_font = font, - false => used_font = font2, - } + let is_in_basic_multilingual_plane = character as u32 <= 0xffff; - let font_scale = 1.6; + let plane = match is_in_basic_multilingual_plane { + true => basic_multingual_plane, + false => supplementary_multilingual_plane, + }; match character { '\n' => {} _ => { - let mut q_glyph: Glyph = used_font.glyph_id(character).with_scale_and_position( - 20.0 * font_scale, - ab_glyph::point(10.0 * font_scale, 18.0 * font_scale), + let q_glyph: Glyph = plane.glyph_id(character).with_scale_and_position( + 20.0 * FONT_SCALE, + ab_glyph::point(10.0 * FONT_SCALE, 18.0 * FONT_SCALE), ); - if let Some(q) = used_font.outline_glyph(q_glyph) { + if let Some(q) = plane.outline_glyph(q_glyph) { q.draw(|x, y, c| { if c > 0.015 { let corner = q.px_bounds().min; @@ -80,6 +81,7 @@ pub fn draw_char(x: u8, y: u8, character: char, color: Rgba64) { } } } + /// Converts a number to ... i forgor 💀 pub fn num_to_vga16(num: u8) -> Color16 { use Color16::*; diff --git a/shadeable/src/pixel_format.rs b/shadeable/src/pixel_format.rs index bd9fad2..b14c051 100644 --- a/shadeable/src/pixel_format.rs +++ b/shadeable/src/pixel_format.rs @@ -1,4 +1,3 @@ -#![feature(exclusive_range_pattern)] use vga::colors::Color16; pub type Rgba64 = u64; From ffdb6c2816ba321e27b446b69e298057343c8678 Mon Sep 17 00:00:00 2001 From: Elfein Landers Date: Wed, 26 Jan 2022 23:15:58 -0800 Subject: [PATCH 3/4] impl glyph drawing ig --- ableos/src/vga_e.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ableos/src/vga_e.rs b/ableos/src/vga_e.rs index 8b39667..f151490 100644 --- a/ableos/src/vga_e.rs +++ b/ableos/src/vga_e.rs @@ -21,6 +21,8 @@ lazy_static::lazy_static! { } const FONT_SCALE: f32 = 1.6; +const GLYPH_HEIGHT: f32 = 18.0; +const GLYPH_WIDTH: f32 = 10.0; /// Draw a glyph on the screen at the given position /// @@ -29,7 +31,7 @@ const FONT_SCALE: f32 = 1.6; /// * `y` - the y position of the glyph /// * `glyph` - the glyph to draw /// * `color` - the color of the glyph -pub fn draw_char(x: u8, y: u8, character: char, color: Rgba64) { +pub fn draw_char(mut x: u32, mut y: u32, character: char, color: Rgba64) { // let mode = *VGAE.lock(); let mut mode = SCREEN_BUFFER.lock(); @@ -63,16 +65,22 @@ pub fn draw_char(x: u8, y: u8, character: char, color: Rgba64) { _ => { let q_glyph: Glyph = plane.glyph_id(character).with_scale_and_position( 20.0 * FONT_SCALE, - ab_glyph::point(10.0 * FONT_SCALE, 18.0 * FONT_SCALE), + ab_glyph::point(GLYPH_WIDTH * FONT_SCALE, GLYPH_HEIGHT * FONT_SCALE), ); + // elf: I don't know if GLYPH_HEIGHT is in the right units here. I'm just guessing. + if x as usize > SCREEN_BUFFER.lock().size.x { + x = 0; + y += (GLYPH_HEIGHT * FONT_SCALE) as u32; + } + if let Some(q) = plane.outline_glyph(q_glyph) { - q.draw(|x, y, c| { + q.draw(|gx, gy, c| { if c > 0.015 { let corner = q.px_bounds().min; mode.set_pixel( - x as usize + corner.x as usize, - y as usize + corner.y as usize, + gx as usize + corner.x as usize + x as usize, + gy as usize + corner.y as usize + y as usize, color, ); } From 01892368934881269fee11ae64d2299ab59e0841 Mon Sep 17 00:00:00 2001 From: Elfein Landers Date: Wed, 26 Jan 2022 23:36:46 -0800 Subject: [PATCH 4/4] maybe commit --- ableos/src/kmain.rs | 404 ++++++++++++++++++++++---------------------- ableos/src/vga_e.rs | 2 +- 2 files changed, 203 insertions(+), 203 deletions(-) diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index 5f1b931..d718d7e 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -3,307 +3,307 @@ use alloc::{format, vec::Vec}; use crate::{ - boot_conf::BootConfig, - capabilities::FileAccess, - file::{File, PathRep}, - scheduler::SCHEDULER, + boot_conf::BootConfig, + capabilities::FileAccess, + file::{File, PathRep}, + scheduler::SCHEDULER, }; // use crate::scheduler; use { - crate::{ - arch::{init, sloop}, - boot_conf, - experiments::{ - info::master, - systeminfo::{KERNEL_VERSION, RELEASE_TYPE}, - }, - graphics::{VgaBuffer, SCREEN_BUFFER}, - relib::network::socket::Socket, - relib::network::socket::{SimpleSock, SocketReturns}, - vga_e::{self, num_to_vga16}, - }, - alloc::{ - string::{String, ToString}, - vec, - }, - core::sync::atomic::{AtomicU64, Ordering::*}, - lazy_static::lazy_static, - log::*, - picorand::PicoRandGenerate, - rkyv::{ser::serializers::AllocSerializer, Deserialize}, - shadeable::pixel_format::from_vga_16, - y_compositor_protocol::Version, + crate::{ + arch::{init, sloop}, + boot_conf, + experiments::{ + info::master, + systeminfo::{KERNEL_VERSION, RELEASE_TYPE}, + }, + graphics::{VgaBuffer, SCREEN_BUFFER}, + relib::network::socket::Socket, + relib::network::socket::{SimpleSock, SocketReturns}, + vga_e::{self, num_to_vga16}, + }, + alloc::{ + string::{String, ToString}, + vec, + }, + core::sync::atomic::{AtomicU64, Ordering::*}, + lazy_static::lazy_static, + log::*, + picorand::PicoRandGenerate, + rkyv::{ser::serializers::AllocSerializer, Deserialize}, + shadeable::pixel_format::from_vga_16, + y_compositor_protocol::Version, }; #[no_mangle] #[allow(unconditional_recursion)] pub extern "C" fn stack_overflow() -> u8 { - stack_overflow(); - // meme number - 69 // NOTE: Any specific reason for this number aside from memes? + stack_overflow(); + // meme number + 69 // NOTE: Any specific reason for this number aside from memes? } lazy_static! { - pub static ref KEY_BUFFER: spin::Mutex = spin::Mutex::new("".to_string()); - pub static ref TICK: AtomicU64 = AtomicU64::new(0); - pub static ref BOOT_CONF: BootConfig = boot_conf::BootConfig::new(); + pub static ref KEY_BUFFER: spin::Mutex = spin::Mutex::new("".to_string()); + pub static ref TICK: AtomicU64 = AtomicU64::new(0); + pub static ref BOOT_CONF: BootConfig = boot_conf::BootConfig::new(); } /// The main entry point of the kernel #[no_mangle] pub fn kernel_main() -> ! { - init::init(); - log::set_max_level(BOOT_CONF.log_level()); - // info!("Initialized"); + init::init(); + log::set_max_level(BOOT_CONF.log_level()); + // info!("Initialized"); - // facepalm::start_facepalm(); + // facepalm::start_facepalm(); - graphics_pipe_startup(); + graphics_pipe_startup(); - if false { - let mut proc_1 = SimpleSock::new(); - proc_1.register_protocol("ProcessSpawner".to_string()); + if false { + let mut proc_1 = SimpleSock::new(); + proc_1.register_protocol("ProcessSpawner".to_string()); - let version = 0; - use rkyv::ser::Serializer; - let mut serializer = AllocSerializer::<0>::default(); - serializer.serialize_value(&version).unwrap(); + let version = 0; + use rkyv::ser::Serializer; + let mut serializer = AllocSerializer::<0>::default(); + serializer.serialize_value(&version).unwrap(); - let bytes = serializer.into_serializer().into_inner(); - proc_1.write(bytes.into_vec()); - unsafe { - let the_bytes = proc_1.read(3).unwrap(); - let archived = rkyv::archived_root::(&the_bytes); - let deserialized: Version = archived.deserialize(&mut rkyv::Infallible).unwrap(); - trace!("{:?}", deserialized); - } - } + let bytes = serializer.into_serializer().into_inner(); + proc_1.write(bytes.into_vec()); + unsafe { + let the_bytes = proc_1.read(3).unwrap(); + let archived = rkyv::archived_root::(&the_bytes); + let deserialized: Version = archived.deserialize(&mut rkyv::Infallible).unwrap(); + trace!("{:?}", deserialized); + } + } - use crate::scheduler::Priority; - let mut scheduler = SCHEDULER.lock(); + use crate::scheduler::Priority; + let mut scheduler = SCHEDULER.lock(); - use Priority::*; + use Priority::*; - let mut xyz = scheduler.new_process(High); - xyz.capabilities.files = FileAccess::Some(vec![PathRep { - location: FileLocations::Home, - file_name: "test".to_string(), - }]); + let mut xyz = scheduler.new_process(High); + xyz.capabilities.files = FileAccess::Some(vec![PathRep { + location: FileLocations::Home, + file_name: "test".to_string(), + }]); - scheduler.add_process(xyz); - for x in &scheduler.list { - trace!("{:?}", x); - } - drop(scheduler); + scheduler.add_process(xyz); + for x in &scheduler.list { + trace!("{:?}", x); + } + drop(scheduler); - use crate::proto_filetable::contain::FILE_TABLE; - use crate::proto_filetable::file::FileLocations; + use crate::proto_filetable::contain::FILE_TABLE; + use crate::proto_filetable::file::FileLocations; - let mut file_table = FILE_TABLE.lock(); - let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string()); - new_file.write_bytes(b"Hello, world!"); + let mut file_table = FILE_TABLE.lock(); + let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string()); + new_file.write_bytes(b"Hello, world!"); - file_table.add_file("test", new_file); + file_table.add_file("test", new_file); - let file = file_table.get_file("test"); + let file = file_table.get_file("test"); - match file { - Some(file) => { - let file_bytes = &file.data_pointer; - let file_string = String::from_utf8(file_bytes.to_vec()).unwrap(); - info!("{}", file_string); - } - None => { - info!("File not found"); - } - } + match file { + Some(file) => { + let file_bytes = &file.data_pointer; + let file_string = String::from_utf8(file_bytes.to_vec()).unwrap(); + info!("{}", file_string); + } + None => { + info!("File not found"); + } + } - use crate::wasm::WasmProgram; - let ret = WasmProgram::new_from_bytes(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]); - trace!("Binary Valid: {:?}", ret.validate_header()); + use crate::wasm::WasmProgram; + let ret = WasmProgram::new_from_bytes(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]); + trace!("Binary Valid: {:?}", ret.validate_header()); - if BOOT_CONF.run_tests { - // quick and dirty testing framework - screen_writer_test(); - socket_test(); - graphics_pipe_test(); - socket_startup_rng(); - socket_test_rng(); - } + // quick and dirty testing framework + // if BOOT_CONF.run_tests { + screen_writer_test(); + socket_test(); + graphics_pipe_test(); + socket_startup_rng(); + socket_test_rng(); + // } - if BOOT_CONF.run_demos { - graphics_api_demo(); - } + if BOOT_CONF.run_demos { + graphics_api_demo(); + } - if BOOT_CONF.run_shader_tests { - shader_tests(); - } + if BOOT_CONF.run_shader_tests { + shader_tests(); + } - sloop() + sloop() } /// called by arch specific timers to tick up all kernel related functions pub fn tick() { - let mut data = TICK.load(Relaxed); - data += 1; + let mut data = TICK.load(Relaxed); + data += 1; - crate::kernel_state::KERNEL_STATE.lock().update_state(); + crate::kernel_state::KERNEL_STATE.lock().update_state(); - let mut scheduler = SCHEDULER.lock(); - scheduler.bump_exec(); + let mut scheduler = SCHEDULER.lock(); + scheduler.bump_exec(); - TICK.store(data, Relaxed) + TICK.store(data, Relaxed) } /// called every time a key is pressed to add it to the randomness pool pub fn key_entropy(key: u8) {} pub fn cpu_socket_startup() { - let mut cpu_info_socket = SimpleSock::new(); - cpu_info_socket.register_protocol("CPU_INFO".to_string()); + let mut cpu_info_socket = SimpleSock::new(); + cpu_info_socket.register_protocol("CPU_INFO".to_string()); - let x = master().unwrap(); - let _xyz = x.brand_string().unwrap(); + let x = master().unwrap(); + let _xyz = x.brand_string().unwrap(); } pub fn log_version_data() { - info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); - info!( - "Brand String: {:?}", - master().unwrap().brand_string().unwrap() - ); + info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); + info!( + "Brand String: {:?}", + master().unwrap().brand_string().unwrap() + ); } pub fn socket_test() { - let mut xyz = SimpleSock::new(); + let mut xyz = SimpleSock::new(); - xyz.peek(); + xyz.peek(); - xyz.write(vec![0, 1, 2, 3]); + xyz.write(vec![0, 1, 2, 3]); - let x = "simple 🧦".to_string().into_bytes(); - xyz.write(x); + let x = "simple 🧦".to_string().into_bytes(); + xyz.write(x); - info!("{:?}", &xyz.read(4).unwrap()); + info!("{:?}", &xyz.read(4).unwrap()); - match &xyz.peek() { - SocketReturns::ReadOk(strr) => { - let out = String::from_utf8_lossy(strr); + match &xyz.peek() { + SocketReturns::ReadOk(strr) => { + let out = String::from_utf8_lossy(strr); - info!("{}", out); - } - SocketReturns::ReadIndexOutOfBounds => todo!(), - SocketReturns::WriteOk => todo!(), - } + info!("{}", out); + } + SocketReturns::ReadIndexOutOfBounds => todo!(), + SocketReturns::WriteOk => todo!(), + } } pub fn socket_test_rng() { - let mut test_sock = SimpleSock::grab_socket("RNGProvider".to_string()).unwrap(); - info!( - "Recieving {} from protocol {}", - test_sock.read(1).unwrap()[0], - test_sock.protocol().unwrap() - ); + let mut test_sock = SimpleSock::grab_socket("RNGProvider".to_string()).unwrap(); + info!( + "Recieving {} from protocol {}", + test_sock.read(1).unwrap()[0], + test_sock.protocol().unwrap() + ); } pub fn socket_startup_rng() { - use picorand::{WyRand, RNG}; - let mut random_socket = SimpleSock::new(); + use picorand::{WyRand, RNG}; + let mut random_socket = SimpleSock::new(); - random_socket.register_protocol("RNGProvider".to_string()); - let bruh = TICK.load(core::sync::atomic::Ordering::Relaxed); + random_socket.register_protocol("RNGProvider".to_string()); + let bruh = TICK.load(core::sync::atomic::Ordering::Relaxed); - let mut rng = RNG::::new(bruh); + let mut rng = RNG::::new(bruh); - for _ in 0..512 { - let x = rng.generate(); - random_socket.write(vec![x]); - } + for _ in 0..512 { + let x = rng.generate(); + random_socket.write(vec![x]); + } } pub fn screen_writer_test() { - let mut sock_print_id = SimpleSock::new(); + let mut sock_print_id = SimpleSock::new(); - sock_print_id.register_protocol("Screen Printer".to_string()); - // sock_print_id.write(format!("a原 b画 cフ dァ eイ fル 集").into()); - // sock_print_id.write(format!("⋮").into()); + sock_print_id.register_protocol("Screen Printer".to_string()); + // sock_print_id.write(format!("a原 b画 cフ dァ eイ fル 集").into()); + // sock_print_id.write(format!("⋮").into()); - sock_print_id.write(format!("λ³ Half Life 3 booting up ㎣").into()); - // sock_print_id.write(format!("Happy birthday 🎉").into()); - // sock_print_id.write(format!("I look forward to ur ai stuff :^>").into()); - // sock_print_id.write(format!("1....2....3....4....5....6....7....8....9").into()); + sock_print_id.write(format!("λ³ Half Life 3 booting up ㎣").into()); + // sock_print_id.write(format!("Happy birthday 🎉").into()); + // sock_print_id.write(format!("I look forward to ur ai stuff :^>").into()); + // sock_print_id.write(format!("1....2....3....4....5....6....7....8....9").into()); - for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() { - vga_e::draw_char(0, 0, current, 0); - } + for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() { + vga_e::draw_char(0, 0, current, 0); + } } pub fn vga_boot_screen() { - let mut abcde = SCREEN_BUFFER.lock(); + let mut abcde = SCREEN_BUFFER.lock(); - for y in 0..480 { - for x in 0..640 { - let segment_x = x * 4 / 640; - let segment_y = y * 4 / 480; - let segment = segment_x + segment_y * 4; + for y in 0..480 { + for x in 0..640 { + let segment_x = x * 4 / 640; + let segment_y = y * 4 / 480; + let segment = segment_x + segment_y * 4; - abcde.set_pixel(x, y, from_vga_16(num_to_vga16(segment as u8))); - } - } + abcde.set_pixel(x, y, from_vga_16(num_to_vga16(segment as u8))); + } + } } pub fn graphics_pipe_test() { - let mut graphics_pipe = SimpleSock::grab_socket("YCompositor".to_string()).unwrap(); + let mut graphics_pipe = SimpleSock::grab_socket("YCompositor".to_string()).unwrap(); - let version = Version { - major: 13, - minor: 123, - patch: 0, - }; - use rkyv::ser::Serializer; - let mut serializer = AllocSerializer::<0>::default(); - serializer.serialize_value(&version).unwrap(); - // let bytes = serializer.into_serializer().into_inner(); + let version = Version { + major: 13, + minor: 123, + patch: 0, + }; + use rkyv::ser::Serializer; + let mut serializer = AllocSerializer::<0>::default(); + serializer.serialize_value(&version).unwrap(); + // let bytes = serializer.into_serializer().into_inner(); - // info!("{:?}", bytes); - let bytes = serializer.into_serializer().into_inner(); - graphics_pipe.write(bytes.into_vec()); - unsafe { - let the_bytes = graphics_pipe.read(3).unwrap(); - let archived = rkyv::archived_root::(&the_bytes); - let deserialized: Version = archived.deserialize(&mut rkyv::Infallible).unwrap(); - trace!("{:?}", deserialized); - } + // info!("{:?}", bytes); + let bytes = serializer.into_serializer().into_inner(); + graphics_pipe.write(bytes.into_vec()); + unsafe { + let the_bytes = graphics_pipe.read(3).unwrap(); + let archived = rkyv::archived_root::(&the_bytes); + let deserialized: Version = archived.deserialize(&mut rkyv::Infallible).unwrap(); + trace!("{:?}", deserialized); + } } pub fn graphics_pipe_startup() { - let mut graphics_pipe = SimpleSock::new(); + let mut graphics_pipe = SimpleSock::new(); - graphics_pipe.register_protocol("YCompositor".to_string()); + graphics_pipe.register_protocol("YCompositor".to_string()); } pub fn graphics_api_demo() { - let mut abcde = SCREEN_BUFFER.lock(); - abcde.force_redraw(); + let mut abcde = SCREEN_BUFFER.lock(); + abcde.force_redraw(); - abcde.draw_filled_circle(100, 100, 300, 0x0000ff00); - abcde.draw_unfilled_rect(100, 100, 400, 200, 0xff000000); - abcde.draw_filled_rect(300, 300, 400, 400, 0xff000000); - abcde.draw_line(100, 100, 400, 200, 0xff000000); - abcde.copy_to_buffer(); + abcde.draw_filled_circle(100, 100, 300, 0x0000ff00); + abcde.draw_unfilled_rect(100, 100, 400, 200, 0xff000000); + abcde.draw_filled_rect(300, 300, 400, 400, 0xff000000); + abcde.draw_line(100, 100, 400, 200, 0xff000000); + abcde.copy_to_buffer(); } pub fn shader_tests() { - let mut graphics = SCREEN_BUFFER.lock(); + let mut graphics = SCREEN_BUFFER.lock(); - graphics.clear(); - graphics.force_redraw(); - graphics.draw_filled_rect(25, 25, 50, 50, 0xff000000); - graphics.set_pixel(50, 50, 0xffffff00); - graphics.shade(); + graphics.clear(); + graphics.force_redraw(); + graphics.draw_filled_rect(25, 25, 50, 50, 0xff000000); + graphics.set_pixel(50, 50, 0xffffff00); + graphics.shade(); - graphics.copy_to_buffer(); + graphics.copy_to_buffer(); - // drop(graphics) + // drop(graphics) } diff --git a/ableos/src/vga_e.rs b/ableos/src/vga_e.rs index f151490..2c6a1ff 100644 --- a/ableos/src/vga_e.rs +++ b/ableos/src/vga_e.rs @@ -69,7 +69,7 @@ pub fn draw_char(mut x: u32, mut y: u32, character: char, color: Rgba64) { ); // elf: I don't know if GLYPH_HEIGHT is in the right units here. I'm just guessing. - if x as usize > SCREEN_BUFFER.lock().size.x { + if x as usize > mode.size.x { x = 0; y += (GLYPH_HEIGHT * FONT_SCALE) as u32; }