提交 3769917c 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Pass system call arguments via registers.

上级 a938d2bd
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
- (is there a way to use address_space(256) attributes?) - (is there a way to use address_space(256) attributes?)
* bring mtrace back * bring mtrace back
* finish syscall/sysret implementation * finish syscall/sysret implementation
- pass syscall args via argument registers
- (adjust argint and friends)
* make uart console work over IPMI SOL * make uart console work over IPMI SOL
* make syslinux/pxelinux work over IPMI SOL * make syslinux/pxelinux work over IPMI SOL
* the elf loader in exec.c is a bit sketchy * the elf loader in exec.c is a bit sketchy
......
...@@ -6,9 +6,8 @@ ...@@ -6,9 +6,8 @@
# exec(init, argv) # exec(init, argv)
.globl start .globl start
start: start:
pushq $argv movq $argv, %rsi
pushq $init movq $init, %rdi
pushq $0 // where caller pc would be
movq $SYS_exec, %rax movq $SYS_exec, %rax
int $T_SYSCALL int $T_SYSCALL
......
...@@ -53,7 +53,19 @@ fetchstr(uptr addr, char **pp) ...@@ -53,7 +53,19 @@ fetchstr(uptr addr, char **pp)
int int
argint64(int n, u64 *ip) argint64(int n, u64 *ip)
{ {
return fetchint64(myproc()->tf->rsp + 8 + 8*n, ip); switch(n) {
case 0: *ip = myproc()->tf->rdi; break;
case 1: *ip = myproc()->tf->rsi; break;
case 2: *ip = myproc()->tf->rdx; break;
case 3: *ip = myproc()->tf->rcx; break;
case 4: *ip = myproc()->tf->r8; break;
case 5: *ip = myproc()->tf->r9; break;
default:
cprintf("argint64: bad arg %d\n", n);
return -1;
}
return 0;
} }
int int
...@@ -62,7 +74,7 @@ argint32(int n, int *ip) ...@@ -62,7 +74,7 @@ argint32(int n, int *ip)
int r; int r;
u64 i; u64 i;
r = fetchint64(myproc()->tf->rsp + 8 + 8*n, &i); r = argint64(n, &i);
if (r >= 0) if (r >= 0)
*ip = i; *ip = i;
return r; return r;
......
...@@ -4,16 +4,8 @@ ...@@ -4,16 +4,8 @@
#define SYSCALL(name) \ #define SYSCALL(name) \
.globl name; \ .globl name; \
name: \ name: \
pushq %r9; \
pushq %r8; \
pushq %rcx; \
pushq %rdx; \
pushq %rsi; \
pushq %rdi; \
pushq $0; \
movq $SYS_ ## name, %rax; \ movq $SYS_ ## name, %rax; \
int $T_SYSCALL; \ int $T_SYSCALL; \
addq $(7 * 8), %rsp; \
ret ret
SYSCALL(fork) SYSCALL(fork)
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论