/* Convert MMU ATTR to PAGE_{READ,WRITE,EXEC} mask. See ISA, 4.  */
static unsigned mmu_attr_to_access(uint32_t attr)
/* Convert MMU ATTR to PAGE_{READ,WRITE,EXEC} mask. See ISA, 4.  */
static unsigned mmu_attr_to_access(uint32_t attr)
{
    unsigned access = 0;
    if (attr < 12) {
        access |= PAGE_READ;
        if (attr & 0x1) {
            access |= PAGE_EXEC;
        }
        if (attr & 0x2) {
            access |= PAGE_WRITE;
        }
        switch (attr & 0xc) {
        case 0:
            access |= PAGE_CACHE_BYPASS;
            break;
        case 4:
            access |= PAGE_CACHE_WB;
            break;
        case 8:
            access |= PAGE_CACHE_WT;
            break;
        }
    } else if (attr == 13) {
        access |= PAGE_READ | PAGE_WRITE | PAGE_CACHE_ISOLATE;
    }
    return access;
}