ARM System MMU(SMMU)是用于虚拟地址与物理地址转换的硬件模块。SMMU将多个不同设备的地址映射到phys_to_dma和dma_to_phys表(这两个表由IOMMU程序在操作系统启动时自动设置)中的相应位置。
在SMMU中,每个事务都有一个被称为stream ID的唯一标识符。事务被视为一个过程,其中设备在某个通道上读取或写入数据。这个stream ID用于识别给定设备的操作,然后将相应的物理地址映射到该设备。
以下是一个示例代码,用于设置SMMU事务和stream ID:
#define ARM_SMMU_STREAMID_BASE 0 /* Default stream id for devices */
/* Configure the ARM SMMU */
static int arm_smmu_configure(void)
{
....
/* Set the stream id for devices */
iommu->write32(iommu->base + ARM_SMMU_GR0_sCR0, ARM_SMMU_GR0_sCR0_USFCFG_EN);
iommu->write32(iommu->base + ARM_SMMU_GR0_sCR1, ARM_SMMU_GR0_sCR1_USFCFG);
iommu->write32(iommu->base + ARM_SMMU_GR0_sCR2, ARM_SMMU_GR0_sCR2_SMTNMB);
iommu->write64(iommu->base + ARM_SMMU_GR0_sCR3, ARM_SMMU_GR0_sCR3_S1STALL | ARM_SMMU_GR0_sCR3_ATS_S1E);
/* Set the stream id */
iommu->write32(iommu->base + ARM_SMMU_GR1_sCR1, ARM_SMMU_GR1_sCR1_SSID_EN | ARM_SMMU_STREAMID_BASE);
....
}
上一篇:ARMSim超出有效内存范围