| 204 | } |
| 205 | |
| 206 | void OSInit(void) |
| 207 | { |
| 208 | /* |
| 209 | Initializes the Dolphin operating system. |
| 210 | - most of the main operations get farmed out to other functions |
| 211 | - loading debug info and setting up heap bounds largely happen here |
| 212 | - a lot of OS reporting also gets controlled here |
| 213 | */ |
| 214 | // pretty sure this is the min(/max) amount of pointers etc for the stack to match |
| 215 | BI2Debug* DebugInfo; |
| 216 | void* debugArenaLo; |
| 217 | u32 inputConsoleType; |
| 218 | u32 tdev; |
| 219 | |
| 220 | // check if we've already done all this or not |
| 221 | if ((BOOL)AreWeInitialized == FALSE) |
| 222 | { // fantastic name |
| 223 | AreWeInitialized = TRUE; // flag to make sure we don't have to do this again |
| 224 | |
| 225 | // SYSTEM // |
| 226 | __OSStartTime = __OSGetSystemTime(); |
| 227 | OSDisableInterrupts(); |
| 228 | |
| 229 | // set some PPC things |
| 230 | PPCMtmmcr0(0); |
| 231 | PPCMtmmcr1(0); |
| 232 | PPCMtpmc1(0); |
| 233 | PPCMtpmc2(0); |
| 234 | PPCMtpmc3(0); |
| 235 | PPCMtpmc4(0); |
| 236 | PPCDisableSpeculation(); |
| 237 | PPCSetFpNonIEEEMode(); |
| 238 | |
| 239 | // DEBUG // |
| 240 | // load some DVD stuff |
| 241 | BI2DebugFlag = 0; // debug flag from the DVD BI2 header |
| 242 | BootInfo = (OSBootInfo*)OS_BASE_CACHED; // set pointer to BootInfo |
| 243 | |
| 244 | __DVDLongFileNameFlag = |
| 245 | (u32)0; // flag to tell us whether we make it through the debug loading |
| 246 | |
| 247 | // time to grab a bunch of debug info from the DVD |
| 248 | // the address for where the BI2 debug info is, is stored at OS_BI2_DEBUG_ADDRESS |
| 249 | DebugInfo = (BI2Debug*)*((u32*)OS_BI2_DEBUG_ADDRESS); |
| 250 | |
| 251 | // if the debug info address exists, grab some debug info |
| 252 | if (DebugInfo != NULL) |
| 253 | { |
| 254 | BI2DebugFlag = &DebugInfo->debugFlag; // debug flag from DVD BI2 |
| 255 | __PADSpec = (u32)DebugInfo->padSpec; // some other info from DVD BI2 |
| 256 | *((u8*)DEBUGFLAG_ADDR) = (u8)*BI2DebugFlag; // store flag in mem |
| 257 | *((u8*)OS_DEBUG_ADDRESS_2) = (u8)__PADSpec; // store other info in mem |
| 258 | } |
| 259 | else if (BootInfo->arenaHi) |
| 260 | { // if the top of the heap is already set |
| 261 | BI2DebugFlagHolder = |
| 262 | (u32*)*((u8*)DEBUGFLAG_ADDR); // grab whatever's stored at 0x800030E8 |
| 263 | BI2DebugFlag = (u32*)&BI2DebugFlagHolder; // flag is then address of flag holder |
no test coverage detected