check_syscall_nr: /* Check to make sure we don't jump to a bogus syscall number. */ li t0, __NR_syscalls la s0, sys_ni_syscall /* * Syscall number held in a7. * If syscall number is above allowed value, redirect to ni_syscall. */ bgeu a7, t0, 1f /* Call syscall */ la...
# 参数:a7 = syscall number (93 for exit)# a0 = exit code li a7, 93 li a0, 0 # 退...
Original file line numberDiff line numberDiff line change @@ -46,7 +46,8 @@ _distinguish_syscall: #ifdef RT_USING_SMART // TODO swap 8 with config macro name li t1, 8 beq t0, t1, syscall_entry bne t0, t1, _handle_interrupt_and_exception call syscall_entry // syscall never return...
ecall可以发起系统调用(比如中断、异常)、访问文件系统、写入console。 发起系统调用需要设置正确的syscall代码,例如 li a0,1#syscallnumber for printing integer li a1,1024# the integer we're printing ecall # issue system call 系统调用部分,参考 https://man7.org/linux/man-pages/man2/syscall.2.html#...
// Make a System Call with 1 parameters // https://github.com/apache/nuttx/blob/master/arch/risc-v/include/syscall.h#L188-L213 inline uintptr_t sys_call1( unsigned int nbr, // System Call Number uintptr_t parm1 // First Parameter ) { // Pass the Function Number and Parameters ...
主动的让其进入异常处理函数,常见的是系统调用syscall。而在riscv上为ecall或者进入断点的ebreak。 外部中断(Interrupt) 一般由外部事件触发,比如定时器中断、GPIO中断等。这些异常是不可预知的。 对于一般的中断处理流程,进入中断后需要进行上下文的保存与恢复。
/home/pi/RVOS/code/os# ls 00-bootstrap 02-memanagement 04-multitask 06-interrupts 08-preemptive 10-swtimer gdbinit 01-helloRVOS 03-contextswitch 05-traps 07-hwtimer 09-lock 11-syscall Makefile root@pi-desktop:/home/pi/RVOS/code/os# cd 01-helloRVOS root@pi-desktop:/home/pi/RVOS/...
当然最典型的还是在支持多权态/虚拟化的实现上,作为虚拟环境或者权态的接口,比如各种系统调用(syscall)。物理机上的例子如OpenSBI。riscv官方提供的相关spec可以见文档"RISC-V Supervisor Binary Interface Specification"。 // from "RISC-V Supervisor Binary Interface Specification"...
n; int a; printf("请输入需要打印的斐波那契数\n"); scanf("%d",&n); a=Fib(n); sy ...
Linux中RTOS需要一个tick心跳进行调度处理,linux中的tick处理函数是scheduler_tick。本文从整体流程上来分析下执行到scheduler_tick的流程,以及过程中定时器中断相关的回调是如何注册的,以stime即中断号为5为例。 先上流程图方便对照 二.设置异常入口handle_exception ...