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

Pass system call arguments via registers.

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