-/*
- * User space emulation of system calls.
- * edx - user address to handle syscall
- *
- * User stack will become:
- * uesp-> eflags
- * eip
- * Register use on entry:
- * ebx contains user regs pointer
- * edx contains emulator vector address
- */
-syscall_emul:
- movl R_UESP(%ebx),%edi /* get user stack pointer */
- CPU_NUMBER(%eax)
- movl CX(EXT(active_kloaded),%eax),%eax
- orl %eax,%eax /* if thread not kernel-loaded, */
- jz 0f /* do address checks */
- subl $8,%edi
- mov %ds,%ax /* kernel data segment access */
- jmp 1f /* otherwise, skip them */
-0:
- cmpl $(VM_MAX_ADDRESS),%edi /* in user space? */
- ja syscall_addr /* address error if not */
- subl $8,%edi /* push space for new arguments */
- cmpl $(VM_MIN_ADDRESS),%edi /* still in user space? */
- jb syscall_addr /* error if not */
- movl $ USER_DS,%ax /* user data segment access */
-1:
- mov %ax,%fs
- movl R_EFLAGS(%ebx),%eax /* move flags */
- RECOVERY_SECTION
- RECOVER(syscall_addr)
- movl %eax,%fs:0(%edi) /* to user stack */
- movl R_EIP(%ebx),%eax /* move eip */
- RECOVERY_SECTION
- RECOVER(syscall_addr)
- movl %eax,%fs:4(%edi) /* to user stack */
- movl %edi,R_UESP(%ebx) /* set new user stack pointer */
- movl %edx,R_EIP(%ebx) /* change return address to trap */
- movl %ebx,%esp /* back to PCB stack */
- CAH(emul)
- jmp EXT(return_from_trap) /* return to user */
-
-
-/*
- * Address error - address is in %edi.
- * Register use on entry:
- * ebx contains user regs pointer
- */
-syscall_addr:
- movl %edi,R_CR2(%ebx) /* set fault address */
- movl $(T_PAGE_FAULT),R_TRAPNO(%ebx)
- /* set page-fault trap */
- movl $(T_PF_USER),R_ERR(%ebx)
- /* set error code - read user space */
- CAH(addr)
- jmp EXT(take_trap) /* treat as a trap */
-