Compare commits
2 commits
b505622601
...
241139f5af
Author | SHA1 | Date | |
---|---|---|---|
Able | 241139f5af | ||
Able | 5c4056bc5c |
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -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",
|
||||
]
|
||||
|
|
|
@ -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",
|
||||
|
|
4
sysdata/libraries/stn/src/alloc/alloc_return.hb
Normal file
4
sysdata/libraries/stn/src/alloc/alloc_return.hb
Normal file
|
@ -0,0 +1,4 @@
|
|||
AllocReturn := struct {
|
||||
byte_count: uint,
|
||||
ptr: ?^u8,
|
||||
}
|
75
sysdata/libraries/stn/src/alloc/block_alloc.hb
Normal file
75
sysdata/libraries/stn/src/alloc/block_alloc.hb
Normal file
|
@ -0,0 +1,75 @@
|
|||
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 {
|
||||
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
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// request a kernel page
|
||||
// ptr := memory.alloc(1)
|
||||
|
||||
|
||||
|
||||
// $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
|
||||
|
||||
// }
|
||||
// }
|
22
sysdata/libraries/stn/src/alloc/fake_alloc.hb
Normal file
22
sysdata/libraries/stn/src/alloc/fake_alloc.hb
Normal file
|
@ -0,0 +1,22 @@
|
|||
alloc_return := @use("alloc_return.hb")
|
||||
|
||||
|
||||
FakeAlloc := struct {
|
||||
$init := fn():Self{
|
||||
return .()
|
||||
}
|
||||
|
||||
$alloc := fn(self: Self, alloc_type: type, count: uint): alloc_return.AllocReturn {
|
||||
return .(0, null)
|
||||
}
|
||||
|
||||
$dealloc := fn(self: Self, ptr: ^u8, alloc_type: Type, count: uint) : void{
|
||||
return void
|
||||
}
|
||||
// Nothing to clean up here
|
||||
$deinit := fn(self: Self): void {
|
||||
return void
|
||||
}
|
||||
}
|
||||
|
||||
|
2
sysdata/libraries/stn/src/alloc/lib.hb
Normal file
2
sysdata/libraries/stn/src/alloc/lib.hb
Normal file
|
@ -0,0 +1,2 @@
|
|||
.{BlockAlloc} := @use("block_alloc.hb");
|
||||
.{FakeAlloc} := @use("fake_alloc.hb")
|
25
sysdata/libraries/stn/src/alloc/main.hb
Normal file
25
sysdata/libraries/stn/src/alloc/main.hb
Normal file
|
@ -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()
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
acs := @use("acs.hb")
|
||||
allocators := @use("alloc/lib.hb")
|
||||
string := @use("string.hb")
|
||||
log := @use("log.hb")
|
||||
memory := @use("memory.hb")
|
||||
|
|
1
sysdata/programs/alloc_test/README.md
Normal file
1
sysdata/programs/alloc_test/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
# alloc_test
|
11
sysdata/programs/alloc_test/meta.toml
Normal file
11
sysdata/programs/alloc_test/meta.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "alloc_test"
|
||||
authors = [""]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
25
sysdata/programs/alloc_test/src/main.hb
Normal file
25
sysdata/programs/alloc_test/src/main.hb
Normal file
|
@ -0,0 +1,25 @@
|
|||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{allocators, panic} := stn
|
||||
|
||||
AStruct := struct {
|
||||
a_field: u8,
|
||||
}
|
||||
|
||||
main := fn(): void {
|
||||
alloc := allocators.FakeAlloc.init()
|
||||
astruct := alloc.alloc(AStruct, 2)
|
||||
// if astruct.ptr != null{
|
||||
// panic.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()
|
||||
return
|
||||
}
|
|
@ -1 +1 @@
|
|||
.{example: main} := @use("./examples/text.hb")
|
||||
.{example: main} := @use("./examples/orbit.hb")
|
|
@ -28,20 +28,23 @@ resolution = "1024x768x24"
|
|||
# [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"
|
||||
|
||||
# [boot.limine.ableos.modules.alloc_test]
|
||||
# path = "boot:///alloc_test.hbf"
|
Loading…
Reference in a new issue