aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/conf
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-11-13 15:15:22 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2022-11-13 15:15:22 +0200
commite6dc962ef7758c438039d7f8ac7e2bf3ebcb5c10 (patch)
tree9484a801bc205e0e5f921ebeaba0a15e4d561400 /arch/riscv64/conf
parentb36e3b83b402ee054c319f0472b16a2bd64bba7e (diff)
downloadkmi-e6dc962ef7758c438039d7f8ac7e2bf3ebcb5c10.tar.gz
kmi-e6dc962ef7758c438039d7f8ac7e2bf3ebcb5c10.zip
improve documentation on new features
Diffstat (limited to 'arch/riscv64/conf')
-rw-r--r--arch/riscv64/conf/init.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/arch/riscv64/conf/init.c b/arch/riscv64/conf/init.c
index 438bff4..de9814e 100644
--- a/arch/riscv64/conf/init.c
+++ b/arch/riscv64/conf/init.c
@@ -1,16 +1,25 @@
-/* This file is allowed to be undocumented as it is only temporarily in this
- * tree. At some point in the (hopefully) near future, I intend to move the
+/**
+ * Header for silencing scripts/warn-undocumented
+ *
+ * @file init.c
+ *
+ * Test init program.
+ *
+ * This file is only temporarily in this tree.
+ * At some point in the (hopefully) near future, I intend to move the
* kernel code and initrd generation stuff into separate repositories, to make
* things easier for myself. For now though, this is good enough.
+ *
+ * Compile with
+ * riscv64-unknown-elf-gcc -ffreestanding -nostdlib
+ *
+ * Create initrd with
+ * echo init | cpio -H newc -o > initrd
*/
-/* compile with riscv64-unknown-elf-gcc -ffreestanding -nostdlib */
-/* create initrd with echo init | cpio -H newc -o > initrd */
#include <stdint.h>
#include "../../../include/apos/syscalls.h"
-#define CLOBBER_LIST "a0", "a1", "a2", "a3", "a4", "a5"
-
struct sys_ret {
long a0, a1, a2, a3, a4, a5;
};
@@ -25,8 +34,10 @@ struct sys_ret ecall(struct sys_ret s)
register long a5 asm ("a5") = s.a5;
asm volatile ("ecall"
- : "=r"(a0), "=r"(a1), "=r"(a2), "=r"(a3), "=r"(a4), "=r"(a5)
- : "r"(a0), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5));
+ : "=r" (a0), "=r" (a1), "=r" (a2), "=r" (a3), "=r" (a4),
+ "=r" (a5)
+ : "r" (a0), "r" (a1), "r" (a2), "r" (a3), "r" (a4),
+ "r" (a5));
return (struct sys_ret){a0, a1, a2, a3, a4, a5};
}
@@ -134,6 +145,7 @@ static void sys_ipc_server(void *f)
print_value("ipc_server() failed with error ", r.a0);
}
+/** Helper for ipc arguments/return values. */
struct ipc_args {
long a0, a1, a2, a3;
};
@@ -141,11 +153,11 @@ struct ipc_args {
static struct ipc_args sys_ipc_req(long tid, long d0, long d1, long d2, long d3)
{
struct sys_ret r = {.a0 = SYS_IPC_REQ,
- .a1 = tid,
- .a2 = d0,
- .a3 = d1,
- .a4 = d2,
- .a5 = d3};
+ .a1 = tid,
+ .a2 = d0,
+ .a3 = d1,
+ .a4 = d2,
+ .a5 = d3};
r = ecall(r);
@@ -158,10 +170,10 @@ static struct ipc_args sys_ipc_req(long tid, long d0, long d1, long d2, long d3)
static void sys_ipc_resp(long d0, long d1, long d2, long d3)
{
struct sys_ret r = {.a0 = SYS_IPC_RESP,
- .a1 = d0,
- .a2 = d1,
- .a3 = d2,
- .a4 = d3};
+ .a1 = d0,
+ .a2 = d1,
+ .a3 = d2,
+ .a4 = d3};
ecall(r);
}