1
0
Fork 0
forked from AbleOS/ableos

hexadecimal support!!

remove fb_driver_stresstest, move examples back to fb_driver, update hblang, update Cargo.lock
This commit is contained in:
koniifer 2024-09-01 22:29:42 +01:00
parent c752028c73
commit f7b970eaf0
18 changed files with 348 additions and 342 deletions

592
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@ kiam = "0.1.1"
[dependencies.limine] [dependencies.limine]
version = "0.1" version = "0.1"
git = "https://github.com/limine-bootloader/limine-rs" #git = "https://github.com/limine-bootloader/limine-rs"
[dependencies.crossbeam-queue] [dependencies.crossbeam-queue]
version = "0.3" version = "0.3"

View file

@ -40,10 +40,10 @@ outl := fn(addr: u16, value: u32): void {
*msg = 1; *msg = 1;
*(msg + 1) = 2; *(msg + 1) = 2;
*@as(^u16, @bitcast(msg + 2)) = addr; *@as(^u16, @bitcast(msg + 2)) = addr;
*(msg + 4) = value >> 24 & 255; *(msg + 4) = value >> 24 & 0xFF;
*(msg + 5) = value >> 16 & 255; *(msg + 5) = value >> 16 & 0xFF;
*(msg + 6) = value >> 8 & 255; *(msg + 6) = value >> 8 & 0xFF;
*(msg + 7) = value & 255 *(msg + 7) = value & 0xFF
@eca(void, 3, 3, msg, 8) @eca(void, 3, 3, msg, 8)
return return
} }

View file

