2 # Copyright (C) 2001-2004 Jakub Jermar
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # - Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # - Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # - The name of the author may not be used to endorse or promote products
15 # derived from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 ## very low and hardware-level functions
31 # Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word
32 # and 1 means interrupt with error word
33 #define ERROR_WORD_INTERRUPT_LIST 0x00027D00
38 .global xen_failsafe_callback
39 .global enable_l_apic_in_msr
41 .global memcpy_from_uspace
42 .global memcpy_from_uspace_failover_address
43 .global memcpy_to_uspace
44 .global memcpy_to_uspace_failover_address
50 xen_failsafe_callback:
56 #define MEMCPY_SIZE 12
58 /** Copy memory to/from userspace.
60 * This is almost conventional memcpy().
61 * The difference is that there is a failover part
62 * to where control is returned from a page fault
63 * if the page fault occurs during copy_from_uspace()
64 * or copy_to_uspace().
66 * @param MEMCPY_DST(%esp) Destination address.
67 * @param MEMCPY_SRC(%esp) Source address.
68 * @param MEMCPY_SIZE(%esp) Size.
70 * @return MEMCPY_SRC(%esp) on success and 0 on failure.
75 movl %edi, %edx /* save %edi */
76 movl %esi, %eax /* save %esi */
78 movl MEMCPY_SIZE(%esp), %ecx
79 shrl $2, %ecx /* size / 4 */
81 movl MEMCPY_DST(%esp), %edi
82 movl MEMCPY_SRC(%esp), %esi
84 rep movsl /* copy as much as possible word by word */
86 movl MEMCPY_SIZE(%esp), %ecx
87 andl $3, %ecx /* size % 4 */
90 rep movsb /* copy the rest byte by byte */
95 movl MEMCPY_SRC(%esp), %eax /* MEMCPY_SRC(%esp), success */
99 * We got here from as_page_fault() after the memory operations
100 * above had caused a page fault.
102 memcpy_from_uspace_failover_address:
103 memcpy_to_uspace_failover_address:
106 xorl %eax, %eax /* return 0, failure */
112 # Enable local APIC in MSR.
114 enable_l_apic_in_msr:
120 orl $(0xfee00000),%eax