2 * Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
3 * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de.
4 * Copyright 2012, Rene Gollent, rene@gollent.com.
5 * Distributed under the terms of the MIT License.
7 * Copyright 2001, Travis Geiselbrecht. All rights reserved.
8 * Copyright 2002, Michael Noisternig. All rights reserved.
9 * Distributed under the terms of the NewOS License.
15 #include "asm_offsets.h"
16 #include "syscall_numbers.h"
22 /* addr_t x86_get_stack_frame(); */
23 FUNCTION(x86_get_stack_frame):
26 FUNCTION_END(x86_get_stack_frame)
29 /* void x86_64_thread_entry(); */
30 FUNCTION(x86_64_thread_entry):
35 andq $0xfffffffffffffff0, %rsp
40 FUNCTION_END(x86_64_thread_entry)
43 /* thread exit stub */
45 FUNCTION(x86_userspace_thread_exit):
47 movq $SYSCALL_EXIT_THREAD, %rax
50 FUNCTION_END(x86_userspace_thread_exit)
51 SYMBOL(x86_end_userspace_thread_exit):
63 FUNCTION_END(x86_reboot)
66 /*! \fn void arch_debug_call_with_fault_handler(cpu_ent* cpu,
67 jmp_buf jumpBuffer, void (*function)(void*), void* parameter)
69 Called by debug_call_with_fault_handler() to do the dirty work of setting
70 the fault handler and calling the function. If the function causes a page
71 fault, the arch_debug_call_with_fault_handler() calls longjmp() with the
72 given \a jumpBuffer. Otherwise it returns normally.
74 debug_call_with_fault_handler() has already saved the CPU's fault_handler
75 and fault_handler_stack_pointer and will reset them later, so
76 arch_debug_call_with_fault_handler() doesn't need to care about it.
78 \param cpu The \c cpu_ent for the current CPU.
79 \param jumpBuffer Buffer to be used for longjmp().
80 \param function The function to be called.
81 \param parameter The parameter to be passed to the function to be called.
83 FUNCTION(arch_debug_call_with_fault_handler):
87 // Preserve the jump buffer address for the fault return.
90 // Set fault handler address, and fault handler stack pointer address. We
91 // don't need to save the previous values, since that's done by the caller.
92 movq $.L_debug_call_fault_handler, CPU_ENT_fault_handler(%rdi)
93 movq %rbp, CPU_ENT_fault_handler_stack_pointer(%rdi)
104 .L_debug_call_fault_handler:
105 // Fault -- return via longjmp(jumpBuffer, 1)
110 FUNCTION_END(arch_debug_call_with_fault_handler)