fiddle with memory free & alloc for safety & simplicity reasons
This commit is contained in:
parent
90f1b3fdc5
commit
5616e0ba03
34
Cargo.lock
generated
34
Cargo.lock
generated
|
@ -73,9 +73,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.5"
|
||||
version = "1.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e"
|
||||
checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
@ -213,12 +213,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#08fc9d6ab6a8dd539255bf45d892f4b7f08776c5"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d1bc70892b442376138e854450b0f423302962ef"
|
||||
|
||||
[[package]]
|
||||
name = "hblang"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#08fc9d6ab6a8dd539255bf45d892f4b7f08776c5"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d1bc70892b442376138e854450b0f423302962ef"
|
||||
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#08fc9d6ab6a8dd539255bf45d892f4b7f08776c5"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#d1bc70892b442376138e854450b0f423302962ef"
|
||||
dependencies = [
|
||||
"hbbytecode",
|
||||
]
|
||||
|
@ -521,9 +521,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -625,9 +625,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.18"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248"
|
||||
checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
|
||||
|
||||
[[package]]
|
||||
name = "sbi"
|
||||
|
@ -649,18 +649,18 @@ checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.216"
|
||||
version = "1.0.217"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e"
|
||||
checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.216"
|
||||
version = "1.0.217"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e"
|
||||
checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -726,9 +726,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.91"
|
||||
version = "2.0.93"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035"
|
||||
checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -967,9 +967,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.20"
|
||||
version = "0.6.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
|
||||
checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
|
|
@ -48,29 +48,24 @@ pub fn memory_msg_handler(
|
|||
let msg_type = msg_vec[0];
|
||||
match msg_type {
|
||||
0 => unsafe {
|
||||
let page_count = msg_vec[1];
|
||||
let page_count = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap()) as usize;
|
||||
|
||||
let ptr = alloc(Layout::from_size_align_unchecked(
|
||||
page_count as usize * 4096,
|
||||
8,
|
||||
));
|
||||
let ptr = alloc(Layout::from_size_align_unchecked(page_count * 4096, 1));
|
||||
|
||||
log::debug!("Allocating {} pages @ {:x}", page_count, ptr as u64);
|
||||
log::debug!("Allocating {} pages @ {:?}", page_count, ptr);
|
||||
|
||||
vm.registers[1] = hbvm::value::Value(ptr as u64);
|
||||
log::debug!("Kernel ptr: {:x}", ptr as u64);
|
||||
},
|
||||
|
||||
1 => unsafe {
|
||||
let page_count = msg_vec[1];
|
||||
let page_count = u64::from_le_bytes(msg_vec[1..9].try_into().unwrap()) as usize;
|
||||
|
||||
let mptr_raw: [u8; 8] = msg_vec[2..10].try_into().unwrap();
|
||||
let mptr: u64 = u64::from_le_bytes(mptr_raw);
|
||||
log::debug!("Deallocating {} pages @ {:x}", page_count, mptr);
|
||||
let mptr = u64::from_le_bytes(msg_vec[9..17].try_into().unwrap()) as *mut u8;
|
||||
log::debug!("Deallocating {} pages @ {:?}", page_count, mptr);
|
||||
|
||||
dealloc(
|
||||
mptr as *mut u8,
|
||||
Layout::from_size_align_unchecked(page_count as usize * 4096, 8),
|
||||
mptr,
|
||||
Layout::from_size_align_unchecked(page_count * 4096, 1),
|
||||
)
|
||||
},
|
||||
2 => {
|
||||
|
|
|
@ -60,9 +60,9 @@ impl hbvm::mem::Memory for Memory {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn log_instr(&mut self, at: Address, regs: &[hbvm::value::Value]) {
|
||||
log::debug!("exec: [{:02x}] {}", at.get(), unsafe {
|
||||
self.logger.display_instr(at, regs)
|
||||
});
|
||||
fn log_instr(&mut self, _at: Address, _regs: &[hbvm::value::Value]) {
|
||||
// log::debug!("exec: [{:02x}] {}", at.get(), unsafe {
|
||||
// self.logger.display_instr(at, regs)
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,37 +15,26 @@ $dangling := fn($Expr: type): ^Expr {
|
|||
}
|
||||
|
||||
$calc_pages := fn($Expr: type, num: uint): uint {
|
||||
return 1 + @sizeof(Expr) * num / PAGE_SIZE
|
||||
return (num + PAGE_SIZE - 1) / PAGE_SIZE
|
||||
}
|
||||
|
||||
// ! will be replaced, don't get attached
|
||||
alloc := fn($Expr: type, num: uint): ^Expr {
|
||||
pages := calc_pages(Expr, num)
|
||||
if pages <= MAX_ALLOC {
|
||||
return @bitcast(request_page(@intcast(pages)))
|
||||
}
|
||||
ptr := request_page(MAX_ALLOC)
|
||||
remaining := pages - MAX_ALLOC
|
||||
loop if remaining < MAX_ALLOC break else {
|
||||
_ = request_page(MAX_ALLOC)
|
||||
remaining -= MAX_ALLOC
|
||||
}
|
||||
_ = request_page(@intcast(remaining))
|
||||
return @bitcast(ptr)
|
||||
return @bitcast(request_page(@intcast(calc_pages(Expr, num))))
|
||||
}
|
||||
|
||||
// ! stub
|
||||
$free := fn($Expr: type, ptr: ^Expr, num: uint, nullify: bool): void {
|
||||
return
|
||||
$free := fn($Expr: type, ptr: ^Expr, num: uint): void {
|
||||
release_page(@bitcast(ptr), @intcast(calc_pages(Expr, num)))
|
||||
}
|
||||
|
||||
RqPageMsg := packed struct {a: u8, count: u8}
|
||||
$request_page := fn(count: u8): ^u8 {
|
||||
RqPageMsg := packed struct {a: u8, count: uint}
|
||||
$request_page := fn(count: uint): ^u8 {
|
||||
return @eca(3, 2, &RqPageMsg.(0, count), @sizeof(RqPageMsg))
|
||||
}
|
||||
|
||||
RlPageMsg := packed struct {a: u8, count: u8, ptr: ^u8}
|
||||
$release_page := fn(ptr: ^u8, count: u8): void {
|
||||
RlPageMsg := packed struct {a: u8, count: uint, ptr: ^u8}
|
||||
$release_page := fn(ptr: ^u8, count: uint): void {
|
||||
return @eca(3, 2, &RlPageMsg.(1, count, ptr), @sizeof(RlPageMsg))
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ identify := fn(drive: Drive): u8 {
|
|||
status := inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||
|
||||
loop if (status & STAT_BSY) == 0 break else {
|
||||
// if DEBUG_PRINT log.printf("(ata: waiting for status) status={}", .(status), .{radix: 16, log: .Warn})
|
||||
if DEBUG_PRINT log.printf("(ata: waiting for status) status={}", .(status), .{radix: 16, log: .Warn})
|
||||
status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@ serial_driver := @use("./tests/serial_driver.hb")
|
|||
|
||||
main := fn(): uint {
|
||||
// return serial_driver.test()
|
||||
return stn.hashers.test()
|
||||
return stn.process.test()
|
||||
}
|
BIN
sysdata/programs/test/src/tests/stn/assets/lily.hbf
Normal file
BIN
sysdata/programs/test/src/tests/stn/assets/lily.hbf
Normal file
Binary file not shown.
|
@ -1,13 +1,9 @@
|
|||
.{process, log} := @use("stn")
|
||||
|
||||
exe := @embed("./assets/hello_world_and_spin.hbf")
|
||||
// src: https://git.ablecorp.us/koniifer/lily
|
||||
exe := @embed("./assets/lily.hbf")
|
||||
|
||||
test := fn(): uint {
|
||||
loop {
|
||||
log.print(process.spawn(@bitcast(&exe), 356), .{})
|
||||
// spin so we don't spawn 10 quattuordecillion processes
|
||||
i := 0
|
||||
loop if i == 20000000 break else i += 1
|
||||
}
|
||||
process.spawn(@bitcast(&exe), @sizeof(@TypeOf(exe)))
|
||||
return 0
|
||||
}
|
|
@ -44,14 +44,14 @@ resolution = "1024x768x24"
|
|||
# [boot.limine.ableos.modules.ablefetch]
|
||||
# path = "boot:///ablefetch.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.diskio_driver]
|
||||
path = "boot:///diskio_driver.hbf"
|
||||
# [boot.limine.ableos.modules.diskio_driver]
|
||||
# path = "boot:///diskio_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.angels_halo]
|
||||
# path = "boot:///angels_halo.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.test]
|
||||
# path = "boot:///test.hbf"
|
||||
[boot.limine.ableos.modules.test]
|
||||
path = "boot:///test.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.vfsaur]
|
||||
# path = "boot:///vfsaur.hbf"
|
||||
|
|
Loading…
Reference in a new issue