更新系统调用号 (#410)

* 更新系统调用号

* 更改DragonReach和relibc版本

* update

* update

* fix warning

---------

Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
GnoCiYeH 2023-10-24 19:59:01 +08:00 committed by GitHub
parent f4082b86b1
commit ad1d649edd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 263 additions and 150 deletions

View File

@ -3,6 +3,7 @@ use crate::driver::base::block::block_device::{BlockDevice, BlockId};
use crate::driver::base::block::disk_info::Partition;
use crate::driver::base::block::SeekFrom;
use crate::driver::base::device::bus::Bus;
use crate::driver::base::device::driver::Driver;
use crate::driver::base::device::{Device, DeviceType, IdTable};
use crate::driver::base::kobject::{KObjType, KObject, KObjectState};

View File

@ -328,68 +328,112 @@ impl SystemError {
}
// 定义系统调用号
pub const SYS_PUT_STRING: usize = 1;
pub const SYS_READ: usize = 0;
pub const SYS_WRITE: usize = 1;
pub const SYS_OPEN: usize = 2;
pub const SYS_CLOSE: usize = 3;
pub const SYS_READ: usize = 4;
pub const SYS_WRITE: usize = 5;
pub const SYS_LSEEK: usize = 6;
pub const SYS_FORK: usize = 7;
pub const SYS_VFORK: usize = 8;
pub const SYS_BRK: usize = 9;
pub const SYS_SBRK: usize = 10;
#[allow(dead_code)]
pub const SYS_STAT: usize = 4;
pub const SYS_FSTAT: usize = 5;
pub const SYS_REBOOT: usize = 11;
pub const SYS_CHDIR: usize = 12;
pub const SYS_GET_DENTS: usize = 13;
pub const SYS_EXECVE: usize = 14;
pub const SYS_WAIT4: usize = 15;
pub const SYS_EXIT: usize = 16;
pub const SYS_MKDIR: usize = 17;
pub const SYS_NANOSLEEP: usize = 18;
#[allow(dead_code)]
pub const SYS_POLL: usize = 7;
pub const SYS_LSEEK: usize = 8;
pub const SYS_MMAP: usize = 9;
pub const SYS_MPROTECT: usize = 10;
pub const SYS_MUNMAP: usize = 11;
pub const SYS_BRK: usize = 12;
pub const SYS_SIGACTION: usize = 13;
#[allow(dead_code)]
pub const SYS_RT_SIGPROCMASK: usize = 14;
pub const SYS_RT_SIGRETURN: usize = 15;
pub const SYS_IOCTL: usize = 16;
#[allow(dead_code)]
pub const SYS_WRITEV: usize = 20;
pub const SYS_DUP: usize = 32;
pub const SYS_DUP2: usize = 33;
pub const SYS_NANOSLEEP: usize = 35;
pub const SYS_GETPID: usize = 39;
pub const SYS_SOCKET: usize = 41;
pub const SYS_CONNECT: usize = 42;
pub const SYS_ACCEPT: usize = 43;
pub const SYS_SENDTO: usize = 44;
pub const SYS_RECVFROM: usize = 45;
pub const SYS_RECVMSG: usize = 47;
pub const SYS_SHUTDOWN: usize = 48;
pub const SYS_BIND: usize = 49;
pub const SYS_LISTEN: usize = 50;
pub const SYS_GETSOCKNAME: usize = 51;
pub const SYS_GETPEERNAME: usize = 52;
pub const SYS_SETSOCKOPT: usize = 54;
pub const SYS_GETSOCKOPT: usize = 55;
#[allow(dead_code)]
pub const SYS_CLONE: usize = 56;
pub const SYS_FORK: usize = 57;
pub const SYS_VFORK: usize = 58;
pub const SYS_EXECVE: usize = 59;
pub const SYS_EXIT: usize = 60;
pub const SYS_WAIT4: usize = 61;
pub const SYS_KILL: usize = 62;
pub const SYS_FCNTL: usize = 72;
pub const SYS_FTRUNCATE: usize = 77;
pub const SYS_GET_DENTS: usize = 78;
pub const SYS_GETCWD: usize = 79;
pub const SYS_CHDIR: usize = 80;
pub const SYS_MKDIR: usize = 83;
pub const SYS_GETTIMEOFDAY: usize = 96;
#[allow(dead_code)]
pub const SYS_SIGALTSTACK: usize = 131;
#[allow(dead_code)]
pub const SYS_ARCH_PRCTL: usize = 158;
pub const SYS_REBOOT: usize = 169;
pub const SYS_GETPPID: usize = 110;
pub const SYS_GETPGID: usize = 121;
pub const SYS_MKNOD: usize = 133;
#[allow(dead_code)]
pub const SYS_TKILL: usize = 200;
#[allow(dead_code)]
pub const SYS_FUTEX: usize = 202;
pub const SYS_GET_DENTS_64: usize = 217;
#[allow(dead_code)]
pub const SYS_SET_TID_ADDR: usize = 218;
pub const SYS_UNLINK_AT: usize = 263;
pub const SYS_PIPE: usize = 293;
#[allow(dead_code)]
pub const SYS_GET_RANDOM: usize = 318;
// 与linux不一致的调用在linux基础上累加
pub const SYS_PUT_STRING: usize = 100000;
pub const SYS_SBRK: usize = 100001;
/// todo: 该系统调用与Linux不一致将来需要删除该系统调用 删的时候记得改C版本的libc
pub const SYS_CLOCK: usize = 19;
pub const SYS_PIPE: usize = 20;
/// 系统调用21曾经是SYS_MSTAT但是现在已经废弃
pub const __NOT_USED: usize = 21;
pub const SYS_UNLINK_AT: usize = 22;
pub const SYS_KILL: usize = 23;
pub const SYS_SIGACTION: usize = 24;
pub const SYS_RT_SIGRETURN: usize = 25;
pub const SYS_GETPID: usize = 26;
pub const SYS_SCHED: usize = 27;
pub const SYS_DUP: usize = 28;
pub const SYS_DUP2: usize = 29;
pub const SYS_SOCKET: usize = 30;
pub const SYS_SETSOCKOPT: usize = 31;
pub const SYS_GETSOCKOPT: usize = 32;
pub const SYS_CONNECT: usize = 33;
pub const SYS_BIND: usize = 34;
pub const SYS_SENDTO: usize = 35;
pub const SYS_RECVFROM: usize = 36;
pub const SYS_RECVMSG: usize = 37;
pub const SYS_LISTEN: usize = 38;
pub const SYS_SHUTDOWN: usize = 39;
pub const SYS_ACCEPT: usize = 40;
pub const SYS_GETSOCKNAME: usize = 41;
pub const SYS_GETPEERNAME: usize = 42;
pub const SYS_GETTIMEOFDAY: usize = 43;
pub const SYS_MMAP: usize = 44;
pub const SYS_MUNMAP: usize = 45;
pub const SYS_MPROTECT: usize = 46;
pub const SYS_FSTAT: usize = 47;
pub const SYS_GETCWD: usize = 48;
pub const SYS_GETPPID: usize = 49;
pub const SYS_GETPGID: usize = 50;
pub const SYS_FCNTL: usize = 51;
pub const SYS_FTRUNCATE: usize = 52;
pub const SYS_MKNOD: usize = 53;
pub const SYS_IOCTL: usize = 54;
pub const SYS_CLOCK: usize = 100002;
pub const SYS_SCHED: usize = 100003;
#[derive(Debug)]
pub struct Syscall;
@ -544,7 +588,7 @@ impl Syscall {
Self::chdir(r)
}
SYS_GET_DENTS => {
SYS_GET_DENTS | SYS_GET_DENTS_64 => {
let fd = args[0] as i32;
let buf_vaddr = args[1];

View File

@ -7,56 +7,89 @@
*
*/
#define SYS_NOT_EXISTS 0
#define SYS_PUT_STRING 1
// 定义系统调用号
#define SYS_READ 0
#define SYS_WRITE 1
#define SYS_OPEN 2
#define SYS_CLOSE 3
#define SYS_READ 4
#define SYS_WRITE 5
#define SYS_LSEEK 6
#define SYS_FORK 7
#define SYS_VFORK 8
#define SYS_BRK 9
#define SYS_SBRK 10
#define SYS_REBOOT 11 // 重启
#define SYS_CHDIR 12 // 切换工作目录
#define SYS_GET_DENTS 13 // 获取目录中的数据
#define SYS_EXECVE 14 // 执行新的应用程序
#define SYS_WAIT4 15 // 等待进程退出
#define SYS_EXIT 16 // 进程退出
#define SYS_MKDIR 17 // 创建文件夹
#define SYS_NANOSLEEP 18 // 纳秒级休眠
#define SYS_CLOCK 19 // 获取当前cpu时间
#define SYS_PIPE 20 // 创建管道
#define SYS_FSTAT 5
#define SYS_LSEEK 8
#define SYS_MMAP 9
#define SYS_MPROTECT 10
#define SYS_MUNMAP 11
#define SYS_BRK 12
#define SYS_SIGACTION 13
#define SYS_UNLINK_AT 22 // 删除文件夹/删除文件链接
#define SYS_KILL 23 // kill一个进程(向这个进程发出信号)
#define SYS_SIGACTION 24 // 设置进程的信号处理动作
#define SYS_RT_SIGRETURN 25 // 从信号处理函数返回
#define SYS_GETPID 26 // 获取当前进程的pid进程标识符
#define SYS_SCHED 27 // 让系统立即运行调度器该系统调用不能由运行在Ring3的程序发起
#define SYS_DUP 28
#define SYS_DUP2 29
#define SYS_SOCKET 30 // 创建一个socket
#define SYS_RT_SIGRETURN 15
#define SYS_IOCTL 16
#define SYS_SETSOCKOPT 31 // 设置socket的选项
#define SYS_GETSOCKOPT 32 // 获取socket的选项
#define SYS_CONNECT 33 // 连接到一个socket
#define SYS_BIND 34 // 绑定一个socket
#define SYS_SENDTO 35 // 向一个socket发送数据
#define SYS_RECVFROM 36 // 从一个socket接收数据
#define SYS_RECVMSG 37 // 从一个socket接收消息
#define SYS_LISTEN 38 // 监听一个socket
#define SYS_SHUTDOWN 39 // 关闭socket
#define SYS_ACCEPT 40 // 接受一个socket连接
#define SYS_DUP 32
#define SYS_DUP2 33
#define SYS_GETSOCKNAME 41 // 获取socket的名字
#define SYS_GETPEERNAME 42 // 获取socket的对端名字
#define SYS_GETTIMEOFDAY 43 // 获取当前时间
#define SYS_MMAP 44 // 内存映射
#define SYS_MUNMAP 45 // 内存解除映射
#define SYS_MPROTECT 46 // 内存保护
#define SYS_NANOSLEEP 35
#define SYS_FSTAT 47 // 根据文件描述符获取文件信息
#define SYS_GETPID 39
#define SYS_SOCKET 41
#define SYS_CONNECT 42
#define SYS_ACCEPT 43
#define SYS_SENDTO 44
#define SYS_RECVFROM 45
#define SYS_RECVMSG 47
#define SYS_SHUTDOWN 48
#define SYS_BIND 49
#define SYS_LISTEN 50
#define SYS_GETSOCKNAME 51
#define SYS_GETPEERNAME 52
#define SYS_SETSOCKOPT 54
#define SYS_GETSOCKOPT 55
#define SYS_CLONE 56
#define SYS_FORK 57
#define SYS_VFORK 58
#define SYS_EXECVE 59
#define SYS_EXIT 60
#define SYS_WAIT4 61
#define SYS_KILL 62
#define SYS_FCNTL 72
#define SYS_FTRUNCATE 77
#define SYS_GET_DENTS 78
#define SYS_GETCWD 79
#define SYS_CHDIR 80
#define SYS_MKDIR 83
#define SYS_GETTIMEOFDAY 96
#define SYS_ARCH_PRCTL 158
#define SYS_REBOOT 169
#define SYS_GETPPID 110
#define SYS_GETPGID 121
#define SYS_MKNOD 133
#define SYS_FUTEX 202
#define SYS_SET_TID_ADDR 218
#define SYS_UNLINK_AT 263
#define SYS_PIPE 293
#define SYS_WRITEV 20
// 与linux不一致的调用在linux基础上累加
#define SYS_PUT_STRING 100000
#define SYS_SBRK 100001
/// todo: 该系统调用与Linux不一致将来需要删除该系统调用
/// 删的时候记得改C版本的libc
#define SYS_CLOCK 100002
#define SYS_SCHED 100003

View File

@ -6,7 +6,7 @@
"BuildFromSource": {
"Git": {
"url" : "https://git.mirrors.dragonos.org/DragonOS-Community/DragonReach.git",
"revision": "a3341790a8"
"revision": "67e3e34cb5"
}
}
},

View File

@ -6,7 +6,7 @@
"BuildFromSource": {
"Git": {
"url": "https://git.mirrors.dragonos.org/DragonOS-Community/relibc.git",
"revision": "ac1ea83106"
"revision": "f797586d73"
}
}
},

View File

@ -2,56 +2,91 @@
#include <stdint.h>
// 系统调用号
#define SYS_NOT_EXISTS 0
#define SYS_PUT_STRING 1
// 定义系统调用号
#define SYS_READ 0
#define SYS_WRITE 1
#define SYS_OPEN 2
#define SYS_CLOSE 3
#define SYS_READ 4
#define SYS_WRITE 5
#define SYS_LSEEK 6
#define SYS_FORK 7
#define SYS_VFORK 8
#define SYS_BRK 9
#define SYS_SBRK 10
#define SYS_REBOOT 11 // 重启
#define SYS_CHDIR 12 // 切换工作目录
#define SYS_GET_DENTS 13 // 获取目录中的数据
#define SYS_EXECVE 14 // 执行新的应用程序
#define SYS_WAIT4 15 // 等待进程退出
#define SYS_EXIT 16 // 进程退出
#define SYS_MKDIR 17 // 创建文件夹
#define SYS_NANOSLEEP 18 // 纳秒级休眠
#define SYS_CLOCK 19 // 获取当前cpu时间
#define SYS_PIPE 20
#define SYS_FSTAT 5
#define SYS_LSEEK 8
#define SYS_MMAP 9
#define SYS_MPROTECT 10
#define SYS_MUNMAP 11
#define SYS_BRK 12
#define SYS_SIGACTION 13
// 现在已经废弃
// #define SYS_MSTAT 21 // 获取系统的内存状态信息
#define SYS_UNLINK_AT 22 // 删除文件夹/删除文件链接
#define SYS_KILL 23 // kill一个进程(向这个进程发出信号)
#define SYS_SIGACTION 24 // 设置进程的信号处理动作
#define SYS_RT_SIGRETURN 25 // 从信号处理函数返回
#define SYS_GETPID 26 // 获取当前进程的pid进程标识符
#define SYS_DUP 28
#define SYS_DUP2 29
#define SYS_SOCKET 30 // 创建一个socket
#define SYS_RT_SIGRETURN 15
#define SYS_IOCTL 16
#define SYS_SETSOCKOPT 31 // 设置socket的选项
#define SYS_GETSOCKOPT 32 // 获取socket的选项
#define SYS_CONNECT 33 // 连接到一个socket
#define SYS_BIND 34 // 绑定一个socket
#define SYS_SENDTO 35 // 向一个socket发送数据
#define SYS_RECVFROM 36 // 从一个socket接收数据
#define SYS_RECVMSG 37 // 从一个socket接收消息
#define SYS_LISTEN 38 // 监听一个socket
#define SYS_SHUTDOWN 39 // 关闭socket
#define SYS_ACCEPT 40 // 接受一个socket连接
#define SYS_GETSOCKNAME 41 // 获取socket的名字
#define SYS_GETPEERNAME 42 // 获取socket的对端名字
#define SYS_IOCTL 54
#define SYS_DUP 32
#define SYS_DUP2 33
#define SYS_GETCWD 48
#define SYS_NANOSLEEP 35
#define SYS_GETPID 39
#define SYS_SOCKET 41
#define SYS_CONNECT 42
#define SYS_ACCEPT 43
#define SYS_SENDTO 44
#define SYS_RECVFROM 45
#define SYS_RECVMSG 47
#define SYS_SHUTDOWN 48
#define SYS_BIND 49
#define SYS_LISTEN 50
#define SYS_GETSOCKNAME 51
#define SYS_GETPEERNAME 52
#define SYS_SETSOCKOPT 54
#define SYS_GETSOCKOPT 55
#define SYS_CLONE 56
#define SYS_FORK 57
#define SYS_VFORK 58
#define SYS_EXECVE 59
#define SYS_EXIT 60
#define SYS_WAIT4 61
#define SYS_KILL 62
#define SYS_FCNTL 72
#define SYS_FTRUNCATE 77
#define SYS_GET_DENTS 78
#define SYS_GETCWD 79
#define SYS_CHDIR 80
#define SYS_MKDIR 83
#define SYS_GETTIMEOFDAY 96
#define SYS_ARCH_PRCTL 158
#define SYS_REBOOT 169
#define SYS_GETPPID 110
#define SYS_GETPGID 121
#define SYS_MKNOD 133
#define SYS_FUTEX 202
#define SYS_SET_TID_ADDR 218
#define SYS_UNLINK_AT 263
#define SYS_PIPE 293
#define SYS_WRITEV 20
// 与linux不一致的调用在linux基础上累加
#define SYS_PUT_STRING 100000
#define SYS_SBRK 100001
/// todo: 该系统调用与Linux不一致将来需要删除该系统调用 删的时候记得改C版本的libc
#define SYS_CLOCK 100002
#define SYS_SCHED 100003
/**
* @brief