Disabling MPC5777C (remaining) data cache while keeping its stack there

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Disabling MPC5777C (remaining) data cache while keeping its stack there

2,187件の閲覧回数
ricardofranca
Contributor III

Hello,

 

I am following AN5191 guidance to boot a MPC5777C custom board and some of its built-in tests require me to disable the caches to perform some actions, then re-enable them for normal operation. Considering that I took half of the data cache to be my stack (using the AN5191 code based on dcbz and dcbtls instructions), how should I proceed to keep the stack working while disabling the rest of the data cache?

 

Thanks,

Ricardo

0 件の賞賛
返信
7 返答(返信)

2,134件の閲覧回数
ricardofranca
Contributor III

Hello David,

 

Is it possible to use L1FINV0[CCMD] to force CWAY to 0 for a 4KB stack? I was thinking about something like:

stack_cache_0:
mfpir r3
se_cmpi r3,0
se_bne stack_cache_1 /* this part is Core 0 only */
/* assuming a 4KB stack */
e_li r4,3 # will set L1FINV0[CWAY] = 0 and L1FINV0[CCMD] = 3
e_lis r5,__CPU0_STACK_SIZE@h
e_or2i r5,__CPU0_STACK_SIZE@l
se_srwi r5,5 # Shift the contents of R3 right by 5 bits (stack_size/32 = 128)
se_mtctr r5
e_lis r3,_cpu0_stack_end@h
e_or2i r3,_cpu0_stack_end@l
mtl1finv0 r4
lock_cache_loop_cpu0_way0:
dcbz r0,r3 # Establish address in cache for 32 bytes and zero
dcbtls 0,r0,r3 # Lock the address into the cache
se_addi r3,32 # Increment to start of next cache line (+32 bytes)
e_bdnz lock_cache_loop_cpu0_way0 # Decrement the counter (CTR), branch if nonzero

 

But I don't know how to be sure my stack is where I think it is.

 

Thanks!

0 件の賞賛
返信

2,118件の閲覧回数
davidtosenovjan
NXP TechSupport
NXP TechSupport
 

At init, it is supposed to invalidate all. It also forces replacement counter to way 0. Then you may lock lines for cache.

image.png

0 件の賞賛
返信

2,076件の閲覧回数
ricardofranca
Contributor III

Hi David,

 

Am I right to assume that if I set L1FINV0[CCMD] to 3, it will force the way replacement counter to the value I specify in L1FINV0[CWAY] without performing any flush/invalidation?

 

Thanks!

0 件の賞賛
返信

2,073件の閲覧回数
davidtosenovjan
NXP TechSupport
NXP TechSupport

I can neither confirm nor deny this. It doesn't come out of any description.

0 件の賞賛
返信

2,061件の閲覧回数
ricardofranca
Contributor III

I thought this use of L1FINV0 would not invalidate anything because the description of L1FINV0[CCMD] provides details of invalidation/flushing for all cache commands except this one:

 

CCMD.png

 

 

 

In any case, what happens if I try to invalidate a locked cache line?

Thanks!

 

 

0 件の賞賛
返信

2,040件の閲覧回数
davidtosenovjan
NXP TechSupport
NXP TechSupport

I see. You are right apparently.

The ICINV/DCINV Flash invalidation invalidates ALL cache, locked lines are also invalidated using this, but ICLFC/DCLFC will not be altered by the invalidation action, so to clear the Lock Bits the software must write this bit. You will end up with an invalid line which is locked if you just do the invalidate operation with this register.

The icbi cache instructions invalidates and unlocks a cache lines in the L1 ICache.

0 件の賞賛
返信

2,175件の閲覧回数
davidtosenovjan
NXP TechSupport
NXP TechSupport

The ICINV/DCINV Flash invalidation invalidates ALL cache, locked lines are also invalidated using this, but ICLFC/DCLFC will not be altered by the invalidation action, so to clear the Lock Bits the software must write this bit. You will end up with an invalid line which is locked if you just do the invalidate operation with this register.

The icbi cache instructions invalidates and unlocks a cache lines in the L1 ICache.

Pay attention to following presentation, slides 115-139, showing detailed description of cache instructions and also some code examples:

https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/e200-Core-Training-relevant-to-MPC55xx-and-MPC56...

 

0 件の賞賛
返信