更改系统调用的寄存器传参顺序 (#409)

This commit is contained in:
LoGin
2023-10-24 16:40:49 +08:00
committed by GitHub
parent 40314b30ab
commit f4082b86b1
16 changed files with 50 additions and 56 deletions

View File

@ -56,7 +56,7 @@ int closedir(struct DIR *dirp)
int64_t getdents(int fd, struct dirent *dirent, long count)
{
return syscall_invoke(SYS_GET_DENTS, fd, (uint64_t)dirent, count, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_GET_DENTS, fd, (uint64_t)dirent, count, 0, 0, 0);
}
/**
* @brief 从目录中读取数据

View File

@ -11,7 +11,7 @@
*/
int open(const char *path, int options, ...)
{
return syscall_invoke(SYS_OPEN, (uint64_t)path, options, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_OPEN, (uint64_t)path, options, 0, 0, 0, 0);
}
/**
@ -24,5 +24,5 @@ int open(const char *path, int options, ...)
*/
int ioctl(int fd, int cmd, uint64_t data, ...)
{
return syscall_invoke(SYS_IOCTL, fd, cmd, data, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_IOCTL, fd, cmd, data, 0, 0, 0);
}

View File

@ -35,7 +35,7 @@ static int skip_and_atoi(const char **s)
*/
int64_t put_string(char *str, uint64_t front_color, uint64_t bg_color)
{
return syscall_invoke(SYS_PUT_STRING, (uint64_t)str, front_color, bg_color, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_PUT_STRING, (uint64_t)str, front_color, bg_color, 0, 0, 0);
}
int printf(const char *fmt, ...)

View File

@ -40,7 +40,7 @@ int signal(int signum, __sighandler_t handler)
*/
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
{
return syscall_invoke(SYS_SIGACTION, (uint64_t)signum, (uint64_t)act, (uint64_t)oldact, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_SIGACTION, (uint64_t)signum, (uint64_t)act, (uint64_t)oldact, 0, 0, 0);
}
/**
@ -63,5 +63,5 @@ int raise(int sig)
*/
int kill(pid_t pid, int sig)
{
syscall_invoke(SYS_KILL, pid, sig, 0, 0, 0, 0, 0, 0);
syscall_invoke(SYS_KILL, pid, sig, 0, 0, 0, 0);
}

View File

@ -57,7 +57,7 @@ int atoi(const char *str)
void exit(int status)
{
_fini();
syscall_invoke(SYS_EXIT, status, 0, 0, 0, 0, 0, 0, 0);
syscall_invoke(SYS_EXIT, status, 0, 0, 0, 0, 0);
}
/**

View File

@ -8,7 +8,7 @@
int mkdir(const char *path, mode_t mode)
{
return syscall_invoke(SYS_MKDIR, (uint64_t)path, (uint64_t)mode, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_MKDIR, (uint64_t)path, (uint64_t)mode, 0, 0, 0, 0);
}
/**

View File

@ -22,5 +22,5 @@ pid_t wait(int *stat_loc)
*/
pid_t waitpid(pid_t pid, int *stat_loc, int options)
{
return (pid_t)syscall_invoke(SYS_WAIT4, (uint64_t)pid, (uint64_t)stat_loc, options, 0, 0, 0, 0, 0);
return (pid_t)syscall_invoke(SYS_WAIT4, (uint64_t)pid, (uint64_t)stat_loc, options, 0, 0, 0);
}

View File

@ -12,7 +12,7 @@
*/
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
return syscall_invoke(SYS_NANOSLEEP, (uint64_t)rqtp, (uint64_t)rmtp, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_NANOSLEEP, (uint64_t)rqtp, (uint64_t)rmtp, 0, 0, 0, 0);
}
/**
@ -33,10 +33,10 @@ int usleep(useconds_t usec)
/**
* @brief 获取系统当前cpu时间
*
* @return clock_t
*
* @return clock_t
*/
clock_t clock()
{
return (clock_t)syscall_invoke(SYS_CLOCK, 0,0,0,0,0,0,0,0);
return (clock_t)syscall_invoke(SYS_CLOCK, 0, 0, 0, 0, 0, 0);
}

View File

