Skip to content

Commit 2f5329f

Browse files
committed
实现 timer_create timer_settime fchdir系统调用.
1 parent a6273f4 commit 2f5329f

File tree

11 files changed

+362
-172
lines changed

11 files changed

+362
-172
lines changed

assets/initramfs.img

0 Bytes
Binary file not shown.

src/arch/x86_64/include/nr.h

Lines changed: 148 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -19,148 +19,154 @@
1919
#define SYSCALL_MPROTECT 10
2020
#define SYSCALL_MUNMAP 11
2121
/* #define SYSCALL_BRK 12 brk 系统调用不实现*/
22-
#define SYSCALL_SIGACTION 13
23-
#define SYSCALL_RT_SIGMASK 14
24-
#define SYSCALL_SIGRET 15
25-
#define SYSCALL_IOCTL 16
26-
#define SYSCALL_PREAD 17
27-
#define SYSCALL_PWRITE 18
28-
#define SYSCALL_READV 19
29-
#define SYSCALL_WRITEV 20
30-
#define SYSCALL_ACCESS 21
31-
#define SYSCALL_PIPE 22
32-
#define SYSCALL_SELECT 23
33-
#define SYSCALL_YIELD 24
34-
#define SYSCALL_MREMAP 25
35-
#define SYSCALL_MINCORE 27
36-
#define SYSCALL_MADVISE 28
37-
#define SYSCALL_DUP 32
38-
#define SYSCALL_DUP2 33
39-
#define SYSCALL_NANO_SLEEP 35
40-
#define SYSCALL_SETITIMER 38
41-
#define SYSCALL_GETPID 39
42-
#define SYSCALL_SENDFILE 40
43-
#define SYSCALL_SOCKET 41
44-
#define SYSCALL_CONNECT 42
45-
#define SYSCALL_ACCEPT 43
46-
#define SYSCALL_SENDTO 44
47-
#define SYSCALL_RECVFROM 45
48-
#define SYSCALL_SENDMSG 46
49-
#define SYSCALL_RECVMSG 47
50-
#define SYSCALL_SHUTDOWN 48
51-
#define SYSCALL_BIND 49
52-
#define SYSCALL_LISTEN 50
53-
#define SYSCALL_GETSOCKNAME 51
54-
#define SYSCALL_GETPEERNAME 52
55-
#define SYSCALL_SOCKETPAIR 53
56-
#define SYSCALL_SETSOCKOPT 54
57-
#define SYSCALL_GETSOCKOPT 55
58-
#define SYSCALL_CLONE 56
59-
#define SYSCALL_FORK 57
60-
#define SYSCALL_VFORK 58
61-
#define SYSCALL_EXECVE 59
62-
#define SYSCALL_EXIT 60
63-
#define SYSCALL_WAITPID 61
64-
#define SYSCALL_KILL 62
65-
#define SYSCALL_UNAME 63
66-
#define SYSCALL_FSYNC 74
67-
#define SYSCALL_FDATASYNC 75
68-
#define SYSCALL_FCNTL 72
69-
#define SYSCALL_FTRUNCATE 77
70-
#define SYSCALL_GETCWD 79
71-
#define SYSCALL_CHDIR 80
72-
#define SYSCALL_RENAME 82
73-
#define SYSCALL_MKDIR 83
74-
#define SYSCALL_RMDIR 84
75-
#define SYSCALL_LINK 86
76-
#define SYSCALL_UNLINK 87
77-
#define SYSCALL_SYMLINK 88
78-
#define SYSCALL_READLINK 89
79-
#define SYSCALL_CHMOD 90
80-
#define SYSCALL_FCHMOD 91
81-
#define SYSCALL_CHOWN 92
82-
#define SYSCALL_FCHOWN 93
83-
#define SYSCALL_LCHOWN 94
84-
#define SYSCALL_UMASK 95
85-
#define SYSCALL_GETRLIMIT 97
86-
#define SYSCALL_GETRUSAGE 98
87-
#define SYSCALL_SYSINFO 99
88-
#define SYSCALL_TIMES 100
89-
#define SYSCALL_GETUID 102
90-
#define SYSCALL_SYSLOG 103
91-
#define SYSCALL_GETGID 104
92-
#define SYSCALL_GETSID 124
93-
#define SYSCALL_CAPGET 125
94-
#define SYSCALL_CAPSET 126
95-
#define SYSCALL_SETUID 105
96-
#define SYSCALL_SETGID 106
97-
#define SYSCALL_GETEUID 107
98-
#define SYSCALL_GETEGID 108
99-
#define SYSCALL_SETPGID 109
100-
#define SYSCALL_GETPPID 110
101-
#define SYSCALL_SETSID 112
102-
#define SYSCALL_GETGROUPS 115
103-
#define SYSCALL_SETRESUID 117
104-
#define SYSCALL_GETRESUID 118
105-
#define SYSCALL_SETRESGID 119
106-
#define SYSCALL_GETRESGID 120
107-
#define SYSCALL_GETPGID 121
108-
#define SYSCALL_SIGPENDING 127
109-
#define SYSCALL_SIGTIMEDWAIT 128
110-
#define SYSCALL_SIGQUEUEINFO 129
111-
#define SYSCALL_SIGSUSPEND 130
112-
#define SYSCALL_SIGALTSTACK 131
113-
#define SYSCALL_MKNOD 133
114-
#define SYSCALL_STATFS 137
115-
#define SYSCALL_SETPRIORITY 141
116-
#define SYSCALL_PRCTL 157
117-
#define SYSCALL_ARCH_PRCTL 158
118-
#define SYSCALL_PIVOT_ROOT 155
119-
#define SYSCALL_SETRLIMIT 160
120-
#define SYSCALL_CHROOT 161
121-
#define SYSCALL_SYNC 162
122-
#define SYSCALL_MOUNT 165
123-
#define SYSCALL_UMOUNT2 166
124-
#define SYSCALL_REBOOT 169
125-
#define SYSCALL_GET_TID 186
126-
#define SYSCALL_LGETXATTR 192
127-
#define SYSCALL_LLISTXATTR 195
128-
#define SYSCALL_S_AFFINITY 203
129-
#define SYSCALL_G_AFFINITY 204
130-
#define SYSCALL_FUTEX 202
131-
#define SYSCALL_GETDENTS64 217
132-
#define SYSCALL_SETID_ADDR 218
133-
#define SYSCALL_FADVISE64 221
134-
#define SYSCALL_EXIT_GROUP 231
135-
#define SYSCALL_C_SETTIME 227
136-
#define SYSCALL_C_GETTIME 228
137-
#define SYSCALL_C_GETRES 229
138-
#define SYSCALL_C_NANOSLEEP 230
139-
#define SYSCALL_OPENAT 257
140-
#define SYSCALL_MKDIRAT 258
141-
#define SYSCALL_FCHOWNAT 260
142-
#define SYSCALL_FUTIMESAT 261
143-
#define SYSCALL_NEWFSTATAT 262
144-
#define SYSCALL_UNLINKAT 263
145-
#define SYSCALL_FACCESSAT 269
146-
#define SYSCALL_FCHMODAT 268
147-
#define SYSCALL_PSELECT6 270
148-
#define SYSCALL_EPOLL_WAIT 232
149-
#define SYSCALL_EPOLL_CTL 233
150-
#define SYSCALL_UTIMENSAT 280
151-
#define SYSCALL_EPOLL_PWAIT 281
152-
#define SYSCALL_ACCEPT4 288
153-
#define SYSCALL_EVENTFD2 290
154-
#define SYSCALL_EPOLL_CREATE1 291
155-
#define SYSCALL_DUP3 292
156-
#define SYSCALL_PIPE2 293
157-
#define SYSCALL_PRLIMIT64 302
158-
#define SYSCALL_GETRANDOM 318
159-
#define SYSCALL_MEMFD_CREATE 319
160-
#define SYSCALL_CP_F_RANGE 326
161-
#define SYSCALL_STATX 332
162-
#define SYSCALL_FSOPEN 430
163-
#define SYSCALL_FACCESSAT2 439
22+
#define SYSCALL_SIGACTION 13
23+
#define SYSCALL_RT_SIGMASK 14
24+
#define SYSCALL_SIGRET 15
25+
#define SYSCALL_IOCTL 16
26+
#define SYSCALL_PREAD 17
27+
#define SYSCALL_PWRITE 18
28+
#define SYSCALL_READV 19
29+
#define SYSCALL_WRITEV 20
30+
#define SYSCALL_ACCESS 21
31+
#define SYSCALL_PIPE 22
32+
#define SYSCALL_SELECT 23
33+
#define SYSCALL_YIELD 24
34+
#define SYSCALL_MREMAP 25
35+
#define SYSCALL_MINCORE 27
36+
#define SYSCALL_MADVISE 28
37+
#define SYSCALL_DUP 32
38+
#define SYSCALL_DUP2 33
39+
#define SYSCALL_NANO_SLEEP 35
40+
#define SYSCALL_SETITIMER 38
41+
#define SYSCALL_GETPID 39
42+
#define SYSCALL_SENDFILE 40
43+
#define SYSCALL_SOCKET 41
44+
#define SYSCALL_CONNECT 42
45+
#define SYSCALL_ACCEPT 43
46+
#define SYSCALL_SENDTO 44
47+
#define SYSCALL_RECVFROM 45
48+
#define SYSCALL_SENDMSG 46
49+
#define SYSCALL_RECVMSG 47
50+
#define SYSCALL_SHUTDOWN 48
51+
#define SYSCALL_BIND 49
52+
#define SYSCALL_LISTEN 50
53+
#define SYSCALL_GETSOCKNAME 51
54+
#define SYSCALL_GETPEERNAME 52
55+
#define SYSCALL_SOCKETPAIR 53
56+
#define SYSCALL_SETSOCKOPT 54
57+
#define SYSCALL_GETSOCKOPT 55
58+
#define SYSCALL_CLONE 56
59+
#define SYSCALL_FORK 57
60+
#define SYSCALL_VFORK 58
61+
#define SYSCALL_EXECVE 59
62+
#define SYSCALL_EXIT 60
63+
#define SYSCALL_WAITPID 61
64+
#define SYSCALL_KILL 62
65+
#define SYSCALL_UNAME 63
66+
#define SYSCALL_FSYNC 74
67+
#define SYSCALL_FDATASYNC 75
68+
#define SYSCALL_FCNTL 72
69+
#define SYSCALL_FTRUNCATE 77
70+
#define SYSCALL_GETCWD 79
71+
#define SYSCALL_CHDIR 80
72+
#define SYSCALL_FCHDIR 81
73+
#define SYSCALL_RENAME 82
74+
#define SYSCALL_MKDIR 83
75+
#define SYSCALL_RMDIR 84
76+
#define SYSCALL_LINK 86
77+
#define SYSCALL_UNLINK 87
78+
#define SYSCALL_SYMLINK 88
79+
#define SYSCALL_READLINK 89
80+
#define SYSCALL_CHMOD 90
81+
#define SYSCALL_FCHMOD 91
82+
#define SYSCALL_CHOWN 92
83+
#define SYSCALL_FCHOWN 93
84+
#define SYSCALL_LCHOWN 94
85+
#define SYSCALL_UMASK 95
86+
#define SYSCALL_GETRLIMIT 97
87+
#define SYSCALL_GETRUSAGE 98
88+
#define SYSCALL_SYSINFO 99
89+
#define SYSCALL_TIMES 100
90+
#define SYSCALL_GETUID 102
91+
#define SYSCALL_SYSLOG 103
92+
#define SYSCALL_GETGID 104
93+
#define SYSCALL_GETSID 124
94+
#define SYSCALL_CAPGET 125
95+
#define SYSCALL_CAPSET 126
96+
#define SYSCALL_SETUID 105
97+
#define SYSCALL_SETGID 106
98+
#define SYSCALL_GETEUID 107
99+
#define SYSCALL_GETEGID 108
100+
#define SYSCALL_SETPGID 109
101+
#define SYSCALL_GETPPID 110
102+
#define SYSCALL_SETSID 112
103+
#define SYSCALL_GETGROUPS 115
104+
#define SYSCALL_SETRESUID 117
105+
#define SYSCALL_GETRESUID 118
106+
#define SYSCALL_SETRESGID 119
107+
#define SYSCALL_GETRESGID 120
108+
#define SYSCALL_GETPGID 121
109+
#define SYSCALL_SIGPENDING 127
110+
#define SYSCALL_SIGTIMEDWAIT 128
111+
#define SYSCALL_SIGQUEUEINFO 129
112+
#define SYSCALL_SIGSUSPEND 130
113+
#define SYSCALL_SIGALTSTACK 131
114+
#define SYSCALL_MKNOD 133
115+
#define SYSCALL_STATFS 137
116+
#define SYSCALL_SETPRIORITY 141
117+
#define SYSCALL_PRCTL 157
118+
#define SYSCALL_ARCH_PRCTL 158
119+
#define SYSCALL_PIVOT_ROOT 155
120+
#define SYSCALL_SETRLIMIT 160
121+
#define SYSCALL_CHROOT 161
122+
#define SYSCALL_SYNC 162
123+
#define SYSCALL_MOUNT 165
124+
#define SYSCALL_UMOUNT2 166
125+
#define SYSCALL_REBOOT 169
126+
#define SYSCALL_GET_TID 186
127+
#define SYSCALL_LGETXATTR 192
128+
#define SYSCALL_LLISTXATTR 195
129+
#define SYSCALL_S_AFFINITY 203
130+
#define SYSCALL_G_AFFINITY 204
131+
#define SYSCALL_FUTEX 202
132+
#define SYSCALL_GETDENTS64 217
133+
#define SYSCALL_SETID_ADDR 218
134+
#define SYSCALL_FADVISE64 221
135+
#define SYSCALL_TIMER_CREATE 222
136+
#define SYSCALL_TIMER_SETTIME 223
137+
#define SYSCALL_TIMER_GETTIME 224
138+
#define SYSCALL_TIMER_GETOVERRUN 225
139+
#define SYSCALL_TIMER_DELETE 226
140+
#define SYSCALL_C_SETTIME 227
141+
#define SYSCALL_C_GETTIME 228
142+
#define SYSCALL_C_GETRES 229
143+
#define SYSCALL_C_NANOSLEEP 230
144+
#define SYSCALL_EXIT_GROUP 231
145+
#define SYSCALL_OPENAT 257
146+
#define SYSCALL_MKDIRAT 258
147+
#define SYSCALL_FCHOWNAT 260
148+
#define SYSCALL_FUTIMESAT 261
149+
#define SYSCALL_NEWFSTATAT 262
150+
#define SYSCALL_UNLINKAT 263
151+
#define SYSCALL_FACCESSAT 269
152+
#define SYSCALL_FCHMODAT 268
153+
#define SYSCALL_PSELECT6 270
154+
#define SYSCALL_EPOLL_WAIT 232
155+
#define SYSCALL_EPOLL_CTL 233
156+
#define SYSCALL_UTIMENSAT 280
157+
#define SYSCALL_EPOLL_PWAIT 281
158+
#define SYSCALL_ACCEPT4 288
159+
#define SYSCALL_EVENTFD2 290
160+
#define SYSCALL_EPOLL_CREATE1 291
161+
#define SYSCALL_DUP3 292
162+
#define SYSCALL_PIPE2 293
163+
#define SYSCALL_PRLIMIT64 302
164+
#define SYSCALL_GETRANDOM 318
165+
#define SYSCALL_MEMFD_CREATE 319
166+
#define SYSCALL_CP_F_RANGE 326
167+
#define SYSCALL_STATX 332
168+
#define SYSCALL_FSOPEN 430
169+
#define SYSCALL_FACCESSAT2 439
164170

