Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 27653f9)
raw | patch | inline | side by side (parent: 27653f9)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Wed, 31 Dec 2025 03:43:07 +0000 (11:43 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Wed, 31 Dec 2025 03:43:07 +0000 (11:43 +0800) |
| include/syscall.h | patch | blob | history | |
| kernel/ring3.S | patch | blob | history | |
| kernel/syscall.c | patch | blob | history |
diff --git a/include/syscall.h b/include/syscall.h
--- a/include/syscall.h
+++ b/include/syscall.h
#define SYSC_PAUSE (10)
#define SYSC_TEST (11)
#define SYSC_DEBUG (12)
+#define SYSC_RAND (13)
#define SYSC_BAD_NR (SYSC_NUM - 1)
#endif //_SYSCALL_H
diff --git a/kernel/ring3.S b/kernel/ring3.S
--- a/kernel/ring3.S
+++ b/kernel/ring3.S
nop
nop
- pushal
+ movl $SYSC_RAND, %eax
+ call ring3_syscall
- movl $7, %ebx
+
+ movl %eax, %ecx
+ andl $0x000000FF, %ecx
movl $SYSC_WAIT, %eax
+ call ring3_syscall
+
+ nop
+ nop
+ jmp ring3_entry
+
+# eax 系统调用号
+# ecx 参数1
+ring3_syscall:
+ pushl %ebp
+
+ pushl %ebx
+ pushl %edi
+
+ movl %ecx, %ebx
call get_eip
get_eip:
# 这里popl取得的就是上一个call指令自动压入栈中的地址
sysenter
- popal
+ popl %edi
+ popl %ebx
+ popl %ebp
- nop
- nop
- jmp ring3_entry
+ ret
diff --git a/kernel/syscall.c b/kernel/syscall.c
--- a/kernel/syscall.c
+++ b/kernel/syscall.c
return 0;
}
+int sysc_rand() {
+ uint32_t rand = jiffies;
+ return (int)rand;
+}
+
void init_sysc_handler_table() {
int i;
for (i = 0; i < SYSC_NUM; i++) sysc_handler_table[i] = (unsigned long)sysc_none;
_sysc_(SYSC_PAUSE, sysc_pause);
_sysc_(SYSC_TEST, sysc_test);
_sysc_(SYSC_DEBUG, sysc_debug);
- _sysc_(SYSC_BAD_NR, sysc_bad_nr)
+ _sysc_(SYSC_RAND, sysc_rand);
+ _sysc_(SYSC_BAD_NR, sysc_bad_nr);
}
int sysc_bad_nr() {