aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rwxr-xr-xarch/riscv64/conf/initbin2560 -> 2664 bytes
-rw-r--r--arch/riscv64/conf/init.c11
-rw-r--r--arch/riscv64/conf/initrdbin3072 -> 3072 bytes
-rw-r--r--arch/riscv64/kernel/proc.c17
4 files changed, 20 insertions, 8 deletions
diff --git a/arch/riscv64/conf/init b/arch/riscv64/conf/init
index 47e733f..11d838c 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 1886760..45274d9 100644
--- a/arch/riscv64/conf/init.c
+++ b/arch/riscv64/conf/init.c
@@ -133,10 +133,15 @@ void _start()
if (pid != 0) {
print_value("Child pid: ", pid);
puts("Swapping to child...\n");
- sys_swap(pid);
- puts("We shouldn't be here?\n");
- while(1);
+ while(1) sys_swap(pid);
}
puts("Hello from child!\n");
+
+ puts("Doing 1M swaps...\n");
+ start = sys_ticks();
+ for (long i = 0; i < 1000000; ++i)
+ sys_swap(1);
+ uint64_t ticks = sys_ticks() - start;
+ print_value("1M swaps took ", ticks / second);
}
diff --git a/arch/riscv64/conf/initrd b/arch/riscv64/conf/initrd
index 24f9fb4..5c0c9bb 100644
--- a/arch/riscv64/conf/initrd
+++ b/arch/riscv64/conf/initrd
Binary files differ
diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c
index d2b8dfb..2ccc5bc 100644
--- a/arch/riscv64/kernel/proc.c
+++ b/arch/riscv64/kernel/proc.c
@@ -30,7 +30,7 @@ void run_init(struct tcb *t, void *fdt)
void set_args(struct tcb *t, struct sys_ret a)
{
- struct riscv_regs *r = (struct riscv_regs *)(--t);
+ struct riscv_regs *r = (struct riscv_regs *)(t) - 1;
r->a0 = a.s;
r->a1 = a.ar0;
r->a2 = a.ar1;
@@ -41,7 +41,7 @@ void set_args(struct tcb *t, struct sys_ret a)
struct sys_ret get_args(struct tcb *t)
{
- struct riscv_regs *r = (struct riscv_regs *)(--t);
+ struct riscv_regs *r = (struct riscv_regs *)(t) - 1;
return SYS_RET6(r->a0, r->a1, r->a2, r->a3, r->a4, r->a5);
}
@@ -49,7 +49,7 @@ void set_thread(struct tcb *t)
{
/* get location of registers in memory */
/** \todo check alignment, should be fine but just to be sure */
- struct riscv_regs *r = (struct riscv_regs *)(--t);
+ struct riscv_regs *r = (struct riscv_regs *)(t) - 1;
/* insert important values into register slots */
r->sp = (long)t->thread_stack_top;
@@ -58,16 +58,23 @@ void set_thread(struct tcb *t)
void save_regs(struct tcb *t, void *p)
{
- struct riscv_regs *r = (struct riscv_regs *)(t++);
+ struct riscv_regs *r = (struct riscv_regs *)(t) - 1;
memcpy(p, r, sizeof(*r));
}
void load_regs(void *p, struct tcb *t)
{
- struct riscv_regs *r = (struct riscv_regs *)(t++);
+ struct riscv_regs *r = (struct riscv_regs *)(t) - 1;
memcpy(r, p, sizeof(*r));
}
+void clone_regs(struct tcb *d, struct tcb *s)
+{
+ struct riscv_regs *rd = (struct riscv_regs *)(d) - 1;
+ struct riscv_regs *rs = (struct riscv_regs *)(s) - 1;
+ memcpy(rd, rs, sizeof(*rs));
+}
+
void adjust_ipi(struct tcb *t)
{
UNUSED(t);