@ -5,7 +5,7 @@ serial_print := fn(ptr: ^u8): void {
letter := 0 letter := 0
loop if *ptr == 0 break else { loop if *ptr == 0 break else {
letter = *ptr letter = *ptr
memory.outb(63491, letter) memory.outb(0xF803, letter)
ptr += 1 ptr += 1
} }
return return
@ -13,8 +13,8 @@ serial_print := fn(ptr: ^u8): void {
serial_println := fn(ptr: ^u8): void { serial_println := fn(ptr: ^u8): void {
serial_print(ptr) serial_print(ptr)
memory.outb(63491, 12) memory.outb(0xF803, 12)
memory.outb(63491, 13) memory.outb(0xF803, 13)
return return
} }
@ -26,7 +26,7 @@ main := fn(): int {
mem := memory.request_page(1) mem := memory.request_page(1)
loop { loop {
ptr := @eca(int, 4, a, mem, 4096) ptr := @eca(int, 4, a, mem, 0x1000)
if ptr == 0 { if ptr == 0 {
serial_println("No message\0") serial_println("No message\0")
} }

View file

@ -3,10 +3,10 @@ stn := @use("../../../libraries/stn/src/lib.hb");
main := fn(): int { main := fn(): int {
// shuts down ableOS // shuts down ableOS
//memory.outb(62464, 0) //memory.outb(0xF400, 0)
a := memory.inb(17920) a := memory.inb(0x4600)
b := memory.inb(18176) b := memory.inb(0x4700)
c := buffer.search("XNumber\0") c := buffer.search("XNumber\0")

View file

@ -22,6 +22,6 @@ LIGHTCYAN := ColorBGRA.{b: 255, g: 255, r: 0, a: 255}
// i have no clue if this works. please don't me ask how it works. -koniifer // i have no clue if this works. please don't me ask how it works. -koniifer
blend := fn(fg: ColorBGRA, bg: ColorBGRA): ColorBGRA { blend := fn(fg: ColorBGRA, bg: ColorBGRA): ColorBGRA {
s := fg + bg s := fg + bg
m := s - ((fg ^ bg) & 16843008) & 16843008 m := s - ((fg ^ bg) & 0x1010100) & 0x1010100
return (m >> 8 | 16777216 * (s < fg)) * 255 | s - m return (m >> 8 | 0x1000000 * (s < fg)) * 0xFF | s - m
} }

View file

@ -12,7 +12,7 @@ example := fn(): void {
color := ColorBGRA.(0, 255, 0, 255) color := ColorBGRA.(0, 255, 0, 255)
/* have to explicitly say 0 is a u8, or we do something crazy to the colors. /* have to explicitly say 0 is a u8, or we do something crazy to the colors.
looks like a compiler bug */ looks like a compiler bug */
n := @as(i8, @as(u8, 0)) - 1 n := @as(u8, 0) - 1
loop { loop {
clear(buffer, color) clear(buffer, color)
present(buffer) present(buffer)

View file

@ -5,9 +5,10 @@ FB_WIDTH := 1024
FB_HEIGHT := 768 FB_HEIGHT := 768
FB_PIXELS := FB_WIDTH * FB_HEIGHT FB_PIXELS := FB_WIDTH * FB_HEIGHT
FB_BYTES := FB_PIXELS << 2 FB_BYTES := FB_PIXELS << 2
// actual enforced max copy size is (1 << 16) - 1, but this was faster // actual enforced max copy size is 0xFFFF, but this was faster
MAX_COPY_SIZE := 6144 MAX_COPY_SIZE := 0x1800
// see stn.math.min, cant use here due to compiler bug (reg id leaked) // see stn.math.min, cant use here due to compiler bug (reg id leaked)
// COPY_PIXELS := math.min(MAX_COPY_SIZE, FB_BYTES) >> 2
COPY_PIXELS := MAX_COPY_SIZE + (FB_BYTES - MAX_COPY_SIZE & FB_BYTES - MAX_COPY_SIZE >> 31) >> 2 COPY_PIXELS := MAX_COPY_SIZE + (FB_BYTES - MAX_COPY_SIZE & FB_BYTES - MAX_COPY_SIZE >> 31) >> 2
PARTITIONS := FB_PIXELS / COPY_PIXELS PARTITIONS := FB_PIXELS / COPY_PIXELS
TOTAL_PAGES := 1 + FB_BYTES >> 12 TOTAL_PAGES := 1 + FB_BYTES >> 12
@ -17,12 +18,12 @@ Point := struct {x: int, y: int}
Transform := struct {width: int, height: int} Transform := struct {width: int, height: int}
Rect := struct {p1: Point, p2: Point} Rect := struct {p1: Point, p2: Point}
front_buffer_ptr := @as(^ColorBGRA, @bitcast(18446603339442421760)) front_buffer_ptr := @as(^ColorBGRA, @bitcast(0xFFFF8000C0000000))
front_buffer_copy := @as(^[ColorBGRA; COPY_PIXELS], @bitcast(front_buffer_ptr)) front_buffer_copy := @as(^[ColorBGRA; COPY_PIXELS], @bitcast(front_buffer_ptr))
get_front_buffer := fn(): Buffer { get_front_buffer := fn(): Buffer {
// trying to return front_buffer_ptr or front_buffer_copy causes reg id leak // trying to return front_buffer_ptr or front_buffer_copy causes reg id leak
return Buffer.{write: @as(^ColorBGRA, @bitcast(18446603339442421760)), copy: @as(^[ColorBGRA; COPY_PIXELS], @bitcast(18446603339442421760))} return Buffer.{write: @as(^ColorBGRA, @bitcast(0xFFFF8000C0000000)), copy: @as(^[ColorBGRA; COPY_PIXELS], @bitcast(0xFFFF8000C0000000))}
} }
/* this is separate to create_raw_buffer because returning a Buffer from /* this is separate to create_raw_buffer because returning a Buffer from
create_raw_buffer causes reg id leak */ create_raw_buffer causes reg id leak */
@ -36,18 +37,18 @@ create_buffer := fn(): Buffer {
create_raw_buffer := fn(): ^ColorBGRA { create_raw_buffer := fn(): ^ColorBGRA {
// helps to trace allocation bugs // helps to trace allocation bugs
log.info("Creating buffer. This will allocate.\0") log.info("Creating buffer. This will allocate.\0")
if TOTAL_PAGES <= 255 { if TOTAL_PAGES <= 0xFF {
return @bitcast(memory.request_page(TOTAL_PAGES)) return @bitcast(memory.request_page(TOTAL_PAGES))
} }
ptr := memory.request_page(255) ptr := memory.request_page(255)
remaining := TOTAL_PAGES - 255 remaining := TOTAL_PAGES - 0xFF
loop if remaining <= 0 break else { loop if remaining <= 0 break else {
if remaining < 255 { if remaining < 0xFF {
memory.request_page(remaining) memory.request_page(remaining)
} else { } else {
memory.request_page(255) memory.request_page(0xFF)
} }
remaining -= 255 remaining -= 0xFF
} }
return @bitcast(ptr) return @bitcast(ptr)
} }

View file

@ -1,19 +1,6 @@
.{log, memory, string, buffer} := @use("../../../libraries/stn/src/lib.hb") .{example} := @use("./examples/colors.hb")
main := fn(): int { main := fn(): int {
buffer_id := buffer.create("XGraphics\0") example()
memmap := memory.request_page(1)
x := 0
loop {
msg := buffer.receive_message(buffer_id, memmap, 0)
if msg != 0 {
log.info("Hello, Framebuffer!\0")
}
loop if x == 4096 {
*(memmap + x) = 0
x += 1
}
x = 0
}
return 0 return 0
} }

View file

@ -1,11 +0,0 @@
[package]
name = "fb_driver_stresstest"
authors = ["aurlex"]
[dependants.libraries]
[dependants.binaries]
hblang.version = "1.0.0"
[build]
command = "hblang src/main.hb"

View file

@ -1,6 +0,0 @@
.{test, put_pixel, sync} := @use("../../../libraries/render/src/lib.hb").software
main := fn(): int {
test()
return 0
}

View file

@ -1,23 +1,23 @@
.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb") .{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb")
send_byte := fn(byte: u8): u8 { send_byte := fn(byte: u8): u8 {
memory.outb(24576, byte) memory.outb(0x6000, byte)
return memory.inb(24576) return memory.inb(0x6000)
} }
main := fn(): int { main := fn(): int {
log.info("PS/2 Driver Loaded\0") log.info("PS/2 Driver Loaded\0")
if send_byte(238) == 238 { if send_byte(0xEE) == 0xEE {
log.info("PS/2 Keyboard Echoed\0") log.info("PS/2 Keyboard Echoed\0")
} }
if send_byte(244) == 250 { if send_byte(0xF4) == 0xFA {
log.info("Enabled scanning\0") log.info("Enabled scanning\0")
} }
buf := buffer.create("XKeyboard\0") buf := buffer.create("XKeyboard\0")
ptr := memory.request_page(1) ptr := memory.request_page(1)
prev_input := 250 prev_input := 0xFA
loop { loop {
input := memory.inb(24576) input := memory.inb(0x6000)
if input == prev_input { if input == prev_input {
continue continue
} }

View file

@ -34,6 +34,3 @@ path = "boot:///fb_driver.hbf"
[boot.limine.ableos.modules.serial_driver_test] [boot.limine.ableos.modules.serial_driver_test]
path = "boot:///serial_driver_test.hbf" path = "boot:///serial_driver_test.hbf"
[boot.limine.ableos.modules.fb_driver_stresstest]
path = "boot:///fb_driver_stresstest.hbf"