]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/AltiAssist.s
xnu-1228.12.14.tar.gz
[apple/xnu.git] / osfmk / ppc / AltiAssist.s
1 /*
2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 AltiAssist.s
30
31 Do the VMX assists
32
33 Lovingly crafted by Bill Angell using traditional methods and only natural or recycled materials.
34 No animal products are used other than rendered otter bile and deep fried pork lard.
35
36 */
37
38 #include <ppc/asm.h>
39 #include <ppc/proc_reg.h>
40 #include <ppc/exception.h>
41 #include <mach/machine/vm_param.h>
42 #include <assym.s>
43
44 ;
45 ;
46 ; General stuff what happens here:
47 ; 1) All general context saved, interrupts off, translation off
48 ; 2) Vector and floating point disabled, but there may be live context.
49 ; This code is responsible for saving and restoring what is used. This
50 ; includes exception states, java mode, etc.
51 ; 3) No attempt is made to resolve page faults. PTE misses are handled
52 ; automatically, but actual faults (ala copyin/copyout) are not. If
53 ; a fault does occur, the exception that caused entry to the emulation
54 ; routine is remapped to either an instruction or data miss (depending
55 ; upon the stage detected) and redriven through the exception handler.
56 ; The only time that an instruction fault can happen is when a different
57 ; processor removes a mapping between our original fault and when we
58 ; fetch the assisted instruction. For an assisted instruction, data
59 ; faults should not occur (except in the MP case). For a purely
60 ; emulated instruction, faults can occur.
61 ;
62 ; Emulation algorithms cloned from MacOS 9 code.
63 ;
64 ; Assumes that R2 = per_proc_area
65 ;
66 ;
67
68
69 .align 5
70 .globl EXT(AltivecAssist)
71
72 LEXT(AltivecAssist)
73
74 li r10,emvr0 ; Point to the vector savearea
75
76 li r11,emvr1 ; Another savearea
77 stvxl v0,r10,r2 ; Save V0
78 stvxl v1,r11,r2 ; Save V1
79 vspltisw v0,1 ; Set a 1 in V0
80 vspltisw v1,8 ; Get half of the shift
81 vslw v0,v0,v1 ; Shift half way
82 vslw v0,v0,v1 ; Shift the rest of the way (we now have 0x00010000)
83 mfvscr v1 ; Get the VSCR
84 vor v1,v1,v0 ; Turn off Java mode
85 lvxl v0,r10,r2 ; Restore V0
86 mtvscr v1 ; Set Java mode off
87 lvxl v1,r11,r2 ; Restore V1
88
89 li r11,T_IN_VAIN ; We are all done
90 b EXT(EmulExit) ; We are done, no tracing on...
91