AR# 47662


14.1 Zynq - Changing Memory Access Type


How can I change the memory access type from CortexA9 through the GP0 to PL to other options such as shared device accesses when running Linux?


The access type for memory in the Xilinx GIT tree ( can be altered by using the ioremap function associated with Linux. The function of ioremap is to assign virtual addresses to physical memory regions on the device. This allows data that is important to a certain task to be stored in the same relative location even if there is not enough free continuous physical space on the device. The advantage of this is physical memory no longer has to go through address relocation calculations each time a task is performed.

During the mapping of virtual memory space, it is possible to change certain attributes of the memory, such as access types. Within the Xilinx GIT tree, there are multiple ioremap functions that users can use to map their memory, each having different attributes.

For example, in the arch/arm/include/asm/io.h header file the following ioremap functions exist:

249 #defineioremap(cookie,size)__arch_ioremap((cookie),(size),MT_DEVICE)
250 #defineioremap_nocache(cookie,size)__arch_ioremap((cookie),(size),MT_DEVICE)
251 #defineioremap_cached(cookie,size)__arch_ioremap((cookie),(size),MT_DEVICE_CACHED)
252 #defineioremap_wc(cookie,size)__arch_ioremap((cookie),(size),MT_DEVICE_WC)
253 #defineiounmap__arch_iounmap

The difference between these functions is the MT_DEVICE attributes which can be found in the arch/arm/mm/mmu.c file:

(Note: MT_DEVICE for pre-ARMv6 will have 'strongly ordered' memory and ARMv6/post-ARMv6 will have 'shared device' memory)

195 staticstructmem_typemem_types[]={
196 [MT_DEVICE]={/*ARMv6shareddevice*/
199 .prot_l1=PMD_TYPE_TABLE,
201 .domain=DOMAIN_IO,
202 },
209 [MT_DEVICE_CACHED]={/*ioremap_cached*/
211 .prot_l1=PMD_TYPE_TABLE,
213 .domain=DOMAIN_IO,
214 },
215 [MT_DEVICE_WC]={/*ioremap_wc*/
217 .prot_l1=PMD_TYPE_TABLE,
218 .prot_sect=PROT_SECT_DEVICE,
219 .domain=DOMAIN_IO,
220 },
276 };

Each instance of the ioremap function will allow for a different access type.

AR# 47662
Date 02/13/2013
Status Active
Type General Article
People Also Viewed