The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/powerpc/powerpc/fpu.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (C) 1996 Wolfgang Solfrank.
    3  * Copyright (C) 1996 TooLs GmbH.
    4  * All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. 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  * 3. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by TooLs GmbH.
   17  * 4. The name of TooLs GmbH may not be used to endorse or promote products
   18  *    derived from this software without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
   21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   23  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
   26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
   28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
   29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   30  *
   31  *      $NetBSD: fpu.c,v 1.5 2001/07/22 11:29:46 wiz Exp $
   32  */
   33 
   34 #ifndef lint
   35 static const char rcsid[] =
   36   "$FreeBSD: releng/5.0/sys/powerpc/powerpc/fpu.c 96771 2002-05-17 01:41:01Z benno $";
   37 #endif /* not lint */
   38 
   39 #include <sys/param.h>
   40 #include <sys/proc.h>
   41 #include <sys/systm.h>
   42 #include <sys/user.h>
   43 
   44 #include <machine/fpu.h>
   45 #include <machine/psl.h>
   46 
   47 void
   48 enable_fpu(struct thread *td)
   49 {
   50         int     msr, scratch;
   51         struct  pcb *pcb;
   52         struct  trapframe *tf;
   53 
   54         pcb = td->td_pcb;
   55         tf = trapframe(td);
   56         
   57         tf->srr1 |= PSL_FP;
   58         if (!(pcb->pcb_flags & PCB_FPU)) {
   59                 memset(&pcb->pcb_fpu, 0, sizeof pcb->pcb_fpu);
   60                 pcb->pcb_flags |= PCB_FPU;
   61         }
   62         __asm __volatile ("mfmsr %0; ori %1,%0,%2; mtmsr %1; isync"
   63                           : "=r"(msr), "=r"(scratch) : "K"(PSL_FP));
   64         __asm __volatile ("lfd 0,0(%0); mtfsf 0xff,0"
   65                           :: "b"(&pcb->pcb_fpu.fpscr));
   66         __asm ("lfd 0,0(%0);"
   67                "lfd 1,8(%0);"
   68                "lfd 2,16(%0);"
   69                "lfd 3,24(%0);"
   70                "lfd 4,32(%0);"
   71                "lfd 5,40(%0);"
   72                "lfd 6,48(%0);"
   73                "lfd 7,56(%0);"
   74                "lfd 8,64(%0);"
   75                "lfd 9,72(%0);"
   76                "lfd 10,80(%0);"
   77                "lfd 11,88(%0);"
   78                "lfd 12,96(%0);"
   79                "lfd 13,104(%0);"
   80                "lfd 14,112(%0);"
   81                "lfd 15,120(%0);"
   82                "lfd 16,128(%0);"
   83                "lfd 17,136(%0);"
   84                "lfd 18,144(%0);"
   85                "lfd 19,152(%0);"
   86                "lfd 20,160(%0);"
   87                "lfd 21,168(%0);"
   88                "lfd 22,176(%0);"
   89                "lfd 23,184(%0);"
   90                "lfd 24,192(%0);"
   91                "lfd 25,200(%0);"
   92                "lfd 26,208(%0);"
   93                "lfd 27,216(%0);"
   94                "lfd 28,224(%0);"
   95                "lfd 29,232(%0);"
   96                "lfd 30,240(%0);"
   97                "lfd 31,248(%0)" :: "b"(&pcb->pcb_fpu.fpr[0]));
   98         __asm __volatile ("mtmsr %0; isync" :: "r"(msr));
   99 }
  100 
  101 void
  102 save_fpu(struct thread *td)
  103 {
  104         int     msr, scratch;
  105         struct  pcb *pcb;
  106 
  107         pcb = td->td_pcb;
  108         
  109         __asm __volatile ("mfmsr %0; ori %1,%0,%2; mtmsr %1; isync"
  110                           : "=r"(msr), "=r"(scratch) : "K"(PSL_FP));
  111         __asm ("stfd 0,0(%0);"
  112                "stfd 1,8(%0);"
  113                "stfd 2,16(%0);"
  114                "stfd 3,24(%0);"
  115                "stfd 4,32(%0);"
  116                "stfd 5,40(%0);"
  117                "stfd 6,48(%0);"
  118                "stfd 7,56(%0);"
  119                "stfd 8,64(%0);"
  120                "stfd 9,72(%0);"
  121                "stfd 10,80(%0);"
  122                "stfd 11,88(%0);"
  123                "stfd 12,96(%0);"
  124                "stfd 13,104(%0);"
  125                "stfd 14,112(%0);"
  126                "stfd 15,120(%0);"
  127                "stfd 16,128(%0);"
  128                "stfd 17,136(%0);"
  129                "stfd 18,144(%0);"
  130                "stfd 19,152(%0);"
  131                "stfd 20,160(%0);"
  132                "stfd 21,168(%0);"
  133                "stfd 22,176(%0);"
  134                "stfd 23,184(%0);"
  135                "stfd 24,192(%0);"
  136                "stfd 25,200(%0);"
  137                "stfd 26,208(%0);"
  138                "stfd 27,216(%0);"
  139                "stfd 28,224(%0);"
  140                "stfd 29,232(%0);"
  141                "stfd 30,240(%0);"
  142                "stfd 31,248(%0)" :: "b"(&pcb->pcb_fpu.fpr[0]));
  143         __asm __volatile ("mffs 0; stfd 0,0(%0)" :: "b"(&pcb->pcb_fpu.fpscr));
  144         __asm __volatile ("mtmsr %0; isync" :: "r"(msr));
  145         pcb->pcb_fpcpu = NULL;
  146         PCPU_SET(fputhread, NULL);
  147 }

Cache object: f3f5a5326434f3dae810d44075361307


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.