diff --git a/sysdata/libraries/stn/src/alloc/block_alloc.hb b/sysdata/libraries/stn/src/alloc/block_alloc.hb index 6f27fa42..7cca6062 100644 --- a/sysdata/libraries/stn/src/alloc/block_alloc.hb +++ b/sysdata/libraries/stn/src/alloc/block_alloc.hb @@ -1,4 +1,4 @@ -.{log, panic} := @use("../lib.hb") +.{log, panic, memory} := @use("../lib.hb") alloc_return := @use("alloc_return.hb") /* the block size is 64 bytes, 64 blocks of 64 bytes. @@ -10,29 +10,40 @@ BlockAlloc := struct { ptr: ?^u8, $init := fn(): Self { - return .(0, null) + alloc_page_ptr := memory.request_page(1) + state := 0xFFFFFFFFFFFFFFFF + return .(state, alloc_page_ptr) } alloc := fn(self: Self, alloc_type: type, count: uint): alloc_return.AllocReturn { - offset := 1 - a := 1 + offset := 0 + state_2 := 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 - log.info("Already Allocated\0") + xyz := self.state & 1 + abc := if xyz == 1 { + true } else { - // self it to 1 and return the ptr to the allocation - self.state |= a - // return ptr + offset * 64 - if self.ptr != null { - return .(64, self.ptr + offset * 64) - } else { - // panic.panic("Allocator is not inited.\0") - // return .(0, null) - } + false } + // check if the `offset` bit is 1, if it is move to the next offset + if abc { + offset += 1 + return .(0, null) + } else { + log.info("Already Allocated\0") + } + + // else { + // // self it to 1 and return the ptr to the allocation + // self.state |= a + // // return ptr + offset * 64 + // if self.ptr != null { + // return .(64, self.ptr + offset * 64) + // } else { + // // panic.panic("Allocator is not inited.\0") + // // return .(0, null) + // } + // } // there are only 64 blocks if offset >= 64 { return .(0, null) diff --git a/sysdata/programs/alloc_test/src/main.hb b/sysdata/programs/alloc_test/src/main.hb index 479d1b41..250ecea6 100644 --- a/sysdata/programs/alloc_test/src/main.hb +++ b/sysdata/programs/alloc_test/src/main.hb @@ -15,14 +15,16 @@ main := fn(): void { // alloc.deinit() balloc := allocators.BlockAlloc.init() - defer balloc.deinit() + // defer { + // balloc.deinit() + // } bstruct := balloc.alloc(AStruct, 2) - if bstruct.ptr == null { - log.info("Hi\0") - // panic.panic("BlockAlloc actually didn't allocate.") - } else { - log.info("Allocator functioned.\0") - } + // if bstruct.ptr == null { + // log.info("Hi\0") + // // panic.panic("BlockAlloc actually didn't allocate.") + // } else { + // log.info("Allocator functioned.\0") + // } // balloc.dealloc(bstruct_ptr, AStruct, 2) return } \ No newline at end of file diff --git a/sysdata/programs/sunset_server/src/main.hb b/sysdata/programs/sunset_server/src/main.hb index 43295868..1376ee51 100644 --- a/sysdata/programs/sunset_server/src/main.hb +++ b/sysdata/programs/sunset_server/src/main.hb @@ -13,6 +13,9 @@ img := @embed("../../../assets/wallpaper.qoi") main := fn(): int { sunset.server.start() + defer { + stn.log.info("Sunset Server Exit\0") + } screen := render.init(true) render.clear(screen, render.black) diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 34b0649f..f6b8e039 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -50,4 +50,4 @@ resolution = "1024x768x24" # path = "boot:///alloc_test.hbf" [boot.limine.ableos.modules.alloc_test] -path = "boot:///hash_test.hbf" +path = "boot:///alloc_test.hbf"