From 363baf34d92bbf8367b168a4d8b8ab88c5471b11 Mon Sep 17 00:00:00 2001 From: Kinjal Pravinbhai Patel Date: Thu, 23 Jul 2015 11:16:35 +0530 Subject: [PATCH] bsp: a53: xil_settlbattributes modified for addresses > 4GB This patch modifies xil_settlbattributes API to work with addresses > 4GB by modifying the address masking value appropriate for higher addresses lies beyond 4GB Signed-off-by: Kinjal Pravinbhai Patel Reviewed-by: Anirudha Sarangi --- .../standalone/src/cortexa53/64bit/xil_mmu.c | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/bsp/standalone/src/cortexa53/64bit/xil_mmu.c b/lib/bsp/standalone/src/cortexa53/64bit/xil_mmu.c index ceae6edf..a36bebc5 100644 --- a/lib/bsp/standalone/src/cortexa53/64bit/xil_mmu.c +++ b/lib/bsp/standalone/src/cortexa53/64bit/xil_mmu.c @@ -65,10 +65,15 @@ /************************** Constant Definitions *****************************/ +#define BLOCK_SIZE_2MB 0x200000U +#define BLOCK_SIZE_1GB 0x40000000U +#define ADDRESS_LIMIT_4GB 0x100000000UL + /************************** Variable Definitions *****************************/ extern INTPTR MMUTableL1; extern INTPTR MMUTableL2; + /************************** Function Prototypes ******************************/ /***************************************************************************** * @@ -88,18 +93,22 @@ void Xil_SetTlbAttributes(INTPTR Addr, u64 attrib) { INTPTR *ptr; INTPTR section; + u64 block_size; /* if region is less than 4GB MMUTable level 2 need to be modified */ - if(Addr<0x100000000){ - section = Addr / 0x00200000U; - ptr = &MMUTableL2 + section; - *ptr = (Addr & (~0x001FFFFFU)) | attrib; + if(Addr < ADDRESS_LIMIT_4GB){ + /* block size is 2MB for addressed < 4GB*/ + block_size = BLOCK_SIZE_2MB; + section = Addr / block_size; + ptr = &MMUTableL2 + section; } /* if region is greater than 4GB MMUTable level 1 need to be modified */ else{ - section = Addr / 0x40000000U; - ptr = &MMUTableL1 + section; - *ptr = (Addr & (~0x3FFFFFFFU)) | attrib; + /* block size is 1GB for addressed > 4GB */ + block_size = BLOCK_SIZE_1GB; + section = Addr / block_size; + ptr = &MMUTableL1 + section; } + *ptr = (Addr & (~(block_size-1))) | attrib; Xil_DCacheFlush(); mtcptlbi(ALLE3);