void ppc_hw_interrupt (CPUPPCState *env)

{

    int raised = 0;



#if 1

    if (loglevel & CPU_LOG_INT) {

        fprintf(logfile, "%s: %p pending %08x req %08x me %d ee %d\n",

                __func__, env, env->pending_interrupts,

                env->interrupt_request, msr_me, msr_ee);

    }

#endif

    /* Raise it */

    if (env->pending_interrupts & (1 << PPC_INTERRUPT_RESET)) {

        /* External reset / critical input */

        /* XXX: critical input should be handled another way.

         *      This code is not correct !

         */

        env->exception_index = EXCP_RESET;

        env->pending_interrupts &= ~(1 << PPC_INTERRUPT_RESET);

        raised = 1;

    }

    if (raised == 0 && msr_me != 0) {

        /* Machine check exception */

        if (env->pending_interrupts & (1 << PPC_INTERRUPT_MCK)) {

            env->exception_index = EXCP_MACHINE_CHECK;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_MCK);

            raised = 1;

        }

    }

    if (raised == 0 && msr_ee != 0) {

#if defined(TARGET_PPC64H) /* PowerPC 64 with hypervisor mode support */

        /* Hypervisor decrementer exception */

        if (env->pending_interrupts & (1 << PPC_INTERRUPT_HDECR)) {

            env->exception_index = EXCP_HDECR;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_HDECR);

            raised = 1;

        } else

#endif

        /* Decrementer exception */

        if (env->pending_interrupts & (1 << PPC_INTERRUPT_DECR)) {

            env->exception_index = EXCP_DECR;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DECR);

            raised = 1;

        /* Programmable interval timer on embedded PowerPC */

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_PIT)) {

            env->exception_index = EXCP_40x_PIT;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_PIT);

            raised = 1;

        /* Fixed interval timer on embedded PowerPC */

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_FIT)) {

            env->exception_index = EXCP_40x_FIT;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_FIT);

            raised = 1;

        /* Watchdog timer on embedded PowerPC */

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_WDT)) {

            env->exception_index = EXCP_40x_WATCHDOG;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_WDT);

            raised = 1;

        /* External interrupt */

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_EXT)) {

            env->exception_index = EXCP_EXTERNAL;

            /* Taking an external interrupt does not clear the external

             * interrupt status

             */

#if 0

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_EXT);

#endif

            raised = 1;

#if 0 // TODO

        /* Thermal interrupt */

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_THERM)) {

            env->exception_index = EXCP_970_THRM;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_THERM);

            raised = 1;

#endif

        }

#if 0 // TODO

    /* External debug exception */

    } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_DEBUG)) {

        env->exception_index = EXCP_xxx;

        env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DEBUG);

        raised = 1;

#endif

    }

    if (raised != 0) {

        env->error_code = 0;

        do_interrupt(env);

    }

}

void ppc_hw_interrupt (CPUPPCState *env)

{

    int raised = 0;



#if 1

    if (loglevel & CPU_LOG_INT) {

        fprintf(logfile, "%s: %p pending %08x req %08x me %d ee %d\n",

                __func__, env, env->pending_interrupts,

                env->interrupt_request, msr_me, msr_ee);

    }

#endif

    

    if (env->pending_interrupts & (1 << PPC_INTERRUPT_RESET)) {

        

        





        env->exception_index = EXCP_RESET;

        env->pending_interrupts &= ~(1 << PPC_INTERRUPT_RESET);

        raised = 1;

    }

    if (raised == 0 && msr_me != 0) {

        

        if (env->pending_interrupts & (1 << PPC_INTERRUPT_MCK)) {

            env->exception_index = EXCP_MACHINE_CHECK;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_MCK);

            raised = 1;

        }

    }

    if (raised == 0 && msr_ee != 0) {

#if defined(TARGET_PPC64H) 

        

        if (env->pending_interrupts & (1 << PPC_INTERRUPT_HDECR)) {

            env->exception_index = EXCP_HDECR;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_HDECR);

            raised = 1;

        } else

#endif

        

        if (env->pending_interrupts & (1 << PPC_INTERRUPT_DECR)) {

            env->exception_index = EXCP_DECR;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DECR);

            raised = 1;

        

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_PIT)) {

            env->exception_index = EXCP_40x_PIT;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_PIT);

            raised = 1;

        

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_FIT)) {

            env->exception_index = EXCP_40x_FIT;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_FIT);

            raised = 1;

        

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_WDT)) {

            env->exception_index = EXCP_40x_WATCHDOG;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_WDT);

            raised = 1;

        

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_EXT)) {

            env->exception_index = EXCP_EXTERNAL;

            





#if 0

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_EXT);

#endif

            raised = 1;

#if 0 

        

        } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_THERM)) {

            env->exception_index = EXCP_970_THRM;

            env->pending_interrupts &= ~(1 << PPC_INTERRUPT_THERM);

            raised = 1;

#endif

        }

