Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

cpu_state.c

Go to the documentation of this file.
00001 /*
00002  * cpu_state.c
00003  * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
00004  * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
00005  *
00006  * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
00007  * See http://libmpeg2.sourceforge.net/ for updates.
00008  *
00009  * mpeg2dec is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * mpeg2dec is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  */
00023 
00024 #include "config.h"
00025 
00026 #include <stdlib.h>
00027 #include <inttypes.h>
00028 
00029 #include "mpeg2.h"
00030 #include "mpeg2_internal.h"
00031 #include "attributes.h"
00032 #ifdef ARCH_X86
00033 #include "mmx.h"
00034 #endif
00035 
00036 void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
00037 void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
00038 
00039 #ifdef ARCH_X86
00040 static void state_restore_mmx (cpu_state_t * state)
00041 {
00042     emms ();
00043 }
00044 #endif
00045 
00046 #ifdef ARCH_PPC
00047 static void state_save_altivec (cpu_state_t * state)
00048 {
00049     asm ("                                              \n"
00050         "       li              %r9,  16                \n"
00051         "       stvx            %v20, 0,    %r3         \n"
00052         "       li              %r11, 32                \n"
00053         "       stvx            %v21, %r9,  %r3         \n"
00054         "       li              %r9,  48                \n"
00055         "       stvx            %v22, %r11, %r3         \n"
00056         "       li              %r11, 64                \n"
00057         "       stvx            %v23, %r9,  %r3         \n"
00058         "       li              %r9,  80                \n"
00059         "       stvx            %v24, %r11, %r3         \n"
00060         "       li              %r11, 96                \n"
00061         "       stvx            %v25, %r9,  %r3         \n"
00062         "       li              %r9,  112               \n"
00063         "       stvx            %v26, %r11, %r3         \n"
00064         "       li              %r11, 128               \n"
00065         "       stvx            %v27, %r9,  %r3         \n"
00066         "       li              %r9,  144               \n"
00067         "       stvx            %v28, %r11, %r3         \n"
00068         "       li              %r11, 160               \n"
00069         "       stvx            %v29, %r9,  %r3         \n"
00070         "       li              %r9,  176               \n"
00071         "       stvx            %v30, %r11, %r3         \n"
00072         "       stvx            %v31, %r9,  %r3         \n"
00073          );
00074 }
00075 
00076 static void state_restore_altivec (cpu_state_t * state)
00077 {
00078     asm ("                                              \n"
00079         "       li              %r9,  16                \n"
00080         "       lvx             %v20, 0,    %r3         \n"
00081         "       li              %r11, 32                \n"
00082         "       lvx             %v21, %r9,  %r3         \n"
00083         "       li              %r9,  48                \n"
00084         "       lvx             %v22, %r11, %r3         \n"
00085         "       li              %r11, 64                \n"
00086         "       lvx             %v23, %r9,  %r3         \n"
00087         "       li              %r9,  80                \n"
00088         "       lvx             %v24, %r11, %r3         \n"
00089         "       li              %r11, 96                \n"
00090         "       lvx             %v25, %r9,  %r3         \n"
00091         "       li              %r9,  112               \n"
00092         "       lvx             %v26, %r11, %r3         \n"
00093         "       li              %r11, 128               \n"
00094         "       lvx             %v27, %r9,  %r3         \n"
00095         "       li              %r9,  144               \n"
00096         "       lvx             %v28, %r11, %r3         \n"
00097         "       li              %r11, 160               \n"
00098         "       lvx             %v29, %r9,  %r3         \n"
00099         "       li              %r9,  176               \n"
00100         "       lvx             %v30, %r11, %r3         \n"
00101         "       lvx             %v31, %r9,  %r3         \n"
00102          );
00103 }
00104 #endif
00105 
00106 void mpeg2_cpu_state_init (uint32_t accel)
00107 {
00108 #ifdef ARCH_X86
00109     if (accel & MPEG2_ACCEL_X86_MMX) {
00110         mpeg2_cpu_state_restore = state_restore_mmx;
00111     }
00112 #endif
00113 #ifdef ARCH_PPC
00114     if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
00115         mpeg2_cpu_state_save = state_save_altivec;
00116         mpeg2_cpu_state_restore = state_restore_altivec;
00117     }
00118 #endif
00119 }
 

Powered by Plone

This site conforms to the following standards: