diff --git a/Cargo.lock b/Cargo.lock index baaf1a605..45ec40178 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,12 +213,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#86ca959ea3eae1cb32298e135a444820583d24a0" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#784d552c1dee2a3cfde4b83e01523d91988bb554" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#86ca959ea3eae1cb32298e135a444820583d24a0" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#784d552c1dee2a3cfde4b83e01523d91988bb554" dependencies = [ "hashbrown", "hbbytecode", @@ -229,7 +229,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#86ca959ea3eae1cb32298e135a444820583d24a0" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#784d552c1dee2a3cfde4b83e01523d91988bb554" dependencies = [ "hbbytecode", ] diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 5a80bf499..8d63c2dd8 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -485,7 +485,7 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> { #[rustfmt::skip] com.args([ "-M", "virt", - "-cpu", "neoverse-n2", + "-cpu", "max", "-device", "ramfb", "-device", "qemu-xhci", "-device", "usb-kbd", diff --git a/sysdata/libraries/stn/src/alloc/alloc_return.hb b/sysdata/libraries/stn/src/alloc/alloc_return.hb new file mode 100644 index 000000000..e32bd1aac --- /dev/null +++ b/sysdata/libraries/stn/src/alloc/alloc_return.hb @@ -0,0 +1,4 @@ +AllocReturn := struct { + byte_count: uint, + ptr: ?^u8, +} diff --git a/sysdata/libraries/stn/src/alloc/block_alloc.hb b/sysdata/libraries/stn/src/alloc/block_alloc.hb new file mode 100644 index 000000000..34aba7a02 --- /dev/null +++ b/sysdata/libraries/stn/src/alloc/block_alloc.hb @@ -0,0 +1,73 @@ +alloc_return := @use("alloc_return.hb") + +/* the block size is 64 bytes, 64 blocks of 64 bytes. + this will very quickly lead to exhaustion of free blocks. +*/ +BlockAlloc := struct { + state := uint, + ptr := ^u8, + + $init := fn(): Self{ + // request a kernel page + // ptr := memory.alloc(1) + return .(0, null) + } + + + // $alloc := fn(self: Self, alloc_type: Type, count: uint): alloc_return.AllocReturn { + // offset := 0 + // a := 0 + // loop { + // a = self.state << offset; + // // check if the `offset` bit is 1, if it is move to the next offset + // if a == 1 { + // offset += 1 + // } else { + // // self it to 1 and return the ptr to the allocation + // self.state |= a + // return (ptr + (offset * 64)) + // } + // // there are only 64 blocks + // if offset >= 64 { + // break; + // } + // } + // return null + // } + + // $dealloc := fn(&self, ptr: ^u8, alloc_type: Type, count: uint): void { + // size := size_of(alloc_type)*count + // // get the size alligned to the nearest block + // rounded_size := nearest_block_size_rounded_up(size) + + + // state_bit_start := { + // // Do math here to figure out what starting ptr corresponds to what bit + // 3 + // } + + // offset := 0 + + // loop { + // if rounded_size > 0 { + // // set state_bit_start+offset to 0 + + + // // at the end move to the next one + // offset += 1 + // } else { + // break; + // } + + // rounded_size -= 64 + // } + + // return void + // } + + // $deinit := fn(&self): void { + // self.state := 0 + + + // } +} diff --git a/sysdata/libraries/stn/src/alloc/fake_alloc.hb b/sysdata/libraries/stn/src/alloc/fake_alloc.hb new file mode 100644 index 000000000..5b2e74c65 --- /dev/null +++ b/sysdata/libraries/stn/src/alloc/fake_alloc.hb @@ -0,0 +1,22 @@ +alloc_return := @use("alloc_return.hb") + + +FakeAlloc := struct { + $init := fn():Self{ + return .() + } + + $alloc := fn(&self, alloc_type: Type, count: uint): alloc_return.AllocReturn { + return .(0, null) + } + + $dealloc := fn(&self, ptr: ^u8, alloc_type: Type, count: uint) : void{ + return void + } + // Nothing to clean up here + $deinit := fn(&self): void { + return void + } +} + + diff --git a/sysdata/libraries/stn/src/alloc/lib.hb b/sysdata/libraries/stn/src/alloc/lib.hb new file mode 100644 index 000000000..a05698f10 --- /dev/null +++ b/sysdata/libraries/stn/src/alloc/lib.hb @@ -0,0 +1,2 @@ +// .{FakeAlloc} := @use("fake_alloc.hb") +.{BlockAlloc} := @use("block_alloc.hb") diff --git a/sysdata/libraries/stn/src/alloc/main.hb b/sysdata/libraries/stn/src/alloc/main.hb new file mode 100644 index 000000000..138d53c43 --- /dev/null +++ b/sysdata/libraries/stn/src/alloc/main.hb @@ -0,0 +1,25 @@ +allocators := @use("alloc/alloc.hb") + +AStruct := struct { + a_field: u8, +} + +main := fn():void{ + alloc := allocators.FakeAlloc.init() + astruct := alloc.alloc(AStruct, 2) + if astruct.ptr != null{ + panic("FakeAlloc actually allocated.") + } + alloc.dealloc(astruct_ptr, AStruct, 2) + alloc.deinit() + + balloc := allocators.BlockAlloc.init() + bstruct_ptr := balloc.alloc(AStruct, 2) + if bstruct_ptr == null { + panic("BlockAlloc actually didn't allocate.") + } + balloc.dealloc(bstruct_ptr, AStruct, 2) + balloc.deinit() + + +} diff --git a/sysdata/libraries/stn/src/lib.hb b/sysdata/libraries/stn/src/lib.hb index 961037cb9..538e77862 100644 --- a/sysdata/libraries/stn/src/lib.hb +++ b/sysdata/libraries/stn/src/lib.hb @@ -1,4 +1,5 @@ acs := @use("acs.hb") +alloc := @use("alloc/lib.hb") string := @use("string.hb") log := @use("log.hb") memory := @use("memory.hb") @@ -9,6 +10,7 @@ file := @use("file_io.hb") dt := @use("dt.hb") process := @use("process.hb") + panic := fn(message: ?^u8): never { log.error("Error: Panic Called, Message:\0") if message == null { diff --git a/sysdata/programs/render_example/src/main.hb b/sysdata/programs/render_example/src/main.hb index 77cb04c04..ab66cfa82 100644 --- a/sysdata/programs/render_example/src/main.hb +++ b/sysdata/programs/render_example/src/main.hb @@ -1 +1 @@ -.{example: main} := @use("./examples/text.hb") \ No newline at end of file +.{example: main} := @use("./examples/orbit.hb") \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 530c98a7b..a7b849e0d 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -22,26 +22,26 @@ resolution = "1024x768x24" [boot.limine.ableos.modules] -# [boot.limine.ableos.modules.render_example] -# path = "boot:///render_example.hbf" +[boot.limine.ableos.modules.render_example] +path = "boot:///render_example.hbf" # [boot.limine.ableos.modules.horizon] # path = "boot:///horizon.hbf" -[boot.limine.ableos.modules.ps2_mouse_driver] -path = "boot:///ps2_mouse_driver.hbf" +# [boot.limine.ableos.modules.ps2_mouse_driver] +# path = "boot:///ps2_mouse_driver.hbf" # [boot.limine.ableos.modules.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf" -[boot.limine.ableos.modules.sunset_client] -path = "boot:///sunset_client.hbf" +# [boot.limine.ableos.modules.sunset_client] +# path = "boot:///sunset_client.hbf" -[boot.limine.ableos.modules.sunset_client_2] -path = "boot:///sunset_client_2.hbf" +# [boot.limine.ableos.modules.sunset_client_2] +# path = "boot:///sunset_client_2.hbf" -[boot.limine.ableos.modules.sunset_server] -path = "boot:///sunset_server.hbf" +# [boot.limine.ableos.modules.sunset_server] +# path = "boot:///sunset_server.hbf" # [boot.limine.ableos.modules.processes] # path = "boot:///processes.hbf"