Home | History | Annotate | Line # | Download | only in oea
altivec.c revision 1.17
      1  1.17    rmind /*	$NetBSD: altivec.c,v 1.17 2011/01/14 02:06:30 rmind Exp $	*/
      2   1.1     matt 
      3   1.1     matt /*
      4   1.1     matt  * Copyright (C) 1996 Wolfgang Solfrank.
      5   1.1     matt  * Copyright (C) 1996 TooLs GmbH.
      6   1.1     matt  * All rights reserved.
      7   1.1     matt  *
      8   1.1     matt  * Redistribution and use in source and binary forms, with or without
      9   1.1     matt  * modification, are permitted provided that the following conditions
     10   1.1     matt  * are met:
     11   1.1     matt  * 1. Redistributions of source code must retain the above copyright
     12   1.1     matt  *    notice, this list of conditions and the following disclaimer.
     13   1.1     matt  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1     matt  *    notice, this list of conditions and the following disclaimer in the
     15   1.1     matt  *    documentation and/or other materials provided with the distribution.
     16   1.1     matt  * 3. All advertising materials mentioning features or use of this software
     17   1.1     matt  *    must display the following acknowledgement:
     18   1.1     matt  *	This product includes software developed by TooLs GmbH.
     19   1.1     matt  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20   1.1     matt  *    derived from this software without specific prior written permission.
     21   1.1     matt  *
     22   1.1     matt  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23   1.1     matt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24   1.1     matt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25   1.1     matt  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26   1.1     matt  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27   1.1     matt  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28   1.1     matt  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29   1.1     matt  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30   1.1     matt  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31   1.1     matt  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32   1.1     matt  */
     33   1.5    lukem 
     34   1.5    lukem #include <sys/cdefs.h>
     35  1.17    rmind __KERNEL_RCSID(0, "$NetBSD: altivec.c,v 1.17 2011/01/14 02:06:30 rmind Exp $");
     36   1.4   martin 
     37   1.4   martin #include "opt_multiprocessor.h"
     38   1.4   martin 
     39   1.1     matt #include <sys/param.h>
     40   1.1     matt #include <sys/proc.h>
     41   1.1     matt #include <sys/systm.h>
     42   1.1     matt #include <sys/malloc.h>
     43   1.1     matt #include <sys/pool.h>
     44   1.1     matt 
     45   1.3  thorpej #include <uvm/uvm_extern.h>
     46   1.3  thorpej 
     47  1.17    rmind #include <powerpc/pcb.h>
     48   1.1     matt #include <powerpc/altivec.h>
     49  1.16     matt #include <powerpc/psl.h>
     50   1.1     matt #include <powerpc/spr.h>
     51  1.16     matt #include <powerpc/oea/spr.h>
     52   1.1     matt 
     53  1.13  garbled #ifdef MULTIPROCESSOR
     54  1.13  garbled #include <arch/powerpc/pic/picvar.h>
     55  1.13  garbled #include <arch/powerpc/pic/ipivar.h>
     56  1.13  garbled static void mp_save_vec_lwp(struct lwp *);
     57  1.13  garbled #endif
     58  1.13  garbled 
     59   1.1     matt void
     60   1.7     matt enable_vec(void)
     61   1.1     matt {
     62   1.1     matt 	struct cpu_info *ci = curcpu();
     63   1.1     matt 	struct lwp *l = curlwp;
     64  1.15    rmind 	struct pcb *pcb = lwp_getpcb(l);
     65   1.1     matt 	struct trapframe *tf = trapframe(l);
     66   1.2     matt 	struct vreg *vr = &pcb->pcb_vr;
     67   1.2     matt 	register_t msr;
     68   1.1     matt 
     69   1.1     matt 	KASSERT(pcb->pcb_veccpu == NULL);
     70   1.1     matt 
     71   1.2     matt 	pcb->pcb_flags |= PCB_ALTIVEC;
     72   1.1     matt 
     73   1.1     matt 	/*
     74   1.1     matt 	 * Enable AltiVec temporarily (and disable interrupts).
     75   1.1     matt 	 */
     76   1.1     matt 	msr = mfmsr();
     77   1.1     matt 	mtmsr((msr & ~PSL_EE) | PSL_VEC);
     78  1.11    perry 	__asm volatile ("isync");
     79   1.1     matt 	if (ci->ci_veclwp) {
     80   1.1     matt 		save_vec_cpu();
     81   1.1     matt 	}
     82   1.1     matt 	KASSERT(curcpu()->ci_veclwp == NULL);
     83   1.1     matt 
     84   1.1     matt 	/*
     85   1.1     matt 	 * Restore VSCR by first loading it into a vector and then into VSCR.
     86   1.1     matt 	 * (this needs to done before loading the user's vector registers
     87   1.1     matt 	 * since we need to use a scratch vector register)
     88   1.1     matt 	 */
     89  1.11    perry 	__asm volatile("vxor %2,%2,%2; lvewx %2,%0,%1; mtvscr %2" \
     90   1.2     matt 	    ::	"b"(vr), "r"(offsetof(struct vreg, vscr)), "n"(0));
     91   1.1     matt 
     92   1.1     matt 	/*
     93   1.1     matt 	 * VRSAVE will be restored when trap frame returns
     94   1.1     matt 	 */
     95   1.1     matt 	tf->tf_xtra[TF_VRSAVE] = vr->vrsave;
     96   1.1     matt 
     97  1.11    perry #define	LVX(n,vr)	__asm /*volatile*/("lvx %2,%0,%1" \
     98   1.2     matt 	    ::	"b"(vr), "r"(offsetof(struct vreg, vreg[n])), "n"(n));
     99   1.1     matt 
    100   1.1     matt 	/*
    101   1.1     matt 	 * Load all 32 vector registers
    102   1.1     matt 	 */
    103   1.1     matt 	LVX( 0,vr);	LVX( 1,vr);	LVX( 2,vr);	LVX( 3,vr);
    104   1.1     matt 	LVX( 4,vr);	LVX( 5,vr);	LVX( 6,vr);	LVX( 7,vr);
    105   1.1     matt 	LVX( 8,vr);	LVX( 9,vr);	LVX(10,vr);	LVX(11,vr);
    106   1.1     matt 	LVX(12,vr);	LVX(13,vr);	LVX(14,vr);	LVX(15,vr);
    107   1.1     matt 
    108   1.1     matt 	LVX(16,vr);	LVX(17,vr);	LVX(18,vr);	LVX(19,vr);
    109   1.1     matt 	LVX(20,vr);	LVX(21,vr);	LVX(22,vr);	LVX(23,vr);
    110   1.1     matt 	LVX(24,vr);	LVX(25,vr);	LVX(26,vr);	LVX(27,vr);
    111   1.1     matt 	LVX(28,vr);	LVX(29,vr);	LVX(30,vr);	LVX(31,vr);
    112  1.11    perry 	__asm volatile ("isync");
    113   1.1     matt 
    114   1.1     matt 	/*
    115   1.1     matt 	 * Enable AltiVec when we return to user-mode.
    116   1.1     matt 	 * Record the new ownership of the AltiVec unit.
    117   1.1     matt 	 */
    118   1.1     matt 	curcpu()->ci_veclwp = l;
    119   1.1     matt 	pcb->pcb_veccpu = curcpu();
    120   1.8     matt 	pcb->pcb_flags |= PCB_OWNALTIVEC;
    121  1.11    perry 	__asm volatile ("sync");
    122   1.1     matt 
    123   1.1     matt 	/*
    124   1.1     matt 	 * Restore MSR (turn off AltiVec)
    125   1.1     matt 	 */
    126   1.1     matt 	mtmsr(msr);
    127   1.1     matt }
    128   1.1     matt 
    129   1.1     matt void
    130   1.1     matt save_vec_cpu(void)
    131   1.1     matt {
    132   1.1     matt 	struct cpu_info *ci = curcpu();
    133   1.1     matt 	struct lwp *l;
    134   1.1     matt 	struct pcb *pcb;
    135   1.1     matt 	struct vreg *vr;
    136   1.1     matt 	struct trapframe *tf;
    137   1.2     matt 	register_t msr;
    138   1.1     matt 
    139   1.1     matt 	/*
    140   1.1     matt 	 * Turn on AltiVEC, turn off interrupts.
    141   1.1     matt 	 */
    142   1.1     matt 	msr = mfmsr();
    143   1.1     matt 	mtmsr((msr & ~PSL_EE) | PSL_VEC);
    144  1.11    perry 	__asm volatile ("isync");
    145   1.1     matt 	l = ci->ci_veclwp;
    146   1.7     matt 	if (l == NULL)
    147   1.1     matt 		goto out;
    148  1.15    rmind 	pcb = lwp_getpcb(l);
    149   1.2     matt 	vr = &pcb->pcb_vr;
    150   1.1     matt 	tf = trapframe(l);
    151   1.1     matt 
    152  1.11    perry #define	STVX(n,vr)	__asm /*volatile*/("stvx %2,%0,%1" \
    153   1.2     matt 	    ::	"b"(vr), "r"(offsetof(struct vreg, vreg[n])), "n"(n));
    154   1.1     matt 
    155   1.1     matt 	/*
    156   1.1     matt 	 * Save the vector registers.
    157   1.1     matt 	 */
    158   1.1     matt 	STVX( 0,vr);	STVX( 1,vr);	STVX( 2,vr);	STVX( 3,vr);
    159   1.1     matt 	STVX( 4,vr);	STVX( 5,vr);	STVX( 6,vr);	STVX( 7,vr);
    160   1.1     matt 	STVX( 8,vr);	STVX( 9,vr);	STVX(10,vr);	STVX(11,vr);
    161   1.1     matt 	STVX(12,vr);	STVX(13,vr);	STVX(14,vr);	STVX(15,vr);
    162   1.1     matt 
    163   1.1     matt 	STVX(16,vr);	STVX(17,vr);	STVX(18,vr);	STVX(19,vr);
    164   1.1     matt 	STVX(20,vr);	STVX(21,vr);	STVX(22,vr);	STVX(23,vr);
    165   1.1     matt 	STVX(24,vr);	STVX(25,vr);	STVX(26,vr);	STVX(27,vr);
    166   1.1     matt 	STVX(28,vr);	STVX(29,vr);	STVX(30,vr);	STVX(31,vr);
    167   1.1     matt 
    168   1.1     matt 	/*
    169   1.1     matt 	 * Save VSCR (this needs to be done after save the vector registers
    170   1.1     matt 	 * since we need to use one as scratch).
    171   1.1     matt 	 */
    172  1.11    perry 	__asm volatile("mfvscr %2; stvewx %2,%0,%1" \
    173   1.2     matt 	    ::	"b"(vr), "r"(offsetof(struct vreg, vscr)), "n"(0));
    174   1.1     matt 
    175   1.1     matt 	/*
    176   1.1     matt 	 * Save VRSAVE
    177   1.1     matt 	 */
    178   1.1     matt 	vr->vrsave = tf->tf_xtra[TF_VRSAVE];
    179   1.1     matt 
    180   1.1     matt 	/*
    181   1.1     matt 	 * Note that we aren't using any CPU resources and stop any
    182   1.1     matt 	 * data streams.
    183   1.1     matt 	 */
    184   1.1     matt 	pcb->pcb_veccpu = NULL;
    185   1.1     matt 	ci->ci_veclwp = NULL;
    186  1.11    perry 	__asm volatile ("dssall; sync");
    187   1.1     matt 
    188   1.1     matt  out:
    189   1.1     matt 
    190   1.1     matt 	/*
    191   1.1     matt 	 * Restore MSR (turn off AltiVec)
    192   1.1     matt 	 */
    193   1.1     matt 	mtmsr(msr);
    194   1.1     matt }
    195   1.1     matt 
    196  1.13  garbled #ifdef MULTIPROCESSOR
    197  1.13  garbled /*
    198  1.13  garbled  * Save a process's AltiVEC state to its PCB.  The state may be in any CPU.
    199  1.13  garbled  * The process must either be curproc or traced by curproc (and stopped).
    200  1.13  garbled  * (The point being that the process must not run on another CPU during
    201  1.13  garbled  * this function).
    202  1.13  garbled  */
    203  1.13  garbled static void
    204  1.13  garbled mp_save_vec_lwp(struct lwp *l)
    205  1.13  garbled {
    206  1.15    rmind 	struct pcb *pcb = lwp_getpcb(l);
    207  1.13  garbled 	struct cpu_info *veccpu;
    208  1.13  garbled 	int i;
    209  1.13  garbled 
    210  1.13  garbled 	/*
    211  1.13  garbled 	 * Send an IPI to the other CPU with the data and wait for that CPU
    212  1.13  garbled 	 * to flush the data.  Note that the other CPU might have switched
    213  1.13  garbled 	 * to a different proc's AltiVEC state by the time it receives the IPI,
    214  1.13  garbled 	 * but that will only result in an unnecessary reload.
    215  1.13  garbled 	 */
    216  1.13  garbled 
    217  1.13  garbled 	veccpu = pcb->pcb_veccpu;
    218  1.13  garbled 	if (veccpu == NULL)
    219  1.13  garbled 		return;
    220  1.13  garbled 
    221  1.14  garbled 	ppc_send_ipi(veccpu->ci_index, PPC_IPI_FLUSH_VEC);
    222  1.13  garbled 
    223  1.13  garbled 	/* Wait for flush. */
    224  1.13  garbled 	for (i = 0; i < 0x3fffffff; i++)
    225  1.13  garbled 		if (pcb->pcb_veccpu == NULL)
    226  1.13  garbled 			return;
    227  1.13  garbled 
    228  1.13  garbled 	aprint_error("mp_save_vec_lwp{%d} pid = %d.%d, veccpu->ci_cpuid = %d\n",
    229  1.13  garbled 	    cpu_number(), l->l_proc->p_pid, l->l_lid, veccpu->ci_cpuid);
    230  1.13  garbled 	panic("mp_save_vec_lwp: timed out");
    231  1.13  garbled }
    232  1.13  garbled #endif /*MULTIPROCESSOR*/
    233  1.13  garbled 
    234   1.1     matt /*
    235   1.1     matt  * Save a process's AltiVEC state to its PCB.  The state may be in any CPU.
    236   1.1     matt  * The process must either be curproc or traced by curproc (and stopped).
    237   1.1     matt  * (The point being that the process must not run on another CPU during
    238   1.1     matt  * this function).
    239   1.1     matt  */
    240   1.1     matt void
    241   1.7     matt save_vec_lwp(struct lwp *l, int discard)
    242   1.1     matt {
    243  1.15    rmind 	struct pcb * const pcb = lwp_getpcb(l);
    244   1.7     matt 	struct cpu_info * const ci = curcpu();
    245   1.1     matt 
    246   1.1     matt 	/*
    247   1.1     matt 	 * If it's already in the PCB, there's nothing to do.
    248   1.1     matt 	 */
    249   1.7     matt 	if (pcb->pcb_veccpu == NULL)
    250   1.7     matt 		return;
    251   1.1     matt 
    252   1.7     matt 	/*
    253   1.7     matt 	 * If we simply need to discard the information, then don't
    254   1.7     matt 	 * to save anything.
    255   1.7     matt 	 */
    256   1.7     matt 	if (discard) {
    257   1.7     matt #ifndef MULTIPROCESSOR
    258   1.7     matt 		KASSERT(ci == pcb->pcb_veccpu);
    259   1.7     matt #endif
    260   1.7     matt 		KASSERT(l == pcb->pcb_veccpu->ci_veclwp);
    261   1.7     matt 		pcb->pcb_veccpu->ci_veclwp = NULL;
    262   1.7     matt 		pcb->pcb_veccpu = NULL;
    263   1.8     matt 		pcb->pcb_flags &= ~PCB_OWNALTIVEC;
    264   1.1     matt 		return;
    265   1.1     matt 	}
    266   1.1     matt 
    267   1.1     matt 	/*
    268   1.1     matt 	 * If the state is in the current CPU, just flush the current CPU's
    269   1.1     matt 	 * state.
    270   1.1     matt 	 */
    271   1.1     matt 	if (l == ci->ci_veclwp) {
    272   1.1     matt 		save_vec_cpu();
    273   1.1     matt 		return;
    274   1.1     matt 	}
    275   1.1     matt 
    276   1.7     matt 
    277   1.1     matt #ifdef MULTIPROCESSOR
    278   1.1     matt 	/*
    279   1.1     matt 	 * It must be on another CPU, flush it from there.
    280   1.1     matt 	 */
    281   1.1     matt 
    282   1.1     matt 	mp_save_vec_lwp(l);
    283   1.1     matt #endif
    284   1.1     matt }
    285   1.1     matt 
    286   1.1     matt #define ZERO_VEC	19
    287   1.1     matt 
    288   1.1     matt void
    289   1.1     matt vzeropage(paddr_t pa)
    290   1.1     matt {
    291   1.3  thorpej 	const paddr_t ea = pa + PAGE_SIZE;
    292   1.1     matt 	uint32_t vec[7], *vp = (void *) roundup((uintptr_t) vec, 16);
    293   1.2     matt 	register_t omsr, msr;
    294   1.1     matt 
    295  1.11    perry 	__asm volatile("mfmsr %0" : "=r"(omsr) :);
    296   1.1     matt 
    297   1.1     matt 	/*
    298   1.1     matt 	 * Turn on AltiVec, turn off interrupts.
    299   1.1     matt 	 */
    300   1.1     matt 	msr = (omsr & ~PSL_EE) | PSL_VEC;
    301  1.11    perry 	__asm volatile("sync; mtmsr %0; isync" :: "r"(msr));
    302   1.1     matt 
    303   1.1     matt 	/*
    304   1.1     matt 	 * Save the VEC register we are going to use before we disable
    305   1.1     matt 	 * relocation.
    306   1.1     matt 	 */
    307   1.1     matt 	__asm("stvx %1,0,%0" :: "r"(vp), "n"(ZERO_VEC));
    308   1.1     matt 	__asm("vxor %0,%0,%0" :: "n"(ZERO_VEC));
    309   1.1     matt 
    310   1.1     matt 	/*
    311   1.1     matt 	 * Zero the page using a single cache line.
    312   1.1     matt 	 */
    313  1.11    perry 	__asm volatile(
    314   1.9  nathanw 	    "   sync ;"
    315   1.9  nathanw 	    "   mfmsr  %[msr];"
    316   1.9  nathanw 	    "   rlwinm %[msr],%[msr],0,28,26;"	/* Clear PSL_DR */
    317   1.9  nathanw 	    "   mtmsr  %[msr];"			/* Turn off DMMU */
    318   1.9  nathanw 	    "   isync;"
    319   1.9  nathanw 	    "1: stvx   %[zv], %[pa], %[off0];"
    320   1.9  nathanw 	    "   stvxl  %[zv], %[pa], %[off16];"
    321   1.9  nathanw 	    "   stvx   %[zv], %[pa], %[off32];"
    322   1.9  nathanw 	    "   stvxl  %[zv], %[pa], %[off48];"
    323   1.9  nathanw 	    "   addi   %[pa], %[pa], 64;"
    324   1.9  nathanw 	    "   cmplw  %[pa], %[ea];"
    325   1.9  nathanw 	    "	blt+   1b;"
    326   1.9  nathanw 	    "   ori    %[msr], %[msr], 0x10;"	/* Set PSL_DR */
    327   1.9  nathanw 	    "   sync;"
    328   1.9  nathanw 	    "	mtmsr  %[msr];"			/* Turn on DMMU */
    329   1.9  nathanw 	    "   isync;"
    330   1.9  nathanw 	    :: [msr] "r"(msr), [pa] "b"(pa), [ea] "b"(ea),
    331   1.9  nathanw 	    [off0] "r"(0), [off16] "r"(16), [off32] "r"(32), [off48] "r"(48),
    332   1.9  nathanw 	    [zv] "n"(ZERO_VEC));
    333   1.1     matt 
    334   1.1     matt 	/*
    335   1.1     matt 	 * Restore VEC register (now that we can access the stack again).
    336   1.1     matt 	 */
    337   1.1     matt 	__asm("lvx %1,0,%0" :: "r"(vp), "n"(ZERO_VEC));
    338   1.1     matt 
    339   1.1     matt 	/*
    340   1.1     matt 	 * Restore old MSR (AltiVec OFF).
    341   1.1     matt 	 */
    342  1.11    perry 	__asm volatile("sync; mtmsr %0; isync" :: "r"(omsr));
    343   1.1     matt }
    344   1.1     matt 
    345   1.1     matt #define LO_VEC	16
    346   1.1     matt #define HI_VEC	17
    347   1.1     matt 
    348   1.1     matt void
    349   1.1     matt vcopypage(paddr_t dst, paddr_t src)
    350   1.1     matt {
    351   1.3  thorpej 	const paddr_t edst = dst + PAGE_SIZE;
    352   1.1     matt 	uint32_t vec[11], *vp = (void *) roundup((uintptr_t) vec, 16);
    353   1.2     matt 	register_t omsr, msr;
    354   1.1     matt 
    355  1.11    perry 	__asm volatile("mfmsr %0" : "=r"(omsr) :);
    356   1.1     matt 
    357   1.1     matt 	/*
    358   1.1     matt 	 * Turn on AltiVec, turn off interrupts.
    359   1.1     matt 	 */
    360   1.1     matt 	msr = (omsr & ~PSL_EE) | PSL_VEC;
    361  1.11    perry 	__asm volatile("sync; mtmsr %0; isync" :: "r"(msr));
    362   1.1     matt 
    363   1.1     matt 	/*
    364   1.1     matt 	 * Save the VEC registers we will be using before we disable
    365   1.1     matt 	 * relocation.
    366   1.1     matt 	 */
    367   1.2     matt 	__asm("stvx %2,%1,%0" :: "b"(vp), "r"( 0), "n"(LO_VEC));
    368   1.2     matt 	__asm("stvx %2,%1,%0" :: "b"(vp), "r"(16), "n"(HI_VEC));
    369   1.1     matt 
    370   1.1     matt 	/*
    371   1.9  nathanw 	 * Copy the page using a single cache line, with DMMU
    372   1.9  nathanw 	 * disabled.  On most PPCs, two vector registers occupy one
    373   1.9  nathanw 	 * cache line.
    374   1.9  nathanw 	 */
    375  1.11    perry 	__asm volatile(
    376   1.9  nathanw 	    "   sync ;"
    377   1.9  nathanw 	    "   mfmsr  %[msr];"
    378   1.9  nathanw 	    "   rlwinm %[msr],%[msr],0,28,26;"	/* Clear PSL_DR */
    379   1.9  nathanw 	    "   mtmsr  %[msr];"			/* Turn off DMMU */
    380   1.9  nathanw 	    "   isync;"
    381   1.9  nathanw 	    "1: lvx    %[lv], %[src], %[off0];"
    382   1.9  nathanw 	    "   stvx   %[lv], %[dst], %[off0];"
    383   1.9  nathanw 	    "   lvxl   %[hv], %[src], %[off16];"
    384   1.9  nathanw 	    "   stvxl  %[hv], %[dst], %[off16];"
    385   1.9  nathanw 	    "   addi   %[src], %[src], 32;"
    386   1.9  nathanw 	    "   addi   %[dst], %[dst], 32;"
    387   1.9  nathanw 	    "   cmplw  %[dst], %[edst];"
    388   1.9  nathanw 	    "	blt+   1b;"
    389   1.9  nathanw 	    "   ori    %[msr], %[msr], 0x10;"	/* Set PSL_DR */
    390   1.9  nathanw 	    "   sync;"
    391   1.9  nathanw 	    "	mtmsr  %[msr];"			/* Turn on DMMU */
    392   1.9  nathanw 	    "   isync;"
    393   1.9  nathanw 	    :: [msr] "r"(msr), [src] "b"(src), [dst] "b"(dst),
    394   1.9  nathanw 	    [edst] "b"(edst), [off0] "r"(0), [off16] "r"(16),
    395   1.9  nathanw 	    [lv] "n"(LO_VEC), [hv] "n"(HI_VEC));
    396   1.1     matt 
    397   1.1     matt 	/*
    398   1.1     matt 	 * Restore VEC registers (now that we can access the stack again).
    399   1.1     matt 	 */
    400   1.2     matt 	__asm("lvx %2,%1,%0" :: "b"(vp), "r"( 0), "n"(LO_VEC));
    401   1.2     matt 	__asm("lvx %2,%1,%0" :: "b"(vp), "r"(16), "n"(HI_VEC));
    402   1.1     matt 
    403   1.1     matt 	/*
    404   1.1     matt 	 * Restore old MSR (AltiVec OFF).
    405   1.1     matt 	 */
    406  1.11    perry 	__asm volatile("sync; mtmsr %0; isync" :: "r"(omsr));
    407   1.1     matt }
    408