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
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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 }