Compare commits

..

No commits in common. "9aa84a0f40b0b1651f61f79b4a790fc7638356eb" and "0b57c2e9bb4c534d60799ea787de6a2a0842276e" have entirely different histories.

5 changed files with 24 additions and 51 deletions

View file

@ -21,17 +21,6 @@ a := fn(): void {}
/// in fat32.hb
a := fn(): void {}
```
## Magic Functions | loose
'Magic functions' are what I am calling small helper functions that do one or two things.
### Example
```rust
a := null
magic_a := fn(){
a = 10
}
```
The exact policy I want to have here is a bit fuzzy. I think that functions like this are nice in certain situations and not in others.
Regardless of if you use them or not, put a comment above the function explaining rational.
## Magic Numbers | loose

View file

@ -1,4 +1,4 @@
.{log, panic, memory} := @use("../lib.hb")
.{log, panic} := @use("../lib.hb")
alloc_return := @use("alloc_return.hb")
/* the block size is 64 bytes, 64 blocks of 64 bytes.
@ -10,40 +10,29 @@ BlockAlloc := struct {
ptr: ?^u8,
$init := fn(): Self {
alloc_page_ptr := memory.request_page(1)
state := 0xFFFFFFFFFFFFFFFF
return .(state, alloc_page_ptr)
return .(0, null)
}
alloc := fn(self: Self, alloc_type: type, count: uint): alloc_return.AllocReturn {
offset := 0
state_2 := 0
offset := 1
a := 1
loop {
xyz := self.state & 1
abc := if xyz == 1 {
true
} else {
false
}
// a = self.state >> offset
// check if the `offset` bit is 1, if it is move to the next offset
if abc {
if a == 1 {
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)
}
}
// 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)

View file

@ -15,16 +15,14 @@ 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
}

View file

@ -13,9 +13,6 @@ 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)

View file

@ -50,4 +50,4 @@ resolution = "1024x768x24"
# path = "boot:///alloc_test.hbf"
[boot.limine.ableos.modules.alloc_test]
path = "boot:///alloc_test.hbf"
path = "boot:///hash_test.hbf"