MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / OSExceptionInit

Function OSExceptionInit

src/dolphin/src/os/OS.c:419–505  ·  view source on GitHub ↗

* --INFO-- * Address: 800EB654 * Size: 000280 */

Source from the content-addressed store, hash-verified

417 * Size: 000280
418 */
419static void OSExceptionInit(void)
420{
421 __OSException exception;
422 void* destAddr;
423
424 // These two vars help us change the exception number embedded
425 // in the exception handler code.
426 u32* opCodeAddr;
427 u32 oldOpCode;
428
429 // Address range of the actual code to be copied.
430 u8* handlerStart;
431 u32 handlerSize;
432
433 // Install the first level exception vector.
434 opCodeAddr = (u32*)__OSEVSetNumber;
435 oldOpCode = *opCodeAddr;
436 handlerStart = (u8*)__OSEVStart;
437 handlerSize = (u32)((u8*)__OSEVEnd - (u8*)__OSEVStart);
438
439 // Install the DB integrator, only if we are the first OSInit to be run
440 destAddr = (void*)OSPhysicalToCached(OS_DBJUMPPOINT_ADDR);
441 if (*(u32*)destAddr == 0) // Lomem should be zero cleared only once by BS2
442 {
443 DBPrintf("Installing OSDBIntegrator\n");
444 memcpy(destAddr, (void*)__OSDBINTSTART, (u32)__OSDBINTEND - (u32)__OSDBINTSTART);
445 DCFlushRangeNoSync(destAddr, (u32)__OSDBINTEND - (u32)__OSDBINTSTART);
446 __sync();
447 ICInvalidateRange(destAddr, (u32)__OSDBINTEND - (u32)__OSDBINTSTART);
448 }
449
450 // Copy the right vector into the table
451 for (exception = 0; exception < __OS_EXCEPTION_MAX; exception++)
452 {
453 if (BI2DebugFlag && (*BI2DebugFlag >= 2) && __DBIsExceptionMarked(exception))
454 {
455 // this DBPrintf is suspicious.
456 DBPrintf(">>> OSINIT: exception %d commandeered by TRK\n", exception);
457 continue;
458 }
459
460 // Modify the copy of code in text before transferring
461 // to the exception table.
462 *opCodeAddr = oldOpCode | exception;
463
464 // Modify opcodes at __DBVECTOR if necessary
465 if (__DBIsExceptionMarked(exception))
466 {
467 DBPrintf(">>> OSINIT: exception %d vectored to debugger\n", exception);
468 memcpy((void*)__DBVECTOR, (void*)__OSDBJUMPSTART,
469 (u32)__OSDBJUMPEND - (u32)__OSDBJUMPSTART);
470 }
471 else
472 {
473 // make sure the opcodes are still nop
474 u32* ops = (u32*)__DBVECTOR;
475 int cb;
476

Callers 1

OSInitFunction · 0.85

Calls 3

DBPrintfFunction · 0.85
memcpyFunction · 0.85
__DBIsExceptionMarkedFunction · 0.85

Tested by

no test coverage detected