165171
#define MAX_SYSCALLS 550
166172

src/arch/x86_64/syscall.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
#include "task/task.h"
1010
#include "term/klog.h"
1111

12-
syscall_(arch_prctl, uint64_t code, uint64_t addr); // prsys_x64.c
13-
syscall_(sched_getaffinity, pid_t pid, size_t cpusetsize, unsigned long *mask); // prsys.c
12+
syscall_(arch_prctl, uint64_t code, uint64_t addr); // prsys_x64.c
13+
syscall_(sched_getaffinity, pid_t pid, size_t cpusetsize, unsigned long *mask); // prsys.c
1414
syscall_(lgetxattr, const char *path, const char *name, void *value, size_t size); // fssys.c
15-
syscall_(llistxattr, const char *path, char *list, size_t size); // fssys.c
16-
syscall_(setuid, int uid); // prsys.c
17-
syscall_(setgid, int gid); // prsys.c
18-
syscall_(setpriority, int which, int who, int niceval); // prsys.c
19-
syscall_(membarrier, int cmd, int flags, int cpu_id); // prsys.c
15+
syscall_(llistxattr, const char *path, char *list, size_t size); // fssys.c
16+
syscall_(setuid, int uid); // prsys.c
17+
syscall_(setgid, int gid); // prsys.c
18+
syscall_(setpriority, int which, int who, int niceval); // prsys.c
19+
syscall_(membarrier, int cmd, int flags, int cpu_id); // prsys.c
2020

