clang-format
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
#include <current.h>
|
||||
#include <syscall.h>
|
||||
|
||||
|
||||
/*
|
||||
* System call dispatcher.
|
||||
*
|
||||
@@ -75,75 +74,70 @@
|
||||
* stack, starting at sp+16 to skip over the slots for the
|
||||
* registerized values, with copyin().
|
||||
*/
|
||||
void
|
||||
syscall(struct trapframe *tf)
|
||||
{
|
||||
int callno;
|
||||
int32_t retval;
|
||||
int err;
|
||||
void syscall(struct trapframe *tf) {
|
||||
int callno;
|
||||
int32_t retval;
|
||||
int err;
|
||||
|
||||
KASSERT(curthread != NULL);
|
||||
KASSERT(curthread->t_curspl == 0);
|
||||
KASSERT(curthread->t_iplhigh_count == 0);
|
||||
KASSERT(curthread != NULL);
|
||||
KASSERT(curthread->t_curspl == 0);
|
||||
KASSERT(curthread->t_iplhigh_count == 0);
|
||||
|
||||
callno = tf->tf_v0;
|
||||
callno = tf->tf_v0;
|
||||
|
||||
/*
|
||||
* Initialize retval to 0. Many of the system calls don't
|
||||
* really return a value, just 0 for success and -1 on
|
||||
* error. Since retval is the value returned on success,
|
||||
* initialize it to 0 by default; thus it's not necessary to
|
||||
* deal with it except for calls that return other values,
|
||||
* like write.
|
||||
*/
|
||||
/*
|
||||
* Initialize retval to 0. Many of the system calls don't
|
||||
* really return a value, just 0 for success and -1 on
|
||||
* error. Since retval is the value returned on success,
|
||||
* initialize it to 0 by default; thus it's not necessary to
|
||||
* deal with it except for calls that return other values,
|
||||
* like write.
|
||||
*/
|
||||
|
||||
retval = 0;
|
||||
retval = 0;
|
||||
|
||||
switch (callno) {
|
||||
case SYS_reboot:
|
||||
err = sys_reboot(tf->tf_a0);
|
||||
break;
|
||||
switch (callno) {
|
||||
case SYS_reboot:
|
||||
err = sys_reboot(tf->tf_a0);
|
||||
break;
|
||||
|
||||
case SYS___time:
|
||||
err = sys___time((userptr_t)tf->tf_a0,
|
||||
(userptr_t)tf->tf_a1);
|
||||
break;
|
||||
case SYS___time:
|
||||
err = sys___time((userptr_t)tf->tf_a0, (userptr_t)tf->tf_a1);
|
||||
break;
|
||||
|
||||
/* Add stuff here */
|
||||
/* Add stuff here */
|
||||
|
||||
default:
|
||||
kprintf("Unknown syscall %d\n", callno);
|
||||
err = ENOSYS;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
kprintf("Unknown syscall %d\n", callno);
|
||||
err = ENOSYS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
/*
|
||||
* Return the error code. This gets converted at
|
||||
* userlevel to a return value of -1 and the error
|
||||
* code in errno.
|
||||
*/
|
||||
tf->tf_v0 = err;
|
||||
tf->tf_a3 = 1; /* signal an error */
|
||||
} else {
|
||||
/* Success. */
|
||||
tf->tf_v0 = retval;
|
||||
tf->tf_a3 = 0; /* signal no error */
|
||||
}
|
||||
|
||||
if (err) {
|
||||
/*
|
||||
* Return the error code. This gets converted at
|
||||
* userlevel to a return value of -1 and the error
|
||||
* code in errno.
|
||||
*/
|
||||
tf->tf_v0 = err;
|
||||
tf->tf_a3 = 1; /* signal an error */
|
||||
}
|
||||
else {
|
||||
/* Success. */
|
||||
tf->tf_v0 = retval;
|
||||
tf->tf_a3 = 0; /* signal no error */
|
||||
}
|
||||
/*
|
||||
* Now, advance the program counter, to avoid restarting
|
||||
* the syscall over and over again.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Now, advance the program counter, to avoid restarting
|
||||
* the syscall over and over again.
|
||||
*/
|
||||
tf->tf_epc += 4;
|
||||
|
||||
tf->tf_epc += 4;
|
||||
|
||||
/* Make sure the syscall code didn't forget to lower spl */
|
||||
KASSERT(curthread->t_curspl == 0);
|
||||
/* ...or leak any spinlocks */
|
||||
KASSERT(curthread->t_iplhigh_count == 0);
|
||||
/* Make sure the syscall code didn't forget to lower spl */
|
||||
KASSERT(curthread->t_curspl == 0);
|
||||
/* ...or leak any spinlocks */
|
||||
KASSERT(curthread->t_iplhigh_count == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -154,8 +148,4 @@ syscall(struct trapframe *tf)
|
||||
*
|
||||
* Thus, you can trash it and do things another way if you prefer.
|
||||
*/
|
||||
void
|
||||
enter_forked_process(struct trapframe *tf)
|
||||
{
|
||||
(void)tf;
|
||||
}
|
||||
void enter_forked_process(struct trapframe *tf) { (void)tf; }
|
||||
|
||||
Reference in New Issue
Block a user