1// Copyright 2016 The Fuchsia Authors 2// 3// Use of this source code is governed by a MIT-style 4// license that can be found in the LICENSE file or at 5// https://opensource.org/licenses/MIT 6 7#include <asm.h> 8#include <arch/x86/descriptor.h> 9 10// x86_uspace_entry(uintptr_t arg1, uintptr_t arg2, uintptr_t sp, uintptr_t pc, uint64_t rflags) 11FUNCTION(x86_uspace_entry) 12 /* push a fake 64bit interrupt stack frame and iret to it */ 13 push_value $USER_DATA_SELECTOR // ss 14 push_value %rdx // sp 15 push_value %r8 // rflags 16 push_value $USER_CODE_64_SELECTOR // cs 17 push_value %rcx // pc 18 19 ALL_CFI_UNDEFINED 20 21 // Clear registers 22 xorl %eax, %eax /* set %rax = 0 */ 23 xorl %ebx, %ebx 24 xorl %ecx, %ecx 25 xorl %edx, %edx 26 // Don't clear rdi or rsi, since they have the user arguments. 27 xorl %ebp, %ebp 28 xorl %r8d, %r8d 29 xorl %r9d, %r9d 30 xorl %r10d, %r10d 31 xorl %r11d, %r11d 32 xorl %r12d, %r12d 33 xorl %r13d, %r13d 34 xorl %r14d, %r14d 35 xorl %r15d, %r15d 36 37 // We do not need to clear extended register state, since the kernel only 38 // uses the general purpose registers, and the extended state is initialized 39 // to a cleared state. 40 41 swapgs 42 43 mov %ax, %ds 44 mov %ax, %es 45 mov %ax, %fs 46 mov %ax, %gs 47 48 iretq 49END_FUNCTION(x86_uspace_entry) 50