diff --git a/Cargo.lock b/Cargo.lock index 28e2305..75c9a25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,17 +390,17 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -408,7 +408,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -416,7 +416,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/ableos/holey-bytes#641d344d2dcdf9392f6506831f5ccc31ed5e2ab8" +source = "git+https://git.ablecorp.us/ableos/holey-bytes#2bc7a5c13f6ab2b3ee28f772f31eb3414fa2b25b" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/ableos/holey-bytes)", ] diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 07fa1ad..dc4b83c 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -176,10 +176,21 @@ pub fn handler(vm: &mut Vm) { }; let fb1: &NonNullPtr = &FB_REQ.get_response().get().unwrap().framebuffers()[0]; - let fb_front = fb1.address.as_ptr().unwrap() as *const u8; - log::info!("Graphics front ptr {:?}", fb_front); - - vm.registers[1] = hbvm::value::Value(fb_front as u64); + let msg = block_read(mem_addr, length)[0]; + if msg == b'p' { + // ptr + let fb_front = fb1.address.as_ptr().unwrap() as *const u8; + log::info!("Graphics front ptr {:?}", fb_front); + vm.registers[1] = hbvm::value::Value(fb_front as u64); + } else if msg == b'w' { + // width + log::info!("FB Width: {}", fb1.width); + vm.registers[1] = hbvm::value::Value(fb1.width); + } else if msg == b'h' { + // height + log::info!("FB Height: {}", fb1.height); + vm.registers[1] = hbvm::value::Value(fb1.height); + } } buffer_id => { let mut buffs = IPC_BUFFERS.lock(); diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 7963c37..194b150 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -2,6 +2,7 @@ //! Named akern. //! Akern is woefully undersupported at the moment but we are looking to add support improve hardware discovery and make our lives as kernel and operating system developers easier and better #![no_std] +#![feature(new_uninit)] #![feature( abi_x86_interrupt, alloc_error_handler, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d3900e7..9353a54 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2024-07-17" +channel = "nightly-2024-07-27" components = ["rust-src", "llvm-tools"] diff --git a/sysdata/libraries/render/src/software.hb b/sysdata/libraries/render/src/software.hb index bf6de59..d584d44 100644 --- a/sysdata/libraries/render/src/software.hb +++ b/sysdata/libraries/render/src/software.hb @@ -19,13 +19,13 @@ light_blue := Color.(255, 0, 0, 255) light_magenta := Color.(255, 0, 255, 255) light_cyan := Color.(255, 255, 0, 255) -fb_width := 1024 -fb_height := 768 -fb_pixels := fb_width * fb_height -fb_bytes := fb_pixels << 2 -copy_pixels := math.min(0xC000, fb_bytes) >> 2 -partitions := fb_pixels / copy_pixels -total_pages := 1 + fb_bytes >> 12 +// fb_width := 1024 +// fb_height := 768 +// fb_pixels := fb_width * fb_height +// fb_bytes := fb_pixels << 2 +copy_pixels := 0xC000 >> 2 +// partitions := fb_pixels / copy_pixels +// total_pages := 1 + fb_bytes >> 12 ctx := @as(Context, idk) @@ -33,9 +33,38 @@ Context := struct { fb: ^Color, bb: ^Color, buf: ^Color, + width: int, + height: int, + partitions: int, + pixels: int, + bb_pages: int, double_buffer: bool, } +init := fn(): void { + width := @eca(int, 3, 6, "w\0", 2) + height := @eca(int, 3, 6, "h\0", 2) + // width := 1024 + // height := 768 + pixels := width * height + bytes := pixels << 2 + partitions := pixels / copy_pixels + pages := 1 + bytes >> 12 + back_buffer := create_back_buffer(pages) + ctx = Context.{ + fb: @eca(^Color, 3, 6, "p\0", 2), + bb: back_buffer, + buf: back_buffer, + width, + height, + partitions, + pixels, + bb_pages: pages, + double_buffer: true, + } + return +} + doublebuffer := fn(enable: bool): void { if enable { ctx.buf = ctx.bb @@ -46,12 +75,12 @@ doublebuffer := fn(enable: bool): void { return } -create_back_buffer := fn(): ^Color { - if total_pages <= 0xFF { - return @bitcast(@inline(memory.request_page, total_pages)) +create_back_buffer := fn(pages: int): ^Color { + if pages <= 0xFF { + return @bitcast(@inline(memory.request_page, pages)) } ptr := @inline(memory.request_page, 255) - remaining := total_pages - 0xFF + remaining := pages - 0xFF loop if remaining <= 0 break else { if remaining < 0xFF { memory.request_page(remaining) @@ -80,7 +109,7 @@ clear := fn(color: Color): void { *@as(^[Color; 4096], @bitcast(cursor)) = *@as(^[Color; 4096], @bitcast(ctx.buf)) cursor += 4096 } - boundary += (partitions - 1) * copy_pixels + boundary += (ctx.partitions - 1) * copy_pixels loop if cursor == boundary break else { *@as(^[Color; copy_pixels], @bitcast(cursor)) = *@as(^[Color; copy_pixels], @bitcast(ctx.buf)) cursor += @sizeof([u8; copy_pixels]) @@ -92,26 +121,26 @@ sync := fn(): void { if ctx.double_buffer { bb := ctx.buf fb := ctx.fb - boundary := bb + fb_pixels + boundary := bb + ctx.pixels loop if bb == boundary break else { *@as(^[Color; copy_pixels], @bitcast(fb)) = *@as(^[Color; copy_pixels], @bitcast(bb)) - bb += @sizeof([u8; copy_pixels]) - fb += @sizeof([u8; copy_pixels]) + bb += copy_pixels + fb += copy_pixels } } return } width := fn(): int { - return fb_width + return ctx.width } height := fn(): int { - return fb_height + return ctx.height } screenidx := fn(x: int, y: int): int { - return x + fb_width * y + return x + ctx.width * y } put_pixel := fn(pos: IVec2, color: Color): void { @@ -226,20 +255,9 @@ set_width := fn(new: int): void { } dimensions := fn(): IVec2 { - return .(fb_width, fb_height) + return .(ctx.width, ctx.height) } set_dimensions := fn(new: IVec2): void { return -} - -init := fn(): void { - back_buffer := create_back_buffer() - ctx = Context.{ - fb: @as(^Color, @bitcast(@eca(uint, 3, 6))), - bb: back_buffer, - buf: back_buffer, - double_buffer: true, - } - return } \ No newline at end of file