Hi everyone, I am trying to make data cache to be used as ram in mpc5777c for that purpose I've invalidated and enable the dcache in copy back mode, then I've created a tlb entry at address 0x40040000 and set it as cacheable
The dcache code goes like this:
.section .text
.global assemblyFunction
assemblyFunction:
cfg_DCACHE:
/*--------------------------------------------#
# Invalidate - Set CINV #
# e_bit in L1CSR0 Register #
#--------------------------------------------*/
e_li r5, 0x0000
e_ori r5, r5, 0x0002
msync
isync
mtspr 1010,r5
/*-------------------------------------------#
# Mask out CINV and CAbT to see if #
# invalidation is complete (i.e. CINV=0, #
# CAbT=0) #
#-------------------------------------------*/
label_DCINV_check:
/*-------------------------------------------#
# Load Registers with Masks: #
# Load CINV mask into R8 #
# Load CAbT mask into R7 #
# Load CAbT clear mask into R11 #
#-------------------------------------------*/
e_li r8, 0x0000
e_ori r8, r8, 0x0002
e_li r7, 0x0000
e_ori r7, r7, 0x0004
e_li r11, 0xFFFF
e_or2i r11, 0xFFFB
CHECK_DCINV:
/*-------------------------------------------#
# Read 1010 register, store in r9 #
#-------------------------------------------*/
mfspr r9, 1010
/*-------------------------------------------#
# check for an Ae_bORT of the cache invalidate #
# operation #
#-------------------------------------------*/
and. r10, r7, r9
e_beq D_NO_ABORT
/*-------------------------------------------#
# If ae_bort detected, clear CAe_bT e_bit and #
# re-run invalidation #
#-------------------------------------------*/
and. r10, r11, r9
msync
isync
mtspr 1010, r10
e_b cfg_DCACHE
D_NO_ABORT:
/*-------------------------------------------#
# Check that invalidation has completed - #
# (CINV=0). branch if invalidation not #
# complete. #
#-------------------------------------------*/
and. r10, r8, r9
e_bne CHECK_DCINV
/*-------------------------------------------#
# Enable cache by performing a #
# read/modify/write of the CE bit in the #
# 1010 register #
#-------------------------------------------*/
mfspr r5, 1010
e_ori r5, r5, 0x0000
e_ori r5, r5, 0x0001 /* Store 1010 value to R5 (CE=1) */
msync
isync
mtspr 1010, r5 /* Write R5 to 1010 register */
/*-------------------------------------------#
# Enable cache by performing a #
# read/modify/write of the DCWM bit in the #
# 1010 register #
#-------------------------------------------*/
mfspr r5, 1010
e_add2is r5,0x0010 /* Store 1010 value to R5 (DCWM=1) */
msync
isync
mtspr 1010, r5 /* Write R5 to 1010 register */
e_li r3, 0x80 /* Load r3 with loop count = 4KB/32B = 128 = 0x80 */
mtCTR r3 /* Move loop count to spr CTR */
e_li r3, 0x4004 /* Point r3 to start of desired address (r3=0x40040000)*/
LockingLoop:
dcbz r0, r3 /* Establish address in cache for 32B cache line of 0's */
dcbtls 0, r0, r3 /* Lock that line in cache */
e_addi r3, r3, 0x20 /* Increment address pointer by 32 B */
e_bdnz LockingLoop
se_blr
the tlb entry is:
e_lis r3, 0x1005 /* Select TLB entry #, define R/W replacment control */
mtspr 624, r3 /* Load MAS0 with 0x1006 0000 for TLB entry #6 */
/* Define description context and configuration control:*/
/* VALID=1, IPROT=0, TID=0, TS=0, TSIZE=1 (4KB size) */
e_lis r3, 0x8000 /* Load MAS 1 with 0x8000 0100 */
e_ori r3, r3, 0x0100
mtspr 625, r3
/* Define EPN and page attributes: */
/* EPN = 0x4004 0000, WIMAGE = all 0's */
e_lis r3, 0x4004 /* Load MAS2 with 0x4004 0000 */
mtspr 626, r3
/* Define RPN and access control for data R/W */
/* RPN = 0x4004 0000, U0:3=0, UX/SX=0, UR/SR/UW/SW=1 */
e_lis r3, 0x4004 /* Load MAS3 with 0x4004 000F */
e_ori r3, r3, 0x003F
mtspr 627, r3
tlbwe
After doing all this I dont see any difference though when writing at memory address 0x40040000 nothing happens even after removing the tlb I dont see any change.
I've changed the memory to 0x40040000 just for checking the data is written on the ram but not in the dcache (I am using trace32 as debugger) the dcache shows nothing but 0 as defined in the dcache code.
BR,
Indra