aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/conf
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-12-01 02:05:19 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2022-12-01 02:05:19 +0200
commit131af4eec38752a27e6e56579fbf76178e022ec1 (patch)
tree1940634f69a44395fc6945b25c5cbc8b68bba876 /arch/riscv64/conf
parente25f1e7a8f8f2320546ad4950464713d85b47785 (diff)
downloadkmi-131af4eec38752a27e6e56579fbf76178e022ec1.tar.gz
kmi-131af4eec38752a27e6e56579fbf76178e022ec1.zip
start looking into memory handling
+ Now 10M alloc/frees succeed, which totals more memory than the virtual machine has, so no too obvious leaks are occuring. For future debugging speed, changed 10M to 1M. + Also quick fix to rpcs, stacks are now assigned. Not entirely sure why they worked before this, but good that I found it.
Diffstat (limited to 'arch/riscv64/conf')
-rwxr-xr-xarch/riscv64/conf/initbin2720 -> 5088 bytes
-rw-r--r--arch/riscv64/conf/init.c31
-rw-r--r--arch/riscv64/conf/initrdbin3072 -> 5632 bytes
3 files changed, 30 insertions, 1 deletions
diff --git a/arch/riscv64/conf/init b/arch/riscv64/conf/init
index eba8186..0d99b80 100755
--- a/arch/riscv64/conf/init
+++ b/arch/riscv64/conf/init
Binary files differ
diff --git a/arch/riscv64/conf/init.c b/arch/riscv64/conf/init.c
index de9814e..4cd4cea 100644
--- a/arch/riscv64/conf/init.c
+++ b/arch/riscv64/conf/init.c
@@ -18,6 +18,7 @@
*/
#include <stdint.h>
+#include <stddef.h>
#include "../../../include/apos/syscalls.h"
struct sys_ret {
@@ -184,6 +185,27 @@ static void sys_poweroff(long type)
ecall(r);
}
+static void *sys_req_mem(size_t count)
+{
+ struct sys_ret r = {.a0 = SYS_REQ_MEM, .a1 = count,
+ .a2 = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 4)};
+ r = ecall(r);
+
+ if (r.a0)
+ print_value("sys_req_mem() failed with error ", r.a0);
+
+ return (void *)r.a1;
+}
+
+static void sys_free_mem(void *p)
+{
+ struct sys_ret r = {.a0 = SYS_FREE_MEM, .a1 = (long)p};
+ r = ecall(r);
+
+ if (r.a0)
+ print_value("sys_free_mem() failed with error ", r.a0);
+}
+
void callback(long status, long tid, long d0, long d1, long d2, long d3)
{
(void)status;
@@ -244,12 +266,19 @@ void _start()
csr_read(CSR_TIME, i);
start = i; n = 0;
while (i < start + second) {
- sys_ipc_req(1, d0, d1, d2, d3);
+ sys_ipc_req(1, n, d1, d2, d3);
csr_read(CSR_TIME, i);
n++;
}
print_value("IPC requests per second", n);
+ puts("Doing memory allocations...\n");
+ for (i = 0; i < 1000000; ++i) {
+ char *p = sys_req_mem(10);
+ *p = 'c';
+ sys_free_mem(p);
+ }
+
sys_poweroff(0);
}
diff --git a/arch/riscv64/conf/initrd b/arch/riscv64/conf/initrd
index 905bbfe..8d36a5a 100644
--- a/arch/riscv64/conf/initrd
+++ b/arch/riscv64/conf/initrd
Binary files differ