1 /*---------------------------------------------------------------------------* 2 Project: Cafe 3 File: PPCArch.h 4 5 Copyright (C) Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 *---------------------------------------------------------------------------*/ 14 15 #ifndef __PPCARCH_H__ 16 #define __PPCARCH_H__ 17 18 #ifndef EPPC 19 #define EPPC // embedded PowerPC 20 #endif // EPPC 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #ifndef _ASSEMBLER 27 #include <types.h> 28 #endif // _ASSEMBLER 29 30 31 /*---------------------------------------------------------------------------* 32 GQR 33 *---------------------------------------------------------------------------*/ 34 #ifndef _ASSEMBLER 35 typedef struct 36 { 37 u32 _pad0 :2; 38 u32 loadScale :6; 39 u32 _pad1 :5; 40 u32 loadType :3; 41 u32 _pad2 :2; 42 u32 storeScale :6; 43 u32 _pad3 :5; 44 u32 storeType :3; 45 } PPC_GQR_t; 46 47 typedef union 48 { 49 u32 val; 50 PPC_GQR_t f; 51 } PPC_GQR_u; 52 #endif // _ASSEMBLER 53 54 /*---------------------------------------------------------------------------* 55 DMA fields 56 *---------------------------------------------------------------------------*/ 57 #ifndef _ASSEMBLER 58 typedef struct 59 { 60 u32 memAddr :27; 61 u32 dmaLenU :5; 62 } PPC_DMA_U_t; 63 64 typedef union 65 { 66 u32 val; 67 PPC_DMA_U_t f; 68 } PPC_DMA_U_u; 69 70 71 typedef struct 72 { 73 u32 lcAddr :27; 74 u32 dmaLd :1; 75 u32 dmaLenL :2; 76 u32 dmaTrigger :1; 77 u32 dmaFlush :1; 78 } PPC_DMA_L_t; 79 80 81 typedef union 82 { 83 u32 val; 84 PPC_DMA_L_t f; 85 } PPC_DMA_L_u; 86 #endif // _ASSEMBLER 87 88 89 #ifndef _ASSEMBLER 90 91 /*---------------------------------------------------------------------------* 92 PPC instructions 93 *---------------------------------------------------------------------------*/ 94 #ifdef __ghs__ 95 #define WEAK_SYMBOL 96 #else 97 #define WEAK_SYMBOL __declspec(weak) 98 #endif 99 100 u32 PPCMfmsr ( void ); 101 void PPCMtmsr ( u32 newMSR ); 102 u32 PPCOrMsr ( u32 value ); 103 u32 PPCAndMsr ( u32 value ); 104 u32 PPCAndCMsr( u32 value ); 105 106 u32 PPCMfhid0 ( void ); 107 void PPCMthid0 ( u32 newHID0 ); 108 109 u32 PPCMfhid1 ( void ); 110 111 u32 PPCMfhid2 ( void ); 112 void PPCMthid2 ( u32 newhid2 ); 113 114 u32 PPCMfwpar ( void ); 115 // Note: this will flush the write pipe 116 void PPCMtwpar ( u32 newwpar ); 117 118 u32 PPCMfdmaU ( void ); 119 u32 PPCMfdmaL ( void ); 120 121 void PPCMtdmaU ( u32 newdmau ); 122 void PPCMtdmaL ( u32 newdmal ); 123 124 u32 PPCMfl2cr ( void ); 125 void PPCMtl2cr ( u32 newL2cr ); 126 127 void PPCMtdec ( u32 newDec ); 128 u32 PPCMfdec ( void ); 129 130 void PPCSync ( void ); 131 void PPCEieio ( void ); 132 133 void __PPCHalt ( void ); 134 void __PPCExit ( int result ); 135 void PPCHalt ( char* msg, u32 size ); 136 void PPCIsync ( void ); 137 138 u32 PPCMfmmcr0( void ); 139 void PPCMtmmcr0( u32 newMmcr0 ); 140 u32 PPCMfmmcr1( void ); 141 void PPCMtmmcr1( u32 newMmcr1 ); 142 u32 PPCMfpmc1 ( void ); 143 void PPCMtpmc1 ( u32 newPmc1 ); 144 u32 PPCMfpmc2 ( void ); 145 void PPCMtpmc2 ( u32 newPmc2 ); 146 u32 PPCMfpmc3 ( void ); 147 void PPCMtpmc3 ( u32 newPmc3 ); 148 u32 PPCMfpmc4 ( void ); 149 void PPCMtpmc4 ( u32 newPmc4 ); 150 u32 PPCMfsia ( void ); 151 void PPCMtsia ( u32 newSia ); 152 153 u32 PPCMfpvr ( void ); 154 155 u32 PPCMffpscr( void ); 156 void PPCMtfpscr( u32 newFPSCR ); 157 158 /*---------------------------------------------------------------------------* 159 PPC mode functions 160 *---------------------------------------------------------------------------*/ 161 void PPCEnableSpeculation ( void ); 162 void PPCDisableSpeculation ( void ); 163 164 void PPCSetFpIEEEMode ( void ); 165 void PPCSetFpNonIEEEMode ( void ); 166 167 u32 PPCMfhid4 ( void ); 168 void PPCMthid4 ( register u32 newhid4 ); 169 170 u32 PPCMfpir ( void ); 171 u32 PPCMfsprg0 ( void ); 172 173 #endif // _ASSEMBLER 174 175 #ifdef __cplusplus 176 } 177 #endif 178 179 #endif //__PPCARCH_H__ 180