2121
__attribute__((naked)) void asm_syscall_handle() {
2222
__asm__ volatile(".intel_syntax noprefix\n\t"
@@ -260,6 +260,9 @@ syscall_t syscall_handlers[MAX_SYSCALLS] = {
260260
[SYSCALL_EVENTFD2] = (syscall_t)syscall_eventfd2,
261261
[SYSCALL_FTRUNCATE] = (syscall_t)syscall_ftruncate,
262262
[SYSCALL_MEMFD_CREATE] = (syscall_t)syscall_memfd_create,
263+
[SYSCALL_TIMER_CREATE] = (syscall_t)syscall_timer_create,
264+
[SYSCALL_TIMER_SETTIME] = (syscall_t)syscall_timer_settime,
265+
[SYSCALL_FCHDIR] = (syscall_t)syscall_fchdir,
263266
};
264267

265268
USED void syscall_handler(struct syscall_regs *regs, uint64_t user_regs) { // syscall 指令处理
@@ -287,7 +290,8 @@ USED void syscall_handler(struct syscall_regs *regs, uint64_t user_regs) { // sy
287290
logkf(
288291
"Syscall(%d) cannot implemented. proc=%s pid=%d\n",
289292
syscall_id,
290-
current && current->process && current->process->name ? current->process->name : "<none>",
293+
current && current->process && current->process->name ? current->process->name
294+
: "<none>",
291295
current && current->process ? current->process->pid : -1
292296
);
293297
regs->rax = -ENOSYS;

0 commit comments

Comments
 (0)