| 
									
										
										
										
											2010-01-08 01:46:27 -05:00
										 |  |  | #if defined(__APPLE__) | 
					
						
							|  |  |  |     #define MANGLE(sym) _##sym | 
					
						
							|  |  |  |     #define XX @
 | 
					
						
							| 
									
										
										
										
											2010-01-07 00:05:31 -05:00
										 |  |  | #else | 
					
						
							| 
									
										
										
										
											2010-01-08 01:46:27 -05:00
										 |  |  |     #define MANGLE(sym) sym | 
					
						
							|  |  |  |     #define XX ;
 | 
					
						
							| 
									
										
										
										
											2010-01-07 00:05:31 -05:00
										 |  |  | #endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* The returns and args are just for documentation */ | 
					
						
							|  |  |  | #define DEF(returns,symbol,args) .globl MANGLE(symbol) XX \ | 
					
						
							|  |  |  | MANGLE(symbol) | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Thanks to Joshua Grams for this code. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | On PowerPC processors, we must flush the instruction cache manually | 
					
						
							|  |  |  | after writing to the code heap. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 01:46:27 -05:00
										 |  |  | DEF(void,flush_icache,(void*, int)): | 
					
						
							|  |  |  |     /* compute number of cache lines to flush */ | 
					
						
							|  |  |  |     add r4,r4,r3 | 
					
						
							|  |  |  |     /* align addr to next lower cache line boundary */ | 
					
						
							|  |  |  |     clrrwi r3,r3,5 | 
					
						
							|  |  |  |     /* then n_lines = (len + 0x1f) / 0x20 */ | 
					
						
							|  |  |  |     sub r4,r4,r3 | 
					
						
							|  |  |  |     addi r4,r4,0x1f | 
					
						
							|  |  |  |     /* note '.' suffix */ | 
					
						
							|  |  |  |     srwi. r4,r4,5 | 
					
						
							|  |  |  |     /* if n_lines == 0, just return. */ | 
					
						
							|  |  |  |     beqlr | 
					
						
							|  |  |  |     /* flush cache lines */ | 
					
						
							|  |  |  |     mtctr r4 | 
					
						
							|  |  |  |     /* for each line... */ | 
					
						
							|  |  |  | 0:  dcbf 0,r3 | 
					
						
							|  |  |  |     sync | 
					
						
							|  |  |  |     icbi 0,r3 | 
					
						
							|  |  |  |     addi r3,r3,0x20 | 
					
						
							|  |  |  |     bdnz 0b | 
					
						
							|  |  |  |     /* finish up */ | 
					
						
							|  |  |  |     sync | 
					
						
							|  |  |  |     isync | 
					
						
							|  |  |  |     blr | 
					
						
							| 
									
										
										
										
											2009-05-06 16:39:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 16:29:29 -04:00
										 |  |  | DEF(void,get_ppc_fpu_env,(void*)): | 
					
						
							| 
									
										
										
										
											2010-01-08 01:46:27 -05:00
										 |  |  |     mffs f0 | 
					
						
							|  |  |  |     stfd f0,0(r3) | 
					
						
							|  |  |  |     blr | 
					
						
							| 
									
										
										
										
											2009-09-05 20:48:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-08 16:29:29 -04:00
										 |  |  | DEF(void,set_ppc_fpu_env,(const void*)): | 
					
						
							| 
									
										
										
										
											2010-01-08 01:46:27 -05:00
										 |  |  |     lfd f0,0(r3) | 
					
						
							|  |  |  |     mtfsf 0xff,f0 | 
					
						
							|  |  |  |     blr | 
					
						
							| 
									
										
										
										
											2009-09-12 21:39:41 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | DEF(void,get_ppc_vmx_env,(void*)): | 
					
						
							| 
									
										
										
										
											2010-01-08 01:46:27 -05:00
										 |  |  |     mfvscr v0 | 
					
						
							|  |  |  |     subi r4,r1,16 | 
					
						
							|  |  |  |     li r5,0xf | 
					
						
							|  |  |  |     andc r4,r4,r5 | 
					
						
							|  |  |  |     stvxl v0,0,r4 | 
					
						
							|  |  |  |     li r5,0xc | 
					
						
							|  |  |  |     lwzx r6,r5,r4 | 
					
						
							|  |  |  |     stw r6,0(r3) | 
					
						
							|  |  |  |     blr | 
					
						
							| 
									
										
										
										
											2009-09-12 21:39:41 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | DEF(void,set_ppc_vmx_env,(const void*)): | 
					
						
							| 
									
										
										
										
											2010-01-08 01:46:27 -05:00
										 |  |  |     subi r4,r1,16 | 
					
						
							|  |  |  |     li r5,0xf | 
					
						
							|  |  |  |     andc r4,r4,r5 | 
					
						
							|  |  |  |     li r5,0xc | 
					
						
							|  |  |  |     lwz r6,0(r3) | 
					
						
							|  |  |  |     stwx r6,r5,r4 | 
					
						
							|  |  |  |     lvxl v0,0,r4 | 
					
						
							|  |  |  |     mtvscr v0 | 
					
						
							|  |  |  |     blr |