Invalidate Data Cache from User Space

Jonathan Haws Jonathan.Haws at sdl.usu.edu
Tue Nov 10 05:10:42 EST 2009


All,

I have a routine to invalidate the data cache from user space (since I do not believe there is a standard routine I can use outside of kernel space??).

Here is the code:

	.text;
	.globl cacheInvalidate405;
cacheInvalidate405:

      /*
       *   r3 = Data cache
       *   r4 = address
       *   r5 = number of bytes
       */

        cmpwi   r5,0                /* make sure number of bytes is > 0 */
        beq     invalDone
        add     r6,r4,r5
        addi    r6,r6,31
        rlwinm  r6,r6,0,0,26        /* end addr to start of next cache line */
        rlwinm  r7,r4,0,0,26        /* start address back to start of line  */
        sub     r6,r6,r7
        srawi   r6,r6,5             /* divide by 32 to get number of lines  */
        mtctr   r6
invalLoop:
        dcbi    r0,r4			/* THIS INSTRUCTION FAILS! */
        addi    r4,r4,32
        bdnz    invalLoop
        sync
invalDone:
        blr
.size	cacheInvalidate405, . - cacheInvalidate405

What is happening is the dcbi instruction will fail.  I get an Illegal Instruction message on the console and my program exits.

Is there a reason I cannot call dbci from a user space application, or is there something wrong in my code?  Even better, is there a working and tested function that I can call from user space to invalidate a portion of the data cache?

Thanks!

Jonathan




More information about the Linuxppc-dev mailing list