mirror of
https://github.com/plctlab/riscv-operating-system-mooc.git
synced 2025-11-16 12:34:47 +00:00
We use %ld to print mcause.code to compatilbe with rv64 and it do no harm for rv32. Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
29 lines
484 B
C
29 lines
484 B
C
#include "os.h"
|
|
#include "syscall.h"
|
|
|
|
int sys_gethid(unsigned int *ptr_hid)
|
|
{
|
|
printf("--> sys_gethid, arg0 = %p\n", ptr_hid);
|
|
if (ptr_hid == NULL) {
|
|
return -1;
|
|
} else {
|
|
*ptr_hid = r_mhartid();
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void do_syscall(struct context *cxt)
|
|
{
|
|
uint32_t syscall_num = cxt->a7;
|
|
|
|
switch (syscall_num) {
|
|
case SYS_gethid:
|
|
cxt->a0 = sys_gethid((unsigned int *)(cxt->a0));
|
|
break;
|
|
default:
|
|
printf("Unknown syscall no: %d\n", syscall_num);
|
|
cxt->a0 = -1;
|
|
}
|
|
|
|
return;
|
|
} |