Mips_cache_lock () function
Hi everybody.
Hope this mail will not rejected for the disclaimer on bottom...Sorry but I cannot remove it...
I'm trying to port the current U-Boot on a proprietary mips4k little endian platform.
I've succeeded in booting to the u-boot console.
But I've got some relocation problems; it seems that some functions are still linked to the old address (e.g. flash_fill_sect_ranges() appears to be not relocated...)
I think that this hide bigger problems, so I'm trying to understand all the boot and relocation code to find what I'm doing wrong.
So, finally the question: how the mips_cache_lock () works?
It takes the address to lock from a0 (stored in start.S before calling), but instead of passing it to the (overcomplicated) icacheop, it performs some math on that address.
To me, it seems that it locks the last DCACHE_SIZE bytes of the stack.
Also, in a0 we store not an address, but the CFG_INIT_SP_OFFSET, so at least the mips_cache_lock comment is wrong.
Can somebody explain this function to me?
Many thanks,
Signature · 7 lines
Andrea Gimignani --------------------------------------------------------------- Mettiti al centro del mondo! Crea il tuo blog e condividi con i tuoi amici idee, immagini e video, da web e da cellulare! http://beta.dada.net/ ---------------------------------------------------------------
Quoted 11 lines · ilGimmy
So, finally the question: how the
mips_cache_lock() works?It takes the address to lock from a0 (stored in
start.Sbefore calling), but instead of passing it to the (overcomplicated) icacheop, it performs some math on that address.To me, it seems that it locks the last
DCACHE_SIZEbytes of the stack.Also, in a0 we store not an address, but the
CFG_INIT_SP_OFFSET, so at least themips_cache_lockcomment is wrong.
I believe what it's supposed to do is lock the entire d-cache to provide some usable
ram for a stack for C code. I don't think it works correctly, but I also think it doesn't
matter for the boards I know about (Au1x00 stuff). I know nothing about the mysterious
purple, tb0229, and inca_ip boards.
The code takes an offset from K0BASE for a stack pointer (not a physical address as
you pointed out) and subtracts the size (grow down stack) of the d-cache or 1/2 for the purple board and then tries to run a single lock d-cache op.
The trouble on the Au1550 is that cache lock is a per line operation, so it should
to iterate across the addresses it wants to lock, starting at a cache-aligned base
and using a cache-line sized stride. It doesn't matter because on Au1550 the dram
is already initialized by the lowlevel_init.S assembly code, so the one's that aren't
locked are passed to the ram that's already there. I also noticed that on the Au1x00
stuff it looks like the dcache line never gets unlocked (I did a very cursory scan - I
could have missed it).
In a general case MIPS requires the ram to be up and running before the cache because
some variants require the ram behind the cache to be zeroed to do a proper cache parity init.
For a more general handling of different types of caches for mips you can look at the
linux or netbsd cache stuff - it get's hairy very quickly because of all the variations.
Signature · 2 lines
Hardware, n.:
The parts of a computer system that can be kicked.