@ -14,7 +14,7 @@
*/
int close(int fd)
{
return syscall_invoke(SYS_CLOSE, fd, 0, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_CLOSE, fd, 0, 0, 0, 0, 0);
}
/**
@ -27,7 +27,7 @@ int close(int fd)
*/
ssize_t read(int fd, void *buf, size_t count)
{
return (ssize_t)syscall_invoke(SYS_READ, fd, (uint64_t)buf, count, 0, 0, 0, 0, 0);
return (ssize_t)syscall_invoke(SYS_READ, fd, (uint64_t)buf, count, 0, 0, 0);
}
/**
@ -40,7 +40,7 @@ ssize_t read(int fd, void *buf, size_t count)
*/
ssize_t write(int fd, void const *buf, size_t count)
{
return (ssize_t)syscall_invoke(SYS_WRITE, fd, (uint64_t)buf, count, 0, 0, 0, 0, 0);
return (ssize_t)syscall_invoke(SYS_WRITE, fd, (uint64_t)buf, count, 0, 0, 0);
}
/**
@ -53,7 +53,7 @@ ssize_t write(int fd, void const *buf, size_t count)
*/
off_t lseek(int fd, off_t offset, int whence)
{
return (off_t)syscall_invoke(SYS_LSEEK, fd, offset, whence, 0, 0, 0, 0, 0);
return (off_t)syscall_invoke(SYS_LSEEK, fd, offset, whence, 0, 0, 0);
}
/**
@ -63,7 +63,7 @@ off_t lseek(int fd, off_t offset, int whence)
*/
pid_t fork(void)
{
return (pid_t)syscall_invoke(SYS_FORK, 0, 0, 0, 0, 0, 0, 0, 0);
return (pid_t)syscall_invoke(SYS_FORK, 0, 0, 0, 0, 0, 0);
}
/**
* @brief 调用匿名管道
@ -72,7 +72,7 @@ pid_t fork(void)
*/
int pipe(int fd[2])
{
return (int)syscall_invoke(SYS_PIPE, fd, 0, 0, 0, 0, 0, 0, 0);
return (int)syscall_invoke(SYS_PIPE, fd, 0, 0, 0, 0, 0);
}
/**
* @brief 调用带参数的匿名管道
@ -81,7 +81,7 @@ int pipe(int fd[2])
*/
int pipe2(int fd[2], int flags)
{
return (int)syscall_invoke(SYS_PIPE, fd, flags, 0, 0, 0, 0, 0, 0);
return (int)syscall_invoke(SYS_PIPE, fd, flags, 0, 0, 0, 0);
}
/**
* @brief fork当前进程但是与父进程共享VM、flags、fd
@ -90,7 +90,7 @@ int pipe2(int fd[2], int flags)
*/
pid_t vfork(void)
{
return (pid_t)syscall_invoke(SYS_VFORK, 0, 0, 0, 0, 0, 0, 0, 0);
return (pid_t)syscall_invoke(SYS_VFORK, 0, 0, 0, 0, 0, 0);
}
/**
@ -104,7 +104,7 @@ pid_t vfork(void)
*/
uint64_t brk(uint64_t end_brk)
{
uint64_t x = (uint64_t)syscall_invoke(SYS_BRK, (uint64_t)end_brk, 0, 0, 0, 0, 0, 0, 0);
uint64_t x = (uint64_t)syscall_invoke(SYS_BRK, (uint64_t)end_brk, 0, 0, 0, 0, 0);
if (x < end_brk)
{
errno = -ENOMEM;
@ -121,7 +121,7 @@ uint64_t brk(uint64_t end_brk)
*/
void *sbrk(int64_t increment)
{
void *retval = (void *)syscall_invoke(SYS_SBRK, (uint64_t)increment, 0, 0, 0, 0, 0, 0, 0);
void *retval = (void *)syscall_invoke(SYS_SBRK, (uint64_t)increment, 0, 0, 0, 0, 0);
if (retval == (void *)-ENOMEM)
return (void *)(-1);
else
@ -146,7 +146,7 @@ int64_t chdir(char *dest_path)
}
else
{
return syscall_invoke(SYS_CHDIR, (uint64_t)dest_path, 0, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_CHDIR, (uint64_t)dest_path, 0, 0, 0, 0, 0);
}
}
@ -165,7 +165,7 @@ int execv(const char *path, char *const argv[])
return -1;
}
int retval = syscall_invoke(SYS_EXECVE, (uint64_t)path, (uint64_t)argv, 0, 0, 0, 0, 0, 0);
int retval = syscall_invoke(SYS_EXECVE, (uint64_t)path, (uint64_t)argv, 0, 0, 0, 0);
if (retval != 0)
return -1;
else
@ -180,7 +180,7 @@ int execv(const char *path, char *const argv[])
*/
int rmdir(const char *path)
{
return syscall_invoke(SYS_UNLINK_AT, 0, (uint64_t)path, AT_REMOVEDIR, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_UNLINK_AT, 0, (uint64_t)path, AT_REMOVEDIR, 0, 0, 0);
}
/**
@ -191,7 +191,7 @@ int rmdir(const char *path)
*/
int rm(const char *path)
{
return syscall_invoke(SYS_UNLINK_AT, 0, (uint64_t)path, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_UNLINK_AT, 0, (uint64_t)path, 0, 0, 0, 0);
}
/**
@ -224,20 +224,20 @@ void swab(void *restrict src, void *restrict dest, ssize_t nbytes)
*/
pid_t getpid(void)
{
return syscall_invoke(SYS_GETPID, 0, 0, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_GETPID, 0, 0, 0, 0, 0, 0);
}
int dup(int fd)
{
return syscall_invoke(SYS_DUP, fd, 0, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_DUP, fd, 0, 0, 0, 0, 0);
}
int dup2(int ofd, int nfd)
{
return syscall_invoke(SYS_DUP2, ofd, nfd, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_DUP2, ofd, nfd, 0, 0, 0, 0);
}
char *getcwd(char* buf, size_t size)
char *getcwd(char *buf, size_t size)
{
return syscall_invoke(SYS_GETCWD, buf, size, 0, 0, 0, 0, 0, 0);
return syscall_invoke(SYS_GETCWD, buf, size, 0, 0, 0, 0);
}