#if 0 

    

    } else if (env->pending_interrupts & (1 << PPC_INTERRUPT_DEBUG)) {

        env->exception_index = EXCP_xxx;

        env->pending_interrupts &= ~(1 << PPC_INTERRUPT_DEBUG);

        raised = 1;

#endif

    }

    if (raised != 0) {

        env->error_code = 0;

        do_interrupt(env);

    }

}

void FUNC_0 (CPUPPCState *VAR_0)

{

    int VAR_1 = 0;



#if 1

    if (loglevel & CPU_LOG_INT) {

        fprintf(logfile, "%s: %p pending %08x req %08x me %d ee %d\n",

                __func__, VAR_0, VAR_0->pending_interrupts,

                VAR_0->interrupt_request, msr_me, msr_ee);

    }

#endif

    

    if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_RESET)) {

        

        





        VAR_0->exception_index = EXCP_RESET;

        VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_RESET);

        VAR_1 = 1;

    }

    if (VAR_1 == 0 && msr_me != 0) {

        

        if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_MCK)) {

            VAR_0->exception_index = EXCP_MACHINE_CHECK;

            VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_MCK);

            VAR_1 = 1;

        }

    }

    if (VAR_1 == 0 && msr_ee != 0) {

#if defined(TARGET_PPC64H) 

        

        if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_HDECR)) {

            VAR_0->exception_index = EXCP_HDECR;

            VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_HDECR);

            VAR_1 = 1;

        } else

#endif

        

        if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_DECR)) {

            VAR_0->exception_index = EXCP_DECR;

            VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_DECR);

            VAR_1 = 1;

        

        } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_PIT)) {

            VAR_0->exception_index = EXCP_40x_PIT;

            VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_PIT);

            VAR_1 = 1;

        

        } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_FIT)) {

            VAR_0->exception_index = EXCP_40x_FIT;

            VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_FIT);

            VAR_1 = 1;

        

        } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_WDT)) {

            VAR_0->exception_index = EXCP_40x_WATCHDOG;

            VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_WDT);

            VAR_1 = 1;

        

        } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_EXT)) {

            VAR_0->exception_index = EXCP_EXTERNAL;

            





#if 0

            VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_EXT);

#endif

            VAR_1 = 1;

#if 0 

        

        } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_THERM)) {

            VAR_0->exception_index = EXCP_970_THRM;

            VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_THERM);

            VAR_1 = 1;

#endif

        }

#if 0 

    

    } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_DEBUG)) {

        VAR_0->exception_index = EXCP_xxx;

        VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_DEBUG);

        VAR_1 = 1;

#endif

    }

    if (VAR_1 != 0) {

        VAR_0->error_code = 0;

        do_interrupt(VAR_0);

    }

}

void FUNC_0 (CPUPPCState *VAR_0)
{ int VAR_1 = 0; #if 1
if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: %p pending %08x req %08x me %d ee %d\n",
__func__, VAR_0, VAR_0->pending_interrupts,
VAR_0->interrupt_request, msr_me, msr_ee); } #endif
if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_RESET)) { VAR_0->exception_index = EXCP_RESET; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_RESET); VAR_1 = 1; } if (VAR_1 == 0 && msr_me != 0) { if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_MCK)) { VAR_0->exception_index = EXCP_MACHINE_CHECK; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_MCK); VAR_1 = 1; } } if (VAR_1 == 0 && msr_ee != 0) { #if defined(TARGET_PPC64H)
if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_HDECR)) { VAR_0->exception_index = EXCP_HDECR; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_HDECR); VAR_1 = 1; } else #endif
if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_DECR)) { VAR_0->exception_index = EXCP_DECR; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_DECR); VAR_1 = 1; } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_PIT)) { VAR_0->exception_index = EXCP_40x_PIT; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_PIT); VAR_1 = 1; } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_FIT)) { VAR_0->exception_index = EXCP_40x_FIT; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_FIT); VAR_1 = 1; } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_WDT)) { VAR_0->exception_index = EXCP_40x_WATCHDOG; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_WDT); VAR_1 = 1; } else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_EXT)) { VAR_0->exception_index = EXCP_EXTERNAL; #if 0
VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_EXT); #endif
VAR_1 = 1; #if 0
} else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_THERM)) { VAR_0->exception_index = EXCP_970_THRM; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_THERM); VAR_1 = 1; #endif
} #if 0
} else if (VAR_0->pending_interrupts & (1 << PPC_INTERRUPT_DEBUG)) { VAR_0->exception_index = EXCP_xxx; VAR_0->pending_interrupts &= ~(1 << PPC_INTERRUPT_DEBUG); VAR_1 = 1; #endif
} if (VAR_1 != 0) { VAR_0->error_code = 0; do_interrupt(VAR_0); } }