aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/conf
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv64/conf')
-rw-r--r--arch/riscv64/conf/init.c60
-rw-r--r--arch/riscv64/conf/kernel-link.S2
2 files changed, 40 insertions, 22 deletions
diff --git a/arch/riscv64/conf/init.c b/arch/riscv64/conf/init.c
index 6b1ce46..c61848e 100644
--- a/arch/riscv64/conf/init.c
+++ b/arch/riscv64/conf/init.c
@@ -274,24 +274,9 @@ static void *sys_req_sharedmem(long tid, unsigned long size, void **cbuf)
static char *rw_buf = 0;
static size_t rw_buf_size = 4096;
-void callback(long pid, long tid, long d0, long d1, long d2, long d3)
+static void sys_sleep()
{
- (void)tid;
- if (d0 == 1) {
- void *cbuf = 0;
- rw_buf = sys_req_sharedmem(pid, rw_buf_size, &cbuf);
- sys_ipc_resp((long)cbuf, rw_buf_size, 0, 0);
- __builtin_unreachable();
-
- } else if (d0 == 2) {
- puts("Received string: ");
- puts(rw_buf);
- sys_ipc_resp(0, 0, 0, 0);
- __builtin_unreachable();
- }
-
- sys_ipc_resp(0, 0, 0, 0);
- __builtin_unreachable();
+ ecall1(SYS_SLEEP);
}
#define CSR_TIME "0xc01"
@@ -300,8 +285,19 @@ void callback(long pid, long tid, long d0, long d1, long d2, long d3)
#define CSR_CYCLE "0xc00"
-void _start()
+static void handle_kernel(long a0, long a1, long d0, long d1, long d2, long d3)
{
+ if (a1 != SYS_USER_BOOTED)
+ return;
+
+ long tid = d0;
+ if (tid != 1) {
+ puts("Woo, more cores!\n");
+ while (1)
+ sys_sleep();
+ }
+
+ /* otherwise */
sys_noop();
puts("Hello, world!\n");
@@ -322,9 +318,6 @@ void _start()
print_value("Syscalls per second", n);
print_value("Executed cycles per second", cend - cstart);
- puts("Setting callback...");
- sys_ipc_server(callback);
-
puts("Starting fork():\n");
long pid = sys_fork();
if (pid != 0) {
@@ -387,3 +380,28 @@ void _start()
sys_poweroff(0);
}
+
+void _start(long a0, long a1, long d0, long d1, long d2, long d3)
+{
+ if (a0 == 0)
+ handle_kernel(a0, a1, d0, d1, d2, d3);
+
+ /* otherwise, implement test functionality */
+ long pid = a0;
+ long tid = a1;
+ if (d0 == 1) {
+ void *cbuf = 0;
+ rw_buf = sys_req_sharedmem(pid, rw_buf_size, &cbuf);
+ sys_ipc_resp((long)cbuf, rw_buf_size, 0, 0);
+ __builtin_unreachable();
+
+ } else if (d0 == 2) {
+ puts("Received string: ");
+ puts(rw_buf);
+ sys_ipc_resp(0, 0, 0, 0);
+ __builtin_unreachable();
+ }
+
+ sys_ipc_resp(0, 0, 0, 0);
+ __builtin_unreachable();
+}
diff --git a/arch/riscv64/conf/kernel-link.S b/arch/riscv64/conf/kernel-link.S
index 832a886..88f2e75 100644
--- a/arch/riscv64/conf/kernel-link.S
+++ b/arch/riscv64/conf/kernel-link.S
@@ -11,7 +11,7 @@ SECTIONS {
* hack.
* @todo look into this further.
*/
- . = VM_DMAP;
+ . = ABSOLUTE(VM_KERNEL);
__kernel_start = .;
.text ALIGN(4K) : AT(0) {
*(.kernel.start);