__STATIC_INLINE int __ap_section()

in AZ3166/src/system/mbed-os/cmsis/core_ca_mmu.h [290:315]


__STATIC_INLINE int __ap_section(uint32_t *descriptor_l1, mmu_access_Type user, mmu_access_Type priv,  uint32_t afe)
{
    uint32_t ap = 0;

    if (afe == 0) { //full access
        if ((priv == NO_ACCESS) && (user == NO_ACCESS)) { ap = 0x0; }
        else if ((priv == RW) && (user == NO_ACCESS))   { ap = 0x1; }
        else if ((priv == RW) && (user == READ))        { ap = 0x2; }
        else if ((priv == RW) && (user == RW))          { ap = 0x3; }
        else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
        else if ((priv == READ) && (user == READ))      { ap = 0x7; }
    }

    else { //Simplified access
        if ((priv == RW) && (user == NO_ACCESS))        { ap = 0x1; }
        else if ((priv == RW) && (user == RW))          { ap = 0x3; }
        else if ((priv == READ) && (user == NO_ACCESS)) { ap = 0x5; }
        else if ((priv == READ) && (user == READ))      { ap = 0x7; }
    }

    *descriptor_l1 &= SECTION_AP_MASK;
    *descriptor_l1 |= (ap & 0x3) << SECTION_AP_SHIFT;
    *descriptor_l1 |= ((ap & 0x4)>>2) << SECTION_AP2_SHIFT;

    return 0;
}