static int get_phys_addr_mpu(CPUARMState *env, uint32_t address,

                             int access_type, int is_user,

                             hwaddr *phys_ptr, int *prot)

{

    int n;

    uint32_t mask;

    uint32_t base;



    *phys_ptr = address;

    for (n = 7; n >= 0; n--) {

	base = env->cp15.c6_region[n];

	if ((base & 1) == 0)

	    continue;

	mask = 1 << ((base >> 1) & 0x1f);

	/* Keep this shift separate from the above to avoid an

	   (undefined) << 32.  */

	mask = (mask << 1) - 1;

	if (((base ^ address) & ~mask) == 0)

	    break;

    }

    if (n < 0)

	return 2;



    if (access_type == 2) {

	mask = env->cp15.c5_insn;

    } else {

	mask = env->cp15.c5_data;

    }

    mask = (mask >> (n * 4)) & 0xf;

    switch (mask) {

    case 0:

	return 1;

    case 1:

	if (is_user)

	  return 1;

	*prot = PAGE_READ | PAGE_WRITE;

	break;

    case 2:

	*prot = PAGE_READ;

	if (!is_user)

	    *prot |= PAGE_WRITE;

	break;

    case 3:

	*prot = PAGE_READ | PAGE_WRITE;

	break;

    case 5:

	if (is_user)

	    return 1;

	*prot = PAGE_READ;

	break;

    case 6:

	*prot = PAGE_READ;

	break;

    default:

	/* Bad permission.  */

	return 1;

    }

    *prot |= PAGE_EXEC;

    return 0;

}

static int get_phys_addr_mpu(CPUARMState *env, uint32_t address,

                             int access_type, int is_user,

                             hwaddr *phys_ptr, int *prot)

{

    int n;

    uint32_t mask;

    uint32_t base;



    *phys_ptr = address;

    for (n = 7; n >= 0; n--) {

	base = env->cp15.c6_region[n];

	if ((base & 1) == 0)

	    continue;

	mask = 1 << ((base >> 1) & 0x1f);

	



	mask = (mask << 1) - 1;

	if (((base ^ address) & ~mask) == 0)

	    break;

    }

    if (n < 0)

	return 2;



    if (access_type == 2) {

	mask = env->cp15.c5_insn;

    } else {

	mask = env->cp15.c5_data;

    }

    mask = (mask >> (n * 4)) & 0xf;

    switch (mask) {

    case 0:

	return 1;

    case 1:

	if (is_user)

	  return 1;

	*prot = PAGE_READ | PAGE_WRITE;

	break;

    case 2:

	*prot = PAGE_READ;

	if (!is_user)

	    *prot |= PAGE_WRITE;

	break;

    case 3:

	*prot = PAGE_READ | PAGE_WRITE;

	break;

    case 5:

	if (is_user)

	    return 1;

	*prot = PAGE_READ;

	break;

    case 6:

	*prot = PAGE_READ;

	break;

    default:

	

	return 1;

    }

    *prot |= PAGE_EXEC;

    return 0;

}

	mask = env->cp15.c5_insn; 	mask = env->cp15.c5_data;
static int FUNC_0(CPUARMState *VAR_0, uint32_t VAR_1,

                             int VAR_2, int VAR_3,

                             hwaddr *VAR_4, int *VAR_5)

{

    int VAR_6;

    uint32_t mask;

    uint32_t base;



    *VAR_4 = VAR_1;

    for (VAR_6 = 7; VAR_6 >= 0; VAR_6--) {

	base = VAR_0->cp15.c6_region[VAR_6];

	if ((base & 1) == 0)

	    continue;

	mask = 1 << ((base >> 1) & 0x1f);

	



	mask = (mask << 1) - 1;

	if (((base ^ VAR_1) & ~mask) == 0)

	    break;

    }

    if (VAR_6 < 0)

	return 2;



    if (VAR_2 == 2) {

	mask = VAR_0->cp15.c5_insn;

    } else {

	mask = VAR_0->cp15.c5_data;

    }

    mask = (mask >> (VAR_6 * 4)) & 0xf;

    switch (mask) {

    case 0:

	return 1;

    case 1:

	if (VAR_3)

	  return 1;

	*VAR_5 = PAGE_READ | PAGE_WRITE;

	break;

    case 2:

	*VAR_5 = PAGE_READ;

	if (!VAR_3)

	    *VAR_5 |= PAGE_WRITE;

	break;

    case 3:

	*VAR_5 = PAGE_READ | PAGE_WRITE;

	break;

    case 5:

	if (VAR_3)

	    return 1;

	*VAR_5 = PAGE_READ;

	break;

    case 6:

	*VAR_5 = PAGE_READ;

	break;

    default:

	

	return 1;

    }

    *VAR_5 |= PAGE_EXEC;

    return 0;

}

static int FUNC_0(CPUARMState *VAR_0, uint32_t VAR_1,
int VAR_2, int VAR_3,
hwaddr *VAR_4, int *VAR_5)
{ int VAR_6; uint32_t mask; uint32_t base; *VAR_4 = VAR_1; for (VAR_6 = 7; VAR_6 >= 0; VAR_6--) { base = VAR_0->cp15.c6_region[VAR_6]; if ((base & 1) == 0)
continue; mask = 1 << ((base >> 1) & 0x1f); mask = (mask << 1) - 1; if (((base ^ VAR_1) & ~mask) == 0)
break; } if (VAR_6 < 0)
return 2; if (VAR_2 == 2) { mask = VAR_0->cp15.c5_insn; } else { mask = VAR_0->cp15.c5_data; } mask = (mask >> (VAR_6 * 4)) & 0xf; switch (mask) { case 0:
return 1; case 1:
if (VAR_3)
return 1; *VAR_5 = PAGE_READ | PAGE_WRITE; break; case 2:
*VAR_5 = PAGE_READ; if (!VAR_3)
*VAR_5 |= PAGE_WRITE; break; case 3:
*VAR_5 = PAGE_READ | PAGE_WRITE; break; case 5:
if (VAR_3)
return 1; *VAR_5 = PAGE_READ; break; case 6:
*VAR_5 = PAGE_READ; break; default:
return 1; } *VAR_5 |= PAGE_EXEC; return 0; }