aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/conf
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-07-06 18:14:04 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-07-06 18:14:04 +0300
commit76517486919657ecadda9867125dc6730f29a5b7 (patch)
tree02d975db2b911ec7b92c4b1be7c5a2510b418ae1 /arch/riscv64/conf
parent608f44306a6f0d5692f5c81bcbfe7a621ec254ba (diff)
downloadkmi-76517486919657ecadda9867125dc6730f29a5b7.tar.gz
kmi-76517486919657ecadda9867125dc6730f29a5b7.zip
pretty massive virtual memory rewrite
+ The system is now a bit simpler and hopefully easier to understand, while also extending the shared memory to be 1:N, where there is one owner who may become a zombie while waiting for the N to die.
Diffstat (limited to 'arch/riscv64/conf')
-rwxr-xr-xarch/riscv64/conf/initbin5312 -> 3688 bytes
-rw-r--r--arch/riscv64/conf/init.c23
-rw-r--r--arch/riscv64/conf/initrdbin5632 -> 4096 bytes
3 files changed, 15 insertions, 8 deletions
diff --git a/arch/riscv64/conf/init b/arch/riscv64/conf/init
index ea63935..e1a5de7 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 010267e..7029dbd 100644
--- a/arch/riscv64/conf/init.c
+++ b/arch/riscv64/conf/init.c
@@ -14,7 +14,7 @@
* things easier for myself. For now though, this is good enough.
*
* Compile with
- * riscv64-unknown-elf-gcc -ffreestanding -nostdlib
+ * riscv64-unknown-elf-gcc -Driscv64 -ffreestanding -nostdlib
*
* Create initrd with
* echo init | cpio -H newc -o > initrd
@@ -211,8 +211,7 @@ static void sys_poweroff(long type)
static void *sys_req_mem(size_t count)
{
- struct sys_ret r = ecall3(SYS_REQ_MEM, count,
- (1 << 0) | (1 << 1) | (1 << 2) | (1 << 4));
+ struct sys_ret r = ecall3(SYS_REQ_MEM, count, VM_R | VM_W);
if (r.s) {
print_value("sys_req_mem() failed with error ", r.s);
return NULL;
@@ -231,16 +230,22 @@ static void sys_free_mem(void *p)
static void *sys_req_sharedmem(long tid, unsigned long size, void **cbuf)
{
- struct sys_ret r = ecall5(SYS_REQ_SHAREDMEM, tid, size,
- (1 << 0) | (1 << 1) | (1 << 2) | (1 << 4),
- (1 << 0) | (1 << 1) | (1 << 2) | (1 << 4));
+ struct sys_ret r = ecall3(SYS_REQ_SHAREDMEM, size, VM_R | VM_W);
if (r.s) {
print_value("sys_req_sharedmem() failed with error ", r.s);
return NULL;
}
- *cbuf = (void *)r.ar1;
- return (void *)r.ar0;
+ void *rw_buf = (void *)r.ar0;
+
+ r = ecall4(SYS_REF_SHAREDMEM, tid, (sys_arg_t)rw_buf, VM_R | VM_W);
+ if (r.s) {
+ print_value("sys_ref_sharedmem() failed with error ", r.s);
+ return NULL;
+ }
+
+ *cbuf = (void *)r.ar0;
+ return rw_buf;
}
/* I'm guessing my elf parser doesn't handle data pages correctly yet... */
@@ -257,6 +262,7 @@ void callback(long pid, long tid, long d0, long d1, long d2, long d3)
__builtin_unreachable();
} else if (d0 == 2) {
+ puts("Received string: ");
puts(rw_buf);
sys_ipc_resp(0, 0, 0, 0);
__builtin_unreachable();
@@ -345,6 +351,7 @@ void _start()
print_value("Shared memory size", rw_buf_size);
rw_buf[0] = 0;
+ puts("Sending string...\n");
strcpy(rw_buf, "Hello from the other side!\n");
sys_ipc_req(1, 2, 0, 0, 0);
diff --git a/arch/riscv64/conf/initrd b/arch/riscv64/conf/initrd
index 72260ef..6c101bc 100644
--- a/arch/riscv64/conf/initrd
+++ b/arch/riscv64/conf/initrd
Binary files differ