static int ppc_hash32_translate(CPUPPCState *env, struct mmu_ctx_hash32 *ctx,

                                target_ulong eaddr, int rwx)

{

    int ret;

    target_ulong sr;



    /* 1. Handle real mode accesses */

    if (((rwx == 2) && (msr_ir == 0)) || ((rwx != 2) && (msr_dr == 0))) {

        /* Translation is off */

        ctx->raddr = eaddr;

        ctx->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE;

        return 0;

    }



    /* 2. Check Block Address Translation entries (BATs) */

    if (env->nb_BATs != 0) {

        ret = ppc_hash32_get_bat(env, ctx, eaddr, rwx);

        if (ret == 0) {

            return 0;

        }

    }



    /* 3. Look up the Segment Register */

    sr = env->sr[eaddr >> 28];



    /* 4. Handle direct store segments */

    if (sr & SR32_T) {

        return ppc_hash32_direct_store(env, sr, eaddr, rwx,

                                       &ctx->raddr, &ctx->prot);

    }



    /* 5. Check for segment level no-execute violation */

    ctx->nx = !!(sr & SR32_NX);

    if ((rwx == 2) && ctx->nx) {

        return -3;

    }

    ret = find_pte32(env, ctx, sr, eaddr, rwx);



    return ret;

}

static int ppc_hash32_translate(CPUPPCState *env, struct mmu_ctx_hash32 *ctx,

                                target_ulong eaddr, int rwx)

{

    int ret;

    target_ulong sr;



    

    if (((rwx == 2) && (msr_ir == 0)) || ((rwx != 2) && (msr_dr == 0))) {

        

        ctx->raddr = eaddr;

        ctx->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE;

        return 0;

    }



    

    if (env->nb_BATs != 0) {

        ret = ppc_hash32_get_bat(env, ctx, eaddr, rwx);

        if (ret == 0) {

            return 0;

        }

    }



    

    sr = env->sr[eaddr >> 28];



    

    if (sr & SR32_T) {

        return ppc_hash32_direct_store(env, sr, eaddr, rwx,

                                       &ctx->raddr, &ctx->prot);

    }



    

    ctx->nx = !!(sr & SR32_NX);

    if ((rwx == 2) && ctx->nx) {

        return -3;

    }

    ret = find_pte32(env, ctx, sr, eaddr, rwx);



    return ret;

}

static int FUNC_0(CPUPPCState *VAR_0, struct mmu_ctx_hash32 *VAR_1,

                                target_ulong VAR_2, int VAR_3)

{

    int VAR_4;

    target_ulong sr;



    

    if (((VAR_3 == 2) && (msr_ir == 0)) || ((VAR_3 != 2) && (msr_dr == 0))) {

        

        VAR_1->raddr = VAR_2;

        VAR_1->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE;

        return 0;

    }



    

    if (VAR_0->nb_BATs != 0) {

        VAR_4 = ppc_hash32_get_bat(VAR_0, VAR_1, VAR_2, VAR_3);

        if (VAR_4 == 0) {

            return 0;

        }

    }



    

    sr = VAR_0->sr[VAR_2 >> 28];



    

    if (sr & SR32_T) {

        return ppc_hash32_direct_store(VAR_0, sr, VAR_2, VAR_3,

                                       &VAR_1->raddr, &VAR_1->prot);

    }



    

    VAR_1->nx = !!(sr & SR32_NX);

    if ((VAR_3 == 2) && VAR_1->nx) {

        return -3;

    }

    VAR_4 = find_pte32(VAR_0, VAR_1, sr, VAR_2, VAR_3);



    return VAR_4;

}

static int FUNC_0(CPUPPCState *VAR_0, struct mmu_ctx_hash32 *VAR_1,
target_ulong VAR_2, int VAR_3)
{ int VAR_4; target_ulong sr; if (((VAR_3 == 2) && (msr_ir == 0)) || ((VAR_3 != 2) && (msr_dr == 0))) { VAR_1->raddr = VAR_2; VAR_1->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE; return 0; } if (VAR_0->nb_BATs != 0) { VAR_4 = ppc_hash32_get_bat(VAR_0, VAR_1, VAR_2, VAR_3); if (VAR_4 == 0) { return 0; } } sr = VAR_0->sr[VAR_2 >> 28]; if (sr & SR32_T) { return ppc_hash32_direct_store(VAR_0, sr, VAR_2, VAR_3,
&VAR_1->raddr, &VAR_1->prot); } VAR_1->nx = !!(sr & SR32_NX); if ((VAR_3 == 2) && VAR_1->nx) { return -3; } VAR_4 = find_pte32(VAR_0, VAR_1, sr, VAR_2, VAR_3); return VAR_4; }