每个SAU寄存器是32位宽。下表显示了SAU寄存器概要。
5.1 SAU_CTRL register
SAU_CTRL寄存器的特征如下图和表所示:
5.2 SAU_TYPE register
5.3 SAU_RNR register
5.4 SAU_RBAR register
5.5 SAU_RLAR register
5.6 SAU区域配置
当SAU启用时,未由已启用的SAU区域覆盖的内存是安全的。区域可以单独使用SAU_RLAR启用。
- 当SAU_RLAR.ENABLE = 1且SAU_RLAR.NSC = 0时,该区域为非安全。
- 当SAU_RLAR.ENABLE = 1且SAU_RLAR.NSC = 1时,该区域既是安全的,又是非安全可调用的。
5.7 配置示例
下面的示例CMSIS代码展示了如何为两个区域配置SAU。
// Configure SAU using CMSIS
// Configure SAU Region 0
// Start Address 0x00200000
// Limit Address 0x003FFFE0
// Secure non-secure callable
// Use CMSIS to access SAU Region Number Register (SAU_RNR)
// Select region 0
SAU->RNR = (0);
// Set SAU Region Base Address Register (SAU_RBAR)
SAU->RBAR = (0x00200000U & SAU_RBAR_BADDR_Msk);
// Set SAU Region Limit Address Register (SAU_RLAR)
SAU->RLAR = (0x003FFFE0U & SAU_RLAR_LADDR_Msk) |
((1U << SAU_RLAR_NSC_Pos) & SAU_RLAR_NSC_Msk) | 1U;
// Configure SAU Region 1
// Start Address 0x20200000
// Limit Address 0x203FFFE0
// Non-secure
// Select region 1
SAU->RNR = (1);
// Set SAU Region Base Address Register (SAU_RBAR)
SAU->RBAR = (0x20200000U & SAU_RBAR_BADDR_Msk);
// Set SAU Region Limit Address Register (SAU_RLAR)
SAU->RLAR = (0x203FFFE0U & SAU_RLAR_LADDR_Msk) |
((0U << SAU_RLAR_NSC_Pos) & SAU_RLAR_NSC_Msk) | 1U;
// Enable SAU
// Use CMSIS to access SAU Control Register (SAU_CTRL)
// Set ENABLE bit[0] to 1
// Set ALLNS bit[1] to 1
// All memory is secure when SAU is disabled
SAU->CTRL = ((SAU_INIT_CTRL_ENABLE << SAU_CTRL_ENABLE_Pos) & SAU_CTRL_ENABLE_Msk) |
((SAU_INIT_CTRL_ALLNS << SAU_CTRL_ALLNS_Pos) & SAU_CTRL_ALLNS_Msk);