Exemple #1
0
////////////////////////////////////////////////////////////////////////
// Installs ee exception handlers for the 'usual' exceptions and iop
// exception callback
void
installExceptionHandlers(void)
{
    int i;

	// Skip exception #8 (syscall) & 9 (breakpoint)
    for (i = 1; i < 4; i++) {
        SetVTLBRefillHandler(i, pkoExceptionHandler);
    }
    for (i = 4; i < 8; i++) {
        SetVCommonHandler(i, pkoExceptionHandler);
    }
    for (i = 10; i < 14; i++) {
        SetVCommonHandler(i, pkoExceptionHandler);
    }

}
Exemple #2
0
int ee_dbg_remove(int levels)
{
    u32 oldintr, oldop;
    int i;

    if((levels < 1) || (levels > 3)) { return(-1); }

    if(!(_installed_levels & levels)) { return(-1); }

    if((levels & _installed_levels) & 2)
    {
        oldintr = DIntr();
        oldop = ee_set_opmode(0);

        ee_dbg_clr_bps();

        // restore the original debug exception vector.
        memcpy((void *) (0x80000100), &__saved_dbg_ex_vector, sizeof(__saved_dbg_ex_vector));

        ee_set_opmode(oldop);
        if(oldintr) { EIntr(); }
        
        FlushCache(0);
        FlushCache(2);

        _installed_levels &= 1;
    }

    if((levels & _installed_levels) & 1)
    {
        // restore the exception handlers that we previously hooked.
        for(i = 1; i <= 3; i++)
        {
            if(_old_l1_handlers[i] != NULL)
            {
                SetVTLBRefillHandler(i, _old_l1_handlers[i]);
                _old_l1_handlers[i] = NULL;
            }
        }
        for(i = 4; i <= 7; i++)
        {
            if(_old_l1_handlers[i] != NULL)
            {
                SetVCommonHandler(i, _old_l1_handlers[i]);
                _old_l1_handlers[i] = NULL;
            }
        }
        for(i = 10; i <= 13; i++)
        {
            if(_old_l1_handlers[i] != NULL)
            {
                SetVCommonHandler(i, _old_l1_handlers[i]);
                _old_l1_handlers[i] = NULL;
            }
        }
        
        FlushCache(0);
        FlushCache(2);

        _installed_levels &= 2;
    }

    return(0);
}
Exemple #3
0
int ee_dbg_install(int levels)
{
    u32 oldintr, oldop;
    int i;

    if(_installed_levels & levels)
    {
        return(-1);
    }

    if(levels & 1)
    {
        for(i = 0; i < 16; i++) { ee_level1_exception_handlers[i] = NULL; }
    }

    if(levels & 2)
    {
        for(i = 0; i < 4; i++) { ee_level2_exception_handlers[i] = NULL; }

        oldintr = DIntr();
        oldop = ee_set_opmode(0);

        ee_dbg_clr_bps();
        
        // save the original level 2 debug exception vector.
        memcpy(&__saved_dbg_ex_vector, (void *) (0x80000100), 0x80);

        // replace the level 2 debug exception vector with our own
        memcpy((void *) (0x80000100), &__ee_level2_ex_vector, 32);

        ee_set_opmode(oldop);
        if(oldintr) { EIntr(); }
    }

    if(levels & 1)
    {
        // redirect desirable "Level 1" exceptions to our level 1 handler.
        for(i = 1; i <= 3; i++)
        {
            _old_l1_handlers[i] = GetExceptionHandler(i);
            SetVTLBRefillHandler(i, __ee_level1_ex_vector);
        }

        for(i = 4; i <= 7; i++)
        {
            _old_l1_handlers[i] = GetExceptionHandler(i);
            SetVCommonHandler(i, __ee_level1_ex_vector);
        }

        for(i = 10; i <= 13; i++)
        {
            _old_l1_handlers[i] = GetExceptionHandler(i);
            SetVCommonHandler(i, __ee_level1_ex_vector);
        }
    }

    FlushCache(0);
    FlushCache(2);

    _installed_levels |= levels;

    return(0);
}