Merge main.

This commit is contained in:
peony 2024-11-10 21:26:54 +01:00
commit edfb588060
15 changed files with 287 additions and 17 deletions

6
Cargo.lock generated
View file

@ -228,12 +228,12 @@ dependencies = [
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#c61efc393361089f5217db9f4a9011ed0248b8db" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6274f3455d0545a64f2cc866b39d409e0a73427"
[[package]] [[package]]
name = "hblang" name = "hblang"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#c61efc393361089f5217db9f4a9011ed0248b8db" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6274f3455d0545a64f2cc866b39d409e0a73427"
dependencies = [ dependencies = [
"hashbrown 0.15.1", "hashbrown 0.15.1",
"hbbytecode", "hbbytecode",
@ -245,7 +245,7 @@ dependencies = [
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#c61efc393361089f5217db9f4a9011ed0248b8db" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6274f3455d0545a64f2cc866b39d409e0a73427"
dependencies = [ dependencies = [
"hbbytecode", "hbbytecode",
] ]

View file

@ -1,27 +1,27 @@
string := @use("string.hb") string := @use("string.hb")
recv := fn($Expr: type, buffer_id: int, memory_map_location: ^u8): void { recv := fn($Expr: type, buffer_id: uint, memory_map_location: ^u8): void {
return @eca(4, buffer_id, memory_map_location, @sizeof(Expr)) return @eca(4, buffer_id, memory_map_location, @sizeof(Expr))
} }
write := fn($Expr: type, msg: ^Expr, buffer_id: int): void { write := fn($Expr: type, msg: ^Expr, buffer_id: uint): void {
return @eca(3, buffer_id, msg, @sizeof(Expr)) return @eca(3, buffer_id, msg, @sizeof(Expr))
} }
recv_length := fn(buffer_id: int, memory_map_location: ^u8, length: int): void { recv_length := fn(buffer_id: uint, memory_map_location: ^u8, length: uint): void {
return @eca(4, buffer_id, memory_map_location, length) return @eca(4, buffer_id, memory_map_location, length)
} }
write_length := fn(msg: ^u8, buffer_id: int, length: int): void { write_length := fn(msg: ^u8, buffer_id: uint, length: uint): void {
return @eca(3, buffer_id, msg, length) return @eca(3, buffer_id, msg, length)
} }
BufferMsg := packed struct {operation: u8, msg: ^u8, msg_len: uint} BufferMsg := packed struct {operation: u8, msg: ^u8, msg_len: uint}
create := fn(msg: ^u8): int { create := fn(msg: ^u8): uint {
return @eca(3, 0, BufferMsg.(0, msg, @inline(string.length, msg)), @sizeof(BufferMsg)) return @eca(3, 0, BufferMsg.(0, msg, @inline(string.length, msg)), @sizeof(BufferMsg))
} }
search := fn(msg: ^u8): int { search := fn(msg: ^u8): uint {
return @eca(3, 0, BufferMsg.(3, msg, @inline(string.length, msg)), @sizeof(BufferMsg)) return @eca(3, 0, BufferMsg.(3, msg, @inline(string.length, msg)), @sizeof(BufferMsg))
} }

View file

@ -40,7 +40,7 @@ $TABLE_SIZE := @as(i32, 256)
sin := fn(theta: f32): f32 { sin := fn(theta: f32): f32 {
si := @fti(theta * 0.5 * @itf(TABLE_SIZE) / PI) si := @fti(theta * 0.5 * @itf(TABLE_SIZE) / PI)
d := theta - @floatcast(@itf(si)) * 2.0 * PI / @itf(TABLE_SIZE) d := theta - @floatcast(@itf(si)) * 2.0 * PI / @floatcast(@itf(TABLE_SIZE))
ci := si + TABLE_SIZE / 4 & TABLE_SIZE - 1 ci := si + TABLE_SIZE / 4 & TABLE_SIZE - 1
si &= TABLE_SIZE - 1 si &= TABLE_SIZE - 1
return SIN_TABLE[@bitcast(si)] + (SIN_TABLE[@bitcast(ci)] - 0.5 * SIN_TABLE[@bitcast(si)] * d) * d return SIN_TABLE[@bitcast(si)] + (SIN_TABLE[@bitcast(ci)] - 0.5 * SIN_TABLE[@bitcast(si)] * d) * d
@ -48,10 +48,10 @@ sin := fn(theta: f32): f32 {
cos := fn(theta: f32): f32 { cos := fn(theta: f32): f32 {
ci := @fti(theta * 0.5 * @itf(TABLE_SIZE) / PI) ci := @fti(theta * 0.5 * @itf(TABLE_SIZE) / PI)
d := theta - @floatcast(@itf(ci)) * 2.0 * PI / @itf(TABLE_SIZE) d := theta - @floatcast(@itf(ci)) * 2.0 * PI / @floatcast(@itf(TABLE_SIZE))
si := ci + TABLE_SIZE / 4 & TABLE_SIZE - 1 si := ci + TABLE_SIZE / 4 & TABLE_SIZE - 1
ci &= TABLE_SIZE - 1 ci &= TABLE_SIZE - 1
return SIN_TABLE[@bitcast(si)] + (SIN_TABLE[@bitcast(ci)] - 0.5 * SIN_TABLE[@bitcast(si)] * d) * d return SIN_TABLE[@bitcast(si)] - (SIN_TABLE[@bitcast(ci)] + 0.5 * SIN_TABLE[@bitcast(si)] * d) * d
} }
tan := fn(theta: f32): f32 { tan := fn(theta: f32): f32 {

View file

@ -2,6 +2,17 @@ PAGE_SIZE := 4096
MAX_ALLOC := 0xFF MAX_ALLOC := 0xFF
MAX_FREE := 0xFF MAX_FREE := 0xFF
is_uninit := fn($Expr: type, ptr: ^Expr): bool {
i := 0
loop if *(@as(^u8, @bitcast(ptr)) + i) != 0 return false else if i + 1 == @sizeof(Expr) return true else i += 1
}
uninit := fn($Expr: type): Expr {
empty := @as(Expr, idk)
@inline(set, u8, &0, @bitcast(&empty), @sizeof(Expr))
return empty
}
dangling := fn($Expr: type): ^Expr { dangling := fn($Expr: type): ^Expr {
return @bitcast(@alignof(Expr)) return @bitcast(@alignof(Expr))
} }

View file

@ -0,0 +1,62 @@
.{math: .{Vec2}, buffer, log, memory} := @use("../../stn/src/lib.hb");
.{Surface, new_surface} := @use("../../render/src/lib.hb");
.{WindowWrapper, WindowID, WindowProps, WindowMessage, message, BUFFER} := @use("./lib.hb")
buffer_id := @as(?uint, null)
new_window := fn(props: WindowProps): ?WindowWrapper {
if buffer_id == null {
log.error("client: (request_new) buffer id is null. did you init the client?\0")
return null
}
buf := memory.uninit(?WindowWrapper)
buffer.write(WindowMessage, &.(message.new, 0, @sizeof(WindowProps), @bitcast(&props), @bitcast(&buf)), @unwrap(buffer_id))
loop if memory.is_uninit(?WindowWrapper, &buf) == false break else {
}
// loop until i write a better socket
i := 0
loop if i >= 1000 break else i += 1
return buf
}
update_window_props := fn(wrapper: WindowWrapper): ?WindowProps {
log.error("todo: sunset_proto/src/client/update_window_props.hb\0")
if buffer_id == null {
log.error("client: (request_update_properties) buffer id is null. did you init the client?\0")
return null
}
// TODO: buffer.write(WINDOWING_BUFFER, update properties) request
return null
}
request_shutdown := fn(): ?bool {
if buffer_id == null {
log.error("client: (request_shutdown) buffer id is null. did you init the client?\0")
return null
}
buf := memory.uninit(?u8)
buffer.write(WindowMessage, &.(message.shutdown, 0, 0, memory.dangling(u8), @bitcast(&buf)), @unwrap(buffer_id))
loop if memory.is_uninit(?u8, &buf) == false break else {
}
// loop until i write a better socket
i := 0
loop if i >= 1000 break else i += 1
// had to do ?u8 here, ?bool didnt work
if buf == null | @unwrap(buf) != 255 {
return false
} else {
return true
}
}
init := fn(): void {
log.info("client: waiting for server\0")
id := 0
loop if id != 0 {
buffer_id = id
log.info("client: done waiting\0")
return
} else {
id = buffer.search(BUFFER)
}
}

View file

@ -0,0 +1,36 @@
.{math: .{Vec2}} := @use("../../stn/src/lib.hb");
.{Surface} := @use("../../render/src/lib.hb")
$BUFFER := "sunset\0"
client := @use("./client.hb")
server := @use("./server.hb")
message := @use("./message.hb")
WindowID := uint
MessageKind := uint
WindowMessage := packed struct {
kind: MessageKind,
id: WindowID,
length: uint,
data_ptr: ^u8,
// need to replace this with a buffer id
callback: ^u8,
}
WindowProps := struct {
position: Vec2(uint),
dimensions: Vec2(uint),
title: ^u8,
}
WindowWrapper := struct {
id: WindowID,
props: WindowProps,
}
Window := struct {
surface: Surface,
props: WindowProps,
}

View file

@ -0,0 +1,4 @@
$new := 0
$destroy := 1
$update_props := 2
$shutdown := 3

View file

@ -0,0 +1,34 @@
.{math, log, string, random, buffer, memory} := @use("../../stn/src/lib.hb");
.{Surface, new_surface} := @use("../../render/src/lib.hb");
.{WindowWrapper, WindowID, WindowProps, WindowMessage, BUFFER} := @use("./lib.hb")
WindowServer := struct {window_count: uint, buffer_id: uint}
server := @as(?WindowServer, null)
new_window_id := fn(): WindowID {
return random.any(uint)
}
init := fn(): bool {
log.info("server: starting server\0")
server = .(0, buffer.create(BUFFER))
return true
}
recieve := fn(): ?WindowMessage {
if server == null {
log.error("server: (request_new) server is null. did you init the client?\0")
return null
}
buf := memory.uninit(WindowMessage)
buffer.recv(WindowMessage, @unwrap(server).buffer_id, @bitcast(&buf))
if memory.is_uninit(WindowMessage, &buf) {
return null
}
return buf
}
should_shutdown := fn(): bool {
return false
}

View file

@ -60,9 +60,9 @@ main := fn(): int {
// TODO: Read the window buffer here // TODO: Read the window buffer here
{ {
// ret := buffer.recv([u8; 4096], win_buff, mem_buf) // buffer.recv([u8; 4096], win_buff, mem_buf)
// for some reason this null check causes the compiler to spin forever // // for some reason this null check causes the compiler to spin forever
// if ret == null { // if *mem_buf == 0 {
// log.info("No messages\0") // log.info("No messages\0")
// } else { // } else {
// log.info("Handle Messages\0") // log.info("Handle Messages\0")

View file

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

View file

@ -0,0 +1,24 @@
.{log, string} := @use("../../../libraries/stn/src/lib.hb")
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
main := fn(): void {
sunset.client.init()
log.info("client: request new window\0")
window := sunset.client.new_window(.(.(100, 100), .(150, 150), "Hello, World!\0"))
if window == null {
log.error("Could not create window\0")
return
}
log.info("client: window created. title:\0")
log.info(window.props.title)
window.props.position = .(500, 500)
props := @unwrap(sunset.client.update_window_props(window))
if props.position.x != window.props.position.x {
log.error("client: we did not update props\0")
}
log.info("client: sending shutdown request\0")
shutdown := sunset.client.request_shutdown()
if shutdown == null {
log.error("client: didnt shutdown the server\0")
}
}

View file

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

View file

@ -0,0 +1,36 @@
.{log} := @use("../../../libraries/stn/src/lib.hb")
render := @use("../../../libraries/render/src/lib.hb");
.{server, message, WindowWrapper, WindowProps} := @use("../../../libraries/sunset_proto/src/lib.hb")
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
main := fn(): void {
screen := render.init(false)
font := render.text.font_from_psf2(@bitcast(&psf), false)
if font == null {
return
}
if server.init() == false {
log.error("Failed to create server\0")
return
}
loop if server.should_shutdown() break else {
recv := server.recieve()
if recv == null {
continue
} else if recv.kind == message.new {
props := *@as(^WindowProps, @bitcast(recv.data_ptr));
*@as(^?WindowWrapper, @bitcast(recv.callback)) = WindowWrapper.(0, props)
render.put_rect(screen, props.position, props.dimensions, render.white)
render.put_text(screen, font, props.position + .(1, 1), render.white, props.title)
render.put_hline(screen, props.position.y + font.height + 2, props.position.x, props.position.x + props.dimensions.x, render.white)
log.info("server: made a new window\0")
} else if recv.kind == message.shutdown {
*@as(^?u8, @bitcast(recv.callback)) = 255
break
}
}
render.put_text(screen, font, .(0, 0), render.white, "Shutdown triggered\0")
log.info("Server shutdown\0")
}

View file

@ -34,5 +34,8 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.ps2_keyboard_driver] # [boot.limine.ableos.modules.ps2_keyboard_driver]
# path = "boot:///ps2_keyboard_driver.hbf" # path = "boot:///ps2_keyboard_driver.hbf"
[boot.limine.ableos.modules.ps2_driver] [boot.limine.ableos.modules.sunset_client]
path = "boot:///ps2_driver.hbf" path = "boot:///sunset_client.hbf"
[boot.limine.ableos.modules.sunset_server]
path = "boot:///sunset_server.hbf"

38
todo.md Normal file
View file

@ -0,0 +1,38 @@
@konii
Windowing System
Rendering
@able
Windowing System
Interrupt Forwarding
@peony
PS/2
XYZ
@kodin
AIDL AbleOS Interface Description Language
UI-SEXPR lispy ui decl language
@morshy
Simple Userland Allocator
@unassigned
FileIO (Fat32)
DiskIO (Undecided Disk type)
Proper Memory Protection
Channels (Two buffers bundled together to form two way communication)
Kernel Testing Framework (A rust framework for testing the kernel)
Userland Testing Framework (An hblang framework for testing the userspace)
PCI/E (Honestly I have no fucking clue whats going on with PCI or why userland cant properly read it)
Kernel Reimpl (Do not you dare think about this yet its only here as an option to show goals)
AbleOS Compiler Collection
acc-asm
hblang^2 (hblang compiler in hblang)