int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,

                  target_ulong *raddr, int *flags)

{

    int r = -1;

    uint8_t *sk;



    *flags = PAGE_READ | PAGE_WRITE | PAGE_EXEC;

    vaddr &= TARGET_PAGE_MASK;



    if (!(env->psw.mask & PSW_MASK_DAT)) {

        *raddr = vaddr;

        r = 0;

        goto out;

    }



    switch (asc) {

    case PSW_ASC_PRIMARY:

    case PSW_ASC_HOME:

        r = mmu_translate_asc(env, vaddr, asc, raddr, flags, rw);

        break;

    case PSW_ASC_SECONDARY:

        /*

         * Instruction: Primary

         * Data: Secondary

         */

        if (rw == 2) {

            r = mmu_translate_asc(env, vaddr, PSW_ASC_PRIMARY, raddr, flags,

                                  rw);

            *flags &= ~(PAGE_READ | PAGE_WRITE);

        } else {

            r = mmu_translate_asc(env, vaddr, PSW_ASC_SECONDARY, raddr, flags,

                                  rw);

            *flags &= ~(PAGE_EXEC);

        }

        break;

    case PSW_ASC_ACCREG:

    default:

        hw_error("guest switched to unknown asc mode\n");

        break;

    }



 out:

    /* Convert real address -> absolute address */

    *raddr = mmu_real2abs(env, *raddr);



    if (*raddr <= ram_size) {

        sk = &env->storage_keys[*raddr / TARGET_PAGE_SIZE];

        if (*flags & PAGE_READ) {

            *sk |= SK_R;

        }



        if (*flags & PAGE_WRITE) {

            *sk |= SK_C;

        }

    }



    return r;

}

int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,

                  target_ulong *raddr, int *flags)

{

    int r = -1;

    uint8_t *sk;



    *flags = PAGE_READ | PAGE_WRITE | PAGE_EXEC;

    vaddr &= TARGET_PAGE_MASK;



    if (!(env->psw.mask & PSW_MASK_DAT)) {

        *raddr = vaddr;

        r = 0;

        goto out;

    }



    switch (asc) {

    case PSW_ASC_PRIMARY:

    case PSW_ASC_HOME:

        r = mmu_translate_asc(env, vaddr, asc, raddr, flags, rw);

        break;

    case PSW_ASC_SECONDARY:

        







        if (rw == 2) {

            r = mmu_translate_asc(env, vaddr, PSW_ASC_PRIMARY, raddr, flags,

                                  rw);

            *flags &= ~(PAGE_READ | PAGE_WRITE);

        } else {

            r = mmu_translate_asc(env, vaddr, PSW_ASC_SECONDARY, raddr, flags,

                                  rw);

            *flags &= ~(PAGE_EXEC);

        }

        break;

    case PSW_ASC_ACCREG:

    default:

        hw_error("guest switched to unknown asc mode\n");

        break;

    }



 out:

    

    *raddr = mmu_real2abs(env, *raddr);



    if (*raddr <= ram_size) {

        sk = &env->storage_keys[*raddr / TARGET_PAGE_SIZE];

        if (*flags & PAGE_READ) {

            *sk |= SK_R;

        }



        if (*flags & PAGE_WRITE) {

            *sk |= SK_C;

        }

    }



    return r;

}

int FUNC_0(CPUS390XState *VAR_0, target_ulong VAR_1, int VAR_2, uint64_t VAR_3,

                  target_ulong *VAR_4, int *VAR_5)

{

    int VAR_6 = -1;

    uint8_t *sk;



    *VAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC;

    VAR_1 &= TARGET_PAGE_MASK;



    if (!(VAR_0->psw.mask & PSW_MASK_DAT)) {

        *VAR_4 = VAR_1;

        VAR_6 = 0;

        goto out;

    }



    switch (VAR_3) {

    case PSW_ASC_PRIMARY:

    case PSW_ASC_HOME:

        VAR_6 = mmu_translate_asc(VAR_0, VAR_1, VAR_3, VAR_4, VAR_5, VAR_2);

        break;

    case PSW_ASC_SECONDARY:

        







        if (VAR_2 == 2) {

            VAR_6 = mmu_translate_asc(VAR_0, VAR_1, PSW_ASC_PRIMARY, VAR_4, VAR_5,

                                  VAR_2);

            *VAR_5 &= ~(PAGE_READ | PAGE_WRITE);

        } else {

            VAR_6 = mmu_translate_asc(VAR_0, VAR_1, PSW_ASC_SECONDARY, VAR_4, VAR_5,

                                  VAR_2);

            *VAR_5 &= ~(PAGE_EXEC);

        }

        break;

    case PSW_ASC_ACCREG:

    default:

        hw_error("guest switched to unknown VAR_3 mode\n");

        break;

    }



 out:

    

    *VAR_4 = mmu_real2abs(VAR_0, *VAR_4);



    if (*VAR_4 <= ram_size) {

        sk = &VAR_0->storage_keys[*VAR_4 / TARGET_PAGE_SIZE];

        if (*VAR_5 & PAGE_READ) {

            *sk |= SK_R;

        }



        if (*VAR_5 & PAGE_WRITE) {

            *sk |= SK_C;

        }

    }



    return VAR_6;

}

int FUNC_0(CPUS390XState *VAR_0, target_ulong VAR_1, int VAR_2, uint64_t VAR_3,
target_ulong *VAR_4, int *VAR_5)
{ int VAR_6 = -1; uint8_t *sk; *VAR_5 = PAGE_READ | PAGE_WRITE | PAGE_EXEC; VAR_1 &= TARGET_PAGE_MASK; if (!(VAR_0->psw.mask & PSW_MASK_DAT)) { *VAR_4 = VAR_1; VAR_6 = 0; goto out; } switch (VAR_3) { case PSW_ASC_PRIMARY:
case PSW_ASC_HOME:
VAR_6 = mmu_translate_asc(VAR_0, VAR_1, VAR_3, VAR_4, VAR_5, VAR_2); break; case PSW_ASC_SECONDARY:
if (VAR_2 == 2) { VAR_6 = mmu_translate_asc(VAR_0, VAR_1, PSW_ASC_PRIMARY, VAR_4, VAR_5,
VAR_2); *VAR_5 &= ~(PAGE_READ | PAGE_WRITE); } else { VAR_6 = mmu_translate_asc(VAR_0, VAR_1, PSW_ASC_SECONDARY, VAR_4, VAR_5,
VAR_2); *VAR_5 &= ~(PAGE_EXEC); } break; case PSW_ASC_ACCREG:
default:
hw_error("guest switched to unknown VAR_3 mode\n"); break; } out:
*VAR_4 = mmu_real2abs(VAR_0, *VAR_4); if (*VAR_4 <= ram_size) { sk = &VAR_0->storage_keys[*VAR_4 / TARGET_PAGE_SIZE]; if (*VAR_5 & PAGE_READ) { *sk |= SK_R; } if (*VAR_5 & PAGE_WRITE) { *sk |= SK_C; } } return VAR_6; }