int mmubooke_get_physical_address (CPUState *env, mmu_ctx_t *ctx,

                                   target_ulong address, int rw,

                                   int access_type)

{

    ppcemb_tlb_t *tlb;

    target_phys_addr_t raddr;

    int i, prot, ret;



    ret = -1;

    raddr = -1;

    for (i = 0; i < env->nb_tlb; i++) {

        tlb = &env->tlb[i].tlbe;

        if (ppcemb_tlb_check(env, tlb, &raddr, address,

                             env->spr[SPR_BOOKE_PID], 1, i) < 0)

            continue;

        if (msr_pr != 0)

            prot = tlb->prot & 0xF;

        else

            prot = (tlb->prot >> 4) & 0xF;

        /* Check the address space */

        if (access_type == ACCESS_CODE) {

            if (msr_ir != (tlb->attr & 1))

                continue;

            ctx->prot = prot;

            if (prot & PAGE_EXEC) {

                ret = 0;

                break;

            }

            ret = -3;

        } else {

            if (msr_dr != (tlb->attr & 1))

                continue;

            ctx->prot = prot;

            if ((!rw && prot & PAGE_READ) || (rw && (prot & PAGE_WRITE))) {

                ret = 0;

                break;

            }

            ret = -2;

        }

    }

    if (ret >= 0)

        ctx->raddr = raddr;



    return ret;

}

int mmubooke_get_physical_address (CPUState *env, mmu_ctx_t *ctx,

                                   target_ulong address, int rw,

                                   int access_type)

{

    ppcemb_tlb_t *tlb;

    target_phys_addr_t raddr;

    int i, prot, ret;



    ret = -1;

    raddr = -1;

    for (i = 0; i < env->nb_tlb; i++) {

        tlb = &env->tlb[i].tlbe;

        if (ppcemb_tlb_check(env, tlb, &raddr, address,

                             env->spr[SPR_BOOKE_PID], 1, i) < 0)

            continue;

        if (msr_pr != 0)

            prot = tlb->prot & 0xF;

        else

            prot = (tlb->prot >> 4) & 0xF;

        

        if (access_type == ACCESS_CODE) {

            if (msr_ir != (tlb->attr & 1))

                continue;

            ctx->prot = prot;

            if (prot & PAGE_EXEC) {

                ret = 0;

                break;

            }

            ret = -3;

        } else {

            if (msr_dr != (tlb->attr & 1))

                continue;

            ctx->prot = prot;

            if ((!rw && prot & PAGE_READ) || (rw && (prot & PAGE_WRITE))) {

                ret = 0;

                break;

            }

            ret = -2;

        }

    }

    if (ret >= 0)

        ctx->raddr = raddr;



    return ret;

}

    raddr = -1;     raddr = -1;
int FUNC_0 (CPUState *VAR_0, mmu_ctx_t *VAR_1,

                                   target_ulong VAR_2, int VAR_3,

                                   int VAR_4)

{

    ppcemb_tlb_t *tlb;

    target_phys_addr_t raddr;

    int VAR_5, VAR_6, VAR_7;



    VAR_7 = -1;

    raddr = -1;

    for (VAR_5 = 0; VAR_5 < VAR_0->nb_tlb; VAR_5++) {

        tlb = &VAR_0->tlb[VAR_5].tlbe;

        if (ppcemb_tlb_check(VAR_0, tlb, &raddr, VAR_2,

                             VAR_0->spr[SPR_BOOKE_PID], 1, VAR_5) < 0)

            continue;

        if (msr_pr != 0)

            VAR_6 = tlb->VAR_6 & 0xF;

        else

            VAR_6 = (tlb->VAR_6 >> 4) & 0xF;

        

        if (VAR_4 == ACCESS_CODE) {

            if (msr_ir != (tlb->attr & 1))

                continue;

            VAR_1->VAR_6 = VAR_6;

            if (VAR_6 & PAGE_EXEC) {

                VAR_7 = 0;

                break;

            }

            VAR_7 = -3;

        } else {

            if (msr_dr != (tlb->attr & 1))

                continue;

            VAR_1->VAR_6 = VAR_6;

            if ((!VAR_3 && VAR_6 & PAGE_READ) || (VAR_3 && (VAR_6 & PAGE_WRITE))) {

                VAR_7 = 0;

                break;

            }

            VAR_7 = -2;

        }

    }

    if (VAR_7 >= 0)

        VAR_1->raddr = raddr;



    return VAR_7;

}

int FUNC_0 (CPUState *VAR_0, mmu_ctx_t *VAR_1,
target_ulong VAR_2, int VAR_3,
int VAR_4)
{ ppcemb_tlb_t *tlb; target_phys_addr_t raddr; int VAR_5, VAR_6, VAR_7; VAR_7 = -1; raddr = -1; for (VAR_5 = 0; VAR_5 < VAR_0->nb_tlb; VAR_5++) { tlb = &VAR_0->tlb[VAR_5].tlbe; if (ppcemb_tlb_check(VAR_0, tlb, &raddr, VAR_2,
VAR_0->spr[SPR_BOOKE_PID], 1, VAR_5) < 0)
continue; if (msr_pr != 0)
VAR_6 = tlb->VAR_6 & 0xF; else
VAR_6 = (tlb->VAR_6 >> 4) & 0xF; if (VAR_4 == ACCESS_CODE) { if (msr_ir != (tlb->attr & 1))
continue; VAR_1->VAR_6 = VAR_6; if (VAR_6 & PAGE_EXEC) { VAR_7 = 0; break; } VAR_7 = -3; } else { if (msr_dr != (tlb->attr & 1))
continue; VAR_1->VAR_6 = VAR_6; if ((!VAR_3 && VAR_6 & PAGE_READ) || (VAR_3 && (VAR_6 & PAGE_WRITE))) { VAR_7 = 0; break; } VAR_7 = -2; } } if (VAR_7 >= 0)
VAR_1->raddr = raddr; return VAR_7; }