mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
Improve syscalls for new task switching
There are a lot of under the hood changes here: - Move syscalls to be a dispatch table, defined by syscalls.inc - Don't need a full process state (push_all) in syscalls now - In push_all, define REGS instead of using offsets - Save TWO stack pointers as well as current saved stack pointer in TCB: - rsp0 is the base of the kernel stack for interrupts - rsp3 is the saved user stack from cpu_data - Update syscall numbers in nulldrv - Some asm-debugging enhancements to the gdb script - fork() still not working
This commit is contained in:
@@ -16,7 +16,7 @@ main(int argc, const char **argv)
|
||||
{
|
||||
int32_t pid = getpid();
|
||||
//int32_t child = fork();
|
||||
debug();
|
||||
//debug();
|
||||
for (int i = 1; i < 5; ++i)
|
||||
sleep(i*10);
|
||||
debug();
|
||||
|
||||
@@ -11,7 +11,7 @@ getpid:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
mov rax, 5 ; getpid syscall
|
||||
mov rax, 3 ; getpid syscall
|
||||
syscall ; pid is now already in rax, so just return
|
||||
|
||||
pop rbp
|
||||
@@ -22,7 +22,7 @@ debug:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
mov rax, 1 ; debug syscall
|
||||
mov rax, 0 ; debug syscall
|
||||
syscall
|
||||
|
||||
pop rbp
|
||||
@@ -33,7 +33,7 @@ sleep:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
mov rax, 4 ; sleep syscall
|
||||
mov rax, 6 ; sleep syscall
|
||||
syscall
|
||||
|
||||
pop rbp
|
||||
@@ -44,7 +44,8 @@ fork:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
mov rax, 8
|
||||
mov rax, 0
|
||||
|
||||
syscall ; pid left in rax
|
||||
|
||||
pop rbp
|
||||
|
||||
Reference in New Issue
Block a user